linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Drew Fustini <pdp7pdp7@gmail.com>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [RFC] gpio: expose pull-up/pull-down line flags to userspace
Date: Thu, 10 Oct 2019 19:17:05 +0800	[thread overview]
Message-ID: <20191010111705.GA17666@sol> (raw)
In-Reply-To: <20191010101421.GA14692@sol>

On Thu, Oct 10, 2019 at 06:14:21PM +0800, Kent Gibson wrote:
> On Thu, Oct 10, 2019 at 09:47:35AM +0200, Drew Fustini wrote:
> > On Thu, Oct 10, 2019 at 1:59 AM Kent Gibson <warthog618@gmail.com> wrote:
> > > It is basically working for me on my Pi4:
> > >
> > > pi@quoll:~ $ ./gpiodctl get gpiochip0 7
> > > 0
> > > pi@quoll:~ $ ./gpiodctl get -u gpiochip0 7
> > > 1
> > > pi@quoll:~ $ ./gpiodctl get gpiochip0 7
> > > 1
> > > pi@quoll:~ $ ./gpiodctl get -d gpiochip0 7
> > > 0
> > > pi@quoll:~ $ ./gpiodctl get gpiochip0 7
> > > 0
> > >
> > > That is using the gpiodctl tool from my gpiod library.
> > > My gpiod test suite also passes, but it doesn't do much to
> > > exercise the UAPI.
> > > I was intending to run my uapi test suite, which is more thorough,
> > > but it turns out that only targets gpio-mockup, whereas my gpiod
> > > test suite can target either.
> > > Something else for the todo list.
> > >
> > > Hopefully it is obvious what gpiodctl is doing. (-u sets the
> > > pull-up flag, -d sets the pull-down flag)
> > > Looks like the pulls stick when the line is released, and the
> > > subsequent get, without pull-up set, either doesn't clear the
> > > pull-up/down or the line stays floating at the old pull level.
> > > More investigation required, but that will have to wait til
> > > I get back to this later in the day.
> > >
> > > Oh, and that is running on the rpi-5.3.3 kernel patched with everything
> > > on my topic/gpio-uapi-config branch from 5.4-rc2 onward.
> > 
> > Thanks for sharing your results.
> > 
> > My Pi 3 had been running 5.3.0-v7+ from September 20th with my
> > pull-up/down patch (82fc38f6ab59).
> > 
> > I removed that patch and just cross-compiled 5.4-rc2 with
> > multi_v7_defconfig for the Pi3.
> > 
> > Are these the commits that I should apply from your topic branch?
> > 
> > bdc9696a27ed pull up/down requires explicit input mode in lineevent_create
> > 14ee636232d4 disallow pull up/down on outputs
> > ce03bf5af1ec implement SET_CONFIG_IOCTL
> > f38b7554eb52 pull common validation code into linehandle_validate_flags
> > 31c0aa53ffc3 Add default values for setting output
> > 3c7ec03efcd9 add support for pull up/down to lineevent_create
> > 99b85d1c26ea gpio: add new ioctl() to gpio chardev
> > 82fc38f6ab59 gpio: expose pull-up/pull-down line flags to userspace
> > f6cfbbe2950b gpiolib: sanitize flags before allocating memory in
> > lineevent_create()
> > 
> Those are the ones.
> 
> Plus there are now another 3:
> 625cd0a0df3ad9 actively disable bias on outputs
> 9d1f9db81b4dc4 actively disable bias on inputs when pull up/down not set
> c6d4bf32c05189 add set_config to support pull up/down
> 
> Those add pull up/down support to gpio-mockup, and fix the stuck pulls 
> I noted earlier - though they still remain applied until the next time
> the line is requested.
> 
> 9d1f9db81b4dc4 doesn't like being applied to the rpi kernel, I assume as
> there have been conflicting changes between 5.3.3 and 5.4-rc2, so I
> patched that one manually.
> 
The disable bias changes I mentioned above are problematic - they break
ABI backward compatibility by explicitly disabling bias when neither
PULL_UP nor PULL_DOWN are set - which will be the case for legacy apps.

We really need to handle 4 possible bias states - None, Pull Up, Pull
Down and As Is, with the zero default being As Is.
So I intend to reinterpret the pull up and down flags as a two bit field
encoding the following:

0 - AsIs
1 - PullUp
2 - PullDown
3 - PullNone

Any objections?

Cheers,
Kent.

  reply	other threads:[~2019-10-10 11:17 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-21 10:25 [RFC] gpio: expose pull-up/pull-down line flags to userspace Drew Fustini
2019-09-23  8:38 ` Bartosz Golaszewski
2019-10-02 11:10   ` Drew Fustini
2019-10-03 12:47   ` Linus Walleij
2019-10-04  7:22     ` Bartosz Golaszewski
2019-10-04 12:46       ` Bartosz Golaszewski
2019-10-05 17:02       ` Linus Walleij
2019-10-06  3:12         ` Kent Gibson
2019-10-06 21:06           ` Linus Walleij
2019-10-07  4:37             ` Kent Gibson
2019-10-08  6:15 ` Kent Gibson
2019-10-08 20:56   ` Bartosz Golaszewski
2019-10-08 23:21     ` Kent Gibson
2019-10-08 23:30       ` Bartosz Golaszewski
2019-10-08 23:56         ` Kent Gibson
2019-10-09  0:03           ` Bartosz Golaszewski
2019-10-09  0:22             ` Kent Gibson
2019-10-09  6:55               ` Kent Gibson
2019-10-09 12:57                 ` Drew Fustini
2019-10-09 13:23                   ` Kent Gibson
2019-10-09 13:30                 ` Drew Fustini
2019-10-09 14:11                   ` Kent Gibson
2019-10-09 15:50                     ` Bartosz Golaszewski
2019-10-09 16:19                       ` Kent Gibson
2019-10-09 23:59                   ` Kent Gibson
2019-10-10  7:47                     ` Drew Fustini
2019-10-10 10:14                       ` Kent Gibson
2019-10-10 11:17                         ` Kent Gibson [this message]
2019-10-11 13:04                           ` Drew Fustini
2019-10-11 13:06                         ` Drew Fustini
2019-10-11 13:49                           ` Kent Gibson
2019-10-09 11:32               ` Drew Fustini
2019-10-09 13:57       ` Drew Fustini
2019-10-09 14:01         ` Kent Gibson
2019-10-09 11:46   ` 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=20191010111705.GA17666@sol \
    --to=warthog618@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=pdp7pdp7@gmail.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).