GPIO input not working

I have a BBB (running Ubuntu) connected to a custom cape which uses some GPIO pins for input and output. The output pins work as expected without any extra configuration, I’m just exporting the required pins in the /sys/class/gpio folder, setting the direction, and writing values.

One of the GPIOs (specifically GPIO1_15) is connected to a button, which when pushed I want to shut down the BBB. I export the pin the same way I do the outputs, set the direction, and try reading the value. The value is always read as 0, regardless of whether the button is pressed or not. Is there any extra configuration needed for using GPIO inputs?

Looking at the pinmux for this pin in /sys/kernel/debug/pinctrl/44e10800.pinmux I get:

pin 15 (44e1083c) 00000027 pinctrl-single

which I take to mean that this pin is already configured for GPIO. I did a device tree overlay for that pin only for testing purposes, setting it to 0x07. The pinmux changed, but it still behaved the same way. The tree overlay I tried:

`
/dts-v1/;
/plugin/;

/ {
compatible = “ti,beaglebone”, “ti,beaglebone-black”;

/* identification */
part-number = “bb-gpio”;
version = “00A0”;

exclusive-use =
/* the pin header uses /
“P8.15”, /
GPIO1_15 /
/
the hardware ip uses */
“GPIO1_15”;

fragment@0 {
target = <&am33xx_pinmux>;
overlay {
bb_GPIO1_15_pins: pinmux_bb_GPIO1_15_pins {
pinctrl-single,pins = <
0x03c 0x07

;
};
};
};
fragment@1 {
target = <&ocp>;
overlay {
/* avoid stupid warning */
#address-cells = <1>;
#size-cells = <1>;

gpio1_15_test {
compatible = “bone-pinmux-helper”;
pinctrl-names = “default”;
pinctrl-0 = <&bb_GPIO1_15_pins>;
status = “okay”;
};
};
};
};

`

We tested the cape without a BBB attached and the button sent a signal when pushed as expected. Any ideas on what is going wrong?

Thanks

Check the last page of the schematic. P8.15 is inside the bracket labeled “Caution: Used On Board”. If I could find my old post I’d confirm it was that pin but I ran into something similar where some pins were pulled one way or the other in hardware and my circuit could not use the pin. It was definitely one on that header. Have you looked at the voltage on that pin when your cape is installed?

"P8.15", /* GPIO1_15 */

Hi,
While on the schematic GPIO1_15 is inside the bracket labeled “Caution: Used On Board”, actually it (P8.15) is not connected anywhere but to the processor pad. That is actually NOT used on board.
I verified this many times: no troubles with GPIO1_15.
I do not think that setting pinmux to 0x07 is a good idea. If you want to read the GPIO you need the respective receiver enabled. The 0x27 pinmux data is much better.
What else… If you often want to see what the actual pinmux settings are, or what is the GPIO state, this might be handy:
http://www.academ.org/~sv/epc/pinmux.pdf