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-AM64X: AM64 SK can not toggle GPIO output

Part Number: PROCESSOR-SDK-AM64X

I am trying to configure GPIO0_35 from the DTS since it leads to the Raspberry Pi header on the AM64 SK. I am using processor SDK 8.1.0.39. I have done my best to follow this FAQ, however I am still not successful. 

I added the following into &main_pmx0:

main_rpi_gpio0_35_default: main_rpi_gpio0_35_default {
	pinctrl-single,pins = <
		AM64X_IOPAD(0x0090, PIN_OUTPUT, 7) /* (P17) GPIO0_35 */
	>;
};

I then built the dtb and replaced the k3-am643-sk.dtb file in the rootfs/boot/ directory. Please also note these commands from the console in this image, they show no change in output value: 

 What is it that I'm missing? 

  • Hi Sabeeh,

    I am not sure what is missing. I don't have an SK, but I tested on GPEVM, and I can toggle GPIO0_40 which is accessible on the expansion card. Please see the detail in the following post.

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1076217/tmds64gpevm-cannot-toggle-the-gpios/4000919#4000919

    Can you please read the GPIO0_35 pad config register?

    # devmem2 0xf4090

    I do see your entries in /sys/class/gpio/ are different than mine which is also running SDK 8.1.0.39.

    What is the output of command 'uname -a' on your SK board?

  • Hi Bin,

    See output of the following commands:

    root@am64xx-evm:~# devmem2 devmem2 0xf4090
    /dev/mem opened.
    Memory mapped at address 0xffff87220000.
    Illegal data type '0'.

    root@am64xx-evm:~# devmem2 0x000F4090
    /dev/mem opened.
    Memory mapped at address 0xffff9f1c0000.
    Read at address 0x000F4090 (0xffff9f1c4090): 0x00214007

    root@am64xx-evm:~# uname -a
    Linux am64xx-evm 5.10.65-gdcc6bedb2c #1 SMP PREEMPT Mon Jan 17 20:42:23 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

  • Hi Sabeeh,

    It might need more in device tree. But you could use a quick hack:

    # devmem2 0xf4090 w 0x14007

    then you can try to toggle it in sysfs.

  • Hi Bin,

    Thank you for your suggestion, however that still doesn't seem to work. BTW, doesn't reading back value after setting it to 1 a bug or something is incorrect?

    I will also compare DTS from AM64 SK to EVM and see if there is anything outstanding between the two. 

    root@am64xx-evm:~# devmem2 0xf4090
    /dev/mem opened.
    Memory mapped at address 0xffff82750000.
    Read at address 0x000F4090 (0xffff82754090): 0x00214007
    root@am64xx-evm:~# devmem2 0xf4090 w 0x14007
    /dev/mem opened.
    Memory mapped at address 0xffffa4200000.
    Read at address 0x000F4090 (0xffffa4204090): 0x00214007
    Write at address 0x000F4090 (0xffffa4204090): 0x00014007, readback 0x00014007
    root@am64xx-evm:~# cd /sys/class/gpio/
    root@am64xx-evm:/sys/class/gpio# ls -l
    total 0
    --w------- 1 root root 65536 Jan 17 20:55 export
    lrwxrwxrwx 1 root root 0 Mar 6 06:34 gpiochip319 -> ../../devices/platform/bus@f4000/20010000.i2c/i2c-1/1-0060/gpio/gpiochip319
    lrwxrwxrwx 1 root root 0 Jan 17 20:55 gpiochip327 -> ../../devices/platform/bus@f4000/601000.gpio/gpio/gpiochip327
    lrwxrwxrwx 1 root root 0 Jan 17 20:55 gpiochip415 -> ../../devices/platform/bus@f4000/600000.gpio/gpio/gpiochip415
    lrwxrwxrwx 1 root root 0 Jan 17 20:55 gpiochip502 -> ../../devices/platform/bus@f4000/20010000.i2c/i2c-1/1-0070/gpio/gpiochip502
    lrwxrwxrwx 1 root root 0 Jan 17 20:55 gpiochip510 -> ../../devices/platform/bus@f4000/3b000000.memory-controller/gpio/gpiochip510
    --w------- 1 root root 65536 Jan 17 20:55 unexport
    root@am64xx-evm:/sys/class/gpio# echo 450 > gpio
    -sh: gpio: Permission denied
    root@am64xx-evm:/sys/class/gpio# echo 450 > export
    root@am64xx-evm:/sys/class/gpio# cd gpio450
    root@am64xx-evm:/sys/class/gpio/gpio450# cat direction
    in
    root@am64xx-evm:/sys/class/gpio/gpio450# echo out > direction
    root@am64xx-evm:/sys/class/gpio/gpio450# echo 1 > value
    root@am64xx-evm:/sys/class/gpio/gpio450# cat value
    0
    root@am64xx-evm:/sys/class/gpio/gpio450# echo 0 > value
    root@am64xx-evm:/sys/class/gpio/gpio450# cat value
    0

  • Hi Sabeeh,

    The "value" already read 0.

    Beside the DTS setting pinmux you added in your first post, you also have to add a reference to this pinmux to "active" it. Following is a quick hack to get this gpio toggling working.

    diff --git a/arch/arm64/boot/dts/ti/k3-am642-sk.dts b/arch/arm64/boot/dts/ti/k3-am642-sk.dts
    index ae823118b7e0..ba534deb5635 100644
    --- a/arch/arm64/boot/dts/ti/k3-am642-sk.dts
    +++ b/arch/arm64/boot/dts/ti/k3-am642-sk.dts
    @@ -140,6 +140,9 @@
     };
    
     &main_pmx0 {
    +       pinctrl-names = "default";
    +       pinctrl-0 = <&main_rpi_gpio0_35_default>;
    +
            main_mmc1_pins_default: main-mmc1-pins-default {
                    pinctrl-single,pins = <
                            AM64X_IOPAD(0x0294, PIN_INPUT, 0) /* (J19) MMC1_CMD */