Renesas R8A7743 CPG/MSSR clock support
Subsystems (3)
v2 cover Renesas R8A7743 CPG/MSSR clock support
Hello.
Here's the set of 2 patches against the 'clk-next' branch of CLK group's
'linux.git' repo. I'm splitting this from the R-Car gen2 common support patch. As the DT patches in the R8A7743/SK-RZG1M board support series depend on the patch #2 of this series, so it might make sense to merge this patch to the 'renesas.git' repo as well...
[1/2] ARM: shmobile: r8a7743: add CPG clock index macros [2/2] clk: renesas: cpg-mssr: add R8A7743 support
MBR, Sergei
PATCH v2 1/2 ARM: shmobile: r8a7743: add CPG clock index macros
Add macros usable by the device tree sources to reference the R8A7743 CPG clocks by index.
---
Changes in version 2:
- reduced the macro value indentation.
include/dt-bindings/clock/r8a7743-cpg-mssr.h | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
include/dt-bindings/clock/r8a7743-cpg-mssr.h new file +43 -0
@@ -0,0 +1,43 @@ +/* +* Copyright (C) 2016 Cogent Embedded Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ +#ifndef __DT_BINDINGS_CLOCK_R8A7743_CPG_MSSR_H__ +#define __DT_BINDINGS_CLOCK_R8A7743_CPG_MSSR_H__ + +#include <dt-bindings/clock/renesas-cpg-mssr.h> + +/* r8a7743 CPG Core Clocks */ +#define R8A7743_CLK_Z 0 +#define R8A7743_CLK_ZG 1 +#define R8A7743_CLK_ZTR 2 +#define R8A7743_CLK_ZTRD2 3 +#define R8A7743_CLK_ZT 4 +#define R8A7743_CLK_ZX 5 +#define R8A7743_CLK_ZS 6 +#define R8A7743_CLK_HP 7 +#define R8A7743_CLK_B 8 +#define R8A7743_CLK_LB 9 +#define R8A7743_CLK_P 10 +#define R8A7743_CLK_CL 11 +#define R8A7743_CLK_M2 12 +#define R8A7743_CLK_ZB3 13 +#define R8A7743_CLK_ZB3D2 14 +#define R8A7743_CLK_DDR 15 +#define R8A7743_CLK_SDH 16 +#define R8A7743_CLK_SD0 17 +#define R8A7743_CLK_SD2 18 +#define R8A7743_CLK_SD3 19 +#define R8A7743_CLK_MMC0 20 +#define R8A7743_CLK_MP 21 +#define R8A7743_CLK_QSPI 22 +#define R8A7743_CLK_CP 23 +#define R8A7743_CLK_RCAN 24 +#define R8A7743_CLK_R 25 +#define R8A7743_CLK_OSC 26 + +#endif /* __DT_BINDINGS_CLOCK_R8A7743_CPG_MSSR_H__ */
Re: [PATCH v2 1/2] ARM: shmobile: r8a7743: add CPG clock index macros
Hi Sergei,
Quoted 4 lines · Sergei Shtylyov
Add macros usable by the device tree sources to reference the R8A7743 CPG clocks by index.
Signed-off-by Sergei Shtylyov <[email protected]>
Thanks for your patch!
It would be good to refer to the table and version of the datasheet (i.e. Table 7.2b, I have Rev. 0.50 of the RZ/G series User's Manual).
Quoted 15 lines
include/dt-bindings/clock/r8a7743-cpg-mssr.h new file +12
-0@@ -0,0 +1,43 @@ +/* +* Copyright (C) 2016 Cogent Embedded Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ +#ifndef __DT_BINDINGS_CLOCK_R8A7743_CPG_MSSR_H__ +#define __DT_BINDINGS_CLOCK_R8A7743_CPG_MSSR_H__ + +#include <dt-bindings/clock/renesas-cpg-mssr.h>
include/dt-bindings/clock/r8a7743-cpg-mssr.h line 22
Quoted 10 lines
include/dt-bindings/clock/r8a7743-cpg-mssr.h new file +10
-0+ +/* r8a7743 CPG Core Clocks */ +#define R8A7743_CLK_Z 0 +#define R8A7743_CLK_ZG 1 +#define R8A7743_CLK_ZTR 2 +#define R8A7743_CLK_ZTRD2 3 +#define R8A7743_CLK_ZT 4 +#define R8A7743_CLK_ZX 5 +#define R8A7743_CLK_ZS 6 +#define R8A7743_CLK_HP 7
In this particular case, I think we should leave holes in the numbering for clocks that exist on r8a7791. That way we can easily reuse the driver on r8a7791 later, and NULLify the entries for clocks that do not exist on r8a7743.
I.e. a one entry hole here, ...
include/dt-bindings/clock/r8a7743-cpg-mssr.h line 27
Quoted 5 lines
include/dt-bindings/clock/r8a7743-cpg-mssr.h new file +5
-0+#define R8A7743_CLK_B 8 +#define R8A7743_CLK_LB 9 +#define R8A7743_CLK_P 10 +#define R8A7743_CLK_CL 11 +#define R8A7743_CLK_M2 12
... a one entry hole here, ...
include/dt-bindings/clock/r8a7743-cpg-mssr.h line 36
Quoted 9 lines
include/dt-bindings/clock/r8a7743-cpg-mssr.h new file +9
-0+#define R8A7743_CLK_ZB3 13 +#define R8A7743_CLK_ZB3D2 14 +#define R8A7743_CLK_DDR 15 +#define R8A7743_CLK_SDH 16 +#define R8A7743_CLK_SD0 17 +#define R8A7743_CLK_SD2 18 +#define R8A7743_CLK_SD3 19 +#define R8A7743_CLK_MMC0 20 +#define R8A7743_CLK_MP 21
... and a two entry hole here.
include/dt-bindings/clock/r8a7743-cpg-mssr.h line 43
Quoted 7 lines
include/dt-bindings/clock/r8a7743-cpg-mssr.h new file +7
-0+#define R8A7743_CLK_QSPI 22 +#define R8A7743_CLK_CP 23 +#define R8A7743_CLK_RCAN 24 +#define R8A7743_CLK_R 25 +#define R8A7743_CLK_OSC 26 + +#endif /* __DT_BINDINGS_CLOCK_R8A7743_CPG_MSSR_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
PATCH v2 2/2 clk: renesas: cpg-mssr: add R8A7743 support
In reply to Sergei ShtylyovAdd RZ/G1M (R8A7743) Clock Pulse Generator / Module Standby and Software Reset support, using the CPG/MSSR driver core and the common R-Car Gen2 (and RZ/G) code.
Based on the proof-of-concept R8A7791 CPG/MSSR patch by Geert Uytterhoeven <[email protected]>.
---
Changes in version 2:
- documented the R8A7743 device tree binding;
- fixed whitespace errors/warnings reported by checkpatch.pl;
- used tabs instead of spaces for indentation;
- fixed the PLL3 column name in the PLL table.
Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt | 4 drivers/clk/renesas/Kconfig | 1 drivers/clk/renesas/Makefile | 1 drivers/clk/renesas/r8a7743-cpg-mssr.c | 268 +++++++++++ drivers/clk/renesas/renesas-cpg-mssr.c | 6 drivers/clk/renesas/renesas-cpg-mssr.h | 1 6 files changed, 280 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt +3 -1
@@ -13,6 +13,7 @@ They provide the following functionaliti Required Properties: - compatible: Must be one of: + - "renesas,r8a7743-cpg-mssr" for the r8a7743 SoC (RZ/G1M) - "renesas,r8a7795-cpg-mssr" for the r8a7795 SoC (R-Car H3) - "renesas,r8a7796-cpg-mssr" for the r8a7796 SoC (R-Car M3-W)
@@ -22,7 +23,8 @@ Required Properties: - clocks: References to external parent clocks, one entry for each entry in clock-names - clock-names: List of external parent clock names. Valid names are: - - "extal" (r8a7795, r8a7796) + - "extal" (r8a7743, r8a7795, r8a7796) + - "usb_extal" (r8a7743) - "extalr" (r8a7795, r8a7796) - #clock-cells: Must be 2
drivers/clk/renesas/Kconfig +1 -0
@@ -1,5 +1,6 @@ config CLK_RENESAS_CPG_MSSR bool + default y if ARCH_R8A7743 default y if ARCH_R8A7795 default y if ARCH_R8A7796
drivers/clk/renesas/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-$(CONFIG_ARCH_EMEV2) += clk-emev2.o obj-$(CONFIG_ARCH_R7S72100) += clk-rz.o obj-$(CONFIG_ARCH_R8A73A4) += clk-r8a73a4.o clk-div6.o obj-$(CONFIG_ARCH_R8A7740) += clk-r8a7740.o clk-div6.o +obj-$(CONFIG_ARCH_R8A7743) += r8a7743-cpg-mssr.o rcar-gen2-cpg.o obj-$(CONFIG_ARCH_R8A7778) += clk-r8a7778.o obj-$(CONFIG_ARCH_R8A7779) += clk-r8a7779.o obj-$(CONFIG_ARCH_R8A7790) += clk-rcar-gen2.o clk-div6.o
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +268 -0
268 lines not on this page · raw message
drivers/clk/renesas/renesas-cpg-mssr.c +6 -0
@@ -503,6 +503,12 @@ static int __init cpg_mssr_add_clk_domai }static const struct of_device_id cpg_mssr_match[] = { +#ifdef CONFIG_ARCH_R8A7743 + { + .compatible ="renesas,r8a7743-cpg-mssr" , + .data = &r8a7743_cpg_mssr_info, + }, +#endif #ifdef CONFIG_ARCH_R8A7795 { .compatible ="renesas,r8a7795-cpg-mssr" ,
drivers/clk/renesas/renesas-cpg-mssr.h +1 -0
@@ -130,6 +130,7 @@ struct cpg_mssr_info { struct clk **clks, void __iomem *base); }; +extern const struct cpg_mssr_info r8a7743_cpg_mssr_info;extern const struct cpg_mssr_info r8a7795_cpg_mssr_info;extern const struct cpg_mssr_info r8a7796_cpg_mssr_info;#endif
Re: [PATCH v2 2/2] clk: renesas: cpg-mssr: add R8A7743 support
Quoted 9 lines · Sergei Shtylyov
Add RZ/G1M (R8A7743) Clock Pulse Generator / Module Standby and Software Reset support, using the CPG/MSSR driver core and the common R-Car Gen2 (and RZ/G) code.
Based on the proof-of-concept R8A7791 CPG/MSSR patch by Geert Uytterhoeven <[email protected]>.
Signed-off-by Sergei Shtylyov <[email protected]>
Quoted 8 lines
---
Changes in version 2:
- documented the R8A7743 device tree binding;
- fixed whitespace errors/warnings reported by checkpatch.pl;
- used tabs instead of spaces for indentation;
- fixed the PLL3 column name in the PLL table.Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt | 4
Quoted 6 lines
drivers/clk/renesas/Kconfig | 1 drivers/clk/renesas/Makefile | 1 drivers/clk/renesas/r8a7743-cpg-mssr.c | 268 +++++++++++ drivers/clk/renesas/renesas-cpg-mssr.c | 6 drivers/clk/renesas/renesas-cpg-mssr.h | 1 6 files changed, 280 insertions(+), 1 deletion(-)
Re: [PATCH v2 2/2] clk: renesas: cpg-mssr: add R8A7743 support
In reply to Sergei ShtylyovHi Sergei,
Quoted 8 lines · Sergei Shtylyov
Add RZ/G1M (R8A7743) Clock Pulse Generator / Module Standby and Software Reset support, using the CPG/MSSR driver core and the common R-Car Gen2 (and RZ/G) code.
Based on the proof-of-concept R8A7791 CPG/MSSR patch by Geert Uytterhoeven <[email protected]>.
Signed-off-by Sergei Shtylyov <[email protected]>
Thanks for your patch!
drivers/clk/renesas/r8a7743-cpg-mssr.c line 197
Quoted 5 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +2
-0+static const unsigned int r8a7743_crit_mod_clks[]__initconst = { +MOD_CLK_ID (408 ),/* INTC-AP (GIC) */
This clock is actually called "INTC-SYS" on the RZ/G series, like on most other Renesas SoCs.
Quoted 1 line
+};
The rest looks good at first sight. I'll have a closer look after ELC-E.
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
Re: [PATCH v2 2/2] clk: renesas: cpg-mssr: add R8A7743 support
In reply to Sergei ShtylyovHi Sergei,
Quoted 8 lines · Sergei Shtylyov
Add RZ/G1M (R8A7743) Clock Pulse Generator / Module Standby and Software Reset support, using the CPG/MSSR driver core and the common R-Car Gen2 (and RZ/G) code.
Based on the proof-of-concept R8A7791 CPG/MSSR patch by Geert Uytterhoeven <[email protected]>.
Signed-off-by Sergei Shtylyov <[email protected]>
Thanks a lot!
With the few minor nits below fixed:
drivers/clk/renesas/r8a7743-cpg-mssr.c line 111
Quoted 6 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +2
-0+static const struct mssr_mod_clk r8a7743_mod_clks[]__initconst = { +DEF_MOD ("mmcif0" ,315 ,R8A7743_CLK_MMC0 ),
"mmc0"
drivers/clk/renesas/r8a7743-cpg-mssr.c line 122
Quoted 2 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +2
-0+DEF_MOD ("audio-dmac0" ,502 ,R8A7743_CLK_HP ), + DEF_MOD("audio-dmac1", 501, R8A7743_CLK_HP),
Please sort by numerical clock ID.
Quoted 1 line
+
DEF_MOD("i2c6", 926, R8A7743_CLK_CP),
"iicdvfs"
drivers/clk/renesas/r8a7743-cpg-mssr.c line 197
Quoted 2 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +2
-0+static const unsigned int r8a7743_crit_mod_clks[]__initconst = { +MOD_CLK_ID (408 ),/* INTC-AP (GIC) */
INTC-SYS
Quoted 11 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +10
-0+}; +static const struct rcar_gen2_cpg_pll_config cpg_pll_configs[8 ]__initconst = { +/* EXTAL div PLL1 mult PLL3 mult */ + {1 ,208 ,106 , }, + {1 ,208 ,88 , }, + {1 ,156 ,80 , }, + {1 ,156 ,66 , }, + {2 ,240 ,122 , }, + {2 ,240 ,102 , }, + {2 ,208 ,106 , },
drivers/clk/renesas/r8a7743-cpg-mssr.c line 241
Quoted 10 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +10
-0+ { 2, 208, 88, }, +}; + +static int __init r8a7743_cpg_mssr_init (struct device *dev) +{ +const struct rcar_gen2_cpg_pll_config *cpg_pll_config; +u32 cpg_mode =rcar_gen2_read_modemr (); + + cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX (cpg_mode)]; +if (!cpg_pll_config->extal_div) {
This check is not needed, as extal_div is never zero in the above table.
drivers/clk/renesas/r8a7743-cpg-mssr.c line 244
Quoted 3 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +3
-0+dev_err (dev,"Prohibited setting (cpg_mode=0x%x)\n" , cpg_mode); +return -EINVAL ; + }
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
Re: [PATCH v2 2/2] clk: renesas: cpg-mssr: add R8A7743 support
Hello.
Quoted 14 lines · Geert Uytterhoeven
Quoted 8 lines
Add RZ/G1M (R8A7743) Clock Pulse Generator / Module Standby and Software Reset support, using the CPG/MSSR driver core and the common R-Car Gen2 (and RZ/G) code.
Based on the proof-of-concept R8A7791 CPG/MSSR patch by Geert Uytterhoeven <[email protected]>.
Signed-off-by Sergei Shtylyov <[email protected]>Thanks a lot!
With the few minor nits below fixed:
Reviewed-by Geert Uytterhoeven <[email protected]>
Quoted 8 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c line 111
Quoted 6 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +2
-0+static const struct mssr_mod_clk r8a7743_mod_clks[]__initconst = { +DEF_MOD ("mmcif0" ,315 ,R8A7743_CLK_MMC0 ),"mmc0"
There's also "mmc0" CPG clock, so I thought I'd rename this one.
Quoted 4 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c line 122
Quoted 2 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +2
-0+DEF_MOD ("audio-dmac0" ,502 ,R8A7743_CLK_HP ), + DEF_MOD("audio-dmac1", 501, R8A7743_CLK_HP),Please sort by numerical clock ID.
Oops, will do.
Quoted 3 lines
Quoted 1 line
+
DEF_MOD("i2c6", 926, R8A7743_CLK_CP),"iicdvfs"
Not sure how I missed that...
Quoted 4 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c line 197
Quoted 2 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +2
-0+static const unsigned int r8a7743_crit_mod_clks[]__initconst = { +MOD_CLK_ID (408 ),/* INTC-AP (GIC) */ INTC-SYS
OK.
[...]
Quoted 13 lines
Quoted 13 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +13
-0+static const struct rcar_gen2_cpg_pll_config cpg_pll_configs[8 ]__initconst = { +/* EXTAL div PLL1 mult PLL3 mult */ + {1 ,208 ,106 , }, + {1 ,208 ,88 , }, + {1 ,156 ,80 , }, + {1 ,156 ,66 , }, + {2 ,240 ,122 , }, + {2 ,240 ,102 , }, + {2 ,208 ,106 , }, + {2 ,208 ,88 , }, +}; + +static int __init r8a7743_cpg_mssr_init (struct device *dev)
Quoted 8 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c line 241
Quoted 6 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +6
-0+{ +const struct rcar_gen2_cpg_pll_config *cpg_pll_config; +u32 cpg_mode =rcar_gen2_read_modemr (); + + cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX (cpg_mode)]; +if (!cpg_pll_config->extal_div) {This check is not needed, as
extal_divis never zero in the above table.
Indeed, will fix.
Quoted 7 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c line 244
Quoted 3 lines
drivers/clk/renesas/r8a7743-cpg-mssr.c new file +3
-0+dev_err (dev,"Prohibited setting (cpg_mode=0x%x)\n" , cpg_mode); +return -EINVAL ; + }Gr{oetje,eeting}s,
Geert
WBR, Sergei