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.

Can't control GPIO pins on an AM437x EVM

Hi all,

I can't seem to control the GPIO pins on header J30 using the sysfs control following the Linux PSP GPIO Driver Guide.

I'm trying to control pin 5 on header J30, which is according to the schematics connected to LED D12 on the board.

following the documentation:

  • - J30-5 is connected to L23 on the AM437x MPU via signal "AM437X_STATUS_LED0" ( Am437x_gp_evm_3k0006_schematic_rev1_4a.pdf - sheet 23 & 24).
  • - L23  has the signal name "mcasp0_aclkr" within the datasheet "AM437x Sitara Processors (Rev. B)" (table 4-11).
  • - mcasp0_aclkr has an offset of 0x9A0 ( 0x800 + 0x1A0 )according to "AM437x ARM Cortex-A9 Processors (Rev. D)" (table 7-11).

Looking at the DTS file "am437x-gp-evm.dts" for the offset of 0x1A0 I found this.

	unused_pins: unused_pins {
		pinctrl-single,pins = <
			0x54	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x58	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x60	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x64	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x68	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x6C	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x80	(PIN_INPUT_PULLDOWN | MUX_MODE7) /* gpmc_csn1.mmc1_clk */
			0x84	(PIN_INPUT | PULL_DISABLE | MUX_MODE7) /* gpmc_csn2.mmc1_cmd */
			0x150	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x190	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x194	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x198	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x19C	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x1A0	(PIN_INPUT_PULLDOWN | MUX_MODE7)                  /* j30-5  
			0x23C	(PIN_INPUT | PULL_DISABLE | MUX_MODE7)
			0x240	(PIN_INPUT_PULLDOWN | MUX_MODE7)                  /* j30-31
			0x244	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x248	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x24C	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x250	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x254	(PIN_INPUT | PULL_DISABLE | MUX_MODE7)
			0x258	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x260	(PIN_INPUT | PULL_DISABLE | MUX_MODE7)
			0x268	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x270	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x278	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x27C	(PIN_INPUT | PULL_DISABLE)
			0x2C8	(PIN_INPUT_PULLDOWN)
			0x2D4	(PIN_INPUT_PULLDOWN)
			0x2D8	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x2DC	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x2E0	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x2E4	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x2E8	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x2EC	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x2F0	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x2F4	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x2F8	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x2FC	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x300	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x304	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x308	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x30C	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x310	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x314	(PIN_INPUT_PULLDOWN | MUX_MODE7)
			0x318	(PIN_INPUT_PULLDOWN | MUX_MODE7)
		>;
	};

I assume that pin L23 is in mode 7, which should give me that it is used as GPIO3_18 ( gpio0_18 = mode 9).

linux pin number should then be 3*32 + 18 = 114

executing following commands:

$ echo 114 > /sys/class/gpio/export
$ cat /sys/class/gpio/gpio114/direction
in
$ cat /sys/class/gpio/gpio114/value
0
$ echo "out" > /sys/class/gpio/gpio114/direction

$ echo 1 > /sys/class/gpio/gpio114/value

Nothing on pin J30-3 or the LED, no voltage, no light, no dmesg entry.
I tried the same thing with gpio0_18 (mode 9), but nothing.

This goes for all the pins that I can export, I cant seem to export anything above pin 159

$ echo 160 > /sys/class/gpio/export /* gpio5_0 */
export_store: invalid GPIO 160
$ echo 170 > /sys/class/gpio/export             /* gpio5_10  pin J30-31 connected to LED D9 */
export_store: invalid GPIO 170

I know i'm new to TI and linux but I'm at a loss any help or direction would be greatly appreciated.

Khasyk

  • I will ask the software team to look at this.
  • Biser,

    Thank you.

    Khasyk

  • Hi,

    Have you tried removing this pin from the unused_pins node & then try sysfs entries?

    Best Regards,
    Yordan
  • Yordan,

    I need to read up on the device tree syntax to create a single entry for this LED and will let your know, but simply removing them from the unused_pins node didn't help. I removed pin 114 and pin 160 (linux) which gave me the same invalid argument error for pin 160 as before.

    $ cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pins        shows

    pin 114 (44e109c8.0)  00060000 pinctrl-single

    pin 160 (44e10a80.0) 00050000 pinctrl-single

    $ cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pingroups

    shows that they are indeed removed from the group unused_pins group.

    After reading up on the device tree syntax and create an entry for these pins I will come back.

    Khasyk

  • Hi,

    Can try:

    gpio3_pins: gpio3_pins {
    pinctrl-single,pins = <
    0x1A0 (PIN_INPUT_PULLUP | MUX_MODE7)
    >;
    };

    &gpio3 {
    pinctrl-names = "default";
    pinctrl-0 = <& gpio3_pins>;
    status = "okay";
    };

    Best Regards,
    Yordan
  • Yordan,

    What i did:

    I entered the lines

        gpio3_pins: gpio3_pins {
            pinctrl-single,pins = <
                0x1A0 (PIN_OUTPUT | MUX_MODE7)
            >;
        };

    just under the gpio0_pins: gpio0_pins @ line 574 of the am437x-gp-evm.dts file and changed the already existing ( prox. line 920)

    &gpio3 {
        pinctrl-names = "default";
     };

    to

    &gpio3 {
        pinctrl-names = "default";
        pinctrl-0 = <&gpio3_pins>;
        status = "okay";
    };

    And indeed this is now working with sysfs, but what I found in the pingroups was telling me something different.

    $ cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pingroups | more

    group: gpio3_pins
    pin 104 (44e109a0.0)

    group: vpfe0_pins_default
    pin 108 (44e109b0.0)
    pin 109 (44e109b4.0)
    pin 112 (44e109c0.0)
    pin 113 (44e109c4.0)
    pin 114 (44e109c8.0)                  <------
    pin 130 (44e10a08.0)
    pin 131 (44e10a0c.0)
    pin 132 (44e10a10.0)
    pin 133 (44e10a14.0)
    pin 134 (44e10a18.0)
    pin 135 (44e10a1c.0)
    pin 136 (44e10a20.0)
    pin 137 (44e10a24.0)

    group: vpfe0_pins_sleep
    pin 108 (44e109b0.0)
    pin 109 (44e109b4.0)
    pin 112 (44e109c0.0)
    pin 113 (44e109c4.0)
    pin 114 (44e109c8.0)                  <------
    pin 130 (44e10a08.0)
    pin 131 (44e10a0c.0)
    pin 132 (44e10a10.0)
    pin 133 (44e10a14.0)
    pin 134 (44e10a18.0)
    pin 135 (44e10a1c.0)
    pin 136 (44e10a20.0)
    pin 137 (44e10a24.0)

    This makes me believe there is no correlation between the pin numbers shown in these files and what is calculated but rather there register address or am I mistaken in that?
    Because the sysfs instruction where made on gpio114 which seems to work ( LED blinked :D) and gpio104 did nothing I could see or probe.

    Many thanks,

    Khasyk

  • Clearly im missing something, while gpio114 works like a charm. Using any other pin which are used by the switches gpio4_2, gpio4_3 and gpio4_12 are non responsive to any form of manipulation. I removed the DTS entry for the matrix keypad and made a new entry like the gpio3_pins from before. They show up in the pingroups and are able to export, but reading or writing the value does nothing at all.

    I searched the DTS and all included files for either "gpio4" , offset address, full address, every line but there is no other reference to these pins within the DTS files.

    Is there a way to find out which pins are in used by any part of the kernel?