Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/gpio Make the gpiosim(4) device a 64 bit wide GPIO.



details:   https://anonhg.NetBSD.org/src/rev/0283efc4da72
branches:  trunk
changeset: 786910:0283efc4da72
user:      mbalmer <mbalmer%NetBSD.org@localhost>
date:      Mon May 20 15:48:25 2013 +0000

description:
Make the gpiosim(4) device a 64 bit wide GPIO.

diffstat:

 sys/dev/gpio/gpiosim.c |  42 +++++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diffs (108 lines):

diff -r 8bf1e5dd4329 -r 0283efc4da72 sys/dev/gpio/gpiosim.c
--- a/sys/dev/gpio/gpiosim.c    Mon May 20 15:46:41 2013 +0000
+++ b/sys/dev/gpio/gpiosim.c    Mon May 20 15:48:25 2013 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: gpiosim.c,v 1.14 2012/06/02 21:36:44 dsl Exp $ */
+/* $NetBSD: gpiosim.c,v 1.15 2013/05/20 15:48:25 mbalmer Exp $ */
 /*      $OpenBSD: gpiosim.c,v 1.1 2008/11/23 18:46:49 mbalmer Exp $    */
 
 /*
- * Copyright (c) 2007, 2008, 2009, 2010, 2011 Marc Balmer <marc%msys.ch@localhost>
+ * Copyright (c) 2007 - 2011, 2013 Marc Balmer <marc%msys.ch@localhost>
  * All rights reserved.
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -18,7 +18,7 @@
  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* 32 bit wide GPIO simulator  */
+/* 64 bit wide GPIO simulator  */
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -30,12 +30,12 @@
 #include <sys/ioccom.h>
 #include <dev/gpio/gpiovar.h>
 
-#define        GPIOSIM_NPINS   32
+#define        GPIOSIM_NPINS   64
 
 struct gpiosim_softc {
        device_t                sc_dev;
        device_t                sc_gdev;        /* gpio that attaches here */
-       uint32_t                sc_state;
+       uint64_t                sc_state;
        struct gpio_chipset_tag sc_gpio_gc;
        gpio_pin_t              sc_gpio_pins[GPIOSIM_NPINS];
 
@@ -105,19 +105,19 @@
 
                /* read initial state */
                sc->sc_gpio_pins[i].pin_flags = GPIO_PIN_INPUT;
-               sc->sc_state = 0;
+       }
+       sc->sc_state = 0;
 
-               /* create controller tag */
-               sc->sc_gpio_gc.gp_cookie = sc;
-               sc->sc_gpio_gc.gp_pin_read = gpiosim_pin_read;
-               sc->sc_gpio_gc.gp_pin_write = gpiosim_pin_write;
-               sc->sc_gpio_gc.gp_pin_ctl = gpiosim_pin_ctl;
+       /* create controller tag */
+       sc->sc_gpio_gc.gp_cookie = sc;
+       sc->sc_gpio_gc.gp_pin_read = gpiosim_pin_read;
+       sc->sc_gpio_gc.gp_pin_write = gpiosim_pin_write;
+       sc->sc_gpio_gc.gp_pin_ctl = gpiosim_pin_ctl;
 
-               /* gba.gba_name = "gpio"; */
-               gba.gba_gc = &sc->sc_gpio_gc;
-               gba.gba_pins = sc->sc_gpio_pins;
-               gba.gba_npins = GPIOSIM_NPINS;
-       }
+       /* gba.gba_name = "gpio"; */
+       gba.gba_gc = &sc->sc_gpio_gc;
+       gba.gba_pins = sc->sc_gpio_pins;
+       gba.gba_npins = GPIOSIM_NPINS;
 
        pmf_device_register(self, NULL, NULL);
 
@@ -140,7 +140,7 @@
 
         sysctl_createv(&sc->sc_log, 0, &node, NULL,
             CTLFLAG_READWRITE,
-            CTLTYPE_INT, "value",
+            CTLTYPE_QUAD, "value",
             SYSCTL_DESCR("Current GPIO simulator value"),
             gpiosim_sysctl, 0, (void *)sc, 0,
            CTL_CREATE, CTL_EOL);
@@ -171,7 +171,7 @@
 {
        struct sysctlnode node;
        struct gpiosim_softc *sc;
-       int val, error;
+       uint64_t val, error;
 
        node = *rnode;
        sc = node.sysctl_data;
@@ -192,7 +192,7 @@
 {
        struct gpiosim_softc *sc = arg;
 
-       if (sc->sc_state & (1 << pin))
+       if (sc->sc_state & (1LL << pin))
                return GPIO_PIN_HIGH;
        else
                return GPIO_PIN_LOW;
@@ -204,9 +204,9 @@
        struct gpiosim_softc *sc = arg;
 
        if (value == 0)
-               sc->sc_state &= ~(1 << pin);
+               sc->sc_state &= ~(1LL << pin);
        else
-               sc->sc_state |= (1 << pin);
+               sc->sc_state |= (1LL << pin);
 }
 
 static void



Home | Main Index | Thread Index | Old Index