公司对rk3128的芯片重新适配屏幕,所以我们要重新写设备树
Menuconfig 配置
要调用到 MIPI 驱动需要在 menuconfig 里面进行配置
屏参文件配置
mipi host 配置、屏
电源控制配置、屏初始化序列三部分是在
drivers/video/rockchip/screen/lcd_mipi.c 中解析的,最后的屏参是在
drivers/video/of_display_
timing.c 中解析。因为该部分信息 mipi/edp/lvds/hdmi 之
类显示设备都存在,所以在统一的地方进行解析。
mipi host 配置
disp_mipi_init: mipi_dsi_init{
compatible = "rockchip,mipi_dsi_init";
rockchip,screen_init = <0>;
rockchip,dsi_lane = <1>;
rockchip,dsi_hs_clk = <160>;
rockchip,mipi_dsi_num = <1>;
};
screen_init : 表示屏是否需要初始化,如果需要则置为 1.
dsi_lane : mipi 数据传输需要几条数据 lane,手上这个屏幕就一条数据
dsi_hs_clk : 屏 ddr clk,表示一条数据 lane 的传输速率,单位为 Mbits/s。有个大概
的计算公式:100+H_totalV_totalfps38/lanes。
所以 H_total = 240 V_total=240 fps=60(根据厂家给的
单片机) 在最后厂商说100来左右 那就160
mipi_dsi_num : 单 mipi 还是双 mipi
屏电源控制配置
在之前上电后背光已经能正常亮,所以这个暂时不用调整
屏初始化序列
这个就需要问厂商要一份单片机初始化代码,根据把他改成RK3128中MIPI格式
关键的是cmd 一条命令(如 0x05/0x15/0x39)+命令+参数
0x05 : 后面只有一个参数
0x15 : 后面有两个参数
0x39 : 两个参数以上
disp_mipi_init_cmds: screen-on-cmds {
rockchip,cmd_debug = <1>;
compatible = "rockchip,screen-on-cmds";
rockchip,on-cmds1 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type =
;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xDF 0x98 0x51 0xE9>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds2 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0x00>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds3 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xB7 0x2D 0x8C 0x2D 0x1C>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds4 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xC8 0x3F 0x36 0x30 0x2F 0x34 0x39 0x36 0x36 0x35 0x33 0x2F 0x25 0x21 0x1A 0x15 0x00 0x3F 0x36 0x30 0x2F 0x34 0x39 0x36 0x36 0x35 0x33 0x2F 0x25 0x21 0x1A 0x15 0x00 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds5 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xB9 0x33 0x0C 0xCC >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds6 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xBB 0x48 0x7E 0xD0 0x40 0x7C 0x60 0x60 0x70>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds7 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xBC 0x38 0x3C >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds8 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xC0 0x31 0x20 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds9 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xC1 0x12>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds10 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xC3 0x08 0x00 0x0A 0x10 0x08 0x54 0x45 0x71 0x2C>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmd11 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xC4 0x00 0x78 0x79 0x0E 0x0A 0x16 0x79 0x0E 0x0A 0x16 0x79 0x0E 0x0A 0x16 0x79 0x0E 0x0A 0x16 0x82 0x00 0x03 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds12 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xD0 0x04 0x0C 0x6B 0x0F 0x07 0x03 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds13 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xD7 0x13 0x00 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds14 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0x02>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds15 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xB7 0x63 0x00 0x0C>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds16 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xB8 0x1D 0xB6 0x2F 0x08 0x1E >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds17 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xC1 0x10 0x66 0x66 0x01 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds18 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x30 0xC4 0x7E 0x0E >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds19 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0x00 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds20 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x05 0x11>;
rockchip,cmd_delay = <120>;
};
rockchip,on-cmds21 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0x02>;
rockchip,cmd_delay = <00>;
};
rockchip,on-cmds22 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xC5 0x4E>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds23 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xCA 0x30 0x20 0xF4>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds24 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0x04 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds25 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xD3 0x3C >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds26 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0X00>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds27 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x05 0x29>;
rockchip,cmd_delay = <0>;
};
};
屏参
disp_timings: display-timings {
native-mode = <&timing0>;
compatible = "rockchip,display-timings";
timing0: timing0 {
screen-type = ;
lvds-format = ;
out-face = ;
clock-frequency = <6000000>;
hactive = <240>;
vactive = <240>;
hback-porch = <20>;
hfront-porch = <50>;
hsync-len = <12>;
vback-porch = <20>;
vfront-porch = <50>;
vsync-len = <12>;
hsync-active = <0>;
vsync-active = <0>;
de-active = <0>;
pixelclk-active = <0>;
swap-rb = <0>;
swap-rg = <0>;
swap-gb = <0>;
};
};
screen-type : 屏幕类型,对于 mipi 屏来说有两种选择:单 mipi(SCREEN_MIPI);
双 mipi(SCREEN_DUAL_MIPI);
lvds-format : lvds 数据格式。对于 mipi 来说是无效参数,不用配置
out-face : 屏幕接线格式,include/dt-bindings/rkfb/rk_fb.h 中定义。
clock-frequency : dclk 频率,单位为 HZ,6000000 这个地方设置错了,根据单片机设置成了60000000,还是要自己根据公式算才正确,不然会花屏
Hactive : 水平有效像素
Vactive : 垂直有效像素
hback-porch/hfront-porch/hsync-len : 水平同步信号
vback-porch/vfront-porch/vsync-len : 垂直同步信号
hsync-active 、 vsync-active 、 de-active 、 pixelclk-active : 分 别 为 hync,
vsync,DEN,dclk 的极性控制。置 1 将对极性进行翻转。
swap-rb、swap-rg、swap-gb : 设 1 将对对应的颜色进行翻转。
最后整个屏幕的设备树
lcd-480X800-mipi0.dtsi 名字是这个名字,因为在总设备树里导入了它
/ {
disp_mipi_init: mipi_dsi_init{
compatible = "rockchip,mipi_dsi_init";
rockchip,screen_init = <1>;
rockchip,dsi_lane = <1>;
rockchip,dsi_hs_clk = <160>;
rockchip,mipi_dsi_num = <1>;
};
disp_mipi_power_ctr: mipi_power_ctr {
compatible = "rockchip,mipi_power_ctr";
mipi_lcd_rst:mipi_lcd_rst{
compatible = "rockchip,lcd_rst";
rockchip,gpios = <&gpio3 GPIO_C6 GPIO_ACTIVE_HIGH>;
rockchip,delay = <120>;
};/*
mipi_lcd_en:mipi_lcd_en {
compatible = "rockchip,lcd_en";
rockchip,gpios = <&gpio2 GPIO_A6 GPIO_ACTIVE_HIGH>;
rockchip,delay = <120>;
};*/
};
disp_mipi_init_cmds: screen-on-cmds {
rockchip,cmd_debug = <1>;
compatible = "rockchip,screen-on-cmds";
rockchip,on-cmds1 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xDF 0x98 0x51 0xE9>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds2 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0x00>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds3 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xB7 0x2D 0x8C 0x2D 0x1C>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds4 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xC8 0x3F 0x36 0x30 0x2F 0x34 0x39 0x36 0x36 0x35 0x33 0x2F 0x25 0x21 0x1A 0x15 0x00 0x3F 0x36 0x30 0x2F 0x34 0x39 0x36 0x36 0x35 0x33 0x2F 0x25 0x21 0x1A 0x15 0x00 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds5 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xB9 0x33 0x0C 0xCC >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds6 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xBB 0x48 0x7E 0xD0 0x40 0x7C 0x60 0x60 0x70>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds7 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xBC 0x38 0x3C >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds8 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xC0 0x31 0x20 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds9 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xC1 0x12>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds10 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xC3 0x08 0x00 0x0A 0x10 0x08 0x54 0x45 0x71 0x2C>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmd11 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xC4 0x00 0x78 0x79 0x0E 0x0A 0x16 0x79 0x0E 0x0A 0x16 0x79 0x0E 0x0A 0x16 0x79 0x0E 0x0A 0x16 0x82 0x00 0x03 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds12 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xD0 0x04 0x0C 0x6B 0x0F 0x07 0x03 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds13 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xD7 0x13 0x00 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds14 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0x02>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds15 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xB7 0x63 0x00 0x0C>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds16 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xB8 0x1D 0xB6 0x2F 0x08 0x1E >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds17 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xC1 0x10 0x66 0x66 0x01 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds18 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x30 0xC4 0x7E 0x0E >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds19 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0x00 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds20 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x05 0x11>;
rockchip,cmd_delay = <120>;
};
rockchip,on-cmds21 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0x02>;
rockchip,cmd_delay = <00>;
};
rockchip,on-cmds22 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xC5 0x4E>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds23 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x39 0xCA 0x30 0x20 0xF4>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds24 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0x04 >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds25 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xD3 0x3C >;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds26 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x15 0xDE 0X00>;
rockchip,cmd_delay = <0>;
};
rockchip,on-cmds27 {
compatible = "rockchip,on-cmds";
rockchip,cmd_type = ;
rockchip,dsi_id = <0>;
rockchip,cmd = <0x05 0x29>;
rockchip,cmd_delay = <0>;
};
};
disp_timings: display-timings {
native-mode = <&timing0>;
compatible = "rockchip,display-timings";
timing0: timing0 {
screen-type = ;
lvds-format = ;
out-face = ;
clock-frequency = <60000000>;
hactive = <240>;
vactive = <240>;
hback-porch = <20>;
hfront-porch = <50>;
hsync-len = <12>;
vback-porch = <20>;
vfront-porch = <50>;
vsync-len = <12>;
hsync-active = <0>;
vsync-active = <0>;
de-active = <0>;
pixelclk-active = <0>;
swap-rb = <0>;
swap-rg = <0>;
swap-gb = <0>;
};
};
};
原作者:鸭鸭打瞌睡