From: maxime.ripard@free-electrons.com (Maxime Ripard)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 6/9] clk: sunxi: mod1 clock support
Date: Sun, 3 Aug 2014 14:47:33 +0200 [thread overview]
Message-ID: <20140803124733.GW3952@lukather> (raw)
In-Reply-To: <1406842092-25207-7-git-send-email-emilio@elopez.com.ar>
On Thu, Jul 31, 2014 at 06:28:09PM -0300, Emilio L?pez wrote:
> The module 1 type of clocks consist of a gate and a mux and are used on
> the audio blocks to mux and gate the PLL2 outputs for AC97, IIS or
> SPDIF. This commit adds support for them on the sunxi clock driver.
>
> Not-signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
Why so?
It looks quite good.
> ---
>
> Changes from RFC:
> * Document compatible used
>
> Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
> drivers/clk/sunxi/Makefile | 1 +
> drivers/clk/sunxi/clk-a10-mod1.c | 69 +++++++++++++++++++++++
> 3 files changed, 71 insertions(+)
> create mode 100644 drivers/clk/sunxi/clk-a10-mod1.c
>
> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
> index d18b89b..b028ee2 100644
> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
> @@ -50,6 +50,7 @@ Required properties:
> "allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23
> "allwinner,sun4i-a10-codec-clk" - for the codec clock on A10
> "allwinner,sun4i-a10-mod0-clk" - for the module 0 family of clocks
> + "allwinner,sun4i-a10-mod1-clk" - for the module 1 family of clocks
> "allwinner,sun7i-a20-out-clk" - for the external output clocks
> "allwinner,sun7i-a20-gmac-clk" - for the GMAC clock module on A20/A31
> "allwinner,sun4i-a10-usb-clk" - for usb gates + resets on A10 / A20
> diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
> index a7a96f8..75d113d 100644
> --- a/drivers/clk/sunxi/Makefile
> +++ b/drivers/clk/sunxi/Makefile
> @@ -5,6 +5,7 @@
> obj-y += clk-sunxi.o clk-factors.o
> obj-y += clk-a10-codec.o
> obj-y += clk-a10-hosc.o
> +obj-y += clk-a10-mod1.o
> obj-y += clk-a10-pll2.o
> obj-y += clk-a20-gmac.o
>
> diff --git a/drivers/clk/sunxi/clk-a10-mod1.c b/drivers/clk/sunxi/clk-a10-mod1.c
> new file mode 100644
> index 0000000..09afd54
> --- /dev/null
> +++ b/drivers/clk/sunxi/clk-a10-mod1.c
> @@ -0,0 +1,69 @@
> +/*
> + * Copyright 2014 Emilio L?pez
> + *
> + * Emilio L?pez <emilio@elopez.com.ar>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/clk-provider.h>
> +#include <linux/clkdev.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +
> +static DEFINE_SPINLOCK(mod1_lock);
> +
> +#define SUN4I_MOD1_ENABLE 31
> +#define SUN4I_MOD1_MUX 16
> +#define SUN4I_MOD1_MUX_WIDTH 2
> +#define SUN4I_MOD1_MAX_PARENTS 4
> +
> +static void __init sun4i_mod1_clk_setup(struct device_node *node)
> +{
> + struct clk *clk;
> + struct clk_mux *mux;
> + struct clk_gate *gate;
> + const char *parents[4];
> + const char *clk_name = node->name;
> + void __iomem *reg;
> + int i = 0;
> +
> + mux = kzalloc(sizeof(*mux), GFP_KERNEL);
> + gate = kzalloc(sizeof(*gate), GFP_KERNEL);
> + if (!mux || !gate) {
> + kfree(mux);
> + kfree(gate);
> + return;
> + }
> +
> + of_property_read_string(node, "clock-output-names", &clk_name);
> + reg = of_iomap(node, 0);
> +
> + while (i < SUN4I_MOD1_MAX_PARENTS &&
> + (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
> + i++;
> +
> + gate->reg = reg;
> + gate->bit_idx = SUN4I_MOD1_ENABLE;
> + gate->lock = &mod1_lock;
> + mux->reg = reg;
> + mux->shift = SUN4I_MOD1_MUX;
> + mux->mask = BIT(SUN4I_MOD1_MUX_WIDTH) - 1;
> + mux->lock = &mod1_lock;
> +
> + clk = clk_register_composite(NULL, clk_name, parents, i,
> + &mux->hw, &clk_mux_ops,
> + NULL, NULL,
> + &gate->hw, &clk_gate_ops, 0);
> + if (!IS_ERR(clk))
> + of_clk_add_provider(node, of_clk_src_simple_get, clk);
> +}
> +CLK_OF_DECLARE(sun4i_mod1, "allwinner,sun4i-a10-mod1-clk", sun4i_mod1_clk_setup);
Why are you not using clk-sunxi for this? It has pretty much
everything in place to do so already.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140803/345affed/attachment.sig>
next prev parent reply other threads:[~2014-08-03 12:47 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-31 21:28 [PATCH 0/9] Audio clocks for sun[457]i, SoC revision detection Emilio López
2014-07-31 21:28 ` [PATCH 1/9] ARM: sunxi: introduce SoC identification support Emilio López
2014-08-03 12:40 ` Maxime Ripard
2014-08-03 21:45 ` Emilio López
2014-08-04 8:08 ` Lee Jones
2014-08-04 19:48 ` Maxime Ripard
2014-07-31 21:28 ` [PATCH 2/9] ARM: sunxi: quirk support Emilio López
2014-08-03 12:42 ` Maxime Ripard
2014-08-03 21:37 ` Emilio López
2014-08-04 19:32 ` Maxime Ripard
2014-07-31 21:28 ` [PATCH 3/9] ARM: sunxi: make sun6i SMP ops static Emilio López
2014-08-03 12:41 ` Maxime Ripard
2014-07-31 21:28 ` [PATCH 4/9] clk: sunxi: PLL2 support for sun4i, sun5i and sun7i Emilio López
2014-08-03 12:44 ` Maxime Ripard
2014-08-03 15:58 ` Chen-Yu Tsai
2014-08-03 18:48 ` Maxime Ripard
2014-08-03 22:02 ` Emilio López
2014-08-04 20:02 ` Maxime Ripard
2014-08-04 20:23 ` Emilio López
2014-08-07 11:23 ` Maxime Ripard
2014-08-06 13:51 ` jonsmirl at gmail.com
2014-08-06 15:20 ` jonsmirl at gmail.com
2014-08-08 0:03 ` jonsmirl at gmail.com
2014-07-31 21:28 ` [PATCH 5/9] clk: sunxi: codec clock support Emilio López
2014-07-31 21:28 ` [PATCH 6/9] clk: sunxi: mod1 " Emilio López
2014-08-03 12:47 ` Maxime Ripard [this message]
2014-08-03 22:11 ` Emilio López
2014-08-04 19:52 ` Maxime Ripard
2014-07-31 21:28 ` [PATCH 7/9] ARM: sunxi: dt: Add PLL2 support Emilio López
2014-07-31 21:46 ` jonsmirl at gmail.com
2014-08-03 12:50 ` Maxime Ripard
2014-08-03 15:55 ` Chen-Yu Tsai
2014-08-03 22:15 ` Emilio López
2014-08-04 19:53 ` Maxime Ripard
2014-07-31 21:28 ` [PATCH 8/9] ARM: sunxi: dt: Add codec clock support Emilio López
2014-07-31 21:28 ` [PATCH 9/9] ARM: sun7i: dt: Add mod1 clock nodes Emilio López
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=20140803124733.GW3952@lukather \
--to=maxime.ripard@free-electrons.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).