|||
s3c2440 linux lcd驱动解读
驱动层即s3c2410fb.c定义platform_driver 如下面文件定义了s3c2410fb_driver:
\linux\linux-2.6.29\drivers\video\S3c2410fb.c
static struct platform_driver s3c2410fb_driver = {
.probe = s3c2410fb_probe,
.remove = s3c2410fb_remove,
.suspend = s3c2410fb_suspend,
.resume = s3c2410fb_resume,
.driver = {
.name = "s3c2410-lcd",
.owner = THIS_MODULE,
},
};
plat层定义device, 如下面文件定义了 s3c_device_lcd
\linux\linux-2.6.29\arch\arm\plat-s3c24xx\Devs.c
struct platform_device s3c_device_lcd = {
.name = "s3c2410-lcd",
.id = -1,
.num_resources = ARRAY_SIZE(s3c_lcd_resource),
.resource = s3c_lcd_resource,
.dev = {
.dma_mask = &s3c_device_lcd_dmamask,
.coherent_dma_mask = 0xffffffffUL
}
};
因为内核配置是针对s3c2440芯片的, s3c2440自带lcd控制器,因此内核已经知道有s3c_device_lcd这个device存在, 驱动为device服务,driver通过
platform_driver_register(&s3c2410fb_driver)
告诉内核驱动的存在,内核根据 driver.name 找到 device, 然后把device的信息通过 platform_device *pdev 这个参数传递给driver下挂着的各个功能函数,从而使驱动完成使命.
驱动函数s3c24xxfb_probe 所引用到的参数 mach_info, 即pdev->dev.platform_data 在 mach-mini2440.c里定义如下
static struct s3c2410fb_mach_info mini2440_fb_info __initdata = {
.displays = &mini2440_lcd_cfg,
.num_displays = 1,
.default_display = 0,
.gpccon = 0xaa955699,
.gpccon_mask = 0xffc003cc,
.gpcup = 0x0000ffff,
.gpcup_mask = 0xffffffff,
.gpdcon = 0xaa95aaa1,
.gpdcon_mask = 0xffc0fff0,
.gpdup = 0x0000faff,
.gpdup_mask = 0xffffffff,
.lpcsel = 0xf82,
};
驱动根据 lcd device 信息建立一块buffer, 然后把这块buffer作为一个设备通过 ret = register_buffer(fbinfo) 注册到linux设备管理系统中, linux在 /dev 下生成一个叫 fb 的节点, GUI就对这个 fb 节点操作.
详见网文
http://blog.chinaunix.net/u1/57747/showart_1073860.html
http://blog.chinaunix.net/u1/57747/showart.php?id=1074059