All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] soc: bcm2835-power: Prepare BCM2711 V3D support
@ 2022-05-15 20:20 ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

This series is a split out of version 4 - Raspberry PI 4 V3D enablement send
by Peter Robinson [1]. It attemps to enable BCM2711 V3D support for the
power management driver. It's a rework of the less controversial changes
(excluding V3D GPU driver changes) so this can be reviewed and applied faster.

The changes has been tested just superficial on RPi 3B+ and 4B, so further
tester are welcome.

Changes since the mention series:
- fix DT schema errors
- make rpivid_asb register optional in DT schema
- avoid code duplication in BCM2835 ASB enable/disable
- rework ASB V3D handling so we don't need the V3D flag
- avoid log errors for optional register
- use a define for expected ASB_AXI_BRDG_ID result
- fix copy & paste issues in bcm2835-pm changes

[1] - https://patchwork.kernel.org/project/linux-arm-kernel/cover/20220213225646.67761-1-pbrobinson@gmail.com/

Nicolas Saenz Julienne (6):
  dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema
  dt-bindings: soc: bcm: bcm2835-pm: Introduce reg-names
  ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node
  ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node
  mfd: bcm2835-pm: Use 'reg-names' to get resources
  soc: bcm: bcm2835-power: Bypass power_on/off() calls

Stefan Wahren (5):
  dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711
  mfd: bcm2835-pm: Add support for BCM2711
  soc: bcm: bcm2835-power: Refactor ASB control
  soc: bcm: bcm2835-power: Resolve ASB register macros
  soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB

 .../bindings/soc/bcm/brcm,bcm2835-pm.txt      | 46 ----------
 .../bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 89 +++++++++++++++++++
 arch/arm/boot/dts/bcm2711.dtsi                |  3 +-
 arch/arm/boot/dts/bcm2835-common.dtsi         |  1 +
 drivers/mfd/bcm2835-pm.c                      | 77 ++++++++++++----
 drivers/soc/bcm/bcm2835-power.c               | 72 ++++++++++-----
 include/linux/mfd/bcm2835-pm.h                |  1 +
 7 files changed, 199 insertions(+), 90 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt
 create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml

-- 
2.25.1


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

* [PATCH 00/11] soc: bcm2835-power: Prepare BCM2711 V3D support
@ 2022-05-15 20:20 ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

This series is a split out of version 4 - Raspberry PI 4 V3D enablement send
by Peter Robinson [1]. It attemps to enable BCM2711 V3D support for the
power management driver. It's a rework of the less controversial changes
(excluding V3D GPU driver changes) so this can be reviewed and applied faster.

The changes has been tested just superficial on RPi 3B+ and 4B, so further
tester are welcome.

Changes since the mention series:
- fix DT schema errors
- make rpivid_asb register optional in DT schema
- avoid code duplication in BCM2835 ASB enable/disable
- rework ASB V3D handling so we don't need the V3D flag
- avoid log errors for optional register
- use a define for expected ASB_AXI_BRDG_ID result
- fix copy & paste issues in bcm2835-pm changes

[1] - https://patchwork.kernel.org/project/linux-arm-kernel/cover/20220213225646.67761-1-pbrobinson@gmail.com/

Nicolas Saenz Julienne (6):
  dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema
  dt-bindings: soc: bcm: bcm2835-pm: Introduce reg-names
  ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node
  ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node
  mfd: bcm2835-pm: Use 'reg-names' to get resources
  soc: bcm: bcm2835-power: Bypass power_on/off() calls

Stefan Wahren (5):
  dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711
  mfd: bcm2835-pm: Add support for BCM2711
  soc: bcm: bcm2835-power: Refactor ASB control
  soc: bcm: bcm2835-power: Resolve ASB register macros
  soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB

 .../bindings/soc/bcm/brcm,bcm2835-pm.txt      | 46 ----------
 .../bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 89 +++++++++++++++++++
 arch/arm/boot/dts/bcm2711.dtsi                |  3 +-
 arch/arm/boot/dts/bcm2835-common.dtsi         |  1 +
 drivers/mfd/bcm2835-pm.c                      | 77 ++++++++++++----
 drivers/soc/bcm/bcm2835-power.c               | 72 ++++++++++-----
 include/linux/mfd/bcm2835-pm.h                |  1 +
 7 files changed, 199 insertions(+), 90 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt
 create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml

-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 01/11] dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-15 20:20   ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Rob Herring, Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

This converts the brcm,bcm2835-pm bindings from text to proper schema.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 .../bindings/soc/bcm/brcm,bcm2835-pm.txt      | 46 -----------
 .../bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 77 +++++++++++++++++++
 2 files changed, 77 insertions(+), 46 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt
 create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml

diff --git a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt
deleted file mode 100644
index 72ff033565e5..000000000000
--- a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-BCM2835 PM (Power domains, watchdog)
-
-The PM block controls power domains and some reset lines, and includes
-a watchdog timer.  This binding supersedes the brcm,bcm2835-pm-wdt
-binding which covered some of PM's register range and functionality.
-
-Required properties:
-
-- compatible:		Should be "brcm,bcm2835-pm"
-- reg:			Specifies base physical address and size of the two
-			  register ranges ("PM" and "ASYNC_BRIDGE" in that
-			  order)
-- clocks:		a) v3d: The V3D clock from CPRMAN
-			b) peri_image: The PERI_IMAGE clock from CPRMAN
-			c) h264: The H264 clock from CPRMAN
-			d) isp: The ISP clock from CPRMAN
-- #reset-cells: 	Should be 1.  This property follows the reset controller
-			  bindings[1].
-- #power-domain-cells:	Should be 1.  This property follows the power domain
-			  bindings[2].
-
-Optional properties:
-
-- timeout-sec:		Contains the watchdog timeout in seconds
-- system-power-controller: Whether the watchdog is controlling the
-    system power.  This node follows the power controller bindings[3].
-
-[1] Documentation/devicetree/bindings/reset/reset.txt
-[2] Documentation/devicetree/bindings/power/power-domain.yaml
-[3] Documentation/devicetree/bindings/power/power-controller.txt
-
-Example:
-
-pm {
-	compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt";
-	#power-domain-cells = <1>;
-	#reset-cells = <1>;
-	reg = <0x7e100000 0x114>,
-	      <0x7e00a000 0x24>;
-	clocks = <&clocks BCM2835_CLOCK_V3D>,
-		 <&clocks BCM2835_CLOCK_PERI_IMAGE>,
-		 <&clocks BCM2835_CLOCK_H264>,
-		 <&clocks BCM2835_CLOCK_ISP>;
-	clock-names = "v3d", "peri_image", "h264", "isp";
-	system-power-controller;
-};
diff --git a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
new file mode 100644
index 000000000000..5d1ff0f6c8ce
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/soc/bcm/brcm,bcm2835-pm.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: BCM2835 PM (Power domains, watchdog)
+
+description: |
+  The PM block controls power domains and some reset lines, and includes a
+  watchdog timer.
+
+maintainers:
+  - Nicolas Saenz Julienne <nsaenz@kernel.org>
+
+allOf:
+  - $ref: ../../watchdog/watchdog.yaml#
+
+properties:
+  compatible:
+    items:
+      - const: brcm,bcm2835-pm
+      - const: brcm,bcm2835-pm-wdt
+
+  reg:
+    items:
+      - description: PM registers
+      - description: ASB registers
+
+  "#power-domain-cells":
+    const: 1
+
+  "#reset-cells":
+    const: 1
+
+  clocks:
+    minItems: 4
+    maxItems: 4
+
+  clock-names:
+    items:
+      - const: v3d
+      - const: peri_image
+      - const: h264
+      - const: isp
+
+  system-power-controller:
+    type: boolean
+
+  timeout-sec: true
+
+required:
+  - compatible
+  - reg
+  - "#power-domain-cells"
+  - "#reset-cells"
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/bcm2835.h>
+
+    watchdog@7e100000 {
+        compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt";
+        #power-domain-cells = <1>;
+        #reset-cells = <1>;
+        reg = <0x7e100000 0x114>,
+              <0x7e00a000 0x24>;
+        clocks = <&clocks BCM2835_CLOCK_V3D>,
+               <&clocks BCM2835_CLOCK_PERI_IMAGE>,
+               <&clocks BCM2835_CLOCK_H264>,
+               <&clocks BCM2835_CLOCK_ISP>;
+        clock-names = "v3d", "peri_image", "h264", "isp";
+        system-power-controller;
+    };
-- 
2.25.1


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

* [PATCH 01/11] dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema
@ 2022-05-15 20:20   ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Rob Herring, Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

This converts the brcm,bcm2835-pm bindings from text to proper schema.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 .../bindings/soc/bcm/brcm,bcm2835-pm.txt      | 46 -----------
 .../bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 77 +++++++++++++++++++
 2 files changed, 77 insertions(+), 46 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt
 create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml

diff --git a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt
deleted file mode 100644
index 72ff033565e5..000000000000
--- a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-BCM2835 PM (Power domains, watchdog)
-
-The PM block controls power domains and some reset lines, and includes
-a watchdog timer.  This binding supersedes the brcm,bcm2835-pm-wdt
-binding which covered some of PM's register range and functionality.
-
-Required properties:
-
-- compatible:		Should be "brcm,bcm2835-pm"
-- reg:			Specifies base physical address and size of the two
-			  register ranges ("PM" and "ASYNC_BRIDGE" in that
-			  order)
-- clocks:		a) v3d: The V3D clock from CPRMAN
-			b) peri_image: The PERI_IMAGE clock from CPRMAN
-			c) h264: The H264 clock from CPRMAN
-			d) isp: The ISP clock from CPRMAN
-- #reset-cells: 	Should be 1.  This property follows the reset controller
-			  bindings[1].
-- #power-domain-cells:	Should be 1.  This property follows the power domain
-			  bindings[2].
-
-Optional properties:
-
-- timeout-sec:		Contains the watchdog timeout in seconds
-- system-power-controller: Whether the watchdog is controlling the
-    system power.  This node follows the power controller bindings[3].
-
-[1] Documentation/devicetree/bindings/reset/reset.txt
-[2] Documentation/devicetree/bindings/power/power-domain.yaml
-[3] Documentation/devicetree/bindings/power/power-controller.txt
-
-Example:
-
-pm {
-	compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt";
-	#power-domain-cells = <1>;
-	#reset-cells = <1>;
-	reg = <0x7e100000 0x114>,
-	      <0x7e00a000 0x24>;
-	clocks = <&clocks BCM2835_CLOCK_V3D>,
-		 <&clocks BCM2835_CLOCK_PERI_IMAGE>,
-		 <&clocks BCM2835_CLOCK_H264>,
-		 <&clocks BCM2835_CLOCK_ISP>;
-	clock-names = "v3d", "peri_image", "h264", "isp";
-	system-power-controller;
-};
diff --git a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
new file mode 100644
index 000000000000..5d1ff0f6c8ce
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/soc/bcm/brcm,bcm2835-pm.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: BCM2835 PM (Power domains, watchdog)
+
+description: |
+  The PM block controls power domains and some reset lines, and includes a
+  watchdog timer.
+
+maintainers:
+  - Nicolas Saenz Julienne <nsaenz@kernel.org>
+
+allOf:
+  - $ref: ../../watchdog/watchdog.yaml#
+
+properties:
+  compatible:
+    items:
+      - const: brcm,bcm2835-pm
+      - const: brcm,bcm2835-pm-wdt
+
+  reg:
+    items:
+      - description: PM registers
+      - description: ASB registers
+
+  "#power-domain-cells":
+    const: 1
+
+  "#reset-cells":
+    const: 1
+
+  clocks:
+    minItems: 4
+    maxItems: 4
+
+  clock-names:
+    items:
+      - const: v3d
+      - const: peri_image
+      - const: h264
+      - const: isp
+
+  system-power-controller:
+    type: boolean
+
+  timeout-sec: true
+
+required:
+  - compatible
+  - reg
+  - "#power-domain-cells"
+  - "#reset-cells"
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/bcm2835.h>
+
+    watchdog@7e100000 {
+        compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt";
+        #power-domain-cells = <1>;
+        #reset-cells = <1>;
+        reg = <0x7e100000 0x114>,
+              <0x7e00a000 0x24>;
+        clocks = <&clocks BCM2835_CLOCK_V3D>,
+               <&clocks BCM2835_CLOCK_PERI_IMAGE>,
+               <&clocks BCM2835_CLOCK_H264>,
+               <&clocks BCM2835_CLOCK_ISP>;
+        clock-names = "v3d", "peri_image", "h264", "isp";
+        system-power-controller;
+    };
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 02/11] dt-bindings: soc: bcm: bcm2835-pm: Introduce reg-names
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-15 20:20   ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Rob Herring, Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

Anticipating the introduction of BCM2711, of which we'll need to support
its new RPiVid ASB, introduce reg-names into bcm2835-pm's binding. This
will help to have a consistent mapping between resources and their
meaning.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 .../devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
index 5d1ff0f6c8ce..883ab7cb96e9 100644
--- a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
+++ b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
@@ -23,9 +23,13 @@ properties:
       - const: brcm,bcm2835-pm-wdt
 
   reg:
+    minItems: 2
+    maxItems: 2
+
+  reg-names:
     items:
-      - description: PM registers
-      - description: ASB registers
+      - const: pm
+      - const: asb
 
   "#power-domain-cells":
     const: 1
@@ -68,6 +72,7 @@ examples:
         #reset-cells = <1>;
         reg = <0x7e100000 0x114>,
               <0x7e00a000 0x24>;
+        reg-names = "pm", "asb";
         clocks = <&clocks BCM2835_CLOCK_V3D>,
                <&clocks BCM2835_CLOCK_PERI_IMAGE>,
                <&clocks BCM2835_CLOCK_H264>,
-- 
2.25.1


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

* [PATCH 02/11] dt-bindings: soc: bcm: bcm2835-pm: Introduce reg-names
@ 2022-05-15 20:20   ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Rob Herring, Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

Anticipating the introduction of BCM2711, of which we'll need to support
its new RPiVid ASB, introduce reg-names into bcm2835-pm's binding. This
will help to have a consistent mapping between resources and their
meaning.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 .../devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
index 5d1ff0f6c8ce..883ab7cb96e9 100644
--- a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
+++ b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
@@ -23,9 +23,13 @@ properties:
       - const: brcm,bcm2835-pm-wdt
 
   reg:
+    minItems: 2
+    maxItems: 2
+
+  reg-names:
     items:
-      - description: PM registers
-      - description: ASB registers
+      - const: pm
+      - const: asb
 
   "#power-domain-cells":
     const: 1
@@ -68,6 +72,7 @@ examples:
         #reset-cells = <1>;
         reg = <0x7e100000 0x114>,
               <0x7e00a000 0x24>;
+        reg-names = "pm", "asb";
         clocks = <&clocks BCM2835_CLOCK_V3D>,
                <&clocks BCM2835_CLOCK_PERI_IMAGE>,
                <&clocks BCM2835_CLOCK_H264>,
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 03/11] dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-15 20:20   ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

Add a new compatible string for BCM2711 and the option to provide a
third reg property for the board's new RPiVid ASB.

In BCM2711 the new RPiVid ASB took over V3D, which is our only consumer
of this driver so far. The old ASB is still be present with ISP and H264
bits but no V3D.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 .../bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
index 883ab7cb96e9..e13ce98d1753 100644
--- a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
+++ b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
@@ -19,17 +19,24 @@ allOf:
 properties:
   compatible:
     items:
-      - const: brcm,bcm2835-pm
+      - enum:
+          - brcm,bcm2835-pm
+          - brcm,bcm2711-pm
       - const: brcm,bcm2835-pm-wdt
 
   reg:
-    minItems: 2
-    maxItems: 2
+    minItems: 1
+    maxItems: 3
 
   reg-names:
-    items:
-      - const: pm
-      - const: asb
+    oneOf:
+      - items:
+          - const: pm
+          - const: asb
+      - items:
+          - const: pm
+          - const: asb
+          - const: rpivid_asb
 
   "#power-domain-cells":
     const: 1
-- 
2.25.1


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

* [PATCH 03/11] dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711
@ 2022-05-15 20:20   ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

Add a new compatible string for BCM2711 and the option to provide a
third reg property for the board's new RPiVid ASB.

In BCM2711 the new RPiVid ASB took over V3D, which is our only consumer
of this driver so far. The old ASB is still be present with ISP and H264
bits but no V3D.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 .../bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
index 883ab7cb96e9..e13ce98d1753 100644
--- a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
+++ b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
@@ -19,17 +19,24 @@ allOf:
 properties:
   compatible:
     items:
-      - const: brcm,bcm2835-pm
+      - enum:
+          - brcm,bcm2835-pm
+          - brcm,bcm2711-pm
       - const: brcm,bcm2835-pm-wdt
 
   reg:
-    minItems: 2
-    maxItems: 2
+    minItems: 1
+    maxItems: 3
 
   reg-names:
-    items:
-      - const: pm
-      - const: asb
+    oneOf:
+      - items:
+          - const: pm
+          - const: asb
+      - items:
+          - const: pm
+          - const: asb
+          - const: rpivid_asb
 
   "#power-domain-cells":
     const: 1
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 04/11] ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-15 20:20   ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

bcm2835-pm's bindings now support explicitly setting 'reg-names,' so use
them.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 arch/arm/boot/dts/bcm2711.dtsi        | 1 +
 arch/arm/boot/dts/bcm2835-common.dtsi | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
index 89af57482bc8..cbb47e2c9434 100644
--- a/arch/arm/boot/dts/bcm2711.dtsi
+++ b/arch/arm/boot/dts/bcm2711.dtsi
@@ -113,6 +113,7 @@ pm: watchdog@7e100000 {
 			reg = <0x7e100000 0x114>,
 			      <0x7e00a000 0x24>,
 			      <0x7ec11000 0x20>;
+			reg-names = "pm", "asb", "rpivid_asb";
 			clocks = <&clocks BCM2835_CLOCK_V3D>,
 				 <&clocks BCM2835_CLOCK_PERI_IMAGE>,
 				 <&clocks BCM2835_CLOCK_H264>,
diff --git a/arch/arm/boot/dts/bcm2835-common.dtsi b/arch/arm/boot/dts/bcm2835-common.dtsi
index c25e797b9060..a037d2bc5b11 100644
--- a/arch/arm/boot/dts/bcm2835-common.dtsi
+++ b/arch/arm/boot/dts/bcm2835-common.dtsi
@@ -62,6 +62,7 @@ pm: watchdog@7e100000 {
 			#reset-cells = <1>;
 			reg = <0x7e100000 0x114>,
 			      <0x7e00a000 0x24>;
+			reg-names = "pm", "asb";
 			clocks = <&clocks BCM2835_CLOCK_V3D>,
 				 <&clocks BCM2835_CLOCK_PERI_IMAGE>,
 				 <&clocks BCM2835_CLOCK_H264>,
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 04/11] ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node
@ 2022-05-15 20:20   ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

bcm2835-pm's bindings now support explicitly setting 'reg-names,' so use
them.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 arch/arm/boot/dts/bcm2711.dtsi        | 1 +
 arch/arm/boot/dts/bcm2835-common.dtsi | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
index 89af57482bc8..cbb47e2c9434 100644
--- a/arch/arm/boot/dts/bcm2711.dtsi
+++ b/arch/arm/boot/dts/bcm2711.dtsi
@@ -113,6 +113,7 @@ pm: watchdog@7e100000 {
 			reg = <0x7e100000 0x114>,
 			      <0x7e00a000 0x24>,
 			      <0x7ec11000 0x20>;
+			reg-names = "pm", "asb", "rpivid_asb";
 			clocks = <&clocks BCM2835_CLOCK_V3D>,
 				 <&clocks BCM2835_CLOCK_PERI_IMAGE>,
 				 <&clocks BCM2835_CLOCK_H264>,
diff --git a/arch/arm/boot/dts/bcm2835-common.dtsi b/arch/arm/boot/dts/bcm2835-common.dtsi
index c25e797b9060..a037d2bc5b11 100644
--- a/arch/arm/boot/dts/bcm2835-common.dtsi
+++ b/arch/arm/boot/dts/bcm2835-common.dtsi
@@ -62,6 +62,7 @@ pm: watchdog@7e100000 {
 			#reset-cells = <1>;
 			reg = <0x7e100000 0x114>,
 			      <0x7e00a000 0x24>;
+			reg-names = "pm", "asb";
 			clocks = <&clocks BCM2835_CLOCK_V3D>,
 				 <&clocks BCM2835_CLOCK_PERI_IMAGE>,
 				 <&clocks BCM2835_CLOCK_H264>,
-- 
2.25.1


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

* [PATCH 05/11] ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-15 20:20   ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

A new compatible string was introduced specifically for BCM2711, so make
use of it.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 arch/arm/boot/dts/bcm2711.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
index cbb47e2c9434..5eca5207c212 100644
--- a/arch/arm/boot/dts/bcm2711.dtsi
+++ b/arch/arm/boot/dts/bcm2711.dtsi
@@ -107,7 +107,7 @@ dma: dma@7e007000 {
 		};
 
 		pm: watchdog@7e100000 {
-			compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt";
+			compatible = "brcm,bcm2711-pm", "brcm,bcm2835-pm-wdt";
 			#power-domain-cells = <1>;
 			#reset-cells = <1>;
 			reg = <0x7e100000 0x114>,
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 05/11] ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node
@ 2022-05-15 20:20   ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

A new compatible string was introduced specifically for BCM2711, so make
use of it.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 arch/arm/boot/dts/bcm2711.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
index cbb47e2c9434..5eca5207c212 100644
--- a/arch/arm/boot/dts/bcm2711.dtsi
+++ b/arch/arm/boot/dts/bcm2711.dtsi
@@ -107,7 +107,7 @@ dma: dma@7e007000 {
 		};
 
 		pm: watchdog@7e100000 {
-			compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt";
+			compatible = "brcm,bcm2711-pm", "brcm,bcm2835-pm-wdt";
 			#power-domain-cells = <1>;
 			#reset-cells = <1>;
 			reg = <0x7e100000 0x114>,
-- 
2.25.1


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

* [PATCH 06/11] mfd: bcm2835-pm: Use 'reg-names' to get resources
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-15 20:20   ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

If available in firmware, find resources by their 'reg-names' position
instead of relying on hardcoded offsets. Care is taken to support old
firmware nonetheless.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/mfd/bcm2835-pm.c | 59 +++++++++++++++++++++++++++-------------
 1 file changed, 40 insertions(+), 19 deletions(-)

diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
index 42fe67f1538e..1656d786993a 100644
--- a/drivers/mfd/bcm2835-pm.c
+++ b/drivers/mfd/bcm2835-pm.c
@@ -25,9 +25,41 @@ static const struct mfd_cell bcm2835_power_devs[] = {
 	{ .name = "bcm2835-power" },
 };
 
+static int bcm2835_pm_get_pdata(struct platform_device *pdev,
+				struct bcm2835_pm *pm)
+{
+	/* If no 'reg-names' property is found we can assume we're using old
+	 * firmware.
+	 */
+	if (!of_find_property(pm->dev->of_node, "reg-names", NULL)) {
+		dev_warn(pm->dev, "Old devicetree detected, please update your firmware.\n");
+
+		pm->base = devm_platform_ioremap_resource(pdev, 0);
+		if (IS_ERR(pm->base))
+			return PTR_ERR(pm->base);
+
+		pm->asb = devm_platform_ioremap_resource(pdev, 1);
+	} else {
+		struct resource *res;
+
+		pm->base = devm_platform_ioremap_resource_byname(pdev, "pm");
+		if (IS_ERR(pm->base))
+			return PTR_ERR(pm->base);
+
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+						    "asb");
+		if (res)
+			pm->asb = devm_ioremap_resource(&pdev->dev, res);
+	}
+
+	if (IS_ERR(pm->asb))
+		pm->asb = NULL;
+
+	return 0;
+}
+
 static int bcm2835_pm_probe(struct platform_device *pdev)
 {
-	struct resource *res;
 	struct device *dev = &pdev->dev;
 	struct bcm2835_pm *pm;
 	int ret;
@@ -39,10 +71,9 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
 
 	pm->dev = dev;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	pm->base = devm_ioremap_resource(dev, res);
-	if (IS_ERR(pm->base))
-		return PTR_ERR(pm->base);
+	ret = bcm2835_pm_get_pdata(pdev, pm);
+	if (ret)
+		return ret;
 
 	ret = devm_mfd_add_devices(dev, -1,
 				   bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs),
@@ -54,20 +85,10 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
 	 * bcm2835-pm binding as the key for whether we can reference
 	 * the full PM register range and support power domains.
 	 */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	if (res) {
-		pm->asb = devm_ioremap_resource(dev, res);
-		if (IS_ERR(pm->asb))
-			return PTR_ERR(pm->asb);
-
-		ret = devm_mfd_add_devices(dev, -1,
-					   bcm2835_power_devs,
-					   ARRAY_SIZE(bcm2835_power_devs),
-					   NULL, 0, NULL);
-		if (ret)
-			return ret;
-	}
-
+	if (pm->asb)
+		return devm_mfd_add_devices(dev, -1, bcm2835_power_devs,
+					    ARRAY_SIZE(bcm2835_power_devs),
+					    NULL, 0, NULL);
 	return 0;
 }
 
-- 
2.25.1


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

* [PATCH 06/11] mfd: bcm2835-pm: Use 'reg-names' to get resources
@ 2022-05-15 20:20   ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

If available in firmware, find resources by their 'reg-names' position
instead of relying on hardcoded offsets. Care is taken to support old
firmware nonetheless.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/mfd/bcm2835-pm.c | 59 +++++++++++++++++++++++++++-------------
 1 file changed, 40 insertions(+), 19 deletions(-)

diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
index 42fe67f1538e..1656d786993a 100644
--- a/drivers/mfd/bcm2835-pm.c
+++ b/drivers/mfd/bcm2835-pm.c
@@ -25,9 +25,41 @@ static const struct mfd_cell bcm2835_power_devs[] = {
 	{ .name = "bcm2835-power" },
 };
 
+static int bcm2835_pm_get_pdata(struct platform_device *pdev,
+				struct bcm2835_pm *pm)
+{
+	/* If no 'reg-names' property is found we can assume we're using old
+	 * firmware.
+	 */
+	if (!of_find_property(pm->dev->of_node, "reg-names", NULL)) {
+		dev_warn(pm->dev, "Old devicetree detected, please update your firmware.\n");
+
+		pm->base = devm_platform_ioremap_resource(pdev, 0);
+		if (IS_ERR(pm->base))
+			return PTR_ERR(pm->base);
+
+		pm->asb = devm_platform_ioremap_resource(pdev, 1);
+	} else {
+		struct resource *res;
+
+		pm->base = devm_platform_ioremap_resource_byname(pdev, "pm");
+		if (IS_ERR(pm->base))
+			return PTR_ERR(pm->base);
+
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+						    "asb");
+		if (res)
+			pm->asb = devm_ioremap_resource(&pdev->dev, res);
+	}
+
+	if (IS_ERR(pm->asb))
+		pm->asb = NULL;
+
+	return 0;
+}
+
 static int bcm2835_pm_probe(struct platform_device *pdev)
 {
-	struct resource *res;
 	struct device *dev = &pdev->dev;
 	struct bcm2835_pm *pm;
 	int ret;
@@ -39,10 +71,9 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
 
 	pm->dev = dev;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	pm->base = devm_ioremap_resource(dev, res);
-	if (IS_ERR(pm->base))
-		return PTR_ERR(pm->base);
+	ret = bcm2835_pm_get_pdata(pdev, pm);
+	if (ret)
+		return ret;
 
 	ret = devm_mfd_add_devices(dev, -1,
 				   bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs),
@@ -54,20 +85,10 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
 	 * bcm2835-pm binding as the key for whether we can reference
 	 * the full PM register range and support power domains.
 	 */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	if (res) {
-		pm->asb = devm_ioremap_resource(dev, res);
-		if (IS_ERR(pm->asb))
-			return PTR_ERR(pm->asb);
-
-		ret = devm_mfd_add_devices(dev, -1,
-					   bcm2835_power_devs,
-					   ARRAY_SIZE(bcm2835_power_devs),
-					   NULL, 0, NULL);
-		if (ret)
-			return ret;
-	}
-
+	if (pm->asb)
+		return devm_mfd_add_devices(dev, -1, bcm2835_power_devs,
+					    ARRAY_SIZE(bcm2835_power_devs),
+					    NULL, 0, NULL);
 	return 0;
 }
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-15 20:20   ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
with the ISP and H264 bits, and V3D is in the same place in the new ASB
as the old one.

As per the devicetree bindings, BCM2711 will provide both the old and
new ASB resources, so get both of them and pass them into
'bcm2835-power,' which will take care of selecting which one to use
accordingly.

Since the RPiVid ASB's resources were being provided prior to formalizing
the bindings[1], also support the old firmwares that didn't use
'reg-names.'

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
 include/linux/mfd/bcm2835-pm.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
index 1656d786993a..da110767c6a4 100644
--- a/drivers/mfd/bcm2835-pm.c
+++ b/drivers/mfd/bcm2835-pm.c
@@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
 static int bcm2835_pm_get_pdata(struct platform_device *pdev,
 				struct bcm2835_pm *pm)
 {
+	bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
+
 	/* If no 'reg-names' property is found we can assume we're using old
 	 * firmware.
 	 */
@@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
 			return PTR_ERR(pm->base);
 
 		pm->asb = devm_platform_ioremap_resource(pdev, 1);
+		pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
 	} else {
 		struct resource *res;
 
@@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
 						    "asb");
 		if (res)
 			pm->asb = devm_ioremap_resource(&pdev->dev, res);
+
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+						    "rpivid_asb");
+		if (res)
+			pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
+								res);
 	}
 
 	if (IS_ERR(pm->asb))
 		pm->asb = NULL;
 
+	if (IS_ERR(pm->rpivid_asb))
+		pm->rpivid_asb = NULL;
+
+	if (pm->rpivid_asb && !is_bcm2711) {
+		dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");
+		return -EINVAL;
+	}
+
 	return 0;
 }
 
@@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
 static const struct of_device_id bcm2835_pm_of_match[] = {
 	{ .compatible = "brcm,bcm2835-pm-wdt", },
 	{ .compatible = "brcm,bcm2835-pm", },
+	{ .compatible = "brcm,bcm2711-pm", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
index ed37dc40e82a..f70a810c55f7 100644
--- a/include/linux/mfd/bcm2835-pm.h
+++ b/include/linux/mfd/bcm2835-pm.h
@@ -9,6 +9,7 @@ struct bcm2835_pm {
 	struct device *dev;
 	void __iomem *base;
 	void __iomem *asb;
+	void __iomem *rpivid_asb;
 };
 
 #endif /* BCM2835_MFD_PM_H */
-- 
2.25.1


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

* [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
@ 2022-05-15 20:20   ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
with the ISP and H264 bits, and V3D is in the same place in the new ASB
as the old one.

As per the devicetree bindings, BCM2711 will provide both the old and
new ASB resources, so get both of them and pass them into
'bcm2835-power,' which will take care of selecting which one to use
accordingly.

Since the RPiVid ASB's resources were being provided prior to formalizing
the bindings[1], also support the old firmwares that didn't use
'reg-names.'

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
 include/linux/mfd/bcm2835-pm.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
index 1656d786993a..da110767c6a4 100644
--- a/drivers/mfd/bcm2835-pm.c
+++ b/drivers/mfd/bcm2835-pm.c
@@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
 static int bcm2835_pm_get_pdata(struct platform_device *pdev,
 				struct bcm2835_pm *pm)
 {
+	bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
+
 	/* If no 'reg-names' property is found we can assume we're using old
 	 * firmware.
 	 */
@@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
 			return PTR_ERR(pm->base);
 
 		pm->asb = devm_platform_ioremap_resource(pdev, 1);
+		pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
 	} else {
 		struct resource *res;
 
@@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
 						    "asb");
 		if (res)
 			pm->asb = devm_ioremap_resource(&pdev->dev, res);
+
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+						    "rpivid_asb");
+		if (res)
+			pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
+								res);
 	}
 
 	if (IS_ERR(pm->asb))
 		pm->asb = NULL;
 
+	if (IS_ERR(pm->rpivid_asb))
+		pm->rpivid_asb = NULL;
+
+	if (pm->rpivid_asb && !is_bcm2711) {
+		dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");
+		return -EINVAL;
+	}
+
 	return 0;
 }
 
@@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
 static const struct of_device_id bcm2835_pm_of_match[] = {
 	{ .compatible = "brcm,bcm2835-pm-wdt", },
 	{ .compatible = "brcm,bcm2835-pm", },
+	{ .compatible = "brcm,bcm2711-pm", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
index ed37dc40e82a..f70a810c55f7 100644
--- a/include/linux/mfd/bcm2835-pm.h
+++ b/include/linux/mfd/bcm2835-pm.h
@@ -9,6 +9,7 @@ struct bcm2835_pm {
 	struct device *dev;
 	void __iomem *base;
 	void __iomem *asb;
+	void __iomem *rpivid_asb;
 };
 
 #endif /* BCM2835_MFD_PM_H */
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 08/11] soc: bcm: bcm2835-power: Refactor ASB control
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-15 20:20   ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

The functions to control the async AXI bridges are almost identical.
So define a general function to handle it and keep the original ones as
wrapper. This should make this driver easier to extend.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/soc/bcm/bcm2835-power.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
index 1e0041ec8132..77dc9e62b207 100644
--- a/drivers/soc/bcm/bcm2835-power.c
+++ b/drivers/soc/bcm/bcm2835-power.c
@@ -148,7 +148,7 @@ struct bcm2835_power {
 	struct reset_controller_dev reset;
 };
 
-static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
+static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
 {
 	u64 start;
 
@@ -158,7 +158,12 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
 	start = ktime_get_ns();
 
 	/* Enable the module's async AXI bridges. */
-	ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
+	if (enable) {
+		ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
+	} else {
+		ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
+	}
+
 	while (ASB_READ(reg) & ASB_ACK) {
 		cpu_relax();
 		if (ktime_get_ns() - start >= 1000)
@@ -168,24 +173,14 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
 	return 0;
 }
 
-static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
+static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
 {
-	u64 start;
-
-	if (!reg)
-		return 0;
-
-	start = ktime_get_ns();
-
-	/* Enable the module's async AXI bridges. */
-	ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
-	while (!(ASB_READ(reg) & ASB_ACK)) {
-		cpu_relax();
-		if (ktime_get_ns() - start >= 1000)
-			return -ETIMEDOUT;
-	}
+	return bcm2835_asb_control(power, reg, true);
+}
 
-	return 0;
+static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
+{
+	return bcm2835_asb_control(power, reg, false);
 }
 
 static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)
-- 
2.25.1


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

* [PATCH 08/11] soc: bcm: bcm2835-power: Refactor ASB control
@ 2022-05-15 20:20   ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

The functions to control the async AXI bridges are almost identical.
So define a general function to handle it and keep the original ones as
wrapper. This should make this driver easier to extend.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/soc/bcm/bcm2835-power.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
index 1e0041ec8132..77dc9e62b207 100644
--- a/drivers/soc/bcm/bcm2835-power.c
+++ b/drivers/soc/bcm/bcm2835-power.c
@@ -148,7 +148,7 @@ struct bcm2835_power {
 	struct reset_controller_dev reset;
 };
 
-static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
+static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
 {
 	u64 start;
 
@@ -158,7 +158,12 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
 	start = ktime_get_ns();
 
 	/* Enable the module's async AXI bridges. */
-	ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
+	if (enable) {
+		ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
+	} else {
+		ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
+	}
+
 	while (ASB_READ(reg) & ASB_ACK) {
 		cpu_relax();
 		if (ktime_get_ns() - start >= 1000)
@@ -168,24 +173,14 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
 	return 0;
 }
 
-static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
+static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
 {
-	u64 start;
-
-	if (!reg)
-		return 0;
-
-	start = ktime_get_ns();
-
-	/* Enable the module's async AXI bridges. */
-	ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
-	while (!(ASB_READ(reg) & ASB_ACK)) {
-		cpu_relax();
-		if (ktime_get_ns() - start >= 1000)
-			return -ETIMEDOUT;
-	}
+	return bcm2835_asb_control(power, reg, true);
+}
 
-	return 0;
+static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
+{
+	return bcm2835_asb_control(power, reg, false);
 }
 
 static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 09/11] soc: bcm: bcm2835-power: Resolve ASB register macros
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-15 20:20   ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

The macros in order to access the ASB registers have a hard coded base
address. So extending them for other platforms would make them harder
to read. As a solution resolve these macros.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/soc/bcm/bcm2835-power.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
index 77dc9e62b207..fa0a13035794 100644
--- a/drivers/soc/bcm/bcm2835-power.c
+++ b/drivers/soc/bcm/bcm2835-power.c
@@ -126,9 +126,6 @@
 
 #define ASB_AXI_BRDG_ID			0x20
 
-#define ASB_READ(reg) readl(power->asb + (reg))
-#define ASB_WRITE(reg, val) writel(PM_PASSWORD | (val), power->asb + (reg))
-
 struct bcm2835_power_domain {
 	struct generic_pm_domain base;
 	struct bcm2835_power *power;
@@ -150,7 +147,10 @@ struct bcm2835_power {
 
 static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
 {
+	void __iomem *base = power->asb;
 	u64 start;
+	u32 val;
+
 
 	if (!reg)
 		return 0;
@@ -159,12 +159,13 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
 
 	/* Enable the module's async AXI bridges. */
 	if (enable) {
-		ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
+		val = readl(base + reg) & ~ASB_REQ_STOP;
 	} else {
-		ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
+		val = readl(base + reg) | ASB_REQ_STOP;
 	}
+	writel(PM_PASSWORD | val, base + reg);
 
-	while (ASB_READ(reg) & ASB_ACK) {
+	while (readl(base + reg) & ASB_ACK) {
 		cpu_relax();
 		if (ktime_get_ns() - start >= 1000)
 			return -ETIMEDOUT;
@@ -622,7 +623,7 @@ static int bcm2835_power_probe(struct platform_device *pdev)
 	power->base = pm->base;
 	power->asb = pm->asb;
 
-	id = ASB_READ(ASB_AXI_BRDG_ID);
+	id = readl(power->asb + ASB_AXI_BRDG_ID);
 	if (id != 0x62726467 /* "BRDG" */) {
 		dev_err(dev, "ASB register ID returned 0x%08x\n", id);
 		return -ENODEV;
-- 
2.25.1


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

* [PATCH 09/11] soc: bcm: bcm2835-power: Resolve ASB register macros
@ 2022-05-15 20:20   ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

The macros in order to access the ASB registers have a hard coded base
address. So extending them for other platforms would make them harder
to read. As a solution resolve these macros.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/soc/bcm/bcm2835-power.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
index 77dc9e62b207..fa0a13035794 100644
--- a/drivers/soc/bcm/bcm2835-power.c
+++ b/drivers/soc/bcm/bcm2835-power.c
@@ -126,9 +126,6 @@
 
 #define ASB_AXI_BRDG_ID			0x20
 
-#define ASB_READ(reg) readl(power->asb + (reg))
-#define ASB_WRITE(reg, val) writel(PM_PASSWORD | (val), power->asb + (reg))
-
 struct bcm2835_power_domain {
 	struct generic_pm_domain base;
 	struct bcm2835_power *power;
@@ -150,7 +147,10 @@ struct bcm2835_power {
 
 static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
 {
+	void __iomem *base = power->asb;
 	u64 start;
+	u32 val;
+
 
 	if (!reg)
 		return 0;
@@ -159,12 +159,13 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
 
 	/* Enable the module's async AXI bridges. */
 	if (enable) {
-		ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
+		val = readl(base + reg) & ~ASB_REQ_STOP;
 	} else {
-		ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
+		val = readl(base + reg) | ASB_REQ_STOP;
 	}
+	writel(PM_PASSWORD | val, base + reg);
 
-	while (ASB_READ(reg) & ASB_ACK) {
+	while (readl(base + reg) & ASB_ACK) {
 		cpu_relax();
 		if (ktime_get_ns() - start >= 1000)
 			return -ETIMEDOUT;
@@ -622,7 +623,7 @@ static int bcm2835_power_probe(struct platform_device *pdev)
 	power->base = pm->base;
 	power->asb = pm->asb;
 
-	id = ASB_READ(ASB_AXI_BRDG_ID);
+	id = readl(power->asb + ASB_AXI_BRDG_ID);
 	if (id != 0x62726467 /* "BRDG" */) {
 		dev_err(dev, "ASB register ID returned 0x%08x\n", id);
 		return -ENODEV;
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 10/11] soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-15 20:20   ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
with the ISP and H264 bits, and V3D is in the same place in the new ASB
as the old one.

Use the fact that 'pm->rpivid_asb' is populated as a hint that we're on
BCM2711.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/soc/bcm/bcm2835-power.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
index fa0a13035794..1e06d91c0739 100644
--- a/drivers/soc/bcm/bcm2835-power.c
+++ b/drivers/soc/bcm/bcm2835-power.c
@@ -126,6 +126,8 @@
 
 #define ASB_AXI_BRDG_ID			0x20
 
+#define BCM2835_BRDG_ID			0x62726467
+
 struct bcm2835_power_domain {
 	struct generic_pm_domain base;
 	struct bcm2835_power *power;
@@ -139,6 +141,8 @@ struct bcm2835_power {
 	void __iomem		*base;
 	/* AXI Async bridge registers. */
 	void __iomem		*asb;
+	/* RPiVid bridge registers. */
+	void __iomem		*rpivid_asb;
 
 	struct genpd_onecell_data pd_xlate;
 	struct bcm2835_power_domain domains[BCM2835_POWER_DOMAIN_COUNT];
@@ -151,9 +155,15 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
 	u64 start;
 	u32 val;
 
-
-	if (!reg)
+	switch (reg) {
+	case 0:
 		return 0;
+	case ASB_V3D_S_CTRL:
+	case ASB_V3D_M_CTRL:
+		if (power->rpivid_asb)
+			base = power->rpivid_asb;
+		break;
+	}
 
 	start = ktime_get_ns();
 
@@ -622,13 +632,23 @@ static int bcm2835_power_probe(struct platform_device *pdev)
 	power->dev = dev;
 	power->base = pm->base;
 	power->asb = pm->asb;
+	power->rpivid_asb = pm->rpivid_asb;
 
 	id = readl(power->asb + ASB_AXI_BRDG_ID);
-	if (id != 0x62726467 /* "BRDG" */) {
+	if (id != BCM2835_BRDG_ID /* "BRDG" */) {
 		dev_err(dev, "ASB register ID returned 0x%08x\n", id);
 		return -ENODEV;
 	}
 
+	if (power->rpivid_asb) {
+		id = readl(power->rpivid_asb + ASB_AXI_BRDG_ID);
+		if (id != BCM2835_BRDG_ID /* "BRDG" */) {
+			dev_err(dev, "RPiVid ASB register ID returned 0x%08x\n",
+				     id);
+			return -ENODEV;
+		}
+	}
+
 	power->pd_xlate.domains = devm_kcalloc(dev,
 					       ARRAY_SIZE(power_domain_names),
 					       sizeof(*power->pd_xlate.domains),
-- 
2.25.1


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

* [PATCH 10/11] soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB
@ 2022-05-15 20:20   ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Stefan Wahren

In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
with the ISP and H264 bits, and V3D is in the same place in the new ASB
as the old one.

Use the fact that 'pm->rpivid_asb' is populated as a hint that we're on
BCM2711.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/soc/bcm/bcm2835-power.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
index fa0a13035794..1e06d91c0739 100644
--- a/drivers/soc/bcm/bcm2835-power.c
+++ b/drivers/soc/bcm/bcm2835-power.c
@@ -126,6 +126,8 @@
 
 #define ASB_AXI_BRDG_ID			0x20
 
+#define BCM2835_BRDG_ID			0x62726467
+
 struct bcm2835_power_domain {
 	struct generic_pm_domain base;
 	struct bcm2835_power *power;
@@ -139,6 +141,8 @@ struct bcm2835_power {
 	void __iomem		*base;
 	/* AXI Async bridge registers. */
 	void __iomem		*asb;
+	/* RPiVid bridge registers. */
+	void __iomem		*rpivid_asb;
 
 	struct genpd_onecell_data pd_xlate;
 	struct bcm2835_power_domain domains[BCM2835_POWER_DOMAIN_COUNT];
@@ -151,9 +155,15 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
 	u64 start;
 	u32 val;
 
-
-	if (!reg)
+	switch (reg) {
+	case 0:
 		return 0;
+	case ASB_V3D_S_CTRL:
+	case ASB_V3D_M_CTRL:
+		if (power->rpivid_asb)
+			base = power->rpivid_asb;
+		break;
+	}
 
 	start = ktime_get_ns();
 
@@ -622,13 +632,23 @@ static int bcm2835_power_probe(struct platform_device *pdev)
 	power->dev = dev;
 	power->base = pm->base;
 	power->asb = pm->asb;
+	power->rpivid_asb = pm->rpivid_asb;
 
 	id = readl(power->asb + ASB_AXI_BRDG_ID);
-	if (id != 0x62726467 /* "BRDG" */) {
+	if (id != BCM2835_BRDG_ID /* "BRDG" */) {
 		dev_err(dev, "ASB register ID returned 0x%08x\n", id);
 		return -ENODEV;
 	}
 
+	if (power->rpivid_asb) {
+		id = readl(power->rpivid_asb + ASB_AXI_BRDG_ID);
+		if (id != BCM2835_BRDG_ID /* "BRDG" */) {
+			dev_err(dev, "RPiVid ASB register ID returned 0x%08x\n",
+				     id);
+			return -ENODEV;
+		}
+	}
+
 	power->pd_xlate.domains = devm_kcalloc(dev,
 					       ARRAY_SIZE(power_domain_names),
 					       sizeof(*power->pd_xlate.domains),
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 11/11] soc: bcm: bcm2835-power: Bypass power_on/off() calls
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-15 20:20   ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

Bypass power_on/power_off() when running on BCM2711 as they are not
needed.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/soc/bcm/bcm2835-power.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
index 1e06d91c0739..5bcd047768b6 100644
--- a/drivers/soc/bcm/bcm2835-power.c
+++ b/drivers/soc/bcm/bcm2835-power.c
@@ -198,6 +198,10 @@ static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)
 {
 	struct bcm2835_power *power = pd->power;
 
+	/* We don't run this on BCM2711 */
+	if (power->rpivid_asb)
+		return 0;
+
 	/* Enable functional isolation */
 	PM_WRITE(pm_reg, PM_READ(pm_reg) & ~PM_ISFUNC);
 
@@ -219,6 +223,10 @@ static int bcm2835_power_power_on(struct bcm2835_power_domain *pd, u32 pm_reg)
 	int inrush;
 	bool powok;
 
+	/* We don't run this on BCM2711 */
+	if (power->rpivid_asb)
+		return 0;
+
 	/* If it was already powered on by the fw, leave it that way. */
 	if (PM_READ(pm_reg) & PM_POWUP)
 		return 0;
-- 
2.25.1


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

* [PATCH 11/11] soc: bcm: bcm2835-power: Bypass power_on/off() calls
@ 2022-05-15 20:20   ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-15 20:20 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel, Nicolas Saenz Julienne,
	Stefan Wahren

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

Bypass power_on/power_off() when running on BCM2711 as they are not
needed.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/soc/bcm/bcm2835-power.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
index 1e06d91c0739..5bcd047768b6 100644
--- a/drivers/soc/bcm/bcm2835-power.c
+++ b/drivers/soc/bcm/bcm2835-power.c
@@ -198,6 +198,10 @@ static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)
 {
 	struct bcm2835_power *power = pd->power;
 
+	/* We don't run this on BCM2711 */
+	if (power->rpivid_asb)
+		return 0;
+
 	/* Enable functional isolation */
 	PM_WRITE(pm_reg, PM_READ(pm_reg) & ~PM_ISFUNC);
 
@@ -219,6 +223,10 @@ static int bcm2835_power_power_on(struct bcm2835_power_domain *pd, u32 pm_reg)
 	int inrush;
 	bool powok;
 
+	/* We don't run this on BCM2711 */
+	if (power->rpivid_asb)
+		return 0;
+
 	/* If it was already powered on by the fw, leave it that way. */
 	if (PM_READ(pm_reg) & PM_POWUP)
 		return 0;
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 03/11] dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711
  2022-05-15 20:20   ` Stefan Wahren
@ 2022-05-18  0:55     ` Rob Herring
  -1 siblings, 0 replies; 56+ messages in thread
From: Rob Herring @ 2022-05-18  0:55 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel

On Sun, May 15, 2022 at 10:20:24PM +0200, Stefan Wahren wrote:
> Add a new compatible string for BCM2711 and the option to provide a
> third reg property for the board's new RPiVid ASB.
> 
> In BCM2711 the new RPiVid ASB took over V3D, which is our only consumer
> of this driver so far. The old ASB is still be present with ISP and H264
> bits but no V3D.
> 
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  .../bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
> index 883ab7cb96e9..e13ce98d1753 100644
> --- a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
> +++ b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
> @@ -19,17 +19,24 @@ allOf:
>  properties:
>    compatible:
>      items:
> -      - const: brcm,bcm2835-pm
> +      - enum:
> +          - brcm,bcm2835-pm
> +          - brcm,bcm2711-pm
>        - const: brcm,bcm2835-pm-wdt
>  
>    reg:
> -    minItems: 2
> -    maxItems: 2
> +    minItems: 1
> +    maxItems: 3
>  
>    reg-names:
> -    items:
> -      - const: pm
> -      - const: asb
> +    oneOf:
> +      - items:
> +          - const: pm
> +          - const: asb
> +      - items:
> +          - const: pm
> +          - const: asb
> +          - const: rpivid_asb

This can be simplified to:

minItems: 2
items:
  - const: pm
  - const: asb
  - const: rpivid_asb

>  
>    "#power-domain-cells":
>      const: 1
> -- 
> 2.25.1
> 
> 

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

* Re: [PATCH 03/11] dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711
@ 2022-05-18  0:55     ` Rob Herring
  0 siblings, 0 replies; 56+ messages in thread
From: Rob Herring @ 2022-05-18  0:55 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel

On Sun, May 15, 2022 at 10:20:24PM +0200, Stefan Wahren wrote:
> Add a new compatible string for BCM2711 and the option to provide a
> third reg property for the board's new RPiVid ASB.
> 
> In BCM2711 the new RPiVid ASB took over V3D, which is our only consumer
> of this driver so far. The old ASB is still be present with ISP and H264
> bits but no V3D.
> 
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  .../bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
> index 883ab7cb96e9..e13ce98d1753 100644
> --- a/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
> +++ b/Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
> @@ -19,17 +19,24 @@ allOf:
>  properties:
>    compatible:
>      items:
> -      - const: brcm,bcm2835-pm
> +      - enum:
> +          - brcm,bcm2835-pm
> +          - brcm,bcm2711-pm
>        - const: brcm,bcm2835-pm-wdt
>  
>    reg:
> -    minItems: 2
> -    maxItems: 2
> +    minItems: 1
> +    maxItems: 3
>  
>    reg-names:
> -    items:
> -      - const: pm
> -      - const: asb
> +    oneOf:
> +      - items:
> +          - const: pm
> +          - const: asb
> +      - items:
> +          - const: pm
> +          - const: asb
> +          - const: rpivid_asb

This can be simplified to:

minItems: 2
items:
  - const: pm
  - const: asb
  - const: rpivid_asb

>  
>    "#power-domain-cells":
>      const: 1
> -- 
> 2.25.1
> 
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 00/11] soc: bcm2835-power: Prepare BCM2711 V3D support
  2022-05-15 20:20 ` Stefan Wahren
@ 2022-05-18 20:22   ` Florian Fainelli
  -1 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2022-05-18 20:22 UTC (permalink / raw)
  To: Stefan Wahren, Florian Fainelli, Ray Jui, Scott Branden,
	Nicolas Saenz Julienne, Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel



On 5/15/2022 1:20 PM, Stefan Wahren wrote:
> This series is a split out of version 4 - Raspberry PI 4 V3D enablement send
> by Peter Robinson [1]. It attemps to enable BCM2711 V3D support for the
> power management driver. It's a rework of the less controversial changes
> (excluding V3D GPU driver changes) so this can be reviewed and applied faster.
> 
> The changes has been tested just superficial on RPi 3B+ and 4B, so further
> tester are welcome.
> 
> Changes since the mention series:
> - fix DT schema errors
> - make rpivid_asb register optional in DT schema
> - avoid code duplication in BCM2835 ASB enable/disable
> - rework ASB V3D handling so we don't need the V3D flag
> - avoid log errors for optional register
> - use a define for expected ASB_AXI_BRDG_ID result
> - fix copy & paste issues in bcm2835-pm changes
> 
> [1] - https://patchwork.kernel.org/project/linux-arm-kernel/cover/20220213225646.67761-1-pbrobinson@gmail.com/

Lee, can I get your Ack for the two patches touching mfd so I can take 
the entire series via the arm-soc pull request?

> 
> Nicolas Saenz Julienne (6):
>    dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema
>    dt-bindings: soc: bcm: bcm2835-pm: Introduce reg-names
>    ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node
>    ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node
>    mfd: bcm2835-pm: Use 'reg-names' to get resources
>    soc: bcm: bcm2835-power: Bypass power_on/off() calls
> 
> Stefan Wahren (5):
>    dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711
>    mfd: bcm2835-pm: Add support for BCM2711
>    soc: bcm: bcm2835-power: Refactor ASB control
>    soc: bcm: bcm2835-power: Resolve ASB register macros
>    soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB
> 
>   .../bindings/soc/bcm/brcm,bcm2835-pm.txt      | 46 ----------
>   .../bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 89 +++++++++++++++++++
>   arch/arm/boot/dts/bcm2711.dtsi                |  3 +-
>   arch/arm/boot/dts/bcm2835-common.dtsi         |  1 +
>   drivers/mfd/bcm2835-pm.c                      | 77 ++++++++++++----
>   drivers/soc/bcm/bcm2835-power.c               | 72 ++++++++++-----
>   include/linux/mfd/bcm2835-pm.h                |  1 +
>   7 files changed, 199 insertions(+), 90 deletions(-)
>   delete mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt
>   create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
> 

-- 
Florian

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

* Re: [PATCH 00/11] soc: bcm2835-power: Prepare BCM2711 V3D support
@ 2022-05-18 20:22   ` Florian Fainelli
  0 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2022-05-18 20:22 UTC (permalink / raw)
  To: Stefan Wahren, Florian Fainelli, Ray Jui, Scott Branden,
	Nicolas Saenz Julienne, Lee Jones
  Cc: Peter Robinson, Melissa Wen, Phil Elwell,
	bcm-kernel-feedback-list, Maxime Ripard, devicetree,
	linux-rpi-kernel, linux-arm-kernel



On 5/15/2022 1:20 PM, Stefan Wahren wrote:
> This series is a split out of version 4 - Raspberry PI 4 V3D enablement send
> by Peter Robinson [1]. It attemps to enable BCM2711 V3D support for the
> power management driver. It's a rework of the less controversial changes
> (excluding V3D GPU driver changes) so this can be reviewed and applied faster.
> 
> The changes has been tested just superficial on RPi 3B+ and 4B, so further
> tester are welcome.
> 
> Changes since the mention series:
> - fix DT schema errors
> - make rpivid_asb register optional in DT schema
> - avoid code duplication in BCM2835 ASB enable/disable
> - rework ASB V3D handling so we don't need the V3D flag
> - avoid log errors for optional register
> - use a define for expected ASB_AXI_BRDG_ID result
> - fix copy & paste issues in bcm2835-pm changes
> 
> [1] - https://patchwork.kernel.org/project/linux-arm-kernel/cover/20220213225646.67761-1-pbrobinson@gmail.com/

Lee, can I get your Ack for the two patches touching mfd so I can take 
the entire series via the arm-soc pull request?

> 
> Nicolas Saenz Julienne (6):
>    dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema
>    dt-bindings: soc: bcm: bcm2835-pm: Introduce reg-names
>    ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node
>    ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node
>    mfd: bcm2835-pm: Use 'reg-names' to get resources
>    soc: bcm: bcm2835-power: Bypass power_on/off() calls
> 
> Stefan Wahren (5):
>    dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711
>    mfd: bcm2835-pm: Add support for BCM2711
>    soc: bcm: bcm2835-power: Refactor ASB control
>    soc: bcm: bcm2835-power: Resolve ASB register macros
>    soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB
> 
>   .../bindings/soc/bcm/brcm,bcm2835-pm.txt      | 46 ----------
>   .../bindings/soc/bcm/brcm,bcm2835-pm.yaml     | 89 +++++++++++++++++++
>   arch/arm/boot/dts/bcm2711.dtsi                |  3 +-
>   arch/arm/boot/dts/bcm2835-common.dtsi         |  1 +
>   drivers/mfd/bcm2835-pm.c                      | 77 ++++++++++++----
>   drivers/soc/bcm/bcm2835-power.c               | 72 ++++++++++-----
>   include/linux/mfd/bcm2835-pm.h                |  1 +
>   7 files changed, 199 insertions(+), 90 deletions(-)
>   delete mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt
>   create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.yaml
> 

-- 
Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 04/11] ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node
  2022-05-15 20:20   ` Stefan Wahren
@ 2022-05-31 12:55     ` Peter Robinson
  -1 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 12:55 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Nicolas Saenz Julienne

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> bcm2835-pm's bindings now support explicitly setting 'reg-names,' so use
> them.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  arch/arm/boot/dts/bcm2711.dtsi        | 1 +
>  arch/arm/boot/dts/bcm2835-common.dtsi | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
> index 89af57482bc8..cbb47e2c9434 100644
> --- a/arch/arm/boot/dts/bcm2711.dtsi
> +++ b/arch/arm/boot/dts/bcm2711.dtsi
> @@ -113,6 +113,7 @@ pm: watchdog@7e100000 {
>                         reg = <0x7e100000 0x114>,
>                               <0x7e00a000 0x24>,
>                               <0x7ec11000 0x20>;
> +                       reg-names = "pm", "asb", "rpivid_asb";
>                         clocks = <&clocks BCM2835_CLOCK_V3D>,
>                                  <&clocks BCM2835_CLOCK_PERI_IMAGE>,
>                                  <&clocks BCM2835_CLOCK_H264>,
> diff --git a/arch/arm/boot/dts/bcm2835-common.dtsi b/arch/arm/boot/dts/bcm2835-common.dtsi
> index c25e797b9060..a037d2bc5b11 100644
> --- a/arch/arm/boot/dts/bcm2835-common.dtsi
> +++ b/arch/arm/boot/dts/bcm2835-common.dtsi
> @@ -62,6 +62,7 @@ pm: watchdog@7e100000 {
>                         #reset-cells = <1>;
>                         reg = <0x7e100000 0x114>,
>                               <0x7e00a000 0x24>;
> +                       reg-names = "pm", "asb";
>                         clocks = <&clocks BCM2835_CLOCK_V3D>,
>                                  <&clocks BCM2835_CLOCK_PERI_IMAGE>,
>                                  <&clocks BCM2835_CLOCK_H264>,
> --
> 2.25.1
>

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

* Re: [PATCH 04/11] ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node
@ 2022-05-31 12:55     ` Peter Robinson
  0 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 12:55 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Nicolas Saenz Julienne

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> bcm2835-pm's bindings now support explicitly setting 'reg-names,' so use
> them.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  arch/arm/boot/dts/bcm2711.dtsi        | 1 +
>  arch/arm/boot/dts/bcm2835-common.dtsi | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
> index 89af57482bc8..cbb47e2c9434 100644
> --- a/arch/arm/boot/dts/bcm2711.dtsi
> +++ b/arch/arm/boot/dts/bcm2711.dtsi
> @@ -113,6 +113,7 @@ pm: watchdog@7e100000 {
>                         reg = <0x7e100000 0x114>,
>                               <0x7e00a000 0x24>,
>                               <0x7ec11000 0x20>;
> +                       reg-names = "pm", "asb", "rpivid_asb";
>                         clocks = <&clocks BCM2835_CLOCK_V3D>,
>                                  <&clocks BCM2835_CLOCK_PERI_IMAGE>,
>                                  <&clocks BCM2835_CLOCK_H264>,
> diff --git a/arch/arm/boot/dts/bcm2835-common.dtsi b/arch/arm/boot/dts/bcm2835-common.dtsi
> index c25e797b9060..a037d2bc5b11 100644
> --- a/arch/arm/boot/dts/bcm2835-common.dtsi
> +++ b/arch/arm/boot/dts/bcm2835-common.dtsi
> @@ -62,6 +62,7 @@ pm: watchdog@7e100000 {
>                         #reset-cells = <1>;
>                         reg = <0x7e100000 0x114>,
>                               <0x7e00a000 0x24>;
> +                       reg-names = "pm", "asb";
>                         clocks = <&clocks BCM2835_CLOCK_V3D>,
>                                  <&clocks BCM2835_CLOCK_PERI_IMAGE>,
>                                  <&clocks BCM2835_CLOCK_H264>,
> --
> 2.25.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 05/11] ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node
  2022-05-15 20:20   ` Stefan Wahren
@ 2022-05-31 12:56     ` Peter Robinson
  -1 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 12:56 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Nicolas Saenz Julienne

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> A new compatible string was introduced specifically for BCM2711, so make
> use of it.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  arch/arm/boot/dts/bcm2711.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
> index cbb47e2c9434..5eca5207c212 100644
> --- a/arch/arm/boot/dts/bcm2711.dtsi
> +++ b/arch/arm/boot/dts/bcm2711.dtsi
> @@ -107,7 +107,7 @@ dma: dma@7e007000 {
>                 };
>
>                 pm: watchdog@7e100000 {
> -                       compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt";
> +                       compatible = "brcm,bcm2711-pm", "brcm,bcm2835-pm-wdt";
>                         #power-domain-cells = <1>;
>                         #reset-cells = <1>;
>                         reg = <0x7e100000 0x114>,
> --
> 2.25.1
>

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

* Re: [PATCH 05/11] ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node
@ 2022-05-31 12:56     ` Peter Robinson
  0 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 12:56 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Nicolas Saenz Julienne

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> A new compatible string was introduced specifically for BCM2711, so make
> use of it.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  arch/arm/boot/dts/bcm2711.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
> index cbb47e2c9434..5eca5207c212 100644
> --- a/arch/arm/boot/dts/bcm2711.dtsi
> +++ b/arch/arm/boot/dts/bcm2711.dtsi
> @@ -107,7 +107,7 @@ dma: dma@7e007000 {
>                 };
>
>                 pm: watchdog@7e100000 {
> -                       compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt";
> +                       compatible = "brcm,bcm2711-pm", "brcm,bcm2835-pm-wdt";
>                         #power-domain-cells = <1>;
>                         #reset-cells = <1>;
>                         reg = <0x7e100000 0x114>,
> --
> 2.25.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 06/11] mfd: bcm2835-pm: Use 'reg-names' to get resources
  2022-05-15 20:20   ` Stefan Wahren
@ 2022-05-31 14:54     ` Peter Robinson
  -1 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 14:54 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Nicolas Saenz Julienne

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> If available in firmware, find resources by their 'reg-names' position
> instead of relying on hardcoded offsets. Care is taken to support old
> firmware nonetheless.

So this patch has changed a little over Nicolas's last one, which was
what I based my patch on [1] but there's no changelog

[1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-7-pbrobinson@gmail.com/

> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Minor comment inline, else:
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  drivers/mfd/bcm2835-pm.c | 59 +++++++++++++++++++++++++++-------------
>  1 file changed, 40 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
> index 42fe67f1538e..1656d786993a 100644
> --- a/drivers/mfd/bcm2835-pm.c
> +++ b/drivers/mfd/bcm2835-pm.c
> @@ -25,9 +25,41 @@ static const struct mfd_cell bcm2835_power_devs[] = {
>         { .name = "bcm2835-power" },
>  };
>
> +static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> +                               struct bcm2835_pm *pm)
> +{
> +       /* If no 'reg-names' property is found we can assume we're using old
> +        * firmware.
> +        */
> +       if (!of_find_property(pm->dev->of_node, "reg-names", NULL)) {
> +               dev_warn(pm->dev, "Old devicetree detected, please update your firmware.\n");

If they're using an upstream kernel DT and an old firmware this may be
confusing, maybe tweak the wording a little?

> +
> +               pm->base = devm_platform_ioremap_resource(pdev, 0);
> +               if (IS_ERR(pm->base))
> +                       return PTR_ERR(pm->base);
> +
> +               pm->asb = devm_platform_ioremap_resource(pdev, 1);
> +       } else {
> +               struct resource *res;
> +
> +               pm->base = devm_platform_ioremap_resource_byname(pdev, "pm");
> +               if (IS_ERR(pm->base))
> +                       return PTR_ERR(pm->base);
> +
> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> +                                                   "asb");
> +               if (res)
> +                       pm->asb = devm_ioremap_resource(&pdev->dev, res);
> +       }
> +
> +       if (IS_ERR(pm->asb))
> +               pm->asb = NULL;
> +
> +       return 0;
> +}
> +
>  static int bcm2835_pm_probe(struct platform_device *pdev)
>  {
> -       struct resource *res;
>         struct device *dev = &pdev->dev;
>         struct bcm2835_pm *pm;
>         int ret;
> @@ -39,10 +71,9 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>
>         pm->dev = dev;
>
> -       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -       pm->base = devm_ioremap_resource(dev, res);
> -       if (IS_ERR(pm->base))
> -               return PTR_ERR(pm->base);
> +       ret = bcm2835_pm_get_pdata(pdev, pm);
> +       if (ret)
> +               return ret;
>
>         ret = devm_mfd_add_devices(dev, -1,
>                                    bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs),
> @@ -54,20 +85,10 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>          * bcm2835-pm binding as the key for whether we can reference
>          * the full PM register range and support power domains.
>          */
> -       res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> -       if (res) {
> -               pm->asb = devm_ioremap_resource(dev, res);
> -               if (IS_ERR(pm->asb))
> -                       return PTR_ERR(pm->asb);
> -
> -               ret = devm_mfd_add_devices(dev, -1,
> -                                          bcm2835_power_devs,
> -                                          ARRAY_SIZE(bcm2835_power_devs),
> -                                          NULL, 0, NULL);
> -               if (ret)
> -                       return ret;
> -       }
> -
> +       if (pm->asb)
> +               return devm_mfd_add_devices(dev, -1, bcm2835_power_devs,
> +                                           ARRAY_SIZE(bcm2835_power_devs),
> +                                           NULL, 0, NULL);
>         return 0;
>  }
>
> --
> 2.25.1
>

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

* Re: [PATCH 06/11] mfd: bcm2835-pm: Use 'reg-names' to get resources
@ 2022-05-31 14:54     ` Peter Robinson
  0 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 14:54 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Nicolas Saenz Julienne

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> If available in firmware, find resources by their 'reg-names' position
> instead of relying on hardcoded offsets. Care is taken to support old
> firmware nonetheless.

So this patch has changed a little over Nicolas's last one, which was
what I based my patch on [1] but there's no changelog

[1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-7-pbrobinson@gmail.com/

> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Minor comment inline, else:
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  drivers/mfd/bcm2835-pm.c | 59 +++++++++++++++++++++++++++-------------
>  1 file changed, 40 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
> index 42fe67f1538e..1656d786993a 100644
> --- a/drivers/mfd/bcm2835-pm.c
> +++ b/drivers/mfd/bcm2835-pm.c
> @@ -25,9 +25,41 @@ static const struct mfd_cell bcm2835_power_devs[] = {
>         { .name = "bcm2835-power" },
>  };
>
> +static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> +                               struct bcm2835_pm *pm)
> +{
> +       /* If no 'reg-names' property is found we can assume we're using old
> +        * firmware.
> +        */
> +       if (!of_find_property(pm->dev->of_node, "reg-names", NULL)) {
> +               dev_warn(pm->dev, "Old devicetree detected, please update your firmware.\n");

If they're using an upstream kernel DT and an old firmware this may be
confusing, maybe tweak the wording a little?

> +
> +               pm->base = devm_platform_ioremap_resource(pdev, 0);
> +               if (IS_ERR(pm->base))
> +                       return PTR_ERR(pm->base);
> +
> +               pm->asb = devm_platform_ioremap_resource(pdev, 1);
> +       } else {
> +               struct resource *res;
> +
> +               pm->base = devm_platform_ioremap_resource_byname(pdev, "pm");
> +               if (IS_ERR(pm->base))
> +                       return PTR_ERR(pm->base);
> +
> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> +                                                   "asb");
> +               if (res)
> +                       pm->asb = devm_ioremap_resource(&pdev->dev, res);
> +       }
> +
> +       if (IS_ERR(pm->asb))
> +               pm->asb = NULL;
> +
> +       return 0;
> +}
> +
>  static int bcm2835_pm_probe(struct platform_device *pdev)
>  {
> -       struct resource *res;
>         struct device *dev = &pdev->dev;
>         struct bcm2835_pm *pm;
>         int ret;
> @@ -39,10 +71,9 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>
>         pm->dev = dev;
>
> -       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -       pm->base = devm_ioremap_resource(dev, res);
> -       if (IS_ERR(pm->base))
> -               return PTR_ERR(pm->base);
> +       ret = bcm2835_pm_get_pdata(pdev, pm);
> +       if (ret)
> +               return ret;
>
>         ret = devm_mfd_add_devices(dev, -1,
>                                    bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs),
> @@ -54,20 +85,10 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>          * bcm2835-pm binding as the key for whether we can reference
>          * the full PM register range and support power domains.
>          */
> -       res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> -       if (res) {
> -               pm->asb = devm_ioremap_resource(dev, res);
> -               if (IS_ERR(pm->asb))
> -                       return PTR_ERR(pm->asb);
> -
> -               ret = devm_mfd_add_devices(dev, -1,
> -                                          bcm2835_power_devs,
> -                                          ARRAY_SIZE(bcm2835_power_devs),
> -                                          NULL, 0, NULL);
> -               if (ret)
> -                       return ret;
> -       }
> -
> +       if (pm->asb)
> +               return devm_mfd_add_devices(dev, -1, bcm2835_power_devs,
> +                                           ARRAY_SIZE(bcm2835_power_devs),
> +                                           NULL, 0, NULL);
>         return 0;
>  }
>
> --
> 2.25.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
  2022-05-15 20:20   ` Stefan Wahren
@ 2022-05-31 15:08     ` Peter Robinson
  -1 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 15:08 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
> with the ISP and H264 bits, and V3D is in the same place in the new ASB
> as the old one.
>
> As per the devicetree bindings, BCM2711 will provide both the old and
> new ASB resources, so get both of them and pass them into
> 'bcm2835-power,' which will take care of selecting which one to use
> accordingly.
>
> Since the RPiVid ASB's resources were being provided prior to formalizing
> the bindings[1], also support the old firmwares that didn't use

I'm guessing this [1] is referring to "[1] See: 7dbe8c62ceeb ("ARM:
dts: Add minimal Raspberry Pi 4 support")" referred to in the original
patch [1] that Nicolas did, was there a reason to drop the
details/changelog here? The decision not to use bits makes sense I
believe.

[1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-8-pbrobinson@gmail.com/

> 'reg-names.'
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
>  include/linux/mfd/bcm2835-pm.h |  1 +
>  2 files changed, 19 insertions(+)
>
> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
> index 1656d786993a..da110767c6a4 100644
> --- a/drivers/mfd/bcm2835-pm.c
> +++ b/drivers/mfd/bcm2835-pm.c
> @@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
>  static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>                                 struct bcm2835_pm *pm)
>  {
> +       bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
> +
>         /* If no 'reg-names' property is found we can assume we're using old
>          * firmware.
>          */
> @@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>                         return PTR_ERR(pm->base);
>
>                 pm->asb = devm_platform_ioremap_resource(pdev, 1);
> +               pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);

Shouldn't we check if is_bcm2711 before we assign rpivid_asb above?

>         } else {
>                 struct resource *res;
>
> @@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>                                                     "asb");
>                 if (res)
>                         pm->asb = devm_ioremap_resource(&pdev->dev, res);
> +
> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> +                                                   "rpivid_asb");
> +               if (res)
> +                       pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
> +                                                               res);
>         }
>
>         if (IS_ERR(pm->asb))
>                 pm->asb = NULL;
>
> +       if (IS_ERR(pm->rpivid_asb))
> +               pm->rpivid_asb = NULL;
> +
> +       if (pm->rpivid_asb && !is_bcm2711) {
> +               dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");

Should we ever get into this situation? If it's an older get RPi I'm
guessing pm->rpivid_asb should have been set to NULL from the error
above.

> +               return -EINVAL;
> +       }
> +
>         return 0;
>  }
>
> @@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>  static const struct of_device_id bcm2835_pm_of_match[] = {
>         { .compatible = "brcm,bcm2835-pm-wdt", },
>         { .compatible = "brcm,bcm2835-pm", },
> +       { .compatible = "brcm,bcm2711-pm", },
>         {},
>  };
>  MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
> diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
> index ed37dc40e82a..f70a810c55f7 100644
> --- a/include/linux/mfd/bcm2835-pm.h
> +++ b/include/linux/mfd/bcm2835-pm.h
> @@ -9,6 +9,7 @@ struct bcm2835_pm {
>         struct device *dev;
>         void __iomem *base;
>         void __iomem *asb;
> +       void __iomem *rpivid_asb;
>  };
>
>  #endif /* BCM2835_MFD_PM_H */
> --
> 2.25.1
>

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

* Re: [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
@ 2022-05-31 15:08     ` Peter Robinson
  0 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 15:08 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
> with the ISP and H264 bits, and V3D is in the same place in the new ASB
> as the old one.
>
> As per the devicetree bindings, BCM2711 will provide both the old and
> new ASB resources, so get both of them and pass them into
> 'bcm2835-power,' which will take care of selecting which one to use
> accordingly.
>
> Since the RPiVid ASB's resources were being provided prior to formalizing
> the bindings[1], also support the old firmwares that didn't use

I'm guessing this [1] is referring to "[1] See: 7dbe8c62ceeb ("ARM:
dts: Add minimal Raspberry Pi 4 support")" referred to in the original
patch [1] that Nicolas did, was there a reason to drop the
details/changelog here? The decision not to use bits makes sense I
believe.

[1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-8-pbrobinson@gmail.com/

> 'reg-names.'
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
>  include/linux/mfd/bcm2835-pm.h |  1 +
>  2 files changed, 19 insertions(+)
>
> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
> index 1656d786993a..da110767c6a4 100644
> --- a/drivers/mfd/bcm2835-pm.c
> +++ b/drivers/mfd/bcm2835-pm.c
> @@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
>  static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>                                 struct bcm2835_pm *pm)
>  {
> +       bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
> +
>         /* If no 'reg-names' property is found we can assume we're using old
>          * firmware.
>          */
> @@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>                         return PTR_ERR(pm->base);
>
>                 pm->asb = devm_platform_ioremap_resource(pdev, 1);
> +               pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);

Shouldn't we check if is_bcm2711 before we assign rpivid_asb above?

>         } else {
>                 struct resource *res;
>
> @@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>                                                     "asb");
>                 if (res)
>                         pm->asb = devm_ioremap_resource(&pdev->dev, res);
> +
> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> +                                                   "rpivid_asb");
> +               if (res)
> +                       pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
> +                                                               res);
>         }
>
>         if (IS_ERR(pm->asb))
>                 pm->asb = NULL;
>
> +       if (IS_ERR(pm->rpivid_asb))
> +               pm->rpivid_asb = NULL;
> +
> +       if (pm->rpivid_asb && !is_bcm2711) {
> +               dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");

Should we ever get into this situation? If it's an older get RPi I'm
guessing pm->rpivid_asb should have been set to NULL from the error
above.

> +               return -EINVAL;
> +       }
> +
>         return 0;
>  }
>
> @@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>  static const struct of_device_id bcm2835_pm_of_match[] = {
>         { .compatible = "brcm,bcm2835-pm-wdt", },
>         { .compatible = "brcm,bcm2835-pm", },
> +       { .compatible = "brcm,bcm2711-pm", },
>         {},
>  };
>  MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
> diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
> index ed37dc40e82a..f70a810c55f7 100644
> --- a/include/linux/mfd/bcm2835-pm.h
> +++ b/include/linux/mfd/bcm2835-pm.h
> @@ -9,6 +9,7 @@ struct bcm2835_pm {
>         struct device *dev;
>         void __iomem *base;
>         void __iomem *asb;
> +       void __iomem *rpivid_asb;
>  };
>
>  #endif /* BCM2835_MFD_PM_H */
> --
> 2.25.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 08/11] soc: bcm: bcm2835-power: Refactor ASB control
  2022-05-15 20:20   ` Stefan Wahren
@ 2022-05-31 15:18     ` Peter Robinson
  -1 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 15:18 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> The functions to control the async AXI bridges are almost identical.
> So define a general function to handle it and keep the original ones as
> wrapper. This should make this driver easier to extend.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  drivers/soc/bcm/bcm2835-power.c | 31 +++++++++++++------------------
>  1 file changed, 13 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
> index 1e0041ec8132..77dc9e62b207 100644
> --- a/drivers/soc/bcm/bcm2835-power.c
> +++ b/drivers/soc/bcm/bcm2835-power.c
> @@ -148,7 +148,7 @@ struct bcm2835_power {
>         struct reset_controller_dev reset;
>  };
>
> -static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
> +static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
>  {
>         u64 start;
>
> @@ -158,7 +158,12 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
>         start = ktime_get_ns();
>
>         /* Enable the module's async AXI bridges. */
> -       ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
> +       if (enable) {
> +               ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
> +       } else {
> +               ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
> +       }
> +
>         while (ASB_READ(reg) & ASB_ACK) {
>                 cpu_relax();
>                 if (ktime_get_ns() - start >= 1000)
> @@ -168,24 +173,14 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
>         return 0;
>  }
>
> -static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
> +static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
>  {
> -       u64 start;
> -
> -       if (!reg)
> -               return 0;
> -
> -       start = ktime_get_ns();
> -
> -       /* Enable the module's async AXI bridges. */
> -       ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
> -       while (!(ASB_READ(reg) & ASB_ACK)) {
> -               cpu_relax();
> -               if (ktime_get_ns() - start >= 1000)
> -                       return -ETIMEDOUT;
> -       }
> +       return bcm2835_asb_control(power, reg, true);
> +}
>
> -       return 0;
> +static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
> +{
> +       return bcm2835_asb_control(power, reg, false);
>  }
>
>  static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)
> --
> 2.25.1
>

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

* Re: [PATCH 08/11] soc: bcm: bcm2835-power: Refactor ASB control
@ 2022-05-31 15:18     ` Peter Robinson
  0 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 15:18 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> The functions to control the async AXI bridges are almost identical.
> So define a general function to handle it and keep the original ones as
> wrapper. This should make this driver easier to extend.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  drivers/soc/bcm/bcm2835-power.c | 31 +++++++++++++------------------
>  1 file changed, 13 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
> index 1e0041ec8132..77dc9e62b207 100644
> --- a/drivers/soc/bcm/bcm2835-power.c
> +++ b/drivers/soc/bcm/bcm2835-power.c
> @@ -148,7 +148,7 @@ struct bcm2835_power {
>         struct reset_controller_dev reset;
>  };
>
> -static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
> +static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
>  {
>         u64 start;
>
> @@ -158,7 +158,12 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
>         start = ktime_get_ns();
>
>         /* Enable the module's async AXI bridges. */
> -       ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
> +       if (enable) {
> +               ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
> +       } else {
> +               ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
> +       }
> +
>         while (ASB_READ(reg) & ASB_ACK) {
>                 cpu_relax();
>                 if (ktime_get_ns() - start >= 1000)
> @@ -168,24 +173,14 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
>         return 0;
>  }
>
> -static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
> +static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
>  {
> -       u64 start;
> -
> -       if (!reg)
> -               return 0;
> -
> -       start = ktime_get_ns();
> -
> -       /* Enable the module's async AXI bridges. */
> -       ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
> -       while (!(ASB_READ(reg) & ASB_ACK)) {
> -               cpu_relax();
> -               if (ktime_get_ns() - start >= 1000)
> -                       return -ETIMEDOUT;
> -       }
> +       return bcm2835_asb_control(power, reg, true);
> +}
>
> -       return 0;
> +static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
> +{
> +       return bcm2835_asb_control(power, reg, false);
>  }
>
>  static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)
> --
> 2.25.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 09/11] soc: bcm: bcm2835-power: Resolve ASB register macros
  2022-05-15 20:20   ` Stefan Wahren
@ 2022-05-31 15:47     ` Peter Robinson
  -1 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 15:47 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> The macros in order to access the ASB registers have a hard coded base
> address. So extending them for other platforms would make them harder
> to read. As a solution resolve these macros.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
A minor query below:
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  drivers/soc/bcm/bcm2835-power.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
> index 77dc9e62b207..fa0a13035794 100644
> --- a/drivers/soc/bcm/bcm2835-power.c
> +++ b/drivers/soc/bcm/bcm2835-power.c
> @@ -126,9 +126,6 @@
>
>  #define ASB_AXI_BRDG_ID                        0x20
>
> -#define ASB_READ(reg) readl(power->asb + (reg))
> -#define ASB_WRITE(reg, val) writel(PM_PASSWORD | (val), power->asb + (reg))
> -
>  struct bcm2835_power_domain {
>         struct generic_pm_domain base;
>         struct bcm2835_power *power;
> @@ -150,7 +147,10 @@ struct bcm2835_power {
>
>  static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
>  {
> +       void __iomem *base = power->asb;

I wonder the perf of defining base here vs the readability of
power->asb; throughout.

>         u64 start;
> +       u32 val;
> +
>
>         if (!reg)
>                 return 0;
> @@ -159,12 +159,13 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
>
>         /* Enable the module's async AXI bridges. */
>         if (enable) {
> -               ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
> +               val = readl(base + reg) & ~ASB_REQ_STOP;
>         } else {
> -               ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
> +               val = readl(base + reg) | ASB_REQ_STOP;
>         }
> +       writel(PM_PASSWORD | val, base + reg);
>
> -       while (ASB_READ(reg) & ASB_ACK) {
> +       while (readl(base + reg) & ASB_ACK) {
>                 cpu_relax();
>                 if (ktime_get_ns() - start >= 1000)
>                         return -ETIMEDOUT;
> @@ -622,7 +623,7 @@ static int bcm2835_power_probe(struct platform_device *pdev)
>         power->base = pm->base;
>         power->asb = pm->asb;
>
> -       id = ASB_READ(ASB_AXI_BRDG_ID);
> +       id = readl(power->asb + ASB_AXI_BRDG_ID);
>         if (id != 0x62726467 /* "BRDG" */) {
>                 dev_err(dev, "ASB register ID returned 0x%08x\n", id);
>                 return -ENODEV;
> --
> 2.25.1
>

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

* Re: [PATCH 09/11] soc: bcm: bcm2835-power: Resolve ASB register macros
@ 2022-05-31 15:47     ` Peter Robinson
  0 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 15:47 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> The macros in order to access the ASB registers have a hard coded base
> address. So extending them for other platforms would make them harder
> to read. As a solution resolve these macros.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
A minor query below:
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  drivers/soc/bcm/bcm2835-power.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
> index 77dc9e62b207..fa0a13035794 100644
> --- a/drivers/soc/bcm/bcm2835-power.c
> +++ b/drivers/soc/bcm/bcm2835-power.c
> @@ -126,9 +126,6 @@
>
>  #define ASB_AXI_BRDG_ID                        0x20
>
> -#define ASB_READ(reg) readl(power->asb + (reg))
> -#define ASB_WRITE(reg, val) writel(PM_PASSWORD | (val), power->asb + (reg))
> -
>  struct bcm2835_power_domain {
>         struct generic_pm_domain base;
>         struct bcm2835_power *power;
> @@ -150,7 +147,10 @@ struct bcm2835_power {
>
>  static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
>  {
> +       void __iomem *base = power->asb;

I wonder the perf of defining base here vs the readability of
power->asb; throughout.

>         u64 start;
> +       u32 val;
> +
>
>         if (!reg)
>                 return 0;
> @@ -159,12 +159,13 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
>
>         /* Enable the module's async AXI bridges. */
>         if (enable) {
> -               ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
> +               val = readl(base + reg) & ~ASB_REQ_STOP;
>         } else {
> -               ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
> +               val = readl(base + reg) | ASB_REQ_STOP;
>         }
> +       writel(PM_PASSWORD | val, base + reg);
>
> -       while (ASB_READ(reg) & ASB_ACK) {
> +       while (readl(base + reg) & ASB_ACK) {
>                 cpu_relax();
>                 if (ktime_get_ns() - start >= 1000)
>                         return -ETIMEDOUT;
> @@ -622,7 +623,7 @@ static int bcm2835_power_probe(struct platform_device *pdev)
>         power->base = pm->base;
>         power->asb = pm->asb;
>
> -       id = ASB_READ(ASB_AXI_BRDG_ID);
> +       id = readl(power->asb + ASB_AXI_BRDG_ID);
>         if (id != 0x62726467 /* "BRDG" */) {
>                 dev_err(dev, "ASB register ID returned 0x%08x\n", id);
>                 return -ENODEV;
> --
> 2.25.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 10/11] soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB
  2022-05-15 20:20   ` Stefan Wahren
@ 2022-05-31 15:58     ` Peter Robinson
  -1 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 15:58 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
> with the ISP and H264 bits, and V3D is in the same place in the new ASB
> as the old one.
>
> Use the fact that 'pm->rpivid_asb' is populated as a hint that we're on
> BCM2711.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>

> ---
>  drivers/soc/bcm/bcm2835-power.c | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
> index fa0a13035794..1e06d91c0739 100644
> --- a/drivers/soc/bcm/bcm2835-power.c
> +++ b/drivers/soc/bcm/bcm2835-power.c
> @@ -126,6 +126,8 @@
>
>  #define ASB_AXI_BRDG_ID                        0x20
>
> +#define BCM2835_BRDG_ID                        0x62726467
> +
>  struct bcm2835_power_domain {
>         struct generic_pm_domain base;
>         struct bcm2835_power *power;
> @@ -139,6 +141,8 @@ struct bcm2835_power {
>         void __iomem            *base;
>         /* AXI Async bridge registers. */
>         void __iomem            *asb;
> +       /* RPiVid bridge registers. */
> +       void __iomem            *rpivid_asb;
>
>         struct genpd_onecell_data pd_xlate;
>         struct bcm2835_power_domain domains[BCM2835_POWER_DOMAIN_COUNT];
> @@ -151,9 +155,15 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
>         u64 start;
>         u32 val;
>
> -
> -       if (!reg)
> +       switch (reg) {
> +       case 0:
>                 return 0;
> +       case ASB_V3D_S_CTRL:
> +       case ASB_V3D_M_CTRL:
> +               if (power->rpivid_asb)
> +                       base = power->rpivid_asb;
> +               break;
> +       }
>
>         start = ktime_get_ns();
>
> @@ -622,13 +632,23 @@ static int bcm2835_power_probe(struct platform_device *pdev)
>         power->dev = dev;
>         power->base = pm->base;
>         power->asb = pm->asb;
> +       power->rpivid_asb = pm->rpivid_asb;
>
>         id = readl(power->asb + ASB_AXI_BRDG_ID);
> -       if (id != 0x62726467 /* "BRDG" */) {
> +       if (id != BCM2835_BRDG_ID /* "BRDG" */) {
>                 dev_err(dev, "ASB register ID returned 0x%08x\n", id);
>                 return -ENODEV;
>         }
>
> +       if (power->rpivid_asb) {
> +               id = readl(power->rpivid_asb + ASB_AXI_BRDG_ID);
> +               if (id != BCM2835_BRDG_ID /* "BRDG" */) {
> +                       dev_err(dev, "RPiVid ASB register ID returned 0x%08x\n",
> +                                    id);
> +                       return -ENODEV;
> +               }
> +       }
> +
>         power->pd_xlate.domains = devm_kcalloc(dev,
>                                                ARRAY_SIZE(power_domain_names),
>                                                sizeof(*power->pd_xlate.domains),
> --
> 2.25.1
>

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

* Re: [PATCH 10/11] soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB
@ 2022-05-31 15:58     ` Peter Robinson
  0 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 15:58 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
> with the ISP and H264 bits, and V3D is in the same place in the new ASB
> as the old one.
>
> Use the fact that 'pm->rpivid_asb' is populated as a hint that we're on
> BCM2711.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>

> ---
>  drivers/soc/bcm/bcm2835-power.c | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
> index fa0a13035794..1e06d91c0739 100644
> --- a/drivers/soc/bcm/bcm2835-power.c
> +++ b/drivers/soc/bcm/bcm2835-power.c
> @@ -126,6 +126,8 @@
>
>  #define ASB_AXI_BRDG_ID                        0x20
>
> +#define BCM2835_BRDG_ID                        0x62726467
> +
>  struct bcm2835_power_domain {
>         struct generic_pm_domain base;
>         struct bcm2835_power *power;
> @@ -139,6 +141,8 @@ struct bcm2835_power {
>         void __iomem            *base;
>         /* AXI Async bridge registers. */
>         void __iomem            *asb;
> +       /* RPiVid bridge registers. */
> +       void __iomem            *rpivid_asb;
>
>         struct genpd_onecell_data pd_xlate;
>         struct bcm2835_power_domain domains[BCM2835_POWER_DOMAIN_COUNT];
> @@ -151,9 +155,15 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
>         u64 start;
>         u32 val;
>
> -
> -       if (!reg)
> +       switch (reg) {
> +       case 0:
>                 return 0;
> +       case ASB_V3D_S_CTRL:
> +       case ASB_V3D_M_CTRL:
> +               if (power->rpivid_asb)
> +                       base = power->rpivid_asb;
> +               break;
> +       }
>
>         start = ktime_get_ns();
>
> @@ -622,13 +632,23 @@ static int bcm2835_power_probe(struct platform_device *pdev)
>         power->dev = dev;
>         power->base = pm->base;
>         power->asb = pm->asb;
> +       power->rpivid_asb = pm->rpivid_asb;
>
>         id = readl(power->asb + ASB_AXI_BRDG_ID);
> -       if (id != 0x62726467 /* "BRDG" */) {
> +       if (id != BCM2835_BRDG_ID /* "BRDG" */) {
>                 dev_err(dev, "ASB register ID returned 0x%08x\n", id);
>                 return -ENODEV;
>         }
>
> +       if (power->rpivid_asb) {
> +               id = readl(power->rpivid_asb + ASB_AXI_BRDG_ID);
> +               if (id != BCM2835_BRDG_ID /* "BRDG" */) {
> +                       dev_err(dev, "RPiVid ASB register ID returned 0x%08x\n",
> +                                    id);
> +                       return -ENODEV;
> +               }
> +       }
> +
>         power->pd_xlate.domains = devm_kcalloc(dev,
>                                                ARRAY_SIZE(power_domain_names),
>                                                sizeof(*power->pd_xlate.domains),
> --
> 2.25.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 11/11] soc: bcm: bcm2835-power: Bypass power_on/off() calls
  2022-05-15 20:20   ` Stefan Wahren
@ 2022-05-31 16:03     ` Peter Robinson
  -1 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 16:03 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Nicolas Saenz Julienne

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> Bypass power_on/power_off() when running on BCM2711 as they are not
> needed.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  drivers/soc/bcm/bcm2835-power.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
> index 1e06d91c0739..5bcd047768b6 100644
> --- a/drivers/soc/bcm/bcm2835-power.c
> +++ b/drivers/soc/bcm/bcm2835-power.c
> @@ -198,6 +198,10 @@ static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)
>  {
>         struct bcm2835_power *power = pd->power;
>
> +       /* We don't run this on BCM2711 */
> +       if (power->rpivid_asb)
> +               return 0;
> +
>         /* Enable functional isolation */
>         PM_WRITE(pm_reg, PM_READ(pm_reg) & ~PM_ISFUNC);
>
> @@ -219,6 +223,10 @@ static int bcm2835_power_power_on(struct bcm2835_power_domain *pd, u32 pm_reg)
>         int inrush;
>         bool powok;
>
> +       /* We don't run this on BCM2711 */
> +       if (power->rpivid_asb)
> +               return 0;
> +
>         /* If it was already powered on by the fw, leave it that way. */
>         if (PM_READ(pm_reg) & PM_POWUP)
>                 return 0;
> --
> 2.25.1
>

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

* Re: [PATCH 11/11] soc: bcm: bcm2835-power: Bypass power_on/off() calls
@ 2022-05-31 16:03     ` Peter Robinson
  0 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 16:03 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Nicolas Saenz Julienne

On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> Bypass power_on/power_off() when running on BCM2711 as they are not
> needed.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  drivers/soc/bcm/bcm2835-power.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
> index 1e06d91c0739..5bcd047768b6 100644
> --- a/drivers/soc/bcm/bcm2835-power.c
> +++ b/drivers/soc/bcm/bcm2835-power.c
> @@ -198,6 +198,10 @@ static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)
>  {
>         struct bcm2835_power *power = pd->power;
>
> +       /* We don't run this on BCM2711 */
> +       if (power->rpivid_asb)
> +               return 0;
> +
>         /* Enable functional isolation */
>         PM_WRITE(pm_reg, PM_READ(pm_reg) & ~PM_ISFUNC);
>
> @@ -219,6 +223,10 @@ static int bcm2835_power_power_on(struct bcm2835_power_domain *pd, u32 pm_reg)
>         int inrush;
>         bool powok;
>
> +       /* We don't run this on BCM2711 */
> +       if (power->rpivid_asb)
> +               return 0;
> +
>         /* If it was already powered on by the fw, leave it that way. */
>         if (PM_READ(pm_reg) & PM_POWUP)
>                 return 0;
> --
> 2.25.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 06/11] mfd: bcm2835-pm: Use 'reg-names' to get resources
  2022-05-31 14:54     ` Peter Robinson
@ 2022-05-31 17:12       ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-31 17:12 UTC (permalink / raw)
  To: Peter Robinson
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Nicolas Saenz Julienne

Hi Peter,

Am 31.05.22 um 16:54 schrieb Peter Robinson:
> On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>>
>> If available in firmware, find resources by their 'reg-names' position
>> instead of relying on hardcoded offsets. Care is taken to support old
>> firmware nonetheless.
> So this patch has changed a little over Nicolas's last one, which was
> what I based my patch on [1] but there's no changelog
>
> [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-7-pbrobinson@gmail.com/

yes my favorite changelog style is "within the cover letter". Since i 
started a new and split out series a version reference doesn't make 
sense. But yes, very unfortunate for a reviewer. Keeping the version 
number would have been better.

Here the changes since v4 afterwards:

- fix copy & paste issue in else branch
- don't use devm_platform_ioremap_resource_byname for optional register 
to avoid confusing log error
- pull out asb handling to avoid copy & paste

>
>> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> Minor comment inline, else:
> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
>> ---
>>   drivers/mfd/bcm2835-pm.c | 59 +++++++++++++++++++++++++++-------------
>>   1 file changed, 40 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
>> index 42fe67f1538e..1656d786993a 100644
>> --- a/drivers/mfd/bcm2835-pm.c
>> +++ b/drivers/mfd/bcm2835-pm.c
>> @@ -25,9 +25,41 @@ static const struct mfd_cell bcm2835_power_devs[] = {
>>          { .name = "bcm2835-power" },
>>   };
>>
>> +static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>> +                               struct bcm2835_pm *pm)
>> +{
>> +       /* If no 'reg-names' property is found we can assume we're using old
>> +        * firmware.
>> +        */
>> +       if (!of_find_property(pm->dev->of_node, "reg-names", NULL)) {
>> +               dev_warn(pm->dev, "Old devicetree detected, please update your firmware.\n");
> If they're using an upstream kernel DT and an old firmware this may be
> confusing, maybe tweak the wording a little?

"reg-names are missing, please update your DTB.\ņ"

>> +               pm->base = devm_platform_ioremap_resource(pdev, 0);
>> +               if (IS_ERR(pm->base))
>> +                       return PTR_ERR(pm->base);
>> +
>> +               pm->asb = devm_platform_ioremap_resource(pdev, 1);
>> +       } else {
>> +               struct resource *res;
>> +
>> +               pm->base = devm_platform_ioremap_resource_byname(pdev, "pm");
>> +               if (IS_ERR(pm->base))
>> +                       return PTR_ERR(pm->base);
>> +
>> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
>> +                                                   "asb");
>> +               if (res)
>> +                       pm->asb = devm_ioremap_resource(&pdev->dev, res);
>> +       }
>> +
>> +       if (IS_ERR(pm->asb))
>> +               pm->asb = NULL;
>> +
>> +       return 0;
>> +}
>> +
>>   static int bcm2835_pm_probe(struct platform_device *pdev)
>>   {
>> -       struct resource *res;
>>          struct device *dev = &pdev->dev;
>>          struct bcm2835_pm *pm;
>>          int ret;
>> @@ -39,10 +71,9 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>>
>>          pm->dev = dev;
>>
>> -       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> -       pm->base = devm_ioremap_resource(dev, res);
>> -       if (IS_ERR(pm->base))
>> -               return PTR_ERR(pm->base);
>> +       ret = bcm2835_pm_get_pdata(pdev, pm);
>> +       if (ret)
>> +               return ret;
>>
>>          ret = devm_mfd_add_devices(dev, -1,
>>                                     bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs),
>> @@ -54,20 +85,10 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>>           * bcm2835-pm binding as the key for whether we can reference
>>           * the full PM register range and support power domains.
>>           */
>> -       res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>> -       if (res) {
>> -               pm->asb = devm_ioremap_resource(dev, res);
>> -               if (IS_ERR(pm->asb))
>> -                       return PTR_ERR(pm->asb);
>> -
>> -               ret = devm_mfd_add_devices(dev, -1,
>> -                                          bcm2835_power_devs,
>> -                                          ARRAY_SIZE(bcm2835_power_devs),
>> -                                          NULL, 0, NULL);
>> -               if (ret)
>> -                       return ret;
>> -       }
>> -
>> +       if (pm->asb)
>> +               return devm_mfd_add_devices(dev, -1, bcm2835_power_devs,
>> +                                           ARRAY_SIZE(bcm2835_power_devs),
>> +                                           NULL, 0, NULL);
>>          return 0;
>>   }
>>
>> --
>> 2.25.1
>>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 06/11] mfd: bcm2835-pm: Use 'reg-names' to get resources
@ 2022-05-31 17:12       ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-31 17:12 UTC (permalink / raw)
  To: Peter Robinson
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel,
	Nicolas Saenz Julienne

Hi Peter,

Am 31.05.22 um 16:54 schrieb Peter Robinson:
> On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>>
>> If available in firmware, find resources by their 'reg-names' position
>> instead of relying on hardcoded offsets. Care is taken to support old
>> firmware nonetheless.
> So this patch has changed a little over Nicolas's last one, which was
> what I based my patch on [1] but there's no changelog
>
> [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-7-pbrobinson@gmail.com/

yes my favorite changelog style is "within the cover letter". Since i 
started a new and split out series a version reference doesn't make 
sense. But yes, very unfortunate for a reviewer. Keeping the version 
number would have been better.

Here the changes since v4 afterwards:

- fix copy & paste issue in else branch
- don't use devm_platform_ioremap_resource_byname for optional register 
to avoid confusing log error
- pull out asb handling to avoid copy & paste

>
>> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> Minor comment inline, else:
> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
>> ---
>>   drivers/mfd/bcm2835-pm.c | 59 +++++++++++++++++++++++++++-------------
>>   1 file changed, 40 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
>> index 42fe67f1538e..1656d786993a 100644
>> --- a/drivers/mfd/bcm2835-pm.c
>> +++ b/drivers/mfd/bcm2835-pm.c
>> @@ -25,9 +25,41 @@ static const struct mfd_cell bcm2835_power_devs[] = {
>>          { .name = "bcm2835-power" },
>>   };
>>
>> +static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>> +                               struct bcm2835_pm *pm)
>> +{
>> +       /* If no 'reg-names' property is found we can assume we're using old
>> +        * firmware.
>> +        */
>> +       if (!of_find_property(pm->dev->of_node, "reg-names", NULL)) {
>> +               dev_warn(pm->dev, "Old devicetree detected, please update your firmware.\n");
> If they're using an upstream kernel DT and an old firmware this may be
> confusing, maybe tweak the wording a little?

"reg-names are missing, please update your DTB.\ņ"

>> +               pm->base = devm_platform_ioremap_resource(pdev, 0);
>> +               if (IS_ERR(pm->base))
>> +                       return PTR_ERR(pm->base);
>> +
>> +               pm->asb = devm_platform_ioremap_resource(pdev, 1);
>> +       } else {
>> +               struct resource *res;
>> +
>> +               pm->base = devm_platform_ioremap_resource_byname(pdev, "pm");
>> +               if (IS_ERR(pm->base))
>> +                       return PTR_ERR(pm->base);
>> +
>> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
>> +                                                   "asb");
>> +               if (res)
>> +                       pm->asb = devm_ioremap_resource(&pdev->dev, res);
>> +       }
>> +
>> +       if (IS_ERR(pm->asb))
>> +               pm->asb = NULL;
>> +
>> +       return 0;
>> +}
>> +
>>   static int bcm2835_pm_probe(struct platform_device *pdev)
>>   {
>> -       struct resource *res;
>>          struct device *dev = &pdev->dev;
>>          struct bcm2835_pm *pm;
>>          int ret;
>> @@ -39,10 +71,9 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>>
>>          pm->dev = dev;
>>
>> -       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> -       pm->base = devm_ioremap_resource(dev, res);
>> -       if (IS_ERR(pm->base))
>> -               return PTR_ERR(pm->base);
>> +       ret = bcm2835_pm_get_pdata(pdev, pm);
>> +       if (ret)
>> +               return ret;
>>
>>          ret = devm_mfd_add_devices(dev, -1,
>>                                     bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs),
>> @@ -54,20 +85,10 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>>           * bcm2835-pm binding as the key for whether we can reference
>>           * the full PM register range and support power domains.
>>           */
>> -       res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>> -       if (res) {
>> -               pm->asb = devm_ioremap_resource(dev, res);
>> -               if (IS_ERR(pm->asb))
>> -                       return PTR_ERR(pm->asb);
>> -
>> -               ret = devm_mfd_add_devices(dev, -1,
>> -                                          bcm2835_power_devs,
>> -                                          ARRAY_SIZE(bcm2835_power_devs),
>> -                                          NULL, 0, NULL);
>> -               if (ret)
>> -                       return ret;
>> -       }
>> -
>> +       if (pm->asb)
>> +               return devm_mfd_add_devices(dev, -1, bcm2835_power_devs,
>> +                                           ARRAY_SIZE(bcm2835_power_devs),
>> +                                           NULL, 0, NULL);
>>          return 0;
>>   }
>>
>> --
>> 2.25.1
>>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
  2022-05-31 15:08     ` Peter Robinson
@ 2022-05-31 17:27       ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-31 17:27 UTC (permalink / raw)
  To: Peter Robinson
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

Hi Peter,

Am 31.05.22 um 17:08 schrieb Peter Robinson:
> On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
>> with the ISP and H264 bits, and V3D is in the same place in the new ASB
>> as the old one.
>>
>> As per the devicetree bindings, BCM2711 will provide both the old and
>> new ASB resources, so get both of them and pass them into
>> 'bcm2835-power,' which will take care of selecting which one to use
>> accordingly.
>>
>> Since the RPiVid ASB's resources were being provided prior to formalizing
>> the bindings[1], also support the old firmwares that didn't use
> I'm guessing this [1] is referring to "[1] See: 7dbe8c62ceeb ("ARM:
> dts: Add minimal Raspberry Pi 4 support")" referred to in the original
> patch [1] that Nicolas did, was there a reason to drop the
> details/changelog here?
Oops, the link accidently get lost.
> The decision not to use bits makes sense I
> believe.
Yes, i think the new version is more elegant.
>
> [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-8-pbrobinson@gmail.com/
>
>> 'reg-names.'
>>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>> ---
>>   drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
>>   include/linux/mfd/bcm2835-pm.h |  1 +
>>   2 files changed, 19 insertions(+)
>>
>> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
>> index 1656d786993a..da110767c6a4 100644
>> --- a/drivers/mfd/bcm2835-pm.c
>> +++ b/drivers/mfd/bcm2835-pm.c
>> @@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
>>   static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>                                  struct bcm2835_pm *pm)
>>   {
>> +       bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
>> +
>>          /* If no 'reg-names' property is found we can assume we're using old
>>           * firmware.
>>           */
>> @@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>                          return PTR_ERR(pm->base);
>>
>>                  pm->asb = devm_platform_ioremap_resource(pdev, 1);
>> +               pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
> Shouldn't we check if is_bcm2711 before we assign rpivid_asb above?
Yes, make sense.
>
>>          } else {
>>                  struct resource *res;
>>
>> @@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>                                                      "asb");
>>                  if (res)
>>                          pm->asb = devm_ioremap_resource(&pdev->dev, res);
>> +
>> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
>> +                                                   "rpivid_asb");
>> +               if (res)
>> +                       pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
>> +                                                               res);
>>          }
>>
>>          if (IS_ERR(pm->asb))
>>                  pm->asb = NULL;
>>
>> +       if (IS_ERR(pm->rpivid_asb))
>> +               pm->rpivid_asb = NULL;
>> +
>> +       if (pm->rpivid_asb && !is_bcm2711) {
>> +               dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");
> Should we ever get into this situation? If it's an older get RPi I'm
> guessing pm->rpivid_asb should have been set to NULL from the error
> above.
I think this was a warning for older BCM2711 downstream DT files which 
had rpivid_asb register but no BCM2711 compatible.
>> +               return -EINVAL;
>> +       }
>> +
>>          return 0;
>>   }
>>
>> @@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>>   static const struct of_device_id bcm2835_pm_of_match[] = {
>>          { .compatible = "brcm,bcm2835-pm-wdt", },
>>          { .compatible = "brcm,bcm2835-pm", },
>> +       { .compatible = "brcm,bcm2711-pm", },
>>          {},
>>   };
>>   MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
>> diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
>> index ed37dc40e82a..f70a810c55f7 100644
>> --- a/include/linux/mfd/bcm2835-pm.h
>> +++ b/include/linux/mfd/bcm2835-pm.h
>> @@ -9,6 +9,7 @@ struct bcm2835_pm {
>>          struct device *dev;
>>          void __iomem *base;
>>          void __iomem *asb;
>> +       void __iomem *rpivid_asb;
>>   };
>>
>>   #endif /* BCM2835_MFD_PM_H */
>> --
>> 2.25.1
>>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
@ 2022-05-31 17:27       ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-31 17:27 UTC (permalink / raw)
  To: Peter Robinson
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

Hi Peter,

Am 31.05.22 um 17:08 schrieb Peter Robinson:
> On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
>> with the ISP and H264 bits, and V3D is in the same place in the new ASB
>> as the old one.
>>
>> As per the devicetree bindings, BCM2711 will provide both the old and
>> new ASB resources, so get both of them and pass them into
>> 'bcm2835-power,' which will take care of selecting which one to use
>> accordingly.
>>
>> Since the RPiVid ASB's resources were being provided prior to formalizing
>> the bindings[1], also support the old firmwares that didn't use
> I'm guessing this [1] is referring to "[1] See: 7dbe8c62ceeb ("ARM:
> dts: Add minimal Raspberry Pi 4 support")" referred to in the original
> patch [1] that Nicolas did, was there a reason to drop the
> details/changelog here?
Oops, the link accidently get lost.
> The decision not to use bits makes sense I
> believe.
Yes, i think the new version is more elegant.
>
> [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-8-pbrobinson@gmail.com/
>
>> 'reg-names.'
>>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>> ---
>>   drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
>>   include/linux/mfd/bcm2835-pm.h |  1 +
>>   2 files changed, 19 insertions(+)
>>
>> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
>> index 1656d786993a..da110767c6a4 100644
>> --- a/drivers/mfd/bcm2835-pm.c
>> +++ b/drivers/mfd/bcm2835-pm.c
>> @@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
>>   static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>                                  struct bcm2835_pm *pm)
>>   {
>> +       bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
>> +
>>          /* If no 'reg-names' property is found we can assume we're using old
>>           * firmware.
>>           */
>> @@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>                          return PTR_ERR(pm->base);
>>
>>                  pm->asb = devm_platform_ioremap_resource(pdev, 1);
>> +               pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
> Shouldn't we check if is_bcm2711 before we assign rpivid_asb above?
Yes, make sense.
>
>>          } else {
>>                  struct resource *res;
>>
>> @@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>                                                      "asb");
>>                  if (res)
>>                          pm->asb = devm_ioremap_resource(&pdev->dev, res);
>> +
>> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
>> +                                                   "rpivid_asb");
>> +               if (res)
>> +                       pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
>> +                                                               res);
>>          }
>>
>>          if (IS_ERR(pm->asb))
>>                  pm->asb = NULL;
>>
>> +       if (IS_ERR(pm->rpivid_asb))
>> +               pm->rpivid_asb = NULL;
>> +
>> +       if (pm->rpivid_asb && !is_bcm2711) {
>> +               dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");
> Should we ever get into this situation? If it's an older get RPi I'm
> guessing pm->rpivid_asb should have been set to NULL from the error
> above.
I think this was a warning for older BCM2711 downstream DT files which 
had rpivid_asb register but no BCM2711 compatible.
>> +               return -EINVAL;
>> +       }
>> +
>>          return 0;
>>   }
>>
>> @@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>>   static const struct of_device_id bcm2835_pm_of_match[] = {
>>          { .compatible = "brcm,bcm2835-pm-wdt", },
>>          { .compatible = "brcm,bcm2835-pm", },
>> +       { .compatible = "brcm,bcm2711-pm", },
>>          {},
>>   };
>>   MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
>> diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
>> index ed37dc40e82a..f70a810c55f7 100644
>> --- a/include/linux/mfd/bcm2835-pm.h
>> +++ b/include/linux/mfd/bcm2835-pm.h
>> @@ -9,6 +9,7 @@ struct bcm2835_pm {
>>          struct device *dev;
>>          void __iomem *base;
>>          void __iomem *asb;
>> +       void __iomem *rpivid_asb;
>>   };
>>
>>   #endif /* BCM2835_MFD_PM_H */
>> --
>> 2.25.1
>>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 09/11] soc: bcm: bcm2835-power: Resolve ASB register macros
  2022-05-31 15:47     ` Peter Robinson
@ 2022-05-31 17:34       ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-31 17:34 UTC (permalink / raw)
  To: Peter Robinson
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

Hi Peter,

Am 31.05.22 um 17:47 schrieb Peter Robinson:
> On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> The macros in order to access the ASB registers have a hard coded base
>> address. So extending them for other platforms would make them harder
>> to read. As a solution resolve these macros.
>>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> A minor query below:
> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
>> ---
>>   drivers/soc/bcm/bcm2835-power.c | 15 ++++++++-------
>>   1 file changed, 8 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
>> index 77dc9e62b207..fa0a13035794 100644
>> --- a/drivers/soc/bcm/bcm2835-power.c
>> +++ b/drivers/soc/bcm/bcm2835-power.c
>> @@ -126,9 +126,6 @@
>>
>>   #define ASB_AXI_BRDG_ID                        0x20
>>
>> -#define ASB_READ(reg) readl(power->asb + (reg))
>> -#define ASB_WRITE(reg, val) writel(PM_PASSWORD | (val), power->asb + (reg))
>> -
>>   struct bcm2835_power_domain {
>>          struct generic_pm_domain base;
>>          struct bcm2835_power *power;
>> @@ -150,7 +147,10 @@ struct bcm2835_power {
>>
>>   static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
>>   {
>> +       void __iomem *base = power->asb;
> I wonder the perf of defining base here vs the readability of
> power->asb; throughout.
this is the whole "trick" in order to change the base to rpivid_asb in 
patch #10.
>
>>          u64 start;
>> +       u32 val;
>> +
>>
>>          if (!reg)
>>                  return 0;
>> @@ -159,12 +159,13 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
>>
>>          /* Enable the module's async AXI bridges. */
>>          if (enable) {
>> -               ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
>> +               val = readl(base + reg) & ~ASB_REQ_STOP;
>>          } else {
>> -               ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
>> +               val = readl(base + reg) | ASB_REQ_STOP;
>>          }
>> +       writel(PM_PASSWORD | val, base + reg);
>>
>> -       while (ASB_READ(reg) & ASB_ACK) {
>> +       while (readl(base + reg) & ASB_ACK) {
>>                  cpu_relax();
>>                  if (ktime_get_ns() - start >= 1000)
>>                          return -ETIMEDOUT;
>> @@ -622,7 +623,7 @@ static int bcm2835_power_probe(struct platform_device *pdev)
>>          power->base = pm->base;
>>          power->asb = pm->asb;
>>
>> -       id = ASB_READ(ASB_AXI_BRDG_ID);
>> +       id = readl(power->asb + ASB_AXI_BRDG_ID);
>>          if (id != 0x62726467 /* "BRDG" */) {
>>                  dev_err(dev, "ASB register ID returned 0x%08x\n", id);
>>                  return -ENODEV;
>> --
>> 2.25.1
>>

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

* Re: [PATCH 09/11] soc: bcm: bcm2835-power: Resolve ASB register macros
@ 2022-05-31 17:34       ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-31 17:34 UTC (permalink / raw)
  To: Peter Robinson
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

Hi Peter,

Am 31.05.22 um 17:47 schrieb Peter Robinson:
> On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> The macros in order to access the ASB registers have a hard coded base
>> address. So extending them for other platforms would make them harder
>> to read. As a solution resolve these macros.
>>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> A minor query below:
> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
>> ---
>>   drivers/soc/bcm/bcm2835-power.c | 15 ++++++++-------
>>   1 file changed, 8 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
>> index 77dc9e62b207..fa0a13035794 100644
>> --- a/drivers/soc/bcm/bcm2835-power.c
>> +++ b/drivers/soc/bcm/bcm2835-power.c
>> @@ -126,9 +126,6 @@
>>
>>   #define ASB_AXI_BRDG_ID                        0x20
>>
>> -#define ASB_READ(reg) readl(power->asb + (reg))
>> -#define ASB_WRITE(reg, val) writel(PM_PASSWORD | (val), power->asb + (reg))
>> -
>>   struct bcm2835_power_domain {
>>          struct generic_pm_domain base;
>>          struct bcm2835_power *power;
>> @@ -150,7 +147,10 @@ struct bcm2835_power {
>>
>>   static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
>>   {
>> +       void __iomem *base = power->asb;
> I wonder the perf of defining base here vs the readability of
> power->asb; throughout.
this is the whole "trick" in order to change the base to rpivid_asb in 
patch #10.
>
>>          u64 start;
>> +       u32 val;
>> +
>>
>>          if (!reg)
>>                  return 0;
>> @@ -159,12 +159,13 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
>>
>>          /* Enable the module's async AXI bridges. */
>>          if (enable) {
>> -               ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
>> +               val = readl(base + reg) & ~ASB_REQ_STOP;
>>          } else {
>> -               ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
>> +               val = readl(base + reg) | ASB_REQ_STOP;
>>          }
>> +       writel(PM_PASSWORD | val, base + reg);
>>
>> -       while (ASB_READ(reg) & ASB_ACK) {
>> +       while (readl(base + reg) & ASB_ACK) {
>>                  cpu_relax();
>>                  if (ktime_get_ns() - start >= 1000)
>>                          return -ETIMEDOUT;
>> @@ -622,7 +623,7 @@ static int bcm2835_power_probe(struct platform_device *pdev)
>>          power->base = pm->base;
>>          power->asb = pm->asb;
>>
>> -       id = ASB_READ(ASB_AXI_BRDG_ID);
>> +       id = readl(power->asb + ASB_AXI_BRDG_ID);
>>          if (id != 0x62726467 /* "BRDG" */) {
>>                  dev_err(dev, "ASB register ID returned 0x%08x\n", id);
>>                  return -ENODEV;
>> --
>> 2.25.1
>>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
  2022-05-31 17:27       ` Stefan Wahren
@ 2022-05-31 20:11         ` Peter Robinson
  -1 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 20:11 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

Hi Stefan,

On Tue, May 31, 2022 at 6:27 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> Hi Peter,
>
> Am 31.05.22 um 17:08 schrieb Peter Robinson:
> > On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
> >> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
> >> with the ISP and H264 bits, and V3D is in the same place in the new ASB
> >> as the old one.
> >>
> >> As per the devicetree bindings, BCM2711 will provide both the old and
> >> new ASB resources, so get both of them and pass them into
> >> 'bcm2835-power,' which will take care of selecting which one to use
> >> accordingly.
> >>
> >> Since the RPiVid ASB's resources were being provided prior to formalizing
> >> the bindings[1], also support the old firmwares that didn't use
> > I'm guessing this [1] is referring to "[1] See: 7dbe8c62ceeb ("ARM:
> > dts: Add minimal Raspberry Pi 4 support")" referred to in the original
> > patch [1] that Nicolas did, was there a reason to drop the
> > details/changelog here?
> Oops, the link accidently get lost.
> > The decision not to use bits makes sense I
> > believe.
> Yes, i think the new version is more elegant.
> >
> > [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-8-pbrobinson@gmail.com/
> >
> >> 'reg-names.'
> >>
> >> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> >> ---
> >>   drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
> >>   include/linux/mfd/bcm2835-pm.h |  1 +
> >>   2 files changed, 19 insertions(+)
> >>
> >> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
> >> index 1656d786993a..da110767c6a4 100644
> >> --- a/drivers/mfd/bcm2835-pm.c
> >> +++ b/drivers/mfd/bcm2835-pm.c
> >> @@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
> >>   static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>                                  struct bcm2835_pm *pm)
> >>   {
> >> +       bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
> >> +
> >>          /* If no 'reg-names' property is found we can assume we're using old
> >>           * firmware.
> >>           */
> >> @@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>                          return PTR_ERR(pm->base);
> >>
> >>                  pm->asb = devm_platform_ioremap_resource(pdev, 1);
> >> +               pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
> > Shouldn't we check if is_bcm2711 before we assign rpivid_asb above?
> Yes, make sense.
> >
> >>          } else {
> >>                  struct resource *res;
> >>
> >> @@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>                                                      "asb");
> >>                  if (res)
> >>                          pm->asb = devm_ioremap_resource(&pdev->dev, res);
> >> +
> >> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> >> +                                                   "rpivid_asb");
> >> +               if (res)
> >> +                       pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
> >> +                                                               res);
> >>          }
> >>
> >>          if (IS_ERR(pm->asb))
> >>                  pm->asb = NULL;
> >>
> >> +       if (IS_ERR(pm->rpivid_asb))
> >> +               pm->rpivid_asb = NULL;
> >> +
> >> +       if (pm->rpivid_asb && !is_bcm2711) {
> >> +               dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");
> > Should we ever get into this situation? If it's an older get RPi I'm
> > guessing pm->rpivid_asb should have been set to NULL from the error
> > above.
> I think this was a warning for older BCM2711 downstream DT files which
> had rpivid_asb register but no BCM2711 compatible.

Based on the history I remember that makes sense, but the warning is a
bit misleading in the context given it would actually be a 2711. Is it
purely a DT check or is does the version of VC firmware come into play
here too, I seem to remember firmware was used to make some things
work on older OSes in the early days of RPi4 (although it's hard to
tell exactly what was done, and I've tried to forget).

> >> +               return -EINVAL;
> >> +       }
> >> +
> >>          return 0;
> >>   }
> >>
> >> @@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
> >>   static const struct of_device_id bcm2835_pm_of_match[] = {
> >>          { .compatible = "brcm,bcm2835-pm-wdt", },
> >>          { .compatible = "brcm,bcm2835-pm", },
> >> +       { .compatible = "brcm,bcm2711-pm", },
> >>          {},
> >>   };
> >>   MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
> >> diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
> >> index ed37dc40e82a..f70a810c55f7 100644
> >> --- a/include/linux/mfd/bcm2835-pm.h
> >> +++ b/include/linux/mfd/bcm2835-pm.h
> >> @@ -9,6 +9,7 @@ struct bcm2835_pm {
> >>          struct device *dev;
> >>          void __iomem *base;
> >>          void __iomem *asb;
> >> +       void __iomem *rpivid_asb;
> >>   };
> >>
> >>   #endif /* BCM2835_MFD_PM_H */
> >> --
> >> 2.25.1
> >>
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
@ 2022-05-31 20:11         ` Peter Robinson
  0 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-05-31 20:11 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

Hi Stefan,

On Tue, May 31, 2022 at 6:27 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>
> Hi Peter,
>
> Am 31.05.22 um 17:08 schrieb Peter Robinson:
> > On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
> >> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
> >> with the ISP and H264 bits, and V3D is in the same place in the new ASB
> >> as the old one.
> >>
> >> As per the devicetree bindings, BCM2711 will provide both the old and
> >> new ASB resources, so get both of them and pass them into
> >> 'bcm2835-power,' which will take care of selecting which one to use
> >> accordingly.
> >>
> >> Since the RPiVid ASB's resources were being provided prior to formalizing
> >> the bindings[1], also support the old firmwares that didn't use
> > I'm guessing this [1] is referring to "[1] See: 7dbe8c62ceeb ("ARM:
> > dts: Add minimal Raspberry Pi 4 support")" referred to in the original
> > patch [1] that Nicolas did, was there a reason to drop the
> > details/changelog here?
> Oops, the link accidently get lost.
> > The decision not to use bits makes sense I
> > believe.
> Yes, i think the new version is more elegant.
> >
> > [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-8-pbrobinson@gmail.com/
> >
> >> 'reg-names.'
> >>
> >> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> >> ---
> >>   drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
> >>   include/linux/mfd/bcm2835-pm.h |  1 +
> >>   2 files changed, 19 insertions(+)
> >>
> >> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
> >> index 1656d786993a..da110767c6a4 100644
> >> --- a/drivers/mfd/bcm2835-pm.c
> >> +++ b/drivers/mfd/bcm2835-pm.c
> >> @@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
> >>   static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>                                  struct bcm2835_pm *pm)
> >>   {
> >> +       bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
> >> +
> >>          /* If no 'reg-names' property is found we can assume we're using old
> >>           * firmware.
> >>           */
> >> @@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>                          return PTR_ERR(pm->base);
> >>
> >>                  pm->asb = devm_platform_ioremap_resource(pdev, 1);
> >> +               pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
> > Shouldn't we check if is_bcm2711 before we assign rpivid_asb above?
> Yes, make sense.
> >
> >>          } else {
> >>                  struct resource *res;
> >>
> >> @@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>                                                      "asb");
> >>                  if (res)
> >>                          pm->asb = devm_ioremap_resource(&pdev->dev, res);
> >> +
> >> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> >> +                                                   "rpivid_asb");
> >> +               if (res)
> >> +                       pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
> >> +                                                               res);
> >>          }
> >>
> >>          if (IS_ERR(pm->asb))
> >>                  pm->asb = NULL;
> >>
> >> +       if (IS_ERR(pm->rpivid_asb))
> >> +               pm->rpivid_asb = NULL;
> >> +
> >> +       if (pm->rpivid_asb && !is_bcm2711) {
> >> +               dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");
> > Should we ever get into this situation? If it's an older get RPi I'm
> > guessing pm->rpivid_asb should have been set to NULL from the error
> > above.
> I think this was a warning for older BCM2711 downstream DT files which
> had rpivid_asb register but no BCM2711 compatible.

Based on the history I remember that makes sense, but the warning is a
bit misleading in the context given it would actually be a 2711. Is it
purely a DT check or is does the version of VC firmware come into play
here too, I seem to remember firmware was used to make some things
work on older OSes in the early days of RPi4 (although it's hard to
tell exactly what was done, and I've tried to forget).

> >> +               return -EINVAL;
> >> +       }
> >> +
> >>          return 0;
> >>   }
> >>
> >> @@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
> >>   static const struct of_device_id bcm2835_pm_of_match[] = {
> >>          { .compatible = "brcm,bcm2835-pm-wdt", },
> >>          { .compatible = "brcm,bcm2835-pm", },
> >> +       { .compatible = "brcm,bcm2711-pm", },
> >>          {},
> >>   };
> >>   MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
> >> diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
> >> index ed37dc40e82a..f70a810c55f7 100644
> >> --- a/include/linux/mfd/bcm2835-pm.h
> >> +++ b/include/linux/mfd/bcm2835-pm.h
> >> @@ -9,6 +9,7 @@ struct bcm2835_pm {
> >>          struct device *dev;
> >>          void __iomem *base;
> >>          void __iomem *asb;
> >> +       void __iomem *rpivid_asb;
> >>   };
> >>
> >>   #endif /* BCM2835_MFD_PM_H */
> >> --
> >> 2.25.1
> >>
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
  2022-05-31 20:11         ` Peter Robinson
@ 2022-05-31 22:03           ` Stefan Wahren
  -1 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-31 22:03 UTC (permalink / raw)
  To: Peter Robinson
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

Hi Peter,

Am 31.05.22 um 22:11 schrieb Peter Robinson:
> Hi Stefan,
>
> On Tue, May 31, 2022 at 6:27 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> Hi Peter,
>>
>> Am 31.05.22 um 17:08 schrieb Peter Robinson:
>>> On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>>>> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
>>>> with the ISP and H264 bits, and V3D is in the same place in the new ASB
>>>> as the old one.
>>>>
>>>> As per the devicetree bindings, BCM2711 will provide both the old and
>>>> new ASB resources, so get both of them and pass them into
>>>> 'bcm2835-power,' which will take care of selecting which one to use
>>>> accordingly.
>>>>
>>>> Since the RPiVid ASB's resources were being provided prior to formalizing
>>>> the bindings[1], also support the old firmwares that didn't use
>>> I'm guessing this [1] is referring to "[1] See: 7dbe8c62ceeb ("ARM:
>>> dts: Add minimal Raspberry Pi 4 support")" referred to in the original
>>> patch [1] that Nicolas did, was there a reason to drop the
>>> details/changelog here?
>> Oops, the link accidently get lost.
>>> The decision not to use bits makes sense I
>>> believe.
>> Yes, i think the new version is more elegant.
>>> [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-8-pbrobinson@gmail.com/
>>>
>>>> 'reg-names.'
>>>>
>>>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>>>> ---
>>>>    drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
>>>>    include/linux/mfd/bcm2835-pm.h |  1 +
>>>>    2 files changed, 19 insertions(+)
>>>>
>>>> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
>>>> index 1656d786993a..da110767c6a4 100644
>>>> --- a/drivers/mfd/bcm2835-pm.c
>>>> +++ b/drivers/mfd/bcm2835-pm.c
>>>> @@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
>>>>    static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>>>                                   struct bcm2835_pm *pm)
>>>>    {
>>>> +       bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
>>>> +
>>>>           /* If no 'reg-names' property is found we can assume we're using old
>>>>            * firmware.
>>>>            */
>>>> @@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>>>                           return PTR_ERR(pm->base);
>>>>
>>>>                   pm->asb = devm_platform_ioremap_resource(pdev, 1);
>>>> +               pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
>>> Shouldn't we check if is_bcm2711 before we assign rpivid_asb above?
>> Yes, make sense.
>>>>           } else {
>>>>                   struct resource *res;
>>>>
>>>> @@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>>>                                                       "asb");
>>>>                   if (res)
>>>>                           pm->asb = devm_ioremap_resource(&pdev->dev, res);
>>>> +
>>>> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
>>>> +                                                   "rpivid_asb");
>>>> +               if (res)
>>>> +                       pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
>>>> +                                                               res);
>>>>           }
>>>>
>>>>           if (IS_ERR(pm->asb))
>>>>                   pm->asb = NULL;
>>>>
>>>> +       if (IS_ERR(pm->rpivid_asb))
>>>> +               pm->rpivid_asb = NULL;
>>>> +
>>>> +       if (pm->rpivid_asb && !is_bcm2711) {
>>>> +               dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");
>>> Should we ever get into this situation? If it's an older get RPi I'm
>>> guessing pm->rpivid_asb should have been set to NULL from the error
>>> above.
>> I think this was a warning for older BCM2711 downstream DT files which
>> had rpivid_asb register but no BCM2711 compatible.
> Based on the history I remember that makes sense, but the warning is a
> bit misleading in the context given it would actually be a 2711. Is it
> purely a DT check or is does the version of VC firmware come into play
> here too, I seem to remember firmware was used to make some things
> work on older OSes in the early days of RPi4 (although it's hard to
> tell exactly what was done, and I've tried to forget).

Sorry, my fault. This isn't a warning. It's an error. This driver bail 
out as soon the DT is unexpected, which could otherwise lead to 
unexpected behavior of the power driver (rpivid_asb will be interpret as 
BCM2711). There is no firmware involved, just a pure DT. Maybe i should 
add a comment about this assumption here.

Suggested error message:

"Unexpected rpivid_asb register, please fix your DTB.\ņ"

>
>>>> +               return -EINVAL;
>>>> +       }
>>>> +
>>>>           return 0;
>>>>    }
>>>>
>>>> @@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>>>>    static const struct of_device_id bcm2835_pm_of_match[] = {
>>>>           { .compatible = "brcm,bcm2835-pm-wdt", },
>>>>           { .compatible = "brcm,bcm2835-pm", },
>>>> +       { .compatible = "brcm,bcm2711-pm", },
>>>>           {},
>>>>    };
>>>>    MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
>>>> diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
>>>> index ed37dc40e82a..f70a810c55f7 100644
>>>> --- a/include/linux/mfd/bcm2835-pm.h
>>>> +++ b/include/linux/mfd/bcm2835-pm.h
>>>> @@ -9,6 +9,7 @@ struct bcm2835_pm {
>>>>           struct device *dev;
>>>>           void __iomem *base;
>>>>           void __iomem *asb;
>>>> +       void __iomem *rpivid_asb;
>>>>    };
>>>>
>>>>    #endif /* BCM2835_MFD_PM_H */
>>>> --
>>>> 2.25.1
>>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> linux-arm-kernel@lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
@ 2022-05-31 22:03           ` Stefan Wahren
  0 siblings, 0 replies; 56+ messages in thread
From: Stefan Wahren @ 2022-05-31 22:03 UTC (permalink / raw)
  To: Peter Robinson
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

Hi Peter,

Am 31.05.22 um 22:11 schrieb Peter Robinson:
> Hi Stefan,
>
> On Tue, May 31, 2022 at 6:27 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> Hi Peter,
>>
>> Am 31.05.22 um 17:08 schrieb Peter Robinson:
>>> On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
>>>> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
>>>> with the ISP and H264 bits, and V3D is in the same place in the new ASB
>>>> as the old one.
>>>>
>>>> As per the devicetree bindings, BCM2711 will provide both the old and
>>>> new ASB resources, so get both of them and pass them into
>>>> 'bcm2835-power,' which will take care of selecting which one to use
>>>> accordingly.
>>>>
>>>> Since the RPiVid ASB's resources were being provided prior to formalizing
>>>> the bindings[1], also support the old firmwares that didn't use
>>> I'm guessing this [1] is referring to "[1] See: 7dbe8c62ceeb ("ARM:
>>> dts: Add minimal Raspberry Pi 4 support")" referred to in the original
>>> patch [1] that Nicolas did, was there a reason to drop the
>>> details/changelog here?
>> Oops, the link accidently get lost.
>>> The decision not to use bits makes sense I
>>> believe.
>> Yes, i think the new version is more elegant.
>>> [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-8-pbrobinson@gmail.com/
>>>
>>>> 'reg-names.'
>>>>
>>>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>>>> ---
>>>>    drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
>>>>    include/linux/mfd/bcm2835-pm.h |  1 +
>>>>    2 files changed, 19 insertions(+)
>>>>
>>>> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
>>>> index 1656d786993a..da110767c6a4 100644
>>>> --- a/drivers/mfd/bcm2835-pm.c
>>>> +++ b/drivers/mfd/bcm2835-pm.c
>>>> @@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
>>>>    static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>>>                                   struct bcm2835_pm *pm)
>>>>    {
>>>> +       bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
>>>> +
>>>>           /* If no 'reg-names' property is found we can assume we're using old
>>>>            * firmware.
>>>>            */
>>>> @@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>>>                           return PTR_ERR(pm->base);
>>>>
>>>>                   pm->asb = devm_platform_ioremap_resource(pdev, 1);
>>>> +               pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
>>> Shouldn't we check if is_bcm2711 before we assign rpivid_asb above?
>> Yes, make sense.
>>>>           } else {
>>>>                   struct resource *res;
>>>>
>>>> @@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
>>>>                                                       "asb");
>>>>                   if (res)
>>>>                           pm->asb = devm_ioremap_resource(&pdev->dev, res);
>>>> +
>>>> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
>>>> +                                                   "rpivid_asb");
>>>> +               if (res)
>>>> +                       pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
>>>> +                                                               res);
>>>>           }
>>>>
>>>>           if (IS_ERR(pm->asb))
>>>>                   pm->asb = NULL;
>>>>
>>>> +       if (IS_ERR(pm->rpivid_asb))
>>>> +               pm->rpivid_asb = NULL;
>>>> +
>>>> +       if (pm->rpivid_asb && !is_bcm2711) {
>>>> +               dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");
>>> Should we ever get into this situation? If it's an older get RPi I'm
>>> guessing pm->rpivid_asb should have been set to NULL from the error
>>> above.
>> I think this was a warning for older BCM2711 downstream DT files which
>> had rpivid_asb register but no BCM2711 compatible.
> Based on the history I remember that makes sense, but the warning is a
> bit misleading in the context given it would actually be a 2711. Is it
> purely a DT check or is does the version of VC firmware come into play
> here too, I seem to remember firmware was used to make some things
> work on older OSes in the early days of RPi4 (although it's hard to
> tell exactly what was done, and I've tried to forget).

Sorry, my fault. This isn't a warning. It's an error. This driver bail 
out as soon the DT is unexpected, which could otherwise lead to 
unexpected behavior of the power driver (rpivid_asb will be interpret as 
BCM2711). There is no firmware involved, just a pure DT. Maybe i should 
add a comment about this assumption here.

Suggested error message:

"Unexpected rpivid_asb register, please fix your DTB.\ņ"

>
>>>> +               return -EINVAL;
>>>> +       }
>>>> +
>>>>           return 0;
>>>>    }
>>>>
>>>> @@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
>>>>    static const struct of_device_id bcm2835_pm_of_match[] = {
>>>>           { .compatible = "brcm,bcm2835-pm-wdt", },
>>>>           { .compatible = "brcm,bcm2835-pm", },
>>>> +       { .compatible = "brcm,bcm2711-pm", },
>>>>           {},
>>>>    };
>>>>    MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
>>>> diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
>>>> index ed37dc40e82a..f70a810c55f7 100644
>>>> --- a/include/linux/mfd/bcm2835-pm.h
>>>> +++ b/include/linux/mfd/bcm2835-pm.h
>>>> @@ -9,6 +9,7 @@ struct bcm2835_pm {
>>>>           struct device *dev;
>>>>           void __iomem *base;
>>>>           void __iomem *asb;
>>>> +       void __iomem *rpivid_asb;
>>>>    };
>>>>
>>>>    #endif /* BCM2835_MFD_PM_H */
>>>> --
>>>> 2.25.1
>>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> linux-arm-kernel@lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
  2022-05-31 22:03           ` Stefan Wahren
@ 2022-06-01 11:09             ` Peter Robinson
  -1 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-06-01 11:09 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

Hi Stefan,

> Am 31.05.22 um 22:11 schrieb Peter Robinson:
> > Hi Stefan,
> >
> > On Tue, May 31, 2022 at 6:27 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
> >> Hi Peter,
> >>
> >> Am 31.05.22 um 17:08 schrieb Peter Robinson:
> >>> On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
> >>>> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
> >>>> with the ISP and H264 bits, and V3D is in the same place in the new ASB
> >>>> as the old one.
> >>>>
> >>>> As per the devicetree bindings, BCM2711 will provide both the old and
> >>>> new ASB resources, so get both of them and pass them into
> >>>> 'bcm2835-power,' which will take care of selecting which one to use
> >>>> accordingly.
> >>>>
> >>>> Since the RPiVid ASB's resources were being provided prior to formalizing
> >>>> the bindings[1], also support the old firmwares that didn't use
> >>> I'm guessing this [1] is referring to "[1] See: 7dbe8c62ceeb ("ARM:
> >>> dts: Add minimal Raspberry Pi 4 support")" referred to in the original
> >>> patch [1] that Nicolas did, was there a reason to drop the
> >>> details/changelog here?
> >> Oops, the link accidently get lost.
> >>> The decision not to use bits makes sense I
> >>> believe.
> >> Yes, i think the new version is more elegant.
> >>> [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-8-pbrobinson@gmail.com/
> >>>
> >>>> 'reg-names.'
> >>>>
> >>>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> >>>> ---
> >>>>    drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
> >>>>    include/linux/mfd/bcm2835-pm.h |  1 +
> >>>>    2 files changed, 19 insertions(+)
> >>>>
> >>>> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
> >>>> index 1656d786993a..da110767c6a4 100644
> >>>> --- a/drivers/mfd/bcm2835-pm.c
> >>>> +++ b/drivers/mfd/bcm2835-pm.c
> >>>> @@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
> >>>>    static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>>>                                   struct bcm2835_pm *pm)
> >>>>    {
> >>>> +       bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
> >>>> +
> >>>>           /* If no 'reg-names' property is found we can assume we're using old
> >>>>            * firmware.
> >>>>            */
> >>>> @@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>>>                           return PTR_ERR(pm->base);
> >>>>
> >>>>                   pm->asb = devm_platform_ioremap_resource(pdev, 1);
> >>>> +               pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
> >>> Shouldn't we check if is_bcm2711 before we assign rpivid_asb above?
> >> Yes, make sense.
> >>>>           } else {
> >>>>                   struct resource *res;
> >>>>
> >>>> @@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>>>                                                       "asb");
> >>>>                   if (res)
> >>>>                           pm->asb = devm_ioremap_resource(&pdev->dev, res);
> >>>> +
> >>>> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> >>>> +                                                   "rpivid_asb");
> >>>> +               if (res)
> >>>> +                       pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
> >>>> +                                                               res);
> >>>>           }
> >>>>
> >>>>           if (IS_ERR(pm->asb))
> >>>>                   pm->asb = NULL;
> >>>>
> >>>> +       if (IS_ERR(pm->rpivid_asb))
> >>>> +               pm->rpivid_asb = NULL;
> >>>> +
> >>>> +       if (pm->rpivid_asb && !is_bcm2711) {
> >>>> +               dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");
> >>> Should we ever get into this situation? If it's an older get RPi I'm
> >>> guessing pm->rpivid_asb should have been set to NULL from the error
> >>> above.
> >> I think this was a warning for older BCM2711 downstream DT files which
> >> had rpivid_asb register but no BCM2711 compatible.
> > Based on the history I remember that makes sense, but the warning is a
> > bit misleading in the context given it would actually be a 2711. Is it
> > purely a DT check or is does the version of VC firmware come into play
> > here too, I seem to remember firmware was used to make some things
> > work on older OSes in the early days of RPi4 (although it's hard to
> > tell exactly what was done, and I've tried to forget).
>
> Sorry, my fault. This isn't a warning. It's an error. This driver bail
> out as soon the DT is unexpected, which could otherwise lead to
> unexpected behavior of the power driver (rpivid_asb will be interpret as
> BCM2711). There is no firmware involved, just a pure DT. Maybe i should
> add a comment about this assumption here.
>
> Suggested error message:
>
> "Unexpected rpivid_asb register, please fix your DTB.\ņ"

Maybe "please fix/update your DTB" but either way is good for me.

> >
> >>>> +               return -EINVAL;
> >>>> +       }
> >>>> +
> >>>>           return 0;
> >>>>    }
> >>>>
> >>>> @@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
> >>>>    static const struct of_device_id bcm2835_pm_of_match[] = {
> >>>>           { .compatible = "brcm,bcm2835-pm-wdt", },
> >>>>           { .compatible = "brcm,bcm2835-pm", },
> >>>> +       { .compatible = "brcm,bcm2711-pm", },
> >>>>           {},
> >>>>    };
> >>>>    MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
> >>>> diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
> >>>> index ed37dc40e82a..f70a810c55f7 100644
> >>>> --- a/include/linux/mfd/bcm2835-pm.h
> >>>> +++ b/include/linux/mfd/bcm2835-pm.h
> >>>> @@ -9,6 +9,7 @@ struct bcm2835_pm {
> >>>>           struct device *dev;
> >>>>           void __iomem *base;
> >>>>           void __iomem *asb;
> >>>> +       void __iomem *rpivid_asb;
> >>>>    };
> >>>>
> >>>>    #endif /* BCM2835_MFD_PM_H */
> >>>> --
> >>>> 2.25.1
> >>>>
> >>> _______________________________________________
> >>> linux-arm-kernel mailing list
> >>> linux-arm-kernel@lists.infradead.org
> >>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711
@ 2022-06-01 11:09             ` Peter Robinson
  0 siblings, 0 replies; 56+ messages in thread
From: Peter Robinson @ 2022-06-01 11:09 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nicolas Saenz Julienne,
	Lee Jones, Melissa Wen, Phil Elwell, bcm-kernel-feedback-list,
	Maxime Ripard, devicetree, linux-rpi-kernel, linux-arm-kernel

Hi Stefan,

> Am 31.05.22 um 22:11 schrieb Peter Robinson:
> > Hi Stefan,
> >
> > On Tue, May 31, 2022 at 6:27 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
> >> Hi Peter,
> >>
> >> Am 31.05.22 um 17:08 schrieb Peter Robinson:
> >>> On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote:
> >>>> In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
> >>>> with the ISP and H264 bits, and V3D is in the same place in the new ASB
> >>>> as the old one.
> >>>>
> >>>> As per the devicetree bindings, BCM2711 will provide both the old and
> >>>> new ASB resources, so get both of them and pass them into
> >>>> 'bcm2835-power,' which will take care of selecting which one to use
> >>>> accordingly.
> >>>>
> >>>> Since the RPiVid ASB's resources were being provided prior to formalizing
> >>>> the bindings[1], also support the old firmwares that didn't use
> >>> I'm guessing this [1] is referring to "[1] See: 7dbe8c62ceeb ("ARM:
> >>> dts: Add minimal Raspberry Pi 4 support")" referred to in the original
> >>> patch [1] that Nicolas did, was there a reason to drop the
> >>> details/changelog here?
> >> Oops, the link accidently get lost.
> >>> The decision not to use bits makes sense I
> >>> believe.
> >> Yes, i think the new version is more elegant.
> >>> [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220213225646.67761-8-pbrobinson@gmail.com/
> >>>
> >>>> 'reg-names.'
> >>>>
> >>>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> >>>> ---
> >>>>    drivers/mfd/bcm2835-pm.c       | 18 ++++++++++++++++++
> >>>>    include/linux/mfd/bcm2835-pm.h |  1 +
> >>>>    2 files changed, 19 insertions(+)
> >>>>
> >>>> diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
> >>>> index 1656d786993a..da110767c6a4 100644
> >>>> --- a/drivers/mfd/bcm2835-pm.c
> >>>> +++ b/drivers/mfd/bcm2835-pm.c
> >>>> @@ -28,6 +28,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
> >>>>    static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>>>                                   struct bcm2835_pm *pm)
> >>>>    {
> >>>> +       bool is_bcm2711 = of_device_is_compatible(pm->dev->of_node, "brcm,bcm2711-pm");
> >>>> +
> >>>>           /* If no 'reg-names' property is found we can assume we're using old
> >>>>            * firmware.
> >>>>            */
> >>>> @@ -39,6 +41,7 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>>>                           return PTR_ERR(pm->base);
> >>>>
> >>>>                   pm->asb = devm_platform_ioremap_resource(pdev, 1);
> >>>> +               pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
> >>> Shouldn't we check if is_bcm2711 before we assign rpivid_asb above?
> >> Yes, make sense.
> >>>>           } else {
> >>>>                   struct resource *res;
> >>>>
> >>>> @@ -50,11 +53,25 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
> >>>>                                                       "asb");
> >>>>                   if (res)
> >>>>                           pm->asb = devm_ioremap_resource(&pdev->dev, res);
> >>>> +
> >>>> +               res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
> >>>> +                                                   "rpivid_asb");
> >>>> +               if (res)
> >>>> +                       pm->rpivid_asb = devm_ioremap_resource(&pdev->dev,
> >>>> +                                                               res);
> >>>>           }
> >>>>
> >>>>           if (IS_ERR(pm->asb))
> >>>>                   pm->asb = NULL;
> >>>>
> >>>> +       if (IS_ERR(pm->rpivid_asb))
> >>>> +               pm->rpivid_asb = NULL;
> >>>> +
> >>>> +       if (pm->rpivid_asb && !is_bcm2711) {
> >>>> +               dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");
> >>> Should we ever get into this situation? If it's an older get RPi I'm
> >>> guessing pm->rpivid_asb should have been set to NULL from the error
> >>> above.
> >> I think this was a warning for older BCM2711 downstream DT files which
> >> had rpivid_asb register but no BCM2711 compatible.
> > Based on the history I remember that makes sense, but the warning is a
> > bit misleading in the context given it would actually be a 2711. Is it
> > purely a DT check or is does the version of VC firmware come into play
> > here too, I seem to remember firmware was used to make some things
> > work on older OSes in the early days of RPi4 (although it's hard to
> > tell exactly what was done, and I've tried to forget).
>
> Sorry, my fault. This isn't a warning. It's an error. This driver bail
> out as soon the DT is unexpected, which could otherwise lead to
> unexpected behavior of the power driver (rpivid_asb will be interpret as
> BCM2711). There is no firmware involved, just a pure DT. Maybe i should
> add a comment about this assumption here.
>
> Suggested error message:
>
> "Unexpected rpivid_asb register, please fix your DTB.\ņ"

Maybe "please fix/update your DTB" but either way is good for me.

> >
> >>>> +               return -EINVAL;
> >>>> +       }
> >>>> +
> >>>>           return 0;
> >>>>    }
> >>>>
> >>>> @@ -95,6 +112,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
> >>>>    static const struct of_device_id bcm2835_pm_of_match[] = {
> >>>>           { .compatible = "brcm,bcm2835-pm-wdt", },
> >>>>           { .compatible = "brcm,bcm2835-pm", },
> >>>> +       { .compatible = "brcm,bcm2711-pm", },
> >>>>           {},
> >>>>    };
> >>>>    MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
> >>>> diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
> >>>> index ed37dc40e82a..f70a810c55f7 100644
> >>>> --- a/include/linux/mfd/bcm2835-pm.h
> >>>> +++ b/include/linux/mfd/bcm2835-pm.h
> >>>> @@ -9,6 +9,7 @@ struct bcm2835_pm {
> >>>>           struct device *dev;
> >>>>           void __iomem *base;
> >>>>           void __iomem *asb;
> >>>> +       void __iomem *rpivid_asb;
> >>>>    };
> >>>>
> >>>>    #endif /* BCM2835_MFD_PM_H */
> >>>> --
> >>>> 2.25.1
> >>>>
> >>> _______________________________________________
> >>> linux-arm-kernel mailing list
> >>> linux-arm-kernel@lists.infradead.org
> >>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-06-01 11:11 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-15 20:20 [PATCH 00/11] soc: bcm2835-power: Prepare BCM2711 V3D support Stefan Wahren
2022-05-15 20:20 ` Stefan Wahren
2022-05-15 20:20 ` [PATCH 01/11] dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema Stefan Wahren
2022-05-15 20:20   ` Stefan Wahren
2022-05-15 20:20 ` [PATCH 02/11] dt-bindings: soc: bcm: bcm2835-pm: Introduce reg-names Stefan Wahren
2022-05-15 20:20   ` Stefan Wahren
2022-05-15 20:20 ` [PATCH 03/11] dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711 Stefan Wahren
2022-05-15 20:20   ` Stefan Wahren
2022-05-18  0:55   ` Rob Herring
2022-05-18  0:55     ` Rob Herring
2022-05-15 20:20 ` [PATCH 04/11] ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node Stefan Wahren
2022-05-15 20:20   ` Stefan Wahren
2022-05-31 12:55   ` Peter Robinson
2022-05-31 12:55     ` Peter Robinson
2022-05-15 20:20 ` [PATCH 05/11] ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node Stefan Wahren
2022-05-15 20:20   ` Stefan Wahren
2022-05-31 12:56   ` Peter Robinson
2022-05-31 12:56     ` Peter Robinson
2022-05-15 20:20 ` [PATCH 06/11] mfd: bcm2835-pm: Use 'reg-names' to get resources Stefan Wahren
2022-05-15 20:20   ` Stefan Wahren
2022-05-31 14:54   ` Peter Robinson
2022-05-31 14:54     ` Peter Robinson
2022-05-31 17:12     ` Stefan Wahren
2022-05-31 17:12       ` Stefan Wahren
2022-05-15 20:20 ` [PATCH 07/11] mfd: bcm2835-pm: Add support for BCM2711 Stefan Wahren
2022-05-15 20:20   ` Stefan Wahren
2022-05-31 15:08   ` Peter Robinson
2022-05-31 15:08     ` Peter Robinson
2022-05-31 17:27     ` Stefan Wahren
2022-05-31 17:27       ` Stefan Wahren
2022-05-31 20:11       ` Peter Robinson
2022-05-31 20:11         ` Peter Robinson
2022-05-31 22:03         ` Stefan Wahren
2022-05-31 22:03           ` Stefan Wahren
2022-06-01 11:09           ` Peter Robinson
2022-06-01 11:09             ` Peter Robinson
2022-05-15 20:20 ` [PATCH 08/11] soc: bcm: bcm2835-power: Refactor ASB control Stefan Wahren
2022-05-15 20:20   ` Stefan Wahren
2022-05-31 15:18   ` Peter Robinson
2022-05-31 15:18     ` Peter Robinson
2022-05-15 20:20 ` [PATCH 09/11] soc: bcm: bcm2835-power: Resolve ASB register macros Stefan Wahren
2022-05-15 20:20   ` Stefan Wahren
2022-05-31 15:47   ` Peter Robinson
2022-05-31 15:47     ` Peter Robinson
2022-05-31 17:34     ` Stefan Wahren
2022-05-31 17:34       ` Stefan Wahren
2022-05-15 20:20 ` [PATCH 10/11] soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB Stefan Wahren
2022-05-15 20:20   ` Stefan Wahren
2022-05-31 15:58   ` Peter Robinson
2022-05-31 15:58     ` Peter Robinson
2022-05-15 20:20 ` [PATCH 11/11] soc: bcm: bcm2835-power: Bypass power_on/off() calls Stefan Wahren
2022-05-15 20:20   ` Stefan Wahren
2022-05-31 16:03   ` Peter Robinson
2022-05-31 16:03     ` Peter Robinson
2022-05-18 20:22 ` [PATCH 00/11] soc: bcm2835-power: Prepare BCM2711 V3D support Florian Fainelli
2022-05-18 20:22   ` Florian Fainelli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.