linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: socfpga: Add a second parent option for the dbg_base_clk
@ 2015-07-22 19:04 dinguyen
  2015-07-24 21:41 ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: dinguyen @ 2015-07-22 19:04 UTC (permalink / raw)
  To: sboyd, mturquette; +Cc: dinh.linux, linux-clk, linux-kernel, Dinh Nguyen

From: Dinh Nguyen <dinguyen@opensource.altera.com>

The debug base clock can be bypassed from the main PLL to the OSC1 clock.
The bypass register is the staysoc1(0x10) register that is in the clock
manager.

This patch adds the option to get the correct parent for the debug base
clock.

Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
---
 arch/arm/boot/dts/socfpga.dtsi   |  2 +-
 drivers/clk/socfpga/clk-periph.c | 18 ++++++++++++++----
 drivers/clk/socfpga/clk.h        |  1 +
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
index 80f924d..7d5db54 100644
--- a/arch/arm/boot/dts/socfpga.dtsi
+++ b/arch/arm/boot/dts/socfpga.dtsi
@@ -164,7 +164,7 @@
 						dbg_base_clk: dbg_base_clk {
 							#clock-cells = <0>;
 							compatible = "altr,socfpga-perip-clk";
-							clocks = <&main_pll>;
+							clocks = <&main_pll>, <&osc1>;
 							div-reg = <0xe8 0 9>;
 							reg = <0x50>;
 						};
diff --git a/drivers/clk/socfpga/clk-periph.c b/drivers/clk/socfpga/clk-periph.c
index 0c66863..52c883e 100644
--- a/drivers/clk/socfpga/clk-periph.c
+++ b/drivers/clk/socfpga/clk-periph.c
@@ -44,8 +44,17 @@ static unsigned long clk_periclk_recalc_rate(struct clk_hw *hwclk,
 	return parent_rate / div;
 }
 
+static u8 clk_periclk_get_parent(struct clk_hw *hwclk)
+{
+	u32 clk_src;
+
+	clk_src = readl(clk_mgr_base_addr + CLKMGR_DBCTRL);
+	return clk_src & 0x1;
+}
+
 static const struct clk_ops periclk_ops = {
 	.recalc_rate = clk_periclk_recalc_rate,
+	.get_parent = clk_periclk_get_parent,
 };
 
 static __init void __socfpga_periph_init(struct device_node *node,
@@ -55,7 +64,7 @@ static __init void __socfpga_periph_init(struct device_node *node,
 	struct clk *clk;
 	struct socfpga_periph_clk *periph_clk;
 	const char *clk_name = node->name;
-	const char *parent_name;
+	const char *parent_name[SOCFPGA_MAX_PARENTS];
 	struct clk_init_data init;
 	int rc;
 	u32 fixed_div;
@@ -89,9 +98,10 @@ static __init void __socfpga_periph_init(struct device_node *node,
 	init.name = clk_name;
 	init.ops = ops;
 	init.flags = 0;
-	parent_name = of_clk_get_parent_name(node, 0);
-	init.parent_names = &parent_name;
-	init.num_parents = 1;
+
+	init.num_parents = of_clk_parent_fill(node, parent_name,
+					      SOCFPGA_MAX_PARENTS);
+	init.parent_names = parent_name;
 
 	periph_clk->hw.hw.init = &init;
 
diff --git a/drivers/clk/socfpga/clk.h b/drivers/clk/socfpga/clk.h
index aa2741d..814c724 100644
--- a/drivers/clk/socfpga/clk.h
+++ b/drivers/clk/socfpga/clk.h
@@ -22,6 +22,7 @@
 /* Clock Manager offsets */
 #define CLKMGR_CTRL		0x0
 #define CLKMGR_BYPASS		0x4
+#define CLKMGR_DBCTRL		0x10
 #define CLKMGR_L4SRC		0x70
 #define CLKMGR_PERPLL_SRC	0xAC
 
-- 
2.4.5


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

* Re: [PATCH] clk: socfpga: Add a second parent option for the dbg_base_clk
  2015-07-22 19:04 [PATCH] clk: socfpga: Add a second parent option for the dbg_base_clk dinguyen
@ 2015-07-24 21:41 ` Stephen Boyd
  2015-07-25  2:42   ` Dinh Nguyen
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2015-07-24 21:41 UTC (permalink / raw)
  To: dinguyen; +Cc: mturquette, dinh.linux, linux-clk, linux-kernel

On 07/22, dinguyen@opensource.altera.com wrote:
> diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
> index 80f924d..7d5db54 100644
> --- a/arch/arm/boot/dts/socfpga.dtsi
> +++ b/arch/arm/boot/dts/socfpga.dtsi
> @@ -164,7 +164,7 @@
>  						dbg_base_clk: dbg_base_clk {
>  							#clock-cells = <0>;
>  							compatible = "altr,socfpga-perip-clk";
> -							clocks = <&main_pll>;
> +							clocks = <&main_pll>, <&osc1>;
>  							div-reg = <0xe8 0 9>;
>  							reg = <0x50>;
>  						};

We don't usually take changes in dts files. Can you split this
off and take it through arm-soc?

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH] clk: socfpga: Add a second parent option for the dbg_base_clk
  2015-07-24 21:41 ` Stephen Boyd
@ 2015-07-25  2:42   ` Dinh Nguyen
  0 siblings, 0 replies; 3+ messages in thread
From: Dinh Nguyen @ 2015-07-25  2:42 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: mturquette, dinh.linux, linux-clk, linux-kernel



On 7/24/15 4:41 PM, Stephen Boyd wrote:
> On 07/22, dinguyen@opensource.altera.com wrote:
>> diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
>> index 80f924d..7d5db54 100644
>> --- a/arch/arm/boot/dts/socfpga.dtsi
>> +++ b/arch/arm/boot/dts/socfpga.dtsi
>> @@ -164,7 +164,7 @@
>>  						dbg_base_clk: dbg_base_clk {
>>  							#clock-cells = <0>;
>>  							compatible = "altr,socfpga-perip-clk";
>> -							clocks = <&main_pll>;
>> +							clocks = <&main_pll>, <&osc1>;
>>  							div-reg = <0xe8 0 9>;
>>  							reg = <0x50>;
>>  						};
> 
> We don't usually take changes in dts files. Can you split this
> off and take it through arm-soc?
> 

Ah okay..will do.

Thanks,
Dinh

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

end of thread, other threads:[~2015-07-25  2:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-22 19:04 [PATCH] clk: socfpga: Add a second parent option for the dbg_base_clk dinguyen
2015-07-24 21:41 ` Stephen Boyd
2015-07-25  2:42   ` Dinh Nguyen

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).