| @@ -1,221 +1,227 @@ | | | @@ -1,221 +1,227 @@ |
1 | /* $NetBSD: tegra_io.c,v 1.13 2015/08/01 21:20:11 jmcneill Exp $ */ | | 1 | /* $NetBSD: tegra_io.c,v 1.14 2015/10/17 21:18:16 jmcneill Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> | | 4 | * Copyright (c) 2015 Jared D. 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. |
15 | * | | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
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_tegra.h" | | 29 | #include "opt_tegra.h" |
30 | | | 30 | |
31 | #include <sys/cdefs.h> | | 31 | #include <sys/cdefs.h> |
32 | __KERNEL_RCSID(0, "$NetBSD: tegra_io.c,v 1.13 2015/08/01 21:20:11 jmcneill Exp $"); | | 32 | __KERNEL_RCSID(0, "$NetBSD: tegra_io.c,v 1.14 2015/10/17 21:18:16 jmcneill Exp $"); |
33 | | | 33 | |
34 | #include <sys/param.h> | | 34 | #include <sys/param.h> |
35 | #include <sys/systm.h> | | 35 | #include <sys/systm.h> |
36 | #include <sys/device.h> | | 36 | #include <sys/device.h> |
37 | | | 37 | |
38 | #include <machine/cpu.h> | | 38 | #include <machine/cpu.h> |
39 | #include <sys/bus.h> | | 39 | #include <sys/bus.h> |
40 | | | 40 | |
41 | #include <arm/mainbus/mainbus.h> | | 41 | #include <arm/mainbus/mainbus.h> |
42 | #include <arm/nvidia/tegra_reg.h> | | 42 | #include <arm/nvidia/tegra_reg.h> |
43 | #include <arm/nvidia/tegra_var.h> | | 43 | #include <arm/nvidia/tegra_var.h> |
44 | | | 44 | |
45 | #include "locators.h" | | 45 | #include "locators.h" |
46 | | | 46 | |
47 | static int tegraio_match(device_t, cfdata_t, void *); | | 47 | static int tegraio_match(device_t, cfdata_t, void *); |
48 | static void tegraio_attach(device_t, device_t, void *); | | 48 | static void tegraio_attach(device_t, device_t, void *); |
49 | | | 49 | |
50 | CFATTACH_DECL_NEW(tegra_io, 0, | | 50 | CFATTACH_DECL_NEW(tegra_io, 0, |
51 | tegraio_match, tegraio_attach, NULL, NULL); | | 51 | tegraio_match, tegraio_attach, NULL, NULL); |
52 | | | 52 | |
53 | static int tegraio_print(void *, const char *); | | 53 | static int tegraio_print(void *, const char *); |
54 | static int tegraio_find(device_t, cfdata_t, const int *, void *); | | 54 | static int tegraio_find(device_t, cfdata_t, const int *, void *); |
55 | | | 55 | |
56 | static void tegraio_scan(device_t, bus_space_handle_t, | | 56 | static void tegraio_scan(device_t, bus_space_handle_t, |
57 | const struct tegra_locators *, u_int); | | 57 | const struct tegra_locators *, u_int); |
58 | | | 58 | |
59 | static bool tegraio_found = false; | | 59 | static bool tegraio_found = false; |
60 | | | 60 | |
61 | #define NOPORT TEGRAIOCF_PORT_DEFAULT | | 61 | #define NOPORT TEGRAIOCF_PORT_DEFAULT |
62 | #define NOINTR TEGRAIO_INTR_DEFAULT | | 62 | #define NOINTR TEGRAIO_INTR_DEFAULT |
63 | | | 63 | |
64 | static const struct tegra_locators tegra_ppsb_locators[] = { | | 64 | static const struct tegra_locators tegra_ppsb_locators[] = { |
65 | { "tegracar", | | 65 | { "tegracar", |
66 | TEGRA_CAR_OFFSET, TEGRA_CAR_SIZE, NOPORT, NOINTR }, | | 66 | TEGRA_CAR_OFFSET, TEGRA_CAR_SIZE, NOPORT, NOINTR }, |
67 | { "tegragpio", | | 67 | { "tegragpio", |
68 | TEGRA_GPIO_OFFSET, TEGRA_GPIO_SIZE, NOPORT, NOINTR }, | | 68 | TEGRA_GPIO_OFFSET, TEGRA_GPIO_SIZE, NOPORT, NOINTR }, |
69 | { "tegratimer", | | 69 | { "tegratimer", |
70 | TEGRA_TIMER_OFFSET, TEGRA_TIMER_SIZE, NOPORT, NOINTR }, | | 70 | TEGRA_TIMER_OFFSET, TEGRA_TIMER_SIZE, NOPORT, NOINTR }, |
71 | }; | | 71 | }; |
72 | | | 72 | |
73 | static const struct tegra_locators tegra_apb_locators[] = { | | 73 | static const struct tegra_locators tegra_apb_locators[] = { |
74 | { "tegramc", | | 74 | { "tegramc", |
75 | TEGRA_MC_OFFSET, TEGRA_MC_SIZE, NOPORT, NOINTR }, | | 75 | TEGRA_MC_OFFSET, TEGRA_MC_SIZE, NOPORT, NOINTR }, |
76 | { "tegrapmc", | | 76 | { "tegrapmc", |
77 | TEGRA_PMC_OFFSET, TEGRA_PMC_SIZE, NOPORT, NOINTR }, | | 77 | TEGRA_PMC_OFFSET, TEGRA_PMC_SIZE, NOPORT, NOINTR }, |
78 | { "tegraxusbpad", | | 78 | { "tegraxusbpad", |
79 | TEGRA_XUSB_PADCTL_OFFSET, TEGRA_XUSB_PADCTL_SIZE, NOPORT, NOINTR }, | | 79 | TEGRA_XUSB_PADCTL_OFFSET, TEGRA_XUSB_PADCTL_SIZE, NOPORT, NOINTR }, |
80 | { "tegrampio", | | 80 | { "tegrampio", |
81 | TEGRA_MPIO_OFFSET, TEGRA_MPIO_SIZE, NOPORT, NOINTR }, | | 81 | TEGRA_MPIO_OFFSET, TEGRA_MPIO_SIZE, NOPORT, NOINTR }, |
82 | { "tegrai2c", | | 82 | { "tegrai2c", |
83 | TEGRA_I2C1_OFFSET, TEGRA_I2C1_SIZE, 0, TEGRA_INTR_I2C1 }, | | 83 | TEGRA_I2C1_OFFSET, TEGRA_I2C1_SIZE, 0, TEGRA_INTR_I2C1 }, |
84 | { "tegrai2c", | | 84 | { "tegrai2c", |
85 | TEGRA_I2C2_OFFSET, TEGRA_I2C2_SIZE, 1, TEGRA_INTR_I2C2 }, | | 85 | TEGRA_I2C2_OFFSET, TEGRA_I2C2_SIZE, 1, TEGRA_INTR_I2C2 }, |
86 | { "tegrai2c", | | 86 | { "tegrai2c", |
87 | TEGRA_I2C3_OFFSET, TEGRA_I2C3_SIZE, 2, TEGRA_INTR_I2C3 }, | | 87 | TEGRA_I2C3_OFFSET, TEGRA_I2C3_SIZE, 2, TEGRA_INTR_I2C3 }, |
88 | { "tegrai2c", | | 88 | { "tegrai2c", |
89 | TEGRA_I2C4_OFFSET, TEGRA_I2C4_SIZE, 3, TEGRA_INTR_I2C4 }, | | 89 | TEGRA_I2C4_OFFSET, TEGRA_I2C4_SIZE, 3, TEGRA_INTR_I2C4 }, |
90 | { "tegrai2c", | | 90 | { "tegrai2c", |
91 | TEGRA_I2C5_OFFSET, TEGRA_I2C5_SIZE, 4, TEGRA_INTR_I2C5 }, | | 91 | TEGRA_I2C5_OFFSET, TEGRA_I2C5_SIZE, 4, TEGRA_INTR_I2C5 }, |
92 | { "tegrai2c", | | 92 | { "tegrai2c", |
93 | TEGRA_I2C6_OFFSET, TEGRA_I2C6_SIZE, 5, TEGRA_INTR_I2C6 }, | | 93 | TEGRA_I2C6_OFFSET, TEGRA_I2C6_SIZE, 5, TEGRA_INTR_I2C6 }, |
94 | { "com", | | 94 | { "com", |
95 | TEGRA_UARTA_OFFSET, TEGRA_UARTA_SIZE, 0, TEGRA_INTR_UARTA }, | | 95 | TEGRA_UARTA_OFFSET, TEGRA_UARTA_SIZE, 0, TEGRA_INTR_UARTA }, |
96 | { "com", | | 96 | { "com", |
97 | TEGRA_UARTB_OFFSET, TEGRA_UARTB_SIZE, 1, TEGRA_INTR_UARTB }, | | 97 | TEGRA_UARTB_OFFSET, TEGRA_UARTB_SIZE, 1, TEGRA_INTR_UARTB }, |
98 | { "com", | | 98 | { "com", |
99 | TEGRA_UARTC_OFFSET, TEGRA_UARTC_SIZE, 2, TEGRA_INTR_UARTC }, | | 99 | TEGRA_UARTC_OFFSET, TEGRA_UARTC_SIZE, 2, TEGRA_INTR_UARTC }, |
100 | { "com", | | 100 | { "com", |
101 | TEGRA_UARTD_OFFSET, TEGRA_UARTD_SIZE, 3, TEGRA_INTR_UARTD }, | | 101 | TEGRA_UARTD_OFFSET, TEGRA_UARTD_SIZE, 3, TEGRA_INTR_UARTD }, |
102 | { "tegrartc", | | 102 | { "tegrartc", |
103 | TEGRA_RTC_OFFSET, TEGRA_RTC_SIZE, NOPORT, NOINTR }, | | 103 | TEGRA_RTC_OFFSET, TEGRA_RTC_SIZE, NOPORT, NOINTR }, |
104 | { "sdhc", | | 104 | { "sdhc", |
105 | TEGRA_SDMMC1_OFFSET, TEGRA_SDMMC1_SIZE, 0, TEGRA_INTR_SDMMC1 }, | | 105 | TEGRA_SDMMC1_OFFSET, TEGRA_SDMMC1_SIZE, 0, TEGRA_INTR_SDMMC1 }, |
106 | { "sdhc", | | 106 | { "sdhc", |
107 | TEGRA_SDMMC2_OFFSET, TEGRA_SDMMC2_SIZE, 1, TEGRA_INTR_SDMMC2 }, | | 107 | TEGRA_SDMMC2_OFFSET, TEGRA_SDMMC2_SIZE, 1, TEGRA_INTR_SDMMC2 }, |
108 | { "sdhc", | | 108 | { "sdhc", |
109 | TEGRA_SDMMC3_OFFSET, TEGRA_SDMMC3_SIZE, 2, TEGRA_INTR_SDMMC3 }, | | 109 | TEGRA_SDMMC3_OFFSET, TEGRA_SDMMC3_SIZE, 2, TEGRA_INTR_SDMMC3 }, |
110 | { "sdhc", | | 110 | { "sdhc", |
111 | TEGRA_SDMMC4_OFFSET, TEGRA_SDMMC4_SIZE, 3, TEGRA_INTR_SDMMC4 }, | | 111 | TEGRA_SDMMC4_OFFSET, TEGRA_SDMMC4_SIZE, 3, TEGRA_INTR_SDMMC4 }, |
112 | { "ahcisata", | | 112 | { "ahcisata", |
113 | TEGRA_SATA_OFFSET, TEGRA_SATA_SIZE, NOPORT, TEGRA_INTR_SATA }, | | 113 | TEGRA_SATA_OFFSET, TEGRA_SATA_SIZE, NOPORT, TEGRA_INTR_SATA }, |
114 | { "hdaudio", | | 114 | { "hdaudio", |
115 | TEGRA_HDA_OFFSET, TEGRA_HDA_SIZE, NOPORT, TEGRA_INTR_HDA }, | | 115 | TEGRA_HDA_OFFSET, TEGRA_HDA_SIZE, NOPORT, TEGRA_INTR_HDA }, |
116 | { "tegracec", | | 116 | { "tegracec", |
117 | TEGRA_CEC_OFFSET, TEGRA_CEC_SIZE, NOPORT, TEGRA_INTR_CEC }, | | 117 | TEGRA_CEC_OFFSET, TEGRA_CEC_SIZE, NOPORT, TEGRA_INTR_CEC }, |
118 | }; | | 118 | }; |
119 | | | 119 | |
120 | static const struct tegra_locators tegra_ahb_a2_locators[] = { | | 120 | static const struct tegra_locators tegra_ahb_a2_locators[] = { |
121 | { "ehci", | | 121 | { "ehci", |
122 | TEGRA_USB1_OFFSET, TEGRA_USB1_SIZE, 0, TEGRA_INTR_USB1 }, | | 122 | TEGRA_USB1_OFFSET, TEGRA_USB1_SIZE, 0, TEGRA_INTR_USB1 }, |
123 | { "ehci", | | 123 | { "ehci", |
124 | TEGRA_USB2_OFFSET, TEGRA_USB2_SIZE, 1, TEGRA_INTR_USB2 }, | | 124 | TEGRA_USB2_OFFSET, TEGRA_USB2_SIZE, 1, TEGRA_INTR_USB2 }, |
125 | { "ehci", | | 125 | { "ehci", |
126 | TEGRA_USB3_OFFSET, TEGRA_USB3_SIZE, 2, TEGRA_INTR_USB3 }, | | 126 | TEGRA_USB3_OFFSET, TEGRA_USB3_SIZE, 2, TEGRA_INTR_USB3 }, |
127 | }; | | 127 | }; |
128 | | | 128 | |
129 | static const struct tegra_locators tegra_pcie_locators[] = { | | 129 | static const struct tegra_locators tegra_pcie_locators[] = { |
130 | { "tegrapcie", | | 130 | { "tegrapcie", |
131 | TEGRA_PCIE_OFFSET, TEGRA_PCIE_SIZE, NOPORT, TEGRA_INTR_PCIE_INT }, | | 131 | TEGRA_PCIE_OFFSET, TEGRA_PCIE_SIZE, NOPORT, TEGRA_INTR_PCIE_INT }, |
132 | }; | | 132 | }; |
133 | | | 133 | |
134 | static const struct tegra_locators tegra_host1x_locators[] = { | | 134 | static const struct tegra_locators tegra_host1x_locators[] = { |
135 | { "tegrahost1x", 0, TEGRA_HOST1X_SIZE, NOPORT, NOINTR } | | 135 | { "tegrahost1x", 0, TEGRA_HOST1X_SIZE, NOPORT, NOINTR } |
136 | }; | | 136 | }; |
137 | | | 137 | |
138 | static const struct tegra_locators tegra_ghost_locators[] = { | | 138 | static const struct tegra_locators tegra_ghost_locators[] = { |
139 | { "tegradc", | | 139 | { "tegradc", |
140 | TEGRA_DISPLAYA_OFFSET, TEGRA_DISPLAYA_SIZE, 0, TEGRA_INTR_DISPLAYA }, | | 140 | TEGRA_DISPLAYA_OFFSET, TEGRA_DISPLAYA_SIZE, 0, TEGRA_INTR_DISPLAYA }, |
141 | { "tegradc", | | 141 | { "tegradc", |
142 | TEGRA_DISPLAYB_OFFSET, TEGRA_DISPLAYB_SIZE, 1, TEGRA_INTR_DISPLAYB }, | | 142 | TEGRA_DISPLAYB_OFFSET, TEGRA_DISPLAYB_SIZE, 1, TEGRA_INTR_DISPLAYB }, |
143 | { "tegrahdmi", | | 143 | { "tegrahdmi", |
144 | TEGRA_HDMI_OFFSET, TEGRA_HDMI_SIZE, NOPORT, TEGRA_INTR_HDMI }, | | 144 | TEGRA_HDMI_OFFSET, TEGRA_HDMI_SIZE, NOPORT, TEGRA_INTR_HDMI }, |
145 | }; | | 145 | }; |
146 | | | 146 | |
| | | 147 | static const struct tegra_locators tegra_gpu_locators[] = { |
| | | 148 | { "nouveau", 0, TEGRA_GPU_SIZE, NOPORT, NOINTR } |
| | | 149 | }; |
| | | 150 | |
147 | int | | 151 | int |
148 | tegraio_match(device_t parent, cfdata_t cf, void *aux) | | 152 | tegraio_match(device_t parent, cfdata_t cf, void *aux) |
149 | { | | 153 | { |
150 | if (tegraio_found) | | 154 | if (tegraio_found) |
151 | return 0; | | 155 | return 0; |
152 | return 1; | | 156 | return 1; |
153 | } | | 157 | } |
154 | | | 158 | |
155 | void | | 159 | void |
156 | tegraio_attach(device_t parent, device_t self, void *aux) | | 160 | tegraio_attach(device_t parent, device_t self, void *aux) |
157 | { | | 161 | { |
158 | tegraio_found = true; | | 162 | tegraio_found = true; |
159 | | | 163 | |
160 | aprint_naive("\n"); | | 164 | aprint_naive("\n"); |
161 | aprint_normal(": %s\n", tegra_chip_name()); | | 165 | aprint_normal(": %s\n", tegra_chip_name()); |
162 | | | 166 | |
163 | tegraio_scan(self, tegra_ppsb_bsh, | | 167 | tegraio_scan(self, tegra_ppsb_bsh, |
164 | tegra_ppsb_locators, __arraycount(tegra_ppsb_locators)); | | 168 | tegra_ppsb_locators, __arraycount(tegra_ppsb_locators)); |
165 | tegraio_scan(self, tegra_apb_bsh, | | 169 | tegraio_scan(self, tegra_apb_bsh, |
166 | tegra_apb_locators, __arraycount(tegra_apb_locators)); | | 170 | tegra_apb_locators, __arraycount(tegra_apb_locators)); |
167 | tegraio_scan(self, tegra_ahb_a2_bsh, | | 171 | tegraio_scan(self, tegra_ahb_a2_bsh, |
168 | tegra_ahb_a2_locators, __arraycount(tegra_ahb_a2_locators)); | | 172 | tegra_ahb_a2_locators, __arraycount(tegra_ahb_a2_locators)); |
169 | tegraio_scan(self, (bus_space_handle_t)NULL, | | 173 | tegraio_scan(self, (bus_space_handle_t)NULL, |
170 | tegra_host1x_locators, __arraycount(tegra_host1x_locators)); | | 174 | tegra_host1x_locators, __arraycount(tegra_host1x_locators)); |
171 | tegraio_scan(self, (bus_space_handle_t)NULL, | | 175 | tegraio_scan(self, (bus_space_handle_t)NULL, |
172 | tegra_ghost_locators, __arraycount(tegra_ghost_locators)); | | 176 | tegra_ghost_locators, __arraycount(tegra_ghost_locators)); |
173 | tegraio_scan(self, (bus_space_handle_t)NULL, | | 177 | tegraio_scan(self, (bus_space_handle_t)NULL, |
| | | 178 | tegra_gpu_locators, __arraycount(tegra_gpu_locators)); |
| | | 179 | tegraio_scan(self, (bus_space_handle_t)NULL, |
174 | tegra_pcie_locators, __arraycount(tegra_pcie_locators)); | | 180 | tegra_pcie_locators, __arraycount(tegra_pcie_locators)); |
175 | } | | 181 | } |
176 | | | 182 | |
177 | static void | | 183 | static void |
178 | tegraio_scan(device_t self, bus_space_handle_t bsh, | | 184 | tegraio_scan(device_t self, bus_space_handle_t bsh, |
179 | const struct tegra_locators *locators, u_int count) | | 185 | const struct tegra_locators *locators, u_int count) |
180 | { | | 186 | { |
181 | const struct tegra_locators * const eloc = locators + count; | | 187 | const struct tegra_locators * const eloc = locators + count; |
182 | for (const struct tegra_locators *loc = locators; loc < eloc; loc++) { | | 188 | for (const struct tegra_locators *loc = locators; loc < eloc; loc++) { |
183 | struct tegraio_attach_args tio = { | | 189 | struct tegraio_attach_args tio = { |
184 | .tio_loc = *loc, | | 190 | .tio_loc = *loc, |
185 | .tio_bst = &armv7_generic_bs_tag, | | 191 | .tio_bst = &armv7_generic_bs_tag, |
186 | .tio_a4x_bst = &armv7_generic_a4x_bs_tag, | | 192 | .tio_a4x_bst = &armv7_generic_a4x_bs_tag, |
187 | .tio_bsh = bsh, | | 193 | .tio_bsh = bsh, |
188 | .tio_dmat = &tegra_dma_tag, | | 194 | .tio_dmat = &tegra_dma_tag, |
189 | .tio_coherent_dmat = &tegra_coherent_dma_tag, | | 195 | .tio_coherent_dmat = &tegra_coherent_dma_tag, |
190 | }; | | 196 | }; |
191 | cfdata_t cf = config_search_ia(tegraio_find, self, | | 197 | cfdata_t cf = config_search_ia(tegraio_find, self, |
192 | "tegraio", &tio); | | 198 | "tegraio", &tio); |
193 | if (cf != NULL) | | 199 | if (cf != NULL) |
194 | config_attach(self, cf, &tio, tegraio_print); | | 200 | config_attach(self, cf, &tio, tegraio_print); |
195 | } | | 201 | } |
196 | } | | 202 | } |
197 | | | 203 | |
198 | int | | 204 | int |
199 | tegraio_print(void *aux, const char *pnp) | | 205 | tegraio_print(void *aux, const char *pnp) |
200 | { | | 206 | { |
201 | const struct tegraio_attach_args * const tio = aux; | | 207 | const struct tegraio_attach_args * const tio = aux; |
202 | | | 208 | |
203 | if (tio->tio_loc.loc_port != TEGRAIOCF_PORT_DEFAULT) | | 209 | if (tio->tio_loc.loc_port != TEGRAIOCF_PORT_DEFAULT) |
204 | aprint_normal(" port %d", tio->tio_loc.loc_port); | | 210 | aprint_normal(" port %d", tio->tio_loc.loc_port); |
205 | | | 211 | |
206 | return UNCONF; | | 212 | return UNCONF; |
207 | } | | 213 | } |
208 | | | 214 | |
209 | static int | | 215 | static int |
210 | tegraio_find(device_t parent, cfdata_t cf, const int *ldesc, void *aux) | | 216 | tegraio_find(device_t parent, cfdata_t cf, const int *ldesc, void *aux) |
211 | { | | 217 | { |
212 | const struct tegraio_attach_args * const tio = aux; | | 218 | const struct tegraio_attach_args * const tio = aux; |
213 | const struct tegra_locators * const loc = &tio->tio_loc; | | 219 | const struct tegra_locators * const loc = &tio->tio_loc; |
214 | const int port = cf->cf_loc[TEGRAIOCF_PORT]; | | 220 | const int port = cf->cf_loc[TEGRAIOCF_PORT]; |
215 | | | 221 | |
216 | if (strcmp(cf->cf_name, loc->loc_name) | | 222 | if (strcmp(cf->cf_name, loc->loc_name) |
217 | || (port != TEGRAIOCF_PORT_DEFAULT && port != loc->loc_port)) | | 223 | || (port != TEGRAIOCF_PORT_DEFAULT && port != loc->loc_port)) |
218 | return 0; | | 224 | return 0; |
219 | | | 225 | |
220 | return config_match(parent, cf, aux); | | 226 | return config_match(parent, cf, aux); |
221 | } | | 227 | } |