From: "Tanwar, Rahul" <rahul.tanwar@linux.intel.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: linux-pwm@vger.kernel.org, thierry.reding@gmail.com,
p.zabel@pengutronix.de, robh+dt@kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
andriy.shevchenko@intel.com, songjun.Wu@intel.com,
cheol.yong.kim@intel.com, qi-ming.wu@intel.com,
rahul.tanwar.linux@gmail.com
Subject: Re: [PATCH v5 2/2] Add PWM fan controller driver for LGM SoC
Date: Mon, 27 Jul 2020 15:30:16 +0800 [thread overview]
Message-ID: <70fde2ba-b38f-a0d6-bc2d-89c074afd466@linux.intel.com> (raw)
In-Reply-To: <20200727070126.2juwfmra3i67lxfw@pengutronix.de>
Hi Uwe,
On 27/7/2020 3:01 pm, Uwe Kleine-König wrote:
> On Mon, Jul 27, 2020 at 02:04:56PM +0800, Tanwar, Rahul wrote:
>> Hi Uwe,
>>
>> On 24/7/2020 12:15 am, Uwe Kleine-König wrote:
>>> Hello,
>>>
>>> On Thu, Jul 23, 2020 at 03:44:18PM +0800, Rahul Tanwar wrote:
>>>> +static int lgm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>>>> + const struct pwm_state *state)
>>>> +{
>>>> + struct lgm_pwm_chip *pc = to_lgm_pwm_chip(chip);
>>>> + u32 duty_cycle, val;
>>>> + int ret;
>>>> +
>>>> + if (!state->enabled) {
>>>> + ret = lgm_pwm_enable(chip, 0);
>>>> + return ret;
>>>> + }
>>>> +
>>>> + /*
>>>> + * HW only supports NORMAL polarity
>>>> + * HW supports fixed period which can not be changed/configured by user
>>>> + */
>>>> + if (state->polarity != PWM_POLARITY_NORMAL ||
>>>> + state->period != pc->period)
>>>> + return -EINVAL;
>>> At least for state->polarity you have to check before state->enabled, as
>>> the expectation on
>>>
>>> .enabled = false
>>> .polarity = PWM_POLARITY_INVERSED
>>>
>>> is that the output becomes constant high. Also as confirmed at the end
>>> of v4, state->period < pc->period was the right check to do.
>> For below case:
>>
>> .enabled = false
>> .polarity = PWM_POLARITY_INVERSED
>>
>> Since our HW does not support inversed polarity, the output for above case
>> is expected to be constant low. And if we disable PWM before checking for
>> polarity, the output becomes constant low. The code just does that. Sorry,
>> i could not understand what is wrong with the code. It looks correct to me.
> As your hardware can only support normal polarity, the code must have:
>
> if (state->polarity != PWM_POLARITY_NORMAL)
> return -EINVAL;
>
> if (!state->enabled) {
> ret = lgm_pwm_enable(chip, 0);
> return ret;
> }
>
> That's what I meant writing: "At least for state->polarity you have to
> check before state->enabled".
Ok, i understand your point now.
>> Given the fact that we support fixed period, if we allow
>> state->period < pc->period case then the duty cycle will be evaluated as
>> higher than the requested one because the state->period is lesser than
>> the actual fixed period supported by the HW. Can you please elaborate
>> on why you think we should allow state->period < pc->period case?
> You should not allow it. In v4 you had:
>
> if (state->polarity != PWM_POLARITY_NORMAL ||
> state->period < pc->period)
> return -EINVAL;
>
> That's the right thing to do (even though I was unsettled at one point
> and wrote it was wrong). The check in v5 with state->period !=
> pc->period is wrong.
>
Does that mean we should allow state->period >= pc->period cases?
If the state->period is greater than HW supported pc->period and
if we allow it then the duty cycle will again be evaluated to be
incorrect/higher than requested duty cycle. Am i missing something
else? Thanks.
Regards,
Rahul
next prev parent reply other threads:[~2020-07-27 7:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-23 7:44 [PATCH v5 0/2] pwm: intel: Add PWM driver for a new SoC Rahul Tanwar
[not found] ` <cover.1595489518.git.rahul.tanwar-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2020-07-23 7:44 ` [PATCH v5 1/2] Add DT bindings YAML schema for PWM fan controller of LGM SoC Rahul Tanwar
[not found] ` <4e975206fcbddedc746e8d39b620336d5fab8b14.1595489518.git.rahul.tanwar-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2020-07-23 15:42 ` Rob Herring
2020-07-23 7:44 ` [PATCH v5 2/2] Add PWM fan controller driver for " Rahul Tanwar
2020-07-23 16:15 ` Uwe Kleine-König
2020-07-27 6:04 ` Tanwar, Rahul
2020-07-27 7:01 ` Uwe Kleine-König
2020-07-27 7:30 ` Tanwar, Rahul [this message]
2020-07-27 20:00 ` Uwe Kleine-König
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=70fde2ba-b38f-a0d6-bc2d-89c074afd466@linux.intel.com \
--to=rahul.tanwar@linux.intel.com \
--cc=andriy.shevchenko@intel.com \
--cc=cheol.yong.kim@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=qi-ming.wu@intel.com \
--cc=rahul.tanwar.linux@gmail.com \
--cc=robh+dt@kernel.org \
--cc=songjun.Wu@intel.com \
--cc=thierry.reding@gmail.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;
as well as URLs for NNTP newsgroup(s).