Author: ian
Date: Fri Dec 13 17:28:08 2013
New Revision: 259317
URL: http://svnweb.freebsd.org/changeset/base/259317

Log:
  MFC r256806, r256919, r257167:
  
    Add a driver for the Freescale Fast Ethernet Controller found on various
    Freescale SoCs including the i.MX series.  This also works for the newer
    SoCs with the ENET gigabit controller, but doesn't use any of the new
    hardware features other than enabling gigabit speed.
  
    Mask out non-address bits in the mac address register, for proper
    detection of an all-zeroes address.  Also remove a misplaced return.
  
    Switch to using ofw_bus_search_compatible() table-driven compat lookup.
    Add compat strings for Freescale Vybrid family SoCs.

Added:
  stable/10/sys/dev/ffec/
     - copied from r256806, head/sys/dev/ffec/
Modified:
  stable/10/sys/arm/freescale/imx/files.imx53
  stable/10/sys/dev/ffec/if_ffec.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/arm/freescale/imx/files.imx53
==============================================================================
--- stable/10/sys/arm/freescale/imx/files.imx53 Fri Dec 13 17:23:47 2013        
(r259316)
+++ stable/10/sys/arm/freescale/imx/files.imx53 Fri Dec 13 17:28:08 2013        
(r259317)
@@ -49,3 +49,6 @@ dev/ofw/ofw_iicbus.c                  optional fsliic
 # IPU - Image Processing Unit (frame buffer also)
 arm/freescale/imx/imx51_ipuv3.c                optional sc
 
+# Fast Ethernet Controller
+dev/ffec/if_ffec.c                     optional ffec
+

Modified: stable/10/sys/dev/ffec/if_ffec.c
==============================================================================
--- head/sys/dev/ffec/if_ffec.c Sun Oct 20 21:07:38 2013        (r256806)
+++ stable/10/sys/dev/ffec/if_ffec.c    Fri Dec 13 17:28:08 2013        
(r259317)
@@ -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;
@@ -883,7 +908,7 @@ ffec_get_hwaddr(struct ffec_softc *sc, u
         * assigned bit set, and the broadcast/multicast bit clear.
         */
        palr = RD4(sc, FEC_PALR_REG);
-       paur = RD4(sc, FEC_PAUR_REG);
+       paur = RD4(sc, FEC_PAUR_REG) & FEC_PAUR_PADDR2_MASK;
        if ((palr | paur) != 0) {
                hwaddr[0] = palr >> 24;
                hwaddr[1] = palr >> 16;
@@ -891,7 +916,6 @@ ffec_get_hwaddr(struct ffec_softc *sc, u
                hwaddr[3] = palr >>  0;
                hwaddr[4] = paur >> 24;
                hwaddr[5] = paur >> 16;
-               return;
        } else {
                rnd = arc4random() & 0x00ffffff;
                hwaddr[0] = 'b';
@@ -1405,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
@@ -1692,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);
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to