2 * Copyright (c) 2016 Michael Zhilin <mizhka@gmail.com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 * redistribution must be conditioned upon including a substantially
14 * similar Disclaimer requirement for further binary redistribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include <sys/param.h>
34 #include <sys/kernel.h>
36 #include <sys/module.h>
37 #include <sys/systm.h>
38 #include <sys/errno.h>
40 #include <sys/stddef.h>
42 #include <machine/bus.h>
43 #include <machine/resource.h>
45 #include <dev/bhnd/bhnd.h>
46 #include <dev/bhnd/bhndvar.h>
47 #include <dev/bhnd/bhnd_ids.h>
49 #include "bcm_mipscore.h"
51 static const struct resource_spec mipscore_rspec[MIPSCORE_MAX_RSPEC] = {
52 { SYS_RES_MEMORY, 0, RF_ACTIVE },
56 struct bhnd_device mipscore_match[] = {
57 BHND_MIPS_DEVICE(MIPS, "BHND MIPS processor", NULL),
58 BHND_MIPS_DEVICE(MIPS33, "BHND MIPS3302 processor", NULL),
59 BHND_MIPS_DEVICE(MIPS74K, "BHND MIPS74K processor", NULL),
64 mipscore_probe(device_t dev)
66 const struct bhnd_device *id;
68 id = bhnd_device_lookup(dev, mipscore_match, sizeof(mipscore_match[0]));
72 bhnd_set_default_core_desc(dev);
73 return (BUS_PROBE_DEFAULT);
77 mipscore_attach(device_t dev)
79 struct mipscore_softc *sc;
85 sc = device_get_softc(dev);
86 devid = bhnd_get_device(dev);
91 /* Allocate bus resources */
92 memcpy(sc->rspec, mipscore_rspec, sizeof(sc->rspec));
93 error = bhnd_alloc_resources(dev, sc->rspec, sc->res);
97 res = sc->res[0]->res;
101 if (devid == BHND_COREID_MIPS74K) {
103 /* Use intmask5 register to route the timer interrupt */
104 bus_write_4(res, offsetof(struct mipscore_regs, intmask[5]),
111 static device_method_t mipscore_methods[] = {
112 DEVMETHOD(device_probe, mipscore_probe),
113 DEVMETHOD(device_attach, mipscore_attach),
117 devclass_t bhnd_mipscore_devclass;
119 DEFINE_CLASS_0(bhnd_mipscore, mipscore_driver, mipscore_methods,
120 sizeof(struct mipscore_softc));
121 DRIVER_MODULE(bhnd_mipscore, bhnd, mipscore_driver, bhnd_mipscore_devclass,
123 MODULE_VERSION(bhnd_mipscore, 1);