Source-Changes-HG archive

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

[src/trunk]: src Remove software pulsing in gpio(4), this functionality is no...



details:   https://anonhg.NetBSD.org/src/rev/7f6e02be6e48
branches:  trunk
changeset: 771168:7f6e02be6e48
user:      mbalmer <mbalmer%NetBSD.org@localhost>
date:      Sun Nov 13 13:20:02 2011 +0000

description:
Remove software pulsing in gpio(4), this functionality is now provided
by the gpiopwm(4) driver.

diffstat:

 sys/dev/gpio/gpio.c        |  90 ++-------------------------------------------
 sys/dev/gpio/gpiovar.h     |   5 +--
 sys/sys/gpio.h             |  12 +-----
 usr.sbin/gpioctl/gpioctl.8 |  22 +---------
 usr.sbin/gpioctl/gpioctl.c |  78 +--------------------------------------
 5 files changed, 12 insertions(+), 195 deletions(-)

diffs (truncated from 404 to 300 lines):

diff -r 375f38d89d95 -r 7f6e02be6e48 sys/dev/gpio/gpio.c
--- a/sys/dev/gpio/gpio.c       Sun Nov 13 13:16:33 2011 +0000
+++ b/sys/dev/gpio/gpio.c       Sun Nov 13 13:20:02 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpio.c,v 1.46 2011/10/03 11:31:56 mbalmer Exp $ */
+/* $NetBSD: gpio.c,v 1.47 2011/11/13 13:20:02 mbalmer 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.46 2011/10/03 11:31:56 mbalmer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.47 2011/11/13 13:20:02 mbalmer Exp $");
 
 /*
  * General Purpose Input/Output framework.
@@ -81,7 +81,6 @@
 static int     gpio_search(device_t, cfdata_t, const int *, void *);
 static int     gpio_print(void *, const char *);
 static int     gpio_pinbyname(struct gpio_softc *, char *);
-static void    gpio_pulse(void *);
 static int     gpio_ioctl(struct gpio_softc *, u_long, void *, int,
     struct lwp *);
 
@@ -193,7 +192,7 @@
 {
        struct gpio_softc *sc = device_private(self);
        struct gpiobus_attach_args *gba = aux;
-       int pin;
+
        sc->sc_dev = self;
        sc->sc_gc = gba->gba_gc;
        sc->sc_pins = gba->gba_pins;
@@ -201,11 +200,6 @@
 
        printf(": %d pins\n", sc->sc_npins);
 
-       for (pin = 0; pin < sc->sc_npins; pin++) {
-               callout_init(&sc->sc_pins[pin].pin_pulse, CALLOUT_MPSAFE);
-               callout_setfunc(&sc->sc_pins[pin].pin_pulse, gpio_pulse,
-                    &sc->sc_pins[pin]);
-       }
        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);
@@ -222,18 +216,10 @@
 gpio_detach(device_t self, int flags)
 {
        struct gpio_softc *sc;
-       int pin, rc;
+       int rc;
 
        sc = device_private(self);
 
-       for (pin = 0; pin < sc->sc_npins; pin++) {
-               if (sc->sc_pins[pin].pin_state & GPIO_PIN_PULSE) {
-                       callout_halt(&sc->sc_pins[pin].pin_pulse, NULL);
-                       callout_destroy(&sc->sc_pins[pin].pin_pulse);
-                       sc->sc_pins[pin].pin_state &= ~GPIO_PIN_PULSE;
-               }
-       }
-
        if ((rc = config_detach_children(self, flags)) != 0)
                return rc;
        mutex_destroy(&sc->sc_mtx);
@@ -465,26 +451,6 @@
         return -1;
 }
 
-static void
-gpio_pulse(void *arg)
-{
-       struct gpio_pin *pin;
-
-       pin = arg;
-       if ((pin->pin_state & GPIO_PIN_PULSE) == 0)
-               return;
-
-       if (pin->pin_state & GPIO_PIN_HIGH) {
-               gpiobus_pin_write(pin->pin_gc, pin->pin_num, GPIO_PIN_LOW);
-               pin->pin_state &= ~GPIO_PIN_HIGH;
-               callout_schedule(&pin->pin_pulse, pin->pin_ticks_off);
-       } else {
-               gpiobus_pin_write(pin->pin_gc, pin->pin_num, GPIO_PIN_HIGH);
-               pin->pin_state |= GPIO_PIN_HIGH;
-               callout_schedule(&pin->pin_pulse, pin->pin_ticks_on);
-       }
-}
-
 int
 gpioioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
 {
@@ -511,7 +477,6 @@
        struct gpio_attach *attach;
        struct gpio_attach_args ga;
        struct gpio_req *req;
-       struct gpio_pulse *pulse;
        struct gpio_name *nm;
        struct gpio_set *set;
        struct gpio_pin *gpin;
@@ -593,59 +558,12 @@
                if (value != GPIO_PIN_LOW && value != GPIO_PIN_HIGH)
                        return EINVAL;
 
-               if (sc->sc_pins[pin].pin_state & GPIO_PIN_PULSE) {
-                       callout_halt(&sc->sc_pins[pin].pin_pulse, NULL);
-                       sc->sc_pins[pin].pin_state &= ~GPIO_PIN_PULSE;
-               }
                gpiobus_pin_write(gc, pin, value);
                /* return old value */
                req->gp_value = sc->sc_pins[pin].pin_state;
                /* update current value */
                sc->sc_pins[pin].pin_state = value;
                break;
-       case GPIOPULSE:
-               if ((flag & FWRITE) == 0)
-                       return EBADF;
-
-               pulse = data;
-               if (pulse->gp_name[0] != '\0')
-                       pin = gpio_pinbyname(sc, pulse->gp_name);
-               else
-                       pin = pulse->gp_pin;
-
-               if (pin < 0 || pin >= sc->sc_npins)
-                       return EINVAL;
-
-               gpin = &sc->sc_pins[pin];
-               if (gpin->pin_mapped)
-                       return EBUSY;
-
-               if (!(gpin->pin_flags & GPIO_PIN_SET) &&
-                   kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
-                   NULL, NULL, NULL, NULL))
-                       return EPERM;
-
-               if (gpin->pin_flags & GPIO_PIN_PULSATE) {
-                       gpiobus_pin_write(gc, pin, GPIO_PIN_HIGH);
-                       gpin->pin_state = GPIO_PIN_PULSE;
-                       return 0;
-               }
-
-               if (gpin->pin_state & GPIO_PIN_PULSE)
-                       callout_halt(&gpin->pin_pulse, NULL);
-
-               gpin->pin_gc = gc;
-
-               gpin->pin_ticks_on = tvtohz(&pulse->gp_pulse_on);
-               gpin->pin_ticks_off = tvtohz(&pulse->gp_pulse_off);
-               if (gpin->pin_ticks_on == 0 || gpin->pin_ticks_off == 0) {
-                       gpin->pin_ticks_on = hz / 2;
-                       gpin->pin_ticks_off = hz / 2;
-               }
-               gpiobus_pin_write(gc, pin, GPIO_PIN_HIGH);
-               gpin->pin_state = GPIO_PIN_HIGH | GPIO_PIN_PULSE;
-               callout_schedule(&gpin->pin_pulse, gpin->pin_ticks_on);
-               break;
        case GPIOTOGGLE:
                if ((flag & FWRITE) == 0)
                        return EBADF;
diff -r 375f38d89d95 -r 7f6e02be6e48 sys/dev/gpio/gpiovar.h
--- a/sys/dev/gpio/gpiovar.h    Sun Nov 13 13:16:33 2011 +0000
+++ b/sys/dev/gpio/gpiovar.h    Sun Nov 13 13:20:02 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpiovar.h,v 1.14 2011/10/02 09:33:19 mbalmer Exp $ */
+/* $NetBSD: gpiovar.h,v 1.15 2011/11/13 13:20:02 mbalmer Exp $ */
 /*     $OpenBSD: gpiovar.h,v 1.3 2006/01/14 12:33:49 grange Exp $      */
 
 /*
@@ -40,9 +40,6 @@
        int                     pin_flags;      /* current configuration */
        int                     pin_state;      /* current state */
        int                     pin_mapped;     /* is mapped */
-       callout_t               pin_pulse;      /* for pulsing */
-       int                     pin_ticks_on;   /* "on" period */
-       int                     pin_ticks_off;  /* "off" period */
        gpio_chipset_tag_t      pin_gc;         /* reference the controller */
 } gpio_pin_t;
 
diff -r 375f38d89d95 -r 7f6e02be6e48 sys/sys/gpio.h
--- a/sys/sys/gpio.h    Sun Nov 13 13:16:33 2011 +0000
+++ b/sys/sys/gpio.h    Sun Nov 13 13:20:02 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpio.h,v 1.11 2011/10/03 11:16:47 mbalmer Exp $ */
+/* $NetBSD: gpio.h,v 1.12 2011/11/13 13:20:02 mbalmer Exp $ */
 /*     $OpenBSD: gpio.h,v 1.7 2008/11/26 14:51:20 mbalmer Exp $        */
 /*
  * Copyright (c) 2009, 2011 Marc Balmer <marc%msys.ch@localhost>
@@ -25,7 +25,6 @@
 /* GPIO pin states */
 #define GPIO_PIN_LOW           0x00    /* low level (logical 0) */
 #define GPIO_PIN_HIGH          0x01    /* high level (logical 1) */
-#define GPIO_PIN_PULSE         0x02    /* pulsing, or-ed with state */
 
 /* Max name length of a pin */
 #define GPIOMAXNAME            64
@@ -59,14 +58,6 @@
        int             gp_value;               /* value */
 };
 
-/* GPIO pulse request */
-struct gpio_pulse {
-       char            gp_name[GPIOMAXNAME];   /* pin name */
-       int             gp_pin;                 /* pin number */
-       struct timeval  gp_pulse_on;            /* "on" period */
-       struct timeval  gp_pulse_off;           /* "off" period */
-};
-
 /* GPIO pin configuration */
 struct gpio_set {
        char    gp_name[GPIOMAXNAME];
@@ -92,7 +83,6 @@
 #define GPIOWRITE              _IOWR('G', 8, struct gpio_req)
 #define GPIOTOGGLE             _IOWR('G', 9, struct gpio_req)
 #define GPIOATTACH             _IOWR('G', 10, struct gpio_attach)
-#define GPIOPULSE              _IOWR('G', 12, struct gpio_pulse)
 
 #ifdef COMPAT_50
 /* Old structure to attach/detach devices */
diff -r 375f38d89d95 -r 7f6e02be6e48 usr.sbin/gpioctl/gpioctl.8
--- a/usr.sbin/gpioctl/gpioctl.8        Sun Nov 13 13:16:33 2011 +0000
+++ b/usr.sbin/gpioctl/gpioctl.8        Sun Nov 13 13:20:02 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpioctl.8,v 1.14 2011/10/06 11:06:44 wiz Exp $
+.\" $NetBSD: gpioctl.8,v 1.15 2011/11/13 13:20:02 mbalmer Exp $
 .\"
 .\" Copyright (c) 2009, 2010, 2011 Marc Balmer <marc%msys.ch@localhost>
 .\" Copyright (c) 2004 Alexander Yurchenko <grange%openbsd.org@localhost>
@@ -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 October 3, 2011
+.Dd November 13, 2011
 .Dt GPIOCTL 8
 .Os
 .Sh NAME
@@ -41,11 +41,6 @@
 .Ar pin
 .Op Ar on | off | toggle
 .Nm gpioctl
-.Op Fl q
-.Ar device
-.Ar pin
-.Cm pulse
-.Op Ar frequency Op Ar duty cycle
 .Nm gpioctl
 .Op Fl q
 .Ar device
@@ -105,17 +100,6 @@
 can be used.
 .Pp
 To
-.Dq pulse
-a pin, use the pulse command line option with an optional frequency value
-in hertz and an optional duty cycle in percent.
-If no frequency is specified, 1 Hz is assumed.
-If no duty cycle is specified, 50% are assumed.
-If the underlying hardware is not capable of pulsing in hardware,
-pulsing is done in software using the
-.Xr callout 9
-facility.
-The frequency and duty cycle arguments are ignored for pins that are able to
-pulse in hardware.
 .Pp
 Only pins that have been configured at securelevel 0, typically during system
 startup, are accessible once the securelevel has been raised.
@@ -227,5 +211,5 @@
 .Nm
 program was written by
 .An Alexander Yurchenko Aq grange%openbsd.org@localhost .
-Device attachment and pulsing was added by
+Device attachment was added by
 .An Marc Balmer Aq marc%msys.ch@localhost .
diff -r 375f38d89d95 -r 7f6e02be6e48 usr.sbin/gpioctl/gpioctl.c
--- a/usr.sbin/gpioctl/gpioctl.c        Sun Nov 13 13:16:33 2011 +0000
+++ b/usr.sbin/gpioctl/gpioctl.c        Sun Nov 13 13:20:02 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpioctl.c,v 1.18 2011/11/12 16:34:03 mbalmer Exp $ */
+/* $NetBSD: gpioctl.c,v 1.19 2011/11/13 13:20:02 mbalmer Exp $ */
 
 /*
  * Copyright (c) 2008, 2010, 2011 Marc Balmer <mbalmer%NetBSD.org@localhost>
@@ -43,7 +43,6 @@
 static void getinfo(void);
 static void gpioread(int, char *);
 static void gpiowrite(int, char *, int);
-static void gpiopulse(int, char *, double, double);
 static void gpioset(int pin, char *name, int flags, char *alias);
 static void gpiounset(int pin, char *name);
 static void devattach(char *, int, uint32_t, uint32_t);
@@ -74,7 +73,6 @@
 main(int argc, char *argv[])
 {
        const struct bitstr *bs;
-       double freq, dc;
        int pin, ch, n, fl = 0, value = 0;
        const char *errstr;



Home | Main Index | Thread Index | Old Index