| @@ -1,475 +1,475 @@ | | | @@ -1,475 +1,475 @@ |
1 | /* $NetBSD: fdtvar.h,v 1.74 2022/01/14 07:40:52 skrll Exp $ */ | | 1 | /* $NetBSD: fdtvar.h,v 1.75 2022/02/23 07:55:55 skrll 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 | #ifndef _DEV_FDT_FDTVAR_H_ | | 29 | #ifndef _DEV_FDT_FDTVAR_H_ |
30 | #define _DEV_FDT_FDTVAR_H_ | | 30 | #define _DEV_FDT_FDTVAR_H_ |
31 | | | 31 | |
32 | #include <sys/types.h> | | 32 | #include <sys/types.h> |
33 | #include <sys/bus.h> | | 33 | #include <sys/bus.h> |
34 | #include <sys/gpio.h> | | 34 | #include <sys/gpio.h> |
35 | #include <sys/termios.h> | | 35 | #include <sys/termios.h> |
36 | | | 36 | |
37 | #include <dev/i2c/i2cvar.h> | | 37 | #include <dev/i2c/i2cvar.h> |
38 | #include <dev/pwm/pwmvar.h> | | 38 | #include <dev/pwm/pwmvar.h> |
39 | #include <dev/clk/clk.h> | | 39 | #include <dev/clk/clk.h> |
40 | | | 40 | |
41 | #ifdef _KERNEL_OPT | | 41 | #ifdef _KERNEL_OPT |
42 | #include "audio.h" | | 42 | #include "audio.h" |
43 | #endif | | 43 | #endif |
44 | #if NAUDIO > 0 | | 44 | #if NAUDIO > 0 |
45 | #include <dev/audio/audio_dai.h> | | 45 | #include <dev/audio/audio_dai.h> |
46 | #else | | 46 | #else |
47 | typedef void *audio_dai_tag_t; | | 47 | typedef void *audio_dai_tag_t; |
48 | #endif | | 48 | #endif |
49 | | | 49 | |
50 | #include <dev/clock_subr.h> | | 50 | #include <dev/clock_subr.h> |
51 | | | 51 | |
52 | #include <dev/ofw/openfirm.h> | | 52 | #include <dev/ofw/openfirm.h> |
53 | | | 53 | |
54 | struct fdt_attach_args { | | 54 | struct fdt_attach_args { |
55 | const char *faa_name; | | 55 | const char *faa_name; |
56 | bus_space_tag_t faa_bst; | | 56 | bus_space_tag_t faa_bst; |
57 | bus_dma_tag_t faa_dmat; | | 57 | bus_dma_tag_t faa_dmat; |
58 | int faa_phandle; | | 58 | int faa_phandle; |
59 | int faa_quiet; | | 59 | int faa_quiet; |
60 | }; | | 60 | }; |
61 | | | 61 | |
62 | /* flags for fdtbus_intr_establish */ | | 62 | /* flags for fdtbus_intr_establish */ |
63 | #define FDT_INTR_MPSAFE __BIT(0) | | 63 | #define FDT_INTR_MPSAFE __BIT(0) |
64 | | | 64 | |
65 | /* Interrupt trigger types defined by the FDT "interrupts" bindings. */ | | 65 | /* Interrupt trigger types defined by the FDT "interrupts" bindings. */ |
66 | #define FDT_INTR_TYPE_POS_EDGE __BIT(0) | | 66 | #define FDT_INTR_TYPE_POS_EDGE __BIT(0) |
67 | #define FDT_INTR_TYPE_NEG_EDGE __BIT(1) | | 67 | #define FDT_INTR_TYPE_NEG_EDGE __BIT(1) |
68 | #define FDT_INTR_TYPE_DOUBLE_EDGE (FDT_INTR_TYPE_POS_EDGE | \ | | 68 | #define FDT_INTR_TYPE_DOUBLE_EDGE (FDT_INTR_TYPE_POS_EDGE | \ |
69 | FDT_INTR_TYPE_NEG_EDGE) | | 69 | FDT_INTR_TYPE_NEG_EDGE) |
70 | #define FDT_INTR_TYPE_HIGH_LEVEL __BIT(2) | | 70 | #define FDT_INTR_TYPE_HIGH_LEVEL __BIT(2) |
71 | #define FDT_INTR_TYPE_LOW_LEVEL __BIT(3) | | 71 | #define FDT_INTR_TYPE_LOW_LEVEL __BIT(3) |
72 | | | 72 | |
73 | struct fdtbus_interrupt_controller_func { | | 73 | struct fdtbus_interrupt_controller_func { |
74 | void * (*establish)(device_t, u_int *, int, int, | | 74 | void * (*establish)(device_t, u_int *, int, int, |
75 | int (*)(void *), void *, const char *); | | 75 | int (*)(void *), void *, const char *); |
76 | void (*disestablish)(device_t, void *); | | 76 | void (*disestablish)(device_t, void *); |
77 | bool (*intrstr)(device_t, u_int *, char *, size_t); | | 77 | bool (*intrstr)(device_t, u_int *, char *, size_t); |
78 | void (*mask)(device_t, void *); | | 78 | void (*mask)(device_t, void *); |
79 | void (*unmask)(device_t, void *); | | 79 | void (*unmask)(device_t, void *); |
80 | }; | | 80 | }; |
81 | | | 81 | |
82 | struct fdtbus_spi_controller_func { | | 82 | struct fdtbus_spi_controller_func { |
83 | struct spi_controller * (*get_controller)(device_t); | | 83 | struct spi_controller * (*get_controller)(device_t); |
84 | }; | | 84 | }; |
85 | | | 85 | |
86 | struct fdtbus_gpio_controller; | | 86 | struct fdtbus_gpio_controller; |
87 | | | 87 | |
88 | struct fdtbus_gpio_pin { | | 88 | struct fdtbus_gpio_pin { |
89 | struct fdtbus_gpio_controller *gp_gc; | | 89 | struct fdtbus_gpio_controller *gp_gc; |
90 | void *gp_priv; | | 90 | void *gp_priv; |
91 | }; | | 91 | }; |
92 | | | 92 | |
93 | struct fdtbus_gpio_controller_func { | | 93 | struct fdtbus_gpio_controller_func { |
94 | void * (*acquire)(device_t, const void *, size_t, int); | | 94 | void * (*acquire)(device_t, const void *, size_t, int); |
95 | void (*release)(device_t, void *); | | 95 | void (*release)(device_t, void *); |
96 | int (*read)(device_t, void *, bool); | | 96 | int (*read)(device_t, void *, bool); |
97 | void (*write)(device_t, void *, int, bool); | | 97 | void (*write)(device_t, void *, int, bool); |
98 | }; | | 98 | }; |
99 | | | 99 | |
100 | struct fdtbus_pinctrl_controller; | | 100 | struct fdtbus_pinctrl_controller; |
101 | | | 101 | |
102 | struct fdtbus_pinctrl_pin { | | 102 | struct fdtbus_pinctrl_pin { |
103 | struct fdtbus_pinctrl_controller *pp_pc; | | 103 | struct fdtbus_pinctrl_controller *pp_pc; |
104 | void *pp_priv; | | 104 | void *pp_priv; |
105 | }; | | 105 | }; |
106 | | | 106 | |
107 | struct fdtbus_pinctrl_controller_func { | | 107 | struct fdtbus_pinctrl_controller_func { |
108 | int (*set_config)(device_t, const void *, size_t); | | 108 | int (*set_config)(device_t, const void *, size_t); |
109 | }; | | 109 | }; |
110 | | | 110 | |
111 | struct fdtbus_iommu_func { | | 111 | struct fdtbus_iommu_func { |
112 | bus_dma_tag_t (*map)(device_t, const u_int *, bus_dma_tag_t); | | 112 | bus_dma_tag_t (*map)(device_t, const u_int *, bus_dma_tag_t); |
113 | }; | | 113 | }; |
114 | | | 114 | |
115 | struct fdtbus_regulator_controller; | | 115 | struct fdtbus_regulator_controller; |
116 | | | 116 | |
117 | struct fdtbus_regulator { | | 117 | struct fdtbus_regulator { |
118 | struct fdtbus_regulator_controller *reg_rc; | | 118 | struct fdtbus_regulator_controller *reg_rc; |
119 | }; | | 119 | }; |
120 | | | 120 | |
121 | struct fdtbus_regulator_controller_func { | | 121 | struct fdtbus_regulator_controller_func { |
122 | int (*acquire)(device_t); | | 122 | int (*acquire)(device_t); |
123 | void (*release)(device_t); | | 123 | void (*release)(device_t); |
124 | int (*enable)(device_t, bool); | | 124 | int (*enable)(device_t, bool); |
125 | int (*set_voltage)(device_t, u_int, u_int); | | 125 | int (*set_voltage)(device_t, u_int, u_int); |
126 | int (*get_voltage)(device_t, u_int *); | | 126 | int (*get_voltage)(device_t, u_int *); |
127 | }; | | 127 | }; |
128 | | | 128 | |
129 | struct fdtbus_clock_controller_func { | | 129 | struct fdtbus_clock_controller_func { |
130 | struct clk * (*decode)(device_t, int, const void *, size_t); | | 130 | struct clk * (*decode)(device_t, int, const void *, size_t); |
131 | }; | | 131 | }; |
132 | | | 132 | |
133 | struct fdtbus_reset_controller; | | 133 | struct fdtbus_reset_controller; |
134 | | | 134 | |
135 | struct fdtbus_reset { | | 135 | struct fdtbus_reset { |
136 | struct fdtbus_reset_controller *rst_rc; | | 136 | struct fdtbus_reset_controller *rst_rc; |
137 | void *rst_priv; | | 137 | void *rst_priv; |
138 | }; | | 138 | }; |
139 | | | 139 | |
140 | struct fdtbus_reset_controller_func { | | 140 | struct fdtbus_reset_controller_func { |
141 | void * (*acquire)(device_t, const void *, size_t); | | 141 | void * (*acquire)(device_t, const void *, size_t); |
142 | void (*release)(device_t, void *); | | 142 | void (*release)(device_t, void *); |
143 | int (*reset_assert)(device_t, void *); | | 143 | int (*reset_assert)(device_t, void *); |
144 | int (*reset_deassert)(device_t, void *); | | 144 | int (*reset_deassert)(device_t, void *); |
145 | }; | | 145 | }; |
146 | | | 146 | |
147 | struct fdtbus_dai_controller_func { | | 147 | struct fdtbus_dai_controller_func { |
148 | audio_dai_tag_t (*get_tag)(device_t, const void *, size_t); | | 148 | audio_dai_tag_t (*get_tag)(device_t, const void *, size_t); |
149 | }; | | 149 | }; |
150 | | | 150 | |
151 | struct fdtbus_dma_controller; | | 151 | struct fdtbus_dma_controller; |
152 | | | 152 | |
153 | struct fdtbus_dma { | | 153 | struct fdtbus_dma { |
154 | struct fdtbus_dma_controller *dma_dc; | | 154 | struct fdtbus_dma_controller *dma_dc; |
155 | void *dma_priv; | | 155 | void *dma_priv; |
156 | }; | | 156 | }; |
157 | | | 157 | |
158 | enum fdtbus_dma_dir { | | 158 | enum fdtbus_dma_dir { |
159 | FDT_DMA_READ, /* device -> memory */ | | 159 | FDT_DMA_READ, /* device -> memory */ |
160 | FDT_DMA_WRITE /* memory -> device */ | | 160 | FDT_DMA_WRITE /* memory -> device */ |
161 | }; | | 161 | }; |
162 | | | 162 | |
163 | struct fdtbus_dma_opt { | | 163 | struct fdtbus_dma_opt { |
164 | int opt_bus_width; /* Bus width */ | | 164 | int opt_bus_width; /* Bus width */ |
165 | int opt_burst_len; /* Burst length */ | | 165 | int opt_burst_len; /* Burst length */ |
166 | int opt_swap; /* Enable data swapping */ | | 166 | int opt_swap; /* Enable data swapping */ |
167 | int opt_dblbuf; /* Enable double buffering */ | | 167 | int opt_dblbuf; /* Enable double buffering */ |
168 | int opt_wrap_len; /* Address wrap-around window */ | | 168 | int opt_wrap_len; /* Address wrap-around window */ |
169 | }; | | 169 | }; |
170 | | | 170 | |
171 | struct fdtbus_dma_req { | | 171 | struct fdtbus_dma_req { |
172 | bus_dma_segment_t *dreq_segs; /* Memory */ | | 172 | bus_dma_segment_t *dreq_segs; /* Memory */ |
173 | int dreq_nsegs; | | 173 | int dreq_nsegs; |
174 | | | 174 | |
175 | bus_addr_t dreq_dev_phys; /* Device */ | | 175 | bus_addr_t dreq_dev_phys; /* Device */ |
176 | int dreq_sel; /* Device selector */ | | 176 | int dreq_sel; /* Device selector */ |
177 | | | 177 | |
178 | enum fdtbus_dma_dir dreq_dir; /* Transfer direction */ | | 178 | enum fdtbus_dma_dir dreq_dir; /* Transfer direction */ |
179 | | | 179 | |
180 | int dreq_block_irq; /* Enable IRQ at end of block */ | | 180 | int dreq_block_irq; /* Enable IRQ at end of block */ |
181 | int dreq_block_multi; /* Enable multiple block transfers */ | | 181 | int dreq_block_multi; /* Enable multiple block transfers */ |
182 | int dreq_flow; /* Enable flow control */ | | 182 | int dreq_flow; /* Enable flow control */ |
183 | | | 183 | |
184 | struct fdtbus_dma_opt dreq_mem_opt; /* Memory options */ | | 184 | struct fdtbus_dma_opt dreq_mem_opt; /* Memory options */ |
185 | struct fdtbus_dma_opt dreq_dev_opt; /* Device options */ | | 185 | struct fdtbus_dma_opt dreq_dev_opt; /* Device options */ |
186 | }; | | 186 | }; |
187 | | | 187 | |
188 | struct fdtbus_dma_controller_func { | | 188 | struct fdtbus_dma_controller_func { |
189 | void * (*acquire)(device_t, const void *, size_t, | | 189 | void * (*acquire)(device_t, const void *, size_t, |
190 | void (*)(void *), void *); | | 190 | void (*)(void *), void *); |
191 | void (*release)(device_t, void *); | | 191 | void (*release)(device_t, void *); |
192 | int (*transfer)(device_t, void *, struct fdtbus_dma_req *); | | 192 | int (*transfer)(device_t, void *, struct fdtbus_dma_req *); |
193 | void (*halt)(device_t, void *); | | 193 | void (*halt)(device_t, void *); |
194 | }; | | 194 | }; |
195 | | | 195 | |
196 | struct fdtbus_power_controller; | | 196 | struct fdtbus_power_controller; |
197 | | | 197 | |
198 | struct fdtbus_power_controller_func { | | 198 | struct fdtbus_power_controller_func { |
199 | void (*reset)(device_t); | | 199 | void (*reset)(device_t); |
200 | void (*poweroff)(device_t); | | 200 | void (*poweroff)(device_t); |
201 | }; | | 201 | }; |
202 | | | 202 | |
203 | struct fdtbus_phy_controller; | | 203 | struct fdtbus_phy_controller; |
204 | | | 204 | |
205 | struct fdtbus_phy { | | 205 | struct fdtbus_phy { |
206 | struct fdtbus_phy_controller *phy_pc; | | 206 | struct fdtbus_phy_controller *phy_pc; |
207 | void *phy_priv; | | 207 | void *phy_priv; |
208 | }; | | 208 | }; |
209 | | | 209 | |
210 | struct fdtbus_phy_controller_func { | | 210 | struct fdtbus_phy_controller_func { |
211 | void * (*acquire)(device_t, const void *, size_t); | | 211 | void * (*acquire)(device_t, const void *, size_t); |
212 | void (*release)(device_t, void *); | | 212 | void (*release)(device_t, void *); |
213 | int (*enable)(device_t, void *, bool); | | 213 | int (*enable)(device_t, void *, bool); |
214 | }; | | 214 | }; |
215 | | | 215 | |
216 | struct fdtbus_pwm_controller_func { | | 216 | struct fdtbus_pwm_controller_func { |
217 | pwm_tag_t (*get_tag)(device_t, const void *, size_t); | | 217 | pwm_tag_t (*get_tag)(device_t, const void *, size_t); |
218 | }; | | 218 | }; |
219 | | | 219 | |
220 | struct fdtbus_mmc_pwrseq; | | 220 | struct fdtbus_mmc_pwrseq; |
221 | | | 221 | |
222 | struct fdtbus_mmc_pwrseq_func { | | 222 | struct fdtbus_mmc_pwrseq_func { |
223 | void (*pre_power_on)(device_t); | | 223 | void (*pre_power_on)(device_t); |
224 | void (*post_power_on)(device_t); | | 224 | void (*post_power_on)(device_t); |
225 | void (*power_off)(device_t); | | 225 | void (*power_off)(device_t); |
226 | void (*reset)(device_t); | | 226 | void (*reset)(device_t); |
227 | }; | | 227 | }; |
228 | | | 228 | |
229 | struct syscon; | | 229 | struct syscon; |
230 | | | 230 | |
231 | struct fdt_console { | | 231 | struct fdt_console { |
232 | int (*match)(int); | | 232 | int (*match)(int); |
233 | void (*consinit)(struct fdt_attach_args *, u_int); | | 233 | void (*consinit)(struct fdt_attach_args *, u_int); |
234 | }; | | 234 | }; |
235 | | | 235 | |
236 | struct fdt_console_info { | | 236 | struct fdt_console_info { |
237 | const struct fdt_console *ops; | | 237 | const struct fdt_console *ops; |
238 | }; | | 238 | }; |
239 | | | 239 | |
240 | struct fdt_phandle_data { | | 240 | struct fdt_phandle_data { |
241 | int phandle; | | 241 | int phandle; |
242 | int count; | | 242 | int count; |
243 | const u_int *values; | | 243 | const u_int *values; |
244 | }; | | 244 | }; |
245 | | | 245 | |
246 | #define _FDT_CONSOLE_REGISTER(name) \ | | 246 | #define _FDT_CONSOLE_REGISTER(name) \ |
247 | __link_set_add_rodata(fdt_consoles, __CONCAT(name,_consinfo)); | | 247 | __link_set_add_rodata(fdt_consoles, __CONCAT(name,_consinfo)); |
248 | | | 248 | |
249 | #define FDT_CONSOLE(_name, _ops) \ | | 249 | #define FDT_CONSOLE(_name, _ops) \ |
250 | static const struct fdt_console_info __CONCAT(_name,_consinfo) = { \ | | 250 | static const struct fdt_console_info __CONCAT(_name,_consinfo) = { \ |
251 | .ops = (_ops) \ | | 251 | .ops = (_ops) \ |
252 | }; \ | | 252 | }; \ |
253 | _FDT_CONSOLE_REGISTER(_name) | | 253 | _FDT_CONSOLE_REGISTER(_name) |
254 | | | 254 | |
255 | struct fdt_opp_info { | | 255 | struct fdt_opp_info { |
256 | const char * opp_compat; | | 256 | const char * opp_compat; |
257 | bool (*opp_supported)(const int, const int); | | 257 | bool (*opp_supported)(const int, const int); |
258 | }; | | 258 | }; |
259 | | | 259 | |
260 | #define _FDT_OPP_REGISTER(name) \ | | 260 | #define _FDT_OPP_REGISTER(name) \ |
261 | __link_set_add_rodata(fdt_opps, __CONCAT(name,_oppinfo)); | | 261 | __link_set_add_rodata(fdt_opps, __CONCAT(name,_oppinfo)); |
262 | | | 262 | |
263 | #define FDT_OPP(_name, _compat, _suppfn) \ | | 263 | #define FDT_OPP(_name, _compat, _suppfn) \ |
264 | static const struct fdt_opp_info __CONCAT(_name,_oppinfo) = { \ | | 264 | static const struct fdt_opp_info __CONCAT(_name,_oppinfo) = { \ |
265 | .opp_compat = (_compat), \ | | 265 | .opp_compat = (_compat), \ |
266 | .opp_supported = (_suppfn) \ | | 266 | .opp_supported = (_suppfn) \ |
267 | }; \ | | 267 | }; \ |
268 | _FDT_OPP_REGISTER(_name) | | 268 | _FDT_OPP_REGISTER(_name) |
269 | | | 269 | |
270 | TAILQ_HEAD(fdt_conslist, fdt_console_info); | | 270 | TAILQ_HEAD(fdt_conslist, fdt_console_info); |
271 | | | 271 | |
272 | struct fdt_dma_range { | | 272 | struct fdt_dma_range { |
273 | paddr_t dr_sysbase; | | 273 | paddr_t dr_sysbase; |
274 | bus_addr_t dr_busbase; | | 274 | bus_addr_t dr_busbase; |
275 | bus_size_t dr_len; | | 275 | bus_size_t dr_len; |
276 | }; | | 276 | }; |
277 | | | 277 | |
278 | #define FDT_BUS_SPACE_FLAG_NONPOSTED_MMIO __BIT(0) | | 278 | #define FDT_BUS_SPACE_FLAG_NONPOSTED_MMIO __BIT(0) |
279 | | | 279 | |
280 | int fdtbus_register_interrupt_controller(device_t, int, | | 280 | int fdtbus_register_interrupt_controller(device_t, int, |
281 | const struct fdtbus_interrupt_controller_func *); | | 281 | const struct fdtbus_interrupt_controller_func *); |
282 | int fdtbus_register_i2c_controller(i2c_tag_t, int); | | 282 | int fdtbus_register_i2c_controller(i2c_tag_t, int); |
283 | int fdtbus_register_spi_controller(device_t, int, | | 283 | int fdtbus_register_spi_controller(device_t, int, |
284 | const struct fdtbus_spi_controller_func *); | | 284 | const struct fdtbus_spi_controller_func *); |
285 | int fdtbus_register_gpio_controller(device_t, int, | | 285 | int fdtbus_register_gpio_controller(device_t, int, |
286 | const struct fdtbus_gpio_controller_func *); | | 286 | const struct fdtbus_gpio_controller_func *); |
287 | int fdtbus_register_pinctrl_config(device_t, int, | | 287 | int fdtbus_register_pinctrl_config(device_t, int, |
288 | const struct fdtbus_pinctrl_controller_func *); | | 288 | const struct fdtbus_pinctrl_controller_func *); |
289 | int fdtbus_register_regulator_controller(device_t, int, | | 289 | int fdtbus_register_regulator_controller(device_t, int, |
290 | const struct fdtbus_regulator_controller_func *); | | 290 | const struct fdtbus_regulator_controller_func *); |
291 | int fdtbus_register_clock_controller(device_t, int, | | 291 | int fdtbus_register_clock_controller(device_t, int, |
292 | const struct fdtbus_clock_controller_func *); | | 292 | const struct fdtbus_clock_controller_func *); |
293 | int fdtbus_register_reset_controller(device_t, int, | | 293 | int fdtbus_register_reset_controller(device_t, int, |
294 | const struct fdtbus_reset_controller_func *); | | 294 | const struct fdtbus_reset_controller_func *); |
295 | int fdtbus_register_dai_controller(device_t, int, | | 295 | int fdtbus_register_dai_controller(device_t, int, |
296 | const struct fdtbus_dai_controller_func *); | | 296 | const struct fdtbus_dai_controller_func *); |
297 | int fdtbus_register_dma_controller(device_t, int, | | 297 | int fdtbus_register_dma_controller(device_t, int, |
298 | const struct fdtbus_dma_controller_func *); | | 298 | const struct fdtbus_dma_controller_func *); |
299 | int fdtbus_register_power_controller(device_t, int, | | 299 | int fdtbus_register_power_controller(device_t, int, |
300 | const struct fdtbus_power_controller_func *); | | 300 | const struct fdtbus_power_controller_func *); |
301 | int fdtbus_register_phy_controller(device_t, int, | | 301 | int fdtbus_register_phy_controller(device_t, int, |
302 | const struct fdtbus_phy_controller_func *); | | 302 | const struct fdtbus_phy_controller_func *); |
303 | int fdtbus_register_pwm_controller(device_t, int, | | 303 | int fdtbus_register_pwm_controller(device_t, int, |
304 | const struct fdtbus_pwm_controller_func *); | | 304 | const struct fdtbus_pwm_controller_func *); |
305 | int fdtbus_register_mmc_pwrseq(device_t, int, | | 305 | int fdtbus_register_mmc_pwrseq(device_t, int, |
306 | const struct fdtbus_mmc_pwrseq_func *); | | 306 | const struct fdtbus_mmc_pwrseq_func *); |
307 | int fdtbus_register_syscon(device_t, int, struct syscon *); | | 307 | int fdtbus_register_syscon(device_t, int, struct syscon *); |
308 | int fdtbus_register_iommu(device_t, int, | | 308 | int fdtbus_register_iommu(device_t, int, |
309 | const struct fdtbus_iommu_func *); | | 309 | const struct fdtbus_iommu_func *); |
310 | | | 310 | |
311 | void fdtbus_set_decoderegprop(bool); | | 311 | void fdtbus_set_decoderegprop(bool); |
312 | | | 312 | |
313 | int fdtbus_get_reg(int, u_int, bus_addr_t *, bus_size_t *); | | 313 | int fdtbus_get_reg(int, u_int, bus_addr_t *, bus_size_t *); |
314 | int fdtbus_get_reg_byname(int, const char *, bus_addr_t *, | | 314 | int fdtbus_get_reg_byname(int, const char *, bus_addr_t *, |
315 | bus_size_t *); | | 315 | bus_size_t *); |
316 | int fdtbus_get_reg64(int, u_int, uint64_t *, uint64_t *); | | 316 | int fdtbus_get_reg64(int, u_int, uint64_t *, uint64_t *); |
317 | int fdtbus_get_addr_cells(int); | | 317 | int fdtbus_get_addr_cells(int); |
318 | int fdtbus_get_size_cells(int); | | 318 | int fdtbus_get_size_cells(int); |
319 | uint64_t fdtbus_get_cells(const uint8_t *, int); | | 319 | uint64_t fdtbus_get_cells(const uint8_t *, int); |
320 | int fdtbus_get_phandle(int, const char *); | | 320 | int fdtbus_get_phandle(int, const char *); |
321 | int fdtbus_get_phandle_with_data(int, const char *, const char *, | | 321 | int fdtbus_get_phandle_with_data(int, const char *, const char *, |
322 | int, struct fdt_phandle_data *); | | 322 | int, struct fdt_phandle_data *); |
323 | int fdtbus_get_phandle_from_native(int); | | 323 | int fdtbus_get_phandle_from_native(int); |
324 | | | 324 | |
325 | i2c_tag_t fdtbus_get_i2c_tag(int); | | 325 | i2c_tag_t fdtbus_i2c_get_tag(int); |
326 | i2c_tag_t fdtbus_i2c_acquire(int, const char *); | | 326 | i2c_tag_t fdtbus_i2c_acquire(int, const char *); |
327 | | | 327 | |
328 | void * fdtbus_intr_establish(int, u_int, int, int, | | 328 | void * fdtbus_intr_establish(int, u_int, int, int, |
329 | int (*func)(void *), void *arg); | | 329 | int (*func)(void *), void *arg); |
330 | void * fdtbus_intr_establish_xname(int, u_int, int, int, | | 330 | void * fdtbus_intr_establish_xname(int, u_int, int, int, |
331 | int (*func)(void *), void *arg, const char *); | | 331 | int (*func)(void *), void *arg, const char *); |
332 | void * fdtbus_intr_establish_byname(int, const char *, int, int, | | 332 | void * fdtbus_intr_establish_byname(int, const char *, int, int, |
333 | int (*func)(void *), void *arg, const char *); | | 333 | int (*func)(void *), void *arg, const char *); |
334 | void * fdtbus_intr_establish_raw(int, const u_int *, int, int, | | 334 | void * fdtbus_intr_establish_raw(int, const u_int *, int, int, |
335 | int (*func)(void *), void *arg, const char *); | | 335 | int (*func)(void *), void *arg, const char *); |
336 | void fdtbus_intr_mask(int, void *); | | 336 | void fdtbus_intr_mask(int, void *); |
337 | void fdtbus_intr_unmask(int, void *); | | 337 | void fdtbus_intr_unmask(int, void *); |
338 | void fdtbus_intr_disestablish(int, void *); | | 338 | void fdtbus_intr_disestablish(int, void *); |
339 | bool fdtbus_intr_str(int, u_int, char *, size_t); | | 339 | bool fdtbus_intr_str(int, u_int, char *, size_t); |
340 | bool fdtbus_intr_str_raw(int, const u_int *, char *, size_t); | | 340 | bool fdtbus_intr_str_raw(int, const u_int *, char *, size_t); |
341 | int fdtbus_intr_parent(int); | | 341 | int fdtbus_intr_parent(int); |
342 | | | 342 | |
343 | int fdtbus_gpio_count(int, const char *); | | 343 | int fdtbus_gpio_count(int, const char *); |
344 | struct fdtbus_gpio_pin * | | 344 | struct fdtbus_gpio_pin * |
345 | fdtbus_gpio_acquire(int, const char *, int); | | 345 | fdtbus_gpio_acquire(int, const char *, int); |
346 | struct fdtbus_gpio_pin * | | 346 | struct fdtbus_gpio_pin * |
347 | fdtbus_gpio_acquire_index(int, const char *, int, int); | | 347 | fdtbus_gpio_acquire_index(int, const char *, int, int); |
348 | void fdtbus_gpio_release(struct fdtbus_gpio_pin *); | | 348 | void fdtbus_gpio_release(struct fdtbus_gpio_pin *); |
349 | int fdtbus_gpio_read(struct fdtbus_gpio_pin *); | | 349 | int fdtbus_gpio_read(struct fdtbus_gpio_pin *); |
350 | void fdtbus_gpio_write(struct fdtbus_gpio_pin *, int); | | 350 | void fdtbus_gpio_write(struct fdtbus_gpio_pin *, int); |
351 | int fdtbus_gpio_read_raw(struct fdtbus_gpio_pin *); | | 351 | int fdtbus_gpio_read_raw(struct fdtbus_gpio_pin *); |
352 | void fdtbus_gpio_write_raw(struct fdtbus_gpio_pin *, int); | | 352 | void fdtbus_gpio_write_raw(struct fdtbus_gpio_pin *, int); |
353 | | | 353 | |
354 | audio_dai_tag_t fdtbus_dai_acquire(int, const char *); | | 354 | audio_dai_tag_t fdtbus_dai_acquire(int, const char *); |
355 | audio_dai_tag_t fdtbus_dai_acquire_index(int, const char *, int); | | 355 | audio_dai_tag_t fdtbus_dai_acquire_index(int, const char *, int); |
356 | | | 356 | |
357 | pwm_tag_t fdtbus_pwm_acquire(int, const char *); | | 357 | pwm_tag_t fdtbus_pwm_acquire(int, const char *); |
358 | pwm_tag_t fdtbus_pwm_acquire_index(int, const char *, int); | | 358 | pwm_tag_t fdtbus_pwm_acquire_index(int, const char *, int); |
359 | | | 359 | |
360 | int fdtbus_pinctrl_set_config_index(int, u_int); | | 360 | int fdtbus_pinctrl_set_config_index(int, u_int); |
361 | int fdtbus_pinctrl_set_config(int, const char *); | | 361 | int fdtbus_pinctrl_set_config(int, const char *); |
362 | bool fdtbus_pinctrl_has_config(int, const char *); | | 362 | bool fdtbus_pinctrl_has_config(int, const char *); |
363 | const char * fdtbus_pinctrl_parse_function(int); | | 363 | const char * fdtbus_pinctrl_parse_function(int); |
364 | const void * fdtbus_pinctrl_parse_pins(int, int *); | | 364 | const void * fdtbus_pinctrl_parse_pins(int, int *); |
365 | const char * fdtbus_pinctrl_parse_groups(int, int *); | | 365 | const char * fdtbus_pinctrl_parse_groups(int, int *); |
366 | const u_int * fdtbus_pinctrl_parse_pinmux(int, int *); | | 366 | const u_int * fdtbus_pinctrl_parse_pinmux(int, int *); |
367 | int fdtbus_pinctrl_parse_bias(int, int *); | | 367 | int fdtbus_pinctrl_parse_bias(int, int *); |
368 | int fdtbus_pinctrl_parse_drive(int); | | 368 | int fdtbus_pinctrl_parse_drive(int); |
369 | int fdtbus_pinctrl_parse_drive_strength(int); | | 369 | int fdtbus_pinctrl_parse_drive_strength(int); |
370 | int fdtbus_pinctrl_parse_input_output(int, int *); | | 370 | int fdtbus_pinctrl_parse_input_output(int, int *); |
371 | | | 371 | |
372 | struct fdtbus_regulator * | | 372 | struct fdtbus_regulator * |
373 | fdtbus_regulator_acquire(int, const char *); | | 373 | fdtbus_regulator_acquire(int, const char *); |
374 | void fdtbus_regulator_release(struct fdtbus_regulator *); | | 374 | void fdtbus_regulator_release(struct fdtbus_regulator *); |
375 | int fdtbus_regulator_enable(struct fdtbus_regulator *); | | 375 | int fdtbus_regulator_enable(struct fdtbus_regulator *); |
376 | int fdtbus_regulator_disable(struct fdtbus_regulator *); | | 376 | int fdtbus_regulator_disable(struct fdtbus_regulator *); |
377 | int fdtbus_regulator_set_voltage(struct fdtbus_regulator *, | | 377 | int fdtbus_regulator_set_voltage(struct fdtbus_regulator *, |
378 | u_int, u_int); | | 378 | u_int, u_int); |
379 | int fdtbus_regulator_get_voltage(struct fdtbus_regulator *, | | 379 | int fdtbus_regulator_get_voltage(struct fdtbus_regulator *, |
380 | u_int *); | | 380 | u_int *); |
381 | int fdtbus_regulator_supports_voltage(struct fdtbus_regulator *, | | 381 | int fdtbus_regulator_supports_voltage(struct fdtbus_regulator *, |
382 | u_int, u_int); | | 382 | u_int, u_int); |
383 | | | 383 | |
384 | struct syscon * fdtbus_syscon_acquire(int, const char *); | | 384 | struct syscon * fdtbus_syscon_acquire(int, const char *); |
385 | struct syscon * fdtbus_syscon_lookup(int); | | 385 | struct syscon * fdtbus_syscon_lookup(int); |
386 | | | 386 | |
387 | bus_dma_tag_t fdtbus_iommu_map(int, u_int, bus_dma_tag_t); | | 387 | bus_dma_tag_t fdtbus_iommu_map(int, u_int, bus_dma_tag_t); |
388 | bus_dma_tag_t fdtbus_iommu_map_pci(int, uint32_t, bus_dma_tag_t); | | 388 | bus_dma_tag_t fdtbus_iommu_map_pci(int, uint32_t, bus_dma_tag_t); |
389 | | | 389 | |
390 | struct fdtbus_dma * | | 390 | struct fdtbus_dma * |
391 | fdtbus_dma_get(int, const char *, void (*)(void *), void *); | | 391 | fdtbus_dma_get(int, const char *, void (*)(void *), void *); |
392 | struct fdtbus_dma * | | 392 | struct fdtbus_dma * |
393 | fdtbus_dma_get_index(int, u_int, void (*)(void *), | | 393 | fdtbus_dma_get_index(int, u_int, void (*)(void *), |
394 | void *); | | 394 | void *); |
395 | void fdtbus_dma_put(struct fdtbus_dma *); | | 395 | void fdtbus_dma_put(struct fdtbus_dma *); |
396 | int fdtbus_dma_transfer(struct fdtbus_dma *, | | 396 | int fdtbus_dma_transfer(struct fdtbus_dma *, |
397 | struct fdtbus_dma_req *); | | 397 | struct fdtbus_dma_req *); |
398 | void fdtbus_dma_halt(struct fdtbus_dma *); | | 398 | void fdtbus_dma_halt(struct fdtbus_dma *); |
399 | | | 399 | |
400 | struct clk * fdtbus_clock_get(int, const char *); | | 400 | struct clk * fdtbus_clock_get(int, const char *); |
401 | struct clk * fdtbus_clock_get_index(int, u_int); | | 401 | struct clk * fdtbus_clock_get_index(int, u_int); |
402 | struct clk * fdtbus_clock_byname(const char *); | | 402 | struct clk * fdtbus_clock_byname(const char *); |
403 | void fdtbus_clock_assign(int); | | 403 | void fdtbus_clock_assign(int); |
404 | u_int fdtbus_clock_count(int, const char *); | | 404 | u_int fdtbus_clock_count(int, const char *); |
405 | int fdtbus_clock_enable(int, const char *, bool); | | 405 | int fdtbus_clock_enable(int, const char *, bool); |
406 | int fdtbus_clock_enable_index(int, u_int, bool); | | 406 | int fdtbus_clock_enable_index(int, u_int, bool); |
407 | | | 407 | |
408 | struct fdtbus_reset * | | 408 | struct fdtbus_reset * |
409 | fdtbus_reset_get(int, const char *); | | 409 | fdtbus_reset_get(int, const char *); |
410 | struct fdtbus_reset * | | 410 | struct fdtbus_reset * |
411 | fdtbus_reset_get_index(int, u_int); | | 411 | fdtbus_reset_get_index(int, u_int); |
412 | void fdtbus_reset_put(struct fdtbus_reset *); | | 412 | void fdtbus_reset_put(struct fdtbus_reset *); |
413 | int fdtbus_reset_assert(struct fdtbus_reset *); | | 413 | int fdtbus_reset_assert(struct fdtbus_reset *); |
414 | int fdtbus_reset_deassert(struct fdtbus_reset *); | | 414 | int fdtbus_reset_deassert(struct fdtbus_reset *); |
415 | | | 415 | |
416 | struct fdtbus_phy * | | 416 | struct fdtbus_phy * |
417 | fdtbus_phy_get(int, const char *); | | 417 | fdtbus_phy_get(int, const char *); |
418 | struct fdtbus_phy * | | 418 | struct fdtbus_phy * |
419 | fdtbus_phy_get_index(int, u_int); | | 419 | fdtbus_phy_get_index(int, u_int); |
420 | void fdtbus_phy_put(struct fdtbus_phy *); | | 420 | void fdtbus_phy_put(struct fdtbus_phy *); |
421 | device_t fdtbus_phy_device(struct fdtbus_phy *); | | 421 | device_t fdtbus_phy_device(struct fdtbus_phy *); |
422 | int fdtbus_phy_enable(struct fdtbus_phy *, bool); | | 422 | int fdtbus_phy_enable(struct fdtbus_phy *, bool); |
423 | | | 423 | |
424 | struct fdtbus_mmc_pwrseq * | | 424 | struct fdtbus_mmc_pwrseq * |
425 | fdtbus_mmc_pwrseq_get(int); | | 425 | fdtbus_mmc_pwrseq_get(int); |
426 | void fdtbus_mmc_pwrseq_pre_power_on(struct fdtbus_mmc_pwrseq *); | | 426 | void fdtbus_mmc_pwrseq_pre_power_on(struct fdtbus_mmc_pwrseq *); |
427 | void fdtbus_mmc_pwrseq_post_power_on(struct fdtbus_mmc_pwrseq *); | | 427 | void fdtbus_mmc_pwrseq_post_power_on(struct fdtbus_mmc_pwrseq *); |
428 | void fdtbus_mmc_pwrseq_power_off(struct fdtbus_mmc_pwrseq *); | | 428 | void fdtbus_mmc_pwrseq_power_off(struct fdtbus_mmc_pwrseq *); |
429 | void fdtbus_mmc_pwrseq_reset(struct fdtbus_mmc_pwrseq *); | | 429 | void fdtbus_mmc_pwrseq_reset(struct fdtbus_mmc_pwrseq *); |
430 | | | 430 | |
431 | int fdtbus_todr_attach(device_t, int, todr_chip_handle_t); | | 431 | int fdtbus_todr_attach(device_t, int, todr_chip_handle_t); |
432 | | | 432 | |
433 | void fdtbus_power_reset(void); | | 433 | void fdtbus_power_reset(void); |
434 | void fdtbus_power_poweroff(void); | | 434 | void fdtbus_power_poweroff(void); |
435 | | | 435 | |
436 | device_t fdtbus_attach_i2cbus(device_t, int, i2c_tag_t, cfprint_t); | | 436 | device_t fdtbus_attach_i2cbus(device_t, int, i2c_tag_t, cfprint_t); |
437 | device_t fdtbus_attach_spibus(device_t, int, cfprint_t); | | 437 | device_t fdtbus_attach_spibus(device_t, int, cfprint_t); |
438 | | | 438 | |
439 | bool fdtbus_init(const void *); | | 439 | bool fdtbus_init(const void *); |
440 | const void * fdtbus_get_data(void); | | 440 | const void * fdtbus_get_data(void); |
441 | int fdtbus_phandle2offset(int); | | 441 | int fdtbus_phandle2offset(int); |
442 | int fdtbus_offset2phandle(int); | | 442 | int fdtbus_offset2phandle(int); |
443 | bool fdtbus_get_path(int, char *, size_t); | | 443 | bool fdtbus_get_path(int, char *, size_t); |
444 | | | 444 | |
445 | const struct fdt_console * | | 445 | const struct fdt_console * |
446 | fdtbus_get_console(void); | | 446 | fdtbus_get_console(void); |
447 | | | 447 | |
448 | const char * fdtbus_get_stdout_path(void); | | 448 | const char * fdtbus_get_stdout_path(void); |
449 | int fdtbus_get_stdout_phandle(void); | | 449 | int fdtbus_get_stdout_phandle(void); |
450 | int fdtbus_get_stdout_speed(void); | | 450 | int fdtbus_get_stdout_speed(void); |
451 | tcflag_t fdtbus_get_stdout_flags(void); | | 451 | tcflag_t fdtbus_get_stdout_flags(void); |
452 | | | 452 | |
453 | bool fdtbus_status_okay(int); | | 453 | bool fdtbus_status_okay(int); |
454 | | | 454 | |
455 | const void * fdtbus_get_prop(int, const char *, int *); | | 455 | const void * fdtbus_get_prop(int, const char *, int *); |
456 | const char * fdtbus_get_string(int, const char *); | | 456 | const char * fdtbus_get_string(int, const char *); |
457 | const char * fdtbus_get_string_index(int, const char *, u_int); | | 457 | const char * fdtbus_get_string_index(int, const char *, u_int); |
458 | int fdtbus_get_index(int, const char *, const char *, u_int *); | | 458 | int fdtbus_get_index(int, const char *, const char *, u_int *); |
459 | | | 459 | |
460 | void fdt_add_bus(device_t, int, struct fdt_attach_args *); | | 460 | void fdt_add_bus(device_t, int, struct fdt_attach_args *); |
461 | void fdt_add_bus_match(device_t, int, struct fdt_attach_args *, | | 461 | void fdt_add_bus_match(device_t, int, struct fdt_attach_args *, |
462 | bool (*)(void *, int), void *); | | 462 | bool (*)(void *, int), void *); |
463 | void fdt_add_child(device_t, int, struct fdt_attach_args *, u_int); | | 463 | void fdt_add_child(device_t, int, struct fdt_attach_args *, u_int); |
464 | | | 464 | |
465 | void fdt_remove_byhandle(int); | | 465 | void fdt_remove_byhandle(int); |
466 | void fdt_remove_bycompat(const char *[]); | | 466 | void fdt_remove_bycompat(const char *[]); |
467 | int fdt_find_with_property(const char *, int *); | | 467 | int fdt_find_with_property(const char *, int *); |
468 | | | 468 | |
469 | int fdtbus_print(void *, const char *); | | 469 | int fdtbus_print(void *, const char *); |
470 | | | 470 | |
471 | bus_dma_tag_t fdtbus_dma_tag_create(int, const struct fdt_dma_range *, | | 471 | bus_dma_tag_t fdtbus_dma_tag_create(int, const struct fdt_dma_range *, |
472 | u_int); | | 472 | u_int); |
473 | bus_space_tag_t fdtbus_bus_tag_create(int, uint32_t); | | 473 | bus_space_tag_t fdtbus_bus_tag_create(int, uint32_t); |
474 | | | 474 | |
475 | #endif /* _DEV_FDT_FDTVAR_H_ */ | | 475 | #endif /* _DEV_FDT_FDTVAR_H_ */ |