aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Horman <horms+renesas@verge.net.au>2015-08-11 22:15:19 -0400
committerSimon Horman <horms+renesas@verge.net.au>2015-08-11 22:15:19 -0400
commit3f3f0ea0afe031ca20e48a212f4faa00f9920450 (patch)
tree03f2945aaf6c0e5450a75adfd220615e9b37f184
parent94bdc48d55ca10f90b4a625f0e443197e0013557 (diff)
parentf04b486d34ac6bab2aaa3988ee098b2bad3950de (diff)
Merge branch 'clk-for-v4.3' into dt-for-v4.3
-rw-r--r--Documentation/devicetree/bindings/clock/renesas,r8a7778-cpg-clocks.txt29
-rw-r--r--Documentation/devicetree/bindings/clock/renesas,r8a7779-cpg-clocks.txt30
-rw-r--r--Documentation/devicetree/bindings/clock/renesas,rcar-gen2-cpg-clocks.txt26
-rw-r--r--Documentation/devicetree/bindings/clock/renesas,rz-cpg-clocks.txt29
-rw-r--r--arch/arm/mach-shmobile/Kconfig2
-rw-r--r--drivers/clk/shmobile/clk-mstp.c87
-rw-r--r--drivers/clk/shmobile/clk-r8a7778.c2
-rw-r--r--drivers/clk/shmobile/clk-r8a7779.c2
-rw-r--r--drivers/clk/shmobile/clk-rcar-gen2.c2
-rw-r--r--drivers/clk/shmobile/clk-rz.c3
-rw-r--r--include/linux/clk/shmobile.h12
11 files changed, 213 insertions, 11 deletions
diff --git a/Documentation/devicetree/bindings/clock/renesas,r8a7778-cpg-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,r8a7778-cpg-clocks.txt
index 2f3747fdcf1c..e4cdaf1cb333 100644
--- a/Documentation/devicetree/bindings/clock/renesas,r8a7778-cpg-clocks.txt
+++ b/Documentation/devicetree/bindings/clock/renesas,r8a7778-cpg-clocks.txt
@@ -1,7 +1,9 @@
1* Renesas R8A7778 Clock Pulse Generator (CPG) 1* Renesas R8A7778 Clock Pulse Generator (CPG)
2 2
3The CPG generates core clocks for the R8A7778. It includes two PLLs and 3The CPG generates core clocks for the R8A7778. It includes two PLLs and
4several fixed ratio dividers 4several fixed ratio dividers.
5The CPG also provides a Clock Domain for SoC devices, in combination with the
6CPG Module Stop (MSTP) Clocks.
5 7
6Required Properties: 8Required Properties:
7 9
@@ -10,10 +12,18 @@ Required Properties:
10 - #clock-cells: Must be 1 12 - #clock-cells: Must be 1
11 - clock-output-names: The names of the clocks. Supported clocks are 13 - clock-output-names: The names of the clocks. Supported clocks are
12 "plla", "pllb", "b", "out", "p", "s", and "s1". 14 "plla", "pllb", "b", "out", "p", "s", and "s1".
15 - #power-domain-cells: Must be 0
13 16
17SoC devices that are part of the CPG/MSTP Clock Domain and can be power-managed
18through an MSTP clock should refer to the CPG device node in their
19"power-domains" property, as documented by the generic PM domain bindings in
20Documentation/devicetree/bindings/power/power_domain.txt.
14 21
15Example 22
16------- 23Examples
24--------
25
26 - CPG device node:
17 27
18 cpg_clocks: cpg_clocks@ffc80000 { 28 cpg_clocks: cpg_clocks@ffc80000 {
19 compatible = "renesas,r8a7778-cpg-clocks"; 29 compatible = "renesas,r8a7778-cpg-clocks";
@@ -22,4 +32,17 @@ Example
22 clocks = <&extal_clk>; 32 clocks = <&extal_clk>;
23 clock-output-names = "plla", "pllb", "b", 33 clock-output-names = "plla", "pllb", "b",
24 "out", "p", "s", "s1"; 34 "out", "p", "s", "s1";
35 #power-domain-cells = <0>;
36 };
37
38
39 - CPG/MSTP Clock Domain member device node:
40
41 sdhi0: sd@ffe4c000 {
42 compatible = "renesas,sdhi-r8a7778";
43 reg = <0xffe4c000 0x100>;
44 interrupts = <0 87 IRQ_TYPE_LEVEL_HIGH>;
45 clocks = <&mstp3_clks R8A7778_CLK_SDHI0>;
46 power-domains = <&cpg_clocks>;
47 status = "disabled";
25 }; 48 };
diff --git a/Documentation/devicetree/bindings/clock/renesas,r8a7779-cpg-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,r8a7779-cpg-clocks.txt
index ed3c8cb12f4e..8c81547c29f5 100644
--- a/Documentation/devicetree/bindings/clock/renesas,r8a7779-cpg-clocks.txt
+++ b/Documentation/devicetree/bindings/clock/renesas,r8a7779-cpg-clocks.txt
@@ -1,7 +1,9 @@
1* Renesas R8A7779 Clock Pulse Generator (CPG) 1* Renesas R8A7779 Clock Pulse Generator (CPG)
2 2
3The CPG generates core clocks for the R8A7779. It includes one PLL and 3The CPG generates core clocks for the R8A7779. It includes one PLL and
4several fixed ratio dividers 4several fixed ratio dividers.
5The CPG also provides a Clock Domain for SoC devices, in combination with the
6CPG Module Stop (MSTP) Clocks.
5 7
6Required Properties: 8Required Properties:
7 9
@@ -12,16 +14,36 @@ Required Properties:
12 - #clock-cells: Must be 1 14 - #clock-cells: Must be 1
13 - clock-output-names: The names of the clocks. Supported clocks are "plla", 15 - clock-output-names: The names of the clocks. Supported clocks are "plla",
14 "z", "zs", "s", "s1", "p", "b", "out". 16 "z", "zs", "s", "s1", "p", "b", "out".
17 - #power-domain-cells: Must be 0
15 18
19SoC devices that are part of the CPG/MSTP Clock Domain and can be power-managed
20through an MSTP clock should refer to the CPG device node in their
21"power-domains" property, as documented by the generic PM domain bindings in
22Documentation/devicetree/bindings/power/power_domain.txt.
16 23
17Example 24
18------- 25Examples
26--------
27
28 - CPG device node:
19 29
20 cpg_clocks: cpg_clocks@ffc80000 { 30 cpg_clocks: cpg_clocks@ffc80000 {
21 compatible = "renesas,r8a7779-cpg-clocks"; 31 compatible = "renesas,r8a7779-cpg-clocks";
22 reg = <0 0xffc80000 0 0x30>; 32 reg = <0xffc80000 0x30>;
23 clocks = <&extal_clk>; 33 clocks = <&extal_clk>;
24 #clock-cells = <1>; 34 #clock-cells = <1>;
25 clock-output-names = "plla", "z", "zs", "s", "s1", "p", 35 clock-output-names = "plla", "z", "zs", "s", "s1", "p",
26 "b", "out"; 36 "b", "out";
37 #power-domain-cells = <0>;
38 };
39
40
41 - CPG/MSTP Clock Domain member device node:
42
43 sata: sata@fc600000 {
44 compatible = "renesas,sata-r8a7779", "renesas,rcar-sata";
45 reg = <0xfc600000 0x2000>;
46 interrupts = <0 100 IRQ_TYPE_LEVEL_HIGH>;
47 clocks = <&mstp1_clks R8A7779_CLK_SATA>;
48 power-domains = <&cpg_clocks>;
27 }; 49 };
diff --git a/Documentation/devicetree/bindings/clock/renesas,rcar-gen2-cpg-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,rcar-gen2-cpg-clocks.txt
index 56f111bd3e45..2a9a8edc8f35 100644
--- a/Documentation/devicetree/bindings/clock/renesas,rcar-gen2-cpg-clocks.txt
+++ b/Documentation/devicetree/bindings/clock/renesas,rcar-gen2-cpg-clocks.txt
@@ -2,6 +2,8 @@
2 2
3The CPG generates core clocks for the R-Car Gen2 SoCs. It includes three PLLs 3The CPG generates core clocks for the R-Car Gen2 SoCs. It includes three PLLs
4and several fixed ratio dividers. 4and several fixed ratio dividers.
5The CPG also provides a Clock Domain for SoC devices, in combination with the
6CPG Module Stop (MSTP) Clocks.
5 7
6Required Properties: 8Required Properties:
7 9
@@ -20,10 +22,18 @@ Required Properties:
20 - clock-output-names: The names of the clocks. Supported clocks are "main", 22 - clock-output-names: The names of the clocks. Supported clocks are "main",
21 "pll0", "pll1", "pll3", "lb", "qspi", "sdh", "sd0", "sd1", "z", "rcan", and 23 "pll0", "pll1", "pll3", "lb", "qspi", "sdh", "sd0", "sd1", "z", "rcan", and
22 "adsp" 24 "adsp"
25 - #power-domain-cells: Must be 0
23 26
27SoC devices that are part of the CPG/MSTP Clock Domain and can be power-managed
28through an MSTP clock should refer to the CPG device node in their
29"power-domains" property, as documented by the generic PM domain bindings in
30Documentation/devicetree/bindings/power/power_domain.txt.
24 31
25Example 32
26------- 33Examples
34--------
35
36 - CPG device node:
27 37
28 cpg_clocks: cpg_clocks@e6150000 { 38 cpg_clocks: cpg_clocks@e6150000 {
29 compatible = "renesas,r8a7790-cpg-clocks", 39 compatible = "renesas,r8a7790-cpg-clocks",
@@ -34,4 +44,16 @@ Example
34 clock-output-names = "main", "pll0, "pll1", "pll3", 44 clock-output-names = "main", "pll0, "pll1", "pll3",
35 "lb", "qspi", "sdh", "sd0", "sd1", "z", 45 "lb", "qspi", "sdh", "sd0", "sd1", "z",
36 "rcan", "adsp"; 46 "rcan", "adsp";
47 #power-domain-cells = <0>;
48 };
49
50
51 - CPG/MSTP Clock Domain member device node:
52
53 thermal@e61f0000 {
54 compatible = "renesas,thermal-r8a7790", "renesas,rcar-thermal";
55 reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
56 interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
57 clocks = <&mstp5_clks R8A7790_CLK_THERMAL>;
58 power-domains = <&cpg_clocks>;
37 }; 59 };
diff --git a/Documentation/devicetree/bindings/clock/renesas,rz-cpg-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,rz-cpg-clocks.txt
index b0f7ddb8cdb1..bb51a33a1fbf 100644
--- a/Documentation/devicetree/bindings/clock/renesas,rz-cpg-clocks.txt
+++ b/Documentation/devicetree/bindings/clock/renesas,rz-cpg-clocks.txt
@@ -2,6 +2,8 @@
2 2
3The CPG generates core clocks for the RZ SoCs. It includes the PLL, variable 3The CPG generates core clocks for the RZ SoCs. It includes the PLL, variable
4CPU and GPU clocks, and several fixed ratio dividers. 4CPU and GPU clocks, and several fixed ratio dividers.
5The CPG also provides a Clock Domain for SoC devices, in combination with the
6CPG Module Stop (MSTP) Clocks.
5 7
6Required Properties: 8Required Properties:
7 9
@@ -14,10 +16,18 @@ Required Properties:
14 - #clock-cells: Must be 1 16 - #clock-cells: Must be 1
15 - clock-output-names: The names of the clocks. Supported clocks are "pll", 17 - clock-output-names: The names of the clocks. Supported clocks are "pll",
16 "i", and "g" 18 "i", and "g"
19 - #power-domain-cells: Must be 0
17 20
21SoC devices that are part of the CPG/MSTP Clock Domain and can be power-managed
22through an MSTP clock should refer to the CPG device node in their
23"power-domains" property, as documented by the generic PM domain bindings in
24Documentation/devicetree/bindings/power/power_domain.txt.
18 25
19Example 26
20------- 27Examples
28--------
29
30 - CPG device node:
21 31
22 cpg_clocks: cpg_clocks@fcfe0000 { 32 cpg_clocks: cpg_clocks@fcfe0000 {
23 #clock-cells = <1>; 33 #clock-cells = <1>;
@@ -26,4 +36,19 @@ Example
26 reg = <0xfcfe0000 0x18>; 36 reg = <0xfcfe0000 0x18>;
27 clocks = <&extal_clk>, <&usb_x1_clk>; 37 clocks = <&extal_clk>, <&usb_x1_clk>;
28 clock-output-names = "pll", "i", "g"; 38 clock-output-names = "pll", "i", "g";
39 #power-domain-cells = <0>;
40 };
41
42
43 - CPG/MSTP Clock Domain member device node:
44
45 mtu2: timer@fcff0000 {
46 compatible = "renesas,mtu2-r7s72100", "renesas,mtu2";
47 reg = <0xfcff0000 0x400>;
48 interrupts = <0 107 IRQ_TYPE_LEVEL_HIGH>;
49 interrupt-names = "tgi0a";
50 clocks = <&mstp3_clks R7S72100_CLK_MTU2>;
51 clock-names = "fck";
52 power-domains = <&cpg_clocks>;
53 status = "disabled";
29 }; 54 };
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 45006479d461..34eac88a9889 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -4,6 +4,7 @@ config ARCH_SHMOBILE
4 4
5config PM_RCAR 5config PM_RCAR
6 bool 6 bool
7 select PM_GENERIC_DOMAINS if PM
7 8
8config PM_RMOBILE 9config PM_RMOBILE
9 bool 10 bool
@@ -50,6 +51,7 @@ config ARCH_EMEV2
50 51
51config ARCH_R7S72100 52config ARCH_R7S72100
52 bool "RZ/A1H (R7S72100)" 53 bool "RZ/A1H (R7S72100)"
54 select PM_GENERIC_DOMAINS if PM
53 select SYS_SUPPORTS_SH_MTU2 55 select SYS_SUPPORTS_SH_MTU2
54 56
55config ARCH_R8A73A4 57config ARCH_R8A73A4
diff --git a/drivers/clk/shmobile/clk-mstp.c b/drivers/clk/shmobile/clk-mstp.c
index 2d2fe773ac81..b1df7b2f1e97 100644
--- a/drivers/clk/shmobile/clk-mstp.c
+++ b/drivers/clk/shmobile/clk-mstp.c
@@ -2,6 +2,7 @@
2 * R-Car MSTP clocks 2 * R-Car MSTP clocks
3 * 3 *
4 * Copyright (C) 2013 Ideas On Board SPRL 4 * Copyright (C) 2013 Ideas On Board SPRL
5 * Copyright (C) 2015 Glider bvba
5 * 6 *
6 * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 7 * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * 8 *
@@ -10,11 +11,16 @@
10 * the Free Software Foundation; version 2 of the License. 11 * the Free Software Foundation; version 2 of the License.
11 */ 12 */
12 13
14#include <linux/clk.h>
13#include <linux/clk-provider.h> 15#include <linux/clk-provider.h>
14#include <linux/clkdev.h> 16#include <linux/clkdev.h>
17#include <linux/clk/shmobile.h>
18#include <linux/device.h>
15#include <linux/io.h> 19#include <linux/io.h>
16#include <linux/of.h> 20#include <linux/of.h>
17#include <linux/of_address.h> 21#include <linux/of_address.h>
22#include <linux/pm_clock.h>
23#include <linux/pm_domain.h>
18#include <linux/spinlock.h> 24#include <linux/spinlock.h>
19 25
20/* 26/*
@@ -236,3 +242,84 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
236 of_clk_add_provider(np, of_clk_src_onecell_get, &group->data); 242 of_clk_add_provider(np, of_clk_src_onecell_get, &group->data);
237} 243}
238CLK_OF_DECLARE(cpg_mstp_clks, "renesas,cpg-mstp-clocks", cpg_mstp_clocks_init); 244CLK_OF_DECLARE(cpg_mstp_clks, "renesas,cpg-mstp-clocks", cpg_mstp_clocks_init);
245
246
247#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
248int cpg_mstp_attach_dev(struct generic_pm_domain *domain, struct device *dev)
249{
250 struct device_node *np = dev->of_node;
251 struct of_phandle_args clkspec;
252 struct clk *clk;
253 int i = 0;
254 int error;
255
256 while (!of_parse_phandle_with_args(np, "clocks", "#clock-cells", i,
257 &clkspec)) {
258 if (of_device_is_compatible(clkspec.np,
259 "renesas,cpg-mstp-clocks"))
260 goto found;
261
262 of_node_put(clkspec.np);
263 i++;
264 }
265
266 return 0;
267
268found:
269 clk = of_clk_get_from_provider(&clkspec);
270 of_node_put(clkspec.np);
271
272 if (IS_ERR(clk))
273 return PTR_ERR(clk);
274
275 error = pm_clk_create(dev);
276 if (error) {
277 dev_err(dev, "pm_clk_create failed %d\n", error);
278 goto fail_put;
279 }
280
281 error = pm_clk_add_clk(dev, clk);
282 if (error) {
283 dev_err(dev, "pm_clk_add_clk %pC failed %d\n", clk, error);
284 goto fail_destroy;
285 }
286
287 return 0;
288
289fail_destroy:
290 pm_clk_destroy(dev);
291fail_put:
292 clk_put(clk);
293 return error;
294}
295
296void cpg_mstp_detach_dev(struct generic_pm_domain *domain, struct device *dev)
297{
298 if (!list_empty(&dev->power.subsys_data->clock_list))
299 pm_clk_destroy(dev);
300}
301
302void __init cpg_mstp_add_clk_domain(struct device_node *np)
303{
304 struct generic_pm_domain *pd;
305 u32 ncells;
306
307 if (of_property_read_u32(np, "#power-domain-cells", &ncells)) {
308 pr_warn("%s lacks #power-domain-cells\n", np->full_name);
309 return;
310 }
311
312 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
313 if (!pd)
314 return;
315
316 pd->name = np->name;
317
318 pd->flags = GENPD_FLAG_PM_CLK;
319 pm_genpd_init(pd, &simple_qos_governor, false);
320 pd->attach_dev = cpg_mstp_attach_dev;
321 pd->detach_dev = cpg_mstp_detach_dev;
322
323 of_genpd_add_provider_simple(np, pd);
324}
325#endif /* !CONFIG_PM_GENERIC_DOMAINS_OF */
diff --git a/drivers/clk/shmobile/clk-r8a7778.c b/drivers/clk/shmobile/clk-r8a7778.c
index cb33b57274bf..fa45684e220c 100644
--- a/drivers/clk/shmobile/clk-r8a7778.c
+++ b/drivers/clk/shmobile/clk-r8a7778.c
@@ -124,6 +124,8 @@ static void __init r8a7778_cpg_clocks_init(struct device_node *np)
124 } 124 }
125 125
126 of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data); 126 of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
127
128 cpg_mstp_add_clk_domain(np);
127} 129}
128 130
129CLK_OF_DECLARE(r8a7778_cpg_clks, "renesas,r8a7778-cpg-clocks", 131CLK_OF_DECLARE(r8a7778_cpg_clks, "renesas,r8a7778-cpg-clocks",
diff --git a/drivers/clk/shmobile/clk-r8a7779.c b/drivers/clk/shmobile/clk-r8a7779.c
index 652ecacb6daf..e42a63a2ad25 100644
--- a/drivers/clk/shmobile/clk-r8a7779.c
+++ b/drivers/clk/shmobile/clk-r8a7779.c
@@ -168,6 +168,8 @@ static void __init r8a7779_cpg_clocks_init(struct device_node *np)
168 } 168 }
169 169
170 of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data); 170 of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
171
172 cpg_mstp_add_clk_domain(np);
171} 173}
172CLK_OF_DECLARE(r8a7779_cpg_clks, "renesas,r8a7779-cpg-clocks", 174CLK_OF_DECLARE(r8a7779_cpg_clks, "renesas,r8a7779-cpg-clocks",
173 r8a7779_cpg_clocks_init); 175 r8a7779_cpg_clocks_init);
diff --git a/drivers/clk/shmobile/clk-rcar-gen2.c b/drivers/clk/shmobile/clk-rcar-gen2.c
index acfb6d7dbd6b..f2c457f494eb 100644
--- a/drivers/clk/shmobile/clk-rcar-gen2.c
+++ b/drivers/clk/shmobile/clk-rcar-gen2.c
@@ -415,6 +415,8 @@ static void __init rcar_gen2_cpg_clocks_init(struct device_node *np)
415 } 415 }
416 416
417 of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data); 417 of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
418
419 cpg_mstp_add_clk_domain(np);
418} 420}
419CLK_OF_DECLARE(rcar_gen2_cpg_clks, "renesas,rcar-gen2-cpg-clocks", 421CLK_OF_DECLARE(rcar_gen2_cpg_clks, "renesas,rcar-gen2-cpg-clocks",
420 rcar_gen2_cpg_clocks_init); 422 rcar_gen2_cpg_clocks_init);
diff --git a/drivers/clk/shmobile/clk-rz.c b/drivers/clk/shmobile/clk-rz.c
index 7e68e8630962..9766e3cb595f 100644
--- a/drivers/clk/shmobile/clk-rz.c
+++ b/drivers/clk/shmobile/clk-rz.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/clk-provider.h> 12#include <linux/clk-provider.h>
13#include <linux/clk/shmobile.h>
13#include <linux/init.h> 14#include <linux/init.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
15#include <linux/of.h> 16#include <linux/of.h>
@@ -99,5 +100,7 @@ static void __init rz_cpg_clocks_init(struct device_node *np)
99 } 100 }
100 101
101 of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data); 102 of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
103
104 cpg_mstp_add_clk_domain(np);
102} 105}
103CLK_OF_DECLARE(rz_cpg_clks, "renesas,rz-cpg-clocks", rz_cpg_clocks_init); 106CLK_OF_DECLARE(rz_cpg_clks, "renesas,rz-cpg-clocks", rz_cpg_clocks_init);
diff --git a/include/linux/clk/shmobile.h b/include/linux/clk/shmobile.h
index 63a8159c4e64..cb19cc1865ca 100644
--- a/include/linux/clk/shmobile.h
+++ b/include/linux/clk/shmobile.h
@@ -16,8 +16,20 @@
16 16
17#include <linux/types.h> 17#include <linux/types.h>
18 18
19struct device;
20struct device_node;
21struct generic_pm_domain;
22
19void r8a7778_clocks_init(u32 mode); 23void r8a7778_clocks_init(u32 mode);
20void r8a7779_clocks_init(u32 mode); 24void r8a7779_clocks_init(u32 mode);
21void rcar_gen2_clocks_init(u32 mode); 25void rcar_gen2_clocks_init(u32 mode);
22 26
27#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
28void cpg_mstp_add_clk_domain(struct device_node *np);
29int cpg_mstp_attach_dev(struct generic_pm_domain *domain, struct device *dev);
30void cpg_mstp_detach_dev(struct generic_pm_domain *domain, struct device *dev);
31#else
32static inline void cpg_mstp_add_clk_domain(struct device_node *np) {}
33#endif
34
23#endif 35#endif