platform设备驱动(Linux驱动4)
来源:互联网 发布:android 珍藏源码 编辑:程序博客网 时间:2024/05/20 00:51
说明:
platform是Linux中总线的一种,与i2c,pci,isa一样.但是它并非实际存在,而是虚拟出来的,用于将soc中的外围器件挂接在这个总线中.
linux中的驱动包括总线,设备,设备驱动三个实体,总线将设备和驱动绑定.platform总线的驱动是platform_driver,设备是platform_device.
总线的match函数就是将驱动与设备的名字加以比较,相等认为匹配上了.
变量:
device_private{
..
void * driver_data;
}
device {
device_private *p;//设备的私有数据
void* platform_data;//平台设备数据
。。。
}
platform_device {
char *name;
u32 id;
struct device dev;
u32 num_resourecs;
struct resource *resource;
}
如果资源文件中的描述不够,可以在dev中的platform_data中自定义数据
device_driver{ char * name;//描述驱动名称 struct module *owner; ... } platform_driver{ probe remove shutdown suspend ... struct device_driver driver; } bus_type{ name dev_attrs match uevent pm } resource{ start end name flags resourec *parent,*sibling,*child; } flags:IORESOURCE_IO,IORESORECE_MEM,IORESOURCE_DMA...
函数:
platform_driver_register(platform_driver*)
platform_driver_unregister(platform_driver*)
platform_get_resource(platform_device *dev,flags,num)
platform_set_drvdata(platform_device*pdev,void *);
platform_get_drvdata(platform_device *pdev);
用法
xx_probe(struct platform_device *dev)
{
register_chrdev_region
alloc_chrdev_region
cdev_init
cdev_add
…
}
xx_remove(struct platform_device *dev)
{
cdev_del();
unregister_chrdev_region();
…
}
platform_driver xx_driver={
.probe=xx_probe;
.remove=xx_remove
.driver={
.name=”xxdevice”
.owner=THIS_MODULE;
}
}
platform_device xx_device={
.name=”xxdevice”;
.id=-1;
…
}
xx_init()
{
platform_driver_register(&xx_driver);
}
xx_exit()
{
platform_driver_unregister(&xx_driver);
}
- platform设备驱动(Linux驱动4)
- linux Platform设备驱动
- linux ------ Platform设备驱动
- linux Platform设备驱动
- linux PlatForm设备驱动
- [Linux]Platform设备驱动
- linux platform平台设备驱动
- linux platform平台设备驱动 .
- Linux驱动---------platform总线设备
- Linux-Platform 字符设备驱动
- Linux之platform设备驱动
- Linux中Platform设备驱动
- linux驱动中platform设备驱动模型
- 基于linux驱动设备-platform按键驱动
- Linux驱动基础:platform设备驱动
- Linux驱动-platform总线设备驱动
- linux驱动-- 平台设备驱动platform devices
- 【linux设备模型】之platform设备驱动
- virtualbox ubuntu16
- web设计趋势与潮流设计(2010)
- 关于JQuery.cookie的简单实用方法
- strstr(str1,str2) 函数用于判断字符串str2是否是str1的子串。如果是,则该函数返回str2在str1中首次出现的地址;否则,返回NULL。
- w3c标准
- platform设备驱动(Linux驱动4)
- 《PCL点云库学习&VS2010(X64)》Part 23 快速双边滤波算法之三线插值
- R语言的简单图的绘制
- java中使用akka手记一
- 以图搜图--感知哈希算法
- 使用Navicat进行ssh通道连接MySQL数据库
- 你看得懂的海明码校验和纠错原理
- 汽车租赁系统
- 华为oj初级 求最大连续bit数