blob: e737588da39adf9afc56050d7cf768c7f1952a9d [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>
Stephen Boyd94625ef2011-07-12 17:06:01 -070030#include <mach/socinfo.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070031
32#include "clock-local.h"
33#include "clock-rpm.h"
34#include "clock-voter.h"
35#include "clock-dss-8960.h"
36#include "devices.h"
37
38#define REG(off) (MSM_CLK_CTL_BASE + (off))
39#define REG_MM(off) (MSM_MMSS_CLK_CTL_BASE + (off))
40#define REG_LPA(off) (MSM_LPASS_CLK_CTL_BASE + (off))
Matt Wagantall8b38f942011-08-02 18:23:18 -070041#define REG_GCC(off) (MSM_APCS_GCC_BASE + (off))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070042
43/* Peripheral clock registers. */
44#define CE1_HCLK_CTL_REG REG(0x2720)
45#define CE1_CORE_CLK_CTL_REG REG(0x2724)
46#define DMA_BAM_HCLK_CTL REG(0x25C0)
47#define CLK_HALT_CFPB_STATEA_REG REG(0x2FCC)
48#define CLK_HALT_CFPB_STATEB_REG REG(0x2FD0)
49#define CLK_HALT_CFPB_STATEC_REG REG(0x2FD4)
50#define CLK_HALT_DFAB_STATE_REG REG(0x2FC8)
51#define CLK_HALT_MSS_SMPSS_MISC_STATE_REG REG(0x2FDC)
52#define CLK_HALT_SFPB_MISC_STATE_REG REG(0x2FD8)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070053#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070054#define CLK_TEST_REG REG(0x2FA0)
55#define GSBIn_HCLK_CTL_REG(n) REG(0x29C0+(0x20*((n)-1)))
56#define GSBIn_QUP_APPS_MD_REG(n) REG(0x29C8+(0x20*((n)-1)))
57#define GSBIn_QUP_APPS_NS_REG(n) REG(0x29CC+(0x20*((n)-1)))
58#define GSBIn_RESET_REG(n) REG(0x29DC+(0x20*((n)-1)))
59#define GSBIn_UART_APPS_MD_REG(n) REG(0x29D0+(0x20*((n)-1)))
60#define GSBIn_UART_APPS_NS_REG(n) REG(0x29D4+(0x20*((n)-1)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061#define PDM_CLK_NS_REG REG(0x2CC0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062#define BB_PLL_ENA_SC0_REG REG(0x34C0)
63#define BB_PLL0_STATUS_REG REG(0x30D8)
64#define BB_PLL5_STATUS_REG REG(0x30F8)
65#define BB_PLL6_STATUS_REG REG(0x3118)
66#define BB_PLL7_STATUS_REG REG(0x3138)
67#define BB_PLL8_L_VAL_REG REG(0x3144)
68#define BB_PLL8_M_VAL_REG REG(0x3148)
69#define BB_PLL8_MODE_REG REG(0x3140)
70#define BB_PLL8_N_VAL_REG REG(0x314C)
71#define BB_PLL8_STATUS_REG REG(0x3158)
72#define BB_PLL8_CONFIG_REG REG(0x3154)
73#define BB_PLL8_TEST_CTL_REG REG(0x3150)
Stephen Boyd94625ef2011-07-12 17:06:01 -070074#define BB_MMCC_PLL2_MODE_REG REG(0x3160)
75#define BB_MMCC_PLL2_TEST_CTL_REG REG(0x3170)
76#define BB_PLL14_STATUS_REG REG(0x31D8)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070077#define PLLTEST_PAD_CFG_REG REG(0x2FA4)
78#define PMEM_ACLK_CTL_REG REG(0x25A0)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070079#define QDSS_AT_CLK_SRC0_NS_REG REG(0x2180)
80#define QDSS_AT_CLK_SRC1_NS_REG REG(0x2184)
81#define QDSS_AT_CLK_SRC_CTL_REG REG(0x2188)
82#define QDSS_AT_CLK_NS_REG REG(0x218C)
83#define QDSS_HCLK_CTL_REG REG(0x22A0)
84#define QDSS_RESETS_REG REG(0x2260)
85#define QDSS_STM_CLK_CTL_REG REG(0x2060)
86#define QDSS_TRACECLKIN_CLK_SRC0_NS_REG REG(0x21A0)
87#define QDSS_TRACECLKIN_CLK_SRC1_NS_REG REG(0x21A4)
88#define QDSS_TRACECLKIN_CLK_SRC_CTL_REG REG(0x21A8)
89#define QDSS_TRACECLKIN_CTL_REG REG(0x21AC)
90#define QDSS_TSCTR_CLK_SRC0_NS_REG REG(0x21C0)
91#define QDSS_TSCTR_CLK_SRC1_NS_REG REG(0x21C4)
92#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
93#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
94#define QDSS_TSCTR_CTL_REG REG(0x21CC)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095#define RINGOSC_NS_REG REG(0x2DC0)
96#define RINGOSC_STATUS_REG REG(0x2DCC)
97#define RINGOSC_TCXO_CTL_REG REG(0x2DC4)
98#define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080)
99#define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1)))
100#define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1)))
101#define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1)))
102#define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1)))
103#define SLIMBUS_XO_SRC_CLK_CTL_REG REG(0x2628)
104#define TSIF_HCLK_CTL_REG REG(0x2700)
105#define TSIF_REF_CLK_MD_REG REG(0x270C)
106#define TSIF_REF_CLK_NS_REG REG(0x2710)
107#define TSSC_CLK_CTL_REG REG(0x2CA0)
108#define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1)))
109#define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1)))
110#define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1)))
111#define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1)))
112#define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1)))
113#define USB_HS1_HCLK_CTL_REG REG(0x2900)
114#define USB_HS1_RESET_REG REG(0x2910)
115#define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908)
116#define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700117#define USB_HSIC_HCLK_CTL_REG REG(0x2920)
118#define USB_HSIC_HSIC_CLK_CTL_REG REG(0x2B44)
119#define USB_HSIC_HSIC_CLK_SRC_CTL_REG REG(0x2B40)
120#define USB_HSIC_HSIO_CAL_CLK_CTL_REG REG(0x2B48)
121#define USB_HSIC_RESET_REG REG(0x2934)
122#define USB_HSIC_SYSTEM_CLK_CTL_REG REG(0x292C)
123#define USB_HSIC_XCVR_FS_CLK_MD_REG REG(0x2924)
124#define USB_HSIC_XCVR_FS_CLK_NS_REG REG(0x2928)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700125#define USB_PHY0_RESET_REG REG(0x2E20)
126
127/* Multimedia clock registers. */
128#define AHB_EN_REG REG_MM(0x0008)
129#define AHB_EN2_REG REG_MM(0x0038)
130#define AHB_NS_REG REG_MM(0x0004)
131#define AXI_NS_REG REG_MM(0x0014)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700132#define CAMCLK0_NS_REG REG_MM(0x0148)
133#define CAMCLK0_CC_REG REG_MM(0x0140)
134#define CAMCLK0_MD_REG REG_MM(0x0144)
135#define CAMCLK1_NS_REG REG_MM(0x015C)
136#define CAMCLK1_CC_REG REG_MM(0x0154)
137#define CAMCLK1_MD_REG REG_MM(0x0158)
138#define CAMCLK2_NS_REG REG_MM(0x0228)
139#define CAMCLK2_CC_REG REG_MM(0x0220)
140#define CAMCLK2_MD_REG REG_MM(0x0224)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700141#define CSI0_NS_REG REG_MM(0x0048)
142#define CSI0_CC_REG REG_MM(0x0040)
143#define CSI0_MD_REG REG_MM(0x0044)
144#define CSI1_NS_REG REG_MM(0x0010)
145#define CSI1_CC_REG REG_MM(0x0024)
146#define CSI1_MD_REG REG_MM(0x0028)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700147#define CSI2_NS_REG REG_MM(0x0234)
148#define CSI2_CC_REG REG_MM(0x022C)
149#define CSI2_MD_REG REG_MM(0x0230)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150#define CSIPHYTIMER_CC_REG REG_MM(0x0160)
151#define CSIPHYTIMER_MD_REG REG_MM(0x0164)
152#define CSIPHYTIMER_NS_REG REG_MM(0x0168)
153#define DSI1_BYTE_NS_REG REG_MM(0x00B0)
154#define DSI1_BYTE_CC_REG REG_MM(0x0090)
155#define DSI2_BYTE_NS_REG REG_MM(0x00BC)
156#define DSI2_BYTE_CC_REG REG_MM(0x00B4)
157#define DSI1_ESC_NS_REG REG_MM(0x011C)
158#define DSI1_ESC_CC_REG REG_MM(0x00CC)
159#define DSI2_ESC_NS_REG REG_MM(0x0150)
160#define DSI2_ESC_CC_REG REG_MM(0x013C)
161#define DSI_PIXEL_CC_REG REG_MM(0x0130)
162#define DSI2_PIXEL_CC_REG REG_MM(0x0094)
163#define DBG_BUS_VEC_A_REG REG_MM(0x01C8)
164#define DBG_BUS_VEC_B_REG REG_MM(0x01CC)
165#define DBG_BUS_VEC_C_REG REG_MM(0x01D0)
166#define DBG_BUS_VEC_D_REG REG_MM(0x01D4)
167#define DBG_BUS_VEC_E_REG REG_MM(0x01D8)
168#define DBG_BUS_VEC_F_REG REG_MM(0x01DC)
169#define DBG_BUS_VEC_G_REG REG_MM(0x01E0)
170#define DBG_BUS_VEC_H_REG REG_MM(0x01E4)
171#define DBG_BUS_VEC_I_REG REG_MM(0x01E8)
172#define DBG_CFG_REG_HS_REG REG_MM(0x01B4)
173#define DBG_CFG_REG_LS_REG REG_MM(0x01B8)
174#define GFX2D0_CC_REG REG_MM(0x0060)
175#define GFX2D0_MD0_REG REG_MM(0x0064)
176#define GFX2D0_MD1_REG REG_MM(0x0068)
177#define GFX2D0_NS_REG REG_MM(0x0070)
178#define GFX2D1_CC_REG REG_MM(0x0074)
179#define GFX2D1_MD0_REG REG_MM(0x0078)
180#define GFX2D1_MD1_REG REG_MM(0x006C)
181#define GFX2D1_NS_REG REG_MM(0x007C)
182#define GFX3D_CC_REG REG_MM(0x0080)
183#define GFX3D_MD0_REG REG_MM(0x0084)
184#define GFX3D_MD1_REG REG_MM(0x0088)
185#define GFX3D_NS_REG REG_MM(0x008C)
186#define IJPEG_CC_REG REG_MM(0x0098)
187#define IJPEG_MD_REG REG_MM(0x009C)
188#define IJPEG_NS_REG REG_MM(0x00A0)
189#define JPEGD_CC_REG REG_MM(0x00A4)
190#define JPEGD_NS_REG REG_MM(0x00AC)
191#define MAXI_EN_REG REG_MM(0x0018)
192#define MAXI_EN2_REG REG_MM(0x0020)
193#define MAXI_EN3_REG REG_MM(0x002C)
194#define MAXI_EN4_REG REG_MM(0x0114)
195#define MDP_CC_REG REG_MM(0x00C0)
196#define MDP_LUT_CC_REG REG_MM(0x016C)
197#define MDP_MD0_REG REG_MM(0x00C4)
198#define MDP_MD1_REG REG_MM(0x00C8)
199#define MDP_NS_REG REG_MM(0x00D0)
200#define MISC_CC_REG REG_MM(0x0058)
201#define MISC_CC2_REG REG_MM(0x005C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700202#define MISC_CC3_REG REG_MM(0x0238)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700203#define MM_PLL1_MODE_REG REG_MM(0x031C)
204#define ROT_CC_REG REG_MM(0x00E0)
205#define ROT_NS_REG REG_MM(0x00E8)
206#define SAXI_EN_REG REG_MM(0x0030)
207#define SW_RESET_AHB_REG REG_MM(0x020C)
208#define SW_RESET_AHB2_REG REG_MM(0x0200)
209#define SW_RESET_ALL_REG REG_MM(0x0204)
210#define SW_RESET_AXI_REG REG_MM(0x0208)
211#define SW_RESET_CORE_REG REG_MM(0x0210)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700212#define SW_RESET_CORE2_REG REG_MM(0x0214)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700213#define TV_CC_REG REG_MM(0x00EC)
214#define TV_CC2_REG REG_MM(0x0124)
215#define TV_MD_REG REG_MM(0x00F0)
216#define TV_NS_REG REG_MM(0x00F4)
217#define VCODEC_CC_REG REG_MM(0x00F8)
218#define VCODEC_MD0_REG REG_MM(0x00FC)
219#define VCODEC_MD1_REG REG_MM(0x0128)
220#define VCODEC_NS_REG REG_MM(0x0100)
221#define VFE_CC_REG REG_MM(0x0104)
222#define VFE_MD_REG REG_MM(0x0108)
223#define VFE_NS_REG REG_MM(0x010C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700224#define VFE_CC2_REG REG_MM(0x023C)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700225#define VPE_CC_REG REG_MM(0x0110)
226#define VPE_NS_REG REG_MM(0x0118)
227
228/* Low-power Audio clock registers. */
229#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
230#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
231#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
232#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
233#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
234#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
235#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
236#define LCC_MI2S_MD_REG REG_LPA(0x004C)
237#define LCC_MI2S_NS_REG REG_LPA(0x0048)
238#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
239#define LCC_PCM_MD_REG REG_LPA(0x0058)
240#define LCC_PCM_NS_REG REG_LPA(0x0054)
241#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
242#define LCC_PLL0_STATUS_REG REG_LPA(0x0018)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700243#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
244#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
245#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
246#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
247#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
248#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
249#define LCC_SLIMBUS_NS_REG REG_LPA(0x00CC)
250#define LCC_SLIMBUS_MD_REG REG_LPA(0x00D0)
251#define LCC_SLIMBUS_STATUS_REG REG_LPA(0x00D4)
252#define LCC_AHBEX_BRANCH_CTL_REG REG_LPA(0x00E4)
253
Matt Wagantall8b38f942011-08-02 18:23:18 -0700254#define GCC_APCS_CLK_DIAG REG_GCC(0x001C)
255
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700256/* MUX source input identifiers. */
257#define pxo_to_bb_mux 0
258#define cxo_to_bb_mux pxo_to_bb_mux
259#define pll0_to_bb_mux 2
260#define pll8_to_bb_mux 3
261#define pll6_to_bb_mux 4
262#define gnd_to_bb_mux 5
Stephen Boyd94625ef2011-07-12 17:06:01 -0700263#define pll3_to_bb_mux 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700264#define pxo_to_mm_mux 0
265#define pll1_to_mm_mux 1
266#define pll2_to_mm_mux 1
267#define pll8_to_mm_mux 2
268#define pll0_to_mm_mux 3
269#define gnd_to_mm_mux 4
Stephen Boyd94625ef2011-07-12 17:06:01 -0700270#define pll3_to_mm_mux 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700271#define hdmi_pll_to_mm_mux 3
272#define cxo_to_xo_mux 0
273#define pxo_to_xo_mux 1
274#define gnd_to_xo_mux 3
275#define pxo_to_lpa_mux 0
276#define cxo_to_lpa_mux 1
277#define pll4_to_lpa_mux 2
278#define gnd_to_lpa_mux 6
279
280/* Test Vector Macros */
281#define TEST_TYPE_PER_LS 1
282#define TEST_TYPE_PER_HS 2
283#define TEST_TYPE_MM_LS 3
284#define TEST_TYPE_MM_HS 4
285#define TEST_TYPE_LPA 5
Matt Wagantall8b38f942011-08-02 18:23:18 -0700286#define TEST_TYPE_CPUL2 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700287#define TEST_TYPE_SHIFT 24
288#define TEST_CLK_SEL_MASK BM(23, 0)
289#define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s)))
290#define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS)
291#define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS)
292#define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS)
293#define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS)
294#define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA)
Matt Wagantall8b38f942011-08-02 18:23:18 -0700295#define TEST_CPUL2(s) TEST_VECTOR((s), TEST_TYPE_CPUL2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700296
297#define MN_MODE_DUAL_EDGE 0x2
298
299/* MD Registers */
300#define MD4(m_lsb, m, n_lsb, n) \
301 (BVAL((m_lsb+3), m_lsb, m) | BVAL((n_lsb+3), n_lsb, ~(n)))
302#define MD8(m_lsb, m, n_lsb, n) \
303 (BVAL((m_lsb+7), m_lsb, m) | BVAL((n_lsb+7), n_lsb, ~(n)))
304#define MD16(m, n) (BVAL(31, 16, m) | BVAL(15, 0, ~(n)))
305
306/* NS Registers */
307#define NS(n_msb, n_lsb, n, m, mde_lsb, d_msb, d_lsb, d, s_msb, s_lsb, s) \
308 (BVAL(n_msb, n_lsb, ~(n-m)) \
309 | (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n)) \
310 | BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
311
312#define NS_MM(n_msb, n_lsb, n, m, d_msb, d_lsb, d, s_msb, s_lsb, s) \
313 (BVAL(n_msb, n_lsb, ~(n-m)) | BVAL(d_msb, d_lsb, (d-1)) \
314 | BVAL(s_msb, s_lsb, s))
315
316#define NS_DIVSRC(d_msb , d_lsb, d, s_msb, s_lsb, s) \
317 (BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
318
319#define NS_DIV(d_msb , d_lsb, d) \
320 BVAL(d_msb, d_lsb, (d-1))
321
322#define NS_SRC_SEL(s_msb, s_lsb, s) \
323 BVAL(s_msb, s_lsb, s)
324
325#define NS_MND_BANKED4(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
326 (BVAL((n0_lsb+3), n0_lsb, ~(n-m)) \
327 | BVAL((n1_lsb+3), n1_lsb, ~(n-m)) \
328 | BVAL((s0_lsb+2), s0_lsb, s) \
329 | BVAL((s1_lsb+2), s1_lsb, s))
330
331#define NS_MND_BANKED8(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
332 (BVAL((n0_lsb+7), n0_lsb, ~(n-m)) \
333 | BVAL((n1_lsb+7), n1_lsb, ~(n-m)) \
334 | BVAL((s0_lsb+2), s0_lsb, s) \
335 | BVAL((s1_lsb+2), s1_lsb, s))
336
337#define NS_DIVSRC_BANKED(d0_msb, d0_lsb, d1_msb, d1_lsb, d, \
338 s0_msb, s0_lsb, s1_msb, s1_lsb, s) \
339 (BVAL(d0_msb, d0_lsb, (d-1)) | BVAL(d1_msb, d1_lsb, (d-1)) \
340 | BVAL(s0_msb, s0_lsb, s) \
341 | BVAL(s1_msb, s1_lsb, s))
342
343/* CC Registers */
344#define CC(mde_lsb, n) (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n))
345#define CC_BANKED(mde0_lsb, mde1_lsb, n) \
346 ((BVAL((mde0_lsb+1), mde0_lsb, MN_MODE_DUAL_EDGE) \
347 | BVAL((mde1_lsb+1), mde1_lsb, MN_MODE_DUAL_EDGE)) \
348 * !!(n))
349
350struct pll_rate {
351 const uint32_t l_val;
352 const uint32_t m_val;
353 const uint32_t n_val;
354 const uint32_t vco;
355 const uint32_t post_div;
356 const uint32_t i_bits;
357};
358#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
359
360/*
361 * Clock Descriptions
362 */
363
364static struct msm_xo_voter *xo_pxo, *xo_cxo;
365
366static int pxo_clk_enable(struct clk *clk)
367{
368 return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON);
369}
370
371static void pxo_clk_disable(struct clk *clk)
372{
373 msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF);
374}
375
376static struct clk_ops clk_ops_pxo = {
377 .enable = pxo_clk_enable,
378 .disable = pxo_clk_disable,
379 .get_rate = fixed_clk_get_rate,
380 .is_local = local_clk_is_local,
381};
382
383static struct fixed_clk pxo_clk = {
384 .rate = 27000000,
385 .c = {
386 .dbg_name = "pxo_clk",
387 .ops = &clk_ops_pxo,
388 CLK_INIT(pxo_clk.c),
389 },
390};
391
392static int cxo_clk_enable(struct clk *clk)
393{
394 return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON);
395}
396
397static void cxo_clk_disable(struct clk *clk)
398{
399 msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF);
400}
401
402static struct clk_ops clk_ops_cxo = {
403 .enable = cxo_clk_enable,
404 .disable = cxo_clk_disable,
405 .get_rate = fixed_clk_get_rate,
406 .is_local = local_clk_is_local,
407};
408
409static struct fixed_clk cxo_clk = {
410 .rate = 19200000,
411 .c = {
412 .dbg_name = "cxo_clk",
413 .ops = &clk_ops_cxo,
414 CLK_INIT(cxo_clk.c),
415 },
416};
417
418static struct pll_clk pll2_clk = {
419 .rate = 800000000,
420 .mode_reg = MM_PLL1_MODE_REG,
421 .parent = &pxo_clk.c,
422 .c = {
423 .dbg_name = "pll2_clk",
424 .ops = &clk_ops_pll,
425 CLK_INIT(pll2_clk.c),
426 },
427};
428
Stephen Boyd94625ef2011-07-12 17:06:01 -0700429static struct pll_clk pll3_clk = {
430 .rate = 1200000000,
431 .mode_reg = BB_MMCC_PLL2_MODE_REG,
432 .parent = &pxo_clk.c,
433 .c = {
434 .dbg_name = "pll3_clk",
435 .ops = &clk_ops_pll,
436 CLK_INIT(pll3_clk.c),
437 },
438};
439
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700440static struct pll_vote_clk pll4_clk = {
441 .rate = 393216000,
442 .en_reg = BB_PLL_ENA_SC0_REG,
443 .en_mask = BIT(4),
444 .status_reg = LCC_PLL0_STATUS_REG,
445 .parent = &pxo_clk.c,
446 .c = {
447 .dbg_name = "pll4_clk",
448 .ops = &clk_ops_pll_vote,
449 CLK_INIT(pll4_clk.c),
450 },
451};
452
453static struct pll_vote_clk pll8_clk = {
454 .rate = 384000000,
455 .en_reg = BB_PLL_ENA_SC0_REG,
456 .en_mask = BIT(8),
457 .status_reg = BB_PLL8_STATUS_REG,
458 .parent = &pxo_clk.c,
459 .c = {
460 .dbg_name = "pll8_clk",
461 .ops = &clk_ops_pll_vote,
462 CLK_INIT(pll8_clk.c),
463 },
464};
465
Stephen Boyd94625ef2011-07-12 17:06:01 -0700466static struct pll_vote_clk pll14_clk = {
467 .rate = 480000000,
468 .en_reg = BB_PLL_ENA_SC0_REG,
469 .en_mask = BIT(14),
470 .status_reg = BB_PLL14_STATUS_REG,
471 .parent = &pxo_clk.c,
472 .c = {
473 .dbg_name = "pll14_clk",
474 .ops = &clk_ops_pll_vote,
475 CLK_INIT(pll14_clk.c),
476 },
477};
478
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700479/*
480 * SoC-specific functions required by clock-local driver
481 */
482
483/* Update the sys_vdd voltage given a level. */
484static int msm8960_update_sys_vdd(enum sys_vdd_level level)
485{
486 static const int vdd_uv[] = {
487 [NONE...LOW] = 945000,
488 [NOMINAL] = 1050000,
489 [HIGH] = 1150000,
490 };
491
492 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
493 vdd_uv[level], vdd_uv[HIGH], 1);
494}
495
496static int soc_clk_reset(struct clk *clk, enum clk_reset_action action)
497{
498 return branch_reset(&to_rcg_clk(clk)->b, action);
499}
500
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700501static struct clk_ops clk_ops_rcg_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700502 .enable = rcg_clk_enable,
503 .disable = rcg_clk_disable,
504 .auto_off = rcg_clk_auto_off,
Matt Wagantall53d968f2011-07-19 13:22:53 -0700505 .handoff = rcg_clk_handoff,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700506 .set_rate = rcg_clk_set_rate,
507 .set_min_rate = rcg_clk_set_min_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700508 .get_rate = rcg_clk_get_rate,
509 .list_rate = rcg_clk_list_rate,
510 .is_enabled = rcg_clk_is_enabled,
511 .round_rate = rcg_clk_round_rate,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700512 .reset = soc_clk_reset,
513 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700514 .get_parent = rcg_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700515};
516
517static struct clk_ops clk_ops_branch = {
518 .enable = branch_clk_enable,
519 .disable = branch_clk_disable,
520 .auto_off = branch_clk_auto_off,
521 .is_enabled = branch_clk_is_enabled,
522 .reset = branch_clk_reset,
523 .is_local = local_clk_is_local,
524 .get_parent = branch_clk_get_parent,
525 .set_parent = branch_clk_set_parent,
526};
527
528static struct clk_ops clk_ops_reset = {
529 .reset = branch_clk_reset,
530 .is_local = local_clk_is_local,
531};
532
533/* AXI Interfaces */
534static struct branch_clk gmem_axi_clk = {
535 .b = {
536 .ctl_reg = MAXI_EN_REG,
537 .en_mask = BIT(24),
538 .halt_reg = DBG_BUS_VEC_E_REG,
539 .halt_bit = 6,
540 },
541 .c = {
542 .dbg_name = "gmem_axi_clk",
543 .ops = &clk_ops_branch,
544 CLK_INIT(gmem_axi_clk.c),
545 },
546};
547
548static struct branch_clk ijpeg_axi_clk = {
549 .b = {
550 .ctl_reg = MAXI_EN_REG,
551 .en_mask = BIT(21),
552 .reset_reg = SW_RESET_AXI_REG,
553 .reset_mask = BIT(14),
554 .halt_reg = DBG_BUS_VEC_E_REG,
555 .halt_bit = 4,
556 },
557 .c = {
558 .dbg_name = "ijpeg_axi_clk",
559 .ops = &clk_ops_branch,
560 CLK_INIT(ijpeg_axi_clk.c),
561 },
562};
563
564static struct branch_clk imem_axi_clk = {
565 .b = {
566 .ctl_reg = MAXI_EN_REG,
567 .en_mask = BIT(22),
568 .reset_reg = SW_RESET_CORE_REG,
569 .reset_mask = BIT(10),
570 .halt_reg = DBG_BUS_VEC_E_REG,
571 .halt_bit = 7,
572 },
573 .c = {
574 .dbg_name = "imem_axi_clk",
575 .ops = &clk_ops_branch,
576 CLK_INIT(imem_axi_clk.c),
577 },
578};
579
580static struct branch_clk jpegd_axi_clk = {
581 .b = {
582 .ctl_reg = MAXI_EN_REG,
583 .en_mask = BIT(25),
584 .halt_reg = DBG_BUS_VEC_E_REG,
585 .halt_bit = 5,
586 },
587 .c = {
588 .dbg_name = "jpegd_axi_clk",
589 .ops = &clk_ops_branch,
590 CLK_INIT(jpegd_axi_clk.c),
591 },
592};
593
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700594static struct branch_clk vcodec_axi_b_clk = {
595 .b = {
596 .ctl_reg = MAXI_EN4_REG,
597 .en_mask = BIT(23),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700598 .halt_reg = DBG_BUS_VEC_I_REG,
599 .halt_bit = 25,
600 },
601 .c = {
602 .dbg_name = "vcodec_axi_b_clk",
603 .ops = &clk_ops_branch,
604 CLK_INIT(vcodec_axi_b_clk.c),
605 },
606};
607
Matt Wagantall91f42702011-07-14 12:01:15 -0700608static struct branch_clk vcodec_axi_a_clk = {
609 .b = {
610 .ctl_reg = MAXI_EN4_REG,
611 .en_mask = BIT(25),
Matt Wagantall91f42702011-07-14 12:01:15 -0700612 .halt_reg = DBG_BUS_VEC_I_REG,
613 .halt_bit = 26,
614 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700615 .c = {
616 .dbg_name = "vcodec_axi_a_clk",
617 .ops = &clk_ops_branch,
618 CLK_INIT(vcodec_axi_a_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700619 .depends = &vcodec_axi_b_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700620 },
621};
622
623static struct branch_clk vcodec_axi_clk = {
624 .b = {
625 .ctl_reg = MAXI_EN_REG,
626 .en_mask = BIT(19),
627 .reset_reg = SW_RESET_AXI_REG,
Matt Wagantallfe2ee052011-07-14 13:33:44 -0700628 .reset_mask = BIT(4)|BIT(5)|BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700629 .halt_reg = DBG_BUS_VEC_E_REG,
630 .halt_bit = 3,
631 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700632 .c = {
633 .dbg_name = "vcodec_axi_clk",
634 .ops = &clk_ops_branch,
635 CLK_INIT(vcodec_axi_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700636 .depends = &vcodec_axi_a_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700637 },
638};
639
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700640static struct branch_clk vfe_axi_clk = {
641 .b = {
642 .ctl_reg = MAXI_EN_REG,
643 .en_mask = BIT(18),
644 .reset_reg = SW_RESET_AXI_REG,
645 .reset_mask = BIT(9),
646 .halt_reg = DBG_BUS_VEC_E_REG,
647 .halt_bit = 0,
648 },
649 .c = {
650 .dbg_name = "vfe_axi_clk",
651 .ops = &clk_ops_branch,
652 CLK_INIT(vfe_axi_clk.c),
653 },
654};
655
656static struct branch_clk mdp_axi_clk = {
657 .b = {
658 .ctl_reg = MAXI_EN_REG,
659 .en_mask = BIT(23),
660 .reset_reg = SW_RESET_AXI_REG,
661 .reset_mask = BIT(13),
662 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700663 .halt_bit = 8,
664 },
665 .c = {
666 .dbg_name = "mdp_axi_clk",
667 .ops = &clk_ops_branch,
668 CLK_INIT(mdp_axi_clk.c),
669 },
670};
671
672static struct branch_clk rot_axi_clk = {
673 .b = {
674 .ctl_reg = MAXI_EN2_REG,
675 .en_mask = BIT(24),
676 .reset_reg = SW_RESET_AXI_REG,
677 .reset_mask = BIT(6),
678 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700679 .halt_bit = 2,
680 },
681 .c = {
682 .dbg_name = "rot_axi_clk",
683 .ops = &clk_ops_branch,
684 CLK_INIT(rot_axi_clk.c),
685 },
686};
687
688static struct branch_clk vpe_axi_clk = {
689 .b = {
690 .ctl_reg = MAXI_EN2_REG,
691 .en_mask = BIT(26),
692 .reset_reg = SW_RESET_AXI_REG,
693 .reset_mask = BIT(15),
694 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700695 .halt_bit = 1,
696 },
697 .c = {
698 .dbg_name = "vpe_axi_clk",
699 .ops = &clk_ops_branch,
700 CLK_INIT(vpe_axi_clk.c),
701 },
702};
703
704/* AHB Interfaces */
705static struct branch_clk amp_p_clk = {
706 .b = {
707 .ctl_reg = AHB_EN_REG,
708 .en_mask = BIT(24),
709 .halt_reg = DBG_BUS_VEC_F_REG,
710 .halt_bit = 18,
711 },
712 .c = {
713 .dbg_name = "amp_p_clk",
714 .ops = &clk_ops_branch,
715 CLK_INIT(amp_p_clk.c),
716 },
717};
718
Matt Wagantallc23eee92011-08-16 23:06:52 -0700719static struct branch_clk csi_p_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700720 .b = {
721 .ctl_reg = AHB_EN_REG,
722 .en_mask = BIT(7),
723 .reset_reg = SW_RESET_AHB_REG,
724 .reset_mask = BIT(17),
725 .halt_reg = DBG_BUS_VEC_F_REG,
726 .halt_bit = 16,
727 },
728 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -0700729 .dbg_name = "csi_p_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700730 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -0700731 CLK_INIT(csi_p_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700732 },
733};
734
735static struct branch_clk dsi1_m_p_clk = {
736 .b = {
737 .ctl_reg = AHB_EN_REG,
738 .en_mask = BIT(9),
739 .reset_reg = SW_RESET_AHB_REG,
740 .reset_mask = BIT(6),
741 .halt_reg = DBG_BUS_VEC_F_REG,
742 .halt_bit = 19,
743 },
744 .c = {
745 .dbg_name = "dsi1_m_p_clk",
746 .ops = &clk_ops_branch,
747 CLK_INIT(dsi1_m_p_clk.c),
748 },
749};
750
751static struct branch_clk dsi1_s_p_clk = {
752 .b = {
753 .ctl_reg = AHB_EN_REG,
754 .en_mask = BIT(18),
755 .reset_reg = SW_RESET_AHB_REG,
756 .reset_mask = BIT(5),
757 .halt_reg = DBG_BUS_VEC_F_REG,
758 .halt_bit = 21,
759 },
760 .c = {
761 .dbg_name = "dsi1_s_p_clk",
762 .ops = &clk_ops_branch,
763 CLK_INIT(dsi1_s_p_clk.c),
764 },
765};
766
767static struct branch_clk dsi2_m_p_clk = {
768 .b = {
769 .ctl_reg = AHB_EN_REG,
770 .en_mask = BIT(17),
771 .reset_reg = SW_RESET_AHB2_REG,
772 .reset_mask = BIT(1),
773 .halt_reg = DBG_BUS_VEC_E_REG,
774 .halt_bit = 18,
775 },
776 .c = {
777 .dbg_name = "dsi2_m_p_clk",
778 .ops = &clk_ops_branch,
779 CLK_INIT(dsi2_m_p_clk.c),
780 },
781};
782
783static struct branch_clk dsi2_s_p_clk = {
784 .b = {
785 .ctl_reg = AHB_EN_REG,
786 .en_mask = BIT(22),
787 .reset_reg = SW_RESET_AHB2_REG,
788 .reset_mask = BIT(0),
789 .halt_reg = DBG_BUS_VEC_F_REG,
790 .halt_bit = 20,
791 },
792 .c = {
793 .dbg_name = "dsi2_s_p_clk",
794 .ops = &clk_ops_branch,
795 CLK_INIT(dsi2_s_p_clk.c),
796 },
797};
798
799static struct branch_clk gfx2d0_p_clk = {
800 .b = {
801 .ctl_reg = AHB_EN_REG,
802 .en_mask = BIT(19),
803 .reset_reg = SW_RESET_AHB_REG,
804 .reset_mask = BIT(12),
805 .halt_reg = DBG_BUS_VEC_F_REG,
806 .halt_bit = 2,
807 },
808 .c = {
809 .dbg_name = "gfx2d0_p_clk",
810 .ops = &clk_ops_branch,
811 CLK_INIT(gfx2d0_p_clk.c),
812 },
813};
814
815static struct branch_clk gfx2d1_p_clk = {
816 .b = {
817 .ctl_reg = AHB_EN_REG,
818 .en_mask = BIT(2),
819 .reset_reg = SW_RESET_AHB_REG,
820 .reset_mask = BIT(11),
821 .halt_reg = DBG_BUS_VEC_F_REG,
822 .halt_bit = 3,
823 },
824 .c = {
825 .dbg_name = "gfx2d1_p_clk",
826 .ops = &clk_ops_branch,
827 CLK_INIT(gfx2d1_p_clk.c),
828 },
829};
830
831static struct branch_clk gfx3d_p_clk = {
832 .b = {
833 .ctl_reg = AHB_EN_REG,
834 .en_mask = BIT(3),
835 .reset_reg = SW_RESET_AHB_REG,
836 .reset_mask = BIT(10),
837 .halt_reg = DBG_BUS_VEC_F_REG,
838 .halt_bit = 4,
839 },
840 .c = {
841 .dbg_name = "gfx3d_p_clk",
842 .ops = &clk_ops_branch,
843 CLK_INIT(gfx3d_p_clk.c),
844 },
845};
846
847static struct branch_clk hdmi_m_p_clk = {
848 .b = {
849 .ctl_reg = AHB_EN_REG,
850 .en_mask = BIT(14),
851 .reset_reg = SW_RESET_AHB_REG,
852 .reset_mask = BIT(9),
853 .halt_reg = DBG_BUS_VEC_F_REG,
854 .halt_bit = 5,
855 },
856 .c = {
857 .dbg_name = "hdmi_m_p_clk",
858 .ops = &clk_ops_branch,
859 CLK_INIT(hdmi_m_p_clk.c),
860 },
861};
862
863static struct branch_clk hdmi_s_p_clk = {
864 .b = {
865 .ctl_reg = AHB_EN_REG,
866 .en_mask = BIT(4),
867 .reset_reg = SW_RESET_AHB_REG,
868 .reset_mask = BIT(9),
869 .halt_reg = DBG_BUS_VEC_F_REG,
870 .halt_bit = 6,
871 },
872 .c = {
873 .dbg_name = "hdmi_s_p_clk",
874 .ops = &clk_ops_branch,
875 CLK_INIT(hdmi_s_p_clk.c),
876 },
877};
878
879static struct branch_clk ijpeg_p_clk = {
880 .b = {
881 .ctl_reg = AHB_EN_REG,
882 .en_mask = BIT(5),
883 .reset_reg = SW_RESET_AHB_REG,
884 .reset_mask = BIT(7),
885 .halt_reg = DBG_BUS_VEC_F_REG,
886 .halt_bit = 9,
887 },
888 .c = {
889 .dbg_name = "ijpeg_p_clk",
890 .ops = &clk_ops_branch,
891 CLK_INIT(ijpeg_p_clk.c),
892 },
893};
894
895static struct branch_clk imem_p_clk = {
896 .b = {
897 .ctl_reg = AHB_EN_REG,
898 .en_mask = BIT(6),
899 .reset_reg = SW_RESET_AHB_REG,
900 .reset_mask = BIT(8),
901 .halt_reg = DBG_BUS_VEC_F_REG,
902 .halt_bit = 10,
903 },
904 .c = {
905 .dbg_name = "imem_p_clk",
906 .ops = &clk_ops_branch,
907 CLK_INIT(imem_p_clk.c),
908 },
909};
910
911static struct branch_clk jpegd_p_clk = {
912 .b = {
913 .ctl_reg = AHB_EN_REG,
914 .en_mask = BIT(21),
915 .reset_reg = SW_RESET_AHB_REG,
916 .reset_mask = BIT(4),
917 .halt_reg = DBG_BUS_VEC_F_REG,
918 .halt_bit = 7,
919 },
920 .c = {
921 .dbg_name = "jpegd_p_clk",
922 .ops = &clk_ops_branch,
923 CLK_INIT(jpegd_p_clk.c),
924 },
925};
926
927static struct branch_clk mdp_p_clk = {
928 .b = {
929 .ctl_reg = AHB_EN_REG,
930 .en_mask = BIT(10),
931 .reset_reg = SW_RESET_AHB_REG,
932 .reset_mask = BIT(3),
933 .halt_reg = DBG_BUS_VEC_F_REG,
934 .halt_bit = 11,
935 },
936 .c = {
937 .dbg_name = "mdp_p_clk",
938 .ops = &clk_ops_branch,
939 CLK_INIT(mdp_p_clk.c),
940 },
941};
942
943static struct branch_clk rot_p_clk = {
944 .b = {
945 .ctl_reg = AHB_EN_REG,
946 .en_mask = BIT(12),
947 .reset_reg = SW_RESET_AHB_REG,
948 .reset_mask = BIT(2),
949 .halt_reg = DBG_BUS_VEC_F_REG,
950 .halt_bit = 13,
951 },
952 .c = {
953 .dbg_name = "rot_p_clk",
954 .ops = &clk_ops_branch,
955 CLK_INIT(rot_p_clk.c),
956 },
957};
958
959static struct branch_clk smmu_p_clk = {
960 .b = {
961 .ctl_reg = AHB_EN_REG,
962 .en_mask = BIT(15),
963 .halt_reg = DBG_BUS_VEC_F_REG,
964 .halt_bit = 22,
965 },
966 .c = {
967 .dbg_name = "smmu_p_clk",
968 .ops = &clk_ops_branch,
969 CLK_INIT(smmu_p_clk.c),
970 },
971};
972
973static struct branch_clk tv_enc_p_clk = {
974 .b = {
975 .ctl_reg = AHB_EN_REG,
976 .en_mask = BIT(25),
977 .reset_reg = SW_RESET_AHB_REG,
978 .reset_mask = BIT(15),
979 .halt_reg = DBG_BUS_VEC_F_REG,
980 .halt_bit = 23,
981 },
982 .c = {
983 .dbg_name = "tv_enc_p_clk",
984 .ops = &clk_ops_branch,
985 CLK_INIT(tv_enc_p_clk.c),
986 },
987};
988
989static struct branch_clk vcodec_p_clk = {
990 .b = {
991 .ctl_reg = AHB_EN_REG,
992 .en_mask = BIT(11),
993 .reset_reg = SW_RESET_AHB_REG,
994 .reset_mask = BIT(1),
995 .halt_reg = DBG_BUS_VEC_F_REG,
996 .halt_bit = 12,
997 },
998 .c = {
999 .dbg_name = "vcodec_p_clk",
1000 .ops = &clk_ops_branch,
1001 CLK_INIT(vcodec_p_clk.c),
1002 },
1003};
1004
1005static struct branch_clk vfe_p_clk = {
1006 .b = {
1007 .ctl_reg = AHB_EN_REG,
1008 .en_mask = BIT(13),
1009 .reset_reg = SW_RESET_AHB_REG,
1010 .reset_mask = BIT(0),
1011 .halt_reg = DBG_BUS_VEC_F_REG,
1012 .halt_bit = 14,
1013 },
1014 .c = {
1015 .dbg_name = "vfe_p_clk",
1016 .ops = &clk_ops_branch,
1017 CLK_INIT(vfe_p_clk.c),
1018 },
1019};
1020
1021static struct branch_clk vpe_p_clk = {
1022 .b = {
1023 .ctl_reg = AHB_EN_REG,
1024 .en_mask = BIT(16),
1025 .reset_reg = SW_RESET_AHB_REG,
1026 .reset_mask = BIT(14),
1027 .halt_reg = DBG_BUS_VEC_F_REG,
1028 .halt_bit = 15,
1029 },
1030 .c = {
1031 .dbg_name = "vpe_p_clk",
1032 .ops = &clk_ops_branch,
1033 CLK_INIT(vpe_p_clk.c),
1034 },
1035};
1036
1037/*
1038 * Peripheral Clocks
1039 */
1040#define CLK_GSBI_UART(i, n, h_r, h_b) \
1041 struct rcg_clk i##_clk = { \
1042 .b = { \
1043 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
1044 .en_mask = BIT(9), \
1045 .reset_reg = GSBIn_RESET_REG(n), \
1046 .reset_mask = BIT(0), \
1047 .halt_reg = h_r, \
1048 .halt_bit = h_b, \
1049 }, \
1050 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
1051 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
1052 .root_en_mask = BIT(11), \
1053 .ns_mask = (BM(31, 16) | BM(6, 0)), \
1054 .set_rate = set_rate_mnd, \
1055 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001056 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001057 .c = { \
1058 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001059 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001060 CLK_INIT(i##_clk.c), \
1061 }, \
1062 }
1063#define F_GSBI_UART(f, s, d, m, n, v) \
1064 { \
1065 .freq_hz = f, \
1066 .src_clk = &s##_clk.c, \
1067 .md_val = MD16(m, n), \
1068 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1069 .mnd_en_mask = BIT(8) * !!(n), \
1070 .sys_vdd = v, \
1071 }
1072static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
1073 F_GSBI_UART( 0, gnd, 1, 0, 0, NONE),
1074 F_GSBI_UART( 1843200, pll8, 1, 3, 625, LOW),
1075 F_GSBI_UART( 3686400, pll8, 1, 6, 625, LOW),
1076 F_GSBI_UART( 7372800, pll8, 1, 12, 625, LOW),
1077 F_GSBI_UART(14745600, pll8, 1, 24, 625, LOW),
1078 F_GSBI_UART(16000000, pll8, 4, 1, 6, LOW),
1079 F_GSBI_UART(24000000, pll8, 4, 1, 4, LOW),
1080 F_GSBI_UART(32000000, pll8, 4, 1, 3, LOW),
1081 F_GSBI_UART(40000000, pll8, 1, 5, 48, NOMINAL),
1082 F_GSBI_UART(46400000, pll8, 1, 29, 240, NOMINAL),
1083 F_GSBI_UART(48000000, pll8, 4, 1, 2, NOMINAL),
1084 F_GSBI_UART(51200000, pll8, 1, 2, 15, NOMINAL),
1085 F_GSBI_UART(56000000, pll8, 1, 7, 48, NOMINAL),
1086 F_GSBI_UART(58982400, pll8, 1, 96, 625, NOMINAL),
1087 F_GSBI_UART(64000000, pll8, 2, 1, 3, NOMINAL),
1088 F_END
1089};
1090
1091static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1092static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1093static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1094static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1095static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1096static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1097static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1098static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1099static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1100static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1101static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1102static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1103
1104#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1105 struct rcg_clk i##_clk = { \
1106 .b = { \
1107 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1108 .en_mask = BIT(9), \
1109 .reset_reg = GSBIn_RESET_REG(n), \
1110 .reset_mask = BIT(0), \
1111 .halt_reg = h_r, \
1112 .halt_bit = h_b, \
1113 }, \
1114 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1115 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1116 .root_en_mask = BIT(11), \
1117 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1118 .set_rate = set_rate_mnd, \
1119 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001120 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001121 .c = { \
1122 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001123 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001124 CLK_INIT(i##_clk.c), \
1125 }, \
1126 }
1127#define F_GSBI_QUP(f, s, d, m, n, v) \
1128 { \
1129 .freq_hz = f, \
1130 .src_clk = &s##_clk.c, \
1131 .md_val = MD8(16, m, 0, n), \
1132 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1133 .mnd_en_mask = BIT(8) * !!(n), \
1134 .sys_vdd = v, \
1135 }
1136static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
1137 F_GSBI_QUP( 0, gnd, 1, 0, 0, NONE),
1138 F_GSBI_QUP( 1100000, pxo, 1, 2, 49, LOW),
1139 F_GSBI_QUP( 5400000, pxo, 1, 1, 5, LOW),
1140 F_GSBI_QUP(10800000, pxo, 1, 2, 5, LOW),
1141 F_GSBI_QUP(15060000, pll8, 1, 2, 51, LOW),
1142 F_GSBI_QUP(24000000, pll8, 4, 1, 4, LOW),
1143 F_GSBI_QUP(25600000, pll8, 1, 1, 15, NOMINAL),
1144 F_GSBI_QUP(27000000, pxo, 1, 0, 0, NOMINAL),
1145 F_GSBI_QUP(48000000, pll8, 4, 1, 2, NOMINAL),
1146 F_GSBI_QUP(51200000, pll8, 1, 2, 15, NOMINAL),
1147 F_END
1148};
1149
1150static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1151static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1152static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1153static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1154static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1155static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1156static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1157static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1158static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1159static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1160static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1161static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1162
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001163#define F_QDSS(f, s, d, v) \
1164 { \
1165 .freq_hz = f, \
1166 .src_clk = &s##_clk.c, \
1167 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
1168 .sys_vdd = v, \
1169 }
1170static struct clk_freq_tbl clk_tbl_qdss[] = {
1171 F_QDSS(128000000, pll8, 3, LOW),
1172 F_QDSS(300000000, pll3, 4, NOMINAL),
1173 F_END
1174};
1175
1176struct qdss_bank {
1177 const u32 bank_sel_mask;
1178 void __iomem *const ns_reg;
1179 const u32 ns_mask;
1180};
1181
1182static void set_rate_qdss(struct rcg_clk *clk, struct clk_freq_tbl *nf)
1183{
1184 const struct qdss_bank *bank = clk->bank_info;
1185 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1186
1187 /* Switch to bank 0 (always sourced from PXO) */
1188 reg = readl_relaxed(clk->ns_reg);
1189 reg &= ~bank_sel_mask;
1190 writel_relaxed(reg, clk->ns_reg);
1191 /*
1192 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1193 * MUX to fully switch sources.
1194 */
1195 mb();
1196 udelay(1);
1197
1198 /* Set source and divider */
1199 reg = readl_relaxed(bank->ns_reg);
1200 reg &= ~bank->ns_mask;
1201 reg |= nf->ns_val;
1202 writel_relaxed(reg, bank->ns_reg);
1203
1204 /* Switch to reprogrammed bank */
1205 reg = readl_relaxed(clk->ns_reg);
1206 reg |= bank_sel_mask;
1207 writel_relaxed(reg, clk->ns_reg);
1208 /*
1209 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1210 * MUX to fully switch sources.
1211 */
1212 mb();
1213 udelay(1);
1214}
1215
1216#define QDSS_CLK_ROOT_ENA BIT(1)
1217
1218static int qdss_clk_enable(struct clk *c)
1219{
1220 struct rcg_clk *clk = to_rcg_clk(c);
1221 const struct qdss_bank *bank = clk->bank_info;
1222 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1223 int ret;
1224
1225 /* Switch to bank 1 */
1226 reg = readl_relaxed(clk->ns_reg);
1227 reg |= bank_sel_mask;
1228 writel_relaxed(reg, clk->ns_reg);
1229 /* Enable root */
1230 reg |= QDSS_CLK_ROOT_ENA;
1231 writel_relaxed(reg, clk->ns_reg);
1232
1233 ret = rcg_clk_enable(c);
1234 if (ret) {
1235 /* Disable root */
1236 reg = readl_relaxed(clk->ns_reg);
1237 reg &= ~QDSS_CLK_ROOT_ENA;
1238 writel_relaxed(reg, clk->ns_reg);
1239 /* Switch to bank 0 */
1240 reg &= ~bank_sel_mask;
1241 writel_relaxed(reg, clk->ns_reg);
1242 }
1243 return ret;
1244}
1245
1246static void qdss_clk_disable(struct clk *c)
1247{
1248 struct rcg_clk *clk = to_rcg_clk(c);
1249 const struct qdss_bank *bank = clk->bank_info;
1250 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1251
1252 rcg_clk_disable(c);
1253 /* Disable root */
1254 reg = readl_relaxed(clk->ns_reg);
1255 reg &= ~QDSS_CLK_ROOT_ENA;
1256 writel_relaxed(reg, clk->ns_reg);
1257 /* Switch to bank 0 */
1258 reg &= ~bank_sel_mask;
1259 writel_relaxed(reg, clk->ns_reg);
1260}
1261
1262static void qdss_clk_auto_off(struct clk *c)
1263{
1264 struct rcg_clk *clk = to_rcg_clk(c);
1265 const struct qdss_bank *bank = clk->bank_info;
1266 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1267
1268 rcg_clk_auto_off(c);
1269 /* Disable root */
1270 reg = readl_relaxed(clk->ns_reg);
1271 reg &= ~QDSS_CLK_ROOT_ENA;
1272 writel_relaxed(reg, clk->ns_reg);
1273 /* Switch to bank 0 */
1274 reg &= ~bank_sel_mask;
1275 writel_relaxed(reg, clk->ns_reg);
1276}
1277
1278static struct clk_ops clk_ops_qdss = {
1279 .enable = qdss_clk_enable,
1280 .disable = qdss_clk_disable,
1281 .auto_off = qdss_clk_auto_off,
1282 .set_rate = rcg_clk_set_rate,
1283 .set_min_rate = rcg_clk_set_min_rate,
1284 .get_rate = rcg_clk_get_rate,
1285 .list_rate = rcg_clk_list_rate,
1286 .is_enabled = rcg_clk_is_enabled,
1287 .round_rate = rcg_clk_round_rate,
1288 .reset = soc_clk_reset,
1289 .is_local = local_clk_is_local,
1290 .get_parent = rcg_clk_get_parent,
1291};
1292
1293static struct qdss_bank bdiv_info_qdss = {
1294 .bank_sel_mask = BIT(0),
1295 .ns_reg = QDSS_AT_CLK_SRC1_NS_REG,
1296 .ns_mask = BM(6, 0),
1297};
1298
1299static struct rcg_clk qdss_at_clk = {
1300 .b = {
1301 .ctl_reg = QDSS_AT_CLK_NS_REG,
1302 .en_mask = BIT(6),
1303 .reset_reg = QDSS_RESETS_REG,
1304 .reset_mask = BIT(0),
1305 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1306 .halt_bit = 10,
1307 .halt_check = HALT_VOTED,
1308 },
1309 .ns_reg = QDSS_AT_CLK_SRC_CTL_REG,
1310 .set_rate = set_rate_qdss,
1311 .freq_tbl = clk_tbl_qdss,
1312 .bank_info = &bdiv_info_qdss,
1313 .current_freq = &rcg_dummy_freq,
1314 .c = {
1315 .dbg_name = "qdss_at_clk",
1316 .ops = &clk_ops_qdss,
1317 CLK_INIT(qdss_at_clk.c),
1318 },
1319};
1320
1321static struct branch_clk qdss_pclkdbg_clk = {
1322 .b = {
1323 .ctl_reg = QDSS_AT_CLK_NS_REG,
1324 .en_mask = BIT(4),
1325 .reset_reg = QDSS_RESETS_REG,
1326 .reset_mask = BIT(0),
1327 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1328 .halt_bit = 9,
1329 .halt_check = HALT_VOTED
1330 },
1331 .parent = &qdss_at_clk.c,
1332 .c = {
1333 .dbg_name = "qdss_pclkdbg_clk",
1334 .ops = &clk_ops_branch,
1335 CLK_INIT(qdss_pclkdbg_clk.c),
1336 },
1337};
1338
1339static struct qdss_bank bdiv_info_qdss_trace = {
1340 .bank_sel_mask = BIT(0),
1341 .ns_reg = QDSS_TRACECLKIN_CLK_SRC1_NS_REG,
1342 .ns_mask = BM(6, 0),
1343};
1344
1345static struct rcg_clk qdss_traceclkin_clk = {
1346 .b = {
1347 .ctl_reg = QDSS_TRACECLKIN_CTL_REG,
1348 .en_mask = BIT(4),
1349 .reset_reg = QDSS_RESETS_REG,
1350 .reset_mask = BIT(0),
1351 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1352 .halt_bit = 8,
1353 .halt_check = HALT_VOTED,
1354 },
1355 .ns_reg = QDSS_TRACECLKIN_CLK_SRC_CTL_REG,
1356 .set_rate = set_rate_qdss,
1357 .freq_tbl = clk_tbl_qdss,
1358 .bank_info = &bdiv_info_qdss_trace,
1359 .current_freq = &rcg_dummy_freq,
1360 .c = {
1361 .dbg_name = "qdss_traceclkin_clk",
1362 .ops = &clk_ops_qdss,
1363 CLK_INIT(qdss_traceclkin_clk.c),
1364 },
1365};
1366
1367static struct clk_freq_tbl clk_tbl_qdss_tsctr[] = {
1368 F_QDSS(200000000, pll3, 6, LOW),
1369 F_QDSS(400000000, pll3, 3, NOMINAL),
1370 F_END
1371};
1372
1373static struct qdss_bank bdiv_info_qdss_tsctr = {
1374 .bank_sel_mask = BIT(0),
1375 .ns_reg = QDSS_TSCTR_CLK_SRC1_NS_REG,
1376 .ns_mask = BM(6, 0),
1377};
1378
1379static struct rcg_clk qdss_tsctr_clk = {
1380 .b = {
1381 .ctl_reg = QDSS_TSCTR_CTL_REG,
1382 .en_mask = BIT(4),
1383 .reset_reg = QDSS_RESETS_REG,
1384 .reset_mask = BIT(3),
1385 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1386 .halt_bit = 7,
1387 .halt_check = HALT_VOTED,
1388 },
1389 .ns_reg = QDSS_TSCTR_CLK_SRC_CTL_REG,
1390 .set_rate = set_rate_qdss,
1391 .freq_tbl = clk_tbl_qdss_tsctr,
1392 .bank_info = &bdiv_info_qdss_tsctr,
1393 .current_freq = &rcg_dummy_freq,
1394 .c = {
1395 .dbg_name = "qdss_tsctr_clk",
1396 .ops = &clk_ops_qdss,
1397 CLK_INIT(qdss_tsctr_clk.c),
1398 },
1399};
1400
1401static struct branch_clk qdss_stm_clk = {
1402 .b = {
1403 .ctl_reg = QDSS_STM_CLK_CTL_REG,
1404 .en_mask = BIT(4),
1405 .reset_reg = QDSS_RESETS_REG,
1406 .reset_mask = BIT(1),
1407 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
1408 .halt_bit = 20,
1409 .halt_check = HALT_VOTED,
1410 },
1411 .c = {
1412 .dbg_name = "qdss_stm_clk",
1413 .ops = &clk_ops_branch,
1414 CLK_INIT(qdss_stm_clk.c),
1415 },
1416};
1417
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001418#define F_PDM(f, s, d, v) \
1419 { \
1420 .freq_hz = f, \
1421 .src_clk = &s##_clk.c, \
1422 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
1423 .sys_vdd = v, \
1424 }
1425static struct clk_freq_tbl clk_tbl_pdm[] = {
1426 F_PDM( 0, gnd, 1, NONE),
1427 F_PDM(27000000, pxo, 1, LOW),
1428 F_END
1429};
1430
1431static struct rcg_clk pdm_clk = {
1432 .b = {
1433 .ctl_reg = PDM_CLK_NS_REG,
1434 .en_mask = BIT(9),
1435 .reset_reg = PDM_CLK_NS_REG,
1436 .reset_mask = BIT(12),
1437 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1438 .halt_bit = 3,
1439 },
1440 .ns_reg = PDM_CLK_NS_REG,
1441 .root_en_mask = BIT(11),
1442 .ns_mask = BM(1, 0),
1443 .set_rate = set_rate_nop,
1444 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001445 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001446 .c = {
1447 .dbg_name = "pdm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001448 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001449 CLK_INIT(pdm_clk.c),
1450 },
1451};
1452
1453static struct branch_clk pmem_clk = {
1454 .b = {
1455 .ctl_reg = PMEM_ACLK_CTL_REG,
1456 .en_mask = BIT(4),
1457 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1458 .halt_bit = 20,
1459 },
1460 .c = {
1461 .dbg_name = "pmem_clk",
1462 .ops = &clk_ops_branch,
1463 CLK_INIT(pmem_clk.c),
1464 },
1465};
1466
1467#define F_PRNG(f, s, v) \
1468 { \
1469 .freq_hz = f, \
1470 .src_clk = &s##_clk.c, \
1471 .sys_vdd = v, \
1472 }
1473static struct clk_freq_tbl clk_tbl_prng[] = {
1474 F_PRNG(64000000, pll8, NOMINAL),
1475 F_END
1476};
1477
1478static struct rcg_clk prng_clk = {
1479 .b = {
1480 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1481 .en_mask = BIT(10),
1482 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1483 .halt_check = HALT_VOTED,
1484 .halt_bit = 10,
1485 },
1486 .set_rate = set_rate_nop,
1487 .freq_tbl = clk_tbl_prng,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001488 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001489 .c = {
1490 .dbg_name = "prng_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001491 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001492 CLK_INIT(prng_clk.c),
1493 },
1494};
1495
Stephen Boyda78a7402011-08-02 11:23:39 -07001496#define CLK_SDC(name, n, h_b, f_table) \
1497 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001498 .b = { \
1499 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1500 .en_mask = BIT(9), \
1501 .reset_reg = SDCn_RESET_REG(n), \
1502 .reset_mask = BIT(0), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001503 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001504 .halt_bit = h_b, \
1505 }, \
1506 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1507 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1508 .root_en_mask = BIT(11), \
1509 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1510 .set_rate = set_rate_mnd, \
Stephen Boyda78a7402011-08-02 11:23:39 -07001511 .freq_tbl = f_table, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001512 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001513 .c = { \
Stephen Boyda78a7402011-08-02 11:23:39 -07001514 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001515 .ops = &clk_ops_rcg_8960, \
Stephen Boyda78a7402011-08-02 11:23:39 -07001516 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001517 }, \
1518 }
1519#define F_SDC(f, s, d, m, n, v) \
1520 { \
1521 .freq_hz = f, \
1522 .src_clk = &s##_clk.c, \
1523 .md_val = MD8(16, m, 0, n), \
1524 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1525 .mnd_en_mask = BIT(8) * !!(n), \
1526 .sys_vdd = v, \
1527 }
Stephen Boyda78a7402011-08-02 11:23:39 -07001528static struct clk_freq_tbl clk_tbl_sdc1_2[] = {
1529 F_SDC( 0, gnd, 1, 0, 0, NONE),
1530 F_SDC( 144000, pxo, 3, 2, 125, LOW),
1531 F_SDC( 400000, pll8, 4, 1, 240, LOW),
1532 F_SDC( 16000000, pll8, 4, 1, 6, LOW),
1533 F_SDC( 17070000, pll8, 1, 2, 45, LOW),
1534 F_SDC( 20210000, pll8, 1, 1, 19, LOW),
1535 F_SDC( 24000000, pll8, 4, 1, 4, LOW),
1536 F_SDC( 48000000, pll8, 4, 1, 2, LOW),
1537 F_SDC( 64000000, pll8, 3, 1, 2, NOMINAL),
1538 F_SDC( 96000000, pll8, 4, 0, 0, NOMINAL),
1539 F_END
1540};
1541
1542static CLK_SDC(sdc1_clk, 1, 6, clk_tbl_sdc1_2);
1543static CLK_SDC(sdc2_clk, 2, 5, clk_tbl_sdc1_2);
1544
1545static struct clk_freq_tbl clk_tbl_sdc3[] = {
1546 F_SDC( 0, gnd, 1, 0, 0, NONE),
1547 F_SDC( 144000, pxo, 3, 2, 125, LOW),
1548 F_SDC( 400000, pll8, 4, 1, 240, LOW),
1549 F_SDC( 16000000, pll8, 4, 1, 6, LOW),
1550 F_SDC( 17070000, pll8, 1, 2, 45, LOW),
1551 F_SDC( 20210000, pll8, 1, 1, 19, LOW),
1552 F_SDC( 24000000, pll8, 4, 1, 4, LOW),
1553 F_SDC( 48000000, pll8, 4, 1, 2, LOW),
1554 F_SDC( 64000000, pll8, 3, 1, 2, LOW),
1555 F_SDC( 96000000, pll8, 4, 0, 0, LOW),
1556 F_SDC(192000000, pll8, 2, 0, 0, NOMINAL),
1557 F_END
1558};
1559
1560static CLK_SDC(sdc3_clk, 3, 4, clk_tbl_sdc3);
1561
1562static struct clk_freq_tbl clk_tbl_sdc4_5[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001563 F_SDC( 0, gnd, 1, 0, 0, NONE),
1564 F_SDC( 144000, pxo, 3, 2, 125, LOW),
1565 F_SDC( 400000, pll8, 4, 1, 240, LOW),
1566 F_SDC( 16000000, pll8, 4, 1, 6, LOW),
1567 F_SDC( 17070000, pll8, 1, 2, 45, LOW),
1568 F_SDC( 20210000, pll8, 1, 1, 19, LOW),
1569 F_SDC( 24000000, pll8, 4, 1, 4, LOW),
1570 F_SDC( 48000000, pll8, 4, 1, 2, NOMINAL),
1571 F_SDC( 64000000, pll8, 3, 1, 2, NOMINAL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001572 F_END
1573};
1574
Stephen Boyda78a7402011-08-02 11:23:39 -07001575static CLK_SDC(sdc4_clk, 4, 3, clk_tbl_sdc4_5);
1576static CLK_SDC(sdc5_clk, 5, 2, clk_tbl_sdc4_5);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001577
1578#define F_TSIF_REF(f, s, d, m, n, v) \
1579 { \
1580 .freq_hz = f, \
1581 .src_clk = &s##_clk.c, \
1582 .md_val = MD16(m, n), \
1583 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1584 .mnd_en_mask = BIT(8) * !!(n), \
1585 .sys_vdd = v, \
1586 }
1587static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
1588 F_TSIF_REF( 0, gnd, 1, 0, 0, NONE),
1589 F_TSIF_REF(105000, pxo, 1, 1, 256, LOW),
1590 F_END
1591};
1592
1593static struct rcg_clk tsif_ref_clk = {
1594 .b = {
1595 .ctl_reg = TSIF_REF_CLK_NS_REG,
1596 .en_mask = BIT(9),
1597 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1598 .halt_bit = 5,
1599 },
1600 .ns_reg = TSIF_REF_CLK_NS_REG,
1601 .md_reg = TSIF_REF_CLK_MD_REG,
1602 .root_en_mask = BIT(11),
1603 .ns_mask = (BM(31, 16) | BM(6, 0)),
1604 .set_rate = set_rate_mnd,
1605 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001606 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001607 .c = {
1608 .dbg_name = "tsif_ref_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001609 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001610 CLK_INIT(tsif_ref_clk.c),
1611 },
1612};
1613
1614#define F_TSSC(f, s, v) \
1615 { \
1616 .freq_hz = f, \
1617 .src_clk = &s##_clk.c, \
1618 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
1619 .sys_vdd = v, \
1620 }
1621static struct clk_freq_tbl clk_tbl_tssc[] = {
1622 F_TSSC( 0, gnd, NONE),
1623 F_TSSC(27000000, pxo, LOW),
1624 F_END
1625};
1626
1627static struct rcg_clk tssc_clk = {
1628 .b = {
1629 .ctl_reg = TSSC_CLK_CTL_REG,
1630 .en_mask = BIT(4),
1631 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1632 .halt_bit = 4,
1633 },
1634 .ns_reg = TSSC_CLK_CTL_REG,
1635 .ns_mask = BM(1, 0),
1636 .set_rate = set_rate_nop,
1637 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001638 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001639 .c = {
1640 .dbg_name = "tssc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001641 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001642 CLK_INIT(tssc_clk.c),
1643 },
1644};
1645
1646#define F_USB(f, s, d, m, n, v) \
1647 { \
1648 .freq_hz = f, \
1649 .src_clk = &s##_clk.c, \
1650 .md_val = MD8(16, m, 0, n), \
1651 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1652 .mnd_en_mask = BIT(8) * !!(n), \
1653 .sys_vdd = v, \
1654 }
1655static struct clk_freq_tbl clk_tbl_usb[] = {
1656 F_USB( 0, gnd, 1, 0, 0, NONE),
1657 F_USB(60000000, pll8, 1, 5, 32, NOMINAL),
1658 F_END
1659};
1660
1661static struct rcg_clk usb_hs1_xcvr_clk = {
1662 .b = {
1663 .ctl_reg = USB_HS1_XCVR_FS_CLK_NS_REG,
1664 .en_mask = BIT(9),
1665 .reset_reg = USB_HS1_RESET_REG,
1666 .reset_mask = BIT(0),
1667 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1668 .halt_bit = 0,
1669 },
1670 .ns_reg = USB_HS1_XCVR_FS_CLK_NS_REG,
1671 .md_reg = USB_HS1_XCVR_FS_CLK_MD_REG,
1672 .root_en_mask = BIT(11),
1673 .ns_mask = (BM(23, 16) | BM(6, 0)),
1674 .set_rate = set_rate_mnd,
1675 .freq_tbl = clk_tbl_usb,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001676 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001677 .c = {
1678 .dbg_name = "usb_hs1_xcvr_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001679 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001680 CLK_INIT(usb_hs1_xcvr_clk.c),
1681 },
1682};
1683
Stephen Boyd94625ef2011-07-12 17:06:01 -07001684static struct clk_freq_tbl clk_tbl_usb_hsic[] = {
1685 F_USB( 0, gnd, 1, 0, 0, NONE),
1686 F_USB(60000000, pll8, 1, 5, 32, LOW),
1687 F_END
1688};
1689
1690static struct rcg_clk usb_hsic_xcvr_fs_clk = {
1691 .b = {
1692 .ctl_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1693 .en_mask = BIT(9),
1694 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1695 .halt_bit = 26,
1696 },
1697 .ns_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1698 .md_reg = USB_HSIC_XCVR_FS_CLK_MD_REG,
1699 .root_en_mask = BIT(11),
1700 .ns_mask = (BM(23, 16) | BM(6, 0)),
1701 .set_rate = set_rate_mnd,
1702 .freq_tbl = clk_tbl_usb_hsic,
1703 .current_freq = &rcg_dummy_freq,
1704 .c = {
1705 .dbg_name = "usb_hsic_xcvr_fs_clk",
1706 .ops = &clk_ops_rcg_8960,
1707 CLK_INIT(usb_hsic_xcvr_fs_clk.c),
1708 },
1709};
1710
1711static struct branch_clk usb_hsic_system_clk = {
1712 .b = {
1713 .ctl_reg = USB_HSIC_SYSTEM_CLK_CTL_REG,
1714 .en_mask = BIT(4),
1715 .reset_reg = USB_HSIC_RESET_REG,
1716 .reset_mask = BIT(0),
1717 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1718 .halt_bit = 24,
1719 },
1720 .parent = &usb_hsic_xcvr_fs_clk.c,
1721 .c = {
1722 .dbg_name = "usb_hsic_system_clk",
1723 .ops = &clk_ops_branch,
1724 CLK_INIT(usb_hsic_system_clk.c),
1725 },
1726};
1727
1728#define F_USB_HSIC(f, s, v) \
1729 { \
1730 .freq_hz = f, \
1731 .src_clk = &s##_clk.c, \
1732 .sys_vdd = v, \
1733 }
1734static struct clk_freq_tbl clk_tbl_usb2_hsic[] = {
1735 F_USB_HSIC(480000000, pll14, LOW),
1736 F_END
1737};
1738
1739static struct rcg_clk usb_hsic_hsic_src_clk = {
1740 .b = {
1741 .ctl_reg = USB_HSIC_HSIC_CLK_SRC_CTL_REG,
1742 .halt_check = NOCHECK,
1743 },
1744 .root_en_mask = BIT(0),
1745 .set_rate = set_rate_nop,
1746 .freq_tbl = clk_tbl_usb2_hsic,
1747 .current_freq = &rcg_dummy_freq,
1748 .c = {
1749 .dbg_name = "usb_hsic_hsic_src_clk",
1750 .ops = &clk_ops_rcg_8960,
1751 CLK_INIT(usb_hsic_hsic_src_clk.c),
1752 },
1753};
1754
1755static struct branch_clk usb_hsic_hsic_clk = {
1756 .b = {
1757 .ctl_reg = USB_HSIC_HSIC_CLK_CTL_REG,
1758 .en_mask = BIT(0),
1759 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1760 .halt_bit = 19,
1761 },
1762 .parent = &usb_hsic_hsic_src_clk.c,
1763 .c = {
1764 .dbg_name = "usb_hsic_hsic_clk",
1765 .ops = &clk_ops_branch,
1766 CLK_INIT(usb_hsic_hsic_clk.c),
1767 },
1768};
1769
1770#define F_USB_HSIO_CAL(f, s, v) \
1771 { \
1772 .freq_hz = f, \
1773 .src_clk = &s##_clk.c, \
1774 .sys_vdd = v, \
1775 }
1776static struct clk_freq_tbl clk_tbl_usb_hsio_cal[] = {
1777 F_USB_HSIO_CAL(9000000, pxo, LOW),
1778 F_END
1779};
1780
1781static struct rcg_clk usb_hsic_hsio_cal_clk = {
1782 .b = {
1783 .ctl_reg = USB_HSIC_HSIO_CAL_CLK_CTL_REG,
1784 .en_mask = BIT(0),
1785 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1786 .halt_bit = 23,
1787 },
1788 .set_rate = set_rate_nop,
1789 .freq_tbl = clk_tbl_usb_hsio_cal,
1790 .current_freq = &rcg_dummy_freq,
1791 .c = {
1792 .dbg_name = "usb_hsic_hsio_cal_clk",
1793 .ops = &clk_ops_branch,
1794 CLK_INIT(usb_hsic_hsio_cal_clk.c),
1795 },
1796};
1797
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001798static struct branch_clk usb_phy0_clk = {
1799 .b = {
1800 .reset_reg = USB_PHY0_RESET_REG,
1801 .reset_mask = BIT(0),
1802 },
1803 .c = {
1804 .dbg_name = "usb_phy0_clk",
1805 .ops = &clk_ops_reset,
1806 CLK_INIT(usb_phy0_clk.c),
1807 },
1808};
1809
1810#define CLK_USB_FS(i, n) \
1811 struct rcg_clk i##_clk = { \
1812 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1813 .b = { \
1814 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1815 .halt_check = NOCHECK, \
1816 }, \
1817 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
1818 .root_en_mask = BIT(11), \
1819 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1820 .set_rate = set_rate_mnd, \
1821 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001822 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001823 .c = { \
1824 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001825 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001826 CLK_INIT(i##_clk.c), \
1827 }, \
1828 }
1829
1830static CLK_USB_FS(usb_fs1_src, 1);
1831static struct branch_clk usb_fs1_xcvr_clk = {
1832 .b = {
1833 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
1834 .en_mask = BIT(9),
1835 .reset_reg = USB_FSn_RESET_REG(1),
1836 .reset_mask = BIT(1),
1837 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1838 .halt_bit = 15,
1839 },
1840 .parent = &usb_fs1_src_clk.c,
1841 .c = {
1842 .dbg_name = "usb_fs1_xcvr_clk",
1843 .ops = &clk_ops_branch,
1844 CLK_INIT(usb_fs1_xcvr_clk.c),
1845 },
1846};
1847
1848static struct branch_clk usb_fs1_sys_clk = {
1849 .b = {
1850 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
1851 .en_mask = BIT(4),
1852 .reset_reg = USB_FSn_RESET_REG(1),
1853 .reset_mask = BIT(0),
1854 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1855 .halt_bit = 16,
1856 },
1857 .parent = &usb_fs1_src_clk.c,
1858 .c = {
1859 .dbg_name = "usb_fs1_sys_clk",
1860 .ops = &clk_ops_branch,
1861 CLK_INIT(usb_fs1_sys_clk.c),
1862 },
1863};
1864
1865static CLK_USB_FS(usb_fs2_src, 2);
1866static struct branch_clk usb_fs2_xcvr_clk = {
1867 .b = {
1868 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
1869 .en_mask = BIT(9),
1870 .reset_reg = USB_FSn_RESET_REG(2),
1871 .reset_mask = BIT(1),
1872 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1873 .halt_bit = 12,
1874 },
1875 .parent = &usb_fs2_src_clk.c,
1876 .c = {
1877 .dbg_name = "usb_fs2_xcvr_clk",
1878 .ops = &clk_ops_branch,
1879 CLK_INIT(usb_fs2_xcvr_clk.c),
1880 },
1881};
1882
1883static struct branch_clk usb_fs2_sys_clk = {
1884 .b = {
1885 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
1886 .en_mask = BIT(4),
1887 .reset_reg = USB_FSn_RESET_REG(2),
1888 .reset_mask = BIT(0),
1889 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1890 .halt_bit = 13,
1891 },
1892 .parent = &usb_fs2_src_clk.c,
1893 .c = {
1894 .dbg_name = "usb_fs2_sys_clk",
1895 .ops = &clk_ops_branch,
1896 CLK_INIT(usb_fs2_sys_clk.c),
1897 },
1898};
1899
1900/* Fast Peripheral Bus Clocks */
1901static struct branch_clk ce1_core_clk = {
1902 .b = {
1903 .ctl_reg = CE1_CORE_CLK_CTL_REG,
1904 .en_mask = BIT(4),
1905 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1906 .halt_bit = 27,
1907 },
1908 .c = {
1909 .dbg_name = "ce1_core_clk",
1910 .ops = &clk_ops_branch,
1911 CLK_INIT(ce1_core_clk.c),
1912 },
1913};
1914static struct branch_clk ce1_p_clk = {
1915 .b = {
1916 .ctl_reg = CE1_HCLK_CTL_REG,
1917 .en_mask = BIT(4),
1918 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1919 .halt_bit = 1,
1920 },
1921 .c = {
1922 .dbg_name = "ce1_p_clk",
1923 .ops = &clk_ops_branch,
1924 CLK_INIT(ce1_p_clk.c),
1925 },
1926};
1927
1928static struct branch_clk dma_bam_p_clk = {
1929 .b = {
1930 .ctl_reg = DMA_BAM_HCLK_CTL,
1931 .en_mask = BIT(4),
1932 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1933 .halt_bit = 12,
1934 },
1935 .c = {
1936 .dbg_name = "dma_bam_p_clk",
1937 .ops = &clk_ops_branch,
1938 CLK_INIT(dma_bam_p_clk.c),
1939 },
1940};
1941
1942static struct branch_clk gsbi1_p_clk = {
1943 .b = {
1944 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
1945 .en_mask = BIT(4),
1946 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1947 .halt_bit = 11,
1948 },
1949 .c = {
1950 .dbg_name = "gsbi1_p_clk",
1951 .ops = &clk_ops_branch,
1952 CLK_INIT(gsbi1_p_clk.c),
1953 },
1954};
1955
1956static struct branch_clk gsbi2_p_clk = {
1957 .b = {
1958 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
1959 .en_mask = BIT(4),
1960 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1961 .halt_bit = 7,
1962 },
1963 .c = {
1964 .dbg_name = "gsbi2_p_clk",
1965 .ops = &clk_ops_branch,
1966 CLK_INIT(gsbi2_p_clk.c),
1967 },
1968};
1969
1970static struct branch_clk gsbi3_p_clk = {
1971 .b = {
1972 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
1973 .en_mask = BIT(4),
1974 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1975 .halt_bit = 3,
1976 },
1977 .c = {
1978 .dbg_name = "gsbi3_p_clk",
1979 .ops = &clk_ops_branch,
1980 CLK_INIT(gsbi3_p_clk.c),
1981 },
1982};
1983
1984static struct branch_clk gsbi4_p_clk = {
1985 .b = {
1986 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
1987 .en_mask = BIT(4),
1988 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1989 .halt_bit = 27,
1990 },
1991 .c = {
1992 .dbg_name = "gsbi4_p_clk",
1993 .ops = &clk_ops_branch,
1994 CLK_INIT(gsbi4_p_clk.c),
1995 },
1996};
1997
1998static struct branch_clk gsbi5_p_clk = {
1999 .b = {
2000 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
2001 .en_mask = BIT(4),
2002 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2003 .halt_bit = 23,
2004 },
2005 .c = {
2006 .dbg_name = "gsbi5_p_clk",
2007 .ops = &clk_ops_branch,
2008 CLK_INIT(gsbi5_p_clk.c),
2009 },
2010};
2011
2012static struct branch_clk gsbi6_p_clk = {
2013 .b = {
2014 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
2015 .en_mask = BIT(4),
2016 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2017 .halt_bit = 19,
2018 },
2019 .c = {
2020 .dbg_name = "gsbi6_p_clk",
2021 .ops = &clk_ops_branch,
2022 CLK_INIT(gsbi6_p_clk.c),
2023 },
2024};
2025
2026static struct branch_clk gsbi7_p_clk = {
2027 .b = {
2028 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
2029 .en_mask = BIT(4),
2030 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2031 .halt_bit = 15,
2032 },
2033 .c = {
2034 .dbg_name = "gsbi7_p_clk",
2035 .ops = &clk_ops_branch,
2036 CLK_INIT(gsbi7_p_clk.c),
2037 },
2038};
2039
2040static struct branch_clk gsbi8_p_clk = {
2041 .b = {
2042 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
2043 .en_mask = BIT(4),
2044 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2045 .halt_bit = 11,
2046 },
2047 .c = {
2048 .dbg_name = "gsbi8_p_clk",
2049 .ops = &clk_ops_branch,
2050 CLK_INIT(gsbi8_p_clk.c),
2051 },
2052};
2053
2054static struct branch_clk gsbi9_p_clk = {
2055 .b = {
2056 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
2057 .en_mask = BIT(4),
2058 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2059 .halt_bit = 7,
2060 },
2061 .c = {
2062 .dbg_name = "gsbi9_p_clk",
2063 .ops = &clk_ops_branch,
2064 CLK_INIT(gsbi9_p_clk.c),
2065 },
2066};
2067
2068static struct branch_clk gsbi10_p_clk = {
2069 .b = {
2070 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
2071 .en_mask = BIT(4),
2072 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2073 .halt_bit = 3,
2074 },
2075 .c = {
2076 .dbg_name = "gsbi10_p_clk",
2077 .ops = &clk_ops_branch,
2078 CLK_INIT(gsbi10_p_clk.c),
2079 },
2080};
2081
2082static struct branch_clk gsbi11_p_clk = {
2083 .b = {
2084 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
2085 .en_mask = BIT(4),
2086 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2087 .halt_bit = 18,
2088 },
2089 .c = {
2090 .dbg_name = "gsbi11_p_clk",
2091 .ops = &clk_ops_branch,
2092 CLK_INIT(gsbi11_p_clk.c),
2093 },
2094};
2095
2096static struct branch_clk gsbi12_p_clk = {
2097 .b = {
2098 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
2099 .en_mask = BIT(4),
2100 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2101 .halt_bit = 14,
2102 },
2103 .c = {
2104 .dbg_name = "gsbi12_p_clk",
2105 .ops = &clk_ops_branch,
2106 CLK_INIT(gsbi12_p_clk.c),
2107 },
2108};
2109
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002110static struct branch_clk qdss_p_clk = {
2111 .b = {
2112 .ctl_reg = QDSS_HCLK_CTL_REG,
2113 .en_mask = BIT(4),
2114 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2115 .halt_bit = 11,
2116 .halt_check = HALT_VOTED,
2117 .reset_reg = QDSS_RESETS_REG,
2118 .reset_mask = BIT(2),
2119 },
2120 .c = {
2121 .dbg_name = "qdss_p_clk",
2122 .ops = &clk_ops_branch,
2123 CLK_INIT(qdss_p_clk.c),
2124 },
2125};
2126
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002127static struct branch_clk tsif_p_clk = {
2128 .b = {
2129 .ctl_reg = TSIF_HCLK_CTL_REG,
2130 .en_mask = BIT(4),
2131 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2132 .halt_bit = 7,
2133 },
2134 .c = {
2135 .dbg_name = "tsif_p_clk",
2136 .ops = &clk_ops_branch,
2137 CLK_INIT(tsif_p_clk.c),
2138 },
2139};
2140
2141static struct branch_clk usb_fs1_p_clk = {
2142 .b = {
2143 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
2144 .en_mask = BIT(4),
2145 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2146 .halt_bit = 17,
2147 },
2148 .c = {
2149 .dbg_name = "usb_fs1_p_clk",
2150 .ops = &clk_ops_branch,
2151 CLK_INIT(usb_fs1_p_clk.c),
2152 },
2153};
2154
2155static struct branch_clk usb_fs2_p_clk = {
2156 .b = {
2157 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
2158 .en_mask = BIT(4),
2159 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2160 .halt_bit = 14,
2161 },
2162 .c = {
2163 .dbg_name = "usb_fs2_p_clk",
2164 .ops = &clk_ops_branch,
2165 CLK_INIT(usb_fs2_p_clk.c),
2166 },
2167};
2168
2169static struct branch_clk usb_hs1_p_clk = {
2170 .b = {
2171 .ctl_reg = USB_HS1_HCLK_CTL_REG,
2172 .en_mask = BIT(4),
2173 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2174 .halt_bit = 1,
2175 },
2176 .c = {
2177 .dbg_name = "usb_hs1_p_clk",
2178 .ops = &clk_ops_branch,
2179 CLK_INIT(usb_hs1_p_clk.c),
2180 },
2181};
2182
Stephen Boyd94625ef2011-07-12 17:06:01 -07002183static struct branch_clk usb_hsic_p_clk = {
2184 .b = {
2185 .ctl_reg = USB_HSIC_HCLK_CTL_REG,
2186 .en_mask = BIT(4),
2187 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2188 .halt_bit = 28,
2189 },
2190 .c = {
2191 .dbg_name = "usb_hsic_p_clk",
2192 .ops = &clk_ops_branch,
2193 CLK_INIT(usb_hsic_p_clk.c),
2194 },
2195};
2196
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002197static struct branch_clk sdc1_p_clk = {
2198 .b = {
2199 .ctl_reg = SDCn_HCLK_CTL_REG(1),
2200 .en_mask = BIT(4),
2201 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2202 .halt_bit = 11,
2203 },
2204 .c = {
2205 .dbg_name = "sdc1_p_clk",
2206 .ops = &clk_ops_branch,
2207 CLK_INIT(sdc1_p_clk.c),
2208 },
2209};
2210
2211static struct branch_clk sdc2_p_clk = {
2212 .b = {
2213 .ctl_reg = SDCn_HCLK_CTL_REG(2),
2214 .en_mask = BIT(4),
2215 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2216 .halt_bit = 10,
2217 },
2218 .c = {
2219 .dbg_name = "sdc2_p_clk",
2220 .ops = &clk_ops_branch,
2221 CLK_INIT(sdc2_p_clk.c),
2222 },
2223};
2224
2225static struct branch_clk sdc3_p_clk = {
2226 .b = {
2227 .ctl_reg = SDCn_HCLK_CTL_REG(3),
2228 .en_mask = BIT(4),
2229 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2230 .halt_bit = 9,
2231 },
2232 .c = {
2233 .dbg_name = "sdc3_p_clk",
2234 .ops = &clk_ops_branch,
2235 CLK_INIT(sdc3_p_clk.c),
2236 },
2237};
2238
2239static struct branch_clk sdc4_p_clk = {
2240 .b = {
2241 .ctl_reg = SDCn_HCLK_CTL_REG(4),
2242 .en_mask = BIT(4),
2243 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2244 .halt_bit = 8,
2245 },
2246 .c = {
2247 .dbg_name = "sdc4_p_clk",
2248 .ops = &clk_ops_branch,
2249 CLK_INIT(sdc4_p_clk.c),
2250 },
2251};
2252
2253static struct branch_clk sdc5_p_clk = {
2254 .b = {
2255 .ctl_reg = SDCn_HCLK_CTL_REG(5),
2256 .en_mask = BIT(4),
2257 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2258 .halt_bit = 7,
2259 },
2260 .c = {
2261 .dbg_name = "sdc5_p_clk",
2262 .ops = &clk_ops_branch,
2263 CLK_INIT(sdc5_p_clk.c),
2264 },
2265};
2266
2267/* HW-Voteable Clocks */
2268static struct branch_clk adm0_clk = {
2269 .b = {
2270 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2271 .en_mask = BIT(2),
2272 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2273 .halt_check = HALT_VOTED,
2274 .halt_bit = 14,
2275 },
2276 .c = {
2277 .dbg_name = "adm0_clk",
2278 .ops = &clk_ops_branch,
2279 CLK_INIT(adm0_clk.c),
2280 },
2281};
2282
2283static struct branch_clk adm0_p_clk = {
2284 .b = {
2285 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2286 .en_mask = BIT(3),
2287 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2288 .halt_check = HALT_VOTED,
2289 .halt_bit = 13,
2290 },
2291 .c = {
2292 .dbg_name = "adm0_p_clk",
2293 .ops = &clk_ops_branch,
2294 CLK_INIT(adm0_p_clk.c),
2295 },
2296};
2297
2298static struct branch_clk pmic_arb0_p_clk = {
2299 .b = {
2300 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2301 .en_mask = BIT(8),
2302 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2303 .halt_check = HALT_VOTED,
2304 .halt_bit = 22,
2305 },
2306 .c = {
2307 .dbg_name = "pmic_arb0_p_clk",
2308 .ops = &clk_ops_branch,
2309 CLK_INIT(pmic_arb0_p_clk.c),
2310 },
2311};
2312
2313static struct branch_clk pmic_arb1_p_clk = {
2314 .b = {
2315 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2316 .en_mask = BIT(9),
2317 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2318 .halt_check = HALT_VOTED,
2319 .halt_bit = 21,
2320 },
2321 .c = {
2322 .dbg_name = "pmic_arb1_p_clk",
2323 .ops = &clk_ops_branch,
2324 CLK_INIT(pmic_arb1_p_clk.c),
2325 },
2326};
2327
2328static struct branch_clk pmic_ssbi2_clk = {
2329 .b = {
2330 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2331 .en_mask = BIT(7),
2332 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2333 .halt_check = HALT_VOTED,
2334 .halt_bit = 23,
2335 },
2336 .c = {
2337 .dbg_name = "pmic_ssbi2_clk",
2338 .ops = &clk_ops_branch,
2339 CLK_INIT(pmic_ssbi2_clk.c),
2340 },
2341};
2342
2343static struct branch_clk rpm_msg_ram_p_clk = {
2344 .b = {
2345 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2346 .en_mask = BIT(6),
2347 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2348 .halt_check = HALT_VOTED,
2349 .halt_bit = 12,
2350 },
2351 .c = {
2352 .dbg_name = "rpm_msg_ram_p_clk",
2353 .ops = &clk_ops_branch,
2354 CLK_INIT(rpm_msg_ram_p_clk.c),
2355 },
2356};
2357
2358/*
2359 * Multimedia Clocks
2360 */
2361
2362static struct branch_clk amp_clk = {
2363 .b = {
2364 .reset_reg = SW_RESET_CORE_REG,
2365 .reset_mask = BIT(20),
2366 },
2367 .c = {
2368 .dbg_name = "amp_clk",
2369 .ops = &clk_ops_reset,
2370 CLK_INIT(amp_clk.c),
2371 },
2372};
2373
Stephen Boyd94625ef2011-07-12 17:06:01 -07002374#define CLK_CAM(name, n, hb) \
2375 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002376 .b = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002377 .ctl_reg = CAMCLK##n##_CC_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002378 .en_mask = BIT(0), \
2379 .halt_reg = DBG_BUS_VEC_I_REG, \
2380 .halt_bit = hb, \
2381 }, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002382 .ns_reg = CAMCLK##n##_NS_REG, \
2383 .md_reg = CAMCLK##n##_MD_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002384 .root_en_mask = BIT(2), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002385 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002386 .ctl_mask = BM(7, 6), \
2387 .set_rate = set_rate_mnd_8, \
2388 .freq_tbl = clk_tbl_cam, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002389 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002390 .c = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002391 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002392 .ops = &clk_ops_rcg_8960, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002393 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002394 }, \
2395 }
2396#define F_CAM(f, s, d, m, n, v) \
2397 { \
2398 .freq_hz = f, \
2399 .src_clk = &s##_clk.c, \
2400 .md_val = MD8(8, m, 0, n), \
2401 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2402 .ctl_val = CC(6, n), \
2403 .mnd_en_mask = BIT(5) * !!(n), \
2404 .sys_vdd = v, \
2405 }
2406static struct clk_freq_tbl clk_tbl_cam[] = {
2407 F_CAM( 0, gnd, 1, 0, 0, NONE),
2408 F_CAM( 6000000, pll8, 4, 1, 16, LOW),
2409 F_CAM( 8000000, pll8, 4, 1, 12, LOW),
2410 F_CAM( 12000000, pll8, 4, 1, 8, LOW),
2411 F_CAM( 16000000, pll8, 4, 1, 6, LOW),
2412 F_CAM( 19200000, pll8, 4, 1, 5, LOW),
2413 F_CAM( 24000000, pll8, 4, 1, 4, LOW),
2414 F_CAM( 32000000, pll8, 4, 1, 3, LOW),
2415 F_CAM( 48000000, pll8, 4, 1, 2, LOW),
2416 F_CAM( 64000000, pll8, 3, 1, 2, LOW),
2417 F_CAM( 96000000, pll8, 4, 0, 0, NOMINAL),
2418 F_CAM(128000000, pll8, 3, 0, 0, NOMINAL),
2419 F_END
2420};
2421
Stephen Boyd94625ef2011-07-12 17:06:01 -07002422static CLK_CAM(cam0_clk, 0, 15);
2423static CLK_CAM(cam1_clk, 1, 16);
2424static CLK_CAM(cam2_clk, 2, 31);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002425
2426#define F_CSI(f, s, d, m, n, v) \
2427 { \
2428 .freq_hz = f, \
2429 .src_clk = &s##_clk.c, \
2430 .md_val = MD8(8, m, 0, n), \
2431 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2432 .ctl_val = CC(6, n), \
2433 .mnd_en_mask = BIT(5) * !!(n), \
2434 .sys_vdd = v, \
2435 }
2436static struct clk_freq_tbl clk_tbl_csi[] = {
2437 F_CSI( 0, gnd, 1, 0, 0, NONE),
2438 F_CSI( 85330000, pll8, 1, 2, 9, LOW),
2439 F_CSI(177780000, pll2, 1, 2, 9, NOMINAL),
2440 F_END
2441};
2442
2443static struct rcg_clk csi0_src_clk = {
2444 .ns_reg = CSI0_NS_REG,
2445 .b = {
2446 .ctl_reg = CSI0_CC_REG,
2447 .halt_check = NOCHECK,
2448 },
2449 .md_reg = CSI0_MD_REG,
2450 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002451 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002452 .ctl_mask = BM(7, 6),
2453 .set_rate = set_rate_mnd,
2454 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002455 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002456 .c = {
2457 .dbg_name = "csi0_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002458 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002459 CLK_INIT(csi0_src_clk.c),
2460 },
2461};
2462
2463static struct branch_clk csi0_clk = {
2464 .b = {
2465 .ctl_reg = CSI0_CC_REG,
2466 .en_mask = BIT(0),
2467 .reset_reg = SW_RESET_CORE_REG,
2468 .reset_mask = BIT(8),
2469 .halt_reg = DBG_BUS_VEC_B_REG,
2470 .halt_bit = 13,
2471 },
2472 .parent = &csi0_src_clk.c,
2473 .c = {
2474 .dbg_name = "csi0_clk",
2475 .ops = &clk_ops_branch,
2476 CLK_INIT(csi0_clk.c),
2477 },
2478};
2479
2480static struct branch_clk csi0_phy_clk = {
2481 .b = {
2482 .ctl_reg = CSI0_CC_REG,
2483 .en_mask = BIT(8),
2484 .reset_reg = SW_RESET_CORE_REG,
2485 .reset_mask = BIT(29),
2486 .halt_reg = DBG_BUS_VEC_I_REG,
2487 .halt_bit = 9,
2488 },
2489 .parent = &csi0_src_clk.c,
2490 .c = {
2491 .dbg_name = "csi0_phy_clk",
2492 .ops = &clk_ops_branch,
2493 CLK_INIT(csi0_phy_clk.c),
2494 },
2495};
2496
2497static struct rcg_clk csi1_src_clk = {
2498 .ns_reg = CSI1_NS_REG,
2499 .b = {
2500 .ctl_reg = CSI1_CC_REG,
2501 .halt_check = NOCHECK,
2502 },
2503 .md_reg = CSI1_MD_REG,
2504 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002505 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002506 .ctl_mask = BM(7, 6),
2507 .set_rate = set_rate_mnd,
2508 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002509 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002510 .c = {
2511 .dbg_name = "csi1_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002512 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002513 CLK_INIT(csi1_src_clk.c),
2514 },
2515};
2516
2517static struct branch_clk csi1_clk = {
2518 .b = {
2519 .ctl_reg = CSI1_CC_REG,
2520 .en_mask = BIT(0),
2521 .reset_reg = SW_RESET_CORE_REG,
2522 .reset_mask = BIT(18),
2523 .halt_reg = DBG_BUS_VEC_B_REG,
2524 .halt_bit = 14,
2525 },
2526 .parent = &csi1_src_clk.c,
2527 .c = {
2528 .dbg_name = "csi1_clk",
2529 .ops = &clk_ops_branch,
2530 CLK_INIT(csi1_clk.c),
2531 },
2532};
2533
2534static struct branch_clk csi1_phy_clk = {
2535 .b = {
2536 .ctl_reg = CSI1_CC_REG,
2537 .en_mask = BIT(8),
2538 .reset_reg = SW_RESET_CORE_REG,
2539 .reset_mask = BIT(28),
2540 .halt_reg = DBG_BUS_VEC_I_REG,
2541 .halt_bit = 10,
2542 },
2543 .parent = &csi1_src_clk.c,
2544 .c = {
2545 .dbg_name = "csi1_phy_clk",
2546 .ops = &clk_ops_branch,
2547 CLK_INIT(csi1_phy_clk.c),
2548 },
2549};
2550
Stephen Boyd94625ef2011-07-12 17:06:01 -07002551static struct rcg_clk csi2_src_clk = {
2552 .ns_reg = CSI2_NS_REG,
2553 .b = {
2554 .ctl_reg = CSI2_CC_REG,
2555 .halt_check = NOCHECK,
2556 },
2557 .md_reg = CSI2_MD_REG,
2558 .root_en_mask = BIT(2),
2559 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
2560 .ctl_mask = BM(7, 6),
2561 .set_rate = set_rate_mnd,
2562 .freq_tbl = clk_tbl_csi,
2563 .current_freq = &rcg_dummy_freq,
2564 .c = {
2565 .dbg_name = "csi2_src_clk",
2566 .ops = &clk_ops_rcg_8960,
2567 CLK_INIT(csi2_src_clk.c),
2568 },
2569};
2570
2571static struct branch_clk csi2_clk = {
2572 .b = {
2573 .ctl_reg = CSI2_CC_REG,
2574 .en_mask = BIT(0),
2575 .reset_reg = SW_RESET_CORE2_REG,
2576 .reset_mask = BIT(2),
2577 .halt_reg = DBG_BUS_VEC_B_REG,
2578 .halt_bit = 29,
2579 },
2580 .parent = &csi2_src_clk.c,
2581 .c = {
2582 .dbg_name = "csi2_clk",
2583 .ops = &clk_ops_branch,
2584 CLK_INIT(csi2_clk.c),
2585 },
2586};
2587
2588static struct branch_clk csi2_phy_clk = {
2589 .b = {
2590 .ctl_reg = CSI2_CC_REG,
2591 .en_mask = BIT(8),
2592 .reset_reg = SW_RESET_CORE_REG,
2593 .reset_mask = BIT(31),
2594 .halt_reg = DBG_BUS_VEC_I_REG,
2595 .halt_bit = 29,
2596 },
2597 .parent = &csi2_src_clk.c,
2598 .c = {
2599 .dbg_name = "csi2_phy_clk",
2600 .ops = &clk_ops_branch,
2601 CLK_INIT(csi2_phy_clk.c),
2602 },
2603};
2604
2605/*
2606 * The csi pix and csi rdi clocks have two bits in two registers to control a
2607 * three input mux. So we have the generic rcg_clk_enable() path handle the
2608 * first bit, and this function handle the second bit.
2609 */
2610static void set_rate_pix_rdi(struct rcg_clk *clk, struct clk_freq_tbl *nf)
2611{
2612 u32 reg = readl_relaxed(MISC_CC3_REG);
2613 u32 bit = (u32)nf->extra_freq_data;
2614 if (nf->freq_hz == 2)
2615 reg |= bit;
2616 else
2617 reg &= ~bit;
2618 writel_relaxed(reg, MISC_CC3_REG);
2619}
2620
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002621#define F_CSI_PIX(s) \
2622 { \
2623 .src_clk = &csi##s##_clk.c, \
2624 .freq_hz = s, \
2625 .ns_val = BVAL(25, 25, s), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002626 .extra_freq_data = (void *)BIT(13), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002627 }
2628static struct clk_freq_tbl clk_tbl_csi_pix[] = {
2629 F_CSI_PIX(0), /* CSI0 source */
2630 F_CSI_PIX(1), /* CSI1 source */
Stephen Boyd94625ef2011-07-12 17:06:01 -07002631 F_CSI_PIX(2), /* CSI2 source */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002632 F_END
2633};
2634
2635static struct rcg_clk csi_pix_clk = {
2636 .b = {
2637 .ctl_reg = MISC_CC_REG,
2638 .en_mask = BIT(26),
2639 .halt_check = DELAY,
2640 .reset_reg = SW_RESET_CORE_REG,
2641 .reset_mask = BIT(26),
2642 },
2643 .ns_reg = MISC_CC_REG,
2644 .ns_mask = BIT(25),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002645 .set_rate = set_rate_pix_rdi,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002646 .freq_tbl = clk_tbl_csi_pix,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002647 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002648 .c = {
2649 .dbg_name = "csi_pix_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002650 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002651 CLK_INIT(csi_pix_clk.c),
2652 },
2653};
2654
Stephen Boyd94625ef2011-07-12 17:06:01 -07002655#define F_CSI_PIX1(s) \
2656 { \
2657 .src_clk = &csi##s##_clk.c, \
2658 .freq_hz = s, \
2659 .ns_val = BVAL(9, 8, s), \
2660 }
2661static struct clk_freq_tbl clk_tbl_csi_pix1[] = {
2662 F_CSI_PIX1(0), /* CSI0 source */
2663 F_CSI_PIX1(1), /* CSI1 source */
2664 F_CSI_PIX1(2), /* CSI2 source */
2665 F_END
2666};
2667
2668static struct rcg_clk csi_pix1_clk = {
2669 .b = {
2670 .ctl_reg = MISC_CC3_REG,
2671 .en_mask = BIT(10),
2672 .halt_check = DELAY,
2673 .reset_reg = SW_RESET_CORE_REG,
2674 .reset_mask = BIT(30),
2675 },
2676 .ns_reg = MISC_CC3_REG,
2677 .ns_mask = BM(9, 8),
2678 .set_rate = set_rate_nop,
2679 .freq_tbl = clk_tbl_csi_pix1,
2680 .current_freq = &rcg_dummy_freq,
2681 .c = {
2682 .dbg_name = "csi_pix1_clk",
2683 .ops = &clk_ops_rcg_8960,
2684 CLK_INIT(csi_pix1_clk.c),
2685 },
2686};
2687
2688#define F_CSI_RDI(s) \
2689 { \
2690 .src_clk = &csi##s##_clk.c, \
2691 .freq_hz = s, \
2692 .ns_val = BVAL(12, 12, s), \
2693 .extra_freq_data = (void *)BIT(12), \
2694 }
2695static struct clk_freq_tbl clk_tbl_csi_rdi[] = {
2696 F_CSI_RDI(0), /* CSI0 source */
2697 F_CSI_RDI(1), /* CSI1 source */
2698 F_CSI_RDI(2), /* CSI2 source */
2699 F_END
2700};
2701
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002702static struct rcg_clk csi_rdi_clk = {
2703 .b = {
2704 .ctl_reg = MISC_CC_REG,
2705 .en_mask = BIT(13),
2706 .halt_check = DELAY,
2707 .reset_reg = SW_RESET_CORE_REG,
2708 .reset_mask = BIT(27),
2709 },
2710 .ns_reg = MISC_CC_REG,
2711 .ns_mask = BIT(12),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002712 .set_rate = set_rate_pix_rdi,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002713 .freq_tbl = clk_tbl_csi_rdi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002714 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002715 .c = {
2716 .dbg_name = "csi_rdi_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002717 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002718 CLK_INIT(csi_rdi_clk.c),
2719 },
2720};
2721
Stephen Boyd94625ef2011-07-12 17:06:01 -07002722#define F_CSI_RDI1(s) \
2723 { \
2724 .src_clk = &csi##s##_clk.c, \
2725 .freq_hz = s, \
2726 .ns_val = BVAL(1, 0, s), \
2727 }
2728static struct clk_freq_tbl clk_tbl_csi_rdi1[] = {
2729 F_CSI_RDI1(0), /* CSI0 source */
2730 F_CSI_RDI1(1), /* CSI1 source */
2731 F_CSI_RDI1(2), /* CSI2 source */
2732 F_END
2733};
2734
2735static struct rcg_clk csi_rdi1_clk = {
2736 .b = {
2737 .ctl_reg = MISC_CC3_REG,
2738 .en_mask = BIT(2),
2739 .halt_check = DELAY,
2740 .reset_reg = SW_RESET_CORE2_REG,
2741 .reset_mask = BIT(1),
2742 },
2743 .ns_reg = MISC_CC3_REG,
2744 .ns_mask = BM(1, 0),
2745 .set_rate = set_rate_nop,
2746 .freq_tbl = clk_tbl_csi_rdi1,
2747 .current_freq = &rcg_dummy_freq,
2748 .c = {
2749 .dbg_name = "csi_rdi1_clk",
2750 .ops = &clk_ops_rcg_8960,
2751 CLK_INIT(csi_rdi1_clk.c),
2752 },
2753};
2754
2755#define F_CSI_RDI2(s) \
2756 { \
2757 .src_clk = &csi##s##_clk.c, \
2758 .freq_hz = s, \
2759 .ns_val = BVAL(5, 4, s), \
2760 }
2761static struct clk_freq_tbl clk_tbl_csi_rdi2[] = {
2762 F_CSI_RDI2(0), /* CSI0 source */
2763 F_CSI_RDI2(1), /* CSI1 source */
2764 F_CSI_RDI2(2), /* CSI2 source */
2765 F_END
2766};
2767
2768static struct rcg_clk csi_rdi2_clk = {
2769 .b = {
2770 .ctl_reg = MISC_CC3_REG,
2771 .en_mask = BIT(6),
2772 .halt_check = DELAY,
2773 .reset_reg = SW_RESET_CORE2_REG,
2774 .reset_mask = BIT(0),
2775 },
2776 .ns_reg = MISC_CC3_REG,
2777 .ns_mask = BM(5, 4),
2778 .set_rate = set_rate_nop,
2779 .freq_tbl = clk_tbl_csi_rdi2,
2780 .current_freq = &rcg_dummy_freq,
2781 .c = {
2782 .dbg_name = "csi_rdi2_clk",
2783 .ops = &clk_ops_rcg_8960,
2784 CLK_INIT(csi_rdi2_clk.c),
2785 },
2786};
2787
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002788#define F_CSI_PHYTIMER(f, s, d, m, n, v) \
2789 { \
2790 .freq_hz = f, \
2791 .src_clk = &s##_clk.c, \
2792 .md_val = MD8(8, m, 0, n), \
2793 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2794 .ctl_val = CC(6, n), \
2795 .mnd_en_mask = BIT(5) * !!(n), \
2796 .sys_vdd = v, \
2797 }
2798static struct clk_freq_tbl clk_tbl_csi_phytimer[] = {
2799 F_CSI_PHYTIMER( 0, gnd, 1, 0, 0, NONE),
2800 F_CSI_PHYTIMER( 85330000, pll8, 1, 2, 9, LOW),
2801 F_CSI_PHYTIMER(177780000, pll2, 1, 2, 9, NOMINAL),
2802 F_END
2803};
2804
2805static struct rcg_clk csiphy_timer_src_clk = {
2806 .ns_reg = CSIPHYTIMER_NS_REG,
2807 .b = {
2808 .ctl_reg = CSIPHYTIMER_CC_REG,
2809 .halt_check = NOCHECK,
2810 },
2811 .md_reg = CSIPHYTIMER_MD_REG,
2812 .root_en_mask = BIT(2),
2813 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
2814 .ctl_mask = BM(7, 6),
2815 .set_rate = set_rate_mnd_8,
2816 .freq_tbl = clk_tbl_csi_phytimer,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002817 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002818 .c = {
2819 .dbg_name = "csiphy_timer_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002820 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002821 CLK_INIT(csiphy_timer_src_clk.c),
2822 },
2823};
2824
2825static struct branch_clk csi0phy_timer_clk = {
2826 .b = {
2827 .ctl_reg = CSIPHYTIMER_CC_REG,
2828 .en_mask = BIT(0),
2829 .halt_reg = DBG_BUS_VEC_I_REG,
2830 .halt_bit = 17,
2831 },
2832 .parent = &csiphy_timer_src_clk.c,
2833 .c = {
2834 .dbg_name = "csi0phy_timer_clk",
2835 .ops = &clk_ops_branch,
2836 CLK_INIT(csi0phy_timer_clk.c),
2837 },
2838};
2839
2840static struct branch_clk csi1phy_timer_clk = {
2841 .b = {
2842 .ctl_reg = CSIPHYTIMER_CC_REG,
2843 .en_mask = BIT(9),
2844 .halt_reg = DBG_BUS_VEC_I_REG,
2845 .halt_bit = 18,
2846 },
2847 .parent = &csiphy_timer_src_clk.c,
2848 .c = {
2849 .dbg_name = "csi1phy_timer_clk",
2850 .ops = &clk_ops_branch,
2851 CLK_INIT(csi1phy_timer_clk.c),
2852 },
2853};
2854
Stephen Boyd94625ef2011-07-12 17:06:01 -07002855static struct branch_clk csi2phy_timer_clk = {
2856 .b = {
2857 .ctl_reg = CSIPHYTIMER_CC_REG,
2858 .en_mask = BIT(11),
2859 .halt_reg = DBG_BUS_VEC_I_REG,
2860 .halt_bit = 30,
2861 },
2862 .parent = &csiphy_timer_src_clk.c,
2863 .c = {
2864 .dbg_name = "csi2phy_timer_clk",
2865 .ops = &clk_ops_branch,
2866 CLK_INIT(csi2phy_timer_clk.c),
2867 },
2868};
2869
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002870#define F_DSI(d) \
2871 { \
2872 .freq_hz = d, \
2873 .ns_val = BVAL(15, 12, (d-1)), \
2874 }
2875/*
2876 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
2877 * without this clock driver knowing. So, overload the clk_set_rate() to set
2878 * the divider (1 to 16) of the clock with respect to the PLL rate.
2879 */
2880static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
2881 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
2882 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
2883 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
2884 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
2885 F_END
2886};
2887
2888static struct rcg_clk dsi1_byte_clk = {
2889 .b = {
2890 .ctl_reg = DSI1_BYTE_CC_REG,
2891 .en_mask = BIT(0),
2892 .reset_reg = SW_RESET_CORE_REG,
2893 .reset_mask = BIT(7),
2894 .halt_reg = DBG_BUS_VEC_B_REG,
2895 .halt_bit = 21,
2896 },
2897 .ns_reg = DSI1_BYTE_NS_REG,
2898 .root_en_mask = BIT(2),
2899 .ns_mask = BM(15, 12),
2900 .set_rate = set_rate_nop,
2901 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002902 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002903 .c = {
2904 .dbg_name = "dsi1_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002905 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002906 CLK_INIT(dsi1_byte_clk.c),
2907 },
2908};
2909
2910static struct rcg_clk dsi2_byte_clk = {
2911 .b = {
2912 .ctl_reg = DSI2_BYTE_CC_REG,
2913 .en_mask = BIT(0),
2914 .reset_reg = SW_RESET_CORE_REG,
2915 .reset_mask = BIT(25),
2916 .halt_reg = DBG_BUS_VEC_B_REG,
2917 .halt_bit = 20,
2918 },
2919 .ns_reg = DSI2_BYTE_NS_REG,
2920 .root_en_mask = BIT(2),
2921 .ns_mask = BM(15, 12),
2922 .set_rate = set_rate_nop,
2923 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002924 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002925 .c = {
2926 .dbg_name = "dsi2_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002927 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002928 CLK_INIT(dsi2_byte_clk.c),
2929 },
2930};
2931
2932static struct rcg_clk dsi1_esc_clk = {
2933 .b = {
2934 .ctl_reg = DSI1_ESC_CC_REG,
2935 .en_mask = BIT(0),
2936 .reset_reg = SW_RESET_CORE_REG,
2937 .halt_reg = DBG_BUS_VEC_I_REG,
2938 .halt_bit = 1,
2939 },
2940 .ns_reg = DSI1_ESC_NS_REG,
2941 .root_en_mask = BIT(2),
2942 .ns_mask = BM(15, 12),
2943 .set_rate = set_rate_nop,
2944 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002945 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002946 .c = {
2947 .dbg_name = "dsi1_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002948 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002949 CLK_INIT(dsi1_esc_clk.c),
2950 },
2951};
2952
2953static struct rcg_clk dsi2_esc_clk = {
2954 .b = {
2955 .ctl_reg = DSI2_ESC_CC_REG,
2956 .en_mask = BIT(0),
2957 .halt_reg = DBG_BUS_VEC_I_REG,
2958 .halt_bit = 3,
2959 },
2960 .ns_reg = DSI2_ESC_NS_REG,
2961 .root_en_mask = BIT(2),
2962 .ns_mask = BM(15, 12),
2963 .set_rate = set_rate_nop,
2964 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002965 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002966 .c = {
2967 .dbg_name = "dsi2_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002968 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002969 CLK_INIT(dsi2_esc_clk.c),
2970 },
2971};
2972
2973#define F_GFX2D(f, s, m, n, v) \
2974 { \
2975 .freq_hz = f, \
2976 .src_clk = &s##_clk.c, \
2977 .md_val = MD4(4, m, 0, n), \
2978 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
2979 .ctl_val = CC_BANKED(9, 6, n), \
2980 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
2981 .sys_vdd = v, \
2982 }
2983static struct clk_freq_tbl clk_tbl_gfx2d[] = {
2984 F_GFX2D( 0, gnd, 0, 0, NONE),
2985 F_GFX2D( 27000000, pxo, 0, 0, LOW),
2986 F_GFX2D( 48000000, pll8, 1, 8, LOW),
2987 F_GFX2D( 54857000, pll8, 1, 7, LOW),
2988 F_GFX2D( 64000000, pll8, 1, 6, LOW),
2989 F_GFX2D( 76800000, pll8, 1, 5, LOW),
2990 F_GFX2D( 96000000, pll8, 1, 4, LOW),
2991 F_GFX2D(128000000, pll8, 1, 3, NOMINAL),
2992 F_GFX2D(145455000, pll2, 2, 11, NOMINAL),
2993 F_GFX2D(160000000, pll2, 1, 5, NOMINAL),
2994 F_GFX2D(177778000, pll2, 2, 9, NOMINAL),
2995 F_GFX2D(200000000, pll2, 1, 4, NOMINAL),
2996 F_GFX2D(228571000, pll2, 2, 7, HIGH),
2997 F_END
2998};
2999
3000static struct bank_masks bmnd_info_gfx2d0 = {
3001 .bank_sel_mask = BIT(11),
3002 .bank0_mask = {
3003 .md_reg = GFX2D0_MD0_REG,
3004 .ns_mask = BM(23, 20) | BM(5, 3),
3005 .rst_mask = BIT(25),
3006 .mnd_en_mask = BIT(8),
3007 .mode_mask = BM(10, 9),
3008 },
3009 .bank1_mask = {
3010 .md_reg = GFX2D0_MD1_REG,
3011 .ns_mask = BM(19, 16) | BM(2, 0),
3012 .rst_mask = BIT(24),
3013 .mnd_en_mask = BIT(5),
3014 .mode_mask = BM(7, 6),
3015 },
3016};
3017
3018static struct rcg_clk gfx2d0_clk = {
3019 .b = {
3020 .ctl_reg = GFX2D0_CC_REG,
3021 .en_mask = BIT(0),
3022 .reset_reg = SW_RESET_CORE_REG,
3023 .reset_mask = BIT(14),
3024 .halt_reg = DBG_BUS_VEC_A_REG,
3025 .halt_bit = 9,
3026 },
3027 .ns_reg = GFX2D0_NS_REG,
3028 .root_en_mask = BIT(2),
3029 .set_rate = set_rate_mnd_banked,
3030 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003031 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003032 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003033 .c = {
3034 .dbg_name = "gfx2d0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003035 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003036 CLK_INIT(gfx2d0_clk.c),
3037 },
3038};
3039
3040static struct bank_masks bmnd_info_gfx2d1 = {
3041 .bank_sel_mask = BIT(11),
3042 .bank0_mask = {
3043 .md_reg = GFX2D1_MD0_REG,
3044 .ns_mask = BM(23, 20) | BM(5, 3),
3045 .rst_mask = BIT(25),
3046 .mnd_en_mask = BIT(8),
3047 .mode_mask = BM(10, 9),
3048 },
3049 .bank1_mask = {
3050 .md_reg = GFX2D1_MD1_REG,
3051 .ns_mask = BM(19, 16) | BM(2, 0),
3052 .rst_mask = BIT(24),
3053 .mnd_en_mask = BIT(5),
3054 .mode_mask = BM(7, 6),
3055 },
3056};
3057
3058static struct rcg_clk gfx2d1_clk = {
3059 .b = {
3060 .ctl_reg = GFX2D1_CC_REG,
3061 .en_mask = BIT(0),
3062 .reset_reg = SW_RESET_CORE_REG,
3063 .reset_mask = BIT(13),
3064 .halt_reg = DBG_BUS_VEC_A_REG,
3065 .halt_bit = 14,
3066 },
3067 .ns_reg = GFX2D1_NS_REG,
3068 .root_en_mask = BIT(2),
3069 .set_rate = set_rate_mnd_banked,
3070 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003071 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003072 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003073 .c = {
3074 .dbg_name = "gfx2d1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003075 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003076 CLK_INIT(gfx2d1_clk.c),
3077 },
3078};
3079
3080#define F_GFX3D(f, s, m, n, v) \
3081 { \
3082 .freq_hz = f, \
3083 .src_clk = &s##_clk.c, \
3084 .md_val = MD4(4, m, 0, n), \
3085 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3086 .ctl_val = CC_BANKED(9, 6, n), \
3087 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
3088 .sys_vdd = v, \
3089 }
3090static struct clk_freq_tbl clk_tbl_gfx3d[] = {
3091 F_GFX3D( 0, gnd, 0, 0, NONE),
3092 F_GFX3D( 27000000, pxo, 0, 0, LOW),
3093 F_GFX3D( 48000000, pll8, 1, 8, LOW),
3094 F_GFX3D( 54857000, pll8, 1, 7, LOW),
3095 F_GFX3D( 64000000, pll8, 1, 6, LOW),
3096 F_GFX3D( 76800000, pll8, 1, 5, LOW),
3097 F_GFX3D( 96000000, pll8, 1, 4, LOW),
Stephen Boydd7797422011-08-10 16:01:45 -07003098 F_GFX3D(128000000, pll8, 1, 3, LOW),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003099 F_GFX3D(145455000, pll2, 2, 11, NOMINAL),
3100 F_GFX3D(160000000, pll2, 1, 5, NOMINAL),
3101 F_GFX3D(177778000, pll2, 2, 9, NOMINAL),
3102 F_GFX3D(200000000, pll2, 1, 4, NOMINAL),
3103 F_GFX3D(228571000, pll2, 2, 7, NOMINAL),
3104 F_GFX3D(266667000, pll2, 1, 3, NOMINAL),
3105 F_GFX3D(320000000, pll2, 2, 5, HIGH),
3106 F_END
3107};
3108
Stephen Boyd94625ef2011-07-12 17:06:01 -07003109static struct clk_freq_tbl clk_tbl_gfx3d_v2[] = {
3110 F_GFX3D( 0, gnd, 0, 0, NONE),
3111 F_GFX3D( 27000000, pxo, 0, 0, LOW),
3112 F_GFX3D( 48000000, pll8, 1, 8, LOW),
3113 F_GFX3D( 54857000, pll8, 1, 7, LOW),
3114 F_GFX3D( 64000000, pll8, 1, 6, LOW),
3115 F_GFX3D( 76800000, pll8, 1, 5, LOW),
3116 F_GFX3D( 96000000, pll8, 1, 4, LOW),
3117 F_GFX3D(128000000, pll8, 1, 3, LOW),
3118 F_GFX3D(145455000, pll2, 2, 11, NOMINAL),
3119 F_GFX3D(160000000, pll2, 1, 5, NOMINAL),
3120 F_GFX3D(177778000, pll2, 2, 9, NOMINAL),
3121 F_GFX3D(200000000, pll2, 1, 4, NOMINAL),
3122 F_GFX3D(228571000, pll2, 2, 7, NOMINAL),
3123 F_GFX3D(266667000, pll2, 1, 3, NOMINAL),
3124 F_GFX3D(300000000, pll3, 1, 4, NOMINAL),
3125 F_GFX3D(320000000, pll2, 2, 5, HIGH),
3126 F_GFX3D(400000000, pll2, 1, 2, HIGH),
3127 F_END
3128};
3129
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003130static struct bank_masks bmnd_info_gfx3d = {
3131 .bank_sel_mask = BIT(11),
3132 .bank0_mask = {
3133 .md_reg = GFX3D_MD0_REG,
3134 .ns_mask = BM(21, 18) | BM(5, 3),
3135 .rst_mask = BIT(23),
3136 .mnd_en_mask = BIT(8),
3137 .mode_mask = BM(10, 9),
3138 },
3139 .bank1_mask = {
3140 .md_reg = GFX3D_MD1_REG,
3141 .ns_mask = BM(17, 14) | BM(2, 0),
3142 .rst_mask = BIT(22),
3143 .mnd_en_mask = BIT(5),
3144 .mode_mask = BM(7, 6),
3145 },
3146};
3147
3148static struct rcg_clk gfx3d_clk = {
3149 .b = {
3150 .ctl_reg = GFX3D_CC_REG,
3151 .en_mask = BIT(0),
3152 .reset_reg = SW_RESET_CORE_REG,
3153 .reset_mask = BIT(12),
3154 .halt_reg = DBG_BUS_VEC_A_REG,
3155 .halt_bit = 4,
3156 },
3157 .ns_reg = GFX3D_NS_REG,
3158 .root_en_mask = BIT(2),
3159 .set_rate = set_rate_mnd_banked,
3160 .freq_tbl = clk_tbl_gfx3d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003161 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003162 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003163 .c = {
3164 .dbg_name = "gfx3d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003165 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003166 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003167 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003168 },
3169};
3170
3171#define F_IJPEG(f, s, d, m, n, v) \
3172 { \
3173 .freq_hz = f, \
3174 .src_clk = &s##_clk.c, \
3175 .md_val = MD8(8, m, 0, n), \
3176 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
3177 .ctl_val = CC(6, n), \
3178 .mnd_en_mask = BIT(5) * !!(n), \
3179 .sys_vdd = v, \
3180 }
3181static struct clk_freq_tbl clk_tbl_ijpeg[] = {
3182 F_IJPEG( 0, gnd, 1, 0, 0, NONE),
3183 F_IJPEG( 27000000, pxo, 1, 0, 0, LOW),
3184 F_IJPEG( 36570000, pll8, 1, 2, 21, LOW),
3185 F_IJPEG( 54860000, pll8, 7, 0, 0, LOW),
3186 F_IJPEG( 96000000, pll8, 4, 0, 0, LOW),
3187 F_IJPEG(109710000, pll8, 1, 2, 7, LOW),
3188 F_IJPEG(128000000, pll8, 3, 0, 0, NOMINAL),
3189 F_IJPEG(153600000, pll8, 1, 2, 5, NOMINAL),
3190 F_IJPEG(200000000, pll2, 4, 0, 0, NOMINAL),
3191 F_IJPEG(228571000, pll2, 1, 2, 7, NOMINAL),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003192 F_IJPEG(320000000, pll2, 1, 2, 5, HIGH),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003193 F_END
3194};
3195
3196static struct rcg_clk ijpeg_clk = {
3197 .b = {
3198 .ctl_reg = IJPEG_CC_REG,
3199 .en_mask = BIT(0),
3200 .reset_reg = SW_RESET_CORE_REG,
3201 .reset_mask = BIT(9),
3202 .halt_reg = DBG_BUS_VEC_A_REG,
3203 .halt_bit = 24,
3204 },
3205 .ns_reg = IJPEG_NS_REG,
3206 .md_reg = IJPEG_MD_REG,
3207 .root_en_mask = BIT(2),
3208 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
3209 .ctl_mask = BM(7, 6),
3210 .set_rate = set_rate_mnd,
3211 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003212 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003213 .c = {
3214 .dbg_name = "ijpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003215 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003216 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003217 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003218 },
3219};
3220
3221#define F_JPEGD(f, s, d, v) \
3222 { \
3223 .freq_hz = f, \
3224 .src_clk = &s##_clk.c, \
3225 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
3226 .sys_vdd = v, \
3227 }
3228static struct clk_freq_tbl clk_tbl_jpegd[] = {
3229 F_JPEGD( 0, gnd, 1, NONE),
3230 F_JPEGD( 64000000, pll8, 6, LOW),
3231 F_JPEGD( 76800000, pll8, 5, LOW),
3232 F_JPEGD( 96000000, pll8, 4, LOW),
3233 F_JPEGD(160000000, pll2, 5, NOMINAL),
3234 F_JPEGD(200000000, pll2, 4, NOMINAL),
3235 F_END
3236};
3237
3238static struct rcg_clk jpegd_clk = {
3239 .b = {
3240 .ctl_reg = JPEGD_CC_REG,
3241 .en_mask = BIT(0),
3242 .reset_reg = SW_RESET_CORE_REG,
3243 .reset_mask = BIT(19),
3244 .halt_reg = DBG_BUS_VEC_A_REG,
3245 .halt_bit = 19,
3246 },
3247 .ns_reg = JPEGD_NS_REG,
3248 .root_en_mask = BIT(2),
3249 .ns_mask = (BM(15, 12) | BM(2, 0)),
3250 .set_rate = set_rate_nop,
3251 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003252 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003253 .c = {
3254 .dbg_name = "jpegd_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003255 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003256 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003257 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003258 },
3259};
3260
3261#define F_MDP(f, s, m, n, v) \
3262 { \
3263 .freq_hz = f, \
3264 .src_clk = &s##_clk.c, \
3265 .md_val = MD8(8, m, 0, n), \
3266 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
3267 .ctl_val = CC_BANKED(9, 6, n), \
3268 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
3269 .sys_vdd = v, \
3270 }
3271static struct clk_freq_tbl clk_tbl_mdp[] = {
3272 F_MDP( 0, gnd, 0, 0, NONE),
3273 F_MDP( 9600000, pll8, 1, 40, LOW),
3274 F_MDP( 13710000, pll8, 1, 28, LOW),
3275 F_MDP( 27000000, pxo, 0, 0, LOW),
3276 F_MDP( 29540000, pll8, 1, 13, LOW),
3277 F_MDP( 34910000, pll8, 1, 11, LOW),
3278 F_MDP( 38400000, pll8, 1, 10, LOW),
3279 F_MDP( 59080000, pll8, 2, 13, LOW),
3280 F_MDP( 76800000, pll8, 1, 5, LOW),
3281 F_MDP( 85330000, pll8, 2, 9, LOW),
3282 F_MDP( 96000000, pll8, 1, 4, NOMINAL),
3283 F_MDP(128000000, pll8, 1, 3, NOMINAL),
3284 F_MDP(160000000, pll2, 1, 5, NOMINAL),
3285 F_MDP(177780000, pll2, 2, 9, NOMINAL),
3286 F_MDP(200000000, pll2, 1, 4, NOMINAL),
3287 F_END
3288};
3289
3290static struct bank_masks bmnd_info_mdp = {
3291 .bank_sel_mask = BIT(11),
3292 .bank0_mask = {
3293 .md_reg = MDP_MD0_REG,
3294 .ns_mask = BM(29, 22) | BM(5, 3),
3295 .rst_mask = BIT(31),
3296 .mnd_en_mask = BIT(8),
3297 .mode_mask = BM(10, 9),
3298 },
3299 .bank1_mask = {
3300 .md_reg = MDP_MD1_REG,
3301 .ns_mask = BM(21, 14) | BM(2, 0),
3302 .rst_mask = BIT(30),
3303 .mnd_en_mask = BIT(5),
3304 .mode_mask = BM(7, 6),
3305 },
3306};
3307
3308static struct rcg_clk mdp_clk = {
3309 .b = {
3310 .ctl_reg = MDP_CC_REG,
3311 .en_mask = BIT(0),
3312 .reset_reg = SW_RESET_CORE_REG,
3313 .reset_mask = BIT(21),
3314 .halt_reg = DBG_BUS_VEC_C_REG,
3315 .halt_bit = 10,
3316 },
3317 .ns_reg = MDP_NS_REG,
3318 .root_en_mask = BIT(2),
3319 .set_rate = set_rate_mnd_banked,
3320 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003321 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003322 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003323 .c = {
3324 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003325 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003326 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003327 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003328 },
3329};
3330
3331static struct branch_clk lut_mdp_clk = {
3332 .b = {
3333 .ctl_reg = MDP_LUT_CC_REG,
3334 .en_mask = BIT(0),
3335 .halt_reg = DBG_BUS_VEC_I_REG,
3336 .halt_bit = 13,
3337 },
3338 .parent = &mdp_clk.c,
3339 .c = {
3340 .dbg_name = "lut_mdp_clk",
3341 .ops = &clk_ops_branch,
3342 CLK_INIT(lut_mdp_clk.c),
3343 },
3344};
3345
3346#define F_MDP_VSYNC(f, s, v) \
3347 { \
3348 .freq_hz = f, \
3349 .src_clk = &s##_clk.c, \
3350 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
3351 .sys_vdd = v, \
3352 }
3353static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
3354 F_MDP_VSYNC(27000000, pxo, LOW),
3355 F_END
3356};
3357
3358static struct rcg_clk mdp_vsync_clk = {
3359 .b = {
3360 .ctl_reg = MISC_CC_REG,
3361 .en_mask = BIT(6),
3362 .reset_reg = SW_RESET_CORE_REG,
3363 .reset_mask = BIT(3),
3364 .halt_reg = DBG_BUS_VEC_B_REG,
3365 .halt_bit = 22,
3366 },
3367 .ns_reg = MISC_CC2_REG,
3368 .ns_mask = BIT(13),
3369 .set_rate = set_rate_nop,
3370 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003371 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003372 .c = {
3373 .dbg_name = "mdp_vsync_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003374 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003375 CLK_INIT(mdp_vsync_clk.c),
3376 },
3377};
3378
3379#define F_ROT(f, s, d, v) \
3380 { \
3381 .freq_hz = f, \
3382 .src_clk = &s##_clk.c, \
3383 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
3384 21, 19, 18, 16, s##_to_mm_mux), \
3385 .sys_vdd = v, \
3386 }
3387static struct clk_freq_tbl clk_tbl_rot[] = {
3388 F_ROT( 0, gnd, 1, NONE),
3389 F_ROT( 27000000, pxo, 1, LOW),
3390 F_ROT( 29540000, pll8, 13, LOW),
3391 F_ROT( 32000000, pll8, 12, LOW),
3392 F_ROT( 38400000, pll8, 10, LOW),
3393 F_ROT( 48000000, pll8, 8, LOW),
3394 F_ROT( 54860000, pll8, 7, LOW),
3395 F_ROT( 64000000, pll8, 6, LOW),
3396 F_ROT( 76800000, pll8, 5, LOW),
3397 F_ROT( 96000000, pll8, 4, NOMINAL),
3398 F_ROT(100000000, pll2, 8, NOMINAL),
3399 F_ROT(114290000, pll2, 7, NOMINAL),
3400 F_ROT(133330000, pll2, 6, NOMINAL),
3401 F_ROT(160000000, pll2, 5, NOMINAL),
Stephen Boyd8487f712011-08-29 12:10:09 -07003402 F_ROT(200000000, pll2, 4, NOMINAL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003403 F_END
3404};
3405
3406static struct bank_masks bdiv_info_rot = {
3407 .bank_sel_mask = BIT(30),
3408 .bank0_mask = {
3409 .ns_mask = BM(25, 22) | BM(18, 16),
3410 },
3411 .bank1_mask = {
3412 .ns_mask = BM(29, 26) | BM(21, 19),
3413 },
3414};
3415
3416static struct rcg_clk rot_clk = {
3417 .b = {
3418 .ctl_reg = ROT_CC_REG,
3419 .en_mask = BIT(0),
3420 .reset_reg = SW_RESET_CORE_REG,
3421 .reset_mask = BIT(2),
3422 .halt_reg = DBG_BUS_VEC_C_REG,
3423 .halt_bit = 15,
3424 },
3425 .ns_reg = ROT_NS_REG,
3426 .root_en_mask = BIT(2),
3427 .set_rate = set_rate_div_banked,
3428 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003429 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003430 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003431 .c = {
3432 .dbg_name = "rot_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003433 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003434 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003435 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003436 },
3437};
3438
3439static int hdmi_pll_clk_enable(struct clk *clk)
3440{
3441 int ret;
3442 unsigned long flags;
3443 spin_lock_irqsave(&local_clock_reg_lock, flags);
3444 ret = hdmi_pll_enable();
3445 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3446 return ret;
3447}
3448
3449static void hdmi_pll_clk_disable(struct clk *clk)
3450{
3451 unsigned long flags;
3452 spin_lock_irqsave(&local_clock_reg_lock, flags);
3453 hdmi_pll_disable();
3454 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3455}
3456
3457static unsigned hdmi_pll_clk_get_rate(struct clk *clk)
3458{
3459 return hdmi_pll_get_rate();
3460}
3461
3462static struct clk_ops clk_ops_hdmi_pll = {
3463 .enable = hdmi_pll_clk_enable,
3464 .disable = hdmi_pll_clk_disable,
3465 .get_rate = hdmi_pll_clk_get_rate,
3466 .is_local = local_clk_is_local,
3467};
3468
3469static struct clk hdmi_pll_clk = {
3470 .dbg_name = "hdmi_pll_clk",
3471 .ops = &clk_ops_hdmi_pll,
3472 CLK_INIT(hdmi_pll_clk),
3473};
3474
3475#define F_TV_GND(f, s, p_r, d, m, n, v) \
3476 { \
3477 .freq_hz = f, \
3478 .src_clk = &s##_clk.c, \
3479 .md_val = MD8(8, m, 0, n), \
3480 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3481 .ctl_val = CC(6, n), \
3482 .mnd_en_mask = BIT(5) * !!(n), \
3483 .sys_vdd = v, \
3484 }
3485#define F_TV(f, s, p_r, d, m, n, v) \
3486 { \
3487 .freq_hz = f, \
3488 .src_clk = &s##_clk, \
3489 .md_val = MD8(8, m, 0, n), \
3490 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3491 .ctl_val = CC(6, n), \
3492 .mnd_en_mask = BIT(5) * !!(n), \
3493 .sys_vdd = v, \
3494 .extra_freq_data = (void *)p_r, \
3495 }
3496/* Switching TV freqs requires PLL reconfiguration. */
3497static struct clk_freq_tbl clk_tbl_tv[] = {
3498 F_TV_GND( 0, gnd, 0, 1, 0, 0, NONE),
3499 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0, LOW),
3500 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0, LOW),
3501 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0, LOW),
3502 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0, NOMINAL),
3503 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0, NOMINAL),
3504 F_END
3505};
3506
3507/*
3508 * Unlike other clocks, the TV rate is adjusted through PLL
3509 * re-programming. It is also routed through an MND divider.
3510 */
3511void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
3512{
3513 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
3514 if (pll_rate)
3515 hdmi_pll_set_rate(pll_rate);
3516 set_rate_mnd(clk, nf);
3517}
3518
3519static struct rcg_clk tv_src_clk = {
3520 .ns_reg = TV_NS_REG,
3521 .b = {
3522 .ctl_reg = TV_CC_REG,
3523 .halt_check = NOCHECK,
3524 },
3525 .md_reg = TV_MD_REG,
3526 .root_en_mask = BIT(2),
3527 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
3528 .ctl_mask = BM(7, 6),
3529 .set_rate = set_rate_tv,
3530 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003531 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003532 .c = {
3533 .dbg_name = "tv_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003534 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003535 CLK_INIT(tv_src_clk.c),
3536 },
3537};
3538
3539static struct branch_clk tv_enc_clk = {
3540 .b = {
3541 .ctl_reg = TV_CC_REG,
3542 .en_mask = BIT(8),
3543 .reset_reg = SW_RESET_CORE_REG,
3544 .reset_mask = BIT(0),
3545 .halt_reg = DBG_BUS_VEC_D_REG,
3546 .halt_bit = 9,
3547 },
3548 .parent = &tv_src_clk.c,
3549 .c = {
3550 .dbg_name = "tv_enc_clk",
3551 .ops = &clk_ops_branch,
3552 CLK_INIT(tv_enc_clk.c),
3553 },
3554};
3555
3556static struct branch_clk tv_dac_clk = {
3557 .b = {
3558 .ctl_reg = TV_CC_REG,
3559 .en_mask = BIT(10),
3560 .halt_reg = DBG_BUS_VEC_D_REG,
3561 .halt_bit = 10,
3562 },
3563 .parent = &tv_src_clk.c,
3564 .c = {
3565 .dbg_name = "tv_dac_clk",
3566 .ops = &clk_ops_branch,
3567 CLK_INIT(tv_dac_clk.c),
3568 },
3569};
3570
3571static struct branch_clk mdp_tv_clk = {
3572 .b = {
3573 .ctl_reg = TV_CC_REG,
3574 .en_mask = BIT(0),
3575 .reset_reg = SW_RESET_CORE_REG,
3576 .reset_mask = BIT(4),
3577 .halt_reg = DBG_BUS_VEC_D_REG,
3578 .halt_bit = 12,
3579 },
3580 .parent = &tv_src_clk.c,
3581 .c = {
3582 .dbg_name = "mdp_tv_clk",
3583 .ops = &clk_ops_branch,
3584 CLK_INIT(mdp_tv_clk.c),
3585 },
3586};
3587
3588static struct branch_clk hdmi_tv_clk = {
3589 .b = {
3590 .ctl_reg = TV_CC_REG,
3591 .en_mask = BIT(12),
3592 .reset_reg = SW_RESET_CORE_REG,
3593 .reset_mask = BIT(1),
3594 .halt_reg = DBG_BUS_VEC_D_REG,
3595 .halt_bit = 11,
3596 },
3597 .parent = &tv_src_clk.c,
3598 .c = {
3599 .dbg_name = "hdmi_tv_clk",
3600 .ops = &clk_ops_branch,
3601 CLK_INIT(hdmi_tv_clk.c),
3602 },
3603};
3604
3605static struct branch_clk hdmi_app_clk = {
3606 .b = {
3607 .ctl_reg = MISC_CC2_REG,
3608 .en_mask = BIT(11),
3609 .reset_reg = SW_RESET_CORE_REG,
3610 .reset_mask = BIT(11),
3611 .halt_reg = DBG_BUS_VEC_B_REG,
3612 .halt_bit = 25,
3613 },
3614 .c = {
3615 .dbg_name = "hdmi_app_clk",
3616 .ops = &clk_ops_branch,
3617 CLK_INIT(hdmi_app_clk.c),
3618 },
3619};
3620
3621static struct bank_masks bmnd_info_vcodec = {
3622 .bank_sel_mask = BIT(13),
3623 .bank0_mask = {
3624 .md_reg = VCODEC_MD0_REG,
3625 .ns_mask = BM(18, 11) | BM(2, 0),
3626 .rst_mask = BIT(31),
3627 .mnd_en_mask = BIT(5),
3628 .mode_mask = BM(7, 6),
3629 },
3630 .bank1_mask = {
3631 .md_reg = VCODEC_MD1_REG,
3632 .ns_mask = BM(26, 19) | BM(29, 27),
3633 .rst_mask = BIT(30),
3634 .mnd_en_mask = BIT(10),
3635 .mode_mask = BM(12, 11),
3636 },
3637};
3638#define F_VCODEC(f, s, m, n, v) \
3639 { \
3640 .freq_hz = f, \
3641 .src_clk = &s##_clk.c, \
3642 .md_val = MD8(8, m, 0, n), \
3643 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
3644 .ctl_val = CC_BANKED(6, 11, n), \
3645 .mnd_en_mask = (BIT(10) | BIT(5)) * !!(n), \
3646 .sys_vdd = v, \
3647 }
3648static struct clk_freq_tbl clk_tbl_vcodec[] = {
3649 F_VCODEC( 0, gnd, 0, 0, NONE),
3650 F_VCODEC( 27000000, pxo, 0, 0, LOW),
3651 F_VCODEC( 32000000, pll8, 1, 12, LOW),
3652 F_VCODEC( 48000000, pll8, 1, 8, LOW),
3653 F_VCODEC( 54860000, pll8, 1, 7, LOW),
3654 F_VCODEC( 96000000, pll8, 1, 4, LOW),
3655 F_VCODEC(133330000, pll2, 1, 6, NOMINAL),
3656 F_VCODEC(200000000, pll2, 1, 4, NOMINAL),
3657 F_VCODEC(228570000, pll2, 2, 7, HIGH),
3658 F_END
3659};
3660
3661static struct rcg_clk vcodec_clk = {
3662 .b = {
3663 .ctl_reg = VCODEC_CC_REG,
3664 .en_mask = BIT(0),
3665 .reset_reg = SW_RESET_CORE_REG,
3666 .reset_mask = BIT(6),
3667 .halt_reg = DBG_BUS_VEC_C_REG,
3668 .halt_bit = 29,
3669 },
3670 .ns_reg = VCODEC_NS_REG,
3671 .root_en_mask = BIT(2),
3672 .set_rate = set_rate_mnd_banked,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003673 .bank_info = &bmnd_info_vcodec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003674 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003675 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003676 .c = {
3677 .dbg_name = "vcodec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003678 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003679 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003680 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003681 },
3682};
3683
3684#define F_VPE(f, s, d, v) \
3685 { \
3686 .freq_hz = f, \
3687 .src_clk = &s##_clk.c, \
3688 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
3689 .sys_vdd = v, \
3690 }
3691static struct clk_freq_tbl clk_tbl_vpe[] = {
3692 F_VPE( 0, gnd, 1, NONE),
3693 F_VPE( 27000000, pxo, 1, LOW),
3694 F_VPE( 34909000, pll8, 11, LOW),
3695 F_VPE( 38400000, pll8, 10, LOW),
3696 F_VPE( 64000000, pll8, 6, LOW),
3697 F_VPE( 76800000, pll8, 5, LOW),
3698 F_VPE( 96000000, pll8, 4, NOMINAL),
3699 F_VPE(100000000, pll2, 8, NOMINAL),
3700 F_VPE(160000000, pll2, 5, NOMINAL),
3701 F_END
3702};
3703
3704static struct rcg_clk vpe_clk = {
3705 .b = {
3706 .ctl_reg = VPE_CC_REG,
3707 .en_mask = BIT(0),
3708 .reset_reg = SW_RESET_CORE_REG,
3709 .reset_mask = BIT(17),
3710 .halt_reg = DBG_BUS_VEC_A_REG,
3711 .halt_bit = 28,
3712 },
3713 .ns_reg = VPE_NS_REG,
3714 .root_en_mask = BIT(2),
3715 .ns_mask = (BM(15, 12) | BM(2, 0)),
3716 .set_rate = set_rate_nop,
3717 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003718 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003719 .c = {
3720 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003721 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003722 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003723 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003724 },
3725};
3726
3727#define F_VFE(f, s, d, m, n, v) \
3728 { \
3729 .freq_hz = f, \
3730 .src_clk = &s##_clk.c, \
3731 .md_val = MD8(8, m, 0, n), \
3732 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
3733 .ctl_val = CC(6, n), \
3734 .mnd_en_mask = BIT(5) * !!(n), \
3735 .sys_vdd = v, \
3736 }
3737static struct clk_freq_tbl clk_tbl_vfe[] = {
3738 F_VFE( 0, gnd, 1, 0, 0, NONE),
3739 F_VFE( 13960000, pll8, 1, 2, 55, LOW),
3740 F_VFE( 27000000, pxo, 1, 0, 0, LOW),
3741 F_VFE( 36570000, pll8, 1, 2, 21, LOW),
3742 F_VFE( 38400000, pll8, 2, 1, 5, LOW),
3743 F_VFE( 45180000, pll8, 1, 2, 17, LOW),
3744 F_VFE( 48000000, pll8, 2, 1, 4, LOW),
3745 F_VFE( 54860000, pll8, 1, 1, 7, LOW),
3746 F_VFE( 64000000, pll8, 2, 1, 3, LOW),
3747 F_VFE( 76800000, pll8, 1, 1, 5, LOW),
3748 F_VFE( 96000000, pll8, 2, 1, 2, LOW),
3749 F_VFE(109710000, pll8, 1, 2, 7, LOW),
3750 F_VFE(128000000, pll8, 1, 1, 3, NOMINAL),
3751 F_VFE(153600000, pll8, 1, 2, 5, NOMINAL),
3752 F_VFE(200000000, pll2, 2, 1, 2, NOMINAL),
3753 F_VFE(228570000, pll2, 1, 2, 7, NOMINAL),
3754 F_VFE(266667000, pll2, 1, 1, 3, NOMINAL),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003755 F_VFE(320000000, pll2, 1, 2, 5, HIGH),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003756 F_END
3757};
3758
3759
3760static struct rcg_clk vfe_clk = {
3761 .b = {
3762 .ctl_reg = VFE_CC_REG,
3763 .reset_reg = SW_RESET_CORE_REG,
3764 .reset_mask = BIT(15),
3765 .halt_reg = DBG_BUS_VEC_B_REG,
3766 .halt_bit = 6,
3767 .en_mask = BIT(0),
3768 },
3769 .ns_reg = VFE_NS_REG,
3770 .md_reg = VFE_MD_REG,
3771 .root_en_mask = BIT(2),
3772 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
3773 .ctl_mask = BM(7, 6),
3774 .set_rate = set_rate_mnd,
3775 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003776 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003777 .c = {
3778 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003779 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003780 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003781 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003782 },
3783};
3784
Matt Wagantallc23eee92011-08-16 23:06:52 -07003785static struct branch_clk csi_vfe_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003786 .b = {
3787 .ctl_reg = VFE_CC_REG,
3788 .en_mask = BIT(12),
3789 .reset_reg = SW_RESET_CORE_REG,
3790 .reset_mask = BIT(24),
3791 .halt_reg = DBG_BUS_VEC_B_REG,
3792 .halt_bit = 8,
3793 },
3794 .parent = &vfe_clk.c,
3795 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -07003796 .dbg_name = "csi_vfe_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003797 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -07003798 CLK_INIT(csi_vfe_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003799 },
3800};
3801
3802/*
3803 * Low Power Audio Clocks
3804 */
3805#define F_AIF_OSR(f, s, d, m, n, v) \
3806 { \
3807 .freq_hz = f, \
3808 .src_clk = &s##_clk.c, \
3809 .md_val = MD8(8, m, 0, n), \
3810 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
3811 .mnd_en_mask = BIT(8) * !!(n), \
3812 .sys_vdd = v, \
3813 }
3814static struct clk_freq_tbl clk_tbl_aif_osr[] = {
3815 F_AIF_OSR( 0, gnd, 1, 0, 0, NONE),
3816 F_AIF_OSR( 768000, pll4, 4, 1, 128, LOW),
3817 F_AIF_OSR( 1024000, pll4, 4, 1, 96, LOW),
3818 F_AIF_OSR( 1536000, pll4, 4, 1, 64, LOW),
3819 F_AIF_OSR( 2048000, pll4, 4, 1, 48, LOW),
3820 F_AIF_OSR( 3072000, pll4, 4, 1, 32, LOW),
3821 F_AIF_OSR( 4096000, pll4, 4, 1, 24, LOW),
3822 F_AIF_OSR( 6144000, pll4, 4, 1, 16, LOW),
3823 F_AIF_OSR( 8192000, pll4, 4, 1, 12, LOW),
3824 F_AIF_OSR(12288000, pll4, 4, 1, 8, LOW),
3825 F_AIF_OSR(24576000, pll4, 4, 1, 4, LOW),
3826 F_END
3827};
3828
3829#define CLK_AIF_OSR(i, ns, md, h_r) \
3830 struct rcg_clk i##_clk = { \
3831 .b = { \
3832 .ctl_reg = ns, \
3833 .en_mask = BIT(17), \
3834 .reset_reg = ns, \
3835 .reset_mask = BIT(19), \
3836 .halt_reg = h_r, \
3837 .halt_check = ENABLE, \
3838 .halt_bit = 1, \
3839 }, \
3840 .ns_reg = ns, \
3841 .md_reg = md, \
3842 .root_en_mask = BIT(9), \
3843 .ns_mask = (BM(31, 24) | BM(6, 0)), \
3844 .set_rate = set_rate_mnd, \
3845 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003846 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003847 .c = { \
3848 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003849 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003850 CLK_INIT(i##_clk.c), \
3851 }, \
3852 }
3853#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
3854 struct rcg_clk i##_clk = { \
3855 .b = { \
3856 .ctl_reg = ns, \
3857 .en_mask = BIT(21), \
3858 .reset_reg = ns, \
3859 .reset_mask = BIT(23), \
3860 .halt_reg = h_r, \
3861 .halt_check = ENABLE, \
3862 .halt_bit = 1, \
3863 }, \
3864 .ns_reg = ns, \
3865 .md_reg = md, \
3866 .root_en_mask = BIT(9), \
3867 .ns_mask = (BM(31, 24) | BM(6, 0)), \
3868 .set_rate = set_rate_mnd, \
3869 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003870 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003871 .c = { \
3872 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003873 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003874 CLK_INIT(i##_clk.c), \
3875 }, \
3876 }
3877
3878#define F_AIF_BIT(d, s) \
3879 { \
3880 .freq_hz = d, \
3881 .ns_val = (BVAL(14, 14, s) | BVAL(13, 10, (d-1))) \
3882 }
3883static struct clk_freq_tbl clk_tbl_aif_bit[] = {
3884 F_AIF_BIT(0, 1), /* Use external clock. */
3885 F_AIF_BIT(1, 0), F_AIF_BIT(2, 0), F_AIF_BIT(3, 0), F_AIF_BIT(4, 0),
3886 F_AIF_BIT(5, 0), F_AIF_BIT(6, 0), F_AIF_BIT(7, 0), F_AIF_BIT(8, 0),
3887 F_AIF_BIT(9, 0), F_AIF_BIT(10, 0), F_AIF_BIT(11, 0), F_AIF_BIT(12, 0),
3888 F_AIF_BIT(13, 0), F_AIF_BIT(14, 0), F_AIF_BIT(15, 0), F_AIF_BIT(16, 0),
3889 F_END
3890};
3891
3892#define CLK_AIF_BIT(i, ns, h_r) \
3893 struct rcg_clk i##_clk = { \
3894 .b = { \
3895 .ctl_reg = ns, \
3896 .en_mask = BIT(15), \
3897 .halt_reg = h_r, \
3898 .halt_check = DELAY, \
3899 }, \
3900 .ns_reg = ns, \
3901 .ns_mask = BM(14, 10), \
3902 .set_rate = set_rate_nop, \
3903 .freq_tbl = clk_tbl_aif_bit, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003904 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003905 .c = { \
3906 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003907 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003908 CLK_INIT(i##_clk.c), \
3909 }, \
3910 }
3911
3912#define F_AIF_BIT_D(d, s) \
3913 { \
3914 .freq_hz = d, \
3915 .ns_val = (BVAL(18, 18, s) | BVAL(17, 10, (d-1))) \
3916 }
3917static struct clk_freq_tbl clk_tbl_aif_bit_div[] = {
3918 F_AIF_BIT_D(0, 1), /* Use external clock. */
3919 F_AIF_BIT_D(1, 0), F_AIF_BIT_D(2, 0), F_AIF_BIT_D(3, 0),
3920 F_AIF_BIT_D(4, 0), F_AIF_BIT_D(5, 0), F_AIF_BIT_D(6, 0),
3921 F_AIF_BIT_D(7, 0), F_AIF_BIT_D(8, 0), F_AIF_BIT_D(9, 0),
3922 F_AIF_BIT_D(10, 0), F_AIF_BIT_D(11, 0), F_AIF_BIT_D(12, 0),
3923 F_AIF_BIT_D(13, 0), F_AIF_BIT_D(14, 0), F_AIF_BIT_D(15, 0),
3924 F_AIF_BIT_D(16, 0),
3925 F_END
3926};
3927
3928#define CLK_AIF_BIT_DIV(i, ns, h_r) \
3929 struct rcg_clk i##_clk = { \
3930 .b = { \
3931 .ctl_reg = ns, \
3932 .en_mask = BIT(19), \
3933 .halt_reg = h_r, \
3934 .halt_check = ENABLE, \
3935 }, \
3936 .ns_reg = ns, \
3937 .ns_mask = BM(18, 10), \
3938 .set_rate = set_rate_nop, \
3939 .freq_tbl = clk_tbl_aif_bit_div, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003940 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003941 .c = { \
3942 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003943 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003944 CLK_INIT(i##_clk.c), \
3945 }, \
3946 }
3947
3948static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
3949 LCC_MI2S_STATUS_REG);
3950static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
3951
3952static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
3953 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
3954static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
3955 LCC_CODEC_I2S_MIC_STATUS_REG);
3956
3957static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
3958 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
3959static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
3960 LCC_SPARE_I2S_MIC_STATUS_REG);
3961
3962static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
3963 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
3964static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
3965 LCC_CODEC_I2S_SPKR_STATUS_REG);
3966
3967static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
3968 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
3969static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
3970 LCC_SPARE_I2S_SPKR_STATUS_REG);
3971
3972#define F_PCM(f, s, d, m, n, v) \
3973 { \
3974 .freq_hz = f, \
3975 .src_clk = &s##_clk.c, \
3976 .md_val = MD16(m, n), \
3977 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
3978 .mnd_en_mask = BIT(8) * !!(n), \
3979 .sys_vdd = v, \
3980 }
3981static struct clk_freq_tbl clk_tbl_pcm[] = {
3982 F_PCM( 0, gnd, 1, 0, 0, NONE),
3983 F_PCM( 512000, pll4, 4, 1, 192, LOW),
3984 F_PCM( 768000, pll4, 4, 1, 128, LOW),
3985 F_PCM( 1024000, pll4, 4, 1, 96, LOW),
3986 F_PCM( 1536000, pll4, 4, 1, 64, LOW),
3987 F_PCM( 2048000, pll4, 4, 1, 48, LOW),
3988 F_PCM( 3072000, pll4, 4, 1, 32, LOW),
3989 F_PCM( 4096000, pll4, 4, 1, 24, LOW),
3990 F_PCM( 6144000, pll4, 4, 1, 16, LOW),
3991 F_PCM( 8192000, pll4, 4, 1, 12, LOW),
3992 F_PCM(12288000, pll4, 4, 1, 8, LOW),
3993 F_PCM(24576000, pll4, 4, 1, 4, LOW),
3994 F_END
3995};
3996
3997static struct rcg_clk pcm_clk = {
3998 .b = {
3999 .ctl_reg = LCC_PCM_NS_REG,
4000 .en_mask = BIT(11),
4001 .reset_reg = LCC_PCM_NS_REG,
4002 .reset_mask = BIT(13),
4003 .halt_reg = LCC_PCM_STATUS_REG,
4004 .halt_check = ENABLE,
4005 .halt_bit = 0,
4006 },
4007 .ns_reg = LCC_PCM_NS_REG,
4008 .md_reg = LCC_PCM_MD_REG,
4009 .root_en_mask = BIT(9),
4010 .ns_mask = (BM(31, 16) | BM(6, 0)),
4011 .set_rate = set_rate_mnd,
4012 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004013 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004014 .c = {
4015 .dbg_name = "pcm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004016 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004017 CLK_INIT(pcm_clk.c),
4018 },
4019};
4020
4021static struct rcg_clk audio_slimbus_clk = {
4022 .b = {
4023 .ctl_reg = LCC_SLIMBUS_NS_REG,
4024 .en_mask = BIT(10),
4025 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
4026 .reset_mask = BIT(5),
4027 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4028 .halt_check = ENABLE,
4029 .halt_bit = 0,
4030 },
4031 .ns_reg = LCC_SLIMBUS_NS_REG,
4032 .md_reg = LCC_SLIMBUS_MD_REG,
4033 .root_en_mask = BIT(9),
4034 .ns_mask = (BM(31, 24) | BM(6, 0)),
4035 .set_rate = set_rate_mnd,
4036 .freq_tbl = clk_tbl_aif_osr,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004037 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004038 .c = {
4039 .dbg_name = "audio_slimbus_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004040 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004041 CLK_INIT(audio_slimbus_clk.c),
4042 },
4043};
4044
4045static struct branch_clk sps_slimbus_clk = {
4046 .b = {
4047 .ctl_reg = LCC_SLIMBUS_NS_REG,
4048 .en_mask = BIT(12),
4049 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4050 .halt_check = ENABLE,
4051 .halt_bit = 1,
4052 },
4053 .parent = &audio_slimbus_clk.c,
4054 .c = {
4055 .dbg_name = "sps_slimbus_clk",
4056 .ops = &clk_ops_branch,
4057 CLK_INIT(sps_slimbus_clk.c),
4058 },
4059};
4060
4061static struct branch_clk slimbus_xo_src_clk = {
4062 .b = {
4063 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
4064 .en_mask = BIT(2),
4065 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004066 .halt_bit = 28,
4067 },
4068 .parent = &sps_slimbus_clk.c,
4069 .c = {
4070 .dbg_name = "slimbus_xo_src_clk",
4071 .ops = &clk_ops_branch,
4072 CLK_INIT(slimbus_xo_src_clk.c),
4073 },
4074};
4075
Matt Wagantall735f01a2011-08-12 12:40:28 -07004076DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
4077DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
4078DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
4079DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
4080DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
4081DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
4082DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
4083DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004084
4085static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
4086static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
4087static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
4088static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
4089static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
4090static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
4091static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
4092static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
4093
4094static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
4095/*
4096 * TODO: replace dummy_clk below with ebi1_clk.c once the
4097 * bus driver starts voting on ebi1 rates.
4098 */
4099static DEFINE_CLK_VOTER(ebi1_adm_clk, &dummy_clk);
4100
4101#ifdef CONFIG_DEBUG_FS
4102struct measure_sel {
4103 u32 test_vector;
4104 struct clk *clk;
4105};
4106
Matt Wagantall8b38f942011-08-02 18:23:18 -07004107static DEFINE_CLK_MEASURE(l2_m_clk);
4108static DEFINE_CLK_MEASURE(krait0_m_clk);
4109static DEFINE_CLK_MEASURE(krait1_m_clk);
4110
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004111static struct measure_sel measure_mux[] = {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004112 { TEST_PER_LS(0x05), &qdss_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004113 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
4114 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
4115 { TEST_PER_LS(0x13), &sdc1_clk.c },
4116 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
4117 { TEST_PER_LS(0x15), &sdc2_clk.c },
4118 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
4119 { TEST_PER_LS(0x17), &sdc3_clk.c },
4120 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
4121 { TEST_PER_LS(0x19), &sdc4_clk.c },
4122 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
4123 { TEST_PER_LS(0x1B), &sdc5_clk.c },
4124 { TEST_PER_LS(0x25), &dfab_clk.c },
4125 { TEST_PER_LS(0x25), &dfab_a_clk.c },
4126 { TEST_PER_LS(0x26), &pmem_clk.c },
4127 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
4128 { TEST_PER_LS(0x33), &cfpb_clk.c },
4129 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
4130 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
4131 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
4132 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
4133 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
4134 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
4135 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
4136 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
4137 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
4138 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
4139 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
4140 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
4141 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
4142 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
4143 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
4144 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
4145 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
4146 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
4147 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
4148 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
4149 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
4150 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
4151 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
4152 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
4153 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
4154 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
4155 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
4156 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
4157 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
4158 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
4159 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
4160 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
4161 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
4162 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
4163 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
4164 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
4165 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
4166 { TEST_PER_LS(0x78), &sfpb_clk.c },
4167 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
4168 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
4169 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
4170 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
4171 { TEST_PER_LS(0x7D), &prng_clk.c },
4172 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
4173 { TEST_PER_LS(0x80), &adm0_p_clk.c },
4174 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
4175 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004176 { TEST_PER_LS(0x86), &usb_hsic_p_clk.c },
4177 { TEST_PER_LS(0x87), &usb_hsic_system_clk.c },
4178 { TEST_PER_LS(0x88), &usb_hsic_xcvr_fs_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004179 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
4180 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
4181 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
4182 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
4183 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
4184 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
4185 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
4186 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
4187 { TEST_PER_LS(0x92), &ce1_p_clk.c },
4188 { TEST_PER_LS(0x94), &tssc_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004189 { TEST_PER_LS(0x9D), &usb_hsic_hsio_cal_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004190 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
4191
4192 { TEST_PER_HS(0x07), &afab_clk.c },
4193 { TEST_PER_HS(0x07), &afab_a_clk.c },
4194 { TEST_PER_HS(0x18), &sfab_clk.c },
4195 { TEST_PER_HS(0x18), &sfab_a_clk.c },
4196 { TEST_PER_HS(0x2A), &adm0_clk.c },
4197 { TEST_PER_HS(0x34), &ebi1_clk.c },
4198 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004199 { TEST_PER_HS(0x48), &qdss_at_clk.c },
4200 { TEST_PER_HS(0x49), &qdss_pclkdbg_clk.c },
4201 { TEST_PER_HS(0x4A), &qdss_traceclkin_clk.c },
4202 { TEST_PER_HS(0x4B), &qdss_tsctr_clk.c },
4203 { TEST_PER_HS(0x4F), &qdss_stm_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004204 { TEST_PER_HS(0x50), &usb_hsic_hsic_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004205
4206 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
4207 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
4208 { TEST_MM_LS(0x02), &cam1_clk.c },
4209 { TEST_MM_LS(0x06), &amp_p_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004210 { TEST_MM_LS(0x07), &csi_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004211 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
4212 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
4213 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
4214 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
4215 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
4216 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
4217 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
4218 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
4219 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
4220 { TEST_MM_LS(0x12), &imem_p_clk.c },
4221 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
4222 { TEST_MM_LS(0x14), &mdp_p_clk.c },
4223 { TEST_MM_LS(0x16), &rot_p_clk.c },
4224 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
4225 { TEST_MM_LS(0x18), &smmu_p_clk.c },
4226 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
4227 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
4228 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
4229 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
4230 { TEST_MM_LS(0x1D), &cam0_clk.c },
4231 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
4232 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
4233 { TEST_MM_LS(0x21), &tv_dac_clk.c },
4234 { TEST_MM_LS(0x22), &tv_enc_clk.c },
4235 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
4236 { TEST_MM_LS(0x25), &mmfpb_clk.c },
4237 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
4238 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004239 { TEST_MM_LS(0x27), &cam2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004240
4241 { TEST_MM_HS(0x00), &csi0_clk.c },
4242 { TEST_MM_HS(0x01), &csi1_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004243 { TEST_MM_HS(0x04), &csi_vfe_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004244 { TEST_MM_HS(0x05), &ijpeg_clk.c },
4245 { TEST_MM_HS(0x06), &vfe_clk.c },
4246 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
4247 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
4248 { TEST_MM_HS(0x09), &gfx3d_clk.c },
4249 { TEST_MM_HS(0x0A), &jpegd_clk.c },
4250 { TEST_MM_HS(0x0B), &vcodec_clk.c },
4251 { TEST_MM_HS(0x0F), &mmfab_clk.c },
4252 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
4253 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
4254 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
4255 { TEST_MM_HS(0x13), &imem_axi_clk.c },
4256 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
4257 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
4258 { TEST_MM_HS(0x16), &rot_axi_clk.c },
4259 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
4260 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
4261 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
4262 { TEST_MM_HS(0x1A), &mdp_clk.c },
4263 { TEST_MM_HS(0x1B), &rot_clk.c },
4264 { TEST_MM_HS(0x1C), &vpe_clk.c },
4265 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
4266 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
4267 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
4268 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
4269 { TEST_MM_HS(0x26), &csi_pix_clk.c },
4270 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
4271 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
4272 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
4273 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
4274 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
4275 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004276 { TEST_MM_HS(0x2D), &csi2_clk.c },
4277 { TEST_MM_HS(0x2E), &csi2_phy_clk.c },
4278 { TEST_MM_HS(0x2F), &csi2phy_timer_clk.c },
4279 { TEST_MM_HS(0x30), &csi_pix1_clk.c },
4280 { TEST_MM_HS(0x31), &csi_rdi1_clk.c },
4281 { TEST_MM_HS(0x32), &csi_rdi2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004282
4283 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
4284 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
4285 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
4286 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
4287 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
4288 { TEST_LPA(0x14), &pcm_clk.c },
4289 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
Matt Wagantall8b38f942011-08-02 18:23:18 -07004290
4291 { TEST_CPUL2(0x1), &l2_m_clk },
4292 { TEST_CPUL2(0x2), &krait0_m_clk },
4293 { TEST_CPUL2(0x3), &krait1_m_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004294};
4295
4296static struct measure_sel *find_measure_sel(struct clk *clk)
4297{
4298 int i;
4299
4300 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
4301 if (measure_mux[i].clk == clk)
4302 return &measure_mux[i];
4303 return NULL;
4304}
4305
Matt Wagantall8b38f942011-08-02 18:23:18 -07004306static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004307{
4308 int ret = 0;
4309 u32 clk_sel;
4310 struct measure_sel *p;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004311 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004312 unsigned long flags;
4313
4314 if (!parent)
4315 return -EINVAL;
4316
4317 p = find_measure_sel(parent);
4318 if (!p)
4319 return -EINVAL;
4320
4321 spin_lock_irqsave(&local_clock_reg_lock, flags);
4322
Matt Wagantall8b38f942011-08-02 18:23:18 -07004323 /*
4324 * Program the test vector, measurement period (sample_ticks)
4325 * and scaling multiplier.
4326 */
4327 clk->sample_ticks = 0x10000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004328 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004329 clk->multiplier = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004330 switch (p->test_vector >> TEST_TYPE_SHIFT) {
4331 case TEST_TYPE_PER_LS:
4332 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
4333 break;
4334 case TEST_TYPE_PER_HS:
4335 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
4336 break;
4337 case TEST_TYPE_MM_LS:
4338 writel_relaxed(0x4030D97, CLK_TEST_REG);
4339 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
4340 break;
4341 case TEST_TYPE_MM_HS:
4342 writel_relaxed(0x402B800, CLK_TEST_REG);
4343 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
4344 break;
4345 case TEST_TYPE_LPA:
4346 writel_relaxed(0x4030D98, CLK_TEST_REG);
4347 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
4348 LCC_CLK_LS_DEBUG_CFG_REG);
4349 break;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004350 case TEST_TYPE_CPUL2:
4351 writel_relaxed(0x4030400, CLK_TEST_REG);
4352 writel_relaxed(0x80|BVAL(5, 3, clk_sel), GCC_APCS_CLK_DIAG);
4353 clk->sample_ticks = 0x4000;
4354 clk->multiplier = 2;
4355 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004356 default:
4357 ret = -EPERM;
4358 }
4359 /* Make sure test vector is set before starting measurements. */
4360 mb();
4361
4362 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4363
4364 return ret;
4365}
4366
4367/* Sample clock for 'ticks' reference clock ticks. */
4368static u32 run_measurement(unsigned ticks)
4369{
4370 /* Stop counters and set the XO4 counter start value. */
4371 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
4372 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
4373
4374 /* Wait for timer to become ready. */
4375 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
4376 cpu_relax();
4377
4378 /* Run measurement and wait for completion. */
4379 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
4380 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
4381 cpu_relax();
4382
4383 /* Stop counters. */
4384 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
4385
4386 /* Return measured ticks. */
4387 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
4388}
4389
4390
4391/* Perform a hardware rate measurement for a given clock.
4392 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall8b38f942011-08-02 18:23:18 -07004393static unsigned measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004394{
4395 unsigned long flags;
4396 u32 pdm_reg_backup, ringosc_reg_backup;
4397 u64 raw_count_short, raw_count_full;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004398 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004399 unsigned ret;
4400
4401 spin_lock_irqsave(&local_clock_reg_lock, flags);
4402
4403 /* Enable CXO/4 and RINGOSC branch and root. */
4404 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
4405 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
4406 writel_relaxed(0x2898, PDM_CLK_NS_REG);
4407 writel_relaxed(0xA00, RINGOSC_NS_REG);
4408
4409 /*
4410 * The ring oscillator counter will not reset if the measured clock
4411 * is not running. To detect this, run a short measurement before
4412 * the full measurement. If the raw results of the two are the same
4413 * then the clock must be off.
4414 */
4415
4416 /* Run a short measurement. (~1 ms) */
4417 raw_count_short = run_measurement(0x1000);
4418 /* Run a full measurement. (~14 ms) */
Matt Wagantall8b38f942011-08-02 18:23:18 -07004419 raw_count_full = run_measurement(clk->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004420
4421 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
4422 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
4423
4424 /* Return 0 if the clock is off. */
4425 if (raw_count_full == raw_count_short)
4426 ret = 0;
4427 else {
4428 /* Compute rate in Hz. */
4429 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004430 do_div(raw_count_full, ((clk->sample_ticks * 10) + 35));
4431 ret = (raw_count_full * clk->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004432 }
4433
4434 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07004435 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004436 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4437
4438 return ret;
4439}
4440#else /* !CONFIG_DEBUG_FS */
4441static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
4442{
4443 return -EINVAL;
4444}
4445
4446static unsigned measure_clk_get_rate(struct clk *clk)
4447{
4448 return 0;
4449}
4450#endif /* CONFIG_DEBUG_FS */
4451
4452static struct clk_ops measure_clk_ops = {
4453 .set_parent = measure_clk_set_parent,
4454 .get_rate = measure_clk_get_rate,
4455 .is_local = local_clk_is_local,
4456};
4457
Matt Wagantall8b38f942011-08-02 18:23:18 -07004458static struct measure_clk measure_clk = {
4459 .c = {
4460 .dbg_name = "measure_clk",
4461 .ops = &measure_clk_ops,
4462 CLK_INIT(measure_clk.c),
4463 },
4464 .multiplier = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004465};
4466
Stephen Boyd94625ef2011-07-12 17:06:01 -07004467static struct clk_lookup msm_clocks_8960_v1[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004468 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
4469 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
4470 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
4471 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Matt Wagantall8b38f942011-08-02 18:23:18 -07004472 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004473
4474 CLK_LOOKUP("afab_clk", afab_clk.c, NULL),
4475 CLK_LOOKUP("afab_a_clk", afab_a_clk.c, NULL),
4476 CLK_LOOKUP("cfpb_clk", cfpb_clk.c, NULL),
4477 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, NULL),
4478 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
4479 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
4480 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
4481 CLK_LOOKUP("ebi1_a_clk", ebi1_a_clk.c, NULL),
4482 CLK_LOOKUP("mmfab_clk", mmfab_clk.c, NULL),
4483 CLK_LOOKUP("mmfab_a_clk", mmfab_a_clk.c, NULL),
4484 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
4485 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, NULL),
4486 CLK_LOOKUP("sfab_clk", sfab_clk.c, NULL),
4487 CLK_LOOKUP("sfab_a_clk", sfab_a_clk.c, NULL),
4488 CLK_LOOKUP("sfpb_clk", sfpb_clk.c, NULL),
4489 CLK_LOOKUP("sfpb_a_clk", sfpb_a_clk.c, NULL),
4490
Matt Wagantalle2522372011-08-17 14:52:21 -07004491 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
4492 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
4493 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
4494 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
4495 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
4496 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
4497 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
4498 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, NULL),
4499 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, NULL),
4500 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, NULL),
4501 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, NULL),
4502 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004503 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004504 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004505 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
4506 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004507 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
4508 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
4509 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
4510 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, NULL),
4511 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004512 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004513 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004514 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004515 CLK_LOOKUP("pdm_clk", pdm_clk.c, NULL),
4516 CLK_LOOKUP("pmem_clk", pmem_clk.c, NULL),
4517 CLK_LOOKUP("prng_clk", prng_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07004518 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
4519 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
4520 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
4521 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
4522 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004523 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
4524 CLK_LOOKUP("tsif_ref_clk", tsif_ref_clk.c, NULL),
4525 CLK_LOOKUP("tssc_clk", tssc_clk.c, NULL),
4526 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
4527 CLK_LOOKUP("usb_phy_clk", usb_phy0_clk.c, NULL),
4528 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
4529 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
4530 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
4531 CLK_LOOKUP("usb_fs_clk", usb_fs2_xcvr_clk.c, NULL),
4532 CLK_LOOKUP("usb_fs_sys_clk", usb_fs2_sys_clk.c, NULL),
4533 CLK_LOOKUP("usb_fs_src_clk", usb_fs2_src_clk.c, NULL),
4534 CLK_LOOKUP("ce_pclk", ce1_p_clk.c, NULL),
4535 CLK_LOOKUP("ce_clk", ce1_core_clk.c, NULL),
4536 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004537 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004538 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004539 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
4540 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07004541 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
4542 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004543 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
4544 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, NULL),
4545 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004546 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004547 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004548 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.12"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004549 CLK_LOOKUP("tsif_pclk", tsif_p_clk.c, NULL),
4550 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
4551 CLK_LOOKUP("usb_fs_pclk", usb_fs2_p_clk.c, NULL),
4552 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07004553 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
4554 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
4555 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
4556 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
4557 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07004558 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
4559 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004560 CLK_LOOKUP("pmic_arb_pclk", pmic_arb0_p_clk.c, NULL),
4561 CLK_LOOKUP("pmic_arb_pclk", pmic_arb1_p_clk.c, NULL),
4562 CLK_LOOKUP("pmic_ssbi2", pmic_ssbi2_clk.c, NULL),
4563 CLK_LOOKUP("rpm_msg_ram_pclk", rpm_msg_ram_p_clk.c, NULL),
4564 CLK_LOOKUP("amp_clk", amp_clk.c, NULL),
4565 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
4566 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
4567 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_imx074.0"),
4568 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_ov2720.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07004569 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004570 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, NULL),
4571 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
4572 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07004573 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004574 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_camera_ov2720.0"),
4575 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
4576 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
4577 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07004578 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004579 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov2720.0"),
4580 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, NULL),
4581 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
4582 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07004583 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004584 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_camera_ov2720.0"),
4585 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, NULL),
4586 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, NULL),
4587 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
4588 CLK_LOOKUP("csi0phy_timer_clk", csi0phy_timer_clk.c, NULL),
4589 CLK_LOOKUP("csi1phy_timer_clk", csi1phy_timer_clk.c, NULL),
4590 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
4591 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
4592 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
4593 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
4594 CLK_LOOKUP("gfx2d0_clk", gfx2d0_clk.c, NULL),
4595 CLK_LOOKUP("gfx2d1_clk", gfx2d1_clk.c, NULL),
4596 CLK_LOOKUP("gfx3d_clk", gfx3d_clk.c, NULL),
4597 CLK_LOOKUP("ijpeg_axi_clk", ijpeg_axi_clk.c, NULL),
4598 CLK_LOOKUP("imem_axi_clk", imem_axi_clk.c, NULL),
4599 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
4600 CLK_LOOKUP("jpegd_clk", jpegd_clk.c, NULL),
4601 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
4602 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
4603 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004604 CLK_LOOKUP("qdss_pclk", qdss_p_clk.c, NULL),
4605 CLK_LOOKUP("qdss_at_clk", qdss_at_clk.c, NULL),
4606 CLK_LOOKUP("qdss_pclkdbg_clk", qdss_pclkdbg_clk.c, NULL),
4607 CLK_LOOKUP("qdss_traceclkin_clk", qdss_traceclkin_clk.c, NULL),
4608 CLK_LOOKUP("qdss_tsctr_clk", qdss_tsctr_clk.c, NULL),
4609 CLK_LOOKUP("qdss_stm_clk", qdss_stm_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004610 CLK_LOOKUP("rot_clk", rot_clk.c, NULL),
4611 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
4612 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
4613 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
4614 CLK_LOOKUP("vcodec_clk", vcodec_clk.c, NULL),
4615 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
4616 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
4617 CLK_LOOKUP("hdmi_app_clk", hdmi_app_clk.c, NULL),
4618 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
4619 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantallc23eee92011-08-16 23:06:52 -07004620 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004621 CLK_LOOKUP("vfe_axi_clk", vfe_axi_clk.c, NULL),
4622 CLK_LOOKUP("mdp_axi_clk", mdp_axi_clk.c, NULL),
4623 CLK_LOOKUP("rot_axi_clk", rot_axi_clk.c, NULL),
4624 CLK_LOOKUP("vcodec_axi_clk", vcodec_axi_clk.c, NULL),
4625 CLK_LOOKUP("vcodec_axi_a_clk", vcodec_axi_a_clk.c, NULL),
4626 CLK_LOOKUP("vcodec_axi_b_clk", vcodec_axi_b_clk.c, NULL),
4627 CLK_LOOKUP("vpe_axi_clk", vpe_axi_clk.c, NULL),
4628 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Matt Wagantallc23eee92011-08-16 23:06:52 -07004629 CLK_LOOKUP("csi_pclk", csi_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004630 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
4631 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
4632 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
4633 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
4634 CLK_LOOKUP("gfx2d0_pclk", gfx2d0_p_clk.c, NULL),
4635 CLK_LOOKUP("gfx2d1_pclk", gfx2d1_p_clk.c, NULL),
4636 CLK_LOOKUP("gfx3d_pclk", gfx3d_p_clk.c, NULL),
4637 CLK_LOOKUP("hdmi_m_pclk", hdmi_m_p_clk.c, NULL),
4638 CLK_LOOKUP("hdmi_s_pclk", hdmi_s_p_clk.c, NULL),
4639 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
4640 CLK_LOOKUP("jpegd_pclk", jpegd_p_clk.c, NULL),
4641 CLK_LOOKUP("imem_pclk", imem_p_clk.c, NULL),
4642 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
4643 CLK_LOOKUP("smmu_pclk", smmu_p_clk.c, NULL),
4644 CLK_LOOKUP("rotator_pclk", rot_p_clk.c, NULL),
4645 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
4646 CLK_LOOKUP("vcodec_pclk", vcodec_p_clk.c, NULL),
4647 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
4648 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
4649 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
4650 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
4651 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
4652 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
4653 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
4654 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
4655 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
4656 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
4657 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
4658 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
4659 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
4660 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
4661 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
4662 CLK_LOOKUP("iommu_clk", jpegd_axi_clk.c, "msm_iommu.0"),
4663 CLK_LOOKUP("iommu_clk", vpe_axi_clk.c, "msm_iommu.1"),
4664 CLK_LOOKUP("iommu_clk", mdp_axi_clk.c, "msm_iommu.2"),
4665 CLK_LOOKUP("iommu_clk", mdp_axi_clk.c, "msm_iommu.3"),
4666 CLK_LOOKUP("iommu_clk", rot_axi_clk.c, "msm_iommu.4"),
4667 CLK_LOOKUP("iommu_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
4668 CLK_LOOKUP("iommu_clk", vfe_axi_clk.c, "msm_iommu.6"),
4669 CLK_LOOKUP("iommu_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
4670 CLK_LOOKUP("iommu_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
4671 CLK_LOOKUP("iommu_clk", gfx3d_clk.c, "msm_iommu.9"),
4672 CLK_LOOKUP("iommu_clk", gfx2d0_clk.c, "msm_iommu.10"),
4673 CLK_LOOKUP("iommu_clk", gfx2d1_clk.c, "msm_iommu.11"),
4674 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
4675 CLK_LOOKUP("dfab_usb_hs_clk", dfab_usb_hs_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07004676 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
4677 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
4678 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
4679 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
4680 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Yan He160633e2011-06-30 12:18:56 -07004681 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004682
4683 CLK_LOOKUP("ebi1_msmbus_clk", ebi1_msmbus_clk.c, NULL),
Matt Wagantalle1a86062011-08-18 17:46:10 -07004684 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Matt Wagantall8b38f942011-08-02 18:23:18 -07004685
4686 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
4687 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
4688 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004689};
4690
Stephen Boyd94625ef2011-07-12 17:06:01 -07004691static struct clk_lookup msm_clocks_8960_v2[] __initdata = {
4692 CLK_LOOKUP("cam_clk", cam2_clk.c, NULL),
4693 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
4694 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
4695 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, NULL),
4696 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, NULL),
4697 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, NULL),
4698 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
4699 CLK_LOOKUP("csi2phy_timer_clk", csi2phy_timer_clk.c, NULL),
4700 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
4701 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
4702 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
4703 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
4704 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
4705};
4706
4707/* Add v2 clocks dynamically at runtime */
4708static struct clk_lookup msm_clocks_8960[ARRAY_SIZE(msm_clocks_8960_v1) +
4709 ARRAY_SIZE(msm_clocks_8960_v2)];
4710
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004711/*
4712 * Miscellaneous clock register initializations
4713 */
4714
4715/* Read, modify, then write-back a register. */
4716static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
4717{
4718 uint32_t regval = readl_relaxed(reg);
4719 regval &= ~mask;
4720 regval |= val;
4721 writel_relaxed(regval, reg);
4722}
4723
4724static void __init reg_init(void)
4725{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004726 /* Deassert MM SW_RESET_ALL signal. */
4727 writel_relaxed(0, SW_RESET_ALL_REG);
4728
4729 /* Initialize MM AHB registers: Enable the FPB clock and disable HW
4730 * gating for all clocks. Also set VFE_AHB's FORCE_CORE_ON bit to
4731 * prevent its memory from being collapsed when the clock is halted.
4732 * The sleep and wake-up delays are set to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07004733 rmwreg(0x00000003, AHB_EN_REG, 0x6C000103);
4734 writel_relaxed(0x000007F9, AHB_EN2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004735
4736 /* Deassert all locally-owned MM AHB resets. */
4737 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
4738
4739 /* Initialize MM AXI registers: Enable HW gating for all clocks that
4740 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
4741 * delays to safe values. */
4742 /* TODO: Enable HW Gating */
Matt Wagantall53d968f2011-07-19 13:22:53 -07004743 rmwreg(0x000007F9, MAXI_EN_REG, 0x0803FFFF);
4744 rmwreg(0x3027FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
4745 rmwreg(0x0027FCFF, MAXI_EN3_REG, 0x003FFFFF);
4746 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
4747 rmwreg(0x000003C7, SAXI_EN_REG, 0x00003FFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004748
4749 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
4750 * memories retain state even when not clocked. Also, set sleep and
4751 * wake-up delays to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07004752 rmwreg(0x00000000, CSI0_CC_REG, 0x00000410);
4753 rmwreg(0x00000000, CSI1_CC_REG, 0x00000410);
4754 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, 0xE0FF0010);
4755 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, 0xE0FF0010);
4756 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, 0xE0FF0010);
4757 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, 0xE0FF0010);
4758 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
4759 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
4760 rmwreg(0x80FF0000, GFX3D_CC_REG, 0xE0FF0010);
4761 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0010);
4762 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0010);
4763 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
4764 rmwreg(0x80FF0000, MDP_LUT_CC_REG, 0xE0FF0010);
4765 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
4766 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
4767 rmwreg(0x000004FF, TV_CC2_REG, 0x000007FF);
4768 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
4769 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FF4010);
Stephen Boyd94625ef2011-07-12 17:06:01 -07004770 rmwreg(0x800000FF, VFE_CC2_REG, 0xE00000FF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07004771 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004772
4773 /* De-assert MM AXI resets to all hardware blocks. */
4774 writel_relaxed(0, SW_RESET_AXI_REG);
4775
4776 /* Deassert all MM core resets. */
4777 writel_relaxed(0, SW_RESET_CORE_REG);
4778
4779 /* Reset 3D core once more, with its clock enabled. This can
4780 * eventually be done as part of the GDFS footswitch driver. */
4781 clk_set_rate(&gfx3d_clk.c, 27000000);
4782 clk_enable(&gfx3d_clk.c);
4783 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
4784 mb();
4785 udelay(5);
4786 writel_relaxed(0, SW_RESET_CORE_REG);
4787 /* Make sure reset is de-asserted before clock is disabled. */
4788 mb();
4789 clk_disable(&gfx3d_clk.c);
4790
4791 /* Enable TSSC and PDM PXO sources. */
4792 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
4793 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
4794
4795 /* Source SLIMBus xo src from slimbus reference clock */
4796 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
4797
4798 /* Source the dsi_byte_clks from the DSI PHY PLLs */
4799 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
4800 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
4801}
4802
4803static int wr_pll_clk_enable(struct clk *clk)
4804{
4805 u32 mode;
4806 unsigned long flags;
4807 struct pll_clk *pll = to_pll_clk(clk);
4808
4809 spin_lock_irqsave(&local_clock_reg_lock, flags);
4810 mode = readl_relaxed(pll->mode_reg);
4811 /* De-assert active-low PLL reset. */
4812 mode |= BIT(2);
4813 writel_relaxed(mode, pll->mode_reg);
4814
4815 /*
4816 * H/W requires a 5us delay between disabling the bypass and
4817 * de-asserting the reset. Delay 10us just to be safe.
4818 */
4819 mb();
4820 udelay(10);
4821
4822 /* Disable PLL bypass mode. */
4823 mode |= BIT(1);
4824 writel_relaxed(mode, pll->mode_reg);
4825
4826 /* Wait until PLL is locked. */
4827 mb();
4828 udelay(60);
4829
4830 /* Enable PLL output. */
4831 mode |= BIT(0);
4832 writel_relaxed(mode, pll->mode_reg);
4833
4834 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4835 return 0;
4836}
4837
Stephen Boyd94625ef2011-07-12 17:06:01 -07004838struct clock_init_data msm8960_clock_init_data __initdata;
4839
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004840/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07004841static void __init msm8960_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004842{
Stephen Boyd94625ef2011-07-12 17:06:01 -07004843 size_t num_lookups = ARRAY_SIZE(msm_clocks_8960_v1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004844 xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8960");
4845 if (IS_ERR(xo_pxo)) {
4846 pr_err("%s: msm_xo_get(PXO) failed.\n", __func__);
4847 BUG();
4848 }
4849 xo_cxo = msm_xo_get(MSM_XO_TCXO_D0, "clock-8960");
4850 if (IS_ERR(xo_cxo)) {
4851 pr_err("%s: msm_xo_get(CXO) failed.\n", __func__);
4852 BUG();
4853 }
4854
Stephen Boyd94625ef2011-07-12 17:06:01 -07004855 memcpy(msm_clocks_8960, msm_clocks_8960_v1, sizeof(msm_clocks_8960_v1));
4856 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
4857 struct clk_freq_tbl **ptr =
4858 (struct clk_freq_tbl **)&gfx3d_clk.freq_tbl;
4859 *ptr = clk_tbl_gfx3d_v2;
4860 memcpy(msm_clocks_8960 + ARRAY_SIZE(msm_clocks_8960_v1),
4861 msm_clocks_8960_v2, sizeof(msm_clocks_8960_v2));
4862 num_lookups = ARRAY_SIZE(msm_clocks_8960);
4863 }
4864 msm8960_clock_init_data.size = num_lookups;
4865
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004866 soc_update_sys_vdd = msm8960_update_sys_vdd;
4867 local_vote_sys_vdd(HIGH);
4868
4869 clk_ops_pll.enable = wr_pll_clk_enable;
4870
4871 /* Initialize clock registers. */
4872 reg_init();
4873
4874 /* Initialize rates for clocks that only support one. */
4875 clk_set_rate(&pdm_clk.c, 27000000);
4876 clk_set_rate(&prng_clk.c, 64000000);
4877 clk_set_rate(&mdp_vsync_clk.c, 27000000);
4878 clk_set_rate(&tsif_ref_clk.c, 105000);
4879 clk_set_rate(&tssc_clk.c, 27000000);
4880 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
4881 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
4882 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
Stephen Boyd94625ef2011-07-12 17:06:01 -07004883 clk_set_rate(&usb_hsic_xcvr_fs_clk.c, 60000000);
4884 clk_set_rate(&usb_hsic_hsic_src_clk.c, 480000000);
4885 clk_set_rate(&usb_hsic_hsio_cal_clk.c, 9000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004886
4887 /*
4888 * The halt status bits for PDM and TSSC may be incorrect at boot.
4889 * Toggle these clocks on and off to refresh them.
4890 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07004891 rcg_clk_enable(&pdm_clk.c);
4892 rcg_clk_disable(&pdm_clk.c);
4893 rcg_clk_enable(&tssc_clk.c);
4894 rcg_clk_disable(&tssc_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004895
4896 if (machine_is_msm8960_sim()) {
4897 clk_set_rate(&sdc1_clk.c, 48000000);
4898 clk_enable(&sdc1_clk.c);
4899 clk_enable(&sdc1_p_clk.c);
4900 clk_set_rate(&sdc3_clk.c, 48000000);
4901 clk_enable(&sdc3_clk.c);
4902 clk_enable(&sdc3_p_clk.c);
4903 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004904}
4905
Stephen Boydbb600ae2011-08-02 20:11:40 -07004906static int __init msm8960_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004907{
4908 return local_unvote_sys_vdd(HIGH);
4909}
Stephen Boydbb600ae2011-08-02 20:11:40 -07004910
4911struct clock_init_data msm8960_clock_init_data __initdata = {
4912 .table = msm_clocks_8960,
4913 .size = ARRAY_SIZE(msm_clocks_8960),
4914 .init = msm8960_clock_init,
4915 .late_init = msm8960_clock_late_init,
4916};