From: Gokul Praveen <g-praveen@ti.com>
To: "Uwe Kleine-König" <ukleinek@kernel.org>
Cc: <j-keerthy@ti.com>, <linux-pwm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <u-kumar1@ti.com>,
<n-francis@ti.com>,
"Rafael V. Volkmer" <rafael.v.volkmer@gmail.com>,
Gokul Praveen <g-praveen@ti.com>
Subject: Re: [PATCH v2] pwm: tiehrpwm: Enable EHRPWM controller before setting configuration
Date: Wed, 7 Jan 2026 15:53:33 +0530 [thread overview]
Message-ID: <60ef0a6d-f4f5-41ea-899c-e353ec9c1c8c@ti.com> (raw)
In-Reply-To: <kkddrxw37dx7w6f6csomopcwz5xk2o7ezddrisfisij6lq46hf@ije72we4xrek>
Hi Uwe,
Thank you for your prompt response and reply.
On 07/01/26 15:21, Uwe Kleine-König wrote:
> Hello,
>
> adding Rafael to Cc: who sent a patch series for this driver that I
> didn't come around to review yet. Given that neither he nor me noticed
> the problem addressed in this patch I wonder if it applies to all
> hardware variants.
>
Yes, it applies to all hardware variants, Uwe.
> On Wed, Jan 07, 2026 at 11:23:39AM +0530, Gokul Praveen wrote:
>> The period and duty cycle configurations does not get reflected
>> after setting them using sysfs nodes. This is because at the
>> end of ehrpwm_pwm_config function, the put_sync function is
>> called which resets the hardware.
>>
>> Fix it by preventing the pwm controller from going into
>> low-power mode.
>>
>> Fixes: 5f027d9b83db("pwm: tiehrpwm: Implement .apply() callback")
>> Signed-off-by: Gokul Praveen <g-praveen@ti.com>
>> ---
>> v2 <==> v1
>> ==========
>> * Removed space between Fixes and Signed-off tag
>>
>> drivers/pwm/pwm-tiehrpwm.c | 22 +++++++++++++---------
>> 1 file changed, 13 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
>> index 7a86cb090f76..408aed70be8c 100644
>> --- a/drivers/pwm/pwm-tiehrpwm.c
>> +++ b/drivers/pwm/pwm-tiehrpwm.c
>> @@ -237,7 +237,6 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>> if (period_cycles < 1)
>> period_cycles = 1;
>>
>> - pm_runtime_get_sync(pwmchip_parent(chip));
>>
>> /* Update clock prescaler values */
>> ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_CLKDIV_MASK, tb_divval);
>> @@ -290,12 +289,11 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>> if (!(duty_cycles > period_cycles))
>> ehrpwm_write(pc->mmio_base, cmp_reg, duty_cycles);
>>
>> - pm_runtime_put_sync(pwmchip_parent(chip));
>> -
>> return 0;
>> }
>>
>> -static int ehrpwm_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
>> +static int ehrpwm_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm,
>> + const struct pwm_state *state)
>
> With this function also caring for *state the name isn't appropriate any
> more.
>
But the duty cycle, period and polarity values are extracted from the
state parameter, right?
Please feel free to correct me if I am wrong, Uwe?
>> {
>> struct ehrpwm_pwm_chip *pc = to_ehrpwm_pwm_chip(chip);
>> u16 aqcsfrc_val, aqcsfrc_mask;
>> @@ -304,6 +302,13 @@ static int ehrpwm_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
>> /* Leave clock enabled on enabling PWM */
>> pm_runtime_get_sync(pwmchip_parent(chip));
>>
>> + ret = ehrpwm_pwm_config(chip, pwm, state->duty_cycle, state->period, state->polarity);
>> +
>> + if (ret) {
>> + pm_runtime_put_sync(pwmchip_parent(chip));
>> + return ret;
>> + }
>> +
>> /* Disabling Action Qualifier on PWM output */
>> if (pwm->hwpwm) {
>> aqcsfrc_val = AQCSFRC_CSFB_FRCDIS;
>> @@ -391,12 +396,11 @@ static int ehrpwm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>> return 0;
>> }
>>
>> - err = ehrpwm_pwm_config(chip, pwm, state->duty_cycle, state->period, state->polarity);
>> - if (err)
>> - return err;
>> -
>> if (!enabled)
>> - err = ehrpwm_pwm_enable(chip, pwm);
>> + err = ehrpwm_pwm_enable(chip, pwm, state);
>> + else
>> + err = ehrpwm_pwm_config(chip, pwm, state->duty_cycle,
>> + state->period, state->polarity);
>>
>> return err;
>> }
>
> Why are the changes from the two hunks above needed? Reading the change
> log I only understand the first hunk and would expect it to be enough.
>
The 2nd hunk is needed I believe because now, the ehrpwm_pwm_config
function is called inside the ehrpwm_pwm_enable function.
Hence, calling the ehrpwm_pwm_config function before the
ehrpwm_pwm_enable function within the ehrpwm_pwm_apply function would be
a redundant call I believe when we try to enable the ehrpwm.
Now, coming to the ehrpwm_pwm_config function which I have added after
the ehrpwm_pwm_enable function in the else case, it would be needed I
believe in order to change the duty cycle and period at runtime after
the pwm has been enabled.
Please feel free and do correct me if I am wrong, Uwe.
> Best regards
> Uwe
next prev parent reply other threads:[~2026-01-07 10:23 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 5:53 Gokul Praveen
2026-01-07 9:51 ` Uwe Kleine-König
2026-01-07 10:23 ` Gokul Praveen [this message]
2026-01-07 19:47 ` Rafael V. Volkmer
2026-01-08 6:40 ` Gokul Praveen
2026-01-08 18:10 ` Uwe Kleine-König
2026-01-09 5:51 ` Gokul Praveen
2026-01-09 22:53 ` Uwe Kleine-König
2026-01-12 5:51 ` Gokul Praveen
2026-01-12 7:22 ` Uwe Kleine-König
2026-01-19 15:00 ` Kumar, Udit
2026-01-19 21:33 ` Uwe Kleine-König
2026-01-20 4:40 ` Kumar, Udit
2026-01-20 5:53 ` Gokul Praveen
2026-01-20 8:23 ` Uwe Kleine-König
2026-01-20 8:34 ` Gokul Praveen
2026-01-15 10:32 ` Gokul Praveen
2026-01-15 17:17 ` Uwe Kleine-König
2026-01-16 8:41 ` Gokul Praveen
2026-01-16 9:10 ` Gokul Praveen
2026-01-19 2:55 ` Rafael V. Volkmer
2026-01-19 6:48 ` Gokul Praveen
2026-01-15 5:20 ` Kumar, Udit
2026-01-15 6:14 ` Gokul Praveen
2026-01-15 7:46 ` Kumar, Udit
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=60ef0a6d-f4f5-41ea-899c-e353ec9c1c8c@ti.com \
--to=g-praveen@ti.com \
--cc=j-keerthy@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=n-francis@ti.com \
--cc=rafael.v.volkmer@gmail.com \
--cc=u-kumar1@ti.com \
--cc=ukleinek@kernel.org \
/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®