Skip to contentSkip to conversation

net: dsa: bcm_sf2: Add support for optional reset controller line

PATCH Superseded Florian Fainelli 2 participants 6 messages Nov 4, 2019

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover net: dsa: bcm_sf2: Add support for optional reset controller line

Hi David,

This patch series definest the optional reset controller line for the BCM7445/BCM7278 integrated Ethernet switches and updates the driver to drive that reset line in lieu of the internal watchdog based reset since it does not work on BCM7278.

Thanks!

Florian Fainelli (2):
dt-bindings: net: Describe BCM7445 switch reset property
net: dsa: bcm_sf2: Add support for optional reset controller line

 .../bindings/net/brcm,bcm7445-switch-v4.0.txt |  6 ++++++
 drivers/net/dsa/bcm_sf2.c                     | 19 +++++++++++++++++++
 drivers/net/dsa/bcm_sf2.h                     |  3 +++
 3 files changed, 28 insertions(+)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 dt-bindings: net: Describe BCM7445 switch reset property

The BCM7445/BCM7278 built-in Ethernet switch have an optional reset line to the SoC's reset controller, describe the 'resets' and 'reset-names' properties as optional.

---
 .../devicetree/bindings/net/brcm,bcm7445-switch-v4.0.txt    | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/net/brcm,bcm7445-switch-v4.0.txt +6 -0
index b7336b9d6a3c..48a7f916c5e4 100644
@@ -44,6 +44,12 @@ Optional properties:
   Admission Control Block supports reporting the number of packets in-flight in a
   switch queue
 
+- resets: a single phandle and reset identifier pair. See
+  Documentation/devicetree/binding/reset/reset.txt for details.
+
+- reset-names: If the "reset" property is specified, this property should have
+  the value "switch" to denote the switch reset line.
+
 Port subnodes:
 
 Optional properties:
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH net-next 1/2] dt-bindings: net: Describe BCM7445 switch reset property

Quoted 5 lines · Florian Fainelli

The BCM7445/BCM7278 built-in Ethernet switch have an optional reset line to the SoC's reset controller, describe the 'resets' and 'reset-names' properties as optional.

Andrew

#3 lore raw

PATCH 2/2 net: dsa: bcm_sf2: Add support for optional reset controller line

In reply to Florian Fainelli

Grab an optional and exclusive reset controller line for the switch and manage it during probe/remove functions accordingly. For 7278 devices we change bcm_sf2_sw_rst() to use the reset controller line since the WATCHDOG_CTRL register does not reset the switch contrary to stated documentation.

---
 drivers/net/dsa/bcm_sf2.c | 19 +++++++++++++++++++
 drivers/net/dsa/bcm_sf2.h |  3 +++
 2 files changed, 22 insertions(+)
drivers/net/dsa/bcm_sf2.c +19 -0
index 9add84c79dd6..e001c3842afb 100644
@@ -350,6 +350,18 @@ static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv)
 {
 	unsigned int timeout = 1000;
 	u32 reg;
+	int ret;
+
+	/* The watchdog reset does not work on 7278, we need to hit the
+	 * "external" reset line through the reset controller.
+	 */
+	if (priv->type == BCM7278_DEVICE_ID && !IS_ERR(priv->rcdev)) {
+		ret = reset_control_assert(priv->rcdev);
+		if (ret)
+			return ret;
+
+		return reset_control_deassert(priv->rcdev);
+	}
 
 	reg = core_readl(priv, CORE_WATCHDOG_CTRL);
 	reg |= SOFTWARE_RESET | EN_CHIP_RST | EN_SW_RESET;
@@ -1091,6 +1103,11 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
 	priv->core_reg_align = data->core_reg_align;
 	priv->num_cfp_rules = data->num_cfp_rules;
 
+	priv->rcdev = devm_reset_control_get_optional_exclusive(&pdev->dev,
+								"switch");
+	if (PTR_ERR(priv->rcdev) == -EPROBE_DEFER)
+		return PTR_ERR(priv->rcdev);
+
 	/* Auto-detection using standard registers will not work, so
 	 * provide an indication of what kind of device we are for
 	 * b53_common to work with
@@ -1223,6 +1240,8 @@ static int bcm_sf2_sw_remove(struct platform_device *pdev)
 	/* Disable all ports and interrupts */
 	bcm_sf2_sw_suspend(priv->dev->ds);
 	bcm_sf2_mdio_unregister(priv);
+	if (!IS_ERR(priv->rcdev))
+		reset_control_assert(priv->rcdev);
 
 	return 0;
 }
drivers/net/dsa/bcm_sf2.h +3 -0
index 1df30ccec42d..de386dd96d66 100644
@@ -18,6 +18,7 @@
 #include <linux/types.h>
 #include <linux/bitops.h>
 #include <linux/if_vlan.h>
+#include <linux/reset.h>
 
 #include <net/dsa.h>
 
@@ -64,6 +65,8 @@ struct bcm_sf2_priv {
 	void __iomem			*fcb;
 	void __iomem			*acb;
 
+	struct reset_control		*rcdev;
+
 	/* Register offsets indirection tables */
 	u32 				type;
 	const u16			*reg_offsets;
Signature · 1 line
2.17.1
maintainer
#4 lore raw
Quoted 5 lines
drivers/net/dsa/bcm_sf2.c +1 -0
@@ -350,6 +350,18 @@ static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv)
 {
 	unsigned int timeout = 1000;
 	u32 reg;
+	int ret;

drivers/net/dsa/bcm_sf2.c static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv) · line 363

Quoted 10 lines
drivers/net/dsa/bcm_sf2.c +10 -0
+
+	/* The watchdog reset does not work on 7278, we need to hit the
+	 * "external" reset line through the reset controller.
+	 */
+	if (priv->type == BCM7278_DEVICE_ID && !IS_ERR(priv->rcdev)) {
+		ret = reset_control_assert(priv->rcdev);
+		if (ret)
+			return ret;
+
+		return reset_control_deassert(priv->rcdev);

Hi Florian

Here you do it conditional on priv->type

drivers/net/dsa/bcm_sf2.c static int bcm_sf2_sw_remove(struct platform_device *pdev) · line 1244

Quoted 6 lines
drivers/net/dsa/bcm_sf2.c +2 -0
@@ -1223,6 +1240,8 @@ static int bcm_sf2_sw_remove(struct platform_device *pdev)
 	/* Disable all ports and interrupts */
 	bcm_sf2_sw_suspend(priv->dev->ds);
 	bcm_sf2_mdio_unregister(priv);
+	if (!IS_ERR(priv->rcdev))
+		reset_control_assert(priv->rcdev);

And here it is unconditional. Seem a bit inconsistent. If it is in DT, why not use it?

Andrew

#5 lore raw
Quoted 20 lines · Andrew Lunn
Quoted 5 lines
drivers/net/dsa/bcm_sf2.c +1 -0
@@ -350,6 +350,18 @@ static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv)
 {
 	unsigned int timeout = 1000;
 	u32 reg;
+	int ret;

drivers/net/dsa/bcm_sf2.c static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv) · line 363

Quoted 10 lines
drivers/net/dsa/bcm_sf2.c +10 -0
+
+	/* The watchdog reset does not work on 7278, we need to hit the
+	 * "external" reset line through the reset controller.
+	 */
+	if (priv->type == BCM7278_DEVICE_ID && !IS_ERR(priv->rcdev)) {
+		ret = reset_control_assert(priv->rcdev);
+		if (ret)
+			return ret;
+
+		return reset_control_deassert(priv->rcdev);

Hi Florian

Here you do it conditional on priv->type

Quoted 9 lines

drivers/net/dsa/bcm_sf2.c static int bcm_sf2_sw_remove(struct platform_device *pdev) · line 1244

Quoted 6 lines
drivers/net/dsa/bcm_sf2.c +2 -0
@@ -1223,6 +1240,8 @@ static int bcm_sf2_sw_remove(struct platform_device *pdev)
 	/* Disable all ports and interrupts */
 	bcm_sf2_sw_suspend(priv->dev->ds);
 	bcm_sf2_mdio_unregister(priv);
+	if (!IS_ERR(priv->rcdev))
+		reset_control_assert(priv->rcdev);

And here it is unconditional. Seem a bit inconsistent. If it is in DT, why not use it?

That's an oversight, thanks for spotting that, v2 coming shortly.

Signature · 1 line
Florian