Platform: ROCKCHIP
OS: Android 6.0
Kernel: 3.10.92
DTSI解析:
1. MIPI初始化
disp_mipi_init: mipi_dsi_init{
compatible = "rockchip,mipi_dsi_init";
//屏幕是否需要初始化
rockchip,screen_init = <1>;
//有几条Lane, lcd drvier需要配置移植.
rockchip,dsi_lane = <4>;
//参考http://blog.csdn.net/kris_fei/article/details/52701053
//单位是MHz,范围在90~1500MHz, 实际会有点偏差.
rockchip,dsi_hs_clk = <600>;
//单MIPI还是双MIPI.
rockchip,mipi_dsi_num = <1>;
};
2. 上电时序
GPIO根据你在连到屏幕的pin作修改.
disp_mipi_power_ctr: mipi_power_ctr {
compatible = "rockchip,mipi_power_ctr";
mipi_lcd_rst:mipi_lcd_rst{
compatible = "rockchip,lcd_rst";
//reset pin,用的是gpio7的A4 pin, 高电平有效.
rockchip,gpios = <&gpio7 GPIO_A4 GPIO_ACTIVE_HIGH>;
//延时多久,根据lcd spec来确定具体值.
rockchip,delay = <10>;
};
mipi_lcd_en:mipi_lcd_en {
compatible = "rockchip,lcd_en";
//enable pin
rockchip,gpios = <&gpio7 GPIO_A3 GPIO_ACTIVE_HIGH>;
rockchip,delay = <10>;
};
};
注意,这里RK在使用GPIO_ACTIVE_HIGH是反了,比如SPEC中写着是低电平有效,那么这里要配置为GPIO_ACTIVE_HIGH,而不是GPIO_ACTIVE_LOW.
这两个PIN在lcdc节点中有重复配置,只要使用其中一组就可以.
/*lcdc0 as PRMRY(LCD),lcdc1 as EXTEND(HDMI)*/
&lcdc0 {
status = "okay";
rockchip,mirror = <NO_MIRROR>;
rockchip,cabc_mode = <0>;
power_ctr: power_ctr {
rockchip,debug = <0>;
/*lcd_en:lcd_en {
rockchip,power_type = <GPIO>;
gpios = <&gpio7 GPIO_A3 GPIO_ACTIVE_HIGH>;
rockchip,delay = <10>;
};
lcd_cs:lcd_cs {
rockchip,power_type = <GPIO>;
gpios = <&gpio7 GPIO_A4 GPIO_ACTIVE_LOW>;
rockchip,delay = <10>;
};*/
};
};
3. 初始化命令
初始化命令问屏供应商获取.
disp_mipi_init_cmds: screen-on-cmds {
compatible = "rockchip,screen-on-cmds";
//是否打开cmd调试
rockchip,cmd_debug = <1>;
//on-cmdsxxx可以随便取,只要不重复就可以,code会按照放置而不是数字顺序读取.
rockchip,on-cmds1 {
compatible = "rockchip,on-cmds";
//命令在low power 还是 high speed (HSDT)发送,一般都是LPDT.
rockchip,cmd_type = <LPDT>;
//用的平台哪个通道dsi,单MIPI是0, 双MIPI是2.
rockchip,dsi_id = <0>;
//依次是type|cmd|data, 只有一个参数用0x15.
rockchip,cmd = <0x15 0xcd 0xaa>;
rockchip,cmd_delay = <0>;
};
//......
rockchip,on-cmds17 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = <LPDT>;
rockchip,dsi_id = <0>;
//依次是type|cmd|data0|data1|datax..., 长包用0x39
rockchip,cmd = <0x39 0x57 0x00 0x00 0x00 0x00>;
rockchip,cmd_delay = <0>;
};
//.......
//下面两条命令厂家有时候不会提供,需要自己补上.
rockchip,on-cmds40 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = <LPDT>;
rockchip,dsi_id = <0>;
//dcs_exit_sleep_mode在code中有定义,可以直接使用,包括下面的dcs_set_display_on.
rockchip,cmd = <0x05 dcs_exit_sleep_mode>;
rockchip,cmd_delay = <120>;
};
rockchip,on-cmds41 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = <LPDT>;
rockchip,dsi_id = <0>;
//只有命令没有参数用0x05.
rockchip,cmd = <0x05 dcs_set_display_on>;
//这个延时很重要.
rockchip,cmd_delay = <120>;
};
};
4. 屏幕Timing
下面几个参数需要参考屏spec来确定.
disp_timings: display-timings {
native-mode = <&timing0>;
compatible = "rockchip,display-timings";
timing0: timing0 {
//屏幕类型,双MIPI是SCREEN_DUAL_MIPI.
screen-type = <SCREEN_MIPI>;
//无效参数
lvds-format = <LVDS_8BIT_2>;
//屏幕pixel format
out-face = <OUT_P888>;
//参考: http://blog.csdn.net/kris_fei/article/details/52701053
//此值影响fps,刚开始fps可以低一些,比如fps,后面再慢慢加大.
clock-frequency = <58200000>;
//水平有效像素
hactive = <480>;
//垂直有效像素
vactive = <1280>;
//hbp
hback-porch = <160>;
//hfp
hfront-porch = <160>;
//vbp
vback-porch = <10>;
//vfp
vfront-porch = <12>;
//h-sync
hsync-len = <24>;
//v-sync
vsync-len = <2>;
//下面几个参数基本上不需要变化,除非屏幕显示有异常.
hsync-active = <0>;
vsync-active = <0>;
de-active = <0>;
pixelclk-active = <0>;
swap-rb = <0>;
swap-rg = <0>;
swap-gb = <0>;
};
};
调试过程:
1. Log查看驱动是否已经正常跑起来,文件有一些调试宏可以打开,以获取更多有用信息.
2. 确认屏的供电电压以及复位电压正常(有遇到过板子的一个5V电源窜到复位引脚),上电时序要符合spec要求,这时屏幕可以不接,以免烧坏.
3. 如果屏幕需要初始化,确认命令是否发送成功.有如下几种方法确认:
a) 用示波器抓取Lan0N和Lane0P,难度较大,不到最后一步不用.
b) 把发出去的命令读回来看是否一致,前提是读取接口要正常.(我遇到的读接口就没成功,不知是不是接口问题,没有深究)
c) 和厂商确认是否有类型工厂测试命令,配置完后屏可以自己显示7彩色种类的画面.
4. 如果还不亮,需要测量下Lane上面的电压,LPDT在1.2V左右,HSDT在200mV左右.如果还是正常,就需要分析MIPI协议了,这一步一个是需要设备,一个是分析时间会很长.
5.还有个情况就是是否使用了转接板,因为是高速信号,所以fpc线要求要高. 我就被这问题折磨了整整一周,后来换了插口和短的线就有显示了.
OS: Android 6.0
Kernel: 3.10.92
DTSI解析:
1. MIPI初始化
disp_mipi_init: mipi_dsi_init{
compatible = "rockchip,mipi_dsi_init";
//屏幕是否需要初始化
rockchip,screen_init = <1>;
//有几条Lane, lcd drvier需要配置移植.
rockchip,dsi_lane = <4>;
//参考http://blog.csdn.net/kris_fei/article/details/52701053
//单位是MHz,范围在90~1500MHz, 实际会有点偏差.
rockchip,dsi_hs_clk = <600>;
//单MIPI还是双MIPI.
rockchip,mipi_dsi_num = <1>;
};
2. 上电时序
GPIO根据你在连到屏幕的pin作修改.
disp_mipi_power_ctr: mipi_power_ctr {
compatible = "rockchip,mipi_power_ctr";
mipi_lcd_rst:mipi_lcd_rst{
compatible = "rockchip,lcd_rst";
//reset pin,用的是gpio7的A4 pin, 高电平有效.
rockchip,gpios = <&gpio7 GPIO_A4 GPIO_ACTIVE_HIGH>;
//延时多久,根据lcd spec来确定具体值.
rockchip,delay = <10>;
};
mipi_lcd_en:mipi_lcd_en {
compatible = "rockchip,lcd_en";
//enable pin
rockchip,gpios = <&gpio7 GPIO_A3 GPIO_ACTIVE_HIGH>;
rockchip,delay = <10>;
};
};
注意,这里RK在使用GPIO_ACTIVE_HIGH是反了,比如SPEC中写着是低电平有效,那么这里要配置为GPIO_ACTIVE_HIGH,而不是GPIO_ACTIVE_LOW.
这两个PIN在lcdc节点中有重复配置,只要使用其中一组就可以.
/*lcdc0 as PRMRY(LCD),lcdc1 as EXTEND(HDMI)*/
&lcdc0 {
status = "okay";
rockchip,mirror = <NO_MIRROR>;
rockchip,cabc_mode = <0>;
power_ctr: power_ctr {
rockchip,debug = <0>;
/*lcd_en:lcd_en {
rockchip,power_type = <GPIO>;
gpios = <&gpio7 GPIO_A3 GPIO_ACTIVE_HIGH>;
rockchip,delay = <10>;
};
lcd_cs:lcd_cs {
rockchip,power_type = <GPIO>;
gpios = <&gpio7 GPIO_A4 GPIO_ACTIVE_LOW>;
rockchip,delay = <10>;
};*/
};
};
3. 初始化命令
初始化命令问屏供应商获取.
disp_mipi_init_cmds: screen-on-cmds {
compatible = "rockchip,screen-on-cmds";
//是否打开cmd调试
rockchip,cmd_debug = <1>;
//on-cmdsxxx可以随便取,只要不重复就可以,code会按照放置而不是数字顺序读取.
rockchip,on-cmds1 {
compatible = "rockchip,on-cmds";
//命令在low power 还是 high speed (HSDT)发送,一般都是LPDT.
rockchip,cmd_type = <LPDT>;
//用的平台哪个通道dsi,单MIPI是0, 双MIPI是2.
rockchip,dsi_id = <0>;
//依次是type|cmd|data, 只有一个参数用0x15.
rockchip,cmd = <0x15 0xcd 0xaa>;
rockchip,cmd_delay = <0>;
};
//......
rockchip,on-cmds17 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = <LPDT>;
rockchip,dsi_id = <0>;
//依次是type|cmd|data0|data1|datax..., 长包用0x39
rockchip,cmd = <0x39 0x57 0x00 0x00 0x00 0x00>;
rockchip,cmd_delay = <0>;
};
//.......
//下面两条命令厂家有时候不会提供,需要自己补上.
rockchip,on-cmds40 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = <LPDT>;
rockchip,dsi_id = <0>;
//dcs_exit_sleep_mode在code中有定义,可以直接使用,包括下面的dcs_set_display_on.
rockchip,cmd = <0x05 dcs_exit_sleep_mode>;
rockchip,cmd_delay = <120>;
};
rockchip,on-cmds41 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = <LPDT>;
rockchip,dsi_id = <0>;
//只有命令没有参数用0x05.
rockchip,cmd = <0x05 dcs_set_display_on>;
//这个延时很重要.
rockchip,cmd_delay = <120>;
};
};
4. 屏幕Timing
下面几个参数需要参考屏spec来确定.
disp_timings: display-timings {
native-mode = <&timing0>;
compatible = "rockchip,display-timings";
timing0: timing0 {
//屏幕类型,双MIPI是SCREEN_DUAL_MIPI.
screen-type = <SCREEN_MIPI>;
//无效参数
lvds-format = <LVDS_8BIT_2>;
//屏幕pixel format
out-face = <OUT_P888>;
//参考: http://blog.csdn.net/kris_fei/article/details/52701053
//此值影响fps,刚开始fps可以低一些,比如fps,后面再慢慢加大.
clock-frequency = <58200000>;
//水平有效像素
hactive = <480>;
//垂直有效像素
vactive = <1280>;
//hbp
hback-porch = <160>;
//hfp
hfront-porch = <160>;
//vbp
vback-porch = <10>;
//vfp
vfront-porch = <12>;
//h-sync
hsync-len = <24>;
//v-sync
vsync-len = <2>;
//下面几个参数基本上不需要变化,除非屏幕显示有异常.
hsync-active = <0>;
vsync-active = <0>;
de-active = <0>;
pixelclk-active = <0>;
swap-rb = <0>;
swap-rg = <0>;
swap-gb = <0>;
};
};
调试过程:
1. Log查看驱动是否已经正常跑起来,文件有一些调试宏可以打开,以获取更多有用信息.
2. 确认屏的供电电压以及复位电压正常(有遇到过板子的一个5V电源窜到复位引脚),上电时序要符合spec要求,这时屏幕可以不接,以免烧坏.
3. 如果屏幕需要初始化,确认命令是否发送成功.有如下几种方法确认:
a) 用示波器抓取Lan0N和Lane0P,难度较大,不到最后一步不用.
b) 把发出去的命令读回来看是否一致,前提是读取接口要正常.(我遇到的读接口就没成功,不知是不是接口问题,没有深究)
c) 和厂商确认是否有类型工厂测试命令,配置完后屏可以自己显示7彩色种类的画面.
4. 如果还不亮,需要测量下Lane上面的电压,LPDT在1.2V左右,HSDT在200mV左右.如果还是正常,就需要分析MIPI协议了,这一步一个是需要设备,一个是分析时间会很长.
5.还有个情况就是是否使用了转接板,因为是高速信号,所以fpc线要求要高. 我就被这问题折磨了整整一周,后来换了插口和短的线就有显示了.