2 * Copyright (c) 2016 Michael Zhilin <mizhka@gmail.com>
3 * Copyright (c) 2016 Landon Fuller <landonf@FreeBSD.org>
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 * without modification.
12 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
13 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
14 * redistribution must be conditioned upon including a substantially
15 * similar Disclaimer requirement for further binary redistribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
21 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
23 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGES.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include <sys/param.h>
35 #include <sys/kernel.h>
37 #include <sys/module.h>
39 #include <machine/bus.h>
41 #include <machine/resource.h>
43 #include <dev/bhnd/bhnd.h>
45 #include "bcm_mips74kreg.h"
48 * Broadcom MIPS74K Core
50 * These cores are only found on bcma(4) chipsets, allowing
51 * us to assume the availability of bcma interrupt registers.
54 static const struct bhnd_device bcm_mips74k_devs[] = {
55 BHND_DEVICE(MIPS, MIPS74K, NULL, NULL, BHND_DF_SOC),
59 struct bcm_mips74k_softc {
61 struct resource *mem_res;
66 bcm_mips74k_probe(device_t dev)
68 const struct bhnd_device *id;
70 id = bhnd_device_lookup(dev, bcm_mips74k_devs,
71 sizeof(bcm_mips74k_devs[0]));
75 bhnd_set_default_core_desc(dev);
76 return (BUS_PROBE_DEFAULT);
80 bcm_mips74k_attach(device_t dev)
82 struct bcm_mips74k_softc *sc;
84 sc = device_get_softc(dev);
87 /* Allocate bus resources */
89 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid,
91 if (sc->mem_res == NULL)
94 /* Route MIPS timer to IRQ5 */
95 bus_write_4(sc->mem_res, BCM_MIPS74K_INTR5_SEL,
96 (1<<BCM_MIPS74K_TIMER_IVEC));
102 bcm_mips74k_detach(device_t dev)
104 struct bcm_mips74k_softc *sc;
106 sc = device_get_softc(dev);
108 bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res);
113 static device_method_t bcm_mips74k_methods[] = {
114 /* Device interface */
115 DEVMETHOD(device_probe, bcm_mips74k_probe),
116 DEVMETHOD(device_attach, bcm_mips74k_attach),
117 DEVMETHOD(device_detach, bcm_mips74k_detach),
122 static devclass_t bcm_mips_devclass;
124 DEFINE_CLASS_0(bcm_mips, bcm_mips74k_driver, bcm_mips74k_methods, sizeof(struct bcm_mips74k_softc));
125 EARLY_DRIVER_MODULE(bcm_mips74k, bhnd, bcm_mips74k_driver, bcm_mips_devclass, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_EARLY);
126 MODULE_VERSION(bcm_mips74k, 1);
127 MODULE_DEPEND(bcm_mips74k, bhnd, 1, 1, 1);