Skip to contentSkip to conversation

pinctrl: ocelot: add shared reset

PATCH Superseded Michael Walle 3 participants 5 messages Apr 19, 2022 – Apr 28, 2022

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover pinctrl: ocelot: add shared reset

On LAN966x SoCs, there is an internal reset which is used to reset the switch core. But this will also reset the GPIO and the SGPIO. Thus add support for this shared reset line.

changes since v1:
- rebased onto linus' devel tree, former patch was still based on v1 of the YAML conversion patch

Michael Walle (2):
dt-bindings: pinctrl: ocelot: add reset property
pinctrl: ocelot: add optional shared reset

 .../devicetree/bindings/pinctrl/mscc,ocelot-pinctrl.yaml | 8 ++++++++
 drivers/pinctrl/pinctrl-ocelot.c                         | 9 +++++++++
 2 files changed, 17 insertions(+)
Signature · 1 line
2.30.2
#1 lore raw

PATCH v2 1/2 dt-bindings: pinctrl: ocelot: add reset property

On the LAN966x SoC the GPIO controller will be resetted together with the SGPIO and the switch core. Add a phandle to register the shared reset line.

---
 .../devicetree/bindings/pinctrl/mscc,ocelot-pinctrl.yaml  | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/pinctrl/mscc,ocelot-pinctrl.yaml +8 -0
index 7149a6655623..98d547c34ef3 100644
@@ -42,6 +42,14 @@ properties:
   "#interrupt-cells":
     const: 2
 
+  resets:
+    maxItems: 1
+
+  reset-names:
+    description: Optional shared switch reset.
+    items:
+      - const: switch
+
 patternProperties:
   '-pins$':
     type: object
Signature · 1 line
2.30.2
#2 lore raw

PATCH v2 2/2 pinctrl: ocelot: add optional shared reset

In reply to Michael Walle

On the LAN9668 there is a shared reset line which affects GPIO, SGPIO and the switch core. Add support for this shared reset line.

---
 drivers/pinctrl/pinctrl-ocelot.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/pinctrl/pinctrl-ocelot.c +9 -0
index 1bdced67464b..b25eb04e4e1d 100644
@@ -19,6 +19,7 @@
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
+#include <linux/reset.h>
 #include <linux/slab.h>
 
 #include "core.h"
@@ -1912,6 +1913,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct ocelot_pinctrl *info;
+	struct reset_control *reset;
 	struct regmap *pincfg;
 	void __iomem *base;
 	int ret;
@@ -1927,6 +1929,13 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
 
 	info->desc = (struct pinctrl_desc *)device_get_match_data(dev);
 
+	reset = devm_reset_control_get_optional_shared(dev, "switch");
+	if (IS_ERR(reset)) {
+		dev_err(dev, "Failed to get reset\n");
+		return PTR_ERR(reset);
+	}
+	reset_control_reset(reset);
+
 	base = devm_ioremap_resource(dev,
 			platform_get_resource(pdev, IORESOURCE_MEM, 0));
 	if (IS_ERR(base))
Signature · 1 line
2.30.2
Tested-by on v2 2/2
#3 lore raw

Re: [PATCH v2 2/2] pinctrl: ocelot: add optional shared reset

The 04/20/2022 01:03, Michael Walle wrote:

Hi Michael,

Quoted 3 lines

On the LAN9668 there is a shared reset line which affects GPIO, SGPIO and the switch core. Add support for this shared reset line.

I have just a small comment below. Otherwise:

Quoted 27 lines
---
 drivers/pinctrl/pinctrl-ocelot.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/pinctrl/pinctrl-ocelot.c +2 -0
index 1bdced67464b..b25eb04e4e1d 100644
@@ -19,6 +19,7 @@
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
+#include <linux/reset.h>
 #include <linux/slab.h>
 
 #include "core.h"
@@ -1912,6 +1913,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct ocelot_pinctrl *info;
+       struct reset_control *reset;
        struct regmap *pincfg;
        void __iomem *base;
        int ret;

drivers/pinctrl/pinctrl-ocelot.c static int ocelot_pinctrl_probe(struct platform_device *pdev) · line 1935

Quoted 7 lines
drivers/pinctrl/pinctrl-ocelot.c +4 -0
@@ -1927,6 +1929,13 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
 
        info->desc = (struct pinctrl_desc *)device_get_match_data(dev);
 
+       reset = devm_reset_control_get_optional_shared(dev, "switch");
+       if (IS_ERR(reset)) {
+               dev_err(dev, "Failed to get reset\n");
+               return PTR_ERR(reset);

Can you use dev_err_probe here?

Quoted 9 lines
drivers/pinctrl/pinctrl-ocelot.c +3 -1
+       }
+       reset_control_reset(reset);
+
        base = devm_ioremap_resource(dev,
                        platform_get_resource(pdev, IORESOURCE_MEM, 0));
        if (IS_ERR(base))
--

2.30.2

Signature · 1 line
/Horatiu
#4 lore raw
In reply to Michael Walle
Quoted 7 lines · Michael Walle

On LAN966x SoCs, there is an internal reset which is used to reset the switch core. But this will also reset the GPIO and the SGPIO. Thus add support for this shared reset line.

changes since v1:
- rebased onto linus' devel tree, former patch was still based on v1 of the YAML conversion patch

Patches applied!

Yours,
Linus Walleij