From patchwork Tue Dec 11 19:33:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 10724565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00A4013BF for ; Tue, 11 Dec 2018 19:34:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3D392ADA3 for ; Tue, 11 Dec 2018 19:34:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D86D62B454; Tue, 11 Dec 2018 19:34:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7854C2ADA3 for ; Tue, 11 Dec 2018 19:34:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=syxVIWMvp4oGiyc1W9EKtNA4Y080RXjMrGXxN7yQrvw=; b=WiL8fBSHngXpkIfkPKRJO+nsUN emASanUqnpe3R7snYFembJdtZnFCwxdECsKWddlaMO1nWJInL2Z8V6KvIGoWzBjxTx/AaQWh7RBTX 0MJ/61jfRt5Mb/W32CtTvoInIIZdhh0RrfVU98u0S+P/MpIip6GUkD+YBA1RB0C5uSZ0JmzZCYgjs 6LgE/4EQl5mehe4sfynAc6hXh52A3eCPb5FkaWxLcaXHUiIAFHrYKAe/QjiBF2SJfkQD8CqGnkBk6 HL5UZQHBK1Ir34L9ir3pFxxw0B5m8LTnF1vHiLTN4tvWfmI0gMOFGi66+Qd2eoVQTfW893j0V50eV fNArEMRw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWnnl-0000zV-Ff; Tue, 11 Dec 2018 19:34:41 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWnnH-0000Rb-5K; Tue, 11 Dec 2018 19:34:14 +0000 Received: from localhost.localdomain ([91.14.83.44]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MIMQR-1gawO50CBr-004BML; Tue, 11 Dec 2018 20:33:38 +0100 From: Frank Wunderlich To: Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 5/7] [DSA] dsa multi cpu (mt7530.c) Date: Tue, 11 Dec 2018 20:33:12 +0100 Message-Id: <20181211193314.10695-5-frank-w@public-files.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181211193314.10695-1-frank-w@public-files.de> References: <20181211193314.10695-1-frank-w@public-files.de> X-Provags-ID: V03:K1:5uvOk/q14HGD/2jzna7B3U2QGMeJRss93L6l5tAEsPqt/qo3/Hw t7VaXEHRIIA7NMGwrxTwhiX8YWX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QAC2IuOqMoY Mz++mS1aqOoBenLrkpwvAXGNisUufN5V/UTbR8pTLCA1txg9tPcYzkXXhsYGB4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181211_113411_500431_05EBE3ED X-CRM114-Status: GOOD ( 12.30 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Frank Wunderlich MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP based on https://github.com/openwrt/openwrt/blob/master/target/linux/mediatek/patches-4.14/0033-dsa-multi-cpu.patch Signed-off-by: Frank Wunderlich --- drivers/net/dsa/mt7530.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index a6a15a063e3e..441320d4d779 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -674,6 +674,9 @@ static int mt7530_cpu_port_enable(struct mt7530_priv *priv, int port) { + u8 port_mask = 0; + int i; + /* Enable Mediatek header mode on the cpu port */ mt7530_write(priv, MT7530_PVC_P(port), PORT_SPEC_TAG); @@ -690,8 +693,14 @@ mt7530_cpu_port_enable(struct mt7530_priv *priv, /* CPU port gets connected to all user ports of * the switch */ + + for (i = 0; i < MT7530_NUM_PORTS; i++) + if ((priv->ds->ports[port].type == DSA_PORT_TYPE_USER) && + (dsa_port_upstream_port(priv->ds, i) == port)) + port_mask |= BIT(i); + mt7530_write(priv, MT7530_PCR_P(port), - PCR_MATRIX(dsa_user_ports(priv->ds))); + PCR_MATRIX(port_mask)); return 0; } @@ -701,6 +710,7 @@ mt7530_port_enable(struct dsa_switch *ds, int port, struct phy_device *phy) { struct mt7530_priv *priv = ds->priv; + u8 upstream = dsa_port_upstream_port(ds, port); mutex_lock(&priv->reg_mutex); @@ -711,7 +721,7 @@ mt7530_port_enable(struct dsa_switch *ds, int port, * restore the port matrix if the port is the member of a certain * bridge. */ - priv->ports[port].pm |= PCR_MATRIX(BIT(MT7530_CPU_PORT)); + priv->ports[port].pm |= PCR_MATRIX(BIT(upstream)); priv->ports[port].enable = true; mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, priv->ports[port].pm); @@ -774,7 +784,8 @@ mt7530_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *bridge) { struct mt7530_priv *priv = ds->priv; - u32 port_bitmap = BIT(MT7530_CPU_PORT); + u8 upstream = dsa_port_upstream_port(ds, port); + u32 port_bitmap = BIT(upstream); int i; mutex_lock(&priv->reg_mutex); @@ -875,6 +886,7 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port, struct net_device *bridge) { struct mt7530_priv *priv = ds->priv; + u8 upstream = dsa_port_upstream_port(ds, port); int i; mutex_lock(&priv->reg_mutex); @@ -902,8 +914,8 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port, */ if (priv->ports[port].enable) mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, - PCR_MATRIX(BIT(MT7530_CPU_PORT))); - priv->ports[port].pm = PCR_MATRIX(BIT(MT7530_CPU_PORT)); + PCR_MATRIX(BIT(upstream))); + priv->ports[port].pm = PCR_MATRIX(BIT(upstream)); mt7530_port_set_vlan_unaware(ds, port); @@ -1194,15 +1206,7 @@ mt7530_port_vlan_del(struct dsa_switch *ds, int port, static enum dsa_tag_protocol mtk_get_tag_protocol(struct dsa_switch *ds, int port) { - struct mt7530_priv *priv = ds->priv; - - if (port != MT7530_CPU_PORT) { - dev_warn(priv->dev, - "port not matched with tagging CPU port\n"); - return DSA_TAG_PROTO_NONE; - } else { - return DSA_TAG_PROTO_MTK; - } + return DSA_TAG_PROTO_MTK; } static int @@ -1275,7 +1279,7 @@ mt7530_setup(struct dsa_switch *ds) /* Enable Port 6 only; P5 as GMAC5 which currently is not supported */ val = mt7530_read(priv, MT7530_MHWTRAP); - val &= ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS; + val &= ~MHWTRAP_P5_DIS & ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS; val |= MHWTRAP_MANUAL; if (!dsa_is_cpu_port(ds, 5)) { val |= MHWTRAP_P5_DIS;