blob: 74d71a2dd072cd947adb8661a254aa31ccc05b72 [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,
Matt Wagantall158f73b2012-05-16 11:29:35 -0700703 .flags = CLKFLAG_SKIP_HANDOFF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700704 CLK_INIT(gfx2d0_p_clk.c),
705 },
706};
707
708static struct branch_clk gfx2d1_p_clk = {
709 .b = {
710 .ctl_reg = AHB_EN_REG,
711 .en_mask = BIT(2),
712 .reset_reg = SW_RESET_AHB_REG,
713 .reset_mask = BIT(11),
714 .halt_reg = DBG_BUS_VEC_F_REG,
715 .halt_bit = 3,
716 },
717 .c = {
718 .dbg_name = "gfx2d1_p_clk",
719 .ops = &clk_ops_branch,
Matt Wagantall158f73b2012-05-16 11:29:35 -0700720 .flags = CLKFLAG_SKIP_HANDOFF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700721 CLK_INIT(gfx2d1_p_clk.c),
722 },
723};
724
725static struct branch_clk gfx3d_p_clk = {
726 .b = {
727 .ctl_reg = AHB_EN_REG,
728 .en_mask = BIT(3),
729 .reset_reg = SW_RESET_AHB_REG,
730 .reset_mask = BIT(10),
731 .halt_reg = DBG_BUS_VEC_F_REG,
732 .halt_bit = 4,
733 },
734 .c = {
735 .dbg_name = "gfx3d_p_clk",
736 .ops = &clk_ops_branch,
737 CLK_INIT(gfx3d_p_clk.c),
738 },
739};
740
741static struct branch_clk hdmi_m_p_clk = {
742 .b = {
743 .ctl_reg = AHB_EN_REG,
744 .en_mask = BIT(14),
745 .reset_reg = SW_RESET_AHB_REG,
746 .reset_mask = BIT(9),
747 .halt_reg = DBG_BUS_VEC_F_REG,
748 .halt_bit = 5,
749 },
750 .c = {
751 .dbg_name = "hdmi_m_p_clk",
752 .ops = &clk_ops_branch,
753 CLK_INIT(hdmi_m_p_clk.c),
754 },
755};
756
757static struct branch_clk hdmi_s_p_clk = {
758 .b = {
759 .ctl_reg = AHB_EN_REG,
760 .en_mask = BIT(4),
761 .reset_reg = SW_RESET_AHB_REG,
762 .reset_mask = BIT(9),
763 .halt_reg = DBG_BUS_VEC_F_REG,
764 .halt_bit = 6,
765 },
766 .c = {
767 .dbg_name = "hdmi_s_p_clk",
768 .ops = &clk_ops_branch,
769 CLK_INIT(hdmi_s_p_clk.c),
770 },
771};
772
773static struct branch_clk ijpeg_p_clk = {
774 .b = {
775 .ctl_reg = AHB_EN_REG,
776 .en_mask = BIT(5),
777 .reset_reg = SW_RESET_AHB_REG,
778 .reset_mask = BIT(7),
779 .halt_reg = DBG_BUS_VEC_F_REG,
780 .halt_bit = 9,
781 },
782 .c = {
783 .dbg_name = "ijpeg_p_clk",
784 .ops = &clk_ops_branch,
785 CLK_INIT(ijpeg_p_clk.c),
786 },
787};
788
789static struct branch_clk imem_p_clk = {
790 .b = {
791 .ctl_reg = AHB_EN_REG,
792 .en_mask = BIT(6),
793 .reset_reg = SW_RESET_AHB_REG,
794 .reset_mask = BIT(8),
795 .halt_reg = DBG_BUS_VEC_F_REG,
796 .halt_bit = 10,
797 },
798 .c = {
799 .dbg_name = "imem_p_clk",
800 .ops = &clk_ops_branch,
801 CLK_INIT(imem_p_clk.c),
802 },
803};
804
805static struct branch_clk jpegd_p_clk = {
806 .b = {
807 .ctl_reg = AHB_EN_REG,
808 .en_mask = BIT(21),
809 .reset_reg = SW_RESET_AHB_REG,
810 .reset_mask = BIT(4),
811 .halt_reg = DBG_BUS_VEC_F_REG,
812 .halt_bit = 7,
813 },
814 .c = {
815 .dbg_name = "jpegd_p_clk",
816 .ops = &clk_ops_branch,
817 CLK_INIT(jpegd_p_clk.c),
818 },
819};
820
821static struct branch_clk mdp_p_clk = {
822 .b = {
823 .ctl_reg = AHB_EN_REG,
824 .en_mask = BIT(10),
825 .reset_reg = SW_RESET_AHB_REG,
826 .reset_mask = BIT(3),
827 .halt_reg = DBG_BUS_VEC_F_REG,
828 .halt_bit = 11,
829 },
830 .c = {
831 .dbg_name = "mdp_p_clk",
832 .ops = &clk_ops_branch,
833 CLK_INIT(mdp_p_clk.c),
834 },
835};
836
837static struct branch_clk rot_p_clk = {
838 .b = {
839 .ctl_reg = AHB_EN_REG,
840 .en_mask = BIT(12),
841 .reset_reg = SW_RESET_AHB_REG,
842 .reset_mask = BIT(2),
843 .halt_reg = DBG_BUS_VEC_F_REG,
844 .halt_bit = 13,
845 },
846 .c = {
847 .dbg_name = "rot_p_clk",
848 .ops = &clk_ops_branch,
849 CLK_INIT(rot_p_clk.c),
850 },
851};
852
853static struct branch_clk smmu_p_clk = {
854 .b = {
855 .ctl_reg = AHB_EN_REG,
856 .en_mask = BIT(15),
857 .halt_reg = DBG_BUS_VEC_F_REG,
858 .halt_bit = 22,
859 },
860 .c = {
861 .dbg_name = "smmu_p_clk",
862 .ops = &clk_ops_branch,
863 CLK_INIT(smmu_p_clk.c),
864 },
865};
866
867static struct branch_clk tv_enc_p_clk = {
868 .b = {
869 .ctl_reg = AHB_EN_REG,
870 .en_mask = BIT(25),
871 .reset_reg = SW_RESET_AHB_REG,
872 .reset_mask = BIT(15),
873 .halt_reg = DBG_BUS_VEC_F_REG,
874 .halt_bit = 23,
875 },
876 .c = {
877 .dbg_name = "tv_enc_p_clk",
878 .ops = &clk_ops_branch,
879 CLK_INIT(tv_enc_p_clk.c),
880 },
881};
882
883static struct branch_clk vcodec_p_clk = {
884 .b = {
885 .ctl_reg = AHB_EN_REG,
886 .en_mask = BIT(11),
887 .reset_reg = SW_RESET_AHB_REG,
888 .reset_mask = BIT(1),
889 .halt_reg = DBG_BUS_VEC_F_REG,
890 .halt_bit = 12,
891 },
892 .c = {
893 .dbg_name = "vcodec_p_clk",
894 .ops = &clk_ops_branch,
895 CLK_INIT(vcodec_p_clk.c),
896 },
897};
898
899static struct branch_clk vfe_p_clk = {
900 .b = {
901 .ctl_reg = AHB_EN_REG,
902 .en_mask = BIT(13),
903 .reset_reg = SW_RESET_AHB_REG,
904 .reset_mask = BIT(0),
905 .halt_reg = DBG_BUS_VEC_F_REG,
906 .halt_bit = 14,
Matt Wagantall6bc8f102012-01-20 19:20:44 -0800907 .retain_reg = AHB_EN2_REG,
908 .retain_mask = BIT(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700909 },
910 .c = {
911 .dbg_name = "vfe_p_clk",
912 .ops = &clk_ops_branch,
913 CLK_INIT(vfe_p_clk.c),
914 },
915};
916
917static struct branch_clk vpe_p_clk = {
918 .b = {
919 .ctl_reg = AHB_EN_REG,
920 .en_mask = BIT(16),
921 .reset_reg = SW_RESET_AHB_REG,
922 .reset_mask = BIT(14),
923 .halt_reg = DBG_BUS_VEC_F_REG,
924 .halt_bit = 15,
925 },
926 .c = {
927 .dbg_name = "vpe_p_clk",
928 .ops = &clk_ops_branch,
929 CLK_INIT(vpe_p_clk.c),
930 },
931};
932
933/*
934 * Peripheral Clocks
935 */
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700936#define CLK_GP(i, n, h_r, h_b) \
937 struct rcg_clk i##_clk = { \
938 .b = { \
939 .ctl_reg = GPn_NS_REG(n), \
940 .en_mask = BIT(9), \
941 .halt_reg = h_r, \
942 .halt_bit = h_b, \
943 }, \
944 .ns_reg = GPn_NS_REG(n), \
945 .md_reg = GPn_MD_REG(n), \
946 .root_en_mask = BIT(11), \
947 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -0800948 .mnd_en_mask = BIT(8), \
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700949 .set_rate = set_rate_mnd, \
950 .freq_tbl = clk_tbl_gp, \
951 .current_freq = &rcg_dummy_freq, \
952 .c = { \
953 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -0700954 .ops = &clk_ops_rcg, \
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700955 VDD_DIG_FMAX_MAP1(LOW, 27000000), \
956 CLK_INIT(i##_clk.c), \
957 }, \
958 }
959#define F_GP(f, s, d, m, n) \
960 { \
961 .freq_hz = f, \
962 .src_clk = &s##_clk.c, \
963 .md_val = MD8(16, m, 0, n), \
964 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700965 }
966static struct clk_freq_tbl clk_tbl_gp[] = {
967 F_GP( 0, gnd, 1, 0, 0),
968 F_GP( 9600000, cxo, 2, 0, 0),
969 F_GP( 13500000, pxo, 2, 0, 0),
970 F_GP( 19200000, cxo, 1, 0, 0),
971 F_GP( 27000000, pxo, 1, 0, 0),
972 F_END
973};
974
975static CLK_GP(gp0, 0, CLK_HALT_SFPB_MISC_STATE_REG, 7);
976static CLK_GP(gp1, 1, CLK_HALT_SFPB_MISC_STATE_REG, 6);
977static CLK_GP(gp2, 2, CLK_HALT_SFPB_MISC_STATE_REG, 5);
978
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700979#define CLK_GSBI_UART(i, n, h_r, h_b) \
980 struct rcg_clk i##_clk = { \
981 .b = { \
982 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
983 .en_mask = BIT(9), \
984 .reset_reg = GSBIn_RESET_REG(n), \
985 .reset_mask = BIT(0), \
986 .halt_reg = h_r, \
987 .halt_bit = h_b, \
988 }, \
989 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
990 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
991 .root_en_mask = BIT(11), \
992 .ns_mask = (BM(31, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -0800993 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700994 .set_rate = set_rate_mnd, \
995 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700996 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700997 .c = { \
998 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -0700999 .ops = &clk_ops_rcg, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001000 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001001 CLK_INIT(i##_clk.c), \
1002 }, \
1003 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001004#define F_GSBI_UART(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001005 { \
1006 .freq_hz = f, \
1007 .src_clk = &s##_clk.c, \
1008 .md_val = MD16(m, n), \
1009 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001010 }
1011static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001012 F_GSBI_UART( 0, gnd, 1, 0, 0),
1013 F_GSBI_UART( 1843200, pll8, 1, 3, 625),
1014 F_GSBI_UART( 3686400, pll8, 1, 6, 625),
1015 F_GSBI_UART( 7372800, pll8, 1, 12, 625),
1016 F_GSBI_UART(14745600, pll8, 1, 24, 625),
1017 F_GSBI_UART(16000000, pll8, 4, 1, 6),
1018 F_GSBI_UART(24000000, pll8, 4, 1, 4),
1019 F_GSBI_UART(32000000, pll8, 4, 1, 3),
1020 F_GSBI_UART(40000000, pll8, 1, 5, 48),
1021 F_GSBI_UART(46400000, pll8, 1, 29, 240),
1022 F_GSBI_UART(48000000, pll8, 4, 1, 2),
1023 F_GSBI_UART(51200000, pll8, 1, 2, 15),
1024 F_GSBI_UART(56000000, pll8, 1, 7, 48),
1025 F_GSBI_UART(58982400, pll8, 1, 96, 625),
1026 F_GSBI_UART(64000000, pll8, 2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001027 F_END
1028};
1029
1030static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1031static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1032static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1033static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1034static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1035static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1036static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1037static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1038static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1039static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1040static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1041static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1042
1043#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1044 struct rcg_clk i##_clk = { \
1045 .b = { \
1046 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1047 .en_mask = BIT(9), \
1048 .reset_reg = GSBIn_RESET_REG(n), \
1049 .reset_mask = BIT(0), \
1050 .halt_reg = h_r, \
1051 .halt_bit = h_b, \
1052 }, \
1053 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1054 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1055 .root_en_mask = BIT(11), \
1056 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001057 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001058 .set_rate = set_rate_mnd, \
1059 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001060 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001061 .c = { \
1062 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -07001063 .ops = &clk_ops_rcg, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001064 VDD_DIG_FMAX_MAP2(LOW, 24000000, NOMINAL, 52000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001065 CLK_INIT(i##_clk.c), \
1066 }, \
1067 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001068#define F_GSBI_QUP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001069 { \
1070 .freq_hz = f, \
1071 .src_clk = &s##_clk.c, \
1072 .md_val = MD8(16, m, 0, n), \
1073 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001074 }
1075static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001076 F_GSBI_QUP( 0, gnd, 1, 0, 0),
1077 F_GSBI_QUP( 1100000, pxo, 1, 2, 49),
1078 F_GSBI_QUP( 5400000, pxo, 1, 1, 5),
1079 F_GSBI_QUP(10800000, pxo, 1, 2, 5),
1080 F_GSBI_QUP(15060000, pll8, 1, 2, 51),
1081 F_GSBI_QUP(24000000, pll8, 4, 1, 4),
1082 F_GSBI_QUP(25600000, pll8, 1, 1, 15),
1083 F_GSBI_QUP(27000000, pxo, 1, 0, 0),
1084 F_GSBI_QUP(48000000, pll8, 4, 1, 2),
1085 F_GSBI_QUP(51200000, pll8, 1, 2, 15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001086 F_END
1087};
1088
1089static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1090static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1091static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1092static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1093static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1094static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1095static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1096static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1097static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1098static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1099static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1100static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1101
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001102#define F_PDM(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001103 { \
1104 .freq_hz = f, \
1105 .src_clk = &s##_clk.c, \
1106 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001107 }
1108static struct clk_freq_tbl clk_tbl_pdm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001109 F_PDM( 0, gnd, 1),
1110 F_PDM(27000000, pxo, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001111 F_END
1112};
1113
1114static struct rcg_clk pdm_clk = {
1115 .b = {
1116 .ctl_reg = PDM_CLK_NS_REG,
1117 .en_mask = BIT(9),
1118 .reset_reg = PDM_CLK_NS_REG,
1119 .reset_mask = BIT(12),
1120 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1121 .halt_bit = 3,
1122 },
1123 .ns_reg = PDM_CLK_NS_REG,
1124 .root_en_mask = BIT(11),
1125 .ns_mask = BM(1, 0),
1126 .set_rate = set_rate_nop,
1127 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001128 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001129 .c = {
1130 .dbg_name = "pdm_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001131 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001132 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001133 CLK_INIT(pdm_clk.c),
1134 },
1135};
1136
1137static struct branch_clk pmem_clk = {
1138 .b = {
1139 .ctl_reg = PMEM_ACLK_CTL_REG,
1140 .en_mask = BIT(4),
1141 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1142 .halt_bit = 20,
1143 },
1144 .c = {
1145 .dbg_name = "pmem_clk",
1146 .ops = &clk_ops_branch,
1147 CLK_INIT(pmem_clk.c),
1148 },
1149};
1150
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001151#define F_PRNG(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001152 { \
1153 .freq_hz = f, \
1154 .src_clk = &s##_clk.c, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001155 }
Stephen Boyd842a1f62012-04-26 19:07:38 -07001156static struct clk_freq_tbl clk_tbl_prng_32[] = {
1157 F_PRNG(32000000, pll8),
1158 F_END
1159};
1160
1161static struct clk_freq_tbl clk_tbl_prng_64[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001162 F_PRNG(64000000, pll8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001163 F_END
1164};
1165
1166static struct rcg_clk prng_clk = {
1167 .b = {
1168 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1169 .en_mask = BIT(10),
1170 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1171 .halt_check = HALT_VOTED,
1172 .halt_bit = 10,
1173 },
1174 .set_rate = set_rate_nop,
Stephen Boyd842a1f62012-04-26 19:07:38 -07001175 .freq_tbl = clk_tbl_prng_32,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001176 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001177 .c = {
1178 .dbg_name = "prng_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001179 .ops = &clk_ops_rcg,
Stephen Boyd842a1f62012-04-26 19:07:38 -07001180 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001181 CLK_INIT(prng_clk.c),
1182 },
1183};
1184
1185#define CLK_SDC(i, n, h_r, h_b) \
1186 struct rcg_clk i##_clk = { \
1187 .b = { \
1188 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1189 .en_mask = BIT(9), \
1190 .reset_reg = SDCn_RESET_REG(n), \
1191 .reset_mask = BIT(0), \
1192 .halt_reg = h_r, \
1193 .halt_bit = h_b, \
1194 }, \
1195 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1196 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1197 .root_en_mask = BIT(11), \
1198 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001199 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001200 .set_rate = set_rate_mnd, \
1201 .freq_tbl = clk_tbl_sdc, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001202 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001203 .c = { \
1204 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -07001205 .ops = &clk_ops_rcg, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001206 VDD_DIG_FMAX_MAP2(LOW, 25000000, NOMINAL, 50000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001207 CLK_INIT(i##_clk.c), \
1208 }, \
1209 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001210#define F_SDC(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001211 { \
1212 .freq_hz = f, \
1213 .src_clk = &s##_clk.c, \
1214 .md_val = MD8(16, m, 0, n), \
1215 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001216 }
1217static struct clk_freq_tbl clk_tbl_sdc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001218 F_SDC( 0, gnd, 1, 0, 0),
1219 F_SDC( 144000, pxo, 3, 2, 125),
1220 F_SDC( 400000, pll8, 4, 1, 240),
1221 F_SDC(16000000, pll8, 4, 1, 6),
1222 F_SDC(17070000, pll8, 1, 2, 45),
1223 F_SDC(20210000, pll8, 1, 1, 19),
1224 F_SDC(24000000, pll8, 4, 1, 4),
1225 F_SDC(48000000, pll8, 4, 1, 2),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001226 F_END
1227};
1228
1229static CLK_SDC(sdc1, 1, CLK_HALT_DFAB_STATE_REG, 6);
1230static CLK_SDC(sdc2, 2, CLK_HALT_DFAB_STATE_REG, 5);
1231static CLK_SDC(sdc3, 3, CLK_HALT_DFAB_STATE_REG, 4);
1232static CLK_SDC(sdc4, 4, CLK_HALT_DFAB_STATE_REG, 3);
1233static CLK_SDC(sdc5, 5, CLK_HALT_DFAB_STATE_REG, 2);
1234
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001235#define F_TSIF_REF(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001236 { \
1237 .freq_hz = f, \
1238 .src_clk = &s##_clk.c, \
1239 .md_val = MD16(m, n), \
1240 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001241 }
1242static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001243 F_TSIF_REF( 0, gnd, 1, 0, 0),
1244 F_TSIF_REF(105000, pxo, 1, 1, 256),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001245 F_END
1246};
1247
1248static struct rcg_clk tsif_ref_clk = {
1249 .b = {
1250 .ctl_reg = TSIF_REF_CLK_NS_REG,
1251 .en_mask = BIT(9),
1252 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1253 .halt_bit = 5,
1254 },
1255 .ns_reg = TSIF_REF_CLK_NS_REG,
1256 .md_reg = TSIF_REF_CLK_MD_REG,
1257 .root_en_mask = BIT(11),
1258 .ns_mask = (BM(31, 16) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08001259 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001260 .set_rate = set_rate_mnd,
1261 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001262 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001263 .c = {
1264 .dbg_name = "tsif_ref_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001265 .ops = &clk_ops_rcg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001266 CLK_INIT(tsif_ref_clk.c),
1267 },
1268};
1269
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001270#define F_TSSC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001271 { \
1272 .freq_hz = f, \
1273 .src_clk = &s##_clk.c, \
1274 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001275 }
1276static struct clk_freq_tbl clk_tbl_tssc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001277 F_TSSC( 0, gnd),
1278 F_TSSC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001279 F_END
1280};
1281
1282static struct rcg_clk tssc_clk = {
1283 .b = {
1284 .ctl_reg = TSSC_CLK_CTL_REG,
1285 .en_mask = BIT(4),
1286 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1287 .halt_bit = 4,
1288 },
1289 .ns_reg = TSSC_CLK_CTL_REG,
1290 .ns_mask = BM(1, 0),
1291 .set_rate = set_rate_nop,
1292 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001293 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001294 .c = {
1295 .dbg_name = "tssc_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001296 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001297 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001298 CLK_INIT(tssc_clk.c),
1299 },
1300};
1301
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001302#define F_USB(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001303 { \
1304 .freq_hz = f, \
1305 .src_clk = &s##_clk.c, \
1306 .md_val = MD8(16, m, 0, n), \
1307 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001308 }
1309static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001310 F_USB( 0, gnd, 1, 0, 0),
1311 F_USB(60000000, pll8, 1, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001312 F_END
1313};
1314
1315static struct rcg_clk usb_hs1_xcvr_clk = {
1316 .b = {
1317 .ctl_reg = USB_HS1_XCVR_FS_CLK_NS_REG,
1318 .en_mask = BIT(9),
1319 .reset_reg = USB_HS1_RESET_REG,
1320 .reset_mask = BIT(0),
1321 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1322 .halt_bit = 0,
1323 },
1324 .ns_reg = USB_HS1_XCVR_FS_CLK_NS_REG,
1325 .md_reg = USB_HS1_XCVR_FS_CLK_MD_REG,
1326 .root_en_mask = BIT(11),
1327 .ns_mask = (BM(23, 16) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08001328 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001329 .set_rate = set_rate_mnd,
1330 .freq_tbl = clk_tbl_usb,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001331 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001332 .c = {
1333 .dbg_name = "usb_hs1_xcvr_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001334 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001335 VDD_DIG_FMAX_MAP1(NOMINAL, 60000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001336 CLK_INIT(usb_hs1_xcvr_clk.c),
1337 },
1338};
1339
1340static struct branch_clk usb_phy0_clk = {
1341 .b = {
1342 .reset_reg = USB_PHY0_RESET_REG,
1343 .reset_mask = BIT(0),
1344 },
1345 .c = {
1346 .dbg_name = "usb_phy0_clk",
1347 .ops = &clk_ops_reset,
1348 CLK_INIT(usb_phy0_clk.c),
1349 },
1350};
1351
1352#define CLK_USB_FS(i, n) \
1353 struct rcg_clk i##_clk = { \
1354 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1355 .b = { \
1356 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1357 .halt_check = NOCHECK, \
1358 }, \
1359 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
1360 .root_en_mask = BIT(11), \
1361 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001362 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001363 .set_rate = set_rate_mnd, \
1364 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001365 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001366 .c = { \
1367 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -07001368 .ops = &clk_ops_rcg, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001369 VDD_DIG_FMAX_MAP1(NOMINAL, 60000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001370 CLK_INIT(i##_clk.c), \
1371 }, \
1372 }
1373
1374static CLK_USB_FS(usb_fs1_src, 1);
1375static struct branch_clk usb_fs1_xcvr_clk = {
1376 .b = {
1377 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
1378 .en_mask = BIT(9),
1379 .reset_reg = USB_FSn_RESET_REG(1),
1380 .reset_mask = BIT(1),
1381 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1382 .halt_bit = 15,
1383 },
1384 .parent = &usb_fs1_src_clk.c,
1385 .c = {
1386 .dbg_name = "usb_fs1_xcvr_clk",
1387 .ops = &clk_ops_branch,
1388 CLK_INIT(usb_fs1_xcvr_clk.c),
1389 },
1390};
1391
1392static struct branch_clk usb_fs1_sys_clk = {
1393 .b = {
1394 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
1395 .en_mask = BIT(4),
1396 .reset_reg = USB_FSn_RESET_REG(1),
1397 .reset_mask = BIT(0),
1398 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1399 .halt_bit = 16,
1400 },
1401 .parent = &usb_fs1_src_clk.c,
1402 .c = {
1403 .dbg_name = "usb_fs1_sys_clk",
1404 .ops = &clk_ops_branch,
1405 CLK_INIT(usb_fs1_sys_clk.c),
1406 },
1407};
1408
1409static CLK_USB_FS(usb_fs2_src, 2);
1410static struct branch_clk usb_fs2_xcvr_clk = {
1411 .b = {
1412 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
1413 .en_mask = BIT(9),
1414 .reset_reg = USB_FSn_RESET_REG(2),
1415 .reset_mask = BIT(1),
1416 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1417 .halt_bit = 12,
1418 },
1419 .parent = &usb_fs2_src_clk.c,
1420 .c = {
1421 .dbg_name = "usb_fs2_xcvr_clk",
1422 .ops = &clk_ops_branch,
1423 CLK_INIT(usb_fs2_xcvr_clk.c),
1424 },
1425};
1426
1427static struct branch_clk usb_fs2_sys_clk = {
1428 .b = {
1429 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
1430 .en_mask = BIT(4),
1431 .reset_reg = USB_FSn_RESET_REG(2),
1432 .reset_mask = BIT(0),
1433 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1434 .halt_bit = 13,
1435 },
1436 .parent = &usb_fs2_src_clk.c,
1437 .c = {
1438 .dbg_name = "usb_fs2_sys_clk",
1439 .ops = &clk_ops_branch,
1440 CLK_INIT(usb_fs2_sys_clk.c),
1441 },
1442};
1443
1444/* Fast Peripheral Bus Clocks */
1445static struct branch_clk ce2_p_clk = {
1446 .b = {
1447 .ctl_reg = CE2_HCLK_CTL_REG,
1448 .en_mask = BIT(4),
1449 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1450 .halt_bit = 0,
1451 },
1452 .parent = &pxo_clk.c,
1453 .c = {
1454 .dbg_name = "ce2_p_clk",
1455 .ops = &clk_ops_branch,
1456 CLK_INIT(ce2_p_clk.c),
1457 },
1458};
1459
1460static struct branch_clk gsbi1_p_clk = {
1461 .b = {
1462 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
1463 .en_mask = BIT(4),
1464 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1465 .halt_bit = 11,
1466 },
1467 .c = {
1468 .dbg_name = "gsbi1_p_clk",
1469 .ops = &clk_ops_branch,
1470 CLK_INIT(gsbi1_p_clk.c),
1471 },
1472};
1473
1474static struct branch_clk gsbi2_p_clk = {
1475 .b = {
1476 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
1477 .en_mask = BIT(4),
1478 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1479 .halt_bit = 7,
1480 },
1481 .c = {
1482 .dbg_name = "gsbi2_p_clk",
1483 .ops = &clk_ops_branch,
1484 CLK_INIT(gsbi2_p_clk.c),
1485 },
1486};
1487
1488static struct branch_clk gsbi3_p_clk = {
1489 .b = {
1490 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
1491 .en_mask = BIT(4),
1492 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1493 .halt_bit = 3,
1494 },
1495 .c = {
1496 .dbg_name = "gsbi3_p_clk",
1497 .ops = &clk_ops_branch,
1498 CLK_INIT(gsbi3_p_clk.c),
1499 },
1500};
1501
1502static struct branch_clk gsbi4_p_clk = {
1503 .b = {
1504 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
1505 .en_mask = BIT(4),
1506 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1507 .halt_bit = 27,
1508 },
1509 .c = {
1510 .dbg_name = "gsbi4_p_clk",
1511 .ops = &clk_ops_branch,
1512 CLK_INIT(gsbi4_p_clk.c),
1513 },
1514};
1515
1516static struct branch_clk gsbi5_p_clk = {
1517 .b = {
1518 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
1519 .en_mask = BIT(4),
1520 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1521 .halt_bit = 23,
1522 },
1523 .c = {
1524 .dbg_name = "gsbi5_p_clk",
1525 .ops = &clk_ops_branch,
1526 CLK_INIT(gsbi5_p_clk.c),
1527 },
1528};
1529
1530static struct branch_clk gsbi6_p_clk = {
1531 .b = {
1532 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
1533 .en_mask = BIT(4),
1534 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1535 .halt_bit = 19,
1536 },
1537 .c = {
1538 .dbg_name = "gsbi6_p_clk",
1539 .ops = &clk_ops_branch,
1540 CLK_INIT(gsbi6_p_clk.c),
1541 },
1542};
1543
1544static struct branch_clk gsbi7_p_clk = {
1545 .b = {
1546 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
1547 .en_mask = BIT(4),
1548 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1549 .halt_bit = 15,
1550 },
1551 .c = {
1552 .dbg_name = "gsbi7_p_clk",
1553 .ops = &clk_ops_branch,
1554 CLK_INIT(gsbi7_p_clk.c),
1555 },
1556};
1557
1558static struct branch_clk gsbi8_p_clk = {
1559 .b = {
1560 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
1561 .en_mask = BIT(4),
1562 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1563 .halt_bit = 11,
1564 },
1565 .c = {
1566 .dbg_name = "gsbi8_p_clk",
1567 .ops = &clk_ops_branch,
1568 CLK_INIT(gsbi8_p_clk.c),
1569 },
1570};
1571
1572static struct branch_clk gsbi9_p_clk = {
1573 .b = {
1574 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
1575 .en_mask = BIT(4),
1576 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1577 .halt_bit = 7,
1578 },
1579 .c = {
1580 .dbg_name = "gsbi9_p_clk",
1581 .ops = &clk_ops_branch,
1582 CLK_INIT(gsbi9_p_clk.c),
1583 },
1584};
1585
1586static struct branch_clk gsbi10_p_clk = {
1587 .b = {
1588 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
1589 .en_mask = BIT(4),
1590 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1591 .halt_bit = 3,
1592 },
1593 .c = {
1594 .dbg_name = "gsbi10_p_clk",
1595 .ops = &clk_ops_branch,
1596 CLK_INIT(gsbi10_p_clk.c),
1597 },
1598};
1599
1600static struct branch_clk gsbi11_p_clk = {
1601 .b = {
1602 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
1603 .en_mask = BIT(4),
1604 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1605 .halt_bit = 18,
1606 },
1607 .c = {
1608 .dbg_name = "gsbi11_p_clk",
1609 .ops = &clk_ops_branch,
1610 CLK_INIT(gsbi11_p_clk.c),
1611 },
1612};
1613
1614static struct branch_clk gsbi12_p_clk = {
1615 .b = {
1616 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
1617 .en_mask = BIT(4),
1618 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1619 .halt_bit = 14,
1620 },
1621 .c = {
1622 .dbg_name = "gsbi12_p_clk",
1623 .ops = &clk_ops_branch,
1624 CLK_INIT(gsbi12_p_clk.c),
1625 },
1626};
1627
1628static struct branch_clk ppss_p_clk = {
1629 .b = {
1630 .ctl_reg = PPSS_HCLK_CTL_REG,
1631 .en_mask = BIT(4),
1632 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1633 .halt_bit = 19,
1634 },
1635 .c = {
1636 .dbg_name = "ppss_p_clk",
1637 .ops = &clk_ops_branch,
1638 CLK_INIT(ppss_p_clk.c),
1639 },
1640};
1641
1642static struct branch_clk tsif_p_clk = {
1643 .b = {
1644 .ctl_reg = TSIF_HCLK_CTL_REG,
1645 .en_mask = BIT(4),
1646 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1647 .halt_bit = 7,
1648 },
1649 .c = {
1650 .dbg_name = "tsif_p_clk",
1651 .ops = &clk_ops_branch,
1652 CLK_INIT(tsif_p_clk.c),
1653 },
1654};
1655
1656static struct branch_clk usb_fs1_p_clk = {
1657 .b = {
1658 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
1659 .en_mask = BIT(4),
1660 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1661 .halt_bit = 17,
1662 },
1663 .c = {
1664 .dbg_name = "usb_fs1_p_clk",
1665 .ops = &clk_ops_branch,
1666 CLK_INIT(usb_fs1_p_clk.c),
1667 },
1668};
1669
1670static struct branch_clk usb_fs2_p_clk = {
1671 .b = {
1672 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
1673 .en_mask = BIT(4),
1674 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1675 .halt_bit = 14,
1676 },
1677 .c = {
1678 .dbg_name = "usb_fs2_p_clk",
1679 .ops = &clk_ops_branch,
1680 CLK_INIT(usb_fs2_p_clk.c),
1681 },
1682};
1683
1684static struct branch_clk usb_hs1_p_clk = {
1685 .b = {
1686 .ctl_reg = USB_HS1_HCLK_CTL_REG,
1687 .en_mask = BIT(4),
1688 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1689 .halt_bit = 1,
1690 },
1691 .c = {
1692 .dbg_name = "usb_hs1_p_clk",
1693 .ops = &clk_ops_branch,
1694 CLK_INIT(usb_hs1_p_clk.c),
1695 },
1696};
1697
1698static struct branch_clk sdc1_p_clk = {
1699 .b = {
1700 .ctl_reg = SDCn_HCLK_CTL_REG(1),
1701 .en_mask = BIT(4),
1702 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1703 .halt_bit = 11,
1704 },
1705 .c = {
1706 .dbg_name = "sdc1_p_clk",
1707 .ops = &clk_ops_branch,
1708 CLK_INIT(sdc1_p_clk.c),
1709 },
1710};
1711
1712static struct branch_clk sdc2_p_clk = {
1713 .b = {
1714 .ctl_reg = SDCn_HCLK_CTL_REG(2),
1715 .en_mask = BIT(4),
1716 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1717 .halt_bit = 10,
1718 },
1719 .c = {
1720 .dbg_name = "sdc2_p_clk",
1721 .ops = &clk_ops_branch,
1722 CLK_INIT(sdc2_p_clk.c),
1723 },
1724};
1725
1726static struct branch_clk sdc3_p_clk = {
1727 .b = {
1728 .ctl_reg = SDCn_HCLK_CTL_REG(3),
1729 .en_mask = BIT(4),
1730 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1731 .halt_bit = 9,
1732 },
1733 .c = {
1734 .dbg_name = "sdc3_p_clk",
1735 .ops = &clk_ops_branch,
1736 CLK_INIT(sdc3_p_clk.c),
1737 },
1738};
1739
1740static struct branch_clk sdc4_p_clk = {
1741 .b = {
1742 .ctl_reg = SDCn_HCLK_CTL_REG(4),
1743 .en_mask = BIT(4),
1744 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1745 .halt_bit = 8,
1746 },
1747 .c = {
1748 .dbg_name = "sdc4_p_clk",
1749 .ops = &clk_ops_branch,
1750 CLK_INIT(sdc4_p_clk.c),
1751 },
1752};
1753
1754static struct branch_clk sdc5_p_clk = {
1755 .b = {
1756 .ctl_reg = SDCn_HCLK_CTL_REG(5),
1757 .en_mask = BIT(4),
1758 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1759 .halt_bit = 7,
1760 },
1761 .c = {
1762 .dbg_name = "sdc5_p_clk",
1763 .ops = &clk_ops_branch,
1764 CLK_INIT(sdc5_p_clk.c),
1765 },
1766};
1767
Matt Wagantall66cd0932011-09-12 19:04:34 -07001768static struct branch_clk ebi2_2x_clk = {
1769 .b = {
1770 .ctl_reg = EBI2_2X_CLK_CTL_REG,
1771 .en_mask = BIT(4),
1772 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1773 .halt_bit = 18,
1774 },
1775 .c = {
1776 .dbg_name = "ebi2_2x_clk",
1777 .ops = &clk_ops_branch,
1778 CLK_INIT(ebi2_2x_clk.c),
1779 },
1780};
1781
1782static struct branch_clk ebi2_clk = {
1783 .b = {
1784 .ctl_reg = EBI2_CLK_CTL_REG,
1785 .en_mask = BIT(4),
1786 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1787 .halt_bit = 19,
1788 },
1789 .c = {
1790 .dbg_name = "ebi2_clk",
1791 .ops = &clk_ops_branch,
1792 CLK_INIT(ebi2_clk.c),
1793 .depends = &ebi2_2x_clk.c,
1794 },
1795};
1796
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001797/* HW-Voteable Clocks */
1798static struct branch_clk adm0_clk = {
1799 .b = {
1800 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1801 .en_mask = BIT(2),
1802 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1803 .halt_check = HALT_VOTED,
1804 .halt_bit = 14,
1805 },
1806 .parent = &pxo_clk.c,
1807 .c = {
1808 .dbg_name = "adm0_clk",
1809 .ops = &clk_ops_branch,
1810 CLK_INIT(adm0_clk.c),
1811 },
1812};
1813
1814static struct branch_clk adm0_p_clk = {
1815 .b = {
1816 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1817 .en_mask = BIT(3),
1818 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1819 .halt_check = HALT_VOTED,
1820 .halt_bit = 13,
1821 },
1822 .c = {
1823 .dbg_name = "adm0_p_clk",
1824 .ops = &clk_ops_branch,
1825 CLK_INIT(adm0_p_clk.c),
1826 },
1827};
1828
1829static struct branch_clk adm1_clk = {
1830 .b = {
1831 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1832 .en_mask = BIT(4),
1833 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1834 .halt_check = HALT_VOTED,
1835 .halt_bit = 12,
1836 },
1837 .parent = &pxo_clk.c,
1838 .c = {
1839 .dbg_name = "adm1_clk",
1840 .ops = &clk_ops_branch,
1841 CLK_INIT(adm1_clk.c),
1842 },
1843};
1844
1845static struct branch_clk adm1_p_clk = {
1846 .b = {
1847 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1848 .en_mask = BIT(5),
1849 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1850 .halt_check = HALT_VOTED,
1851 .halt_bit = 11,
1852 },
1853 .c = {
1854 .dbg_name = "adm1_p_clk",
1855 .ops = &clk_ops_branch,
1856 CLK_INIT(adm1_p_clk.c),
1857 },
1858};
1859
1860static struct branch_clk modem_ahb1_p_clk = {
1861 .b = {
1862 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1863 .en_mask = BIT(0),
1864 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1865 .halt_check = HALT_VOTED,
1866 .halt_bit = 8,
1867 },
1868 .c = {
1869 .dbg_name = "modem_ahb1_p_clk",
1870 .ops = &clk_ops_branch,
1871 CLK_INIT(modem_ahb1_p_clk.c),
1872 },
1873};
1874
1875static struct branch_clk modem_ahb2_p_clk = {
1876 .b = {
1877 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1878 .en_mask = BIT(1),
1879 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1880 .halt_check = HALT_VOTED,
1881 .halt_bit = 7,
1882 },
1883 .c = {
1884 .dbg_name = "modem_ahb2_p_clk",
1885 .ops = &clk_ops_branch,
1886 CLK_INIT(modem_ahb2_p_clk.c),
1887 },
1888};
1889
1890static struct branch_clk pmic_arb0_p_clk = {
1891 .b = {
1892 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1893 .en_mask = BIT(8),
1894 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1895 .halt_check = HALT_VOTED,
1896 .halt_bit = 22,
1897 },
1898 .c = {
1899 .dbg_name = "pmic_arb0_p_clk",
1900 .ops = &clk_ops_branch,
1901 CLK_INIT(pmic_arb0_p_clk.c),
1902 },
1903};
1904
1905static struct branch_clk pmic_arb1_p_clk = {
1906 .b = {
1907 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1908 .en_mask = BIT(9),
1909 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1910 .halt_check = HALT_VOTED,
1911 .halt_bit = 21,
1912 },
1913 .c = {
1914 .dbg_name = "pmic_arb1_p_clk",
1915 .ops = &clk_ops_branch,
1916 CLK_INIT(pmic_arb1_p_clk.c),
1917 },
1918};
1919
1920static struct branch_clk pmic_ssbi2_clk = {
1921 .b = {
1922 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1923 .en_mask = BIT(7),
1924 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1925 .halt_check = HALT_VOTED,
1926 .halt_bit = 23,
1927 },
1928 .c = {
1929 .dbg_name = "pmic_ssbi2_clk",
1930 .ops = &clk_ops_branch,
1931 CLK_INIT(pmic_ssbi2_clk.c),
1932 },
1933};
1934
1935static struct branch_clk rpm_msg_ram_p_clk = {
1936 .b = {
1937 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1938 .en_mask = BIT(6),
1939 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1940 .halt_check = HALT_VOTED,
1941 .halt_bit = 12,
1942 },
1943 .c = {
1944 .dbg_name = "rpm_msg_ram_p_clk",
1945 .ops = &clk_ops_branch,
1946 CLK_INIT(rpm_msg_ram_p_clk.c),
1947 },
1948};
1949
1950/*
1951 * Multimedia Clocks
1952 */
1953
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001954#define F_CAM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001955 { \
1956 .freq_hz = f, \
1957 .src_clk = &s##_clk.c, \
1958 .md_val = MD8(8, m, 0, n), \
1959 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
1960 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001961 }
1962static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001963 F_CAM( 0, gnd, 1, 0, 0),
1964 F_CAM( 6000000, pll8, 4, 1, 16),
1965 F_CAM( 8000000, pll8, 4, 1, 12),
1966 F_CAM( 12000000, pll8, 4, 1, 8),
1967 F_CAM( 16000000, pll8, 4, 1, 6),
1968 F_CAM( 19200000, pll8, 4, 1, 5),
1969 F_CAM( 24000000, pll8, 4, 1, 4),
1970 F_CAM( 32000000, pll8, 4, 1, 3),
1971 F_CAM( 48000000, pll8, 4, 1, 2),
1972 F_CAM( 64000000, pll8, 3, 1, 2),
1973 F_CAM( 96000000, pll8, 4, 0, 0),
1974 F_CAM(128000000, pll8, 3, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001975 F_END
1976};
1977
1978static struct rcg_clk cam_clk = {
1979 .b = {
1980 .ctl_reg = CAMCLK_CC_REG,
1981 .en_mask = BIT(0),
1982 .halt_check = DELAY,
1983 },
1984 .ns_reg = CAMCLK_NS_REG,
1985 .md_reg = CAMCLK_MD_REG,
1986 .root_en_mask = BIT(2),
1987 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08001988 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001989 .ctl_mask = BM(7, 6),
1990 .set_rate = set_rate_mnd_8,
1991 .freq_tbl = clk_tbl_cam,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001992 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001993 .c = {
1994 .dbg_name = "cam_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07001995 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001996 VDD_DIG_FMAX_MAP2(LOW, 64000000, NOMINAL, 128000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001997 CLK_INIT(cam_clk.c),
1998 },
1999};
2000
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002001#define F_CSI(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002002 { \
2003 .freq_hz = f, \
2004 .src_clk = &s##_clk.c, \
2005 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002006 }
2007static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002008 F_CSI( 0, gnd, 1),
2009 F_CSI(192000000, pll8, 2),
2010 F_CSI(384000000, pll8, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002011 F_END
2012};
2013
2014static struct rcg_clk csi_src_clk = {
2015 .ns_reg = CSI_NS_REG,
2016 .b = {
2017 .ctl_reg = CSI_CC_REG,
2018 .halt_check = NOCHECK,
2019 },
2020 .root_en_mask = BIT(2),
2021 .ns_mask = (BM(15, 12) | BM(2, 0)),
2022 .set_rate = set_rate_nop,
2023 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002024 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002025 .c = {
2026 .dbg_name = "csi_src_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002027 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002028 VDD_DIG_FMAX_MAP2(LOW, 192000000, NOMINAL, 384000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002029 CLK_INIT(csi_src_clk.c),
2030 },
2031};
2032
2033static struct branch_clk csi0_clk = {
2034 .b = {
2035 .ctl_reg = CSI_CC_REG,
2036 .en_mask = BIT(0),
2037 .reset_reg = SW_RESET_CORE_REG,
2038 .reset_mask = BIT(8),
2039 .halt_reg = DBG_BUS_VEC_B_REG,
2040 .halt_bit = 13,
2041 },
2042 .parent = &csi_src_clk.c,
2043 .c = {
2044 .dbg_name = "csi0_clk",
2045 .ops = &clk_ops_branch,
2046 CLK_INIT(csi0_clk.c),
2047 },
2048};
2049
2050static struct branch_clk csi1_clk = {
2051 .b = {
2052 .ctl_reg = CSI_CC_REG,
2053 .en_mask = BIT(7),
2054 .reset_reg = SW_RESET_CORE_REG,
2055 .reset_mask = BIT(18),
2056 .halt_reg = DBG_BUS_VEC_B_REG,
2057 .halt_bit = 14,
2058 },
2059 .parent = &csi_src_clk.c,
2060 .c = {
2061 .dbg_name = "csi1_clk",
2062 .ops = &clk_ops_branch,
2063 CLK_INIT(csi1_clk.c),
2064 },
2065};
2066
2067#define F_DSI(d) \
2068 { \
2069 .freq_hz = d, \
2070 .ns_val = BVAL(27, 24, (d-1)), \
2071 }
2072/* The DSI_BYTE clock is sourced from the DSI PHY PLL, which may change rate
2073 * without this clock driver knowing. So, overload the clk_set_rate() to set
2074 * the divider (1 to 16) of the clock with respect to the PLL rate. */
2075static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
2076 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
2077 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
2078 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
2079 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
2080 F_END
2081};
2082
2083
2084static struct rcg_clk dsi_byte_clk = {
2085 .b = {
2086 .ctl_reg = MISC_CC_REG,
2087 .halt_check = DELAY,
2088 .reset_reg = SW_RESET_CORE_REG,
2089 .reset_mask = BIT(7),
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002090 .retain_reg = MISC_CC2_REG,
2091 .retain_mask = BIT(10),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002092 },
2093 .ns_reg = MISC_CC2_REG,
2094 .root_en_mask = BIT(2),
2095 .ns_mask = BM(27, 24),
2096 .set_rate = set_rate_nop,
2097 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002098 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002099 .c = {
2100 .dbg_name = "dsi_byte_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002101 .ops = &clk_ops_rcg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002102 CLK_INIT(dsi_byte_clk.c),
2103 },
2104};
2105
2106static struct branch_clk dsi_esc_clk = {
2107 .b = {
2108 .ctl_reg = MISC_CC_REG,
2109 .en_mask = BIT(0),
2110 .halt_reg = DBG_BUS_VEC_B_REG,
2111 .halt_bit = 24,
2112 },
2113 .c = {
2114 .dbg_name = "dsi_esc_clk",
2115 .ops = &clk_ops_branch,
2116 CLK_INIT(dsi_esc_clk.c),
2117 },
2118};
2119
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002120#define F_GFX2D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002121 { \
2122 .freq_hz = f, \
2123 .src_clk = &s##_clk.c, \
2124 .md_val = MD4(4, m, 0, n), \
2125 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
2126 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002127 }
2128static struct clk_freq_tbl clk_tbl_gfx2d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002129 F_GFX2D( 0, gnd, 0, 0),
2130 F_GFX2D( 27000000, pxo, 0, 0),
2131 F_GFX2D( 48000000, pll8, 1, 8),
2132 F_GFX2D( 54857000, pll8, 1, 7),
2133 F_GFX2D( 64000000, pll8, 1, 6),
2134 F_GFX2D( 76800000, pll8, 1, 5),
2135 F_GFX2D( 96000000, pll8, 1, 4),
2136 F_GFX2D(128000000, pll8, 1, 3),
2137 F_GFX2D(145455000, pll2, 2, 11),
2138 F_GFX2D(160000000, pll2, 1, 5),
2139 F_GFX2D(177778000, pll2, 2, 9),
2140 F_GFX2D(200000000, pll2, 1, 4),
2141 F_GFX2D(228571000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002142 F_END
2143};
2144
2145static struct bank_masks bmnd_info_gfx2d0 = {
2146 .bank_sel_mask = BIT(11),
2147 .bank0_mask = {
2148 .md_reg = GFX2D0_MD0_REG,
2149 .ns_mask = BM(23, 20) | BM(5, 3),
2150 .rst_mask = BIT(25),
2151 .mnd_en_mask = BIT(8),
2152 .mode_mask = BM(10, 9),
2153 },
2154 .bank1_mask = {
2155 .md_reg = GFX2D0_MD1_REG,
2156 .ns_mask = BM(19, 16) | BM(2, 0),
2157 .rst_mask = BIT(24),
2158 .mnd_en_mask = BIT(5),
2159 .mode_mask = BM(7, 6),
2160 },
2161};
2162
2163static struct rcg_clk gfx2d0_clk = {
2164 .b = {
2165 .ctl_reg = GFX2D0_CC_REG,
2166 .en_mask = BIT(0),
2167 .reset_reg = SW_RESET_CORE_REG,
2168 .reset_mask = BIT(14),
2169 .halt_reg = DBG_BUS_VEC_A_REG,
2170 .halt_bit = 9,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002171 .retain_reg = GFX2D0_CC_REG,
2172 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002173 },
2174 .ns_reg = GFX2D0_NS_REG,
2175 .root_en_mask = BIT(2),
2176 .set_rate = set_rate_mnd_banked,
2177 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07002178 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002179 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002180 .c = {
2181 .dbg_name = "gfx2d0_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002182 .ops = &clk_ops_rcg,
Matt Wagantall158f73b2012-05-16 11:29:35 -07002183 .flags = CLKFLAG_SKIP_HANDOFF,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002184 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
2185 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002186 CLK_INIT(gfx2d0_clk.c),
2187 },
2188};
2189
2190static struct bank_masks bmnd_info_gfx2d1 = {
2191 .bank_sel_mask = BIT(11),
2192 .bank0_mask = {
2193 .md_reg = GFX2D1_MD0_REG,
2194 .ns_mask = BM(23, 20) | BM(5, 3),
2195 .rst_mask = BIT(25),
2196 .mnd_en_mask = BIT(8),
2197 .mode_mask = BM(10, 9),
2198 },
2199 .bank1_mask = {
2200 .md_reg = GFX2D1_MD1_REG,
2201 .ns_mask = BM(19, 16) | BM(2, 0),
2202 .rst_mask = BIT(24),
2203 .mnd_en_mask = BIT(5),
2204 .mode_mask = BM(7, 6),
2205 },
2206};
2207
2208static struct rcg_clk gfx2d1_clk = {
2209 .b = {
2210 .ctl_reg = GFX2D1_CC_REG,
2211 .en_mask = BIT(0),
2212 .reset_reg = SW_RESET_CORE_REG,
2213 .reset_mask = BIT(13),
2214 .halt_reg = DBG_BUS_VEC_A_REG,
2215 .halt_bit = 14,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002216 .retain_reg = GFX2D1_CC_REG,
2217 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002218 },
2219 .ns_reg = GFX2D1_NS_REG,
2220 .root_en_mask = BIT(2),
2221 .set_rate = set_rate_mnd_banked,
2222 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07002223 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002224 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002225 .c = {
2226 .dbg_name = "gfx2d1_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002227 .ops = &clk_ops_rcg,
Matt Wagantall158f73b2012-05-16 11:29:35 -07002228 .flags = CLKFLAG_SKIP_HANDOFF,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002229 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
2230 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002231 CLK_INIT(gfx2d1_clk.c),
2232 },
2233};
2234
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002235#define F_GFX3D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002236 { \
2237 .freq_hz = f, \
2238 .src_clk = &s##_clk.c, \
2239 .md_val = MD4(4, m, 0, n), \
2240 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
2241 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002242 }
2243static struct clk_freq_tbl clk_tbl_gfx3d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002244 F_GFX3D( 0, gnd, 0, 0),
2245 F_GFX3D( 27000000, pxo, 0, 0),
2246 F_GFX3D( 48000000, pll8, 1, 8),
2247 F_GFX3D( 54857000, pll8, 1, 7),
2248 F_GFX3D( 64000000, pll8, 1, 6),
2249 F_GFX3D( 76800000, pll8, 1, 5),
2250 F_GFX3D( 96000000, pll8, 1, 4),
2251 F_GFX3D(128000000, pll8, 1, 3),
2252 F_GFX3D(145455000, pll2, 2, 11),
2253 F_GFX3D(160000000, pll2, 1, 5),
2254 F_GFX3D(177778000, pll2, 2, 9),
2255 F_GFX3D(200000000, pll2, 1, 4),
2256 F_GFX3D(228571000, pll2, 2, 7),
2257 F_GFX3D(266667000, pll2, 1, 3),
2258 F_GFX3D(320000000, pll2, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002259 F_END
2260};
2261
2262static struct bank_masks bmnd_info_gfx3d = {
2263 .bank_sel_mask = BIT(11),
2264 .bank0_mask = {
2265 .md_reg = GFX3D_MD0_REG,
2266 .ns_mask = BM(21, 18) | BM(5, 3),
2267 .rst_mask = BIT(23),
2268 .mnd_en_mask = BIT(8),
2269 .mode_mask = BM(10, 9),
2270 },
2271 .bank1_mask = {
2272 .md_reg = GFX3D_MD1_REG,
2273 .ns_mask = BM(17, 14) | BM(2, 0),
2274 .rst_mask = BIT(22),
2275 .mnd_en_mask = BIT(5),
2276 .mode_mask = BM(7, 6),
2277 },
2278};
2279
2280static struct rcg_clk gfx3d_clk = {
2281 .b = {
2282 .ctl_reg = GFX3D_CC_REG,
2283 .en_mask = BIT(0),
2284 .reset_reg = SW_RESET_CORE_REG,
2285 .reset_mask = BIT(12),
2286 .halt_reg = DBG_BUS_VEC_A_REG,
2287 .halt_bit = 4,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002288 .retain_reg = GFX3D_CC_REG,
2289 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002290 },
2291 .ns_reg = GFX3D_NS_REG,
2292 .root_en_mask = BIT(2),
2293 .set_rate = set_rate_mnd_banked,
2294 .freq_tbl = clk_tbl_gfx3d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07002295 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002296 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002297 .c = {
2298 .dbg_name = "gfx3d_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002299 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002300 VDD_DIG_FMAX_MAP3(LOW, 96000000, NOMINAL, 200000000,
2301 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002302 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002303 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002304 },
2305};
2306
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002307#define F_IJPEG(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002308 { \
2309 .freq_hz = f, \
2310 .src_clk = &s##_clk.c, \
2311 .md_val = MD8(8, m, 0, n), \
2312 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
2313 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002314 }
2315static struct clk_freq_tbl clk_tbl_ijpeg[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002316 F_IJPEG( 0, gnd, 1, 0, 0),
2317 F_IJPEG( 27000000, pxo, 1, 0, 0),
2318 F_IJPEG( 36570000, pll8, 1, 2, 21),
2319 F_IJPEG( 54860000, pll8, 7, 0, 0),
2320 F_IJPEG( 96000000, pll8, 4, 0, 0),
2321 F_IJPEG(109710000, pll8, 1, 2, 7),
2322 F_IJPEG(128000000, pll8, 3, 0, 0),
2323 F_IJPEG(153600000, pll8, 1, 2, 5),
2324 F_IJPEG(200000000, pll2, 4, 0, 0),
2325 F_IJPEG(228571000, pll2, 1, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002326 F_END
2327};
2328
2329static struct rcg_clk ijpeg_clk = {
2330 .b = {
2331 .ctl_reg = IJPEG_CC_REG,
2332 .en_mask = BIT(0),
2333 .reset_reg = SW_RESET_CORE_REG,
2334 .reset_mask = BIT(9),
2335 .halt_reg = DBG_BUS_VEC_A_REG,
2336 .halt_bit = 24,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002337 .retain_reg = IJPEG_CC_REG,
2338 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002339 },
2340 .ns_reg = IJPEG_NS_REG,
2341 .md_reg = IJPEG_MD_REG,
2342 .root_en_mask = BIT(2),
2343 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08002344 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002345 .ctl_mask = BM(7, 6),
2346 .set_rate = set_rate_mnd,
2347 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002348 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002349 .c = {
2350 .dbg_name = "ijpeg_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002351 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002352 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002353 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002354 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002355 },
2356};
2357
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002358#define F_JPEGD(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002359 { \
2360 .freq_hz = f, \
2361 .src_clk = &s##_clk.c, \
2362 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002363 }
2364static struct clk_freq_tbl clk_tbl_jpegd[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002365 F_JPEGD( 0, gnd, 1),
2366 F_JPEGD( 64000000, pll8, 6),
2367 F_JPEGD( 76800000, pll8, 5),
2368 F_JPEGD( 96000000, pll8, 4),
2369 F_JPEGD(160000000, pll2, 5),
2370 F_JPEGD(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002371 F_END
2372};
2373
2374static struct rcg_clk jpegd_clk = {
2375 .b = {
2376 .ctl_reg = JPEGD_CC_REG,
2377 .en_mask = BIT(0),
2378 .reset_reg = SW_RESET_CORE_REG,
2379 .reset_mask = BIT(19),
2380 .halt_reg = DBG_BUS_VEC_A_REG,
2381 .halt_bit = 19,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002382 .retain_reg = JPEGD_CC_REG,
2383 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002384 },
2385 .ns_reg = JPEGD_NS_REG,
2386 .root_en_mask = BIT(2),
2387 .ns_mask = (BM(15, 12) | BM(2, 0)),
2388 .set_rate = set_rate_nop,
2389 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002390 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002391 .c = {
2392 .dbg_name = "jpegd_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002393 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002394 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002395 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002396 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002397 },
2398};
2399
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002400#define F_MDP(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002401 { \
2402 .freq_hz = f, \
2403 .src_clk = &s##_clk.c, \
2404 .md_val = MD8(8, m, 0, n), \
2405 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
2406 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002407 }
2408static struct clk_freq_tbl clk_tbl_mdp[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002409 F_MDP( 0, gnd, 0, 0),
2410 F_MDP( 9600000, pll8, 1, 40),
2411 F_MDP( 13710000, pll8, 1, 28),
2412 F_MDP( 27000000, pxo, 0, 0),
2413 F_MDP( 29540000, pll8, 1, 13),
2414 F_MDP( 34910000, pll8, 1, 11),
2415 F_MDP( 38400000, pll8, 1, 10),
2416 F_MDP( 59080000, pll8, 2, 13),
2417 F_MDP( 76800000, pll8, 1, 5),
2418 F_MDP( 85330000, pll8, 2, 9),
2419 F_MDP( 96000000, pll8, 1, 4),
2420 F_MDP(128000000, pll8, 1, 3),
2421 F_MDP(160000000, pll2, 1, 5),
2422 F_MDP(177780000, pll2, 2, 9),
2423 F_MDP(200000000, pll2, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002424 F_END
2425};
2426
2427static struct bank_masks bmnd_info_mdp = {
2428 .bank_sel_mask = BIT(11),
2429 .bank0_mask = {
2430 .md_reg = MDP_MD0_REG,
2431 .ns_mask = BM(29, 22) | BM(5, 3),
2432 .rst_mask = BIT(31),
2433 .mnd_en_mask = BIT(8),
2434 .mode_mask = BM(10, 9),
2435 },
2436 .bank1_mask = {
2437 .md_reg = MDP_MD1_REG,
2438 .ns_mask = BM(21, 14) | BM(2, 0),
2439 .rst_mask = BIT(30),
2440 .mnd_en_mask = BIT(5),
2441 .mode_mask = BM(7, 6),
2442 },
2443};
2444
2445static struct rcg_clk mdp_clk = {
2446 .b = {
2447 .ctl_reg = MDP_CC_REG,
2448 .en_mask = BIT(0),
2449 .reset_reg = SW_RESET_CORE_REG,
2450 .reset_mask = BIT(21),
2451 .halt_reg = DBG_BUS_VEC_C_REG,
2452 .halt_bit = 10,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002453 .retain_reg = MDP_CC_REG,
2454 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002455 },
2456 .ns_reg = MDP_NS_REG,
2457 .root_en_mask = BIT(2),
2458 .set_rate = set_rate_mnd_banked,
2459 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07002460 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002461 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002462 .c = {
2463 .dbg_name = "mdp_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002464 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002465 VDD_DIG_FMAX_MAP3(LOW, 85330000, NOMINAL, 200000000,
2466 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002467 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002468 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002469 },
2470};
2471
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002472#define F_MDP_VSYNC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002473 { \
2474 .freq_hz = f, \
2475 .src_clk = &s##_clk.c, \
2476 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002477 }
2478static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002479 F_MDP_VSYNC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002480 F_END
2481};
2482
2483static struct rcg_clk mdp_vsync_clk = {
2484 .b = {
2485 .ctl_reg = MISC_CC_REG,
2486 .en_mask = BIT(6),
2487 .reset_reg = SW_RESET_CORE_REG,
2488 .reset_mask = BIT(3),
2489 .halt_reg = DBG_BUS_VEC_B_REG,
2490 .halt_bit = 22,
2491 },
2492 .ns_reg = MISC_CC2_REG,
2493 .ns_mask = BIT(13),
2494 .set_rate = set_rate_nop,
2495 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002496 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002497 .c = {
2498 .dbg_name = "mdp_vsync_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002499 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002500 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002501 CLK_INIT(mdp_vsync_clk.c),
2502 },
2503};
2504
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002505#define F_PIXEL_MDP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002506 { \
2507 .freq_hz = f, \
2508 .src_clk = &s##_clk.c, \
2509 .md_val = MD16(m, n), \
2510 .ns_val = NS_MM(31, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2511 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002512 }
2513static struct clk_freq_tbl clk_tbl_pixel_mdp[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002514 F_PIXEL_MDP( 0, gnd, 1, 0, 0),
2515 F_PIXEL_MDP( 25600000, pll8, 3, 1, 5),
2516 F_PIXEL_MDP( 42667000, pll8, 1, 1, 9),
2517 F_PIXEL_MDP( 43192000, pll8, 1, 64, 569),
2518 F_PIXEL_MDP( 48000000, pll8, 4, 1, 2),
2519 F_PIXEL_MDP( 53990000, pll8, 2, 169, 601),
2520 F_PIXEL_MDP( 64000000, pll8, 2, 1, 3),
2521 F_PIXEL_MDP( 69300000, pll8, 1, 231, 1280),
2522 F_PIXEL_MDP( 76800000, pll8, 1, 1, 5),
2523 F_PIXEL_MDP( 85333000, pll8, 1, 2, 9),
2524 F_PIXEL_MDP(106500000, pll8, 1, 71, 256),
2525 F_PIXEL_MDP(109714000, pll8, 1, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002526 F_END
2527};
2528
2529static struct rcg_clk pixel_mdp_clk = {
2530 .ns_reg = PIXEL_NS_REG,
2531 .md_reg = PIXEL_MD_REG,
2532 .b = {
2533 .ctl_reg = PIXEL_CC_REG,
2534 .en_mask = BIT(0),
2535 .reset_reg = SW_RESET_CORE_REG,
2536 .reset_mask = BIT(5),
2537 .halt_reg = DBG_BUS_VEC_C_REG,
2538 .halt_bit = 23,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002539 .retain_reg = PIXEL_CC_REG,
2540 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002541 },
2542 .root_en_mask = BIT(2),
2543 .ns_mask = (BM(31, 16) | BM(15, 14) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08002544 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002545 .ctl_mask = BM(7, 6),
2546 .set_rate = set_rate_mnd,
2547 .freq_tbl = clk_tbl_pixel_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002548 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002549 .c = {
2550 .dbg_name = "pixel_mdp_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002551 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002552 VDD_DIG_FMAX_MAP2(LOW, 85333000, NOMINAL, 170000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002553 CLK_INIT(pixel_mdp_clk.c),
2554 },
2555};
2556
2557static struct branch_clk pixel_lcdc_clk = {
2558 .b = {
2559 .ctl_reg = PIXEL_CC_REG,
2560 .en_mask = BIT(8),
2561 .halt_reg = DBG_BUS_VEC_C_REG,
2562 .halt_bit = 21,
2563 },
2564 .parent = &pixel_mdp_clk.c,
2565 .c = {
2566 .dbg_name = "pixel_lcdc_clk",
2567 .ops = &clk_ops_branch,
2568 CLK_INIT(pixel_lcdc_clk.c),
2569 },
2570};
2571
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002572#define F_ROT(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002573 { \
2574 .freq_hz = f, \
2575 .src_clk = &s##_clk.c, \
2576 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
2577 21, 19, 18, 16, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002578 }
2579static struct clk_freq_tbl clk_tbl_rot[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002580 F_ROT( 0, gnd, 1),
2581 F_ROT( 27000000, pxo, 1),
2582 F_ROT( 29540000, pll8, 13),
2583 F_ROT( 32000000, pll8, 12),
2584 F_ROT( 38400000, pll8, 10),
2585 F_ROT( 48000000, pll8, 8),
2586 F_ROT( 54860000, pll8, 7),
2587 F_ROT( 64000000, pll8, 6),
2588 F_ROT( 76800000, pll8, 5),
2589 F_ROT( 96000000, pll8, 4),
2590 F_ROT(100000000, pll2, 8),
2591 F_ROT(114290000, pll2, 7),
2592 F_ROT(133330000, pll2, 6),
2593 F_ROT(160000000, pll2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002594 F_END
2595};
2596
2597static struct bank_masks bdiv_info_rot = {
2598 .bank_sel_mask = BIT(30),
2599 .bank0_mask = {
2600 .ns_mask = BM(25, 22) | BM(18, 16),
2601 },
2602 .bank1_mask = {
2603 .ns_mask = BM(29, 26) | BM(21, 19),
2604 },
2605};
2606
2607static struct rcg_clk rot_clk = {
2608 .b = {
2609 .ctl_reg = ROT_CC_REG,
2610 .en_mask = BIT(0),
2611 .reset_reg = SW_RESET_CORE_REG,
2612 .reset_mask = BIT(2),
2613 .halt_reg = DBG_BUS_VEC_C_REG,
2614 .halt_bit = 15,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002615 .retain_reg = ROT_CC_REG,
2616 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002617 },
2618 .ns_reg = ROT_NS_REG,
2619 .root_en_mask = BIT(2),
2620 .set_rate = set_rate_div_banked,
2621 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07002622 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002623 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002624 .c = {
2625 .dbg_name = "rot_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002626 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002627 VDD_DIG_FMAX_MAP2(LOW, 80000000, NOMINAL, 160000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002628 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002629 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002630 },
2631};
2632
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002633#define F_TV(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002634 { \
2635 .freq_hz = f, \
2636 .src_clk = &s##_clk.c, \
2637 .md_val = MD8(8, m, 0, n), \
2638 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2639 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002640 .extra_freq_data = p_r, \
2641 }
2642/* Switching TV freqs requires PLL reconfiguration. */
2643static struct pll_rate mm_pll2_rate[] = {
2644 [0] = PLL_RATE( 7, 6301, 13500, 0, 4, 0x4248B), /* 50400500 Hz */
2645 [1] = PLL_RATE( 8, 0, 0, 0, 4, 0x4248B), /* 54000000 Hz */
2646 [2] = PLL_RATE(16, 2, 125, 0, 4, 0x5248F), /* 108108000 Hz */
2647 [3] = PLL_RATE(22, 0, 0, 2, 4, 0x6248B), /* 148500000 Hz */
2648 [4] = PLL_RATE(44, 0, 0, 2, 4, 0x6248F), /* 297000000 Hz */
2649};
2650static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002651 F_TV( 0, gnd, &mm_pll2_rate[0], 1, 0, 0),
2652 F_TV( 25200000, pll3, &mm_pll2_rate[0], 2, 0, 0),
2653 F_TV( 27000000, pll3, &mm_pll2_rate[1], 2, 0, 0),
2654 F_TV( 27030000, pll3, &mm_pll2_rate[2], 4, 0, 0),
2655 F_TV( 74250000, pll3, &mm_pll2_rate[3], 2, 0, 0),
2656 F_TV(148500000, pll3, &mm_pll2_rate[4], 2, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002657 F_END
2658};
2659
2660static struct rcg_clk tv_src_clk = {
2661 .ns_reg = TV_NS_REG,
2662 .b = {
2663 .ctl_reg = TV_CC_REG,
2664 .halt_check = NOCHECK,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002665 .retain_reg = TV_CC_REG,
2666 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002667 },
2668 .md_reg = TV_MD_REG,
2669 .root_en_mask = BIT(2),
2670 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08002671 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002672 .ctl_mask = BM(7, 6),
2673 .set_rate = set_rate_tv,
2674 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002675 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002676 .c = {
2677 .dbg_name = "tv_src_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002678 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002679 VDD_DIG_FMAX_MAP2(LOW, 27030000, NOMINAL, 149000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002680 CLK_INIT(tv_src_clk.c),
2681 },
2682};
2683
2684static struct branch_clk tv_enc_clk = {
2685 .b = {
2686 .ctl_reg = TV_CC_REG,
2687 .en_mask = BIT(8),
2688 .reset_reg = SW_RESET_CORE_REG,
2689 .reset_mask = BIT(0),
2690 .halt_reg = DBG_BUS_VEC_D_REG,
2691 .halt_bit = 8,
2692 },
2693 .parent = &tv_src_clk.c,
2694 .c = {
2695 .dbg_name = "tv_enc_clk",
2696 .ops = &clk_ops_branch,
2697 CLK_INIT(tv_enc_clk.c),
2698 },
2699};
2700
2701static struct branch_clk tv_dac_clk = {
2702 .b = {
2703 .ctl_reg = TV_CC_REG,
2704 .en_mask = BIT(10),
2705 .halt_reg = DBG_BUS_VEC_D_REG,
2706 .halt_bit = 9,
2707 },
2708 .parent = &tv_src_clk.c,
2709 .c = {
2710 .dbg_name = "tv_dac_clk",
2711 .ops = &clk_ops_branch,
2712 CLK_INIT(tv_dac_clk.c),
2713 },
2714};
2715
2716static struct branch_clk mdp_tv_clk = {
2717 .b = {
2718 .ctl_reg = TV_CC_REG,
2719 .en_mask = BIT(0),
2720 .reset_reg = SW_RESET_CORE_REG,
2721 .reset_mask = BIT(4),
2722 .halt_reg = DBG_BUS_VEC_D_REG,
2723 .halt_bit = 11,
2724 },
2725 .parent = &tv_src_clk.c,
2726 .c = {
2727 .dbg_name = "mdp_tv_clk",
2728 .ops = &clk_ops_branch,
2729 CLK_INIT(mdp_tv_clk.c),
2730 },
2731};
2732
2733static struct branch_clk hdmi_tv_clk = {
2734 .b = {
2735 .ctl_reg = TV_CC_REG,
2736 .en_mask = BIT(12),
2737 .reset_reg = SW_RESET_CORE_REG,
2738 .reset_mask = BIT(1),
2739 .halt_reg = DBG_BUS_VEC_D_REG,
2740 .halt_bit = 10,
2741 },
2742 .parent = &tv_src_clk.c,
2743 .c = {
2744 .dbg_name = "hdmi_tv_clk",
2745 .ops = &clk_ops_branch,
2746 CLK_INIT(hdmi_tv_clk.c),
2747 },
2748};
2749
2750static struct branch_clk hdmi_app_clk = {
2751 .b = {
2752 .ctl_reg = MISC_CC2_REG,
2753 .en_mask = BIT(11),
2754 .reset_reg = SW_RESET_CORE_REG,
2755 .reset_mask = BIT(11),
2756 .halt_reg = DBG_BUS_VEC_B_REG,
2757 .halt_bit = 25,
2758 },
2759 .c = {
2760 .dbg_name = "hdmi_app_clk",
2761 .ops = &clk_ops_branch,
2762 CLK_INIT(hdmi_app_clk.c),
2763 },
2764};
2765
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002766#define F_VCODEC(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002767 { \
2768 .freq_hz = f, \
2769 .src_clk = &s##_clk.c, \
2770 .md_val = MD8(8, m, 0, n), \
2771 .ns_val = NS_MM(18, 11, n, m, 0, 0, 1, 2, 0, s##_to_mm_mux), \
2772 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002773 }
2774static struct clk_freq_tbl clk_tbl_vcodec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002775 F_VCODEC( 0, gnd, 0, 0),
2776 F_VCODEC( 27000000, pxo, 0, 0),
2777 F_VCODEC( 32000000, pll8, 1, 12),
2778 F_VCODEC( 48000000, pll8, 1, 8),
2779 F_VCODEC( 54860000, pll8, 1, 7),
2780 F_VCODEC( 96000000, pll8, 1, 4),
2781 F_VCODEC(133330000, pll2, 1, 6),
2782 F_VCODEC(200000000, pll2, 1, 4),
2783 F_VCODEC(228570000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002784 F_END
2785};
2786
2787static struct rcg_clk vcodec_clk = {
2788 .b = {
2789 .ctl_reg = VCODEC_CC_REG,
2790 .en_mask = BIT(0),
2791 .reset_reg = SW_RESET_CORE_REG,
2792 .reset_mask = BIT(6),
2793 .halt_reg = DBG_BUS_VEC_C_REG,
2794 .halt_bit = 29,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002795 .retain_reg = VCODEC_CC_REG,
2796 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002797 },
2798 .ns_reg = VCODEC_NS_REG,
2799 .md_reg = VCODEC_MD0_REG,
2800 .root_en_mask = BIT(2),
2801 .ns_mask = (BM(18, 11) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08002802 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002803 .ctl_mask = BM(7, 6),
2804 .set_rate = set_rate_mnd,
2805 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002806 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002807 .c = {
2808 .dbg_name = "vcodec_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002809 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002810 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
2811 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002812 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002813 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002814 },
2815};
2816
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002817#define F_VPE(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002818 { \
2819 .freq_hz = f, \
2820 .src_clk = &s##_clk.c, \
2821 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002822 }
2823static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002824 F_VPE( 0, gnd, 1),
2825 F_VPE( 27000000, pxo, 1),
2826 F_VPE( 34909000, pll8, 11),
2827 F_VPE( 38400000, pll8, 10),
2828 F_VPE( 64000000, pll8, 6),
2829 F_VPE( 76800000, pll8, 5),
2830 F_VPE( 96000000, pll8, 4),
2831 F_VPE(100000000, pll2, 8),
2832 F_VPE(160000000, pll2, 5),
2833 F_VPE(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002834 F_END
2835};
2836
2837static struct rcg_clk vpe_clk = {
2838 .b = {
2839 .ctl_reg = VPE_CC_REG,
2840 .en_mask = BIT(0),
2841 .reset_reg = SW_RESET_CORE_REG,
2842 .reset_mask = BIT(17),
2843 .halt_reg = DBG_BUS_VEC_A_REG,
2844 .halt_bit = 28,
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002845 .retain_reg = VPE_CC_REG,
2846 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002847 },
2848 .ns_reg = VPE_NS_REG,
2849 .root_en_mask = BIT(2),
2850 .ns_mask = (BM(15, 12) | BM(2, 0)),
2851 .set_rate = set_rate_nop,
2852 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002853 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002854 .c = {
2855 .dbg_name = "vpe_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002856 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002857 VDD_DIG_FMAX_MAP3(LOW, 76800000, NOMINAL, 160000000,
2858 HIGH, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002859 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002860 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002861 },
2862};
2863
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002864#define F_VFE(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002865 { \
2866 .freq_hz = f, \
2867 .src_clk = &s##_clk.c, \
2868 .md_val = MD8(8, m, 0, n), \
2869 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
2870 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002871 }
2872static struct clk_freq_tbl clk_tbl_vfe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002873 F_VFE( 0, gnd, 1, 0, 0),
2874 F_VFE( 13960000, pll8, 1, 2, 55),
2875 F_VFE( 27000000, pxo, 1, 0, 0),
2876 F_VFE( 36570000, pll8, 1, 2, 21),
2877 F_VFE( 38400000, pll8, 2, 1, 5),
2878 F_VFE( 45180000, pll8, 1, 2, 17),
2879 F_VFE( 48000000, pll8, 2, 1, 4),
2880 F_VFE( 54860000, pll8, 1, 1, 7),
2881 F_VFE( 64000000, pll8, 2, 1, 3),
2882 F_VFE( 76800000, pll8, 1, 1, 5),
2883 F_VFE( 96000000, pll8, 2, 1, 2),
2884 F_VFE(109710000, pll8, 1, 2, 7),
2885 F_VFE(128000000, pll8, 1, 1, 3),
2886 F_VFE(153600000, pll8, 1, 2, 5),
2887 F_VFE(200000000, pll2, 2, 1, 2),
2888 F_VFE(228570000, pll2, 1, 2, 7),
2889 F_VFE(266667000, pll2, 1, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002890 F_END
2891};
2892
2893static struct rcg_clk vfe_clk = {
2894 .b = {
2895 .ctl_reg = VFE_CC_REG,
2896 .reset_reg = SW_RESET_CORE_REG,
2897 .reset_mask = BIT(15),
2898 .halt_reg = DBG_BUS_VEC_B_REG,
2899 .halt_bit = 6,
2900 .en_mask = BIT(0),
Matt Wagantall6bc8f102012-01-20 19:20:44 -08002901 .retain_reg = VFE_CC_REG,
2902 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002903 },
2904 .ns_reg = VFE_NS_REG,
2905 .md_reg = VFE_MD_REG,
2906 .root_en_mask = BIT(2),
2907 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08002908 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002909 .ctl_mask = BM(7, 6),
2910 .set_rate = set_rate_mnd,
2911 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002912 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002913 .c = {
2914 .dbg_name = "vfe_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07002915 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002916 VDD_DIG_FMAX_MAP3(LOW, 110000000, NOMINAL, 228570000,
2917 HIGH, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002918 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07002919 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002920 },
2921};
2922
2923static struct branch_clk csi0_vfe_clk = {
2924 .b = {
2925 .ctl_reg = VFE_CC_REG,
2926 .en_mask = BIT(12),
2927 .reset_reg = SW_RESET_CORE_REG,
2928 .reset_mask = BIT(24),
2929 .halt_reg = DBG_BUS_VEC_B_REG,
2930 .halt_bit = 7,
2931 },
2932 .parent = &vfe_clk.c,
2933 .c = {
2934 .dbg_name = "csi0_vfe_clk",
2935 .ops = &clk_ops_branch,
2936 CLK_INIT(csi0_vfe_clk.c),
2937 },
2938};
2939
2940static struct branch_clk csi1_vfe_clk = {
2941 .b = {
2942 .ctl_reg = VFE_CC_REG,
2943 .en_mask = BIT(10),
2944 .reset_reg = SW_RESET_CORE_REG,
2945 .reset_mask = BIT(23),
2946 .halt_reg = DBG_BUS_VEC_B_REG,
2947 .halt_bit = 8,
2948 },
2949 .parent = &vfe_clk.c,
2950 .c = {
2951 .dbg_name = "csi1_vfe_clk",
2952 .ops = &clk_ops_branch,
2953 CLK_INIT(csi1_vfe_clk.c),
2954 },
2955};
2956
2957/*
2958 * Low Power Audio Clocks
2959 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002960#define F_AIF_OSR(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002961 { \
2962 .freq_hz = f, \
2963 .src_clk = &s##_clk.c, \
2964 .md_val = MD8(8, m, 0, n), \
2965 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002966 }
2967static struct clk_freq_tbl clk_tbl_aif_osr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002968 F_AIF_OSR( 0, gnd, 1, 0, 0),
2969 F_AIF_OSR( 768000, pll4, 4, 1, 176),
2970 F_AIF_OSR( 1024000, pll4, 4, 1, 132),
2971 F_AIF_OSR( 1536000, pll4, 4, 1, 88),
2972 F_AIF_OSR( 2048000, pll4, 4, 1, 66),
2973 F_AIF_OSR( 3072000, pll4, 4, 1, 44),
2974 F_AIF_OSR( 4096000, pll4, 4, 1, 33),
2975 F_AIF_OSR( 6144000, pll4, 4, 1, 22),
2976 F_AIF_OSR( 8192000, pll4, 2, 1, 33),
2977 F_AIF_OSR(12288000, pll4, 4, 1, 11),
2978 F_AIF_OSR(24576000, pll4, 2, 1, 11),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002979 F_END
2980};
2981
2982#define CLK_AIF_OSR(i, ns, md, h_r) \
2983 struct rcg_clk i##_clk = { \
2984 .b = { \
2985 .ctl_reg = ns, \
2986 .en_mask = BIT(17), \
2987 .reset_reg = ns, \
2988 .reset_mask = BIT(19), \
2989 .halt_reg = h_r, \
2990 .halt_check = ENABLE, \
2991 .halt_bit = 1, \
2992 }, \
2993 .ns_reg = ns, \
2994 .md_reg = md, \
2995 .root_en_mask = BIT(9), \
2996 .ns_mask = (BM(31, 24) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08002997 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002998 .set_rate = set_rate_mnd, \
2999 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003000 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003001 .c = { \
3002 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -07003003 .ops = &clk_ops_rcg, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003004 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003005 CLK_INIT(i##_clk.c), \
3006 }, \
3007 }
3008
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003009#define CLK_AIF_BIT(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08003010 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003011 .b = { \
3012 .ctl_reg = ns, \
3013 .en_mask = BIT(15), \
3014 .halt_reg = h_r, \
3015 .halt_check = DELAY, \
3016 }, \
3017 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08003018 .ext_mask = BIT(14), \
3019 .div_offset = 10, \
3020 .max_div = 16, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003021 .c = { \
3022 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08003023 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003024 CLK_INIT(i##_clk.c), \
3025 }, \
3026 }
3027
3028static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
3029 LCC_MI2S_STATUS_REG);
3030static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
3031
3032static CLK_AIF_OSR(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
3033 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
3034static CLK_AIF_BIT(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
3035 LCC_CODEC_I2S_MIC_STATUS_REG);
3036
3037static CLK_AIF_OSR(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
3038 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
3039static CLK_AIF_BIT(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
3040 LCC_SPARE_I2S_MIC_STATUS_REG);
3041
3042static CLK_AIF_OSR(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
3043 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
3044static CLK_AIF_BIT(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
3045 LCC_CODEC_I2S_SPKR_STATUS_REG);
3046
3047static CLK_AIF_OSR(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
3048 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
3049static CLK_AIF_BIT(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
3050 LCC_SPARE_I2S_SPKR_STATUS_REG);
3051
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003052#define F_PCM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003053 { \
3054 .freq_hz = f, \
3055 .src_clk = &s##_clk.c, \
3056 .md_val = MD16(m, n), \
3057 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003058 }
3059static struct clk_freq_tbl clk_tbl_pcm[] = {
Stephen Boyd630f3252012-01-31 00:10:08 -08003060 { .ns_val = BIT(10) /* external input */ },
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003061 F_PCM( 512000, pll4, 4, 1, 264),
3062 F_PCM( 768000, pll4, 4, 1, 176),
3063 F_PCM( 1024000, pll4, 4, 1, 132),
3064 F_PCM( 1536000, pll4, 4, 1, 88),
3065 F_PCM( 2048000, pll4, 4, 1, 66),
3066 F_PCM( 3072000, pll4, 4, 1, 44),
3067 F_PCM( 4096000, pll4, 4, 1, 33),
3068 F_PCM( 6144000, pll4, 4, 1, 22),
3069 F_PCM( 8192000, pll4, 2, 1, 33),
3070 F_PCM(12288000, pll4, 4, 1, 11),
3071 F_PCM(24580000, pll4, 2, 1, 11),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003072 F_END
3073};
3074
3075static struct rcg_clk pcm_clk = {
3076 .b = {
3077 .ctl_reg = LCC_PCM_NS_REG,
3078 .en_mask = BIT(11),
3079 .reset_reg = LCC_PCM_NS_REG,
3080 .reset_mask = BIT(13),
3081 .halt_reg = LCC_PCM_STATUS_REG,
3082 .halt_check = ENABLE,
3083 .halt_bit = 0,
3084 },
3085 .ns_reg = LCC_PCM_NS_REG,
3086 .md_reg = LCC_PCM_MD_REG,
3087 .root_en_mask = BIT(9),
Stephen Boyd630f3252012-01-31 00:10:08 -08003088 .ns_mask = BM(31, 16) | BIT(10) | BM(6, 0),
Matt Wagantall07c45472012-02-10 23:27:24 -08003089 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003090 .set_rate = set_rate_mnd,
3091 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003092 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003093 .c = {
3094 .dbg_name = "pcm_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07003095 .ops = &clk_ops_rcg,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003096 VDD_DIG_FMAX_MAP1(LOW, 24580000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003097 CLK_INIT(pcm_clk.c),
3098 },
3099};
3100
Matt Wagantall735f01a2011-08-12 12:40:28 -07003101DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
3102DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
3103DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
3104DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
3105DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
3106DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
3107DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
3108DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Matt Wagantallf8032602011-06-15 23:01:56 -07003109DEFINE_CLK_RPM(smi_clk, smi_a_clk, SMI, &smi_2x_axi_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003110
Matt Wagantall35e78fc2012-04-05 14:18:44 -07003111static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c, 0);
3112static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c, 0);
3113static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c, 0);
3114static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c, 0);
3115static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c, 0);
3116static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c, 0);
3117static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c, 0);
3118static DEFINE_CLK_VOTER(dfab_scm_clk, &dfab_clk.c, 0);
Ramesh Masavarapued4e6012012-04-12 16:30:40 -07003119static DEFINE_CLK_VOTER(dfab_qseecom_clk, &dfab_clk.c, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003120
Matt Wagantall42cd12a2012-03-30 18:02:40 -07003121static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c, LONG_MAX);
Matt Wagantall35e78fc2012-04-05 14:18:44 -07003122static DEFINE_CLK_VOTER(ebi1_adm0_clk, &ebi1_clk.c, 0);
3123static DEFINE_CLK_VOTER(ebi1_adm1_clk, &ebi1_clk.c, 0);
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003124static DEFINE_CLK_VOTER(ebi1_acpu_a_clk, &ebi1_a_clk.c, LONG_MAX);
3125static DEFINE_CLK_VOTER(ebi1_msmbus_a_clk, &ebi1_a_clk.c, LONG_MAX);
3126static DEFINE_CLK_VOTER(afab_acpu_a_clk, &afab_a_clk.c, LONG_MAX);
3127static DEFINE_CLK_VOTER(afab_msmbus_a_clk, &afab_a_clk.c, LONG_MAX);
3128
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003129static DEFINE_CLK_MEASURE(sc0_m_clk);
3130static DEFINE_CLK_MEASURE(sc1_m_clk);
3131static DEFINE_CLK_MEASURE(l2_m_clk);
3132
3133#ifdef CONFIG_DEBUG_FS
3134struct measure_sel {
3135 u32 test_vector;
3136 struct clk *clk;
3137};
3138
3139static struct measure_sel measure_mux[] = {
3140 { TEST_PER_LS(0x08), &modem_ahb1_p_clk.c },
3141 { TEST_PER_LS(0x09), &modem_ahb2_p_clk.c },
3142 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
3143 { TEST_PER_LS(0x13), &sdc1_clk.c },
3144 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
3145 { TEST_PER_LS(0x15), &sdc2_clk.c },
3146 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
3147 { TEST_PER_LS(0x17), &sdc3_clk.c },
3148 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
3149 { TEST_PER_LS(0x19), &sdc4_clk.c },
3150 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
3151 { TEST_PER_LS(0x1B), &sdc5_clk.c },
Matt Wagantall66cd0932011-09-12 19:04:34 -07003152 { TEST_PER_LS(0x1D), &ebi2_2x_clk.c },
3153 { TEST_PER_LS(0x1E), &ebi2_clk.c },
Matt Wagantall7625a4c2011-11-01 16:17:53 -07003154 { TEST_PER_LS(0x1F), &gp0_clk.c },
3155 { TEST_PER_LS(0x20), &gp1_clk.c },
3156 { TEST_PER_LS(0x21), &gp2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003157 { TEST_PER_LS(0x25), &dfab_clk.c },
3158 { TEST_PER_LS(0x25), &dfab_a_clk.c },
3159 { TEST_PER_LS(0x26), &pmem_clk.c },
3160 { TEST_PER_LS(0x2B), &ppss_p_clk.c },
3161 { TEST_PER_LS(0x33), &cfpb_clk.c },
3162 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
3163 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
3164 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
3165 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
3166 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
3167 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
3168 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
3169 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
3170 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
3171 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
3172 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
3173 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
3174 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
3175 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
3176 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
3177 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
3178 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
3179 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
3180 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
3181 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
3182 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
3183 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
3184 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
3185 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
3186 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
3187 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
3188 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
3189 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
3190 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
3191 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
3192 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
3193 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
3194 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
3195 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
3196 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
3197 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
3198 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
3199 { TEST_PER_LS(0x78), &sfpb_clk.c },
3200 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
3201 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
3202 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
3203 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
3204 { TEST_PER_LS(0x7D), &prng_clk.c },
3205 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
3206 { TEST_PER_LS(0x80), &adm0_p_clk.c },
3207 { TEST_PER_LS(0x81), &adm1_p_clk.c },
3208 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
3209 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
3210 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
3211 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
3212 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
3213 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
3214 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
3215 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
3216 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
3217 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
3218 { TEST_PER_LS(0x93), &ce2_p_clk.c },
3219 { TEST_PER_LS(0x94), &tssc_clk.c },
3220
3221 { TEST_PER_HS(0x07), &afab_clk.c },
3222 { TEST_PER_HS(0x07), &afab_a_clk.c },
3223 { TEST_PER_HS(0x18), &sfab_clk.c },
3224 { TEST_PER_HS(0x18), &sfab_a_clk.c },
3225 { TEST_PER_HS(0x2A), &adm0_clk.c },
3226 { TEST_PER_HS(0x2B), &adm1_clk.c },
3227 { TEST_PER_HS(0x34), &ebi1_clk.c },
3228 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
3229
3230 { TEST_MM_LS(0x00), &dsi_byte_clk.c },
3231 { TEST_MM_LS(0x01), &pixel_lcdc_clk.c },
3232 { TEST_MM_LS(0x04), &pixel_mdp_clk.c },
3233 { TEST_MM_LS(0x06), &amp_p_clk.c },
3234 { TEST_MM_LS(0x07), &csi0_p_clk.c },
3235 { TEST_MM_LS(0x08), &csi1_p_clk.c },
3236 { TEST_MM_LS(0x09), &dsi_m_p_clk.c },
3237 { TEST_MM_LS(0x0A), &dsi_s_p_clk.c },
3238 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
3239 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
3240 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
3241 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
3242 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
3243 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
3244 { TEST_MM_LS(0x12), &imem_p_clk.c },
3245 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
3246 { TEST_MM_LS(0x14), &mdp_p_clk.c },
3247 { TEST_MM_LS(0x16), &rot_p_clk.c },
3248 { TEST_MM_LS(0x18), &smmu_p_clk.c },
3249 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
3250 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
3251 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
3252 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
3253 { TEST_MM_LS(0x1D), &cam_clk.c },
3254 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
3255 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
3256 { TEST_MM_LS(0x21), &tv_dac_clk.c },
3257 { TEST_MM_LS(0x22), &tv_enc_clk.c },
3258 { TEST_MM_LS(0x23), &dsi_esc_clk.c },
3259 { TEST_MM_LS(0x25), &mmfpb_clk.c },
3260 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
3261
3262 { TEST_MM_HS(0x00), &csi0_clk.c },
3263 { TEST_MM_HS(0x01), &csi1_clk.c },
3264 { TEST_MM_HS(0x03), &csi0_vfe_clk.c },
3265 { TEST_MM_HS(0x04), &csi1_vfe_clk.c },
3266 { TEST_MM_HS(0x05), &ijpeg_clk.c },
3267 { TEST_MM_HS(0x06), &vfe_clk.c },
3268 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
3269 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
3270 { TEST_MM_HS(0x09), &gfx3d_clk.c },
3271 { TEST_MM_HS(0x0A), &jpegd_clk.c },
3272 { TEST_MM_HS(0x0B), &vcodec_clk.c },
3273 { TEST_MM_HS(0x0F), &mmfab_clk.c },
3274 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
3275 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
3276 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
3277 { TEST_MM_HS(0x13), &imem_axi_clk.c },
3278 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
3279 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
Matt Wagantallf63a8892011-06-15 16:44:46 -07003280 { TEST_MM_HS(0x16), &rot_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003281 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
3282 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
Matt Wagantallf63a8892011-06-15 16:44:46 -07003283 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003284 { TEST_MM_HS(0x1A), &mdp_clk.c },
3285 { TEST_MM_HS(0x1B), &rot_clk.c },
3286 { TEST_MM_HS(0x1C), &vpe_clk.c },
3287 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
3288 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
Matt Wagantallf8032602011-06-15 23:01:56 -07003289 { TEST_MM_HS(0x24), &smi_2x_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003290
3291 { TEST_MM_HS2X(0x24), &smi_clk.c },
3292 { TEST_MM_HS2X(0x24), &smi_a_clk.c },
3293
3294 { TEST_LPA(0x0A), &mi2s_osr_clk.c },
3295 { TEST_LPA(0x0B), &mi2s_bit_clk.c },
3296 { TEST_LPA(0x0C), &codec_i2s_mic_osr_clk.c },
3297 { TEST_LPA(0x0D), &codec_i2s_mic_bit_clk.c },
3298 { TEST_LPA(0x0E), &codec_i2s_spkr_osr_clk.c },
3299 { TEST_LPA(0x0F), &codec_i2s_spkr_bit_clk.c },
3300 { TEST_LPA(0x10), &spare_i2s_mic_osr_clk.c },
3301 { TEST_LPA(0x11), &spare_i2s_mic_bit_clk.c },
3302 { TEST_LPA(0x12), &spare_i2s_spkr_osr_clk.c },
3303 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
3304 { TEST_LPA(0x14), &pcm_clk.c },
3305
3306 { TEST_SC(0x40), &sc0_m_clk },
3307 { TEST_SC(0x41), &sc1_m_clk },
3308 { TEST_SC(0x42), &l2_m_clk },
3309};
3310
3311static struct measure_sel *find_measure_sel(struct clk *clk)
3312{
3313 int i;
3314
3315 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
3316 if (measure_mux[i].clk == clk)
3317 return &measure_mux[i];
3318 return NULL;
3319}
3320
3321static int measure_clk_set_parent(struct clk *c, struct clk *parent)
3322{
3323 int ret = 0;
3324 u32 clk_sel;
3325 struct measure_sel *p;
3326 struct measure_clk *clk = to_measure_clk(c);
3327 unsigned long flags;
3328
3329 if (!parent)
3330 return -EINVAL;
3331
3332 p = find_measure_sel(parent);
3333 if (!p)
3334 return -EINVAL;
3335
3336 spin_lock_irqsave(&local_clock_reg_lock, flags);
3337
3338 /*
3339 * Program the test vector, measurement period (sample_ticks)
3340 * and scaling factors (multiplier, divider).
3341 */
3342 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
3343 clk->sample_ticks = 0x10000;
3344 clk->multiplier = 1;
3345 clk->divider = 1;
3346 switch (p->test_vector >> TEST_TYPE_SHIFT) {
3347 case TEST_TYPE_PER_LS:
3348 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
3349 break;
3350 case TEST_TYPE_PER_HS:
3351 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
3352 break;
3353 case TEST_TYPE_MM_LS:
3354 writel_relaxed(0x4030D97, CLK_TEST_REG);
3355 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
3356 break;
3357 case TEST_TYPE_MM_HS2X:
3358 clk->divider = 2;
3359 case TEST_TYPE_MM_HS:
3360 writel_relaxed(0x402B800, CLK_TEST_REG);
3361 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
3362 break;
3363 case TEST_TYPE_LPA:
3364 writel_relaxed(0x4030D98, CLK_TEST_REG);
3365 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
3366 LCC_CLK_LS_DEBUG_CFG_REG);
3367 break;
3368 case TEST_TYPE_SC:
3369 writel_relaxed(0x5020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
3370 clk->sample_ticks = 0x4000;
3371 clk->multiplier = 2;
3372 break;
3373 default:
3374 ret = -EPERM;
3375 }
3376 /* Make sure test vector is set before starting measurements. */
3377 mb();
3378
3379 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3380
3381 return ret;
3382}
3383
3384/* Sample clock for 'ticks' reference clock ticks. */
3385static u32 run_measurement(unsigned ticks)
3386{
3387 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003388 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
3389
3390 /* Wait for timer to become ready. */
3391 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
3392 cpu_relax();
3393
3394 /* Run measurement and wait for completion. */
3395 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
3396 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
3397 cpu_relax();
3398
3399 /* Stop counters. */
3400 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
3401
3402 /* Return measured ticks. */
3403 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
3404}
3405
3406/* Perform a hardware rate measurement for a given clock.
3407 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003408static unsigned long measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003409{
3410 unsigned long flags;
3411 u32 pdm_reg_backup, ringosc_reg_backup;
3412 u64 raw_count_short, raw_count_full;
3413 struct measure_clk *clk = to_measure_clk(c);
3414 unsigned ret;
3415
3416 spin_lock_irqsave(&local_clock_reg_lock, flags);
3417
3418 /* Enable CXO/4 and RINGOSC branch and root. */
3419 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
3420 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
3421 writel_relaxed(0x2898, PDM_CLK_NS_REG);
3422 writel_relaxed(0xA00, RINGOSC_NS_REG);
3423
3424 /*
3425 * The ring oscillator counter will not reset if the measured clock
3426 * is not running. To detect this, run a short measurement before
3427 * the full measurement. If the raw results of the two are the same
3428 * then the clock must be off.
3429 */
3430
3431 /* Run a short measurement. (~1 ms) */
3432 raw_count_short = run_measurement(0x1000);
3433 /* Run a full measurement. (~14 ms) */
3434 raw_count_full = run_measurement(clk->sample_ticks);
3435
3436 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
3437 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
3438
3439 /* Return 0 if the clock is off. */
3440 if (raw_count_full == raw_count_short)
3441 ret = 0;
3442 else {
3443 /* Compute rate in Hz. */
3444 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
3445 do_div(raw_count_full,
3446 (((clk->sample_ticks * 10) + 35) * clk->divider));
3447 ret = (raw_count_full * clk->multiplier);
3448 }
3449
3450 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
3451 writel_relaxed(0x3CF8, PLLTEST_PAD_CFG_REG);
3452 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3453
3454 return ret;
3455}
3456#else /* !CONFIG_DEBUG_FS */
3457static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
3458{
3459 return -EINVAL;
3460}
3461
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003462static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003463{
3464 return 0;
3465}
3466#endif /* CONFIG_DEBUG_FS */
3467
Matt Wagantallae053222012-05-14 19:42:07 -07003468static struct clk_ops clk_ops_measure = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003469 .set_parent = measure_clk_set_parent,
3470 .get_rate = measure_clk_get_rate,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003471};
3472
3473static struct measure_clk measure_clk = {
3474 .c = {
3475 .dbg_name = "measure_clk",
Matt Wagantallae053222012-05-14 19:42:07 -07003476 .ops = &clk_ops_measure,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003477 CLK_INIT(measure_clk.c),
3478 },
3479 .multiplier = 1,
3480 .divider = 1,
3481};
3482
3483static struct clk_lookup msm_clocks_8x60[] = {
Stephen Boyd72a80352012-01-26 15:57:38 -08003484 CLK_LOOKUP("xo", cxo_clk.c, ""),
3485 CLK_LOOKUP("xo", cxo_a_clk.c, ""),
3486 CLK_LOOKUP("xo", pxo_a_clk.c, ""),
Stephen Boyd67036532012-01-26 15:43:51 -08003487 CLK_LOOKUP("xo", pxo_clk.c, "pil_modem"),
Stephen Boyd3acc9e42011-09-28 16:46:40 -07003488 CLK_LOOKUP("pll4", pll4_clk.c, "pil_qdsp6v3"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003489 CLK_LOOKUP("measure", measure_clk.c, "debug"),
3490
Matt Wagantalld75f1312012-05-23 16:17:35 -07003491 CLK_LOOKUP("bus_clk", afab_clk.c, ""),
3492 CLK_LOOKUP("bus_clk", afab_a_clk.c, ""),
3493 CLK_LOOKUP("bus_clk", cfpb_clk.c, ""),
3494 CLK_LOOKUP("bus_clk", cfpb_a_clk.c, ""),
3495 CLK_LOOKUP("bus_clk", dfab_clk.c, ""),
3496 CLK_LOOKUP("bus_clk", dfab_a_clk.c, ""),
3497 CLK_LOOKUP("mem_clk", ebi1_clk.c, ""),
3498 CLK_LOOKUP("mem_clk", ebi1_a_clk.c, ""),
3499 CLK_LOOKUP("bus_clk", mmfab_clk.c, ""),
3500 CLK_LOOKUP("bus_clk", mmfab_a_clk.c, ""),
3501 CLK_LOOKUP("bus_clk", mmfpb_clk.c, ""),
3502 CLK_LOOKUP("bus_clk", mmfpb_a_clk.c, ""),
3503 CLK_LOOKUP("bus_clk", sfab_clk.c, ""),
3504 CLK_LOOKUP("bus_clk", sfab_a_clk.c, ""),
3505 CLK_LOOKUP("bus_clk", sfpb_clk.c, ""),
3506 CLK_LOOKUP("bus_clk", sfpb_a_clk.c, ""),
3507 CLK_LOOKUP("mem_clk", smi_clk.c, ""),
3508 CLK_LOOKUP("mem_clk", smi_a_clk.c, ""),
3509
Matt Wagantallb2710b82011-11-16 19:55:17 -08003510 CLK_LOOKUP("bus_clk", afab_clk.c, "msm_apps_fab"),
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003511 CLK_LOOKUP("bus_a_clk", afab_msmbus_a_clk.c, "msm_apps_fab"),
Matt Wagantallb2710b82011-11-16 19:55:17 -08003512 CLK_LOOKUP("bus_clk", sfab_clk.c, "msm_sys_fab"),
3513 CLK_LOOKUP("bus_a_clk", sfab_a_clk.c, "msm_sys_fab"),
3514 CLK_LOOKUP("bus_clk", sfpb_clk.c, "msm_sys_fpb"),
3515 CLK_LOOKUP("bus_a_clk", sfpb_a_clk.c, "msm_sys_fpb"),
3516 CLK_LOOKUP("bus_clk", mmfab_clk.c, "msm_mm_fab"),
3517 CLK_LOOKUP("bus_a_clk", mmfab_a_clk.c, "msm_mm_fab"),
3518 CLK_LOOKUP("bus_clk", cfpb_clk.c, "msm_cpss_fpb"),
3519 CLK_LOOKUP("bus_a_clk", cfpb_a_clk.c, "msm_cpss_fpb"),
3520 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003521 CLK_LOOKUP("mem_a_clk", ebi1_msmbus_a_clk.c, "msm_bus"),
Matt Wagantallb2710b82011-11-16 19:55:17 -08003522 CLK_LOOKUP("smi_clk", smi_clk.c, "msm_bus"),
3523 CLK_LOOKUP("smi_a_clk", smi_a_clk.c, "msm_bus"),
3524
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003525 CLK_LOOKUP("core_clk", gp0_clk.c, ""),
3526 CLK_LOOKUP("core_clk", gp1_clk.c, ""),
3527 CLK_LOOKUP("core_clk", gp2_clk.c, ""),
3528 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, ""),
3529 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003530 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, "msm_serial_hsl.2"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003531 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, ""),
3532 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003533 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003534 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, ""),
3535 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003536 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, "msm_serial_hsl.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003537 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, ""),
3538 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003539 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, "msm_serial_hsl.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003540 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003541 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07003542 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.0"),
3543 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003544 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, ""),
3545 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07003546 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, "qup_i2c.4"),
3547 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, "qup_i2c.3"),
3548 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, "qup_i2c.2"),
3549 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "spi_qsd.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003550 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, ""),
Wentao Xu4a053042011-10-03 14:06:34 -04003551 CLK_LOOKUP("gsbi_qup_clk", gsbi12_qup_clk.c, "msm_dsps"),
Matt Wagantallac294852011-08-17 15:44:58 -07003552 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.5"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003553 CLK_LOOKUP("core_clk", pdm_clk.c, ""),
Wentao Xu4a053042011-10-03 14:06:34 -04003554 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_dsps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07003555 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07003556 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
3557 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
3558 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
3559 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
3560 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07003561 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, "msm_tsif.0"),
3562 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, "msm_tsif.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003563 CLK_LOOKUP("core_clk", tssc_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08003564 CLK_LOOKUP("alt_core_clk", usb_hs1_xcvr_clk.c, "msm_otg"),
3565 CLK_LOOKUP("phy_clk", usb_phy0_clk.c, "msm_otg"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003566 CLK_LOOKUP("alt_core_clk", usb_fs1_xcvr_clk.c, ""),
3567 CLK_LOOKUP("sys_clk", usb_fs1_sys_clk.c, ""),
3568 CLK_LOOKUP("src_clk", usb_fs1_src_clk.c, ""),
3569 CLK_LOOKUP("alt_core_clk", usb_fs2_xcvr_clk.c, ""),
3570 CLK_LOOKUP("sys_clk", usb_fs2_sys_clk.c, ""),
3571 CLK_LOOKUP("src_clk", usb_fs2_src_clk.c, ""),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07003572 CLK_LOOKUP("core_clk", ce2_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07003573 CLK_LOOKUP("core_clk", ce2_p_clk.c, "qcrypto.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003574 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003575 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003576 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "msm_serial_hsl.2"),
Matt Wagantallac294852011-08-17 15:44:58 -07003577 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.0"),
3578 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003579 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003580 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003581 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, "qup_i2c.4"),
3582 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, "qup_i2c.3"),
Matt Wagantalle2522372011-08-17 14:52:21 -07003583 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, "msm_serial_hsl.1"),
Matt Wagantallac294852011-08-17 15:44:58 -07003584 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, "qup_i2c.2"),
3585 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "spi_qsd.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003586 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, ""),
3587 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003588 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "msm_serial_hsl.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003589 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.5"),
Matt Wagantall5bb16ca2012-04-19 11:34:01 -07003590 CLK_LOOKUP("iface_clk", ppss_p_clk.c, "msm_dsps"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07003591 CLK_LOOKUP("iface_clk", tsif_p_clk.c, "msm_tsif.0"),
3592 CLK_LOOKUP("iface_clk", tsif_p_clk.c, "msm_tsif.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003593 CLK_LOOKUP("iface_clk", usb_fs1_p_clk.c, ""),
3594 CLK_LOOKUP("iface_clk", usb_fs2_p_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08003595 CLK_LOOKUP("iface_clk", usb_hs1_p_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07003596 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
3597 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
3598 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
3599 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
3600 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003601 CLK_LOOKUP("mem_clk", ebi2_2x_clk.c, ""),
Terence Hampsonb36a38c2011-09-19 19:10:40 -04003602 CLK_LOOKUP("mem_clk", ebi2_clk.c, "msm_ebi2"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07003603 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov.0"),
3604 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov.0"),
3605 CLK_LOOKUP("core_clk", adm1_clk.c, "msm_dmov.1"),
3606 CLK_LOOKUP("iface_clk", adm1_p_clk.c, "msm_dmov.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003607 CLK_LOOKUP("iface_clk", modem_ahb1_p_clk.c, ""),
3608 CLK_LOOKUP("iface_clk", modem_ahb2_p_clk.c, ""),
3609 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, ""),
3610 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, ""),
3611 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, ""),
3612 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003613 CLK_LOOKUP("cam_clk", cam_clk.c, NULL),
3614 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
3615 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov7692.0"),
3616 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov9726.0"),
Kevin Chan3be11612012-03-22 20:05:40 -07003617 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csic.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003618 CLK_LOOKUP("csi_src_clk", csi_src_clk.c, NULL),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003619 CLK_LOOKUP("byte_clk", dsi_byte_clk.c, "mipi_dsi.1"),
3620 CLK_LOOKUP("esc_clk", dsi_esc_clk.c, "mipi_dsi.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003621 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003622 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003623 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07003624 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003625 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003626 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
Matt Wagantallf45cd362012-05-03 21:09:44 -07003627 CLK_LOOKUP("core_clk", ijpeg_clk.c, "msm_gemini.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003628 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07003629 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003630 CLK_LOOKUP("core_clk", mdp_clk.c, "mdp.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003631 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003632 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "mdp.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003633 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003634 CLK_LOOKUP("lcdc_clk", pixel_lcdc_clk.c, "lcdc.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003635 CLK_LOOKUP("pixel_lcdc_clk", pixel_lcdc_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003636 CLK_LOOKUP("mdp_clk", pixel_mdp_clk.c, "lcdc.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003637 CLK_LOOKUP("pixel_mdp_clk", pixel_mdp_clk.c, "footswitch-8x60.4"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07003638 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003639 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003640 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
3641 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07003642 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003643 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003644 CLK_LOOKUP("mdp_clk", mdp_tv_clk.c, "dtv.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003645 CLK_LOOKUP("tv_clk", mdp_tv_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003646 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, "dtv.0"),
3647 CLK_LOOKUP("src_clk", tv_src_clk.c, "dtv.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003648 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, "footswitch-8x60.4"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07003649 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003650 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003651 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003652 CLK_LOOKUP("csi_vfe_clk", csi0_vfe_clk.c, NULL),
3653 CLK_LOOKUP("csi_vfe_clk", csi1_vfe_clk.c, "msm_camera_ov7692.0"),
3654 CLK_LOOKUP("csi_vfe_clk", csi1_vfe_clk.c, "msm_camera_ov9726.0"),
Kevin Chan3be11612012-03-22 20:05:40 -07003655 CLK_LOOKUP("csi_vfe_clk", csi1_vfe_clk.c, "msm_csic.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003656 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003657 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Matt Wagantall49722712011-08-17 18:50:53 -07003658 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
3659 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003660 CLK_LOOKUP("mem_clk", imem_axi_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003661 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
3662 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
3663 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
3664 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003665 CLK_LOOKUP("arb_clk", amp_p_clk.c, "mipi_dsi.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003666 CLK_LOOKUP("csi_pclk", csi0_p_clk.c, NULL),
3667 CLK_LOOKUP("csi_pclk", csi1_p_clk.c, "msm_camera_ov7692.0"),
3668 CLK_LOOKUP("csi_pclk", csi1_p_clk.c, "msm_camera_ov9726.0"),
Kevin Chan3be11612012-03-22 20:05:40 -07003669 CLK_LOOKUP("csi_pclk", csi1_p_clk.c, "msm_csic.1"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003670 CLK_LOOKUP("master_iface_clk", dsi_m_p_clk.c, "mipi_dsi.1"),
3671 CLK_LOOKUP("slave_iface_clk", dsi_s_p_clk.c, "mipi_dsi.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003672 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003673 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003674 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07003675 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003676 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003677 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07003678 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
3679 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Matt Wagantallf45cd362012-05-03 21:09:44 -07003680 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "msm_gemini.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003681 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07003682 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003683 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, "kgsl-3d0.0"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003684 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "mdp.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003685 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07003686 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07003687 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003688 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003689 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07003690 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003691 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003692 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003693 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003694 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003695 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003696 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
3697 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
3698 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
3699 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
3700 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
3701 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
3702 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
3703 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
3704 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
3705 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
3706 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
Matt Wagantalle604d712011-10-21 15:38:18 -07003707 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
Matt Wagantall21903c02012-04-17 16:39:58 -07003708 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
Matt Wagantalle604d712011-10-21 15:38:18 -07003709 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
3710 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
Matt Wagantall21903c02012-04-17 16:39:58 -07003711 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07003712 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
3713 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
3714 CLK_LOOKUP("core_clk", vcodec_axi_clk.c, "msm_iommu.7"),
3715 CLK_LOOKUP("core_clk", vcodec_axi_clk.c, "msm_iommu.8"),
3716 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
3717 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
3718 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003719
Riaz Rahaman966922b2012-02-21 10:48:01 -08003720 CLK_LOOKUP("mdp_iommu_clk", mdp_axi_clk.c, "msm_vidc.0"),
3721 CLK_LOOKUP("rot_iommu_clk", rot_axi_clk.c, "msm_vidc.0"),
3722 CLK_LOOKUP("vcodec_iommu0_clk", vcodec_axi_clk.c, "msm_vidc.0"),
3723 CLK_LOOKUP("vcodec_iommu1_clk", vcodec_axi_clk.c, "msm_vidc.0"),
3724 CLK_LOOKUP("smmu_iface_clk", smmu_p_clk.c, "msm_vidc.0"),
3725
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003726 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
Manu Gautam5143b252012-01-05 19:25:23 -08003727 CLK_LOOKUP("core_clk", dfab_usb_hs_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07003728 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
3729 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
3730 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
3731 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
3732 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Stephen Boydef5d1c42011-12-15 20:47:14 -08003733 CLK_LOOKUP("bus_clk", dfab_scm_clk.c, "scm"),
Ramesh Masavarapued4e6012012-04-12 16:30:40 -07003734 CLK_LOOKUP("bus_clk", dfab_qseecom_clk.c, "qseecom"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003735
Matt Wagantalle1a86062011-08-18 17:46:10 -07003736 CLK_LOOKUP("mem_clk", ebi1_adm0_clk.c, "msm_dmov.0"),
3737 CLK_LOOKUP("mem_clk", ebi1_adm1_clk.c, "msm_dmov.1"),
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003738 CLK_LOOKUP("mem_clk", ebi1_acpu_a_clk.c, ""),
3739 CLK_LOOKUP("bus_clk", afab_acpu_a_clk.c, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003740
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003741 CLK_LOOKUP("sc0_mclk", sc0_m_clk, ""),
3742 CLK_LOOKUP("sc1_mclk", sc1_m_clk, ""),
3743 CLK_LOOKUP("l2_mclk", l2_m_clk, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003744};
3745
3746/*
3747 * Miscellaneous clock register initializations
3748 */
3749
3750/* Read, modify, then write-back a register. */
3751static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
3752{
3753 uint32_t regval = readl_relaxed(reg);
3754 regval &= ~mask;
3755 regval |= val;
3756 writel_relaxed(regval, reg);
3757}
3758
Matt Wagantallb64888f2012-04-02 21:35:07 -07003759static void __init msm8660_clock_pre_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003760{
Matt Wagantallb64888f2012-04-02 21:35:07 -07003761 vote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
3762
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003763 /* Setup MM_PLL2 (PLL3), but turn it off. Rate set by set_rate_tv(). */
3764 rmwreg(0, MM_PLL2_MODE_REG, BIT(0)); /* Disable output */
3765 /* Set ref, bypass, assert reset, disable output, disable test mode */
3766 writel_relaxed(0, MM_PLL2_MODE_REG); /* PXO */
3767 writel_relaxed(0x00800000, MM_PLL2_CONFIG_REG); /* Enable main out. */
3768
3769 /* The clock driver doesn't use SC1's voting register to control
3770 * HW-voteable clocks. Clear its bits so that disabling bits in the
3771 * SC0 register will cause the corresponding clocks to be disabled. */
3772 rmwreg(BIT(12)|BIT(11), SC0_U_CLK_BRANCH_ENA_VOTE_REG, BM(12, 11));
3773 writel_relaxed(BIT(12)|BIT(11), SC1_U_CLK_BRANCH_ENA_VOTE_REG);
3774 /* Let sc_aclk and sc_clk halt when both Scorpions are collapsed. */
3775 writel_relaxed(BIT(12)|BIT(11), SC0_U_CLK_SLEEP_ENA_VOTE_REG);
3776 writel_relaxed(BIT(12)|BIT(11), SC1_U_CLK_SLEEP_ENA_VOTE_REG);
3777
3778 /* Deassert MM SW_RESET_ALL signal. */
3779 writel_relaxed(0, SW_RESET_ALL_REG);
3780
3781 /* Initialize MM AHB registers: Enable the FPB clock and disable HW
3782 * gating for all clocks. Also set VFE_AHB's FORCE_CORE_ON bit to
3783 * prevent its memory from being collapsed when the clock is halted.
3784 * The sleep and wake-up delays are set to safe values. */
Matt Wagantall30011d22011-07-25 20:32:04 -07003785 rmwreg(0x00000003, AHB_EN_REG, 0x6C000003);
3786 writel_relaxed(0x000007F9, AHB_EN2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003787
3788 /* Deassert all locally-owned MM AHB resets. */
3789 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
3790
3791 /* Initialize MM AXI registers: Enable HW gating for all clocks that
3792 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
3793 * delays to safe values. */
Matt Wagantall30011d22011-07-25 20:32:04 -07003794 rmwreg(0x100207F9, MAXI_EN_REG, 0x1803FFFF);
3795 rmwreg(0x7027FCFF, MAXI_EN2_REG, 0x7A3FFFFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003796 writel_relaxed(0x3FE7FCFF, MAXI_EN3_REG);
3797 writel_relaxed(0x000001D8, SAXI_EN_REG);
3798
3799 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
3800 * memories retain state even when not clocked. Also, set sleep and
3801 * wake-up delays to safe values. */
Matt Wagantall30011d22011-07-25 20:32:04 -07003802 rmwreg(0x00000000, CSI_CC_REG, 0x00000018);
3803 rmwreg(0x00000400, MISC_CC_REG, 0x017C0400);
3804 rmwreg(0x000007FD, MISC_CC2_REG, 0x70C2E7FF);
3805 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
3806 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
3807 rmwreg(0x80FF0000, GFX3D_CC_REG, 0xE0FF0010);
3808 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0018);
3809 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0018);
3810 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
3811 rmwreg(0x80FF0000, PIXEL_CC_REG, 0xE1FF0010);
3812 rmwreg(0x000004FF, PIXEL_CC2_REG, 0x000007FF);
3813 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
3814 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
3815 rmwreg(0x000004FF, TV_CC2_REG, 0x000027FF);
3816 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
3817 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FFC010);
3818 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003819
3820 /* De-assert MM AXI resets to all hardware blocks. */
3821 writel_relaxed(0, SW_RESET_AXI_REG);
3822
3823 /* Deassert all MM core resets. */
3824 writel_relaxed(0, SW_RESET_CORE_REG);
3825
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003826 /* Enable TSSC and PDM PXO sources. */
3827 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
3828 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
3829 /* Set the dsi_byte_clk src to the DSI PHY PLL,
3830 * dsi_esc_clk to PXO/2, and the hdmi_app_clk src to PXO */
3831 rmwreg(0x400001, MISC_CC2_REG, 0x424003);
Stephen Boyd842a1f62012-04-26 19:07:38 -07003832
3833 if ((readl_relaxed(PRNG_CLK_NS_REG) & 0x7F) == 0x2B)
3834 prng_clk.freq_tbl = clk_tbl_prng_64;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003835}
3836
Matt Wagantallb64888f2012-04-02 21:35:07 -07003837static void __init msm8660_clock_post_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003838{
Stephen Boyd72a80352012-01-26 15:57:38 -08003839 /* Keep PXO on whenever APPS cpu is active */
3840 clk_prepare_enable(&pxo_a_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003841
Matt Wagantalle655cd72012-04-09 10:15:03 -07003842 /* Reset 3D core while clocked to ensure it resets completely. */
3843 clk_set_rate(&gfx3d_clk.c, 27000000);
3844 clk_prepare_enable(&gfx3d_clk.c);
3845 clk_reset(&gfx3d_clk.c, CLK_RESET_ASSERT);
3846 udelay(5);
3847 clk_reset(&gfx3d_clk.c, CLK_RESET_DEASSERT);
3848 clk_disable_unprepare(&gfx3d_clk.c);
3849
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003850 /* Initialize rates for clocks that only support one. */
3851 clk_set_rate(&pdm_clk.c, 27000000);
Stephen Boyd842a1f62012-04-26 19:07:38 -07003852 clk_set_rate(&prng_clk.c, prng_clk.freq_tbl->freq_hz);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003853 clk_set_rate(&mdp_vsync_clk.c, 27000000);
3854 clk_set_rate(&tsif_ref_clk.c, 105000);
3855 clk_set_rate(&tssc_clk.c, 27000000);
3856 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
3857 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
3858 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
3859
3860 /* The halt status bits for PDM and TSSC may be incorrect at boot.
3861 * Toggle these clocks on and off to refresh them. */
Stephen Boyd409b8b42012-04-10 12:12:56 -07003862 clk_prepare_enable(&pdm_clk.c);
3863 clk_disable_unprepare(&pdm_clk.c);
3864 clk_prepare_enable(&tssc_clk.c);
3865 clk_disable_unprepare(&tssc_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003866}
3867
Stephen Boydbb600ae2011-08-02 20:11:40 -07003868static int __init msm8660_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003869{
3870 int rc;
3871
3872 /* Vote for MMFPB to be at least 64MHz when an Apps CPU is active. */
3873 struct clk *mmfpb_a_clk = clk_get(NULL, "mmfpb_a_clk");
3874 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
3875 PTR_ERR(mmfpb_a_clk)))
3876 return PTR_ERR(mmfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08003877 rc = clk_set_rate(mmfpb_a_clk, 64000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003878 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
3879 return rc;
Stephen Boyde334aeb2012-01-24 12:17:29 -08003880 rc = clk_prepare_enable(mmfpb_a_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003881 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
3882 return rc;
3883
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003884 return unvote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003885}
Stephen Boydbb600ae2011-08-02 20:11:40 -07003886
3887struct clock_init_data msm8x60_clock_init_data __initdata = {
3888 .table = msm_clocks_8x60,
3889 .size = ARRAY_SIZE(msm_clocks_8x60),
Matt Wagantallb64888f2012-04-02 21:35:07 -07003890 .pre_init = msm8660_clock_pre_init,
3891 .post_init = msm8660_clock_post_init,
Stephen Boydbb600ae2011-08-02 20:11:40 -07003892 .late_init = msm8660_clock_late_init,
3893};