IMX6ULL Linux5.18 LCD移植
最近在将Linux5.18移植到了正点原子的IMX6ULL MINI的板子上,想要点亮LCD的时候发现和以前Linux4.0.x的套路不一样了,故在本文中记录一下。
设备树的修改
默认的设备树如下
&lcdif {
assigned-clocks = <&clks IMX6UL_CLK_LCDIF_PRE_SEL>;
assigned-clock-parents = <&clks IMX6UL_CLK_PLL5_VIDEO_DIV>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lcdif_dat
&pinctrl_lcdif_ctrl>;
status = "okay";
port {
display_out: endpoint {
remote-endpoint = <&panel_in>;
};
};
};
panel {
compatible = "innolux,at043tn24";
backlight = <&backlight_display>;
port {
panel_in: endpoint {
remote-endpoint = <&display_out>;
};
};
};
当我尝试想要添加正点的7寸屏幕的时候,发现怎么都点不亮,参考了mculover666的文章也不行
display0: display @0{
bits-per-pixel = <24>;
bus-width = <24>;
display-timings {
native-mode = <&timing0>;
timing0: timing0 {
clock-frequency = <51200000>;
hactive = <1024>;
vactive = <600>;
hfront-porch = <160>;
hback-porch = <140>;
hsync-len = <20>;
vback-porch = <20>;
vfront-porch = <12>;
vsync-len = <3>;
hsync-active = <0>;
vsync-active = <0>;
de-active = <1>;
pixelclk-active = <0>;
};
};
};
后来才发现原来是linux的显示架构修改了,修改过后(最终可用)的设备树如下
/ {
chosen {
stdout-path = &uart1;
};
memory@80000000 {
device_type = "memory";
reg = <0x80000000 0x20000000>;
};
backlight_display: backlight-display {
compatible = "pwm-backlight";
pwms = <&pwm1 0 5000000>;
brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <6>;
status = "okay";
};
...
panel {
compatible = "atk,7inch"; //这里我们后续会添加lcd的参数
backlight = <&backlight_display>;
port {
panel_in: endpoint {
remote-endpoint = <&display_out>;
};
};
};
};
&lcdif {
assigned-clocks = <&clks IMX6UL_CLK_LCDIF_PRE_SEL>;
assigned-clock-parents = <&clks IMX6UL_CLK_PLL5_VIDEO_DIV>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lcdif_dat
&pinctrl_lcdif_ctrl>;
status = "okay";
port {
display_out: endpoint {
remote-endpoint = <&panel_in>;
};
};
};
驱动修改
我们需要修改的文件路径如下
drivers/gpu/drm/panel/panel-simple.c
这里,我们照猫画虎,添加正点的7寸屏幕的参数
static const struct drm_display_mode atk_7inch_mode = {
.clock = 51200,//khz
.hdisplay = 1024, //有效显示水平像素数量
.hsync_start = 1024 + 160,//水平同步开始,hdisplay+HFP
.hsync_end = 1024 + 160 + 20,//水平同步结束 hdisplay + HFP + HSYNC width(HPW)
.htotal = 1024 + 260 + 20 + 140, //水平总像素,对应hdisplay + HFP + HSYNC width + HBP
.vdisplay = 600,//垂直显示像素
.vsync_start = 600 + 12, //垂直同步开始,对应vdispay + VFP
.vsync_end = 600 + 12 + 3, //垂直像素结束,对应vdisplay + VFP + VSYNC width(VPW)
.vtotal = 600 + 12 + 3 + 20,//垂直总像素,对应vdisplay + VFP + VSYNC width + VBP
.flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
};
static const struct panel_desc atk_7inch = {
.modes = &atk_7inch_mode,
.num_modes = 1,
.bpc = 8,
.size = {
.width = 95,
.height = 54,
},
.bus_format = MEDIA_BUS_FMT_RGB888_1X24,
.bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE,
};
添加compatible
最后成功点亮正点的屏幕,一直在用之前的linux4.0.x的内核,都和时代脱节了。