cgem: rework hardware quirk detection
Rather than doing these checks based on the detected hardware variant, allow quirks to be specified as a set of flags for each compatible string. This simplifies adding support for new compatible hardware. Reviewed by: mhorne MFC after: 1 week Sponsored by: Conclusive Engineering Differential Revision: https://reviews.freebsd.org/D34764
This commit is contained in:
parent
86fa80f320
commit
66cc0c61b0
@ -100,18 +100,19 @@ __FBSDID("$FreeBSD$");
|
||||
#define CGEM_CKSUM_ASSIST (CSUM_IP | CSUM_TCP | CSUM_UDP | \
|
||||
CSUM_TCP_IPV6 | CSUM_UDP_IPV6)
|
||||
|
||||
#define HWTYPE_GENERIC_GEM 1
|
||||
#define HWTYPE_ZYNQ 2
|
||||
#define HWTYPE_ZYNQMP 3
|
||||
#define HWTYPE_SIFIVE 4
|
||||
#define HWQUIRK_NONE 0
|
||||
#define HWQUIRK_NEEDNULLQS 1
|
||||
#define HWQUIRK_RXHANGWAR 2
|
||||
#define HWQUIRK_TXCLK 4
|
||||
#define HWQUIRK_PCLK 8
|
||||
|
||||
static struct ofw_compat_data compat_data[] = {
|
||||
{ "cdns,zynq-gem", HWTYPE_ZYNQ },
|
||||
{ "cdns,zynqmp-gem", HWTYPE_ZYNQMP },
|
||||
{ "sifive,fu540-c000-gem", HWTYPE_SIFIVE },
|
||||
{ "sifive,fu740-c000-gem", HWTYPE_SIFIVE },
|
||||
{ "cdns,gem", HWTYPE_GENERIC_GEM },
|
||||
{ "cadence,gem", HWTYPE_GENERIC_GEM },
|
||||
{ "cdns,zynq-gem", HWQUIRK_RXHANGWAR | HWQUIRK_TXCLK },
|
||||
{ "cdns,zynqmp-gem", HWQUIRK_NEEDNULLQS | HWQUIRK_TXCLK },
|
||||
{ "sifive,fu540-c000-gem", HWQUIRK_PCLK },
|
||||
{ "sifive,fu740-c000-gem", HWQUIRK_PCLK },
|
||||
{ "cdns,gem", HWQUIRK_NONE },
|
||||
{ "cadence,gem", HWQUIRK_NONE },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
@ -1712,7 +1713,7 @@ cgem_probe(device_t dev)
|
||||
if (!ofw_bus_status_okay(dev))
|
||||
return (ENXIO);
|
||||
|
||||
if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
|
||||
if (ofw_bus_search_compatible(dev, compat_data)->ocd_str == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
device_set_desc(dev, "Cadence CGEM Gigabit Ethernet Interface");
|
||||
@ -1726,25 +1727,25 @@ cgem_attach(device_t dev)
|
||||
if_t ifp = NULL;
|
||||
int rid, err;
|
||||
u_char eaddr[ETHER_ADDR_LEN];
|
||||
int hwtype;
|
||||
int hwquirks;
|
||||
|
||||
sc->dev = dev;
|
||||
CGEM_LOCK_INIT(sc);
|
||||
|
||||
/* Key off of compatible string and set hardware-specific options. */
|
||||
hwtype = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
|
||||
if (hwtype == HWTYPE_ZYNQMP)
|
||||
hwquirks = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
|
||||
if ((hwquirks & HWQUIRK_NEEDNULLQS) != 0)
|
||||
sc->neednullqs = 1;
|
||||
if (hwtype == HWTYPE_ZYNQ)
|
||||
if ((hwquirks & HWQUIRK_RXHANGWAR) != 0)
|
||||
sc->rxhangwar = 1;
|
||||
|
||||
if (hwtype == HWTYPE_ZYNQ || hwtype == HWTYPE_ZYNQMP) {
|
||||
if ((hwquirks & HWQUIRK_TXCLK) != 0) {
|
||||
if (clk_get_by_ofw_name(dev, 0, "tx_clk", &sc->ref_clk) != 0)
|
||||
device_printf(dev,
|
||||
"could not retrieve reference clock.\n");
|
||||
else if (clk_enable(sc->ref_clk) != 0)
|
||||
device_printf(dev, "could not enable clock.\n");
|
||||
} else if (hwtype == HWTYPE_SIFIVE) {
|
||||
}
|
||||
if ((hwquirks & HWQUIRK_PCLK) != 0) {
|
||||
if (clk_get_by_ofw_name(dev, 0, "pclk", &sc->ref_clk) != 0)
|
||||
device_printf(dev,
|
||||
"could not retrieve reference clock.\n");
|
||||
|
Loading…
Reference in New Issue
Block a user