Source-Changes-HG archive

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

[src/trunk]: src/sys Remove GPIO driver attach defer.



details:   https://anonhg.NetBSD.org/src/rev/d9932ebbc587
branches:  trunk
changeset: 465525:d9932ebbc587
user:      hkenken <hkenken%NetBSD.org@localhost>
date:      Wed Nov 27 07:26:08 2019 +0000

description:
Remove GPIO driver attach defer.

diffstat:

 sys/arch/arm/imx/fdt/imx6_gpio.c |  12 ++++++------
 sys/arch/arm/imx/imxgpio.c       |  35 ++++++++++++++++-------------------
 sys/dev/spi/spi.c                |   6 ++++--
 sys/dev/spi/spivar.h             |   4 +++-
 4 files changed, 29 insertions(+), 28 deletions(-)

diffs (166 lines):

diff -r bb02862dd9c3 -r d9932ebbc587 sys/arch/arm/imx/fdt/imx6_gpio.c
--- a/sys/arch/arm/imx/fdt/imx6_gpio.c  Wed Nov 27 06:24:33 2019 +0000
+++ b/sys/arch/arm/imx/fdt/imx6_gpio.c  Wed Nov 27 07:26:08 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: imx6_gpio.c,v 1.3 2019/11/24 11:07:19 skrll Exp $      */
+/*     $NetBSD: imx6_gpio.c,v 1.4 2019/11/27 07:26:08 hkenken Exp $    */
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imx6_gpio.c,v 1.3 2019/11/24 11:07:19 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_gpio.c,v 1.4 2019/11/27 07:26:08 hkenken Exp $");
 
 #include "opt_fdt.h"
 #include "gpio.h"
@@ -123,8 +123,8 @@
                aprint_error_dev(self, "failed to decode interrupt\n");
                return;
        }
-       sc->gpio_is = fdtbus_intr_establish(phandle, 0, IPL_HIGH,
-           FDT_INTR_MPSAFE, pic_handle_intr, &sc->gpio_pic);
+       sc->gpio_is = fdtbus_intr_establish(phandle, 0, IPL_HIGH, 0,
+           pic_handle_intr, &sc->gpio_pic);
        if (sc->gpio_is == NULL) {
                aprint_error_dev(self, "couldn't establish interrupt on %s\n",
                    intrstr);
@@ -136,8 +136,8 @@
                aprint_error_dev(self, "failed to decode interrupt\n");
                return;
        }
-       sc->gpio_is_high = fdtbus_intr_establish(phandle, 1, IPL_HIGH,
-           FDT_INTR_MPSAFE, pic_handle_intr, &sc->gpio_pic);
+       sc->gpio_is_high = fdtbus_intr_establish(phandle, 1, IPL_HIGH, 0,
+           pic_handle_intr, &sc->gpio_pic);
        if (sc->gpio_is_high == NULL) {
                aprint_error_dev(self, "couldn't establish interrupt on %s\n",
                    intrstr);
diff -r bb02862dd9c3 -r d9932ebbc587 sys/arch/arm/imx/imxgpio.c
--- a/sys/arch/arm/imx/imxgpio.c        Wed Nov 27 06:24:33 2019 +0000
+++ b/sys/arch/arm/imx/imxgpio.c        Wed Nov 27 07:26:08 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: imxgpio.c,v 1.6 2019/07/24 12:33:18 hkenken Exp $ */
+/*     $NetBSD: imxgpio.c,v 1.7 2019/11/27 07:26:08 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imxgpio.c,v 1.6 2019/07/24 12:33:18 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imxgpio.c,v 1.7 2019/11/27 07:26:08 hkenken Exp $");
 
 #define        _INTR_PRIVATE
 
@@ -288,40 +288,37 @@
 }
 
 static void
-gpio_defer(device_t self)
+imxgpio_attach_ports(struct imxgpio_softc *gpio)
 {
-       struct imxgpio_softc * const gpio = device_private(self);
        struct gpio_chipset_tag * const gp = &gpio->gpio_chipset;
        struct gpiobus_attach_args gba;
-       gpio_pin_t *pins;
-       uint32_t mask, dir, value;
-       int pin;
+       uint32_t dir;
+       u_int pin;
 
        gp->gp_cookie = gpio;
        gp->gp_pin_read = imxgpio_pin_read;
        gp->gp_pin_write = imxgpio_pin_write;
        gp->gp_pin_ctl = imxgpio_pin_ctl;
 
-       gba.gba_gc = gp;
-       gba.gba_pins = gpio->gpio_pins;
-       gba.gba_npins = __arraycount(gpio->gpio_pins);
-
        dir = GPIO_READ(gpio, GPIO_DIR);
-       value = GPIO_READ(gpio, GPIO_DR);
-       for (pin = 0, mask = 1, pins = gpio->gpio_pins;
-            pin < 32; pin++, mask <<= 1, pins++) {
+       for (pin = 0; pin < __arraycount(gpio->gpio_pins); pin++) {
+               uint32_t mask = __BIT(pin);
+               gpio_pin_t *pins = &gpio->gpio_pins[pin];
                pins->pin_num = pin;
                if ((gpio->gpio_edge_mask | gpio->gpio_level_mask) & mask)
                        pins->pin_caps = GPIO_PIN_INPUT;
                else
-                       pins->pin_caps = GPIO_PIN_INPUT|GPIO_PIN_OUTPUT;
+                       pins->pin_caps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT;
                pins->pin_flags =
                    (dir & mask) ? GPIO_PIN_OUTPUT : GPIO_PIN_INPUT;
-               pins->pin_state =
-                   (value & mask) ? GPIO_PIN_HIGH : GPIO_PIN_LOW;
+               pins->pin_state = imxgpio_pin_read(gpio, pin);
        }
 
-       config_found_ia(self, "gpiobus", &gba, gpiobus_print);
+       memset(&gba, 0, sizeof(gba));
+       gba.gba_gc = gp;
+       gba.gba_pins = gpio->gpio_pins;
+       gba.gba_npins = __arraycount(gpio->gpio_pins);
+       config_found_ia(gpio->gpio_dev, "gpiobus", &gba, gpiobus_print);
 }
 #endif /* NGPIO > 0 */
 
@@ -351,7 +348,7 @@
        imxgpio_handles[gpio->gpio_unit] = gpio;
 
 #if NGPIO > 0
-       config_interrupts(self, gpio_defer);
+       imxgpio_attach_ports(gpio);
 #endif
 }
 
diff -r bb02862dd9c3 -r d9932ebbc587 sys/dev/spi/spi.c
--- a/sys/dev/spi/spi.c Wed Nov 27 06:24:33 2019 +0000
+++ b/sys/dev/spi/spi.c Wed Nov 27 07:26:08 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spi.c,v 1.12 2019/08/13 16:37:15 tnn Exp $ */
+/* $NetBSD: spi.c,v 1.13 2019/11/27 07:26:08 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.12 2019/08/13 16:37:15 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.13 2019/11/27 07:26:08 hkenken Exp $");
 
 #include "locators.h"
 
@@ -239,6 +239,8 @@
 
                memset(&sa, 0, sizeof sa);
                sa.sa_handle = &sc->sc_slaves[i];
+               sa.sa_prop = child;
+               sa.sa_cookie = cookie;
                if (ISSET(sa.sa_handle->sh_flags, SPIH_ATTACHED))
                        continue;
                SET(sa.sa_handle->sh_flags, SPIH_ATTACHED);
diff -r bb02862dd9c3 -r d9932ebbc587 sys/dev/spi/spivar.h
--- a/sys/dev/spi/spivar.h      Wed Nov 27 06:24:33 2019 +0000
+++ b/sys/dev/spi/spivar.h      Wed Nov 27 07:26:08 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spivar.h,v 1.8 2019/08/13 16:37:15 tnn Exp $ */
+/* $NetBSD: spivar.h,v 1.9 2019/11/27 07:26:08 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -87,6 +87,8 @@
                                           ia_compat array */
        const char **   sa_compat;      /* chip names */
        prop_dictionary_t sa_prop;      /* dictionary for this device */
+
+       uintptr_t       sa_cookie;      /* OF node in openfirmware machines */
 };
 
 /*



Home | Main Index | Thread Index | Old Index