以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结构指针来添加设备。
阅读(1904) | 评论(0) | 转发(0) |