All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/3] Add PWM support Amlogic S7 S7D S6
@ 2026-12-01  3:34 ` Xianwei Zhao via B4 Relay
  0 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao via B4 Relay @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Junyi Zhao, Krzysztof Kozlowski,
	Alexandre Mergnat

Add bindings and driver support Amlogic S7/S7D/S6 SoCs.

Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
Changes in v6:
- Drop the subject of [1/3] redundant characters "bindings".
- A maximum limit of 2 for npwm in func probe [2/3] and update the commit message.
- Link to v5: https://lore.kernel.org/r/20261130-s6-s7-pwm-v5-0-396935d2987d@amlogic.com

Changes in v5:
- Since [3/4] has already been merged, drop it from the series.
- Update the commit message of [2/4] to better match the actual change.
- In [4/4], add the missing space in the commit message and move private_data to a more appropriate location.
- Link to v4: https://lore.kernel.org/r/20260827-s6-s7-pwm-v4-0-d28a2015177d@amlogic.com

Changes in v4:
- It is divided into three submissions based on the function-driven part.
- Merge and modify functions for init clocks, According to Alexandre's suggestion.
- Link to v3: https://lore.kernel.org/r/20260521-s6-s7-pwm-v3-0-57b073fbafef@amlogic.com

Changes in v3:
- Use npwm instead of single_pwm in priv_data and format adjustments.
- Link to v2: https://lore.kernel.org/r/20260402-s6-s7-pwm-v2-0-657dce040956@amlogic.com

Changes in v2:
- Simpler s7 clock desc, and drop the example in bindings.
- Make minor changes to probe based on Martin's suggestion.
- Link to v1: https://lore.kernel.org/r/20260326-s6-s7-pwm-v1-0-67e2f72b98bc@amlogic.com

---
Junyi Zhao (1):
      dt-bindings: pwm: amlogic: Add S6, S7 and S7D PWM

Xianwei Zhao (2):
      pwm: meson: add the PWM count driver data
      pwm: meson: Add support for Amlogic S7

 .../devicetree/bindings/pwm/pwm-amlogic.yaml       | 19 ++++++++++++++
 drivers/pwm/pwm-meson.c                            | 30 +++++++++++++++++++---
 2 files changed, 46 insertions(+), 3 deletions(-)
---
base-commit: ed17ca6b91b8258eb5fe023992875cbb54d04614
change-id: 20260325-s6-s7-pwm-281658b88736

Best regards,
-- 
Xianwei Zhao <xianwei.zhao@amlogic.com>



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

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

* [PATCH v6 0/3] Add PWM support Amlogic S7 S7D S6
@ 2026-12-01  3:34 ` Xianwei Zhao via B4 Relay
  0 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao via B4 Relay @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Junyi Zhao, Krzysztof Kozlowski,
	Alexandre Mergnat

Add bindings and driver support Amlogic S7/S7D/S6 SoCs.

Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
Changes in v6:
- Drop the subject of [1/3] redundant characters "bindings".
- A maximum limit of 2 for npwm in func probe [2/3] and update the commit message.
- Link to v5: https://lore.kernel.org/r/20261130-s6-s7-pwm-v5-0-396935d2987d@amlogic.com

Changes in v5:
- Since [3/4] has already been merged, drop it from the series.
- Update the commit message of [2/4] to better match the actual change.
- In [4/4], add the missing space in the commit message and move private_data to a more appropriate location.
- Link to v4: https://lore.kernel.org/r/20260827-s6-s7-pwm-v4-0-d28a2015177d@amlogic.com

Changes in v4:
- It is divided into three submissions based on the function-driven part.
- Merge and modify functions for init clocks, According to Alexandre's suggestion.
- Link to v3: https://lore.kernel.org/r/20260521-s6-s7-pwm-v3-0-57b073fbafef@amlogic.com

Changes in v3:
- Use npwm instead of single_pwm in priv_data and format adjustments.
- Link to v2: https://lore.kernel.org/r/20260402-s6-s7-pwm-v2-0-657dce040956@amlogic.com

Changes in v2:
- Simpler s7 clock desc, and drop the example in bindings.
- Make minor changes to probe based on Martin's suggestion.
- Link to v1: https://lore.kernel.org/r/20260326-s6-s7-pwm-v1-0-67e2f72b98bc@amlogic.com

---
Junyi Zhao (1):
      dt-bindings: pwm: amlogic: Add S6, S7 and S7D PWM

Xianwei Zhao (2):
      pwm: meson: add the PWM count driver data
      pwm: meson: Add support for Amlogic S7

 .../devicetree/bindings/pwm/pwm-amlogic.yaml       | 19 ++++++++++++++
 drivers/pwm/pwm-meson.c                            | 30 +++++++++++++++++++---
 2 files changed, 46 insertions(+), 3 deletions(-)
---
base-commit: ed17ca6b91b8258eb5fe023992875cbb54d04614
change-id: 20260325-s6-s7-pwm-281658b88736

Best regards,
-- 
Xianwei Zhao <xianwei.zhao@amlogic.com>



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

* [PATCH v6 0/3] Add PWM support Amlogic S7 S7D S6
@ 2026-12-01  3:34 ` Xianwei Zhao via B4 Relay
  0 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Junyi Zhao, Krzysztof Kozlowski,
	Alexandre Mergnat

Add bindings and driver support Amlogic S7/S7D/S6 SoCs.

Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
Changes in v6:
- Drop the subject of [1/3] redundant characters "bindings".
- A maximum limit of 2 for npwm in func probe [2/3] and update the commit message.
- Link to v5: https://lore.kernel.org/r/20261130-s6-s7-pwm-v5-0-396935d2987d@amlogic.com

Changes in v5:
- Since [3/4] has already been merged, drop it from the series.
- Update the commit message of [2/4] to better match the actual change.
- In [4/4], add the missing space in the commit message and move private_data to a more appropriate location.
- Link to v4: https://lore.kernel.org/r/20260827-s6-s7-pwm-v4-0-d28a2015177d@amlogic.com

Changes in v4:
- It is divided into three submissions based on the function-driven part.
- Merge and modify functions for init clocks, According to Alexandre's suggestion.
- Link to v3: https://lore.kernel.org/r/20260521-s6-s7-pwm-v3-0-57b073fbafef@amlogic.com

Changes in v3:
- Use npwm instead of single_pwm in priv_data and format adjustments.
- Link to v2: https://lore.kernel.org/r/20260402-s6-s7-pwm-v2-0-657dce040956@amlogic.com

Changes in v2:
- Simpler s7 clock desc, and drop the example in bindings.
- Make minor changes to probe based on Martin's suggestion.
- Link to v1: https://lore.kernel.org/r/20260326-s6-s7-pwm-v1-0-67e2f72b98bc@amlogic.com

---
Junyi Zhao (1):
      dt-bindings: pwm: amlogic: Add S6, S7 and S7D PWM

Xianwei Zhao (2):
      pwm: meson: add the PWM count driver data
      pwm: meson: Add support for Amlogic S7

 .../devicetree/bindings/pwm/pwm-amlogic.yaml       | 19 ++++++++++++++
 drivers/pwm/pwm-meson.c                            | 30 +++++++++++++++++++---
 2 files changed, 46 insertions(+), 3 deletions(-)
---
base-commit: ed17ca6b91b8258eb5fe023992875cbb54d04614
change-id: 20260325-s6-s7-pwm-281658b88736

Best regards,
-- 
Xianwei Zhao <xianwei.zhao@amlogic.com>


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

* [PATCH v6 1/3] dt-bindings: pwm: amlogic: Add S6, S7 and S7D PWM
  2026-12-01  3:34 ` Xianwei Zhao via B4 Relay
  (?)
@ 2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
  -1 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao via B4 Relay @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Junyi Zhao, Krzysztof Kozlowski,
	Alexandre Mergnat

From: Junyi Zhao <junyi.zhao@amlogic.com>

Amlogic S7/S7D/S6 different from the previous SoCs, a controller
includes one pwm, at the same time, the controller has only one
input clock source.

Signed-off-by: Junyi Zhao <junyi.zhao@amlogic.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
 .../devicetree/bindings/pwm/pwm-amlogic.yaml          | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml b/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml
index c337d85da40f..93fa97f4011b 100644
--- a/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml
+++ b/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml
@@ -37,6 +37,7 @@ properties:
       - enum:
           - amlogic,meson8-pwm-v2
           - amlogic,meson-s4-pwm
+          - amlogic,s7-pwm
       - items:
           - enum:
               - amlogic,a4-pwm
@@ -45,6 +46,11 @@ properties:
               - amlogic,t7-pwm
               - amlogic,meson-a1-pwm
           - const: amlogic,meson-s4-pwm
+      - items:
+          - enum:
+              - amlogic,s6-pwm
+              - amlogic,s7d-pwm
+          - const: amlogic,s7-pwm
       - items:
           - enum:
               - amlogic,meson8b-pwm-v2
@@ -146,6 +152,19 @@ allOf:
         clock-names: false
       required:
         - clocks
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - amlogic,s7-pwm
+    then:
+      properties:
+        clocks:
+          maxItems: 1
+        clock-names: false
+      required:
+        - clocks
 
   - if:
       properties:

-- 
2.52.0



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

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

* [PATCH v6 1/3] dt-bindings: pwm: amlogic: Add S6, S7 and S7D PWM
@ 2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
  0 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao via B4 Relay @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Junyi Zhao, Krzysztof Kozlowski,
	Alexandre Mergnat

From: Junyi Zhao <junyi.zhao@amlogic.com>

Amlogic S7/S7D/S6 different from the previous SoCs, a controller
includes one pwm, at the same time, the controller has only one
input clock source.

Signed-off-by: Junyi Zhao <junyi.zhao@amlogic.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
 .../devicetree/bindings/pwm/pwm-amlogic.yaml          | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml b/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml
index c337d85da40f..93fa97f4011b 100644
--- a/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml
+++ b/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml
@@ -37,6 +37,7 @@ properties:
       - enum:
           - amlogic,meson8-pwm-v2
           - amlogic,meson-s4-pwm
+          - amlogic,s7-pwm
       - items:
           - enum:
               - amlogic,a4-pwm
@@ -45,6 +46,11 @@ properties:
               - amlogic,t7-pwm
               - amlogic,meson-a1-pwm
           - const: amlogic,meson-s4-pwm
+      - items:
+          - enum:
+              - amlogic,s6-pwm
+              - amlogic,s7d-pwm
+          - const: amlogic,s7-pwm
       - items:
           - enum:
               - amlogic,meson8b-pwm-v2
@@ -146,6 +152,19 @@ allOf:
         clock-names: false
       required:
         - clocks
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - amlogic,s7-pwm
+    then:
+      properties:
+        clocks:
+          maxItems: 1
+        clock-names: false
+      required:
+        - clocks
 
   - if:
       properties:

-- 
2.52.0



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

* [PATCH v6 1/3] dt-bindings: pwm: amlogic: Add S6, S7 and S7D PWM
@ 2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
  0 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Junyi Zhao, Krzysztof Kozlowski,
	Alexandre Mergnat

From: Junyi Zhao <junyi.zhao@amlogic.com>

Amlogic S7/S7D/S6 different from the previous SoCs, a controller
includes one pwm, at the same time, the controller has only one
input clock source.

Signed-off-by: Junyi Zhao <junyi.zhao@amlogic.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
 .../devicetree/bindings/pwm/pwm-amlogic.yaml          | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml b/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml
index c337d85da40f..93fa97f4011b 100644
--- a/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml
+++ b/Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml
@@ -37,6 +37,7 @@ properties:
       - enum:
           - amlogic,meson8-pwm-v2
           - amlogic,meson-s4-pwm
+          - amlogic,s7-pwm
       - items:
           - enum:
               - amlogic,a4-pwm
@@ -45,6 +46,11 @@ properties:
               - amlogic,t7-pwm
               - amlogic,meson-a1-pwm
           - const: amlogic,meson-s4-pwm
+      - items:
+          - enum:
+              - amlogic,s6-pwm
+              - amlogic,s7d-pwm
+          - const: amlogic,s7-pwm
       - items:
           - enum:
               - amlogic,meson8b-pwm-v2
@@ -146,6 +152,19 @@ allOf:
         clock-names: false
       required:
         - clocks
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - amlogic,s7-pwm
+    then:
+      properties:
+        clocks:
+          maxItems: 1
+        clock-names: false
+      required:
+        - clocks
 
   - if:
       properties:

-- 
2.52.0


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

* [PATCH v6 2/3] pwm: meson: add the PWM count driver data
  2026-12-01  3:34 ` Xianwei Zhao via B4 Relay
  (?)
@ 2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
  -1 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao via B4 Relay @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Alexandre Mergnat

From: Xianwei Zhao <xianwei.zhao@amlogic.com>

To prepare adding support for S6, S7 and S7D SoCs which don't have 2
but 1 PWM outputs, make the various loops iterate using chip->npwm
instead of the constant MESON_NUM_PWMS. Add npwm to struct
meson_pwm_data, and set .npwm = 2 for existing variants.

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
 drivers/pwm/pwm-meson.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 3a28c853089f..a4b5f3877607 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -108,6 +108,7 @@ struct meson_pwm_data {
 	int (*channels_init)(struct pwm_chip *chip);
 	bool has_constant;
 	bool has_polarity;
+	u8 npwm;
 };
 
 struct meson_pwm {
@@ -440,7 +441,7 @@ static int meson_pwm_init_clocks_meson8b(struct pwm_chip *chip,
 	char name[255];
 	int err;
 
-	for (i = 0; i < MESON_NUM_PWMS; i++) {
+	for (i = 0; i < chip->npwm; i++) {
 		struct meson_pwm_channel *channel = &meson->channels[i];
 		struct clk_parent_data div_parent = {}, gate_parent = {};
 		struct clk_init_data init = {};
@@ -580,6 +581,7 @@ static int meson_pwm_init_channels_per_channel_clk(struct pwm_chip *chip)
 static const struct meson_pwm_data pwm_meson8b_data = {
 	.parent_names = { "xtal", NULL, "fclk_div4", "fclk_div3" },
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
+	.npwm = 2,
 };
 
 /*
@@ -589,6 +591,7 @@ static const struct meson_pwm_data pwm_meson8b_data = {
 static const struct meson_pwm_data pwm_gxbb_ao_data = {
 	.parent_names = { "xtal", "clk81", NULL, NULL },
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_axg_ee_data = {
@@ -596,6 +599,7 @@ static const struct meson_pwm_data pwm_axg_ee_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_axg_ao_data = {
@@ -603,6 +607,7 @@ static const struct meson_pwm_data pwm_axg_ao_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_g12a_ee_data = {
@@ -610,6 +615,7 @@ static const struct meson_pwm_data pwm_g12a_ee_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_g12a_ao_ab_data = {
@@ -617,6 +623,7 @@ static const struct meson_pwm_data pwm_g12a_ao_ab_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_g12a_ao_cd_data = {
@@ -624,22 +631,26 @@ static const struct meson_pwm_data pwm_g12a_ao_cd_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_meson8_v2_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_v2,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_meson_axg_v2_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_v2,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_s4_data = {
 	.channels_init = meson_pwm_init_channels_per_channel_clk,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct of_device_id meson_pwm_matches[] = {
@@ -699,9 +710,12 @@ static int meson_pwm_probe(struct platform_device *pdev)
 {
 	struct pwm_chip *chip;
 	struct meson_pwm *meson;
+	const struct meson_pwm_data *pdata = of_device_get_match_data(&pdev->dev);
 	int err;
 
-	chip = devm_pwmchip_alloc(&pdev->dev, MESON_NUM_PWMS, sizeof(*meson));
+	if (pdata->npwm > 2)
+		return -EINVAL;
+	chip = devm_pwmchip_alloc(&pdev->dev, pdata->npwm, sizeof(*meson));
 	if (IS_ERR(chip))
 		return PTR_ERR(chip);
 	meson = to_meson_pwm(chip);
@@ -713,7 +727,7 @@ static int meson_pwm_probe(struct platform_device *pdev)
 	spin_lock_init(&meson->lock);
 	chip->ops = &meson_pwm_ops;
 
-	meson->data = of_device_get_match_data(&pdev->dev);
+	meson->data = pdata;
 
 	err = meson->data->channels_init(chip);
 	if (err < 0)

-- 
2.52.0



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

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

* [PATCH v6 2/3] pwm: meson: add the PWM count driver data
@ 2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
  0 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao via B4 Relay @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Alexandre Mergnat

From: Xianwei Zhao <xianwei.zhao@amlogic.com>

To prepare adding support for S6, S7 and S7D SoCs which don't have 2
but 1 PWM outputs, make the various loops iterate using chip->npwm
instead of the constant MESON_NUM_PWMS. Add npwm to struct
meson_pwm_data, and set .npwm = 2 for existing variants.

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
 drivers/pwm/pwm-meson.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 3a28c853089f..a4b5f3877607 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -108,6 +108,7 @@ struct meson_pwm_data {
 	int (*channels_init)(struct pwm_chip *chip);
 	bool has_constant;
 	bool has_polarity;
+	u8 npwm;
 };
 
 struct meson_pwm {
@@ -440,7 +441,7 @@ static int meson_pwm_init_clocks_meson8b(struct pwm_chip *chip,
 	char name[255];
 	int err;
 
-	for (i = 0; i < MESON_NUM_PWMS; i++) {
+	for (i = 0; i < chip->npwm; i++) {
 		struct meson_pwm_channel *channel = &meson->channels[i];
 		struct clk_parent_data div_parent = {}, gate_parent = {};
 		struct clk_init_data init = {};
@@ -580,6 +581,7 @@ static int meson_pwm_init_channels_per_channel_clk(struct pwm_chip *chip)
 static const struct meson_pwm_data pwm_meson8b_data = {
 	.parent_names = { "xtal", NULL, "fclk_div4", "fclk_div3" },
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
+	.npwm = 2,
 };
 
 /*
@@ -589,6 +591,7 @@ static const struct meson_pwm_data pwm_meson8b_data = {
 static const struct meson_pwm_data pwm_gxbb_ao_data = {
 	.parent_names = { "xtal", "clk81", NULL, NULL },
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_axg_ee_data = {
@@ -596,6 +599,7 @@ static const struct meson_pwm_data pwm_axg_ee_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_axg_ao_data = {
@@ -603,6 +607,7 @@ static const struct meson_pwm_data pwm_axg_ao_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_g12a_ee_data = {
@@ -610,6 +615,7 @@ static const struct meson_pwm_data pwm_g12a_ee_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_g12a_ao_ab_data = {
@@ -617,6 +623,7 @@ static const struct meson_pwm_data pwm_g12a_ao_ab_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_g12a_ao_cd_data = {
@@ -624,22 +631,26 @@ static const struct meson_pwm_data pwm_g12a_ao_cd_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_meson8_v2_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_v2,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_meson_axg_v2_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_v2,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_s4_data = {
 	.channels_init = meson_pwm_init_channels_per_channel_clk,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct of_device_id meson_pwm_matches[] = {
@@ -699,9 +710,12 @@ static int meson_pwm_probe(struct platform_device *pdev)
 {
 	struct pwm_chip *chip;
 	struct meson_pwm *meson;
+	const struct meson_pwm_data *pdata = of_device_get_match_data(&pdev->dev);
 	int err;
 
-	chip = devm_pwmchip_alloc(&pdev->dev, MESON_NUM_PWMS, sizeof(*meson));
+	if (pdata->npwm > 2)
+		return -EINVAL;
+	chip = devm_pwmchip_alloc(&pdev->dev, pdata->npwm, sizeof(*meson));
 	if (IS_ERR(chip))
 		return PTR_ERR(chip);
 	meson = to_meson_pwm(chip);
@@ -713,7 +727,7 @@ static int meson_pwm_probe(struct platform_device *pdev)
 	spin_lock_init(&meson->lock);
 	chip->ops = &meson_pwm_ops;
 
-	meson->data = of_device_get_match_data(&pdev->dev);
+	meson->data = pdata;
 
 	err = meson->data->channels_init(chip);
 	if (err < 0)

-- 
2.52.0



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

* [PATCH v6 2/3] pwm: meson: add the PWM count driver data
@ 2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
  0 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Alexandre Mergnat

To prepare adding support for S6, S7 and S7D SoCs which don't have 2
but 1 PWM outputs, make the various loops iterate using chip->npwm
instead of the constant MESON_NUM_PWMS. Add npwm to struct
meson_pwm_data, and set .npwm = 2 for existing variants.

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
 drivers/pwm/pwm-meson.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 3a28c853089f..a4b5f3877607 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -108,6 +108,7 @@ struct meson_pwm_data {
 	int (*channels_init)(struct pwm_chip *chip);
 	bool has_constant;
 	bool has_polarity;
+	u8 npwm;
 };
 
 struct meson_pwm {
@@ -440,7 +441,7 @@ static int meson_pwm_init_clocks_meson8b(struct pwm_chip *chip,
 	char name[255];
 	int err;
 
-	for (i = 0; i < MESON_NUM_PWMS; i++) {
+	for (i = 0; i < chip->npwm; i++) {
 		struct meson_pwm_channel *channel = &meson->channels[i];
 		struct clk_parent_data div_parent = {}, gate_parent = {};
 		struct clk_init_data init = {};
@@ -580,6 +581,7 @@ static int meson_pwm_init_channels_per_channel_clk(struct pwm_chip *chip)
 static const struct meson_pwm_data pwm_meson8b_data = {
 	.parent_names = { "xtal", NULL, "fclk_div4", "fclk_div3" },
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
+	.npwm = 2,
 };
 
 /*
@@ -589,6 +591,7 @@ static const struct meson_pwm_data pwm_meson8b_data = {
 static const struct meson_pwm_data pwm_gxbb_ao_data = {
 	.parent_names = { "xtal", "clk81", NULL, NULL },
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_axg_ee_data = {
@@ -596,6 +599,7 @@ static const struct meson_pwm_data pwm_axg_ee_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_axg_ao_data = {
@@ -603,6 +607,7 @@ static const struct meson_pwm_data pwm_axg_ao_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_g12a_ee_data = {
@@ -610,6 +615,7 @@ static const struct meson_pwm_data pwm_g12a_ee_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_g12a_ao_ab_data = {
@@ -617,6 +623,7 @@ static const struct meson_pwm_data pwm_g12a_ao_ab_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_g12a_ao_cd_data = {
@@ -624,22 +631,26 @@ static const struct meson_pwm_data pwm_g12a_ao_cd_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_legacy,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_meson8_v2_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_v2,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_meson_axg_v2_data = {
 	.channels_init = meson_pwm_init_channels_meson8b_v2,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct meson_pwm_data pwm_s4_data = {
 	.channels_init = meson_pwm_init_channels_per_channel_clk,
 	.has_constant = true,
 	.has_polarity = true,
+	.npwm = 2,
 };
 
 static const struct of_device_id meson_pwm_matches[] = {
@@ -699,9 +710,12 @@ static int meson_pwm_probe(struct platform_device *pdev)
 {
 	struct pwm_chip *chip;
 	struct meson_pwm *meson;
+	const struct meson_pwm_data *pdata = of_device_get_match_data(&pdev->dev);
 	int err;
 
-	chip = devm_pwmchip_alloc(&pdev->dev, MESON_NUM_PWMS, sizeof(*meson));
+	if (pdata->npwm > 2)
+		return -EINVAL;
+	chip = devm_pwmchip_alloc(&pdev->dev, pdata->npwm, sizeof(*meson));
 	if (IS_ERR(chip))
 		return PTR_ERR(chip);
 	meson = to_meson_pwm(chip);
@@ -713,7 +727,7 @@ static int meson_pwm_probe(struct platform_device *pdev)
 	spin_lock_init(&meson->lock);
 	chip->ops = &meson_pwm_ops;
 
-	meson->data = of_device_get_match_data(&pdev->dev);
+	meson->data = pdata;
 
 	err = meson->data->channels_init(chip);
 	if (err < 0)

-- 
2.52.0


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

* [PATCH v6 3/3] pwm: meson: Add support for Amlogic S7
  2026-12-01  3:34 ` Xianwei Zhao via B4 Relay
  (?)
@ 2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
  -1 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao via B4 Relay @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Alexandre Mergnat

From: Xianwei Zhao <xianwei.zhao@amlogic.com>

Add support for Amlogic S7 PWM. Amlogic S7 different from the previous
SoCs, a controller includes one pwm, at the same time, the controller has
only one input clock source.

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
 drivers/pwm/pwm-meson.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index a4b5f3877607..c4515f494f34 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -653,6 +653,13 @@ static const struct meson_pwm_data pwm_s4_data = {
 	.npwm = 2,
 };
 
+static const struct meson_pwm_data pwm_s7_data = {
+	.channels_init = meson_pwm_init_channels_per_channel_clk,
+	.has_constant = true,
+	.has_polarity = true,
+	.npwm = 1,
+};
+
 static const struct of_device_id meson_pwm_matches[] = {
 	{
 		.compatible = "amlogic,meson8-pwm-v2",
@@ -663,6 +670,9 @@ static const struct of_device_id meson_pwm_matches[] = {
 	}, {
 		.compatible = "amlogic,meson-g12-pwm-v2",
 		.data = &pwm_meson_axg_v2_data
+	}, {
+		.compatible = "amlogic,s7-pwm",
+		.data = &pwm_s7_data
 	},
 
 	/* The following compatibles are obsolete */

-- 
2.52.0



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

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

* [PATCH v6 3/3] pwm: meson: Add support for Amlogic S7
@ 2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
  0 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao via B4 Relay @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Alexandre Mergnat

From: Xianwei Zhao <xianwei.zhao@amlogic.com>

Add support for Amlogic S7 PWM. Amlogic S7 different from the previous
SoCs, a controller includes one pwm, at the same time, the controller has
only one input clock source.

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
 drivers/pwm/pwm-meson.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index a4b5f3877607..c4515f494f34 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -653,6 +653,13 @@ static const struct meson_pwm_data pwm_s4_data = {
 	.npwm = 2,
 };
 
+static const struct meson_pwm_data pwm_s7_data = {
+	.channels_init = meson_pwm_init_channels_per_channel_clk,
+	.has_constant = true,
+	.has_polarity = true,
+	.npwm = 1,
+};
+
 static const struct of_device_id meson_pwm_matches[] = {
 	{
 		.compatible = "amlogic,meson8-pwm-v2",
@@ -663,6 +670,9 @@ static const struct of_device_id meson_pwm_matches[] = {
 	}, {
 		.compatible = "amlogic,meson-g12-pwm-v2",
 		.data = &pwm_meson_axg_v2_data
+	}, {
+		.compatible = "amlogic,s7-pwm",
+		.data = &pwm_s7_data
 	},
 
 	/* The following compatibles are obsolete */

-- 
2.52.0



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

* [PATCH v6 3/3] pwm: meson: Add support for Amlogic S7
@ 2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
  0 siblings, 0 replies; 14+ messages in thread
From: Xianwei Zhao @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Heiner Kallweit, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl
  Cc: linux-pwm, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, Xianwei Zhao, Alexandre Mergnat

Add support for Amlogic S7 PWM. Amlogic S7 different from the previous
SoCs, a controller includes one pwm, at the same time, the controller has
only one input clock source.

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
 drivers/pwm/pwm-meson.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index a4b5f3877607..c4515f494f34 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -653,6 +653,13 @@ static const struct meson_pwm_data pwm_s4_data = {
 	.npwm = 2,
 };
 
+static const struct meson_pwm_data pwm_s7_data = {
+	.channels_init = meson_pwm_init_channels_per_channel_clk,
+	.has_constant = true,
+	.has_polarity = true,
+	.npwm = 1,
+};
+
 static const struct of_device_id meson_pwm_matches[] = {
 	{
 		.compatible = "amlogic,meson8-pwm-v2",
@@ -663,6 +670,9 @@ static const struct of_device_id meson_pwm_matches[] = {
 	}, {
 		.compatible = "amlogic,meson-g12-pwm-v2",
 		.data = &pwm_meson_axg_v2_data
+	}, {
+		.compatible = "amlogic,s7-pwm",
+		.data = &pwm_s7_data
 	},
 
 	/* The following compatibles are obsolete */

-- 
2.52.0


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

* Re: [PATCH v6 2/3] pwm: meson: add the PWM count driver data
  2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
@ 2026-12-01  3:38     ` sashiko-bot
  -1 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-01  3:38 UTC (permalink / raw)
  To: Xianwei Zhao; +Cc: devicetree, linux-amlogic, robh, conor+dt, neil.armstrong

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] pwm: meson: MESON_NUM_PWMS retained and literal 2 used in
  meson_pwm_probe()
--

commit 6ed68747213a295ffa942a4e360553ca50e1dfff
Author: Xianwei Zhao <xianwei.zhao@amlogic.com>

pwm: meson: add the PWM count driver data

This commit adds an npwm field to struct meson_pwm_data, sets it to 2 for
existing variants, and replaces MESON_NUM_PWMS with chip->npwm and
pdata->npwm in clock initialization and probe.

> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
> index 3a28c853089f8..a4b5f38776070 100644
> --- a/drivers/pwm/pwm-meson.c
> +++ b/drivers/pwm/pwm-meson.c

[ ... ]

> @@ -699,9 +710,12 @@ static int meson_pwm_probe(struct platform_device *pdev)
>  {
>  	struct pwm_chip *chip;
>  	struct meson_pwm *meson;
> +	const struct meson_pwm_data *pdata = of_device_get_match_data(&pdev->dev);
>  	int err;
>  
> -	chip = devm_pwmchip_alloc(&pdev->dev, MESON_NUM_PWMS, sizeof(*meson));
> +	if (pdata->npwm > 2)
> +		return -EINVAL;
> +	chip = devm_pwmchip_alloc(&pdev->dev, pdata->npwm, sizeof(*meson));

[Severity: Low]
As reported by Uwe Kleine-König on v4 [1], can MESON_NUM_PWMS be dropped
in this commit?  It is still defined to size
meson_pwm_per_channel_data[] and meson->channels[], while
meson_pwm_probe() checks pdata->npwm > 2 using a literal 2 instead of
sizing meson_pwm_per_channel_data[] and meson->channels[] without the
macro and bounding against ARRAY_SIZE().

[1] https://lore.kernel.org/r/aw01OAIy4gGjXvDI@monoceros

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-s6-s7-pwm-v6-0-703cc13d4da5@amlogic.com?part=2

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

* Re: [PATCH v6 2/3] pwm: meson: add the PWM count driver data
@ 2026-12-01  3:38     ` sashiko-bot
  0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-01  3:38 UTC (permalink / raw)
  To: Xianwei Zhao; +Cc: devicetree, linux-amlogic, robh, conor+dt, neil.armstrong

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] pwm: meson: MESON_NUM_PWMS retained and literal 2 used in
  meson_pwm_probe()
--

commit 6ed68747213a295ffa942a4e360553ca50e1dfff
Author: Xianwei Zhao <xianwei.zhao@amlogic.com>

pwm: meson: add the PWM count driver data

This commit adds an npwm field to struct meson_pwm_data, sets it to 2 for
existing variants, and replaces MESON_NUM_PWMS with chip->npwm and
pdata->npwm in clock initialization and probe.

> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
> index 3a28c853089f8..a4b5f38776070 100644
> --- a/drivers/pwm/pwm-meson.c
> +++ b/drivers/pwm/pwm-meson.c

[ ... ]

> @@ -699,9 +710,12 @@ static int meson_pwm_probe(struct platform_device *pdev)
>  {
>  	struct pwm_chip *chip;
>  	struct meson_pwm *meson;
> +	const struct meson_pwm_data *pdata = of_device_get_match_data(&pdev->dev);
>  	int err;
>  
> -	chip = devm_pwmchip_alloc(&pdev->dev, MESON_NUM_PWMS, sizeof(*meson));
> +	if (pdata->npwm > 2)
> +		return -EINVAL;
> +	chip = devm_pwmchip_alloc(&pdev->dev, pdata->npwm, sizeof(*meson));

[Severity: Low]
As reported by Uwe Kleine-König on v4 [1], can MESON_NUM_PWMS be dropped
in this commit?  It is still defined to size
meson_pwm_per_channel_data[] and meson->channels[], while
meson_pwm_probe() checks pdata->npwm > 2 using a literal 2 instead of
sizing meson_pwm_per_channel_data[] and meson->channels[] without the
macro and bounding against ARRAY_SIZE().

[1] https://lore.kernel.org/r/aw01OAIy4gGjXvDI@monoceros

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-s6-s7-pwm-v6-0-703cc13d4da5@amlogic.com?part=2

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

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

end of thread, other threads:[~2026-12-01  3:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  3:34 [PATCH v6 0/3] Add PWM support Amlogic S7 S7D S6 Xianwei Zhao via B4 Relay
2026-12-01  3:34 ` Xianwei Zhao
2026-12-01  3:34 ` Xianwei Zhao via B4 Relay
2026-12-01  3:34 ` [PATCH v6 1/3] dt-bindings: pwm: amlogic: Add S6, S7 and S7D PWM Xianwei Zhao via B4 Relay
2026-12-01  3:34   ` Xianwei Zhao
2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
2026-12-01  3:34 ` [PATCH v6 2/3] pwm: meson: add the PWM count driver data Xianwei Zhao via B4 Relay
2026-12-01  3:34   ` Xianwei Zhao
2026-12-01  3:34   ` Xianwei Zhao via B4 Relay
2026-12-01  3:38   ` sashiko-bot
2026-12-01  3:38     ` sashiko-bot
2026-12-01  3:34 ` [PATCH v6 3/3] pwm: meson: Add support for Amlogic S7 Xianwei Zhao via B4 Relay
2026-12-01  3:34   ` Xianwei Zhao
2026-12-01  3:34   ` Xianwei Zhao via B4 Relay

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.