using device-tree fragments/overlays

Peter Robinson pbrobinson at gmail.com
Wed Oct 13 10:38:37 CEST 2021


Hi Tim,

> I'm working on some features for the imx8mm-venice boards I support
> which depend on making small changes to the dt before booting Linux.
>
> The purpose is not to have any of this apply to the U-Boot controlling
> dt but instead to the Linux kernel dt applied within ft_board_setup. I
> could apply these changes with code but it would be way more readable
> if there was a way to store these as fragments in the FIT image and
> apply them.
>
> The fragments would be small and have to do with two UART's routed to
> a multi-protocol RS232/RS485 transceiver that can be used as either of
> the following:
>  - two tx/rx UART's (the default configuration for my dt's)
>  - one rs232 uart with CTS/RTS flow control
>  - one rs485 uart
>
> Here would be an example dt overlay to apply over the default
> arch/arm/dts/imx8mm-venice-gw73xx-0x.dts to change it from 2x RS232
> UARTS with TX/RX (uart2/uart4) to RS485 half duplex:
>
> /* For RS485 HD:
>  *  - UART4_TX is DE for RS485 transmitter
>  *  - RS485_EN needs to be pulled high
>  *  - RS485_HALF needs to be pulled high
>  *  - RS485_TERM enables on-chip termination
>  */
> &uart2 {
>         rts-gpios = <&gpio5 29 GPIO_ACTIVE_HIGH>;
>         rs485-term-gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
> };
>
> &uart4 {
>         status = "disabled";
> };
>
> &iomuxc {
>         pinctrl-names = "default";
>         pinctrl-0 = <&pinctrl_hog>;
>
>         pinctrl_hog: hoggrp {
>                 fsl,pins = <
>                         MX8MM_IOMUXC_GPIO1_IO00_GPIO1_IO0
> 0x40000104 /* RS485_TERM */
>                         MX8MM_IOMUXC_SAI1_RXFS_GPIO4_IO0
> 0x40000144 /* RS485_EN */
>                         MX8MM_IOMUXC_SAI1_RXD0_GPIO4_IO2
> 0x40000144 /* RS485_HALF */
>                 >;
>         };
>
>         pinctrl_uart2: uart2grp {
>                 fsl,pins = <
>                         MX8MM_IOMUXC_UART2_RXD_UART2_DCE_RX     0x140
>                         MX8MM_IOMUXC_UART2_TXD_UART2_DCE_TX     0x140
>                         MX8MM_IOMUXC_UART4_TXD_GPIO5_IO29       0x140
>                 >;
>         };
> };
>
> Anyone do anything like this before or work with dt fragments/overlays
> in U-Boot or have any other suggestions?

A feature for overlays landed upstream in May [1], so the 2021,07
release, so I'm sure there's most of the functionality you require
already upstream. Not sure how a user would specify which of the
variants to use or how it would load it from the FIT but I'm sure the
patch series provides you a good start point.

Peter

[1] https://lists.denx.de/pipermail/u-boot/2021-May/448794.html


More information about the U-Boot mailing list