Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp978396pxj; Fri, 4 Jun 2021 03:06:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw51MozQqohienhHRgU/JjvD4UjvdCphEJcholXqnIh9ZrqKp11ESRimf/kJh374EOqKtCX X-Received: by 2002:a17:906:2892:: with SMTP id o18mr3366430ejd.124.1622801203304; Fri, 04 Jun 2021 03:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622801203; cv=none; d=google.com; s=arc-20160816; b=EmBFO8r3Gc4A+pGWHaEwqyB2HSZXZ5cd5HaupXwx4SLvPaC0hys+ccm1o4v1cHqqgF o5MmWg0/VGbdertN3lizF38L1EmzJAY8G0To4ZOYRsPRh+XTxYtLB25ABGjI613Al671 /nTBDQ3l55eSFpgrqhTIl3nnyUxryHuV9OUN9bNRkU7bmEXd6kPRUUayGjAjyc4c9J4h qGEWKDt7viVFW7LUOX0mRbotAMGSGZdEawg9op/+lahQoV4MKYrA6IvPGpiGjellnuFJ Rd0aPY1U14YM0X5cYUbvG8kuC0bcpHLG0iV0x4a8QU32CjgiBeZE0Q/mxRLOw0rea9cA 4lRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:ironport-sdr:ironport-sdr; bh=pNHly0MHqCqwSdRfjqCbB7Ys0aDjsYWRx8xVXSWcqOQ=; b=g+5WKsRGDbZE7rQ0IkyLHRGigPopgfmtOAy0sa198/vKGt3num2yAC5vmiNKxl52Bx Jn2QiDZY4IDpCNQeY4uxyFLX6vPFj0KnhRCnYjV4OCNwT6mnXM/eRWy9iFYfgZ0Z8yv5 /TGotWLK64PLVmZ2WX4NraNNuvSWOedGXz8W9T4m10J7b7lDl6iWGaaaowCOiQ/AgFVR he0RVJ3Iyaz+M9XzYY7629xFVfmCT+lo8PrXRMlac8394V7PlU9x/eGVfp++iZ/I/u6Y ag4zarH0QRo3AXXD7iK4RI+SoM8Clt7aEQDUSXBQCfwzpTYEpaZgbPdfbkixcdkraYtv LYeg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d10si4437219edq.351.2021.06.04.03.06.19; Fri, 04 Jun 2021 03:06:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbhFDKEY (ORCPT + 99 others); Fri, 4 Jun 2021 06:04:24 -0400 Received: from mga04.intel.com ([192.55.52.120]:53397 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbhFDKEX (ORCPT ); Fri, 4 Jun 2021 06:04:23 -0400 IronPort-SDR: DnjuxhrHwN7xu5txsCL8q15LUDDEtsZ2EAjPVJD9waXFfuOcex+jQNjdCQsPr4mdGuSD23YyjI KqlTIOAKfLlg== X-IronPort-AV: E=McAfee;i="6200,9189,10004"; a="202404517" X-IronPort-AV: E=Sophos;i="5.83,248,1616482800"; d="scan'208";a="202404517" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2021 03:02:37 -0700 IronPort-SDR: +mJhw9hTZQIhtDNLjWBuodxeVdrQub/i0PiwO/LE/0qVACHqpW3Mq+VschdXxIY85S5tyM4pH9 /2f4sC7+oy4A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,248,1616482800"; d="scan'208";a="633994099" Received: from mike-ilbpg1.png.intel.com ([10.88.227.76]) by fmsmga006.fm.intel.com with ESMTP; 04 Jun 2021 03:02:33 -0700 From: Michael Sit Wei Hong To: Jose.Abreu@synopsys.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, kuba@kernel.org, netdev@vger.kernel.org, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, davem@davemloft.net, mcoquelin.stm32@gmail.com, weifeng.voon@intel.com, boon.leong.ong@intel.com, tee.min.tan@intel.com, vee.khee.wong@linux.intel.com, vee.khee.wong@intel.com, michael.wei.hong.sit@intel.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, vladimir.oltean@nxp.com Subject: [PATCH net-next v5 1/3] net: stmmac: split xPCS setup from mdio register Date: Fri, 4 Jun 2021 17:57:59 +0800 Message-Id: <20210604095801.1033-2-michael.wei.hong.sit@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210604095801.1033-1-michael.wei.hong.sit@intel.com> References: <20210604095801.1033-1-michael.wei.hong.sit@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Voon Weifeng This patch is a preparation patch for the enabling of Intel mGbE 2.5Gbps link speed. The Intel mGbR link speed configuration (1G/2.5G) is depends on a mdio ADHOC register which can be configured in the bios menu. As PHY interface might be different for 1G and 2.5G, the mdio bus need be ready to check the link speed and select the PHY interface before probing the xPCS. Signed-off-by: Voon Weifeng Signed-off-by: Michael Sit Wei Hong --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ++ .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 65 ++++++++++--------- 3 files changed, 44 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index b6cd43eda7ac..fd7212afc543 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -311,6 +311,7 @@ enum stmmac_state { int stmmac_mdio_unregister(struct net_device *ndev); int stmmac_mdio_register(struct net_device *ndev); int stmmac_mdio_reset(struct mii_bus *mii); +int stmmac_xpcs_setup(struct mii_bus *mii); void stmmac_set_ethtool_ops(struct net_device *netdev); void stmmac_ptp_register(struct stmmac_priv *priv); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 6d41dd6f9f7a..c1331c07623d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6991,6 +6991,12 @@ int stmmac_dvr_probe(struct device *device, } } + if (priv->plat->mdio_bus_data->has_xpcs) { + ret = stmmac_xpcs_setup(priv->mii); + if (ret) + goto error_xpcs_setup; + } + ret = stmmac_phy_setup(priv); if (ret) { netdev_err(ndev, "failed to setup phy (%d)\n", ret); @@ -7027,6 +7033,7 @@ int stmmac_dvr_probe(struct device *device, unregister_netdev(ndev); error_netdev_register: phylink_destroy(priv->phylink); +error_xpcs_setup: error_phy_setup: if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 6312a152c8ad..d059305ddf9c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -397,6 +397,42 @@ int stmmac_mdio_reset(struct mii_bus *bus) return 0; } +int stmmac_xpcs_setup(struct mii_bus *bus) +{ + int mode, max_addr, addr; + struct net_device *ndev = bus->priv; + struct mdio_xpcs_args *xpcs; + struct stmmac_priv *priv; + struct mdio_device *mdiodev; + + priv = netdev_priv(ndev); + mode = priv->plat->phy_interface; + max_addr = PHY_MAX_ADDR; + + /* Try to probe the XPCS by scanning all addresses. */ + for (addr = 0; addr < PHY_MAX_ADDR; addr++) { + mdiodev = mdio_device_create(bus, addr); + if (IS_ERR(mdiodev)) + continue; + + xpcs = xpcs_create(mdiodev, mode); + if (IS_ERR_OR_NULL(xpcs)) { + mdio_device_free(mdiodev); + continue; + } + + priv->hw->xpcs = xpcs; + break; + } + + if (!priv->hw->xpcs) { + dev_warn(priv->device, "No xPCS found\n"); + return -ENODEV; + } + + return 0; +} + /** * stmmac_mdio_register * @ndev: net device structure @@ -501,40 +537,11 @@ int stmmac_mdio_register(struct net_device *ndev) goto no_phy_found; } - /* Try to probe the XPCS by scanning all addresses. */ - if (mdio_bus_data->has_xpcs) { - int mode = priv->plat->phy_interface; - struct mdio_device *mdiodev; - struct mdio_xpcs_args *xpcs; - - for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - mdiodev = mdio_device_create(new_bus, addr); - if (IS_ERR(mdiodev)) - continue; - - xpcs = xpcs_create(mdiodev, mode); - if (IS_ERR_OR_NULL(xpcs)) { - mdio_device_free(mdiodev); - continue; - } - - priv->hw->xpcs = xpcs; - break; - } - - if (!priv->hw->xpcs) { - dev_warn(dev, "No XPCS found\n"); - err = -ENODEV; - goto no_xpcs_found; - } - } - bus_register_done: priv->mii = new_bus; return 0; -no_xpcs_found: no_phy_found: mdiobus_unregister(new_bus); bus_register_fail: -- 2.17.1