这一篇主要参考博文,流程差不多,只是代码内容得自己写
http://5istt.com/cookies/blog/?post=122
《s5pv-u-boot-2011.06之增加LCD显示功能.PDF》的文档
其实我一直就只想学一点东西,当时心太大了,就直接买了Tiny4412,才发现这是一块硬骨头,网上资料少的可怜,FriendlyARM给的资料基本就是代码,说明性、讲原理的东西也没有。看了好久才发现其给的U-BOOT是不带LCD显示功能的,我就想给这个U-BOOT增加LCD显示功能,我所有的学习过程,都是为了增加LCD功能而开展的。这一篇虽然也有参考别人成份,但绝大多数内容都是我最近这段时间分析U-BOOT后,也进行相关裸机程序后(裸机代码的实现我有一篇相关的说明文档),有了一定的感觉,才顺利完成的。
下面依据《s5pv-u -boot-2011.06之增加LCD显示功能》的实现过程,来说明一下:我增加LCD功能的过程。
《s5pv-u-boot-2011.06之增加LCD显示功能》上说,其主要完成 U-Boot 层可以在 LCD 上显示字符,而且对于软件分层的 U-Boot 来说,只要将底层驱动移植过来并调整好初始化参数就可以在LCD上显示console。下图17-1是LCD 驱动软件分层执行流程示意。可以看到 LCD 在执行时最终调用的是底层的 board_video_init() 函数,其主要作用是对 LCD控制寄存器进行初始化。可由用户根据实际 LCD 硬件编写。
这个功能的移植修改了5 个文件。
图19-1、LCD 驱动软件分层执行流程示意
废话不多说,开始按步骤说明吧:
我用的U-Boot代码就是光盘中FriendlyARM提供的uboot_tiny4412-20130729.tgz。我的所有编辑操作都是在windows环境下,应用sourcein sight等工具进行的,最后才到linux环境下面进行编译。
复制LCD裸机程序下的字库文件,font_8x16.h,font_10x18.h,font_sun12x22.h到\uboot_tiny4412-lcd\include\下,这三个字库文件是从Linux源码下提取出来的。具体说明可参看我裸机LCD程序说明文档。
接着,在\uboot_tiny4412-lcd\include\目录下添加一个驱动程序所需的头文件,文件名为zth_tiny4412_lcd.h,此文件是从我的LCD裸机程序里复制过来的。zth_tiny4412_lcd.h内容如下,大家可以将其粘贴过去。
/****************************************
NAME:LCD.h
TRAD:
PROJECT:
CREATER:Zhang Taohua
DATA:2014-06-07
MAIL :[email protected]
DESCRIPTION:
*****************************************/
#ifndef __LCD_H
#define __LCD_H
extern void lcd_init(void);
extern void lcd_draw_pixel(introw, int col, int color);
extern void lcd_clear_screen(intcolor);
extern void lcd_draw_hline(introw, int col1, int col2, int color);
extern void lcd_draw_vline(intcol, int row1, int row2, int color);
extern void lcd_draw_cross(introw, int col, int halflen, int color);
extern void led_blink(intlink_times);
extern void delay(unsigned longcount);
extern void draw_point(int x, inty, int r, int g, int b);
//extern void memset_int(unsignedint * s, int c,unsigned int count);
extern void lcd_draw_bmp(constunsigned char gImage_bmp[]);
extern voidlcd_draw_char(unsigned char c);
#define readb(a) (*(volatile unsigned char*)(a))
#define readw(a) (*(volatile unsigned short*)(a))
#define readl(a) (*(volatile unsigned int*)(a))
#define writeb(v,a) (*(volatile unsigned char *)(a) = (v))
#define writew(v,a) (*(volatile unsigned short *)(a) =(v))
#define writel(v,a) (*(volatile unsigned int *)(a) = (v))
//FONT
//#define FONT8_16 1
//#define FONT10_18 1
#define FONT12_22 1
#define FONT_STATIC_ROW 8
#if FONT8_16
#define FONT_ROW 8
#define FONT_COL 16
#endif
#if FONT10_18
#define FONT_ROW 10
#define FONT_COL 18
#endif
#if FONT12_22
#define FONT_ROW 12
#define FONT_COL 22
#endif
//PICTURE
#define PICTURE_WIDTH
#define PICTURE_HEIGHT
//LCD Clock Relate Register
#define CLK_DIV_LCD (*(volatileunsigned int *)0x1003c534)
#define CLK_SRC_MASK_LCD(*(volatile unsigned int *)0x1003c334)
#define CLK_GATE_IP_LCD(*(volatile unsigned int *)0x1003c934)
#define CLK_SRC_LCD0 (*(volatileunsigned int *)0x1003c234)
//Framer Buffer Address And Size
//#define LCD_VIDEO_ADDR (0x54000000)
//#define VIDEO_MEM_SIZE 0x200000 /* 800x480x24bit =0X119400 bytes */
//LED IO Control Regiester
#define GPM4CON (*(volatile unsigned long *) 0x110002E0)
#define GPM4DAT (*(volatile unsigned long *) 0x110002E4)
//LCD OP Control Regiester
#define GPF0CON (*(volatile unsigned int *)0x11400180)
#define GPF0DAT (*(volatile unsigned int *)0x11400184)
#define GPF0PUD (*(volatile unsigned int *)0x11400188)
#define GPF0DRV (*(volatile unsigned int *)0x1140018C)
#define GPF1CON (*(volatile unsigned int *)0x114001a0)
#define GPF1DAT (*(volatileunsigned int *)0x114001a4)
#define GPF1PUD (*(volatile unsigned int *)0x114001a8)
#define GPF1DRV (*(volatile unsigned int *)0x114001ac)
#define GPF2CON (*(volatile unsigned int *)0x114001c0)
#define GPF2DAT (*(volatileunsigned int *)0x114001c4)
#define GPF2PUD (*(volatile unsigned int *)0x114001c8)
#define GPF2DRV (*(volatile unsigned int *)0x114001cc)
#define GPF3CON (*(volatile unsigned int *)0x114001e0)
#define GPF3DAT (*(volatileunsigned int *)0x114001e4)
#define GPF3PUD (*(volatile unsigned int *)0x114001e8)
#define GPF3DRV (*(volatile unsigned int *)0x114001ec)
#define LCDBLK_CFG (*(volatileunsigned int *)0x10010210)
#define LCDBLK_CFG2 (*(volatileunsigned int *)0x10010214)
//LCD Control Register
#define LCD_BASE 0x11C00000
#define VIDCON0 (*(volatile unsigned int *)(LCD_BASE +0x0000))
#define VIDCON1 (*(volatile unsigned int *)(LCD_BASE +0x0004))
#define VIDCON2 (*(volatile unsigned int *)(LCD_BASE +0x0008))
#define VIDCON3 (*(volatile unsigned int *)(LCD_BASE +0x000C))
#define VIDTCON0 (*(volatile unsigned int *)(LCD_BASE +0x0010))
#define VIDTCON1 (*(volatile unsigned int *)(LCD_BASE +0x0014))
#define VIDTCON2 (*(volatile unsigned int *)(LCD_BASE +0x0018))
#define VIDTCON3 (*(volatile unsigned int *)(LCD_BASE +0x001C))
#define WINCON0 (*(volatile unsigned int *)(LCD_BASE +0x0020))
#define WINCON1 (*(volatile unsigned int *)(LCD_BASE +0x0024))
#define WINCON2 (*(volatile unsigned int *)(LCD_BASE +0x0028))
#define WINCON3 (*(volatile unsigned int *)(LCD_BASE + 0x002C))
#define WINCON4 (*(volatile unsigned int *)(LCD_BASE +0x0030))
#define SHADOWCON (*(volatile unsigned int *)(LCD_BASE +0x0034))
#define WINCHMAP2 (*(volatile unsigned int *)(LCD_BASE + 0x003C))
#define VIDOSD0A (*(volatile unsigned int *)(LCD_BASE +0x0040))
#define VIDOSD0B (*(volatile unsigned int *)(LCD_BASE +0x0044))
#define VIDOSD0C (*(volatile unsigned int *)(LCD_BASE +0x0048))
#define VIDOSD1A (*(volatile unsigned int *)(LCD_BASE +0x0050))
#define VIDOSD1B (*(volatile unsigned int *)(LCD_BASE +0x0054))
#define VIDOSD1C (*(volatile unsigned int *)(LCD_BASE +0x0058))
#define VIDOSD1D (*(volatile unsigned int *)(LCD_BASE +0x005C))
#define VIDOSD2A (*(volatile unsigned int *)(LCD_BASE +0x0060))
#define VIDOSD2B (*(volatile unsigned int *)(LCD_BASE +0x0064))
#define VIDOSD2C (*(volatile unsigned int *)(LCD_BASE +0x0068))
#define VIDOSD2D (*(volatile unsigned int *)(LCD_BASE +0x006C))
#define VIDOSD3A (*(volatile unsigned int *)(LCD_BASE +0x0070))
#define VIDOSD3B (*(volatile unsigned int *)(LCD_BASE +0x0074))
#define VIDOSD3C (*(volatile unsigned int *)(LCD_BASE +0x0078))
#define VIDOSD4A (*(volatile unsigned int *)(LCD_BASE +0x0080))
#define VIDOSD4B (*(volatile unsigned int *)(LCD_BASE +0x0084))
#define VIDOSD4C (*(volatile unsigned int *)(LCD_BASE +0x0088))
#define VIDW00ADD0B0 (*(volatile unsigned int *)(LCD_BASE +0x00A0))
#define VIDW00ADD0B1 (*(volatile unsigned int *)(LCD_BASE +0x00A4))
#define VIDW00ADD0B2 (*(volatile unsigned int *)(LCD_BASE +0x20A0))
#define VIDW01ADD0B0 (*(volatile unsigned int *)(LCD_BASE +0x00A8))
#define VIDW01ADD0B1 (*(volatile unsigned int *)(LCD_BASE +0x00AC))
#define VIDW01ADD0B2 (*(volatile unsigned int *)(LCD_BASE +0x20A8))
#define VIDW02ADD0B0 (*(volatile unsigned int *)(LCD_BASE +0x00B0))
#define VIDW02ADD0B1 (*(volatile unsigned int *)(LCD_BASE +0x00B4))
#define VIDW02ADD0B2 (*(volatile unsigned int *)(LCD_BASE +0x20B0))
#define VIDW03ADD0B0 (*(volatile unsigned int *)(LCD_BASE + 0x00B8))
#define VIDW03ADD0B1 (*(volatile unsigned int *)(LCD_BASE +0x00BC))
#define VIDW03ADD0B2 (*(volatile unsigned int *)(LCD_BASE +0x20B8))
#define VIDW04ADD0B0 (*(volatile unsigned int *)(LCD_BASE +0x00C0))
#define VIDW04ADD0B1 (*(volatile unsigned int *)(LCD_BASE +0x00C4))
#define VIDW04ADD0B2 (*(volatile unsigned int *)(LCD_BASE +0x20C0))
#define VIDW00ADD1B0 (*(volatile unsigned int *)(LCD_BASE +0x00D0))
#define VIDW00ADD1B1 (*(volatile unsigned int *)(LCD_BASE +0x00D4))
#define VIDW00ADD1B2 (*(volatile unsigned int *)(LCD_BASE +0x20D0))
#define VIDW01ADD1B0 (*(volatile unsigned int *)(LCD_BASE +0x00D8))
#define VIDW01ADD1B1 (*(volatile unsigned int *)(LCD_BASE +0x00DC))
#define VIDW01ADD1B2 (*(volatile unsigned int *)(LCD_BASE +0x20D8))
#define VIDW02ADD1B0 (*(volatile unsigned int *)(LCD_BASE +0x00E0))
#define VIDW02ADD1B1 (*(volatile unsigned int *)(LCD_BASE +0x00E4))
#define VIDW02ADD1B2 (*(volatile unsigned int *)(LCD_BASE +0x20E0))
#define VIDW03ADD1B0 (*(volatile unsigned int *)(LCD_BASE +0x00E8))
#define VIDW03ADD1B1 (*(volatile unsigned int *)(LCD_BASE +0x00EC))
#define VIDW03ADD1B2 (*(volatile unsigned int *)(LCD_BASE +0x20E8))
#define VIDW04ADD1B0 (*(volatile unsigned int *)(LCD_BASE + 0x00F0))
#define VIDW04ADD1B1 (*(volatile unsigned int *)(LCD_BASE +0x00F4))
#define VIDW04ADD1B2 (*(volatile unsigned int *)(LCD_BASE +0x20F0))
#define VIDW00ADD2 (*(volatile unsigned int *)(LCD_BASE +0x0100))
#define VIDW01ADD2 (*(volatile unsigned int *)(LCD_BASE +0x0104))
#define VIDW02ADD2 (*(volatile unsigned int *)(LCD_BASE +0x0108))
#define VIDW03ADD2 (*(volatile unsigned int *)(LCD_BASE +0x010C))
#define VIDW04ADD2 (*(volatile unsigned int *)(LCD_BASE +0x0110))
#define VIDINTCON0 (*(volatile unsigned int *)(LCD_BASE + 0x0130))
#define VIDINTCON1 (*(volatile unsigned int *)(LCD_BASE + 0x0134))
#define W1KEYCON0 (*(volatile unsigned int *)(LCD_BASE + 0x0140))
#define VIDW0ALPHA0 (*(volatile unsigned int *)(LCD_BASE +0x021C))
#define VIDW0ALPHA1 (*(volatile unsigned int *)(LCD_BASE +0x0220))
#define VIDW1ALPHA0 (*(volatile unsigned int *)(LCD_BASE +0x0224))
#define VIDW1ALPHA1 (*(volatile unsigned int *)(LCD_BASE +0x0228))
#define VIDW2ALPHA0 (*(volatile unsigned int *)(LCD_BASE +0x022C))
#define VIDW2ALPHA1 (*(volatile unsigned int *)(LCD_BASE +0x0230))
#define VIDW3ALPHA0 (*(volatile unsigned int *)(LCD_BASE +0x0234))
#define VIDW3ALPHA1 (*(volatile unsigned int *)(LCD_BASE +0x0238))
#define VIDW4ALPHA0 (*(volatile unsigned int *)(LCD_BASE +0x023C))
#define VIDW4ALPHA1 (*(volatile unsigned int *)(LCD_BASE +0x0240))
/*
*
*VIDTCON0:
* [23:16]: VBPD + 1 <------> tvpw (1 - 20) 13
* [15:8]: VFPD + 1 <------> tvfp 22
* [7:0]: VSPW +1 <------> tvb - tvpw = 23 - 13 = 10
* */
#define VBPD (22) //12 22
#define VFPD (21)
#define VSPW (0) //9 0
/*
*VIDTCON1:
* [23:16]: HBPD + 1 <------> thpw (1 - 40) 36
* [15:8]: HFPD + 1 <------> thfp 210
* [7:0]: HSPW + 1 <------> thb - thpw= 46 - 36 = 10
* */
#define HBPD (45) //35 45
#define HFPD (209)
#define HSPW (0) //9 0
#define ROW (480)
#define COL (800)
#define HOZVAL (COL-1)
#define LINEVAL (ROW-1)// 479
/*
* Register offsets
*/
#define EXYNOS_WINCON(x) (x * 0x04)
#define EXYNOS_VIDOSD(x) (x * 0x10)
#define EXYNOS_BUFFER_OFFSET(x) (x * 0x08)
#define EXYNOS_BUFFER_SIZE(x) (x * 0x04)
/*
* Bit Definitions
*/
/* VIDCON0 */
#defineEXYNOS_VIDCON0_DSI_DISABLE (0<< 30)
#define EXYNOS_VIDCON0_DSI_ENABLE (1 << 30)
#defineEXYNOS_VIDCON0_SCAN_PROGRESSIVE (0<< 29)
#define EXYNOS_VIDCON0_SCAN_INTERLACE (1 << 29)
#define EXYNOS_VIDCON0_SCAN_MASK (1 << 29)
#define EXYNOS_VIDCON0_VIDOUT_RGB (0 << 26)
#define EXYNOS_VIDCON0_VIDOUT_ITU (1 << 26)
#defineEXYNOS_VIDCON0_VIDOUT_I80LDI0 (2<< 26)
#defineEXYNOS_VIDCON0_VIDOUT_I80LDI1 (3<< 26)
#defineEXYNOS_VIDCON0_VIDOUT_WB_RGB (4<< 26)
#defineEXYNOS_VIDCON0_VIDOUT_WB_I80LDI0 (6<< 26)
#defineEXYNOS_VIDCON0_VIDOUT_WB_I80LDI1 (7<< 26)
#defineEXYNOS_VIDCON0_VIDOUT_MASK (7<< 26)
#defineEXYNOS_VIDCON0_PNRMODE_RGB_P (0<< 17)
#defineEXYNOS_VIDCON0_PNRMODE_BGR_P (1<< 17)
#defineEXYNOS_VIDCON0_PNRMODE_RGB_S (2<< 17)
#defineEXYNOS_VIDCON0_PNRMODE_BGR_S (3<< 17)
#defineEXYNOS_VIDCON0_PNRMODE_MASK (3<< 17)
#defineEXYNOS_VIDCON0_PNRMODE_SHIFT (17)
#define EXYNOS_VIDCON0_CLKVALUP_ALWAYS (0 << 16)
#defineEXYNOS_VIDCON0_CLKVALUP_START_FRAME (1<< 16)
#defineEXYNOS_VIDCON0_CLKVALUP_MASK (1<< 16)
#defineEXYNOS_VIDCON0_CLKVAL_F(x) (((x)& 0xff) << 6)
#defineEXYNOS_VIDCON0_VCLKEN_NORMAL (0<< 5)
#define EXYNOS_VIDCON0_VCLKEN_FREERUN (1 << 5)
#defineEXYNOS_VIDCON0_VCLKEN_MASK (1<< 5)
#defineEXYNOS_VIDCON0_CLKDIR_DIRECTED (0<< 4)
#defineEXYNOS_VIDCON0_CLKDIR_DIVIDED (1<< 4)
#defineEXYNOS_VIDCON0_CLKDIR_MASK (1<< 4)
#define EXYNOS_VIDCON0_CLKSEL_HCLK (0 << 2)
#defineEXYNOS_VIDCON0_CLKSEL_SCLK (1<< 2)
#defineEXYNOS_VIDCON0_CLKSEL_MASK (1<< 2)
#defineEXYNOS_VIDCON0_ENVID_ENABLE (1<< 1)
#defineEXYNOS_VIDCON0_ENVID_DISABLE (0<< 1)
#defineEXYNOS_VIDCON0_ENVID_F_ENABLE (1<< 0)
#defineEXYNOS_VIDCON0_ENVID_F_DISABLE (0<< 0)
/* VIDCON1 */
#defineEXYNOS_VIDCON1_VCLK_HOLD (0 << 9)
#defineEXYNOS_VIDCON1_VCLK_RUNNING (1 << 9)
#defineEXYNOS_VIDCON1_VCLK_RUNNING_DIS_VDEN (3<< 9)
#define EXYNOS_VIDCON1_IVCLK_FALLING_EDGE (0 << 7)
#defineEXYNOS_VIDCON1_IVCLK_RISING_EDGE (1<< 7)
#defineEXYNOS_VIDCON1_IHSYNC_NORMAL (0<< 6)
#defineEXYNOS_VIDCON1_IHSYNC_INVERT (1<< 6)
#defineEXYNOS_VIDCON1_IVSYNC_NORMAL (0<< 5)
#defineEXYNOS_VIDCON1_IVSYNC_INVERT (1<< 5)
#defineEXYNOS_VIDCON1_IVDEN_NORMAL (0<< 4)
#defineEXYNOS_VIDCON1_IVDEN_INVERT (1<< 4)
/* VIDCON2 */
#defineEXYNOS_VIDCON2_EN601_DISABLE (0<< 23)
#defineEXYNOS_VIDCON2_EN601_ENABLE (1<< 23)
#define EXYNOS_VIDCON2_EN601_MASK (1 << 23)
#define EXYNOS_VIDCON2_WB_DISABLE (0 << 15)
#define EXYNOS_VIDCON2_WB_ENABLE (1 << 15)
#define EXYNOS_VIDCON2_WB_MASK (1 << 15)
#defineEXYNOS_VIDCON2_TVFORMATSEL_HW (0<< 14)
#defineEXYNOS_VIDCON2_TVFORMATSEL_SW (1<< 14)
#define EXYNOS_VIDCON2_TVFORMATSEL_MASK (1 << 14)
#defineEXYNOS_VIDCON2_TVFORMATSEL_YUV422 (1<< 12)
#defineEXYNOS_VIDCON2_TVFORMATSEL_YUV444 (2<< 12)
#defineEXYNOS_VIDCON2_TVFORMATSEL_YUV_MASK (3<< 12)
#defineEXYNOS_VIDCON2_ORGYUV_YCBCR (0<< 8)
#define EXYNOS_VIDCON2_ORGYUV_CBCRY (1 << 8)
#defineEXYNOS_VIDCON2_ORGYUV_MASK (1<< 8)
#defineEXYNOS_VIDCON2_YUVORD_CBCR (0<< 7)
#defineEXYNOS_VIDCON2_YUVORD_CRCB (1<< 7)
#defineEXYNOS_VIDCON2_YUVORD_MASK (1<< 7)
/* PRTCON */
#define EXYNOS_PRTCON_UPDATABLE (0 << 11)
#define EXYNOS_PRTCON_PROTECT (1 << 11)
/* VIDTCON0 */
#define EXYNOS_VIDTCON0_VBPDE(x) (((x) & 0xff) << 24)
#define EXYNOS_VIDTCON0_VBPD(x) (((x) & 0xff)<< 16)
#define EXYNOS_VIDTCON0_VFPD(x) (((x) & 0xff)<< 8)
#define EXYNOS_VIDTCON0_VSPW(x) (((x) & 0xff)<< 0)
/* VIDTCON1 */
#define EXYNOS_VIDTCON1_VFPDE(x) (((x) & 0xff) << 24)
#define EXYNOS_VIDTCON1_HBPD(x) (((x) & 0xff)<< 16)
#define EXYNOS_VIDTCON1_HFPD(x) (((x) & 0xff)<< 8)
#define EXYNOS_VIDTCON1_HSPW(x) (((x) & 0xff)<< 0)
/* VIDTCON2 */
#defineEXYNOS_VIDTCON2_LINEVAL(x) (((x)& 0x7ff) << 11)
#define EXYNOS_VIDTCON2_HOZVAL(x) (((x) & 0x7ff)<< 0)
#defineEXYNOS_VIDTCON2_LINEVAL_E(x) ((((x)& 0x800) >> 11) << 23)
#define EXYNOS_VIDTCON2_HOZVAL_E(x) ((((x) & 0x800) >> 11)<< 22)
/* Window 0~4 Control - WINCONx*/
#defineEXYNOS_WINCON_DATAPATH_DMA (0<< 22)
#defineEXYNOS_WINCON_DATAPATH_LOCAL (1<< 22)
#defineEXYNOS_WINCON_DATAPATH_MASK (1<< 22)
#define EXYNOS_WINCON_BUFSEL_0 (0 << 20)
#define EXYNOS_WINCON_BUFSEL_1 (1 << 20)
#define EXYNOS_WINCON_BUFSEL_MASK (1 << 20)
#defineEXYNOS_WINCON_BUFSEL_SHIFT (20)
#defineEXYNOS_WINCON_BUFAUTO_DISABLE (0<< 19)
#defineEXYNOS_WINCON_BUFAUTO_ENABLE (1<< 19)
#define EXYNOS_WINCON_BUFAUTO_MASK (1 << 19)
#defineEXYNOS_WINCON_BITSWP_DISABLE (0<< 18)
#defineEXYNOS_WINCON_BITSWP_ENABLE (1<< 18)
#defineEXYNOS_WINCON_BITSWP_SHIFT (18)
#defineEXYNOS_WINCON_BYTESWP_DISABLE (0<< 17)
#defineEXYNOS_WINCON_BYTESWP_ENABLE (1 << 17)
#defineEXYNOS_WINCON_BYTESWP_SHIFT (17)
#defineEXYNOS_WINCON_HAWSWP_DISABLE (0<< 16)
#defineEXYNOS_WINCON_HAWSWP_ENABLE (1<< 16)
#defineEXYNOS_WINCON_HAWSWP_SHIFT (16)
#defineEXYNOS_WINCON_WSWP_DISABLE (0<< 15)
#define EXYNOS_WINCON_WSWP_ENABLE (1 << 15)
#define EXYNOS_WINCON_WSWP_SHIFT (15)
#define EXYNOS_WINCON_INRGB_RGB (0 << 13)
#define EXYNOS_WINCON_INRGB_YUV (1 << 13)
#define EXYNOS_WINCON_INRGB_MASK (1 << 13)
#defineEXYNOS_WINCON_BURSTLEN_16WORD (0<< 9)
#defineEXYNOS_WINCON_BURSTLEN_8WORD (1<< 9)
#defineEXYNOS_WINCON_BURSTLEN_4WORD (2<< 9)
#defineEXYNOS_WINCON_BURSTLEN_MASK (3<< 9)
#defineEXYNOS_WINCON_ALPHA_MULTI_DISABLE (0<< 7)
#defineEXYNOS_WINCON_ALPHA_MULTI_ENABLE (1<< 7)
#define EXYNOS_WINCON_BLD_PLANE (0 << 6)
#define EXYNOS_WINCON_BLD_PIXEL (1 << 6)
#define EXYNOS_WINCON_BLD_MASK (1 << 6)
#defineEXYNOS_WINCON_BPPMODE_1BPP (0<< 2)
#defineEXYNOS_WINCON_BPPMODE_2BPP (1<< 2)
#defineEXYNOS_WINCON_BPPMODE_4BPP (2<< 2)
#defineEXYNOS_WINCON_BPPMODE_8BPP_PAL (3<< 2)
#defineEXYNOS_WINCON_BPPMODE_8BPP (4<< 2)
#defineEXYNOS_WINCON_BPPMODE_16BPP_565 (5<< 2)
#defineEXYNOS_WINCON_BPPMODE_16BPP_A555 (6<< 2)
#defineEXYNOS_WINCON_BPPMODE_18BPP_666 (8<< 2)
#defineEXYNOS_WINCON_BPPMODE_18BPP_A665 (9<< 2)
#defineEXYNOS_WINCON_BPPMODE_24BPP_888 (0xb<< 2)
#defineEXYNOS_WINCON_BPPMODE_24BPP_A887 (0xc<< 2)
#defineEXYNOS_WINCON_BPPMODE_32BPP (0xd<< 2)
#defineEXYNOS_WINCON_BPPMODE_16BPP_A444 (0xe<< 2)
#defineEXYNOS_WINCON_BPPMODE_15BPP_555 (0xf<< 2)
#defineEXYNOS_WINCON_BPPMODE_MASK (0xf<< 2)
#defineEXYNOS_WINCON_BPPMODE_SHIFT (2)
#define EXYNOS_WINCON_ALPHA0_SEL (0 << 1)
#define EXYNOS_WINCON_ALPHA1_SEL (1 << 1)
#define EXYNOS_WINCON_ALPHA_SEL_MASK (1 << 1)
#defineEXYNOS_WINCON_ENWIN_DISABLE (0<< 0)
#defineEXYNOS_WINCON_ENWIN_ENABLE (1<< 0)
/* WINCON1 special */
#define EXYNOS_WINCON1_VP_DISABLE (0 << 24)
#define EXYNOS_WINCON1_VP_ENABLE (1 << 24)
#define EXYNOS_WINCON1_LOCALSEL_FIMC1 (0 << 23)
#defineEXYNOS_WINCON1_LOCALSEL_VP (1<< 23)
#defineEXYNOS_WINCON1_LOCALSEL_MASK (1<< 23)
/* WINSHMAP */
#defineEXYNOS_WINSHMAP_PROTECT(x) (((x)& 0x1f) << 10)
#defineEXYNOS_WINSHMAP_CH_ENABLE(x) (1 << (x))
#define EXYNOS_WINSHMAP_CH_DISABLE(x) (~(7 << (x)))
#defineEXYNOS_WINSHMAP_LOCAL_ENABLE(x) (0x20<< (x))
#defineEXYNOS_WINSHMAP_LOCAL_DISABLE(x) (0x20<< (x))
/* VIDOSDxA, VIDOSDxB */
#define EXYNOS_VIDOSD_LEFT_X(x) (((x) & 0x7ff)<< 11)
#define EXYNOS_VIDOSD_TOP_Y(x) (((x) & 0x7ff)<< 0)
#define EXYNOS_VIDOSD_RIGHT_X(x) (((x) & 0x7ff) << 11)
#define EXYNOS_VIDOSD_BOTTOM_Y(x) (((x) & 0x7ff) <<0)
#defineEXYNOS_VIDOSD_RIGHT_X_E(x) (((x)& 0x1) << 23)
#defineEXYNOS_VIDOSD_BOTTOM_Y_E(x) (((x)& 0x1) << 22)
/* VIDOSD0C, VIDOSDxD */
#define EXYNOS_VIDOSD_SIZE(x) (((x) & 0xffffff)<< 0)
/* VIDOSDxC (1~4) */
#define EXYNOS_VIDOSD_ALPHA0_R(x) (((x) & 0xf) <<20)
#define EXYNOS_VIDOSD_ALPHA0_G(x) (((x) & 0xf) <<16)
#define EXYNOS_VIDOSD_ALPHA0_B(x) (((x) & 0xf) <<12)
#define EXYNOS_VIDOSD_ALPHA1_R(x) (((x) & 0xf) << 8)
#define EXYNOS_VIDOSD_ALPHA1_G(x) (((x) & 0xf) << 4)
#define EXYNOS_VIDOSD_ALPHA1_B(x) (((x) & 0xf) << 0)
#defineEXYNOS_VIDOSD_ALPHA0_SHIFT (12)
#define EXYNOS_VIDOSD_ALPHA1_SHIFT (0)
/* Start Address */
#defineEXYNOS_VIDADDR_START_VBANK(x) (((x)& 0xff) << 24)
#defineEXYNOS_VIDADDR_START_VBASEU(x) (((x)& 0xffffff) << 0)
/* End Address */
#defineEXYNOS_VIDADDR_END_VBASEL(x) (((x)& 0xffffff) << 0)
/* Buffer Size */
#define EXYNOS_VIDADDR_OFFSIZE(x) (((x) & 0x1fff)<< 13)
#defineEXYNOS_VIDADDR_PAGEWIDTH(x) (((x)& 0x1fff) << 0)
#defineEXYNOS_VIDADDR_OFFSIZE_E(x) ((((x)& 0x2000) >> 13) << 27)
#defineEXYNOS_VIDADDR_PAGEWIDTH_E(x) ((((x)& 0x2000) >> 13) << 26)
/* WIN Color Map */
#define EXYNOS_WINMAP_COLOR(x) ((x) & 0xffffff)
/* VIDINTCON0 */
#defineEXYNOS_VIDINTCON0_SYSMAINCON_DISABLE (0<< 19)
#defineEXYNOS_VIDINTCON0_SYSMAINCON_ENABLE (1<< 19)
#defineEXYNOS_VIDINTCON0_SYSSUBCON_DISABLE (0<< 18)
#defineEXYNOS_VIDINTCON0_SYSSUBCON_ENABLE (1<< 18)
#defineEXYNOS_VIDINTCON0_SYSIFDONE_DISABLE (0<< 17)
#defineEXYNOS_VIDINTCON0_SYSIFDONE_ENABLE (1<< 17)
#defineEXYNOS_VIDINTCON0_FRAMESEL0_BACK (0<< 15)
#define EXYNOS_VIDINTCON0_FRAMESEL0_VSYNC (1 << 15)
#defineEXYNOS_VIDINTCON0_FRAMESEL0_ACTIVE (2<< 15)
#defineEXYNOS_VIDINTCON0_FRAMESEL0_FRONT (3<< 15)
#defineEXYNOS_VIDINTCON0_FRAMESEL0_MASK (3<< 15)
#defineEXYNOS_VIDINTCON0_FRAMESEL1_NONE (0<< 13)
#define EXYNOS_VIDINTCON0_FRAMESEL1_BACK (1 << 13)
#defineEXYNOS_VIDINTCON0_FRAMESEL1_VSYNC (2<< 13)
#defineEXYNOS_VIDINTCON0_FRAMESEL1_FRONT (3<< 13)
#defineEXYNOS_VIDINTCON0_INTFRMEN_DISABLE (0<< 12)
#defineEXYNOS_VIDINTCON0_INTFRMEN_ENABLE (1<< 12)
#defineEXYNOS_VIDINTCON0_FIFOSEL_WIN4 (1<< 11)
#defineEXYNOS_VIDINTCON0_FIFOSEL_WIN3 (1<< 10)
#defineEXYNOS_VIDINTCON0_FIFOSEL_WIN2 (1<< 9)
#defineEXYNOS_VIDINTCON0_FIFOSEL_WIN1 (1<< 6)
#defineEXYNOS_VIDINTCON0_FIFOSEL_WIN0 (1<< 5)
#define EXYNOS_VIDINTCON0_FIFOSEL_ALL (0x73 << 5)
#defineEXYNOS_VIDINTCON0_FIFOSEL_MASK (0x73<< 5)
#defineEXYNOS_VIDINTCON0_FIFOLEVEL_25 (0<< 2)
#defineEXYNOS_VIDINTCON0_FIFOLEVEL_50 (1<< 2)
#defineEXYNOS_VIDINTCON0_FIFOLEVEL_75 (2<< 2)
#define EXYNOS_VIDINTCON0_FIFOLEVEL_EMPTY (3 << 2)
#defineEXYNOS_VIDINTCON0_FIFOLEVEL_FULL (4<< 2)
#defineEXYNOS_VIDINTCON0_FIFOLEVEL_MASK (7<< 2)
#defineEXYNOS_VIDINTCON0_INTFIFO_DISABLE (0<< 1)
#defineEXYNOS_VIDINTCON0_INTFIFO_ENABLE (1<< 1)
#define EXYNOS_VIDINTCON0_INT_DISABLE (0 << 0)
#defineEXYNOS_VIDINTCON0_INT_ENABLE (1<< 0)
#defineEXYNOS_VIDINTCON0_INT_MASK (1<< 0)
/* VIDINTCON1 */
#defineEXYNOS_VIDINTCON1_INTVPPEND (1<< 5)
#defineEXYNOS_VIDINTCON1_INTI80PEND (1<< 2)
#define EXYNOS_VIDINTCON1_INTFRMPEND (1 << 1)
#defineEXYNOS_VIDINTCON1_INTFIFOPEND (1<< 0)
/* WINMAP */
#define EXYNOS_WINMAP_ENABLE (1 << 24)
/* WxKEYCON0 (1~4) */
#defineEXYNOS_KEYCON0_KEYBLEN_DISABLE (0<< 26)
#defineEXYNOS_KEYCON0_KEYBLEN_ENABLE (1<< 26)
#defineEXYNOS_KEYCON0_KEY_DISABLE (0<< 25)
#define EXYNOS_KEYCON0_KEY_ENABLE (1 << 25)
#defineEXYNOS_KEYCON0_DIRCON_MATCH_FG (0<< 24)
#defineEXYNOS_KEYCON0_DIRCON_MATCH_BG (1<< 24)
#define EXYNOS_KEYCON0_COMPKEY(x) (((x) & 0xffffff) <<0)
/* WxKEYCON1 (1~4) */
#define EXYNOS_KEYCON1_COLVAL(x) (((x) & 0xffffff)<< 0)
/* DUALRGB */
#defineEXYNOS_DUALRGB_BYPASS_SINGLE (0x00<< 0)
#defineEXYNOS_DUALRGB_BYPASS_DUAL (0x01<< 0)
#define EXYNOS_DUALRGB_MIE_DUAL (0x10 << 0)
#define EXYNOS_DUALRGB_MIE_SINGLE (0x11 << 0)
#define EXYNOS_DUALRGB_LINESPLIT (0x0 << 2)
#define EXYNOS_DUALRGB_FRAMESPLIT (0x1 << 2)
#define EXYNOS_DUALRGB_SUB_CNT(x) ((x & 0xfff) << 4)
#defineEXYNOS_DUALRGB_VDEN_EN_DISABLE (0x0<< 16)
#define EXYNOS_DUALRGB_VDEN_EN_ENABLE (0x1 << 16)
#defineEXYNOS_DUALRGB_MAIN_CNT(x) ((x& 0xfff) << 18)
/* I80IFCONA0 and I80IFCONA1 */
#define EXYNOS_LCD_CS_SETUP(x) (((x) & 0xf)<< 16)
#define EXYNOS_LCD_WR_SETUP(x) (((x) & 0xf)<< 12)
#define EXYNOS_LCD_WR_ACT(x) (((x) & 0xf) <<8)
#define EXYNOS_LCD_WR_HOLD(x) (((x) & 0xf)<< 4)
#define EXYNOS_RSPOL_LOW (0 << 2)
#define EXYNOS_RSPOL_HIGH (1 << 2)
#define EXYNOS_I80IFEN_DISABLE (0 << 0)
#define EXYNOS_I80IFEN_ENABLE (1 << 0)
/* TRIGCON */
#define EXYNOS_I80SOFT_TRIG_EN (1 << 0)
#define EXYNOS_I80START_TRIG (1 << 1)
#defineEXYNOS_I80STATUS_TRIG_DONE (1<< 2)
/* DP_MIE_CLKCON */
#define EXYNOS_DP_MIE_DISABLE (0 << 0)
#define EXYNOS_DP_CLK_ENABLE (1 << 1)
#define EXYNOS_MIE_CLK_ENABLE (3 << 0)
#endif
在\uboot_tiny4412-lcd \drivers\video\目录下添加一个底层驱动程序文件,文件名为zth_tiny4412_lcd.c,此文件是从我的LCD裸机程序里复制过来后,进行点点修改的。zth_tiny4412_lcd.c内容如下,大家可以将其粘贴过去。
/****************************************
NAME:LCD.C
TRAD:/USER/
PROJECT:
CREATER:Zhang Taohua
DATA:2014-05-07
DESCRIPTION:
LCD relation function
*****************************************/
//#include "stdio.h"
#include "videomodes.h"
#include
#include
#include
#include
#include
#if FONT8_16
#include
#endif
#if FONT10_18
#include
#endif
#if FONT12_22
#include
#endif
#ifdefined(CONFIG_LCD_EXYNOS4412)//add by zth
void delay(unsigned long count)
{
volatileunsigned long j,i = count;
for(;i>0;i--)
{
for(j=0x20000;j>0;j--){}
}
}
/*void memset_int(unsigned int *s, int c,unsigned int count)
{
unsignedint *xs = (unsigned int *) s;
while(count--)
*xs++= c;
//returns;
}
*/
/****************************************
FUNCTION :led_blink()
PARAMETERS: link_times : blink times
REMARKS:
EXAMPLE
SEE ALSO:
DATA:
*****************************************/
void led_blink(int link_times)
{
GPM4CON= 0x00001111; //IO SET
inti;
for(i=0;i<= link_times;i++)
{
GPM4DAT= 0; // LED on
delay(0x2);
GPM4DAT= 0xf; // LED off
delay(0x2);
}
}
/****************************************
FUNCTION :led_blink()
PARAMETERS: link_times : blink times
REMARKS:
EXAMPLE
SEE ALSO:
DATA:
*****************************************/
DECLARE_GLOBAL_DATA_PTR;
GraphicDevice smi;
//extern voidboard_video_init(GraphicDevice *pGD);
void *video_hw_init (void)
{
GraphicDevice *pGD = (GraphicDevice*)&smi;
int videomode;
unsigned long t1, hsynch, vsynch;
char *penv;
int tmp, i, bits_per_pixel;
struct ctfb_res_modes *res_mode;
struct ctfb_res_modes var_mode;
int clkval;
unsignedlong long src_clock;
unsignedint cfg = 0, div = 0, remainder, remainder_div;
//indicateLCD start Init
printf("addby zth now now is in zthtiny_fb.c ;video_hw_init() \n ");
printf("modifyby zth, Strat to Init the lCD\r\n");
/*
*SET IO IS LCD
*
*
* GPF0CON : [31:0] : 0x2
* GPF1CON : [31:0] : 0x2
* GPF2CON : [31:0] : 0x2
* GPF3CON : [31:0] : 0x2
* */
GPF0CON= 0x22222222;
GPF1CON= 0x22222222;
GPF2CON= 0x22222222;
GPF3CON= 0x00222222;
//Set pull-up,down disable
GPF0PUD= 0x0000FFFF;
GPF1PUD= 0x0000FFFF;
GPF2PUD= 0x0000FFFF;
GPF3PUD= 0x00000FFF;
//MAXdrive strength---------//
GPF0DRV= 0x0000FFFF;
GPF1DRV= 0x0000FFFF;
GPF2DRV= 0x0000FFFF;
GPF3DRV= 0x00000FFF;
/*
*
*CLK_DIV_LCD:
* [3:0]:FIMD0_RATIO 0
* SCLK_FIMD0 =MOUTFIMD0/(FIMD0_RATIO + 1)
* = MOUTFIMD0/1 = 800MHz
* MOUTFIMD0 == SCLKmpll_user_t ==800MHz
* */
CLK_DIV_LCD&= ~0xf;
/*
*
*CLK_SRC_LCD0:
* [3:0]:FIMD0_SEL 0110 ===> SCLKmpll_user_t 选择时钟源为SCLKmpll_user_t
*
* */
CLK_SRC_LCD0&= ~0xf;
CLK_SRC_LCD0|= 6;
//LCD0_SYS_PWR_REG== 7 Don't use
/*
*Using the display controller data, youcan select one of the above data paths by setting LCDBLK_CFG Register
*(0x1001_0210). For more information,refer to the "System Others" manual.
*
*
*
* LCDBLK_CFG:
* [1] : FIMD of LBLK0 Bypass Selection 1 : FIMD Bypass 使用FIMD接口
*
* LCDBLK_CFG :
* [0]:MIE0_DISPON 1 : PWM outpupt enable
*
*
* */
LCDBLK_CFG|= 1 << 1;
LCDBLK_CFG2 |= 1;
printf("Video:");
tmp = 0;
videomode = CONFIG_SYS_DEFAULT_VIDEO_MODE;
/* get video mode via environment */
if ((penv = getenv ("videomode"))!= NULL) {
/* deceide if it is a string */
if (penv[0] <= '9') {
videomode = (int) simple_strtoul(penv, NULL, 16);
tmp = 1;
}
} else {
tmp = 1;
}
if (tmp){
/* parameter are vesa modes */
/* search params */
for (i = 0; i < VESA_MODES_COUNT; i++) {
if (vesa_modes[i].vesanr ==videomode)
break;
}
if (i == VESA_MODES_COUNT) {
printf ("no VESAMode found, switching to mode 0x%x ", CONFIG_SYS_DEFAULT_VIDEO_MODE);
i = 0;
}
res_mode =(struct ctfb_res_modes *)&res_mode_init[vesa_modes[i].resindex];
bits_per_pixel =vesa_modes[i].bits_per_pixel;
} else {
res_mode = (struct ctfb_res_modes *)&var_mode;
bits_per_pixel =video_get_params (res_mode, penv);
}
printf("add by zth now calculate hsynchand vsynch freq (info only )\n ");
/* calculate hsynch and vsynch freq (infoonly) */
t1 = (res_mode->left_margin +res_mode->xres + res_mode->right_margin + res_mode->hsync_len) / 8;
t1 *= 8;
t1 *= res_mode->pixclock;
printf("addby zth;res_mode->pixclock= %d\n ",res_mode->pixclock);
t1 /= 1000;
hsynch = 1000000000L / t1;
t1 *= (res_mode->upper_margin +res_mode->yres + res_mode->lower_margin + res_mode->vsync_len);
t1 /= 1000;
vsynch = 1000000000L / t1;
/* fill in Graphic device struct */
sprintf (pGD->modeIdent, "%dx%dx%d%ldkHz %ldHz", res_mode->xres, res_mode->yres, bits_per_pixel,(hsynch /
1000), (vsynch / 1000));
printf ("%s\n",pGD->modeIdent);
pGD->winSizeX = res_mode->xres;
pGD->winSizeY = res_mode->yres;
pGD->plnSizeX = res_mode->xres;
pGD->plnSizeY = res_mode->yres;
printf("bits_per_pixel%d\n ",bits_per_pixel);
switch (bits_per_pixel) {
case 8:
pGD->gdfBytesPP = 1;
pGD->gdfIndex = GDF__8BIT_INDEX;
break;
case 15:
pGD->gdfBytesPP = 2;
pGD->gdfIndex = GDF_15BIT_555RGB;
break;
case 16:
pGD->gdfBytesPP = 2;
pGD->gdfIndex = GDF_16BIT_565RGB;
break;
case 24:
pGD->gdfBytesPP = 4;
pGD->gdfIndex = GDF_24BIT_888RGB;
break;
case 32:
pGD->gdfBytesPP = 4;
pGD->gdfIndex =GDF_32BIT_X888RGB;
break;
}
//pGD->frameAdrs= gd->fb_base;
pGD->frameAdrs= LCD_VIDEO_ADDR;
pGD->memSize= VIDEO_MEM_SIZE;
/*Clear video memory */
memset((void*)pGD->frameAdrs, 0xFF00, pGD->memSize);
// memset(LCD_VIDEO_ADDR, 0xFF00, VIDEO_MEM_SIZE);
/*
*
*VIDCON0:
* [13:6]: CLKVAL_F //设置LCD时钟分频系数
*
* VCLK == 33.3Mhz
* VCLK = FIMD * SCLK/(CLKVAL+1)
* VCLK = 800000000 / (CLKVAL +1)
* 33300000 = 800000000 /(CLKVAL + 1)
* CLKVAL + 1 = 24.02
* CLKVAL = 23
* */
t1 = res_mode->pixclock;
t1 /= 1000;
t1 = 1000000000L / t1;
clkval = (CONFIG_SYS_VIDEO_VCLOCK_HZ / t1)- 1;
//clkval = (800000000 / 33300000) - 1;
// VIDCON0 = (23 << 6);
VIDCON0= EXYNOS_VIDCON0_CLKVAL_F(clkval);
printf("VIDCON0= %d or %d \r\n",(23 <<6),EXYNOS_VIDCON0_CLKVAL_F(clkval));
/*
*
*VIDTCON1:
* [5]:IVSYNC ===> 1 : Inverted(反转)
* [6]:IHSYNC ===> 1 : Inverted(反转)
* [7]:IVCLK ===> 1 : Fetchesvideo data at VCLK rising edge (下降沿触发)
* [10:9]:FIXVCLK ====> 01 : VCLK running
* */
//VIDCON1= (1 << 9) | (1 << 7) | (1 << 5) | (1 << 6);
VIDCON1= ( EXYNOS_VIDCON1_VCLK_RUNNING |
EXYNOS_VIDCON1_IVCLK_RISING_EDGE|
EXYNOS_VIDCON1_IVSYNC_INVERT |
EXYNOS_VIDCON1_IHSYNC_INVERT);
/*
printf("VIDCON1= %d or %d \r\n",(1 << 9) | (1 << 7) |(1 << 5) | (1 << 6),
EXYNOS_VIDCON1_VCLK_RUNNING|
EXYNOS_VIDCON1_IVCLK_RISING_EDGE|
EXYNOS_VIDCON1_IVSYNC_INVERT|
EXYNOS_VIDCON1_IHSYNC_INVERT);
*/
/*
*
*VIDTCON0:
* [23:16]: VBPD + 1 <------>tvpw (1 - 20) 13
* [15:8]: VFPD + 1 <------> tvfp 22
* [7:0]: VSPW + 1 <------>tvb - tvpw = 23 - 13 = 10
* */
// VIDTCON0 = (12 << 16) | (21 << 8)| (9);
// VIDTCON0 = (22 << 16)| (21 << 8) | (0);
/*VIDTCON0= ( EXYNOS_VIDTCON0_VBPD(VBPD) |
EXYNOS_VIDTCON0_VFPD(VFPD) |
EXYNOS_VIDTCON0_VSPW(VSPW));
*/
VIDTCON0= ( EXYNOS_VIDTCON0_VBPD(res_mode->upper_margin) |
EXYNOS_VIDTCON0_VFPD(res_mode->lower_margin)|
EXYNOS_VIDTCON0_VSPW(res_mode->vsync_len));
printf("VIDTCON0= is 22,21,0 %d; %d; %d; \r\n", res_mode->upper_margin,
res_mode->lower_margin,
res_mode->vsync_len);
/*
*VIDTCON1:
* [23:16]: HBPD + 1 <------>thpw (1 - 40) 36
* [15:8]: HFPD + 1 <------>thfp 210
* [7:0]: HSPW + 1 <------> thb - thpw = 46 - 36 = 10
*/
//VIDTCON1= (35 << 16) | (209 << 8) | (9);
//VIDTCON1= (45 << 16) | (209 << 8) | (0);
/* VIDTCON1 = ( EXYNOS_VIDTCON1_HBPD(HBPD) |
EXYNOS_VIDTCON1_HFPD(HFPD) |
EXYNOS_VIDTCON1_HSPW(HSPW));
*/
VIDTCON1= ( EXYNOS_VIDTCON1_HBPD(res_mode->left_margin) |
EXYNOS_VIDTCON1_HFPD(res_mode->right_margin) |
EXYNOS_VIDTCON1_HSPW(res_mode->hsync_len));
printf("VIDTCON1= is 45,209,0 %d; %d; %d; \r\n", res_mode->left_margin,
res_mode->right_margin,
res_mode->hsync_len);
/*
*
*
*HOZVAL = (Horizontal display size) – 1and LINEVAL = (Vertical display size) – 1.
* Horizontal(水平) display size : 800
*Vertical(垂直) display size : 480
* */
//VIDTCON2= (479 << 11) | 799;
/*VIDTCON2= ( EXYNOS_VIDTCON2_LINEVAL(LINEVAL) |
EXYNOS_VIDTCON2_HOZVAL(HOZVAL));
*/
VIDTCON2= ( EXYNOS_VIDTCON2_LINEVAL(pGD->winSizeY - 1) |
EXYNOS_VIDTCON2_HOZVAL(pGD->winSizeX - 1));
printf("VIDTCON2= 479 799 %d or %d \r\n", pGD->winSizeY - 1,pGD->winSizeX - 1);
//win0
/*
*
*WINCON0:
* [5:2]: Selects Bits Per Pixel (BPP) mode for Window image : 1011 ===>24BPP
* [1]:Enables/disables video output 1 = Enables
*
*modify by zth; have an error;add [15] :specifies word swap control bit :1=Enable ;2014 06-15 need enable
* */
//WINCON0 =( (1<<15) | (11 <<2) | 1);
WINCON0=(EXYNOS_WINCON_WSWP_ENABLE | EXYNOS_WINCON_BPPMODE_24BPP_888 |
EXYNOS_WINCON_ENWIN_ENABLE);
/*
printf("WINCON0= %d or %d \r\n",(1<<15)|(11 << 2) | 1,
EXYNOS_WINCON_WSWP_ENABLE|
EXYNOS_WINCON_BPPMODE_24BPP_888|
EXYNOS_WINCON_ENWIN_ENABLE);
*/
/*
*
*VIDOSD0C:Specifies the Window Size (窗口尺寸 单位为word)
*
*
* */
//VIDOSD0C = 480 * 800;
//VIDOSD0C= EXYNOS_VIDOSD_SIZE(ROW * COL);
VIDOSD0C= EXYNOS_VIDOSD_SIZE(pGD->winSizeY * pGD->winSizeX);
//printf("VIDOSD0C= %d or %d \r\n",480 * 800,EXYNOS_VIDOSD_SIZE(ROW *COL));
/*
*
*[0]: Enables Channel 0. 1 = Enables
* */
// SHADOWCON |= 1;
SHADOWCON |= EXYNOS_WINSHMAP_CH_ENABLE(0);
printf("SHADOWCON= %d or %d \r\n",1,EXYNOS_WINSHMAP_CH_ENABLE(0));
/*
*
*[18:16] Selects Channel 0's channel. ===>001 = Window 0
*[2:0] Selects Window 0's channel. ===> 001 = Channel 0
*
*
* */
/*WINCHMAP2&= ~(7 << 16);
WINCHMAP2|= 1 << 16;
WINCHMAP2&= ~7;
WINCHMAP2|= 1;
*/
WINCHMAP2&= EXYNOS_WINSHMAP_CH_DISABLE(16);
WINCHMAP2|= EXYNOS_WINSHMAP_CH_ENABLE(16);
WINCHMAP2&= EXYNOS_WINSHMAP_CH_DISABLE(0);
WINCHMAP2|= EXYNOS_WINSHMAP_CH_ENABLE(0);
printf("~(7<< 16) = %d or %d \r\n",~(7 <<16),EXYNOS_WINSHMAP_CH_DISABLE(16));
printf("1<< 16= %d or %d \r\n",1 << 16,EXYNOS_WINSHMAP_CH_ENABLE(16));
printf("~7= %d or %d \r\n",~7,EXYNOS_WINSHMAP_CH_DISABLE(0));
/*
*
*VIDOSD0A: LCD左上角坐标
*VIDOSD0B: LCD右下角坐标
*/
//VIDOSD0A= 0;
//VIDOSD0B= (799 << 11) | 479;
VIDOSD0A= ( EXYNOS_VIDOSD_LEFT_X(0) |EXYNOS_VIDOSD_TOP_Y(0));//0
VIDOSD0B= (EXYNOS_VIDOSD_RIGHT_X(pGD->winSizeX - 1) |EXYNOS_VIDOSD_BOTTOM_Y(pGD->winSizeY - 1));
//printf("VIDOSD0A= %d or %d \r\n",0,EXYNOS_VIDOSD_LEFT_X(0) |EXYNOS_VIDOSD_TOP_Y(0));
printf("VIDOSD0B= %d or %d \r\n",(799 << 11) | 479,
EXYNOS_VIDOSD_RIGHT_X(pGD->winSizeX- 1) | EXYNOS_VIDOSD_BOTTOM_Y(pGD->winSizeY - 1));
/*
*
* VIDW00ADD0B0 : window0 frame buffer 起始地址
* VIDW00ADD1B0 : window0 frame buffer 结束地址
* */
//VIDW00ADD0B0= LCD_VIDEO_ADDR;
//VIDW00ADD1B0= LCD_VIDEO_ADDR + VIDOSD0C * 4;
VIDW00ADD0B0= pGD->frameAdrs;
VIDW00ADD1B0= pGD->frameAdrs + VIDOSD0C * pGD->gdfBytesPP;
printf("pGD->gdfBytesPP= 4 ; %d \r\n",pGD->gdfBytesPP);
/*
*
* Display On: ENVID and ENVID_F are set to"1".
* [0]:ENVID ===> 1 = Enables
* [1]:ENVID_F ===> 1 = Enables
* */
// VIDCON0 |= 3;
VIDCON0|= (EXYNOS_VIDCON0_ENVID_ENABLE |
EXYNOS_VIDCON0_ENVID_F_ENABLE);
/*printf("VIDCON0= %d or %d \r\n",3,
(EXYNOS_VIDCON0_ENVID_ENABLE|EXYNOS_VIDCON0_ENVID_F_ENABLE));
*/
led_blink(10);//youcan see led blink and the lce is green now!
printf("Video:video_hw_init complete \n");
return((void*)&smi);
}
// 描点
void lcd_draw_pixel(int row, intcol, int color) //行,列 ,颜色
{
unsignedlong * pixel = (unsigned long *)LCD_VIDEO_ADDR;
*(pixel+ row * COL + col) = color;
}
// 画图
//此函数仅支持img2lcd转换格式包含信息头的文件
void lcd_draw_bmp(const unsignedchar gImage_bmp[])
{
inti, j;
unsignedchar *p = (unsigned char *)gImage_bmp+8;//img2lcd转换出来的包含信息头8字节
intblue, green, red;
intcolor;
intpic_width, pic_height;
//获取图片大小 参考img2lcd软件,可知其转换的第3、4字节为宽,5、6字节为高
pic_width= ((*(gImage_bmp+3)<<8) | *(gImage_bmp+2) );
pic_height=((*(gImage_bmp+5)<<8) | *(gImage_bmp+4) );
printf("pic_width= %d, pic_height = %d",pic_width,pic_height);
for(i = 0; i < pic_height; i++)
for(j = 0; j < pic_width; j++)
{
blue = *p++;
green= *p++;
red = *p++;
color= red << 16 | green << 8 | blue << 0;
lcd_draw_pixel(i,j, color);
}
}
// 清屏
void lcd_clear_screen(int color)
{
inti, j;
for(i = 0; i < ROW; i++)
for(j = 0; j < COL; j++)
lcd_draw_pixel(i,j, color);
}
// 划横线
void lcd_draw_hline(int row, intcol1, int col2, int color)
{
intj;
//描第row行,第j列
for(j = col1; j <= col2; j++)
lcd_draw_pixel(row,j, color);
}
// 划竖线
void lcd_draw_vline(int col, introw1, int row2, int color)
{
inti;
//描第i行,第col列
for(i = row1; i <= row2; i++)
lcd_draw_pixel(i,col, color);
}
// 划十字
void lcd_draw_cross(int row, intcol, int halflen, int color)
{
lcd_draw_hline(row,col-halflen, col+halflen, color);
lcd_draw_vline(col,row-halflen, row+halflen, color);
}
// 画字符
void lcd_draw_char(unsigned charc)
{
//必须是静态变量
staticint x = 0; // 第几列
staticint y = 0; // 第几行
inti,j;
unsignedint line_dots=0x0;
//获得字模
#if FONT8_16
unsigned char *char_dots =(unsigned char *) (fontdata_8x16 + c * FONT_COL);
#endif
#if FONT10_18
unsigned char *char_dots =(unsigned char *) (fontdata_10x18 + c * FONT_COL*2);
#endif
#if FONT12_22
unsigned char *char_dots =(unsigned char *) (fontdata_sun12x22 + c * FONT_COL*2);
#endif
//是否需要回车换行
if(c == '\n')
{
y+= FONT_COL;
if(y > ROW)
y= 0;
return;
}
elseif (c == '\r')
{
x= 0;
return;
}
unsignedlinek;
#ifFONT8_16
for(i = 0; i < FONT_COL; i++)
{
line_dots= char_dots[i];
for(j = 0; j < FONT_ROW; j++)
{
//为1,则描蓝点
if(line_dots & (0x80 >> j))
{
lcd_draw_pixel(y+i,x+j, 0xff);
}
}
}
#endif
#ifFONT10_18
for(i = 0; i < FONT_COL; i++)
{
line_dots= ((char_dots[i*2]<<8) | char_dots[i*2+1]);
for(j = 0; j < FONT_ROW; j++)
{
//为1,则描蓝点
if(line_dots & (0x8000 >> j))
{
lcd_draw_pixel(y+i,x+j, 0xff);
}
}
}
#endif
#ifFONT12_22
for(i = 0; i < FONT_COL; i++)
{
line_dots= ((char_dots[i*2]<<8) | char_dots[i*2+1]);
for(j = 0; j < FONT_ROW; j++)
{
//为1,则描蓝点
if(line_dots & (0x8000 >> j))
{
lcd_draw_pixel(y+i,x+j, 0xff);
}
}
}
#endif
// 光标移动到下一个字符的位置
x += FONT_ROW;
if (x > COL)
{
x= 0;
y+= FONT_COL;
if(y > ROW)
y = 0;
}
}
#endif
打开/drivers/video/Makefile,定位到后面点位置增加:
COBJS-$(CONFIG_LCD_EXYNOS4412)+= zth_tiny4412_lcd.o videomodes.o
如下图所示:
图19-2 修改Makefile示意图
//参考的第3步没有去修改。
打开/drivers/video/videomodes.c,首先定位到97行左右增加:
const struct ctfb_vesa_modes vesa_modes[VESA_MODES_COUNT] = {
{0x301,RES_MODE_640x480, 8},
{0x310,RES_MODE_640x480, 15},
{0x311,RES_MODE_640x480, 16},
{0x312,RES_MODE_640x480, 24},
{0x303,RES_MODE_800x600, 8},
{0x313,RES_MODE_800x600, 15},
{0x314, RES_MODE_800x600,16},
{0x315,RES_MODE_800x600, 24},
{0x305,RES_MODE_1024x768, 8},
{0x316,RES_MODE_1024x768, 15},
{0x317,RES_MODE_1024x768, 16},
{0x318,RES_MODE_1024x768, 24},
{0x161,RES_MODE_1152x864, 8},
{0x162,RES_MODE_1152x864, 15},
{0x163,RES_MODE_1152x864, 16},
{0x307,RES_MODE_1280x1024, 8},
{0x319,RES_MODE_1280x1024, 15},
{0x31A,RES_MODE_1280x1024, 16},
{0x31B,RES_MODE_1280x1024, 24},
{0x211,RES_MODE_800x480, 24}, //modify by zth
};
接着、定位到106行附近,修改如下:
const struct ctfb_res_modes res_mode_init[RES_MODES_COUNT] = {
/* x y pixclk le ri up lo hs vs s vmode */
{640, 480, 39721, 40,24, 32, 11, 96, 2, 0, FB_VMODE_NONINTERLACED},
{800, 600, 27778, 64,24, 22, 1, 72, 2, 0, FB_VMODE_NONINTERLACED},
{1024, 768, 15384,168, 8, 29, 3, 144, 4, 0, FB_VMODE_NONINTERLACED},
{960, 720, 13100, 160,40, 32, 8, 80, 4, 0, FB_VMODE_NONINTERLACED},
{1152, 864, 12004,200, 64, 32, 16, 80, 4, 0, FB_VMODE_NONINTERLACED},
{1280, 1024, 9090,200, 48, 26, 1, 184, 3, 0, FB_VMODE_NONINTERLACED},
{800, 480 ,30030 , 45, 209,22,21, 0, 0, 0, FB_VMODE_NONINTERLACED},
};
打开/drivers/video/videomodes.h,定位到25行附近,修改如下:
#ifndefCONFIG_SYS_DEFAULT_VIDEO_MODE
//#defineCONFIG_SYS_DEFAULT_VIDEO_MODE 0x301
//#ifndefCFG_SYS_DEFAULT_VIDEO_MODE
//#defineCFG_SYS_DEFAULT_VIDEO_MODE 0x211
#define CONFIG_SYS_DEFAULT_VIDEO_MODE 0x211
#endif
接着定位到86行左右,修改如下:
#defineRES_MODE_640x480 0
#defineRES_MODE_800x600 1
#defineRES_MODE_1024x768 2
#defineRES_MODE_960_720 3
#defineRES_MODE_1152x864 4
#defineRES_MODE_1280x1024 5
//#define RES_MODES_COUNT 6
#define RES_MODE_800x480 6
#define RES_MODES_COUNT 7
//#define VESA_MODES_COUNT 19
#define VESA_MODES_COUNT 20 //19->20
在\uboot_tiny4412-lcd\include\目录下添加一个图片数组文件:jpg_104160.h
此文件是用img2lcd来转换实现得到,其设置示意如下图18-3所示。
图19-3img2lcd 软件设置示意图
首先,打开/drivers/video/cfb_console.c文件。
定们到98行左右,增加:
#if defined(CONFIG_LCD_EXYNOS4412)//modify by zth
#include
#include
#endif
接着,定位到285行左右,修改:
//modify by zth
//#define VIDEO_INFO_X (VIDEO_LOGO_WIDTH)
//#define VIDEO_INFO_Y (VIDEO_FONT_HEIGHT/2)
#define VIDEO_INFO_X (0)
#define VIDEO_INFO_Y (VIDEO_LOGO_HEIGHT)
接着定位到1615行,增加修改:
#ifdef CONFIG_VIDEO_LOGO
/* Plot the logo andget start point of console */
PRINTD ("Video:Drawing the logo ...\n");
video_console_address= video_logo ();
lcd_draw_bmp(gImage_bmp);
#else
video_console_address= video_fb_address;
#endif
打开/common/console.c,定位368行左右,为了输出字符到LCD上,修改printf()函数。修改内容如下:
int printf(constchar *fmt, ...)
{
va_list args;
uint i;
char printbuffer[CONFIG_SYS_PBSIZE];
va_start(args, fmt);
/* For this to work, printbuffer must belarger than
*anything we ever want to print.
*/
i = vsprintf(printbuffer, fmt, args);
va_end(args);
/* Print the string */
puts(printbuffer);
//modify by zth
uint j;
for (j = 0; j
{
lcd_draw_char((unsignedchar)printbuffer[j]);
}
return i;
}
这一步修改配置文件,打开/include/configs/zth_tiny4412.h,首先定位到155行左右,使能调试输出信息,这样你会看到很多其他额外的信息,但这样会去检测Memorry,我们再将CONFIG_RAM_TEST注释了,修改如下:
//#undefCONFIG_LL_DEBUG /*disable debug */
#defineCONFIG_LL_DEBUG 1
#defineDEBUG 1
//#ifdefCONFIG_LL_DEBUG
//#defineCONFIG_RAM_TEST 1 /* Memory R/W test */
//#endif
定位到文件的最后部分,文件的第443行左右。增加下面内容:
/*LCD*/
#define CONFIG_VIDEO //Video support
#defineCONFIG_LCD_EXYNOS4412 1
#defineCONFIG_VIDEO_LOGO 1 //display Linux Logo in upper left corner
//#defineCONFIG_VIDEO_BMP_LOGO //use bmp_logo instead of linux_logo
//#defineCONFIG_CMD_BMP //BMP support
//#defineCONFIG_VIDEO_BMP_GZIP //Gzipcompressed BMP image support
//#defineCONFIG_CMD_UNZIP
//#defineCONFIG_SPLASH_SCREEN //enable splashscreen support,implicitly enable U-Boot Bitmap Support.
#defineCONFIG_VGA_AS_SINGLE_DEVICE 1
#defineCONFIG_CFB_CONSOLE
#defineVIDEO_KBD_INIT_FCT 0 //init function for keyboard
#defineVIDEO_TSTC_FCT serial_tstc //keyboard_tstc function
#defineVIDEO_GETC_FCT serial_getc //keyboard_getc function
#define LCD_VIDEO_ADDR (0x58000000)
#define VIDEO_MEM_SIZE 0x200000 /* 800x480x24bit = 0X119400 bytes */
#define CONFIG_SYS_VIDEO_VCLOCK_HZ (800000000)
#defineCONFIG_EXTRA_ENV_SETTINGS \
"stdin=serial\0" \
"stdout=vga\0" \
"stderr=serial\0" \
""
其实经过上面的步骤,大家可以按第十二步进行编译,煤写到SD卡运行u-boot了,但会出现一个问题,你会发现程序串口输出运行输出到如下图18-4所示的位置,就不会继续往下执行了,正常运行的串口输出如图18-6所示。这是为什么呢?大家查看生成的u-boot.bin大小,就会发现其大小为372.8K左右,如下图18-5所示。
图19-4、未正常运行串口输出信息截图
图19-5、u-boot.bin 大小说明图
我们来看下/sd_fuse/tiny4412/ sd_fusing.sh的文件,有如下几行语句,下面的语句是说明BL1、BL2、u-boot.bin、还有E4412_tzsw.bin烧写到SD卡的位置。
# fusing images
signed_bl1_position=1
bl2_position=17
uboot_position=49
tzsw_position=705
来算一下,一个扇区为512byte ,那么(705-49)*512/1024=328K,即给u-boot.bin的空间只有328k大小,后面的u-boot.bin程序被烧写到tzsw_position 位置片的E4412_tzsw.bin给覆盖了。
所以这们这里需要修改一下,修改内容如下
tzsw_position=1073
这里为什么是1073呢,是因为我还改了一个地方,增加拷贝u-boot.bin大小为512K,那么512*2+49=1073了
还要修改一下程序里的文件/arch/arm/include/asm/arch-exynos/ movi_partition.h定位到28行
#ifdefCONFIG_TRUSTZONE
#definePART_SIZE_UBOOT (512 *1024) //modify by zth 328->512
#else
#definePART_SIZE_UBOOT (512 * 1024)
#endif
这样就可以真正进行第十二步了。
以下命令提供参考:
cp -R /media/sf_share/u-boot_zth .
chmod 777 -R u-boot_zth /
cd u-boot_zth
make distclean
make zthtiny4412_config
make
cd sd_fuse/
make
cd zthtiny4412/
./sd_fusing.sh /dev/sdb
运行后的串口信息如下图所示:
图19-6 、正常运行串口输出信息截图
图19-7 、正常运行效果图