2013-08-20 02:04:38

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 00/17] ARM: provide common arch init for DT clocks

This RFC converts arch/arm to provide a common arch init for DT clock
providers. Currently, the call to of_clk_init(NULL) to initialize DT
clock providers is spread among several mach-dirs. Since most machs
require DT clocks initialized before timers, no initcall can be used.

By adding of_clk_init(NULL) to ARM time_init(), we can remove all
mach-specific .init_time hooks that basically called of_clk_init before
starting timers. Some machs use the hook for more initialization, that
has been moved to other hooks where required.

The only exception is mach-tegra which requires clocks even earlier in
.init_irq. To allow machs to call clk_of_init at any time earlier than
time_init(), we first need to ensure drivers in __clk_of_table are only
initialized once.

The RFC is based on next-20130819 to catch up with future clock related
changes. It has been tested on mach-mvebu and compile tested for all the
other machs modified. All single patches have also been sent to the
respective maintainers.

Although some patches also modify files in mach-foo and drivers/clk, I
decided to keep them in a single patch to also show what would be
required for a common arch clock init.

Sebastian Hesselbarth (17):
clk: ensure __clk_of_table is only initialized once
ARM: call clk_of_init from time_init
ARM: dove: remove custom .init_time hook
ARM: exynos: remove custom .init_time hook
ARM: highbank: remove custom .init_time hook
ARM: imx: remove custom .init_time hook
ARM: kirkwood: remove custom .init_time hook
ARM: mvebu: remove custom .init_time hook
ARM: mxs: remove custom .init_time hook
ARM: nspire: remove custom .init_time hook
ARM: rockchip: remove custom .init_time hook
ARM: socfpga: remove custom .init_time hook
ARM: sti: remove custom .init_time hook
ARM: tegra: remove .init_time hook to clocksource_of_init
ARM: vexpress: remove custom .init_time hook
clk: vt8500: remove call to of_clk_init
clk: zynq: remove call to of_clk_init

arch/arm/kernel/time.c | 4 ++++
arch/arm/mach-dove/board-dt.c | 16 +---------------
arch/arm/mach-exynos/common.c | 7 -------
arch/arm/mach-exynos/common.h | 1 -
arch/arm/mach-exynos/mach-exynos4-dt.c | 1 -
arch/arm/mach-exynos/mach-exynos5-dt.c | 1 -
arch/arm/mach-highbank/highbank.c | 23 +++++++----------------
arch/arm/mach-imx/clk-imx51-imx53.c | 12 ------------
arch/arm/mach-imx/common.h | 2 --
arch/arm/mach-imx/imx51-dt.c | 6 ------
arch/arm/mach-imx/mach-imx53.c | 6 ------
arch/arm/mach-imx/mach-imx6q.c | 14 +++-----------
arch/arm/mach-imx/mach-imx6sl.c | 7 -------
arch/arm/mach-imx/mach-vf610.c | 9 ---------
arch/arm/mach-kirkwood/board-dt.c | 8 --------
arch/arm/mach-mvebu/armada-370-xp.c | 11 +----------
arch/arm/mach-mxs/mach-mxs.c | 13 -------------
arch/arm/mach-nspire/nspire.c | 9 ---------
arch/arm/mach-rockchip/rockchip.c | 9 ---------
arch/arm/mach-socfpga/socfpga.c | 2 --
arch/arm/mach-sti/board-dt.c | 10 ++++------
arch/arm/mach-tegra/tegra.c | 2 --
arch/arm/mach-vexpress/v2m.c | 14 +-------------
drivers/clk/clk-highbank.c | 10 +++++++---
drivers/clk/clk-vt8500.c | 2 --
drivers/clk/clk.c | 8 +++++++-
drivers/clk/mxs/clk-imx23.c | 16 +++++++---------
drivers/clk/mxs/clk-imx28.c | 16 ++++++++--------
drivers/clk/zynq/clkc.c | 1 -
drivers/clocksource/time-armada-370-xp.c | 7 +++----
include/linux/clk/mxs.h | 2 --
include/linux/time-armada-370-xp.h | 16 ----------------
32 files changed, 53 insertions(+), 212 deletions(-)
delete mode 100644 include/linux/time-armada-370-xp.h

---
Cc: Mike Turquette <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
--
1.7.10.4


2013-08-20 02:04:42

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 01/17] clk: ensure __clk_of_table is only initialized once

This patch ensures DT clock providers are only initialized once by
using a static bool that is set after first call to of_clk_init().

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Mike Turquette <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/clk/clk.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 56a00db..0a8a750 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2117,9 +2117,15 @@ EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
void __init of_clk_init(const struct of_device_id *matches)
{
struct device_node *np;
+ static bool table_done;

- if (!matches)
+ if (!matches) {
+ /* init __clk_of_table drivers only once */
+ if (table_done)
+ return;
matches = __clk_of_table;
+ table_done = true;
+ }

for_each_matching_node(np, matches) {
const struct of_device_id *match = of_match_node(matches, np);
--
1.7.10.4

2013-08-20 02:04:45

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 15/17] ARM: vexpress: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Notes:
- call to versatile_sched_clock_init is moved to .init_early. It is
there for non-DT and existing DT init_early takes care of mapping
its registers.

Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-vexpress/v2m.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index 95a469e..4f8b8cb 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -1,12 +1,10 @@
/*
* Versatile Express V2M Motherboard Support
*/
-#include <linux/clocksource.h>
#include <linux/device.h>
#include <linux/amba/bus.h>
#include <linux/amba/mmci.h>
#include <linux/io.h>
-#include <linux/clocksource.h>
#include <linux/smp.h>
#include <linux/init.h>
#include <linux/of_address.h>
@@ -22,7 +20,6 @@
#include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h>
#include <linux/vexpress.h>
-#include <linux/clk-provider.h>
#include <linux/clkdev.h>

#include <asm/mach-types.h>
@@ -422,16 +419,8 @@ void __init v2m_dt_init_early(void)
pr_warning("vexpress: DT HBI (%x) is not matching "
"hardware (%x)!\n", dt_hbi, hbi);
}
-}
-
-static void __init v2m_dt_timer_init(void)
-{
- of_clk_init(NULL);

- clocksource_of_init();
-
- versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
- 24000000);
+ versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
}

static const struct of_device_id v2m_dt_bus_match[] __initconst = {
@@ -458,6 +447,5 @@ DT_MACHINE_START(VEXPRESS_DT, "ARM-Versatile Express")
.smp_init = smp_init_ops(vexpress_smp_init_ops),
.map_io = v2m_dt_map_io,
.init_early = v2m_dt_init_early,
- .init_time = v2m_dt_timer_init,
.init_machine = v2m_dt_init,
MACHINE_END
--
1.7.10.4

2013-08-20 02:05:00

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 17/17] clk: zynq: remove call to of_clk_init

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove it from corresponding drivers/clk code.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Mike Turquette <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/clk/zynq/clkc.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index 089d3e3..7ca6362 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -532,5 +532,4 @@ CLK_OF_DECLARE(zynq_clkc, "xlnx,ps7-clkc", zynq_clk_setup);
void __init zynq_clock_init(void __iomem *slcr_base)
{
zynq_slcr_base_priv = slcr_base;
- of_clk_init(NULL);
}
--
1.7.10.4

2013-08-20 02:04:41

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 03/17] ARM: dove: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks. While at it, also remove some obsolete
includes.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Jason Cooper <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-dove/board-dt.c | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/arch/arm/mach-dove/board-dt.c b/arch/arm/mach-dove/board-dt.c
index 9a116d7..5ea4491 100644
--- a/arch/arm/mach-dove/board-dt.c
+++ b/arch/arm/mach-dove/board-dt.c
@@ -9,26 +9,13 @@
*/

#include <linux/init.h>
-#include <linux/clk-provider.h>
-#include <linux/clocksource.h>
-#include <linux/irqchip.h>
+#include <linux/mbus.h>
#include <linux/of.h>
#include <linux/of_platform.h>
-#include <linux/platform_data/usb-ehci-orion.h>
#include <asm/hardware/cache-tauros2.h>
#include <asm/mach/arch.h>
-#include <mach/dove.h>
-#include <mach/pm.h>
-#include <plat/common.h>
-#include <plat/irq.h>
#include "common.h"

-static void __init dove_dt_time_init(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static void __init dove_dt_init(void)
{
pr_info("Dove 88AP510 SoC\n");
@@ -47,7 +34,6 @@ static const char * const dove_dt_board_compat[] = {

DT_MACHINE_START(DOVE_DT, "Marvell Dove (Flattened Device Tree)")
.map_io = dove_map_io,
- .init_time = dove_dt_time_init,
.init_machine = dove_dt_init,
.restart = dove_restart,
.dt_compat = dove_dt_board_compat,
--
1.7.10.4

2013-08-20 02:05:35

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 16/17] clk: vt8500: remove call to of_clk_init

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove it from corresponding drivers/clk code.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Mike Turquette <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Tony Prisk <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/clk/clk-vt8500.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
index 82306f5..218d7ba 100644
--- a/drivers/clk/clk-vt8500.c
+++ b/drivers/clk/clk-vt8500.c
@@ -701,6 +701,4 @@ void __init vtwm_clk_init(void __iomem *base)
return;

pmc_base = base;
-
- of_clk_init(NULL);
}
--
1.7.10.4

2013-08-20 02:05:58

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 13/17] ARM: sti: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Notes:
- replacing .init_time with .init_machine isn't really cleanup, but
there is no direct DT probing of l2cc. Anyway, I chose this conversion
so we have no more custom .init_time left. With DT support for l2cc,
temporary .init_machine hook can be removed again.

Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Srinivas Kandagatla <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-sti/board-dt.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-sti/board-dt.c b/arch/arm/mach-sti/board-dt.c
index 8fe6f0c..1217fb5 100644
--- a/arch/arm/mach-sti/board-dt.c
+++ b/arch/arm/mach-sti/board-dt.c
@@ -7,9 +7,8 @@
* published by the Free Software Foundation.
*/

-#include <linux/clk-provider.h>
-#include <linux/clocksource.h>
#include <linux/irq.h>
+#include <linux/of_platform.h>
#include <asm/hardware/cache-l2x0.h>
#include <asm/mach/arch.h>

@@ -28,11 +27,10 @@ void __init stih41x_l2x0_init(void)
l2x0_of_init(aux_ctrl, L2X0_AUX_CTRL_MASK);
}

-static void __init stih41x_timer_init(void)
+static void __init stih41x_machine_init(void)
{
- of_clk_init(NULL);
- clocksource_of_init();
stih41x_l2x0_init();
+ of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
}

static const char *stih41x_dt_match[] __initdata = {
@@ -42,7 +40,7 @@ static const char *stih41x_dt_match[] __initdata = {
};

DT_MACHINE_START(STM, "STiH415/416 SoC with Flattened Device Tree")
- .init_time = stih41x_timer_init,
+ .init_machine = stih41x_machine_init,
.smp = smp_ops(sti_smp_ops),
.dt_compat = stih41x_dt_match,
MACHINE_END
--
1.7.10.4

2013-08-20 02:05:57

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 14/17] ARM: tegra: remove .init_time hook to clocksource_of_init

clocksource_of_init is called on NULL .init_time hook automatically.
Just get rid of it.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Notes:
- tegra calls of_clk_init(NULL) in .init_irq already. With of_clk_init
checking for multiple calls with NULL argument, it is safe to remove
the custom .init_time hook. I have added mach-tegra to make maintainers
aware of this RFC.

Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Stephen Warren <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-tegra/tegra.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index 5b86055..28563d9 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -16,7 +16,6 @@
*
*/

-#include <linux/clocksource.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
@@ -119,7 +118,6 @@ DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)")
.smp = smp_ops(tegra_smp_ops),
.init_early = tegra_init_early,
.init_irq = tegra_dt_init_irq,
- .init_time = clocksource_of_init,
.init_machine = tegra_dt_init,
.init_late = tegra_dt_init_late,
.restart = tegra_assert_system_reset,
--
1.7.10.4

2013-08-20 02:04:39

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 02/17] ARM: call clk_of_init from time_init

Most DT ARM machs require common clock providers initialized before timers.
Currently, arch/arm machs use .init_time to call clk_of_init right before
clocksource_of_init. This prevents to remove that hook and use the default
hook instead. clk_of_init now checks for multiple calls to it, so add
the call to ARM arch time_init by default.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Mike Turquette <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/kernel/time.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index 98aee32..94b51b8 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -22,6 +22,7 @@
#include <linux/errno.h>
#include <linux/profile.h>
#include <linux/timer.h>
+#include <linux/clk-provider.h>
#include <linux/clocksource.h>
#include <linux/irq.h>
#include <linux/sched_clock.h>
@@ -116,6 +117,9 @@ int __init register_persistent_clock(clock_access_fn read_boot,

void __init time_init(void)
{
+ /* initalize common clocks before timers */
+ of_clk_init(NULL);
+
if (machine_desc->init_time)
machine_desc->init_time();
else
--
1.7.10.4

2013-08-20 02:06:46

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 12/17] ARM: socfpga: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Dinh Nguyen <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-socfpga/socfpga.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c
index bfce964..dd0d49c 100644
--- a/arch/arm/mach-socfpga/socfpga.c
+++ b/arch/arm/mach-socfpga/socfpga.c
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <linux/clk-provider.h>
#include <linux/irqchip.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
@@ -107,7 +106,6 @@ static void __init socfpga_cyclone5_init(void)
{
l2x0_of_init(0, ~0UL);
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
- of_clk_init(NULL);
socfpga_init_clocks();
}

--
1.7.10.4

2013-08-20 02:07:16

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 10/17] ARM: nspire: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-nspire/nspire.c | 9 ---------
1 file changed, 9 deletions(-)

diff --git a/arch/arm/mach-nspire/nspire.c b/arch/arm/mach-nspire/nspire.c
index 99e2609..4b2ed2e 100644
--- a/arch/arm/mach-nspire/nspire.c
+++ b/arch/arm/mach-nspire/nspire.c
@@ -14,11 +14,9 @@
#include <linux/of_platform.h>
#include <linux/irqchip.h>
#include <linux/irqchip/arm-vic.h>
-#include <linux/clk-provider.h>
#include <linux/clkdev.h>
#include <linux/amba/bus.h>
#include <linux/amba/clcd.h>
-#include <linux/clocksource.h>

#include <asm/mach/arch.h>
#include <asm/mach-types.h>
@@ -65,12 +63,6 @@ static void __init nspire_init(void)
nspire_auxdata, NULL);
}

-static void __init nspire_init_time(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static void nspire_restart(char mode, const char *cmd)
{
void __iomem *base = ioremap(NSPIRE_MISC_PHYS_BASE, SZ_4K);
@@ -83,7 +75,6 @@ static void nspire_restart(char mode, const char *cmd)
DT_MACHINE_START(NSPIRE, "TI-NSPIRE")
.dt_compat = nspire_dt_match,
.map_io = nspire_map_io,
- .init_time = nspire_init_time,
.init_machine = nspire_init,
.restart = nspire_restart,
MACHINE_END
--
1.7.10.4

2013-08-20 02:07:15

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 06/17] ARM: imx: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Notes:
- Although mx5_clocks_common_init() is shared with non-DT, removing
of_clk_init(NULL) should be fine, as it only registers DT clk providers.
- For imx6q, printing of silicon revision has been moved from .init_time
to .init_machine hook.

Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-imx/clk-imx51-imx53.c | 12 ------------
arch/arm/mach-imx/common.h | 2 --
arch/arm/mach-imx/imx51-dt.c | 6 ------
arch/arm/mach-imx/mach-imx53.c | 6 ------
arch/arm/mach-imx/mach-imx6q.c | 14 +++-----------
arch/arm/mach-imx/mach-imx6sl.c | 7 -------
arch/arm/mach-imx/mach-vf610.c | 9 ---------
7 files changed, 3 insertions(+), 53 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
index 1a56a33..5955a54 100644
--- a/arch/arm/mach-imx/clk-imx51-imx53.c
+++ b/arch/arm/mach-imx/clk-imx51-imx53.c
@@ -131,8 +131,6 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
{
int i;

- of_clk_init(NULL);
-
clk[dummy] = imx_clk_fixed("dummy", 0);
clk[ckil] = imx_obtain_fixed_clock("ckil", rate_ckil);
clk[osc] = imx_obtain_fixed_clock("osc", rate_osc);
@@ -569,13 +567,3 @@ int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,

return 0;
}
-
-int __init mx51_clocks_init_dt(void)
-{
- return mx51_clocks_init(0, 0, 0, 0);
-}
-
-int __init mx53_clocks_init_dt(void)
-{
- return mx53_clocks_init(0, 0, 0, 0);
-}
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index 4517fd7..0ce8313 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -68,8 +68,6 @@ extern int mx53_clocks_init(unsigned long ckil, unsigned long osc,
extern int mx25_clocks_init_dt(void);
extern int mx27_clocks_init_dt(void);
extern int mx31_clocks_init_dt(void);
-extern int mx51_clocks_init_dt(void);
-extern int mx53_clocks_init_dt(void);
extern struct platform_device *mxc_register_gpio(char *name, int id,
resource_size_t iobase, resource_size_t iosize, int irq, int irq_high);
extern void mxc_set_cpu_type(unsigned int type);
diff --git a/arch/arm/mach-imx/imx51-dt.c b/arch/arm/mach-imx/imx51-dt.c
index 53e43e5..bece8a6 100644
--- a/arch/arm/mach-imx/imx51-dt.c
+++ b/arch/arm/mach-imx/imx51-dt.c
@@ -34,17 +34,11 @@ static const char *imx51_dt_board_compat[] __initdata = {
NULL
};

-static void __init imx51_timer_init(void)
-{
- mx51_clocks_init_dt();
-}
-
DT_MACHINE_START(IMX51_DT, "Freescale i.MX51 (Device Tree Support)")
.map_io = mx51_map_io,
.init_early = imx51_init_early,
.init_irq = mx51_init_irq,
.handle_irq = imx51_handle_irq,
- .init_time = imx51_timer_init,
.init_machine = imx51_dt_init,
.init_late = imx51_init_late,
.dt_compat = imx51_dt_board_compat,
diff --git a/arch/arm/mach-imx/mach-imx53.c b/arch/arm/mach-imx/mach-imx53.c
index 98c5894..c9c4d8d 100644
--- a/arch/arm/mach-imx/mach-imx53.c
+++ b/arch/arm/mach-imx/mach-imx53.c
@@ -36,17 +36,11 @@ static const char *imx53_dt_board_compat[] __initdata = {
NULL
};

-static void __init imx53_timer_init(void)
-{
- mx53_clocks_init_dt();
-}
-
DT_MACHINE_START(IMX53_DT, "Freescale i.MX53 (Device Tree Support)")
.map_io = mx53_map_io,
.init_early = imx53_init_early,
.init_irq = mx53_init_irq,
.handle_irq = imx53_handle_irq,
- .init_time = imx53_timer_init,
.init_machine = imx53_dt_init,
.init_late = imx53_init_late,
.dt_compat = imx53_dt_board_compat,
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index b605098..ad71738 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -11,9 +11,7 @@
*/

#include <linux/clk.h>
-#include <linux/clk-provider.h>
#include <linux/clkdev.h>
-#include <linux/clocksource.h>
#include <linux/cpu.h>
#include <linux/delay.h>
#include <linux/export.h>
@@ -192,6 +190,9 @@ static void __init imx6q_1588_init(void)

static void __init imx6q_init_machine(void)
{
+ imx_print_silicon_rev(cpu_is_imx6dl() ? "i.MX6DL" : "i.MX6Q",
+ imx6q_revision());
+
imx6q_enet_phy_init();

of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
@@ -289,14 +290,6 @@ static void __init imx6q_init_irq(void)
irqchip_init();
}

-static void __init imx6q_timer_init(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
- imx_print_silicon_rev(cpu_is_imx6dl() ? "i.MX6DL" : "i.MX6Q",
- imx6q_revision());
-}
-
static const char *imx6q_dt_compat[] __initdata = {
"fsl,imx6dl",
"fsl,imx6q",
@@ -307,7 +300,6 @@ DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad/DualLite (Device Tree)")
.smp = smp_ops(imx_smp_ops),
.map_io = imx6q_map_io,
.init_irq = imx6q_init_irq,
- .init_time = imx6q_timer_init,
.init_machine = imx6q_init_machine,
.init_late = imx6q_init_late,
.dt_compat = imx6q_dt_compat,
diff --git a/arch/arm/mach-imx/mach-imx6sl.c b/arch/arm/mach-imx/mach-imx6sl.c
index 0d75dc5..c70bd7c 100644
--- a/arch/arm/mach-imx/mach-imx6sl.c
+++ b/arch/arm/mach-imx/mach-imx6sl.c
@@ -7,7 +7,6 @@
*
*/

-#include <linux/clk-provider.h>
#include <linux/irqchip.h>
#include <linux/of.h>
#include <linux/of_platform.h>
@@ -31,11 +30,6 @@ static void __init imx6sl_init_irq(void)
irqchip_init();
}

-static void __init imx6sl_timer_init(void)
-{
- of_clk_init(NULL);
-}
-
static const char *imx6sl_dt_compat[] __initdata = {
"fsl,imx6sl",
NULL,
@@ -44,7 +38,6 @@ static const char *imx6sl_dt_compat[] __initdata = {
DT_MACHINE_START(IMX6SL, "Freescale i.MX6 SoloLite (Device Tree)")
.map_io = debug_ll_io_init,
.init_irq = imx6sl_init_irq,
- .init_time = imx6sl_timer_init,
.init_machine = imx6sl_init_machine,
.dt_compat = imx6sl_dt_compat,
.restart = mxc_restart,
diff --git a/arch/arm/mach-imx/mach-vf610.c b/arch/arm/mach-imx/mach-vf610.c
index 816991d..af0cb8a 100644
--- a/arch/arm/mach-imx/mach-vf610.c
+++ b/arch/arm/mach-imx/mach-vf610.c
@@ -8,9 +8,7 @@
*/

#include <linux/of_platform.h>
-#include <linux/clocksource.h>
#include <linux/irqchip.h>
-#include <linux/clk-provider.h>
#include <asm/mach/arch.h>
#include <asm/hardware/cache-l2x0.h>

@@ -28,12 +26,6 @@ static void __init vf610_init_irq(void)
irqchip_init();
}

-static void __init vf610_init_time(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static const char *vf610_dt_compat[] __initdata = {
"fsl,vf610",
NULL,
@@ -41,7 +33,6 @@ static const char *vf610_dt_compat[] __initdata = {

DT_MACHINE_START(VYBRID_VF610, "Freescale Vybrid VF610 (Device Tree)")
.init_irq = vf610_init_irq,
- .init_time = vf610_init_time,
.init_machine = vf610_init_machine,
.dt_compat = vf610_dt_compat,
.restart = mxc_restart,
--
1.7.10.4

2013-08-20 02:07:13

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 08/17] ARM: mvebu: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Notes:
- coherency, mbus, and cache init are moved to .init_machine hook
- time-armada-370-xp is converted to clocksource_of_init compatible init

Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Gregory Clement <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-mvebu/armada-370-xp.c | 11 +----------
drivers/clocksource/time-armada-370-xp.c | 7 +++----
include/linux/time-armada-370-xp.h | 16 ----------------
3 files changed, 4 insertions(+), 30 deletions(-)
delete mode 100644 include/linux/time-armada-370-xp.h

diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
index 829b573..139f572 100644
--- a/arch/arm/mach-mvebu/armada-370-xp.c
+++ b/arch/arm/mach-mvebu/armada-370-xp.c
@@ -14,11 +14,9 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/clk-provider.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/io.h>
-#include <linux/time-armada-370-xp.h>
#include <linux/dma-mapping.h>
#include <linux/mbus.h>
#include <asm/hardware/cache-l2x0.h>
@@ -34,19 +32,13 @@ static void __init armada_370_xp_map_io(void)
debug_ll_io_init();
}

-static void __init armada_370_xp_timer_and_clk_init(void)
+static void __init armada_370_xp_dt_init(void)
{
- of_clk_init(NULL);
- armada_370_xp_timer_init();
coherency_init();
BUG_ON(mvebu_mbus_dt_init());
#ifdef CONFIG_CACHE_L2X0
l2x0_of_init(0, ~0UL);
#endif
-}
-
-static void __init armada_370_xp_dt_init(void)
-{
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
}

@@ -59,7 +51,6 @@ DT_MACHINE_START(ARMADA_XP_DT, "Marvell Armada 370/XP (Device Tree)")
.smp = smp_ops(armada_xp_smp_ops),
.init_machine = armada_370_xp_dt_init,
.map_io = armada_370_xp_map_io,
- .init_time = armada_370_xp_timer_and_clk_init,
.restart = mvebu_restart,
.dt_compat = armada_370_xp_dt_compat,
MACHINE_END
diff --git a/drivers/clocksource/time-armada-370-xp.c b/drivers/clocksource/time-armada-370-xp.c
index 847cab6..67904cf 100644
--- a/drivers/clocksource/time-armada-370-xp.c
+++ b/drivers/clocksource/time-armada-370-xp.c
@@ -30,7 +30,6 @@
#include <linux/module.h>
#include <linux/sched_clock.h>
#include <linux/percpu.h>
-#include <linux/time-armada-370-xp.h>

/*
* Timer block registers.
@@ -217,13 +216,11 @@ static struct notifier_block armada_370_xp_timer_cpu_nb = {
.notifier_call = armada_370_xp_timer_cpu_notify,
};

-void __init armada_370_xp_timer_init(void)
+void __init armada_370_xp_timer_init(struct device_node *np)
{
u32 u;
- struct device_node *np;
int res;

- np = of_find_compatible_node(NULL, NULL, "marvell,armada-370-xp-timer");
timer_base = of_iomap(np, 0);
WARN_ON(!timer_base);
local_base = of_iomap(np, 1);
@@ -293,3 +290,5 @@ void __init armada_370_xp_timer_init(void)
if (!res)
armada_370_xp_timer_setup(this_cpu_ptr(armada_370_xp_evt));
}
+CLOCKSOURCE_OF_DECLARE(armada_370_xp_timer, "marvell,armada-370-xp-timer",
+ armada_370_xp_timer_init);
diff --git a/include/linux/time-armada-370-xp.h b/include/linux/time-armada-370-xp.h
deleted file mode 100644
index 6fb0856..0000000
--- a/include/linux/time-armada-370-xp.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Marvell Armada 370/XP SoC timer handling.
- *
- * Copyright (C) 2012 Marvell
- *
- * Lior Amsalem <[email protected]>
- * Gregory CLEMENT <[email protected]>
- * Thomas Petazzoni <[email protected]>
- *
- */
-#ifndef __TIME_ARMADA_370_XPPRCMU_H
-#define __TIME_ARMADA_370_XPPRCMU_H
-
-void armada_370_xp_timer_init(void);
-
-#endif
--
1.7.10.4

2013-08-20 02:07:10

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 09/17] ARM: mxs: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Notes:
- clk-imx2[38] are converted to clocksource_of_init compatible init
associated with fsl,imx2[38]-clkctrl

Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-mxs/mach-mxs.c | 13 -------------
drivers/clk/mxs/clk-imx23.c | 16 +++++++---------
drivers/clk/mxs/clk-imx28.c | 16 ++++++++--------
include/linux/clk/mxs.h | 2 --
4 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 98f6e2a..cc511a4 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -13,8 +13,6 @@
#include <linux/clk.h>
#include <linux/clk/mxs.h>
#include <linux/clkdev.h>
-#include <linux/clocksource.h>
-#include <linux/clk-provider.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/gpio.h>
@@ -490,16 +488,6 @@ static void mxs_restart(enum reboot_mode mode, const char *cmd)
soft_restart(0);
}

-static void __init mxs_timer_init(void)
-{
- if (of_machine_is_compatible("fsl,imx23"))
- mx23_clocks_init();
- else
- mx28_clocks_init();
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static const char *mxs_dt_compat[] __initdata = {
"fsl,imx28",
"fsl,imx23",
@@ -508,7 +496,6 @@ static const char *mxs_dt_compat[] __initdata = {

DT_MACHINE_START(MXS, "Freescale MXS (Device Tree)")
.handle_irq = icoll_handle_irq,
- .init_time = mxs_timer_init,
.init_machine = mxs_machine_init,
.init_late = mxs_pm_init,
.dt_compat = mxs_dt_compat,
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
index c396fe3..7c2794d 100644
--- a/drivers/clk/mxs/clk-imx23.c
+++ b/drivers/clk/mxs/clk-imx23.c
@@ -12,6 +12,7 @@
#include <linux/clk.h>
#include <linux/clk/mxs.h>
#include <linux/clkdev.h>
+#include <linux/clk-provider.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/io.h>
@@ -100,19 +101,17 @@ static enum imx23_clk clks_init_on[] __initdata = {
cpu, hbus, xbus, emi, uart,
};

-int __init mx23_clocks_init(void)
+void __init mx23_clocks_init(struct device_node *np)
{
- struct device_node *np;
u32 i;

+ clkctrl = of_iomap(np, 0);
+ WARN_ON(!clkctrl);
+
np = of_find_compatible_node(NULL, NULL, "fsl,imx23-digctl");
digctrl = of_iomap(np, 0);
WARN_ON(!digctrl);

- np = of_find_compatible_node(NULL, NULL, "fsl,imx23-clkctrl");
- clkctrl = of_iomap(np, 0);
- WARN_ON(!clkctrl);
-
clk_misc_init();

clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
@@ -162,7 +161,7 @@ int __init mx23_clocks_init(void)
if (IS_ERR(clks[i])) {
pr_err("i.MX23 clk %d: register failed with %ld\n",
i, PTR_ERR(clks[i]));
- return PTR_ERR(clks[i]);
+ return;
}

clk_data.clks = clks;
@@ -171,6 +170,5 @@ int __init mx23_clocks_init(void)

for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
clk_prepare_enable(clks[clks_init_on[i]]);
-
- return 0;
}
+CLK_OF_DECLARE(imx23_clkctrl, "fsl,imx23-clkctrl", mx23_clocks_init);
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
index 4faf0af..5627fa2 100644
--- a/drivers/clk/mxs/clk-imx28.c
+++ b/drivers/clk/mxs/clk-imx28.c
@@ -12,6 +12,7 @@
#include <linux/clk.h>
#include <linux/clk/mxs.h>
#include <linux/clkdev.h>
+#include <linux/clk-provider.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/io.h>
@@ -154,19 +155,17 @@ static enum imx28_clk clks_init_on[] __initdata = {
cpu, hbus, xbus, emi, uart,
};

-int __init mx28_clocks_init(void)
+void __init mx28_clocks_init(struct device_node *np)
{
- struct device_node *np;
u32 i;

+ clkctrl = of_iomap(np, 0);
+ WARN_ON(!clkctrl);
+
np = of_find_compatible_node(NULL, NULL, "fsl,imx28-digctl");
digctrl = of_iomap(np, 0);
WARN_ON(!digctrl);

- np = of_find_compatible_node(NULL, NULL, "fsl,imx28-clkctrl");
- clkctrl = of_iomap(np, 0);
- WARN_ON(!clkctrl);
-
clk_misc_init();

clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
@@ -239,7 +238,7 @@ int __init mx28_clocks_init(void)
if (IS_ERR(clks[i])) {
pr_err("i.MX28 clk %d: register failed with %ld\n",
i, PTR_ERR(clks[i]));
- return PTR_ERR(clks[i]);
+ return;
}

clk_data.clks = clks;
@@ -251,5 +250,6 @@ int __init mx28_clocks_init(void)
for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
clk_prepare_enable(clks[clks_init_on[i]]);

- return 0;
+ return;
}
+CLK_OF_DECLARE(imx28_clkctrl, "fsl,imx28-clkctrl", mx28_clocks_init);
diff --git a/include/linux/clk/mxs.h b/include/linux/clk/mxs.h
index 90c30dc..5138a90 100644
--- a/include/linux/clk/mxs.h
+++ b/include/linux/clk/mxs.h
@@ -9,8 +9,6 @@
#ifndef __LINUX_CLK_MXS_H
#define __LINUX_CLK_MXS_H

-int mx23_clocks_init(void);
-int mx28_clocks_init(void);
int mxs_saif_clkmux_select(unsigned int clkmux);

#endif
--
1.7.10.4

2013-08-20 02:07:08

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 11/17] ARM: rockchip: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-rockchip/rockchip.c | 9 ---------
1 file changed, 9 deletions(-)

diff --git a/arch/arm/mach-rockchip/rockchip.c b/arch/arm/mach-rockchip/rockchip.c
index 724d2d8..82c0b07 100644
--- a/arch/arm/mach-rockchip/rockchip.c
+++ b/arch/arm/mach-rockchip/rockchip.c
@@ -19,18 +19,10 @@
#include <linux/init.h>
#include <linux/of_platform.h>
#include <linux/irqchip.h>
-#include <linux/dw_apb_timer.h>
-#include <linux/clk-provider.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/hardware/cache-l2x0.h>

-static void __init rockchip_timer_init(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static void __init rockchip_dt_init(void)
{
l2x0_of_init(0, ~0UL);
@@ -47,6 +39,5 @@ static const char * const rockchip_board_dt_compat[] = {

DT_MACHINE_START(ROCKCHIP_DT, "Rockchip Cortex-A9 (Device Tree)")
.init_machine = rockchip_dt_init,
- .init_time = rockchip_timer_init,
.dt_compat = rockchip_board_dt_compat,
MACHINE_END
--
1.7.10.4

2013-08-20 02:08:37

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 07/17] ARM: kirkwood: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Jason Cooper <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-kirkwood/board-dt.c | 8 --------
1 file changed, 8 deletions(-)

diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index 82d3ad8..a32a3e5 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -15,7 +15,6 @@
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/clk-provider.h>
-#include <linux/clocksource.h>
#include <linux/dma-mapping.h>
#include <linux/irqchip.h>
#include <linux/kexec.h>
@@ -66,12 +65,6 @@ static void __init kirkwood_legacy_clk_init(void)
clk_prepare_enable(clk);
}

-static void __init kirkwood_dt_time_init(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static void __init kirkwood_dt_init_early(void)
{
mvebu_mbus_init("marvell,kirkwood-mbus",
@@ -122,7 +115,6 @@ DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
/* Maintainer: Jason Cooper <[email protected]> */
.map_io = kirkwood_map_io,
.init_early = kirkwood_dt_init_early,
- .init_time = kirkwood_dt_time_init,
.init_machine = kirkwood_dt_init,
.restart = kirkwood_restart,
.dt_compat = kirkwood_dt_board_compat,
--
1.7.10.4

2013-08-20 02:08:52

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 05/17] ARM: highbank: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks. Highbank clock provider need a reference
to system registers, as a workaround current clk driver maps those
independent of arch code now.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Notes:
- I suggest to consolidate the four single clock providers into a single
provider with one node if possible.

Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-highbank/highbank.c | 23 +++++++----------------
drivers/clk/clk-highbank.c | 10 +++++++---
2 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 1894dcf..efa9496 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -27,7 +27,6 @@
#include <linux/of_address.h>
#include <linux/smp.h>
#include <linux/amba/bus.h>
-#include <linux/clk-provider.h>

#include <asm/cacheflush.h>
#include <asm/cputype.h>
@@ -88,20 +87,6 @@ static void __init highbank_init_irq(void)
#endif
}

-static void __init highbank_timer_init(void)
-{
- struct device_node *np;
-
- /* Map system registers */
- np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
- sregs_base = of_iomap(np, 0);
- WARN_ON(!sregs_base);
-
- of_clk_init(NULL);
-
- clocksource_of_init();
-}
-
static void highbank_power_off(void)
{
highbank_set_pwr_shutdown();
@@ -160,6 +145,13 @@ static struct notifier_block highbank_platform_nb = {

static void __init highbank_init(void)
{
+ struct device_node *np;
+
+ /* Map system registers */
+ np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
+ sregs_base = of_iomap(np, 0);
+ WARN_ON(!sregs_base);
+
pm_power_off = highbank_power_off;
highbank_pm_init();

@@ -181,7 +173,6 @@ DT_MACHINE_START(HIGHBANK, "Highbank")
#endif
.smp = smp_ops(highbank_smp_ops),
.init_irq = highbank_init_irq,
- .init_time = highbank_timer_init,
.init_machine = highbank_init,
.dt_compat = highbank_match,
.restart = highbank_restart,
diff --git a/drivers/clk/clk-highbank.c b/drivers/clk/clk-highbank.c
index 2e08cb0..2e7e9d9 100644
--- a/drivers/clk/clk-highbank.c
+++ b/drivers/clk/clk-highbank.c
@@ -20,8 +20,7 @@
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/of.h>
-
-extern void __iomem *sregs_base;
+#include <linux/of_address.h>

#define HB_PLL_LOCK_500 0x20000000
#define HB_PLL_LOCK 0x10000000
@@ -280,6 +279,7 @@ static __init struct clk *hb_clk_init(struct device_node *node, const struct clk
const char *clk_name = node->name;
const char *parent_name;
struct clk_init_data init;
+ struct device_node *srnp;
int rc;

rc = of_property_read_u32(node, "reg", &reg);
@@ -290,7 +290,11 @@ static __init struct clk *hb_clk_init(struct device_node *node, const struct clk
if (WARN_ON(!hb_clk))
return NULL;

- hb_clk->reg = sregs_base + reg;
+ /* Map system registers */
+ srnp = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
+ hb_clk->reg = of_iomap(srnp, 0);
+ BUG_ON(!hb_clk->reg);
+ hb_clk->reg += reg;

of_property_read_string(node, "clock-output-names", &clk_name);

--
1.7.10.4

2013-08-20 02:09:14

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC 04/17] ARM: exynos: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Kukjin Kim <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-exynos/common.c | 7 -------
arch/arm/mach-exynos/common.h | 1 -
arch/arm/mach-exynos/mach-exynos4-dt.c | 1 -
arch/arm/mach-exynos/mach-exynos5-dt.c | 1 -
4 files changed, 10 deletions(-)

diff --git a/arch/arm/mach-exynos/common.c b/arch/arm/mach-exynos/common.c
index ba95e5d..587625b 100644
--- a/arch/arm/mach-exynos/common.c
+++ b/arch/arm/mach-exynos/common.c
@@ -27,7 +27,6 @@
#include <linux/irqdomain.h>
#include <linux/of_address.h>
#include <linux/clocksource.h>
-#include <linux/clk-provider.h>
#include <linux/irqchip/arm-gic.h>
#include <linux/irqchip/chained_irq.h>

@@ -367,12 +366,6 @@ static void __init exynos5_map_io(void)
iotable_init(exynos5250_iodesc, ARRAY_SIZE(exynos5250_iodesc));
}

-void __init exynos_init_time(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
struct bus_type exynos_subsys = {
.name = "exynos-core",
.dev_name = "exynos-core",
diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index 8646a14..f0fa205 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -16,7 +16,6 @@
#include <linux/of.h>

void mct_init(void __iomem *base, int irq_g0, int irq_l0, int irq_l1);
-void exynos_init_time(void);

struct map_desc;
void exynos_init_io(void);
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c b/arch/arm/mach-exynos/mach-exynos4-dt.c
index 0099c6c..7458dd4 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -54,7 +54,6 @@ DT_MACHINE_START(EXYNOS4210_DT, "Samsung Exynos4 (Flattened Device Tree)")
.init_early = exynos_firmware_init,
.init_machine = exynos4_dt_machine_init,
.init_late = exynos_init_late,
- .init_time = exynos_init_time,
.dt_compat = exynos4_dt_compat,
.restart = exynos4_restart,
.reserve = exynos4_reserve,
diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
index f874b77..8829da2 100644
--- a/arch/arm/mach-exynos/mach-exynos5-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
@@ -76,7 +76,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
.map_io = exynos_init_io,
.init_machine = exynos5_dt_machine_init,
.init_late = exynos_init_late,
- .init_time = exynos_init_time,
.dt_compat = exynos5_dt_compat,
.restart = exynos5_restart,
.reserve = exynos5_reserve,
--
1.7.10.4

2013-08-20 07:27:05

by Sascha Hauer

[permalink] [raw]
Subject: Re: [RFC 06/17] ARM: imx: remove custom .init_time hook

On Tue, Aug 20, 2013 at 04:04:20AM +0200, Sebastian Hesselbarth wrote:
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove custom .init_time hooks.
>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>
> ---
> Notes:
> - Although mx5_clocks_common_init() is shared with non-DT, removing
> of_clk_init(NULL) should be fine, as it only registers DT clk providers.
> - For imx6q, printing of silicon revision has been moved from .init_time
> to .init_machine hook.
>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Sascha Hauer <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/arm/mach-imx/clk-imx51-imx53.c | 12 ------------
> arch/arm/mach-imx/common.h | 2 --
> arch/arm/mach-imx/imx51-dt.c | 6 ------
> arch/arm/mach-imx/mach-imx53.c | 6 ------
> arch/arm/mach-imx/mach-imx6q.c | 14 +++-----------
> arch/arm/mach-imx/mach-imx6sl.c | 7 -------
> arch/arm/mach-imx/mach-vf610.c | 9 ---------
> 7 files changed, 3 insertions(+), 53 deletions(-)
>
> diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
> index 1a56a33..5955a54 100644
> --- a/arch/arm/mach-imx/clk-imx51-imx53.c
> +++ b/arch/arm/mach-imx/clk-imx51-imx53.c
> @@ -131,8 +131,6 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
> {
> int i;
>
> - of_clk_init(NULL);
> -
> clk[dummy] = imx_clk_fixed("dummy", 0);
> clk[ckil] = imx_obtain_fixed_clock("ckil", rate_ckil);
> clk[osc] = imx_obtain_fixed_clock("osc", rate_osc);
> @@ -569,13 +567,3 @@ int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
>
> return 0;
> }
> -
> -int __init mx51_clocks_init_dt(void)
> -{
> - return mx51_clocks_init(0, 0, 0, 0);
> -}
> -
> -int __init mx53_clocks_init_dt(void)
> -{
> - return mx53_clocks_init(0, 0, 0, 0);
> -}
> diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
> index 4517fd7..0ce8313 100644
> --- a/arch/arm/mach-imx/common.h
> +++ b/arch/arm/mach-imx/common.h
> @@ -68,8 +68,6 @@ extern int mx53_clocks_init(unsigned long ckil, unsigned long osc,
> extern int mx25_clocks_init_dt(void);
> extern int mx27_clocks_init_dt(void);
> extern int mx31_clocks_init_dt(void);
> -extern int mx51_clocks_init_dt(void);
> -extern int mx53_clocks_init_dt(void);
> extern struct platform_device *mxc_register_gpio(char *name, int id,
> resource_size_t iobase, resource_size_t iosize, int irq, int irq_high);
> extern void mxc_set_cpu_type(unsigned int type);
> diff --git a/arch/arm/mach-imx/imx51-dt.c b/arch/arm/mach-imx/imx51-dt.c
> index 53e43e5..bece8a6 100644
> --- a/arch/arm/mach-imx/imx51-dt.c
> +++ b/arch/arm/mach-imx/imx51-dt.c
> @@ -34,17 +34,11 @@ static const char *imx51_dt_board_compat[] __initdata = {
> NULL
> };
>
> -static void __init imx51_timer_init(void)
> -{
> - mx51_clocks_init_dt();
> -}
> -
> DT_MACHINE_START(IMX51_DT, "Freescale i.MX51 (Device Tree Support)")
> .map_io = mx51_map_io,
> .init_early = imx51_init_early,
> .init_irq = mx51_init_irq,
> .handle_irq = imx51_handle_irq,
> - .init_time = imx51_timer_init,

On i.MX5 the init_time hook calls mx5x_clocks_init_dt which calls
mx5x_clocks_init which not only calls of_clk_init() but also registers
all clocks in the system. You can't remove it.

I am missing some

CLK_OF_DECLARE(imx51, "fsl,imx51-ccm", imx51_clocks_init);
CLK_OF_DECLARE(imx53, "fsl,imx53-ccm", imx53_clocks_init);

Somewhere.

Sascha

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

2013-08-20 08:48:58

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 06/17] ARM: imx: remove custom .init_time hook

On 08/20/2013 09:26 AM, Sascha Hauer wrote:
> On Tue, Aug 20, 2013 at 04:04:20AM +0200, Sebastian Hesselbarth wrote:
>> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
>> remove custom .init_time hooks.
>>
>> Signed-off-by: Sebastian Hesselbarth <[email protected]>
>> ---
>> Notes:
>> - Although mx5_clocks_common_init() is shared with non-DT, removing
>> of_clk_init(NULL) should be fine, as it only registers DT clk providers.
>> - For imx6q, printing of silicon revision has been moved from .init_time
>> to .init_machine hook.
>>
>> Cc: Russell King <[email protected]>
>> Cc: Arnd Bergmann <[email protected]>
>> Cc: Sascha Hauer <[email protected]>
>> Cc: [email protected]
>> Cc: [email protected]
>> ---
>> arch/arm/mach-imx/clk-imx51-imx53.c | 12 ------------
>> arch/arm/mach-imx/common.h | 2 --
>> arch/arm/mach-imx/imx51-dt.c | 6 ------
>> arch/arm/mach-imx/mach-imx53.c | 6 ------
>> arch/arm/mach-imx/mach-imx6q.c | 14 +++-----------
>> arch/arm/mach-imx/mach-imx6sl.c | 7 -------
>> arch/arm/mach-imx/mach-vf610.c | 9 ---------
>> 7 files changed, 3 insertions(+), 53 deletions(-)
>>
>> diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
>> index 1a56a33..5955a54 100644
>> --- a/arch/arm/mach-imx/clk-imx51-imx53.c
>> +++ b/arch/arm/mach-imx/clk-imx51-imx53.c
>> @@ -131,8 +131,6 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
>> {
>> int i;
>>
>> - of_clk_init(NULL);
>> -
>> clk[dummy] = imx_clk_fixed("dummy", 0);
>> clk[ckil] = imx_obtain_fixed_clock("ckil", rate_ckil);
>> clk[osc] = imx_obtain_fixed_clock("osc", rate_osc);
>> @@ -569,13 +567,3 @@ int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
>>
>> return 0;
>> }
>> -
>> -int __init mx51_clocks_init_dt(void)
>> -{
>> - return mx51_clocks_init(0, 0, 0, 0);
>> -}
>> -
>> -int __init mx53_clocks_init_dt(void)
>> -{
>> - return mx53_clocks_init(0, 0, 0, 0);
>> -}
>> diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
>> index 4517fd7..0ce8313 100644
>> --- a/arch/arm/mach-imx/common.h
>> +++ b/arch/arm/mach-imx/common.h
>> @@ -68,8 +68,6 @@ extern int mx53_clocks_init(unsigned long ckil, unsigned long osc,
>> extern int mx25_clocks_init_dt(void);
>> extern int mx27_clocks_init_dt(void);
>> extern int mx31_clocks_init_dt(void);
>> -extern int mx51_clocks_init_dt(void);
>> -extern int mx53_clocks_init_dt(void);
>> extern struct platform_device *mxc_register_gpio(char *name, int id,
>> resource_size_t iobase, resource_size_t iosize, int irq, int irq_high);
>> extern void mxc_set_cpu_type(unsigned int type);
>> diff --git a/arch/arm/mach-imx/imx51-dt.c b/arch/arm/mach-imx/imx51-dt.c
>> index 53e43e5..bece8a6 100644
>> --- a/arch/arm/mach-imx/imx51-dt.c
>> +++ b/arch/arm/mach-imx/imx51-dt.c
>> @@ -34,17 +34,11 @@ static const char *imx51_dt_board_compat[] __initdata = {
>> NULL
>> };
>>
>> -static void __init imx51_timer_init(void)
>> -{
>> - mx51_clocks_init_dt();
>> -}
>> -
>> DT_MACHINE_START(IMX51_DT, "Freescale i.MX51 (Device Tree Support)")
>> .map_io = mx51_map_io,
>> .init_early = imx51_init_early,
>> .init_irq = mx51_init_irq,
>> .handle_irq = imx51_handle_irq,
>> - .init_time = imx51_timer_init,
>
> On i.MX5 the init_time hook calls mx5x_clocks_init_dt which calls
> mx5x_clocks_init which not only calls of_clk_init() but also registers
> all clocks in the system. You can't remove it.
>
> I am missing some
>
> CLK_OF_DECLARE(imx51, "fsl,imx51-ccm", imx51_clocks_init);
> CLK_OF_DECLARE(imx53, "fsl,imx53-ccm", imx53_clocks_init);
>
> Somewhere.

Sascha,

you are right, I forgot to add the two lines above as replacement for
the now removed direct call. If the general approach is accepted, I'll
add them for sure.

Do imx51/imx53 still boot with CLK_OF_DECLARE added?

Sebastian

2013-08-20 09:10:08

by Sascha Hauer

[permalink] [raw]
Subject: Re: [RFC 06/17] ARM: imx: remove custom .init_time hook

On Tue, Aug 20, 2013 at 10:48:44AM +0200, Sebastian Hesselbarth wrote:
> On 08/20/2013 09:26 AM, Sascha Hauer wrote:
> >On i.MX5 the init_time hook calls mx5x_clocks_init_dt which calls
> >mx5x_clocks_init which not only calls of_clk_init() but also registers
> >all clocks in the system. You can't remove it.
> >
> >I am missing some
> >
> >CLK_OF_DECLARE(imx51, "fsl,imx51-ccm", imx51_clocks_init);
> >CLK_OF_DECLARE(imx53, "fsl,imx53-ccm", imx53_clocks_init);
> >
> >Somewhere.
>
> Sascha,
>
> you are right, I forgot to add the two lines above as replacement for
> the now removed direct call. If the general approach is accepted, I'll
> add them for sure.
>
> Do imx51/imx53 still boot with CLK_OF_DECLARE added?

I can test this once the whole series arrived here. So far I only have
6/16 and 10/17. I probably need at least 1/17.

Sascha


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

2013-08-20 09:19:54

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 06/17] ARM: imx: remove custom .init_time hook

On 08/20/2013 11:10 AM, Sascha Hauer wrote:
> On Tue, Aug 20, 2013 at 10:48:44AM +0200, Sebastian Hesselbarth wrote:
>> On 08/20/2013 09:26 AM, Sascha Hauer wrote:
>>> On i.MX5 the init_time hook calls mx5x_clocks_init_dt which calls
>>> mx5x_clocks_init which not only calls of_clk_init() but also registers
>>> all clocks in the system. You can't remove it.
>>>
>>> I am missing some
>>>
>>> CLK_OF_DECLARE(imx51, "fsl,imx51-ccm", imx51_clocks_init);
>>> CLK_OF_DECLARE(imx53, "fsl,imx53-ccm", imx53_clocks_init);
>>>
>>> Somewhere.
>>
>> Sascha,
>>
>> you are right, I forgot to add the two lines above as replacement for
>> the now removed direct call. If the general approach is accepted, I'll
>> add them for sure.
>>
>> Do imx51/imx53 still boot with CLK_OF_DECLARE added?
>
> I can test this once the whole series arrived here. So far I only have
> 6/16 and 10/17. I probably need at least 1/17.

Yeah, I am having troubles with linux-arm-kernel rejecting my mails
because of a suspicious header. I have no clue, what has changed lately
with my mails sent by git send-email to make them get stuck.

I didn't add all sub-arch maintainers to the whole set, that would
have been simply too many.

You need patches [1], [2], and 6 for imx which I will send a v2 in
a second. Ok for you to get them from lkml?

Sebastian

[1] https://lkml.org/lkml/2013/8/19/591
[2] https://lkml.org/lkml/2013/8/19/592

2013-08-20 09:23:48

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [RFC v2] ARM: imx: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Notes:
- Although mx5_clocks_common_init() is shared with non-DT, removing
of_clk_init(NULL) should be fine, as it only registers DT clk providers.
- For imx6q, printing of silicon revision has been moved from .init_time
to .init_machine hook.

Changelog:
v1->v2:
- added missing CLK_OF_DECLARE for imx51 and imx53 (Reported by Sascha Hauer)
mx53_clocks_init can be converted as it is used DT only, mx51_clocks_init
still is used by non-DT.

Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-imx/clk-imx51-imx53.c | 29 ++++++++++-------------------
arch/arm/mach-imx/common.h | 4 ----
arch/arm/mach-imx/imx51-dt.c | 6 ------
arch/arm/mach-imx/mach-imx53.c | 6 ------
arch/arm/mach-imx/mach-imx6q.c | 14 +++-----------
arch/arm/mach-imx/mach-imx6sl.c | 7 -------
arch/arm/mach-imx/mach-vf610.c | 9 ---------
7 files changed, 13 insertions(+), 62 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
index 1a56a33..1b796db 100644
--- a/arch/arm/mach-imx/clk-imx51-imx53.c
+++ b/arch/arm/mach-imx/clk-imx51-imx53.c
@@ -11,6 +11,7 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/clkdev.h>
+#include <linux/clk-provider.h>
#include <linux/of.h>
#include <linux/err.h>

@@ -131,8 +132,6 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
{
int i;

- of_clk_init(NULL);
-
clk[dummy] = imx_clk_fixed("dummy", 0);
clk[ckil] = imx_obtain_fixed_clock("ckil", rate_ckil);
clk[osc] = imx_obtain_fixed_clock("osc", rate_osc);
@@ -465,12 +464,16 @@ int __init mx51_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
return 0;
}

-int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
- unsigned long rate_ckih1, unsigned long rate_ckih2)
+static void __init mx51_clocks_init_dt(struct device_node *np)
+{
+ mx51_clocks_init(0, 0, 0, 0);
+}
+CLK_OF_DECLARE(imx51_ccm, "fsl,imx51-ccm", mx51_clocks_init_dt);
+
+static void __init mx53_clocks_init(struct device_node *np)
{
int i;
unsigned long r;
- struct device_node *np;

clk[pll1_sw] = imx_clk_pllv2("pll1_sw", "osc", MX53_DPLL1_BASE);
clk[pll2_sw] = imx_clk_pllv2("pll2_sw", "osc", MX53_DPLL2_BASE);
@@ -529,12 +532,11 @@ int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
pr_err("i.MX53 clk %d: register failed with %ld\n",
i, PTR_ERR(clk[i]));

- np = of_find_compatible_node(NULL, NULL, "fsl,imx53-ccm");
clk_data.clks = clk;
clk_data.clk_num = ARRAY_SIZE(clk);
of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);

- mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2);
+ mx5_clocks_common_init(0, 0, 0, 0);

clk_register_clkdev(clk[vpu_gate], NULL, "imx53-vpu.0");
clk_register_clkdev(clk[i2c3_gate], NULL, "imx21-i2c.2");
@@ -566,16 +568,5 @@ int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,

r = clk_round_rate(clk[usboh3_per_gate], 54000000);
clk_set_rate(clk[usboh3_per_gate], r);
-
- return 0;
-}
-
-int __init mx51_clocks_init_dt(void)
-{
- return mx51_clocks_init(0, 0, 0, 0);
-}
-
-int __init mx53_clocks_init_dt(void)
-{
- return mx53_clocks_init(0, 0, 0, 0);
}
+CLK_OF_DECLARE(imx53_ccm, "fsl,imx53-ccm", mx53_clocks_init);
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index 4517fd7..28e8ca0 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -63,13 +63,9 @@ extern int mx31_clocks_init(unsigned long fref);
extern int mx35_clocks_init(void);
extern int mx51_clocks_init(unsigned long ckil, unsigned long osc,
unsigned long ckih1, unsigned long ckih2);
-extern int mx53_clocks_init(unsigned long ckil, unsigned long osc,
- unsigned long ckih1, unsigned long ckih2);
extern int mx25_clocks_init_dt(void);
extern int mx27_clocks_init_dt(void);
extern int mx31_clocks_init_dt(void);
-extern int mx51_clocks_init_dt(void);
-extern int mx53_clocks_init_dt(void);
extern struct platform_device *mxc_register_gpio(char *name, int id,
resource_size_t iobase, resource_size_t iosize, int irq, int irq_high);
extern void mxc_set_cpu_type(unsigned int type);
diff --git a/arch/arm/mach-imx/imx51-dt.c b/arch/arm/mach-imx/imx51-dt.c
index 53e43e5..bece8a6 100644
--- a/arch/arm/mach-imx/imx51-dt.c
+++ b/arch/arm/mach-imx/imx51-dt.c
@@ -34,17 +34,11 @@ static const char *imx51_dt_board_compat[] __initdata = {
NULL
};

-static void __init imx51_timer_init(void)
-{
- mx51_clocks_init_dt();
-}
-
DT_MACHINE_START(IMX51_DT, "Freescale i.MX51 (Device Tree Support)")
.map_io = mx51_map_io,
.init_early = imx51_init_early,
.init_irq = mx51_init_irq,
.handle_irq = imx51_handle_irq,
- .init_time = imx51_timer_init,
.init_machine = imx51_dt_init,
.init_late = imx51_init_late,
.dt_compat = imx51_dt_board_compat,
diff --git a/arch/arm/mach-imx/mach-imx53.c b/arch/arm/mach-imx/mach-imx53.c
index 98c5894..c9c4d8d 100644
--- a/arch/arm/mach-imx/mach-imx53.c
+++ b/arch/arm/mach-imx/mach-imx53.c
@@ -36,17 +36,11 @@ static const char *imx53_dt_board_compat[] __initdata = {
NULL
};

-static void __init imx53_timer_init(void)
-{
- mx53_clocks_init_dt();
-}
-
DT_MACHINE_START(IMX53_DT, "Freescale i.MX53 (Device Tree Support)")
.map_io = mx53_map_io,
.init_early = imx53_init_early,
.init_irq = mx53_init_irq,
.handle_irq = imx53_handle_irq,
- .init_time = imx53_timer_init,
.init_machine = imx53_dt_init,
.init_late = imx53_init_late,
.dt_compat = imx53_dt_board_compat,
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index b605098..ad71738 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -11,9 +11,7 @@
*/

#include <linux/clk.h>
-#include <linux/clk-provider.h>
#include <linux/clkdev.h>
-#include <linux/clocksource.h>
#include <linux/cpu.h>
#include <linux/delay.h>
#include <linux/export.h>
@@ -192,6 +190,9 @@ static void __init imx6q_1588_init(void)

static void __init imx6q_init_machine(void)
{
+ imx_print_silicon_rev(cpu_is_imx6dl() ? "i.MX6DL" : "i.MX6Q",
+ imx6q_revision());
+
imx6q_enet_phy_init();

of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
@@ -289,14 +290,6 @@ static void __init imx6q_init_irq(void)
irqchip_init();
}

-static void __init imx6q_timer_init(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
- imx_print_silicon_rev(cpu_is_imx6dl() ? "i.MX6DL" : "i.MX6Q",
- imx6q_revision());
-}
-
static const char *imx6q_dt_compat[] __initdata = {
"fsl,imx6dl",
"fsl,imx6q",
@@ -307,7 +300,6 @@ DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad/DualLite (Device Tree)")
.smp = smp_ops(imx_smp_ops),
.map_io = imx6q_map_io,
.init_irq = imx6q_init_irq,
- .init_time = imx6q_timer_init,
.init_machine = imx6q_init_machine,
.init_late = imx6q_init_late,
.dt_compat = imx6q_dt_compat,
diff --git a/arch/arm/mach-imx/mach-imx6sl.c b/arch/arm/mach-imx/mach-imx6sl.c
index 0d75dc5..c70bd7c 100644
--- a/arch/arm/mach-imx/mach-imx6sl.c
+++ b/arch/arm/mach-imx/mach-imx6sl.c
@@ -7,7 +7,6 @@
*
*/

-#include <linux/clk-provider.h>
#include <linux/irqchip.h>
#include <linux/of.h>
#include <linux/of_platform.h>
@@ -31,11 +30,6 @@ static void __init imx6sl_init_irq(void)
irqchip_init();
}

-static void __init imx6sl_timer_init(void)
-{
- of_clk_init(NULL);
-}
-
static const char *imx6sl_dt_compat[] __initdata = {
"fsl,imx6sl",
NULL,
@@ -44,7 +38,6 @@ static const char *imx6sl_dt_compat[] __initdata = {
DT_MACHINE_START(IMX6SL, "Freescale i.MX6 SoloLite (Device Tree)")
.map_io = debug_ll_io_init,
.init_irq = imx6sl_init_irq,
- .init_time = imx6sl_timer_init,
.init_machine = imx6sl_init_machine,
.dt_compat = imx6sl_dt_compat,
.restart = mxc_restart,
diff --git a/arch/arm/mach-imx/mach-vf610.c b/arch/arm/mach-imx/mach-vf610.c
index 816991d..af0cb8a 100644
--- a/arch/arm/mach-imx/mach-vf610.c
+++ b/arch/arm/mach-imx/mach-vf610.c
@@ -8,9 +8,7 @@
*/

#include <linux/of_platform.h>
-#include <linux/clocksource.h>
#include <linux/irqchip.h>
-#include <linux/clk-provider.h>
#include <asm/mach/arch.h>
#include <asm/hardware/cache-l2x0.h>

@@ -28,12 +26,6 @@ static void __init vf610_init_irq(void)
irqchip_init();
}

-static void __init vf610_init_time(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static const char *vf610_dt_compat[] __initdata = {
"fsl,vf610",
NULL,
@@ -41,7 +33,6 @@ static const char *vf610_dt_compat[] __initdata = {

DT_MACHINE_START(VYBRID_VF610, "Freescale Vybrid VF610 (Device Tree)")
.init_irq = vf610_init_irq,
- .init_time = vf610_init_time,
.init_machine = vf610_init_machine,
.dt_compat = vf610_dt_compat,
.restart = mxc_restart,
--
1.7.10.4

2013-08-20 10:22:19

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [RFC 06/17] ARM: imx: remove custom .init_time hook

On Tue, Aug 20, 2013 at 11:20:06AM +0200, Sebastian Hesselbarth wrote:
> Yeah, I am having troubles with linux-arm-kernel rejecting my mails
> because of a suspicious header. I have no clue, what has changed lately
> with my mails sent by git send-email to make them get stuck.

I believe David feels the same way as I do wrt thread hijacking on
mailing lists. The problem is that it seems all too easy for people
to hit the reply button on some random message from the mailing list,
change the subject line, and then type an entirely new email into the
body not related to the message they hit "reply" on.

So, any message which doesn't look like it's a reply to the preceding
message gets held for moderation. However, git came along and broke
that - because every patch sent as a threaded reply to a cover email
is effectively a "hijack". Therefore, there's an exception to this -
if the subject line starts with "[PATCH" then it will be allowed through.

This means if you want to send a RFC, it must be "[PATCH RFC" not just
"[RFC", because "[RFC" isn't whitelisted. Maybe it should be, but that
is David's decision now.

2013-08-20 10:37:24

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 06/17] ARM: imx: remove custom .init_time hook

On 08/20/13 12:20, Russell King - ARM Linux wrote:
> On Tue, Aug 20, 2013 at 11:20:06AM +0200, Sebastian Hesselbarth wrote:
>> Yeah, I am having troubles with linux-arm-kernel rejecting my mails
>> because of a suspicious header. I have no clue, what has changed lately
>> with my mails sent by git send-email to make them get stuck.
>
> I believe David feels the same way as I do wrt thread hijacking on
> mailing lists. The problem is that it seems all too easy for people
> to hit the reply button on some random message from the mailing list,
> change the subject line, and then type an entirely new email into the
> body not related to the message they hit "reply" on.
>
> So, any message which doesn't look like it's a reply to the preceding
> message gets held for moderation. However, git came along and broke
> that - because every patch sent as a threaded reply to a cover email
> is effectively a "hijack". Therefore, there's an exception to this -
> if the subject line starts with "[PATCH" then it will be allowed through.
>
> This means if you want to send a RFC, it must be "[PATCH RFC" not just
> "[RFC", because "[RFC" isn't whitelisted. Maybe it should be, but that
> is David's decision now.

Russell,

I already guessed it has something to do with the In-reply-to line, as
only the patches but not the cover letter gets stuck. Thanks for
pointing me at the missing PATCH prefix and sorry for the noise on
the moderators screen.

For me it is fine not to expand the whitelist and after reading
SubmittingPatches again, it clearly says that RFC is just a tag to be
added after PATCH.

Sebastian

2013-08-20 10:46:55

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 06/17] ARM: imx: remove custom .init_time hook

On 08/20/13 12:42, Russell King - ARM Linux wrote:
> On Tue, Aug 20, 2013 at 12:37:18PM +0200, Sebastian Hesselbarth wrote:
>> I already guessed it has something to do with the In-reply-to line, as
>> only the patches but not the cover letter gets stuck. Thanks for
>> pointing me at the missing PATCH prefix and sorry for the noise on
>> the moderators screen.
>
> I just want to be clear about something there: I have nothing what so
> ever to do with the running of these lists anymore.
>
> While I may know some of the policies, that is as far as it goes; I
> don't have any access to the admin or moderation side of these lists.
>

Small typo, huge difference: It should have been "moderator's screen",
i.e. David's, of course.

Sebastian

2013-08-20 10:47:59

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [RFC 06/17] ARM: imx: remove custom .init_time hook

On Tue, Aug 20, 2013 at 12:37:18PM +0200, Sebastian Hesselbarth wrote:
> I already guessed it has something to do with the In-reply-to line, as
> only the patches but not the cover letter gets stuck. Thanks for
> pointing me at the missing PATCH prefix and sorry for the noise on
> the moderators screen.

I just want to be clear about something there: I have nothing what so
ever to do with the running of these lists anymore.

While I may know some of the policies, that is as far as it goes; I
don't have any access to the admin or moderation side of these lists.

2013-08-20 12:50:15

by Ezequiel Garcia

[permalink] [raw]
Subject: Re: [RFC 08/17] ARM: mvebu: remove custom .init_time hook

Hi Sebastian,

I've only received a few patches of this series. I *think*
using "RFC" alone is not correct in LAKML and for some reason
you're required to use RFC/PATCH.

Maybe that's why I'm getting only the patches where I'm Cced?

Could you please re-send this? The series looks promising and I'd like
to take a peep :-)

BTW, some of this (but not all) has already been posted [1, 2] and
is on its way to v3.12 through Daniel Lezcano.

(Maybe you already noticed, but just in case...)

[1] http://www.spinics.net/lists/arm-kernel/msg265509.html
[2] http://comments.gmane.org/gmane.linux.ports.arm.kernel/260179

Regards,
Ezequiel

On Tue, Aug 20, 2013 at 04:04:22AM +0200, Sebastian Hesselbarth wrote:
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove custom .init_time hooks.
>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>
> ---
> Notes:
> - coherency, mbus, and cache init are moved to .init_machine hook
> - time-armada-370-xp is converted to clocksource_of_init compatible init
>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Gregory Clement <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/arm/mach-mvebu/armada-370-xp.c | 11 +----------
> drivers/clocksource/time-armada-370-xp.c | 7 +++----
> include/linux/time-armada-370-xp.h | 16 ----------------
> 3 files changed, 4 insertions(+), 30 deletions(-)
> delete mode 100644 include/linux/time-armada-370-xp.h
>
> diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
> index 829b573..139f572 100644
> --- a/arch/arm/mach-mvebu/armada-370-xp.c
> +++ b/arch/arm/mach-mvebu/armada-370-xp.c
> @@ -14,11 +14,9 @@
>
> #include <linux/kernel.h>
> #include <linux/init.h>
> -#include <linux/clk-provider.h>
> #include <linux/of_address.h>
> #include <linux/of_platform.h>
> #include <linux/io.h>
> -#include <linux/time-armada-370-xp.h>
> #include <linux/dma-mapping.h>
> #include <linux/mbus.h>
> #include <asm/hardware/cache-l2x0.h>
> @@ -34,19 +32,13 @@ static void __init armada_370_xp_map_io(void)
> debug_ll_io_init();
> }
>
> -static void __init armada_370_xp_timer_and_clk_init(void)
> +static void __init armada_370_xp_dt_init(void)
> {
> - of_clk_init(NULL);
> - armada_370_xp_timer_init();
> coherency_init();
> BUG_ON(mvebu_mbus_dt_init());
> #ifdef CONFIG_CACHE_L2X0
> l2x0_of_init(0, ~0UL);
> #endif
> -}
> -
> -static void __init armada_370_xp_dt_init(void)
> -{
> of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> }
>
> @@ -59,7 +51,6 @@ DT_MACHINE_START(ARMADA_XP_DT, "Marvell Armada 370/XP (Device Tree)")
> .smp = smp_ops(armada_xp_smp_ops),
> .init_machine = armada_370_xp_dt_init,
> .map_io = armada_370_xp_map_io,
> - .init_time = armada_370_xp_timer_and_clk_init,
> .restart = mvebu_restart,
> .dt_compat = armada_370_xp_dt_compat,
> MACHINE_END
> diff --git a/drivers/clocksource/time-armada-370-xp.c b/drivers/clocksource/time-armada-370-xp.c
> index 847cab6..67904cf 100644
> --- a/drivers/clocksource/time-armada-370-xp.c
> +++ b/drivers/clocksource/time-armada-370-xp.c
> @@ -30,7 +30,6 @@
> #include <linux/module.h>
> #include <linux/sched_clock.h>
> #include <linux/percpu.h>
> -#include <linux/time-armada-370-xp.h>
>
> /*
> * Timer block registers.
> @@ -217,13 +216,11 @@ static struct notifier_block armada_370_xp_timer_cpu_nb = {
> .notifier_call = armada_370_xp_timer_cpu_notify,
> };
>
> -void __init armada_370_xp_timer_init(void)
> +void __init armada_370_xp_timer_init(struct device_node *np)
> {
> u32 u;
> - struct device_node *np;
> int res;
>
> - np = of_find_compatible_node(NULL, NULL, "marvell,armada-370-xp-timer");
> timer_base = of_iomap(np, 0);
> WARN_ON(!timer_base);
> local_base = of_iomap(np, 1);
> @@ -293,3 +290,5 @@ void __init armada_370_xp_timer_init(void)
> if (!res)
> armada_370_xp_timer_setup(this_cpu_ptr(armada_370_xp_evt));
> }
> +CLOCKSOURCE_OF_DECLARE(armada_370_xp_timer, "marvell,armada-370-xp-timer",
> + armada_370_xp_timer_init);
> diff --git a/include/linux/time-armada-370-xp.h b/include/linux/time-armada-370-xp.h
> deleted file mode 100644
> index 6fb0856..0000000
> --- a/include/linux/time-armada-370-xp.h
> +++ /dev/null
> @@ -1,16 +0,0 @@
> -/*
> - * Marvell Armada 370/XP SoC timer handling.
> - *
> - * Copyright (C) 2012 Marvell
> - *
> - * Lior Amsalem <[email protected]>
> - * Gregory CLEMENT <[email protected]>
> - * Thomas Petazzoni <[email protected]>
> - *
> - */
> -#ifndef __TIME_ARMADA_370_XPPRCMU_H
> -#define __TIME_ARMADA_370_XPPRCMU_H
> -
> -void armada_370_xp_timer_init(void);
> -
> -#endif
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

--
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

2013-08-20 13:12:18

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 08/17] ARM: mvebu: remove custom .init_time hook

On 08/20/13 14:50, Ezequiel Garcia wrote:
> I've only received a few patches of this series. I *think*
> using "RFC" alone is not correct in LAKML and for some reason
> you're required to use RFC/PATCH.

Ezequiel,

we already sorted out, why they got stuck on LAKML. It is because
of the missing PATCH prefix, I'll add that in future postings for sure.

But the patches should have been managed to get through to LKML.

> Maybe that's why I'm getting only the patches where I'm Cced?

I try to keep Cc list as short as possible, so I only put Gregory as the
maintainer of mach-mvebu on Cc.

> Could you please re-send this? The series looks promising and I'd like
> to take a peep :-)

No, I am not going to resend v1 but only updates. For a single mach
you need patches [1], [2], and the one supposed for your mach.

> BTW, some of this (but not all) has already been posted [1, 2] and
> is on its way to v3.12 through Daniel Lezcano.
>
> (Maybe you already noticed, but just in case...)
>
> [1] http://www.spinics.net/lists/arm-kernel/msg265509.html
> [2] http://comments.gmane.org/gmane.linux.ports.arm.kernel/260179

I expect machs to move until all of it has been Ack'ed, so I
based in on most recent tag of linux-next yesterday.

Sebastian

[1] https://lkml.org/lkml/2013/8/19/591
[2] https://lkml.org/lkml/2013/8/19/592

2013-08-20 14:01:08

by Ezequiel Garcia

[permalink] [raw]
Subject: Re: [RFC 08/17] ARM: mvebu: remove custom .init_time hook

On Tue, Aug 20, 2013 at 03:12:12PM +0200, Sebastian Hesselbarth wrote:
> > Maybe that's why I'm getting only the patches where I'm Cced?
>
> I try to keep Cc list as short as possible, so I only put Gregory as the
> maintainer of mach-mvebu on Cc.
>

Pff... you're right, I got this because my mvebu-filters caught it from
lkml! I'm seeing now the complete patchset in lkml, it looks good!

>
> I expect machs to move until all of it has been Ack'ed, so I
> based in on most recent tag of linux-next yesterday.
>

No problem, just wanted to let you know about that.
Feel free to update the remaining bits once Daniel's lands
in linux-next.

Thanks,
--
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

2013-08-20 15:46:35

by Stephen Warren

[permalink] [raw]
Subject: Re: [RFC 02/17] ARM: call clk_of_init from time_init

On 08/19/2013 08:04 PM, Sebastian Hesselbarth wrote:
> Most DT ARM machs require common clock providers initialized before timers.
> Currently, arch/arm machs use .init_time to call clk_of_init right before
> clocksource_of_init. This prevents to remove that hook and use the default
> hook instead. clk_of_init now checks for multiple calls to it, so add
> the call to ARM arch time_init by default.

Some SoCs call this function in .init_irq() rather than .init_time().
Perhaps we adjust this patch to do that instead. That way, we can
presumably get rid of patch 1/17 since we can eliminate any duplicate
calls, and adjust patch 14/17 (Tegra board file) to remove its custom
call to of_clock_init(NULL)?

2013-08-20 19:21:44

by Rob Herring

[permalink] [raw]
Subject: Re: [RFC 05/17] ARM: highbank: remove custom .init_time hook

On 08/19/2013 09:04 PM, Sebastian Hesselbarth wrote:
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove custom .init_time hooks. Highbank clock provider need a reference
> to system registers, as a workaround current clk driver maps those
> independent of arch code now.
>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>
> ---
> Notes:
> - I suggest to consolidate the four single clock providers into a single
> provider with one node if possible.

And how do you suggest doing that while maintaining the DT ABI?

>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Rob Herring <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/arm/mach-highbank/highbank.c | 23 +++++++----------------
> drivers/clk/clk-highbank.c | 10 +++++++---
> 2 files changed, 14 insertions(+), 19 deletions(-)

Acked-by: Rob Herring <[email protected]>

2013-08-20 19:47:43

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 02/17] ARM: call clk_of_init from time_init

On 08/20/2013 05:46 PM, Stephen Warren wrote:
> On 08/19/2013 08:04 PM, Sebastian Hesselbarth wrote:
>> Most DT ARM machs require common clock providers initialized before timers.
>> Currently, arch/arm machs use .init_time to call clk_of_init right before
>> clocksource_of_init. This prevents to remove that hook and use the default
>> hook instead. clk_of_init now checks for multiple calls to it, so add
>> the call to ARM arch time_init by default.
>
> Some SoCs call this function in .init_irq() rather than .init_time().
> Perhaps we adjust this patch to do that instead. That way, we can
> presumably get rid of patch 1/17 since we can eliminate any duplicate
> calls, and adjust patch 14/17 (Tegra board file) to remove its custom
> call to of_clock_init(NULL)?

Currently as of -next from yesterday, only tegra is requiring clocks
that early, while others are fine with them close to timers. I really
have no strong opinion on that. That decision should rather be made
by those with a far more complete insight of the consequences than I
have.

Sebastian

2013-08-20 19:52:53

by Stephen Warren

[permalink] [raw]
Subject: Re: [RFC 02/17] ARM: call clk_of_init from time_init

On 08/20/2013 01:47 PM, Sebastian Hesselbarth wrote:
> On 08/20/2013 05:46 PM, Stephen Warren wrote:
>> On 08/19/2013 08:04 PM, Sebastian Hesselbarth wrote:
>>> Most DT ARM machs require common clock providers initialized before
>>> timers.
>>> Currently, arch/arm machs use .init_time to call clk_of_init right
>>> before
>>> clocksource_of_init. This prevents to remove that hook and use the
>>> default
>>> hook instead. clk_of_init now checks for multiple calls to it, so add
>>> the call to ARM arch time_init by default.
>>
>> Some SoCs call this function in .init_irq() rather than .init_time().
>> Perhaps we adjust this patch to do that instead. That way, we can
>> presumably get rid of patch 1/17 since we can eliminate any duplicate
>> calls, and adjust patch 14/17 (Tegra board file) to remove its custom
>> call to of_clock_init(NULL)?
>
> Currently as of -next from yesterday, only tegra is requiring clocks
> that early, while others are fine with them close to timers. I really
> have no strong opinion on that. That decision should rather be made
> by those with a far more complete insight of the consequences than I
> have.

Perhaps if Tegra is a special-case, it shouldn't rely on the generic
init_time() callback, and hence you could still eliminate patch 1/17?

2013-08-20 20:01:26

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 05/17] ARM: highbank: remove custom .init_time hook

On 08/20/2013 09:12 PM, Rob Herring wrote:
> On 08/19/2013 09:04 PM, Sebastian Hesselbarth wrote:
>> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
>> remove custom .init_time hooks. Highbank clock provider need a reference
>> to system registers, as a workaround current clk driver maps those
>> independent of arch code now.
>>
>> Signed-off-by: Sebastian Hesselbarth <[email protected]>
>> ---
>> Notes:
>> - I suggest to consolidate the four single clock providers into a single
>> provider with one node if possible.
>
> And how do you suggest doing that while maintaining the DT ABI?

Rob,

I am aware of ABI status of the DT bindings and the discussion about
deprecating/cleanup of what went in in the past. Maybe "suggest" is a
little bit too strong and should have been "would be nice to have".

But looking at clk-highbank, all providers depend on the same register.
If you'd introduce e.g. a new "calxeda,core-clocks" that sets up the
four providers and also CLK_OF_DECLARE the same init with one out of
the four existing compatibles shouldn't that maintain backwards
compatibility?

Anyway, I was just puting the note above to raise some comment on it.
You actually gave a good one to leave it as is.

>> ---
>> arch/arm/mach-highbank/highbank.c | 23 +++++++----------------
>> drivers/clk/clk-highbank.c | 10 +++++++---
>> 2 files changed, 14 insertions(+), 19 deletions(-)
>
> Acked-by: Rob Herring <[email protected]>

Ok, I keep that in mind until all other issues are resolved.

Thanks,
Sebastian

2013-08-20 20:19:33

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 02/17] ARM: call clk_of_init from time_init

On 08/20/2013 09:52 PM, Stephen Warren wrote:
> On 08/20/2013 01:47 PM, Sebastian Hesselbarth wrote:
>> On 08/20/2013 05:46 PM, Stephen Warren wrote:
>>> Some SoCs call this function in .init_irq() rather than .init_time().
>>> Perhaps we adjust this patch to do that instead. That way, we can
>>> presumably get rid of patch 1/17 since we can eliminate any duplicate
>>> calls, and adjust patch 14/17 (Tegra board file) to remove its custom
>>> call to of_clock_init(NULL)?
>>
>> Currently as of -next from yesterday, only tegra is requiring clocks
>> that early, while others are fine with them close to timers. I really
>> have no strong opinion on that. That decision should rather be made
>> by those with a far more complete insight of the consequences than I
>> have.
>
> Perhaps if Tegra is a special-case, it shouldn't rely on the generic
> init_time() callback, and hence you could still eliminate patch 1/17?
>

Perhaps Tegra is the common case but other SoC haven't dug deep enough?
IMHO from a HW point-of-view clocks are really among the essential
things that need to be running before you can do anything useful.

Just consider boot loaders that run fine without irqs but don't without
clocks (even if just represented by API). Maybe you are right, and we
should call of_clk_init(NULL) as early as possible. That would also
eliminate patch 1/17 as you suggest.

Sebastian

2013-08-20 20:45:36

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [RFC 02/17] ARM: call clk_of_init from time_init

On Tuesday 20 August 2013, Stephen Warren wrote:
> On 08/19/2013 08:04 PM, Sebastian Hesselbarth wrote:
> > Most DT ARM machs require common clock providers initialized before timers.
> > Currently, arch/arm machs use .init_time to call clk_of_init right before
> > clocksource_of_init. This prevents to remove that hook and use the default
> > hook instead. clk_of_init now checks for multiple calls to it, so add
> > the call to ARM arch time_init by default.
>
> Some SoCs call this function in .init_irq() rather than .init_time().
> Perhaps we adjust this patch to do that instead. That way, we can
> presumably get rid of patch 1/17 since we can eliminate any duplicate
> calls, and adjust patch 14/17 (Tegra board file) to remove its custom
> call to of_clock_init(NULL)?

I think we should do thinks as late as possible in general. We probably
need clocks running on most platforms before we can set up timers, so
it makes sense to do the clocks first, but very few platforms require
clocks to be running before the interrupt controller is set up.

A nicer solution would be to change the tegra code to not require this
to be called this early, if at all possible.

Arnd

2013-08-20 20:58:00

by Stephen Warren

[permalink] [raw]
Subject: Re: [RFC 02/17] ARM: call clk_of_init from time_init

On 08/20/2013 02:44 PM, Arnd Bergmann wrote:
> On Tuesday 20 August 2013, Stephen Warren wrote:
>> On 08/19/2013 08:04 PM, Sebastian Hesselbarth wrote:
>>> Most DT ARM machs require common clock providers initialized before timers.
>>> Currently, arch/arm machs use .init_time to call clk_of_init right before
>>> clocksource_of_init. This prevents to remove that hook and use the default
>>> hook instead. clk_of_init now checks for multiple calls to it, so add
>>> the call to ARM arch time_init by default.
>>
>> Some SoCs call this function in .init_irq() rather than .init_time().
>> Perhaps we adjust this patch to do that instead. That way, we can
>> presumably get rid of patch 1/17 since we can eliminate any duplicate
>> calls, and adjust patch 14/17 (Tegra board file) to remove its custom
>> call to of_clock_init(NULL)?
>
> I think we should do thinks as late as possible in general. We probably
> need clocks running on most platforms before we can set up timers, so
> it makes sense to do the clocks first, but very few platforms require
> clocks to be running before the interrupt controller is set up.
>
> A nicer solution would be to change the tegra code to not require this
> to be called this early, if at all possible.

Hmm. This probably isn't too hard. I /think/ the only reason the clocks
are initialized early is:

* The PMC HW block is involved in the path of some interrupts (i.e. it
inverts, or not, the IRQ input pin dedicated to the PMIC).

* So, that part of the PMC must be initialized early so that the IRQ
polarity is correct.

* The PMC initialization is currently monolithic, and the PMC has some
clock inputs, so the init routine ends up calling of_clk_get_by_name(),
and hence clocks must be set up early too.

Perhaps if we just separate tegra_pmc_init() into two functions which
initialize different parts of the PMC, we can get rid of the
tegra_dt_init_irq() -> tegra_pmc_init() -> of_clk_get_by_name() call
path, and hence move Tegra's call to of_clk_init() to the typical place.

I'll try it.

2013-08-21 18:52:39

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [RFC 02/17] ARM: call clk_of_init from time_init

On Tuesday 20 August 2013, Stephen Warren wrote:
> On 08/20/2013 02:44 PM, Arnd Bergmann wrote:
> > On Tuesday 20 August 2013, Stephen Warren wrote:

> Hmm. This probably isn't too hard. I /think/ the only reason the clocks
> are initialized early is:
>
> * The PMC HW block is involved in the path of some interrupts (i.e. it
> inverts, or not, the IRQ input pin dedicated to the PMIC).
>
> * So, that part of the PMC must be initialized early so that the IRQ
> polarity is correct.
>
> * The PMC initialization is currently monolithic, and the PMC has some
> clock inputs, so the init routine ends up calling of_clk_get_by_name(),
> and hence clocks must be set up early too.
>
> Perhaps if we just separate tegra_pmc_init() into two functions which
> initialize different parts of the PMC, we can get rid of the
> tegra_dt_init_irq() -> tegra_pmc_init() -> of_clk_get_by_name() call
> path, and hence move Tegra's call to of_clk_init() to the typical place.

That sounds good to me, thanks for looking into it.

Arnd

2013-08-21 18:54:21

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [RFC 02/17] ARM: call clk_of_init from time_init

On Tuesday 20 August 2013, Sebastian Hesselbarth wrote:
> Perhaps Tegra is the common case but other SoC haven't dug deep enough?
> IMHO from a HW point-of-view clocks are really among the essential
> things that need to be running before you can do anything useful.
>
> Just consider boot loaders that run fine without irqs but don't without
> clocks (even if just represented by API). Maybe you are right, and we
> should call of_clk_init(NULL) as early as possible. That would also
> eliminate patch 1/17 as you suggest.

Timers and interrupts are also things that are required really early,
and from my experience they tend to be needed earlier than clock
management. Obviously you need some clocks to be enabled in order
to do anything (including interrupt handling), but those clocks tend
to be enabled in the boot loader, so we don't have to worry about
reprogramming them this early.

Arnd

2013-08-22 07:25:29

by Mike Turquette

[permalink] [raw]
Subject: Re: [RFC 02/17] ARM: call clk_of_init from time_init

Quoting Arnd Bergmann (2013-08-21 11:54:10)
> On Tuesday 20 August 2013, Sebastian Hesselbarth wrote:
> > Perhaps Tegra is the common case but other SoC haven't dug deep enough?
> > IMHO from a HW point-of-view clocks are really among the essential
> > things that need to be running before you can do anything useful.
> >
> > Just consider boot loaders that run fine without irqs but don't without
> > clocks (even if just represented by API). Maybe you are right, and we
> > should call of_clk_init(NULL) as early as possible. That would also
> > eliminate patch 1/17 as you suggest.
>
> Timers and interrupts are also things that are required really early,
> and from my experience they tend to be needed earlier than clock
> management. Obviously you need some clocks to be enabled in order
> to do anything (including interrupt handling), but those clocks tend
> to be enabled in the boot loader, so we don't have to worry about
> reprogramming them this early.

Some timers need to know their clock rate for the timer setup. This
could be hard-coded (e.g. for some timer driven from a fixed 32Khz
source) but it could also be from a clock capable of different rates
that needs to be calculated.

I remember discussing the early clock init stuff for OMAP and there was
an idea to not rely on the clock framework for timer init and just do
some raw reads and compute the clock rate that way. Using the framework
would be better of course.

Regards,
Mike

>
> Arnd
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

2013-08-22 17:28:47

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [RFC 02/17] ARM: call clk_of_init from time_init

On Thursday 22 August 2013, Mike Turquette wrote:
> Some timers need to know their clock rate for the timer setup. This
> could be hard-coded (e.g. for some timer driven from a fixed 32Khz
> source) but it could also be from a clock capable of different rates
> that needs to be calculated.
>
> I remember discussing the early clock init stuff for OMAP and there was
> an idea to not rely on the clock framework for timer init and just do
> some raw reads and compute the clock rate that way. Using the framework
> would be better of course.
>

Just to be clear: I think we should initialize all clocks before timers,
just not any earlier like Tegra does.

Arnd

2013-08-23 00:26:56

by Soren Brinkmann

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

Hi Sebastian,

On Tue, Aug 20, 2013 at 04:04:31AM +0200, Sebastian Hesselbarth wrote:
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove it from corresponding drivers/clk code.

I think that would break Zynq.
If I see this correctly you call of_clk_init() from common code,
_before_ the SOC specific time init function is called.
The problem is, that we have code setting up a global pointer which is
required by zynq_clk_setup() which is triggered when of_clk_init() is
called.

Let me try to illustrate the current call graph:

time_init()
zynq_timer_init() // this machines init_time()
zynq_slcr_init() // setup System Level Control Registers including a global pointer
zynq_clock_init()
of_clk_init()
zynq_clk_setup() // requires pointer setup in zynq_slcr_init()
...

IIUC, your series would change this to:
time_init()
of_clk_init()
zynq_clk_setup() // SLCR pointer is not setup/NULL
...
zynq_timer_init()
zynq_slcr_init() // now the pointer becomes valid

Sören

2013-08-23 00:59:48

by Soren Brinkmann

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

On Thu, Aug 22, 2013 at 05:26:47PM -0700, Sören Brinkmann wrote:
> Hi Sebastian,
>
> On Tue, Aug 20, 2013 at 04:04:31AM +0200, Sebastian Hesselbarth wrote:
> > With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> > remove it from corresponding drivers/clk code.
>
> I think that would break Zynq.
> If I see this correctly you call of_clk_init() from common code,
> _before_ the SOC specific time init function is called.
> The problem is, that we have code setting up a global pointer which is
> required by zynq_clk_setup() which is triggered when of_clk_init() is
> called.
>
> Let me try to illustrate the current call graph:
>
> time_init()
> zynq_timer_init() // this machines init_time()
> zynq_slcr_init() // setup System Level Control Registers including a global pointer
> zynq_clock_init()
> of_clk_init()
> zynq_clk_setup() // requires pointer setup in zynq_slcr_init()
> ...
>
> IIUC, your series would change this to:
> time_init()
> of_clk_init()
> zynq_clk_setup() // SLCR pointer is not setup/NULL
> ...
> zynq_timer_init()
> zynq_slcr_init() // now the pointer becomes valid

I guess we could move zynq_slcr_init() into init_irq(). I'll give that a
shot tomorrow.

Sören

2013-08-23 07:33:00

by Steffen Trumtrar

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

Hi!

On Thu, Aug 22, 2013 at 05:59:36PM -0700, S?ren Brinkmann wrote:
> On Thu, Aug 22, 2013 at 05:26:47PM -0700, S?ren Brinkmann wrote:
> > Hi Sebastian,
> >
> > On Tue, Aug 20, 2013 at 04:04:31AM +0200, Sebastian Hesselbarth wrote:
> > > With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> > > remove it from corresponding drivers/clk code.
> >
> > I think that would break Zynq.
> > If I see this correctly you call of_clk_init() from common code,
> > _before_ the SOC specific time init function is called.
> > The problem is, that we have code setting up a global pointer which is
> > required by zynq_clk_setup() which is triggered when of_clk_init() is
> > called.
> >
> > Let me try to illustrate the current call graph:
> >
> > time_init()
> > zynq_timer_init() // this machines init_time()
> > zynq_slcr_init() // setup System Level Control Registers including a global pointer
> > zynq_clock_init()
> > of_clk_init()
> > zynq_clk_setup() // requires pointer setup in zynq_slcr_init()
> > ...
> >
> > IIUC, your series would change this to:
> > time_init()
> > of_clk_init()
> > zynq_clk_setup() // SLCR pointer is not setup/NULL
> > ...
> > zynq_timer_init()
> > zynq_slcr_init() // now the pointer becomes valid
>
> I guess we could move zynq_slcr_init() into init_irq(). I'll give that a
> shot tomorrow.
>

I propose getting rid of the whole global pointer and let the clkc map the
address itself instead.

Then there is no need to shuffle stuff around in the initcalls.
I have some WIP patches (not rebased on next and not even tested with it,
but with v3.11-rc4)

The dtsi would be something like:

control-register@f8000000 {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0xf8000000 0x1000>;
ranges;

slcr: slcr@f8000000 {
compatible = "xlnx,zynq-slcr", "syscon";
reg = <0xf8000000 0x10>;
};

clkc: clkc@f8000100 {
#clock-cells = <1>;
compatible = "xlnx,ps7-clkc";
reg = <0xf8000100 0x100>;
ps-clk-frequency = <33333333>;
xlnx,slcr = <&slcr>;
clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x",
"cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x",
"dci", "lqspi", "smc", "pcap", "gem0", "gem1",
"fclk0", "fclk1", "fclk2", "fclk3", "can0", "can1",
"sdio0", "sdio1", "uart0", "uart1", "spi0", "spi1",
"dma", "usb0_aper", "usb1_aper", "gem0_aper",
"gem1_aper", "sdio0_aper", "sdio1_aper",
"spi0_aper", "spi1_aper", "can0_aper", "can1_aper",
"i2c0_aper", "i2c1_aper", "uart0_aper", "uart1_aper",
"gpio_aper", "lqspi_aper", "smc_aper", "swdt",
"dbg_trc", "dbg_apb";
};

mio: pinmux@f8000700 {
compatible = "xlnx,ps7-pinctrl";
reg = <0xf8000700 0x110>;
xlnx,slcr = <&slcr>;
};
};

With the phandle to the slcr node it should also be possible to handle locking,
unlocking, but I haven't tried that yet.
Also, as you can see, I would add "syscon" to the slcr. Than it can get an early
init call to unlock the register space. And be later added as as syscon driver
so you can work with regmap etc. and work dynamically with the slcr after boot
(pinmuxing + dt overlays etc). I have tested the early-init-and-later-syscon-registering-stuff
and it works. With the time_init changes, the early_init might have to be earlier
though, but only when the slcr is locked.

The clkc driver than has

np = of_find_compatible_node(NULL, NULL, "xlnx,ps7-clkc");
if (!np) {
pr_err("%s: no ps7-clkc node found\n", __func__);
BUG();
}

zynq_slcr_base_priv = of_iomap(np, 0);
if (!zynq_slcr_base_priv) {
pr_err("%s: Unable to map I/O memory\n", np->name);
of_node_put(np);
BUG();
return;
}

in the setup function. So, it is independent from any prior setup of the slcr.
This just leaves the locking. Which might me able to be handled with the phandle.

But I have to finish that first. So, if reording the entries is working as a
hotfix, go ahead I guess.


Regards,
Steffen

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

2013-08-23 09:30:28

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

On 08/23/13 02:59, Sören Brinkmann wrote:
> On Thu, Aug 22, 2013 at 05:26:47PM -0700, Sören Brinkmann wrote:
>> On Tue, Aug 20, 2013 at 04:04:31AM +0200, Sebastian Hesselbarth wrote:
>>> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
>>> remove it from corresponding drivers/clk code.
>>
>> I think that would break Zynq.
>> If I see this correctly you call of_clk_init() from common code,
>> _before_ the SOC specific time init function is called.
>> The problem is, that we have code setting up a global pointer which is
>> required by zynq_clk_setup() which is triggered when of_clk_init() is
>> called.
>>
>> Let me try to illustrate the current call graph:
>>
>> time_init()
>> zynq_timer_init() // this machines init_time()
>> zynq_slcr_init() // setup System Level Control Registers including a global pointer
>> zynq_clock_init()
>> of_clk_init()
>> zynq_clk_setup() // requires pointer setup in zynq_slcr_init()
>> ...
>>
>> IIUC, your series would change this to:
>> time_init()
>> of_clk_init()
>> zynq_clk_setup() // SLCR pointer is not setup/NULL
>> ...
>> zynq_timer_init()
>> zynq_slcr_init() // now the pointer becomes valid
>
> I guess we could move zynq_slcr_init() into init_irq(). I'll give that a
> shot tomorrow.

Sören,

thanks for looking into this. I also had a look at the files in
question. Based on Steffen's proposal, I prepared a diff that should do
the trick. It moves zynq_slcr_init() to early_init, instead of reusing
another hook that has magic cow powers (it calls irqchip_init that zynq
also wants sooner or later).

Also, it removes zynq_clock_init() and let zynq_clk_setup() map the
register itself by finding the node and use of_iomap(). I realized that
clock registers are quite separated within slcr, so you can consider
to have your own node for the clk-provider. As Steffen is proposing
this but mentioned incompatible DT changes, I chose that intermediate
step above.

It would be great, if you test the diff and prepare a patch out of
it, that I pick-up in the patch set. That way, we also have your
Signed-off on it.

Sebastian



Attachments:
arm-of_clk_init-zynq-proposal.diff (3.04 kB)

2013-08-23 10:06:04

by Gregory CLEMENT

[permalink] [raw]
Subject: Re: [RFC 08/17] ARM: mvebu: remove custom .init_time hook

Hi Sebastian,

On 20/08/2013 04:04, Sebastian Hesselbarth wrote:
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove custom .init_time hooks.
>

As a feared it won't work on Armada XP. You moved coherency_init(), and
l2x0_of_init() in the init_machine hook. However init_machine is an
arch_initcall, and as all the initcall it is called at the end of the
do_basic_setup() which is called after smp_prepare_cpus(). The issue is
that smp_prepare_cpus need coherency (and I think L2 cache) already enable.

Regards,

> Signed-off-by: Sebastian Hesselbarth <[email protected]>
> ---
> Notes:
> - coherency, mbus, and cache init are moved to .init_machine hook
> - time-armada-370-xp is converted to clocksource_of_init compatible init
>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Gregory Clement <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/arm/mach-mvebu/armada-370-xp.c | 11 +----------
> drivers/clocksource/time-armada-370-xp.c | 7 +++----
> include/linux/time-armada-370-xp.h | 16 ----------------
> 3 files changed, 4 insertions(+), 30 deletions(-)
> delete mode 100644 include/linux/time-armada-370-xp.h
>
> diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
> index 829b573..139f572 100644
> --- a/arch/arm/mach-mvebu/armada-370-xp.c
> +++ b/arch/arm/mach-mvebu/armada-370-xp.c
> @@ -14,11 +14,9 @@
>
> #include <linux/kernel.h>
> #include <linux/init.h>
> -#include <linux/clk-provider.h>
> #include <linux/of_address.h>
> #include <linux/of_platform.h>
> #include <linux/io.h>
> -#include <linux/time-armada-370-xp.h>
> #include <linux/dma-mapping.h>
> #include <linux/mbus.h>
> #include <asm/hardware/cache-l2x0.h>
> @@ -34,19 +32,13 @@ static void __init armada_370_xp_map_io(void)
> debug_ll_io_init();
> }
>
> -static void __init armada_370_xp_timer_and_clk_init(void)
> +static void __init armada_370_xp_dt_init(void)
> {
> - of_clk_init(NULL);
> - armada_370_xp_timer_init();
> coherency_init();
> BUG_ON(mvebu_mbus_dt_init());
> #ifdef CONFIG_CACHE_L2X0
> l2x0_of_init(0, ~0UL);
> #endif
> -}
> -
> -static void __init armada_370_xp_dt_init(void)
> -{
> of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> }
>
> @@ -59,7 +51,6 @@ DT_MACHINE_START(ARMADA_XP_DT, "Marvell Armada 370/XP (Device Tree)")
> .smp = smp_ops(armada_xp_smp_ops),
> .init_machine = armada_370_xp_dt_init,
> .map_io = armada_370_xp_map_io,
> - .init_time = armada_370_xp_timer_and_clk_init,
> .restart = mvebu_restart,
> .dt_compat = armada_370_xp_dt_compat,
> MACHINE_END
> diff --git a/drivers/clocksource/time-armada-370-xp.c b/drivers/clocksource/time-armada-370-xp.c
> index 847cab6..67904cf 100644
> --- a/drivers/clocksource/time-armada-370-xp.c
> +++ b/drivers/clocksource/time-armada-370-xp.c
> @@ -30,7 +30,6 @@
> #include <linux/module.h>
> #include <linux/sched_clock.h>
> #include <linux/percpu.h>
> -#include <linux/time-armada-370-xp.h>
>
> /*
> * Timer block registers.
> @@ -217,13 +216,11 @@ static struct notifier_block armada_370_xp_timer_cpu_nb = {
> .notifier_call = armada_370_xp_timer_cpu_notify,
> };
>
> -void __init armada_370_xp_timer_init(void)
> +void __init armada_370_xp_timer_init(struct device_node *np)
> {
> u32 u;
> - struct device_node *np;
> int res;
>
> - np = of_find_compatible_node(NULL, NULL, "marvell,armada-370-xp-timer");
> timer_base = of_iomap(np, 0);
> WARN_ON(!timer_base);
> local_base = of_iomap(np, 1);
> @@ -293,3 +290,5 @@ void __init armada_370_xp_timer_init(void)
> if (!res)
> armada_370_xp_timer_setup(this_cpu_ptr(armada_370_xp_evt));
> }
> +CLOCKSOURCE_OF_DECLARE(armada_370_xp_timer, "marvell,armada-370-xp-timer",
> + armada_370_xp_timer_init);
> diff --git a/include/linux/time-armada-370-xp.h b/include/linux/time-armada-370-xp.h
> deleted file mode 100644
> index 6fb0856..0000000
> --- a/include/linux/time-armada-370-xp.h
> +++ /dev/null
> @@ -1,16 +0,0 @@
> -/*
> - * Marvell Armada 370/XP SoC timer handling.
> - *
> - * Copyright (C) 2012 Marvell
> - *
> - * Lior Amsalem <[email protected]>
> - * Gregory CLEMENT <[email protected]>
> - * Thomas Petazzoni <[email protected]>
> - *
> - */
> -#ifndef __TIME_ARMADA_370_XPPRCMU_H
> -#define __TIME_ARMADA_370_XPPRCMU_H
> -
> -void armada_370_xp_timer_init(void);
> -
> -#endif
>


--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

2013-08-23 10:32:37

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 08/17] ARM: mvebu: remove custom .init_time hook

On 08/23/13 12:06, Gregory CLEMENT wrote:
> On 20/08/2013 04:04, Sebastian Hesselbarth wrote:
>> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
>> remove custom .init_time hooks.
>
> As a feared it won't work on Armada XP. You moved coherency_init(), and
> l2x0_of_init() in the init_machine hook. However init_machine is an
> arch_initcall, and as all the initcall it is called at the end of the
> do_basic_setup() which is called after smp_prepare_cpus(). The issue is
> that smp_prepare_cpus need coherency (and I think L2 cache) already enable.

Ok, I see. I remember mvebu smp relies on mbus mappings also? Can you
try below as replacement for the mach-mvebu/armada-370-xp.c changes?

It will move coherency_init(), l2x0_of_init(), and mvebu_mbus_dt_init()
to .init_early hook.

Sebastian


Attachments:
arm-of_clk_init-mvebu-proposal.diff (1.26 kB)

2013-08-23 11:39:40

by Gregory CLEMENT

[permalink] [raw]
Subject: Re: [RFC 08/17] ARM: mvebu: remove custom .init_time hook

On 23/08/2013 12:32, Sebastian Hesselbarth wrote:
> On 08/23/13 12:06, Gregory CLEMENT wrote:
>> On 20/08/2013 04:04, Sebastian Hesselbarth wrote:
>>> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
>>> remove custom .init_time hooks.
>>
>> As a feared it won't work on Armada XP. You moved coherency_init(), and
>> l2x0_of_init() in the init_machine hook. However init_machine is an
>> arch_initcall, and as all the initcall it is called at the end of the
>> do_basic_setup() which is called after smp_prepare_cpus(). The issue is
>> that smp_prepare_cpus need coherency (and I think L2 cache) already enable.
>
> Ok, I see. I remember mvebu smp relies on mbus mappings also? Can you
> try below as replacement for the mach-mvebu/armada-370-xp.c changes?
>
> It will move coherency_init(), l2x0_of_init(), and mvebu_mbus_dt_init()
> to .init_early hook.
>

I can't test it, because I don't receive the patch 1 and 2 neither directly
or through linux-arm-kernel (it should have been bounced), or even at
https://github.com/shesselba/linux-dove.git

If you don't want to send them again, could you at least push our branch on your
github?

Thanks

> Sebastian
>


--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

2013-08-23 12:13:35

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 08/17] ARM: mvebu: remove custom .init_time hook

On 08/23/13 13:39, Gregory CLEMENT wrote:
> On 23/08/2013 12:32, Sebastian Hesselbarth wrote:
>> On 08/23/13 12:06, Gregory CLEMENT wrote:
>>> On 20/08/2013 04:04, Sebastian Hesselbarth wrote:
>>>> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
>>>> remove custom .init_time hooks.
>>>
>>> As a feared it won't work on Armada XP. You moved coherency_init(), and
>>> l2x0_of_init() in the init_machine hook. However init_machine is an
>>> arch_initcall, and as all the initcall it is called at the end of the
>>> do_basic_setup() which is called after smp_prepare_cpus(). The issue is
>>> that smp_prepare_cpus need coherency (and I think L2 cache) already enable.
>>
>> Ok, I see. I remember mvebu smp relies on mbus mappings also? Can you
>> try below as replacement for the mach-mvebu/armada-370-xp.c changes?
>>
>> It will move coherency_init(), l2x0_of_init(), and mvebu_mbus_dt_init()
>> to .init_early hook.
>>
>
> I can't test it, because I don't receive the patch 1 and 2 neither directly
> or through linux-arm-kernel (it should have been bounced), or even at
> https://github.com/shesselba/linux-dove.git
>
> If you don't want to send them again, could you at least push our branch on your
> github?

Gregory,

I pushed a branch containing the latest state to
https://github.com/shesselba/linux-dove.git arm-clk-of-init

It still contains the changes to drivers/clk.c, that will become
obsolete, if there are no objections against Stephen's tegra patch.

Sebastian

2013-08-23 14:23:09

by Gregory CLEMENT

[permalink] [raw]
Subject: Re: [RFC 08/17] ARM: mvebu: remove custom .init_time hook

On 23/08/2013 14:13, Sebastian Hesselbarth wrote:
> On 08/23/13 13:39, Gregory CLEMENT wrote:
>> On 23/08/2013 12:32, Sebastian Hesselbarth wrote:
>>> On 08/23/13 12:06, Gregory CLEMENT wrote:
>>>> On 20/08/2013 04:04, Sebastian Hesselbarth wrote:
>>>>> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
>>>>> remove custom .init_time hooks.
>>>>
>>>> As a feared it won't work on Armada XP. You moved coherency_init(), and
>>>> l2x0_of_init() in the init_machine hook. However init_machine is an
>>>> arch_initcall, and as all the initcall it is called at the end of the
>>>> do_basic_setup() which is called after smp_prepare_cpus(). The issue is
>>>> that smp_prepare_cpus need coherency (and I think L2 cache) already enable.
>>>
>>> Ok, I see. I remember mvebu smp relies on mbus mappings also? Can you
>>> try below as replacement for the mach-mvebu/armada-370-xp.c changes?
>>>
>>> It will move coherency_init(), l2x0_of_init(), and mvebu_mbus_dt_init()
>>> to .init_early hook.
>>>
>>
>> I can't test it, because I don't receive the patch 1 and 2 neither directly
>> or through linux-arm-kernel (it should have been bounced), or even at
>> https://github.com/shesselba/linux-dove.git
>>
>> If you don't want to send them again, could you at least push our branch on your
>> github?
>
> Gregory,
>
> I pushed a branch containing the latest state to
> https://github.com/shesselba/linux-dove.git arm-clk-of-init
>
> It still contains the changes to drivers/clk.c, that will become
> obsolete, if there are no objections against Stephen's tegra patch.
>

I tested your branch on my Armada XP boards (the GP and the AX3), and it hanged
very early: before that anything was displayed by the early_printk!

init_early is maybe called too early :(

> Sebastian
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>


--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

2013-08-23 14:34:45

by Gregory CLEMENT

[permalink] [raw]
Subject: Re: [RFC 08/17] ARM: mvebu: remove custom .init_time hook

On 23/08/2013 16:23, Gregory CLEMENT wrote:
> On 23/08/2013 14:13, Sebastian Hesselbarth wrote:
>> On 08/23/13 13:39, Gregory CLEMENT wrote:
>>> On 23/08/2013 12:32, Sebastian Hesselbarth wrote:
>>>> On 08/23/13 12:06, Gregory CLEMENT wrote:
>>>>> On 20/08/2013 04:04, Sebastian Hesselbarth wrote:
>>>>>> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
>>>>>> remove custom .init_time hooks.
>>>>>
>>>>> As a feared it won't work on Armada XP. You moved coherency_init(), and
>>>>> l2x0_of_init() in the init_machine hook. However init_machine is an
>>>>> arch_initcall, and as all the initcall it is called at the end of the
>>>>> do_basic_setup() which is called after smp_prepare_cpus(). The issue is
>>>>> that smp_prepare_cpus need coherency (and I think L2 cache) already enable.
>>>>
>>>> Ok, I see. I remember mvebu smp relies on mbus mappings also? Can you
>>>> try below as replacement for the mach-mvebu/armada-370-xp.c changes?
>>>>
>>>> It will move coherency_init(), l2x0_of_init(), and mvebu_mbus_dt_init()
>>>> to .init_early hook.
>>>>
>>>
>>> I can't test it, because I don't receive the patch 1 and 2 neither directly
>>> or through linux-arm-kernel (it should have been bounced), or even at
>>> https://github.com/shesselba/linux-dove.git
>>>
>>> If you don't want to send them again, could you at least push our branch on your
>>> github?
>>
>> Gregory,
>>
>> I pushed a branch containing the latest state to
>> https://github.com/shesselba/linux-dove.git arm-clk-of-init
>>
>> It still contains the changes to drivers/clk.c, that will become
>> obsolete, if there are no objections against Stephen's tegra patch.
>>
>
> I tested your branch on my Armada XP boards (the GP and the AX3), and it hanged
> very early: before that anything was displayed by the early_printk!
>
> init_early is maybe called too early :(

Well actually next-20130822 don't boot. So I can't say if your changes are ok.

>
>> Sebastian
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> [email protected]
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
>
>


--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

2013-08-23 16:00:38

by Soren Brinkmann

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

Hi Steffen,

On Fri, Aug 23, 2013 at 09:32:50AM +0200, Steffen Trumtrar wrote:
> Hi!
>
> On Thu, Aug 22, 2013 at 05:59:36PM -0700, Sören Brinkmann wrote:
> > On Thu, Aug 22, 2013 at 05:26:47PM -0700, Sören Brinkmann wrote:
[ ... ]
> I propose getting rid of the whole global pointer and let the clkc map the
> address itself instead.
>
> Then there is no need to shuffle stuff around in the initcalls.
> I have some WIP patches (not rebased on next and not even tested with it,
> but with v3.11-rc4)
>
> The dtsi would be something like:
>
> control-register@f8000000 {
> compatible = "simple-bus";
> #address-cells = <1>;
> #size-cells = <1>;
> reg = <0xf8000000 0x1000>;
> ranges;
>
> slcr: slcr@f8000000 {
> compatible = "xlnx,zynq-slcr", "syscon";
> reg = <0xf8000000 0x10>;
> };
>
> clkc: clkc@f8000100 {
> #clock-cells = <1>;
> compatible = "xlnx,ps7-clkc";
> reg = <0xf8000100 0x100>;

This is splitting the SLCR into multiple regions. I just heard about the
syscon the first time, but wouldn't it be more correct to leave the SLCR
region in one piece in the slcr node and then pass the slcr phandle to
the clkc and later also pinmux etc. nodes? This way the SLCR is in
charge of the lock and all registers protected by the lock.
That wouldn't get rid of the dependency that SLCR has to be initialized
before any of its users, but seems to reflect actual HW better since the
whole region is protected by the same SLCR lock which makes them kinda
inseparable.

Anyway, after all we more or less agree, that syscon/slcr has to be
initialized before any SLCR user. So, no matter whether we do this
through current code and a global pointer or DT phandles, the effect
stays the same, IIUC.
So, in order to not mix stuff around too much, I'd rather make sure that
zynq_slcr_init() is called early enough (put it in init_irq() or some
init_call() whatever works best), and keep the global pointer for now.
That way most code can stay as is and we don't have to change the DT
bindings.
And then you can finish your work on this and we can revisit the topic
of migrating to use the slcr through a phandle later?

Sören

2013-08-23 17:19:52

by Soren Brinkmann

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

Hi Sebastian, Steffen,

On Fri, Aug 23, 2013 at 11:30:18AM +0200, Sebastian Hesselbarth wrote:
> On 08/23/13 02:59, Sören Brinkmann wrote:
> >On Thu, Aug 22, 2013 at 05:26:47PM -0700, Sören Brinkmann wrote:
> >>On Tue, Aug 20, 2013 at 04:04:31AM +0200, Sebastian Hesselbarth wrote:
> >>>With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> >>>remove it from corresponding drivers/clk code.
> >>
> >>I think that would break Zynq.
> >>If I see this correctly you call of_clk_init() from common code,
> >>_before_ the SOC specific time init function is called.
> >>The problem is, that we have code setting up a global pointer which is
> >>required by zynq_clk_setup() which is triggered when of_clk_init() is
> >>called.
[ ... ]
> thanks for looking into this. I also had a look at the files in
> question. Based on Steffen's proposal, I prepared a diff that should do
> the trick. It moves zynq_slcr_init() to early_init, instead of reusing
> another hook that has magic cow powers (it calls irqchip_init that zynq
> also wants sooner or later).
>
> Also, it removes zynq_clock_init() and let zynq_clk_setup() map the
> register itself by finding the node and use of_iomap(). I realized that
> clock registers are quite separated within slcr, so you can consider
> to have your own node for the clk-provider. As Steffen is proposing
> this but mentioned incompatible DT changes, I chose that intermediate
> step above.
>
> It would be great, if you test the diff and prepare a patch out of
> it, that I pick-up in the patch set. That way, we also have your
> Signed-off on it.

I looked into this. Looks like init_early() happens to early. I suspect
slab is missing to make zynq_slcr_init() work. So, I moved it into
init_irq(). Is there any init_call() type which is called at the correct
time?

I looked briefly into syscon and regmap, and that does actually look
promising and to really fix this mess, I guess we have to wait a little
until Steffen finishes his work on it.

To facilitate Sebastian's series I came up with the patch below.
The problem I have is, I do not really want the clkc to map the
registers. They are in the SLCR and the SLCR driver is doing it, hence
we should work with what that driver provides - which ideally would be
based on regmap and syscon, but we're not there yet. Hence I somehow
need to pass the SLCR pointer to the clkc. To avoid accessing the global
pointer directly I kept the zynq_clock_init() routine which is called
from zynq_slcr_init().

That is the best I could come up with quickly and w/o investing a lot of
time to figure out the regmap and syscon stuff, which seems to be handled
by Steffen already, anyway.
It is essentially a stripped down version of Sebastian's proposal.

Sören

-----8<--------------------8<-------------------8<-------------------

>From bb7a02dad9cc578caf1e21a1b7f45ed602676bfa Mon Sep 17 00:00:00 2001
From: Soren Brinkmann <[email protected]>
Date: Fri, 23 Aug 2013 09:27:11 -0700
Subject: [PATCH RFC] arm: zynq: Don't call of_clk_init()

of_clk_init() has been moved to be called from common code, therefore
remove it from Zynq's clock init routine.
Since the Zynq's clock setup routine relies on an initialized SLCR,
zynq_slcr_init() is moved to init_irq() (note: it must be before
init_time() but after slab is available, hence init_early() does not
work).

Signed-off-by: Soren Brinkmann <[email protected]>
---
arch/arm/mach-zynq/common.c | 9 ++++-----
drivers/clk/zynq/clkc.c | 4 +++-
2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 5f25256..f28046e 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -19,10 +19,9 @@
#include <linux/cpumask.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
-#include <linux/clk/zynq.h>
-#include <linux/clocksource.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
+#include <linux/irqchip.h>
#include <linux/of_platform.h>
#include <linux/of.h>

@@ -58,10 +57,10 @@ static void __init zynq_init_machine(void)
of_platform_bus_probe(NULL, zynq_of_bus_ids, NULL);
}

-static void __init zynq_timer_init(void)
+static void __init zynq_init_irq(void)
{
+ irqchip_init();
zynq_slcr_init();
- clocksource_of_init();
}

static struct map_desc zynq_cortex_a9_scu_map __initdata = {
@@ -104,8 +103,8 @@ static const char * const zynq_dt_match[] = {
DT_MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform")
.smp = smp_ops(zynq_smp_ops),
.map_io = zynq_map_io,
+ .init_irq = zynq_init_irq,
.init_machine = zynq_init_machine,
- .init_time = zynq_timer_init,
.dt_compat = zynq_dt_match,
.restart = zynq_system_reset,
MACHINE_END
diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index 089d3e3..53b851e 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -206,6 +206,9 @@ static void __init zynq_clk_setup(struct device_node *np)

pr_info("Zynq clock init\n");

+ if (WARN_ON(!zynq_slcr_base_priv))
+ return;
+
/* get clock output names from DT */
for (i = 0; i < clk_max; i++) {
if (of_property_read_string_index(np, "clock-output-names",
@@ -532,5 +535,4 @@ CLK_OF_DECLARE(zynq_clkc, "xlnx,ps7-clkc", zynq_clk_setup);
void __init zynq_clock_init(void __iomem *slcr_base)
{
zynq_slcr_base_priv = slcr_base;
- of_clk_init(NULL);
}
--
1.8.3.4

2013-08-23 17:44:11

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

On 08/23/13 19:19, Sören Brinkmann wrote:
> On Fri, Aug 23, 2013 at 11:30:18AM +0200, Sebastian Hesselbarth wrote:
>> On 08/23/13 02:59, Sören Brinkmann wrote:
>>> On Thu, Aug 22, 2013 at 05:26:47PM -0700, Sören Brinkmann wrote:
>>>> On Tue, Aug 20, 2013 at 04:04:31AM +0200, Sebastian Hesselbarth wrote:
>>>>> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
>>>>> remove it from corresponding drivers/clk code.
>>>>
>>>> I think that would break Zynq.
>>>> If I see this correctly you call of_clk_init() from common code,
>>>> _before_ the SOC specific time init function is called.
>>>> The problem is, that we have code setting up a global pointer which is
>>>> required by zynq_clk_setup() which is triggered when of_clk_init() is
>>>> called.
> [ ... ]
>> thanks for looking into this. I also had a look at the files in
>> question. Based on Steffen's proposal, I prepared a diff that should do
>> the trick. It moves zynq_slcr_init() to early_init, instead of reusing
>> another hook that has magic cow powers (it calls irqchip_init that zynq
>> also wants sooner or later).
>>
>> Also, it removes zynq_clock_init() and let zynq_clk_setup() map the
>> register itself by finding the node and use of_iomap(). I realized that
>> clock registers are quite separated within slcr, so you can consider
>> to have your own node for the clk-provider. As Steffen is proposing
>> this but mentioned incompatible DT changes, I chose that intermediate
>> step above.
>>
>> It would be great, if you test the diff and prepare a patch out of
>> it, that I pick-up in the patch set. That way, we also have your
>> Signed-off on it.
>
> I looked into this. Looks like init_early() happens to early. I suspect
> slab is missing to make zynq_slcr_init() work. So, I moved it into
> init_irq(). Is there any init_call() type which is called at the correct
> time?

Sören,

I mistakenly assumed init_early is after mm, so of course my proposal
does not work as it should. I am fine with moving it to init_irq() until
you find the best solution (or until we have the same "mess" with
default init_irq hook).

> I looked briefly into syscon and regmap, and that does actually look
> promising and to really fix this mess, I guess we have to wait a little
> until Steffen finishes his work on it.

IIRC, both syscon and regmap will require you to have devices ready.
I haven't followed all recent discussions about early device
registration. Anyway, it will not help much in the current approach
to get rid of custom .init_timer and maybe .init_irq later.

> To facilitate Sebastian's series I came up with the patch below.
> The problem I have is, I do not really want the clkc to map the
> registers. They are in the SLCR and the SLCR driver is doing it, hence
> we should work with what that driver provides - which ideally would be
> based on regmap and syscon, but we're not there yet. Hence I somehow
> need to pass the SLCR pointer to the clkc. To avoid accessing the global
> pointer directly I kept the zynq_clock_init() routine which is called
> from zynq_slcr_init().

For this patch set I'd be fine with the proposal below. For the short
run, you could consider to hide register accesses to slcr by providing
zynq_slcr_readl/writel instead of passing just the base address.

But again, that will require either custom .init_time or .init_irq
to set up slcr before clocks.

> That is the best I could come up with quickly and w/o investing a lot of
> time to figure out the regmap and syscon stuff, which seems to be handled
> by Steffen already, anyway.
> It is essentially a stripped down version of Sebastian's proposal.

If there are no general objections, I take that one for the real patch
set.

Sebastian

2013-08-23 23:22:53

by Steffen Trumtrar

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

On Fri, Aug 23, 2013 at 07:44:03PM +0200, Sebastian Hesselbarth wrote:
> On 08/23/13 19:19, S?ren Brinkmann wrote:
> >On Fri, Aug 23, 2013 at 11:30:18AM +0200, Sebastian Hesselbarth wrote:
> >>On 08/23/13 02:59, S?ren Brinkmann wrote:
> >>>On Thu, Aug 22, 2013 at 05:26:47PM -0700, S?ren Brinkmann wrote:
> >>>>On Tue, Aug 20, 2013 at 04:04:31AM +0200, Sebastian Hesselbarth wrote:
> >>>>>With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> >>>>>remove it from corresponding drivers/clk code.
> >>>>
> >>>>I think that would break Zynq.
> >>>>If I see this correctly you call of_clk_init() from common code,
> >>>>_before_ the SOC specific time init function is called.
> >>>>The problem is, that we have code setting up a global pointer which is
> >>>>required by zynq_clk_setup() which is triggered when of_clk_init() is
> >>>>called.
> >[ ... ]
> >>thanks for looking into this. I also had a look at the files in
> >>question. Based on Steffen's proposal, I prepared a diff that should do
> >>the trick. It moves zynq_slcr_init() to early_init, instead of reusing
> >>another hook that has magic cow powers (it calls irqchip_init that zynq
> >>also wants sooner or later).
> >>
> >>Also, it removes zynq_clock_init() and let zynq_clk_setup() map the
> >>register itself by finding the node and use of_iomap(). I realized that
> >>clock registers are quite separated within slcr, so you can consider
> >>to have your own node for the clk-provider. As Steffen is proposing
> >>this but mentioned incompatible DT changes, I chose that intermediate
> >>step above.
> >>
> >>It would be great, if you test the diff and prepare a patch out of
> >>it, that I pick-up in the patch set. That way, we also have your
> >>Signed-off on it.
> >
> >I looked into this. Looks like init_early() happens to early. I suspect
> >slab is missing to make zynq_slcr_init() work. So, I moved it into
> >init_irq(). Is there any init_call() type which is called at the correct
> >time?
>
> S?ren,
>
> I mistakenly assumed init_early is after mm, so of course my proposal
> does not work as it should. I am fine with moving it to init_irq() until
> you find the best solution (or until we have the same "mess" with
> default init_irq hook).
>
> >I looked briefly into syscon and regmap, and that does actually look
> >promising and to really fix this mess, I guess we have to wait a little
> >until Steffen finishes his work on it.
>
> IIRC, both syscon and regmap will require you to have devices ready.
> I haven't followed all recent discussions about early device
> registration. Anyway, it will not help much in the current approach
> to get rid of custom .init_timer and maybe .init_irq later.
>

Yes. The syscon driver can not be used that early. It only makes sense
for later stages. Therefore the slcr has to be mapped early to unlock
and than remapped later. But with the current drivers, it is not essential
to have the slcr as a seperate driver.

> >To facilitate Sebastian's series I came up with the patch below.
> >The problem I have is, I do not really want the clkc to map the
> >registers. They are in the SLCR and the SLCR driver is doing it, hence
> >we should work with what that driver provides - which ideally would be
> >based on regmap and syscon, but we're not there yet. Hence I somehow
> >need to pass the SLCR pointer to the clkc. To avoid accessing the global
> >pointer directly I kept the zynq_clock_init() routine which is called
> >from zynq_slcr_init().
>
> For this patch set I'd be fine with the proposal below. For the short
> run, you could consider to hide register accesses to slcr by providing
> zynq_slcr_readl/writel instead of passing just the base address.
>
> But again, that will require either custom .init_time or .init_irq
> to set up slcr before clocks.
>
> >That is the best I could come up with quickly and w/o investing a lot of
> >time to figure out the regmap and syscon stuff, which seems to be handled
> >by Steffen already, anyway.
> >It is essentially a stripped down version of Sebastian's proposal.
>
> If there are no general objections, I take that one for the real patch
> set.

I haven't tested this, but I hope S?ren did. For the time being, I am
okay with it.

Regards,
Steffen

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

2013-08-23 23:38:59

by Steffen Trumtrar

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

On Fri, Aug 23, 2013 at 09:00:23AM -0700, S?ren Brinkmann wrote:
> Hi Steffen,
>
> On Fri, Aug 23, 2013 at 09:32:50AM +0200, Steffen Trumtrar wrote:
> > Hi!
> >
> > On Thu, Aug 22, 2013 at 05:59:36PM -0700, S?ren Brinkmann wrote:
> > > On Thu, Aug 22, 2013 at 05:26:47PM -0700, S?ren Brinkmann wrote:
> [ ... ]
> > I propose getting rid of the whole global pointer and let the clkc map the
> > address itself instead.
> >
> > Then there is no need to shuffle stuff around in the initcalls.
> > I have some WIP patches (not rebased on next and not even tested with it,
> > but with v3.11-rc4)
> >
> > The dtsi would be something like:
> >
> > control-register@f8000000 {
> > compatible = "simple-bus";
> > #address-cells = <1>;
> > #size-cells = <1>;
> > reg = <0xf8000000 0x1000>;
> > ranges;
> >
> > slcr: slcr@f8000000 {
> > compatible = "xlnx,zynq-slcr", "syscon";
> > reg = <0xf8000000 0x10>;
> > };
> >
> > clkc: clkc@f8000100 {
> > #clock-cells = <1>;
> > compatible = "xlnx,ps7-clkc";
> > reg = <0xf8000100 0x100>;
>
> This is splitting the SLCR into multiple regions. I just heard about the
> syscon the first time, but wouldn't it be more correct to leave the SLCR
> region in one piece in the slcr node and then pass the slcr phandle to
> the clkc and later also pinmux etc. nodes? This way the SLCR is in
> charge of the lock and all registers protected by the lock.
> That wouldn't get rid of the dependency that SLCR has to be initialized
> before any of its users, but seems to reflect actual HW better since the
> whole region is protected by the same SLCR lock which makes them kinda
> inseparable.
>

Actually I agree. What I was struggeling with, was the correct mapping of the
ranges. But maybe I have to take another look at the "ranges = <..>" property.

> Anyway, after all we more or less agree, that syscon/slcr has to be
> initialized before any SLCR user. So, no matter whether we do this
> through current code and a global pointer or DT phandles, the effect
> stays the same, IIUC.
> So, in order to not mix stuff around too much, I'd rather make sure that
> zynq_slcr_init() is called early enough (put it in init_irq() or some
> init_call() whatever works best), and keep the global pointer for now.
> That way most code can stay as is and we don't have to change the DT
> bindings.
> And then you can finish your work on this and we can revisit the topic
> of migrating to use the slcr through a phandle later?
>

Agreed.

Steffen

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

2013-08-26 11:15:25

by Michal Simek

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

On 08/23/2013 09:32 AM, Steffen Trumtrar wrote:
> Hi!
>
> On Thu, Aug 22, 2013 at 05:59:36PM -0700, S?ren Brinkmann wrote:
>> On Thu, Aug 22, 2013 at 05:26:47PM -0700, S?ren Brinkmann wrote:
>>> Hi Sebastian,
>>>
>>> On Tue, Aug 20, 2013 at 04:04:31AM +0200, Sebastian Hesselbarth wrote:
>>>> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
>>>> remove it from corresponding drivers/clk code.
>>>
>>> I think that would break Zynq.
>>> If I see this correctly you call of_clk_init() from common code,
>>> _before_ the SOC specific time init function is called.
>>> The problem is, that we have code setting up a global pointer which is
>>> required by zynq_clk_setup() which is triggered when of_clk_init() is
>>> called.
>>>
>>> Let me try to illustrate the current call graph:
>>>
>>> time_init()
>>> zynq_timer_init() // this machines init_time()
>>> zynq_slcr_init() // setup System Level Control Registers including a global pointer
>>> zynq_clock_init()
>>> of_clk_init()
>>> zynq_clk_setup() // requires pointer setup in zynq_slcr_init()
>>> ...
>>>
>>> IIUC, your series would change this to:
>>> time_init()
>>> of_clk_init()
>>> zynq_clk_setup() // SLCR pointer is not setup/NULL
>>> ...
>>> zynq_timer_init()
>>> zynq_slcr_init() // now the pointer becomes valid
>>
>> I guess we could move zynq_slcr_init() into init_irq(). I'll give that a
>> shot tomorrow.
>>
>
> I propose getting rid of the whole global pointer and let the clkc map the
> address itself instead.
>
> Then there is no need to shuffle stuff around in the initcalls.
> I have some WIP patches (not rebased on next and not even tested with it,
> but with v3.11-rc4)
>
> The dtsi would be something like:
>
> control-register@f8000000 {

This name is incorrect - it still should be slcr (system level control registers)

> compatible = "simple-bus";

I expect that syscon compatible should be here not in the lock part because
you want to map the whole reg space.

> #address-cells = <1>;
> #size-cells = <1>;
> reg = <0xf8000000 0x1000>;
> ranges;
>
> slcr: slcr@f8000000 {

we should use different name here - lock/locks/etc.

> compatible = "xlnx,zynq-slcr", "syscon";
> reg = <0xf8000000 0x10>;
> };



>
> clkc: clkc@f8000100 {
> #clock-cells = <1>;
> compatible = "xlnx,ps7-clkc";
> reg = <0xf8000100 0x100>;
> ps-clk-frequency = <33333333>;
> xlnx,slcr = <&slcr>;

Currently there is no code which handles locks that's why I think at least
for now it is not necessary to extend binding which feature which is not used.

> clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x",
> "cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x",
> "dci", "lqspi", "smc", "pcap", "gem0", "gem1",
> "fclk0", "fclk1", "fclk2", "fclk3", "can0", "can1",
> "sdio0", "sdio1", "uart0", "uart1", "spi0", "spi1",
> "dma", "usb0_aper", "usb1_aper", "gem0_aper",
> "gem1_aper", "sdio0_aper", "sdio1_aper",
> "spi0_aper", "spi1_aper", "can0_aper", "can1_aper",
> "i2c0_aper", "i2c1_aper", "uart0_aper", "uart1_aper",
> "gpio_aper", "lqspi_aper", "smc_aper", "swdt",
> "dbg_trc", "dbg_apb";
> };
>
> mio: pinmux@f8000700 {
> compatible = "xlnx,ps7-pinctrl";

Have you created any driver for pinmuxing stuff?

I agree with Soren - let's fix the current problem and then when Steffen has patches with syscon
we can look at them.

If there is any discussion about early syscon registration please let me know.

Thanks,
Michal


--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: http://www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform



Attachments:
signature.asc (263.00 B)
OpenPGP digital signature

2013-08-26 12:07:26

by Steffen Trumtrar

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

Hi Michal!

On Mon, Aug 26, 2013 at 01:15:11PM +0200, Michal Simek wrote:
> On 08/23/2013 09:32 AM, Steffen Trumtrar wrote:
> > Hi!
> >
> > On Thu, Aug 22, 2013 at 05:59:36PM -0700, S?ren Brinkmann wrote:
> >> On Thu, Aug 22, 2013 at 05:26:47PM -0700, S?ren Brinkmann wrote:
> >>> Hi Sebastian,
> >>>
> >>> On Tue, Aug 20, 2013 at 04:04:31AM +0200, Sebastian Hesselbarth wrote:
> >>>> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> >>>> remove it from corresponding drivers/clk code.
> >>>
> >>> I think that would break Zynq.
> >>> If I see this correctly you call of_clk_init() from common code,
> >>> _before_ the SOC specific time init function is called.
> >>> The problem is, that we have code setting up a global pointer which is
> >>> required by zynq_clk_setup() which is triggered when of_clk_init() is
> >>> called.
> >>>
> >>> Let me try to illustrate the current call graph:
> >>>
> >>> time_init()
> >>> zynq_timer_init() // this machines init_time()
> >>> zynq_slcr_init() // setup System Level Control Registers including a global pointer
> >>> zynq_clock_init()
> >>> of_clk_init()
> >>> zynq_clk_setup() // requires pointer setup in zynq_slcr_init()
> >>> ...
> >>>
> >>> IIUC, your series would change this to:
> >>> time_init()
> >>> of_clk_init()
> >>> zynq_clk_setup() // SLCR pointer is not setup/NULL
> >>> ...
> >>> zynq_timer_init()
> >>> zynq_slcr_init() // now the pointer becomes valid
> >>
> >> I guess we could move zynq_slcr_init() into init_irq(). I'll give that a
> >> shot tomorrow.
> >>
> >
> > I propose getting rid of the whole global pointer and let the clkc map the
> > address itself instead.
> >
> > Then there is no need to shuffle stuff around in the initcalls.
> > I have some WIP patches (not rebased on next and not even tested with it,
> > but with v3.11-rc4)
> >
> > The dtsi would be something like:
> >
> > control-register@f8000000 {
>
> This name is incorrect - it still should be slcr (system level control registers)
>

Agreed. I actually already changed it back...

> > compatible = "simple-bus";
>
> I expect that syscon compatible should be here not in the lock part because
> you want to map the whole reg space.
>

and have done this...

> > #address-cells = <1>;
> > #size-cells = <1>;
> > reg = <0xf8000000 0x1000>;
> > ranges;
> >
> > slcr: slcr@f8000000 {
>
> we should use different name here - lock/locks/etc.
>

and this actually, too.

> > compatible = "xlnx,zynq-slcr", "syscon";
> > reg = <0xf8000000 0x10>;
> > };
>
>
>
> >
> > clkc: clkc@f8000100 {
> > #clock-cells = <1>;
> > compatible = "xlnx,ps7-clkc";
> > reg = <0xf8000100 0x100>;
> > ps-clk-frequency = <33333333>;
> > xlnx,slcr = <&slcr>;
>
> Currently there is no code which handles locks that's why I think at least
> for now it is not necessary to extend binding which feature which is not used.
>

Sure. You are right.

> > clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x",
> > "cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x",
> > "dci", "lqspi", "smc", "pcap", "gem0", "gem1",
> > "fclk0", "fclk1", "fclk2", "fclk3", "can0", "can1",
> > "sdio0", "sdio1", "uart0", "uart1", "spi0", "spi1",
> > "dma", "usb0_aper", "usb1_aper", "gem0_aper",
> > "gem1_aper", "sdio0_aper", "sdio1_aper",
> > "spi0_aper", "spi1_aper", "can0_aper", "can1_aper",
> > "i2c0_aper", "i2c1_aper", "uart0_aper", "uart1_aper",
> > "gpio_aper", "lqspi_aper", "smc_aper", "swdt",
> > "dbg_trc", "dbg_apb";
> > };
> >
> > mio: pinmux@f8000700 {
> > compatible = "xlnx,ps7-pinctrl";
>
> Have you created any driver for pinmuxing stuff?
>

At the moment it is just a regmap. That means one could hammer the values directly
into /sys/kernel/debug/regmap/pinmux@...

I first opted for the pinctrl-single driver, but the MIO has three (?) extra registers
which do not map very well to the "one pin one register" setup of that driver.

> I agree with Soren - let's fix the current problem and then when Steffen has patches with syscon
> we can look at them.
>
> If there is any discussion about early syscon registration please let me know.
>

Where I'm stuck at the moment is: if I map the whole register space to the
parent node, how do I get its mapped address in the clkc?
AFAIK the phandle is pretty useless in this early stage. In the pinmuxing
case I should be able to find the registered driver for the lock via the
phandle.
If I remember correctly, there where some patches floating around for exactly
this problem. At the moment, I think the global pointer has to stay, until
those patches are mainline, if ever. Or I'm missing some obvious way of how
to get the base address of the slcr, that I can pass to the clock framework.
It doesn't need to be syscon, as the clock framework can't use it anyway.

Regards,
Steffen

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

2013-08-26 12:53:42

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

On 08/26/13 14:07, Steffen Trumtrar wrote:
> On Mon, Aug 26, 2013 at 01:15:11PM +0200, Michal Simek wrote:
>> I agree with Soren - let's fix the current problem and then when Steffen has patches with syscon
>> we can look at them.
>>
>> If there is any discussion about early syscon registration please let me know.
>>
>
> Where I'm stuck at the moment is: if I map the whole register space to the
> parent node, how do I get its mapped address in the clkc?

Steffen,

if slcr is such an essential part of the SoC, you can choose to provide
zynq_slcr_readl/writel callbacks. You can then use those callback in the
clock driver without knowing the base address. Also, it allows you to
hide slcr specific locking details from subsequent drivers using the
callbacks.

> AFAIK the phandle is pretty useless in this early stage. In the pinmuxing
> case I should be able to find the registered driver for the lock via the
> phandle.

About the slcr phandle, yes, it is useless. IMHO phandles should only
be used if the referenced node is not known in advance, e.g. for gpios
or clocks. As you will always reference slcr node (and only that node)
you can just use of_find_compatible_node instead. But with the callbacks
above, you will solve it without exploiting DT but common non-static
functions instead.

Sebastian

2013-08-26 15:14:37

by Michal Simek

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

On 08/26/2013 02:53 PM, Sebastian Hesselbarth wrote:
> On 08/26/13 14:07, Steffen Trumtrar wrote:
>> On Mon, Aug 26, 2013 at 01:15:11PM +0200, Michal Simek wrote:
>>> I agree with Soren - let's fix the current problem and then when Steffen has patches with syscon
>>> we can look at them.
>>>
>>> If there is any discussion about early syscon registration please let me know.
>>>
>>
>> Where I'm stuck at the moment is: if I map the whole register space to the
>> parent node, how do I get its mapped address in the clkc?
>
> Steffen,
>
> if slcr is such an essential part of the SoC, you can choose to provide
> zynq_slcr_readl/writel callbacks. You can then use those callback in the
> clock driver without knowing the base address. Also, it allows you to
> hide slcr specific locking details from subsequent drivers using the
> callbacks.

I don't think this will help. What you need to call in the clk driver is
regmap_read/regmap_write but you can call it when syscon/regmap driver
is initialized.

Steffen: Can you point me to that floading patches? If they are useful
we can try them and help with pushing them to the mainline.
I don't think that there is any reasonable solution without using these
patches.

Thanks,
Michal

--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: http://www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform



Attachments:
signature.asc (263.00 B)
OpenPGP digital signature

2013-08-26 15:16:46

by Soren Brinkmann

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

On Mon, Aug 26, 2013 at 02:53:35PM +0200, Sebastian Hesselbarth wrote:
> On 08/26/13 14:07, Steffen Trumtrar wrote:
> >On Mon, Aug 26, 2013 at 01:15:11PM +0200, Michal Simek wrote:
> >>I agree with Soren - let's fix the current problem and then when Steffen has patches with syscon
> >>we can look at them.
> >>
> >>If there is any discussion about early syscon registration please let me know.
> >>
> >
> >Where I'm stuck at the moment is: if I map the whole register space to the
> >parent node, how do I get its mapped address in the clkc?
>
> Steffen,
>
> if slcr is such an essential part of the SoC, you can choose to provide
> zynq_slcr_readl/writel callbacks. You can then use those callback in the
> clock driver without knowing the base address. Also, it allows you to
> hide slcr specific locking details from subsequent drivers using the
> callbacks.

I don't think that'll work. The clkc just wraps the cock primitives and
does not provide a lot of own clock drivers - actually only one. Those
clock primitives receive an iomapped address for the clock control which
is then accessed using readl/writel(). So, wrapping all SLCR accesses in
special accessors would mean to have almost identical reimplementations
of all used clock primitives, just to replace readl/writel with
zynq_slcr_write/read. Or is there some way to make this actually work?


Sören

2013-08-26 15:20:49

by Soren Brinkmann

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

On Fri, Aug 23, 2013 at 07:44:03PM +0200, Sebastian Hesselbarth wrote:
> On 08/23/13 19:19, Sören Brinkmann wrote:
> >On Fri, Aug 23, 2013 at 11:30:18AM +0200, Sebastian Hesselbarth wrote:
> >>On 08/23/13 02:59, Sören Brinkmann wrote:
> >>>On Thu, Aug 22, 2013 at 05:26:47PM -0700, Sören Brinkmann wrote:
> >>>>On Tue, Aug 20, 2013 at 04:04:31AM +0200, Sebastian Hesselbarth wrote:
> >>>>>With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> >>>>>remove it from corresponding drivers/clk code.
> >>>>
> >>>>I think that would break Zynq.
> >>>>If I see this correctly you call of_clk_init() from common code,
> >>>>_before_ the SOC specific time init function is called.
> >>>>The problem is, that we have code setting up a global pointer which is
> >>>>required by zynq_clk_setup() which is triggered when of_clk_init() is
> >>>>called.
> >[ ... ]
> >>thanks for looking into this. I also had a look at the files in
> >>question. Based on Steffen's proposal, I prepared a diff that should do
> >>the trick. It moves zynq_slcr_init() to early_init, instead of reusing
> >>another hook that has magic cow powers (it calls irqchip_init that zynq
> >>also wants sooner or later).
> >>
> >>Also, it removes zynq_clock_init() and let zynq_clk_setup() map the
> >>register itself by finding the node and use of_iomap(). I realized that
> >>clock registers are quite separated within slcr, so you can consider
> >>to have your own node for the clk-provider. As Steffen is proposing
> >>this but mentioned incompatible DT changes, I chose that intermediate
> >>step above.
> >>
> >>It would be great, if you test the diff and prepare a patch out of
> >>it, that I pick-up in the patch set. That way, we also have your
> >>Signed-off on it.
> >
> >I looked into this. Looks like init_early() happens to early. I suspect
> >slab is missing to make zynq_slcr_init() work. So, I moved it into
> >init_irq(). Is there any init_call() type which is called at the correct
> >time?
>
> Sören,
>
> I mistakenly assumed init_early is after mm, so of course my proposal
> does not work as it should. I am fine with moving it to init_irq() until
> you find the best solution (or until we have the same "mess" with
> default init_irq hook).

Looking at these two hooks. If the SOC provides init_irq(), the common
code does nothing, but calling it. Ergo, the SOC is now responsible for
otherwise commonly called code like of_irq_init().

It's probably an idea to design the common init_time() function the same
way. That way SOCs that don't need any custom init at that stage get
everything for free. And SOCs like Zynq have to still call of_clk_init()
manually, but can ensure that dependencies like our SLCR init are
satisfied before calling it.

Just an idea, not sure if it makes sense since I didn't look beyond Zynq
too much on this.

Sören

2013-08-26 15:31:22

by Steffen Trumtrar

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

Hi Michal,

On Mon, Aug 26, 2013 at 05:14:25PM +0200, Michal Simek wrote:
> Steffen: Can you point me to that floading patches? If they are useful
> we can try them and help with pushing them to the mainline.
> I don't think that there is any reasonable solution without using these
> patches.
>

I was referring to the RFC from Thierry https://lkml.org/lkml/2013/8/16/399
It sounds like it might help, but also that this might lead to unwanted
side effects.

str

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

2013-08-26 15:33:36

by Steffen Trumtrar

[permalink] [raw]
Subject: Re: [RFC 17/17] clk: zynq: remove call to of_clk_init

On Mon, Aug 26, 2013 at 08:16:29AM -0700, S?ren Brinkmann wrote:
> On Mon, Aug 26, 2013 at 02:53:35PM +0200, Sebastian Hesselbarth wrote:
> > On 08/26/13 14:07, Steffen Trumtrar wrote:
> > >On Mon, Aug 26, 2013 at 01:15:11PM +0200, Michal Simek wrote:
> > >>I agree with Soren - let's fix the current problem and then when Steffen has patches with syscon
> > >>we can look at them.
> > >>
> > >>If there is any discussion about early syscon registration please let me know.
> > >>
> > >
> > >Where I'm stuck at the moment is: if I map the whole register space to the
> > >parent node, how do I get its mapped address in the clkc?
> >
> > Steffen,
> >
> > if slcr is such an essential part of the SoC, you can choose to provide
> > zynq_slcr_readl/writel callbacks. You can then use those callback in the
> > clock driver without knowing the base address. Also, it allows you to
> > hide slcr specific locking details from subsequent drivers using the
> > callbacks.
>
> I don't think that'll work. The clkc just wraps the cock primitives and
> does not provide a lot of own clock drivers - actually only one. Those
> clock primitives receive an iomapped address for the clock control which
> is then accessed using readl/writel(). So, wrapping all SLCR accesses in
> special accessors would mean to have almost identical reimplementations
> of all used clock primitives, just to replace readl/writel with
> zynq_slcr_write/read. Or is there some way to make this actually work?

This is exactly my understanding, why I can't use a callback here. At least
not for the clkc.

str

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

2013-08-27 21:28:26

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 01/16] ARM: call clk_of_init from time_init

Most DT ARM machs require common clock providers initialized before timers.
Currently, arch/arm machs use .init_time to call clk_of_init right before
clocksource_of_init. This prevents to remove that hook and use the default
hook instead. clk_of_init is safe to call for non-DT platforms, so add
the call to ARM arch time_init by default. While at it, also reorder includes
alphabetically.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Changelog:
v1->v2:
- reorder includes alphabetically

Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
arch/arm/kernel/time.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index 98aee32..dd1028e 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -11,25 +11,26 @@
* This file contains the ARM-specific time handling details:
* reading the RTC at bootup, etc...
*/
+#include <linux/clk-provider.h>
+#include <linux/clocksource.h>
+#include <linux/errno.h>
#include <linux/export.h>
-#include <linux/kernel.h>
-#include <linux/interrupt.h>
-#include <linux/time.h>
#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/kernel.h>
+#include <linux/profile.h>
#include <linux/sched.h>
+#include <linux/sched_clock.h>
#include <linux/smp.h>
+#include <linux/time.h>
#include <linux/timex.h>
-#include <linux/errno.h>
-#include <linux/profile.h>
#include <linux/timer.h>
-#include <linux/clocksource.h>
-#include <linux/irq.h>
-#include <linux/sched_clock.h>

-#include <asm/thread_info.h>
-#include <asm/stacktrace.h>
#include <asm/mach/arch.h>
#include <asm/mach/time.h>
+#include <asm/stacktrace.h>
+#include <asm/thread_info.h>

#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE) || \
defined(CONFIG_NVRAM) || defined(CONFIG_NVRAM_MODULE)
@@ -116,6 +117,9 @@ int __init register_persistent_clock(clock_access_fn read_boot,

void __init time_init(void)
{
+ /* initalize common clocks before timers */
+ of_clk_init(NULL);
+
if (machine_desc->init_time)
machine_desc->init_time();
else
--
1.7.2.5

2013-08-27 21:28:33

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 11/16] ARM: socfpga: remove call to of_clk_init

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove mach specific calls to it.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Dinh Nguyen <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-socfpga/socfpga.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c
index bfce964..dd0d49c 100644
--- a/arch/arm/mach-socfpga/socfpga.c
+++ b/arch/arm/mach-socfpga/socfpga.c
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <linux/clk-provider.h>
#include <linux/irqchip.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
@@ -107,7 +106,6 @@ static void __init socfpga_cyclone5_init(void)
{
l2x0_of_init(0, ~0UL);
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
- of_clk_init(NULL);
socfpga_init_clocks();
}

--
1.7.2.5

2013-08-27 21:28:30

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 13/16] ARM: tegra: split tegra_pmc_init() in two

From: Stephen Warren <[email protected]>

Tegra's board file currently initializes clocks much earlier than those
for most other ARM SoCs. The reason is:

* The PMC HW block is involved in the path of some interrupts (i.e. it
inverts, or not, the IRQ input pin dedicated to the PMIC).

* So, that part of the PMC must be initialized early so that the IRQ
polarity is correct.

* The PMC initialization is currently monolithic, and the PMC has some
clock inputs, so the init routine ends up calling of_clk_get_by_name(),
and hence clocks must be set up early too.

In order to defer clock initialization to the more typical location,
split out the portions of tegra_pmc_init() that are truly IRQ-related
into a separate tegra_pmc_init_irq(), which can be called from the
machine descriptor's .init_irq() function, and defer the rest until
the machine descriptor's .init_machine() function. With arch/arm calling
of_clk_init(NULL) from time_init() this also allows the removal of
.init_time() hook.

Signed-off-by: Stephen Warren <[email protected]>
---
Changelog:
v1->v2:
- took Stephen Warren's patch provided to separate Tegra's pmc_init
- sqashed in .init_time removal and reworded patch text

Cc: Stephen Warren <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-tegra/common.c | 4 +---
arch/arm/mach-tegra/pmc.c | 41 ++++++++++++++++++++++-------------------
arch/arm/mach-tegra/pmc.h | 1 +
arch/arm/mach-tegra/tegra.c | 5 +++--
4 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-tegra/common.c b/arch/arm/mach-tegra/common.c
index 94a119a..58dc91c5 100644
--- a/arch/arm/mach-tegra/common.c
+++ b/arch/arm/mach-tegra/common.c
@@ -24,7 +24,6 @@
#include <linux/delay.h>
#include <linux/reboot.h>
#include <linux/irqchip.h>
-#include <linux/clk-provider.h>

#include <asm/hardware/cache-l2x0.h>

@@ -61,8 +60,7 @@ u32 tegra_uart_config[4] = {
#ifdef CONFIG_OF
void __init tegra_dt_init_irq(void)
{
- of_clk_init(NULL);
- tegra_pmc_init();
+ tegra_pmc_init_irq();
tegra_init_irq();
irqchip_init();
tegra_legacy_irq_syscore_init();
diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c
index 8acb881..7916ff9 100644
--- a/arch/arm/mach-tegra/pmc.c
+++ b/arch/arm/mach-tegra/pmc.c
@@ -285,13 +285,10 @@ static const struct of_device_id matches[] __initconst = {
{ }
};

-static void __init tegra_pmc_parse_dt(void)
+void __init tegra_pmc_init_irq(void)
{
struct device_node *np;
- u32 prop;
- enum tegra_suspend_mode suspend_mode;
- u32 core_good_time[2] = {0, 0};
- u32 lp0_vec[2] = {0, 0};
+ u32 val;

np = of_find_matching_node(NULL, matches);
BUG_ON(!np);
@@ -300,6 +297,26 @@ static void __init tegra_pmc_parse_dt(void)

tegra_pmc_invert_interrupt = of_property_read_bool(np,
"nvidia,invert-interrupt");
+
+ val = tegra_pmc_readl(PMC_CTRL);
+ if (tegra_pmc_invert_interrupt)
+ val |= PMC_CTRL_INTR_LOW;
+ else
+ val &= ~PMC_CTRL_INTR_LOW;
+ tegra_pmc_writel(val, PMC_CTRL);
+}
+
+void __init tegra_pmc_init(void)
+{
+ struct device_node *np;
+ u32 prop;
+ enum tegra_suspend_mode suspend_mode;
+ u32 core_good_time[2] = {0, 0};
+ u32 lp0_vec[2] = {0, 0};
+
+ np = of_find_matching_node(NULL, matches);
+ BUG_ON(!np);
+
tegra_pclk = of_clk_get_by_name(np, "pclk");
WARN_ON(IS_ERR(tegra_pclk));

@@ -365,17 +382,3 @@ static void __init tegra_pmc_parse_dt(void)

pmc_pm_data.suspend_mode = suspend_mode;
}
-
-void __init tegra_pmc_init(void)
-{
- u32 val;
-
- tegra_pmc_parse_dt();
-
- val = tegra_pmc_readl(PMC_CTRL);
- if (tegra_pmc_invert_interrupt)
- val |= PMC_CTRL_INTR_LOW;
- else
- val &= ~PMC_CTRL_INTR_LOW;
- tegra_pmc_writel(val, PMC_CTRL);
-}
diff --git a/arch/arm/mach-tegra/pmc.h b/arch/arm/mach-tegra/pmc.h
index 549f8c7..4d5f8f3 100644
--- a/arch/arm/mach-tegra/pmc.h
+++ b/arch/arm/mach-tegra/pmc.h
@@ -39,6 +39,7 @@ bool tegra_pmc_cpu_is_powered(int cpuid);
int tegra_pmc_cpu_power_on(int cpuid);
int tegra_pmc_cpu_remove_clamping(int cpuid);

+void tegra_pmc_init_irq(void);
void tegra_pmc_init(void);

#endif
diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index 5b86055..2e21928 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -16,7 +16,6 @@
*
*/

-#include <linux/clocksource.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
@@ -44,6 +43,7 @@
#include "common.h"
#include "fuse.h"
#include "iomap.h"
+#include "pmc.h"

static void __init tegra_dt_init(void)
{
@@ -51,6 +51,8 @@ static void __init tegra_dt_init(void)
struct soc_device *soc_dev;
struct device *parent = NULL;

+ tegra_pmc_init();
+
tegra_clocks_apply_init_table();

soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
@@ -119,7 +121,6 @@ DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)")
.smp = smp_ops(tegra_smp_ops),
.init_early = tegra_init_early,
.init_irq = tegra_dt_init_irq,
- .init_time = clocksource_of_init,
.init_machine = tegra_dt_init,
.init_late = tegra_dt_init_late,
.restart = tegra_assert_system_reset,
--
1.7.2.5

2013-08-27 21:28:29

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 14/16] ARM: vexpress: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks. The call to versatile_sched_clock_init
is moved to .init_early instead, we it is also for non-DT boards.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-vexpress/v2m.c | 14 +-------------
1 files changed, 1 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index 95a469e..4f8b8cb 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -1,12 +1,10 @@
/*
* Versatile Express V2M Motherboard Support
*/
-#include <linux/clocksource.h>
#include <linux/device.h>
#include <linux/amba/bus.h>
#include <linux/amba/mmci.h>
#include <linux/io.h>
-#include <linux/clocksource.h>
#include <linux/smp.h>
#include <linux/init.h>
#include <linux/of_address.h>
@@ -22,7 +20,6 @@
#include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h>
#include <linux/vexpress.h>
-#include <linux/clk-provider.h>
#include <linux/clkdev.h>

#include <asm/mach-types.h>
@@ -422,16 +419,8 @@ void __init v2m_dt_init_early(void)
pr_warning("vexpress: DT HBI (%x) is not matching "
"hardware (%x)!\n", dt_hbi, hbi);
}
-}
-
-static void __init v2m_dt_timer_init(void)
-{
- of_clk_init(NULL);

- clocksource_of_init();
-
- versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
- 24000000);
+ versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
}

static const struct of_device_id v2m_dt_bus_match[] __initconst = {
@@ -458,6 +447,5 @@ DT_MACHINE_START(VEXPRESS_DT, "ARM-Versatile Express")
.smp_init = smp_init_ops(vexpress_smp_init_ops),
.map_io = v2m_dt_map_io,
.init_early = v2m_dt_init_early,
- .init_time = v2m_dt_timer_init,
.init_machine = v2m_dt_init,
MACHINE_END
--
1.7.2.5

2013-08-27 21:29:33

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 12/16] ARM: sti: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks. To get rid of it, move l2cc init to
.init_machine hook instead.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Srinivas Kandagatla <[email protected]>
Cc: Stuart Menefy <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-sti/board-dt.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-sti/board-dt.c b/arch/arm/mach-sti/board-dt.c
index 8fe6f0c..1217fb5 100644
--- a/arch/arm/mach-sti/board-dt.c
+++ b/arch/arm/mach-sti/board-dt.c
@@ -7,9 +7,8 @@
* published by the Free Software Foundation.
*/

-#include <linux/clk-provider.h>
-#include <linux/clocksource.h>
#include <linux/irq.h>
+#include <linux/of_platform.h>
#include <asm/hardware/cache-l2x0.h>
#include <asm/mach/arch.h>

@@ -28,11 +27,10 @@ void __init stih41x_l2x0_init(void)
l2x0_of_init(aux_ctrl, L2X0_AUX_CTRL_MASK);
}

-static void __init stih41x_timer_init(void)
+static void __init stih41x_machine_init(void)
{
- of_clk_init(NULL);
- clocksource_of_init();
stih41x_l2x0_init();
+ of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
}

static const char *stih41x_dt_match[] __initdata = {
@@ -42,7 +40,7 @@ static const char *stih41x_dt_match[] __initdata = {
};

DT_MACHINE_START(STM, "STiH415/416 SoC with Flattened Device Tree")
- .init_time = stih41x_timer_init,
+ .init_machine = stih41x_machine_init,
.smp = smp_ops(sti_smp_ops),
.dt_compat = stih41x_dt_match,
MACHINE_END
--
1.7.2.5

2013-08-27 21:29:31

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 16/16] ARM: zynq: Don't call of_clk_init()

From: Soren Brinkmann <[email protected]>

of_clk_init() has been moved to be called from common code, therefore
remove it from Zynq's clock init routine. Since the Zynq's clock setup
routine relies on an initialized SLCR, zynq_slcr_init() is moved to
init_irq() instead.

Signed-off-by: Soren Brinkmann <[email protected]>
---
Cc: Michal Simek <[email protected]>
Cc: Mike Turquette <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-zynq/common.c | 9 ++++-----
drivers/clk/zynq/clkc.c | 4 +++-
2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 5f25256..9f79ebb 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -19,8 +19,7 @@
#include <linux/cpumask.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
-#include <linux/clk/zynq.h>
-#include <linux/clocksource.h>
+#include <linux/irqchip.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
@@ -58,10 +57,10 @@ static void __init zynq_init_machine(void)
of_platform_bus_probe(NULL, zynq_of_bus_ids, NULL);
}

-static void __init zynq_timer_init(void)
+static void __init zynq_init_irq(void)
{
+ irqchip_init();
zynq_slcr_init();
- clocksource_of_init();
}

static struct map_desc zynq_cortex_a9_scu_map __initdata = {
@@ -104,8 +103,8 @@ static const char * const zynq_dt_match[] = {
DT_MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform")
.smp = smp_ops(zynq_smp_ops),
.map_io = zynq_map_io,
+ .init_irq = zynq_init_irq,
.init_machine = zynq_init_machine,
- .init_time = zynq_timer_init,
.dt_compat = zynq_dt_match,
.restart = zynq_system_reset,
MACHINE_END
diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index 089d3e3..53b851e 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -206,6 +206,9 @@ static void __init zynq_clk_setup(struct device_node *np)

pr_info("Zynq clock init\n");

+ if (WARN_ON(!zynq_slcr_base_priv))
+ return;
+
/* get clock output names from DT */
for (i = 0; i < clk_max; i++) {
if (of_property_read_string_index(np, "clock-output-names",
@@ -532,5 +535,4 @@ CLK_OF_DECLARE(zynq_clkc, "xlnx,ps7-clkc", zynq_clk_setup);
void __init zynq_clock_init(void __iomem *slcr_base)
{
zynq_slcr_base_priv = slcr_base;
- of_clk_init(NULL);
}
--
1.7.2.5

2013-08-27 21:29:30

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 15/16] clk: vt8500: remove call to of_clk_init

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove it from corresponding drivers/clk code.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Mike Turquette <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/clk/clk-vt8500.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
index 82306f5..218d7ba 100644
--- a/drivers/clk/clk-vt8500.c
+++ b/drivers/clk/clk-vt8500.c
@@ -701,6 +701,4 @@ void __init vtwm_clk_init(void __iomem *base)
return;

pmc_base = base;
-
- of_clk_init(NULL);
}
--
1.7.2.5

2013-08-27 21:30:23

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 07/16] ARM: mvebu: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Changelog:
v1->v2:
- only remove of_clk_init from custom timer hook, further cleanup
will be carried out later (Reported by Gregory Clement)

Cc: Gregory Clement <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-mvebu/armada-370-xp.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
index 829b573..164c62b 100644
--- a/arch/arm/mach-mvebu/armada-370-xp.c
+++ b/arch/arm/mach-mvebu/armada-370-xp.c
@@ -14,7 +14,6 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/clk-provider.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/io.h>
@@ -36,7 +35,6 @@ static void __init armada_370_xp_map_io(void)

static void __init armada_370_xp_timer_and_clk_init(void)
{
- of_clk_init(NULL);
armada_370_xp_timer_init();
coherency_init();
BUG_ON(mvebu_mbus_dt_init());
--
1.7.2.5

2013-08-27 21:30:22

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 09/16] ARM: nspire: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-nspire/nspire.c | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-nspire/nspire.c b/arch/arm/mach-nspire/nspire.c
index 99e2609..4b2ed2e 100644
--- a/arch/arm/mach-nspire/nspire.c
+++ b/arch/arm/mach-nspire/nspire.c
@@ -14,11 +14,9 @@
#include <linux/of_platform.h>
#include <linux/irqchip.h>
#include <linux/irqchip/arm-vic.h>
-#include <linux/clk-provider.h>
#include <linux/clkdev.h>
#include <linux/amba/bus.h>
#include <linux/amba/clcd.h>
-#include <linux/clocksource.h>

#include <asm/mach/arch.h>
#include <asm/mach-types.h>
@@ -65,12 +63,6 @@ static void __init nspire_init(void)
nspire_auxdata, NULL);
}

-static void __init nspire_init_time(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static void nspire_restart(char mode, const char *cmd)
{
void __iomem *base = ioremap(NSPIRE_MISC_PHYS_BASE, SZ_4K);
@@ -83,7 +75,6 @@ static void nspire_restart(char mode, const char *cmd)
DT_MACHINE_START(NSPIRE, "TI-NSPIRE")
.dt_compat = nspire_dt_match,
.map_io = nspire_map_io,
- .init_time = nspire_init_time,
.init_machine = nspire_init,
.restart = nspire_restart,
MACHINE_END
--
1.7.2.5

2013-08-27 21:30:20

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 10/16] ARM: rockchip: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-rockchip/rockchip.c | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-rockchip/rockchip.c b/arch/arm/mach-rockchip/rockchip.c
index 724d2d8..82c0b07 100644
--- a/arch/arm/mach-rockchip/rockchip.c
+++ b/arch/arm/mach-rockchip/rockchip.c
@@ -19,18 +19,10 @@
#include <linux/init.h>
#include <linux/of_platform.h>
#include <linux/irqchip.h>
-#include <linux/dw_apb_timer.h>
-#include <linux/clk-provider.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/hardware/cache-l2x0.h>

-static void __init rockchip_timer_init(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static void __init rockchip_dt_init(void)
{
l2x0_of_init(0, ~0UL);
@@ -47,6 +39,5 @@ static const char * const rockchip_board_dt_compat[] = {

DT_MACHINE_START(ROCKCHIP_DT, "Rockchip Cortex-A9 (Device Tree)")
.init_machine = rockchip_dt_init,
- .init_time = rockchip_timer_init,
.dt_compat = rockchip_board_dt_compat,
MACHINE_END
--
1.7.2.5

2013-08-27 21:30:18

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 08/16] ARM: mxs: remove custom .init_time hook

This patch converts clk-imx2[38] clocksource_of_init compatible init
associated with fsl,imx2[38]-clkctrl. With arch/arm calling
of_clk_init(NULL) from time_init(), we can now also remove custom
.init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Shawn Guo <[email protected]>
Cc: Mike Turquette <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-mxs/mach-mxs.c | 13 -------------
drivers/clk/mxs/clk-imx23.c | 16 +++++++---------
drivers/clk/mxs/clk-imx28.c | 16 +++++++---------
include/linux/clk/mxs.h | 2 --
4 files changed, 14 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 98f6e2a..cc511a4 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -13,8 +13,6 @@
#include <linux/clk.h>
#include <linux/clk/mxs.h>
#include <linux/clkdev.h>
-#include <linux/clocksource.h>
-#include <linux/clk-provider.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/gpio.h>
@@ -490,16 +488,6 @@ static void mxs_restart(enum reboot_mode mode, const char *cmd)
soft_restart(0);
}

-static void __init mxs_timer_init(void)
-{
- if (of_machine_is_compatible("fsl,imx23"))
- mx23_clocks_init();
- else
- mx28_clocks_init();
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static const char *mxs_dt_compat[] __initdata = {
"fsl,imx28",
"fsl,imx23",
@@ -508,7 +496,6 @@ static const char *mxs_dt_compat[] __initdata = {

DT_MACHINE_START(MXS, "Freescale MXS (Device Tree)")
.handle_irq = icoll_handle_irq,
- .init_time = mxs_timer_init,
.init_machine = mxs_machine_init,
.init_late = mxs_pm_init,
.dt_compat = mxs_dt_compat,
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
index c396fe3..7eb1d1a 100644
--- a/drivers/clk/mxs/clk-imx23.c
+++ b/drivers/clk/mxs/clk-imx23.c
@@ -12,6 +12,7 @@
#include <linux/clk.h>
#include <linux/clk/mxs.h>
#include <linux/clkdev.h>
+#include <linux/clk-provider.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/io.h>
@@ -100,19 +101,17 @@ static enum imx23_clk clks_init_on[] __initdata = {
cpu, hbus, xbus, emi, uart,
};

-int __init mx23_clocks_init(void)
+static void __init mx23_clocks_init(struct device_node *np)
{
- struct device_node *np;
u32 i;

+ clkctrl = of_iomap(np, 0);
+ WARN_ON(!clkctrl);
+
np = of_find_compatible_node(NULL, NULL, "fsl,imx23-digctl");
digctrl = of_iomap(np, 0);
WARN_ON(!digctrl);

- np = of_find_compatible_node(NULL, NULL, "fsl,imx23-clkctrl");
- clkctrl = of_iomap(np, 0);
- WARN_ON(!clkctrl);
-
clk_misc_init();

clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
@@ -162,7 +161,7 @@ int __init mx23_clocks_init(void)
if (IS_ERR(clks[i])) {
pr_err("i.MX23 clk %d: register failed with %ld\n",
i, PTR_ERR(clks[i]));
- return PTR_ERR(clks[i]);
+ return;
}

clk_data.clks = clks;
@@ -171,6 +170,5 @@ int __init mx23_clocks_init(void)

for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
clk_prepare_enable(clks[clks_init_on[i]]);
-
- return 0;
}
+CLK_OF_DECLARE(imx23_clkctrl, "fsl,imx23-clkctrl", mx23_clocks_init);
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
index 4faf0af..12d3f3d 100644
--- a/drivers/clk/mxs/clk-imx28.c
+++ b/drivers/clk/mxs/clk-imx28.c
@@ -12,6 +12,7 @@
#include <linux/clk.h>
#include <linux/clk/mxs.h>
#include <linux/clkdev.h>
+#include <linux/clk-provider.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/io.h>
@@ -154,19 +155,17 @@ static enum imx28_clk clks_init_on[] __initdata = {
cpu, hbus, xbus, emi, uart,
};

-int __init mx28_clocks_init(void)
+static void __init mx28_clocks_init(struct device_node *np)
{
- struct device_node *np;
u32 i;

+ clkctrl = of_iomap(np, 0);
+ WARN_ON(!clkctrl);
+
np = of_find_compatible_node(NULL, NULL, "fsl,imx28-digctl");
digctrl = of_iomap(np, 0);
WARN_ON(!digctrl);

- np = of_find_compatible_node(NULL, NULL, "fsl,imx28-clkctrl");
- clkctrl = of_iomap(np, 0);
- WARN_ON(!clkctrl);
-
clk_misc_init();

clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
@@ -239,7 +238,7 @@ int __init mx28_clocks_init(void)
if (IS_ERR(clks[i])) {
pr_err("i.MX28 clk %d: register failed with %ld\n",
i, PTR_ERR(clks[i]));
- return PTR_ERR(clks[i]);
+ return;
}

clk_data.clks = clks;
@@ -250,6 +249,5 @@ int __init mx28_clocks_init(void)

for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
clk_prepare_enable(clks[clks_init_on[i]]);
-
- return 0;
}
+CLK_OF_DECLARE(imx28_clkctrl, "fsl,imx28-clkctrl", mx28_clocks_init);
diff --git a/include/linux/clk/mxs.h b/include/linux/clk/mxs.h
index 90c30dc..5138a90 100644
--- a/include/linux/clk/mxs.h
+++ b/include/linux/clk/mxs.h
@@ -9,8 +9,6 @@
#ifndef __LINUX_CLK_MXS_H
#define __LINUX_CLK_MXS_H

-int mx23_clocks_init(void);
-int mx28_clocks_init(void);
int mxs_saif_clkmux_select(unsigned int clkmux);

#endif
--
1.7.2.5

2013-08-27 21:31:44

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 05/16] ARM: imx: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Changelog:
v1->v2:
- added missing CLK_OF_DECLARE for imx51 and imx53 (Reported by Sascha Hauer)
mx53_clocks_init can be converted as it is used DT only, mx51_clocks_init
still is used by non-DT.

Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-imx/clk-imx51-imx53.c | 29 ++++++++++-------------------
arch/arm/mach-imx/common.h | 4 ----
arch/arm/mach-imx/imx51-dt.c | 6 ------
arch/arm/mach-imx/mach-imx53.c | 6 ------
arch/arm/mach-imx/mach-imx6q.c | 14 +++-----------
arch/arm/mach-imx/mach-imx6sl.c | 7 -------
arch/arm/mach-imx/mach-vf610.c | 9 ---------
7 files changed, 13 insertions(+), 62 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
index 1a56a33..1b796db 100644
--- a/arch/arm/mach-imx/clk-imx51-imx53.c
+++ b/arch/arm/mach-imx/clk-imx51-imx53.c
@@ -11,6 +11,7 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/clkdev.h>
+#include <linux/clk-provider.h>
#include <linux/of.h>
#include <linux/err.h>

@@ -131,8 +132,6 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
{
int i;

- of_clk_init(NULL);
-
clk[dummy] = imx_clk_fixed("dummy", 0);
clk[ckil] = imx_obtain_fixed_clock("ckil", rate_ckil);
clk[osc] = imx_obtain_fixed_clock("osc", rate_osc);
@@ -465,12 +464,16 @@ int __init mx51_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
return 0;
}

-int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
- unsigned long rate_ckih1, unsigned long rate_ckih2)
+static void __init mx51_clocks_init_dt(struct device_node *np)
+{
+ mx51_clocks_init(0, 0, 0, 0);
+}
+CLK_OF_DECLARE(imx51_ccm, "fsl,imx51-ccm", mx51_clocks_init_dt);
+
+static void __init mx53_clocks_init(struct device_node *np)
{
int i;
unsigned long r;
- struct device_node *np;

clk[pll1_sw] = imx_clk_pllv2("pll1_sw", "osc", MX53_DPLL1_BASE);
clk[pll2_sw] = imx_clk_pllv2("pll2_sw", "osc", MX53_DPLL2_BASE);
@@ -529,12 +532,11 @@ int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
pr_err("i.MX53 clk %d: register failed with %ld\n",
i, PTR_ERR(clk[i]));

- np = of_find_compatible_node(NULL, NULL, "fsl,imx53-ccm");
clk_data.clks = clk;
clk_data.clk_num = ARRAY_SIZE(clk);
of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);

- mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2);
+ mx5_clocks_common_init(0, 0, 0, 0);

clk_register_clkdev(clk[vpu_gate], NULL, "imx53-vpu.0");
clk_register_clkdev(clk[i2c3_gate], NULL, "imx21-i2c.2");
@@ -566,16 +568,5 @@ int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,

r = clk_round_rate(clk[usboh3_per_gate], 54000000);
clk_set_rate(clk[usboh3_per_gate], r);
-
- return 0;
-}
-
-int __init mx51_clocks_init_dt(void)
-{
- return mx51_clocks_init(0, 0, 0, 0);
-}
-
-int __init mx53_clocks_init_dt(void)
-{
- return mx53_clocks_init(0, 0, 0, 0);
}
+CLK_OF_DECLARE(imx53_ccm, "fsl,imx53-ccm", mx53_clocks_init);
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index 4517fd7..28e8ca0 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -63,13 +63,9 @@ extern int mx31_clocks_init(unsigned long fref);
extern int mx35_clocks_init(void);
extern int mx51_clocks_init(unsigned long ckil, unsigned long osc,
unsigned long ckih1, unsigned long ckih2);
-extern int mx53_clocks_init(unsigned long ckil, unsigned long osc,
- unsigned long ckih1, unsigned long ckih2);
extern int mx25_clocks_init_dt(void);
extern int mx27_clocks_init_dt(void);
extern int mx31_clocks_init_dt(void);
-extern int mx51_clocks_init_dt(void);
-extern int mx53_clocks_init_dt(void);
extern struct platform_device *mxc_register_gpio(char *name, int id,
resource_size_t iobase, resource_size_t iosize, int irq, int irq_high);
extern void mxc_set_cpu_type(unsigned int type);
diff --git a/arch/arm/mach-imx/imx51-dt.c b/arch/arm/mach-imx/imx51-dt.c
index 53e43e5..bece8a6 100644
--- a/arch/arm/mach-imx/imx51-dt.c
+++ b/arch/arm/mach-imx/imx51-dt.c
@@ -34,17 +34,11 @@ static const char *imx51_dt_board_compat[] __initdata = {
NULL
};

-static void __init imx51_timer_init(void)
-{
- mx51_clocks_init_dt();
-}
-
DT_MACHINE_START(IMX51_DT, "Freescale i.MX51 (Device Tree Support)")
.map_io = mx51_map_io,
.init_early = imx51_init_early,
.init_irq = mx51_init_irq,
.handle_irq = imx51_handle_irq,
- .init_time = imx51_timer_init,
.init_machine = imx51_dt_init,
.init_late = imx51_init_late,
.dt_compat = imx51_dt_board_compat,
diff --git a/arch/arm/mach-imx/mach-imx53.c b/arch/arm/mach-imx/mach-imx53.c
index 98c5894..c9c4d8d 100644
--- a/arch/arm/mach-imx/mach-imx53.c
+++ b/arch/arm/mach-imx/mach-imx53.c
@@ -36,17 +36,11 @@ static const char *imx53_dt_board_compat[] __initdata = {
NULL
};

-static void __init imx53_timer_init(void)
-{
- mx53_clocks_init_dt();
-}
-
DT_MACHINE_START(IMX53_DT, "Freescale i.MX53 (Device Tree Support)")
.map_io = mx53_map_io,
.init_early = imx53_init_early,
.init_irq = mx53_init_irq,
.handle_irq = imx53_handle_irq,
- .init_time = imx53_timer_init,
.init_machine = imx53_dt_init,
.init_late = imx53_init_late,
.dt_compat = imx53_dt_board_compat,
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index b605098..ad71738 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -11,9 +11,7 @@
*/

#include <linux/clk.h>
-#include <linux/clk-provider.h>
#include <linux/clkdev.h>
-#include <linux/clocksource.h>
#include <linux/cpu.h>
#include <linux/delay.h>
#include <linux/export.h>
@@ -192,6 +190,9 @@ static void __init imx6q_1588_init(void)

static void __init imx6q_init_machine(void)
{
+ imx_print_silicon_rev(cpu_is_imx6dl() ? "i.MX6DL" : "i.MX6Q",
+ imx6q_revision());
+
imx6q_enet_phy_init();

of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
@@ -289,14 +290,6 @@ static void __init imx6q_init_irq(void)
irqchip_init();
}

-static void __init imx6q_timer_init(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
- imx_print_silicon_rev(cpu_is_imx6dl() ? "i.MX6DL" : "i.MX6Q",
- imx6q_revision());
-}
-
static const char *imx6q_dt_compat[] __initdata = {
"fsl,imx6dl",
"fsl,imx6q",
@@ -307,7 +300,6 @@ DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad/DualLite (Device Tree)")
.smp = smp_ops(imx_smp_ops),
.map_io = imx6q_map_io,
.init_irq = imx6q_init_irq,
- .init_time = imx6q_timer_init,
.init_machine = imx6q_init_machine,
.init_late = imx6q_init_late,
.dt_compat = imx6q_dt_compat,
diff --git a/arch/arm/mach-imx/mach-imx6sl.c b/arch/arm/mach-imx/mach-imx6sl.c
index 0d75dc5..c70bd7c 100644
--- a/arch/arm/mach-imx/mach-imx6sl.c
+++ b/arch/arm/mach-imx/mach-imx6sl.c
@@ -7,7 +7,6 @@
*
*/

-#include <linux/clk-provider.h>
#include <linux/irqchip.h>
#include <linux/of.h>
#include <linux/of_platform.h>
@@ -31,11 +30,6 @@ static void __init imx6sl_init_irq(void)
irqchip_init();
}

-static void __init imx6sl_timer_init(void)
-{
- of_clk_init(NULL);
-}
-
static const char *imx6sl_dt_compat[] __initdata = {
"fsl,imx6sl",
NULL,
@@ -44,7 +38,6 @@ static const char *imx6sl_dt_compat[] __initdata = {
DT_MACHINE_START(IMX6SL, "Freescale i.MX6 SoloLite (Device Tree)")
.map_io = debug_ll_io_init,
.init_irq = imx6sl_init_irq,
- .init_time = imx6sl_timer_init,
.init_machine = imx6sl_init_machine,
.dt_compat = imx6sl_dt_compat,
.restart = mxc_restart,
diff --git a/arch/arm/mach-imx/mach-vf610.c b/arch/arm/mach-imx/mach-vf610.c
index 816991d..af0cb8a 100644
--- a/arch/arm/mach-imx/mach-vf610.c
+++ b/arch/arm/mach-imx/mach-vf610.c
@@ -8,9 +8,7 @@
*/

#include <linux/of_platform.h>
-#include <linux/clocksource.h>
#include <linux/irqchip.h>
-#include <linux/clk-provider.h>
#include <asm/mach/arch.h>
#include <asm/hardware/cache-l2x0.h>

@@ -28,12 +26,6 @@ static void __init vf610_init_irq(void)
irqchip_init();
}

-static void __init vf610_init_time(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static const char *vf610_dt_compat[] __initdata = {
"fsl,vf610",
NULL,
@@ -41,7 +33,6 @@ static const char *vf610_dt_compat[] __initdata = {

DT_MACHINE_START(VYBRID_VF610, "Freescale Vybrid VF610 (Device Tree)")
.init_irq = vf610_init_irq,
- .init_time = vf610_init_time,
.init_machine = vf610_init_machine,
.dt_compat = vf610_dt_compat,
.restart = mxc_restart,
--
1.7.2.5

2013-08-27 21:31:42

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 06/16] ARM: kirkwood: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Jason Cooper <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-kirkwood/board-dt.c | 8 --------
1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index 82d3ad8..a32a3e5 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -15,7 +15,6 @@
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/clk-provider.h>
-#include <linux/clocksource.h>
#include <linux/dma-mapping.h>
#include <linux/irqchip.h>
#include <linux/kexec.h>
@@ -66,12 +65,6 @@ static void __init kirkwood_legacy_clk_init(void)
clk_prepare_enable(clk);
}

-static void __init kirkwood_dt_time_init(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static void __init kirkwood_dt_init_early(void)
{
mvebu_mbus_init("marvell,kirkwood-mbus",
@@ -122,7 +115,6 @@ DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
/* Maintainer: Jason Cooper <[email protected]> */
.map_io = kirkwood_map_io,
.init_early = kirkwood_dt_init_early,
- .init_time = kirkwood_dt_time_init,
.init_machine = kirkwood_dt_init,
.restart = kirkwood_restart,
.dt_compat = kirkwood_dt_board_compat,
--
1.7.2.5

2013-08-27 21:28:23

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 02/16] ARM: dove: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks. While at it, also remove some obsolete
includes.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Jason Cooper <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-dove/board-dt.c | 17 +----------------
1 files changed, 1 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-dove/board-dt.c b/arch/arm/mach-dove/board-dt.c
index 9a116d7..b527728 100644
--- a/arch/arm/mach-dove/board-dt.c
+++ b/arch/arm/mach-dove/board-dt.c
@@ -9,26 +9,12 @@
*/

#include <linux/init.h>
-#include <linux/clk-provider.h>
-#include <linux/clocksource.h>
-#include <linux/irqchip.h>
-#include <linux/of.h>
+#include <linux/mbus.h>
#include <linux/of_platform.h>
-#include <linux/platform_data/usb-ehci-orion.h>
#include <asm/hardware/cache-tauros2.h>
#include <asm/mach/arch.h>
-#include <mach/dove.h>
-#include <mach/pm.h>
-#include <plat/common.h>
-#include <plat/irq.h>
#include "common.h"

-static void __init dove_dt_time_init(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
static void __init dove_dt_init(void)
{
pr_info("Dove 88AP510 SoC\n");
@@ -47,7 +33,6 @@ static const char * const dove_dt_board_compat[] = {

DT_MACHINE_START(DOVE_DT, "Marvell Dove (Flattened Device Tree)")
.map_io = dove_map_io,
- .init_time = dove_dt_time_init,
.init_machine = dove_dt_init,
.restart = dove_restart,
.dt_compat = dove_dt_board_compat,
--
1.7.2.5

2013-08-27 21:32:21

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 03/16] ARM: exynos: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
---
Cc: Kukjin Kim <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-exynos/common.c | 7 -------
arch/arm/mach-exynos/common.h | 1 -
arch/arm/mach-exynos/mach-exynos4-dt.c | 1 -
arch/arm/mach-exynos/mach-exynos5-dt.c | 1 -
4 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-exynos/common.c b/arch/arm/mach-exynos/common.c
index ba95e5d..587625b 100644
--- a/arch/arm/mach-exynos/common.c
+++ b/arch/arm/mach-exynos/common.c
@@ -27,7 +27,6 @@
#include <linux/irqdomain.h>
#include <linux/of_address.h>
#include <linux/clocksource.h>
-#include <linux/clk-provider.h>
#include <linux/irqchip/arm-gic.h>
#include <linux/irqchip/chained_irq.h>

@@ -367,12 +366,6 @@ static void __init exynos5_map_io(void)
iotable_init(exynos5250_iodesc, ARRAY_SIZE(exynos5250_iodesc));
}

-void __init exynos_init_time(void)
-{
- of_clk_init(NULL);
- clocksource_of_init();
-}
-
struct bus_type exynos_subsys = {
.name = "exynos-core",
.dev_name = "exynos-core",
diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index 8646a14..f0fa205 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -16,7 +16,6 @@
#include <linux/of.h>

void mct_init(void __iomem *base, int irq_g0, int irq_l0, int irq_l1);
-void exynos_init_time(void);

struct map_desc;
void exynos_init_io(void);
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c b/arch/arm/mach-exynos/mach-exynos4-dt.c
index 0099c6c..7458dd4 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -54,7 +54,6 @@ DT_MACHINE_START(EXYNOS4210_DT, "Samsung Exynos4 (Flattened Device Tree)")
.init_early = exynos_firmware_init,
.init_machine = exynos4_dt_machine_init,
.init_late = exynos_init_late,
- .init_time = exynos_init_time,
.dt_compat = exynos4_dt_compat,
.restart = exynos4_restart,
.reserve = exynos4_reserve,
diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
index f874b77..8829da2 100644
--- a/arch/arm/mach-exynos/mach-exynos5-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
@@ -76,7 +76,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
.map_io = exynos_init_io,
.init_machine = exynos5_dt_machine_init,
.init_late = exynos_init_late,
- .init_time = exynos_init_time,
.dt_compat = exynos5_dt_compat,
.restart = exynos5_restart,
.reserve = exynos5_reserve,
--
1.7.2.5

2013-08-27 21:32:41

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 00/16] ARM: provide common arch init for DT clocks

This RFC converts arch/arm to provide a common arch init for DT clock
providers. Currently, the call to of_clk_init(NULL) to initialize DT
clock providers is spread among several mach-dirs. Since most machs
require DT clocks initialized before timers, no initcall can be used.

By adding of_clk_init(NULL) to ARM time_init(), we can remove all
mach-specific .init_time hooks that basically called of_clk_init before
starting timers.

Based on the previous version, this one now includes patches provided by
Stephen Warren for mach-tegra and Soren Brinkmann for mach-zynq.

With mach-tegra now requiring clocks as late as the other machs, the
patch to protect of_clk_init() from being called twice, has been dropped.

The RFCv2 is based on next-20130827 and has been compile tested for
multi_v7_defconfig and mach-dove. All single patches have also been sent
to the respective maintainers and corresponding mailing lists.

Before going for a real patch set after v3.11 drops, I prefer to have
Tested-by or Acked-by for at least mach-imx, mach-mxs, mach-sti, and
mach-vexpress. Others are trivial, prepared by maintainers (mach-tegra
and mach-zynq), or have already been Acked-by (mach-highbank).

Also, I'd like to know if the patches should be grouped by mach- or
rather been split into mach- preparation and .init_time removal.

Sebastian Hesselbarth (14):
ARM: call clk_of_init from time_init
ARM: dove: remove custom .init_time hook
ARM: exynos: remove custom .init_time hook
ARM: highbank: remove custom .init_time hook
ARM: imx: remove custom .init_time hook
ARM: kirkwood: remove custom .init_time hook
ARM: mvebu: remove custom .init_time hook
ARM: mxs: remove custom .init_time hook
ARM: nspire: remove custom .init_time hook
ARM: rockchip: remove custom .init_time hook
ARM: socfpga: remove call to of_clk_init
ARM: sti: remove custom .init_time hook
ARM: vexpress: remove custom .init_time hook
clk: vt8500: remove call to of_clk_init

Soren Brinkmann (1):
ARM: zynq: Don't call of_clk_init()

Stephen Warren (1):
ARM: tegra: split tegra_pmc_init() in two

arch/arm/kernel/time.c | 24 +++++++++++-------
arch/arm/mach-dove/board-dt.c | 17 +------------
arch/arm/mach-exynos/common.c | 7 -----
arch/arm/mach-exynos/common.h | 1 -
arch/arm/mach-exynos/mach-exynos4-dt.c | 1 -
arch/arm/mach-exynos/mach-exynos5-dt.c | 1 -
arch/arm/mach-highbank/highbank.c | 23 +++++------------
arch/arm/mach-imx/clk-imx51-imx53.c | 29 +++++++--------------
arch/arm/mach-imx/common.h | 4 ---
arch/arm/mach-imx/imx51-dt.c | 6 ----
arch/arm/mach-imx/mach-imx53.c | 6 ----
arch/arm/mach-imx/mach-imx6q.c | 14 ++--------
arch/arm/mach-imx/mach-imx6sl.c | 7 -----
arch/arm/mach-imx/mach-vf610.c | 9 -------
arch/arm/mach-kirkwood/board-dt.c | 8 ------
arch/arm/mach-mvebu/armada-370-xp.c | 2 -
arch/arm/mach-mxs/mach-mxs.c | 13 ----------
arch/arm/mach-nspire/nspire.c | 9 -------
arch/arm/mach-rockchip/rockchip.c | 9 -------
arch/arm/mach-socfpga/socfpga.c | 2 -
arch/arm/mach-sti/board-dt.c | 10 +++----
arch/arm/mach-tegra/common.c | 4 +--
arch/arm/mach-tegra/pmc.c | 41 +++++++++++++++++--------------
arch/arm/mach-tegra/pmc.h | 1 +
arch/arm/mach-tegra/tegra.c | 5 ++-
arch/arm/mach-vexpress/v2m.c | 14 +----------
arch/arm/mach-zynq/common.c | 9 +++----
drivers/clk/clk-highbank.c | 10 +++++--
drivers/clk/clk-vt8500.c | 2 -
drivers/clk/mxs/clk-imx23.c | 16 +++++-------
drivers/clk/mxs/clk-imx28.c | 16 +++++-------
drivers/clk/zynq/clkc.c | 4 ++-
include/linux/clk/mxs.h | 2 -
33 files changed, 95 insertions(+), 231 deletions(-)

---
Cc: Mike Turquette <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--
1.7.2.5

2013-08-27 21:32:40

by Sebastian Hesselbarth

[permalink] [raw]
Subject: [PATCH RFC v2 04/16] ARM: highbank: remove custom .init_time hook

With arch/arm calling of_clk_init(NULL) from time_init(), we can now
remove custom .init_time hooks. Highbank clock provider need a reference
to system registers, as a workaround current clk driver maps those
independent of arch code now.

Signed-off-by: Sebastian Hesselbarth <[email protected]>
Acked-by: Rob Herring <[email protected]>
---
Cc: Rob Herring <[email protected]>
Cc: Mike Turquette <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/mach-highbank/highbank.c | 23 +++++++----------------
drivers/clk/clk-highbank.c | 10 +++++++---
2 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 8881579..fa36d14 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -27,7 +27,6 @@
#include <linux/of_address.h>
#include <linux/smp.h>
#include <linux/amba/bus.h>
-#include <linux/clk-provider.h>

#include <asm/cacheflush.h>
#include <asm/cputype.h>
@@ -88,20 +87,6 @@ static void __init highbank_init_irq(void)
#endif
}

-static void __init highbank_timer_init(void)
-{
- struct device_node *np;
-
- /* Map system registers */
- np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
- sregs_base = of_iomap(np, 0);
- WARN_ON(!sregs_base);
-
- of_clk_init(NULL);
-
- clocksource_of_init();
-}
-
static void highbank_power_off(void)
{
highbank_set_pwr_shutdown();
@@ -160,6 +145,13 @@ static struct notifier_block highbank_platform_nb = {

static void __init highbank_init(void)
{
+ struct device_node *np;
+
+ /* Map system registers */
+ np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
+ sregs_base = of_iomap(np, 0);
+ WARN_ON(!sregs_base);
+
pm_power_off = highbank_power_off;
highbank_pm_init();

@@ -178,7 +170,6 @@ static const char *highbank_match[] __initconst = {
DT_MACHINE_START(HIGHBANK, "Highbank")
.smp = smp_ops(highbank_smp_ops),
.init_irq = highbank_init_irq,
- .init_time = highbank_timer_init,
.init_machine = highbank_init,
.dt_compat = highbank_match,
.restart = highbank_restart,
diff --git a/drivers/clk/clk-highbank.c b/drivers/clk/clk-highbank.c
index 2e08cb0..2e7e9d9 100644
--- a/drivers/clk/clk-highbank.c
+++ b/drivers/clk/clk-highbank.c
@@ -20,8 +20,7 @@
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/of.h>
-
-extern void __iomem *sregs_base;
+#include <linux/of_address.h>

#define HB_PLL_LOCK_500 0x20000000
#define HB_PLL_LOCK 0x10000000
@@ -280,6 +279,7 @@ static __init struct clk *hb_clk_init(struct device_node *node, const struct clk
const char *clk_name = node->name;
const char *parent_name;
struct clk_init_data init;
+ struct device_node *srnp;
int rc;

rc = of_property_read_u32(node, "reg", &reg);
@@ -290,7 +290,11 @@ static __init struct clk *hb_clk_init(struct device_node *node, const struct clk
if (WARN_ON(!hb_clk))
return NULL;

- hb_clk->reg = sregs_base + reg;
+ /* Map system registers */
+ srnp = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
+ hb_clk->reg = of_iomap(srnp, 0);
+ BUG_ON(!hb_clk->reg);
+ hb_clk->reg += reg;

of_property_read_string(node, "clock-output-names", &clk_name);

--
1.7.2.5

2013-08-27 21:59:45

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH RFC v2 13/16] ARM: tegra: split tegra_pmc_init() in two

On 08/27/2013 03:28 PM, Sebastian Hesselbarth wrote:
> From: Stephen Warren <[email protected]>
>
> Tegra's board file currently initializes clocks much earlier than those
> for most other ARM SoCs. The reason is:
>
> * The PMC HW block is involved in the path of some interrupts (i.e. it
> inverts, or not, the IRQ input pin dedicated to the PMIC).
>
> * So, that part of the PMC must be initialized early so that the IRQ
> polarity is correct.
>
> * The PMC initialization is currently monolithic, and the PMC has some
> clock inputs, so the init routine ends up calling of_clk_get_by_name(),
> and hence clocks must be set up early too.
>
> In order to defer clock initialization to the more typical location,
> split out the portions of tegra_pmc_init() that are truly IRQ-related
> into a separate tegra_pmc_init_irq(), which can be called from the
> machine descriptor's .init_irq() function, and defer the rest until
> the machine descriptor's .init_machine() function. With arch/arm calling
> of_clk_init(NULL) from time_init() this also allows the removal of
> .init_time() hook.
>
> Signed-off-by: Stephen Warren <[email protected]>
> ---
> Changelog:
> v1->v2:
> - took Stephen Warren's patch provided to separate Tegra's pmc_init
> - sqashed in .init_time removal and reworded patch text

I think it'd be better to keep the 2 patches separate so the two logical
changes are in different patches. I suppose it isn't a huge deal though.

Either way, on this patch, your S-o-b line is missing above.

2013-08-27 22:09:31

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [PATCH RFC v2 13/16] ARM: tegra: split tegra_pmc_init() in two

On 08/27/13 23:59, Stephen Warren wrote:
> On 08/27/2013 03:28 PM, Sebastian Hesselbarth wrote:
>> From: Stephen Warren <[email protected]>
>>
>> Tegra's board file currently initializes clocks much earlier than those
>> for most other ARM SoCs. The reason is:
>>
>> * The PMC HW block is involved in the path of some interrupts (i.e. it
>> inverts, or not, the IRQ input pin dedicated to the PMIC).
>>
>> * So, that part of the PMC must be initialized early so that the IRQ
>> polarity is correct.
>>
>> * The PMC initialization is currently monolithic, and the PMC has some
>> clock inputs, so the init routine ends up calling of_clk_get_by_name(),
>> and hence clocks must be set up early too.
>>
>> In order to defer clock initialization to the more typical location,
>> split out the portions of tegra_pmc_init() that are truly IRQ-related
>> into a separate tegra_pmc_init_irq(), which can be called from the
>> machine descriptor's .init_irq() function, and defer the rest until
>> the machine descriptor's .init_machine() function. With arch/arm calling
>> of_clk_init(NULL) from time_init() this also allows the removal of
>> .init_time() hook.
>>
>> Signed-off-by: Stephen Warren <[email protected]>
>> ---
>> Changelog:
>> v1->v2:
>> - took Stephen Warren's patch provided to separate Tegra's pmc_init
>> - sqashed in .init_time removal and reworded patch text
>
> I think it'd be better to keep the 2 patches separate so the two logical
> changes are in different patches. I suppose it isn't a huge deal though.
>
> Either way, on this patch, your S-o-b line is missing above.

Stephen,

I was already wondering here, if I should separate the patches into
preparation and actual removal. I put that question into the cover
letter and removed it from this patch text ;)

As you suggest to use preparation/removal, I will take that approach
for the final patch set. Will take you original unmodified patch then.

Sebastian

2013-08-27 22:19:53

by Soren Brinkmann

[permalink] [raw]
Subject: Re: [PATCH RFC v2 01/16] ARM: call clk_of_init from time_init

On Tue, Aug 27, 2013 at 11:27:55PM +0200, Sebastian Hesselbarth wrote:
> Most DT ARM machs require common clock providers initialized before timers.
> Currently, arch/arm machs use .init_time to call clk_of_init right before
> clocksource_of_init. This prevents to remove that hook and use the default
> hook instead. clk_of_init is safe to call for non-DT platforms, so add
> the call to ARM arch time_init by default. While at it, also reorder includes
> alphabetically.
>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>
> ---
> Changelog:
> v1->v2:
> - reorder includes alphabetically
>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/arm/kernel/time.c | 24 ++++++++++++++----------
> 1 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
> index 98aee32..dd1028e 100644
> --- a/arch/arm/kernel/time.c
> +++ b/arch/arm/kernel/time.c
> @@ -11,25 +11,26 @@
[ ... ]
> void __init time_init(void)
> {
> + /* initalize common clocks before timers */
> + of_clk_init(NULL);
> +
> if (machine_desc->init_time)
> machine_desc->init_time();
> else

This forces zynq to move some initialization our clock code relies on to
init_irq(). Also, the current code already takes an approach of
doing either common init or machine specific init.
I think it might be better to move the call to of_clk_init() down into
the else branch of the if-else.
Though, this probably contradicts the purpose of the whole series.

Sören

2013-08-27 22:58:47

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [PATCH RFC v2 01/16] ARM: call clk_of_init from time_init

On 08/28/13 00:19, Sören Brinkmann wrote:
> On Tue, Aug 27, 2013 at 11:27:55PM +0200, Sebastian Hesselbarth wrote:
>> Most DT ARM machs require common clock providers initialized before timers.
>> Currently, arch/arm machs use .init_time to call clk_of_init right before
>> clocksource_of_init. This prevents to remove that hook and use the default
>> hook instead. clk_of_init is safe to call for non-DT platforms, so add
>> the call to ARM arch time_init by default. While at it, also reorder includes
>> alphabetically.
>>
>> Signed-off-by: Sebastian Hesselbarth <[email protected]>
>> ---
>> Changelog:
>> v1->v2:
>> - reorder includes alphabetically
>>
>> Cc: Russell King <[email protected]>
>> Cc: Arnd Bergmann <[email protected]>
>> Cc: [email protected]
>> Cc: [email protected]
>> Cc: [email protected]
>> Cc: [email protected]
>> Cc: [email protected]
>> ---
>> arch/arm/kernel/time.c | 24 ++++++++++++++----------
>> 1 files changed, 14 insertions(+), 10 deletions(-)
>>
>> diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
>> index 98aee32..dd1028e 100644
>> --- a/arch/arm/kernel/time.c
>> +++ b/arch/arm/kernel/time.c
>> @@ -11,25 +11,26 @@
> [ ... ]
>> void __init time_init(void)
>> {
>> + /* initalize common clocks before timers */
>> + of_clk_init(NULL);
>> +
>> if (machine_desc->init_time)
>> machine_desc->init_time();
>> else
>
> This forces zynq to move some initialization our clock code relies on to
> init_irq(). Also, the current code already takes an approach of
> doing either common init or machine specific init.

Soeren,

you know that patch 16/16 takes care of zynq's clock init?

It's your own patch you provided from the last RFC. Looking at it, it
moves zynq_sclr_init() to .init_irq and removes the call to
of_clk_init() from zynq_clock_init() which is called by
zynq_sclr_init().

Isn't that solving the above issues for mach-zynq?

> I think it might be better to move the call to of_clk_init() down into
> the else branch of the if-else.

Possibly, yes. But we could also unconditionally call of_clk_init() at
the beginning of time_init() and call clocksource_of_init() at the end.
That will make .init_time() to some fixup hook between initialization of
clocks and timers.

> Though, this probably contradicts the purpose of the whole series.

Hmm, the purpose was to allow most platforms to remove a custom
.init_time hook only calling of_clk_init() and clocksource_of_init().

If we move of_clk_init() above also in the else-branch the purpose
is still met.

Sebastian

2013-08-27 23:13:34

by Mike Turquette

[permalink] [raw]
Subject: Re: [PATCH RFC v2 04/16] ARM: highbank: remove custom .init_time hook

Quoting Sebastian Hesselbarth (2013-08-27 14:27:58)
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove custom .init_time hooks. Highbank clock provider need a reference
> to system registers, as a workaround current clk driver maps those
> independent of arch code now.
>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>
> Acked-by: Rob Herring <[email protected]>

Acked-by: Mike Turquette <[email protected]>

> ---
> Cc: Rob Herring <[email protected]>
> Cc: Mike Turquette <[email protected]>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/arm/mach-highbank/highbank.c | 23 +++++++----------------
> drivers/clk/clk-highbank.c | 10 +++++++---
> 2 files changed, 14 insertions(+), 19 deletions(-)
>
> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
> index 8881579..fa36d14 100644
> --- a/arch/arm/mach-highbank/highbank.c
> +++ b/arch/arm/mach-highbank/highbank.c
> @@ -27,7 +27,6 @@
> #include <linux/of_address.h>
> #include <linux/smp.h>
> #include <linux/amba/bus.h>
> -#include <linux/clk-provider.h>
>
> #include <asm/cacheflush.h>
> #include <asm/cputype.h>
> @@ -88,20 +87,6 @@ static void __init highbank_init_irq(void)
> #endif
> }
>
> -static void __init highbank_timer_init(void)
> -{
> - struct device_node *np;
> -
> - /* Map system registers */
> - np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
> - sregs_base = of_iomap(np, 0);
> - WARN_ON(!sregs_base);
> -
> - of_clk_init(NULL);
> -
> - clocksource_of_init();
> -}
> -
> static void highbank_power_off(void)
> {
> highbank_set_pwr_shutdown();
> @@ -160,6 +145,13 @@ static struct notifier_block highbank_platform_nb = {
>
> static void __init highbank_init(void)
> {
> + struct device_node *np;
> +
> + /* Map system registers */
> + np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
> + sregs_base = of_iomap(np, 0);
> + WARN_ON(!sregs_base);
> +
> pm_power_off = highbank_power_off;
> highbank_pm_init();
>
> @@ -178,7 +170,6 @@ static const char *highbank_match[] __initconst = {
> DT_MACHINE_START(HIGHBANK, "Highbank")
> .smp = smp_ops(highbank_smp_ops),
> .init_irq = highbank_init_irq,
> - .init_time = highbank_timer_init,
> .init_machine = highbank_init,
> .dt_compat = highbank_match,
> .restart = highbank_restart,
> diff --git a/drivers/clk/clk-highbank.c b/drivers/clk/clk-highbank.c
> index 2e08cb0..2e7e9d9 100644
> --- a/drivers/clk/clk-highbank.c
> +++ b/drivers/clk/clk-highbank.c
> @@ -20,8 +20,7 @@
> #include <linux/clk-provider.h>
> #include <linux/io.h>
> #include <linux/of.h>
> -
> -extern void __iomem *sregs_base;
> +#include <linux/of_address.h>
>
> #define HB_PLL_LOCK_500 0x20000000
> #define HB_PLL_LOCK 0x10000000
> @@ -280,6 +279,7 @@ static __init struct clk *hb_clk_init(struct device_node *node, const struct clk
> const char *clk_name = node->name;
> const char *parent_name;
> struct clk_init_data init;
> + struct device_node *srnp;
> int rc;
>
> rc = of_property_read_u32(node, "reg", &reg);
> @@ -290,7 +290,11 @@ static __init struct clk *hb_clk_init(struct device_node *node, const struct clk
> if (WARN_ON(!hb_clk))
> return NULL;
>
> - hb_clk->reg = sregs_base + reg;
> + /* Map system registers */
> + srnp = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
> + hb_clk->reg = of_iomap(srnp, 0);
> + BUG_ON(!hb_clk->reg);
> + hb_clk->reg += reg;
>
> of_property_read_string(node, "clock-output-names", &clk_name);
>
> --
> 1.7.2.5

2013-08-27 23:16:20

by Mike Turquette

[permalink] [raw]
Subject: Re: [PATCH RFC v2 08/16] ARM: mxs: remove custom .init_time hook

Quoting Sebastian Hesselbarth (2013-08-27 14:28:02)
> This patch converts clk-imx2[38] clocksource_of_init compatible init
> associated with fsl,imx2[38]-clkctrl. With arch/arm calling
> of_clk_init(NULL) from time_init(), we can now also remove custom
> .init_time hooks.
>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>

Acked-by: Mike Turquette <[email protected]>

Need Shawn's Ack for this as well.

> ---
> Cc: Shawn Guo <[email protected]>
> Cc: Mike Turquette <[email protected]>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/arm/mach-mxs/mach-mxs.c | 13 -------------
> drivers/clk/mxs/clk-imx23.c | 16 +++++++---------
> drivers/clk/mxs/clk-imx28.c | 16 +++++++---------
> include/linux/clk/mxs.h | 2 --
> 4 files changed, 14 insertions(+), 33 deletions(-)
>
> diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
> index 98f6e2a..cc511a4 100644
> --- a/arch/arm/mach-mxs/mach-mxs.c
> +++ b/arch/arm/mach-mxs/mach-mxs.c
> @@ -13,8 +13,6 @@
> #include <linux/clk.h>
> #include <linux/clk/mxs.h>
> #include <linux/clkdev.h>
> -#include <linux/clocksource.h>
> -#include <linux/clk-provider.h>
> #include <linux/delay.h>
> #include <linux/err.h>
> #include <linux/gpio.h>
> @@ -490,16 +488,6 @@ static void mxs_restart(enum reboot_mode mode, const char *cmd)
> soft_restart(0);
> }
>
> -static void __init mxs_timer_init(void)
> -{
> - if (of_machine_is_compatible("fsl,imx23"))
> - mx23_clocks_init();
> - else
> - mx28_clocks_init();
> - of_clk_init(NULL);
> - clocksource_of_init();
> -}
> -
> static const char *mxs_dt_compat[] __initdata = {
> "fsl,imx28",
> "fsl,imx23",
> @@ -508,7 +496,6 @@ static const char *mxs_dt_compat[] __initdata = {
>
> DT_MACHINE_START(MXS, "Freescale MXS (Device Tree)")
> .handle_irq = icoll_handle_irq,
> - .init_time = mxs_timer_init,
> .init_machine = mxs_machine_init,
> .init_late = mxs_pm_init,
> .dt_compat = mxs_dt_compat,
> diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
> index c396fe3..7eb1d1a 100644
> --- a/drivers/clk/mxs/clk-imx23.c
> +++ b/drivers/clk/mxs/clk-imx23.c
> @@ -12,6 +12,7 @@
> #include <linux/clk.h>
> #include <linux/clk/mxs.h>
> #include <linux/clkdev.h>
> +#include <linux/clk-provider.h>
> #include <linux/err.h>
> #include <linux/init.h>
> #include <linux/io.h>
> @@ -100,19 +101,17 @@ static enum imx23_clk clks_init_on[] __initdata = {
> cpu, hbus, xbus, emi, uart,
> };
>
> -int __init mx23_clocks_init(void)
> +static void __init mx23_clocks_init(struct device_node *np)
> {
> - struct device_node *np;
> u32 i;
>
> + clkctrl = of_iomap(np, 0);
> + WARN_ON(!clkctrl);
> +
> np = of_find_compatible_node(NULL, NULL, "fsl,imx23-digctl");
> digctrl = of_iomap(np, 0);
> WARN_ON(!digctrl);
>
> - np = of_find_compatible_node(NULL, NULL, "fsl,imx23-clkctrl");
> - clkctrl = of_iomap(np, 0);
> - WARN_ON(!clkctrl);
> -
> clk_misc_init();
>
> clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
> @@ -162,7 +161,7 @@ int __init mx23_clocks_init(void)
> if (IS_ERR(clks[i])) {
> pr_err("i.MX23 clk %d: register failed with %ld\n",
> i, PTR_ERR(clks[i]));
> - return PTR_ERR(clks[i]);
> + return;
> }
>
> clk_data.clks = clks;
> @@ -171,6 +170,5 @@ int __init mx23_clocks_init(void)
>
> for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
> clk_prepare_enable(clks[clks_init_on[i]]);
> -
> - return 0;
> }
> +CLK_OF_DECLARE(imx23_clkctrl, "fsl,imx23-clkctrl", mx23_clocks_init);
> diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
> index 4faf0af..12d3f3d 100644
> --- a/drivers/clk/mxs/clk-imx28.c
> +++ b/drivers/clk/mxs/clk-imx28.c
> @@ -12,6 +12,7 @@
> #include <linux/clk.h>
> #include <linux/clk/mxs.h>
> #include <linux/clkdev.h>
> +#include <linux/clk-provider.h>
> #include <linux/err.h>
> #include <linux/init.h>
> #include <linux/io.h>
> @@ -154,19 +155,17 @@ static enum imx28_clk clks_init_on[] __initdata = {
> cpu, hbus, xbus, emi, uart,
> };
>
> -int __init mx28_clocks_init(void)
> +static void __init mx28_clocks_init(struct device_node *np)
> {
> - struct device_node *np;
> u32 i;
>
> + clkctrl = of_iomap(np, 0);
> + WARN_ON(!clkctrl);
> +
> np = of_find_compatible_node(NULL, NULL, "fsl,imx28-digctl");
> digctrl = of_iomap(np, 0);
> WARN_ON(!digctrl);
>
> - np = of_find_compatible_node(NULL, NULL, "fsl,imx28-clkctrl");
> - clkctrl = of_iomap(np, 0);
> - WARN_ON(!clkctrl);
> -
> clk_misc_init();
>
> clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
> @@ -239,7 +238,7 @@ int __init mx28_clocks_init(void)
> if (IS_ERR(clks[i])) {
> pr_err("i.MX28 clk %d: register failed with %ld\n",
> i, PTR_ERR(clks[i]));
> - return PTR_ERR(clks[i]);
> + return;
> }
>
> clk_data.clks = clks;
> @@ -250,6 +249,5 @@ int __init mx28_clocks_init(void)
>
> for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
> clk_prepare_enable(clks[clks_init_on[i]]);
> -
> - return 0;
> }
> +CLK_OF_DECLARE(imx28_clkctrl, "fsl,imx28-clkctrl", mx28_clocks_init);
> diff --git a/include/linux/clk/mxs.h b/include/linux/clk/mxs.h
> index 90c30dc..5138a90 100644
> --- a/include/linux/clk/mxs.h
> +++ b/include/linux/clk/mxs.h
> @@ -9,8 +9,6 @@
> #ifndef __LINUX_CLK_MXS_H
> #define __LINUX_CLK_MXS_H
>
> -int mx23_clocks_init(void);
> -int mx28_clocks_init(void);
> int mxs_saif_clkmux_select(unsigned int clkmux);
>
> #endif
> --
> 1.7.2.5

2013-08-27 23:17:00

by Mike Turquette

[permalink] [raw]
Subject: Re: [PATCH RFC v2 15/16] clk: vt8500: remove call to of_clk_init

Quoting Sebastian Hesselbarth (2013-08-27 14:28:09)
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove it from corresponding drivers/clk code.
>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>

Acked-by: Mike Turquette <[email protected]>

> ---
> Cc: Mike Turquette <[email protected]>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> drivers/clk/clk-vt8500.c | 2 --
> 1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
> index 82306f5..218d7ba 100644
> --- a/drivers/clk/clk-vt8500.c
> +++ b/drivers/clk/clk-vt8500.c
> @@ -701,6 +701,4 @@ void __init vtwm_clk_init(void __iomem *base)
> return;
>
> pmc_base = base;
> -
> - of_clk_init(NULL);
> }
> --
> 1.7.2.5

2013-08-27 23:20:16

by Soren Brinkmann

[permalink] [raw]
Subject: Re: [PATCH RFC v2 01/16] ARM: call clk_of_init from time_init

On Wed, Aug 28, 2013 at 12:58:39AM +0200, Sebastian Hesselbarth wrote:
> On 08/28/13 00:19, Sören Brinkmann wrote:
> >On Tue, Aug 27, 2013 at 11:27:55PM +0200, Sebastian Hesselbarth wrote:
> >>Most DT ARM machs require common clock providers initialized before timers.
> >>Currently, arch/arm machs use .init_time to call clk_of_init right before
> >>clocksource_of_init. This prevents to remove that hook and use the default
> >>hook instead. clk_of_init is safe to call for non-DT platforms, so add
> >>the call to ARM arch time_init by default. While at it, also reorder includes
> >>alphabetically.
> >>
> >>Signed-off-by: Sebastian Hesselbarth <[email protected]>
> >>---
> >>Changelog:
> >>v1->v2:
> >>- reorder includes alphabetically
> >>
> >>Cc: Russell King <[email protected]>
> >>Cc: Arnd Bergmann <[email protected]>
> >>Cc: [email protected]
> >>Cc: [email protected]
> >>Cc: [email protected]
> >>Cc: [email protected]
> >>Cc: [email protected]
> >>---
> >> arch/arm/kernel/time.c | 24 ++++++++++++++----------
> >> 1 files changed, 14 insertions(+), 10 deletions(-)
> >>
> >>diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
> >>index 98aee32..dd1028e 100644
> >>--- a/arch/arm/kernel/time.c
> >>+++ b/arch/arm/kernel/time.c
> >>@@ -11,25 +11,26 @@
> >[ ... ]
> >> void __init time_init(void)
> >> {
> >>+ /* initalize common clocks before timers */
> >>+ of_clk_init(NULL);
> >>+
> >> if (machine_desc->init_time)
> >> machine_desc->init_time();
> >> else
> >
> >This forces zynq to move some initialization our clock code relies on to
> >init_irq(). Also, the current code already takes an approach of
> >doing either common init or machine specific init.
>
> Soeren,
>
> you know that patch 16/16 takes care of zynq's clock init?
>
> It's your own patch you provided from the last RFC. Looking at it, it
> moves zynq_sclr_init() to .init_irq and removes the call to
> of_clk_init() from zynq_clock_init() which is called by
> zynq_sclr_init().
>
> Isn't that solving the above issues for mach-zynq?

Yes, I know. This alternative approach came to me after I sent my patch
and took a closer look at init_irq(). As you said, we move our problem
just to an earlier boot stage. Which wouldn't be true if a strict
if-else would allow us to explicitly call everything in the right order
- which init_irq by the way does.
I mentioned it in an email in the original thread yesterday. But since
there is a v2 now, I just thought to bring it up here now.

>
> >I think it might be better to move the call to of_clk_init() down into
> >the else branch of the if-else.
>
> Possibly, yes. But we could also unconditionally call of_clk_init() at
> the beginning of time_init() and call clocksource_of_init() at the end.
> That will make .init_time() to some fixup hook between
> initialization of clocks and timers.

Right, the question is what is the common case? What do SOCs use the
custom init_time() hook for?

If SOCs use it for things additionally to clock init where
execution order doesn't matter, your patch works perfectly well and is
the preferred solution.

If they use it just to call of_clk_init() and of_clocksource_init(),
those hooks can go away and it would work in the else branch or outside,
equally well.

If they use it like Zynq, to do some required SOC specific init which must
be done before clock init, it would make more sense to have it in the
else branch. That way the SOC intentionally replaces init_time()
with its own implementation and has to take care of calling everything in the
right order.

Another approach might be to move the custom init_time() hook before the
call to of_clk_init().

As I said, it depends on how this hook is used.

Sören

2013-08-28 06:28:29

by Gregory CLEMENT

[permalink] [raw]
Subject: Re: [PATCH RFC v2 07/16] ARM: mvebu: remove custom .init_time hook

Hi Sebastian,
On 27/08/2013 23:28, Sebastian Hesselbarth wrote:
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove custom .init_time hooks.

You should update the commit log, the .init_time hooks won't be removed
with this patch.

Gregory

>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>
> ---
> Changelog:
> v1->v2:
> - only remove of_clk_init from custom timer hook, further cleanup
> will be carried out later (Reported by Gregory Clement)
>
> Cc: Gregory Clement <[email protected]>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/arm/mach-mvebu/armada-370-xp.c | 2 --
> 1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
> index 829b573..164c62b 100644
> --- a/arch/arm/mach-mvebu/armada-370-xp.c
> +++ b/arch/arm/mach-mvebu/armada-370-xp.c
> @@ -14,7 +14,6 @@
>
> #include <linux/kernel.h>
> #include <linux/init.h>
> -#include <linux/clk-provider.h>
> #include <linux/of_address.h>
> #include <linux/of_platform.h>
> #include <linux/io.h>
> @@ -36,7 +35,6 @@ static void __init armada_370_xp_map_io(void)
>
> static void __init armada_370_xp_timer_and_clk_init(void)
> {
> - of_clk_init(NULL);
> armada_370_xp_timer_init();
> coherency_init();
> BUG_ON(mvebu_mbus_dt_init());
>


--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

2013-08-29 11:00:55

by Shawn Guo

[permalink] [raw]
Subject: Re: [PATCH RFC v2 05/16] ARM: imx: remove custom .init_time hook

On Tue, Aug 27, 2013 at 11:27:59PM +0200, Sebastian Hesselbarth wrote:
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove custom .init_time hooks.
>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>
> ---
> Changelog:
> v1->v2:
> - added missing CLK_OF_DECLARE for imx51 and imx53 (Reported by Sascha Hauer)
> mx53_clocks_init can be converted as it is used DT only, mx51_clocks_init
> still is used by non-DT.
>
> Cc: Sascha Hauer <[email protected]>
> Cc: Shawn Guo <[email protected]>

Acked-by: Shawn Guo <[email protected]>

2013-08-29 11:09:33

by Shawn Guo

[permalink] [raw]
Subject: Re: [PATCH RFC v2 08/16] ARM: mxs: remove custom .init_time hook

On Tue, Aug 27, 2013 at 11:28:02PM +0200, Sebastian Hesselbarth wrote:
> @@ -100,19 +101,17 @@ static enum imx23_clk clks_init_on[] __initdata = {
> cpu, hbus, xbus, emi, uart,
> };
>
> -int __init mx23_clocks_init(void)
> +static void __init mx23_clocks_init(struct device_node *np)
> {
> - struct device_node *np;
> u32 i;
>
> + clkctrl = of_iomap(np, 0);
> + WARN_ON(!clkctrl);
> +
> np = of_find_compatible_node(NULL, NULL, "fsl,imx23-digctl");
> digctrl = of_iomap(np, 0);
> WARN_ON(!digctrl);
>
> - np = of_find_compatible_node(NULL, NULL, "fsl,imx23-clkctrl");
> - clkctrl = of_iomap(np, 0);
> - WARN_ON(!clkctrl);
> -

With the changes, 'np' becomes a pointer to digctl node instead of
clkctrl as the original. This will cause problem for
of_clk_add_provider(np, ...) later in this function.

Same problem with mx28_clocks_init() changes.

Shawn

> clk_misc_init();
>
> clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
> @@ -162,7 +161,7 @@ int __init mx23_clocks_init(void)
> if (IS_ERR(clks[i])) {
> pr_err("i.MX23 clk %d: register failed with %ld\n",
> i, PTR_ERR(clks[i]));
> - return PTR_ERR(clks[i]);
> + return;
> }
>
> clk_data.clks = clks;
> @@ -171,6 +170,5 @@ int __init mx23_clocks_init(void)
>
> for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
> clk_prepare_enable(clks[clks_init_on[i]]);
> -
> - return 0;
> }
> +CLK_OF_DECLARE(imx23_clkctrl, "fsl,imx23-clkctrl", mx23_clocks_init);
> diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
> index 4faf0af..12d3f3d 100644
> --- a/drivers/clk/mxs/clk-imx28.c
> +++ b/drivers/clk/mxs/clk-imx28.c
> @@ -12,6 +12,7 @@
> #include <linux/clk.h>
> #include <linux/clk/mxs.h>
> #include <linux/clkdev.h>
> +#include <linux/clk-provider.h>
> #include <linux/err.h>
> #include <linux/init.h>
> #include <linux/io.h>
> @@ -154,19 +155,17 @@ static enum imx28_clk clks_init_on[] __initdata = {
> cpu, hbus, xbus, emi, uart,
> };
>
> -int __init mx28_clocks_init(void)
> +static void __init mx28_clocks_init(struct device_node *np)
> {
> - struct device_node *np;
> u32 i;
>
> + clkctrl = of_iomap(np, 0);
> + WARN_ON(!clkctrl);
> +
> np = of_find_compatible_node(NULL, NULL, "fsl,imx28-digctl");
> digctrl = of_iomap(np, 0);
> WARN_ON(!digctrl);
>
> - np = of_find_compatible_node(NULL, NULL, "fsl,imx28-clkctrl");
> - clkctrl = of_iomap(np, 0);
> - WARN_ON(!clkctrl);
> -
> clk_misc_init();
>
> clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
> @@ -239,7 +238,7 @@ int __init mx28_clocks_init(void)
> if (IS_ERR(clks[i])) {
> pr_err("i.MX28 clk %d: register failed with %ld\n",
> i, PTR_ERR(clks[i]));
> - return PTR_ERR(clks[i]);
> + return;
> }
>
> clk_data.clks = clks;
> @@ -250,6 +249,5 @@ int __init mx28_clocks_init(void)
>
> for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
> clk_prepare_enable(clks[clks_init_on[i]]);
> -
> - return 0;
> }
> +CLK_OF_DECLARE(imx28_clkctrl, "fsl,imx28-clkctrl", mx28_clocks_init);
> diff --git a/include/linux/clk/mxs.h b/include/linux/clk/mxs.h
> index 90c30dc..5138a90 100644
> --- a/include/linux/clk/mxs.h
> +++ b/include/linux/clk/mxs.h
> @@ -9,8 +9,6 @@
> #ifndef __LINUX_CLK_MXS_H
> #define __LINUX_CLK_MXS_H
>
> -int mx23_clocks_init(void);
> -int mx28_clocks_init(void);
> int mxs_saif_clkmux_select(unsigned int clkmux);
>
> #endif
> --
> 1.7.2.5
>

2013-08-29 11:32:40

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [PATCH RFC v2 08/16] ARM: mxs: remove custom .init_time hook

On 08/29/13 13:08, Shawn Guo wrote:
> On Tue, Aug 27, 2013 at 11:28:02PM +0200, Sebastian Hesselbarth wrote:
>> @@ -100,19 +101,17 @@ static enum imx23_clk clks_init_on[] __initdata = {
>> cpu, hbus, xbus, emi, uart,
>> };
>>
>> -int __init mx23_clocks_init(void)
>> +static void __init mx23_clocks_init(struct device_node *np)
>> {
>> - struct device_node *np;
>> u32 i;
>>
>> + clkctrl = of_iomap(np, 0);
>> + WARN_ON(!clkctrl);
>> +
>> np = of_find_compatible_node(NULL, NULL, "fsl,imx23-digctl");
>> digctrl = of_iomap(np, 0);
>> WARN_ON(!digctrl);
>>
>> - np = of_find_compatible_node(NULL, NULL, "fsl,imx23-clkctrl");
>> - clkctrl = of_iomap(np, 0);
>> - WARN_ON(!clkctrl);
>> -
>
> With the changes, 'np' becomes a pointer to digctl node instead of
> clkctrl as the original. This will cause problem for
> of_clk_add_provider(np, ...) later in this function.
>
> Same problem with mx28_clocks_init() changes.

Ok, will take care of it. I assume you are fine with having an extra
struct device_node pointer for the sake of readability instead of
reusing the same pointer.

Sebastian

2013-08-29 12:58:48

by Shawn Guo

[permalink] [raw]
Subject: Re: [PATCH RFC v2 08/16] ARM: mxs: remove custom .init_time hook

On Thu, Aug 29, 2013 at 01:32:33PM +0200, Sebastian Hesselbarth wrote:
> Ok, will take care of it. I assume you are fine with having an extra
> struct device_node pointer for the sake of readability instead of
> reusing the same pointer.

Yeah, something like np_digctl for digctl node.

Thanks for your work.

Shawn

2013-08-29 13:37:15

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH RFC v2 14/16] ARM: vexpress: remove custom .init_time hook

On Tuesday 27 August 2013, Sebastian Hesselbarth wrote:
> @@ -422,16 +419,8 @@ void __init v2m_dt_init_early(void)
> pr_warning("vexpress: DT HBI (%x) is not matching "
> "hardware (%x)!\n", dt_hbi, hbi);
> }
> -}
> -
> -static void __init v2m_dt_timer_init(void)
> -{
> - of_clk_init(NULL);
>
> - clocksource_of_init();
> -
> - versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> - 24000000);
> + versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
> }


You are moving versatile_sched_clock_init() ahead of clocksource_of_init(), which I suspect
won't work. Have you checked this?

Arnd

2013-08-29 13:38:33

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH RFC v2 16/16] ARM: zynq: Don't call of_clk_init()

On Tuesday 27 August 2013, Sebastian Hesselbarth wrote:
> @@ -58,10 +57,10 @@ static void __init zynq_init_machine(void)
> of_platform_bus_probe(NULL, zynq_of_bus_ids, NULL);
> }
>
> -static void __init zynq_timer_init(void)
> +static void __init zynq_init_irq(void)
> {
> + irqchip_init();
> zynq_slcr_init();
> - clocksource_of_init();
> }
>
> static struct map_desc zynq_cortex_a9_scu_map __initdata = {
> @@ -104,8 +103,8 @@ static const char * const zynq_dt_match[] = {
> DT_MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform")
> .smp = smp_ops(zynq_smp_ops),
> .map_io = zynq_map_io,
> + .init_irq = zynq_init_irq,
> .init_machine = zynq_init_machine,
> - .init_time = zynq_timer_init,
> .dt_compat = zynq_dt_match,
> .restart = zynq_system_reset,
> MACHINE_END

It looks like we are not getting any closer to removing all callbacks here,
since you add one in order to remove another, and after the patch we do
more things "early", which we try to avoid. I think we're better off without
this particular patch.

Arnd

2013-08-29 13:43:08

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH RFC v2 15/16] clk: vt8500: remove call to of_clk_init

On Tuesday 27 August 2013, Sebastian Hesselbarth wrote:
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove it from corresponding drivers/clk code.
>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>
> ---
> Cc: Mike Turquette <[email protected]>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> drivers/clk/clk-vt8500.c | 2 --
> 1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
> index 82306f5..218d7ba 100644
> --- a/drivers/clk/clk-vt8500.c
> +++ b/drivers/clk/clk-vt8500.c
> @@ -701,6 +701,4 @@ void __init vtwm_clk_init(void __iomem *base)
> return;
>
> pmc_base = base;
> -
> - of_clk_init(NULL);
> }

This looks suspicious: of_clk_init must be called after assigning pmc_base
in this driver. I think you should better do the same thing you did for
highbank and move the initialization into the clk driver.

Arnd

2013-08-29 13:46:26

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH RFC v2 01/16] ARM: call clk_of_init from time_init

On Wednesday 28 August 2013, Sebastian Hesselbarth wrote:
> >
> > This forces zynq to move some initialization our clock code relies on to
> > init_irq(). Also, the current code already takes an approach of
> > doing either common init or machine specific init.
>
> Soeren,
>
> you know that patch 16/16 takes care of zynq's clock init?
>
> It's your own patch you provided from the last RFC. Looking at it, it
> moves zynq_sclr_init() to .init_irq and removes the call to
> of_clk_init() from zynq_clock_init() which is called by
> zynq_sclr_init().
>
> Isn't that solving the above issues for mach-zynq?

Please be careful with the patch ordering here. The patch series should
be bisectable, i.e. no patch should ever knowingly break any of the
platforms, with the fix getting added in a later patch.

You should be able to do that by cleaning up all platforms to not
rely on ordering first, then add this patch, and finally remove
the other calls.

Arnd

2013-08-29 14:21:41

by Michal Simek

[permalink] [raw]
Subject: Re: [PATCH RFC v2 16/16] ARM: zynq: Don't call of_clk_init()

On 08/29/2013 03:37 PM, Arnd Bergmann wrote:
> On Tuesday 27 August 2013, Sebastian Hesselbarth wrote:
>> @@ -58,10 +57,10 @@ static void __init zynq_init_machine(void)
>> of_platform_bus_probe(NULL, zynq_of_bus_ids, NULL);
>> }
>>
>> -static void __init zynq_timer_init(void)
>> +static void __init zynq_init_irq(void)
>> {
>> + irqchip_init();
>> zynq_slcr_init();
>> - clocksource_of_init();
>> }
>>
>> static struct map_desc zynq_cortex_a9_scu_map __initdata = {
>> @@ -104,8 +103,8 @@ static const char * const zynq_dt_match[] = {
>> DT_MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform")
>> .smp = smp_ops(zynq_smp_ops),
>> .map_io = zynq_map_io,
>> + .init_irq = zynq_init_irq,
>> .init_machine = zynq_init_machine,
>> - .init_time = zynq_timer_init,
>> .dt_compat = zynq_dt_match,
>> .restart = zynq_system_reset,
>> MACHINE_END
>
> It looks like we are not getting any closer to removing all callbacks here,
> since you add one in order to remove another, and after the patch we do
> more things "early", which we try to avoid. I think we're better off without
> this particular patch.

Is there any plan to remove all of them?
I expect that on almost all platforms it is a need to have at least one
early hook to be able to setup things.

Thanks,
Michal

2013-08-29 15:38:58

by Dinh Nguyen

[permalink] [raw]
Subject: Re: [PATCH RFC v2 11/16] ARM: socfpga: remove call to of_clk_init

On Tue, 2013-08-27 at 23:28 +0200, Sebastian Hesselbarth wrote:
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove mach specific calls to it.
>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>
> ---
> Cc: Dinh Nguyen <[email protected]>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/arm/mach-socfpga/socfpga.c | 2 --
> 1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c
> index bfce964..dd0d49c 100644
> --- a/arch/arm/mach-socfpga/socfpga.c
> +++ b/arch/arm/mach-socfpga/socfpga.c
> @@ -14,7 +14,6 @@
> * You should have received a copy of the GNU General Public License
> * along with this program. If not, see <http://www.gnu.org/licenses/>.
> */
> -#include <linux/clk-provider.h>
> #include <linux/irqchip.h>
> #include <linux/of_address.h>
> #include <linux/of_irq.h>
> @@ -107,7 +106,6 @@ static void __init socfpga_cyclone5_init(void)
> {
> l2x0_of_init(0, ~0UL);
> of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> - of_clk_init(NULL);
> socfpga_init_clocks();
> }
>

Acked-by: Dinh Nguyen <[email protected]>

Thanks,
Dinh


2013-08-29 16:47:23

by Srinivas KANDAGATLA

[permalink] [raw]
Subject: Re: [STLinux Kernel] [PATCH RFC v2 12/16] ARM: sti: remove custom .init_time hook

On 27/08/13 22:28, Sebastian Hesselbarth wrote:
> With arch/arm calling of_clk_init(NULL) from time_init(), we can now
> remove custom .init_time hooks. To get rid of it, move l2cc init to
> .init_machine hook instead.
>
> Signed-off-by: Sebastian Hesselbarth <[email protected]>

Acked-by: Srinivas Kandagatla <[email protected]>
> ---
> Cc: Srinivas Kandagatla <[email protected]>
> Cc: Stuart Menefy <[email protected]>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/arm/mach-sti/board-dt.c | 10 ++++------
> 1 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/mach-sti/board-dt.c b/arch/arm/mach-sti/board-dt.c
> index 8fe6f0c..1217fb5 100644
> --- a/arch/arm/mach-sti/board-dt.c
> +++ b/arch/arm/mach-sti/board-dt.c
> @@ -7,9 +7,8 @@
> * published by the Free Software Foundation.
> */
>
> -#include <linux/clk-provider.h>
> -#include <linux/clocksource.h>
> #include <linux/irq.h>
> +#include <linux/of_platform.h>
> #include <asm/hardware/cache-l2x0.h>
> #include <asm/mach/arch.h>
>
> @@ -28,11 +27,10 @@ void __init stih41x_l2x0_init(void)
> l2x0_of_init(aux_ctrl, L2X0_AUX_CTRL_MASK);
> }
>
> -static void __init stih41x_timer_init(void)
> +static void __init stih41x_machine_init(void)
> {
> - of_clk_init(NULL);
> - clocksource_of_init();
> stih41x_l2x0_init();
> + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> }
>
> static const char *stih41x_dt_match[] __initdata = {
> @@ -42,7 +40,7 @@ static const char *stih41x_dt_match[] __initdata = {
> };
>
> DT_MACHINE_START(STM, "STiH415/416 SoC with Flattened Device Tree")
> - .init_time = stih41x_timer_init,
> + .init_machine = stih41x_machine_init,
> .smp = smp_ops(sti_smp_ops),
> .dt_compat = stih41x_dt_match,
> MACHINE_END
>


2013-08-29 17:20:40

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH RFC v2 16/16] ARM: zynq: Don't call of_clk_init()

On Thursday 29 August 2013, Michal Simek wrote:
> Is there any plan to remove all of them?
> I expect that on almost all platforms it is a need to have at least one
> early hook to be able to setup things.

In an ideal world, we wouldn't need any, and on arm64 we don't plan to
introduce callbacks in the first place. We don't put a lot of effort
into eliminating all the ones from existing platforms in the near future,
but but I do hope to have a situation where we don't use any callbacks
for newly introduced 32-bit platforms soon, and remove a lot of the
existing callbacks over time when we have the chance (like now for the
clk init).

Arnd

2013-08-29 17:23:27

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH RFC v2 11/16] ARM: socfpga: remove call to of_clk_init

On Thursday 29 August 2013, Dinh Nguyen wrote:
> On Tue, 2013-08-27 at 23:28 +0200, Sebastian Hesselbarth wrote:

> > @@ -107,7 +106,6 @@ static void __init socfpga_cyclone5_init(void)
> > {
> > l2x0_of_init(0, ~0UL);
> > of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> > - of_clk_init(NULL);
> > socfpga_init_clocks();
> > }
> >
>
> Acked-by: Dinh Nguyen <[email protected]>

I saw that your socfpga_init_clocks() function only has these contents:

void __init socfpga_init_clocks(void)
{
struct clk *clk;
int ret;

clk = clk_register_fixed_factor(NULL, "smp_twd", "mpuclk", 0, 1, 4);
ret = clk_register_clkdev(clk, NULL, "smp_twd");
if (ret)
pr_err("smp_twd alias not registered\n");
}


I think that can easily be expressed with DT syntax now (correct me if I'm wrong), so
you should be able to kill this off as well. Once somebody gets around to automate
the l2x0 setup, the entire socfpga_cyclone5_init() function can go away too.

Arnd

2013-08-29 18:14:45

by Michal Simek

[permalink] [raw]
Subject: RE: [PATCH RFC v2 16/16] ARM: zynq: Don't call of_clk_init()

Hi.

> -----Original Message-----
> From: Arnd Bergmann [mailto:[email protected]]
> Sent: Thursday, August 29, 2013 7:20 PM
> To: Michal Simek
> Cc: Sebastian Hesselbarth; Soren Brinkmann; Mike Turquette; Russell King;
> [email protected]; [email protected]
> Subject: Re: [PATCH RFC v2 16/16] ARM: zynq: Don't call of_clk_init()
>
> On Thursday 29 August 2013, Michal Simek wrote:
> > Is there any plan to remove all of them?
> > I expect that on almost all platforms it is a need to have at least
> > one early hook to be able to setup things.
>
> In an ideal world, we wouldn't need any, and on arm64 we don't plan to
> introduce callbacks in the first place. We don't put a lot of effort into eliminating
> all the ones from existing platforms in the near future, but but I do hope to have
> a situation where we don't use any callbacks for newly introduced 32-bit
> platforms soon, and remove a lot of the existing callbacks over time when we
> have the chance (like now for the clk init).

As you know we are open to change this when we have alternative for doing that.
I have read discussion about early device probing. Especially for this slcr case.
It is giant IP where generic locking is, clock stuff, pin muxing, reset, cpu startup.
It points to use syscon and regmap and I would love to use better solution
but slcr unlocking must be done very early for clock setup and smp startup.
If you know how to do it let me know. I am definitely open to try that solution.

I expect that this topic will be discussed on ksummit or at least on arm minisummit.

Thanks,
Michal



This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

2013-08-29 18:17:05

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [PATCH RFC v2 14/16] ARM: vexpress: remove custom .init_time hook

On 08/29/13 15:35, Arnd Bergmann wrote:
> On Tuesday 27 August 2013, Sebastian Hesselbarth wrote:
>> @@ -422,16 +419,8 @@ void __init v2m_dt_init_early(void)
>> pr_warning("vexpress: DT HBI (%x) is not matching "
>> "hardware (%x)!\n", dt_hbi, hbi);
>> }
>> -}
>> -
>> -static void __init v2m_dt_timer_init(void)
>> -{
>> - of_clk_init(NULL);
>>
>> - clocksource_of_init();
>> -
>> - versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
>> - 24000000);
>> + versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
>> }
>
> You are moving versatile_sched_clock_init() ahead of clocksource_of_init(), which I suspect
> won't work. Have you checked this?

"Checked" as in "Tested", no I haven't.

But non-DT v2m has it in v2m_init_early also, while v2m_sp804_init()
is called in v2m_timer_init().

That matches the above approach taken for DT v2m where
versatile_sched_clock_init() is now called from v2m_dt_init_early()
and clocksource_of_init() called from arch-wide .timer_init.

get_maintainer.pl did not spit out any additional maintainer except
Russell of course. You know someone who can test the above?

Sebastian

2013-08-29 18:20:55

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [PATCH RFC v2 16/16] ARM: zynq: Don't call of_clk_init()

On 08/29/13 15:37, Arnd Bergmann wrote:
> On Tuesday 27 August 2013, Sebastian Hesselbarth wrote:
>> @@ -58,10 +57,10 @@ static void __init zynq_init_machine(void)
>> of_platform_bus_probe(NULL, zynq_of_bus_ids, NULL);
>> }
>>
>> -static void __init zynq_timer_init(void)
>> +static void __init zynq_init_irq(void)
>> {
>> + irqchip_init();
>> zynq_slcr_init();
>> - clocksource_of_init();
>> }
>>
>> static struct map_desc zynq_cortex_a9_scu_map __initdata = {
>> @@ -104,8 +103,8 @@ static const char * const zynq_dt_match[] = {
>> DT_MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform")
>> .smp = smp_ops(zynq_smp_ops),
>> .map_io = zynq_map_io,
>> + .init_irq = zynq_init_irq,
>> .init_machine = zynq_init_machine,
>> - .init_time = zynq_timer_init,
>> .dt_compat = zynq_dt_match,
>> .restart = zynq_system_reset,
>> MACHINE_END
>
> It looks like we are not getting any closer to removing all callbacks here,
> since you add one in order to remove another, and after the patch we do
> more things "early", which we try to avoid. I think we're better off without
> this particular patch.

Right.

Have you seen Soeren requesting to move of_clk_init(NULL) under the
else branch of arch-wide .init_time? In the proposed patch it is called
unconditionally before any mach specific callback.

Moving it to what gets called if no mach specific callback is set,
would allow zynq (and others) to still have their own callback where
they can probe clocks whenever they want to.

Sebastian

2013-08-30 10:02:35

by Jon Medhurst (Tixy)

[permalink] [raw]
Subject: Re: [PATCH RFC v2 14/16] ARM: vexpress: remove custom .init_time hook

On Thu, 2013-08-29 at 20:16 +0200, Sebastian Hesselbarth wrote:
> On 08/29/13 15:35, Arnd Bergmann wrote:
> > On Tuesday 27 August 2013, Sebastian Hesselbarth wrote:
> >> @@ -422,16 +419,8 @@ void __init v2m_dt_init_early(void)
> >> pr_warning("vexpress: DT HBI (%x) is not matching "
> >> "hardware (%x)!\n", dt_hbi, hbi);
> >> }
> >> -}
> >> -
> >> -static void __init v2m_dt_timer_init(void)
> >> -{
> >> - of_clk_init(NULL);
> >>
> >> - clocksource_of_init();
> >> -
> >> - versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> >> - 24000000);
> >> + versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
> >> }
> >
> > You are moving versatile_sched_clock_init() ahead of clocksource_of_init(), which I suspect
> > won't work. Have you checked this?
>
> "Checked" as in "Tested", no I haven't.
>
> But non-DT v2m has it in v2m_init_early also, while v2m_sp804_init()
> is called in v2m_timer_init().
>
> That matches the above approach taken for DT v2m where
> versatile_sched_clock_init() is now called from v2m_dt_init_early()
> and clocksource_of_init() called from arch-wide .timer_init.
>
> get_maintainer.pl did not spit out any additional maintainer except
> Russell of course. You know someone who can test the above?

After adding of_clk_init(NULL) to time_init() things boot OK for me with
this patch. However, do we know that sched_clock is never going to get
read before time_init() has actually started the clock it reads? Are we
making things more fragile?

(My testing was on a 3.11-rc6 based Linaro kernel on TC2 because that's
what I had to hand. So it's not a vanilla mainline kernel and I have
other vexpress changes in my tree.)

--
Tixy

2013-08-30 11:39:32

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH RFC v2 14/16] ARM: vexpress: remove custom .init_time hook

On Fri, Aug 30, 2013 at 11:02:31AM +0100, Jon Medhurst (Tixy) wrote:
> After adding of_clk_init(NULL) to time_init() things boot OK for me with
> this patch. However, do we know that sched_clock is never going to get
> read before time_init() has actually started the clock it reads? Are we
> making things more fragile?

As I've been saying for years, sched_clock gets read for the first time
in sched_init() -> init_idle() which occurs before time_init().

Whether that matters or not is debatable, but the first read should return
zero, and it will return zero after initialization - so I think all we end
up losing is some accounting of the time taken in the early kernel boot.

If we wish to talk about correctness, then arguably it isn't correct.

2013-08-30 13:12:16

by Pawel Moll

[permalink] [raw]
Subject: Re: [PATCH RFC v2 14/16] ARM: vexpress: remove custom .init_time hook

On Fri, 2013-08-30 at 11:02 +0100, Jon Medhurst (Tixy) wrote:
> On Thu, 2013-08-29 at 20:16 +0200, Sebastian Hesselbarth wrote:
> > On 08/29/13 15:35, Arnd Bergmann wrote:
> > > On Tuesday 27 August 2013, Sebastian Hesselbarth wrote:
> > >> @@ -422,16 +419,8 @@ void __init v2m_dt_init_early(void)
> > >> pr_warning("vexpress: DT HBI (%x) is not matching "
> > >> "hardware (%x)!\n", dt_hbi, hbi);
> > >> }
> > >> -}
> > >> -
> > >> -static void __init v2m_dt_timer_init(void)
> > >> -{
> > >> - of_clk_init(NULL);
> > >>
> > >> - clocksource_of_init();
> > >> -
> > >> - versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> > >> - 24000000);
> > >> + versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
> > >> }
> > >
> > > You are moving versatile_sched_clock_init() ahead of clocksource_of_init(), which I suspect
> > > won't work. Have you checked this?
> >
> > "Checked" as in "Tested", no I haven't.
> >
> > But non-DT v2m has it in v2m_init_early also, while v2m_sp804_init()
> > is called in v2m_timer_init().
> >
> > That matches the above approach taken for DT v2m where
> > versatile_sched_clock_init() is now called from v2m_dt_init_early()
> > and clocksource_of_init() called from arch-wide .timer_init.
> >
> > get_maintainer.pl did not spit out any additional maintainer except
> > Russell of course. You know someone who can test the above?
>
> After adding of_clk_init(NULL) to time_init() things boot OK for me with
> this patch. However, do we know that sched_clock is never going to get
> read before time_init() has actually started the clock it reads? Are we
> making things more fragile?

The versatile_sched_clock_init() is currently completely independent of
the clocksource infrastructure, so no harm should be done at all by
moving it.

Paweł

2013-09-04 19:32:32

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [PATCH RFC v2 01/16] ARM: call clk_of_init from time_init

On 08/29/2013 03:45 PM, Arnd Bergmann wrote:
> Please be careful with the patch ordering here. The patch series should
> be bisectable, i.e. no patch should ever knowingly break any of the
> platforms, with the fix getting added in a later patch.
>
> You should be able to do that by cleaning up all platforms to not
> rely on ordering first, then add this patch, and finally remove
> the other calls.

[Added Linus Walleij to Cc]

Just for the record, I have pushed a new version to
https://github.com/shesselba/linux-dove.git clk-of-init-rfc-v3

It is rebased to next-20130904 and most notably calls of_clk_init(NULL)
only if there is no .init_time callback set. Also, I have split up
the set into preparatory and cleanup patches.

I have dropped conversion for mach-mvebu and mach-zynq; taken care of
new mach-nomadik, mach-prima2, and mach-sunxi.

For mach-zynq I prepared a patch set that brings it close to .init_time
removal. I have pushed it to
https://github.com/shesselba/linux-dove.git zynq-clk-init-v1
and will maybe post a patch set after this one is done.

Also new is mach-u300, that looks like it needs clocks before irqs.
It calls irqchip_init but next-20130904 does not yet contain the
corresponding irqchip driver. I added Linus Walleij to make him aware
of the effort to remove most of the mach specific DT .init_time
callbacks. I even started to try to clean it up, but then I realized
the missing irqchip driver. Anyway, with the modifications above, it is
now safe to have custom .init_time and call of_clk_init on your own.
The initial u300 cleanup efforts can be found at
https://github.com/shesselba/linux-dove.git u300-clk-init-v1

I will *not* send RFCv3 but rather wait for v3.11-rc1 to drop, rebase,
and send real v1 of what is left then.

Sebastian

2013-09-04 20:42:25

by Soren Brinkmann

[permalink] [raw]
Subject: Re: [PATCH RFC v2 01/16] ARM: call clk_of_init from time_init

Hi Sebastian,

+Michal

On Wed, Sep 04, 2013 at 09:32:24PM +0200, Sebastian Hesselbarth wrote:

[ ... ]

> For mach-zynq I prepared a patch set that brings it close to .init_time
> removal. I have pushed it to
> https://github.com/shesselba/linux-dove.git zynq-clk-init-v1
> and will maybe post a patch set after this one is done.

I think Steffen had a similar approach and we turned it down:
Your proposal lets the clkc map the SLCR's registers. I think
that approach is not right. It might be okay now, since the
SLCR driver is pretty much a useless skeleton. But in general,
there is a driver for the SLCR which maps that register
region. No other driver should mess with it.

Actually, one early version of my clkc looked pretty much like what you
propose now and we changed it because of above reason.

Sören

2013-09-04 20:52:15

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [PATCH RFC v2 01/16] ARM: call clk_of_init from time_init

On 09/04/2013 10:41 PM, Sören Brinkmann wrote:
> On Wed, Sep 04, 2013 at 09:32:24PM +0200, Sebastian Hesselbarth wrote:
> [ ... ]
>> For mach-zynq I prepared a patch set that brings it close to .init_time
>> removal. I have pushed it to
>> https://github.com/shesselba/linux-dove.git zynq-clk-init-v1
>> and will maybe post a patch set after this one is done.
>
> I think Steffen had a similar approach and we turned it down:
> Your proposal lets the clkc map the SLCR's registers. I think
> that approach is not right. It might be okay now, since the
> SLCR driver is pretty much a useless skeleton. But in general,
> there is a driver for the SLCR which maps that register
> region. No other driver should mess with it.
>
> Actually, one early version of my clkc looked pretty much like what you
> propose now and we changed it because of above reason.

Erm, passing the base address to clkc is less "mess with it" then
get it from DT?

Anyways, having a custom .init_time gives you full control over
of_clk_init and clocksource_of_init back again thanks to your
suggestion.

I'll stop converting zynq and let you decide on your own ;)

Sebastian

2013-09-04 20:59:17

by Soren Brinkmann

[permalink] [raw]
Subject: Re: [PATCH RFC v2 01/16] ARM: call clk_of_init from time_init

Hi Sebastian,

On Wed, Sep 04, 2013 at 10:52:09PM +0200, Sebastian Hesselbarth wrote:
> On 09/04/2013 10:41 PM, Sören Brinkmann wrote:
> >On Wed, Sep 04, 2013 at 09:32:24PM +0200, Sebastian Hesselbarth wrote:
> >[ ... ]
> >>For mach-zynq I prepared a patch set that brings it close to .init_time
> >>removal. I have pushed it to
> >> https://github.com/shesselba/linux-dove.git zynq-clk-init-v1
> >>and will maybe post a patch set after this one is done.
> >
> >I think Steffen had a similar approach and we turned it down:
> >Your proposal lets the clkc map the SLCR's registers. I think
> >that approach is not right. It might be okay now, since the
> >SLCR driver is pretty much a useless skeleton. But in general,
> >there is a driver for the SLCR which maps that register
> >region. No other driver should mess with it.
> >
> >Actually, one early version of my clkc looked pretty much like what you
> >propose now and we changed it because of above reason.
>
> Erm, passing the base address to clkc is less "mess with it" then
> get it from DT?
>
> Anyways, having a custom .init_time gives you full control over
> of_clk_init and clocksource_of_init back again thanks to your
> suggestion.
>
> I'll stop converting zynq and let you decide on your own ;)

As I said, currently it's rather messy and neither solution is perfect.
Steffen seemed to already have looked towards syscon and regmap, which
are probably the right ways of making the SLCR regs available to other users.
Sure, passing down the pointer is not perfect, but having two drivers
map the same memory region seems slightly worse to me. And it would even
fail for one driver if you properly used request_mem_region() and friends.

Sören

2013-09-05 09:35:45

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH RFC v2 01/16] ARM: call clk_of_init from time_init

On Wednesday 04 September 2013, Sören Brinkmann wrote:
> On Wed, Sep 04, 2013 at 10:52:09PM +0200, Sebastian Hesselbarth wrote:
> > On 09/04/2013 10:41 PM, Sören Brinkmann wrote:
> > Anyways, having a custom .init_time gives you full control over
> > of_clk_init and clocksource_of_init back again thanks to your
> > suggestion.
> >
> > I'll stop converting zynq and let you decide on your own ;)
>
> As I said, currently it's rather messy and neither solution is perfect.
> Steffen seemed to already have looked towards syscon and regmap, which
> are probably the right ways of making the SLCR regs available to other users.

Yes, this seems fine. I suspect we will first have to find a way to have
"early" syscon mappings, which seem to be required for a few other use
cases as well, but are not trivial to implement in a nice way.

> Sure, passing down the pointer is not perfect, but having two drivers
> map the same memory region seems slightly worse to me. And it would even
> fail for one driver if you properly used request_mem_region() and friends.

I think the two approaches are equally hacky, no need to change it now
or rush to a better solution -- let's fix the other of_clk_init() users
first.

One suggestion though: it might be better to not use CLK_OF_DECLARE
with of_clk_init(NULL) in cases like this but have an explicit table
in the clk driver that does not get intermixed with the default table.

Arnd

2013-09-11 19:56:45

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH RFC v2 13/16] ARM: tegra: split tegra_pmc_init() in two

On 08/27/2013 03:28 PM, Sebastian Hesselbarth wrote:
> From: Stephen Warren <[email protected]>
>
> Tegra's board file currently initializes clocks much earlier than those
> for most other ARM SoCs. The reason is:
>
> * The PMC HW block is involved in the path of some interrupts (i.e. it
> inverts, or not, the IRQ input pin dedicated to the PMIC).
>
> * So, that part of the PMC must be initialized early so that the IRQ
> polarity is correct.
>
> * The PMC initialization is currently monolithic, and the PMC has some
> clock inputs, so the init routine ends up calling of_clk_get_by_name(),
> and hence clocks must be set up early too.
>
> In order to defer clock initialization to the more typical location,
> split out the portions of tegra_pmc_init() that are truly IRQ-related
> into a separate tegra_pmc_init_irq(), which can be called from the
> machine descriptor's .init_irq() function, and defer the rest until
> the machine descriptor's .init_machine() function. With arch/arm calling
> of_clk_init(NULL) from time_init() this also allows the removal of
> .init_time() hook.

Sebastian, I assume you're targeting v3.13 or later for this patch
series? If so, it might be a good idea if I apply this patch myself to
the Tegra tree so that I can base any future Tegra patches on top of it
to avoid any possible conflicts. I can put this patch first in the
cleanup branch so you can merge it into whatever tree you use for the
rest of this series. Does that work for you? If so, let me know. Thanks.

2013-09-12 06:22:07

by Sebastian Hesselbarth

[permalink] [raw]
Subject: Re: [PATCH RFC v2 13/16] ARM: tegra: split tegra_pmc_init() in two

On 09/11/2013 09:56 PM, Stephen Warren wrote:
> On 08/27/2013 03:28 PM, Sebastian Hesselbarth wrote:
>> From: Stephen Warren <[email protected]>
>>
>> Tegra's board file currently initializes clocks much earlier than those
>> for most other ARM SoCs. The reason is:
>>
>> * The PMC HW block is involved in the path of some interrupts (i.e. it
>> inverts, or not, the IRQ input pin dedicated to the PMIC).
>>
>> * So, that part of the PMC must be initialized early so that the IRQ
>> polarity is correct.
>>
>> * The PMC initialization is currently monolithic, and the PMC has some
>> clock inputs, so the init routine ends up calling of_clk_get_by_name(),
>> and hence clocks must be set up early too.
>>
>> In order to defer clock initialization to the more typical location,
>> split out the portions of tegra_pmc_init() that are truly IRQ-related
>> into a separate tegra_pmc_init_irq(), which can be called from the
>> machine descriptor's .init_irq() function, and defer the rest until
>> the machine descriptor's .init_machine() function. With arch/arm calling
>> of_clk_init(NULL) from time_init() this also allows the removal of
>> .init_time() hook.
>
> Sebastian, I assume you're targeting v3.13 or later for this patch
> series? If so, it might be a good idea if I apply this patch myself to
> the Tegra tree so that I can base any future Tegra patches on top of it
> to avoid any possible conflicts. I can put this patch first in the
> cleanup branch so you can merge it into whatever tree you use for the
> rest of this series. Does that work for you? If so, let me know. Thanks.

Yes, I was waiting for v3.12-rc1 to drop to have something stable with
the new machs inside. I haven't made up my mind who will finally take
the patches but I guess it's either arm-soc or each individual
maintainer.

Currently, the patch set includes your original patch and another one to
remove .init_time when the arch-wide default callback is available. If
you want to take it now, I can add the corresponding dependency to the
cover letter and drop the patch from my set.

If Arnd, Olof, and Mike say that current mainline head is stable with
respect to arm-soc and clk, I can also send it today or tomorrow.

Sebastian

2013-09-12 16:32:31

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH RFC v2 13/16] ARM: tegra: split tegra_pmc_init() in two

On 09/12/2013 12:21 AM, Sebastian Hesselbarth wrote:
> On 09/11/2013 09:56 PM, Stephen Warren wrote:
>> On 08/27/2013 03:28 PM, Sebastian Hesselbarth wrote:
>>> From: Stephen Warren <[email protected]>
>>>
>>> Tegra's board file currently initializes clocks much earlier than those
>>> for most other ARM SoCs. The reason is:
>>>
>>> * The PMC HW block is involved in the path of some interrupts (i.e. it
>>> inverts, or not, the IRQ input pin dedicated to the PMIC).
>>>
>>> * So, that part of the PMC must be initialized early so that the IRQ
>>> polarity is correct.
>>>
>>> * The PMC initialization is currently monolithic, and the PMC has some
>>> clock inputs, so the init routine ends up calling of_clk_get_by_name(),
>>> and hence clocks must be set up early too.
>>>
>>> In order to defer clock initialization to the more typical location,
>>> split out the portions of tegra_pmc_init() that are truly IRQ-related
>>> into a separate tegra_pmc_init_irq(), which can be called from the
>>> machine descriptor's .init_irq() function, and defer the rest until
>>> the machine descriptor's .init_machine() function. With arch/arm calling
>>> of_clk_init(NULL) from time_init() this also allows the removal of
>>> .init_time() hook.
>>
>> Sebastian, I assume you're targeting v3.13 or later for this patch
>> series? If so, it might be a good idea if I apply this patch myself to
>> the Tegra tree so that I can base any future Tegra patches on top of it
>> to avoid any possible conflicts. I can put this patch first in the
>> cleanup branch so you can merge it into whatever tree you use for the
>> rest of this series. Does that work for you? If so, let me know. Thanks.
>
> Yes, I was waiting for v3.12-rc1 to drop to have something stable with
> the new machs inside. I haven't made up my mind who will finally take
> the patches but I guess it's either arm-soc or each individual
> maintainer.

OK, I'll take this one patch through the Tegra tree, making sure it's
first and based on v3.12-rc1, and I'll create a tag for you to pull into
your branch as needed.

> Currently, the patch set includes your original patch and another one to
> remove .init_time when the arch-wide default callback is available. If
> you want to take it now, I can add the corresponding dependency to the
> cover letter and drop the patch from my set.

Sounds good. From memory, that second patch you mentioned can go through
any tree you want; I don't think it will cause any conflicts since it's
tiny.