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.

PROCESSOR-SDK-AM62X: GPIO toggle test

Part Number: PROCESSOR-SDK-AM62X

Hi,

I would like to test GPIO chain test on AM62x EVK.

I have already configured the pins necessary but the input and output does not seem to change.

The voltage also does not change.

I saw that a few other people had the same problem but I couldn't find the solution to it.

I am using physical pin 16 and 18 of J3.

This is the dts file in patch format.

10a11
> 		serial5 = &main_uart5;
23c24
< 		bootargs = "console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02800000";
---
> 		bootargs = "console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02850000";
231a233,246
> 	led1 {
> 		compatible = "gpio-leds";
> 		pinctrl-names = "default";
> 		pinctrl-0 = <&usr_led_pins_test>;
> 
> 		led-0 {
> 			label = "gpio_single_led";
> 			gpios = <&main_gpio0 42 GPIO_ACTIVE_HIGH>;
> 			linux,default-trigger = "heartbeat";
> 			function = LED_FUNCTION_HEARTBEAT;
> 			default-state = "on";
> 		};
> 	};
> 
250a266,272
> 	mygpio1_pins_default: mygpio1-pins-default {
> 		pinctrl-single,pins = <
> 			AM62X_IOPAD(0x009c, PIN_OUTPUT_PULLUP, 7) /* (V25) GPMC0_WAIT1.GPIO0_38 */
> 			AM62X_IOPAD(0x00a0, PIN_INPUT_PULLDOWN, 7) /* (K25) GPMC0_WPn.GPIO0_39 */
> 		>;
> 	};
> 
257a280,287
> 	main_uart5_pins_default: main-uart5-pins-default {
> 		pinctrl-single,pins = <
> 			AM62X_IOPAD(0x1d8, PIN_INPUT, 1) /* (C15) MCAN0_TX.UART5_RXD */
> 			AM62X_IOPAD(0x1dc, PIN_OUTPUT, 1) /* (E15) MCAN0_RX.UART5_TXD */
> 		>;
> 	};
> 
> // this is connected to EEPROM
335a366,371
> 	usr_led_pins_test: usr-led-pins-test {
> 		pinctrl-single,pins = <
> 			AM62X_IOPAD(0x00ac, PIN_OUTPUT, 7) /* (L21) GPMC0_CSn1.GPIO0_42 */
> 		>;
> 	};
> 
453a490,505
> &mcu_pmx0 {
> 	mymcui2c1_pins_default: mymcui2c1-pins-default {
> 		pinctrl-single,pins = <
> 			AM62X_MCU_IOPAD(0x0044, PIN_INPUT, 0) /* (A8) MCU_I2C0_SCL */
> 			AM62X_MCU_IOPAD(0x0048, PIN_INPUT, 0) /* (D10) MCU_I2C0_SDA */
> 		>;
> 	};
> 
> 	mymcugpio1_pins_default: mymcugpio1-pins-default {
> 		pinctrl-single,pins = <
> 			AM62X_MCU_IOPAD(0x003c, PIN_INPUT, 7) /* (E5) MCU_MCAN1_TX.MCU_GPIO0_15 */
> 			AM62X_MCU_IOPAD(0x0040, PIN_OUTPUT, 7) /* (D4) MCU_MCAN1_RX.MCU_GPIO0_16 */
> 		>;
> 	};
> };
> 
486c538,539
< 	status = "disabled";
---
> 	pinctrl-names = "default";
> 	pinctrl-0 = <&main_uart5_pins_default>;
494c547
< 	status = "disabled";
---
> 	status = "okay";
524a578,584
> 
> 	at24@50 {
>     compatible = "atmel,24c02";
>     reg = <0x50>;
>     pagesize = <8>;
>     size = <256>;
> };

after this, i did the following commands.

echo 439 > /sys/class/gpio/export

echo 440 > /sys/class/gpio/export

echo in > /sys/class/gpio/gpio440/direction

cat /sys/class/gpio/gpio440/direction

in

echo out > /sys/class/gpio/gpio439/direction

cat /sys/class/gpio/gpio439/direction

out

cat /sys/class/gpio/gpio439/value

0

echo 1 > /sys/class/gpio/gpio439/value

cat /sys/class/gpio/gpio439/value

0

  • Hi,

    is "usr_led_pins_test" having valid pinctrl-single?

    Example for GPIO1_22 need to add

    pinctrl-single,pins = <
        AM62X_IOPAD(0x01d0, PIN_OUTPUT, 7) /* (A15) GPIO1_22 */
    >;

  • Yes, usr_led_pins_test is working properly. I can toggle the led using /sys/class/leds/...

    The problem is i cant control these following two pins.

    >             AM62X_IOPAD(0x009c, PIN_OUTPUT_PULLUP, 7) /* (V25) GPMC0_WAIT1.GPIO0_38 */
    >             AM62X_IOPAD(0x00a0, PIN_INPUT_PULLDOWN, 7) /* (K25) GPMC0_WPn.GPIO0_39 */

  • try without PULLUP and PULLDOWN

  • Yes i have tried that already also. I tried with both nopulluppulldown. And it still didn't work.

  • Hi Cyra,

    >     mygpio1_pins_default: mygpio1-pins-default {
    >         pinctrl-single,pins = <
    >             AM62X_IOPAD(0x009c, PIN_OUTPUT_PULLUP, 7) /* (V25) GPMC0_WAIT1.GPIO0_38 */
    >             AM62X_IOPAD(0x00a0, PIN_INPUT_PULLDOWN, 7) /* (K25) GPMC0_WPn.GPIO0_39 */
    >         >;
    >     };

    This only defines the pinmux mode for these two pins, but you need to add "pinctrl-0 = <&mygpio1_pins_default>;" somewhere in DTS to activate this pinmux setting. You can add it to &main_pmx0 node.

  • Like this?

    If so, still not working.

    &main_pmx0 {
    
     pinctrl-0 = <&usr_gpio_pins_test>;
     pinctrl-names = "gpio_test";
    
     usr_gpio_pins_test: usr-gpio-pins-test {
     pinctrl-single,pins = <
     AM62X_IOPAD(0x00ac, PIN_OUTPUT, 7) /* (L21) GPMC0_CSn1.GPIO0_42 */
     AM62X_IOPAD(0x01d0, PIN_INPUT, 7) /* (A15) UART0_CTSn.GPIO1_22 */
     >;
     };
    };

  • I am able to toggling same gpio0_38 and gpio0_39, checked with multi meter but proc entries are not updating always showing zero

  • Hi Gireesh,

    Glad to hear it is working for you. Thanks for the update.

    I am aware that the sysfs entry always showing zero, not sure if this is intended or a bug in kernel GPIO drivers. This is on my backlog to check, but haven't got time for it yet.

  • Hi Gireesh,

    So after you toggle the pins, you checked with multi meter and the output was 3V?

    Were you able to check whether toggling is success or not via software side?

    Is the settings the same as mine? Or am i missing anything?

  • Hi cyra,

    software side same as suggested above.

    for testing I made both gpio as output  and validated with multi meter, output was 3.29v

    but proc are not reflecting the actual pin status

    dtb changes:

    test_gpio_default: test-gpio {
                    pinctrl-single,pins = <
                            AM62X_IOPAD(0x009c, PIN_OUTPUT, 7) /* (V25) GPMC0_WAIT1.GPIO0_38 */
                            AM62X_IOPAD(0x00a0, PIN_OUTPUT, 7) /* (K25) GPMC0_WPn.GPIO0_39 */
                    >;
    };

    call it in any of driver dtb which  loads or inbuilt

    pinctrl-names = "default";
    pinctrl-0 = <&test_gpio_default>;

    after boot enable  with proc

    echo 439 > /sys/class/gpio/export

    echo 440 > /sys/class/gpio/export

    echo out > /sys/class/gpio/gpio440/direction

    echo out > /sys/class/gpio/gpio439/direction

    echo 1 > /sys/class/gpio/gpio439/value

    echo 1 > /sys/class/gpio/gpio440/value

    test voltage with multi meter

  • I followed the same instruction but only seeing 0.5V.

    I did both of the following in k3-am62x-sk-common.dtsi.

    &main_pmx0 {
    pinctrl-names = "default";
    pinctrl-0 = <&test_gpio_default>;
    test_gpio_default: test-gpio {
    pinctrl-single,pins = <
    AM62X_IOPAD(0x009c, PIN_OUTPUT, 7) /* (V25) GPMC0_WAIT1.GPIO0_38 */
    AM62X_IOPAD(0x00a0, PIN_OUTPUT, 7) /* (K25) GPMC0_WPn.GPIO0_39 */
    >;
    };
    };

    Flash the DTB files into device. Power on.

    echo 439 > /sys/class/gpio/export

    echo 440 > /sys/class/gpio/export

    echo out > /sys/class/gpio/gpio440/direction

    echo out > /sys/class/gpio/gpio439/direction

    echo 1 > /sys/class/gpio/gpio439/value

    echo 1 > /sys/class/gpio/gpio440/value

    test voltage with multi meter > 0.5V.

  • you have done pin mux but you also need to call pinmux in some driver dtb

  • Can you show me an example?

  • taking UART as example

    from k3-am62x-sk-common.dtsi

    &main_uart0 {
            pinctrl-names = "default";
            pinctrl-0 = <&main_uart0_pins_default>;
    };

    &main_pmx0 {
            main_uart0_pins_default: main-uart0-pins-default {
                    pinctrl-single,pins = <
                            AM62X_IOPAD(0x1c8, PIN_INPUT, 0) /* (D14) UART0_RXD */
                            AM62X_IOPAD(0x1cc, PIN_OUTPUT, 0) /* (E14) UART0_TXD */
                    >;
            };

    from k3-am62-main.dtsi

            main_uart0: serial@2800000 {
                    compatible = "ti,am64-uart", "ti,am654-uart";
                    reg = <0x00 0x02800000 0x00 0x100>;
                    interrupts = <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>;
                    power-domains = <&k3_pds 146 TI_SCI_PD_EXCLUSIVE>;
                    clocks = <&k3_clks 146 0>;
                    clock-names = "fclk";
            };

    only for quick testing purpose add only pin mux in existed serial pinmux and  test once

    &main_pmx0 {
            main_uart0_pins_default: main-uart0-pins-default {
                    pinctrl-single,pins = <
                            AM62X_IOPAD(0x1c8, PIN_INPUT, 0) /* (D14) UART0_RXD */
                            AM62X_IOPAD(0x1cc, PIN_OUTPUT, 0) /* (E14) UART0_TXD */
                           AM62X_IOPAD(0x009c, PIN_OUTPUT, 7) /* (V25) GPMC0_WAIT1.GPIO0_38 */
                           AM62X_IOPAD(0x00a0, PIN_OUTPUT, 7) /* (K25) GPMC0_WPn.GPIO0_39 */

                    >;
            };

  • Hi Gireesh,

    Thank you for providing details in this e2e thread.

    only for quick testing purpose add only pin mux in existed serial pinmux and  test once

    &main_pmx0 {
            main_uart0_pins_default: main-uart0-pins-default {
                    pinctrl-single,pins = <
                            AM62X_IOPAD(0x1c8, PIN_INPUT, 0) /* (D14) UART0_RXD */
                            AM62X_IOPAD(0x1cc, PIN_OUTPUT, 0) /* (E14) UART0_TXD */
                           AM62X_IOPAD(0x009c, PIN_OUTPUT, 7) /* (V25) GPMC0_WAIT1.GPIO0_38 */
                           AM62X_IOPAD(0x00a0, PIN_OUTPUT, 7) /* (K25) GPMC0_WPn.GPIO0_39 */

                    >;
            };

    This is a good trick to get a prototype quickly up and running.

    Alternatively, you could define the pinmux in a separate new node, then add its "pinctrl-0" entry to "&main_pmx0" node. This would activate the new pinmux setting without relying on other DT node (the main_uart0 in your example).

  • I tried as Gireesh and Bin mentioned and able to measure 3V.

    Back to the topic, I won't be able to verify via user space even if i manage to connect and set as output and input since the read back value via "cat value" won't be accurate.

    So is there any other way to verify this via user space?

  • Thanks for the update Cyra. I am not aware of any other way to check it in software. The GPIO pin should work correctly if it is configured properly in kernel DTS. So I don't think you need to verify it in user space applications, after thee kernel porting work is done.

  • Is this the kernel issue or hardware issue?

    I need to read the input value (high or low) as part of our testing application.

    So if this is the hardware issue, we can skip testing this on AM62x-EVM and only test it on our custom hardware.

    But if this is not the case, then we need another way to check this input value.

  • Is this the kernel issue or hardware issue?

    It seems to be a kernel driver bug. Please try the following kernel patch. I have sent it to our sw dev team for review.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/0001_2D00_gpio_2D00_davinci_2D00_gpio_5F00_get_2D00_return_2D00_proper_2D00_value.patch

  • May I know how to include/merge this file with it's original file?

    And where and what is original file.

  • - download this patch file to your kernel source folder - <sdk>/board-support/linux-5.10.*/;

    - run the following command in the kernel source folder:

    $ git am 0001-gpio-davinci-gpio_get-return-proper-value.patch

  • And then generate the image again?

  • Cyra,

    Please ignore the kernel patch I sent yesterday.

                           AM62X_IOPAD(0x009c, PIN_OUTPUT, 7) /* (V25) GPMC0_WAIT1.GPIO0_38 */
                           AM62X_IOPAD(0x00a0, PIN_OUTPUT, 7) /* (K25) GPMC0_WPn.GPIO0_39 */

    The issue is in the GPIO pinmux setting here, the mode should be "PIN_INPUT".

    Please see the definition of PIN_INPUT and PIN_OUTPUT here,

    https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/include/dt-bindings/pinctrl/k3.h?h=ti-linux-5.10.y#n26

    PIN_OUTPUT has the RXACTIVE disabled, which causes the sysfs entry doesn't reflect the correct value.

  • I changed the pin to input for 38 and output for 39. But it still didn't work.

  • Here is what I tested:

    root@am62xx-evm:~# cd /sys/class/gpio
    root@am62xx-evm:gpio# ls -l
    total 0
    --w------- 1 root root 4096 Sep 27 17:03 export
    lrwxrwxrwx 1 root root    0 Sep 27 17:03 gpiochip287 -> ../../devices/platform/bus@f0000/20010000.i2c/i2c-1/1-0022/gpio/gpiochip287
    lrwxrwxrwx 1 root root    0 Sep 27 17:03 gpiochip311 -> ../../devices/platform/bus@f0000/601000.gpio/gpio/gpiochip311
    lrwxrwxrwx 1 root root    0 Sep 27 17:03 gpiochip399 -> ../../devices/platform/bus@f0000/600000.gpio/gpio/gpiochip399
    lrwxrwxrwx 1 root root    0 Sep 27 17:03 gpiochip486 -> ../../devices/platform/bus@f0000/bus@f0000:bus@4000000/4201000.gpio/gpio/gpiochip486
    lrwxrwxrwx 1 root root    0 Sep 27 17:03 gpiochip510 -> ../../devices/platform/bus@f0000/3b000000.memory-controller/gpio/gpiochip510
    --w------- 1 root root 4096 Sep 27 17:03 unexport
    root@am62xx-evm:gpio# echo 437 > export
    root@am62xx-evm:gpio# echo 438 > export
    root@am62xx-evm:gpio# cd gpio437
    root@am62xx-evm:gpio437# cat value
    0
    root@am62xx-evm:gpio437# echo out > direction 
    root@am62xx-evm:gpio437# cat value 
    0
    root@am62xx-evm:gpio437# echo 1 > value 
    root@am62xx-evm:gpio437# cat value 
    1
    root@am62xx-evm:gpio437# cd ../gpio438
    root@am62xx-evm:gpio438# cat value 
    1
    root@am62xx-evm:gpio438# echo out > direction 
    root@am62xx-evm:gpio438# cat value 
    0
    root@am62xx-evm:gpio438# echo 1 > value 
    root@am62xx-evm:gpio438# cat value 
    1
    root@am62xx-evm:gpio438# 
    

    Here is my device tree change:

    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 e586884eb077..ade1ffa81830 100644
    --- a/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
    +++ b/arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi
    @@ -242,6 +244,8 @@
                    pinctrl-single,pins = <
                            AM62X_IOPAD(0x1c8, PIN_INPUT, 0) /* (D14) UART0_RXD */
                            AM62X_IOPAD(0x1cc, PIN_OUTPUT, 0) /* (E14) UART0_TXD */
    +                       AM62X_IOPAD(0x009c, PIN_INPUT_PULLDOWN, 7) /* (V25) GPMC0_WAIT1.GPIO0_38 */
    +                       AM62X_IOPAD(0x00a0, PIN_INPUT_PULLUP, 7) /* (K25) GPMC0_WPn.GPIO0_39 */
                    >;
            };
     
     

  • Is this with the patch that you sent? or without using that patch?

  • Do i need to remove the patch? if so, how?

  • Is this with the patch that you sent? or without using that patch?

    Without the patch. The patch is not the solution. The solution is to use 'PIN_INPUT' in the pinmux configuration.

    Do i need to remove the patch? if so, how?

    If the patch was added using 'git am' command I mentioned earlier, and you didn't modify anything else in the kernel, the following command will remove the patch:

    $ git reset --hard HEAD^