blob: 6e33332b6b34fcfbeb006c323507620e678eda7e [file] [log] [blame]
Tero Kristoaafd9002013-08-02 14:04:19 +03001/*
2 * OMAP3 Clock init
3 *
4 * Copyright (C) 2013 Texas Instruments, Inc
5 * Tero Kristo (t-kristo@ti.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation version 2.
10 *
11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12 * kind, whether express or implied; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/kernel.h>
18#include <linux/list.h>
19#include <linux/clk-provider.h>
20#include <linux/clk/ti.h>
21
Tero Kristoa5aa8a62015-03-03 10:51:01 +020022#include "clock.h"
Tero Kristoaafd9002013-08-02 14:04:19 +030023
Tero Kristo0565fb12015-03-03 13:27:48 +020024/*
25 * DPLL5_FREQ_FOR_USBHOST: USBHOST and USBTLL are the only clocks
26 * that are sourced by DPLL5, and both of these require this clock
27 * to be at 120 MHz for proper operation.
28 */
29#define DPLL5_FREQ_FOR_USBHOST 120000000
30
Tero Kristof2671d52015-03-03 17:28:12 +020031#define OMAP3430ES2_ST_DSS_IDLE_SHIFT 1
32#define OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT 5
33#define OMAP3430ES2_ST_SSI_IDLE_SHIFT 8
34
35#define OMAP34XX_CM_IDLEST_VAL 1
36
Tero Kristoc9a58b02015-03-03 21:19:25 +020037/*
38 * In AM35xx IPSS, the {ICK,FCK} enable bits for modules are exported
39 * in the same register at a bit offset of 0x8. The EN_ACK for ICK is
40 * at an offset of 4 from ICK enable bit.
41 */
42#define AM35XX_IPSS_ICK_MASK 0xF
43#define AM35XX_IPSS_ICK_EN_ACK_OFFSET 0x4
44#define AM35XX_IPSS_ICK_FCK_OFFSET 0x8
45#define AM35XX_IPSS_CLK_IDLEST_VAL 0
46
47#define AM35XX_ST_IPSS_SHIFT 5
48
Tero Kristof2671d52015-03-03 17:28:12 +020049/**
50 * omap3430es2_clk_ssi_find_idlest - return CM_IDLEST info for SSI
51 * @clk: struct clk * being enabled
52 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
53 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
54 * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
55 *
56 * The OMAP3430ES2 SSI target CM_IDLEST bit is at a different shift
57 * from the CM_{I,F}CLKEN bit. Pass back the correct info via
58 * @idlest_reg and @idlest_bit. No return value.
59 */
60static void omap3430es2_clk_ssi_find_idlest(struct clk_hw_omap *clk,
61 void __iomem **idlest_reg,
62 u8 *idlest_bit,
63 u8 *idlest_val)
64{
65 u32 r;
66
67 r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
68 *idlest_reg = (__force void __iomem *)r;
69 *idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT;
70 *idlest_val = OMAP34XX_CM_IDLEST_VAL;
71}
72
73const struct clk_hw_omap_ops clkhwops_omap3430es2_ssi_wait = {
74 .find_idlest = omap3430es2_clk_ssi_find_idlest,
75 .find_companion = omap2_clk_dflt_find_companion,
76};
77
78const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait = {
79 .allow_idle = omap2_clkt_iclk_allow_idle,
80 .deny_idle = omap2_clkt_iclk_deny_idle,
81 .find_idlest = omap3430es2_clk_ssi_find_idlest,
82 .find_companion = omap2_clk_dflt_find_companion,
83};
84
85/**
86 * omap3430es2_clk_dss_usbhost_find_idlest - CM_IDLEST info for DSS, USBHOST
87 * @clk: struct clk * being enabled
88 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
89 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
90 * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
91 *
92 * Some OMAP modules on OMAP3 ES2+ chips have both initiator and
93 * target IDLEST bits. For our purposes, we are concerned with the
94 * target IDLEST bits, which exist at a different bit position than
95 * the *CLKEN bit position for these modules (DSS and USBHOST) (The
96 * default find_idlest code assumes that they are at the same
97 * position.) No return value.
98 */
99static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk_hw_omap *clk,
100 void __iomem **idlest_reg,
101 u8 *idlest_bit,
102 u8 *idlest_val)
103{
104 u32 r;
105
106 r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
107 *idlest_reg = (__force void __iomem *)r;
108 /* USBHOST_IDLE has same shift */
109 *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT;
110 *idlest_val = OMAP34XX_CM_IDLEST_VAL;
111}
112
113const struct clk_hw_omap_ops clkhwops_omap3430es2_dss_usbhost_wait = {
114 .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
115 .find_companion = omap2_clk_dflt_find_companion,
116};
117
118const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait = {
119 .allow_idle = omap2_clkt_iclk_allow_idle,
120 .deny_idle = omap2_clkt_iclk_deny_idle,
121 .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
122 .find_companion = omap2_clk_dflt_find_companion,
123};
124
125/**
126 * omap3430es2_clk_hsotgusb_find_idlest - return CM_IDLEST info for HSOTGUSB
127 * @clk: struct clk * being enabled
128 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
129 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
130 * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
131 *
132 * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different
133 * shift from the CM_{I,F}CLKEN bit. Pass back the correct info via
134 * @idlest_reg and @idlest_bit. No return value.
135 */
136static void omap3430es2_clk_hsotgusb_find_idlest(struct clk_hw_omap *clk,
137 void __iomem **idlest_reg,
138 u8 *idlest_bit,
139 u8 *idlest_val)
140{
141 u32 r;
142
143 r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
144 *idlest_reg = (__force void __iomem *)r;
145 *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT;
146 *idlest_val = OMAP34XX_CM_IDLEST_VAL;
147}
148
149const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait = {
150 .allow_idle = omap2_clkt_iclk_allow_idle,
151 .deny_idle = omap2_clkt_iclk_deny_idle,
152 .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
153 .find_companion = omap2_clk_dflt_find_companion,
154};
155
156const struct clk_hw_omap_ops clkhwops_omap3430es2_hsotgusb_wait = {
157 .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
158 .find_companion = omap2_clk_dflt_find_companion,
159};
160
Tero Kristoc9a58b02015-03-03 21:19:25 +0200161/**
162 * am35xx_clk_find_idlest - return clock ACK info for AM35XX IPSS
163 * @clk: struct clk * being enabled
164 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
165 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
166 * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
167 *
168 * The interface clocks on AM35xx IPSS reflects the clock idle status
169 * in the enable register itsel at a bit offset of 4 from the enable
170 * bit. A value of 1 indicates that clock is enabled.
171 */
172static void am35xx_clk_find_idlest(struct clk_hw_omap *clk,
173 void __iomem **idlest_reg,
174 u8 *idlest_bit,
175 u8 *idlest_val)
176{
177 *idlest_reg = (__force void __iomem *)(clk->enable_reg);
178 *idlest_bit = clk->enable_bit + AM35XX_IPSS_ICK_EN_ACK_OFFSET;
179 *idlest_val = AM35XX_IPSS_CLK_IDLEST_VAL;
180}
181
182/**
183 * am35xx_clk_find_companion - find companion clock to @clk
184 * @clk: struct clk * to find the companion clock of
185 * @other_reg: void __iomem ** to return the companion clock CM_*CLKEN va in
186 * @other_bit: u8 ** to return the companion clock bit shift in
187 *
188 * Some clocks don't have companion clocks. For example, modules with
189 * only an interface clock (such as HECC) don't have a companion
190 * clock. Right now, this code relies on the hardware exporting a bit
191 * in the correct companion register that indicates that the
192 * nonexistent 'companion clock' is active. Future patches will
193 * associate this type of code with per-module data structures to
194 * avoid this issue, and remove the casts. No return value.
195 */
196static void am35xx_clk_find_companion(struct clk_hw_omap *clk,
197 void __iomem **other_reg,
198 u8 *other_bit)
199{
200 *other_reg = (__force void __iomem *)(clk->enable_reg);
201 if (clk->enable_bit & AM35XX_IPSS_ICK_MASK)
202 *other_bit = clk->enable_bit + AM35XX_IPSS_ICK_FCK_OFFSET;
203 else
204 *other_bit = clk->enable_bit - AM35XX_IPSS_ICK_FCK_OFFSET;
205}
206
207const struct clk_hw_omap_ops clkhwops_am35xx_ipss_module_wait = {
208 .find_idlest = am35xx_clk_find_idlest,
209 .find_companion = am35xx_clk_find_companion,
210};
211
212/**
213 * am35xx_clk_ipss_find_idlest - return CM_IDLEST info for IPSS
214 * @clk: struct clk * being enabled
215 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
216 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
217 * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
218 *
219 * The IPSS target CM_IDLEST bit is at a different shift from the
220 * CM_{I,F}CLKEN bit. Pass back the correct info via @idlest_reg
221 * and @idlest_bit. No return value.
222 */
223static void am35xx_clk_ipss_find_idlest(struct clk_hw_omap *clk,
224 void __iomem **idlest_reg,
225 u8 *idlest_bit,
226 u8 *idlest_val)
227{
228 u32 r;
229
230 r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
231 *idlest_reg = (__force void __iomem *)r;
232 *idlest_bit = AM35XX_ST_IPSS_SHIFT;
233 *idlest_val = OMAP34XX_CM_IDLEST_VAL;
234}
235
236const struct clk_hw_omap_ops clkhwops_am35xx_ipss_wait = {
237 .allow_idle = omap2_clkt_iclk_allow_idle,
238 .deny_idle = omap2_clkt_iclk_deny_idle,
239 .find_idlest = am35xx_clk_ipss_find_idlest,
240 .find_companion = omap2_clk_dflt_find_companion,
241};
242
Tero Kristoaafd9002013-08-02 14:04:19 +0300243static struct ti_dt_clk omap3xxx_clks[] = {
244 DT_CLK(NULL, "apb_pclk", "dummy_apb_pclk"),
245 DT_CLK(NULL, "omap_32k_fck", "omap_32k_fck"),
246 DT_CLK(NULL, "virt_12m_ck", "virt_12m_ck"),
247 DT_CLK(NULL, "virt_13m_ck", "virt_13m_ck"),
248 DT_CLK(NULL, "virt_19200000_ck", "virt_19200000_ck"),
249 DT_CLK(NULL, "virt_26000000_ck", "virt_26000000_ck"),
250 DT_CLK(NULL, "virt_38_4m_ck", "virt_38_4m_ck"),
251 DT_CLK(NULL, "osc_sys_ck", "osc_sys_ck"),
252 DT_CLK("twl", "fck", "osc_sys_ck"),
253 DT_CLK(NULL, "sys_ck", "sys_ck"),
254 DT_CLK(NULL, "omap_96m_alwon_fck", "omap_96m_alwon_fck"),
255 DT_CLK("etb", "emu_core_alwon_ck", "emu_core_alwon_ck"),
256 DT_CLK(NULL, "sys_altclk", "sys_altclk"),
Tero Kristoaafd9002013-08-02 14:04:19 +0300257 DT_CLK(NULL, "sys_clkout1", "sys_clkout1"),
258 DT_CLK(NULL, "dpll1_ck", "dpll1_ck"),
259 DT_CLK(NULL, "dpll1_x2_ck", "dpll1_x2_ck"),
260 DT_CLK(NULL, "dpll1_x2m2_ck", "dpll1_x2m2_ck"),
261 DT_CLK(NULL, "dpll3_ck", "dpll3_ck"),
262 DT_CLK(NULL, "core_ck", "core_ck"),
263 DT_CLK(NULL, "dpll3_x2_ck", "dpll3_x2_ck"),
264 DT_CLK(NULL, "dpll3_m2_ck", "dpll3_m2_ck"),
265 DT_CLK(NULL, "dpll3_m2x2_ck", "dpll3_m2x2_ck"),
266 DT_CLK(NULL, "dpll3_m3_ck", "dpll3_m3_ck"),
267 DT_CLK(NULL, "dpll3_m3x2_ck", "dpll3_m3x2_ck"),
268 DT_CLK(NULL, "dpll4_ck", "dpll4_ck"),
269 DT_CLK(NULL, "dpll4_x2_ck", "dpll4_x2_ck"),
270 DT_CLK(NULL, "omap_96m_fck", "omap_96m_fck"),
271 DT_CLK(NULL, "cm_96m_fck", "cm_96m_fck"),
272 DT_CLK(NULL, "omap_54m_fck", "omap_54m_fck"),
273 DT_CLK(NULL, "omap_48m_fck", "omap_48m_fck"),
274 DT_CLK(NULL, "omap_12m_fck", "omap_12m_fck"),
275 DT_CLK(NULL, "dpll4_m2_ck", "dpll4_m2_ck"),
276 DT_CLK(NULL, "dpll4_m2x2_ck", "dpll4_m2x2_ck"),
277 DT_CLK(NULL, "dpll4_m3_ck", "dpll4_m3_ck"),
278 DT_CLK(NULL, "dpll4_m3x2_ck", "dpll4_m3x2_ck"),
279 DT_CLK(NULL, "dpll4_m4_ck", "dpll4_m4_ck"),
280 DT_CLK(NULL, "dpll4_m4x2_ck", "dpll4_m4x2_ck"),
281 DT_CLK(NULL, "dpll4_m5_ck", "dpll4_m5_ck"),
282 DT_CLK(NULL, "dpll4_m5x2_ck", "dpll4_m5x2_ck"),
283 DT_CLK(NULL, "dpll4_m6_ck", "dpll4_m6_ck"),
284 DT_CLK(NULL, "dpll4_m6x2_ck", "dpll4_m6x2_ck"),
285 DT_CLK("etb", "emu_per_alwon_ck", "emu_per_alwon_ck"),
286 DT_CLK(NULL, "clkout2_src_ck", "clkout2_src_ck"),
287 DT_CLK(NULL, "sys_clkout2", "sys_clkout2"),
288 DT_CLK(NULL, "corex2_fck", "corex2_fck"),
289 DT_CLK(NULL, "dpll1_fck", "dpll1_fck"),
290 DT_CLK(NULL, "mpu_ck", "mpu_ck"),
291 DT_CLK(NULL, "arm_fck", "arm_fck"),
292 DT_CLK("etb", "emu_mpu_alwon_ck", "emu_mpu_alwon_ck"),
293 DT_CLK(NULL, "l3_ick", "l3_ick"),
294 DT_CLK(NULL, "l4_ick", "l4_ick"),
295 DT_CLK(NULL, "rm_ick", "rm_ick"),
296 DT_CLK(NULL, "gpt10_fck", "gpt10_fck"),
297 DT_CLK(NULL, "gpt11_fck", "gpt11_fck"),
298 DT_CLK(NULL, "core_96m_fck", "core_96m_fck"),
299 DT_CLK(NULL, "mmchs2_fck", "mmchs2_fck"),
300 DT_CLK(NULL, "mmchs1_fck", "mmchs1_fck"),
301 DT_CLK(NULL, "i2c3_fck", "i2c3_fck"),
302 DT_CLK(NULL, "i2c2_fck", "i2c2_fck"),
303 DT_CLK(NULL, "i2c1_fck", "i2c1_fck"),
Tero Kristoaafd9002013-08-02 14:04:19 +0300304 DT_CLK(NULL, "core_48m_fck", "core_48m_fck"),
305 DT_CLK(NULL, "mcspi4_fck", "mcspi4_fck"),
306 DT_CLK(NULL, "mcspi3_fck", "mcspi3_fck"),
307 DT_CLK(NULL, "mcspi2_fck", "mcspi2_fck"),
308 DT_CLK(NULL, "mcspi1_fck", "mcspi1_fck"),
309 DT_CLK(NULL, "uart2_fck", "uart2_fck"),
310 DT_CLK(NULL, "uart1_fck", "uart1_fck"),
311 DT_CLK(NULL, "core_12m_fck", "core_12m_fck"),
312 DT_CLK("omap_hdq.0", "fck", "hdq_fck"),
313 DT_CLK(NULL, "hdq_fck", "hdq_fck"),
314 DT_CLK(NULL, "core_l3_ick", "core_l3_ick"),
315 DT_CLK(NULL, "sdrc_ick", "sdrc_ick"),
316 DT_CLK(NULL, "gpmc_fck", "gpmc_fck"),
317 DT_CLK(NULL, "core_l4_ick", "core_l4_ick"),
318 DT_CLK("omap_hsmmc.1", "ick", "mmchs2_ick"),
319 DT_CLK("omap_hsmmc.0", "ick", "mmchs1_ick"),
320 DT_CLK(NULL, "mmchs2_ick", "mmchs2_ick"),
321 DT_CLK(NULL, "mmchs1_ick", "mmchs1_ick"),
322 DT_CLK("omap_hdq.0", "ick", "hdq_ick"),
323 DT_CLK(NULL, "hdq_ick", "hdq_ick"),
324 DT_CLK("omap2_mcspi.4", "ick", "mcspi4_ick"),
325 DT_CLK("omap2_mcspi.3", "ick", "mcspi3_ick"),
326 DT_CLK("omap2_mcspi.2", "ick", "mcspi2_ick"),
327 DT_CLK("omap2_mcspi.1", "ick", "mcspi1_ick"),
328 DT_CLK(NULL, "mcspi4_ick", "mcspi4_ick"),
329 DT_CLK(NULL, "mcspi3_ick", "mcspi3_ick"),
330 DT_CLK(NULL, "mcspi2_ick", "mcspi2_ick"),
331 DT_CLK(NULL, "mcspi1_ick", "mcspi1_ick"),
332 DT_CLK("omap_i2c.3", "ick", "i2c3_ick"),
333 DT_CLK("omap_i2c.2", "ick", "i2c2_ick"),
334 DT_CLK("omap_i2c.1", "ick", "i2c1_ick"),
335 DT_CLK(NULL, "i2c3_ick", "i2c3_ick"),
336 DT_CLK(NULL, "i2c2_ick", "i2c2_ick"),
337 DT_CLK(NULL, "i2c1_ick", "i2c1_ick"),
338 DT_CLK(NULL, "uart2_ick", "uart2_ick"),
339 DT_CLK(NULL, "uart1_ick", "uart1_ick"),
340 DT_CLK(NULL, "gpt11_ick", "gpt11_ick"),
341 DT_CLK(NULL, "gpt10_ick", "gpt10_ick"),
Tero Kristoaafd9002013-08-02 14:04:19 +0300342 DT_CLK(NULL, "omapctrl_ick", "omapctrl_ick"),
343 DT_CLK(NULL, "dss_tv_fck", "dss_tv_fck"),
344 DT_CLK(NULL, "dss_96m_fck", "dss_96m_fck"),
345 DT_CLK(NULL, "dss2_alwon_fck", "dss2_alwon_fck"),
Tero Kristoaafd9002013-08-02 14:04:19 +0300346 DT_CLK(NULL, "init_60m_fclk", "dummy_ck"),
347 DT_CLK(NULL, "gpt1_fck", "gpt1_fck"),
348 DT_CLK(NULL, "aes2_ick", "aes2_ick"),
349 DT_CLK(NULL, "wkup_32k_fck", "wkup_32k_fck"),
350 DT_CLK(NULL, "gpio1_dbck", "gpio1_dbck"),
351 DT_CLK(NULL, "sha12_ick", "sha12_ick"),
352 DT_CLK(NULL, "wdt2_fck", "wdt2_fck"),
353 DT_CLK("omap_wdt", "ick", "wdt2_ick"),
354 DT_CLK(NULL, "wdt2_ick", "wdt2_ick"),
355 DT_CLK(NULL, "wdt1_ick", "wdt1_ick"),
356 DT_CLK(NULL, "gpio1_ick", "gpio1_ick"),
357 DT_CLK(NULL, "omap_32ksync_ick", "omap_32ksync_ick"),
358 DT_CLK(NULL, "gpt12_ick", "gpt12_ick"),
359 DT_CLK(NULL, "gpt1_ick", "gpt1_ick"),
360 DT_CLK(NULL, "per_96m_fck", "per_96m_fck"),
361 DT_CLK(NULL, "per_48m_fck", "per_48m_fck"),
362 DT_CLK(NULL, "uart3_fck", "uart3_fck"),
363 DT_CLK(NULL, "gpt2_fck", "gpt2_fck"),
364 DT_CLK(NULL, "gpt3_fck", "gpt3_fck"),
365 DT_CLK(NULL, "gpt4_fck", "gpt4_fck"),
366 DT_CLK(NULL, "gpt5_fck", "gpt5_fck"),
367 DT_CLK(NULL, "gpt6_fck", "gpt6_fck"),
368 DT_CLK(NULL, "gpt7_fck", "gpt7_fck"),
369 DT_CLK(NULL, "gpt8_fck", "gpt8_fck"),
370 DT_CLK(NULL, "gpt9_fck", "gpt9_fck"),
371 DT_CLK(NULL, "per_32k_alwon_fck", "per_32k_alwon_fck"),
372 DT_CLK(NULL, "gpio6_dbck", "gpio6_dbck"),
373 DT_CLK(NULL, "gpio5_dbck", "gpio5_dbck"),
374 DT_CLK(NULL, "gpio4_dbck", "gpio4_dbck"),
375 DT_CLK(NULL, "gpio3_dbck", "gpio3_dbck"),
376 DT_CLK(NULL, "gpio2_dbck", "gpio2_dbck"),
377 DT_CLK(NULL, "wdt3_fck", "wdt3_fck"),
378 DT_CLK(NULL, "per_l4_ick", "per_l4_ick"),
379 DT_CLK(NULL, "gpio6_ick", "gpio6_ick"),
380 DT_CLK(NULL, "gpio5_ick", "gpio5_ick"),
381 DT_CLK(NULL, "gpio4_ick", "gpio4_ick"),
382 DT_CLK(NULL, "gpio3_ick", "gpio3_ick"),
383 DT_CLK(NULL, "gpio2_ick", "gpio2_ick"),
384 DT_CLK(NULL, "wdt3_ick", "wdt3_ick"),
385 DT_CLK(NULL, "uart3_ick", "uart3_ick"),
386 DT_CLK(NULL, "uart4_ick", "uart4_ick"),
387 DT_CLK(NULL, "gpt9_ick", "gpt9_ick"),
388 DT_CLK(NULL, "gpt8_ick", "gpt8_ick"),
389 DT_CLK(NULL, "gpt7_ick", "gpt7_ick"),
390 DT_CLK(NULL, "gpt6_ick", "gpt6_ick"),
391 DT_CLK(NULL, "gpt5_ick", "gpt5_ick"),
392 DT_CLK(NULL, "gpt4_ick", "gpt4_ick"),
393 DT_CLK(NULL, "gpt3_ick", "gpt3_ick"),
394 DT_CLK(NULL, "gpt2_ick", "gpt2_ick"),
Peter Ujfalusif757d1b2015-03-16 12:40:57 +0200395 DT_CLK(NULL, "mcbsp_clks", "mcbsp_clks"),
396 DT_CLK(NULL, "mcbsp1_ick", "mcbsp1_ick"),
397 DT_CLK(NULL, "mcbsp2_ick", "mcbsp2_ick"),
Tero Kristoaafd9002013-08-02 14:04:19 +0300398 DT_CLK(NULL, "mcbsp3_ick", "mcbsp3_ick"),
Peter Ujfalusif757d1b2015-03-16 12:40:57 +0200399 DT_CLK(NULL, "mcbsp4_ick", "mcbsp4_ick"),
400 DT_CLK(NULL, "mcbsp5_ick", "mcbsp5_ick"),
401 DT_CLK(NULL, "mcbsp1_fck", "mcbsp1_fck"),
Tero Kristoaafd9002013-08-02 14:04:19 +0300402 DT_CLK(NULL, "mcbsp2_fck", "mcbsp2_fck"),
403 DT_CLK(NULL, "mcbsp3_fck", "mcbsp3_fck"),
404 DT_CLK(NULL, "mcbsp4_fck", "mcbsp4_fck"),
Peter Ujfalusif757d1b2015-03-16 12:40:57 +0200405 DT_CLK(NULL, "mcbsp5_fck", "mcbsp5_fck"),
Tero Kristoaafd9002013-08-02 14:04:19 +0300406 DT_CLK("etb", "emu_src_ck", "emu_src_ck"),
407 DT_CLK(NULL, "emu_src_ck", "emu_src_ck"),
408 DT_CLK(NULL, "pclk_fck", "pclk_fck"),
409 DT_CLK(NULL, "pclkx2_fck", "pclkx2_fck"),
410 DT_CLK(NULL, "atclk_fck", "atclk_fck"),
411 DT_CLK(NULL, "traceclk_src_fck", "traceclk_src_fck"),
412 DT_CLK(NULL, "traceclk_fck", "traceclk_fck"),
413 DT_CLK(NULL, "secure_32k_fck", "secure_32k_fck"),
414 DT_CLK(NULL, "gpt12_fck", "gpt12_fck"),
415 DT_CLK(NULL, "wdt1_fck", "wdt1_fck"),
416 DT_CLK(NULL, "timer_32k_ck", "omap_32k_fck"),
417 DT_CLK(NULL, "timer_sys_ck", "sys_ck"),
418 DT_CLK(NULL, "cpufreq_ck", "dpll1_ck"),
419 { .node_name = NULL },
420};
421
422static struct ti_dt_clk omap34xx_omap36xx_clks[] = {
423 DT_CLK(NULL, "aes1_ick", "aes1_ick"),
424 DT_CLK("omap_rng", "ick", "rng_ick"),
425 DT_CLK("omap3-rom-rng", "ick", "rng_ick"),
426 DT_CLK(NULL, "sha11_ick", "sha11_ick"),
427 DT_CLK(NULL, "des1_ick", "des1_ick"),
428 DT_CLK(NULL, "cam_mclk", "cam_mclk"),
429 DT_CLK(NULL, "cam_ick", "cam_ick"),
430 DT_CLK(NULL, "csi2_96m_fck", "csi2_96m_fck"),
431 DT_CLK(NULL, "security_l3_ick", "security_l3_ick"),
432 DT_CLK(NULL, "pka_ick", "pka_ick"),
433 DT_CLK(NULL, "icr_ick", "icr_ick"),
434 DT_CLK("omap-aes", "ick", "aes2_ick"),
435 DT_CLK("omap-sham", "ick", "sha12_ick"),
436 DT_CLK(NULL, "des2_ick", "des2_ick"),
437 DT_CLK(NULL, "mspro_ick", "mspro_ick"),
438 DT_CLK(NULL, "mailboxes_ick", "mailboxes_ick"),
439 DT_CLK(NULL, "ssi_l4_ick", "ssi_l4_ick"),
440 DT_CLK(NULL, "sr1_fck", "sr1_fck"),
441 DT_CLK(NULL, "sr2_fck", "sr2_fck"),
442 DT_CLK(NULL, "sr_l4_ick", "sr_l4_ick"),
443 DT_CLK(NULL, "security_l4_ick2", "security_l4_ick2"),
444 DT_CLK(NULL, "wkup_l4_ick", "wkup_l4_ick"),
445 DT_CLK(NULL, "dpll2_fck", "dpll2_fck"),
446 DT_CLK(NULL, "iva2_ck", "iva2_ck"),
447 DT_CLK(NULL, "modem_fck", "modem_fck"),
448 DT_CLK(NULL, "sad2d_ick", "sad2d_ick"),
449 DT_CLK(NULL, "mad2d_ick", "mad2d_ick"),
450 DT_CLK(NULL, "mspro_fck", "mspro_fck"),
451 DT_CLK(NULL, "dpll2_ck", "dpll2_ck"),
452 DT_CLK(NULL, "dpll2_m2_ck", "dpll2_m2_ck"),
453 { .node_name = NULL },
454};
455
456static struct ti_dt_clk omap36xx_omap3430es2plus_clks[] = {
457 DT_CLK(NULL, "ssi_ssr_fck", "ssi_ssr_fck_3430es2"),
458 DT_CLK(NULL, "ssi_sst_fck", "ssi_sst_fck_3430es2"),
459 DT_CLK("musb-omap2430", "ick", "hsotgusb_ick_3430es2"),
460 DT_CLK(NULL, "hsotgusb_ick", "hsotgusb_ick_3430es2"),
461 DT_CLK(NULL, "ssi_ick", "ssi_ick_3430es2"),
462 DT_CLK(NULL, "usim_fck", "usim_fck"),
463 DT_CLK(NULL, "usim_ick", "usim_ick"),
464 { .node_name = NULL },
465};
466
467static struct ti_dt_clk omap3430es1_clks[] = {
468 DT_CLK(NULL, "gfx_l3_ck", "gfx_l3_ck"),
469 DT_CLK(NULL, "gfx_l3_fck", "gfx_l3_fck"),
470 DT_CLK(NULL, "gfx_l3_ick", "gfx_l3_ick"),
471 DT_CLK(NULL, "gfx_cg1_ck", "gfx_cg1_ck"),
472 DT_CLK(NULL, "gfx_cg2_ck", "gfx_cg2_ck"),
473 DT_CLK(NULL, "d2d_26m_fck", "d2d_26m_fck"),
474 DT_CLK(NULL, "fshostusb_fck", "fshostusb_fck"),
475 DT_CLK(NULL, "ssi_ssr_fck", "ssi_ssr_fck_3430es1"),
476 DT_CLK(NULL, "ssi_sst_fck", "ssi_sst_fck_3430es1"),
477 DT_CLK("musb-omap2430", "ick", "hsotgusb_ick_3430es1"),
478 DT_CLK(NULL, "hsotgusb_ick", "hsotgusb_ick_3430es1"),
479 DT_CLK(NULL, "fac_ick", "fac_ick"),
480 DT_CLK(NULL, "ssi_ick", "ssi_ick_3430es1"),
481 DT_CLK(NULL, "usb_l4_ick", "usb_l4_ick"),
482 DT_CLK(NULL, "dss1_alwon_fck", "dss1_alwon_fck_3430es1"),
483 DT_CLK("omapdss_dss", "ick", "dss_ick_3430es1"),
484 DT_CLK(NULL, "dss_ick", "dss_ick_3430es1"),
485 { .node_name = NULL },
486};
487
488static struct ti_dt_clk omap36xx_am35xx_omap3430es2plus_clks[] = {
489 DT_CLK(NULL, "virt_16_8m_ck", "virt_16_8m_ck"),
490 DT_CLK(NULL, "dpll5_ck", "dpll5_ck"),
491 DT_CLK(NULL, "dpll5_m2_ck", "dpll5_m2_ck"),
492 DT_CLK(NULL, "sgx_fck", "sgx_fck"),
493 DT_CLK(NULL, "sgx_ick", "sgx_ick"),
494 DT_CLK(NULL, "cpefuse_fck", "cpefuse_fck"),
495 DT_CLK(NULL, "ts_fck", "ts_fck"),
496 DT_CLK(NULL, "usbtll_fck", "usbtll_fck"),
497 DT_CLK(NULL, "usbtll_ick", "usbtll_ick"),
498 DT_CLK("omap_hsmmc.2", "ick", "mmchs3_ick"),
499 DT_CLK(NULL, "mmchs3_ick", "mmchs3_ick"),
500 DT_CLK(NULL, "mmchs3_fck", "mmchs3_fck"),
501 DT_CLK(NULL, "dss1_alwon_fck", "dss1_alwon_fck_3430es2"),
502 DT_CLK("omapdss_dss", "ick", "dss_ick_3430es2"),
503 DT_CLK(NULL, "dss_ick", "dss_ick_3430es2"),
504 DT_CLK(NULL, "usbhost_120m_fck", "usbhost_120m_fck"),
505 DT_CLK(NULL, "usbhost_48m_fck", "usbhost_48m_fck"),
506 DT_CLK(NULL, "usbhost_ick", "usbhost_ick"),
507 { .node_name = NULL },
508};
509
510static struct ti_dt_clk am35xx_clks[] = {
511 DT_CLK(NULL, "ipss_ick", "ipss_ick"),
512 DT_CLK(NULL, "rmii_ck", "rmii_ck"),
513 DT_CLK(NULL, "pclk_ck", "pclk_ck"),
514 DT_CLK(NULL, "emac_ick", "emac_ick"),
515 DT_CLK(NULL, "emac_fck", "emac_fck"),
516 DT_CLK("davinci_emac.0", NULL, "emac_ick"),
517 DT_CLK("davinci_mdio.0", NULL, "emac_fck"),
518 DT_CLK("vpfe-capture", "master", "vpfe_ick"),
519 DT_CLK("vpfe-capture", "slave", "vpfe_fck"),
520 DT_CLK(NULL, "hsotgusb_ick", "hsotgusb_ick_am35xx"),
521 DT_CLK(NULL, "hsotgusb_fck", "hsotgusb_fck_am35xx"),
522 DT_CLK(NULL, "hecc_ck", "hecc_ck"),
523 DT_CLK(NULL, "uart4_ick", "uart4_ick_am35xx"),
524 DT_CLK(NULL, "uart4_fck", "uart4_fck_am35xx"),
525 { .node_name = NULL },
526};
527
528static struct ti_dt_clk omap36xx_clks[] = {
529 DT_CLK(NULL, "omap_192m_alwon_fck", "omap_192m_alwon_fck"),
530 DT_CLK(NULL, "uart4_fck", "uart4_fck"),
531 { .node_name = NULL },
532};
533
534static const char *enable_init_clks[] = {
535 "sdrc_ick",
536 "gpmc_fck",
537 "omapctrl_ick",
538};
539
540enum {
541 OMAP3_SOC_AM35XX,
542 OMAP3_SOC_OMAP3430_ES1,
543 OMAP3_SOC_OMAP3430_ES2_PLUS,
544 OMAP3_SOC_OMAP3630,
Tero Kristoaafd9002013-08-02 14:04:19 +0300545};
546
Tero Kristo0565fb12015-03-03 13:27:48 +0200547/**
548 * omap3_clk_lock_dpll5 - locks DPLL5
549 *
550 * Locks DPLL5 to a pre-defined frequency. This is required for proper
551 * operation of USB.
552 */
553void __init omap3_clk_lock_dpll5(void)
554{
555 struct clk *dpll5_clk;
556 struct clk *dpll5_m2_clk;
557
558 dpll5_clk = clk_get(NULL, "dpll5_ck");
559 clk_set_rate(dpll5_clk, DPLL5_FREQ_FOR_USBHOST);
560 clk_prepare_enable(dpll5_clk);
561
562 /* Program dpll5_m2_clk divider for no division */
563 dpll5_m2_clk = clk_get(NULL, "dpll5_m2_ck");
564 clk_prepare_enable(dpll5_m2_clk);
565 clk_set_rate(dpll5_m2_clk, DPLL5_FREQ_FOR_USBHOST);
566
567 clk_disable_unprepare(dpll5_m2_clk);
568 clk_disable_unprepare(dpll5_clk);
569}
570
Tero Kristoaafd9002013-08-02 14:04:19 +0300571static int __init omap3xxx_dt_clk_init(int soc_type)
572{
573 if (soc_type == OMAP3_SOC_AM35XX || soc_type == OMAP3_SOC_OMAP3630 ||
574 soc_type == OMAP3_SOC_OMAP3430_ES1 ||
575 soc_type == OMAP3_SOC_OMAP3430_ES2_PLUS)
576 ti_dt_clocks_register(omap3xxx_clks);
577
578 if (soc_type == OMAP3_SOC_AM35XX)
579 ti_dt_clocks_register(am35xx_clks);
580
581 if (soc_type == OMAP3_SOC_OMAP3630 || soc_type == OMAP3_SOC_AM35XX ||
582 soc_type == OMAP3_SOC_OMAP3430_ES2_PLUS)
583 ti_dt_clocks_register(omap36xx_am35xx_omap3430es2plus_clks);
584
585 if (soc_type == OMAP3_SOC_OMAP3430_ES1)
586 ti_dt_clocks_register(omap3430es1_clks);
587
588 if (soc_type == OMAP3_SOC_OMAP3430_ES2_PLUS ||
589 soc_type == OMAP3_SOC_OMAP3630)
590 ti_dt_clocks_register(omap36xx_omap3430es2plus_clks);
591
592 if (soc_type == OMAP3_SOC_OMAP3430_ES1 ||
593 soc_type == OMAP3_SOC_OMAP3430_ES2_PLUS ||
594 soc_type == OMAP3_SOC_OMAP3630)
595 ti_dt_clocks_register(omap34xx_omap36xx_clks);
596
597 if (soc_type == OMAP3_SOC_OMAP3630)
598 ti_dt_clocks_register(omap36xx_clks);
599
600 omap2_clk_disable_autoidle_all();
601
602 omap2_clk_enable_init_clocks(enable_init_clks,
603 ARRAY_SIZE(enable_init_clks));
604
605 pr_info("Clocking rate (Crystal/Core/MPU): %ld.%01ld/%ld/%ld MHz\n",
606 (clk_get_rate(clk_get_sys(NULL, "osc_sys_ck")) / 1000000),
607 (clk_get_rate(clk_get_sys(NULL, "osc_sys_ck")) / 100000) % 10,
608 (clk_get_rate(clk_get_sys(NULL, "core_ck")) / 1000000),
609 (clk_get_rate(clk_get_sys(NULL, "arm_fck")) / 1000000));
610
Tony Lindgren1a342752015-01-13 14:51:28 -0800611 if (soc_type != OMAP3_SOC_OMAP3430_ES1)
Tero Kristoaafd9002013-08-02 14:04:19 +0300612 omap3_clk_lock_dpll5();
613
614 return 0;
615}
616
617int __init omap3430_dt_clk_init(void)
618{
619 return omap3xxx_dt_clk_init(OMAP3_SOC_OMAP3430_ES2_PLUS);
620}
621
622int __init omap3630_dt_clk_init(void)
623{
624 return omap3xxx_dt_clk_init(OMAP3_SOC_OMAP3630);
625}
626
627int __init am35xx_dt_clk_init(void)
628{
629 return omap3xxx_dt_clk_init(OMAP3_SOC_AM35XX);
630}