linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Drew Fustini <drew@beagleboard.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Tony Lindgren <tony@atomide.com>,
	Linux-OMAP <linux-omap@vger.kernel.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Jason Kridner <jkridner@beagleboard.org>,
	Robert Nelson <robertcnelson@gmail.com>
Subject: Re: gpio-omap: handle bias flag for gpio line
Date: Sun, 12 Jul 2020 23:56:30 +0200	[thread overview]
Message-ID: <20200712215630.GA1298162@x1> (raw)
In-Reply-To: <CACRpkdYze_6cM0R=rr7RF8h5WO4GoCcz4=K1_XLt0PJNxCYtbw@mail.gmail.com>

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@beagleboard.org> 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@beagleboard.org/
[1] https://lore.kernel.org/linux-omap/20200709223401.780051-1-drew@beagleboard.org/

  reply	other threads:[~2020-07-12 21:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-25  0:27 gpio-omap: handle bias flag for gpio line Drew Fustini
2020-07-07 12:38 ` Linus Walleij
2020-07-12 21:56   ` Drew Fustini [this message]
2020-07-13 15:02     ` Tony Lindgren
2020-07-13 17:47       ` Drew Fustini
2020-07-13 18:05         ` Tony Lindgren
2020-07-17  1:42           ` Drew Fustini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200712215630.GA1298162@x1 \
    --to=drew@beagleboard.org \
    --cc=jkridner@beagleboard.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=robertcnelson@gmail.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).