Skip to contentSkip to conversation

net: dsa: mt7530: introduce MMIO driver for MT7988 SoC

RFC PATCH Superseded Daniel Golle 4 participants 8 messages Mar 27, 2023 – Mar 29, 2023

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Daniel Golle

author maintainer
#0 lore raw

RFC PATCH 2/2 net: dsa: mt7530: introduce MMIO driver for MT7988 SoC

The MediaTek MT7988 SoC comes with a built-in switch very similar to previous MT7530 and MT7531. However, the switch address space is mapped into the SoCs memory space rather than being connected via MDIO. Using MMIO simplifies register access and also removes the need for a bus lock, and for that reason also makes interrupt handling more light-weight.

Note that this is different from previous SoCs like MT7621 and MT7623N which also came with an integrated MT7530-like switch which yet had to be accessed via MDIO.

---
 drivers/net/dsa/Kconfig       |   8 ++
 drivers/net/dsa/Makefile      |   1 +
 drivers/net/dsa/mt7530-mmio.c | 126 +++++++++++++++++++++
 drivers/net/dsa/mt7530.c      | 203 ++++++++++++++++++++++++++++++----
 drivers/net/dsa/mt7530.h      |  16 ++-
 5 files changed, 324 insertions(+), 30 deletions(-)
 create mode 100644 drivers/net/dsa/mt7530-mmio.c
drivers/net/dsa/Kconfig +8 -0
index 5a67a74166a3d..0120586df330d 100644
@@ -50,6 +50,14 @@ config NET_DSA_MT7530_MDIO
 	  switch chips. Multi-chip module MT7530 in MT7621AT, MT7621DAT,
 	  MT7621ST and MT7623AI SoCs is supported.
 
+config NET_DSA_MT7530_MMIO
+	tristate "MediaTek MT7988 built-in Ethernet switch support"
+	select NET_DSA_MT7530
+	depends on HAS_IOMEM
+	help
+	  This enables support for the MediaTek MT7988 Ethernet
+	  switch chip.
+
 config NET_DSA_MV88E6060
 	tristate "Marvell 88E6060 ethernet switch chip support"
 	select NET_DSA_TAG_TRAILER
drivers/net/dsa/Makefile +1 -0
index 2b072d574ed02..7c763578b297f 100644
@@ -8,6 +8,7 @@ endif
 obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o
 obj-$(CONFIG_NET_DSA_MT7530)		+= mt7530.o
 obj-$(CONFIG_NET_DSA_MT7530_MDIO)	+= mt7530-mdio.o
+obj-$(CONFIG_NET_DSA_MT7530_MMIO)	+= mt7530-mmio.o
 obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
 obj-$(CONFIG_NET_DSA_RZN1_A5PSW) += rzn1_a5psw.o
 obj-$(CONFIG_NET_DSA_SMSC_LAN9303) += lan9303-core.o
drivers/net/dsa/mt7530-mmio.c new file +126 -0

126 lines not on this page · raw message

drivers/net/dsa/mt7530.c +179 -24

372 lines not on this page · raw message

drivers/net/dsa/mt7530.h +10 -6
index e78ae5c8955ee..6d7f72cb8a2bb 100644
@@ -11,6 +11,8 @@
 #define MT7530_NUM_FDB_RECORDS		2048
 #define MT7530_ALL_MEMBERS		0xff
 
+#define MT7988_CPU_PORT			6
+
 #define MTK_HDR_LEN	4
 #define MT7530_MAX_MTU	(15 * 1024 - ETH_HLEN - ETH_FCS_LEN - MTK_HDR_LEN)
 
@@ -18,6 +20,7 @@ enum mt753x_id {
 	ID_MT7530 = 0,
 	ID_MT7621 = 1,
 	ID_MT7531 = 2,
+	ID_MT7988 = 3,
 };
 
 #define	NUM_TRGMII_CTRL			5
@@ -54,11 +57,11 @@ enum mt753x_id {
 #define  MT7531_MIRROR_PORT_SET(x)	(((x) & MIRROR_MASK) << 16)
 #define  MT7531_CPU_PMAP_MASK		GENMASK(7, 0)
 
-#define MT753X_MIRROR_REG(id)		(((id) == ID_MT7531) ? \
+#define MT753X_MIRROR_REG(id)		((((id) == ID_MT7531) || ((id) == ID_MT7988)) ?	\
 					 MT7531_CFC : MT7530_MFC)
-#define MT753X_MIRROR_EN(id)		(((id) == ID_MT7531) ? \
+#define MT753X_MIRROR_EN(id)		((((id) == ID_MT7531) || ((id) == ID_MT7988)) ?	\
 					 MT7531_MIRROR_EN : MIRROR_EN)
-#define MT753X_MIRROR_MASK(id)		(((id) == ID_MT7531) ? \
+#define MT753X_MIRROR_MASK(id)		((((id) == ID_MT7531) || ((id) == ID_MT7988)) ?	\
 					 MT7531_MIRROR_MASK : MIRROR_MASK)
 
 /* Registers for BPDU and PAE frame control*/
@@ -295,9 +298,8 @@ enum mt7530_vlan_port_acc_frm {
 					 MT7531_FORCE_DPX | \
 					 MT7531_FORCE_RX_FC | \
 					 MT7531_FORCE_TX_FC)
-#define  PMCR_FORCE_MODE_ID(id)		(((id) == ID_MT7531) ? \
-					 MT7531_FORCE_MODE : \
-					 PMCR_FORCE_MODE)
+#define  PMCR_FORCE_MODE_ID(id)		((((id) == ID_MT7531) || ((id) == ID_MT7988)) ?	\
+					 MT7531_FORCE_MODE : PMCR_FORCE_MODE)
 #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 | \
@@ -740,6 +742,7 @@ struct mt753x_info {
  * @core_pwr:		The power supplied into the core
  * @io_pwr:		The power supplied into the I/O
  * @reset:		The descriptor for GPIO line tied to its reset pin
+ * @base_addr:		MMIO address for the switch interface.
  * @mcm:		Flag for distinguishing if standalone IC or module
  *			coupling
  * @ports:		Holding the state among ports
@@ -760,6 +763,7 @@ struct mt7530_priv {
 	struct regulator	*core_pwr;
 	struct regulator	*io_pwr;
 	struct gpio_desc	*reset;
+	void __iomem		*base_addr;
 	const struct mt753x_info *info;
 	unsigned int		id;
 	bool			mcm;
Signature · 1 line
2.39.2
maintainer
#1 lore raw
Quoted 51 lines
drivers/net/dsa/mt7530.c +15 -2
@@ -118,6 +118,9 @@ core_write_mmd_indirect(struct mt7530_priv *priv, int prtad,
 	struct mii_bus *bus = priv->bus;
 	int ret;
 
+	if (!bus)
+		return 0;
+
 	/* Write the desired MMD Devad */
 	ret = bus->write(bus, 0, MII_MMD_CTRL, devad);
 	if (ret < 0)
@@ -147,11 +150,13 @@ core_write(struct mt7530_priv *priv, u32 reg, u32 val)
 {
 	struct mii_bus *bus = priv->bus;
 
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+	if (bus)
+		mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
 
 	core_write_mmd_indirect(priv, reg, MDIO_MMD_VEND2, val);
 
-	mutex_unlock(&bus->mdio_lock);
+	if (bus)
+		mutex_unlock(&bus->mdio_lock);
 }
 
 static void
@@ -160,6 +165,9 @@ core_rmw(struct mt7530_priv *priv, u32 reg, u32 mask, u32 set)
 	struct mii_bus *bus = priv->bus;
 	u32 val;
 
+	if (!bus)
+		return;
+
 	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
 
 	val = core_read_mmd_indirect(priv, reg, MDIO_MMD_VEND2);
@@ -189,6 +197,11 @@ mt7530_mii_write(struct mt7530_priv *priv, u32 reg, u32 val)
 	u16 page, r, lo, hi;
 	int ret;
 
+	if (priv->base_addr) {
+		iowrite32(val, priv->base_addr + reg);
+		return 0;
+	}
+
 	page = (reg >> 6) & 0x3ff;
 	r  = (reg >> 2) & 0xf;
 	lo = val & 0xffff;

drivers/net/dsa/mt7530.c mt7530_mii_read(struct mt7530_priv *priv, u32 reg) · line 239

Quoted 9 lines
drivers/net/dsa/mt7530.c +3 -0
@@ -218,6 +231,9 @@ mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
 	u16 page, r, lo, hi;
 	int ret;
 
+	if (priv->base_addr)
+		return ioread32(priv->base_addr + reg);
+
 	page = (reg >> 6) & 0x3ff;
 	r = (reg >> 2) & 0xf;
 

This looks pretty ugly.

A much better way to do this is to use regmap. Take a look at xrs700x and how it has both an i2c and an mdio version.

Andrew

author maintainer
#2 lore raw

Hi Andrew,

Quoted 63 lines · Andrew Lunn
Quoted 51 lines
drivers/net/dsa/mt7530.c +15 -2
@@ -118,6 +118,9 @@ core_write_mmd_indirect(struct mt7530_priv *priv, int prtad,
 	struct mii_bus *bus = priv->bus;
 	int ret;
 
+	if (!bus)
+		return 0;
+
 	/* Write the desired MMD Devad */
 	ret = bus->write(bus, 0, MII_MMD_CTRL, devad);
 	if (ret < 0)
@@ -147,11 +150,13 @@ core_write(struct mt7530_priv *priv, u32 reg, u32 val)
 {
 	struct mii_bus *bus = priv->bus;
 
-	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
+	if (bus)
+		mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
 
 	core_write_mmd_indirect(priv, reg, MDIO_MMD_VEND2, val);
 
-	mutex_unlock(&bus->mdio_lock);
+	if (bus)
+		mutex_unlock(&bus->mdio_lock);
 }
 
 static void
@@ -160,6 +165,9 @@ core_rmw(struct mt7530_priv *priv, u32 reg, u32 mask, u32 set)
 	struct mii_bus *bus = priv->bus;
 	u32 val;
 
+	if (!bus)
+		return;
+
 	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
 
 	val = core_read_mmd_indirect(priv, reg, MDIO_MMD_VEND2);
@@ -189,6 +197,11 @@ mt7530_mii_write(struct mt7530_priv *priv, u32 reg, u32 val)
 	u16 page, r, lo, hi;
 	int ret;
 
+	if (priv->base_addr) {
+		iowrite32(val, priv->base_addr + reg);
+		return 0;
+	}
+
 	page = (reg >> 6) & 0x3ff;
 	r  = (reg >> 2) & 0xf;
 	lo = val & 0xffff;

drivers/net/dsa/mt7530.c mt7530_mii_read(struct mt7530_priv *priv, u32 reg) · line 239

Quoted 9 lines
drivers/net/dsa/mt7530.c +3 -0
@@ -218,6 +231,9 @@ mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
 	u16 page, r, lo, hi;
 	int ret;
 
+	if (priv->base_addr)
+		return ioread32(priv->base_addr + reg);
+
 	page = (reg >> 6) & 0x3ff;
 	r = (reg >> 2) & 0xf;
 

This looks pretty ugly.

Quoted 2 lines

A much better way to do this is to use regmap. Take a look at xrs700x and how it has both an i2c and an mdio version.

I agree that using regmap would be better and I have evaluated that approach as well. As regmap doesn't allow lock-skipping and mt7530.c is much more complex than xrs700x in the way indirect access to its MDIO bus and interrupts work, using regmap accessors for everything would not be trivial.

To illustrate what I'm talking about, let me show some examples in the current code for which I don't see a way to use regmap:
634) static int
635) mt7531_ind_c45_phy_read(struct mt7530_priv *priv, int port, int devad,
636) int regnum)
637) {

638)   struct mii_bus *bus = priv->bus;
639)   struct mt7530_dummy_poll p;
640)   u32 reg, val;
641)   int ret;

642)
643) INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
644)
645) mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
646)
647) ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
648) !(val & MT7531_PHY_ACS_ST), 20, 100000);
649) if (ret < 0) {
650) dev_err(priv->dev, "poll timeout\n");
651) goto out;
652) }
653)
654) reg = MT7531_MDIO_CL45_ADDR | MT7531_MDIO_PHY_ADDR(port) |
655) MT7531_MDIO_DEV_ADDR(devad) | regnum;
656) mt7530_mii_write(priv, MT7531_PHY_IAC, reg | MT7531_PHY_ACS_ST);
657)
658) ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
659) !(val & MT7531_PHY_ACS_ST), 20, 100000);
660) if (ret < 0) {
661) dev_err(priv->dev, "poll timeout\n");
662) goto out;
663) }
664)
665) reg = MT7531_MDIO_CL45_READ | MT7531_MDIO_PHY_ADDR(port) |
666) MT7531_MDIO_DEV_ADDR(devad);
667) mt7530_mii_write(priv, MT7531_PHY_IAC, reg | MT7531_PHY_ACS_ST);
668)
669) ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
670) !(val & MT7531_PHY_ACS_ST), 20, 100000);
671) if (ret < 0) {
672) dev_err(priv->dev, "poll timeout\n");
673) goto out;
674) }
675)
676) ret = val & MT7531_MDIO_RW_DATA_MASK;
677) out:
678) mutex_unlock(&bus->mdio_lock);
679)
680) return ret;
681) }

So here we can of course use regmap_read_poll_timeout and a bunch of readmap_write operations. However, each of them will individually acquire and release the mdio bus mutex while the current code acquires the lock at the top of the function and then uses unlocked operations. regmap currently doesn't offer any way to skip the locking and/or perform locking manually. regmap_read, regmap_write, regmap_update_bits, ... always acquire and release the lock on each operation.

While in the above example this might just imply a performance hit, look here:

1958) static void
1959) mt7530_irq_bus_sync_unlock(struct irq_data *d) 1960) {
1961) struct mt7530_priv *priv = irq_data_get_irq_chip_data(d);
1962)
1963) mt7530_mii_write(priv, MT7530_SYS_INT_EN, priv->irq_enable);
1964) mutex_unlock(&priv->bus->mdio_lock);
1965) }

So in this case the lock has previously been acquired and the register is written when releasing the lock.
The above function is being used as .irq_bus_sync_unlock...

Hence there are two ways to go:
1. Extend regmap to allow callers to perform locking manually and provide unlocked variants of all operations.
This would allow us to then convert all the mt7530_{read,write,rmw}, mt7530_mii_{read,write}, ... calls to use regmap_* calls instead.

2. Use regmap to only provide locked access and keep open-coding the cases where unlocked access is used while manually acquiring the bus mutex in such cases, as it is the case now.

3. Use regmap to only provide unlocked access to beging with and keep taking care of locking in mt7530.c as it is now. This would be easy, but then all those ugly checks you criticized would still be needed. Ie. if (priv->base_addr) ... would of course go away, but all the other if (priv->bus) ... checks would have to stay.

Let me know what you think and how I should proceed.

Thank you!

Best regards

Daniel

maintainer
#3 lore raw
Quoted 5 lines

I agree that using regmap would be better and I have evaluated that approach as well. As regmap doesn't allow lock-skipping and mt7530.c is much more complex than xrs700x in the way indirect access to its MDIO bus and interrupts work, using regmap accessors for everything would not be trivial.

O.K, so lets go another way.

Study the low level accesors, and put an abstraction over them. Provide an MDIO set and an MMIO set.

Quoted 6 lines

To illustrate what I'm talking about, let me show some examples in the current code for which I don't see a way to use regmap:
634) static int
635) mt7531_ind_c45_phy_read(struct mt7530_priv *priv, int port, int devad,
636) int regnum)
637) {

Quoted 8 lines
638)   struct mii_bus *bus = priv->bus;
639)   struct mt7530_dummy_poll p;
640)   u32 reg, val;
641)   int ret;

642)
643) INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
644)
645) mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);

So you need an abstract lock() and an unlock(). Maybe the MMIO implementation is a NOP? And the MDIO implementation does a real lock?

Quoted 3 lines

646)
647) ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
648) !(val & MT7531_PHY_ACS_ST), 20, 100000);

_mt7530_unlocked_read and presumably _mt7530_unlocked_write()?

Quoted 8 lines

649) if (ret < 0) {
650) dev_err(priv->dev, "poll timeout\n");
651) goto out;
652) }
653)
654) reg = MT7531_MDIO_CL45_ADDR | MT7531_MDIO_PHY_ADDR(port) |
655) MT7531_MDIO_DEV_ADDR(devad) | regnum;
656) mt7530_mii_write(priv, MT7531_PHY_IAC, reg | MT7531_PHY_ACS_ST);

mt7530_write() and mt7530_read()

Put the MDIO accessors in the _mdio.c file, and the MMIO accessors in the _mmio.c file. Pass them to the core. If you have the abstraction correct, the core should not care how the registers are accessed.

Andrew

maintainer
#4 lore raw
In reply to Daniel Golle
Quoted 6 lines · Daniel Golle

I agree that using regmap would be better and I have evaluated that approach as well. As regmap doesn't allow lock-skipping and mt7530.c is much more complex than xrs700x in the way indirect access to its MDIO bus and interrupts work, using regmap accessors for everything would not be trivial.

Quoted 7 lines

So here we can of course use regmap_read_poll_timeout and a bunch of readmap_write operations. However, each of them will individually acquire and release the mdio bus mutex while the current code acquires the lock at the top of the function and then uses unlocked operations. regmap currently doesn't offer any way to skip the locking and/or perform locking manually. regmap_read, regmap_write, regmap_update_bits, ... always acquire and release the lock on each operation.

What does struct regmap_config :: disable_locking do?

author maintainer
#5 lore raw
Quoted 15 lines · Vladimir Oltean
Quoted 6 lines · Daniel Golle

I agree that using regmap would be better and I have evaluated that approach as well. As regmap doesn't allow lock-skipping and mt7530.c is much more complex than xrs700x in the way indirect access to its MDIO bus and interrupts work, using regmap accessors for everything would not be trivial.

Quoted 7 lines

So here we can of course use regmap_read_poll_timeout and a bunch of readmap_write operations. However, each of them will individually acquire and release the mdio bus mutex while the current code acquires the lock at the top of the function and then uses unlocked operations. regmap currently doesn't offer any way to skip the locking and/or perform locking manually. regmap_read, regmap_write, regmap_update_bits, ... always acquire and release the lock on each operation.

Quoted 1 line

What does struct regmap_config :: disable_locking do?

I thought I can't use that on a per-operation base because the instance of struct regmap_config itself isn't protected by any lock and hence setting disable_locking=false before calling one of the accessor functions may affect also other congruent calls to the accessors which will then ignore locking and screw things up. Please correct me if I'm wrong there.

Yet another way I thought about now could also be to have two regmap instances, one for locked and one for unlocked accessed to the same regmap_bus.

maintainer
#6 lore raw
Quoted 16 lines · Daniel Golle
Quoted 15 lines · Vladimir Oltean
Quoted 13 lines · Daniel Golle

I agree that using regmap would be better and I have evaluated that approach as well. As regmap doesn't allow lock-skipping and mt7530.c is much more complex than xrs700x in the way indirect access to its MDIO bus and interrupts work, using regmap accessors for everything would not be trivial.

So here we can of course use regmap_read_poll_timeout and a bunch of readmap_write operations. However, each of them will individually acquire and release the mdio bus mutex while the current code acquires the lock at the top of the function and then uses unlocked operations. regmap currently doesn't offer any way to skip the locking and/or perform locking manually. regmap_read, regmap_write, regmap_update_bits, ... always acquire and release the lock on each operation.

Quoted 8 lines
Quoted 1 line

What does struct regmap_config :: disable_locking do?

I thought I can't use that on a per-operation base because the instance of struct regmap_config itself isn't protected by any lock and hence setting disable_locking=false before calling one of the accessor functions may affect also other congruent calls to the accessors which will then ignore locking and screw things up. Please correct me if I'm wrong there.

It's not supposed to be used like that. You set disable_locking = true once, and take care of locking from the mt7530 driver. Not before every operation.

Quoted 3 lines

Yet another way I thought about now could also be to have two regmap instances, one for locked and one for unlocked accessed to the same regmap_bus.

That would also be theoretically possible, but the above would be equivalent and would require a single regmap.

#7 lore raw
In reply to Daniel Golle
reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install arm64 cross compiling tool for…

Hi Daniel,

[FYI, it's a private test report for your RFC patch.] [auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Daniel-Golle/net-dsa-mt7530-introduce-MMIO-driver-for-MT7988-SoC/20230328-053725
patch link:    https://lore.kernel.org/r/ZCIML310vc8%2FuoM4%40makrotopia.org
patch subject: [RFC PATCH net-next 2/2] net: dsa: mt7530: introduce MMIO driver for MT7988 SoC
config: arm64-randconfig-r014-20230327 (https://download.01.org/0day-ci/archive/20230329/[email protected]/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/e58502b71250c25c0b71b5adb3c776be06dfb909
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Daniel-Golle/net-dsa-mt7530-introduce-MMIO-driver-for-MT7988-SoC/20230328-053725 git checkout e58502b71250c25c0b71b5adb3c776be06dfb909
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/net/dsa/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/net/dsa/mt7530.c:3128:6: warning: variable 'unused_pm' set but not used [-Wunused-but-set-variable]
           u32 unused_pm = 0;
               ^

1 warning generated.

vim +/unused_pm +3128 drivers/net/dsa/mt7530.c

3124
3125 static int mt7988_setup(struct dsa_switch *ds)
3126 {
3127 struct mt7530_priv *priv = ds->priv;

> 3128		u32 unused_pm = 0;

3129 int i;
3130
3131 /* Reset the switch */
3132 reset_control_assert(priv->rstc);
3133 udelay(20);
3134 reset_control_deassert(priv->rstc);
3135 udelay(20);
3136
3137 /* Reset the switch PHYs */
3138 mt7530_write(priv, MT7530_SYS_CTRL, SYS_CTRL_PHY_RST);
3139
3140 /* BPDU to CPU port */
3141 mt7530_rmw(priv, MT7531_CFC, MT7531_CPU_PMAP_MASK,
3142 BIT(MT7988_CPU_PORT));
3143 mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
3144 MT753X_BPDU_CPU_ONLY);
3145
3146 /* Enable and reset MIB counters */
3147 mt7530_mib_reset(ds);
3148
3149 for (i = 0; i < MT7530_NUM_PORTS; i++) {
3150 /* Disable forwarding by default on all ports */
3151 mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
3152 PCR_MATRIX_CLR);
3153
3154 mt7530_set(priv, MT7531_DBG_CNT(i), MT7531_DIS_CLR);
3155
3156 if (dsa_is_unused_port(ds, i))
3157 unused_pm |= BIT(i);
3158 else if (dsa_is_cpu_port(ds, i))
3159 mt753x_cpu_port_enable(ds, i);
3160 else
3161 mt7530_port_disable(ds, i);
3162
3163 /* Enable consistent egress tag */
3164 mt7530_rmw(priv, MT7530_PVC_P(i), PVC_EG_TAG_MASK,
3165 PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
3166 }
3167
3168 ds->configure_vlan_while_not_filtering = true;
3169
3170 /* Flush the FDB table */
3171 return mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
3172 }
3173

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests