linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] pwm: bcm2835: Minor fixes
@ 2019-08-24  7:07 Stefan Wahren
  2019-08-24  7:07 ` [PATCH 1/3] pwm: bcm2835: suppress error message for invalid period_ns Stefan Wahren
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Stefan Wahren @ 2019-08-24  7:07 UTC (permalink / raw)
  To: Thierry Reding, Eric Anholt, Florian Fainelli, Ray Jui, Scott Branden
  Cc: linux-pwm, Stefan Wahren, linux-arm-kernel

This small patch series contains minor fixes for clock handling and the
period range check.

Stefan Wahren (3):
  pwm: bcm2835: suppress error message for invalid period_ns
  pwm: bcm2835: fix period_ns range check
  pwm: bcm2835: suppress error message during deferred probe

 drivers/pwm/pwm-bcm2835.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

--
2.7.4


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

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

* [PATCH 1/3] pwm: bcm2835: suppress error message for invalid period_ns
  2019-08-24  7:07 [PATCH 0/3] pwm: bcm2835: Minor fixes Stefan Wahren
@ 2019-08-24  7:07 ` Stefan Wahren
  2019-08-24  9:26   ` Uwe Kleine-König
  2019-08-24  7:07 ` [PATCH 2/3] pwm: bcm2835: fix period_ns range check Stefan Wahren
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Stefan Wahren @ 2019-08-24  7:07 UTC (permalink / raw)
  To: Thierry Reding, Eric Anholt, Florian Fainelli, Ray Jui, Scott Branden
  Cc: linux-pwm, Stefan Wahren, linux-arm-kernel

The PWM config can be triggered via sysfs, so we better suppress the
error message in case of an invalid period to avoid kernel log spamming.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/pwm/pwm-bcm2835.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index f6fe0b9..5276306 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -72,11 +72,8 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,

 	scaler = DIV_ROUND_CLOSEST(NSEC_PER_SEC, rate);

-	if (period_ns <= MIN_PERIOD) {
-		dev_err(pc->dev, "period %d not supported, minimum %d\n",
-			period_ns, MIN_PERIOD);
+	if (period_ns <= MIN_PERIOD)
 		return -EINVAL;
-	}

 	writel(DIV_ROUND_CLOSEST(duty_ns, scaler),
 	       pc->base + DUTY(pwm->hwpwm));
--
2.7.4


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

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

* [PATCH 2/3] pwm: bcm2835: fix period_ns range check
  2019-08-24  7:07 [PATCH 0/3] pwm: bcm2835: Minor fixes Stefan Wahren
  2019-08-24  7:07 ` [PATCH 1/3] pwm: bcm2835: suppress error message for invalid period_ns Stefan Wahren
@ 2019-08-24  7:07 ` Stefan Wahren
  2019-08-24  9:26   ` Uwe Kleine-König
  2019-08-24  7:07 ` [PATCH 3/3] pwm: bcm2835: suppress error message during deferred probe Stefan Wahren
  2019-08-24  9:25 ` [PATCH 0/3] pwm: bcm2835: Minor fixes Uwe Kleine-König
  3 siblings, 1 reply; 12+ messages in thread
From: Stefan Wahren @ 2019-08-24  7:07 UTC (permalink / raw)
  To: Thierry Reding, Eric Anholt, Florian Fainelli, Ray Jui, Scott Branden
  Cc: linux-pwm, Stefan Wahren, linux-arm-kernel

The range check for period_ns was written under assumption of a fixed
PWM clock. With clk-bcm2835 driver the PWM clock is a dynamic one.
So fix this by doing the range check on the period register value.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/pwm/pwm-bcm2835.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index 5276306..2c82386 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -21,7 +21,7 @@
 #define PERIOD(x)		(((x) * 0x10) + 0x10)
 #define DUTY(x)			(((x) * 0x10) + 0x14)

-#define MIN_PERIOD		108		/* 9.2 MHz max. PWM clock */
+#define PERIOD_MIN		0x2

 struct bcm2835_pwm {
 	struct pwm_chip chip;
@@ -64,6 +64,7 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 	struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
 	unsigned long rate = clk_get_rate(pc->clk);
 	unsigned long scaler;
+	u32 period;

 	if (!rate) {
 		dev_err(pc->dev, "failed to get clock rate\n");
@@ -71,14 +72,14 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 	}

 	scaler = DIV_ROUND_CLOSEST(NSEC_PER_SEC, rate);
+	period = DIV_ROUND_CLOSEST(period_ns, scaler);

-	if (period_ns <= MIN_PERIOD)
+	if (period < PERIOD_MIN)
 		return -EINVAL;

 	writel(DIV_ROUND_CLOSEST(duty_ns, scaler),
 	       pc->base + DUTY(pwm->hwpwm));
-	writel(DIV_ROUND_CLOSEST(period_ns, scaler),
-	       pc->base + PERIOD(pwm->hwpwm));
+	writel(period, pc->base + PERIOD(pwm->hwpwm));

 	return 0;
 }
--
2.7.4


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

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

* [PATCH 3/3] pwm: bcm2835: suppress error message during deferred probe
  2019-08-24  7:07 [PATCH 0/3] pwm: bcm2835: Minor fixes Stefan Wahren
  2019-08-24  7:07 ` [PATCH 1/3] pwm: bcm2835: suppress error message for invalid period_ns Stefan Wahren
  2019-08-24  7:07 ` [PATCH 2/3] pwm: bcm2835: fix period_ns range check Stefan Wahren
@ 2019-08-24  7:07 ` Stefan Wahren
  2019-08-24  9:30   ` Uwe Kleine-König
  2019-08-24  9:25 ` [PATCH 0/3] pwm: bcm2835: Minor fixes Uwe Kleine-König
  3 siblings, 1 reply; 12+ messages in thread
From: Stefan Wahren @ 2019-08-24  7:07 UTC (permalink / raw)
  To: Thierry Reding, Eric Anholt, Florian Fainelli, Ray Jui, Scott Branden
  Cc: linux-pwm, Stefan Wahren, linux-arm-kernel

This suppresses error messages in case the PWM clock isn't ready yet.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/pwm/pwm-bcm2835.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index 2c82386..ce362be 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -153,7 +153,10 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)

 	pc->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(pc->clk)) {
-		dev_err(&pdev->dev, "clock not found: %ld\n", PTR_ERR(pc->clk));
+		if (PTR_ERR(pc->clk) != -EPROBE_DEFER) {
+			dev_err(&pdev->dev, "clock not found: %ld\n",
+				PTR_ERR(pc->clk));
+		}
 		return PTR_ERR(pc->clk);
 	}

--
2.7.4


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

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

* Re: [PATCH 0/3] pwm: bcm2835: Minor fixes
  2019-08-24  7:07 [PATCH 0/3] pwm: bcm2835: Minor fixes Stefan Wahren
                   ` (2 preceding siblings ...)
  2019-08-24  7:07 ` [PATCH 3/3] pwm: bcm2835: suppress error message during deferred probe Stefan Wahren
@ 2019-08-24  9:25 ` Uwe Kleine-König
  2019-08-24 10:05   ` Stefan Wahren
  3 siblings, 1 reply; 12+ messages in thread
From: Uwe Kleine-König @ 2019-08-24  9:25 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: linux-pwm, Florian Fainelli, Scott Branden, Ray Jui, Eric Anholt,
	Thierry Reding, linux-arm-kernel

Hello Stefan,

On Sat, Aug 24, 2019 at 09:07:22AM +0200, Stefan Wahren wrote:
> This small patch series contains minor fixes for clock handling and the
> period range check.

I'd like to understand the various different usecases of PWMs. The
in-kernel consumers are kind of obvious, but sysfs users are not. It
seems you are one of the latter.

Would you mind sharing what you control using the PWM? Does it bother
you that the sysfs interface doesn't allow atomic configuration?

Assuming you have some interest in this driver: It still uses the legacy
stuff implementing .config, .enable, .disable, .set_polarity. Are you
willing to test (or even implement) a switch to .apply instead?

Just from a quick lock into the driver I wonder a few things, maybe you
can shed some light here. If there is publicly available documenation
for this piece of hardware, feel free to point this out, then I might be
able to work out some of the answers myself.

The overall (and common) design of the PWM is an input clk, a counter, a
duty and a period register.

The slightly simplified logic in .config is:

	scaler = DIV_ROUND_CLOSEST(NSEC_PER_SEC, rate);
	writel(DIV_ROUND_CLOSEST(duty_ns, scaler), PWM_DUTY);
	writel(DIV_ROUND_CLOSEST(period_ns, scaler), PWM_PERIOD);

This is loosing precision while the calculation could be cheaper (in CPU
cycles) and more exact when using:

	writel(DIV_ROUND_CLOSEST(duty_ns * rate, NSEC_PER_SEC), PWM_DUTY);
	writel(DIV_ROUND_CLOSEST(period_ns * rate, NSEC_PER_SEC), PWM_PERIOD);

This is only two divisions instead of three. And assuming a rate of 9.2
MHz and a request of duty_ns = 499945, period_ns = 999891 the original
calculation yields

	DUTY = 4587
	PERIOD = 9173

	real_duty_ns = 498586.95652173914
	real_period_ns = 997065.2173913043

	error_duty_ns = 1358.0434782608645
	error_period_ns = 2825.7826086956775

With my suggestion you'd get

	DUTY = 4599
	PERIOD = 9199

	real_duty_ns = 499891.3043478261
	real_period_ns = 999891.304347826

	error_duty_ns = 53.69565217389027
	error_period_ns = -0.30434782605152577

(But having said this, I'd prefer to use rounding down instead of
rounding closest).

Also I wonder if reprogramming the hardware completes the currently
running period and how the hardware behaves on disable. (In the latter
case I'm interested in "Does it complete the running period?" and "Which
state does the output stop in?")

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

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

* Re: [PATCH 1/3] pwm: bcm2835: suppress error message for invalid period_ns
  2019-08-24  7:07 ` [PATCH 1/3] pwm: bcm2835: suppress error message for invalid period_ns Stefan Wahren
@ 2019-08-24  9:26   ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2019-08-24  9:26 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: linux-pwm, Florian Fainelli, Scott Branden, Ray Jui, Eric Anholt,
	Thierry Reding, linux-arm-kernel

On Sat, Aug 24, 2019 at 09:07:23AM +0200, Stefan Wahren wrote:
> The PWM config can be triggered via sysfs, so we better suppress the
> error message in case of an invalid period to avoid kernel log spamming.
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

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

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

* Re: [PATCH 2/3] pwm: bcm2835: fix period_ns range check
  2019-08-24  7:07 ` [PATCH 2/3] pwm: bcm2835: fix period_ns range check Stefan Wahren
@ 2019-08-24  9:26   ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2019-08-24  9:26 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: linux-pwm, Florian Fainelli, Scott Branden, Ray Jui, Eric Anholt,
	Thierry Reding, linux-arm-kernel

On Sat, Aug 24, 2019 at 09:07:24AM +0200, Stefan Wahren wrote:
> The range check for period_ns was written under assumption of a fixed
> PWM clock. With clk-bcm2835 driver the PWM clock is a dynamic one.
> So fix this by doing the range check on the period register value.
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>


-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

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

* Re: [PATCH 3/3] pwm: bcm2835: suppress error message during deferred probe
  2019-08-24  7:07 ` [PATCH 3/3] pwm: bcm2835: suppress error message during deferred probe Stefan Wahren
@ 2019-08-24  9:30   ` Uwe Kleine-König
  2019-08-24  9:44     ` Stefan Wahren
  0 siblings, 1 reply; 12+ messages in thread
From: Uwe Kleine-König @ 2019-08-24  9:30 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: linux-pwm, Florian Fainelli, Scott Branden, Ray Jui, Eric Anholt,
	Thierry Reding, linux-arm-kernel

On Sat, Aug 24, 2019 at 09:07:25AM +0200, Stefan Wahren wrote:
> This suppresses error messages in case the PWM clock isn't ready yet.
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> ---
>  drivers/pwm/pwm-bcm2835.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
> index 2c82386..ce362be 100644
> --- a/drivers/pwm/pwm-bcm2835.c
> +++ b/drivers/pwm/pwm-bcm2835.c
> @@ -153,7 +153,10 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
> 
>  	pc->clk = devm_clk_get(&pdev->dev, NULL);
>  	if (IS_ERR(pc->clk)) {
> -		dev_err(&pdev->dev, "clock not found: %ld\n", PTR_ERR(pc->clk));
> +		if (PTR_ERR(pc->clk) != -EPROBE_DEFER) {
> +			dev_err(&pdev->dev, "clock not found: %ld\n",
> +				PTR_ERR(pc->clk));
> +		}
>  		return PTR_ERR(pc->clk);
>  	}

I would have used:

	if (IS_ERR(pc->clk)) {
		int err = PTR_ERR(pc->clk);
		if (err != -EPROBE_DEFER)
			dev_err(&pdev->dev, "clock not found: %d\n", err);

		return err;
	}

This calculates the error code only once and make the dev_err line short
enough to not make it necessary to add a line break.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

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

* Re: [PATCH 3/3] pwm: bcm2835: suppress error message during deferred probe
  2019-08-24  9:30   ` Uwe Kleine-König
@ 2019-08-24  9:44     ` Stefan Wahren
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Wahren @ 2019-08-24  9:44 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: linux-pwm, Florian Fainelli, Scott Branden, Ray Jui, Eric Anholt,
	Thierry Reding, linux-arm-kernel

Am 24.08.19 um 11:30 schrieb Uwe Kleine-König:
> On Sat, Aug 24, 2019 at 09:07:25AM +0200, Stefan Wahren wrote:
>> This suppresses error messages in case the PWM clock isn't ready yet.
>>
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> ---
>>  drivers/pwm/pwm-bcm2835.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
>> index 2c82386..ce362be 100644
>> --- a/drivers/pwm/pwm-bcm2835.c
>> +++ b/drivers/pwm/pwm-bcm2835.c
>> @@ -153,7 +153,10 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
>>
>>  	pc->clk = devm_clk_get(&pdev->dev, NULL);
>>  	if (IS_ERR(pc->clk)) {
>> -		dev_err(&pdev->dev, "clock not found: %ld\n", PTR_ERR(pc->clk));
>> +		if (PTR_ERR(pc->clk) != -EPROBE_DEFER) {
>> +			dev_err(&pdev->dev, "clock not found: %ld\n",
>> +				PTR_ERR(pc->clk));
>> +		}
>>  		return PTR_ERR(pc->clk);
>>  	}
> I would have used:
>
> 	if (IS_ERR(pc->clk)) {
> 		int err = PTR_ERR(pc->clk);
> 		if (err != -EPROBE_DEFER)
> 			dev_err(&pdev->dev, "clock not found: %d\n", err);
>
> 		return err;
> 	}
>
> This calculates the error code only once and make the dev_err line short
> enough to not make it necessary to add a line break.
Sure that's better. Will send V2 soon
>
> Best regards
> Uwe
>

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

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

* Re: [PATCH 0/3] pwm: bcm2835: Minor fixes
  2019-08-24  9:25 ` [PATCH 0/3] pwm: bcm2835: Minor fixes Uwe Kleine-König
@ 2019-08-24 10:05   ` Stefan Wahren
  2019-08-24 10:56     ` Uwe Kleine-König
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Wahren @ 2019-08-24 10:05 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: linux-pwm, Florian Fainelli, Scott Branden, Ray Jui, Eric Anholt,
	Thierry Reding, linux-arm-kernel

Hi Uwe,

Am 24.08.19 um 11:25 schrieb Uwe Kleine-König:
> Hello Stefan,
>
> On Sat, Aug 24, 2019 at 09:07:22AM +0200, Stefan Wahren wrote:
>> This small patch series contains minor fixes for clock handling and the
>> period range check.
> I'd like to understand the various different usecases of PWMs. The
> in-kernel consumers are kind of obvious, but sysfs users are not. It
> seems you are one of the latter.
>
> Would you mind sharing what you control using the PWM?
not really a PWM user with BCM2835. It's more the motivation as a
platform maintainer to keep the drivers in shape. At work we are using
sysfs interface for user applications to control ventilation (via hwmon
interface) and EV charging (IEC 61851) with a different SoC.
>  Does it bother
> you that the sysfs interface doesn't allow atomic configuration?
To be honest not really, but i think a lot of user could benefit and
might stop using hacky Python scripts which manipulate the registers
directly.
>
> Assuming you have some interest in this driver: It still uses the legacy
> stuff implementing .config, .enable, .disable, .set_polarity. Are you
> willing to test (or even implement) a switch to .apply instead?
Yes, definitely. This is one of my never ending TODO list [1]. But i
would be suprised that you wont have access to a Raspberry Pi.
>
> Just from a quick lock into the driver I wonder a few things, maybe you
> can shed some light here. If there is publicly available documenation
> for this piece of hardware, feel free to point this out, then I might be
> able to work out some of the answers myself.
Fortunately yes [2]
>
> The overall (and common) design of the PWM is an input clk, a counter, a
> duty and a period register.
>
> The slightly simplified logic in .config is:
>
> 	scaler = DIV_ROUND_CLOSEST(NSEC_PER_SEC, rate);
> 	writel(DIV_ROUND_CLOSEST(duty_ns, scaler), PWM_DUTY);
> 	writel(DIV_ROUND_CLOSEST(period_ns, scaler), PWM_PERIOD);
>
> This is loosing precision while the calculation could be cheaper (in CPU
> cycles) and more exact when using:
>
> 	writel(DIV_ROUND_CLOSEST(duty_ns * rate, NSEC_PER_SEC), PWM_DUTY);
> 	writel(DIV_ROUND_CLOSEST(period_ns * rate, NSEC_PER_SEC), PWM_PERIOD);
>
> This is only two divisions instead of three. And assuming a rate of 9.2
> MHz and a request of duty_ns = 499945, period_ns = 999891 the original
> calculation yields
>
> 	DUTY = 4587
> 	PERIOD = 9173
>
> 	real_duty_ns = 498586.95652173914
> 	real_period_ns = 997065.2173913043
>
> 	error_duty_ns = 1358.0434782608645
> 	error_period_ns = 2825.7826086956775
>
> With my suggestion you'd get
>
> 	DUTY = 4599
> 	PERIOD = 9199
>
> 	real_duty_ns = 499891.3043478261
> 	real_period_ns = 999891.304347826
>
> 	error_duty_ns = 53.69565217389027
> 	error_period_ns = -0.30434782605152577
>
> (But having said this, I'd prefer to use rounding down instead of
> rounding closest).
>
> Also I wonder if reprogramming the hardware completes the currently
> running period and how the hardware behaves on disable. (In the latter
> case I'm interested in "Does it complete the running period?" and "Which
> state does the output stop in?")

I need to make logic analyzer traces to make any statement.

Thanks

[1] - https://github.com/lategoodbye/rpi-zero/issues/16

[2] -
https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf

>
> Best regards
> Uwe
>

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

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

* Re: [PATCH 0/3] pwm: bcm2835: Minor fixes
  2019-08-24 10:05   ` Stefan Wahren
@ 2019-08-24 10:56     ` Uwe Kleine-König
  2019-08-24 14:17       ` Stefan Wahren
  0 siblings, 1 reply; 12+ messages in thread
From: Uwe Kleine-König @ 2019-08-24 10:56 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: linux-pwm, Florian Fainelli, Scott Branden, Ray Jui, Eric Anholt,
	Thierry Reding, linux-arm-kernel

Hello Stefan,

On Sat, Aug 24, 2019 at 12:05:00PM +0200, Stefan Wahren wrote:
> Am 24.08.19 um 11:25 schrieb Uwe Kleine-König:
> > Hello Stefan,
> >
> > On Sat, Aug 24, 2019 at 09:07:22AM +0200, Stefan Wahren wrote:
> >> This small patch series contains minor fixes for clock handling and the
> >> period range check.
> >
> > I'd like to understand the various different usecases of PWMs. The
> > in-kernel consumers are kind of obvious, but sysfs users are not. It
> > seems you are one of the latter.
> >
> > Would you mind sharing what you control using the PWM?
> 
> not really a PWM user with BCM2835. It's more the motivation as a
> platform maintainer to keep the drivers in shape. At work we are using
> sysfs interface for user applications to control ventilation (via hwmon
> interface) and EV charging (IEC 61851) with a different SoC.

I don't understand how you use the sysfs interface and still interact
with the hwmon interface. Other than that, thanks for sharing.


> > Assuming you have some interest in this driver: It still uses the legacy
> > stuff implementing .config, .enable, .disable, .set_polarity. Are you
> > willing to test (or even implement) a switch to .apply instead?
> 
> Yes, definitely. This is one of my never ending TODO list [1]. But i
> would be suprised that you wont have access to a Raspberry Pi.

So be surprised :-)

> > Just from a quick lock into the driver I wonder a few things, maybe you
> > can shed some light here. If there is publicly available documenation
> > for this piece of hardware, feel free to point this out, then I might be
> > able to work out some of the answers myself.
> 
> Fortunately yes [2]

Care to add a link to this document in the driver for others to easily
find it?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

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

* Re: [PATCH 0/3] pwm: bcm2835: Minor fixes
  2019-08-24 10:56     ` Uwe Kleine-König
@ 2019-08-24 14:17       ` Stefan Wahren
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Wahren @ 2019-08-24 14:17 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: linux-pwm, Florian Fainelli, Scott Branden, Ray Jui, Eric Anholt,
	Thierry Reding, linux-arm-kernel

Hi Uwe,

Am 24.08.19 um 12:56 schrieb Uwe Kleine-König:
> Hello Stefan,
>
> On Sat, Aug 24, 2019 at 12:05:00PM +0200, Stefan Wahren wrote:
>> Am 24.08.19 um 11:25 schrieb Uwe Kleine-König:
>>> Hello Stefan,
>>>
>>> On Sat, Aug 24, 2019 at 09:07:22AM +0200, Stefan Wahren wrote:
>>>> This small patch series contains minor fixes for clock handling and the
>>>> period range check.
>>> I'd like to understand the various different usecases of PWMs. The
>>> in-kernel consumers are kind of obvious, but sysfs users are not. It
>>> seems you are one of the latter.
>>>
>>> Would you mind sharing what you control using the PWM?
>> not really a PWM user with BCM2835. It's more the motivation as a
>> platform maintainer to keep the drivers in shape. At work we are using
>> sysfs interface for user applications to control ventilation (via hwmon
>> interface) and EV charging (IEC 61851) with a different SoC.
> I don't understand how you use the sysfs interface and still interact
> with the hwmon interface. Other than that, thanks for sharing.
I meant the hwmon sysfs interface. Sure using with pwm sysfs in parallel
isn't possible.
>
>
>>> Assuming you have some interest in this driver: It still uses the legacy
>>> stuff implementing .config, .enable, .disable, .set_polarity. Are you
>>> willing to test (or even implement) a switch to .apply instead?
>> Yes, definitely. This is one of my never ending TODO list [1]. But i
>> would be suprised that you wont have access to a Raspberry Pi.
> So be surprised :-)
>
>>> Just from a quick lock into the driver I wonder a few things, maybe you
>>> can shed some light here. If there is publicly available documenation
>>> for this piece of hardware, feel free to point this out, then I might be
>>> able to work out some of the answers myself.
>> Fortunately yes [2]
> Care to add a link to this document in the driver for others to easily
> find it?
I don't think it's necessary. This document is easy to find via "bcm2835
datasheet".
>
> Best regards
> Uwe
>

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

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

end of thread, other threads:[~2019-08-24 14:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-24  7:07 [PATCH 0/3] pwm: bcm2835: Minor fixes Stefan Wahren
2019-08-24  7:07 ` [PATCH 1/3] pwm: bcm2835: suppress error message for invalid period_ns Stefan Wahren
2019-08-24  9:26   ` Uwe Kleine-König
2019-08-24  7:07 ` [PATCH 2/3] pwm: bcm2835: fix period_ns range check Stefan Wahren
2019-08-24  9:26   ` Uwe Kleine-König
2019-08-24  7:07 ` [PATCH 3/3] pwm: bcm2835: suppress error message during deferred probe Stefan Wahren
2019-08-24  9:30   ` Uwe Kleine-König
2019-08-24  9:44     ` Stefan Wahren
2019-08-24  9:25 ` [PATCH 0/3] pwm: bcm2835: Minor fixes Uwe Kleine-König
2019-08-24 10:05   ` Stefan Wahren
2019-08-24 10:56     ` Uwe Kleine-König
2019-08-24 14:17       ` Stefan Wahren

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).