linuxhardwaredevice-tree

DTS: Overwriting pin configuration


I'm setting up a custom device and I need to disable some pins in the dts. Can I just overwrite the pins in the dts file or do I need to change them in the dtsi file. Note that I do want to keep the other pin assignments.

The dtsi file contains the following.

&iomuxc {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_hog>;

    imx6qdl-var-som-mx6 {

        pinctrl_hog: hoggrp {
            fsl,pins = <
                /* CTW6120 IRQ */
                MX6QDL_PAD_EIM_DA7__GPIO3_IO07      0x80000000
                /* for Bluetooth/wifi enable */
                MX6QDL_PAD_SD3_DAT6__GPIO6_IO18     0x1b0b1
                /* SDMMC2 CD/WP */
                MX6QDL_PAD_KEY_COL4__GPIO4_IO14     0x80000000
                MX6QDL_PAD_KEY_ROW4__GPIO4_IO15     0x80000000
                /* USBOTG ID pin */
                /*MX6QDL_PAD_GPIO_4__GPIO1_IO04     0x80000000*/
                /* PMIC INT */
                MX6QDL_PAD_GPIO_17__GPIO7_IO12      0x80000000
                /* Wifi Slow Clock */
                MX6QDL_PAD_ENET_RXD0__OSC32K_32K_OUT    0x000b0
                /* Audio Clock */
                MX6QDL_PAD_GPIO_0__CCM_CLKO1        0x130b0
                /* Audio reset */
                MX6QDL_PAD_GPIO_19__GPIO4_IO05      0x178b0
                /* Camera Clock */
                MX6QDL_PAD_GPIO_3__CCM_CLKO2        0x130b0
                /* Resistive touch irq */
                MX6QDL_PAD_DISP0_DAT4__GPIO4_IO25   0x178b0
            >;
        };
        ... /* Other definitions */
    };
};

I read the following documentation


Solution

  • You can overwrite a node as long as you have labled it. A label has the form of label: node@0x1 { /* data */ };

    Lets take an example device tree named main.dts:

    $ cat main.dts 
    /dts-v1/;
    
    / {
            model = "Test device tree";
            #address-cells = <0>;
            #size-cells = <1>;
    
            iomuxc: iomuxc@0x1 {
                    reg = <0x1>;
                    pinctrl-names = "default";
                    pinctrl-0 = <&pinctrl_hog>;
    
                    imx6qdl-var-som-mx6 {
                            pinctrl_hog: hoggrp {
                                    fsl,pins = <
                                            0x1b8 0x588 0x000 0x5 0x0 0x80000000
                                            /* more pins */
                                    >;
                            };
                    };
            };
    };
    
    &pinctrl_hog {
            fsl,pins = <
                    0x1b8 0x588 0x000 0x5 0x0 0x89999999
                    /* more pins */
            >;
    };
    

    Here, I overwrite the pin control for the label pinctrl_hog. You can validate the output by compile and decompile the device tree:

    $ dtc -I dts -O dtb -o out.dtb main.dts # compile 
    $ dtc -I dtb -O dts out.dtb 
    /dts-v1/;
    
    / {
            model = "Test device tree";
            #address-cells = <0x0>;
            #size-cells = <0x1>;
    
            iomuxc@0x1 {
                    reg = <0x1>;
                    pinctrl-names = "default";
                    pinctrl-0 = <0x1>;
    
                    imx6qdl-var-som-mx6 {
    
                            hoggrp {
                                    fsl,pins = <0x1b8 0x588 0x0 0x5 0x0 0x89999999>;
                                    linux,phandle = <0x1>;
                                    phandle = <0x1>;
                            };
                    };
            };
    };
    

    As you can see, the pins is set to 0x89999999 instead of the original 0x80000000. Just make sure that the label exists before you use it. Normally, just as in C, you include the header on top of your file.

    I hope this helps ;-)