mirror of https://github.com/hak5/openwrt.git
mediatek: backport the latest version of the mt7531 support patches
Fixes unknown unicast flooding issue Signed-off-by: Felix Fietkau <nbd@nbd.name>master
parent
d8104c8353
commit
c18a872825
|
@ -1,98 +0,0 @@
|
||||||
From patchwork Tue Dec 10 08:14:37 2019
|
|
||||||
Content-Type: text/plain; charset="utf-8"
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Transfer-Encoding: 7bit
|
|
||||||
X-Patchwork-Submitter: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
X-Patchwork-Id: 1206962
|
|
||||||
X-Patchwork-Delegate: davem@davemloft.net
|
|
||||||
Return-Path: <netdev-owner@vger.kernel.org>
|
|
||||||
X-Original-To: patchwork-incoming-netdev@ozlabs.org
|
|
||||||
Delivered-To: patchwork-incoming-netdev@ozlabs.org
|
|
||||||
Authentication-Results: ozlabs.org; spf=none (no SPF record)
|
|
||||||
smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67;
|
|
||||||
helo=vger.kernel.org;
|
|
||||||
envelope-from=netdev-owner@vger.kernel.org;
|
|
||||||
receiver=<UNKNOWN>)
|
|
||||||
Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none)
|
|
||||||
header.from=mediatek.com
|
|
||||||
Authentication-Results: ozlabs.org; dkim=pass (1024-bit key;
|
|
||||||
unprotected) header.d=mediatek.com header.i=@mediatek.com
|
|
||||||
header.b="pTp2PPKi"; dkim-atps=neutral
|
|
||||||
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
|
|
||||||
by ozlabs.org (Postfix) with ESMTP id 47XCY42hJqz9sRf
|
|
||||||
for <patchwork-incoming-netdev@ozlabs.org>;
|
|
||||||
Tue, 10 Dec 2019 19:15:20 +1100 (AEDT)
|
|
||||||
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
|
|
||||||
id S1727061AbfLJIO5 (ORCPT
|
|
||||||
<rfc822;patchwork-incoming-netdev@ozlabs.org>);
|
|
||||||
Tue, 10 Dec 2019 03:14:57 -0500
|
|
||||||
Received: from mailgw02.mediatek.com ([210.61.82.184]:45567 "EHLO
|
|
||||||
mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by
|
|
||||||
vger.kernel.org with ESMTP id S1726932AbfLJIO4 (ORCPT
|
|
||||||
<rfc822;netdev@vger.kernel.org>); Tue, 10 Dec 2019 03:14:56 -0500
|
|
||||||
X-UUID: f5656f2ff80846ebb40e3da87d60fb90-20191210
|
|
||||||
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
|
|
||||||
d=mediatek.com; s=dk;
|
|
||||||
h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From;
|
|
||||||
bh=THbuVAlbiUyMgTyO0rwrKX/mskzsxNwDv9gxXp2O2c8=;
|
|
||||||
b=pTp2PPKiPwR8QPOOf5yohf9lFERpEDlo/g/t2ChREfzFb9c+wylx++/div4hAB337+Ja2KIzbSu4URgdj5XHXUly8yuxrD8OBvV+ox0jlNLiRIN2dkCgL4fyzPr7ZPSk9lObJW05Yx2LY6Jy6eJZZXSShLlqLd0lDKwy6FT+hSI=;
|
|
||||||
X-UUID: f5656f2ff80846ebb40e3da87d60fb90-20191210
|
|
||||||
Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by
|
|
||||||
mailgw02.mediatek.com (envelope-from <landen.chao@mediatek.com>)
|
|
||||||
(Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS)
|
|
||||||
with ESMTP id 565263134; Tue, 10 Dec 2019 16:14:47 +0800
|
|
||||||
Received: from mtkcas08.mediatek.inc (172.21.101.126) by
|
|
||||||
mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server
|
|
||||||
(TLS) id 15.0.1395.4; Tue, 10 Dec 2019 16:14:38 +0800
|
|
||||||
Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc
|
|
||||||
(172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via
|
|
||||||
Frontend Transport; Tue, 10 Dec 2019 16:14:26 +0800
|
|
||||||
From: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
To: <andrew@lunn.ch>, <f.fainelli@gmail.com>,
|
|
||||||
<vivien.didelot@savoirfairelinux.com>, <matthias.bgg@gmail.com>,
|
|
||||||
<robh+dt@kernel.org>, <mark.rutland@arm.com>
|
|
||||||
CC: <devicetree@vger.kernel.org>, <netdev@vger.kernel.org>,
|
|
||||||
<linux-kernel@vger.kernel.org>,
|
|
||||||
<linux-mediatek@lists.infradead.org>, <davem@davemloft.net>,
|
|
||||||
<sean.wang@mediatek.com>, <opensource@vdorst.com>,
|
|
||||||
<frank-w@public-files.de>, Landen Chao <landen.chao@mediatek.com>
|
|
||||||
Subject: [PATCH net-next 1/6] net: dsa: mt7530: Refine message in Kconfig
|
|
||||||
Date: Tue, 10 Dec 2019 16:14:37 +0800
|
|
||||||
Message-ID: <6ecf6cbf38223f35854bc361c2eefa1d85c724d2.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
X-Mailer: git-send-email 2.18.0
|
|
||||||
In-Reply-To: <cover.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
References: <cover.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
MIME-Version: 1.0
|
|
||||||
X-MTK: N
|
|
||||||
Sender: netdev-owner@vger.kernel.org
|
|
||||||
Precedence: bulk
|
|
||||||
List-ID: <netdev.vger.kernel.org>
|
|
||||||
X-Mailing-List: netdev@vger.kernel.org
|
|
||||||
|
|
||||||
Refine message in Kconfig with fixing typo and an explicit MT7621 support.
|
|
||||||
|
|
||||||
Signed-off-by: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
|
|
||||||
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
|
|
||||||
---
|
|
||||||
drivers/net/dsa/Kconfig | 6 +++---
|
|
||||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
--- a/drivers/net/dsa/Kconfig
|
|
||||||
+++ b/drivers/net/dsa/Kconfig
|
|
||||||
@@ -33,12 +33,12 @@ config NET_DSA_LANTIQ_GSWIP
|
|
||||||
the xrx200 / VR9 SoC.
|
|
||||||
|
|
||||||
config NET_DSA_MT7530
|
|
||||||
- tristate "Mediatek MT7530 Ethernet switch support"
|
|
||||||
+ tristate "MediaTek MT7530 and MT7621 Ethernet switch support"
|
|
||||||
depends on NET_DSA
|
|
||||||
select NET_DSA_TAG_MTK
|
|
||||||
---help---
|
|
||||||
- This enables support for the Mediatek MT7530 Ethernet switch
|
|
||||||
- chip.
|
|
||||||
+ This enables support for the MediaTek MT7530 and MT7621 Ethernet
|
|
||||||
+ switch chip.
|
|
||||||
|
|
||||||
config NET_DSA_MV88E6060
|
|
||||||
tristate "Marvell 88E6060 ethernet switch chip support"
|
|
|
@ -1,441 +0,0 @@
|
||||||
From patchwork Tue Dec 10 08:14:38 2019
|
|
||||||
Content-Type: text/plain; charset="utf-8"
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Transfer-Encoding: 7bit
|
|
||||||
X-Patchwork-Submitter: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
X-Patchwork-Id: 1206963
|
|
||||||
X-Patchwork-Delegate: davem@davemloft.net
|
|
||||||
Return-Path: <netdev-owner@vger.kernel.org>
|
|
||||||
X-Original-To: patchwork-incoming-netdev@ozlabs.org
|
|
||||||
Delivered-To: patchwork-incoming-netdev@ozlabs.org
|
|
||||||
Authentication-Results: ozlabs.org; spf=none (no SPF record)
|
|
||||||
smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67;
|
|
||||||
helo=vger.kernel.org;
|
|
||||||
envelope-from=netdev-owner@vger.kernel.org;
|
|
||||||
receiver=<UNKNOWN>)
|
|
||||||
Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none)
|
|
||||||
header.from=mediatek.com
|
|
||||||
Authentication-Results: ozlabs.org; dkim=pass (1024-bit key;
|
|
||||||
unprotected) header.d=mediatek.com header.i=@mediatek.com
|
|
||||||
header.b="UJ5NATux"; dkim-atps=neutral
|
|
||||||
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
|
|
||||||
by ozlabs.org (Postfix) with ESMTP id 47XCY92tBkz9sR7
|
|
||||||
for <patchwork-incoming-netdev@ozlabs.org>;
|
|
||||||
Tue, 10 Dec 2019 19:15:25 +1100 (AEDT)
|
|
||||||
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
|
|
||||||
id S1727003AbfLJIO4 (ORCPT
|
|
||||||
<rfc822;patchwork-incoming-netdev@ozlabs.org>);
|
|
||||||
Tue, 10 Dec 2019 03:14:56 -0500
|
|
||||||
Received: from mailgw02.mediatek.com ([210.61.82.184]:45567 "EHLO
|
|
||||||
mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by
|
|
||||||
vger.kernel.org with ESMTP id S1726071AbfLJIOy (ORCPT
|
|
||||||
<rfc822;netdev@vger.kernel.org>); Tue, 10 Dec 2019 03:14:54 -0500
|
|
||||||
X-UUID: a18674d7b33c423e9e67b7440f4771cf-20191210
|
|
||||||
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
|
|
||||||
d=mediatek.com; s=dk;
|
|
||||||
h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From;
|
|
||||||
bh=c2C/fEHYw/8uqadmiP2m2xa2hsUpAd52urXVJTPlYck=;
|
|
||||||
b=UJ5NATuxMtqHln5i6BTpWiLnxGKgWvp4DpRsKVO2xdnz2cJaT4XL8F/T5fK3CTF4nAai0EKPAcqp+rr8eCLq7uURJv5e5h+ZIzKLSAB4zgnchXesQLo0uFS8vs5w2yp49j6bez1z3v/uN+1+Lpq0uYid9awCqzvbnovrooEysu4=;
|
|
||||||
X-UUID: a18674d7b33c423e9e67b7440f4771cf-20191210
|
|
||||||
Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by
|
|
||||||
mailgw02.mediatek.com (envelope-from <landen.chao@mediatek.com>)
|
|
||||||
(Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS)
|
|
||||||
with ESMTP id 1965641267; Tue, 10 Dec 2019 16:14:46 +0800
|
|
||||||
Received: from mtkcas08.mediatek.inc (172.21.101.126) by
|
|
||||||
mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server
|
|
||||||
(TLS) id 15.0.1395.4; Tue, 10 Dec 2019 16:14:31 +0800
|
|
||||||
Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc
|
|
||||||
(172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via
|
|
||||||
Frontend Transport; Tue, 10 Dec 2019 16:14:26 +0800
|
|
||||||
From: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
To: <andrew@lunn.ch>, <f.fainelli@gmail.com>,
|
|
||||||
<vivien.didelot@savoirfairelinux.com>, <matthias.bgg@gmail.com>,
|
|
||||||
<robh+dt@kernel.org>, <mark.rutland@arm.com>
|
|
||||||
CC: <devicetree@vger.kernel.org>, <netdev@vger.kernel.org>,
|
|
||||||
<linux-kernel@vger.kernel.org>,
|
|
||||||
<linux-mediatek@lists.infradead.org>, <davem@davemloft.net>,
|
|
||||||
<sean.wang@mediatek.com>, <opensource@vdorst.com>,
|
|
||||||
<frank-w@public-files.de>, Landen Chao <landen.chao@mediatek.com>
|
|
||||||
Subject: [PATCH net-next 2/6] net: dsa: mt7530: Extend device data ready for
|
|
||||||
adding a new hardware
|
|
||||||
Date: Tue, 10 Dec 2019 16:14:38 +0800
|
|
||||||
Message-ID: <2d546d6bb15ff8b4b75af2220e20db4e634f4145.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
X-Mailer: git-send-email 2.18.0
|
|
||||||
In-Reply-To: <cover.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
References: <cover.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
MIME-Version: 1.0
|
|
||||||
X-MTK: N
|
|
||||||
Sender: netdev-owner@vger.kernel.org
|
|
||||||
Precedence: bulk
|
|
||||||
List-ID: <netdev.vger.kernel.org>
|
|
||||||
X-Mailing-List: netdev@vger.kernel.org
|
|
||||||
|
|
||||||
Add a structure holding required operations for each device such as device
|
|
||||||
initialization, PHY port read or write, a checker whether PHY interface is
|
|
||||||
supported on a certain port, MAC port setup for either bus pad or a
|
|
||||||
specific PHY interface.
|
|
||||||
|
|
||||||
The patch is done for ready adding a new hardware MT7531.
|
|
||||||
|
|
||||||
Signed-off-by: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
|
|
||||||
---
|
|
||||||
drivers/net/dsa/mt7530.c | 231 +++++++++++++++++++++++++++++----------
|
|
||||||
drivers/net/dsa/mt7530.h | 29 ++++-
|
|
||||||
2 files changed, 203 insertions(+), 57 deletions(-)
|
|
||||||
|
|
||||||
--- a/drivers/net/dsa/mt7530.c
|
|
||||||
+++ b/drivers/net/dsa/mt7530.c
|
|
||||||
@@ -373,7 +373,7 @@ mt7530_fdb_write(struct mt7530_priv *pri
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
-mt7530_pad_clk_setup(struct dsa_switch *ds, int mode)
|
|
||||||
+mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t mode)
|
|
||||||
{
|
|
||||||
struct mt7530_priv *priv = ds->priv;
|
|
||||||
u32 ncpo1, ssc_delta, trgint, i, xtal;
|
|
||||||
@@ -1355,13 +1355,111 @@ mt7530_setup(struct dsa_switch *ds)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void mt7530_phylink_mac_config(struct dsa_switch *ds, int port,
|
|
||||||
+static bool mt7530_phy_supported(struct dsa_switch *ds, int port,
|
|
||||||
+ const struct phylink_link_state *state)
|
|
||||||
+{
|
|
||||||
+ struct mt7530_priv *priv = ds->priv;
|
|
||||||
+
|
|
||||||
+ switch (port) {
|
|
||||||
+ case 0: /* Internal phy */
|
|
||||||
+ case 1:
|
|
||||||
+ case 2:
|
|
||||||
+ case 3:
|
|
||||||
+ case 4:
|
|
||||||
+ if (state->interface != PHY_INTERFACE_MODE_GMII)
|
|
||||||
+ goto unsupported;
|
|
||||||
+ break;
|
|
||||||
+ case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
|
|
||||||
+ if (!phy_interface_mode_is_rgmii(state->interface) &&
|
|
||||||
+ state->interface != PHY_INTERFACE_MODE_MII &&
|
|
||||||
+ state->interface != PHY_INTERFACE_MODE_GMII)
|
|
||||||
+ goto unsupported;
|
|
||||||
+ break;
|
|
||||||
+ case 6: /* 1st cpu port */
|
|
||||||
+ if (state->interface != PHY_INTERFACE_MODE_RGMII &&
|
|
||||||
+ state->interface != PHY_INTERFACE_MODE_TRGMII)
|
|
||||||
+ goto unsupported;
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ dev_err(priv->dev, "%s: unsupported port: %i\n", __func__,
|
|
||||||
+ port);
|
|
||||||
+ goto unsupported;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return true;
|
|
||||||
+
|
|
||||||
+unsupported:
|
|
||||||
+ return false;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static bool mt753x_phy_supported(struct dsa_switch *ds, int port,
|
|
||||||
+ const struct phylink_link_state *state)
|
|
||||||
+{
|
|
||||||
+ struct mt7530_priv *priv = ds->priv;
|
|
||||||
+
|
|
||||||
+ return priv->info->phy_supported(ds, port, state);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int
|
|
||||||
+mt7530_pad_setup(struct dsa_switch *ds, const struct phylink_link_state *state)
|
|
||||||
+{
|
|
||||||
+ struct mt7530_priv *priv = ds->priv;
|
|
||||||
+
|
|
||||||
+ /* Setup TX circuit incluing relevant PAD and driving */
|
|
||||||
+ mt7530_pad_clk_setup(ds, state->interface);
|
|
||||||
+
|
|
||||||
+ if (priv->id == ID_MT7530) {
|
|
||||||
+ /* Setup RX circuit, relevant PAD and driving on the
|
|
||||||
+ * host which must be placed after the setup on the
|
|
||||||
+ * device side is all finished.
|
|
||||||
+ */
|
|
||||||
+ mt7623_pad_clk_setup(ds);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int
|
|
||||||
+mt753x_pad_setup(struct dsa_switch *ds, const struct phylink_link_state *state)
|
|
||||||
+{
|
|
||||||
+ struct mt7530_priv *priv = ds->priv;
|
|
||||||
+
|
|
||||||
+ return priv->info->pad_setup(ds, state);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int
|
|
||||||
+mt7530_mac_setup(struct dsa_switch *ds, int port, unsigned int mode,
|
|
||||||
+ const struct phylink_link_state *state)
|
|
||||||
+{
|
|
||||||
+ struct mt7530_priv *priv = ds->priv;
|
|
||||||
+
|
|
||||||
+ /* Only need to setup port5. */
|
|
||||||
+ if (port != 5)
|
|
||||||
+ return 0;
|
|
||||||
+
|
|
||||||
+ mt7530_setup_port5(priv->ds, state->interface);
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int mt753x_mac_setup(struct dsa_switch *ds, int port, unsigned int mode,
|
|
||||||
+ const struct phylink_link_state *state)
|
|
||||||
+{
|
|
||||||
+ struct mt7530_priv *priv = ds->priv;
|
|
||||||
+
|
|
||||||
+ return priv->info->mac_setup(ds, port, mode, state);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void mt753x_phylink_mac_config(struct dsa_switch *ds, int port,
|
|
||||||
unsigned int mode,
|
|
||||||
const struct phylink_link_state *state)
|
|
||||||
{
|
|
||||||
struct mt7530_priv *priv = ds->priv;
|
|
||||||
u32 mcr_cur, mcr_new;
|
|
||||||
|
|
||||||
+ if (!mt753x_phy_supported(ds, port, state))
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
switch (port) {
|
|
||||||
case 0: /* Internal phy */
|
|
||||||
case 1:
|
|
||||||
@@ -1374,24 +1472,15 @@ static void mt7530_phylink_mac_config(st
|
|
||||||
case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
|
|
||||||
if (priv->p5_interface == state->interface)
|
|
||||||
break;
|
|
||||||
- if (!phy_interface_mode_is_rgmii(state->interface) &&
|
|
||||||
- state->interface != PHY_INTERFACE_MODE_MII &&
|
|
||||||
- state->interface != PHY_INTERFACE_MODE_GMII)
|
|
||||||
- return;
|
|
||||||
-
|
|
||||||
- mt7530_setup_port5(ds, state->interface);
|
|
||||||
+ if (mt753x_mac_setup(ds, port, mode, state) < 0)
|
|
||||||
+ goto unsupported;
|
|
||||||
break;
|
|
||||||
case 6: /* 1st cpu port */
|
|
||||||
if (priv->p6_interface == state->interface)
|
|
||||||
break;
|
|
||||||
-
|
|
||||||
- if (state->interface != PHY_INTERFACE_MODE_RGMII &&
|
|
||||||
- state->interface != PHY_INTERFACE_MODE_TRGMII)
|
|
||||||
- return;
|
|
||||||
-
|
|
||||||
- /* Setup TX circuit incluing relevant PAD and driving */
|
|
||||||
- mt7530_pad_clk_setup(ds, state->interface);
|
|
||||||
-
|
|
||||||
+ mt753x_pad_setup(ds, state);
|
|
||||||
+ if (mt753x_mac_setup(ds, port, mode, state) < 0)
|
|
||||||
+ goto unsupported;
|
|
||||||
priv->p6_interface = state->interface;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
@@ -1459,38 +1548,14 @@ static void mt7530_phylink_mac_link_up(s
|
|
||||||
mt7530_port_set_status(priv, port, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void mt7530_phylink_validate(struct dsa_switch *ds, int port,
|
|
||||||
+static void mt753x_phylink_validate(struct dsa_switch *ds, int port,
|
|
||||||
unsigned long *supported,
|
|
||||||
struct phylink_link_state *state)
|
|
||||||
{
|
|
||||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
|
|
||||||
|
|
||||||
- switch (port) {
|
|
||||||
- case 0: /* Internal phy */
|
|
||||||
- case 1:
|
|
||||||
- case 2:
|
|
||||||
- case 3:
|
|
||||||
- case 4:
|
|
||||||
- if (state->interface != PHY_INTERFACE_MODE_NA &&
|
|
||||||
- state->interface != PHY_INTERFACE_MODE_GMII)
|
|
||||||
- goto unsupported;
|
|
||||||
- break;
|
|
||||||
- case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
|
|
||||||
- if (state->interface != PHY_INTERFACE_MODE_NA &&
|
|
||||||
- !phy_interface_mode_is_rgmii(state->interface) &&
|
|
||||||
- state->interface != PHY_INTERFACE_MODE_MII &&
|
|
||||||
- state->interface != PHY_INTERFACE_MODE_GMII)
|
|
||||||
- goto unsupported;
|
|
||||||
- break;
|
|
||||||
- case 6: /* 1st cpu port */
|
|
||||||
- if (state->interface != PHY_INTERFACE_MODE_NA &&
|
|
||||||
- state->interface != PHY_INTERFACE_MODE_RGMII &&
|
|
||||||
- state->interface != PHY_INTERFACE_MODE_TRGMII)
|
|
||||||
- goto unsupported;
|
|
||||||
- break;
|
|
||||||
- default:
|
|
||||||
- dev_err(ds->dev, "%s: unsupported port: %i\n", __func__, port);
|
|
||||||
-unsupported:
|
|
||||||
+ if (state->interface != PHY_INTERFACE_MODE_NA &&
|
|
||||||
+ !mt753x_phy_supported(ds, port, state)) {
|
|
||||||
linkmode_zero(supported);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@@ -1609,12 +1674,36 @@ static int mt7530_set_mac_eee(struct dsa
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int
|
|
||||||
+mt753x_setup(struct dsa_switch *ds)
|
|
||||||
+{
|
|
||||||
+ struct mt7530_priv *priv = ds->priv;
|
|
||||||
+
|
|
||||||
+ return priv->info->setup(ds);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int
|
|
||||||
+mt753x_phy_read(struct dsa_switch *ds, int port, int regnum)
|
|
||||||
+{
|
|
||||||
+ struct mt7530_priv *priv = ds->priv;
|
|
||||||
+
|
|
||||||
+ return priv->info->phy_read(ds, port, regnum);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int
|
|
||||||
+mt753x_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
|
|
||||||
+{
|
|
||||||
+ struct mt7530_priv *priv = ds->priv;
|
|
||||||
+
|
|
||||||
+ return priv->info->phy_write(ds, port, regnum, val);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static const struct dsa_switch_ops mt7530_switch_ops = {
|
|
||||||
.get_tag_protocol = mtk_get_tag_protocol,
|
|
||||||
- .setup = mt7530_setup,
|
|
||||||
+ .setup = mt753x_setup,
|
|
||||||
.get_strings = mt7530_get_strings,
|
|
||||||
- .phy_read = mt7530_phy_read,
|
|
||||||
- .phy_write = mt7530_phy_write,
|
|
||||||
+ .phy_read = mt753x_phy_read,
|
|
||||||
+ .phy_write = mt753x_phy_write,
|
|
||||||
.get_ethtool_stats = mt7530_get_ethtool_stats,
|
|
||||||
.get_sset_count = mt7530_get_sset_count,
|
|
||||||
.port_enable = mt7530_port_enable,
|
|
||||||
@@ -1631,18 +1720,39 @@ static const struct dsa_switch_ops mt753
|
|
||||||
.port_vlan_del = mt7530_port_vlan_del,
|
|
||||||
.port_mirror_add = mt7530_port_mirror_add,
|
|
||||||
.port_mirror_del = mt7530_port_mirror_del,
|
|
||||||
- .phylink_validate = mt7530_phylink_validate,
|
|
||||||
+ .phylink_validate = mt753x_phylink_validate,
|
|
||||||
.phylink_mac_link_state = mt7530_phylink_mac_link_state,
|
|
||||||
- .phylink_mac_config = mt7530_phylink_mac_config,
|
|
||||||
+ .phylink_mac_config = mt753x_phylink_mac_config,
|
|
||||||
.phylink_mac_link_down = mt7530_phylink_mac_link_down,
|
|
||||||
.phylink_mac_link_up = mt7530_phylink_mac_link_up,
|
|
||||||
.get_mac_eee = mt7530_get_mac_eee,
|
|
||||||
.set_mac_eee = mt7530_set_mac_eee,
|
|
||||||
};
|
|
||||||
|
|
||||||
-static const struct of_device_id mt7530_of_match[] = {
|
|
||||||
- { .compatible = "mediatek,mt7621", .data = (void *)ID_MT7621, },
|
|
||||||
- { .compatible = "mediatek,mt7530", .data = (void *)ID_MT7530, },
|
|
||||||
+static const struct mt753x_info mt753x_table[] = {
|
|
||||||
+ [ID_MT7621] = {
|
|
||||||
+ .id = ID_MT7621,
|
|
||||||
+ .setup = mt7530_setup,
|
|
||||||
+ .phy_read = mt7530_phy_read,
|
|
||||||
+ .phy_write = mt7530_phy_write,
|
|
||||||
+ .phy_supported = mt7530_phy_supported,
|
|
||||||
+ .pad_setup = mt7530_pad_setup,
|
|
||||||
+ .mac_setup = mt7530_mac_setup,
|
|
||||||
+ },
|
|
||||||
+ [ID_MT7530] = {
|
|
||||||
+ .id = ID_MT7530,
|
|
||||||
+ .setup = mt7530_setup,
|
|
||||||
+ .phy_read = mt7530_phy_read,
|
|
||||||
+ .phy_write = mt7530_phy_write,
|
|
||||||
+ .phy_supported = mt7530_phy_supported,
|
|
||||||
+ .pad_setup = mt7530_pad_setup,
|
|
||||||
+ .mac_setup = mt7530_mac_setup,
|
|
||||||
+ },
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+ static const struct of_device_id mt7530_of_match[] = {
|
|
||||||
+ { .compatible = "mediatek,mt7621", .data = &mt753x_table[ID_MT7621], },
|
|
||||||
+ { .compatible = "mediatek,mt7530", .data = &mt753x_table[ID_MT7530], },
|
|
||||||
{ /* sentinel */ },
|
|
||||||
};
|
|
||||||
MODULE_DEVICE_TABLE(of, mt7530_of_match);
|
|
||||||
@@ -1680,8 +1790,19 @@ mt7530_probe(struct mdio_device *mdiodev
|
|
||||||
/* Get the hardware identifier from the devicetree node.
|
|
||||||
* We will need it for some of the clock and regulator setup.
|
|
||||||
*/
|
|
||||||
- priv->id = (unsigned int)(unsigned long)
|
|
||||||
- of_device_get_match_data(&mdiodev->dev);
|
|
||||||
+ priv->info = of_device_get_match_data(&mdiodev->dev);
|
|
||||||
+ if (!priv->info)
|
|
||||||
+ return -EINVAL;
|
|
||||||
+
|
|
||||||
+ /* Sanity check if these required device operstaions are filled
|
|
||||||
+ * properly.
|
|
||||||
+ */
|
|
||||||
+ if (!priv->info->setup || !priv->info->phy_read ||
|
|
||||||
+ !priv->info->phy_write || !priv->info->phy_supported ||
|
|
||||||
+ !priv->info->pad_setup || !priv->info->mac_setup)
|
|
||||||
+ return -EINVAL;
|
|
||||||
+
|
|
||||||
+ priv->id = priv->info->id;
|
|
||||||
|
|
||||||
if (priv->id == ID_MT7530) {
|
|
||||||
priv->core_pwr = devm_regulator_get(&mdiodev->dev, "core");
|
|
||||||
--- a/drivers/net/dsa/mt7530.h
|
|
||||||
+++ b/drivers/net/dsa/mt7530.h
|
|
||||||
@@ -11,7 +11,7 @@
|
|
||||||
#define MT7530_NUM_FDB_RECORDS 2048
|
|
||||||
#define MT7530_ALL_MEMBERS 0xff
|
|
||||||
|
|
||||||
-enum {
|
|
||||||
+enum mt753x_id {
|
|
||||||
ID_MT7530 = 0,
|
|
||||||
ID_MT7621 = 1,
|
|
||||||
};
|
|
||||||
@@ -447,6 +447,32 @@ static const char *p5_intf_modes(unsigne
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+/* struct mt753x_info - This is the main data structure for holding the specific
|
|
||||||
+ * part for each supported device
|
|
||||||
+ * @setup: Holding the handler to a device initialization
|
|
||||||
+ * @phy_read: Holding the way reading PHY port
|
|
||||||
+ * @phy_write: Holding the way writing PHY port
|
|
||||||
+ * @phy_supported: Check if the PHY type is being supported on a certain
|
|
||||||
+ * port
|
|
||||||
+ * @pad_setup: Holding the way setting up the bus pad for a certain MAC
|
|
||||||
+ * port
|
|
||||||
+ * @mac_setup: Holding the way setting up the PHY attribute for a
|
|
||||||
+ * certain MAC port
|
|
||||||
+ */
|
|
||||||
+struct mt753x_info {
|
|
||||||
+ enum mt753x_id id;
|
|
||||||
+
|
|
||||||
+ int (*setup)(struct dsa_switch *ds);
|
|
||||||
+ int (*phy_read)(struct dsa_switch *ds, int port, int regnum);
|
|
||||||
+ int (*phy_write)(struct dsa_switch *ds, int port, int regnum, u16 val);
|
|
||||||
+ bool (*phy_supported)(struct dsa_switch *ds, int port,
|
|
||||||
+ const struct phylink_link_state *state);
|
|
||||||
+ int (*pad_setup)(struct dsa_switch *ds,
|
|
||||||
+ const struct phylink_link_state *state);
|
|
||||||
+ int (*mac_setup)(struct dsa_switch *ds, int port, unsigned int mode,
|
|
||||||
+ const struct phylink_link_state *state);
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/* struct mt7530_priv - This is the main data structure for holding the state
|
|
||||||
* of the driver
|
|
||||||
* @dev: The device pointer
|
|
||||||
@@ -472,6 +498,7 @@ struct mt7530_priv {
|
|
||||||
struct regulator *core_pwr;
|
|
||||||
struct regulator *io_pwr;
|
|
||||||
struct gpio_desc *reset;
|
|
||||||
+ const struct mt753x_info *info;
|
|
||||||
unsigned int id;
|
|
||||||
bool mcm;
|
|
||||||
phy_interface_t p6_interface;
|
|
|
@ -1,179 +0,0 @@
|
||||||
From patchwork Tue Dec 10 08:14:39 2019
|
|
||||||
Content-Type: text/plain; charset="utf-8"
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Transfer-Encoding: 7bit
|
|
||||||
X-Patchwork-Submitter: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
X-Patchwork-Id: 1206955
|
|
||||||
X-Patchwork-Delegate: davem@davemloft.net
|
|
||||||
Return-Path: <netdev-owner@vger.kernel.org>
|
|
||||||
X-Original-To: patchwork-incoming-netdev@ozlabs.org
|
|
||||||
Delivered-To: patchwork-incoming-netdev@ozlabs.org
|
|
||||||
Authentication-Results: ozlabs.org; spf=none (no SPF record)
|
|
||||||
smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67;
|
|
||||||
helo=vger.kernel.org;
|
|
||||||
envelope-from=netdev-owner@vger.kernel.org;
|
|
||||||
receiver=<UNKNOWN>)
|
|
||||||
Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none)
|
|
||||||
header.from=mediatek.com
|
|
||||||
Authentication-Results: ozlabs.org; dkim=pass (1024-bit key;
|
|
||||||
unprotected) header.d=mediatek.com header.i=@mediatek.com
|
|
||||||
header.b="SuczJHZp"; dkim-atps=neutral
|
|
||||||
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
|
|
||||||
by ozlabs.org (Postfix) with ESMTP id 47XCXj3BBNz9sPh
|
|
||||||
for <patchwork-incoming-netdev@ozlabs.org>;
|
|
||||||
Tue, 10 Dec 2019 19:15:01 +1100 (AEDT)
|
|
||||||
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
|
|
||||||
id S1727133AbfLJIPA (ORCPT
|
|
||||||
<rfc822;patchwork-incoming-netdev@ozlabs.org>);
|
|
||||||
Tue, 10 Dec 2019 03:15:00 -0500
|
|
||||||
Received: from mailgw02.mediatek.com ([210.61.82.184]:45567 "EHLO
|
|
||||||
mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by
|
|
||||||
vger.kernel.org with ESMTP id S1727022AbfLJIO7 (ORCPT
|
|
||||||
<rfc822;netdev@vger.kernel.org>); Tue, 10 Dec 2019 03:14:59 -0500
|
|
||||||
X-UUID: a1d9a42928d44d63b201d5ad84c05baa-20191210
|
|
||||||
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
|
|
||||||
d=mediatek.com; s=dk;
|
|
||||||
h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From;
|
|
||||||
bh=KJqQ2m7z9H4vre+SZyxgKEGRWb9Edp5pJlYnepJNMyM=;
|
|
||||||
b=SuczJHZpeY7vF8UsCGorYUAcT2lEUX2E0ciiyQBS1rDLPzTYnufK8OXyAw5Uq8U1m72TGWYCaq1o0VWtI1meJpEmCL2TVK/d+Y+IaacHlO716BmX77+0MU0crczE8zx1Nz2pNh+GicsB6AoC9qbBU+p5egbKDMBhpRaGQNAeBww=;
|
|
||||||
X-UUID: a1d9a42928d44d63b201d5ad84c05baa-20191210
|
|
||||||
Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by
|
|
||||||
mailgw02.mediatek.com (envelope-from <landen.chao@mediatek.com>)
|
|
||||||
(Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS)
|
|
||||||
with ESMTP id 297826603; Tue, 10 Dec 2019 16:14:47 +0800
|
|
||||||
Received: from mtkcas08.mediatek.inc (172.21.101.126) by
|
|
||||||
mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server
|
|
||||||
(TLS) id 15.0.1395.4; Tue, 10 Dec 2019 16:14:38 +0800
|
|
||||||
Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc
|
|
||||||
(172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via
|
|
||||||
Frontend Transport; Tue, 10 Dec 2019 16:14:26 +0800
|
|
||||||
From: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
To: <andrew@lunn.ch>, <f.fainelli@gmail.com>,
|
|
||||||
<vivien.didelot@savoirfairelinux.com>, <matthias.bgg@gmail.com>,
|
|
||||||
<robh+dt@kernel.org>, <mark.rutland@arm.com>
|
|
||||||
CC: <devicetree@vger.kernel.org>, <netdev@vger.kernel.org>,
|
|
||||||
<linux-kernel@vger.kernel.org>,
|
|
||||||
<linux-mediatek@lists.infradead.org>, <davem@davemloft.net>,
|
|
||||||
<sean.wang@mediatek.com>, <opensource@vdorst.com>,
|
|
||||||
<frank-w@public-files.de>, Landen Chao <landen.chao@mediatek.com>
|
|
||||||
Subject: [PATCH net-next 3/6] dt-bindings: net: dsa: add new MT7531 binding
|
|
||||||
to support MT7531
|
|
||||||
Date: Tue, 10 Dec 2019 16:14:39 +0800
|
|
||||||
Message-ID: <1c382fd916b66bfe3ce8ef18c12f954dbcbddbbc.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
X-Mailer: git-send-email 2.18.0
|
|
||||||
In-Reply-To: <cover.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
References: <cover.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
MIME-Version: 1.0
|
|
||||||
X-MTK: N
|
|
||||||
Sender: netdev-owner@vger.kernel.org
|
|
||||||
Precedence: bulk
|
|
||||||
List-ID: <netdev.vger.kernel.org>
|
|
||||||
X-Mailing-List: netdev@vger.kernel.org
|
|
||||||
|
|
||||||
Add devicetree binding to support the compatible mt7531 switch as used
|
|
||||||
in the MediaTek MT7531 switch.
|
|
||||||
|
|
||||||
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
|
|
||||||
Signed-off-by: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
---
|
|
||||||
.../devicetree/bindings/net/dsa/mt7530.txt | 77 ++++++++++++++++++-
|
|
||||||
1 file changed, 74 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
--- a/Documentation/devicetree/bindings/net/dsa/mt7530.txt
|
|
||||||
+++ b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
|
|
||||||
@@ -5,6 +5,7 @@ Required properties:
|
|
||||||
|
|
||||||
- compatible: may be compatible = "mediatek,mt7530"
|
|
||||||
or compatible = "mediatek,mt7621"
|
|
||||||
+ or compatible = "mediatek,mt7531"
|
|
||||||
- #address-cells: Must be 1.
|
|
||||||
- #size-cells: Must be 0.
|
|
||||||
- mediatek,mcm: Boolean; if defined, indicates that either MT7530 is the part
|
|
||||||
@@ -32,10 +33,13 @@ Required properties for the child nodes
|
|
||||||
|
|
||||||
- reg: Port address described must be 6 for CPU port and from 0 to 5 for
|
|
||||||
user ports.
|
|
||||||
-- phy-mode: String, must be either "trgmii" or "rgmii" for port labeled
|
|
||||||
- "cpu".
|
|
||||||
+- phy-mode: String, the follow value would be acceptable for port labeled "cpu"
|
|
||||||
+ If compatible mediatek,mt7530 or mediatek,mt7621 is set,
|
|
||||||
+ must be either "trgmii" or "rgmii"
|
|
||||||
+ If compatible mediatek,mt7531 is set,
|
|
||||||
+ must be either "sgmii", "1000base-x" or "2500base-x"
|
|
||||||
|
|
||||||
-Port 5 of the switch is muxed between:
|
|
||||||
+Port 5 of mt7530 and mt7621 switch is muxed between:
|
|
||||||
1. GMAC5: GMAC5 can interface with another external MAC or PHY.
|
|
||||||
2. PHY of port 0 or port 4: PHY interfaces with an external MAC like 2nd GMAC
|
|
||||||
of the SOC. Used in many setups where port 0/4 becomes the WAN port.
|
|
||||||
@@ -308,3 +312,70 @@ Example 3: MT7621: Port 5 is connected t
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
+
|
|
||||||
+Example 4:
|
|
||||||
+
|
|
||||||
+ð {
|
|
||||||
+ gmac0: mac@0 {
|
|
||||||
+ compatible = "mediatek,eth-mac";
|
|
||||||
+ reg = <0>;
|
|
||||||
+ phy-mode = "2500base-x";
|
|
||||||
+
|
|
||||||
+ fixed-link {
|
|
||||||
+ speed = <1000>;
|
|
||||||
+ full-duplex;
|
|
||||||
+ pause;
|
|
||||||
+ };
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ &mdio0 {
|
|
||||||
+ switch@0 {
|
|
||||||
+ compatible = "mediatek,mt7531";
|
|
||||||
+ reg = <0>;
|
|
||||||
+ reset-gpios = <&pio 54 0>;
|
|
||||||
+
|
|
||||||
+ ports {
|
|
||||||
+ #address-cells = <1>;
|
|
||||||
+ #size-cells = <0>;
|
|
||||||
+ reg = <0>;
|
|
||||||
+
|
|
||||||
+ port@0 {
|
|
||||||
+ reg = <0>;
|
|
||||||
+ label = "lan0";
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ port@1 {
|
|
||||||
+ reg = <1>;
|
|
||||||
+ label = "lan1";
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ port@2 {
|
|
||||||
+ reg = <2>;
|
|
||||||
+ label = "lan2";
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ port@3 {
|
|
||||||
+ reg = <3>;
|
|
||||||
+ label = "lan3";
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ port@4 {
|
|
||||||
+ reg = <4>;
|
|
||||||
+ label = "wan";
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ port@6 {
|
|
||||||
+ reg = <6>;
|
|
||||||
+ label = "cpu";
|
|
||||||
+ ethernet = <&gmac0>;
|
|
||||||
+ phy-mode = "2500base-x";
|
|
||||||
+
|
|
||||||
+ fixed-link {
|
|
||||||
+ speed = <1000>;
|
|
||||||
+ full-duplex;
|
|
||||||
+ pause;
|
|
||||||
+ };
|
|
||||||
+ };
|
|
||||||
+ };
|
|
||||||
+ };
|
|
||||||
+ };
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,138 +0,0 @@
|
||||||
From patchwork Tue Dec 10 08:14:42 2019
|
|
||||||
Content-Type: text/plain; charset="utf-8"
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Transfer-Encoding: 7bit
|
|
||||||
X-Patchwork-Submitter: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
X-Patchwork-Id: 1206964
|
|
||||||
X-Patchwork-Delegate: davem@davemloft.net
|
|
||||||
Return-Path: <netdev-owner@vger.kernel.org>
|
|
||||||
X-Original-To: patchwork-incoming-netdev@ozlabs.org
|
|
||||||
Delivered-To: patchwork-incoming-netdev@ozlabs.org
|
|
||||||
Authentication-Results: ozlabs.org; spf=none (no SPF record)
|
|
||||||
smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67;
|
|
||||||
helo=vger.kernel.org;
|
|
||||||
envelope-from=netdev-owner@vger.kernel.org;
|
|
||||||
receiver=<UNKNOWN>)
|
|
||||||
Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none)
|
|
||||||
header.from=mediatek.com
|
|
||||||
Authentication-Results: ozlabs.org; dkim=pass (1024-bit key;
|
|
||||||
unprotected) header.d=mediatek.com header.i=@mediatek.com
|
|
||||||
header.b="eagJVm76"; dkim-atps=neutral
|
|
||||||
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
|
|
||||||
by ozlabs.org (Postfix) with ESMTP id 47XCYF2fNjz9sR7
|
|
||||||
for <patchwork-incoming-netdev@ozlabs.org>;
|
|
||||||
Tue, 10 Dec 2019 19:15:29 +1100 (AEDT)
|
|
||||||
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
|
|
||||||
id S1727295AbfLJIP0 (ORCPT
|
|
||||||
<rfc822;patchwork-incoming-netdev@ozlabs.org>);
|
|
||||||
Tue, 10 Dec 2019 03:15:26 -0500
|
|
||||||
Received: from mailgw01.mediatek.com ([210.61.82.183]:21469 "EHLO
|
|
||||||
mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by
|
|
||||||
vger.kernel.org with ESMTP id S1726062AbfLJIO4 (ORCPT
|
|
||||||
<rfc822;netdev@vger.kernel.org>); Tue, 10 Dec 2019 03:14:56 -0500
|
|
||||||
X-UUID: f9b456136baf42daba0957485d388010-20191210
|
|
||||||
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
|
|
||||||
d=mediatek.com; s=dk;
|
|
||||||
h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From;
|
|
||||||
bh=BT+q/z4xoeKXCk+y25bvARvW/z0vRa1uB7kHqAjvpaw=;
|
|
||||||
b=eagJVm76XNgnVVvxDHR4QtcIyynPPYY4k7twyvlRAQeSnsJbABh1afLK+LlxnJ0TM069F+hNNzWXq7ZGru/I+gYhmqZcYCt/SkEYgxdTb0VNE+DIW0hmNAOoJ0i23gobJ3xa7JVRfIfeZcbjwRJSuqwzLBRZBLIFzqSs71VZx1Y=;
|
|
||||||
X-UUID: f9b456136baf42daba0957485d388010-20191210
|
|
||||||
Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by
|
|
||||||
mailgw01.mediatek.com (envelope-from <landen.chao@mediatek.com>)
|
|
||||||
(Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS)
|
|
||||||
with ESMTP id 1831961689; Tue, 10 Dec 2019 16:14:48 +0800
|
|
||||||
Received: from mtkcas08.mediatek.inc (172.21.101.126) by
|
|
||||||
mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server
|
|
||||||
(TLS) id 15.0.1395.4; Tue, 10 Dec 2019 16:14:32 +0800
|
|
||||||
Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc
|
|
||||||
(172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via
|
|
||||||
Frontend Transport; Tue, 10 Dec 2019 16:14:27 +0800
|
|
||||||
From: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
To: <andrew@lunn.ch>, <f.fainelli@gmail.com>,
|
|
||||||
<vivien.didelot@savoirfairelinux.com>, <matthias.bgg@gmail.com>,
|
|
||||||
<robh+dt@kernel.org>, <mark.rutland@arm.com>
|
|
||||||
CC: <devicetree@vger.kernel.org>, <netdev@vger.kernel.org>,
|
|
||||||
<linux-kernel@vger.kernel.org>,
|
|
||||||
<linux-mediatek@lists.infradead.org>, <davem@davemloft.net>,
|
|
||||||
<sean.wang@mediatek.com>, <opensource@vdorst.com>,
|
|
||||||
<frank-w@public-files.de>, Landen Chao <landen.chao@mediatek.com>
|
|
||||||
Subject: [PATCH net-next 6/6] arm64: dts: mt7622: add mt7531 dsa to
|
|
||||||
bananapi-bpi-r64 board
|
|
||||||
Date: Tue, 10 Dec 2019 16:14:42 +0800
|
|
||||||
Message-ID: <62eef5503c117f48d4b41e94fd28d75e123590b4.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
X-Mailer: git-send-email 2.18.0
|
|
||||||
In-Reply-To: <cover.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
References: <cover.1575914275.git.landen.chao@mediatek.com>
|
|
||||||
MIME-Version: 1.0
|
|
||||||
X-MTK: N
|
|
||||||
Sender: netdev-owner@vger.kernel.org
|
|
||||||
Precedence: bulk
|
|
||||||
List-ID: <netdev.vger.kernel.org>
|
|
||||||
X-Mailing-List: netdev@vger.kernel.org
|
|
||||||
|
|
||||||
Add mt7531 dsa to bananapi-bpi-r64 board for 5 giga Ethernet ports support.
|
|
||||||
|
|
||||||
Signed-off-by: Landen Chao <landen.chao@mediatek.com>
|
|
||||||
---
|
|
||||||
.../dts/mediatek/mt7622-bananapi-bpi-r64.dts | 50 +++++++++++++++++++
|
|
||||||
1 file changed, 50 insertions(+)
|
|
||||||
|
|
||||||
--- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
|
||||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
|
||||||
@@ -150,6 +150,56 @@
|
|
||||||
mdio: mdio-bus {
|
|
||||||
#address-cells = <1>;
|
|
||||||
#size-cells = <0>;
|
|
||||||
+
|
|
||||||
+ switch@0 {
|
|
||||||
+ compatible = "mediatek,mt7531";
|
|
||||||
+ reg = <0>;
|
|
||||||
+ reset-gpios = <&pio 54 0>;
|
|
||||||
+
|
|
||||||
+ ports {
|
|
||||||
+ #address-cells = <1>;
|
|
||||||
+ #size-cells = <0>;
|
|
||||||
+
|
|
||||||
+ port@0 {
|
|
||||||
+ reg = <0>;
|
|
||||||
+ label = "wan";
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ port@1 {
|
|
||||||
+ reg = <1>;
|
|
||||||
+ label = "lan0";
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ port@2 {
|
|
||||||
+ reg = <2>;
|
|
||||||
+ label = "lan1";
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ port@3 {
|
|
||||||
+ reg = <3>;
|
|
||||||
+ label = "lan2";
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ port@4 {
|
|
||||||
+ reg = <4>;
|
|
||||||
+ label = "lan3";
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ port@6 {
|
|
||||||
+ reg = <6>;
|
|
||||||
+ label = "cpu";
|
|
||||||
+ ethernet = <&gmac0>;
|
|
||||||
+ phy-mode = "2500base-x";
|
|
||||||
+
|
|
||||||
+ fixed-link {
|
|
||||||
+ speed = <2500>;
|
|
||||||
+ full-duplex;
|
|
||||||
+ pause;
|
|
||||||
+ };
|
|
||||||
+ };
|
|
||||||
+ };
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
|
@ -0,0 +1,246 @@
|
||||||
|
From: Russell King <rmk+kernel@armlinux.org.uk>
|
||||||
|
Date: Wed, 26 Feb 2020 10:23:41 +0000
|
||||||
|
Subject: [PATCH] net: phylink: propagate resolved link config via
|
||||||
|
mac_link_up()
|
||||||
|
|
||||||
|
Propagate the resolved link parameters via the mac_link_up() call for
|
||||||
|
MACs that do not automatically track their PCS state. We propagate the
|
||||||
|
link parameters via function arguments so that inappropriate members
|
||||||
|
of struct phylink_link_state can't be accessed, and creating a new
|
||||||
|
structure just for this adds needless complexity to the API.
|
||||||
|
|
||||||
|
Tested-by: Andre Przywara <andre.przywara@arm.com>
|
||||||
|
Tested-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
|
||||||
|
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
|
||||||
|
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
|
||||||
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||||
|
---
|
||||||
|
|
||||||
|
--- a/Documentation/networking/sfp-phylink.rst
|
||||||
|
+++ b/Documentation/networking/sfp-phylink.rst
|
||||||
|
@@ -74,10 +74,13 @@ phylib to the sfp/phylink support. Plea
|
||||||
|
this documentation.
|
||||||
|
|
||||||
|
1. Optionally split the network driver's phylib update function into
|
||||||
|
- three parts dealing with link-down, link-up and reconfiguring the
|
||||||
|
- MAC settings. This can be done as a separate preparation commit.
|
||||||
|
+ two parts dealing with link-down and link-up. This can be done as
|
||||||
|
+ a separate preparation commit.
|
||||||
|
|
||||||
|
- An example of this preparation can be found in git commit fc548b991fb0.
|
||||||
|
+ An older example of this preparation can be found in git commit
|
||||||
|
+ fc548b991fb0, although this was splitting into three parts; the
|
||||||
|
+ link-up part now includes configuring the MAC for the link settings.
|
||||||
|
+ Please see :c:func:`mac_link_up` for more information on this.
|
||||||
|
|
||||||
|
2. Replace::
|
||||||
|
|
||||||
|
@@ -207,6 +210,14 @@ this documentation.
|
||||||
|
using. This is particularly important for in-band negotiation
|
||||||
|
methods such as 1000base-X and SGMII.
|
||||||
|
|
||||||
|
+ The :c:func:`mac_link_up` method is used to inform the MAC that the
|
||||||
|
+ link has come up. The call includes the negotiation mode and interface
|
||||||
|
+ for reference only. The finalised link parameters are also supplied
|
||||||
|
+ (speed, duplex and flow control/pause enablement settings) which
|
||||||
|
+ should be used to configure the MAC when the MAC and PCS are not
|
||||||
|
+ tightly integrated, or when the settings are not coming from in-band
|
||||||
|
+ negotiation.
|
||||||
|
+
|
||||||
|
The :c:func:`mac_config` method is used to update the MAC with the
|
||||||
|
requested state, and must avoid unnecessarily taking the link down
|
||||||
|
when making changes to the MAC configuration. This means the
|
||||||
|
--- a/drivers/net/ethernet/marvell/mvneta.c
|
||||||
|
+++ b/drivers/net/ethernet/marvell/mvneta.c
|
||||||
|
@@ -3653,9 +3653,11 @@ static void mvneta_mac_link_down(struct
|
||||||
|
mvneta_set_eee(pp, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void mvneta_mac_link_up(struct phylink_config *config, unsigned int mode,
|
||||||
|
- phy_interface_t interface,
|
||||||
|
- struct phy_device *phy)
|
||||||
|
+static void mvneta_mac_link_up(struct phylink_config *config,
|
||||||
|
+ struct phy_device *phy,
|
||||||
|
+ unsigned int mode, phy_interface_t interface,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
struct net_device *ndev = to_net_dev(config->dev);
|
||||||
|
struct mvneta_port *pp = netdev_priv(ndev);
|
||||||
|
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
|
||||||
|
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
|
||||||
|
@@ -58,8 +58,11 @@ static struct {
|
||||||
|
*/
|
||||||
|
static void mvpp2_mac_config(struct phylink_config *config, unsigned int mode,
|
||||||
|
const struct phylink_link_state *state);
|
||||||
|
-static void mvpp2_mac_link_up(struct phylink_config *config, unsigned int mode,
|
||||||
|
- phy_interface_t interface, struct phy_device *phy);
|
||||||
|
+static void mvpp2_mac_link_up(struct phylink_config *config,
|
||||||
|
+ struct phy_device *phy,
|
||||||
|
+ unsigned int mode, phy_interface_t interface,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause);
|
||||||
|
|
||||||
|
/* Queue modes */
|
||||||
|
#define MVPP2_QDIST_SINGLE_MODE 0
|
||||||
|
@@ -3467,8 +3470,9 @@ static void mvpp2_start_dev(struct mvpp2
|
||||||
|
.interface = port->phy_interface,
|
||||||
|
};
|
||||||
|
mvpp2_mac_config(&port->phylink_config, MLO_AN_INBAND, &state);
|
||||||
|
- mvpp2_mac_link_up(&port->phylink_config, MLO_AN_INBAND,
|
||||||
|
- port->phy_interface, NULL);
|
||||||
|
+ mvpp2_mac_link_up(&port->phylink_config, NULL,
|
||||||
|
+ MLO_AN_INBAND, port->phy_interface,
|
||||||
|
+ SPEED_UNKNOWN, DUPLEX_UNKNOWN, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
netif_tx_start_all_queues(port->dev);
|
||||||
|
@@ -5124,8 +5128,11 @@ static void mvpp2_mac_config(struct phyl
|
||||||
|
mvpp2_port_enable(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void mvpp2_mac_link_up(struct phylink_config *config, unsigned int mode,
|
||||||
|
- phy_interface_t interface, struct phy_device *phy)
|
||||||
|
+static void mvpp2_mac_link_up(struct phylink_config *config,
|
||||||
|
+ struct phy_device *phy,
|
||||||
|
+ unsigned int mode, phy_interface_t interface,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
struct net_device *dev = to_net_dev(config->dev);
|
||||||
|
struct mvpp2_port *port = netdev_priv(dev);
|
||||||
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||||
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||||
|
@@ -445,9 +445,10 @@ static void mtk_mac_link_down(struct phy
|
||||||
|
mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id));
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void mtk_mac_link_up(struct phylink_config *config, unsigned int mode,
|
||||||
|
- phy_interface_t interface,
|
||||||
|
- struct phy_device *phy)
|
||||||
|
+static void mtk_mac_link_up(struct phylink_config *config,
|
||||||
|
+ struct phy_device *phy,
|
||||||
|
+ unsigned int mode, phy_interface_t interface,
|
||||||
|
+ int speed, int duplex, bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
struct mtk_mac *mac = container_of(config, struct mtk_mac,
|
||||||
|
phylink_config);
|
||||||
|
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||||
|
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||||
|
@@ -951,8 +951,10 @@ static void stmmac_mac_link_down(struct
|
||||||
|
}
|
||||||
|
|
||||||
|
static void stmmac_mac_link_up(struct phylink_config *config,
|
||||||
|
+ struct phy_device *phy,
|
||||||
|
unsigned int mode, phy_interface_t interface,
|
||||||
|
- struct phy_device *phy)
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
|
||||||
|
|
||||||
|
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
|
||||||
|
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
|
||||||
|
@@ -1488,9 +1488,10 @@ static void axienet_mac_link_down(struct
|
||||||
|
}
|
||||||
|
|
||||||
|
static void axienet_mac_link_up(struct phylink_config *config,
|
||||||
|
- unsigned int mode,
|
||||||
|
- phy_interface_t interface,
|
||||||
|
- struct phy_device *phy)
|
||||||
|
+ struct phy_device *phy,
|
||||||
|
+ unsigned int mode, phy_interface_t interface,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
/* nothing meaningful to do */
|
||||||
|
}
|
||||||
|
--- a/drivers/net/phy/phylink.c
|
||||||
|
+++ b/drivers/net/phy/phylink.c
|
||||||
|
@@ -447,8 +447,11 @@ static void phylink_mac_link_up(struct p
|
||||||
|
struct net_device *ndev = pl->netdev;
|
||||||
|
|
||||||
|
pl->cur_interface = link_state.interface;
|
||||||
|
- pl->ops->mac_link_up(pl->config, pl->cur_link_an_mode,
|
||||||
|
- pl->cur_interface, pl->phydev);
|
||||||
|
+ pl->ops->mac_link_up(pl->config, pl->phydev,
|
||||||
|
+ pl->cur_link_an_mode, pl->cur_interface,
|
||||||
|
+ link_state.speed, link_state.duplex,
|
||||||
|
+ !!(link_state.pause & MLO_PAUSE_TX),
|
||||||
|
+ !!(link_state.pause & MLO_PAUSE_RX));
|
||||||
|
|
||||||
|
if (ndev)
|
||||||
|
netif_carrier_on(ndev);
|
||||||
|
--- a/include/linux/phylink.h
|
||||||
|
+++ b/include/linux/phylink.h
|
||||||
|
@@ -91,9 +91,10 @@ struct phylink_mac_ops {
|
||||||
|
void (*mac_an_restart)(struct phylink_config *config);
|
||||||
|
void (*mac_link_down)(struct phylink_config *config, unsigned int mode,
|
||||||
|
phy_interface_t interface);
|
||||||
|
- void (*mac_link_up)(struct phylink_config *config, unsigned int mode,
|
||||||
|
- phy_interface_t interface,
|
||||||
|
- struct phy_device *phy);
|
||||||
|
+ void (*mac_link_up)(struct phylink_config *config,
|
||||||
|
+ struct phy_device *phy, unsigned int mode,
|
||||||
|
+ phy_interface_t interface, int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause);
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 0 /* For kernel-doc purposes only. */
|
||||||
|
@@ -217,19 +218,34 @@ void mac_link_down(struct phylink_config
|
||||||
|
/**
|
||||||
|
* mac_link_up() - allow the link to come up
|
||||||
|
* @config: a pointer to a &struct phylink_config.
|
||||||
|
+ * @phy: any attached phy
|
||||||
|
* @mode: link autonegotiation mode
|
||||||
|
* @interface: link &typedef phy_interface_t mode
|
||||||
|
- * @phy: any attached phy
|
||||||
|
+ * @speed: link speed
|
||||||
|
+ * @duplex: link duplex
|
||||||
|
+ * @tx_pause: link transmit pause enablement status
|
||||||
|
+ * @rx_pause: link receive pause enablement status
|
||||||
|
*
|
||||||
|
- * If @mode is not an in-band negotiation mode (as defined by
|
||||||
|
- * phylink_autoneg_inband()), allow the link to come up. If @phy
|
||||||
|
- * is non-%NULL, configure Energy Efficient Ethernet by calling
|
||||||
|
+ * Configure the MAC for an established link.
|
||||||
|
+ *
|
||||||
|
+ * @speed, @duplex, @tx_pause and @rx_pause indicate the finalised link
|
||||||
|
+ * settings, and should be used to configure the MAC block appropriately
|
||||||
|
+ * where these settings are not automatically conveyed from the PCS block,
|
||||||
|
+ * or if in-band negotiation (as defined by phylink_autoneg_inband(@mode))
|
||||||
|
+ * is disabled.
|
||||||
|
+ *
|
||||||
|
+ * Note that when 802.3z in-band negotiation is in use, it is possible
|
||||||
|
+ * that the user wishes to override the pause settings, and this should
|
||||||
|
+ * be allowed when considering the implementation of this method.
|
||||||
|
+ *
|
||||||
|
+ * If in-band negotiation mode is disabled, allow the link to come up. If
|
||||||
|
+ * @phy is non-%NULL, configure Energy Efficient Ethernet by calling
|
||||||
|
* phy_init_eee() and perform appropriate MAC configuration for EEE.
|
||||||
|
* Interface type selection must be done in mac_config().
|
||||||
|
*/
|
||||||
|
-void mac_link_up(struct phylink_config *config, unsigned int mode,
|
||||||
|
- phy_interface_t interface,
|
||||||
|
- struct phy_device *phy);
|
||||||
|
+void mac_link_up(struct phylink_config *config, struct phy_device *phy,
|
||||||
|
+ unsigned int mode, phy_interface_t interface,
|
||||||
|
+ int speed, int duplex, bool tx_pause, bool rx_pause);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *,
|
||||||
|
--- a/net/dsa/port.c
|
||||||
|
+++ b/net/dsa/port.c
|
||||||
|
@@ -529,9 +529,11 @@ void dsa_port_phylink_mac_link_down(stru
|
||||||
|
EXPORT_SYMBOL_GPL(dsa_port_phylink_mac_link_down);
|
||||||
|
|
||||||
|
void dsa_port_phylink_mac_link_up(struct phylink_config *config,
|
||||||
|
+ struct phy_device *phydev,
|
||||||
|
unsigned int mode,
|
||||||
|
phy_interface_t interface,
|
||||||
|
- struct phy_device *phydev)
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||||
|
struct dsa_switch *ds = dp->ds;
|
|
@ -0,0 +1,143 @@
|
||||||
|
From: Russell King <rmk+kernel@armlinux.org.uk>
|
||||||
|
Date: Wed, 26 Feb 2020 10:23:46 +0000
|
||||||
|
Subject: [PATCH] net: dsa: propagate resolved link config via mac_link_up()
|
||||||
|
|
||||||
|
Propagate the resolved link configuration down via DSA's
|
||||||
|
phylink_mac_link_up() operation to allow split PCS/MAC to work.
|
||||||
|
|
||||||
|
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
|
||||||
|
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
|
||||||
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||||
|
---
|
||||||
|
|
||||||
|
--- a/drivers/net/dsa/b53/b53_common.c
|
||||||
|
+++ b/drivers/net/dsa/b53/b53_common.c
|
||||||
|
@@ -1276,7 +1276,9 @@ EXPORT_SYMBOL(b53_phylink_mac_link_down)
|
||||||
|
void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||||
|
unsigned int mode,
|
||||||
|
phy_interface_t interface,
|
||||||
|
- struct phy_device *phydev)
|
||||||
|
+ struct phy_device *phydev,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
struct b53_device *dev = ds->priv;
|
||||||
|
|
||||||
|
--- a/drivers/net/dsa/b53/b53_priv.h
|
||||||
|
+++ b/drivers/net/dsa/b53/b53_priv.h
|
||||||
|
@@ -337,7 +337,9 @@ void b53_phylink_mac_link_down(struct ds
|
||||||
|
void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||||
|
unsigned int mode,
|
||||||
|
phy_interface_t interface,
|
||||||
|
- struct phy_device *phydev);
|
||||||
|
+ struct phy_device *phydev,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause);
|
||||||
|
int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering);
|
||||||
|
int b53_vlan_prepare(struct dsa_switch *ds, int port,
|
||||||
|
const struct switchdev_obj_port_vlan *vlan);
|
||||||
|
--- a/drivers/net/dsa/bcm_sf2.c
|
||||||
|
+++ b/drivers/net/dsa/bcm_sf2.c
|
||||||
|
@@ -635,7 +635,9 @@ static void bcm_sf2_sw_mac_link_down(str
|
||||||
|
static void bcm_sf2_sw_mac_link_up(struct dsa_switch *ds, int port,
|
||||||
|
unsigned int mode,
|
||||||
|
phy_interface_t interface,
|
||||||
|
- struct phy_device *phydev)
|
||||||
|
+ struct phy_device *phydev,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
|
||||||
|
struct ethtool_eee *p = &priv->dev->ports[port].eee;
|
||||||
|
--- a/drivers/net/dsa/lantiq_gswip.c
|
||||||
|
+++ b/drivers/net/dsa/lantiq_gswip.c
|
||||||
|
@@ -1517,7 +1517,9 @@ static void gswip_phylink_mac_link_down(
|
||||||
|
static void gswip_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||||
|
unsigned int mode,
|
||||||
|
phy_interface_t interface,
|
||||||
|
- struct phy_device *phydev)
|
||||||
|
+ struct phy_device *phydev,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
struct gswip_priv *priv = ds->priv;
|
||||||
|
|
||||||
|
--- a/drivers/net/dsa/mt7530.c
|
||||||
|
+++ b/drivers/net/dsa/mt7530.c
|
||||||
|
@@ -1452,7 +1452,9 @@ static void mt7530_phylink_mac_link_down
|
||||||
|
static void mt7530_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||||
|
unsigned int mode,
|
||||||
|
phy_interface_t interface,
|
||||||
|
- struct phy_device *phydev)
|
||||||
|
+ struct phy_device *phydev,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
struct mt7530_priv *priv = ds->priv;
|
||||||
|
|
||||||
|
--- a/drivers/net/dsa/mv88e6xxx/chip.c
|
||||||
|
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
|
||||||
|
@@ -652,7 +652,9 @@ static void mv88e6xxx_mac_link_down(stru
|
||||||
|
|
||||||
|
static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
|
||||||
|
unsigned int mode, phy_interface_t interface,
|
||||||
|
- struct phy_device *phydev)
|
||||||
|
+ struct phy_device *phydev,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
if (mode == MLO_AN_FIXED)
|
||||||
|
mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
|
||||||
|
--- a/drivers/net/dsa/sja1105/sja1105_main.c
|
||||||
|
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
|
||||||
|
@@ -830,7 +830,9 @@ static void sja1105_mac_link_down(struct
|
||||||
|
static void sja1105_mac_link_up(struct dsa_switch *ds, int port,
|
||||||
|
unsigned int mode,
|
||||||
|
phy_interface_t interface,
|
||||||
|
- struct phy_device *phydev)
|
||||||
|
+ struct phy_device *phydev,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
sja1105_inhibit_tx(ds->priv, BIT(port), false);
|
||||||
|
}
|
||||||
|
--- a/include/net/dsa.h
|
||||||
|
+++ b/include/net/dsa.h
|
||||||
|
@@ -401,7 +401,9 @@ struct dsa_switch_ops {
|
||||||
|
void (*phylink_mac_link_up)(struct dsa_switch *ds, int port,
|
||||||
|
unsigned int mode,
|
||||||
|
phy_interface_t interface,
|
||||||
|
- struct phy_device *phydev);
|
||||||
|
+ struct phy_device *phydev,
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause);
|
||||||
|
void (*phylink_fixed_state)(struct dsa_switch *ds, int port,
|
||||||
|
struct phylink_link_state *state);
|
||||||
|
/*
|
||||||
|
--- a/net/dsa/port.c
|
||||||
|
+++ b/net/dsa/port.c
|
||||||
|
@@ -544,7 +544,8 @@ void dsa_port_phylink_mac_link_up(struct
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
- ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev);
|
||||||
|
+ ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev,
|
||||||
|
+ speed, duplex, tx_pause, rx_pause);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dsa_port_phylink_mac_link_up);
|
||||||
|
|
||||||
|
--- a/net/dsa/dsa_priv.h
|
||||||
|
+++ b/net/dsa/dsa_priv.h
|
||||||
|
@@ -180,9 +180,11 @@ void dsa_port_phylink_mac_link_down(stru
|
||||||
|
unsigned int mode,
|
||||||
|
phy_interface_t interface);
|
||||||
|
void dsa_port_phylink_mac_link_up(struct phylink_config *config,
|
||||||
|
+ struct phy_device *phydev,
|
||||||
|
unsigned int mode,
|
||||||
|
phy_interface_t interface,
|
||||||
|
- struct phy_device *phydev);
|
||||||
|
+ int speed, int duplex,
|
||||||
|
+ bool tx_pause, bool rx_pause);
|
||||||
|
extern const struct phylink_mac_ops dsa_port_phylink_mac_ops;
|
||||||
|
|
||||||
|
/* slave.c */
|
|
@ -0,0 +1,145 @@
|
||||||
|
From: =?UTF-8?q?Ren=C3=A9=20van=20Dorst?= <opensource@vdorst.com>
|
||||||
|
Date: Fri, 27 Mar 2020 15:44:12 +0100
|
||||||
|
Subject: [PATCH] net: dsa: mt7530: use resolved link config in mac_link_up()
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Convert the mt7530 switch driver to use the finalised link
|
||||||
|
parameters in mac_link_up() rather than the parameters in mac_config().
|
||||||
|
|
||||||
|
Signed-off-by: René van Dorst <opensource@vdorst.com>
|
||||||
|
Tested-by: Sean Wang <sean.wang@mediatek.com>
|
||||||
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||||
|
---
|
||||||
|
|
||||||
|
--- a/drivers/net/dsa/mt7530.c
|
||||||
|
+++ b/drivers/net/dsa/mt7530.c
|
||||||
|
@@ -490,17 +490,6 @@ mt7530_mib_reset(struct dsa_switch *ds)
|
||||||
|
mt7530_write(priv, MT7530_MIB_CCR, CCR_MIB_ACTIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void
|
||||||
|
-mt7530_port_set_status(struct mt7530_priv *priv, int port, int enable)
|
||||||
|
-{
|
||||||
|
- u32 mask = PMCR_TX_EN | PMCR_RX_EN | PMCR_FORCE_LNK;
|
||||||
|
-
|
||||||
|
- if (enable)
|
||||||
|
- mt7530_set(priv, MT7530_PMCR_P(port), mask);
|
||||||
|
- else
|
||||||
|
- mt7530_clear(priv, MT7530_PMCR_P(port), mask);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static int mt7530_phy_read(struct dsa_switch *ds, int port, int regnum)
|
||||||
|
{
|
||||||
|
struct mt7530_priv *priv = ds->priv;
|
||||||
|
@@ -674,7 +663,7 @@ mt7530_port_enable(struct dsa_switch *ds
|
||||||
|
priv->ports[port].enable = true;
|
||||||
|
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
|
||||||
|
priv->ports[port].pm);
|
||||||
|
- mt7530_port_set_status(priv, port, 0);
|
||||||
|
+ mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
|
||||||
|
|
||||||
|
mutex_unlock(&priv->reg_mutex);
|
||||||
|
|
||||||
|
@@ -697,7 +686,7 @@ mt7530_port_disable(struct dsa_switch *d
|
||||||
|
priv->ports[port].enable = false;
|
||||||
|
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
|
||||||
|
PCR_MATRIX_CLR);
|
||||||
|
- mt7530_port_set_status(priv, port, 0);
|
||||||
|
+ mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
|
||||||
|
|
||||||
|
mutex_unlock(&priv->reg_mutex);
|
||||||
|
}
|
||||||
|
@@ -1407,8 +1396,7 @@ static void mt7530_phylink_mac_config(st
|
||||||
|
|
||||||
|
mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port));
|
||||||
|
mcr_new = mcr_cur;
|
||||||
|
- mcr_new &= ~(PMCR_FORCE_SPEED_1000 | PMCR_FORCE_SPEED_100 |
|
||||||
|
- PMCR_FORCE_FDX | PMCR_TX_FC_EN | PMCR_RX_FC_EN);
|
||||||
|
+ mcr_new &= ~PMCR_LINK_SETTINGS_MASK;
|
||||||
|
mcr_new |= PMCR_IFG_XMIT(1) | PMCR_MAC_MODE | PMCR_BACKOFF_EN |
|
||||||
|
PMCR_BACKPR_EN | PMCR_FORCE_MODE;
|
||||||
|
|
||||||
|
@@ -1416,26 +1404,6 @@ static void mt7530_phylink_mac_config(st
|
||||||
|
if (port == 5 && dsa_is_user_port(ds, 5))
|
||||||
|
mcr_new |= PMCR_EXT_PHY;
|
||||||
|
|
||||||
|
- switch (state->speed) {
|
||||||
|
- case SPEED_1000:
|
||||||
|
- mcr_new |= PMCR_FORCE_SPEED_1000;
|
||||||
|
- if (priv->eee_enable & BIT(port))
|
||||||
|
- mcr_new |= PMCR_FORCE_EEE1G;
|
||||||
|
- break;
|
||||||
|
- case SPEED_100:
|
||||||
|
- mcr_new |= PMCR_FORCE_SPEED_100;
|
||||||
|
- if (priv->eee_enable & BIT(port))
|
||||||
|
- mcr_new |= PMCR_FORCE_EEE100;
|
||||||
|
- break;
|
||||||
|
- }
|
||||||
|
- if (state->duplex == DUPLEX_FULL) {
|
||||||
|
- mcr_new |= PMCR_FORCE_FDX;
|
||||||
|
- if (state->pause & MLO_PAUSE_TX)
|
||||||
|
- mcr_new |= PMCR_TX_FC_EN;
|
||||||
|
- if (state->pause & MLO_PAUSE_RX)
|
||||||
|
- mcr_new |= PMCR_RX_FC_EN;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
if (mcr_new != mcr_cur)
|
||||||
|
mt7530_write(priv, MT7530_PMCR_P(port), mcr_new);
|
||||||
|
}
|
||||||
|
@@ -1446,7 +1414,7 @@ static void mt7530_phylink_mac_link_down
|
||||||
|
{
|
||||||
|
struct mt7530_priv *priv = ds->priv;
|
||||||
|
|
||||||
|
- mt7530_port_set_status(priv, port, 0);
|
||||||
|
+ mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mt7530_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||||
|
@@ -1457,8 +1425,31 @@ static void mt7530_phylink_mac_link_up(s
|
||||||
|
bool tx_pause, bool rx_pause)
|
||||||
|
{
|
||||||
|
struct mt7530_priv *priv = ds->priv;
|
||||||
|
+ u32 mcr;
|
||||||
|
|
||||||
|
- mt7530_port_set_status(priv, port, 1);
|
||||||
|
+ mcr = PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK;
|
||||||
|
+
|
||||||
|
+ switch (speed) {
|
||||||
|
+ case SPEED_1000:
|
||||||
|
+ mcr |= PMCR_FORCE_SPEED_1000;
|
||||||
|
+ if (priv->eee_enable & BIT(port))
|
||||||
|
+ mcr_new |= PMCR_FORCE_EEE1G;
|
||||||
|
+ break;
|
||||||
|
+ case SPEED_100:
|
||||||
|
+ mcr |= PMCR_FORCE_SPEED_100;
|
||||||
|
+ if (priv->eee_enable & BIT(port))
|
||||||
|
+ mcr_new |= PMCR_FORCE_EEE100;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ if (duplex == DUPLEX_FULL) {
|
||||||
|
+ mcr |= PMCR_FORCE_FDX;
|
||||||
|
+ if (tx_pause)
|
||||||
|
+ mcr |= PMCR_TX_FC_EN;
|
||||||
|
+ if (rx_pause)
|
||||||
|
+ mcr |= PMCR_RX_FC_EN;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ mt7530_set(priv, MT7530_PMCR_P(port), mcr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mt7530_phylink_validate(struct dsa_switch *ds, int port,
|
||||||
|
--- a/drivers/net/dsa/mt7530.h
|
||||||
|
+++ b/drivers/net/dsa/mt7530.h
|
||||||
|
@@ -222,6 +222,10 @@ enum mt7530_vlan_port_attr {
|
||||||
|
#define PMCR_FORCE_LNK BIT(0)
|
||||||
|
#define PMCR_SPEED_MASK (PMCR_FORCE_SPEED_100 | \
|
||||||
|
PMCR_FORCE_SPEED_1000)
|
||||||
|
+#define PMCR_LINK_SETTINGS_MASK (PMCR_TX_EN | PMCR_FORCE_SPEED_1000 | \
|
||||||
|
+ PMCR_RX_EN | PMCR_FORCE_SPEED_100 | \
|
||||||
|
+ PMCR_TX_FC_EN | PMCR_RX_FC_EN | \
|
||||||
|
+ PMCR_FORCE_FDX | PMCR_FORCE_LNK)
|
||||||
|
|
||||||
|
#define MT7530_PMSR_P(x) (0x3008 + (x) * 0x100)
|
||||||
|
#define PMSR_EEE1G BIT(7)
|
|
@ -0,0 +1,458 @@
|
||||||
|
From: Landen Chao <landen.chao@mediatek.com>
|
||||||
|
Date: Fri, 4 Sep 2020 22:21:57 +0800
|
||||||
|
Subject: [PATCH] net: dsa: mt7530: Extend device data ready for adding a
|
||||||
|
new hardware
|
||||||
|
|
||||||
|
Add a structure holding required operations for each device such as device
|
||||||
|
initialization, PHY port read or write, a checker whether PHY interface is
|
||||||
|
supported on a certain port, MAC port setup for either bus pad or a
|
||||||
|
specific PHY interface.
|
||||||
|
|
||||||
|
The patch is done for ready adding a new hardware MT7531, and keep the
|
||||||
|
same setup logic of existing hardware.
|
||||||
|
|
||||||
|
Signed-off-by: Landen Chao <landen.chao@mediatek.com>
|
||||||
|
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
|
||||||
|
---
|
||||||
|
|
||||||
|
--- a/drivers/net/dsa/mt7530.c
|
||||||
|
+++ b/drivers/net/dsa/mt7530.c
|
||||||
|
@@ -372,8 +372,9 @@ mt7530_fdb_write(struct mt7530_priv *pri
|
||||||
|
mt7530_write(priv, MT7530_ATA1 + (i * 4), reg[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* Setup TX circuit including relevant PAD and driving */
|
||||||
|
static int
|
||||||
|
-mt7530_pad_clk_setup(struct dsa_switch *ds, int mode)
|
||||||
|
+mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
|
||||||
|
{
|
||||||
|
struct mt7530_priv *priv = ds->priv;
|
||||||
|
u32 ncpo1, ssc_delta, trgint, i, xtal;
|
||||||
|
@@ -387,7 +388,7 @@ mt7530_pad_clk_setup(struct dsa_switch *
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
- switch (mode) {
|
||||||
|
+ switch (interface) {
|
||||||
|
case PHY_INTERFACE_MODE_RGMII:
|
||||||
|
trgint = 0;
|
||||||
|
/* PLL frequency: 125MHz */
|
||||||
|
@@ -409,7 +410,8 @@ mt7530_pad_clk_setup(struct dsa_switch *
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
- dev_err(priv->dev, "xMII mode %d not supported\n", mode);
|
||||||
|
+ dev_err(priv->dev, "xMII interface %d not supported\n",
|
||||||
|
+ interface);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1344,12 +1346,11 @@ mt7530_setup(struct dsa_switch *ds)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void mt7530_phylink_mac_config(struct dsa_switch *ds, int port,
|
||||||
|
- unsigned int mode,
|
||||||
|
- const struct phylink_link_state *state)
|
||||||
|
+static bool
|
||||||
|
+mt7530_phy_mode_supported(struct dsa_switch *ds, int port,
|
||||||
|
+ const struct phylink_link_state *state)
|
||||||
|
{
|
||||||
|
struct mt7530_priv *priv = ds->priv;
|
||||||
|
- u32 mcr_cur, mcr_new;
|
||||||
|
|
||||||
|
switch (port) {
|
||||||
|
case 0: /* Internal phy */
|
||||||
|
@@ -1358,33 +1359,114 @@ static void mt7530_phylink_mac_config(st
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
if (state->interface != PHY_INTERFACE_MODE_GMII)
|
||||||
|
- return;
|
||||||
|
+ goto unsupported;
|
||||||
|
break;
|
||||||
|
case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
|
||||||
|
- if (priv->p5_interface == state->interface)
|
||||||
|
- break;
|
||||||
|
if (!phy_interface_mode_is_rgmii(state->interface) &&
|
||||||
|
state->interface != PHY_INTERFACE_MODE_MII &&
|
||||||
|
state->interface != PHY_INTERFACE_MODE_GMII)
|
||||||
|
- return;
|
||||||
|
+ goto unsupported;
|
||||||
|
+ break;
|
||||||
|
+ case 6: /* 1st cpu port */
|
||||||
|
+ if (state->interface != PHY_INTERFACE_MODE_RGMII &&
|
||||||
|
+ state->interface != PHY_INTERFACE_MODE_TRGMII)
|
||||||
|
+ goto unsupported;
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ dev_err(priv->dev, "%s: unsupported port: %i\n", __func__,
|
||||||
|
+ port);
|
||||||
|
+ goto unsupported;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return true;
|
||||||
|
+
|
||||||
|
+unsupported:
|
||||||
|
+ return false;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static bool
|
||||||
|
+mt753x_phy_mode_supported(struct dsa_switch *ds, int port,
|
||||||
|
+ const struct phylink_link_state *state)
|
||||||
|
+{
|
||||||
|
+ struct mt7530_priv *priv = ds->priv;
|
||||||
|
+
|
||||||
|
+ return priv->info->phy_mode_supported(ds, port, state);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+mt753x_pad_setup(struct dsa_switch *ds, const struct phylink_link_state *state)
|
||||||
|
+{
|
||||||
|
+ struct mt7530_priv *priv = ds->priv;
|
||||||
|
+
|
||||||
|
+ return priv->info->pad_setup(ds, state->interface);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||||
|
+ phy_interface_t interface)
|
||||||
|
+{
|
||||||
|
+ struct mt7530_priv *priv = ds->priv;
|
||||||
|
+
|
||||||
|
+ /* Only need to setup port5. */
|
||||||
|
+ if (port != 5)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ mt7530_setup_port5(priv->ds, interface);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+mt753x_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||||
|
+ const struct phylink_link_state *state)
|
||||||
|
+{
|
||||||
|
+ struct mt7530_priv *priv = ds->priv;
|
||||||
|
+
|
||||||
|
+ return priv->info->mac_port_config(ds, port, mode, state->interface);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||||
|
+ const struct phylink_link_state *state)
|
||||||
|
+{
|
||||||
|
+ struct mt7530_priv *priv = ds->priv;
|
||||||
|
+ u32 mcr_cur, mcr_new;
|
||||||
|
+
|
||||||
|
+ if (!mt753x_phy_mode_supported(ds, port, state))
|
||||||
|
+ goto unsupported;
|
||||||
|
+
|
||||||
|
+ switch (port) {
|
||||||
|
+ case 0: /* Internal phy */
|
||||||
|
+ case 1:
|
||||||
|
+ case 2:
|
||||||
|
+ case 3:
|
||||||
|
+ case 4:
|
||||||
|
+ if (state->interface != PHY_INTERFACE_MODE_GMII)
|
||||||
|
+ goto unsupported;
|
||||||
|
+ break;
|
||||||
|
+ case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
|
||||||
|
+ if (priv->p5_interface == state->interface)
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ if (mt753x_mac_config(ds, port, mode, state) < 0)
|
||||||
|
+ goto unsupported;
|
||||||
|
|
||||||
|
- mt7530_setup_port5(ds, state->interface);
|
||||||
|
break;
|
||||||
|
case 6: /* 1st cpu port */
|
||||||
|
if (priv->p6_interface == state->interface)
|
||||||
|
break;
|
||||||
|
|
||||||
|
- if (state->interface != PHY_INTERFACE_MODE_RGMII &&
|
||||||
|
- state->interface != PHY_INTERFACE_MODE_TRGMII)
|
||||||
|
- return;
|
||||||
|
+ mt753x_pad_setup(ds, state);
|
||||||
|
|
||||||
|
- /* Setup TX circuit incluing relevant PAD and driving */
|
||||||
|
- mt7530_pad_clk_setup(ds, state->interface);
|
||||||
|
+ if (mt753x_mac_config(ds, port, mode, state) < 0)
|
||||||
|
+ goto unsupported;
|
||||||
|
|
||||||
|
priv->p6_interface = state->interface;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
- dev_err(ds->dev, "%s: unsupported port: %i\n", __func__, port);
|
||||||
|
+unsupported:
|
||||||
|
+ dev_err(ds->dev, "%s: unsupported %s port: %i\n",
|
||||||
|
+ __func__, phy_modes(state->interface), port);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1452,61 +1534,44 @@ static void mt7530_phylink_mac_link_up(s
|
||||||
|
mt7530_set(priv, MT7530_PMCR_P(port), mcr);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void mt7530_phylink_validate(struct dsa_switch *ds, int port,
|
||||||
|
- unsigned long *supported,
|
||||||
|
- struct phylink_link_state *state)
|
||||||
|
+static void
|
||||||
|
+mt7530_mac_port_validate(struct dsa_switch *ds, int port,
|
||||||
|
+ unsigned long *supported)
|
||||||
|
{
|
||||||
|
+ if (port == 5)
|
||||||
|
+ phylink_set(supported, 1000baseX_Full);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+mt753x_phylink_validate(struct dsa_switch *ds, int port,
|
||||||
|
+ unsigned long *supported,
|
||||||
|
+ struct phylink_link_state *state)
|
||||||
|
+{
|
||||||
|
+ struct mt7530_priv *priv = ds->priv;
|
||||||
|
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
|
||||||
|
|
||||||
|
- switch (port) {
|
||||||
|
- case 0: /* Internal phy */
|
||||||
|
- case 1:
|
||||||
|
- case 2:
|
||||||
|
- case 3:
|
||||||
|
- case 4:
|
||||||
|
- if (state->interface != PHY_INTERFACE_MODE_NA &&
|
||||||
|
- state->interface != PHY_INTERFACE_MODE_GMII)
|
||||||
|
- goto unsupported;
|
||||||
|
- break;
|
||||||
|
- case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
|
||||||
|
- if (state->interface != PHY_INTERFACE_MODE_NA &&
|
||||||
|
- !phy_interface_mode_is_rgmii(state->interface) &&
|
||||||
|
- state->interface != PHY_INTERFACE_MODE_MII &&
|
||||||
|
- state->interface != PHY_INTERFACE_MODE_GMII)
|
||||||
|
- goto unsupported;
|
||||||
|
- break;
|
||||||
|
- case 6: /* 1st cpu port */
|
||||||
|
- if (state->interface != PHY_INTERFACE_MODE_NA &&
|
||||||
|
- state->interface != PHY_INTERFACE_MODE_RGMII &&
|
||||||
|
- state->interface != PHY_INTERFACE_MODE_TRGMII)
|
||||||
|
- goto unsupported;
|
||||||
|
- break;
|
||||||
|
- default:
|
||||||
|
- dev_err(ds->dev, "%s: unsupported port: %i\n", __func__, port);
|
||||||
|
-unsupported:
|
||||||
|
+ if (state->interface != PHY_INTERFACE_MODE_NA &&
|
||||||
|
+ !mt753x_phy_mode_supported(ds, port, state)) {
|
||||||
|
linkmode_zero(supported);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
phylink_set_port_modes(mask);
|
||||||
|
- phylink_set(mask, Autoneg);
|
||||||
|
|
||||||
|
- if (state->interface == PHY_INTERFACE_MODE_TRGMII) {
|
||||||
|
- phylink_set(mask, 1000baseT_Full);
|
||||||
|
- } else {
|
||||||
|
+ if (state->interface != PHY_INTERFACE_MODE_TRGMII) {
|
||||||
|
phylink_set(mask, 10baseT_Half);
|
||||||
|
phylink_set(mask, 10baseT_Full);
|
||||||
|
phylink_set(mask, 100baseT_Half);
|
||||||
|
phylink_set(mask, 100baseT_Full);
|
||||||
|
-
|
||||||
|
- if (state->interface != PHY_INTERFACE_MODE_MII) {
|
||||||
|
- phylink_set(mask, 1000baseT_Half);
|
||||||
|
- phylink_set(mask, 1000baseT_Full);
|
||||||
|
- if (port == 5)
|
||||||
|
- phylink_set(mask, 1000baseX_Full);
|
||||||
|
- }
|
||||||
|
+ phylink_set(mask, Autoneg);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* This switch only supports 1G full-duplex. */
|
||||||
|
+ if (state->interface != PHY_INTERFACE_MODE_MII)
|
||||||
|
+ phylink_set(mask, 1000baseT_Full);
|
||||||
|
+
|
||||||
|
+ priv->info->mac_port_validate(ds, port, mask);
|
||||||
|
+
|
||||||
|
phylink_set(mask, Pause);
|
||||||
|
phylink_set(mask, Asym_Pause);
|
||||||
|
|
||||||
|
@@ -1602,12 +1667,45 @@ static int mt7530_set_mac_eee(struct dsa
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int
|
||||||
|
+mt753x_phylink_mac_link_state(struct dsa_switch *ds, int port,
|
||||||
|
+ struct phylink_link_state *state)
|
||||||
|
+{
|
||||||
|
+ struct mt7530_priv *priv = ds->priv;
|
||||||
|
+
|
||||||
|
+ return priv->info->mac_port_get_state(ds, port, state);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+mt753x_setup(struct dsa_switch *ds)
|
||||||
|
+{
|
||||||
|
+ struct mt7530_priv *priv = ds->priv;
|
||||||
|
+
|
||||||
|
+ return priv->info->sw_setup(ds);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+mt753x_phy_read(struct dsa_switch *ds, int port, int regnum)
|
||||||
|
+{
|
||||||
|
+ struct mt7530_priv *priv = ds->priv;
|
||||||
|
+
|
||||||
|
+ return priv->info->phy_read(ds, port, regnum);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+mt753x_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
|
||||||
|
+{
|
||||||
|
+ struct mt7530_priv *priv = ds->priv;
|
||||||
|
+
|
||||||
|
+ return priv->info->phy_write(ds, port, regnum, val);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static const struct dsa_switch_ops mt7530_switch_ops = {
|
||||||
|
.get_tag_protocol = mtk_get_tag_protocol,
|
||||||
|
- .setup = mt7530_setup,
|
||||||
|
+ .setup = mt753x_setup,
|
||||||
|
.get_strings = mt7530_get_strings,
|
||||||
|
- .phy_read = mt7530_phy_read,
|
||||||
|
- .phy_write = mt7530_phy_write,
|
||||||
|
+ .phy_read = mt753x_phy_read,
|
||||||
|
+ .phy_write = mt753x_phy_write,
|
||||||
|
.get_ethtool_stats = mt7530_get_ethtool_stats,
|
||||||
|
.get_sset_count = mt7530_get_sset_count,
|
||||||
|
.port_enable = mt7530_port_enable,
|
||||||
|
@@ -1624,18 +1722,43 @@ static const struct dsa_switch_ops mt753
|
||||||
|
.port_vlan_del = mt7530_port_vlan_del,
|
||||||
|
.port_mirror_add = mt7530_port_mirror_add,
|
||||||
|
.port_mirror_del = mt7530_port_mirror_del,
|
||||||
|
- .phylink_validate = mt7530_phylink_validate,
|
||||||
|
- .phylink_mac_link_state = mt7530_phylink_mac_link_state,
|
||||||
|
- .phylink_mac_config = mt7530_phylink_mac_config,
|
||||||
|
+ .phylink_validate = mt753x_phylink_validate,
|
||||||
|
+ .phylink_mac_link_state = mt753x_phylink_mac_link_state,
|
||||||
|
+ .phylink_mac_config = mt753x_phylink_mac_config,
|
||||||
|
.phylink_mac_link_down = mt7530_phylink_mac_link_down,
|
||||||
|
.phylink_mac_link_up = mt7530_phylink_mac_link_up,
|
||||||
|
.get_mac_eee = mt7530_get_mac_eee,
|
||||||
|
.set_mac_eee = mt7530_set_mac_eee,
|
||||||
|
};
|
||||||
|
|
||||||
|
+static const struct mt753x_info mt753x_table[] = {
|
||||||
|
+ [ID_MT7621] = {
|
||||||
|
+ .id = ID_MT7621,
|
||||||
|
+ .sw_setup = mt7530_setup,
|
||||||
|
+ .phy_read = mt7530_phy_read,
|
||||||
|
+ .phy_write = mt7530_phy_write,
|
||||||
|
+ .pad_setup = mt7530_pad_clk_setup,
|
||||||
|
+ .phy_mode_supported = mt7530_phy_mode_supported,
|
||||||
|
+ .mac_port_validate = mt7530_mac_port_validate,
|
||||||
|
+ .mac_port_get_state = mt7530_phylink_mac_link_state,
|
||||||
|
+ .mac_port_config = mt7530_mac_config,
|
||||||
|
+ },
|
||||||
|
+ [ID_MT7530] = {
|
||||||
|
+ .id = ID_MT7530,
|
||||||
|
+ .sw_setup = mt7530_setup,
|
||||||
|
+ .phy_read = mt7530_phy_read,
|
||||||
|
+ .phy_write = mt7530_phy_write,
|
||||||
|
+ .pad_setup = mt7530_pad_clk_setup,
|
||||||
|
+ .phy_mode_supported = mt7530_phy_mode_supported,
|
||||||
|
+ .mac_port_validate = mt7530_mac_port_validate,
|
||||||
|
+ .mac_port_get_state = mt7530_phylink_mac_link_state,
|
||||||
|
+ .mac_port_config = mt7530_mac_config,
|
||||||
|
+ },
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
static const struct of_device_id mt7530_of_match[] = {
|
||||||
|
- { .compatible = "mediatek,mt7621", .data = (void *)ID_MT7621, },
|
||||||
|
- { .compatible = "mediatek,mt7530", .data = (void *)ID_MT7530, },
|
||||||
|
+ { .compatible = "mediatek,mt7621", .data = &mt753x_table[ID_MT7621], },
|
||||||
|
+ { .compatible = "mediatek,mt7530", .data = &mt753x_table[ID_MT7530], },
|
||||||
|
{ /* sentinel */ },
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, mt7530_of_match);
|
||||||
|
@@ -1673,8 +1796,21 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||||
|
/* Get the hardware identifier from the devicetree node.
|
||||||
|
* We will need it for some of the clock and regulator setup.
|
||||||
|
*/
|
||||||
|
- priv->id = (unsigned int)(unsigned long)
|
||||||
|
- of_device_get_match_data(&mdiodev->dev);
|
||||||
|
+ priv->info = of_device_get_match_data(&mdiodev->dev);
|
||||||
|
+ if (!priv->info)
|
||||||
|
+ return -EINVAL;
|
||||||
|
+
|
||||||
|
+ /* Sanity check if these required device operations are filled
|
||||||
|
+ * properly.
|
||||||
|
+ */
|
||||||
|
+ if (!priv->info->sw_setup || !priv->info->pad_setup ||
|
||||||
|
+ !priv->info->phy_read || !priv->info->phy_write ||
|
||||||
|
+ !priv->info->phy_mode_supported ||
|
||||||
|
+ !priv->info->mac_port_validate ||
|
||||||
|
+ !priv->info->mac_port_get_state || !priv->info->mac_port_config)
|
||||||
|
+ return -EINVAL;
|
||||||
|
+
|
||||||
|
+ priv->id = priv->info->id;
|
||||||
|
|
||||||
|
if (priv->id == ID_MT7530) {
|
||||||
|
priv->core_pwr = devm_regulator_get(&mdiodev->dev, "core");
|
||||||
|
--- a/drivers/net/dsa/mt7530.h
|
||||||
|
+++ b/drivers/net/dsa/mt7530.h
|
||||||
|
@@ -11,7 +11,7 @@
|
||||||
|
#define MT7530_NUM_FDB_RECORDS 2048
|
||||||
|
#define MT7530_ALL_MEMBERS 0xff
|
||||||
|
|
||||||
|
-enum {
|
||||||
|
+enum mt753x_id {
|
||||||
|
ID_MT7530 = 0,
|
||||||
|
ID_MT7621 = 1,
|
||||||
|
};
|
||||||
|
@@ -451,6 +451,40 @@ static const char *p5_intf_modes(unsigne
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* struct mt753x_info - This is the main data structure for holding the specific
|
||||||
|
+ * part for each supported device
|
||||||
|
+ * @sw_setup: Holding the handler to a device initialization
|
||||||
|
+ * @phy_read: Holding the way reading PHY port
|
||||||
|
+ * @phy_write: Holding the way writing PHY port
|
||||||
|
+ * @pad_setup: Holding the way setting up the bus pad for a certain
|
||||||
|
+ * MAC port
|
||||||
|
+ * @phy_mode_supported: Check if the PHY type is being supported on a certain
|
||||||
|
+ * port
|
||||||
|
+ * @mac_port_validate: Holding the way to set addition validate type for a
|
||||||
|
+ * certan MAC port
|
||||||
|
+ * @mac_port_get_state: Holding the way getting the MAC/PCS state for a certain
|
||||||
|
+ * MAC port
|
||||||
|
+ * @mac_port_config: Holding the way setting up the PHY attribute to a
|
||||||
|
+ * certain MAC port
|
||||||
|
+ */
|
||||||
|
+struct mt753x_info {
|
||||||
|
+ enum mt753x_id id;
|
||||||
|
+
|
||||||
|
+ int (*sw_setup)(struct dsa_switch *ds);
|
||||||
|
+ int (*phy_read)(struct dsa_switch *ds, int port, int regnum);
|
||||||
|
+ int (*phy_write)(struct dsa_switch *ds, int port, int regnum, u16 val);
|
||||||
|
+ int (*pad_setup)(struct dsa_switch *ds, phy_interface_t interface);
|
||||||
|
+ bool (*phy_mode_supported)(struct dsa_switch *ds, int port,
|
||||||
|
+ const struct phylink_link_state *state);
|
||||||
|
+ void (*mac_port_validate)(struct dsa_switch *ds, int port,
|
||||||
|
+ unsigned long *supported);
|
||||||
|
+ int (*mac_port_get_state)(struct dsa_switch *ds, int port,
|
||||||
|
+ struct phylink_link_state *state);
|
||||||
|
+ int (*mac_port_config)(struct dsa_switch *ds, int port,
|
||||||
|
+ unsigned int mode,
|
||||||
|
+ phy_interface_t interface);
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
/* struct mt7530_priv - This is the main data structure for holding the state
|
||||||
|
* of the driver
|
||||||
|
* @dev: The device pointer
|
||||||
|
@@ -476,6 +510,7 @@ struct mt7530_priv {
|
||||||
|
struct regulator *core_pwr;
|
||||||
|
struct regulator *io_pwr;
|
||||||
|
struct gpio_desc *reset;
|
||||||
|
+ const struct mt753x_info *info;
|
||||||
|
unsigned int id;
|
||||||
|
bool mcm;
|
||||||
|
phy_interface_t p6_interface;
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,71 @@
|
||||||
|
From: Landen Chao <landen.chao@mediatek.com>
|
||||||
|
Subject: [PATCH net-next 6/6] arm64: dts: mt7622: add mt7531 dsa to
|
||||||
|
bananapi-bpi-r64 board
|
||||||
|
Date: Tue, 10 Dec 2019 16:14:42 +0800
|
||||||
|
|
||||||
|
Add mt7531 dsa to bananapi-bpi-r64 board for 5 giga Ethernet ports support.
|
||||||
|
|
||||||
|
Signed-off-by: Landen Chao <landen.chao@mediatek.com>
|
||||||
|
---
|
||||||
|
.../dts/mediatek/mt7622-bananapi-bpi-r64.dts | 50 +++++++++++++++++++
|
||||||
|
1 file changed, 50 insertions(+)
|
||||||
|
|
||||||
|
--- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||||
|
+++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||||
|
@@ -150,6 +150,56 @@
|
||||||
|
mdio: mdio-bus {
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <0>;
|
||||||
|
+
|
||||||
|
+ switch@0 {
|
||||||
|
+ compatible = "mediatek,mt7531";
|
||||||
|
+ reg = <0>;
|
||||||
|
+ reset-gpios = <&pio 54 0>;
|
||||||
|
+
|
||||||
|
+ ports {
|
||||||
|
+ #address-cells = <1>;
|
||||||
|
+ #size-cells = <0>;
|
||||||
|
+
|
||||||
|
+ port@0 {
|
||||||
|
+ reg = <0>;
|
||||||
|
+ label = "wan";
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ port@1 {
|
||||||
|
+ reg = <1>;
|
||||||
|
+ label = "lan0";
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ port@2 {
|
||||||
|
+ reg = <2>;
|
||||||
|
+ label = "lan1";
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ port@3 {
|
||||||
|
+ reg = <3>;
|
||||||
|
+ label = "lan2";
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ port@4 {
|
||||||
|
+ reg = <4>;
|
||||||
|
+ label = "lan3";
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ port@6 {
|
||||||
|
+ reg = <6>;
|
||||||
|
+ label = "cpu";
|
||||||
|
+ ethernet = <&gmac0>;
|
||||||
|
+ phy-mode = "2500base-x";
|
||||||
|
+
|
||||||
|
+ fixed-link {
|
||||||
|
+ speed = <2500>;
|
||||||
|
+ full-duplex;
|
||||||
|
+ pause;
|
||||||
|
+ };
|
||||||
|
+ };
|
||||||
|
+ };
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue