开发板:jz2440 4.3吋
内核:Linux4.3.2
arch/arm/mach-s3c24xx/mach-smdk2440.c:
将源代码中的对应部分改为以下代码:
/* LCD driver info */
static struct s3c2410fb_display smdk2440_lcd_cfg __initdata = {
.lcdcon5 = S3C2410_LCDCON5_FRM565 |
S3C2410_LCDCON5_INVVLINE |
S3C2410_LCDCON5_INVVFRAME |
S3C2410_LCDCON5_PWREN |
S3C2410_LCDCON5_HWSWP,
.type = S3C2410_LCDCON1_TFT, //LCD类型,开发板用的是TFT,注意,不能用 S3C2410_LCDCON1_TFT16BPP
//S3C2410_LCDCON1_TFT16BPP是TFT的格式
.width = 480,
.height = 272,
//.pixclock = 166667, /* HCLK 60 MHz, divisor 10 */
.pixclock = 112493,
/*
pixclock的计算:
DOTCLK = fframe × (X + HBP + HFP+HSPW) × (Y + VBP + VFP+VSPW) //fframe是屏幕刷新频率
pixclock = 10^12/ DOTCLK=1012/ (fframe × (X + HBP + HFP+HSPW) × (Y + VBP + VFP+VSPW))
经过计算,本开发板的fframe为66hz左右,所以DOTCLK = 66*(480 + 2 + 2 + 4) * (272 + 2 + 2 )
pixclock = 10^12/DOTCLK = 112493;
*/
.xres = 480,
.yres = 272,
.bpp = 16,
.left_margin = 2,
.right_margin = 2,
.hsync_len = 40,
.upper_margin = 2,
.lower_margin = 2,
.vsync_len = 9,
};
static struct s3c2410fb_mach_info smdk2440_fb_info __initdata = {
.displays = &smdk2440_lcd_cfg,
.num_displays = 1,
.default_display = 0,
#if 1
/* currently setup by downloader */
.gpccon = 0xaaaaaaaa,
.gpccon_mask = 0xffffffff,
.gpcup = 0xffffffff,
.gpcup_mask = 0xffffffff,
.gpdcon = 0xaaaaaaaa,
.gpdcon_mask = 0xffffffff,
.gpdup = 0xffffffff,
.gpdup_mask = 0xffffffff,
#endif
//.lpcsel = ((0xCE6) & ~7) | 1<<4,
};
虽然修改了上述硬件相关的资源,但是发现LCD并不能工作(内核已经配置LCD支持)
修改源码,支持启动背光灯和LCD_PWREN
在smdk2440_machine_init中添加:
writel((readl(S3C2410_GPBCON) & ~(3)) | 1, S3C2410_GPBCON);
writel((readl(S3C2410_GPBDAT) | 1), S3C2410_GPBDAT);
writel((readl(S3C2410_GPGCON) | (3<<8)), S3C2410_GPGCON);
如果编译不通过的话添加相应头文件,好像是#include <asm/io.h>
测试:
修改开发板上的
vi /etc/inittab
添加:
tty1::askfirst:-/bin/sh
重启,如果发现开发板的LCD出现Please press Enter to activate this console.即移植成功。
Linux内核4.2已经发布–附安装说明:http://www.linuxdiyf.com/linux/13682.html
在Ubuntu中如何安装或升级Linux内核到4.2:http://www.linuxdiyf.com/linux/13724.html
嵌入式Linux工控板的LCD驱动应用示例:http://www.linuxdiyf.com/linux/8523.html