Devicetree
 help / color / mirror / Atom feed
* [v6 0/3] Change PWM-controlled LED pin active mode and algorithm
@ 2024-01-16  4:10 Nylon Chen
  2024-01-16  4:10 ` [v6 1/3] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties Nylon Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Nylon Chen @ 2024-01-16  4:10 UTC (permalink / raw)
  To: paul.walmsley, palmer, conor+dt, krzysztof.kozlowski+dt, robh+dt,
	u.kleine-koenig, thierry.reding, aou
  Cc: zong.li, vincent.chen, linux-pwm, linux-kernel, linux-riscv,
	devicetree, nylon7717, Nylon Chen

According to the circuit diagram of User LEDs - RGB described in the
manual hifive-unleashed-a00.pdf[0] and hifive-unmatched-schematics-v3.pdf[1].

The behavior of PWM is acitve-high.

According to the descriptionof PWM for pwmcmp in SiFive FU740-C000 Manual[2].

The pwm algorithm is (PW) pulse active time  = (D) duty * (T) period.
The `frac` variable is pulse "inactive" time so we need to invert it.

So this patchset removes active-low in DTS and adds reverse logic to the driver.

Updated patches: 1
New patches: 1
Unchanged patches: 1

Links:
- [0]: https://sifive.cdn.prismic.io/sifive/c52a8e32-05ce-4aaf-95c8-7bf8453f8698_hifive-unleashed-a00-schematics-1.pdf
- [1]: https://sifive.cdn.prismic.io/sifive/6a06d6c0-6e66-49b5-8e9e-e68ce76f4192_hifive-unmatched-schematics-v3.pdf
- [2]: https://sifive.cdn.prismic.io/sifive/1a82e600-1f93-4f41-b2d8-86ed8b16acba_fu740-c000-manual-v1p6.pdf

Changed in v6:
 - Separate the idempotent test bug fixes into a new patch.
 - Move the reversing the duty before the line checking
   state->enabled.
 - Fix the algorithm and change it to take the minimum value first and
   then reverse it.

Changed in v5:
 - Add the updates to the PWM algorithm based on version 2 back in.
 - Replace div64_ul with DIV_ROUND_UP_ULL to correct the error in the
   period value of the idempotent test in pwm_apply_state_debug.

Changed in v4:
 - Remove previous updates to the PWM algorithm.

Changed in v3:
 - Convert the reference link to standard link.
 - Move the inverted function before taking the minimum value.
 - Change polarity check condition(high and low).
 - Pick the biggest period length possible that is not bigger than the
   requested period.

Changed in v2:
 - Convert the reference link to standard link.
 - Fix typo: s/sifive unmatched:/sifive: unmatched:/.
 - Remove active-low from hifive-unleashed-a00.dts.
 - Include this reference link in the dts and pwm commit messages.


Nylon Chen (3):
  riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's
    active-low properties
  pwm: sifive: change the PWM controlled LED algorithm
  pwm: sifive: Fix the error in the idempotent test within the
    pwm_apply_state_debug function

 arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts |  8 ++++----
 arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 12 ++++--------
 drivers/pwm/pwm-sifive.c                            |  9 +++++----
 3 files changed, 13 insertions(+), 16 deletions(-)

-- 
2.42.0


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

* [v6 1/3] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties
  2024-01-16  4:10 [v6 0/3] Change PWM-controlled LED pin active mode and algorithm Nylon Chen
@ 2024-01-16  4:10 ` Nylon Chen
  2024-01-16 10:20   ` Emil Renner Berthing
  2024-01-16  4:10 ` [v6 2/3] pwm: sifive: change the PWM controlled LED algorithm Nylon Chen
  2024-01-16  4:10 ` [v6 3/3] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function Nylon Chen
  2 siblings, 1 reply; 7+ messages in thread
From: Nylon Chen @ 2024-01-16  4:10 UTC (permalink / raw)
  To: paul.walmsley, palmer, conor+dt, krzysztof.kozlowski+dt, robh+dt,
	u.kleine-koenig, thierry.reding, aou
  Cc: zong.li, vincent.chen, linux-pwm, linux-kernel, linux-riscv,
	devicetree, nylon7717, Nylon Chen, Conor Dooley

This removes the active-low properties of the PWM-controlled LEDs in
the HiFive Unmatched device tree.

The reference is hifive-unleashed-a00.pdf[0] and hifive-unmatched-schematics-v3.pdf[1].

Link: https://sifive.cdn.prismic.io/sifive/c52a8e32-05ce-4aaf-95c8-7bf8453f8698_hifive-unleashed-a00-schematics-1.pdf [0]
Link: https://sifive.cdn.prismic.io/sifive/6a06d6c0-6e66-49b5-8e9e-e68ce76f4192_hifive-unmatched-schematics-v3.pdf [1]

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Co-developed-by: Zong Li <zong.li@sifve.com>
Signed-off-by: Zong Li <zong.li@sifve.com>
Co-developed-by: Vincent Chen <vincent.chen@sifive.com>
Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
---
 arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts |  8 ++++----
 arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 12 ++++--------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
index 900a50526d77..11e7ac1c54bb 100644
--- a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
+++ b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
@@ -49,7 +49,7 @@ led-controller {
 		compatible = "pwm-leds";
 
 		led-d1 {
-			pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>;
+			pwms = <&pwm0 0 7812500 0>;
 			active-low;
 			color = <LED_COLOR_ID_GREEN>;
 			max-brightness = <255>;
@@ -57,7 +57,7 @@ led-d1 {
 		};
 
 		led-d2 {
-			pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>;
+			pwms = <&pwm0 1 7812500 0>;
 			active-low;
 			color = <LED_COLOR_ID_GREEN>;
 			max-brightness = <255>;
@@ -65,7 +65,7 @@ led-d2 {
 		};
 
 		led-d3 {
-			pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>;
+			pwms = <&pwm0 2 7812500 0>;
 			active-low;
 			color = <LED_COLOR_ID_GREEN>;
 			max-brightness = <255>;
@@ -73,7 +73,7 @@ led-d3 {
 		};
 
 		led-d4 {
-			pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>;
+			pwms = <&pwm0 3 7812500 0>;
 			active-low;
 			color = <LED_COLOR_ID_GREEN>;
 			max-brightness = <255>;
diff --git a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
index 07387f9c135c..b328ee80693f 100644
--- a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
+++ b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
@@ -51,8 +51,7 @@ led-controller-1 {
 		compatible = "pwm-leds";
 
 		led-d12 {
-			pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>;
-			active-low;
+			pwms = <&pwm0 0 7812500 0>;
 			color = <LED_COLOR_ID_GREEN>;
 			max-brightness = <255>;
 			label = "d12";
@@ -68,20 +67,17 @@ multi-led {
 			label = "d2";
 
 			led-red {
-				pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>;
-				active-low;
+				pwms = <&pwm0 2 7812500 0>;
 				color = <LED_COLOR_ID_RED>;
 			};
 
 			led-green {
-				pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>;
-				active-low;
+				pwms = <&pwm0 1 7812500 0>;
 				color = <LED_COLOR_ID_GREEN>;
 			};
 
 			led-blue {
-				pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>;
-				active-low;
+				pwms = <&pwm0 3 7812500 0>;
 				color = <LED_COLOR_ID_BLUE>;
 			};
 		};
-- 
2.42.0


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

* [v6 2/3] pwm: sifive: change the PWM controlled LED algorithm
  2024-01-16  4:10 [v6 0/3] Change PWM-controlled LED pin active mode and algorithm Nylon Chen
  2024-01-16  4:10 ` [v6 1/3] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties Nylon Chen
@ 2024-01-16  4:10 ` Nylon Chen
  2024-01-16  4:10 ` [v6 3/3] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function Nylon Chen
  2 siblings, 0 replies; 7+ messages in thread
From: Nylon Chen @ 2024-01-16  4:10 UTC (permalink / raw)
  To: paul.walmsley, palmer, conor+dt, krzysztof.kozlowski+dt, robh+dt,
	u.kleine-koenig, thierry.reding, aou
  Cc: zong.li, vincent.chen, linux-pwm, linux-kernel, linux-riscv,
	devicetree, nylon7717, Nylon Chen

The `frac` variable represents the pulse inactive time, and the result
of this algorithm is the pulse active time. Therefore, we must reverse the result.

The reference is SiFive FU740-C000 Manual[0]

Link: https://sifive.cdn.prismic.io/sifive/1a82e600-1f93-4f41-b2d8-86ed8b16acba_fu740-c000-manual-v1p6.pdf [0]

Co-developed-by: Zong Li <zong.li@sifve.com>
Signed-off-by: Zong Li <zong.li@sifve.com>
Co-developed-by: Vincent Chen <vincent.chen@sifive.com>
Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
---
 drivers/pwm/pwm-sifive.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
index eabddb7c7820..b07c8598bb21 100644
--- a/drivers/pwm/pwm-sifive.c
+++ b/drivers/pwm/pwm-sifive.c
@@ -113,6 +113,7 @@ static int pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 	u32 duty, val;
 
 	duty = readl(ddata->regs + PWM_SIFIVE_PWMCMP(pwm->hwpwm));
+	duty = (1U << PWM_SIFIVE_CMPWIDTH) - 1 - duty;
 
 	state->enabled = duty > 0;
 
@@ -123,11 +124,10 @@ static int pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 	state->period = ddata->real_period;
 	state->duty_cycle =
 		(u64)duty * ddata->real_period >> PWM_SIFIVE_CMPWIDTH;
-	state->polarity = PWM_POLARITY_INVERSED;
+	state->polarity = PWM_POLARITY_NORMAL;
 
 	return 0;
 }
-
 static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 			    const struct pwm_state *state)
 {
@@ -139,7 +139,7 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	int ret = 0;
 	u32 frac;
 
-	if (state->polarity != PWM_POLARITY_INVERSED)
+	if (state->polarity != PWM_POLARITY_NORMAL)
 		return -EINVAL;
 
 	cur_state = pwm->state;
@@ -159,6 +159,7 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	frac = DIV64_U64_ROUND_CLOSEST(num, state->period);
 	/* The hardware cannot generate a 100% duty cycle */
 	frac = min(frac, (1U << PWM_SIFIVE_CMPWIDTH) - 1);
+	frac = (1U << PWM_SIFIVE_CMPWIDTH) - 1 - frac;
 
 	mutex_lock(&ddata->lock);
 	if (state->period != ddata->approx_period) {
-- 
2.42.0


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

* [v6 3/3] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function
  2024-01-16  4:10 [v6 0/3] Change PWM-controlled LED pin active mode and algorithm Nylon Chen
  2024-01-16  4:10 ` [v6 1/3] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties Nylon Chen
  2024-01-16  4:10 ` [v6 2/3] pwm: sifive: change the PWM controlled LED algorithm Nylon Chen
@ 2024-01-16  4:10 ` Nylon Chen
  2 siblings, 0 replies; 7+ messages in thread
From: Nylon Chen @ 2024-01-16  4:10 UTC (permalink / raw)
  To: paul.walmsley, palmer, conor+dt, krzysztof.kozlowski+dt, robh+dt,
	u.kleine-koenig, thierry.reding, aou
  Cc: zong.li, vincent.chen, linux-pwm, linux-kernel, linux-riscv,
	devicetree, nylon7717, Nylon Chen

Round the result to the nearest whole number. This ensures that
real_period is always a reasonable integer that is not lower than the
actual value.

e.g.
$ echo 110 > /sys/devices/platform/led-controller-1/leds/d12/brightness
$ .apply is not idempotent (ena=1 pol=0 1739692/4032985) -> (ena=1 pol=0 1739630/4032985)

Co-developed-by: Zong Li <zong.li@sifve.com>
Signed-off-by: Zong Li <zong.li@sifve.com>
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
---
 drivers/pwm/pwm-sifive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
index b07c8598bb21..7cf7a76cdb44 100644
--- a/drivers/pwm/pwm-sifive.c
+++ b/drivers/pwm/pwm-sifive.c
@@ -101,7 +101,7 @@ static void pwm_sifive_update_clock(struct pwm_sifive_ddata *ddata,
 
 	/* As scale <= 15 the shift operation cannot overflow. */
 	num = (unsigned long long)NSEC_PER_SEC << (PWM_SIFIVE_CMPWIDTH + scale);
-	ddata->real_period = div64_ul(num, rate);
+	ddata->real_period = DIV_ROUND_UP_ULL(num, rate);
 	dev_dbg(ddata->chip.dev,
 		"New real_period = %u ns\n", ddata->real_period);
 }
-- 
2.42.0


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

* Re: [v6 1/3] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties
  2024-01-16  4:10 ` [v6 1/3] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties Nylon Chen
@ 2024-01-16 10:20   ` Emil Renner Berthing
  2024-01-16 10:44     ` Conor Dooley
  0 siblings, 1 reply; 7+ messages in thread
From: Emil Renner Berthing @ 2024-01-16 10:20 UTC (permalink / raw)
  To: Nylon Chen, paul.walmsley, palmer, conor+dt,
	krzysztof.kozlowski+dt, robh+dt, u.kleine-koenig, thierry.reding,
	aou
  Cc: zong.li, vincent.chen, linux-pwm, linux-kernel, linux-riscv,
	devicetree, nylon7717, Conor Dooley

Nylon Chen wrote:
> This removes the active-low properties of the PWM-controlled LEDs in
> the HiFive Unmatched device tree.
>
> The reference is hifive-unleashed-a00.pdf[0] and hifive-unmatched-schematics-v3.pdf[1].
>
> Link: https://sifive.cdn.prismic.io/sifive/c52a8e32-05ce-4aaf-95c8-7bf8453f8698_hifive-unleashed-a00-schematics-1.pdf [0]
> Link: https://sifive.cdn.prismic.io/sifive/6a06d6c0-6e66-49b5-8e9e-e68ce76f4192_hifive-unmatched-schematics-v3.pdf [1]
>
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> Co-developed-by: Zong Li <zong.li@sifve.com>
> Signed-off-by: Zong Li <zong.li@sifve.com>
> Co-developed-by: Vincent Chen <vincent.chen@sifive.com>
> Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
> Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
> ---
>  arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts |  8 ++++----
>  arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 12 ++++--------
>  2 files changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
> index 900a50526d77..11e7ac1c54bb 100644
> --- a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
> +++ b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
> @@ -49,7 +49,7 @@ led-controller {
>  		compatible = "pwm-leds";
>
>  		led-d1 {
> -			pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>;
> +			pwms = <&pwm0 0 7812500 0>;
>  			active-low;
>  			color = <LED_COLOR_ID_GREEN>;
>  			max-brightness = <255>;
> @@ -57,7 +57,7 @@ led-d1 {
>  		};
>
>  		led-d2 {
> -			pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>;
> +			pwms = <&pwm0 1 7812500 0>;
>  			active-low;
>  			color = <LED_COLOR_ID_GREEN>;
>  			max-brightness = <255>;
> @@ -65,7 +65,7 @@ led-d2 {
>  		};
>
>  		led-d3 {
> -			pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>;
> +			pwms = <&pwm0 2 7812500 0>;
>  			active-low;
>  			color = <LED_COLOR_ID_GREEN>;
>  			max-brightness = <255>;
> @@ -73,7 +73,7 @@ led-d3 {
>  		};
>
>  		led-d4 {
> -			pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>;
> +			pwms = <&pwm0 3 7812500 0>;
>  			active-low;
>  			color = <LED_COLOR_ID_GREEN>;
>  			max-brightness = <255>;
> diff --git a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
> index 07387f9c135c..b328ee80693f 100644
> --- a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
> +++ b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
> @@ -51,8 +51,7 @@ led-controller-1 {
>  		compatible = "pwm-leds";
>
>  		led-d12 {
> -			pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>;
> -			active-low;
> +			pwms = <&pwm0 0 7812500 0>;

Here you remove the active-low property, but you don't above. I'm not sure
what's the right thing to do, but I would have expected the same change in both
places.

/Emil

>  			color = <LED_COLOR_ID_GREEN>;
>  			max-brightness = <255>;
>  			label = "d12";
> @@ -68,20 +67,17 @@ multi-led {
>  			label = "d2";
>
>  			led-red {
> -				pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>;
> -				active-low;
> +				pwms = <&pwm0 2 7812500 0>;
>  				color = <LED_COLOR_ID_RED>;
>  			};
>
>  			led-green {
> -				pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>;
> -				active-low;
> +				pwms = <&pwm0 1 7812500 0>;
>  				color = <LED_COLOR_ID_GREEN>;
>  			};
>
>  			led-blue {
> -				pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>;
> -				active-low;
> +				pwms = <&pwm0 3 7812500 0>;
>  				color = <LED_COLOR_ID_BLUE>;
>  			};
>  		};
> --
> 2.42.0
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [v6 1/3] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties
  2024-01-16 10:20   ` Emil Renner Berthing
@ 2024-01-16 10:44     ` Conor Dooley
  2024-01-17  6:37       ` Nylon Chen
  0 siblings, 1 reply; 7+ messages in thread
From: Conor Dooley @ 2024-01-16 10:44 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: Nylon Chen, paul.walmsley, palmer, conor+dt,
	krzysztof.kozlowski+dt, robh+dt, u.kleine-koenig, thierry.reding,
	aou, zong.li, vincent.chen, linux-pwm, linux-kernel, linux-riscv,
	devicetree, nylon7717

[-- Attachment #1: Type: text/plain, Size: 4736 bytes --]

On Tue, Jan 16, 2024 at 02:20:57AM -0800, Emil Renner Berthing wrote:
> Nylon Chen wrote:
> > This removes the active-low properties of the PWM-controlled LEDs in
> > the HiFive Unmatched device tree.
> >
> > The reference is hifive-unleashed-a00.pdf[0] and hifive-unmatched-schematics-v3.pdf[1].
> >
> > Link: https://sifive.cdn.prismic.io/sifive/c52a8e32-05ce-4aaf-95c8-7bf8453f8698_hifive-unleashed-a00-schematics-1.pdf [0]
> > Link: https://sifive.cdn.prismic.io/sifive/6a06d6c0-6e66-49b5-8e9e-e68ce76f4192_hifive-unmatched-schematics-v3.pdf [1]
> >
> > Acked-by: Conor Dooley <conor.dooley@microchip.com>
> > Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> > Co-developed-by: Zong Li <zong.li@sifve.com>
> > Signed-off-by: Zong Li <zong.li@sifve.com>
> > Co-developed-by: Vincent Chen <vincent.chen@sifive.com>
> > Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
> > Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
> > ---
> >  arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts |  8 ++++----
> >  arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 12 ++++--------
> >  2 files changed, 8 insertions(+), 12 deletions(-)
> >
> > diff --git a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
> > index 900a50526d77..11e7ac1c54bb 100644
> > --- a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
> > +++ b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
> > @@ -49,7 +49,7 @@ led-controller {
> >  		compatible = "pwm-leds";
> >
> >  		led-d1 {
> > -			pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>;
> > +			pwms = <&pwm0 0 7812500 0>;
> >  			active-low;
> >  			color = <LED_COLOR_ID_GREEN>;
> >  			max-brightness = <255>;
> > @@ -57,7 +57,7 @@ led-d1 {
> >  		};
> >
> >  		led-d2 {
> > -			pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>;
> > +			pwms = <&pwm0 1 7812500 0>;
> >  			active-low;
> >  			color = <LED_COLOR_ID_GREEN>;
> >  			max-brightness = <255>;
> > @@ -65,7 +65,7 @@ led-d2 {
> >  		};
> >
> >  		led-d3 {
> > -			pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>;
> > +			pwms = <&pwm0 2 7812500 0>;
> >  			active-low;
> >  			color = <LED_COLOR_ID_GREEN>;
> >  			max-brightness = <255>;
> > @@ -73,7 +73,7 @@ led-d3 {
> >  		};
> >
> >  		led-d4 {
> > -			pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>;
> > +			pwms = <&pwm0 3 7812500 0>;
> >  			active-low;
> >  			color = <LED_COLOR_ID_GREEN>;
> >  			max-brightness = <255>;
> > diff --git a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
> > index 07387f9c135c..b328ee80693f 100644
> > --- a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
> > +++ b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
> > @@ -51,8 +51,7 @@ led-controller-1 {
> >  		compatible = "pwm-leds";
> >
> >  		led-d12 {
> > -			pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>;
> > -			active-low;
> > +			pwms = <&pwm0 0 7812500 0>;
> 
> Here you remove the active-low property, but you don't above. I'm not sure
> what's the right thing to do, but I would have expected the same change in both
> places.

Just to note, the original version of this that I acked/reviewed removed
the property from all led nodes. I then apparently didn't look closely
enough at v5 and left acked/reviewed tags on it too. It did not remove
the active-low properties but this change was not mentioned in the
changelog for the series.

D4 on the unleashed and D12 on the unmatched have the same circuitry
(modulo the placement of the series resistor) so I don't get why the
property is being removed from only D12.

I rescind my ack/review until that is clarified and/or fixed.

Thanks,
Conor.


> >  			color = <LED_COLOR_ID_GREEN>;
> >  			max-brightness = <255>;
> >  			label = "d12";
> > @@ -68,20 +67,17 @@ multi-led {
> >  			label = "d2";
> >
> >  			led-red {
> > -				pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>;
> > -				active-low;
> > +				pwms = <&pwm0 2 7812500 0>;
> >  				color = <LED_COLOR_ID_RED>;
> >  			};
> >
> >  			led-green {
> > -				pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>;
> > -				active-low;
> > +				pwms = <&pwm0 1 7812500 0>;
> >  				color = <LED_COLOR_ID_GREEN>;
> >  			};
> >
> >  			led-blue {
> > -				pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>;
> > -				active-low;
> > +				pwms = <&pwm0 3 7812500 0>;
> >  				color = <LED_COLOR_ID_BLUE>;
> >  			};
> >  		};
> > --
> > 2.42.0
> >
> >
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [v6 1/3] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties
  2024-01-16 10:44     ` Conor Dooley
@ 2024-01-17  6:37       ` Nylon Chen
  0 siblings, 0 replies; 7+ messages in thread
From: Nylon Chen @ 2024-01-17  6:37 UTC (permalink / raw)
  To: Conor Dooley
  Cc: Emil Renner Berthing, paul.walmsley, palmer, conor+dt,
	krzysztof.kozlowski+dt, robh+dt, u.kleine-koenig, thierry.reding,
	aou, zong.li, vincent.chen, linux-pwm, linux-kernel, linux-riscv,
	devicetree, nylon7717

Conor Dooley <conor.dooley@microchip.com> 於 2024年1月16日 週二 下午6:45寫道:
>
> On Tue, Jan 16, 2024 at 02:20:57AM -0800, Emil Renner Berthing wrote:
> > Nylon Chen wrote:
> > > This removes the active-low properties of the PWM-controlled LEDs in
> > > the HiFive Unmatched device tree.
> > >
> > > The reference is hifive-unleashed-a00.pdf[0] and hifive-unmatched-schematics-v3.pdf[1].
> > >
> > > Link: https://sifive.cdn.prismic.io/sifive/c52a8e32-05ce-4aaf-95c8-7bf8453f8698_hifive-unleashed-a00-schematics-1.pdf [0]
> > > Link: https://sifive.cdn.prismic.io/sifive/6a06d6c0-6e66-49b5-8e9e-e68ce76f4192_hifive-unmatched-schematics-v3.pdf [1]
> > >
> > > Acked-by: Conor Dooley <conor.dooley@microchip.com>
> > > Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> > > Co-developed-by: Zong Li <zong.li@sifve.com>
> > > Signed-off-by: Zong Li <zong.li@sifve.com>
> > > Co-developed-by: Vincent Chen <vincent.chen@sifive.com>
> > > Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
> > > Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
> > > ---
> > >  arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts |  8 ++++----
> > >  arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 12 ++++--------
> > >  2 files changed, 8 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
> > > index 900a50526d77..11e7ac1c54bb 100644
> > > --- a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
> > > +++ b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
> > > @@ -49,7 +49,7 @@ led-controller {
> > >             compatible = "pwm-leds";
> > >
> > >             led-d1 {
> > > -                   pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>;
> > > +                   pwms = <&pwm0 0 7812500 0>;
> > >                     active-low;
> > >                     color = <LED_COLOR_ID_GREEN>;
> > >                     max-brightness = <255>;
> > > @@ -57,7 +57,7 @@ led-d1 {
> > >             };
> > >
> > >             led-d2 {
> > > -                   pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>;
> > > +                   pwms = <&pwm0 1 7812500 0>;
> > >                     active-low;
> > >                     color = <LED_COLOR_ID_GREEN>;
> > >                     max-brightness = <255>;
> > > @@ -65,7 +65,7 @@ led-d2 {
> > >             };
> > >
> > >             led-d3 {
> > > -                   pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>;
> > > +                   pwms = <&pwm0 2 7812500 0>;
> > >                     active-low;
> > >                     color = <LED_COLOR_ID_GREEN>;
> > >                     max-brightness = <255>;
> > > @@ -73,7 +73,7 @@ led-d3 {
> > >             };
> > >
> > >             led-d4 {
> > > -                   pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>;
> > > +                   pwms = <&pwm0 3 7812500 0>;
> > >                     active-low;
> > >                     color = <LED_COLOR_ID_GREEN>;
> > >                     max-brightness = <255>;
> > > diff --git a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
> > > index 07387f9c135c..b328ee80693f 100644
> > > --- a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
> > > +++ b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
> > > @@ -51,8 +51,7 @@ led-controller-1 {
> > >             compatible = "pwm-leds";
> > >
> > >             led-d12 {
> > > -                   pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>;
> > > -                   active-low;
> > > +                   pwms = <&pwm0 0 7812500 0>;
> >

Hi Emil and Conor, thanks for your feedback.
>
>
> > Here you remove the active-low property, but you don't above. I'm not sure
> > what's the right thing to do, but I would have expected the same change in both
> > places.
>
For this patch, all "active-low" should be deleted. This is my
mistake. I will fix it in the next version.
>
>
> Just to note, the original version of this that I acked/reviewed removed
> the property from all led nodes. I then apparently didn't look closely
> enough at v5 and left acked/reviewed tags on it too. It did not remove
> the active-low properties but this change was not mentioned in the
> changelog for the series.
Sorry Conor, I apologize for any confusion I may have caused.
>
> D4 on the unleashed and D12 on the unmatched have the same circuitry
> (modulo the placement of the series resistor) so I don't get why the
> property is being removed from only D12.
>
> I rescind my ack/review until that is clarified and/or fixed.
>
> Thanks,
> Conor.
>
>
> > >                     color = <LED_COLOR_ID_GREEN>;
> > >                     max-brightness = <255>;
> > >                     label = "d12";
> > > @@ -68,20 +67,17 @@ multi-led {
> > >                     label = "d2";
> > >
> > >                     led-red {
> > > -                           pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>;
> > > -                           active-low;
> > > +                           pwms = <&pwm0 2 7812500 0>;
> > >                             color = <LED_COLOR_ID_RED>;
> > >                     };
> > >
> > >                     led-green {
> > > -                           pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>;
> > > -                           active-low;
> > > +                           pwms = <&pwm0 1 7812500 0>;
> > >                             color = <LED_COLOR_ID_GREEN>;
> > >                     };
> > >
> > >                     led-blue {
> > > -                           pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>;
> > > -                           active-low;
> > > +                           pwms = <&pwm0 3 7812500 0>;
> > >                             color = <LED_COLOR_ID_BLUE>;
> > >                     };
> > >             };
> > > --
> > > 2.42.0
> > >
> > >
> > > _______________________________________________
> > > linux-riscv mailing list
> > > linux-riscv@lists.infradead.org
> > > http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2024-01-17  6:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-16  4:10 [v6 0/3] Change PWM-controlled LED pin active mode and algorithm Nylon Chen
2024-01-16  4:10 ` [v6 1/3] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties Nylon Chen
2024-01-16 10:20   ` Emil Renner Berthing
2024-01-16 10:44     ` Conor Dooley
2024-01-17  6:37       ` Nylon Chen
2024-01-16  4:10 ` [v6 2/3] pwm: sifive: change the PWM controlled LED algorithm Nylon Chen
2024-01-16  4:10 ` [v6 3/3] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function Nylon Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox