From: Thierry Reding <thierry.reding@gmail.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
linux-pwm@vger.kernel.org, devicetree@vger.kernel.org,
Samuel Ortiz <sameo@linux.intel.com>,
Pawel Moll <pawel.moll@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Lee Jones <lee.jones@linaro.org>,
Nicolas Ferre <nicolas.ferre@atmel.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
Rob Herring <robh+dt@kernel.org>,
Alexandre Belloni <alexandre.belloni@free-electrons.com>,
Kumar Gala <galak@codeaurora.org>,
Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
Andrew Victor <linux@maxim.org.za>,
linux-arm-kernel@lists.infradead.org,
Mark Yao <mark.yao@rock-chips.com>
Subject: Re: [PATCH v7 03/11] pwm: add support for atmel-hlcdc-pwm device
Date: Mon, 6 Oct 2014 14:28:57 +0200 [thread overview]
Message-ID: <20141006122856.GB26833@ulmo> (raw)
In-Reply-To: <20141006135009.6cd980a1@bbrezillon>
[-- Attachment #1.1: Type: text/plain, Size: 3167 bytes --]
On Mon, Oct 06, 2014 at 01:50:09PM +0200, Boris Brezillon wrote:
> On Mon, 6 Oct 2014 12:46:35 +0200 Thierry Reding <thierry.reding@gmail.com> wrote:
> > On Wed, Oct 01, 2014 at 04:53:00PM +0200, Boris Brezillon wrote:
[...]
> > > + if (pres > ATMEL_HLCDC_PWMPS_MAX)
> > > + return -EINVAL;
> >
> > I think the condition above needs to be "pres == ATMEL_HLCDC_PWMPS_MAX",
> > otherwise this will never be true.
>
> Actually the previous loop is:
>
> for (pres = 0; pres *<=* ATMEL_HLCDC_PWMPS_MAX; pres++)
>
> thus pres will be equal to ATMEL_HLCDC_PWMPS_MAX + 1 when no
> appropriate prescaler is found.
Indeed so.
> > > + regmap_update_bits(hlcdc->regmap, ATMEL_HLCDC_CFG(0),
> > > + ATMEL_HLCDC_CLKPWMSEL, gencfg);
> > > + }
> > > +
> > > + do_div(pwmcval, period_ns);
> > > + if (pwmcval > 255)
> >
> > The PWM core already makes sure that duty_ns <= period_ns, so pwmcval
> > could be anywhere between 0 and 256 here. Where does the disconnect come
> > from? Why not make pwmcval = duty_ns * 255 if that's the maximum?
>
> Here is what the datasheet says:
>
> "Due to the comparison mechanism, the output pulse has a width between
> zero and 255 PWM counter cycles. Thus by adding a simple passive filter
> outside the chip, an analog voltage between 0 and (255/256) × VDD can
> be obtained (for the positive polarity case, or between (1/256) × VDD
> and VDD for the negative polarity case). Other voltage values can be
> obtained by adding active external circuitry."
>
> Given this explanation we should divide by 256, but 256/256 is a
> forbidden value, hence I just use the maximum available one (255) when
> I'm asked to configure a duty cycle occupying the whole period.
Okay, perhaps you can summarize the above explanation from the datasheet
in a comment to clarify.
> > > + pwmcval = 255;
> > > +
> > > + pwmcfg |= ATMEL_HLCDC_PWMCVAL(pwmcval);
> > > +
> > > + regmap_update_bits(hlcdc->regmap, ATMEL_HLCDC_CFG(6),
> > > + ATMEL_HLCDC_PWMCVAL_MASK | ATMEL_HLCDC_PWMPS_MASK,
> > > + pwmcfg);
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +static int atmel_hlcdc_pwm_set_polarity(struct pwm_chip *c,
> > > + struct pwm_device *pwm,
> > > + enum pwm_polarity polarity)
> > > +{
> > > + struct atmel_hlcdc_pwm_chip *chip =
> > > + pwm_chip_to_atmel_hlcdc_pwm_chip(c);
> > > + struct atmel_hlcdc *hlcdc = chip->hlcdc;
> > > + u32 cfg = 0;
> > > +
> > > + if (polarity == PWM_POLARITY_NORMAL)
> > > + cfg = ATMEL_HLCDC_PWMPOL;
> >
> > That's strange. Inverse polarity is the default on this hardware?
>
> Quote from the datasheet:
>
> "
> • PWMPOL: LCD Controller PWM Signal Polarity
> This bit defines the polarity of the PWM output signal. If set to one,
> the output pulses are high level (the output will be high when- ever
> the value in the counter is less than the value CVAL) If set to zero,
> the output pulses are low level.
> "
>
> My understanding is that ATMEL_HLCDC_PWMPOL should be set when using
> normal polarity (and my tests confirm that it works as expected ;-)).
Yes, sounds good then.
Thierry
[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2014-10-06 12:28 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-01 14:52 [PATCH v7 00/11] drm: add support for Atmel HLCDC Display Controller Boris Brezillon
2014-10-01 14:52 ` [PATCH v7 01/11] mfd: add atmel-hlcdc driver Boris Brezillon
2014-10-06 10:49 ` Thierry Reding
2014-10-06 11:38 ` Boris Brezillon
2014-10-01 14:52 ` [PATCH v7 02/11] mfd: add documentation for atmel-hlcdc DT bindings Boris Brezillon
2014-10-01 14:53 ` [PATCH v7 03/11] pwm: add support for atmel-hlcdc-pwm device Boris Brezillon
2014-10-06 10:46 ` Thierry Reding
2014-10-06 11:50 ` Boris Brezillon
2014-10-06 12:28 ` Thierry Reding [this message]
2014-10-01 14:53 ` [PATCH v7 04/11] pwm: add DT bindings documentation for atmel-hlcdc-pwm driver Boris Brezillon
2014-10-06 10:13 ` Thierry Reding
2014-10-06 11:33 ` Mark Rutland
2014-10-06 12:23 ` Thierry Reding
2014-10-06 12:59 ` Boris Brezillon
2014-10-06 13:26 ` Thierry Reding
2014-10-01 14:53 ` [PATCH v7 05/11] drm: add Atmel HLCDC Display Controller support Boris Brezillon
2014-10-08 10:42 ` Nicolas Ferre
2014-10-01 14:53 ` [PATCH v7 06/11] drm: add DT bindings documentation for atmel-hlcdc-dc driver Boris Brezillon
2014-10-06 10:54 ` Thierry Reding
2014-10-06 12:14 ` Boris Brezillon
2014-10-06 12:35 ` Thierry Reding
2014-10-06 13:53 ` Boris Brezillon
2014-10-06 14:26 ` Thierry Reding
2014-10-06 16:02 ` Boris Brezillon
2014-10-01 14:53 ` [PATCH v7 07/11] ARM: AT91/dt: split sama5d3 lcd pin definitions to match RGB mode configs Boris Brezillon
2014-10-01 14:53 ` [PATCH v7 08/11] ARM: AT91/dt: add alternative pin muxing for sama5d3 lcd pins Boris Brezillon
2014-10-01 14:53 ` [PATCH v7 09/11] ARM: at91/dt: define the HLCDC node available on sama5d3 SoCs Boris Brezillon
2014-10-01 14:53 ` [PATCH v7 10/11] ARM: at91/dt: add LCD panel description to sama5d3xdm.dtsi Boris Brezillon
2014-10-06 11:01 ` Thierry Reding
2014-10-06 12:25 ` Boris Brezillon
2014-10-06 12:40 ` Thierry Reding
2014-10-06 13:11 ` Boris Brezillon
2014-10-06 13:30 ` Thierry Reding
2014-10-06 13:58 ` Boris Brezillon
[not found] ` <1412175188-28278-1-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-10-01 14:53 ` [PATCH v7 11/11] ARM: at91/dt: enable the LCD panel on sama5d3xek boards Boris Brezillon
2014-10-06 11:01 ` Thierry Reding
2014-10-01 14:59 ` [PATCH v7 00/11] drm: add support for Atmel HLCDC Display Controller Boris Brezillon
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=20141006122856.GB26833@ulmo \
--to=thierry.reding@gmail.com \
--cc=alexandre.belloni@free-electrons.com \
--cc=boris.brezillon@free-electrons.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=galak@codeaurora.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux@maxim.org.za \
--cc=mark.rutland@arm.com \
--cc=mark.yao@rock-chips.com \
--cc=nicolas.ferre@atmel.com \
--cc=pawel.moll@arm.com \
--cc=plagnioj@jcrosoft.com \
--cc=robh+dt@kernel.org \
--cc=sameo@linux.intel.com \
/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).