Switch to using ofw_bus_search_compatible() table-driven compat lookup.
Add compat strings for Freescale Vybrid family SoCs.
This commit is contained in:
parent
8cde1e8a69
commit
21104c7028
@ -85,6 +85,38 @@ __FBSDID("$FreeBSD$");
|
||||
#include <dev/mii/miivar.h>
|
||||
#include "miibus_if.h"
|
||||
|
||||
/*
|
||||
* There are small differences in the hardware on various SoCs. Not every SoC
|
||||
* we support has its own FECTYPE; most work as GENERIC and only the ones that
|
||||
* need different handling get their own entry. In addition to the types in
|
||||
* this list, there are some flags below that can be ORed into the upper bits.
|
||||
*/
|
||||
enum {
|
||||
FECTYPE_NONE,
|
||||
FECTYPE_GENERIC,
|
||||
FECTYPE_IMX53,
|
||||
FECTYPE_IMX6,
|
||||
};
|
||||
|
||||
/*
|
||||
* Flags that describe general differences between the FEC hardware in various
|
||||
* SoCs. These are ORed into the FECTYPE enum values.
|
||||
*/
|
||||
#define FECTYPE_MASK 0x0000ffff
|
||||
#define FECFLAG_GBE (0x0001 << 16)
|
||||
|
||||
/*
|
||||
* Table of supported FDT compat strings and their associated FECTYPE values.
|
||||
*/
|
||||
static struct ofw_compat_data compat_data[] = {
|
||||
{"fsl,imx51-fec", FECTYPE_GENERIC},
|
||||
{"fsl,imx53-fec", FECTYPE_IMX53},
|
||||
{"fsl,imx6q-fec", FECTYPE_IMX6 | FECFLAG_GBE},
|
||||
{"fsl,mvf600-fec", FECTYPE_GENERIC},
|
||||
{"fsl,vf-fec", FECTYPE_GENERIC},
|
||||
{NULL, FECTYPE_NONE},
|
||||
};
|
||||
|
||||
/*
|
||||
* Driver data and defines.
|
||||
*/
|
||||
@ -108,13 +140,6 @@ enum {
|
||||
PHY_CONN_RGMII
|
||||
};
|
||||
|
||||
enum {
|
||||
FECTYPE_GENERIC,
|
||||
FECTYPE_IMX51,
|
||||
FECTYPE_IMX53,
|
||||
FECTYPE_IMX6,
|
||||
};
|
||||
|
||||
struct ffec_softc {
|
||||
device_t dev;
|
||||
device_t miibus;
|
||||
@ -226,7 +251,7 @@ ffec_miigasket_setup(struct ffec_softc *sc)
|
||||
* We only need the gasket for MII and RMII connections on certain SoCs.
|
||||
*/
|
||||
|
||||
switch (sc->fectype)
|
||||
switch (sc->fectype & FECTYPE_MASK)
|
||||
{
|
||||
case FECTYPE_IMX53:
|
||||
break;
|
||||
@ -1404,14 +1429,7 @@ ffec_attach(device_t dev)
|
||||
* There are differences in the implementation and features of the FEC
|
||||
* hardware on different SoCs, so figure out what type we are.
|
||||
*/
|
||||
if (ofw_bus_is_compatible(dev, "fsl,imx51-fec"))
|
||||
sc->fectype = FECTYPE_IMX51;
|
||||
else if (ofw_bus_is_compatible(dev, "fsl,imx53-fec"))
|
||||
sc->fectype = FECTYPE_IMX53;
|
||||
else if (ofw_bus_is_compatible(dev, "fsl,imx6q-fec"))
|
||||
sc->fectype = FECTYPE_IMX6;
|
||||
else
|
||||
sc->fectype = FECTYPE_GENERIC;
|
||||
sc->fectype = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
|
||||
|
||||
/*
|
||||
* We have to be told what kind of electrical connection exists between
|
||||
@ -1691,15 +1709,16 @@ out:
|
||||
static int
|
||||
ffec_probe(device_t dev)
|
||||
{
|
||||
uintptr_t fectype;
|
||||
|
||||
if (ofw_bus_is_compatible(dev, "fsl,imx51-fec") ||
|
||||
ofw_bus_is_compatible(dev, "fsl,imx53-fec")) {
|
||||
device_set_desc(dev, "Freescale Fast Ethernet Controller");
|
||||
} else if (ofw_bus_is_compatible(dev, "fsl,imx6q-fec")) {
|
||||
device_set_desc(dev, "Freescale Gigabit Ethernet Controller");
|
||||
} else {
|
||||
fectype = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
|
||||
if (fectype == FECTYPE_NONE)
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
device_set_desc(dev, (fectype & FECFLAG_GBE) ?
|
||||
"Freescale Gigabit Ethernet Controller" :
|
||||
"Freescale Fast Ethernet Controller");
|
||||
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user