blob: 975587dade6fb7cdc7014421c8d4144872e286e4 [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
25#include <mach/msm_iomap.h>
26#include <mach/clk.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070027#include <mach/scm-io.h>
28#include <mach/rpm.h>
29#include <mach/rpm-regulator.h>
30
31#include "clock-local.h"
32#include "clock-rpm.h"
33#include "clock-voter.h"
Vikram Mulukutla681d8682012-03-09 23:56:20 -080034#include "clock-pll.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070035
36#ifdef CONFIG_MSM_SECURE_IO
37#undef readl_relaxed
38#undef writel_relaxed
39#define readl_relaxed secure_readl
40#define writel_relaxed secure_writel
41#endif
42
43#define REG(off) (MSM_CLK_CTL_BASE + (off))
44#define REG_MM(off) (MSM_MMSS_CLK_CTL_BASE + (off))
45#define REG_LPA(off) (MSM_LPASS_CLK_CTL_BASE + (off))
46
47/* Peripheral clock registers. */
48#define CE2_HCLK_CTL_REG REG(0x2740)
49#define CLK_HALT_CFPB_STATEA_REG REG(0x2FCC)
50#define CLK_HALT_CFPB_STATEB_REG REG(0x2FD0)
51#define CLK_HALT_CFPB_STATEC_REG REG(0x2FD4)
52#define CLK_HALT_DFAB_STATE_REG REG(0x2FC8)
53#define CLK_HALT_MSS_SMPSS_MISC_STATE_REG REG(0x2FDC)
54#define CLK_HALT_SFPB_MISC_STATE_REG REG(0x2FD8)
55#define CLK_TEST_REG REG(0x2FA0)
Matt Wagantall66cd0932011-09-12 19:04:34 -070056#define EBI2_2X_CLK_CTL_REG REG(0x2660)
57#define EBI2_CLK_CTL_REG REG(0x2664)
Matt Wagantall7625a4c2011-11-01 16:17:53 -070058#define GPn_MD_REG(n) REG(0x2D00+(0x20*(n)))
59#define GPn_NS_REG(n) REG(0x2D24+(0x20*(n)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060#define GSBIn_HCLK_CTL_REG(n) REG(0x29C0+(0x20*((n)-1)))
61#define GSBIn_QUP_APPS_MD_REG(n) REG(0x29C8+(0x20*((n)-1)))
62#define GSBIn_QUP_APPS_NS_REG(n) REG(0x29CC+(0x20*((n)-1)))
63#define GSBIn_RESET_REG(n) REG(0x29DC+(0x20*((n)-1)))
64#define GSBIn_UART_APPS_MD_REG(n) REG(0x29D0+(0x20*((n)-1)))
65#define GSBIn_UART_APPS_NS_REG(n) REG(0x29D4+(0x20*((n)-1)))
66#define PDM_CLK_NS_REG REG(0x2CC0)
67#define BB_PLL_ENA_SC0_REG REG(0x34C0)
68#define BB_PLL0_STATUS_REG REG(0x30D8)
69#define BB_PLL6_STATUS_REG REG(0x3118)
70#define BB_PLL8_L_VAL_REG REG(0x3144)
71#define BB_PLL8_M_VAL_REG REG(0x3148)
72#define BB_PLL8_MODE_REG REG(0x3140)
73#define BB_PLL8_N_VAL_REG REG(0x314C)
74#define BB_PLL8_STATUS_REG REG(0x3158)
75#define PLLTEST_PAD_CFG_REG REG(0x2FA4)
76#define PMEM_ACLK_CTL_REG REG(0x25A0)
77#define PPSS_HCLK_CTL_REG REG(0x2580)
Stephen Boyd842a1f62012-04-26 19:07:38 -070078#define PRNG_CLK_NS_REG REG(0x2E80)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070079#define RINGOSC_NS_REG REG(0x2DC0)
80#define RINGOSC_STATUS_REG REG(0x2DCC)
81#define RINGOSC_TCXO_CTL_REG REG(0x2DC4)
82#define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080)
83#define SC1_U_CLK_BRANCH_ENA_VOTE_REG REG(0x30A0)
84#define SC0_U_CLK_SLEEP_ENA_VOTE_REG REG(0x3084)
85#define SC1_U_CLK_SLEEP_ENA_VOTE_REG REG(0x30A4)
86#define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1)))
87#define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1)))
88#define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1)))
89#define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1)))
90#define TSIF_HCLK_CTL_REG REG(0x2700)
91#define TSIF_REF_CLK_MD_REG REG(0x270C)
92#define TSIF_REF_CLK_NS_REG REG(0x2710)
93#define TSSC_CLK_CTL_REG REG(0x2CA0)
94#define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1)))
95#define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1)))
96#define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1)))
97#define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1)))
98#define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1)))
99#define USB_HS1_HCLK_CTL_REG REG(0x2900)
100#define USB_HS1_RESET_REG REG(0x2910)
101#define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908)
102#define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C)
103#define USB_PHY0_RESET_REG REG(0x2E20)
104
105/* Multimedia clock registers. */
106#define AHB_EN_REG REG_MM(0x0008)
107#define AHB_EN2_REG REG_MM(0x0038)
108#define AHB_NS_REG REG_MM(0x0004)
109#define AXI_NS_REG REG_MM(0x0014)
110#define CAMCLK_CC_REG REG_MM(0x0140)
111#define CAMCLK_MD_REG REG_MM(0x0144)
112#define CAMCLK_NS_REG REG_MM(0x0148)
113#define CSI_CC_REG REG_MM(0x0040)
114#define CSI_NS_REG REG_MM(0x0048)
115#define DBG_BUS_VEC_A_REG REG_MM(0x01C8)
116#define DBG_BUS_VEC_B_REG REG_MM(0x01CC)
117#define DBG_BUS_VEC_C_REG REG_MM(0x01D0)
118#define DBG_BUS_VEC_D_REG REG_MM(0x01D4)
119#define DBG_BUS_VEC_E_REG REG_MM(0x01D8)
120#define DBG_BUS_VEC_F_REG REG_MM(0x01DC)
121#define DBG_BUS_VEC_H_REG REG_MM(0x01E4)
Matt Wagantallf8032602011-06-15 23:01:56 -0700122#define DBG_BUS_VEC_I_REG REG_MM(0x01E8)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700123#define DBG_CFG_REG_HS_REG REG_MM(0x01B4)
124#define DBG_CFG_REG_LS_REG REG_MM(0x01B8)
125#define GFX2D0_CC_REG REG_MM(0x0060)
126#define GFX2D0_MD0_REG REG_MM(0x0064)
127#define GFX2D0_MD1_REG REG_MM(0x0068)
128#define GFX2D0_NS_REG REG_MM(0x0070)
129#define GFX2D1_CC_REG REG_MM(0x0074)
130#define GFX2D1_MD0_REG REG_MM(0x0078)
131#define GFX2D1_MD1_REG REG_MM(0x006C)
132#define GFX2D1_NS_REG REG_MM(0x007C)
133#define GFX3D_CC_REG REG_MM(0x0080)
134#define GFX3D_MD0_REG REG_MM(0x0084)
135#define GFX3D_MD1_REG REG_MM(0x0088)
136#define GFX3D_NS_REG REG_MM(0x008C)
137#define IJPEG_CC_REG REG_MM(0x0098)
138#define IJPEG_MD_REG REG_MM(0x009C)
139#define IJPEG_NS_REG REG_MM(0x00A0)
140#define JPEGD_CC_REG REG_MM(0x00A4)
141#define JPEGD_NS_REG REG_MM(0x00AC)
142#define MAXI_EN_REG REG_MM(0x0018)
Matt Wagantallf63a8892011-06-15 16:44:46 -0700143#define MAXI_EN2_REG REG_MM(0x0020)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700144#define MAXI_EN3_REG REG_MM(0x002C)
145#define MDP_CC_REG REG_MM(0x00C0)
146#define MDP_MD0_REG REG_MM(0x00C4)
147#define MDP_MD1_REG REG_MM(0x00C8)
148#define MDP_NS_REG REG_MM(0x00D0)
149#define MISC_CC_REG REG_MM(0x0058)
150#define MISC_CC2_REG REG_MM(0x005C)
151#define PIXEL_CC_REG REG_MM(0x00D4)
152#define PIXEL_CC2_REG REG_MM(0x0120)
153#define PIXEL_MD_REG REG_MM(0x00D8)
154#define PIXEL_NS_REG REG_MM(0x00DC)
155#define MM_PLL0_MODE_REG REG_MM(0x0300)
156#define MM_PLL1_MODE_REG REG_MM(0x031C)
157#define MM_PLL2_CONFIG_REG REG_MM(0x0348)
158#define MM_PLL2_L_VAL_REG REG_MM(0x033C)
159#define MM_PLL2_M_VAL_REG REG_MM(0x0340)
160#define MM_PLL2_MODE_REG REG_MM(0x0338)
161#define MM_PLL2_N_VAL_REG REG_MM(0x0344)
162#define ROT_CC_REG REG_MM(0x00E0)
163#define ROT_NS_REG REG_MM(0x00E8)
164#define SAXI_EN_REG REG_MM(0x0030)
165#define SW_RESET_AHB_REG REG_MM(0x020C)
166#define SW_RESET_ALL_REG REG_MM(0x0204)
167#define SW_RESET_AXI_REG REG_MM(0x0208)
168#define SW_RESET_CORE_REG REG_MM(0x0210)
169#define TV_CC_REG REG_MM(0x00EC)
170#define TV_CC2_REG REG_MM(0x0124)
171#define TV_MD_REG REG_MM(0x00F0)
172#define TV_NS_REG REG_MM(0x00F4)
173#define VCODEC_CC_REG REG_MM(0x00F8)
174#define VCODEC_MD0_REG REG_MM(0x00FC)
175#define VCODEC_MD1_REG REG_MM(0x0128)
176#define VCODEC_NS_REG REG_MM(0x0100)
177#define VFE_CC_REG REG_MM(0x0104)
178#define VFE_MD_REG REG_MM(0x0108)
179#define VFE_NS_REG REG_MM(0x010C)
180#define VPE_CC_REG REG_MM(0x0110)
181#define VPE_NS_REG REG_MM(0x0118)
182
183/* Low-power Audio clock registers. */
184#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
185#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
186#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
187#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
188#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
189#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
190#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
191#define LCC_MI2S_MD_REG REG_LPA(0x004C)
192#define LCC_MI2S_NS_REG REG_LPA(0x0048)
193#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
194#define LCC_PCM_MD_REG REG_LPA(0x0058)
195#define LCC_PCM_NS_REG REG_LPA(0x0054)
196#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
197#define LCC_PLL0_CONFIG_REG REG_LPA(0x0014)
198#define LCC_PLL0_L_VAL_REG REG_LPA(0x0004)
199#define LCC_PLL0_M_VAL_REG REG_LPA(0x0008)
200#define LCC_PLL0_MODE_REG REG_LPA(0x0000)
201#define LCC_PLL0_N_VAL_REG REG_LPA(0x000C)
202#define LCC_PRI_PLL_CLK_CTL_REG REG_LPA(0x00C4)
203#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
204#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
205#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
206#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
207#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
208#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
209
210/* MUX source input identifiers. */
211#define pxo_to_bb_mux 0
212#define mxo_to_bb_mux 1
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700213#define cxo_to_bb_mux 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700214#define pll0_to_bb_mux 2
215#define pll8_to_bb_mux 3
216#define pll6_to_bb_mux 4
217#define gnd_to_bb_mux 6
218#define pxo_to_mm_mux 0
219#define pll1_to_mm_mux 1 /* or MMSS_PLL0 */
220#define pll2_to_mm_mux 1 /* or MMSS_PLL1 */
221#define pll3_to_mm_mux 3 /* or MMSS_PLL2 */
222#define pll8_to_mm_mux 2 /* or MMSS_GPERF */
223#define pll0_to_mm_mux 3 /* or MMSS_GPLL0 */
224#define mxo_to_mm_mux 4
225#define gnd_to_mm_mux 6
226#define cxo_to_xo_mux 0
227#define pxo_to_xo_mux 1
228#define mxo_to_xo_mux 2
229#define gnd_to_xo_mux 3
230#define pxo_to_lpa_mux 0
231#define cxo_to_lpa_mux 1
232#define pll4_to_lpa_mux 2 /* or LPA_PLL0 */
233#define gnd_to_lpa_mux 6
234
235/* Test Vector Macros */
236#define TEST_TYPE_PER_LS 1
237#define TEST_TYPE_PER_HS 2
238#define TEST_TYPE_MM_LS 3
239#define TEST_TYPE_MM_HS 4
240#define TEST_TYPE_LPA 5
241#define TEST_TYPE_SC 6
242#define TEST_TYPE_MM_HS2X 7
243#define TEST_TYPE_SHIFT 24
244#define TEST_CLK_SEL_MASK BM(23, 0)
245#define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s)))
246#define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS)
247#define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS)
248#define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS)
249#define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS)
250#define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA)
251#define TEST_SC(s) TEST_VECTOR((s), TEST_TYPE_SC)
252#define TEST_MM_HS2X(s) TEST_VECTOR((s), TEST_TYPE_MM_HS2X)
253
254struct pll_rate {
255 const uint32_t l_val;
256 const uint32_t m_val;
257 const uint32_t n_val;
258 const uint32_t vco;
259 const uint32_t post_div;
260 const uint32_t i_bits;
261};
262#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
263/*
264 * Clock frequency definitions and macros
265 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700266
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700267enum vdd_dig_levels {
268 VDD_DIG_NONE,
269 VDD_DIG_LOW,
270 VDD_DIG_NOMINAL,
271 VDD_DIG_HIGH
272};
273
274static int set_vdd_dig(struct clk_vdd_class *vdd_class, int level)
275{
276 static const int vdd_uv[] = {
277 [VDD_DIG_NONE] = 500000,
278 [VDD_DIG_LOW] = 1000000,
279 [VDD_DIG_NOMINAL] = 1100000,
280 [VDD_DIG_HIGH] = 1200000
281 };
282
283 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8058_S1, RPM_VREG_VOTER3,
284 vdd_uv[level], 1200000, 1);
285}
286
287static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig);
288
289#define VDD_DIG_FMAX_MAP1(l1, f1) \
290 .vdd_class = &vdd_dig, \
291 .fmax[VDD_DIG_##l1] = (f1)
292#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
293 .vdd_class = &vdd_dig, \
294 .fmax[VDD_DIG_##l1] = (f1), \
295 .fmax[VDD_DIG_##l2] = (f2)
296#define VDD_DIG_FMAX_MAP3(l1, f1, l2, f2, l3, f3) \
297 .vdd_class = &vdd_dig, \
298 .fmax[VDD_DIG_##l1] = (f1), \
299 .fmax[VDD_DIG_##l2] = (f2), \
300 .fmax[VDD_DIG_##l3] = (f3)
301
Stephen Boyd72a80352012-01-26 15:57:38 -0800302DEFINE_CLK_RPM_BRANCH(pxo_clk, pxo_a_clk, PXO, 27000000);
303DEFINE_CLK_RPM_BRANCH(cxo_clk, cxo_a_clk, CXO, 19200000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700304
305static struct pll_vote_clk pll8_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700306 .en_reg = BB_PLL_ENA_SC0_REG,
307 .en_mask = BIT(8),
308 .status_reg = BB_PLL8_STATUS_REG,
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800309 .status_mask = BIT(16),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700310 .parent = &pxo_clk.c,
311 .c = {
312 .dbg_name = "pll8_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800313 .rate = 384000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700314 .ops = &clk_ops_pll_vote,
315 CLK_INIT(pll8_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800316 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700317 },
318};
319
320static struct pll_clk pll2_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700321 .mode_reg = MM_PLL1_MODE_REG,
322 .parent = &pxo_clk.c,
323 .c = {
324 .dbg_name = "pll2_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800325 .rate = 800000000,
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800326 .ops = &clk_ops_local_pll,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700327 CLK_INIT(pll2_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800328 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700329 },
330};
331
332static struct pll_clk pll3_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700333 .mode_reg = MM_PLL2_MODE_REG,
334 .parent = &pxo_clk.c,
335 .c = {
336 .dbg_name = "pll3_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800337 .rate = 0, /* TODO: Detect rate dynamically */
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800338 .ops = &clk_ops_local_pll,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700339 CLK_INIT(pll3_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800340 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700341 },
342};
343
344static int pll4_clk_enable(struct clk *clk)
345{
346 struct msm_rpm_iv_pair iv = { MSM_RPM_ID_PLL_4, 1 };
347 return msm_rpm_set_noirq(MSM_RPM_CTX_SET_0, &iv, 1);
348}
349
350static void pll4_clk_disable(struct clk *clk)
351{
352 struct msm_rpm_iv_pair iv = { MSM_RPM_ID_PLL_4, 0 };
353 msm_rpm_set_noirq(MSM_RPM_CTX_SET_0, &iv, 1);
354}
355
356static struct clk *pll4_clk_get_parent(struct clk *clk)
357{
358 return &pxo_clk.c;
359}
360
361static bool pll4_clk_is_local(struct clk *clk)
362{
363 return false;
364}
365
Matt Wagantall4a36a7e2012-05-14 17:03:21 -0700366static enum handoff pll4_clk_handoff(struct clk *clk)
367{
368 struct msm_rpm_iv_pair iv = { MSM_RPM_ID_PLL_4 };
369 int rc = msm_rpm_get_status(&iv, 1);
370 if (rc < 0 || !iv.value)
371 return HANDOFF_DISABLED_CLK;
372
373 return HANDOFF_ENABLED_CLK;
374}
375
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700376static struct clk_ops clk_ops_pll4 = {
377 .enable = pll4_clk_enable,
378 .disable = pll4_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700379 .get_parent = pll4_clk_get_parent,
380 .is_local = pll4_clk_is_local,
Matt Wagantall4a36a7e2012-05-14 17:03:21 -0700381 .handoff = pll4_clk_handoff,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700382};
383
384static struct fixed_clk pll4_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700385 .c = {
386 .dbg_name = "pll4_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800387 .rate = 540672000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700388 .ops = &clk_ops_pll4,
389 CLK_INIT(pll4_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800390 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700391 },
392};
393
394/*
395 * SoC-specific Set-Rate Functions
396 */
397
398/* Unlike other clocks, the TV rate is adjusted through PLL
399 * re-programming. It is also routed through an MND divider. */
400static void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
401{
402 struct pll_rate *rate = nf->extra_freq_data;
403 uint32_t pll_mode, pll_config, misc_cc2;
404
405 /* Disable PLL output. */
406 pll_mode = readl_relaxed(MM_PLL2_MODE_REG);
407 pll_mode &= ~BIT(0);
408 writel_relaxed(pll_mode, MM_PLL2_MODE_REG);
409
410 /* Assert active-low PLL reset. */
411 pll_mode &= ~BIT(2);
412 writel_relaxed(pll_mode, MM_PLL2_MODE_REG);
413
414 /* Program L, M and N values. */
415 writel_relaxed(rate->l_val, MM_PLL2_L_VAL_REG);
416 writel_relaxed(rate->m_val, MM_PLL2_M_VAL_REG);
417 writel_relaxed(rate->n_val, MM_PLL2_N_VAL_REG);
418
419 /* Configure MN counter, post-divide, VCO, and i-bits. */
420 pll_config = readl_relaxed(MM_PLL2_CONFIG_REG);
421 pll_config &= ~(BM(22, 20) | BM(18, 0));
422 pll_config |= rate->n_val ? BIT(22) : 0;
423 pll_config |= BVAL(21, 20, rate->post_div);
424 pll_config |= BVAL(17, 16, rate->vco);
425 pll_config |= rate->i_bits;
426 writel_relaxed(pll_config, MM_PLL2_CONFIG_REG);
427
428 /* Configure MND. */
429 set_rate_mnd(clk, nf);
430
431 /* Configure hdmi_ref_clk to be equal to the TV clock rate. */
432 misc_cc2 = readl_relaxed(MISC_CC2_REG);
433 misc_cc2 &= ~(BIT(28)|BM(21, 18));
434 misc_cc2 |= (BIT(28)|BVAL(21, 18, (nf->ns_val >> 14) & 0x3));
435 writel_relaxed(misc_cc2, MISC_CC2_REG);
436
437 /* De-assert active-low PLL reset. */
438 pll_mode |= BIT(2);
439 writel_relaxed(pll_mode, MM_PLL2_MODE_REG);
440
441 /* Enable PLL output. */
442 pll_mode |= BIT(0);
443 writel_relaxed(pll_mode, MM_PLL2_MODE_REG);
444}
445
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700446/*
447 * Clock Descriptions
448 */
449
450/* AXI Interfaces */
451static struct branch_clk gmem_axi_clk = {
452 .b = {
453 .ctl_reg = MAXI_EN_REG,
454 .en_mask = BIT(24),
455 .halt_reg = DBG_BUS_VEC_E_REG,
456 .halt_bit = 6,
457 },
458 .c = {
459 .dbg_name = "gmem_axi_clk",
460 .ops = &clk_ops_branch,
461 CLK_INIT(gmem_axi_clk.c),
462 },
463};
464
465static struct branch_clk ijpeg_axi_clk = {
466 .b = {
467 .ctl_reg = MAXI_EN_REG,
468 .en_mask = BIT(21),
469 .reset_reg = SW_RESET_AXI_REG,
470 .reset_mask = BIT(14),
471 .halt_reg = DBG_BUS_VEC_E_REG,
472 .halt_bit = 4,
473 },
474 .c = {
475 .dbg_name = "ijpeg_axi_clk",
476 .ops = &clk_ops_branch,
477 CLK_INIT(ijpeg_axi_clk.c),
478 },
479};
480
481static struct branch_clk imem_axi_clk = {
482 .b = {
483 .ctl_reg = MAXI_EN_REG,
484 .en_mask = BIT(22),
485 .reset_reg = SW_RESET_CORE_REG,
486 .reset_mask = BIT(10),
487 .halt_reg = DBG_BUS_VEC_E_REG,
488 .halt_bit = 7,
Matt Wagantall6bc8f102012-01-20 19:20:44 -0800489 .retain_reg = MAXI_EN2_REG,
490 .retain_mask = BIT(10),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700491 },
492 .c = {
493 .dbg_name = "imem_axi_clk",
494 .ops = &clk_ops_branch,
495 CLK_INIT(imem_axi_clk.c),
496 },
497};
498
499static struct branch_clk jpegd_axi_clk = {
500 .b = {
501 .ctl_reg = MAXI_EN_REG,
502 .en_mask = BIT(25),
503 .halt_reg = DBG_BUS_VEC_E_REG,
504 .halt_bit = 5,
505 },
506 .c = {
507 .dbg_name = "jpegd_axi_clk",
508 .ops = &clk_ops_branch,
509 CLK_INIT(jpegd_axi_clk.c),
510 },
511};
512
513static struct branch_clk mdp_axi_clk = {
514 .b = {
515 .ctl_reg = MAXI_EN_REG,
516 .en_mask = BIT(23),
517 .reset_reg = SW_RESET_AXI_REG,
518 .reset_mask = BIT(13),
519 .halt_reg = DBG_BUS_VEC_E_REG,
520 .halt_bit = 8,
Matt Wagantall6bc8f102012-01-20 19:20:44 -0800521 .retain_reg = MAXI_EN_REG,
522 .retain_mask = BIT(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700523 },
524 .c = {
525 .dbg_name = "mdp_axi_clk",
526 .ops = &clk_ops_branch,
527 CLK_INIT(mdp_axi_clk.c),
528 },
529};
530
531static struct branch_clk vcodec_axi_clk = {
532 .b = {
533 .ctl_reg = MAXI_EN_REG,
534 .en_mask = BIT(19),
535 .reset_reg = SW_RESET_AXI_REG,
536 .reset_mask = BIT(4)|BIT(5),
537 .halt_reg = DBG_BUS_VEC_E_REG,
538 .halt_bit = 3,
539 },
540 .c = {
541 .dbg_name = "vcodec_axi_clk",
542 .ops = &clk_ops_branch,
543 CLK_INIT(vcodec_axi_clk.c),
544 },
545};
546
547static struct branch_clk vfe_axi_clk = {
548 .b = {
549 .ctl_reg = MAXI_EN_REG,
550 .en_mask = BIT(18),
551 .reset_reg = SW_RESET_AXI_REG,
552 .reset_mask = BIT(9),
553 .halt_reg = DBG_BUS_VEC_E_REG,
554 .halt_bit = 0,
555 },
556 .c = {
557 .dbg_name = "vfe_axi_clk",
558 .ops = &clk_ops_branch,
559 CLK_INIT(vfe_axi_clk.c),
560 },
561};
562
563static struct branch_clk rot_axi_clk = {
564 .b = {
Matt Wagantallf63a8892011-06-15 16:44:46 -0700565 .ctl_reg = MAXI_EN2_REG,
566 .en_mask = BIT(24),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700567 .reset_reg = SW_RESET_AXI_REG,
568 .reset_mask = BIT(6),
Matt Wagantallf63a8892011-06-15 16:44:46 -0700569 .halt_reg = DBG_BUS_VEC_E_REG,
570 .halt_bit = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700571 },
572 .c = {
573 .dbg_name = "rot_axi_clk",
Matt Wagantallf63a8892011-06-15 16:44:46 -0700574 .ops = &clk_ops_branch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700575 CLK_INIT(rot_axi_clk.c),
576 },
577};
578
579static struct branch_clk vpe_axi_clk = {
580 .b = {
Matt Wagantallf63a8892011-06-15 16:44:46 -0700581 .ctl_reg = MAXI_EN2_REG,
582 .en_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700583 .reset_reg = SW_RESET_AXI_REG,
584 .reset_mask = BIT(15),
Matt Wagantallf63a8892011-06-15 16:44:46 -0700585 .halt_reg = DBG_BUS_VEC_E_REG,
586 .halt_bit = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700587 },
588 .c = {
589 .dbg_name = "vpe_axi_clk",
Matt Wagantallf63a8892011-06-15 16:44:46 -0700590 .ops = &clk_ops_branch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700591 CLK_INIT(vpe_axi_clk.c),
592 },
593};
594
Matt Wagantallf8032602011-06-15 23:01:56 -0700595static struct branch_clk smi_2x_axi_clk = {
596 .b = {
597 .ctl_reg = MAXI_EN2_REG,
598 .en_mask = BIT(30),
599 .halt_reg = DBG_BUS_VEC_I_REG,
600 .halt_bit = 0,
601 },
602 .c = {
603 .dbg_name = "smi_2x_axi_clk",
604 .ops = &clk_ops_branch,
605 .flags = CLKFLAG_SKIP_AUTO_OFF,
606 CLK_INIT(smi_2x_axi_clk.c),
607 },
608};
609
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700610/* AHB Interfaces */
611static struct branch_clk amp_p_clk = {
612 .b = {
613 .ctl_reg = AHB_EN_REG,
614 .en_mask = BIT(24),
Matt Wagantalld40857a2012-04-10 19:15:43 -0700615 .reset_reg = SW_RESET_CORE_REG,
616 .reset_mask = BIT(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700617 .halt_reg = DBG_BUS_VEC_F_REG,
618 .halt_bit = 18,
619 },
620 .c = {
621 .dbg_name = "amp_p_clk",
622 .ops = &clk_ops_branch,
623 CLK_INIT(amp_p_clk.c),
624 },
625};
626
627static struct branch_clk csi0_p_clk = {
628 .b = {
629 .ctl_reg = AHB_EN_REG,
630 .en_mask = BIT(7),
631 .reset_reg = SW_RESET_AHB_REG,
632 .reset_mask = BIT(17),
633 .halt_reg = DBG_BUS_VEC_F_REG,
634 .halt_bit = 16,
635 },
636 .c = {
637 .dbg_name = "csi0_p_clk",
638 .ops = &clk_ops_branch,
639 CLK_INIT(csi0_p_clk.c),
640 },
641};
642
643static struct branch_clk csi1_p_clk = {
644 .b = {
645 .ctl_reg = AHB_EN_REG,
646 .en_mask = BIT(20),
647 .reset_reg = SW_RESET_AHB_REG,
648 .reset_mask = BIT(16),
649 .halt_reg = DBG_BUS_VEC_F_REG,
650 .halt_bit = 17,
651 },
652 .c = {
653 .dbg_name = "csi1_p_clk",
654 .ops = &clk_ops_branch,
655 CLK_INIT(csi1_p_clk.c),
656 },
657};
658
659static struct branch_clk dsi_m_p_clk = {
660 .b = {
661 .ctl_reg = AHB_EN_REG,
662 .en_mask = BIT(9),
663 .reset_reg = SW_RESET_AHB_REG,
664 .reset_mask = BIT(6),
665 .halt_reg = DBG_BUS_VEC_F_REG,
666 .halt_bit = 19,
667 },
668 .c = {
669 .dbg_name = "dsi_m_p_clk",
670 .ops = &clk_ops_branch,
671 CLK_INIT(dsi_m_p_clk.c),
672 },
673};
674
675static struct branch_clk dsi_s_p_clk = {
676 .b = {
677 .ctl_reg = AHB_EN_REG,
678 .en_mask = BIT(18),
679 .reset_reg = SW_RESET_AHB_REG,
680 .reset_mask = BIT(5),
681 .halt_reg = DBG_BUS_VEC_F_REG,
682 .halt_bit = 20,
683 },
684 .c = {
685 .dbg_name = "dsi_s_p_clk",
686 .ops = &clk_ops_branch,
687 CLK_INIT(dsi_s_p_clk.c),
688 },
689};
690
691static struct branch_clk gfx2d0_p_clk = {
692 .b = {
693 .ctl_reg = AHB_EN_REG,
694 .en_mask = BIT(19),
695 .reset_reg = SW_RESET_AHB_REG,
696 .reset_mask = BIT(12),
697 .halt_reg = DBG_BUS_VEC_F_REG,
698 .halt_bit = 2,
699 },
700 .c = {
701 .dbg_name = "gfx2d0_p_clk",
702 .ops = &clk_ops_branch,
703 CLK_INIT(gfx2d0_p_clk.c),
704 },
705};
706
707static struct branch_clk gfx2d1_p_clk = {
708 .b = {
709 .ctl_reg = AHB_EN_REG,
710 .en_mask = BIT(2),
711 .reset_reg = SW_RESET_AHB_REG,
712 .reset_mask = BIT(11),
713 .halt_reg = DBG_BUS_VEC_F_REG,
714 .halt_bit = 3,
715 },
716 .c = {
717 .dbg_name = "gfx2d1_p_clk",
718 .ops = &clk_ops_branch,
719 CLK_INIT(gfx2d1_p_clk.c),
720 },
721};
722
723static struct branch_clk gfx3d_p_clk = {
724 .b = {
725 .ctl_reg = AHB_EN_REG,
726 .en_mask = BIT(3),
727 .reset_reg = SW_RESET_AHB_REG,
728 .reset_mask = BIT(10),
729 .halt_reg = DBG_BUS_VEC_F_REG,
730 .halt_bit = 4,
731 },
732 .c = {
733 .dbg_name = "gfx3d_p_clk",
734 .ops = &clk_ops_branch,
735 CLK_INIT(gfx3d_p_clk.c),
736 },
737};
738
739static struct branch_clk hdmi_m_p_clk = {
740 .b = {
741 .ctl_reg = AHB_EN_REG,
742 .en_mask = BIT(14),
743 .reset_reg = SW_RESET_AHB_REG,
744 .reset_mask = BIT(9),
745 .halt_reg = DBG_BUS_VEC_F_REG,
746 .halt_bit = 5,
747 },
748 .c = {
749 .dbg_name = "hdmi_m_p_clk",
750 .ops = &clk_ops_branch,
751 CLK_INIT(hdmi_m_p_clk.c),
752 },
753};
754
755static struct branch_clk hdmi_s_p_clk = {
756 .b = {
757 .ctl_reg = AHB_EN_REG,
758 .en_mask = BIT(4),
759 .reset_reg = SW_RESET_AHB_REG,
760 .reset_mask = BIT(9),
761 .halt_reg = DBG_BUS_VEC_F_REG,
762 .halt_bit = 6,
763 },
764 .c = {
765 .dbg_name = "hdmi_s_p_clk",
766 .ops = &clk_ops_branch,
767 CLK_INIT(hdmi_s_p_clk.c),
768 },
769};
770
771static struct branch_clk ijpeg_p_clk = {
772 .b = {
773 .ctl_reg = AHB_EN_REG,
774 .en_mask = BIT(5),
775 .reset_reg = SW_RESET_AHB_REG,
776 .reset_mask = BIT(7),
777 .halt_reg = DBG_BUS_VEC_F_REG,
778 .halt_bit = 9,
779 },
780 .c = {
781 .dbg_name = "ijpeg_p_clk",
782 .ops = &clk_ops_branch,
783 CLK_INIT(ijpeg_p_clk.c),
784 },
785};
786
787static struct branch_clk imem_p_clk = {
788 .b = {
789 .ctl_reg = AHB_EN_REG,
790 .en_mask = BIT(6),
791 .reset_reg = SW_RESET_AHB_REG,
792 .reset_mask = BIT(8),
793 .halt_reg = DBG_BUS_VEC_F_REG,
794 .halt_bit = 10,
795 },
796 .c = {
797 .dbg_name = "imem_p_clk",
798 .ops = &clk_ops_branch,
799 CLK_INIT(imem_p_clk.c),
800 },
801};
802
803static struct branch_clk jpegd_p_clk = {
804 .b = {
805 .ctl_reg = AHB_EN_REG,
806 .en_mask = BIT(21),
807 .reset_reg = SW_RESET_AHB_REG,
808 .reset_mask = BIT(4),
809 .halt_reg = DBG_BUS_VEC_F_REG,
810 .halt_bit = 7,
811 },
812 .c = {
813 .dbg_name = "jpegd_p_clk",
814 .ops = &clk_ops_branch,
815 CLK_INIT(jpegd_p_clk.c),
816 },
817};
818
819static struct branch_clk mdp_p_clk = {
820 .b = {
821 .ctl_reg = AHB_EN_REG,
822 .en_mask = BIT(10),
823 .reset_reg = SW_RESET_AHB_REG,
824 .reset_mask = BIT(3),
825 .halt_reg = DBG_BUS_VEC_F_REG,
826 .halt_bit = 11,
827 },
828 .c = {
829 .dbg_name = "mdp_p_clk",
830 .ops = &clk_ops_branch,
831 CLK_INIT(mdp_p_clk.c),
832 },
833};
834
835static struct branch_clk rot_p_clk = {
836 .b = {
837 .ctl_reg = AHB_EN_REG,
838 .en_mask = BIT(12),
839 .reset_reg = SW_RESET_AHB_REG,
840 .reset_mask = BIT(2),
841 .halt_reg = DBG_BUS_VEC_F_REG,
842 .halt_bit = 13,
843 },
844 .c = {
845 .dbg_name = "rot_p_clk",
846 .ops = &clk_ops_branch,
847 CLK_INIT(rot_p_clk.c),
848 },
849};
850
851static struct branch_clk smmu_p_clk = {
852 .b = {
853 .ctl_reg = AHB_EN_REG,
854 .en_mask = BIT(15),
855 .halt_reg = DBG_BUS_VEC_F_REG,
856 .halt_bit = 22,
857 },
858 .c = {
859 .dbg_name = "smmu_p_clk",
860 .ops = &clk_ops_branch,
861 CLK_INIT(smmu_p_clk.c),
862 },
863};
864
865static struct branch_clk tv_enc_p_clk = {
866 .b = {
867 .ctl_reg = AHB_EN_REG,
868 .en_mask = BIT(25),
869 .reset_reg = SW_RESET_AHB_REG,
870 .reset_mask = BIT(15),
871 .halt_reg = DBG_BUS_VEC_F_REG,
872 .halt_bit = 23,
873 },
874 .c = {
875 .dbg_name = "tv_enc_p_clk",
876 .ops = &clk_ops_branch,
877 CLK_INIT(tv_enc_p_clk.c),
878 },
879};
880
881static struct branch_clk vcodec_p_clk = {
882 .b = {
883 .ctl_reg = AHB_EN_REG,
884 .en_mask = BIT(11),
885 .reset_reg = SW_RESET_AHB_REG,
886 .reset_mask = BIT(1),
887 .halt_reg = DBG_BUS_VEC_F_REG,
888 .halt_bit = 12,
889 },
890 .c = {
891 .dbg_name = "vcodec_p_clk",
892 .ops = &clk_ops_branch,
893 CLK_INIT(vcodec_p_clk.c),
894 },
895};
896
897static struct branch_clk vfe_p_clk = {
898 .b = {
899 .ctl_reg = AHB_EN_REG,
900 .en_mask = BIT(13),
901 .reset_reg = SW_RESET_AHB_REG,
902 .reset_mask = BIT(0),
903 .halt_reg = DBG_BUS_VEC_F_REG,
904 .halt_bit = 14,
Matt Wagantall6bc8f102012-01-20 19:20:44 -0800905 .retain_reg = AHB_EN2_REG,
906 .retain_mask = BIT(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700907 },
908 .c = {
909 .dbg_name = "vfe_p_clk",
910 .ops = &clk_ops_branch,
911 CLK_INIT(vfe_p_clk.c),
912 },
913};
914
915static struct branch_clk vpe_p_clk = {
916 .b = {
917 .ctl_reg = AHB_EN_REG,
918 .en_mask = BIT(16),
919 .reset_reg = SW_RESET_AHB_REG,
920 .reset_mask = BIT(14),
921 .halt_reg = DBG_BUS_VEC_F_REG,
922 .halt_bit = 15,
923 },
924 .c = {
925 .dbg_name = "vpe_p_clk",
926 .ops = &clk_ops_branch,
927 CLK_INIT(vpe_p_clk.c),
928 },
929};
930
931/*
932 * Peripheral Clocks
933 */
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700934#define CLK_GP(i, n, h_r, h_b) \
935 struct rcg_clk i##_clk = { \
936 .b = { \
937 .ctl_reg = GPn_NS_REG(n), \
938 .en_mask = BIT(9), \
939 .halt_reg = h_r, \
940 .halt_bit = h_b, \
941 }, \
942 .ns_reg = GPn_NS_REG(n), \
943 .md_reg = GPn_MD_REG(n), \
944 .root_en_mask = BIT(11), \
945 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -0800946 .mnd_en_mask = BIT(8), \
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700947 .set_rate = set_rate_mnd, \
948 .freq_tbl = clk_tbl_gp, \
949 .current_freq = &rcg_dummy_freq, \
950 .c = { \
951 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -0700952 .ops = &clk_ops_rcg, \
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700953 VDD_DIG_FMAX_MAP1(LOW, 27000000), \
954 CLK_INIT(i##_clk.c), \
955 }, \
956 }
957#define F_GP(f, s, d, m, n) \
958 { \
959 .freq_hz = f, \
960 .src_clk = &s##_clk.c, \
961 .md_val = MD8(16, m, 0, n), \
962 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700963 }
964static struct clk_freq_tbl clk_tbl_gp[] = {
965 F_GP( 0, gnd, 1, 0, 0),
966 F_GP( 9600000, cxo, 2, 0, 0),
967 F_GP( 13500000, pxo, 2, 0, 0),
968 F_GP( 19200000, cxo, 1, 0, 0),
969 F_GP( 27000000, pxo, 1, 0, 0),
970 F_END
971};
972
973static CLK_GP(gp0, 0, CLK_HALT_SFPB_MISC_STATE_REG, 7);
974static CLK_GP(gp1, 1, CLK_HALT_SFPB_MISC_STATE_REG, 6);
975static CLK_GP(gp2, 2, CLK_HALT_SFPB_MISC_STATE_REG, 5);
976
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700977#define CLK_GSBI_UART(i, n, h_r, h_b) \
978 struct rcg_clk i##_clk = { \
979 .b = { \
980 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
981 .en_mask = BIT(9), \
982 .reset_reg = GSBIn_RESET_REG(n), \
983 .reset_mask = BIT(0), \
984 .halt_reg = h_r, \
985 .halt_bit = h_b, \
986 }, \
987 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
988 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
989 .root_en_mask = BIT(11), \
990 .ns_mask = (BM(31, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -0800991 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700992 .set_rate = set_rate_mnd, \
993 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700994 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700995 .c = { \
996 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -0700997 .ops = &clk_ops_rcg, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700998 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700999 CLK_INIT(i##_clk.c), \
1000 }, \
1001 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001002#define F_GSBI_UART(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001003 { \
1004 .freq_hz = f, \
1005 .src_clk = &s##_clk.c, \
1006 .md_val = MD16(m, n), \
1007 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001008 }
1009static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001010 F_GSBI_UART( 0, gnd, 1, 0, 0),
1011 F_GSBI_UART( 1843200, pll8, 1, 3, 625),
1012 F_GSBI_UART( 3686400, pll8, 1, 6, 625),
1013 F_GSBI_UART( 7372800, pll8, 1, 12, 625),
1014 F_GSBI_UART(14745600, pll8, 1, 24, 625),
1015 F_GSBI_UART(16000000, pll8, 4, 1, 6),
1016 F_GSBI_UART(24000000, pll8, 4, 1, 4),
1017 F_GSBI_UART(32000000, pll8, 4, 1, 3),
1018 F_GSBI_UART(40000000, pll8, 1, 5, 48),
1019 F_GSBI_UART(46400000, pll8, 1, 29, 240),
1020 F_GSBI_UART(48000000, pll8, 4, 1, 2),
1021 F_GSBI_UART(51200000, pll8, 1, 2, 15),
1022 F_GSBI_UART(56000000, pll8, 1, 7, 48),
1023 F_GSBI_UART(58982400, pll8, 1, 96, 625),
1024 F_GSBI_UART(64000000, pll8, 2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001025 F_END
1026};
1027
1028static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1029static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1030static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1031static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1032static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1033static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1034static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1035static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1036static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1037static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1038static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1039static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1040
1041#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1042 struct rcg_clk i##_clk = { \
1043 .b = { \
1044 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1045 .en_mask = BIT(9), \
1046 .reset_reg = GSBIn_RESET_REG(n), \
1047 .reset_mask = BIT(0), \
1048 .halt_reg = h_r, \
1049 .halt_bit = h_b, \
1050 }, \
1051 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1052 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1053 .root_en_mask = BIT(11), \
1054 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001055 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001056 .set_rate = set_rate_mnd, \
1057 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001058 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001059 .c = { \
1060 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -07001061 .ops = &clk_ops_rcg, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001062 VDD_DIG_FMAX_MAP2(LOW, 24000000, NOMINAL, 52000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001063 CLK_INIT(i##_clk.c), \
1064 }, \
1065 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001066#define F_GSBI_QUP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001067 { \
1068 .freq_hz = f, \
1069 .src_clk = &s##_clk.c, \
1070 .md_val = MD8(16, m, 0, n), \
1071 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001072 }
1073static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001074 F_GSBI_QUP( 0, gnd, 1, 0, 0),
1075 F_GSBI_QUP( 1100000, pxo, 1, 2, 49),
1076 F_GSBI_QUP( 5400000, pxo, 1, 1, 5),
1077 F_GSBI_QUP(10800000, pxo, 1, 2, 5),
1078 F_GSBI_QUP(15060000, pll8, 1, 2, 51),
1079 F_GSBI_QUP(24000000, pll8, 4, 1, 4),
1080 F_GSBI_QUP(25600000, pll8, 1, 1, 15),
1081 F_GSBI_QUP(27000000, pxo, 1, 0, 0),
1082 F_GSBI_QUP(48000000, pll8, 4, 1, 2),
1083 F_GSBI_QUP(51200000, pll8, 1, 2, 15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001084 F_END
1085};
1086
1087static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1088static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1089static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1090static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1091static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1092static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1093static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1094static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1095static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1096static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1097static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1098static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1099
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001100#define F_PDM(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001101 { \
1102 .freq_hz = f, \
1103 .src_clk = &s##_clk.c, \
1104 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001105 }
1106static struct clk_freq_tbl clk_tbl_pdm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001107 F_PDM( 0, gnd, 1),
1108 F_PDM(27000000, pxo, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001109 F_END
1110};
1111
1112static struct rcg_clk pdm_clk = {
1113 .b = {
1114 .ctl_reg = PDM_CLK_NS_REG,
1115 .en_mask = BIT(9),
1116 .reset_reg = PDM_CLK_NS_REG,
1117 .reset_mask = BIT(12),
1118 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1119 .halt_bit = 3,
1120 },
1121 .ns_reg = PDM_CLK_NS_REG,
1122 .root_en_mask = BIT(11),
1123 .ns_mask = BM(1, 0),
1124 .set_rate = set_rate_nop,
1125 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001126 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001127 .c = {
1128 .dbg_name = "pdm_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001129 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001130 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001131 CLK_INIT(pdm_clk.c),
1132 },
1133};
1134
1135static struct branch_clk pmem_clk = {
1136 .b = {
1137 .ctl_reg = PMEM_ACLK_CTL_REG,
1138 .en_mask = BIT(4),
1139 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1140 .halt_bit = 20,
1141 },
1142 .c = {
1143 .dbg_name = "pmem_clk",
1144 .ops = &clk_ops_branch,
1145 CLK_INIT(pmem_clk.c),
1146 },
1147};
1148
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001149#define F_PRNG(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001150 { \
1151 .freq_hz = f, \
1152 .src_clk = &s##_clk.c, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001153 }
Stephen Boyd842a1f62012-04-26 19:07:38 -07001154static struct clk_freq_tbl clk_tbl_prng_32[] = {
1155 F_PRNG(32000000, pll8),
1156 F_END
1157};
1158
1159static struct clk_freq_tbl clk_tbl_prng_64[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001160 F_PRNG(64000000, pll8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001161 F_END
1162};
1163
1164static struct rcg_clk prng_clk = {
1165 .b = {
1166 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1167 .en_mask = BIT(10),
1168 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1169 .halt_check = HALT_VOTED,
1170 .halt_bit = 10,
1171 },
1172 .set_rate = set_rate_nop,
Stephen Boyd842a1f62012-04-26 19:07:38 -07001173 .freq_tbl = clk_tbl_prng_32,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001174 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001175 .c = {
1176 .dbg_name = "prng_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001177 .ops = &clk_ops_rcg,
Stephen Boyd842a1f62012-04-26 19:07:38 -07001178 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001179 CLK_INIT(prng_clk.c),
1180 },
1181};
1182
1183#define CLK_SDC(i, n, h_r, h_b) \
1184 struct rcg_clk i##_clk = { \
1185 .b = { \
1186 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1187 .en_mask = BIT(9), \
1188 .reset_reg = SDCn_RESET_REG(n), \
1189 .reset_mask = BIT(0), \
1190 .halt_reg = h_r, \
1191 .halt_bit = h_b, \
1192 }, \
1193 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1194 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1195 .root_en_mask = BIT(11), \
1196 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001197 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001198 .set_rate = set_rate_mnd, \
1199 .freq_tbl = clk_tbl_sdc, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001200 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001201 .c = { \
1202 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -07001203 .ops = &clk_ops_rcg, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001204 VDD_DIG_FMAX_MAP2(LOW, 25000000, NOMINAL, 50000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001205 CLK_INIT(i##_clk.c), \
1206 }, \
1207 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001208#define F_SDC(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001209 { \
1210 .freq_hz = f, \
1211 .src_clk = &s##_clk.c, \
1212 .md_val = MD8(16, m, 0, n), \
1213 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001214 }
1215static struct clk_freq_tbl clk_tbl_sdc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001216 F_SDC( 0, gnd, 1, 0, 0),
1217 F_SDC( 144000, pxo, 3, 2, 125),
1218 F_SDC( 400000, pll8, 4, 1, 240),
1219 F_SDC(16000000, pll8, 4, 1, 6),
1220 F_SDC(17070000, pll8, 1, 2, 45),
1221 F_SDC(20210000, pll8, 1, 1, 19),
1222 F_SDC(24000000, pll8, 4, 1, 4),
1223 F_SDC(48000000, pll8, 4, 1, 2),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001224 F_END
1225};
1226
1227static CLK_SDC(sdc1, 1, CLK_HALT_DFAB_STATE_REG, 6);
1228static CLK_SDC(sdc2, 2, CLK_HALT_DFAB_STATE_REG, 5);
1229static CLK_SDC(sdc3, 3, CLK_HALT_DFAB_STATE_REG, 4);
1230static CLK_SDC(sdc4, 4, CLK_HALT_DFAB_STATE_REG, 3);
1231static CLK_SDC(sdc5, 5, CLK_HALT_DFAB_STATE_REG, 2);
1232
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001233#define F_TSIF_REF(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001234 { \
1235 .freq_hz = f, \
1236 .src_clk = &s##_clk.c, \
1237 .md_val = MD16(m, n), \
1238 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001239 }
1240static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001241 F_TSIF_REF( 0, gnd, 1, 0, 0),
1242 F_TSIF_REF(105000, pxo, 1, 1, 256),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001243 F_END
1244};
1245
1246static struct rcg_clk tsif_ref_clk = {
1247 .b = {
1248 .ctl_reg = TSIF_REF_CLK_NS_REG,
1249 .en_mask = BIT(9),
1250 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1251 .halt_bit = 5,
1252 },
1253 .ns_reg = TSIF_REF_CLK_NS_REG,
1254 .md_reg = TSIF_REF_CLK_MD_REG,
1255 .root_en_mask = BIT(11),
1256 .ns_mask = (BM(31, 16) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08001257 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001258 .set_rate = set_rate_mnd,
1259 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001260 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001261 .c = {
1262 .dbg_name = "tsif_ref_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001263 .ops = &clk_ops_rcg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001264 CLK_INIT(tsif_ref_clk.c),
1265 },
1266};
1267
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001268#define F_TSSC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001269 { \
1270 .freq_hz = f, \
1271 .src_clk = &s##_clk.c, \
1272 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001273 }
1274static struct clk_freq_tbl clk_tbl_tssc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001275 F_TSSC( 0, gnd),
1276 F_TSSC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001277 F_END
1278};
1279
1280static struct rcg_clk tssc_clk = {
1281 .b = {
1282 .ctl_reg = TSSC_CLK_CTL_REG,
1283 .en_mask = BIT(4),
1284 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1285 .halt_bit = 4,
1286 },
1287 .ns_reg = TSSC_CLK_CTL_REG,
1288 .ns_mask = BM(1, 0),
1289 .set_rate = set_rate_nop,
1290 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001291 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001292 .c = {
1293 .dbg_name = "tssc_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001294 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001295 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001296 CLK_INIT(tssc_clk.c),
1297 },
1298};
1299
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001300#define F_USB(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001301 { \
1302 .freq_hz = f, \
1303 .src_clk = &s##_clk.c, \
1304 .md_val = MD8(16, m, 0, n), \
1305 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001306 }
1307static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001308 F_USB( 0, gnd, 1, 0, 0),
1309 F_USB(60000000, pll8, 1, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001310 F_END
1311};
1312
1313static struct rcg_clk usb_hs1_xcvr_clk = {
1314 .b = {
1315 .ctl_reg = USB_HS1_XCVR_FS_CLK_NS_REG,
1316 .en_mask = BIT(9),
1317 .reset_reg = USB_HS1_RESET_REG,
1318 .reset_mask = BIT(0),
1319 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1320 .halt_bit = 0,
1321 },
1322 .ns_reg = USB_HS1_XCVR_FS_CLK_NS_REG,
1323 .md_reg = USB_HS1_XCVR_FS_CLK_MD_REG,
1324 .root_en_mask = BIT(11),
1325 .ns_mask = (BM(23, 16) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08001326 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001327 .set_rate = set_rate_mnd,
1328 .freq_tbl = clk_tbl_usb,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001329 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001330 .c = {
1331 .dbg_name = "usb_hs1_xcvr_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001332 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001333 VDD_DIG_FMAX_MAP1(NOMINAL, 60000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001334 CLK_INIT(usb_hs1_xcvr_clk.c),
1335 },
1336};
1337
1338static struct branch_clk usb_phy0_clk = {
1339 .b = {
1340 .reset_reg = USB_PHY0_RESET_REG,
1341 .reset_mask = BIT(0),
1342 },
1343 .c = {
1344 .dbg_name = "usb_phy0_clk",
1345 .ops = &clk_ops_reset,
1346 CLK_INIT(usb_phy0_clk.c),
1347 },
1348};
1349
1350#define CLK_USB_FS(i, n) \
1351 struct rcg_clk i##_clk = { \
1352 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1353 .b = { \
1354 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1355 .halt_check = NOCHECK, \
1356 }, \
1357 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
1358 .root_en_mask = BIT(11), \
1359 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001360 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001361 .set_rate = set_rate_mnd, \
1362 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001363 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001364 .c = { \
1365 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -07001366 .ops = &clk_ops_rcg, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001367 VDD_DIG_FMAX_MAP1(NOMINAL, 60000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001368 CLK_INIT(i##_clk.c), \
1369 }, \
1370 }
1371
1372static CLK_USB_FS(usb_fs1_src, 1);
1373static struct branch_clk usb_fs1_xcvr_clk = {
1374 .b = {
1375 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
1376 .en_mask = BIT(9),
1377 .reset_reg = USB_FSn_RESET_REG(1),
1378 .reset_mask = BIT(1),
1379 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1380 .halt_bit = 15,
1381 },
1382 .parent = &usb_fs1_src_clk.c,
1383 .c = {
1384 .dbg_name = "usb_fs1_xcvr_clk",
1385 .ops = &clk_ops_branch,
1386 CLK_INIT(usb_fs1_xcvr_clk.c),
1387 },
1388};
1389
1390static struct branch_clk usb_fs1_sys_clk = {
1391 .b = {
1392 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
1393 .en_mask = BIT(4),
1394 .reset_reg = USB_FSn_RESET_REG(1),
1395 .reset_mask = BIT(0),
1396 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1397 .halt_bit = 16,
1398 },
1399 .parent = &usb_fs1_src_clk.c,
1400 .c = {
1401 .dbg_name = "usb_fs1_sys_clk",
1402 .ops = &clk_ops_branch,
1403 CLK_INIT(usb_fs1_sys_clk.c),
1404 },
1405};
1406
1407static CLK_USB_FS(usb_fs2_src, 2);
1408static struct branch_clk usb_fs2_xcvr_clk = {
1409 .b = {
1410 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
1411 .en_mask = BIT(9),
1412 .reset_reg = USB_FSn_RESET_REG(2),
1413 .reset_mask = BIT(1),
1414 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1415 .halt_bit = 12,
1416 },
1417 .parent = &usb_fs2_src_clk.c,
1418 .c = {
1419 .dbg_name = "usb_fs2_xcvr_clk",
1420 .ops = &clk_ops_branch,
1421 CLK_INIT(usb_fs2_xcvr_clk.c),
1422 },
1423};
1424
1425static struct branch_clk usb_fs2_sys_clk = {
1426 .b = {
1427 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
1428 .en_mask = BIT(4),
1429 .reset_reg = USB_FSn_RESET_REG(2),
1430 .reset_mask = BIT(0),
1431 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1432 .halt_bit = 13,
1433 },
1434 .parent = &usb_fs2_src_clk.c,
1435 .c = {
1436 .dbg_name = "usb_fs2_sys_clk",
1437 .ops = &clk_ops_branch,
1438 CLK_INIT(usb_fs2_sys_clk.c),
1439 },
1440};
1441
1442/* Fast Peripheral Bus Clocks */
1443static struct branch_clk ce2_p_clk = {
1444 .b = {
1445 .ctl_reg = CE2_HCLK_CTL_REG,
1446 .en_mask = BIT(4),
1447 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1448 .halt_bit = 0,
1449 },
1450 .parent = &pxo_clk.c,
1451 .c = {
1452 .dbg_name = "ce2_p_clk",
1453 .ops = &clk_ops_branch,
1454 CLK_INIT(ce2_p_clk.c),
1455 },
1456};
1457
1458static struct branch_clk gsbi1_p_clk = {
1459 .b = {
1460 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
1461 .en_mask = BIT(4),
1462 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1463 .halt_bit = 11,
1464 },
1465 .c = {
1466 .dbg_name = "gsbi1_p_clk",
1467 .ops = &clk_ops_branch,
1468 CLK_INIT(gsbi1_p_clk.c),
1469 },
1470};
1471
1472static struct branch_clk gsbi2_p_clk = {
1473 .b = {
1474 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
1475 .en_mask = BIT(4),
1476 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1477 .halt_bit = 7,
1478 },
1479 .c = {
1480 .dbg_name = "gsbi2_p_clk",
1481 .ops = &clk_ops_branch,
1482 CLK_INIT(gsbi2_p_clk.c),
1483 },
1484};
1485
1486static struct branch_clk gsbi3_p_clk = {
1487 .b = {
1488 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
1489 .en_mask = BIT(4),
1490 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1491 .halt_bit = 3,
1492 },
1493 .c = {
1494 .dbg_name = "gsbi3_p_clk",
1495 .ops = &clk_ops_branch,
1496 CLK_INIT(gsbi3_p_clk.c),
1497 },
1498};
1499
1500static struct branch_clk gsbi4_p_clk = {
1501 .b = {
1502 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
1503 .en_mask = BIT(4),
1504 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1505 .halt_bit = 27,
1506 },
1507 .c = {
1508 .dbg_name = "gsbi4_p_clk",
1509 .ops = &clk_ops_branch,
1510 CLK_INIT(gsbi4_p_clk.c),
1511 },
1512};
1513
1514static struct branch_clk gsbi5_p_clk = {
1515 .b = {
1516 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
1517 .en_mask = BIT(4),
1518 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1519 .halt_bit = 23,
1520 },
1521 .c = {
1522 .dbg_name = "gsbi5_p_clk",
1523 .ops = &clk_ops_branch,
1524 CLK_INIT(gsbi5_p_clk.c),
1525 },
1526};
1527
1528static struct branch_clk gsbi6_p_clk = {
1529 .b = {
1530 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
1531 .en_mask = BIT(4),
1532 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1533 .halt_bit = 19,
1534 },
1535 .c = {
1536 .dbg_name = "gsbi6_p_clk",
1537 .ops = &clk_ops_branch,
1538 CLK_INIT(gsbi6_p_clk.c),
1539 },
1540};
1541
1542static struct branch_clk gsbi7_p_clk = {
1543 .b = {
1544 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
1545 .en_mask = BIT(4),
1546 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1547 .halt_bit = 15,
1548 },
1549 .c = {
1550 .dbg_name = "gsbi7_p_clk",
1551 .ops = &clk_ops_branch,
1552 CLK_INIT(gsbi7_p_clk.c),
1553 },
1554};
1555
1556static struct branch_clk gsbi8_p_clk = {
1557 .b = {
1558 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
1559 .en_mask = BIT(4),
1560 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1561 .halt_bit = 11,
1562 },
1563 .c = {
1564 .dbg_name = "gsbi8_p_clk",
1565 .ops = &clk_ops_branch,
1566 CLK_INIT(gsbi8_p_clk.c),
1567 },
1568};
1569
1570static struct branch_clk gsbi9_p_clk = {
1571 .b = {
1572 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
1573 .en_mask = BIT(4),
1574 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1575 .halt_bit = 7,
1576 },
1577 .c = {
1578 .dbg_name = "gsbi9_p_clk",
1579 .ops = &clk_ops_branch,
1580 CLK_INIT(gsbi9_p_clk.c),
1581 },
1582};
1583
1584static struct branch_clk gsbi10_p_clk = {
1585 .b = {
1586 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
1587 .en_mask = BIT(4),
1588 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1589 .halt_bit = 3,
1590 },
1591 .c = {
1592 .dbg_name = "gsbi10_p_clk",
1593 .ops = &clk_ops_branch,
1594 CLK_INIT(gsbi10_p_clk.c),
1595 },
1596};
1597
1598static struct branch_clk gsbi11_p_clk = {
1599 .b = {
1600 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
1601 .en_mask = BIT(4),
1602 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1603 .halt_bit = 18,
1604 },
1605 .c = {
1606 .dbg_name = "gsbi11_p_clk",
1607 .ops = &clk_ops_branch,
1608 CLK_INIT(gsbi11_p_clk.c),
1609 },
1610};
1611
1612static struct branch_clk gsbi12_p_clk = {
1613 .b = {
1614 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
1615 .en_mask = BIT(4),
1616 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1617 .halt_bit = 14,
1618 },
1619 .c = {
1620 .dbg_name = "gsbi12_p_clk",
1621 .ops = &clk_ops_branch,
1622 CLK_INIT(gsbi12_p_clk.c),
1623 },
1624};
1625
1626static struct branch_clk ppss_p_clk = {
1627 .b = {
1628 .ctl_reg = PPSS_HCLK_CTL_REG,
1629 .en_mask = BIT(4),
1630 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1631 .halt_bit = 19,
1632 },
1633 .c = {
1634 .dbg_name = "ppss_p_clk",
1635 .ops = &clk_ops_branch,
1636 CLK_INIT(ppss_p_clk.c),
1637 },
1638};
1639
1640static struct branch_clk tsif_p_clk = {
1641 .b = {
1642 .ctl_reg = TSIF_HCLK_CTL_REG,
1643 .en_mask = BIT(4),
1644 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1645 .halt_bit = 7,
1646 },
1647 .c = {
1648 .dbg_name = "tsif_p_clk",
1649 .ops = &clk_ops_branch,
1650 CLK_INIT(tsif_p_clk.c),
1651 },
1652};
1653
1654static struct branch_clk usb_fs1_p_clk = {
1655 .b = {
1656 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
1657 .en_mask = BIT(4),
1658 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1659 .halt_bit = 17,
1660 },
1661 .c = {
1662 .dbg_name = "usb_fs1_p_clk",
1663 .ops = &clk_ops_branch,
1664 CLK_INIT(usb_fs1_p_clk.c),
1665 },
1666};
1667
1668static struct branch_clk usb_fs2_p_clk = {
1669 .b = {
1670 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
1671 .en_mask = BIT(4),
1672 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1673 .halt_bit = 14,
1674 },
1675 .c = {
1676 .dbg_name = "usb_fs2_p_clk",
1677 .ops = &clk_ops_branch,
1678 CLK_INIT(usb_fs2_p_clk.c),
1679 },
1680};
1681
1682static struct branch_clk usb_hs1_p_clk = {
1683 .b = {
1684 .ctl_reg = USB_HS1_HCLK_CTL_REG,
1685 .en_mask = BIT(4),
1686 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1687 .halt_bit = 1,
1688 },
1689 .c = {
1690 .dbg_name = "usb_hs1_p_clk",
1691 .ops = &clk_ops_branch,
1692 CLK_INIT(usb_hs1_p_clk.c),
1693 },
1694};
1695
1696static struct branch_clk sdc1_p_clk = {
1697 .b = {
1698 .ctl_reg = SDCn_HCLK_CTL_REG(1),
1699 .en_mask = BIT(4),
1700 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1701 .halt_bit = 11,
1702 },
1703 .c = {
1704 .dbg_name = "sdc1_p_clk",
1705 .ops = &clk_ops_branch,
1706 CLK_INIT(sdc1_p_clk.c),
1707 },
1708};
1709
1710static struct branch_clk sdc2_p_clk = {
1711 .b = {
1712 .ctl_reg = SDCn_HCLK_CTL_REG(2),
1713 .en_mask = BIT(4),
1714 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1715 .halt_bit = 10,
1716 },
1717 .c = {
1718 .dbg_name = "sdc2_p_clk",
1719 .ops = &clk_ops_branch,
1720 CLK_INIT(sdc2_p_clk.c),
1721 },
1722};
1723
1724static struct branch_clk sdc3_p_clk = {
1725 .b = {
1726 .ctl_reg = SDCn_HCLK_CTL_REG(3),
1727 .en_mask = BIT(4),
1728 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1729 .halt_bit = 9,
1730 },
1731 .c = {
1732 .dbg_name = "sdc3_p_clk",
1733 .ops = &clk_ops_branch,
1734 CLK_INIT(sdc3_p_clk.c),
1735 },
1736};
1737
1738static struct branch_clk sdc4_p_clk = {
1739 .b = {
1740 .ctl_reg = SDCn_HCLK_CTL_REG(4),
1741 .en_mask = BIT(4),
1742 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1743 .halt_bit = 8,
1744 },
1745 .c = {
1746 .dbg_name = "sdc4_p_clk",
1747 .ops = &clk_ops_branch,
1748 CLK_INIT(sdc4_p_clk.c),
1749 },
1750};
1751
1752static struct branch_clk sdc5_p_clk = {
1753 .b = {
1754 .ctl_reg = SDCn_HCLK_CTL_REG(5),
1755 .en_mask = BIT(4),
1756 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1757 .halt_bit = 7,
1758 },
1759 .c = {
1760 .dbg_name = "sdc5_p_clk",
1761 .ops = &clk_ops_branch,
1762 CLK_INIT(sdc5_p_clk.c),
1763 },
1764};
1765
Matt Wagantall66cd0932011-09-12 19:04:34 -07001766static struct branch_clk ebi2_2x_clk = {
1767 .b = {
1768 .ctl_reg = EBI2_2X_CLK_CTL_REG,
1769 .en_mask = BIT(4),
1770 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1771 .halt_bit = 18,
1772 },
1773 .c = {
1774 .dbg_name = "ebi2_2x_clk",
1775 .ops = &clk_ops_branch,
1776 CLK_INIT(ebi2_2x_clk.c),
1777 },
1778};
1779
1780static struct branch_clk ebi2_clk = {
1781 .b = {
1782 .ctl_reg = EBI2_CLK_CTL_REG,
1783 .en_mask = BIT(4),
1784 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1785 .halt_bit = 19,
1786 },
1787 .c = {
1788 .dbg_name = "ebi2_clk",
1789 .ops = &clk_ops_branch,
1790 CLK_INIT(ebi2_clk.c),
1791 .depends = &ebi2_2x_clk.c,
1792 },
1793};
1794
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001795/* HW-Voteable Clocks */
1796static struct branch_clk adm0_clk = {
1797 .b = {
1798 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1799 .en_mask = BIT(2),
1800 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1801 .halt_check = HALT_VOTED,
1802 .halt_bit = 14,
1803 },
1804 .parent = &pxo_clk.c,
1805 .c = {
1806 .dbg_name = "adm0_clk",
1807 .ops = &clk_ops_branch,
1808 CLK_INIT(adm0_clk.c),
1809 },
1810};
1811
1812static struct branch_clk adm0_p_clk = {
1813 .b = {
1814 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1815 .en_mask = BIT(3),
1816 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1817 .halt_check = HALT_VOTED,
1818 .halt_bit = 13,
1819 },
1820 .c = {
1821 .dbg_name = "adm0_p_clk",
1822 .ops = &clk_ops_branch,
1823 CLK_INIT(adm0_p_clk.c),
1824 },
1825};
1826
1827static struct branch_clk adm1_clk = {
1828 .b = {
1829 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1830 .en_mask = BIT(4),
1831 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1832 .halt_check = HALT_VOTED,
1833 .halt_bit = 12,
1834 },
1835 .parent = &pxo_clk.c,
1836 .c = {
1837 .dbg_name = "adm1_clk",
1838 .ops = &clk_ops_branch,
1839 CLK_INIT(adm1_clk.c),
1840 },
1841};
1842
1843static struct branch_clk adm1_p_clk = {
1844 .b = {
1845 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1846 .en_mask = BIT(5),
1847 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1848 .halt_check = HALT_VOTED,
1849 .halt_bit = 11,
1850 },
1851 .c = {
1852 .dbg_name = "adm1_p_clk",
1853 .ops = &clk_ops_branch,
1854 CLK_INIT(adm1_p_clk.c),
1855 },
1856};
1857
1858static struct branch_clk modem_ahb1_p_clk = {
1859 .b = {
1860 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1861 .en_mask = BIT(0),
1862 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1863 .halt_check = HALT_VOTED,
1864 .halt_bit = 8,
1865 },
1866 .c = {
1867 .dbg_name = "modem_ahb1_p_clk",
1868 .ops = &clk_ops_branch,
1869 CLK_INIT(modem_ahb1_p_clk.c),
1870 },
1871};
1872
1873static struct branch_clk modem_ahb2_p_clk = {
1874 .b = {
1875 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1876 .en_mask = BIT(1),
1877 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1878 .halt_check = HALT_VOTED,
1879 .halt_bit = 7,
1880 },
1881 .c = {
1882 .dbg_name = "modem_ahb2_p_clk",
1883 .ops = &clk_ops_branch,
1884 CLK_INIT(modem_ahb2_p_clk.c),
1885 },
1886};
1887
1888static struct branch_clk pmic_arb0_p_clk = {
1889 .b = {
1890 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1891 .en_mask = BIT(8),
1892 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1893 .halt_check = HALT_VOTED,
1894 .halt_bit = 22,
1895 },
1896 .c = {
1897 .dbg_name = "pmic_arb0_p_clk",
1898 .ops = &clk_ops_branch,
1899 CLK_INIT(pmic_arb0_p_clk.c),
1900 },
1901};
1902
1903static struct branch_clk pmic_arb1_p_clk = {
1904 .b = {
1905 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1906 .en_mask = BIT(9),
1907 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1908 .halt_check = HALT_VOTED,
1909 .halt_bit = 21,
1910 },
1911 .c = {
1912 .dbg_name = "pmic_arb1_p_clk",
1913 .ops = &clk_ops_branch,
1914 CLK_INIT(pmic_arb1_p_clk.c),
1915 },
1916};
1917
1918static struct branch_clk pmic_ssbi2_clk = {
1919 .b = {
1920 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1921 .en_mask = BIT(7),
1922 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1923 .halt_check = HALT_VOTED,
1924 .halt_bit = 23,
1925 },
1926 .c = {
1927 .dbg_name = "pmic_ssbi2_clk",
1928 .ops = &clk_ops_branch,
1929 CLK_INIT(pmic_ssbi2_clk.c),
1930 },
1931};
1932
1933static struct branch_clk rpm_msg_ram_p_clk = {
1934 .b = {
1935 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1936 .en_mask = BIT(6),
1937 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1938 .halt_check = HALT_VOTED,
1939 .halt_bit = 12,
1940 },
1941 .c = {
1942 .dbg_name = "rpm_msg_ram_p_clk",
1943 .ops = &clk_ops_branch,
1944 CLK_INIT(rpm_msg_ram_p_clk.c),
1945 },
1946};
1947
1948/*
1949 * Multimedia Clocks
1950 */
1951
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001952#define F_CAM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001953 { \
1954 .freq_hz = f, \
1955 .src_clk = &s##_clk.c, \
1956 .md_val = MD8(8, m, 0, n), \
1957 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
1958 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001959 }
1960static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001961 F_CAM( 0, gnd, 1, 0, 0),
1962 F_CAM( 6000000, pll8, 4, 1, 16),
1963 F_CAM( 8000000, pll8, 4, 1, 12),
1964 F_CAM( 12000000, pll8, 4, 1, 8),
1965 F_CAM( 16000000, pll8, 4, 1, 6),
1966 F_CAM( 19200000, pll8, 4, 1, 5),
1967 F_CAM( 24000000, pll8, 4, 1, 4),
1968 F_CAM( 32000000, pll8, 4, 1, 3),
1969 F_CAM( 48000000, pll8, 4, 1, 2),
1970 F_CAM( 64000000, pll8, 3, 1, 2),
1971 F_CAM( 96000000, pll8, 4, 0, 0),
1972 F_CAM(128000000, pll8, 3, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001973 F_END
1974};
1975
1976static struct rcg_clk cam_clk = {
1977 .b = {
1978 .ctl_reg = CAMCLK_CC_REG,
1979 .en_mask = BIT(0),
1980 .halt_check = DELAY,
1981 },
1982 .ns_reg = CAMCLK_NS_REG,
1983 .md_reg = CAMCLK_MD_REG,
1984 .root_en_mask = BIT(2),
1985 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08001986 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001987 .ctl_mask = BM(7, 6),
1988 .set_rate = set_rate_mnd_8,
1989 .freq_tbl = clk_tbl_cam,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001990 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001991 .c = {
1992 .dbg_name = "cam_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001993 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001994 VDD_DIG_FMAX_MAP2(LOW, 64000000, NOMINAL, 128000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001995 CLK_INIT(cam_clk.c),
1996 },
1997};
1998
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001999#define F_CSI(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002000 { \
2001 .freq_hz = f, \
2002 .src_clk = &s##_clk.c, \
2003 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002004 }
2005static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002006 F_CSI( 0, gnd, 1),
2007 F_CSI(192000000, pll8, 2),
2008 F_CSI(384000000, pll8, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002009 F_END
2010};
2011
2012static struct rcg_clk csi_src_clk = {
2013 .ns_reg = CSI_NS_REG,
2014 .b = {
2015 .ctl_reg = CSI_CC_REG,
2016 .halt_check = NOCHECK,
2017 },
2018 .root_en_mask = BIT(2),
2019 .ns_mask = (BM(15, 12) | BM(2, 0)),
2020 .set_rate = set_rate_nop,
2021 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002022 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002023 .c = {
2024 .dbg_name = "csi_src_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002025 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002026 VDD_DIG_FMAX_MAP2(LOW, 192000000, NOMINAL, 384000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002027 CLK_INIT(csi_src_clk.c),
2028 },
2029};
2030
2031static struct branch_clk csi0_clk = {
2032 .b = {
2033 .ctl_reg = CSI_CC_REG,
2034 .en_mask = BIT(0),
2035 .reset_reg = SW_RESET_CORE_REG,
2036 .reset_mask = BIT(8),
2037 .halt_reg = DBG_BUS_VEC_B_REG,
2038 .halt_bit = 13,
2039 },
2040 .parent = &csi_src_clk.c,
2041 .c = {
2042 .dbg_name = "csi0_clk",
2043 .ops = &clk_ops_branch,
2044 CLK_INIT(csi0_clk.c),
2045 },
2046};
2047
2048static struct branch_clk csi1_clk = {
2049 .b = {
2050 .ctl_reg = CSI_CC_REG,
2051 .en_mask = BIT(7),
2052 .reset_reg = SW_RESET_CORE_REG,
2053 .reset_mask = BIT(18),
2054 .halt_reg = DBG_BUS_VEC_B_REG,
2055 .halt_bit = 14,
2056 },
2057 .parent = &csi_src_clk.c,
2058 .c = {
2059 .dbg_name = "csi1_clk",
2060 .ops = &clk_ops_branch,
2061 CLK_INIT(csi1_clk.c),
2062 },
2063};
2064
2065#define F_DSI(d) \
2066 { \
2067 .freq_hz = d, \
2068 .ns_val = BVAL(27, 24, (d-1)), \
2069 }
2070/* The DSI_BYTE clock is sourced from the DSI PHY PLL, which may change rate
2071 * without this clock driver knowing. So, overload the clk_set_rate() to set
2072 * the divider (1 to 16) of the clock with respect to the PLL rate. */
2073static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
2074 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
2075 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
2076 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
2077 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
2078 F_END
2079};
2080
2081
2082static struct rcg_clk dsi_byte_clk = {
2083 .b = {
2084 .ctl_reg = MISC_CC_REG,
2085 .halt_check = DELAY,
2086 .reset_reg = SW_RESET_CORE_REG,
2087 .reset_mask = BIT(7),
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002088 .retain_reg = MISC_CC2_REG,
2089 .retain_mask = BIT(10),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002090 },
2091 .ns_reg = MISC_CC2_REG,
2092 .root_en_mask = BIT(2),
2093 .ns_mask = BM(27, 24),
2094 .set_rate = set_rate_nop,
2095 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002096 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002097 .c = {
2098 .dbg_name = "dsi_byte_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002099 .ops = &clk_ops_rcg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002100 CLK_INIT(dsi_byte_clk.c),
2101 },
2102};
2103
2104static struct branch_clk dsi_esc_clk = {
2105 .b = {
2106 .ctl_reg = MISC_CC_REG,
2107 .en_mask = BIT(0),
2108 .halt_reg = DBG_BUS_VEC_B_REG,
2109 .halt_bit = 24,
2110 },
2111 .c = {
2112 .dbg_name = "dsi_esc_clk",
2113 .ops = &clk_ops_branch,
2114 CLK_INIT(dsi_esc_clk.c),
2115 },
2116};
2117
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002118#define F_GFX2D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002119 { \
2120 .freq_hz = f, \
2121 .src_clk = &s##_clk.c, \
2122 .md_val = MD4(4, m, 0, n), \
2123 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
2124 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002125 }
2126static struct clk_freq_tbl clk_tbl_gfx2d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002127 F_GFX2D( 0, gnd, 0, 0),
2128 F_GFX2D( 27000000, pxo, 0, 0),
2129 F_GFX2D( 48000000, pll8, 1, 8),
2130 F_GFX2D( 54857000, pll8, 1, 7),
2131 F_GFX2D( 64000000, pll8, 1, 6),
2132 F_GFX2D( 76800000, pll8, 1, 5),
2133 F_GFX2D( 96000000, pll8, 1, 4),
2134 F_GFX2D(128000000, pll8, 1, 3),
2135 F_GFX2D(145455000, pll2, 2, 11),
2136 F_GFX2D(160000000, pll2, 1, 5),
2137 F_GFX2D(177778000, pll2, 2, 9),
2138 F_GFX2D(200000000, pll2, 1, 4),
2139 F_GFX2D(228571000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002140 F_END
2141};
2142
2143static struct bank_masks bmnd_info_gfx2d0 = {
2144 .bank_sel_mask = BIT(11),
2145 .bank0_mask = {
2146 .md_reg = GFX2D0_MD0_REG,
2147 .ns_mask = BM(23, 20) | BM(5, 3),
2148 .rst_mask = BIT(25),
2149 .mnd_en_mask = BIT(8),
2150 .mode_mask = BM(10, 9),
2151 },
2152 .bank1_mask = {
2153 .md_reg = GFX2D0_MD1_REG,
2154 .ns_mask = BM(19, 16) | BM(2, 0),
2155 .rst_mask = BIT(24),
2156 .mnd_en_mask = BIT(5),
2157 .mode_mask = BM(7, 6),
2158 },
2159};
2160
2161static struct rcg_clk gfx2d0_clk = {
2162 .b = {
2163 .ctl_reg = GFX2D0_CC_REG,
2164 .en_mask = BIT(0),
2165 .reset_reg = SW_RESET_CORE_REG,
2166 .reset_mask = BIT(14),
2167 .halt_reg = DBG_BUS_VEC_A_REG,
2168 .halt_bit = 9,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002169 .retain_reg = GFX2D0_CC_REG,
2170 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002171 },
2172 .ns_reg = GFX2D0_NS_REG,
2173 .root_en_mask = BIT(2),
2174 .set_rate = set_rate_mnd_banked,
2175 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07002176 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002177 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002178 .c = {
2179 .dbg_name = "gfx2d0_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002180 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002181 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
2182 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002183 CLK_INIT(gfx2d0_clk.c),
2184 },
2185};
2186
2187static struct bank_masks bmnd_info_gfx2d1 = {
2188 .bank_sel_mask = BIT(11),
2189 .bank0_mask = {
2190 .md_reg = GFX2D1_MD0_REG,
2191 .ns_mask = BM(23, 20) | BM(5, 3),
2192 .rst_mask = BIT(25),
2193 .mnd_en_mask = BIT(8),
2194 .mode_mask = BM(10, 9),
2195 },
2196 .bank1_mask = {
2197 .md_reg = GFX2D1_MD1_REG,
2198 .ns_mask = BM(19, 16) | BM(2, 0),
2199 .rst_mask = BIT(24),
2200 .mnd_en_mask = BIT(5),
2201 .mode_mask = BM(7, 6),
2202 },
2203};
2204
2205static struct rcg_clk gfx2d1_clk = {
2206 .b = {
2207 .ctl_reg = GFX2D1_CC_REG,
2208 .en_mask = BIT(0),
2209 .reset_reg = SW_RESET_CORE_REG,
2210 .reset_mask = BIT(13),
2211 .halt_reg = DBG_BUS_VEC_A_REG,
2212 .halt_bit = 14,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002213 .retain_reg = GFX2D1_CC_REG,
2214 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002215 },
2216 .ns_reg = GFX2D1_NS_REG,
2217 .root_en_mask = BIT(2),
2218 .set_rate = set_rate_mnd_banked,
2219 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07002220 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002221 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002222 .c = {
2223 .dbg_name = "gfx2d1_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002224 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002225 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
2226 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002227 CLK_INIT(gfx2d1_clk.c),
2228 },
2229};
2230
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002231#define F_GFX3D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002232 { \
2233 .freq_hz = f, \
2234 .src_clk = &s##_clk.c, \
2235 .md_val = MD4(4, m, 0, n), \
2236 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
2237 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002238 }
2239static struct clk_freq_tbl clk_tbl_gfx3d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002240 F_GFX3D( 0, gnd, 0, 0),
2241 F_GFX3D( 27000000, pxo, 0, 0),
2242 F_GFX3D( 48000000, pll8, 1, 8),
2243 F_GFX3D( 54857000, pll8, 1, 7),
2244 F_GFX3D( 64000000, pll8, 1, 6),
2245 F_GFX3D( 76800000, pll8, 1, 5),
2246 F_GFX3D( 96000000, pll8, 1, 4),
2247 F_GFX3D(128000000, pll8, 1, 3),
2248 F_GFX3D(145455000, pll2, 2, 11),
2249 F_GFX3D(160000000, pll2, 1, 5),
2250 F_GFX3D(177778000, pll2, 2, 9),
2251 F_GFX3D(200000000, pll2, 1, 4),
2252 F_GFX3D(228571000, pll2, 2, 7),
2253 F_GFX3D(266667000, pll2, 1, 3),
2254 F_GFX3D(320000000, pll2, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002255 F_END
2256};
2257
2258static struct bank_masks bmnd_info_gfx3d = {
2259 .bank_sel_mask = BIT(11),
2260 .bank0_mask = {
2261 .md_reg = GFX3D_MD0_REG,
2262 .ns_mask = BM(21, 18) | BM(5, 3),
2263 .rst_mask = BIT(23),
2264 .mnd_en_mask = BIT(8),
2265 .mode_mask = BM(10, 9),
2266 },
2267 .bank1_mask = {
2268 .md_reg = GFX3D_MD1_REG,
2269 .ns_mask = BM(17, 14) | BM(2, 0),
2270 .rst_mask = BIT(22),
2271 .mnd_en_mask = BIT(5),
2272 .mode_mask = BM(7, 6),
2273 },
2274};
2275
2276static struct rcg_clk gfx3d_clk = {
2277 .b = {
2278 .ctl_reg = GFX3D_CC_REG,
2279 .en_mask = BIT(0),
2280 .reset_reg = SW_RESET_CORE_REG,
2281 .reset_mask = BIT(12),
2282 .halt_reg = DBG_BUS_VEC_A_REG,
2283 .halt_bit = 4,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002284 .retain_reg = GFX3D_CC_REG,
2285 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002286 },
2287 .ns_reg = GFX3D_NS_REG,
2288 .root_en_mask = BIT(2),
2289 .set_rate = set_rate_mnd_banked,
2290 .freq_tbl = clk_tbl_gfx3d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07002291 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002292 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002293 .c = {
2294 .dbg_name = "gfx3d_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002295 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002296 VDD_DIG_FMAX_MAP3(LOW, 96000000, NOMINAL, 200000000,
2297 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002298 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002299 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002300 },
2301};
2302
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002303#define F_IJPEG(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002304 { \
2305 .freq_hz = f, \
2306 .src_clk = &s##_clk.c, \
2307 .md_val = MD8(8, m, 0, n), \
2308 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
2309 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002310 }
2311static struct clk_freq_tbl clk_tbl_ijpeg[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002312 F_IJPEG( 0, gnd, 1, 0, 0),
2313 F_IJPEG( 27000000, pxo, 1, 0, 0),
2314 F_IJPEG( 36570000, pll8, 1, 2, 21),
2315 F_IJPEG( 54860000, pll8, 7, 0, 0),
2316 F_IJPEG( 96000000, pll8, 4, 0, 0),
2317 F_IJPEG(109710000, pll8, 1, 2, 7),
2318 F_IJPEG(128000000, pll8, 3, 0, 0),
2319 F_IJPEG(153600000, pll8, 1, 2, 5),
2320 F_IJPEG(200000000, pll2, 4, 0, 0),
2321 F_IJPEG(228571000, pll2, 1, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002322 F_END
2323};
2324
2325static struct rcg_clk ijpeg_clk = {
2326 .b = {
2327 .ctl_reg = IJPEG_CC_REG,
2328 .en_mask = BIT(0),
2329 .reset_reg = SW_RESET_CORE_REG,
2330 .reset_mask = BIT(9),
2331 .halt_reg = DBG_BUS_VEC_A_REG,
2332 .halt_bit = 24,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002333 .retain_reg = IJPEG_CC_REG,
2334 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002335 },
2336 .ns_reg = IJPEG_NS_REG,
2337 .md_reg = IJPEG_MD_REG,
2338 .root_en_mask = BIT(2),
2339 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08002340 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002341 .ctl_mask = BM(7, 6),
2342 .set_rate = set_rate_mnd,
2343 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002344 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002345 .c = {
2346 .dbg_name = "ijpeg_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002347 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002348 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002349 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002350 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002351 },
2352};
2353
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002354#define F_JPEGD(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002355 { \
2356 .freq_hz = f, \
2357 .src_clk = &s##_clk.c, \
2358 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002359 }
2360static struct clk_freq_tbl clk_tbl_jpegd[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002361 F_JPEGD( 0, gnd, 1),
2362 F_JPEGD( 64000000, pll8, 6),
2363 F_JPEGD( 76800000, pll8, 5),
2364 F_JPEGD( 96000000, pll8, 4),
2365 F_JPEGD(160000000, pll2, 5),
2366 F_JPEGD(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002367 F_END
2368};
2369
2370static struct rcg_clk jpegd_clk = {
2371 .b = {
2372 .ctl_reg = JPEGD_CC_REG,
2373 .en_mask = BIT(0),
2374 .reset_reg = SW_RESET_CORE_REG,
2375 .reset_mask = BIT(19),
2376 .halt_reg = DBG_BUS_VEC_A_REG,
2377 .halt_bit = 19,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002378 .retain_reg = JPEGD_CC_REG,
2379 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002380 },
2381 .ns_reg = JPEGD_NS_REG,
2382 .root_en_mask = BIT(2),
2383 .ns_mask = (BM(15, 12) | BM(2, 0)),
2384 .set_rate = set_rate_nop,
2385 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002386 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002387 .c = {
2388 .dbg_name = "jpegd_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002389 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002390 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002391 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002392 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002393 },
2394};
2395
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002396#define F_MDP(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002397 { \
2398 .freq_hz = f, \
2399 .src_clk = &s##_clk.c, \
2400 .md_val = MD8(8, m, 0, n), \
2401 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
2402 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002403 }
2404static struct clk_freq_tbl clk_tbl_mdp[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002405 F_MDP( 0, gnd, 0, 0),
2406 F_MDP( 9600000, pll8, 1, 40),
2407 F_MDP( 13710000, pll8, 1, 28),
2408 F_MDP( 27000000, pxo, 0, 0),
2409 F_MDP( 29540000, pll8, 1, 13),
2410 F_MDP( 34910000, pll8, 1, 11),
2411 F_MDP( 38400000, pll8, 1, 10),
2412 F_MDP( 59080000, pll8, 2, 13),
2413 F_MDP( 76800000, pll8, 1, 5),
2414 F_MDP( 85330000, pll8, 2, 9),
2415 F_MDP( 96000000, pll8, 1, 4),
2416 F_MDP(128000000, pll8, 1, 3),
2417 F_MDP(160000000, pll2, 1, 5),
2418 F_MDP(177780000, pll2, 2, 9),
2419 F_MDP(200000000, pll2, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002420 F_END
2421};
2422
2423static struct bank_masks bmnd_info_mdp = {
2424 .bank_sel_mask = BIT(11),
2425 .bank0_mask = {
2426 .md_reg = MDP_MD0_REG,
2427 .ns_mask = BM(29, 22) | BM(5, 3),
2428 .rst_mask = BIT(31),
2429 .mnd_en_mask = BIT(8),
2430 .mode_mask = BM(10, 9),
2431 },
2432 .bank1_mask = {
2433 .md_reg = MDP_MD1_REG,
2434 .ns_mask = BM(21, 14) | BM(2, 0),
2435 .rst_mask = BIT(30),
2436 .mnd_en_mask = BIT(5),
2437 .mode_mask = BM(7, 6),
2438 },
2439};
2440
2441static struct rcg_clk mdp_clk = {
2442 .b = {
2443 .ctl_reg = MDP_CC_REG,
2444 .en_mask = BIT(0),
2445 .reset_reg = SW_RESET_CORE_REG,
2446 .reset_mask = BIT(21),
2447 .halt_reg = DBG_BUS_VEC_C_REG,
2448 .halt_bit = 10,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002449 .retain_reg = MDP_CC_REG,
2450 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002451 },
2452 .ns_reg = MDP_NS_REG,
2453 .root_en_mask = BIT(2),
2454 .set_rate = set_rate_mnd_banked,
2455 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07002456 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002457 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002458 .c = {
2459 .dbg_name = "mdp_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002460 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002461 VDD_DIG_FMAX_MAP3(LOW, 85330000, NOMINAL, 200000000,
2462 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002463 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002464 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002465 },
2466};
2467
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002468#define F_MDP_VSYNC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002469 { \
2470 .freq_hz = f, \
2471 .src_clk = &s##_clk.c, \
2472 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002473 }
2474static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002475 F_MDP_VSYNC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002476 F_END
2477};
2478
2479static struct rcg_clk mdp_vsync_clk = {
2480 .b = {
2481 .ctl_reg = MISC_CC_REG,
2482 .en_mask = BIT(6),
2483 .reset_reg = SW_RESET_CORE_REG,
2484 .reset_mask = BIT(3),
2485 .halt_reg = DBG_BUS_VEC_B_REG,
2486 .halt_bit = 22,
2487 },
2488 .ns_reg = MISC_CC2_REG,
2489 .ns_mask = BIT(13),
2490 .set_rate = set_rate_nop,
2491 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002492 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002493 .c = {
2494 .dbg_name = "mdp_vsync_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002495 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002496 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002497 CLK_INIT(mdp_vsync_clk.c),
2498 },
2499};
2500
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002501#define F_PIXEL_MDP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002502 { \
2503 .freq_hz = f, \
2504 .src_clk = &s##_clk.c, \
2505 .md_val = MD16(m, n), \
2506 .ns_val = NS_MM(31, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2507 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002508 }
2509static struct clk_freq_tbl clk_tbl_pixel_mdp[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002510 F_PIXEL_MDP( 0, gnd, 1, 0, 0),
2511 F_PIXEL_MDP( 25600000, pll8, 3, 1, 5),
2512 F_PIXEL_MDP( 42667000, pll8, 1, 1, 9),
2513 F_PIXEL_MDP( 43192000, pll8, 1, 64, 569),
2514 F_PIXEL_MDP( 48000000, pll8, 4, 1, 2),
2515 F_PIXEL_MDP( 53990000, pll8, 2, 169, 601),
2516 F_PIXEL_MDP( 64000000, pll8, 2, 1, 3),
2517 F_PIXEL_MDP( 69300000, pll8, 1, 231, 1280),
2518 F_PIXEL_MDP( 76800000, pll8, 1, 1, 5),
2519 F_PIXEL_MDP( 85333000, pll8, 1, 2, 9),
2520 F_PIXEL_MDP(106500000, pll8, 1, 71, 256),
2521 F_PIXEL_MDP(109714000, pll8, 1, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002522 F_END
2523};
2524
2525static struct rcg_clk pixel_mdp_clk = {
2526 .ns_reg = PIXEL_NS_REG,
2527 .md_reg = PIXEL_MD_REG,
2528 .b = {
2529 .ctl_reg = PIXEL_CC_REG,
2530 .en_mask = BIT(0),
2531 .reset_reg = SW_RESET_CORE_REG,
2532 .reset_mask = BIT(5),
2533 .halt_reg = DBG_BUS_VEC_C_REG,
2534 .halt_bit = 23,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002535 .retain_reg = PIXEL_CC_REG,
2536 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002537 },
2538 .root_en_mask = BIT(2),
2539 .ns_mask = (BM(31, 16) | BM(15, 14) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08002540 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002541 .ctl_mask = BM(7, 6),
2542 .set_rate = set_rate_mnd,
2543 .freq_tbl = clk_tbl_pixel_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002544 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002545 .c = {
2546 .dbg_name = "pixel_mdp_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002547 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002548 VDD_DIG_FMAX_MAP2(LOW, 85333000, NOMINAL, 170000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002549 CLK_INIT(pixel_mdp_clk.c),
2550 },
2551};
2552
2553static struct branch_clk pixel_lcdc_clk = {
2554 .b = {
2555 .ctl_reg = PIXEL_CC_REG,
2556 .en_mask = BIT(8),
2557 .halt_reg = DBG_BUS_VEC_C_REG,
2558 .halt_bit = 21,
2559 },
2560 .parent = &pixel_mdp_clk.c,
2561 .c = {
2562 .dbg_name = "pixel_lcdc_clk",
2563 .ops = &clk_ops_branch,
2564 CLK_INIT(pixel_lcdc_clk.c),
2565 },
2566};
2567
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002568#define F_ROT(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002569 { \
2570 .freq_hz = f, \
2571 .src_clk = &s##_clk.c, \
2572 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
2573 21, 19, 18, 16, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002574 }
2575static struct clk_freq_tbl clk_tbl_rot[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002576 F_ROT( 0, gnd, 1),
2577 F_ROT( 27000000, pxo, 1),
2578 F_ROT( 29540000, pll8, 13),
2579 F_ROT( 32000000, pll8, 12),
2580 F_ROT( 38400000, pll8, 10),
2581 F_ROT( 48000000, pll8, 8),
2582 F_ROT( 54860000, pll8, 7),
2583 F_ROT( 64000000, pll8, 6),
2584 F_ROT( 76800000, pll8, 5),
2585 F_ROT( 96000000, pll8, 4),
2586 F_ROT(100000000, pll2, 8),
2587 F_ROT(114290000, pll2, 7),
2588 F_ROT(133330000, pll2, 6),
2589 F_ROT(160000000, pll2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002590 F_END
2591};
2592
2593static struct bank_masks bdiv_info_rot = {
2594 .bank_sel_mask = BIT(30),
2595 .bank0_mask = {
2596 .ns_mask = BM(25, 22) | BM(18, 16),
2597 },
2598 .bank1_mask = {
2599 .ns_mask = BM(29, 26) | BM(21, 19),
2600 },
2601};
2602
2603static struct rcg_clk rot_clk = {
2604 .b = {
2605 .ctl_reg = ROT_CC_REG,
2606 .en_mask = BIT(0),
2607 .reset_reg = SW_RESET_CORE_REG,
2608 .reset_mask = BIT(2),
2609 .halt_reg = DBG_BUS_VEC_C_REG,
2610 .halt_bit = 15,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002611 .retain_reg = ROT_CC_REG,
2612 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002613 },
2614 .ns_reg = ROT_NS_REG,
2615 .root_en_mask = BIT(2),
2616 .set_rate = set_rate_div_banked,
2617 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07002618 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002619 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002620 .c = {
2621 .dbg_name = "rot_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002622 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002623 VDD_DIG_FMAX_MAP2(LOW, 80000000, NOMINAL, 160000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002624 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002625 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002626 },
2627};
2628
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002629#define F_TV(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002630 { \
2631 .freq_hz = f, \
2632 .src_clk = &s##_clk.c, \
2633 .md_val = MD8(8, m, 0, n), \
2634 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2635 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002636 .extra_freq_data = p_r, \
2637 }
2638/* Switching TV freqs requires PLL reconfiguration. */
2639static struct pll_rate mm_pll2_rate[] = {
2640 [0] = PLL_RATE( 7, 6301, 13500, 0, 4, 0x4248B), /* 50400500 Hz */
2641 [1] = PLL_RATE( 8, 0, 0, 0, 4, 0x4248B), /* 54000000 Hz */
2642 [2] = PLL_RATE(16, 2, 125, 0, 4, 0x5248F), /* 108108000 Hz */
2643 [3] = PLL_RATE(22, 0, 0, 2, 4, 0x6248B), /* 148500000 Hz */
2644 [4] = PLL_RATE(44, 0, 0, 2, 4, 0x6248F), /* 297000000 Hz */
2645};
2646static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002647 F_TV( 0, gnd, &mm_pll2_rate[0], 1, 0, 0),
2648 F_TV( 25200000, pll3, &mm_pll2_rate[0], 2, 0, 0),
2649 F_TV( 27000000, pll3, &mm_pll2_rate[1], 2, 0, 0),
2650 F_TV( 27030000, pll3, &mm_pll2_rate[2], 4, 0, 0),
2651 F_TV( 74250000, pll3, &mm_pll2_rate[3], 2, 0, 0),
2652 F_TV(148500000, pll3, &mm_pll2_rate[4], 2, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002653 F_END
2654};
2655
2656static struct rcg_clk tv_src_clk = {
2657 .ns_reg = TV_NS_REG,
2658 .b = {
2659 .ctl_reg = TV_CC_REG,
2660 .halt_check = NOCHECK,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002661 .retain_reg = TV_CC_REG,
2662 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002663 },
2664 .md_reg = TV_MD_REG,
2665 .root_en_mask = BIT(2),
2666 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08002667 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002668 .ctl_mask = BM(7, 6),
2669 .set_rate = set_rate_tv,
2670 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002671 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002672 .c = {
2673 .dbg_name = "tv_src_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002674 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002675 VDD_DIG_FMAX_MAP2(LOW, 27030000, NOMINAL, 149000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002676 CLK_INIT(tv_src_clk.c),
2677 },
2678};
2679
2680static struct branch_clk tv_enc_clk = {
2681 .b = {
2682 .ctl_reg = TV_CC_REG,
2683 .en_mask = BIT(8),
2684 .reset_reg = SW_RESET_CORE_REG,
2685 .reset_mask = BIT(0),
2686 .halt_reg = DBG_BUS_VEC_D_REG,
2687 .halt_bit = 8,
2688 },
2689 .parent = &tv_src_clk.c,
2690 .c = {
2691 .dbg_name = "tv_enc_clk",
2692 .ops = &clk_ops_branch,
2693 CLK_INIT(tv_enc_clk.c),
2694 },
2695};
2696
2697static struct branch_clk tv_dac_clk = {
2698 .b = {
2699 .ctl_reg = TV_CC_REG,
2700 .en_mask = BIT(10),
2701 .halt_reg = DBG_BUS_VEC_D_REG,
2702 .halt_bit = 9,
2703 },
2704 .parent = &tv_src_clk.c,
2705 .c = {
2706 .dbg_name = "tv_dac_clk",
2707 .ops = &clk_ops_branch,
2708 CLK_INIT(tv_dac_clk.c),
2709 },
2710};
2711
2712static struct branch_clk mdp_tv_clk = {
2713 .b = {
2714 .ctl_reg = TV_CC_REG,
2715 .en_mask = BIT(0),
2716 .reset_reg = SW_RESET_CORE_REG,
2717 .reset_mask = BIT(4),
2718 .halt_reg = DBG_BUS_VEC_D_REG,
2719 .halt_bit = 11,
2720 },
2721 .parent = &tv_src_clk.c,
2722 .c = {
2723 .dbg_name = "mdp_tv_clk",
2724 .ops = &clk_ops_branch,
2725 CLK_INIT(mdp_tv_clk.c),
2726 },
2727};
2728
2729static struct branch_clk hdmi_tv_clk = {
2730 .b = {
2731 .ctl_reg = TV_CC_REG,
2732 .en_mask = BIT(12),
2733 .reset_reg = SW_RESET_CORE_REG,
2734 .reset_mask = BIT(1),
2735 .halt_reg = DBG_BUS_VEC_D_REG,
2736 .halt_bit = 10,
2737 },
2738 .parent = &tv_src_clk.c,
2739 .c = {
2740 .dbg_name = "hdmi_tv_clk",
2741 .ops = &clk_ops_branch,
2742 CLK_INIT(hdmi_tv_clk.c),
2743 },
2744};
2745
2746static struct branch_clk hdmi_app_clk = {
2747 .b = {
2748 .ctl_reg = MISC_CC2_REG,
2749 .en_mask = BIT(11),
2750 .reset_reg = SW_RESET_CORE_REG,
2751 .reset_mask = BIT(11),
2752 .halt_reg = DBG_BUS_VEC_B_REG,
2753 .halt_bit = 25,
2754 },
2755 .c = {
2756 .dbg_name = "hdmi_app_clk",
2757 .ops = &clk_ops_branch,
2758 CLK_INIT(hdmi_app_clk.c),
2759 },
2760};
2761
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002762#define F_VCODEC(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002763 { \
2764 .freq_hz = f, \
2765 .src_clk = &s##_clk.c, \
2766 .md_val = MD8(8, m, 0, n), \
2767 .ns_val = NS_MM(18, 11, n, m, 0, 0, 1, 2, 0, s##_to_mm_mux), \
2768 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002769 }
2770static struct clk_freq_tbl clk_tbl_vcodec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002771 F_VCODEC( 0, gnd, 0, 0),
2772 F_VCODEC( 27000000, pxo, 0, 0),
2773 F_VCODEC( 32000000, pll8, 1, 12),
2774 F_VCODEC( 48000000, pll8, 1, 8),
2775 F_VCODEC( 54860000, pll8, 1, 7),
2776 F_VCODEC( 96000000, pll8, 1, 4),
2777 F_VCODEC(133330000, pll2, 1, 6),
2778 F_VCODEC(200000000, pll2, 1, 4),
2779 F_VCODEC(228570000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002780 F_END
2781};
2782
2783static struct rcg_clk vcodec_clk = {
2784 .b = {
2785 .ctl_reg = VCODEC_CC_REG,
2786 .en_mask = BIT(0),
2787 .reset_reg = SW_RESET_CORE_REG,
2788 .reset_mask = BIT(6),
2789 .halt_reg = DBG_BUS_VEC_C_REG,
2790 .halt_bit = 29,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002791 .retain_reg = VCODEC_CC_REG,
2792 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002793 },
2794 .ns_reg = VCODEC_NS_REG,
2795 .md_reg = VCODEC_MD0_REG,
2796 .root_en_mask = BIT(2),
2797 .ns_mask = (BM(18, 11) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08002798 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002799 .ctl_mask = BM(7, 6),
2800 .set_rate = set_rate_mnd,
2801 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002802 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002803 .c = {
2804 .dbg_name = "vcodec_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002805 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002806 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
2807 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002808 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002809 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002810 },
2811};
2812
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002813#define F_VPE(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002814 { \
2815 .freq_hz = f, \
2816 .src_clk = &s##_clk.c, \
2817 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002818 }
2819static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002820 F_VPE( 0, gnd, 1),
2821 F_VPE( 27000000, pxo, 1),
2822 F_VPE( 34909000, pll8, 11),
2823 F_VPE( 38400000, pll8, 10),
2824 F_VPE( 64000000, pll8, 6),
2825 F_VPE( 76800000, pll8, 5),
2826 F_VPE( 96000000, pll8, 4),
2827 F_VPE(100000000, pll2, 8),
2828 F_VPE(160000000, pll2, 5),
2829 F_VPE(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002830 F_END
2831};
2832
2833static struct rcg_clk vpe_clk = {
2834 .b = {
2835 .ctl_reg = VPE_CC_REG,
2836 .en_mask = BIT(0),
2837 .reset_reg = SW_RESET_CORE_REG,
2838 .reset_mask = BIT(17),
2839 .halt_reg = DBG_BUS_VEC_A_REG,
2840 .halt_bit = 28,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002841 .retain_reg = VPE_CC_REG,
2842 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002843 },
2844 .ns_reg = VPE_NS_REG,
2845 .root_en_mask = BIT(2),
2846 .ns_mask = (BM(15, 12) | BM(2, 0)),
2847 .set_rate = set_rate_nop,
2848 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002849 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002850 .c = {
2851 .dbg_name = "vpe_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002852 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002853 VDD_DIG_FMAX_MAP3(LOW, 76800000, NOMINAL, 160000000,
2854 HIGH, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002855 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002856 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002857 },
2858};
2859
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002860#define F_VFE(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002861 { \
2862 .freq_hz = f, \
2863 .src_clk = &s##_clk.c, \
2864 .md_val = MD8(8, m, 0, n), \
2865 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
2866 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002867 }
2868static struct clk_freq_tbl clk_tbl_vfe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002869 F_VFE( 0, gnd, 1, 0, 0),
2870 F_VFE( 13960000, pll8, 1, 2, 55),
2871 F_VFE( 27000000, pxo, 1, 0, 0),
2872 F_VFE( 36570000, pll8, 1, 2, 21),
2873 F_VFE( 38400000, pll8, 2, 1, 5),
2874 F_VFE( 45180000, pll8, 1, 2, 17),
2875 F_VFE( 48000000, pll8, 2, 1, 4),
2876 F_VFE( 54860000, pll8, 1, 1, 7),
2877 F_VFE( 64000000, pll8, 2, 1, 3),
2878 F_VFE( 76800000, pll8, 1, 1, 5),
2879 F_VFE( 96000000, pll8, 2, 1, 2),
2880 F_VFE(109710000, pll8, 1, 2, 7),
2881 F_VFE(128000000, pll8, 1, 1, 3),
2882 F_VFE(153600000, pll8, 1, 2, 5),
2883 F_VFE(200000000, pll2, 2, 1, 2),
2884 F_VFE(228570000, pll2, 1, 2, 7),
2885 F_VFE(266667000, pll2, 1, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002886 F_END
2887};
2888
2889static struct rcg_clk vfe_clk = {
2890 .b = {
2891 .ctl_reg = VFE_CC_REG,
2892 .reset_reg = SW_RESET_CORE_REG,
2893 .reset_mask = BIT(15),
2894 .halt_reg = DBG_BUS_VEC_B_REG,
2895 .halt_bit = 6,
2896 .en_mask = BIT(0),
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002897 .retain_reg = VFE_CC_REG,
2898 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002899 },
2900 .ns_reg = VFE_NS_REG,
2901 .md_reg = VFE_MD_REG,
2902 .root_en_mask = BIT(2),
2903 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08002904 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002905 .ctl_mask = BM(7, 6),
2906 .set_rate = set_rate_mnd,
2907 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002908 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002909 .c = {
2910 .dbg_name = "vfe_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002911 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002912 VDD_DIG_FMAX_MAP3(LOW, 110000000, NOMINAL, 228570000,
2913 HIGH, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002914 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002915 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002916 },
2917};
2918
2919static struct branch_clk csi0_vfe_clk = {
2920 .b = {
2921 .ctl_reg = VFE_CC_REG,
2922 .en_mask = BIT(12),
2923 .reset_reg = SW_RESET_CORE_REG,
2924 .reset_mask = BIT(24),
2925 .halt_reg = DBG_BUS_VEC_B_REG,
2926 .halt_bit = 7,
2927 },
2928 .parent = &vfe_clk.c,
2929 .c = {
2930 .dbg_name = "csi0_vfe_clk",
2931 .ops = &clk_ops_branch,
2932 CLK_INIT(csi0_vfe_clk.c),
2933 },
2934};
2935
2936static struct branch_clk csi1_vfe_clk = {
2937 .b = {
2938 .ctl_reg = VFE_CC_REG,
2939 .en_mask = BIT(10),
2940 .reset_reg = SW_RESET_CORE_REG,
2941 .reset_mask = BIT(23),
2942 .halt_reg = DBG_BUS_VEC_B_REG,
2943 .halt_bit = 8,
2944 },
2945 .parent = &vfe_clk.c,
2946 .c = {
2947 .dbg_name = "csi1_vfe_clk",
2948 .ops = &clk_ops_branch,
2949 CLK_INIT(csi1_vfe_clk.c),
2950 },
2951};
2952
2953/*
2954 * Low Power Audio Clocks
2955 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002956#define F_AIF_OSR(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002957 { \
2958 .freq_hz = f, \
2959 .src_clk = &s##_clk.c, \
2960 .md_val = MD8(8, m, 0, n), \
2961 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002962 }
2963static struct clk_freq_tbl clk_tbl_aif_osr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002964 F_AIF_OSR( 0, gnd, 1, 0, 0),
2965 F_AIF_OSR( 768000, pll4, 4, 1, 176),
2966 F_AIF_OSR( 1024000, pll4, 4, 1, 132),
2967 F_AIF_OSR( 1536000, pll4, 4, 1, 88),
2968 F_AIF_OSR( 2048000, pll4, 4, 1, 66),
2969 F_AIF_OSR( 3072000, pll4, 4, 1, 44),
2970 F_AIF_OSR( 4096000, pll4, 4, 1, 33),
2971 F_AIF_OSR( 6144000, pll4, 4, 1, 22),
2972 F_AIF_OSR( 8192000, pll4, 2, 1, 33),
2973 F_AIF_OSR(12288000, pll4, 4, 1, 11),
2974 F_AIF_OSR(24576000, pll4, 2, 1, 11),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002975 F_END
2976};
2977
2978#define CLK_AIF_OSR(i, ns, md, h_r) \
2979 struct rcg_clk i##_clk = { \
2980 .b = { \
2981 .ctl_reg = ns, \
2982 .en_mask = BIT(17), \
2983 .reset_reg = ns, \
2984 .reset_mask = BIT(19), \
2985 .halt_reg = h_r, \
2986 .halt_check = ENABLE, \
2987 .halt_bit = 1, \
2988 }, \
2989 .ns_reg = ns, \
2990 .md_reg = md, \
2991 .root_en_mask = BIT(9), \
2992 .ns_mask = (BM(31, 24) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08002993 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002994 .set_rate = set_rate_mnd, \
2995 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002996 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002997 .c = { \
2998 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -07002999 .ops = &clk_ops_rcg, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003000 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003001 CLK_INIT(i##_clk.c), \
3002 }, \
3003 }
3004
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003005#define CLK_AIF_BIT(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08003006 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003007 .b = { \
3008 .ctl_reg = ns, \
3009 .en_mask = BIT(15), \
3010 .halt_reg = h_r, \
3011 .halt_check = DELAY, \
3012 }, \
3013 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08003014 .ext_mask = BIT(14), \
3015 .div_offset = 10, \
3016 .max_div = 16, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003017 .c = { \
3018 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08003019 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003020 CLK_INIT(i##_clk.c), \
3021 }, \
3022 }
3023
3024static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
3025 LCC_MI2S_STATUS_REG);
3026static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
3027
3028static CLK_AIF_OSR(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
3029 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
3030static CLK_AIF_BIT(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
3031 LCC_CODEC_I2S_MIC_STATUS_REG);
3032
3033static CLK_AIF_OSR(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
3034 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
3035static CLK_AIF_BIT(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
3036 LCC_SPARE_I2S_MIC_STATUS_REG);
3037
3038static CLK_AIF_OSR(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
3039 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
3040static CLK_AIF_BIT(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
3041 LCC_CODEC_I2S_SPKR_STATUS_REG);
3042
3043static CLK_AIF_OSR(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
3044 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
3045static CLK_AIF_BIT(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
3046 LCC_SPARE_I2S_SPKR_STATUS_REG);
3047
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003048#define F_PCM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003049 { \
3050 .freq_hz = f, \
3051 .src_clk = &s##_clk.c, \
3052 .md_val = MD16(m, n), \
3053 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003054 }
3055static struct clk_freq_tbl clk_tbl_pcm[] = {
Stephen Boyd630f3252012-01-31 00:10:08 -08003056 { .ns_val = BIT(10) /* external input */ },
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003057 F_PCM( 512000, pll4, 4, 1, 264),
3058 F_PCM( 768000, pll4, 4, 1, 176),
3059 F_PCM( 1024000, pll4, 4, 1, 132),
3060 F_PCM( 1536000, pll4, 4, 1, 88),
3061 F_PCM( 2048000, pll4, 4, 1, 66),
3062 F_PCM( 3072000, pll4, 4, 1, 44),
3063 F_PCM( 4096000, pll4, 4, 1, 33),
3064 F_PCM( 6144000, pll4, 4, 1, 22),
3065 F_PCM( 8192000, pll4, 2, 1, 33),
3066 F_PCM(12288000, pll4, 4, 1, 11),
3067 F_PCM(24580000, pll4, 2, 1, 11),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003068 F_END
3069};
3070
3071static struct rcg_clk pcm_clk = {
3072 .b = {
3073 .ctl_reg = LCC_PCM_NS_REG,
3074 .en_mask = BIT(11),
3075 .reset_reg = LCC_PCM_NS_REG,
3076 .reset_mask = BIT(13),
3077 .halt_reg = LCC_PCM_STATUS_REG,
3078 .halt_check = ENABLE,
3079 .halt_bit = 0,
3080 },
3081 .ns_reg = LCC_PCM_NS_REG,
3082 .md_reg = LCC_PCM_MD_REG,
3083 .root_en_mask = BIT(9),
Stephen Boyd630f3252012-01-31 00:10:08 -08003084 .ns_mask = BM(31, 16) | BIT(10) | BM(6, 0),
Matt Wagantall07c45472012-02-10 23:27:24 -08003085 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003086 .set_rate = set_rate_mnd,
3087 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003088 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003089 .c = {
3090 .dbg_name = "pcm_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07003091 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003092 VDD_DIG_FMAX_MAP1(LOW, 24580000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003093 CLK_INIT(pcm_clk.c),
3094 },
3095};
3096
Matt Wagantall735f01a2011-08-12 12:40:28 -07003097DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
3098DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
3099DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
3100DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
3101DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
3102DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
3103DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
3104DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Matt Wagantallf8032602011-06-15 23:01:56 -07003105DEFINE_CLK_RPM(smi_clk, smi_a_clk, SMI, &smi_2x_axi_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003106
Matt Wagantall35e78fc2012-04-05 14:18:44 -07003107static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c, 0);
3108static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c, 0);
3109static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c, 0);
3110static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c, 0);
3111static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c, 0);
3112static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c, 0);
3113static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c, 0);
3114static DEFINE_CLK_VOTER(dfab_scm_clk, &dfab_clk.c, 0);
Ramesh Masavarapued4e6012012-04-12 16:30:40 -07003115static DEFINE_CLK_VOTER(dfab_qseecom_clk, &dfab_clk.c, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003116
Matt Wagantall42cd12a2012-03-30 18:02:40 -07003117static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c, LONG_MAX);
Matt Wagantall35e78fc2012-04-05 14:18:44 -07003118static DEFINE_CLK_VOTER(ebi1_adm0_clk, &ebi1_clk.c, 0);
3119static DEFINE_CLK_VOTER(ebi1_adm1_clk, &ebi1_clk.c, 0);
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003120static DEFINE_CLK_VOTER(ebi1_acpu_a_clk, &ebi1_a_clk.c, LONG_MAX);
3121static DEFINE_CLK_VOTER(ebi1_msmbus_a_clk, &ebi1_a_clk.c, LONG_MAX);
3122static DEFINE_CLK_VOTER(afab_acpu_a_clk, &afab_a_clk.c, LONG_MAX);
3123static DEFINE_CLK_VOTER(afab_msmbus_a_clk, &afab_a_clk.c, LONG_MAX);
3124
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003125static DEFINE_CLK_MEASURE(sc0_m_clk);
3126static DEFINE_CLK_MEASURE(sc1_m_clk);
3127static DEFINE_CLK_MEASURE(l2_m_clk);
3128
3129#ifdef CONFIG_DEBUG_FS
3130struct measure_sel {
3131 u32 test_vector;
3132 struct clk *clk;
3133};
3134
3135static struct measure_sel measure_mux[] = {
3136 { TEST_PER_LS(0x08), &modem_ahb1_p_clk.c },
3137 { TEST_PER_LS(0x09), &modem_ahb2_p_clk.c },
3138 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
3139 { TEST_PER_LS(0x13), &sdc1_clk.c },
3140 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
3141 { TEST_PER_LS(0x15), &sdc2_clk.c },
3142 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
3143 { TEST_PER_LS(0x17), &sdc3_clk.c },
3144 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
3145 { TEST_PER_LS(0x19), &sdc4_clk.c },
3146 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
3147 { TEST_PER_LS(0x1B), &sdc5_clk.c },
Matt Wagantall66cd0932011-09-12 19:04:34 -07003148 { TEST_PER_LS(0x1D), &ebi2_2x_clk.c },
3149 { TEST_PER_LS(0x1E), &ebi2_clk.c },
Matt Wagantall7625a4c2011-11-01 16:17:53 -07003150 { TEST_PER_LS(0x1F), &gp0_clk.c },
3151 { TEST_PER_LS(0x20), &gp1_clk.c },
3152 { TEST_PER_LS(0x21), &gp2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003153 { TEST_PER_LS(0x25), &dfab_clk.c },
3154 { TEST_PER_LS(0x25), &dfab_a_clk.c },
3155 { TEST_PER_LS(0x26), &pmem_clk.c },
3156 { TEST_PER_LS(0x2B), &ppss_p_clk.c },
3157 { TEST_PER_LS(0x33), &cfpb_clk.c },
3158 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
3159 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
3160 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
3161 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
3162 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
3163 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
3164 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
3165 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
3166 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
3167 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
3168 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
3169 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
3170 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
3171 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
3172 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
3173 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
3174 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
3175 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
3176 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
3177 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
3178 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
3179 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
3180 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
3181 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
3182 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
3183 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
3184 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
3185 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
3186 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
3187 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
3188 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
3189 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
3190 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
3191 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
3192 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
3193 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
3194 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
3195 { TEST_PER_LS(0x78), &sfpb_clk.c },
3196 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
3197 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
3198 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
3199 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
3200 { TEST_PER_LS(0x7D), &prng_clk.c },
3201 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
3202 { TEST_PER_LS(0x80), &adm0_p_clk.c },
3203 { TEST_PER_LS(0x81), &adm1_p_clk.c },
3204 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
3205 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
3206 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
3207 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
3208 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
3209 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
3210 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
3211 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
3212 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
3213 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
3214 { TEST_PER_LS(0x93), &ce2_p_clk.c },
3215 { TEST_PER_LS(0x94), &tssc_clk.c },
3216
3217 { TEST_PER_HS(0x07), &afab_clk.c },
3218 { TEST_PER_HS(0x07), &afab_a_clk.c },
3219 { TEST_PER_HS(0x18), &sfab_clk.c },
3220 { TEST_PER_HS(0x18), &sfab_a_clk.c },
3221 { TEST_PER_HS(0x2A), &adm0_clk.c },
3222 { TEST_PER_HS(0x2B), &adm1_clk.c },
3223 { TEST_PER_HS(0x34), &ebi1_clk.c },
3224 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
3225
3226 { TEST_MM_LS(0x00), &dsi_byte_clk.c },
3227 { TEST_MM_LS(0x01), &pixel_lcdc_clk.c },
3228 { TEST_MM_LS(0x04), &pixel_mdp_clk.c },
3229 { TEST_MM_LS(0x06), &amp_p_clk.c },
3230 { TEST_MM_LS(0x07), &csi0_p_clk.c },
3231 { TEST_MM_LS(0x08), &csi1_p_clk.c },
3232 { TEST_MM_LS(0x09), &dsi_m_p_clk.c },
3233 { TEST_MM_LS(0x0A), &dsi_s_p_clk.c },
3234 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
3235 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
3236 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
3237 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
3238 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
3239 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
3240 { TEST_MM_LS(0x12), &imem_p_clk.c },
3241 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
3242 { TEST_MM_LS(0x14), &mdp_p_clk.c },
3243 { TEST_MM_LS(0x16), &rot_p_clk.c },
3244 { TEST_MM_LS(0x18), &smmu_p_clk.c },
3245 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
3246 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
3247 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
3248 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
3249 { TEST_MM_LS(0x1D), &cam_clk.c },
3250 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
3251 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
3252 { TEST_MM_LS(0x21), &tv_dac_clk.c },
3253 { TEST_MM_LS(0x22), &tv_enc_clk.c },
3254 { TEST_MM_LS(0x23), &dsi_esc_clk.c },
3255 { TEST_MM_LS(0x25), &mmfpb_clk.c },
3256 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
3257
3258 { TEST_MM_HS(0x00), &csi0_clk.c },
3259 { TEST_MM_HS(0x01), &csi1_clk.c },
3260 { TEST_MM_HS(0x03), &csi0_vfe_clk.c },
3261 { TEST_MM_HS(0x04), &csi1_vfe_clk.c },
3262 { TEST_MM_HS(0x05), &ijpeg_clk.c },
3263 { TEST_MM_HS(0x06), &vfe_clk.c },
3264 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
3265 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
3266 { TEST_MM_HS(0x09), &gfx3d_clk.c },
3267 { TEST_MM_HS(0x0A), &jpegd_clk.c },
3268 { TEST_MM_HS(0x0B), &vcodec_clk.c },
3269 { TEST_MM_HS(0x0F), &mmfab_clk.c },
3270 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
3271 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
3272 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
3273 { TEST_MM_HS(0x13), &imem_axi_clk.c },
3274 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
3275 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
Matt Wagantallf63a8892011-06-15 16:44:46 -07003276 { TEST_MM_HS(0x16), &rot_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003277 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
3278 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
Matt Wagantallf63a8892011-06-15 16:44:46 -07003279 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003280 { TEST_MM_HS(0x1A), &mdp_clk.c },
3281 { TEST_MM_HS(0x1B), &rot_clk.c },
3282 { TEST_MM_HS(0x1C), &vpe_clk.c },
3283 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
3284 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
Matt Wagantallf8032602011-06-15 23:01:56 -07003285 { TEST_MM_HS(0x24), &smi_2x_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003286
3287 { TEST_MM_HS2X(0x24), &smi_clk.c },
3288 { TEST_MM_HS2X(0x24), &smi_a_clk.c },
3289
3290 { TEST_LPA(0x0A), &mi2s_osr_clk.c },
3291 { TEST_LPA(0x0B), &mi2s_bit_clk.c },
3292 { TEST_LPA(0x0C), &codec_i2s_mic_osr_clk.c },
3293 { TEST_LPA(0x0D), &codec_i2s_mic_bit_clk.c },
3294 { TEST_LPA(0x0E), &codec_i2s_spkr_osr_clk.c },
3295 { TEST_LPA(0x0F), &codec_i2s_spkr_bit_clk.c },
3296 { TEST_LPA(0x10), &spare_i2s_mic_osr_clk.c },
3297 { TEST_LPA(0x11), &spare_i2s_mic_bit_clk.c },
3298 { TEST_LPA(0x12), &spare_i2s_spkr_osr_clk.c },
3299 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
3300 { TEST_LPA(0x14), &pcm_clk.c },
3301
3302 { TEST_SC(0x40), &sc0_m_clk },
3303 { TEST_SC(0x41), &sc1_m_clk },
3304 { TEST_SC(0x42), &l2_m_clk },
3305};
3306
3307static struct measure_sel *find_measure_sel(struct clk *clk)
3308{
3309 int i;
3310
3311 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
3312 if (measure_mux[i].clk == clk)
3313 return &measure_mux[i];
3314 return NULL;
3315}
3316
3317static int measure_clk_set_parent(struct clk *c, struct clk *parent)
3318{
3319 int ret = 0;
3320 u32 clk_sel;
3321 struct measure_sel *p;
3322 struct measure_clk *clk = to_measure_clk(c);
3323 unsigned long flags;
3324
3325 if (!parent)
3326 return -EINVAL;
3327
3328 p = find_measure_sel(parent);
3329 if (!p)
3330 return -EINVAL;
3331
3332 spin_lock_irqsave(&local_clock_reg_lock, flags);
3333
3334 /*
3335 * Program the test vector, measurement period (sample_ticks)
3336 * and scaling factors (multiplier, divider).
3337 */
3338 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
3339 clk->sample_ticks = 0x10000;
3340 clk->multiplier = 1;
3341 clk->divider = 1;
3342 switch (p->test_vector >> TEST_TYPE_SHIFT) {
3343 case TEST_TYPE_PER_LS:
3344 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
3345 break;
3346 case TEST_TYPE_PER_HS:
3347 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
3348 break;
3349 case TEST_TYPE_MM_LS:
3350 writel_relaxed(0x4030D97, CLK_TEST_REG);
3351 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
3352 break;
3353 case TEST_TYPE_MM_HS2X:
3354 clk->divider = 2;
3355 case TEST_TYPE_MM_HS:
3356 writel_relaxed(0x402B800, CLK_TEST_REG);
3357 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
3358 break;
3359 case TEST_TYPE_LPA:
3360 writel_relaxed(0x4030D98, CLK_TEST_REG);
3361 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
3362 LCC_CLK_LS_DEBUG_CFG_REG);
3363 break;
3364 case TEST_TYPE_SC:
3365 writel_relaxed(0x5020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
3366 clk->sample_ticks = 0x4000;
3367 clk->multiplier = 2;
3368 break;
3369 default:
3370 ret = -EPERM;
3371 }
3372 /* Make sure test vector is set before starting measurements. */
3373 mb();
3374
3375 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3376
3377 return ret;
3378}
3379
3380/* Sample clock for 'ticks' reference clock ticks. */
3381static u32 run_measurement(unsigned ticks)
3382{
3383 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003384 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
3385
3386 /* Wait for timer to become ready. */
3387 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
3388 cpu_relax();
3389
3390 /* Run measurement and wait for completion. */
3391 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
3392 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
3393 cpu_relax();
3394
3395 /* Stop counters. */
3396 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
3397
3398 /* Return measured ticks. */
3399 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
3400}
3401
3402/* Perform a hardware rate measurement for a given clock.
3403 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003404static unsigned long measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003405{
3406 unsigned long flags;
3407 u32 pdm_reg_backup, ringosc_reg_backup;
3408 u64 raw_count_short, raw_count_full;
3409 struct measure_clk *clk = to_measure_clk(c);
3410 unsigned ret;
3411
3412 spin_lock_irqsave(&local_clock_reg_lock, flags);
3413
3414 /* Enable CXO/4 and RINGOSC branch and root. */
3415 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
3416 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
3417 writel_relaxed(0x2898, PDM_CLK_NS_REG);
3418 writel_relaxed(0xA00, RINGOSC_NS_REG);
3419
3420 /*
3421 * The ring oscillator counter will not reset if the measured clock
3422 * is not running. To detect this, run a short measurement before
3423 * the full measurement. If the raw results of the two are the same
3424 * then the clock must be off.
3425 */
3426
3427 /* Run a short measurement. (~1 ms) */
3428 raw_count_short = run_measurement(0x1000);
3429 /* Run a full measurement. (~14 ms) */
3430 raw_count_full = run_measurement(clk->sample_ticks);
3431
3432 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
3433 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
3434
3435 /* Return 0 if the clock is off. */
3436 if (raw_count_full == raw_count_short)
3437 ret = 0;
3438 else {
3439 /* Compute rate in Hz. */
3440 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
3441 do_div(raw_count_full,
3442 (((clk->sample_ticks * 10) + 35) * clk->divider));
3443 ret = (raw_count_full * clk->multiplier);
3444 }
3445
3446 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
3447 writel_relaxed(0x3CF8, PLLTEST_PAD_CFG_REG);
3448 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3449
3450 return ret;
3451}
3452#else /* !CONFIG_DEBUG_FS */
3453static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
3454{
3455 return -EINVAL;
3456}
3457
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003458static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003459{
3460 return 0;
3461}
3462#endif /* CONFIG_DEBUG_FS */
3463
Matt Wagantallae053222012-05-14 19:42:07 -07003464static struct clk_ops clk_ops_measure = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003465 .set_parent = measure_clk_set_parent,
3466 .get_rate = measure_clk_get_rate,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003467};
3468
3469static struct measure_clk measure_clk = {
3470 .c = {
3471 .dbg_name = "measure_clk",
Matt Wagantallae053222012-05-14 19:42:07 -07003472 .ops = &clk_ops_measure,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003473 CLK_INIT(measure_clk.c),
3474 },
3475 .multiplier = 1,
3476 .divider = 1,
3477};
3478
3479static struct clk_lookup msm_clocks_8x60[] = {
Stephen Boyd72a80352012-01-26 15:57:38 -08003480 CLK_LOOKUP("xo", cxo_clk.c, ""),
3481 CLK_LOOKUP("xo", cxo_a_clk.c, ""),
3482 CLK_LOOKUP("xo", pxo_a_clk.c, ""),
Stephen Boyd67036532012-01-26 15:43:51 -08003483 CLK_LOOKUP("xo", pxo_clk.c, "pil_modem"),
Stephen Boyd3acc9e42011-09-28 16:46:40 -07003484 CLK_LOOKUP("pll4", pll4_clk.c, "pil_qdsp6v3"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003485 CLK_LOOKUP("measure", measure_clk.c, "debug"),
3486
Matt Wagantalld75f1312012-05-23 16:17:35 -07003487 CLK_LOOKUP("bus_clk", afab_clk.c, ""),
3488 CLK_LOOKUP("bus_clk", afab_a_clk.c, ""),
3489 CLK_LOOKUP("bus_clk", cfpb_clk.c, ""),
3490 CLK_LOOKUP("bus_clk", cfpb_a_clk.c, ""),
3491 CLK_LOOKUP("bus_clk", dfab_clk.c, ""),
3492 CLK_LOOKUP("bus_clk", dfab_a_clk.c, ""),
3493 CLK_LOOKUP("mem_clk", ebi1_clk.c, ""),
3494 CLK_LOOKUP("mem_clk", ebi1_a_clk.c, ""),
3495 CLK_LOOKUP("bus_clk", mmfab_clk.c, ""),
3496 CLK_LOOKUP("bus_clk", mmfab_a_clk.c, ""),
3497 CLK_LOOKUP("bus_clk", mmfpb_clk.c, ""),
3498 CLK_LOOKUP("bus_clk", mmfpb_a_clk.c, ""),
3499 CLK_LOOKUP("bus_clk", sfab_clk.c, ""),
3500 CLK_LOOKUP("bus_clk", sfab_a_clk.c, ""),
3501 CLK_LOOKUP("bus_clk", sfpb_clk.c, ""),
3502 CLK_LOOKUP("bus_clk", sfpb_a_clk.c, ""),
3503 CLK_LOOKUP("mem_clk", smi_clk.c, ""),
3504 CLK_LOOKUP("mem_clk", smi_a_clk.c, ""),
3505
Matt Wagantallb2710b82011-11-16 19:55:17 -08003506 CLK_LOOKUP("bus_clk", afab_clk.c, "msm_apps_fab"),
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003507 CLK_LOOKUP("bus_a_clk", afab_msmbus_a_clk.c, "msm_apps_fab"),
Matt Wagantallb2710b82011-11-16 19:55:17 -08003508 CLK_LOOKUP("bus_clk", sfab_clk.c, "msm_sys_fab"),
3509 CLK_LOOKUP("bus_a_clk", sfab_a_clk.c, "msm_sys_fab"),
3510 CLK_LOOKUP("bus_clk", sfpb_clk.c, "msm_sys_fpb"),
3511 CLK_LOOKUP("bus_a_clk", sfpb_a_clk.c, "msm_sys_fpb"),
3512 CLK_LOOKUP("bus_clk", mmfab_clk.c, "msm_mm_fab"),
3513 CLK_LOOKUP("bus_a_clk", mmfab_a_clk.c, "msm_mm_fab"),
3514 CLK_LOOKUP("bus_clk", cfpb_clk.c, "msm_cpss_fpb"),
3515 CLK_LOOKUP("bus_a_clk", cfpb_a_clk.c, "msm_cpss_fpb"),
3516 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003517 CLK_LOOKUP("mem_a_clk", ebi1_msmbus_a_clk.c, "msm_bus"),
Matt Wagantallb2710b82011-11-16 19:55:17 -08003518 CLK_LOOKUP("smi_clk", smi_clk.c, "msm_bus"),
3519 CLK_LOOKUP("smi_a_clk", smi_a_clk.c, "msm_bus"),
3520
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003521 CLK_LOOKUP("core_clk", gp0_clk.c, ""),
3522 CLK_LOOKUP("core_clk", gp1_clk.c, ""),
3523 CLK_LOOKUP("core_clk", gp2_clk.c, ""),
3524 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, ""),
3525 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003526 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, "msm_serial_hsl.2"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003527 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, ""),
3528 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003529 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003530 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, ""),
3531 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003532 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, "msm_serial_hsl.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003533 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, ""),
3534 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003535 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, "msm_serial_hsl.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003536 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003537 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07003538 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.0"),
3539 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003540 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, ""),
3541 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07003542 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, "qup_i2c.4"),
3543 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, "qup_i2c.3"),
3544 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, "qup_i2c.2"),
3545 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "spi_qsd.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003546 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, ""),
Wentao Xu4a053042011-10-03 14:06:34 -04003547 CLK_LOOKUP("gsbi_qup_clk", gsbi12_qup_clk.c, "msm_dsps"),
Matt Wagantallac294852011-08-17 15:44:58 -07003548 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.5"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003549 CLK_LOOKUP("core_clk", pdm_clk.c, ""),
Wentao Xu4a053042011-10-03 14:06:34 -04003550 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_dsps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07003551 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07003552 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
3553 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
3554 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
3555 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
3556 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07003557 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, "msm_tsif.0"),
3558 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, "msm_tsif.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003559 CLK_LOOKUP("core_clk", tssc_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08003560 CLK_LOOKUP("alt_core_clk", usb_hs1_xcvr_clk.c, "msm_otg"),
3561 CLK_LOOKUP("phy_clk", usb_phy0_clk.c, "msm_otg"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003562 CLK_LOOKUP("alt_core_clk", usb_fs1_xcvr_clk.c, ""),
3563 CLK_LOOKUP("sys_clk", usb_fs1_sys_clk.c, ""),
3564 CLK_LOOKUP("src_clk", usb_fs1_src_clk.c, ""),
3565 CLK_LOOKUP("alt_core_clk", usb_fs2_xcvr_clk.c, ""),
3566 CLK_LOOKUP("sys_clk", usb_fs2_sys_clk.c, ""),
3567 CLK_LOOKUP("src_clk", usb_fs2_src_clk.c, ""),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07003568 CLK_LOOKUP("core_clk", ce2_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07003569 CLK_LOOKUP("core_clk", ce2_p_clk.c, "qcrypto.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003570 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003571 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003572 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "msm_serial_hsl.2"),
Matt Wagantallac294852011-08-17 15:44:58 -07003573 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.0"),
3574 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003575 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003576 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003577 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, "qup_i2c.4"),
3578 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, "qup_i2c.3"),
Matt Wagantalle2522372011-08-17 14:52:21 -07003579 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, "msm_serial_hsl.1"),
Matt Wagantallac294852011-08-17 15:44:58 -07003580 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, "qup_i2c.2"),
3581 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "spi_qsd.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003582 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, ""),
3583 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003584 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "msm_serial_hsl.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003585 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.5"),
Matt Wagantall5bb16ca2012-04-19 11:34:01 -07003586 CLK_LOOKUP("iface_clk", ppss_p_clk.c, "msm_dsps"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07003587 CLK_LOOKUP("iface_clk", tsif_p_clk.c, "msm_tsif.0"),
3588 CLK_LOOKUP("iface_clk", tsif_p_clk.c, "msm_tsif.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003589 CLK_LOOKUP("iface_clk", usb_fs1_p_clk.c, ""),
3590 CLK_LOOKUP("iface_clk", usb_fs2_p_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08003591 CLK_LOOKUP("iface_clk", usb_hs1_p_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07003592 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
3593 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
3594 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
3595 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
3596 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003597 CLK_LOOKUP("mem_clk", ebi2_2x_clk.c, ""),
Terence Hampsonb36a38c2011-09-19 19:10:40 -04003598 CLK_LOOKUP("mem_clk", ebi2_clk.c, "msm_ebi2"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07003599 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov.0"),
3600 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov.0"),
3601 CLK_LOOKUP("core_clk", adm1_clk.c, "msm_dmov.1"),
3602 CLK_LOOKUP("iface_clk", adm1_p_clk.c, "msm_dmov.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003603 CLK_LOOKUP("iface_clk", modem_ahb1_p_clk.c, ""),
3604 CLK_LOOKUP("iface_clk", modem_ahb2_p_clk.c, ""),
3605 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, ""),
3606 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, ""),
3607 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, ""),
3608 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003609 CLK_LOOKUP("cam_clk", cam_clk.c, NULL),
3610 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
3611 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov7692.0"),
3612 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov9726.0"),
Kevin Chan3be11612012-03-22 20:05:40 -07003613 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csic.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003614 CLK_LOOKUP("csi_src_clk", csi_src_clk.c, NULL),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003615 CLK_LOOKUP("byte_clk", dsi_byte_clk.c, "mipi_dsi.1"),
3616 CLK_LOOKUP("esc_clk", dsi_esc_clk.c, "mipi_dsi.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003617 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003618 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003619 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07003620 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003621 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003622 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
Matt Wagantallf45cd362012-05-03 21:09:44 -07003623 CLK_LOOKUP("core_clk", ijpeg_clk.c, "msm_gemini.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003624 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07003625 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003626 CLK_LOOKUP("core_clk", mdp_clk.c, "mdp.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003627 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003628 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "mdp.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003629 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003630 CLK_LOOKUP("lcdc_clk", pixel_lcdc_clk.c, "lcdc.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003631 CLK_LOOKUP("pixel_lcdc_clk", pixel_lcdc_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003632 CLK_LOOKUP("mdp_clk", pixel_mdp_clk.c, "lcdc.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003633 CLK_LOOKUP("pixel_mdp_clk", pixel_mdp_clk.c, "footswitch-8x60.4"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07003634 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003635 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003636 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
3637 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07003638 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003639 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003640 CLK_LOOKUP("mdp_clk", mdp_tv_clk.c, "dtv.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003641 CLK_LOOKUP("tv_clk", mdp_tv_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003642 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, "dtv.0"),
3643 CLK_LOOKUP("src_clk", tv_src_clk.c, "dtv.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003644 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, "footswitch-8x60.4"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07003645 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003646 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003647 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003648 CLK_LOOKUP("csi_vfe_clk", csi0_vfe_clk.c, NULL),
3649 CLK_LOOKUP("csi_vfe_clk", csi1_vfe_clk.c, "msm_camera_ov7692.0"),
3650 CLK_LOOKUP("csi_vfe_clk", csi1_vfe_clk.c, "msm_camera_ov9726.0"),
Kevin Chan3be11612012-03-22 20:05:40 -07003651 CLK_LOOKUP("csi_vfe_clk", csi1_vfe_clk.c, "msm_csic.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003652 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003653 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Matt Wagantall49722712011-08-17 18:50:53 -07003654 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
3655 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003656 CLK_LOOKUP("mem_clk", imem_axi_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003657 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
3658 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
3659 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
3660 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003661 CLK_LOOKUP("arb_clk", amp_p_clk.c, "mipi_dsi.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003662 CLK_LOOKUP("csi_pclk", csi0_p_clk.c, NULL),
3663 CLK_LOOKUP("csi_pclk", csi1_p_clk.c, "msm_camera_ov7692.0"),
3664 CLK_LOOKUP("csi_pclk", csi1_p_clk.c, "msm_camera_ov9726.0"),
Kevin Chan3be11612012-03-22 20:05:40 -07003665 CLK_LOOKUP("csi_pclk", csi1_p_clk.c, "msm_csic.1"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003666 CLK_LOOKUP("master_iface_clk", dsi_m_p_clk.c, "mipi_dsi.1"),
3667 CLK_LOOKUP("slave_iface_clk", dsi_s_p_clk.c, "mipi_dsi.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003668 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003669 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003670 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07003671 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003672 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003673 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07003674 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
3675 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Matt Wagantallf45cd362012-05-03 21:09:44 -07003676 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "msm_gemini.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003677 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07003678 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003679 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, "kgsl-3d0.0"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003680 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "mdp.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003681 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07003682 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07003683 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003684 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003685 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07003686 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003687 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003688 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003689 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003690 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003691 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003692 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
3693 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
3694 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
3695 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
3696 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
3697 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
3698 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
3699 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
3700 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
3701 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
3702 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
Matt Wagantalle604d712011-10-21 15:38:18 -07003703 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
Matt Wagantall21903c02012-04-17 16:39:58 -07003704 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
Matt Wagantalle604d712011-10-21 15:38:18 -07003705 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
3706 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
Matt Wagantall21903c02012-04-17 16:39:58 -07003707 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07003708 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
3709 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
3710 CLK_LOOKUP("core_clk", vcodec_axi_clk.c, "msm_iommu.7"),
3711 CLK_LOOKUP("core_clk", vcodec_axi_clk.c, "msm_iommu.8"),
3712 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
3713 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
3714 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003715
Riaz Rahaman966922b2012-02-21 10:48:01 -08003716 CLK_LOOKUP("mdp_iommu_clk", mdp_axi_clk.c, "msm_vidc.0"),
3717 CLK_LOOKUP("rot_iommu_clk", rot_axi_clk.c, "msm_vidc.0"),
3718 CLK_LOOKUP("vcodec_iommu0_clk", vcodec_axi_clk.c, "msm_vidc.0"),
3719 CLK_LOOKUP("vcodec_iommu1_clk", vcodec_axi_clk.c, "msm_vidc.0"),
3720 CLK_LOOKUP("smmu_iface_clk", smmu_p_clk.c, "msm_vidc.0"),
3721
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003722 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
Manu Gautam5143b252012-01-05 19:25:23 -08003723 CLK_LOOKUP("core_clk", dfab_usb_hs_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07003724 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
3725 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
3726 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
3727 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
3728 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Stephen Boydef5d1c42011-12-15 20:47:14 -08003729 CLK_LOOKUP("bus_clk", dfab_scm_clk.c, "scm"),
Ramesh Masavarapued4e6012012-04-12 16:30:40 -07003730 CLK_LOOKUP("bus_clk", dfab_qseecom_clk.c, "qseecom"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003731
Matt Wagantalle1a86062011-08-18 17:46:10 -07003732 CLK_LOOKUP("mem_clk", ebi1_adm0_clk.c, "msm_dmov.0"),
3733 CLK_LOOKUP("mem_clk", ebi1_adm1_clk.c, "msm_dmov.1"),
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003734 CLK_LOOKUP("mem_clk", ebi1_acpu_a_clk.c, ""),
3735 CLK_LOOKUP("bus_clk", afab_acpu_a_clk.c, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003736
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003737 CLK_LOOKUP("sc0_mclk", sc0_m_clk, ""),
3738 CLK_LOOKUP("sc1_mclk", sc1_m_clk, ""),
3739 CLK_LOOKUP("l2_mclk", l2_m_clk, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003740};
3741
3742/*
3743 * Miscellaneous clock register initializations
3744 */
3745
3746/* Read, modify, then write-back a register. */
3747static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
3748{
3749 uint32_t regval = readl_relaxed(reg);
3750 regval &= ~mask;
3751 regval |= val;
3752 writel_relaxed(regval, reg);
3753}
3754
Matt Wagantallb64888f2012-04-02 21:35:07 -07003755static void __init msm8660_clock_pre_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003756{
Matt Wagantallb64888f2012-04-02 21:35:07 -07003757 vote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
3758
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003759 /* Setup MM_PLL2 (PLL3), but turn it off. Rate set by set_rate_tv(). */
3760 rmwreg(0, MM_PLL2_MODE_REG, BIT(0)); /* Disable output */
3761 /* Set ref, bypass, assert reset, disable output, disable test mode */
3762 writel_relaxed(0, MM_PLL2_MODE_REG); /* PXO */
3763 writel_relaxed(0x00800000, MM_PLL2_CONFIG_REG); /* Enable main out. */
3764
3765 /* The clock driver doesn't use SC1's voting register to control
3766 * HW-voteable clocks. Clear its bits so that disabling bits in the
3767 * SC0 register will cause the corresponding clocks to be disabled. */
3768 rmwreg(BIT(12)|BIT(11), SC0_U_CLK_BRANCH_ENA_VOTE_REG, BM(12, 11));
3769 writel_relaxed(BIT(12)|BIT(11), SC1_U_CLK_BRANCH_ENA_VOTE_REG);
3770 /* Let sc_aclk and sc_clk halt when both Scorpions are collapsed. */
3771 writel_relaxed(BIT(12)|BIT(11), SC0_U_CLK_SLEEP_ENA_VOTE_REG);
3772 writel_relaxed(BIT(12)|BIT(11), SC1_U_CLK_SLEEP_ENA_VOTE_REG);
3773
3774 /* Deassert MM SW_RESET_ALL signal. */
3775 writel_relaxed(0, SW_RESET_ALL_REG);
3776
3777 /* Initialize MM AHB registers: Enable the FPB clock and disable HW
3778 * gating for all clocks. Also set VFE_AHB's FORCE_CORE_ON bit to
3779 * prevent its memory from being collapsed when the clock is halted.
3780 * The sleep and wake-up delays are set to safe values. */
Matt Wagantall30011d22011-07-25 20:32:04 -07003781 rmwreg(0x00000003, AHB_EN_REG, 0x6C000003);
3782 writel_relaxed(0x000007F9, AHB_EN2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003783
3784 /* Deassert all locally-owned MM AHB resets. */
3785 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
3786
3787 /* Initialize MM AXI registers: Enable HW gating for all clocks that
3788 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
3789 * delays to safe values. */
Matt Wagantall30011d22011-07-25 20:32:04 -07003790 rmwreg(0x100207F9, MAXI_EN_REG, 0x1803FFFF);
3791 rmwreg(0x7027FCFF, MAXI_EN2_REG, 0x7A3FFFFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003792 writel_relaxed(0x3FE7FCFF, MAXI_EN3_REG);
3793 writel_relaxed(0x000001D8, SAXI_EN_REG);
3794
3795 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
3796 * memories retain state even when not clocked. Also, set sleep and
3797 * wake-up delays to safe values. */
Matt Wagantall30011d22011-07-25 20:32:04 -07003798 rmwreg(0x00000000, CSI_CC_REG, 0x00000018);
3799 rmwreg(0x00000400, MISC_CC_REG, 0x017C0400);
3800 rmwreg(0x000007FD, MISC_CC2_REG, 0x70C2E7FF);
3801 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
3802 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
3803 rmwreg(0x80FF0000, GFX3D_CC_REG, 0xE0FF0010);
3804 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0018);
3805 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0018);
3806 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
3807 rmwreg(0x80FF0000, PIXEL_CC_REG, 0xE1FF0010);
3808 rmwreg(0x000004FF, PIXEL_CC2_REG, 0x000007FF);
3809 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
3810 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
3811 rmwreg(0x000004FF, TV_CC2_REG, 0x000027FF);
3812 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
3813 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FFC010);
3814 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003815
3816 /* De-assert MM AXI resets to all hardware blocks. */
3817 writel_relaxed(0, SW_RESET_AXI_REG);
3818
3819 /* Deassert all MM core resets. */
3820 writel_relaxed(0, SW_RESET_CORE_REG);
3821
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003822 /* Enable TSSC and PDM PXO sources. */
3823 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
3824 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
3825 /* Set the dsi_byte_clk src to the DSI PHY PLL,
3826 * dsi_esc_clk to PXO/2, and the hdmi_app_clk src to PXO */
3827 rmwreg(0x400001, MISC_CC2_REG, 0x424003);
Stephen Boyd842a1f62012-04-26 19:07:38 -07003828
3829 if ((readl_relaxed(PRNG_CLK_NS_REG) & 0x7F) == 0x2B)
3830 prng_clk.freq_tbl = clk_tbl_prng_64;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003831}
3832
Matt Wagantallb64888f2012-04-02 21:35:07 -07003833static void __init msm8660_clock_post_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003834{
Stephen Boyd72a80352012-01-26 15:57:38 -08003835 /* Keep PXO on whenever APPS cpu is active */
3836 clk_prepare_enable(&pxo_a_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003837
Matt Wagantalle655cd72012-04-09 10:15:03 -07003838 /* Reset 3D core while clocked to ensure it resets completely. */
3839 clk_set_rate(&gfx3d_clk.c, 27000000);
3840 clk_prepare_enable(&gfx3d_clk.c);
3841 clk_reset(&gfx3d_clk.c, CLK_RESET_ASSERT);
3842 udelay(5);
3843 clk_reset(&gfx3d_clk.c, CLK_RESET_DEASSERT);
3844 clk_disable_unprepare(&gfx3d_clk.c);
3845
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003846 /* Initialize rates for clocks that only support one. */
3847 clk_set_rate(&pdm_clk.c, 27000000);
Stephen Boyd842a1f62012-04-26 19:07:38 -07003848 clk_set_rate(&prng_clk.c, prng_clk.freq_tbl->freq_hz);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003849 clk_set_rate(&mdp_vsync_clk.c, 27000000);
3850 clk_set_rate(&tsif_ref_clk.c, 105000);
3851 clk_set_rate(&tssc_clk.c, 27000000);
3852 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
3853 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
3854 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
3855
3856 /* The halt status bits for PDM and TSSC may be incorrect at boot.
3857 * Toggle these clocks on and off to refresh them. */
Stephen Boyd409b8b42012-04-10 12:12:56 -07003858 clk_prepare_enable(&pdm_clk.c);
3859 clk_disable_unprepare(&pdm_clk.c);
3860 clk_prepare_enable(&tssc_clk.c);
3861 clk_disable_unprepare(&tssc_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003862}
3863
Stephen Boydbb600ae2011-08-02 20:11:40 -07003864static int __init msm8660_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003865{
3866 int rc;
3867
3868 /* Vote for MMFPB to be at least 64MHz when an Apps CPU is active. */
3869 struct clk *mmfpb_a_clk = clk_get(NULL, "mmfpb_a_clk");
3870 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
3871 PTR_ERR(mmfpb_a_clk)))
3872 return PTR_ERR(mmfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08003873 rc = clk_set_rate(mmfpb_a_clk, 64000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003874 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
3875 return rc;
Stephen Boyde334aeb2012-01-24 12:17:29 -08003876 rc = clk_prepare_enable(mmfpb_a_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003877 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
3878 return rc;
3879
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003880 return unvote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003881}
Stephen Boydbb600ae2011-08-02 20:11:40 -07003882
3883struct clock_init_data msm8x60_clock_init_data __initdata = {
3884 .table = msm_clocks_8x60,
3885 .size = ARRAY_SIZE(msm_clocks_8x60),
Matt Wagantallb64888f2012-04-02 21:35:07 -07003886 .pre_init = msm8660_clock_pre_init,
3887 .post_init = msm8660_clock_post_init,
Stephen Boydbb600ae2011-08-02 20:11:40 -07003888 .late_init = msm8660_clock_late_init,
3889};