linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101
@ 2025-10-09 15:25 André Draszik
  2025-10-09 15:25 ` [PATCH v2 01/10] dt-bindings: power: samsung: add google,gs101-pd André Draszik
                   ` (9 more replies)
  0 siblings, 10 replies; 18+ messages in thread
From: André Draszik @ 2025-10-09 15:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, André Draszik, stable, Krzysztof Kozlowski

Hi,

This series adds support for the power domains on Google GS101. It's
fairly similar to SoCs already supported by this driver, except that
register acces does not work via plain ioremap() / readl() / writel().
Instead, the regmap created by the PMU driver must be used (which uses
Arm SMCC calls under the hood).

The DT update to add the new required properties on gs101 will be
posted separately.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
Changes in v2:
- Krzysztof:
  - move google,gs101-pmu binding into separate file
  - mark devm_kstrdup_const() patch as fix
  - use bool for need_early_sync_state
  - merge patches 8 and 10 from v1 series into one patch
- collect tags
- Link to v1: https://lore.kernel.org/r/20251006-gs101-pd-v1-0-f0cb0c01ea7b@linaro.org

---
André Draszik (10):
      dt-bindings: power: samsung: add google,gs101-pd
      dt-bindings: soc: samsung: exynos-pmu: move gs101-pmu into separate binding
      dt-bindings: soc: samsung: gs101-pmu: allow power domains as children
      pmdomain: samsung: plug potential memleak during probe
      pmdomain: samsung: convert to using regmap
      pmdomain: samsung: convert to regmap_read_poll_timeout()
      pmdomain: samsung: don't hardcode offset for registers to 0 and 4
      pmdomain: samsung: selectively handle enforced sync_state
      pmdomain: samsung: add support for google,gs101-pd
      pmdomain: samsung: use dev_err() instead of pr_err()

 .../devicetree/bindings/power/pd-samsung.yaml      |   1 +
 .../bindings/soc/google/google,gs101-pmu.yaml      | 107 +++++++++++++++++
 .../bindings/soc/samsung/exynos-pmu.yaml           |  20 ----
 MAINTAINERS                                        |   1 +
 drivers/pmdomain/samsung/exynos-pm-domains.c       | 126 +++++++++++++++------
 5 files changed, 201 insertions(+), 54 deletions(-)
---
base-commit: a5f97c90e75f09f24ece2dca34168722b140a798
change-id: 20251001-gs101-pd-d4dc97d70a84

Best regards,
-- 
André Draszik <andre.draszik@linaro.org>


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

* [PATCH v2 01/10] dt-bindings: power: samsung: add google,gs101-pd
  2025-10-09 15:25 [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
@ 2025-10-09 15:25 ` André Draszik
  2025-10-10 18:31   ` Rob Herring (Arm)
  2025-10-09 15:25 ` [PATCH v2 02/10] dt-bindings: soc: samsung: exynos-pmu: move gs101-pmu into separate binding André Draszik
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 18+ messages in thread
From: André Draszik @ 2025-10-09 15:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, André Draszik

Add support for the Google gs101 version of the Exynos power domains. A
new compatible is needed because register fields have changed.

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 Documentation/devicetree/bindings/power/pd-samsung.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/power/pd-samsung.yaml b/Documentation/devicetree/bindings/power/pd-samsung.yaml
index 9c2c51133457112ca0098c043e123f0a02fa1291..c35c9cb0115d79e5c36142da2c2a5dd30cd2ad47 100644
--- a/Documentation/devicetree/bindings/power/pd-samsung.yaml
+++ b/Documentation/devicetree/bindings/power/pd-samsung.yaml
@@ -19,6 +19,7 @@ allOf:
 properties:
   compatible:
     enum:
+      - google,gs101-pd
       - samsung,exynos4210-pd
       - samsung,exynos5433-pd
 

-- 
2.51.0.710.ga91ca5db03-goog


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

* [PATCH v2 02/10] dt-bindings: soc: samsung: exynos-pmu: move gs101-pmu into separate binding
  2025-10-09 15:25 [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
  2025-10-09 15:25 ` [PATCH v2 01/10] dt-bindings: power: samsung: add google,gs101-pd André Draszik
@ 2025-10-09 15:25 ` André Draszik
  2025-10-10 12:23   ` Rob Herring (Arm)
  2025-10-10 14:09   ` Rob Herring
  2025-10-09 15:25 ` [PATCH v2 03/10] dt-bindings: soc: samsung: gs101-pmu: allow power domains as children André Draszik
                   ` (7 subsequent siblings)
  9 siblings, 2 replies; 18+ messages in thread
From: André Draszik @ 2025-10-09 15:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, André Draszik

The gs101-pmu binding is going to acquire various additional (pattern)
properties that don't apply to other PMUs supported by this binding.

To enable this, move google,gs101-pmu into a separate binding.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 .../bindings/soc/google/google,gs101-pmu.yaml      | 67 ++++++++++++++++++++++
 .../bindings/soc/samsung/exynos-pmu.yaml           | 20 -------
 MAINTAINERS                                        |  1 +
 3 files changed, 68 insertions(+), 20 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml b/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..209ee2f80d449c3eec568188898b3c6f7ae0ddd4
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/samsung/google,gs101-pmu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Google GS101 Power Management Unit (PMU)
+
+maintainers:
+  - André Draszik <andre.draszik@linaro.org>
+
+# Custom select to avoid matching all nodes with 'syscon'
+select:
+  properties:
+    compatible:
+      contains:
+        const: google,gs101-pmu
+  required:
+    - compatible
+
+properties:
+  compatible:
+    items:
+      - const: google,gs101-pmu
+      - const: syscon
+
+  reg:
+    maxItems: 1
+
+  reboot-mode:
+    $ref: /schemas/power/reset/syscon-reboot-mode.yaml
+    type: object
+    description:
+      Reboot mode to alter bootloader behavior for the next boot
+
+  syscon-poweroff:
+    $ref: /schemas/power/reset/syscon-poweroff.yaml#
+    type: object
+    description:
+      Node for power off method
+
+  syscon-reboot:
+    $ref: /schemas/power/reset/syscon-reboot.yaml#
+    type: object
+    description:
+      Node for reboot method
+
+  google,pmu-intr-gen-syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to PMU interrupt generation interface.
+
+required:
+  - compatible
+  - reg
+  - google,pmu-intr-gen-syscon
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    system-controller@17460000 {
+        compatible = "google,gs101-pmu", "syscon";
+        reg = <0x17460000 0x10000>;
+
+        google,pmu-intr-gen-syscon = <&pmu_intr_gen>;
+    };
diff --git a/Documentation/devicetree/bindings/soc/samsung/exynos-pmu.yaml b/Documentation/devicetree/bindings/soc/samsung/exynos-pmu.yaml
index f0fb24156da9b8980dcfd5339ae75f12a71cf6d6..83f18a92fa1c4de75a90f00475cf17d5f0b652e4 100644
--- a/Documentation/devicetree/bindings/soc/samsung/exynos-pmu.yaml
+++ b/Documentation/devicetree/bindings/soc/samsung/exynos-pmu.yaml
@@ -15,7 +15,6 @@ select:
     compatible:
       contains:
         enum:
-          - google,gs101-pmu
           - samsung,exynos3250-pmu
           - samsung,exynos4210-pmu
           - samsung,exynos4212-pmu
@@ -36,7 +35,6 @@ properties:
     oneOf:
       - items:
           - enum:
-              - google,gs101-pmu
               - samsung,exynos3250-pmu
               - samsung,exynos4210-pmu
               - samsung,exynos4212-pmu
@@ -129,11 +127,6 @@ properties:
     description:
       Node for reboot method
 
-  google,pmu-intr-gen-syscon:
-    $ref: /schemas/types.yaml#/definitions/phandle
-    description:
-      Phandle to PMU interrupt generation interface.
-
 required:
   - compatible
   - reg
@@ -194,19 +187,6 @@ allOf:
       properties:
         dp-phy: false
 
-  - if:
-      properties:
-        compatible:
-          contains:
-            enum:
-              - google,gs101-pmu
-    then:
-      required:
-        - google,pmu-intr-gen-syscon
-    else:
-      properties:
-        google,pmu-intr-gen-syscon: false
-
 examples:
   - |
     #include <dt-bindings/clock/exynos5250.h>
diff --git a/MAINTAINERS b/MAINTAINERS
index 3439485437117aaffbe61b709468348231ca3cc4..9cf5b9300d4d96bfed8d1a75cc806925a884744b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10596,6 +10596,7 @@ S:	Maintained
 P:	Documentation/process/maintainer-soc-clean-dts.rst
 C:	irc://irc.oftc.net/pixel6-kernel-dev
 F:	Documentation/devicetree/bindings/clock/google,gs101-clock.yaml
+F:	Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
 F:	Documentation/devicetree/bindings/soc/google/google,gs101-pmu-intr-gen.yaml
 F:	arch/arm64/boot/dts/exynos/google/
 F:	drivers/clk/samsung/clk-gs101.c

-- 
2.51.0.710.ga91ca5db03-goog


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

* [PATCH v2 03/10] dt-bindings: soc: samsung: gs101-pmu: allow power domains as children
  2025-10-09 15:25 [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
  2025-10-09 15:25 ` [PATCH v2 01/10] dt-bindings: power: samsung: add google,gs101-pd André Draszik
  2025-10-09 15:25 ` [PATCH v2 02/10] dt-bindings: soc: samsung: exynos-pmu: move gs101-pmu into separate binding André Draszik
@ 2025-10-09 15:25 ` André Draszik
  2025-10-10  5:26   ` André Draszik
  2025-10-10 14:13   ` Rob Herring
  2025-10-09 15:25 ` [PATCH v2 04/10] pmdomain: samsung: plug potential memleak during probe André Draszik
                   ` (6 subsequent siblings)
  9 siblings, 2 replies; 18+ messages in thread
From: André Draszik @ 2025-10-09 15:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, André Draszik

The power domains are a property of / implemented in the PMU. As such,
they should be modelled as child nodes of the PMU.

Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
Note: Ideally, the newly added properties (ranges, etc.) should only be
'required' if "^power-domain@[0-9a-f]+$" exists as a patternProperty,
as they're needed only in that case. As-is, this patch now causes
warnings for existing DTs as they don't specify the new properties (and
they shouldn't need to). Only if DTs are updated to include
power-domains, such an update should also add the new properties.

I've not been able to come up with the correct schema syntax to achieve
that. dependencies, dependentRequired, and dependentSchemas don't seem
to support patterns. Similarly,
  - if:
      required:
        - ...
    then:
      required:
        - ...

doesn't allow patterns in the 'if' block (or I didn't get the syntax
right).
---
 .../bindings/soc/google/google,gs101-pmu.yaml      | 42 +++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml b/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
index 209ee2f80d449c3eec568188898b3c6f7ae0ddd4..d18a351b649c0736662e67bb64de46afa01e399a 100644
--- a/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
+++ b/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
@@ -27,6 +27,14 @@ properties:
   reg:
     maxItems: 1
 
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
+  ranges: true
+
   reboot-mode:
     $ref: /schemas/power/reset/syscon-reboot-mode.yaml
     type: object
@@ -50,18 +58,50 @@ properties:
     description:
       Phandle to PMU interrupt generation interface.
 
+patternProperties:
+  "^power-domain@[0-9a-f]+$":
+    type: object
+    description: Child node describing one power domain within the PMU
+
+    additionalProperties: true
+
+    properties:
+      compatible:
+        const: google,gs101-pd
+
 required:
   - compatible
   - reg
+  - '#address-cells'
+  - '#size-cells'
+  - ranges
   - google,pmu-intr-gen-syscon
 
-unevaluatedProperties: false
+additionalProperties: false
 
 examples:
   - |
     system-controller@17460000 {
         compatible = "google,gs101-pmu", "syscon";
         reg = <0x17460000 0x10000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges;
 
         google,pmu-intr-gen-syscon = <&pmu_intr_gen>;
+
+        pd_g3d: power-domain@1e00 {
+            compatible = "google,gs101-pd";
+            reg = <0x1e00 0x80>;
+            #power-domain-cells = <0>;
+            label = "g3d";
+        };
+
+        power-domain@2000 {
+            compatible = "google,gs101-pd";
+            reg = <0x2000 0x80>;
+            #power-domain-cells = <0>;
+            power-domains = <&pd_g3d>;
+            label = "embedded_g3d";
+        };
     };

-- 
2.51.0.710.ga91ca5db03-goog


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

* [PATCH v2 04/10] pmdomain: samsung: plug potential memleak during probe
  2025-10-09 15:25 [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
                   ` (2 preceding siblings ...)
  2025-10-09 15:25 ` [PATCH v2 03/10] dt-bindings: soc: samsung: gs101-pmu: allow power domains as children André Draszik
@ 2025-10-09 15:25 ` André Draszik
  2025-10-10  0:35   ` Krzysztof Kozlowski
  2025-10-09 15:25 ` [PATCH v2 05/10] pmdomain: samsung: convert to using regmap André Draszik
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 18+ messages in thread
From: André Draszik @ 2025-10-09 15:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, André Draszik, stable

of_genpd_add_provider_simple() could fail, in which case this code
leaks the domain name, pd->pd.name.

Use devm_kstrdup_const() to plug this leak. As a side-effect, we can
simplify existing error handling.

Fixes: c09a3e6c97f0 ("soc: samsung: pm_domains: Convert to regular platform driver")
Cc: stable@vger.kernel.org
Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
v2:
reword commit message, as this isn't a pure simplification
---
 drivers/pmdomain/samsung/exynos-pm-domains.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/pmdomain/samsung/exynos-pm-domains.c b/drivers/pmdomain/samsung/exynos-pm-domains.c
index 5d478bb37ad68afc7aed7c6ae19b5fefc94a9035..f53e1bd2479807988f969774b4b7b4c5739c1aba 100644
--- a/drivers/pmdomain/samsung/exynos-pm-domains.c
+++ b/drivers/pmdomain/samsung/exynos-pm-domains.c
@@ -92,13 +92,14 @@ static const struct of_device_id exynos_pm_domain_of_match[] = {
 	{ },
 };
 
-static const char *exynos_get_domain_name(struct device_node *node)
+static const char *exynos_get_domain_name(struct device *dev,
+					  struct device_node *node)
 {
 	const char *name;
 
 	if (of_property_read_string(node, "label", &name) < 0)
 		name = kbasename(node->full_name);
-	return kstrdup_const(name, GFP_KERNEL);
+	return devm_kstrdup_const(dev, name, GFP_KERNEL);
 }
 
 static int exynos_pd_probe(struct platform_device *pdev)
@@ -115,15 +116,13 @@ static int exynos_pd_probe(struct platform_device *pdev)
 	if (!pd)
 		return -ENOMEM;
 
-	pd->pd.name = exynos_get_domain_name(np);
+	pd->pd.name = exynos_get_domain_name(dev, np);
 	if (!pd->pd.name)
 		return -ENOMEM;
 
 	pd->base = of_iomap(np, 0);
-	if (!pd->base) {
-		kfree_const(pd->pd.name);
+	if (!pd->base)
 		return -ENODEV;
-	}
 
 	pd->pd.power_off = exynos_pd_power_off;
 	pd->pd.power_on = exynos_pd_power_on;

-- 
2.51.0.710.ga91ca5db03-goog


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

* [PATCH v2 05/10] pmdomain: samsung: convert to using regmap
  2025-10-09 15:25 [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
                   ` (3 preceding siblings ...)
  2025-10-09 15:25 ` [PATCH v2 04/10] pmdomain: samsung: plug potential memleak during probe André Draszik
@ 2025-10-09 15:25 ` André Draszik
  2025-10-09 15:25 ` [PATCH v2 06/10] pmdomain: samsung: convert to regmap_read_poll_timeout() André Draszik
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: André Draszik @ 2025-10-09 15:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, André Draszik

On platforms such as Google gs101, direct mmio register access to the
PMU registers doesn't necessarily work and access must happen via a
(syscon) regmap created by the PMU driver instead.

In preparation for supporting such SoCs convert the existing mmio
accesses to using a regmap wrapper.

With this change in place, a follow-up patch can update the driver to
optionally acquire the PMU-created regmap without having to change the
rest of the code.

Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
There is one checkpatch warning, relating to the non-const
regmap_config. It can a) not be made const without resorting to having
two copies and copying, and b) will go away in a follow-up patch
anyway.
---
 drivers/pmdomain/samsung/exynos-pm-domains.c | 78 ++++++++++++++++++++--------
 1 file changed, 57 insertions(+), 21 deletions(-)

diff --git a/drivers/pmdomain/samsung/exynos-pm-domains.c b/drivers/pmdomain/samsung/exynos-pm-domains.c
index f53e1bd2479807988f969774b4b7b4c5739c1aba..383126245811cb8e4dbae3b99ced3f06d3093f35 100644
--- a/drivers/pmdomain/samsung/exynos-pm-domains.c
+++ b/drivers/pmdomain/samsung/exynos-pm-domains.c
@@ -9,15 +9,14 @@
 // conjunction with runtime-pm. Support for both device-tree and non-device-tree
 // based power domain support is included.
 
-#include <linux/io.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/pm_domain.h>
 #include <linux/delay.h>
 #include <linux/of.h>
-#include <linux/of_address.h>
 #include <linux/pm_runtime.h>
+#include <linux/regmap.h>
 
 struct exynos_pm_domain_config {
 	/* Value for LOCAL_PWR_CFG and STATUS fields for each domain */
@@ -28,7 +27,7 @@ struct exynos_pm_domain_config {
  * Exynos specific wrapper around the generic power domain
  */
 struct exynos_pm_domain {
-	void __iomem *base;
+	struct regmap *regmap;
 	struct generic_pm_domain pd;
 	u32 local_pwr_cfg;
 };
@@ -36,31 +35,37 @@ struct exynos_pm_domain {
 static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
 {
 	struct exynos_pm_domain *pd;
-	void __iomem *base;
 	u32 timeout, pwr;
-	char *op;
+	int err;
 
 	pd = container_of(domain, struct exynos_pm_domain, pd);
-	base = pd->base;
 
 	pwr = power_on ? pd->local_pwr_cfg : 0;
-	writel_relaxed(pwr, base);
+	err = regmap_write(pd->regmap, 0, pwr);
+	if (err)
+		return err;
 
 	/* Wait max 1ms */
 	timeout = 10;
-
-	while ((readl_relaxed(base + 0x4) & pd->local_pwr_cfg) != pwr) {
-		if (!timeout) {
-			op = (power_on) ? "enable" : "disable";
-			pr_err("Power domain %s %s failed\n", domain->name, op);
-			return -ETIMEDOUT;
+	while (timeout-- > 0) {
+		unsigned int val;
+
+		err = regmap_read(pd->regmap, 0x4, &val);
+		if (err || ((val & pd->local_pwr_cfg) != pwr)) {
+			cpu_relax();
+			usleep_range(80, 100);
+			continue;
 		}
-		timeout--;
-		cpu_relax();
-		usleep_range(80, 100);
+
+		return 0;
 	}
 
-	return 0;
+	if (!err)
+		err = -ETIMEDOUT;
+	pr_err("Power domain %s %sable failed: %d\n", domain->name,
+	       power_on ? "en" : "dis", err);
+
+	return err;
 }
 
 static int exynos_pd_power_on(struct generic_pm_domain *domain)
@@ -109,8 +114,18 @@ static int exynos_pd_probe(struct platform_device *pdev)
 	struct device_node *np = dev->of_node;
 	struct of_phandle_args child, parent;
 	struct exynos_pm_domain *pd;
+	struct resource *res;
+	void __iomem *base;
+	unsigned int val;
 	int on, ret;
 
+	struct regmap_config reg_config = {
+		.reg_bits = 32,
+		.val_bits = 32,
+		.reg_stride = 4,
+		.use_relaxed_mmio = true,
+	};
+
 	pm_domain_cfg = of_device_get_match_data(dev);
 	pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
 	if (!pd)
@@ -120,15 +135,36 @@ static int exynos_pd_probe(struct platform_device *pdev)
 	if (!pd->pd.name)
 		return -ENOMEM;
 
-	pd->base = of_iomap(np, 0);
-	if (!pd->base)
-		return -ENODEV;
+	/*
+	 * The resource typically points into the address space of the PMU.
+	 * Therefore, avoid using devm_platform_get_and_ioremap_resource() and
+	 * instead use platform_get_resource() and devm_ioremap() to avoid
+	 * conflicts due to address space overlap.
+	 */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return dev_err_probe(dev, -ENXIO, "missing IO resources");
+
+	base = devm_ioremap(dev, res->start, resource_size(res));
+	if (!base)
+		return dev_err_probe(dev, -ENOMEM,
+				     "failed to ioremap PMU registers");
+
+	reg_config.max_register = resource_size(res) - reg_config.reg_stride;
+	pd->regmap = devm_regmap_init_mmio(dev, base, &reg_config);
+	if (IS_ERR(pd->regmap))
+		return dev_err_probe(dev, PTR_ERR(base),
+				     "failed to init regmap");
 
 	pd->pd.power_off = exynos_pd_power_off;
 	pd->pd.power_on = exynos_pd_power_on;
 	pd->local_pwr_cfg = pm_domain_cfg->local_pwr_cfg;
 
-	on = readl_relaxed(pd->base + 0x4) & pd->local_pwr_cfg;
+	ret = regmap_read(pd->regmap, 0x4, &val);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to read status");
+
+	on = val & pd->local_pwr_cfg;
 
 	pm_genpd_init(&pd->pd, NULL, !on);
 	ret = of_genpd_add_provider_simple(np, &pd->pd);

-- 
2.51.0.710.ga91ca5db03-goog


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

* [PATCH v2 06/10] pmdomain: samsung: convert to regmap_read_poll_timeout()
  2025-10-09 15:25 [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
                   ` (4 preceding siblings ...)
  2025-10-09 15:25 ` [PATCH v2 05/10] pmdomain: samsung: convert to using regmap André Draszik
@ 2025-10-09 15:25 ` André Draszik
  2025-10-09 15:25 ` [PATCH v2 07/10] pmdomain: samsung: don't hardcode offset for registers to 0 and 4 André Draszik
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: André Draszik @ 2025-10-09 15:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, André Draszik

Replace the open-coded PD status polling with
regmap_read_poll_timeout(). This change simplifies the code without
altering functionality.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/pmdomain/samsung/exynos-pm-domains.c | 29 ++++++++--------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/drivers/pmdomain/samsung/exynos-pm-domains.c b/drivers/pmdomain/samsung/exynos-pm-domains.c
index 383126245811cb8e4dbae3b99ced3f06d3093f35..431548ad9a7e40c0a77ac6672081b600c90ddd4e 100644
--- a/drivers/pmdomain/samsung/exynos-pm-domains.c
+++ b/drivers/pmdomain/samsung/exynos-pm-domains.c
@@ -13,7 +13,6 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/pm_domain.h>
-#include <linux/delay.h>
 #include <linux/of.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
@@ -35,7 +34,8 @@ struct exynos_pm_domain {
 static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
 {
 	struct exynos_pm_domain *pd;
-	u32 timeout, pwr;
+	unsigned int val;
+	u32 pwr;
 	int err;
 
 	pd = container_of(domain, struct exynos_pm_domain, pd);
@@ -45,25 +45,12 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
 	if (err)
 		return err;
 
-	/* Wait max 1ms */
-	timeout = 10;
-	while (timeout-- > 0) {
-		unsigned int val;
-
-		err = regmap_read(pd->regmap, 0x4, &val);
-		if (err || ((val & pd->local_pwr_cfg) != pwr)) {
-			cpu_relax();
-			usleep_range(80, 100);
-			continue;
-		}
-
-		return 0;
-	}
-
-	if (!err)
-		err = -ETIMEDOUT;
-	pr_err("Power domain %s %sable failed: %d\n", domain->name,
-	       power_on ? "en" : "dis", err);
+	err = regmap_read_poll_timeout(pd->regmap, 0x4, val,
+				       (val & pd->local_pwr_cfg) == pwr,
+				       100, 1 * USEC_PER_MSEC);
+	if (err)
+		pr_err("Power domain %s %sable failed: %d (%#.2x)\n",
+		       domain->name, power_on ? "en" : "dis", err, val);
 
 	return err;
 }

-- 
2.51.0.710.ga91ca5db03-goog


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

* [PATCH v2 07/10] pmdomain: samsung: don't hardcode offset for registers to 0 and 4
  2025-10-09 15:25 [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
                   ` (5 preceding siblings ...)
  2025-10-09 15:25 ` [PATCH v2 06/10] pmdomain: samsung: convert to regmap_read_poll_timeout() André Draszik
@ 2025-10-09 15:25 ` André Draszik
  2025-10-09 15:25 ` [PATCH v2 08/10] pmdomain: samsung: selectively handle enforced sync_state André Draszik
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: André Draszik @ 2025-10-09 15:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, André Draszik

On platforms such as Google gs101, direct mmio register access to the
PMU registers doesn't necessarily work and access must happen via a
(syscon) regmap created by the PMU driver instead.

When such a regmap is used it will cover the complete PMU memory region
rather than individual power domains. This means the register offsets
for the configuration and status registers will have to take the power
domain offsets into account, rather than unconditionally hardcoding 0
and 4 respectively.

Update the code to allow that.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/pmdomain/samsung/exynos-pm-domains.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/pmdomain/samsung/exynos-pm-domains.c b/drivers/pmdomain/samsung/exynos-pm-domains.c
index 431548ad9a7e40c0a77ac6672081b600c90ddd4e..638d286b57f716140b2401092415644a6805870e 100644
--- a/drivers/pmdomain/samsung/exynos-pm-domains.c
+++ b/drivers/pmdomain/samsung/exynos-pm-domains.c
@@ -29,6 +29,8 @@ struct exynos_pm_domain {
 	struct regmap *regmap;
 	struct generic_pm_domain pd;
 	u32 local_pwr_cfg;
+	u32 configuration_reg;
+	u32 status_reg;
 };
 
 static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
@@ -41,11 +43,11 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
 	pd = container_of(domain, struct exynos_pm_domain, pd);
 
 	pwr = power_on ? pd->local_pwr_cfg : 0;
-	err = regmap_write(pd->regmap, 0, pwr);
+	err = regmap_write(pd->regmap, pd->configuration_reg, pwr);
 	if (err)
 		return err;
 
-	err = regmap_read_poll_timeout(pd->regmap, 0x4, val,
+	err = regmap_read_poll_timeout(pd->regmap, pd->status_reg, val,
 				       (val & pd->local_pwr_cfg) == pwr,
 				       100, 1 * USEC_PER_MSEC);
 	if (err)
@@ -146,8 +148,10 @@ static int exynos_pd_probe(struct platform_device *pdev)
 	pd->pd.power_off = exynos_pd_power_off;
 	pd->pd.power_on = exynos_pd_power_on;
 	pd->local_pwr_cfg = pm_domain_cfg->local_pwr_cfg;
+	pd->configuration_reg += 0;
+	pd->status_reg += 4;
 
-	ret = regmap_read(pd->regmap, 0x4, &val);
+	ret = regmap_read(pd->regmap, pd->status_reg, &val);
 	if (ret)
 		return dev_err_probe(dev, ret, "failed to read status");
 

-- 
2.51.0.710.ga91ca5db03-goog


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

* [PATCH v2 08/10] pmdomain: samsung: selectively handle enforced sync_state
  2025-10-09 15:25 [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
                   ` (6 preceding siblings ...)
  2025-10-09 15:25 ` [PATCH v2 07/10] pmdomain: samsung: don't hardcode offset for registers to 0 and 4 André Draszik
@ 2025-10-09 15:25 ` André Draszik
  2025-10-09 15:25 ` [PATCH v2 09/10] pmdomain: samsung: add support for google,gs101-pd André Draszik
  2025-10-09 15:25 ` [PATCH v2 10/10] pmdomain: samsung: use dev_err() instead of pr_err() André Draszik
  9 siblings, 0 replies; 18+ messages in thread
From: André Draszik @ 2025-10-09 15:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, André Draszik

Unconditionally calling of_genpd_sync_state() causes issues on
platforms with child domains as the parent domain will be turned off
before the child domain was even registered during boot.

This in particular is an issue for the upcoming Google gs101 support -
all operations on child domains registered after the parent domain
misbehave.

Add a flag to the probe data to be able to sync_state conditionally
only, and enable that flag on the two platforms currently supported by
this driver.

Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
v2:
* use bool for need_early_sync_state (Krzysztof)
---
 drivers/pmdomain/samsung/exynos-pm-domains.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pmdomain/samsung/exynos-pm-domains.c b/drivers/pmdomain/samsung/exynos-pm-domains.c
index 638d286b57f716140b2401092415644a6805870e..15a1582aa92103a07335eb681600d9415369fefd 100644
--- a/drivers/pmdomain/samsung/exynos-pm-domains.c
+++ b/drivers/pmdomain/samsung/exynos-pm-domains.c
@@ -20,6 +20,7 @@
 struct exynos_pm_domain_config {
 	/* Value for LOCAL_PWR_CFG and STATUS fields for each domain */
 	u32 local_pwr_cfg;
+	bool need_early_sync_state;
 };
 
 /*
@@ -69,10 +70,12 @@ static int exynos_pd_power_off(struct generic_pm_domain *domain)
 
 static const struct exynos_pm_domain_config exynos4210_cfg = {
 	.local_pwr_cfg		= 0x7,
+	.need_early_sync_state	= true,
 };
 
 static const struct exynos_pm_domain_config exynos5433_cfg = {
 	.local_pwr_cfg		= 0xf,
+	.need_early_sync_state	= true,
 };
 
 static const struct of_device_id exynos_pm_domain_of_match[] = {
@@ -179,7 +182,7 @@ static int exynos_pd_probe(struct platform_device *pdev)
 	 * reset during boot. As a temporary hack to manage this, let's enforce
 	 * a sync_state.
 	 */
-	if (!ret)
+	if (pm_domain_cfg->need_early_sync_state && !ret)
 		of_genpd_sync_state(np);
 
 	pm_runtime_enable(dev);

-- 
2.51.0.710.ga91ca5db03-goog


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

* [PATCH v2 09/10] pmdomain: samsung: add support for google,gs101-pd
  2025-10-09 15:25 [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
                   ` (7 preceding siblings ...)
  2025-10-09 15:25 ` [PATCH v2 08/10] pmdomain: samsung: selectively handle enforced sync_state André Draszik
@ 2025-10-09 15:25 ` André Draszik
  2025-10-09 15:25 ` [PATCH v2 10/10] pmdomain: samsung: use dev_err() instead of pr_err() André Draszik
  9 siblings, 0 replies; 18+ messages in thread
From: André Draszik @ 2025-10-09 15:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, André Draszik

On Google gs101, direct mmio register access to the PMU registers
doesn't work and access must happen via a (syscon) regmap created by
the PMU driver instead.

Try to obtain this regmap using the parent node in DT in case this PD
is a child of the PMU and fall back to the traditional direct mmio
regmap otherwise.

Additionally, the status is just one bit on gs101.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/pmdomain/samsung/exynos-pm-domains.c | 65 +++++++++++++++++++---------
 1 file changed, 45 insertions(+), 20 deletions(-)

diff --git a/drivers/pmdomain/samsung/exynos-pm-domains.c b/drivers/pmdomain/samsung/exynos-pm-domains.c
index 15a1582aa92103a07335eb681600d9415369fefd..a7e55624728a62545eac049c9a51012a229f44c2 100644
--- a/drivers/pmdomain/samsung/exynos-pm-domains.c
+++ b/drivers/pmdomain/samsung/exynos-pm-domains.c
@@ -12,6 +12,7 @@
 #include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/mfd/syscon.h>
 #include <linux/pm_domain.h>
 #include <linux/of.h>
 #include <linux/pm_runtime.h>
@@ -78,8 +79,15 @@ static const struct exynos_pm_domain_config exynos5433_cfg = {
 	.need_early_sync_state	= true,
 };
 
+static const struct exynos_pm_domain_config gs101_cfg = {
+	.local_pwr_cfg		= BIT(0),
+};
+
 static const struct of_device_id exynos_pm_domain_of_match[] = {
 	{
+		.compatible = "google,gs101-pd",
+		.data = &gs101_cfg,
+	}, {
 		.compatible = "samsung,exynos4210-pd",
 		.data = &exynos4210_cfg,
 	}, {
@@ -107,17 +115,9 @@ static int exynos_pd_probe(struct platform_device *pdev)
 	struct of_phandle_args child, parent;
 	struct exynos_pm_domain *pd;
 	struct resource *res;
-	void __iomem *base;
 	unsigned int val;
 	int on, ret;
 
-	struct regmap_config reg_config = {
-		.reg_bits = 32,
-		.val_bits = 32,
-		.reg_stride = 4,
-		.use_relaxed_mmio = true,
-	};
-
 	pm_domain_cfg = of_device_get_match_data(dev);
 	pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
 	if (!pd)
@@ -128,25 +128,50 @@ static int exynos_pd_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	/*
-	 * The resource typically points into the address space of the PMU.
+	 * The resource typically points into the address space of the PMU and
+	 * we have to consider two cases:
+	 *   1) some implementations require a custom syscon regmap
+	 *   2) this driver might map the same addresses as the PMU driver
 	 * Therefore, avoid using devm_platform_get_and_ioremap_resource() and
-	 * instead use platform_get_resource() and devm_ioremap() to avoid
+	 * instead use platform_get_resource() here, and below for case 1) use
+	 * syscon_node_to_regmap() while for case 2) use devm_ioremap() to avoid
 	 * conflicts due to address space overlap.
 	 */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
 		return dev_err_probe(dev, -ENXIO, "missing IO resources");
 
-	base = devm_ioremap(dev, res->start, resource_size(res));
-	if (!base)
-		return dev_err_probe(dev, -ENOMEM,
-				     "failed to ioremap PMU registers");
-
-	reg_config.max_register = resource_size(res) - reg_config.reg_stride;
-	pd->regmap = devm_regmap_init_mmio(dev, base, &reg_config);
-	if (IS_ERR(pd->regmap))
-		return dev_err_probe(dev, PTR_ERR(base),
-				     "failed to init regmap");
+	if (dev->parent &&
+	    of_device_is_compatible(dev->parent->of_node, "syscon")) {
+		pd->regmap = syscon_node_to_regmap(dev->parent->of_node);
+		if (IS_ERR(pd->regmap))
+			return dev_err_probe(dev, PTR_ERR(pd->regmap),
+					     "failed to acquire PMU regmap");
+
+		pd->configuration_reg = res->start;
+		pd->status_reg = res->start;
+	} else {
+		void __iomem *base;
+
+		const struct regmap_config reg_config = {
+			.reg_bits = 32,
+			.val_bits = 32,
+			.reg_stride = 4,
+			.use_relaxed_mmio = true,
+			.max_register = (resource_size(res)
+					 - reg_config.reg_stride),
+		};
+
+		base = devm_ioremap(dev, res->start, resource_size(res));
+		if (!base)
+			return dev_err_probe(dev, -ENOMEM,
+					     "failed to ioremap PMU registers");
+
+		pd->regmap = devm_regmap_init_mmio(dev, base, &reg_config);
+		if (IS_ERR(pd->regmap))
+			return dev_err_probe(dev, PTR_ERR(base),
+					     "failed to init regmap");
+	}
 
 	pd->pd.power_off = exynos_pd_power_off;
 	pd->pd.power_on = exynos_pd_power_on;

-- 
2.51.0.710.ga91ca5db03-goog


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

* [PATCH v2 10/10] pmdomain: samsung: use dev_err() instead of pr_err()
  2025-10-09 15:25 [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
                   ` (8 preceding siblings ...)
  2025-10-09 15:25 ` [PATCH v2 09/10] pmdomain: samsung: add support for google,gs101-pd André Draszik
@ 2025-10-09 15:25 ` André Draszik
  9 siblings, 0 replies; 18+ messages in thread
From: André Draszik @ 2025-10-09 15:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, André Draszik, Krzysztof Kozlowski

dev_err() gives us more consistent error messages, which include the
device. Switch to using dev_err().

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/pmdomain/samsung/exynos-pm-domains.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pmdomain/samsung/exynos-pm-domains.c b/drivers/pmdomain/samsung/exynos-pm-domains.c
index a7e55624728a62545eac049c9a51012a229f44c2..387ee1c91caeae4519237af2ec659f56782e7bd7 100644
--- a/drivers/pmdomain/samsung/exynos-pm-domains.c
+++ b/drivers/pmdomain/samsung/exynos-pm-domains.c
@@ -29,6 +29,7 @@ struct exynos_pm_domain_config {
  */
 struct exynos_pm_domain {
 	struct regmap *regmap;
+	struct device *dev;
 	struct generic_pm_domain pd;
 	u32 local_pwr_cfg;
 	u32 configuration_reg;
@@ -53,8 +54,9 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
 				       (val & pd->local_pwr_cfg) == pwr,
 				       100, 1 * USEC_PER_MSEC);
 	if (err)
-		pr_err("Power domain %s %sable failed: %d (%#.2x)\n",
-		       domain->name, power_on ? "en" : "dis", err, val);
+		dev_err(pd->dev,
+			"Power domain %s %sable failed: %d (%#.2x)\n",
+			domain->name, power_on ? "en" : "dis", err, val);
 
 	return err;
 }
@@ -123,6 +125,8 @@ static int exynos_pd_probe(struct platform_device *pdev)
 	if (!pd)
 		return -ENOMEM;
 
+	pd->dev = dev;
+
 	pd->pd.name = exynos_get_domain_name(dev, np);
 	if (!pd->pd.name)
 		return -ENOMEM;

-- 
2.51.0.710.ga91ca5db03-goog


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

* Re: [PATCH v2 04/10] pmdomain: samsung: plug potential memleak during probe
  2025-10-09 15:25 ` [PATCH v2 04/10] pmdomain: samsung: plug potential memleak during probe André Draszik
@ 2025-10-10  0:35   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2025-10-10  0:35 UTC (permalink / raw)
  To: André Draszik, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm, stable

On 09/10/2025 00:25, André Draszik wrote:
> of_genpd_add_provider_simple() could fail, in which case this code
> leaks the domain name, pd->pd.name.
> 
> Use devm_kstrdup_const() to plug this leak. As a side-effect, we can
> simplify existing error handling.
> 
> Fixes: c09a3e6c97f0 ("soc: samsung: pm_domains: Convert to regular platform driver")
> Cc: stable@vger.kernel.org
> Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof

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

* Re: [PATCH v2 03/10] dt-bindings: soc: samsung: gs101-pmu: allow power domains as children
  2025-10-09 15:25 ` [PATCH v2 03/10] dt-bindings: soc: samsung: gs101-pmu: allow power domains as children André Draszik
@ 2025-10-10  5:26   ` André Draszik
  2025-10-10 14:13   ` Rob Herring
  1 sibling, 0 replies; 18+ messages in thread
From: André Draszik @ 2025-10-10  5:26 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Rob Herring, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
	linux-arm-kernel, linux-samsung-soc, devicetree, linux-kernel,
	linux-pm

On Thu, 2025-10-09 at 16:25 +0100, André Draszik wrote:
> The power domains are a property of / implemented in the PMU. As such,
> they should be modelled as child nodes of the PMU.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> 
> ---
> Note: Ideally, the newly added properties (ranges, etc.) should only be
> 'required' if "^power-domain@[0-9a-f]+$" exists as a patternProperty,
> as they're needed only in that case. As-is, this patch now causes
> warnings for existing DTs as they don't specify the new properties (and
> they shouldn't need to). Only if DTs are updated to include
> power-domains, such an update should also add the new properties.
> 
> I've not been able to come up with the correct schema syntax to achieve
> that. dependencies, dependentRequired, and dependentSchemas don't seem
> to support patterns. Similarly,
>   - if:
>       required:
>         - ...
>     then:
>       required:
>         - ...
> 
> doesn't allow patterns in the 'if' block (or I didn't get the syntax
> right).
> ---
>  .../bindings/soc/google/google,gs101-pmu.yaml      | 42 +++++++++++++++++++++-
>  1 file changed, 41 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
> b/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
> index 209ee2f80d449c3eec568188898b3c6f7ae0ddd4..d18a351b649c0736662e67bb64de46afa01e399a 100644
> --- a/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
> +++ b/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
> @@ -27,6 +27,14 @@ properties:
>    reg:
>      maxItems: 1
>  
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 1
> +
> +  ranges: true
> +
>    reboot-mode:
>      $ref: /schemas/power/reset/syscon-reboot-mode.yaml
>      type: object
> @@ -50,18 +58,50 @@ properties:
>      description:
>        Phandle to PMU interrupt generation interface.
>  
> +patternProperties:
> +  "^power-domain@[0-9a-f]+$":
> +    type: object
> +    description: Child node describing one power domain within the PMU
> +
> +    additionalProperties: true
> +
> +    properties:
> +      compatible:
> +        const: google,gs101-pd
> +
>  required:
>    - compatible
>    - reg
> +  - '#address-cells'
> +  - '#size-cells'
> +  - ranges
>    - google,pmu-intr-gen-syscon
>  
> -unevaluatedProperties: false
> +additionalProperties: false

Ooops, this line should have been part of patch 02 in the first place. Will
fix in next version.

Cheers,
Andre'


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

* Re: [PATCH v2 02/10] dt-bindings: soc: samsung: exynos-pmu: move gs101-pmu into separate binding
  2025-10-09 15:25 ` [PATCH v2 02/10] dt-bindings: soc: samsung: exynos-pmu: move gs101-pmu into separate binding André Draszik
@ 2025-10-10 12:23   ` Rob Herring (Arm)
  2025-10-10 14:16     ` André Draszik
  2025-10-10 14:09   ` Rob Herring
  1 sibling, 1 reply; 18+ messages in thread
From: Rob Herring (Arm) @ 2025-10-10 12:23 UTC (permalink / raw)
  To: André Draszik
  Cc: Peter Griffin, Ulf Hansson, kernel-team, linux-samsung-soc,
	devicetree, Krzysztof Kozlowski, linux-arm-kernel,
	Marek Szyprowski, linux-kernel, Conor Dooley, linux-pm,
	Tudor Ambarus, Will McVicker, Alim Akhtar, Krzysztof Kozlowski


On Thu, 09 Oct 2025 16:25:04 +0100, André Draszik wrote:
> The gs101-pmu binding is going to acquire various additional (pattern)
> properties that don't apply to other PMUs supported by this binding.
> 
> To enable this, move google,gs101-pmu into a separate binding.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
>  .../bindings/soc/google/google,gs101-pmu.yaml      | 67 ++++++++++++++++++++++
>  .../bindings/soc/samsung/exynos-pmu.yaml           | 20 -------
>  MAINTAINERS                                        |  1 +
>  3 files changed, 68 insertions(+), 20 deletions(-)
> 

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

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml: $id: Cannot determine base path from $id, relative path/filename doesn't match actual path or filename
 	 $id: http://devicetree.org/schemas/soc/samsung/google,gs101-pmu.yaml
 	file: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20251009-gs101-pd-v2-2-3f4a6db2af39@linaro.org

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

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

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


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

* Re: [PATCH v2 02/10] dt-bindings: soc: samsung: exynos-pmu: move gs101-pmu into separate binding
  2025-10-09 15:25 ` [PATCH v2 02/10] dt-bindings: soc: samsung: exynos-pmu: move gs101-pmu into separate binding André Draszik
  2025-10-10 12:23   ` Rob Herring (Arm)
@ 2025-10-10 14:09   ` Rob Herring
  1 sibling, 0 replies; 18+ messages in thread
From: Rob Herring @ 2025-10-10 14:09 UTC (permalink / raw)
  To: André Draszik
  Cc: Krzysztof Kozlowski, Alim Akhtar, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski, Peter Griffin,
	Tudor Ambarus, Will McVicker, kernel-team, linux-arm-kernel,
	linux-samsung-soc, devicetree, linux-kernel, linux-pm

On Thu, Oct 09, 2025 at 04:25:04PM +0100, André Draszik wrote:
> The gs101-pmu binding is going to acquire various additional (pattern)
> properties that don't apply to other PMUs supported by this binding.
> 
> To enable this, move google,gs101-pmu into a separate binding.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
>  .../bindings/soc/google/google,gs101-pmu.yaml      | 67 ++++++++++++++++++++++
>  .../bindings/soc/samsung/exynos-pmu.yaml           | 20 -------
>  MAINTAINERS                                        |  1 +
>  3 files changed, 68 insertions(+), 20 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml b/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
> new file mode 100644
> index 0000000000000000000000000000000000000000..209ee2f80d449c3eec568188898b3c6f7ae0ddd4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml
> @@ -0,0 +1,67 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/soc/samsung/google,gs101-pmu.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Google GS101 Power Management Unit (PMU)
> +
> +maintainers:
> +  - André Draszik <andre.draszik@linaro.org>
> +
> +# Custom select to avoid matching all nodes with 'syscon'

That's not necessary.

> +select:
> +  properties:
> +    compatible:
> +      contains:
> +        const: google,gs101-pmu
> +  required:
> +    - compatible

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

* Re: [PATCH v2 03/10] dt-bindings: soc: samsung: gs101-pmu: allow power domains as children
  2025-10-09 15:25 ` [PATCH v2 03/10] dt-bindings: soc: samsung: gs101-pmu: allow power domains as children André Draszik
  2025-10-10  5:26   ` André Draszik
@ 2025-10-10 14:13   ` Rob Herring
  1 sibling, 0 replies; 18+ messages in thread
From: Rob Herring @ 2025-10-10 14:13 UTC (permalink / raw)
  To: André Draszik
  Cc: Krzysztof Kozlowski, Alim Akhtar, Conor Dooley,
	Krzysztof Kozlowski, Ulf Hansson, Marek Szyprowski, Peter Griffin,
	Tudor Ambarus, Will McVicker, kernel-team, linux-arm-kernel,
	linux-samsung-soc, devicetree, linux-kernel, linux-pm

On Thu, Oct 09, 2025 at 04:25:05PM +0100, André Draszik wrote:
> The power domains are a property of / implemented in the PMU. As such,
> they should be modelled as child nodes of the PMU.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> 
> ---
> Note: Ideally, the newly added properties (ranges, etc.) should only be
> 'required' if "^power-domain@[0-9a-f]+$" exists as a patternProperty,
> as they're needed only in that case. As-is, this patch now causes
> warnings for existing DTs as they don't specify the new properties (and
> they shouldn't need to). Only if DTs are updated to include
> power-domains, such an update should also add the new properties.
> 
> I've not been able to come up with the correct schema syntax to achieve
> that. dependencies, dependentRequired, and dependentSchemas don't seem
> to support patterns. Similarly,
>   - if:
>       required:
>         - ...
>     then:
>       required:
>         - ...
> 
> doesn't allow patterns in the 'if' block (or I didn't get the syntax
> right).

This is a known limitation in json-schema. Not sure if they've come up 
with a solution yet.

Rob

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

* Re: [PATCH v2 02/10] dt-bindings: soc: samsung: exynos-pmu: move gs101-pmu into separate binding
  2025-10-10 12:23   ` Rob Herring (Arm)
@ 2025-10-10 14:16     ` André Draszik
  0 siblings, 0 replies; 18+ messages in thread
From: André Draszik @ 2025-10-10 14:16 UTC (permalink / raw)
  To: Rob Herring (Arm)
  Cc: Peter Griffin, Ulf Hansson, kernel-team, linux-samsung-soc,
	devicetree, Krzysztof Kozlowski, linux-arm-kernel,
	Marek Szyprowski, linux-kernel, Conor Dooley, linux-pm,
	Tudor Ambarus, Will McVicker, Alim Akhtar, Krzysztof Kozlowski

On Fri, 2025-10-10 at 07:23 -0500, Rob Herring (Arm) wrote:
> 
> On Thu, 09 Oct 2025 16:25:04 +0100, André Draszik wrote:
> > The gs101-pmu binding is going to acquire various additional (pattern)
> > properties that don't apply to other PMUs supported by this binding.
> > 
> > To enable this, move google,gs101-pmu into a separate binding.
> > 
> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > ---
> >  .../bindings/soc/google/google,gs101-pmu.yaml      | 67 ++++++++++++++++++++++
> >  .../bindings/soc/samsung/exynos-pmu.yaml           | 20 -------
> >  MAINTAINERS                                        |  1 +
> >  3 files changed, 68 insertions(+), 20 deletions(-)
> > 
> 
> My bot found errors running 'make dt_binding_check' on your patch:
> 
> yamllint warnings/errors:
> 
> dtschema/dtc warnings/errors:
> /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml: $id: Cannot determine base
> path from $id, relative path/filename doesn't match actual path or filename
>  	 $id: http://devicetree.org/schemas/soc/samsung/google,gs101-pmu.yaml
>  	file: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml

I moved the file ultimately but had restricted to samsung using DT_SCHEMA_FILES=
during my binding check run :-(

A.

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

* Re: [PATCH v2 01/10] dt-bindings: power: samsung: add google,gs101-pd
  2025-10-09 15:25 ` [PATCH v2 01/10] dt-bindings: power: samsung: add google,gs101-pd André Draszik
@ 2025-10-10 18:31   ` Rob Herring (Arm)
  0 siblings, 0 replies; 18+ messages in thread
From: Rob Herring (Arm) @ 2025-10-10 18:31 UTC (permalink / raw)
  To: André Draszik
  Cc: Marek Szyprowski, Peter Griffin, Alim Akhtar, Krzysztof Kozlowski,
	Will McVicker, Krzysztof Kozlowski, Conor Dooley, kernel-team,
	linux-samsung-soc, Tudor Ambarus, devicetree, linux-kernel,
	linux-pm, linux-arm-kernel, Ulf Hansson


On Thu, 09 Oct 2025 16:25:03 +0100, André Draszik wrote:
> Add support for the Google gs101 version of the Exynos power domains. A
> new compatible is needed because register fields have changed.
> 
> Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
>  Documentation/devicetree/bindings/power/pd-samsung.yaml | 1 +
>  1 file changed, 1 insertion(+)
> 

Acked-by: Rob Herring (Arm) <robh@kernel.org>


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

end of thread, other threads:[~2025-10-10 18:31 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-09 15:25 [PATCH v2 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
2025-10-09 15:25 ` [PATCH v2 01/10] dt-bindings: power: samsung: add google,gs101-pd André Draszik
2025-10-10 18:31   ` Rob Herring (Arm)
2025-10-09 15:25 ` [PATCH v2 02/10] dt-bindings: soc: samsung: exynos-pmu: move gs101-pmu into separate binding André Draszik
2025-10-10 12:23   ` Rob Herring (Arm)
2025-10-10 14:16     ` André Draszik
2025-10-10 14:09   ` Rob Herring
2025-10-09 15:25 ` [PATCH v2 03/10] dt-bindings: soc: samsung: gs101-pmu: allow power domains as children André Draszik
2025-10-10  5:26   ` André Draszik
2025-10-10 14:13   ` Rob Herring
2025-10-09 15:25 ` [PATCH v2 04/10] pmdomain: samsung: plug potential memleak during probe André Draszik
2025-10-10  0:35   ` Krzysztof Kozlowski
2025-10-09 15:25 ` [PATCH v2 05/10] pmdomain: samsung: convert to using regmap André Draszik
2025-10-09 15:25 ` [PATCH v2 06/10] pmdomain: samsung: convert to regmap_read_poll_timeout() André Draszik
2025-10-09 15:25 ` [PATCH v2 07/10] pmdomain: samsung: don't hardcode offset for registers to 0 and 4 André Draszik
2025-10-09 15:25 ` [PATCH v2 08/10] pmdomain: samsung: selectively handle enforced sync_state André Draszik
2025-10-09 15:25 ` [PATCH v2 09/10] pmdomain: samsung: add support for google,gs101-pd André Draszik
2025-10-09 15:25 ` [PATCH v2 10/10] pmdomain: samsung: use dev_err() instead of pr_err() André Draszik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).