Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/gpio Let the controller provide a default name for p...



details:   https://anonhg.NetBSD.org/src/rev/906a00532ffd
branches:  trunk
changeset: 825264:906a00532ffd
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Jul 06 10:43:06 2017 +0000

description:
Let the controller provide a default name for pins. This makes pins easier
to locate when we have multiple banks and a variable number of pins per
bank.

diffstat:

 sys/dev/gpio/gpio.c    |  17 +++++++++++++++--
 sys/dev/gpio/gpiovar.h |   3 ++-
 2 files changed, 17 insertions(+), 3 deletions(-)

diffs (62 lines):

diff -r 94cea923ca72 -r 906a00532ffd sys/dev/gpio/gpio.c
--- a/sys/dev/gpio/gpio.c       Thu Jul 06 09:49:46 2017 +0000
+++ b/sys/dev/gpio/gpio.c       Thu Jul 06 10:43:06 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpio.c,v 1.58 2016/05/11 18:33:40 bouyer Exp $ */
+/* $NetBSD: gpio.c,v 1.59 2017/07/06 10:43:06 jmcneill Exp $ */
 /*     $OpenBSD: gpio.c,v 1.6 2006/01/14 12:33:49 grange Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.58 2016/05/11 18:33:40 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.59 2017/07/06 10:43:06 jmcneill Exp $");
 
 /*
  * General Purpose Input/Output framework.
@@ -202,6 +202,8 @@
 {
        struct gpio_softc *sc = device_private(self);
        struct gpiobus_attach_args *gba = aux;
+       struct gpio_name *nm;
+       int pin;
 
        sc->sc_dev = self;
        sc->sc_gc = gba->gba_gc;
@@ -211,6 +213,17 @@
        aprint_normal(": %d pins\n", sc->sc_npins);
        aprint_naive("\n");
 
+       /* Configure default pin names */
+       for (pin = 0; pin < sc->sc_npins; pin++) {
+               if (sc->sc_pins[pin].pin_defname[0] == '\0')
+                       continue;
+               nm = kmem_alloc(sizeof(*nm), KM_SLEEP);
+               strlcpy(nm->gp_name, sc->sc_pins[pin].pin_defname,
+                   sizeof(nm->gp_name));
+               nm->gp_pin = pin;
+               LIST_INSERT_HEAD(&sc->sc_names, nm, gp_next);
+       }
+
        if (!pmf_device_register(self, NULL, gpio_resume))
                aprint_error_dev(self, "couldn't establish power handler\n");
        mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_VM);
diff -r 94cea923ca72 -r 906a00532ffd sys/dev/gpio/gpiovar.h
--- a/sys/dev/gpio/gpiovar.h    Thu Jul 06 09:49:46 2017 +0000
+++ b/sys/dev/gpio/gpiovar.h    Thu Jul 06 10:43:06 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpiovar.h,v 1.16 2016/05/11 18:33:40 bouyer Exp $ */
+/* $NetBSD: gpiovar.h,v 1.17 2017/07/06 10:43:06 jmcneill Exp $ */
 /*     $OpenBSD: gpiovar.h,v 1.3 2006/01/14 12:33:49 grange Exp $      */
 
 /*
@@ -44,6 +44,7 @@
        gpio_chipset_tag_t      pin_gc;         /* reference the controller */
        void                    (*pin_callback)(void *); /* irq callback */
        void *                  pin_callback_arg; /* callback arg */
+       char                    pin_defname[GPIOMAXNAME]; /* default name */
 } gpio_pin_t;
 
 /* Attach GPIO framework to the controller */



Home | Main Index | Thread Index | Old Index