static void LCD_bl_open(u32 sel)
{
pr_info("[LCD] %s: screen %u\n", __func__, sel);
sunxi_lcd_pwm_enable(sel);
sunxi_lcd_delay_ms(50);
sunxi_lcd_backlight_enable(sel);//config lcd_bl_en pin to open lcd backlight
}
static void LCD_bl_close(u32 sel)
{
pr_info("[LCD] %s: screen %u\n", __func__, sel);
sunxi_lcd_backlight_disable(sel);//config lcd_bl_en pin to close lcd backlight
sunxi_lcd_delay_ms(20);
sunxi_lcd_pwm_disable(sel);
}
#define REGFLAG_DELAY 0XFE
#define REGFLAG_END_OF_TABLE 0xFD // END OF REGISTERS MARKER
struct LCM_setting_table {
u8 cmd;
u32 count;
u8 para_list[64];
};
/*add panel initialization below*/
static struct LCM_setting_table lcm_initialization_setting[] = {
{REGFLAG_DELAY, REGFLAG_DELAY, {120}}, /* 120 ms after reset */
/* Page-1 (0x3001) */
{0xFF, 1, {0x30}},
{0xFF, 1, {0x52}},
{0xFF, 1, {0x01}},
{0xE3, 1, {0x04}},
{0x08, 1, {0x0E}},
{0x25, 1, {0x10}},
{0x28, 1, {0x5F}},
{0x2C, 1, {0x22}},
{0x30, 1, {0x58}},
{0x45, 1, {0x91}},
{0x37, 1, {0x9C}},
{0x38, 1, {0xA7}},
{0x39, 1, {0x27}},
{0x44, 1, {0x00}},
{0x49, 1, {0x1C}},
{0x59, 1, {0xFE}},
{0x5C, 1, {0x00}},
{0x91, 1, {0x77}},
{0x92, 1, {0x77}},
{0xA0, 1, {0x55}},
{0xA1, 1, {0x50}},
{0xA3, 1, {0x58}},
{0xA4, 1, {0x9C}},
{0xA7, 1, {0x02}},
{0xA8, 1, {0x01}},
{0xA9, 1, {0x01}},
{0xAA, 1, {0xFC}},
{0xAB, 1, {0x28}},
{0xAC, 1, {0x06}},
{0xAD, 1, {0x06}},
{0xAE, 1, {0x06}},
{0xAF, 1, {0x03}},
{0xB0, 1, {0x08}},
{0xB1, 1, {0x26}},
{0xB2, 1, {0x28}},
{0xB3, 1, {0x28}},
{0xB4, 1, {0x03}},
{0xB5, 1, {0x08}},
{0xB6, 1, {0x26}},
{0xB7, 1, {0x08}},
{0xB8, 1, {0x26}},
{0xC0, 1, {0x00}},
{0xC1, 1, {0x00}},
{0xC3, 1, {0x0F}},
/* Page-2 (0x3002) */
{0xFF, 1, {0x30}},
{0xFF, 1, {0x52}},
{0xFF, 1, {0x02}},
{0xB0, 1, {0x00}},
{0xB1, 1, {0x05}},
{0xB2, 1, {0x02}},
{0xB3, 1, {0x24}},
{0xB4, 1, {0x25}},
{0xB5, 1, {0x30}},
{0xB6, 1, {0x0C}},
{0xB7, 1, {0x27}},
{0xB8, 1, {0x0F}},
{0xB9, 1, {0x05}},
{0xBA, 1, {0x11}},
{0xBB, 1, {0x10}},
{0xBC, 1, {0x11}},
{0xBD, 1, {0x12}},
{0xBE, 1, {0x17}},
{0xBF, 1, {0x0C}},
{0xC0, 1, {0x14}},
{0xC1, 1, {0x0A}},
{0xD0, 1, {0x08}},
{0xD1, 1, {0x0F}},
{0xD2, 1, {0x09}},
{0xD3, 1, {0x35}},
{0xD4, 1, {0x38}},
{0xD5, 1, {0x3D}},
{0xD6, 1, {0x1B}},
{0xD7, 1, {0x3B}},
{0xD8, 1, {0x0F}},
{0xD9, 1, {0x05}},
{0xDA, 1, {0x11}},
{0xDB, 1, {0x10}},
{0xDC, 1, {0x11}},
{0xDD, 1, {0x14}},
{0xDE, 1, {0x19}},
{0xDF, 1, {0x11}},
{0xE0, 1, {0x19}},
{0xE1, 1, {0x09}},
/* Page-3 (0x3003) */
{0xFF, 1, {0x30}},
{0xFF, 1, {0x52}},
{0xFF, 1, {0x03}},
{0x08, 1, {0x8B}},
{0x09, 1, {0x8A}},
{0x0A, 1, {0x89}},
{0x0B, 1, {0x88}},
{0x34, 1, {0x61}},
{0x35, 1, {0xD4}},
{0x36, 1, {0x24}},
{0x37, 1, {0x03}},
{0x40, 1, {0x8B}},
{0x41, 1, {0x8A}},
{0x42, 1, {0x89}},
{0x43, 1, {0x88}},
{0x45, 1, {0x01}},
{0x46, 1, {0x02}},
{0x48, 1, {0x03}},
{0x49, 1, {0x04}},
{0x50, 1, {0x87}},
{0x51, 1, {0x86}},
{0x52, 1, {0x85}},
{0x53, 1, {0x84}},
{0x55, 1, {0x05}},
{0x56, 1, {0x06}},
{0x58, 1, {0x07}},
{0x59, 1, {0x08}},
{0x80, 1, {0x0F}},
{0x81, 1, {0x0E}},
{0x82, 1, {0x07}},
{0x83, 1, {0x06}},
{0x84, 1, {0x05}},
{0x85, 1, {0x04}},
{0x92, 1, {0x0E}},
{0x93, 1, {0x0F}},
{0x94, 1, {0x01}},
{0x95, 1, {0x00}},
{0x96, 1, {0x0F}},
{0x97, 1, {0x0E}},
{0x98, 1, {0x07}},
{0x99, 1, {0x06}},
{0x9A, 1, {0x05}},
{0x9B, 1, {0x04}},
{0xA8, 1, {0x0E}},
{0xA9, 1, {0x0F}},
{0xAA, 1, {0x01}},
{0xAB, 1, {0x00}},
{0xE0, 1, {0x02}},
{0xE1, 1, {0x52}},
/* Page-0 (0x3000) */
{0xFF, 1, {0x30}},
{0xFF, 1, {0x52}},
{0xFF, 1, {0x00}},
{0x35, 1, {0x00}},
{0x36, 1, {0x02}},
{0x53, 1, {0x2C}},
/* Display ON sequence */
//SLP OUT
{0x11, 0, {0x00} }, // SLPOUT
{REGFLAG_DELAY, REGFLAG_DELAY, {120} },
//DISP ON
{0x29, 0, {0x00} }, // DSPON
{REGFLAG_DELAY, REGFLAG_DELAY, {100} },
{REGFLAG_END_OF_TABLE, REGFLAG_END_OF_TABLE, {} }
};
/*static void LCD_panel_try_switch(u32 sel)
{
u8 result[16] = {0};
u32 num = 0;
sunxi_lcd_delay_ms(100);
sunxi_lcd_dsi_dcs_read(sel, 0x04, result, &num);
printf("get lcd id 0x%x\n", result[0]);
if (result[0] == 0x93) {
LCD_power_off(sel);
sunxi_lcd_switch_compat_panel(sel, 1);
return;
}
}*/
static void LCD_panel_init(u32 sel)
{
__u32 i;
pr_info("[LCD] %s: screen %u - start init table\n", __func__, sel);
sunxi_lcd_dsi_clk_enable(sel);
sunxi_lcd_delay_ms(20);
pr_info("[LCD] %s: sending SW reset\n", __func__);
sunxi_lcd_dsi_dcs_write_0para(sel, DSI_DCS_SOFT_RESET);
//sunxi_lcd_delay_ms(10);
sunxi_lcd_delay_ms(120);
pr_info("[LCD] %s: entering init table loop\n", __func__);
for (i = 0; ; i++) {
if (lcm_initialization_setting[i ].count == REGFLAG_END_OF_TABLE)
break;
else if (lcm_initialization_setting[i ].count == REGFLAG_DELAY)
sunxi_lcd_delay_ms(lcm_initialization_setting[i ].para_list[0]);
#ifdef SUPPORT_DSI
else
dsi_dcs_wr(sel, lcm_initialization_setting[i ].cmd, lcm_initialization_setting[i ].para_list, lcm_initialization_setting[i ].count);
#endif
//break;
}
pr_info("[LCD] %s: screen %u - init table done\n", __func__, sel);
return;
}
static void LCD_panel_exit(u32 sel)
{
pr_info("[LCD] %s: screen %u\n", __func__, sel);
sunxi_lcd_dsi_dcs_write_0para(sel, DSI_DCS_SET_DISPLAY_OFF);
sunxi_lcd_delay_ms(20);
sunxi_lcd_dsi_dcs_write_0para(sel, DSI_DCS_ENTER_SLEEP_MODE);
sunxi_lcd_delay_ms(80);
return ;
}
disp: disp@06000000 {
disp_init_enable = <1>;
disp_mode = <0>;
screen0_output_type = <1>;
screen0_output_mode = <4>;
screen1_output_type = <1>;
screen1_output_mode = <4>;
screen1_output_format = <0>;
screen1_output_bits = <0>;
screen1_output_eotf = <4>;
screen1_output_cs = <257>;
screen1_output_dvi_hdmi = <2>;
screen1_output_range = <2>;
screen1_output_scan = <0>;
screen1_output_aspect_ratio = <8>;
dev0_output_type = <1>;
dev0_output_mode = <4>;
dev0_screen_id = <0>;
dev0_do_hpd = <0>;
dev1_output_type = <4>;
dev1_output_mode = <10>;
dev1_screen_id = <1>;
dev1_do_hpd = <1>;
def_output_dev = <0>;
hdmi_mode_check = <1>;
fb0_format = <0>;
fb0_width = <720>;
fb0_height = <1280>;
fb1_format = <0>;
fb1_width = <0>;
fb1_height = <0>;
chn_cfg_mode = <1>;
disp_para_zone = <1>;
/*VCC-LCD*/
cldo4-supply = <®_cldo4>;
/*VCC-LVDS-1.8V*/
cldo1-supply = <®_cldo1>;
/*VCC-DSI*/
/*VCC-PD-3.3V*/
cldo3-supply = <®_cldo3>;
};
lcd0: lcd0@01c0c000 {
lcd_used = <1>;
lcd_driver_name = "K080_IM2HYL802R_800X1280";
lcd_backlight = <50>;
lcd_if = <4>;
lcd_x = <720>;
lcd_y = <1280>;
lcd_width = <150>;
lcd_height = <36>;
lcd_dclk_freq = <58>;
/* PWM for backlight */
lcd_pwm_used = <1>;
lcd_pwm_ch = <0>;
lcd_pwm_freq = <50000>;
lcd_pwm_pol = <1>;
lcd_pwm_max_limit = <255>;
lcd_hbp = <30>;
lcd_ht = <770>;
lcd_hspw = <6>;
lcd_vbp = <16>;
lcd_vt = <1311>;
lcd_vspw = <4>;
lcd_frm = <0>;
lcd_gamma_en = <0>;
lcd_bright_curve_en = <0>;
lcd_cmap_en = <0>;
deu_mode = <0>;
lcdgamma4iep = <22>;
smart_color = <90>;
lcd_dsi_if = <0>;
lcd_dsi_lane = <4>;
lcd_dsi_format = <0>;
lcd_dsi_te = <0>;
lcd_dsi_eotp = <0>;
lcd_pin_power = "cldo3"; // VCC-PD (3.3 V)
lcd_power1 = "cldo1"; // VCC-LVDS (1.8 V)
lcd_power2 = "cldo4"; // VCC-LCD (3.3 V)
lcd_gpio_1 = <&pio PD 22 1 0 3 1>; /* RESET */
pinctrl-0 = <&dsi4lane_pins_a>;
pinctrl-1 = <&dsi4lane_pins_b>;
lcd_bl_en = <&pio PD 23 1 1 0 3 1>;
lcd_bl_0_percent = <15>;
lcd_bl_100_percent = <100>;
};
离线