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