From: Caesar Wang <caesar.upstream@gmail.com>
To: Douglas Anderson <dianders@chromium.org>,
Mark Brown <broonie@kernel.org>
Cc: boris.brezillon@free-electrons.com,
Heiko Stuebner <heiko@sntech.de>,
linux-kernel@vger.kernel.org, briannorris@chromium.org,
lgirdwood@gmail.com, linux-rockchip@lists.infradead.org,
lee.jones@linaro.org
Subject: Re: [PATCH] regulator: pwm: Fix regulator ramp delay for continuous mode
Date: Tue, 28 Jun 2016 18:32:24 +0800 [thread overview]
Message-ID: <57725238.9010809@gmail.com> (raw)
In-Reply-To: <1467089591-7631-1-git-send-email-dianders@chromium.org>
On 2016年06月28日 12:53, Douglas Anderson wrote:
> The original commit adding support for continuous voltage mode didn't
> handle the regulator ramp delay properly. It treated the delay as a
> fixed delay in uS despite the property being defined as uV / uS. Let's
> adjust it. Luckily there appear to be no users of this ramp delay for
> PWM regulators (as per grepping through device trees in linuxnext).
>
> Note also that the upper bound of usleep_range probably shouldn't be a
> full 1 ms longer than the lower bound since I've seen plenty of hardware
> with a ramp rate of ~5000 uS / uV and for small jumps the total delays
> are in the tens of uS. 1000 is way too much. We'll try to be dynamic
> and use 10%
I'm agree with the dynamic and use 10%.
>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Caesar Wang <wxt@rock-chips.com>
Tested for my rk3399 board. That's still happy work for my board.
..
[ 2891.541958] pwm_regulator_set_voltage: delay=38, min-v=800000,
old-v=1024000
[ 2898.188785] pwm_regulator_set_voltage: delay=13, min-v=875000,
old-v=800000
[ 2898.211873] pwm_regulator_set_voltage: delay=8, min-v=925000,
old-v=877000
[ 2898.312026] pwm_regulator_set_voltage: delay=21, min-v=-800000,
old-v=926000
..
> ---
> Note that this patch is atop Boris's recent PWM regulator fixes. If
> desired it wouldn't be too hard to write it atop the old code, though
> quite honestly anyone using a PWM regulator should probably be using his
> new code.
>
> drivers/regulator/pwm-regulator.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
> index fa1c74c77bb0..de94d19f6e1f 100644
> --- a/drivers/regulator/pwm-regulator.c
> +++ b/drivers/regulator/pwm-regulator.c
> @@ -188,6 +188,7 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
> struct pwm_state pstate;
> unsigned int diff_duty;
> unsigned int dutycycle;
> + int old_uV = pwm_regulator_get_voltage(rdev);
> int ret;
>
> pwm_init_state(drvdata->pwm, &pstate);
> @@ -219,8 +220,12 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
> return ret;
> }
>
> - /* Delay required by PWM regulator to settle to the new voltage */
> - usleep_range(ramp_delay, ramp_delay + 1000);
> + if (ramp_delay == 0)
> + return 0;
> +
> + /* Ramp delay is in uV/uS. Adjust to uS and delay */
> + ramp_delay = DIV_ROUND_UP(abs(req_min_uV - old_uV), ramp_delay);
> + usleep_range(ramp_delay, ramp_delay + DIV_ROUND_UP(ramp_delay, 10));
>
> return 0;
> }
next prev parent reply other threads:[~2016-06-28 10:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-28 4:53 [PATCH] regulator: pwm: Fix regulator ramp delay for continuous mode Douglas Anderson
2016-06-28 10:32 ` Caesar Wang [this message]
[not found] ` <1467089591-7631-1-git-send-email-dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2016-06-28 16:07 ` Brian Norris
2016-06-28 18:56 ` Mark Brown
[not found] ` <20160628185656.GU17217-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-06-28 19:35 ` Doug Anderson
2016-06-28 18:52 ` Mark Brown
[not found] ` <20160628185244.GT17217-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-06-28 19:31 ` Doug Anderson
[not found] ` <CAD=FV=UNMhDYy3r+4a4FF8Ndwt+qNuV7_pOC=kzoaUxLfYYp4Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-06-28 19:53 ` Mark Brown
2016-07-01 8:06 ` Mark Brown
[not found] ` <20160701080614.GA9196-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-07-01 20:17 ` Doug Anderson
[not found] ` <CAD=FV=WKR_Fq6o34886RCY-T-6AKdRqFz9H1aTiRq7Zu=o8TWA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-02 7:59 ` Mark Brown
2016-07-06 18:30 ` Doug Anderson
2016-07-07 8:17 ` Mark Brown
2016-07-02 15:47 ` Boris Brezillon
2016-07-04 8:53 ` Mark Brown
[not found] ` <20160704085336.GT6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-07-04 9:05 ` Boris Brezillon
2016-07-04 9:13 ` Mark Brown
2016-07-08 16:41 ` Thierry Reding
2016-07-06 12:27 ` Boris Brezillon
2016-07-06 18:31 ` Doug Anderson
2016-07-07 8:16 ` Mark Brown
2016-07-07 8:03 ` Mark Brown
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=57725238.9010809@gmail.com \
--to=caesar.upstream@gmail.com \
--cc=boris.brezillon@free-electrons.com \
--cc=briannorris@chromium.org \
--cc=broonie@kernel.org \
--cc=dianders@chromium.org \
--cc=heiko@sntech.de \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).