From: zonque@gmail.com (Daniel Mack)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] clk: add si5351 i2c common clock driver
Date: Sat, 16 Mar 2013 16:10:36 +0100 [thread overview]
Message-ID: <51448B6C.9010702@gmail.com> (raw)
In-Reply-To: <1363439447-21336-1-git-send-email-sebastian.hesselbarth@gmail.com>
Hi Sebastian,
On 16.03.2013 14:10, Sebastian Hesselbarth wrote:
> This patch adds a common clock driver for Silicon Labs Si5351a/b/c
> i2c programmable clock generators. Currently, the driver supports
> DT kernels only and VXCO feature of si5351b is not implemented. DT
> bindings selectively allow to overwrite stored Si5351 configuration
> which is very helpful for clock generators with empty eeprom
> configuration. Corresponding device tree binding documentation is
> also added.
>
> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> ---
> Changes from v1:
> - remove .is_enabled functions as they read from i2c
> (Reported by Daniel Mack)
> - add CLK_SET_RATE_PARENT on clkout reparent if clkout uses
> its own multisync
>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Rob Landley <rob@landley.net>
> Cc: Mike Turquette <mturquette@linaro.org>
> Cc: Stephen Warren <swarren@nvidia.com>
> Cc: Thierry Reding <thierry.reding@avionic-design.de>
> Cc: Dom Cobley <popcornmix@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
> Cc: Rabeeh Khoury <rabeeh@solid-run.com>
> Cc: Daniel Mack <zonque@gmail.com>
> Cc: Jean-Francois Moine <moinejf@free.fr>
> Cc: devicetree-discuss at lists.ozlabs.org
> Cc: linux-doc at vger.kernel.org
> Cc: linux-kernel at vger.kernel.org
> Cc: linux-arm-kernel at lists.infradead.org
> ---
> .../devicetree/bindings/clock/silabs,si5351.txt | 114 ++
> .../devicetree/bindings/vendor-prefixes.txt | 1 +
> drivers/clk/Kconfig | 9 +
> drivers/clk/Makefile | 1 +
> drivers/clk/clk-si5351.c | 1413 ++++++++++++++++++++
> drivers/clk/clk-si5351.h | 155 +++
> 6 files changed, 1693 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/clock/silabs,si5351.txt
> create mode 100644 drivers/clk/clk-si5351.c
> create mode 100644 drivers/clk/clk-si5351.h
[...]
> +static unsigned long si5351_msynth_recalc_rate(struct clk_hw *hw,
> + unsigned long parent_rate)
> +{
> + struct si5351_hw_data *hwdata =
> + container_of(hw, struct si5351_hw_data, hw);
> + unsigned char reg = SI5351_CLK0_PARAMETERS +
> + (SI5351_PARAMETERS_LENGTH * hwdata->num);
> + unsigned long long rate;
> + unsigned long m;
> +
> + if (!hwdata->params.valid)
> + si5351_read_parameters(hwdata->drvdata, reg, &hwdata->params);
> +
> + if (hwdata->params.p3 == 0)
> + return parent_rate;
> +
> + /*
> + * multisync0-5: fOUT = (128 * P3 * fIN) / (P1*P3 + P2 + 512*P3)
> + * multisync6-7: fOUT = fIN / P1
> + */
> + rate = parent_rate;
> + if (hwdata->num > 5)
> + m = hwdata->params.p1;
> + else if ((si5351_reg_read(hwdata->drvdata, reg + 2) &
> + SI5351_OUTPUT_CLK_DIVBY4) == SI5351_OUTPUT_CLK_DIVBY4)
> + m = 4;
> + else {
> + rate *= 128 * hwdata->params.p3;
> + m = hwdata->params.p1 * hwdata->params.p3;
> + m += hwdata->params.p2;
> + m += 512 * hwdata->params.p3;
> + }
A nit only, but according to Documentation/CodingStyle, all if/else
blocks need curly brackets if any of them needs them. Maybe there are
more places which are affected.
> + do_div(rate, m);
I still have the problem that m == 0 in my case as I only set up two
clocks from my DT - which leads to a DIV0. The easiest fix is certainly
to bail here in that case.
Another option would be to only register the clocks to the framework
that are actually set up from DT, but that would require more rework at
the driver's probe level.
Other than that, this driver works perfectly for me - thanks again for
your work!
Daniel
next prev parent reply other threads:[~2013-03-16 15:10 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-09 12:59 [PATCH] clk: add si5351 i2c common clock driver Sebastian Hesselbarth
2013-02-11 5:46 ` Mike Turquette
2013-02-11 9:52 ` Sebastian Hesselbarth
2013-02-18 10:19 ` Daniel Mack
2013-02-19 19:15 ` Daniel Mack
2013-02-27 10:01 ` Sebastian Hesselbarth
2013-03-01 15:01 ` Daniel Mack
2013-03-16 13:10 ` [PATCH v2] " Sebastian Hesselbarth
2013-03-16 15:10 ` Daniel Mack [this message]
2013-03-18 10:43 ` [PATCH v3] " Sebastian Hesselbarth
2013-03-18 11:37 ` Daniel Mack
2013-03-20 0:26 ` Mike Turquette
2013-03-20 8:20 ` Sebastian Hesselbarth
2013-03-21 18:09 ` Lars-Peter Clausen
2013-03-21 21:32 ` Sebastian Hesselbarth
2013-03-23 10:07 ` Lars-Peter Clausen
2013-03-23 14:46 ` [PATCH v4] " Sebastian Hesselbarth
2013-04-02 23:46 ` Mike Turquette
2013-04-03 11:10 ` Sebastian Hesselbarth
2013-04-05 5:23 ` [PATCH v5] " Sebastian Hesselbarth
2013-04-07 22:50 ` [v5] " Guenter Roeck
2013-04-07 23:49 ` Sebastian Hesselbarth
2013-04-08 0:17 ` Guenter Roeck
2013-04-08 6:11 ` Sebastian Hesselbarth
2013-04-08 14:54 ` Guenter Roeck
2013-04-08 15:38 ` Sebastian Hesselbarth
2013-04-08 17:36 ` Mike Turquette
2013-04-08 18:32 ` Sebastian Hesselbarth
2013-04-08 16:46 ` [PATCH v6] " Sebastian Hesselbarth
2013-04-08 17:46 ` Guenter Roeck
2013-04-08 18:24 ` Sebastian Hesselbarth
2013-04-10 9:40 ` [PATCH v7] " Sebastian Hesselbarth
2013-04-10 10:17 ` Daniel Mack
2013-04-10 14:48 ` Michal Bachraty
2013-04-10 17:27 ` Sebastian Hesselbarth
2013-04-11 7:44 ` Michal Bachraty
2013-04-11 8:22 ` Sebastian Hesselbarth
2013-04-10 19:34 ` Guenter Roeck
2013-04-11 19:42 ` [PATCH v8] " Sebastian Hesselbarth
2013-04-12 11:43 ` Michal Bachraty
2013-04-12 18:19 ` Mike Turquette
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=51448B6C.9010702@gmail.com \
--to=zonque@gmail.com \
--cc=linux-arm-kernel@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).