linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: manual merge of the pwm tree with the regulator tree
@ 2016-07-11  6:56 Stephen Rothwell
  2016-07-11 16:47 ` Doug Anderson
  0 siblings, 1 reply; 10+ messages in thread
From: Stephen Rothwell @ 2016-07-11  6:56 UTC (permalink / raw)
  To: Thierry Reding, Mark Brown, Liam Girdwood
  Cc: linux-next, linux-kernel, Boris Brezillon, Alexandre Courbot,
	Douglas Anderson

Hi Thierry,

Today's linux-next merge of the pwm tree got a conflict in:

  drivers/regulator/pwm-regulator.c

between commit:

  830583004e61 ("regulator: pwm: Drop unneeded pwm_enable() call")
  27bfa8893b15 ("regulator: pwm: Support for enable GPIO")
  c2588393e631 ("regulator: pwm: Fix regulator ramp delay for continuous mode")

from the regulator tree and commit:

  b0303deaa480 ("regulator: pwm: Adjust PWM config at probe time")
  8bd57ca236d0 ("regulator: pwm: Switch to the atomic PWM API")
  25d16595935b ("regulator: pwm: Retrieve correct voltage")
  53f239af4c14 ("regulator: pwm: Support extra continuous mode cases")

from the pwm tree.

I fixed it up (I think, please check - see below) and can carry the fix
as necessary. This is now fixed as far as linux-next is concerned, but
any non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging.  You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/regulator/pwm-regulator.c
index 666bc3bb52ef,a8e9147dd8db..000000000000
--- a/drivers/regulator/pwm-regulator.c
+++ b/drivers/regulator/pwm-regulator.c
@@@ -20,8 -20,13 +20,14 @@@
  #include <linux/of.h>
  #include <linux/of_device.h>
  #include <linux/pwm.h>
 +#include <linux/gpio/consumer.h>
  
+ struct pwm_continuous_reg_data {
+ 	unsigned int min_uV_dutycycle;
+ 	unsigned int max_uV_dutycycle;
+ 	unsigned int dutycycle_unit;
+ };
+ 
  struct pwm_regulator_data {
  	/*  Shared */
  	struct pwm_device *pwm;
@@@ -36,12 -44,6 +45,9 @@@
  	struct regulator_ops ops;
  
  	int state;
 +
- 	/* Continuous voltage */
- 	int volt_uV;
- 
 +	/* Enable GPIO */
 +	struct gpio_desc *enb_gpio;
  };
  
  struct pwm_voltages {
@@@ -134,53 -174,59 +187,58 @@@ static int pwm_regulator_get_voltage(st
  }
  
  static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
- 					int min_uV, int max_uV,
- 					unsigned *selector)
+ 				     int req_min_uV, int req_max_uV,
+ 				     unsigned int *selector)
  {
  	struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev);
+ 	unsigned int min_uV_duty = drvdata->continuous.min_uV_dutycycle;
+ 	unsigned int max_uV_duty = drvdata->continuous.max_uV_dutycycle;
+ 	unsigned int duty_unit = drvdata->continuous.dutycycle_unit;
  	unsigned int ramp_delay = rdev->constraints->ramp_delay;
- 	struct pwm_args pargs;
- 	unsigned int req_diff = min_uV - rdev->constraints->min_uV;
- 	unsigned int diff;
- 	unsigned int duty_pulse;
- 	u64 req_period;
- 	u32 rem;
+ 	int min_uV = rdev->constraints->min_uV;
+ 	int max_uV = rdev->constraints->max_uV;
+ 	int diff_uV = max_uV - min_uV;
+ 	struct pwm_state pstate;
+ 	unsigned int diff_duty;
+ 	unsigned int dutycycle;
 +	int old_uV = pwm_regulator_get_voltage(rdev);
  	int ret;
  
- 	pwm_get_args(drvdata->pwm, &pargs);
- 	diff = rdev->constraints->max_uV - rdev->constraints->min_uV;
+ 	pwm_init_state(drvdata->pwm, &pstate);
  
- 	/* First try to find out if we get the iduty cycle time which is
- 	 * factor of PWM period time. If (request_diff_to_min * pwm_period)
- 	 * is perfect divided by voltage_range_diff then it is possible to
- 	 * get duty cycle time which is factor of PWM period. This will help
- 	 * to get output voltage nearer to requested value as there is no
- 	 * calculation loss.
+ 	/*
+ 	 * The dutycycle for min_uV might be greater than the one for max_uV.
+ 	 * This is happening when the user needs an inversed polarity, but the
+ 	 * PWM device does not support inversing it in hardware.
  	 */
- 	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);
- 	}
+ 	if (max_uV_duty < min_uV_duty)
+ 		diff_duty = min_uV_duty - max_uV_duty;
+ 	else
+ 		diff_duty = max_uV_duty - min_uV_duty;
+ 
+ 	dutycycle = DIV_ROUND_CLOSEST_ULL((u64)(req_min_uV - min_uV) *
+ 					  diff_duty,
+ 					  diff_uV);
+ 
+ 	if (max_uV_duty < min_uV_duty)
+ 		dutycycle = min_uV_duty - dutycycle;
+ 	else
+ 		dutycycle = min_uV_duty + dutycycle;
+ 
+ 	pwm_set_relative_duty_cycle(&pstate, dutycycle, duty_unit);
  
- 	ret = pwm_config(drvdata->pwm, duty_pulse, pargs.period);
+ 	ret = pwm_apply_state(drvdata->pwm, &pstate);
  	if (ret) {
  		dev_err(&rdev->dev, "Failed to configure PWM: %d\n", ret);
  		return ret;
  	}
  
- 	drvdata->volt_uV = min_uV;
- 
 -	ret = pwm_enable(drvdata->pwm);
 -	if (ret) {
 -		dev_err(&rdev->dev, "Failed to enable PWM: %d\n", ret);
 -		return ret;
 -	}
 +	if ((ramp_delay == 0) || !pwm_regulator_is_enabled(rdev))
 +		return 0;
  
 -	/* Delay required by PWM regulator to settle to the new voltage */
 -	usleep_range(ramp_delay, ramp_delay + 1000);
 +	/* Ramp delay is in uV/uS. Adjust to uS and delay */
 +	ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_delay);
 +	usleep_range(ramp_delay, ramp_delay + DIV_ROUND_UP(ramp_delay, 10));
  
  	return 0;
  }
@@@ -304,23 -367,9 +380,21 @@@ static int pwm_regulator_probe(struct p
  		return ret;
  	}
  
 +	if (init_data->constraints.boot_on || init_data->constraints.always_on)
 +		gpio_flags = GPIOD_OUT_HIGH;
 +	else
 +		gpio_flags = GPIOD_OUT_LOW;
 +	drvdata->enb_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
 +						    gpio_flags);
 +	if (IS_ERR(drvdata->enb_gpio)) {
 +		ret = PTR_ERR(drvdata->enb_gpio);
 +		dev_err(&pdev->dev, "Failed to get enable GPIO: %d\n", ret);
 +		return ret;
 +	}
 +
- 	/*
- 	 * FIXME: pwm_apply_args() should be removed when switching to the
- 	 * atomic PWM API.
- 	 */
- 	pwm_apply_args(drvdata->pwm);
+ 	ret = pwm_adjust_config(drvdata->pwm);
+ 	if (ret)
+ 		return ret;
  
  	regulator = devm_regulator_register(&pdev->dev,
  					    &drvdata->desc, &config);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: linux-next: manual merge of the pwm tree with the regulator tree
  2016-07-11  6:56 linux-next: manual merge of the pwm tree with the regulator tree Stephen Rothwell
@ 2016-07-11 16:47 ` Doug Anderson
  2016-07-11 21:30   ` Thierry Reding
  0 siblings, 1 reply; 10+ messages in thread
From: Doug Anderson @ 2016-07-11 16:47 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Thierry Reding, Mark Brown, Liam Girdwood, linux-next,
	linux-kernel, Boris Brezillon, Alexandre Courbot

Hi,

On Sun, Jul 10, 2016 at 11:56 PM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> Hi Thierry,
>
> Today's linux-next merge of the pwm tree got a conflict in:
>
>   drivers/regulator/pwm-regulator.c
>
> between commit:
>
>   830583004e61 ("regulator: pwm: Drop unneeded pwm_enable() call")
>   27bfa8893b15 ("regulator: pwm: Support for enable GPIO")
>   c2588393e631 ("regulator: pwm: Fix regulator ramp delay for continuous mode")
>
> from the regulator tree and commit:
>
>   b0303deaa480 ("regulator: pwm: Adjust PWM config at probe time")
>   8bd57ca236d0 ("regulator: pwm: Switch to the atomic PWM API")
>   25d16595935b ("regulator: pwm: Retrieve correct voltage")
>   53f239af4c14 ("regulator: pwm: Support extra continuous mode cases")
>
> from the pwm tree.
>
> I fixed it up (I think, please check - see below) and can carry the fix
> as necessary. This is now fixed as far as linux-next is concerned, but
> any non trivial conflicts should be mentioned to your upstream maintainer
> when your tree is submitted for merging.  You may also want to consider
> cooperating with the maintainer of the conflicting tree to minimise any
> particularly complex conflicts.
>
> --
> Cheers,
> Stephen Rothwell

[ cut ]

>  -      /* Delay required by PWM regulator to settle to the new voltage */
>  -      usleep_range(ramp_delay, ramp_delay + 1000);
>  +      /* Ramp delay is in uV/uS. Adjust to uS and delay */
>  +      ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_delay);

This was what I was worried about and why I originally sent my patch
based upon Boris's series.  The above should be:

ramp_delay = DIV_ROUND_UP(abs(req_min_uV - old_uV), ramp_delay);

Specifically note the use of "req_min_uV" and not "min_uV".


-Doug

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: linux-next: manual merge of the pwm tree with the regulator tree
  2016-07-11 16:47 ` Doug Anderson
@ 2016-07-11 21:30   ` Thierry Reding
  2016-07-11 21:39     ` Thierry Reding
  0 siblings, 1 reply; 10+ messages in thread
From: Thierry Reding @ 2016-07-11 21:30 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Stephen Rothwell, Mark Brown, Liam Girdwood, linux-next,
	linux-kernel, Boris Brezillon, Alexandre Courbot

[-- Attachment #1: Type: text/plain, Size: 2136 bytes --]

On Mon, Jul 11, 2016 at 09:47:34AM -0700, Doug Anderson wrote:
> Hi,
> 
> On Sun, Jul 10, 2016 at 11:56 PM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> > Hi Thierry,
> >
> > Today's linux-next merge of the pwm tree got a conflict in:
> >
> >   drivers/regulator/pwm-regulator.c
> >
> > between commit:
> >
> >   830583004e61 ("regulator: pwm: Drop unneeded pwm_enable() call")
> >   27bfa8893b15 ("regulator: pwm: Support for enable GPIO")
> >   c2588393e631 ("regulator: pwm: Fix regulator ramp delay for continuous mode")
> >
> > from the regulator tree and commit:
> >
> >   b0303deaa480 ("regulator: pwm: Adjust PWM config at probe time")
> >   8bd57ca236d0 ("regulator: pwm: Switch to the atomic PWM API")
> >   25d16595935b ("regulator: pwm: Retrieve correct voltage")
> >   53f239af4c14 ("regulator: pwm: Support extra continuous mode cases")
> >
> > from the pwm tree.
> >
> > I fixed it up (I think, please check - see below) and can carry the fix
> > as necessary. This is now fixed as far as linux-next is concerned, but
> > any non trivial conflicts should be mentioned to your upstream maintainer
> > when your tree is submitted for merging.  You may also want to consider
> > cooperating with the maintainer of the conflicting tree to minimise any
> > particularly complex conflicts.
> >
> > --
> > Cheers,
> > Stephen Rothwell
> 
> [ cut ]
> 
> >  -      /* Delay required by PWM regulator to settle to the new voltage */
> >  -      usleep_range(ramp_delay, ramp_delay + 1000);
> >  +      /* Ramp delay is in uV/uS. Adjust to uS and delay */
> >  +      ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_delay);
> 
> This was what I was worried about and why I originally sent my patch
> based upon Boris's series.  The above should be:
> 
> ramp_delay = DIV_ROUND_UP(abs(req_min_uV - old_uV), ramp_delay);
> 
> Specifically note the use of "req_min_uV" and not "min_uV".

Okay, so this is something that needs to be fixed up in one of Boris'
patches? Can you help point out where exactly? The conflict should be
gone as of tomorrow's linux-next.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: linux-next: manual merge of the pwm tree with the regulator tree
  2016-07-11 21:30   ` Thierry Reding
@ 2016-07-11 21:39     ` Thierry Reding
  2016-07-25  8:29       ` Thierry Reding
  0 siblings, 1 reply; 10+ messages in thread
From: Thierry Reding @ 2016-07-11 21:39 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Stephen Rothwell, Mark Brown, Liam Girdwood, linux-next,
	linux-kernel, Boris Brezillon, Alexandre Courbot

[-- Attachment #1: Type: text/plain, Size: 3052 bytes --]

On Mon, Jul 11, 2016 at 11:30:59PM +0200, Thierry Reding wrote:
> On Mon, Jul 11, 2016 at 09:47:34AM -0700, Doug Anderson wrote:
> > Hi,
> > 
> > On Sun, Jul 10, 2016 at 11:56 PM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> > > Hi Thierry,
> > >
> > > Today's linux-next merge of the pwm tree got a conflict in:
> > >
> > >   drivers/regulator/pwm-regulator.c
> > >
> > > between commit:
> > >
> > >   830583004e61 ("regulator: pwm: Drop unneeded pwm_enable() call")
> > >   27bfa8893b15 ("regulator: pwm: Support for enable GPIO")
> > >   c2588393e631 ("regulator: pwm: Fix regulator ramp delay for continuous mode")
> > >
> > > from the regulator tree and commit:
> > >
> > >   b0303deaa480 ("regulator: pwm: Adjust PWM config at probe time")
> > >   8bd57ca236d0 ("regulator: pwm: Switch to the atomic PWM API")
> > >   25d16595935b ("regulator: pwm: Retrieve correct voltage")
> > >   53f239af4c14 ("regulator: pwm: Support extra continuous mode cases")
> > >
> > > from the pwm tree.
> > >
> > > I fixed it up (I think, please check - see below) and can carry the fix
> > > as necessary. This is now fixed as far as linux-next is concerned, but
> > > any non trivial conflicts should be mentioned to your upstream maintainer
> > > when your tree is submitted for merging.  You may also want to consider
> > > cooperating with the maintainer of the conflicting tree to minimise any
> > > particularly complex conflicts.
> > >
> > > --
> > > Cheers,
> > > Stephen Rothwell
> > 
> > [ cut ]
> > 
> > >  -      /* Delay required by PWM regulator to settle to the new voltage */
> > >  -      usleep_range(ramp_delay, ramp_delay + 1000);
> > >  +      /* Ramp delay is in uV/uS. Adjust to uS and delay */
> > >  +      ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_delay);
> > 
> > This was what I was worried about and why I originally sent my patch
> > based upon Boris's series.  The above should be:
> > 
> > ramp_delay = DIV_ROUND_UP(abs(req_min_uV - old_uV), ramp_delay);
> > 
> > Specifically note the use of "req_min_uV" and not "min_uV".
> 
> Okay, so this is something that needs to be fixed up in one of Boris'
> patches? Can you help point out where exactly? The conflict should be
> gone as of tomorrow's linux-next.

Looks like the below should be squashed into commit:

	4585082afab4 regulator: pwm: Support extra continuous mode cases

Can you confirm?

Thierry

--- >8 ---
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
index 263a2d16d909..c24524242da2 100644
--- a/drivers/regulator/pwm-regulator.c
+++ b/drivers/regulator/pwm-regulator.c
@@ -237,7 +237,7 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
 		return 0;
 
 	/* Ramp delay is in uV/uS. Adjust to uS and delay */
-	ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_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;

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: linux-next: manual merge of the pwm tree with the regulator tree
  2016-07-11 21:39     ` Thierry Reding
@ 2016-07-25  8:29       ` Thierry Reding
  2016-07-25 13:29         ` Doug Anderson
  0 siblings, 1 reply; 10+ messages in thread
From: Thierry Reding @ 2016-07-25  8:29 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Stephen Rothwell, Mark Brown, Liam Girdwood, linux-next,
	linux-kernel, Boris Brezillon, Alexandre Courbot

[-- Attachment #1: Type: text/plain, Size: 3308 bytes --]

On Mon, Jul 11, 2016 at 11:39:00PM +0200, Thierry Reding wrote:
> On Mon, Jul 11, 2016 at 11:30:59PM +0200, Thierry Reding wrote:
> > On Mon, Jul 11, 2016 at 09:47:34AM -0700, Doug Anderson wrote:
> > > Hi,
> > > 
> > > On Sun, Jul 10, 2016 at 11:56 PM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> > > > Hi Thierry,
> > > >
> > > > Today's linux-next merge of the pwm tree got a conflict in:
> > > >
> > > >   drivers/regulator/pwm-regulator.c
> > > >
> > > > between commit:
> > > >
> > > >   830583004e61 ("regulator: pwm: Drop unneeded pwm_enable() call")
> > > >   27bfa8893b15 ("regulator: pwm: Support for enable GPIO")
> > > >   c2588393e631 ("regulator: pwm: Fix regulator ramp delay for continuous mode")
> > > >
> > > > from the regulator tree and commit:
> > > >
> > > >   b0303deaa480 ("regulator: pwm: Adjust PWM config at probe time")
> > > >   8bd57ca236d0 ("regulator: pwm: Switch to the atomic PWM API")
> > > >   25d16595935b ("regulator: pwm: Retrieve correct voltage")
> > > >   53f239af4c14 ("regulator: pwm: Support extra continuous mode cases")
> > > >
> > > > from the pwm tree.
> > > >
> > > > I fixed it up (I think, please check - see below) and can carry the fix
> > > > as necessary. This is now fixed as far as linux-next is concerned, but
> > > > any non trivial conflicts should be mentioned to your upstream maintainer
> > > > when your tree is submitted for merging.  You may also want to consider
> > > > cooperating with the maintainer of the conflicting tree to minimise any
> > > > particularly complex conflicts.
> > > >
> > > > --
> > > > Cheers,
> > > > Stephen Rothwell
> > > 
> > > [ cut ]
> > > 
> > > >  -      /* Delay required by PWM regulator to settle to the new voltage */
> > > >  -      usleep_range(ramp_delay, ramp_delay + 1000);
> > > >  +      /* Ramp delay is in uV/uS. Adjust to uS and delay */
> > > >  +      ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_delay);
> > > 
> > > This was what I was worried about and why I originally sent my patch
> > > based upon Boris's series.  The above should be:
> > > 
> > > ramp_delay = DIV_ROUND_UP(abs(req_min_uV - old_uV), ramp_delay);
> > > 
> > > Specifically note the use of "req_min_uV" and not "min_uV".
> > 
> > Okay, so this is something that needs to be fixed up in one of Boris'
> > patches? Can you help point out where exactly? The conflict should be
> > gone as of tomorrow's linux-next.
> 
> Looks like the below should be squashed into commit:
> 
> 	4585082afab4 regulator: pwm: Support extra continuous mode cases
> 
> Can you confirm?
> 
> Thierry
> 
> --- >8 ---
> diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
> index 263a2d16d909..c24524242da2 100644
> --- a/drivers/regulator/pwm-regulator.c
> +++ b/drivers/regulator/pwm-regulator.c
> @@ -237,7 +237,7 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
>  		return 0;
>  
>  	/* Ramp delay is in uV/uS. Adjust to uS and delay */
> -	ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_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;

Doug? Can you confirm?

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: linux-next: manual merge of the pwm tree with the regulator tree
  2016-07-25  8:29       ` Thierry Reding
@ 2016-07-25 13:29         ` Doug Anderson
  2016-07-25 14:26           ` Thierry Reding
  0 siblings, 1 reply; 10+ messages in thread
From: Doug Anderson @ 2016-07-25 13:29 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Stephen Rothwell, Mark Brown, Liam Girdwood, linux-next,
	linux-kernel, Boris Brezillon, Alexandre Courbot

Hi,

On Mon, Jul 25, 2016 at 1:29 AM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> On Mon, Jul 11, 2016 at 11:39:00PM +0200, Thierry Reding wrote:
>> On Mon, Jul 11, 2016 at 11:30:59PM +0200, Thierry Reding wrote:
>> > On Mon, Jul 11, 2016 at 09:47:34AM -0700, Doug Anderson wrote:
>> > > Hi,
>> > >
>> > > On Sun, Jul 10, 2016 at 11:56 PM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>> > > > Hi Thierry,
>> > > >
>> > > > Today's linux-next merge of the pwm tree got a conflict in:
>> > > >
>> > > >   drivers/regulator/pwm-regulator.c
>> > > >
>> > > > between commit:
>> > > >
>> > > >   830583004e61 ("regulator: pwm: Drop unneeded pwm_enable() call")
>> > > >   27bfa8893b15 ("regulator: pwm: Support for enable GPIO")
>> > > >   c2588393e631 ("regulator: pwm: Fix regulator ramp delay for continuous mode")
>> > > >
>> > > > from the regulator tree and commit:
>> > > >
>> > > >   b0303deaa480 ("regulator: pwm: Adjust PWM config at probe time")
>> > > >   8bd57ca236d0 ("regulator: pwm: Switch to the atomic PWM API")
>> > > >   25d16595935b ("regulator: pwm: Retrieve correct voltage")
>> > > >   53f239af4c14 ("regulator: pwm: Support extra continuous mode cases")
>> > > >
>> > > > from the pwm tree.
>> > > >
>> > > > I fixed it up (I think, please check - see below) and can carry the fix
>> > > > as necessary. This is now fixed as far as linux-next is concerned, but
>> > > > any non trivial conflicts should be mentioned to your upstream maintainer
>> > > > when your tree is submitted for merging.  You may also want to consider
>> > > > cooperating with the maintainer of the conflicting tree to minimise any
>> > > > particularly complex conflicts.
>> > > >
>> > > > --
>> > > > Cheers,
>> > > > Stephen Rothwell
>> > >
>> > > [ cut ]
>> > >
>> > > >  -      /* Delay required by PWM regulator to settle to the new voltage */
>> > > >  -      usleep_range(ramp_delay, ramp_delay + 1000);
>> > > >  +      /* Ramp delay is in uV/uS. Adjust to uS and delay */
>> > > >  +      ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_delay);
>> > >
>> > > This was what I was worried about and why I originally sent my patch
>> > > based upon Boris's series.  The above should be:
>> > >
>> > > ramp_delay = DIV_ROUND_UP(abs(req_min_uV - old_uV), ramp_delay);
>> > >
>> > > Specifically note the use of "req_min_uV" and not "min_uV".
>> >
>> > Okay, so this is something that needs to be fixed up in one of Boris'
>> > patches? Can you help point out where exactly? The conflict should be
>> > gone as of tomorrow's linux-next.
>>
>> Looks like the below should be squashed into commit:
>>
>>       4585082afab4 regulator: pwm: Support extra continuous mode cases
>>
>> Can you confirm?
>>
>> Thierry
>>
>> --- >8 ---
>> diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
>> index 263a2d16d909..c24524242da2 100644
>> --- a/drivers/regulator/pwm-regulator.c
>> +++ b/drivers/regulator/pwm-regulator.c
>> @@ -237,7 +237,7 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
>>               return 0;
>>
>>       /* Ramp delay is in uV/uS. Adjust to uS and delay */
>> -     ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_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;
>
> Doug? Can you confirm?

Yes, right.  Sorry, previous email got lost in the shuffle since I was
on vacation.

Right, commit 4585082afab4 ("regulator: pwm: Support extra continuous
mode cases") is the one that renamed the parameters and so this use of
one of the parameters needs to be part of that commit.

Thanks!

-Doug

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: linux-next: manual merge of the pwm tree with the regulator tree
  2016-07-25 13:29         ` Doug Anderson
@ 2016-07-25 14:26           ` Thierry Reding
  0 siblings, 0 replies; 10+ messages in thread
From: Thierry Reding @ 2016-07-25 14:26 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Stephen Rothwell, Mark Brown, Liam Girdwood, linux-next,
	linux-kernel, Boris Brezillon, Alexandre Courbot

[-- Attachment #1: Type: text/plain, Size: 4109 bytes --]

On Mon, Jul 25, 2016 at 06:29:00AM -0700, Doug Anderson wrote:
> Hi,
> 
> On Mon, Jul 25, 2016 at 1:29 AM, Thierry Reding
> <thierry.reding@gmail.com> wrote:
> > On Mon, Jul 11, 2016 at 11:39:00PM +0200, Thierry Reding wrote:
> >> On Mon, Jul 11, 2016 at 11:30:59PM +0200, Thierry Reding wrote:
> >> > On Mon, Jul 11, 2016 at 09:47:34AM -0700, Doug Anderson wrote:
> >> > > Hi,
> >> > >
> >> > > On Sun, Jul 10, 2016 at 11:56 PM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> >> > > > Hi Thierry,
> >> > > >
> >> > > > Today's linux-next merge of the pwm tree got a conflict in:
> >> > > >
> >> > > >   drivers/regulator/pwm-regulator.c
> >> > > >
> >> > > > between commit:
> >> > > >
> >> > > >   830583004e61 ("regulator: pwm: Drop unneeded pwm_enable() call")
> >> > > >   27bfa8893b15 ("regulator: pwm: Support for enable GPIO")
> >> > > >   c2588393e631 ("regulator: pwm: Fix regulator ramp delay for continuous mode")
> >> > > >
> >> > > > from the regulator tree and commit:
> >> > > >
> >> > > >   b0303deaa480 ("regulator: pwm: Adjust PWM config at probe time")
> >> > > >   8bd57ca236d0 ("regulator: pwm: Switch to the atomic PWM API")
> >> > > >   25d16595935b ("regulator: pwm: Retrieve correct voltage")
> >> > > >   53f239af4c14 ("regulator: pwm: Support extra continuous mode cases")
> >> > > >
> >> > > > from the pwm tree.
> >> > > >
> >> > > > I fixed it up (I think, please check - see below) and can carry the fix
> >> > > > as necessary. This is now fixed as far as linux-next is concerned, but
> >> > > > any non trivial conflicts should be mentioned to your upstream maintainer
> >> > > > when your tree is submitted for merging.  You may also want to consider
> >> > > > cooperating with the maintainer of the conflicting tree to minimise any
> >> > > > particularly complex conflicts.
> >> > > >
> >> > > > --
> >> > > > Cheers,
> >> > > > Stephen Rothwell
> >> > >
> >> > > [ cut ]
> >> > >
> >> > > >  -      /* Delay required by PWM regulator to settle to the new voltage */
> >> > > >  -      usleep_range(ramp_delay, ramp_delay + 1000);
> >> > > >  +      /* Ramp delay is in uV/uS. Adjust to uS and delay */
> >> > > >  +      ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_delay);
> >> > >
> >> > > This was what I was worried about and why I originally sent my patch
> >> > > based upon Boris's series.  The above should be:
> >> > >
> >> > > ramp_delay = DIV_ROUND_UP(abs(req_min_uV - old_uV), ramp_delay);
> >> > >
> >> > > Specifically note the use of "req_min_uV" and not "min_uV".
> >> >
> >> > Okay, so this is something that needs to be fixed up in one of Boris'
> >> > patches? Can you help point out where exactly? The conflict should be
> >> > gone as of tomorrow's linux-next.
> >>
> >> Looks like the below should be squashed into commit:
> >>
> >>       4585082afab4 regulator: pwm: Support extra continuous mode cases
> >>
> >> Can you confirm?
> >>
> >> Thierry
> >>
> >> --- >8 ---
> >> diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
> >> index 263a2d16d909..c24524242da2 100644
> >> --- a/drivers/regulator/pwm-regulator.c
> >> +++ b/drivers/regulator/pwm-regulator.c
> >> @@ -237,7 +237,7 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
> >>               return 0;
> >>
> >>       /* Ramp delay is in uV/uS. Adjust to uS and delay */
> >> -     ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_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;
> >
> > Doug? Can you confirm?
> 
> Yes, right.  Sorry, previous email got lost in the shuffle since I was
> on vacation.
> 
> Right, commit 4585082afab4 ("regulator: pwm: Support extra continuous
> mode cases") is the one that renamed the parameters and so this use of
> one of the parameters needs to be part of that commit.

Squashed it into the above commit and pushed everything out.

Thanks,
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: linux-next: manual merge of the pwm tree with the regulator tree
  2016-05-03 11:03 ` Mark Brown
@ 2016-05-03 12:18   ` Thierry Reding
  0 siblings, 0 replies; 10+ messages in thread
From: Thierry Reding @ 2016-05-03 12:18 UTC (permalink / raw)
  To: Mark Brown
  Cc: Stephen Rothwell, Liam Girdwood, linux-next, linux-kernel,
	Boris Brezillon, Laxman Dewangan

[-- Attachment #1: Type: text/plain, Size: 873 bytes --]

On Tue, May 03, 2016 at 12:03:43PM +0100, Mark Brown wrote:
> On Tue, May 03, 2016 at 06:25:09PM +1000, Stephen Rothwell wrote:
> 
> > I fixed it up (see below) and can carry the fix as necessary. This
> > is now fixed as far as linux-next is concerned, but any non trivial
> > conflicts should be mentioned to your upstream maintainer when your tree
> > is submitted for merging.  You may also want to consider cooperating
> > with the maintainer of the conflicting tree to minimise any particularly
> > complex conflicts.
> 
> Please send me a pull request for the regulator commits you've added.

I had to reshuffle things a little, but I've new sent out a pull request
for a stable branch that contains the one regulator patch on top of the
shared dependency branch that adds the new struct pwm_args.

Let me know if you need anything else.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: linux-next: manual merge of the pwm tree with the regulator tree
  2016-05-03  8:25 Stephen Rothwell
@ 2016-05-03 11:03 ` Mark Brown
  2016-05-03 12:18   ` Thierry Reding
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2016-05-03 11:03 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Thierry Reding, Liam Girdwood, linux-next, linux-kernel,
	Boris Brezillon, Laxman Dewangan

[-- Attachment #1: Type: text/plain, Size: 519 bytes --]

On Tue, May 03, 2016 at 06:25:09PM +1000, Stephen Rothwell wrote:

> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.

Please send me a pull request for the regulator commits you've added.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* linux-next: manual merge of the pwm tree with the regulator tree
@ 2016-05-03  8:25 Stephen Rothwell
  2016-05-03 11:03 ` Mark Brown
  0 siblings, 1 reply; 10+ messages in thread
From: Stephen Rothwell @ 2016-05-03  8:25 UTC (permalink / raw)
  To: Thierry Reding, Mark Brown, Liam Girdwood
  Cc: linux-next, linux-kernel, Boris Brezillon, Laxman Dewangan

Hi Thierry,

Today's linux-next merge of the pwm tree got a conflict in:

  drivers/regulator/pwm-regulator.c

between commit:

  fd786fb0276a ("regulator: pwm: Try to avoid voltage error in duty cycle calculation")

from the regulator tree and commit:

  f137b90ba6cd ("regulator: pwm: Use pwm_get_args() where appropriate")

from the pwm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/regulator/pwm-regulator.c
index 8e928f23279b,ffdb895ace0a..000000000000
--- a/drivers/regulator/pwm-regulator.c
+++ b/drivers/regulator/pwm-regulator.c
@@@ -63,14 -63,14 +63,14 @@@ static int pwm_regulator_set_voltage_se
  	int dutycycle;
  	int ret;
  
- 	pwm_reg_period = pwm_get_period(drvdata->pwm);
+ 	pwm_get_args(drvdata->pwm, &pargs);
  
- 	dutycycle = (pwm_reg_period *
+ 	dutycycle = (pargs.period *
  		    drvdata->duty_cycle_table[selector].dutycycle) / 100;
  
- 	ret = pwm_config(drvdata->pwm, dutycycle, pwm_reg_period);
+ 	ret = pwm_config(drvdata->pwm, dutycycle, pargs.period);
  	if (ret) {
 -		dev_err(&rdev->dev, "Failed to configure PWM\n");
 +		dev_err(&rdev->dev, "Failed to configure PWM: %d\n", ret);
  		return ret;
  	}
  
@@@ -126,35 -138,17 +126,36 @@@ static int pwm_regulator_set_voltage(st
  {
  	struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev);
  	unsigned int ramp_delay = rdev->constraints->ramp_delay;
- 	unsigned int period = pwm_get_period(drvdata->pwm);
+ 	struct pwm_args pargs;
 -	int duty_cycle;
 +	unsigned int req_diff = min_uV - rdev->constraints->min_uV;
 +	unsigned int diff;
 +	unsigned int duty_pulse;
 +	u64 req_period;
 +	u32 rem;
  	int ret;
  
+ 	pwm_get_args(drvdata->pwm, &pargs);
 -	duty_cycle = pwm_voltage_to_duty_cycle_percentage(rdev, min_uV);
 +	diff = rdev->constraints->max_uV - rdev->constraints->min_uV;
 +
 +	/* First try to find out if we get the iduty cycle time which is
 +	 * factor of PWM period time. If (request_diff_to_min * pwm_period)
 +	 * is perfect divided by voltage_range_diff then it is possible to
 +	 * get duty cycle time which is factor of PWM period. This will help
 +	 * to get output voltage nearer to requested value as there is no
 +	 * calculation loss.
 +	 */
- 	req_period = req_diff * period;
++	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 = (period / 100) * ((req_diff * 100) / diff);
++		duty_pulse = (pargs.period / 100) * ((req_diff * 100) / diff);
 +	}
  
- 	ret = pwm_config(drvdata->pwm, duty_pulse, period);
 -	ret = pwm_config(drvdata->pwm, (pargs.period / 100) * duty_cycle,
 -			 pargs.period);
++	ret = pwm_config(drvdata->pwm, duty_pulse, pargs.period);
  	if (ret) {
 -		dev_err(&rdev->dev, "Failed to configure PWM\n");
 +		dev_err(&rdev->dev, "Failed to configure PWM: %d\n", ret);
  		return ret;
  	}
  
@@@ -284,11 -279,16 +285,17 @@@ static int pwm_regulator_probe(struct p
  
  	drvdata->pwm = devm_pwm_get(&pdev->dev, NULL);
  	if (IS_ERR(drvdata->pwm)) {
 -		dev_err(&pdev->dev, "Failed to get PWM\n");
 -		return PTR_ERR(drvdata->pwm);
 +		ret = PTR_ERR(drvdata->pwm);
 +		dev_err(&pdev->dev, "Failed to get PWM: %d\n", ret);
 +		return ret;
  	}
  
+ 	/*
+ 	 * FIXME: pwm_apply_args() should be removed when switching to the
+ 	 * atomic PWM API.
+ 	 */
+ 	pwm_apply_args(drvdata->pwm);
+ 
  	regulator = devm_regulator_register(&pdev->dev,
  					    &drvdata->desc, &config);
  	if (IS_ERR(regulator)) {

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-07-25 14:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-11  6:56 linux-next: manual merge of the pwm tree with the regulator tree Stephen Rothwell
2016-07-11 16:47 ` Doug Anderson
2016-07-11 21:30   ` Thierry Reding
2016-07-11 21:39     ` Thierry Reding
2016-07-25  8:29       ` Thierry Reding
2016-07-25 13:29         ` Doug Anderson
2016-07-25 14:26           ` Thierry Reding
  -- strict thread matches above, loose matches on Subject: below --
2016-05-03  8:25 Stephen Rothwell
2016-05-03 11:03 ` Mark Brown
2016-05-03 12:18   ` Thierry Reding

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).