blob: 34f78b7e8dcf1d51788d8591d155c5be801d43c9 [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. */
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700229#define LCC_CLK_HS_DEBUG_CFG_REG REG_LPA(0x00A4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700230#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
231#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
232#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
233#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
234#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
235#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
236#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
237#define LCC_MI2S_MD_REG REG_LPA(0x004C)
238#define LCC_MI2S_NS_REG REG_LPA(0x0048)
239#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
240#define LCC_PCM_MD_REG REG_LPA(0x0058)
241#define LCC_PCM_NS_REG REG_LPA(0x0054)
242#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
243#define LCC_PLL0_STATUS_REG REG_LPA(0x0018)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700244#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
245#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
246#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
247#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
248#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
249#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
250#define LCC_SLIMBUS_NS_REG REG_LPA(0x00CC)
251#define LCC_SLIMBUS_MD_REG REG_LPA(0x00D0)
252#define LCC_SLIMBUS_STATUS_REG REG_LPA(0x00D4)
253#define LCC_AHBEX_BRANCH_CTL_REG REG_LPA(0x00E4)
254
Matt Wagantall8b38f942011-08-02 18:23:18 -0700255#define GCC_APCS_CLK_DIAG REG_GCC(0x001C)
256
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700257/* MUX source input identifiers. */
258#define pxo_to_bb_mux 0
259#define cxo_to_bb_mux pxo_to_bb_mux
260#define pll0_to_bb_mux 2
261#define pll8_to_bb_mux 3
262#define pll6_to_bb_mux 4
263#define gnd_to_bb_mux 5
Stephen Boyd94625ef2011-07-12 17:06:01 -0700264#define pll3_to_bb_mux 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700265#define pxo_to_mm_mux 0
266#define pll1_to_mm_mux 1
267#define pll2_to_mm_mux 1
268#define pll8_to_mm_mux 2
269#define pll0_to_mm_mux 3
270#define gnd_to_mm_mux 4
Stephen Boyd94625ef2011-07-12 17:06:01 -0700271#define pll3_to_mm_mux 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700272#define hdmi_pll_to_mm_mux 3
273#define cxo_to_xo_mux 0
274#define pxo_to_xo_mux 1
275#define gnd_to_xo_mux 3
276#define pxo_to_lpa_mux 0
277#define cxo_to_lpa_mux 1
278#define pll4_to_lpa_mux 2
279#define gnd_to_lpa_mux 6
280
281/* Test Vector Macros */
282#define TEST_TYPE_PER_LS 1
283#define TEST_TYPE_PER_HS 2
284#define TEST_TYPE_MM_LS 3
285#define TEST_TYPE_MM_HS 4
286#define TEST_TYPE_LPA 5
Matt Wagantall8b38f942011-08-02 18:23:18 -0700287#define TEST_TYPE_CPUL2 6
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700288#define TEST_TYPE_LPA_HS 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700289#define TEST_TYPE_SHIFT 24
290#define TEST_CLK_SEL_MASK BM(23, 0)
291#define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s)))
292#define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS)
293#define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS)
294#define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS)
295#define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS)
296#define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA)
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700297#define TEST_LPA_HS(s) TEST_VECTOR((s), TEST_TYPE_LPA_HS)
Matt Wagantall8b38f942011-08-02 18:23:18 -0700298#define TEST_CPUL2(s) TEST_VECTOR((s), TEST_TYPE_CPUL2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700299
300#define MN_MODE_DUAL_EDGE 0x2
301
302/* MD Registers */
303#define MD4(m_lsb, m, n_lsb, n) \
304 (BVAL((m_lsb+3), m_lsb, m) | BVAL((n_lsb+3), n_lsb, ~(n)))
305#define MD8(m_lsb, m, n_lsb, n) \
306 (BVAL((m_lsb+7), m_lsb, m) | BVAL((n_lsb+7), n_lsb, ~(n)))
307#define MD16(m, n) (BVAL(31, 16, m) | BVAL(15, 0, ~(n)))
308
309/* NS Registers */
310#define NS(n_msb, n_lsb, n, m, mde_lsb, d_msb, d_lsb, d, s_msb, s_lsb, s) \
311 (BVAL(n_msb, n_lsb, ~(n-m)) \
312 | (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n)) \
313 | BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
314
315#define NS_MM(n_msb, n_lsb, n, m, d_msb, d_lsb, d, s_msb, s_lsb, s) \
316 (BVAL(n_msb, n_lsb, ~(n-m)) | BVAL(d_msb, d_lsb, (d-1)) \
317 | BVAL(s_msb, s_lsb, s))
318
319#define NS_DIVSRC(d_msb , d_lsb, d, s_msb, s_lsb, s) \
320 (BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
321
322#define NS_DIV(d_msb , d_lsb, d) \
323 BVAL(d_msb, d_lsb, (d-1))
324
325#define NS_SRC_SEL(s_msb, s_lsb, s) \
326 BVAL(s_msb, s_lsb, s)
327
328#define NS_MND_BANKED4(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
329 (BVAL((n0_lsb+3), n0_lsb, ~(n-m)) \
330 | BVAL((n1_lsb+3), n1_lsb, ~(n-m)) \
331 | BVAL((s0_lsb+2), s0_lsb, s) \
332 | BVAL((s1_lsb+2), s1_lsb, s))
333
334#define NS_MND_BANKED8(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
335 (BVAL((n0_lsb+7), n0_lsb, ~(n-m)) \
336 | BVAL((n1_lsb+7), n1_lsb, ~(n-m)) \
337 | BVAL((s0_lsb+2), s0_lsb, s) \
338 | BVAL((s1_lsb+2), s1_lsb, s))
339
340#define NS_DIVSRC_BANKED(d0_msb, d0_lsb, d1_msb, d1_lsb, d, \
341 s0_msb, s0_lsb, s1_msb, s1_lsb, s) \
342 (BVAL(d0_msb, d0_lsb, (d-1)) | BVAL(d1_msb, d1_lsb, (d-1)) \
343 | BVAL(s0_msb, s0_lsb, s) \
344 | BVAL(s1_msb, s1_lsb, s))
345
346/* CC Registers */
347#define CC(mde_lsb, n) (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n))
348#define CC_BANKED(mde0_lsb, mde1_lsb, n) \
349 ((BVAL((mde0_lsb+1), mde0_lsb, MN_MODE_DUAL_EDGE) \
350 | BVAL((mde1_lsb+1), mde1_lsb, MN_MODE_DUAL_EDGE)) \
351 * !!(n))
352
353struct pll_rate {
354 const uint32_t l_val;
355 const uint32_t m_val;
356 const uint32_t n_val;
357 const uint32_t vco;
358 const uint32_t post_div;
359 const uint32_t i_bits;
360};
361#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
362
363/*
364 * Clock Descriptions
365 */
366
367static struct msm_xo_voter *xo_pxo, *xo_cxo;
368
369static int pxo_clk_enable(struct clk *clk)
370{
371 return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON);
372}
373
374static void pxo_clk_disable(struct clk *clk)
375{
376 msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF);
377}
378
379static struct clk_ops clk_ops_pxo = {
380 .enable = pxo_clk_enable,
381 .disable = pxo_clk_disable,
382 .get_rate = fixed_clk_get_rate,
383 .is_local = local_clk_is_local,
384};
385
386static struct fixed_clk pxo_clk = {
387 .rate = 27000000,
388 .c = {
389 .dbg_name = "pxo_clk",
390 .ops = &clk_ops_pxo,
391 CLK_INIT(pxo_clk.c),
392 },
393};
394
395static int cxo_clk_enable(struct clk *clk)
396{
397 return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON);
398}
399
400static void cxo_clk_disable(struct clk *clk)
401{
402 msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF);
403}
404
405static struct clk_ops clk_ops_cxo = {
406 .enable = cxo_clk_enable,
407 .disable = cxo_clk_disable,
408 .get_rate = fixed_clk_get_rate,
409 .is_local = local_clk_is_local,
410};
411
412static struct fixed_clk cxo_clk = {
413 .rate = 19200000,
414 .c = {
415 .dbg_name = "cxo_clk",
416 .ops = &clk_ops_cxo,
417 CLK_INIT(cxo_clk.c),
418 },
419};
420
421static struct pll_clk pll2_clk = {
422 .rate = 800000000,
423 .mode_reg = MM_PLL1_MODE_REG,
424 .parent = &pxo_clk.c,
425 .c = {
426 .dbg_name = "pll2_clk",
427 .ops = &clk_ops_pll,
428 CLK_INIT(pll2_clk.c),
429 },
430};
431
Stephen Boyd94625ef2011-07-12 17:06:01 -0700432static struct pll_clk pll3_clk = {
433 .rate = 1200000000,
434 .mode_reg = BB_MMCC_PLL2_MODE_REG,
435 .parent = &pxo_clk.c,
436 .c = {
437 .dbg_name = "pll3_clk",
438 .ops = &clk_ops_pll,
439 CLK_INIT(pll3_clk.c),
440 },
441};
442
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700443static struct pll_vote_clk pll4_clk = {
444 .rate = 393216000,
445 .en_reg = BB_PLL_ENA_SC0_REG,
446 .en_mask = BIT(4),
447 .status_reg = LCC_PLL0_STATUS_REG,
448 .parent = &pxo_clk.c,
449 .c = {
450 .dbg_name = "pll4_clk",
451 .ops = &clk_ops_pll_vote,
452 CLK_INIT(pll4_clk.c),
453 },
454};
455
456static struct pll_vote_clk pll8_clk = {
457 .rate = 384000000,
458 .en_reg = BB_PLL_ENA_SC0_REG,
459 .en_mask = BIT(8),
460 .status_reg = BB_PLL8_STATUS_REG,
461 .parent = &pxo_clk.c,
462 .c = {
463 .dbg_name = "pll8_clk",
464 .ops = &clk_ops_pll_vote,
465 CLK_INIT(pll8_clk.c),
466 },
467};
468
Stephen Boyd94625ef2011-07-12 17:06:01 -0700469static struct pll_vote_clk pll14_clk = {
470 .rate = 480000000,
471 .en_reg = BB_PLL_ENA_SC0_REG,
472 .en_mask = BIT(14),
473 .status_reg = BB_PLL14_STATUS_REG,
474 .parent = &pxo_clk.c,
475 .c = {
476 .dbg_name = "pll14_clk",
477 .ops = &clk_ops_pll_vote,
478 CLK_INIT(pll14_clk.c),
479 },
480};
481
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700482/*
483 * SoC-specific functions required by clock-local driver
484 */
485
486/* Update the sys_vdd voltage given a level. */
487static int msm8960_update_sys_vdd(enum sys_vdd_level level)
488{
489 static const int vdd_uv[] = {
490 [NONE...LOW] = 945000,
491 [NOMINAL] = 1050000,
492 [HIGH] = 1150000,
493 };
494
495 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
496 vdd_uv[level], vdd_uv[HIGH], 1);
497}
498
499static int soc_clk_reset(struct clk *clk, enum clk_reset_action action)
500{
501 return branch_reset(&to_rcg_clk(clk)->b, action);
502}
503
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700504static struct clk_ops clk_ops_rcg_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700505 .enable = rcg_clk_enable,
506 .disable = rcg_clk_disable,
507 .auto_off = rcg_clk_auto_off,
Matt Wagantall53d968f2011-07-19 13:22:53 -0700508 .handoff = rcg_clk_handoff,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700509 .set_rate = rcg_clk_set_rate,
510 .set_min_rate = rcg_clk_set_min_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700511 .get_rate = rcg_clk_get_rate,
512 .list_rate = rcg_clk_list_rate,
513 .is_enabled = rcg_clk_is_enabled,
514 .round_rate = rcg_clk_round_rate,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700515 .reset = soc_clk_reset,
516 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700517 .get_parent = rcg_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700518};
519
520static struct clk_ops clk_ops_branch = {
521 .enable = branch_clk_enable,
522 .disable = branch_clk_disable,
523 .auto_off = branch_clk_auto_off,
524 .is_enabled = branch_clk_is_enabled,
525 .reset = branch_clk_reset,
526 .is_local = local_clk_is_local,
527 .get_parent = branch_clk_get_parent,
528 .set_parent = branch_clk_set_parent,
529};
530
531static struct clk_ops clk_ops_reset = {
532 .reset = branch_clk_reset,
533 .is_local = local_clk_is_local,
534};
535
536/* AXI Interfaces */
537static struct branch_clk gmem_axi_clk = {
538 .b = {
539 .ctl_reg = MAXI_EN_REG,
540 .en_mask = BIT(24),
541 .halt_reg = DBG_BUS_VEC_E_REG,
542 .halt_bit = 6,
543 },
544 .c = {
545 .dbg_name = "gmem_axi_clk",
546 .ops = &clk_ops_branch,
547 CLK_INIT(gmem_axi_clk.c),
548 },
549};
550
551static struct branch_clk ijpeg_axi_clk = {
552 .b = {
553 .ctl_reg = MAXI_EN_REG,
554 .en_mask = BIT(21),
555 .reset_reg = SW_RESET_AXI_REG,
556 .reset_mask = BIT(14),
557 .halt_reg = DBG_BUS_VEC_E_REG,
558 .halt_bit = 4,
559 },
560 .c = {
561 .dbg_name = "ijpeg_axi_clk",
562 .ops = &clk_ops_branch,
563 CLK_INIT(ijpeg_axi_clk.c),
564 },
565};
566
567static struct branch_clk imem_axi_clk = {
568 .b = {
569 .ctl_reg = MAXI_EN_REG,
570 .en_mask = BIT(22),
571 .reset_reg = SW_RESET_CORE_REG,
572 .reset_mask = BIT(10),
573 .halt_reg = DBG_BUS_VEC_E_REG,
574 .halt_bit = 7,
575 },
576 .c = {
577 .dbg_name = "imem_axi_clk",
578 .ops = &clk_ops_branch,
579 CLK_INIT(imem_axi_clk.c),
580 },
581};
582
583static struct branch_clk jpegd_axi_clk = {
584 .b = {
585 .ctl_reg = MAXI_EN_REG,
586 .en_mask = BIT(25),
587 .halt_reg = DBG_BUS_VEC_E_REG,
588 .halt_bit = 5,
589 },
590 .c = {
591 .dbg_name = "jpegd_axi_clk",
592 .ops = &clk_ops_branch,
593 CLK_INIT(jpegd_axi_clk.c),
594 },
595};
596
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700597static struct branch_clk vcodec_axi_b_clk = {
598 .b = {
599 .ctl_reg = MAXI_EN4_REG,
600 .en_mask = BIT(23),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700601 .halt_reg = DBG_BUS_VEC_I_REG,
602 .halt_bit = 25,
603 },
604 .c = {
605 .dbg_name = "vcodec_axi_b_clk",
606 .ops = &clk_ops_branch,
607 CLK_INIT(vcodec_axi_b_clk.c),
608 },
609};
610
Matt Wagantall91f42702011-07-14 12:01:15 -0700611static struct branch_clk vcodec_axi_a_clk = {
612 .b = {
613 .ctl_reg = MAXI_EN4_REG,
614 .en_mask = BIT(25),
Matt Wagantall91f42702011-07-14 12:01:15 -0700615 .halt_reg = DBG_BUS_VEC_I_REG,
616 .halt_bit = 26,
617 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700618 .c = {
619 .dbg_name = "vcodec_axi_a_clk",
620 .ops = &clk_ops_branch,
621 CLK_INIT(vcodec_axi_a_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700622 .depends = &vcodec_axi_b_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700623 },
624};
625
626static struct branch_clk vcodec_axi_clk = {
627 .b = {
628 .ctl_reg = MAXI_EN_REG,
629 .en_mask = BIT(19),
630 .reset_reg = SW_RESET_AXI_REG,
Matt Wagantallfe2ee052011-07-14 13:33:44 -0700631 .reset_mask = BIT(4)|BIT(5)|BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700632 .halt_reg = DBG_BUS_VEC_E_REG,
633 .halt_bit = 3,
634 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700635 .c = {
636 .dbg_name = "vcodec_axi_clk",
637 .ops = &clk_ops_branch,
638 CLK_INIT(vcodec_axi_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700639 .depends = &vcodec_axi_a_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700640 },
641};
642
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700643static struct branch_clk vfe_axi_clk = {
644 .b = {
645 .ctl_reg = MAXI_EN_REG,
646 .en_mask = BIT(18),
647 .reset_reg = SW_RESET_AXI_REG,
648 .reset_mask = BIT(9),
649 .halt_reg = DBG_BUS_VEC_E_REG,
650 .halt_bit = 0,
651 },
652 .c = {
653 .dbg_name = "vfe_axi_clk",
654 .ops = &clk_ops_branch,
655 CLK_INIT(vfe_axi_clk.c),
656 },
657};
658
659static struct branch_clk mdp_axi_clk = {
660 .b = {
661 .ctl_reg = MAXI_EN_REG,
662 .en_mask = BIT(23),
663 .reset_reg = SW_RESET_AXI_REG,
664 .reset_mask = BIT(13),
665 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700666 .halt_bit = 8,
667 },
668 .c = {
669 .dbg_name = "mdp_axi_clk",
670 .ops = &clk_ops_branch,
671 CLK_INIT(mdp_axi_clk.c),
672 },
673};
674
675static struct branch_clk rot_axi_clk = {
676 .b = {
677 .ctl_reg = MAXI_EN2_REG,
678 .en_mask = BIT(24),
679 .reset_reg = SW_RESET_AXI_REG,
680 .reset_mask = BIT(6),
681 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700682 .halt_bit = 2,
683 },
684 .c = {
685 .dbg_name = "rot_axi_clk",
686 .ops = &clk_ops_branch,
687 CLK_INIT(rot_axi_clk.c),
688 },
689};
690
691static struct branch_clk vpe_axi_clk = {
692 .b = {
693 .ctl_reg = MAXI_EN2_REG,
694 .en_mask = BIT(26),
695 .reset_reg = SW_RESET_AXI_REG,
696 .reset_mask = BIT(15),
697 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700698 .halt_bit = 1,
699 },
700 .c = {
701 .dbg_name = "vpe_axi_clk",
702 .ops = &clk_ops_branch,
703 CLK_INIT(vpe_axi_clk.c),
704 },
705};
706
707/* AHB Interfaces */
708static struct branch_clk amp_p_clk = {
709 .b = {
710 .ctl_reg = AHB_EN_REG,
711 .en_mask = BIT(24),
712 .halt_reg = DBG_BUS_VEC_F_REG,
713 .halt_bit = 18,
714 },
715 .c = {
716 .dbg_name = "amp_p_clk",
717 .ops = &clk_ops_branch,
718 CLK_INIT(amp_p_clk.c),
719 },
720};
721
Matt Wagantallc23eee92011-08-16 23:06:52 -0700722static struct branch_clk csi_p_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700723 .b = {
724 .ctl_reg = AHB_EN_REG,
725 .en_mask = BIT(7),
726 .reset_reg = SW_RESET_AHB_REG,
727 .reset_mask = BIT(17),
728 .halt_reg = DBG_BUS_VEC_F_REG,
729 .halt_bit = 16,
730 },
731 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -0700732 .dbg_name = "csi_p_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700733 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -0700734 CLK_INIT(csi_p_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700735 },
736};
737
738static struct branch_clk dsi1_m_p_clk = {
739 .b = {
740 .ctl_reg = AHB_EN_REG,
741 .en_mask = BIT(9),
742 .reset_reg = SW_RESET_AHB_REG,
743 .reset_mask = BIT(6),
744 .halt_reg = DBG_BUS_VEC_F_REG,
745 .halt_bit = 19,
746 },
747 .c = {
748 .dbg_name = "dsi1_m_p_clk",
749 .ops = &clk_ops_branch,
750 CLK_INIT(dsi1_m_p_clk.c),
751 },
752};
753
754static struct branch_clk dsi1_s_p_clk = {
755 .b = {
756 .ctl_reg = AHB_EN_REG,
757 .en_mask = BIT(18),
758 .reset_reg = SW_RESET_AHB_REG,
759 .reset_mask = BIT(5),
760 .halt_reg = DBG_BUS_VEC_F_REG,
761 .halt_bit = 21,
762 },
763 .c = {
764 .dbg_name = "dsi1_s_p_clk",
765 .ops = &clk_ops_branch,
766 CLK_INIT(dsi1_s_p_clk.c),
767 },
768};
769
770static struct branch_clk dsi2_m_p_clk = {
771 .b = {
772 .ctl_reg = AHB_EN_REG,
773 .en_mask = BIT(17),
774 .reset_reg = SW_RESET_AHB2_REG,
775 .reset_mask = BIT(1),
776 .halt_reg = DBG_BUS_VEC_E_REG,
777 .halt_bit = 18,
778 },
779 .c = {
780 .dbg_name = "dsi2_m_p_clk",
781 .ops = &clk_ops_branch,
782 CLK_INIT(dsi2_m_p_clk.c),
783 },
784};
785
786static struct branch_clk dsi2_s_p_clk = {
787 .b = {
788 .ctl_reg = AHB_EN_REG,
789 .en_mask = BIT(22),
790 .reset_reg = SW_RESET_AHB2_REG,
791 .reset_mask = BIT(0),
792 .halt_reg = DBG_BUS_VEC_F_REG,
793 .halt_bit = 20,
794 },
795 .c = {
796 .dbg_name = "dsi2_s_p_clk",
797 .ops = &clk_ops_branch,
798 CLK_INIT(dsi2_s_p_clk.c),
799 },
800};
801
802static struct branch_clk gfx2d0_p_clk = {
803 .b = {
804 .ctl_reg = AHB_EN_REG,
805 .en_mask = BIT(19),
806 .reset_reg = SW_RESET_AHB_REG,
807 .reset_mask = BIT(12),
808 .halt_reg = DBG_BUS_VEC_F_REG,
809 .halt_bit = 2,
810 },
811 .c = {
812 .dbg_name = "gfx2d0_p_clk",
813 .ops = &clk_ops_branch,
814 CLK_INIT(gfx2d0_p_clk.c),
815 },
816};
817
818static struct branch_clk gfx2d1_p_clk = {
819 .b = {
820 .ctl_reg = AHB_EN_REG,
821 .en_mask = BIT(2),
822 .reset_reg = SW_RESET_AHB_REG,
823 .reset_mask = BIT(11),
824 .halt_reg = DBG_BUS_VEC_F_REG,
825 .halt_bit = 3,
826 },
827 .c = {
828 .dbg_name = "gfx2d1_p_clk",
829 .ops = &clk_ops_branch,
830 CLK_INIT(gfx2d1_p_clk.c),
831 },
832};
833
834static struct branch_clk gfx3d_p_clk = {
835 .b = {
836 .ctl_reg = AHB_EN_REG,
837 .en_mask = BIT(3),
838 .reset_reg = SW_RESET_AHB_REG,
839 .reset_mask = BIT(10),
840 .halt_reg = DBG_BUS_VEC_F_REG,
841 .halt_bit = 4,
842 },
843 .c = {
844 .dbg_name = "gfx3d_p_clk",
845 .ops = &clk_ops_branch,
846 CLK_INIT(gfx3d_p_clk.c),
847 },
848};
849
850static struct branch_clk hdmi_m_p_clk = {
851 .b = {
852 .ctl_reg = AHB_EN_REG,
853 .en_mask = BIT(14),
854 .reset_reg = SW_RESET_AHB_REG,
855 .reset_mask = BIT(9),
856 .halt_reg = DBG_BUS_VEC_F_REG,
857 .halt_bit = 5,
858 },
859 .c = {
860 .dbg_name = "hdmi_m_p_clk",
861 .ops = &clk_ops_branch,
862 CLK_INIT(hdmi_m_p_clk.c),
863 },
864};
865
866static struct branch_clk hdmi_s_p_clk = {
867 .b = {
868 .ctl_reg = AHB_EN_REG,
869 .en_mask = BIT(4),
870 .reset_reg = SW_RESET_AHB_REG,
871 .reset_mask = BIT(9),
872 .halt_reg = DBG_BUS_VEC_F_REG,
873 .halt_bit = 6,
874 },
875 .c = {
876 .dbg_name = "hdmi_s_p_clk",
877 .ops = &clk_ops_branch,
878 CLK_INIT(hdmi_s_p_clk.c),
879 },
880};
881
882static struct branch_clk ijpeg_p_clk = {
883 .b = {
884 .ctl_reg = AHB_EN_REG,
885 .en_mask = BIT(5),
886 .reset_reg = SW_RESET_AHB_REG,
887 .reset_mask = BIT(7),
888 .halt_reg = DBG_BUS_VEC_F_REG,
889 .halt_bit = 9,
890 },
891 .c = {
892 .dbg_name = "ijpeg_p_clk",
893 .ops = &clk_ops_branch,
894 CLK_INIT(ijpeg_p_clk.c),
895 },
896};
897
898static struct branch_clk imem_p_clk = {
899 .b = {
900 .ctl_reg = AHB_EN_REG,
901 .en_mask = BIT(6),
902 .reset_reg = SW_RESET_AHB_REG,
903 .reset_mask = BIT(8),
904 .halt_reg = DBG_BUS_VEC_F_REG,
905 .halt_bit = 10,
906 },
907 .c = {
908 .dbg_name = "imem_p_clk",
909 .ops = &clk_ops_branch,
910 CLK_INIT(imem_p_clk.c),
911 },
912};
913
914static struct branch_clk jpegd_p_clk = {
915 .b = {
916 .ctl_reg = AHB_EN_REG,
917 .en_mask = BIT(21),
918 .reset_reg = SW_RESET_AHB_REG,
919 .reset_mask = BIT(4),
920 .halt_reg = DBG_BUS_VEC_F_REG,
921 .halt_bit = 7,
922 },
923 .c = {
924 .dbg_name = "jpegd_p_clk",
925 .ops = &clk_ops_branch,
926 CLK_INIT(jpegd_p_clk.c),
927 },
928};
929
930static struct branch_clk mdp_p_clk = {
931 .b = {
932 .ctl_reg = AHB_EN_REG,
933 .en_mask = BIT(10),
934 .reset_reg = SW_RESET_AHB_REG,
935 .reset_mask = BIT(3),
936 .halt_reg = DBG_BUS_VEC_F_REG,
937 .halt_bit = 11,
938 },
939 .c = {
940 .dbg_name = "mdp_p_clk",
941 .ops = &clk_ops_branch,
942 CLK_INIT(mdp_p_clk.c),
943 },
944};
945
946static struct branch_clk rot_p_clk = {
947 .b = {
948 .ctl_reg = AHB_EN_REG,
949 .en_mask = BIT(12),
950 .reset_reg = SW_RESET_AHB_REG,
951 .reset_mask = BIT(2),
952 .halt_reg = DBG_BUS_VEC_F_REG,
953 .halt_bit = 13,
954 },
955 .c = {
956 .dbg_name = "rot_p_clk",
957 .ops = &clk_ops_branch,
958 CLK_INIT(rot_p_clk.c),
959 },
960};
961
962static struct branch_clk smmu_p_clk = {
963 .b = {
964 .ctl_reg = AHB_EN_REG,
965 .en_mask = BIT(15),
966 .halt_reg = DBG_BUS_VEC_F_REG,
967 .halt_bit = 22,
968 },
969 .c = {
970 .dbg_name = "smmu_p_clk",
971 .ops = &clk_ops_branch,
972 CLK_INIT(smmu_p_clk.c),
973 },
974};
975
976static struct branch_clk tv_enc_p_clk = {
977 .b = {
978 .ctl_reg = AHB_EN_REG,
979 .en_mask = BIT(25),
980 .reset_reg = SW_RESET_AHB_REG,
981 .reset_mask = BIT(15),
982 .halt_reg = DBG_BUS_VEC_F_REG,
983 .halt_bit = 23,
984 },
985 .c = {
986 .dbg_name = "tv_enc_p_clk",
987 .ops = &clk_ops_branch,
988 CLK_INIT(tv_enc_p_clk.c),
989 },
990};
991
992static struct branch_clk vcodec_p_clk = {
993 .b = {
994 .ctl_reg = AHB_EN_REG,
995 .en_mask = BIT(11),
996 .reset_reg = SW_RESET_AHB_REG,
997 .reset_mask = BIT(1),
998 .halt_reg = DBG_BUS_VEC_F_REG,
999 .halt_bit = 12,
1000 },
1001 .c = {
1002 .dbg_name = "vcodec_p_clk",
1003 .ops = &clk_ops_branch,
1004 CLK_INIT(vcodec_p_clk.c),
1005 },
1006};
1007
1008static struct branch_clk vfe_p_clk = {
1009 .b = {
1010 .ctl_reg = AHB_EN_REG,
1011 .en_mask = BIT(13),
1012 .reset_reg = SW_RESET_AHB_REG,
1013 .reset_mask = BIT(0),
1014 .halt_reg = DBG_BUS_VEC_F_REG,
1015 .halt_bit = 14,
1016 },
1017 .c = {
1018 .dbg_name = "vfe_p_clk",
1019 .ops = &clk_ops_branch,
1020 CLK_INIT(vfe_p_clk.c),
1021 },
1022};
1023
1024static struct branch_clk vpe_p_clk = {
1025 .b = {
1026 .ctl_reg = AHB_EN_REG,
1027 .en_mask = BIT(16),
1028 .reset_reg = SW_RESET_AHB_REG,
1029 .reset_mask = BIT(14),
1030 .halt_reg = DBG_BUS_VEC_F_REG,
1031 .halt_bit = 15,
1032 },
1033 .c = {
1034 .dbg_name = "vpe_p_clk",
1035 .ops = &clk_ops_branch,
1036 CLK_INIT(vpe_p_clk.c),
1037 },
1038};
1039
1040/*
1041 * Peripheral Clocks
1042 */
1043#define CLK_GSBI_UART(i, n, h_r, h_b) \
1044 struct rcg_clk i##_clk = { \
1045 .b = { \
1046 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
1047 .en_mask = BIT(9), \
1048 .reset_reg = GSBIn_RESET_REG(n), \
1049 .reset_mask = BIT(0), \
1050 .halt_reg = h_r, \
1051 .halt_bit = h_b, \
1052 }, \
1053 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
1054 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
1055 .root_en_mask = BIT(11), \
1056 .ns_mask = (BM(31, 16) | BM(6, 0)), \
1057 .set_rate = set_rate_mnd, \
1058 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001059 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001060 .c = { \
1061 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001062 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001063 CLK_INIT(i##_clk.c), \
1064 }, \
1065 }
1066#define F_GSBI_UART(f, s, d, m, n, v) \
1067 { \
1068 .freq_hz = f, \
1069 .src_clk = &s##_clk.c, \
1070 .md_val = MD16(m, n), \
1071 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1072 .mnd_en_mask = BIT(8) * !!(n), \
1073 .sys_vdd = v, \
1074 }
1075static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
1076 F_GSBI_UART( 0, gnd, 1, 0, 0, NONE),
1077 F_GSBI_UART( 1843200, pll8, 1, 3, 625, LOW),
1078 F_GSBI_UART( 3686400, pll8, 1, 6, 625, LOW),
1079 F_GSBI_UART( 7372800, pll8, 1, 12, 625, LOW),
1080 F_GSBI_UART(14745600, pll8, 1, 24, 625, LOW),
1081 F_GSBI_UART(16000000, pll8, 4, 1, 6, LOW),
1082 F_GSBI_UART(24000000, pll8, 4, 1, 4, LOW),
1083 F_GSBI_UART(32000000, pll8, 4, 1, 3, LOW),
1084 F_GSBI_UART(40000000, pll8, 1, 5, 48, NOMINAL),
1085 F_GSBI_UART(46400000, pll8, 1, 29, 240, NOMINAL),
1086 F_GSBI_UART(48000000, pll8, 4, 1, 2, NOMINAL),
1087 F_GSBI_UART(51200000, pll8, 1, 2, 15, NOMINAL),
1088 F_GSBI_UART(56000000, pll8, 1, 7, 48, NOMINAL),
1089 F_GSBI_UART(58982400, pll8, 1, 96, 625, NOMINAL),
1090 F_GSBI_UART(64000000, pll8, 2, 1, 3, NOMINAL),
1091 F_END
1092};
1093
1094static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1095static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1096static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1097static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1098static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1099static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1100static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1101static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1102static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1103static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1104static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1105static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1106
1107#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1108 struct rcg_clk i##_clk = { \
1109 .b = { \
1110 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1111 .en_mask = BIT(9), \
1112 .reset_reg = GSBIn_RESET_REG(n), \
1113 .reset_mask = BIT(0), \
1114 .halt_reg = h_r, \
1115 .halt_bit = h_b, \
1116 }, \
1117 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1118 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1119 .root_en_mask = BIT(11), \
1120 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1121 .set_rate = set_rate_mnd, \
1122 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001123 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001124 .c = { \
1125 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001126 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001127 CLK_INIT(i##_clk.c), \
1128 }, \
1129 }
1130#define F_GSBI_QUP(f, s, d, m, n, v) \
1131 { \
1132 .freq_hz = f, \
1133 .src_clk = &s##_clk.c, \
1134 .md_val = MD8(16, m, 0, n), \
1135 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1136 .mnd_en_mask = BIT(8) * !!(n), \
1137 .sys_vdd = v, \
1138 }
1139static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
1140 F_GSBI_QUP( 0, gnd, 1, 0, 0, NONE),
1141 F_GSBI_QUP( 1100000, pxo, 1, 2, 49, LOW),
1142 F_GSBI_QUP( 5400000, pxo, 1, 1, 5, LOW),
1143 F_GSBI_QUP(10800000, pxo, 1, 2, 5, LOW),
1144 F_GSBI_QUP(15060000, pll8, 1, 2, 51, LOW),
1145 F_GSBI_QUP(24000000, pll8, 4, 1, 4, LOW),
1146 F_GSBI_QUP(25600000, pll8, 1, 1, 15, NOMINAL),
1147 F_GSBI_QUP(27000000, pxo, 1, 0, 0, NOMINAL),
1148 F_GSBI_QUP(48000000, pll8, 4, 1, 2, NOMINAL),
1149 F_GSBI_QUP(51200000, pll8, 1, 2, 15, NOMINAL),
1150 F_END
1151};
1152
1153static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1154static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1155static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1156static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1157static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1158static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1159static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1160static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1161static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1162static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1163static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1164static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1165
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001166#define F_QDSS(f, s, d, v) \
1167 { \
1168 .freq_hz = f, \
1169 .src_clk = &s##_clk.c, \
1170 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
1171 .sys_vdd = v, \
1172 }
1173static struct clk_freq_tbl clk_tbl_qdss[] = {
1174 F_QDSS(128000000, pll8, 3, LOW),
1175 F_QDSS(300000000, pll3, 4, NOMINAL),
1176 F_END
1177};
1178
1179struct qdss_bank {
1180 const u32 bank_sel_mask;
1181 void __iomem *const ns_reg;
1182 const u32 ns_mask;
1183};
1184
1185static void set_rate_qdss(struct rcg_clk *clk, struct clk_freq_tbl *nf)
1186{
1187 const struct qdss_bank *bank = clk->bank_info;
1188 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1189
1190 /* Switch to bank 0 (always sourced from PXO) */
1191 reg = readl_relaxed(clk->ns_reg);
1192 reg &= ~bank_sel_mask;
1193 writel_relaxed(reg, clk->ns_reg);
1194 /*
1195 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1196 * MUX to fully switch sources.
1197 */
1198 mb();
1199 udelay(1);
1200
1201 /* Set source and divider */
1202 reg = readl_relaxed(bank->ns_reg);
1203 reg &= ~bank->ns_mask;
1204 reg |= nf->ns_val;
1205 writel_relaxed(reg, bank->ns_reg);
1206
1207 /* Switch to reprogrammed bank */
1208 reg = readl_relaxed(clk->ns_reg);
1209 reg |= bank_sel_mask;
1210 writel_relaxed(reg, clk->ns_reg);
1211 /*
1212 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1213 * MUX to fully switch sources.
1214 */
1215 mb();
1216 udelay(1);
1217}
1218
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001219static int qdss_clk_enable(struct clk *c)
1220{
1221 struct rcg_clk *clk = to_rcg_clk(c);
1222 const struct qdss_bank *bank = clk->bank_info;
1223 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1224 int ret;
1225
1226 /* Switch to bank 1 */
1227 reg = readl_relaxed(clk->ns_reg);
1228 reg |= bank_sel_mask;
1229 writel_relaxed(reg, clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001230
1231 ret = rcg_clk_enable(c);
1232 if (ret) {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001233 /* Switch to bank 0 */
1234 reg &= ~bank_sel_mask;
1235 writel_relaxed(reg, clk->ns_reg);
1236 }
1237 return ret;
1238}
1239
1240static void qdss_clk_disable(struct clk *c)
1241{
1242 struct rcg_clk *clk = to_rcg_clk(c);
1243 const struct qdss_bank *bank = clk->bank_info;
1244 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1245
1246 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001247 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001248 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001249 reg &= ~bank_sel_mask;
1250 writel_relaxed(reg, clk->ns_reg);
1251}
1252
1253static void qdss_clk_auto_off(struct clk *c)
1254{
1255 struct rcg_clk *clk = to_rcg_clk(c);
1256 const struct qdss_bank *bank = clk->bank_info;
1257 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1258
1259 rcg_clk_auto_off(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001260 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001261 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001262 reg &= ~bank_sel_mask;
1263 writel_relaxed(reg, clk->ns_reg);
1264}
1265
1266static struct clk_ops clk_ops_qdss = {
1267 .enable = qdss_clk_enable,
1268 .disable = qdss_clk_disable,
1269 .auto_off = qdss_clk_auto_off,
1270 .set_rate = rcg_clk_set_rate,
1271 .set_min_rate = rcg_clk_set_min_rate,
1272 .get_rate = rcg_clk_get_rate,
1273 .list_rate = rcg_clk_list_rate,
1274 .is_enabled = rcg_clk_is_enabled,
1275 .round_rate = rcg_clk_round_rate,
1276 .reset = soc_clk_reset,
1277 .is_local = local_clk_is_local,
1278 .get_parent = rcg_clk_get_parent,
1279};
1280
1281static struct qdss_bank bdiv_info_qdss = {
1282 .bank_sel_mask = BIT(0),
1283 .ns_reg = QDSS_AT_CLK_SRC1_NS_REG,
1284 .ns_mask = BM(6, 0),
1285};
1286
1287static struct rcg_clk qdss_at_clk = {
1288 .b = {
1289 .ctl_reg = QDSS_AT_CLK_NS_REG,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001290 .reset_reg = QDSS_RESETS_REG,
1291 .reset_mask = BIT(0),
Stephen Boydfcfd4dd2011-09-13 12:49:57 -07001292 .halt_check = NOCHECK,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001293 },
1294 .ns_reg = QDSS_AT_CLK_SRC_CTL_REG,
1295 .set_rate = set_rate_qdss,
1296 .freq_tbl = clk_tbl_qdss,
1297 .bank_info = &bdiv_info_qdss,
1298 .current_freq = &rcg_dummy_freq,
1299 .c = {
1300 .dbg_name = "qdss_at_clk",
1301 .ops = &clk_ops_qdss,
1302 CLK_INIT(qdss_at_clk.c),
1303 },
1304};
1305
1306static struct branch_clk qdss_pclkdbg_clk = {
1307 .b = {
1308 .ctl_reg = QDSS_AT_CLK_NS_REG,
1309 .en_mask = BIT(4),
1310 .reset_reg = QDSS_RESETS_REG,
1311 .reset_mask = BIT(0),
1312 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1313 .halt_bit = 9,
1314 .halt_check = HALT_VOTED
1315 },
1316 .parent = &qdss_at_clk.c,
1317 .c = {
1318 .dbg_name = "qdss_pclkdbg_clk",
1319 .ops = &clk_ops_branch,
1320 CLK_INIT(qdss_pclkdbg_clk.c),
1321 },
1322};
1323
1324static struct qdss_bank bdiv_info_qdss_trace = {
1325 .bank_sel_mask = BIT(0),
1326 .ns_reg = QDSS_TRACECLKIN_CLK_SRC1_NS_REG,
1327 .ns_mask = BM(6, 0),
1328};
1329
1330static struct rcg_clk qdss_traceclkin_clk = {
1331 .b = {
1332 .ctl_reg = QDSS_TRACECLKIN_CTL_REG,
1333 .en_mask = BIT(4),
1334 .reset_reg = QDSS_RESETS_REG,
1335 .reset_mask = BIT(0),
1336 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1337 .halt_bit = 8,
1338 .halt_check = HALT_VOTED,
1339 },
1340 .ns_reg = QDSS_TRACECLKIN_CLK_SRC_CTL_REG,
1341 .set_rate = set_rate_qdss,
1342 .freq_tbl = clk_tbl_qdss,
1343 .bank_info = &bdiv_info_qdss_trace,
1344 .current_freq = &rcg_dummy_freq,
1345 .c = {
1346 .dbg_name = "qdss_traceclkin_clk",
1347 .ops = &clk_ops_qdss,
1348 CLK_INIT(qdss_traceclkin_clk.c),
1349 },
1350};
1351
1352static struct clk_freq_tbl clk_tbl_qdss_tsctr[] = {
1353 F_QDSS(200000000, pll3, 6, LOW),
1354 F_QDSS(400000000, pll3, 3, NOMINAL),
1355 F_END
1356};
1357
1358static struct qdss_bank bdiv_info_qdss_tsctr = {
1359 .bank_sel_mask = BIT(0),
1360 .ns_reg = QDSS_TSCTR_CLK_SRC1_NS_REG,
1361 .ns_mask = BM(6, 0),
1362};
1363
1364static struct rcg_clk qdss_tsctr_clk = {
1365 .b = {
1366 .ctl_reg = QDSS_TSCTR_CTL_REG,
1367 .en_mask = BIT(4),
1368 .reset_reg = QDSS_RESETS_REG,
1369 .reset_mask = BIT(3),
1370 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1371 .halt_bit = 7,
1372 .halt_check = HALT_VOTED,
1373 },
1374 .ns_reg = QDSS_TSCTR_CLK_SRC_CTL_REG,
1375 .set_rate = set_rate_qdss,
1376 .freq_tbl = clk_tbl_qdss_tsctr,
1377 .bank_info = &bdiv_info_qdss_tsctr,
1378 .current_freq = &rcg_dummy_freq,
1379 .c = {
1380 .dbg_name = "qdss_tsctr_clk",
1381 .ops = &clk_ops_qdss,
1382 CLK_INIT(qdss_tsctr_clk.c),
1383 },
1384};
1385
1386static struct branch_clk qdss_stm_clk = {
1387 .b = {
1388 .ctl_reg = QDSS_STM_CLK_CTL_REG,
1389 .en_mask = BIT(4),
1390 .reset_reg = QDSS_RESETS_REG,
1391 .reset_mask = BIT(1),
1392 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
1393 .halt_bit = 20,
1394 .halt_check = HALT_VOTED,
1395 },
1396 .c = {
1397 .dbg_name = "qdss_stm_clk",
1398 .ops = &clk_ops_branch,
1399 CLK_INIT(qdss_stm_clk.c),
1400 },
1401};
1402
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001403#define F_PDM(f, s, d, v) \
1404 { \
1405 .freq_hz = f, \
1406 .src_clk = &s##_clk.c, \
1407 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
1408 .sys_vdd = v, \
1409 }
1410static struct clk_freq_tbl clk_tbl_pdm[] = {
1411 F_PDM( 0, gnd, 1, NONE),
1412 F_PDM(27000000, pxo, 1, LOW),
1413 F_END
1414};
1415
1416static struct rcg_clk pdm_clk = {
1417 .b = {
1418 .ctl_reg = PDM_CLK_NS_REG,
1419 .en_mask = BIT(9),
1420 .reset_reg = PDM_CLK_NS_REG,
1421 .reset_mask = BIT(12),
1422 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1423 .halt_bit = 3,
1424 },
1425 .ns_reg = PDM_CLK_NS_REG,
1426 .root_en_mask = BIT(11),
1427 .ns_mask = BM(1, 0),
1428 .set_rate = set_rate_nop,
1429 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001430 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001431 .c = {
1432 .dbg_name = "pdm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001433 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001434 CLK_INIT(pdm_clk.c),
1435 },
1436};
1437
1438static struct branch_clk pmem_clk = {
1439 .b = {
1440 .ctl_reg = PMEM_ACLK_CTL_REG,
1441 .en_mask = BIT(4),
1442 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1443 .halt_bit = 20,
1444 },
1445 .c = {
1446 .dbg_name = "pmem_clk",
1447 .ops = &clk_ops_branch,
1448 CLK_INIT(pmem_clk.c),
1449 },
1450};
1451
1452#define F_PRNG(f, s, v) \
1453 { \
1454 .freq_hz = f, \
1455 .src_clk = &s##_clk.c, \
1456 .sys_vdd = v, \
1457 }
1458static struct clk_freq_tbl clk_tbl_prng[] = {
1459 F_PRNG(64000000, pll8, NOMINAL),
1460 F_END
1461};
1462
1463static struct rcg_clk prng_clk = {
1464 .b = {
1465 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1466 .en_mask = BIT(10),
1467 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1468 .halt_check = HALT_VOTED,
1469 .halt_bit = 10,
1470 },
1471 .set_rate = set_rate_nop,
1472 .freq_tbl = clk_tbl_prng,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001473 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001474 .c = {
1475 .dbg_name = "prng_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001476 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001477 CLK_INIT(prng_clk.c),
1478 },
1479};
1480
Stephen Boyda78a7402011-08-02 11:23:39 -07001481#define CLK_SDC(name, n, h_b, f_table) \
1482 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001483 .b = { \
1484 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1485 .en_mask = BIT(9), \
1486 .reset_reg = SDCn_RESET_REG(n), \
1487 .reset_mask = BIT(0), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001488 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001489 .halt_bit = h_b, \
1490 }, \
1491 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1492 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1493 .root_en_mask = BIT(11), \
1494 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1495 .set_rate = set_rate_mnd, \
Stephen Boyda78a7402011-08-02 11:23:39 -07001496 .freq_tbl = f_table, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001497 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001498 .c = { \
Stephen Boyda78a7402011-08-02 11:23:39 -07001499 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001500 .ops = &clk_ops_rcg_8960, \
Stephen Boyda78a7402011-08-02 11:23:39 -07001501 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001502 }, \
1503 }
1504#define F_SDC(f, s, d, m, n, v) \
1505 { \
1506 .freq_hz = f, \
1507 .src_clk = &s##_clk.c, \
1508 .md_val = MD8(16, m, 0, n), \
1509 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1510 .mnd_en_mask = BIT(8) * !!(n), \
1511 .sys_vdd = v, \
1512 }
Stephen Boyda78a7402011-08-02 11:23:39 -07001513static struct clk_freq_tbl clk_tbl_sdc1_2[] = {
1514 F_SDC( 0, gnd, 1, 0, 0, NONE),
1515 F_SDC( 144000, pxo, 3, 2, 125, LOW),
1516 F_SDC( 400000, pll8, 4, 1, 240, LOW),
1517 F_SDC( 16000000, pll8, 4, 1, 6, LOW),
1518 F_SDC( 17070000, pll8, 1, 2, 45, LOW),
1519 F_SDC( 20210000, pll8, 1, 1, 19, LOW),
1520 F_SDC( 24000000, pll8, 4, 1, 4, LOW),
1521 F_SDC( 48000000, pll8, 4, 1, 2, LOW),
1522 F_SDC( 64000000, pll8, 3, 1, 2, NOMINAL),
1523 F_SDC( 96000000, pll8, 4, 0, 0, NOMINAL),
1524 F_END
1525};
1526
1527static CLK_SDC(sdc1_clk, 1, 6, clk_tbl_sdc1_2);
1528static CLK_SDC(sdc2_clk, 2, 5, clk_tbl_sdc1_2);
1529
1530static struct clk_freq_tbl clk_tbl_sdc3[] = {
1531 F_SDC( 0, gnd, 1, 0, 0, NONE),
1532 F_SDC( 144000, pxo, 3, 2, 125, LOW),
1533 F_SDC( 400000, pll8, 4, 1, 240, LOW),
1534 F_SDC( 16000000, pll8, 4, 1, 6, LOW),
1535 F_SDC( 17070000, pll8, 1, 2, 45, LOW),
1536 F_SDC( 20210000, pll8, 1, 1, 19, LOW),
1537 F_SDC( 24000000, pll8, 4, 1, 4, LOW),
1538 F_SDC( 48000000, pll8, 4, 1, 2, LOW),
1539 F_SDC( 64000000, pll8, 3, 1, 2, LOW),
1540 F_SDC( 96000000, pll8, 4, 0, 0, LOW),
1541 F_SDC(192000000, pll8, 2, 0, 0, NOMINAL),
1542 F_END
1543};
1544
1545static CLK_SDC(sdc3_clk, 3, 4, clk_tbl_sdc3);
1546
1547static struct clk_freq_tbl clk_tbl_sdc4_5[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001548 F_SDC( 0, gnd, 1, 0, 0, NONE),
1549 F_SDC( 144000, pxo, 3, 2, 125, LOW),
1550 F_SDC( 400000, pll8, 4, 1, 240, LOW),
1551 F_SDC( 16000000, pll8, 4, 1, 6, LOW),
1552 F_SDC( 17070000, pll8, 1, 2, 45, LOW),
1553 F_SDC( 20210000, pll8, 1, 1, 19, LOW),
1554 F_SDC( 24000000, pll8, 4, 1, 4, LOW),
1555 F_SDC( 48000000, pll8, 4, 1, 2, NOMINAL),
1556 F_SDC( 64000000, pll8, 3, 1, 2, NOMINAL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001557 F_END
1558};
1559
Stephen Boyda78a7402011-08-02 11:23:39 -07001560static CLK_SDC(sdc4_clk, 4, 3, clk_tbl_sdc4_5);
1561static CLK_SDC(sdc5_clk, 5, 2, clk_tbl_sdc4_5);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001562
1563#define F_TSIF_REF(f, s, d, m, n, v) \
1564 { \
1565 .freq_hz = f, \
1566 .src_clk = &s##_clk.c, \
1567 .md_val = MD16(m, n), \
1568 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1569 .mnd_en_mask = BIT(8) * !!(n), \
1570 .sys_vdd = v, \
1571 }
1572static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
1573 F_TSIF_REF( 0, gnd, 1, 0, 0, NONE),
1574 F_TSIF_REF(105000, pxo, 1, 1, 256, LOW),
1575 F_END
1576};
1577
1578static struct rcg_clk tsif_ref_clk = {
1579 .b = {
1580 .ctl_reg = TSIF_REF_CLK_NS_REG,
1581 .en_mask = BIT(9),
1582 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1583 .halt_bit = 5,
1584 },
1585 .ns_reg = TSIF_REF_CLK_NS_REG,
1586 .md_reg = TSIF_REF_CLK_MD_REG,
1587 .root_en_mask = BIT(11),
1588 .ns_mask = (BM(31, 16) | BM(6, 0)),
1589 .set_rate = set_rate_mnd,
1590 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001591 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001592 .c = {
1593 .dbg_name = "tsif_ref_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001594 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001595 CLK_INIT(tsif_ref_clk.c),
1596 },
1597};
1598
1599#define F_TSSC(f, s, v) \
1600 { \
1601 .freq_hz = f, \
1602 .src_clk = &s##_clk.c, \
1603 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
1604 .sys_vdd = v, \
1605 }
1606static struct clk_freq_tbl clk_tbl_tssc[] = {
1607 F_TSSC( 0, gnd, NONE),
1608 F_TSSC(27000000, pxo, LOW),
1609 F_END
1610};
1611
1612static struct rcg_clk tssc_clk = {
1613 .b = {
1614 .ctl_reg = TSSC_CLK_CTL_REG,
1615 .en_mask = BIT(4),
1616 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1617 .halt_bit = 4,
1618 },
1619 .ns_reg = TSSC_CLK_CTL_REG,
1620 .ns_mask = BM(1, 0),
1621 .set_rate = set_rate_nop,
1622 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001623 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001624 .c = {
1625 .dbg_name = "tssc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001626 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001627 CLK_INIT(tssc_clk.c),
1628 },
1629};
1630
1631#define F_USB(f, s, d, m, n, v) \
1632 { \
1633 .freq_hz = f, \
1634 .src_clk = &s##_clk.c, \
1635 .md_val = MD8(16, m, 0, n), \
1636 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1637 .mnd_en_mask = BIT(8) * !!(n), \
1638 .sys_vdd = v, \
1639 }
1640static struct clk_freq_tbl clk_tbl_usb[] = {
1641 F_USB( 0, gnd, 1, 0, 0, NONE),
1642 F_USB(60000000, pll8, 1, 5, 32, NOMINAL),
1643 F_END
1644};
1645
1646static struct rcg_clk usb_hs1_xcvr_clk = {
1647 .b = {
1648 .ctl_reg = USB_HS1_XCVR_FS_CLK_NS_REG,
1649 .en_mask = BIT(9),
1650 .reset_reg = USB_HS1_RESET_REG,
1651 .reset_mask = BIT(0),
1652 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1653 .halt_bit = 0,
1654 },
1655 .ns_reg = USB_HS1_XCVR_FS_CLK_NS_REG,
1656 .md_reg = USB_HS1_XCVR_FS_CLK_MD_REG,
1657 .root_en_mask = BIT(11),
1658 .ns_mask = (BM(23, 16) | BM(6, 0)),
1659 .set_rate = set_rate_mnd,
1660 .freq_tbl = clk_tbl_usb,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001661 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001662 .c = {
1663 .dbg_name = "usb_hs1_xcvr_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001664 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001665 CLK_INIT(usb_hs1_xcvr_clk.c),
1666 },
1667};
1668
Stephen Boyd94625ef2011-07-12 17:06:01 -07001669static struct clk_freq_tbl clk_tbl_usb_hsic[] = {
1670 F_USB( 0, gnd, 1, 0, 0, NONE),
1671 F_USB(60000000, pll8, 1, 5, 32, LOW),
1672 F_END
1673};
1674
1675static struct rcg_clk usb_hsic_xcvr_fs_clk = {
1676 .b = {
1677 .ctl_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1678 .en_mask = BIT(9),
1679 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1680 .halt_bit = 26,
1681 },
1682 .ns_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1683 .md_reg = USB_HSIC_XCVR_FS_CLK_MD_REG,
1684 .root_en_mask = BIT(11),
1685 .ns_mask = (BM(23, 16) | BM(6, 0)),
1686 .set_rate = set_rate_mnd,
1687 .freq_tbl = clk_tbl_usb_hsic,
1688 .current_freq = &rcg_dummy_freq,
1689 .c = {
1690 .dbg_name = "usb_hsic_xcvr_fs_clk",
1691 .ops = &clk_ops_rcg_8960,
1692 CLK_INIT(usb_hsic_xcvr_fs_clk.c),
1693 },
1694};
1695
1696static struct branch_clk usb_hsic_system_clk = {
1697 .b = {
1698 .ctl_reg = USB_HSIC_SYSTEM_CLK_CTL_REG,
1699 .en_mask = BIT(4),
1700 .reset_reg = USB_HSIC_RESET_REG,
1701 .reset_mask = BIT(0),
1702 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1703 .halt_bit = 24,
1704 },
1705 .parent = &usb_hsic_xcvr_fs_clk.c,
1706 .c = {
1707 .dbg_name = "usb_hsic_system_clk",
1708 .ops = &clk_ops_branch,
1709 CLK_INIT(usb_hsic_system_clk.c),
1710 },
1711};
1712
1713#define F_USB_HSIC(f, s, v) \
1714 { \
1715 .freq_hz = f, \
1716 .src_clk = &s##_clk.c, \
1717 .sys_vdd = v, \
1718 }
1719static struct clk_freq_tbl clk_tbl_usb2_hsic[] = {
1720 F_USB_HSIC(480000000, pll14, LOW),
1721 F_END
1722};
1723
1724static struct rcg_clk usb_hsic_hsic_src_clk = {
1725 .b = {
1726 .ctl_reg = USB_HSIC_HSIC_CLK_SRC_CTL_REG,
1727 .halt_check = NOCHECK,
1728 },
1729 .root_en_mask = BIT(0),
1730 .set_rate = set_rate_nop,
1731 .freq_tbl = clk_tbl_usb2_hsic,
1732 .current_freq = &rcg_dummy_freq,
1733 .c = {
1734 .dbg_name = "usb_hsic_hsic_src_clk",
1735 .ops = &clk_ops_rcg_8960,
1736 CLK_INIT(usb_hsic_hsic_src_clk.c),
1737 },
1738};
1739
1740static struct branch_clk usb_hsic_hsic_clk = {
1741 .b = {
1742 .ctl_reg = USB_HSIC_HSIC_CLK_CTL_REG,
1743 .en_mask = BIT(0),
1744 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1745 .halt_bit = 19,
1746 },
1747 .parent = &usb_hsic_hsic_src_clk.c,
1748 .c = {
1749 .dbg_name = "usb_hsic_hsic_clk",
1750 .ops = &clk_ops_branch,
1751 CLK_INIT(usb_hsic_hsic_clk.c),
1752 },
1753};
1754
1755#define F_USB_HSIO_CAL(f, s, v) \
1756 { \
1757 .freq_hz = f, \
1758 .src_clk = &s##_clk.c, \
1759 .sys_vdd = v, \
1760 }
1761static struct clk_freq_tbl clk_tbl_usb_hsio_cal[] = {
1762 F_USB_HSIO_CAL(9000000, pxo, LOW),
1763 F_END
1764};
1765
1766static struct rcg_clk usb_hsic_hsio_cal_clk = {
1767 .b = {
1768 .ctl_reg = USB_HSIC_HSIO_CAL_CLK_CTL_REG,
1769 .en_mask = BIT(0),
1770 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1771 .halt_bit = 23,
1772 },
1773 .set_rate = set_rate_nop,
1774 .freq_tbl = clk_tbl_usb_hsio_cal,
1775 .current_freq = &rcg_dummy_freq,
1776 .c = {
1777 .dbg_name = "usb_hsic_hsio_cal_clk",
1778 .ops = &clk_ops_branch,
1779 CLK_INIT(usb_hsic_hsio_cal_clk.c),
1780 },
1781};
1782
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001783static struct branch_clk usb_phy0_clk = {
1784 .b = {
1785 .reset_reg = USB_PHY0_RESET_REG,
1786 .reset_mask = BIT(0),
1787 },
1788 .c = {
1789 .dbg_name = "usb_phy0_clk",
1790 .ops = &clk_ops_reset,
1791 CLK_INIT(usb_phy0_clk.c),
1792 },
1793};
1794
1795#define CLK_USB_FS(i, n) \
1796 struct rcg_clk i##_clk = { \
1797 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1798 .b = { \
1799 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1800 .halt_check = NOCHECK, \
1801 }, \
1802 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
1803 .root_en_mask = BIT(11), \
1804 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1805 .set_rate = set_rate_mnd, \
1806 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001807 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001808 .c = { \
1809 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001810 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001811 CLK_INIT(i##_clk.c), \
1812 }, \
1813 }
1814
1815static CLK_USB_FS(usb_fs1_src, 1);
1816static struct branch_clk usb_fs1_xcvr_clk = {
1817 .b = {
1818 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
1819 .en_mask = BIT(9),
1820 .reset_reg = USB_FSn_RESET_REG(1),
1821 .reset_mask = BIT(1),
1822 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1823 .halt_bit = 15,
1824 },
1825 .parent = &usb_fs1_src_clk.c,
1826 .c = {
1827 .dbg_name = "usb_fs1_xcvr_clk",
1828 .ops = &clk_ops_branch,
1829 CLK_INIT(usb_fs1_xcvr_clk.c),
1830 },
1831};
1832
1833static struct branch_clk usb_fs1_sys_clk = {
1834 .b = {
1835 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
1836 .en_mask = BIT(4),
1837 .reset_reg = USB_FSn_RESET_REG(1),
1838 .reset_mask = BIT(0),
1839 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1840 .halt_bit = 16,
1841 },
1842 .parent = &usb_fs1_src_clk.c,
1843 .c = {
1844 .dbg_name = "usb_fs1_sys_clk",
1845 .ops = &clk_ops_branch,
1846 CLK_INIT(usb_fs1_sys_clk.c),
1847 },
1848};
1849
1850static CLK_USB_FS(usb_fs2_src, 2);
1851static struct branch_clk usb_fs2_xcvr_clk = {
1852 .b = {
1853 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
1854 .en_mask = BIT(9),
1855 .reset_reg = USB_FSn_RESET_REG(2),
1856 .reset_mask = BIT(1),
1857 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1858 .halt_bit = 12,
1859 },
1860 .parent = &usb_fs2_src_clk.c,
1861 .c = {
1862 .dbg_name = "usb_fs2_xcvr_clk",
1863 .ops = &clk_ops_branch,
1864 CLK_INIT(usb_fs2_xcvr_clk.c),
1865 },
1866};
1867
1868static struct branch_clk usb_fs2_sys_clk = {
1869 .b = {
1870 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
1871 .en_mask = BIT(4),
1872 .reset_reg = USB_FSn_RESET_REG(2),
1873 .reset_mask = BIT(0),
1874 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1875 .halt_bit = 13,
1876 },
1877 .parent = &usb_fs2_src_clk.c,
1878 .c = {
1879 .dbg_name = "usb_fs2_sys_clk",
1880 .ops = &clk_ops_branch,
1881 CLK_INIT(usb_fs2_sys_clk.c),
1882 },
1883};
1884
1885/* Fast Peripheral Bus Clocks */
1886static struct branch_clk ce1_core_clk = {
1887 .b = {
1888 .ctl_reg = CE1_CORE_CLK_CTL_REG,
1889 .en_mask = BIT(4),
1890 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1891 .halt_bit = 27,
1892 },
1893 .c = {
1894 .dbg_name = "ce1_core_clk",
1895 .ops = &clk_ops_branch,
1896 CLK_INIT(ce1_core_clk.c),
1897 },
1898};
1899static struct branch_clk ce1_p_clk = {
1900 .b = {
1901 .ctl_reg = CE1_HCLK_CTL_REG,
1902 .en_mask = BIT(4),
1903 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1904 .halt_bit = 1,
1905 },
1906 .c = {
1907 .dbg_name = "ce1_p_clk",
1908 .ops = &clk_ops_branch,
1909 CLK_INIT(ce1_p_clk.c),
1910 },
1911};
1912
1913static struct branch_clk dma_bam_p_clk = {
1914 .b = {
1915 .ctl_reg = DMA_BAM_HCLK_CTL,
1916 .en_mask = BIT(4),
1917 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1918 .halt_bit = 12,
1919 },
1920 .c = {
1921 .dbg_name = "dma_bam_p_clk",
1922 .ops = &clk_ops_branch,
1923 CLK_INIT(dma_bam_p_clk.c),
1924 },
1925};
1926
1927static struct branch_clk gsbi1_p_clk = {
1928 .b = {
1929 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
1930 .en_mask = BIT(4),
1931 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1932 .halt_bit = 11,
1933 },
1934 .c = {
1935 .dbg_name = "gsbi1_p_clk",
1936 .ops = &clk_ops_branch,
1937 CLK_INIT(gsbi1_p_clk.c),
1938 },
1939};
1940
1941static struct branch_clk gsbi2_p_clk = {
1942 .b = {
1943 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
1944 .en_mask = BIT(4),
1945 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1946 .halt_bit = 7,
1947 },
1948 .c = {
1949 .dbg_name = "gsbi2_p_clk",
1950 .ops = &clk_ops_branch,
1951 CLK_INIT(gsbi2_p_clk.c),
1952 },
1953};
1954
1955static struct branch_clk gsbi3_p_clk = {
1956 .b = {
1957 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
1958 .en_mask = BIT(4),
1959 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1960 .halt_bit = 3,
1961 },
1962 .c = {
1963 .dbg_name = "gsbi3_p_clk",
1964 .ops = &clk_ops_branch,
1965 CLK_INIT(gsbi3_p_clk.c),
1966 },
1967};
1968
1969static struct branch_clk gsbi4_p_clk = {
1970 .b = {
1971 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
1972 .en_mask = BIT(4),
1973 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1974 .halt_bit = 27,
1975 },
1976 .c = {
1977 .dbg_name = "gsbi4_p_clk",
1978 .ops = &clk_ops_branch,
1979 CLK_INIT(gsbi4_p_clk.c),
1980 },
1981};
1982
1983static struct branch_clk gsbi5_p_clk = {
1984 .b = {
1985 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
1986 .en_mask = BIT(4),
1987 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
1988 .halt_bit = 23,
1989 },
1990 .c = {
1991 .dbg_name = "gsbi5_p_clk",
1992 .ops = &clk_ops_branch,
1993 CLK_INIT(gsbi5_p_clk.c),
1994 },
1995};
1996
1997static struct branch_clk gsbi6_p_clk = {
1998 .b = {
1999 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
2000 .en_mask = BIT(4),
2001 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2002 .halt_bit = 19,
2003 },
2004 .c = {
2005 .dbg_name = "gsbi6_p_clk",
2006 .ops = &clk_ops_branch,
2007 CLK_INIT(gsbi6_p_clk.c),
2008 },
2009};
2010
2011static struct branch_clk gsbi7_p_clk = {
2012 .b = {
2013 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
2014 .en_mask = BIT(4),
2015 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2016 .halt_bit = 15,
2017 },
2018 .c = {
2019 .dbg_name = "gsbi7_p_clk",
2020 .ops = &clk_ops_branch,
2021 CLK_INIT(gsbi7_p_clk.c),
2022 },
2023};
2024
2025static struct branch_clk gsbi8_p_clk = {
2026 .b = {
2027 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
2028 .en_mask = BIT(4),
2029 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2030 .halt_bit = 11,
2031 },
2032 .c = {
2033 .dbg_name = "gsbi8_p_clk",
2034 .ops = &clk_ops_branch,
2035 CLK_INIT(gsbi8_p_clk.c),
2036 },
2037};
2038
2039static struct branch_clk gsbi9_p_clk = {
2040 .b = {
2041 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
2042 .en_mask = BIT(4),
2043 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2044 .halt_bit = 7,
2045 },
2046 .c = {
2047 .dbg_name = "gsbi9_p_clk",
2048 .ops = &clk_ops_branch,
2049 CLK_INIT(gsbi9_p_clk.c),
2050 },
2051};
2052
2053static struct branch_clk gsbi10_p_clk = {
2054 .b = {
2055 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
2056 .en_mask = BIT(4),
2057 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2058 .halt_bit = 3,
2059 },
2060 .c = {
2061 .dbg_name = "gsbi10_p_clk",
2062 .ops = &clk_ops_branch,
2063 CLK_INIT(gsbi10_p_clk.c),
2064 },
2065};
2066
2067static struct branch_clk gsbi11_p_clk = {
2068 .b = {
2069 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
2070 .en_mask = BIT(4),
2071 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2072 .halt_bit = 18,
2073 },
2074 .c = {
2075 .dbg_name = "gsbi11_p_clk",
2076 .ops = &clk_ops_branch,
2077 CLK_INIT(gsbi11_p_clk.c),
2078 },
2079};
2080
2081static struct branch_clk gsbi12_p_clk = {
2082 .b = {
2083 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
2084 .en_mask = BIT(4),
2085 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2086 .halt_bit = 14,
2087 },
2088 .c = {
2089 .dbg_name = "gsbi12_p_clk",
2090 .ops = &clk_ops_branch,
2091 CLK_INIT(gsbi12_p_clk.c),
2092 },
2093};
2094
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002095static struct branch_clk qdss_p_clk = {
2096 .b = {
2097 .ctl_reg = QDSS_HCLK_CTL_REG,
2098 .en_mask = BIT(4),
2099 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2100 .halt_bit = 11,
2101 .halt_check = HALT_VOTED,
2102 .reset_reg = QDSS_RESETS_REG,
2103 .reset_mask = BIT(2),
2104 },
2105 .c = {
2106 .dbg_name = "qdss_p_clk",
2107 .ops = &clk_ops_branch,
2108 CLK_INIT(qdss_p_clk.c),
2109 },
2110};
2111
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002112static struct branch_clk tsif_p_clk = {
2113 .b = {
2114 .ctl_reg = TSIF_HCLK_CTL_REG,
2115 .en_mask = BIT(4),
2116 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2117 .halt_bit = 7,
2118 },
2119 .c = {
2120 .dbg_name = "tsif_p_clk",
2121 .ops = &clk_ops_branch,
2122 CLK_INIT(tsif_p_clk.c),
2123 },
2124};
2125
2126static struct branch_clk usb_fs1_p_clk = {
2127 .b = {
2128 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
2129 .en_mask = BIT(4),
2130 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2131 .halt_bit = 17,
2132 },
2133 .c = {
2134 .dbg_name = "usb_fs1_p_clk",
2135 .ops = &clk_ops_branch,
2136 CLK_INIT(usb_fs1_p_clk.c),
2137 },
2138};
2139
2140static struct branch_clk usb_fs2_p_clk = {
2141 .b = {
2142 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
2143 .en_mask = BIT(4),
2144 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2145 .halt_bit = 14,
2146 },
2147 .c = {
2148 .dbg_name = "usb_fs2_p_clk",
2149 .ops = &clk_ops_branch,
2150 CLK_INIT(usb_fs2_p_clk.c),
2151 },
2152};
2153
2154static struct branch_clk usb_hs1_p_clk = {
2155 .b = {
2156 .ctl_reg = USB_HS1_HCLK_CTL_REG,
2157 .en_mask = BIT(4),
2158 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2159 .halt_bit = 1,
2160 },
2161 .c = {
2162 .dbg_name = "usb_hs1_p_clk",
2163 .ops = &clk_ops_branch,
2164 CLK_INIT(usb_hs1_p_clk.c),
2165 },
2166};
2167
Stephen Boyd94625ef2011-07-12 17:06:01 -07002168static struct branch_clk usb_hsic_p_clk = {
2169 .b = {
2170 .ctl_reg = USB_HSIC_HCLK_CTL_REG,
2171 .en_mask = BIT(4),
2172 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2173 .halt_bit = 28,
2174 },
2175 .c = {
2176 .dbg_name = "usb_hsic_p_clk",
2177 .ops = &clk_ops_branch,
2178 CLK_INIT(usb_hsic_p_clk.c),
2179 },
2180};
2181
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002182static struct branch_clk sdc1_p_clk = {
2183 .b = {
2184 .ctl_reg = SDCn_HCLK_CTL_REG(1),
2185 .en_mask = BIT(4),
2186 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2187 .halt_bit = 11,
2188 },
2189 .c = {
2190 .dbg_name = "sdc1_p_clk",
2191 .ops = &clk_ops_branch,
2192 CLK_INIT(sdc1_p_clk.c),
2193 },
2194};
2195
2196static struct branch_clk sdc2_p_clk = {
2197 .b = {
2198 .ctl_reg = SDCn_HCLK_CTL_REG(2),
2199 .en_mask = BIT(4),
2200 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2201 .halt_bit = 10,
2202 },
2203 .c = {
2204 .dbg_name = "sdc2_p_clk",
2205 .ops = &clk_ops_branch,
2206 CLK_INIT(sdc2_p_clk.c),
2207 },
2208};
2209
2210static struct branch_clk sdc3_p_clk = {
2211 .b = {
2212 .ctl_reg = SDCn_HCLK_CTL_REG(3),
2213 .en_mask = BIT(4),
2214 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2215 .halt_bit = 9,
2216 },
2217 .c = {
2218 .dbg_name = "sdc3_p_clk",
2219 .ops = &clk_ops_branch,
2220 CLK_INIT(sdc3_p_clk.c),
2221 },
2222};
2223
2224static struct branch_clk sdc4_p_clk = {
2225 .b = {
2226 .ctl_reg = SDCn_HCLK_CTL_REG(4),
2227 .en_mask = BIT(4),
2228 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2229 .halt_bit = 8,
2230 },
2231 .c = {
2232 .dbg_name = "sdc4_p_clk",
2233 .ops = &clk_ops_branch,
2234 CLK_INIT(sdc4_p_clk.c),
2235 },
2236};
2237
2238static struct branch_clk sdc5_p_clk = {
2239 .b = {
2240 .ctl_reg = SDCn_HCLK_CTL_REG(5),
2241 .en_mask = BIT(4),
2242 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2243 .halt_bit = 7,
2244 },
2245 .c = {
2246 .dbg_name = "sdc5_p_clk",
2247 .ops = &clk_ops_branch,
2248 CLK_INIT(sdc5_p_clk.c),
2249 },
2250};
2251
2252/* HW-Voteable Clocks */
2253static struct branch_clk adm0_clk = {
2254 .b = {
2255 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2256 .en_mask = BIT(2),
2257 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2258 .halt_check = HALT_VOTED,
2259 .halt_bit = 14,
2260 },
2261 .c = {
2262 .dbg_name = "adm0_clk",
2263 .ops = &clk_ops_branch,
2264 CLK_INIT(adm0_clk.c),
2265 },
2266};
2267
2268static struct branch_clk adm0_p_clk = {
2269 .b = {
2270 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2271 .en_mask = BIT(3),
2272 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2273 .halt_check = HALT_VOTED,
2274 .halt_bit = 13,
2275 },
2276 .c = {
2277 .dbg_name = "adm0_p_clk",
2278 .ops = &clk_ops_branch,
2279 CLK_INIT(adm0_p_clk.c),
2280 },
2281};
2282
2283static struct branch_clk pmic_arb0_p_clk = {
2284 .b = {
2285 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2286 .en_mask = BIT(8),
2287 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2288 .halt_check = HALT_VOTED,
2289 .halt_bit = 22,
2290 },
2291 .c = {
2292 .dbg_name = "pmic_arb0_p_clk",
2293 .ops = &clk_ops_branch,
2294 CLK_INIT(pmic_arb0_p_clk.c),
2295 },
2296};
2297
2298static struct branch_clk pmic_arb1_p_clk = {
2299 .b = {
2300 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2301 .en_mask = BIT(9),
2302 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2303 .halt_check = HALT_VOTED,
2304 .halt_bit = 21,
2305 },
2306 .c = {
2307 .dbg_name = "pmic_arb1_p_clk",
2308 .ops = &clk_ops_branch,
2309 CLK_INIT(pmic_arb1_p_clk.c),
2310 },
2311};
2312
2313static struct branch_clk pmic_ssbi2_clk = {
2314 .b = {
2315 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2316 .en_mask = BIT(7),
2317 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2318 .halt_check = HALT_VOTED,
2319 .halt_bit = 23,
2320 },
2321 .c = {
2322 .dbg_name = "pmic_ssbi2_clk",
2323 .ops = &clk_ops_branch,
2324 CLK_INIT(pmic_ssbi2_clk.c),
2325 },
2326};
2327
2328static struct branch_clk rpm_msg_ram_p_clk = {
2329 .b = {
2330 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2331 .en_mask = BIT(6),
2332 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2333 .halt_check = HALT_VOTED,
2334 .halt_bit = 12,
2335 },
2336 .c = {
2337 .dbg_name = "rpm_msg_ram_p_clk",
2338 .ops = &clk_ops_branch,
2339 CLK_INIT(rpm_msg_ram_p_clk.c),
2340 },
2341};
2342
2343/*
2344 * Multimedia Clocks
2345 */
2346
2347static struct branch_clk amp_clk = {
2348 .b = {
2349 .reset_reg = SW_RESET_CORE_REG,
2350 .reset_mask = BIT(20),
2351 },
2352 .c = {
2353 .dbg_name = "amp_clk",
2354 .ops = &clk_ops_reset,
2355 CLK_INIT(amp_clk.c),
2356 },
2357};
2358
Stephen Boyd94625ef2011-07-12 17:06:01 -07002359#define CLK_CAM(name, n, hb) \
2360 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002361 .b = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002362 .ctl_reg = CAMCLK##n##_CC_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002363 .en_mask = BIT(0), \
2364 .halt_reg = DBG_BUS_VEC_I_REG, \
2365 .halt_bit = hb, \
2366 }, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002367 .ns_reg = CAMCLK##n##_NS_REG, \
2368 .md_reg = CAMCLK##n##_MD_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002369 .root_en_mask = BIT(2), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002370 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002371 .ctl_mask = BM(7, 6), \
2372 .set_rate = set_rate_mnd_8, \
2373 .freq_tbl = clk_tbl_cam, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002374 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002375 .c = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002376 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002377 .ops = &clk_ops_rcg_8960, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002378 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002379 }, \
2380 }
2381#define F_CAM(f, s, d, m, n, v) \
2382 { \
2383 .freq_hz = f, \
2384 .src_clk = &s##_clk.c, \
2385 .md_val = MD8(8, m, 0, n), \
2386 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2387 .ctl_val = CC(6, n), \
2388 .mnd_en_mask = BIT(5) * !!(n), \
2389 .sys_vdd = v, \
2390 }
2391static struct clk_freq_tbl clk_tbl_cam[] = {
2392 F_CAM( 0, gnd, 1, 0, 0, NONE),
2393 F_CAM( 6000000, pll8, 4, 1, 16, LOW),
2394 F_CAM( 8000000, pll8, 4, 1, 12, LOW),
2395 F_CAM( 12000000, pll8, 4, 1, 8, LOW),
2396 F_CAM( 16000000, pll8, 4, 1, 6, LOW),
2397 F_CAM( 19200000, pll8, 4, 1, 5, LOW),
2398 F_CAM( 24000000, pll8, 4, 1, 4, LOW),
2399 F_CAM( 32000000, pll8, 4, 1, 3, LOW),
2400 F_CAM( 48000000, pll8, 4, 1, 2, LOW),
2401 F_CAM( 64000000, pll8, 3, 1, 2, LOW),
2402 F_CAM( 96000000, pll8, 4, 0, 0, NOMINAL),
2403 F_CAM(128000000, pll8, 3, 0, 0, NOMINAL),
2404 F_END
2405};
2406
Stephen Boyd94625ef2011-07-12 17:06:01 -07002407static CLK_CAM(cam0_clk, 0, 15);
2408static CLK_CAM(cam1_clk, 1, 16);
2409static CLK_CAM(cam2_clk, 2, 31);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002410
2411#define F_CSI(f, s, d, m, n, v) \
2412 { \
2413 .freq_hz = f, \
2414 .src_clk = &s##_clk.c, \
2415 .md_val = MD8(8, m, 0, n), \
2416 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2417 .ctl_val = CC(6, n), \
2418 .mnd_en_mask = BIT(5) * !!(n), \
2419 .sys_vdd = v, \
2420 }
2421static struct clk_freq_tbl clk_tbl_csi[] = {
2422 F_CSI( 0, gnd, 1, 0, 0, NONE),
2423 F_CSI( 85330000, pll8, 1, 2, 9, LOW),
2424 F_CSI(177780000, pll2, 1, 2, 9, NOMINAL),
2425 F_END
2426};
2427
2428static struct rcg_clk csi0_src_clk = {
2429 .ns_reg = CSI0_NS_REG,
2430 .b = {
2431 .ctl_reg = CSI0_CC_REG,
2432 .halt_check = NOCHECK,
2433 },
2434 .md_reg = CSI0_MD_REG,
2435 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002436 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002437 .ctl_mask = BM(7, 6),
2438 .set_rate = set_rate_mnd,
2439 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002440 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002441 .c = {
2442 .dbg_name = "csi0_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002443 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002444 CLK_INIT(csi0_src_clk.c),
2445 },
2446};
2447
2448static struct branch_clk csi0_clk = {
2449 .b = {
2450 .ctl_reg = CSI0_CC_REG,
2451 .en_mask = BIT(0),
2452 .reset_reg = SW_RESET_CORE_REG,
2453 .reset_mask = BIT(8),
2454 .halt_reg = DBG_BUS_VEC_B_REG,
2455 .halt_bit = 13,
2456 },
2457 .parent = &csi0_src_clk.c,
2458 .c = {
2459 .dbg_name = "csi0_clk",
2460 .ops = &clk_ops_branch,
2461 CLK_INIT(csi0_clk.c),
2462 },
2463};
2464
2465static struct branch_clk csi0_phy_clk = {
2466 .b = {
2467 .ctl_reg = CSI0_CC_REG,
2468 .en_mask = BIT(8),
2469 .reset_reg = SW_RESET_CORE_REG,
2470 .reset_mask = BIT(29),
2471 .halt_reg = DBG_BUS_VEC_I_REG,
2472 .halt_bit = 9,
2473 },
2474 .parent = &csi0_src_clk.c,
2475 .c = {
2476 .dbg_name = "csi0_phy_clk",
2477 .ops = &clk_ops_branch,
2478 CLK_INIT(csi0_phy_clk.c),
2479 },
2480};
2481
2482static struct rcg_clk csi1_src_clk = {
2483 .ns_reg = CSI1_NS_REG,
2484 .b = {
2485 .ctl_reg = CSI1_CC_REG,
2486 .halt_check = NOCHECK,
2487 },
2488 .md_reg = CSI1_MD_REG,
2489 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002490 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002491 .ctl_mask = BM(7, 6),
2492 .set_rate = set_rate_mnd,
2493 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002494 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002495 .c = {
2496 .dbg_name = "csi1_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002497 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002498 CLK_INIT(csi1_src_clk.c),
2499 },
2500};
2501
2502static struct branch_clk csi1_clk = {
2503 .b = {
2504 .ctl_reg = CSI1_CC_REG,
2505 .en_mask = BIT(0),
2506 .reset_reg = SW_RESET_CORE_REG,
2507 .reset_mask = BIT(18),
2508 .halt_reg = DBG_BUS_VEC_B_REG,
2509 .halt_bit = 14,
2510 },
2511 .parent = &csi1_src_clk.c,
2512 .c = {
2513 .dbg_name = "csi1_clk",
2514 .ops = &clk_ops_branch,
2515 CLK_INIT(csi1_clk.c),
2516 },
2517};
2518
2519static struct branch_clk csi1_phy_clk = {
2520 .b = {
2521 .ctl_reg = CSI1_CC_REG,
2522 .en_mask = BIT(8),
2523 .reset_reg = SW_RESET_CORE_REG,
2524 .reset_mask = BIT(28),
2525 .halt_reg = DBG_BUS_VEC_I_REG,
2526 .halt_bit = 10,
2527 },
2528 .parent = &csi1_src_clk.c,
2529 .c = {
2530 .dbg_name = "csi1_phy_clk",
2531 .ops = &clk_ops_branch,
2532 CLK_INIT(csi1_phy_clk.c),
2533 },
2534};
2535
Stephen Boyd94625ef2011-07-12 17:06:01 -07002536static struct rcg_clk csi2_src_clk = {
2537 .ns_reg = CSI2_NS_REG,
2538 .b = {
2539 .ctl_reg = CSI2_CC_REG,
2540 .halt_check = NOCHECK,
2541 },
2542 .md_reg = CSI2_MD_REG,
2543 .root_en_mask = BIT(2),
2544 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
2545 .ctl_mask = BM(7, 6),
2546 .set_rate = set_rate_mnd,
2547 .freq_tbl = clk_tbl_csi,
2548 .current_freq = &rcg_dummy_freq,
2549 .c = {
2550 .dbg_name = "csi2_src_clk",
2551 .ops = &clk_ops_rcg_8960,
2552 CLK_INIT(csi2_src_clk.c),
2553 },
2554};
2555
2556static struct branch_clk csi2_clk = {
2557 .b = {
2558 .ctl_reg = CSI2_CC_REG,
2559 .en_mask = BIT(0),
2560 .reset_reg = SW_RESET_CORE2_REG,
2561 .reset_mask = BIT(2),
2562 .halt_reg = DBG_BUS_VEC_B_REG,
2563 .halt_bit = 29,
2564 },
2565 .parent = &csi2_src_clk.c,
2566 .c = {
2567 .dbg_name = "csi2_clk",
2568 .ops = &clk_ops_branch,
2569 CLK_INIT(csi2_clk.c),
2570 },
2571};
2572
2573static struct branch_clk csi2_phy_clk = {
2574 .b = {
2575 .ctl_reg = CSI2_CC_REG,
2576 .en_mask = BIT(8),
2577 .reset_reg = SW_RESET_CORE_REG,
2578 .reset_mask = BIT(31),
2579 .halt_reg = DBG_BUS_VEC_I_REG,
2580 .halt_bit = 29,
2581 },
2582 .parent = &csi2_src_clk.c,
2583 .c = {
2584 .dbg_name = "csi2_phy_clk",
2585 .ops = &clk_ops_branch,
2586 CLK_INIT(csi2_phy_clk.c),
2587 },
2588};
2589
2590/*
2591 * The csi pix and csi rdi clocks have two bits in two registers to control a
2592 * three input mux. So we have the generic rcg_clk_enable() path handle the
2593 * first bit, and this function handle the second bit.
2594 */
2595static void set_rate_pix_rdi(struct rcg_clk *clk, struct clk_freq_tbl *nf)
2596{
2597 u32 reg = readl_relaxed(MISC_CC3_REG);
2598 u32 bit = (u32)nf->extra_freq_data;
2599 if (nf->freq_hz == 2)
2600 reg |= bit;
2601 else
2602 reg &= ~bit;
2603 writel_relaxed(reg, MISC_CC3_REG);
2604}
2605
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002606#define F_CSI_PIX(s) \
2607 { \
2608 .src_clk = &csi##s##_clk.c, \
2609 .freq_hz = s, \
2610 .ns_val = BVAL(25, 25, s), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002611 .extra_freq_data = (void *)BIT(13), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002612 }
2613static struct clk_freq_tbl clk_tbl_csi_pix[] = {
2614 F_CSI_PIX(0), /* CSI0 source */
2615 F_CSI_PIX(1), /* CSI1 source */
Stephen Boyd94625ef2011-07-12 17:06:01 -07002616 F_CSI_PIX(2), /* CSI2 source */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002617 F_END
2618};
2619
2620static struct rcg_clk csi_pix_clk = {
2621 .b = {
2622 .ctl_reg = MISC_CC_REG,
2623 .en_mask = BIT(26),
2624 .halt_check = DELAY,
2625 .reset_reg = SW_RESET_CORE_REG,
2626 .reset_mask = BIT(26),
2627 },
2628 .ns_reg = MISC_CC_REG,
2629 .ns_mask = BIT(25),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002630 .set_rate = set_rate_pix_rdi,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002631 .freq_tbl = clk_tbl_csi_pix,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002632 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002633 .c = {
2634 .dbg_name = "csi_pix_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002635 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002636 CLK_INIT(csi_pix_clk.c),
2637 },
2638};
2639
Stephen Boyd94625ef2011-07-12 17:06:01 -07002640#define F_CSI_PIX1(s) \
2641 { \
2642 .src_clk = &csi##s##_clk.c, \
2643 .freq_hz = s, \
2644 .ns_val = BVAL(9, 8, s), \
2645 }
2646static struct clk_freq_tbl clk_tbl_csi_pix1[] = {
2647 F_CSI_PIX1(0), /* CSI0 source */
2648 F_CSI_PIX1(1), /* CSI1 source */
2649 F_CSI_PIX1(2), /* CSI2 source */
2650 F_END
2651};
2652
2653static struct rcg_clk csi_pix1_clk = {
2654 .b = {
2655 .ctl_reg = MISC_CC3_REG,
2656 .en_mask = BIT(10),
2657 .halt_check = DELAY,
2658 .reset_reg = SW_RESET_CORE_REG,
2659 .reset_mask = BIT(30),
2660 },
2661 .ns_reg = MISC_CC3_REG,
2662 .ns_mask = BM(9, 8),
2663 .set_rate = set_rate_nop,
2664 .freq_tbl = clk_tbl_csi_pix1,
2665 .current_freq = &rcg_dummy_freq,
2666 .c = {
2667 .dbg_name = "csi_pix1_clk",
2668 .ops = &clk_ops_rcg_8960,
2669 CLK_INIT(csi_pix1_clk.c),
2670 },
2671};
2672
2673#define F_CSI_RDI(s) \
2674 { \
2675 .src_clk = &csi##s##_clk.c, \
2676 .freq_hz = s, \
2677 .ns_val = BVAL(12, 12, s), \
2678 .extra_freq_data = (void *)BIT(12), \
2679 }
2680static struct clk_freq_tbl clk_tbl_csi_rdi[] = {
2681 F_CSI_RDI(0), /* CSI0 source */
2682 F_CSI_RDI(1), /* CSI1 source */
2683 F_CSI_RDI(2), /* CSI2 source */
2684 F_END
2685};
2686
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002687static struct rcg_clk csi_rdi_clk = {
2688 .b = {
2689 .ctl_reg = MISC_CC_REG,
2690 .en_mask = BIT(13),
2691 .halt_check = DELAY,
2692 .reset_reg = SW_RESET_CORE_REG,
2693 .reset_mask = BIT(27),
2694 },
2695 .ns_reg = MISC_CC_REG,
2696 .ns_mask = BIT(12),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002697 .set_rate = set_rate_pix_rdi,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002698 .freq_tbl = clk_tbl_csi_rdi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002699 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002700 .c = {
2701 .dbg_name = "csi_rdi_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002702 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002703 CLK_INIT(csi_rdi_clk.c),
2704 },
2705};
2706
Stephen Boyd94625ef2011-07-12 17:06:01 -07002707#define F_CSI_RDI1(s) \
2708 { \
2709 .src_clk = &csi##s##_clk.c, \
2710 .freq_hz = s, \
2711 .ns_val = BVAL(1, 0, s), \
2712 }
2713static struct clk_freq_tbl clk_tbl_csi_rdi1[] = {
2714 F_CSI_RDI1(0), /* CSI0 source */
2715 F_CSI_RDI1(1), /* CSI1 source */
2716 F_CSI_RDI1(2), /* CSI2 source */
2717 F_END
2718};
2719
2720static struct rcg_clk csi_rdi1_clk = {
2721 .b = {
2722 .ctl_reg = MISC_CC3_REG,
2723 .en_mask = BIT(2),
2724 .halt_check = DELAY,
2725 .reset_reg = SW_RESET_CORE2_REG,
2726 .reset_mask = BIT(1),
2727 },
2728 .ns_reg = MISC_CC3_REG,
2729 .ns_mask = BM(1, 0),
2730 .set_rate = set_rate_nop,
2731 .freq_tbl = clk_tbl_csi_rdi1,
2732 .current_freq = &rcg_dummy_freq,
2733 .c = {
2734 .dbg_name = "csi_rdi1_clk",
2735 .ops = &clk_ops_rcg_8960,
2736 CLK_INIT(csi_rdi1_clk.c),
2737 },
2738};
2739
2740#define F_CSI_RDI2(s) \
2741 { \
2742 .src_clk = &csi##s##_clk.c, \
2743 .freq_hz = s, \
2744 .ns_val = BVAL(5, 4, s), \
2745 }
2746static struct clk_freq_tbl clk_tbl_csi_rdi2[] = {
2747 F_CSI_RDI2(0), /* CSI0 source */
2748 F_CSI_RDI2(1), /* CSI1 source */
2749 F_CSI_RDI2(2), /* CSI2 source */
2750 F_END
2751};
2752
2753static struct rcg_clk csi_rdi2_clk = {
2754 .b = {
2755 .ctl_reg = MISC_CC3_REG,
2756 .en_mask = BIT(6),
2757 .halt_check = DELAY,
2758 .reset_reg = SW_RESET_CORE2_REG,
2759 .reset_mask = BIT(0),
2760 },
2761 .ns_reg = MISC_CC3_REG,
2762 .ns_mask = BM(5, 4),
2763 .set_rate = set_rate_nop,
2764 .freq_tbl = clk_tbl_csi_rdi2,
2765 .current_freq = &rcg_dummy_freq,
2766 .c = {
2767 .dbg_name = "csi_rdi2_clk",
2768 .ops = &clk_ops_rcg_8960,
2769 CLK_INIT(csi_rdi2_clk.c),
2770 },
2771};
2772
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002773#define F_CSI_PHYTIMER(f, s, d, m, n, v) \
2774 { \
2775 .freq_hz = f, \
2776 .src_clk = &s##_clk.c, \
2777 .md_val = MD8(8, m, 0, n), \
2778 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2779 .ctl_val = CC(6, n), \
2780 .mnd_en_mask = BIT(5) * !!(n), \
2781 .sys_vdd = v, \
2782 }
2783static struct clk_freq_tbl clk_tbl_csi_phytimer[] = {
2784 F_CSI_PHYTIMER( 0, gnd, 1, 0, 0, NONE),
2785 F_CSI_PHYTIMER( 85330000, pll8, 1, 2, 9, LOW),
2786 F_CSI_PHYTIMER(177780000, pll2, 1, 2, 9, NOMINAL),
2787 F_END
2788};
2789
2790static struct rcg_clk csiphy_timer_src_clk = {
2791 .ns_reg = CSIPHYTIMER_NS_REG,
2792 .b = {
2793 .ctl_reg = CSIPHYTIMER_CC_REG,
2794 .halt_check = NOCHECK,
2795 },
2796 .md_reg = CSIPHYTIMER_MD_REG,
2797 .root_en_mask = BIT(2),
2798 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
2799 .ctl_mask = BM(7, 6),
2800 .set_rate = set_rate_mnd_8,
2801 .freq_tbl = clk_tbl_csi_phytimer,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002802 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002803 .c = {
2804 .dbg_name = "csiphy_timer_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002805 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002806 CLK_INIT(csiphy_timer_src_clk.c),
2807 },
2808};
2809
2810static struct branch_clk csi0phy_timer_clk = {
2811 .b = {
2812 .ctl_reg = CSIPHYTIMER_CC_REG,
2813 .en_mask = BIT(0),
2814 .halt_reg = DBG_BUS_VEC_I_REG,
2815 .halt_bit = 17,
2816 },
2817 .parent = &csiphy_timer_src_clk.c,
2818 .c = {
2819 .dbg_name = "csi0phy_timer_clk",
2820 .ops = &clk_ops_branch,
2821 CLK_INIT(csi0phy_timer_clk.c),
2822 },
2823};
2824
2825static struct branch_clk csi1phy_timer_clk = {
2826 .b = {
2827 .ctl_reg = CSIPHYTIMER_CC_REG,
2828 .en_mask = BIT(9),
2829 .halt_reg = DBG_BUS_VEC_I_REG,
2830 .halt_bit = 18,
2831 },
2832 .parent = &csiphy_timer_src_clk.c,
2833 .c = {
2834 .dbg_name = "csi1phy_timer_clk",
2835 .ops = &clk_ops_branch,
2836 CLK_INIT(csi1phy_timer_clk.c),
2837 },
2838};
2839
Stephen Boyd94625ef2011-07-12 17:06:01 -07002840static struct branch_clk csi2phy_timer_clk = {
2841 .b = {
2842 .ctl_reg = CSIPHYTIMER_CC_REG,
2843 .en_mask = BIT(11),
2844 .halt_reg = DBG_BUS_VEC_I_REG,
2845 .halt_bit = 30,
2846 },
2847 .parent = &csiphy_timer_src_clk.c,
2848 .c = {
2849 .dbg_name = "csi2phy_timer_clk",
2850 .ops = &clk_ops_branch,
2851 CLK_INIT(csi2phy_timer_clk.c),
2852 },
2853};
2854
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002855#define F_DSI(d) \
2856 { \
2857 .freq_hz = d, \
2858 .ns_val = BVAL(15, 12, (d-1)), \
2859 }
2860/*
2861 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
2862 * without this clock driver knowing. So, overload the clk_set_rate() to set
2863 * the divider (1 to 16) of the clock with respect to the PLL rate.
2864 */
2865static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
2866 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
2867 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
2868 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
2869 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
2870 F_END
2871};
2872
2873static struct rcg_clk dsi1_byte_clk = {
2874 .b = {
2875 .ctl_reg = DSI1_BYTE_CC_REG,
2876 .en_mask = BIT(0),
2877 .reset_reg = SW_RESET_CORE_REG,
2878 .reset_mask = BIT(7),
2879 .halt_reg = DBG_BUS_VEC_B_REG,
2880 .halt_bit = 21,
2881 },
2882 .ns_reg = DSI1_BYTE_NS_REG,
2883 .root_en_mask = BIT(2),
2884 .ns_mask = BM(15, 12),
2885 .set_rate = set_rate_nop,
2886 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002887 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002888 .c = {
2889 .dbg_name = "dsi1_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002890 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002891 CLK_INIT(dsi1_byte_clk.c),
2892 },
2893};
2894
2895static struct rcg_clk dsi2_byte_clk = {
2896 .b = {
2897 .ctl_reg = DSI2_BYTE_CC_REG,
2898 .en_mask = BIT(0),
2899 .reset_reg = SW_RESET_CORE_REG,
2900 .reset_mask = BIT(25),
2901 .halt_reg = DBG_BUS_VEC_B_REG,
2902 .halt_bit = 20,
2903 },
2904 .ns_reg = DSI2_BYTE_NS_REG,
2905 .root_en_mask = BIT(2),
2906 .ns_mask = BM(15, 12),
2907 .set_rate = set_rate_nop,
2908 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002909 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002910 .c = {
2911 .dbg_name = "dsi2_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002912 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002913 CLK_INIT(dsi2_byte_clk.c),
2914 },
2915};
2916
2917static struct rcg_clk dsi1_esc_clk = {
2918 .b = {
2919 .ctl_reg = DSI1_ESC_CC_REG,
2920 .en_mask = BIT(0),
2921 .reset_reg = SW_RESET_CORE_REG,
2922 .halt_reg = DBG_BUS_VEC_I_REG,
2923 .halt_bit = 1,
2924 },
2925 .ns_reg = DSI1_ESC_NS_REG,
2926 .root_en_mask = BIT(2),
2927 .ns_mask = BM(15, 12),
2928 .set_rate = set_rate_nop,
2929 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002930 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002931 .c = {
2932 .dbg_name = "dsi1_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002933 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002934 CLK_INIT(dsi1_esc_clk.c),
2935 },
2936};
2937
2938static struct rcg_clk dsi2_esc_clk = {
2939 .b = {
2940 .ctl_reg = DSI2_ESC_CC_REG,
2941 .en_mask = BIT(0),
2942 .halt_reg = DBG_BUS_VEC_I_REG,
2943 .halt_bit = 3,
2944 },
2945 .ns_reg = DSI2_ESC_NS_REG,
2946 .root_en_mask = BIT(2),
2947 .ns_mask = BM(15, 12),
2948 .set_rate = set_rate_nop,
2949 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002950 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002951 .c = {
2952 .dbg_name = "dsi2_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002953 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002954 CLK_INIT(dsi2_esc_clk.c),
2955 },
2956};
2957
2958#define F_GFX2D(f, s, m, n, v) \
2959 { \
2960 .freq_hz = f, \
2961 .src_clk = &s##_clk.c, \
2962 .md_val = MD4(4, m, 0, n), \
2963 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
2964 .ctl_val = CC_BANKED(9, 6, n), \
2965 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
2966 .sys_vdd = v, \
2967 }
2968static struct clk_freq_tbl clk_tbl_gfx2d[] = {
2969 F_GFX2D( 0, gnd, 0, 0, NONE),
2970 F_GFX2D( 27000000, pxo, 0, 0, LOW),
2971 F_GFX2D( 48000000, pll8, 1, 8, LOW),
2972 F_GFX2D( 54857000, pll8, 1, 7, LOW),
2973 F_GFX2D( 64000000, pll8, 1, 6, LOW),
2974 F_GFX2D( 76800000, pll8, 1, 5, LOW),
2975 F_GFX2D( 96000000, pll8, 1, 4, LOW),
2976 F_GFX2D(128000000, pll8, 1, 3, NOMINAL),
2977 F_GFX2D(145455000, pll2, 2, 11, NOMINAL),
2978 F_GFX2D(160000000, pll2, 1, 5, NOMINAL),
2979 F_GFX2D(177778000, pll2, 2, 9, NOMINAL),
2980 F_GFX2D(200000000, pll2, 1, 4, NOMINAL),
2981 F_GFX2D(228571000, pll2, 2, 7, HIGH),
2982 F_END
2983};
2984
2985static struct bank_masks bmnd_info_gfx2d0 = {
2986 .bank_sel_mask = BIT(11),
2987 .bank0_mask = {
2988 .md_reg = GFX2D0_MD0_REG,
2989 .ns_mask = BM(23, 20) | BM(5, 3),
2990 .rst_mask = BIT(25),
2991 .mnd_en_mask = BIT(8),
2992 .mode_mask = BM(10, 9),
2993 },
2994 .bank1_mask = {
2995 .md_reg = GFX2D0_MD1_REG,
2996 .ns_mask = BM(19, 16) | BM(2, 0),
2997 .rst_mask = BIT(24),
2998 .mnd_en_mask = BIT(5),
2999 .mode_mask = BM(7, 6),
3000 },
3001};
3002
3003static struct rcg_clk gfx2d0_clk = {
3004 .b = {
3005 .ctl_reg = GFX2D0_CC_REG,
3006 .en_mask = BIT(0),
3007 .reset_reg = SW_RESET_CORE_REG,
3008 .reset_mask = BIT(14),
3009 .halt_reg = DBG_BUS_VEC_A_REG,
3010 .halt_bit = 9,
3011 },
3012 .ns_reg = GFX2D0_NS_REG,
3013 .root_en_mask = BIT(2),
3014 .set_rate = set_rate_mnd_banked,
3015 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003016 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003017 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003018 .c = {
3019 .dbg_name = "gfx2d0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003020 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003021 CLK_INIT(gfx2d0_clk.c),
3022 },
3023};
3024
3025static struct bank_masks bmnd_info_gfx2d1 = {
3026 .bank_sel_mask = BIT(11),
3027 .bank0_mask = {
3028 .md_reg = GFX2D1_MD0_REG,
3029 .ns_mask = BM(23, 20) | BM(5, 3),
3030 .rst_mask = BIT(25),
3031 .mnd_en_mask = BIT(8),
3032 .mode_mask = BM(10, 9),
3033 },
3034 .bank1_mask = {
3035 .md_reg = GFX2D1_MD1_REG,
3036 .ns_mask = BM(19, 16) | BM(2, 0),
3037 .rst_mask = BIT(24),
3038 .mnd_en_mask = BIT(5),
3039 .mode_mask = BM(7, 6),
3040 },
3041};
3042
3043static struct rcg_clk gfx2d1_clk = {
3044 .b = {
3045 .ctl_reg = GFX2D1_CC_REG,
3046 .en_mask = BIT(0),
3047 .reset_reg = SW_RESET_CORE_REG,
3048 .reset_mask = BIT(13),
3049 .halt_reg = DBG_BUS_VEC_A_REG,
3050 .halt_bit = 14,
3051 },
3052 .ns_reg = GFX2D1_NS_REG,
3053 .root_en_mask = BIT(2),
3054 .set_rate = set_rate_mnd_banked,
3055 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003056 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003057 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003058 .c = {
3059 .dbg_name = "gfx2d1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003060 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003061 CLK_INIT(gfx2d1_clk.c),
3062 },
3063};
3064
3065#define F_GFX3D(f, s, m, n, v) \
3066 { \
3067 .freq_hz = f, \
3068 .src_clk = &s##_clk.c, \
3069 .md_val = MD4(4, m, 0, n), \
3070 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3071 .ctl_val = CC_BANKED(9, 6, n), \
3072 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
3073 .sys_vdd = v, \
3074 }
3075static struct clk_freq_tbl clk_tbl_gfx3d[] = {
3076 F_GFX3D( 0, gnd, 0, 0, NONE),
3077 F_GFX3D( 27000000, pxo, 0, 0, LOW),
3078 F_GFX3D( 48000000, pll8, 1, 8, LOW),
3079 F_GFX3D( 54857000, pll8, 1, 7, LOW),
3080 F_GFX3D( 64000000, pll8, 1, 6, LOW),
3081 F_GFX3D( 76800000, pll8, 1, 5, LOW),
3082 F_GFX3D( 96000000, pll8, 1, 4, LOW),
Stephen Boydd7797422011-08-10 16:01:45 -07003083 F_GFX3D(128000000, pll8, 1, 3, LOW),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003084 F_GFX3D(145455000, pll2, 2, 11, NOMINAL),
3085 F_GFX3D(160000000, pll2, 1, 5, NOMINAL),
3086 F_GFX3D(177778000, pll2, 2, 9, NOMINAL),
3087 F_GFX3D(200000000, pll2, 1, 4, NOMINAL),
3088 F_GFX3D(228571000, pll2, 2, 7, NOMINAL),
3089 F_GFX3D(266667000, pll2, 1, 3, NOMINAL),
3090 F_GFX3D(320000000, pll2, 2, 5, HIGH),
3091 F_END
3092};
3093
Stephen Boyd94625ef2011-07-12 17:06:01 -07003094static struct clk_freq_tbl clk_tbl_gfx3d_v2[] = {
3095 F_GFX3D( 0, gnd, 0, 0, NONE),
3096 F_GFX3D( 27000000, pxo, 0, 0, LOW),
3097 F_GFX3D( 48000000, pll8, 1, 8, LOW),
3098 F_GFX3D( 54857000, pll8, 1, 7, LOW),
3099 F_GFX3D( 64000000, pll8, 1, 6, LOW),
3100 F_GFX3D( 76800000, pll8, 1, 5, LOW),
3101 F_GFX3D( 96000000, pll8, 1, 4, LOW),
3102 F_GFX3D(128000000, pll8, 1, 3, LOW),
3103 F_GFX3D(145455000, pll2, 2, 11, NOMINAL),
3104 F_GFX3D(160000000, pll2, 1, 5, NOMINAL),
3105 F_GFX3D(177778000, pll2, 2, 9, NOMINAL),
3106 F_GFX3D(200000000, pll2, 1, 4, NOMINAL),
3107 F_GFX3D(228571000, pll2, 2, 7, NOMINAL),
3108 F_GFX3D(266667000, pll2, 1, 3, NOMINAL),
3109 F_GFX3D(300000000, pll3, 1, 4, NOMINAL),
3110 F_GFX3D(320000000, pll2, 2, 5, HIGH),
3111 F_GFX3D(400000000, pll2, 1, 2, HIGH),
3112 F_END
3113};
3114
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003115static struct bank_masks bmnd_info_gfx3d = {
3116 .bank_sel_mask = BIT(11),
3117 .bank0_mask = {
3118 .md_reg = GFX3D_MD0_REG,
3119 .ns_mask = BM(21, 18) | BM(5, 3),
3120 .rst_mask = BIT(23),
3121 .mnd_en_mask = BIT(8),
3122 .mode_mask = BM(10, 9),
3123 },
3124 .bank1_mask = {
3125 .md_reg = GFX3D_MD1_REG,
3126 .ns_mask = BM(17, 14) | BM(2, 0),
3127 .rst_mask = BIT(22),
3128 .mnd_en_mask = BIT(5),
3129 .mode_mask = BM(7, 6),
3130 },
3131};
3132
3133static struct rcg_clk gfx3d_clk = {
3134 .b = {
3135 .ctl_reg = GFX3D_CC_REG,
3136 .en_mask = BIT(0),
3137 .reset_reg = SW_RESET_CORE_REG,
3138 .reset_mask = BIT(12),
3139 .halt_reg = DBG_BUS_VEC_A_REG,
3140 .halt_bit = 4,
3141 },
3142 .ns_reg = GFX3D_NS_REG,
3143 .root_en_mask = BIT(2),
3144 .set_rate = set_rate_mnd_banked,
3145 .freq_tbl = clk_tbl_gfx3d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003146 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003147 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003148 .c = {
3149 .dbg_name = "gfx3d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003150 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003151 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003152 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003153 },
3154};
3155
3156#define F_IJPEG(f, s, d, m, n, v) \
3157 { \
3158 .freq_hz = f, \
3159 .src_clk = &s##_clk.c, \
3160 .md_val = MD8(8, m, 0, n), \
3161 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
3162 .ctl_val = CC(6, n), \
3163 .mnd_en_mask = BIT(5) * !!(n), \
3164 .sys_vdd = v, \
3165 }
3166static struct clk_freq_tbl clk_tbl_ijpeg[] = {
3167 F_IJPEG( 0, gnd, 1, 0, 0, NONE),
3168 F_IJPEG( 27000000, pxo, 1, 0, 0, LOW),
3169 F_IJPEG( 36570000, pll8, 1, 2, 21, LOW),
3170 F_IJPEG( 54860000, pll8, 7, 0, 0, LOW),
3171 F_IJPEG( 96000000, pll8, 4, 0, 0, LOW),
3172 F_IJPEG(109710000, pll8, 1, 2, 7, LOW),
3173 F_IJPEG(128000000, pll8, 3, 0, 0, NOMINAL),
3174 F_IJPEG(153600000, pll8, 1, 2, 5, NOMINAL),
3175 F_IJPEG(200000000, pll2, 4, 0, 0, NOMINAL),
3176 F_IJPEG(228571000, pll2, 1, 2, 7, NOMINAL),
Matt Wagantall393bdb52011-09-07 10:15:28 -07003177 F_IJPEG(266667000, pll2, 1, 1, 3, NOMINAL),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003178 F_IJPEG(320000000, pll2, 1, 2, 5, HIGH),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003179 F_END
3180};
3181
3182static struct rcg_clk ijpeg_clk = {
3183 .b = {
3184 .ctl_reg = IJPEG_CC_REG,
3185 .en_mask = BIT(0),
3186 .reset_reg = SW_RESET_CORE_REG,
3187 .reset_mask = BIT(9),
3188 .halt_reg = DBG_BUS_VEC_A_REG,
3189 .halt_bit = 24,
3190 },
3191 .ns_reg = IJPEG_NS_REG,
3192 .md_reg = IJPEG_MD_REG,
3193 .root_en_mask = BIT(2),
3194 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
3195 .ctl_mask = BM(7, 6),
3196 .set_rate = set_rate_mnd,
3197 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003198 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003199 .c = {
3200 .dbg_name = "ijpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003201 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003202 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003203 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003204 },
3205};
3206
3207#define F_JPEGD(f, s, d, v) \
3208 { \
3209 .freq_hz = f, \
3210 .src_clk = &s##_clk.c, \
3211 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
3212 .sys_vdd = v, \
3213 }
3214static struct clk_freq_tbl clk_tbl_jpegd[] = {
3215 F_JPEGD( 0, gnd, 1, NONE),
3216 F_JPEGD( 64000000, pll8, 6, LOW),
3217 F_JPEGD( 76800000, pll8, 5, LOW),
3218 F_JPEGD( 96000000, pll8, 4, LOW),
3219 F_JPEGD(160000000, pll2, 5, NOMINAL),
3220 F_JPEGD(200000000, pll2, 4, NOMINAL),
3221 F_END
3222};
3223
3224static struct rcg_clk jpegd_clk = {
3225 .b = {
3226 .ctl_reg = JPEGD_CC_REG,
3227 .en_mask = BIT(0),
3228 .reset_reg = SW_RESET_CORE_REG,
3229 .reset_mask = BIT(19),
3230 .halt_reg = DBG_BUS_VEC_A_REG,
3231 .halt_bit = 19,
3232 },
3233 .ns_reg = JPEGD_NS_REG,
3234 .root_en_mask = BIT(2),
3235 .ns_mask = (BM(15, 12) | BM(2, 0)),
3236 .set_rate = set_rate_nop,
3237 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003238 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003239 .c = {
3240 .dbg_name = "jpegd_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003241 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003242 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003243 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003244 },
3245};
3246
3247#define F_MDP(f, s, m, n, v) \
3248 { \
3249 .freq_hz = f, \
3250 .src_clk = &s##_clk.c, \
3251 .md_val = MD8(8, m, 0, n), \
3252 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
3253 .ctl_val = CC_BANKED(9, 6, n), \
3254 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
3255 .sys_vdd = v, \
3256 }
3257static struct clk_freq_tbl clk_tbl_mdp[] = {
3258 F_MDP( 0, gnd, 0, 0, NONE),
3259 F_MDP( 9600000, pll8, 1, 40, LOW),
3260 F_MDP( 13710000, pll8, 1, 28, LOW),
3261 F_MDP( 27000000, pxo, 0, 0, LOW),
3262 F_MDP( 29540000, pll8, 1, 13, LOW),
3263 F_MDP( 34910000, pll8, 1, 11, LOW),
3264 F_MDP( 38400000, pll8, 1, 10, LOW),
3265 F_MDP( 59080000, pll8, 2, 13, LOW),
3266 F_MDP( 76800000, pll8, 1, 5, LOW),
3267 F_MDP( 85330000, pll8, 2, 9, LOW),
3268 F_MDP( 96000000, pll8, 1, 4, NOMINAL),
3269 F_MDP(128000000, pll8, 1, 3, NOMINAL),
3270 F_MDP(160000000, pll2, 1, 5, NOMINAL),
3271 F_MDP(177780000, pll2, 2, 9, NOMINAL),
3272 F_MDP(200000000, pll2, 1, 4, NOMINAL),
3273 F_END
3274};
3275
3276static struct bank_masks bmnd_info_mdp = {
3277 .bank_sel_mask = BIT(11),
3278 .bank0_mask = {
3279 .md_reg = MDP_MD0_REG,
3280 .ns_mask = BM(29, 22) | BM(5, 3),
3281 .rst_mask = BIT(31),
3282 .mnd_en_mask = BIT(8),
3283 .mode_mask = BM(10, 9),
3284 },
3285 .bank1_mask = {
3286 .md_reg = MDP_MD1_REG,
3287 .ns_mask = BM(21, 14) | BM(2, 0),
3288 .rst_mask = BIT(30),
3289 .mnd_en_mask = BIT(5),
3290 .mode_mask = BM(7, 6),
3291 },
3292};
3293
3294static struct rcg_clk mdp_clk = {
3295 .b = {
3296 .ctl_reg = MDP_CC_REG,
3297 .en_mask = BIT(0),
3298 .reset_reg = SW_RESET_CORE_REG,
3299 .reset_mask = BIT(21),
3300 .halt_reg = DBG_BUS_VEC_C_REG,
3301 .halt_bit = 10,
3302 },
3303 .ns_reg = MDP_NS_REG,
3304 .root_en_mask = BIT(2),
3305 .set_rate = set_rate_mnd_banked,
3306 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003307 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003308 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003309 .c = {
3310 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003311 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003312 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003313 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003314 },
3315};
3316
3317static struct branch_clk lut_mdp_clk = {
3318 .b = {
3319 .ctl_reg = MDP_LUT_CC_REG,
3320 .en_mask = BIT(0),
3321 .halt_reg = DBG_BUS_VEC_I_REG,
3322 .halt_bit = 13,
3323 },
3324 .parent = &mdp_clk.c,
3325 .c = {
3326 .dbg_name = "lut_mdp_clk",
3327 .ops = &clk_ops_branch,
3328 CLK_INIT(lut_mdp_clk.c),
3329 },
3330};
3331
3332#define F_MDP_VSYNC(f, s, v) \
3333 { \
3334 .freq_hz = f, \
3335 .src_clk = &s##_clk.c, \
3336 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
3337 .sys_vdd = v, \
3338 }
3339static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
3340 F_MDP_VSYNC(27000000, pxo, LOW),
3341 F_END
3342};
3343
3344static struct rcg_clk mdp_vsync_clk = {
3345 .b = {
3346 .ctl_reg = MISC_CC_REG,
3347 .en_mask = BIT(6),
3348 .reset_reg = SW_RESET_CORE_REG,
3349 .reset_mask = BIT(3),
3350 .halt_reg = DBG_BUS_VEC_B_REG,
3351 .halt_bit = 22,
3352 },
3353 .ns_reg = MISC_CC2_REG,
3354 .ns_mask = BIT(13),
3355 .set_rate = set_rate_nop,
3356 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003357 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003358 .c = {
3359 .dbg_name = "mdp_vsync_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003360 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003361 CLK_INIT(mdp_vsync_clk.c),
3362 },
3363};
3364
3365#define F_ROT(f, s, d, v) \
3366 { \
3367 .freq_hz = f, \
3368 .src_clk = &s##_clk.c, \
3369 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
3370 21, 19, 18, 16, s##_to_mm_mux), \
3371 .sys_vdd = v, \
3372 }
3373static struct clk_freq_tbl clk_tbl_rot[] = {
3374 F_ROT( 0, gnd, 1, NONE),
3375 F_ROT( 27000000, pxo, 1, LOW),
3376 F_ROT( 29540000, pll8, 13, LOW),
3377 F_ROT( 32000000, pll8, 12, LOW),
3378 F_ROT( 38400000, pll8, 10, LOW),
3379 F_ROT( 48000000, pll8, 8, LOW),
3380 F_ROT( 54860000, pll8, 7, LOW),
3381 F_ROT( 64000000, pll8, 6, LOW),
3382 F_ROT( 76800000, pll8, 5, LOW),
Matt Wagantall448db0f2011-09-07 10:17:40 -07003383 F_ROT( 96000000, pll8, 4, LOW),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003384 F_ROT(100000000, pll2, 8, NOMINAL),
3385 F_ROT(114290000, pll2, 7, NOMINAL),
3386 F_ROT(133330000, pll2, 6, NOMINAL),
3387 F_ROT(160000000, pll2, 5, NOMINAL),
Stephen Boyd8487f712011-08-29 12:10:09 -07003388 F_ROT(200000000, pll2, 4, NOMINAL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003389 F_END
3390};
3391
3392static struct bank_masks bdiv_info_rot = {
3393 .bank_sel_mask = BIT(30),
3394 .bank0_mask = {
3395 .ns_mask = BM(25, 22) | BM(18, 16),
3396 },
3397 .bank1_mask = {
3398 .ns_mask = BM(29, 26) | BM(21, 19),
3399 },
3400};
3401
3402static struct rcg_clk rot_clk = {
3403 .b = {
3404 .ctl_reg = ROT_CC_REG,
3405 .en_mask = BIT(0),
3406 .reset_reg = SW_RESET_CORE_REG,
3407 .reset_mask = BIT(2),
3408 .halt_reg = DBG_BUS_VEC_C_REG,
3409 .halt_bit = 15,
3410 },
3411 .ns_reg = ROT_NS_REG,
3412 .root_en_mask = BIT(2),
3413 .set_rate = set_rate_div_banked,
3414 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003415 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003416 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003417 .c = {
3418 .dbg_name = "rot_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003419 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003420 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003421 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003422 },
3423};
3424
3425static int hdmi_pll_clk_enable(struct clk *clk)
3426{
3427 int ret;
3428 unsigned long flags;
3429 spin_lock_irqsave(&local_clock_reg_lock, flags);
3430 ret = hdmi_pll_enable();
3431 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3432 return ret;
3433}
3434
3435static void hdmi_pll_clk_disable(struct clk *clk)
3436{
3437 unsigned long flags;
3438 spin_lock_irqsave(&local_clock_reg_lock, flags);
3439 hdmi_pll_disable();
3440 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3441}
3442
3443static unsigned hdmi_pll_clk_get_rate(struct clk *clk)
3444{
3445 return hdmi_pll_get_rate();
3446}
3447
3448static struct clk_ops clk_ops_hdmi_pll = {
3449 .enable = hdmi_pll_clk_enable,
3450 .disable = hdmi_pll_clk_disable,
3451 .get_rate = hdmi_pll_clk_get_rate,
3452 .is_local = local_clk_is_local,
3453};
3454
3455static struct clk hdmi_pll_clk = {
3456 .dbg_name = "hdmi_pll_clk",
3457 .ops = &clk_ops_hdmi_pll,
3458 CLK_INIT(hdmi_pll_clk),
3459};
3460
3461#define F_TV_GND(f, s, p_r, d, m, n, v) \
3462 { \
3463 .freq_hz = f, \
3464 .src_clk = &s##_clk.c, \
3465 .md_val = MD8(8, m, 0, n), \
3466 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3467 .ctl_val = CC(6, n), \
3468 .mnd_en_mask = BIT(5) * !!(n), \
3469 .sys_vdd = v, \
3470 }
3471#define F_TV(f, s, p_r, d, m, n, v) \
3472 { \
3473 .freq_hz = f, \
3474 .src_clk = &s##_clk, \
3475 .md_val = MD8(8, m, 0, n), \
3476 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3477 .ctl_val = CC(6, n), \
3478 .mnd_en_mask = BIT(5) * !!(n), \
3479 .sys_vdd = v, \
3480 .extra_freq_data = (void *)p_r, \
3481 }
3482/* Switching TV freqs requires PLL reconfiguration. */
3483static struct clk_freq_tbl clk_tbl_tv[] = {
3484 F_TV_GND( 0, gnd, 0, 1, 0, 0, NONE),
3485 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0, LOW),
3486 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0, LOW),
3487 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0, LOW),
3488 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0, NOMINAL),
3489 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0, NOMINAL),
3490 F_END
3491};
3492
3493/*
3494 * Unlike other clocks, the TV rate is adjusted through PLL
3495 * re-programming. It is also routed through an MND divider.
3496 */
3497void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
3498{
3499 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
3500 if (pll_rate)
3501 hdmi_pll_set_rate(pll_rate);
3502 set_rate_mnd(clk, nf);
3503}
3504
3505static struct rcg_clk tv_src_clk = {
3506 .ns_reg = TV_NS_REG,
3507 .b = {
3508 .ctl_reg = TV_CC_REG,
3509 .halt_check = NOCHECK,
3510 },
3511 .md_reg = TV_MD_REG,
3512 .root_en_mask = BIT(2),
3513 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
3514 .ctl_mask = BM(7, 6),
3515 .set_rate = set_rate_tv,
3516 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003517 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003518 .c = {
3519 .dbg_name = "tv_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003520 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003521 CLK_INIT(tv_src_clk.c),
3522 },
3523};
3524
3525static struct branch_clk tv_enc_clk = {
3526 .b = {
3527 .ctl_reg = TV_CC_REG,
3528 .en_mask = BIT(8),
3529 .reset_reg = SW_RESET_CORE_REG,
3530 .reset_mask = BIT(0),
3531 .halt_reg = DBG_BUS_VEC_D_REG,
3532 .halt_bit = 9,
3533 },
3534 .parent = &tv_src_clk.c,
3535 .c = {
3536 .dbg_name = "tv_enc_clk",
3537 .ops = &clk_ops_branch,
3538 CLK_INIT(tv_enc_clk.c),
3539 },
3540};
3541
3542static struct branch_clk tv_dac_clk = {
3543 .b = {
3544 .ctl_reg = TV_CC_REG,
3545 .en_mask = BIT(10),
3546 .halt_reg = DBG_BUS_VEC_D_REG,
3547 .halt_bit = 10,
3548 },
3549 .parent = &tv_src_clk.c,
3550 .c = {
3551 .dbg_name = "tv_dac_clk",
3552 .ops = &clk_ops_branch,
3553 CLK_INIT(tv_dac_clk.c),
3554 },
3555};
3556
3557static struct branch_clk mdp_tv_clk = {
3558 .b = {
3559 .ctl_reg = TV_CC_REG,
3560 .en_mask = BIT(0),
3561 .reset_reg = SW_RESET_CORE_REG,
3562 .reset_mask = BIT(4),
3563 .halt_reg = DBG_BUS_VEC_D_REG,
3564 .halt_bit = 12,
3565 },
3566 .parent = &tv_src_clk.c,
3567 .c = {
3568 .dbg_name = "mdp_tv_clk",
3569 .ops = &clk_ops_branch,
3570 CLK_INIT(mdp_tv_clk.c),
3571 },
3572};
3573
3574static struct branch_clk hdmi_tv_clk = {
3575 .b = {
3576 .ctl_reg = TV_CC_REG,
3577 .en_mask = BIT(12),
3578 .reset_reg = SW_RESET_CORE_REG,
3579 .reset_mask = BIT(1),
3580 .halt_reg = DBG_BUS_VEC_D_REG,
3581 .halt_bit = 11,
3582 },
3583 .parent = &tv_src_clk.c,
3584 .c = {
3585 .dbg_name = "hdmi_tv_clk",
3586 .ops = &clk_ops_branch,
3587 CLK_INIT(hdmi_tv_clk.c),
3588 },
3589};
3590
3591static struct branch_clk hdmi_app_clk = {
3592 .b = {
3593 .ctl_reg = MISC_CC2_REG,
3594 .en_mask = BIT(11),
3595 .reset_reg = SW_RESET_CORE_REG,
3596 .reset_mask = BIT(11),
3597 .halt_reg = DBG_BUS_VEC_B_REG,
3598 .halt_bit = 25,
3599 },
3600 .c = {
3601 .dbg_name = "hdmi_app_clk",
3602 .ops = &clk_ops_branch,
3603 CLK_INIT(hdmi_app_clk.c),
3604 },
3605};
3606
3607static struct bank_masks bmnd_info_vcodec = {
3608 .bank_sel_mask = BIT(13),
3609 .bank0_mask = {
3610 .md_reg = VCODEC_MD0_REG,
3611 .ns_mask = BM(18, 11) | BM(2, 0),
3612 .rst_mask = BIT(31),
3613 .mnd_en_mask = BIT(5),
3614 .mode_mask = BM(7, 6),
3615 },
3616 .bank1_mask = {
3617 .md_reg = VCODEC_MD1_REG,
3618 .ns_mask = BM(26, 19) | BM(29, 27),
3619 .rst_mask = BIT(30),
3620 .mnd_en_mask = BIT(10),
3621 .mode_mask = BM(12, 11),
3622 },
3623};
3624#define F_VCODEC(f, s, m, n, v) \
3625 { \
3626 .freq_hz = f, \
3627 .src_clk = &s##_clk.c, \
3628 .md_val = MD8(8, m, 0, n), \
3629 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
3630 .ctl_val = CC_BANKED(6, 11, n), \
3631 .mnd_en_mask = (BIT(10) | BIT(5)) * !!(n), \
3632 .sys_vdd = v, \
3633 }
3634static struct clk_freq_tbl clk_tbl_vcodec[] = {
3635 F_VCODEC( 0, gnd, 0, 0, NONE),
3636 F_VCODEC( 27000000, pxo, 0, 0, LOW),
3637 F_VCODEC( 32000000, pll8, 1, 12, LOW),
3638 F_VCODEC( 48000000, pll8, 1, 8, LOW),
3639 F_VCODEC( 54860000, pll8, 1, 7, LOW),
3640 F_VCODEC( 96000000, pll8, 1, 4, LOW),
3641 F_VCODEC(133330000, pll2, 1, 6, NOMINAL),
3642 F_VCODEC(200000000, pll2, 1, 4, NOMINAL),
3643 F_VCODEC(228570000, pll2, 2, 7, HIGH),
3644 F_END
3645};
3646
3647static struct rcg_clk vcodec_clk = {
3648 .b = {
3649 .ctl_reg = VCODEC_CC_REG,
3650 .en_mask = BIT(0),
3651 .reset_reg = SW_RESET_CORE_REG,
3652 .reset_mask = BIT(6),
3653 .halt_reg = DBG_BUS_VEC_C_REG,
3654 .halt_bit = 29,
3655 },
3656 .ns_reg = VCODEC_NS_REG,
3657 .root_en_mask = BIT(2),
3658 .set_rate = set_rate_mnd_banked,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003659 .bank_info = &bmnd_info_vcodec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003660 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003661 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003662 .c = {
3663 .dbg_name = "vcodec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003664 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003665 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003666 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003667 },
3668};
3669
3670#define F_VPE(f, s, d, v) \
3671 { \
3672 .freq_hz = f, \
3673 .src_clk = &s##_clk.c, \
3674 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
3675 .sys_vdd = v, \
3676 }
3677static struct clk_freq_tbl clk_tbl_vpe[] = {
3678 F_VPE( 0, gnd, 1, NONE),
3679 F_VPE( 27000000, pxo, 1, LOW),
3680 F_VPE( 34909000, pll8, 11, LOW),
3681 F_VPE( 38400000, pll8, 10, LOW),
3682 F_VPE( 64000000, pll8, 6, LOW),
3683 F_VPE( 76800000, pll8, 5, LOW),
3684 F_VPE( 96000000, pll8, 4, NOMINAL),
3685 F_VPE(100000000, pll2, 8, NOMINAL),
3686 F_VPE(160000000, pll2, 5, NOMINAL),
3687 F_END
3688};
3689
3690static struct rcg_clk vpe_clk = {
3691 .b = {
3692 .ctl_reg = VPE_CC_REG,
3693 .en_mask = BIT(0),
3694 .reset_reg = SW_RESET_CORE_REG,
3695 .reset_mask = BIT(17),
3696 .halt_reg = DBG_BUS_VEC_A_REG,
3697 .halt_bit = 28,
3698 },
3699 .ns_reg = VPE_NS_REG,
3700 .root_en_mask = BIT(2),
3701 .ns_mask = (BM(15, 12) | BM(2, 0)),
3702 .set_rate = set_rate_nop,
3703 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003704 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003705 .c = {
3706 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003707 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003708 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003709 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003710 },
3711};
3712
3713#define F_VFE(f, s, d, m, n, v) \
3714 { \
3715 .freq_hz = f, \
3716 .src_clk = &s##_clk.c, \
3717 .md_val = MD8(8, m, 0, n), \
3718 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
3719 .ctl_val = CC(6, n), \
3720 .mnd_en_mask = BIT(5) * !!(n), \
3721 .sys_vdd = v, \
3722 }
3723static struct clk_freq_tbl clk_tbl_vfe[] = {
3724 F_VFE( 0, gnd, 1, 0, 0, NONE),
3725 F_VFE( 13960000, pll8, 1, 2, 55, LOW),
3726 F_VFE( 27000000, pxo, 1, 0, 0, LOW),
3727 F_VFE( 36570000, pll8, 1, 2, 21, LOW),
3728 F_VFE( 38400000, pll8, 2, 1, 5, LOW),
3729 F_VFE( 45180000, pll8, 1, 2, 17, LOW),
3730 F_VFE( 48000000, pll8, 2, 1, 4, LOW),
3731 F_VFE( 54860000, pll8, 1, 1, 7, LOW),
3732 F_VFE( 64000000, pll8, 2, 1, 3, LOW),
3733 F_VFE( 76800000, pll8, 1, 1, 5, LOW),
3734 F_VFE( 96000000, pll8, 2, 1, 2, LOW),
3735 F_VFE(109710000, pll8, 1, 2, 7, LOW),
3736 F_VFE(128000000, pll8, 1, 1, 3, NOMINAL),
3737 F_VFE(153600000, pll8, 1, 2, 5, NOMINAL),
3738 F_VFE(200000000, pll2, 2, 1, 2, NOMINAL),
3739 F_VFE(228570000, pll2, 1, 2, 7, NOMINAL),
3740 F_VFE(266667000, pll2, 1, 1, 3, NOMINAL),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003741 F_VFE(320000000, pll2, 1, 2, 5, HIGH),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003742 F_END
3743};
3744
3745
3746static struct rcg_clk vfe_clk = {
3747 .b = {
3748 .ctl_reg = VFE_CC_REG,
3749 .reset_reg = SW_RESET_CORE_REG,
3750 .reset_mask = BIT(15),
3751 .halt_reg = DBG_BUS_VEC_B_REG,
3752 .halt_bit = 6,
3753 .en_mask = BIT(0),
3754 },
3755 .ns_reg = VFE_NS_REG,
3756 .md_reg = VFE_MD_REG,
3757 .root_en_mask = BIT(2),
3758 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
3759 .ctl_mask = BM(7, 6),
3760 .set_rate = set_rate_mnd,
3761 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003762 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003763 .c = {
3764 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003765 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003766 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003767 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003768 },
3769};
3770
Matt Wagantallc23eee92011-08-16 23:06:52 -07003771static struct branch_clk csi_vfe_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003772 .b = {
3773 .ctl_reg = VFE_CC_REG,
3774 .en_mask = BIT(12),
3775 .reset_reg = SW_RESET_CORE_REG,
3776 .reset_mask = BIT(24),
3777 .halt_reg = DBG_BUS_VEC_B_REG,
3778 .halt_bit = 8,
3779 },
3780 .parent = &vfe_clk.c,
3781 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -07003782 .dbg_name = "csi_vfe_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003783 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -07003784 CLK_INIT(csi_vfe_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003785 },
3786};
3787
3788/*
3789 * Low Power Audio Clocks
3790 */
3791#define F_AIF_OSR(f, s, d, m, n, v) \
3792 { \
3793 .freq_hz = f, \
3794 .src_clk = &s##_clk.c, \
3795 .md_val = MD8(8, m, 0, n), \
3796 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
3797 .mnd_en_mask = BIT(8) * !!(n), \
3798 .sys_vdd = v, \
3799 }
3800static struct clk_freq_tbl clk_tbl_aif_osr[] = {
3801 F_AIF_OSR( 0, gnd, 1, 0, 0, NONE),
3802 F_AIF_OSR( 768000, pll4, 4, 1, 128, LOW),
3803 F_AIF_OSR( 1024000, pll4, 4, 1, 96, LOW),
3804 F_AIF_OSR( 1536000, pll4, 4, 1, 64, LOW),
3805 F_AIF_OSR( 2048000, pll4, 4, 1, 48, LOW),
3806 F_AIF_OSR( 3072000, pll4, 4, 1, 32, LOW),
3807 F_AIF_OSR( 4096000, pll4, 4, 1, 24, LOW),
3808 F_AIF_OSR( 6144000, pll4, 4, 1, 16, LOW),
3809 F_AIF_OSR( 8192000, pll4, 4, 1, 12, LOW),
3810 F_AIF_OSR(12288000, pll4, 4, 1, 8, LOW),
3811 F_AIF_OSR(24576000, pll4, 4, 1, 4, LOW),
3812 F_END
3813};
3814
3815#define CLK_AIF_OSR(i, ns, md, h_r) \
3816 struct rcg_clk i##_clk = { \
3817 .b = { \
3818 .ctl_reg = ns, \
3819 .en_mask = BIT(17), \
3820 .reset_reg = ns, \
3821 .reset_mask = BIT(19), \
3822 .halt_reg = h_r, \
3823 .halt_check = ENABLE, \
3824 .halt_bit = 1, \
3825 }, \
3826 .ns_reg = ns, \
3827 .md_reg = md, \
3828 .root_en_mask = BIT(9), \
3829 .ns_mask = (BM(31, 24) | BM(6, 0)), \
3830 .set_rate = set_rate_mnd, \
3831 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003832 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003833 .c = { \
3834 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003835 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003836 CLK_INIT(i##_clk.c), \
3837 }, \
3838 }
3839#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
3840 struct rcg_clk i##_clk = { \
3841 .b = { \
3842 .ctl_reg = ns, \
3843 .en_mask = BIT(21), \
3844 .reset_reg = ns, \
3845 .reset_mask = BIT(23), \
3846 .halt_reg = h_r, \
3847 .halt_check = ENABLE, \
3848 .halt_bit = 1, \
3849 }, \
3850 .ns_reg = ns, \
3851 .md_reg = md, \
3852 .root_en_mask = BIT(9), \
3853 .ns_mask = (BM(31, 24) | BM(6, 0)), \
3854 .set_rate = set_rate_mnd, \
3855 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003856 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003857 .c = { \
3858 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003859 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003860 CLK_INIT(i##_clk.c), \
3861 }, \
3862 }
3863
3864#define F_AIF_BIT(d, s) \
3865 { \
3866 .freq_hz = d, \
3867 .ns_val = (BVAL(14, 14, s) | BVAL(13, 10, (d-1))) \
3868 }
3869static struct clk_freq_tbl clk_tbl_aif_bit[] = {
3870 F_AIF_BIT(0, 1), /* Use external clock. */
3871 F_AIF_BIT(1, 0), F_AIF_BIT(2, 0), F_AIF_BIT(3, 0), F_AIF_BIT(4, 0),
3872 F_AIF_BIT(5, 0), F_AIF_BIT(6, 0), F_AIF_BIT(7, 0), F_AIF_BIT(8, 0),
3873 F_AIF_BIT(9, 0), F_AIF_BIT(10, 0), F_AIF_BIT(11, 0), F_AIF_BIT(12, 0),
3874 F_AIF_BIT(13, 0), F_AIF_BIT(14, 0), F_AIF_BIT(15, 0), F_AIF_BIT(16, 0),
3875 F_END
3876};
3877
3878#define CLK_AIF_BIT(i, ns, h_r) \
3879 struct rcg_clk i##_clk = { \
3880 .b = { \
3881 .ctl_reg = ns, \
3882 .en_mask = BIT(15), \
3883 .halt_reg = h_r, \
3884 .halt_check = DELAY, \
3885 }, \
3886 .ns_reg = ns, \
3887 .ns_mask = BM(14, 10), \
3888 .set_rate = set_rate_nop, \
3889 .freq_tbl = clk_tbl_aif_bit, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003890 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003891 .c = { \
3892 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003893 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003894 CLK_INIT(i##_clk.c), \
3895 }, \
3896 }
3897
3898#define F_AIF_BIT_D(d, s) \
3899 { \
3900 .freq_hz = d, \
3901 .ns_val = (BVAL(18, 18, s) | BVAL(17, 10, (d-1))) \
3902 }
3903static struct clk_freq_tbl clk_tbl_aif_bit_div[] = {
3904 F_AIF_BIT_D(0, 1), /* Use external clock. */
3905 F_AIF_BIT_D(1, 0), F_AIF_BIT_D(2, 0), F_AIF_BIT_D(3, 0),
3906 F_AIF_BIT_D(4, 0), F_AIF_BIT_D(5, 0), F_AIF_BIT_D(6, 0),
3907 F_AIF_BIT_D(7, 0), F_AIF_BIT_D(8, 0), F_AIF_BIT_D(9, 0),
3908 F_AIF_BIT_D(10, 0), F_AIF_BIT_D(11, 0), F_AIF_BIT_D(12, 0),
3909 F_AIF_BIT_D(13, 0), F_AIF_BIT_D(14, 0), F_AIF_BIT_D(15, 0),
3910 F_AIF_BIT_D(16, 0),
3911 F_END
3912};
3913
3914#define CLK_AIF_BIT_DIV(i, ns, h_r) \
3915 struct rcg_clk i##_clk = { \
3916 .b = { \
3917 .ctl_reg = ns, \
3918 .en_mask = BIT(19), \
3919 .halt_reg = h_r, \
3920 .halt_check = ENABLE, \
3921 }, \
3922 .ns_reg = ns, \
3923 .ns_mask = BM(18, 10), \
3924 .set_rate = set_rate_nop, \
3925 .freq_tbl = clk_tbl_aif_bit_div, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003926 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003927 .c = { \
3928 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003929 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003930 CLK_INIT(i##_clk.c), \
3931 }, \
3932 }
3933
3934static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
3935 LCC_MI2S_STATUS_REG);
3936static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
3937
3938static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
3939 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
3940static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
3941 LCC_CODEC_I2S_MIC_STATUS_REG);
3942
3943static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
3944 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
3945static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
3946 LCC_SPARE_I2S_MIC_STATUS_REG);
3947
3948static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
3949 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
3950static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
3951 LCC_CODEC_I2S_SPKR_STATUS_REG);
3952
3953static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
3954 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
3955static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
3956 LCC_SPARE_I2S_SPKR_STATUS_REG);
3957
3958#define F_PCM(f, s, d, m, n, v) \
3959 { \
3960 .freq_hz = f, \
3961 .src_clk = &s##_clk.c, \
3962 .md_val = MD16(m, n), \
3963 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
3964 .mnd_en_mask = BIT(8) * !!(n), \
3965 .sys_vdd = v, \
3966 }
3967static struct clk_freq_tbl clk_tbl_pcm[] = {
3968 F_PCM( 0, gnd, 1, 0, 0, NONE),
3969 F_PCM( 512000, pll4, 4, 1, 192, LOW),
3970 F_PCM( 768000, pll4, 4, 1, 128, LOW),
3971 F_PCM( 1024000, pll4, 4, 1, 96, LOW),
3972 F_PCM( 1536000, pll4, 4, 1, 64, LOW),
3973 F_PCM( 2048000, pll4, 4, 1, 48, LOW),
3974 F_PCM( 3072000, pll4, 4, 1, 32, LOW),
3975 F_PCM( 4096000, pll4, 4, 1, 24, LOW),
3976 F_PCM( 6144000, pll4, 4, 1, 16, LOW),
3977 F_PCM( 8192000, pll4, 4, 1, 12, LOW),
3978 F_PCM(12288000, pll4, 4, 1, 8, LOW),
3979 F_PCM(24576000, pll4, 4, 1, 4, LOW),
3980 F_END
3981};
3982
3983static struct rcg_clk pcm_clk = {
3984 .b = {
3985 .ctl_reg = LCC_PCM_NS_REG,
3986 .en_mask = BIT(11),
3987 .reset_reg = LCC_PCM_NS_REG,
3988 .reset_mask = BIT(13),
3989 .halt_reg = LCC_PCM_STATUS_REG,
3990 .halt_check = ENABLE,
3991 .halt_bit = 0,
3992 },
3993 .ns_reg = LCC_PCM_NS_REG,
3994 .md_reg = LCC_PCM_MD_REG,
3995 .root_en_mask = BIT(9),
3996 .ns_mask = (BM(31, 16) | BM(6, 0)),
3997 .set_rate = set_rate_mnd,
3998 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003999 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004000 .c = {
4001 .dbg_name = "pcm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004002 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004003 CLK_INIT(pcm_clk.c),
4004 },
4005};
4006
4007static struct rcg_clk audio_slimbus_clk = {
4008 .b = {
4009 .ctl_reg = LCC_SLIMBUS_NS_REG,
4010 .en_mask = BIT(10),
4011 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
4012 .reset_mask = BIT(5),
4013 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4014 .halt_check = ENABLE,
4015 .halt_bit = 0,
4016 },
4017 .ns_reg = LCC_SLIMBUS_NS_REG,
4018 .md_reg = LCC_SLIMBUS_MD_REG,
4019 .root_en_mask = BIT(9),
4020 .ns_mask = (BM(31, 24) | BM(6, 0)),
4021 .set_rate = set_rate_mnd,
4022 .freq_tbl = clk_tbl_aif_osr,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004023 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004024 .c = {
4025 .dbg_name = "audio_slimbus_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004026 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004027 CLK_INIT(audio_slimbus_clk.c),
4028 },
4029};
4030
4031static struct branch_clk sps_slimbus_clk = {
4032 .b = {
4033 .ctl_reg = LCC_SLIMBUS_NS_REG,
4034 .en_mask = BIT(12),
4035 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4036 .halt_check = ENABLE,
4037 .halt_bit = 1,
4038 },
4039 .parent = &audio_slimbus_clk.c,
4040 .c = {
4041 .dbg_name = "sps_slimbus_clk",
4042 .ops = &clk_ops_branch,
4043 CLK_INIT(sps_slimbus_clk.c),
4044 },
4045};
4046
4047static struct branch_clk slimbus_xo_src_clk = {
4048 .b = {
4049 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
4050 .en_mask = BIT(2),
4051 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004052 .halt_bit = 28,
4053 },
4054 .parent = &sps_slimbus_clk.c,
4055 .c = {
4056 .dbg_name = "slimbus_xo_src_clk",
4057 .ops = &clk_ops_branch,
4058 CLK_INIT(slimbus_xo_src_clk.c),
4059 },
4060};
4061
Matt Wagantall735f01a2011-08-12 12:40:28 -07004062DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
4063DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
4064DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
4065DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
4066DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
4067DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
4068DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
4069DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004070
4071static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
4072static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
4073static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
4074static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
4075static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
4076static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
4077static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
4078static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
4079
4080static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
4081/*
4082 * TODO: replace dummy_clk below with ebi1_clk.c once the
4083 * bus driver starts voting on ebi1 rates.
4084 */
4085static DEFINE_CLK_VOTER(ebi1_adm_clk, &dummy_clk);
4086
4087#ifdef CONFIG_DEBUG_FS
4088struct measure_sel {
4089 u32 test_vector;
4090 struct clk *clk;
4091};
4092
Matt Wagantall8b38f942011-08-02 18:23:18 -07004093static DEFINE_CLK_MEASURE(l2_m_clk);
4094static DEFINE_CLK_MEASURE(krait0_m_clk);
4095static DEFINE_CLK_MEASURE(krait1_m_clk);
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004096static DEFINE_CLK_MEASURE(q6sw_clk);
4097static DEFINE_CLK_MEASURE(q6fw_clk);
4098static DEFINE_CLK_MEASURE(q6_func_clk);
Matt Wagantall8b38f942011-08-02 18:23:18 -07004099
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004100static struct measure_sel measure_mux[] = {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004101 { TEST_PER_LS(0x05), &qdss_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004102 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
4103 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
4104 { TEST_PER_LS(0x13), &sdc1_clk.c },
4105 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
4106 { TEST_PER_LS(0x15), &sdc2_clk.c },
4107 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
4108 { TEST_PER_LS(0x17), &sdc3_clk.c },
4109 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
4110 { TEST_PER_LS(0x19), &sdc4_clk.c },
4111 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
4112 { TEST_PER_LS(0x1B), &sdc5_clk.c },
4113 { TEST_PER_LS(0x25), &dfab_clk.c },
4114 { TEST_PER_LS(0x25), &dfab_a_clk.c },
4115 { TEST_PER_LS(0x26), &pmem_clk.c },
4116 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
4117 { TEST_PER_LS(0x33), &cfpb_clk.c },
4118 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
4119 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
4120 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
4121 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
4122 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
4123 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
4124 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
4125 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
4126 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
4127 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
4128 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
4129 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
4130 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
4131 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
4132 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
4133 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
4134 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
4135 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
4136 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
4137 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
4138 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
4139 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
4140 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
4141 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
4142 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
4143 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
4144 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
4145 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
4146 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
4147 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
4148 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
4149 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
4150 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
4151 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
4152 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
4153 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
4154 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
4155 { TEST_PER_LS(0x78), &sfpb_clk.c },
4156 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
4157 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
4158 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
4159 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
4160 { TEST_PER_LS(0x7D), &prng_clk.c },
4161 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
4162 { TEST_PER_LS(0x80), &adm0_p_clk.c },
4163 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
4164 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004165 { TEST_PER_LS(0x86), &usb_hsic_p_clk.c },
4166 { TEST_PER_LS(0x87), &usb_hsic_system_clk.c },
4167 { TEST_PER_LS(0x88), &usb_hsic_xcvr_fs_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004168 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
4169 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
4170 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
4171 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
4172 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
4173 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
4174 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
4175 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
4176 { TEST_PER_LS(0x92), &ce1_p_clk.c },
4177 { TEST_PER_LS(0x94), &tssc_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004178 { TEST_PER_LS(0x9D), &usb_hsic_hsio_cal_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004179 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
4180
4181 { TEST_PER_HS(0x07), &afab_clk.c },
4182 { TEST_PER_HS(0x07), &afab_a_clk.c },
4183 { TEST_PER_HS(0x18), &sfab_clk.c },
4184 { TEST_PER_HS(0x18), &sfab_a_clk.c },
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004185 { TEST_PER_HS(0x26), &q6sw_clk },
4186 { TEST_PER_HS(0x27), &q6fw_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004187 { TEST_PER_HS(0x2A), &adm0_clk.c },
4188 { TEST_PER_HS(0x34), &ebi1_clk.c },
4189 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004190 { TEST_PER_HS(0x48), &qdss_at_clk.c },
4191 { TEST_PER_HS(0x49), &qdss_pclkdbg_clk.c },
4192 { TEST_PER_HS(0x4A), &qdss_traceclkin_clk.c },
4193 { TEST_PER_HS(0x4B), &qdss_tsctr_clk.c },
4194 { TEST_PER_HS(0x4F), &qdss_stm_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004195 { TEST_PER_HS(0x50), &usb_hsic_hsic_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004196
4197 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
4198 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
4199 { TEST_MM_LS(0x02), &cam1_clk.c },
4200 { TEST_MM_LS(0x06), &amp_p_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004201 { TEST_MM_LS(0x07), &csi_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004202 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
4203 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
4204 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
4205 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
4206 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
4207 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
4208 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
4209 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
4210 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
4211 { TEST_MM_LS(0x12), &imem_p_clk.c },
4212 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
4213 { TEST_MM_LS(0x14), &mdp_p_clk.c },
4214 { TEST_MM_LS(0x16), &rot_p_clk.c },
4215 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
4216 { TEST_MM_LS(0x18), &smmu_p_clk.c },
4217 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
4218 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
4219 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
4220 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
4221 { TEST_MM_LS(0x1D), &cam0_clk.c },
4222 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
4223 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
4224 { TEST_MM_LS(0x21), &tv_dac_clk.c },
4225 { TEST_MM_LS(0x22), &tv_enc_clk.c },
4226 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
4227 { TEST_MM_LS(0x25), &mmfpb_clk.c },
4228 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
4229 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004230 { TEST_MM_LS(0x27), &cam2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004231
4232 { TEST_MM_HS(0x00), &csi0_clk.c },
4233 { TEST_MM_HS(0x01), &csi1_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004234 { TEST_MM_HS(0x04), &csi_vfe_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004235 { TEST_MM_HS(0x05), &ijpeg_clk.c },
4236 { TEST_MM_HS(0x06), &vfe_clk.c },
4237 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
4238 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
4239 { TEST_MM_HS(0x09), &gfx3d_clk.c },
4240 { TEST_MM_HS(0x0A), &jpegd_clk.c },
4241 { TEST_MM_HS(0x0B), &vcodec_clk.c },
4242 { TEST_MM_HS(0x0F), &mmfab_clk.c },
4243 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
4244 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
4245 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
4246 { TEST_MM_HS(0x13), &imem_axi_clk.c },
4247 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
4248 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
4249 { TEST_MM_HS(0x16), &rot_axi_clk.c },
4250 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
4251 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
4252 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
4253 { TEST_MM_HS(0x1A), &mdp_clk.c },
4254 { TEST_MM_HS(0x1B), &rot_clk.c },
4255 { TEST_MM_HS(0x1C), &vpe_clk.c },
4256 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
4257 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
4258 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
4259 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
4260 { TEST_MM_HS(0x26), &csi_pix_clk.c },
4261 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
4262 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
4263 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
4264 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
4265 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
4266 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004267 { TEST_MM_HS(0x2D), &csi2_clk.c },
4268 { TEST_MM_HS(0x2E), &csi2_phy_clk.c },
4269 { TEST_MM_HS(0x2F), &csi2phy_timer_clk.c },
4270 { TEST_MM_HS(0x30), &csi_pix1_clk.c },
4271 { TEST_MM_HS(0x31), &csi_rdi1_clk.c },
4272 { TEST_MM_HS(0x32), &csi_rdi2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004273
4274 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
4275 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
4276 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
4277 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
4278 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
4279 { TEST_LPA(0x14), &pcm_clk.c },
4280 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
Matt Wagantall8b38f942011-08-02 18:23:18 -07004281
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004282 { TEST_LPA_HS(0x00), &q6_func_clk },
4283
Matt Wagantall8b38f942011-08-02 18:23:18 -07004284 { TEST_CPUL2(0x1), &l2_m_clk },
4285 { TEST_CPUL2(0x2), &krait0_m_clk },
4286 { TEST_CPUL2(0x3), &krait1_m_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004287};
4288
4289static struct measure_sel *find_measure_sel(struct clk *clk)
4290{
4291 int i;
4292
4293 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
4294 if (measure_mux[i].clk == clk)
4295 return &measure_mux[i];
4296 return NULL;
4297}
4298
Matt Wagantall8b38f942011-08-02 18:23:18 -07004299static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004300{
4301 int ret = 0;
4302 u32 clk_sel;
4303 struct measure_sel *p;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004304 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004305 unsigned long flags;
4306
4307 if (!parent)
4308 return -EINVAL;
4309
4310 p = find_measure_sel(parent);
4311 if (!p)
4312 return -EINVAL;
4313
4314 spin_lock_irqsave(&local_clock_reg_lock, flags);
4315
Matt Wagantall8b38f942011-08-02 18:23:18 -07004316 /*
4317 * Program the test vector, measurement period (sample_ticks)
4318 * and scaling multiplier.
4319 */
4320 clk->sample_ticks = 0x10000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004321 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004322 clk->multiplier = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004323 switch (p->test_vector >> TEST_TYPE_SHIFT) {
4324 case TEST_TYPE_PER_LS:
4325 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
4326 break;
4327 case TEST_TYPE_PER_HS:
4328 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
4329 break;
4330 case TEST_TYPE_MM_LS:
4331 writel_relaxed(0x4030D97, CLK_TEST_REG);
4332 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
4333 break;
4334 case TEST_TYPE_MM_HS:
4335 writel_relaxed(0x402B800, CLK_TEST_REG);
4336 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
4337 break;
4338 case TEST_TYPE_LPA:
4339 writel_relaxed(0x4030D98, CLK_TEST_REG);
4340 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
4341 LCC_CLK_LS_DEBUG_CFG_REG);
4342 break;
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004343 case TEST_TYPE_LPA_HS:
4344 writel_relaxed(0x402BC00, CLK_TEST_REG);
4345 writel_relaxed(BVAL(2, 1, clk_sel)|BIT(0),
4346 LCC_CLK_HS_DEBUG_CFG_REG);
4347 break;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004348 case TEST_TYPE_CPUL2:
4349 writel_relaxed(0x4030400, CLK_TEST_REG);
4350 writel_relaxed(0x80|BVAL(5, 3, clk_sel), GCC_APCS_CLK_DIAG);
4351 clk->sample_ticks = 0x4000;
4352 clk->multiplier = 2;
4353 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004354 default:
4355 ret = -EPERM;
4356 }
4357 /* Make sure test vector is set before starting measurements. */
4358 mb();
4359
4360 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4361
4362 return ret;
4363}
4364
4365/* Sample clock for 'ticks' reference clock ticks. */
4366static u32 run_measurement(unsigned ticks)
4367{
4368 /* Stop counters and set the XO4 counter start value. */
4369 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
4370 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
4371
4372 /* Wait for timer to become ready. */
4373 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
4374 cpu_relax();
4375
4376 /* Run measurement and wait for completion. */
4377 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
4378 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
4379 cpu_relax();
4380
4381 /* Stop counters. */
4382 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
4383
4384 /* Return measured ticks. */
4385 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
4386}
4387
4388
4389/* Perform a hardware rate measurement for a given clock.
4390 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall8b38f942011-08-02 18:23:18 -07004391static unsigned measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004392{
4393 unsigned long flags;
4394 u32 pdm_reg_backup, ringosc_reg_backup;
4395 u64 raw_count_short, raw_count_full;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004396 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004397 unsigned ret;
4398
4399 spin_lock_irqsave(&local_clock_reg_lock, flags);
4400
4401 /* Enable CXO/4 and RINGOSC branch and root. */
4402 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
4403 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
4404 writel_relaxed(0x2898, PDM_CLK_NS_REG);
4405 writel_relaxed(0xA00, RINGOSC_NS_REG);
4406
4407 /*
4408 * The ring oscillator counter will not reset if the measured clock
4409 * is not running. To detect this, run a short measurement before
4410 * the full measurement. If the raw results of the two are the same
4411 * then the clock must be off.
4412 */
4413
4414 /* Run a short measurement. (~1 ms) */
4415 raw_count_short = run_measurement(0x1000);
4416 /* Run a full measurement. (~14 ms) */
Matt Wagantall8b38f942011-08-02 18:23:18 -07004417 raw_count_full = run_measurement(clk->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004418
4419 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
4420 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
4421
4422 /* Return 0 if the clock is off. */
4423 if (raw_count_full == raw_count_short)
4424 ret = 0;
4425 else {
4426 /* Compute rate in Hz. */
4427 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004428 do_div(raw_count_full, ((clk->sample_ticks * 10) + 35));
4429 ret = (raw_count_full * clk->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004430 }
4431
4432 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07004433 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004434 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4435
4436 return ret;
4437}
4438#else /* !CONFIG_DEBUG_FS */
4439static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
4440{
4441 return -EINVAL;
4442}
4443
4444static unsigned measure_clk_get_rate(struct clk *clk)
4445{
4446 return 0;
4447}
4448#endif /* CONFIG_DEBUG_FS */
4449
4450static struct clk_ops measure_clk_ops = {
4451 .set_parent = measure_clk_set_parent,
4452 .get_rate = measure_clk_get_rate,
4453 .is_local = local_clk_is_local,
4454};
4455
Matt Wagantall8b38f942011-08-02 18:23:18 -07004456static struct measure_clk measure_clk = {
4457 .c = {
4458 .dbg_name = "measure_clk",
4459 .ops = &measure_clk_ops,
4460 CLK_INIT(measure_clk.c),
4461 },
4462 .multiplier = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004463};
4464
Stephen Boyd94625ef2011-07-12 17:06:01 -07004465static struct clk_lookup msm_clocks_8960_v1[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004466 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
4467 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
4468 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
4469 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Matt Wagantall8b38f942011-08-02 18:23:18 -07004470 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004471
4472 CLK_LOOKUP("afab_clk", afab_clk.c, NULL),
4473 CLK_LOOKUP("afab_a_clk", afab_a_clk.c, NULL),
4474 CLK_LOOKUP("cfpb_clk", cfpb_clk.c, NULL),
4475 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, NULL),
4476 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
4477 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
4478 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
4479 CLK_LOOKUP("ebi1_a_clk", ebi1_a_clk.c, NULL),
4480 CLK_LOOKUP("mmfab_clk", mmfab_clk.c, NULL),
4481 CLK_LOOKUP("mmfab_a_clk", mmfab_a_clk.c, NULL),
4482 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
4483 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, NULL),
4484 CLK_LOOKUP("sfab_clk", sfab_clk.c, NULL),
4485 CLK_LOOKUP("sfab_a_clk", sfab_a_clk.c, NULL),
4486 CLK_LOOKUP("sfpb_clk", sfpb_clk.c, NULL),
4487 CLK_LOOKUP("sfpb_a_clk", sfpb_a_clk.c, NULL),
4488
Matt Wagantalle2522372011-08-17 14:52:21 -07004489 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
4490 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
4491 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
4492 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
4493 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
4494 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
4495 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
4496 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, NULL),
4497 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, NULL),
4498 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, NULL),
4499 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, NULL),
4500 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004501 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004502 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004503 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
4504 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004505 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
4506 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
4507 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
4508 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, NULL),
4509 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004510 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004511 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004512 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004513 CLK_LOOKUP("pdm_clk", pdm_clk.c, NULL),
Matt Wagantalld86d6832011-08-17 14:06:55 -07004514 CLK_LOOKUP("mem_clk", pmem_clk.c, NULL),
Matt Wagantallc1205292011-08-11 17:19:31 -07004515 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07004516 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
4517 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
4518 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
4519 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
4520 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004521 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07004522 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004523 CLK_LOOKUP("tssc_clk", tssc_clk.c, NULL),
4524 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
4525 CLK_LOOKUP("usb_phy_clk", usb_phy0_clk.c, NULL),
4526 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
4527 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
4528 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
4529 CLK_LOOKUP("usb_fs_clk", usb_fs2_xcvr_clk.c, NULL),
4530 CLK_LOOKUP("usb_fs_sys_clk", usb_fs2_sys_clk.c, NULL),
4531 CLK_LOOKUP("usb_fs_src_clk", usb_fs2_src_clk.c, NULL),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07004532 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qce.0"),
4533 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qce.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004534 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004535 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004536 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004537 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
4538 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07004539 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
4540 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004541 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
4542 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, NULL),
4543 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004544 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07004545 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07004546 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.12"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07004547 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004548 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
4549 CLK_LOOKUP("usb_fs_pclk", usb_fs2_p_clk.c, NULL),
4550 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07004551 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
4552 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
4553 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
4554 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
4555 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07004556 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
4557 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004558 CLK_LOOKUP("pmic_arb_pclk", pmic_arb0_p_clk.c, NULL),
4559 CLK_LOOKUP("pmic_arb_pclk", pmic_arb1_p_clk.c, NULL),
4560 CLK_LOOKUP("pmic_ssbi2", pmic_ssbi2_clk.c, NULL),
4561 CLK_LOOKUP("rpm_msg_ram_pclk", rpm_msg_ram_p_clk.c, NULL),
4562 CLK_LOOKUP("amp_clk", amp_clk.c, NULL),
4563 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
4564 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
4565 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_imx074.0"),
4566 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_ov2720.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07004567 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004568 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, NULL),
4569 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
4570 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07004571 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004572 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_camera_ov2720.0"),
4573 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
4574 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
4575 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07004576 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004577 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov2720.0"),
4578 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, NULL),
4579 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
4580 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07004581 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004582 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_camera_ov2720.0"),
4583 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, NULL),
4584 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, NULL),
4585 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
4586 CLK_LOOKUP("csi0phy_timer_clk", csi0phy_timer_clk.c, NULL),
4587 CLK_LOOKUP("csi1phy_timer_clk", csi1phy_timer_clk.c, NULL),
4588 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
4589 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
4590 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
4591 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
4592 CLK_LOOKUP("gfx2d0_clk", gfx2d0_clk.c, NULL),
4593 CLK_LOOKUP("gfx2d1_clk", gfx2d1_clk.c, NULL),
4594 CLK_LOOKUP("gfx3d_clk", gfx3d_clk.c, NULL),
4595 CLK_LOOKUP("ijpeg_axi_clk", ijpeg_axi_clk.c, NULL),
4596 CLK_LOOKUP("imem_axi_clk", imem_axi_clk.c, NULL),
4597 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
4598 CLK_LOOKUP("jpegd_clk", jpegd_clk.c, NULL),
4599 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
4600 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
4601 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004602 CLK_LOOKUP("qdss_pclk", qdss_p_clk.c, NULL),
4603 CLK_LOOKUP("qdss_at_clk", qdss_at_clk.c, NULL),
4604 CLK_LOOKUP("qdss_pclkdbg_clk", qdss_pclkdbg_clk.c, NULL),
4605 CLK_LOOKUP("qdss_traceclkin_clk", qdss_traceclkin_clk.c, NULL),
4606 CLK_LOOKUP("qdss_tsctr_clk", qdss_tsctr_clk.c, NULL),
4607 CLK_LOOKUP("qdss_stm_clk", qdss_stm_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004608 CLK_LOOKUP("rot_clk", rot_clk.c, NULL),
4609 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
4610 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
4611 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
4612 CLK_LOOKUP("vcodec_clk", vcodec_clk.c, NULL),
4613 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
4614 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
4615 CLK_LOOKUP("hdmi_app_clk", hdmi_app_clk.c, NULL),
4616 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
4617 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantallc23eee92011-08-16 23:06:52 -07004618 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004619 CLK_LOOKUP("vfe_axi_clk", vfe_axi_clk.c, NULL),
4620 CLK_LOOKUP("mdp_axi_clk", mdp_axi_clk.c, NULL),
4621 CLK_LOOKUP("rot_axi_clk", rot_axi_clk.c, NULL),
4622 CLK_LOOKUP("vcodec_axi_clk", vcodec_axi_clk.c, NULL),
4623 CLK_LOOKUP("vcodec_axi_a_clk", vcodec_axi_a_clk.c, NULL),
4624 CLK_LOOKUP("vcodec_axi_b_clk", vcodec_axi_b_clk.c, NULL),
4625 CLK_LOOKUP("vpe_axi_clk", vpe_axi_clk.c, NULL),
4626 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Matt Wagantallc23eee92011-08-16 23:06:52 -07004627 CLK_LOOKUP("csi_pclk", csi_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004628 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
4629 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
4630 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
4631 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
4632 CLK_LOOKUP("gfx2d0_pclk", gfx2d0_p_clk.c, NULL),
4633 CLK_LOOKUP("gfx2d1_pclk", gfx2d1_p_clk.c, NULL),
4634 CLK_LOOKUP("gfx3d_pclk", gfx3d_p_clk.c, NULL),
4635 CLK_LOOKUP("hdmi_m_pclk", hdmi_m_p_clk.c, NULL),
4636 CLK_LOOKUP("hdmi_s_pclk", hdmi_s_p_clk.c, NULL),
4637 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
4638 CLK_LOOKUP("jpegd_pclk", jpegd_p_clk.c, NULL),
4639 CLK_LOOKUP("imem_pclk", imem_p_clk.c, NULL),
4640 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
4641 CLK_LOOKUP("smmu_pclk", smmu_p_clk.c, NULL),
4642 CLK_LOOKUP("rotator_pclk", rot_p_clk.c, NULL),
4643 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
4644 CLK_LOOKUP("vcodec_pclk", vcodec_p_clk.c, NULL),
4645 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
4646 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
4647 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
4648 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
4649 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
4650 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
4651 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
4652 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
4653 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
4654 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
4655 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
4656 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
4657 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
4658 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
4659 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
4660 CLK_LOOKUP("iommu_clk", jpegd_axi_clk.c, "msm_iommu.0"),
4661 CLK_LOOKUP("iommu_clk", vpe_axi_clk.c, "msm_iommu.1"),
4662 CLK_LOOKUP("iommu_clk", mdp_axi_clk.c, "msm_iommu.2"),
4663 CLK_LOOKUP("iommu_clk", mdp_axi_clk.c, "msm_iommu.3"),
4664 CLK_LOOKUP("iommu_clk", rot_axi_clk.c, "msm_iommu.4"),
4665 CLK_LOOKUP("iommu_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
4666 CLK_LOOKUP("iommu_clk", vfe_axi_clk.c, "msm_iommu.6"),
4667 CLK_LOOKUP("iommu_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
4668 CLK_LOOKUP("iommu_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
4669 CLK_LOOKUP("iommu_clk", gfx3d_clk.c, "msm_iommu.9"),
4670 CLK_LOOKUP("iommu_clk", gfx2d0_clk.c, "msm_iommu.10"),
4671 CLK_LOOKUP("iommu_clk", gfx2d1_clk.c, "msm_iommu.11"),
4672 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
4673 CLK_LOOKUP("dfab_usb_hs_clk", dfab_usb_hs_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07004674 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
4675 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
4676 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
4677 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
4678 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Yan He160633e2011-06-30 12:18:56 -07004679 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004680
4681 CLK_LOOKUP("ebi1_msmbus_clk", ebi1_msmbus_clk.c, NULL),
Matt Wagantalle1a86062011-08-18 17:46:10 -07004682 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Matt Wagantall8b38f942011-08-02 18:23:18 -07004683
4684 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
4685 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
4686 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004687 CLK_LOOKUP("q6sw_clk", q6sw_clk, NULL),
4688 CLK_LOOKUP("q6fw_clk", q6fw_clk, NULL),
4689 CLK_LOOKUP("q6_func_clk", q6_func_clk, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004690};
4691
Stephen Boyd94625ef2011-07-12 17:06:01 -07004692static struct clk_lookup msm_clocks_8960_v2[] __initdata = {
4693 CLK_LOOKUP("cam_clk", cam2_clk.c, NULL),
4694 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
4695 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
4696 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, NULL),
4697 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, NULL),
4698 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, NULL),
4699 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
4700 CLK_LOOKUP("csi2phy_timer_clk", csi2phy_timer_clk.c, NULL),
4701 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
4702 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
4703 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
4704 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
4705 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
4706};
4707
4708/* Add v2 clocks dynamically at runtime */
4709static struct clk_lookup msm_clocks_8960[ARRAY_SIZE(msm_clocks_8960_v1) +
4710 ARRAY_SIZE(msm_clocks_8960_v2)];
4711
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004712/*
4713 * Miscellaneous clock register initializations
4714 */
4715
4716/* Read, modify, then write-back a register. */
4717static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
4718{
4719 uint32_t regval = readl_relaxed(reg);
4720 regval &= ~mask;
4721 regval |= val;
4722 writel_relaxed(regval, reg);
4723}
4724
4725static void __init reg_init(void)
4726{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004727 /* Deassert MM SW_RESET_ALL signal. */
4728 writel_relaxed(0, SW_RESET_ALL_REG);
4729
4730 /* Initialize MM AHB registers: Enable the FPB clock and disable HW
4731 * gating for all clocks. Also set VFE_AHB's FORCE_CORE_ON bit to
4732 * prevent its memory from being collapsed when the clock is halted.
4733 * The sleep and wake-up delays are set to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07004734 rmwreg(0x00000003, AHB_EN_REG, 0x6C000103);
4735 writel_relaxed(0x000007F9, AHB_EN2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004736
4737 /* Deassert all locally-owned MM AHB resets. */
4738 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
4739
4740 /* Initialize MM AXI registers: Enable HW gating for all clocks that
4741 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
4742 * delays to safe values. */
4743 /* TODO: Enable HW Gating */
Matt Wagantall53d968f2011-07-19 13:22:53 -07004744 rmwreg(0x000007F9, MAXI_EN_REG, 0x0803FFFF);
4745 rmwreg(0x3027FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
4746 rmwreg(0x0027FCFF, MAXI_EN3_REG, 0x003FFFFF);
4747 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
4748 rmwreg(0x000003C7, SAXI_EN_REG, 0x00003FFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004749
4750 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
4751 * memories retain state even when not clocked. Also, set sleep and
4752 * wake-up delays to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07004753 rmwreg(0x00000000, CSI0_CC_REG, 0x00000410);
4754 rmwreg(0x00000000, CSI1_CC_REG, 0x00000410);
4755 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, 0xE0FF0010);
4756 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, 0xE0FF0010);
4757 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, 0xE0FF0010);
4758 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, 0xE0FF0010);
4759 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
4760 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
4761 rmwreg(0x80FF0000, GFX3D_CC_REG, 0xE0FF0010);
4762 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0010);
4763 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0010);
4764 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
4765 rmwreg(0x80FF0000, MDP_LUT_CC_REG, 0xE0FF0010);
4766 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
4767 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
4768 rmwreg(0x000004FF, TV_CC2_REG, 0x000007FF);
4769 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
4770 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FF4010);
Stephen Boyd94625ef2011-07-12 17:06:01 -07004771 rmwreg(0x800000FF, VFE_CC2_REG, 0xE00000FF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07004772 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004773
4774 /* De-assert MM AXI resets to all hardware blocks. */
4775 writel_relaxed(0, SW_RESET_AXI_REG);
4776
4777 /* Deassert all MM core resets. */
4778 writel_relaxed(0, SW_RESET_CORE_REG);
4779
4780 /* Reset 3D core once more, with its clock enabled. This can
4781 * eventually be done as part of the GDFS footswitch driver. */
4782 clk_set_rate(&gfx3d_clk.c, 27000000);
4783 clk_enable(&gfx3d_clk.c);
4784 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
4785 mb();
4786 udelay(5);
4787 writel_relaxed(0, SW_RESET_CORE_REG);
4788 /* Make sure reset is de-asserted before clock is disabled. */
4789 mb();
4790 clk_disable(&gfx3d_clk.c);
4791
4792 /* Enable TSSC and PDM PXO sources. */
4793 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
4794 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
4795
4796 /* Source SLIMBus xo src from slimbus reference clock */
4797 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
4798
4799 /* Source the dsi_byte_clks from the DSI PHY PLLs */
4800 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
4801 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
4802}
4803
Stephen Boyd94625ef2011-07-12 17:06:01 -07004804struct clock_init_data msm8960_clock_init_data __initdata;
4805
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004806/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07004807static void __init msm8960_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004808{
Stephen Boyd94625ef2011-07-12 17:06:01 -07004809 size_t num_lookups = ARRAY_SIZE(msm_clocks_8960_v1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004810 xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8960");
4811 if (IS_ERR(xo_pxo)) {
4812 pr_err("%s: msm_xo_get(PXO) failed.\n", __func__);
4813 BUG();
4814 }
4815 xo_cxo = msm_xo_get(MSM_XO_TCXO_D0, "clock-8960");
4816 if (IS_ERR(xo_cxo)) {
4817 pr_err("%s: msm_xo_get(CXO) failed.\n", __func__);
4818 BUG();
4819 }
4820
Stephen Boyd94625ef2011-07-12 17:06:01 -07004821 memcpy(msm_clocks_8960, msm_clocks_8960_v1, sizeof(msm_clocks_8960_v1));
4822 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
Tianyi Goubaf6d342011-08-30 21:49:02 -07004823 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_v2;
Stephen Boyd94625ef2011-07-12 17:06:01 -07004824 memcpy(msm_clocks_8960 + ARRAY_SIZE(msm_clocks_8960_v1),
4825 msm_clocks_8960_v2, sizeof(msm_clocks_8960_v2));
4826 num_lookups = ARRAY_SIZE(msm_clocks_8960);
4827 }
4828 msm8960_clock_init_data.size = num_lookups;
4829
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004830 soc_update_sys_vdd = msm8960_update_sys_vdd;
4831 local_vote_sys_vdd(HIGH);
4832
Vikram Mulukutla489e39e2011-08-31 18:04:05 -07004833 clk_ops_pll.enable = sr_pll_clk_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004834
4835 /* Initialize clock registers. */
4836 reg_init();
4837
4838 /* Initialize rates for clocks that only support one. */
4839 clk_set_rate(&pdm_clk.c, 27000000);
4840 clk_set_rate(&prng_clk.c, 64000000);
4841 clk_set_rate(&mdp_vsync_clk.c, 27000000);
4842 clk_set_rate(&tsif_ref_clk.c, 105000);
4843 clk_set_rate(&tssc_clk.c, 27000000);
4844 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
4845 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
4846 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
Stephen Boyd94625ef2011-07-12 17:06:01 -07004847 clk_set_rate(&usb_hsic_xcvr_fs_clk.c, 60000000);
4848 clk_set_rate(&usb_hsic_hsic_src_clk.c, 480000000);
4849 clk_set_rate(&usb_hsic_hsio_cal_clk.c, 9000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004850
4851 /*
4852 * The halt status bits for PDM and TSSC may be incorrect at boot.
4853 * Toggle these clocks on and off to refresh them.
4854 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07004855 rcg_clk_enable(&pdm_clk.c);
4856 rcg_clk_disable(&pdm_clk.c);
4857 rcg_clk_enable(&tssc_clk.c);
4858 rcg_clk_disable(&tssc_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004859
4860 if (machine_is_msm8960_sim()) {
4861 clk_set_rate(&sdc1_clk.c, 48000000);
4862 clk_enable(&sdc1_clk.c);
4863 clk_enable(&sdc1_p_clk.c);
4864 clk_set_rate(&sdc3_clk.c, 48000000);
4865 clk_enable(&sdc3_clk.c);
4866 clk_enable(&sdc3_p_clk.c);
4867 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004868}
4869
Stephen Boydbb600ae2011-08-02 20:11:40 -07004870static int __init msm8960_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004871{
4872 return local_unvote_sys_vdd(HIGH);
4873}
Stephen Boydbb600ae2011-08-02 20:11:40 -07004874
4875struct clock_init_data msm8960_clock_init_data __initdata = {
4876 .table = msm_clocks_8960,
4877 .size = ARRAY_SIZE(msm_clocks_8960),
4878 .init = msm8960_clock_init,
4879 .late_init = msm8960_clock_late_init,
4880};