2 * Copyright (c) 2016 Michael Zhilin <mizhka@gmail.com>
3 * Copyright (c) 2015-2016 Landon Fuller <landon@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.
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/kernel.h>
39 #include <sys/module.h>
41 #include <machine/bus.h>
43 #include <machine/resource.h>
45 #include <dev/bhnd/bhnd_ids.h>
47 #include <dev/bhnd/bcma/bcmavar.h>
48 #include <dev/bhnd/bcma/bcma_dmp.h>
50 #include "bcm_mipsvar.h"
51 #include "bcm_machdep.h"
53 #include "bhnd_nexusvar.h"
56 * Supports bcma(4) attachment to a MIPS nexus bus.
59 static int bcma_nexus_attach(device_t);
60 static int bcma_nexus_probe(device_t);
62 _Static_assert(BCMA_OOB_NUM_BUSLINES == BCM_MIPS_NINTR, "BCMA incompatible "
63 "with generic NINTR");
66 bcma_nexus_probe(device_t dev)
70 switch (bcm_get_platform()->cid.chip_type) {
71 case BHND_CHIPTYPE_BCMA:
72 case BHND_CHIPTYPE_BCMA_ALT:
73 case BHND_CHIPTYPE_UBUS:
79 if ((error = bcma_probe(dev)) > 0)
82 /* Set device description */
83 bhnd_set_default_bus_desc(dev, &bcm_get_platform()->cid);
85 return (BUS_PROBE_SPECIFIC);
89 bcma_nexus_attach(device_t dev)
93 /* Perform initial attach and enumerate our children. */
94 if ((error = bcma_attach(dev)))
97 /* Delegate remainder to standard bhnd method implementation */
98 if ((error = bhnd_generic_attach(dev)))
104 device_delete_children(dev);
108 static device_method_t bcma_nexus_methods[] = {
109 DEVMETHOD(device_probe, bcma_nexus_probe),
110 DEVMETHOD(device_attach, bcma_nexus_attach),
115 DEFINE_CLASS_2(bhnd, bcma_nexus_driver, bcma_nexus_methods,
116 sizeof(struct bcma_softc), bhnd_nexus_driver, bcma_driver);
118 EARLY_DRIVER_MODULE(bcma_nexus, nexus, bcma_nexus_driver, bhnd_devclass, 0, 0,
119 BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);