嵌入式驱动开发详解12(LCD驱动)

时间:2025-01-21 07:31:59

设备树配置

pinctrl_lcdif_dat: lcdifdatgrp {
	fsl,pins = <
		MX6UL_PAD_LCD_DATA00__LCDIF_DATA00  0x49
		MX6UL_PAD_LCD_DATA01__LCDIF_DATA01  0x49
		MX6UL_PAD_LCD_DATA02__LCDIF_DATA02  0x49
		MX6UL_PAD_LCD_DATA03__LCDIF_DATA03  0x49
		MX6UL_PAD_LCD_DATA04__LCDIF_DATA04  0x49
		MX6UL_PAD_LCD_DATA05__LCDIF_DATA05  0x49
		MX6UL_PAD_LCD_DATA06__LCDIF_DATA06  0x49
		MX6UL_PAD_LCD_DATA07__LCDIF_DATA07  0x49
		MX6UL_PAD_LCD_DATA08__LCDIF_DATA08  0x49
		MX6UL_PAD_LCD_DATA09__LCDIF_DATA09  0x49
		MX6UL_PAD_LCD_DATA10__LCDIF_DATA10  0x49
		MX6UL_PAD_LCD_DATA11__LCDIF_DATA11  0x49
		MX6UL_PAD_LCD_DATA12__LCDIF_DATA12  0x49
		MX6UL_PAD_LCD_DATA13__LCDIF_DATA13  0x49
		MX6UL_PAD_LCD_DATA14__LCDIF_DATA14  0x49
		MX6UL_PAD_LCD_DATA15__LCDIF_DATA15  0x49
		MX6UL_PAD_LCD_DATA16__LCDIF_DATA16  0x49
		MX6UL_PAD_LCD_DATA17__LCDIF_DATA17  0x49
		MX6UL_PAD_LCD_DATA18__LCDIF_DATA18  0x49
		MX6UL_PAD_LCD_DATA19__LCDIF_DATA19  0x49
		MX6UL_PAD_LCD_DATA20__LCDIF_DATA20  0x49
		MX6UL_PAD_LCD_DATA21__LCDIF_DATA21  0x49
		MX6UL_PAD_LCD_DATA22__LCDIF_DATA22  0x49
		MX6UL_PAD_LCD_DATA23__LCDIF_DATA23  0x49
	>;
};
pinctrl_lcdif_ctrl: lcdifctrlgrp {
	fsl,pins = <
		MX6UL_PAD_LCD_CLK__LCDIF_CLK	    0x49
		MX6UL_PAD_LCD_ENABLE__LCDIF_ENABLE  0x49
		MX6UL_PAD_LCD_HSYNC__LCDIF_HSYNC    0x49
		MX6UL_PAD_LCD_VSYNC__LCDIF_VSYNC    0x49
	>;
};
pinctrl_pwm1: pwm1grp {
	fsl,pins = <
		MX6UL_PAD_GPIO1_IO08__PWM1_OUT   0x110b0
	>;
};
&lcdif {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lcdif_dat
	     &pinctrl_lcdif_ctrl>;
/*		     &pinctrl_lcdif_reset>;  */
display = <&display0>;
status = "okay";
display0: display {
	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>;
			};
		};
	};
};
&pwm1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_pwm1>;
	status = "okay";
};
backlight {
	compatible = "pwm-backlight";
	pwms = <&pwm1 0 5000000>;
	brightness-levels = <0 4 8 16 32 64 128 255>;
	default-brightness-level = <6>;
	status = "okay";
};

以上便是对LCD设备树的展示,需要配置好LCD所需要用到的数据引脚,控制引脚以及背光引脚,随后需要对lcd屏幕的相关参数进行设置,并配置好背光引脚,但是linux系统并不知道pwm1_out就是对应LCD的背光引脚,这里我们需要参考设备树绑定文档Documentation/devicetree/indings/video/backlight/pwm-backlight.txt 这个文档,此文档详细讲解了 backlight 节点该如何去创建。