All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: renesas: rz: Select EXTAL vs USB clock
@ 2016-08-25 19:05 Chris Brandt
  2016-08-29 13:18 ` Geert Uytterhoeven
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Chris Brandt @ 2016-08-25 19:05 UTC (permalink / raw)
  To: mturquette, Stephen Boyd, Geert Uytterhoeven, Simon Horman
  Cc: Chris Brandt, linux-clk, linux-renesas-soc

Instead of hard coding EXTAL only, check if EXTAL was specified. If not,
then assume the USB clock is used as the main system clock.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 drivers/clk/renesas/clk-rz.c | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/renesas/clk-rz.c b/drivers/clk/renesas/clk-rz.c
index f6312c6..466b9fc 100644
--- a/drivers/clk/renesas/clk-rz.c
+++ b/drivers/clk/renesas/clk-rz.c
@@ -37,13 +37,29 @@ rz_cpg_register_clock(struct device_node *np, struct rz_cpg *cpg, const char *na
 	static const unsigned frqcr_tab[4] = { 3, 2, 0, 1 };
 
 	if (strcmp(name, "pll") == 0) {
-		/* FIXME: cpg_mode should be read from GPIO. But no GPIO support yet */
-		unsigned cpg_mode = 0; /* hardcoded to EXTAL for now */
-		const char *parent_name = of_clk_get_parent_name(np, cpg_mode);
-
-		mult = cpg_mode ? (32 / 4) : 30;
-
-		return clk_register_fixed_factor(NULL, name, parent_name, 0, mult, 1);
+		u32 freq = 0;
+		struct device_node *np;
+
+		/* If a clock-frequency for extal was specified, assume EXTAL boot */
+		np = of_find_node_by_name(NULL, "extal");
+		if( np ) {
+			of_property_read_u32(np, "clock-frequency", &freq);
+			if( freq )
+				return clk_register_fixed_factor(NULL, "pll", "extal",
+					0, 30, 1);
+		}
+
+		/* Must be USB clock boot */
+		np = of_find_node_by_name(NULL, "usb_x1");
+		if( np ) {
+			of_property_read_u32(np, "clock-frequency", &freq);
+			if( freq )
+				return clk_register_fixed_factor(NULL, "pll", "usb_x1",
+					0, (32 / 4), 1);
+		}
+
+		/* No clock frequency set in DT */
+		BUG();
 	}
 
 	/* If mapping regs failed, skip non-pll clocks. System will boot anyhow */
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2016-09-02  8:35 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-25 19:05 [PATCH] clk: renesas: rz: Select EXTAL vs USB clock Chris Brandt
2016-08-29 13:18 ` Geert Uytterhoeven
2016-08-29 14:53   ` Chris Brandt
2016-08-29 14:53     ` Chris Brandt
2016-08-29 15:13     ` Geert Uytterhoeven
2016-08-29 15:32       ` Chris Brandt
2016-08-29 15:32         ` Chris Brandt
2016-08-29 15:41         ` Geert Uytterhoeven
2016-08-29 16:04           ` Chris Brandt
2016-08-29 16:04             ` Chris Brandt
2016-08-29 18:39 ` Sergei Shtylyov
2016-08-29 18:41   ` Geert Uytterhoeven
2016-08-30  3:13 ` [PATCH v2] " Chris Brandt
2016-08-30  7:04   ` Simon Horman
2016-08-30  7:06     ` Simon Horman
2016-08-30  7:23   ` Geert Uytterhoeven
2016-08-30 13:31     ` Chris Brandt
2016-08-30 13:31       ` Chris Brandt
2016-09-01 13:10   ` [PATCH v3] " Chris Brandt
2016-09-01 19:21     ` Geert Uytterhoeven
2016-09-01 19:41       ` Chris Brandt
2016-09-01 19:41         ` Chris Brandt
2016-09-02  2:32     ` [PATCH v4] " Chris Brandt
2016-09-02  8:19       ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.