2 * Copyright (c) 2015-2016 Landon Fuller <landon@freebsd.org>
3 * Copyright (c) 2007 Bruce M. Simpson.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * 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/kernel.h>
34 #include <sys/module.h>
36 #include <machine/bus.h>
38 #include <machine/resource.h>
40 #include <dev/bhnd/bhnd_ids.h>
41 #include <dev/bhnd/bhnd_nexusvar.h>
42 #include <dev/bhnd/cores/chipc/chipcreg.h>
47 * Supports siba(4) attachment to a MIPS nexus bus.
49 * Derived from Bruce M. Simpson' original siba(4) driver.
52 struct siba_nexus_softc {
53 struct siba_softc parent_sc;
54 struct bhnd_chipid siba_cid;
58 siba_nexus_probe(device_t dev)
60 struct siba_nexus_softc *sc;
63 sc = device_get_softc(dev);
65 /* Read the ChipCommon info using the hints the kernel
66 * was compiled with. */
67 if ((error = bhnd_nexus_read_chipid(dev, &sc->siba_cid)))
70 if (sc->siba_cid.chip_type != BHND_CHIPTYPE_SIBA)
73 if ((error = siba_probe(dev)) > 0) {
74 device_printf(dev, "error %d in probe\n", error);
78 /* Set device description */
79 bhnd_set_default_bus_desc(dev, &sc->siba_cid);
85 siba_nexus_attach(device_t dev)
89 /* Perform initial attach and enumerate our children. */
90 if ((error = siba_attach(dev)))
93 /* Delegate remainder to standard bhnd method implementation */
94 if ((error = bhnd_generic_attach(dev)))
100 device_delete_children(dev);
104 static const struct bhnd_chipid *
105 siba_nexus_get_chipid(device_t dev, device_t child) {
106 struct siba_nexus_softc *sc = device_get_softc(dev);
107 return (&sc->siba_cid);
110 static device_method_t siba_nexus_methods[] = {
111 /* Device interface */
112 DEVMETHOD(device_probe, siba_nexus_probe),
113 DEVMETHOD(device_attach, siba_nexus_attach),
116 DEVMETHOD(bhnd_bus_get_chipid, siba_nexus_get_chipid),
121 DEFINE_CLASS_2(bhnd, siba_nexus_driver, siba_nexus_methods,
122 sizeof(struct siba_nexus_softc), bhnd_nexus_driver, siba_driver);
124 EARLY_DRIVER_MODULE(siba_nexus, nexus, siba_nexus_driver, bhnd_devclass, 0, 0,
125 BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);