2 * Copyright (c) 2019 Emmanuel Vadot <manu@FreeBSD.org>
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
20 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
31 #include <sys/param.h>
32 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/module.h>
38 #include <sys/resource.h>
39 #include <machine/bus.h>
41 #include <vm/vm_extern.h>
42 #include <vm/vm_kern.h>
45 #include <dev/fdt/simplebus.h>
47 #include <dev/ofw/ofw_bus.h>
48 #include <dev/ofw/ofw_bus_subr.h>
50 static struct ofw_compat_data compat_data[] = {
55 struct ti_sysc_softc {
56 struct simplebus_softc sc;
60 static int ti_sysc_probe(device_t dev);
61 static int ti_sysc_attach(device_t dev);
62 static int ti_sysc_detach(device_t dev);
65 ti_sysc_probe(device_t dev)
67 if (!ofw_bus_status_okay(dev))
70 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
73 device_set_desc(dev, "TI SYSC Interconnect");
77 return (BUS_PROBE_DEFAULT);
81 ti_sysc_attach(device_t dev)
83 struct ti_sysc_softc *sc;
85 phandle_t node, child;
87 sc = device_get_softc(dev);
89 node = ofw_bus_get_node(dev);
91 simplebus_init(dev, node);
92 if (simplebus_fill_ranges(node, &sc->sc) < 0) {
93 device_printf(dev, "could not get ranges\n");
97 for (child = OF_child(node); child > 0; child = OF_peer(child)) {
98 cdev = simplebus_add_device(dev, child, 0, NULL, -1, NULL);
100 device_probe_and_attach(cdev);
103 return (bus_generic_attach(dev));
107 ti_sysc_detach(device_t dev)
113 static device_method_t ti_sysc_methods[] = {
114 /* Device interface */
115 DEVMETHOD(device_probe, ti_sysc_probe),
116 DEVMETHOD(device_attach, ti_sysc_attach),
117 DEVMETHOD(device_detach, ti_sysc_detach),
122 DEFINE_CLASS_1(ti_sysc, ti_sysc_driver, ti_sysc_methods,
123 sizeof(struct ti_sysc_softc), simplebus_driver);
125 static devclass_t ti_sysc_devclass;
127 EARLY_DRIVER_MODULE(ti_sysc, simplebus, ti_sysc_driver,
128 ti_sysc_devclass, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_FIRST);