LCD驱动分析(二)帧缓冲设备作为平台设备
参考:S3C2440 LCD驱动(FrameBuffer)实例开发<一>
S3C2440 LCD驱动(FrameBuffer)实例开发<二>
1.平台设备注册
1.1在linux/arch/arm/plat-samsung/dev-fb.c中定义平台设备。
1 static struct resource s3c_fb_resource[] = { 2 [0] = { 3 .start = S3C_PA_FB, 4 .end = S3C_PA_FB + SZ_16K - 1, 5 .flags = IORESOURCE_MEM, 6 }, 7 [1] = { 8 .start = IRQ_LCD_VSYNC, 9 .end = IRQ_LCD_VSYNC, 10 .flags = IORESOURCE_IRQ, 11 }, 12 [2] = { 13 .start = IRQ_LCD_FIFO, 14 .end = IRQ_LCD_FIFO, 15 .flags = IORESOURCE_IRQ, 16 }, 17 [3] = { 18 .start = IRQ_LCD_SYSTEM, 19 .end = IRQ_LCD_SYSTEM, 20 .flags = IORESOURCE_IRQ, 21 }, 22 }; 23 24 struct platform_device s3c_device_fb = { 25 .name = "s3c-fb", 26 .id = -1, 27 .num_resources = ARRAY_SIZE(s3c_fb_resource), 28 .resource = s3c_fb_resource, 29 .dev.dma_mask = &s3c_device_fb.dev.coherent_dma_mask, 30 .dev.coherent_dma_mask = 0xffffffffUL, 31 };
1.2 在linux/arch/arm/mach-s3c64xx/mach-smdk6410.c中定义的指针数组指向dev-fb.c中的平台设备并注册
static struct platform_device *smdk6410_devices[] __initdata = { ...... &s3c_device_fb, ...... }
static void __init smdk6410_machine_init(void)
-->s3c_fb_set_platdata(&smdk6410_lcd_pdata);
-->platform_add_devices(smdk6410_devices, ARRAY_SIZE(smdk6410_devices));
-->platform_device_register(&s3c_device_fb);
2. 在drivers/video/samsung/s3cfb.c中注册平台驱动。
1 static struct platform_driver s3cfb_driver = { 2 .probe = s3cfb_probe, 3 .remove = s3cfb_remove, 4 .suspend = s3cfb_suspend, 5 .resume = s3cfb_resume, 6 .driver = { 7 .name = "s3c-fb", 8 .owner = THIS_MODULE, 9 }, 10 }; 11 12 int __devinit s3cfb_init(void) 13 { 14 return platform_driver_register(&s3cfb_driver); 15 }
3. 当平台设备与驱动匹配后,调用s3cfb_probe()函数,调用register_framebuffer()函数。
static int __init s3cfb_probe(struct platform_device *pdev)
-->register_framebuffer()//在/dev/目录下创建fb*设备节点