All of lore.kernel.org
 help / color / mirror / Atom feed
* gpiod: Set pullup for Input Line
@ 2022-03-21 10:43 Hans Kurscheidt
  2022-03-21 13:34 ` Alexander Dahl
  2022-03-21 16:26 ` Andy Shevchenko
  0 siblings, 2 replies; 16+ messages in thread
From: Hans Kurscheidt @ 2022-03-21 10:43 UTC (permalink / raw)
  To: linux-gpio

Despite deep searching, I cannot find any information, if gpiod allow 
specifying pull-ups to input lines and how to do/handle it.

RGDS

hk



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
  2022-03-21 10:43 gpiod: Set pullup for Input Line Hans Kurscheidt
@ 2022-03-21 13:34 ` Alexander Dahl
  2022-03-21 16:26 ` Andy Shevchenko
  1 sibling, 0 replies; 16+ messages in thread
From: Alexander Dahl @ 2022-03-21 13:34 UTC (permalink / raw)
  To: Hans Kurscheidt; +Cc: linux-gpio

Hello Hans,

Am Mon, Mar 21, 2022 at 11:43:45AM +0100 schrieb Hans Kurscheidt:
> Despite deep searching, I cannot find any information, if gpiod allow
> specifying pull-ups to input lines and how to do/handle it.

This is usually something described in device tree.  Or do you have a
use case for changing it at runtime?

Greets
Alex


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
       [not found] <ab3240e5-df61-cff4-ebba-f6a7e5d99f52@gmail.com>
@ 2022-03-21 13:48 ` Hans Kurscheidt
  2022-03-21 14:42   ` Alexander Dahl
  0 siblings, 1 reply; 16+ messages in thread
From: Hans Kurscheidt @ 2022-03-21 13:48 UTC (permalink / raw)
  To: linux-gpio


Hi Alex,

sure, device trees are eventually overwritten w/ new kernels or "as is" 
on a new device. Hence my application won't work on a new 
installation/board, because it needs certain GPIO input pins w/pull ups. 
DTBs need to be disassembled and re-compiled, which is not for the 
average user to install & run an application!

RGDS

hk


Am 21.03.2022 um 14:34 schrieb Alexander Dahl:
> Hello Hans,
>
> Am Mon, Mar 21, 2022 at 11:43:45AM +0100 schrieb Hans Kurscheidt:
>> Despite deep searching, I cannot find any information, if gpiod allow
>> specifying pull-ups to input lines and how to do/handle it.
> This is usually something described in device tree. Or do you have a
> use case for changing it at runtime?
>
> Greets
> Alex
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
  2022-03-21 13:48 ` Hans Kurscheidt
@ 2022-03-21 14:42   ` Alexander Dahl
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Dahl @ 2022-03-21 14:42 UTC (permalink / raw)
  To: Hans Kurscheidt; +Cc: linux-gpio

Hei hei,

Am Mon, Mar 21, 2022 at 02:48:02PM +0100 schrieb Hans Kurscheidt:
> sure, device trees are eventually overwritten w/ new kernels or "as is" on a
> new device. 

You would need a board specific dts or dt overlay anyways.  Just compile
that again with you new kernel.  For a new board, you need to make a
new dts anyways, I don't see the problem here.

> Hence my application won't work on a new installation/board,
> because it needs certain GPIO input pins w/pull ups. 

Well, and those pullups need to be in SoC, and can not be external?

> DTBs need to be
> disassembled and re-compiled, which is not for the average user to install &
> run an application!

Why disassemble dtb, just go with the dts and compile that.

For easier handling in your application and across different boards,
you might want to checkout gpio line names.  We successfully used that
to let the same application work with different boards (even with
SoCs of different vendors), without the need to modify the app at all
if the hardware changes.  That is much more convenient than putting
pin numbers and knowledge about each and every possible board into the
application.

HTH & Greets
Alex


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
  2022-03-21 10:43 gpiod: Set pullup for Input Line Hans Kurscheidt
  2022-03-21 13:34 ` Alexander Dahl
@ 2022-03-21 16:26 ` Andy Shevchenko
  2022-03-21 17:27   ` Hans Kurscheidt
  1 sibling, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2022-03-21 16:26 UTC (permalink / raw)
  To: Hans Kurscheidt; +Cc: open list:GPIO SUBSYSTEM

On Mon, Mar 21, 2022 at 1:30 PM Hans Kurscheidt <lve0200@gmail.com> wrote:
>
> Despite deep searching, I cannot find any information, if gpiod allow
> specifying pull-ups to input lines and how to do/handle it.

Have you followed this code from libgpiod?
https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/tools/gpioset.c#n44

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
  2022-03-21 16:26 ` Andy Shevchenko
@ 2022-03-21 17:27   ` Hans Kurscheidt
  2022-03-21 17:33     ` Andy Shevchenko
  0 siblings, 1 reply; 16+ messages in thread
From: Hans Kurscheidt @ 2022-03-21 17:27 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: open list:GPIO SUBSYSTEM

Hi thanks, that makes hope.

Unfortunately apt-get gpiod on my OrangePi Armbian board gives me 
version 1.2, while the dev is already at 1.6. I probably have to build 
it from source.

Keeping fingers crossed .

RGDS

hk


Am 21.03.2022 um 17:26 schrieb Andy Shevchenko:
> On Mon, Mar 21, 2022 at 1:30 PM Hans Kurscheidt <lve0200@gmail.com> wrote:
>> Despite deep searching, I cannot find any information, if gpiod allow
>> specifying pull-ups to input lines and how to do/handle it.
> Have you followed this code from libgpiod?
> https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/tools/gpioset.c#n44
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
  2022-03-21 17:27   ` Hans Kurscheidt
@ 2022-03-21 17:33     ` Andy Shevchenko
  2022-03-21 18:17       ` Hans Kurscheidt
  2022-03-22  0:59       ` Kent Gibson
  0 siblings, 2 replies; 16+ messages in thread
From: Andy Shevchenko @ 2022-03-21 17:33 UTC (permalink / raw)
  To: Hans Kurscheidt, Bartosz Golaszewski, Kent Gibson
  Cc: open list:GPIO SUBSYSTEM

On Mon, Mar 21, 2022 at 7:27 PM Hans Kurscheidt <lve0200@gmail.com> wrote:
>
> Hi thanks, that makes hope.

First of all, please do not top-post.

> Unfortunately apt-get gpiod on my OrangePi Armbian board gives me
> version 1.2, while the dev is already at 1.6. I probably have to build
> it from source.
>
> Keeping fingers crossed .

I don't remember the details of old versions of libgpiod (Bart? Kent?)
I think it was available even there.

> Am 21.03.2022 um 17:26 schrieb Andy Shevchenko:
> > On Mon, Mar 21, 2022 at 1:30 PM Hans Kurscheidt <lve0200@gmail.com> wrote:
> >> Despite deep searching, I cannot find any information, if gpiod allow
> >> specifying pull-ups to input lines and how to do/handle it.
> > Have you followed this code from libgpiod?
> > https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/tools/gpioset.c#n44


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
  2022-03-21 17:33     ` Andy Shevchenko
@ 2022-03-21 18:17       ` Hans Kurscheidt
  2022-03-21 20:25         ` Fwd: " Hans Kurscheidt
  2022-03-22  0:59       ` Kent Gibson
  1 sibling, 1 reply; 16+ messages in thread
From: Hans Kurscheidt @ 2022-03-21 18:17 UTC (permalink / raw)
  To: Andy Shevchenko, Bartosz Golaszewski, Kent Gibson
  Cc: open list:GPIO SUBSYSTEM


Am 21.03.2022 um 18:33 schrieb Andy Shevchenko:
> On Mon, Mar 21, 2022 at 7:27 PM Hans Kurscheidt <lve0200@gmail.com> wrote:
>> Hi thanks, that makes hope.
> First of all, please do not top-post.
>
>> Unfortunately apt-get gpiod on my OrangePi Armbian board gives me
>> version 1.2, while the dev is already at 1.6. I probably have to build
>> it from source.
>>
>> Keeping fingers crossed .
> I don't remember the details of old versions of libgpiod (Bart? Kent?)
> I think it was available even there.
>
>> Am 21.03.2022 um 17:26 schrieb Andy Shevchenko:
>>> On Mon, Mar 21, 2022 at 1:30 PM Hans Kurscheidt <lve0200@gmail.com> wrote:
>>>> Despite deep searching, I cannot find any information, if gpiod allow
>>>> specifying pull-ups to input lines and how to do/handle it.
>>> Have you followed this code from libgpiod?
>>> https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/tools/gpioset.c#n44
> I don't think that the Bias option is in 1.2.3, because help is mute about it

>   Trying to build it from source, doesn't work for me. I get:
hk@orangepizeroplus:~/libgpiod$ ./autogen.sh --enable-tools=yes 
--prefix=/usr/bin
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
aclocal: warning: couldn't open directory 'm4': No such file or directory
autoreconf: configure.ac: tracing
autoreconf: configure.ac: creating directory autostuff
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
configure.ac:163: error: possibly undefined macro: AC_LIBTOOL_CXX
       If this token and others are legitimate, please use m4_pattern_allow.
       See the Autoconf documentation.
configure.ac:165: error: Unexpanded AX_ macro found. Please install GNU 
autoconf-archive.
configure.ac:179: error: Unexpanded AX_ macro found. Please install GNU 
autoconf-archive.
autoreconf: /usr/bin/autoconf failed with exit status: 1
hk@orangepizeroplus:~/libgpiod$


??

RGDS



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Fwd: gpiod: Set pullup for Input Line
  2022-03-21 18:17       ` Hans Kurscheidt
@ 2022-03-21 20:25         ` Hans Kurscheidt
  0 siblings, 0 replies; 16+ messages in thread
From: Hans Kurscheidt @ 2022-03-21 20:25 UTC (permalink / raw)
  To: ndy Shevchenko, Bartosz Golaszewski, Kent Gibson; +Cc: open list:GPIO SUBSYSTEM


Am 21.03.2022 um 18:33 schrieb Andy Shevchenko:
> On Mon, Mar 21, 2022 at 7:27 PM Hans Kurscheidt <lve0200@gmail.com> wrote:
>> Hi thanks, that makes hope.
> First of all, please do not top-post.
>
>> Unfortunately apt-get gpiod on my OrangePi Armbian board gives me
>> version 1.2, while the dev is already at 1.6. I probably have to build
>> it from source.
>>
>> Keeping fingers crossed .
> I don't remember the details of old versions of libgpiod (Bart? Kent?)
> I think it was available even there.
>
>> Am 21.03.2022 um 17:26 schrieb Andy Shevchenko:
>>> On Mon, Mar 21, 2022 at 1:30 PM Hans Kurscheidt <lve0200@gmail.com> 
>>> wrote:
>>>> Despite deep searching, I cannot find any information, if gpiod allow
>>>> specifying pull-ups to input lines and how to do/handle it.
>>> Have you followed this code from libgpiod?
>>> https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/tools/gpioset.c#n44
> I don't think that the Bias option is in 1.2.3, because help is mute 
> about it

> Trying to build it from source, doesn't work for me. I get:
hk@orangepizeroplus:~/libgpiod$ ./autogen.sh --enable-tools=yes 
--prefix=/usr/bin
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
aclocal: warning: couldn't open directory 'm4': No such file or directory
autoreconf: configure.ac: tracing
autoreconf: configure.ac: creating directory autostuff
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
configure.ac:163: error: possibly undefined macro: AC_LIBTOOL_CXX
       If this token and others are legitimate, please use m4_pattern_allow.
       See the Autoconf documentation.
configure.ac:165: error: Unexpanded AX_ macro found. Please install GNU 
autoconf-archive.
configure.ac:179: error: Unexpanded AX_ macro found. Please install GNU 
autoconf-archive.
autoreconf: /usr/bin/autoconf failed with exit status: 1
hk@orangepizeroplus:~/libgpiod$


??

RGDS

Got it; needed to install libtools and (may be) create a directory m4 in 
libgpiod
Its working now w/ Version 2.0 and I see the Bias Option

Thank you


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
  2022-03-21 17:33     ` Andy Shevchenko
  2022-03-21 18:17       ` Hans Kurscheidt
@ 2022-03-22  0:59       ` Kent Gibson
       [not found]         ` <1a7fd31a-221e-7b23-b95f-d71e440b3ff0@gmail.com>
  1 sibling, 1 reply; 16+ messages in thread
From: Kent Gibson @ 2022-03-22  0:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hans Kurscheidt, Bartosz Golaszewski, open list:GPIO SUBSYSTEM

On Mon, Mar 21, 2022 at 07:33:28PM +0200, Andy Shevchenko wrote:
> On Mon, Mar 21, 2022 at 7:27 PM Hans Kurscheidt <lve0200@gmail.com> wrote:
> >
> > Hi thanks, that makes hope.
> 
> First of all, please do not top-post.
> 
> > Unfortunately apt-get gpiod on my OrangePi Armbian board gives me
> > version 1.2, while the dev is already at 1.6. I probably have to build
> > it from source.
> >
> > Keeping fingers crossed .
> 
> I don't remember the details of old versions of libgpiod (Bart? Kent?)
> I think it was available even there.
> 

Bias support was added in libgpiod v1.5.
It wasn't even exposed in the uAPI prior to that - it wasn't added until
kernel v5.5.

In this case building the latest stable, 1.6.3, is the way to go.

Cheers,
Kent.

> > Am 21.03.2022 um 17:26 schrieb Andy Shevchenko:
> > > On Mon, Mar 21, 2022 at 1:30 PM Hans Kurscheidt <lve0200@gmail.com> wrote:
> > >> Despite deep searching, I cannot find any information, if gpiod allow
> > >> specifying pull-ups to input lines and how to do/handle it.
> > > Have you followed this code from libgpiod?
> > > https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/tools/gpioset.c#n44
> 
> 
> -- 
> With Best Regards,
> Andy Shevchenko

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
       [not found]         ` <1a7fd31a-221e-7b23-b95f-d71e440b3ff0@gmail.com>
@ 2022-03-22  8:39           ` Hans Kurscheidt
  2022-03-22  8:50             ` Andy Shevchenko
  2022-03-22 16:11           ` Kent Gibson
  1 sibling, 1 reply; 16+ messages in thread
From: Hans Kurscheidt @ 2022-03-22  8:39 UTC (permalink / raw)
  To: Kent Gibson, Andy Shevchenko
  Cc: Bartosz Golaszewski, open list:GPIO SUBSYSTEM


Am 22.03.2022 um 09:36 schrieb Hans Kurscheidt:
>
>
> Am 22.03.2022 um 01:59 schrieb Kent Gibson:
>> On Mon, Mar 21, 2022 at 07:33:28PM +0200, Andy Shevchenko wrote:
>>> On Mon, Mar 21, 2022 at 7:27 PM Hans Kurscheidt<lve0200@gmail.com>  wrote:
>>>> Hi thanks, that makes hope.
>>> First of all, please do not top-post.
>>>
>>>> Unfortunately apt-get gpiod on my OrangePi Armbian board gives me
>>>> version 1.2, while the dev is already at 1.6. I probably have to build
>>>> it from source.
>>>>
>>>> Keeping fingers crossed .
>>> I don't remember the details of old versions of libgpiod (Bart? Kent?)
>>> I think it was available even there.
>>>
>> Bias support was added in libgpiod v1.5.
>> It wasn't even exposed in the uAPI prior to that - it wasn't added until
>> kernel v5.5.
>>
>> In this case building the latest stable, 1.6.3, is the way to go.
>>
>> Cheers,
>> Kent.
>>
>>>> Am 21.03.2022 um 17:26 schrieb Andy Shevchenko:
>>>>> On Mon, Mar 21, 2022 at 1:30 PM Hans Kurscheidt<lve0200@gmail.com>  wrote:
>>>>>> Despite deep searching, I cannot find any information, if gpiod allow
>>>>>> specifying pull-ups to input lines and how to do/handle it.
>>>>> Have you followed this code from libgpiod?
>>>>> https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/tools/gpioset.c#n44
>>> -- 
>>> With Best Regards,
>>> Andy Shevchenko
>
> Thank-you Kent!
>
> Still 1 more question. I understand the sense of a Pull-up in Input 
> mode, but reading the code, I see that the Bias option exists as well 
> for gpioset (Output). What is the sense of this, and what does it do?
>
> WRT. building it, it wasn't that straight forward, as in the 
> description. On the Armbian/Debian buster Kernel 5.10.60-sunxi64 
> #21.08.1 I had to create an M4 dir, install GNU-archives and install 
> libtools in addition to succeed building it. Then doxygen and help2man 
> were still missing.
>
> All the best and thank you again, for solving my problem!
>
> Hans
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
  2022-03-22  8:39           ` Hans Kurscheidt
@ 2022-03-22  8:50             ` Andy Shevchenko
  2022-03-22  9:39               ` Hans Kurscheidt
  2022-03-22 16:11               ` Kent Gibson
  0 siblings, 2 replies; 16+ messages in thread
From: Andy Shevchenko @ 2022-03-22  8:50 UTC (permalink / raw)
  To: Hans Kurscheidt
  Cc: Kent Gibson, Bartosz Golaszewski, open list:GPIO SUBSYSTEM

On Tue, Mar 22, 2022 at 10:39 AM Hans Kurscheidt <lve0200@gmail.com> wrote:
> Am 22.03.2022 um 09:36 schrieb Hans Kurscheidt:
> > Am 22.03.2022 um 01:59 schrieb Kent Gibson:

...

> > Still 1 more question. I understand the sense of a Pull-up in Input
> > mode, but reading the code, I see that the Bias option exists as well
> > for gpioset (Output). What is the sense of this, and what does it do?

I guess we started providing OPEN SOURCE / DRAIN in libgpiod v2.0
(Bart or Kent may correct me), but you should get an idea why it may
be useful.

On top of that, the pin can be reconfigured from input to output and
vice versa at run-time. So, keeping a bias setting will allow not to
think about it when pin direction is switched, although I agree this
may not be a clean case to use.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
  2022-03-22  8:50             ` Andy Shevchenko
@ 2022-03-22  9:39               ` Hans Kurscheidt
  2022-03-22 16:12                 ` Kent Gibson
  2022-03-22 16:11               ` Kent Gibson
  1 sibling, 1 reply; 16+ messages in thread
From: Hans Kurscheidt @ 2022-03-22  9:39 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Kent Gibson, Bartosz Golaszewski, open list:GPIO SUBSYSTEM


Am 22.03.2022 um 09:50 schrieb Andy Shevchenko:
> On Tue, Mar 22, 2022 at 10:39 AM Hans Kurscheidt <lve0200@gmail.com> wrote:
>> Am 22.03.2022 um 09:36 schrieb Hans Kurscheidt:
>>> Am 22.03.2022 um 01:59 schrieb Kent Gibson:
> ...
>
>>> Still 1 more question. I understand the sense of a Pull-up in Input
>>> mode, but reading the code, I see that the Bias option exists as well
>>> for gpioset (Output). What is the sense of this, and what does it do?
> I guess we started providing OPEN SOURCE / DRAIN in libgpiod v2.0
> (Bart or Kent may correct me), but you should get an idea why it may
> be useful.
>
> On top of that, the pin can be reconfigured from input to output and
> vice versa at run-time. So, keeping a bias setting will allow not to
> think about it when pin direction is switched, although I agree this
> may not be a clean case to use.

Hi Andy,

Open Source/Drain is completely different from Pull_UP/DOWN! Open 
source/drain defines, which active element (transistor) is attached to 
the line, while pull_up/down defines, which passive element (resistor) 
is attached to the line. In some sense one could say, what pull_up/down 
is for input, open drain/source is the corresponding thing for output, 
but they are realized by different means. IMHO, "bias" (pull-up/down) 
should be an option for gpioget, while "drive" makes only sense for 
gpioset, because I understand them as mutually excluding, but may be, 
I'm overseeing something.

Unfortunately, this leads me to yet another question: Bias defines 
"as-is" and "pull-up/down" as options. Just to be sure, that would imply 
that one has to set the bias option to pull_up/down for the first call 
to gpioget and that subsequent readings from the input pin should/can 
run w/out the bias option, hence "as-is", or do you recommend to have 
the bias option specified for each read from the pin?


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
       [not found]         ` <1a7fd31a-221e-7b23-b95f-d71e440b3ff0@gmail.com>
  2022-03-22  8:39           ` Hans Kurscheidt
@ 2022-03-22 16:11           ` Kent Gibson
  1 sibling, 0 replies; 16+ messages in thread
From: Kent Gibson @ 2022-03-22 16:11 UTC (permalink / raw)
  To: Hans Kurscheidt
  Cc: Andy Shevchenko, Bartosz Golaszewski, open list:GPIO SUBSYSTEM

On Tue, Mar 22, 2022 at 09:36:29AM +0100, Hans Kurscheidt wrote:
> 
> Am 22.03.2022 um 01:59 schrieb Kent Gibson:
> > On Mon, Mar 21, 2022 at 07:33:28PM +0200, Andy Shevchenko wrote:
> > > On Mon, Mar 21, 2022 at 7:27 PM Hans Kurscheidt<lve0200@gmail.com>  wrote:
> > > > Hi thanks, that makes hope.
> > > First of all, please do not top-post.
> > > 
> > > > Unfortunately apt-get gpiod on my OrangePi Armbian board gives me
> > > > version 1.2, while the dev is already at 1.6. I probably have to build
> > > > it from source.
> > > > 
> > > > Keeping fingers crossed .
> > > I don't remember the details of old versions of libgpiod (Bart? Kent?)
> > > I think it was available even there.
> > > 
> > Bias support was added in libgpiod v1.5.
> > It wasn't even exposed in the uAPI prior to that - it wasn't added until
> > kernel v5.5.
> > 
> > In this case building the latest stable, 1.6.3, is the way to go.
> > 
> > Cheers,
> > Kent.
> > 
> > > > Am 21.03.2022 um 17:26 schrieb Andy Shevchenko:
> > > > > On Mon, Mar 21, 2022 at 1:30 PM Hans Kurscheidt<lve0200@gmail.com>  wrote:
> > > > > > Despite deep searching, I cannot find any information, if gpiod allow
> > > > > > specifying pull-ups to input lines and how to do/handle it.
> > > > > Have you followed this code from libgpiod?
> > > > > https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/tools/gpioset.c#n44
> > > 
> > > -- 
> > > With Best Regards,
> > > Andy Shevchenko
> 
> Thank-you Kent!
> 
> Still 1 more question. I understand the sense of a Pull-up in Input mode,
> but reading the code, I see that the Bias option exists as well for gpioset
> (Output). What is the sense of this, and what does it do?
> 

As answered by Andy, drive and bias are orthogonal so gpioset supports
setting them independently.  Obviously setting bias with push-pull
doesn't make much sense, but the case it is there for is combining open
drain/source with a pull for when the line is not being driven.
Granted that such a pull would usually be provided externally, but the
option is there in case it isn't.

> WRT. building it, it wasn't that straight forward, as in the description. On
> the Armbian/Debian buster Kernel 5.10.60-sunxi64 #21.08.1 I had to create an
> M4 dir, install GNU-archives and install libtools in addition to succeed
> building it. Then doxygen and help2man were still missing.
> 

I defer to Bart on build issues, but you shouldn't need to create the
m4 directory - you should install m4.
In fact all these packages:
  apt_packages:
      - autoconf
      - autoconf-archive
      - libtool
      - m4
      - doxygen
      - graphviz

That list is drawn from a recent patch I submitted to build the documentation
on a readthedocs Ubuntu VM, but it is probably the same or very similar
for Armbian.
That is in addition to build-essential, but I assume you already have that.

Cheers,
Kent.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
  2022-03-22  8:50             ` Andy Shevchenko
  2022-03-22  9:39               ` Hans Kurscheidt
@ 2022-03-22 16:11               ` Kent Gibson
  1 sibling, 0 replies; 16+ messages in thread
From: Kent Gibson @ 2022-03-22 16:11 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hans Kurscheidt, Bartosz Golaszewski, open list:GPIO SUBSYSTEM

On Tue, Mar 22, 2022 at 10:50:30AM +0200, Andy Shevchenko wrote:
> On Tue, Mar 22, 2022 at 10:39 AM Hans Kurscheidt <lve0200@gmail.com> wrote:
> > Am 22.03.2022 um 09:36 schrieb Hans Kurscheidt:
> > > Am 22.03.2022 um 01:59 schrieb Kent Gibson:
> 
> ...
> 
> > > Still 1 more question. I understand the sense of a Pull-up in Input
> > > mode, but reading the code, I see that the Bias option exists as well
> > > for gpioset (Output). What is the sense of this, and what does it do?
> 
> I guess we started providing OPEN SOURCE / DRAIN in libgpiod v2.0
> (Bart or Kent may correct me), but you should get an idea why it may
> be useful.
> 

No - open drain/source is not new - it has been there since cdev was added
AFAIAA.
The v2 ABI, which libgpiod v2 will support, adds debounce, event sequence
numbers, events from multiple lines in one request, and a few other
things, but the drive options have always been there - even before the
bias options were added.

> On top of that, the pin can be reconfigured from input to output and
> vice versa at run-time. So, keeping a bias setting will allow not to
> think about it when pin direction is switched, although I agree this
> may not be a clean case to use.
> 

Agreed - I would set both the direction and bias in such a case.

Cheers,
Kent.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: gpiod: Set pullup for Input Line
  2022-03-22  9:39               ` Hans Kurscheidt
@ 2022-03-22 16:12                 ` Kent Gibson
  0 siblings, 0 replies; 16+ messages in thread
From: Kent Gibson @ 2022-03-22 16:12 UTC (permalink / raw)
  To: Hans Kurscheidt
  Cc: Andy Shevchenko, Bartosz Golaszewski, open list:GPIO SUBSYSTEM

On Tue, Mar 22, 2022 at 10:39:00AM +0100, Hans Kurscheidt wrote:
> 
> Am 22.03.2022 um 09:50 schrieb Andy Shevchenko:
> > On Tue, Mar 22, 2022 at 10:39 AM Hans Kurscheidt <lve0200@gmail.com> wrote:
> > > Am 22.03.2022 um 09:36 schrieb Hans Kurscheidt:
> > > > Am 22.03.2022 um 01:59 schrieb Kent Gibson:
> > ...
> > 
> > > > Still 1 more question. I understand the sense of a Pull-up in Input
> > > > mode, but reading the code, I see that the Bias option exists as well
> > > > for gpioset (Output). What is the sense of this, and what does it do?
> > I guess we started providing OPEN SOURCE / DRAIN in libgpiod v2.0
> > (Bart or Kent may correct me), but you should get an idea why it may
> > be useful.
> > 
> > On top of that, the pin can be reconfigured from input to output and
> > vice versa at run-time. So, keeping a bias setting will allow not to
> > think about it when pin direction is switched, although I agree this
> > may not be a clean case to use.
> 
> Hi Andy,
> 
> Open Source/Drain is completely different from Pull_UP/DOWN! Open
> source/drain defines, which active element (transistor) is attached to the
> line, while pull_up/down defines, which passive element (resistor) is
> attached to the line. In some sense one could say, what pull_up/down is for
> input, open drain/source is the corresponding thing for output, but they are
> realized by different means. IMHO, "bias" (pull-up/down) should be an option
> for gpioget, while "drive" makes only sense for gpioset, because I
> understand them as mutually excluding, but may be, I'm overseeing something.
> 

You understand that with open drain/source there is one state where the
line is not driven by the chip, but goes high impedance and is driven
by the external circuit?  
And the bias can be considered to be part of the external circuit?
If so, not sure what your issue is here.  You agree that drive and bias are
totally independent, but take issue at being able to set them
independently in gpioset?  What am I missing?

And there IS a bias option for gpioget - as it makes sense there as
well.  And gpiomon as well.

> Unfortunately, this leads me to yet another question: Bias defines "as-is"
> and "pull-up/down" as options. Just to be sure, that would imply that one
> has to set the bias option to pull_up/down for the first call to gpioget and
> that subsequent readings from the input pin should/can run w/out the bias
> option, hence "as-is", or do you recommend to have the bias option specified
> for each read from the pin?
> 

The "as-is" is an unfortunate side-effect of bias being a late addition
to the API, though it could be argued that it is useful in its own
right, as Andy mentioned.
Its main purpose is for backwards compatibility and is the default for that
reason.

If you need a bias then set it as needed.  I would use options consistently,
not have different options on subsequent calls.

I would also recommend using edge events, such as those provided by
gpiomon, rather than polling with gpioget, but that depends on the complexity
of your use case.

Cheers,
Kent.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-03-22 16:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 10:43 gpiod: Set pullup for Input Line Hans Kurscheidt
2022-03-21 13:34 ` Alexander Dahl
2022-03-21 16:26 ` Andy Shevchenko
2022-03-21 17:27   ` Hans Kurscheidt
2022-03-21 17:33     ` Andy Shevchenko
2022-03-21 18:17       ` Hans Kurscheidt
2022-03-21 20:25         ` Fwd: " Hans Kurscheidt
2022-03-22  0:59       ` Kent Gibson
     [not found]         ` <1a7fd31a-221e-7b23-b95f-d71e440b3ff0@gmail.com>
2022-03-22  8:39           ` Hans Kurscheidt
2022-03-22  8:50             ` Andy Shevchenko
2022-03-22  9:39               ` Hans Kurscheidt
2022-03-22 16:12                 ` Kent Gibson
2022-03-22 16:11               ` Kent Gibson
2022-03-22 16:11           ` Kent Gibson
     [not found] <ab3240e5-df61-cff4-ebba-f6a7e5d99f52@gmail.com>
2022-03-21 13:48 ` Hans Kurscheidt
2022-03-21 14:42   ` Alexander Dahl

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.