Linux PWM subsystem development
 help / color / mirror / Atom feed
From: Stefan Wahren <wahrenst@gmx.net>
To: Sean Young <sean@mess.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	andy.shevchenko@gmail.com,
	"Angelo Compagnucci" <angelo.compagnucci@gmail.com>,
	"Philip Howard" <phil@gadgetoid.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	linux-pwm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-gpio@vger.kernel.org,
	"Vincent Whitchurch" <vincent.whitchurch@axis.com>
Subject: Re: [PATCH V3 2/2] pwm: Add GPIO PWM driver
Date: Tue, 30 Jan 2024 12:21:29 +0100	[thread overview]
Message-ID: <c6180cc2-8912-4cd0-82f9-4428df84db6b@gmx.net> (raw)
In-Reply-To: <Zbi8pbT7N0vKUgmx@gofer.mess.org>

Hi Sean,

Am 30.01.24 um 10:08 schrieb Sean Young:
> On Sun, Jan 28, 2024 at 05:36:30PM +0100, Stefan Wahren wrote:
>> From: Vincent Whitchurch <vincent.whitchurch@axis.com>
>>
>> Add a software PWM which toggles a GPIO from a high-resolution timer.
>>
>> This will naturally not be as accurate or as efficient as a hardware
>> PWM, but it is useful in some cases.  I have for example used it for
>> evaluating LED brightness handling (via leds-pwm) on a board where the
>> LED was just hooked up to a GPIO, and for a simple verification of the
>> timer frequency on another platform.
>>
>> Since high-resolution timers are used, sleeping gpio chips are not
>> supported and are rejected in the probe function.
>>
>> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
>> Co-developed-by: Stefan Wahren <wahrenst@gmx.net>
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> ---
...
>> +
>> +static int pwm_gpio_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>> +			  const struct pwm_state *state)
>> +{
>> +	struct pwm_gpio *gpwm = container_of(chip, struct pwm_gpio, chip);
>> +	bool invert = state->polarity == PWM_POLARITY_INVERSED;
>> +	unsigned long flags;
> Not sure this is necessary but how about:
>
> 	if (state->duty_cycle < hrtimer_resolution ||
> 	    state->period - state->duty_cycle < hrtimer_resolution)
> 		return -EINVAL;
>
i think i get the idea, but we need to care about corner cases like
duty_cycle = 0

  reply	other threads:[~2024-01-30 11:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-28 16:36 [PATCH V3 0/2] pwm: Add GPIO PWM driver Stefan Wahren
2024-01-28 16:36 ` [PATCH V3 1/2] dt-bindings: pwm: Add pwm-gpio Stefan Wahren
2024-01-28 17:08   ` Conor Dooley
2024-01-28 16:36 ` [PATCH V3 2/2] pwm: Add GPIO PWM driver Stefan Wahren
2024-01-29  9:40   ` Krzysztof Kozlowski
2024-01-29 13:55     ` Linus Walleij
2024-01-30  8:36       ` Krzysztof Kozlowski
2024-01-30  9:08   ` Sean Young
2024-01-30 11:21     ` Stefan Wahren [this message]
2024-02-02 13:19 ` [PATCH V3 0/2] " Phil Howard
2024-02-02 20:13   ` Stefan Wahren
2024-02-04 19:21     ` Phil Howard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c6180cc2-8912-4cd0-82f9-4428df84db6b@gmx.net \
    --to=wahrenst@gmx.net \
    --cc=andy.shevchenko@gmail.com \
    --cc=angelo.compagnucci@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=phil@gadgetoid.com \
    --cc=robh+dt@kernel.org \
    --cc=sean@mess.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=vincent.whitchurch@axis.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox