STM32MP157 Linux系统移植开发篇11:Linux HDMI驱动移植 本文章为《STM32MP157 Linux系统移植开发篇》系列中的一篇,笔者使用的开发平台为华清远见FS-MP1A开发板(STM32MP157开发板)。stm32mp157是ARM双核,2个A7核,1个M4核,A7核上可以跑Linux操作系统,M4核上可以跑FreeRTOS、RT-Thread等实时操作系统,STM32MP157开发板所以既可以学嵌入式linux,也可以学stm32单片机。针对FS-MP1A开发板,除了Linux系统移植篇外,还包括其他多系列教程,包括Cortex-A7开发篇、Cortex-M4开发篇、扩展板驱动移植篇、Linux应用开发篇、FreeRTOS系统移植篇、Linux驱动开发篇、硬件设计篇、人工智能机器视觉篇、Qt应用编程篇、Qt综合项目实战篇等。欢迎,更多stm32mp157开发教程及视频,可加技术交流Q群459754978,感谢。关于FS-MP1A开发板:手机淘宝分享码:复制本行文字打开手淘₤T4FPXn3YYJ2₤链接:https://item.taobao.com/item.htm?id=622457259672 1.1实验原理 STM32MP157A系列SoC中默认没有HDMI相关控制器,FS-MP1A使用SiI9022芯片将RGB信号转化为HDMI信号。STM32MP157A集成LTDC(LCD-TFT Display Controller),提供一个24bit RGB并行接口用于连接到各种LCD和TFT面板。
SiI9022芯片通过I2C5总线与SoC进行交互,通过SoC的LCD_PCLK、LCD_VSYNC、LCD_HSYNC、LCD_DEN与RGB信号线来进行图像信号的传输,通过I2S2总线进行音频数据的传输。
查看原理图确认I2C5、中断、复位管脚对应关系:
原理图网络编号对应管脚管脚功能管脚功能码I2C5_SCLPA11I2C5_SCLAF4I2C5_SDAPA12I2C5_SDAAF4HDMI_RSTPA13GPIOHDMI_INTPA14INT LCD接口管脚对应关系:
原理图网络编号对应管脚管脚功能管脚功能码LCD_R0PI15LCD_R0AF14LCD_R1PJ0LCD_R1AF14LCD_R2PJ1LCD_R2AF14LCD_R3PJ2LCD_R3AF14LCD_R4PJ3LCD_R4AF14LCD_R5PJ4LCD_R5AF14LCD_R6PJ5LCD_R6AF14LCD_R7PJ6LCD_R7AF14LCD_G0PJ8LCD_G0AF14LCD_G1PJ7LCD_G1AF14LCD_G2PJ10LCD_G2AF14LCD_G3PJ19LCD_G3AF14LCD_G4PJ11LCD_G4AF14LCD_G5PK0LCD_G5AF14LCD_G6PK1LCD_G6AF14LCD_G7PK2LCD_G7AF14LCD_B0PJ12LCD_B0AF14LCD_B1PJ13LCD_B1AF14LCD_B2PJ14LCD_B2AF14LCD_B3PJ15LCD_B3AF14LCD_B4PK3LCD_B4AF14LCD_B5PK4LCD_B5AF14LCD_B6PK5LCD_B6AF14LCD_B7PK6LCD_B7AF14LCD_PCLKPI14LCD_PCLKAF14LCD_DENPK7LCD_DENAF14LCD_HSYNCPI12LCD_HSYNCAF14LCD_VSYNCPI13LCD_VSYNCAF14I2C5设备树节点 参考文档: Documentation/devicetree/bindings/i2c/i2c-stm32.txt 内核中ST对STM32MP15x系列芯片的设备树资源了做了定义,可参见: arch/arm/boot/dts/stm32mp151.dtsi stm32mp151中i2c5定义如下: i2c5: i2c@ { compatible = “st,stm32mp15-i2c”; reg = <0x 0x400>; interrupt-names = “event”, “error”; interrupts-extended = <&exti 25 IRQ_TYPE_LEVEL_HIGH>, <&intc GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; clocks = <&rcc I2C5_K>; resets = <&rcc I2C5_R>; #address-cells = <1>; #size-cells = <0>; dmas = <&dmamux1 115 0x400 0x>, <&dmamux1 116 0x400 0x>; dma-names = “rx”, “tx”; power-domains = <&pd_core>; st,syscfg-fmp = <&syscfg 0x4 0x10>; wakeup-source; status = “disabled”; }; 上述代码只对i2c5做了基本的初始化,并没有针对不同的硬件设计做适配,所以需结合硬件补全设备树节点信息。 参考stm32mp15xx-dkx.dtsi对于i2c设备节点的描述,修改i2c5内容如下: &i2c5 { pinctrl-names = “default”, “sleep”; pinctrl-0 = <&i2c5_pins_a>; pinctrl-1 = <&i2c5_pins_sleep_a>; i2c-scl-rising-time-ns = <100>; i2c-scl-falling-time-ns = <7>; clock-frequency = <>; /* spare dmas for other usage */ /delete-property/dmas; /delete-property/dma-names; status = “okay”; }; 由于stm32mp15-pinctrl.dtsi中对于i2c5_pins_a和i2c5_pins_sleep_a的定义与板子实际使用管脚一致,所以无需修改,内容如下: i2c5_pins_a: i2c5-0 { pins { pinmux = <STM32_PINMUX(‘A’, 11, AF4)>, /* I2C5_SCL */ <STM32_PINMUX(‘A’, 12, AF4)>; /* I2C5_SDA */ bias-disable; drive-open-drain; slew-rate = <0>; }; }; i2c5_pins_sleep_a: i2c5-1 { pins { pinmux = <STM32_PINMUX(‘A’, 11, ANALOG)>, /* I2C5_SCL */ <STM32_PINMUX(‘A’, 12, ANALOG)>; /* I2C5_SDA */ }; }; I2S2设备树节点 参考文档: Documentation/devicetree/bindings/i2c/sound/st,stm32-i2s.txt LTDC设备树节点 SiI9022实现HDMI输出需要RGB信号作为数据源,LTDC为STM32MP157的LCD显示控制器,可以输出24bit的并行数据,HDMI显示首先需要驱动LTDC。 参考文档: Documentation/devicetree/bindings/display/st,stm32-ltdc.txt 内核中ST对STM32MP15x系列芯片的设备树资源了做了定义,可参见: arch/arm/boot/dts/stm32mp151.dtsi stm32mp151中ltdc定义如下: ltdc: display-controller@5a001000 { compatible = “st,stm32-ltdc”; reg = <0x5a001000 0x400>; interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; clocks = <&rcc LTDC_PX>; clock-names = “lcd”; resets = <&rcc LTDC_R>; status = “disabled”; }; 上述代码只对ltdc做了基本的初始化,并没有针对不同的硬件设计做适配,所以需结合硬件补全设备树节点信息。 参考stm32mp15xx-dkx.dtsi对于ltdc设备节点的描述,需增加内容如下: <dc { pinctrl-names = “default”, “sleep”; pinctrl-0 = <<dc_pins_b>; pinctrl-1 = <<dc_pins_sleep_b>; status = “okay”; port { #address-cells = <1>; #size-cells = <0>; ltdc_ep0_out: endpoint@0 { reg = <0>; /*图像输出通道,需对接显示设备*/ remote-endpoint = <&sii9022_in>; }; }; }; 由于stm32mp15-pinctrl.dtsi中对于ltdc_pins_b和ltdc_pins_b的定于与板子实际使用管脚一致,所以无需修改,内容如下: ltdc_pins_b: ltdc-b-0 { pins { pinmux = <STM32_PINMUX(‘I’, 14, AF14)>, /* LCD_CLK */ <STM32_PINMUX(‘I’, 12, AF14)>, /* LCD_HSYNC */ <STM32_PINMUX(‘I’, 13, AF14)>, /* LCD_VSYNC */ <STM32_PINMUX(‘K’, 7, AF14)>, /* LCD_DE */ <STM32_PINMUX(‘I’, 15, AF14)>, /* LCD_R0 */ <STM32_PINMUX(‘J’, 0, AF14)>, /* LCD_R1 */ <STM32_PINMUX(‘J’, 1, AF14)>, /* LCD_R2 */ <STM32_PINMUX(‘J’, 2, AF14)>, /* LCD_R3 */ <STM32_PINMUX(‘J’, 3, AF14)>, /* LCD_R4 */ <STM32_PINMUX(‘J’, 4, AF14)>, /* LCD_R5 */ <STM32_PINMUX(‘J’, 5, AF14)>, /* LCD_R6 */ <STM32_PINMUX(‘J’, 6, AF14)>, /* LCD_R7 */ <STM32_PINMUX(‘J’, 7, AF14)>, /* LCD_G0 */ <STM32_PINMUX(‘J’, 8, AF14)>, /* LCD_G1 */ <STM32_PINMUX(‘J’, 9, AF14)>, /* LCD_G2 */ <STM32_PINMUX(‘J’, 10, AF14)>, /* LCD_G3 */ <STM32_PINMUX(‘J’, 11, AF14)>, /* LCD_G4 */ <STM32_PINMUX(‘K’, 0, AF14)>, /* LCD_G5 */ <STM32_PINMUX(‘K’, 1, AF14)>, /* LCD_G6 */ <STM32_PINMUX(‘K’, 2, AF14)>, /* LCD_G7 */ <STM32_PINMUX(‘J’, 12, AF14)>, /* LCD_B0 */ <STM32_PINMUX(‘J’, 13, AF14)>, /* LCD_B1 */ <STM32_PINMUX(‘J’, 14, AF14)>, /* LCD_B2 */ <STM32_PINMUX(‘J’, 15, AF14)>, /* LCD_B3 */ <STM32_PINMUX(‘K’, 3, AF14)>, /* LCD_B4 */ <STM32_PINMUX(‘K’, 4, AF14)>, /* LCD_B5 */ <STM32_PINMUX(‘K’, 5, AF14)>, /* LCD_B6 */ <STM32_PINMUX(‘K’, 6, AF14)>; /* LCD_B7 */ bias-disable; drive-push-pull; slew-rate = <1>; }; }; ltdc_pins_sleep_b: ltdc-b-1 { pins { pinmux = <STM32_PINMUX(‘I’, 14, ANALOG)>, /* LCD_CLK */ <STM32_PINMUX(‘I’, 12, ANALOG)>, /* LCD_HSYNC */ <STM32_PINMUX(‘I’, 13, ANALOG)>, /* LCD_VSYNC */ <STM32_PINMUX(‘K’, 7, ANALOG)>, /* LCD_DE */ <STM32_PINMUX(‘I’, 15, ANALOG)>, /* LCD_R0 */ <STM32_PINMUX(‘J’, 0, ANALOG)>, /* LCD_R1 */ <STM32_PINMUX(‘J’, 1, ANALOG)>, /* LCD_R2 */ <STM32_PINMUX(‘J’, 2, ANALOG)>, /* LCD_R3 */ <STM32_PINMUX(‘J’, 3, ANALOG)>, /* LCD_R4 */ <STM32_PINMUX(‘J’, 4, ANALOG)>, /* LCD_R5 */ <STM32_PINMUX(‘J’, 5, ANALOG)>, /* LCD_R6 */ <STM32_PINMUX(‘J’, 6, ANALOG)>, /* LCD_R7 */ <STM32_PINMUX(‘J’, 7, ANALOG)>, /* LCD_G0 */ <STM32_PINMUX(‘J’, 8, ANALOG)>, /* LCD_G1 */ <STM32_PINMUX(‘J’, 9, ANALOG)>, /* LCD_G2 */ <STM32_PINMUX(‘J’, 10, ANALOG)>, /* LCD_G3 */ <STM32_PINMUX(‘J’, 11, ANALOG)>, /* LCD_G4 */ <STM32_PINMUX(‘K’, 0, ANALOG)>, /* LCD_G5 */ <STM32_PINMUX(‘K’, 1, ANALOG)>, /* LCD_G6 */ <STM32_PINMUX(‘K’, 2, ANALOG)>, /* LCD_G7 */ <STM32_PINMUX(‘J’, 12, ANALOG)>, /* LCD_B0 */ <STM32_PINMUX(‘J’, 13, ANALOG)>, /* LCD_B1 */ <STM32_PINMUX(‘J’, 14, ANALOG)>, /* LCD_B2 */ <STM32_PINMUX(‘J’, 15, ANALOG)>, /* LCD_B3 */ <STM32_PINMUX(‘K’, 3, ANALOG)>, /* LCD_B4 */ <STM32_PINMUX(‘K’, 4, ANALOG)>, /* LCD_B5 */ <STM32_PINMUX(‘K’, 5, ANALOG)>, /* LCD_B6 */ <STM32_PINMUX(‘K’, 6, ANALOG)>; /* LCD_B7 */ }; };SiI9022设备树节点 参考文档: Documentation/devicetree/bindings/display/arm,hdlcd.txt 由于SiI9002只是I2C5总线上的一个外设,所以STM32MP157A的通用设备树文件中并没有相关的定义,结合arm,hdlcd.txt和stm32mp15xx-dkx.dtsi对于HDMI的描述,增加SiI9002的支持,需在I2C5节点下添加相关信息,添加内容为: hdmi-transmitter@39 { compatible = “sil,sii9022”; reg = <0x39>; iovcc-supply = <&v3v3_hdmi>; cvcc12-supply = <&v1v2_hdmi>; reset-gpios = <&gpioa 10 GPIO_ACTIVE_LOW>; interrupts = <1 IRQ_TYPE_EDGE_FALLING>; interrupt-parent = <&gpiog>; #sound-dai-cells = <0>; status = “okay”; ports { #address-cells = <1>; #size-cells = <0>; port@0 { reg = <0>; sii9022_in: endpoint { /*视频输入端口,与LTDC输出端口对接*/ remote-endpoint = <<dc_ep0_out>; }; }; port@3 { reg = <3>; sii9022_tx_endpoint: endpoint { /*音频输入端口,与声卡输出端口对接*/ remote-endpoint = <&i2s2_endpoint>; }; }; }; };电源节点添加 由于内核中很多驱动会根据电源的方位调整设备的工作方式,所以在设备树中需要传递相关电源电压参数,如sii9022驱动中需要两个电源分别是iovcc和cvcc12,但是在设备树中并没有这两个电源的定义,官方参考板DK1使用的是MPU作为电源管理,而FS-MP1A使用的分离器件的形式,所以stm32mp15xx-dkx.dtsi中对于电源的定义就不实用了。参考内核中相关文档添加固定电源节点的形式添加iovcc和cvcc12即可,根据sii9022的需求,iovcc和cvcc12电压分别为3.3v和1.2v。 参考文档 Documentation/devicetree/bindings/regulator/fixed-regulator.yaml 需在设备树根节点下添加,内容如下: v3v3_hdmi: regulator-v3v3-hdmi { compatible = “regulator-fixed”; regulator-name = “v3v3_hdmi “; regulator-min-microvolt = <>; regulator-max-microvolt = <>; regulator-always-on; regulator-boot-on; }; v1v2_hdmi: regulator-v1v2-hdmi { compatible = “regulator-fixed”; regulator-name = “v1v2_hdmi”; regulator-min-microvolt = <>; regulator-max-microvolt = <>; regulator-always-on; regulator-boot-on; }; 1.2实验目的 熟悉基于Linux操作系统下的HDMI设备驱动移植配置过程。 1.3实验平台 华清远见开发环境,FS-MP1A平台; 1.4实验步骤 导入交叉编译工具链 linux@ubuntu:$ source /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi 添加i2c5及sii9022内容 修改arch/arm/boot/dts/stm32mp15xx-fsmp1x.dtsi文件,在文件末尾添加如下内容: &i2c5 { pinctrl-names = “default”, “sleep”; pinctrl-0 = <&i2c5_pins_a>; pinctrl-1 = <&i2c5_pins_sleep_a>; i2c-scl-rising-time-ns = <100>; i2c-scl-falling-time-ns = <7>; clock-frequency = <>; /* spare dmas for other usage */ /delete-property/dmas; /delete-property/dma-names; status = “okay”; hdmi-transmitter@39 { compatible = “sil,sii9022”; reg = <0x39>; iovcc-supply = <&v3v3_hdmi>; cvcc12-supply = <&v1v2_hdmi>; reset-gpios = <&gpioa 13 GPIO_ACTIVE_LOW>; interrupts = <14 IRQ_TYPE_EDGE_FALLING>; interrupt-parent = <&gpioa>; #sound-dai-cells = <0>; status = “okay”; ports { #address-cells = <1>; #size-cells = <0>; port@0 { reg = <0>; sii9022_in: endpoint { remote-endpoint = <<dc_ep0_out>; }; }; }; }; }; 添加ltdc内容 修改arch/arm/boot/dts/stm32mp15xx-fsmp1x.dtsi文件,在文件末尾添加如下内容: <dc { pinctrl-names = “default”, “sleep”; pinctrl-0 = <<dc_pins_b>; pinctrl-1 = <<dc_pins_sleep_b>; status = “okay”; port { #address-cells = <1>; #size-cells = <0>; ltdc_ep0_out: endpoint@0 { reg = <0>; remote-endpoint = <&sii9022_in>; }; }; };添加电源内容 修改arch/arm/boot/dts/stm32mp15xx-fsmp1x.dtsi文件,在根节点末尾添加如下内容: v3v3_hdmi: regulator-v3v3-hdmi { compatible = “regulator-fixed”; regulator-name = “v3v3_hdmi “; regulator-min-microvolt = <>; regulator-max-microvolt = <>; regulator-always-on; regulator-boot-on; }; v1v2_hdmi: regulator-v1v2-hdmi { compatible = “regulator-fixed”; regulator-name = “v1v2_hdmi”; regulator-min-microvolt = <>; regulator-max-microvolt = <>; regulator-always-on; regulator-boot-on; }; 配置内核 由于内核源码默认配置以及支持sii902x,本节列出主要选项,如下: 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 Interface Bridges —> <*> Silicon Image sii902x RGB/HDMI bridge编译内核及设备树: linux@ubuntu:$ make -j4 uImage dtbs LOADADDR=0xC 重启测试 将编译好的设备树和内核镜像拷贝到/tftpboot目录下,通过tftp引导内核,设备连接HDMI显示器,重启设备后查看/sys/class/drm会多出HMID的信息,同时显示器会有显示。
硬件平台:华清远见FS-MP1A开发板(STM32MP157) 部分开发教程下载:加sigusoft群459754978,群文件里有。 部分视频课程收看:华清远见研发中心的个人空间_哔哩哔哩_Bilibili 淘宝购买链接:https://item.taobao.com/item.htm?id=622457259672 手机淘宝分享码:复制本行文字打开手淘₤T4FPXn3YYJ2₤
2024最新激活全家桶教程,稳定运行到2099年,请移步至置顶文章:https://sigusoft.com/99576.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。 文章由激活谷谷主-小谷整理,转载请注明出处:https://sigusoft.com/60769.html