IMX6ULL Linux 5.18 LCD移植

作者将Linux5.18移植到正点原子的IMX6ULL MINI板子上,点亮LCD时发现与Linux4.0.x不同。文章记录了移植过程,包括设备树修改,因Linux显示架构改变,参考他人文章后找到可用设备树;还进行了驱动修改,添加屏幕参数和compatible,最终成功点亮屏幕。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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的内核,都和时代脱节了。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值