查看“Linux内核-HDMI驱动移植”的源代码
←
Linux内核-HDMI驱动移植
跳转至:
导航
、
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
==实验原理== STM32MP157A系列SoC中默认没有HDMI相关控制器,FS-MP1A使用SiI9022芯片将RGB信号转化为HDMI信号。STM32MP157A集成LTDC(LCD-TFT Display Controller),提供一个24bit RGB并行接口用于连接到各种LCD和TFT面板。<br> [[Image:51-1-1-1.png]]<br> SiI9022芯片通过I2C5总线与SoC进行交互,通过SoC的LCD_PCLK、LCD_VSYNC、LCD_HSYNC、LCD_DEN与RGB信号线来进行图像信号的传输,通过I2S2总线进行音频数据的传输。<br> [[Image:51-1-1-2.png]]<br> 查看原理图确认I2C5、中断、复位管脚对应关系: [[Image:51-1-1-3.png]]<br> {|class="wikitable" |- ! 原理图网络编号 !! 对应管脚 !! 管脚功能 !! 管脚功能码 |- | I2C5_SCL | PA11 | I2C5_SCL | AF4 |- | I2C5_SDA | PA12 | I2C5_SDA | AF4 |- | HDMI_RST | PA13 | GPIO | |- | HDMI_INT | PA14 | INT | |} LCD接口管脚对应关系: [[Image:51-1-1-4.png]]<br> {|class="wikitable" |- ! 原理图网络编号 !! 对应管脚 !! 管脚功能 !! 管脚功能码 |- | LCD_R0 | PI15 | LCD_R0 | AF14 |- | LCD_R1 | PJ0 | LCD_R1 | AF14 |- | LCD_R2 | PJ1 | LCD_R2 | AF14 |- | LCD_R3 | PJ2 | LCD_R3 | AF14 |- | LCD_R4 | PJ3 | LCD_R4 | AF14 |- | LCD_R5 | PJ4 | LCD_R5 | AF14 |- | LCD_R6 | PJ5 | LCD_R6 | AF14 |- | LCD_R7 | PJ6 | LCD_R7 | AF14 |- | LCD_G0 | PJ8 | LCD_G0 | AF14 |- | LCD_G1 | PJ7 | LCD_G1 | AF14 |- | LCD_G2 | PJ10 | LCD_G2 | AF14 |- | LCD_G3 | PJ19 | LCD_G3 | AF14 |- | LCD_G4 | PJ11 | LCD_G4 | AF14 |- | LCD_G5 | PK0 | LCD_G5 | AF14 |- | LCD_G6 | PK1 | LCD_G6 | AF14 |- | LCD_G7 | PK2 | LCD_G7 | AF14 |- | LCD_B0 | PJ12 | LCD_B0 | AF14 |- | LCD_B1 | PJ13 | LCD_B1 | AF14 |- | LCD_B2 | PJ14 | LCD_B2 | AF14 |- | LCD_B3 | PJ15 | LCD_B3 | AF14 |- | LCD_B4 | PK3 | LCD_B4 | AF14 |- | LCD_B5 | PK4 | LCD_B5 | AF14 |- | LCD_B6 | PK5 | LCD_B6 | AF14 |- | LCD_B7 | PK6 | LCD_B7 | AF14 |- | LCD_PCLK | PI14 | LCD_PCLK | AF14 |- | LCD_DEN | PK7 | LCD_DEN | AF14 |- | LCD_HSYNC | PI12 | LCD_HSYNC | AF14 |- | LCD_VSYNC | PI13 | LCD_VSYNC | AF14 |} *I2C5设备树节点<br> 参考文档: Documentation/devicetree/bindings/i2c/i2c-stm32.txt 内核中ST对STM32MP15x系列芯片的设备树资源了做了定义,可参见: arch/arm/boot/dts/stm32mp151.dtsi stm32mp151中i2c5定义如下: <pre><nowiki> i2c5: i2c@40015000 { compatible = "st,stm32mp15-i2c"; reg = <0x40015000 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 0x80000001>, <&dmamux1 116 0x400 0x80000001>; dma-names = "rx", "tx"; power-domains = <&pd_core>; st,syscfg-fmp = <&syscfg 0x4 0x10>; wakeup-source; status = "disabled"; }; </nowiki></pre> 上述代码只对i2c5做了基本的初始化,并没有针对不同的硬件设计做适配,所以需结合硬件补全设备树节点信息。<br> 参考stm32mp15xx-dkx.dtsi对于i2c设备节点的描述,修改i2c5内容如下: <pre><nowiki> &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 = <100000>; /* spare dmas for other usage */ /delete-property/dmas; /delete-property/dma-names; status = "okay"; }; </nowiki></pre> 由于stm32mp15-pinctrl.dtsi中对于i2c5_pins_a和i2c5_pins_sleep_a的定义与板子实际使用管脚一致,所以无需修改,内容如下: <pre><nowiki> 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 */ }; }; </nowiki></pre> *I2S2设备树节点<br> 参考文档: Documentation/devicetree/bindings/i2c/sound/st,stm32-i2s.txt *LTDC设备树节点<br> SiI9022实现HDMI输出需要RGB信号作为数据源,LTDC为STM32MP157的LCD显示控制器,可以输出24bit的并行数据,HDMI显示首先需要驱动LTDC。<br> 参考文档: Documentation/devicetree/bindings/display/st,stm32-ltdc.txt 内核中ST对STM32MP15x系列芯片的设备树资源了做了定义,可参见: arch/arm/boot/dts/stm32mp151.dtsi stm32mp151中ltdc定义如下: <pre><nowiki> 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"; }; </nowiki></pre> 上述代码只对ltdc做了基本的初始化,并没有针对不同的硬件设计做适配,所以需结合硬件补全设备树节点信息。<br> 参考stm32mp15xx-dkx.dtsi对于ltdc设备节点的描述,需增加内容如下: <pre><nowiki> <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>; }; }; }; </nowiki></pre> 由于stm32mp15-pinctrl.dtsi中对于ltdc_pins_b和ltdc_pins_b的定于与板子实际使用管脚一致,所以无需修改,内容如下:<br> <pre><nowiki> 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 */ }; }; </nowiki></pre> *SiI9022设备树节点<br> 参考文档: Documentation/devicetree/bindings/display/arm,hdlcd.txt 由于SiI9002只是I2C5总线上的一个外设,所以STM32MP157A的通用设备树文件中并没有相关的定义,结合arm,hdlcd.txt和stm32mp15xx-dkx.dtsi对于HDMI的描述,增加SiI9002的支持,需在I2C5节点下添加相关信息,添加内容为:<br> <pre><nowiki> 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>; }; }; }; }; </nowiki></pre> *电源节点添加<br> 由于内核中很多驱动会根据电源的方位调整设备的工作方式,所以在设备树中需要传递相关电源电压参数,如sii9022驱动中需要两个电源分别是iovcc和cvcc12,但是在设备树中并没有这两个电源的定义,官方参考板DK1使用的是MPU作为电源管理,而FS-MP1A使用的分离元器件的形式,所以stm32mp15xx-dkx.dtsi中对于电源的定义就不实用了。参考内核中相关文档添加固定电源节点的形式添加iovcc和cvcc12即可,根据sii9022的需求,iovcc和cvcc12电压分别为3.3v和1.2v。<br> 参考文档: Documentation/devicetree/bindings/regulator/fixed-regulator.yaml 需在设备树根节点下添加,内容如下: <pre><nowiki> v3v3_hdmi: regulator-v3v3-hdmi { compatible = "regulator-fixed"; regulator-name = "v3v3_hdmi "; regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; regulator-always-on; regulator-boot-on; }; v1v2_hdmi: regulator-v1v2-hdmi { compatible = "regulator-fixed"; regulator-name = "v1v2_hdmi"; regulator-min-microvolt = <1200000>; regulator-max-microvolt = <1200000>; regulator-always-on; regulator-boot-on; }; </nowiki></pre> ==实验目的== 熟悉基于Linux操作系统下的HDMI设备驱动移植配置过程。 ==实验平台== 华清远见开发环境,FS-MP1A平台; ==实验步骤== *添加i2c5及sii9022内容<br> 修改arch/arm/dts/stm32mp15xx-fsmp1x.dts文件,在文件末尾添加如下内容: <pre><nowiki> &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 = <100000>; /* 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>; }; }; }; }; }; </nowiki></pre> *添加ltdc内容<br> 修改arch/arm/dts/stm32mp15xx-fsmp1x.dts文件,在文件末尾添加如下内容: <pre><nowiki> <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>; }; }; }; </nowiki></pre> *添加电源内容<br> 修改arch/arm/dts/stm32mp15xx-fsmp1x.dts文件,在根节点中添加如下内容: <pre><nowiki> v3v3_hdmi: regulator-v3v3-hdmi { compatible = "regulator-fixed"; regulator-name = "v3v3_hdmi "; regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; regulator-always-on; regulator-boot-on; }; v1v2_hdmi: regulator-v1v2-hdmi { compatible = "regulator-fixed"; regulator-name = "v1v2_hdmi"; regulator-min-microvolt = <1200000>; regulator-max-microvolt = <1200000>; regulator-always-on; regulator-boot-on; }; </nowiki></pre> *配置内核<br> 由于内核源码默认配置以及支持sii902x,本节列出主要选项,如下: <pre><nowiki> 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 </nowiki></pre> *编译内核及设备树: linux@ubuntu:$ make -j4 uImage dtbs LOADADDR=0xC2000040 *重启测试<br> 将编译好的设备树和内核镜像拷贝到/tftpboot目录下,通过tftp引导内核,设备连接HDMI显示器,重启设备后查看/sys/class/drm会多出HMID的信息,同时显示器会有显示。 [[Image:51-1-4-1.png]] <br>
返回至
Linux内核-HDMI驱动移植
。
导航菜单
个人工具
登录
命名空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
关于我们
联系我们
资料下载
STM32F103开发板
STM32U575开发板
STM32MP157开发板
Hi3861鸿蒙开发板
HaaS EDU开发板
ESP32开发板
i.MX8M Plus开发板
图书下载
嵌入式系列图书
物联网系列图书
Android系列图书
高校教仪
嵌入式实验室产品
物联网实验室产品
人工智能实验室产品
虚拟仿真实验室产品
行业应用实训室产品
虚拟仿真
嵌入式虚拟仿真平台
物联网虚拟仿真平台
人工智能虚拟仿真
友情链接
华清远见研发中心
元宇宙实验中心
华清远见硬件商城
工具
链入页面
相关更改
特殊页面
页面信息