开发板linux内核:linux-2.6.39
lcd型号:统宝 3.5 LCD
参考《mini2440 linux移植开发实战指南.pdf》
Linux-2.6.32.2 内核已经支持S3C2440 的LCD 控制器驱动,但在此我们先介绍一下关于2440 LCD控制器以及驱动相关的LCD 的一些基础知识。
注意:在此我们只讨论TFT LCD,也就是真彩屏。
LCD 驱动中最关键的就是时钟频率( Clock frequency) 的设置,时钟频率设置不对,LCD的显示就会闪,或者根本没有显示。一般LCD的Datasheet 上会写有一个推荐的频率,比如mini2440 所用的统宝3.5”LCD ,在它的数据手册第13页,有这样一个表格:
2、在linux-2.6.39/arch/arm/mach-s3c2440/mach-my2440.c 中修改对lcd控制寄存器的配置
-
/* LCD driver info */
-
#if defined(CONFIG_FB_S3C2410_N240320)
-
-
#define LCD_WIDTH 240
-
#define LCD_HEIGHT 320
-
#define LCD_PIXCLOCK 100000
-
-
#define LCD_RIGHT_MARGIN 36
-
#define LCD_LEFT_MARGIN 19
-
#define LCD_HSYNC_LEN 5
-
-
#define LCD_UPPER_MARGIN 1
-
#define LCD_LOWER_MARGIN 5
-
#define LCD_VSYNC_LEN 1
-
-
#elif defined(CONFIG_FB_S3C2410_W320240)
-
#define LCD_WIDTH 320
-
#define LCD_HEIGHT 240
-
#define LCD_PIXCLOCK 170000
-
-
#define LCD_RIGHT_MARGIN 0x44
-
#define LCD_LEFT_MARGIN 0x04
-
#define LCD_HSYNC_LEN 0x01
-
-
#define LCD_UPPER_MARGIN 10
-
#define LCD_LOWER_MARGIN 4
-
#define LCD_VSYNC_LEN 1
-
-
#define LCD_CON5 (S3C2410_LCDCON5_FRM565 | S3C2410_LCDCON5_INVVFRAME | S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_HWSWP )
-
-
#elif defined(CONFIG_FB_S3C2410_N480272)
-
-
#define LCD_WIDTH 480
-
#define LCD_HEIGHT 272
-
#define LCD_PIXCLOCK 100000
-
-
#define LCD_RIGHT_MARGIN 36
-
#define LCD_LEFT_MARGIN 19
-
#define LCD_HSYNC_LEN 5
-
-
#define LCD_UPPER_MARGIN 1
-
#define LCD_LOWER_MARGIN 5
-
#define LCD_VSYNC_LEN 1
-
-
#elif defined(CONFIG_FB_S3C2410_TFT640480)
-
#define LCD_WIDTH 640
-
#define LCD_HEIGHT 480
-
#define LCD_PIXCLOCK 40000
-
-
#define LCD_RIGHT_MARGIN 67
-
#define LCD_LEFT_MARGIN 40
-
#define LCD_HSYNC_LEN 31
-
-
#define LCD_UPPER_MARGIN 5
-
#define LCD_LOWER_MARGIN 25
-
#define LCD_VSYNC_LEN 1
-
-
#elif defined(CONFIG_FB_S3C2410_T240320)
-
#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 1
-
#define LCD_LOWER_MARGIN 4
-
#define LCD_VSYNC_LEN 1
-
#define LCD_CON5 (S3C2410_LCDCON5_FRM565 | S3C2410_LCDCON5_INVVDEN | S3C2410_LCDCON5_INVVFRAME | S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVCLK | S3C2410_LCDCON5_HWSWP )
-
-
#elif defined(CONFIG_FB_S3C2410_X240320)
-
#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 )
-
-
#elif defined(CONFIG_FB_S3C2410_TFT800480)
-
#define LCD_WIDTH 800
-
#define LCD_HEIGHT 480
-
#define LCD_PIXCLOCK 40000
-
-
#define LCD_RIGHT_MARGIN 67
-
#define LCD_LEFT_MARGIN 40
-
#define LCD_HSYNC_LEN 31
-
-
#define LCD_UPPER_MARGIN 25
-
#define LCD_LOWER_MARGIN 5
-
#define LCD_VSYNC_LEN 1
-
-
#elif defined(CONFIG_FB_S3C2410_VGA1024768)
-
#define LCD_WIDTH 1024
-
#define LCD_HEIGHT 768
-
#define LCD_PIXCLOCK 80000
-
-
#define LCD_RIGHT_MARGIN 15
-
#define LCD_LEFT_MARGIN 199
-
#define LCD_HSYNC_LEN 15
-
-
#define LCD_UPPER_MARGIN 1
-
#define LCD_LOWER_MARGIN 1
-
#define LCD_VSYNC_LEN 1
-
#define LCD_CON5 (S3C2410_LCDCON5_FRM565 | S3C2410_LCDCON5_HWSWP)
-
-
#endif
-
-
#if defined (LCD_WIDTH)
-
-
static struct s3c2410fb_display my2440_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 my2440_fb_info __initdata = {
-
.displays = &my2440_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,
-
};
-
-
#endif
3、
重新编译内核并下载到开发板上,上电系统启动后可以看到LCD亮起,并且出现小企鹅图标。
阅读(1356) | 评论(0) | 转发(0) |