移植环境
BootLoader:u-boot-1.1.6
kernel:linux-2.6.30.4
CPU:s3c2440
开发板:TQ2440
LCD:TFT480*272
参考资料:《天嵌Linux移植手册》
移植步骤
1、修改LCD时钟计算方法
内核源码的“drivers/video/s3c2410fb.c”文件,就是 LCD 的驱动源码。修改“drivers/video/s3c2410fb.c”文件
static void s3c2410fb_activate_var(struct fb_info *info)
{
struct s3c2410fb_info *fbi = info->par;
void __iomem *regs = fbi->io;
int type = fbi->regs.lcdcon1 & S3C2410_LCDCON1_TFT;
struct fb_var_screeninfo *var = &info->var;
struct s3c2410fb_mach_info *mach_info = fbi->dev->platform_data;
struct s3c2410fb_display *default_display = mach_info->displays +
mach_info->default_display;
int clkdiv = s3c2410fb_calc_pixclk(fbi, var->pixclock) / 2;
dprintk("%s: var->xres = %dn", __FUNCTION__, var->xres);
dprintk("%s: var->yres = %dn", __FUNCTION__, var->yres);
dprintk("%s: var->bpp = %dn", __FUNCTION__, var->bits_per_pixel);
if (type == S3C2410_LCDCON1_TFT) {
s3c2410fb_calculate_tft_lcd_regs(info, &fbi->regs);
--clkdiv;
if (clkdiv < 0)
clkdiv = 0;
} else {
s3c2410fb_calculate_stn_lcd_regs(info, &fbi->regs);
if (clkdiv < 2)
clkdiv = 2;
}
// fbi->regs.lcdcon1 |= S3C2410_LCDCON1_CLKVAL(clkdiv);
fbi->regs.lcdcon1 |= S3C2410_LCDCON1_CLKVAL(default_display->setclkval);
/* write new registers */
完成了这部分修改之后,在 s3c2410fb_display 结构体中添加了一个 setclkval 的变量,那么需要在该结构体的原型中添加上该变量,修改Linux-2.6.30.4 的“arch/arm/mach-s3c2410/include/mach/fb.h”文件,添加如下内容:
/* LCD description */
struct s3c2410fb_display {
/* LCD type */
unsigned type;
/* Screen size */
unsigned short width;
unsigned short height;
/* Screen info */
unsigned short xres;
unsigned short yres;
unsigned short bpp;
unsigned pixclock; /* pixclock in picoseconds */
unsigned setclkval; /* clkval */
unsigned short left_margin; /* value in pixels (TFT) or HCLKs (STN) */
unsigned short right_margin; /* value in pixels (TFT) or HCLKs (STN) */
unsigned short hsync_len; /* value in pixels (TFT) or HCLKs (STN) */
unsigned short upper_margin;/* value in lines (TFT) or 0 (STN) */
unsigned short lower_margin;/* value in lines (TFT) or 0 (STN) */
unsigned short vsync_len; /* value in lines (TFT) or 0 (STN) */
/* lcd configuration registers */
unsigned long lcdcon5;
};
2、修改LCD参数设置
然后修改 LCD 各个参数的配置,该配置参数在“arch/arm/mach-s3c2440/mach-smdk2440.c”文件中的由 107 行开始的结构体中,然后将其改为如下内容即可:
(注意:添加上刚刚添加的那个变量 setclkval 的赋值)
/* 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,
.width = 480,
.height = 272,
.pixclock = 40000, /* HCLK 100 MHz, divisor 1 */
.setclkval = 0x4,
.xres = 480,
.yres = 272,
.bpp = 16,
.left_margin = 19, /* for HFPD*/
.right_margin = 10, /* for HBPD*/
.hsync_len = 30, /* for HSPW*/
.upper_margin = 4, /* for VFPD*/
.lower_margin = 2, /* for VBPD*/
.vsync_len = 8, /* for VSPW*/
}
static struct s3c2410fb_mach_info smdk2440_fb_info __initdata = {
.displays = &smdk2440_lcd_cfg,
.num_displays = 1,
.default_display = 0,
#if 0
/* currently setup by downloader */
.gpccon = 0xaa940659,
.gpccon_mask = 0xffffffff,
.gpcup = 0x0000ffff,
.gpcup_mask = 0xffffffff,
.gpdcon = 0xaa84aaa0,
.gpdcon_mask = 0xffffffff,
.gpdup = 0x0000faff,
.gpdup_mask = 0xffffffff,
#endif
// .lpcsel = ((0xCE6) & ~7) | 1<<4,
};
然后修改“drivers/video/Kconfig”文件
config FB_S3C2410
tristate "S3C2410 LCD framebuffer support"
depends on FB && ARCH_S3C2410
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
---help---
Frame buffer driver for the built-in LCD controller in the Samsung
S3C2410 processor.
This driver is also available as a module ( = code which can be
inserted and removed from the running kernel whenever you want). The
module will be called s3c2410fb. If you want to compile it as a module,
say M here and read If unsure, say N. config FB_S3C2410_DEBUG bool "S3C2410 lcd debug messages" depends on FB_S3C24X0 help Turn on debugging messages. Note that you can set/unset at run time through sysfs 然后修改“drivers/video/Makefile”文件,把 109 行的内容改成如下所示: obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o 3、制作开机logo 首先需要在PC端下载GIMP软件,然后导入一张480*272的bmp图片. 图像->模式->索引,最大颜色数量为224 保存图片为ppm格式,数据类型为ASCII 开机logo就制作好了,将其替换“drivers/video/logo/logo_linux_clut224.ppm”文件 4、配置内核 Device Drivers —> Graphics support —> <* > Support for frame buffer devices —> [* ] Enable firmware EDID [* ] Enable Video Mode Handling Helpers *** Frame buffer hardware drivers *** < * > S3C2410 LCD framebuffer support <* > Framebuffer Console support [ * ] Bootup logo —> [ * ] Standard 224-color Linux logo 5、开机显示logo 配置完毕后,编译出内核镜像,烧写到 TQ2440 开发板中,启动系统时,就可以看到开机logo 的画面,这就表明 LCD 驱动完成了。
上一篇:LCD驱动移植之背光控制
下一篇:嵌入式驱动编写之简单驱动Hello_word
设计资源 培训 开发板 精华推荐
- NJM2706音效音频模块 低音增强 环绕增强 重制版
- 在 AD9279 的 I/Q 输出之后使用 ADA4896-2ARMZ 作为滤波器、I/V 转换器、电流加法器和 ADC 驱动器的典型应用电路
- 60W、19V AC 到 DC 单路输出电源,用于适配器 AC 到 DC 电源
- 适用于STM32F302R8 MCU的STM32 Nucleo-64开发板,支持Arduino和ST morpho连接
- LTC4095 的典型应用 - 采用 2mm x 2mm DFN 的独立 USB 锂离子/聚合物电池充电器
- C8051F800DK、8051 MCU 开发套件旨在用作 C8051F331 微控制器的开发平台
- 基于CH224K的PD 快充头 转接输出
- 带有压力、湿度和温度传感的智能风门控制参考设计
- xmas_tree_usb_base:两节AAA电池输出5V USB的DCDC功能板
- LTC2291IUP 演示板,DeMUX 双路 ADC,+3.0V,25Msps 12 位 1MHz