Add mailbox and power-domain support. power-domain support is very rudimentary.diff -r0 -r1.1 src/sys/dev/fdt/fdt_mbox.c
(skrll)
/* $NetBSD: fdt_mbox.c,v 1.1 2022/03/04 08:19:06 skrll Exp $ */
/*-
* Copyright (c) 2022 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: fdt_mbox.c,v 1.1 2022/03/04 08:19:06 skrll Exp $");
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/kmem.h>
#include <sys/queue.h>
#include <libfdt.h>
#include <dev/fdt/fdtvar.h>
struct fdtbus_mbox_controller {
device_t mc_dev;
int mc_phandle;
int mc_cells;
const struct fdtbus_mbox_controller_func *mc_funcs;
LIST_ENTRY(fdtbus_mbox_controller) mc_next;
};
static LIST_HEAD(, fdtbus_mbox_controller) fdtbus_mbox_controllers =
LIST_HEAD_INITIALIZER(fdtbus_mbox_controllers);
int
fdtbus_register_mbox_controller(device_t dev, int phandle,
const struct fdtbus_mbox_controller_func *funcs)
{
struct fdtbus_mbox_controller *mc;
uint32_t cells;
if (of_getprop_uint32(phandle, "#mbox-cells", &cells) != 0) {
aprint_debug_dev(dev, "missing #mbox-cells");
return EINVAL;
}
mc = kmem_alloc(sizeof(*mc), KM_SLEEP);
mc->mc_dev = dev;
mc->mc_phandle = phandle;
mc->mc_funcs = funcs;
mc->mc_cells = cells;
LIST_INSERT_HEAD(&fdtbus_mbox_controllers, mc, mc_next);
return 0;
}
static struct fdtbus_mbox_controller *
fdtbus_mbox_lookup(int phandle)
{
struct fdtbus_mbox_controller *mc;
LIST_FOREACH(mc, &fdtbus_mbox_controllers, mc_next) {
if (mc->mc_phandle == phandle)
return mc;
}
return NULL;
}
struct fdtbus_mbox_channel *
fdtbus_mbox_get_index(int phandle, u_int index, void (*cb)(void *), void *cbarg)
{
struct fdtbus_mbox_controller *mc;
struct fdtbus_mbox_channel *mbox = NULL;
void *mbox_priv = NULL;
uint32_t *mboxes = NULL;
uint32_t *p;
u_int n;
int len, resid;
len = OF_getproplen(phandle, "mboxes");
if (len <= 0)
return NULL;
mboxes = kmem_alloc(len, KM_SLEEP);
if (OF_getprop(phandle, "mboxes", mboxes, len) != len) {
kmem_free(mboxes, len);
return NULL;
}
p = mboxes;
for (n = 0, resid = len; resid > 0; n++) {
const int mc_phandle =
fdtbus_get_phandle_from_native(be32toh(p[0]));
mc = fdtbus_mbox_lookup(mc_phandle);
if (mc == NULL)
break;
u_int mbox_cells = mc->mc_cells;
if (n == index) {
mbox_priv = mc->mc_funcs->mc_acquire(mc->mc_dev,
mbox_cells > 0 ? &p[1] : NULL, mbox_cells * 4,
cb, cbarg);
if (mbox_priv) {
mbox = kmem_alloc(sizeof(*mbox), KM_SLEEP);
mbox->mb_ctlr = mc;
mbox->mb_priv = mbox_priv;
}
break;
}
resid -= (mbox_cells + 1) * 4;
p += mbox_cells + 1;
}
if (mboxes)
kmem_free(mboxes, len);
return mbox;
}
struct fdtbus_mbox_channel *
fdtbus_mbox_get(int phandle, const char *name, void (*cb)(void *), void *cbarg)
{
u_int index;
int err;
err = fdtbus_get_index(phandle, "mbox-names", name, &index);
if (err != 0)
return NULL;
return fdtbus_mbox_get_index(phandle, index, cb, cbarg);
}
void
fdtbus_mbox_put(struct fdtbus_mbox_channel *mbox)
{
struct fdtbus_mbox_controller *mc = mbox->mb_ctlr;
mc->mc_funcs->mc_release(mc->mc_dev, mbox->mb_priv);
kmem_free(mbox, sizeof(*mbox));
}
int
fdtbus_mbox_send(struct fdtbus_mbox_channel *mbox, const void *data, size_t len)
{
struct fdtbus_mbox_controller * const mc = mbox->mb_ctlr;
return mc->mc_funcs->mc_send(mc->mc_dev, mbox->mb_priv, data, len);
}
int
fdtbus_mbox_recv(struct fdtbus_mbox_channel *mbox, void *data, size_t len)
{
struct fdtbus_mbox_controller * const mc = mbox->mb_ctlr;
return mc->mc_funcs->mc_recv(mc->mc_dev, mbox->mb_priv, data, len);
}
/* $NetBSD: fdt_powerdomain.c,v 1.1 2022/03/04 08:19:06 skrll Exp $ */
/*-
* Copyright (c) 2022 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: fdt_powerdomain.c,v 1.1 2022/03/04 08:19:06 skrll Exp $");
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/kmem.h>
#include <sys/queue.h>
#include <libfdt.h>
#include <dev/fdt/fdtvar.h>
struct fdtbus_powerdomain_controller {
device_t pdc_dev;
int pdc_phandle;
void *pdc_cookie;
int pdc_cells;
const struct fdtbus_powerdomain_controller_func *pdc_funcs;
LIST_ENTRY(fdtbus_powerdomain_controller) pdc_next;
};
static LIST_HEAD(, fdtbus_powerdomain_controller) fdtbus_powerdomain_controllers =
LIST_HEAD_INITIALIZER(fdtbus_powerdomain_controllers);
int
fdtbus_register_powerdomain_controller(device_t dev, int phandle,
const struct fdtbus_powerdomain_controller_func *funcs)
{
struct fdtbus_powerdomain_controller *pdc;
uint32_t cells;
if (of_getprop_uint32(phandle, "#power-domain-cells", &cells) != 0) {
aprint_debug_dev(dev, "missing #power-domain-cells");
return EINVAL;
}
pdc = kmem_alloc(sizeof(*pdc), KM_SLEEP);
pdc->pdc_dev = dev;
pdc->pdc_phandle = phandle;
pdc->pdc_funcs = funcs;
pdc->pdc_cells = cells;
LIST_INSERT_HEAD(&fdtbus_powerdomain_controllers, pdc, pdc_next);
return 0;
}
static struct fdtbus_powerdomain_controller *
fdtbus_powerdomain_lookup(int phandle)
{
struct fdtbus_powerdomain_controller *pdc;
LIST_FOREACH(pdc, &fdtbus_powerdomain_controllers, pdc_next) {
if (pdc->pdc_phandle == phandle)
return pdc;
}
return NULL;
}
static int
fdtbus_powerdomain_enable_internal(int phandle, int index, bool enable)
{
int len;
const uint32_t *pds = fdtbus_get_prop(phandle, "power-domains", &len);
if (pds == NULL)
return EINVAL;
for (const uint32_t *pd = pds; pd < pds + len; index--) {
uint32_t pd_node =
fdtbus_get_phandle_from_native(be32toh(pd[0]));
struct fdtbus_powerdomain_controller *pdc =
fdtbus_powerdomain_lookup(pd_node);
if (pdc == NULL)
return ENXIO;
if (index < 0 || index == 0)
pdc->pdc_funcs->pdc_enable(pdc->pdc_dev, pd, enable);
if (index == 0)
break;
pd += pdc->pdc_cells + 1;
}
return 0;
}
int
fdtbus_powerdomain_enable_index(int phandle, int index)
{
return fdtbus_powerdomain_enable_internal(phandle, index, true);
}
int
fdtbus_powerdomain_disable_index(int phandle, int index)
{
return fdtbus_powerdomain_enable_internal(phandle, index, false);
}
int
fdtbus_powerdomain_enable(int node)
{
return fdtbus_powerdomain_enable_index(node, -1);
}
int
fdtbus_powerdomain_disable(int node)
{
return fdtbus_powerdomain_disable_index(node, -1);
}
--- src/sys/dev/fdt/fdtbus.c 2022/01/22 11:49:17 1.45
+++ src/sys/dev/fdt/fdtbus.c 2022/03/04 08:19:06 1.46
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: fdtbus.c,v 1.45 2022/01/22 11:49:17 thorpej Exp $ */ | 1 | /* $NetBSD: fdtbus.c,v 1.46 2022/03/04 08:19:06 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. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
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 <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.45 2022/01/22 11:49:17 thorpej Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.46 2022/03/04 08:19:06 skrll Exp $"); | |
31 | 31 | |||
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/systm.h> | 33 | #include <sys/systm.h> | |
34 | #include <sys/device.h> | 34 | #include <sys/device.h> | |
35 | #include <sys/kmem.h> | 35 | #include <sys/kmem.h> | |
36 | #include <sys/cpu.h> | 36 | #include <sys/cpu.h> | |
37 | 37 | |||
38 | #include <sys/bus.h> | 38 | #include <sys/bus.h> | |
39 | 39 | |||
40 | #include <dev/ofw/openfirm.h> | 40 | #include <dev/ofw/openfirm.h> | |
41 | 41 | |||
42 | #include <dev/fdt/fdtvar.h> | 42 | #include <dev/fdt/fdtvar.h> | |
43 | 43 | |||
@@ -458,26 +458,28 @@ fdt_pre_attach(struct fdt_node *node) | @@ -458,26 +458,28 @@ fdt_pre_attach(struct fdt_node *node) | |||
458 | int error; | 458 | int error; | |
459 | 459 | |||
460 | node->n_pinctrl_init = fdtbus_pinctrl_has_config(node->n_phandle, "init"); | 460 | node->n_pinctrl_init = fdtbus_pinctrl_has_config(node->n_phandle, "init"); | |
461 | 461 | |||
462 | cfgname = node->n_pinctrl_init ? "init" : "default"; | 462 | cfgname = node->n_pinctrl_init ? "init" : "default"; | |
463 | 463 | |||
464 | aprint_debug_dev(node->n_bus, "set %s config for %s\n", cfgname, node->n_name); | 464 | aprint_debug_dev(node->n_bus, "set %s config for %s\n", cfgname, node->n_name); | |
465 | 465 | |||
466 | error = fdtbus_pinctrl_set_config(node->n_phandle, cfgname); | 466 | error = fdtbus_pinctrl_set_config(node->n_phandle, cfgname); | |
467 | if (error != 0 && error != ENOENT) | 467 | if (error != 0 && error != ENOENT) | |
468 | aprint_debug_dev(node->n_bus, | 468 | aprint_debug_dev(node->n_bus, | |
469 | "failed to set %s config on %s: %d\n", | 469 | "failed to set %s config on %s: %d\n", | |
470 | cfgname, node->n_name, error); | 470 | cfgname, node->n_name, error); | |
471 | ||||
472 | fdtbus_powerdomain_enable(node->n_phandle); | |||
471 | } | 473 | } | |
472 | 474 | |||
473 | static void | 475 | static void | |
474 | fdt_post_attach(struct fdt_node *node) | 476 | fdt_post_attach(struct fdt_node *node) | |
475 | { | 477 | { | |
476 | char buf[FDT_MAX_PATH]; | 478 | char buf[FDT_MAX_PATH]; | |
477 | prop_dictionary_t dict; | 479 | prop_dictionary_t dict; | |
478 | int error; | 480 | int error; | |
479 | 481 | |||
480 | dict = device_properties(node->n_dev); | 482 | dict = device_properties(node->n_dev); | |
481 | if (fdtbus_get_path(node->n_phandle, buf, sizeof(buf))) | 483 | if (fdtbus_get_path(node->n_phandle, buf, sizeof(buf))) | |
482 | prop_dictionary_set_string(dict, "fdt-path", buf); | 484 | prop_dictionary_set_string(dict, "fdt-path", buf); | |
483 | 485 |
--- src/sys/dev/fdt/fdtvar.h 2022/02/23 08:56:11 1.76
+++ src/sys/dev/fdt/fdtvar.h 2022/03/04 08:19:06 1.77
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: fdtvar.h,v 1.76 2022/02/23 08:56:11 skrll Exp $ */ | 1 | /* $NetBSD: fdtvar.h,v 1.77 2022/03/04 08:19:06 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. | |
@@ -147,26 +147,40 @@ struct fdtbus_interrupt_controller_func | @@ -147,26 +147,40 @@ struct fdtbus_interrupt_controller_func | |||
147 | int (*)(void *), void *, const char *); | 147 | int (*)(void *), void *, const char *); | |
148 | void (*disestablish)(device_t, void *); | 148 | void (*disestablish)(device_t, void *); | |
149 | bool (*intrstr)(device_t, u_int *, char *, size_t); | 149 | bool (*intrstr)(device_t, u_int *, char *, size_t); | |
150 | void (*mask)(device_t, void *); | 150 | void (*mask)(device_t, void *); | |
151 | void (*unmask)(device_t, void *); | 151 | void (*unmask)(device_t, void *); | |
152 | }; | 152 | }; | |
153 | 153 | |||
154 | 154 | |||
155 | struct fdtbus_iommu_func { | 155 | struct fdtbus_iommu_func { | |
156 | bus_dma_tag_t (*map)(device_t, const u_int *, bus_dma_tag_t); | 156 | bus_dma_tag_t (*map)(device_t, const u_int *, bus_dma_tag_t); | |
157 | }; | 157 | }; | |
158 | 158 | |||
159 | 159 | |||
160 | struct fdtbus_mbox_channel { | |||
161 | struct fdtbus_mbox_controller *mb_ctlr; | |||
162 | void *mb_priv; | |||
163 | }; | |||
164 | ||||
165 | struct fdtbus_mbox_controller_func { | |||
166 | void * (*mc_acquire)(device_t, const void *, size_t, void (*)(void *), | |||
167 | void *); | |||
168 | void (*mc_release)(device_t, void *); | |||
169 | int (*mc_recv)(device_t, void *, void *, size_t); | |||
170 | int (*mc_send)(device_t, void *, const void *, size_t); | |||
171 | }; | |||
172 | ||||
173 | ||||
160 | struct fdtbus_mmc_pwrseq; | 174 | struct fdtbus_mmc_pwrseq; | |
161 | 175 | |||
162 | struct fdtbus_mmc_pwrseq_func { | 176 | struct fdtbus_mmc_pwrseq_func { | |
163 | void (*pre_power_on)(device_t); | 177 | void (*pre_power_on)(device_t); | |
164 | void (*post_power_on)(device_t); | 178 | void (*post_power_on)(device_t); | |
165 | void (*power_off)(device_t); | 179 | void (*power_off)(device_t); | |
166 | void (*reset)(device_t); | 180 | void (*reset)(device_t); | |
167 | }; | 181 | }; | |
168 | 182 | |||
169 | 183 | |||
170 | struct fdtbus_phy_controller; | 184 | struct fdtbus_phy_controller; | |
171 | 185 | |||
172 | struct fdtbus_phy { | 186 | struct fdtbus_phy { | |
@@ -191,26 +205,33 @@ struct fdtbus_pinctrl_pin { | @@ -191,26 +205,33 @@ struct fdtbus_pinctrl_pin { | |||
191 | struct fdtbus_pinctrl_controller_func { | 205 | struct fdtbus_pinctrl_controller_func { | |
192 | int (*set_config)(device_t, const void *, size_t); | 206 | int (*set_config)(device_t, const void *, size_t); | |
193 | }; | 207 | }; | |
194 | 208 | |||
195 | 209 | |||
196 | struct fdtbus_power_controller; | 210 | struct fdtbus_power_controller; | |
197 | 211 | |||
198 | struct fdtbus_power_controller_func { | 212 | struct fdtbus_power_controller_func { | |
199 | void (*reset)(device_t); | 213 | void (*reset)(device_t); | |
200 | void (*poweroff)(device_t); | 214 | void (*poweroff)(device_t); | |
201 | }; | 215 | }; | |
202 | 216 | |||
203 | 217 | |||
218 | struct fdtbus_powerdomain_controller; | |||
219 | ||||
220 | struct fdtbus_powerdomain_controller_func { | |||
221 | void (*pdc_enable)(device_t, const uint32_t *, bool); | |||
222 | }; | |||
223 | ||||
224 | ||||
204 | struct fdtbus_pwm_controller_func { | 225 | struct fdtbus_pwm_controller_func { | |
205 | pwm_tag_t (*get_tag)(device_t, const void *, size_t); | 226 | pwm_tag_t (*get_tag)(device_t, const void *, size_t); | |
206 | }; | 227 | }; | |
207 | 228 | |||
208 | 229 | |||
209 | struct fdtbus_regulator_controller; | 230 | struct fdtbus_regulator_controller; | |
210 | 231 | |||
211 | struct fdtbus_regulator { | 232 | struct fdtbus_regulator { | |
212 | struct fdtbus_regulator_controller *reg_rc; | 233 | struct fdtbus_regulator_controller *reg_rc; | |
213 | }; | 234 | }; | |
214 | 235 | |||
215 | struct fdtbus_regulator_controller_func { | 236 | struct fdtbus_regulator_controller_func { | |
216 | int (*acquire)(device_t); | 237 | int (*acquire)(device_t); | |
@@ -296,32 +317,36 @@ struct fdt_dma_range { | @@ -296,32 +317,36 @@ struct fdt_dma_range { | |||
296 | int fdtbus_register_clock_controller(device_t, int, | 317 | int fdtbus_register_clock_controller(device_t, int, | |
297 | const struct fdtbus_clock_controller_func *); | 318 | const struct fdtbus_clock_controller_func *); | |
298 | int fdtbus_register_dai_controller(device_t, int, | 319 | int fdtbus_register_dai_controller(device_t, int, | |
299 | const struct fdtbus_dai_controller_func *); | 320 | const struct fdtbus_dai_controller_func *); | |
300 | int fdtbus_register_dma_controller(device_t, int, | 321 | int fdtbus_register_dma_controller(device_t, int, | |
301 | const struct fdtbus_dma_controller_func *); | 322 | const struct fdtbus_dma_controller_func *); | |
302 | int fdtbus_register_gpio_controller(device_t, int, | 323 | int fdtbus_register_gpio_controller(device_t, int, | |
303 | const struct fdtbus_gpio_controller_func *); | 324 | const struct fdtbus_gpio_controller_func *); | |
304 | int fdtbus_register_i2c_controller(i2c_tag_t, int); | 325 | int fdtbus_register_i2c_controller(i2c_tag_t, int); | |
305 | int fdtbus_register_interrupt_controller(device_t, int, | 326 | int fdtbus_register_interrupt_controller(device_t, int, | |
306 | const struct fdtbus_interrupt_controller_func *); | 327 | const struct fdtbus_interrupt_controller_func *); | |
307 | int fdtbus_register_iommu(device_t, int, | 328 | int fdtbus_register_iommu(device_t, int, | |
308 | const struct fdtbus_iommu_func *); | 329 | const struct fdtbus_iommu_func *); | |
330 | int fdtbus_register_mbox_controller(device_t, int, | |||
331 | const struct fdtbus_mbox_controller_func *); | |||
309 | int fdtbus_register_mmc_pwrseq(device_t, int, | 332 | int fdtbus_register_mmc_pwrseq(device_t, int, | |
310 | const struct fdtbus_mmc_pwrseq_func *); | 333 | const struct fdtbus_mmc_pwrseq_func *); | |
311 | int fdtbus_register_pinctrl_config(device_t, int, | 334 | int fdtbus_register_pinctrl_config(device_t, int, | |
312 | const struct fdtbus_pinctrl_controller_func *); | 335 | const struct fdtbus_pinctrl_controller_func *); | |
313 | int fdtbus_register_power_controller(device_t, int, | 336 | int fdtbus_register_power_controller(device_t, int, | |
314 | const struct fdtbus_power_controller_func *); | 337 | const struct fdtbus_power_controller_func *); | |
338 | int fdtbus_register_powerdomain_controller(device_t, int, | |||
339 | const struct fdtbus_powerdomain_controller_func *); | |||
315 | int fdtbus_register_phy_controller(device_t, int, | 340 | int fdtbus_register_phy_controller(device_t, int, | |
316 | const struct fdtbus_phy_controller_func *); | 341 | const struct fdtbus_phy_controller_func *); | |
317 | int fdtbus_register_pwm_controller(device_t, int, | 342 | int fdtbus_register_pwm_controller(device_t, int, | |
318 | const struct fdtbus_pwm_controller_func *); | 343 | const struct fdtbus_pwm_controller_func *); | |
319 | int fdtbus_register_regulator_controller(device_t, int, | 344 | int fdtbus_register_regulator_controller(device_t, int, | |
320 | const struct fdtbus_regulator_controller_func *); | 345 | const struct fdtbus_regulator_controller_func *); | |
321 | int fdtbus_register_reset_controller(device_t, int, | 346 | int fdtbus_register_reset_controller(device_t, int, | |
322 | const struct fdtbus_reset_controller_func *); | 347 | const struct fdtbus_reset_controller_func *); | |
323 | int fdtbus_register_spi_controller(device_t, int, | 348 | int fdtbus_register_spi_controller(device_t, int, | |
324 | const struct fdtbus_spi_controller_func *); | 349 | const struct fdtbus_spi_controller_func *); | |
325 | int fdtbus_register_syscon(device_t, int, struct syscon *); | 350 | int fdtbus_register_syscon(device_t, int, struct syscon *); | |
326 | 351 | |||
327 | void fdtbus_set_decoderegprop(bool); | 352 | void fdtbus_set_decoderegprop(bool); | |
@@ -382,26 +407,35 @@ void * fdtbus_intr_establish_byname(int | @@ -382,26 +407,35 @@ void * fdtbus_intr_establish_byname(int | |||
382 | int (*func)(void *), void *arg, const char *); | 407 | int (*func)(void *), void *arg, const char *); | |
383 | void * fdtbus_intr_establish_raw(int, const u_int *, int, int, | 408 | void * fdtbus_intr_establish_raw(int, const u_int *, int, int, | |
384 | int (*func)(void *), void *arg, const char *); | 409 | int (*func)(void *), void *arg, const char *); | |
385 | void fdtbus_intr_mask(int, void *); | 410 | void fdtbus_intr_mask(int, void *); | |
386 | void fdtbus_intr_unmask(int, void *); | 411 | void fdtbus_intr_unmask(int, void *); | |
387 | void fdtbus_intr_disestablish(int, void *); | 412 | void fdtbus_intr_disestablish(int, void *); | |
388 | bool fdtbus_intr_str(int, u_int, char *, size_t); | 413 | bool fdtbus_intr_str(int, u_int, char *, size_t); | |
389 | bool fdtbus_intr_str_raw(int, const u_int *, char *, size_t); | 414 | bool fdtbus_intr_str_raw(int, const u_int *, char *, size_t); | |
390 | int fdtbus_intr_parent(int); | 415 | int fdtbus_intr_parent(int); | |
391 | 416 | |||
392 | bus_dma_tag_t fdtbus_iommu_map(int, u_int, bus_dma_tag_t); | 417 | bus_dma_tag_t fdtbus_iommu_map(int, u_int, bus_dma_tag_t); | |
393 | bus_dma_tag_t fdtbus_iommu_map_pci(int, uint32_t, bus_dma_tag_t); | 418 | bus_dma_tag_t fdtbus_iommu_map_pci(int, uint32_t, bus_dma_tag_t); | |
394 | 419 | |||
420 | struct fdtbus_mbox_channel * | |||
421 | fdtbus_mbox_get(int, const char *, void (*)(void *), void *); | |||
422 | struct fdtbus_mbox_channel * | |||
423 | fdtbus_mbox_get_index(int, u_int, void (*)(void *), | |||
424 | void *); | |||
425 | int fdtbus_mbox_send(struct fdtbus_mbox_channel *, const void *, size_t); | |||
426 | int fdtbus_mbox_recv(struct fdtbus_mbox_channel *, void *, size_t); | |||
427 | void fdtbus_mbox_put(struct fdtbus_mbox_channel *); | |||
428 | ||||
395 | struct fdtbus_mmc_pwrseq * | 429 | struct fdtbus_mmc_pwrseq * | |
396 | fdtbus_mmc_pwrseq_get(int); | 430 | fdtbus_mmc_pwrseq_get(int); | |
397 | void fdtbus_mmc_pwrseq_pre_power_on(struct fdtbus_mmc_pwrseq *); | 431 | void fdtbus_mmc_pwrseq_pre_power_on(struct fdtbus_mmc_pwrseq *); | |
398 | void fdtbus_mmc_pwrseq_post_power_on(struct fdtbus_mmc_pwrseq *); | 432 | void fdtbus_mmc_pwrseq_post_power_on(struct fdtbus_mmc_pwrseq *); | |
399 | void fdtbus_mmc_pwrseq_power_off(struct fdtbus_mmc_pwrseq *); | 433 | void fdtbus_mmc_pwrseq_power_off(struct fdtbus_mmc_pwrseq *); | |
400 | void fdtbus_mmc_pwrseq_reset(struct fdtbus_mmc_pwrseq *); | 434 | void fdtbus_mmc_pwrseq_reset(struct fdtbus_mmc_pwrseq *); | |
401 | 435 | |||
402 | struct fdtbus_phy * | 436 | struct fdtbus_phy * | |
403 | fdtbus_phy_get(int, const char *); | 437 | fdtbus_phy_get(int, const char *); | |
404 | struct fdtbus_phy * | 438 | struct fdtbus_phy * | |
405 | fdtbus_phy_get_index(int, u_int); | 439 | fdtbus_phy_get_index(int, u_int); | |
406 | void fdtbus_phy_put(struct fdtbus_phy *); | 440 | void fdtbus_phy_put(struct fdtbus_phy *); | |
407 | device_t fdtbus_phy_device(struct fdtbus_phy *); | 441 | device_t fdtbus_phy_device(struct fdtbus_phy *); | |
@@ -437,26 +471,31 @@ int fdtbus_regulator_supports_voltage(s | @@ -437,26 +471,31 @@ int fdtbus_regulator_supports_voltage(s | |||
437 | struct fdtbus_reset * | 471 | struct fdtbus_reset * | |
438 | fdtbus_reset_get(int, const char *); | 472 | fdtbus_reset_get(int, const char *); | |
439 | struct fdtbus_reset * | 473 | struct fdtbus_reset * | |
440 | fdtbus_reset_get_index(int, u_int); | 474 | fdtbus_reset_get_index(int, u_int); | |
441 | void fdtbus_reset_put(struct fdtbus_reset *); | 475 | void fdtbus_reset_put(struct fdtbus_reset *); | |
442 | int fdtbus_reset_assert(struct fdtbus_reset *); | 476 | int fdtbus_reset_assert(struct fdtbus_reset *); | |
443 | int fdtbus_reset_deassert(struct fdtbus_reset *); | 477 | int fdtbus_reset_deassert(struct fdtbus_reset *); | |
444 | 478 | |||
445 | int fdtbus_todr_attach(device_t, int, todr_chip_handle_t); | 479 | int fdtbus_todr_attach(device_t, int, todr_chip_handle_t); | |
446 | 480 | |||
447 | void fdtbus_power_reset(void); | 481 | void fdtbus_power_reset(void); | |
448 | void fdtbus_power_poweroff(void); | 482 | void fdtbus_power_poweroff(void); | |
449 | 483 | |||
484 | int fdtbus_powerdomain_enable(int); | |||
485 | int fdtbus_powerdomain_enable_index(int, int); | |||
486 | int fdtbus_powerdomain_disable(int); | |||
487 | int fdtbus_powerdomain_disable_index(int, int); | |||
488 | ||||
450 | struct syscon * fdtbus_syscon_acquire(int, const char *); | 489 | struct syscon * fdtbus_syscon_acquire(int, const char *); | |
451 | struct syscon * fdtbus_syscon_lookup(int); | 490 | struct syscon * fdtbus_syscon_lookup(int); | |
452 | 491 | |||
453 | 492 | |||
454 | device_t fdtbus_attach_i2cbus(device_t, int, i2c_tag_t, cfprint_t); | 493 | device_t fdtbus_attach_i2cbus(device_t, int, i2c_tag_t, cfprint_t); | |
455 | device_t fdtbus_attach_spibus(device_t, int, cfprint_t); | 494 | device_t fdtbus_attach_spibus(device_t, int, cfprint_t); | |
456 | 495 | |||
457 | bool fdtbus_init(const void *); | 496 | bool fdtbus_init(const void *); | |
458 | const void * fdtbus_get_data(void); | 497 | const void * fdtbus_get_data(void); | |
459 | int fdtbus_phandle2offset(int); | 498 | int fdtbus_phandle2offset(int); | |
460 | int fdtbus_offset2phandle(int); | 499 | int fdtbus_offset2phandle(int); | |
461 | bool fdtbus_get_path(int, char *, size_t); | 500 | bool fdtbus_get_path(int, char *, size_t); | |
462 | 501 |
--- src/sys/dev/fdt/files.fdt 2021/09/04 12:34:39 1.62
+++ src/sys/dev/fdt/files.fdt 2022/03/04 08:19:06 1.63
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: files.fdt,v 1.62 2021/09/04 12:34:39 jmcneill Exp $ | 1 | # $NetBSD: files.fdt,v 1.63 2022/03/04 08:19:06 skrll Exp $ | |
2 | 2 | |||
3 | include "external/bsd/libfdt/conf/files.libfdt" | 3 | include "external/bsd/libfdt/conf/files.libfdt" | |
4 | 4 | |||
5 | defflag opt_fdt.h FDTBASE : libfdt, ofw_subr | 5 | defflag opt_fdt.h FDTBASE : libfdt, ofw_subr | |
6 | defflag opt_fdt.h FDT: FDTBASE | 6 | defflag opt_fdt.h FDT: FDTBASE | |
7 | defparam opt_fdt.h FDT_MEMORY_RANGES | 7 | defparam opt_fdt.h FDT_MEMORY_RANGES | |
8 | defparam opt_fdt.h FDT_DEFAULT_STDOUT_PATH | 8 | defparam opt_fdt.h FDT_DEFAULT_STDOUT_PATH | |
9 | 9 | |||
10 | define fdt { [pass = 10] } : clk, pwm | 10 | define fdt { [pass = 10] } : clk, pwm | |
11 | 11 | |||
12 | device simplebus: fdt | 12 | device simplebus: fdt | |
13 | attach simplebus at fdt | 13 | attach simplebus at fdt | |
14 | file dev/fdt/fdtbus.c fdt | 14 | file dev/fdt/fdtbus.c fdt | |
@@ -64,29 +64,31 @@ file dev/fdt/i2cmux_fdt.c iicmux_fdt | @@ -64,29 +64,31 @@ file dev/fdt/i2cmux_fdt.c iicmux_fdt | |||
64 | 64 | |||
65 | file dev/fdt/fdt_memory.c fdtbase | 65 | file dev/fdt/fdt_memory.c fdtbase | |
66 | file dev/fdt/fdt_openfirm.c fdtbase | 66 | file dev/fdt/fdt_openfirm.c fdtbase | |
67 | file dev/fdt/fdt_subr.c fdtbase | 67 | file dev/fdt/fdt_subr.c fdtbase | |
68 | 68 | |||
69 | file dev/fdt/fdt_clock.c fdt | 69 | file dev/fdt/fdt_clock.c fdt | |
70 | file dev/fdt/fdt_dai.c fdt | 70 | file dev/fdt/fdt_dai.c fdt | |
71 | file dev/fdt/fdt_dma.c fdt | 71 | file dev/fdt/fdt_dma.c fdt | |
72 | file dev/fdt/fdt_ddb.c fdt & ddb | 72 | file dev/fdt/fdt_ddb.c fdt & ddb | |
73 | file dev/fdt/fdt_gpio.c fdt | 73 | file dev/fdt/fdt_gpio.c fdt | |
74 | file dev/fdt/fdt_i2c.c fdt | 74 | file dev/fdt/fdt_i2c.c fdt | |
75 | file dev/fdt/fdt_iommu.c fdt | 75 | file dev/fdt/fdt_iommu.c fdt | |
76 | file dev/fdt/fdt_intr.c fdt | 76 | file dev/fdt/fdt_intr.c fdt | |
77 | file dev/fdt/fdt_mbox.c fdt | |||
77 | file dev/fdt/fdt_mmc_pwrseq.c fdt | 78 | file dev/fdt/fdt_mmc_pwrseq.c fdt | |
78 | file dev/fdt/fdt_phy.c fdt | 79 | file dev/fdt/fdt_phy.c fdt | |
79 | file dev/fdt/fdt_power.c fdt | 80 | file dev/fdt/fdt_power.c fdt | |
81 | file dev/fdt/fdt_powerdomain.c fdt | |||
80 | file dev/fdt/fdt_pwm.c fdt | 82 | file dev/fdt/fdt_pwm.c fdt | |
81 | file dev/fdt/fdt_regulator.c fdt | 83 | file dev/fdt/fdt_regulator.c fdt | |
82 | file dev/fdt/fdt_reset.c fdt | 84 | file dev/fdt/fdt_reset.c fdt | |
83 | file dev/fdt/fdt_rtc.c fdt | 85 | file dev/fdt/fdt_rtc.c fdt | |
84 | file dev/fdt/fdt_spi.c fdt | 86 | file dev/fdt/fdt_spi.c fdt | |
85 | file dev/fdt/fdt_syscon.c fdt | 87 | file dev/fdt/fdt_syscon.c fdt | |
86 | file dev/fdt/fdt_pinctrl.c fdt | 88 | file dev/fdt/fdt_pinctrl.c fdt | |
87 | 89 | |||
88 | device cpus: fdt | 90 | device cpus: fdt | |
89 | attach cpus at fdt | 91 | attach cpus at fdt | |
90 | file dev/fdt/cpus.c cpus | 92 | file dev/fdt/cpus.c cpus | |
91 | 93 | |||
92 | device mmcpwrseq | 94 | device mmcpwrseq |