From owner-svn-src-all@FreeBSD.ORG Fri Dec 13 17:28:09 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 08B53E3D; Fri, 13 Dec 2013 17:28:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DCA0A1B26; Fri, 13 Dec 2013 17:28:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBDHS8pW042387; Fri, 13 Dec 2013 17:28:08 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBDHS8rZ042385; Fri, 13 Dec 2013 17:28:08 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201312131728.rBDHS8rZ042385@svn.freebsd.org> From: Ian Lepore Date: Fri, 13 Dec 2013 17:28:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r259317 - in stable/10/sys: arm/freescale/imx dev/ffec X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Dec 2013 17:28:09 -0000 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); }