* [PATCH v2 1/6] dt-bindings: pwm: renesas,tpu-pwm: Add support for R-Car X5H
2026-11-26 14:30 [PATCH v2 0/6] pwm: renesas: Add R-Car X5H support Geert Uytterhoeven
@ 2026-11-26 14:30 ` Geert Uytterhoeven
2026-11-26 14:30 ` [PATCH v2 2/6] dt-bindings: pwm: renesas,pwm-rcar: " Geert Uytterhoeven
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2026-11-26 14:30 UTC (permalink / raw)
To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Yoshihiro Shimoda, Laurent Pinchart, Wolfram Sang,
Magnus Damm
Cc: linux-pwm, devicetree, linux-renesas-soc, Khanh Le,
Geert Uytterhoeven, Krzysztof Kozlowski
From: Khanh Le <khanh.le.xr@renesas.com>
Document support for the 16-Bit Timer Pulse Unit (TPU) in the Renesas
R-Car X5H (R8A78000) SoC.
Signed-off-by: Khanh Le <khanh.le.xr@renesas.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
v2:
- Add Acked-by.
---
Documentation/devicetree/bindings/pwm/renesas,tpu-pwm.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/pwm/renesas,tpu-pwm.yaml b/Documentation/devicetree/bindings/pwm/renesas,tpu-pwm.yaml
index f85ee5d20ccbb3f9..144a88ff53e5633b 100644
--- a/Documentation/devicetree/bindings/pwm/renesas,tpu-pwm.yaml
+++ b/Documentation/devicetree/bindings/pwm/renesas,tpu-pwm.yaml
@@ -33,6 +33,7 @@ properties:
- renesas,tpu-r8a779a0 # R-Car V3U
- renesas,tpu-r8a779g0 # R-Car V4H
- renesas,tpu-r8a779h0 # R-Car V4M
+ - renesas,tpu-r8a78000 # R-Car X5H
- const: renesas,tpu
reg:
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 2/6] dt-bindings: pwm: renesas,pwm-rcar: Add support for R-Car X5H
2026-11-26 14:30 [PATCH v2 0/6] pwm: renesas: Add R-Car X5H support Geert Uytterhoeven
2026-11-26 14:30 ` [PATCH v2 1/6] dt-bindings: pwm: renesas,tpu-pwm: Add support for R-Car X5H Geert Uytterhoeven
@ 2026-11-26 14:30 ` Geert Uytterhoeven
2026-11-26 14:30 ` [PATCH v2 3/6] pwm: rcar: Use FIELD_PREP() for PWMCR_CC0 access Geert Uytterhoeven
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2026-11-26 14:30 UTC (permalink / raw)
To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Yoshihiro Shimoda, Laurent Pinchart, Wolfram Sang,
Magnus Damm
Cc: linux-pwm, devicetree, linux-renesas-soc, Geert Uytterhoeven,
Krzysztof Kozlowski
From: Geert Uytterhoeven <geert+renesas@glider.be>
Document support for the Pulse Width Modulation (PWM) module in the
Renesas R-Car X5H (R8A78000) SoC.
R-Car Gen5 enlarged the PWM output cycle and high-level period fields
from 10 to 24 bits. While the added register bits have initial states
of all-zeroes, and thus look compatible with previous generations, the
register bits may have been modified before Linux boots. Hence no
fallback to renesas,pwm-rcar is included.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
v2:
- Add Reviewed-by.
---
.../bindings/pwm/renesas,pwm-rcar.yaml | 61 ++++++++++---------
1 file changed, 33 insertions(+), 28 deletions(-)
diff --git a/Documentation/devicetree/bindings/pwm/renesas,pwm-rcar.yaml b/Documentation/devicetree/bindings/pwm/renesas,pwm-rcar.yaml
index 2fe1992e29088c9a..424ca1e2df15354c 100644
--- a/Documentation/devicetree/bindings/pwm/renesas,pwm-rcar.yaml
+++ b/Documentation/devicetree/bindings/pwm/renesas,pwm-rcar.yaml
@@ -11,34 +11,39 @@ maintainers:
properties:
compatible:
- items:
- - enum:
- - renesas,pwm-r8a7742 # RZ/G1H
- - renesas,pwm-r8a7743 # RZ/G1M
- - renesas,pwm-r8a7744 # RZ/G1N
- - renesas,pwm-r8a7745 # RZ/G1E
- - renesas,pwm-r8a77470 # RZ/G1C
- - renesas,pwm-r8a774a1 # RZ/G2M
- - renesas,pwm-r8a774b1 # RZ/G2N
- - renesas,pwm-r8a774c0 # RZ/G2E
- - renesas,pwm-r8a774e1 # RZ/G2H
- - renesas,pwm-r8a7778 # R-Car M1A
- - renesas,pwm-r8a7779 # R-Car H1
- - renesas,pwm-r8a7790 # R-Car H2
- - renesas,pwm-r8a7791 # R-Car M2-W
- - renesas,pwm-r8a7794 # R-Car E2
- - renesas,pwm-r8a7795 # R-Car H3
- - renesas,pwm-r8a7796 # R-Car M3-W
- - renesas,pwm-r8a77961 # R-Car M3-W+
- - renesas,pwm-r8a77965 # R-Car M3-N
- - renesas,pwm-r8a77970 # R-Car V3M
- - renesas,pwm-r8a77980 # R-Car V3H
- - renesas,pwm-r8a77990 # R-Car E3
- - renesas,pwm-r8a77995 # R-Car D3
- - renesas,pwm-r8a779a0 # R-Car V3U
- - renesas,pwm-r8a779g0 # R-Car V4H
- - renesas,pwm-r8a779h0 # R-Car V4M
- - const: renesas,pwm-rcar
+ oneOf:
+ - items:
+ - enum:
+ - renesas,pwm-r8a7742 # RZ/G1H
+ - renesas,pwm-r8a7743 # RZ/G1M
+ - renesas,pwm-r8a7744 # RZ/G1N
+ - renesas,pwm-r8a7745 # RZ/G1E
+ - renesas,pwm-r8a77470 # RZ/G1C
+ - renesas,pwm-r8a774a1 # RZ/G2M
+ - renesas,pwm-r8a774b1 # RZ/G2N
+ - renesas,pwm-r8a774c0 # RZ/G2E
+ - renesas,pwm-r8a774e1 # RZ/G2H
+ - renesas,pwm-r8a7778 # R-Car M1A
+ - renesas,pwm-r8a7779 # R-Car H1
+ - renesas,pwm-r8a7790 # R-Car H2
+ - renesas,pwm-r8a7791 # R-Car M2-W
+ - renesas,pwm-r8a7794 # R-Car E2
+ - renesas,pwm-r8a7795 # R-Car H3
+ - renesas,pwm-r8a7796 # R-Car M3-W
+ - renesas,pwm-r8a77961 # R-Car M3-W+
+ - renesas,pwm-r8a77965 # R-Car M3-N
+ - renesas,pwm-r8a77970 # R-Car V3M
+ - renesas,pwm-r8a77980 # R-Car V3H
+ - renesas,pwm-r8a77990 # R-Car E3
+ - renesas,pwm-r8a77995 # R-Car D3
+ - renesas,pwm-r8a779a0 # R-Car V3U
+ - renesas,pwm-r8a779g0 # R-Car V4H
+ - renesas,pwm-r8a779h0 # R-Car V4M
+ - const: renesas,pwm-rcar
+ - items:
+ - enum:
+ - renesas,pwm-r8a78000 # R-Car X5H
+ - const: renesas,rcar-gen5-pwm
reg:
# base address and length of the registers block for the PWM.
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 3/6] pwm: rcar: Use FIELD_PREP() for PWMCR_CC0 access
2026-11-26 14:30 [PATCH v2 0/6] pwm: renesas: Add R-Car X5H support Geert Uytterhoeven
2026-11-26 14:30 ` [PATCH v2 1/6] dt-bindings: pwm: renesas,tpu-pwm: Add support for R-Car X5H Geert Uytterhoeven
2026-11-26 14:30 ` [PATCH v2 2/6] dt-bindings: pwm: renesas,pwm-rcar: " Geert Uytterhoeven
@ 2026-11-26 14:30 ` Geert Uytterhoeven
2026-11-26 14:30 ` [PATCH v2 4/6] pwm: rcar: Add helper variable dev to rcar_pwm_probe() Geert Uytterhoeven
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2026-11-26 14:30 UTC (permalink / raw)
To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Yoshihiro Shimoda, Laurent Pinchart, Wolfram Sang,
Magnus Damm
Cc: linux-pwm, devicetree, linux-renesas-soc, Geert Uytterhoeven
From: Geert Uytterhoeven <geert+renesas@glider.be>
Use the FIELD_PREP() helper instead of open-coding the same operation.
Drop the now unused RCAR_PWMCR_CC0_SHIFT definition, and redefine
RCAR_PWMCR_CC0_SHIFT using GENMASK() while at it.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
- No changes.
---
drivers/pwm/pwm-rcar.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/pwm/pwm-rcar.c b/drivers/pwm/pwm-rcar.c
index 1733cd700693713e..4641f258df531baf 100644
--- a/drivers/pwm/pwm-rcar.c
+++ b/drivers/pwm/pwm-rcar.c
@@ -25,8 +25,7 @@
#define RCAR_PWM_MAX_CYCLE 1023
#define RCAR_PWMCR 0x00
-#define RCAR_PWMCR_CC0_MASK 0x000f0000
-#define RCAR_PWMCR_CC0_SHIFT 16
+#define RCAR_PWMCR_CC0_MASK GENMASK(19, 16)
#define RCAR_PWMCR_CCMD BIT(15)
#define RCAR_PWMCR_SYNC BIT(11)
#define RCAR_PWMCR_SS0 BIT(4)
@@ -99,7 +98,7 @@ static void rcar_pwm_set_clock_control(struct rcar_pwm_chip *rp,
div >>= 1;
- value |= div << RCAR_PWMCR_CC0_SHIFT;
+ value |= FIELD_PREP(RCAR_PWMCR_CC0_MASK, div);
rcar_pwm_write(rp, value, RCAR_PWMCR);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 4/6] pwm: rcar: Add helper variable dev to rcar_pwm_probe()
2026-11-26 14:30 [PATCH v2 0/6] pwm: renesas: Add R-Car X5H support Geert Uytterhoeven
` (2 preceding siblings ...)
2026-11-26 14:30 ` [PATCH v2 3/6] pwm: rcar: Use FIELD_PREP() for PWMCR_CC0 access Geert Uytterhoeven
@ 2026-11-26 14:30 ` Geert Uytterhoeven
2026-11-26 14:30 ` [PATCH v2 5/6] pwm: rcar: Parametrize cycle counter field size Geert Uytterhoeven
2026-11-26 14:30 ` [PATCH v2 6/6] pwm: rcar: Add support for R-Car Gen5 Geert Uytterhoeven
5 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2026-11-26 14:30 UTC (permalink / raw)
To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Yoshihiro Shimoda, Laurent Pinchart, Wolfram Sang,
Magnus Damm
Cc: linux-pwm, devicetree, linux-renesas-soc, Geert Uytterhoeven
From: Geert Uytterhoeven <geert+renesas@glider.be>
rcar_pwm_probe() has many users of "&pdev->dev".
Introduce a shorthand to simplify the code.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
- No changes.
---
drivers/pwm/pwm-rcar.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/pwm/pwm-rcar.c b/drivers/pwm/pwm-rcar.c
index 4641f258df531baf..f1f68bfe016f729f 100644
--- a/drivers/pwm/pwm-rcar.c
+++ b/drivers/pwm/pwm-rcar.c
@@ -202,11 +202,12 @@ static const struct pwm_ops rcar_pwm_ops = {
static int rcar_pwm_probe(struct platform_device *pdev)
{
- struct pwm_chip *chip;
+ struct device *dev = &pdev->dev;
struct rcar_pwm_chip *rcar_pwm;
+ struct pwm_chip *chip;
int ret;
- chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*rcar_pwm));
+ chip = devm_pwmchip_alloc(dev, 1, sizeof(*rcar_pwm));
if (IS_ERR(chip))
return PTR_ERR(chip);
rcar_pwm = to_rcar_pwm_chip(chip);
@@ -215,9 +216,9 @@ static int rcar_pwm_probe(struct platform_device *pdev)
if (IS_ERR(rcar_pwm->base))
return PTR_ERR(rcar_pwm->base);
- rcar_pwm->clk = devm_clk_get(&pdev->dev, NULL);
+ rcar_pwm->clk = devm_clk_get(dev, NULL);
if (IS_ERR(rcar_pwm->clk)) {
- dev_err(&pdev->dev, "cannot get clock\n");
+ dev_err(dev, "cannot get clock\n");
return PTR_ERR(rcar_pwm->clk);
}
@@ -225,12 +226,12 @@ static int rcar_pwm_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, chip);
- pm_runtime_enable(&pdev->dev);
+ pm_runtime_enable(dev);
ret = pwmchip_add(chip);
if (ret < 0) {
- dev_err(&pdev->dev, "failed to register PWM chip: %d\n", ret);
- pm_runtime_disable(&pdev->dev);
+ dev_err(dev, "failed to register PWM chip: %d\n", ret);
+ pm_runtime_disable(dev);
return ret;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 5/6] pwm: rcar: Parametrize cycle counter field size
2026-11-26 14:30 [PATCH v2 0/6] pwm: renesas: Add R-Car X5H support Geert Uytterhoeven
` (3 preceding siblings ...)
2026-11-26 14:30 ` [PATCH v2 4/6] pwm: rcar: Add helper variable dev to rcar_pwm_probe() Geert Uytterhoeven
@ 2026-11-26 14:30 ` Geert Uytterhoeven
2026-11-26 14:30 ` [PATCH v2 6/6] pwm: rcar: Add support for R-Car Gen5 Geert Uytterhoeven
5 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2026-11-26 14:30 UTC (permalink / raw)
To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Yoshihiro Shimoda, Laurent Pinchart, Wolfram Sang,
Magnus Damm
Cc: linux-pwm, devicetree, linux-renesas-soc, Geert Uytterhoeven
From: Geert Uytterhoeven <geert+renesas@glider.be>
Prepare for the advent of PWM blocks with output cycle and high-level
period fields larger than 10 bits by parametrizing the field size.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
- No changes.
---
drivers/pwm/pwm-rcar.c | 51 +++++++++++++++++++++++++++---------------
1 file changed, 33 insertions(+), 18 deletions(-)
diff --git a/drivers/pwm/pwm-rcar.c b/drivers/pwm/pwm-rcar.c
index f1f68bfe016f729f..3813094c601efc8c 100644
--- a/drivers/pwm/pwm-rcar.c
+++ b/drivers/pwm/pwm-rcar.c
@@ -22,7 +22,7 @@
#include <linux/slab.h>
#define RCAR_PWM_MAX_DIVISION 24
-#define RCAR_PWM_MAX_CYCLE 1023
+#define RCAR_PWM_MAX_CYCLE(rp) GENMASK(rp->cycle_bits - 1, 0)
#define RCAR_PWMCR 0x00
#define RCAR_PWMCR_CC0_MASK GENMASK(19, 16)
@@ -32,14 +32,17 @@
#define RCAR_PWMCR_EN0 BIT(0)
#define RCAR_PWMCNT 0x04
-#define RCAR_PWMCNT_CYC0_MASK 0x03ff0000
-#define RCAR_PWMCNT_CYC0_SHIFT 16
-#define RCAR_PWMCNT_PH0_MASK 0x000003ff
-#define RCAR_PWMCNT_PH0_SHIFT 0
+#define RCAR_PWMCNT_CYC0_MASK GENMASK(31, 16)
+#define RCAR_PWMCNT_PH0_MASK GENMASK(15, 0)
struct rcar_pwm_chip {
void __iomem *base;
struct clk *clk;
+ unsigned int cycle_bits;
+};
+
+struct rcar_pwm_info {
+ unsigned int cycle_bits;
};
static inline struct rcar_pwm_chip *to_rcar_pwm_chip(struct pwm_chip *chip)
@@ -77,7 +80,7 @@ static int rcar_pwm_get_clock_division(struct rcar_pwm_chip *rp, int period_ns)
if (clk_rate == 0)
return -EINVAL;
- div = (u64)NSEC_PER_SEC * RCAR_PWM_MAX_CYCLE;
+ div = mul_u32_u32(NSEC_PER_SEC, RCAR_PWM_MAX_CYCLE(rp));
tmp = (u64)period_ns * clk_rate + div - 1;
tmp = div64_u64(tmp, div);
div = ilog2(tmp - 1) + 1;
@@ -111,21 +114,19 @@ static int rcar_pwm_set_counter(struct rcar_pwm_chip *rp, int div, u64 duty_ns,
/* div <= 24 == RCAR_PWM_MAX_DIVISION, so the shift doesn't overflow. */
tmp = mul_u64_u64_div_u64(period_ns, clk_rate, (u64)NSEC_PER_SEC << div);
- if (tmp > FIELD_MAX(RCAR_PWMCNT_CYC0_MASK))
- tmp = FIELD_MAX(RCAR_PWMCNT_CYC0_MASK);
-
- cyc = FIELD_PREP(RCAR_PWMCNT_CYC0_MASK, tmp);
+ cyc = min(tmp, RCAR_PWM_MAX_CYCLE(rp));
tmp = mul_u64_u64_div_u64(duty_ns, clk_rate, (u64)NSEC_PER_SEC << div);
- if (tmp > FIELD_MAX(RCAR_PWMCNT_PH0_MASK))
- tmp = FIELD_MAX(RCAR_PWMCNT_PH0_MASK);
- ph = FIELD_PREP(RCAR_PWMCNT_PH0_MASK, tmp);
+ ph = min(tmp, RCAR_PWM_MAX_CYCLE(rp));
/* Avoid prohibited setting */
if (cyc == 0 || ph == 0)
return -EINVAL;
- rcar_pwm_write(rp, cyc | ph, RCAR_PWMCNT);
+ rcar_pwm_write(rp,
+ FIELD_PREP(RCAR_PWMCNT_CYC0_MASK, cyc) |
+ FIELD_PREP(RCAR_PWMCNT_PH0_MASK, ph),
+ RCAR_PWMCNT);
return 0;
}
@@ -142,12 +143,15 @@ static void rcar_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
static int rcar_pwm_enable(struct rcar_pwm_chip *rp)
{
- u32 value;
+ u32 value, cyc, ph;
/* Don't enable the PWM device if CYC0 or PH0 is 0 */
value = rcar_pwm_read(rp, RCAR_PWMCNT);
- if ((value & RCAR_PWMCNT_CYC0_MASK) == 0 ||
- (value & RCAR_PWMCNT_PH0_MASK) == 0)
+ cyc = FIELD_GET(RCAR_PWMCNT_CYC0_MASK, value);
+ ph = FIELD_GET(RCAR_PWMCNT_PH0_MASK, value);
+
+ if ((cyc & RCAR_PWM_MAX_CYCLE(rp)) == 0 ||
+ (ph & RCAR_PWM_MAX_CYCLE(rp)) == 0)
return -EINVAL;
rcar_pwm_update(rp, RCAR_PWMCR_EN0, RCAR_PWMCR_EN0, RCAR_PWMCR);
@@ -202,11 +206,16 @@ static const struct pwm_ops rcar_pwm_ops = {
static int rcar_pwm_probe(struct platform_device *pdev)
{
+ const struct rcar_pwm_info *info;
struct device *dev = &pdev->dev;
struct rcar_pwm_chip *rcar_pwm;
struct pwm_chip *chip;
int ret;
+ info = of_device_get_match_data(dev);
+ if (!info)
+ return -ENODEV;
+
chip = devm_pwmchip_alloc(dev, 1, sizeof(*rcar_pwm));
if (IS_ERR(chip))
return PTR_ERR(chip);
@@ -222,6 +231,8 @@ static int rcar_pwm_probe(struct platform_device *pdev)
return PTR_ERR(rcar_pwm->clk);
}
+ rcar_pwm->cycle_bits = info->cycle_bits;
+
chip->ops = &rcar_pwm_ops;
platform_set_drvdata(pdev, chip);
@@ -247,8 +258,12 @@ static void rcar_pwm_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
}
+static const struct rcar_pwm_info rcar_pwm_info = {
+ .cycle_bits = 10,
+};
+
static const struct of_device_id rcar_pwm_of_table[] = {
- { .compatible = "renesas,pwm-rcar" },
+ { .compatible = "renesas,pwm-rcar", .data = &rcar_pwm_info },
{ }
};
MODULE_DEVICE_TABLE(of, rcar_pwm_of_table);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 6/6] pwm: rcar: Add support for R-Car Gen5
2026-11-26 14:30 [PATCH v2 0/6] pwm: renesas: Add R-Car X5H support Geert Uytterhoeven
` (4 preceding siblings ...)
2026-11-26 14:30 ` [PATCH v2 5/6] pwm: rcar: Parametrize cycle counter field size Geert Uytterhoeven
@ 2026-11-26 14:30 ` Geert Uytterhoeven
5 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2026-11-26 14:30 UTC (permalink / raw)
To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Yoshihiro Shimoda, Laurent Pinchart, Wolfram Sang,
Magnus Damm
Cc: linux-pwm, devicetree, linux-renesas-soc, Geert Uytterhoeven
From: Geert Uytterhoeven <geert+renesas@glider.be>
R-Car Gen5 enlarged the PWM output cycle and high-level period fields
from 10 to 24 bits. As the existing register bitfields can accommodate
only 16 bits, the high parts of each field are stored in a new register.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
- Improve patch description.
---
drivers/pwm/pwm-rcar.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/drivers/pwm/pwm-rcar.c b/drivers/pwm/pwm-rcar.c
index 3813094c601efc8c..5e91509de7a7c162 100644
--- a/drivers/pwm/pwm-rcar.c
+++ b/drivers/pwm/pwm-rcar.c
@@ -31,7 +31,8 @@
#define RCAR_PWMCR_SS0 BIT(4)
#define RCAR_PWMCR_EN0 BIT(0)
-#define RCAR_PWMCNT 0x04
+#define RCAR_PWMCNTA 0x04 /* Low part */
+#define RCAR_PWMCNTB 0x08 /* High part (R-Car Gen5) */
#define RCAR_PWMCNT_CYC0_MASK GENMASK(31, 16)
#define RCAR_PWMCNT_PH0_MASK GENMASK(15, 0)
@@ -124,9 +125,15 @@ static int rcar_pwm_set_counter(struct rcar_pwm_chip *rp, int div, u64 duty_ns,
return -EINVAL;
rcar_pwm_write(rp,
- FIELD_PREP(RCAR_PWMCNT_CYC0_MASK, cyc) |
- FIELD_PREP(RCAR_PWMCNT_PH0_MASK, ph),
- RCAR_PWMCNT);
+ FIELD_PREP(RCAR_PWMCNT_CYC0_MASK, lower_16_bits(cyc)) |
+ FIELD_PREP(RCAR_PWMCNT_PH0_MASK, lower_16_bits(ph)),
+ RCAR_PWMCNTA);
+
+ if (rp->cycle_bits >= 16)
+ rcar_pwm_write(rp,
+ FIELD_PREP(RCAR_PWMCNT_CYC0_MASK, upper_16_bits(cyc)) |
+ FIELD_PREP(RCAR_PWMCNT_PH0_MASK, upper_16_bits(ph)),
+ RCAR_PWMCNTB);
return 0;
}
@@ -146,9 +153,14 @@ static int rcar_pwm_enable(struct rcar_pwm_chip *rp)
u32 value, cyc, ph;
/* Don't enable the PWM device if CYC0 or PH0 is 0 */
- value = rcar_pwm_read(rp, RCAR_PWMCNT);
+ value = rcar_pwm_read(rp, RCAR_PWMCNTA);
cyc = FIELD_GET(RCAR_PWMCNT_CYC0_MASK, value);
ph = FIELD_GET(RCAR_PWMCNT_PH0_MASK, value);
+ if (rp->cycle_bits >= 16) {
+ value = rcar_pwm_read(rp, RCAR_PWMCNTB);
+ cyc |= FIELD_GET(RCAR_PWMCNT_CYC0_MASK, value) << 16;
+ ph |= FIELD_GET(RCAR_PWMCNT_PH0_MASK, value) << 16;
+ }
if ((cyc & RCAR_PWM_MAX_CYCLE(rp)) == 0 ||
(ph & RCAR_PWM_MAX_CYCLE(rp)) == 0)
@@ -262,8 +274,13 @@ static const struct rcar_pwm_info rcar_pwm_info = {
.cycle_bits = 10,
};
+static const struct rcar_pwm_info rcar_gen5_pwm_info = {
+ .cycle_bits = 24,
+};
+
static const struct of_device_id rcar_pwm_of_table[] = {
{ .compatible = "renesas,pwm-rcar", .data = &rcar_pwm_info },
+ { .compatible = "renesas,rcar-gen5-pwm", .data = &rcar_gen5_pwm_info },
{ }
};
MODULE_DEVICE_TABLE(of, rcar_pwm_of_table);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread