Skip to contentSkip to conversation

net: dsa: b53: configure BCM63268 RGMII ports

PATCH Superseded Álvaro Fernández Rojas 5 participants 26 messages Mar 20, 2023 – Mar 23, 2023

Subsystems (5)
lore
Share & tools
lore
#10 lore raw

PATCH 3/4 net: dsa: b53: mmap: allow passing a chip ID

In reply to Álvaro Fernández Rojas

BCM63268 SoCs require a special handling for their RGMIIs, so we should be able to identify them as a special BCM63xx switch.

---
 drivers/net/dsa/b53/b53_mmap.c | 32 +++++++++++++++++++++++---------
 drivers/net/dsa/b53/b53_priv.h |  9 ++++++++-
 2 files changed, 31 insertions(+), 10 deletions(-)
drivers/net/dsa/b53/b53_mmap.c +23 -9
index 464c77e10f60..706df04b6cee 100644
@@ -248,7 +248,7 @@ static int b53_mmap_probe_of(struct platform_device *pdev,
 		return -ENOMEM;
 
 	pdata->regs = mem;
-	pdata->chip_id = BCM63XX_DEVICE_ID;
+	pdata->chip_id = (u32)device_get_match_data(dev);
 	pdata->big_endian = of_property_read_bool(np, "big-endian");
 
 	of_ports = of_get_child_by_name(np, "ports");
@@ -330,14 +330,28 @@ static void b53_mmap_shutdown(struct platform_device *pdev)
 }
 
 static const struct of_device_id b53_mmap_of_table[] = {
-	{ .compatible = "brcm,bcm3384-switch" },
-	{ .compatible = "brcm,bcm6318-switch" },
-	{ .compatible = "brcm,bcm6328-switch" },
-	{ .compatible = "brcm,bcm6362-switch" },
-	{ .compatible = "brcm,bcm6368-switch" },
-	{ .compatible = "brcm,bcm63268-switch" },
-	{ .compatible = "brcm,bcm63xx-switch" },
-	{ /* sentinel */ },
+	{
+		.compatible = "brcm,bcm3384-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6318-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6328-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6362-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6368-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm63268-switch",
+		.data = (void *)BCM63268_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm63xx-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, { /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, b53_mmap_of_table);
 
drivers/net/dsa/b53/b53_priv.h +8 -1
index 4cf9f540696e..a689a6950189 100644
@@ -70,6 +70,7 @@ enum {
 	BCM53125_DEVICE_ID = 0x53125,
 	BCM53128_DEVICE_ID = 0x53128,
 	BCM63XX_DEVICE_ID = 0x6300,
+	BCM63268_DEVICE_ID = 0x63268,
 	BCM53010_DEVICE_ID = 0x53010,
 	BCM53011_DEVICE_ID = 0x53011,
 	BCM53012_DEVICE_ID = 0x53012,
@@ -191,7 +192,13 @@ static inline int is531x5(struct b53_device *dev)
 
 static inline int is63xx(struct b53_device *dev)
 {
-	return dev->chip_id == BCM63XX_DEVICE_ID;
+	return dev->chip_id == BCM63XX_DEVICE_ID ||
+		dev->chip_id == BCM63268_DEVICE_ID;
+}
+
+static inline int is63268(struct b53_device *dev)
+{
+	return dev->chip_id == BCM63268_DEVICE_ID;
 }
 
 static inline int is5301x(struct b53_device *dev)
Signature · 1 line
2.30.2
#13 lore raw

PATCH 4/4 net: dsa: b53: add BCM63268 RGMII configuration

In reply to Álvaro Fernández Rojas

BCM63268 requires special RGMII configuration to work.

---
 drivers/net/dsa/b53/b53_common.c | 6 +++++-
 drivers/net/dsa/b53/b53_regs.h   | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/b53/b53_common.c +5 -1
index 6e212f6f1cb9..d0a22c8a55c9 100644
@@ -1240,8 +1240,12 @@ static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port,
 		break;
 	}
 
-	if (port != dev->imp_port)
+	if (port != dev->imp_port) {
+		if (is63268(dev))
+			rgmii_ctrl |= RGMII_CTRL_MII_OVERRIDE;
+
 		rgmii_ctrl |= RGMII_CTRL_ENABLE_GMII;
+	}
 
 	b53_write8(dev, B53_CTRL_PAGE, off, rgmii_ctrl);
 
drivers/net/dsa/b53/b53_regs.h +1 -0
index b2c539a42154..bfbcb66bef66 100644
@@ -138,6 +138,7 @@
 
 #define B53_RGMII_CTRL_IMP		0x60
 #define   RGMII_CTRL_ENABLE_GMII	BIT(7)
+#define   RGMII_CTRL_MII_OVERRIDE	BIT(6)
 #define   RGMII_CTRL_TIMING_SEL		BIT(2)
 #define   RGMII_CTRL_DLL_RXC		BIT(1)
 #define   RGMII_CTRL_DLL_TXC		BIT(0)
Signature · 1 line
2.30.2
#5 lore raw

PATCH 2/4 net: dsa: b53: mmap: add more BCM63xx SoCs

In reply to Álvaro Fernández Rojas

BCM6318, BCM6362 and BCM63268 are SoCs with a B53 MMAP switch.

---
 drivers/net/dsa/b53/b53_mmap.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/dsa/b53/b53_mmap.c +3 -0
index 70887e0aece3..464c77e10f60 100644
@@ -331,8 +331,11 @@ static void b53_mmap_shutdown(struct platform_device *pdev)
 
 static const struct of_device_id b53_mmap_of_table[] = {
 	{ .compatible = "brcm,bcm3384-switch" },
+	{ .compatible = "brcm,bcm6318-switch" },
 	{ .compatible = "brcm,bcm6328-switch" },
+	{ .compatible = "brcm,bcm6362-switch" },
 	{ .compatible = "brcm,bcm6368-switch" },
+	{ .compatible = "brcm,bcm63268-switch" },
 	{ .compatible = "brcm,bcm63xx-switch" },
 	{ /* sentinel */ },
 };
Signature · 1 line
2.30.2
#0 lore raw

cover net: dsa: b53: configure BCM63268 RGMII ports

BCM63268 need special configuration for their RGMII ports, so we need to be able to identify them as a special BCM63xx switch.
In the meantime, let's add some missing BCM63xx SoCs to B53 MMAP device table.

This should be applied after "net: dsa: b53: add support for BCM63xx RGMIIs":
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

Álvaro Fernández Rojas (4):
dt-bindings: net: dsa: b53: add more 63xx SoCs
net: dsa: b53: mmap: add more BCM63xx SoCs
net: dsa: b53: mmap: allow passing a chip ID
net: dsa: b53: add BCM63268 RGMII configuration

 .../devicetree/bindings/net/dsa/brcm,b53.yaml |  3 ++
 drivers/net/dsa/b53/b53_common.c              |  6 +++-
 drivers/net/dsa/b53/b53_mmap.c                | 29 +++++++++++++++----
 drivers/net/dsa/b53/b53_priv.h                |  9 +++++-
 drivers/net/dsa/b53/b53_regs.h                |  1 +
 5 files changed, 40 insertions(+), 8 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/4 dt-bindings: net: dsa: b53: add more 63xx SoCs

BCM6318, BCM6362 and BCM63268 are SoCs with a B53 MMAP switch.

---
 Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml +3 -0
index 5bef4128d175..57e0ef93b134 100644
@@ -57,8 +57,11 @@ properties:
       - items:
           - enum:
               - brcm,bcm3384-switch
+              - brcm,bcm6318-switch
               - brcm,bcm6328-switch
+              - brcm,bcm6362-switch
               - brcm,bcm6368-switch
+              - brcm,bcm63268-switch
           - const: brcm,bcm63xx-switch
 
 required:
Signature · 1 line
2.30.2
#7 lore raw

Re: [PATCH 2/4] net: dsa: b53: mmap: add more BCM63xx SoCs

In reply to Álvaro Fernández Rojas
Quoted 12 lines · Álvaro Fernández Rojas

BCM6318, BCM6362 and BCM63268 are SoCs with a B53 MMAP switch.

---
 drivers/net/dsa/b53/b53_mmap.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/dsa/b53/b53_mmap.c +0 -0
index 70887e0aece3..464c77e10f60 100644

drivers/net/dsa/b53/b53_mmap.c static void b53_mmap_shutdown(struct platform_device *pdev) · line 338

Quoted 8 lines
drivers/net/dsa/b53/b53_mmap.c +3 -0
@@ -331,8 +331,11 @@ static void b53_mmap_shutdown(struct platform_device *pdev)
 
 static const struct of_device_id b53_mmap_of_table[] = {
 	{ .compatible = "brcm,bcm3384-switch" },
+	{ .compatible = "brcm,bcm6318-switch" },
 	{ .compatible = "brcm,bcm6328-switch" },
+	{ .compatible = "brcm,bcm6362-switch" },
 	{ .compatible = "brcm,bcm6368-switch" },
+	{ .compatible = "brcm,bcm63268-switch" },

This patch adds support to this driver for "brcm,bcm63268-switch". However, less I am mistaken, this support doesn't work without patches 3/4 and 4/4 of this series.

I think it would be better to re-range this series so that support for "brcm,bcm63268-switch" works when it is added to/enabled in the driver.

Quoted 6 lines
drivers/net/dsa/b53/b53_mmap.c +0 -0
 	{ .compatible = "brcm,bcm63xx-switch" },
 	{ /* sentinel */ },
 };
Signature · 1 line
2.30.2
#8 lore raw

Re: [PATCH 2/4] net: dsa: b53: mmap: add more BCM63xx SoCs

Quoted 15 lines · Simon Horman
Quoted 13 lines · Álvaro Fernández Rojas

BCM6318, BCM6362 and BCM63268 are SoCs with a B53 MMAP switch.

---
 drivers/net/dsa/b53/b53_mmap.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/dsa/b53/b53_mmap.c +0 -0
index 70887e0aece3..464c77e10f60 100644
@@ -331,8 +331,11 @@ static void b53_mmap_shutdown(struct platform_device *pdev)
 
Quoted 11 lines

drivers/net/dsa/b53/b53_mmap.c static void b53_mmap_shutdown(struct platform_device *pdev) · line 338

Quoted 7 lines
drivers/net/dsa/b53/b53_mmap.c +3 -0
 static const struct of_device_id b53_mmap_of_table[] = {
      { .compatible = "brcm,bcm3384-switch" },
+     { .compatible = "brcm,bcm6318-switch" },
      { .compatible = "brcm,bcm6328-switch" },
+     { .compatible = "brcm,bcm6362-switch" },
      { .compatible = "brcm,bcm6368-switch" },
+     { .compatible = "brcm,bcm63268-switch" },

This patch adds support to this driver for "brcm,bcm63268-switch". However, less I am mistaken, this support doesn't work without patches 3/4 and 4/4 of this series.

It works for those devices which only use ports 0-3 (Comtrend VR-3032u for example).
If the device has a external switch or uses any of the RGMIIs then it won't configure those ports properly.

Quoted 11 lines

I think it would be better to re-range this series so that support for "brcm,bcm63268-switch" works when it is added to/enabled in the driver.

Quoted 6 lines
drivers/net/dsa/b53/b53_mmap.c +0 -1
      { .compatible = "brcm,bcm63xx-switch" },
      { /* sentinel */ },
 };
--

2.30.2

#11 lore raw

Re: [PATCH 3/4] net: dsa: b53: mmap: allow passing a chip ID

In reply to Álvaro Fernández Rojas
Quoted 30 lines · Álvaro Fernández Rojas

BCM63268 SoCs require a special handling for their RGMIIs, so we should be able to identify them as a special BCM63xx switch.

---
  drivers/net/dsa/b53/b53_mmap.c | 32 +++++++++++++++++++++++---------
  drivers/net/dsa/b53/b53_priv.h |  9 ++++++++-
  2 files changed, 31 insertions(+), 10 deletions(-)
drivers/net/dsa/b53/b53_mmap.c +1 -5
index 464c77e10f60..706df04b6cee 100644
@@ -248,7 +248,7 @@ static int b53_mmap_probe_of(struct platform_device *pdev,
  		return -ENOMEM;
 
  	pdata->regs = mem;
-	pdata->chip_id = BCM63XX_DEVICE_ID;
+	pdata->chip_id = (u32)device_get_match_data(dev);
  	pdata->big_endian = of_property_read_bool(np, "big-endian");
 
  	of_ports = of_get_child_by_name(np, "ports");
@@ -330,14 +330,28 @@ static void b53_mmap_shutdown(struct platform_device *pdev)
  }
 
  static const struct of_device_id b53_mmap_of_table[] = {
-	{ .compatible = "brcm,bcm3384-switch" },
-	{ .compatible = "brcm,bcm6318-switch" },
-	{ .compatible = "brcm,bcm6328-switch" },
-	{ .compatible = "brcm,bcm6362-switch" },

drivers/net/dsa/b53/b53_mmap.c static void b53_mmap_shutdown(struct platform_device *pdev) · line 338

Quoted 10 lines
drivers/net/dsa/b53/b53_mmap.c +6 -4
-	{ .compatible = "brcm,bcm6368-switch" },
-	{ .compatible = "brcm,bcm63268-switch" },
-	{ .compatible = "brcm,bcm63xx-switch" },
-	{ /* sentinel */ },
+	{
+		.compatible = "brcm,bcm3384-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6318-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,

You will want to also pass BCM63268_DEVICE_ID here, see my comment in patch 4.

Signature · 1 line
Florian
Reviewed-by on v1 4/4
#14 lore raw

Re: [PATCH 4/4] net: dsa: b53: add BCM63268 RGMII configuration

In reply to Álvaro Fernández Rojas
Quoted 13 lines · Álvaro Fernández Rojas

BCM63268 requires special RGMII configuration to work.

---
  drivers/net/dsa/b53/b53_common.c | 6 +++++-
  drivers/net/dsa/b53/b53_regs.h   | 1 +
  2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/b53/b53_common.c +0 -0
index 6e212f6f1cb9..d0a22c8a55c9 100644

drivers/net/dsa/b53/b53_common.c static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port, · line 1245

Quoted 7 lines
drivers/net/dsa/b53/b53_common.c +3 -1
@@ -1240,8 +1240,12 @@ static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port,
  		break;
  	}
 
-	if (port != dev->imp_port)
+	if (port != dev->imp_port) {
+		if (is63268(dev))
+			rgmii_ctrl |= RGMII_CTRL_MII_OVERRIDE;

AFAICT the override bit is defined and valid for both 63268 and 6318, essentially whenever more than one RGMII control register for port 4, but also for other ports, it seems like the bit becomes valid. The comment I have says that the override bit ensures that what is populated in bits 5:4 which is the actual RGMII interface mode is applied. That mode can be one of:

0b00: RGMII mode
0b01: MII mode
0b10: RVMII mode
0b11: GMII mode

even though this is not documented as such, I suspect that the override bit does not only set the mode, but also ensures that the delays are also applied.

Once you update patch 3, this LGTM and you may add:

For your v2. Thanks!

Signature · 1 line
Florian
#12 lore raw

Re: [PATCH 3/4] net: dsa: b53: mmap: allow passing a chip ID

In reply to Álvaro Fernández Rojas
Quoted 14 lines · Álvaro Fernández Rojas

BCM63268 SoCs require a special handling for their RGMIIs, so we should be able to identify them as a special BCM63xx switch.

---
 drivers/net/dsa/b53/b53_mmap.c | 32 +++++++++++++++++++++++---------
 drivers/net/dsa/b53/b53_priv.h |  9 ++++++++-
 2 files changed, 31 insertions(+), 10 deletions(-)
drivers/net/dsa/b53/b53_mmap.c +0 -0
index 464c77e10f60..706df04b6cee 100644

drivers/net/dsa/b53/b53_mmap.c static int b53_mmap_probe_of(struct platform_device *pdev, · line 251

Quoted 5 lines
drivers/net/dsa/b53/b53_mmap.c +1 -1
@@ -248,7 +248,7 @@ static int b53_mmap_probe_of(struct platform_device *pdev,
 		return -ENOMEM;
 
 	pdata->regs = mem;
-	pdata->chip_id = BCM63XX_DEVICE_ID;
+	pdata->chip_id = (u32)device_get_match_data(dev);

make W=1 with gcc-12 tells me:

drivers/net/dsa/b53/b53_mmap.c: In function 'b53_mmap_probe_of':
drivers/net/dsa/b53/b53_mmap.c:251:26: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
251 | pdata->chip_id = (u32)device_get_match_data(dev);

I don't like casts much, but looking in b53_srab.c I see what appears to be a solution to this problem:

	 pdata->chip_id = (u32)(unsigned long)of_id->data;
Quoted 27 lines
drivers/net/dsa/b53/b53_mmap.c +12 -8
 	pdata->big_endian = of_property_read_bool(np, "big-endian");
 
 	of_ports = of_get_child_by_name(np, "ports");
@@ -330,14 +330,28 @@ static void b53_mmap_shutdown(struct platform_device *pdev)
 }
 
 static const struct of_device_id b53_mmap_of_table[] = {
-	{ .compatible = "brcm,bcm3384-switch" },
-	{ .compatible = "brcm,bcm6318-switch" },
-	{ .compatible = "brcm,bcm6328-switch" },
-	{ .compatible = "brcm,bcm6362-switch" },
-	{ .compatible = "brcm,bcm6368-switch" },
-	{ .compatible = "brcm,bcm63268-switch" },
-	{ .compatible = "brcm,bcm63xx-switch" },
-	{ /* sentinel */ },
+	{
+		.compatible = "brcm,bcm3384-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6318-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6328-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6362-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,

drivers/net/dsa/b53/b53_mmap.c static void b53_mmap_shutdown(struct platform_device *pdev) · line 354

Quoted 10 lines
drivers/net/dsa/b53/b53_mmap.c +10 -0
+	}, {
+		.compatible = "brcm,bcm6368-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm63268-switch",
+		.data = (void *)BCM63268_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm63xx-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, { /* sentinel */ }

This boilerplate doesn't seem ideal.
But it does seem to follow other examples in drivers/net/dsa/

FWIIW, I might have used of_device_is_compatible() without .data. Or only provided data for the exception case(s) and used something like this. (*completely untested*!)

	pdata->chip_id = (u32)(unsigned long)of_id->data ? : BCM63XX_DEVICE_ID;
Quoted 33 lines
drivers/net/dsa/b53/b53_mmap.c +0 -0
 };
 MODULE_DEVICE_TABLE(of, b53_mmap_of_table);
 
drivers/net/dsa/b53/b53_priv.h +8 -1
index 4cf9f540696e..a689a6950189 100644
@@ -70,6 +70,7 @@ enum {
 	BCM53125_DEVICE_ID = 0x53125,
 	BCM53128_DEVICE_ID = 0x53128,
 	BCM63XX_DEVICE_ID = 0x6300,
+	BCM63268_DEVICE_ID = 0x63268,
 	BCM53010_DEVICE_ID = 0x53010,
 	BCM53011_DEVICE_ID = 0x53011,
 	BCM53012_DEVICE_ID = 0x53012,
@@ -191,7 +192,13 @@ static inline int is531x5(struct b53_device *dev)
 
 static inline int is63xx(struct b53_device *dev)
 {
-	return dev->chip_id == BCM63XX_DEVICE_ID;
+	return dev->chip_id == BCM63XX_DEVICE_ID ||
+		dev->chip_id == BCM63268_DEVICE_ID;
+}
+
+static inline int is63268(struct b53_device *dev)
+{
+	return dev->chip_id == BCM63268_DEVICE_ID;
 }
 
 static inline int is5301x(struct b53_device *dev)
Signature · 1 line
2.30.2
#9 lore raw

Re: [PATCH 2/4] net: dsa: b53: mmap: add more BCM63xx SoCs

In reply to Álvaro Fernández Rojas
Quoted 29 lines · Álvaro Fernández Rojas
Quoted 15 lines · Simon Horman
Quoted 13 lines · Álvaro Fernández Rojas

BCM6318, BCM6362 and BCM63268 are SoCs with a B53 MMAP switch.

---
 drivers/net/dsa/b53/b53_mmap.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/dsa/b53/b53_mmap.c +0 -0
index 70887e0aece3..464c77e10f60 100644
@@ -331,8 +331,11 @@ static void b53_mmap_shutdown(struct platform_device *pdev)
 
Quoted 11 lines

drivers/net/dsa/b53/b53_mmap.c static void b53_mmap_shutdown(struct platform_device *pdev) · line 338

Quoted 7 lines
drivers/net/dsa/b53/b53_mmap.c +3 -0
 static const struct of_device_id b53_mmap_of_table[] = {
      { .compatible = "brcm,bcm3384-switch" },
+     { .compatible = "brcm,bcm6318-switch" },
      { .compatible = "brcm,bcm6328-switch" },
+     { .compatible = "brcm,bcm6362-switch" },
      { .compatible = "brcm,bcm6368-switch" },
+     { .compatible = "brcm,bcm63268-switch" },

This patch adds support to this driver for "brcm,bcm63268-switch". However, less I am mistaken, this support doesn't work without patches 3/4 and 4/4 of this series.

Quoted 4 lines

It works for those devices which only use ports 0-3 (Comtrend VR-3032u for example).
If the device has a external switch or uses any of the RGMIIs then it won't configure those ports properly.

Ok, I guess that all drivers have incomplete support, so from that point of view I guess this is fine.

Quoted 10 lines
Quoted 10 lines

I think it would be better to re-range this series so that support for "brcm,bcm63268-switch" works when it is added to/enabled in the driver.

Quoted 6 lines
drivers/net/dsa/b53/b53_mmap.c +0 -1
      { .compatible = "brcm,bcm63xx-switch" },
      { /* sentinel */ },
 };
--

2.30.2

#15 lore raw

Re: [PATCH 4/4] net: dsa: b53: add BCM63268 RGMII configuration

In reply to Florian Fainelli

(Excuse me for my previous email in HTML, but I forgot Android Gmail app uses HTML)

2023-03-20 21:00 GMT+01:00, Florian Fainelli <[email protected]>:

Quoted 19 lines · Álvaro Fernández Rojas
Quoted 18 lines

BCM63268 requires special RGMII configuration to work.

---
  drivers/net/dsa/b53/b53_common.c | 6 +++++-
  drivers/net/dsa/b53/b53_regs.h   | 1 +
  2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/b53/b53_common.c +0 -0
index 6e212f6f1cb9..d0a22c8a55c9 100644
@@ -1240,8 +1240,12 @@ static void b53_adjust_63xx_rgmii(struct dsa_switch
 *ds, int port,
  		break;
  	}
 
Quoted 6 lines

drivers/net/dsa/b53/b53_common.c static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port, · line 1245

Quoted 4 lines
drivers/net/dsa/b53/b53_common.c +3 -1
-	if (port != dev->imp_port)
+	if (port != dev->imp_port) {
+		if (is63268(dev))
+			rgmii_ctrl |= RGMII_CTRL_MII_OVERRIDE;

AFAICT the override bit is defined and valid for both 63268 and 6318,

Should we add a specific ID for the 6318?
I don't know if it's different enough from the 63268 to need a special treatment such as is6318()...

Quoted 10 lines

essentially whenever more than one RGMII control register for port 4, but also for other ports, it seems like the bit becomes valid. The comment I have says that the override bit ensures that what is populated in bits 5:4 which is the actual RGMII interface mode is applied. That mode can be one of:

0b00: RGMII mode
0b01: MII mode
0b10: RVMII mode
0b11: GMII mode

This is interesting since we never set those bits in the bcm63xx enetsw controller...
Should we add configuration for those bits in future patches? Which SoCs hace those bits? Only 6318 and 63268 or every 63xx has them?

Quoted 5 lines

even though this is not documented as such, I suspect that the override bit does not only set the mode, but also ensures that the delays are also applied.

Quoted 9 lines

Once you update patch 3, this LGTM and you may add:

For your v2. Thanks!
--
Florian

--
Álvaro

#17 lore raw

v2 cover net: dsa: b53: configure 6318 and 63268 RGMII ports

In reply to Álvaro Fernández Rojas

BCM6318 and BCM63268 need special configuration for their RGMII ports, so we need to be able to identify them as a special BCM63xx switch.
In the meantime, let's add some missing BCM63xx SoCs to B53 MMAP device table.

This should be applied after "net: dsa: b53: add support for BCM63xx RGMIIs":
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

Álvaro Fernández Rojas (4):
dt-bindings: net: dsa: b53: add more 63xx SoCs
net: dsa: b53: mmap: add more 63xx SoCs
net: dsa: b53: mmap: allow passing a chip ID
net: dsa: b53: add BCM63268 RGMII configuration

 .../devicetree/bindings/net/dsa/brcm,b53.yaml |  3 ++
 drivers/net/dsa/b53/b53_common.c              | 19 +++++++++++-
 drivers/net/dsa/b53/b53_mmap.c                | 29 +++++++++++++++----
 drivers/net/dsa/b53/b53_priv.h                |  9 +++++-
 drivers/net/dsa/b53/b53_regs.h                |  1 +
 5 files changed, 53 insertions(+), 8 deletions(-)
Signature · 1 line
2.30.2
#18 lore raw

PATCH v2 1/4 dt-bindings: net: dsa: b53: add more 63xx SoCs

BCM6318, BCM6362 and BCM63268 are SoCs with a B53 MMAP switch.

---
v2: no changes.

 Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml +3 -0
index 5bef4128d175..57e0ef93b134 100644
@@ -57,8 +57,11 @@ properties:
       - items:
           - enum:
               - brcm,bcm3384-switch
+              - brcm,bcm6318-switch
               - brcm,bcm6328-switch
+              - brcm,bcm6362-switch
               - brcm,bcm6368-switch
+              - brcm,bcm63268-switch
           - const: brcm,bcm63xx-switch
 
 required:
Signature · 1 line
2.30.2
#19 lore raw

PATCH v2 2/4 net: dsa: b53: mmap: add more 63xx SoCs

In reply to Álvaro Fernández Rojas

BCM6318, BCM6362 and BCM63268 are SoCs with a B53 MMAP switch.

---
v2: no changes.

 drivers/net/dsa/b53/b53_mmap.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/dsa/b53/b53_mmap.c +3 -0
index e968322dfbf0..f63aebd445e8 100644
@@ -331,8 +331,11 @@ static void b53_mmap_shutdown(struct platform_device *pdev)
 
 static const struct of_device_id b53_mmap_of_table[] = {
 	{ .compatible = "brcm,bcm3384-switch" },
+	{ .compatible = "brcm,bcm6318-switch" },
 	{ .compatible = "brcm,bcm6328-switch" },
+	{ .compatible = "brcm,bcm6362-switch" },
 	{ .compatible = "brcm,bcm6368-switch" },
+	{ .compatible = "brcm,bcm63268-switch" },
 	{ .compatible = "brcm,bcm63xx-switch" },
 	{ /* sentinel */ },
 };
Signature · 1 line
2.30.2
#21 lore raw

PATCH v2 3/4 net: dsa: b53: mmap: allow passing a chip ID

In reply to Álvaro Fernández Rojas

BCM6318 and BCM63268 SoCs require a special handling for their RGMIIs, so we should be able to identify them as a special BCM63xx switch.

---
v2:
- Add missing chip to b53_switch_chips[].
- Fix device_get_match_data() casting warning.
- Add BCM63268_DEVICE_ID to BCM6318 too.
- Add BCM6318 in commit description.

 drivers/net/dsa/b53/b53_common.c | 13 +++++++++++++
 drivers/net/dsa/b53/b53_mmap.c   | 32 +++++++++++++++++++++++---------
 drivers/net/dsa/b53/b53_priv.h   |  9 ++++++++-
 3 files changed, 44 insertions(+), 10 deletions(-)
drivers/net/dsa/b53/b53_common.c +13 -0
index 6e212f6f1cb9..97327d7a6760 100644
@@ -2465,6 +2465,19 @@ static const struct b53_chip_data b53_switch_chips[] = {
 		.jumbo_pm_reg = B53_JUMBO_PORT_MASK_63XX,
 		.jumbo_size_reg = B53_JUMBO_MAX_SIZE_63XX,
 	},
+	{
+		.chip_id = BCM63268_DEVICE_ID,
+		.dev_name = "BCM63268",
+		.vlans = 4096,
+		.enabled_ports = 0, /* pdata must provide them */
+		.arl_bins = 4,
+		.arl_buckets = 1024,
+		.imp_port = 8,
+		.vta_regs = B53_VTA_REGS_63XX,
+		.duplex_reg = B53_DUPLEX_STAT_63XX,
+		.jumbo_pm_reg = B53_JUMBO_PORT_MASK_63XX,
+		.jumbo_size_reg = B53_JUMBO_MAX_SIZE_63XX,
+	},
 	{
 		.chip_id = BCM53010_DEVICE_ID,
 		.dev_name = "BCM53010",
drivers/net/dsa/b53/b53_mmap.c +23 -9
index f63aebd445e8..a83a0c9d6939 100644
@@ -248,7 +248,7 @@ static int b53_mmap_probe_of(struct platform_device *pdev,
 		return -ENOMEM;
 
 	pdata->regs = mem;
-	pdata->chip_id = BCM63XX_DEVICE_ID;
+	pdata->chip_id = (u32)(unsigned long)device_get_match_data(dev);
 	pdata->big_endian = of_property_read_bool(np, "big-endian");
 
 	of_ports = of_get_child_by_name(np, "ports");
@@ -330,14 +330,28 @@ static void b53_mmap_shutdown(struct platform_device *pdev)
 }
 
 static const struct of_device_id b53_mmap_of_table[] = {
-	{ .compatible = "brcm,bcm3384-switch" },
-	{ .compatible = "brcm,bcm6318-switch" },
-	{ .compatible = "brcm,bcm6328-switch" },
-	{ .compatible = "brcm,bcm6362-switch" },
-	{ .compatible = "brcm,bcm6368-switch" },
-	{ .compatible = "brcm,bcm63268-switch" },
-	{ .compatible = "brcm,bcm63xx-switch" },
-	{ /* sentinel */ },
+	{
+		.compatible = "brcm,bcm3384-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6318-switch",
+		.data = (void *)BCM63268_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6328-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6362-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm6368-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm63268-switch",
+		.data = (void *)BCM63268_DEVICE_ID,
+	}, {
+		.compatible = "brcm,bcm63xx-switch",
+		.data = (void *)BCM63XX_DEVICE_ID,
+	}, { /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, b53_mmap_of_table);
 
drivers/net/dsa/b53/b53_priv.h +8 -1
index 4cf9f540696e..a689a6950189 100644
@@ -70,6 +70,7 @@ enum {
 	BCM53125_DEVICE_ID = 0x53125,
 	BCM53128_DEVICE_ID = 0x53128,
 	BCM63XX_DEVICE_ID = 0x6300,
+	BCM63268_DEVICE_ID = 0x63268,
 	BCM53010_DEVICE_ID = 0x53010,
 	BCM53011_DEVICE_ID = 0x53011,
 	BCM53012_DEVICE_ID = 0x53012,
@@ -191,7 +192,13 @@ static inline int is531x5(struct b53_device *dev)
 
 static inline int is63xx(struct b53_device *dev)
 {
-	return dev->chip_id == BCM63XX_DEVICE_ID;
+	return dev->chip_id == BCM63XX_DEVICE_ID ||
+		dev->chip_id == BCM63268_DEVICE_ID;
+}
+
+static inline int is63268(struct b53_device *dev)
+{
+	return dev->chip_id == BCM63268_DEVICE_ID;
 }
 
 static inline int is5301x(struct b53_device *dev)
Signature · 1 line
2.30.2
#24 lore raw

PATCH v2 4/4 net: dsa: b53: add BCM63268 RGMII configuration

In reply to Álvaro Fernández Rojas

BCM63268 requires special RGMII configuration to work.

---
v2: no changes.

 drivers/net/dsa/b53/b53_common.c | 6 +++++-
 drivers/net/dsa/b53/b53_regs.h   | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/b53/b53_common.c +5 -1
index 97327d7a6760..1f9b251a5452 100644
@@ -1240,8 +1240,12 @@ static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port,
 		break;
 	}
 
-	if (port != dev->imp_port)
+	if (port != dev->imp_port) {
+		if (is63268(dev))
+			rgmii_ctrl |= RGMII_CTRL_MII_OVERRIDE;
+
 		rgmii_ctrl |= RGMII_CTRL_ENABLE_GMII;
+	}
 
 	b53_write8(dev, B53_CTRL_PAGE, off, rgmii_ctrl);
 
drivers/net/dsa/b53/b53_regs.h +1 -0
index b2c539a42154..bfbcb66bef66 100644
@@ -138,6 +138,7 @@
 
 #define B53_RGMII_CTRL_IMP		0x60
 #define   RGMII_CTRL_ENABLE_GMII	BIT(7)
+#define   RGMII_CTRL_MII_OVERRIDE	BIT(6)
 #define   RGMII_CTRL_TIMING_SEL		BIT(2)
 #define   RGMII_CTRL_DLL_RXC		BIT(1)
 #define   RGMII_CTRL_DLL_TXC		BIT(0)
Signature · 1 line
2.30.2
#25 lore raw

Re: [PATCH v2 0/4] net: dsa: b53: configure 6318 and 63268 RGMII ports

In reply to Álvaro Fernández Rojas
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Tue, 21 Mar 2023 18:33:55 +0100 you wrote:

BCM6318 and BCM63268 need special configuration for their RGMII ports, so we need to be able to identify them as a special BCM63xx switch.
In the meantime, let's add some missing BCM63xx SoCs to B53 MMAP device table.

This should be applied after "net: dsa: b53: add support for BCM63xx RGMIIs":
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

[...]

Here is the summary with links:
- [v2,1/4] dt-bindings: net: dsa: b53: add more 63xx SoCs

    https://git.kernel.org/netdev/net-next/c/3ec5ac3133b5
  - [v2,2/4] net: dsa: b53: mmap: add more 63xx SoCs
    https://git.kernel.org/netdev/net-next/c/a2b212fe5c32
  - [v2,3/4] net: dsa: b53: mmap: allow passing a chip ID
    https://git.kernel.org/netdev/net-next/c/260887c770eb
  - [v2,4/4] net: dsa: b53: add BCM63268 RGMII configuration
    https://git.kernel.org/netdev/net-next/c/594c6c2e3ea2

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html