linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: sboyd@codeaurora.org (Stephen Boyd)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 03/12] clk: Allow drivers to pass in a regmap
Date: Wed, 16 Oct 2013 00:40:05 -0700	[thread overview]
Message-ID: <1381909214-12693-4-git-send-email-sboyd@codeaurora.org> (raw)
In-Reply-To: <1381909214-12693-1-git-send-email-sboyd@codeaurora.org>

Add support to the clock core so that drivers can pass in a
regmap. If no regmap is specified try to query the device that's
registering the clock for its regmap. This should allow drivers
to use the core regmap helpers.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clk/clk.c            | 8 ++++++++
 include/linux/clk-provider.h | 7 +++++++
 2 files changed, 15 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index fbb5d59..8042c00 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -20,6 +20,7 @@
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/sched.h>
+#include <linux/regmap.h>
 
 static DEFINE_SPINLOCK(enable_lock);
 static DEFINE_MUTEX(prepare_lock);
@@ -1828,6 +1829,13 @@ static int _clk_register(struct device *dev, struct clk_hw *hw, struct clk *clk)
 	clk->num_parents = hw->init->num_parents;
 	hw->clk = clk;
 
+	if (hw->init->regmap)
+		hw->regmap = hw->init->regmap;
+	else if (dev && dev_get_regmap(dev, NULL))
+		hw->regmap = dev_get_regmap(dev, NULL);
+	else if (dev->parent)
+		hw->regmap = dev_get_regmap(dev->parent, NULL);
+
 	/* allocate local copy in case parent_names is __initdata */
 	clk->parent_names = kzalloc((sizeof(char*) * clk->num_parents),
 			GFP_KERNEL);
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 73bdb69..6ed62f1 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -142,6 +142,8 @@ struct clk_ops {
 	void		(*init)(struct clk_hw *hw);
 };
 
+struct regmap;
+
 /**
  * struct clk_init_data - holds init data that's common to all clocks and is
  * shared between the clock provider and the common clock framework.
@@ -151,6 +153,7 @@ struct clk_ops {
  * @parent_names: array of string names for all possible parents
  * @num_parents: number of possible parents
  * @flags: framework-level hints and quirks
+ * @regmap: regmap to use for regmap helpers and/or by providers
  */
 struct clk_init_data {
 	const char		*name;
@@ -158,6 +161,7 @@ struct clk_init_data {
 	const char		**parent_names;
 	u8			num_parents;
 	unsigned long		flags;
+	struct regmap		*regmap;
 };
 
 /**
@@ -171,10 +175,13 @@ struct clk_init_data {
  *
  * @init: pointer to struct clk_init_data that contains the init data shared
  * with the common clock framework.
+ *
+ * @regmap: regmap to use for regmap helpers and/or by providers
  */
 struct clk_hw {
 	struct clk *clk;
 	const struct clk_init_data *init;
+	struct regmap *regmap;
 };
 
 /*
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

  parent reply	other threads:[~2013-10-16  7:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16  7:40 [PATCH v3 00/12] Add support for MSM's mmio clock/reset controller Stephen Boyd
2013-10-16  7:40 ` [PATCH v3 01/12] clk: Fix debugfs reparenting NULL pointer dereference Stephen Boyd
2013-12-15  3:24   ` Mike Turquette
2013-10-16  7:40 ` [PATCH v3 02/12] reset: Silence warning in reset-controller.h Stephen Boyd
2013-10-16  7:40 ` Stephen Boyd [this message]
2013-10-16  7:40 ` [PATCH v3 04/12] clk: Add regmap core helpers for enable/disable/is_enabled Stephen Boyd
2013-12-19  4:50   ` Mike Turquette
2013-12-19 20:24     ` Gerhard Sittig
2013-12-24 13:45       ` Gerhard Sittig
2013-12-21  6:15     ` Stephen Boyd
2013-10-16  7:40 ` [PATCH v3 05/12] clk: Add set_rate_and_parent() op Stephen Boyd
2013-10-16  7:40 ` [PATCH v3 06/12] clk: msm: Add support for phase locked loops (PLLs) Stephen Boyd
2013-10-16  7:40 ` [PATCH v3 07/12] clk: msm: Add support for root clock generators (RCGs) Stephen Boyd
2013-10-16  7:40 ` [PATCH v3 08/12] clk: msm: Add support for branches/gate clocks Stephen Boyd
2013-10-16  7:40 ` [PATCH v3 09/12] clk: msm: Add reset controller support Stephen Boyd
2013-10-16  7:40 ` [PATCH v3 10/12] clk: msm: Add support for MSM8960's global clock controller (GCC) Stephen Boyd
2013-10-16  7:40 ` [PATCH v3 11/12] clk: msm: Add support for MSM8960's multimedia clock controller (MMCC) Stephen Boyd
2013-10-16  7:40 ` [PATCH v3 12/12] clk: msm: Add support for MSM8974's global clock controller (GCC) Stephen Boyd

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=1381909214-12693-4-git-send-email-sboyd@codeaurora.org \
    --to=sboyd@codeaurora.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).