| struct platform_device { const char * name; //设备名称 int id; struct device dev; u32 num_resources; //设备使用各类资源的数量 struct resource * resource; //设备使用的资源 struct platform_device_id *id_entry; }; |
| * RTC */ static struct resource s3c_rtc_resource[] = { //定义了RTC平台设备使用的资源,这些资源在驱动中都会用到 [0] = { //IO端口资源范围 .start = S3C24XX_PA_RTC, .end = S3C24XX_PA_RTC + 0xff, .flags = IORESOURCE_MEM, }, [1] = { //RTC报警中断资源 .start = IRQ_RTC, .end = IRQ_RTC, .flags = IORESOURCE_IRQ, }, [2] = { //TICK节拍时间中断资源 .start = IRQ_TICK, .end = IRQ_TICK, .flags = IORESOURCE_IRQ } }; struct platform_device s3c_device_rtc = { //定义了RTC平台设备 .name = "s3c2410-rtc", //设备名称 .id = -1, .num_resources = ARRAY_SIZE(s3c_rtc_resource), //资源数量 .resource = s3c_rtc_resource, //引用上面定义的资源 }; EXPORT_SYMBOL(s3c_device_rtc); |
| static struct platform_device *smdk2440_devices[] __initdata = { &s3c_device_usb, &s3c_device_lcd, &s3c_device_wdt, &s3c_device_i2c0, &s3c_device_iis,DE> &s3c_device_rtc, //这里我们添加上RTC平台设备,默认是没添加的 }; //平台设备列表,也就是说我们要使用一个新的平台设备要先在上面定义,然后加到这个列表中,最后到驱动层去实现该设备的驱动 static void __init smdk2440_machine_init(void) { s3c24xx_fb_set_platdata(&smdk2440_fb_info); s3c_i2c0_set_platdata(NULL); //将上面列表中的平台设备添加到系统总线中 platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices)); smdk_machine_init(); } |