blob: f51eb5bc3264599d87f5053411cb7941e7cc0978 [file] [log] [blame]
Manu Gautam5143b252012-01-05 19:25:23 -08001/* Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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"
Vikram Mulukutla681d8682012-03-09 23:56:20 -080034#include "clock-pll.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070035
36#define REG_BASE(off) (MSM_CLK_CTL_BASE + (off))
37#define REG(off) (MSM_CLK_CTL_SH2_BASE + (off))
38
39/* Shadow-region 2 (SH2) registers. */
40#define QUP_I2C_NS_REG REG(0x04F0)
41#define CAM_NS_REG REG(0x0374)
42#define CAM_VFE_NS_REG REG(0x0044)
43#define CLK_HALT_STATEA_REG REG(0x0108)
44#define CLK_HALT_STATEB_REG REG(0x010C)
45#define CLK_HALT_STATEC_REG REG(0x02D4)
46#define CSI_NS_REG REG(0x0174)
47#define EMDH_NS_REG REG(0x0050)
48#define GLBL_CLK_ENA_2_SC_REG REG(0x03C0)
49#define GLBL_CLK_ENA_SC_REG REG(0x03BC)
50#define GLBL_CLK_STATE_2_REG REG(0x037C)
51#define GLBL_CLK_STATE_REG REG(0x0004)
52#define GRP_2D_NS_REG REG(0x0034)
53#define GRP_NS_REG REG(0x0084)
54#define HDMI_NS_REG REG(0x0484)
55#define I2C_2_NS_REG REG(0x02D8)
56#define I2C_NS_REG REG(0x0068)
57#define JPEG_NS_REG REG(0x0164)
58#define LPA_CORE_CLK_MA0_REG REG(0x04F4)
59#define LPA_CORE_CLK_MA2_REG REG(0x04FC)
60#define LPA_NS_REG REG(0x02E8)
61#define MDC_NS_REG REG(0x007C)
62#define MDP_LCDC_NS_REG REG(0x0390)
63#define MDP_NS_REG REG(0x014C)
64#define MDP_VSYNC_REG REG(0x0460)
65#define MFC_NS_REG REG(0x0154)
66#define MI2S_CODEC_RX_DIV_REG REG(0x02EC)
67#define MI2S_CODEC_TX_DIV_REG REG(0x02F0)
68#define MI2S_DIV_REG REG(0x02E4)
69#define MI2S_NS_REG REG(0x02E0)
70#define MI2S_RX_NS_REG REG(0x0070)
71#define MI2S_TX_NS_REG REG(0x0078)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070072#define PLL_ENA_REG REG(0x0264)
73#define PMDH_NS_REG REG(0x008C)
74#define SDAC_NS_REG REG(0x009C)
75#define SDCn_NS_REG(n) REG(0x00A4+(0x8*((n)-1)))
76#define SPI_NS_REG REG(0x02C8)
77#define TSIF_NS_REG REG(0x00C4)
78#define TV_NS_REG REG(0x00CC)
79#define UART1DM_NS_REG REG(0x00D4)
80#define UART2DM_NS_REG REG(0x00DC)
81#define UART2_NS_REG REG(0x0464)
82#define UART_NS_REG REG(0x00E0)
83#define USBH2_NS_REG REG(0x046C)
84#define USBH3_NS_REG REG(0x0470)
85#define USBH_MD_REG REG(0x02BC)
86#define USBH_NS_REG REG(0x02C0)
87#define VPE_NS_REG REG(0x015C)
88
89/* Registers in the base (non-shadow) region. */
90#define CLK_TEST_BASE_REG REG_BASE(0x011C)
91#define CLK_TEST_2_BASE_REG REG_BASE(0x0384)
92#define MISC_CLK_CTL_BASE_REG REG_BASE(0x0110)
93#define PRPH_WEB_NS_BASE_REG REG_BASE(0x0080)
94#define PLL0_STATUS_BASE_REG REG_BASE(0x0318)
95#define PLL1_STATUS_BASE_REG REG_BASE(0x0334)
96#define PLL2_STATUS_BASE_REG REG_BASE(0x0350)
97#define PLL3_STATUS_BASE_REG REG_BASE(0x036C)
98#define PLL4_STATUS_BASE_REG REG_BASE(0x0254)
99#define PLL5_STATUS_BASE_REG REG_BASE(0x0258)
100#define PLL6_STATUS_BASE_REG REG_BASE(0x04EC)
101#define RINGOSC_CNT_BASE_REG REG_BASE(0x00FC)
102#define SH2_OWN_APPS1_BASE_REG REG_BASE(0x040C)
103#define SH2_OWN_APPS2_BASE_REG REG_BASE(0x0414)
104#define SH2_OWN_APPS3_BASE_REG REG_BASE(0x0444)
105#define SH2_OWN_GLBL_BASE_REG REG_BASE(0x0404)
106#define SH2_OWN_ROW1_BASE_REG REG_BASE(0x041C)
107#define SH2_OWN_ROW2_BASE_REG REG_BASE(0x0424)
108#define TCXO_CNT_BASE_REG REG_BASE(0x00F8)
109#define TCXO_CNT_DONE_BASE_REG REG_BASE(0x00F8)
110
111
112/* MUX source input identifiers. */
113#define SRC_SEL_pll0 4 /* Modem PLL */
114#define SRC_SEL_pll1 1 /* Global PLL */
115#define SRC_SEL_pll3 3 /* Multimedia/Peripheral PLL or Backup PLL1 */
116#define SRC_SEL_pll4 2 /* Display PLL */
117#define SRC_SEL_SDAC_lpxo 5 /* Low-power XO for SDAC */
118#define SRC_SEL_lpxo 6 /* Low-power XO */
119#define SRC_SEL_tcxo 0 /* Used for rates from TCXO */
120#define SRC_SEL_axi 0 /* Used for rates that sync to AXI */
121#define SRC_SEL_gnd 7 /* No clock */
122
123/* Clock declaration macros. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700124#define N8(msb, lsb, m, n) (BVAL(msb, lsb, ~(n-m)) | BVAL(6, 5, \
125 (MN_MODE_DUAL_EDGE * !!(n))))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700126#define N16(m, n) (BVAL(31, 16, ~(n-m)) | BVAL(6, 5, \
127 (MN_MODE_DUAL_EDGE * !!(n))))
128#define SPDIV(s, d) (BVAL(4, 3, d-1) | BVAL(2, 0, s))
129#define SDIV(s, d) (BVAL(6, 3, d-1) | BVAL(2, 0, s))
130#define F_MASK_BASIC (BM(6, 3)|BM(2, 0))
131#define F_MASK_MND16 (BM(31, 16)|BM(6, 5)|BM(4, 3)|BM(2, 0))
132#define F_MASK_MND8(m, l) (BM(m, l)|BM(6, 5)|BM(4, 3)|BM(2, 0))
133
134/*
135 * Clock frequency definitions and macros
136 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700137#define F_BASIC(f, s, div) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700138 { \
139 .freq_hz = f, \
140 .src_clk = &s##_clk.c, \
141 .ns_val = SDIV(SRC_SEL_##s, div), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700142 }
143
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700144#define F_MND16(f, s, div, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700145 { \
146 .freq_hz = f, \
147 .src_clk = &s##_clk.c, \
148 .md_val = MD16(m, n), \
149 .ns_val = N16(m, n) | SPDIV(SRC_SEL_##s, div), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150 }
151
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700152#define F_MND8(f, nmsb, nlsb, s, div, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153 { \
154 .freq_hz = f, \
155 .src_clk = &s##_clk.c, \
Stephen Boydd10d2642012-01-23 18:09:00 -0800156 .md_val = MD8(8, m, 0, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700157 .ns_val = N8(nmsb, nlsb, m, n) | SPDIV(SRC_SEL_##s, div), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700158 }
159
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700160enum vdd_dig_levels {
161 VDD_DIG_NONE,
162 VDD_DIG_LOW,
163 VDD_DIG_NOMINAL,
164 VDD_DIG_HIGH
165};
166
167static int set_vdd_dig(struct clk_vdd_class *vdd_class, int level)
168{
169 int rc, target_mv;
170
171 static const int mv[] = {
172 [VDD_DIG_NONE] = 1000,
173 [VDD_DIG_LOW] = 1000,
174 [VDD_DIG_NOMINAL] = 1100,
175 [VDD_DIG_HIGH] = 1200
176 };
177
178 target_mv = mv[level];
179 rc = msm_proc_comm(PCOM_CLKCTL_RPC_MIN_MSMC1, &target_mv, NULL);
180 if (rc)
181 return rc;
182 if (target_mv)
183 rc = -EINVAL;
184
185 return rc;
186}
187
188static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig);
189
190#define VDD_DIG_FMAX_MAP1(l1, f1) \
191 .vdd_class = &vdd_dig, \
192 .fmax[VDD_DIG_##l1] = (f1)
193#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
194 .vdd_class = &vdd_dig, \
195 .fmax[VDD_DIG_##l1] = (f1), \
196 .fmax[VDD_DIG_##l2] = (f2)
197
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700198#define PCOM_XO_DISABLE 0
199#define PCOM_XO_ENABLE 1
200#define PCOM_XO_TCXO 0
201#define PCOM_XO_LPXO 1
202
203static bool pcom_is_local(struct clk *clk)
204{
205 return false;
206}
207
208static int pcom_xo_enable(unsigned pcom_id, unsigned enable)
209{
210 /* TODO: Check return code in pcom_id */
211 return msm_proc_comm(PCOM_CLKCTL_RPC_SRC_REQUEST, &pcom_id, &enable);
212}
213
214static int tcxo_clk_enable(struct clk *clk)
215{
216 return pcom_xo_enable(PCOM_XO_TCXO, PCOM_XO_ENABLE);
217}
218
219static void tcxo_clk_disable(struct clk *clk)
220{
221 pcom_xo_enable(PCOM_XO_TCXO, PCOM_XO_DISABLE);
222}
223
224static struct clk_ops clk_ops_tcxo = {
225 .enable = tcxo_clk_enable,
226 .disable = tcxo_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700227 .is_local = pcom_is_local,
228};
229
230static struct fixed_clk tcxo_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700231 .c = {
232 .dbg_name = "tcxo_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800233 .rate = 19200000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700234 .ops = &clk_ops_tcxo,
235 CLK_INIT(tcxo_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800236 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700237 },
238};
239
240static int lpxo_clk_enable(struct clk *clk)
241{
242 return pcom_xo_enable(PCOM_XO_LPXO, PCOM_XO_ENABLE);
243}
244
245static void lpxo_clk_disable(struct clk *clk)
246{
247 pcom_xo_enable(PCOM_XO_LPXO, PCOM_XO_DISABLE);
248}
249
250static struct clk_ops clk_ops_lpxo = {
251 .enable = lpxo_clk_enable,
252 .disable = lpxo_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700253 .is_local = pcom_is_local,
254};
255
256static struct fixed_clk lpxo_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700257 .c = {
258 .dbg_name = "lpxo_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800259 .rate = 24576000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700260 .ops = &clk_ops_lpxo,
261 CLK_INIT(lpxo_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800262 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700263 },
264};
265
266static struct pll_vote_clk pll1_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700267 .en_reg = PLL_ENA_REG,
268 .en_mask = BIT(1),
269 .status_reg = PLL1_STATUS_BASE_REG,
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800270 .status_mask = BIT(16),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700271 .parent = &tcxo_clk.c,
272 .c = {
273 .dbg_name = "pll1_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800274 .rate = 768000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700275 .ops = &clk_ops_pll_vote,
276 CLK_INIT(pll1_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800277 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700278 },
279};
280
281static struct pll_vote_clk pll2_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700282 .en_reg = PLL_ENA_REG,
283 .en_mask = BIT(2),
284 .status_reg = PLL2_STATUS_BASE_REG,
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800285 .status_mask = BIT(16),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700286 .parent = &tcxo_clk.c,
287 .c = {
288 .dbg_name = "pll2_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800289 .rate = 806400000, /* TODO: Support scaling */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700290 .ops = &clk_ops_pll_vote,
291 CLK_INIT(pll2_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800292 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700293 },
294};
295
296static struct pll_vote_clk pll3_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700297 .en_reg = PLL_ENA_REG,
298 .en_mask = BIT(3),
299 .status_reg = PLL3_STATUS_BASE_REG,
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800300 .status_mask = BIT(16),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700301 .parent = &lpxo_clk.c,
302 .c = {
303 .dbg_name = "pll3_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800304 .rate = 737280000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700305 .ops = &clk_ops_pll_vote,
306 CLK_INIT(pll3_clk.c),
307 },
308};
309
310static struct pll_vote_clk pll4_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700311 .en_reg = PLL_ENA_REG,
312 .en_mask = BIT(4),
313 .status_reg = PLL4_STATUS_BASE_REG,
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800314 .status_mask = BIT(16),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700315 .parent = &lpxo_clk.c,
316 .c = {
317 .dbg_name = "pll4_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800318 .rate = 891000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700319 .ops = &clk_ops_pll_vote,
320 CLK_INIT(pll4_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800321 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700322 },
323};
324
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700325static struct clk_freq_tbl clk_tbl_axi[] = {
Matt Wagantall07c45472012-02-10 23:27:24 -0800326 F_RAW(1, &lpxo_clk.c, 0, 0, 0, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700327 F_END,
328};
329
330/* For global clocks to be on we must have GLBL_ROOT_ENA set */
331static struct rcg_clk glbl_root_clk = {
332 .b = {
333 .ctl_reg = GLBL_CLK_ENA_SC_REG,
334 .en_mask = BIT(29),
335 .halt_check = NOCHECK,
336 },
337 .freq_tbl = clk_tbl_axi,
338 .set_rate = set_rate_nop,
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700339 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700340 .set_rate = set_rate_nop,
341 .c = {
342 .dbg_name = "glbl_root_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -0700343 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700344 VDD_DIG_FMAX_MAP1(NOMINAL, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700345 CLK_INIT(glbl_root_clk.c),
346 },
347};
348
349/* AXI bridge clocks. */
350static struct branch_clk axi_li_apps_clk = {
351 .b = {
352 .ctl_reg = GLBL_CLK_ENA_SC_REG,
353 .en_mask = BIT(2),
354 .halt_reg = GLBL_CLK_STATE_REG,
355 .halt_check = HALT_VOTED,
356 .halt_bit = 2,
357 },
358 .parent = &glbl_root_clk.c,
359 .c = {
360 .dbg_name = "axi_li_apps_clk",
361 .ops = &clk_ops_branch,
362 CLK_INIT(axi_li_apps_clk.c),
363 },
364};
365
366static struct branch_clk axi_li_adsp_a_clk = {
367 .b = {
368 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
369 .en_mask = BIT(14),
370 .halt_reg = GLBL_CLK_STATE_2_REG,
371 .halt_check = HALT_VOTED,
372 .halt_bit = 14,
373 },
374 .parent = &axi_li_apps_clk.c,
375 .c = {
376 .dbg_name = "axi_li_adsp_a_clk",
377 .ops = &clk_ops_branch,
378 CLK_INIT(axi_li_adsp_a_clk.c),
379 },
380};
381
382static struct branch_clk axi_li_jpeg_clk = {
383 .b = {
384 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
385 .en_mask = BIT(19),
386 .halt_reg = GLBL_CLK_STATE_2_REG,
387 .halt_check = HALT_VOTED,
388 .halt_bit = 19,
389 },
390 .parent = &axi_li_apps_clk.c,
391 .c = {
392 .dbg_name = "axi_li_jpeg_clk",
393 .ops = &clk_ops_branch,
394 CLK_INIT(axi_li_jpeg_clk.c),
395 },
396};
397
398static struct branch_clk axi_li_vfe_clk = {
399 .b = {
400 .ctl_reg = GLBL_CLK_ENA_SC_REG,
401 .en_mask = BIT(23),
402 .halt_reg = GLBL_CLK_STATE_REG,
403 .halt_check = HALT_VOTED,
404 .halt_bit = 23,
405 },
406 .parent = &axi_li_apps_clk.c,
407 .c = {
408 .dbg_name = "axi_li_vfe_clk",
409 .ops = &clk_ops_branch,
410 CLK_INIT(axi_li_vfe_clk.c),
411 },
412};
413
414static struct branch_clk axi_mdp_clk = {
415 .b = {
416 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
417 .en_mask = BIT(29),
418 .halt_reg = GLBL_CLK_STATE_2_REG,
419 .halt_check = HALT_VOTED,
420 .halt_bit = 29,
421 },
422 .parent = &axi_li_apps_clk.c,
423 .c = {
424 .dbg_name = "axi_mdp_clk",
425 .ops = &clk_ops_branch,
426 CLK_INIT(axi_mdp_clk.c),
427 },
428};
429
430static struct branch_clk axi_li_vg_clk = {
431 .b = {
432 .ctl_reg = GLBL_CLK_ENA_SC_REG,
433 .en_mask = BIT(3),
434 .halt_reg = GLBL_CLK_STATE_REG,
435 .halt_check = HALT_VOTED,
436 .halt_bit = 3,
437 },
438 .parent = &glbl_root_clk.c,
439 .c = {
440 .dbg_name = "axi_li_vg_clk",
441 .ops = &clk_ops_branch,
442 CLK_INIT(axi_li_vg_clk.c),
443 },
444};
445
446static struct branch_clk axi_grp_2d_clk = {
447 .b = {
448 .ctl_reg = GLBL_CLK_ENA_SC_REG,
449 .en_mask = BIT(21),
450 .halt_reg = GLBL_CLK_STATE_REG,
451 .halt_check = HALT_VOTED,
452 .halt_bit = 21,
453 },
454 .parent = &axi_li_vg_clk.c,
455 .c = {
456 .dbg_name = "axi_grp_2d_clk",
457 .ops = &clk_ops_branch,
458 CLK_INIT(axi_grp_2d_clk.c),
459 },
460};
461
462static struct branch_clk axi_li_grp_clk = {
463 .b = {
464 .ctl_reg = GLBL_CLK_ENA_SC_REG,
465 .en_mask = BIT(22),
466 .halt_reg = GLBL_CLK_STATE_REG,
467 .halt_check = HALT_VOTED,
468 .halt_bit = 22,
469 },
470 .parent = &axi_li_vg_clk.c,
471 .c = {
472 .dbg_name = "axi_li_grp_clk",
473 .ops = &clk_ops_branch,
474 CLK_INIT(axi_li_grp_clk.c),
475 },
476};
477
478static struct branch_clk axi_mfc_clk = {
479 .b = {
480 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
481 .en_mask = BIT(20),
482 .halt_reg = GLBL_CLK_STATE_2_REG,
483 .halt_check = HALT_VOTED,
484 .halt_bit = 20,
485 },
486 .parent = &axi_li_vg_clk.c,
487 .c = {
488 .dbg_name = "axi_mfc_clk",
489 .ops = &clk_ops_branch,
490 CLK_INIT(axi_mfc_clk.c),
491 },
492};
493
494static struct branch_clk axi_rotator_clk = {
495 .b = {
496 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
497 .en_mask = BIT(22),
498 .halt_reg = GLBL_CLK_STATE_2_REG,
499 .halt_check = HALT_VOTED,
500 .halt_bit = 22,
501 .reset_mask = P_AXI_ROTATOR_CLK,
502 },
503 .parent = &axi_li_vg_clk.c,
504 .c = {
505 .dbg_name = "axi_rotator_clk",
506 .ops = &clk_ops_branch,
507 CLK_INIT(axi_rotator_clk.c),
508 },
509};
510
511static struct branch_clk axi_vpe_clk = {
512 .b = {
513 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
514 .en_mask = BIT(21),
515 .halt_reg = GLBL_CLK_STATE_2_REG,
516 .halt_check = HALT_VOTED,
517 .halt_bit = 21,
518 },
519 .parent = &axi_li_vg_clk.c,
520 .c = {
521 .dbg_name = "axi_vpe_clk",
522 .ops = &clk_ops_branch,
523 CLK_INIT(axi_vpe_clk.c),
524 },
525};
526
527/* Peripheral bus clocks. */
528static struct branch_clk adm_clk = {
529 .b = {
530 .ctl_reg = GLBL_CLK_ENA_SC_REG,
531 .en_mask = BIT(5),
532 .halt_reg = GLBL_CLK_STATE_REG,
533 .halt_check = HALT_VOTED,
534 .halt_bit = 5,
535 .reset_mask = P_ADM_CLK,
536 },
537 .parent = &axi_li_apps_clk.c,
538 .c = {
539 .dbg_name = "adm_clk",
540 .ops = &clk_ops_branch,
541 CLK_INIT(adm_clk.c),
542 },
543};
544
545static struct branch_clk adm_p_clk = {
546 .b = {
547 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
548 .en_mask = BIT(15),
549 .halt_reg = GLBL_CLK_STATE_2_REG,
550 .halt_check = HALT_VOTED,
551 .halt_bit = 15,
552 },
553 .parent = &glbl_root_clk.c,
554 .c = {
555 .dbg_name = "adm_p_clk",
556 .ops = &clk_ops_branch,
557 CLK_INIT(adm_p_clk.c),
558 },
559};
560
561static struct branch_clk ce_clk = {
562 .b = {
563 .ctl_reg = GLBL_CLK_ENA_SC_REG,
564 .en_mask = BIT(6),
565 .halt_reg = GLBL_CLK_STATE_REG,
566 .halt_check = HALT_VOTED,
567 .halt_bit = 6,
568 .reset_mask = P_CE_CLK,
569 },
570 .parent = &glbl_root_clk.c,
571 .c = {
572 .dbg_name = "ce_clk",
573 .ops = &clk_ops_branch,
574 CLK_INIT(ce_clk.c),
575 },
576};
577
578static struct branch_clk camif_pad_p_clk = {
579 .b = {
580 .ctl_reg = GLBL_CLK_ENA_SC_REG,
581 .en_mask = BIT(9),
582 .halt_reg = GLBL_CLK_STATE_REG,
583 .halt_check = HALT_VOTED,
584 .halt_bit = 9,
585 .reset_mask = P_CAMIF_PAD_P_CLK,
586 },
587 .parent = &glbl_root_clk.c,
588 .c = {
589 .dbg_name = "camif_pad_p_clk",
590 .ops = &clk_ops_branch,
591 CLK_INIT(camif_pad_p_clk.c),
592 },
593};
594
595static struct branch_clk csi0_p_clk = {
596 .b = {
597 .ctl_reg = GLBL_CLK_ENA_SC_REG,
598 .en_mask = BIT(30),
599 .halt_reg = GLBL_CLK_STATE_REG,
600 .halt_check = HALT_VOTED,
601 .halt_bit = 30,
602 .reset_mask = P_CSI0_P_CLK,
603 },
604 .parent = &glbl_root_clk.c,
605 .c = {
606 .dbg_name = "csi0_p_clk",
607 .ops = &clk_ops_branch,
608 CLK_INIT(csi0_p_clk.c),
609 },
610};
611
612static struct branch_clk emdh_p_clk = {
613 .b = {
614 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
615 .en_mask = BIT(3),
616 .halt_reg = GLBL_CLK_STATE_2_REG,
617 .halt_check = HALT_VOTED,
618 .halt_bit = 3,
619 .reset_mask = P_EMDH_P_CLK,
620 },
621 .parent = &glbl_root_clk.c,
622 .c = {
623 .dbg_name = "emdh_p_clk",
624 .ops = &clk_ops_branch,
625 CLK_INIT(emdh_p_clk.c),
626 },
627};
628
629static struct branch_clk grp_2d_p_clk = {
630 .b = {
631 .ctl_reg = GLBL_CLK_ENA_SC_REG,
632 .en_mask = BIT(24),
633 .halt_reg = GLBL_CLK_STATE_REG,
634 .halt_check = HALT_VOTED,
635 .halt_bit = 24,
636 .reset_mask = P_GRP_2D_P_CLK,
637 },
638 .parent = &glbl_root_clk.c,
639 .c = {
640 .dbg_name = "grp_2d_p_clk",
641 .ops = &clk_ops_branch,
642 CLK_INIT(grp_2d_p_clk.c),
643 },
644};
645
646static struct branch_clk grp_3d_p_clk = {
647 .b = {
648 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
649 .en_mask = BIT(17),
650 .halt_reg = GLBL_CLK_STATE_2_REG,
651 .halt_check = HALT_VOTED,
652 .halt_bit = 17,
653 .reset_mask = P_GRP_3D_P_CLK,
654 },
655 .parent = &glbl_root_clk.c,
656 .c = {
657 .dbg_name = "grp_3d_p_clk",
658 .ops = &clk_ops_branch,
659 CLK_INIT(grp_3d_p_clk.c),
660 },
661};
662
663static struct branch_clk jpeg_p_clk = {
664 .b = {
665 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
666 .en_mask = BIT(24),
667 .halt_reg = GLBL_CLK_STATE_2_REG,
668 .halt_check = HALT_VOTED,
669 .halt_bit = 24,
670 .reset_mask = P_JPEG_P_CLK,
671 },
672 .parent = &glbl_root_clk.c,
673 .c = {
674 .dbg_name = "jpeg_p_clk",
675 .ops = &clk_ops_branch,
676 CLK_INIT(jpeg_p_clk.c),
677 },
678};
679
680static struct branch_clk lpa_p_clk = {
681 .b = {
682 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
683 .en_mask = BIT(7),
684 .halt_reg = GLBL_CLK_STATE_2_REG,
685 .halt_check = HALT_VOTED,
686 .halt_bit = 7,
687 .reset_mask = P_LPA_P_CLK,
688 },
689 .parent = &glbl_root_clk.c,
690 .c = {
691 .dbg_name = "lpa_p_clk",
692 .ops = &clk_ops_branch,
693 CLK_INIT(lpa_p_clk.c),
694 },
695};
696
697static struct branch_clk mdp_p_clk = {
698 .b = {
699 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
700 .en_mask = BIT(6),
701 .halt_reg = GLBL_CLK_STATE_2_REG,
702 .halt_check = HALT_VOTED,
703 .halt_bit = 6,
704 .reset_mask = P_MDP_P_CLK,
705 },
706 .parent = &glbl_root_clk.c,
707 .c = {
708 .dbg_name = "mdp_p_clk",
709 .ops = &clk_ops_branch,
710 CLK_INIT(mdp_p_clk.c),
711 },
712};
713
714static struct branch_clk mfc_p_clk = {
715 .b = {
716 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
717 .en_mask = BIT(26),
718 .halt_reg = GLBL_CLK_STATE_2_REG,
719 .halt_check = HALT_VOTED,
720 .halt_bit = 26,
721 .reset_mask = P_MFC_P_CLK,
722 },
723 .parent = &glbl_root_clk.c,
724 .c = {
725 .dbg_name = "mfc_p_clk",
726 .ops = &clk_ops_branch,
727 CLK_INIT(mfc_p_clk.c),
728 },
729};
730
731static struct branch_clk pmdh_p_clk = {
732 .b = {
733 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
734 .en_mask = BIT(4),
735 .halt_reg = GLBL_CLK_STATE_2_REG,
736 .halt_check = HALT_VOTED,
737 .halt_bit = 4,
738 .reset_mask = P_PMDH_P_CLK,
739 },
740 .parent = &glbl_root_clk.c,
741 .c = {
742 .dbg_name = "pmdh_p_clk",
743 .ops = &clk_ops_branch,
744 CLK_INIT(pmdh_p_clk.c),
745 },
746};
747
748static struct branch_clk rotator_imem_clk = {
749 .b = {
750 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
751 .en_mask = BIT(23),
752 .halt_reg = GLBL_CLK_STATE_2_REG,
753 .halt_check = HALT_VOTED,
754 .halt_bit = 23,
755 .reset_mask = P_ROTATOR_IMEM_CLK,
756 },
757 .parent = &glbl_root_clk.c,
758 .c = {
759 .dbg_name = "rotator_imem_clk",
760 .ops = &clk_ops_branch,
761 CLK_INIT(rotator_imem_clk.c),
762 },
763};
764
765static struct branch_clk rotator_p_clk = {
766 .b = {
767 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
768 .en_mask = BIT(25),
769 .halt_reg = GLBL_CLK_STATE_2_REG,
770 .halt_check = HALT_VOTED,
771 .halt_bit = 25,
772 .reset_mask = P_ROTATOR_P_CLK,
773 },
774 .parent = &glbl_root_clk.c,
775 .c = {
776 .dbg_name = "rotator_p_clk",
777 .ops = &clk_ops_branch,
778 CLK_INIT(rotator_p_clk.c),
779 },
780};
781
782static struct branch_clk sdc1_p_clk = {
783 .b = {
784 .ctl_reg = GLBL_CLK_ENA_SC_REG,
785 .en_mask = BIT(7),
786 .halt_reg = GLBL_CLK_STATE_REG,
787 .halt_check = HALT_VOTED,
788 .halt_bit = 7,
789 .reset_mask = P_SDC1_P_CLK,
790 },
791 .parent = &glbl_root_clk.c,
792 .c = {
793 .dbg_name = "sdc1_p_clk",
794 .ops = &clk_ops_branch,
795 CLK_INIT(sdc1_p_clk.c),
796 },
797};
798
799static struct branch_clk sdc2_p_clk = {
800 .b = {
801 .ctl_reg = GLBL_CLK_ENA_SC_REG,
802 .en_mask = BIT(8),
803 .halt_reg = GLBL_CLK_STATE_REG,
804 .halt_check = HALT_VOTED,
805 .halt_bit = 8,
806 .reset_mask = P_SDC2_P_CLK,
807 },
808 .parent = &glbl_root_clk.c,
809 .c = {
810 .dbg_name = "sdc2_p_clk",
811 .ops = &clk_ops_branch,
812 CLK_INIT(sdc2_p_clk.c),
813 },
814};
815
816static struct branch_clk sdc3_p_clk = {
817 .b = {
818 .ctl_reg = GLBL_CLK_ENA_SC_REG,
819 .en_mask = BIT(27),
820 .halt_reg = GLBL_CLK_STATE_REG,
821 .halt_check = HALT_VOTED,
822 .halt_bit = 27,
823 .reset_mask = P_SDC3_P_CLK,
824 },
825 .parent = &glbl_root_clk.c,
826 .c = {
827 .dbg_name = "sdc3_p_clk",
828 .ops = &clk_ops_branch,
829 CLK_INIT(sdc3_p_clk.c),
830 },
831};
832
833static struct branch_clk sdc4_p_clk = {
834 .b = {
835 .ctl_reg = GLBL_CLK_ENA_SC_REG,
836 .en_mask = BIT(28),
837 .halt_reg = GLBL_CLK_STATE_REG,
838 .halt_check = HALT_VOTED,
839 .halt_bit = 28,
840 .reset_mask = P_SDC4_P_CLK,
841 },
842 .parent = &glbl_root_clk.c,
843 .c = {
844 .dbg_name = "sdc4_p_clk",
845 .ops = &clk_ops_branch,
846 CLK_INIT(sdc4_p_clk.c),
847 },
848};
849
850static struct branch_clk spi_p_clk = {
851 .b = {
852 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
853 .en_mask = BIT(10),
854 .halt_reg = GLBL_CLK_STATE_2_REG,
855 .halt_check = HALT_VOTED,
856 .halt_bit = 10,
857 .reset_mask = P_SPI_P_CLK,
858 },
859 .parent = &glbl_root_clk.c,
860 .c = {
861 .dbg_name = "spi_p_clk",
862 .ops = &clk_ops_branch,
863 CLK_INIT(spi_p_clk.c),
864 },
865};
866
867static struct branch_clk tsif_p_clk = {
868 .b = {
869 .ctl_reg = GLBL_CLK_ENA_SC_REG,
870 .en_mask = BIT(18),
871 .halt_reg = GLBL_CLK_STATE_REG,
872 .halt_check = HALT_VOTED,
873 .halt_bit = 18,
874 .reset_mask = P_TSIF_P_CLK,
875 },
876 .parent = &glbl_root_clk.c,
877 .c = {
878 .dbg_name = "tsif_p_clk",
879 .ops = &clk_ops_branch,
880 CLK_INIT(tsif_p_clk.c),
881 },
882};
883
884static struct branch_clk uart1dm_p_clk = {
885 .b = {
886 .ctl_reg = GLBL_CLK_ENA_SC_REG,
887 .en_mask = BIT(17),
888 .halt_reg = GLBL_CLK_STATE_REG,
889 .halt_check = HALT_VOTED,
890 .halt_bit = 17,
891 },
892 .parent = &glbl_root_clk.c,
893 .c = {
894 .dbg_name = "uart1dm_p_clk",
895 .ops = &clk_ops_branch,
896 CLK_INIT(uart1dm_p_clk.c),
897 },
898};
899
900static struct branch_clk uart2dm_p_clk = {
901 .b = {
902 .ctl_reg = GLBL_CLK_ENA_SC_REG,
903 .en_mask = BIT(26),
904 .halt_reg = GLBL_CLK_STATE_REG,
905 .halt_check = HALT_VOTED,
906 .halt_bit = 26,
907 },
908 .parent = &glbl_root_clk.c,
909 .c = {
910 .dbg_name = "uart2dm_p_clk",
911 .ops = &clk_ops_branch,
912 CLK_INIT(uart2dm_p_clk.c),
913 },
914};
915
916static struct branch_clk usb_hs2_p_clk = {
917 .b = {
918 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
919 .en_mask = BIT(8),
920 .halt_reg = GLBL_CLK_STATE_2_REG,
921 .halt_check = HALT_VOTED,
922 .halt_bit = 8,
923 .reset_mask = P_USB_HS2_P_CLK,
924 },
925 .parent = &glbl_root_clk.c,
926 .c = {
927 .dbg_name = "usb_hs2_p_clk",
928 .ops = &clk_ops_branch,
929 CLK_INIT(usb_hs2_p_clk.c),
930 },
931};
932
933static struct branch_clk usb_hs3_p_clk = {
934 .b = {
935 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
936 .en_mask = BIT(9),
937 .halt_reg = GLBL_CLK_STATE_2_REG,
938 .halt_check = HALT_VOTED,
939 .halt_bit = 9,
940 .reset_mask = P_USB_HS3_P_CLK,
941 },
942 .parent = &glbl_root_clk.c,
943 .c = {
944 .dbg_name = "usb_hs3_p_clk",
945 .ops = &clk_ops_branch,
946 CLK_INIT(usb_hs3_p_clk.c),
947 },
948};
949
950static struct branch_clk usb_hs_p_clk = {
951 .b = {
952 .ctl_reg = GLBL_CLK_ENA_SC_REG,
953 .en_mask = BIT(25),
954 .halt_reg = GLBL_CLK_STATE_REG,
955 .halt_check = HALT_VOTED,
956 .halt_bit = 25,
957 .reset_mask = P_USB_HS_P_CLK,
958 },
959 .parent = &glbl_root_clk.c,
960 .c = {
961 .dbg_name = "usb_hs_p_clk",
962 .ops = &clk_ops_branch,
963 CLK_INIT(usb_hs_p_clk.c),
964 },
965};
966
967static struct branch_clk vfe_p_clk = {
968 .b = {
969 .ctl_reg = GLBL_CLK_ENA_2_SC_REG,
970 .en_mask = BIT(27),
971 .halt_reg = GLBL_CLK_STATE_2_REG,
972 .halt_check = HALT_VOTED,
973 .halt_bit = 27,
974 .reset_mask = P_VFE_P_CLK,
975 },
976 .parent = &glbl_root_clk.c,
977 .c = {
978 .dbg_name = "vfe_p_clk",
979 .ops = &clk_ops_branch,
980 CLK_INIT(vfe_p_clk.c),
981 },
982};
983
984static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700985 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
986 F_MND8(153600000, 24, 17, pll1, 2, 2, 5),
987 F_MND8(192000000, 24, 17, pll1, 4, 0, 0),
988 F_MND8(384000000, 24, 17, pll1, 2, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700989 F_END,
990};
991
992static struct rcg_clk csi0_clk = {
993 .b = {
994 .ctl_reg = CSI_NS_REG,
995 .en_mask = BIT(9),
996 .halt_reg = CLK_HALT_STATEC_REG,
997 .halt_bit = 17,
998 .reset_mask = P_CSI0_CLK,
999 },
1000 .ns_reg = CSI_NS_REG,
1001 .md_reg = CSI_NS_REG - 4,
1002 .ns_mask = F_MASK_MND8(24, 17),
Matt Wagantall07c45472012-02-10 23:27:24 -08001003 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001004 .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",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001010 .ops = &clk_ops_rcg,
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 Wagantall07c45472012-02-10 23:27:24 -08001017 F_RAW(19200000, &tcxo_clk.c, 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",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001035 .ops = &clk_ops_rcg,
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",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001055 .ops = &clk_ops_rcg,
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",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001075 .ops = &clk_ops_rcg,
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",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001095 .ops = &clk_ops_rcg,
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",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001115 .ops = &clk_ops_rcg,
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),
Matt Wagantall07c45472012-02-10 23:27:24 -08001148 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001149 .freq_tbl = clk_tbl_uartdm,
1150 .ns_mask = F_MASK_MND16,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001151 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001152 .set_rate = set_rate_mnd,
1153 .c = {
1154 .dbg_name = "uart1dm_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001155 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001156 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001157 CLK_INIT(uart1dm_clk.c),
1158 },
1159};
1160
1161static struct rcg_clk uart2dm_clk = {
1162 .b = {
1163 .ctl_reg = UART2DM_NS_REG,
1164 .en_mask = BIT(9),
1165 .halt_reg = CLK_HALT_STATEB_REG,
1166 .halt_bit = 23,
1167 .reset_mask = P_UART2DM_CLK,
1168 },
1169 .ns_reg = UART2DM_NS_REG,
1170 .md_reg = UART2DM_NS_REG - 4,
1171 .root_en_mask = BIT(11),
1172 .freq_tbl = clk_tbl_uartdm,
1173 .ns_mask = F_MASK_MND16,
Matt Wagantall07c45472012-02-10 23:27:24 -08001174 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001175 .set_rate = set_rate_mnd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001176 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001177 .c = {
1178 .dbg_name = "uart2dm_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001179 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001180 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001181 CLK_INIT(uart2dm_clk.c),
1182 },
1183};
1184
1185static struct clk_freq_tbl clk_tbl_mdh[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001186 F_BASIC( 0, gnd, 1),
1187 F_BASIC( 49150000, pll3, 15),
1188 F_BASIC( 92160000, pll3, 8),
1189 F_BASIC(122880000, pll3, 6),
1190 F_BASIC(184320000, pll3, 4),
1191 F_BASIC(245760000, pll3, 3),
1192 F_BASIC(368640000, pll3, 2),
1193 F_BASIC(384000000, pll1, 2),
1194 F_BASIC(445500000, pll4, 2),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001195 F_END,
1196};
1197
1198static struct rcg_clk emdh_clk = {
1199 .b = {
1200 .ctl_reg = EMDH_NS_REG,
1201 .halt_check = DELAY,
1202 .reset_mask = P_EMDH_CLK,
1203 },
1204 .root_en_mask = BIT(11),
1205 .ns_reg = EMDH_NS_REG,
1206 .ns_mask = F_MASK_BASIC,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001207 .set_rate = set_rate_nop,
1208 .freq_tbl = clk_tbl_mdh,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001209 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001210 .c = {
1211 .dbg_name = "emdh_clk",
1212 .flags = CLKFLAG_MIN | CLKFLAG_MAX,
Stephen Boyd409b8b42012-04-10 12:12:56 -07001213 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001214 VDD_DIG_FMAX_MAP1(NOMINAL, 445500000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001215 CLK_INIT(emdh_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001216 .depends = &axi_li_adsp_a_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001217 },
1218};
1219
1220static struct rcg_clk pmdh_clk = {
1221 .b = {
1222 .ctl_reg = PMDH_NS_REG,
1223 .halt_check = DELAY,
1224 .reset_mask = P_PMDH_CLK,
1225 },
1226 .root_en_mask = BIT(11),
1227 .ns_reg = PMDH_NS_REG,
1228 .ns_mask = F_MASK_BASIC,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001229 .set_rate = set_rate_nop,
1230 .freq_tbl = clk_tbl_mdh,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001231 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001232 .c = {
1233 .dbg_name = "pmdh_clk",
1234 .flags = CLKFLAG_MIN | CLKFLAG_MAX,
Stephen Boyd409b8b42012-04-10 12:12:56 -07001235 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001236 VDD_DIG_FMAX_MAP1(NOMINAL, 445500000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001237 CLK_INIT(pmdh_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001238 .depends = &axi_li_adsp_a_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001239 },
1240};
1241
1242static struct clk_freq_tbl clk_tbl_grp[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001243 F_BASIC( 24576000, lpxo, 1),
1244 F_BASIC( 46080000, pll3, 16),
1245 F_BASIC( 49152000, pll3, 15),
1246 F_BASIC( 52662875, pll3, 14),
1247 F_BASIC( 56713846, pll3, 13),
1248 F_BASIC( 61440000, pll3, 12),
1249 F_BASIC( 67025454, pll3, 11),
1250 F_BASIC( 73728000, pll3, 10),
1251 F_BASIC( 81920000, pll3, 9),
1252 F_BASIC( 92160000, pll3, 8),
1253 F_BASIC(105325714, pll3, 7),
1254 F_BASIC(122880000, pll3, 6),
1255 F_BASIC(147456000, pll3, 5),
1256 F_BASIC(184320000, pll3, 4),
1257 F_BASIC(192000000, pll1, 4),
1258 F_BASIC(245760000, pll3, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001259 /* Sync to AXI. Hence this "rate" is not fixed. */
Matt Wagantall07c45472012-02-10 23:27:24 -08001260 F_RAW(1, &lpxo_clk.c, 0, BIT(14), 0, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001261 F_END,
1262};
1263
1264static struct rcg_clk grp_2d_clk = {
1265 .b = {
1266 .ctl_reg = GRP_2D_NS_REG,
1267 .en_mask = BIT(7),
1268 .halt_reg = CLK_HALT_STATEA_REG,
1269 .halt_bit = 31,
1270 .reset_mask = P_GRP_2D_CLK,
1271 },
1272 .ns_reg = GRP_2D_NS_REG,
1273 .root_en_mask = BIT(11),
1274 .ns_mask = F_MASK_BASIC | (7 << 12),
1275 .set_rate = set_rate_nop,
1276 .freq_tbl = clk_tbl_grp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001277 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001278 .c = {
1279 .dbg_name = "grp_2d_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001280 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001281 VDD_DIG_FMAX_MAP2(NOMINAL, 192000000, HIGH, 245760000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001282 CLK_INIT(grp_2d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001283 .depends = &axi_grp_2d_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001284 },
1285};
1286
1287static struct rcg_clk grp_3d_src_clk = {
1288 .ns_reg = GRP_NS_REG,
1289 .b = {
1290 .ctl_reg = GRP_NS_REG,
1291 .halt_check = NOCHECK,
1292 },
1293 .root_en_mask = BIT(11),
1294 .ns_mask = F_MASK_BASIC | (7 << 12),
1295 .set_rate = set_rate_nop,
1296 .freq_tbl = clk_tbl_grp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001297 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001298 .c = {
1299 .dbg_name = "grp_3d_src_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001300 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001301 VDD_DIG_FMAX_MAP2(NOMINAL, 192000000, HIGH, 245760000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001302 CLK_INIT(grp_3d_src_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001303 .depends = &axi_li_grp_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001304 },
1305};
1306
1307static struct branch_clk grp_3d_clk = {
1308 .b = {
1309 .ctl_reg = GRP_NS_REG,
1310 .en_mask = BIT(7),
1311 .halt_reg = CLK_HALT_STATEB_REG,
1312 .halt_bit = 18,
1313 .reset_mask = P_GRP_3D_CLK,
1314 },
1315 .parent = &grp_3d_src_clk.c,
1316 .c = {
1317 .dbg_name = "grp_3d_clk",
1318 .ops = &clk_ops_branch,
1319 CLK_INIT(grp_3d_clk.c),
1320 },
1321};
1322
1323static struct branch_clk imem_clk = {
1324 .b = {
1325 .ctl_reg = GRP_NS_REG,
1326 .en_mask = BIT(9),
1327 .halt_reg = CLK_HALT_STATEB_REG,
1328 .halt_bit = 19,
1329 .reset_mask = P_IMEM_CLK,
1330 },
1331 .parent = &grp_3d_src_clk.c,
1332 .c = {
1333 .dbg_name = "imem_clk",
1334 .ops = &clk_ops_branch,
1335 CLK_INIT(imem_clk.c),
1336 },
1337};
1338
1339static struct clk_freq_tbl clk_tbl_sdc1_3[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001340 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
1341 F_MND8( 144000, 19, 12, lpxo, 1, 1, 171),
1342 F_MND8( 400000, 19, 12, lpxo, 1, 2, 123),
1343 F_MND8(16027000, 19, 12, pll3, 3, 14, 215),
1344 F_MND8(17000000, 19, 12, pll3, 4, 19, 206),
1345 F_MND8(20480000, 19, 12, pll3, 4, 23, 212),
1346 F_MND8(24576000, 19, 12, lpxo, 1, 0, 0),
1347 F_MND8(49152000, 19, 12, pll3, 3, 1, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001348 F_END,
1349};
1350
1351static struct rcg_clk sdc1_clk = {
1352 .b = {
1353 .ctl_reg = SDCn_NS_REG(1),
1354 .en_mask = BIT(9),
1355 .halt_reg = CLK_HALT_STATEA_REG,
1356 .halt_bit = 1,
1357 .reset_mask = P_SDC1_CLK,
1358 },
1359 .ns_reg = SDCn_NS_REG(1),
1360 .md_reg = SDCn_NS_REG(1) - 4,
1361 .ns_mask = F_MASK_MND8(19, 12),
Matt Wagantall07c45472012-02-10 23:27:24 -08001362 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001363 .root_en_mask = BIT(11),
1364 .freq_tbl = clk_tbl_sdc1_3,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001365 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001366 .set_rate = set_rate_mnd,
1367 .c = {
1368 .dbg_name = "sdc1_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001369 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001370 VDD_DIG_FMAX_MAP1(NOMINAL, 49152000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001371 CLK_INIT(sdc1_clk.c),
1372 },
1373};
1374
1375static struct rcg_clk sdc3_clk = {
1376 .b = {
1377 .ctl_reg = SDCn_NS_REG(3),
1378 .en_mask = BIT(9),
1379 .halt_reg = CLK_HALT_STATEB_REG,
1380 .halt_bit = 24,
1381 .reset_mask = P_SDC3_CLK,
1382 },
1383 .ns_reg = SDCn_NS_REG(3),
1384 .md_reg = SDCn_NS_REG(3) - 4,
1385 .ns_mask = F_MASK_MND8(19, 12),
Matt Wagantall07c45472012-02-10 23:27:24 -08001386 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001387 .root_en_mask = BIT(11),
1388 .freq_tbl = clk_tbl_sdc1_3,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001389 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001390 .set_rate = set_rate_mnd,
1391 .c = {
1392 .dbg_name = "sdc3_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001393 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001394 VDD_DIG_FMAX_MAP1(NOMINAL, 49152000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001395 CLK_INIT(sdc3_clk.c),
1396 },
1397};
1398
1399static struct clk_freq_tbl clk_tbl_sdc2_4[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001400 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
1401 F_MND8( 144000, 20, 13, lpxo, 1, 1, 171),
1402 F_MND8( 400000, 20, 13, lpxo, 1, 2, 123),
1403 F_MND8(16027000, 20, 13, pll3, 3, 14, 215),
1404 F_MND8(17000000, 20, 13, pll3, 4, 19, 206),
1405 F_MND8(20480000, 20, 13, pll3, 4, 23, 212),
1406 F_MND8(24576000, 20, 13, lpxo, 1, 0, 0),
1407 F_MND8(49152000, 20, 13, pll3, 3, 1, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001408 F_END,
1409};
1410
1411static struct rcg_clk sdc2_clk = {
1412 .b = {
1413 .ctl_reg = SDCn_NS_REG(2),
1414 .en_mask = BIT(9),
1415 .halt_reg = CLK_HALT_STATEA_REG,
1416 .halt_bit = 0,
1417 .reset_mask = P_SDC2_CLK,
1418 },
1419 .ns_reg = SDCn_NS_REG(2),
1420 .md_reg = SDCn_NS_REG(2) - 4,
1421 .ns_mask = F_MASK_MND8(20, 13),
Matt Wagantall07c45472012-02-10 23:27:24 -08001422 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001423 .root_en_mask = BIT(11),
1424 .freq_tbl = clk_tbl_sdc2_4,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001425 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001426 .set_rate = set_rate_mnd,
1427 .c = {
1428 .dbg_name = "sdc2_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001429 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001430 VDD_DIG_FMAX_MAP1(NOMINAL, 49152000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001431 CLK_INIT(sdc2_clk.c),
1432 },
1433};
1434
1435static struct rcg_clk sdc4_clk = {
1436 .b = {
1437 .ctl_reg = SDCn_NS_REG(4),
1438 .en_mask = BIT(9),
1439 .halt_reg = CLK_HALT_STATEB_REG,
1440 .halt_bit = 25,
1441 .reset_mask = P_SDC4_CLK,
1442 },
1443 .ns_reg = SDCn_NS_REG(4),
1444 .md_reg = SDCn_NS_REG(4) - 4,
1445 .ns_mask = F_MASK_MND8(20, 13),
Matt Wagantall07c45472012-02-10 23:27:24 -08001446 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001447 .root_en_mask = BIT(11),
1448 .freq_tbl = clk_tbl_sdc2_4,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001449 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001450 .set_rate = set_rate_mnd,
1451 .c = {
1452 .dbg_name = "sdc4_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001453 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001454 VDD_DIG_FMAX_MAP1(NOMINAL, 49152000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001455 CLK_INIT(sdc4_clk.c),
1456 },
1457};
1458
1459static struct clk_freq_tbl clk_tbl_mdp_core[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001460 F_BASIC( 24576000, lpxo, 1),
1461 F_BASIC( 46080000, pll3, 16),
1462 F_BASIC( 49152000, pll3, 15),
1463 F_BASIC( 52663000, pll3, 14),
1464 F_BASIC( 92160000, pll3, 8),
1465 F_BASIC(122880000, pll3, 6),
1466 F_BASIC(147456000, pll3, 5),
1467 F_BASIC(153600000, pll1, 5),
1468 F_BASIC(192000000, pll1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001469 F_END,
1470};
1471
1472static struct rcg_clk mdp_clk = {
1473 .b = {
1474 .ctl_reg = MDP_NS_REG,
1475 .en_mask = BIT(9),
1476 .halt_reg = CLK_HALT_STATEB_REG,
1477 .halt_bit = 16,
1478 .reset_mask = P_MDP_CLK,
1479 },
1480 .ns_reg = MDP_NS_REG,
1481 .root_en_mask = BIT(11),
1482 .ns_mask = F_MASK_BASIC,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001483 .set_rate = set_rate_nop,
1484 .freq_tbl = clk_tbl_mdp_core,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001485 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001486 .c = {
1487 .dbg_name = "mdp_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001488 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001489 VDD_DIG_FMAX_MAP2(NOMINAL, 153600000, HIGH, 192000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001490 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001491 .depends = &axi_mdp_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001492 },
1493};
1494
1495static struct clk_freq_tbl clk_tbl_mdp_lcdc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001496 F_MND16( 0, gnd, 1, 0, 0),
1497 F_MND16(24576000, lpxo, 1, 0, 0),
1498 F_MND16(30720000, pll3, 4, 1, 6),
1499 F_MND16(32768000, pll3, 3, 2, 15),
1500 F_MND16(40960000, pll3, 2, 1, 9),
1501 F_MND16(73728000, pll3, 2, 1, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001502 F_END,
1503};
1504
1505static struct rcg_clk mdp_lcdc_pclk_clk = {
1506 .b = {
1507 .ctl_reg = MDP_LCDC_NS_REG,
1508 .en_mask = BIT(9),
1509 .halt_reg = CLK_HALT_STATEB_REG,
1510 .halt_bit = 28,
1511 .reset_mask = P_MDP_LCDC_PCLK_CLK,
1512 },
1513 .ns_reg = MDP_LCDC_NS_REG,
1514 .md_reg = MDP_LCDC_NS_REG - 4,
1515 .root_en_mask = BIT(11),
1516 .ns_mask = F_MASK_MND16,
Matt Wagantall07c45472012-02-10 23:27:24 -08001517 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001518 .set_rate = set_rate_mnd,
1519 .freq_tbl = clk_tbl_mdp_lcdc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001520 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001521 .c = {
1522 .dbg_name = "mdp_lcdc_pclk_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001523 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001524 VDD_DIG_FMAX_MAP1(NOMINAL, 73728000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001525 CLK_INIT(mdp_lcdc_pclk_clk.c),
1526 },
1527};
1528
1529static struct branch_clk mdp_lcdc_pad_pclk_clk = {
1530 .b = {
1531 .ctl_reg = MDP_LCDC_NS_REG,
1532 .en_mask = BIT(12),
1533 .halt_reg = CLK_HALT_STATEB_REG,
1534 .halt_bit = 29,
1535 .reset_mask = P_MDP_LCDC_PAD_PCLK_CLK,
1536 },
1537 .parent = &mdp_lcdc_pclk_clk.c,
1538 .c = {
1539 .dbg_name = "mdp_lcdc_pad_pclk_clk",
1540 .ops = &clk_ops_branch,
1541 CLK_INIT(mdp_lcdc_pad_pclk_clk.c),
1542 },
1543};
1544
1545static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantall07c45472012-02-10 23:27:24 -08001546 F_RAW( 0, &gnd_clk.c, 0, (0x3<<2), 0, NULL),
1547 F_RAW(24576000, &lpxo_clk.c, 0, (0x1<<2), 0, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001548 F_END,
1549};
1550
1551static struct rcg_clk mdp_vsync_clk = {
1552 .b = {
1553 .ctl_reg = MDP_VSYNC_REG,
1554 .en_mask = BIT(0),
1555 .halt_reg = CLK_HALT_STATEB_REG,
1556 .halt_bit = 30,
1557 .reset_mask = P_MDP_VSYNC_CLK,
1558 },
1559 .ns_reg = MDP_VSYNC_REG,
1560 .ns_mask = BM(3, 2),
1561 .freq_tbl = clk_tbl_mdp_vsync,
1562 .set_rate = set_rate_nop,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001563 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001564 .c = {
1565 .dbg_name = "mdp_vsync_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001566 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001567 VDD_DIG_FMAX_MAP1(NOMINAL, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001568 CLK_INIT(mdp_vsync_clk.c),
1569 },
1570};
1571
1572static struct clk_freq_tbl clk_tbl_mi2s_codec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001573 F_MND16( 0, gnd, 1, 0, 0),
1574 F_MND16( 2048000, lpxo, 4, 1, 3),
1575 F_MND16(12288000, lpxo, 2, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001576 F_END,
1577};
1578
1579static struct rcg_clk mi2s_codec_rx_m_clk = {
1580 .b = {
1581 .ctl_reg = MI2S_RX_NS_REG,
1582 .en_mask = BIT(12),
1583 .halt_reg = CLK_HALT_STATEA_REG,
1584 .halt_bit = 12,
1585 .reset_mask = P_MI2S_CODEC_RX_M_CLK,
1586 },
1587 .ns_reg = MI2S_RX_NS_REG,
1588 .md_reg = MI2S_RX_NS_REG - 4,
1589 .root_en_mask = BIT(11),
1590 .ns_mask = F_MASK_MND16,
Matt Wagantall07c45472012-02-10 23:27:24 -08001591 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001592 .set_rate = set_rate_mnd,
1593 .freq_tbl = clk_tbl_mi2s_codec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001594 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001595 .c = {
1596 .dbg_name = "mi2s_codec_rx_m_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001597 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001598 VDD_DIG_FMAX_MAP1(NOMINAL, 12288000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001599 CLK_INIT(mi2s_codec_rx_m_clk.c),
1600 },
1601};
1602
1603static struct branch_clk mi2s_codec_rx_s_clk = {
1604 .b = {
1605 .ctl_reg = MI2S_RX_NS_REG,
1606 .en_mask = BIT(9),
1607 .halt_reg = CLK_HALT_STATEA_REG,
1608 .halt_bit = 13,
1609 .reset_mask = P_MI2S_CODEC_RX_S_CLK,
1610 },
1611 .parent = &mi2s_codec_rx_m_clk.c,
1612 .c = {
1613 .dbg_name = "mi2s_codec_rx_s_clk",
1614 .ops = &clk_ops_branch,
1615 CLK_INIT(mi2s_codec_rx_s_clk.c),
1616 },
1617};
1618
1619static struct rcg_clk mi2s_codec_tx_m_clk = {
1620 .b = {
1621 .ctl_reg = MI2S_TX_NS_REG,
1622 .en_mask = BIT(12),
1623 .halt_reg = CLK_HALT_STATEC_REG,
1624 .halt_bit = 8,
1625 .reset_mask = P_MI2S_CODEC_TX_M_CLK,
1626 },
1627 .ns_reg = MI2S_TX_NS_REG,
1628 .md_reg = MI2S_TX_NS_REG - 4,
1629 .root_en_mask = BIT(11),
1630 .ns_mask = F_MASK_MND16,
Matt Wagantall07c45472012-02-10 23:27:24 -08001631 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001632 .set_rate = set_rate_mnd,
1633 .freq_tbl = clk_tbl_mi2s_codec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001634 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001635 .c = {
1636 .dbg_name = "mi2s_codec_tx_m_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001637 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001638 VDD_DIG_FMAX_MAP1(NOMINAL, 12288000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001639 CLK_INIT(mi2s_codec_tx_m_clk.c),
1640 },
1641};
1642
1643static struct branch_clk mi2s_codec_tx_s_clk = {
1644 .b = {
1645 .ctl_reg = MI2S_TX_NS_REG,
1646 .en_mask = BIT(9),
1647 .halt_reg = CLK_HALT_STATEA_REG,
1648 .halt_bit = 11,
1649 .reset_mask = P_MI2S_CODEC_TX_S_CLK,
1650 },
1651 .parent = &mi2s_codec_tx_m_clk.c,
1652 .c = {
1653 .dbg_name = "mi2s_codec_tx_s_clk",
1654 .ops = &clk_ops_branch,
1655 CLK_INIT(mi2s_codec_tx_s_clk.c),
1656 },
1657};
1658
1659static struct clk_freq_tbl clk_tbl_mi2s[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001660 F_MND16( 0, gnd, 1, 0, 0),
1661 F_MND16(12288000, lpxo, 2, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001662 F_END,
1663};
1664
1665static struct rcg_clk mi2s_m_clk = {
1666 .b = {
1667 .ctl_reg = MI2S_NS_REG,
1668 .en_mask = BIT(12),
1669 .halt_reg = CLK_HALT_STATEC_REG,
1670 .halt_bit = 4,
1671 .reset_mask = P_MI2S_M_CLK,
1672 },
1673 .ns_reg = MI2S_NS_REG,
1674 .md_reg = MI2S_NS_REG - 4,
1675 .root_en_mask = BIT(11),
1676 .ns_mask = F_MASK_MND16,
Matt Wagantall07c45472012-02-10 23:27:24 -08001677 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001678 .set_rate = set_rate_mnd,
1679 .freq_tbl = clk_tbl_mi2s,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001680 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001681 .c = {
1682 .dbg_name = "mi2s_m_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001683 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001684 VDD_DIG_FMAX_MAP1(NOMINAL, 12288000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001685 CLK_INIT(mi2s_m_clk.c),
1686 },
1687};
1688
1689static struct branch_clk mi2s_s_clk = {
1690 .b = {
1691 .ctl_reg = MI2S_NS_REG,
1692 .en_mask = BIT(9),
1693 .halt_reg = CLK_HALT_STATEC_REG,
1694 .halt_bit = 3,
1695 .reset_mask = P_MI2S_S_CLK,
1696 },
1697 .parent = &mi2s_m_clk.c,
1698 .c = {
1699 .dbg_name = "mi2s_s_clk",
1700 .ops = &clk_ops_branch,
1701 CLK_INIT(mi2s_s_clk.c),
1702 },
1703};
1704
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001705#define F_SDAC(f, s, div, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001706 { \
1707 .freq_hz = f, \
1708 .md_val = MD16(m, n), \
1709 .ns_val = N16(m, n) | SPDIV(SRC_SEL_SDAC_##s, div), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001710 .src_clk = &s##_clk.c, \
1711 }
1712
1713static struct clk_freq_tbl clk_tbl_sdac[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001714 F_SDAC( 256000, lpxo, 4, 1, 24),
1715 F_SDAC( 352800, lpxo, 1, 147, 10240),
1716 F_SDAC( 384000, lpxo, 4, 1, 16),
1717 F_SDAC( 512000, lpxo, 4, 1, 12),
1718 F_SDAC( 705600, lpxo, 1, 147, 5120),
1719 F_SDAC( 768000, lpxo, 4, 1, 8),
1720 F_SDAC(1024000, lpxo, 4, 1, 6),
1721 F_SDAC(1411200, lpxo, 1, 147, 2560),
1722 F_SDAC(1536000, lpxo, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001723 F_END,
1724};
1725
1726static struct rcg_clk sdac_clk = {
1727 .b = {
1728 .ctl_reg = SDAC_NS_REG,
1729 .en_mask = BIT(9),
1730 .halt_reg = CLK_HALT_STATEA_REG,
1731 .halt_bit = 2,
1732 .reset_mask = P_SDAC_CLK,
1733 },
1734 .ns_reg = SDAC_NS_REG,
1735 .md_reg = SDAC_NS_REG - 4,
1736 .root_en_mask = BIT(11),
Matt Wagantall07c45472012-02-10 23:27:24 -08001737 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001738 .freq_tbl = clk_tbl_sdac,
1739 .ns_mask = F_MASK_MND16,
1740 .set_rate = set_rate_mnd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001741 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001742 .c = {
1743 .dbg_name = "sdac_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001744 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001745 VDD_DIG_FMAX_MAP1(NOMINAL, 1536000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001746 CLK_INIT(sdac_clk.c),
1747 },
1748};
1749
1750static struct branch_clk sdac_m_clk = {
1751 .b = {
1752 .ctl_reg = SDAC_NS_REG,
1753 .en_mask = BIT(12),
1754 .halt_reg = CLK_HALT_STATEB_REG,
1755 .halt_bit = 17,
1756 .reset_mask = P_SDAC_M_CLK,
1757 },
1758 .parent = &sdac_clk.c,
1759 .c = {
1760 .dbg_name = "sdac_m_clk",
1761 .ops = &clk_ops_branch,
1762 CLK_INIT(sdac_m_clk.c),
1763 },
1764};
1765
1766static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001767 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
1768 F_MND8(27000000, 23, 16, pll4, 2, 2, 33),
1769 F_MND8(74250000, 23, 16, pll4, 2, 1, 6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001770 F_END,
1771};
1772
1773static struct rcg_clk tv_clk = {
1774 .ns_reg = TV_NS_REG,
1775 .b = {
1776 .ctl_reg = TV_NS_REG,
1777 .halt_check = NOCHECK,
1778 },
1779 .md_reg = TV_NS_REG - 4,
1780 .ns_mask = F_MASK_MND8(23, 16),
Matt Wagantall07c45472012-02-10 23:27:24 -08001781 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001782 .root_en_mask = BIT(11),
1783 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001784 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001785 .set_rate = set_rate_mnd,
1786 .c = {
1787 .dbg_name = "tv_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001788 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001789 VDD_DIG_FMAX_MAP1(NOMINAL, 74250000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001790 CLK_INIT(tv_clk.c),
1791 },
1792};
1793
1794static struct branch_clk hdmi_clk = {
1795 .b = {
1796 .ctl_reg = HDMI_NS_REG,
1797 .en_mask = BIT(9),
1798 .halt_reg = CLK_HALT_STATEC_REG,
1799 .halt_bit = 7,
1800 .reset_mask = P_HDMI_CLK,
1801 },
1802 .parent = &tv_clk.c,
1803 .c = {
1804 .dbg_name = "hdmi_clk",
1805 .ops = &clk_ops_branch,
1806 CLK_INIT(hdmi_clk.c),
1807 },
1808};
1809
1810static struct branch_clk tv_dac_clk = {
1811 .b = {
1812 .ctl_reg = TV_NS_REG,
1813 .en_mask = BIT(12),
1814 .halt_reg = CLK_HALT_STATEB_REG,
1815 .halt_bit = 27,
1816 .reset_mask = P_TV_DAC_CLK,
1817 },
1818 .parent = &tv_clk.c,
1819 .c = {
1820 .dbg_name = "tv_dac_clk",
1821 .ops = &clk_ops_branch,
1822 CLK_INIT(tv_dac_clk.c),
1823 },
1824};
1825
1826static struct branch_clk tv_enc_clk = {
1827 .b = {
1828 .ctl_reg = TV_NS_REG,
1829 .en_mask = BIT(9),
1830 .halt_reg = CLK_HALT_STATEB_REG,
1831 .halt_bit = 10,
1832 .reset_mask = P_TV_ENC_CLK,
1833 },
1834 .parent = &tv_clk.c,
1835 .c = {
1836 .dbg_name = "tv_enc_clk",
1837 .ops = &clk_ops_branch,
1838 CLK_INIT(tv_enc_clk.c),
1839 },
1840};
1841
1842/* Hacking root & branch into one param. */
1843static struct branch_clk tsif_ref_clk = {
1844 .b = {
1845 .ctl_reg = TSIF_NS_REG,
1846 .en_mask = BIT(9)|BIT(11),
1847 .halt_reg = CLK_HALT_STATEB_REG,
1848 .halt_bit = 11,
1849 .reset_mask = P_TSIF_REF_CLK,
1850 },
1851 .parent = &tv_clk.c,
1852 .c = {
1853 .dbg_name = "tsif_ref_clk",
1854 .ops = &clk_ops_branch,
1855 CLK_INIT(tsif_ref_clk.c),
1856 },
1857};
1858
1859static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001860 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
1861 F_MND8(60000000, 23, 16, pll1, 2, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001862 F_END,
1863};
1864
1865static struct rcg_clk usb_hs_src_clk = {
1866 .ns_reg = USBH_NS_REG,
1867 .b = {
1868 .ctl_reg = USBH_NS_REG,
1869 .halt_check = NOCHECK,
1870 },
1871 .md_reg = USBH_NS_REG - 4,
1872 .ns_mask = F_MASK_MND8(23, 16),
Matt Wagantall07c45472012-02-10 23:27:24 -08001873 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001874 .root_en_mask = BIT(11),
1875 .freq_tbl = clk_tbl_usb,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001876 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001877 .set_rate = set_rate_mnd,
1878 .c = {
1879 .dbg_name = "usb_hs_src_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001880 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001881 VDD_DIG_FMAX_MAP1(NOMINAL, 60000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001882 CLK_INIT(usb_hs_src_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07001883 .depends = &axi_li_adsp_a_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001884 },
1885};
1886
1887static struct branch_clk usb_hs_clk = {
1888 .b = {
1889 .ctl_reg = USBH_NS_REG,
1890 .en_mask = BIT(9),
1891 .halt_reg = CLK_HALT_STATEB_REG,
1892 .halt_bit = 26,
1893 .reset_mask = P_USB_HS_CLK,
1894 },
1895 .c = {
1896 .dbg_name = "usb_hs_clk",
1897 .ops = &clk_ops_branch,
1898 CLK_INIT(usb_hs_clk.c),
1899 },
1900};
1901
1902static struct branch_clk usb_hs_core_clk = {
1903 .b = {
1904 .ctl_reg = USBH_NS_REG,
1905 .en_mask = BIT(13),
1906 .halt_reg = CLK_HALT_STATEA_REG,
1907 .halt_bit = 27,
1908 .reset_mask = P_USB_HS_CORE_CLK,
1909 },
1910 .parent = &usb_hs_src_clk.c,
1911 .c = {
1912 .dbg_name = "usb_hs_core_clk",
1913 .ops = &clk_ops_branch,
1914 CLK_INIT(usb_hs_core_clk.c),
1915 },
1916};
1917
1918static struct branch_clk usb_hs2_clk = {
1919 .b = {
1920 .ctl_reg = USBH2_NS_REG,
1921 .en_mask = BIT(9),
1922 .halt_reg = CLK_HALT_STATEB_REG,
1923 .halt_bit = 3,
1924 .reset_mask = P_USB_HS2_CLK,
1925 },
1926 .parent = &usb_hs_src_clk.c,
1927 .c = {
1928 .dbg_name = "usb_hs2_clk",
1929 .ops = &clk_ops_branch,
1930 CLK_INIT(usb_hs2_clk.c),
1931 },
1932};
1933
1934static struct branch_clk usb_hs2_core_clk = {
1935 .b = {
1936 .ctl_reg = USBH2_NS_REG,
1937 .en_mask = BIT(4),
1938 .halt_reg = CLK_HALT_STATEA_REG,
1939 .halt_bit = 28,
1940 .reset_mask = P_USB_HS2_CORE_CLK,
1941 },
1942 .parent = &usb_hs_src_clk.c,
1943 .c = {
1944 .dbg_name = "usb_hs2_core_clk",
1945 .ops = &clk_ops_branch,
1946 CLK_INIT(usb_hs2_core_clk.c),
1947 },
1948};
1949
1950static struct branch_clk usb_hs3_clk = {
1951 .b = {
1952 .ctl_reg = USBH3_NS_REG,
1953 .en_mask = BIT(9),
1954 .halt_reg = CLK_HALT_STATEB_REG,
1955 .halt_bit = 2,
1956 .reset_mask = P_USB_HS3_CLK,
1957 },
1958 .parent = &usb_hs_src_clk.c,
1959 .c = {
1960 .dbg_name = "usb_hs3_clk",
1961 .ops = &clk_ops_branch,
1962 CLK_INIT(usb_hs3_clk.c),
1963 },
1964};
1965
1966static struct branch_clk usb_hs3_core_clk = {
1967 .b = {
1968 .ctl_reg = USBH3_NS_REG,
1969 .en_mask = BIT(4),
1970 .halt_reg = CLK_HALT_STATEA_REG,
1971 .halt_bit = 29,
1972 .reset_mask = P_USB_HS3_CORE_CLK,
1973 },
1974 .parent = &usb_hs_src_clk.c,
1975 .c = {
1976 .dbg_name = "usb_hs3_core_clk",
1977 .ops = &clk_ops_branch,
1978 CLK_INIT(usb_hs3_core_clk.c),
1979 },
1980};
1981
1982static struct clk_freq_tbl clk_tbl_vfe_jpeg[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001983 F_MND16( 24576000, lpxo, 1, 0, 0),
1984 F_MND16( 36864000, pll3, 4, 1, 5),
1985 F_MND16( 46080000, pll3, 4, 1, 4),
1986 F_MND16( 61440000, pll3, 4, 1, 3),
1987 F_MND16( 73728000, pll3, 2, 1, 5),
1988 F_MND16( 81920000, pll3, 3, 1, 3),
1989 F_MND16( 92160000, pll3, 4, 1, 2),
1990 F_MND16( 98304000, pll3, 3, 2, 5),
1991 F_MND16(105326000, pll3, 2, 2, 7),
1992 F_MND16(122880000, pll3, 2, 1, 3),
1993 F_MND16(147456000, pll3, 2, 2, 5),
1994 F_MND16(153600000, pll1, 2, 2, 5),
1995 F_MND16(192000000, pll1, 4, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001996 F_END,
1997};
1998
1999static struct rcg_clk jpeg_clk = {
2000 .b = {
2001 .ctl_reg = JPEG_NS_REG,
2002 .en_mask = BIT(9),
2003 .halt_reg = CLK_HALT_STATEB_REG,
2004 .halt_bit = 1,
2005 .reset_mask = P_JPEG_CLK,
2006 },
2007 .ns_reg = JPEG_NS_REG,
2008 .md_reg = JPEG_NS_REG - 4,
2009 .root_en_mask = BIT(11),
2010 .freq_tbl = clk_tbl_vfe_jpeg,
2011 .ns_mask = F_MASK_MND16,
Matt Wagantall07c45472012-02-10 23:27:24 -08002012 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002013 .set_rate = set_rate_mnd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002014 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002015 .c = {
2016 .dbg_name = "jpeg_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002017 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002018 VDD_DIG_FMAX_MAP2(NOMINAL, 153600000, HIGH, 192000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002019 CLK_INIT(jpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002020 .depends = &axi_li_jpeg_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002021 },
2022};
2023
2024static struct rcg_clk vfe_clk = {
2025 .b = {
2026 .ctl_reg = CAM_VFE_NS_REG,
2027 .en_mask = BIT(9),
2028 .halt_reg = CLK_HALT_STATEB_REG,
2029 .halt_bit = 0,
2030 .reset_mask = P_VFE_CLK,
2031 },
2032 .ns_reg = CAM_VFE_NS_REG,
2033 .md_reg = CAM_VFE_NS_REG - 4,
2034 .root_en_mask = BIT(13),
2035 .freq_tbl = clk_tbl_vfe_jpeg,
2036 .ns_mask = F_MASK_MND16,
Matt Wagantall07c45472012-02-10 23:27:24 -08002037 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002038 .set_rate = set_rate_mnd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002039 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002040 .c = {
2041 .dbg_name = "vfe_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002042 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002043 VDD_DIG_FMAX_MAP2(NOMINAL, 153600000, HIGH, 192000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002044 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002045 .depends = &axi_li_vfe_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002046 },
2047};
2048
2049static struct branch_clk vfe_mdc_clk = {
2050 .b = {
2051 .ctl_reg = CAM_VFE_NS_REG,
2052 .en_mask = BIT(11),
2053 .halt_reg = CLK_HALT_STATEA_REG,
2054 .halt_bit = 9,
2055 .reset_mask = P_VFE_MDC_CLK,
2056 },
2057 .parent = &vfe_clk.c,
2058 .c = {
2059 .dbg_name = "vfe_mdc_clk",
2060 .ops = &clk_ops_branch,
2061 CLK_INIT(vfe_mdc_clk.c),
2062 },
2063};
2064
2065static struct branch_clk vfe_camif_clk = {
2066 .b = {
2067 .ctl_reg = CAM_VFE_NS_REG,
2068 .en_mask = BIT(15),
2069 .halt_reg = CLK_HALT_STATEC_REG,
2070 .halt_bit = 13,
2071 .reset_mask = P_VFE_CAMIF_CLK,
2072 },
2073 .parent = &vfe_clk.c,
2074 .c = {
2075 .dbg_name = "vfe_camif_clk",
2076 .ops = &clk_ops_branch,
2077 CLK_INIT(vfe_camif_clk.c),
2078 },
2079};
2080
2081static struct branch_clk csi0_vfe_clk = {
2082 .b = {
2083 .ctl_reg = CSI_NS_REG,
2084 .en_mask = BIT(15),
2085 .halt_reg = CLK_HALT_STATEC_REG,
2086 .halt_bit = 16,
2087 .reset_mask = P_CSI0_VFE_CLK,
2088 },
2089 .parent = &vfe_clk.c,
2090 .c = {
2091 .dbg_name = "csi0_vfe_clk",
2092 .ops = &clk_ops_branch,
2093 CLK_INIT(csi0_vfe_clk.c),
2094 },
2095};
2096
2097static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002098 F_MND16( 0, gnd, 1, 0, 0),
2099 F_MND16( 6000000, pll1, 4, 1, 32),
2100 F_MND16( 8000000, pll1, 4, 1, 24),
2101 F_MND16(12000000, pll1, 4, 1, 16),
2102 F_MND16(16000000, pll1, 4, 1, 12),
2103 F_MND16(19200000, pll1, 4, 1, 10),
2104 F_MND16(24000000, pll1, 4, 1, 8),
2105 F_MND16(32000000, pll1, 4, 1, 6),
2106 F_MND16(48000000, pll1, 4, 1, 4),
2107 F_MND16(64000000, pll1, 4, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002108 F_END,
2109};
2110
2111static struct rcg_clk cam_m_clk = {
2112 .b = {
2113 .ctl_reg = CAM_NS_REG,
2114 .halt_check = DELAY,
2115 .reset_mask = P_CAM_M_CLK,
2116 },
2117 .ns_reg = CAM_NS_REG,
2118 .md_reg = CAM_NS_REG - 4,
2119 .root_en_mask = BIT(9),
2120 .freq_tbl = clk_tbl_cam,
2121 .ns_mask = F_MASK_MND16,
Matt Wagantall07c45472012-02-10 23:27:24 -08002122 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002123 .set_rate = set_rate_mnd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002124 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002125 .c = {
2126 .dbg_name = "cam_m_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002127 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002128 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002129 CLK_INIT(cam_m_clk.c),
2130 },
2131};
2132
2133static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002134 F_MND8( 24576000, 22, 15, lpxo, 1, 0, 0),
2135 F_MND8( 30720000, 22, 15, pll3, 4, 1, 6),
2136 F_MND8( 61440000, 22, 15, pll3, 4, 1, 3),
2137 F_MND8( 81920000, 22, 15, pll3, 3, 1, 3),
2138 F_MND8(122880000, 22, 15, pll3, 3, 1, 2),
2139 F_MND8(147456000, 22, 15, pll3, 1, 1, 5),
2140 F_MND8(153600000, 22, 15, pll1, 1, 1, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002141 F_END,
2142};
2143
2144static struct rcg_clk vpe_clk = {
2145 .b = {
2146 .ctl_reg = VPE_NS_REG,
2147 .en_mask = BIT(9),
2148 .halt_reg = CLK_HALT_STATEC_REG,
2149 .halt_bit = 10,
2150 .reset_mask = P_VPE_CLK,
2151 },
2152 .ns_reg = VPE_NS_REG,
2153 .md_reg = VPE_NS_REG - 4,
2154 .ns_mask = F_MASK_MND8(22, 15),
Matt Wagantall07c45472012-02-10 23:27:24 -08002155 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002156 .root_en_mask = BIT(11),
2157 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002158 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002159 .set_rate = set_rate_mnd,
2160 .c = {
2161 .dbg_name = "vpe_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002162 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002163 VDD_DIG_FMAX_MAP1(NOMINAL, 153600000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002164 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002165 .depends = &axi_vpe_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002166 },
2167};
2168
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002169static struct clk_freq_tbl clk_tbl_mfc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002170 F_MND8( 24576000, 24, 17, lpxo, 1, 0, 0),
2171 F_MND8( 30720000, 24, 17, pll3, 4, 1, 6),
2172 F_MND8( 61440000, 24, 17, pll3, 4, 1, 3),
2173 F_MND8( 81920000, 24, 17, pll3, 3, 1, 3),
2174 F_MND8(122880000, 24, 17, pll3, 3, 1, 2),
2175 F_MND8(147456000, 24, 17, pll3, 1, 1, 5),
2176 F_MND8(153600000, 24, 17, pll1, 1, 1, 5),
2177 F_MND8(170667000, 24, 17, pll1, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002178 F_END,
2179};
2180
2181static struct rcg_clk mfc_clk = {
2182 .b = {
2183 .ctl_reg = MFC_NS_REG,
2184 .en_mask = BIT(9),
2185 .halt_reg = CLK_HALT_STATEC_REG,
2186 .halt_bit = 12,
2187 .reset_mask = P_MFC_CLK,
2188 },
2189 .ns_reg = MFC_NS_REG,
2190 .md_reg = MFC_NS_REG - 4,
2191 .ns_mask = F_MASK_MND8(24, 17),
Matt Wagantall07c45472012-02-10 23:27:24 -08002192 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002193 .root_en_mask = BIT(11),
2194 .freq_tbl = clk_tbl_mfc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002195 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002196 .set_rate = set_rate_mnd,
2197 .c = {
2198 .dbg_name = "mfc_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002199 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002200 VDD_DIG_FMAX_MAP1(NOMINAL, 170667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002201 CLK_INIT(mfc_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002202 .depends = &axi_mfc_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002203 },
2204};
2205
2206static struct branch_clk mfc_div2_clk = {
2207 .b = {
2208 .ctl_reg = MFC_NS_REG,
2209 .en_mask = BIT(15),
2210 .halt_reg = CLK_HALT_STATEC_REG,
2211 .halt_bit = 11,
2212 .reset_mask = P_MFC_DIV2_CLK,
2213 },
2214 .parent = &mfc_clk.c,
2215 .c = {
2216 .dbg_name = "mfc_div2_clk",
2217 .ops = &clk_ops_branch,
2218 CLK_INIT(mfc_div2_clk.c),
2219 },
2220};
2221
2222static struct clk_freq_tbl clk_tbl_spi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002223 F_MND8( 0, 0, 0, gnd, 1, 0, 0),
2224 F_MND8( 9963243, 19, 12, pll3, 4, 2, 37),
Matt Wagantalla7df37f2011-11-11 11:28:11 -08002225 F_MND8(24576000, 19, 12, lpxo, 1, 0, 0),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002226 F_MND8(26331429, 19, 12, pll3, 4, 1, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002227 F_END,
2228};
2229
2230static struct rcg_clk spi_clk = {
2231 .b = {
2232 .ctl_reg = SPI_NS_REG,
2233 .en_mask = BIT(9),
2234 .halt_reg = CLK_HALT_STATEC_REG,
2235 .halt_bit = 0,
2236 .reset_mask = P_SPI_CLK,
2237 },
2238 .ns_reg = SPI_NS_REG,
2239 .md_reg = SPI_NS_REG - 4,
2240 .ns_mask = F_MASK_MND8(19, 12),
Matt Wagantall07c45472012-02-10 23:27:24 -08002241 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002242 .root_en_mask = BIT(11),
2243 .freq_tbl = clk_tbl_spi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002244 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002245 .set_rate = set_rate_mnd,
2246 .c = {
2247 .dbg_name = "spi_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002248 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002249 VDD_DIG_FMAX_MAP1(NOMINAL, 26331429),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002250 CLK_INIT(spi_clk.c),
2251 },
2252};
2253
2254static struct clk_freq_tbl clk_tbl_lpa_codec[] = {
Matt Wagantall07c45472012-02-10 23:27:24 -08002255 F_RAW(1, NULL, 0, 0, 0, NULL), /* src MI2S_CODEC_RX */
2256 F_RAW(2, NULL, 0, 1, 0, NULL), /* src ECODEC_CIF */
2257 F_RAW(3, NULL, 0, 2, 0, NULL), /* src MI2S */
2258 F_RAW(4, NULL, 0, 3, 0, NULL), /* src SDAC */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002259 F_END,
2260};
2261
2262static struct rcg_clk lpa_codec_clk = {
2263 .b = {
2264 .ctl_reg = LPA_NS_REG,
2265 .en_mask = BIT(9),
2266 .halt_reg = CLK_HALT_STATEC_REG,
2267 .halt_bit = 6,
2268 .reset_mask = P_LPA_CODEC_CLK,
2269 },
2270 .ns_reg = LPA_NS_REG,
2271 .ns_mask = BM(1, 0),
2272 .set_rate = set_rate_nop,
2273 .freq_tbl = clk_tbl_lpa_codec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002274 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002275 .c = {
2276 .dbg_name = "lpa_codec_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002277 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002278 VDD_DIG_FMAX_MAP1(LOW, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002279 CLK_INIT(lpa_codec_clk.c),
2280 },
2281};
2282
2283static struct clk_freq_tbl clk_tbl_mdc[] = {
Matt Wagantall07c45472012-02-10 23:27:24 -08002284 F_RAW(1, NULL, 0, 0, 0, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002285 F_END
2286};
2287
2288static struct rcg_clk mdc_clk = {
2289 .b = {
2290 .ctl_reg = MDC_NS_REG,
2291 .en_mask = BIT(9),
2292 .halt_reg = CLK_HALT_STATEA_REG,
2293 .halt_bit = 10,
2294 .reset_mask = P_MDC_CLK,
2295 },
2296 .ns_reg = MDC_NS_REG,
2297 .root_en_mask = BIT(11),
2298 .freq_tbl = clk_tbl_mdc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002299 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002300 .set_rate = set_rate_nop,
2301 .c = {
2302 .dbg_name = "mdc_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002303 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002304 VDD_DIG_FMAX_MAP1(LOW, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002305 CLK_INIT(mdc_clk.c),
2306 },
2307};
2308
2309static struct branch_clk lpa_core_clk = {
2310 .b = {
2311 .ctl_reg = LPA_NS_REG,
2312 .en_mask = BIT(5),
2313 .halt_reg = CLK_HALT_STATEC_REG,
2314 .halt_bit = 5,
2315 .reset_mask = P_LPA_CORE_CLK,
2316 },
2317 .c = {
2318 .dbg_name = "lpa_core_clk",
2319 .ops = &clk_ops_branch,
2320 CLK_INIT(lpa_core_clk.c),
2321 },
2322};
2323
2324static DEFINE_CLK_PCOM(adsp_clk, ADSP_CLK, CLKFLAG_SKIP_AUTO_OFF);
2325static DEFINE_CLK_PCOM(codec_ssbi_clk, CODEC_SSBI_CLK, CLKFLAG_SKIP_AUTO_OFF);
2326static DEFINE_CLK_PCOM(ebi1_clk, EBI1_CLK, CLKFLAG_SKIP_AUTO_OFF | CLKFLAG_MIN);
2327static DEFINE_CLK_PCOM(ebi1_fixed_clk, EBI1_FIXED_CLK, CLKFLAG_MIN |
2328 CLKFLAG_SKIP_AUTO_OFF);
2329static DEFINE_CLK_PCOM(ecodec_clk, ECODEC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2330static DEFINE_CLK_PCOM(gp_clk, GP_CLK, CLKFLAG_SKIP_AUTO_OFF);
2331static DEFINE_CLK_PCOM(uart3_clk, UART3_CLK, 0);
2332static DEFINE_CLK_PCOM(usb_phy_clk, USB_PHY_CLK, CLKFLAG_MIN);
2333
2334static DEFINE_CLK_PCOM(p_grp_2d_clk, GRP_2D_CLK, CLKFLAG_SKIP_AUTO_OFF);
2335static DEFINE_CLK_PCOM(p_grp_2d_p_clk, GRP_2D_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2336static DEFINE_CLK_PCOM(p_hdmi_clk, HDMI_CLK, CLKFLAG_SKIP_AUTO_OFF);
Matt Wagantall2eedd222011-11-16 12:55:21 -08002337static DEFINE_CLK_PCOM(p_jpeg_clk, JPEG_CLK, CLKFLAG_MIN);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002338static DEFINE_CLK_PCOM(p_jpeg_p_clk, JPEG_P_CLK, 0);
2339static DEFINE_CLK_PCOM(p_lpa_codec_clk, LPA_CODEC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2340static DEFINE_CLK_PCOM(p_lpa_core_clk, LPA_CORE_CLK, CLKFLAG_SKIP_AUTO_OFF);
2341static DEFINE_CLK_PCOM(p_lpa_p_clk, LPA_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2342static DEFINE_CLK_PCOM(p_mi2s_m_clk, MI2S_M_CLK, CLKFLAG_SKIP_AUTO_OFF);
2343static DEFINE_CLK_PCOM(p_mi2s_s_clk, MI2S_S_CLK, CLKFLAG_SKIP_AUTO_OFF);
2344static DEFINE_CLK_PCOM(p_mi2s_codec_rx_m_clk, MI2S_CODEC_RX_M_CLK,
2345 CLKFLAG_SKIP_AUTO_OFF);
2346static DEFINE_CLK_PCOM(p_mi2s_codec_rx_s_clk, MI2S_CODEC_RX_S_CLK,
2347 CLKFLAG_SKIP_AUTO_OFF);
2348static DEFINE_CLK_PCOM(p_mi2s_codec_tx_m_clk, MI2S_CODEC_TX_M_CLK,
2349 CLKFLAG_SKIP_AUTO_OFF);
2350static DEFINE_CLK_PCOM(p_mi2s_codec_tx_s_clk, MI2S_CODEC_TX_S_CLK,
2351 CLKFLAG_SKIP_AUTO_OFF);
2352static DEFINE_CLK_PCOM(p_sdac_clk, SDAC_CLK, 0);
2353static DEFINE_CLK_PCOM(p_sdac_m_clk, SDAC_M_CLK, 0);
2354static DEFINE_CLK_PCOM(p_vfe_clk, VFE_CLK, CLKFLAG_SKIP_AUTO_OFF);
2355static DEFINE_CLK_PCOM(p_vfe_camif_clk, VFE_CAMIF_CLK, CLKFLAG_SKIP_AUTO_OFF);
2356static DEFINE_CLK_PCOM(p_vfe_mdc_clk, VFE_MDC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2357static DEFINE_CLK_PCOM(p_vfe_p_clk, VFE_P_CLK, 0);
2358static DEFINE_CLK_PCOM(p_grp_3d_clk, GRP_3D_CLK, CLKFLAG_SKIP_AUTO_OFF);
2359static DEFINE_CLK_PCOM(p_grp_3d_p_clk, GRP_3D_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2360static DEFINE_CLK_PCOM(p_imem_clk, IMEM_CLK, 0);
2361static DEFINE_CLK_PCOM(p_mdp_lcdc_pad_pclk_clk, MDP_LCDC_PAD_PCLK_CLK,
2362 CLKFLAG_SKIP_AUTO_OFF);
2363static DEFINE_CLK_PCOM(p_mdp_lcdc_pclk_clk, MDP_LCDC_PCLK_CLK,
2364 CLKFLAG_SKIP_AUTO_OFF);
2365static DEFINE_CLK_PCOM(p_mdp_p_clk, MDP_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2366static DEFINE_CLK_PCOM(p_mdp_vsync_clk, MDP_VSYNC_CLK, 0);
2367static DEFINE_CLK_PCOM(p_tsif_ref_clk, TSIF_REF_CLK, CLKFLAG_SKIP_AUTO_OFF);
2368static DEFINE_CLK_PCOM(p_tsif_p_clk, TSIF_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2369static DEFINE_CLK_PCOM(p_tv_dac_clk, TV_DAC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2370static DEFINE_CLK_PCOM(p_tv_enc_clk, TV_ENC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2371static DEFINE_CLK_PCOM(p_emdh_clk, EMDH_CLK, CLKFLAG_MIN | CLKFLAG_MAX);
2372static DEFINE_CLK_PCOM(p_emdh_p_clk, EMDH_P_CLK, 0);
2373static DEFINE_CLK_PCOM(p_i2c_clk, I2C_CLK, CLKFLAG_SKIP_AUTO_OFF);
2374static DEFINE_CLK_PCOM(p_i2c_2_clk, I2C_2_CLK, CLKFLAG_SKIP_AUTO_OFF);
2375static DEFINE_CLK_PCOM(p_mdc_clk, MDC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2376static DEFINE_CLK_PCOM(p_pmdh_clk, PMDH_CLK, CLKFLAG_MIN | CLKFLAG_MAX);
2377static DEFINE_CLK_PCOM(p_pmdh_p_clk, PMDH_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2378static DEFINE_CLK_PCOM(p_sdc1_clk, SDC1_CLK, 0);
2379static DEFINE_CLK_PCOM(p_sdc1_p_clk, SDC1_P_CLK, 0);
2380static DEFINE_CLK_PCOM(p_sdc2_clk, SDC2_CLK, 0);
2381static DEFINE_CLK_PCOM(p_sdc2_p_clk, SDC2_P_CLK, 0);
2382static DEFINE_CLK_PCOM(p_sdc3_clk, SDC3_CLK, 0);
2383static DEFINE_CLK_PCOM(p_sdc3_p_clk, SDC3_P_CLK, 0);
2384static DEFINE_CLK_PCOM(p_sdc4_clk, SDC4_CLK, 0);
2385static DEFINE_CLK_PCOM(p_sdc4_p_clk, SDC4_P_CLK, 0);
2386static DEFINE_CLK_PCOM(p_uart2_clk, UART2_CLK, CLKFLAG_SKIP_AUTO_OFF);
2387static DEFINE_CLK_PCOM(p_usb_hs2_clk, USB_HS2_CLK, 0);
2388static DEFINE_CLK_PCOM(p_usb_hs2_core_clk, USB_HS2_CORE_CLK, 0);
2389static DEFINE_CLK_PCOM(p_usb_hs2_p_clk, USB_HS2_P_CLK, 0);
2390static DEFINE_CLK_PCOM(p_usb_hs3_clk, USB_HS3_CLK, 0);
2391static DEFINE_CLK_PCOM(p_usb_hs3_core_clk, USB_HS3_CORE_CLK, 0);
2392static DEFINE_CLK_PCOM(p_usb_hs3_p_clk, USB_HS3_P_CLK, 0);
2393static DEFINE_CLK_PCOM(p_qup_i2c_clk, QUP_I2C_CLK, CLKFLAG_SKIP_AUTO_OFF);
2394static DEFINE_CLK_PCOM(p_spi_clk, SPI_CLK, CLKFLAG_SKIP_AUTO_OFF);
2395static DEFINE_CLK_PCOM(p_spi_p_clk, SPI_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2396static DEFINE_CLK_PCOM(p_uart1_clk, UART1_CLK, 0);
2397static DEFINE_CLK_PCOM(p_uart1dm_clk, UART1DM_CLK, 0);
2398static DEFINE_CLK_PCOM(p_uart2dm_clk, UART2DM_CLK, CLKFLAG_SKIP_AUTO_OFF);
2399static DEFINE_CLK_PCOM(p_usb_hs_clk, USB_HS_CLK, 0);
2400static DEFINE_CLK_PCOM(p_usb_hs_core_clk, USB_HS_CORE_CLK, 0);
2401static DEFINE_CLK_PCOM(p_usb_hs_p_clk, USB_HS_P_CLK, 0);
2402static DEFINE_CLK_PCOM(p_cam_m_clk, CAM_M_CLK, CLKFLAG_SKIP_AUTO_OFF);
2403static DEFINE_CLK_PCOM(p_camif_pad_p_clk, CAMIF_PAD_P_CLK, 0);
2404static DEFINE_CLK_PCOM(p_csi0_clk, CSI0_CLK, CLKFLAG_SKIP_AUTO_OFF);
2405static DEFINE_CLK_PCOM(p_csi0_vfe_clk, CSI0_VFE_CLK, CLKFLAG_SKIP_AUTO_OFF);
2406static DEFINE_CLK_PCOM(p_csi0_p_clk, CSI0_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
Matt Wagantalla12cc952011-11-08 18:14:50 -08002407static DEFINE_CLK_PCOM(p_mdp_clk, MDP_CLK, CLKFLAG_MIN);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002408static DEFINE_CLK_PCOM(p_mfc_clk, MFC_CLK, CLKFLAG_SKIP_AUTO_OFF);
2409static DEFINE_CLK_PCOM(p_mfc_div2_clk, MFC_DIV2_CLK, CLKFLAG_SKIP_AUTO_OFF);
2410static DEFINE_CLK_PCOM(p_mfc_p_clk, MFC_P_CLK, CLKFLAG_SKIP_AUTO_OFF);
2411static DEFINE_CLK_PCOM(p_vpe_clk, VPE_CLK, CLKFLAG_SKIP_AUTO_OFF);
2412static DEFINE_CLK_PCOM(p_adm_clk, ADM_CLK, CLKFLAG_SKIP_AUTO_OFF);
2413static DEFINE_CLK_PCOM(p_ce_clk, CE_CLK, CLKFLAG_SKIP_AUTO_OFF);
2414static DEFINE_CLK_PCOM(p_axi_rotator_clk, AXI_ROTATOR_CLK,
2415 CLKFLAG_SKIP_AUTO_OFF);
2416static DEFINE_CLK_PCOM(p_rotator_imem_clk, ROTATOR_IMEM_CLK, 0);
2417static DEFINE_CLK_PCOM(p_rotator_p_clk, ROTATOR_P_CLK, 0);
2418
Matt Wagantall35e78fc2012-04-05 14:18:44 -07002419static DEFINE_CLK_VOTER(ebi_dtv_clk, &ebi1_fixed_clk.c, 0);
2420static DEFINE_CLK_VOTER(ebi_grp_3d_clk, &ebi1_fixed_clk.c, 0);
2421static DEFINE_CLK_VOTER(ebi_grp_2d_clk, &ebi1_fixed_clk.c, 0);
2422static DEFINE_CLK_VOTER(ebi_lcdc_clk, &ebi1_fixed_clk.c, 0);
2423static DEFINE_CLK_VOTER(ebi_mddi_clk, &ebi1_fixed_clk.c, 0);
2424static DEFINE_CLK_VOTER(ebi_tv_clk, &ebi1_fixed_clk.c, 0);
2425static DEFINE_CLK_VOTER(ebi_vcd_clk, &ebi1_fixed_clk.c, 0);
2426static DEFINE_CLK_VOTER(ebi_vfe_clk, &ebi1_fixed_clk.c, 0);
2427static DEFINE_CLK_VOTER(ebi_adm_clk, &ebi1_fixed_clk.c, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002428
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002429#ifdef CONFIG_DEBUG_FS
2430
2431#define CLK_TEST_2(s) (s)
2432#define CLK_TEST_HS(s) (0x4000 | ((s) << 8))
2433#define CLK_TEST_LS(s) (0x4D40 | (s))
2434
2435struct measure_sel {
2436 u32 test_vector;
2437 struct clk *clk;
2438};
2439
2440static struct measure_sel measure_mux[] = {
2441 { CLK_TEST_2(0x03), &emdh_p_clk.c },
2442 { CLK_TEST_2(0x04), &pmdh_p_clk.c },
2443 { CLK_TEST_2(0x06), &mdp_p_clk.c },
2444 { CLK_TEST_2(0x07), &lpa_p_clk.c },
2445 { CLK_TEST_2(0x08), &usb_hs2_p_clk.c },
2446 { CLK_TEST_2(0x09), &spi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002447 { CLK_TEST_2(0x0B), &i2c_2_clk.c },
2448 { CLK_TEST_2(0x0D), &mi2s_m_clk.c },
2449 { CLK_TEST_2(0x0E), &lpa_core_clk.c },
2450 { CLK_TEST_2(0x0F), &lpa_codec_clk.c },
2451 { CLK_TEST_2(0x10), &usb_hs3_p_clk.c },
2452 { CLK_TEST_2(0x11), &adm_p_clk.c },
2453 { CLK_TEST_2(0x13), &hdmi_clk.c },
2454 { CLK_TEST_2(0x14), &usb_hs_core_clk.c },
2455 { CLK_TEST_2(0x15), &usb_hs2_core_clk.c },
2456 { CLK_TEST_2(0x16), &usb_hs3_core_clk.c },
2457 { CLK_TEST_2(0x17), &mi2s_codec_tx_s_clk.c },
2458 { CLK_TEST_2(0x18), &spi_p_clk.c },
2459 { CLK_TEST_2(0x1A), &camif_pad_p_clk.c },
2460 { CLK_TEST_2(0x1C), &qup_i2c_clk.c },
2461 { CLK_TEST_2(0x1F), &mfc_div2_clk.c },
2462 { CLK_TEST_2(0x38), &mfc_clk.c },
2463
2464 { CLK_TEST_HS(0x00), &adm_clk.c },
2465 { CLK_TEST_HS(0x01), &mdp_lcdc_pad_pclk_clk.c },
2466 { CLK_TEST_HS(0x02), &mdp_lcdc_pclk_clk.c },
2467 { CLK_TEST_HS(0x03), &axi_rotator_clk.c },
2468 { CLK_TEST_HS(0x07), &axi_li_vg_clk.c },
2469 { CLK_TEST_HS(0x09), &axi_li_apps_clk.c },
2470 { CLK_TEST_HS(0x0E), &axi_li_jpeg_clk.c },
2471 { CLK_TEST_HS(0x0F), &emdh_clk.c },
2472 { CLK_TEST_HS(0x14), &mdp_clk.c },
2473 { CLK_TEST_HS(0x15), &pmdh_clk.c },
2474 { CLK_TEST_HS(0x19), &axi_grp_2d_clk.c },
2475 { CLK_TEST_HS(0x1A), &axi_li_grp_clk.c },
2476 { CLK_TEST_HS(0x1B), &axi_li_vfe_clk.c },
2477 { CLK_TEST_HS(0x1C), &grp_2d_clk.c },
2478 { CLK_TEST_HS(0x1E), &grp_3d_clk.c },
2479 { CLK_TEST_HS(0x1F), &imem_clk.c },
2480 { CLK_TEST_HS(0x20), &jpeg_clk.c },
2481 { CLK_TEST_HS(0x24), &axi_li_adsp_a_clk.c },
2482 { CLK_TEST_HS(0x26), &rotator_imem_clk.c },
2483 { CLK_TEST_HS(0x27), &axi_vpe_clk.c },
2484 { CLK_TEST_HS(0x2A), &axi_mfc_clk.c },
2485 { CLK_TEST_HS(0x2B), &axi_mdp_clk.c },
2486 { CLK_TEST_HS(0x2C), &vpe_clk.c },
2487 { CLK_TEST_HS(0x30), &vfe_camif_clk.c },
2488 { CLK_TEST_HS(0x31), &csi0_clk.c },
2489 { CLK_TEST_HS(0x32), &csi0_vfe_clk.c },
2490 { CLK_TEST_HS(0x33), &csi0_p_clk.c },
2491
2492 { CLK_TEST_LS(0x03), &ce_clk.c },
2493 { CLK_TEST_LS(0x04), &cam_m_clk.c },
2494 { CLK_TEST_LS(0x0C), &grp_2d_p_clk.c },
2495 { CLK_TEST_LS(0x0D), &i2c_clk.c },
2496 { CLK_TEST_LS(0x0E), &mi2s_codec_rx_m_clk.c },
2497 { CLK_TEST_LS(0x0F), &mi2s_codec_rx_s_clk.c },
2498 { CLK_TEST_LS(0x10), &mi2s_codec_tx_m_clk.c },
2499 { CLK_TEST_LS(0x13), &mdp_vsync_clk.c },
2500 { CLK_TEST_LS(0x15), &vfe_p_clk.c },
2501 { CLK_TEST_LS(0x16), &mdc_clk.c },
2502 { CLK_TEST_LS(0x17), &vfe_mdc_clk.c },
2503 { CLK_TEST_LS(0x18), &usb_hs_p_clk.c },
2504 { CLK_TEST_LS(0x1C), &uart1dm_p_clk.c },
2505 { CLK_TEST_LS(0x1E), &jpeg_p_clk.c },
2506 { CLK_TEST_LS(0x20), &sdac_clk.c },
2507 { CLK_TEST_LS(0x21), &sdc1_p_clk.c },
2508 { CLK_TEST_LS(0x22), &sdc1_clk.c },
2509 { CLK_TEST_LS(0x23), &sdc2_p_clk.c },
2510 { CLK_TEST_LS(0x24), &sdc2_clk.c },
2511 { CLK_TEST_LS(0x25), &tsif_p_clk.c },
2512 { CLK_TEST_LS(0x26), &sdac_m_clk.c },
2513 { CLK_TEST_LS(0x27), &grp_3d_p_clk.c },
2514 { CLK_TEST_LS(0x2A), &tsif_ref_clk.c },
2515 { CLK_TEST_LS(0x2B), &tv_enc_clk.c },
2516 { CLK_TEST_LS(0x2C), &tv_dac_clk.c },
2517 { CLK_TEST_LS(0x2D), &rotator_p_clk.c },
2518 { CLK_TEST_LS(0x2F), &uart1_clk.c },
2519 { CLK_TEST_LS(0x30), &uart1dm_clk.c },
2520 { CLK_TEST_LS(0x31), &uart2_clk.c },
2521 { CLK_TEST_LS(0x33), &usb_hs2_clk.c },
2522 { CLK_TEST_LS(0x34), &usb_hs3_clk.c },
2523 { CLK_TEST_LS(0x35), &mfc_p_clk.c },
2524 { CLK_TEST_LS(0x36), &vfe_clk.c },
2525 { CLK_TEST_LS(0x39), &sdc3_p_clk.c },
2526 { CLK_TEST_LS(0x3A), &sdc3_clk.c },
2527 { CLK_TEST_LS(0x3B), &sdc4_p_clk.c },
2528 { CLK_TEST_LS(0x3C), &sdc4_clk.c },
2529 { CLK_TEST_LS(0x3D), &uart2dm_clk.c },
2530 { CLK_TEST_LS(0x3E), &uart2dm_p_clk.c },
2531 { CLK_TEST_LS(0x3F), &usb_hs_clk.c },
2532};
2533
2534static struct measure_sel *find_measure_sel(struct clk *clk)
2535{
2536 int i;
2537
2538 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
2539 if (measure_mux[i].clk == clk)
2540 return &measure_mux[i];
2541 return NULL;
2542}
2543
2544static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
2545{
2546 struct measure_sel *p;
2547 unsigned long flags;
2548
2549 if (!parent)
2550 return -EINVAL;
2551
2552 p = find_measure_sel(parent);
2553 if (!p)
2554 return -EINVAL;
2555
2556 spin_lock_irqsave(&local_clock_reg_lock, flags);
2557
2558 /* Program test vector. */
2559 if (p->test_vector <= 0xFF) {
2560 /* Select CLK_TEST_2 */
2561 writel_relaxed(0x4D40, CLK_TEST_BASE_REG);
2562 writel_relaxed(p->test_vector, CLK_TEST_2_BASE_REG);
2563 } else
2564 writel_relaxed(p->test_vector, CLK_TEST_BASE_REG);
2565
2566 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2567
2568 return 0;
2569}
2570
2571/* Sample clock for 'tcxo4_ticks' reference clock ticks. */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002572static unsigned long run_measurement(unsigned tcxo4_ticks)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002573{
2574 /* TCXO4_CNT_EN and RINGOSC_CNT_EN register values. */
2575 u32 reg_val_enable = readl_relaxed(MISC_CLK_CTL_BASE_REG) | 0x3;
2576 u32 reg_val_disable = reg_val_enable & ~0x3;
2577
2578 /* Stop counters and set the TCXO4 counter start value. */
2579 writel_relaxed(reg_val_disable, MISC_CLK_CTL_BASE_REG);
2580 writel_relaxed(tcxo4_ticks, TCXO_CNT_BASE_REG);
2581
2582 /* Run measurement and wait for completion. */
2583 writel_relaxed(reg_val_enable, MISC_CLK_CTL_BASE_REG);
2584 while (readl_relaxed(TCXO_CNT_DONE_BASE_REG) == 0)
2585 cpu_relax();
2586
2587 /* Stop counters. */
2588 writel_relaxed(reg_val_disable, MISC_CLK_CTL_BASE_REG);
2589
2590 return readl_relaxed(RINGOSC_CNT_BASE_REG);
2591}
2592
2593/* Perform a hardware rate measurement for a given clock.
2594 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002595static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002596{
2597 unsigned long flags;
2598 u32 regval, prph_web_reg_old;
2599 u64 raw_count_short, raw_count_full;
2600 unsigned ret;
2601
Stephen Boyde334aeb2012-01-24 12:17:29 -08002602 clk_prepare_enable(&tcxo_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002603
2604 spin_lock_irqsave(&local_clock_reg_lock, flags);
2605
2606 /* Enable TCXO4 clock branch and root. */
2607 prph_web_reg_old = readl_relaxed(PRPH_WEB_NS_BASE_REG);
2608 regval = prph_web_reg_old | BIT(9) | BIT(11);
2609 writel_relaxed(regval, PRPH_WEB_NS_BASE_REG);
2610
2611 /*
2612 * The ring oscillator counter will not reset if the measured clock
2613 * is not running. To detect this, run a short measurement before
2614 * the full measurement. If the raw results of the two are the same
2615 * then the clock must be off.
2616 */
2617
2618 /* Run a short measurement. (~1 ms) */
2619 raw_count_short = run_measurement(0x1000);
2620 /* Run a full measurement. (~14 ms) */
2621 raw_count_full = run_measurement(0x10000);
2622
2623 /* Disable TCXO4 clock branch and root. */
2624 writel_relaxed(prph_web_reg_old, PRPH_WEB_NS_BASE_REG);
2625
2626 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2627
2628 /* Return 0 if the clock is off. */
2629 if (raw_count_full == raw_count_short)
2630 ret = 0;
2631 else {
2632 /* Compute rate in Hz. */
2633 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
2634 do_div(raw_count_full, ((0x10000 * 10) + 35));
2635 ret = raw_count_full;
2636 }
2637
Stephen Boyde334aeb2012-01-24 12:17:29 -08002638 clk_disable_unprepare(&tcxo_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002639
2640 return ret;
2641}
2642#else /* !CONFIG_DEBUG_FS */
2643static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
2644{
2645 return -EINVAL;
2646}
2647
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002648static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002649{
2650 return 0;
2651}
2652#endif /* CONFIG_DEBUG_FS */
2653
2654static struct clk_ops measure_clk_ops = {
2655 .set_parent = measure_clk_set_parent,
2656 .get_rate = measure_clk_get_rate,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002657};
2658
2659static struct clk measure_clk = {
2660 .dbg_name = "measure_clk",
2661 .ops = &measure_clk_ops,
2662 CLK_INIT(measure_clk),
2663};
2664
2665/* Implementation for clk_set_flags(). */
2666int soc_clk_set_flags(struct clk *clk, unsigned clk_flags)
2667{
2668 uint32_t regval, ret = 0;
2669 unsigned long flags;
2670
2671 spin_lock_irqsave(&local_clock_reg_lock, flags);
2672
2673 if (clk == &vfe_clk.c) {
2674 regval = readl_relaxed(CAM_VFE_NS_REG);
2675 /* Flag values chosen for backward compatibility
2676 * with proc_comm remote clock control. */
2677 if (clk_flags == 0x00000100) {
2678 /* Select external source. */
2679 regval |= BIT(14);
2680 } else if (clk_flags == 0x00000200) {
2681 /* Select internal source. */
2682 regval &= ~BIT(14);
2683 } else
2684 ret = -EINVAL;
2685
2686 writel_relaxed(regval, CAM_VFE_NS_REG);
2687 /* Make sure write is issued before returning. */
2688 mb();
2689 } else
2690 ret = -EPERM;
2691
2692 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2693
2694 return ret;
2695}
2696
2697static int msm7x30_clk_reset(struct clk *clk, enum clk_reset_action action)
2698{
2699 /* reset_mask is actually a proc_comm id */
2700 unsigned id = to_rcg_clk(clk)->b.reset_mask;
2701 return pc_clk_reset(id, action);
2702}
2703
2704static int soc_branch_clk_reset(struct clk *clk, enum clk_reset_action action)
2705{
2706 unsigned id = to_branch_clk(clk)->b.reset_mask;
2707 return pc_clk_reset(id, action);
2708}
2709
2710/*
2711 * Clock ownership detection code
2712 */
2713
2714enum {
2715 SH2_OWN_GLBL,
2716 SH2_OWN_APPS1,
2717 SH2_OWN_APPS2,
2718 SH2_OWN_ROW1,
2719 SH2_OWN_ROW2,
2720 SH2_OWN_APPS3,
2721 NUM_OWNERSHIP
2722};
2723static __initdata uint32_t ownership_regs[NUM_OWNERSHIP];
2724
2725static void __init cache_ownership(void)
2726{
2727 ownership_regs[SH2_OWN_GLBL] = readl_relaxed(SH2_OWN_GLBL_BASE_REG);
2728 ownership_regs[SH2_OWN_APPS1] = readl_relaxed(SH2_OWN_APPS1_BASE_REG);
2729 ownership_regs[SH2_OWN_APPS2] = readl_relaxed(SH2_OWN_APPS2_BASE_REG);
2730 ownership_regs[SH2_OWN_ROW1] = readl_relaxed(SH2_OWN_ROW1_BASE_REG);
2731 ownership_regs[SH2_OWN_ROW2] = readl_relaxed(SH2_OWN_ROW2_BASE_REG);
2732 ownership_regs[SH2_OWN_APPS3] = readl_relaxed(SH2_OWN_APPS3_BASE_REG);
2733}
2734
2735static void __init print_ownership(void)
2736{
2737 pr_info("Clock ownership\n");
2738 pr_info(" GLBL : %08x\n", ownership_regs[SH2_OWN_GLBL]);
2739 pr_info(" APPS : %08x %08x %08x\n", ownership_regs[SH2_OWN_APPS1],
2740 ownership_regs[SH2_OWN_APPS2], ownership_regs[SH2_OWN_APPS3]);
2741 pr_info(" ROW : %08x %08x\n", ownership_regs[SH2_OWN_ROW1],
2742 ownership_regs[SH2_OWN_ROW2]);
2743}
2744
2745#define O(x) (&ownership_regs[(SH2_OWN_##x)])
2746#define OWN(r, b, name, clk, dev) \
2747 { \
2748 .lk = CLK_LOOKUP(name, clk.c, dev), \
2749 .remote = &p_##clk.c, \
2750 .reg = O(r), \
2751 .bit = BIT(b), \
2752 }
2753
2754static struct clk_local_ownership {
2755 struct clk_lookup lk;
2756 const u32 *reg;
2757 const u32 bit;
2758 struct clk *remote;
2759} ownership_map[] __initdata = {
2760 /* Sources */
2761 { CLK_LOOKUP("pll1_clk", pll1_clk.c, "acpu") },
2762 { CLK_LOOKUP("pll2_clk", pll2_clk.c, "acpu") },
2763 { CLK_LOOKUP("pll3_clk", pll3_clk.c, "acpu") },
2764 { CLK_LOOKUP("measure", measure_clk, "debug") },
2765
2766 /* PCOM */
2767 { CLK_LOOKUP("adsp_clk", adsp_clk.c, NULL) },
2768 { CLK_LOOKUP("codec_ssbi_clk", codec_ssbi_clk.c, NULL) },
2769 { CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL) },
2770 { CLK_LOOKUP("ebi1_fixed_clk", ebi1_fixed_clk.c, NULL) },
2771 { CLK_LOOKUP("ecodec_clk", ecodec_clk.c, NULL) },
Matt Wagantallc00f95d2012-01-05 14:22:45 -08002772 { CLK_LOOKUP("core_clk", gp_clk.c, "") },
Matt Wagantalle2522372011-08-17 14:52:21 -07002773 { CLK_LOOKUP("core_clk", uart3_clk.c, "msm_serial.2") },
Manu Gautam5143b252012-01-05 19:25:23 -08002774 { CLK_LOOKUP("phy_clk", usb_phy_clk.c, "msm_otg") },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002775
2776 /* Voters */
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07002777 { CLK_LOOKUP("mem_clk", ebi_dtv_clk.c, "dtv.0") },
Matt Wagantall9dc01632011-08-17 18:55:04 -07002778 { CLK_LOOKUP("bus_clk", ebi_grp_2d_clk.c, "kgsl-2d0.0") },
2779 { CLK_LOOKUP("bus_clk", ebi_grp_3d_clk.c, "kgsl-3d0.0") },
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07002780 { CLK_LOOKUP("mem_clk", ebi_lcdc_clk.c, "lcdc.0") },
2781 { CLK_LOOKUP("mem_clk", ebi_mddi_clk.c, "mddi.0") },
2782 { CLK_LOOKUP("mem_clk", ebi_tv_clk.c, "tvenc.0") },
Matt Wagantall3f7660b2011-08-17 21:25:13 -07002783 { CLK_LOOKUP("mem_clk", ebi_vcd_clk.c, "msm_vidc.0") },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002784 { CLK_LOOKUP("ebi1_vfe_clk", ebi_vfe_clk.c, NULL) },
Matt Wagantalle1a86062011-08-18 17:46:10 -07002785 { CLK_LOOKUP("mem_clk", ebi_adm_clk.c, "msm_dmov") },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002786
2787 /*
2788 * This is a many-to-one mapping because we don't know how the remote
2789 * clock code has decided to handle the dependencies between clocks for
2790 * a particular hardware block. We determine the ownership for all the
2791 * clocks going into a block by checking the ownership bit of one
2792 * register (usually the ns register).
2793 */
Matt Wagantall9dc01632011-08-17 18:55:04 -07002794 OWN(APPS1, 6, "core_clk", grp_2d_clk, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002795 OWN(APPS1, 6, "core_clk", grp_2d_clk, "footswitch-pcom.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07002796 OWN(APPS1, 6, "iface_clk", grp_2d_p_clk, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002797 OWN(APPS1, 6, "iface_clk", grp_2d_p_clk, "footswitch-pcom.0"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07002798 OWN(APPS1, 31, "hdmi_clk", hdmi_clk, "dtv.0"),
Matt Wagantallf45cd362012-05-03 21:09:44 -07002799 OWN(APPS1, 0, "core_clk", jpeg_clk, "msm_gemini.0"),
2800 OWN(APPS1, 0, "iface_clk", jpeg_p_clk, "msm_gemini.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002801 OWN(APPS1, 23, "lpa_codec_clk", lpa_codec_clk, NULL),
2802 OWN(APPS1, 23, "lpa_core_clk", lpa_core_clk, NULL),
2803 OWN(APPS1, 23, "lpa_pclk", lpa_p_clk, NULL),
2804 OWN(APPS1, 28, "mi2s_m_clk", mi2s_m_clk, NULL),
2805 OWN(APPS1, 28, "mi2s_s_clk", mi2s_s_clk, NULL),
2806 OWN(APPS1, 12, "mi2s_codec_rx_m_clk", mi2s_codec_rx_m_clk, NULL),
2807 OWN(APPS1, 12, "mi2s_codec_rx_s_clk", mi2s_codec_rx_s_clk, NULL),
2808 OWN(APPS1, 14, "mi2s_codec_tx_m_clk", mi2s_codec_tx_m_clk, NULL),
2809 OWN(APPS1, 14, "mi2s_codec_tx_s_clk", mi2s_codec_tx_s_clk, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002810 OWN(APPS1, 26, "sdac_clk", sdac_clk, NULL),
2811 OWN(APPS1, 26, "sdac_m_clk", sdac_m_clk, NULL),
2812 OWN(APPS1, 8, "vfe_clk", vfe_clk, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07002813 OWN(APPS1, 8, "core_clk", vfe_clk, "footswitch-pcom.8"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002814 OWN(APPS1, 8, "vfe_camif_clk", vfe_camif_clk, NULL),
2815 OWN(APPS1, 8, "vfe_mdc_clk", vfe_mdc_clk, NULL),
2816 OWN(APPS1, 8, "vfe_pclk", vfe_p_clk, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07002817 OWN(APPS1, 8, "iface_clk", vfe_p_clk, "footswitch-pcom.8"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002818
Matt Wagantall9dc01632011-08-17 18:55:04 -07002819 OWN(APPS2, 0, "core_clk", grp_3d_clk, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002820 OWN(APPS2, 0, "core_clk", grp_3d_clk, "footswitch-pcom.2"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07002821 OWN(APPS2, 0, "iface_clk", grp_3d_p_clk, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002822 OWN(APPS2, 0, "iface_clk", grp_3d_p_clk, "footswitch-pcom.2"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07002823 { CLK_LOOKUP("src_clk", grp_3d_src_clk.c, "kgsl-3d0.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002824 O(APPS2), BIT(0), &p_grp_3d_clk.c },
Matt Wagantall49722712011-08-17 18:50:53 -07002825 { CLK_LOOKUP("src_clk", grp_3d_src_clk.c, "footswitch-pcom.2"),
2826 O(APPS2), BIT(0), &p_grp_3d_clk.c },
Matt Wagantall9dc01632011-08-17 18:55:04 -07002827 OWN(APPS2, 0, "mem_clk", imem_clk, "kgsl-3d0.0"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07002828 OWN(APPS2, 4, "lcdc_clk", mdp_lcdc_pad_pclk_clk, "lcdc.0"),
2829 OWN(APPS2, 4, "mdp_clk", mdp_lcdc_pclk_clk, "lcdc.0"),
2830 OWN(APPS2, 4, "iface_clk", mdp_p_clk, "mdp.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002831 OWN(APPS2, 4, "iface_clk", mdp_p_clk, "footswitch-pcom.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07002832 OWN(APPS2, 28, "vsync_clk", mdp_vsync_clk, "mdp.0"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07002833 OWN(APPS2, 5, "ref_clk", tsif_ref_clk, "msm_tsif.0"),
2834 OWN(APPS2, 5, "iface_clk", tsif_p_clk, "msm_tsif.0"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07002835 { CLK_LOOKUP("src_clk", tv_clk.c, "dtv.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002836 O(APPS2), BIT(2), &p_tv_enc_clk.c },
2837 OWN(APPS2, 2, "tv_dac_clk", tv_dac_clk, NULL),
2838 OWN(APPS2, 2, "tv_enc_clk", tv_enc_clk, NULL),
2839
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07002840 OWN(ROW1, 7, "core_clk", emdh_clk, "msm_mddi.1"),
2841 OWN(ROW1, 7, "iface_clk", emdh_p_clk, "msm_mddi.1"),
Matt Wagantallac294852011-08-17 15:44:58 -07002842 OWN(ROW1, 11, "core_clk", i2c_clk, "msm_i2c.0"),
2843 OWN(ROW1, 12, "core_clk", i2c_2_clk, "msm_i2c.2"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002844 OWN(ROW1, 17, "mdc_clk", mdc_clk, NULL),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07002845 OWN(ROW1, 19, "core_clk", pmdh_clk, "mddi.0"),
2846 OWN(ROW1, 19, "iface_clk", pmdh_p_clk, "mddi.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07002847 OWN(ROW1, 23, "core_clk", sdc1_clk, "msm_sdcc.1"),
2848 OWN(ROW1, 23, "iface_clk", sdc1_p_clk, "msm_sdcc.1"),
2849 OWN(ROW1, 25, "core_clk", sdc2_clk, "msm_sdcc.2"),
2850 OWN(ROW1, 25, "iface_clk", sdc2_p_clk, "msm_sdcc.2"),
2851 OWN(ROW1, 27, "core_clk", sdc3_clk, "msm_sdcc.3"),
2852 OWN(ROW1, 27, "iface_clk", sdc3_p_clk, "msm_sdcc.3"),
2853 OWN(ROW1, 29, "core_clk", sdc4_clk, "msm_sdcc.4"),
2854 OWN(ROW1, 29, "iface_clk", sdc4_p_clk, "msm_sdcc.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07002855 OWN(ROW1, 0, "core_clk", uart2_clk, "msm_serial.1"),
Manu Gautam5143b252012-01-05 19:25:23 -08002856 OWN(ROW1, 2, "alt_core_clk", usb_hs2_clk, "msm_hsusb_host.0"),
2857 OWN(ROW1, 2, "core_clk", usb_hs2_core_clk, "msm_hsusb_host.0"),
2858 OWN(ROW1, 2, "iface_clk", usb_hs2_p_clk, "msm_hsusb_host.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08002859 OWN(ROW1, 4, "alt_core_clk", usb_hs3_clk, ""),
2860 OWN(ROW1, 4, "core_clk", usb_hs3_core_clk, ""),
2861 OWN(ROW1, 4, "iface_clk", usb_hs3_p_clk, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002862
Matt Wagantallac294852011-08-17 15:44:58 -07002863 OWN(ROW2, 3, "core_clk", qup_i2c_clk, "qup_i2c.4"),
2864 OWN(ROW2, 1, "core_clk", spi_clk, "spi_qsd.0"),
2865 OWN(ROW2, 1, "iface_clk", spi_p_clk, "spi_qsd.0"),
Matt Wagantalle2522372011-08-17 14:52:21 -07002866 OWN(ROW2, 9, "core_clk", uart1_clk, "msm_serial.0"),
2867 OWN(ROW2, 6, "core_clk", uart1dm_clk, "msm_serial_hs.0"),
2868 OWN(ROW2, 8, "core_clk", uart2dm_clk, "msm_serial_hs.1"),
Manu Gautam5143b252012-01-05 19:25:23 -08002869 OWN(ROW2, 11, "alt_core_clk", usb_hs_clk, "msm_otg"),
2870 OWN(ROW2, 11, "core_clk", usb_hs_core_clk, "msm_otg"),
2871 OWN(ROW2, 11, "iface_clk", usb_hs_p_clk, "msm_otg"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002872
2873 OWN(APPS3, 6, "cam_m_clk", cam_m_clk, NULL),
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07002874 OWN(APPS3, 6, "cam_clk", cam_m_clk, "4-0020"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002875 OWN(APPS3, 6, "camif_pad_pclk", camif_pad_p_clk, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07002876 OWN(APPS3, 6, "iface_clk", camif_pad_p_clk, "qup_i2c.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002877 OWN(APPS3, 11, "csi_clk", csi0_clk, NULL),
2878 OWN(APPS3, 11, "csi_vfe_clk", csi0_vfe_clk, NULL),
2879 OWN(APPS3, 11, "csi_pclk", csi0_p_clk, NULL),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07002880 OWN(APPS3, 0, "core_clk", mdp_clk, "mdp.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002881 OWN(APPS3, 0, "core_clk", mdp_clk, "footswitch-pcom.4"),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07002882 OWN(APPS3, 2, "core_clk", mfc_clk, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002883 OWN(APPS3, 2, "core_clk", mfc_clk, "footswitch-pcom.5"),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07002884 OWN(APPS3, 2, "core_div2_clk", mfc_div2_clk, "msm_vidc.0"),
2885 OWN(APPS3, 2, "iface_clk", mfc_p_clk, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002886 OWN(APPS3, 2, "iface_clk", mfc_p_clk, "footswitch-pcom.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002887 OWN(APPS3, 4, "vpe_clk", vpe_clk, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07002888 OWN(APPS3, 4, "core_clk", vpe_clk, "footswitch-pcom.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002889
Matt Wagantalle1a86062011-08-18 17:46:10 -07002890 OWN(GLBL, 8, "core_clk", adm_clk, "msm_dmov"),
2891 { CLK_LOOKUP("iface_clk", adm_p_clk.c, "msm_dmov"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002892 O(GLBL), BIT(13), &dummy_clk },
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07002893 OWN(GLBL, 8, "core_clk", ce_clk, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07002894 OWN(GLBL, 8, "core_clk", ce_clk, "crypto.0"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07002895 OWN(GLBL, 13, "core_clk", axi_rotator_clk, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002896 OWN(GLBL, 13, "core_clk", axi_rotator_clk, "footswitch-pcom.6"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07002897 OWN(GLBL, 13, "mem_clk", rotator_imem_clk, "msm_rotator.0"),
2898 OWN(GLBL, 13, "iface_clk", rotator_p_clk, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07002899 OWN(GLBL, 13, "iface_clk", rotator_p_clk, "footswitch-pcom.6"),
Matt Wagantalle2522372011-08-17 14:52:21 -07002900 { CLK_LOOKUP("iface_clk", uart1dm_p_clk.c, "msm_serial_hs.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002901 O(GLBL), BIT(8), &dummy_clk },
Matt Wagantalle2522372011-08-17 14:52:21 -07002902 { CLK_LOOKUP("iface_clk", uart2dm_p_clk.c, "msm_serial_hs.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002903 O(GLBL), BIT(8), &dummy_clk },
2904};
2905
2906static struct clk_lookup msm_clocks_7x30[ARRAY_SIZE(ownership_map)];
2907
2908static void __init set_clock_ownership(void)
2909{
2910 unsigned i;
2911 struct clk_lookup *lk;
2912
2913 for (i = 0; i < ARRAY_SIZE(ownership_map); i++) {
2914 const u32 *reg = ownership_map[i].reg;
2915 u32 bit = ownership_map[i].bit;
2916 struct clk *remote = ownership_map[i].remote;
2917
2918 lk = &ownership_map[i].lk;
2919 memcpy(&msm_clocks_7x30[i], lk, sizeof(*lk));
2920
2921 if (reg && !(*reg & bit))
2922 msm_clocks_7x30[i].clk = remote;
2923 }
2924}
2925
2926/*
2927 * Miscellaneous clock register initializations
2928 */
2929static const struct reg_init {
2930 const void __iomem *reg;
2931 uint32_t mask;
2932 uint32_t val;
2933} ri_list[] __initconst = {
2934 /* Enable UMDX_P clock. Known to causes issues, so never turn off. */
2935 {GLBL_CLK_ENA_2_SC_REG, BIT(2), BIT(2)},
2936
2937 /* Disable all the child clocks of USB_HS_SRC. */
2938 { USBH_NS_REG, BIT(13) | BIT(9), 0 },
2939 { USBH2_NS_REG, BIT(9) | BIT(4), 0 },
2940 { USBH3_NS_REG, BIT(9) | BIT(4), 0 },
2941
2942 {EMDH_NS_REG, BM(18, 17) , BVAL(18, 17, 0x3)}, /* RX div = div-4. */
2943 {PMDH_NS_REG, BM(18, 17), BVAL(18, 17, 0x3)}, /* RX div = div-4. */
2944 /* MI2S_CODEC_RX_S src = MI2S_CODEC_RX_M. */
2945 {MI2S_RX_NS_REG, BIT(14), 0x0},
2946 /* MI2S_CODEC_TX_S src = MI2S_CODEC_TX_M. */
2947 {MI2S_TX_NS_REG, BIT(14), 0x0},
2948 {MI2S_NS_REG, BIT(14), 0x0}, /* MI2S_S src = MI2S_M. */
2949 /* Allow DSP to decide the LPA CORE src. */
2950 {LPA_CORE_CLK_MA0_REG, BIT(0), BIT(0)},
2951 {LPA_CORE_CLK_MA2_REG, BIT(0), BIT(0)},
2952 {MI2S_CODEC_RX_DIV_REG, 0xF, 0xD}, /* MI2S_CODEC_RX_S div = div-8. */
2953 {MI2S_CODEC_TX_DIV_REG, 0xF, 0xD}, /* MI2S_CODEC_TX_S div = div-8. */
2954 {MI2S_DIV_REG, 0xF, 0x7}, /* MI2S_S div = div-8. */
2955 {MDC_NS_REG, 0x3, 0x3}, /* MDC src = external MDH src. */
2956 {SDAC_NS_REG, BM(15, 14), 0x0}, /* SDAC div = div-1. */
2957 /* Disable sources TCXO/5 & TCXO/6. UART1 src = TCXO*/
2958 {UART_NS_REG, BM(26, 25) | BM(2, 0), 0x0},
2959 /* HDMI div = div-1, non-inverted. tv_enc_src = tv_clk_src */
2960 {HDMI_NS_REG, 0x7, 0x0},
2961 {TV_NS_REG, BM(15, 14), 0x0}, /* tv_clk_src_div2 = div-1 */
2962
2963 /* USBH core clocks src = USB_HS_SRC. */
2964 {USBH_NS_REG, BIT(15), BIT(15)},
2965 {USBH2_NS_REG, BIT(6), BIT(6)},
2966 {USBH3_NS_REG, BIT(6), BIT(6)},
2967};
2968
Matt Wagantallb64888f2012-04-02 21:35:07 -07002969static void __init msm7x30_clock_pre_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002970{
2971 int i;
2972 uint32_t val;
2973
Stephen Boyd409b8b42012-04-10 12:12:56 -07002974 clk_ops_branch.reset = soc_branch_clk_reset;
2975 clk_ops_rcg.reset = msm7x30_clk_reset;
2976 clk_ops_rcg.set_flags = soc_clk_set_flags;
2977
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002978 cache_ownership();
2979 print_ownership();
2980 set_clock_ownership();
2981
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002982 /* When we have no local clock control, the rest of the code in this
2983 * function is a NOP since writes to shadow regions that we don't own
2984 * are ignored. */
2985
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002986 for (i = 0; i < ARRAY_SIZE(ri_list); i++) {
2987 val = readl_relaxed(ri_list[i].reg);
2988 val &= ~ri_list[i].mask;
2989 val |= ri_list[i].val;
2990 writel_relaxed(val, ri_list[i].reg);
2991 }
Matt Wagantallb64888f2012-04-02 21:35:07 -07002992}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002993
Matt Wagantallb64888f2012-04-02 21:35:07 -07002994static void __init msm7x30_clock_post_init(void)
2995{
2996 clk_set_rate(&usb_hs_src_clk.c, 60000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002997 clk_set_rate(&i2c_clk.c, 19200000);
2998 clk_set_rate(&i2c_2_clk.c, 19200000);
2999 clk_set_rate(&qup_i2c_clk.c, 19200000);
3000 clk_set_rate(&uart1_clk.c, 19200000);
3001 clk_set_rate(&uart2_clk.c, 19200000);
3002 clk_set_rate(&mi2s_m_clk.c, 12288000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003003 clk_set_rate(&mdp_vsync_clk.c, 24576000);
3004 clk_set_rate(&glbl_root_clk.c, 1);
3005 clk_set_rate(&mdc_clk.c, 1);
3006 /* Sync the LPA_CODEC clock to MI2S_CODEC_RX */
3007 clk_set_rate(&lpa_codec_clk.c, 1);
3008 /* Sync the GRP2D clock to AXI */
3009 clk_set_rate(&grp_2d_clk.c, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003010}
3011
Stephen Boydbb600ae2011-08-02 20:11:40 -07003012struct clock_init_data msm7x30_clock_init_data __initdata = {
3013 .table = msm_clocks_7x30,
3014 .size = ARRAY_SIZE(msm_clocks_7x30),
Matt Wagantallb64888f2012-04-02 21:35:07 -07003015 .pre_init = msm7x30_clock_pre_init,
3016 .post_init = msm7x30_clock_post_init,
Stephen Boydbb600ae2011-08-02 20:11:40 -07003017};