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.

How GPIO input buttons read through sys file and updating in Device tree in SDK 7(3.12)

Hi all,

I am currently using SDK 7.00 for am335x custom board, I am trying to read the value of an input. I am using kernel 3.12 kernel. The only way I have found is to manually export the gpio and then read the value but i want read gpio buttons through sys. here i am using pre defined gpio drive gpio_keys.c. find the device tree bellow...
              

gpio_keys_s0: gpio_keys_s0 {
                        pinctrl-single,pins = <
                                0x2c (PIN_INPUT_PULLUP | MUX_MODE7)   /*key_init GPIO0_27 */
                                0x20 (PIN_INPUT_PULLUP | MUX_MODE7)   /* Alaram_key GPIO0_22 */
                                0x28 (PIN_INPUT_PULLUP | MUX_MODE7)   /* Cancel_key GPIO0_26----  0x28 */
                                0x24 (PIN_INPUT_PULLUP | MUX_MODE7)   /* Away_key GPIO0_23 */
                        >;
                };


     gpio_buttons: gpio_buttons@0 {
                           compatible = "gpio-keys";
                 pinctrl-names = "default";
                pinctrl-0 = <&gpio_keys_s0>;
                #address-cells = <1>;
                #size-cells = <0>;

                switch@1 {
                        label = "key_init";
                        debounce_interval = <50>;
                        linux,code = <100>;
                        gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>;
                         gpio-key,wakeup;
                };

                switch@2 {
                        label = "Alaram_key";
                        linux,code = <0x102>;
                        gpios = <&gpio0 22 GPIO_ACTIVE_HIGH>;
                };

                switch@3 {
                        label = "Cancel_key";
                        linux,code = <0x103>;
                        gpios = <&gpio0 26 GPIO_ACTIVE_HIGH>;
                        gpio-key,wakeup;
                };

                switch@4 {
                        label = "Away_key";
                        linux,code = <0x108>;
                        gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>;
                };
        };

I can see the the events occur in /dev/input/event0.

root@am335x-evm:/dev/input# cat event1
▒Dm8▒R
     ▒Dm8▒R
           ▒Dm8'S
                 ▒Dm8'S
                       ▒Dm8=

The problem is I need to read the value and not trigger off of an interrupt. but i want read the value through sys file like leds output root@am335x-evm:/sys/class/leds/beaglebone:green:usr3#
root@am335x-evm:/sys/class/leds/beaglebone:green:usr3# echo 1 >brightness

root@am335x-evm:/sys/class/leds/beaglebone:green:usr3# cat brightness
1

please help me how to read input gpio data as we as how to export gpio buttons attributes to sys directory

Thankas & Regards

shankar