Am335x U-boot LCD简易驱动

参考此文档说明,自行添加相关代码:

https://pan.baidu.com/s/1i5gLE89

相关代码:

https://pan.baidu.com/s/1qXL8Bne

在文档说明第四步1中,需要手动添加rasterDisplay.h文件,主要是定义rasterDisplay.c中的函数,方便在xxx/board/ti/board.c中调用。

修改rasterDisplay.c中对应于自己的LCD屏的参数(NHD-4.3-480272)

由NHD-4.3-480272数据手册获得LCD参数

hactive---480

hsw-----41

hfp------2

hbp-----2

vactive-----272

vsw-----10

vfp------2

vbp------2

pclk=9000000Hz(pix-clk)

RasterClkConfig(SOC_LCDC_0_REGS, 9000000, 100000000);
RasterTiming2Configure(SOC_LCDC_0_REGS,                                 RASTER_FRAME_CLOCK_HIGH |
                                            RASTER_LINE_CLOCK_HIGH  |
                                            RASTER_PIXEL_CLOCK_HIGH|
                                            RASTER_SYNC_EDGE_RISING|
                                            RASTER_SYNC_CTRL_ACTIVE|
                                            RASTER_AC_BIAS_HIGH     , 0, 255); 
 RasterHparamConfig(SOC_LCDC_0_REGS, 480, 41, 2, 2);
   RasterVparamConfig(SOC_LCDC_0_REGS, 272, 10, 2, 2);

第四步2中添加相关宏,除了添加CONFIG_LCD_UBOOT还要添加CONFIG_CMDLINE(第五步中控制LCD用),。

第四步3中添加lcdblacklight时要根据自己的板子看一看是哪个GPIO控制的LCD背光,还要确定是该电平背光开还是低电平背光开。

第五步3中在配置文件中添加复位LCD时,若按源文档说明,在RESET_LCD出老报错,所以直接将run RESET_LCD修改为run ULCD reset\0

第三步中获得自己的image.h:在第7小步中再生成自己的image.h中命令的最后需为RGB ./a.out 480 272 ./图片名称.bmp ./image.h 24 RGB,要不然生成的image.h在LCD上显示时黄色显示非标准色。

相关代码修改处:

xxxx/drivers/makefile

obj-$(CONFIG_SPL_WATCHDOG_SUPPORT) += watchdog/
obj-$(CONFIG_SPL_USB_HOST_SUPPORT) += usb/host/
obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/
obj-$(CONFIG_SPL_SATA_SUPPORT) += block/

obj-$(CONFIG_LCD_UBOOT) += lcd/

else

obj-y += adc/
obj-$(CONFIG_DM_DEMO) += demo/
obj-$(CONFIG_BIOSEMU) += bios_emulator/
obj-y += block/
obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/
obj-$(CONFIG_CPU) += cpu/
obj-y += crypto/
obj-$(CONFIG_FPGA) += fpga/
obj-y += hwmon/
obj-y += misc/
obj-y += pcmcia/
obj-y += dfu/
obj-$(CONFIG_X86) += pch/
obj-y += rtc/
obj-y += sound/
obj-y += timer/
obj-y += tpm/
obj-y += twserial/
obj-y += video/
obj-y += lcd/
obj-y += watchdog/

 

xxxx/drivers/lcd/rasterDisplay

#include "soc_AM335x.h"
#include "evmAM335x.h"
#include "raster.h"
#include "image2.h"
#include "rasterDisplay.h"

 

xxx/board/ti/board.c

#include "../../../drivers/lcd/rasterDisplay.h"

int board_init(void)
{
#if defined(CONFIG_HW_WATCHDOG)
hw_watchdog_init();
#endif

gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
#if defined(CONFIG_NOR) || defined(CONFIG_NAND)
gpmc_init();
#endif

#if !defined(CONFIG_SPL_BUILD)
#if defined(CONFIG_LCD_UBOOT)
Lcd_Init();
lcdbacklight((3*32+17),"lcdbacklight",0);
#endif
#endif

#if defined(CONFIG_LCD)
am335xfb_init( &lcd_panel_NHD480272 );
gpio_request( (3*32+17), "led_light" );
gpio_direction_output( (3*32+17), 0 );
#endif

#if defined(CONFIG_LCDB)
board_video_init();
//configure_module_pin_mux(bld_pin_mux);
gpio_request( (3*32+17), "led_light" );
gpio_direction_output( (3*32+17), 0 );
//board_video_init();
#endif

return 0;
}

xxxx/cmd

添加lcd_cmd.c

/*
+ * DATE 2017.6
+ * writer:ZYR
+ * Uboot LCD
+ */

#include <common.h>
#include <config.h>
#include <command.h>
#include <asm/io.h>
#include "../drivers/lcd/rasterDisplay.h"
#include "../board/ti/am335x/board.h"

int get_int(char *num)
{
    int len = strlen(num);
    int i, result = 0;
    for(i=0; i<len; i++)
    {
        result = result * 10 + ( num[i] - '0' );
    }
    return result;
}

int get_lcd_cmd(char *var)
{
    if ( strcmp(var, "off") == 0 )
        return 0;
    
    if ( strcmp(var, "on") == 0 )
        return 1;
    
    if ( strcmp(var, "reset") == 0 )
        return 2;
    
    if ( strcmp(var, "set") == 0 )
        return 3;
        
    return -1;
    
}

static int do_lcd( cmd_tbl_t*cmdtp, int flag, int argc, char *const argv[] )
{
    int cmd;
    /*Validate arguments */
    if( ( argc<1)||(argc>2) )
        return CMD_RET_USAGE;
        
    cmd = get_lcd_cmd( argv[1] ); //  
    if( cmd < 0 )
    {
        return CMD_RET_USAGE;
    }
#ifdef CONFIG_CMDLINE
    if( cmd==0 )
    {
        printf("lcd off\n");
        lcdbacklight_off(3*32+17);
    }
    else if( cmd==1 )
    {
        printf("lcd on \n");
        lcdbacklight_on(3*32+17);
    }
    else if( cmd==2 )
    {
        printf(" lcd reset\n");
        board_lcd_reset(3*32+17);
    }
    
    return 0;
#else
    return 1;
#endif
}

U_BOOT_CMD(
    ULCD, 2,  1,  do_lcd,
    "lcd open or close or reset \n",
    "ULCD [on|off|reset]\n"
);

xxxx/cmd/makefile

obj-y += help.o
obj-y += version.o
obj-y += lcd_cmd.o

# command
obj-$(CONFIG_LCD_UBOOT) += lcd_cmd.o
obj-$(CONFIG_CMD_AES) += aes.o
obj-$(CONFIG_CMD_AMBAPP) += ambapp.o

 

xxx/include/configs/am335x_evm.h

#define CONFIG_BOOTCOMMAND \
"run findfdt; " \
"run ULCD reset\0; " \
"run distro_bootcmd"

 

posted @ 2017-06-06 11:05  竹主  阅读(2498)  评论(0编辑  收藏  举报