public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: maxime.ripard@free-electrons.com (Maxime Ripard)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 01/11] clk: sunxi: Add mod0 and mmc module clock support for A80
Date: Fri, 19 Dec 2014 19:02:35 +0100	[thread overview]
Message-ID: <20141219180235.GO4820@lukather> (raw)
In-Reply-To: <1418886058-8145-2-git-send-email-wens@csie.org>

Hi Chen-Yu,

On Thu, Dec 18, 2014 at 03:00:48PM +0800, Chen-Yu Tsai wrote:
> The module 0 style clocks, or storage module clocks as named in the
> official SDK, are almost the same as the module 0 clocks on earlier
> Allwinner SoCs. The only difference is wider mux register bits.
> 
> As with earlier Allwinner SoCs, mmc module clocks are a special case
> of mod0 clocks, with phase controls for 2 child clocks, output and
> sample.
> 
> This patch adds support for both.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  Documentation/devicetree/bindings/clock/sunxi.txt |  7 +-
>  drivers/clk/sunxi/clk-mod0.c                      | 99 +++++++++++++++++++++++
>  2 files changed, 104 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
> index 8c60433..b660bdb 100644
> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
> @@ -56,7 +56,9 @@ Required properties:
>  	"allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23
>  	"allwinner,sun5i-a13-mbus-clk" - for the MBUS clock on A13
>  	"allwinner,sun4i-a10-mmc-clk" - for the MMC clock
> +	"allwinner,sun9i-a80-mmc-clk" - for mmc module clocks on A80
>  	"allwinner,sun4i-a10-mod0-clk" - for the module 0 family of clocks
> +	"allwinner,sun9i-a80-mod0-clk" - for module 0 (storage) clocks on A80
>  	"allwinner,sun8i-a23-mbus-clk" - for the MBUS clock on A23
>  	"allwinner,sun7i-a20-out-clk" - for the external output clocks
>  	"allwinner,sun7i-a20-gmac-clk" - for the GMAC clock module on A20/A31
> @@ -72,7 +74,8 @@ Required properties for all clocks:
>  - #clock-cells : from common clock binding; shall be set to 0 except for
>  	the following compatibles where it shall be set to 1:
>  	"allwinner,*-gates-clk", "allwinner,sun4i-pll5-clk",
> -	"allwinner,sun4i-pll6-clk", "allwinner,sun6i-a31-pll6-clk"
> +	"allwinner,sun4i-pll6-clk", "allwinner,sun6i-a31-pll6-clk",
> +	"allwinner,*-usb-clk", "allwinner,*-mmc-clk"
>  - clock-output-names : shall be the corresponding names of the outputs.
>  	If the clock module only has one output, the name shall be the
>  	module name.
> @@ -94,7 +97,7 @@ For "allwinner,sun6i-a31-pll6-clk", there are 2 outputs. The first output
>  is the normal PLL6 output, or "pll6". The second output is rate doubled
>  PLL6, or "pll6x2".
>  
> -The "allwinner,sun4i-a10-mmc-clk" has three different outputs: the
> +The "allwinner,*-mmc-clk" clocks have three different outputs: the
>  main clock, with the ID 0, and the output and sample clocks, with the
>  IDs 1 and 2, respectively.
>  
> diff --git a/drivers/clk/sunxi/clk-mod0.c b/drivers/clk/sunxi/clk-mod0.c
> index 4ac52c7..ef36e89 100644
> --- a/drivers/clk/sunxi/clk-mod0.c
> +++ b/drivers/clk/sunxi/clk-mod0.c
> @@ -93,6 +93,30 @@ static void __init sun4i_a10_mod0_setup(struct device_node *node)
>  }
>  CLK_OF_DECLARE(sun4i_a10_mod0, "allwinner,sun4i-a10-mod0-clk", sun4i_a10_mod0_setup);
>  
> +static const struct factors_data sun9i_a80_mod0_data __initconst = {
> +	.enable = 31,
> +	.mux = 24,
> +	.muxmask = BIT(3) | BIT(2) | BIT(1) | BIT(0),
> +	.table = &sun4i_a10_mod0_config,
> +	.getter = sun4i_a10_get_mod0_factors,
> +};
> +
> +static void __init sun9i_a80_mod0_setup(struct device_node *node)
> +{
> +	void __iomem *reg;
> +
> +	reg = of_io_request_and_map(node, 0, of_node_full_name(node));
> +	if (!reg) {
> +		pr_err("Could not get registers for mod0-clk: %s\n",
> +		       node->name);
> +		return;
> +	}
> +
> +	sunxi_factors_register(node, &sun9i_a80_mod0_data,
> +			       &sun4i_a10_mod0_lock, reg);
> +}
> +CLK_OF_DECLARE(sun9i_a80_mod0, "allwinner,sun9i-a80-mod0-clk", sun9i_a80_mod0_setup);
> +
>  static DEFINE_SPINLOCK(sun5i_a13_mbus_lock);
>  
>  static void __init sun5i_a13_mbus_setup(struct device_node *node)
> @@ -309,3 +333,78 @@ err_free_data:
>  	kfree(clk_data);
>  }
>  CLK_OF_DECLARE(sun4i_a10_mmc, "allwinner,sun4i-a10-mmc-clk", sun4i_a10_mmc_setup);
> +
> +static DEFINE_SPINLOCK(sun9i_a80_mmc_lock);
> +
> +static void __init sun9i_a80_mmc_setup(struct device_node *node)
> +{
> +	struct clk_onecell_data *clk_data;
> +	const char *parent;
> +	void __iomem *reg;
> +	int i;
> +
> +	reg = of_io_request_and_map(node, 0, of_node_full_name(node));
> +	if (IS_ERR(reg)) {
> +		pr_err("Couldn't map the %s clock registers\n", node->name);
> +		return;
> +	}
> +
> +	clk_data = kmalloc(sizeof(*clk_data), GFP_KERNEL);
> +	if (!clk_data)
> +		return;
> +
> +	clk_data->clks = kcalloc(3, sizeof(*clk_data->clks), GFP_KERNEL);
> +	if (!clk_data->clks)
> +		goto err_free_data;
> +
> +	clk_data->clk_num = 3;
> +	clk_data->clks[0] = sunxi_factors_register(node,
> +						   &sun9i_a80_mod0_data,
> +						   &sun9i_a80_mmc_lock, reg);
> +	if (!clk_data->clks[0])
> +		goto err_free_clks;
> +
> +	parent = __clk_get_name(clk_data->clks[0]);
> +
> +	for (i = 1; i < 3; i++) {
> +		struct clk_init_data init = {
> +			.num_parents	= 1,
> +			.parent_names	= &parent,
> +			.ops		= &mmc_clk_ops,
> +		};
> +		struct mmc_phase *phase;
> +
> +		phase = kmalloc(sizeof(*phase), GFP_KERNEL);
> +		if (!phase)
> +			continue;
> +
> +		phase->hw.init = &init;
> +		phase->reg = reg;
> +		phase->lock = &sun9i_a80_mmc_lock;
> +
> +		if (i == 1)
> +			phase->offset = 8;
> +		else
> +			phase->offset = 20;
> +
> +		if (of_property_read_string_index(node, "clock-output-names",
> +						  i, &init.name))
> +			init.name = node->name;
> +
> +		clk_data->clks[i] = clk_register(NULL, &phase->hw);
> +		if (IS_ERR(clk_data->clks[i])) {
> +			kfree(phase);
> +			continue;
> +		}
> +	}
> +
> +	of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
> +
> +	return;
> +
> +err_free_clks:
> +	kfree(clk_data->clks);
> +err_free_data:
> +	kfree(clk_data);
> +}
> +CLK_OF_DECLARE(sun9i_a80_mmc, "allwinner,sun9i-a80-mmc-clk", sun9i_a80_mmc_setup);

That looks a lot like the A10 MMC clock. What's changing? only the
data to feed to the factors setup code?

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/20141219/310c5257/attachment.sig>

  reply	other threads:[~2014-12-19 18:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-18  7:00 [PATCH v2 00/11] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
2014-12-18  7:00 ` [PATCH v2 01/11] clk: sunxi: Add mod0 and mmc module clock support for A80 Chen-Yu Tsai
2014-12-19 18:02   ` Maxime Ripard [this message]
2014-12-20 12:43     ` Chen-Yu Tsai
2015-01-08  9:38       ` Maxime Ripard
2015-01-12  2:39         ` [linux-sunxi] " Chen-Yu Tsai
2015-01-12  2:54           ` Chen-Yu Tsai
2015-01-12 15:19           ` Maxime Ripard
2014-12-18  7:00 ` [PATCH v2 02/11] ARM: dts: sun9i: Add mmc module clock nodes " Chen-Yu Tsai
2014-12-18  7:00 ` [PATCH v2 03/11] clk: sunxi: Add driver for A80 MMC config clocks/resets Chen-Yu Tsai
2014-12-19 18:08   ` Maxime Ripard
2014-12-22  2:15     ` Chen-Yu Tsai
2015-01-08  9:39       ` Maxime Ripard
2014-12-18  7:00 ` [PATCH v2 04/11] ARM: dts: sun9i: Add clock-indices property for bus gate clocks Chen-Yu Tsai
2014-12-18  7:00 ` [PATCH v2 05/11] ARM: dts: sun9i: Add mmc config clock nodes Chen-Yu Tsai
2014-12-18  7:00 ` [PATCH v2 06/11] ARM: dts: sunxi: Use label to reference pio in sunxi-common-regulators Chen-Yu Tsai
2014-12-18  7:00 ` [PATCH v2 07/11] ARM: dts: sun9i: Add mmc controller nodes to the A80 dtsi Chen-Yu Tsai
2014-12-18  7:00 ` [PATCH v2 08/11] ARM: dts: sun9i: Add pinmux setting for mmc0 Chen-Yu Tsai
2014-12-18  7:00 ` [PATCH v2 09/11] ARM: dts: sun9i: Enable mmc0 on A80 Optimus Board Chen-Yu Tsai
2014-12-18  7:00 ` [PATCH v2 10/11] ARM: dts: sun9i: Add 8 bit mmc pinmux setting for mmc2 Chen-Yu Tsai
2014-12-18  7:00 ` [PATCH v2 11/11] ARM: dts: sun9i: Enable mmc2 on A80 Optimus Board Chen-Yu Tsai

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=20141219180235.GO4820@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