Module Name: src Committed By: hkenken Date: Wed Nov 27 07:26:08 UTC 2019
Modified Files: src/sys/arch/arm/imx: imxgpio.c src/sys/arch/arm/imx/fdt: imx6_gpio.c src/sys/dev/spi: spi.c spivar.h Log Message: Remove GPIO driver attach defer. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/imxgpio.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/fdt/imx6_gpio.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/spi/spi.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/spi/spivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/imx/imxgpio.c diff -u src/sys/arch/arm/imx/imxgpio.c:1.6 src/sys/arch/arm/imx/imxgpio.c:1.7 --- src/sys/arch/arm/imx/imxgpio.c:1.6 Wed Jul 24 12:33:18 2019 +++ src/sys/arch/arm/imx/imxgpio.c Wed Nov 27 07:26:08 2019 @@ -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 @@ imxgpio_pin_ctl(void *arg, int pin, int } 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_attach_common(device_t self) imxgpio_handles[gpio->gpio_unit] = gpio; #if NGPIO > 0 - config_interrupts(self, gpio_defer); + imxgpio_attach_ports(gpio); #endif } Index: src/sys/arch/arm/imx/fdt/imx6_gpio.c diff -u src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.3 src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.4 --- src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.3 Sun Nov 24 11:07:19 2019 +++ src/sys/arch/arm/imx/fdt/imx6_gpio.c Wed Nov 27 07:26:08 2019 @@ -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 @@ imxgpio_attach(device_t parent, device_t 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 @@ imxgpio_attach(device_t parent, device_t 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); Index: src/sys/dev/spi/spi.c diff -u src/sys/dev/spi/spi.c:1.12 src/sys/dev/spi/spi.c:1.13 --- src/sys/dev/spi/spi.c:1.12 Tue Aug 13 16:37:15 2019 +++ src/sys/dev/spi/spi.c Wed Nov 27 07:26:08 2019 @@ -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 @@ spi_direct_attach_child_devices(device_t 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); Index: src/sys/dev/spi/spivar.h diff -u src/sys/dev/spi/spivar.h:1.8 src/sys/dev/spi/spivar.h:1.9 --- src/sys/dev/spi/spivar.h:1.8 Tue Aug 13 16:37:15 2019 +++ src/sys/dev/spi/spivar.h Wed Nov 27 07:26:08 2019 @@ -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 @@ struct spi_attach_args { 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 */ }; /*