Index: sys/conf/files =================================================================== --- sys/conf/files +++ sys/conf/files @@ -1189,8 +1189,6 @@ dev/bhnd/bhnd.c optional bhnd dev/bhnd/bhnd_erom.c optional bhnd dev/bhnd/bhnd_erom_if.m optional bhnd -dev/bhnd/bhnd_nexus.c optional bhnd siba_nexus | \ - bhnd bcma_nexus dev/bhnd/bhnd_subr.c optional bhnd dev/bhnd/bhnd_bus_if.m optional bhnd dev/bhnd/bhndb/bhnd_bhndb.c optional bhndb bhnd @@ -1205,7 +1203,6 @@ dev/bhnd/bcma/bcma.c optional bcma bhnd dev/bhnd/bcma/bcma_bhndb.c optional bcma bhnd bhndb dev/bhnd/bcma/bcma_erom.c optional bcma bhnd -dev/bhnd/bcma/bcma_nexus.c optional bcma_nexus bcma bhnd dev/bhnd/bcma/bcma_subr.c optional bcma bhnd dev/bhnd/cores/chipc/bhnd_chipc_if.m optional bhnd dev/bhnd/cores/chipc/bhnd_sprom_chipc.c optional bhnd @@ -1251,7 +1248,6 @@ dev/bhnd/siba/siba.c optional siba bhnd dev/bhnd/siba/siba_bhndb.c optional siba bhnd bhndb dev/bhnd/siba/siba_erom.c optional siba bhnd -dev/bhnd/siba/siba_nexus.c optional siba_nexus siba bhnd dev/bhnd/siba/siba_subr.c optional siba bhnd # dev/bktr/bktr_audio.c optional bktr pci Index: sys/mips/broadcom/bcma_nexus.c =================================================================== --- sys/mips/broadcom/bcma_nexus.c +++ sys/mips/broadcom/bcma_nexus.c @@ -43,49 +43,41 @@ #include #include -#include -#include -#include "bcmavar.h" -#include "bcma_eromreg.h" +#include + +#include "bcm_machdep.h" + +#include "bhnd_nexusvar.h" /* - * Supports bcma(4) attachment to a nexus bus. + * Supports bcma(4) attachment to a MIPS nexus bus. */ 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; -}; - static int bcma_nexus_probe(device_t dev) { - struct bcma_nexus_softc *sc; - int error; - - 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); + int error; - if (sc->bcma_cid.chip_type != BHND_CHIPTYPE_BCMA) + switch (bcm_get_platform()->cid.chip_type) { + case BHND_CHIPTYPE_BCMA: + case BHND_CHIPTYPE_BCMA_ALT: + case BHND_CHIPTYPE_UBUS: + break; + default: return (ENXIO); + } - if ((error = bcma_probe(dev)) > 0) { - device_printf(dev, "error %d in probe\n", error); + if ((error = bcma_probe(dev)) > 0) return (error); - } /* Set device description */ - bhnd_set_default_bus_desc(dev, &sc->bcma_cid); + bhnd_set_default_bus_desc(dev, &bcm_get_platform()->cid); - return (0); + return (BUS_PROBE_SPECIFIC); } static int @@ -108,25 +100,15 @@ return (error); } -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); -} - static device_method_t bcma_nexus_methods[] = { - /* Device interface */ DEVMETHOD(device_probe, bcma_nexus_probe), DEVMETHOD(device_attach, bcma_nexus_attach), - /* bhnd interface */ - DEVMETHOD(bhnd_bus_get_chipid, bcma_nexus_get_chipid), - DEVMETHOD_END }; DEFINE_CLASS_2(bhnd, bcma_nexus_driver, bcma_nexus_methods, - sizeof(struct bcma_nexus_softc), bhnd_nexus_driver, bcma_driver); + sizeof(struct bcma_softc), bhnd_nexus_driver, bcma_driver); EARLY_DRIVER_MODULE(bcma_nexus, nexus, bcma_nexus_driver, bhnd_devclass, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); Index: sys/mips/broadcom/bhnd_nexus.c =================================================================== --- sys/mips/broadcom/bhnd_nexus.c +++ sys/mips/broadcom/bhnd_nexus.c @@ -32,10 +32,9 @@ #include __FBSDID("$FreeBSD$"); - /* * bhnd(4) driver mix-in providing shared common methods for - * bhnd bus devices attached via a root nexus. + * bhnd bus devices attached via a MIPS root nexus. */ #include @@ -48,50 +47,16 @@ #include +#include #include -#include -#include "bhnd_nexusvar.h" +#include "bcm_machdep.h" -static const struct resource_spec bhnd_nexus_res_spec[] = { - { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* chipc registers */ - { -1, 0, 0 } -}; +#include "bhnd_nexusvar.h" /** - * Map ChipCommon's register block and read the chip identifier data. - * - * @param dev A bhnd_nexus device. - * @param chipid On success, will be populated with the chip identifier. - * @retval 0 success - * @retval non-zero An error occurred reading the chip identifier.. + * Default bhnd_nexus implementation of BHND_BUS_ACTIVATE_RESOURCE(). */ -int -bhnd_nexus_read_chipid(device_t dev, struct bhnd_chipid *chipid) -{ - struct resource_spec rspec[nitems(bhnd_nexus_res_spec)]; - int error; - - memcpy(rspec, bhnd_nexus_res_spec, sizeof(rspec)); - error = bhnd_read_chipid(dev, rspec, 0, chipid); - if (error) - device_printf(dev, "error %d reading chip ID\n", error); - - return (error); -} - -static bool -bhnd_nexus_is_hw_disabled(device_t dev, device_t child) -{ - return (false); -} - -static bhnd_attach_type -bhnd_nexus_get_attach_type(device_t dev, device_t child) -{ - return (BHND_ATTACH_NATIVE); -} - static int bhnd_nexus_activate_resource(device_t dev, device_t child, int type, int rid, struct bhnd_resource *r) @@ -106,6 +71,9 @@ return (0); } +/** + * Default bhnd_nexus implementation of BHND_BUS_DEACTIVATE_RESOURCE(). + */ static int bhnd_nexus_deactivate_resource(device_t dev, device_t child, int type, int rid, struct bhnd_resource *r) @@ -122,6 +90,52 @@ return (0); } +/** + * Default bhnd_nexus implementation of BHND_BUS_IS_HW_DISABLED(). + */ +static bool +bhnd_nexus_is_hw_disabled(device_t dev, device_t child) +{ + struct bcm_platform *bp; + struct bhnd_chipid *cid; + + bp = bcm_get_platform(); + cid = &bp->cid; + + /* The BCM4706 low-cost package leaves secondary GMAC cores + * floating */ + if (cid->chip_id == BHND_CHIPID_BCM4706 && + cid->chip_pkg == BHND_PKGID_BCM4706L && + bhnd_get_device(child) == BHND_COREID_4706_GMAC && + bhnd_get_core_unit(child) != 0) + { + return (true); + } + + return (false); +} + +/** + * Default bhnd_nexus implementation of BHND_BUS_AGET_ATTACH_TYPE(). + */ +static bhnd_attach_type +bhnd_nexus_get_attach_type(device_t dev, device_t child) +{ + return (BHND_ATTACH_NATIVE); +} + +/** + * Default bhnd_nexus implementation of BHND_BUS_GET_CHIPID(). + */ +static const struct bhnd_chipid * +bhnd_nexus_get_chipid(device_t dev, device_t child) +{ + return (&bcm_get_platform()->cid); +} + +/** + * Default bhnd_nexus implementation of BHND_BUS_GET_INTR_COUNT(). + */ static int bhnd_nexus_get_intr_count(device_t dev, device_t child) { @@ -129,14 +143,30 @@ return (0); } +/** + * Default bhnd_nexus implementation of BHND_BUS_ASSIGN_INTR(). + */ +static int +bhnd_nexus_assign_intr(device_t dev, device_t child, int rid) +{ + uint32_t ivec; + int error; + + if ((error = bhnd_get_core_ivec(child, rid, &ivec))) + return (error); + + return (bus_set_resource(child, SYS_RES_IRQ, rid, ivec, 1)); +} + static device_method_t bhnd_nexus_methods[] = { /* bhnd interface */ DEVMETHOD(bhnd_bus_activate_resource, bhnd_nexus_activate_resource), DEVMETHOD(bhnd_bus_deactivate_resource, bhnd_nexus_deactivate_resource), DEVMETHOD(bhnd_bus_is_hw_disabled, bhnd_nexus_is_hw_disabled), DEVMETHOD(bhnd_bus_get_attach_type, bhnd_nexus_get_attach_type), - + DEVMETHOD(bhnd_bus_get_chipid, bhnd_nexus_get_chipid), DEVMETHOD(bhnd_bus_get_intr_count, bhnd_nexus_get_intr_count), + DEVMETHOD(bhnd_bus_assign_intr, bhnd_nexus_assign_intr), DEVMETHOD_END }; Index: sys/mips/broadcom/bhnd_nexusvar.h =================================================================== --- sys/mips/broadcom/bhnd_nexusvar.h +++ sys/mips/broadcom/bhnd_nexusvar.h @@ -29,18 +29,12 @@ * $FreeBSD$ */ -#ifndef _BHND_BHND_NEXUSVAR_H_ -#define _BHND_BHND_NEXUSVAR_H_ +#ifndef _MIPS_BROADCOM_BHND_NEXUSVAR_H_ +#define _MIPS_BROADCOM_BHND_NEXUSVAR_H_ #include -#include -#include -#include - -#include "bhndvar.h" +#include DECLARE_CLASS(bhnd_nexus_driver); -int bhnd_nexus_read_chipid(device_t dev, struct bhnd_chipid *chipid); - -#endif /* _BHND_BHND_NEXUSVAR_H_ */ +#endif /* _MIPS_BROADCOM_BHND_NEXUSVAR_H_ */ Index: sys/mips/broadcom/files.broadcom =================================================================== --- sys/mips/broadcom/files.broadcom +++ sys/mips/broadcom/files.broadcom @@ -10,6 +10,12 @@ mips/broadcom/bcm_nvram_cfe.c optional bhnd siba_nexus cfe | \ bhnd bcma_nexus cfe mips/broadcom/bcm_pmu.c standard + +mips/broadcom/bhnd_nexus.c optional bhnd siba_nexus | \ + bhnd bcma_nexus +mips/broadcom/bcma_nexus.c optional bcma_nexus bcma bhnd +mips/broadcom/siba_nexus.c optional siba_nexus siba bhnd + mips/mips/tick.c standard mips/broadcom/uart_cpu_chipc.c optional uart Index: sys/mips/broadcom/siba_nexus.c =================================================================== --- sys/mips/broadcom/siba_nexus.c +++ sys/mips/broadcom/siba_nexus.c @@ -38,10 +38,12 @@ #include #include -#include -#include -#include "sibavar.h" +#include + +#include "bcm_machdep.h" + +#include "bhnd_nexusvar.h" /* * Supports siba(4) attachment to a MIPS nexus bus. @@ -49,36 +51,21 @@ * Derived from Bruce M. Simpson' original siba(4) driver. */ -struct siba_nexus_softc { - struct siba_softc parent_sc; - struct bhnd_chipid siba_cid; -}; - static int siba_nexus_probe(device_t dev) { - struct siba_nexus_softc *sc; - int error; - - 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->siba_cid))) - return (error); + int error; - if (sc->siba_cid.chip_type != BHND_CHIPTYPE_SIBA) + if (bcm_get_platform()->cid.chip_type != BHND_CHIPTYPE_SIBA) return (ENXIO); - if ((error = siba_probe(dev)) > 0) { - device_printf(dev, "error %d in probe\n", error); + if ((error = siba_probe(dev)) > 0) return (error); - } /* Set device description */ - bhnd_set_default_bus_desc(dev, &sc->siba_cid); + bhnd_set_default_bus_desc(dev, &bcm_get_platform()->cid); - return (0); + return (BUS_PROBE_SPECIFIC); } static int @@ -101,25 +88,16 @@ return (error); } -static const struct bhnd_chipid * -siba_nexus_get_chipid(device_t dev, device_t child) { - struct siba_nexus_softc *sc = device_get_softc(dev); - return (&sc->siba_cid); -} - static device_method_t siba_nexus_methods[] = { /* Device interface */ DEVMETHOD(device_probe, siba_nexus_probe), DEVMETHOD(device_attach, siba_nexus_attach), - /* bhnd interface */ - DEVMETHOD(bhnd_bus_get_chipid, siba_nexus_get_chipid), - DEVMETHOD_END }; DEFINE_CLASS_2(bhnd, siba_nexus_driver, siba_nexus_methods, - sizeof(struct siba_nexus_softc), bhnd_nexus_driver, siba_driver); + sizeof(struct siba_softc), bhnd_nexus_driver, siba_driver); EARLY_DRIVER_MODULE(siba_nexus, nexus, siba_nexus_driver, bhnd_devclass, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);