在LCD驱动移植前先明白几个小知识。。。。。
帧缓冲 透明访问只要在显示缓冲区与显示点对应区域写入颜色值即可
帧缓冲驱动的功能就是分配一块内存作显存,然后设置LCD控制器的寄存器,LCD显示器就会不断从显存中获得数据,并显示在LCD屏上。
需要关注的几个重要参数:
Pixclock 像素刷新时钟
现在开始移植了
在BSP平台上添加LCD的平台设备(因为是platform总线型设备)linux/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
}
};
注册platform型设备时需要告诉内核它的资源这里给出LCD的资源包括内存资源和中断资源
static struct resources3c_lcd_resource[] = {
[0] = {
.start = S3C24XX_PA_LCD, //0x4D000000 从LCD寄存器1开始
.end =S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1, //0x4D000000 + 0x00100000
.flags = IORESOURCE_MEM, //0x00000200
},
[1] = {
.start = IRQ_LCD, //16+16
.end = IRQ_LCD,
.flags = IORESOURCE_IRQ, //0x00000400
}
};
然后我们需要在platform_device结构体数组中添加进上面的LCD设备
linux/arch/arm/mach-s3c2440/mach-tq2440.c
static structplatform_device *tq2440_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&s3c_device_rtc,
#ifdef CONFIG_DM9000
&s3c_device_dm9000,
#endif
&s3c_device_usbgadget,
&s3c_device_uda134x,
};
然后注册进去内核
platform_add_devices(tq2440_devices,ARRAY_SIZE(tq2440_devices));
接着还要给我们的LCD添加一些必要数据
s3c24xx_fb_set_platdata(&tq2440_fb_info);
上面的tq2440_fb_info实现方式如下
static structs3c2410fb_mach_info tq2440_fb_info __initdata = {
.displays =&tq2440_lcd_cfg,
.num_displays = 1,
.default_display = 0,
#ifdefined(CONFIG_FB_S3C24X0_TFT1024768)
/* currently setup by downloader */
.gpccon =0xaa955699,
.gpccon_mask =0xffc003cc,
.gpcup =0x0000ffff,
.gpcup_mask =0xffffffff,
.gpdcon =0xaa95aaa1,
.gpdcon_mask =0xffffffff,
.gpdup =0x0000faff,
.gpdup_mask =0xffffffff,
.lpcsel = 0xf82,
#endif
};
static structs3c2410fb_display tq2440_lcd_cfg __initdata = {
#ifdefined(CONFIG_FB_S3C24X0_TFT1024768)
.lcdcon5 =S3C2410_LCDCON5_FRM565 |
S3C2410_LCDCON5_HWSWP,
#else
.lcdcon5 =S3C2410_LCDCON5_FRM565 |
S3C2410_LCDCON5_INVVLINE |
S3C2410_LCDCON5_INVVFRAME|
S3C2410_LCDCON5_PWREN |
S3C2410_LCDCON5_HWSWP,
#endif
.type =S3C2410_LCDCON1_TFT,
#ifdefined(CONFIG_FB_S3C24X0_T240320)
.width = 240,
.height = 320,
.pixclock = 100000,/* HCLK 100 MHz, divisor 4 */
.setclkval = 0x4,
.xres = 240,
.yres = 320,
.bpp = 16,
/*以上函数由于可供选择的屏幕参数较多故只取部分*/
至此 LCD驱动最底层的工作算是完成了