From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] clk: wm831x: Add initial WM831x clock driver
Date: Wed, 21 Mar 2012 23:26:22 +0100 [thread overview]
Message-ID: <20120321222622.GG29317@pengutronix.de> (raw)
In-Reply-To: <1332360082-25092-4-git-send-email-broonie@opensource.wolfsonmicro.com>
On Wed, Mar 21, 2012 at 08:01:22PM +0000, Mark Brown wrote:
> The WM831x and WM832x series of PMICs contain a flexible clocking
> subsystem intended to provide always on and system core clocks. It
> features:
>
> - A 32.768kHz crystal oscillator which can optionally be used to pass
> through an externally generated clock.
> - A FLL which can be clocked from either the 32.768kHz oscillator or
> the CLKIN pin.
> - A CLKOUT pin which can bring out either the oscillator or the FLL
> output.
> - The 32.768kHz clock can also optionally be brought out on the GPIO
> pins of the device.
>
> This driver fully supports the 32.768kHz oscillator and CLKOUT. The FLL
> is supported only in AUTO mode, the full flexibility of the FLL cannot
> currently be used.
>
> Due to a lack of access to systems where the core SoC has been converted
> to use the generic clock API this driver has been compile tested only.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
[...]
> +
> +static unsigned long wm831x_clkout_recalc_rate(struct clk_hw *hw,
> + unsigned long parent_rate)
> +{
> + return parent_rate;
> +}
You should be able to drop this. The clock framework will use the parent
rate automatically if recalc_rate is not present.
> +
> +static int wm831x_clkout_set_parent(struct clk_hw *hw, u8 parent)
> +{
> + struct wm831x_clk *clkdata = container_of(hw, struct wm831x_clk,
> + clkout_hw);
> + struct wm831x *wm831x = clkdata->wm831x;
> +
> + if (parent > ARRAY_SIZE(wm831x_clkout_parents))
> + return -EINVAL;
Unless you mistrust the clock framework isn't necessary. The framework
checks this already.
> +
> +static __devinit int wm831x_clk_probe(struct platform_device *pdev)
> +{
> + struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
> + struct wm831x_clk *clkdata;
> + int ret;
> +
> + clkdata = devm_kzalloc(&pdev->dev, sizeof(*clkdata), GFP_KERNEL);
> + if (!clkdata)
> + return -ENOMEM;
> +
> + /* XTAL_ENA can only be set via OTP/InstantConfig so just read once */
> + ret = wm831x_reg_read(wm831x, WM831X_CLOCK_CONTROL_2);
> + if (ret < 0) {
> + dev_err(wm831x->dev, "Unable to read CLOCK_CONTROL_2: %d\n",
> + ret);
> + return ret;
> + }
> + clkdata->xtal_ena = ret & WM831X_XTAL_ENA;
> +
> + if (!clk_register(&pdev->dev, "xtal", &wm831x_xtal_ops,
> + &clkdata->xtal_hw, NULL, 0, CLK_IS_ROOT))
> + return -EINVAL;
The clock names are unique identifiers for the clock, so clocks in
drivers should probably have dev_name encoded into them.
You could also use the fixed rate generic clock here.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2012-03-21 22:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-21 20:01 [PATCH 1/4] clk: fixed-rate: Don't open code kstrdup() Mark Brown
2012-03-21 20:01 ` [PATCH 2/4] clk: Constify parent name arrays Mark Brown
2012-03-21 20:01 ` [PATCH 3/4] clk: Provide dummy clk_unregister() Mark Brown
2012-03-21 20:36 ` Turquette, Mike
2012-03-21 20:01 ` [PATCH 4/4] clk: wm831x: Add initial WM831x clock driver Mark Brown
2012-03-21 22:26 ` Sascha Hauer [this message]
2012-03-22 11:15 ` Mark Brown
2012-03-22 11:26 ` Sascha Hauer
2012-03-22 11:33 ` Mark Brown
2012-03-22 18:35 ` Turquette, Mike
2012-03-22 18:44 ` Mark Brown
2012-03-21 20:32 ` [PATCH 1/4] clk: fixed-rate: Don't open code kstrdup() Turquette, Mike
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=20120321222622.GG29317@pengutronix.de \
--to=s.hauer@pengutronix.de \
--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).