All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Drew Fustini <drew@pdp7.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH v5 0/7] gpio: expose line bias flags to userspace
Date: Tue, 5 Nov 2019 08:12:13 +0800	[thread overview]
Message-ID: <20191105001213.GA3685@sol> (raw)
In-Reply-To: <20191104195838.GA9833@x1>

On Mon, Nov 04, 2019 at 11:58:38AM -0800, Drew Fustini wrote:
> On Mon, Nov 04, 2019 at 11:38:34PM +0800, Kent Gibson wrote:
> > on a Raspberry Pi, in both cases using the feature/pud_set_config 
> > branch of my Go gpiod library[2], as well as with my feature/pud 
> > development branch of libgpiod[3].  Patch 7 has only been tested using 
> > my gpiod library as libgpiod has not yet been updated to support the 
> > SET_CONFIG ioctl.
> > 
> > Patch 1 adds pull-up/pull-down support to line handle requests.
> > Patch 2 adds pull-up/pull-down support to line event requests.
> > Patch 3 adds support for disabling bias.
> > Patch 4 adds support for setting bias on output lines.
> > Patch 5 adds pull-up/down support to the gpio-mockup for uAPI testing.
> > Patch 6 refactors the flag validation from linehandle_create.
> > Patch 7 adds the SET_CONFIG ioctl.
> 
> Hi Kent, thanks for continuing pushing this patch series forward.
> 
> I've not used gpiomockup before and I was hoping you might be able to share
> the commands you use to run it to test the patches.
> 

I refer you to the libgpiod tests, particularly
libgpiod/tests/mockup/gpio-mockup.c as well as gpio/gpio-mockup.c
itself.

If you run the libgpiod tests they will load and manipulate the module
themselves.  My gpiod tests do similarly.  I run them in a VM to ensure
they can't interfere with real hardware by accident.

Here is a quick guide to using the mockup manually.

Load the module with two chips with 4 and 8 lines respectively:  

 modprobe gpio-mockup gpio_mockup_named_lines gpio_mockup_ranges=-1,4,-1,8

$ gpiodetect
gpiochip0 [gpio-mockup-A] (4 lines)
gpiochip1 [gpio-mockup-B] (8 lines)

You add a -1,N pair for each chip you want mocked.
The -1s is there for historical reasons.

The gpio_mockup_named_lines is optional and creates labels for the lines 
based on chip and line number (the labels are quoted here):

$ gpioinfo
gpiochip0 - 4 lines:
	line   0: "gpio-mockup-A-0" unused input active-high
	line   1: "gpio-mockup-A-1" unused input active-high
	line   2: "gpio-mockup-A-2" unused input active-high
	line   3: "gpio-mockup-A-3" unused input active-high
gpiochip1 - 8 lines:
	line   0: "gpio-mockup-B-0" unused input active-high
	line   1: "gpio-mockup-B-1" unused input active-high
	line   2: "gpio-mockup-B-2" unused input active-high
	line   3: "gpio-mockup-B-3" unused input active-high
	line   4: "gpio-mockup-B-4" unused input active-high
	line   5: "gpio-mockup-B-5" unused input active-high
	line   6: "gpio-mockup-B-6" unused input active-high
	line   7: "gpio-mockup-B-7" unused input active-high

You manipulate the lines using debugfs as per these examples.

Pull line 1 of chip 0 high:

 echo 1 > /sys/kernel/debug/gpio-mockup/gpiochip0/1

Pull line 2 of chip 1 low:

 echo 0 > /sys/kernel/debug/gpio-mockup/gpiochip1/2

Check the value of a line, which can be set from the kernel side
for gpio output lines:

 cat /sys/kernel/debug/gpio-mockup/gpiochip0/1

Cheers,
Kent.


  reply	other threads:[~2019-11-05  0:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 15:38 [PATCH v5 0/7] gpio: expose line bias flags to userspace Kent Gibson
2019-11-04 15:38 ` [PATCH v5 1/7] gpio: expose pull-up/pull-down line " Kent Gibson
2019-11-04 15:38 ` [PATCH v5 2/7] gpiolib: add support for pull up/down to lineevent_create Kent Gibson
2019-11-04 15:38 ` [PATCH v5 3/7] gpiolib: add support for disabling line bias Kent Gibson
2019-11-04 15:38 ` [PATCH v5 4/7] gpiolib: add support for biasing output lines Kent Gibson
2019-11-04 15:50   ` Bartosz Golaszewski
2019-11-04 15:59     ` Kent Gibson
2019-11-04 16:19       ` Bartosz Golaszewski
2019-11-05  2:03         ` Kent Gibson
2019-11-05  6:06           ` Kent Gibson
2019-11-05  9:10             ` Bartosz Golaszewski
2019-11-04 15:38 ` [PATCH v5 5/7] gpio: mockup: add set_config to support pull up/down Kent Gibson
2019-11-04 15:38 ` [PATCH v5 6/7] gpiolib: move validation of line handle flags into helper function Kent Gibson
2019-11-04 15:38 ` [PATCH v5 7/7] gpio: add new SET_CONFIG ioctl() to gpio chardev Kent Gibson
2019-11-04 19:58 ` [PATCH v5 0/7] gpio: expose line bias flags to userspace Drew Fustini
2019-11-05  0:12   ` Kent Gibson [this message]
2019-11-05  5:34     ` Kent Gibson

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=20191105001213.GA3685@sol \
    --to=warthog618@gmail.com \
    --cc=drew@pdp7.com \
    --cc=linux-gpio@vger.kernel.org \
    /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 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.