内核里已经有很完善的 LCD 驱动了,只要根据所用的 LCD 进行简单的修改。
#vi arch/arm/mach-s3c2440/mach-smdk2440.c

修改smdk2440_lcd_cfg函数和smdk2440_fb_info函数,设置LCD参数,我的是SONY3.5寸(X35)TFT屏。如下:

参照mini2440源码:

首先定义:

  1. #define LCD_WIDTH 240
  2. #define LCD_HEIGHT 320
     
  3. #define LCD_PIXCLOCK 170000
     
  4. #define LCD_RIGHT_MARGIN 25
     
  5. #define LCD_LEFT_MARGIN 0
     
  6. #define LCD_HSYNC_LEN 4
     
  7. #define LCD_UPPER_MARGIN 0
     
  8. #define LCD_LOWER_MARGIN 4
     
  9. #define LCD_VSYNC_LEN 9
     
  10. #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函数。

  1. static struct s3c2410fb_display mini2440_lcd_cfg __initdata = {

  2.  
  3. #if !defined (LCD_CON5)
     
  4.     .lcdcon5 = S3C2410_LCDCON5_FRM565 |
     
  5.               S3C2410_LCDCON5_INVVLINE |
     
  6.               S3C2410_LCDCON5_INVVFRAME |
     
  7.               S3C2410_LCDCON5_PWREN |
     
  8.               S3C2410_LCDCON5_HWSWP,
     
  9. #else
     
  10.     .lcdcon5 = LCD_CON5,
     
  11. #endif
     

  12.  
  13.     .type = S3C2410_LCDCON1_TFT,
     

  14.  
  15.     .width = LCD_WIDTH,
     
  16.     .height = LCD_HEIGHT,
     

  17.  
  18.     .pixclock = LCD_PIXCLOCK,
     
  19.     .xres = LCD_WIDTH,
     
  20.     .yres = LCD_HEIGHT,
     
  21.     .bpp = 16,
     
  22.     .left_margin = LCD_LEFT_MARGIN + 1,
     
  23.     .right_margin = LCD_RIGHT_MARGIN + 1,
     
  24.     .hsync_len = LCD_HSYNC_LEN + 1,
     
  25.     .upper_margin = LCD_UPPER_MARGIN + 1,
     
  26.     .lower_margin = LCD_LOWER_MARGIN + 1,
     
  27.     .vsync_len = LCD_VSYNC_LEN + 1,
     
  28. };

 

  1. static struct s3c2410fb_mach_info mini2440_fb_info __initdata = {
  2.     .displays = &mini2440_lcd_cfg,
     
  3.     .num_displays = 1,
     
  4.     .default_display = 0,
     

  5.  
  6.     .gpccon = 0xaa955699,
     
  7.     .gpccon_mask = 0xffc003cc,
     
  8.     .gpcup = 0x0000ffff,
     
  9.     .gpcup_mask = 0xffffffff,
     

  10.  
  11.     .gpdcon = 0xaa95aaa1,
     
  12.     .gpdcon_mask = 0xffc0fff0,
     
  13.     .gpdup = 0x0000faff,
     
  14.     .gpdup_mask = 0xffffffff,
     

  15.  

  16.  
  17.     .lpcsel = 0xf82,
     
  18. };

打开LCD的背光,如不打开就无法观测LCD是否正常工作。由开发板原理图可以看到LCD的背光电源LCD_PWR接到S3C2440的GPG4引脚上,故在mach-smdk2440.c中作如下修改:

  1. static void __init smdk2440_machine_init(void)
  2. {
     
  3.     s3c24xx_fb_set_platdata(&smdk2440_fb_info);
     

  4.  
  5.     //添加下面两句代码
  6.     s3c2410_gpio_cfgpin(S3C2410_GPG(4), S3C2410_GPIO_OUTPUT);
  7.     s3c2410_gpio_setpin(S3C2410_GPG(4),1);
     

  8.  
  9.     s3c_i2c0_set_platdata(NULL);
     
  10.     platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));
     
  11.     smdk_machine_init();
     
  12. }

linux-2.6.32以上版本需要在mach-smdk2440.c中加入头文件,否则提示找不到函数。

  1. #include <linux/gpio.h>

配置内核,支持 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
 


 

板子启动后,查看硬件信息:

 

  1. cat /proc/devices

 

可以看到:29 fb

 

  1. mknod /dev/fb0 c 29 0

转载来自http://hqpp.chinaunix.com/space.php?uid=20788517&do=blog&id=34707