Socfpga: clk: trivial fixes and cleanup
Subsystems (2)
cover Socfpga: clk: trivial fixes and cleanup
Hi!
This series includes two trivial fixes to the code (1,2), then goes on to split the single clk.c file up into clock-type specific files (3) and finally adds a divider to the peripheral clock path.
The patches are rebased to the for-next branch of
git://git.rocketboards.org/linux-socfpga-next.git
Regards,
Steffen
Steffen Trumtrar (4):
ARM: socfpga: clk: remove unused field
ARM: socfpga: clk: fix define typo
ARM: socfpga: clk: split clk code
ARM: socfpga: clk: add clk_divider to periph
drivers/clk/socfpga/Makefile | 3 + drivers/clk/socfpga/clk-gate.c | 197 ++++++++++++++++++++++++ drivers/clk/socfpga/clk-periph.c | 87 +++++++++++ drivers/clk/socfpga/clk-pll.c | 114 ++++++++++++++ drivers/clk/socfpga/clk.c | 313 +-------------------------------------- drivers/clk/socfpga/clk.h | 56 +++++++ 6 files changed, 458 insertions(+), 312 deletions(-) create mode 100644 drivers/clk/socfpga/clk-gate.c create mode 100644 drivers/clk/socfpga/clk-periph.c create mode 100644 drivers/clk/socfpga/clk-pll.c create mode 100644 drivers/clk/socfpga/clk.h
Signature · 1 line
1.8.4.rc3
PATCH 1/4 ARM: socfpga: clk: remove unused field
The clk_name field from the socfpga_clk struct is unused. Remove it.
--- drivers/clk/socfpga/clk.c | 1 - 1 file changed, 1 deletion(-)
drivers/clk/socfpga/clk.c +0 -1
@@ -60,7 +60,6 @@ extern void __iomem *clk_mgr_base_addr;struct socfpga_clk {struct clk_gate hw;char *parent_name; -char *clk_name;u32 fixed_div;void __iomem *div_reg;u32 width;/* only valid if div_reg != 0 */
Signature · 1 line
1.8.4.rc3
PATCH 2/4 ARM: socfpga: clk: fix define typo
In reply to Steffen TrumtrarIt should be SOCFPGA instead of SOCFGPA.
--- drivers/clk/socfpga/clk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/socfpga/clk.c +3 -3
@@ -43,7 +43,7 @@#define SOCFPGA_PLL_DIVF_SHIFT 3#define SOCFPGA_PLL_DIVQ_MASK 0x003F0000#define SOCFPGA_PLL_DIVQ_SHIFT 16 -#define SOCFGPA_MAX_PARENTS 3 +#define SOCFPGA_MAX_PARENTS 3#define SOCFPGA_L4_MP_CLK "l4_mp_clk"#define SOCFPGA_L4_SP_CLK "l4_sp_clk"
@@ -258,7 +258,7 @@ static void __init socfpga_gate_clk_init(struct device_node *node,struct clk *clk;struct socfpga_clk *socfpga_clk;const char *clk_name = node->name; -const char *parent_name[SOCFGPA_MAX_PARENTS ]; +const char *parent_name[SOCFPGA_MAX_PARENTS ];struct clk_init_data init;int rc;int i =0 ;
@@ -299,7 +299,7 @@ static void __init socfpga_gate_clk_init(struct device_node *node, init.name = clk_name; init.ops = ops; init.flags =0 ; -while (i <SOCFGPA_MAX_PARENTS && (parent_name[i] = +while (i <SOCFPGA_MAX_PARENTS && (parent_name[i] =of_clk_get_parent_name (node, i)) !=NULL ) i++;
Signature · 1 line
1.8.4.rc3
PATCH 3/4 ARM: socfpga: clk: split clk code
In reply to Steffen TrumtrarMove the different kinds of clocks into their own files. The reason is to aid readability of the code. This also goes along with the other SoC-specific clock drivers.
The split introduces new structs for the three types of clocks and uses them. Other changes are not done to the code.
--- drivers/clk/socfpga/Makefile | 3 + drivers/clk/socfpga/clk-gate.c | 197 ++++++++++++++++++++++++ drivers/clk/socfpga/clk-periph.c | 97 ++++++++++++ drivers/clk/socfpga/clk-pll.c | 114 ++++++++++++++ drivers/clk/socfpga/clk.c | 312 +-------------------------------------- drivers/clk/socfpga/clk.h | 54 +++++++ 6 files changed, 466 insertions(+), 311 deletions(-) create mode 100644 drivers/clk/socfpga/clk-gate.c create mode 100644 drivers/clk/socfpga/clk-periph.c create mode 100644 drivers/clk/socfpga/clk-pll.c create mode 100644 drivers/clk/socfpga/clk.h
drivers/clk/socfpga/Makefile +3 -0
@@ -1 +1,4 @@ obj-y += clk.o +obj-y += clk-gate.o +obj-y += clk-pll.o +obj-y += clk-periph.o
drivers/clk/socfpga/clk-gate.c new file +197 -0
197 lines not on this page · raw message
drivers/clk/socfpga/clk-periph.c new file +97 -0
97 lines not on this page · raw message
drivers/clk/socfpga/clk-pll.c new file +114 -0
114 lines not on this page · raw message
drivers/clk/socfpga/clk.c +1 -311
318 lines not on this page · raw message
drivers/clk/socfpga/clk.h new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
1.8.4.rc3
PATCH 4/4 ARM: socfpga: clk: add clk_divider to periph
In reply to Steffen TrumtrarThe socfpga-perip-clks all have a variable clk_divider in their path. Add it to the tree and also use clk_register_fixed_factor for the fixed-dividers instead of a custom implementation.
--- drivers/clk/socfpga/clk-periph.c | 78 ++++++++++++++++++---------------------- drivers/clk/socfpga/clk.h | 6 ++-- 2 files changed, 38 insertions(+), 46 deletions(-)
drivers/clk/socfpga/clk-periph.c +34 -44
@@ -1,6 +1,7 @@/* * Copyright 2011-2012 Calxeda, Inc. * Copyright (C) 2012-2013 Altera Corporation <www.altera.com> +* Copyright (C) 2013 Steffen Trumtrar <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -25,37 +26,17 @@#include "clk.h" -#define to_socfpga_periph_clk (p) container_of(p, struct socfpga_periph_clk, hw.hw) - -static unsigned long clk_periclk_recalc_rate (struct clk_hw *hwclk, -unsigned long parent_rate) -{ -struct socfpga_periph_clk *socfpgaclk =to_socfpga_periph_clk (hwclk); -u32 div; - -if (socfpgaclk->fixed_div) - div = socfpgaclk->fixed_div; -else - div = ((readl (socfpgaclk->hw.reg) &0x1ff ) +1 ); - -return parent_rate / div; -} - -static const struct clk_ops periclk_ops = { - .recalc_rate = clk_periclk_recalc_rate, -}; - -static __init void __socfpga_periph_init (struct device_node *node, -const struct clk_ops *ops) +static __init void __socfpga_periph_init (struct device_node *node) {u32 reg; -struct clk *clk;struct socfpga_periph_clk *periph_clk;const char *clk_name = node->name;const char *parent_name; -struct clk_init_data init; -int rc; +const char *div_name;u32 fixed_div; +int ret; +int i; +unsigned int clk_idx =0 ;of_property_read_u32 (node,"reg" , ®);
@@ -63,35 +44,44 @@ static __init void __socfpga_periph_init(struct device_node *node,if (WARN_ON (!periph_clk))return ; - periph_clk->hw.reg = clk_mgr_base_addr + reg; - - rc =of_property_read_u32 (node,"fixed-divider" , &fixed_div); -if (rc) - periph_clk->fixed_div =0 ; -else - periph_clk->fixed_div = fixed_div; + periph_clk->reg = clk_mgr_base_addr + reg;of_property_read_string (node,"clock-output-names" , &clk_name); - 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 ; - periph_clk->hw.hw.init = &init; +spin_lock_init (&periph_clk->lock); - clk =clk_register (NULL , &periph_clk->hw.hw); -if (WARN_ON (IS_ERR (clk))) { -kfree (periph_clk); -return ; + ret =of_property_read_u32 (node,"fixed-divider" , &fixed_div); +if (!ret) { + div_name =kasprintf (GFP_KERNEL ,"%s_div" , clk_name); + periph_clk->clks[clk_idx++] =clk_register_fixed_factor (NULL , + div_name, parent_name, +0 ,1 , fixed_div); + }else { + div_name =kasprintf (GFP_KERNEL ,"%s" , parent_name); } - rc =of_clk_add_provider (node, of_clk_src_simple_get, clk); + + periph_clk->clks[clk_idx++] =clk_register_divider (NULL , clk_name, + div_name,0 , periph_clk->reg,0 ,9 , +CLK_DIVIDER_ONE_BASED | +CLK_DIVIDER_ALLOW_ZERO , + &periph_clk->lock); + +for (i =0 ; i <ARRAY_SIZE (periph_clk->clks); i++) +if (IS_ERR (periph_clk->clks[i])) +pr_err ("%s: clk %d: register failed with %ld\n" , + node->name, i,PTR_ERR (periph_clk->clks[i])); + +kfree (div_name); + + periph_clk->clk_data.clks = periph_clk->clks; + periph_clk->clk_data.clk_num = clk_idx; +of_clk_add_provider (node, of_clk_src_simple_get, &periph_clk->clk_data); }static void __init socfpga_periph_init (struct device_node *node) { -__socfpga_periph_init (node, &periclk_ops); +__socfpga_periph_init (node); }CLK_OF_DECLARE (socfpga_periph,"altr,socfpga-perip-clk" , socfpga_periph_init);
drivers/clk/socfpga/clk.h +4 -2
@@ -46,9 +46,11 @@ struct socfpga_gate_clk { };struct socfpga_periph_clk { -struct clk_gate hw; +void __iomem *reg; +struct clk_onecell_data clk_data; +struct clk *clks[2 ];char *parent_name; -u32 fixed_div; +spinlock_t lock; };#endif /* SOCFPGA_CLK_H */
Signature · 1 line
1.8.4.rc3
cover Socfpga: clk: trivial fixes and cleanup
In reply to Steffen TrumtrarHi Steffen,
Quoted 9 lines · Steffen Trumtrar
Hi!
This series includes two trivial fixes to the code (1,2), then goes on to split the single
clk.cfile up into clock-type specific files (3) and finally adds a divider to the peripheral clock path.The patches are rebased to the for-next branch of
Quoted 8 lines
git://git.rocketboards.org/linux-socfpga-next.gitRegards,
SteffenSteffen Trumtrar (4):
ARM: socfpga: clk: remove unused field
ARM: socfpga: clk: fix define typo
The first two patches are fine.
Quoted 2 lines
ARM: socfpga: clk: split clk code
ARM: socfpga: clk: addclk_dividerto periph
These two patches are causing the ethernet driver to not be able to grab the correct clock during probe.
Lets wait for 3.13-rc1 and I will push a new for-next that will be more up-to-date.
Thanks,
Dinh
Quoted 13 lines
drivers/clk/socfpga/Makefile | 3 + drivers/clk/socfpga/clk-gate.c | 197 ++++++++++++++++++++++++ drivers/clk/socfpga/clk-periph.c | 87 +++++++++++ drivers/clk/socfpga/clk-pll.c | 114 ++++++++++++++ drivers/clk/socfpga/clk.c | 313 +-------------------------------------- drivers/clk/socfpga/clk.h | 56 +++++++ 6 files changed, 458 insertions(+), 312 deletions(-) create mode 100644 drivers/clk/socfpga/clk-gate.c create mode 100644 drivers/clk/socfpga/clk-periph.c create mode 100644 drivers/clk/socfpga/clk-pll.c create mode 100644 drivers/clk/socfpga/clk.h
cover Socfpga: clk: trivial fixes and cleanup
Quoted 22 lines · Dinh Nguyen
Hi Steffen,
Quoted 9 lines · Steffen Trumtrar
Hi!
This series includes two trivial fixes to the code (1,2), then goes on to split the single
clk.cfile up into clock-type specific files (3) and finally adds a divider to the peripheral clock path.The patches are rebased to the for-next branch of
Quoted 8 lines
git://git.rocketboards.org/linux-socfpga-next.gitRegards,
SteffenSteffen Trumtrar (4):
ARM: socfpga: clk: remove unused field
ARM: socfpga: clk: fix define typoThe first two patches are fine.
Quoted 7 lines
Quoted 2 lines
ARM: socfpga: clk: split clk code
ARM: socfpga: clk: addclk_dividerto periphThese two patches are causing the ethernet driver to not be able to grab the correct clock during probe.
Lets wait for 3.13-rc1 and I will push a new for-next that will be more up-to-date.
Also the values do not look correct with your patch:
per_nand_mmc_clk 1 1 52631578
nand_clk 0 0 13157894
nand_x_clk 0 0 52631578
sdmmc_clk 1 1 52631578Without your patch:
per_nand_mmc_clk 1 1 50000000
nand_clk 0 0 12500000
nand_x_clk 0 0 50000000
sdmmc_clk 1 1 50000000Dinh
Quoted 23 lines
Thanks,
Dinh
Quoted 12 lines
drivers/clk/socfpga/Makefile | 3 + drivers/clk/socfpga/clk-gate.c | 197 ++++++++++++++++++++++++ drivers/clk/socfpga/clk-periph.c | 87 +++++++++++ drivers/clk/socfpga/clk-pll.c | 114 ++++++++++++++ drivers/clk/socfpga/clk.c | 313 +-------------------------------------- drivers/clk/socfpga/clk.h | 56 +++++++ 6 files changed, 458 insertions(+), 312 deletions(-) create mode 100644 drivers/clk/socfpga/clk-gate.c create mode 100644 drivers/clk/socfpga/clk-periph.c create mode 100644 drivers/clk/socfpga/clk-pll.c create mode 100644 drivers/clk/socfpga/clk.h_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
cover Socfpga: clk: trivial fixes and cleanup
Hi Dinh,
Quoted 24 lines · Dinh Nguyen
Quoted 22 lines · Dinh Nguyen
Hi Steffen,
Quoted 9 lines · Steffen Trumtrar
Hi!
This series includes two trivial fixes to the code (1,2), then goes on to split the single
clk.cfile up into clock-type specific files (3) and finally adds a divider to the peripheral clock path.The patches are rebased to the for-next branch of
Quoted 8 lines
git://git.rocketboards.org/linux-socfpga-next.gitRegards,
SteffenSteffen Trumtrar (4):
ARM: socfpga: clk: remove unused field
ARM: socfpga: clk: fix define typoThe first two patches are fine.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
ARM: socfpga: clk: split clk code
ARM: socfpga: clk: addclk_dividerto periphThese two patches are causing the ethernet driver to not be able to grab the correct clock during probe.
Lets wait for 3.13-rc1 and I will push a new for-next that will be more up-to-date.
Hm, okay. It works fine on my SoCKit. But maybe I missed something in the split up.
Quoted 7 lines
Also the values do not look correct with your patch:
per_nand_mmc_clk1 1 52631578nand_clk 0 0 13157894 nand_x_clk 0 0 52631578 sdmmc_clk 1 1 52631578
Quoted 7 lines
Without your patch:
per_nand_mmc_clk1 1 50000000nand_clk 0 0 12500000 nand_x_clk 0 0 50000000 sdmmc_clk 1 1 50000000
Yes. I can confirm that on my board, too. I actually seem to have read over those three values and missed them.
Let's wait for 3.13-rc1, then.
I actually also wanted to change the l3_sp_clk, as it seems to be neglect the "1 or 2" divider from l3_mp_clk IIRC, but I couldn't come up with a good way without changing the binding or something. What do you thing about that? Is that wrong at the moment or do I miss something?
Thanks,
Steffen
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
A message that is not in the archive (sent off-list or not yet received): CADhT+wffgF1veA8ec4zF7J3_4tsKUZXcq5-X9cLCgN5D3A7Nrw@mail.gmail.com
cover Socfpga: clk: trivial fixes and cleanup
Hi Dinh!
Quoted 13 lines · Dinh Nguyen
Hi Steffen,
On Tue, Nov 12, 2013 at 1:40 AM, Steffen Trumtrar <[email protected]
Quoted 8 lines
wrote:
I actually also wanted to change thel3_sp_clk, as it seems to be neglect the "1 or 2" divider froml3_mp_clkIIRC, but I couldn't come up with a good
way without changing the binding or something. What do you thing about that?
Is that wrong at the moment or do I miss something?
Quoted 6 lines
Ah yes, the l3_sp_clk's parent should be
l3_mp_clkand not mainclk.Thanks for spotting that...
Dinh
Hm, that doesn't sound right. Don't we currently have Gate+Divider combo in the l3_mp_clk? If you turn off the clock gate from the l3_mp_clk, then l3_sp_clk would also be turned off.
But according to Figure 2-3 in cv_5v4.pdf
DIV1 --------> GATE -----> L3_MP_CLK
|
|---- DIV2 -----> L3_SP_CLKSo, l3_sp_clk's parent is the divider of l3_mp_clk but NOT the gate.
Regards,
Steffen
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
cover Socfpga: clk: trivial fixes and cleanup
Quoted 28 lines · Steffen Trumtrar
Hi Dinh!
Quoted 13 lines · Dinh Nguyen
Hi Steffen,
On Tue, Nov 12, 2013 at 1:40 AM, Steffen Trumtrar <[email protected]
Quoted 8 lines
wrote:
I actually also wanted to change thel3_sp_clk, as it seems to be neglect the "1 or 2" divider froml3_mp_clkIIRC, but I couldn't come up with a good
way without changing the binding or something. What do you thing about that?
Is that wrong at the moment or do I miss something?Quoted 6 lines
Ah yes, the l3_sp_clk's parent should be
l3_mp_clkand not mainclk.Thanks for spotting that...
Dinh
Hm, that doesn't sound right. Don't we currently have Gate+Divider combo in the
l3_mp_clk? If you turn off the clock gate from thel3_mp_clk, thenl3_sp_clkwould also be turned off.
But according to Figure 2-3 in cv_5v4.pdf
Quoted 5 lines
DIV1 --------> GATE -----> L3_MP_CLK | |---- DIV2 -----> L3_SP_CLKSo, l3_sp_clk's parent is the divider of
l3_mp_clkbut NOT the gate.
ah, yes. I'll have to dig into this issue a bit more.
Dinh
Quoted 4 lines
Regards,
Steffen
cover Socfpga: clk: trivial fixes and cleanup
In reply to Steffen TrumtrarHi Steffen,
Quoted 28 lines · Steffen Trumtrar
Hi Dinh!
Quoted 13 lines · Dinh Nguyen
Hi Steffen,
On Tue, Nov 12, 2013 at 1:40 AM, Steffen Trumtrar <[email protected]
Quoted 8 lines
wrote:
I actually also wanted to change thel3_sp_clk, as it seems to be neglect the "1 or 2" divider froml3_mp_clkIIRC, but I couldn't come up with a good
way without changing the binding or something. What do you thing about that?
Is that wrong at the moment or do I miss something?Quoted 6 lines
Ah yes, the l3_sp_clk's parent should be
l3_mp_clkand not mainclk.Thanks for spotting that...
Dinh
Hm, that doesn't sound right. Don't we currently have Gate+Divider combo in the
l3_mp_clk? If you turn off the clock gate from thel3_mp_clk, thenl3_sp_clkwould also be turned off.
But according to Figure 2-3 in cv_5v4.pdf
Quoted 5 lines
DIV1 --------> GATE -----> L3_MP_CLK | |---- DIV2 -----> L3_SP_CLKSo, l3_sp_clk's parent is the divider of
l3_mp_clkbut NOT the gate.
I just doubled checked. The L3_SP_CLK is taken before the gate of the L3_MP_CLK, so turning off the L3_MP_CLK does not turn off the L3_SP_CLK. So with this information, I think the parent for the L3_SP_CLK can be the L3_MP_CLK, so that the extra divider is accounted for.
Dinh
Quoted 4 lines
Regards,
Steffen
cover Socfpga: clk: trivial fixes and cleanup
Quoted 35 lines · Dinh Nguyen
Hi Steffen,
Quoted 32 lines · Steffen Trumtrar
Hi Dinh!
Quoted 13 lines · Dinh Nguyen
Hi Steffen,
On Tue, Nov 12, 2013 at 1:40 AM, Steffen Trumtrar <[email protected]
Quoted 8 lines
wrote:
I actually also wanted to change thel3_sp_clk, as it seems to be neglect the "1 or 2" divider froml3_mp_clkIIRC, but I couldn't come up with a good
way without changing the binding or something. What do you thing about that?
Is that wrong at the moment or do I miss something?Quoted 6 lines
Ah yes, the l3_sp_clk's parent should be
l3_mp_clkand not mainclk.Thanks for spotting that...
Dinh
Hm, that doesn't sound right. Don't we currently have Gate+Divider combo in the
l3_mp_clk? If you turn off the clock gate from thel3_mp_clk, thenl3_sp_clkwould also be turned off.
But according to Figure 2-3 in cv_5v4.pdfDIV1 --------> GATE -----> L3_MP_CLK | |---- DIV2 -----> L3_SP_CLK
Quoted 6 lines
Quoted 1 line
So, l3_sp_clk's parent is the divider of
l3_mp_clkbut NOT the gate.I just doubled checked. The
L3_SP_CLKis taken before the gate of theL3_MP_CLK, so turning off theL3_MP_CLKdoes not turn off theL3_SP_CLK. So with this information, I think the parent for theL3_SP_CLKcan be theL3_MP_CLK, so that the extra divider is accounted for.
Yes. Giving it another thought, you are right. That should be okay.
Thanks,
Steffen
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |