参考:S3C2440 LCD驱动(FrameBuffer)实例开发<一>
S3C2440 LCD驱动(FrameBuffer)实例开发<二>
1.平台设备注册
1.1在linux/arch/arm/plat-samsung/dev-fb.c中定义平台设备。
static struct resource s3c_fb_resource[] = {
[] = {
.start = S3C_PA_FB,
.end = S3C_PA_FB + SZ_16K - ,
.flags = IORESOURCE_MEM,
},
[] = {
.start = IRQ_LCD_VSYNC,
.end = IRQ_LCD_VSYNC,
.flags = IORESOURCE_IRQ,
},
[] = {
.start = IRQ_LCD_FIFO,
.end = IRQ_LCD_FIFO,
.flags = IORESOURCE_IRQ,
},
[] = {
.start = IRQ_LCD_SYSTEM,
.end = IRQ_LCD_SYSTEM,
.flags = IORESOURCE_IRQ,
},
}; struct platform_device s3c_device_fb = {
.name = "s3c-fb",
.id = -,
.num_resources = ARRAY_SIZE(s3c_fb_resource),
.resource = s3c_fb_resource,
.dev.dma_mask = &s3c_device_fb.dev.coherent_dma_mask,
.dev.coherent_dma_mask = 0xffffffffUL,
};
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中注册平台驱动。
static struct platform_driver s3cfb_driver = {
.probe = s3cfb_probe,
.remove = s3cfb_remove,
.suspend = s3cfb_suspend,
.resume = s3cfb_resume,
.driver = {
.name = "s3c-fb",
.owner = THIS_MODULE,
},
}; int __devinit s3cfb_init(void)
{
return platform_driver_register(&s3cfb_driver);
}
3. 当平台设备与驱动匹配后,调用s3cfb_probe()函数,调用register_framebuffer()函数。
static int __init s3cfb_probe(struct platform_device *pdev)
-->register_framebuffer()//在/dev/目录下创建fb*设备节点