From: Lokesh Vutla <lokeshvutla@ti.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>,
Tony Lindgren <tony@atomide.com>,
Linux OMAP Mailing List <linux-omap@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-pwm@vger.kernel.org>,
Sekhar Nori <nsekhar@ti.com>
Subject: Re: [PATCH 4/4] pwm: omap-dmtimer: Implement .apply callback
Date: Tue, 25 Feb 2020 10:31:45 +0530 [thread overview]
Message-ID: <cee31e10-17b4-1cfb-5c77-a58a142c338d@ti.com> (raw)
In-Reply-To: <20200224090706.xsujpc3yiqlmmrmm@pengutronix.de>
Hi Uwe,
On 24/02/20 2:37 PM, Uwe Kleine-König wrote:
> On Mon, Feb 24, 2020 at 10:51:35AM +0530, Lokesh Vutla wrote:
>> Implement .apply callback and drop the legacy callbacks(enable, disable,
>> config, set_polarity).
>>
>> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
>> ---
>> drivers/pwm/pwm-omap-dmtimer.c | 141 +++++++++++++++++++--------------
>> 1 file changed, 80 insertions(+), 61 deletions(-)
>>
[..snip..]
>> -static int pwm_omap_dmtimer_set_polarity(struct pwm_chip *chip,
>> - struct pwm_device *pwm,
>> - enum pwm_polarity polarity)
>> +/**
>> + * pwm_omap_dmtimer_apply() - Changes the state of the pwm omap dm timer.
>> + * @chip: Pointer to PWM controller
>> + * @pwm: Pointer to PWM channel
>> + * @state: New sate to apply
>> + *
>> + * Return 0 if successfully changed the state else appropriate error.
>> + */
>> +static int pwm_omap_dmtimer_apply(struct pwm_chip *chip,
>> + struct pwm_device *pwm,
>> + const struct pwm_state *state)
>> {
>> struct pwm_omap_dmtimer_chip *omap = to_pwm_omap_dmtimer_chip(chip);
>> + int ret = 0;
>>
>> - /*
>> - * PWM core will not call set_polarity while PWM is enabled so it's
>> - * safe to reconfigure the timer here without stopping it first.
>> - */
>> mutex_lock(&omap->mutex);
>> - omap->pdata->set_pwm(omap->dm_timer,
>> - polarity == PWM_POLARITY_INVERSED,
>> - true, OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE);
>> +
>> + if (pwm_is_enabled(pwm) && !state->enabled) {
>
> In my book calling PWM API functions (designed for PWM consumers) is not
> so nice. I would prefer you checking the hardware registers or cache the
> state locally instead of relying on the core here.
.start and .stop apis does read the hardware registers and check the state
before making any changes. Do you want to drop off the pwm_is_enabled(pwm) check
here?
>
> It would be great to have a general description at the top of the driver
> (like for example drivers/pwm/pwm-sifive.c) that answers things like:
>
> - Does calling .stop completes the currently running period (it
> should)?
Existing driver implementation abruptly stops the cycle. I can make changes such
that it completes the currently running period.
> - Does changing polarity, duty_cycle and period complete the running
> period?
- Polarity can be changed only when the pwm is not running. Ill add extra guards
to reflect this behavior.
- Changing duty_cycle and period does complete the running period and new values
gets reflected in next cycle.
> - How does the hardware behave on disable? (i.e. does it output the
> state the pin is at in that moment? Does it go High-Z?)
Now that I am making changes to complete the current period on disable, the pin
goes to Low after disabling(completing the cycle).
Ill add all these points as you mentioned in v2.
Thanks and regards,
Lokesh
next prev parent reply other threads:[~2020-02-25 5:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 5:21 [PATCH 0/4] pwm: omap-dmtimer: Allow for dynamic pwm period updates Lokesh Vutla
2020-02-24 5:21 ` [PATCH 1/4] pwm: omap-dmtimer: Drop unused header file Lokesh Vutla
2020-02-24 7:53 ` Uwe Kleine-König
2020-02-25 5:02 ` Lokesh Vutla
2020-02-25 6:43 ` Uwe Kleine-König
2020-02-24 5:21 ` [PATCH 2/4] pwm: omap-dmtimer: Fix pwm enabling sequence Lokesh Vutla
2020-02-24 8:49 ` Uwe Kleine-König
2020-02-25 5:02 ` Lokesh Vutla
2020-02-24 5:21 ` [PATCH 3/4] pwm: omap-dmtimer: Do not disable pwm before changing period/duty_cycle Lokesh Vutla
2020-02-24 8:55 ` Uwe Kleine-König
2020-02-25 5:02 ` Lokesh Vutla
2020-02-25 6:48 ` Uwe Kleine-König
2020-02-25 7:59 ` Lokesh Vutla
2020-02-25 8:38 ` Uwe Kleine-König
2020-02-25 11:26 ` Lokesh Vutla
2020-02-26 16:35 ` Uwe Kleine-König
2020-02-24 5:21 ` [PATCH 4/4] pwm: omap-dmtimer: Implement .apply callback Lokesh Vutla
2020-02-24 9:07 ` Uwe Kleine-König
2020-02-25 5:01 ` Lokesh Vutla [this message]
2020-02-26 16:21 ` Uwe Kleine-König
2020-02-26 17:57 ` [PATCH 0/4] pwm: omap-dmtimer: Allow for dynamic pwm period updates Tony Lindgren
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=cee31e10-17b4-1cfb-5c77-a58a142c338d@ti.com \
--to=lokeshvutla@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=nsekhar@ti.com \
--cc=thierry.reding@gmail.com \
--cc=tony@atomide.com \
--cc=u.kleine-koenig@pengutronix.de \
/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
all inboxes | Powered by JetHome®