AM335x: how to mux a pin for libgpiod to use?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am trying to determine an upstream method to be able to mux an AM3358
pin to gpio and then allow that line to be used from the gpiod userspace
ABI.  A "pinctrl-single,pins" device tree property can easily define a
gpio mux for a given pin.  For example, the P9_14 pin on the BeagleBone
[0] can be set to gpio (mode 7) with this node:

P9_14_gpio_pin: pinmux_P9_14_gpio_pin {
	pinctrl-single,pins = <
	AM33XX_PADCONF(AM335X_PIN_GPMC_A2, PIN_INPUT_PULLDOWN, MUX_MODE7)
	>;
};

GPMC_A2 is gpio1_18 per the AM3358 datasheet [1].  Normally, a node for
a driver, like gpio-keys, would have a gpio property that cause the
driver to claim the gpio line.  But, in that case, the line will not be
available to be used through the gpiod userspace ABI.

If no driver claims the gpio line, then I find that the pin mux in
"pinctrl-single,pins" does not get applied by the pinctrl-single driver.

Thus, I can't figure out how to mux a pin to gpio and then use that gpio
line from userspace.  The natural question is why try access a gpio line
from userspace.  BeagleBone users do want this capability for prototyping
and I believe that is an accepted use case based on what Linus Walleij
wrote in "Using GPIO Lines in Linux" [2].

The kernel used in our BeagleBoard.org Debian images has an out-of-tree
driver [3] named gpio-of-helper will claim the gpio line but a hack [4]
allows the line to still be controlled through the gpiod userspace ABI.
This does not seem to be an acceptable upstream solution, so I am trying
to figure out what an upstream solution would look like.

Maybe one soltion would be to make pinctrl-single set the mux for any
"pinctrl-single,pins" properties regardless of whether a driver
references it or not.  Thus, the pin would be muxed to gpio by
pinctrl-single and libgpiod would be able to use the line as it was not
claimed by any driver.

I would very much appreciate any feedback.

Thanks,
Drew

[0] https://git.io/JfjYH
[1] http://www.ti.com/lit/ds/symlink/am3358.pdf
[2] Documentation/driver-api/gpio/using-gpio.rst
[3] https://git.io/JfjYf
[4] https://git.io/JfjYJ



[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux