public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Rajendra Nayak <rnayak@ti.com>
To: balbi@ti.com
Cc: linux-omap@vger.kernel.org, paul@pwsan.com, khilman@deeprootsystems.com
Subject: RE: [RFC 1/3] OMAP: clocks: Use clk names instead of clk pointers
Date: Thu, 20 Jan 2011 11:03:38 +0530	[thread overview]
Message-ID: <504b9356bcc91cc2316b1623095e4f64@mail.gmail.com> (raw)
In-Reply-To: <20110119151924.GA3552@legolas.emea.dhcp.ti.com>

> -----Original Message-----
> From: Felipe Balbi [mailto:balbi@ti.com]
> Sent: Wednesday, January 19, 2011 8:49 PM
> To: Rajendra Nayak
> Cc: linux-omap@vger.kernel.org; paul@pwsan.com;
khilman@deeprootsystems.com
> Subject: Re: [RFC 1/3] OMAP: clocks: Use clk names instead of clk
pointers
>
> On Wed, Jan 19, 2011 at 07:44:24PM +0530, Rajendra Nayak wrote:
> > There are various instances of clk pointers being
> > embedded within structures in the clock framework
> > to refer to clk parents, reference clocks, bypass
> > clocks etc.
> > The right way to reference these is by their name
> > and not by embedding direct pointers to these clks.
> >
> > Hence make provision to be able to provide clock
> > names to refer to parents and bypass/ref clks and
> > populate the clk pointers at runtime.
> >
> > This requires the const qualifier to be dropped for
> > struct clksel within struct clk and hence needs
> > clksel struct definitions to be changed in all
> > clock*_data.c files.
>
> $SUBJECT and this commit log is completely wrong as this patch is only
> dropping the const from the clock structures.

Did you look at this part of the patch?

------->
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index fc62fb5..9bfd193 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -308,6 +308,16 @@ void clk_enable_init_clocks(void)
 	}
 }

+static struct clk *_omap_clk_get_by_name(const char *name)
+{
+	struct clk *c;
+
+	list_for_each_entry(c, &clocks, node)
+		if (!strcmp(c->name, name))
+			return c;
+	return NULL;
+}
+
 /**
  * omap_clk_get_by_name - locate OMAP struct clk by its name
  * @name: name of the struct clk to locate
@@ -318,21 +328,45 @@ void clk_enable_init_clocks(void)
  */
 struct clk *omap_clk_get_by_name(const char *name)
 {
-	struct clk *c;
 	struct clk *ret = NULL;

 	mutex_lock(&clocks_mutex);
+	ret = _omap_clk_get_by_name(name);
+	mutex_unlock(&clocks_mutex);
+
+	return ret;
+}
+
+static inline void omap_init_dpll_data_clk_pts(struct dpll_data *dd)
+{
+	if (!dd->clk_ref && dd->clk_ref_name)
+		dd->clk_ref = _omap_clk_get_by_name(dd->clk_ref_name);
+	if (!dd->clk_bypass && dd->clk_bypass_name)
+		dd->clk_bypass =
_omap_clk_get_by_name(dd->clk_bypass_name);
+}
+
+static inline void omap_init_clksel_clk_pts(struct clksel *clks)
+{
+	if (!clks->parent && clks->parent_name)
+		clks->parent = _omap_clk_get_by_name(clks->parent_name);
+}
+
+void omap_init_clk_pts(void)
+{
+	struct clk *c;
+
+	mutex_lock(&clocks_mutex);

 	list_for_each_entry(c, &clocks, node) {
-		if (!strcmp(c->name, name)) {
-			ret = c;
-			break;
-		}
+		if (!c->parent && c->parent_name)
+			c->parent = _omap_clk_get_by_name(c->parent_name);
+		if (c->dpll_data)
+			omap_init_dpll_data_clk_pts(c->dpll_data);
+		if (c->clksel)
+			omap_init_clksel_clk_pts(c->clksel);
 	}

 	mutex_unlock(&clocks_mutex);
-
-	return ret;
 }

 /*
diff --git a/arch/arm/plat-omap/include/plat/clock.h
b/arch/arm/plat-omap/include/plat/clock.h
index 8eb0ada..dc0d9fd 100644
--- a/arch/arm/plat-omap/include/plat/clock.h
+++ b/arch/arm/plat-omap/include/plat/clock.h
@@ -85,6 +85,7 @@ struct clksel_rate {
 /**
  * struct clksel - available parent clocks, and a pointer to their
divisors
  * @parent: struct clk * to a possible parent clock
+ * @parent_name: Name of the possible parent clock
  * @rates: available divisors for this parent clock
  *
  * A struct clksel is always associated with one or more struct clks
@@ -92,6 +93,7 @@ struct clksel_rate {
  */
 struct clksel {
 	struct clk		 *parent;
+	const char		 *parent_name;
 	const struct clksel_rate *rates;
 };

@@ -101,7 +103,9 @@ struct clksel {
  * @mult_mask: mask of the DPLL M bitfield in @mult_div1_reg
  * @div1_mask: mask of the DPLL N bitfield in @mult_div1_reg
  * @clk_bypass: struct clk pointer to the clock's bypass clock input
+ * @clk_bypass_name: Name of the clock's bypass clock input
  * @clk_ref: struct clk pointer to the clock's reference clock input
+ * @clk_ref_name: Name of the clock's reference clock input
  * @control_reg: register containing the DPLL mode bitfield
  * @enable_mask: mask of the DPLL mode bitfield in @control_reg
  * @rate_tolerance: maximum variance allowed from target rate (in Hz)
@@ -143,7 +147,9 @@ struct dpll_data {
 	u32			mult_mask;
 	u32			div1_mask;
 	struct clk		*clk_bypass;
+	const char		*clk_bypass_name;
 	struct clk		*clk_ref;
+	const char		*clk_ref_name;
 	void __iomem		*control_reg;
 	u32			enable_mask;
 	unsigned int		rate_tolerance;
@@ -230,6 +236,7 @@ struct clk {
 	const struct clkops	*ops;
 	const char		*name;
 	struct clk		*parent;
+	const char		*parent_name;
 	struct list_head	children;
 	struct list_head	sibling;	/* node for children */
 	unsigned long		rate;
@@ -245,7 +252,7 @@ struct clk {
 #ifdef CONFIG_ARCH_OMAP2PLUS
 	void __iomem		*clksel_reg;
 	u32			clksel_mask;
-	const struct clksel	*clksel;
+	struct clksel		*clksel;
 	struct dpll_data	*dpll_data;
 	const char		*clkdm_name;
 	struct clockdomain	*clkdm;
@@ -292,7 +299,7 @@ extern void clk_init_cpufreq_table(struct
cpufreq_frequency_table **table);
 extern void clk_exit_cpufreq_table(struct cpufreq_frequency_table
**table);
 #endif
 extern struct clk *omap_clk_get_by_name(const char *name);
-
+extern void omap_init_clk_pts(void);
 extern const struct clkops clkops_null;

 extern struct clk dummy_ck;
-- 
1.7.0.4

>
> --
> balbi

  reply	other threads:[~2011-01-20  5:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-19 14:14 [RFC 0/3] Use clknames to reference parent/bypass/ref clks Rajendra Nayak
2011-01-19 14:14 ` [RFC 1/3] OMAP: clocks: Use clk names instead of clk pointers Rajendra Nayak
2011-01-19 14:14   ` [RFC 2/3] OMAP3: PM: Fix CLK_SRC mask for IVA2 and MPU on 3430ES2PLUS Rajendra Nayak
2011-01-19 14:14     ` [RFC 3/3] OMAP4: clocks: Remove unused clksel definitions Rajendra Nayak
2011-01-24 22:09     ` [RFC 2/3] OMAP3: PM: Fix CLK_SRC mask for IVA2 and MPU on 3430ES2PLUS Kevin Hilman
2011-01-25  7:24       ` Rajendra Nayak
2011-01-25 15:58         ` Kevin Hilman
2011-01-27  2:43           ` Rajendra Nayak
2011-01-19 15:19   ` [RFC 1/3] OMAP: clocks: Use clk names instead of clk pointers Felipe Balbi
2011-01-20  5:33     ` Rajendra Nayak [this message]
2011-01-20  6:26       ` Felipe Balbi
2011-01-20  6:28         ` Rajendra Nayak
2011-01-24 22:08   ` Kevin Hilman
2011-01-25  7:21     ` Rajendra Nayak
2011-01-25 15:57       ` Kevin Hilman
2011-01-27  2:42         ` Rajendra Nayak
2011-02-16 12:22 ` [RFC 0/3] Use clknames to reference parent/bypass/ref clks Rajendra Nayak

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=504b9356bcc91cc2316b1623095e4f64@mail.gmail.com \
    --to=rnayak@ti.com \
    --cc=balbi@ti.com \
    --cc=khilman@deeprootsystems.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    /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