blob: 100689bfbba236892ad03f591478a2731e372bf9 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/err.h>
17#include <linux/ctype.h>
18#include <linux/bitops.h>
19#include <linux/io.h>
20#include <linux/spinlock.h>
21#include <linux/delay.h>
22#include <linux/clk.h>
23#include <linux/clkdev.h>
24#include <linux/string.h>
25
26#include <mach/msm_iomap.h>
27#include <mach/clk.h>
28
29#include "clock.h"
30#include "clock-local.h"
31#include "clock-pcom.h"
32#include "clock-voter.h"
33#include "proc_comm.h"
34
35#define REG_BASE(off) (MSM_CLK_CTL_BASE + (off))
36#define REG(off) (MSM_CLK_CTL_SH2_BASE + (off))
37
38/* Shadow-region 2 (SH2) registers. */
39#define QUP_I2C_NS_REG REG(0x04F0)
40#define CAM_NS_REG REG(0x0374)
41#define CAM_VFE_NS_REG REG(0x0044)
42#define CLK_HALT_STATEA_REG REG(0x0108)
43#define CLK_HALT_STATEB_REG REG(0x010C)
44#define CLK_HALT_STATEC_REG REG(0x02D4)
45#define CSI_NS_REG REG(0x0174)
46#define EMDH_NS_REG REG(0x0050)
47#define GLBL_CLK_ENA_2_SC_REG REG(0x03C0)
48#define GLBL_CLK_ENA_SC_REG REG(0x03BC)
49#define GLBL_CLK_STATE_2_REG REG(0x037C)
50#define GLBL_CLK_STATE_REG REG(0x0004)
51#define GRP_2D_NS_REG REG(0x0034)
52#define GRP_NS_REG REG(0x0084)
53#define HDMI_NS_REG REG(0x0484)
54#define I2C_2_NS_REG REG(0x02D8)
55#define I2C_NS_REG REG(0x0068)
56#define JPEG_NS_REG REG(0x0164)
57#define LPA_CORE_CLK_MA0_REG REG(0x04F4)
58#define LPA_CORE_CLK_MA2_REG REG(0x04FC)
59#define LPA_NS_REG REG(0x02E8)
60#define MDC_NS_REG REG(0x007C)
61#define MDP_LCDC_NS_REG REG(0x0390)
62#define MDP_NS_REG REG(0x014C)
63#define MDP_VSYNC_REG REG(0x0460)
64#define MFC_NS_REG REG(0x0154)
65#define MI2S_CODEC_RX_DIV_REG REG(0x02EC)
66#define MI2S_CODEC_TX_DIV_REG REG(0x02F0)
67#define MI2S_DIV_REG REG(0x02E4)
68#define MI2S_NS_REG REG(0x02E0)
69#define MI2S_RX_NS_REG REG(0x0070)
70#define MI2S_TX_NS_REG REG(0x0078)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070071#define PLL_ENA_REG REG(0x0264)
72#define PMDH_NS_REG REG(0x008C)
73#define SDAC_NS_REG REG(0x009C)
74#define SDCn_NS_REG(n) REG(0x00A4+(0x8*((n)-1)))
75#define SPI_NS_REG REG(0x02C8)
76#define TSIF_NS_REG REG(0x00C4)
77#define TV_NS_REG REG(0x00CC)
78#define UART1DM_NS_REG REG(0x00D4)
79#define UART2DM_NS_REG REG(0x00DC)
80#define UART2_NS_REG REG(0x0464)
81#define UART_NS_REG REG(0x00E0)
82#define USBH2_NS_REG REG(0x046C)
83#define USBH3_NS_REG REG(0x0470)
84#define USBH_MD_REG REG(0x02BC)
85#define USBH_NS_REG REG(0x02C0)
86#define VPE_NS_REG REG(0x015C)
87
88/* Registers in the base (non-shadow) region. */
89#define CLK_TEST_BASE_REG REG_BASE(0x011C)
90#define CLK_TEST_2_BASE_REG REG_BASE(0x0384)
91#define MISC_CLK_CTL_BASE_REG REG_BASE(0x0110)
92#define PRPH_WEB_NS_BASE_REG REG_BASE(0x0080)
93#define PLL0_STATUS_BASE_REG REG_BASE(0x0318)
94#define PLL1_STATUS_BASE_REG REG_BASE(0x0334)
95#define PLL2_STATUS_BASE_REG REG_BASE(0x0350)
96#define PLL3_STATUS_BASE_REG REG_BASE(0x036C)
97#define PLL4_STATUS_BASE_REG REG_BASE(0x0254)
98#define PLL5_STATUS_BASE_REG REG_BASE(0x0258)
99#define PLL6_STATUS_BASE_REG REG_BASE(0x04EC)
100#define RINGOSC_CNT_BASE_REG REG_BASE(0x00FC)
101#define SH2_OWN_APPS1_BASE_REG REG_BASE(0x040C)
102#define SH2_OWN_APPS2_BASE_REG REG_BASE(0x0414)
103#define SH2_OWN_APPS3_BASE_REG REG_BASE(0x0444)
104#define SH2_OWN_GLBL_BASE_REG REG_BASE(0x0404)
105#define SH2_OWN_ROW1_BASE_REG REG_BASE(0x041C)
106#define SH2_OWN_ROW2_BASE_REG REG_BASE(0x0424)
107#define TCXO_CNT_BASE_REG REG_BASE(0x00F8)
108#define TCXO_CNT_DONE_BASE_REG REG_BASE(0x00F8)
109
110
111/* MUX source input identifiers. */
112#define SRC_SEL_pll0 4 /* Modem PLL */
113#define SRC_SEL_pll1 1 /* Global PLL */
114#define SRC_SEL_pll3 3 /* Multimedia/Peripheral PLL or Backup PLL1 */
115#define SRC_SEL_pll4 2 /* Display PLL */
116#define SRC_SEL_SDAC_lpxo 5 /* Low-power XO for SDAC */
117#define SRC_SEL_lpxo 6 /* Low-power XO */
118#define SRC_SEL_tcxo 0 /* Used for rates from TCXO */
119#define SRC_SEL_axi 0 /* Used for rates that sync to AXI */
120#define SRC_SEL_gnd 7 /* No clock */
121
122/* Clock declaration macros. */
123#define MN_MODE_DUAL_EDGE 0x2
124#define MD8(m, n) (BVAL(15, 8, m) | BVAL(7, 0, ~(n)))
125#define N8(msb, lsb, m, n) (BVAL(msb, lsb, ~(n-m)) | BVAL(6, 5, \
126 (MN_MODE_DUAL_EDGE * !!(n))))
127#define MD16(m, n) (BVAL(31, 16, m) | BVAL(15, 0, ~(n)))
128#define N16(m, n) (BVAL(31, 16, ~(n-m)) | BVAL(6, 5, \
129 (MN_MODE_DUAL_EDGE * !!(n))))
130#define SPDIV(s, d) (BVAL(4, 3, d-1) | BVAL(2, 0, s))
131#define SDIV(s, d) (BVAL(6, 3, d-1) | BVAL(2, 0, s))
132#define F_MASK_BASIC (BM(6, 3)|BM(2, 0))
133#define F_MASK_MND16 (BM(31, 16)|BM(6, 5)|BM(4, 3)|BM(2, 0))
134#define F_MASK_MND8(m, l) (BM(m, l)|BM(6, 5)|BM(4, 3)|BM(2, 0))
135
136/*
137 * Clock frequency definitions and macros
138 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700139#define F_BASIC(f, s, div) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700140 { \
141 .freq_hz = f, \
142 .src_clk = &s##_clk.c, \
143 .ns_val = SDIV(SRC_SEL_##s, div), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700144 }
145
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700146#define F_MND16(f, s, div, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700147 { \
148 .freq_hz = f, \
149 .src_clk = &s##_clk.c, \
150 .md_val = MD16(m, n), \
151 .ns_val = N16(m, n) | SPDIV(SRC_SEL_##s, div), \
152 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153 }
154
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700155#define F_MND8(f, nmsb, nlsb, s, div, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700156 { \
157 .freq_hz = f, \
158 .src_clk = &s##_clk.c, \
159 .md_val = MD8(m, n), \
160 .ns_val = N8(nmsb, nlsb, m, n) | SPDIV(SRC_SEL_##s, div), \
161 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700162 }
163
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700164static struct clk_ops clk_ops_rcg_7x30;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700165
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700166enum vdd_dig_levels {
167 VDD_DIG_NONE,
168 VDD_DIG_LOW,
169 VDD_DIG_NOMINAL,
170 VDD_DIG_HIGH
171};
172
173static int set_vdd_dig(struct clk_vdd_class *vdd_class, int level)
174{
175 int rc, target_mv;
176
177 static const int mv[] = {
178 [VDD_DIG_NONE] = 1000,
179 [VDD_DIG_LOW] = 1000,
180 [VDD_DIG_NOMINAL] = 1100,
181 [VDD_DIG_HIGH] = 1200
182 };
183
184 target_mv = mv[level];
185 rc = msm_proc_comm(PCOM_CLKCTL_RPC_MIN_MSMC1, &target_mv, NULL);
186 if (rc)
187 return rc;
188 if (target_mv)
189 rc = -EINVAL;
190
191 return rc;
192}
193
194static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig);
195
196#define VDD_DIG_FMAX_MAP1(l1, f1) \
197 .vdd_class = &vdd_dig, \
198 .fmax[VDD_DIG_##l1] = (f1)
199#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
200 .vdd_class = &vdd_dig, \
201 .fmax[VDD_DIG_##l1] = (f1), \
202 .fmax[VDD_DIG_##l2] = (f2)
203
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700204#define PCOM_XO_DISABLE 0
205#define PCOM_XO_ENABLE 1
206#define PCOM_XO_TCXO 0
207#define PCOM_XO_LPXO 1
208
209static bool pcom_is_local(struct clk *clk)
210{
211 return false;
212}
213
214static int pcom_xo_enable(unsigned pcom_id, unsigned enable)
215{
216 /* TODO: Check return code in pcom_id */
217 return msm_proc_comm(PCOM_CLKCTL_RPC_SRC_REQUEST, &pcom_id, &enable);
218}
219
220static int tcxo_clk_enable(struct clk *clk)
221{
222 return pcom_xo_enable(PCOM_XO_TCXO, PCOM_XO_ENABLE);
223}
224
225static void tcxo_clk_disable(struct clk *clk)
226{
227 pcom_xo_enable(PCOM_XO_TCXO, PCOM_XO_DISABLE);
228}
229
230static struct clk_ops clk_ops_tcxo = {
231 .enable = tcxo_clk_enable,
232 .disable = tcxo_clk_disable,
233 .get_rate = fixed_clk_get_rate,
234 .is_local = pcom_is_local,
235};
236
237static struct fixed_clk tcxo_clk = {
238 .rate = 19200000,
239 .c = {
240 .dbg_name = "tcxo_clk",
241 .ops = &clk_ops_tcxo,
242 CLK_INIT(tcxo_clk.c),
243 },
244};
245
246static int lpxo_clk_enable(struct clk *clk)
247{
248 return pcom_xo_enable(PCOM_XO_LPXO, PCOM_XO_ENABLE);
249}
250
251static void lpxo_clk_disable(struct clk *clk)
252{
253 pcom_xo_enable(PCOM_XO_LPXO, PCOM_XO_DISABLE);
254}
255
256static struct clk_ops clk_ops_lpxo = {
257 .enable = lpxo_clk_enable,
258 .disable = lpxo_clk_disable,
259 .get_rate = fixed_clk_get_rate,
260 .is_local = pcom_is_local,
261};
262
263static struct fixed_clk lpxo_clk = {
264 .rate = 24576000,
265 .c = {
266 .dbg_name = "lpxo_clk",
267 .ops = &clk_ops_lpxo,
268 CLK_INIT(lpxo_clk.c),
269 },
270};
271
272static struct pll_vote_clk pll1_clk = {
273 .rate = 768000000,
274 .en_reg = PLL_ENA_REG,
275 .en_mask = BIT(1),
276 .status_reg = PLL1_STATUS_BASE_REG,
277 .parent = &tcxo_clk.c,
278 .c = {
279 .dbg_name = "pll1_clk",
280 .ops = &clk_ops_pll_vote,
281 CLK_INIT(pll1_clk.c),
282 },
283};
284
285static struct pll_vote_clk pll2_clk = {
286 .rate = 806400000, /* TODO: Support scaling */
287 .en_reg = PLL_ENA_REG,
288 .en_mask = BIT(2),
289 .status_reg = PLL2_STATUS_BASE_REG,
290 .parent = &tcxo_clk.c,
291 .c = {
292 .dbg_name = "pll2_clk",
293 .ops = &clk_ops_pll_vote,
294 CLK_INIT(pll2_clk.c),
295 },
296};
297
298static struct pll_vote_clk pll3_clk = {
299 .rate = 737280000,
300 .en_reg = PLL_ENA_REG,
301 .en_mask = BIT(3),
302 .status_reg = PLL3_STATUS_BASE_REG,
303 .parent = &lpxo_clk.c,
304 .c = {
305 .dbg_name = "pll3_clk",
306 .ops = &clk_ops_pll_vote,
307 CLK_INIT(pll3_clk.c),
308 },
309};
310
311static struct pll_vote_clk pll4_clk = {
312 .rate = 891000000,
313 .en_reg = PLL_ENA_REG,
314 .en_mask = BIT(4),
315 .status_reg = PLL4_STATUS_BASE_REG,
316 .parent = &lpxo_clk.c,
317 .c = {
318 .dbg_name = "pll4_clk",
319 .ops = &clk_ops_pll_vote,
320 CLK_INIT(pll4_clk.c),
321 },
322};
323
324static struct clk_ops clk_ops_branch;
325
326static struct clk_freq_tbl clk_tbl_axi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700327 F_RAW(1, &lpxo_clk.c, 0, 0, 0, 0, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700328 F_END,
329};
330
331/* For global clocks to be on we must have GLBL_ROOT_ENA set */
332static struct rcg_clk glbl_root_clk = {
333 .b = {
334 .ctl_reg = GLBL_CLK_ENA_SC_REG,
335 .en_mask = BIT(29),
336 .halt_check = NOCHECK,
337 },
338 .freq_tbl = clk_tbl_axi,
339 .set_rate = set_rate_nop,
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700340 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700341 .set_rate = set_rate_nop,
342 .c = {
343 .dbg_name = "glbl_root_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700344 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700345 VDD_DIG_FMAX_MAP1(NOMINAL, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700346 CLK_INIT(glbl_root_clk.c),
347 },
348};
349
350/* AXI bridge clocks. */
351static struct branch_clk axi_li_apps_clk = {
352 .b = {
353 .ctl_reg = GLBL_CLK_ENA_SC_REG,
354 .en_mask = BIT(2),
355 .halt_reg = GLBL_CLK_STATE_REG,
356 .halt_check = HALT_VOTED,
357 .halt_bit = 2,
358 },
359 .parent = &glbl_root_clk.c,
360 .c = {
361 .dbg_name = "axi_li_apps_clk",
362 .ops = &clk_ops_branch,
363 CLK_INIT(axi_li_apps_clk.c),
364 },
365};
366
367static struct branch_clk axi_li_adsp_a_clk = {
368 .b = {
369 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
370 .en_mask = BIT(14),
371 .halt_reg = GLBL_CLK_STATE_2_REG,
372 .halt_check = HALT_VOTED,
373 .halt_bit = 14,
374 },
375 .parent = &axi_li_apps_clk.c,
376 .c = {
377 .dbg_name = "axi_li_adsp_a_clk",
378 .ops = &clk_ops_branch,
379 CLK_INIT(axi_li_adsp_a_clk.c),
380 },
381};
382
383static struct branch_clk axi_li_jpeg_clk = {
384 .b = {
385 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
386 .en_mask = BIT(19),
387 .halt_reg = GLBL_CLK_STATE_2_REG,
388 .halt_check = HALT_VOTED,
389 .halt_bit = 19,
390 },
391 .parent = &axi_li_apps_clk.c,
392 .c = {
393 .dbg_name = "axi_li_jpeg_clk",
394 .ops = &clk_ops_branch,
395 CLK_INIT(axi_li_jpeg_clk.c),
396 },
397};
398
399static struct branch_clk axi_li_vfe_clk = {
400 .b = {
401 .ctl_reg = GLBL_CLK_ENA_SC_REG,
402 .en_mask = BIT(23),
403 .halt_reg = GLBL_CLK_STATE_REG,
404 .halt_check = HALT_VOTED,
405 .halt_bit = 23,
406 },
407 .parent = &axi_li_apps_clk.c,
408 .c = {
409 .dbg_name = "axi_li_vfe_clk",
410 .ops = &clk_ops_branch,
411 CLK_INIT(axi_li_vfe_clk.c),
412 },
413};
414
415static struct branch_clk axi_mdp_clk = {
416 .b = {
417 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
418 .en_mask = BIT(29),
419 .halt_reg = GLBL_CLK_STATE_2_REG,
420 .halt_check = HALT_VOTED,
421 .halt_bit = 29,
422 },
423 .parent = &axi_li_apps_clk.c,
424 .c = {
425 .dbg_name = "axi_mdp_clk",
426 .ops = &clk_ops_branch,
427 CLK_INIT(axi_mdp_clk.c),
428 },
429};
430
431static struct branch_clk axi_li_vg_clk = {
432 .b = {
433 .ctl_reg = GLBL_CLK_ENA_SC_REG,
434 .en_mask = BIT(3),
435 .halt_reg = GLBL_CLK_STATE_REG,
436 .halt_check = HALT_VOTED,
437 .halt_bit = 3,
438 },
439 .parent = &glbl_root_clk.c,
440 .c = {
441 .dbg_name = "axi_li_vg_clk",
442 .ops = &clk_ops_branch,
443 CLK_INIT(axi_li_vg_clk.c),
444 },
445};
446
447static struct branch_clk axi_grp_2d_clk = {
448 .b = {
449 .ctl_reg = GLBL_CLK_ENA_SC_REG,
450 .en_mask = BIT(21),
451 .halt_reg = GLBL_CLK_STATE_REG,
452 .halt_check = HALT_VOTED,
453 .halt_bit = 21,
454 },
455 .parent = &axi_li_vg_clk.c,
456 .c = {
457 .dbg_name = "axi_grp_2d_clk",
458 .ops = &clk_ops_branch,
459 CLK_INIT(axi_grp_2d_clk.c),
460 },
461};
462
463static struct branch_clk axi_li_grp_clk = {
464 .b = {
465 .ctl_reg = GLBL_CLK_ENA_SC_REG,
466 .en_mask = BIT(22),
467 .halt_reg = GLBL_CLK_STATE_REG,
468 .halt_check = HALT_VOTED,
469 .halt_bit = 22,
470 },
471 .parent = &axi_li_vg_clk.c,
472 .c = {
473 .dbg_name = "axi_li_grp_clk",
474 .ops = &clk_ops_branch,
475 CLK_INIT(axi_li_grp_clk.c),
476 },
477};
478
479static struct branch_clk axi_mfc_clk = {
480 .b = {
481 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
482 .en_mask = BIT(20),
483 .halt_reg = GLBL_CLK_STATE_2_REG,
484 .halt_check = HALT_VOTED,
485 .halt_bit = 20,
486 },
487 .parent = &axi_li_vg_clk.c,
488 .c = {
489 .dbg_name = "axi_mfc_clk",
490 .ops = &clk_ops_branch,
491 CLK_INIT(axi_mfc_clk.c),
492 },
493};
494
495static struct branch_clk axi_rotator_clk = {
496 .b = {
497 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
498 .en_mask = BIT(22),
499 .halt_reg = GLBL_CLK_STATE_2_REG,
500 .halt_check = HALT_VOTED,
501 .halt_bit = 22,
502 .reset_mask = P_AXI_ROTATOR_CLK,
503 },
504 .parent = &axi_li_vg_clk.c,
505 .c = {
506 .dbg_name = "axi_rotator_clk",
507 .ops = &clk_ops_branch,
508 CLK_INIT(axi_rotator_clk.c),
509 },
510};
511
512static struct branch_clk axi_vpe_clk = {
513 .b = {
514 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
515 .en_mask = BIT(21),
516 .halt_reg = GLBL_CLK_STATE_2_REG,
517 .halt_check = HALT_VOTED,
518 .halt_bit = 21,
519 },
520 .parent = &axi_li_vg_clk.c,
521 .c = {
522 .dbg_name = "axi_vpe_clk",
523 .ops = &clk_ops_branch,
524 CLK_INIT(axi_vpe_clk.c),
525 },
526};
527
528/* Peripheral bus clocks. */
529static struct branch_clk adm_clk = {
530 .b = {
531 .ctl_reg = GLBL_CLK_ENA_SC_REG,
532 .en_mask = BIT(5),
533 .halt_reg = GLBL_CLK_STATE_REG,
534 .halt_check = HALT_VOTED,
535 .halt_bit = 5,
536 .reset_mask = P_ADM_CLK,
537 },
538 .parent = &axi_li_apps_clk.c,
539 .c = {
540 .dbg_name = "adm_clk",
541 .ops = &clk_ops_branch,
542 CLK_INIT(adm_clk.c),
543 },
544};
545
546static struct branch_clk adm_p_clk = {
547 .b = {
548 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
549 .en_mask = BIT(15),
550 .halt_reg = GLBL_CLK_STATE_2_REG,
551 .halt_check = HALT_VOTED,
552 .halt_bit = 15,
553 },
554 .parent = &glbl_root_clk.c,
555 .c = {
556 .dbg_name = "adm_p_clk",
557 .ops = &clk_ops_branch,
558 CLK_INIT(adm_p_clk.c),
559 },
560};
561
562static struct branch_clk ce_clk = {
563 .b = {
564 .ctl_reg = GLBL_CLK_ENA_SC_REG,
565 .en_mask = BIT(6),
566 .halt_reg = GLBL_CLK_STATE_REG,
567 .halt_check = HALT_VOTED,
568 .halt_bit = 6,
569 .reset_mask = P_CE_CLK,
570 },
571 .parent = &glbl_root_clk.c,
572 .c = {
573 .dbg_name = "ce_clk",
574 .ops = &clk_ops_branch,
575 CLK_INIT(ce_clk.c),
576 },
577};
578
579static struct branch_clk camif_pad_p_clk = {
580 .b = {
581 .ctl_reg = GLBL_CLK_ENA_SC_REG,
582 .en_mask = BIT(9),
583 .halt_reg = GLBL_CLK_STATE_REG,
584 .halt_check = HALT_VOTED,
585 .halt_bit = 9,
586 .reset_mask = P_CAMIF_PAD_P_CLK,
587 },
588 .parent = &glbl_root_clk.c,
589 .c = {
590 .dbg_name = "camif_pad_p_clk",
591 .ops = &clk_ops_branch,
592 CLK_INIT(camif_pad_p_clk.c),
593 },
594};
595
596static struct branch_clk csi0_p_clk = {
597 .b = {
598 .ctl_reg = GLBL_CLK_ENA_SC_REG,
599 .en_mask = BIT(30),
600 .halt_reg = GLBL_CLK_STATE_REG,
601 .halt_check = HALT_VOTED,
602 .halt_bit = 30,
603 .reset_mask = P_CSI0_P_CLK,
604 },
605 .parent = &glbl_root_clk.c,
606 .c = {
607 .dbg_name = "csi0_p_clk",
608 .ops = &clk_ops_branch,
609 CLK_INIT(csi0_p_clk.c),
610 },
611};
612
613static struct branch_clk emdh_p_clk = {
614 .b = {
615 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
616 .en_mask = BIT(3),
617 .halt_reg = GLBL_CLK_STATE_2_REG,
618 .halt_check = HALT_VOTED,
619 .halt_bit = 3,
620 .reset_mask = P_EMDH_P_CLK,
621 },
622 .parent = &glbl_root_clk.c,
623 .c = {
624 .dbg_name = "emdh_p_clk",
625 .ops = &clk_ops_branch,
626 CLK_INIT(emdh_p_clk.c),
627 },
628};
629
630static struct branch_clk grp_2d_p_clk = {
631 .b = {
632 .ctl_reg = GLBL_CLK_ENA_SC_REG,
633 .en_mask = BIT(24),
634 .halt_reg = GLBL_CLK_STATE_REG,
635 .halt_check = HALT_VOTED,
636 .halt_bit = 24,
637 .reset_mask = P_GRP_2D_P_CLK,
638 },
639 .parent = &glbl_root_clk.c,
640 .c = {
641 .dbg_name = "grp_2d_p_clk",
642 .ops = &clk_ops_branch,
643 CLK_INIT(grp_2d_p_clk.c),
644 },
645};
646
647static struct branch_clk grp_3d_p_clk = {
648 .b = {
649 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
650 .en_mask = BIT(17),
651 .halt_reg = GLBL_CLK_STATE_2_REG,
652 .halt_check = HALT_VOTED,
653 .halt_bit = 17,
654 .reset_mask = P_GRP_3D_P_CLK,
655 },
656 .parent = &glbl_root_clk.c,
657 .c = {
658 .dbg_name = "grp_3d_p_clk",
659 .ops = &clk_ops_branch,
660 CLK_INIT(grp_3d_p_clk.c),
661 },
662};
663
664static struct branch_clk jpeg_p_clk = {
665 .b = {
666 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
667 .en_mask = BIT(24),
668 .halt_reg = GLBL_CLK_STATE_2_REG,
669 .halt_check = HALT_VOTED,
670 .halt_bit = 24,
671 .reset_mask = P_JPEG_P_CLK,
672 },
673 .parent = &glbl_root_clk.c,
674 .c = {
675 .dbg_name = "jpeg_p_clk",
676 .ops = &clk_ops_branch,
677 CLK_INIT(jpeg_p_clk.c),
678 },
679};
680
681static struct branch_clk lpa_p_clk = {
682 .b = {
683 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
684 .en_mask = BIT(7),
685 .halt_reg = GLBL_CLK_STATE_2_REG,
686 .halt_check = HALT_VOTED,
687 .halt_bit = 7,
688 .reset_mask = P_LPA_P_CLK,
689 },
690 .parent = &glbl_root_clk.c,
691 .c = {
692 .dbg_name = "lpa_p_clk",
693 .ops = &clk_ops_branch,
694 CLK_INIT(lpa_p_clk.c),
695 },
696};
697
698static struct branch_clk mdp_p_clk = {
699 .b = {
700 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
701 .en_mask = BIT(6),
702 .halt_reg = GLBL_CLK_STATE_2_REG,
703 .halt_check = HALT_VOTED,
704 .halt_bit = 6,
705 .reset_mask = P_MDP_P_CLK,
706 },
707 .parent = &glbl_root_clk.c,
708 .c = {
709 .dbg_name = "mdp_p_clk",
710 .ops = &clk_ops_branch,
711 CLK_INIT(mdp_p_clk.c),
712 },
713};
714
715static struct branch_clk mfc_p_clk = {
716 .b = {
717 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
718 .en_mask = BIT(26),
719 .halt_reg = GLBL_CLK_STATE_2_REG,
720 .halt_check = HALT_VOTED,
721 .halt_bit = 26,
722 .reset_mask = P_MFC_P_CLK,
723 },
724 .parent = &glbl_root_clk.c,
725 .c = {
726 .dbg_name = "mfc_p_clk",
727 .ops = &clk_ops_branch,
728 CLK_INIT(mfc_p_clk.c),
729 },
730};
731
732static struct branch_clk pmdh_p_clk = {
733 .b = {
734 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
735 .en_mask = BIT(4),
736 .halt_reg = GLBL_CLK_STATE_2_REG,
737 .halt_check = HALT_VOTED,
738 .halt_bit = 4,
739 .reset_mask = P_PMDH_P_CLK,
740 },
741 .parent = &glbl_root_clk.c,
742 .c = {
743 .dbg_name = "pmdh_p_clk",
744 .ops = &clk_ops_branch,
745 CLK_INIT(pmdh_p_clk.c),
746 },
747};
748
749static struct branch_clk rotator_imem_clk = {
750 .b = {
751 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
752 .en_mask = BIT(23),
753 .halt_reg = GLBL_CLK_STATE_2_REG,
754 .halt_check = HALT_VOTED,
755 .halt_bit = 23,
756 .reset_mask = P_ROTATOR_IMEM_CLK,
757 },
758 .parent = &glbl_root_clk.c,
759 .c = {
760 .dbg_name = "rotator_imem_clk",
761 .ops = &clk_ops_branch,
762 CLK_INIT(rotator_imem_clk.c),
763 },
764};
765
766static struct branch_clk rotator_p_clk = {
767 .b = {
768 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
769 .en_mask = BIT(25),
770 .halt_reg = GLBL_CLK_STATE_2_REG,
771 .halt_check = HALT_VOTED,
772 .halt_bit = 25,
773 .reset_mask = P_ROTATOR_P_CLK,
774 },
775 .parent = &glbl_root_clk.c,
776 .c = {
777 .dbg_name = "rotator_p_clk",
778 .ops = &clk_ops_branch,
779 CLK_INIT(rotator_p_clk.c),
780 },
781};
782
783static struct branch_clk sdc1_p_clk = {
784 .b = {
785 .ctl_reg = GLBL_CLK_ENA_SC_REG,
786 .en_mask = BIT(7),
787 .halt_reg = GLBL_CLK_STATE_REG,
788 .halt_check = HALT_VOTED,
789 .halt_bit = 7,
790 .reset_mask = P_SDC1_P_CLK,
791 },
792 .parent = &glbl_root_clk.c,
793 .c = {
794 .dbg_name = "sdc1_p_clk",
795 .ops = &clk_ops_branch,
796 CLK_INIT(sdc1_p_clk.c),
797 },
798};
799
800static struct branch_clk sdc2_p_clk = {
801 .b = {
802 .ctl_reg = GLBL_CLK_ENA_SC_REG,
803 .en_mask = BIT(8),
804 .halt_reg = GLBL_CLK_STATE_REG,
805 .halt_check = HALT_VOTED,
806 .halt_bit = 8,
807 .reset_mask = P_SDC2_P_CLK,
808 },
809 .parent = &glbl_root_clk.c,
810 .c = {
811 .dbg_name = "sdc2_p_clk",
812 .ops = &clk_ops_branch,
813 CLK_INIT(sdc2_p_clk.c),
814 },
815};
816
817static struct branch_clk sdc3_p_clk = {
818 .b = {
819 .ctl_reg = GLBL_CLK_ENA_SC_REG,
820 .en_mask = BIT(27),
821 .halt_reg = GLBL_CLK_STATE_REG,
822 .halt_check = HALT_VOTED,
823 .halt_bit = 27,
824 .reset_mask = P_SDC3_P_CLK,
825 },
826 .parent = &glbl_root_clk.c,
827 .c = {
828 .dbg_name = "sdc3_p_clk",
829 .ops = &clk_ops_branch,
830 CLK_INIT(sdc3_p_clk.c),
831 },
832};
833
834static struct branch_clk sdc4_p_clk = {
835 .b = {
836 .ctl_reg = GLBL_CLK_ENA_SC_REG,
837 .en_mask = BIT(28),
838 .halt_reg = GLBL_CLK_STATE_REG,
839 .halt_check = HALT_VOTED,
840 .halt_bit = 28,
841 .reset_mask = P_SDC4_P_CLK,
842 },
843 .parent = &glbl_root_clk.c,
844 .c = {
845 .dbg_name = "sdc4_p_clk",
846 .ops = &clk_ops_branch,
847 CLK_INIT(sdc4_p_clk.c),
848 },
849};
850
851static struct branch_clk spi_p_clk = {
852 .b = {
853 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
854 .en_mask = BIT(10),
855 .halt_reg = GLBL_CLK_STATE_2_REG,
856 .halt_check = HALT_VOTED,
857 .halt_bit = 10,
858 .reset_mask = P_SPI_P_CLK,
859 },
860 .parent = &glbl_root_clk.c,
861 .c = {
862 .dbg_name = "spi_p_clk",
863 .ops = &clk_ops_branch,
864 CLK_INIT(spi_p_clk.c),
865 },
866};
867
868static struct branch_clk tsif_p_clk = {
869 .b = {
870 .ctl_reg = GLBL_CLK_ENA_SC_REG,
871 .en_mask = BIT(18),
872 .halt_reg = GLBL_CLK_STATE_REG,
873 .halt_check = HALT_VOTED,
874 .halt_bit = 18,
875 .reset_mask = P_TSIF_P_CLK,
876 },
877 .parent = &glbl_root_clk.c,
878 .c = {
879 .dbg_name = "tsif_p_clk",
880 .ops = &clk_ops_branch,
881 CLK_INIT(tsif_p_clk.c),
882 },
883};
884
885static struct branch_clk uart1dm_p_clk = {
886 .b = {
887 .ctl_reg = GLBL_CLK_ENA_SC_REG,
888 .en_mask = BIT(17),
889 .halt_reg = GLBL_CLK_STATE_REG,
890 .halt_check = HALT_VOTED,
891 .halt_bit = 17,
892 },
893 .parent = &glbl_root_clk.c,
894 .c = {
895 .dbg_name = "uart1dm_p_clk",
896 .ops = &clk_ops_branch,
897 CLK_INIT(uart1dm_p_clk.c),
898 },
899};
900
901static struct branch_clk uart2dm_p_clk = {
902 .b = {
903 .ctl_reg = GLBL_CLK_ENA_SC_REG,
904 .en_mask = BIT(26),
905 .halt_reg = GLBL_CLK_STATE_REG,
906 .halt_check = HALT_VOTED,
907 .halt_bit = 26,
908 },
909 .parent = &glbl_root_clk.c,
910 .c = {
911 .dbg_name = "uart2dm_p_clk",
912 .ops = &clk_ops_branch,
913 CLK_INIT(uart2dm_p_clk.c),
914 },
915};
916
917static struct branch_clk usb_hs2_p_clk = {
918 .b = {
919 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
920 .en_mask = BIT(8),
921 .halt_reg = GLBL_CLK_STATE_2_REG,
922 .halt_check = HALT_VOTED,
923 .halt_bit = 8,
924 .reset_mask = P_USB_HS2_P_CLK,
925 },
926 .parent = &glbl_root_clk.c,
927 .c = {
928 .dbg_name = "usb_hs2_p_clk",
929 .ops = &clk_ops_branch,
930 CLK_INIT(usb_hs2_p_clk.c),
931 },
932};
933
934static struct branch_clk usb_hs3_p_clk = {
935 .b = {
936 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
937 .en_mask = BIT(9),
938 .halt_reg = GLBL_CLK_STATE_2_REG,
939 .halt_check = HALT_VOTED,
940 .halt_bit = 9,
941 .reset_mask = P_USB_HS3_P_CLK,
942 },
943 .parent = &glbl_root_clk.c,
944 .c = {
945 .dbg_name = "usb_hs3_p_clk",
946 .ops = &clk_ops_branch,
947 CLK_INIT(usb_hs3_p_clk.c),
948 },
949};
950
951static struct branch_clk usb_hs_p_clk = {
952 .b = {
953 .ctl_reg = GLBL_CLK_ENA_SC_REG,
954 .en_mask = BIT(25),
955 .halt_reg = GLBL_CLK_STATE_REG,
956 .halt_check = HALT_VOTED,
957 .halt_bit = 25,
958 .reset_mask = P_USB_HS_P_CLK,
959 },
960 .parent = &glbl_root_clk.c,
961 .c = {
962 .dbg_name = "usb_hs_p_clk",
963 .ops = &clk_ops_branch,
964 CLK_INIT(usb_hs_p_clk.c),
965 },
966};
967
968static struct branch_clk vfe_p_clk = {
969 .b = {
970 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
971 .en_mask = BIT(27),
972 .halt_reg = GLBL_CLK_STATE_2_REG,
973 .halt_check = HALT_VOTED,
974 .halt_bit = 27,
975 .reset_mask = P_VFE_P_CLK,
976 },
977 .parent = &glbl_root_clk.c,
978 .c = {
979 .dbg_name = "vfe_p_clk",
980 .ops = &clk_ops_branch,
981 CLK_INIT(vfe_p_clk.c),
982 },
983};
984
985static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700986 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
987 F_MND8(153600000, 24, 17, pll1, 2, 2, 5),
988 F_MND8(192000000, 24, 17, pll1, 4, 0, 0),
989 F_MND8(384000000, 24, 17, pll1, 2, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700990 F_END,
991};
992
993static struct rcg_clk csi0_clk = {
994 .b = {
995 .ctl_reg = CSI_NS_REG,
996 .en_mask = BIT(9),
997 .halt_reg = CLK_HALT_STATEC_REG,
998 .halt_bit = 17,
999 .reset_mask = P_CSI0_CLK,
1000 },
1001 .ns_reg = CSI_NS_REG,
1002 .md_reg = CSI_NS_REG - 4,
1003 .ns_mask = F_MASK_MND8(24, 17),
1004 .root_en_mask = BIT(11),
1005 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001006 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001007 .set_rate = set_rate_mnd,
1008 .c = {
1009 .dbg_name = "csi0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001010 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001011 VDD_DIG_FMAX_MAP1(NOMINAL, 384000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001012 CLK_INIT(csi0_clk.c),
1013 },
1014};
1015
1016static struct clk_freq_tbl clk_tbl_tcxo[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001017 F_RAW(19200000, &tcxo_clk.c, 0, 0, 0, 0, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001018 F_END,
1019};
1020
1021static struct rcg_clk i2c_clk = {
1022 .b = {
1023 .ctl_reg = I2C_NS_REG,
1024 .en_mask = BIT(9),
1025 .halt_reg = CLK_HALT_STATEA_REG,
1026 .halt_bit = 15,
1027 .reset_mask = P_I2C_CLK,
1028 },
1029 .set_rate = set_rate_nop,
1030 .freq_tbl = clk_tbl_tcxo,
1031 .root_en_mask = BIT(11),
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001032 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001033 .c = {
1034 .dbg_name = "i2c_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001035 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001036 VDD_DIG_FMAX_MAP1(NOMINAL, 19200000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001037 CLK_INIT(i2c_clk.c),
1038 },
1039};
1040
1041static struct rcg_clk i2c_2_clk = {
1042 .b = {
1043 .ctl_reg = I2C_2_NS_REG,
1044 .en_mask = BIT(0),
1045 .halt_reg = CLK_HALT_STATEC_REG,
1046 .halt_bit = 2,
1047 .reset_mask = P_I2C_2_CLK,
1048 },
1049 .root_en_mask = BIT(2),
1050 .freq_tbl = clk_tbl_tcxo,
1051 .set_rate = set_rate_nop,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001052 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001053 .c = {
1054 .dbg_name = "i2c_2_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001055 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001056 VDD_DIG_FMAX_MAP1(NOMINAL, 19200000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001057 CLK_INIT(i2c_2_clk.c),
1058 },
1059};
1060
1061static struct rcg_clk qup_i2c_clk = {
1062 .b = {
1063 .ctl_reg = QUP_I2C_NS_REG,
1064 .en_mask = BIT(0),
1065 .halt_reg = CLK_HALT_STATEB_REG,
1066 .halt_bit = 31,
1067 .reset_mask = P_QUP_I2C_CLK,
1068 },
1069 .root_en_mask = BIT(2),
1070 .freq_tbl = clk_tbl_tcxo,
1071 .set_rate = set_rate_nop,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001072 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001073 .c = {
1074 .dbg_name = "qup_i2c_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001075 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001076 VDD_DIG_FMAX_MAP1(NOMINAL, 19200000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001077 CLK_INIT(qup_i2c_clk.c),
1078 },
1079};
1080
1081static struct rcg_clk uart1_clk = {
1082 .b = {
1083 .ctl_reg = UART_NS_REG,
1084 .en_mask = BIT(5),
1085 .halt_reg = CLK_HALT_STATEB_REG,
1086 .halt_bit = 7,
1087 .reset_mask = P_UART1_CLK,
1088 },
1089 .root_en_mask = BIT(4),
1090 .freq_tbl = clk_tbl_tcxo,
1091 .set_rate = set_rate_nop,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001092 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001093 .c = {
1094 .dbg_name = "uart1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001095 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001096 VDD_DIG_FMAX_MAP1(NOMINAL, 19200000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001097 CLK_INIT(uart1_clk.c),
1098 },
1099};
1100
1101static struct rcg_clk uart2_clk = {
1102 .b = {
1103 .ctl_reg = UART2_NS_REG,
1104 .en_mask = BIT(5),
1105 .halt_reg = CLK_HALT_STATEB_REG,
1106 .halt_bit = 5,
1107 .reset_mask = P_UART2_CLK,
1108 },
1109 .root_en_mask = BIT(4),
1110 .freq_tbl = clk_tbl_tcxo,
1111 .set_rate = set_rate_nop,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001112 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001113 .c = {
1114 .dbg_name = "uart2_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001115 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001116 VDD_DIG_FMAX_MAP1(NOMINAL, 19200000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001117 CLK_INIT(uart2_clk.c),
1118 },
1119};
1120
1121static struct clk_freq_tbl clk_tbl_uartdm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001122 F_MND16( 0, gnd, 1, 0, 0),
1123 F_MND16( 3686400, pll3, 3, 3, 200),
1124 F_MND16( 7372800, pll3, 3, 3, 100),
1125 F_MND16(14745600, pll3, 3, 3, 50),
1126 F_MND16(32000000, pll3, 3, 25, 192),
1127 F_MND16(40000000, pll3, 3, 125, 768),
1128 F_MND16(46400000, pll3, 3, 145, 768),
1129 F_MND16(48000000, pll3, 3, 25, 128),
1130 F_MND16(51200000, pll3, 3, 5, 24),
1131 F_MND16(56000000, pll3, 3, 175, 768),
1132 F_MND16(58982400, pll3, 3, 6, 25),
1133 F_MND16(64000000, pll1, 4, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001134 F_END,
1135};
1136
1137static struct rcg_clk uart1dm_clk = {
1138 .b = {
1139 .ctl_reg = UART1DM_NS_REG,
1140 .en_mask = BIT(9),
1141 .halt_reg = CLK_HALT_STATEB_REG,
1142 .halt_bit = 6,
1143 .reset_mask = P_UART1DM_CLK,
1144 },
1145 .ns_reg = UART1DM_NS_REG,
1146 .md_reg = UART1DM_NS_REG - 4,
1147 .root_en_mask = BIT(11),
1148 .freq_tbl = clk_tbl_uartdm,
1149 .ns_mask = F_MASK_MND16,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001150 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001151 .set_rate = set_rate_mnd,
1152 .c = {
1153 .dbg_name = "uart1dm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001154 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001155 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001156 CLK_INIT(uart1dm_clk.c),
1157 },
1158};
1159
1160static struct rcg_clk uart2dm_clk = {
1161 .b = {
1162 .ctl_reg = UART2DM_NS_REG,
1163 .en_mask = BIT(9),
1164 .halt_reg = CLK_HALT_STATEB_REG,
1165 .halt_bit = 23,
1166 .reset_mask = P_UART2DM_CLK,
1167 },
1168 .ns_reg = UART2DM_NS_REG,
1169 .md_reg = UART2DM_NS_REG - 4,
1170 .root_en_mask = BIT(11),
1171 .freq_tbl = clk_tbl_uartdm,
1172 .ns_mask = F_MASK_MND16,
1173 .set_rate = set_rate_mnd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001174 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001175 .c = {
1176 .dbg_name = "uart2dm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001177 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001178 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001179 CLK_INIT(uart2dm_clk.c),
1180 },
1181};
1182
1183static struct clk_freq_tbl clk_tbl_mdh[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001184 F_BASIC( 0, gnd, 1),
1185 F_BASIC( 49150000, pll3, 15),
1186 F_BASIC( 92160000, pll3, 8),
1187 F_BASIC(122880000, pll3, 6),
1188 F_BASIC(184320000, pll3, 4),
1189 F_BASIC(245760000, pll3, 3),
1190 F_BASIC(368640000, pll3, 2),
1191 F_BASIC(384000000, pll1, 2),
1192 F_BASIC(445500000, pll4, 2),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001193 F_END,
1194};
1195
1196static struct rcg_clk emdh_clk = {
1197 .b = {
1198 .ctl_reg = EMDH_NS_REG,
1199 .halt_check = DELAY,
1200 .reset_mask = P_EMDH_CLK,
1201 },
1202 .root_en_mask = BIT(11),
1203 .ns_reg = EMDH_NS_REG,
1204 .ns_mask = F_MASK_BASIC,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001205 .set_rate = set_rate_nop,
1206 .freq_tbl = clk_tbl_mdh,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001207 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001208 .c = {
1209 .dbg_name = "emdh_clk",
1210 .flags = CLKFLAG_MIN | CLKFLAG_MAX,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001211 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001212 VDD_DIG_FMAX_MAP1(NOMINAL, 445500000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001213 CLK_INIT(emdh_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001214 .depends = &axi_li_adsp_a_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001215 },
1216};
1217
1218static struct rcg_clk pmdh_clk = {
1219 .b = {
1220 .ctl_reg = PMDH_NS_REG,
1221 .halt_check = DELAY,
1222 .reset_mask = P_PMDH_CLK,
1223 },
1224 .root_en_mask = BIT(11),
1225 .ns_reg = PMDH_NS_REG,
1226 .ns_mask = F_MASK_BASIC,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001227 .set_rate = set_rate_nop,
1228 .freq_tbl = clk_tbl_mdh,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001229 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001230 .c = {
1231 .dbg_name = "pmdh_clk",
1232 .flags = CLKFLAG_MIN | CLKFLAG_MAX,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001233 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001234 VDD_DIG_FMAX_MAP1(NOMINAL, 445500000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001235 CLK_INIT(pmdh_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001236 .depends = &axi_li_adsp_a_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001237 },
1238};
1239
1240static struct clk_freq_tbl clk_tbl_grp[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001241 F_BASIC( 24576000, lpxo, 1),
1242 F_BASIC( 46080000, pll3, 16),
1243 F_BASIC( 49152000, pll3, 15),
1244 F_BASIC( 52662875, pll3, 14),
1245 F_BASIC( 56713846, pll3, 13),
1246 F_BASIC( 61440000, pll3, 12),
1247 F_BASIC( 67025454, pll3, 11),
1248 F_BASIC( 73728000, pll3, 10),
1249 F_BASIC( 81920000, pll3, 9),
1250 F_BASIC( 92160000, pll3, 8),
1251 F_BASIC(105325714, pll3, 7),
1252 F_BASIC(122880000, pll3, 6),
1253 F_BASIC(147456000, pll3, 5),
1254 F_BASIC(184320000, pll3, 4),
1255 F_BASIC(192000000, pll1, 4),
1256 F_BASIC(245760000, pll3, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001257 /* Sync to AXI. Hence this "rate" is not fixed. */
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001258 F_RAW(1, &lpxo_clk.c, 0, BIT(14), 0, 0, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001259 F_END,
1260};
1261
1262static struct rcg_clk grp_2d_clk = {
1263 .b = {
1264 .ctl_reg = GRP_2D_NS_REG,
1265 .en_mask = BIT(7),
1266 .halt_reg = CLK_HALT_STATEA_REG,
1267 .halt_bit = 31,
1268 .reset_mask = P_GRP_2D_CLK,
1269 },
1270 .ns_reg = GRP_2D_NS_REG,
1271 .root_en_mask = BIT(11),
1272 .ns_mask = F_MASK_BASIC | (7 << 12),
1273 .set_rate = set_rate_nop,
1274 .freq_tbl = clk_tbl_grp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001275 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001276 .c = {
1277 .dbg_name = "grp_2d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001278 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001279 VDD_DIG_FMAX_MAP2(NOMINAL, 192000000, HIGH, 245760000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001280 CLK_INIT(grp_2d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001281 .depends = &axi_grp_2d_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001282 },
1283};
1284
1285static struct rcg_clk grp_3d_src_clk = {
1286 .ns_reg = GRP_NS_REG,
1287 .b = {
1288 .ctl_reg = GRP_NS_REG,
1289 .halt_check = NOCHECK,
1290 },
1291 .root_en_mask = BIT(11),
1292 .ns_mask = F_MASK_BASIC | (7 << 12),
1293 .set_rate = set_rate_nop,
1294 .freq_tbl = clk_tbl_grp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001295 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001296 .c = {
1297 .dbg_name = "grp_3d_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001298 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001299 VDD_DIG_FMAX_MAP2(NOMINAL, 192000000, HIGH, 245760000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001300 CLK_INIT(grp_3d_src_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001301 .depends = &axi_li_grp_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001302 },
1303};
1304
1305static struct branch_clk grp_3d_clk = {
1306 .b = {
1307 .ctl_reg = GRP_NS_REG,
1308 .en_mask = BIT(7),
1309 .halt_reg = CLK_HALT_STATEB_REG,
1310 .halt_bit = 18,
1311 .reset_mask = P_GRP_3D_CLK,
1312 },
1313 .parent = &grp_3d_src_clk.c,
1314 .c = {
1315 .dbg_name = "grp_3d_clk",
1316 .ops = &clk_ops_branch,
1317 CLK_INIT(grp_3d_clk.c),
1318 },
1319};
1320
1321static struct branch_clk imem_clk = {
1322 .b = {
1323 .ctl_reg = GRP_NS_REG,
1324 .en_mask = BIT(9),
1325 .halt_reg = CLK_HALT_STATEB_REG,
1326 .halt_bit = 19,
1327 .reset_mask = P_IMEM_CLK,
1328 },
1329 .parent = &grp_3d_src_clk.c,
1330 .c = {
1331 .dbg_name = "imem_clk",
1332 .ops = &clk_ops_branch,
1333 CLK_INIT(imem_clk.c),
1334 },
1335};
1336
1337static struct clk_freq_tbl clk_tbl_sdc1_3[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001338 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
1339 F_MND8( 144000, 19, 12, lpxo, 1, 1, 171),
1340 F_MND8( 400000, 19, 12, lpxo, 1, 2, 123),
1341 F_MND8(16027000, 19, 12, pll3, 3, 14, 215),
1342 F_MND8(17000000, 19, 12, pll3, 4, 19, 206),
1343 F_MND8(20480000, 19, 12, pll3, 4, 23, 212),
1344 F_MND8(24576000, 19, 12, lpxo, 1, 0, 0),
1345 F_MND8(49152000, 19, 12, pll3, 3, 1, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001346 F_END,
1347};
1348
1349static struct rcg_clk sdc1_clk = {
1350 .b = {
1351 .ctl_reg = SDCn_NS_REG(1),
1352 .en_mask = BIT(9),
1353 .halt_reg = CLK_HALT_STATEA_REG,
1354 .halt_bit = 1,
1355 .reset_mask = P_SDC1_CLK,
1356 },
1357 .ns_reg = SDCn_NS_REG(1),
1358 .md_reg = SDCn_NS_REG(1) - 4,
1359 .ns_mask = F_MASK_MND8(19, 12),
1360 .root_en_mask = BIT(11),
1361 .freq_tbl = clk_tbl_sdc1_3,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001362 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001363 .set_rate = set_rate_mnd,
1364 .c = {
1365 .dbg_name = "sdc1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001366 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001367 VDD_DIG_FMAX_MAP1(NOMINAL, 49152000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001368 CLK_INIT(sdc1_clk.c),
1369 },
1370};
1371
1372static struct rcg_clk sdc3_clk = {
1373 .b = {
1374 .ctl_reg = SDCn_NS_REG(3),
1375 .en_mask = BIT(9),
1376 .halt_reg = CLK_HALT_STATEB_REG,
1377 .halt_bit = 24,
1378 .reset_mask = P_SDC3_CLK,
1379 },
1380 .ns_reg = SDCn_NS_REG(3),
1381 .md_reg = SDCn_NS_REG(3) - 4,
1382 .ns_mask = F_MASK_MND8(19, 12),
1383 .root_en_mask = BIT(11),
1384 .freq_tbl = clk_tbl_sdc1_3,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001385 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001386 .set_rate = set_rate_mnd,
1387 .c = {
1388 .dbg_name = "sdc3_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001389 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001390 VDD_DIG_FMAX_MAP1(NOMINAL, 49152000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001391 CLK_INIT(sdc3_clk.c),
1392 },
1393};
1394
1395static struct clk_freq_tbl clk_tbl_sdc2_4[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001396 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
1397 F_MND8( 144000, 20, 13, lpxo, 1, 1, 171),
1398 F_MND8( 400000, 20, 13, lpxo, 1, 2, 123),
1399 F_MND8(16027000, 20, 13, pll3, 3, 14, 215),
1400 F_MND8(17000000, 20, 13, pll3, 4, 19, 206),
1401 F_MND8(20480000, 20, 13, pll3, 4, 23, 212),
1402 F_MND8(24576000, 20, 13, lpxo, 1, 0, 0),
1403 F_MND8(49152000, 20, 13, pll3, 3, 1, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001404 F_END,
1405};
1406
1407static struct rcg_clk sdc2_clk = {
1408 .b = {
1409 .ctl_reg = SDCn_NS_REG(2),
1410 .en_mask = BIT(9),
1411 .halt_reg = CLK_HALT_STATEA_REG,
1412 .halt_bit = 0,
1413 .reset_mask = P_SDC2_CLK,
1414 },
1415 .ns_reg = SDCn_NS_REG(2),
1416 .md_reg = SDCn_NS_REG(2) - 4,
1417 .ns_mask = F_MASK_MND8(20, 13),
1418 .root_en_mask = BIT(11),
1419 .freq_tbl = clk_tbl_sdc2_4,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001420 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001421 .set_rate = set_rate_mnd,
1422 .c = {
1423 .dbg_name = "sdc2_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001424 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001425 VDD_DIG_FMAX_MAP1(NOMINAL, 49152000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001426 CLK_INIT(sdc2_clk.c),
1427 },
1428};
1429
1430static struct rcg_clk sdc4_clk = {
1431 .b = {
1432 .ctl_reg = SDCn_NS_REG(4),
1433 .en_mask = BIT(9),
1434 .halt_reg = CLK_HALT_STATEB_REG,
1435 .halt_bit = 25,
1436 .reset_mask = P_SDC4_CLK,
1437 },
1438 .ns_reg = SDCn_NS_REG(4),
1439 .md_reg = SDCn_NS_REG(4) - 4,
1440 .ns_mask = F_MASK_MND8(20, 13),
1441 .root_en_mask = BIT(11),
1442 .freq_tbl = clk_tbl_sdc2_4,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001443 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001444 .set_rate = set_rate_mnd,
1445 .c = {
1446 .dbg_name = "sdc4_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001447 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001448 VDD_DIG_FMAX_MAP1(NOMINAL, 49152000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001449 CLK_INIT(sdc4_clk.c),
1450 },
1451};
1452
1453static struct clk_freq_tbl clk_tbl_mdp_core[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001454 F_BASIC( 24576000, lpxo, 1),
1455 F_BASIC( 46080000, pll3, 16),
1456 F_BASIC( 49152000, pll3, 15),
1457 F_BASIC( 52663000, pll3, 14),
1458 F_BASIC( 92160000, pll3, 8),
1459 F_BASIC(122880000, pll3, 6),
1460 F_BASIC(147456000, pll3, 5),
1461 F_BASIC(153600000, pll1, 5),
1462 F_BASIC(192000000, pll1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001463 F_END,
1464};
1465
1466static struct rcg_clk mdp_clk = {
1467 .b = {
1468 .ctl_reg = MDP_NS_REG,
1469 .en_mask = BIT(9),
1470 .halt_reg = CLK_HALT_STATEB_REG,
1471 .halt_bit = 16,
1472 .reset_mask = P_MDP_CLK,
1473 },
1474 .ns_reg = MDP_NS_REG,
1475 .root_en_mask = BIT(11),
1476 .ns_mask = F_MASK_BASIC,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001477 .set_rate = set_rate_nop,
1478 .freq_tbl = clk_tbl_mdp_core,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001479 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001480 .c = {
1481 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001482 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001483 VDD_DIG_FMAX_MAP2(NOMINAL, 153600000, HIGH, 192000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001484 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001485 .depends = &axi_mdp_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001486 },
1487};
1488
1489static struct clk_freq_tbl clk_tbl_mdp_lcdc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001490 F_MND16( 0, gnd, 1, 0, 0),
1491 F_MND16(24576000, lpxo, 1, 0, 0),
1492 F_MND16(30720000, pll3, 4, 1, 6),
1493 F_MND16(32768000, pll3, 3, 2, 15),
1494 F_MND16(40960000, pll3, 2, 1, 9),
1495 F_MND16(73728000, pll3, 2, 1, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001496 F_END,
1497};
1498
1499static struct rcg_clk mdp_lcdc_pclk_clk = {
1500 .b = {
1501 .ctl_reg = MDP_LCDC_NS_REG,
1502 .en_mask = BIT(9),
1503 .halt_reg = CLK_HALT_STATEB_REG,
1504 .halt_bit = 28,
1505 .reset_mask = P_MDP_LCDC_PCLK_CLK,
1506 },
1507 .ns_reg = MDP_LCDC_NS_REG,
1508 .md_reg = MDP_LCDC_NS_REG - 4,
1509 .root_en_mask = BIT(11),
1510 .ns_mask = F_MASK_MND16,
1511 .set_rate = set_rate_mnd,
1512 .freq_tbl = clk_tbl_mdp_lcdc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001513 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001514 .c = {
1515 .dbg_name = "mdp_lcdc_pclk_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001516 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001517 VDD_DIG_FMAX_MAP1(NOMINAL, 73728000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001518 CLK_INIT(mdp_lcdc_pclk_clk.c),
1519 },
1520};
1521
1522static struct branch_clk mdp_lcdc_pad_pclk_clk = {
1523 .b = {
1524 .ctl_reg = MDP_LCDC_NS_REG,
1525 .en_mask = BIT(12),
1526 .halt_reg = CLK_HALT_STATEB_REG,
1527 .halt_bit = 29,
1528 .reset_mask = P_MDP_LCDC_PAD_PCLK_CLK,
1529 },
1530 .parent = &mdp_lcdc_pclk_clk.c,
1531 .c = {
1532 .dbg_name = "mdp_lcdc_pad_pclk_clk",
1533 .ops = &clk_ops_branch,
1534 CLK_INIT(mdp_lcdc_pad_pclk_clk.c),
1535 },
1536};
1537
1538static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001539 F_RAW( 0, &gnd_clk.c, 0, (0x3<<2), 0, 0, NULL),
1540 F_RAW(24576000, &lpxo_clk.c, 0, (0x1<<2), 0, 0, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001541 F_END,
1542};
1543
1544static struct rcg_clk mdp_vsync_clk = {
1545 .b = {
1546 .ctl_reg = MDP_VSYNC_REG,
1547 .en_mask = BIT(0),
1548 .halt_reg = CLK_HALT_STATEB_REG,
1549 .halt_bit = 30,
1550 .reset_mask = P_MDP_VSYNC_CLK,
1551 },
1552 .ns_reg = MDP_VSYNC_REG,
1553 .ns_mask = BM(3, 2),
1554 .freq_tbl = clk_tbl_mdp_vsync,
1555 .set_rate = set_rate_nop,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001556 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001557 .c = {
1558 .dbg_name = "mdp_vsync_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001559 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001560 VDD_DIG_FMAX_MAP1(NOMINAL, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001561 CLK_INIT(mdp_vsync_clk.c),
1562 },
1563};
1564
1565static struct clk_freq_tbl clk_tbl_mi2s_codec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001566 F_MND16( 0, gnd, 1, 0, 0),
1567 F_MND16( 2048000, lpxo, 4, 1, 3),
1568 F_MND16(12288000, lpxo, 2, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001569 F_END,
1570};
1571
1572static struct rcg_clk mi2s_codec_rx_m_clk = {
1573 .b = {
1574 .ctl_reg = MI2S_RX_NS_REG,
1575 .en_mask = BIT(12),
1576 .halt_reg = CLK_HALT_STATEA_REG,
1577 .halt_bit = 12,
1578 .reset_mask = P_MI2S_CODEC_RX_M_CLK,
1579 },
1580 .ns_reg = MI2S_RX_NS_REG,
1581 .md_reg = MI2S_RX_NS_REG - 4,
1582 .root_en_mask = BIT(11),
1583 .ns_mask = F_MASK_MND16,
1584 .set_rate = set_rate_mnd,
1585 .freq_tbl = clk_tbl_mi2s_codec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001586 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001587 .c = {
1588 .dbg_name = "mi2s_codec_rx_m_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001589 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001590 VDD_DIG_FMAX_MAP1(NOMINAL, 12288000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001591 CLK_INIT(mi2s_codec_rx_m_clk.c),
1592 },
1593};
1594
1595static struct branch_clk mi2s_codec_rx_s_clk = {
1596 .b = {
1597 .ctl_reg = MI2S_RX_NS_REG,
1598 .en_mask = BIT(9),
1599 .halt_reg = CLK_HALT_STATEA_REG,
1600 .halt_bit = 13,
1601 .reset_mask = P_MI2S_CODEC_RX_S_CLK,
1602 },
1603 .parent = &mi2s_codec_rx_m_clk.c,
1604 .c = {
1605 .dbg_name = "mi2s_codec_rx_s_clk",
1606 .ops = &clk_ops_branch,
1607 CLK_INIT(mi2s_codec_rx_s_clk.c),
1608 },
1609};
1610
1611static struct rcg_clk mi2s_codec_tx_m_clk = {
1612 .b = {
1613 .ctl_reg = MI2S_TX_NS_REG,
1614 .en_mask = BIT(12),
1615 .halt_reg = CLK_HALT_STATEC_REG,
1616 .halt_bit = 8,
1617 .reset_mask = P_MI2S_CODEC_TX_M_CLK,
1618 },
1619 .ns_reg = MI2S_TX_NS_REG,
1620 .md_reg = MI2S_TX_NS_REG - 4,
1621 .root_en_mask = BIT(11),
1622 .ns_mask = F_MASK_MND16,
1623 .set_rate = set_rate_mnd,
1624 .freq_tbl = clk_tbl_mi2s_codec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001625 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001626 .c = {
1627 .dbg_name = "mi2s_codec_tx_m_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001628 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001629 VDD_DIG_FMAX_MAP1(NOMINAL, 12288000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001630 CLK_INIT(mi2s_codec_tx_m_clk.c),
1631 },
1632};
1633
1634static struct branch_clk mi2s_codec_tx_s_clk = {
1635 .b = {
1636 .ctl_reg = MI2S_TX_NS_REG,
1637 .en_mask = BIT(9),
1638 .halt_reg = CLK_HALT_STATEA_REG,
1639 .halt_bit = 11,
1640 .reset_mask = P_MI2S_CODEC_TX_S_CLK,
1641 },
1642 .parent = &mi2s_codec_tx_m_clk.c,
1643 .c = {
1644 .dbg_name = "mi2s_codec_tx_s_clk",
1645 .ops = &clk_ops_branch,
1646 CLK_INIT(mi2s_codec_tx_s_clk.c),
1647 },
1648};
1649
1650static struct clk_freq_tbl clk_tbl_mi2s[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001651 F_MND16( 0, gnd, 1, 0, 0),
1652 F_MND16(12288000, lpxo, 2, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001653 F_END,
1654};
1655
1656static struct rcg_clk mi2s_m_clk = {
1657 .b = {
1658 .ctl_reg = MI2S_NS_REG,
1659 .en_mask = BIT(12),
1660 .halt_reg = CLK_HALT_STATEC_REG,
1661 .halt_bit = 4,
1662 .reset_mask = P_MI2S_M_CLK,
1663 },
1664 .ns_reg = MI2S_NS_REG,
1665 .md_reg = MI2S_NS_REG - 4,
1666 .root_en_mask = BIT(11),
1667 .ns_mask = F_MASK_MND16,
1668 .set_rate = set_rate_mnd,
1669 .freq_tbl = clk_tbl_mi2s,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001670 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001671 .c = {
1672 .dbg_name = "mi2s_m_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001673 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001674 VDD_DIG_FMAX_MAP1(NOMINAL, 12288000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001675 CLK_INIT(mi2s_m_clk.c),
1676 },
1677};
1678
1679static struct branch_clk mi2s_s_clk = {
1680 .b = {
1681 .ctl_reg = MI2S_NS_REG,
1682 .en_mask = BIT(9),
1683 .halt_reg = CLK_HALT_STATEC_REG,
1684 .halt_bit = 3,
1685 .reset_mask = P_MI2S_S_CLK,
1686 },
1687 .parent = &mi2s_m_clk.c,
1688 .c = {
1689 .dbg_name = "mi2s_s_clk",
1690 .ops = &clk_ops_branch,
1691 CLK_INIT(mi2s_s_clk.c),
1692 },
1693};
1694
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001695#define F_SDAC(f, s, div, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001696 { \
1697 .freq_hz = f, \
1698 .md_val = MD16(m, n), \
1699 .ns_val = N16(m, n) | SPDIV(SRC_SEL_SDAC_##s, div), \
1700 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001701 .src_clk = &s##_clk.c, \
1702 }
1703
1704static struct clk_freq_tbl clk_tbl_sdac[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001705 F_SDAC( 256000, lpxo, 4, 1, 24),
1706 F_SDAC( 352800, lpxo, 1, 147, 10240),
1707 F_SDAC( 384000, lpxo, 4, 1, 16),
1708 F_SDAC( 512000, lpxo, 4, 1, 12),
1709 F_SDAC( 705600, lpxo, 1, 147, 5120),
1710 F_SDAC( 768000, lpxo, 4, 1, 8),
1711 F_SDAC(1024000, lpxo, 4, 1, 6),
1712 F_SDAC(1411200, lpxo, 1, 147, 2560),
1713 F_SDAC(1536000, lpxo, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001714 F_END,
1715};
1716
1717static struct rcg_clk sdac_clk = {
1718 .b = {
1719 .ctl_reg = SDAC_NS_REG,
1720 .en_mask = BIT(9),
1721 .halt_reg = CLK_HALT_STATEA_REG,
1722 .halt_bit = 2,
1723 .reset_mask = P_SDAC_CLK,
1724 },
1725 .ns_reg = SDAC_NS_REG,
1726 .md_reg = SDAC_NS_REG - 4,
1727 .root_en_mask = BIT(11),
1728 .freq_tbl = clk_tbl_sdac,
1729 .ns_mask = F_MASK_MND16,
1730 .set_rate = set_rate_mnd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001731 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001732 .c = {
1733 .dbg_name = "sdac_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001734 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001735 VDD_DIG_FMAX_MAP1(NOMINAL, 1536000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001736 CLK_INIT(sdac_clk.c),
1737 },
1738};
1739
1740static struct branch_clk sdac_m_clk = {
1741 .b = {
1742 .ctl_reg = SDAC_NS_REG,
1743 .en_mask = BIT(12),
1744 .halt_reg = CLK_HALT_STATEB_REG,
1745 .halt_bit = 17,
1746 .reset_mask = P_SDAC_M_CLK,
1747 },
1748 .parent = &sdac_clk.c,
1749 .c = {
1750 .dbg_name = "sdac_m_clk",
1751 .ops = &clk_ops_branch,
1752 CLK_INIT(sdac_m_clk.c),
1753 },
1754};
1755
1756static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001757 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
1758 F_MND8(27000000, 23, 16, pll4, 2, 2, 33),
1759 F_MND8(74250000, 23, 16, pll4, 2, 1, 6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001760 F_END,
1761};
1762
1763static struct rcg_clk tv_clk = {
1764 .ns_reg = TV_NS_REG,
1765 .b = {
1766 .ctl_reg = TV_NS_REG,
1767 .halt_check = NOCHECK,
1768 },
1769 .md_reg = TV_NS_REG - 4,
1770 .ns_mask = F_MASK_MND8(23, 16),
1771 .root_en_mask = BIT(11),
1772 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001773 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001774 .set_rate = set_rate_mnd,
1775 .c = {
1776 .dbg_name = "tv_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001777 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001778 VDD_DIG_FMAX_MAP1(NOMINAL, 74250000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001779 CLK_INIT(tv_clk.c),
1780 },
1781};
1782
1783static struct branch_clk hdmi_clk = {
1784 .b = {
1785 .ctl_reg = HDMI_NS_REG,
1786 .en_mask = BIT(9),
1787 .halt_reg = CLK_HALT_STATEC_REG,
1788 .halt_bit = 7,
1789 .reset_mask = P_HDMI_CLK,
1790 },
1791 .parent = &tv_clk.c,
1792 .c = {
1793 .dbg_name = "hdmi_clk",
1794 .ops = &clk_ops_branch,
1795 CLK_INIT(hdmi_clk.c),
1796 },
1797};
1798
1799static struct branch_clk tv_dac_clk = {
1800 .b = {
1801 .ctl_reg = TV_NS_REG,
1802 .en_mask = BIT(12),
1803 .halt_reg = CLK_HALT_STATEB_REG,
1804 .halt_bit = 27,
1805 .reset_mask = P_TV_DAC_CLK,
1806 },
1807 .parent = &tv_clk.c,
1808 .c = {
1809 .dbg_name = "tv_dac_clk",
1810 .ops = &clk_ops_branch,
1811 CLK_INIT(tv_dac_clk.c),
1812 },
1813};
1814
1815static struct branch_clk tv_enc_clk = {
1816 .b = {
1817 .ctl_reg = TV_NS_REG,
1818 .en_mask = BIT(9),
1819 .halt_reg = CLK_HALT_STATEB_REG,
1820 .halt_bit = 10,
1821 .reset_mask = P_TV_ENC_CLK,
1822 },
1823 .parent = &tv_clk.c,
1824 .c = {
1825 .dbg_name = "tv_enc_clk",
1826 .ops = &clk_ops_branch,
1827 CLK_INIT(tv_enc_clk.c),
1828 },
1829};
1830
1831/* Hacking root & branch into one param. */
1832static struct branch_clk tsif_ref_clk = {
1833 .b = {
1834 .ctl_reg = TSIF_NS_REG,
1835 .en_mask = BIT(9)|BIT(11),
1836 .halt_reg = CLK_HALT_STATEB_REG,
1837 .halt_bit = 11,
1838 .reset_mask = P_TSIF_REF_CLK,
1839 },
1840 .parent = &tv_clk.c,
1841 .c = {
1842 .dbg_name = "tsif_ref_clk",
1843 .ops = &clk_ops_branch,
1844 CLK_INIT(tsif_ref_clk.c),
1845 },
1846};
1847
1848static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001849 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
1850 F_MND8(60000000, 23, 16, pll1, 2, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001851 F_END,
1852};
1853
1854static struct rcg_clk usb_hs_src_clk = {
1855 .ns_reg = USBH_NS_REG,
1856 .b = {
1857 .ctl_reg = USBH_NS_REG,
1858 .halt_check = NOCHECK,
1859 },
1860 .md_reg = USBH_NS_REG - 4,
1861 .ns_mask = F_MASK_MND8(23, 16),
1862 .root_en_mask = BIT(11),
1863 .freq_tbl = clk_tbl_usb,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001864 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001865 .set_rate = set_rate_mnd,
1866 .c = {
1867 .dbg_name = "usb_hs_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001868 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001869 VDD_DIG_FMAX_MAP1(NOMINAL, 60000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001870 CLK_INIT(usb_hs_src_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001871 .depends = &axi_li_adsp_a_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001872 },
1873};
1874
1875static struct branch_clk usb_hs_clk = {
1876 .b = {
1877 .ctl_reg = USBH_NS_REG,
1878 .en_mask = BIT(9),
1879 .halt_reg = CLK_HALT_STATEB_REG,
1880 .halt_bit = 26,
1881 .reset_mask = P_USB_HS_CLK,
1882 },
1883 .c = {
1884 .dbg_name = "usb_hs_clk",
1885 .ops = &clk_ops_branch,
1886 CLK_INIT(usb_hs_clk.c),
1887 },
1888};
1889
1890static struct branch_clk usb_hs_core_clk = {
1891 .b = {
1892 .ctl_reg = USBH_NS_REG,
1893 .en_mask = BIT(13),
1894 .halt_reg = CLK_HALT_STATEA_REG,
1895 .halt_bit = 27,
1896 .reset_mask = P_USB_HS_CORE_CLK,
1897 },
1898 .parent = &usb_hs_src_clk.c,
1899 .c = {
1900 .dbg_name = "usb_hs_core_clk",
1901 .ops = &clk_ops_branch,
1902 CLK_INIT(usb_hs_core_clk.c),
1903 },
1904};
1905
1906static struct branch_clk usb_hs2_clk = {
1907 .b = {
1908 .ctl_reg = USBH2_NS_REG,
1909 .en_mask = BIT(9),
1910 .halt_reg = CLK_HALT_STATEB_REG,
1911 .halt_bit = 3,
1912 .reset_mask = P_USB_HS2_CLK,
1913 },
1914 .parent = &usb_hs_src_clk.c,
1915 .c = {
1916 .dbg_name = "usb_hs2_clk",
1917 .ops = &clk_ops_branch,
1918 CLK_INIT(usb_hs2_clk.c),
1919 },
1920};
1921
1922static struct branch_clk usb_hs2_core_clk = {
1923 .b = {
1924 .ctl_reg = USBH2_NS_REG,
1925 .en_mask = BIT(4),
1926 .halt_reg = CLK_HALT_STATEA_REG,
1927 .halt_bit = 28,
1928 .reset_mask = P_USB_HS2_CORE_CLK,
1929 },
1930 .parent = &usb_hs_src_clk.c,
1931 .c = {
1932 .dbg_name = "usb_hs2_core_clk",
1933 .ops = &clk_ops_branch,
1934 CLK_INIT(usb_hs2_core_clk.c),
1935 },
1936};
1937
1938static struct branch_clk usb_hs3_clk = {
1939 .b = {
1940 .ctl_reg = USBH3_NS_REG,
1941 .en_mask = BIT(9),
1942 .halt_reg = CLK_HALT_STATEB_REG,
1943 .halt_bit = 2,
1944 .reset_mask = P_USB_HS3_CLK,
1945 },
1946 .parent = &usb_hs_src_clk.c,
1947 .c = {
1948 .dbg_name = "usb_hs3_clk",
1949 .ops = &clk_ops_branch,
1950 CLK_INIT(usb_hs3_clk.c),
1951 },
1952};
1953
1954static struct branch_clk usb_hs3_core_clk = {
1955 .b = {
1956 .ctl_reg = USBH3_NS_REG,
1957 .en_mask = BIT(4),
1958 .halt_reg = CLK_HALT_STATEA_REG,
1959 .halt_bit = 29,
1960 .reset_mask = P_USB_HS3_CORE_CLK,
1961 },
1962 .parent = &usb_hs_src_clk.c,
1963 .c = {
1964 .dbg_name = "usb_hs3_core_clk",
1965 .ops = &clk_ops_branch,
1966 CLK_INIT(usb_hs3_core_clk.c),
1967 },
1968};
1969
1970static struct clk_freq_tbl clk_tbl_vfe_jpeg[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001971 F_MND16( 24576000, lpxo, 1, 0, 0),
1972 F_MND16( 36864000, pll3, 4, 1, 5),
1973 F_MND16( 46080000, pll3, 4, 1, 4),
1974 F_MND16( 61440000, pll3, 4, 1, 3),
1975 F_MND16( 73728000, pll3, 2, 1, 5),
1976 F_MND16( 81920000, pll3, 3, 1, 3),
1977 F_MND16( 92160000, pll3, 4, 1, 2),
1978 F_MND16( 98304000, pll3, 3, 2, 5),
1979 F_MND16(105326000, pll3, 2, 2, 7),
1980 F_MND16(122880000, pll3, 2, 1, 3),
1981 F_MND16(147456000, pll3, 2, 2, 5),
1982 F_MND16(153600000, pll1, 2, 2, 5),
1983 F_MND16(192000000, pll1, 4, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001984 F_END,
1985};
1986
1987static struct rcg_clk jpeg_clk = {
1988 .b = {
1989 .ctl_reg = JPEG_NS_REG,
1990 .en_mask = BIT(9),
1991 .halt_reg = CLK_HALT_STATEB_REG,
1992 .halt_bit = 1,
1993 .reset_mask = P_JPEG_CLK,
1994 },
1995 .ns_reg = JPEG_NS_REG,
1996 .md_reg = JPEG_NS_REG - 4,
1997 .root_en_mask = BIT(11),
1998 .freq_tbl = clk_tbl_vfe_jpeg,
1999 .ns_mask = F_MASK_MND16,
2000 .set_rate = set_rate_mnd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002001 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002002 .c = {
2003 .dbg_name = "jpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002004 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002005 VDD_DIG_FMAX_MAP2(NOMINAL, 153600000, HIGH, 192000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002006 CLK_INIT(jpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002007 .depends = &axi_li_jpeg_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002008 },
2009};
2010
2011static struct rcg_clk vfe_clk = {
2012 .b = {
2013 .ctl_reg = CAM_VFE_NS_REG,
2014 .en_mask = BIT(9),
2015 .halt_reg = CLK_HALT_STATEB_REG,
2016 .halt_bit = 0,
2017 .reset_mask = P_VFE_CLK,
2018 },
2019 .ns_reg = CAM_VFE_NS_REG,
2020 .md_reg = CAM_VFE_NS_REG - 4,
2021 .root_en_mask = BIT(13),
2022 .freq_tbl = clk_tbl_vfe_jpeg,
2023 .ns_mask = F_MASK_MND16,
2024 .set_rate = set_rate_mnd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002025 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002026 .c = {
2027 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002028 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002029 VDD_DIG_FMAX_MAP2(NOMINAL, 153600000, HIGH, 192000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002030 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002031 .depends = &axi_li_vfe_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002032 },
2033};
2034
2035static struct branch_clk vfe_mdc_clk = {
2036 .b = {
2037 .ctl_reg = CAM_VFE_NS_REG,
2038 .en_mask = BIT(11),
2039 .halt_reg = CLK_HALT_STATEA_REG,
2040 .halt_bit = 9,
2041 .reset_mask = P_VFE_MDC_CLK,
2042 },
2043 .parent = &vfe_clk.c,
2044 .c = {
2045 .dbg_name = "vfe_mdc_clk",
2046 .ops = &clk_ops_branch,
2047 CLK_INIT(vfe_mdc_clk.c),
2048 },
2049};
2050
2051static struct branch_clk vfe_camif_clk = {
2052 .b = {
2053 .ctl_reg = CAM_VFE_NS_REG,
2054 .en_mask = BIT(15),
2055 .halt_reg = CLK_HALT_STATEC_REG,
2056 .halt_bit = 13,
2057 .reset_mask = P_VFE_CAMIF_CLK,
2058 },
2059 .parent = &vfe_clk.c,
2060 .c = {
2061 .dbg_name = "vfe_camif_clk",
2062 .ops = &clk_ops_branch,
2063 CLK_INIT(vfe_camif_clk.c),
2064 },
2065};
2066
2067static struct branch_clk csi0_vfe_clk = {
2068 .b = {
2069 .ctl_reg = CSI_NS_REG,
2070 .en_mask = BIT(15),
2071 .halt_reg = CLK_HALT_STATEC_REG,
2072 .halt_bit = 16,
2073 .reset_mask = P_CSI0_VFE_CLK,
2074 },
2075 .parent = &vfe_clk.c,
2076 .c = {
2077 .dbg_name = "csi0_vfe_clk",
2078 .ops = &clk_ops_branch,
2079 CLK_INIT(csi0_vfe_clk.c),
2080 },
2081};
2082
2083static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002084 F_MND16( 0, gnd, 1, 0, 0),
2085 F_MND16( 6000000, pll1, 4, 1, 32),
2086 F_MND16( 8000000, pll1, 4, 1, 24),
2087 F_MND16(12000000, pll1, 4, 1, 16),
2088 F_MND16(16000000, pll1, 4, 1, 12),
2089 F_MND16(19200000, pll1, 4, 1, 10),
2090 F_MND16(24000000, pll1, 4, 1, 8),
2091 F_MND16(32000000, pll1, 4, 1, 6),
2092 F_MND16(48000000, pll1, 4, 1, 4),
2093 F_MND16(64000000, pll1, 4, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002094 F_END,
2095};
2096
2097static struct rcg_clk cam_m_clk = {
2098 .b = {
2099 .ctl_reg = CAM_NS_REG,
2100 .halt_check = DELAY,
2101 .reset_mask = P_CAM_M_CLK,
2102 },
2103 .ns_reg = CAM_NS_REG,
2104 .md_reg = CAM_NS_REG - 4,
2105 .root_en_mask = BIT(9),
2106 .freq_tbl = clk_tbl_cam,
2107 .ns_mask = F_MASK_MND16,
2108 .set_rate = set_rate_mnd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002109 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002110 .c = {
2111 .dbg_name = "cam_m_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002112 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002113 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002114 CLK_INIT(cam_m_clk.c),
2115 },
2116};
2117
2118static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002119 F_MND8( 24576000, 22, 15, lpxo, 1, 0, 0),
2120 F_MND8( 30720000, 22, 15, pll3, 4, 1, 6),
2121 F_MND8( 61440000, 22, 15, pll3, 4, 1, 3),
2122 F_MND8( 81920000, 22, 15, pll3, 3, 1, 3),
2123 F_MND8(122880000, 22, 15, pll3, 3, 1, 2),
2124 F_MND8(147456000, 22, 15, pll3, 1, 1, 5),
2125 F_MND8(153600000, 22, 15, pll1, 1, 1, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002126 F_END,
2127};
2128
2129static struct rcg_clk vpe_clk = {
2130 .b = {
2131 .ctl_reg = VPE_NS_REG,
2132 .en_mask = BIT(9),
2133 .halt_reg = CLK_HALT_STATEC_REG,
2134 .halt_bit = 10,
2135 .reset_mask = P_VPE_CLK,
2136 },
2137 .ns_reg = VPE_NS_REG,
2138 .md_reg = VPE_NS_REG - 4,
2139 .ns_mask = F_MASK_MND8(22, 15),
2140 .root_en_mask = BIT(11),
2141 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002142 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002143 .set_rate = set_rate_mnd,
2144 .c = {
2145 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002146 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002147 VDD_DIG_FMAX_MAP1(NOMINAL, 153600000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002148 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002149 .depends = &axi_vpe_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002150 },
2151};
2152
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002153static struct clk_freq_tbl clk_tbl_mfc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002154 F_MND8( 24576000, 24, 17, lpxo, 1, 0, 0),
2155 F_MND8( 30720000, 24, 17, pll3, 4, 1, 6),
2156 F_MND8( 61440000, 24, 17, pll3, 4, 1, 3),
2157 F_MND8( 81920000, 24, 17, pll3, 3, 1, 3),
2158 F_MND8(122880000, 24, 17, pll3, 3, 1, 2),
2159 F_MND8(147456000, 24, 17, pll3, 1, 1, 5),
2160 F_MND8(153600000, 24, 17, pll1, 1, 1, 5),
2161 F_MND8(170667000, 24, 17, pll1, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002162 F_END,
2163};
2164
2165static struct rcg_clk mfc_clk = {
2166 .b = {
2167 .ctl_reg = MFC_NS_REG,
2168 .en_mask = BIT(9),
2169 .halt_reg = CLK_HALT_STATEC_REG,
2170 .halt_bit = 12,
2171 .reset_mask = P_MFC_CLK,
2172 },
2173 .ns_reg = MFC_NS_REG,
2174 .md_reg = MFC_NS_REG - 4,
2175 .ns_mask = F_MASK_MND8(24, 17),
2176 .root_en_mask = BIT(11),
2177 .freq_tbl = clk_tbl_mfc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002178 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002179 .set_rate = set_rate_mnd,
2180 .c = {
2181 .dbg_name = "mfc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002182 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002183 VDD_DIG_FMAX_MAP1(NOMINAL, 170667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002184 CLK_INIT(mfc_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002185 .depends = &axi_mfc_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002186 },
2187};
2188
2189static struct branch_clk mfc_div2_clk = {
2190 .b = {
2191 .ctl_reg = MFC_NS_REG,
2192 .en_mask = BIT(15),
2193 .halt_reg = CLK_HALT_STATEC_REG,
2194 .halt_bit = 11,
2195 .reset_mask = P_MFC_DIV2_CLK,
2196 },
2197 .parent = &mfc_clk.c,
2198 .c = {
2199 .dbg_name = "mfc_div2_clk",
2200 .ops = &clk_ops_branch,
2201 CLK_INIT(mfc_div2_clk.c),
2202 },
2203};
2204
2205static struct clk_freq_tbl clk_tbl_spi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002206 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
2207 F_MND8( 9963243, 19, 12, pll3, 4, 2, 37),
Matt Wagantalla7df37f2011-11-11 11:28:11 -08002208 F_MND8(24576000, 19, 12, lpxo, 1, 0, 0),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002209 F_MND8(26331429, 19, 12, pll3, 4, 1, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002210 F_END,
2211};
2212
2213static struct rcg_clk spi_clk = {
2214 .b = {
2215 .ctl_reg = SPI_NS_REG,
2216 .en_mask = BIT(9),
2217 .halt_reg = CLK_HALT_STATEC_REG,
2218 .halt_bit = 0,
2219 .reset_mask = P_SPI_CLK,
2220 },
2221 .ns_reg = SPI_NS_REG,
2222 .md_reg = SPI_NS_REG - 4,
2223 .ns_mask = F_MASK_MND8(19, 12),
2224 .root_en_mask = BIT(11),
2225 .freq_tbl = clk_tbl_spi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002226 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002227 .set_rate = set_rate_mnd,
2228 .c = {
2229 .dbg_name = "spi_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002230 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002231 VDD_DIG_FMAX_MAP1(NOMINAL, 26331429),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002232 CLK_INIT(spi_clk.c),
2233 },
2234};
2235
2236static struct clk_freq_tbl clk_tbl_lpa_codec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002237 F_RAW(1, NULL, 0, 0, 0, 0, NULL), /* src MI2S_CODEC_RX */
2238 F_RAW(2, NULL, 0, 1, 0, 0, NULL), /* src ECODEC_CIF */
2239 F_RAW(3, NULL, 0, 2, 0, 0, NULL), /* src MI2S */
2240 F_RAW(4, NULL, 0, 3, 0, 0, NULL), /* src SDAC */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002241 F_END,
2242};
2243
2244static struct rcg_clk lpa_codec_clk = {
2245 .b = {
2246 .ctl_reg = LPA_NS_REG,
2247 .en_mask = BIT(9),
2248 .halt_reg = CLK_HALT_STATEC_REG,
2249 .halt_bit = 6,
2250 .reset_mask = P_LPA_CODEC_CLK,
2251 },
2252 .ns_reg = LPA_NS_REG,
2253 .ns_mask = BM(1, 0),
2254 .set_rate = set_rate_nop,
2255 .freq_tbl = clk_tbl_lpa_codec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002256 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002257 .c = {
2258 .dbg_name = "lpa_codec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002259 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002260 VDD_DIG_FMAX_MAP1(LOW, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002261 CLK_INIT(lpa_codec_clk.c),
2262 },
2263};
2264
2265static struct clk_freq_tbl clk_tbl_mdc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002266 F_RAW(1, NULL, 0, 0, 0, 0, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002267 F_END
2268};
2269
2270static struct rcg_clk mdc_clk = {
2271 .b = {
2272 .ctl_reg = MDC_NS_REG,
2273 .en_mask = BIT(9),
2274 .halt_reg = CLK_HALT_STATEA_REG,
2275 .halt_bit = 10,
2276 .reset_mask = P_MDC_CLK,
2277 },
2278 .ns_reg = MDC_NS_REG,
2279 .root_en_mask = BIT(11),
2280 .freq_tbl = clk_tbl_mdc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002281 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002282 .set_rate = set_rate_nop,
2283 .c = {
2284 .dbg_name = "mdc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002285 .ops = &clk_ops_rcg_7x30,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002286 VDD_DIG_FMAX_MAP1(LOW, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002287 CLK_INIT(mdc_clk.c),
2288 },
2289};
2290
2291static struct branch_clk lpa_core_clk = {
2292 .b = {
2293 .ctl_reg = LPA_NS_REG,
2294 .en_mask = BIT(5),
2295 .halt_reg = CLK_HALT_STATEC_REG,
2296 .halt_bit = 5,
2297 .reset_mask = P_LPA_CORE_CLK,
2298 },
2299 .c = {
2300 .dbg_name = "lpa_core_clk",
2301 .ops = &clk_ops_branch,
2302 CLK_INIT(lpa_core_clk.c),
2303 },
2304};
2305
2306static DEFINE_CLK_PCOM(adsp_clk, ADSP_CLK, CLKFLAG_SKIP_AUTO_OFF);
2307static DEFINE_CLK_PCOM(codec_ssbi_clk, CODEC_SSBI_CLK, CLKFLAG_SKIP_AUTO_OFF);
2308static DEFINE_CLK_PCOM(ebi1_clk, EBI1_CLK, CLKFLAG_SKIP_AUTO_OFF | CLKFLAG_MIN);
2309static DEFINE_CLK_PCOM(ebi1_fixed_clk, EBI1_FIXED_CLK, CLKFLAG_MIN |
2310 CLKFLAG_SKIP_AUTO_OFF);
2311static DEFINE_CLK_PCOM(ecodec_clk, ECODEC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2312static DEFINE_CLK_PCOM(gp_clk, GP_CLK, CLKFLAG_SKIP_AUTO_OFF);
2313static DEFINE_CLK_PCOM(uart3_clk, UART3_CLK, 0);
2314static DEFINE_CLK_PCOM(usb_phy_clk, USB_PHY_CLK, CLKFLAG_MIN);
2315
2316static DEFINE_CLK_PCOM(p_grp_2d_clk, GRP_2D_CLK, CLKFLAG_SKIP_AUTO_OFF);
2317static DEFINE_CLK_PCOM(p_grp_2d_p_clk, GRP_2D_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2318static DEFINE_CLK_PCOM(p_hdmi_clk, HDMI_CLK, CLKFLAG_SKIP_AUTO_OFF);
Matt Wagantall2eedd222011-11-16 12:55:21 -08002319static DEFINE_CLK_PCOM(p_jpeg_clk, JPEG_CLK, CLKFLAG_MIN);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002320static DEFINE_CLK_PCOM(p_jpeg_p_clk, JPEG_P_CLK, 0);
2321static DEFINE_CLK_PCOM(p_lpa_codec_clk, LPA_CODEC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2322static DEFINE_CLK_PCOM(p_lpa_core_clk, LPA_CORE_CLK, CLKFLAG_SKIP_AUTO_OFF);
2323static DEFINE_CLK_PCOM(p_lpa_p_clk, LPA_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2324static DEFINE_CLK_PCOM(p_mi2s_m_clk, MI2S_M_CLK, CLKFLAG_SKIP_AUTO_OFF);
2325static DEFINE_CLK_PCOM(p_mi2s_s_clk, MI2S_S_CLK, CLKFLAG_SKIP_AUTO_OFF);
2326static DEFINE_CLK_PCOM(p_mi2s_codec_rx_m_clk, MI2S_CODEC_RX_M_CLK,
2327 CLKFLAG_SKIP_AUTO_OFF);
2328static DEFINE_CLK_PCOM(p_mi2s_codec_rx_s_clk, MI2S_CODEC_RX_S_CLK,
2329 CLKFLAG_SKIP_AUTO_OFF);
2330static DEFINE_CLK_PCOM(p_mi2s_codec_tx_m_clk, MI2S_CODEC_TX_M_CLK,
2331 CLKFLAG_SKIP_AUTO_OFF);
2332static DEFINE_CLK_PCOM(p_mi2s_codec_tx_s_clk, MI2S_CODEC_TX_S_CLK,
2333 CLKFLAG_SKIP_AUTO_OFF);
2334static DEFINE_CLK_PCOM(p_sdac_clk, SDAC_CLK, 0);
2335static DEFINE_CLK_PCOM(p_sdac_m_clk, SDAC_M_CLK, 0);
2336static DEFINE_CLK_PCOM(p_vfe_clk, VFE_CLK, CLKFLAG_SKIP_AUTO_OFF);
2337static DEFINE_CLK_PCOM(p_vfe_camif_clk, VFE_CAMIF_CLK, CLKFLAG_SKIP_AUTO_OFF);
2338static DEFINE_CLK_PCOM(p_vfe_mdc_clk, VFE_MDC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2339static DEFINE_CLK_PCOM(p_vfe_p_clk, VFE_P_CLK, 0);
2340static DEFINE_CLK_PCOM(p_grp_3d_clk, GRP_3D_CLK, CLKFLAG_SKIP_AUTO_OFF);
2341static DEFINE_CLK_PCOM(p_grp_3d_p_clk, GRP_3D_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2342static DEFINE_CLK_PCOM(p_imem_clk, IMEM_CLK, 0);
2343static DEFINE_CLK_PCOM(p_mdp_lcdc_pad_pclk_clk, MDP_LCDC_PAD_PCLK_CLK,
2344 CLKFLAG_SKIP_AUTO_OFF);
2345static DEFINE_CLK_PCOM(p_mdp_lcdc_pclk_clk, MDP_LCDC_PCLK_CLK,
2346 CLKFLAG_SKIP_AUTO_OFF);
2347static DEFINE_CLK_PCOM(p_mdp_p_clk, MDP_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2348static DEFINE_CLK_PCOM(p_mdp_vsync_clk, MDP_VSYNC_CLK, 0);
2349static DEFINE_CLK_PCOM(p_tsif_ref_clk, TSIF_REF_CLK, CLKFLAG_SKIP_AUTO_OFF);
2350static DEFINE_CLK_PCOM(p_tsif_p_clk, TSIF_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2351static DEFINE_CLK_PCOM(p_tv_dac_clk, TV_DAC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2352static DEFINE_CLK_PCOM(p_tv_enc_clk, TV_ENC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2353static DEFINE_CLK_PCOM(p_emdh_clk, EMDH_CLK, CLKFLAG_MIN | CLKFLAG_MAX);
2354static DEFINE_CLK_PCOM(p_emdh_p_clk, EMDH_P_CLK, 0);
2355static DEFINE_CLK_PCOM(p_i2c_clk, I2C_CLK, CLKFLAG_SKIP_AUTO_OFF);
2356static DEFINE_CLK_PCOM(p_i2c_2_clk, I2C_2_CLK, CLKFLAG_SKIP_AUTO_OFF);
2357static DEFINE_CLK_PCOM(p_mdc_clk, MDC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2358static DEFINE_CLK_PCOM(p_pmdh_clk, PMDH_CLK, CLKFLAG_MIN | CLKFLAG_MAX);
2359static DEFINE_CLK_PCOM(p_pmdh_p_clk, PMDH_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2360static DEFINE_CLK_PCOM(p_sdc1_clk, SDC1_CLK, 0);
2361static DEFINE_CLK_PCOM(p_sdc1_p_clk, SDC1_P_CLK, 0);
2362static DEFINE_CLK_PCOM(p_sdc2_clk, SDC2_CLK, 0);
2363static DEFINE_CLK_PCOM(p_sdc2_p_clk, SDC2_P_CLK, 0);
2364static DEFINE_CLK_PCOM(p_sdc3_clk, SDC3_CLK, 0);
2365static DEFINE_CLK_PCOM(p_sdc3_p_clk, SDC3_P_CLK, 0);
2366static DEFINE_CLK_PCOM(p_sdc4_clk, SDC4_CLK, 0);
2367static DEFINE_CLK_PCOM(p_sdc4_p_clk, SDC4_P_CLK, 0);
2368static DEFINE_CLK_PCOM(p_uart2_clk, UART2_CLK, CLKFLAG_SKIP_AUTO_OFF);
2369static DEFINE_CLK_PCOM(p_usb_hs2_clk, USB_HS2_CLK, 0);
2370static DEFINE_CLK_PCOM(p_usb_hs2_core_clk, USB_HS2_CORE_CLK, 0);
2371static DEFINE_CLK_PCOM(p_usb_hs2_p_clk, USB_HS2_P_CLK, 0);
2372static DEFINE_CLK_PCOM(p_usb_hs3_clk, USB_HS3_CLK, 0);
2373static DEFINE_CLK_PCOM(p_usb_hs3_core_clk, USB_HS3_CORE_CLK, 0);
2374static DEFINE_CLK_PCOM(p_usb_hs3_p_clk, USB_HS3_P_CLK, 0);
2375static DEFINE_CLK_PCOM(p_qup_i2c_clk, QUP_I2C_CLK, CLKFLAG_SKIP_AUTO_OFF);
2376static DEFINE_CLK_PCOM(p_spi_clk, SPI_CLK, CLKFLAG_SKIP_AUTO_OFF);
2377static DEFINE_CLK_PCOM(p_spi_p_clk, SPI_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2378static DEFINE_CLK_PCOM(p_uart1_clk, UART1_CLK, 0);
2379static DEFINE_CLK_PCOM(p_uart1dm_clk, UART1DM_CLK, 0);
2380static DEFINE_CLK_PCOM(p_uart2dm_clk, UART2DM_CLK, CLKFLAG_SKIP_AUTO_OFF);
2381static DEFINE_CLK_PCOM(p_usb_hs_clk, USB_HS_CLK, 0);
2382static DEFINE_CLK_PCOM(p_usb_hs_core_clk, USB_HS_CORE_CLK, 0);
2383static DEFINE_CLK_PCOM(p_usb_hs_p_clk, USB_HS_P_CLK, 0);
2384static DEFINE_CLK_PCOM(p_cam_m_clk, CAM_M_CLK, CLKFLAG_SKIP_AUTO_OFF);
2385static DEFINE_CLK_PCOM(p_camif_pad_p_clk, CAMIF_PAD_P_CLK, 0);
2386static DEFINE_CLK_PCOM(p_csi0_clk, CSI0_CLK, CLKFLAG_SKIP_AUTO_OFF);
2387static DEFINE_CLK_PCOM(p_csi0_vfe_clk, CSI0_VFE_CLK, CLKFLAG_SKIP_AUTO_OFF);
2388static DEFINE_CLK_PCOM(p_csi0_p_clk, CSI0_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
Matt Wagantalla12cc952011-11-08 18:14:50 -08002389static DEFINE_CLK_PCOM(p_mdp_clk, MDP_CLK, CLKFLAG_MIN);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002390static DEFINE_CLK_PCOM(p_mfc_clk, MFC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2391static DEFINE_CLK_PCOM(p_mfc_div2_clk, MFC_DIV2_CLK, CLKFLAG_SKIP_AUTO_OFF);
2392static DEFINE_CLK_PCOM(p_mfc_p_clk, MFC_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2393static DEFINE_CLK_PCOM(p_vpe_clk, VPE_CLK, CLKFLAG_SKIP_AUTO_OFF);
2394static DEFINE_CLK_PCOM(p_adm_clk, ADM_CLK, CLKFLAG_SKIP_AUTO_OFF);
2395static DEFINE_CLK_PCOM(p_ce_clk, CE_CLK, CLKFLAG_SKIP_AUTO_OFF);
2396static DEFINE_CLK_PCOM(p_axi_rotator_clk, AXI_ROTATOR_CLK,
2397 CLKFLAG_SKIP_AUTO_OFF);
2398static DEFINE_CLK_PCOM(p_rotator_imem_clk, ROTATOR_IMEM_CLK, 0);
2399static DEFINE_CLK_PCOM(p_rotator_p_clk, ROTATOR_P_CLK, 0);
2400
2401static DEFINE_CLK_VOTER(ebi_dtv_clk, &ebi1_fixed_clk.c);
Matt Wagantall9dc01632011-08-17 18:55:04 -07002402static DEFINE_CLK_VOTER(ebi_grp_3d_clk, &ebi1_fixed_clk.c);
2403static DEFINE_CLK_VOTER(ebi_grp_2d_clk, &ebi1_fixed_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002404static DEFINE_CLK_VOTER(ebi_lcdc_clk, &ebi1_fixed_clk.c);
2405static DEFINE_CLK_VOTER(ebi_mddi_clk, &ebi1_fixed_clk.c);
2406static DEFINE_CLK_VOTER(ebi_tv_clk, &ebi1_fixed_clk.c);
2407static DEFINE_CLK_VOTER(ebi_vcd_clk, &ebi1_fixed_clk.c);
2408static DEFINE_CLK_VOTER(ebi_vfe_clk, &ebi1_fixed_clk.c);
2409static DEFINE_CLK_VOTER(ebi_adm_clk, &ebi1_fixed_clk.c);
2410
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002411#ifdef CONFIG_DEBUG_FS
2412
2413#define CLK_TEST_2(s) (s)
2414#define CLK_TEST_HS(s) (0x4000 | ((s) << 8))
2415#define CLK_TEST_LS(s) (0x4D40 | (s))
2416
2417struct measure_sel {
2418 u32 test_vector;
2419 struct clk *clk;
2420};
2421
2422static struct measure_sel measure_mux[] = {
2423 { CLK_TEST_2(0x03), &emdh_p_clk.c },
2424 { CLK_TEST_2(0x04), &pmdh_p_clk.c },
2425 { CLK_TEST_2(0x06), &mdp_p_clk.c },
2426 { CLK_TEST_2(0x07), &lpa_p_clk.c },
2427 { CLK_TEST_2(0x08), &usb_hs2_p_clk.c },
2428 { CLK_TEST_2(0x09), &spi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002429 { CLK_TEST_2(0x0B), &i2c_2_clk.c },
2430 { CLK_TEST_2(0x0D), &mi2s_m_clk.c },
2431 { CLK_TEST_2(0x0E), &lpa_core_clk.c },
2432 { CLK_TEST_2(0x0F), &lpa_codec_clk.c },
2433 { CLK_TEST_2(0x10), &usb_hs3_p_clk.c },
2434 { CLK_TEST_2(0x11), &adm_p_clk.c },
2435 { CLK_TEST_2(0x13), &hdmi_clk.c },
2436 { CLK_TEST_2(0x14), &usb_hs_core_clk.c },
2437 { CLK_TEST_2(0x15), &usb_hs2_core_clk.c },
2438 { CLK_TEST_2(0x16), &usb_hs3_core_clk.c },
2439 { CLK_TEST_2(0x17), &mi2s_codec_tx_s_clk.c },
2440 { CLK_TEST_2(0x18), &spi_p_clk.c },
2441 { CLK_TEST_2(0x1A), &camif_pad_p_clk.c },
2442 { CLK_TEST_2(0x1C), &qup_i2c_clk.c },
2443 { CLK_TEST_2(0x1F), &mfc_div2_clk.c },
2444 { CLK_TEST_2(0x38), &mfc_clk.c },
2445
2446 { CLK_TEST_HS(0x00), &adm_clk.c },
2447 { CLK_TEST_HS(0x01), &mdp_lcdc_pad_pclk_clk.c },
2448 { CLK_TEST_HS(0x02), &mdp_lcdc_pclk_clk.c },
2449 { CLK_TEST_HS(0x03), &axi_rotator_clk.c },
2450 { CLK_TEST_HS(0x07), &axi_li_vg_clk.c },
2451 { CLK_TEST_HS(0x09), &axi_li_apps_clk.c },
2452 { CLK_TEST_HS(0x0E), &axi_li_jpeg_clk.c },
2453 { CLK_TEST_HS(0x0F), &emdh_clk.c },
2454 { CLK_TEST_HS(0x14), &mdp_clk.c },
2455 { CLK_TEST_HS(0x15), &pmdh_clk.c },
2456 { CLK_TEST_HS(0x19), &axi_grp_2d_clk.c },
2457 { CLK_TEST_HS(0x1A), &axi_li_grp_clk.c },
2458 { CLK_TEST_HS(0x1B), &axi_li_vfe_clk.c },
2459 { CLK_TEST_HS(0x1C), &grp_2d_clk.c },
2460 { CLK_TEST_HS(0x1E), &grp_3d_clk.c },
2461 { CLK_TEST_HS(0x1F), &imem_clk.c },
2462 { CLK_TEST_HS(0x20), &jpeg_clk.c },
2463 { CLK_TEST_HS(0x24), &axi_li_adsp_a_clk.c },
2464 { CLK_TEST_HS(0x26), &rotator_imem_clk.c },
2465 { CLK_TEST_HS(0x27), &axi_vpe_clk.c },
2466 { CLK_TEST_HS(0x2A), &axi_mfc_clk.c },
2467 { CLK_TEST_HS(0x2B), &axi_mdp_clk.c },
2468 { CLK_TEST_HS(0x2C), &vpe_clk.c },
2469 { CLK_TEST_HS(0x30), &vfe_camif_clk.c },
2470 { CLK_TEST_HS(0x31), &csi0_clk.c },
2471 { CLK_TEST_HS(0x32), &csi0_vfe_clk.c },
2472 { CLK_TEST_HS(0x33), &csi0_p_clk.c },
2473
2474 { CLK_TEST_LS(0x03), &ce_clk.c },
2475 { CLK_TEST_LS(0x04), &cam_m_clk.c },
2476 { CLK_TEST_LS(0x0C), &grp_2d_p_clk.c },
2477 { CLK_TEST_LS(0x0D), &i2c_clk.c },
2478 { CLK_TEST_LS(0x0E), &mi2s_codec_rx_m_clk.c },
2479 { CLK_TEST_LS(0x0F), &mi2s_codec_rx_s_clk.c },
2480 { CLK_TEST_LS(0x10), &mi2s_codec_tx_m_clk.c },
2481 { CLK_TEST_LS(0x13), &mdp_vsync_clk.c },
2482 { CLK_TEST_LS(0x15), &vfe_p_clk.c },
2483 { CLK_TEST_LS(0x16), &mdc_clk.c },
2484 { CLK_TEST_LS(0x17), &vfe_mdc_clk.c },
2485 { CLK_TEST_LS(0x18), &usb_hs_p_clk.c },
2486 { CLK_TEST_LS(0x1C), &uart1dm_p_clk.c },
2487 { CLK_TEST_LS(0x1E), &jpeg_p_clk.c },
2488 { CLK_TEST_LS(0x20), &sdac_clk.c },
2489 { CLK_TEST_LS(0x21), &sdc1_p_clk.c },
2490 { CLK_TEST_LS(0x22), &sdc1_clk.c },
2491 { CLK_TEST_LS(0x23), &sdc2_p_clk.c },
2492 { CLK_TEST_LS(0x24), &sdc2_clk.c },
2493 { CLK_TEST_LS(0x25), &tsif_p_clk.c },
2494 { CLK_TEST_LS(0x26), &sdac_m_clk.c },
2495 { CLK_TEST_LS(0x27), &grp_3d_p_clk.c },
2496 { CLK_TEST_LS(0x2A), &tsif_ref_clk.c },
2497 { CLK_TEST_LS(0x2B), &tv_enc_clk.c },
2498 { CLK_TEST_LS(0x2C), &tv_dac_clk.c },
2499 { CLK_TEST_LS(0x2D), &rotator_p_clk.c },
2500 { CLK_TEST_LS(0x2F), &uart1_clk.c },
2501 { CLK_TEST_LS(0x30), &uart1dm_clk.c },
2502 { CLK_TEST_LS(0x31), &uart2_clk.c },
2503 { CLK_TEST_LS(0x33), &usb_hs2_clk.c },
2504 { CLK_TEST_LS(0x34), &usb_hs3_clk.c },
2505 { CLK_TEST_LS(0x35), &mfc_p_clk.c },
2506 { CLK_TEST_LS(0x36), &vfe_clk.c },
2507 { CLK_TEST_LS(0x39), &sdc3_p_clk.c },
2508 { CLK_TEST_LS(0x3A), &sdc3_clk.c },
2509 { CLK_TEST_LS(0x3B), &sdc4_p_clk.c },
2510 { CLK_TEST_LS(0x3C), &sdc4_clk.c },
2511 { CLK_TEST_LS(0x3D), &uart2dm_clk.c },
2512 { CLK_TEST_LS(0x3E), &uart2dm_p_clk.c },
2513 { CLK_TEST_LS(0x3F), &usb_hs_clk.c },
2514};
2515
2516static struct measure_sel *find_measure_sel(struct clk *clk)
2517{
2518 int i;
2519
2520 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
2521 if (measure_mux[i].clk == clk)
2522 return &measure_mux[i];
2523 return NULL;
2524}
2525
2526static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
2527{
2528 struct measure_sel *p;
2529 unsigned long flags;
2530
2531 if (!parent)
2532 return -EINVAL;
2533
2534 p = find_measure_sel(parent);
2535 if (!p)
2536 return -EINVAL;
2537
2538 spin_lock_irqsave(&local_clock_reg_lock, flags);
2539
2540 /* Program test vector. */
2541 if (p->test_vector <= 0xFF) {
2542 /* Select CLK_TEST_2 */
2543 writel_relaxed(0x4D40, CLK_TEST_BASE_REG);
2544 writel_relaxed(p->test_vector, CLK_TEST_2_BASE_REG);
2545 } else
2546 writel_relaxed(p->test_vector, CLK_TEST_BASE_REG);
2547
2548 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2549
2550 return 0;
2551}
2552
2553/* Sample clock for 'tcxo4_ticks' reference clock ticks. */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002554static unsigned long run_measurement(unsigned tcxo4_ticks)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002555{
2556 /* TCXO4_CNT_EN and RINGOSC_CNT_EN register values. */
2557 u32 reg_val_enable = readl_relaxed(MISC_CLK_CTL_BASE_REG) | 0x3;
2558 u32 reg_val_disable = reg_val_enable & ~0x3;
2559
2560 /* Stop counters and set the TCXO4 counter start value. */
2561 writel_relaxed(reg_val_disable, MISC_CLK_CTL_BASE_REG);
2562 writel_relaxed(tcxo4_ticks, TCXO_CNT_BASE_REG);
2563
2564 /* Run measurement and wait for completion. */
2565 writel_relaxed(reg_val_enable, MISC_CLK_CTL_BASE_REG);
2566 while (readl_relaxed(TCXO_CNT_DONE_BASE_REG) == 0)
2567 cpu_relax();
2568
2569 /* Stop counters. */
2570 writel_relaxed(reg_val_disable, MISC_CLK_CTL_BASE_REG);
2571
2572 return readl_relaxed(RINGOSC_CNT_BASE_REG);
2573}
2574
2575/* Perform a hardware rate measurement for a given clock.
2576 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002577static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002578{
2579 unsigned long flags;
2580 u32 regval, prph_web_reg_old;
2581 u64 raw_count_short, raw_count_full;
2582 unsigned ret;
2583
2584 clk_enable(&tcxo_clk.c);
2585
2586 spin_lock_irqsave(&local_clock_reg_lock, flags);
2587
2588 /* Enable TCXO4 clock branch and root. */
2589 prph_web_reg_old = readl_relaxed(PRPH_WEB_NS_BASE_REG);
2590 regval = prph_web_reg_old | BIT(9) | BIT(11);
2591 writel_relaxed(regval, PRPH_WEB_NS_BASE_REG);
2592
2593 /*
2594 * The ring oscillator counter will not reset if the measured clock
2595 * is not running. To detect this, run a short measurement before
2596 * the full measurement. If the raw results of the two are the same
2597 * then the clock must be off.
2598 */
2599
2600 /* Run a short measurement. (~1 ms) */
2601 raw_count_short = run_measurement(0x1000);
2602 /* Run a full measurement. (~14 ms) */
2603 raw_count_full = run_measurement(0x10000);
2604
2605 /* Disable TCXO4 clock branch and root. */
2606 writel_relaxed(prph_web_reg_old, PRPH_WEB_NS_BASE_REG);
2607
2608 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2609
2610 /* Return 0 if the clock is off. */
2611 if (raw_count_full == raw_count_short)
2612 ret = 0;
2613 else {
2614 /* Compute rate in Hz. */
2615 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
2616 do_div(raw_count_full, ((0x10000 * 10) + 35));
2617 ret = raw_count_full;
2618 }
2619
2620 clk_disable(&tcxo_clk.c);
2621
2622 return ret;
2623}
2624#else /* !CONFIG_DEBUG_FS */
2625static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
2626{
2627 return -EINVAL;
2628}
2629
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002630static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002631{
2632 return 0;
2633}
2634#endif /* CONFIG_DEBUG_FS */
2635
2636static struct clk_ops measure_clk_ops = {
2637 .set_parent = measure_clk_set_parent,
2638 .get_rate = measure_clk_get_rate,
2639 .is_local = local_clk_is_local,
2640};
2641
2642static struct clk measure_clk = {
2643 .dbg_name = "measure_clk",
2644 .ops = &measure_clk_ops,
2645 CLK_INIT(measure_clk),
2646};
2647
2648/* Implementation for clk_set_flags(). */
2649int soc_clk_set_flags(struct clk *clk, unsigned clk_flags)
2650{
2651 uint32_t regval, ret = 0;
2652 unsigned long flags;
2653
2654 spin_lock_irqsave(&local_clock_reg_lock, flags);
2655
2656 if (clk == &vfe_clk.c) {
2657 regval = readl_relaxed(CAM_VFE_NS_REG);
2658 /* Flag values chosen for backward compatibility
2659 * with proc_comm remote clock control. */
2660 if (clk_flags == 0x00000100) {
2661 /* Select external source. */
2662 regval |= BIT(14);
2663 } else if (clk_flags == 0x00000200) {
2664 /* Select internal source. */
2665 regval &= ~BIT(14);
2666 } else
2667 ret = -EINVAL;
2668
2669 writel_relaxed(regval, CAM_VFE_NS_REG);
2670 /* Make sure write is issued before returning. */
2671 mb();
2672 } else
2673 ret = -EPERM;
2674
2675 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2676
2677 return ret;
2678}
2679
2680static int msm7x30_clk_reset(struct clk *clk, enum clk_reset_action action)
2681{
2682 /* reset_mask is actually a proc_comm id */
2683 unsigned id = to_rcg_clk(clk)->b.reset_mask;
2684 return pc_clk_reset(id, action);
2685}
2686
2687static int soc_branch_clk_reset(struct clk *clk, enum clk_reset_action action)
2688{
2689 unsigned id = to_branch_clk(clk)->b.reset_mask;
2690 return pc_clk_reset(id, action);
2691}
2692
2693/*
2694 * Clock ownership detection code
2695 */
2696
2697enum {
2698 SH2_OWN_GLBL,
2699 SH2_OWN_APPS1,
2700 SH2_OWN_APPS2,
2701 SH2_OWN_ROW1,
2702 SH2_OWN_ROW2,
2703 SH2_OWN_APPS3,
2704 NUM_OWNERSHIP
2705};
2706static __initdata uint32_t ownership_regs[NUM_OWNERSHIP];
2707
2708static void __init cache_ownership(void)
2709{
2710 ownership_regs[SH2_OWN_GLBL] = readl_relaxed(SH2_OWN_GLBL_BASE_REG);
2711 ownership_regs[SH2_OWN_APPS1] = readl_relaxed(SH2_OWN_APPS1_BASE_REG);
2712 ownership_regs[SH2_OWN_APPS2] = readl_relaxed(SH2_OWN_APPS2_BASE_REG);
2713 ownership_regs[SH2_OWN_ROW1] = readl_relaxed(SH2_OWN_ROW1_BASE_REG);
2714 ownership_regs[SH2_OWN_ROW2] = readl_relaxed(SH2_OWN_ROW2_BASE_REG);
2715 ownership_regs[SH2_OWN_APPS3] = readl_relaxed(SH2_OWN_APPS3_BASE_REG);
2716}
2717
2718static void __init print_ownership(void)
2719{
2720 pr_info("Clock ownership\n");
2721 pr_info(" GLBL : %08x\n", ownership_regs[SH2_OWN_GLBL]);
2722 pr_info(" APPS : %08x %08x %08x\n", ownership_regs[SH2_OWN_APPS1],
2723 ownership_regs[SH2_OWN_APPS2], ownership_regs[SH2_OWN_APPS3]);
2724 pr_info(" ROW : %08x %08x\n", ownership_regs[SH2_OWN_ROW1],
2725 ownership_regs[SH2_OWN_ROW2]);
2726}
2727
2728#define O(x) (&ownership_regs[(SH2_OWN_##x)])
2729#define OWN(r, b, name, clk, dev) \
2730 { \
2731 .lk = CLK_LOOKUP(name, clk.c, dev), \
2732 .remote = &p_##clk.c, \
2733 .reg = O(r), \
2734 .bit = BIT(b), \
2735 }
2736
2737static struct clk_local_ownership {
2738 struct clk_lookup lk;
2739 const u32 *reg;
2740 const u32 bit;
2741 struct clk *remote;
2742} ownership_map[] __initdata = {
2743 /* Sources */
2744 { CLK_LOOKUP("pll1_clk", pll1_clk.c, "acpu") },
2745 { CLK_LOOKUP("pll2_clk", pll2_clk.c, "acpu") },
2746 { CLK_LOOKUP("pll3_clk", pll3_clk.c, "acpu") },
2747 { CLK_LOOKUP("measure", measure_clk, "debug") },
2748
2749 /* PCOM */
2750 { CLK_LOOKUP("adsp_clk", adsp_clk.c, NULL) },
2751 { CLK_LOOKUP("codec_ssbi_clk", codec_ssbi_clk.c, NULL) },
2752 { CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL) },
2753 { CLK_LOOKUP("ebi1_fixed_clk", ebi1_fixed_clk.c, NULL) },
2754 { CLK_LOOKUP("ecodec_clk", ecodec_clk.c, NULL) },
Matt Wagantallb86ad262011-10-24 19:50:29 -07002755 { CLK_LOOKUP("core_clk", gp_clk.c, NULL) },
Matt Wagantalle2522372011-08-17 14:52:21 -07002756 { CLK_LOOKUP("core_clk", uart3_clk.c, "msm_serial.2") },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002757 { CLK_LOOKUP("usb_phy_clk", usb_phy_clk.c, NULL) },
2758
2759 /* Voters */
2760 { CLK_LOOKUP("ebi1_dtv_clk", ebi_dtv_clk.c, NULL) },
Matt Wagantall9dc01632011-08-17 18:55:04 -07002761 { CLK_LOOKUP("bus_clk", ebi_grp_2d_clk.c, "kgsl-2d0.0") },
2762 { CLK_LOOKUP("bus_clk", ebi_grp_3d_clk.c, "kgsl-3d0.0") },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002763 { CLK_LOOKUP("ebi1_lcdc_clk", ebi_lcdc_clk.c, NULL) },
2764 { CLK_LOOKUP("ebi1_mddi_clk", ebi_mddi_clk.c, NULL) },
2765 { CLK_LOOKUP("ebi1_tv_clk", ebi_tv_clk.c, NULL) },
Matt Wagantall3f7660b2011-08-17 21:25:13 -07002766 { CLK_LOOKUP("mem_clk", ebi_vcd_clk.c, "msm_vidc.0") },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002767 { CLK_LOOKUP("ebi1_vfe_clk", ebi_vfe_clk.c, NULL) },
Matt Wagantalle1a86062011-08-18 17:46:10 -07002768 { CLK_LOOKUP("mem_clk", ebi_adm_clk.c, "msm_dmov") },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002769
2770 /*
2771 * This is a many-to-one mapping because we don't know how the remote
2772 * clock code has decided to handle the dependencies between clocks for
2773 * a particular hardware block. We determine the ownership for all the
2774 * clocks going into a block by checking the ownership bit of one
2775 * register (usually the ns register).
2776 */
Matt Wagantall9dc01632011-08-17 18:55:04 -07002777 OWN(APPS1, 6, "core_clk", grp_2d_clk, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002778 OWN(APPS1, 6, "core_clk", grp_2d_clk, "footswitch-pcom.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07002779 OWN(APPS1, 6, "iface_clk", grp_2d_p_clk, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002780 OWN(APPS1, 6, "iface_clk", grp_2d_p_clk, "footswitch-pcom.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002781 OWN(APPS1, 31, "hdmi_clk", hdmi_clk, NULL),
2782 OWN(APPS1, 0, "jpeg_clk", jpeg_clk, NULL),
2783 OWN(APPS1, 0, "jpeg_pclk", jpeg_p_clk, NULL),
2784 OWN(APPS1, 23, "lpa_codec_clk", lpa_codec_clk, NULL),
2785 OWN(APPS1, 23, "lpa_core_clk", lpa_core_clk, NULL),
2786 OWN(APPS1, 23, "lpa_pclk", lpa_p_clk, NULL),
2787 OWN(APPS1, 28, "mi2s_m_clk", mi2s_m_clk, NULL),
2788 OWN(APPS1, 28, "mi2s_s_clk", mi2s_s_clk, NULL),
2789 OWN(APPS1, 12, "mi2s_codec_rx_m_clk", mi2s_codec_rx_m_clk, NULL),
2790 OWN(APPS1, 12, "mi2s_codec_rx_s_clk", mi2s_codec_rx_s_clk, NULL),
2791 OWN(APPS1, 14, "mi2s_codec_tx_m_clk", mi2s_codec_tx_m_clk, NULL),
2792 OWN(APPS1, 14, "mi2s_codec_tx_s_clk", mi2s_codec_tx_s_clk, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002793 OWN(APPS1, 26, "sdac_clk", sdac_clk, NULL),
2794 OWN(APPS1, 26, "sdac_m_clk", sdac_m_clk, NULL),
2795 OWN(APPS1, 8, "vfe_clk", vfe_clk, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07002796 OWN(APPS1, 8, "core_clk", vfe_clk, "footswitch-pcom.8"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002797 OWN(APPS1, 8, "vfe_camif_clk", vfe_camif_clk, NULL),
2798 OWN(APPS1, 8, "vfe_mdc_clk", vfe_mdc_clk, NULL),
2799 OWN(APPS1, 8, "vfe_pclk", vfe_p_clk, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07002800 OWN(APPS1, 8, "iface_clk", vfe_p_clk, "footswitch-pcom.8"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002801
Matt Wagantall9dc01632011-08-17 18:55:04 -07002802 OWN(APPS2, 0, "core_clk", grp_3d_clk, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002803 OWN(APPS2, 0, "core_clk", grp_3d_clk, "footswitch-pcom.2"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07002804 OWN(APPS2, 0, "iface_clk", grp_3d_p_clk, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002805 OWN(APPS2, 0, "iface_clk", grp_3d_p_clk, "footswitch-pcom.2"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07002806 { CLK_LOOKUP("src_clk", grp_3d_src_clk.c, "kgsl-3d0.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002807 O(APPS2), BIT(0), &p_grp_3d_clk.c },
Matt Wagantall49722712011-08-17 18:50:53 -07002808 { CLK_LOOKUP("src_clk", grp_3d_src_clk.c, "footswitch-pcom.2"),
2809 O(APPS2), BIT(0), &p_grp_3d_clk.c },
Matt Wagantall9dc01632011-08-17 18:55:04 -07002810 OWN(APPS2, 0, "mem_clk", imem_clk, "kgsl-3d0.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002811 OWN(APPS2, 4, "mdp_lcdc_pad_pclk_clk", mdp_lcdc_pad_pclk_clk, NULL),
2812 OWN(APPS2, 4, "mdp_lcdc_pclk_clk", mdp_lcdc_pclk_clk, NULL),
2813 OWN(APPS2, 4, "mdp_pclk", mdp_p_clk, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07002814 OWN(APPS2, 4, "iface_clk", mdp_p_clk, "footswitch-pcom.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002815 OWN(APPS2, 28, "mdp_vsync_clk", mdp_vsync_clk, NULL),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07002816 OWN(APPS2, 5, "ref_clk", tsif_ref_clk, "msm_tsif.0"),
2817 OWN(APPS2, 5, "iface_clk", tsif_p_clk, "msm_tsif.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002818 { CLK_LOOKUP("tv_src_clk", tv_clk.c, NULL),
2819 O(APPS2), BIT(2), &p_tv_enc_clk.c },
2820 OWN(APPS2, 2, "tv_dac_clk", tv_dac_clk, NULL),
2821 OWN(APPS2, 2, "tv_enc_clk", tv_enc_clk, NULL),
2822
2823 OWN(ROW1, 7, "emdh_clk", emdh_clk, "msm_mddi.1"),
2824 OWN(ROW1, 7, "emdh_pclk", emdh_p_clk, "msm_mddi.1"),
Matt Wagantallac294852011-08-17 15:44:58 -07002825 OWN(ROW1, 11, "core_clk", i2c_clk, "msm_i2c.0"),
2826 OWN(ROW1, 12, "core_clk", i2c_2_clk, "msm_i2c.2"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002827 OWN(ROW1, 17, "mdc_clk", mdc_clk, NULL),
2828 OWN(ROW1, 19, "mddi_clk", pmdh_clk, NULL),
2829 OWN(ROW1, 19, "mddi_pclk", pmdh_p_clk, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07002830 OWN(ROW1, 23, "core_clk", sdc1_clk, "msm_sdcc.1"),
2831 OWN(ROW1, 23, "iface_clk", sdc1_p_clk, "msm_sdcc.1"),
2832 OWN(ROW1, 25, "core_clk", sdc2_clk, "msm_sdcc.2"),
2833 OWN(ROW1, 25, "iface_clk", sdc2_p_clk, "msm_sdcc.2"),
2834 OWN(ROW1, 27, "core_clk", sdc3_clk, "msm_sdcc.3"),
2835 OWN(ROW1, 27, "iface_clk", sdc3_p_clk, "msm_sdcc.3"),
2836 OWN(ROW1, 29, "core_clk", sdc4_clk, "msm_sdcc.4"),
2837 OWN(ROW1, 29, "iface_clk", sdc4_p_clk, "msm_sdcc.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07002838 OWN(ROW1, 0, "core_clk", uart2_clk, "msm_serial.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002839 OWN(ROW1, 2, "usb_hs2_clk", usb_hs2_clk, NULL),
2840 OWN(ROW1, 2, "usb_hs2_core_clk", usb_hs2_core_clk, NULL),
2841 OWN(ROW1, 2, "usb_hs2_pclk", usb_hs2_p_clk, NULL),
2842 OWN(ROW1, 4, "usb_hs3_clk", usb_hs3_clk, NULL),
2843 OWN(ROW1, 4, "usb_hs3_core_clk", usb_hs3_core_clk, NULL),
2844 OWN(ROW1, 4, "usb_hs3_pclk", usb_hs3_p_clk, NULL),
2845
Matt Wagantallac294852011-08-17 15:44:58 -07002846 OWN(ROW2, 3, "core_clk", qup_i2c_clk, "qup_i2c.4"),
2847 OWN(ROW2, 1, "core_clk", spi_clk, "spi_qsd.0"),
2848 OWN(ROW2, 1, "iface_clk", spi_p_clk, "spi_qsd.0"),
Matt Wagantalle2522372011-08-17 14:52:21 -07002849 OWN(ROW2, 9, "core_clk", uart1_clk, "msm_serial.0"),
2850 OWN(ROW2, 6, "core_clk", uart1dm_clk, "msm_serial_hs.0"),
2851 OWN(ROW2, 8, "core_clk", uart2dm_clk, "msm_serial_hs.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002852 OWN(ROW2, 11, "usb_hs_clk", usb_hs_clk, NULL),
2853 OWN(ROW2, 11, "usb_hs_core_clk", usb_hs_core_clk, NULL),
2854 OWN(ROW2, 11, "usb_hs_pclk", usb_hs_p_clk, NULL),
2855
2856 OWN(APPS3, 6, "cam_m_clk", cam_m_clk, NULL),
2857 OWN(APPS3, 6, "camif_pad_pclk", camif_pad_p_clk, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07002858 OWN(APPS3, 6, "iface_clk", camif_pad_p_clk, "qup_i2c.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002859 OWN(APPS3, 11, "csi_clk", csi0_clk, NULL),
2860 OWN(APPS3, 11, "csi_vfe_clk", csi0_vfe_clk, NULL),
2861 OWN(APPS3, 11, "csi_pclk", csi0_p_clk, NULL),
2862 OWN(APPS3, 0, "mdp_clk", mdp_clk, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07002863 OWN(APPS3, 0, "core_clk", mdp_clk, "footswitch-pcom.4"),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07002864 OWN(APPS3, 2, "core_clk", mfc_clk, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002865 OWN(APPS3, 2, "core_clk", mfc_clk, "footswitch-pcom.5"),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07002866 OWN(APPS3, 2, "core_div2_clk", mfc_div2_clk, "msm_vidc.0"),
2867 OWN(APPS3, 2, "iface_clk", mfc_p_clk, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002868 OWN(APPS3, 2, "iface_clk", mfc_p_clk, "footswitch-pcom.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002869 OWN(APPS3, 4, "vpe_clk", vpe_clk, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07002870 OWN(APPS3, 4, "core_clk", vpe_clk, "footswitch-pcom.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002871
Matt Wagantalle1a86062011-08-18 17:46:10 -07002872 OWN(GLBL, 8, "core_clk", adm_clk, "msm_dmov"),
2873 { CLK_LOOKUP("iface_clk", adm_p_clk.c, "msm_dmov"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002874 O(GLBL), BIT(13), &dummy_clk },
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07002875 OWN(GLBL, 8, "core_clk", ce_clk, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07002876 OWN(GLBL, 8, "core_clk", ce_clk, "crypto.0"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07002877 OWN(GLBL, 13, "core_clk", axi_rotator_clk, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002878 OWN(GLBL, 13, "core_clk", axi_rotator_clk, "footswitch-pcom.6"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07002879 OWN(GLBL, 13, "mem_clk", rotator_imem_clk, "msm_rotator.0"),
2880 OWN(GLBL, 13, "iface_clk", rotator_p_clk, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002881 OWN(GLBL, 13, "iface_clk", rotator_p_clk, "footswitch-pcom.6"),
Matt Wagantalle2522372011-08-17 14:52:21 -07002882 { CLK_LOOKUP("iface_clk", uart1dm_p_clk.c, "msm_serial_hs.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002883 O(GLBL), BIT(8), &dummy_clk },
Matt Wagantalle2522372011-08-17 14:52:21 -07002884 { CLK_LOOKUP("iface_clk", uart2dm_p_clk.c, "msm_serial_hs.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002885 O(GLBL), BIT(8), &dummy_clk },
2886};
2887
2888static struct clk_lookup msm_clocks_7x30[ARRAY_SIZE(ownership_map)];
2889
2890static void __init set_clock_ownership(void)
2891{
2892 unsigned i;
2893 struct clk_lookup *lk;
2894
2895 for (i = 0; i < ARRAY_SIZE(ownership_map); i++) {
2896 const u32 *reg = ownership_map[i].reg;
2897 u32 bit = ownership_map[i].bit;
2898 struct clk *remote = ownership_map[i].remote;
2899
2900 lk = &ownership_map[i].lk;
2901 memcpy(&msm_clocks_7x30[i], lk, sizeof(*lk));
2902
2903 if (reg && !(*reg & bit))
2904 msm_clocks_7x30[i].clk = remote;
2905 }
2906}
2907
2908/*
2909 * Miscellaneous clock register initializations
2910 */
2911static const struct reg_init {
2912 const void __iomem *reg;
2913 uint32_t mask;
2914 uint32_t val;
2915} ri_list[] __initconst = {
2916 /* Enable UMDX_P clock. Known to causes issues, so never turn off. */
2917 {GLBL_CLK_ENA_2_SC_REG, BIT(2), BIT(2)},
2918
2919 /* Disable all the child clocks of USB_HS_SRC. */
2920 { USBH_NS_REG, BIT(13) | BIT(9), 0 },
2921 { USBH2_NS_REG, BIT(9) | BIT(4), 0 },
2922 { USBH3_NS_REG, BIT(9) | BIT(4), 0 },
2923
2924 {EMDH_NS_REG, BM(18, 17) , BVAL(18, 17, 0x3)}, /* RX div = div-4. */
2925 {PMDH_NS_REG, BM(18, 17), BVAL(18, 17, 0x3)}, /* RX div = div-4. */
2926 /* MI2S_CODEC_RX_S src = MI2S_CODEC_RX_M. */
2927 {MI2S_RX_NS_REG, BIT(14), 0x0},
2928 /* MI2S_CODEC_TX_S src = MI2S_CODEC_TX_M. */
2929 {MI2S_TX_NS_REG, BIT(14), 0x0},
2930 {MI2S_NS_REG, BIT(14), 0x0}, /* MI2S_S src = MI2S_M. */
2931 /* Allow DSP to decide the LPA CORE src. */
2932 {LPA_CORE_CLK_MA0_REG, BIT(0), BIT(0)},
2933 {LPA_CORE_CLK_MA2_REG, BIT(0), BIT(0)},
2934 {MI2S_CODEC_RX_DIV_REG, 0xF, 0xD}, /* MI2S_CODEC_RX_S div = div-8. */
2935 {MI2S_CODEC_TX_DIV_REG, 0xF, 0xD}, /* MI2S_CODEC_TX_S div = div-8. */
2936 {MI2S_DIV_REG, 0xF, 0x7}, /* MI2S_S div = div-8. */
2937 {MDC_NS_REG, 0x3, 0x3}, /* MDC src = external MDH src. */
2938 {SDAC_NS_REG, BM(15, 14), 0x0}, /* SDAC div = div-1. */
2939 /* Disable sources TCXO/5 & TCXO/6. UART1 src = TCXO*/
2940 {UART_NS_REG, BM(26, 25) | BM(2, 0), 0x0},
2941 /* HDMI div = div-1, non-inverted. tv_enc_src = tv_clk_src */
2942 {HDMI_NS_REG, 0x7, 0x0},
2943 {TV_NS_REG, BM(15, 14), 0x0}, /* tv_clk_src_div2 = div-1 */
2944
2945 /* USBH core clocks src = USB_HS_SRC. */
2946 {USBH_NS_REG, BIT(15), BIT(15)},
2947 {USBH2_NS_REG, BIT(6), BIT(6)},
2948 {USBH3_NS_REG, BIT(6), BIT(6)},
2949};
2950
2951/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07002952static void __init msm7x30_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002953{
2954 int i;
2955 uint32_t val;
2956
2957 cache_ownership();
2958 print_ownership();
2959 set_clock_ownership();
2960
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002961 /* When we have no local clock control, the rest of the code in this
2962 * function is a NOP since writes to shadow regions that we don't own
2963 * are ignored. */
2964
2965 clk_set_rate(&usb_hs_src_clk.c, clk_tbl_usb[1].freq_hz);
2966
2967 for (i = 0; i < ARRAY_SIZE(ri_list); i++) {
2968 val = readl_relaxed(ri_list[i].reg);
2969 val &= ~ri_list[i].mask;
2970 val |= ri_list[i].val;
2971 writel_relaxed(val, ri_list[i].reg);
2972 }
2973
2974 clk_set_rate(&i2c_clk.c, 19200000);
2975 clk_set_rate(&i2c_2_clk.c, 19200000);
2976 clk_set_rate(&qup_i2c_clk.c, 19200000);
2977 clk_set_rate(&uart1_clk.c, 19200000);
2978 clk_set_rate(&uart2_clk.c, 19200000);
2979 clk_set_rate(&mi2s_m_clk.c, 12288000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002980 clk_set_rate(&mdp_vsync_clk.c, 24576000);
2981 clk_set_rate(&glbl_root_clk.c, 1);
2982 clk_set_rate(&mdc_clk.c, 1);
2983 /* Sync the LPA_CODEC clock to MI2S_CODEC_RX */
2984 clk_set_rate(&lpa_codec_clk.c, 1);
2985 /* Sync the GRP2D clock to AXI */
2986 clk_set_rate(&grp_2d_clk.c, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002987}
2988
Stephen Boydbb600ae2011-08-02 20:11:40 -07002989struct clock_init_data msm7x30_clock_init_data __initdata = {
2990 .table = msm_clocks_7x30,
2991 .size = ARRAY_SIZE(msm_clocks_7x30),
2992 .init = msm7x30_clock_init,
2993};
2994
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002995/*
2996 * Clock operation handler registration
2997 */
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002998static struct clk_ops clk_ops_rcg_7x30 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -07002999 .enable = rcg_clk_enable,
3000 .disable = rcg_clk_disable,
Matt Wagantall41af0772011-09-17 12:21:39 -07003001 .auto_off = rcg_clk_disable,
Matt Wagantall0625ea02011-07-13 18:51:56 -07003002 .set_rate = rcg_clk_set_rate,
3003 .set_min_rate = rcg_clk_set_min_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -07003004 .get_rate = rcg_clk_get_rate,
3005 .list_rate = rcg_clk_list_rate,
3006 .is_enabled = rcg_clk_is_enabled,
3007 .round_rate = rcg_clk_round_rate,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003008 .reset = msm7x30_clk_reset,
3009 .set_flags = soc_clk_set_flags,
3010 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -07003011 .get_parent = rcg_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003012};
3013
3014static struct clk_ops clk_ops_branch = {
3015 .enable = branch_clk_enable,
3016 .disable = branch_clk_disable,
Matt Wagantall41af0772011-09-17 12:21:39 -07003017 .auto_off = branch_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003018 .is_enabled = branch_clk_is_enabled,
3019 .reset = soc_branch_clk_reset,
3020 .set_flags = soc_clk_set_flags,
3021 .is_local = local_clk_is_local,
3022 .get_parent = branch_clk_get_parent,
3023 .set_parent = branch_clk_set_parent,
3024};