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.

Linux/AM3352: GPIO configuration in device tree

Part Number: AM3352

Tool/software: Linux

We are beaglebone black based custom board with 256MB RAM and 512MB DDR.

We are using Linux kernel 3.12.

I was trying to configure three gpios as input in devicetree.

I want to achieve two things.

1. Configure(mux) GPIOs as input with PULLUP from devicetree

2. Get sysfs files for those GPIOs in sysfs so no need to export GPIOs but directly read the values.

Below devicetree snnipet I have used to configure pinmux,

am33xx_pinmux: pinmux@44e10800 {
		pinctrl-names = "default";

---------------cut-----------------------------


        product_id_pins: product_id_pins{
            pinctrl-single,pins = <
                    0x028 (PIN_INPUT_PULLUP | MUX_MODE7)  /* gpmc_ad10.gpio0_26, (ZCE) */
                    0x034 (PIN_INPUT_PULLUP | MUX_MODE7)  /* gpmc_ad13.gpio1_13, (ZCE) */
                    0x024 (PIN_INPUT_PULLUP | MUX_MODE7)  /* gpmc_ad12.gpio1_12, (ZCE), */
            >;
        };
};


pid {

            pinctrl-names = "default";
            pinctrl-0 = <&product_id_pins>;
};

With this I need to write following shell command to read those GPIOs

# echo 26 > /sys/class/gpio/export
# echo 44 > /sys/class/gpio/export
# echo 45 > /sys/class/gpio/export

# cat /sys/class/gpio/gpio26/value 
0

# cat /sys//class/gpio/gpio44/value 
0

# cat /sys//class/gpio/gpio45/value 
0

Now nothing is connected on these GPIO pins, so value must be read high but values are low.

other sysfs entries read following

# grep -r . /sys/class/gpio/gpio26/
/sys/class/gpio/gpio26/edge:none
/sys/class/gpio/gpio26/power/control:auto
/sys/class/gpio/gpio26/power/runtime_active_time:0
/sys/class/gpio/gpio26/power/runtime_status:unsupported
/sys/class/gpio/gpio26/power/runtime_suspended_time:0
/sys/class/gpio/gpio26/value:0
/sys/class/gpio/gpio26/active_low:0
/sys/class/gpio/gpio26/direction:in

# grep -r . /sys/class/gpio/gpio44/
/sys/class/gpio/gpio44/edge:none
/sys/class/gpio/gpio44/power/control:auto
/sys/class/gpio/gpio44/power/runtime_active_time:0
/sys/class/gpio/gpio44/power/runtime_status:unsupported
/sys/class/gpio/gpio44/power/runtime_suspended_time:0
/sys/class/gpio/gpio44/value:0
/sys/class/gpio/gpio44/active_low:0
/sys/class/gpio/gpio44/direction:in

# grep -r . /sys/class/gpio/gpio45/
/sys/class/gpio/gpio45/edge:none
/sys/class/gpio/gpio45/power/control:auto
/sys/class/gpio/gpio45/power/runtime_active_time:0
/sys/class/gpio/gpio45/power/runtime_status:unsupported
/sys/class/gpio/gpio45/power/runtime_suspended_time:0
/sys/class/gpio/gpio45/value:0
/sys/class/gpio/gpio45/active_low:0
/sys/class/gpio/gpio45/direction:in

It has something to do with devicetree configuration.

Can someone suggest which client device I should configure in devicetree for those GPIOs ?

Thank you,

Regards,

Ankur

  • The software team have been notified. They will respond here.
  • Hello,

    once you have configured the pinumx as input, It should be by default configured as input. what is the value of direction (# cat /sys/class/gpio/gpio26/direction), now if you apply some current do you see value changing to 1 ?

    Cheers,
    --Prabhakar Lad
  • Thank you for reply Prabhakar,
    I have copied all the sysfs parameter above,

    /sys/class/gpio/gpio26/direction reads "in"

    Moreover I read the 0x44e10828(gpmc_ad10-gpio0_26) register's value using omapconf , it reads ox27 (receiver enabled and mode 7) But what I need is ox37( receiver enabled, input and mode7).

    So it is configured as input but I also need the input pullup to be enabled which is not getting enabled.

    If I do pinmuxing from u-boot that works but with the current stage of development we won't be able to update bootloader in the field.

    Thank you,

    Regards,
    Ankur
  • With some modification I am able to get pinmux right.

    am33xx_pinmux: pinmux@44e10800 {
    	pinctrl-names = "default";
    
    ----------------CUT---------------
    
            product_id_pins: product_id_pins{
                pinctrl-single,pins = <
                        0x028 (INPUT_EN | PULL_UP | MUX_MODE7 )  /* gpmc_ad10.gpio0_26, BGA T12 (ZCE) */
                        0x034 (INPUT_EN | PULL_UP | MUX_MODE7 )  /* gpmc_ad13.gpio1_13, BGA T13 (ZCE) */
                        0x030 (INPUT_EN | PULL_UP | MUX_MODE7 )  /* gpmc_ad12.gpio1_12, BGA U13 (ZCE), TP39 */
                >;
            };
    };
    
    pid {
    
                pinctrl-names = "default";
                pinctrl-0 = <&product_id_pins>;
    			compatible = "gpio-leds";
    };
    

    With These changes I have to use following commands to read gpios,

    echo 26 > /sys/class/gpio/export
    echo 44 > /sys/class/gpio/export
    echo 45 > /sys/class/gpio/export
    
    cat /sys/class/gpio/gpio26/value
    cat /sys/class/gpio/gpio44/value
    cat /sys/class/gpio/gpio45/value

    I have used compatible driver as "gpio-leds" which is not right.

    And I wanted to create node for each gpio so that I can read gpio without exporting them.

    Any suggestions ?

  • Hi Ankur,

    Here are some useful resources about GPIO configuring and management:
    processors.wiki.ti.com/index.php
    processors.wiki.ti.com/.../Processor_SDK_Linux_GPIO_Driver_Overview
    www.kernel.org/.../sysfs.txt

    BR
    Tsvetolin Shulev
  • Hi Tsvetolin Shulev,

    Thank you for reply,
    I have referred the documents which you pointed me too,
    From that I conclude that I can't create custom nodes for gpio like /sys/class/gpio/pid1 (controlling gpio26), /sys/class/gpio/pid2(controlling gpio44) etc .
    I have to export gpio by its number and use it as i have mentioned above.
    Is my understanding correct ?

    Thank you,

    Regards,
    Ankur
  • Yes, your understanding is correct.

    BR
    Tsvetolin Shulev
  • Can we not configure them as gpio-keys ?

    I tried but running into

    [ 0.423595] gpio-keys gpio_keys: Button without keycode: 0x1a
    [ 0.423638] gpio-keys: probe of gpio_keys failed with error -22

    Thank you,

    Regards,
    Ankur