Thread (37 messages) 37 messages, 5 authors, 2016-06-07

[PATCH 10/14] regulator: pwm: Switch to the atomic PWM API

From: ldewangan@nvidia.com (Laxman Dewangan)
Date: 2016-06-06 06:27:48
Also in: linux-devicetree, linux-pwm, linux-rockchip, lkml

On Saturday 04 June 2016 11:58 AM, Boris Brezillon wrote:
On Fri, 3 Jun 2016 13:50:28 -0700
Brian Norris [off-list ref] wrote:
quoted
+ Laxman

Hi,

On Fri, Jun 03, 2016 at 10:23:08AM +0200, Boris Brezillon wrote:
quoted
-	 * 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@nvidia.com>



Thanks,
Laxman
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help