CVS commit: src/usr.sbin/gpioctl

2022-12-13 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Tue Dec 13 21:47:36 UTC 2022

Modified Files:
src/usr.sbin/gpioctl: gpioctl.c

Log Message:
If we can't read a pin while listing pins, simply continue on to next
pin rather than abort.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/gpioctl/gpioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/gpioctl/gpioctl.c
diff -u src/usr.sbin/gpioctl/gpioctl.c:1.27 src/usr.sbin/gpioctl/gpioctl.c:1.28
--- src/usr.sbin/gpioctl/gpioctl.c:1.27	Sun Oct 20 09:41:53 2019
+++ src/usr.sbin/gpioctl/gpioctl.c	Tue Dec 13 21:47:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: gpioctl.c,v 1.27 2019/10/20 09:41:53 tnn Exp $ */
+/* $NetBSD: gpioctl.c,v 1.28 2022/12/13 21:47:36 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2008, 2010, 2011, 2013 Marc Balmer 
@@ -17,7 +17,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 #include 
-__RCSID("$NetBSD: gpioctl.c,v 1.27 2019/10/20 09:41:53 tnn Exp $");
+__RCSID("$NetBSD: gpioctl.c,v 1.28 2022/12/13 21:47:36 jakllsch Exp $");
 
 /*
  * Program to control GPIO devices.
@@ -362,7 +362,7 @@ gpiolist()
 		memset(&req, 0, sizeof(req));
 		req.gp_pin = i;
 		if (ioctl(devfd, GPIOREAD, &req) == -1)
-			err(EXIT_FAILURE, "GPIOREAD");
+			continue;
 		if (!quiet)
 			printf("%d: %s\n", i, req.gp_name);
 	}



CVS commit: src/usr.sbin/gpioctl

2022-12-13 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Tue Dec 13 21:47:36 UTC 2022

Modified Files:
src/usr.sbin/gpioctl: gpioctl.c

Log Message:
If we can't read a pin while listing pins, simply continue on to next
pin rather than abort.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/gpioctl/gpioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/gpioctl

2019-10-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Oct 20 17:45:08 UTC 2019

Modified Files:
src/usr.sbin/gpioctl: gpioctl.8

Log Message:
Be consistent in not marking up "GPIO".


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/gpioctl/gpioctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/gpioctl

2019-10-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Oct 20 17:45:08 UTC 2019

Modified Files:
src/usr.sbin/gpioctl: gpioctl.8

Log Message:
Be consistent in not marking up "GPIO".


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/gpioctl/gpioctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/gpioctl/gpioctl.8
diff -u src/usr.sbin/gpioctl/gpioctl.8:1.23 src/usr.sbin/gpioctl/gpioctl.8:1.24
--- src/usr.sbin/gpioctl/gpioctl.8:1.23	Sun Oct 20 09:41:53 2019
+++ src/usr.sbin/gpioctl/gpioctl.8	Sun Oct 20 17:45:08 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpioctl.8,v 1.23 2019/10/20 09:41:53 tnn Exp $
+.\" $NetBSD: gpioctl.8,v 1.24 2019/10/20 17:45:08 wiz Exp $
 .\"
 .\" Copyright (c) 2009, 2010, 2011, 2013 Marc Balmer 
 .\" Copyright (c) 2004 Alexander Yurchenko 
@@ -155,9 +155,7 @@ When executed with only the
 .Xr gpio 4
 device name as argument,
 .Nm
-reads information about the
-.Tn GPIO
-device and displays it.
+reads information about the GPIO device and displays it.
 At securelevel 0 the number of physically available pins is displayed,
 at higher securelevels the number of configured (set) pins is displayed.
 .Pp



CVS commit: src/usr.sbin/gpioctl

2019-10-20 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Oct 20 09:41:53 UTC 2019

Modified Files:
src/usr.sbin/gpioctl: gpioctl.8 gpioctl.c

Log Message:
gpioctl: implement support for "gpioctl gpioN list". Like pcictl(8).

For drivers that name their pins, this can be used to determine how the
logical pins are mapped to physical pins. Example from sunxigpio(4):

# gpioctl gpio0 list
0: PA0
1: PA1
2: PA2
...


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/gpioctl/gpioctl.8
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/gpioctl/gpioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/gpioctl/gpioctl.8
diff -u src/usr.sbin/gpioctl/gpioctl.8:1.22 src/usr.sbin/gpioctl/gpioctl.8:1.23
--- src/usr.sbin/gpioctl/gpioctl.8:1.22	Wed Feb 13 11:40:41 2019
+++ src/usr.sbin/gpioctl/gpioctl.8	Sun Oct 20 09:41:53 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpioctl.8,v 1.22 2019/02/13 11:40:41 wiz Exp $
+.\" $NetBSD: gpioctl.8,v 1.23 2019/10/20 09:41:53 tnn Exp $
 .\"
 .\" Copyright (c) 2009, 2010, 2011, 2013 Marc Balmer 
 .\" Copyright (c) 2004 Alexander Yurchenko 
@@ -15,7 +15,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd February 12, 2019
+.Dd October 20, 2019
 .Dt GPIOCTL 8
 .Os
 .Sh NAME
@@ -55,6 +55,10 @@
 .Ar device
 .Ar pin
 .Cm unset
+.Nm gpioctl
+.Op Fl q
+.Ar device
+.Ar list
 .Sh DESCRIPTION
 The
 .Nm
@@ -203,6 +207,10 @@ Configure pin 5 as output and name it er
 Toggle the error_led:
 .Pp
 .Dl # gpioctl gpio0 error_led 2
+.Pp
+Enumerate all pins and display their symbolic names:
+.Pp
+.Dl # gpioctl gpio0 list
 .Sh SEE ALSO
 .Xr gpio 4 ,
 .Xr drvctl 8

Index: src/usr.sbin/gpioctl/gpioctl.c
diff -u src/usr.sbin/gpioctl/gpioctl.c:1.26 src/usr.sbin/gpioctl/gpioctl.c:1.27
--- src/usr.sbin/gpioctl/gpioctl.c:1.26	Sun Jan 27 02:08:51 2019
+++ src/usr.sbin/gpioctl/gpioctl.c	Sun Oct 20 09:41:53 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gpioctl.c,v 1.26 2019/01/27 02:08:51 pgoyette Exp $ */
+/* $NetBSD: gpioctl.c,v 1.27 2019/10/20 09:41:53 tnn Exp $ */
 
 /*
  * Copyright (c) 2008, 2010, 2011, 2013 Marc Balmer 
@@ -17,7 +17,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 #include 
-__RCSID("$NetBSD: gpioctl.c,v 1.26 2019/01/27 02:08:51 pgoyette Exp $");
+__RCSID("$NetBSD: gpioctl.c,v 1.27 2019/10/20 09:41:53 tnn Exp $");
 
 /*
  * Program to control GPIO devices.
@@ -48,6 +48,7 @@ static void gpioread(int, char *);
 static void gpiowrite(int, char *, int);
 static void gpioset(int pin, char *name, int flags, char *alias);
 static void gpiounset(int pin, char *name);
+static void gpiolist(void);
 static void devattach(char *, int, uint32_t, uint32_t);
 __dead static void usage(void);
 
@@ -160,6 +161,9 @@ main(int argc, char *argv[])
 		}
 		devattach(driver, ga_offset, ga_mask, ga_flags);
 		return EXIT_SUCCESS;
+	} else if (!strcmp(argv[1], "list")) {
+		gpiolist();
+		return EXIT_SUCCESS;
 	} else {
 		char *nm = NULL;
 
@@ -345,6 +349,26 @@ gpiounset(int pin, char *name)
 }
 
 static void
+gpiolist()
+{
+	struct gpio_info info;
+	struct gpio_req req;
+	int i;
+
+	if (ioctl(devfd, GPIOINFO, &info) == -1)
+		err(EXIT_FAILURE, "GPIOINFO");
+
+	for (i = 0; i < info.gpio_npins; i++) {
+		memset(&req, 0, sizeof(req));
+		req.gp_pin = i;
+		if (ioctl(devfd, GPIOREAD, &req) == -1)
+			err(EXIT_FAILURE, "GPIOREAD");
+		if (!quiet)
+			printf("%d: %s\n", i, req.gp_name);
+	}
+}
+
+static void
 devattach(char *dvname, int offset, uint32_t mask, uint32_t flags)
 {
 	struct gpio_attach attach;
@@ -372,6 +396,7 @@ usage(void)
 	fprintf(stderr, "   %s [-q] device attach device offset mask "
 	"[flag]\n",
 	progname);
+	fprintf(stderr, "   %s [-q] device list\n", progname);
 
 	exit(EXIT_FAILURE);
 }



CVS commit: src/usr.sbin/gpioctl

2019-10-20 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Oct 20 09:41:53 UTC 2019

Modified Files:
src/usr.sbin/gpioctl: gpioctl.8 gpioctl.c

Log Message:
gpioctl: implement support for "gpioctl gpioN list". Like pcictl(8).

For drivers that name their pins, this can be used to determine how the
logical pins are mapped to physical pins. Example from sunxigpio(4):

# gpioctl gpio0 list
0: PA0
1: PA1
2: PA2
...


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/gpioctl/gpioctl.8
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/gpioctl/gpioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/usr.sbin/gpioctl

2015-12-09 Thread Marc Balmer
I suggest that you document these new flags in the gpioctl(8) manual page as 
well.


> Am 06.12.2015 um 08:31 schrieb Michael van Elst :
> 
> Module Name:  src
> Committed By: mlelstv
> Date: Sun Dec  6 07:31:28 UTC 2015
> 
> Modified Files:
>   src/usr.sbin/gpioctl: gpioctl.c
> 
> Log Message:
> pass new pin configuration flags to driver.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/gpioctl/gpioctl.c
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
> 
> Modified files:
> 
> Index: src/usr.sbin/gpioctl/gpioctl.c
> diff -u src/usr.sbin/gpioctl/gpioctl.c:1.21 
> src/usr.sbin/gpioctl/gpioctl.c:1.22
> --- src/usr.sbin/gpioctl/gpioctl.c:1.21   Thu Jan 29 03:30:06 2015
> +++ src/usr.sbin/gpioctl/gpioctl.cSun Dec  6 07:31:28 2015
> @@ -1,4 +1,4 @@
> -/* $NetBSD: gpioctl.c,v 1.21 2015/01/29 03:30:06 christos Exp $ */
> +/* $NetBSD: gpioctl.c,v 1.22 2015/12/06 07:31:28 mlelstv Exp $ */
> 
> /*
>  * Copyright (c) 2008, 2010, 2011, 2013 Marc Balmer 
> @@ -64,6 +64,18 @@ static const struct bitstr {
>   { GPIO_PIN_INVIN, "iin" },
>   { GPIO_PIN_INVOUT, "iout" },
>   { GPIO_PIN_PULSATE, "pulsate" },
> + { GPIO_PIN_ALT0, "alt0" },
> + { GPIO_PIN_ALT1, "alt1" },
> + { GPIO_PIN_ALT2, "alt2" },
> + { GPIO_PIN_ALT3, "alt3" },
> + { GPIO_PIN_ALT4, "alt4" },
> + { GPIO_PIN_ALT5, "alt5" },
> + { GPIO_PIN_ALT6, "alt6" },
> + { GPIO_PIN_ALT7, "alt7" },
> + { GPIO_PIN_ALT7, "events" },
> + { GPIO_PIN_ALT7, "level" },
> + { GPIO_PIN_ALT7, "falling" },
> + { GPIO_PIN_USER, "user" },
>   { 0, NULL },
> };
> 
>