“Linux内核-RGB LCD驱动移植”的版本间的差异

来自华清远见研发中心
跳转至: 导航搜索
实验步骤
实验步骤
 
(未显示同一用户的4个中间版本)
第1行: 第1行:
 
==实验原理==
 
==实验原理==
 
前文介绍过LTDC的内容,本节只需为LTDC添加一个面板即可。内核中包含一个通用的面板驱动,驱动之包含大量各种各样的面板。<br>
 
前文介绍过LTDC的内容,本节只需为LTDC添加一个面板即可。内核中包含一个通用的面板驱动,驱动之包含大量各种各样的面板。<br>
 
+
<ol>
*驱动修改<br>
+
<li>驱动修改</li>
  
 
驱动路径为:drivers/gpu/drm/panel/panel-simple.c<br>
 
驱动路径为:drivers/gpu/drm/panel/panel-simple.c<br>
第23行: 第23行:
 
这个结构体主要用来描述面板的时序相关信息,时序框图如下:
 
这个结构体主要用来描述面板的时序相关信息,时序框图如下:
  
[[Image:55-1-1-1.png]] <br>
+
<center>[[Image:55-1-1-1.png|640px]]</center> <br>
  
 
hdisplay:有效显示区水平像素数量,对应Active Width<br>
 
hdisplay:有效显示区水平像素数量,对应Active Width<br>
第45行: 第45行:
 
面板芯片手册中关于时序的描述如下:
 
面板芯片手册中关于时序的描述如下:
  
[[Image:55-1-1-2.png]] <br>
+
<center>[[Image:55-1-1-2.png|640px]]</center> <br>
  
 
表中可以确认HBP=140、HPW=20、HFP=160、VBP=20、VPW=3、VFP=12,修改面板信息如下:
 
表中可以确认HBP=140、HPW=20、HFP=160、VBP=20、VPW=3、VFP=12,修改面板信息如下:
第62行: 第62行:
 
};
 
};
 
</nowiki></pre>
 
</nowiki></pre>
*设备树修改<br>
+
<li>设备树修改</li>
  
 
增加ltdc输出端口:
 
增加ltdc输出端口:
第95行: 第95行:
 
};
 
};
 
</nowiki></pre>
 
</nowiki></pre>
 +
 +
<li>PWM设备节点</li>
 +
 +
参考文档:
 +
Documentation/devicetree/bindings/pwm/pwm-stm32.txt
 +
内核中ST对STM32MP15x系列芯片的设备树资源了做了定义,可参见:
 +
arch/arm/boot/dts/stm32mp151.dtsi
 +
 +
stm32mp151中timers2定义如下:
 +
<pre><nowiki>
 +
timers2: timer@40000000 {
 +
#address-cells = <1>;
 +
#size-cells = <0>;
 +
compatible = "st,stm32-timers";
 +
reg = <0x40000000 0x400>;
 +
clocks = <&rcc TIM2_K>;
 +
clock-names = "int";
 +
dmas = <&dmamux1 18 0x400 0x80000001>,
 +
      <&dmamux1 19 0x400 0x80000001>,
 +
      <&dmamux1 20 0x400 0x80000001>,
 +
      <&dmamux1 21 0x400 0x80000001>,
 +
      <&dmamux1 22 0x400 0x80000001>;
 +
dma-names = "ch1", "ch2", "ch3", "ch4", "up";
 +
status = "disabled";
 +
 +
pwm {
 +
compatible = "st,stm32-pwm";
 +
#pwm-cells = <3>;
 +
status = "disabled";
 +
};
 +
 +
timer@1 {
 +
compatible = "st,stm32h7-timer-trigger";
 +
reg = <1>;
 +
status = "disabled";
 +
};
 +
 +
counter {
 +
compatible = "st,stm32-timer-counter";
 +
status = "disabled";
 +
};
 +
};
 +
 +
</nowiki></pre>
 +
上述代码只对timers5做了基本的初始化,并没有针对不同的硬件设计做适配,所以需结合硬件补全设备树节点信息。
 +
参考文档或stm32mp15xx-dkx.dtsi对于i2c设备节点的描述,增加timers内容如下:
 +
<pre><nowiki>
 +
&timers2 {
 +
/* spare dmas for other usage */
 +
/delete-property/dmas;
 +
/delete-property/dma-names;
 +
status = "okay";
 +
pwm2: pwm {
 +
pinctrl-0 = <&pwm2_pins_b>;
 +
pinctrl-1 = <&pwm2_sleep_pins_b>;
 +
pinctrl-names = "default", "sleep";
 +
#pwm-cells = <2>;
 +
status = "okay";
 +
};
 +
timer@2 {
 +
status = "disabled";
 +
};
 +
};
 +
</nowiki></pre>
 +
 +
stm32mp15-pinctrl.dtsi对于pwm2的描述与FS-MP1A所使用管脚不一致,所以无法直接使用,需参考其增加如下内容:
 +
<pre><nowiki>
 +
pwm2_pins_b: pwm2-0 {
 +
pins {
 +
pinmux = <STM32_PINMUX('A', 5, AF1)>; /* TIM2_CH1 */
 +
bias-pull-down;
 +
drive-push-pull;
 +
slew-rate = <0>;
 +
};
 +
};
 +
pwm2_sleep_pins_b: pwm1-sleep-0 {
 +
pins {
 +
pinmux = <STM32_PINMUX('A', 5, ANALOG)>; /* TIM2_CH1 */
 +
};
 +
};
 +
</nowiki></pre>
 +
<li>背光设备节点</li>
 +
参考文档:
 +
<pre>
 +
Documentation/devicetree/bindings/leds/backlight/pwm-backlight.txt
 +
Documentation/devicetree/bindings/leds/backlight/gpio-backlight.txt
 +
</pre>
 +
 +
FS-MP1A背光可以通过GPIO驱动也可通过PWM2的通道1驱动,可以对比参考文档或内核中其他设备树关于背光的定义。
 +
 +
GPIO驱动背光节点内容如下:
 +
<pre>
 +
panel_backlight: panel-backlight {
 +
compatible = "gpio-backlight";
 +
gpios = <&gpiod 13 GPIO_ACTIVE_LOW>;
 +
default-on;
 +
status = "okay";
 +
};
 +
</pre>
 +
PWM驱动背光节点内容如下:
 +
<pre>
 +
panel_backlight: panel-backlight {
 +
compatible = "pwm-backlight";
 +
pwms = <&pwm2 0 5000000>;
 +
brightness-levels = <0 4 8 16 32 64 128 255>;
 +
default-brightness-level = <6>;
 +
status = "okay";
 +
};
 +
</pre>
 +
</ol>
  
 
==实验目的==
 
==实验目的==
第103行: 第213行:
  
 
==实验步骤==
 
==实验步骤==
*增加设备树文件<br>
+
<ol>
 +
<li>导入交叉编译工具链</li>
 +
linux@ubuntu:$ source /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
 +
<li>增加设备树文件</li>
  
 
由于RGB LCD并非FS-MP1A必须配置,本节增加一个设备树文件,对应增加了屏幕的设备。<br>
 
由于RGB LCD并非FS-MP1A必须配置,本节增加一个设备树文件,对应增加了屏幕的设备。<br>
第128行: 第241行:
 
::    stm32mp157d-dk1.dtb \
 
::    stm32mp157d-dk1.dtb \
 
</div>
 
</div>
*添加ltdc端口<br>
+
 
 +
<li>添加pwm2内容</li>
 +
修改stm32mp15xx-fsmp1x.dtsi,在stm32mp15xx-fsmp1x.dtsi文件末尾添加如下内容:
 +
<pre>
 +
&timers2 {
 +
/* spare dmas for other usage */
 +
/delete-property/dmas;
 +
/delete-property/dma-names;
 +
status = "okay";
 +
pwm2: pwm {
 +
pinctrl-0 = <&pwm2_pins_b>;
 +
pinctrl-1 = <&pwm2_sleep_pins_b>;
 +
pinctrl-names = "default", "sleep";
 +
#pwm-cells = <2>;
 +
status = "okay";
 +
};
 +
timer@2 {
 +
status = "disabled";
 +
};
 +
};
 +
 
 +
&pinctrl {
 +
pwm2_pins_b: pwm2-0 {
 +
pins {
 +
pinmux = <STM32_PINMUX('A', 5, AF1)>; /* TIM2_CH1 */
 +
bias-pull-down;
 +
drive-push-pull;
 +
slew-rate = <0>;
 +
};
 +
};
 +
pwm2_sleep_pins_b: pwm1-sleep-0 {
 +
pins {
 +
pinmux = <STM32_PINMUX('A', 5, ANALOG)>; /* TIM2_CH1 */
 +
};
 +
};
 +
};
 +
 
 +
</pre>
 +
<li>添加背光内容</li>
 +
修改stm32mp15xx-fsmp1x.dtsi,在根节点中添加如下内容:
 +
<pre>
 +
panel_backlight: panel-backlight {
 +
compatible = "pwm-backlight";
 +
pwms = <&pwm2 0 5000000>;
 +
brightness-levels = <0 4 8 16 32 64 128 255>;
 +
default-brightness-level = <6>;
 +
status = "okay";
 +
};
 +
</pre>
 +
<li>添加ltdc端口</li>
  
 
修改文件arm/arm/boot/dts/stm32mp157a-fsmp1a-rgb070.dts,在文件末尾添加如下内容:
 
修改文件arm/arm/boot/dts/stm32mp157a-fsmp1a-rgb070.dts,在文件末尾添加如下内容:
第145行: 第307行:
 
};
 
};
 
</nowiki></pre>
 
</nowiki></pre>
*添加面板信息<br>
+
<li>添加面板信息</li>
  
 
修改文件arm/arm/boot/dts/stm32mp157a-fsmp1a-rgb070.dts,在根节点中添加如下内容:
 
修改文件arm/arm/boot/dts/stm32mp157a-fsmp1a-rgb070.dts,在根节点中添加如下内容:
第161行: 第323行:
 
};   
 
};   
 
</nowiki></pre>
 
</nowiki></pre>
*修改面板驱动,修改面板时序参数<br>
+
<li>修改面板驱动,修改面板时序参数</li>
  
 
修改文件drivers/gpu/drm/panel/panel-simple.c,修改zj070na-01p面板信息,对照面板芯片手册修改原有内容,红色字体部分为修改内容:
 
修改文件drivers/gpu/drm/panel/panel-simple.c,修改zj070na-01p面板信息,对照面板芯片手册修改原有内容,红色字体部分为修改内容:
<pre><nowiki>
+
<div style="background-color:#F8F8F8;border:1px solid #E5E5E5;font-family: monospace,Courier;">
static const struct drm_display_mode innolux_zj070na_01p_mode = {
+
:static const struct drm_display_mode innolux_zj070na_01p_mode = {
.clock = 51501,
+
:: .clock = 51501,
.hdisplay = 1024,
+
:: .hdisplay = 1024,
.hsync_start = 1024 + 160,
+
:: .hsync_start = 1024 + <font color="#FF0000">160</font>,
.hsync_end = 1024 + 160 + 20,
+
:: .hsync_end = 1024 + <font color="#FF0000">160 </font>+ <font color="#FF0000">20</font>,
.htotal = 1024 + 160 + 20 + 140,
+
:: .htotal = 1024 + <font color="#FF0000">160</font> + <font color="#FF0000">20</font> + <font color="#FF0000">140</font>,
.vdisplay = 600,
+
:: .vdisplay = 600,
.vsync_start = 600 + 12,
+
:: .vsync_start = 600 + <font color="#FF0000">12</font>,
.vsync_end = 600 + 12 + 3,
+
:: .vsync_end = 600 + <font color="#FF0000">12</font> + <font color="#FF0000">3</font>,
.vtotal = 600 + 12 + 3 + 12,
+
:: .vtotal = 600 + <font color="#FF0000">12</font> + <font color="#FF0000">3</font> + <font color="#FF0000">12</font>,
.vrefresh = 60,
+
:: .vrefresh = 60,
 
};
 
};
</nowiki></pre>
+
</div>
*配置内核<br>
+
<li>配置内核</li>
  
 
由于内核默认支持通用面板驱动,本节列出主要选项,如下
 
由于内核默认支持通用面板驱动,本节列出主要选项,如下
第192行: 第354行:
 
<*>  Generic PWM based Backlight Driver
 
<*>  Generic PWM based Backlight Driver
 
</nowiki></pre>
 
</nowiki></pre>
*编译内核及设备树
+
 
 +
<li>增加启动项</li>
 +
在虚拟机/tftpboot /tftpboot/pxelinux.cfg/01-00-80-e1-42-60-17末尾添加
 +
<pre>
 +
LABEL stm32mp157a-fsmp1a-mipi
 +
  KERNEL /uImage
 +
  FDT /stm32mp157a-fsmp1a-rgb070.dtb
 +
  APPEND root=/dev/mmcblk1p4 rootwait rw console=ttySTM0,115200
 +
</pre>
 +
 
 +
<li>编译内核及设备树</li>
 
  linux@ubuntu:$ make -j4 uImage dtbs LOADADDR=0xC2000040
 
  linux@ubuntu:$ make -j4 uImage dtbs LOADADDR=0xC2000040
*重启测试<br>
+
 
 +
<li>重启测试</li>
  
 
安装上7寸LCD面板,将编译好的设备树和内核镜像拷贝到/tftpboot目录下,通过tftp引导内核,启动后可正常显示,如果屏幕显示不正可适当调节面板参数。
 
安装上7寸LCD面板,将编译好的设备树和内核镜像拷贝到/tftpboot目录下,通过tftp引导内核,启动后可正常显示,如果屏幕显示不正可适当调节面板参数。
  
[[Image:55-1-4-1.png]] <br>
+
<center>[[Image:55-1-4-1.png]] </center><br>
 +
 
 +
</ol>

2021年3月24日 (三) 15:33的最新版本

实验原理

前文介绍过LTDC的内容,本节只需为LTDC添加一个面板即可。内核中包含一个通用的面板驱动,驱动之包含大量各种各样的面板。

  1. 驱动修改
  2. 驱动路径为:drivers/gpu/drm/panel/panel-simple.c

    移植时可以在驱动中支持新的面板的内容,也可以找到一个与自己面板相仿的内容进行修改,本节即使用在原有面板修改的方法。如本节参考面板名称为zj070na-01p,对于一个面板最关键的内容在驱动通过drm_display_mode的结构体描述,zj070na-01p的描述如下:

    static const struct drm_display_mode innolux_zj070na_01p_mode = {
    	.clock = 51501,
    	.hdisplay = 1024,
    	.hsync_start = 1024 + 128,
    	.hsync_end = 1024 + 128 + 64,
    	.htotal = 1024 + 128 + 64 + 128,
    	.vdisplay = 600,
    	.vsync_start = 600 + 16,
    	.vsync_end = 600 + 16 + 4,
    	.vtotal = 600 + 16 + 4 + 16,
    	.vrefresh = 60,
    };
    

    这个结构体主要用来描述面板的时序相关信息,时序框图如下:

    55-1-1-1.png

    hdisplay:有效显示区水平像素数量,对应Active Width

    hsync_start:水平同步开始,对应hdispay + HFP

    hsync_end:水平同步结束,对应hdisplay + HFP + HSYNC width(HPW)

    htotal:水平总像素,对应hdisplay + HFP + HSYNC width + HBP

    vdisplay:垂直显示像素,对应Active Height

    vsync_start:垂直同步开始,对应vdispay + VFP

    vsync_end:垂直像素结束,对应vdisplay + VFP + VSYNC width(VPW)

    vtotal:垂直总像素,对应vdisplay + VFP + VSYNC width + VBP

    vrefresh:刷新率

    面板芯片手册中关于时序的描述如下:

    55-1-1-2.png

    表中可以确认HBP=140、HPW=20、HFP=160、VBP=20、VPW=3、VFP=12,修改面板信息如下:

    static const struct drm_display_mode innolux_zj070na_01p_mode = {
    	.clock = 51501,
    	.hdisplay = 1024,
    	.hsync_start = 1024 + 160,
    	.hsync_end = 1024 + 160 + 20,
    	.htotal = 1024 + 160 + 20 + 140,
    	.vdisplay = 600,
    	.vsync_start = 600 + 12,
    	.vsync_end = 600 + 12 + 3,
    	.vtotal = 600 + 12 + 3 + 12,
    	.vrefresh = 60,
    };
    
  3. 设备树修改
  4. 增加ltdc输出端口:

    &ltdc {
    	status = "okay";
    
    	port {
    		#address-cells = <1>;
    		#size-cells = <0>;
    
    		ltdc_ep1_out: endpoint@1 {
    			reg = <1>;
    			remote-endpoint = <&panel_in_rgb>;
    		};
    	};
    };
    

    增加面板节点:

    panel: panel-rgb {
    	compatible = "innolux,zj070na-01p";
    	pinctrl-names = "default", "sleep";
    	backlight = <&panel_backlight>;
    	status = "okay";
    
    	port {
    		panel_in_rgb: endpoint {
    			remote-endpoint = <&ltdc_ep1_out>;
    		};
    	};
    };
    
  5. PWM设备节点
  6. 参考文档:

    Documentation/devicetree/bindings/pwm/pwm-stm32.txt
    

    内核中ST对STM32MP15x系列芯片的设备树资源了做了定义,可参见:

    arch/arm/boot/dts/stm32mp151.dtsi
    

    stm32mp151中timers2定义如下:

    timers2: timer@40000000 {
    	#address-cells = <1>;
    	#size-cells = <0>;
    	compatible = "st,stm32-timers";
    	reg = <0x40000000 0x400>;
    	clocks = <&rcc TIM2_K>;
    	clock-names = "int";
    	dmas = <&dmamux1 18 0x400 0x80000001>,
    	       <&dmamux1 19 0x400 0x80000001>,
    	       <&dmamux1 20 0x400 0x80000001>,
    	       <&dmamux1 21 0x400 0x80000001>,
    	       <&dmamux1 22 0x400 0x80000001>;
    	dma-names = "ch1", "ch2", "ch3", "ch4", "up";
    	status = "disabled";
    
    	pwm {
    		compatible = "st,stm32-pwm";
    		#pwm-cells = <3>;
    		status = "disabled";
    	};
    
    	timer@1 {
    		compatible = "st,stm32h7-timer-trigger";
    		reg = <1>;
    		status = "disabled";
    	};
    
    	counter {
    			compatible = "st,stm32-timer-counter";
    			status = "disabled";
    		};
    	};
    
    

    上述代码只对timers5做了基本的初始化,并没有针对不同的硬件设计做适配,所以需结合硬件补全设备树节点信息。 参考文档或stm32mp15xx-dkx.dtsi对于i2c设备节点的描述,增加timers内容如下:

    &timers2 {
    	/* spare dmas for other usage */
    	/delete-property/dmas;
    	/delete-property/dma-names;
    	status = "okay";
    	pwm2: pwm {
    		pinctrl-0 = <&pwm2_pins_b>;
    		pinctrl-1 = <&pwm2_sleep_pins_b>;
    		pinctrl-names = "default", "sleep";
    		#pwm-cells = <2>;
    		status = "okay";
    	};
    	timer@2 {
    		status = "disabled";
    	};
    };
    

    stm32mp15-pinctrl.dtsi对于pwm2的描述与FS-MP1A所使用管脚不一致,所以无法直接使用,需参考其增加如下内容:

    pwm2_pins_b: pwm2-0 {
    	pins {
    		pinmux = <STM32_PINMUX('A', 5, AF1)>; /* TIM2_CH1 */
    		bias-pull-down;
    		drive-push-pull;
    		slew-rate = <0>;
    	};
    };
    pwm2_sleep_pins_b: pwm1-sleep-0 {
    	pins {
    		pinmux = <STM32_PINMUX('A', 5, ANALOG)>; /* TIM2_CH1 */
    	};
    };
    
  7. 背光设备节点
  8. 参考文档:

    Documentation/devicetree/bindings/leds/backlight/pwm-backlight.txt
    Documentation/devicetree/bindings/leds/backlight/gpio-backlight.txt
    

    FS-MP1A背光可以通过GPIO驱动也可通过PWM2的通道1驱动,可以对比参考文档或内核中其他设备树关于背光的定义。

    GPIO驱动背光节点内容如下:

    panel_backlight: panel-backlight {
    	compatible = "gpio-backlight";
    	gpios = <&gpiod 13 GPIO_ACTIVE_LOW>;
    		default-on;
    	status = "okay";
    };
    

    PWM驱动背光节点内容如下:

    panel_backlight: panel-backlight {
    	compatible = "pwm-backlight";
    	pwms = <&pwm2 0 5000000>;
    	brightness-levels = <0 4 8 16 32 64 128 255>;
    	default-brightness-level = <6>;
    	status = "okay";
    };
    

实验目的

熟悉基于Linux操作系统下的摄像头设备驱动移植配置过程。

实验平台

华清远见开发环境,FS-MP1A平台;

实验步骤

  1. 导入交叉编译工具链
  2. linux@ubuntu:$ source /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
    
  3. 增加设备树文件
  4. 由于RGB LCD并非FS-MP1A必须配置,本节增加一个设备树文件,对应增加了屏幕的设备。

    在内核的arch/arm/boot/dts目录下新建文件stm32mp157a-fsmp1a-rgb070.dts文件并添加如下内容:

    #include "stm32mp157a-fsmp1a.dts"
    
    / {
        model = "HQYJ STM32MP157 FSMP1A RGB Discovery Board";
        compatible = "st,stm32mp157a-dk1", "st,stm32mp157";
    };
    

    由于增加了新的设备树文件需修改arm/arm/boot/dts/Makefile,在文件中增加新的条目,红色字体部分为增加内容

    dtb-$(CONFIG_ARCH_STM32) += \
    stm32mp157a-dk1.dtb \
    stm32mp157a-fsmp1a.dtb \
    stm32mp157a-fsmp1a-mipi050.dtb \

    stm32mp157a-fsmp1a-rgb070.dtb \

    stm32mp157d-dk1.dtb \
  5. 添加pwm2内容
  6. 修改stm32mp15xx-fsmp1x.dtsi,在stm32mp15xx-fsmp1x.dtsi文件末尾添加如下内容:

    &timers2 {
    	/* spare dmas for other usage */
    	/delete-property/dmas;
    	/delete-property/dma-names;
    	status = "okay";
    	pwm2: pwm {
    		pinctrl-0 = <&pwm2_pins_b>;
    		pinctrl-1 = <&pwm2_sleep_pins_b>;
    		pinctrl-names = "default", "sleep";
    		#pwm-cells = <2>;
    		status = "okay";
    	};
    	timer@2 {
    		status = "disabled";
    	};
    };
    
    &pinctrl {
    	pwm2_pins_b: pwm2-0 {
    		pins {
    			pinmux = <STM32_PINMUX('A', 5, AF1)>; /* TIM2_CH1 */
    			bias-pull-down;
    			drive-push-pull;
    			slew-rate = <0>;
    		};
    	};
    	pwm2_sleep_pins_b: pwm1-sleep-0 {
    		pins {
    			pinmux = <STM32_PINMUX('A', 5, ANALOG)>; /* TIM2_CH1 */
    		};
    	};
    };
    
    
  7. 添加背光内容
  8. 修改stm32mp15xx-fsmp1x.dtsi,在根节点中添加如下内容:

    panel_backlight: panel-backlight {
    	compatible = "pwm-backlight";
    	pwms = <&pwm2 0 5000000>;
    	brightness-levels = <0 4 8 16 32 64 128 255>;
    	default-brightness-level = <6>;
    	status = "okay";
    };
    
  9. 添加ltdc端口
  10. 修改文件arm/arm/boot/dts/stm32mp157a-fsmp1a-rgb070.dts,在文件末尾添加如下内容:

    &ltdc {
    	status = "okay";
    
    	port {
    		#address-cells = <1>;
    		#size-cells = <0>;
    		ltdc_ep1_out: endpoint@1 {
    			reg = <1>;
    			remote-endpoint = <&panel_in_rgb>;
    		};
    	};
    };
    
  11. 添加面板信息
  12. 修改文件arm/arm/boot/dts/stm32mp157a-fsmp1a-rgb070.dts,在根节点中添加如下内容:

    panel: panel-rgb {
    	compatible = "innolux,zj070na-01p";
    	pinctrl-names = "default", "sleep";
    	backlight = <&panel_backlight>;
    	status = "okay";
    	port {
    		panel_in_rgb: endpoint {
    			remote-endpoint = <&ltdc_ep1_out>;
    		};
    	};
    };  
    
  13. 修改面板驱动,修改面板时序参数
  14. 修改文件drivers/gpu/drm/panel/panel-simple.c,修改zj070na-01p面板信息,对照面板芯片手册修改原有内容,红色字体部分为修改内容:

    static const struct drm_display_mode innolux_zj070na_01p_mode = {
    .clock = 51501,
    .hdisplay = 1024,
    .hsync_start = 1024 + 160,
    .hsync_end = 1024 + 160 + 20,
    .htotal = 1024 + 160 + 20 + 140,
    .vdisplay = 600,
    .vsync_start = 600 + 12,
    .vsync_end = 600 + 12 + 3,
    .vtotal = 600 + 12 + 3 + 12,
    .vrefresh = 60,

    };

  15. 配置内核
  16. 由于内核默认支持通用面板驱动,本节列出主要选项,如下

    linux@ubuntu:$ make menuconfig
    Device Drivers  --->
    	Graphics support  --->
    		<*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)  --->
    		<*> DRM Support for STMicroelectronics SoC Series
    		Display Panels  --->
    			<*> support for simple panels
    		Backlight & LCD device support  --->
    			<*>   Generic PWM based Backlight Driver
    
  17. 增加启动项
  18. 在虚拟机/tftpboot /tftpboot/pxelinux.cfg/01-00-80-e1-42-60-17末尾添加

    LABEL stm32mp157a-fsmp1a-mipi
      KERNEL /uImage
      FDT /stm32mp157a-fsmp1a-rgb070.dtb
      APPEND root=/dev/mmcblk1p4 rootwait rw console=ttySTM0,115200
    
  19. 编译内核及设备树
  20. linux@ubuntu:$ make -j4 uImage dtbs LOADADDR=0xC2000040
    
  21. 重启测试
  22. 安装上7寸LCD面板,将编译好的设备树和内核镜像拷贝到/tftpboot目录下,通过tftp引导内核,启动后可正常显示,如果屏幕显示不正可适当调节面板参数。

    55-1-4-1.png