diff options
author | Michael Turquette <mturquette@linaro.org> | 2015-01-27 14:34:41 -0500 |
---|---|---|
committer | Michael Turquette <mturquette@linaro.org> | 2015-01-27 14:34:41 -0500 |
commit | 88f52ecde0b491e285b6b692078fe9e8ee127d8a (patch) | |
tree | c5b40b44b2b0153875e363463e1ac8f8162a1a3b | |
parent | 57386798f7db7f09d69f3b44fc66570e6db91bba (diff) | |
parent | 1484276119fb5083a3a8cb0293e763363c317661 (diff) |
Merge branch 'clk-shmobile-for-3.20' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers into clk-next
-rw-r--r-- | Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt | 1 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/clock/renesas,r8a73a4-cpg-clocks.txt | 33 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/clock/renesas,rcar-gen2-cpg-clocks.txt | 12 | ||||
-rw-r--r-- | drivers/clk/shmobile/Makefile | 2 | ||||
-rw-r--r-- | drivers/clk/shmobile/clk-div6.c | 15 | ||||
-rw-r--r-- | drivers/clk/shmobile/clk-r8a73a4.c | 241 | ||||
-rw-r--r-- | drivers/clk/shmobile/clk-rcar-gen2.c | 88 |
7 files changed, 384 insertions, 8 deletions
diff --git a/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt index 2e18676bd4b5..0a80fa70ca26 100644 --- a/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt +++ b/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt | |||
@@ -11,6 +11,7 @@ Required Properties: | |||
11 | 11 | ||
12 | - compatible: Must be one of the following | 12 | - compatible: Must be one of the following |
13 | - "renesas,r7s72100-mstp-clocks" for R7S72100 (RZ) MSTP gate clocks | 13 | - "renesas,r7s72100-mstp-clocks" for R7S72100 (RZ) MSTP gate clocks |
14 | - "renesas,r8a73a4-mstp-clocks" for R8A73A4 (R-Mobile APE6) MSTP gate clocks | ||
14 | - "renesas,r8a7740-mstp-clocks" for R8A7740 (R-Mobile A1) MSTP gate clocks | 15 | - "renesas,r8a7740-mstp-clocks" for R8A7740 (R-Mobile A1) MSTP gate clocks |
15 | - "renesas,r8a7779-mstp-clocks" for R8A7779 (R-Car H1) MSTP gate clocks | 16 | - "renesas,r8a7779-mstp-clocks" for R8A7779 (R-Car H1) MSTP gate clocks |
16 | - "renesas,r8a7790-mstp-clocks" for R8A7790 (R-Car H2) MSTP gate clocks | 17 | - "renesas,r8a7790-mstp-clocks" for R8A7790 (R-Car H2) MSTP gate clocks |
diff --git a/Documentation/devicetree/bindings/clock/renesas,r8a73a4-cpg-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,r8a73a4-cpg-clocks.txt new file mode 100644 index 000000000000..ece92393e80d --- /dev/null +++ b/Documentation/devicetree/bindings/clock/renesas,r8a73a4-cpg-clocks.txt | |||
@@ -0,0 +1,33 @@ | |||
1 | * Renesas R8A73A4 Clock Pulse Generator (CPG) | ||
2 | |||
3 | The CPG generates core clocks for the R8A73A4 SoC. It includes five PLLs | ||
4 | and several fixed ratio dividers. | ||
5 | |||
6 | Required Properties: | ||
7 | |||
8 | - compatible: Must be "renesas,r8a73a4-cpg-clocks" | ||
9 | |||
10 | - reg: Base address and length of the memory resource used by the CPG | ||
11 | |||
12 | - clocks: Reference to the parent clocks ("extal1" and "extal2") | ||
13 | |||
14 | - #clock-cells: Must be 1 | ||
15 | |||
16 | - clock-output-names: The names of the clocks. Supported clocks are "main", | ||
17 | "pll0", "pll1", "pll2", "pll2s", "pll2h", "z", "z2", "i", "m3", "b", | ||
18 | "m1", "m2", "zx", "zs", and "hp". | ||
19 | |||
20 | |||
21 | Example | ||
22 | ------- | ||
23 | |||
24 | cpg_clocks: cpg_clocks@e6150000 { | ||
25 | compatible = "renesas,r8a73a4-cpg-clocks"; | ||
26 | reg = <0 0xe6150000 0 0x10000>; | ||
27 | clocks = <&extal1_clk>, <&extal2_clk>; | ||
28 | #clock-cells = <1>; | ||
29 | clock-output-names = "main", "pll0", "pll1", "pll2", | ||
30 | "pll2s", "pll2h", "z", "z2", | ||
31 | "i", "m3", "b", "m1", "m2", | ||
32 | "zx", "zs", "hp"; | ||
33 | }; | ||
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 e6ad35b894f9..b02944fba9de 100644 --- a/Documentation/devicetree/bindings/clock/renesas,rcar-gen2-cpg-clocks.txt +++ b/Documentation/devicetree/bindings/clock/renesas,rcar-gen2-cpg-clocks.txt | |||
@@ -8,15 +8,18 @@ Required Properties: | |||
8 | - compatible: Must be one of | 8 | - compatible: Must be one of |
9 | - "renesas,r8a7790-cpg-clocks" for the r8a7790 CPG | 9 | - "renesas,r8a7790-cpg-clocks" for the r8a7790 CPG |
10 | - "renesas,r8a7791-cpg-clocks" for the r8a7791 CPG | 10 | - "renesas,r8a7791-cpg-clocks" for the r8a7791 CPG |
11 | - "renesas,r8a7793-cpg-clocks" for the r8a7793 CPG | ||
11 | - "renesas,r8a7794-cpg-clocks" for the r8a7794 CPG | 12 | - "renesas,r8a7794-cpg-clocks" for the r8a7794 CPG |
12 | - "renesas,rcar-gen2-cpg-clocks" for the generic R-Car Gen2 CPG | 13 | - "renesas,rcar-gen2-cpg-clocks" for the generic R-Car Gen2 CPG |
13 | 14 | ||
14 | - reg: Base address and length of the memory resource used by the CPG | 15 | - reg: Base address and length of the memory resource used by the CPG |
15 | 16 | ||
16 | - clocks: Reference to the parent clock | 17 | - clocks: References to the parent clocks: first to the EXTAL clock, second |
18 | to the USB_EXTAL clock | ||
17 | - #clock-cells: Must be 1 | 19 | - #clock-cells: Must be 1 |
18 | - clock-output-names: The names of the clocks. Supported clocks are "main", | 20 | - clock-output-names: The names of the clocks. Supported clocks are "main", |
19 | "pll0", "pll1", "pll3", "lb", "qspi", "sdh", "sd0", "sd1" and "z" | 21 | "pll0", "pll1", "pll3", "lb", "qspi", "sdh", "sd0", "sd1", "z", "rcan", and |
22 | "adsp" | ||
20 | 23 | ||
21 | 24 | ||
22 | Example | 25 | Example |
@@ -26,8 +29,9 @@ Example | |||
26 | compatible = "renesas,r8a7790-cpg-clocks", | 29 | compatible = "renesas,r8a7790-cpg-clocks", |
27 | "renesas,rcar-gen2-cpg-clocks"; | 30 | "renesas,rcar-gen2-cpg-clocks"; |
28 | reg = <0 0xe6150000 0 0x1000>; | 31 | reg = <0 0xe6150000 0 0x1000>; |
29 | clocks = <&extal_clk>; | 32 | clocks = <&extal_clk &usb_extal_clk>; |
30 | #clock-cells = <1>; | 33 | #clock-cells = <1>; |
31 | clock-output-names = "main", "pll0, "pll1", "pll3", | 34 | clock-output-names = "main", "pll0, "pll1", "pll3", |
32 | "lb", "qspi", "sdh", "sd0", "sd1", "z"; | 35 | "lb", "qspi", "sdh", "sd0", "sd1", "z", |
36 | "rcan", "adsp"; | ||
33 | }; | 37 | }; |
diff --git a/drivers/clk/shmobile/Makefile b/drivers/clk/shmobile/Makefile index 960bf22d42ae..bef4e4fa6688 100644 --- a/drivers/clk/shmobile/Makefile +++ b/drivers/clk/shmobile/Makefile | |||
@@ -1,9 +1,11 @@ | |||
1 | obj-$(CONFIG_ARCH_EMEV2) += clk-emev2.o | 1 | obj-$(CONFIG_ARCH_EMEV2) += clk-emev2.o |
2 | obj-$(CONFIG_ARCH_R7S72100) += clk-rz.o | 2 | obj-$(CONFIG_ARCH_R7S72100) += clk-rz.o |
3 | obj-$(CONFIG_ARCH_R8A73A4) += clk-r8a73a4.o | ||
3 | obj-$(CONFIG_ARCH_R8A7740) += clk-r8a7740.o | 4 | obj-$(CONFIG_ARCH_R8A7740) += clk-r8a7740.o |
4 | obj-$(CONFIG_ARCH_R8A7779) += clk-r8a7779.o | 5 | obj-$(CONFIG_ARCH_R8A7779) += clk-r8a7779.o |
5 | obj-$(CONFIG_ARCH_R8A7790) += clk-rcar-gen2.o | 6 | obj-$(CONFIG_ARCH_R8A7790) += clk-rcar-gen2.o |
6 | obj-$(CONFIG_ARCH_R8A7791) += clk-rcar-gen2.o | 7 | obj-$(CONFIG_ARCH_R8A7791) += clk-rcar-gen2.o |
8 | obj-$(CONFIG_ARCH_R8A7793) += clk-rcar-gen2.o | ||
7 | obj-$(CONFIG_ARCH_R8A7794) += clk-rcar-gen2.o | 9 | obj-$(CONFIG_ARCH_R8A7794) += clk-rcar-gen2.o |
8 | obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += clk-div6.o | 10 | obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += clk-div6.o |
9 | obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += clk-mstp.o | 11 | obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += clk-mstp.o |
diff --git a/drivers/clk/shmobile/clk-div6.c b/drivers/clk/shmobile/clk-div6.c index 639241e31e03..efbaf6c81b75 100644 --- a/drivers/clk/shmobile/clk-div6.c +++ b/drivers/clk/shmobile/clk-div6.c | |||
@@ -54,12 +54,19 @@ static int cpg_div6_clock_enable(struct clk_hw *hw) | |||
54 | static void cpg_div6_clock_disable(struct clk_hw *hw) | 54 | static void cpg_div6_clock_disable(struct clk_hw *hw) |
55 | { | 55 | { |
56 | struct div6_clock *clock = to_div6_clock(hw); | 56 | struct div6_clock *clock = to_div6_clock(hw); |
57 | u32 val; | ||
57 | 58 | ||
58 | /* DIV6 clocks require the divisor field to be non-zero when stopping | 59 | val = clk_readl(clock->reg); |
59 | * the clock. | 60 | val |= CPG_DIV6_CKSTP; |
61 | /* | ||
62 | * DIV6 clocks require the divisor field to be non-zero when stopping | ||
63 | * the clock. However, some clocks (e.g. ZB on sh73a0) fail to be | ||
64 | * re-enabled later if the divisor field is changed when stopping the | ||
65 | * clock | ||
60 | */ | 66 | */ |
61 | clk_writel(clk_readl(clock->reg) | CPG_DIV6_CKSTP | CPG_DIV6_DIV_MASK, | 67 | if (!(val & CPG_DIV6_DIV_MASK)) |
62 | clock->reg); | 68 | val |= CPG_DIV6_DIV_MASK; |
69 | clk_writel(val, clock->reg); | ||
63 | } | 70 | } |
64 | 71 | ||
65 | static int cpg_div6_clock_is_enabled(struct clk_hw *hw) | 72 | static int cpg_div6_clock_is_enabled(struct clk_hw *hw) |
diff --git a/drivers/clk/shmobile/clk-r8a73a4.c b/drivers/clk/shmobile/clk-r8a73a4.c new file mode 100644 index 000000000000..29b9a0b0012a --- /dev/null +++ b/drivers/clk/shmobile/clk-r8a73a4.c | |||
@@ -0,0 +1,241 @@ | |||
1 | /* | ||
2 | * r8a73a4 Core CPG Clocks | ||
3 | * | ||
4 | * Copyright (C) 2014 Ulrich Hecht | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; version 2 of the License. | ||
9 | */ | ||
10 | |||
11 | #include <linux/clk-provider.h> | ||
12 | #include <linux/clkdev.h> | ||
13 | #include <linux/clk/shmobile.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/of.h> | ||
17 | #include <linux/of_address.h> | ||
18 | #include <linux/spinlock.h> | ||
19 | |||
20 | struct r8a73a4_cpg { | ||
21 | struct clk_onecell_data data; | ||
22 | spinlock_t lock; | ||
23 | void __iomem *reg; | ||
24 | }; | ||
25 | |||
26 | #define CPG_CKSCR 0xc0 | ||
27 | #define CPG_FRQCRA 0x00 | ||
28 | #define CPG_FRQCRB 0x04 | ||
29 | #define CPG_FRQCRC 0xe0 | ||
30 | #define CPG_PLL0CR 0xd8 | ||
31 | #define CPG_PLL1CR 0x28 | ||
32 | #define CPG_PLL2CR 0x2c | ||
33 | #define CPG_PLL2HCR 0xe4 | ||
34 | #define CPG_PLL2SCR 0xf4 | ||
35 | |||
36 | #define CLK_ENABLE_ON_INIT BIT(0) | ||
37 | |||
38 | struct div4_clk { | ||
39 | const char *name; | ||
40 | unsigned int reg; | ||
41 | unsigned int shift; | ||
42 | }; | ||
43 | |||
44 | static struct div4_clk div4_clks[] = { | ||
45 | { "i", CPG_FRQCRA, 20 }, | ||
46 | { "m3", CPG_FRQCRA, 12 }, | ||
47 | { "b", CPG_FRQCRA, 8 }, | ||
48 | { "m1", CPG_FRQCRA, 4 }, | ||
49 | { "m2", CPG_FRQCRA, 0 }, | ||
50 | { "zx", CPG_FRQCRB, 12 }, | ||
51 | { "zs", CPG_FRQCRB, 8 }, | ||
52 | { "hp", CPG_FRQCRB, 4 }, | ||
53 | { NULL, 0, 0 }, | ||
54 | }; | ||
55 | |||
56 | static const struct clk_div_table div4_div_table[] = { | ||
57 | { 0, 2 }, { 1, 3 }, { 2, 4 }, { 3, 6 }, { 4, 8 }, { 5, 12 }, | ||
58 | { 6, 16 }, { 7, 18 }, { 8, 24 }, { 10, 36 }, { 11, 48 }, | ||
59 | { 12, 10 }, { 0, 0 } | ||
60 | }; | ||
61 | |||
62 | static struct clk * __init | ||
63 | r8a73a4_cpg_register_clock(struct device_node *np, struct r8a73a4_cpg *cpg, | ||
64 | const char *name) | ||
65 | { | ||
66 | const struct clk_div_table *table = NULL; | ||
67 | const char *parent_name; | ||
68 | unsigned int shift, reg; | ||
69 | unsigned int mult = 1; | ||
70 | unsigned int div = 1; | ||
71 | |||
72 | |||
73 | if (!strcmp(name, "main")) { | ||
74 | u32 ckscr = clk_readl(cpg->reg + CPG_CKSCR); | ||
75 | |||
76 | switch ((ckscr >> 28) & 3) { | ||
77 | case 0: /* extal1 */ | ||
78 | parent_name = of_clk_get_parent_name(np, 0); | ||
79 | break; | ||
80 | case 1: /* extal1 / 2 */ | ||
81 | parent_name = of_clk_get_parent_name(np, 0); | ||
82 | div = 2; | ||
83 | break; | ||
84 | case 2: /* extal2 */ | ||
85 | parent_name = of_clk_get_parent_name(np, 1); | ||
86 | break; | ||
87 | case 3: /* extal2 / 2 */ | ||
88 | parent_name = of_clk_get_parent_name(np, 1); | ||
89 | div = 2; | ||
90 | break; | ||
91 | } | ||
92 | } else if (!strcmp(name, "pll0")) { | ||
93 | /* PLL0/1 are configurable multiplier clocks. Register them as | ||
94 | * fixed factor clocks for now as there's no generic multiplier | ||
95 | * clock implementation and we currently have no need to change | ||
96 | * the multiplier value. | ||
97 | */ | ||
98 | u32 value = clk_readl(cpg->reg + CPG_PLL0CR); | ||
99 | |||
100 | parent_name = "main"; | ||
101 | mult = ((value >> 24) & 0x7f) + 1; | ||
102 | if (value & BIT(20)) | ||
103 | div = 2; | ||
104 | } else if (!strcmp(name, "pll1")) { | ||
105 | u32 value = clk_readl(cpg->reg + CPG_PLL1CR); | ||
106 | |||
107 | parent_name = "main"; | ||
108 | /* XXX: enable bit? */ | ||
109 | mult = ((value >> 24) & 0x7f) + 1; | ||
110 | if (value & BIT(7)) | ||
111 | div = 2; | ||
112 | } else if (!strncmp(name, "pll2", 4)) { | ||
113 | u32 value, cr; | ||
114 | |||
115 | switch (name[4]) { | ||
116 | case 0: | ||
117 | cr = CPG_PLL2CR; | ||
118 | break; | ||
119 | case 's': | ||
120 | cr = CPG_PLL2SCR; | ||
121 | break; | ||
122 | case 'h': | ||
123 | cr = CPG_PLL2HCR; | ||
124 | break; | ||
125 | default: | ||
126 | return ERR_PTR(-EINVAL); | ||
127 | } | ||
128 | value = clk_readl(cpg->reg + cr); | ||
129 | switch ((value >> 5) & 7) { | ||
130 | case 0: | ||
131 | parent_name = "main"; | ||
132 | div = 2; | ||
133 | break; | ||
134 | case 1: | ||
135 | parent_name = "extal2"; | ||
136 | div = 2; | ||
137 | break; | ||
138 | case 3: | ||
139 | parent_name = "extal2"; | ||
140 | div = 4; | ||
141 | break; | ||
142 | case 4: | ||
143 | parent_name = "main"; | ||
144 | break; | ||
145 | case 5: | ||
146 | parent_name = "extal2"; | ||
147 | break; | ||
148 | default: | ||
149 | pr_warn("%s: unexpected parent of %s\n", __func__, | ||
150 | name); | ||
151 | return ERR_PTR(-EINVAL); | ||
152 | } | ||
153 | /* XXX: enable bit? */ | ||
154 | mult = ((value >> 24) & 0x7f) + 1; | ||
155 | } else if (!strcmp(name, "z") || !strcmp(name, "z2")) { | ||
156 | u32 shift = 8; | ||
157 | |||
158 | parent_name = "pll0"; | ||
159 | if (name[1] == '2') { | ||
160 | div = 2; | ||
161 | shift = 0; | ||
162 | } | ||
163 | div *= 32; | ||
164 | mult = 0x20 - ((clk_readl(cpg->reg + CPG_FRQCRC) >> shift) | ||
165 | & 0x1f); | ||
166 | } else { | ||
167 | struct div4_clk *c; | ||
168 | |||
169 | for (c = div4_clks; c->name; c++) { | ||
170 | if (!strcmp(name, c->name)) | ||
171 | break; | ||
172 | } | ||
173 | if (!c->name) | ||
174 | return ERR_PTR(-EINVAL); | ||
175 | |||
176 | parent_name = "pll1"; | ||
177 | table = div4_div_table; | ||
178 | reg = c->reg; | ||
179 | shift = c->shift; | ||
180 | } | ||
181 | |||
182 | if (!table) { | ||
183 | return clk_register_fixed_factor(NULL, name, parent_name, 0, | ||
184 | mult, div); | ||
185 | } else { | ||
186 | return clk_register_divider_table(NULL, name, parent_name, 0, | ||
187 | cpg->reg + reg, shift, 4, 0, | ||
188 | table, &cpg->lock); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | static void __init r8a73a4_cpg_clocks_init(struct device_node *np) | ||
193 | { | ||
194 | struct r8a73a4_cpg *cpg; | ||
195 | struct clk **clks; | ||
196 | unsigned int i; | ||
197 | int num_clks; | ||
198 | |||
199 | num_clks = of_property_count_strings(np, "clock-output-names"); | ||
200 | if (num_clks < 0) { | ||
201 | pr_err("%s: failed to count clocks\n", __func__); | ||
202 | return; | ||
203 | } | ||
204 | |||
205 | cpg = kzalloc(sizeof(*cpg), GFP_KERNEL); | ||
206 | clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL); | ||
207 | if (cpg == NULL || clks == NULL) { | ||
208 | /* We're leaking memory on purpose, there's no point in cleaning | ||
209 | * up as the system won't boot anyway. | ||
210 | */ | ||
211 | return; | ||
212 | } | ||
213 | |||
214 | spin_lock_init(&cpg->lock); | ||
215 | |||
216 | cpg->data.clks = clks; | ||
217 | cpg->data.clk_num = num_clks; | ||
218 | |||
219 | cpg->reg = of_iomap(np, 0); | ||
220 | if (WARN_ON(cpg->reg == NULL)) | ||
221 | return; | ||
222 | |||
223 | for (i = 0; i < num_clks; ++i) { | ||
224 | const char *name; | ||
225 | struct clk *clk; | ||
226 | |||
227 | of_property_read_string_index(np, "clock-output-names", i, | ||
228 | &name); | ||
229 | |||
230 | clk = r8a73a4_cpg_register_clock(np, cpg, name); | ||
231 | if (IS_ERR(clk)) | ||
232 | pr_err("%s: failed to register %s %s clock (%ld)\n", | ||
233 | __func__, np->name, name, PTR_ERR(clk)); | ||
234 | else | ||
235 | cpg->data.clks[i] = clk; | ||
236 | } | ||
237 | |||
238 | of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data); | ||
239 | } | ||
240 | CLK_OF_DECLARE(r8a73a4_cpg_clks, "renesas,r8a73a4-cpg-clocks", | ||
241 | r8a73a4_cpg_clocks_init); | ||
diff --git a/drivers/clk/shmobile/clk-rcar-gen2.c b/drivers/clk/shmobile/clk-rcar-gen2.c index e996425d06a9..acfb6d7dbd6b 100644 --- a/drivers/clk/shmobile/clk-rcar-gen2.c +++ b/drivers/clk/shmobile/clk-rcar-gen2.c | |||
@@ -33,6 +33,8 @@ struct rcar_gen2_cpg { | |||
33 | #define CPG_FRQCRC 0x000000e0 | 33 | #define CPG_FRQCRC 0x000000e0 |
34 | #define CPG_FRQCRC_ZFC_MASK (0x1f << 8) | 34 | #define CPG_FRQCRC_ZFC_MASK (0x1f << 8) |
35 | #define CPG_FRQCRC_ZFC_SHIFT 8 | 35 | #define CPG_FRQCRC_ZFC_SHIFT 8 |
36 | #define CPG_ADSPCKCR 0x0000025c | ||
37 | #define CPG_RCANCKCR 0x00000270 | ||
36 | 38 | ||
37 | /* ----------------------------------------------------------------------------- | 39 | /* ----------------------------------------------------------------------------- |
38 | * Z Clock | 40 | * Z Clock |
@@ -161,6 +163,88 @@ static struct clk * __init cpg_z_clk_register(struct rcar_gen2_cpg *cpg) | |||
161 | return clk; | 163 | return clk; |
162 | } | 164 | } |
163 | 165 | ||
166 | static struct clk * __init cpg_rcan_clk_register(struct rcar_gen2_cpg *cpg, | ||
167 | struct device_node *np) | ||
168 | { | ||
169 | const char *parent_name = of_clk_get_parent_name(np, 1); | ||
170 | struct clk_fixed_factor *fixed; | ||
171 | struct clk_gate *gate; | ||
172 | struct clk *clk; | ||
173 | |||
174 | fixed = kzalloc(sizeof(*fixed), GFP_KERNEL); | ||
175 | if (!fixed) | ||
176 | return ERR_PTR(-ENOMEM); | ||
177 | |||
178 | fixed->mult = 1; | ||
179 | fixed->div = 6; | ||
180 | |||
181 | gate = kzalloc(sizeof(*gate), GFP_KERNEL); | ||
182 | if (!gate) { | ||
183 | kfree(fixed); | ||
184 | return ERR_PTR(-ENOMEM); | ||
185 | } | ||
186 | |||
187 | gate->reg = cpg->reg + CPG_RCANCKCR; | ||
188 | gate->bit_idx = 8; | ||
189 | gate->flags = CLK_GATE_SET_TO_DISABLE; | ||
190 | gate->lock = &cpg->lock; | ||
191 | |||
192 | clk = clk_register_composite(NULL, "rcan", &parent_name, 1, NULL, NULL, | ||
193 | &fixed->hw, &clk_fixed_factor_ops, | ||
194 | &gate->hw, &clk_gate_ops, 0); | ||
195 | if (IS_ERR(clk)) { | ||
196 | kfree(gate); | ||
197 | kfree(fixed); | ||
198 | } | ||
199 | |||
200 | return clk; | ||
201 | } | ||
202 | |||
203 | /* ADSP divisors */ | ||
204 | static const struct clk_div_table cpg_adsp_div_table[] = { | ||
205 | { 1, 3 }, { 2, 4 }, { 3, 6 }, { 4, 8 }, | ||
206 | { 5, 12 }, { 6, 16 }, { 7, 18 }, { 8, 24 }, | ||
207 | { 10, 36 }, { 11, 48 }, { 0, 0 }, | ||
208 | }; | ||
209 | |||
210 | static struct clk * __init cpg_adsp_clk_register(struct rcar_gen2_cpg *cpg) | ||
211 | { | ||
212 | const char *parent_name = "pll1"; | ||
213 | struct clk_divider *div; | ||
214 | struct clk_gate *gate; | ||
215 | struct clk *clk; | ||
216 | |||
217 | div = kzalloc(sizeof(*div), GFP_KERNEL); | ||
218 | if (!div) | ||
219 | return ERR_PTR(-ENOMEM); | ||
220 | |||
221 | div->reg = cpg->reg + CPG_ADSPCKCR; | ||
222 | div->width = 4; | ||
223 | div->table = cpg_adsp_div_table; | ||
224 | div->lock = &cpg->lock; | ||
225 | |||
226 | gate = kzalloc(sizeof(*gate), GFP_KERNEL); | ||
227 | if (!gate) { | ||
228 | kfree(div); | ||
229 | return ERR_PTR(-ENOMEM); | ||
230 | } | ||
231 | |||
232 | gate->reg = cpg->reg + CPG_ADSPCKCR; | ||
233 | gate->bit_idx = 8; | ||
234 | gate->flags = CLK_GATE_SET_TO_DISABLE; | ||
235 | gate->lock = &cpg->lock; | ||
236 | |||
237 | clk = clk_register_composite(NULL, "adsp", &parent_name, 1, NULL, NULL, | ||
238 | &div->hw, &clk_divider_ops, | ||
239 | &gate->hw, &clk_gate_ops, 0); | ||
240 | if (IS_ERR(clk)) { | ||
241 | kfree(gate); | ||
242 | kfree(div); | ||
243 | } | ||
244 | |||
245 | return clk; | ||
246 | } | ||
247 | |||
164 | /* ----------------------------------------------------------------------------- | 248 | /* ----------------------------------------------------------------------------- |
165 | * CPG Clock Data | 249 | * CPG Clock Data |
166 | */ | 250 | */ |
@@ -263,6 +347,10 @@ rcar_gen2_cpg_register_clock(struct device_node *np, struct rcar_gen2_cpg *cpg, | |||
263 | shift = 0; | 347 | shift = 0; |
264 | } else if (!strcmp(name, "z")) { | 348 | } else if (!strcmp(name, "z")) { |
265 | return cpg_z_clk_register(cpg); | 349 | return cpg_z_clk_register(cpg); |
350 | } else if (!strcmp(name, "rcan")) { | ||
351 | return cpg_rcan_clk_register(cpg, np); | ||
352 | } else if (!strcmp(name, "adsp")) { | ||
353 | return cpg_adsp_clk_register(cpg); | ||
266 | } else { | 354 | } else { |
267 | return ERR_PTR(-EINVAL); | 355 | return ERR_PTR(-EINVAL); |
268 | } | 356 | } |