linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] b53: Add BCM53134 support
       [not found] <20221212135640.3590545-1-paul.geurts@prodrive-technologies.com>
@ 2023-02-27 19:44 ` Paul Geurts
       [not found] ` <20221212135640.3590545-2-paul.geurts@prodrive-technologies.com>
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Paul Geurts @ 2023-02-27 19:44 UTC (permalink / raw)
  To: linux-kernel

This series of patches add support for the Broadcom BCM53134 managed Ethernet switch device, as well as some extra additions.

The additions now only cover the MDIO interface part of the device. The
BCM53134 device is also controllable through the SPI interface, but for now I don't have the hardware available to test this interface. The functionality in the b53_common sources should be the same though.

Paul Geurts (4):
  net: dsa: b53: Add support for Broadcom BCM53134 managed Ethernet
    switch
  dt-bindings: net/dsa/: add brcm,bcm53134 as compatible flag
  net: dsa: b53: fail switch initialization for unsupported switch types
  net: dsa: b53: mdio: Add optional reset gpio

 .../devicetree/bindings/net/dsa/brcm,b53.yaml |  1 +
 drivers/net/dsa/b53/b53_common.c              | 26 ++++++++++++++++++-
 drivers/net/dsa/b53/b53_mdio.c                | 14 +++++++++-
 drivers/net/dsa/b53/b53_priv.h                | 12 +++++++--
 4 files changed, 49 insertions(+), 4 deletions(-)

--
2.30.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] net: dsa: b53: Add support for Broadcom BCM53134 managed Ethernet switch
       [not found] ` <20221212135640.3590545-2-paul.geurts@prodrive-technologies.com>
@ 2023-02-27 19:44   ` Paul Geurts
  2023-02-28 11:35     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Geurts @ 2023-02-27 19:44 UTC (permalink / raw)
  To: linux-kernel

Add support for the BCM53134 Ethernet switch in the existing b53 dsa driver. This Ethernet switch supports MDIO and SPI interfacing.
This implementation only implements the MDIO interface of this device.
The device also features an SPI interface, which is not implemente in this patch.

The BCM53134 is very familiar to the BCM58XX series. Therefore is85xx() is also applicable to this device.

Signed-off-by: Paul Geurts <paul.geurts@prodrive-technologies.com>
---
 drivers/net/dsa/b53/b53_common.c | 19 ++++++++++++++++++-
 drivers/net/dsa/b53/b53_mdio.c   |  5 ++++-
 drivers/net/dsa/b53/b53_priv.h   | 12 ++++++++++--
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 59cdfc51ce06..6aa76cb4f992 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1266,7 +1266,9 @@ static void b53_adjust_link(struct dsa_switch *ds, int port,
 			rgmii_ctrl |= RGMII_CTRL_DLL_TXC;
 		if (phydev->interface == PHY_INTERFACE_MODE_RGMII)
 			rgmii_ctrl |= RGMII_CTRL_DLL_TXC | RGMII_CTRL_DLL_RXC;
-		rgmii_ctrl |= RGMII_CTRL_TIMING_SEL;
+		/* BCM53134 does not support this bit */
+		if (!is53134(dev))
+			rgmii_ctrl |= RGMII_CTRL_TIMING_SEL;
 		b53_write8(dev, B53_CTRL_PAGE, off, rgmii_ctrl);
 
 		dev_info(ds->dev, "Configured port %d for %s\n", port, @@ -2550,6 +2552,20 @@ static const struct b53_chip_data b53_switch_chips[] = {
 		.jumbo_pm_reg = B53_JUMBO_PORT_MASK,
 		.jumbo_size_reg = B53_JUMBO_MAX_SIZE,
 	},
+	{
+		.chip_id = BCM53134_DEVICE_ID,
+		.dev_name = "BCM53134",
+		.vlans = 4096,
+		.enabled_ports = 0x12F,
+		.imp_port = 8,
+		.cpu_port = B53_CPU_PORT,
+		.vta_regs = B53_VTA_REGS,
+		.arl_bins = 4,
+		.arl_buckets = 1024,
+		.duplex_reg = B53_DUPLEX_STAT_GE,
+		.jumbo_pm_reg = B53_JUMBO_PORT_MASK,
+		.jumbo_size_reg = B53_JUMBO_MAX_SIZE,
+	},
 };
 
 static int b53_switch_init(struct b53_device *dev) @@ -2727,6 +2743,7 @@ int b53_switch_detect(struct b53_device *dev)
 		case BCM53012_DEVICE_ID:
 		case BCM53018_DEVICE_ID:
 		case BCM53019_DEVICE_ID:
+		case BCM53134_DEVICE_ID:
 			dev->chip_id = id32;
 			break;
 		default:
diff --git a/drivers/net/dsa/b53/b53_mdio.c b/drivers/net/dsa/b53/b53_mdio.c index 6ddc03b58b28..8b422b298cd5 100644
--- a/drivers/net/dsa/b53/b53_mdio.c
+++ b/drivers/net/dsa/b53/b53_mdio.c
@@ -286,6 +286,7 @@ static const struct b53_io_ops b53_mdio_ops = {
 #define B53_BRCM_OUI_2	0x03625c00
 #define B53_BRCM_OUI_3	0x00406000
 #define B53_BRCM_OUI_4	0x01410c00
+#define B53_BRCM_OUI_5	0xae025000
 
 static int b53_mdio_probe(struct mdio_device *mdiodev)  { @@ -313,7 +314,8 @@ static int b53_mdio_probe(struct mdio_device *mdiodev)
 	if ((phy_id & 0xfffffc00) != B53_BRCM_OUI_1 &&
 	    (phy_id & 0xfffffc00) != B53_BRCM_OUI_2 &&
 	    (phy_id & 0xfffffc00) != B53_BRCM_OUI_3 &&
-	    (phy_id & 0xfffffc00) != B53_BRCM_OUI_4) {
+	    (phy_id & 0xfffffc00) != B53_BRCM_OUI_4 &&
+	    (phy_id & 0xfffffc00) != B53_BRCM_OUI_5) {
 		dev_err(&mdiodev->dev, "Unsupported device: 0x%08x\n", phy_id);
 		return -ENODEV;
 	}
@@ -375,6 +377,7 @@ static const struct of_device_id b53_of_match[] = {
 	{ .compatible = "brcm,bcm53115" },
 	{ .compatible = "brcm,bcm53125" },
 	{ .compatible = "brcm,bcm53128" },
+	{ .compatible = "brcm,bcm53134" },
 	{ .compatible = "brcm,bcm5365" },
 	{ .compatible = "brcm,bcm5389" },
 	{ .compatible = "brcm,bcm5395" },
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h index 795cbffd5c2b..0388193709a5 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -79,6 +79,7 @@ enum {
 	BCM583XX_DEVICE_ID = 0x58300,
 	BCM7445_DEVICE_ID = 0x7445,
 	BCM7278_DEVICE_ID = 0x7278,
+	BCM53134_DEVICE_ID = 0x5075,
 };
 
 struct b53_pcs {
@@ -186,7 +187,13 @@ static inline int is531x5(struct b53_device *dev)  {
 	return dev->chip_id == BCM53115_DEVICE_ID ||
 		dev->chip_id == BCM53125_DEVICE_ID ||
-		dev->chip_id == BCM53128_DEVICE_ID;
+		dev->chip_id == BCM53128_DEVICE_ID ||
+		dev->chip_id == BCM53134_DEVICE_ID;
+}
+
+static inline int is53134(struct b53_device *dev) {
+	return dev->chip_id == BCM53134_DEVICE_ID;
 }
 
 static inline int is63xx(struct b53_device *dev) @@ -208,7 +215,8 @@ static inline int is58xx(struct b53_device *dev)
 	return dev->chip_id == BCM58XX_DEVICE_ID ||
 		dev->chip_id == BCM583XX_DEVICE_ID ||
 		dev->chip_id == BCM7445_DEVICE_ID ||
-		dev->chip_id == BCM7278_DEVICE_ID;
+		dev->chip_id == BCM7278_DEVICE_ID ||
+		dev->chip_id == BCM53134_DEVICE_ID;
 }
 
 #define B53_CPU_PORT_25	5
--
2.30.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] dt-bindings: net/dsa/: add brcm,bcm53134 as compatible flag
       [not found] ` <20221212135640.3590545-3-paul.geurts@prodrive-technologies.com>
@ 2023-02-27 19:44   ` Paul Geurts
  2023-02-28 11:33     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Geurts @ 2023-02-27 19:44 UTC (permalink / raw)
  To: linux-kernel

The b53 Ethernet driver now has support for the BCM53134 device.
This means the driver has a new compatible device, which is now also documented

Signed-off-by: Paul Geurts <paul.geurts@prodrive-technologies.com>
---
 Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml b/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
index 1219b830b1a4..87065f6c32b7 100644
--- a/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml
@@ -24,6 +24,7 @@ properties:
       - const: brcm,bcm5389
       - const: brcm,bcm5397
       - const: brcm,bcm5398
+      - const: brcm,bcm53134
       - items:
           - const: brcm,bcm11360-srab
           - const: brcm,cygnus-srab
--
2.30.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] net: dsa: b53: fail switch initialization for unsupported switch types
       [not found] ` <20221212135640.3590545-4-paul.geurts@prodrive-technologies.com>
@ 2023-02-27 19:44   ` Paul Geurts
  0 siblings, 0 replies; 9+ messages in thread
From: Paul Geurts @ 2023-02-27 19:44 UTC (permalink / raw)
  To: linux-kernel

When no supported switch device is found in the b53_switch_chips array is found, the driver continues to do a best effort initialization, wihch most likely results in an error and most definetely a non-functional Ethernet switch.

Now, the switch_init function just returns -EINVAL immediately when no valid chip data is found.

Signed-off-by: Paul Geurts <paul.geurts@prodrive-technologies.com>
---
 drivers/net/dsa/b53/b53_common.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 6aa76cb4f992..3aa0672f2ba9 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -2572,11 +2572,13 @@ static int b53_switch_init(struct b53_device *dev)  {
 	unsigned int i;
 	int ret;
+	bool config_found = false;
 
 	for (i = 0; i < ARRAY_SIZE(b53_switch_chips); i++) {
 		const struct b53_chip_data *chip = &b53_switch_chips[i];
 
 		if (chip->chip_id == dev->chip_id) {
+			config_found = true;
 			if (!dev->enabled_ports)
 				dev->enabled_ports = chip->enabled_ports;
 			dev->name = chip->dev_name;
@@ -2593,6 +2595,11 @@ static int b53_switch_init(struct b53_device *dev)
 		}
 	}
 
+	if (!config_found) {
+		dev_err(dev->dev, "No configuration found for switch id 0x%X\n", dev->chip_id);
+		return -EINVAL;
+	}
+
 	/* check which BCM5325x version we have */
 	if (is5325(dev)) {
 		u8 vc4;
--
2.30.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] net: dsa: b53: mdio: Add optional reset gpio
       [not found] ` <20221212135640.3590545-5-paul.geurts@prodrive-technologies.com>
@ 2023-02-27 19:44   ` Paul Geurts
  2023-02-28 11:34     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Geurts @ 2023-02-27 19:44 UTC (permalink / raw)
  To: linux-kernel

Some Broadcom Ethernet switch devices feature a reset pin driven by GPIO.
Provide the option to specify a reset gpio.

Signed-off-by: Paul Geurts <paul.geurts@prodrive-technologies.com>
---
 drivers/net/dsa/b53/b53_mdio.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/dsa/b53/b53_mdio.c b/drivers/net/dsa/b53/b53_mdio.c index 8b422b298cd5..32af5881834c 100644
--- a/drivers/net/dsa/b53/b53_mdio.c
+++ b/drivers/net/dsa/b53/b53_mdio.c
@@ -22,6 +22,7 @@
 #include <linux/delay.h>
 #include <linux/brcmphy.h>
 #include <linux/rtnetlink.h>
+#include <linux/gpio/consumer.h>
 #include <net/dsa.h>
 
 #include "b53_priv.h"
@@ -303,6 +304,14 @@ static int b53_mdio_probe(struct mdio_device *mdiodev)
 		return -ENODEV;
 	}
 
+	/* Try to get a reset GPIO and get the switch out of reset when its there */
+	mdiodev->reset_gpio = devm_gpiod_get_optional(&mdiodev->dev, "reset", GPIOD_OUT_HIGH);
+	if (mdiodev->reset_gpio) {
+		mdelay(50);
+		gpiod_set_value(mdiodev->reset_gpio, 0);
+		mdelay(50);
+	}
+
 	/* read the first port's id */
 	phy_id = mdiobus_read(mdiodev->bus, 0, 2) << 16;
 	phy_id |= mdiobus_read(mdiodev->bus, 0, 3);
--
2.30.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] dt-bindings: net/dsa/: add brcm,bcm53134 as compatible flag
  2023-02-27 19:44   ` [PATCH 2/4] dt-bindings: net/dsa/: add brcm,bcm53134 as compatible flag Paul Geurts
@ 2023-02-28 11:33     ` Krzysztof Kozlowski
       [not found]       ` <20230301085531.3713797-1-paul.geurts@prodrive-technologies.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Krzysztof Kozlowski @ 2023-02-28 11:33 UTC (permalink / raw)
  To: Paul Geurts, linux-kernel

On 27/02/2023 20:44, Paul Geurts wrote:
> The b53 Ethernet driver now has support for the BCM53134 device.
> This means the driver has a new compatible device, which is now also documented
> 
> Signed-off-by: Paul Geurts <paul.geurts@prodrive-technologies.com>
> ---
>  Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml | 1 +

Please use scripts/get_maintainers.pl to get a list of necessary people
and lists to CC.  It might happen, that command when run on an older
kernel, gives you outdated entries.  Therefore please be sure you base
your patches on recent Linux kernel.

You literally skipped everyone...

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] net: dsa: b53: mdio: Add optional reset gpio
  2023-02-27 19:44   ` [PATCH 4/4] net: dsa: b53: mdio: Add optional reset gpio Paul Geurts
@ 2023-02-28 11:34     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2023-02-28 11:34 UTC (permalink / raw)
  To: Paul Geurts, linux-kernel

On 27/02/2023 20:44, Paul Geurts wrote:
> Some Broadcom Ethernet switch devices feature a reset pin driven by GPIO.
> Provide the option to specify a reset gpio.
> 
> Signed-off-by: Paul Geurts <paul.geurts@prodrive-technologies.com>
> ---
>  drivers/net/dsa/b53/b53_mdio.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/net/dsa/b53/b53_mdio.c b/drivers/net/dsa/b53/b53_mdio.c index 8b422b298cd5..32af5881834c 100644
> --- a/drivers/net/dsa/b53/b53_mdio.c
> +++ b/drivers/net/dsa/b53/b53_mdio.c
> @@ -22,6 +22,7 @@
>  #include <linux/delay.h>
>  #include <linux/brcmphy.h>
>  #include <linux/rtnetlink.h>
> +#include <linux/gpio/consumer.h>
>  #include <net/dsa.h>
>  
>  #include "b53_priv.h"
> @@ -303,6 +304,14 @@ static int b53_mdio_probe(struct mdio_device *mdiodev)
>  		return -ENODEV;
>  	}
>  
> +	/* Try to get a reset GPIO and get the switch out of reset when its there */
> +	mdiodev->reset_gpio = devm_gpiod_get_optional(&mdiodev->dev, "reset", GPIOD_OUT_HIGH);

Aren't you adding now undocumented property? Does your DTS passes
dtbs_check?

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] net: dsa: b53: Add support for Broadcom BCM53134 managed Ethernet switch
  2023-02-27 19:44   ` [PATCH 1/4] net: dsa: b53: Add support for Broadcom BCM53134 managed Ethernet switch Paul Geurts
@ 2023-02-28 11:35     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2023-02-28 11:35 UTC (permalink / raw)
  To: Paul Geurts, linux-kernel

On 27/02/2023 20:44, Paul Geurts wrote:
> Add support for the BCM53134 Ethernet switch in the existing b53 dsa driver. This Ethernet switch supports MDIO and SPI interfacing.
> This implementation only implements the MDIO interface of this device.
> The device also features an SPI interface, which is not implemente in this patch.

Please wrap commit message according to Linux coding style / submission
process (neither too early nor over the limit):
https://elixir.bootlin.com/linux/v5.18-rc4/source/Documentation/process/submitting-patches.rst#L586


Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH 2/4] dt-bindings: net/dsa/: add brcm,bcm53134 as compatible flag
       [not found]       ` <20230301085531.3713797-1-paul.geurts@prodrive-technologies.com>
@ 2023-03-01  8:58         ` Paul Geurts
  0 siblings, 0 replies; 9+ messages in thread
From: Paul Geurts @ 2023-03-01  8:58 UTC (permalink / raw)
  To: krzk; +Cc: linux-kernel

>On 27/02/2023 20:44, Paul Geurts wrote:
>> The b53 Ethernet driver now has support for the BCM53134 device.
>> This means the driver has a new compatible device, which is now also documented
>> 
>> Signed-off-by: Paul Geurts <paul.geurts@prodrive-technologies.com>
>> ---
>>  Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml | 1 +
>
>Please use scripts/get_maintainers.pl to get a list of necessary people
>and lists to CC.  It might happen, that command when run on an older
>kernel, gives you outdated entries.  Therefore please be sure you base
>your patches on recent Linux kernel.
>
I did do this, but my git send-email was not working properly and only the CC to
my own email worked. I forwarded the mail to this mailing list using outlook.

I will fix my mail server settings and resubmit the patches to the proper persons.
These patches can therefore be ignored. Sorry for wasting your time.

Thanks for the feedback on the patches though. I will process them before resubmitting.
>
>You literally skipped everyone...
>
>Best regards,
>Krzysztof

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-03-01  8:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20221212135640.3590545-1-paul.geurts@prodrive-technologies.com>
2023-02-27 19:44 ` [PATCH 0/4] b53: Add BCM53134 support Paul Geurts
     [not found] ` <20221212135640.3590545-2-paul.geurts@prodrive-technologies.com>
2023-02-27 19:44   ` [PATCH 1/4] net: dsa: b53: Add support for Broadcom BCM53134 managed Ethernet switch Paul Geurts
2023-02-28 11:35     ` Krzysztof Kozlowski
     [not found] ` <20221212135640.3590545-3-paul.geurts@prodrive-technologies.com>
2023-02-27 19:44   ` [PATCH 2/4] dt-bindings: net/dsa/: add brcm,bcm53134 as compatible flag Paul Geurts
2023-02-28 11:33     ` Krzysztof Kozlowski
     [not found]       ` <20230301085531.3713797-1-paul.geurts@prodrive-technologies.com>
2023-03-01  8:58         ` Paul Geurts
     [not found] ` <20221212135640.3590545-4-paul.geurts@prodrive-technologies.com>
2023-02-27 19:44   ` [PATCH 3/4] net: dsa: b53: fail switch initialization for unsupported switch types Paul Geurts
     [not found] ` <20221212135640.3590545-5-paul.geurts@prodrive-technologies.com>
2023-02-27 19:44   ` [PATCH 4/4] net: dsa: b53: mdio: Add optional reset gpio Paul Geurts
2023-02-28 11:34     ` Krzysztof Kozlowski

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).