【VR9项目】天马屏配置流程(二):Uboot

一、I2C配置

(1)sun50iw3p1.h

根据全志FAE的要求,开启i2c的配置宏

#define CONFIG_SYS_I2C
#define CONFIG_I2C_MULTI_BUS
#define CONFIG_SYS_MAX_I2C_BUS 4
#define CONFIG_SUNXI_I2C
#define CONFIG_SYS_I2C_SPEED 400000
#define CONFIG_SYS_I2C_SLAVE 0x36
(2)sunxi_i2c_common.c

根据全志FAE的要求,添加sun50平台I2C封装接口

#if defined (CONFIG_ARCH_SUN50IW3P1)
U_BOOT_I2C_ADAP_COMPLETE(sunxi_i2c1, sunxi_i2c_init, sunxi_i2c_probe,
			 sunxi_i2c_read, sunxi_i2c_write, sunxi_i2c_setspeed,
			 CONFIG_SYS_I2C_SPEED,
			 CONFIG_SYS_I2C_SLAVE, /*don't care*/
			 1)
U_BOOT_I2C_ADAP_COMPLETE(sunxi_i2c2, sunxi_i2c_init, sunxi_i2c_probe,
			 sunxi_i2c_read, sunxi_i2c_write, sunxi_i2c_setspeed,
			 CONFIG_SYS_I2C_SPEED,
			 CONFIG_SYS_I2C_SLAVE, /*don't care*/
			 2)
U_BOOT_I2C_ADAP_COMPLETE(sunxi_i2c3, sunxi_i2c_init, sunxi_i2c_probe,
			 sunxi_i2c_read, sunxi_i2c_write, sunxi_i2c_setspeed,
			 CONFIG_SYS_I2C_SPEED,
			 CONFIG_SYS_I2C_SLAVE, /*don't care*/
			 3)
U_BOOT_I2C_ADAP_COMPLETE(sunxi_i2c4, sunxi_i2c_init, sunxi_i2c_probe,
			 sunxi_i2c_read, sunxi_i2c_write, sunxi_i2c_setspeed,
			 CONFIG_SYS_I2C_SPEED,
			 CONFIG_SYS_I2C_SLAVE, /*don't care*/
			 4)
#if defined(CONFIG_CPUS_I2C)
U_BOOT_I2C_ADAP_COMPLETE(sunxi_r_i2c0, sunxi_r_i2c_init, sunxi_i2c_probe,
			 sunxi_i2c_read, sunxi_i2c_write,
			 sunxi_i2c_setspeed,
			 CONFIG_SYS_I2C_SPEED,
			 CONFIG_SYS_I2C_SLAVE, /*don't care*/
			 5)
#endif
#else
#if defined(CONFIG_USE_AC200) && defined (CONFIG_ARCH_SUN50IW6P1)
U_BOOT_I2C_ADAP_COMPLETE(sunxi_i2c3, sunxi_i2c_init, sunxi_i2c_probe,
			 sunxi_i2c_read, sunxi_i2c_write,
			 sunxi_i2c_setspeed,
			 CONFIG_SYS_I2C_AC200_SPEED,
			 CONFIG_SYS_I2C_AC200_SLAVE,
			 3)
#endif

#if defined(CONFIG_CPUS_I2C)
U_BOOT_I2C_ADAP_COMPLETE(sunxi_r_i2c0, sunxi_r_i2c_init, sunxi_i2c_probe,
			 sunxi_i2c_read, sunxi_i2c_write,
			 sunxi_i2c_setspeed,
			 CONFIG_SYS_I2C_SPEED,
			 CONFIG_SYS_I2C_SLAVE,
			 4)
#endif
#endif
(3)sunxi_i2c.h

定义I2C端口

enum {
	SUNXI_I2C0 = 0,
#if defined (CONFIG_ARCH_SUN50IW3P1)
	SUNXI_I2C1,
	SUNXI_I2C2,
	SUNXI_I2C3,
	SUNXI_I2C4,
#if defined(CONFIG_CPUS_I2C)
	SUNXI_R_I2C0,
#endif
#else
#if defined(CONFIG_USE_AC200) && defined (CONFIG_ARCH_SUN50IW6P1)
	SUNXI_I2C3,
#endif
#if defined(CONFIG_CPUS_I2C)
	SUNXI_R_I2C0,
#endif
#endif
};
二、LCD配置流程

(1)LCD配置接口

__lcd_panel_t lq101r1sx03_panel = {
	/* panel driver name, must mach the name of lcd_drv_name in sys_config.fex */
	.name = "lq101r1sx03",
	.func = {
		 .cfg_panel_info = lcd_cfg_panel_info, //TCON扩展参数配置,gamma校正 色彩映射
		 .cfg_open_flow = lcd_open_flow,   //开屏流程
		 .cfg_close_flow = lcd_close_flow,   //关屏流程
		 .lcd_user_defined_func = lcd_user_defined_func,  //名字可改成屏对应的名字
		 .set_bright = lcd_set_bright,     //亮度调节
		 }
	,
};
(2)开屏流程

上电(LCD_Power_on) ---->屏初始化( LCD_Panel_init) ---->使能gamma( sunxi_lcd_tcon_enable ----> LCD_bl_open

函数代码如下:其中LCD_OPEN_FUNC的作用是将对应的函数注册到开屏流程中,并不会立即调用对应的函数体。

扫描二维码关注公众号,回复: 2097124 查看本文章

static s32 lcd_open_flow(u32 sel)
{
	LCD_OPEN_FUNC(sel, lcd_power_on, 250);
	LCD_OPEN_FUNC(sel, lcd_panel_init, 10);
	LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable, 50);
	LCD_OPEN_FUNC(sel, lcd_bl_open, 0);

	return 0;
}
2.1 上电流程
  
#define power_en1(val)  sunxi_lcd_gpio_set_value(sel, 1, val)  //ENP使能
#define power_en2(val)  sunxi_lcd_gpio_set_value(sel, 2, val)  //ENN使能

static void lcd_power_on(u32 sel)
{
    /*added by PICO_driver ben.li for bug18845:开机后有声音无图像--start--*/
    unsigned char data = 0;
    power_en1(0);   //ENP关闭
    power_en2(0);   //ENN关闭
    sunxi_lcd_delay_ms(10);
    /*added by PICO_driver ben.li for bug18845:开机后有声音无图像--end--*/
    /* set lcd-rst to 0 */
    panel_reset(0);   
    /* vcc-dsi */
    sunxi_lcd_power_enable(sel, 0);
    sunxi_lcd_delay_ms(10);
    /* vcc18-lcd */
    sunxi_lcd_power_enable(sel, 1);
    sunxi_lcd_delay_ms(10);
    /* vcc33-lcd */
    sunxi_lcd_power_enable(sel, 2);
    sunxi_lcd_delay_ms(10);
    power_en1(1);
    power_en2(1);
    /*added by PICO_driver ben.li for bug25068:调节背光电压--start--*/
    i2c_set_bus_num(SUNXI_I2C2);
    i2c_init( 400000,normal_i2c[0]);
    data = 0x0f;
    i2c_write( normal_i2c[0],0x0,1,&data,1);
    i2c_write( normal_i2c[0],0x1,1,&data,1);
    /*added by PICO_driver ben.li for bug25068:调节背光电压--end--*/
    sunxi_lcd_delay_ms(50);

    panel_reset(1);
    sunxi_lcd_delay_ms(10);
    panel_reset(0);
    sunxi_lcd_delay_ms(50);
    panel_reset(1);
    sunxi_lcd_delay_ms(10);

    sunxi_lcd_pin_cfg(sel, 1);  //使能LCDDE
}

2.2 初始化流程

static void lcd_panel_init(u32 sel)
{
	sunxi_lcd_dsi_clk_enable(sel);
	sunxi_lcd_delay_ms(10);
	//added by PICO_driver ben.li for bug18237:添加插黑功能--start--
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xff, 0x25);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xfb, 0x01);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xc4, 0x10);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xff, 0x23);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xfb, 0x01);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xa9, 0x20);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xac, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xad, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xae, 0xa0);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xaf, 0xff);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xff, 0x10);
	//added by PICO_driver ben.li for bug24264:change for ES1 hardware --start--
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x36, 0x03);
	//added by PICO_driver ben.li for bug24264:change for ES1 hardware --end--
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xfb, 0x01);
	sunxi_lcd_dsi_dcs_write_4para(sel, 0xbe, 0x00, 0x0c, 0x00, 0x0c);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x35, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xbb, 0x03);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xc0, 0x80);
	sunxi_lcd_dsi_dcs_write_0para(sel, DSI_DCS_EXIT_SLEEP_MODE);
	mdelay(120);
	sunxi_lcd_dsi_dcs_write_0para(sel, DSI_DCS_SET_DISPLAY_ON);
	mdelay(10);
	//added by PICO_driver ben.li for bug18237:添加插黑功能--end--
	return;
}

猜你喜欢

转载自blog.csdn.net/musicalspace/article/details/79061101
今日推荐