Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Oct 2013 15:15:32 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r257167 - head/sys/dev/ffec
Message-ID:  <201310261515.r9QFFW1w013979@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sat Oct 26 15:15:31 2013
New Revision: 257167
URL: http://svnweb.freebsd.org/changeset/base/257167

Log:
  Switch to using ofw_bus_search_compatible() table-driven compat lookup.
  Add compat strings for Freescale Vybrid family SoCs.

Modified:
  head/sys/dev/ffec/if_ffec.c

Modified: head/sys/dev/ffec/if_ffec.c
==============================================================================
--- head/sys/dev/ffec/if_ffec.c	Sat Oct 26 15:10:58 2013	(r257166)
+++ head/sys/dev/ffec/if_ffec.c	Sat Oct 26 15:15:31 2013	(r257167)
@@ -86,6 +86,38 @@ __FBSDID("$FreeBSD$");
 #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.
  */
 #define	RX_DESC_COUNT	64
@@ -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 *
 	 * 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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310261515.r9QFFW1w013979>