ARM: shmobile: kzm9g-reference: enable TWD
Subsystems (5)
cover ARM: shmobile: kzm9g-reference: enable TWD
The first patch in this series is required for the result to work, but is modifying a generic driver, so, it should be considered separately, and if accepted, it can be applied separately too. Patches 2 and 3 are RFC, because I'm not sure, whether this is indeed the right way to enable TWD on kzm9g-reference.
Guennadi Liakhovetski (3):
ARM: also support TWD clock, instantiated from platform data
ARM: shmobile: initialise clock early on kzm9g-reference
ARM: shmobile: kzm9g-reference: add a TWD DT node
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts | 7 +++++++ arch/arm/kernel/smp_twd.c | 2 +- arch/arm/mach-shmobile/board-kzm9g-reference.c | 8 +++++++- arch/arm/mach-shmobile/setup-sh73a0.c | 13 +++++++++---- 4 files changed, 24 insertions(+), 6 deletions(-)
Signature · 8 lines
1.7.2.5 Thanks Guennadi --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/
PATCH 1/3 ARM: also support TWD clock, instantiated from platform data
While gradually switching clock initialisation to DT some architectures can have TWD device in DT, but supplying clock initialised from platform data. This patch adds support for such configurations to ARM.
--- arch/arm/kernel/smp_twd.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/kernel/smp_twd.c +1 -1
@@ -244,7 +244,7 @@ static void twd_get_clock(struct device_node *np)if (np) twd_clk =of_clk_get (np,0 ); -else +if (IS_ERR (twd_clk)) twd_clk =clk_get_sys ("smp_twd" ,NULL );if (IS_ERR (twd_clk)) {
Signature · 1 line
1.7.2.5
PATCH 1/3 ARM: also support TWD clock, instantiated from platform data
Quoted 6 lines · Guennadi Liakhovetski
While gradually switching clock initialisation to DT some architectures can have TWD device in DT, but supplying clock initialised from platform data. This patch adds support for such configurations to ARM.
Signed-off-by Guennadi Liakhovetski <[email protected]>Cc Russell King <[email protected]>
Quoted 20 lines
--- arch/arm/kernel/smp_twd.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/arm/kernel/smp_twd.c +1
-1@@ -244,7 +244,7 @@ static void twd_get_clock(struct device_node *np)if (np) twd_clk =of_clk_get (np,0 ); -else +if (IS_ERR (twd_clk)) twd_clk =clk_get_sys ("smp_twd" ,NULL );if (IS_ERR (twd_clk)) {Signature · 1 line
1.7.2.5
PATCH 1/3 ARM: also support TWD clock, instantiated from platform data
In reply to Guennadi LiakhovetskiQuoted 3 lines · Guennadi Liakhovetski
While gradually switching clock initialisation to DT some architectures can have TWD device in DT, but supplying clock initialised from platform data. This patch adds support for such configurations to ARM.
Why can't you fix the clock problem at the same time - or sort out the clock problem first and then add a DT description for TWD?
PATCH 2/3 ARM: shmobile: initialise clock early on kzm9g-reference
In reply to Guennadi LiakhovetskiTo prepare to enable TWD on kzm9g-reference, clock initialisation has to be done early. Move it from .init_machine to .init_time stage.
--- arch/arm/mach-shmobile/board-kzm9g-reference.c | 8 +++++++- arch/arm/mach-shmobile/setup-sh73a0.c | 13 +++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-)
arch/arm/mach-shmobile/board-kzm9g-reference.c +7 -1
@@ -90,6 +90,12 @@ static void __init kzm_init(void)#endif } +static void __init timer_init (void ) +{ +sh73a0_clock_init (); +shmobile_timer_init (); +} +static const char *kzm9g_boards_compat_dt[]__initdata = {"renesas,kzm9g-reference" ,NULL ,
@@ -102,6 +108,6 @@ DT_MACHINE_START(KZM9G_DT, "kzm9g-reference") .nr_irqs = NR_IRQS_LEGACY, .init_irq = irqchip_init, .init_machine = kzm_init, - .init_time = shmobile_timer_init, + .init_time = timer_init, .dt_compat = kzm9g_boards_compat_dt,MACHINE_END
arch/arm/mach-shmobile/setup-sh73a0.c +9 -4
@@ -1018,9 +1018,6 @@ void __init sh73a0_add_standard_devices_dt(void) {struct platform_device_info devinfo = { .name ="cpufreq-cpu0" , .id =-1 , }; -/* clocks are setup late during boot in the case of DT */ -sh73a0_clock_init (); -platform_add_devices (sh73a0_devices_dt,ARRAY_SIZE (sh73a0_devices_dt)); of_platform_populate(NULL, of_default_bus_match_table,
@@ -1030,6 +1027,14 @@ void __init sh73a0_add_standard_devices_dt(void)platform_device_register_full (&devinfo); } +static void __init add_standard_devices (void ) +{ +/* clocks are setup late during boot in the case of DT */ +sh73a0_clock_init (); + +sh73a0_add_standard_devices_dt (); +} +static const char *sh73a0_boards_compat_dt[]__initdata = {"renesas,sh73a0" ,NULL ,
@@ -1041,7 +1046,7 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)") .init_early = sh73a0_init_delay, .nr_irqs = NR_IRQS_LEGACY, .init_irq = irqchip_init, - .init_machine = sh73a0_add_standard_devices_dt, + .init_machine = add_standard_devices, .init_time = shmobile_timer_init, .dt_compat = sh73a0_boards_compat_dt,MACHINE_END
Signature · 1 line
1.7.2.5
PATCH 2/3 ARM: shmobile: initialise clock early on kzm9g-reference
Hi Guennadi
Quoted 5 lines
To prepare to enable TWD on kzm9g-reference, clock initialisation has to be done early. Move it from .init_machine to .init_time stage.
Signed-off-by Guennadi Liakhovetski <[email protected]>---
(snip)
arch/arm/mach-shmobile/board-kzm9g-reference.c static void __init kzm_init(void) · line 97
Quoted 5 lines
arch/arm/mach-shmobile/board-kzm9g-reference.c +5
-0+static void __init timer_init (void ) +{ +sh73a0_clock_init (); +shmobile_timer_init (); +}
I'm not sure detail,
but, shmobile_timer_init() will be removed.
Can you check these patch/email on SH-ML or ARM ML ?
Subject: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
Date: Mon, 1 Apr 2013 17:21:12 -0500
Subject: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
Date: Mon, 1 Apr 2013 17:21:12 -0500
Best regards
---
Kuninori Morimoto
PATCH 2/3 ARM: shmobile: initialise clock early on kzm9g-reference
Hi Morimoto-san
Quoted 17 lines · Kuninori Morimoto
Hi Guennadi
Quoted 5 lines
To prepare to enable TWD on kzm9g-reference, clock initialisation has to be done early. Move it from .init_machine to .init_time stage.
Signed-off-by Guennadi Liakhovetski <[email protected]>---
(snip)
arch/arm/mach-shmobile/board-kzm9g-reference.c static void __init kzm_init(void) · line 97
Quoted 5 lines
arch/arm/mach-shmobile/board-kzm9g-reference.c +5
-0+static void __init timer_init (void ) +{ +sh73a0_clock_init (); +shmobile_timer_init (); +}I'm not sure detail,
but,shmobile_timer_init()will be removed.
Quoted 7 lines
Can you check these patch/email on SH-ML or ARM ML ?
Subject: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use
CLKSRC_OFinit
Date: Mon, 1 Apr 2013 17:21:12 -0500Subject: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use
CLKSRC_OFinit
Date: Mon, 1 Apr 2013 17:21:12 -0500
Did you mean two different patches or was the duplication an accident? Anyway, thanks for a heads-up! I checked that patch, interesting. At least it's conflicting with this patch from Magnus:
"ARM: shmobile: Register DT TWD from timer.c"
https://patchwork.kernel.org/patch/2222551/
I know those patches are on a hold, but I was using the one above locally. If shmobile_timer_init() is removed, this won't be a huge problem for this work, I'll just have to call twd_local_timer_of_register() directly from .init_time, but whether these patches are good for upstream at all is another question, I'll expand on it a bit in a reply to Simon's mail.
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
PATCH 2/3 ARM: shmobile: initialise clock early on kzm9g-reference
Hi Guennadi
Quoted 7 lines
Quoted 5 lines
Subject: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use
CLKSRC_OFinit
Date: Mon, 1 Apr 2013 17:21:12 -0500Subject: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use
CLKSRC_OFinit
Date: Mon, 1 Apr 2013 17:21:12 -0500Did you mean two different patches or was the duplication an accident?
Sorry, it was my copy-paste fault
Quoted 11 lines
Anyway, thanks for a heads-up! I checked that patch, interesting. At least it's conflicting with this patch from Magnus:
"ARM: shmobile: Register DT TWD from
timer.c"
https://patchwork.kernel.org/patch/2222551/I know those patches are on a hold, but I was using the one above locally. If
shmobile_timer_init()is removed, this won't be a huge problem for this work, I'll just have to calltwd_local_timer_of_register()directly from .init_time, but whether these patches are good for upstream at all is another question, I'll expand on it a bit in a reply to Simon's mail.
Thank you for your help !
Best regards
---
Kuninori Morimoto
PATCH 2/3 ARM: shmobile: initialise clock early on kzm9g-reference
In reply to Guennadi LiakhovetskiQuoted 2 lines · Guennadi Liakhovetski
To prepare to enable TWD on kzm9g-reference, clock initialisation has to be done early. Move it from .init_machine to .init_time stage.
I'm pretty surprised by this given how much effort has been made to avoid early clock initialisation.
Quoted 78 lines
Signed-off-by Guennadi Liakhovetski <[email protected]>--- arch/arm/mach-shmobile/board-kzm9g-reference.c | 8 +++++++- arch/arm/mach-shmobile/setup-sh73a0.c | 13 +++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-)arch/arm/mach-shmobile/board-kzm9g-reference.c +7
-1@@ -90,6 +90,12 @@ static void __init kzm_init(void)#endif } +static void __init timer_init (void ) +{ +sh73a0_clock_init (); +shmobile_timer_init (); +} +static const char *kzm9g_boards_compat_dt[]__initdata = {"renesas,kzm9g-reference" ,NULL ,@@ -102,6 +108,6 @@ DT_MACHINE_START(KZM9G_DT, "kzm9g-reference") .nr_irqs = NR_IRQS_LEGACY, .init_irq = irqchip_init, .init_machine = kzm_init, - .init_time = shmobile_timer_init, + .init_time = timer_init, .dt_compat = kzm9g_boards_compat_dt,MACHINE_END arch/arm/mach-shmobile/setup-sh73a0.c +9
-4@@ -1018,9 +1018,6 @@ void __init sh73a0_add_standard_devices_dt(void) {struct platform_device_info devinfo = { .name ="cpufreq-cpu0" , .id =-1 , }; -/* clocks are setup late during boot in the case of DT */ -sh73a0_clock_init (); -platform_add_devices (sh73a0_devices_dt,ARRAY_SIZE (sh73a0_devices_dt)); of_platform_populate(NULL, of_default_bus_match_table,@@ -1030,6 +1027,14 @@ void __init sh73a0_add_standard_devices_dt(void)platform_device_register_full (&devinfo); } +static void __init add_standard_devices (void ) +{ +/* clocks are setup late during boot in the case of DT */ +sh73a0_clock_init (); + +sh73a0_add_standard_devices_dt (); +} +static const char *sh73a0_boards_compat_dt[]__initdata = {"renesas,sh73a0" ,NULL ,@@ -1041,7 +1046,7 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)") .init_early = sh73a0_init_delay, .nr_irqs = NR_IRQS_LEGACY, .init_irq = irqchip_init, - .init_machine = sh73a0_add_standard_devices_dt, + .init_machine = add_standard_devices, .init_time = shmobile_timer_init, .dt_compat = sh73a0_boards_compat_dt,MACHINE_END Signature · 6 lines
1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/3 ARM: shmobile: initialise clock early on kzm9g-reference
Hi Simon
Quoted 6 lines · Simon Horman
Quoted 2 lines · Guennadi Liakhovetski
To prepare to enable TWD on kzm9g-reference, clock initialisation has to be done early. Move it from .init_machine to .init_time stage.
I'm pretty surprised by this given how much effort has been made to avoid early clock initialisation.
Yes, sorry, I probably failed to explain exactly the meaning of "RFC" in these patches. My goal was to find a way to activate the TWD on kzm9g in the "-reference" configuration, i.e. with DT, when TWD is also instantiated as a DT node. This didn't work out of the box by simply adding the respective DT node as in patch/rfc #3 in this series. Doing that just resulted in a lock up with no output. The reason was, that TWD was trying to initialise before any other timers / clocks and its calibration in twd_calibrate_rate() was cycling endlessly. So, I tried to find a way to fix this lock-up, which produced these RFCs. I'm perfectly aware, that this might not be what we want to have in the mainline, this is just an illustration, what I had to do to get TWD running with DT.
As for "avoid early clock initialisation" - I'm aware of this goal in principle, but I'm not sure about details - how early is too early and when it is already allowed, why is this important with DT and not with legacy (because we want to initialise all clocks from DT?), what are proper ways to solve problems like this one? Note, that TWD has to be registered before secondary_start_kernel() is run. So, we need a clocksource before that time for a successful TWD calibration.
Thanks
Guennadi
Quoted 72 lines
Quoted 72 lines
Signed-off-by Guennadi Liakhovetski <[email protected]>--- arch/arm/mach-shmobile/board-kzm9g-reference.c | 8 +++++++- arch/arm/mach-shmobile/setup-sh73a0.c | 13 +++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-)arch/arm/mach-shmobile/board-kzm9g-reference.c +7
-1@@ -90,6 +90,12 @@ static void __init kzm_init(void)#endif } +static void __init timer_init (void ) +{ +sh73a0_clock_init (); +shmobile_timer_init (); +} +static const char *kzm9g_boards_compat_dt[]__initdata = {"renesas,kzm9g-reference" ,NULL ,@@ -102,6 +108,6 @@ DT_MACHINE_START(KZM9G_DT, "kzm9g-reference") .nr_irqs = NR_IRQS_LEGACY, .init_irq = irqchip_init, .init_machine = kzm_init, - .init_time = shmobile_timer_init, + .init_time = timer_init, .dt_compat = kzm9g_boards_compat_dt,MACHINE_END arch/arm/mach-shmobile/setup-sh73a0.c +9
-4@@ -1018,9 +1018,6 @@ void __init sh73a0_add_standard_devices_dt(void) {struct platform_device_info devinfo = { .name ="cpufreq-cpu0" , .id =-1 , }; -/* clocks are setup late during boot in the case of DT */ -sh73a0_clock_init (); -platform_add_devices (sh73a0_devices_dt,ARRAY_SIZE (sh73a0_devices_dt)); of_platform_populate(NULL, of_default_bus_match_table,@@ -1030,6 +1027,14 @@ void __init sh73a0_add_standard_devices_dt(void)platform_device_register_full (&devinfo); } +static void __init add_standard_devices (void ) +{ +/* clocks are setup late during boot in the case of DT */ +sh73a0_clock_init (); + +sh73a0_add_standard_devices_dt (); +} +static const char *sh73a0_boards_compat_dt[]__initdata = {"renesas,sh73a0" ,NULL ,@@ -1041,7 +1046,7 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)") .init_early = sh73a0_init_delay, .nr_irqs = NR_IRQS_LEGACY, .init_irq = irqchip_init, - .init_machine = sh73a0_add_standard_devices_dt, + .init_machine = add_standard_devices, .init_time = shmobile_timer_init, .dt_compat = sh73a0_boards_compat_dt,MACHINE_END Signature · 1 line
1.7.2.5
Quoted 6 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
PATCH 2/3 ARM: shmobile: initialise clock early on kzm9g-reference
Quoted 11 lines · Guennadi Liakhovetski
Hi Simon
Quoted 6 lines · Simon Horman
Quoted 2 lines · Guennadi Liakhovetski
To prepare to enable TWD on kzm9g-reference, clock initialisation has to be done early. Move it from .init_machine to .init_time stage.
I'm pretty surprised by this given how much effort has been made to avoid early clock initialisation.
Quoted 11 lines
Yes, sorry, I probably failed to explain exactly the meaning of "RFC" in these patches. My goal was to find a way to activate the TWD on kzm9g in the "-reference" configuration, i.e. with DT, when TWD is also instantiated as a DT node. This didn't work out of the box by simply adding the respective DT node as in patch/rfc #3 in this series. Doing that just resulted in a lock up with no output. The reason was, that TWD was trying to initialise before any other timers / clocks and its calibration in
twd_calibrate_rate()was cycling endlessly. So, I tried to find a way to fix this lock-up, which produced these RFCs. I'm perfectly aware, that this might not be what we want to have in the mainline, this is just an illustration, what I had to do to get TWD running with DT.
Thanks for the clarification, I understand.
Quoted 7 lines
As for "avoid early clock initialisation" - I'm aware of this goal in principle, but I'm not sure about details - how early is too early and when it is already allowed, why is this important with DT and not with legacy (because we want to initialise all clocks from DT?), what are proper ways to solve problems like this one? Note, that TWD has to be registered before
secondary_start_kernel()is run. So, we need a clocksource before that time for a successful TWD calibration.
I wonder if this problem can be resolved using init priorities?
In general I believe the idea is that early clocks can and should be avoided because they should not be necessary. If they are necessary in some cases then I assume we will use them.
Magnus, can you clarify this?
Quoted 91 lines
Thanks
GuennadiQuoted 72 lines
Quoted 72 lines
Signed-off-by Guennadi Liakhovetski <[email protected]>--- arch/arm/mach-shmobile/board-kzm9g-reference.c | 8 +++++++- arch/arm/mach-shmobile/setup-sh73a0.c | 13 +++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-)arch/arm/mach-shmobile/board-kzm9g-reference.c +7
-1@@ -90,6 +90,12 @@ static void __init kzm_init(void)#endif } +static void __init timer_init (void ) +{ +sh73a0_clock_init (); +shmobile_timer_init (); +} +static const char *kzm9g_boards_compat_dt[]__initdata = {"renesas,kzm9g-reference" ,NULL ,@@ -102,6 +108,6 @@ DT_MACHINE_START(KZM9G_DT, "kzm9g-reference") .nr_irqs = NR_IRQS_LEGACY, .init_irq = irqchip_init, .init_machine = kzm_init, - .init_time = shmobile_timer_init, + .init_time = timer_init, .dt_compat = kzm9g_boards_compat_dt,MACHINE_END arch/arm/mach-shmobile/setup-sh73a0.c +9
-4@@ -1018,9 +1018,6 @@ void __init sh73a0_add_standard_devices_dt(void) {struct platform_device_info devinfo = { .name ="cpufreq-cpu0" , .id =-1 , }; -/* clocks are setup late during boot in the case of DT */ -sh73a0_clock_init (); -platform_add_devices (sh73a0_devices_dt,ARRAY_SIZE (sh73a0_devices_dt)); of_platform_populate(NULL, of_default_bus_match_table,@@ -1030,6 +1027,14 @@ void __init sh73a0_add_standard_devices_dt(void)platform_device_register_full (&devinfo); } +static void __init add_standard_devices (void ) +{ +/* clocks are setup late during boot in the case of DT */ +sh73a0_clock_init (); + +sh73a0_add_standard_devices_dt (); +} +static const char *sh73a0_boards_compat_dt[]__initdata = {"renesas,sh73a0" ,NULL ,@@ -1041,7 +1046,7 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)") .init_early = sh73a0_init_delay, .nr_irqs = NR_IRQS_LEGACY, .init_irq = irqchip_init, - .init_machine = sh73a0_add_standard_devices_dt, + .init_machine = add_standard_devices, .init_time = shmobile_timer_init, .dt_compat = sh73a0_boards_compat_dt,MACHINE_END Signature · 1 line
1.7.2.5Quoted 6 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/3 ARM: shmobile: kzm9g-reference: add a TWD DT node
In reply to Guennadi LiakhovetskiThis patch enables the use of TWD on kzm9g-reference.
--- arch/arm/boot/dts/sh73a0-kzm9g-reference.dts | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts +7 -0
@@ -40,6 +40,13 @@ reg = <0x41000000 0x1e800000>; }; + timer at f0000600 { + compatible = "arm,cortex-a9-twd-timer"; + reg = <0xf0000600 0x20>; + interrupt-parent = <&gic>; + interrupts = <1 13 0x4>; + }; + reg_1p8v: regulator at 0 { compatible = "regulator-fixed"; regulator-name = "fixed-1.8V";
Signature · 1 line
1.7.2.5