Chinaunix首页 | 论坛 | 博客
  • 博客访问: 627054
  • 博文数量: 121
  • 博客积分: 8469
  • 博客等级: 中将
  • 技术积分: 1065
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-03 10:32
文章分类

全部博文(121)

文章存档

2013年(1)

2012年(15)

2010年(2)

2009年(8)

2008年(95)

我的朋友

分类: LINUX

2008-07-17 09:15:45

以PXA2XX处理器为例
linux用platform_device 结构体来描述"虚拟总线platform"设备:
struct platform_device {
const char * name;
u32 id;
struct device dev;
u32 num_resources;
struct resource * resource;
};

比如mainstone.c中网卡的platform_device
static struct platform_device smc91x_device = {
    .name        = "smc91x",
    .id        = 0,
    .num_resources    = ARRAY_SIZE(smc91x_resources),
    .resource    = smc91x_resources,
};

generic.c中初始化devices数组
static struct platform_device *devices[] __initdata = {
    &pxamci_device,
    &udc_device,
    &pxafb_device,
    &ffuart_device,
    &btuart_device,
    &stuart_device,
};

内核初始化时调用platform_add_devices
static int __init pxa_init(void)
{
    return platform_add_devices(devices, ARRAY_SIZE(devices));
}
ARRAY_SIZE(devices)获得devices数组的大小,platform_add_devices遍历数组中的devices结构指针来添加设备。
阅读(1876) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~