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.

AM6412: GPIO write operation not done

Part Number: AM6412

Hi Experts,

I'm using AM6412 EVM with processor sdk 08.06. I trying to toggle the MAIN GPIO0, GPIO1 and MCU_GPIO0's from usersspace but the value is not changed.

I can able to change the direction to out.


The following commands I have tried to toggle the gpio.

root@am64xx-evm:~# cat /sys/class/gpio/gpio384/value 
1
root@am64xx-evm:~# echo 0 > /sys/class/gpio/gpio384/value                                                                                      

root@am64xx-evm:~# cat /sys/class/gpio/gpio384/value 
1


Is anything I have missed ? any suggestion and help would be appreciated.

  • Hi Karthick,

    Which GPIO pin is this gpio384 for? Did you set its pinmux in kernel device tree? If so, please share the code change.

  • Hi Bin,

    Thanks for your response. I want to toggle GPIO0_8, GPIO0_71, GPIO0_72 and GPIO1_17

    For me,

    gpiochip3: GPIOs 376-462, parent: platform/600000.gpio, 600000.gpio: --> GPIO0

    gpiochip4: GPIOs 288-375, parent: platform/601000.gpio, 601000.gpio: --> GPIO1

    So, For GPIO0_8 is 384 (376+8). But when I try to toggle the value is not changed.



    I have appiled the patches as mentioned below in k3-am642-evm.dts and tried.

    diff --git a/arch/arm64/boot/dts/ti/k3-am642-evm.dts b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
    index 2bd50d4bb..57d0412d9 100644
    --- a/arch/arm64/boot/dts/ti/k3-am642-evm.dts
    +++ b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
    @@ -463,6 +463,21 @@
    AM64X_IOPAD(0x0270, PIN_INPUT, 0) /* (D18) ECAP0_IN_APWM_OUT */
    >;
    };
    +
    + mygpio0_pins_default: mygpio0_pins_default {
    + pinctrl-single,pins = <
    + AM64X_IOPAD(0x0020, PIN_OUTPUT, 7) /* (P20) GPIO0_8 */
    + AM64X_IOPAD(0x0120, PIN_OUTPUT, 7) /* (U11) GPIO0_71 */
    + AM64X_IOPAD(0x0124, PIN_OUTPUT, 7) /* (V15) GPIO0_72 */
    + >;
    + };
    +
    + mygpio1_pins_default: mygpio1_pins_default {
    + pinctrl-single,pins = <
    + AM64X_IOPAD(0x01a4, PIN_OUTPUT, 7) /* (U1) GPIO1_17 */
    + AM64X_IOPAD(0x01fc, PIN_OUTPUT, 7) /* (R2) GPIO1_39 */
    + >;
    + };

    Still i cannot toggle, Am I missing anything ? 

    Is mygpio0_pins_default  and  mygpio1_pins_default  is need to refer somwhere ?

    Can you suggest what needs to be done for ? 

  • Hi Karthick,

    Is mygpio0_pins_default  and  mygpio1_pins_default  is need to refer somwhere ?

    Yes. One solution is to reference them in the beginning of the &main_pmx0 node.

    If you want to use Linux 'cat /sys/...' command to read the pin value, you need to use "PIN_INPUT" instead of "PIN_OUTPUT" in the pinmux settings. "PIN_INPUT" enables the GPIO pin input buffer, so that it reflects the output value.

  • Hi Bin,

    I have just added pinmux settings in &main_pmx0 node as mentioned below and tried but getting error duing booting.

    diff --git a/arch/arm64/boot/dts/ti/k3-am642-evm.dts b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
    index 2bd50d4bb..5f9249e8e 100644
    --- a/arch/arm64/boot/dts/ti/k3-am642-evm.dts
    +++ b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
    @@ -314,6 +314,11 @@
    &main_pmx0 {
    main_mmc1_pins_default: main-mmc1-pins-default {
    pinctrl-single,pins = <
    + AM64X_IOPAD(0x0020, PIN_INPUT, 7) /* (P20) GPIO0_8 */
    + AM64X_IOPAD(0x0120, PIN_INPUT, 7) /* (U11) GPIO0_71 */
    + AM64X_IOPAD(0x0124, PIN_INPUT, 7) /* (V15) GPIO0_72 */
    + AM64X_IOPAD(0x01a4, PIN_INPUT, 7) /* (U1) GPIO1_17 */
    + AM64X_IOPAD(0x01fc, PIN_INPUT, 7) /* (R2) GPIO1_39 */
    AM64X_IOPAD(0x0294, PIN_INPUT_PULLUP, 0) /* (J19) MMC1_CMD */
    AM64X_IOPAD(0x028c, PIN_INPUT_PULLDOWN, 0) /* (L20) MMC1_CLK */
    AM64X_IOPAD(0x0288, PIN_INPUT_PULLUP, 0) /* (K21) MMC1_DAT0 */
    @@ -463,6 +468,21 @@

    Boot log : 
    [ 1.613703] pinctrl-single f4000.pinctrl: pin-8 (fa00000.mmc) status -22
    [ 1.623660] pinctrl-single f4000.pinctrl: could not request pin 8 (PIN8) from group main-mmc1-pins-default on device pinctrl-single

    Providing sample patch for apply pimux settings for MAIN GPIO0 and GPIO1 would be helpful.

  • + AM64X_IOPAD(0x0020, PIN_INPUT, 7) /* (P20) GPIO0_8 */

    This pin is already defined in ospi0_pins_default. You cannot redefine it again without removing it from the OSPI pinmux.

  • Thanks Bin. Now I can able to toggle AM64x GPIO's.

    Also, Can you suggest for toggling MCU_GPIO0_5 and read MCU_PORz (B21). 

    I have followed this ticket : https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1023570/am6442-how-to-find-the-mcu-gpio-number-when-using-the-gpio-pin-in-linux

    I can see that the gpio is being listed. Also I have applied u-boot patches for unlock padconf registers and DT patch. 

    But I can't toggle MCU_GPIO0_5.

    + mymcu_gpio0_pins_default: mymcu_gpio0_pins_default {
    + pinctrl-single,pins = <
    + AM64X_MCU_IOPAD(0x0014, PIN_INPUT, 7) /* (A7) */
    + AM64X_MCU_IOPAD(0x005c, PIN_INPUT, 0) /* (B21) */
    + >;
    + };

    Where I need to add this in k3-am642-evm.dts ? Can we able to read MCU_PORz(B21) pin and how ?

  • Hi Karthick,

    For using MCU GPIOs in Linux, please apply the following kernel device tree patch. This is fixed in SDK 9.0.

    diff --git a/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi b/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi
    index 09a668af9fd3..41ddb5b70384 100644
    --- a/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi
    +++ b/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi
    @@ -86,7 +86,7 @@ mcu_gpio_intr: interrupt-controller1 {
            };
     
            mcu_gpio0: gpio@4201000 {
    -               compatible = "ti,am64-gpio", "keystone-gpio";
    +               compatible = "ti,am64-gpio", "ti,keystone-gpio";
                    reg = <0x0 0x4201000 0x0 0x100>;
                    gpio-controller;
                    #gpio-cells = <2>;

  • Hi Bin,

    I have applied the below patches in k3-am642-evm.dts. GPIO is working fine. But Ethernet PHY device not loaded(eth0 interface). Without these changes eth0 is up.

    Can you suggest what is the reason for this and how can work both at a time ?

    &main_pmx0 {
    main_mmc1_pins_default: main-mmc1-pins-default {
    pinctrl-single,pins = <
    + AM64X_IOPAD(0x0020, PIN_INPUT, 7) /* (P20) */
    + AM64X_IOPAD(0x0120, PIN_INPUT, 7) /* (U11) */
    + AM64X_IOPAD(0x0124, PIN_INPUT, 7) /* (V15) */
    + AM64X_IOPAD(0x01a4, PIN_INPUT, 7) /* (U1) */
    + AM64X_IOPAD(0x01fc, PIN_INPUT, 7) /* (R2) */
    + AM64X_IOPAD(0x0154, PIN_INPUT, 7) /* (V12) */
    + AM64X_IOPAD(0x0140, PIN_INPUT, 7) /* (AA11) */

    root@am64xx-evm:~# ip link
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
    link/ether 34:08:e1:80:b4:cc brd ff:ff:ff:ff:ff:ff
    3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
    link/ether e6:12:41:7b:af:91 brd ff:ff:ff:ff:ff:ff
    4: can0: <NOARP40000> mtu 16 qdisc noop qlen 10
    link/[280]
    5: can1: <NOARP40000> mtu 16 qdisc noop qlen 10
    link/[280]
    6: eth2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq qlen 1000
    link/ether 06:c9:65:74:e6:88 brd ff:ff:ff:ff:ff:ff
    root@am64xx-evm:~#
    root@am64xx-evm:~#
    root@am64xx-evm:~# ifconfig eth0 192.168.10.2 up
    ifconfig: SIOCSIFFLAGS: No such device

  • Hey Karthick,

    This appears to be because you've changed the main-mmc1-pins-default pinctrl to use IOPADs that are normally reserved for both of the RGMII.

    For pins and their supported MUX modes please refer to the Pin Attribute table in the device datasheet: www.ti.com/.../am6412.pdf

    Regards,

    Randolph

  • Hi Randolph 

    we need to access the gpio pins like GPIO0_8(P20),GPIO0_71(U11),GPIO0_72(V15),GPIO0_79(AA11),GPIO0_84(V12),GPIO1_17(U1),GPIO1_39(R2) ,need to toggle these pins for some cases,so we put device tree entry  for these pins,while changing in device tree already these pins are confgiured in other nodes, so we removed that.

    The issue we are facing now,after made a changes in device tree we are able to toggle those pins,but 1G interface is not working

    Can you please suggest some steps ?

  • Hi Uthaya,

    + AM64X_IOPAD(0x0120, PIN_OUTPUT, 7) /* (U11) GPIO0_71 */
    + AM64X_IOPAD(0x0124, PIN_OUTPUT, 7) /* (V15) GPIO0_72 */

    These pins are needed in rgmii2_pins_default and rgmii1_pins_default nodes for RGMII2_RXC and RGMII1_TD0 signals respectively. I am not a network expert but I don't think the network interface will work if these signals are not connected.

    To keep the network interfaces working, you won't be able to use these pins in GPIO mode.