From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>,
Thierry Reding <thierry.reding@gmail.com>,
linux-pwm@vger.kernel.org
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
Alexandre Belloni <alexandre.belloni@free-electrons.com>,
Andrew Victor <linux@maxim.org.za>
Subject: Re: [PATCH] pwm: atmel-hlcdc: add at91sam9x5 and sama5d3 errata handling
Date: Tue, 18 Nov 2014 15:35:11 +0100 [thread overview]
Message-ID: <546B591F.6040108@atmel.com> (raw)
In-Reply-To: <1416314453-28597-1-git-send-email-boris.brezillon@free-electrons.com>
On 18/11/2014 13:40, Boris Brezillon :
> at91sam9x5 has an errata forbidding the use of slow clk as a clk source and
> sama5d3 SoCs has another errata forbidding the use of div1 prescaler.
>
> Take both of these erratas into account.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Thanks for having dealt with this.
Bye,
> ---
> drivers/pwm/pwm-atmel-hlcdc.c | 28 +++++++++++++++++++++++-----
> 1 file changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
> index eaf8b12..405f8a5 100644
> --- a/drivers/pwm/pwm-atmel-hlcdc.c
> +++ b/drivers/pwm/pwm-atmel-hlcdc.c
> @@ -36,6 +36,8 @@ struct atmel_hlcdc_pwm {
> struct pwm_chip chip;
> struct atmel_hlcdc *hlcdc;
> struct clk *cur_clk;
> + bool slow_clk_errata;
> + bool div1_clk_errata;
> };
>
> static inline struct atmel_hlcdc_pwm *to_atmel_hlcdc_pwm(struct pwm_chip *chip)
> @@ -56,20 +58,28 @@ static int atmel_hlcdc_pwm_config(struct pwm_chip *c,
> u32 pwmcfg;
> int pres;
>
> - clk_freq = clk_get_rate(new_clk);
> - clk_period_ns = (u64)NSEC_PER_SEC * 256;
> - do_div(clk_period_ns, clk_freq);
> + if (!chip->slow_clk_errata) {
> + clk_freq = clk_get_rate(new_clk);
> + clk_period_ns = (u64)NSEC_PER_SEC * 256;
> + do_div(clk_period_ns, clk_freq);
> + }
>
> - if (clk_period_ns > period_ns) {
> + /* Errata: cannot use slow clk on some IP revisions */
> + if (chip->slow_clk_errata || clk_period_ns > period_ns) {
> new_clk = hlcdc->sys_clk;
> clk_freq = clk_get_rate(new_clk);
> clk_period_ns = (u64)NSEC_PER_SEC * 256;
> do_div(clk_period_ns, clk_freq);
> }
>
> - for (pres = 0; pres <= ATMEL_HLCDC_PWMPS_MAX; pres++)
> + for (pres = 0; pres <= ATMEL_HLCDC_PWMPS_MAX; pres++) {
> + /* Errata: cannot divide by 1 on some IP revisions */
> + if (!pres && chip->div1_clk_errata)
> + continue;
> +
> if ((clk_period_ns << pres) >= period_ns)
> break;
> + }
>
> if (pres > ATMEL_HLCDC_PWMPS_MAX)
> return -EINVAL;
> @@ -204,6 +214,14 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> + if (of_device_is_compatible(dev->parent->of_node,
> + "atmel,sama5d3-hlcdc"))
> + chip->div1_clk_errata = true;
> +
> + if (of_device_is_compatible(dev->parent->of_node,
> + "atmel,at91sam9x5-hlcdc"))
> + chip->slow_clk_errata = true;
> +
> chip->hlcdc = hlcdc;
> chip->chip.ops = &atmel_hlcdc_pwm_ops;
> chip->chip.dev = dev;
>
--
Nicolas Ferre
next prev parent reply other threads:[~2014-11-18 14:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-18 12:40 [PATCH] pwm: atmel-hlcdc: add at91sam9x5 and sama5d3 errata handling Boris Brezillon
2014-11-18 14:35 ` Nicolas Ferre [this message]
2014-11-18 15:00 ` Thierry Reding
2014-11-18 15:53 ` 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=546B591F.6040108@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=alexandre.belloni@free-electrons.com \
--cc=boris.brezillon@free-electrons.com \
--cc=linux-pwm@vger.kernel.org \
--cc=linux@maxim.org.za \
--cc=plagnioj@jcrosoft.com \
--cc=thierry.reding@gmail.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