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.

AM5728: sysfs gpio not working

Part Number: AM5728

I am using a base arago image. I can twiddle the gpio's using memory mapped io and it all works as expected.

However, When I try to use /sys/class/gpio/gpioX I get no results. For example, I export all gpios for bank 2 (64-95), configure them as outputs. I set all the values to 1 and I get NO change in the measured output pin. This fails no matter which bank or pins I try.

Does anyone have an idea what I am doing wrong?

thanks,

pat

  • Hi Pat,

    The first thing I doubt is the pinmux settings for GPIO. This is configured at the U-Boot stage in the file: board/ti/am57xx/mux_data.h

    Also when you say 

    I can twiddle the gpio's using memory mapped io and it all works as expected.

    With just the direct writes are you able to toggle the GPIOs and see that on the scope without having to configure the pinmux?

    - Keerthy

  • I'll try to attach a copy of our mux_data.h file.

    I have only tested with an image built using that mux data. But I can see the inputs and outputs on the scope in the expected state
    when I read/write directly to them.

    For an explicit example, I setup a small echo program to read input 2_3 and write to output 2_28. With polled memmapped io
    I see the input change and write the output. All verified on the scope.

    But when I export pins 67 and 92 in sysfs which and read/write those values I get NO change on the scope.

    Just FYI, Here is the output from 'cat /sys/kernel/debug/gpio'

    root@am57xx-evm:/sys/class/gpio# cat /sys/kernel/debug/gpio
    gpiochip0: GPIOs 0-31, parent: platform/4ae10000.gpio, gpio-0-31:

    gpiochip1: GPIOs 32-63, parent: platform/48055000.gpio, gpio-32-63:
    gpio-40 ( |51000000.pcie ) out lo
    gpio-62 ( |encoder ) out hi

    gpiochip2: GPIOs 64-95, parent: platform/48057000.gpio, gpio-64-95:
    gpio-67 ( |sysfs ) in lo IRQ
    gpio-92 ( |sysfs ) in lo

    gpiochip3: GPIOs 96-127, parent: platform/48059000.gpio, gpio-96-127:
    gpio-117 ( |vbus ) in lo IRQ

    gpiochip4: GPIOs 128-159, parent: platform/4805b000.gpio, gpio-128-159:

    gpiochip5: GPIOs 160-191, parent: platform/4805d000.gpio, gpio-160-191:
    gpio-187 ( |cd ) in lo IRQ

    gpiochip6: GPIOs 192-223, parent: platform/48051000.gpio, gpio-192-223:
    gpio-200 ( |beagle-x15:usr1 ) out hi
    gpio-201 ( |beagle-x15:usr0 ) out lo
    gpio-202 ( |encoder ) out hi
    gpio-203 ( |vtt_fixed ) out hi
    gpio-204 ( |encoder ) in lo IRQ
    gpio-206 ( |beagle-x15:usr2 ) out lo
    gpio-207 ( |beagle-x15:usr3 ) out lo

    gpiochip7: GPIOs 224-255, parent: platform/48053000.gpio, gpio-224-255:

    gpiochip8: GPIOs 504-511, parent: platform/48070000.i2c:tps659038@58:tps659038_gpio, 48070000.i2c:tps659038@58:tps659038_gpio, can sleep:
    gpio-506 ( |gpio_fan ) out hi

    7571.mux_data.h

  • Hi Pat,

    Can you dump the GPIO2 Module registers when you do it via sysfs?

    Also does the sysfs nodes show that the direction & levels are fine?

    I mean:

    cat /sys/class/gpio/gpio'x'/direction
    cat /sys/class/gpio/gpio'x'/value.

    Best Regards,
    Keerthy

  • Hi Keerthy,

    I think I found the main culprit for my initial problems. It seems the numbering of the pins for sysfs drop the first 32. For pin 2_3 I was exporting 67 (2 * 32 + 3) when I should have been exporting 35 (1 * 32 + 3). With pin 35 exported and rising edge interrupts setup, I can see input values (/sys/class/gpio/gpio35/value) change when I put 3.3 on that pin. 

    Is this assumption correct? What do I do if I need to get to the first 32 pins? ( I don't think I need to right now, just curious).

    thanks,

    pat

  • Hi Pat,

    GPIO numbering starts from 1 & NOT 0.

    So your assumption is right.

    If no other questions please click on verify answer.

    - Keerthy