From owner-svn-src-head@freebsd.org Sun Jun 11 00:44:21 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0BB63BF9D6B; Sun, 11 Jun 2017 00:44:21 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D662268A55; Sun, 11 Jun 2017 00:44:20 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5B0iJcd067919; Sun, 11 Jun 2017 00:44:19 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5B0iJtI067918; Sun, 11 Jun 2017 00:44:19 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201706110044.v5B0iJtI067918@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 11 Jun 2017 00:44:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319818 - 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-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Jun 2017 00:44:21 -0000 Author: ian Date: Sun Jun 11 00:44:19 2017 New Revision: 319818 URL: https://svnweb.freebsd.org/changeset/base/319818 Log: Convert from local code and constants for mac<->phy connection type to new common fdt helper code. Modified: head/sys/dev/ffec/if_ffec.c Modified: head/sys/dev/ffec/if_ffec.c ============================================================================== --- head/sys/dev/ffec/if_ffec.c Sun Jun 11 00:38:16 2017 (r319817) +++ head/sys/dev/ffec/if_ffec.c Sun Jun 11 00:44:19 2017 (r319818) @@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "miibus_if.h" /* @@ -135,13 +136,6 @@ struct ffec_bufmap { bus_dmamap_t map; }; -enum { - PHY_CONN_UNKNOWN, - PHY_CONN_MII, - PHY_CONN_RMII, - PHY_CONN_RGMII -}; - struct ffec_softc { device_t dev; device_t miibus; @@ -153,7 +147,7 @@ struct ffec_softc { struct resource *mem_res; void * intr_cookie; struct callout ffec_callout; - uint8_t phy_conn_type; + mii_contype_t phy_conn_type; uint8_t fectype; boolean_t link_is_up; boolean_t is_attached; @@ -262,10 +256,10 @@ ffec_miigasket_setup(struct ffec_softc *sc) switch (sc->phy_conn_type) { - case PHY_CONN_MII: + case MII_CONTYPE_MII: ifmode = 0; break; - case PHY_CONN_RMII: + case MII_CONTYPE_RMII: ifmode = FEC_MIIGSK_CFGR_IF_MODE_RMII; break; default: @@ -377,14 +371,17 @@ ffec_miibus_statchg(device_t dev) rcr |= FEC_RCR_MII_MODE; /* Must always be on even for R[G]MII. */ switch (sc->phy_conn_type) { - case PHY_CONN_MII: - break; - case PHY_CONN_RMII: + case MII_CONTYPE_RMII: rcr |= FEC_RCR_RMII_MODE; break; - case PHY_CONN_RGMII: + case MII_CONTYPE_RGMII: + case MII_CONTYPE_RGMII_ID: + case MII_CONTYPE_RGMII_RXID: + case MII_CONTYPE_RGMII_TXID: rcr |= FEC_RCR_RGMII_EN; break; + default: + break; } switch (IFM_SUBTYPE(mii->mii_media_active)) { @@ -1440,7 +1437,6 @@ ffec_attach(device_t dev) phandle_t ofw_node; int error, phynum, rid; uint8_t eaddr[ETHER_ADDR_LEN]; - char phy_conn_name[32]; uint32_t idx, mscr; sc = device_get_softc(dev); @@ -1463,16 +1459,8 @@ ffec_attach(device_t dev) error = ENXIO; goto out; } - if (OF_searchprop(ofw_node, "phy-mode", - phy_conn_name, sizeof(phy_conn_name)) != -1) { - if (strcasecmp(phy_conn_name, "mii") == 0) - sc->phy_conn_type = PHY_CONN_MII; - else if (strcasecmp(phy_conn_name, "rmii") == 0) - sc->phy_conn_type = PHY_CONN_RMII; - else if (strcasecmp(phy_conn_name, "rgmii") == 0) - sc->phy_conn_type = PHY_CONN_RGMII; - } - if (sc->phy_conn_type == PHY_CONN_UNKNOWN) { + sc->phy_conn_type = mii_fdt_get_contype(ofw_node); + if (sc->phy_conn_type == MII_CONTYPE_UNKNOWN) { device_printf(sc->dev, "No valid 'phy-mode' " "property found in FDT data for device.\n"); error = ENOATTR;