内核里已经有很完善的 LCD 驱动了,只要根据所用的 LCD 进行简单的修改。
#vi arch/arm/mach-s3c2440/mach-smdk2440.c
修改smdk2440_lcd_cfg函数和smdk2440_fb_info函数,设置LCD参数,我的是SONY3.5寸(X35)TFT屏。如下:
参照mini2440源码:
首先定义:
- #define LCD_WIDTH 240
- #define LCD_HEIGHT 320
- #define LCD_PIXCLOCK 170000
- #define LCD_RIGHT_MARGIN 25
- #define LCD_LEFT_MARGIN 0
- #define LCD_HSYNC_LEN 4
- #define LCD_UPPER_MARGIN 0
- #define LCD_LOWER_MARGIN 4
- #define LCD_VSYNC_LEN 9
- #define LCD_CON5 (S3C2410_LCDCON5_FRM565 | S3C2410_LCDCON5_INVVDEN | S3C2410_LCDCON5_INVVFRAME | S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVCLK | S3C2410_LCDCON5_HWSWP )
然后修改smdk2440_lcd_cfg函数和smdk2440_fb_info函数。
- static struct s3c2410fb_display mini2440_lcd_cfg __initdata = {
- #if !defined (LCD_CON5)
- .lcdcon5 = S3C2410_LCDCON5_FRM565 |
- S3C2410_LCDCON5_INVVLINE |
- S3C2410_LCDCON5_INVVFRAME |
- S3C2410_LCDCON5_PWREN |
- S3C2410_LCDCON5_HWSWP,
- #else
- .lcdcon5 = LCD_CON5,
- #endif
- .type = S3C2410_LCDCON1_TFT,
- .width = LCD_WIDTH,
- .height = LCD_HEIGHT,
- .pixclock = LCD_PIXCLOCK,
- .xres = LCD_WIDTH,
- .yres = LCD_HEIGHT,
- .bpp = 16,
- .left_margin = LCD_LEFT_MARGIN + 1,
- .right_margin = LCD_RIGHT_MARGIN + 1,
- .hsync_len = LCD_HSYNC_LEN + 1,
- .upper_margin = LCD_UPPER_MARGIN + 1,
- .lower_margin = LCD_LOWER_MARGIN + 1,
- .vsync_len = LCD_VSYNC_LEN + 1,
- };
- 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的背光,如不打开就无法观测LCD是否正常工作。由开发板原理图可以看到LCD的背光电源LCD_PWR接到S3C2440的GPG4引脚上,故在mach-smdk2440.c中作如下修改:
- static void __init smdk2440_machine_init(void)
- {
- s3c24xx_fb_set_platdata(&smdk2440_fb_info);
- //添加下面两句代码
- s3c2410_gpio_cfgpin(S3C2410_GPG(4), S3C2410_GPIO_OUTPUT);
- s3c2410_gpio_setpin(S3C2410_GPG(4),1);
- s3c_i2c0_set_platdata(NULL);
- platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));
- smdk_machine_init();
- }
linux-2.6.32以上版本需要在mach-smdk2440.c中加入头文件,否则提示找不到函数。
配置内核,支持 LCD:
Device Drivers:
Graphics Support --->
<*>support for frame buffer devices --->
[*] Enable frameware EDID
[*] Enable Vidoe Mode Handling Helpers
<*> S3C24X0 LCD framebuffer support
Console display driver support --->
<*> Framebuffer Console Support
[*] Bootup Logo --->
<*> Standard 224-color Linux logo
启动时LCD上显示可爱的小企鹅,终端输出:
Console: switching to colour frame buffer device 40x30
fb0: s3c2410fb frame buffer device
板子启动后,查看硬件信息:
可以看到:29 fb
阅读(3668) | 评论(0) | 转发(1) |