From owner-svn-src-all@FreeBSD.ORG Sat Oct 26 15:15:32 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 90F42776; Sat, 26 Oct 2013 15:15:32 +0000 (UTC) (envelope-from ian@FreeBSD.org) 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 7E98622B6; Sat, 26 Oct 2013 15:15:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9QFFWKo013980; Sat, 26 Oct 2013 15:15:32 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9QFFW1w013979; Sat, 26 Oct 2013 15:15:32 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201310261515.r9QFFW1w013979@svn.freebsd.org> From: Ian Lepore Date: Sat, 26 Oct 2013 15:15:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r257167 - head/sys/dev/ffec X-SVN-Group: head 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.14 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: Sat, 26 Oct 2013 15:15:32 -0000 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); }