Skip to contentSkip to conversation

reset: support Broadcom's PMB

PATCH Superseded Rafał Miłecki 3 participants 9 messages Nov 18, 2020 – Nov 19, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover reset: support Broadcom's PMB

From: Rafał Miłecki <[email protected]>

PMB is Broadcom's old reset controller. Later it was replaced by PMC which is a wrapper around PMB.

It's still important to support older PMB as:
1. It's the only reset option on older devices
2. Sometimes PMC may be unable to handle device reset and PMB should be used as fallback
3. Some devices may be configured not to use PMC at all

I'll get back to working on PMC later.

Rafał Miłecki (2):
dt-bindings: reset: document Broadcom's PMB binding
reset: brcm-pmc: add driver for Broadcom's PMB

 .../devicetree/bindings/reset/brcm,pmb.yaml   |  51 +++
 drivers/reset/Kconfig                         |   7 +
 drivers/reset/Makefile                        |   1 +
 drivers/reset/reset-brcm-pmb.c                | 307 ++++++++++++++++++
 include/dt-bindings/reset/brcm,pmb.h          |   9 +
 5 files changed, 375 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/brcm,pmb.yaml
 create mode 100644 drivers/reset/reset-brcm-pmb.c
 create mode 100644 include/dt-bindings/reset/brcm,pmb.h
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/2 dt-bindings: reset: document Broadcom's PMB binding

From: Rafał Miłecki <[email protected]>

Broadcom's PMB is reset controller used for disabling and enabling SoC devices.

---
 .../devicetree/bindings/reset/brcm,pmb.yaml   | 51 +++++++++++++++++++
 include/dt-bindings/reset/brcm,pmb.h          |  9 ++++
 2 files changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/brcm,pmb.yaml
 create mode 100644 include/dt-bindings/reset/brcm,pmb.h
Documentation/devicetree/bindings/reset/brcm,pmb.yaml new file +51 -0
new file mode 100644
index 000000000000..ea78ab629c45
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/reset/brcm,pmb.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom PMB Master reset controller
+
+description: This document describes Broadcom's PMB controller. It supports
+  resetting various types of connected devices (e.g. PCIe, USB, SATA). It
+  requires specifying device address.
+
+maintainers:
+  - Rafał Miłecki <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - brcm,bcm4908-pmb # PMB on BCM4908 and compatible SoCs
+
+  reg:
+    maxItems: 1
+
+  big-endian:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Flag to use for block working in big endian mode.
+
+  "#reset-cells":
+    const: 2
+
+required:
+  - compatible
+  - reg
+  - "#reset-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/reset/brcm,pmb.h>
+
+    pmb: reset-controller@802800e0 {
+        compatible = "brcm,bcm4908-pmb";
+        reg = <0x802800e0 0x20>;
+        #reset-cells = <2>;
+    };
+
+    foo {
+        resets = <&pmb BRCM_PMB_USB 17>;
+    }
include/dt-bindings/reset/brcm,pmb.h new file +9 -0
new file mode 100644
index 000000000000..1b724e451de1
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later OR MIT */
+
+#ifndef _DT_BINDINGS_RESET_BRCM_PMB
+#define _DT_BINDINGS_RESET_BRCM_PMB
+
+#define BRCM_PMB_USB		0x01
+#define BRCM_PMB_PCIE		0x02
+
+#endif
Signature · 1 line
2.27.0
#7 lore raw

PATCH 2/2 reset: brcm-pmc: add driver for Broadcom's PMB

In reply to Rafał Miłecki

From: Rafał Miłecki <[email protected]>

PMB can be found on BCM4908 and many other chipsets (e.g. BCM63138). It's needed to power on and off SoC blocks like PCIe, SATA, USB.

---
 drivers/reset/Kconfig          |   7 +
 drivers/reset/Makefile         |   1 +
 drivers/reset/reset-brcm-pmb.c | 307 +++++++++++++++++++++++++++++++++
 3 files changed, 315 insertions(+)
 create mode 100644 drivers/reset/reset-brcm-pmb.c
drivers/reset/Kconfig +7 -0
index 84baec01aa30..af10fb92691c 100644
@@ -41,6 +41,13 @@ config RESET_BERLIN
 	help
 	  This enables the reset controller driver for Marvell Berlin SoCs.
 
+config RESET_BRCM_PMB
+	tristate "Broadcom PMB reset controller"
+	depends on ARCH_BCM4908 || COMPILE_TEST
+	default ARCH_BCM4908
+	help
+	  This enables the Broadcom PMB reset controller driver.
+
 config RESET_BRCMSTB
 	tristate "Broadcom STB reset controller"
 	depends on ARCH_BRCMSTB || COMPILE_TEST
drivers/reset/Makefile +1 -0
index 16947610cc3b..0dd5d42050dc 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_RESET_A10SR) += reset-a10sr.o
 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
 obj-$(CONFIG_RESET_AXS10X) += reset-axs10x.o
 obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o
+obj-$(CONFIG_RESET_BRCM_PMB) += reset-brcm-pmb.o
 obj-$(CONFIG_RESET_BRCMSTB) += reset-brcmstb.o
 obj-$(CONFIG_RESET_BRCMSTB_RESCAL) += reset-brcmstb-rescal.o
 obj-$(CONFIG_RESET_HSDK) += reset-hsdk.o
drivers/reset/reset-brcm-pmb.c new file +307 -0

307 lines not on this page · raw message

Signature · 1 line
2.27.0
maintainer
#2 lore raw

Re: [PATCH 1/2] dt-bindings: reset: document Broadcom's PMB binding

In reply to Rafał Miłecki
Quoted 5 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Broadcom's PMB is reset controller used for disabling and enabling SoC devices.

Quoted 8 lines
---
 .../devicetree/bindings/reset/brcm,pmb.yaml   | 51 +++++++++++++++++++
 include/dt-bindings/reset/brcm,pmb.h          |  9 ++++
 2 files changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/brcm,pmb.yaml
 create mode 100644 include/dt-bindings/reset/brcm,pmb.h

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/reset/brcm,pmb.example.dts:31.5-6 syntax error
FATAL ERROR: Unable to parse input tree
make[1]: *** [scripts/Makefile.lib:342: Documentation/devicetree/bindings/reset/brcm,pmb.example.dt.yaml] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1364: dt_binding_check] Error 2

See https://patchwork.ozlabs.org/patch/1402238

The base for the patch is generally the last rc1. Any dependencies should be noted.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] dt-bindings: reset: document Broadcom's PMB binding

In reply to Rafał Miłecki
Quoted 39 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Broadcom's PMB is reset controller used for disabling and enabling SoC devices.

---
 .../devicetree/bindings/reset/brcm,pmb.yaml   | 51 +++++++++++++++++++
 include/dt-bindings/reset/brcm,pmb.h          |  9 ++++
 2 files changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/brcm,pmb.yaml
 create mode 100644 include/dt-bindings/reset/brcm,pmb.h
Documentation/devicetree/bindings/reset/brcm,pmb.yaml new file +20 -0
new file mode 100644
index 000000000000..ea78ab629c45
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/reset/brcm,pmb.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom PMB Master reset controller
+
+description: This document describes Broadcom's PMB controller. It supports
+  resetting various types of connected devices (e.g. PCIe, USB, SATA). It
+  requires specifying device address.
+
+maintainers:
+  - Rafał Miłecki <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - brcm,bcm4908-pmb # PMB on BCM4908 and compatible SoCs
+

Documentation/devicetree/bindings/reset/brcm,pmb.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/reset/brcm,pmb.yaml new file +10 -0
+  reg:
+    maxItems: 1
+
+  big-endian:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Flag to use for block working in big endian mode.
+
+  "#reset-cells":
+    const: 2

I believe we would need a description of the #reset-cells property that indicates what they do.

Other than that and the build failure below:

Quoted 11 lines
Documentation/devicetree/bindings/reset/brcm,pmb.yaml new file +11 -0
+
+required:
+  - compatible
+  - reg
+  - "#reset-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/reset/brcm,pmb.h>

Documentation/devicetree/bindings/reset/brcm,pmb.yaml line 51

Quoted 10 lines
Documentation/devicetree/bindings/reset/brcm,pmb.yaml new file +10 -0
+
+    pmb: reset-controller@802800e0 {
+        compatible = "brcm,bcm4908-pmb";
+        reg = <0x802800e0 0x20>;
+        #reset-cells = <2>;
+    };
+
+    foo {
+        resets = <&pmb BRCM_PMB_USB 17>;
+    }

You are missing a ';' here which is why the binding example did not build.

Quoted 16 lines
include/dt-bindings/reset/brcm,pmb.h new file +9 -0
new file mode 100644
index 000000000000..1b724e451de1
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later OR MIT */
+
+#ifndef _DT_BINDINGS_RESET_BRCM_PMB
+#define _DT_BINDINGS_RESET_BRCM_PMB
+
+#define BRCM_PMB_USB		0x01
+#define BRCM_PMB_PCIE		0x02
+
+#endif
Signature · 1 line
Florian
#4 lore raw

Re: [PATCH 1/2] dt-bindings: reset: document Broadcom's PMB binding

Quoted 54 lines · Florian Fainelli
Quoted 39 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Broadcom's PMB is reset controller used for disabling and enabling SoC devices.

---
 .../devicetree/bindings/reset/brcm,pmb.yaml   | 51 +++++++++++++++++++
 include/dt-bindings/reset/brcm,pmb.h          |  9 ++++
 2 files changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/brcm,pmb.yaml
 create mode 100644 include/dt-bindings/reset/brcm,pmb.h
Documentation/devicetree/bindings/reset/brcm,pmb.yaml new file +20 -0
new file mode 100644
index 000000000000..ea78ab629c45
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/reset/brcm,pmb.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom PMB Master reset controller
+
+description: This document describes Broadcom's PMB controller. It supports
+  resetting various types of connected devices (e.g. PCIe, USB, SATA). It
+  requires specifying device address.
+
+maintainers:
+  - Rafał Miłecki <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - brcm,bcm4908-pmb # PMB on BCM4908 and compatible SoCs
+

Documentation/devicetree/bindings/reset/brcm,pmb.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/reset/brcm,pmb.yaml new file +10 -0
+  reg:
+    maxItems: 1
+
+  big-endian:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Flag to use for block working in big endian mode.
+
+  "#reset-cells":
+    const: 2

I believe we would need a description of the #reset-cells property that indicates what they do.

Quoted 1 line

Other than that and the build failure below:

I don't know how to express constraints on each of the cells, but since they are represented by 8 bits you may want to add mininimum: 0 /
maximum: 255 constraints in the YAML binding.

Signature · 1 line
Florian
#8 lore raw

Re: [PATCH 2/2] reset: brcm-pmc: add driver for Broadcom's PMB

In reply to Rafał Miłecki
Quoted 6 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

PMB can be found on BCM4908 and many other chipsets (e.g. BCM63138). It's needed to power on and off SoC blocks like PCIe, SATA, USB.

Since this is a driver for the PMB and not the PMC, the subject should probably reflect that.

Quoted 12 lines
---
 drivers/reset/Kconfig          |   7 +
 drivers/reset/Makefile         |   1 +
 drivers/reset/reset-brcm-pmb.c | 307 +++++++++++++++++++++++++++++++++
 3 files changed, 315 insertions(+)
 create mode 100644 drivers/reset/reset-brcm-pmb.c
drivers/reset/Kconfig +0 -0
index 84baec01aa30..af10fb92691c 100644

drivers/reset/Kconfig config RESET_BERLIN · line 46

Quoted 6 lines
drivers/reset/Kconfig +3 -0
@@ -41,6 +41,13 @@ config RESET_BERLIN
 	help
 	  This enables the reset controller driver for Marvell Berlin SoCs.
 
+config RESET_BRCM_PMB
+	tristate "Broadcom PMB reset controller"
+	depends on ARCH_BCM4908 || COMPILE_TEST

Not sure the depends on ARCH_BCM4908 is warranted here, but it certainly does not hurt to scope the driver to the platform it is applicable to.

[snip]

drivers/reset/Kconfig config RESET_BERLIN

Quoted 10 lines
drivers/reset/Kconfig +10 -0
+static int brcm_pmb_reset_xlate(struct reset_controller_dev *rcdev,
+				const struct of_phandle_args *reset_spec)
+{
+	u8 type = reset_spec->args[0];
+	u8 device = reset_spec->args[1];
+
+	if (type > 0xff)
+		return -EINVAL;
+
+	return (type << 8) | device;

Does not the device also need to be capped at 8 bits?

Quoted 13 lines
drivers/reset/Kconfig +13 -0
+}
+
+static const struct reset_control_ops brcm_pmb_reset_control_ops = {
+	.assert = brcm_pmb_assert,
+	.deassert = brcm_pmb_deassert,
+};
+
+static const struct of_device_id brcm_pmb_reset_of_match[] = {
+	{ .compatible = "brcm,bcm4908-pmb", .data = &brcm_pmb_4908_data, },
+	{ },
+};
+
+static int brcm_pmb_reset_probe(struct platform_device *pdev)

drivers/reset/Kconfig

Quoted 10 lines
drivers/reset/Kconfig +10 -0
+{
+	struct device *dev = &pdev->dev;
+	struct brcm_pmb *pmb;
+	struct resource *res;
+
+	pmb = devm_kzalloc(dev, sizeof(*pmb), GFP_KERNEL);
+	if (!pmb)
+		return -ENOMEM;
+
+	pmb->data = of_device_get_match_data(dev);

Not that it would likely support ACPI in the future but you can use device_get_match_data() to be firmware (OF or ACPI) implementation agnostic here.

Other than that, everything else looks good to me, thanks Rafal!

Signature · 1 line
Florian
#6 lore raw

Re: [PATCH 1/2] dt-bindings: reset: document Broadcom's PMB binding

In reply to Florian Fainelli
Quoted 11 lines · Florian Fainelli

Documentation/devicetree/bindings/reset/brcm,pmb.yaml line 51

Quoted 9 lines
Documentation/devicetree/bindings/reset/brcm,pmb.yaml new file +9 -0
+    pmb: reset-controller@802800e0 {
+        compatible = "brcm,bcm4908-pmb";
+        reg = <0x802800e0 0x20>;
+        #reset-cells = <2>;
+    };
+
+    foo {
+        resets = <&pmb BRCM_PMB_USB 17>;
+    }

You are missing a ';' here which is why the binding example did not build.

Ah, the very last minute fix... Thanks!

#5 lore raw

Re: [PATCH 1/2] dt-bindings: reset: document Broadcom's PMB binding

In reply to Florian Fainelli
Quoted 55 lines · Florian Fainelli
Quoted 54 lines · Florian Fainelli
Quoted 39 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Broadcom's PMB is reset controller used for disabling and enabling SoC devices.

---
 .../devicetree/bindings/reset/brcm,pmb.yaml   | 51 +++++++++++++++++++
 include/dt-bindings/reset/brcm,pmb.h          |  9 ++++
 2 files changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/brcm,pmb.yaml
 create mode 100644 include/dt-bindings/reset/brcm,pmb.h
Documentation/devicetree/bindings/reset/brcm,pmb.yaml new file +20 -0
new file mode 100644
index 000000000000..ea78ab629c45
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/reset/brcm,pmb.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom PMB Master reset controller
+
+description: This document describes Broadcom's PMB controller. It supports
+  resetting various types of connected devices (e.g. PCIe, USB, SATA). It
+  requires specifying device address.
+
+maintainers:
+  - Rafał Miłecki <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - brcm,bcm4908-pmb # PMB on BCM4908 and compatible SoCs
+

Documentation/devicetree/bindings/reset/brcm,pmb.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/reset/brcm,pmb.yaml new file +10 -0
+  reg:
+    maxItems: 1
+
+  big-endian:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Flag to use for block working in big endian mode.
+
+  "#reset-cells":
+    const: 2

I believe we would need a description of the #reset-cells property that indicates what they do.

Quoted 5 lines
Quoted 1 line

Other than that and the build failure below:

I don't know how to express constraints on each of the cells, but since they are represented by 8 bits you may want to add mininimum: 0 /
maximum: 255 constraints in the YAML binding.

I don't think there is syntax for that, I'll just use descriptions as other bindings do.

Signature · 1 line
Rafał