devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: linux-omap@vger.kernel.org, mturquette@linaro.org
Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org
Subject: [PATCH 1/4] clk: ti: mux: add support for default-parenting
Date: Thu, 13 Feb 2014 11:00:45 +0200	[thread overview]
Message-ID: <1392282048-6284-2-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1392282048-6284-1-git-send-email-t-kristo@ti.com>

ti,mux-clock now supports ti,default-parent property, which can be used
to configure the default parent of the clock during boot. This property
can be added to board specific files, or under the clock data itself.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 Documentation/devicetree/bindings/clock/ti/mux.txt |    7 ++++++
 drivers/clk/ti/mux.c                               |   24 ++++++++++++++++++--
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/ti/mux.txt b/Documentation/devicetree/bindings/clock/ti/mux.txt
index 2d0d170..4e291eb 100644
--- a/Documentation/devicetree/bindings/clock/ti/mux.txt
+++ b/Documentation/devicetree/bindings/clock/ti/mux.txt
@@ -48,6 +48,8 @@ Optional properties:
   zero
 - ti,set-rate-parent : clk_set_rate is propagated to parent clock,
   not supported by the composite-mux-clock subtype
+- ti,default-parent : configures mux parent during boot to be the provided
+  phandle clock
 
 Examples:
 
@@ -65,6 +67,7 @@ abe_dpll_bypass_clk_mux_ck: abe_dpll_bypass_clk_mux_ck@4a306108 {
 	clocks = <&sys_clkin_ck>, <&sys_32k_ck>;
 	ti,bit-shift = <24>;
 	reg = <0x0108>;
+	ti,default-parent = <&sys_32k_ck>;
 };
 
 mcbsp5_mux_fck: mcbsp5_mux_fck {
@@ -74,3 +77,7 @@ mcbsp5_mux_fck: mcbsp5_mux_fck {
 	ti,bit-shift = <4>;
 	reg = <0x02d8>;
 };
+
+&mcbsp5_mux_fck {
+	ti,default-parent = <&mcbsp_clks>;
+};
diff --git a/drivers/clk/ti/mux.c b/drivers/clk/ti/mux.c
index 0197a47..557a7ce 100644
--- a/drivers/clk/ti/mux.c
+++ b/drivers/clk/ti/mux.c
@@ -108,7 +108,8 @@ static struct clk *_register_mux(struct device *dev, const char *name,
 				 const char **parent_names, u8 num_parents,
 				 unsigned long flags, void __iomem *reg,
 				 u8 shift, u32 mask, u8 clk_mux_flags,
-				 u32 *table, spinlock_t *lock)
+				 u32 *table, int default_parent,
+				 spinlock_t *lock)
 {
 	struct clk_mux *mux;
 	struct clk *clk;
@@ -136,6 +137,9 @@ static struct clk *_register_mux(struct device *dev, const char *name,
 	mux->table = table;
 	mux->hw.init = &init;
 
+	if (default_parent >= 0)
+		ti_clk_mux_set_parent(&mux->hw, default_parent);
+
 	clk = clk_register(dev, &mux->hw);
 
 	if (IS_ERR(clk))
@@ -161,6 +165,8 @@ static void of_mux_clk_setup(struct device_node *node)
 	u32 mask = 0;
 	u32 shift = 0;
 	u32 flags = 0;
+	struct device_node *default_parent;
+	int default_parent_idx = -1;
 
 	num_parents = of_clk_get_parent_count(node);
 	if (num_parents < 2) {
@@ -174,6 +180,19 @@ static void of_mux_clk_setup(struct device_node *node)
 	for (i = 0; i < num_parents; i++)
 		parent_names[i] = of_clk_get_parent_name(node, i);
 
+	default_parent = of_parse_phandle(node, "ti,default-parent", 0);
+
+	if (default_parent) {
+		for (i = 0; i < num_parents; i++) {
+			struct device_node *tmp;
+			tmp = of_parse_phandle(node, "clocks", i);
+			if (tmp == default_parent) {
+				default_parent_idx = i;
+				break;
+			}
+		}
+	}
+
 	reg = ti_clk_get_reg_addr(node, 0);
 
 	if (!reg)
@@ -195,7 +214,8 @@ static void of_mux_clk_setup(struct device_node *node)
 	mask = (1 << fls(mask)) - 1;
 
 	clk = _register_mux(NULL, node->name, parent_names, num_parents, flags,
-			    reg, shift, mask, clk_mux_flags, NULL, NULL);
+			    reg, shift, mask, clk_mux_flags, NULL,
+			    default_parent_idx, NULL);
 
 	if (!IS_ERR(clk))
 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
-- 
1.7.9.5


  reply	other threads:[~2014-02-13  9:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13  9:00 [PATCH 0/4] clk: dt: add support for default rate/parent Tero Kristo
2014-02-13  9:00 ` Tero Kristo [this message]
2014-02-13  9:00 ` [PATCH 2/4] clk: add support for default-rate Tero Kristo
2014-02-13  9:00 ` [PATCH 3/4] clk: ti: add support for default-rate property from DT Tero Kristo
2014-02-28 22:51   ` Tony Lindgren
2014-02-13  9:00 ` [PATCH 4/4] clk: ti: omap4: set default-parents and default-rates using DT Tero Kristo
2014-03-05 13:10 ` [PATCH 0/4] clk: dt: add support for default rate/parent Tero Kristo
2014-03-20 21:23   ` Mike Turquette
2014-03-21  8:02     ` Tero Kristo
2014-03-21  8:12     ` Peter De Schrijver
2014-03-25  0:38       ` Mike Turquette
2014-03-25  7:28         ` Peter De Schrijver

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=1392282048-6284-2-git-send-email-t-kristo@ti.com \
    --to=t-kristo@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@linaro.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).