| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sunxi_gpio.c,v 1.31 2021/01/18 02:35:49 thorpej Exp $ */ | | 1 | /* $NetBSD: sunxi_gpio.c,v 1.32 2021/01/18 13:29:37 skrll Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> | | 4 | * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -19,27 +19,27 @@ | | | @@ -19,27 +19,27 @@ |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
26 | * SUCH DAMAGE. | | 26 | * SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include "opt_soc.h" | | 29 | #include "opt_soc.h" |
30 | | | 30 | |
31 | #include <sys/cdefs.h> | | 31 | #include <sys/cdefs.h> |
32 | __KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.31 2021/01/18 02:35:49 thorpej Exp $"); | | 32 | __KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.32 2021/01/18 13:29:37 skrll Exp $"); |
33 | | | 33 | |
34 | #include <sys/param.h> | | 34 | #include <sys/param.h> |
35 | #include <sys/bus.h> | | 35 | #include <sys/bus.h> |
36 | #include <sys/device.h> | | 36 | #include <sys/device.h> |
37 | #include <sys/intr.h> | | 37 | #include <sys/intr.h> |
38 | #include <sys/systm.h> | | 38 | #include <sys/systm.h> |
39 | #include <sys/mutex.h> | | 39 | #include <sys/mutex.h> |
40 | #include <sys/kmem.h> | | 40 | #include <sys/kmem.h> |
41 | #include <sys/gpio.h> | | 41 | #include <sys/gpio.h> |
42 | #include <sys/bitops.h> | | 42 | #include <sys/bitops.h> |
43 | #include <sys/lwp.h> | | 43 | #include <sys/lwp.h> |
44 | | | 44 | |
45 | #include <dev/fdt/fdtvar.h> | | 45 | #include <dev/fdt/fdtvar.h> |
| @@ -76,27 +76,27 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c | | | @@ -76,27 +76,27 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c |
76 | #define SUNXI_GPIO_INT_DEBOUNCE_CLK_PRESCALE __BITS(6,4) | | 76 | #define SUNXI_GPIO_INT_DEBOUNCE_CLK_PRESCALE __BITS(6,4) |
77 | #define SUNXI_GPIO_INT_DEBOUNCE_CLK_SEL __BIT(0) | | 77 | #define SUNXI_GPIO_INT_DEBOUNCE_CLK_SEL __BIT(0) |
78 | #define SUNXI_GPIO_GRP_CONFIG(bank) (0x300 + 0x4 * (bank)) | | 78 | #define SUNXI_GPIO_GRP_CONFIG(bank) (0x300 + 0x4 * (bank)) |
79 | #define SUNXI_GPIO_GRP_IO_BIAS_CONFIGMASK 0xf | | 79 | #define SUNXI_GPIO_GRP_IO_BIAS_CONFIGMASK 0xf |
80 | | | 80 | |
81 | static const struct device_compatible_entry compat_data[] = { | | 81 | static const struct device_compatible_entry compat_data[] = { |
82 | #ifdef SOC_SUN4I_A10 | | 82 | #ifdef SOC_SUN4I_A10 |
83 | { .compat = "allwinner,sun4i-a10-pinctrl", | | 83 | { .compat = "allwinner,sun4i-a10-pinctrl", |
84 | .data = &sun4i_a10_padconf }, | | 84 | .data = &sun4i_a10_padconf }, |
85 | #endif | | 85 | #endif |
86 | #ifdef SOC_SUN5I_A13 | | 86 | #ifdef SOC_SUN5I_A13 |
87 | { .compat = "allwinner,sun5i-a13-pinctrl", | | 87 | { .compat = "allwinner,sun5i-a13-pinctrl", |
88 | .data = &sun5i_a13_padconf }, | | 88 | .data = &sun5i_a13_padconf }, |
89 | { .compat = "nextthing,gr8-pinctrl", | | 89 | { .compat = "nextthing,gr8-pinctrl", |
90 | .data = &sun5i_a13_padconf }, | | 90 | .data = &sun5i_a13_padconf }, |
91 | #endif | | 91 | #endif |
92 | #ifdef SOC_SUN6I_A31 | | 92 | #ifdef SOC_SUN6I_A31 |
93 | { .compat = "allwinner,sun6i-a31-pinctrl", | | 93 | { .compat = "allwinner,sun6i-a31-pinctrl", |
94 | .data = &sun6i_a31_padconf }, | | 94 | .data = &sun6i_a31_padconf }, |
95 | { .compat = "allwinner,sun6i-a31-r-pinctrl", | | 95 | { .compat = "allwinner,sun6i-a31-r-pinctrl", |
96 | .data = &sun6i_a31_r_padconf }, | | 96 | .data = &sun6i_a31_r_padconf }, |
97 | #endif | | 97 | #endif |
98 | #ifdef SOC_SUN7I_A20 | | 98 | #ifdef SOC_SUN7I_A20 |
99 | { .compat = "allwinner,sun7i-a20-pinctrl", | | 99 | { .compat = "allwinner,sun7i-a20-pinctrl", |
100 | .data = &sun7i_a20_padconf }, | | 100 | .data = &sun7i_a20_padconf }, |
101 | #endif | | 101 | #endif |
102 | #ifdef SOC_SUN8I_A83T | | 102 | #ifdef SOC_SUN8I_A83T |
| @@ -459,27 +459,27 @@ sunxi_gpio_intr(void *priv) | | | @@ -459,27 +459,27 @@ sunxi_gpio_intr(void *priv) |
459 | } | | 459 | } |
460 | } | | 460 | } |
461 | | | 461 | |
462 | return ret; | | 462 | return ret; |
463 | } | | 463 | } |
464 | | | 464 | |
465 | static void * | | 465 | static void * |
466 | sunxi_intr_enable(struct sunxi_gpio_softc *sc, | | 466 | sunxi_intr_enable(struct sunxi_gpio_softc *sc, |
467 | const struct sunxi_gpio_pins *pin_def, u_int mode, bool mpsafe, | | 467 | const struct sunxi_gpio_pins *pin_def, u_int mode, bool mpsafe, |
468 | int (*func)(void *), void *arg) | | 468 | int (*func)(void *), void *arg) |
469 | { | | 469 | { |
470 | uint32_t val; | | 470 | uint32_t val; |
471 | struct sunxi_gpio_eint *eint; | | 471 | struct sunxi_gpio_eint *eint; |
472 | | | 472 | |
473 | if (pin_def->functions[pin_def->eint_func] == NULL || | | 473 | if (pin_def->functions[pin_def->eint_func] == NULL || |
474 | strcmp(pin_def->functions[pin_def->eint_func], "irq") != 0) | | 474 | strcmp(pin_def->functions[pin_def->eint_func], "irq") != 0) |
475 | return NULL; | | 475 | return NULL; |
476 | | | 476 | |
477 | KASSERT(pin_def->eint_num < SUNXI_GPIO_MAX_EINT); | | 477 | KASSERT(pin_def->eint_num < SUNXI_GPIO_MAX_EINT); |
478 | | | 478 | |
479 | mutex_enter(&sc->sc_lock); | | 479 | mutex_enter(&sc->sc_lock); |
480 | | | 480 | |
481 | eint = &sc->sc_eint[pin_def->eint_bank][pin_def->eint_num]; | | 481 | eint = &sc->sc_eint[pin_def->eint_bank][pin_def->eint_num]; |
482 | if (eint->eint_func != NULL) { | | 482 | if (eint->eint_func != NULL) { |
483 | mutex_exit(&sc->sc_lock); | | 483 | mutex_exit(&sc->sc_lock); |
484 | return NULL; /* in use */ | | 484 | return NULL; /* in use */ |
485 | } | | 485 | } |