From: gerg@kernel.org
To: sean.wang@mediatek.com, andrew@lunn.ch,
vivien.didelot@savoirfairelinux.com, f.fainelli@gmail.com,
netdev@vger.kernel.org
Cc: blogic@openwrt.org, neil@brown.name, Greg Ungerer <gerg@kernel.org>
Subject: [PATCH 2/3] net: dsa: mt7530: optional setting CPU field in MFC register
Date: Fri, 30 Nov 2018 17:57:36 +1000 [thread overview]
Message-ID: <20181130075737.8041-3-gerg@kernel.org> (raw)
In-Reply-To: <20181130075737.8041-1-gerg@kernel.org>
From: Greg Ungerer <gerg@kernel.org>
Some versions of the MediaTek MT7530 switch have a CPU port number and
enable bit in their MFC register. The MT7530 instance on the MediaTek
MT7621 SoC is one that does for example. The switch will not work
without these fields being correctly setup on these devices.
Create a new devicetree tag, mediatek,mfc-has-cpuport, that signifies
that this device needs the CPU port field and enable bit set when the
port is enabled.
Signed-off-by: Greg Ungerer <gerg@kernel.org>
---
drivers/net/dsa/mt7530.c | 9 +++++++++
drivers/net/dsa/mt7530.h | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 532240c4bef9..e41ada47233a 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -689,6 +689,10 @@ mt7530_cpu_port_enable(struct mt7530_priv *priv,
/* Unknown unicast frame fordwarding to the cpu port */
mt7530_set(priv, MT7530_MFC, UNU_FFP(BIT(port)));
+ /* Set CPU port number */
+ if (priv->mfccpu)
+ mt7530_rmw(priv, MT7530_MFC, CPU_MASK, CPU_EN | CPU_PORT(port));
+
/* CPU port gets connected to all user ports of
* the switch
*/
@@ -1380,6 +1384,11 @@ mt7530_probe(struct mdio_device *mdiodev)
"MT7530 with no CLOCK or REGULATOR control\n");
}
+ /* Use mediatek,mfc-has-cpuport to distinguish hardware where the MFC
+ * register has a CPU port number field setting.
+ */
+ priv->mfccpu = of_property_read_bool(dn, "mediatek,mfc-has-cpuport");
+
/* Not MCM that indicates switch works as the remote standalone
* integrated circuit so the GPIO pin would be used to complete
* the reset, otherwise memory-mapped register accessing used
diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h
index ee97944c4507..cbc0725c4258 100644
--- a/drivers/net/dsa/mt7530.h
+++ b/drivers/net/dsa/mt7530.h
@@ -36,6 +36,9 @@
#define UNM_FFP(x) (((x) & 0xff) << 16)
#define UNU_FFP(x) (((x) & 0xff) << 8)
#define UNU_FFP_MASK UNU_FFP(~0)
+#define CPU_EN BIT(7)
+#define CPU_PORT(x) ((x) << 4)
+#define CPU_MASK (0xf << 4)
/* Registers for address table access */
#define MT7530_ATA1 0x74
@@ -432,6 +435,7 @@ struct mt7530_priv {
struct gpio_desc *reset;
bool mcm;
bool clkreg;
+ bool mfccpu;
struct mt7530_port ports[MT7530_NUM_PORTS];
/* protect among processes for registers access*/
--
2.17.1
next prev parent reply other threads:[~2018-11-30 19:06 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-30 7:57 [PATCH 0/3]: net: dsa: mt7530: support MT7530 in the MT7621 SoC gerg
2018-11-30 7:57 ` [PATCH 1/3] net: dsa: mt7530: make clock/regulator setup optional gerg
2018-11-30 7:57 ` gerg [this message]
2018-11-30 7:57 ` [PATCH 3/3] dt-bindings: net: dsa: add new bindings MT7530 gerg
2018-11-30 17:41 ` Florian Fainelli
2018-12-03 7:03 ` Greg Ungerer
2018-12-03 13:19 ` Andrew Lunn
2018-11-30 11:27 ` [PATCH 0/3]: net: dsa: mt7530: support MT7530 in the MT7621 SoC René van Dorst
2018-11-30 13:25 ` Greg Ungerer
2018-11-30 11:30 ` René van Dorst
2018-11-30 12:16 ` Bjørn Mork
2018-11-30 13:41 ` Greg Ungerer
2018-11-30 13:42 ` Andrew Lunn
2018-12-03 7:20 ` Greg Ungerer
2018-12-03 11:34 ` Bjørn Mork
2018-12-03 14:00 ` René van Dorst
2018-12-03 14:02 ` John Crispin
2018-12-07 7:12 ` Greg Ungerer
2018-12-04 7:23 ` Greg Ungerer
2018-12-11 5:02 ` NeilBrown
2018-12-11 8:28 ` Bjørn Mork
2018-12-16 22:08 ` NeilBrown
2018-12-16 22:14 ` David Miller
2018-12-16 23:19 ` NeilBrown
2018-12-17 0:00 ` Florian Fainelli
2018-12-17 7:11 ` NeilBrown
2018-11-30 13:33 ` Andrew Lunn
2018-12-03 6:47 ` Greg Ungerer
2018-11-30 13:37 ` Andrew Lunn
2018-11-30 13:45 ` Greg Ungerer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181130075737.8041-3-gerg@kernel.org \
--to=gerg@kernel.org \
--cc=andrew@lunn.ch \
--cc=blogic@openwrt.org \
--cc=f.fainelli@gmail.com \
--cc=neil@brown.name \
--cc=netdev@vger.kernel.org \
--cc=sean.wang@mediatek.com \
--cc=vivien.didelot@savoirfairelinux.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).