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@xxxxxxxxx> 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.