This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SK-AM62: using the gpios in the 40-pin user expansion port

Part Number: SK-AM62

Hello!

I got the TI Debian release for SK-AM62 booted up. I installed gpiod (via apt-get install) which came with a few programs to set gpio pin outputs etc. I looked at the schematics and the manual for the SK-AM62 to understand the pin numbers connected etc. For eg: user expansion pin 13 is connected to EXP_GPIO0_42. Pin 29 is connected to EXP_GPIO0_36. Now, I list the pins via gpioinfo, and it only shows 22 pins for GPIO0.

If I do,

# gpioset gpiochip0 13=1

or

# gpioset gpiochip0 13=0

I do not see any change in the gpio pin voltage.

For pins like 42, since gpioinfo only lists 22 pins, it gives an error if I try to set them.

root@am62xx:~# gpioset gpiochip0 42=1
gpioset: error setting the GPIO line values: Invalid argument

Do I need to make any changes in the dtsi file to toggle GPIO pins? I tried doing this change, but that didn't change anything.

diff --git a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
index 665c05101e757..e9960212ec11f 100644
--- a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
@@ -268,6 +268,13 @@ AM62X_IOPAD(0x244, PIN_OUTPUT, 7) /* (C17/B15) MMC1_SDWP.GPIO1_49 */
                >;
        };
 
+        usr_exp_gpio_pins_default: usr-exp-gpio-pins-default {
+                pinctrl-single,pins = <
+                        AM62X_IOPAD(0x01b0, PIN_OUTPUT_PULLUP, 7) /* (A20) MCASP0_ACLKR.GPIO1_14 */
+                        AM62X_IOPAD(0x01d0, PIN_OUTPUT_PULLUP, 7) /* (A15) UART0_CTSn.GPIO1_22 */
+                >;
+        };
+

I guess I have to call this fragment from somewhere for this to be effective? Also, I just wanted to add that the earlier examples in this forum that I could find used the older interface in /sys/class/gpio which no longer seem to exist in newer kernels and instead have /sys/bus/gpio/ directory.

Thanks

Ram

  • Hi Ram,

    Do I need to make any changes in the dtsi file to toggle GPIO pins? I tried doing this change, but that didn't change anything.

    This is the correct file, but the device tree is missing a reference to the GPIO module. Follow this thread for an example of adding a reference: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1255485/sk-am62-enabling-user-expansion-i-o-pins/4759247#4759247

    For eg: user expansion pin 13 is connected to EXP_GPIO0_42. Pin 29 is connected to EXP_GPIO0_36.

    While this is true, for gpiod, use the GPIO pin number, not the User Expansion Header number. So for GPIO0_36, use gpioset gpiochip1 36=1.

    For pins like 42, since gpioinfo only lists 22 pins, it gives an error if I try to set them.

    Please run gpiodetect. This command will give you information about what address each gpiochip relates to. GPIO0 will have an address of 600000.gpio and GPIO1 will have 601000.gpio. From the output of gpiodetect, match the gpiochip number to the address. 

    -Anshu

  • Thanks Anshu.

    I tried that on Friday itself, but I was still using the wrong pin numbers I think. This is my current change for the dts file. I will try the other commands and report back.

    Thanks

    Ram

    diff --git a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
    index 665c05101e757..41f8304c8a2a1 100644
    --- a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
    +++ b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
    @@ -268,6 +268,12 @@ AM62X_IOPAD(0x244, PIN_OUTPUT, 7) /* (C17/B15) MMC1_SDWP.GPIO1_49 */
                    >;
            };
     
    +        usr_exp_gpio_pins_default: usr-exp-gpio-pins-default {
    +                pinctrl-single,pins = <
    +                        AM62X_IOPAD(0x01d0, PIN_OUTPUT_PULLUP, 7) /* (A15) UART0_CTSn.GPIO1_22 */
    +                >;
    +        };
    +
            main_mdio1_pins_default: main-mdio1-pins-default {
                    pinctrl-single,pins = <
                            AM62X_IOPAD(0x160, PIN_OUTPUT, 0) /* (AD24/V17) MDIO0_MDC */
    @@ -406,6 +412,12 @@ spidev@0 {
             };
     };
     
    +&main_gpio1 {
    +       pinctrl-names = "default";
    +       pinctrl-0 = <&usr_exp_gpio_pins_default>;
    +       status = "okay";
    +};
    +
     &main_i2c0 {
            status = "okay";
            pinctrl-names = "default";

  • Hi Anshu,

    I made the following change in the dtsi file.

    diff --git a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
    index 665c05101e757..013c27707df24 100644
    --- a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
    +++ b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
    @@ -268,6 +268,13 @@ AM62X_IOPAD(0x244, PIN_OUTPUT, 7) /* (C17/B15) MMC1_SDWP.GPIO1_49 */
                    >;
            };
     
    +        usr_exp_gpio_pins_default: usr-exp-gpio-pins-default {
    +                pinctrl-single,pins = <
    +                        AM62X_IOPAD(0x01d0, PIN_OUTPUT_PULLUP, 7) /* (A15) UART0_CTSn.GPIO1_22 */
    +                        AM62X_IOPAD(0x0088, PIN_OUTPUT, 7) /* (L24) GPMC0_OEn_REn.GPIO0_33 */
    +                >;
    +        };
    +
            main_mdio1_pins_default: main-mdio1-pins-default {
                    pinctrl-single,pins = <
                            AM62X_IOPAD(0x160, PIN_OUTPUT, 0) /* (AD24/V17) MDIO0_MDC */
    @@ -406,6 +413,12 @@ spidev@0 {
             };
     };
     
    +&main_gpio1 {
    +       pinctrl-names = "default";
    +       pinctrl-0 = <&usr_exp_gpio_pins_default>;
    +       status = "okay";
    +};
    +

    I tried to connect a logic analyzer to the physical pin 31 of the user expansion port. This is connected to EXT_GPIO0_33.

    root@am62xx:~# gpiodetect
    gpiochip0 [4201000.gpio] (24 lines)
    gpiochip1 [600000.gpio] (92 lines)
    gpiochip2 [601000.gpio] (52 lines)
    gpiochip3 [1-0022] (24 lines)

    Now, I try to toggle the GPIO0 33 this way.

    root@am62xx:~# gpioset gpiochip1 33=0
    root@am62xx:~# gpioset gpiochip1 33=1

    I am able to see the GPIO toggle on the logic analyzer.

    Thanks for the help.

    Ram