1/*-
2 * Copyright (c) 2016 Michael Zhilin <mizhka@gmail.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
--- 9 unchanged lines hidden (view full) ---
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.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/bhnd/bcma/bcma_nexus.c 300252 2016-05-20 01:02:58Z adrian $");
32
33#include <sys/param.h>
34#include <sys/kernel.h>
35#include <sys/bus.h>
36#include <sys/module.h>
37#include <sys/errno.h>
38
39#include <machine/bus.h>
40#include <machine/resource.h>
41
42#include
43
44#include "bhnd_bus_if.h"
45#include "bcmavar.h"
46#include "bcma_eromreg.h"
47
48#define BCMA_NEXUS_EROM_RID 10
49
50static int
51bcma_nexus_probe(device_t dev)
52{
53 const struct bhnd_chipid *cid = BHND_BUS_GET_CHIPID(device_get_parent(dev), dev);
54
55 /* Check bus type */
56 if (cid->chip_type != BHND_CHIPTYPE_BCMA)
57 return (ENXIO);
58
59 /* Delegate to default probe implementation */
60 return (bcma_probe(dev));
61}
62
63static int
64bcma_nexus_attach(device_t dev)
65{
66 int erom_rid;
67 int error;
68 struct resource *erom_res;
69 const struct bhnd_chipid *cid = BHND_BUS_GET_CHIPID(device_get_parent(dev), dev);
70
71 erom_rid = BCMA_NEXUS_EROM_RID;
72 error = bus_set_resource(dev, SYS_RES_MEMORY, erom_rid, cid->enum_addr, BCMA_EROM_TABLE_SIZE);
73 if (error != 0) {
74 BHND_ERROR_DEV(dev, "failed to set EROM resource");
75 return (error);
76 }
77
78 /* Map the EROM resource and enumerate our children. */
79 BHND_DEBUG_DEV(dev, "erom enum address: %jx", cid->enum_addr);
80 erom_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &erom_rid, RF_ACTIVE);
81 if (erom_res == NULL) {
82 BHND_ERROR_DEV(dev, "failed to allocate EROM resource");
83 return (ENXIO);
84 }
85
86 BHND_DEBUG_DEV(dev, "erom scanning start address: %p", rman_get_virtual(erom_res));
87 error = bcma_add_children(dev, erom_res, BCMA_EROM_TABLE_START);
88
89 /* Clean up */
90 bus_release_resource(dev, SYS_RES_MEMORY, erom_rid, erom_res);
91 if (error)
92 return (error);
93
94 /* Call our superclass' implementation */
95 return (bcma_attach(dev));
96}
97
98static device_method_t bcma_nexus_methods[] = {
99 /* Device interface */
100 DEVMETHOD(device_probe, bcma_nexus_probe),
101 DEVMETHOD(device_attach, bcma_nexus_attach),
102 DEVMETHOD_END
103};
104
105DEFINE_CLASS_1(bhnd, bcma_nexus_driver, bcma_nexus_methods, sizeof(struct bcma_softc), bcma_driver);
106EARLY_DRIVER_MODULE(bcma_nexus, bhnd_soc, bcma_nexus_driver, bhnd_devclass,
107 NULL, NULL, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
108
109MODULE_VERSION(bcma_nexus, 1);
110MODULE_DEPEND(bcma_nexus, bcma, 1, 1, 1);
111MODULE_DEPEND(bcma_nexus, bhnd_soc, 1, 1, 1);
2 * Copyright (c) 2016 Michael Zhilin <mizhka@gmail.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
--- 9 unchanged lines hidden (view full) ---
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.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/bhnd/bcma/bcma_nexus.c 300252 2016-05-20 01:02:58Z adrian $");
32
33#include <sys/param.h>
34#include <sys/kernel.h>
35#include <sys/bus.h>
36#include <sys/module.h>
37#include <sys/errno.h>
38
39#include <machine/bus.h>
40#include <machine/resource.h>
41
42#include
43
44#include "bhnd_bus_if.h"
45#include "bcmavar.h"
46#include "bcma_eromreg.h"
47
48#define BCMA_NEXUS_EROM_RID 10
49
50static int
51bcma_nexus_probe(device_t dev)
52{
53 const struct bhnd_chipid *cid = BHND_BUS_GET_CHIPID(device_get_parent(dev), dev);
54
55 /* Check bus type */
56 if (cid->chip_type != BHND_CHIPTYPE_BCMA)
57 return (ENXIO);
58
59 /* Delegate to default probe implementation */
60 return (bcma_probe(dev));
61}
62
63static int
64bcma_nexus_attach(device_t dev)
65{
66 int erom_rid;
67 int error;
68 struct resource *erom_res;
69 const struct bhnd_chipid *cid = BHND_BUS_GET_CHIPID(device_get_parent(dev), dev);
70
71 erom_rid = BCMA_NEXUS_EROM_RID;
72 error = bus_set_resource(dev, SYS_RES_MEMORY, erom_rid, cid->enum_addr, BCMA_EROM_TABLE_SIZE);
73 if (error != 0) {
74 BHND_ERROR_DEV(dev, "failed to set EROM resource");
75 return (error);
76 }
77
78 /* Map the EROM resource and enumerate our children. */
79 BHND_DEBUG_DEV(dev, "erom enum address: %jx", cid->enum_addr);
80 erom_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &erom_rid, RF_ACTIVE);
81 if (erom_res == NULL) {
82 BHND_ERROR_DEV(dev, "failed to allocate EROM resource");
83 return (ENXIO);
84 }
85
86 BHND_DEBUG_DEV(dev, "erom scanning start address: %p", rman_get_virtual(erom_res));
87 error = bcma_add_children(dev, erom_res, BCMA_EROM_TABLE_START);
88
89 /* Clean up */
90 bus_release_resource(dev, SYS_RES_MEMORY, erom_rid, erom_res);
91 if (error)
92 return (error);
93
94 /* Call our superclass' implementation */
95 return (bcma_attach(dev));
96}
97
98static device_method_t bcma_nexus_methods[] = {
99 /* Device interface */
100 DEVMETHOD(device_probe, bcma_nexus_probe),
101 DEVMETHOD(device_attach, bcma_nexus_attach),
102 DEVMETHOD_END
103};
104
105DEFINE_CLASS_1(bhnd, bcma_nexus_driver, bcma_nexus_methods, sizeof(struct bcma_softc), bcma_driver);
106EARLY_DRIVER_MODULE(bcma_nexus, bhnd_soc, bcma_nexus_driver, bhnd_devclass,
107 NULL, NULL, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
108
109MODULE_VERSION(bcma_nexus, 1);
110MODULE_DEPEND(bcma_nexus, bcma, 1, 1, 1);
111MODULE_DEPEND(bcma_nexus, bhnd_soc, 1, 1, 1);