blob: 1cca688c90ebc8a86823e5cf998bd1f1fb71ec02 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/err.h>
16#include <linux/ctype.h>
17#include <linux/bitops.h>
18#include <linux/io.h>
19#include <linux/spinlock.h>
20#include <linux/delay.h>
21#include <linux/clk.h>
22
23#include <asm/clkdev.h>
24#include <asm/mach-types.h>
25
26#include <mach/msm_iomap.h>
27#include <mach/clk.h>
28#include <mach/rpm-regulator.h>
29#include <mach/msm_xo.h>
30
31#include "clock-local.h"
32#include "clock-rpm.h"
33#include "clock-voter.h"
34#include "clock-dss-8960.h"
35#include "devices.h"
36
37#define REG(off) (MSM_CLK_CTL_BASE + (off))
38#define REG_MM(off) (MSM_MMSS_CLK_CTL_BASE + (off))
39#define REG_LPA(off) (MSM_LPASS_CLK_CTL_BASE + (off))
40
41/* Peripheral clock registers. */
42#define CE1_HCLK_CTL_REG REG(0x2720)
43#define CE1_CORE_CLK_CTL_REG REG(0x2724)
44#define DMA_BAM_HCLK_CTL REG(0x25C0)
45#define CLK_HALT_CFPB_STATEA_REG REG(0x2FCC)
46#define CLK_HALT_CFPB_STATEB_REG REG(0x2FD0)
47#define CLK_HALT_CFPB_STATEC_REG REG(0x2FD4)
48#define CLK_HALT_DFAB_STATE_REG REG(0x2FC8)
49#define CLK_HALT_MSS_SMPSS_MISC_STATE_REG REG(0x2FDC)
50#define CLK_HALT_SFPB_MISC_STATE_REG REG(0x2FD8)
51#define CLK_TEST_REG REG(0x2FA0)
52#define GSBIn_HCLK_CTL_REG(n) REG(0x29C0+(0x20*((n)-1)))
53#define GSBIn_QUP_APPS_MD_REG(n) REG(0x29C8+(0x20*((n)-1)))
54#define GSBIn_QUP_APPS_NS_REG(n) REG(0x29CC+(0x20*((n)-1)))
55#define GSBIn_RESET_REG(n) REG(0x29DC+(0x20*((n)-1)))
56#define GSBIn_UART_APPS_MD_REG(n) REG(0x29D0+(0x20*((n)-1)))
57#define GSBIn_UART_APPS_NS_REG(n) REG(0x29D4+(0x20*((n)-1)))
58#define LPASS_XO_SRC_CLK_CTL_REG REG(0x2EC0)
59#define PDM_CLK_NS_REG REG(0x2CC0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060#define BB_PLL_ENA_SC0_REG REG(0x34C0)
61#define BB_PLL0_STATUS_REG REG(0x30D8)
62#define BB_PLL5_STATUS_REG REG(0x30F8)
63#define BB_PLL6_STATUS_REG REG(0x3118)
64#define BB_PLL7_STATUS_REG REG(0x3138)
65#define BB_PLL8_L_VAL_REG REG(0x3144)
66#define BB_PLL8_M_VAL_REG REG(0x3148)
67#define BB_PLL8_MODE_REG REG(0x3140)
68#define BB_PLL8_N_VAL_REG REG(0x314C)
69#define BB_PLL8_STATUS_REG REG(0x3158)
70#define BB_PLL8_CONFIG_REG REG(0x3154)
71#define BB_PLL8_TEST_CTL_REG REG(0x3150)
72#define PLLTEST_PAD_CFG_REG REG(0x2FA4)
73#define PMEM_ACLK_CTL_REG REG(0x25A0)
74#define RINGOSC_NS_REG REG(0x2DC0)
75#define RINGOSC_STATUS_REG REG(0x2DCC)
76#define RINGOSC_TCXO_CTL_REG REG(0x2DC4)
77#define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080)
78#define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1)))
79#define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1)))
80#define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1)))
81#define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1)))
82#define SLIMBUS_XO_SRC_CLK_CTL_REG REG(0x2628)
83#define TSIF_HCLK_CTL_REG REG(0x2700)
84#define TSIF_REF_CLK_MD_REG REG(0x270C)
85#define TSIF_REF_CLK_NS_REG REG(0x2710)
86#define TSSC_CLK_CTL_REG REG(0x2CA0)
87#define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1)))
88#define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1)))
89#define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1)))
90#define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1)))
91#define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1)))
92#define USB_HS1_HCLK_CTL_REG REG(0x2900)
93#define USB_HS1_RESET_REG REG(0x2910)
94#define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908)
95#define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C)
96#define USB_PHY0_RESET_REG REG(0x2E20)
97
98/* Multimedia clock registers. */
99#define AHB_EN_REG REG_MM(0x0008)
100#define AHB_EN2_REG REG_MM(0x0038)
101#define AHB_NS_REG REG_MM(0x0004)
102#define AXI_NS_REG REG_MM(0x0014)
103#define CAMCLKn_NS_REG(n) REG_MM(0x0148+(0x14*(n)))
104#define CAMCLKn_CC_REG(n) REG_MM(0x0140+(0x14*(n)))
105#define CAMCLKn_MD_REG(n) REG_MM(0x0144+(0x14*(n)))
106#define CSI0_NS_REG REG_MM(0x0048)
107#define CSI0_CC_REG REG_MM(0x0040)
108#define CSI0_MD_REG REG_MM(0x0044)
109#define CSI1_NS_REG REG_MM(0x0010)
110#define CSI1_CC_REG REG_MM(0x0024)
111#define CSI1_MD_REG REG_MM(0x0028)
112#define CSIPHYTIMER_CC_REG REG_MM(0x0160)
113#define CSIPHYTIMER_MD_REG REG_MM(0x0164)
114#define CSIPHYTIMER_NS_REG REG_MM(0x0168)
115#define DSI1_BYTE_NS_REG REG_MM(0x00B0)
116#define DSI1_BYTE_CC_REG REG_MM(0x0090)
117#define DSI2_BYTE_NS_REG REG_MM(0x00BC)
118#define DSI2_BYTE_CC_REG REG_MM(0x00B4)
119#define DSI1_ESC_NS_REG REG_MM(0x011C)
120#define DSI1_ESC_CC_REG REG_MM(0x00CC)
121#define DSI2_ESC_NS_REG REG_MM(0x0150)
122#define DSI2_ESC_CC_REG REG_MM(0x013C)
123#define DSI_PIXEL_CC_REG REG_MM(0x0130)
124#define DSI2_PIXEL_CC_REG REG_MM(0x0094)
125#define DBG_BUS_VEC_A_REG REG_MM(0x01C8)
126#define DBG_BUS_VEC_B_REG REG_MM(0x01CC)
127#define DBG_BUS_VEC_C_REG REG_MM(0x01D0)
128#define DBG_BUS_VEC_D_REG REG_MM(0x01D4)
129#define DBG_BUS_VEC_E_REG REG_MM(0x01D8)
130#define DBG_BUS_VEC_F_REG REG_MM(0x01DC)
131#define DBG_BUS_VEC_G_REG REG_MM(0x01E0)
132#define DBG_BUS_VEC_H_REG REG_MM(0x01E4)
133#define DBG_BUS_VEC_I_REG REG_MM(0x01E8)
134#define DBG_CFG_REG_HS_REG REG_MM(0x01B4)
135#define DBG_CFG_REG_LS_REG REG_MM(0x01B8)
136#define GFX2D0_CC_REG REG_MM(0x0060)
137#define GFX2D0_MD0_REG REG_MM(0x0064)
138#define GFX2D0_MD1_REG REG_MM(0x0068)
139#define GFX2D0_NS_REG REG_MM(0x0070)
140#define GFX2D1_CC_REG REG_MM(0x0074)
141#define GFX2D1_MD0_REG REG_MM(0x0078)
142#define GFX2D1_MD1_REG REG_MM(0x006C)
143#define GFX2D1_NS_REG REG_MM(0x007C)
144#define GFX3D_CC_REG REG_MM(0x0080)
145#define GFX3D_MD0_REG REG_MM(0x0084)
146#define GFX3D_MD1_REG REG_MM(0x0088)
147#define GFX3D_NS_REG REG_MM(0x008C)
148#define IJPEG_CC_REG REG_MM(0x0098)
149#define IJPEG_MD_REG REG_MM(0x009C)
150#define IJPEG_NS_REG REG_MM(0x00A0)
151#define JPEGD_CC_REG REG_MM(0x00A4)
152#define JPEGD_NS_REG REG_MM(0x00AC)
153#define MAXI_EN_REG REG_MM(0x0018)
154#define MAXI_EN2_REG REG_MM(0x0020)
155#define MAXI_EN3_REG REG_MM(0x002C)
156#define MAXI_EN4_REG REG_MM(0x0114)
157#define MDP_CC_REG REG_MM(0x00C0)
158#define MDP_LUT_CC_REG REG_MM(0x016C)
159#define MDP_MD0_REG REG_MM(0x00C4)
160#define MDP_MD1_REG REG_MM(0x00C8)
161#define MDP_NS_REG REG_MM(0x00D0)
162#define MISC_CC_REG REG_MM(0x0058)
163#define MISC_CC2_REG REG_MM(0x005C)
164#define MM_PLL1_MODE_REG REG_MM(0x031C)
165#define ROT_CC_REG REG_MM(0x00E0)
166#define ROT_NS_REG REG_MM(0x00E8)
167#define SAXI_EN_REG REG_MM(0x0030)
168#define SW_RESET_AHB_REG REG_MM(0x020C)
169#define SW_RESET_AHB2_REG REG_MM(0x0200)
170#define SW_RESET_ALL_REG REG_MM(0x0204)
171#define SW_RESET_AXI_REG REG_MM(0x0208)
172#define SW_RESET_CORE_REG REG_MM(0x0210)
173#define TV_CC_REG REG_MM(0x00EC)
174#define TV_CC2_REG REG_MM(0x0124)
175#define TV_MD_REG REG_MM(0x00F0)
176#define TV_NS_REG REG_MM(0x00F4)
177#define VCODEC_CC_REG REG_MM(0x00F8)
178#define VCODEC_MD0_REG REG_MM(0x00FC)
179#define VCODEC_MD1_REG REG_MM(0x0128)
180#define VCODEC_NS_REG REG_MM(0x0100)
181#define VFE_CC_REG REG_MM(0x0104)
182#define VFE_MD_REG REG_MM(0x0108)
183#define VFE_NS_REG REG_MM(0x010C)
184#define VPE_CC_REG REG_MM(0x0110)
185#define VPE_NS_REG REG_MM(0x0118)
186
187/* Low-power Audio clock registers. */
188#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
189#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
190#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
191#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
192#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
193#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
194#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
195#define LCC_MI2S_MD_REG REG_LPA(0x004C)
196#define LCC_MI2S_NS_REG REG_LPA(0x0048)
197#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
198#define LCC_PCM_MD_REG REG_LPA(0x0058)
199#define LCC_PCM_NS_REG REG_LPA(0x0054)
200#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
201#define LCC_PLL0_STATUS_REG REG_LPA(0x0018)
202#define LCC_PRI_PLL_CLK_CTL_REG REG_LPA(0x00C4)
203#define LCC_PXO_SRC_CLK_CTL_REG REG_LPA(0x00B4)
204#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
205#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
206#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
207#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
208#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
209#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
210#define LCC_SLIMBUS_NS_REG REG_LPA(0x00CC)
211#define LCC_SLIMBUS_MD_REG REG_LPA(0x00D0)
212#define LCC_SLIMBUS_STATUS_REG REG_LPA(0x00D4)
213#define LCC_AHBEX_BRANCH_CTL_REG REG_LPA(0x00E4)
214
215/* MUX source input identifiers. */
216#define pxo_to_bb_mux 0
217#define cxo_to_bb_mux pxo_to_bb_mux
218#define pll0_to_bb_mux 2
219#define pll8_to_bb_mux 3
220#define pll6_to_bb_mux 4
221#define gnd_to_bb_mux 5
222#define pxo_to_mm_mux 0
223#define pll1_to_mm_mux 1
224#define pll2_to_mm_mux 1
225#define pll8_to_mm_mux 2
226#define pll0_to_mm_mux 3
227#define gnd_to_mm_mux 4
228#define hdmi_pll_to_mm_mux 3
229#define cxo_to_xo_mux 0
230#define pxo_to_xo_mux 1
231#define gnd_to_xo_mux 3
232#define pxo_to_lpa_mux 0
233#define cxo_to_lpa_mux 1
234#define pll4_to_lpa_mux 2
235#define gnd_to_lpa_mux 6
236
237/* Test Vector Macros */
238#define TEST_TYPE_PER_LS 1
239#define TEST_TYPE_PER_HS 2
240#define TEST_TYPE_MM_LS 3
241#define TEST_TYPE_MM_HS 4
242#define TEST_TYPE_LPA 5
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
252#define MN_MODE_DUAL_EDGE 0x2
253
254/* MD Registers */
255#define MD4(m_lsb, m, n_lsb, n) \
256 (BVAL((m_lsb+3), m_lsb, m) | BVAL((n_lsb+3), n_lsb, ~(n)))
257#define MD8(m_lsb, m, n_lsb, n) \
258 (BVAL((m_lsb+7), m_lsb, m) | BVAL((n_lsb+7), n_lsb, ~(n)))
259#define MD16(m, n) (BVAL(31, 16, m) | BVAL(15, 0, ~(n)))
260
261/* NS Registers */
262#define NS(n_msb, n_lsb, n, m, mde_lsb, d_msb, d_lsb, d, s_msb, s_lsb, s) \
263 (BVAL(n_msb, n_lsb, ~(n-m)) \
264 | (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n)) \
265 | BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
266
267#define NS_MM(n_msb, n_lsb, n, m, d_msb, d_lsb, d, s_msb, s_lsb, s) \
268 (BVAL(n_msb, n_lsb, ~(n-m)) | BVAL(d_msb, d_lsb, (d-1)) \
269 | BVAL(s_msb, s_lsb, s))
270
271#define NS_DIVSRC(d_msb , d_lsb, d, s_msb, s_lsb, s) \
272 (BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
273
274#define NS_DIV(d_msb , d_lsb, d) \
275 BVAL(d_msb, d_lsb, (d-1))
276
277#define NS_SRC_SEL(s_msb, s_lsb, s) \
278 BVAL(s_msb, s_lsb, s)
279
280#define NS_MND_BANKED4(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
281 (BVAL((n0_lsb+3), n0_lsb, ~(n-m)) \
282 | BVAL((n1_lsb+3), n1_lsb, ~(n-m)) \
283 | BVAL((s0_lsb+2), s0_lsb, s) \
284 | BVAL((s1_lsb+2), s1_lsb, s))
285
286#define NS_MND_BANKED8(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
287 (BVAL((n0_lsb+7), n0_lsb, ~(n-m)) \
288 | BVAL((n1_lsb+7), n1_lsb, ~(n-m)) \
289 | BVAL((s0_lsb+2), s0_lsb, s) \
290 | BVAL((s1_lsb+2), s1_lsb, s))
291
292#define NS_DIVSRC_BANKED(d0_msb, d0_lsb, d1_msb, d1_lsb, d, \
293 s0_msb, s0_lsb, s1_msb, s1_lsb, s) \
294 (BVAL(d0_msb, d0_lsb, (d-1)) | BVAL(d1_msb, d1_lsb, (d-1)) \
295 | BVAL(s0_msb, s0_lsb, s) \
296 | BVAL(s1_msb, s1_lsb, s))
297
298/* CC Registers */
299#define CC(mde_lsb, n) (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n))
300#define CC_BANKED(mde0_lsb, mde1_lsb, n) \
301 ((BVAL((mde0_lsb+1), mde0_lsb, MN_MODE_DUAL_EDGE) \
302 | BVAL((mde1_lsb+1), mde1_lsb, MN_MODE_DUAL_EDGE)) \
303 * !!(n))
304
305struct pll_rate {
306 const uint32_t l_val;
307 const uint32_t m_val;
308 const uint32_t n_val;
309 const uint32_t vco;
310 const uint32_t post_div;
311 const uint32_t i_bits;
312};
313#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
314
315/*
316 * Clock Descriptions
317 */
318
319static struct msm_xo_voter *xo_pxo, *xo_cxo;
320
321static int pxo_clk_enable(struct clk *clk)
322{
323 return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON);
324}
325
326static void pxo_clk_disable(struct clk *clk)
327{
328 msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF);
329}
330
331static struct clk_ops clk_ops_pxo = {
332 .enable = pxo_clk_enable,
333 .disable = pxo_clk_disable,
334 .get_rate = fixed_clk_get_rate,
335 .is_local = local_clk_is_local,
336};
337
338static struct fixed_clk pxo_clk = {
339 .rate = 27000000,
340 .c = {
341 .dbg_name = "pxo_clk",
342 .ops = &clk_ops_pxo,
343 CLK_INIT(pxo_clk.c),
344 },
345};
346
347static int cxo_clk_enable(struct clk *clk)
348{
349 return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON);
350}
351
352static void cxo_clk_disable(struct clk *clk)
353{
354 msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF);
355}
356
357static struct clk_ops clk_ops_cxo = {
358 .enable = cxo_clk_enable,
359 .disable = cxo_clk_disable,
360 .get_rate = fixed_clk_get_rate,
361 .is_local = local_clk_is_local,
362};
363
364static struct fixed_clk cxo_clk = {
365 .rate = 19200000,
366 .c = {
367 .dbg_name = "cxo_clk",
368 .ops = &clk_ops_cxo,
369 CLK_INIT(cxo_clk.c),
370 },
371};
372
373static struct pll_clk pll2_clk = {
374 .rate = 800000000,
375 .mode_reg = MM_PLL1_MODE_REG,
376 .parent = &pxo_clk.c,
377 .c = {
378 .dbg_name = "pll2_clk",
379 .ops = &clk_ops_pll,
380 CLK_INIT(pll2_clk.c),
381 },
382};
383
384static struct pll_vote_clk pll4_clk = {
385 .rate = 393216000,
386 .en_reg = BB_PLL_ENA_SC0_REG,
387 .en_mask = BIT(4),
388 .status_reg = LCC_PLL0_STATUS_REG,
389 .parent = &pxo_clk.c,
390 .c = {
391 .dbg_name = "pll4_clk",
392 .ops = &clk_ops_pll_vote,
393 CLK_INIT(pll4_clk.c),
394 },
395};
396
397static struct pll_vote_clk pll8_clk = {
398 .rate = 384000000,
399 .en_reg = BB_PLL_ENA_SC0_REG,
400 .en_mask = BIT(8),
401 .status_reg = BB_PLL8_STATUS_REG,
402 .parent = &pxo_clk.c,
403 .c = {
404 .dbg_name = "pll8_clk",
405 .ops = &clk_ops_pll_vote,
406 CLK_INIT(pll8_clk.c),
407 },
408};
409
410/*
411 * SoC-specific functions required by clock-local driver
412 */
413
414/* Update the sys_vdd voltage given a level. */
415static int msm8960_update_sys_vdd(enum sys_vdd_level level)
416{
417 static const int vdd_uv[] = {
418 [NONE...LOW] = 945000,
419 [NOMINAL] = 1050000,
420 [HIGH] = 1150000,
421 };
422
423 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
424 vdd_uv[level], vdd_uv[HIGH], 1);
425}
426
427static int soc_clk_reset(struct clk *clk, enum clk_reset_action action)
428{
429 return branch_reset(&to_rcg_clk(clk)->b, action);
430}
431
432static struct clk_ops soc_clk_ops_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700433 .enable = rcg_clk_enable,
434 .disable = rcg_clk_disable,
435 .auto_off = rcg_clk_auto_off,
436 .set_rate = rcg_clk_set_rate,
437 .set_min_rate = rcg_clk_set_min_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700438 .get_rate = rcg_clk_get_rate,
439 .list_rate = rcg_clk_list_rate,
440 .is_enabled = rcg_clk_is_enabled,
441 .round_rate = rcg_clk_round_rate,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700442 .reset = soc_clk_reset,
443 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700444 .get_parent = rcg_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700445};
446
447static struct clk_ops clk_ops_branch = {
448 .enable = branch_clk_enable,
449 .disable = branch_clk_disable,
450 .auto_off = branch_clk_auto_off,
451 .is_enabled = branch_clk_is_enabled,
452 .reset = branch_clk_reset,
453 .is_local = local_clk_is_local,
454 .get_parent = branch_clk_get_parent,
455 .set_parent = branch_clk_set_parent,
456};
457
458static struct clk_ops clk_ops_reset = {
459 .reset = branch_clk_reset,
460 .is_local = local_clk_is_local,
461};
462
463/* AXI Interfaces */
464static struct branch_clk gmem_axi_clk = {
465 .b = {
466 .ctl_reg = MAXI_EN_REG,
467 .en_mask = BIT(24),
468 .halt_reg = DBG_BUS_VEC_E_REG,
469 .halt_bit = 6,
470 },
471 .c = {
472 .dbg_name = "gmem_axi_clk",
473 .ops = &clk_ops_branch,
474 CLK_INIT(gmem_axi_clk.c),
475 },
476};
477
478static struct branch_clk ijpeg_axi_clk = {
479 .b = {
480 .ctl_reg = MAXI_EN_REG,
481 .en_mask = BIT(21),
482 .reset_reg = SW_RESET_AXI_REG,
483 .reset_mask = BIT(14),
484 .halt_reg = DBG_BUS_VEC_E_REG,
485 .halt_bit = 4,
486 },
487 .c = {
488 .dbg_name = "ijpeg_axi_clk",
489 .ops = &clk_ops_branch,
490 CLK_INIT(ijpeg_axi_clk.c),
491 },
492};
493
494static struct branch_clk imem_axi_clk = {
495 .b = {
496 .ctl_reg = MAXI_EN_REG,
497 .en_mask = BIT(22),
498 .reset_reg = SW_RESET_CORE_REG,
499 .reset_mask = BIT(10),
500 .halt_reg = DBG_BUS_VEC_E_REG,
501 .halt_bit = 7,
502 },
503 .c = {
504 .dbg_name = "imem_axi_clk",
505 .ops = &clk_ops_branch,
506 CLK_INIT(imem_axi_clk.c),
507 },
508};
509
510static struct branch_clk jpegd_axi_clk = {
511 .b = {
512 .ctl_reg = MAXI_EN_REG,
513 .en_mask = BIT(25),
514 .halt_reg = DBG_BUS_VEC_E_REG,
515 .halt_bit = 5,
516 },
517 .c = {
518 .dbg_name = "jpegd_axi_clk",
519 .ops = &clk_ops_branch,
520 CLK_INIT(jpegd_axi_clk.c),
521 },
522};
523
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700524static struct branch_clk vcodec_axi_b_clk = {
525 .b = {
526 .ctl_reg = MAXI_EN4_REG,
527 .en_mask = BIT(23),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700528 .halt_reg = DBG_BUS_VEC_I_REG,
529 .halt_bit = 25,
530 },
531 .c = {
532 .dbg_name = "vcodec_axi_b_clk",
533 .ops = &clk_ops_branch,
534 CLK_INIT(vcodec_axi_b_clk.c),
535 },
536};
537
Matt Wagantall91f42702011-07-14 12:01:15 -0700538static struct branch_clk vcodec_axi_a_clk = {
539 .b = {
540 .ctl_reg = MAXI_EN4_REG,
541 .en_mask = BIT(25),
Matt Wagantall91f42702011-07-14 12:01:15 -0700542 .halt_reg = DBG_BUS_VEC_I_REG,
543 .halt_bit = 26,
544 },
545 .depends = &vcodec_axi_b_clk.c,
546 .c = {
547 .dbg_name = "vcodec_axi_a_clk",
548 .ops = &clk_ops_branch,
549 CLK_INIT(vcodec_axi_a_clk.c),
550 },
551};
552
553static struct branch_clk vcodec_axi_clk = {
554 .b = {
555 .ctl_reg = MAXI_EN_REG,
556 .en_mask = BIT(19),
557 .reset_reg = SW_RESET_AXI_REG,
Matt Wagantallfe2ee052011-07-14 13:33:44 -0700558 .reset_mask = BIT(4)|BIT(5)|BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700559 .halt_reg = DBG_BUS_VEC_E_REG,
560 .halt_bit = 3,
561 },
562 .depends = &vcodec_axi_a_clk.c,
563 .c = {
564 .dbg_name = "vcodec_axi_clk",
565 .ops = &clk_ops_branch,
566 CLK_INIT(vcodec_axi_clk.c),
567 },
568};
569
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700570static struct branch_clk vfe_axi_clk = {
571 .b = {
572 .ctl_reg = MAXI_EN_REG,
573 .en_mask = BIT(18),
574 .reset_reg = SW_RESET_AXI_REG,
575 .reset_mask = BIT(9),
576 .halt_reg = DBG_BUS_VEC_E_REG,
577 .halt_bit = 0,
578 },
579 .c = {
580 .dbg_name = "vfe_axi_clk",
581 .ops = &clk_ops_branch,
582 CLK_INIT(vfe_axi_clk.c),
583 },
584};
585
586static struct branch_clk mdp_axi_clk = {
587 .b = {
588 .ctl_reg = MAXI_EN_REG,
589 .en_mask = BIT(23),
590 .reset_reg = SW_RESET_AXI_REG,
591 .reset_mask = BIT(13),
592 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700593 .halt_bit = 8,
594 },
595 .c = {
596 .dbg_name = "mdp_axi_clk",
597 .ops = &clk_ops_branch,
598 CLK_INIT(mdp_axi_clk.c),
599 },
600};
601
602static struct branch_clk rot_axi_clk = {
603 .b = {
604 .ctl_reg = MAXI_EN2_REG,
605 .en_mask = BIT(24),
606 .reset_reg = SW_RESET_AXI_REG,
607 .reset_mask = BIT(6),
608 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700609 .halt_bit = 2,
610 },
611 .c = {
612 .dbg_name = "rot_axi_clk",
613 .ops = &clk_ops_branch,
614 CLK_INIT(rot_axi_clk.c),
615 },
616};
617
618static struct branch_clk vpe_axi_clk = {
619 .b = {
620 .ctl_reg = MAXI_EN2_REG,
621 .en_mask = BIT(26),
622 .reset_reg = SW_RESET_AXI_REG,
623 .reset_mask = BIT(15),
624 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700625 .halt_bit = 1,
626 },
627 .c = {
628 .dbg_name = "vpe_axi_clk",
629 .ops = &clk_ops_branch,
630 CLK_INIT(vpe_axi_clk.c),
631 },
632};
633
634/* AHB Interfaces */
635static struct branch_clk amp_p_clk = {
636 .b = {
637 .ctl_reg = AHB_EN_REG,
638 .en_mask = BIT(24),
639 .halt_reg = DBG_BUS_VEC_F_REG,
640 .halt_bit = 18,
641 },
642 .c = {
643 .dbg_name = "amp_p_clk",
644 .ops = &clk_ops_branch,
645 CLK_INIT(amp_p_clk.c),
646 },
647};
648
649static struct branch_clk csi0_p_clk = {
650 .b = {
651 .ctl_reg = AHB_EN_REG,
652 .en_mask = BIT(7),
653 .reset_reg = SW_RESET_AHB_REG,
654 .reset_mask = BIT(17),
655 .halt_reg = DBG_BUS_VEC_F_REG,
656 .halt_bit = 16,
657 },
658 .c = {
659 .dbg_name = "csi0_p_clk",
660 .ops = &clk_ops_branch,
661 CLK_INIT(csi0_p_clk.c),
662 },
663};
664
665static struct branch_clk dsi1_m_p_clk = {
666 .b = {
667 .ctl_reg = AHB_EN_REG,
668 .en_mask = BIT(9),
669 .reset_reg = SW_RESET_AHB_REG,
670 .reset_mask = BIT(6),
671 .halt_reg = DBG_BUS_VEC_F_REG,
672 .halt_bit = 19,
673 },
674 .c = {
675 .dbg_name = "dsi1_m_p_clk",
676 .ops = &clk_ops_branch,
677 CLK_INIT(dsi1_m_p_clk.c),
678 },
679};
680
681static struct branch_clk dsi1_s_p_clk = {
682 .b = {
683 .ctl_reg = AHB_EN_REG,
684 .en_mask = BIT(18),
685 .reset_reg = SW_RESET_AHB_REG,
686 .reset_mask = BIT(5),
687 .halt_reg = DBG_BUS_VEC_F_REG,
688 .halt_bit = 21,
689 },
690 .c = {
691 .dbg_name = "dsi1_s_p_clk",
692 .ops = &clk_ops_branch,
693 CLK_INIT(dsi1_s_p_clk.c),
694 },
695};
696
697static struct branch_clk dsi2_m_p_clk = {
698 .b = {
699 .ctl_reg = AHB_EN_REG,
700 .en_mask = BIT(17),
701 .reset_reg = SW_RESET_AHB2_REG,
702 .reset_mask = BIT(1),
703 .halt_reg = DBG_BUS_VEC_E_REG,
704 .halt_bit = 18,
705 },
706 .c = {
707 .dbg_name = "dsi2_m_p_clk",
708 .ops = &clk_ops_branch,
709 CLK_INIT(dsi2_m_p_clk.c),
710 },
711};
712
713static struct branch_clk dsi2_s_p_clk = {
714 .b = {
715 .ctl_reg = AHB_EN_REG,
716 .en_mask = BIT(22),
717 .reset_reg = SW_RESET_AHB2_REG,
718 .reset_mask = BIT(0),
719 .halt_reg = DBG_BUS_VEC_F_REG,
720 .halt_bit = 20,
721 },
722 .c = {
723 .dbg_name = "dsi2_s_p_clk",
724 .ops = &clk_ops_branch,
725 CLK_INIT(dsi2_s_p_clk.c),
726 },
727};
728
729static struct branch_clk gfx2d0_p_clk = {
730 .b = {
731 .ctl_reg = AHB_EN_REG,
732 .en_mask = BIT(19),
733 .reset_reg = SW_RESET_AHB_REG,
734 .reset_mask = BIT(12),
735 .halt_reg = DBG_BUS_VEC_F_REG,
736 .halt_bit = 2,
737 },
738 .c = {
739 .dbg_name = "gfx2d0_p_clk",
740 .ops = &clk_ops_branch,
741 CLK_INIT(gfx2d0_p_clk.c),
742 },
743};
744
745static struct branch_clk gfx2d1_p_clk = {
746 .b = {
747 .ctl_reg = AHB_EN_REG,
748 .en_mask = BIT(2),
749 .reset_reg = SW_RESET_AHB_REG,
750 .reset_mask = BIT(11),
751 .halt_reg = DBG_BUS_VEC_F_REG,
752 .halt_bit = 3,
753 },
754 .c = {
755 .dbg_name = "gfx2d1_p_clk",
756 .ops = &clk_ops_branch,
757 CLK_INIT(gfx2d1_p_clk.c),
758 },
759};
760
761static struct branch_clk gfx3d_p_clk = {
762 .b = {
763 .ctl_reg = AHB_EN_REG,
764 .en_mask = BIT(3),
765 .reset_reg = SW_RESET_AHB_REG,
766 .reset_mask = BIT(10),
767 .halt_reg = DBG_BUS_VEC_F_REG,
768 .halt_bit = 4,
769 },
770 .c = {
771 .dbg_name = "gfx3d_p_clk",
772 .ops = &clk_ops_branch,
773 CLK_INIT(gfx3d_p_clk.c),
774 },
775};
776
777static struct branch_clk hdmi_m_p_clk = {
778 .b = {
779 .ctl_reg = AHB_EN_REG,
780 .en_mask = BIT(14),
781 .reset_reg = SW_RESET_AHB_REG,
782 .reset_mask = BIT(9),
783 .halt_reg = DBG_BUS_VEC_F_REG,
784 .halt_bit = 5,
785 },
786 .c = {
787 .dbg_name = "hdmi_m_p_clk",
788 .ops = &clk_ops_branch,
789 CLK_INIT(hdmi_m_p_clk.c),
790 },
791};
792
793static struct branch_clk hdmi_s_p_clk = {
794 .b = {
795 .ctl_reg = AHB_EN_REG,
796 .en_mask = BIT(4),
797 .reset_reg = SW_RESET_AHB_REG,
798 .reset_mask = BIT(9),
799 .halt_reg = DBG_BUS_VEC_F_REG,
800 .halt_bit = 6,
801 },
802 .c = {
803 .dbg_name = "hdmi_s_p_clk",
804 .ops = &clk_ops_branch,
805 CLK_INIT(hdmi_s_p_clk.c),
806 },
807};
808
809static struct branch_clk ijpeg_p_clk = {
810 .b = {
811 .ctl_reg = AHB_EN_REG,
812 .en_mask = BIT(5),
813 .reset_reg = SW_RESET_AHB_REG,
814 .reset_mask = BIT(7),
815 .halt_reg = DBG_BUS_VEC_F_REG,
816 .halt_bit = 9,
817 },
818 .c = {
819 .dbg_name = "ijpeg_p_clk",
820 .ops = &clk_ops_branch,
821 CLK_INIT(ijpeg_p_clk.c),
822 },
823};
824
825static struct branch_clk imem_p_clk = {
826 .b = {
827 .ctl_reg = AHB_EN_REG,
828 .en_mask = BIT(6),
829 .reset_reg = SW_RESET_AHB_REG,
830 .reset_mask = BIT(8),
831 .halt_reg = DBG_BUS_VEC_F_REG,
832 .halt_bit = 10,
833 },
834 .c = {
835 .dbg_name = "imem_p_clk",
836 .ops = &clk_ops_branch,
837 CLK_INIT(imem_p_clk.c),
838 },
839};
840
841static struct branch_clk jpegd_p_clk = {
842 .b = {
843 .ctl_reg = AHB_EN_REG,
844 .en_mask = BIT(21),
845 .reset_reg = SW_RESET_AHB_REG,
846 .reset_mask = BIT(4),
847 .halt_reg = DBG_BUS_VEC_F_REG,
848 .halt_bit = 7,
849 },
850 .c = {
851 .dbg_name = "jpegd_p_clk",
852 .ops = &clk_ops_branch,
853 CLK_INIT(jpegd_p_clk.c),
854 },
855};
856
857static struct branch_clk mdp_p_clk = {
858 .b = {
859 .ctl_reg = AHB_EN_REG,
860 .en_mask = BIT(10),
861 .reset_reg = SW_RESET_AHB_REG,
862 .reset_mask = BIT(3),
863 .halt_reg = DBG_BUS_VEC_F_REG,
864 .halt_bit = 11,
865 },
866 .c = {
867 .dbg_name = "mdp_p_clk",
868 .ops = &clk_ops_branch,
869 CLK_INIT(mdp_p_clk.c),
870 },
871};
872
873static struct branch_clk rot_p_clk = {
874 .b = {
875 .ctl_reg = AHB_EN_REG,
876 .en_mask = BIT(12),
877 .reset_reg = SW_RESET_AHB_REG,
878 .reset_mask = BIT(2),
879 .halt_reg = DBG_BUS_VEC_F_REG,
880 .halt_bit = 13,
881 },
882 .c = {
883 .dbg_name = "rot_p_clk",
884 .ops = &clk_ops_branch,
885 CLK_INIT(rot_p_clk.c),
886 },
887};
888
889static struct branch_clk smmu_p_clk = {
890 .b = {
891 .ctl_reg = AHB_EN_REG,
892 .en_mask = BIT(15),
893 .halt_reg = DBG_BUS_VEC_F_REG,
894 .halt_bit = 22,
895 },
896 .c = {
897 .dbg_name = "smmu_p_clk",
898 .ops = &clk_ops_branch,
899 CLK_INIT(smmu_p_clk.c),
900 },
901};
902
903static struct branch_clk tv_enc_p_clk = {
904 .b = {
905 .ctl_reg = AHB_EN_REG,
906 .en_mask = BIT(25),
907 .reset_reg = SW_RESET_AHB_REG,
908 .reset_mask = BIT(15),
909 .halt_reg = DBG_BUS_VEC_F_REG,
910 .halt_bit = 23,
911 },
912 .c = {
913 .dbg_name = "tv_enc_p_clk",
914 .ops = &clk_ops_branch,
915 CLK_INIT(tv_enc_p_clk.c),
916 },
917};
918
919static struct branch_clk vcodec_p_clk = {
920 .b = {
921 .ctl_reg = AHB_EN_REG,
922 .en_mask = BIT(11),
923 .reset_reg = SW_RESET_AHB_REG,
924 .reset_mask = BIT(1),
925 .halt_reg = DBG_BUS_VEC_F_REG,
926 .halt_bit = 12,
927 },
928 .c = {
929 .dbg_name = "vcodec_p_clk",
930 .ops = &clk_ops_branch,
931 CLK_INIT(vcodec_p_clk.c),
932 },
933};
934
935static struct branch_clk vfe_p_clk = {
936 .b = {
937 .ctl_reg = AHB_EN_REG,
938 .en_mask = BIT(13),
939 .reset_reg = SW_RESET_AHB_REG,
940 .reset_mask = BIT(0),
941 .halt_reg = DBG_BUS_VEC_F_REG,
942 .halt_bit = 14,
943 },
944 .c = {
945 .dbg_name = "vfe_p_clk",
946 .ops = &clk_ops_branch,
947 CLK_INIT(vfe_p_clk.c),
948 },
949};
950
951static struct branch_clk vpe_p_clk = {
952 .b = {
953 .ctl_reg = AHB_EN_REG,
954 .en_mask = BIT(16),
955 .reset_reg = SW_RESET_AHB_REG,
956 .reset_mask = BIT(14),
957 .halt_reg = DBG_BUS_VEC_F_REG,
958 .halt_bit = 15,
959 },
960 .c = {
961 .dbg_name = "vpe_p_clk",
962 .ops = &clk_ops_branch,
963 CLK_INIT(vpe_p_clk.c),
964 },
965};
966
967/*
968 * Peripheral Clocks
969 */
970#define CLK_GSBI_UART(i, n, h_r, h_b) \
971 struct rcg_clk i##_clk = { \
972 .b = { \
973 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
974 .en_mask = BIT(9), \
975 .reset_reg = GSBIn_RESET_REG(n), \
976 .reset_mask = BIT(0), \
977 .halt_reg = h_r, \
978 .halt_bit = h_b, \
979 }, \
980 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
981 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
982 .root_en_mask = BIT(11), \
983 .ns_mask = (BM(31, 16) | BM(6, 0)), \
984 .set_rate = set_rate_mnd, \
985 .freq_tbl = clk_tbl_gsbi_uart, \
986 .current_freq = &local_dummy_freq, \
987 .c = { \
988 .dbg_name = #i "_clk", \
989 .ops = &soc_clk_ops_8960, \
990 CLK_INIT(i##_clk.c), \
991 }, \
992 }
993#define F_GSBI_UART(f, s, d, m, n, v) \
994 { \
995 .freq_hz = f, \
996 .src_clk = &s##_clk.c, \
997 .md_val = MD16(m, n), \
998 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
999 .mnd_en_mask = BIT(8) * !!(n), \
1000 .sys_vdd = v, \
1001 }
1002static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
1003 F_GSBI_UART( 0, gnd, 1, 0, 0, NONE),
1004 F_GSBI_UART( 1843200, pll8, 1, 3, 625, LOW),
1005 F_GSBI_UART( 3686400, pll8, 1, 6, 625, LOW),
1006 F_GSBI_UART( 7372800, pll8, 1, 12, 625, LOW),
1007 F_GSBI_UART(14745600, pll8, 1, 24, 625, LOW),
1008 F_GSBI_UART(16000000, pll8, 4, 1, 6, LOW),
1009 F_GSBI_UART(24000000, pll8, 4, 1, 4, LOW),
1010 F_GSBI_UART(32000000, pll8, 4, 1, 3, LOW),
1011 F_GSBI_UART(40000000, pll8, 1, 5, 48, NOMINAL),
1012 F_GSBI_UART(46400000, pll8, 1, 29, 240, NOMINAL),
1013 F_GSBI_UART(48000000, pll8, 4, 1, 2, NOMINAL),
1014 F_GSBI_UART(51200000, pll8, 1, 2, 15, NOMINAL),
1015 F_GSBI_UART(56000000, pll8, 1, 7, 48, NOMINAL),
1016 F_GSBI_UART(58982400, pll8, 1, 96, 625, NOMINAL),
1017 F_GSBI_UART(64000000, pll8, 2, 1, 3, NOMINAL),
1018 F_END
1019};
1020
1021static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1022static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1023static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1024static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1025static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1026static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1027static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1028static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1029static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1030static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1031static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1032static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1033
1034#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1035 struct rcg_clk i##_clk = { \
1036 .b = { \
1037 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1038 .en_mask = BIT(9), \
1039 .reset_reg = GSBIn_RESET_REG(n), \
1040 .reset_mask = BIT(0), \
1041 .halt_reg = h_r, \
1042 .halt_bit = h_b, \
1043 }, \
1044 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1045 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1046 .root_en_mask = BIT(11), \
1047 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1048 .set_rate = set_rate_mnd, \
1049 .freq_tbl = clk_tbl_gsbi_qup, \
1050 .current_freq = &local_dummy_freq, \
1051 .c = { \
1052 .dbg_name = #i "_clk", \
1053 .ops = &soc_clk_ops_8960, \
1054 CLK_INIT(i##_clk.c), \
1055 }, \
1056 }
1057#define F_GSBI_QUP(f, s, d, m, n, v) \
1058 { \
1059 .freq_hz = f, \
1060 .src_clk = &s##_clk.c, \
1061 .md_val = MD8(16, m, 0, n), \
1062 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1063 .mnd_en_mask = BIT(8) * !!(n), \
1064 .sys_vdd = v, \
1065 }
1066static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
1067 F_GSBI_QUP( 0, gnd, 1, 0, 0, NONE),
1068 F_GSBI_QUP( 1100000, pxo, 1, 2, 49, LOW),
1069 F_GSBI_QUP( 5400000, pxo, 1, 1, 5, LOW),
1070 F_GSBI_QUP(10800000, pxo, 1, 2, 5, LOW),
1071 F_GSBI_QUP(15060000, pll8, 1, 2, 51, LOW),
1072 F_GSBI_QUP(24000000, pll8, 4, 1, 4, LOW),
1073 F_GSBI_QUP(25600000, pll8, 1, 1, 15, NOMINAL),
1074 F_GSBI_QUP(27000000, pxo, 1, 0, 0, NOMINAL),
1075 F_GSBI_QUP(48000000, pll8, 4, 1, 2, NOMINAL),
1076 F_GSBI_QUP(51200000, pll8, 1, 2, 15, NOMINAL),
1077 F_END
1078};
1079
1080static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1081static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1082static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1083static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1084static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1085static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1086static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1087static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1088static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1089static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1090static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1091static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1092
1093#define F_PDM(f, s, d, v) \
1094 { \
1095 .freq_hz = f, \
1096 .src_clk = &s##_clk.c, \
1097 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
1098 .sys_vdd = v, \
1099 }
1100static struct clk_freq_tbl clk_tbl_pdm[] = {
1101 F_PDM( 0, gnd, 1, NONE),
1102 F_PDM(27000000, pxo, 1, LOW),
1103 F_END
1104};
1105
1106static struct rcg_clk pdm_clk = {
1107 .b = {
1108 .ctl_reg = PDM_CLK_NS_REG,
1109 .en_mask = BIT(9),
1110 .reset_reg = PDM_CLK_NS_REG,
1111 .reset_mask = BIT(12),
1112 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1113 .halt_bit = 3,
1114 },
1115 .ns_reg = PDM_CLK_NS_REG,
1116 .root_en_mask = BIT(11),
1117 .ns_mask = BM(1, 0),
1118 .set_rate = set_rate_nop,
1119 .freq_tbl = clk_tbl_pdm,
1120 .current_freq = &local_dummy_freq,
1121 .c = {
1122 .dbg_name = "pdm_clk",
1123 .ops = &soc_clk_ops_8960,
1124 CLK_INIT(pdm_clk.c),
1125 },
1126};
1127
1128static struct branch_clk pmem_clk = {
1129 .b = {
1130 .ctl_reg = PMEM_ACLK_CTL_REG,
1131 .en_mask = BIT(4),
1132 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1133 .halt_bit = 20,
1134 },
1135 .c = {
1136 .dbg_name = "pmem_clk",
1137 .ops = &clk_ops_branch,
1138 CLK_INIT(pmem_clk.c),
1139 },
1140};
1141
1142#define F_PRNG(f, s, v) \
1143 { \
1144 .freq_hz = f, \
1145 .src_clk = &s##_clk.c, \
1146 .sys_vdd = v, \
1147 }
1148static struct clk_freq_tbl clk_tbl_prng[] = {
1149 F_PRNG(64000000, pll8, NOMINAL),
1150 F_END
1151};
1152
1153static struct rcg_clk prng_clk = {
1154 .b = {
1155 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1156 .en_mask = BIT(10),
1157 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1158 .halt_check = HALT_VOTED,
1159 .halt_bit = 10,
1160 },
1161 .set_rate = set_rate_nop,
1162 .freq_tbl = clk_tbl_prng,
1163 .current_freq = &local_dummy_freq,
1164 .c = {
1165 .dbg_name = "prng_clk",
1166 .ops = &soc_clk_ops_8960,
1167 CLK_INIT(prng_clk.c),
1168 },
1169};
1170
Matt Wagantallee184092011-07-20 18:56:40 -07001171#define CLK_SDC(i, n, h_r, h_b) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001172 struct rcg_clk i##_clk = { \
1173 .b = { \
1174 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1175 .en_mask = BIT(9), \
1176 .reset_reg = SDCn_RESET_REG(n), \
1177 .reset_mask = BIT(0), \
1178 .halt_reg = h_r, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001179 .halt_bit = h_b, \
1180 }, \
1181 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1182 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1183 .root_en_mask = BIT(11), \
1184 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1185 .set_rate = set_rate_mnd, \
1186 .freq_tbl = clk_tbl_sdc, \
1187 .current_freq = &local_dummy_freq, \
1188 .c = { \
1189 .dbg_name = #i "_clk", \
1190 .ops = &soc_clk_ops_8960, \
1191 CLK_INIT(i##_clk.c), \
1192 }, \
1193 }
1194#define F_SDC(f, s, d, m, n, v) \
1195 { \
1196 .freq_hz = f, \
1197 .src_clk = &s##_clk.c, \
1198 .md_val = MD8(16, m, 0, n), \
1199 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1200 .mnd_en_mask = BIT(8) * !!(n), \
1201 .sys_vdd = v, \
1202 }
1203static struct clk_freq_tbl clk_tbl_sdc[] = {
1204 F_SDC( 0, gnd, 1, 0, 0, NONE),
1205 F_SDC( 144000, pxo, 3, 2, 125, LOW),
1206 F_SDC( 400000, pll8, 4, 1, 240, LOW),
1207 F_SDC( 16000000, pll8, 4, 1, 6, LOW),
1208 F_SDC( 17070000, pll8, 1, 2, 45, LOW),
1209 F_SDC( 20210000, pll8, 1, 1, 19, LOW),
1210 F_SDC( 24000000, pll8, 4, 1, 4, LOW),
1211 F_SDC( 48000000, pll8, 4, 1, 2, NOMINAL),
1212 F_SDC( 64000000, pll8, 3, 1, 2, NOMINAL),
1213 F_SDC( 96000000, pll8, 4, 0, 0, NOMINAL),
1214 F_SDC(192000000, pll8, 2, 0, 0, NOMINAL),
1215 F_END
1216};
1217
Matt Wagantallee184092011-07-20 18:56:40 -07001218static CLK_SDC(sdc1, 1, CLK_HALT_DFAB_STATE_REG, 6);
1219static CLK_SDC(sdc2, 2, CLK_HALT_DFAB_STATE_REG, 5);
1220static CLK_SDC(sdc3, 3, CLK_HALT_DFAB_STATE_REG, 4);
1221static CLK_SDC(sdc4, 4, CLK_HALT_DFAB_STATE_REG, 3);
1222static CLK_SDC(sdc5, 5, CLK_HALT_DFAB_STATE_REG, 2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001223
1224#define F_TSIF_REF(f, s, d, m, n, v) \
1225 { \
1226 .freq_hz = f, \
1227 .src_clk = &s##_clk.c, \
1228 .md_val = MD16(m, n), \
1229 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1230 .mnd_en_mask = BIT(8) * !!(n), \
1231 .sys_vdd = v, \
1232 }
1233static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
1234 F_TSIF_REF( 0, gnd, 1, 0, 0, NONE),
1235 F_TSIF_REF(105000, pxo, 1, 1, 256, LOW),
1236 F_END
1237};
1238
1239static struct rcg_clk tsif_ref_clk = {
1240 .b = {
1241 .ctl_reg = TSIF_REF_CLK_NS_REG,
1242 .en_mask = BIT(9),
1243 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1244 .halt_bit = 5,
1245 },
1246 .ns_reg = TSIF_REF_CLK_NS_REG,
1247 .md_reg = TSIF_REF_CLK_MD_REG,
1248 .root_en_mask = BIT(11),
1249 .ns_mask = (BM(31, 16) | BM(6, 0)),
1250 .set_rate = set_rate_mnd,
1251 .freq_tbl = clk_tbl_tsif_ref,
1252 .current_freq = &local_dummy_freq,
1253 .c = {
1254 .dbg_name = "tsif_ref_clk",
1255 .ops = &soc_clk_ops_8960,
1256 CLK_INIT(tsif_ref_clk.c),
1257 },
1258};
1259
1260#define F_TSSC(f, s, v) \
1261 { \
1262 .freq_hz = f, \
1263 .src_clk = &s##_clk.c, \
1264 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
1265 .sys_vdd = v, \
1266 }
1267static struct clk_freq_tbl clk_tbl_tssc[] = {
1268 F_TSSC( 0, gnd, NONE),
1269 F_TSSC(27000000, pxo, LOW),
1270 F_END
1271};
1272
1273static struct rcg_clk tssc_clk = {
1274 .b = {
1275 .ctl_reg = TSSC_CLK_CTL_REG,
1276 .en_mask = BIT(4),
1277 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1278 .halt_bit = 4,
1279 },
1280 .ns_reg = TSSC_CLK_CTL_REG,
1281 .ns_mask = BM(1, 0),
1282 .set_rate = set_rate_nop,
1283 .freq_tbl = clk_tbl_tssc,
1284 .current_freq = &local_dummy_freq,
1285 .c = {
1286 .dbg_name = "tssc_clk",
1287 .ops = &soc_clk_ops_8960,
1288 CLK_INIT(tssc_clk.c),
1289 },
1290};
1291
1292#define F_USB(f, s, d, m, n, v) \
1293 { \
1294 .freq_hz = f, \
1295 .src_clk = &s##_clk.c, \
1296 .md_val = MD8(16, m, 0, n), \
1297 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1298 .mnd_en_mask = BIT(8) * !!(n), \
1299 .sys_vdd = v, \
1300 }
1301static struct clk_freq_tbl clk_tbl_usb[] = {
1302 F_USB( 0, gnd, 1, 0, 0, NONE),
1303 F_USB(60000000, pll8, 1, 5, 32, NOMINAL),
1304 F_END
1305};
1306
1307static struct rcg_clk usb_hs1_xcvr_clk = {
1308 .b = {
1309 .ctl_reg = USB_HS1_XCVR_FS_CLK_NS_REG,
1310 .en_mask = BIT(9),
1311 .reset_reg = USB_HS1_RESET_REG,
1312 .reset_mask = BIT(0),
1313 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1314 .halt_bit = 0,
1315 },
1316 .ns_reg = USB_HS1_XCVR_FS_CLK_NS_REG,
1317 .md_reg = USB_HS1_XCVR_FS_CLK_MD_REG,
1318 .root_en_mask = BIT(11),
1319 .ns_mask = (BM(23, 16) | BM(6, 0)),
1320 .set_rate = set_rate_mnd,
1321 .freq_tbl = clk_tbl_usb,
1322 .current_freq = &local_dummy_freq,
1323 .c = {
1324 .dbg_name = "usb_hs1_xcvr_clk",
1325 .ops = &soc_clk_ops_8960,
1326 CLK_INIT(usb_hs1_xcvr_clk.c),
1327 },
1328};
1329
1330static struct branch_clk usb_phy0_clk = {
1331 .b = {
1332 .reset_reg = USB_PHY0_RESET_REG,
1333 .reset_mask = BIT(0),
1334 },
1335 .c = {
1336 .dbg_name = "usb_phy0_clk",
1337 .ops = &clk_ops_reset,
1338 CLK_INIT(usb_phy0_clk.c),
1339 },
1340};
1341
1342#define CLK_USB_FS(i, n) \
1343 struct rcg_clk i##_clk = { \
1344 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1345 .b = { \
1346 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1347 .halt_check = NOCHECK, \
1348 }, \
1349 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
1350 .root_en_mask = BIT(11), \
1351 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1352 .set_rate = set_rate_mnd, \
1353 .freq_tbl = clk_tbl_usb, \
1354 .current_freq = &local_dummy_freq, \
1355 .c = { \
1356 .dbg_name = #i "_clk", \
1357 .ops = &soc_clk_ops_8960, \
1358 CLK_INIT(i##_clk.c), \
1359 }, \
1360 }
1361
1362static CLK_USB_FS(usb_fs1_src, 1);
1363static struct branch_clk usb_fs1_xcvr_clk = {
1364 .b = {
1365 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
1366 .en_mask = BIT(9),
1367 .reset_reg = USB_FSn_RESET_REG(1),
1368 .reset_mask = BIT(1),
1369 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1370 .halt_bit = 15,
1371 },
1372 .parent = &usb_fs1_src_clk.c,
1373 .c = {
1374 .dbg_name = "usb_fs1_xcvr_clk",
1375 .ops = &clk_ops_branch,
1376 CLK_INIT(usb_fs1_xcvr_clk.c),
1377 },
1378};
1379
1380static struct branch_clk usb_fs1_sys_clk = {
1381 .b = {
1382 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
1383 .en_mask = BIT(4),
1384 .reset_reg = USB_FSn_RESET_REG(1),
1385 .reset_mask = BIT(0),
1386 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1387 .halt_bit = 16,
1388 },
1389 .parent = &usb_fs1_src_clk.c,
1390 .c = {
1391 .dbg_name = "usb_fs1_sys_clk",
1392 .ops = &clk_ops_branch,
1393 CLK_INIT(usb_fs1_sys_clk.c),
1394 },
1395};
1396
1397static CLK_USB_FS(usb_fs2_src, 2);
1398static struct branch_clk usb_fs2_xcvr_clk = {
1399 .b = {
1400 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
1401 .en_mask = BIT(9),
1402 .reset_reg = USB_FSn_RESET_REG(2),
1403 .reset_mask = BIT(1),
1404 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1405 .halt_bit = 12,
1406 },
1407 .parent = &usb_fs2_src_clk.c,
1408 .c = {
1409 .dbg_name = "usb_fs2_xcvr_clk",
1410 .ops = &clk_ops_branch,
1411 CLK_INIT(usb_fs2_xcvr_clk.c),
1412 },
1413};
1414
1415static struct branch_clk usb_fs2_sys_clk = {
1416 .b = {
1417 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
1418 .en_mask = BIT(4),
1419 .reset_reg = USB_FSn_RESET_REG(2),
1420 .reset_mask = BIT(0),
1421 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1422 .halt_bit = 13,
1423 },
1424 .parent = &usb_fs2_src_clk.c,
1425 .c = {
1426 .dbg_name = "usb_fs2_sys_clk",
1427 .ops = &clk_ops_branch,
1428 CLK_INIT(usb_fs2_sys_clk.c),
1429 },
1430};
1431
1432/* Fast Peripheral Bus Clocks */
1433static struct branch_clk ce1_core_clk = {
1434 .b = {
1435 .ctl_reg = CE1_CORE_CLK_CTL_REG,
1436 .en_mask = BIT(4),
1437 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1438 .halt_bit = 27,
1439 },
1440 .c = {
1441 .dbg_name = "ce1_core_clk",
1442 .ops = &clk_ops_branch,
1443 CLK_INIT(ce1_core_clk.c),
1444 },
1445};
1446static struct branch_clk ce1_p_clk = {
1447 .b = {
1448 .ctl_reg = CE1_HCLK_CTL_REG,
1449 .en_mask = BIT(4),
1450 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1451 .halt_bit = 1,
1452 },
1453 .c = {
1454 .dbg_name = "ce1_p_clk",
1455 .ops = &clk_ops_branch,
1456 CLK_INIT(ce1_p_clk.c),
1457 },
1458};
1459
1460static struct branch_clk dma_bam_p_clk = {
1461 .b = {
1462 .ctl_reg = DMA_BAM_HCLK_CTL,
1463 .en_mask = BIT(4),
1464 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1465 .halt_bit = 12,
1466 },
1467 .c = {
1468 .dbg_name = "dma_bam_p_clk",
1469 .ops = &clk_ops_branch,
1470 CLK_INIT(dma_bam_p_clk.c),
1471 },
1472};
1473
1474static struct branch_clk gsbi1_p_clk = {
1475 .b = {
1476 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
1477 .en_mask = BIT(4),
1478 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1479 .halt_bit = 11,
1480 },
1481 .c = {
1482 .dbg_name = "gsbi1_p_clk",
1483 .ops = &clk_ops_branch,
1484 CLK_INIT(gsbi1_p_clk.c),
1485 },
1486};
1487
1488static struct branch_clk gsbi2_p_clk = {
1489 .b = {
1490 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
1491 .en_mask = BIT(4),
1492 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1493 .halt_bit = 7,
1494 },
1495 .c = {
1496 .dbg_name = "gsbi2_p_clk",
1497 .ops = &clk_ops_branch,
1498 CLK_INIT(gsbi2_p_clk.c),
1499 },
1500};
1501
1502static struct branch_clk gsbi3_p_clk = {
1503 .b = {
1504 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
1505 .en_mask = BIT(4),
1506 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1507 .halt_bit = 3,
1508 },
1509 .c = {
1510 .dbg_name = "gsbi3_p_clk",
1511 .ops = &clk_ops_branch,
1512 CLK_INIT(gsbi3_p_clk.c),
1513 },
1514};
1515
1516static struct branch_clk gsbi4_p_clk = {
1517 .b = {
1518 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
1519 .en_mask = BIT(4),
1520 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1521 .halt_bit = 27,
1522 },
1523 .c = {
1524 .dbg_name = "gsbi4_p_clk",
1525 .ops = &clk_ops_branch,
1526 CLK_INIT(gsbi4_p_clk.c),
1527 },
1528};
1529
1530static struct branch_clk gsbi5_p_clk = {
1531 .b = {
1532 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
1533 .en_mask = BIT(4),
1534 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1535 .halt_bit = 23,
1536 },
1537 .c = {
1538 .dbg_name = "gsbi5_p_clk",
1539 .ops = &clk_ops_branch,
1540 CLK_INIT(gsbi5_p_clk.c),
1541 },
1542};
1543
1544static struct branch_clk gsbi6_p_clk = {
1545 .b = {
1546 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
1547 .en_mask = BIT(4),
1548 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1549 .halt_bit = 19,
1550 },
1551 .c = {
1552 .dbg_name = "gsbi6_p_clk",
1553 .ops = &clk_ops_branch,
1554 CLK_INIT(gsbi6_p_clk.c),
1555 },
1556};
1557
1558static struct branch_clk gsbi7_p_clk = {
1559 .b = {
1560 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
1561 .en_mask = BIT(4),
1562 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1563 .halt_bit = 15,
1564 },
1565 .c = {
1566 .dbg_name = "gsbi7_p_clk",
1567 .ops = &clk_ops_branch,
1568 CLK_INIT(gsbi7_p_clk.c),
1569 },
1570};
1571
1572static struct branch_clk gsbi8_p_clk = {
1573 .b = {
1574 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
1575 .en_mask = BIT(4),
1576 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1577 .halt_bit = 11,
1578 },
1579 .c = {
1580 .dbg_name = "gsbi8_p_clk",
1581 .ops = &clk_ops_branch,
1582 CLK_INIT(gsbi8_p_clk.c),
1583 },
1584};
1585
1586static struct branch_clk gsbi9_p_clk = {
1587 .b = {
1588 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
1589 .en_mask = BIT(4),
1590 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1591 .halt_bit = 7,
1592 },
1593 .c = {
1594 .dbg_name = "gsbi9_p_clk",
1595 .ops = &clk_ops_branch,
1596 CLK_INIT(gsbi9_p_clk.c),
1597 },
1598};
1599
1600static struct branch_clk gsbi10_p_clk = {
1601 .b = {
1602 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
1603 .en_mask = BIT(4),
1604 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1605 .halt_bit = 3,
1606 },
1607 .c = {
1608 .dbg_name = "gsbi10_p_clk",
1609 .ops = &clk_ops_branch,
1610 CLK_INIT(gsbi10_p_clk.c),
1611 },
1612};
1613
1614static struct branch_clk gsbi11_p_clk = {
1615 .b = {
1616 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
1617 .en_mask = BIT(4),
1618 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1619 .halt_bit = 18,
1620 },
1621 .c = {
1622 .dbg_name = "gsbi11_p_clk",
1623 .ops = &clk_ops_branch,
1624 CLK_INIT(gsbi11_p_clk.c),
1625 },
1626};
1627
1628static struct branch_clk gsbi12_p_clk = {
1629 .b = {
1630 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
1631 .en_mask = BIT(4),
1632 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1633 .halt_bit = 14,
1634 },
1635 .c = {
1636 .dbg_name = "gsbi12_p_clk",
1637 .ops = &clk_ops_branch,
1638 CLK_INIT(gsbi12_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
1768/* HW-Voteable Clocks */
1769static struct branch_clk adm0_clk = {
1770 .b = {
1771 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1772 .en_mask = BIT(2),
1773 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1774 .halt_check = HALT_VOTED,
1775 .halt_bit = 14,
1776 },
1777 .c = {
1778 .dbg_name = "adm0_clk",
1779 .ops = &clk_ops_branch,
1780 CLK_INIT(adm0_clk.c),
1781 },
1782};
1783
1784static struct branch_clk adm0_p_clk = {
1785 .b = {
1786 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1787 .en_mask = BIT(3),
1788 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1789 .halt_check = HALT_VOTED,
1790 .halt_bit = 13,
1791 },
1792 .c = {
1793 .dbg_name = "adm0_p_clk",
1794 .ops = &clk_ops_branch,
1795 CLK_INIT(adm0_p_clk.c),
1796 },
1797};
1798
1799static struct branch_clk pmic_arb0_p_clk = {
1800 .b = {
1801 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1802 .en_mask = BIT(8),
1803 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1804 .halt_check = HALT_VOTED,
1805 .halt_bit = 22,
1806 },
1807 .c = {
1808 .dbg_name = "pmic_arb0_p_clk",
1809 .ops = &clk_ops_branch,
1810 CLK_INIT(pmic_arb0_p_clk.c),
1811 },
1812};
1813
1814static struct branch_clk pmic_arb1_p_clk = {
1815 .b = {
1816 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1817 .en_mask = BIT(9),
1818 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1819 .halt_check = HALT_VOTED,
1820 .halt_bit = 21,
1821 },
1822 .c = {
1823 .dbg_name = "pmic_arb1_p_clk",
1824 .ops = &clk_ops_branch,
1825 CLK_INIT(pmic_arb1_p_clk.c),
1826 },
1827};
1828
1829static struct branch_clk pmic_ssbi2_clk = {
1830 .b = {
1831 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1832 .en_mask = BIT(7),
1833 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1834 .halt_check = HALT_VOTED,
1835 .halt_bit = 23,
1836 },
1837 .c = {
1838 .dbg_name = "pmic_ssbi2_clk",
1839 .ops = &clk_ops_branch,
1840 CLK_INIT(pmic_ssbi2_clk.c),
1841 },
1842};
1843
1844static struct branch_clk rpm_msg_ram_p_clk = {
1845 .b = {
1846 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1847 .en_mask = BIT(6),
1848 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1849 .halt_check = HALT_VOTED,
1850 .halt_bit = 12,
1851 },
1852 .c = {
1853 .dbg_name = "rpm_msg_ram_p_clk",
1854 .ops = &clk_ops_branch,
1855 CLK_INIT(rpm_msg_ram_p_clk.c),
1856 },
1857};
1858
1859/*
1860 * Multimedia Clocks
1861 */
1862
1863static struct branch_clk amp_clk = {
1864 .b = {
1865 .reset_reg = SW_RESET_CORE_REG,
1866 .reset_mask = BIT(20),
1867 },
1868 .c = {
1869 .dbg_name = "amp_clk",
1870 .ops = &clk_ops_reset,
1871 CLK_INIT(amp_clk.c),
1872 },
1873};
1874
1875#define CLK_CAM(i, n, hb) \
1876 struct rcg_clk i##_clk = { \
1877 .b = { \
1878 .ctl_reg = CAMCLKn_CC_REG(n), \
1879 .en_mask = BIT(0), \
1880 .halt_reg = DBG_BUS_VEC_I_REG, \
1881 .halt_bit = hb, \
1882 }, \
1883 .ns_reg = CAMCLKn_NS_REG(n), \
1884 .md_reg = CAMCLKn_MD_REG(n), \
1885 .root_en_mask = BIT(2), \
1886 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)), \
1887 .ctl_mask = BM(7, 6), \
1888 .set_rate = set_rate_mnd_8, \
1889 .freq_tbl = clk_tbl_cam, \
1890 .current_freq = &local_dummy_freq, \
1891 .c = { \
1892 .dbg_name = #i "_clk", \
1893 .ops = &soc_clk_ops_8960, \
1894 CLK_INIT(i##_clk.c), \
1895 }, \
1896 }
1897#define F_CAM(f, s, d, m, n, v) \
1898 { \
1899 .freq_hz = f, \
1900 .src_clk = &s##_clk.c, \
1901 .md_val = MD8(8, m, 0, n), \
1902 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
1903 .ctl_val = CC(6, n), \
1904 .mnd_en_mask = BIT(5) * !!(n), \
1905 .sys_vdd = v, \
1906 }
1907static struct clk_freq_tbl clk_tbl_cam[] = {
1908 F_CAM( 0, gnd, 1, 0, 0, NONE),
1909 F_CAM( 6000000, pll8, 4, 1, 16, LOW),
1910 F_CAM( 8000000, pll8, 4, 1, 12, LOW),
1911 F_CAM( 12000000, pll8, 4, 1, 8, LOW),
1912 F_CAM( 16000000, pll8, 4, 1, 6, LOW),
1913 F_CAM( 19200000, pll8, 4, 1, 5, LOW),
1914 F_CAM( 24000000, pll8, 4, 1, 4, LOW),
1915 F_CAM( 32000000, pll8, 4, 1, 3, LOW),
1916 F_CAM( 48000000, pll8, 4, 1, 2, LOW),
1917 F_CAM( 64000000, pll8, 3, 1, 2, LOW),
1918 F_CAM( 96000000, pll8, 4, 0, 0, NOMINAL),
1919 F_CAM(128000000, pll8, 3, 0, 0, NOMINAL),
1920 F_END
1921};
1922
1923static CLK_CAM(cam0, 0, 15);
1924static CLK_CAM(cam1, 1, 16);
1925
1926#define F_CSI(f, s, d, m, n, v) \
1927 { \
1928 .freq_hz = f, \
1929 .src_clk = &s##_clk.c, \
1930 .md_val = MD8(8, m, 0, n), \
1931 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
1932 .ctl_val = CC(6, n), \
1933 .mnd_en_mask = BIT(5) * !!(n), \
1934 .sys_vdd = v, \
1935 }
1936static struct clk_freq_tbl clk_tbl_csi[] = {
1937 F_CSI( 0, gnd, 1, 0, 0, NONE),
1938 F_CSI( 85330000, pll8, 1, 2, 9, LOW),
1939 F_CSI(177780000, pll2, 1, 2, 9, NOMINAL),
1940 F_END
1941};
1942
1943static struct rcg_clk csi0_src_clk = {
1944 .ns_reg = CSI0_NS_REG,
1945 .b = {
1946 .ctl_reg = CSI0_CC_REG,
1947 .halt_check = NOCHECK,
1948 },
1949 .md_reg = CSI0_MD_REG,
1950 .root_en_mask = BIT(2),
1951 .ns_mask = BM(31, 24) | BM(15, 12) | BM(2, 0),
1952 .ctl_mask = BM(7, 6),
1953 .set_rate = set_rate_mnd,
1954 .freq_tbl = clk_tbl_csi,
1955 .current_freq = &local_dummy_freq,
1956 .c = {
1957 .dbg_name = "csi0_src_clk",
1958 .ops = &soc_clk_ops_8960,
1959 CLK_INIT(csi0_src_clk.c),
1960 },
1961};
1962
1963static struct branch_clk csi0_clk = {
1964 .b = {
1965 .ctl_reg = CSI0_CC_REG,
1966 .en_mask = BIT(0),
1967 .reset_reg = SW_RESET_CORE_REG,
1968 .reset_mask = BIT(8),
1969 .halt_reg = DBG_BUS_VEC_B_REG,
1970 .halt_bit = 13,
1971 },
1972 .parent = &csi0_src_clk.c,
1973 .c = {
1974 .dbg_name = "csi0_clk",
1975 .ops = &clk_ops_branch,
1976 CLK_INIT(csi0_clk.c),
1977 },
1978};
1979
1980static struct branch_clk csi0_phy_clk = {
1981 .b = {
1982 .ctl_reg = CSI0_CC_REG,
1983 .en_mask = BIT(8),
1984 .reset_reg = SW_RESET_CORE_REG,
1985 .reset_mask = BIT(29),
1986 .halt_reg = DBG_BUS_VEC_I_REG,
1987 .halt_bit = 9,
1988 },
1989 .parent = &csi0_src_clk.c,
1990 .c = {
1991 .dbg_name = "csi0_phy_clk",
1992 .ops = &clk_ops_branch,
1993 CLK_INIT(csi0_phy_clk.c),
1994 },
1995};
1996
1997static struct rcg_clk csi1_src_clk = {
1998 .ns_reg = CSI1_NS_REG,
1999 .b = {
2000 .ctl_reg = CSI1_CC_REG,
2001 .halt_check = NOCHECK,
2002 },
2003 .md_reg = CSI1_MD_REG,
2004 .root_en_mask = BIT(2),
2005 .ns_mask = BM(31, 24) | BM(15, 12) | BM(2, 0),
2006 .ctl_mask = BM(7, 6),
2007 .set_rate = set_rate_mnd,
2008 .freq_tbl = clk_tbl_csi,
2009 .current_freq = &local_dummy_freq,
2010 .c = {
2011 .dbg_name = "csi1_src_clk",
2012 .ops = &soc_clk_ops_8960,
2013 CLK_INIT(csi1_src_clk.c),
2014 },
2015};
2016
2017static struct branch_clk csi1_clk = {
2018 .b = {
2019 .ctl_reg = CSI1_CC_REG,
2020 .en_mask = BIT(0),
2021 .reset_reg = SW_RESET_CORE_REG,
2022 .reset_mask = BIT(18),
2023 .halt_reg = DBG_BUS_VEC_B_REG,
2024 .halt_bit = 14,
2025 },
2026 .parent = &csi1_src_clk.c,
2027 .c = {
2028 .dbg_name = "csi1_clk",
2029 .ops = &clk_ops_branch,
2030 CLK_INIT(csi1_clk.c),
2031 },
2032};
2033
2034static struct branch_clk csi1_phy_clk = {
2035 .b = {
2036 .ctl_reg = CSI1_CC_REG,
2037 .en_mask = BIT(8),
2038 .reset_reg = SW_RESET_CORE_REG,
2039 .reset_mask = BIT(28),
2040 .halt_reg = DBG_BUS_VEC_I_REG,
2041 .halt_bit = 10,
2042 },
2043 .parent = &csi1_src_clk.c,
2044 .c = {
2045 .dbg_name = "csi1_phy_clk",
2046 .ops = &clk_ops_branch,
2047 CLK_INIT(csi1_phy_clk.c),
2048 },
2049};
2050
2051#define F_CSI_PIX(s) \
2052 { \
2053 .src_clk = &csi##s##_clk.c, \
2054 .freq_hz = s, \
2055 .ns_val = BVAL(25, 25, s), \
2056 }
2057static struct clk_freq_tbl clk_tbl_csi_pix[] = {
2058 F_CSI_PIX(0), /* CSI0 source */
2059 F_CSI_PIX(1), /* CSI1 source */
2060 F_END
2061};
2062
2063#define F_CSI_RDI(s) \
2064 { \
2065 .src_clk = &csi##s##_clk.c, \
2066 .freq_hz = s, \
2067 .ns_val = BVAL(12, 12, s), \
2068 }
2069static struct clk_freq_tbl clk_tbl_csi_rdi[] = {
2070 F_CSI_RDI(0), /* CSI0 source */
2071 F_CSI_RDI(1), /* CSI1 source */
2072 F_END
2073};
2074
2075static struct rcg_clk csi_pix_clk = {
2076 .b = {
2077 .ctl_reg = MISC_CC_REG,
2078 .en_mask = BIT(26),
2079 .halt_check = DELAY,
2080 .reset_reg = SW_RESET_CORE_REG,
2081 .reset_mask = BIT(26),
2082 },
2083 .ns_reg = MISC_CC_REG,
2084 .ns_mask = BIT(25),
2085 .set_rate = set_rate_nop,
2086 .freq_tbl = clk_tbl_csi_pix,
2087 .current_freq = &local_dummy_freq,
2088 .c = {
2089 .dbg_name = "csi_pix_clk",
2090 .ops = &soc_clk_ops_8960,
2091 CLK_INIT(csi_pix_clk.c),
2092 },
2093};
2094
2095static struct rcg_clk csi_rdi_clk = {
2096 .b = {
2097 .ctl_reg = MISC_CC_REG,
2098 .en_mask = BIT(13),
2099 .halt_check = DELAY,
2100 .reset_reg = SW_RESET_CORE_REG,
2101 .reset_mask = BIT(27),
2102 },
2103 .ns_reg = MISC_CC_REG,
2104 .ns_mask = BIT(12),
2105 .set_rate = set_rate_nop,
2106 .freq_tbl = clk_tbl_csi_rdi,
2107 .current_freq = &local_dummy_freq,
2108 .c = {
2109 .dbg_name = "csi_rdi_clk",
2110 .ops = &soc_clk_ops_8960,
2111 CLK_INIT(csi_rdi_clk.c),
2112 },
2113};
2114
2115#define F_CSI_PHYTIMER(f, s, d, m, n, v) \
2116 { \
2117 .freq_hz = f, \
2118 .src_clk = &s##_clk.c, \
2119 .md_val = MD8(8, m, 0, n), \
2120 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2121 .ctl_val = CC(6, n), \
2122 .mnd_en_mask = BIT(5) * !!(n), \
2123 .sys_vdd = v, \
2124 }
2125static struct clk_freq_tbl clk_tbl_csi_phytimer[] = {
2126 F_CSI_PHYTIMER( 0, gnd, 1, 0, 0, NONE),
2127 F_CSI_PHYTIMER( 85330000, pll8, 1, 2, 9, LOW),
2128 F_CSI_PHYTIMER(177780000, pll2, 1, 2, 9, NOMINAL),
2129 F_END
2130};
2131
2132static struct rcg_clk csiphy_timer_src_clk = {
2133 .ns_reg = CSIPHYTIMER_NS_REG,
2134 .b = {
2135 .ctl_reg = CSIPHYTIMER_CC_REG,
2136 .halt_check = NOCHECK,
2137 },
2138 .md_reg = CSIPHYTIMER_MD_REG,
2139 .root_en_mask = BIT(2),
2140 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
2141 .ctl_mask = BM(7, 6),
2142 .set_rate = set_rate_mnd_8,
2143 .freq_tbl = clk_tbl_csi_phytimer,
2144 .current_freq = &local_dummy_freq,
2145 .c = {
2146 .dbg_name = "csiphy_timer_src_clk",
2147 .ops = &soc_clk_ops_8960,
2148 CLK_INIT(csiphy_timer_src_clk.c),
2149 },
2150};
2151
2152static struct branch_clk csi0phy_timer_clk = {
2153 .b = {
2154 .ctl_reg = CSIPHYTIMER_CC_REG,
2155 .en_mask = BIT(0),
2156 .halt_reg = DBG_BUS_VEC_I_REG,
2157 .halt_bit = 17,
2158 },
2159 .parent = &csiphy_timer_src_clk.c,
2160 .c = {
2161 .dbg_name = "csi0phy_timer_clk",
2162 .ops = &clk_ops_branch,
2163 CLK_INIT(csi0phy_timer_clk.c),
2164 },
2165};
2166
2167static struct branch_clk csi1phy_timer_clk = {
2168 .b = {
2169 .ctl_reg = CSIPHYTIMER_CC_REG,
2170 .en_mask = BIT(9),
2171 .halt_reg = DBG_BUS_VEC_I_REG,
2172 .halt_bit = 18,
2173 },
2174 .parent = &csiphy_timer_src_clk.c,
2175 .c = {
2176 .dbg_name = "csi1phy_timer_clk",
2177 .ops = &clk_ops_branch,
2178 CLK_INIT(csi1phy_timer_clk.c),
2179 },
2180};
2181
2182#define F_DSI(d) \
2183 { \
2184 .freq_hz = d, \
2185 .ns_val = BVAL(15, 12, (d-1)), \
2186 }
2187/*
2188 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
2189 * without this clock driver knowing. So, overload the clk_set_rate() to set
2190 * the divider (1 to 16) of the clock with respect to the PLL rate.
2191 */
2192static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
2193 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
2194 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
2195 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
2196 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
2197 F_END
2198};
2199
2200static struct rcg_clk dsi1_byte_clk = {
2201 .b = {
2202 .ctl_reg = DSI1_BYTE_CC_REG,
2203 .en_mask = BIT(0),
2204 .reset_reg = SW_RESET_CORE_REG,
2205 .reset_mask = BIT(7),
2206 .halt_reg = DBG_BUS_VEC_B_REG,
2207 .halt_bit = 21,
2208 },
2209 .ns_reg = DSI1_BYTE_NS_REG,
2210 .root_en_mask = BIT(2),
2211 .ns_mask = BM(15, 12),
2212 .set_rate = set_rate_nop,
2213 .freq_tbl = clk_tbl_dsi_byte,
2214 .current_freq = &local_dummy_freq,
2215 .c = {
2216 .dbg_name = "dsi1_byte_clk",
2217 .ops = &soc_clk_ops_8960,
2218 CLK_INIT(dsi1_byte_clk.c),
2219 },
2220};
2221
2222static struct rcg_clk dsi2_byte_clk = {
2223 .b = {
2224 .ctl_reg = DSI2_BYTE_CC_REG,
2225 .en_mask = BIT(0),
2226 .reset_reg = SW_RESET_CORE_REG,
2227 .reset_mask = BIT(25),
2228 .halt_reg = DBG_BUS_VEC_B_REG,
2229 .halt_bit = 20,
2230 },
2231 .ns_reg = DSI2_BYTE_NS_REG,
2232 .root_en_mask = BIT(2),
2233 .ns_mask = BM(15, 12),
2234 .set_rate = set_rate_nop,
2235 .freq_tbl = clk_tbl_dsi_byte,
2236 .current_freq = &local_dummy_freq,
2237 .c = {
2238 .dbg_name = "dsi2_byte_clk",
2239 .ops = &soc_clk_ops_8960,
2240 CLK_INIT(dsi2_byte_clk.c),
2241 },
2242};
2243
2244static struct rcg_clk dsi1_esc_clk = {
2245 .b = {
2246 .ctl_reg = DSI1_ESC_CC_REG,
2247 .en_mask = BIT(0),
2248 .reset_reg = SW_RESET_CORE_REG,
2249 .halt_reg = DBG_BUS_VEC_I_REG,
2250 .halt_bit = 1,
2251 },
2252 .ns_reg = DSI1_ESC_NS_REG,
2253 .root_en_mask = BIT(2),
2254 .ns_mask = BM(15, 12),
2255 .set_rate = set_rate_nop,
2256 .freq_tbl = clk_tbl_dsi_byte,
2257 .current_freq = &local_dummy_freq,
2258 .c = {
2259 .dbg_name = "dsi1_esc_clk",
2260 .ops = &soc_clk_ops_8960,
2261 CLK_INIT(dsi1_esc_clk.c),
2262 },
2263};
2264
2265static struct rcg_clk dsi2_esc_clk = {
2266 .b = {
2267 .ctl_reg = DSI2_ESC_CC_REG,
2268 .en_mask = BIT(0),
2269 .halt_reg = DBG_BUS_VEC_I_REG,
2270 .halt_bit = 3,
2271 },
2272 .ns_reg = DSI2_ESC_NS_REG,
2273 .root_en_mask = BIT(2),
2274 .ns_mask = BM(15, 12),
2275 .set_rate = set_rate_nop,
2276 .freq_tbl = clk_tbl_dsi_byte,
2277 .current_freq = &local_dummy_freq,
2278 .c = {
2279 .dbg_name = "dsi2_esc_clk",
2280 .ops = &soc_clk_ops_8960,
2281 CLK_INIT(dsi2_esc_clk.c),
2282 },
2283};
2284
2285#define F_GFX2D(f, s, m, n, v) \
2286 { \
2287 .freq_hz = f, \
2288 .src_clk = &s##_clk.c, \
2289 .md_val = MD4(4, m, 0, n), \
2290 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
2291 .ctl_val = CC_BANKED(9, 6, n), \
2292 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
2293 .sys_vdd = v, \
2294 }
2295static struct clk_freq_tbl clk_tbl_gfx2d[] = {
2296 F_GFX2D( 0, gnd, 0, 0, NONE),
2297 F_GFX2D( 27000000, pxo, 0, 0, LOW),
2298 F_GFX2D( 48000000, pll8, 1, 8, LOW),
2299 F_GFX2D( 54857000, pll8, 1, 7, LOW),
2300 F_GFX2D( 64000000, pll8, 1, 6, LOW),
2301 F_GFX2D( 76800000, pll8, 1, 5, LOW),
2302 F_GFX2D( 96000000, pll8, 1, 4, LOW),
2303 F_GFX2D(128000000, pll8, 1, 3, NOMINAL),
2304 F_GFX2D(145455000, pll2, 2, 11, NOMINAL),
2305 F_GFX2D(160000000, pll2, 1, 5, NOMINAL),
2306 F_GFX2D(177778000, pll2, 2, 9, NOMINAL),
2307 F_GFX2D(200000000, pll2, 1, 4, NOMINAL),
2308 F_GFX2D(228571000, pll2, 2, 7, HIGH),
2309 F_END
2310};
2311
2312static struct bank_masks bmnd_info_gfx2d0 = {
2313 .bank_sel_mask = BIT(11),
2314 .bank0_mask = {
2315 .md_reg = GFX2D0_MD0_REG,
2316 .ns_mask = BM(23, 20) | BM(5, 3),
2317 .rst_mask = BIT(25),
2318 .mnd_en_mask = BIT(8),
2319 .mode_mask = BM(10, 9),
2320 },
2321 .bank1_mask = {
2322 .md_reg = GFX2D0_MD1_REG,
2323 .ns_mask = BM(19, 16) | BM(2, 0),
2324 .rst_mask = BIT(24),
2325 .mnd_en_mask = BIT(5),
2326 .mode_mask = BM(7, 6),
2327 },
2328};
2329
2330static struct rcg_clk gfx2d0_clk = {
2331 .b = {
2332 .ctl_reg = GFX2D0_CC_REG,
2333 .en_mask = BIT(0),
2334 .reset_reg = SW_RESET_CORE_REG,
2335 .reset_mask = BIT(14),
2336 .halt_reg = DBG_BUS_VEC_A_REG,
2337 .halt_bit = 9,
2338 },
2339 .ns_reg = GFX2D0_NS_REG,
2340 .root_en_mask = BIT(2),
2341 .set_rate = set_rate_mnd_banked,
2342 .freq_tbl = clk_tbl_gfx2d,
2343 .bank_masks = &bmnd_info_gfx2d0,
2344 .current_freq = &local_dummy_freq,
2345 .c = {
2346 .dbg_name = "gfx2d0_clk",
2347 .ops = &soc_clk_ops_8960,
2348 CLK_INIT(gfx2d0_clk.c),
2349 },
2350};
2351
2352static struct bank_masks bmnd_info_gfx2d1 = {
2353 .bank_sel_mask = BIT(11),
2354 .bank0_mask = {
2355 .md_reg = GFX2D1_MD0_REG,
2356 .ns_mask = BM(23, 20) | BM(5, 3),
2357 .rst_mask = BIT(25),
2358 .mnd_en_mask = BIT(8),
2359 .mode_mask = BM(10, 9),
2360 },
2361 .bank1_mask = {
2362 .md_reg = GFX2D1_MD1_REG,
2363 .ns_mask = BM(19, 16) | BM(2, 0),
2364 .rst_mask = BIT(24),
2365 .mnd_en_mask = BIT(5),
2366 .mode_mask = BM(7, 6),
2367 },
2368};
2369
2370static struct rcg_clk gfx2d1_clk = {
2371 .b = {
2372 .ctl_reg = GFX2D1_CC_REG,
2373 .en_mask = BIT(0),
2374 .reset_reg = SW_RESET_CORE_REG,
2375 .reset_mask = BIT(13),
2376 .halt_reg = DBG_BUS_VEC_A_REG,
2377 .halt_bit = 14,
2378 },
2379 .ns_reg = GFX2D1_NS_REG,
2380 .root_en_mask = BIT(2),
2381 .set_rate = set_rate_mnd_banked,
2382 .freq_tbl = clk_tbl_gfx2d,
2383 .bank_masks = &bmnd_info_gfx2d1,
2384 .current_freq = &local_dummy_freq,
2385 .c = {
2386 .dbg_name = "gfx2d1_clk",
2387 .ops = &soc_clk_ops_8960,
2388 CLK_INIT(gfx2d1_clk.c),
2389 },
2390};
2391
2392#define F_GFX3D(f, s, m, n, v) \
2393 { \
2394 .freq_hz = f, \
2395 .src_clk = &s##_clk.c, \
2396 .md_val = MD4(4, m, 0, n), \
2397 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
2398 .ctl_val = CC_BANKED(9, 6, n), \
2399 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
2400 .sys_vdd = v, \
2401 }
2402static struct clk_freq_tbl clk_tbl_gfx3d[] = {
2403 F_GFX3D( 0, gnd, 0, 0, NONE),
2404 F_GFX3D( 27000000, pxo, 0, 0, LOW),
2405 F_GFX3D( 48000000, pll8, 1, 8, LOW),
2406 F_GFX3D( 54857000, pll8, 1, 7, LOW),
2407 F_GFX3D( 64000000, pll8, 1, 6, LOW),
2408 F_GFX3D( 76800000, pll8, 1, 5, LOW),
2409 F_GFX3D( 96000000, pll8, 1, 4, LOW),
2410 F_GFX3D(128000000, pll8, 1, 3, NOMINAL),
2411 F_GFX3D(145455000, pll2, 2, 11, NOMINAL),
2412 F_GFX3D(160000000, pll2, 1, 5, NOMINAL),
2413 F_GFX3D(177778000, pll2, 2, 9, NOMINAL),
2414 F_GFX3D(200000000, pll2, 1, 4, NOMINAL),
2415 F_GFX3D(228571000, pll2, 2, 7, NOMINAL),
2416 F_GFX3D(266667000, pll2, 1, 3, NOMINAL),
2417 F_GFX3D(320000000, pll2, 2, 5, HIGH),
2418 F_END
2419};
2420
2421static struct bank_masks bmnd_info_gfx3d = {
2422 .bank_sel_mask = BIT(11),
2423 .bank0_mask = {
2424 .md_reg = GFX3D_MD0_REG,
2425 .ns_mask = BM(21, 18) | BM(5, 3),
2426 .rst_mask = BIT(23),
2427 .mnd_en_mask = BIT(8),
2428 .mode_mask = BM(10, 9),
2429 },
2430 .bank1_mask = {
2431 .md_reg = GFX3D_MD1_REG,
2432 .ns_mask = BM(17, 14) | BM(2, 0),
2433 .rst_mask = BIT(22),
2434 .mnd_en_mask = BIT(5),
2435 .mode_mask = BM(7, 6),
2436 },
2437};
2438
2439static struct rcg_clk gfx3d_clk = {
2440 .b = {
2441 .ctl_reg = GFX3D_CC_REG,
2442 .en_mask = BIT(0),
2443 .reset_reg = SW_RESET_CORE_REG,
2444 .reset_mask = BIT(12),
2445 .halt_reg = DBG_BUS_VEC_A_REG,
2446 .halt_bit = 4,
2447 },
2448 .ns_reg = GFX3D_NS_REG,
2449 .root_en_mask = BIT(2),
2450 .set_rate = set_rate_mnd_banked,
2451 .freq_tbl = clk_tbl_gfx3d,
2452 .bank_masks = &bmnd_info_gfx3d,
2453 .depends = &gmem_axi_clk.c,
2454 .current_freq = &local_dummy_freq,
2455 .c = {
2456 .dbg_name = "gfx3d_clk",
2457 .ops = &soc_clk_ops_8960,
2458 CLK_INIT(gfx3d_clk.c),
2459 },
2460};
2461
2462#define F_IJPEG(f, s, d, m, n, v) \
2463 { \
2464 .freq_hz = f, \
2465 .src_clk = &s##_clk.c, \
2466 .md_val = MD8(8, m, 0, n), \
2467 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
2468 .ctl_val = CC(6, n), \
2469 .mnd_en_mask = BIT(5) * !!(n), \
2470 .sys_vdd = v, \
2471 }
2472static struct clk_freq_tbl clk_tbl_ijpeg[] = {
2473 F_IJPEG( 0, gnd, 1, 0, 0, NONE),
2474 F_IJPEG( 27000000, pxo, 1, 0, 0, LOW),
2475 F_IJPEG( 36570000, pll8, 1, 2, 21, LOW),
2476 F_IJPEG( 54860000, pll8, 7, 0, 0, LOW),
2477 F_IJPEG( 96000000, pll8, 4, 0, 0, LOW),
2478 F_IJPEG(109710000, pll8, 1, 2, 7, LOW),
2479 F_IJPEG(128000000, pll8, 3, 0, 0, NOMINAL),
2480 F_IJPEG(153600000, pll8, 1, 2, 5, NOMINAL),
2481 F_IJPEG(200000000, pll2, 4, 0, 0, NOMINAL),
2482 F_IJPEG(228571000, pll2, 1, 2, 7, NOMINAL),
2483 F_END
2484};
2485
2486static struct rcg_clk ijpeg_clk = {
2487 .b = {
2488 .ctl_reg = IJPEG_CC_REG,
2489 .en_mask = BIT(0),
2490 .reset_reg = SW_RESET_CORE_REG,
2491 .reset_mask = BIT(9),
2492 .halt_reg = DBG_BUS_VEC_A_REG,
2493 .halt_bit = 24,
2494 },
2495 .ns_reg = IJPEG_NS_REG,
2496 .md_reg = IJPEG_MD_REG,
2497 .root_en_mask = BIT(2),
2498 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
2499 .ctl_mask = BM(7, 6),
2500 .set_rate = set_rate_mnd,
2501 .freq_tbl = clk_tbl_ijpeg,
2502 .depends = &ijpeg_axi_clk.c,
2503 .current_freq = &local_dummy_freq,
2504 .c = {
2505 .dbg_name = "ijpeg_clk",
2506 .ops = &soc_clk_ops_8960,
2507 CLK_INIT(ijpeg_clk.c),
2508 },
2509};
2510
2511#define F_JPEGD(f, s, d, v) \
2512 { \
2513 .freq_hz = f, \
2514 .src_clk = &s##_clk.c, \
2515 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
2516 .sys_vdd = v, \
2517 }
2518static struct clk_freq_tbl clk_tbl_jpegd[] = {
2519 F_JPEGD( 0, gnd, 1, NONE),
2520 F_JPEGD( 64000000, pll8, 6, LOW),
2521 F_JPEGD( 76800000, pll8, 5, LOW),
2522 F_JPEGD( 96000000, pll8, 4, LOW),
2523 F_JPEGD(160000000, pll2, 5, NOMINAL),
2524 F_JPEGD(200000000, pll2, 4, NOMINAL),
2525 F_END
2526};
2527
2528static struct rcg_clk jpegd_clk = {
2529 .b = {
2530 .ctl_reg = JPEGD_CC_REG,
2531 .en_mask = BIT(0),
2532 .reset_reg = SW_RESET_CORE_REG,
2533 .reset_mask = BIT(19),
2534 .halt_reg = DBG_BUS_VEC_A_REG,
2535 .halt_bit = 19,
2536 },
2537 .ns_reg = JPEGD_NS_REG,
2538 .root_en_mask = BIT(2),
2539 .ns_mask = (BM(15, 12) | BM(2, 0)),
2540 .set_rate = set_rate_nop,
2541 .freq_tbl = clk_tbl_jpegd,
2542 .depends = &jpegd_axi_clk.c,
2543 .current_freq = &local_dummy_freq,
2544 .c = {
2545 .dbg_name = "jpegd_clk",
2546 .ops = &soc_clk_ops_8960,
2547 CLK_INIT(jpegd_clk.c),
2548 },
2549};
2550
2551#define F_MDP(f, s, m, n, v) \
2552 { \
2553 .freq_hz = f, \
2554 .src_clk = &s##_clk.c, \
2555 .md_val = MD8(8, m, 0, n), \
2556 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
2557 .ctl_val = CC_BANKED(9, 6, n), \
2558 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
2559 .sys_vdd = v, \
2560 }
2561static struct clk_freq_tbl clk_tbl_mdp[] = {
2562 F_MDP( 0, gnd, 0, 0, NONE),
2563 F_MDP( 9600000, pll8, 1, 40, LOW),
2564 F_MDP( 13710000, pll8, 1, 28, LOW),
2565 F_MDP( 27000000, pxo, 0, 0, LOW),
2566 F_MDP( 29540000, pll8, 1, 13, LOW),
2567 F_MDP( 34910000, pll8, 1, 11, LOW),
2568 F_MDP( 38400000, pll8, 1, 10, LOW),
2569 F_MDP( 59080000, pll8, 2, 13, LOW),
2570 F_MDP( 76800000, pll8, 1, 5, LOW),
2571 F_MDP( 85330000, pll8, 2, 9, LOW),
2572 F_MDP( 96000000, pll8, 1, 4, NOMINAL),
2573 F_MDP(128000000, pll8, 1, 3, NOMINAL),
2574 F_MDP(160000000, pll2, 1, 5, NOMINAL),
2575 F_MDP(177780000, pll2, 2, 9, NOMINAL),
2576 F_MDP(200000000, pll2, 1, 4, NOMINAL),
2577 F_END
2578};
2579
2580static struct bank_masks bmnd_info_mdp = {
2581 .bank_sel_mask = BIT(11),
2582 .bank0_mask = {
2583 .md_reg = MDP_MD0_REG,
2584 .ns_mask = BM(29, 22) | BM(5, 3),
2585 .rst_mask = BIT(31),
2586 .mnd_en_mask = BIT(8),
2587 .mode_mask = BM(10, 9),
2588 },
2589 .bank1_mask = {
2590 .md_reg = MDP_MD1_REG,
2591 .ns_mask = BM(21, 14) | BM(2, 0),
2592 .rst_mask = BIT(30),
2593 .mnd_en_mask = BIT(5),
2594 .mode_mask = BM(7, 6),
2595 },
2596};
2597
2598static struct rcg_clk mdp_clk = {
2599 .b = {
2600 .ctl_reg = MDP_CC_REG,
2601 .en_mask = BIT(0),
2602 .reset_reg = SW_RESET_CORE_REG,
2603 .reset_mask = BIT(21),
2604 .halt_reg = DBG_BUS_VEC_C_REG,
2605 .halt_bit = 10,
2606 },
2607 .ns_reg = MDP_NS_REG,
2608 .root_en_mask = BIT(2),
2609 .set_rate = set_rate_mnd_banked,
2610 .freq_tbl = clk_tbl_mdp,
2611 .bank_masks = &bmnd_info_mdp,
2612 .depends = &mdp_axi_clk.c,
2613 .current_freq = &local_dummy_freq,
2614 .c = {
2615 .dbg_name = "mdp_clk",
2616 .ops = &soc_clk_ops_8960,
2617 CLK_INIT(mdp_clk.c),
2618 },
2619};
2620
2621static struct branch_clk lut_mdp_clk = {
2622 .b = {
2623 .ctl_reg = MDP_LUT_CC_REG,
2624 .en_mask = BIT(0),
2625 .halt_reg = DBG_BUS_VEC_I_REG,
2626 .halt_bit = 13,
2627 },
2628 .parent = &mdp_clk.c,
2629 .c = {
2630 .dbg_name = "lut_mdp_clk",
2631 .ops = &clk_ops_branch,
2632 CLK_INIT(lut_mdp_clk.c),
2633 },
2634};
2635
2636#define F_MDP_VSYNC(f, s, v) \
2637 { \
2638 .freq_hz = f, \
2639 .src_clk = &s##_clk.c, \
2640 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
2641 .sys_vdd = v, \
2642 }
2643static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
2644 F_MDP_VSYNC(27000000, pxo, LOW),
2645 F_END
2646};
2647
2648static struct rcg_clk mdp_vsync_clk = {
2649 .b = {
2650 .ctl_reg = MISC_CC_REG,
2651 .en_mask = BIT(6),
2652 .reset_reg = SW_RESET_CORE_REG,
2653 .reset_mask = BIT(3),
2654 .halt_reg = DBG_BUS_VEC_B_REG,
2655 .halt_bit = 22,
2656 },
2657 .ns_reg = MISC_CC2_REG,
2658 .ns_mask = BIT(13),
2659 .set_rate = set_rate_nop,
2660 .freq_tbl = clk_tbl_mdp_vsync,
2661 .current_freq = &local_dummy_freq,
2662 .c = {
2663 .dbg_name = "mdp_vsync_clk",
2664 .ops = &soc_clk_ops_8960,
2665 CLK_INIT(mdp_vsync_clk.c),
2666 },
2667};
2668
2669#define F_ROT(f, s, d, v) \
2670 { \
2671 .freq_hz = f, \
2672 .src_clk = &s##_clk.c, \
2673 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
2674 21, 19, 18, 16, s##_to_mm_mux), \
2675 .sys_vdd = v, \
2676 }
2677static struct clk_freq_tbl clk_tbl_rot[] = {
2678 F_ROT( 0, gnd, 1, NONE),
2679 F_ROT( 27000000, pxo, 1, LOW),
2680 F_ROT( 29540000, pll8, 13, LOW),
2681 F_ROT( 32000000, pll8, 12, LOW),
2682 F_ROT( 38400000, pll8, 10, LOW),
2683 F_ROT( 48000000, pll8, 8, LOW),
2684 F_ROT( 54860000, pll8, 7, LOW),
2685 F_ROT( 64000000, pll8, 6, LOW),
2686 F_ROT( 76800000, pll8, 5, LOW),
2687 F_ROT( 96000000, pll8, 4, NOMINAL),
2688 F_ROT(100000000, pll2, 8, NOMINAL),
2689 F_ROT(114290000, pll2, 7, NOMINAL),
2690 F_ROT(133330000, pll2, 6, NOMINAL),
2691 F_ROT(160000000, pll2, 5, NOMINAL),
2692 F_END
2693};
2694
2695static struct bank_masks bdiv_info_rot = {
2696 .bank_sel_mask = BIT(30),
2697 .bank0_mask = {
2698 .ns_mask = BM(25, 22) | BM(18, 16),
2699 },
2700 .bank1_mask = {
2701 .ns_mask = BM(29, 26) | BM(21, 19),
2702 },
2703};
2704
2705static struct rcg_clk rot_clk = {
2706 .b = {
2707 .ctl_reg = ROT_CC_REG,
2708 .en_mask = BIT(0),
2709 .reset_reg = SW_RESET_CORE_REG,
2710 .reset_mask = BIT(2),
2711 .halt_reg = DBG_BUS_VEC_C_REG,
2712 .halt_bit = 15,
2713 },
2714 .ns_reg = ROT_NS_REG,
2715 .root_en_mask = BIT(2),
2716 .set_rate = set_rate_div_banked,
2717 .freq_tbl = clk_tbl_rot,
2718 .bank_masks = &bdiv_info_rot,
2719 .current_freq = &local_dummy_freq,
2720 .depends = &rot_axi_clk.c,
2721 .c = {
2722 .dbg_name = "rot_clk",
2723 .ops = &soc_clk_ops_8960,
2724 CLK_INIT(rot_clk.c),
2725 },
2726};
2727
2728static int hdmi_pll_clk_enable(struct clk *clk)
2729{
2730 int ret;
2731 unsigned long flags;
2732 spin_lock_irqsave(&local_clock_reg_lock, flags);
2733 ret = hdmi_pll_enable();
2734 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2735 return ret;
2736}
2737
2738static void hdmi_pll_clk_disable(struct clk *clk)
2739{
2740 unsigned long flags;
2741 spin_lock_irqsave(&local_clock_reg_lock, flags);
2742 hdmi_pll_disable();
2743 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2744}
2745
2746static unsigned hdmi_pll_clk_get_rate(struct clk *clk)
2747{
2748 return hdmi_pll_get_rate();
2749}
2750
2751static struct clk_ops clk_ops_hdmi_pll = {
2752 .enable = hdmi_pll_clk_enable,
2753 .disable = hdmi_pll_clk_disable,
2754 .get_rate = hdmi_pll_clk_get_rate,
2755 .is_local = local_clk_is_local,
2756};
2757
2758static struct clk hdmi_pll_clk = {
2759 .dbg_name = "hdmi_pll_clk",
2760 .ops = &clk_ops_hdmi_pll,
2761 CLK_INIT(hdmi_pll_clk),
2762};
2763
2764#define F_TV_GND(f, s, p_r, d, m, n, v) \
2765 { \
2766 .freq_hz = f, \
2767 .src_clk = &s##_clk.c, \
2768 .md_val = MD8(8, m, 0, n), \
2769 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2770 .ctl_val = CC(6, n), \
2771 .mnd_en_mask = BIT(5) * !!(n), \
2772 .sys_vdd = v, \
2773 }
2774#define F_TV(f, s, p_r, d, m, n, v) \
2775 { \
2776 .freq_hz = f, \
2777 .src_clk = &s##_clk, \
2778 .md_val = MD8(8, m, 0, n), \
2779 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2780 .ctl_val = CC(6, n), \
2781 .mnd_en_mask = BIT(5) * !!(n), \
2782 .sys_vdd = v, \
2783 .extra_freq_data = (void *)p_r, \
2784 }
2785/* Switching TV freqs requires PLL reconfiguration. */
2786static struct clk_freq_tbl clk_tbl_tv[] = {
2787 F_TV_GND( 0, gnd, 0, 1, 0, 0, NONE),
2788 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0, LOW),
2789 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0, LOW),
2790 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0, LOW),
2791 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0, NOMINAL),
2792 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0, NOMINAL),
2793 F_END
2794};
2795
2796/*
2797 * Unlike other clocks, the TV rate is adjusted through PLL
2798 * re-programming. It is also routed through an MND divider.
2799 */
2800void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
2801{
2802 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
2803 if (pll_rate)
2804 hdmi_pll_set_rate(pll_rate);
2805 set_rate_mnd(clk, nf);
2806}
2807
2808static struct rcg_clk tv_src_clk = {
2809 .ns_reg = TV_NS_REG,
2810 .b = {
2811 .ctl_reg = TV_CC_REG,
2812 .halt_check = NOCHECK,
2813 },
2814 .md_reg = TV_MD_REG,
2815 .root_en_mask = BIT(2),
2816 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
2817 .ctl_mask = BM(7, 6),
2818 .set_rate = set_rate_tv,
2819 .freq_tbl = clk_tbl_tv,
2820 .current_freq = &local_dummy_freq,
2821 .c = {
2822 .dbg_name = "tv_src_clk",
2823 .ops = &soc_clk_ops_8960,
2824 CLK_INIT(tv_src_clk.c),
2825 },
2826};
2827
2828static struct branch_clk tv_enc_clk = {
2829 .b = {
2830 .ctl_reg = TV_CC_REG,
2831 .en_mask = BIT(8),
2832 .reset_reg = SW_RESET_CORE_REG,
2833 .reset_mask = BIT(0),
2834 .halt_reg = DBG_BUS_VEC_D_REG,
2835 .halt_bit = 9,
2836 },
2837 .parent = &tv_src_clk.c,
2838 .c = {
2839 .dbg_name = "tv_enc_clk",
2840 .ops = &clk_ops_branch,
2841 CLK_INIT(tv_enc_clk.c),
2842 },
2843};
2844
2845static struct branch_clk tv_dac_clk = {
2846 .b = {
2847 .ctl_reg = TV_CC_REG,
2848 .en_mask = BIT(10),
2849 .halt_reg = DBG_BUS_VEC_D_REG,
2850 .halt_bit = 10,
2851 },
2852 .parent = &tv_src_clk.c,
2853 .c = {
2854 .dbg_name = "tv_dac_clk",
2855 .ops = &clk_ops_branch,
2856 CLK_INIT(tv_dac_clk.c),
2857 },
2858};
2859
2860static struct branch_clk mdp_tv_clk = {
2861 .b = {
2862 .ctl_reg = TV_CC_REG,
2863 .en_mask = BIT(0),
2864 .reset_reg = SW_RESET_CORE_REG,
2865 .reset_mask = BIT(4),
2866 .halt_reg = DBG_BUS_VEC_D_REG,
2867 .halt_bit = 12,
2868 },
2869 .parent = &tv_src_clk.c,
2870 .c = {
2871 .dbg_name = "mdp_tv_clk",
2872 .ops = &clk_ops_branch,
2873 CLK_INIT(mdp_tv_clk.c),
2874 },
2875};
2876
2877static struct branch_clk hdmi_tv_clk = {
2878 .b = {
2879 .ctl_reg = TV_CC_REG,
2880 .en_mask = BIT(12),
2881 .reset_reg = SW_RESET_CORE_REG,
2882 .reset_mask = BIT(1),
2883 .halt_reg = DBG_BUS_VEC_D_REG,
2884 .halt_bit = 11,
2885 },
2886 .parent = &tv_src_clk.c,
2887 .c = {
2888 .dbg_name = "hdmi_tv_clk",
2889 .ops = &clk_ops_branch,
2890 CLK_INIT(hdmi_tv_clk.c),
2891 },
2892};
2893
2894static struct branch_clk hdmi_app_clk = {
2895 .b = {
2896 .ctl_reg = MISC_CC2_REG,
2897 .en_mask = BIT(11),
2898 .reset_reg = SW_RESET_CORE_REG,
2899 .reset_mask = BIT(11),
2900 .halt_reg = DBG_BUS_VEC_B_REG,
2901 .halt_bit = 25,
2902 },
2903 .c = {
2904 .dbg_name = "hdmi_app_clk",
2905 .ops = &clk_ops_branch,
2906 CLK_INIT(hdmi_app_clk.c),
2907 },
2908};
2909
2910static struct bank_masks bmnd_info_vcodec = {
2911 .bank_sel_mask = BIT(13),
2912 .bank0_mask = {
2913 .md_reg = VCODEC_MD0_REG,
2914 .ns_mask = BM(18, 11) | BM(2, 0),
2915 .rst_mask = BIT(31),
2916 .mnd_en_mask = BIT(5),
2917 .mode_mask = BM(7, 6),
2918 },
2919 .bank1_mask = {
2920 .md_reg = VCODEC_MD1_REG,
2921 .ns_mask = BM(26, 19) | BM(29, 27),
2922 .rst_mask = BIT(30),
2923 .mnd_en_mask = BIT(10),
2924 .mode_mask = BM(12, 11),
2925 },
2926};
2927#define F_VCODEC(f, s, m, n, v) \
2928 { \
2929 .freq_hz = f, \
2930 .src_clk = &s##_clk.c, \
2931 .md_val = MD8(8, m, 0, n), \
2932 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
2933 .ctl_val = CC_BANKED(6, 11, n), \
2934 .mnd_en_mask = (BIT(10) | BIT(5)) * !!(n), \
2935 .sys_vdd = v, \
2936 }
2937static struct clk_freq_tbl clk_tbl_vcodec[] = {
2938 F_VCODEC( 0, gnd, 0, 0, NONE),
2939 F_VCODEC( 27000000, pxo, 0, 0, LOW),
2940 F_VCODEC( 32000000, pll8, 1, 12, LOW),
2941 F_VCODEC( 48000000, pll8, 1, 8, LOW),
2942 F_VCODEC( 54860000, pll8, 1, 7, LOW),
2943 F_VCODEC( 96000000, pll8, 1, 4, LOW),
2944 F_VCODEC(133330000, pll2, 1, 6, NOMINAL),
2945 F_VCODEC(200000000, pll2, 1, 4, NOMINAL),
2946 F_VCODEC(228570000, pll2, 2, 7, HIGH),
2947 F_END
2948};
2949
2950static struct rcg_clk vcodec_clk = {
2951 .b = {
2952 .ctl_reg = VCODEC_CC_REG,
2953 .en_mask = BIT(0),
2954 .reset_reg = SW_RESET_CORE_REG,
2955 .reset_mask = BIT(6),
2956 .halt_reg = DBG_BUS_VEC_C_REG,
2957 .halt_bit = 29,
2958 },
2959 .ns_reg = VCODEC_NS_REG,
2960 .root_en_mask = BIT(2),
2961 .set_rate = set_rate_mnd_banked,
2962 .bank_masks = &bmnd_info_vcodec,
2963 .freq_tbl = clk_tbl_vcodec,
2964 .depends = &vcodec_axi_clk.c,
2965 .current_freq = &local_dummy_freq,
2966 .c = {
2967 .dbg_name = "vcodec_clk",
2968 .ops = &soc_clk_ops_8960,
2969 CLK_INIT(vcodec_clk.c),
2970 },
2971};
2972
2973#define F_VPE(f, s, d, v) \
2974 { \
2975 .freq_hz = f, \
2976 .src_clk = &s##_clk.c, \
2977 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
2978 .sys_vdd = v, \
2979 }
2980static struct clk_freq_tbl clk_tbl_vpe[] = {
2981 F_VPE( 0, gnd, 1, NONE),
2982 F_VPE( 27000000, pxo, 1, LOW),
2983 F_VPE( 34909000, pll8, 11, LOW),
2984 F_VPE( 38400000, pll8, 10, LOW),
2985 F_VPE( 64000000, pll8, 6, LOW),
2986 F_VPE( 76800000, pll8, 5, LOW),
2987 F_VPE( 96000000, pll8, 4, NOMINAL),
2988 F_VPE(100000000, pll2, 8, NOMINAL),
2989 F_VPE(160000000, pll2, 5, NOMINAL),
2990 F_END
2991};
2992
2993static struct rcg_clk vpe_clk = {
2994 .b = {
2995 .ctl_reg = VPE_CC_REG,
2996 .en_mask = BIT(0),
2997 .reset_reg = SW_RESET_CORE_REG,
2998 .reset_mask = BIT(17),
2999 .halt_reg = DBG_BUS_VEC_A_REG,
3000 .halt_bit = 28,
3001 },
3002 .ns_reg = VPE_NS_REG,
3003 .root_en_mask = BIT(2),
3004 .ns_mask = (BM(15, 12) | BM(2, 0)),
3005 .set_rate = set_rate_nop,
3006 .freq_tbl = clk_tbl_vpe,
3007 .current_freq = &local_dummy_freq,
3008 .depends = &vpe_axi_clk.c,
3009 .c = {
3010 .dbg_name = "vpe_clk",
3011 .ops = &soc_clk_ops_8960,
3012 CLK_INIT(vpe_clk.c),
3013 },
3014};
3015
3016#define F_VFE(f, s, d, m, n, v) \
3017 { \
3018 .freq_hz = f, \
3019 .src_clk = &s##_clk.c, \
3020 .md_val = MD8(8, m, 0, n), \
3021 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
3022 .ctl_val = CC(6, n), \
3023 .mnd_en_mask = BIT(5) * !!(n), \
3024 .sys_vdd = v, \
3025 }
3026static struct clk_freq_tbl clk_tbl_vfe[] = {
3027 F_VFE( 0, gnd, 1, 0, 0, NONE),
3028 F_VFE( 13960000, pll8, 1, 2, 55, LOW),
3029 F_VFE( 27000000, pxo, 1, 0, 0, LOW),
3030 F_VFE( 36570000, pll8, 1, 2, 21, LOW),
3031 F_VFE( 38400000, pll8, 2, 1, 5, LOW),
3032 F_VFE( 45180000, pll8, 1, 2, 17, LOW),
3033 F_VFE( 48000000, pll8, 2, 1, 4, LOW),
3034 F_VFE( 54860000, pll8, 1, 1, 7, LOW),
3035 F_VFE( 64000000, pll8, 2, 1, 3, LOW),
3036 F_VFE( 76800000, pll8, 1, 1, 5, LOW),
3037 F_VFE( 96000000, pll8, 2, 1, 2, LOW),
3038 F_VFE(109710000, pll8, 1, 2, 7, LOW),
3039 F_VFE(128000000, pll8, 1, 1, 3, NOMINAL),
3040 F_VFE(153600000, pll8, 1, 2, 5, NOMINAL),
3041 F_VFE(200000000, pll2, 2, 1, 2, NOMINAL),
3042 F_VFE(228570000, pll2, 1, 2, 7, NOMINAL),
3043 F_VFE(266667000, pll2, 1, 1, 3, NOMINAL),
3044 F_END
3045};
3046
3047
3048static struct rcg_clk vfe_clk = {
3049 .b = {
3050 .ctl_reg = VFE_CC_REG,
3051 .reset_reg = SW_RESET_CORE_REG,
3052 .reset_mask = BIT(15),
3053 .halt_reg = DBG_BUS_VEC_B_REG,
3054 .halt_bit = 6,
3055 .en_mask = BIT(0),
3056 },
3057 .ns_reg = VFE_NS_REG,
3058 .md_reg = VFE_MD_REG,
3059 .root_en_mask = BIT(2),
3060 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
3061 .ctl_mask = BM(7, 6),
3062 .set_rate = set_rate_mnd,
3063 .freq_tbl = clk_tbl_vfe,
3064 .depends = &vfe_axi_clk.c,
3065 .current_freq = &local_dummy_freq,
3066 .c = {
3067 .dbg_name = "vfe_clk",
3068 .ops = &soc_clk_ops_8960,
3069 CLK_INIT(vfe_clk.c),
3070 },
3071};
3072
3073static struct branch_clk csi0_vfe_clk = {
3074 .b = {
3075 .ctl_reg = VFE_CC_REG,
3076 .en_mask = BIT(12),
3077 .reset_reg = SW_RESET_CORE_REG,
3078 .reset_mask = BIT(24),
3079 .halt_reg = DBG_BUS_VEC_B_REG,
3080 .halt_bit = 8,
3081 },
3082 .parent = &vfe_clk.c,
3083 .c = {
3084 .dbg_name = "csi0_vfe_clk",
3085 .ops = &clk_ops_branch,
3086 CLK_INIT(csi0_vfe_clk.c),
3087 },
3088};
3089
3090/*
3091 * Low Power Audio Clocks
3092 */
3093#define F_AIF_OSR(f, s, d, m, n, v) \
3094 { \
3095 .freq_hz = f, \
3096 .src_clk = &s##_clk.c, \
3097 .md_val = MD8(8, m, 0, n), \
3098 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
3099 .mnd_en_mask = BIT(8) * !!(n), \
3100 .sys_vdd = v, \
3101 }
3102static struct clk_freq_tbl clk_tbl_aif_osr[] = {
3103 F_AIF_OSR( 0, gnd, 1, 0, 0, NONE),
3104 F_AIF_OSR( 768000, pll4, 4, 1, 128, LOW),
3105 F_AIF_OSR( 1024000, pll4, 4, 1, 96, LOW),
3106 F_AIF_OSR( 1536000, pll4, 4, 1, 64, LOW),
3107 F_AIF_OSR( 2048000, pll4, 4, 1, 48, LOW),
3108 F_AIF_OSR( 3072000, pll4, 4, 1, 32, LOW),
3109 F_AIF_OSR( 4096000, pll4, 4, 1, 24, LOW),
3110 F_AIF_OSR( 6144000, pll4, 4, 1, 16, LOW),
3111 F_AIF_OSR( 8192000, pll4, 4, 1, 12, LOW),
3112 F_AIF_OSR(12288000, pll4, 4, 1, 8, LOW),
3113 F_AIF_OSR(24576000, pll4, 4, 1, 4, LOW),
3114 F_END
3115};
3116
3117#define CLK_AIF_OSR(i, ns, md, h_r) \
3118 struct rcg_clk i##_clk = { \
3119 .b = { \
3120 .ctl_reg = ns, \
3121 .en_mask = BIT(17), \
3122 .reset_reg = ns, \
3123 .reset_mask = BIT(19), \
3124 .halt_reg = h_r, \
3125 .halt_check = ENABLE, \
3126 .halt_bit = 1, \
3127 }, \
3128 .ns_reg = ns, \
3129 .md_reg = md, \
3130 .root_en_mask = BIT(9), \
3131 .ns_mask = (BM(31, 24) | BM(6, 0)), \
3132 .set_rate = set_rate_mnd, \
3133 .freq_tbl = clk_tbl_aif_osr, \
3134 .current_freq = &local_dummy_freq, \
3135 .c = { \
3136 .dbg_name = #i "_clk", \
3137 .ops = &soc_clk_ops_8960, \
3138 CLK_INIT(i##_clk.c), \
3139 }, \
3140 }
3141#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
3142 struct rcg_clk i##_clk = { \
3143 .b = { \
3144 .ctl_reg = ns, \
3145 .en_mask = BIT(21), \
3146 .reset_reg = ns, \
3147 .reset_mask = BIT(23), \
3148 .halt_reg = h_r, \
3149 .halt_check = ENABLE, \
3150 .halt_bit = 1, \
3151 }, \
3152 .ns_reg = ns, \
3153 .md_reg = md, \
3154 .root_en_mask = BIT(9), \
3155 .ns_mask = (BM(31, 24) | BM(6, 0)), \
3156 .set_rate = set_rate_mnd, \
3157 .freq_tbl = clk_tbl_aif_osr, \
3158 .current_freq = &local_dummy_freq, \
3159 .c = { \
3160 .dbg_name = #i "_clk", \
3161 .ops = &soc_clk_ops_8960, \
3162 CLK_INIT(i##_clk.c), \
3163 }, \
3164 }
3165
3166#define F_AIF_BIT(d, s) \
3167 { \
3168 .freq_hz = d, \
3169 .ns_val = (BVAL(14, 14, s) | BVAL(13, 10, (d-1))) \
3170 }
3171static struct clk_freq_tbl clk_tbl_aif_bit[] = {
3172 F_AIF_BIT(0, 1), /* Use external clock. */
3173 F_AIF_BIT(1, 0), F_AIF_BIT(2, 0), F_AIF_BIT(3, 0), F_AIF_BIT(4, 0),
3174 F_AIF_BIT(5, 0), F_AIF_BIT(6, 0), F_AIF_BIT(7, 0), F_AIF_BIT(8, 0),
3175 F_AIF_BIT(9, 0), F_AIF_BIT(10, 0), F_AIF_BIT(11, 0), F_AIF_BIT(12, 0),
3176 F_AIF_BIT(13, 0), F_AIF_BIT(14, 0), F_AIF_BIT(15, 0), F_AIF_BIT(16, 0),
3177 F_END
3178};
3179
3180#define CLK_AIF_BIT(i, ns, h_r) \
3181 struct rcg_clk i##_clk = { \
3182 .b = { \
3183 .ctl_reg = ns, \
3184 .en_mask = BIT(15), \
3185 .halt_reg = h_r, \
3186 .halt_check = DELAY, \
3187 }, \
3188 .ns_reg = ns, \
3189 .ns_mask = BM(14, 10), \
3190 .set_rate = set_rate_nop, \
3191 .freq_tbl = clk_tbl_aif_bit, \
3192 .current_freq = &local_dummy_freq, \
3193 .c = { \
3194 .dbg_name = #i "_clk", \
3195 .ops = &soc_clk_ops_8960, \
3196 CLK_INIT(i##_clk.c), \
3197 }, \
3198 }
3199
3200#define F_AIF_BIT_D(d, s) \
3201 { \
3202 .freq_hz = d, \
3203 .ns_val = (BVAL(18, 18, s) | BVAL(17, 10, (d-1))) \
3204 }
3205static struct clk_freq_tbl clk_tbl_aif_bit_div[] = {
3206 F_AIF_BIT_D(0, 1), /* Use external clock. */
3207 F_AIF_BIT_D(1, 0), F_AIF_BIT_D(2, 0), F_AIF_BIT_D(3, 0),
3208 F_AIF_BIT_D(4, 0), F_AIF_BIT_D(5, 0), F_AIF_BIT_D(6, 0),
3209 F_AIF_BIT_D(7, 0), F_AIF_BIT_D(8, 0), F_AIF_BIT_D(9, 0),
3210 F_AIF_BIT_D(10, 0), F_AIF_BIT_D(11, 0), F_AIF_BIT_D(12, 0),
3211 F_AIF_BIT_D(13, 0), F_AIF_BIT_D(14, 0), F_AIF_BIT_D(15, 0),
3212 F_AIF_BIT_D(16, 0),
3213 F_END
3214};
3215
3216#define CLK_AIF_BIT_DIV(i, ns, h_r) \
3217 struct rcg_clk i##_clk = { \
3218 .b = { \
3219 .ctl_reg = ns, \
3220 .en_mask = BIT(19), \
3221 .halt_reg = h_r, \
3222 .halt_check = ENABLE, \
3223 }, \
3224 .ns_reg = ns, \
3225 .ns_mask = BM(18, 10), \
3226 .set_rate = set_rate_nop, \
3227 .freq_tbl = clk_tbl_aif_bit_div, \
3228 .current_freq = &local_dummy_freq, \
3229 .c = { \
3230 .dbg_name = #i "_clk", \
3231 .ops = &soc_clk_ops_8960, \
3232 CLK_INIT(i##_clk.c), \
3233 }, \
3234 }
3235
3236static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
3237 LCC_MI2S_STATUS_REG);
3238static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
3239
3240static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
3241 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
3242static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
3243 LCC_CODEC_I2S_MIC_STATUS_REG);
3244
3245static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
3246 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
3247static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
3248 LCC_SPARE_I2S_MIC_STATUS_REG);
3249
3250static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
3251 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
3252static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
3253 LCC_CODEC_I2S_SPKR_STATUS_REG);
3254
3255static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
3256 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
3257static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
3258 LCC_SPARE_I2S_SPKR_STATUS_REG);
3259
3260#define F_PCM(f, s, d, m, n, v) \
3261 { \
3262 .freq_hz = f, \
3263 .src_clk = &s##_clk.c, \
3264 .md_val = MD16(m, n), \
3265 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
3266 .mnd_en_mask = BIT(8) * !!(n), \
3267 .sys_vdd = v, \
3268 }
3269static struct clk_freq_tbl clk_tbl_pcm[] = {
3270 F_PCM( 0, gnd, 1, 0, 0, NONE),
3271 F_PCM( 512000, pll4, 4, 1, 192, LOW),
3272 F_PCM( 768000, pll4, 4, 1, 128, LOW),
3273 F_PCM( 1024000, pll4, 4, 1, 96, LOW),
3274 F_PCM( 1536000, pll4, 4, 1, 64, LOW),
3275 F_PCM( 2048000, pll4, 4, 1, 48, LOW),
3276 F_PCM( 3072000, pll4, 4, 1, 32, LOW),
3277 F_PCM( 4096000, pll4, 4, 1, 24, LOW),
3278 F_PCM( 6144000, pll4, 4, 1, 16, LOW),
3279 F_PCM( 8192000, pll4, 4, 1, 12, LOW),
3280 F_PCM(12288000, pll4, 4, 1, 8, LOW),
3281 F_PCM(24576000, pll4, 4, 1, 4, LOW),
3282 F_END
3283};
3284
3285static struct rcg_clk pcm_clk = {
3286 .b = {
3287 .ctl_reg = LCC_PCM_NS_REG,
3288 .en_mask = BIT(11),
3289 .reset_reg = LCC_PCM_NS_REG,
3290 .reset_mask = BIT(13),
3291 .halt_reg = LCC_PCM_STATUS_REG,
3292 .halt_check = ENABLE,
3293 .halt_bit = 0,
3294 },
3295 .ns_reg = LCC_PCM_NS_REG,
3296 .md_reg = LCC_PCM_MD_REG,
3297 .root_en_mask = BIT(9),
3298 .ns_mask = (BM(31, 16) | BM(6, 0)),
3299 .set_rate = set_rate_mnd,
3300 .freq_tbl = clk_tbl_pcm,
3301 .current_freq = &local_dummy_freq,
3302 .c = {
3303 .dbg_name = "pcm_clk",
3304 .ops = &soc_clk_ops_8960,
3305 CLK_INIT(pcm_clk.c),
3306 },
3307};
3308
3309static struct rcg_clk audio_slimbus_clk = {
3310 .b = {
3311 .ctl_reg = LCC_SLIMBUS_NS_REG,
3312 .en_mask = BIT(10),
3313 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
3314 .reset_mask = BIT(5),
3315 .halt_reg = LCC_SLIMBUS_STATUS_REG,
3316 .halt_check = ENABLE,
3317 .halt_bit = 0,
3318 },
3319 .ns_reg = LCC_SLIMBUS_NS_REG,
3320 .md_reg = LCC_SLIMBUS_MD_REG,
3321 .root_en_mask = BIT(9),
3322 .ns_mask = (BM(31, 24) | BM(6, 0)),
3323 .set_rate = set_rate_mnd,
3324 .freq_tbl = clk_tbl_aif_osr,
3325 .current_freq = &local_dummy_freq,
3326 .c = {
3327 .dbg_name = "audio_slimbus_clk",
3328 .ops = &soc_clk_ops_8960,
3329 CLK_INIT(audio_slimbus_clk.c),
3330 },
3331};
3332
3333static struct branch_clk sps_slimbus_clk = {
3334 .b = {
3335 .ctl_reg = LCC_SLIMBUS_NS_REG,
3336 .en_mask = BIT(12),
3337 .halt_reg = LCC_SLIMBUS_STATUS_REG,
3338 .halt_check = ENABLE,
3339 .halt_bit = 1,
3340 },
3341 .parent = &audio_slimbus_clk.c,
3342 .c = {
3343 .dbg_name = "sps_slimbus_clk",
3344 .ops = &clk_ops_branch,
3345 CLK_INIT(sps_slimbus_clk.c),
3346 },
3347};
3348
3349static struct branch_clk slimbus_xo_src_clk = {
3350 .b = {
3351 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
3352 .en_mask = BIT(2),
3353 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003354 .halt_bit = 28,
3355 },
3356 .parent = &sps_slimbus_clk.c,
3357 .c = {
3358 .dbg_name = "slimbus_xo_src_clk",
3359 .ops = &clk_ops_branch,
3360 CLK_INIT(slimbus_xo_src_clk.c),
3361 },
3362};
3363
3364DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC);
3365DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB);
3366DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC);
3367DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1);
3368DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC);
3369DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB);
3370DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC);
3371DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB);
3372
3373static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
3374static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
3375static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
3376static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
3377static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
3378static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
3379static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
3380static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
3381
3382static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
3383/*
3384 * TODO: replace dummy_clk below with ebi1_clk.c once the
3385 * bus driver starts voting on ebi1 rates.
3386 */
3387static DEFINE_CLK_VOTER(ebi1_adm_clk, &dummy_clk);
3388
3389#ifdef CONFIG_DEBUG_FS
3390struct measure_sel {
3391 u32 test_vector;
3392 struct clk *clk;
3393};
3394
3395static struct measure_sel measure_mux[] = {
3396 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
3397 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
3398 { TEST_PER_LS(0x13), &sdc1_clk.c },
3399 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
3400 { TEST_PER_LS(0x15), &sdc2_clk.c },
3401 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
3402 { TEST_PER_LS(0x17), &sdc3_clk.c },
3403 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
3404 { TEST_PER_LS(0x19), &sdc4_clk.c },
3405 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
3406 { TEST_PER_LS(0x1B), &sdc5_clk.c },
3407 { TEST_PER_LS(0x25), &dfab_clk.c },
3408 { TEST_PER_LS(0x25), &dfab_a_clk.c },
3409 { TEST_PER_LS(0x26), &pmem_clk.c },
3410 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
3411 { TEST_PER_LS(0x33), &cfpb_clk.c },
3412 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
3413 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
3414 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
3415 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
3416 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
3417 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
3418 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
3419 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
3420 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
3421 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
3422 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
3423 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
3424 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
3425 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
3426 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
3427 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
3428 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
3429 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
3430 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
3431 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
3432 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
3433 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
3434 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
3435 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
3436 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
3437 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
3438 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
3439 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
3440 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
3441 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
3442 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
3443 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
3444 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
3445 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
3446 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
3447 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
3448 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
3449 { TEST_PER_LS(0x78), &sfpb_clk.c },
3450 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
3451 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
3452 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
3453 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
3454 { TEST_PER_LS(0x7D), &prng_clk.c },
3455 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
3456 { TEST_PER_LS(0x80), &adm0_p_clk.c },
3457 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
3458 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
3459 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
3460 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
3461 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
3462 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
3463 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
3464 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
3465 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
3466 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
3467 { TEST_PER_LS(0x92), &ce1_p_clk.c },
3468 { TEST_PER_LS(0x94), &tssc_clk.c },
3469 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
3470
3471 { TEST_PER_HS(0x07), &afab_clk.c },
3472 { TEST_PER_HS(0x07), &afab_a_clk.c },
3473 { TEST_PER_HS(0x18), &sfab_clk.c },
3474 { TEST_PER_HS(0x18), &sfab_a_clk.c },
3475 { TEST_PER_HS(0x2A), &adm0_clk.c },
3476 { TEST_PER_HS(0x34), &ebi1_clk.c },
3477 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
3478
3479 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
3480 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
3481 { TEST_MM_LS(0x02), &cam1_clk.c },
3482 { TEST_MM_LS(0x06), &amp_p_clk.c },
3483 { TEST_MM_LS(0x07), &csi0_p_clk.c },
3484 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
3485 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
3486 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
3487 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
3488 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
3489 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
3490 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
3491 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
3492 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
3493 { TEST_MM_LS(0x12), &imem_p_clk.c },
3494 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
3495 { TEST_MM_LS(0x14), &mdp_p_clk.c },
3496 { TEST_MM_LS(0x16), &rot_p_clk.c },
3497 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
3498 { TEST_MM_LS(0x18), &smmu_p_clk.c },
3499 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
3500 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
3501 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
3502 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
3503 { TEST_MM_LS(0x1D), &cam0_clk.c },
3504 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
3505 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
3506 { TEST_MM_LS(0x21), &tv_dac_clk.c },
3507 { TEST_MM_LS(0x22), &tv_enc_clk.c },
3508 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
3509 { TEST_MM_LS(0x25), &mmfpb_clk.c },
3510 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
3511 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
3512
3513 { TEST_MM_HS(0x00), &csi0_clk.c },
3514 { TEST_MM_HS(0x01), &csi1_clk.c },
3515 { TEST_MM_HS(0x04), &csi0_vfe_clk.c },
3516 { TEST_MM_HS(0x05), &ijpeg_clk.c },
3517 { TEST_MM_HS(0x06), &vfe_clk.c },
3518 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
3519 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
3520 { TEST_MM_HS(0x09), &gfx3d_clk.c },
3521 { TEST_MM_HS(0x0A), &jpegd_clk.c },
3522 { TEST_MM_HS(0x0B), &vcodec_clk.c },
3523 { TEST_MM_HS(0x0F), &mmfab_clk.c },
3524 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
3525 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
3526 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
3527 { TEST_MM_HS(0x13), &imem_axi_clk.c },
3528 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
3529 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
3530 { TEST_MM_HS(0x16), &rot_axi_clk.c },
3531 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
3532 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
3533 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
3534 { TEST_MM_HS(0x1A), &mdp_clk.c },
3535 { TEST_MM_HS(0x1B), &rot_clk.c },
3536 { TEST_MM_HS(0x1C), &vpe_clk.c },
3537 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
3538 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
3539 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
3540 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
3541 { TEST_MM_HS(0x26), &csi_pix_clk.c },
3542 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
3543 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
3544 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
3545 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
3546 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
3547 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
3548
3549 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
3550 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
3551 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
3552 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
3553 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
3554 { TEST_LPA(0x14), &pcm_clk.c },
3555 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
3556};
3557
3558static struct measure_sel *find_measure_sel(struct clk *clk)
3559{
3560 int i;
3561
3562 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
3563 if (measure_mux[i].clk == clk)
3564 return &measure_mux[i];
3565 return NULL;
3566}
3567
3568static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
3569{
3570 int ret = 0;
3571 u32 clk_sel;
3572 struct measure_sel *p;
3573 unsigned long flags;
3574
3575 if (!parent)
3576 return -EINVAL;
3577
3578 p = find_measure_sel(parent);
3579 if (!p)
3580 return -EINVAL;
3581
3582 spin_lock_irqsave(&local_clock_reg_lock, flags);
3583
3584 /* Program the test vector. */
3585 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
3586 switch (p->test_vector >> TEST_TYPE_SHIFT) {
3587 case TEST_TYPE_PER_LS:
3588 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
3589 break;
3590 case TEST_TYPE_PER_HS:
3591 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
3592 break;
3593 case TEST_TYPE_MM_LS:
3594 writel_relaxed(0x4030D97, CLK_TEST_REG);
3595 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
3596 break;
3597 case TEST_TYPE_MM_HS:
3598 writel_relaxed(0x402B800, CLK_TEST_REG);
3599 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
3600 break;
3601 case TEST_TYPE_LPA:
3602 writel_relaxed(0x4030D98, CLK_TEST_REG);
3603 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
3604 LCC_CLK_LS_DEBUG_CFG_REG);
3605 break;
3606 default:
3607 ret = -EPERM;
3608 }
3609 /* Make sure test vector is set before starting measurements. */
3610 mb();
3611
3612 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3613
3614 return ret;
3615}
3616
3617/* Sample clock for 'ticks' reference clock ticks. */
3618static u32 run_measurement(unsigned ticks)
3619{
3620 /* Stop counters and set the XO4 counter start value. */
3621 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
3622 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
3623
3624 /* Wait for timer to become ready. */
3625 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
3626 cpu_relax();
3627
3628 /* Run measurement and wait for completion. */
3629 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
3630 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
3631 cpu_relax();
3632
3633 /* Stop counters. */
3634 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
3635
3636 /* Return measured ticks. */
3637 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
3638}
3639
3640
3641/* Perform a hardware rate measurement for a given clock.
3642 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
3643static unsigned measure_clk_get_rate(struct clk *clk)
3644{
3645 unsigned long flags;
3646 u32 pdm_reg_backup, ringosc_reg_backup;
3647 u64 raw_count_short, raw_count_full;
3648 unsigned ret;
3649
3650 spin_lock_irqsave(&local_clock_reg_lock, flags);
3651
3652 /* Enable CXO/4 and RINGOSC branch and root. */
3653 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
3654 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
3655 writel_relaxed(0x2898, PDM_CLK_NS_REG);
3656 writel_relaxed(0xA00, RINGOSC_NS_REG);
3657
3658 /*
3659 * The ring oscillator counter will not reset if the measured clock
3660 * is not running. To detect this, run a short measurement before
3661 * the full measurement. If the raw results of the two are the same
3662 * then the clock must be off.
3663 */
3664
3665 /* Run a short measurement. (~1 ms) */
3666 raw_count_short = run_measurement(0x1000);
3667 /* Run a full measurement. (~14 ms) */
3668 raw_count_full = run_measurement(0x10000);
3669
3670 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
3671 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
3672
3673 /* Return 0 if the clock is off. */
3674 if (raw_count_full == raw_count_short)
3675 ret = 0;
3676 else {
3677 /* Compute rate in Hz. */
3678 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
3679 do_div(raw_count_full, ((0x10000 * 10) + 35));
3680 ret = raw_count_full;
3681 }
3682
3683 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07003684 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003685 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3686
3687 return ret;
3688}
3689#else /* !CONFIG_DEBUG_FS */
3690static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
3691{
3692 return -EINVAL;
3693}
3694
3695static unsigned measure_clk_get_rate(struct clk *clk)
3696{
3697 return 0;
3698}
3699#endif /* CONFIG_DEBUG_FS */
3700
3701static struct clk_ops measure_clk_ops = {
3702 .set_parent = measure_clk_set_parent,
3703 .get_rate = measure_clk_get_rate,
3704 .is_local = local_clk_is_local,
3705};
3706
3707static struct clk measure_clk = {
3708 .dbg_name = "measure_clk",
3709 .ops = &measure_clk_ops,
3710 CLK_INIT(measure_clk),
3711};
3712
3713static struct clk_lookup msm_clocks_8960[] = {
3714 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
3715 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
3716 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
3717 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
3718 CLK_LOOKUP("measure", measure_clk, "debug"),
3719
3720 CLK_LOOKUP("afab_clk", afab_clk.c, NULL),
3721 CLK_LOOKUP("afab_a_clk", afab_a_clk.c, NULL),
3722 CLK_LOOKUP("cfpb_clk", cfpb_clk.c, NULL),
3723 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, NULL),
3724 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
3725 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
3726 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
3727 CLK_LOOKUP("ebi1_a_clk", ebi1_a_clk.c, NULL),
3728 CLK_LOOKUP("mmfab_clk", mmfab_clk.c, NULL),
3729 CLK_LOOKUP("mmfab_a_clk", mmfab_a_clk.c, NULL),
3730 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
3731 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, NULL),
3732 CLK_LOOKUP("sfab_clk", sfab_clk.c, NULL),
3733 CLK_LOOKUP("sfab_a_clk", sfab_a_clk.c, NULL),
3734 CLK_LOOKUP("sfpb_clk", sfpb_clk.c, NULL),
3735 CLK_LOOKUP("sfpb_a_clk", sfpb_a_clk.c, NULL),
3736
3737 CLK_LOOKUP("gsbi_uart_clk", gsbi1_uart_clk.c, NULL),
3738 CLK_LOOKUP("gsbi_uart_clk", gsbi2_uart_clk.c, NULL),
3739 CLK_LOOKUP("gsbi_uart_clk", gsbi3_uart_clk.c, NULL),
3740 CLK_LOOKUP("gsbi_uart_clk", gsbi4_uart_clk.c, NULL),
3741 CLK_LOOKUP("gsbi_uart_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
3742 CLK_LOOKUP("uartdm_clk", gsbi6_uart_clk.c, NULL),
3743 CLK_LOOKUP("gsbi_uart_clk", gsbi7_uart_clk.c, NULL),
3744 CLK_LOOKUP("gsbi_uart_clk", gsbi8_uart_clk.c, NULL),
3745 CLK_LOOKUP("gsbi_uart_clk", gsbi9_uart_clk.c, NULL),
3746 CLK_LOOKUP("gsbi_uart_clk", gsbi10_uart_clk.c, NULL),
3747 CLK_LOOKUP("gsbi_uart_clk", gsbi11_uart_clk.c, NULL),
3748 CLK_LOOKUP("gsbi_uart_clk", gsbi12_uart_clk.c, NULL),
3749 CLK_LOOKUP("spi_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
3750 CLK_LOOKUP("gsbi_qup_clk", gsbi2_qup_clk.c, NULL),
3751 CLK_LOOKUP("gsbi_qup_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
3752 CLK_LOOKUP("gsbi_qup_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
3753 CLK_LOOKUP("gsbi_qup_clk", gsbi5_qup_clk.c, NULL),
3754 CLK_LOOKUP("gsbi_qup_clk", gsbi6_qup_clk.c, NULL),
3755 CLK_LOOKUP("gsbi_qup_clk", gsbi7_qup_clk.c, NULL),
3756 CLK_LOOKUP("gsbi_qup_clk", gsbi8_qup_clk.c, NULL),
3757 CLK_LOOKUP("gsbi_qup_clk", gsbi9_qup_clk.c, NULL),
3758 CLK_LOOKUP("gsbi_qup_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
3759 CLK_LOOKUP("gsbi_qup_clk", gsbi11_qup_clk.c, NULL),
3760 CLK_LOOKUP("gsbi_qup_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
3761 CLK_LOOKUP("pdm_clk", pdm_clk.c, NULL),
3762 CLK_LOOKUP("pmem_clk", pmem_clk.c, NULL),
3763 CLK_LOOKUP("prng_clk", prng_clk.c, NULL),
3764 CLK_LOOKUP("sdc_clk", sdc1_clk.c, "msm_sdcc.1"),
3765 CLK_LOOKUP("sdc_clk", sdc2_clk.c, "msm_sdcc.2"),
3766 CLK_LOOKUP("sdc_clk", sdc3_clk.c, "msm_sdcc.3"),
3767 CLK_LOOKUP("sdc_clk", sdc4_clk.c, "msm_sdcc.4"),
3768 CLK_LOOKUP("sdc_clk", sdc5_clk.c, "msm_sdcc.5"),
3769 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
3770 CLK_LOOKUP("tsif_ref_clk", tsif_ref_clk.c, NULL),
3771 CLK_LOOKUP("tssc_clk", tssc_clk.c, NULL),
3772 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
3773 CLK_LOOKUP("usb_phy_clk", usb_phy0_clk.c, NULL),
3774 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
3775 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
3776 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
3777 CLK_LOOKUP("usb_fs_clk", usb_fs2_xcvr_clk.c, NULL),
3778 CLK_LOOKUP("usb_fs_sys_clk", usb_fs2_sys_clk.c, NULL),
3779 CLK_LOOKUP("usb_fs_src_clk", usb_fs2_src_clk.c, NULL),
3780 CLK_LOOKUP("ce_pclk", ce1_p_clk.c, NULL),
3781 CLK_LOOKUP("ce_clk", ce1_core_clk.c, NULL),
3782 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
3783 CLK_LOOKUP("spi_pclk", gsbi1_p_clk.c, "spi_qsd.0"),
3784 CLK_LOOKUP("gsbi_pclk", gsbi2_p_clk.c, NULL),
3785 CLK_LOOKUP("gsbi_pclk", gsbi3_p_clk.c, "qup_i2c.3"),
3786 CLK_LOOKUP("gsbi_pclk", gsbi4_p_clk.c, "qup_i2c.4"),
3787 CLK_LOOKUP("gsbi_pclk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
3788 CLK_LOOKUP("uartdm_pclk", gsbi6_p_clk.c, NULL),
3789 CLK_LOOKUP("gsbi_pclk", gsbi7_p_clk.c, NULL),
3790 CLK_LOOKUP("gsbi_pclk", gsbi8_p_clk.c, NULL),
3791 CLK_LOOKUP("gsbi_pclk", gsbi9_p_clk.c, NULL),
3792 CLK_LOOKUP("gsbi_pclk", gsbi10_p_clk.c, "qup_i2c.10"),
3793 CLK_LOOKUP("gsbi_pclk", gsbi11_p_clk.c, NULL),
3794 CLK_LOOKUP("gsbi_pclk", gsbi12_p_clk.c, "qup_i2c.12"),
3795 CLK_LOOKUP("tsif_pclk", tsif_p_clk.c, NULL),
3796 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
3797 CLK_LOOKUP("usb_fs_pclk", usb_fs2_p_clk.c, NULL),
3798 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
3799 CLK_LOOKUP("sdc_pclk", sdc1_p_clk.c, "msm_sdcc.1"),
3800 CLK_LOOKUP("sdc_pclk", sdc2_p_clk.c, "msm_sdcc.2"),
3801 CLK_LOOKUP("sdc_pclk", sdc3_p_clk.c, "msm_sdcc.3"),
3802 CLK_LOOKUP("sdc_pclk", sdc4_p_clk.c, "msm_sdcc.4"),
3803 CLK_LOOKUP("sdc_pclk", sdc5_p_clk.c, "msm_sdcc.5"),
3804 CLK_LOOKUP("adm_clk", adm0_clk.c, NULL),
3805 CLK_LOOKUP("adm_pclk", adm0_p_clk.c, NULL),
3806 CLK_LOOKUP("pmic_arb_pclk", pmic_arb0_p_clk.c, NULL),
3807 CLK_LOOKUP("pmic_arb_pclk", pmic_arb1_p_clk.c, NULL),
3808 CLK_LOOKUP("pmic_ssbi2", pmic_ssbi2_clk.c, NULL),
3809 CLK_LOOKUP("rpm_msg_ram_pclk", rpm_msg_ram_p_clk.c, NULL),
3810 CLK_LOOKUP("amp_clk", amp_clk.c, NULL),
3811 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
3812 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
3813 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_imx074.0"),
3814 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_ov2720.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07003815 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003816 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, NULL),
3817 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
3818 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07003819 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003820 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_camera_ov2720.0"),
3821 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
3822 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
3823 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07003824 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003825 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov2720.0"),
3826 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, NULL),
3827 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
3828 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07003829 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003830 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_camera_ov2720.0"),
3831 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, NULL),
3832 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, NULL),
3833 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
3834 CLK_LOOKUP("csi0phy_timer_clk", csi0phy_timer_clk.c, NULL),
3835 CLK_LOOKUP("csi1phy_timer_clk", csi1phy_timer_clk.c, NULL),
3836 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
3837 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
3838 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
3839 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
3840 CLK_LOOKUP("gfx2d0_clk", gfx2d0_clk.c, NULL),
3841 CLK_LOOKUP("gfx2d1_clk", gfx2d1_clk.c, NULL),
3842 CLK_LOOKUP("gfx3d_clk", gfx3d_clk.c, NULL),
3843 CLK_LOOKUP("ijpeg_axi_clk", ijpeg_axi_clk.c, NULL),
3844 CLK_LOOKUP("imem_axi_clk", imem_axi_clk.c, NULL),
3845 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
3846 CLK_LOOKUP("jpegd_clk", jpegd_clk.c, NULL),
3847 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
3848 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
3849 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
3850 CLK_LOOKUP("rot_clk", rot_clk.c, NULL),
3851 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
3852 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
3853 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
3854 CLK_LOOKUP("vcodec_clk", vcodec_clk.c, NULL),
3855 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
3856 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
3857 CLK_LOOKUP("hdmi_app_clk", hdmi_app_clk.c, NULL),
3858 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
3859 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
3860 CLK_LOOKUP("csi_vfe_clk", csi0_vfe_clk.c, NULL),
3861 CLK_LOOKUP("vfe_axi_clk", vfe_axi_clk.c, NULL),
3862 CLK_LOOKUP("mdp_axi_clk", mdp_axi_clk.c, NULL),
3863 CLK_LOOKUP("rot_axi_clk", rot_axi_clk.c, NULL),
3864 CLK_LOOKUP("vcodec_axi_clk", vcodec_axi_clk.c, NULL),
3865 CLK_LOOKUP("vcodec_axi_a_clk", vcodec_axi_a_clk.c, NULL),
3866 CLK_LOOKUP("vcodec_axi_b_clk", vcodec_axi_b_clk.c, NULL),
3867 CLK_LOOKUP("vpe_axi_clk", vpe_axi_clk.c, NULL),
3868 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
3869 CLK_LOOKUP("csi_pclk", csi0_p_clk.c, NULL),
3870 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
3871 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
3872 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
3873 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
3874 CLK_LOOKUP("gfx2d0_pclk", gfx2d0_p_clk.c, NULL),
3875 CLK_LOOKUP("gfx2d1_pclk", gfx2d1_p_clk.c, NULL),
3876 CLK_LOOKUP("gfx3d_pclk", gfx3d_p_clk.c, NULL),
3877 CLK_LOOKUP("hdmi_m_pclk", hdmi_m_p_clk.c, NULL),
3878 CLK_LOOKUP("hdmi_s_pclk", hdmi_s_p_clk.c, NULL),
3879 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
3880 CLK_LOOKUP("jpegd_pclk", jpegd_p_clk.c, NULL),
3881 CLK_LOOKUP("imem_pclk", imem_p_clk.c, NULL),
3882 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
3883 CLK_LOOKUP("smmu_pclk", smmu_p_clk.c, NULL),
3884 CLK_LOOKUP("rotator_pclk", rot_p_clk.c, NULL),
3885 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
3886 CLK_LOOKUP("vcodec_pclk", vcodec_p_clk.c, NULL),
3887 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
3888 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
3889 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
3890 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
3891 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
3892 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
3893 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
3894 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
3895 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
3896 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
3897 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
3898 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
3899 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
3900 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
3901 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
3902 CLK_LOOKUP("iommu_clk", jpegd_axi_clk.c, "msm_iommu.0"),
3903 CLK_LOOKUP("iommu_clk", vpe_axi_clk.c, "msm_iommu.1"),
3904 CLK_LOOKUP("iommu_clk", mdp_axi_clk.c, "msm_iommu.2"),
3905 CLK_LOOKUP("iommu_clk", mdp_axi_clk.c, "msm_iommu.3"),
3906 CLK_LOOKUP("iommu_clk", rot_axi_clk.c, "msm_iommu.4"),
3907 CLK_LOOKUP("iommu_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
3908 CLK_LOOKUP("iommu_clk", vfe_axi_clk.c, "msm_iommu.6"),
3909 CLK_LOOKUP("iommu_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
3910 CLK_LOOKUP("iommu_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
3911 CLK_LOOKUP("iommu_clk", gfx3d_clk.c, "msm_iommu.9"),
3912 CLK_LOOKUP("iommu_clk", gfx2d0_clk.c, "msm_iommu.10"),
3913 CLK_LOOKUP("iommu_clk", gfx2d1_clk.c, "msm_iommu.11"),
3914 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
3915 CLK_LOOKUP("dfab_usb_hs_clk", dfab_usb_hs_clk.c, NULL),
3916 CLK_LOOKUP("dfab_sdc_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
3917 CLK_LOOKUP("dfab_sdc_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
3918 CLK_LOOKUP("dfab_sdc_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
3919 CLK_LOOKUP("dfab_sdc_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
3920 CLK_LOOKUP("dfab_sdc_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
3921 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, NULL /* sps */),
3922
3923 CLK_LOOKUP("ebi1_msmbus_clk", ebi1_msmbus_clk.c, NULL),
3924 CLK_LOOKUP("ebi1_clk", ebi1_adm_clk.c, "msm_dmov"),
3925};
3926
3927/*
3928 * Miscellaneous clock register initializations
3929 */
3930
3931/* Read, modify, then write-back a register. */
3932static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
3933{
3934 uint32_t regval = readl_relaxed(reg);
3935 regval &= ~mask;
3936 regval |= val;
3937 writel_relaxed(regval, reg);
3938}
3939
3940static void __init reg_init(void)
3941{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003942 /* Setup LPASS toplevel muxes */
3943 writel_relaxed(0x15, LPASS_XO_SRC_CLK_CTL_REG); /* Select PXO */
3944 writel_relaxed(0x1, LCC_PXO_SRC_CLK_CTL_REG); /* Select PXO */
3945 writel_relaxed(0x1, LCC_PRI_PLL_CLK_CTL_REG); /* Select PLL4 */
3946
3947 /* Deassert MM SW_RESET_ALL signal. */
3948 writel_relaxed(0, SW_RESET_ALL_REG);
3949
3950 /* Initialize MM AHB registers: Enable the FPB clock and disable HW
3951 * gating for all clocks. Also set VFE_AHB's FORCE_CORE_ON bit to
3952 * prevent its memory from being collapsed when the clock is halted.
3953 * The sleep and wake-up delays are set to safe values. */
3954 rmwreg(0x00000003, AHB_EN_REG, 0x0F7FFFFF);
3955 rmwreg(0x000007F9, AHB_EN2_REG, 0xFFFFBFFF);
3956
3957 /* Deassert all locally-owned MM AHB resets. */
3958 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
3959
3960 /* Initialize MM AXI registers: Enable HW gating for all clocks that
3961 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
3962 * delays to safe values. */
3963 /* TODO: Enable HW Gating */
3964 rmwreg(0x000007F9, MAXI_EN_REG, 0x0FFFFFFF);
3965 rmwreg(0x1027FCFF, MAXI_EN2_REG, 0x1FFFFFFF);
3966 writel_relaxed(0x0027FCFF, MAXI_EN3_REG);
3967 writel_relaxed(0x0027FCFF, MAXI_EN4_REG);
3968 writel_relaxed(0x000003C7, SAXI_EN_REG);
3969
3970 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
3971 * memories retain state even when not clocked. Also, set sleep and
3972 * wake-up delays to safe values. */
3973 writel_relaxed(0x00000000, CSI0_CC_REG);
3974 writel_relaxed(0x00000000, CSI1_CC_REG);
3975 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, BM(31, 29) | BM(23, 16));
3976 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, BM(31, 29) | BM(23, 16));
3977 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, BM(31, 29) | BM(23, 16));
3978 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, BM(31, 29) | BM(23, 16));
3979 writel_relaxed(0x80FF0000, GFX2D0_CC_REG);
3980 writel_relaxed(0x80FF0000, GFX2D1_CC_REG);
3981 writel_relaxed(0x80FF0000, GFX3D_CC_REG);
3982 writel_relaxed(0x80FF0000, IJPEG_CC_REG);
3983 writel_relaxed(0x80FF0000, JPEGD_CC_REG);
3984 /* MDP clocks may be running at boot, don't turn them off. */
3985 rmwreg(0x80FF0000, MDP_CC_REG, BM(31, 29) | BM(23, 16));
3986 rmwreg(0x80FF0000, MDP_LUT_CC_REG, BM(31, 29) | BM(23, 16));
3987 writel_relaxed(0x80FF0000, ROT_CC_REG);
3988 writel_relaxed(0x80FF0000, TV_CC_REG);
3989 writel_relaxed(0x000004FF, TV_CC2_REG);
3990 writel_relaxed(0xC0FF0000, VCODEC_CC_REG);
3991 writel_relaxed(0x80FF0000, VFE_CC_REG);
3992 writel_relaxed(0x80FF0000, VPE_CC_REG);
3993
3994 /* De-assert MM AXI resets to all hardware blocks. */
3995 writel_relaxed(0, SW_RESET_AXI_REG);
3996
3997 /* Deassert all MM core resets. */
3998 writel_relaxed(0, SW_RESET_CORE_REG);
3999
4000 /* Reset 3D core once more, with its clock enabled. This can
4001 * eventually be done as part of the GDFS footswitch driver. */
4002 clk_set_rate(&gfx3d_clk.c, 27000000);
4003 clk_enable(&gfx3d_clk.c);
4004 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
4005 mb();
4006 udelay(5);
4007 writel_relaxed(0, SW_RESET_CORE_REG);
4008 /* Make sure reset is de-asserted before clock is disabled. */
4009 mb();
4010 clk_disable(&gfx3d_clk.c);
4011
4012 /* Enable TSSC and PDM PXO sources. */
4013 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
4014 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
4015
4016 /* Source SLIMBus xo src from slimbus reference clock */
4017 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
4018
4019 /* Source the dsi_byte_clks from the DSI PHY PLLs */
4020 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
4021 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
4022}
4023
4024static int wr_pll_clk_enable(struct clk *clk)
4025{
4026 u32 mode;
4027 unsigned long flags;
4028 struct pll_clk *pll = to_pll_clk(clk);
4029
4030 spin_lock_irqsave(&local_clock_reg_lock, flags);
4031 mode = readl_relaxed(pll->mode_reg);
4032 /* De-assert active-low PLL reset. */
4033 mode |= BIT(2);
4034 writel_relaxed(mode, pll->mode_reg);
4035
4036 /*
4037 * H/W requires a 5us delay between disabling the bypass and
4038 * de-asserting the reset. Delay 10us just to be safe.
4039 */
4040 mb();
4041 udelay(10);
4042
4043 /* Disable PLL bypass mode. */
4044 mode |= BIT(1);
4045 writel_relaxed(mode, pll->mode_reg);
4046
4047 /* Wait until PLL is locked. */
4048 mb();
4049 udelay(60);
4050
4051 /* Enable PLL output. */
4052 mode |= BIT(0);
4053 writel_relaxed(mode, pll->mode_reg);
4054
4055 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4056 return 0;
4057}
4058
4059void __init msm8960_clock_init_dummy(void)
4060{
4061 soc_update_sys_vdd = msm8960_update_sys_vdd;
4062 local_vote_sys_vdd(HIGH);
4063 msm_clock_init(msm_clocks_8960_dummy, msm_num_clocks_8960_dummy);
4064}
4065
4066/* Local clock driver initialization. */
4067void __init msm8960_clock_init(void)
4068{
4069 xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8960");
4070 if (IS_ERR(xo_pxo)) {
4071 pr_err("%s: msm_xo_get(PXO) failed.\n", __func__);
4072 BUG();
4073 }
4074 xo_cxo = msm_xo_get(MSM_XO_TCXO_D0, "clock-8960");
4075 if (IS_ERR(xo_cxo)) {
4076 pr_err("%s: msm_xo_get(CXO) failed.\n", __func__);
4077 BUG();
4078 }
4079
4080 soc_update_sys_vdd = msm8960_update_sys_vdd;
4081 local_vote_sys_vdd(HIGH);
4082
4083 clk_ops_pll.enable = wr_pll_clk_enable;
4084
4085 /* Initialize clock registers. */
4086 reg_init();
4087
4088 /* Initialize rates for clocks that only support one. */
4089 clk_set_rate(&pdm_clk.c, 27000000);
4090 clk_set_rate(&prng_clk.c, 64000000);
4091 clk_set_rate(&mdp_vsync_clk.c, 27000000);
4092 clk_set_rate(&tsif_ref_clk.c, 105000);
4093 clk_set_rate(&tssc_clk.c, 27000000);
4094 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
4095 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
4096 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
4097
4098 /*
4099 * The halt status bits for PDM and TSSC may be incorrect at boot.
4100 * Toggle these clocks on and off to refresh them.
4101 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07004102 rcg_clk_enable(&pdm_clk.c);
4103 rcg_clk_disable(&pdm_clk.c);
4104 rcg_clk_enable(&tssc_clk.c);
4105 rcg_clk_disable(&tssc_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004106
4107 if (machine_is_msm8960_sim()) {
4108 clk_set_rate(&sdc1_clk.c, 48000000);
4109 clk_enable(&sdc1_clk.c);
4110 clk_enable(&sdc1_p_clk.c);
4111 clk_set_rate(&sdc3_clk.c, 48000000);
4112 clk_enable(&sdc3_clk.c);
4113 clk_enable(&sdc3_p_clk.c);
4114 }
4115
4116 msm_clock_init(msm_clocks_8960, ARRAY_SIZE(msm_clocks_8960));
4117}
4118
4119static int __init msm_clk_soc_late_init(void)
4120{
4121 return local_unvote_sys_vdd(HIGH);
4122}
4123late_initcall(msm_clk_soc_late_init);