I'm working on a custom board that has several GPIO pins that I would like be able to read and write from user space.
I'm having trouble configuring a pin as a generic output.
I can do it via the gpio-led driver and the device tree like so:
am33xx_pinmux: pinmux@44e10800 { pinctrl-names = "default"; pinctrl-0 = <&system_ctrl &board_id &ac_pwr_supply_status &ir_remote_in &panel_pwr_ctrl &clkout2_pin>; status_leds: status_leds { pinctrl-single,pins = < /* Stand By LEDs */ 0xC8 (PIN_OUTPUT | MUX_MODE7) /* STBY_LED_ENA_0: U3 lcd_data10.gpio2_16 */ 0xCC (PIN_OUTPUT | MUX_MODE7) /* STBY_LED_ENA_1: U4 lcd_data11.gpio2_17 */ /* DEV LEDs */ 0xAC (PIN_OUTPUT | MUX_MODE7) /* LED_0: R4 lcd_data3.gpio2_9 */ 0xA8 (PIN_OUTPUT | MUX_MODE7) /* LED_1: R3 lcd_data2.gpio2_8 */ 0xA4 (PIN_OUTPUT | MUX_MODE7) /* LED_2: R2 lcd_data1.gpio2_7 */ 0xA0 (PIN_OUTPUT | MUX_MODE7) /* LED_3: R2 lcd_data0.gpio2_6 */ /* System communications enable/isolation, set to high to disable * most of the dock, Mstar, i2c, uart, gpio interfaces. */ 0x88 (PIN_OUTPUT | MUX_MODE7) /* UART_GATE_ENA: T13 gpmc_csn3.gpio2_0 */ >; }; ... ocp { /**/ gpio_leds: status_leds@0{ compatible = "gpio-leds"; pinctrl-names = "default"; pinctrl-0 = <&status_leds>;
...
sys-com-en { label = "sys-com-en"; gpios = <&gpio2 0 GPIO_ACTIVE_LOW>; default-sate = "off"; }; }; /*end gpio_leds*/
I can then change the state of sys-com-en from user space via the command:
$echo "1" > /sys/class/leds/sys-con-en/brightness
However this pin is not an LED and it seems like I should be able set it up as a more generic GPIO that is exported under /sys/class/gpio but I can't get it to work, I must be missing something in the device tree.
I've tried putting the pin in it's own group in the pinmux@44e10800 part of the tree and then exporting it via:
$ echo "34" > /sys/class/gpio/export
The pin gets exported I don't appear to have any control over the physical state of the pin. It seems like I'm missing something in the ocp section of the device tree. I've seen plenty of examples of how to do this with device tree overlays using the cape manager and the bone-pinmux-helper but I don't intend to use overlays or the cape manager
Any enlightenment here would be very much appreciated.
Thanks,
Matt S.