linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: wens@csie.org (Chen-Yu Tsai)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 01/13] clk: sunxi: Add a common setup function for mmc module clocks
Date: Tue, 13 Jan 2015 09:37:23 +0800	[thread overview]
Message-ID: <1421113055-17867-2-git-send-email-wens@csie.org> (raw)
In-Reply-To: <1421113055-17867-1-git-send-email-wens@csie.org>

The only difference between module clocks on different platforms is the
width of the mux register bits and the valid values, which are passed in
through struct factors_data. The phase clocks parts are identical.

This patch generalizes the setup function, so most of the code can be
reused when adding sun9i support, which has a wider mux register.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/clk/sunxi/clk-mod0.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/sunxi/clk-mod0.c b/drivers/clk/sunxi/clk-mod0.c
index e37eb6fe19e8..4430d1398ce6 100644
--- a/drivers/clk/sunxi/clk-mod0.c
+++ b/drivers/clk/sunxi/clk-mod0.c
@@ -272,9 +272,16 @@ static const struct clk_ops mmc_clk_ops = {
 	.set_phase	= mmc_set_phase,
 };
 
-static DEFINE_SPINLOCK(sun4i_a10_mmc_lock);
-
-static void __init sun4i_a10_mmc_setup(struct device_node *node)
+/*
+ * sunxi_mmc_setup - Common setup function for mmc module clocks
+ *
+ * The only difference between module clocks on different platforms is the
+ * width of the mux register bits and the valid values, which are passed in
+ * through struct factors_data. The phase clocks parts are identical.
+ */
+static void __init sunxi_mmc_setup(struct device_node *node,
+				   const struct factors_data *data,
+				   spinlock_t *lock)
 {
 	struct clk_onecell_data *clk_data;
 	const char *parent;
@@ -296,9 +303,7 @@ static void __init sun4i_a10_mmc_setup(struct device_node *node)
 		goto err_free_data;
 
 	clk_data->clk_num = 3;
-	clk_data->clks[0] = sunxi_factors_register(node,
-						   &sun4i_a10_mod0_data,
-						   &sun4i_a10_mmc_lock, reg);
+	clk_data->clks[0] = sunxi_factors_register(node, data, lock, reg);
 	if (!clk_data->clks[0])
 		goto err_free_clks;
 
@@ -318,7 +323,7 @@ static void __init sun4i_a10_mmc_setup(struct device_node *node)
 
 		phase->hw.init = &init;
 		phase->reg = reg;
-		phase->lock = &sun4i_a10_mmc_lock;
+		phase->lock = lock;
 
 		if (i == 1)
 			phase->offset = 8;
@@ -345,4 +350,11 @@ err_free_clks:
 err_free_data:
 	kfree(clk_data);
 }
+
+static DEFINE_SPINLOCK(sun4i_a10_mmc_lock);
+
+static void __init sun4i_a10_mmc_setup(struct device_node *node)
+{
+	sunxi_mmc_setup(node, &sun4i_a10_mod0_data, &sun4i_a10_mmc_lock);
+}
 CLK_OF_DECLARE(sun4i_a10_mmc, "allwinner,sun4i-a10-mmc-clk", sun4i_a10_mmc_setup);
-- 
2.1.4

  reply	other threads:[~2015-01-13  1:37 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13  1:37 [PATCH v3 00/13] ARM: sun9i: Enable MMC support on Allwinner A80 Chen-Yu Tsai
2015-01-13  1:37 ` Chen-Yu Tsai [this message]
2015-01-14 16:26   ` [PATCH v3 01/13] clk: sunxi: Add a common setup function for mmc module clocks Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 02/13] clk: sunxi: Add mod0 and mmc module clock support for A80 Chen-Yu Tsai
2015-01-14 16:28   ` Maxime Ripard
2015-01-15  2:34     ` Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 03/13] ARM: dts: sun9i: Add mmc module clock nodes " Chen-Yu Tsai
2015-01-14 16:30   ` Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 04/13] clk: sunxi: Add driver for A80 MMC config clocks/resets Chen-Yu Tsai
2015-01-14 16:37   ` Maxime Ripard
2015-01-15  2:29     ` Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 05/13] ARM: dts: sun9i: Add clock-indices property for bus gate clocks Chen-Yu Tsai
2015-01-14 16:33   ` Maxime Ripard
2015-01-15  2:24     ` Chen-Yu Tsai
2015-01-15 15:20       ` Maxime Ripard
2015-01-15 15:35         ` [linux-sunxi] " Chen-Yu Tsai
2015-01-15 15:51           ` Maxime Ripard
2015-01-15 16:09             ` Chen-Yu Tsai
2015-01-15 21:46               ` Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 06/13] ARM: dts: sun9i: Add mmc config clock nodes Chen-Yu Tsai
2015-01-14 16:38   ` Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 07/13] ARM: dts: sunxi: Use label to reference pio in sunxi-common-regulators Chen-Yu Tsai
2015-01-14 16:39   ` Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 08/13] ARM: dts: sun9i: Add mmc controller nodes to the A80 dtsi Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 09/13] ARM: dts: sun9i: Add pinmux setting for mmc0 Chen-Yu Tsai
2015-01-14 16:40   ` Maxime Ripard
2015-01-13  1:37 ` [PATCH v3 10/13] ARM: dts: sun9i: Convert a80 optimus board dts to label referencing Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 11/13] ARM: dts: sun9i: Enable mmc0 on A80 Optimus Board Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 12/13] ARM: dts: sun9i: Add 8 bit mmc pinmux setting for mmc2 Chen-Yu Tsai
2015-01-13  1:37 ` [PATCH v3 13/13] 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=1421113055-17867-2-git-send-email-wens@csie.org \
    --to=wens@csie.org \
    --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).