[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 6 Jun 2016 11:44:59 +0530
From: Laxman Dewangan <ldewangan@...dia.com>
To: Boris Brezillon <boris.brezillon@...e-electrons.com>,
Brian Norris <briannorris@...omium.org>
CC: Thierry Reding <thierry.reding@...il.com>,
<linux-pwm@...r.kernel.org>, Mark Brown <broonie@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
Heiko Stuebner <heiko@...ech.de>,
<linux-rockchip@...ts.infradead.org>,
Rob Herring <robh+dt@...nel.org>,
Pawel Moll <pawel.moll@....com>,
Mark Rutland <mark.rutland@....com>,
Ian Campbell <ijc+devicetree@...lion.org.uk>,
Kumar Gala <galak@...eaurora.org>,
<devicetree@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, Milo Kim <milo.kim@...com>,
Doug Anderson <dianders@...gle.com>,
Caesar Wang <wxt@...k-chips.com>,
Stephen Barber <smbarber@...omium.org>,
Srinivas Kandagatla <srinivas.kandagatla@...il.com>,
Maxime Coquelin <maxime.coquelin@...com>,
Patrice Chotard <patrice.chotard@...com>, <kernel@...inux.com>
Subject: Re: [PATCH 10/14] regulator: pwm: Switch to the atomic PWM API
On Saturday 04 June 2016 11:58 AM, Boris Brezillon wrote:
> On Fri, 3 Jun 2016 13:50:28 -0700
> Brian Norris <briannorris@...omium.org> wrote:
>
>> + Laxman
>>
>> Hi,
>>
>> On Fri, Jun 03, 2016 at 10:23:08AM +0200, Boris Brezillon wrote:
>>> - * calculation loss.
>>> - */
>>> - req_period = req_diff * pargs.period;
>>> - div_u64_rem(req_period, diff, &rem);
>>> - if (!rem) {
>>> - do_div(req_period, diff);
>>> - duty_pulse = (unsigned int)req_period;
>>> - } else {
>>> - duty_pulse = (pargs.period / 100) * ((req_diff * 100) / diff);
>>> - }
>>> + /* We pass diff as the scale to get a uV precision. */
>>> + pwm_set_relative_duty_cycle(&pstate, req_diff, diff);
>> Notably, you're dropping much of Laxman's commit fd786fb0276a ("regulator:
>> pwm: Try to avoid voltage error in duty cycle calculation"), but I
>> believe the DIV_ROUND_CLOSEST_ULL() in pwm_set_relative_duty_cycle()
>> solves his problem better.
> Oops, forgot to comment on that in the commit message. Indeed, the use
> of pwm_set_relative_duty_cycle() solves the problem Laxman was seeing.
>
Yaah, the issue which I was seeing and had fix will be resolved with
this also.
I wanted to do req_diff * period first before any scaling/division.
Function pwm_set_relative_duty_cycle() does the same, and hence it is fine.
state->duty_cycle = DIV_ROUND_CLOSEST_ULL((u64)val * state->period,
+ scale);
Acked-by: Laxman Dewangan <ldewangan@...dia.com>
Thanks,
Laxman
Powered by blists - more mailing lists