ARM: shmobile: Break out and extend clock workaround
Magnus Damm
maintainercover ARM: shmobile: Break out and extend clock workaround
ARM: shmobile: Break out and extend clock workaround
[PATCH 01/03] ARM: shmobile: Introduce shmobile_clk_workaround() [PATCH 02/03] ARM: shmobile: Use shmobile_clk_workaround() on Lager [PATCH 03/03] ARM: shmobile: Use shmobile_clk_workaround() on Koelsch
These patches consolidates the clkdev workaround present in the DT reference version of board code for Lager and Koelsch, and it also extends it to allow static enablement of a selected set of clocks during boot. The latter is needed for USB PCI support patches that will be posted shortly.
---
Written against renesas.git tag renesas-devel-v3.14-rc3-20140224 on top of "[PATCH 00/12] ARM: shmobile: Rework include path for SoC files"
arch/arm/mach-shmobile/Makefile | 2 arch/arm/mach-shmobile/board-koelsch-reference.c | 71 ++++++++-------------- arch/arm/mach-shmobile/board-lager-reference.c | 65 +++++++------------- arch/arm/mach-shmobile/clock.c | 29 ++++++++ arch/arm/mach-shmobile/include/mach/clock.h | 16 ++++ 5 files changed, 99 insertions(+), 84 deletions(-)
Magnus Damm
maintainerPATCH 1/3 ARM: shmobile: Introduce shmobile_clk_workaround()
From: Magnus Damm <[email protected]>
Introduce a new clock workaround function used by DT reference code on the mach-shmobile subarchitecture. The new function shmobile_clk_workaround() is used to configure clkdev to allow DT and platform devices to coexist. It is possible for the DT reference board code to also request enabling of the clock in case the driver does not implement clock control.
---
arch/arm/mach-shmobile/Makefile | 2 - arch/arm/mach-shmobile/clock.c | 29 +++++++++++++++++++++++++++ arch/arm/mach-shmobile/include/mach/clock.h | 16 ++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-)
arch/arm/mach-shmobile/Makefile +1 -1
@@ -23,8 +23,8 @@ obj-$(CONFIG_ARCH_EMEV2) += setup-emev2. obj-$(CONFIG_ARCH_R7S72100) += setup-r7s72100.o # Clock objects -ifndef CONFIG_COMMON_CLK obj-y += clock.o +ifndef CONFIG_COMMON_CLK obj-$(CONFIG_ARCH_SH7372) += clock-sh7372.o obj-$(CONFIG_ARCH_SH73A0) += clock-sh73a0.o obj-$(CONFIG_ARCH_R8A73A4) += clock-r8a73a4.o
arch/arm/mach-shmobile/clock.c +29 -0
@@ -21,6 +21,32 @@*/ #include <linux/kernel.h> #include <linux/init.h> + +#ifdef CONFIG_COMMON_CLK +#include <linux/clk.h> +#include <linux/clkdev.h> +#include "clock.h" + +void __init shmobile_clk_workaround (const struct clk_name *clks, +int nr_clks,bool enable) +{ +const struct clk_name *clkn; +struct clk *clk; +unsigned int i; + +for (i =0 ; i < nr_clks; ++i) { + clkn = clks + i; + clk =clk_get (NULL , clkn->clk); +if (!IS_ERR (clk)) { +clk_register_clkdev (clk, clkn->con_id, clkn->dev_id); +if (enable) +clk_prepare_enable (clk); +clk_put (clk); + } + } +} + +#else /* CONFIG_COMMON_CLK */ #include <linux/sh_clk.h> #include <linux/export.h> #include "clock.h"
@@ -58,3 +84,6 @@ void __clk_put(struct clk *clk) { }EXPORT_SYMBOL (__clk_put); + +#endif /* CONFIG_COMMON_CLK */ +
arch/arm/mach-shmobile/include/mach/clock.h +16 -0
@@ -1,6 +1,21 @@#ifndef CLOCK_H #define CLOCK_H +#ifdef CONFIG_COMMON_CLK +/* temporary clock configuration helper for platform devices */ + +struct clk_name { +const char *clk; +const char *con_id; +const char *dev_id; +}; + +void shmobile_clk_workaround (const struct clk_name *clks,int nr_clks, +bool enable); + +#else /* CONFIG_COMMON_CLK */ +/* legacy clock implementation */ +unsigned long shmobile_fixed_ratio_clk_recalc (struct clk *clk);extern struct sh_clk_ops shmobile_fixed_ratio_clk_ops;
@@ -36,4 +51,5 @@ do { \ (p)->div = d; \ } while (0) +#endif /* CONFIG_COMMON_CLK */ #endif
Magnus Damm
maintainerPATCH 2/3 ARM: shmobile: Use shmobile_clk_workaround() on Lager
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Convert the Lager DT reference code to use the newly introduced function shmobile_clk_workaround().
---
arch/arm/mach-shmobile/board-lager-reference.c | 65 +++++++++--------------- 1 file changed, 25 insertions(+), 40 deletions(-)
arch/arm/mach-shmobile/board-lager-reference.c +25 -40
@@ -18,12 +18,11 @@* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <linux/clk.h> -#include <linux/clkdev.h> #include <linux/dma-mapping.h> #include <linux/init.h> #include <linux/of_platform.h> #include <linux/platform_data/rcar-du.h> +#include <mach/clock.h> #include <mach/common.h> #include <mach/irqs.h> #include <mach/rcar-gen2.h>
@@ -86,46 +85,32 @@ static void __init lager_add_du_device(vplatform_device_register_full (&info); } +/* +* This is a really crude hack to provide clkdev support to platform +* devices until they get moved to DT. +*/ +static const struct clk_name clk_names[] = { + {"cmt0" ,NULL ,"sh_cmt.0" }, + {"scifa0" ,NULL ,"sh-sci.0" }, + {"scifa1" ,NULL ,"sh-sci.1" }, + {"scifb0" ,NULL ,"sh-sci.2" }, + {"scifb1" ,NULL ,"sh-sci.3" }, + {"scifb2" ,NULL ,"sh-sci.4" }, + {"scifa2" ,NULL ,"sh-sci.5" }, + {"scif0" ,NULL ,"sh-sci.6" }, + {"scif1" ,NULL ,"sh-sci.7" }, + {"hscif0" ,NULL ,"sh-sci.8" }, + {"hscif1" ,NULL ,"sh-sci.9" }, + {"du0" ,"du.0" ,"rcar-du-r8a7790" }, + {"du1" ,"du.1" ,"rcar-du-r8a7790" }, + {"du2" ,"du.2" ,"rcar-du-r8a7790" }, + {"lvds0" ,"lvds.0" ,"rcar-du-r8a7790" }, + {"lvds1" ,"lvds.1" ,"rcar-du-r8a7790" }, +}; +static void __init lager_add_standard_devices (void ) { -/* -* This is a really crude hack to provide clkdev support to platform -* devices until they get moved to DT. -*/ -static const struct clk_name { -const char *clk; -const char *con_id; -const char *dev_id; - } clk_names[] = { - {"cmt0" ,NULL ,"sh_cmt.0" }, - {"scifa0" ,NULL ,"sh-sci.0" }, - {"scifa1" ,NULL ,"sh-sci.1" }, - {"scifb0" ,NULL ,"sh-sci.2" }, - {"scifb1" ,NULL ,"sh-sci.3" }, - {"scifb2" ,NULL ,"sh-sci.4" }, - {"scifa2" ,NULL ,"sh-sci.5" }, - {"scif0" ,NULL ,"sh-sci.6" }, - {"scif1" ,NULL ,"sh-sci.7" }, - {"hscif0" ,NULL ,"sh-sci.8" }, - {"hscif1" ,NULL ,"sh-sci.9" }, - {"du0" ,"du.0" ,"rcar-du-r8a7790" }, - {"du1" ,"du.1" ,"rcar-du-r8a7790" }, - {"du2" ,"du.2" ,"rcar-du-r8a7790" }, - {"lvds0" ,"lvds.0" ,"rcar-du-r8a7790" }, - {"lvds1" ,"lvds.1" ,"rcar-du-r8a7790" }, - }; -struct clk *clk; -unsigned int i; - -for (i =0 ; i <ARRAY_SIZE (clk_names); ++i) { - clk =clk_get (NULL , clk_names[i].clk); -if (!IS_ERR (clk)) { -clk_register_clkdev (clk, clk_names[i].con_id, - clk_names[i].dev_id); -clk_put (clk); - } - } - +shmobile_clk_workaround (clk_names,ARRAY_SIZE (clk_names), false);r8a7790_add_dt_devices ();of_platform_populate (NULL , of_default_bus_match_table,NULL ,NULL );
Magnus Damm
maintainerPATCH 3/3 ARM: shmobile: Use shmobile_clk_workaround() on Koelsch
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Convert the Koelsch DT reference code to use the newly introduced function shmobile_clk_workaround().
---
arch/arm/mach-shmobile/board-koelsch-reference.c | 71 ++++++++-------------- 1 file changed, 28 insertions(+), 43 deletions(-)
arch/arm/mach-shmobile/board-koelsch-reference.c +28 -43
@@ -19,12 +19,11 @@* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <linux/clk.h> -#include <linux/clkdev.h> #include <linux/dma-mapping.h> #include <linux/kernel.h> #include <linux/of_platform.h> #include <linux/platform_data/rcar-du.h> +#include <mach/clock.h> #include <mach/common.h> #include <mach/irqs.h> #include <mach/rcar-gen2.h>
@@ -82,49 +81,35 @@ static void __init koelsch_add_du_deviceplatform_device_register_full (&info); } +/* +* This is a really crude hack to provide clkdev support to platform +* devices until they get moved to DT. +*/ +static const struct clk_name clk_names[] = { + {"cmt0" ,NULL ,"sh_cmt.0" }, + {"scifa0" ,NULL ,"sh-sci.0" }, + {"scifa1" ,NULL ,"sh-sci.1" }, + {"scifb0" ,NULL ,"sh-sci.2" }, + {"scifb1" ,NULL ,"sh-sci.3" }, + {"scifb2" ,NULL ,"sh-sci.4" }, + {"scifa2" ,NULL ,"sh-sci.5" }, + {"scif0" ,NULL ,"sh-sci.6" }, + {"scif1" ,NULL ,"sh-sci.7" }, + {"scif2" ,NULL ,"sh-sci.8" }, + {"scif3" ,NULL ,"sh-sci.9" }, + {"scif4" ,NULL ,"sh-sci.10" }, + {"scif5" ,NULL ,"sh-sci.11" }, + {"scifa3" ,NULL ,"sh-sci.12" }, + {"scifa4" ,NULL ,"sh-sci.13" }, + {"scifa5" ,NULL ,"sh-sci.14" }, + {"du0" ,"du.0" ,"rcar-du-r8a7791" }, + {"du1" ,"du.1" ,"rcar-du-r8a7791" }, + {"lvds0" ,"lvds.0" ,"rcar-du-r8a7791" }, +}; +static void __init koelsch_add_standard_devices (void ) { -/* -* This is a really crude hack to provide clkdev support to the CMT and -* DU devices until they get moved to DT. -*/ -static const struct clk_name { -const char *clk; -const char *con_id; -const char *dev_id; - } clk_names[] = { - {"cmt0" ,NULL ,"sh_cmt.0" }, - {"scifa0" ,NULL ,"sh-sci.0" }, - {"scifa1" ,NULL ,"sh-sci.1" }, - {"scifb0" ,NULL ,"sh-sci.2" }, - {"scifb1" ,NULL ,"sh-sci.3" }, - {"scifb2" ,NULL ,"sh-sci.4" }, - {"scifa2" ,NULL ,"sh-sci.5" }, - {"scif0" ,NULL ,"sh-sci.6" }, - {"scif1" ,NULL ,"sh-sci.7" }, - {"scif2" ,NULL ,"sh-sci.8" }, - {"scif3" ,NULL ,"sh-sci.9" }, - {"scif4" ,NULL ,"sh-sci.10" }, - {"scif5" ,NULL ,"sh-sci.11" }, - {"scifa3" ,NULL ,"sh-sci.12" }, - {"scifa4" ,NULL ,"sh-sci.13" }, - {"scifa5" ,NULL ,"sh-sci.14" }, - {"du0" ,"du.0" ,"rcar-du-r8a7791" }, - {"du1" ,"du.1" ,"rcar-du-r8a7791" }, - {"lvds0" ,"lvds.0" ,"rcar-du-r8a7791" }, - }; -struct clk *clk; -unsigned int i; - -for (i =0 ; i <ARRAY_SIZE (clk_names); ++i) { - clk =clk_get (NULL , clk_names[i].clk); -if (!IS_ERR (clk)) { -clk_register_clkdev (clk, clk_names[i].con_id, - clk_names[i].dev_id); -clk_put (clk); - } - } - +shmobile_clk_workaround (clk_names,ARRAY_SIZE (clk_names), false);r8a7791_add_dt_devices ();of_platform_populate (NULL , of_default_bus_match_table,NULL ,NULL );
PATCH 1/3 ARM: shmobile: Introduce shmobile_clk_workaround()
In reply to Magnus DammQuoted 10 lines · Magnus Damm
From: Magnus Damm <[email protected]>
Introduce a new clock workaround function used by DT reference code on the mach-shmobile subarchitecture. The new function
shmobile_clk_workaround()is used to configure clkdev to allow DT and platform devices to coexist. It is possible for the DT reference board code to also request enabling of the clock in case the driver does not implement clock control.Signed-off-by Magnus Damm <[email protected]>
I use it for r7s72100, too, meanwhile.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140228/821c79f8/attachment.sig>
cover ARM: shmobile: Break out and extend clock workaround
In reply to Magnus DammQuoted 6 lines · Magnus Damm
ARM: shmobile: Break out and extend clock workaround
[PATCH 01/03] ARM: shmobile: Introduce
shmobile_clk_workaround()[PATCH 02/03] ARM: shmobile: Useshmobile_clk_workaround()on Lager [PATCH 03/03] ARM: shmobile: Useshmobile_clk_workaround()on Koelsch
Quoted 7 lines
These patches consolidates the clkdev workaround present in the DT reference version of board code for Lager and Koelsch, and it also extends it to allow static enablement of a selected set of clocks during boot. The latter is needed for USB PCI support patches that will be posted shortly.
Signed-off-by Magnus Damm <[email protected]>
Thanks, I have queued these up.
cover ARM: shmobile: Break out and extend clock workaround
Quoted 13 lines · Simon Horman
Quoted 12 lines · Magnus Damm
ARM: shmobile: Break out and extend clock workaround
[PATCH 01/03] ARM: shmobile: Introduce
shmobile_clk_workaround()[PATCH 02/03] ARM: shmobile: Useshmobile_clk_workaround()on Lager [PATCH 03/03] ARM: shmobile: Useshmobile_clk_workaround()on KoelschThese patches consolidates the clkdev workaround present in the DT reference version of board code for Lager and Koelsch, and it also extends it to allow static enablement of a selected set of clocks during boot. The latter is needed for USB PCI support patches that will be posted shortly.
Quoted 3 lines
Quoted 1 line
Signed-off-by Magnus Damm <[email protected]>Thanks, I have queued these up.
It seems that the #include "clock.h" line in the
first patch of the series depends on "ARM: shmobile: Add temporary include workaround" which I have dropped as Olof objected to it.
Accordingly I am dropping this series too.
Magnus Damm
maintainerPATCH 2/3 ARM: shmobile: Use shmobile_init_delay() on EMEV2
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Adjust EMEV2 to use shmobile_init_delay() together with CPU Frequency settings from the DTS.
---
arch/arm/mach-shmobile/setup-emev2.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
arch/arm/mach-shmobile/setup-emev2.c +1 -6
@@ -42,11 +42,6 @@ static void __init emev2_map_io(void)iotable_init (emev2_io_desc,ARRAY_SIZE (emev2_io_desc)); } -static void __init emev2_init_delay (void ) -{ -shmobile_setup_delay (533 ,1 ,3 );/* Cortex-A9 @ 533MHz */ -} -static void __init emev2_add_standard_devices_dt (void ) {of_clk_init (NULL );
@@ -63,7 +58,7 @@ extern struct smp_operations emev2_smp_oDT_MACHINE_START (EMEV2_DT ,"Generic Emma Mobile EV2 (Flattened Device Tree)" ) .smp = smp_ops(emev2_smp_ops), .map_io = emev2_map_io, - .init_early = emev2_init_delay, + .init_early = shmobile_init_delay, .init_machine = emev2_add_standard_devices_dt, .init_late = shmobile_init_late, .dt_compat = emev2_boards_compat_dt,
Magnus Damm
maintainerPATCH 2/3 ARM: shmobile: Use shmobile_init_delay() on Genmai boards
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Adjust Genmai board support to use shmobile_init_delay() together with r7s72100 CPU Frequency settings from the DTS.
---
arch/arm/mach-shmobile/board-genmai-reference.c | 2 +- arch/arm/mach-shmobile/board-genmai.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-shmobile/board-genmai-reference.c +1 -1
@@ -47,7 +47,7 @@ static const char * const genmai_boards_ };DT_MACHINE_START (GENMAI_DT ,"genmai" ) - .init_early = r7s72100_init_early, + .init_early = shmobile_init_delay, .init_machine = genmai_add_standard_devices, .dt_compat = genmai_boards_compat_dt,MACHINE_END
arch/arm/mach-shmobile/board-genmai.c +1 -1
@@ -154,7 +154,7 @@ static const char * const genmai_boards_ };DT_MACHINE_START (GENMAI_DT ,"genmai" ) - .init_early = r7s72100_init_early, + .init_early = shmobile_init_delay, .init_machine = genmai_add_standard_devices, .dt_compat = genmai_boards_compat_dt,MACHINE_END
Magnus Damm
maintainerPATCH 3/3 ARM: shmobile: Use shmobile_init_delay() on r7s72100
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Adjust Genmai board support to use shmobile_init_delay() together with r7s72100 CPU Frequency settings from the DTS.
---
arch/arm/mach-shmobile/board-genmai-reference.c | 2 +- arch/arm/mach-shmobile/board-genmai.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-shmobile/board-genmai-reference.c +1 -1
@@ -47,7 +47,7 @@ static const char * const genmai_boards_ };DT_MACHINE_START (GENMAI_DT ,"genmai" ) - .init_early = r7s72100_init_early, + .init_early = shmobile_init_delay, .init_machine = genmai_add_standard_devices, .dt_compat = genmai_boards_compat_dt,MACHINE_END
arch/arm/mach-shmobile/board-genmai.c +1 -1
@@ -154,7 +154,7 @@ static const char * const genmai_boards_ };DT_MACHINE_START (GENMAI_DT ,"genmai" ) - .init_early = r7s72100_init_early, + .init_early = shmobile_init_delay, .init_machine = genmai_add_standard_devices, .dt_compat = genmai_boards_compat_dt,MACHINE_END
Re: [PATCH 03/03] ARM: shmobile: Use shmobile_init_delay() on r7s72100
In reply to Magnus DammHi Magnus,
Quoted 11 lines · Magnus Damm
From: Magnus Damm <[email protected]>
Adjust Genmai board support to use
shmobile_init_delay()together with r7s72100 CPU Frequency settings from the DTS.Signed-off-by Magnus Damm <[email protected]>---
arch/arm/mach-shmobile/board-genmai-reference.c | 2 +- arch/arm/mach-shmobile/board-genmai.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
The contents of this patch are identical to "[PATCH 02/03] ARM: shmobile:
Use shmobile_init_delay() on Genmai boards"?
I had expected it to touch arch/arm/mach-shmobile/setup-r7s72100.c and arch/arm/mach-shmobile/include/mach/r7s72100.h.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Magnus Damm
maintainerRe: [PATCH 03/03] ARM: shmobile: Use shmobile_init_delay() on r7s72100
In reply to Magnus DammHi Geert,
Quoted 15 lines · Geert Uytterhoeven
Hi Magnus,
Quoted 11 lines · Magnus Damm
From: Magnus Damm <[email protected]>
Adjust Genmai board support to use
shmobile_init_delay()together with r7s72100 CPU Frequency settings from the DTS.Signed-off-by Magnus Damm <[email protected]>---
arch/arm/mach-shmobile/board-genmai-reference.c | 2 +- arch/arm/mach-shmobile/board-genmai.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
The contents of this patch are identical to "[PATCH 02/03] ARM: shmobile:
Useshmobile_init_delay()on Genmai boards"?I had expected it to touch
arch/arm/mach-shmobile/setup-r7s72100.candarch/arm/mach-shmobile/include/mach/r7s72100.h.
I was about to explain how the patches are split this way between SoC and board because ARM SoC likes to merge things that way, but now I realize that you are telling me that I sent the wrong patch. =)
Thanks for pointing this out. I will fix up and resend (hopefully the right code this time).
Cheers,
/ magnus