From: Thierry Reding <thierry.reding@gmail.com>
To: Clemens Gruber <clemens.gruber@pqgruber.com>
Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
Steffen Trumtrar <s.trumtrar@pengutronix.de>
Subject: Re: [PATCH v3 1/2] pwm-pca9685: Fix several driver bugs
Date: Mon, 20 Jul 2015 11:31:41 +0200 [thread overview]
Message-ID: <20150720093141.GR29614@ulmo> (raw)
In-Reply-To: <20150720092723.GP29614@ulmo>
[-- Attachment #1: Type: text/plain, Size: 2481 bytes --]
On Mon, Jul 20, 2015 at 11:27:23AM +0200, Thierry Reding wrote:
> On Mon, Jul 20, 2015 at 10:36:08AM +0200, Clemens Gruber wrote:
> > Problems:
> > - When duty_ns == period_ns, the full OFF bit was not cleared and the
> > PWM output of the PCA9685 stayed off.
> > - When duty_ns == period_ns and the catch-all channel was used, the
> > ALL_LED_OFF_L register was not cleared.
> > - The full ON bit was not cleared when setting the OFF time, therefore
> > the exact OFF time was ignored when setting a duty_ns < period_ns
> >
> > Solution: Clear both OFF registers when setting full ON and clear the
> > full ON bit when changing the OFF registers.
> >
> > Cc: Thierry Reding <thierry.reding@gmail.com>
> > Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> > Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
> > ---
> > drivers/pwm/pwm-pca9685.c | 24 ++++++++++++++++++++++++
> > 1 file changed, 24 insertions(+)
> >
> > diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c
> > index 34b5c27..f4a9c4a 100644
> > --- a/drivers/pwm/pwm-pca9685.c
> > +++ b/drivers/pwm/pwm-pca9685.c
> > @@ -85,6 +85,22 @@ static int pca9685_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> > }
> >
> > if (duty_ns == period_ns) {
> > + /* Clear both OFF registers */
> > + if (pwm->hwpwm >= PCA9685_MAXCHAN)
> > + reg = PCA9685_ALL_LED_OFF_L;
> > + else
> > + reg = LED_N_OFF_L(pwm->hwpwm);
> > +
> > + regmap_write(pca->regmap, reg, 0x0);
> > +
> > + if (pwm->hwpwm >= PCA9685_MAXCHAN)
> > + reg = PCA9685_ALL_LED_OFF_H;
> > + else
> > + reg = LED_N_OFF_H(pwm->hwpwm);
> > +
> > + regmap_write(pca->regmap, reg, 0x0);
> > +
> > + /* Set the full ON bit */
> > if (pwm->hwpwm >= PCA9685_MAXCHAN)
> > reg = PCA9685_ALL_LED_ON_H;
> > else
> > @@ -112,6 +128,14 @@ static int pca9685_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> >
> > regmap_write(pca->regmap, reg, ((int)duty >> 8) & 0xf);
> >
> > + /* Clear the full ON bit, otherwise the set OFF time has no effect */
> > + if (pwm->hwpwm >= PCA9685_MAXCHAN)
> > + reg = PCA9685_ALL_LED_ON_H;
> > + else
> > + reg = LED_N_ON_H(pwm->hwpwm);
> > +
> > + regmap_write(pca->regmap, reg, 0);
>
> Doesn't this undo the setting of this register back up in the duty_ns ==
> period_ns conditional block?
Nevermind, looking at the full driver code I see that the branch returns
0.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-07-20 9:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-20 8:36 [PATCH v3 0/2] pwm-pca9685: Bugfixes and prescaler support Clemens Gruber
2015-07-20 8:36 ` [PATCH v3 1/2] pwm-pca9685: Fix several driver bugs Clemens Gruber
2015-07-20 9:27 ` Thierry Reding
2015-07-20 9:31 ` Thierry Reding [this message]
2015-07-20 8:36 ` [PATCH v3 2/2] pwm-pca9685: Support changing the output frequency Clemens Gruber
2015-07-20 9:30 ` Thierry Reding
2015-07-20 9:46 ` Clemens Gruber
2015-07-20 9:50 ` Clemens Gruber
2015-07-20 9:58 ` Thierry Reding
2015-07-20 12:15 ` Clemens Gruber
2015-07-20 12:31 ` Clemens Gruber
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=20150720093141.GR29614@ulmo \
--to=thierry.reding@gmail.com \
--cc=clemens.gruber@pqgruber.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=s.trumtrar@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.