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>
49 #include "bcm_machdep.h"
51 #include "bhnd_nexusvar.h"
54 * Supports bcma(4) attachment to a MIPS nexus bus.
57 static int bcma_nexus_attach(device_t);
58 static int bcma_nexus_probe(device_t);
61 bcma_nexus_probe(device_t dev)
65 switch (bcm_get_platform()->cid.chip_type) {
66 case BHND_CHIPTYPE_BCMA:
67 case BHND_CHIPTYPE_BCMA_ALT:
68 case BHND_CHIPTYPE_UBUS:
74 if ((error = bcma_probe(dev)) > 0)
77 /* Set device description */
78 bhnd_set_default_bus_desc(dev, &bcm_get_platform()->cid);
80 return (BUS_PROBE_SPECIFIC);
84 bcma_nexus_attach(device_t dev)
88 /* Perform initial attach and enumerate our children. */
89 if ((error = bcma_attach(dev)))
92 /* Delegate remainder to standard bhnd method implementation */
93 if ((error = bhnd_generic_attach(dev)))
99 device_delete_children(dev);
103 static device_method_t bcma_nexus_methods[] = {
104 DEVMETHOD(device_probe, bcma_nexus_probe),
105 DEVMETHOD(device_attach, bcma_nexus_attach),
110 DEFINE_CLASS_2(bhnd, bcma_nexus_driver, bcma_nexus_methods,
111 sizeof(struct bcma_softc), bhnd_nexus_driver, bcma_driver);
113 EARLY_DRIVER_MODULE(bcma_nexus, nexus, bcma_nexus_driver, bhnd_devclass, 0, 0,
114 BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);