u-boot 起來(排除 u-boot console wait time) 到 kernel logo show 出來會有段蠻常的時間 , 如果沒有任何 logo , 使用者可能會認為...當機 !!
好吧 , 加上 frame buffer driver 到 u-boot 上吧 !! 不過要先確認 backlit dirver 可以 working . backlit 比較簡單 , 所以就不說明了 !!
開始 lcd driver 移植到 u-boot 吧 !!
第一步驟 , 要先啟動 LCDC 相關的 clock / power domain .
#define CM_PER_LCDC_CLKCTRL (CM_PER + 0x18) /* LCDC */
#define CM_PER_LCDC_CLKSTCTRL (CM_PER + 0x148)/* LCDC */
第二步驟 , 設定 LCDC 的 PLL Clock .
void disp_pll_clocks(void)
{
u32 clkmode, clksel, div_m2;
clkmode = readl(CM_CLKMODE_DPLL_DISP);
clksel = readl(CM_CLKSEL_DPLL_DISP);
div_m2 = readl(CM_DIV_M2_DPLL_DISP);
/* Set the PLL to bypass Mode */
clkmode = (clkmode & 0xfffffff8) | 0x00000004;
writel(clkmode, CM_CLKMODE_DPLL_DISP);
while ((readl(CM_IDLEST_DPLL_DISP) & 0x00000100) != 0x00000100);
clksel = clksel & (~0x7ffff);
clksel = clksel | ((DISPPLL_M << 0x8) | DISPPLL_N);
writel(clksel, CM_CLKSEL_DPLL_DISP);
div_m2 = div_m2 & 0xFFFFFFE0;
div_m2 = div_m2 | DISPPLL_M2;
writel(div_m2, CM_DIV_M2_DPLL_DISP);
clkmode = (clkmode & 0xfffffff8) | 0x7;
writel(clkmode, CM_CLKMODE_DPLL_DISP);
while ((readl(CM_IDLEST_DPLL_DISP) & 0x00000001) != 0x1);
}
第三步驟, 設定 LCD 相關 GPIO 的 function.
static struct module_pin_mux lcdc_pin_mux[] =
{
{OFFSET(gpmc_csn3), (MODE(7) | PULLUDEN)}, /* GPIO2_0 ,LCD_PWREN */
{OFFSET(lcd_data0), MODE(0) | PULLUDEN}, /* Makesure lcd_data_0 */
{OFFSET(lcd_data1), MODE(0) | PULLUDEN}, /* Makesure lcd_data_1 */
{OFFSET(lcd_data2), MODE(0) | PULLUDEN}, /* Makesure lcd_data_2 */
{OFFSET(lcd_data3), MODE(0) | PULLUDEN}, /* Makesure lcd_data_3 */
{OFFSET(lcd_data4), MODE(0) | PULLUDEN}, /* Makesure lcd_data_4 */
{OFFSET(lcd_data5), MODE(0) | PULLUDEN}, /* Makesure lcd_data_5 */
{OFFSET(lcd_data6), MODE(0) | PULLUDEN}, /* Makesure lcd_data_6 */
{OFFSET(lcd_data7), MODE(0) | PULLUDEN}, /* Makesure lcd_data_7 */
{OFFSET(lcd_data8), MODE(0) | PULLUDEN}, /* Makesure lcd_data_8 */
{OFFSET(lcd_data9), MODE(0) | PULLUDEN}, /* Makesure lcd_data_9 */
{OFFSET(lcd_data10), MODE(0) | PULLUDEN}, /* Makesure lcd_data_10 */
{OFFSET(lcd_data11), MODE(0) | PULLUDEN}, /* Makesure lcd_data_11 */
{OFFSET(lcd_data12), MODE(0) | PULLUDEN}, /* Makesure lcd_data_12 */
{OFFSET(lcd_data13), MODE(0) | PULLUDEN}, /* Makesure lcd_data_13 */
{OFFSET(lcd_data14), MODE(0) | PULLUDEN}, /* Makesure lcd_data_14 */
{OFFSET(lcd_data15), MODE(0) | PULLUDEN}, /* Makesure lcd_data_15 */
{OFFSET(gpmc_ad15), MODE(1) | PULLUDEN}, /* lcd_data_16 */
{OFFSET(gpmc_ad14), MODE(1) | PULLUDEN}, /* lcd_data_17 */
{OFFSET(gpmc_ad13), MODE(1) | PULLUDEN}, /* lcd_data_18 */
{OFFSET(gpmc_ad12), MODE(1) | PULLUDEN}, /* lcd_data_19 */
{OFFSET(gpmc_ad11), MODE(1) | PULLUDEN}, /* lcd_data_20 */
{OFFSET(gpmc_ad10), MODE(1) | PULLUDEN}, /* lcd_data_21 */
{OFFSET(gpmc_ad9), MODE(1) | PULLUDEN}, /* lcd_data_22 */
{OFFSET(gpmc_ad8), MODE(1) | PULLUDEN}, /* lcd_data_23 */
{OFFSET(lcd_pclk), MODE(0) | PULLUDEN}, /* lcd_pclk */
{OFFSET(lcd_vsync), MODE(0) | PULLUDEN}, /* lcd_vsync */
{OFFSET(lcd_hsync), MODE(0) | PULLUDEN}, /* lcd_hsync */
{OFFSET(lcd_ac_bias_en), MODE(0) | PULLUDEN}, /* lcd_ac_bias */
{-1},
};
第四步驟, 在 video 下增加 driver file .
Make file 中多這項目. am335x_lcdc.c 需要由 kernel 那邊移植過來. 去掉 kernel 相關的部份.
COBJS-$(CONFIG_VIDEO_AM335X) += am335x_lcdc.o
第五步驟 , 在 am335_evm.h 中增加下列選項
u-boot 本身就有支援 lcd 的 driver library 了 , 所以要打開 CONFIG_LCD ,
另外SYS_CONSOLE_IS_IN_ENV 要打開 , 不然 console 會跑到 LCD 上 ,並非 UART.
/* LCD Support */
#define CONFIG_LCD
#ifdef CONFIG_LCD
#define CONFIG_VIDEO_AM335X
#define CONFIG_SYS_CONSOLE_IS_IN_ENV // prevent console switch to LCD.
//---- select LCD type .
#define CONFIG_LCD_TM050RBH01
//---- setting logo file name
#define CONFIG_LOGO_FILE_NAME "inst_logo.raw"
//---- enable backlit support.
#define CONFIG_CMD_BACKLIT
#endif
最後一個步驟 ,在 lcd.h 中增加 相關的 struct 欄位, 這個欄位最後和 kernel 的相同,
這樣移植過程比較順利..
#elif defined(CONFIG_VIDEO_AM335X)
enum panel_type
{
QVGA = 0,
WVGA,
};
enum panel_shade
{
MONOCHROME = 0,
COLOR_ACTIVE,
COLOR_PASSIVE,
};
typedef struct vidinfo
{
ushort vl_col; /* Number of columns (i.e. 160) */
ushort vl_row; /* Number of rows (i.e. 100) */
u_char vl_bpix; /* Bits per pixel, 0 = 1 */
//---- Frame buffer parameter.
enum panel_type panel_type ;
int max_bpp;
int min_bpp;
enum panel_shade panel_shade;
int ac_bias; /* AC Bias Pin Frequency */
int ac_bias_intrpt; /* AC Bias Pin Transitions per Interrupt */
int dma_burst_sz; /* DMA burst size */
int bpp; /* Bits per pixel */
int fdd; /* FIFO DMA Request Delay */
/* TFT Alternative Signal Mapping (Only for active) */
unsigned char tft_alt_mode;
/* 12 Bit Per Pixel (5-6-5) Mode (Only for passive) */
unsigned char stn_565_mode;
/* Mono 8-bit Mode: 1=D0-D7 or 0=D0-D3 */
unsigned char mono_8bit_mode;
unsigned char sync_edge; /* Horizontal and Vertical Sync Edge: 0=rising 1=falling */
unsigned char sync_ctrl; /* Horizontal and Vertical Sync: Control: 0=ignore */
unsigned char raster_order; /* Raster Data Order Select: 1=Most-to-least 0=Least-to-most */
int fifo_th; /* DMA FIFO threshold */
//---- LCD Panel data
unsigned short width;
unsigned short height;
int hfp; /* Horizontal front porch */
int hbp; /* Horizontal back porch */
int hsw; /* Horizontal Sync Pulse Width */
int vfp; /* Vertical front porch */
int vbp; /* Vertical back porch */
int vsw; /* Vertical Sync Pulse Width */
unsigned int pxl_clk; /* Pixel clock */
unsigned char invert_pxl_clk; /* Invert Pixel clock */
unsigned char invert_line_clock; /* Invert line clock */
unsigned char invert_frm_clock; /* Invert frame clock */
//---- par parameter.
unsigned long pseudo_palette[32];
unsigned char *v_palette_base;
unsigned int palette_sz;
void *video_mem;
}vidinfo_t;
注意事項.
Driver 其實只要 implentment 下列這三個 function 就可以了.
其中要注意 setcolreg 的function , AM335x TFT 24/32 BPP 沒有 調色盤 , 不需要
設定..
void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
void lcd_ctrl_init(void *lcdbase);
void lcd_enable(void);
打完收工.......
Hai,
回覆刪除Am trying to get uboot logo in BBB. I have initialized tft successfully. Hope u have done it. Can you explain the above thing in English
What's BBB?
回覆刪除This post just discuss how to initially TFT in u boot !
Beagle Bone Black
回覆刪除can u please send am335x_lcdc.c file?
回覆刪除where can i added "inst_logo.raw" file