| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: exynos_pinctrl.c,v 1.21 2021/01/27 03:10:19 thorpej Exp $ */ | | 1 | /* $NetBSD: exynos_pinctrl.c,v 1.22 2022/02/11 23:48:41 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2015, 2020 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2015, 2020 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Marty Fouts, and by Nick Hudson | | 8 | * by Marty Fouts, and by Nick Hudson |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -24,34 +24,33 @@ | | | @@ -24,34 +24,33 @@ |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include "opt_exynos.h" | | 32 | #include "opt_exynos.h" |
33 | #include "opt_arm_debug.h" | | 33 | #include "opt_arm_debug.h" |
34 | #include "gpio.h" | | 34 | #include "gpio.h" |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | __KERNEL_RCSID(1, "$NetBSD: exynos_pinctrl.c,v 1.21 2021/01/27 03:10:19 thorpej Exp $"); | | 37 | __KERNEL_RCSID(1, "$NetBSD: exynos_pinctrl.c,v 1.22 2022/02/11 23:48:41 riastradh Exp $"); |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | #include <sys/bus.h> | | 40 | #include <sys/bus.h> |
41 | #include <sys/device.h> | | 41 | #include <sys/device.h> |
42 | #include <sys/intr.h> | | 42 | #include <sys/intr.h> |
43 | #include <sys/systm.h> | | 43 | #include <sys/systm.h> |
44 | #include <sys/kmem.h> | | | |
45 | #include <sys/gpio.h> | | 44 | #include <sys/gpio.h> |
46 | | | 45 | |
47 | #include <dev/gpio/gpiovar.h> | | 46 | #include <dev/gpio/gpiovar.h> |
48 | | | 47 | |
49 | #include <arm/samsung/exynos_reg.h> | | 48 | #include <arm/samsung/exynos_reg.h> |
50 | #include <arm/samsung/exynos_var.h> | | 49 | #include <arm/samsung/exynos_var.h> |
51 | #include <arm/samsung/exynos_intr.h> | | 50 | #include <arm/samsung/exynos_intr.h> |
52 | #include <arm/samsung/exynos_pinctrl.h> | | 51 | #include <arm/samsung/exynos_pinctrl.h> |
53 | | | 52 | |
54 | #include <dev/fdt/fdtvar.h> | | 53 | #include <dev/fdt/fdtvar.h> |
55 | | | 54 | |
56 | struct exynos_pinctrl_config { | | 55 | struct exynos_pinctrl_config { |
57 | int pc_phandle; | | 56 | int pc_phandle; |
| @@ -83,41 +82,39 @@ static const struct device_compatible_en | | | @@ -83,41 +82,39 @@ static const struct device_compatible_en |
83 | }; | | 82 | }; |
84 | | | 83 | |
85 | static int | | 84 | static int |
86 | exynos_pinctrl_match(device_t parent, cfdata_t cf, void *aux) | | 85 | exynos_pinctrl_match(device_t parent, cfdata_t cf, void *aux) |
87 | { | | 86 | { |
88 | struct fdt_attach_args * const faa = aux; | | 87 | struct fdt_attach_args * const faa = aux; |
89 | | | 88 | |
90 | return of_compatible_match(faa->faa_phandle, compat_data); | | 89 | return of_compatible_match(faa->faa_phandle, compat_data); |
91 | } | | 90 | } |
92 | | | 91 | |
93 | static void | | 92 | static void |
94 | exynos_pinctrl_attach(device_t parent, device_t self, void *aux) | | 93 | exynos_pinctrl_attach(device_t parent, device_t self, void *aux) |
95 | { | | 94 | { |
96 | struct exynos_pinctrl_softc * const sc | | 95 | struct exynos_pinctrl_softc * const sc = device_private(self); |
97 | = kmem_zalloc(sizeof(*sc), KM_SLEEP); | | | |
98 | struct fdt_attach_args * const faa = aux; | | 96 | struct fdt_attach_args * const faa = aux; |
99 | bus_addr_t addr; | | 97 | bus_addr_t addr; |
100 | bus_size_t size; | | 98 | bus_size_t size; |
101 | int error; | | 99 | int error; |
102 | int child; | | 100 | int child; |
103 | | | 101 | |
104 | if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) { | | 102 | if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) { |
105 | aprint_error(": couldn't get registers\n"); | | 103 | aprint_error(": couldn't get registers\n"); |
106 | return; | | 104 | return; |
107 | } | | 105 | } |
108 | | | 106 | |
109 | aprint_normal(" pinctrl @ 0x%08x ", (uint)addr); | | 107 | aprint_normal(" pinctrl @ 0x%08x ", (uint)addr); |
110 | self->dv_private = sc; | | | |
111 | sc->sc_dev = self; | | 108 | sc->sc_dev = self; |
112 | sc->sc_bst = faa->faa_bst; | | 109 | sc->sc_bst = faa->faa_bst; |
113 | sc->sc_epb = of_compatible_lookup(faa->faa_phandle, compat_data)->data; | | 110 | sc->sc_epb = of_compatible_lookup(faa->faa_phandle, compat_data)->data; |
114 | | | 111 | |
115 | error = bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh); | | 112 | error = bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh); |
116 | if (error) { | | 113 | if (error) { |
117 | aprint_error(": couldn't map %#" PRIxBUSADDR ": %d", | | 114 | aprint_error(": couldn't map %#" PRIxBUSADDR ": %d", |
118 | addr, error); | | 115 | addr, error); |
119 | return; | | 116 | return; |
120 | } | | 117 | } |
121 | | | 118 | |
122 | aprint_naive("\n"); | | 119 | aprint_naive("\n"); |
123 | aprint_normal("\n"); | | 120 | aprint_normal("\n"); |