[mips/broadcom] Move MIPS-specific bhnd(4) nexus drivers to
sys/mips/broadcom, and add MIPS/BCM4706-specific workaround to bhnd_nexus_is_hw_disabled() -- the BCM4706 low-cost package leaves secondary GMAC cores floating. Reviewed by: mizhka Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D9499
This commit is contained in:
parent
92bb8c6809
commit
8f3bba2d35
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=313705
@ -1190,8 +1190,6 @@ dev/bge/if_bge.c optional bge
|
||||
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
|
||||
@ -1206,7 +1204,6 @@ dev/bhnd/bhndb/bhndb_subr.c optional bhndb bhnd
|
||||
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
|
||||
@ -1252,7 +1249,6 @@ dev/bhnd/nvram/bhnd_sprom.c optional bhnd
|
||||
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
|
||||
|
@ -43,49 +43,41 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/resource.h>
|
||||
|
||||
#include <dev/bhnd/bhnd_ids.h>
|
||||
#include <dev/bhnd/bhnd_nexusvar.h>
|
||||
#include <dev/bhnd/cores/chipc/chipcreg.h>
|
||||
|
||||
#include "bcmavar.h"
|
||||
#include "bcma_eromreg.h"
|
||||
#include <dev/bhnd/bcma/bcmavar.h>
|
||||
|
||||
#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;
|
||||
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);
|
||||
|
||||
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);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* Set device description */
|
||||
bhnd_set_default_bus_desc(dev, &sc->bcma_cid);
|
||||
if ((error = bcma_probe(dev)) > 0)
|
||||
return (error);
|
||||
|
||||
return (0);
|
||||
/* Set device description */
|
||||
bhnd_set_default_bus_desc(dev, &bcm_get_platform()->cid);
|
||||
|
||||
return (BUS_PROBE_SPECIFIC);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -108,25 +100,15 @@ bcma_nexus_attach(device_t dev)
|
||||
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);
|
@ -32,10 +32,9 @@
|
||||
#include <sys/cdefs.h>
|
||||
__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 <sys/param.h>
|
||||
@ -48,50 +47,16 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/bhnd/bhndvar.h>
|
||||
#include <dev/bhnd/bhnd_ids.h>
|
||||
#include <dev/bhnd/cores/chipc/chipcreg.h>
|
||||
|
||||
#include "bcm_machdep.h"
|
||||
|
||||
#include "bhnd_nexusvar.h"
|
||||
|
||||
static const struct resource_spec bhnd_nexus_res_spec[] = {
|
||||
{ SYS_RES_MEMORY, 0, RF_ACTIVE }, /* chipc registers */
|
||||
{ -1, 0, 0 }
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 @@ bhnd_nexus_activate_resource(device_t dev, device_t child, int type, int rid,
|
||||
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 @@ bhnd_nexus_deactivate_resource(device_t dev, device_t child,
|
||||
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 @@ bhnd_nexus_get_intr_count(device_t dev, device_t child)
|
||||
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
|
||||
};
|
@ -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 <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
#include "bhndvar.h"
|
||||
#include <sys/kobj.h>
|
||||
|
||||
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_ */
|
@ -10,6 +10,12 @@ mips/broadcom/bcm_mips74k.c optional bcma_nexus bcma
|
||||
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
|
||||
|
@ -38,10 +38,12 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/resource.h>
|
||||
|
||||
#include <dev/bhnd/bhnd_ids.h>
|
||||
#include <dev/bhnd/bhnd_nexusvar.h>
|
||||
#include <dev/bhnd/cores/chipc/chipcreg.h>
|
||||
|
||||
#include "sibavar.h"
|
||||
#include <dev/bhnd/siba/sibavar.h>
|
||||
|
||||
#include "bcm_machdep.h"
|
||||
|
||||
#include "bhnd_nexusvar.h"
|
||||
|
||||
/*
|
||||
* Supports siba(4) attachment to a MIPS nexus bus.
|
||||
@ -49,36 +51,21 @@ __FBSDID("$FreeBSD$");
|
||||
* 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;
|
||||
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);
|
||||
|
||||
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 @@ siba_nexus_attach(device_t dev)
|
||||
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);
|
Loading…
Reference in New Issue
Block a user