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