A33_LCD的驱动调试

lichee\tools\pack\chips\sun8iw5p1\configs\m86\sysconfig.fex里面

;lcd0 configuration

;lcd_if:               0:hv(sync+de); 1:8080; 2:ttl; 3:lvds; 4:dsi; 5:edp; 6:extend dsi
;lcd_x:                lcd horizontal resolution
;lcd_y:                lcd vertical resolution
;lcd_width:            width of lcd in mm
;lcd_height:           height of lcd in mm
;lcd_dclk_freq:        in MHZ unit
;lcd_pwm_freq:         in HZ unit
;lcd_pwm_pol:          lcd backlight PWM polarity
;lcd_pwm_max_limit     lcd backlight PWM max limit(<=255)
;lcd_hbp:              hsync back porch
;lcd_ht:               hsync total cycle
;lcd_vbp:              vsync back porch
;lcd_vt:               vysnc total cycle
;lcd_hspw:             hsync plus width
;lcd_vspw:             vysnc plus width
;lcd_lvds_if:          0:single link;  1:dual link
;lcd_lvds_colordepth:  0:8bit; 1:6bit
;lcd_lvds_mode:        0:NS mode; 1:JEIDA mode
;lcd_frm:              0:disable; 1:enable rgb666 dither; 2:enable rgb656 dither
;lcd_io_phase:         0:noraml; 1:intert phase(0~3bit: vsync phase; 4~7bit:hsync phase;
;                      8~11bit:dclk phase; 12~15bit:de phase)
;lcd_gamma_en          lcd gamma correction enable
;lcd_bright_curve_en   lcd bright curve correction enable
;lcd_cmap_en           lcd color map function enable
;deu_mode              0:smoll lcd screen; 1:large lcd screen(larger than 10inch)
;lcdgamma4iep:         Smart Backlight parameter, lcd gamma vale * 10;
;                      decrease it while lcd is not bright enough; increase while lcd is too bright
;smart_color           90:normal lcd screen 65:retina lcd screen(9.7inch)

[lcd0_para]
lcd_used            = 1

lcd_driver_name     = "jd9362"
lcd_if              = 4  ;DSI接口 ;如果是RGB接口,用0
lcd_x               = 1024  ;TP的 screen_x 大小与LCD分辨率保持一致 ctp_screen_max_x    = 1024
lcd_y               = 600    ;TP的 screen_y 大小与LCD分辨率保持一致 ctp_screen_max_y    = 600
lcd_width           = 155
lcd_height          = 86
lcd_dclk_freq       = 52 ;htotal X vtotal X 60 = lcd_dclk_freq
lcd_pwm_used        = 1 ;这组是否使用
lcd_pwm_ch          = 1 ;pwm使用第几组
lcd_pwm_freq        = 15000  ;当 htotal 、vtotal 过大时 lcd_pwm_freq=50000
lcd_pwm_pol         = 1
lcd_hbp             = 160
lcd_ht              = 1344 ;hspw + hbackporth + hfrontporth + lcd_x = htotal
lcd_hspw            = 20  ;vspw + vbackporth + vfrontporth + lcd_y = vtotal
lcd_vbp             = 23
lcd_vt              = 635
lcd_vspw            = 3
lcd_dsi_if          = 0
lcd_dsi_lane        = 2 ;MIPI 是串行接口,故时钟是必须有的,而且它又是差分传输,故时钟有正负之分,lane指的是数据通道,也就是data1+,data1-,假如一个lane的话。
lcd_dsi_format      = 0
lcd_dsi_eotp        = 0
lcd_dsi_vc          = 0
lcd_dsi_te          = 0
lcd_frm             = 1
lcd_gamma_en        = 0
lcd_bright_curve_en = 0
lcd_cmap_en         = 0

deu_mode            = 0
lcdgamma4iep        = 22
smart_color        = 90

lcd_bl_en           = port:PH06<1><0><1> ;背光 enable 脚
lcd_power           = "axp22_dc1sw"
lcd_gpio_0          = port:PH07<1><0><1> ;这个是reset脚

如果是MIPI屏则配置完成

如果是RGB屏则还需如下配置

lcdd0                   = port:PD02<2><0><3>

。。。。。

lcdd17                  = port:PD23<2><0><3>

lcdclk                   = port:PD24<2><0>
lcdde                    = port:PD25<2><0>
lcdhsync                 = port:PD26<2><0>
lcdvsync                 = port:PD27<2><0>

;----------------------------------------------------------------------------------
;pwm config
;----------------------------------------------------------------------------------
[pwm0_para]
pwm_used            = 0
;pwm_positive        = port:PH00<2><0>

[pwm1_para]
pwm_used            = 1
pwm_positive        = port:PH01<2><0>

lichee\brandy\u-boot-2011.09\drivers\video_sunxi\sunxi_v2\de_bsp\lcd\panels\jd9362.c与kernel中的 jd9362.c一模一样

lichee\brandy\u-boot-2011.09\drivers\video_sunxi\sunxi_v2\de_bsp\lcd\panels\panel.c也与kernel中的 panel.c一模一样

lichee\brandy\u-boot-2011.09\drivers\video_sunxi\sunxi_v2\obj_video中添加如下,(相当于kernel中的 Makefile)

ifeq ($(CONFIG_ARCH_SUN8IW5P1),y)
SUNXI_VIDEO_OBJ = sunxi_v2/dev_disp.o\

sunxi_v2/de_bsp/lcd/panels/R837_jd9362.o

endif

开机后经uboot启动 linux 内核,uboot 具有读写 flash或者 sdcard的能力,同时还会进行时钟,初始化等配置,linux内核会生成根文件系统,在根文件系统上获取应用

lichee\linux-3.4\drivers\video\sunxi\lcd\panels\需要配置

panels\jd9362.c

#include "jd9362.h"
#include "panels.h"

//上电初始化

static void LCD_power_on(u32 sel);
static void LCD_power_off(u32 sel);
static void LCD_bl_open(u32 sel);
static void LCD_bl_close(u32 sel);

static void LCD_panel_init(u32 sel);
static void LCD_panel_exit(u32 sel);

extern int lcd_2v8_enable(void);
extern int lcd_2v8_disable(void);

//上电初始化

static struct LCM_setting_table jd9326_initialization[] = {

} //屏厂需提供的上电初始化参数

static void LCD_cfg_panel_info(panel_extend_para * info)
{
 u32 i = 0, j=0;
 u32 items;
 u8 lcd_gamma_tbl[][2] =
 {
  //{input value, corrected value}
  {0, 0},
  {15, 15},
  {30, 30},
  
  {45, 45},
  {60, 60},
  {75, 75},
  {90, 90},
  {105, 105},
  {120, 120},
  {135, 135},
  {150, 150},
  {165, 165},
  {180, 180},
  {195, 195},
  {210, 210},
  {225, 225},
  {240, 240},
  {255, 255},
 };

 

 u32 lcd_cmap_tbl[2][3][4] = {
 {
  {LCD_CMAP_G0,LCD_CMAP_B1,LCD_CMAP_G2,LCD_CMAP_B3},
  {LCD_CMAP_B0,LCD_CMAP_R1,LCD_CMAP_B2,LCD_CMAP_R3},
  {LCD_CMAP_R0,LCD_CMAP_G1,LCD_CMAP_R2,LCD_CMAP_G3},
  },
  {
  {LCD_CMAP_B3,LCD_CMAP_G2,LCD_CMAP_B1,LCD_CMAP_G0},
  {LCD_CMAP_R3,LCD_CMAP_B2,LCD_CMAP_R1,LCD_CMAP_B0},
  {LCD_CMAP_G3,LCD_CMAP_R2,LCD_CMAP_G1,LCD_CMAP_R0},
  },
 };

 

 items = sizeof(lcd_gamma_tbl)/2;
 for(i=0; i   u32 num = lcd_gamma_tbl[i+1][0] - lcd_gamma_tbl[i][0];

 

  for(j=0; j    u32 value = 0;

 

   value = lcd_gamma_tbl[i][1] + ((lcd_gamma_tbl[i+1][1] - lcd_gamma_tbl[i][1]) * j)/num;
   info->lcd_gamma_tbl[lcd_gamma_tbl[i][0] + j] = (value<<16) + (value<<8) + value;
  }
 }
 info->lcd_gamma_tbl[255] = (lcd_gamma_tbl[items-1][1]<<16) + (lcd_gamma_tbl[items-1][1]<<8) + lcd_gamma_tbl[items-1][1];

 memcpy(info->lcd_cmap_tbl, lcd_cmap_tbl, sizeof(lcd_cmap_tbl));

}

static s32 LCD_open_flow(u32 sel)
{

 

//sunxi_lcd_delay_ms(100);
 LCD_OPEN_FUNC(sel, LCD_power_on, 50);   //open lcd power, and delay 50ms

 

 LCD_OPEN_FUNC(sel, LCD_panel_init, 100);   //open lcd power, than delay 200ms
 LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable, 100);     //open lcd controller, and delay 100ms
 LCD_OPEN_FUNC(sel, LCD_bl_open, 0);     //open lcd backlight, and delay 0ms

 

 return 0;
}

 

static s32 LCD_close_flow(u32 sel)
{
 LCD_CLOSE_FUNC(sel, LCD_bl_close, 0);       //close lcd backlight, and delay 0ms
 LCD_CLOSE_FUNC(sel, sunxi_lcd_tcon_disable, 0);         //close lcd controller, and delay 0ms
 LCD_CLOSE_FUNC(sel, LCD_panel_exit, 20);   //open lcd power, than delay 200ms
 LCD_CLOSE_FUNC(sel, LCD_power_off, 50);   //close lcd power, and delay 500ms

 return 0;
}

static void LCD_power_on(u32 sel)
{

 


 //lcd_2v8_enable();
 //sunxi_lcd_delay_ms(50);
 sunxi_lcd_power_enable(sel, 0);//config lcd_power pin to open lcd power0
 sunxi_lcd_delay_ms(20);
 sunxi_lcd_power_enable(sel, 1);//config lcd_power pin to open lcd power0
 //sunxi_lcd_delay_ms(5);
 //sunxi_lcd_power_enable(sel, 2);//config lcd_power pin to open lcd power2
 //sunxi_lcd_delay_ms(5);
 //power_en(1);

 

 //sunxi_lcd_delay_ms(50);
 //sunxi_lcd_delay_ms(20);
 //panel_reset(1);
 //panel_rst(1);
 sunxi_lcd_delay_ms(10);
 sunxi_lcd_pin_cfg(sel, 1);
}

 

static void LCD_power_off(u32 sel)
{
 sunxi_lcd_pin_cfg(sel, 0);
 //power_en(0);
// sunxi_lcd_delay_ms(20);
 //panel_reset(0);
// panel_rst(0);
// sunxi_lcd_delay_ms(5);
// sunxi_lcd_power_disable(sel, 2);//config lcd_power pin to close lcd power2
// sunxi_lcd_delay_ms(5);
 sunxi_lcd_power_disable(sel, 1);//config lcd_power pin to close lcd power1
 sunxi_lcd_delay_ms(20);
// lcd_2v8_disable();
 sunxi_lcd_power_disable(sel, 0);//config lcd_power pin to close lcd power
}

 

static void LCD_bl_open(u32 sel)
{
 sunxi_lcd_pwm_enable(sel);//open pwm module
 sunxi_lcd_backlight_enable(sel);//config lcd_bl_en pin to open lcd backlight
}

 

static void LCD_bl_close(u32 sel)
{
 sunxi_lcd_backlight_disable(sel);//config lcd_bl_en pin to close lcd backlight
 sunxi_lcd_pwm_disable(sel);//close pwm module
}

 

static void LCD_panel_init(u32 sel)
{
 __u32 i;
//========================================
 sunxi_lcd_pin_cfg(sel, 1);
 sunxi_lcd_delay_ms(10);

 

 
 panel_rst(1);
 sunxi_lcd_delay_ms(10);
 panel_rst(0);
 sunxi_lcd_delay_ms(20);
 panel_rst(1);
 sunxi_lcd_delay_ms(50);
 
 for (i=0;;i++) {
   if(jd9326_initialization[i].cmd == 0x02)
    break;
   else if (jd9326_initialization[i].cmd == 0x01)
    sunxi_lcd_delay_ms(jd9326_initialization[i].count);
   else{
    //printk("mipi 9362,lcd start write data,by zyt\n");
    sunxi_lcd_dsi_write(0,jd9326_initialization[i].cmd,jd9326_initialization[i].para_list,jd9326_initialization[i].count);
   } 
  }
 sunxi_lcd_delay_ms(50); 
 sunxi_lcd_dsi_clk_enable(sel);
    sunxi_lcd_delay_ms(100);
 return;
}

 

static void LCD_panel_exit(u32 sel)
{
 sunxi_lcd_dsi_clk_disable(sel);
 panel_rst(0);
 return ;
}

 

//sel: 0:lcd0; 1:lcd1
static s32 LCD_user_defined_func(u32 sel, u32 para1, u32 para2, u32 para3)
{
 return 0;
}

__lcd_panel_t jd9362_panel = {
 /* panel driver name, must mach the name of lcd_drv_name in sys_config.fex */
 .name = "jd9362", //如果与sysconfig.fex中的名字匹配成功,则会跑func下的子函数
 .func = {
  .cfg_panel_info = LCD_cfg_panel_info,
  .cfg_open_flow = LCD_open_flow,
  .cfg_close_flow = LCD_close_flow,
  .lcd_user_defined_func = LCD_user_defined_func,
 },
};

panels\panel.c下

#include "panels.h"
#include "default_panel.h"
#include "tft720x1280.h"
#include "starry768x1024.h"

extern __lcd_panel_t jd9362_panel;

__lcd_panel_t* panel_array[] = {

 &jd9362_panel,

}

lichee/tools/pack/chips/sun8iw5p1/configs/m86/bootlogo.bmp 通过打开方式里的画图中的调整图像大小,取消纵横比, 把图像大小 X,Y设为 LCD的 X, Y保存。

然后编译,烧录,一般情况下,LCD都会正常显示

你可能感兴趣的:(驱动调试)