blob: dade0edc5add52cfecf6410456b655ecf04f5775 [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>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026#include <mach/scm-io.h>
27#include <mach/rpm.h>
28#include <mach/rpm-regulator.h>
29
Matt Wagantall33d01f52012-02-23 23:27:44 -080030#include "clock.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070031#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,
Saravana Kannan55e959d2012-10-15 22:16:04 -0700271 VDD_DIG_HIGH,
272 VDD_DIG_NUM
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700273};
274
275static int set_vdd_dig(struct clk_vdd_class *vdd_class, int level)
276{
277 static const int vdd_uv[] = {
278 [VDD_DIG_NONE] = 500000,
279 [VDD_DIG_LOW] = 1000000,
280 [VDD_DIG_NOMINAL] = 1100000,
281 [VDD_DIG_HIGH] = 1200000
282 };
283
284 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8058_S1, RPM_VREG_VOTER3,
285 vdd_uv[level], 1200000, 1);
286}
287
Saravana Kannan55e959d2012-10-15 22:16:04 -0700288static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig, VDD_DIG_NUM);
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700289
290#define VDD_DIG_FMAX_MAP1(l1, f1) \
Saravana Kannan55e959d2012-10-15 22:16:04 -0700291 .vdd_class = &vdd_dig, \
292 .fmax = (unsigned long[VDD_DIG_NUM]) { \
293 [VDD_DIG_##l1] = (f1), \
294 }, \
295 .num_fmax = VDD_DIG_NUM
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700296#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
Saravana Kannan55e959d2012-10-15 22:16:04 -0700297 .vdd_class = &vdd_dig, \
298 .fmax = (unsigned long[VDD_DIG_NUM]) { \
299 [VDD_DIG_##l1] = (f1), \
300 [VDD_DIG_##l2] = (f2), \
301 }, \
302 .num_fmax = VDD_DIG_NUM
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700303#define VDD_DIG_FMAX_MAP3(l1, f1, l2, f2, l3, f3) \
Saravana Kannan55e959d2012-10-15 22:16:04 -0700304 .vdd_class = &vdd_dig, \
305 .fmax = (unsigned long[VDD_DIG_NUM]) { \
306 [VDD_DIG_##l1] = (f1), \
307 [VDD_DIG_##l2] = (f2), \
308 [VDD_DIG_##l3] = (f3), \
309 }, \
310 .num_fmax = VDD_DIG_NUM
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700311
Stephen Boyd72a80352012-01-26 15:57:38 -0800312DEFINE_CLK_RPM_BRANCH(pxo_clk, pxo_a_clk, PXO, 27000000);
313DEFINE_CLK_RPM_BRANCH(cxo_clk, cxo_a_clk, CXO, 19200000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700314
315static struct pll_vote_clk pll8_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700316 .en_reg = BB_PLL_ENA_SC0_REG,
317 .en_mask = BIT(8),
318 .status_reg = BB_PLL8_STATUS_REG,
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800319 .status_mask = BIT(16),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700320 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -0700321 .parent = &pxo_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700322 .dbg_name = "pll8_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800323 .rate = 384000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700324 .ops = &clk_ops_pll_vote,
325 CLK_INIT(pll8_clk.c),
326 },
327};
328
329static struct pll_clk pll2_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700330 .mode_reg = MM_PLL1_MODE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700331 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -0700332 .parent = &pxo_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700333 .dbg_name = "pll2_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800334 .rate = 800000000,
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800335 .ops = &clk_ops_local_pll,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700336 CLK_INIT(pll2_clk.c),
337 },
338};
339
340static struct pll_clk pll3_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700341 .mode_reg = MM_PLL2_MODE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700342 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -0700343 .parent = &pxo_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700344 .dbg_name = "pll3_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800345 .rate = 0, /* TODO: Detect rate dynamically */
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800346 .ops = &clk_ops_local_pll,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700347 CLK_INIT(pll3_clk.c),
348 },
349};
350
Matt Wagantallf82f2942012-01-27 13:56:13 -0800351static int pll4_clk_enable(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700352{
353 struct msm_rpm_iv_pair iv = { MSM_RPM_ID_PLL_4, 1 };
354 return msm_rpm_set_noirq(MSM_RPM_CTX_SET_0, &iv, 1);
355}
356
Matt Wagantallf82f2942012-01-27 13:56:13 -0800357static void pll4_clk_disable(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700358{
359 struct msm_rpm_iv_pair iv = { MSM_RPM_ID_PLL_4, 0 };
360 msm_rpm_set_noirq(MSM_RPM_CTX_SET_0, &iv, 1);
361}
362
Matt Wagantallf82f2942012-01-27 13:56:13 -0800363static bool pll4_clk_is_local(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700364{
365 return false;
366}
367
Matt Wagantall4a36a7e2012-05-14 17:03:21 -0700368static enum handoff pll4_clk_handoff(struct clk *clk)
369{
370 struct msm_rpm_iv_pair iv = { MSM_RPM_ID_PLL_4 };
371 int rc = msm_rpm_get_status(&iv, 1);
372 if (rc < 0 || !iv.value)
373 return HANDOFF_DISABLED_CLK;
374
375 return HANDOFF_ENABLED_CLK;
376}
377
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700378static struct clk_ops clk_ops_pll4 = {
379 .enable = pll4_clk_enable,
380 .disable = pll4_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700381 .is_local = pll4_clk_is_local,
Matt Wagantall4a36a7e2012-05-14 17:03:21 -0700382 .handoff = pll4_clk_handoff,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700383};
384
385static struct fixed_clk pll4_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700386 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -0700387 .parent = &pxo_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700388 .dbg_name = "pll4_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800389 .rate = 540672000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700390 .ops = &clk_ops_pll4,
391 CLK_INIT(pll4_clk.c),
392 },
393};
394
395/*
396 * SoC-specific Set-Rate Functions
397 */
398
399/* Unlike other clocks, the TV rate is adjusted through PLL
400 * re-programming. It is also routed through an MND divider. */
Matt Wagantallf82f2942012-01-27 13:56:13 -0800401static void set_rate_tv(struct rcg_clk *rcg, struct clk_freq_tbl *nf)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700402{
403 struct pll_rate *rate = nf->extra_freq_data;
404 uint32_t pll_mode, pll_config, misc_cc2;
405
406 /* Disable PLL output. */
407 pll_mode = readl_relaxed(MM_PLL2_MODE_REG);
408 pll_mode &= ~BIT(0);
409 writel_relaxed(pll_mode, MM_PLL2_MODE_REG);
410
411 /* Assert active-low PLL reset. */
412 pll_mode &= ~BIT(2);
413 writel_relaxed(pll_mode, MM_PLL2_MODE_REG);
414
415 /* Program L, M and N values. */
416 writel_relaxed(rate->l_val, MM_PLL2_L_VAL_REG);
417 writel_relaxed(rate->m_val, MM_PLL2_M_VAL_REG);
418 writel_relaxed(rate->n_val, MM_PLL2_N_VAL_REG);
419
420 /* Configure MN counter, post-divide, VCO, and i-bits. */
421 pll_config = readl_relaxed(MM_PLL2_CONFIG_REG);
422 pll_config &= ~(BM(22, 20) | BM(18, 0));
423 pll_config |= rate->n_val ? BIT(22) : 0;
424 pll_config |= BVAL(21, 20, rate->post_div);
425 pll_config |= BVAL(17, 16, rate->vco);
426 pll_config |= rate->i_bits;
427 writel_relaxed(pll_config, MM_PLL2_CONFIG_REG);
428
429 /* Configure MND. */
Matt Wagantallf82f2942012-01-27 13:56:13 -0800430 set_rate_mnd(rcg, nf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700431
432 /* Configure hdmi_ref_clk to be equal to the TV clock rate. */
433 misc_cc2 = readl_relaxed(MISC_CC2_REG);
434 misc_cc2 &= ~(BIT(28)|BM(21, 18));
435 misc_cc2 |= (BIT(28)|BVAL(21, 18, (nf->ns_val >> 14) & 0x3));
436 writel_relaxed(misc_cc2, MISC_CC2_REG);
437
438 /* De-assert active-low PLL reset. */
439 pll_mode |= BIT(2);
440 writel_relaxed(pll_mode, MM_PLL2_MODE_REG);
441
442 /* Enable PLL output. */
443 pll_mode |= BIT(0);
444 writel_relaxed(pll_mode, MM_PLL2_MODE_REG);
445}
446
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700447/*
448 * Clock Descriptions
449 */
450
451/* AXI Interfaces */
452static struct branch_clk gmem_axi_clk = {
453 .b = {
454 .ctl_reg = MAXI_EN_REG,
455 .en_mask = BIT(24),
456 .halt_reg = DBG_BUS_VEC_E_REG,
457 .halt_bit = 6,
458 },
459 .c = {
460 .dbg_name = "gmem_axi_clk",
461 .ops = &clk_ops_branch,
462 CLK_INIT(gmem_axi_clk.c),
463 },
464};
465
466static struct branch_clk ijpeg_axi_clk = {
467 .b = {
468 .ctl_reg = MAXI_EN_REG,
469 .en_mask = BIT(21),
470 .reset_reg = SW_RESET_AXI_REG,
471 .reset_mask = BIT(14),
472 .halt_reg = DBG_BUS_VEC_E_REG,
473 .halt_bit = 4,
474 },
475 .c = {
476 .dbg_name = "ijpeg_axi_clk",
477 .ops = &clk_ops_branch,
478 CLK_INIT(ijpeg_axi_clk.c),
479 },
480};
481
482static struct branch_clk imem_axi_clk = {
483 .b = {
484 .ctl_reg = MAXI_EN_REG,
485 .en_mask = BIT(22),
486 .reset_reg = SW_RESET_CORE_REG,
487 .reset_mask = BIT(10),
488 .halt_reg = DBG_BUS_VEC_E_REG,
489 .halt_bit = 7,
Matt Wagantall6bc8f102012-01-20 19:20:44 -0800490 .retain_reg = MAXI_EN2_REG,
491 .retain_mask = BIT(10),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700492 },
493 .c = {
494 .dbg_name = "imem_axi_clk",
495 .ops = &clk_ops_branch,
496 CLK_INIT(imem_axi_clk.c),
497 },
498};
499
500static struct branch_clk jpegd_axi_clk = {
501 .b = {
502 .ctl_reg = MAXI_EN_REG,
503 .en_mask = BIT(25),
504 .halt_reg = DBG_BUS_VEC_E_REG,
505 .halt_bit = 5,
506 },
507 .c = {
508 .dbg_name = "jpegd_axi_clk",
509 .ops = &clk_ops_branch,
510 CLK_INIT(jpegd_axi_clk.c),
511 },
512};
513
514static struct branch_clk mdp_axi_clk = {
515 .b = {
516 .ctl_reg = MAXI_EN_REG,
517 .en_mask = BIT(23),
518 .reset_reg = SW_RESET_AXI_REG,
519 .reset_mask = BIT(13),
520 .halt_reg = DBG_BUS_VEC_E_REG,
521 .halt_bit = 8,
Matt Wagantall6bc8f102012-01-20 19:20:44 -0800522 .retain_reg = MAXI_EN_REG,
523 .retain_mask = BIT(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700524 },
525 .c = {
526 .dbg_name = "mdp_axi_clk",
527 .ops = &clk_ops_branch,
528 CLK_INIT(mdp_axi_clk.c),
529 },
530};
531
532static struct branch_clk vcodec_axi_clk = {
533 .b = {
534 .ctl_reg = MAXI_EN_REG,
535 .en_mask = BIT(19),
536 .reset_reg = SW_RESET_AXI_REG,
537 .reset_mask = BIT(4)|BIT(5),
538 .halt_reg = DBG_BUS_VEC_E_REG,
539 .halt_bit = 3,
540 },
541 .c = {
542 .dbg_name = "vcodec_axi_clk",
543 .ops = &clk_ops_branch,
544 CLK_INIT(vcodec_axi_clk.c),
545 },
546};
547
548static struct branch_clk vfe_axi_clk = {
549 .b = {
550 .ctl_reg = MAXI_EN_REG,
551 .en_mask = BIT(18),
552 .reset_reg = SW_RESET_AXI_REG,
553 .reset_mask = BIT(9),
554 .halt_reg = DBG_BUS_VEC_E_REG,
555 .halt_bit = 0,
556 },
557 .c = {
558 .dbg_name = "vfe_axi_clk",
559 .ops = &clk_ops_branch,
560 CLK_INIT(vfe_axi_clk.c),
561 },
562};
563
564static struct branch_clk rot_axi_clk = {
565 .b = {
Matt Wagantallf63a8892011-06-15 16:44:46 -0700566 .ctl_reg = MAXI_EN2_REG,
567 .en_mask = BIT(24),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700568 .reset_reg = SW_RESET_AXI_REG,
569 .reset_mask = BIT(6),
Matt Wagantallf63a8892011-06-15 16:44:46 -0700570 .halt_reg = DBG_BUS_VEC_E_REG,
571 .halt_bit = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700572 },
573 .c = {
574 .dbg_name = "rot_axi_clk",
Matt Wagantallf63a8892011-06-15 16:44:46 -0700575 .ops = &clk_ops_branch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700576 CLK_INIT(rot_axi_clk.c),
577 },
578};
579
580static struct branch_clk vpe_axi_clk = {
581 .b = {
Matt Wagantallf63a8892011-06-15 16:44:46 -0700582 .ctl_reg = MAXI_EN2_REG,
583 .en_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700584 .reset_reg = SW_RESET_AXI_REG,
585 .reset_mask = BIT(15),
Matt Wagantallf63a8892011-06-15 16:44:46 -0700586 .halt_reg = DBG_BUS_VEC_E_REG,
587 .halt_bit = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700588 },
589 .c = {
590 .dbg_name = "vpe_axi_clk",
Matt Wagantallf63a8892011-06-15 16:44:46 -0700591 .ops = &clk_ops_branch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700592 CLK_INIT(vpe_axi_clk.c),
593 },
594};
595
Matt Wagantallf8032602011-06-15 23:01:56 -0700596static struct branch_clk smi_2x_axi_clk = {
597 .b = {
598 .ctl_reg = MAXI_EN2_REG,
599 .en_mask = BIT(30),
600 .halt_reg = DBG_BUS_VEC_I_REG,
601 .halt_bit = 0,
602 },
603 .c = {
604 .dbg_name = "smi_2x_axi_clk",
Stephen Boyd230a6742012-09-21 14:17:11 -0700605 .ops = &clk_ops_smi_2x,
Matt Wagantallf8032602011-06-15 23:01:56 -0700606 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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001384 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07001385 .parent = &usb_fs1_src_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001386 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001401 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07001402 .parent = &usb_fs1_src_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001403 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001419 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07001420 .parent = &usb_fs2_src_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001421 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001436 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07001437 .parent = &usb_fs2_src_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001438 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001452 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07001453 .parent = &pxo_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001454 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001806 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07001807 .parent = &pxo_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001808 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001837 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07001838 .parent = &pxo_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001839 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002042 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07002043 .parent = &csi_src_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002044 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002059 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07002060 .parent = &csi_src_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002061 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002564 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07002565 .parent = &pixel_mdp_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002566 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002693 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07002694 .parent = &tv_src_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002695 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002708 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07002709 .parent = &tv_src_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002710 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002725 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07002726 .parent = &tv_src_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002727 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002742 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07002743 .parent = &tv_src_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002744 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002932 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07002933 .parent = &vfe_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002934 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002949 .c = {
Saravana Kannan7a6532e2012-10-18 20:51:13 -07002950 .parent = &vfe_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002951 .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),
Matt Wagantallac15a372012-10-10 23:36:20 -07002979 F_AIF_OSR(27000000, pxo, 1, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002980 F_END
2981};
2982
2983#define CLK_AIF_OSR(i, ns, md, h_r) \
2984 struct rcg_clk i##_clk = { \
2985 .b = { \
2986 .ctl_reg = ns, \
2987 .en_mask = BIT(17), \
2988 .reset_reg = ns, \
2989 .reset_mask = BIT(19), \
2990 .halt_reg = h_r, \
2991 .halt_check = ENABLE, \
2992 .halt_bit = 1, \
2993 }, \
2994 .ns_reg = ns, \
2995 .md_reg = md, \
2996 .root_en_mask = BIT(9), \
2997 .ns_mask = (BM(31, 24) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08002998 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002999 .set_rate = set_rate_mnd, \
3000 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003001 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003002 .c = { \
3003 .dbg_name = #i "_clk", \
Stephen Boyd409b8b42012-04-10 12:12:56 -07003004 .ops = &clk_ops_rcg, \
Matt Wagantallac15a372012-10-10 23:36:20 -07003005 VDD_DIG_FMAX_MAP1(LOW, 27000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003006 CLK_INIT(i##_clk.c), \
3007 }, \
3008 }
3009
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003010#define CLK_AIF_BIT(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08003011 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003012 .b = { \
3013 .ctl_reg = ns, \
3014 .en_mask = BIT(15), \
3015 .halt_reg = h_r, \
3016 .halt_check = DELAY, \
3017 }, \
3018 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08003019 .ext_mask = BIT(14), \
3020 .div_offset = 10, \
3021 .max_div = 16, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003022 .c = { \
3023 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08003024 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003025 CLK_INIT(i##_clk.c), \
Stephen Boydd51d5e82012-06-18 18:09:50 -07003026 .rate = ULONG_MAX, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003027 }, \
3028 }
3029
3030static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
3031 LCC_MI2S_STATUS_REG);
3032static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
3033
3034static CLK_AIF_OSR(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
3035 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
3036static CLK_AIF_BIT(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
3037 LCC_CODEC_I2S_MIC_STATUS_REG);
3038
3039static CLK_AIF_OSR(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
3040 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
3041static CLK_AIF_BIT(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
3042 LCC_SPARE_I2S_MIC_STATUS_REG);
3043
3044static CLK_AIF_OSR(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
3045 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
3046static CLK_AIF_BIT(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
3047 LCC_CODEC_I2S_SPKR_STATUS_REG);
3048
3049static CLK_AIF_OSR(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
3050 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
3051static CLK_AIF_BIT(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
3052 LCC_SPARE_I2S_SPKR_STATUS_REG);
3053
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003054#define F_PCM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003055 { \
3056 .freq_hz = f, \
3057 .src_clk = &s##_clk.c, \
3058 .md_val = MD16(m, n), \
3059 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003060 }
3061static struct clk_freq_tbl clk_tbl_pcm[] = {
Stephen Boyd630f3252012-01-31 00:10:08 -08003062 { .ns_val = BIT(10) /* external input */ },
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003063 F_PCM( 512000, pll4, 4, 1, 264),
3064 F_PCM( 768000, pll4, 4, 1, 176),
3065 F_PCM( 1024000, pll4, 4, 1, 132),
3066 F_PCM( 1536000, pll4, 4, 1, 88),
3067 F_PCM( 2048000, pll4, 4, 1, 66),
3068 F_PCM( 3072000, pll4, 4, 1, 44),
3069 F_PCM( 4096000, pll4, 4, 1, 33),
3070 F_PCM( 6144000, pll4, 4, 1, 22),
3071 F_PCM( 8192000, pll4, 2, 1, 33),
3072 F_PCM(12288000, pll4, 4, 1, 11),
3073 F_PCM(24580000, pll4, 2, 1, 11),
Matt Wagantallac15a372012-10-10 23:36:20 -07003074 F_PCM(27000000, pxo, 1, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003075 F_END
3076};
3077
3078static struct rcg_clk pcm_clk = {
3079 .b = {
3080 .ctl_reg = LCC_PCM_NS_REG,
3081 .en_mask = BIT(11),
3082 .reset_reg = LCC_PCM_NS_REG,
3083 .reset_mask = BIT(13),
3084 .halt_reg = LCC_PCM_STATUS_REG,
3085 .halt_check = ENABLE,
3086 .halt_bit = 0,
3087 },
3088 .ns_reg = LCC_PCM_NS_REG,
3089 .md_reg = LCC_PCM_MD_REG,
3090 .root_en_mask = BIT(9),
Stephen Boyd630f3252012-01-31 00:10:08 -08003091 .ns_mask = BM(31, 16) | BIT(10) | BM(6, 0),
Matt Wagantall07c45472012-02-10 23:27:24 -08003092 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003093 .set_rate = set_rate_mnd,
3094 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003095 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003096 .c = {
3097 .dbg_name = "pcm_clk",
Stephen Boyd409b8b42012-04-10 12:12:56 -07003098 .ops = &clk_ops_rcg,
Stephen Boyd23ae06d2012-10-30 10:18:48 -07003099 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003100 CLK_INIT(pcm_clk.c),
Stephen Boydc5492fc2012-06-18 18:47:03 -07003101 .rate = ULONG_MAX,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003102 },
3103};
3104
Matt Wagantall735f01a2011-08-12 12:40:28 -07003105DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
3106DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
3107DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
3108DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
3109DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
3110DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
3111DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
3112DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Matt Wagantallf8032602011-06-15 23:01:56 -07003113DEFINE_CLK_RPM(smi_clk, smi_a_clk, SMI, &smi_2x_axi_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003114
Matt Wagantall35e78fc2012-04-05 14:18:44 -07003115static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c, 0);
3116static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c, 0);
3117static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c, 0);
3118static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c, 0);
3119static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c, 0);
3120static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c, 0);
3121static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c, 0);
3122static DEFINE_CLK_VOTER(dfab_scm_clk, &dfab_clk.c, 0);
Ramesh Masavarapued4e6012012-04-12 16:30:40 -07003123static DEFINE_CLK_VOTER(dfab_qseecom_clk, &dfab_clk.c, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003124
Matt Wagantall42cd12a2012-03-30 18:02:40 -07003125static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c, LONG_MAX);
Matt Wagantall35e78fc2012-04-05 14:18:44 -07003126static DEFINE_CLK_VOTER(ebi1_adm0_clk, &ebi1_clk.c, 0);
3127static DEFINE_CLK_VOTER(ebi1_adm1_clk, &ebi1_clk.c, 0);
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003128static DEFINE_CLK_VOTER(ebi1_acpu_a_clk, &ebi1_a_clk.c, LONG_MAX);
3129static DEFINE_CLK_VOTER(ebi1_msmbus_a_clk, &ebi1_a_clk.c, LONG_MAX);
3130static DEFINE_CLK_VOTER(afab_acpu_a_clk, &afab_a_clk.c, LONG_MAX);
3131static DEFINE_CLK_VOTER(afab_msmbus_a_clk, &afab_a_clk.c, LONG_MAX);
3132
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003133static DEFINE_CLK_MEASURE(sc0_m_clk);
3134static DEFINE_CLK_MEASURE(sc1_m_clk);
3135static DEFINE_CLK_MEASURE(l2_m_clk);
3136
3137#ifdef CONFIG_DEBUG_FS
3138struct measure_sel {
3139 u32 test_vector;
Matt Wagantallf82f2942012-01-27 13:56:13 -08003140 struct clk *c;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003141};
3142
3143static struct measure_sel measure_mux[] = {
3144 { TEST_PER_LS(0x08), &modem_ahb1_p_clk.c },
3145 { TEST_PER_LS(0x09), &modem_ahb2_p_clk.c },
3146 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
3147 { TEST_PER_LS(0x13), &sdc1_clk.c },
3148 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
3149 { TEST_PER_LS(0x15), &sdc2_clk.c },
3150 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
3151 { TEST_PER_LS(0x17), &sdc3_clk.c },
3152 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
3153 { TEST_PER_LS(0x19), &sdc4_clk.c },
3154 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
3155 { TEST_PER_LS(0x1B), &sdc5_clk.c },
Matt Wagantall66cd0932011-09-12 19:04:34 -07003156 { TEST_PER_LS(0x1D), &ebi2_2x_clk.c },
3157 { TEST_PER_LS(0x1E), &ebi2_clk.c },
Matt Wagantall7625a4c2011-11-01 16:17:53 -07003158 { TEST_PER_LS(0x1F), &gp0_clk.c },
3159 { TEST_PER_LS(0x20), &gp1_clk.c },
3160 { TEST_PER_LS(0x21), &gp2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003161 { TEST_PER_LS(0x25), &dfab_clk.c },
3162 { TEST_PER_LS(0x25), &dfab_a_clk.c },
3163 { TEST_PER_LS(0x26), &pmem_clk.c },
3164 { TEST_PER_LS(0x2B), &ppss_p_clk.c },
3165 { TEST_PER_LS(0x33), &cfpb_clk.c },
3166 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
3167 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
3168 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
3169 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
3170 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
3171 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
3172 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
3173 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
3174 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
3175 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
3176 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
3177 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
3178 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
3179 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
3180 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
3181 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
3182 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
3183 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
3184 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
3185 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
3186 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
3187 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
3188 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
3189 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
3190 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
3191 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
3192 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
3193 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
3194 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
3195 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
3196 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
3197 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
3198 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
3199 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
3200 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
3201 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
3202 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
3203 { TEST_PER_LS(0x78), &sfpb_clk.c },
3204 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
3205 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
3206 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
3207 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
3208 { TEST_PER_LS(0x7D), &prng_clk.c },
3209 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
3210 { TEST_PER_LS(0x80), &adm0_p_clk.c },
3211 { TEST_PER_LS(0x81), &adm1_p_clk.c },
3212 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
3213 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
3214 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
3215 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
3216 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
3217 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
3218 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
3219 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
3220 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
3221 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
3222 { TEST_PER_LS(0x93), &ce2_p_clk.c },
3223 { TEST_PER_LS(0x94), &tssc_clk.c },
3224
3225 { TEST_PER_HS(0x07), &afab_clk.c },
3226 { TEST_PER_HS(0x07), &afab_a_clk.c },
3227 { TEST_PER_HS(0x18), &sfab_clk.c },
3228 { TEST_PER_HS(0x18), &sfab_a_clk.c },
3229 { TEST_PER_HS(0x2A), &adm0_clk.c },
3230 { TEST_PER_HS(0x2B), &adm1_clk.c },
3231 { TEST_PER_HS(0x34), &ebi1_clk.c },
3232 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
3233
3234 { TEST_MM_LS(0x00), &dsi_byte_clk.c },
3235 { TEST_MM_LS(0x01), &pixel_lcdc_clk.c },
3236 { TEST_MM_LS(0x04), &pixel_mdp_clk.c },
3237 { TEST_MM_LS(0x06), &amp_p_clk.c },
3238 { TEST_MM_LS(0x07), &csi0_p_clk.c },
3239 { TEST_MM_LS(0x08), &csi1_p_clk.c },
3240 { TEST_MM_LS(0x09), &dsi_m_p_clk.c },
3241 { TEST_MM_LS(0x0A), &dsi_s_p_clk.c },
3242 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
3243 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
3244 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
3245 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
3246 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
3247 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
3248 { TEST_MM_LS(0x12), &imem_p_clk.c },
3249 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
3250 { TEST_MM_LS(0x14), &mdp_p_clk.c },
3251 { TEST_MM_LS(0x16), &rot_p_clk.c },
3252 { TEST_MM_LS(0x18), &smmu_p_clk.c },
3253 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
3254 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
3255 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
3256 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
3257 { TEST_MM_LS(0x1D), &cam_clk.c },
3258 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
3259 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
3260 { TEST_MM_LS(0x21), &tv_dac_clk.c },
3261 { TEST_MM_LS(0x22), &tv_enc_clk.c },
3262 { TEST_MM_LS(0x23), &dsi_esc_clk.c },
3263 { TEST_MM_LS(0x25), &mmfpb_clk.c },
3264 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
3265
3266 { TEST_MM_HS(0x00), &csi0_clk.c },
3267 { TEST_MM_HS(0x01), &csi1_clk.c },
3268 { TEST_MM_HS(0x03), &csi0_vfe_clk.c },
3269 { TEST_MM_HS(0x04), &csi1_vfe_clk.c },
3270 { TEST_MM_HS(0x05), &ijpeg_clk.c },
3271 { TEST_MM_HS(0x06), &vfe_clk.c },
3272 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
3273 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
3274 { TEST_MM_HS(0x09), &gfx3d_clk.c },
3275 { TEST_MM_HS(0x0A), &jpegd_clk.c },
3276 { TEST_MM_HS(0x0B), &vcodec_clk.c },
3277 { TEST_MM_HS(0x0F), &mmfab_clk.c },
3278 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
3279 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
3280 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
3281 { TEST_MM_HS(0x13), &imem_axi_clk.c },
3282 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
3283 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
Matt Wagantallf63a8892011-06-15 16:44:46 -07003284 { TEST_MM_HS(0x16), &rot_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003285 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
3286 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
Matt Wagantallf63a8892011-06-15 16:44:46 -07003287 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003288 { TEST_MM_HS(0x1A), &mdp_clk.c },
3289 { TEST_MM_HS(0x1B), &rot_clk.c },
3290 { TEST_MM_HS(0x1C), &vpe_clk.c },
3291 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
3292 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
Matt Wagantallf8032602011-06-15 23:01:56 -07003293 { TEST_MM_HS(0x24), &smi_2x_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003294
3295 { TEST_MM_HS2X(0x24), &smi_clk.c },
3296 { TEST_MM_HS2X(0x24), &smi_a_clk.c },
3297
3298 { TEST_LPA(0x0A), &mi2s_osr_clk.c },
3299 { TEST_LPA(0x0B), &mi2s_bit_clk.c },
3300 { TEST_LPA(0x0C), &codec_i2s_mic_osr_clk.c },
3301 { TEST_LPA(0x0D), &codec_i2s_mic_bit_clk.c },
3302 { TEST_LPA(0x0E), &codec_i2s_spkr_osr_clk.c },
3303 { TEST_LPA(0x0F), &codec_i2s_spkr_bit_clk.c },
3304 { TEST_LPA(0x10), &spare_i2s_mic_osr_clk.c },
3305 { TEST_LPA(0x11), &spare_i2s_mic_bit_clk.c },
3306 { TEST_LPA(0x12), &spare_i2s_spkr_osr_clk.c },
3307 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
3308 { TEST_LPA(0x14), &pcm_clk.c },
3309
3310 { TEST_SC(0x40), &sc0_m_clk },
3311 { TEST_SC(0x41), &sc1_m_clk },
3312 { TEST_SC(0x42), &l2_m_clk },
3313};
3314
Matt Wagantallf82f2942012-01-27 13:56:13 -08003315static struct measure_sel *find_measure_sel(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003316{
3317 int i;
3318
3319 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
Matt Wagantallf82f2942012-01-27 13:56:13 -08003320 if (measure_mux[i].c == c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003321 return &measure_mux[i];
3322 return NULL;
3323}
3324
3325static int measure_clk_set_parent(struct clk *c, struct clk *parent)
3326{
3327 int ret = 0;
3328 u32 clk_sel;
3329 struct measure_sel *p;
Matt Wagantallf82f2942012-01-27 13:56:13 -08003330 struct measure_clk *measure = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003331 unsigned long flags;
3332
3333 if (!parent)
3334 return -EINVAL;
3335
3336 p = find_measure_sel(parent);
3337 if (!p)
3338 return -EINVAL;
3339
3340 spin_lock_irqsave(&local_clock_reg_lock, flags);
3341
3342 /*
3343 * Program the test vector, measurement period (sample_ticks)
3344 * and scaling factors (multiplier, divider).
3345 */
3346 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantallf82f2942012-01-27 13:56:13 -08003347 measure->sample_ticks = 0x10000;
3348 measure->multiplier = 1;
3349 measure->divider = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003350 switch (p->test_vector >> TEST_TYPE_SHIFT) {
3351 case TEST_TYPE_PER_LS:
3352 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
3353 break;
3354 case TEST_TYPE_PER_HS:
3355 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
3356 break;
3357 case TEST_TYPE_MM_LS:
3358 writel_relaxed(0x4030D97, CLK_TEST_REG);
3359 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
3360 break;
3361 case TEST_TYPE_MM_HS2X:
Matt Wagantallf82f2942012-01-27 13:56:13 -08003362 measure->divider = 2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003363 case TEST_TYPE_MM_HS:
3364 writel_relaxed(0x402B800, CLK_TEST_REG);
3365 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
3366 break;
3367 case TEST_TYPE_LPA:
3368 writel_relaxed(0x4030D98, CLK_TEST_REG);
3369 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
3370 LCC_CLK_LS_DEBUG_CFG_REG);
3371 break;
3372 case TEST_TYPE_SC:
3373 writel_relaxed(0x5020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
Matt Wagantallf82f2942012-01-27 13:56:13 -08003374 measure->sample_ticks = 0x4000;
3375 measure->multiplier = 2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003376 break;
3377 default:
3378 ret = -EPERM;
3379 }
3380 /* Make sure test vector is set before starting measurements. */
3381 mb();
3382
3383 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3384
3385 return ret;
3386}
3387
3388/* Sample clock for 'ticks' reference clock ticks. */
3389static u32 run_measurement(unsigned ticks)
3390{
3391 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003392 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
3393
3394 /* Wait for timer to become ready. */
3395 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
3396 cpu_relax();
3397
3398 /* Run measurement and wait for completion. */
3399 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
3400 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
3401 cpu_relax();
3402
3403 /* Stop counters. */
3404 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
3405
3406 /* Return measured ticks. */
3407 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
3408}
3409
3410/* Perform a hardware rate measurement for a given clock.
3411 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003412static unsigned long measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003413{
3414 unsigned long flags;
3415 u32 pdm_reg_backup, ringosc_reg_backup;
3416 u64 raw_count_short, raw_count_full;
Matt Wagantallf82f2942012-01-27 13:56:13 -08003417 struct measure_clk *measure = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003418 unsigned ret;
3419
3420 spin_lock_irqsave(&local_clock_reg_lock, flags);
3421
3422 /* Enable CXO/4 and RINGOSC branch and root. */
3423 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
3424 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
3425 writel_relaxed(0x2898, PDM_CLK_NS_REG);
3426 writel_relaxed(0xA00, RINGOSC_NS_REG);
3427
3428 /*
3429 * The ring oscillator counter will not reset if the measured clock
3430 * is not running. To detect this, run a short measurement before
3431 * the full measurement. If the raw results of the two are the same
3432 * then the clock must be off.
3433 */
3434
3435 /* Run a short measurement. (~1 ms) */
3436 raw_count_short = run_measurement(0x1000);
3437 /* Run a full measurement. (~14 ms) */
Matt Wagantallf82f2942012-01-27 13:56:13 -08003438 raw_count_full = run_measurement(measure->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003439
3440 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
3441 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
3442
3443 /* Return 0 if the clock is off. */
3444 if (raw_count_full == raw_count_short)
3445 ret = 0;
3446 else {
3447 /* Compute rate in Hz. */
3448 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantallf82f2942012-01-27 13:56:13 -08003449 do_div(raw_count_full, (((measure->sample_ticks * 10) + 35)
3450 * measure->divider));
3451 ret = (raw_count_full * measure->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003452 }
3453
3454 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
3455 writel_relaxed(0x3CF8, PLLTEST_PAD_CFG_REG);
3456 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3457
3458 return ret;
3459}
3460#else /* !CONFIG_DEBUG_FS */
Matt Wagantallf82f2942012-01-27 13:56:13 -08003461static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003462{
3463 return -EINVAL;
3464}
3465
Matt Wagantallf82f2942012-01-27 13:56:13 -08003466static unsigned long measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003467{
3468 return 0;
3469}
3470#endif /* CONFIG_DEBUG_FS */
3471
Matt Wagantallae053222012-05-14 19:42:07 -07003472static struct clk_ops clk_ops_measure = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003473 .set_parent = measure_clk_set_parent,
3474 .get_rate = measure_clk_get_rate,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003475};
3476
3477static struct measure_clk measure_clk = {
3478 .c = {
3479 .dbg_name = "measure_clk",
Matt Wagantallae053222012-05-14 19:42:07 -07003480 .ops = &clk_ops_measure,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003481 CLK_INIT(measure_clk.c),
3482 },
3483 .multiplier = 1,
3484 .divider = 1,
3485};
3486
3487static struct clk_lookup msm_clocks_8x60[] = {
Stephen Boyd72a80352012-01-26 15:57:38 -08003488 CLK_LOOKUP("xo", cxo_clk.c, ""),
3489 CLK_LOOKUP("xo", cxo_a_clk.c, ""),
3490 CLK_LOOKUP("xo", pxo_a_clk.c, ""),
Stephen Boyd67036532012-01-26 15:43:51 -08003491 CLK_LOOKUP("xo", pxo_clk.c, "pil_modem"),
David Collinsa7d23532012-08-02 10:48:16 -07003492 CLK_LOOKUP("vref_buff", cxo_clk.c, "rpm-regulator"),
Stephen Boyd3acc9e42011-09-28 16:46:40 -07003493 CLK_LOOKUP("pll4", pll4_clk.c, "pil_qdsp6v3"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003494 CLK_LOOKUP("measure", measure_clk.c, "debug"),
3495
Matt Wagantalld75f1312012-05-23 16:17:35 -07003496 CLK_LOOKUP("bus_clk", afab_clk.c, ""),
3497 CLK_LOOKUP("bus_clk", afab_a_clk.c, ""),
3498 CLK_LOOKUP("bus_clk", cfpb_clk.c, ""),
3499 CLK_LOOKUP("bus_clk", cfpb_a_clk.c, ""),
3500 CLK_LOOKUP("bus_clk", dfab_clk.c, ""),
3501 CLK_LOOKUP("bus_clk", dfab_a_clk.c, ""),
3502 CLK_LOOKUP("mem_clk", ebi1_clk.c, ""),
3503 CLK_LOOKUP("mem_clk", ebi1_a_clk.c, ""),
3504 CLK_LOOKUP("bus_clk", mmfab_clk.c, ""),
3505 CLK_LOOKUP("bus_clk", mmfab_a_clk.c, ""),
3506 CLK_LOOKUP("bus_clk", mmfpb_clk.c, ""),
3507 CLK_LOOKUP("bus_clk", mmfpb_a_clk.c, ""),
3508 CLK_LOOKUP("bus_clk", sfab_clk.c, ""),
3509 CLK_LOOKUP("bus_clk", sfab_a_clk.c, ""),
3510 CLK_LOOKUP("bus_clk", sfpb_clk.c, ""),
3511 CLK_LOOKUP("bus_clk", sfpb_a_clk.c, ""),
3512 CLK_LOOKUP("mem_clk", smi_clk.c, ""),
3513 CLK_LOOKUP("mem_clk", smi_a_clk.c, ""),
3514
Matt Wagantallb2710b82011-11-16 19:55:17 -08003515 CLK_LOOKUP("bus_clk", afab_clk.c, "msm_apps_fab"),
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003516 CLK_LOOKUP("bus_a_clk", afab_msmbus_a_clk.c, "msm_apps_fab"),
Matt Wagantallb2710b82011-11-16 19:55:17 -08003517 CLK_LOOKUP("bus_clk", sfab_clk.c, "msm_sys_fab"),
3518 CLK_LOOKUP("bus_a_clk", sfab_a_clk.c, "msm_sys_fab"),
3519 CLK_LOOKUP("bus_clk", sfpb_clk.c, "msm_sys_fpb"),
3520 CLK_LOOKUP("bus_a_clk", sfpb_a_clk.c, "msm_sys_fpb"),
3521 CLK_LOOKUP("bus_clk", mmfab_clk.c, "msm_mm_fab"),
3522 CLK_LOOKUP("bus_a_clk", mmfab_a_clk.c, "msm_mm_fab"),
3523 CLK_LOOKUP("bus_clk", cfpb_clk.c, "msm_cpss_fpb"),
3524 CLK_LOOKUP("bus_a_clk", cfpb_a_clk.c, "msm_cpss_fpb"),
3525 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003526 CLK_LOOKUP("mem_a_clk", ebi1_msmbus_a_clk.c, "msm_bus"),
Matt Wagantallb2710b82011-11-16 19:55:17 -08003527 CLK_LOOKUP("smi_clk", smi_clk.c, "msm_bus"),
3528 CLK_LOOKUP("smi_a_clk", smi_a_clk.c, "msm_bus"),
Stephen Boyd279196e2012-07-12 16:09:02 -07003529 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8x60"),
Matt Wagantallb2710b82011-11-16 19:55:17 -08003530
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003531 CLK_LOOKUP("core_clk", gp0_clk.c, ""),
3532 CLK_LOOKUP("core_clk", gp1_clk.c, ""),
3533 CLK_LOOKUP("core_clk", gp2_clk.c, ""),
3534 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, ""),
3535 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003536 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, "msm_serial_hsl.2"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003537 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, ""),
3538 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003539 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003540 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, ""),
3541 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003542 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, "msm_serial_hsl.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003543 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, ""),
3544 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003545 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, "msm_serial_hsl.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003546 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003547 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07003548 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.0"),
3549 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003550 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, ""),
3551 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07003552 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, "qup_i2c.4"),
3553 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, "qup_i2c.3"),
3554 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, "qup_i2c.2"),
3555 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "spi_qsd.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003556 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, ""),
Wentao Xu4a053042011-10-03 14:06:34 -04003557 CLK_LOOKUP("gsbi_qup_clk", gsbi12_qup_clk.c, "msm_dsps"),
Matt Wagantallac294852011-08-17 15:44:58 -07003558 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.5"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003559 CLK_LOOKUP("core_clk", pdm_clk.c, ""),
Wentao Xu4a053042011-10-03 14:06:34 -04003560 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_dsps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07003561 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07003562 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
3563 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
3564 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
3565 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
3566 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07003567 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, "msm_tsif.0"),
3568 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, "msm_tsif.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003569 CLK_LOOKUP("core_clk", tssc_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08003570 CLK_LOOKUP("alt_core_clk", usb_hs1_xcvr_clk.c, "msm_otg"),
3571 CLK_LOOKUP("phy_clk", usb_phy0_clk.c, "msm_otg"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003572 CLK_LOOKUP("alt_core_clk", usb_fs1_xcvr_clk.c, ""),
3573 CLK_LOOKUP("sys_clk", usb_fs1_sys_clk.c, ""),
3574 CLK_LOOKUP("src_clk", usb_fs1_src_clk.c, ""),
3575 CLK_LOOKUP("alt_core_clk", usb_fs2_xcvr_clk.c, ""),
3576 CLK_LOOKUP("sys_clk", usb_fs2_sys_clk.c, ""),
3577 CLK_LOOKUP("src_clk", usb_fs2_src_clk.c, ""),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07003578 CLK_LOOKUP("core_clk", ce2_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07003579 CLK_LOOKUP("core_clk", ce2_p_clk.c, "qcrypto.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003580 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003581 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003582 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "msm_serial_hsl.2"),
Matt Wagantallac294852011-08-17 15:44:58 -07003583 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.0"),
3584 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003585 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003586 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003587 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, "qup_i2c.4"),
3588 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, "qup_i2c.3"),
Matt Wagantalle2522372011-08-17 14:52:21 -07003589 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, "msm_serial_hsl.1"),
Matt Wagantallac294852011-08-17 15:44:58 -07003590 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, "qup_i2c.2"),
3591 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "spi_qsd.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003592 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, ""),
3593 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07003594 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "msm_serial_hsl.0"),
Matt Wagantallac294852011-08-17 15:44:58 -07003595 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.5"),
Matt Wagantall5bb16ca2012-04-19 11:34:01 -07003596 CLK_LOOKUP("iface_clk", ppss_p_clk.c, "msm_dsps"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07003597 CLK_LOOKUP("iface_clk", tsif_p_clk.c, "msm_tsif.0"),
3598 CLK_LOOKUP("iface_clk", tsif_p_clk.c, "msm_tsif.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003599 CLK_LOOKUP("iface_clk", usb_fs1_p_clk.c, ""),
3600 CLK_LOOKUP("iface_clk", usb_fs2_p_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08003601 CLK_LOOKUP("iface_clk", usb_hs1_p_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07003602 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
3603 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
3604 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
3605 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
3606 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003607 CLK_LOOKUP("mem_clk", ebi2_2x_clk.c, ""),
Terence Hampsonb36a38c2011-09-19 19:10:40 -04003608 CLK_LOOKUP("mem_clk", ebi2_clk.c, "msm_ebi2"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07003609 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov.0"),
3610 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov.0"),
3611 CLK_LOOKUP("core_clk", adm1_clk.c, "msm_dmov.1"),
3612 CLK_LOOKUP("iface_clk", adm1_p_clk.c, "msm_dmov.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003613 CLK_LOOKUP("iface_clk", modem_ahb1_p_clk.c, ""),
3614 CLK_LOOKUP("iface_clk", modem_ahb2_p_clk.c, ""),
3615 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, ""),
3616 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, ""),
3617 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, ""),
3618 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003619 CLK_LOOKUP("cam_clk", cam_clk.c, NULL),
3620 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
3621 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov7692.0"),
3622 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov9726.0"),
Kevin Chan3be11612012-03-22 20:05:40 -07003623 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csic.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003624 CLK_LOOKUP("csi_src_clk", csi_src_clk.c, NULL),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003625 CLK_LOOKUP("byte_clk", dsi_byte_clk.c, "mipi_dsi.1"),
3626 CLK_LOOKUP("esc_clk", dsi_esc_clk.c, "mipi_dsi.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003627 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003628 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003629 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07003630 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003631 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003632 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
Matt Wagantallf45cd362012-05-03 21:09:44 -07003633 CLK_LOOKUP("core_clk", ijpeg_clk.c, "msm_gemini.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003634 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07003635 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003636 CLK_LOOKUP("core_clk", mdp_clk.c, "mdp.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003637 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003638 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "mdp.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003639 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003640 CLK_LOOKUP("lcdc_clk", pixel_lcdc_clk.c, "lcdc.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003641 CLK_LOOKUP("pixel_lcdc_clk", pixel_lcdc_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003642 CLK_LOOKUP("mdp_clk", pixel_mdp_clk.c, "lcdc.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003643 CLK_LOOKUP("pixel_mdp_clk", pixel_mdp_clk.c, "footswitch-8x60.4"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07003644 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003645 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003646 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
3647 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07003648 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003649 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003650 CLK_LOOKUP("mdp_clk", mdp_tv_clk.c, "dtv.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003651 CLK_LOOKUP("tv_clk", mdp_tv_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003652 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, "dtv.0"),
3653 CLK_LOOKUP("src_clk", tv_src_clk.c, "dtv.0"),
Matt Wagantallb82a5132011-12-12 22:26:41 -08003654 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, "footswitch-8x60.4"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07003655 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003656 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003657 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003658 CLK_LOOKUP("csi_vfe_clk", csi0_vfe_clk.c, NULL),
3659 CLK_LOOKUP("csi_vfe_clk", csi1_vfe_clk.c, "msm_camera_ov7692.0"),
3660 CLK_LOOKUP("csi_vfe_clk", csi1_vfe_clk.c, "msm_camera_ov9726.0"),
Kevin Chan3be11612012-03-22 20:05:40 -07003661 CLK_LOOKUP("csi_vfe_clk", csi1_vfe_clk.c, "msm_csic.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003662 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003663 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Matt Wagantall49722712011-08-17 18:50:53 -07003664 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
3665 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003666 CLK_LOOKUP("mem_clk", imem_axi_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003667 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
3668 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
3669 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
3670 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003671 CLK_LOOKUP("arb_clk", amp_p_clk.c, "mipi_dsi.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003672 CLK_LOOKUP("csi_pclk", csi0_p_clk.c, NULL),
3673 CLK_LOOKUP("csi_pclk", csi1_p_clk.c, "msm_camera_ov7692.0"),
3674 CLK_LOOKUP("csi_pclk", csi1_p_clk.c, "msm_camera_ov9726.0"),
Kevin Chan3be11612012-03-22 20:05:40 -07003675 CLK_LOOKUP("csi_pclk", csi1_p_clk.c, "msm_csic.1"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003676 CLK_LOOKUP("master_iface_clk", dsi_m_p_clk.c, "mipi_dsi.1"),
3677 CLK_LOOKUP("slave_iface_clk", dsi_s_p_clk.c, "mipi_dsi.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003678 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003679 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003680 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07003681 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003682 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003683 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07003684 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
3685 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Matt Wagantallf45cd362012-05-03 21:09:44 -07003686 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "msm_gemini.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003687 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07003688 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07003689 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, "kgsl-3d0.0"),
Ravishangar Kalyanam1b064f52012-03-15 18:17:54 -07003690 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "mdp.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003691 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Olav Haugan95d24162012-12-05 14:47:47 -08003692 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.0"),
3693 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.1"),
3694 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.2"),
3695 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.3"),
3696 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.4"),
3697 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.5"),
3698 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.6"),
3699 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.7"),
3700 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.8"),
3701 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.9"),
3702 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.10"),
3703 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu.11"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07003704 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003705 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003706 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07003707 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07003708 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003709 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003710 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003711 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07003712 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003713 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
3714 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
3715 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
3716 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
3717 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
3718 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
3719 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
3720 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
3721 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
3722 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
3723 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
Matt Wagantalle604d712011-10-21 15:38:18 -07003724 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
Matt Wagantall21903c02012-04-17 16:39:58 -07003725 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
Matt Wagantalle604d712011-10-21 15:38:18 -07003726 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
3727 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
Matt Wagantall21903c02012-04-17 16:39:58 -07003728 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07003729 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
3730 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
3731 CLK_LOOKUP("core_clk", vcodec_axi_clk.c, "msm_iommu.7"),
3732 CLK_LOOKUP("core_clk", vcodec_axi_clk.c, "msm_iommu.8"),
3733 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
3734 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
3735 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003736
Riaz Rahaman966922b2012-02-21 10:48:01 -08003737 CLK_LOOKUP("mdp_iommu_clk", mdp_axi_clk.c, "msm_vidc.0"),
3738 CLK_LOOKUP("rot_iommu_clk", rot_axi_clk.c, "msm_vidc.0"),
3739 CLK_LOOKUP("vcodec_iommu0_clk", vcodec_axi_clk.c, "msm_vidc.0"),
3740 CLK_LOOKUP("vcodec_iommu1_clk", vcodec_axi_clk.c, "msm_vidc.0"),
3741 CLK_LOOKUP("smmu_iface_clk", smmu_p_clk.c, "msm_vidc.0"),
Riaz Rahamandd18ebf2012-06-27 16:06:34 +05303742 CLK_LOOKUP("core_clk", vcodec_axi_clk.c, "pil_vidc"),
3743 CLK_LOOKUP("smmu_iface_clk", smmu_p_clk.c, "pil_vidc"),
Riaz Rahaman966922b2012-02-21 10:48:01 -08003744
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003745 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
Manu Gautam5143b252012-01-05 19:25:23 -08003746 CLK_LOOKUP("core_clk", dfab_usb_hs_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07003747 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
3748 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
3749 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
3750 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
3751 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Stephen Boydef5d1c42011-12-15 20:47:14 -08003752 CLK_LOOKUP("bus_clk", dfab_scm_clk.c, "scm"),
Ramesh Masavarapued4e6012012-04-12 16:30:40 -07003753 CLK_LOOKUP("bus_clk", dfab_qseecom_clk.c, "qseecom"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003754
Matt Wagantalle1a86062011-08-18 17:46:10 -07003755 CLK_LOOKUP("mem_clk", ebi1_adm0_clk.c, "msm_dmov.0"),
3756 CLK_LOOKUP("mem_clk", ebi1_adm1_clk.c, "msm_dmov.1"),
Matt Wagantall33bac7e2012-05-22 14:59:05 -07003757 CLK_LOOKUP("mem_clk", ebi1_acpu_a_clk.c, ""),
3758 CLK_LOOKUP("bus_clk", afab_acpu_a_clk.c, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003759
Matt Wagantallc00f95d2012-01-05 14:22:45 -08003760 CLK_LOOKUP("sc0_mclk", sc0_m_clk, ""),
3761 CLK_LOOKUP("sc1_mclk", sc1_m_clk, ""),
3762 CLK_LOOKUP("l2_mclk", l2_m_clk, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003763};
3764
3765/*
3766 * Miscellaneous clock register initializations
3767 */
3768
3769/* Read, modify, then write-back a register. */
3770static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
3771{
3772 uint32_t regval = readl_relaxed(reg);
3773 regval &= ~mask;
3774 regval |= val;
3775 writel_relaxed(regval, reg);
3776}
3777
Matt Wagantallb64888f2012-04-02 21:35:07 -07003778static void __init msm8660_clock_pre_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003779{
Matt Wagantallb64888f2012-04-02 21:35:07 -07003780 vote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
3781
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003782 /* Setup MM_PLL2 (PLL3), but turn it off. Rate set by set_rate_tv(). */
3783 rmwreg(0, MM_PLL2_MODE_REG, BIT(0)); /* Disable output */
3784 /* Set ref, bypass, assert reset, disable output, disable test mode */
3785 writel_relaxed(0, MM_PLL2_MODE_REG); /* PXO */
3786 writel_relaxed(0x00800000, MM_PLL2_CONFIG_REG); /* Enable main out. */
3787
3788 /* The clock driver doesn't use SC1's voting register to control
3789 * HW-voteable clocks. Clear its bits so that disabling bits in the
3790 * SC0 register will cause the corresponding clocks to be disabled. */
3791 rmwreg(BIT(12)|BIT(11), SC0_U_CLK_BRANCH_ENA_VOTE_REG, BM(12, 11));
3792 writel_relaxed(BIT(12)|BIT(11), SC1_U_CLK_BRANCH_ENA_VOTE_REG);
3793 /* Let sc_aclk and sc_clk halt when both Scorpions are collapsed. */
3794 writel_relaxed(BIT(12)|BIT(11), SC0_U_CLK_SLEEP_ENA_VOTE_REG);
3795 writel_relaxed(BIT(12)|BIT(11), SC1_U_CLK_SLEEP_ENA_VOTE_REG);
3796
3797 /* Deassert MM SW_RESET_ALL signal. */
3798 writel_relaxed(0, SW_RESET_ALL_REG);
3799
3800 /* Initialize MM AHB registers: Enable the FPB clock and disable HW
3801 * gating for all clocks. Also set VFE_AHB's FORCE_CORE_ON bit to
3802 * prevent its memory from being collapsed when the clock is halted.
3803 * The sleep and wake-up delays are set to safe values. */
Matt Wagantall30011d22011-07-25 20:32:04 -07003804 rmwreg(0x00000003, AHB_EN_REG, 0x6C000003);
3805 writel_relaxed(0x000007F9, AHB_EN2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003806
3807 /* Deassert all locally-owned MM AHB resets. */
3808 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
3809
3810 /* Initialize MM AXI registers: Enable HW gating for all clocks that
3811 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
3812 * delays to safe values. */
Matt Wagantall30011d22011-07-25 20:32:04 -07003813 rmwreg(0x100207F9, MAXI_EN_REG, 0x1803FFFF);
3814 rmwreg(0x7027FCFF, MAXI_EN2_REG, 0x7A3FFFFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003815 writel_relaxed(0x3FE7FCFF, MAXI_EN3_REG);
3816 writel_relaxed(0x000001D8, SAXI_EN_REG);
3817
3818 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
3819 * memories retain state even when not clocked. Also, set sleep and
3820 * wake-up delays to safe values. */
Matt Wagantall30011d22011-07-25 20:32:04 -07003821 rmwreg(0x00000000, CSI_CC_REG, 0x00000018);
3822 rmwreg(0x00000400, MISC_CC_REG, 0x017C0400);
3823 rmwreg(0x000007FD, MISC_CC2_REG, 0x70C2E7FF);
3824 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
3825 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
3826 rmwreg(0x80FF0000, GFX3D_CC_REG, 0xE0FF0010);
3827 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0018);
3828 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0018);
3829 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
3830 rmwreg(0x80FF0000, PIXEL_CC_REG, 0xE1FF0010);
3831 rmwreg(0x000004FF, PIXEL_CC2_REG, 0x000007FF);
3832 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
3833 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
3834 rmwreg(0x000004FF, TV_CC2_REG, 0x000027FF);
3835 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
3836 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FFC010);
3837 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003838
3839 /* De-assert MM AXI resets to all hardware blocks. */
3840 writel_relaxed(0, SW_RESET_AXI_REG);
3841
3842 /* Deassert all MM core resets. */
3843 writel_relaxed(0, SW_RESET_CORE_REG);
3844
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003845 /* Enable TSSC and PDM PXO sources. */
3846 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
3847 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
3848 /* Set the dsi_byte_clk src to the DSI PHY PLL,
3849 * dsi_esc_clk to PXO/2, and the hdmi_app_clk src to PXO */
3850 rmwreg(0x400001, MISC_CC2_REG, 0x424003);
Stephen Boyd842a1f62012-04-26 19:07:38 -07003851
3852 if ((readl_relaxed(PRNG_CLK_NS_REG) & 0x7F) == 0x2B)
3853 prng_clk.freq_tbl = clk_tbl_prng_64;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003854}
3855
Matt Wagantallb64888f2012-04-02 21:35:07 -07003856static void __init msm8660_clock_post_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003857{
Stephen Boyd72a80352012-01-26 15:57:38 -08003858 /* Keep PXO on whenever APPS cpu is active */
3859 clk_prepare_enable(&pxo_a_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003860
Matt Wagantalle655cd72012-04-09 10:15:03 -07003861 /* Reset 3D core while clocked to ensure it resets completely. */
3862 clk_set_rate(&gfx3d_clk.c, 27000000);
3863 clk_prepare_enable(&gfx3d_clk.c);
3864 clk_reset(&gfx3d_clk.c, CLK_RESET_ASSERT);
3865 udelay(5);
3866 clk_reset(&gfx3d_clk.c, CLK_RESET_DEASSERT);
3867 clk_disable_unprepare(&gfx3d_clk.c);
3868
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003869 /* Initialize rates for clocks that only support one. */
3870 clk_set_rate(&pdm_clk.c, 27000000);
Stephen Boyd842a1f62012-04-26 19:07:38 -07003871 clk_set_rate(&prng_clk.c, prng_clk.freq_tbl->freq_hz);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003872 clk_set_rate(&mdp_vsync_clk.c, 27000000);
3873 clk_set_rate(&tsif_ref_clk.c, 105000);
3874 clk_set_rate(&tssc_clk.c, 27000000);
3875 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
3876 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
3877 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
3878
3879 /* The halt status bits for PDM and TSSC may be incorrect at boot.
3880 * Toggle these clocks on and off to refresh them. */
Stephen Boyd409b8b42012-04-10 12:12:56 -07003881 clk_prepare_enable(&pdm_clk.c);
3882 clk_disable_unprepare(&pdm_clk.c);
3883 clk_prepare_enable(&tssc_clk.c);
3884 clk_disable_unprepare(&tssc_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003885}
3886
Stephen Boydbb600ae2011-08-02 20:11:40 -07003887static int __init msm8660_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003888{
3889 int rc;
3890
3891 /* Vote for MMFPB to be at least 64MHz when an Apps CPU is active. */
Stephen Boyd279196e2012-07-12 16:09:02 -07003892 struct clk *mmfpb_a_clk = clk_get_sys("clock-8x60", "mmfpb_a_clk");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003893 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
3894 PTR_ERR(mmfpb_a_clk)))
3895 return PTR_ERR(mmfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08003896 rc = clk_set_rate(mmfpb_a_clk, 64000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003897 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
3898 return rc;
Stephen Boyde334aeb2012-01-24 12:17:29 -08003899 rc = clk_prepare_enable(mmfpb_a_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003900 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
3901 return rc;
3902
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003903 return unvote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003904}
Stephen Boydbb600ae2011-08-02 20:11:40 -07003905
3906struct clock_init_data msm8x60_clock_init_data __initdata = {
3907 .table = msm_clocks_8x60,
3908 .size = ARRAY_SIZE(msm_clocks_8x60),
Matt Wagantallb64888f2012-04-02 21:35:07 -07003909 .pre_init = msm8660_clock_pre_init,
3910 .post_init = msm8660_clock_post_init,
Stephen Boydbb600ae2011-08-02 20:11:40 -07003911 .late_init = msm8660_clock_late_init,
3912};