Search by Tags

Device Tree Customization Examples

 

Article updated at 15 May 2020
Compare with Revision




Subscribe for this article updates

Introduction

This article is a collection of examples of Device Tree customization. Examples may get obsolete over time, please check the testing environment details and make similar changes for the device and version you are using.

General Purpose Input / Output (GPIO)

Changing pinmux of a default function to GPIO

Tested on Embedded Linux BSP 3.0b3 (toradex_4.14-2.0.x-imx) / Apalis iMX8X / Apalis Evaluation Board

Note: Please note that the following device trees do not apply for Apalis iMX8QP or Apalis iMX8QM. In those cases, you should make similar changes but in the corresponding fsl-imx8qm-apalis-v1.1.dtsi and fsl-imx8qm-apalis-eval.dtsi or fsl-imx8qm-apalis-ixora-v1.1.dtsi device trees.

In this documentation, we will change a default unneeded function from its original definition to GPIO.

Basically, the steps are:

  1. Locate former function definition and disable or delete it.
  2. Define a new pinctrl with our GPIO pinmux definitions of the selected pins.
  3. Add the pinctrl to the iomux group.

In this particular example, we will be changing the SPI0 pins to a sysfs accessed GPIO.

arch/arm64/boot/dts/freescale/fsl-imx8qxp-apalis-eval.dtsi
diff --git a/arch/arm64/boot/dts/freescale/fsl-imx8qxp-apalis-eval.dtsi b/arch/arm64/boot/dts/freescale/fsl-imx8qxp-apalis-eval.dtsi
index c957472c3652..12652f69f5ff 100644
--- a/arch/arm64/boot/dts/freescale/fsl-imx8qxp-apalis-eval.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-imx8qxp-apalis-eval.dtsi
@@ -199,7 +199,7 @@
 
 /* Apalis SPI1 */
 &lpspi0 {
-	status = "okay";
+	status = "disabled";
 
 	spidev0: spi@0 {
 		compatible = "toradex,evalspi";
arch/arm64/boot/dts/freescale/fsl-imx8qxp-apalis.dtsi
diff --git a/arch/arm64/boot/dts/freescale/fsl-imx8qxp-apalis.dtsi b/arch/arm64/boot/dts/freescale/fsl-imx8qxp-apalis.dtsi
index 56012aab1cf3..a0292e37af14 100644
--- a/arch/arm64/boot/dts/freescale/fsl-imx8qxp-apalis.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-imx8qxp-apalis.dtsi
@@ -317,7 +317,7 @@
 		    <&pinctrl_gpio8>, <&pinctrl_qspi0a_gpios>,
 		    <&pinctrl_sata1_act>, <&pinctrl_reset_moci>,
 		    <&pinctrl_mmc1_gpios>, <&pinctrl_dap1_gpios>,
-		    <&pinctrl_parallel_csi>;
+		    <&pinctrl_parallel_csi>, <&pinctrl_gpiospi0>;
 
 	apalis-imx8qxp {
 		/* Apalis AN1_ADC */
@@ -613,6 +613,17 @@
 			>;
 		};
 
+		/* Apalis SPI1 pins changed to GPIO*/
+		pinctrl_gpiospi0: lpspi0gpiogrp {
+			fsl,pins = <
+				SC_P_SPI0_CS0_LSIO_GPIO1_IO08			0x21	/* MXM3 227 */
+				SC_P_SPI0_SDI_LSIO_GPIO1_IO05			0x21	/* MXM3 223 */
+				SC_P_SPI0_SDO_LSIO_GPIO1_IO06           0x21	/* MXM3 225 */
+				SC_P_CSI_EN_LSIO_GPIO3_IO02           0x21	/* MXM3 221 */
+			>;
+		};
+
+
 		/* Apalis SPI2 */
 		pinctrl_lpspi2: lpspi2grp {
 			fsl,pins = <
 

Note: Pinmux definition are under include/dt-bindings/pinctrl/pads-imx8qpx.h Note: Remember to check the following article to understand the equivalence between physical pins and Linux GPIO: GPIO Alphanumeric to GPIO Numeric Assignment

SION Bit - i.MX family

Tested on Embedded Linux BSP 2.8 / Colibri iMX7 / Colibri Evaluation Board

Remarks: you must check if the SION Bit is available for both the i.MX family you target (i.MX 6, i.MX7, etc,) as well as the specific pin you want to use (SoC pin exposed in the edge connector).

arch/arm/boot/dts/imx7-colibri.dtsi
diff --git a/arch/arm/boot/dts/imx7-colibri.dtsi b/arch/arm/boot/dts/imx7-colibri.dtsi
index 4a1ef3f83faf..d2449ec2cb22 100644
--- a/arch/arm/boot/dts/imx7-colibri.dtsi
+++ b/arch/arm/boot/dts/imx7-colibri.dtsi
@@ -365,7 +365,7 @@
 
        pinctrl_gpio1: gpio1-grp {
                fsl,pins = <
-                       MX7D_PAD_SAI1_RX_SYNC__GPIO6_IO16       0x14 /* SODIMM 77 */
+                       MX7D_PAD_SAI1_RX_SYNC__GPIO6_IO16       ((1 << 30) | 0x14) /* SODIMM 77 */
                        MX7D_PAD_EPDC_DATA09__GPIO2_IO9         0x14 /* SODIMM 89 */
                        MX7D_PAD_EPDC_DATA08__GPIO2_IO8         0x74 /* SODIMM 91 */
                        MX7D_PAD_LCD_RESET__GPIO3_IO4           0x14 /* SODIMM 93 */

Display timings

7.0” WVGA 800 x 3 (RGB) x 480

Since Colibri iMX8X doesn't support vidargs customization, any display implementation has to be done at the device tree.

Tested on Embedded Linux BSP 3.0b3 (toradex_4.14-2.0.x-imx) / Colibri iMX8X / Colibri Evaluation Board

Note: This change is compatible with the Toradex Resistive and Capacitive Touch 7" Parallel displays.

You can check the complete documentation of the following parameters at the Kernel Documentation.

arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri.dtsi
diff --git a/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri.dtsi b/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri.dtsi
index 8c755fae4f22..eee928b38b49 100644
--- a/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-imx8qxp-colibri.dtsi
@@ -44,16 +44,17 @@
                data-mapping = "bgr666";
 
                panel-timing {
-                       /* Default VESA VGA display timings */
-                       clock-frequency = <25175000>;
-                       hactive = <640>;
-                       hback-porch = <48>;
-                       hfront-porch = <16>;
-                       hsync-len = <96>;
+                       /* 7.0” WVGA 800 x 3 (RGB) x 480 */
+                       clock-frequency = <33260000>;
+                       hactive = <800>;
                        vactive = <480>;
-                       vback-porch = <31>;
-                       vfront-porch = <11>;
+                       hback-porch = <216>;
+                       hfront-porch = <40>;
+                       vback-porch = <35>;
+                       vfront-porch = <10>;
+                       hsync-len = <128>;
                        vsync-len = <2>;
+
                        pixelclk-active = <0>;
                };

Inertial Measurement Unit (IMU)

InvenSense MPU-6050

Tested on Embedded Linux BSP 2.8 / Colibri iMX6ULL / Iris Carrier Board

Remarks: address 68 cannot be used since it is also used by the Iris RTC. The pin AD0 of MPU-6050 has to be driven high.

arch/arm/boot/dts/imx6ull-colibri-eval-v3.dtsi
diff --git a/arch/arm/boot/dts/imx6ull-colibri-eval-v3.dtsi b/arch/arm/boot/dts/imx6ull-colibri-eval-v3.dtsi
index 5870638c3a6f..c2eb33edae6b 100644
--- a/arch/arm/boot/dts/imx6ull-colibri-eval-v3.dtsi
+++ b/arch/arm/boot/dts/imx6ull-colibri-eval-v3.dtsi
@@ -166,6 +166,12 @@
 		compatible = "st,m41t0";
 		reg = <0x68>;
 	};
+
+	mpu6050@69 {
+		compatible = "invensense,mpu6050";
+		reg = <0x69>;
+		status = "okay";
+	};
 };
 
 &lcdif {

Ethernet

Adding support for KSZ9031 PHY for early Verdin iMX8M Mini samples

Tested on Embedded Linux BSP 3.0 / Verdin iMX8M Mini / Verdin Development Board

arch/arm64/boot/dts/freescale/fsl-imx8mm-verdin.dtsi
diff --git a/arch/arm64/boot/dts/freescale/fsl-imx8mm-verdin.dtsi b/arch/arm64/boot/dts/freescale/fsl-imx8mm-verdin.dtsi
index 270aa603ecd0..7ad85155c18c 100755
--- a/arch/arm64/boot/dts/freescale/fsl-imx8mm-verdin.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-imx8mm-verdin.dtsi
@@ -211,6 +211,13 @@
                        interrupts = <10 IRQ_TYPE_LEVEL_LOW>;
                        micrel,led-mode = <0>;
                        reg = <7>;
+                       txen-skew-ps = <0>;
+                       txd0-skew-ps = <0>;
+                       txd1-skew-ps = <0>;
+                       txd2-skew-ps = <0>;
+                       txd3-skew-ps = <0>;
+                       txc-skew-ps = <1860>;
+                       rxc-skew-ps = <1200>;
                };
        };
 };