Re: gpio-omap: handle bias flag for gpio line

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

 



On Tue, Jul 07, 2020 at 02:38:36PM +0200, Linus Walleij wrote:
> On Thu, Jun 25, 2020 at 2:27 AM Drew Fustini <drew@xxxxxxxxxxxxxxx> wrote:
> 
> > Tony and Linus -
> >
> > I'm hoping you could give me some feedback on this approach. My goal is
> > to allow a userspace library (like libgpiod) to be able to set pull-up
> > and pull-downs on the AM3358.
> 
> I'm lost on any pinctrl-single specifics, sorry... Generic questions about
> pinctrl I can maybe answer.
> 
> Yours,
> Linus Walleij

I now have a way to set bias with libgpiod on the AM3358 (BeagleBone
and PocketBeagle) with these two patches:

[PATCH] gpio: omap: handle pin config bias flags [0]
------------------------------------------------
Modify omap_gpio_set_config() to handle pin config bias flags by calling
gpiochip_generic_config().

The pin group for the gpio line must have the corresponding pinconf
properties:

PIN_CONFIG_BIAS_PULL_UP requires "pinctrl-single,bias-pullup"
PIN_CONFIG_BIAS_PULL_DOWN requires "pinctrl-single,bias-pulldown

This means the ability to set bias from userspace is controlled from
device tree. If there is concern about potiental damage caused by
userspace setting bias to an unsafe value then those pins should not
have the bias property in the dts.


[PATCH] ARM: dts: am335x-pocketbeagle: set default mux for gpio pins [1]
--------------------------------------------------------------------
These pins on the PocketBeagle P1 and P2 headers are connected to AM3358
balls with gpio lines, and these pins are not used for any other
peripherals by default.  This patch adds "pinctrl-single,bias-pullup"
and "pinctrl-single,bias-pulldown" pinconf properties for each pin per
the ball reset state in the datasheet.

Here is an example for P2.03 header pin on the PocketBeagle:

        /* P2_03 (ZCZ ball T10) gpio0_23 0x824 PIN 9 */
        P2_03_gpio: pinmux_P2_03_gpio {
                pinctrl-single,pins = <
                        AM33XX_PADCONF(AM335X_PIN_GPMC_AD9, PIN_INPUT_PULLUP, MUX_MODE7)
                >;
                pinctrl-single,bias-pullup   =   < 0x10  0x10  0x00  0x18>;
                pinctrl-single,bias-pulldown   = < 0x10  0x00  0x10  0x18>;
        };

P2.03 header pin on PocketBeagle maps to gpiochip 0 line 23. It is PIN9
which value on boot: 0x37 (input [0x20] pull-up [0x10] gpio mode [0x7])

$ cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins |grep ^'pin 9' |head -1
pin 9 (PIN9) 44e10824 00000037 pinctrl-single

$ gpiomon -B pull-down 0 23
^C

Value 0x27 means it switched to pull-down [0x0] but still input [0x20]
and gpio mode [0x7]:

$ cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins |grep ^'pin 9' |head -1
pin 9 (PIN9) 44e10824 00000027 pinctrl-single

Now switch it back to pull-up:

$ gpiomon -B pull-up 0 23
^C

Value 0x37 means it switched to pull-up [0x10] and is still input [0x20]
and gpio mode [0x7]:

$ cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins |grep ^'pin 9' |head -1
pin 9 (PIN9) 44e10824 00000037 pinctrl-single


Question: does this seem like a reasonable solution?

Thanks,
Drew

[0] https://lore.kernel.org/linux-omap/20200712103717.1219765-1-drew@xxxxxxxxxxxxxxx/
[1] https://lore.kernel.org/linux-omap/20200709223401.780051-1-drew@xxxxxxxxxxxxxxx/



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux