2a3
> * Copyright (c) 2015-2016 Landon Fuller <landon@freebsd.org>
27a29,30
> *
> * $FreeBSD: head/sys/dev/bhnd/bcma/bcma_nexus.c 301410 2016-06-04 19:53:47Z landonf $
31c34
< __FBSDID("$FreeBSD: head/sys/dev/bhnd/bcma/bcma_nexus.c 300252 2016-05-20 01:02:58Z adrian $");
---
> __FBSDID("$FreeBSD: head/sys/dev/bhnd/bcma/bcma_nexus.c 301410 2016-06-04 19:53:47Z landonf $");
37d39
< #include <sys/errno.h>
39a42
> #include <sys/rman.h>
42c45,47
< #include <dev/bhnd/bhnd.h>
---
> #include <dev/bhnd/bhnd_ids.h>
> #include <dev/bhnd/bhnd_nexusvar.h>
> #include <dev/bhnd/cores/chipc/chipcreg.h>
44d48
< #include "bhnd_bus_if.h"
48c52,54
< #define BCMA_NEXUS_EROM_RID 10
---
> /*
> * Supports bcma(4) attachment to a nexus bus.
> */
49a56,63
> static int bcma_nexus_attach(device_t);
> static int bcma_nexus_probe(device_t);
>
> struct bcma_nexus_softc {
> struct bcma_softc parent_sc;
> struct bhnd_chipid bcma_cid;
> };
>
53c67,68
< const struct bhnd_chipid *cid = BHND_BUS_GET_CHIPID(device_get_parent(dev), dev);
---
> struct bcma_nexus_softc *sc;
> int error;
55,56c70,77
< /* Check bus type */
< if (cid->chip_type != BHND_CHIPTYPE_BCMA)
---
> sc = device_get_softc(dev);
>
> /* Read the ChipCommon info using the hints the kernel
> * was compiled with. */
> if ((error = bhnd_nexus_read_chipid(dev, &sc->bcma_cid)))
> return (error);
>
> if (sc->bcma_cid.chip_type != BHND_CHIPTYPE_BCMA)
59,60c80,85
< /* Delegate to default probe implementation */
< return (bcma_probe(dev));
---
> if ((error = bcma_probe(dev)) > 0) {
> device_printf(dev, "error %d in probe\n", error);
> return (error);
> }
>
> return (0);
66,69c91,94
< int erom_rid;
< int error;
< struct resource *erom_res;
< const struct bhnd_chipid *cid = BHND_BUS_GET_CHIPID(device_get_parent(dev), dev);
---
> struct bcma_nexus_softc *sc;
> struct resource *erom_res;
> int error;
> int rid;
71,76c96
< erom_rid = BCMA_NEXUS_EROM_RID;
< error = bus_set_resource(dev, SYS_RES_MEMORY, erom_rid, cid->enum_addr, BCMA_EROM_TABLE_SIZE);
< if (error != 0) {
< BHND_ERROR_DEV(dev, "failed to set EROM resource");
< return (error);
< }
---
> sc = device_get_softc(dev);
78,84c98,107
< /* Map the EROM resource and enumerate our children. */
< BHND_DEBUG_DEV(dev, "erom enum address: %jx", cid->enum_addr);
< erom_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &erom_rid, RF_ACTIVE);
< if (erom_res == NULL) {
< BHND_ERROR_DEV(dev, "failed to allocate EROM resource");
< return (ENXIO);
< }
---
> /* Map the EROM resource and enumerate the bus. */
> rid = 0;
> erom_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
> sc->bcma_cid.enum_addr,
> sc->bcma_cid.enum_addr + BCMA_EROM_TABLE_SIZE,
> BCMA_EROM_TABLE_SIZE, RF_ACTIVE);
> if (erom_res == NULL) {
> device_printf(dev, "failed to allocate EROM resource\n");
> return (ENXIO);
> }
86,87c109,110
< BHND_DEBUG_DEV(dev, "erom scanning start address: %p", rman_get_virtual(erom_res));
< error = bcma_add_children(dev, erom_res, BCMA_EROM_TABLE_START);
---
> error = bcma_add_children(dev, erom_res, BCMA_EROM_TABLE_START);
> bus_release_resource(dev, SYS_RES_MEMORY, rid, erom_res);
89,92c112,113
< /* Clean up */
< bus_release_resource(dev, SYS_RES_MEMORY, erom_rid, erom_res);
< if (error)
< return (error);
---
> if (error)
> return (error);
94,95c115
< /* Call our superclass' implementation */
< return (bcma_attach(dev));
---
> return (bcma_attach(dev));
97a118,123
> static const struct bhnd_chipid *
> bcma_nexus_get_chipid(device_t dev, device_t child) {
> struct bcma_nexus_softc *sc = device_get_softc(dev);
> return (&sc->bcma_cid);
> }
>
101a128,131
>
> /* bhnd interface */
> DEVMETHOD(bhnd_bus_get_chipid, bcma_nexus_get_chipid),
>
105,107c135,136
< DEFINE_CLASS_1(bhnd, bcma_nexus_driver, bcma_nexus_methods, sizeof(struct bcma_softc), bcma_driver);
< EARLY_DRIVER_MODULE(bcma_nexus, bhnd_soc, bcma_nexus_driver, bhnd_devclass,
< NULL, NULL, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
---
> DEFINE_CLASS_2(bhnd, bcma_nexus_driver, bcma_nexus_methods,
> sizeof(struct bcma_nexus_softc), bhnd_nexus_driver, bcma_driver);
109,111c138
< MODULE_VERSION(bcma_nexus, 1);
< MODULE_DEPEND(bcma_nexus, bcma, 1, 1, 1);
< MODULE_DEPEND(bcma_nexus, bhnd_soc, 1, 1, 1);
---
> DRIVER_MODULE(bcma_nexus, nexus, bcma_nexus_driver, bhnd_devclass, 0, 0);
> * Copyright (c) 2015-2016 Landon Fuller <landon@freebsd.org>
27a29,30
> *
> * $FreeBSD: head/sys/dev/bhnd/bcma/bcma_nexus.c 301410 2016-06-04 19:53:47Z landonf $
31c34
< __FBSDID("$FreeBSD: head/sys/dev/bhnd/bcma/bcma_nexus.c 300252 2016-05-20 01:02:58Z adrian $");
---
> __FBSDID("$FreeBSD: head/sys/dev/bhnd/bcma/bcma_nexus.c 301410 2016-06-04 19:53:47Z landonf $");
37d39
< #include <sys/errno.h>
39a42
> #include <sys/rman.h>
42c45,47
< #include <dev/bhnd/bhnd.h>
---
> #include <dev/bhnd/bhnd_ids.h>
> #include <dev/bhnd/bhnd_nexusvar.h>
> #include <dev/bhnd/cores/chipc/chipcreg.h>
44d48
< #include "bhnd_bus_if.h"
48c52,54
< #define BCMA_NEXUS_EROM_RID 10
---
> /*
> * Supports bcma(4) attachment to a nexus bus.
> */
49a56,63
> static int bcma_nexus_attach(device_t);
> static int bcma_nexus_probe(device_t);
>
> struct bcma_nexus_softc {
> struct bcma_softc parent_sc;
> struct bhnd_chipid bcma_cid;
> };
>
53c67,68
< const struct bhnd_chipid *cid = BHND_BUS_GET_CHIPID(device_get_parent(dev), dev);
---
> struct bcma_nexus_softc *sc;
> int error;
55,56c70,77
< /* Check bus type */
< if (cid->chip_type != BHND_CHIPTYPE_BCMA)
---
> sc = device_get_softc(dev);
>
> /* Read the ChipCommon info using the hints the kernel
> * was compiled with. */
> if ((error = bhnd_nexus_read_chipid(dev, &sc->bcma_cid)))
> return (error);
>
> if (sc->bcma_cid.chip_type != BHND_CHIPTYPE_BCMA)
59,60c80,85
< /* Delegate to default probe implementation */
< return (bcma_probe(dev));
---
> if ((error = bcma_probe(dev)) > 0) {
> device_printf(dev, "error %d in probe\n", error);
> return (error);
> }
>
> return (0);
66,69c91,94
< int erom_rid;
< int error;
< struct resource *erom_res;
< const struct bhnd_chipid *cid = BHND_BUS_GET_CHIPID(device_get_parent(dev), dev);
---
> struct bcma_nexus_softc *sc;
> struct resource *erom_res;
> int error;
> int rid;
71,76c96
< erom_rid = BCMA_NEXUS_EROM_RID;
< error = bus_set_resource(dev, SYS_RES_MEMORY, erom_rid, cid->enum_addr, BCMA_EROM_TABLE_SIZE);
< if (error != 0) {
< BHND_ERROR_DEV(dev, "failed to set EROM resource");
< return (error);
< }
---
> sc = device_get_softc(dev);
78,84c98,107
< /* Map the EROM resource and enumerate our children. */
< BHND_DEBUG_DEV(dev, "erom enum address: %jx", cid->enum_addr);
< erom_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &erom_rid, RF_ACTIVE);
< if (erom_res == NULL) {
< BHND_ERROR_DEV(dev, "failed to allocate EROM resource");
< return (ENXIO);
< }
---
> /* Map the EROM resource and enumerate the bus. */
> rid = 0;
> erom_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
> sc->bcma_cid.enum_addr,
> sc->bcma_cid.enum_addr + BCMA_EROM_TABLE_SIZE,
> BCMA_EROM_TABLE_SIZE, RF_ACTIVE);
> if (erom_res == NULL) {
> device_printf(dev, "failed to allocate EROM resource\n");
> return (ENXIO);
> }
86,87c109,110
< BHND_DEBUG_DEV(dev, "erom scanning start address: %p", rman_get_virtual(erom_res));
< error = bcma_add_children(dev, erom_res, BCMA_EROM_TABLE_START);
---
> error = bcma_add_children(dev, erom_res, BCMA_EROM_TABLE_START);
> bus_release_resource(dev, SYS_RES_MEMORY, rid, erom_res);
89,92c112,113
< /* Clean up */
< bus_release_resource(dev, SYS_RES_MEMORY, erom_rid, erom_res);
< if (error)
< return (error);
---
> if (error)
> return (error);
94,95c115
< /* Call our superclass' implementation */
< return (bcma_attach(dev));
---
> return (bcma_attach(dev));
97a118,123
> static const struct bhnd_chipid *
> bcma_nexus_get_chipid(device_t dev, device_t child) {
> struct bcma_nexus_softc *sc = device_get_softc(dev);
> return (&sc->bcma_cid);
> }
>
101a128,131
>
> /* bhnd interface */
> DEVMETHOD(bhnd_bus_get_chipid, bcma_nexus_get_chipid),
>
105,107c135,136
< DEFINE_CLASS_1(bhnd, bcma_nexus_driver, bcma_nexus_methods, sizeof(struct bcma_softc), bcma_driver);
< EARLY_DRIVER_MODULE(bcma_nexus, bhnd_soc, bcma_nexus_driver, bhnd_devclass,
< NULL, NULL, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
---
> DEFINE_CLASS_2(bhnd, bcma_nexus_driver, bcma_nexus_methods,
> sizeof(struct bcma_nexus_softc), bhnd_nexus_driver, bcma_driver);
109,111c138
< MODULE_VERSION(bcma_nexus, 1);
< MODULE_DEPEND(bcma_nexus, bcma, 1, 1, 1);
< MODULE_DEPEND(bcma_nexus, bhnd_soc, 1, 1, 1);
---
> DRIVER_MODULE(bcma_nexus, nexus, bcma_nexus_driver, bhnd_devclass, 0, 0);