blob: 38ea5705aa5b07f7e8e8cd556e117d7338fba82d [file] [log] [blame]
Manu Gautam5143b252012-01-05 19:25:23 -08001/* Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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. */
Stephen Boyda52d7e32011-11-10 11:59:00 -080044#define ADM0_PBUS_CLK_CTL_REG REG(0x2208)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070045#define CE1_HCLK_CTL_REG REG(0x2720)
46#define CE1_CORE_CLK_CTL_REG REG(0x2724)
Tianyi Gou05e01102012-02-08 22:15:49 -080047#define PRNG_CLK_NS_REG REG(0x2E80)
Tianyi Gou41515e22011-09-01 19:37:43 -070048#define CE3_HCLK_CTL_REG REG(0x36C4)
49#define CE3_CORE_CLK_CTL_REG REG(0x36CC)
50#define CE3_CLK_SRC_NS_REG REG(0x36C0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#define DMA_BAM_HCLK_CTL REG(0x25C0)
Tianyi Gou41515e22011-09-01 19:37:43 -070052#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070053#define CLK_HALT_CFPB_STATEA_REG REG(0x2FCC)
54#define CLK_HALT_CFPB_STATEB_REG REG(0x2FD0)
55#define CLK_HALT_CFPB_STATEC_REG REG(0x2FD4)
56#define CLK_HALT_DFAB_STATE_REG REG(0x2FC8)
Tianyi Gou41515e22011-09-01 19:37:43 -070057/* 8064 name CLK_HALT_GSS_KPSS_MISC_STATE_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058#define CLK_HALT_MSS_SMPSS_MISC_STATE_REG REG(0x2FDC)
59#define CLK_HALT_SFPB_MISC_STATE_REG REG(0x2FD8)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070060#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061#define CLK_TEST_REG REG(0x2FA0)
Matt Wagantall7625a4c2011-11-01 16:17:53 -070062#define GPn_MD_REG(n) REG(0x2D00+(0x20*(n)))
63#define GPn_NS_REG(n) REG(0x2D24+(0x20*(n)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064#define GSBIn_HCLK_CTL_REG(n) REG(0x29C0+(0x20*((n)-1)))
65#define GSBIn_QUP_APPS_MD_REG(n) REG(0x29C8+(0x20*((n)-1)))
66#define GSBIn_QUP_APPS_NS_REG(n) REG(0x29CC+(0x20*((n)-1)))
67#define GSBIn_RESET_REG(n) REG(0x29DC+(0x20*((n)-1)))
68#define GSBIn_UART_APPS_MD_REG(n) REG(0x29D0+(0x20*((n)-1)))
69#define GSBIn_UART_APPS_NS_REG(n) REG(0x29D4+(0x20*((n)-1)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070#define PDM_CLK_NS_REG REG(0x2CC0)
Tianyi Gou41515e22011-09-01 19:37:43 -070071/* 8064 name BB_PLL_ENA_APCS_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070072#define BB_PLL_ENA_SC0_REG REG(0x34C0)
Tianyi Gou59608a72012-01-31 22:19:30 -080073#define BB_PLL_ENA_RPM_REG REG(0x34A0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070074#define BB_PLL0_STATUS_REG REG(0x30D8)
75#define BB_PLL5_STATUS_REG REG(0x30F8)
76#define BB_PLL6_STATUS_REG REG(0x3118)
77#define BB_PLL7_STATUS_REG REG(0x3138)
78#define BB_PLL8_L_VAL_REG REG(0x3144)
79#define BB_PLL8_M_VAL_REG REG(0x3148)
80#define BB_PLL8_MODE_REG REG(0x3140)
81#define BB_PLL8_N_VAL_REG REG(0x314C)
82#define BB_PLL8_STATUS_REG REG(0x3158)
83#define BB_PLL8_CONFIG_REG REG(0x3154)
84#define BB_PLL8_TEST_CTL_REG REG(0x3150)
Stephen Boyd94625ef2011-07-12 17:06:01 -070085#define BB_MMCC_PLL2_MODE_REG REG(0x3160)
86#define BB_MMCC_PLL2_TEST_CTL_REG REG(0x3170)
Tianyi Gou41515e22011-09-01 19:37:43 -070087#define BB_PLL14_MODE_REG REG(0x31C0)
88#define BB_PLL14_L_VAL_REG REG(0x31C4)
89#define BB_PLL14_M_VAL_REG REG(0x31C8)
90#define BB_PLL14_N_VAL_REG REG(0x31CC)
91#define BB_PLL14_TEST_CTL_REG REG(0x31D0)
92#define BB_PLL14_CONFIG_REG REG(0x31D4)
Stephen Boyd94625ef2011-07-12 17:06:01 -070093#define BB_PLL14_STATUS_REG REG(0x31D8)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094#define PLLTEST_PAD_CFG_REG REG(0x2FA4)
95#define PMEM_ACLK_CTL_REG REG(0x25A0)
96#define RINGOSC_NS_REG REG(0x2DC0)
97#define RINGOSC_STATUS_REG REG(0x2DCC)
98#define RINGOSC_TCXO_CTL_REG REG(0x2DC4)
Stephen Boyda52d7e32011-11-10 11:59:00 -080099#define RPM_MSG_RAM_HCLK_CTL_REG REG(0x27E0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100#define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080)
101#define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1)))
102#define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1)))
103#define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1)))
104#define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1)))
105#define SLIMBUS_XO_SRC_CLK_CTL_REG REG(0x2628)
106#define TSIF_HCLK_CTL_REG REG(0x2700)
107#define TSIF_REF_CLK_MD_REG REG(0x270C)
108#define TSIF_REF_CLK_NS_REG REG(0x2710)
109#define TSSC_CLK_CTL_REG REG(0x2CA0)
Tianyi Gou41515e22011-09-01 19:37:43 -0700110#define SATA_CLK_SRC_NS_REG REG(0x2C08)
111#define SATA_RXOOB_CLK_CTL_REG REG(0x2C0C)
112#define SATA_PMALIVE_CLK_CTL_REG REG(0x2C10)
113#define SATA_PHY_REF_CLK_CTL_REG REG(0x2C14)
114#define SATA_PHY_CFG_CLK_CTL_REG REG(0x2C40)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700115#define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1)))
116#define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1)))
117#define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1)))
118#define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1)))
119#define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1)))
120#define USB_HS1_HCLK_CTL_REG REG(0x2900)
Tianyi Gou41515e22011-09-01 19:37:43 -0700121#define USB_HS1_HCLK_FS_REG REG(0x2904)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700122#define USB_HS1_RESET_REG REG(0x2910)
123#define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908)
124#define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700125#define USB_HS3_HCLK_CTL_REG REG(0x3700)
126#define USB_HS3_HCLK_FS_REG REG(0x3704)
127#define USB_HS3_RESET_REG REG(0x3710)
128#define USB_HS3_XCVR_FS_CLK_MD_REG REG(0X3708)
129#define USB_HS3_XCVR_FS_CLK_NS_REG REG(0X370C)
130#define USB_HS4_HCLK_CTL_REG REG(0x3720)
131#define USB_HS4_HCLK_FS_REG REG(0x3724)
132#define USB_HS4_RESET_REG REG(0x3730)
133#define USB_HS4_XCVR_FS_CLK_MD_REG REG(0X3728)
134#define USB_HS4_XCVR_FS_CLK_NS_REG REG(0X372C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700135#define USB_HSIC_HCLK_CTL_REG REG(0x2920)
136#define USB_HSIC_HSIC_CLK_CTL_REG REG(0x2B44)
137#define USB_HSIC_HSIC_CLK_SRC_CTL_REG REG(0x2B40)
138#define USB_HSIC_HSIO_CAL_CLK_CTL_REG REG(0x2B48)
139#define USB_HSIC_RESET_REG REG(0x2934)
140#define USB_HSIC_SYSTEM_CLK_CTL_REG REG(0x292C)
141#define USB_HSIC_XCVR_FS_CLK_MD_REG REG(0x2924)
142#define USB_HSIC_XCVR_FS_CLK_NS_REG REG(0x2928)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700143#define USB_PHY0_RESET_REG REG(0x2E20)
Tianyi Gou41515e22011-09-01 19:37:43 -0700144#define PCIE_ALT_REF_CLK_NS_REG REG(0x3860)
145#define PCIE_HCLK_CTL_REG REG(0x22CC)
146#define GPLL1_MODE_REG REG(0x3160)
147#define GPLL1_L_VAL_REG REG(0x3164)
148#define GPLL1_M_VAL_REG REG(0x3168)
149#define GPLL1_N_VAL_REG REG(0x316C)
150#define GPLL1_CONFIG_REG REG(0x3174)
151#define GPLL1_STATUS_REG REG(0x3178)
152#define PXO_SRC_CLK_CTL_REG REG(0x2EA0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153
154/* Multimedia clock registers. */
155#define AHB_EN_REG REG_MM(0x0008)
156#define AHB_EN2_REG REG_MM(0x0038)
Tianyi Gou41515e22011-09-01 19:37:43 -0700157#define AHB_EN3_REG REG_MM(0x0248)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700158#define AHB_NS_REG REG_MM(0x0004)
159#define AXI_NS_REG REG_MM(0x0014)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700160#define CAMCLK0_NS_REG REG_MM(0x0148)
161#define CAMCLK0_CC_REG REG_MM(0x0140)
162#define CAMCLK0_MD_REG REG_MM(0x0144)
163#define CAMCLK1_NS_REG REG_MM(0x015C)
164#define CAMCLK1_CC_REG REG_MM(0x0154)
165#define CAMCLK1_MD_REG REG_MM(0x0158)
166#define CAMCLK2_NS_REG REG_MM(0x0228)
167#define CAMCLK2_CC_REG REG_MM(0x0220)
168#define CAMCLK2_MD_REG REG_MM(0x0224)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700169#define CSI0_NS_REG REG_MM(0x0048)
170#define CSI0_CC_REG REG_MM(0x0040)
171#define CSI0_MD_REG REG_MM(0x0044)
172#define CSI1_NS_REG REG_MM(0x0010)
173#define CSI1_CC_REG REG_MM(0x0024)
174#define CSI1_MD_REG REG_MM(0x0028)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700175#define CSI2_NS_REG REG_MM(0x0234)
176#define CSI2_CC_REG REG_MM(0x022C)
177#define CSI2_MD_REG REG_MM(0x0230)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700178#define CSIPHYTIMER_CC_REG REG_MM(0x0160)
179#define CSIPHYTIMER_MD_REG REG_MM(0x0164)
180#define CSIPHYTIMER_NS_REG REG_MM(0x0168)
181#define DSI1_BYTE_NS_REG REG_MM(0x00B0)
182#define DSI1_BYTE_CC_REG REG_MM(0x0090)
183#define DSI2_BYTE_NS_REG REG_MM(0x00BC)
184#define DSI2_BYTE_CC_REG REG_MM(0x00B4)
185#define DSI1_ESC_NS_REG REG_MM(0x011C)
186#define DSI1_ESC_CC_REG REG_MM(0x00CC)
187#define DSI2_ESC_NS_REG REG_MM(0x0150)
188#define DSI2_ESC_CC_REG REG_MM(0x013C)
189#define DSI_PIXEL_CC_REG REG_MM(0x0130)
190#define DSI2_PIXEL_CC_REG REG_MM(0x0094)
191#define DBG_BUS_VEC_A_REG REG_MM(0x01C8)
192#define DBG_BUS_VEC_B_REG REG_MM(0x01CC)
193#define DBG_BUS_VEC_C_REG REG_MM(0x01D0)
194#define DBG_BUS_VEC_D_REG REG_MM(0x01D4)
195#define DBG_BUS_VEC_E_REG REG_MM(0x01D8)
196#define DBG_BUS_VEC_F_REG REG_MM(0x01DC)
197#define DBG_BUS_VEC_G_REG REG_MM(0x01E0)
198#define DBG_BUS_VEC_H_REG REG_MM(0x01E4)
199#define DBG_BUS_VEC_I_REG REG_MM(0x01E8)
Tianyi Gou41515e22011-09-01 19:37:43 -0700200#define DBG_BUS_VEC_J_REG REG_MM(0x0240)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700201#define DBG_CFG_REG_HS_REG REG_MM(0x01B4)
202#define DBG_CFG_REG_LS_REG REG_MM(0x01B8)
203#define GFX2D0_CC_REG REG_MM(0x0060)
204#define GFX2D0_MD0_REG REG_MM(0x0064)
205#define GFX2D0_MD1_REG REG_MM(0x0068)
206#define GFX2D0_NS_REG REG_MM(0x0070)
207#define GFX2D1_CC_REG REG_MM(0x0074)
208#define GFX2D1_MD0_REG REG_MM(0x0078)
209#define GFX2D1_MD1_REG REG_MM(0x006C)
210#define GFX2D1_NS_REG REG_MM(0x007C)
211#define GFX3D_CC_REG REG_MM(0x0080)
212#define GFX3D_MD0_REG REG_MM(0x0084)
213#define GFX3D_MD1_REG REG_MM(0x0088)
214#define GFX3D_NS_REG REG_MM(0x008C)
215#define IJPEG_CC_REG REG_MM(0x0098)
216#define IJPEG_MD_REG REG_MM(0x009C)
217#define IJPEG_NS_REG REG_MM(0x00A0)
218#define JPEGD_CC_REG REG_MM(0x00A4)
219#define JPEGD_NS_REG REG_MM(0x00AC)
Tianyi Gou41515e22011-09-01 19:37:43 -0700220#define VCAP_CC_REG REG_MM(0x0178)
221#define VCAP_NS_REG REG_MM(0x021C)
222#define VCAP_MD0_REG REG_MM(0x01EC)
223#define VCAP_MD1_REG REG_MM(0x0218)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700224#define MAXI_EN_REG REG_MM(0x0018)
225#define MAXI_EN2_REG REG_MM(0x0020)
226#define MAXI_EN3_REG REG_MM(0x002C)
227#define MAXI_EN4_REG REG_MM(0x0114)
Tianyi Gou41515e22011-09-01 19:37:43 -0700228#define MAXI_EN5_REG REG_MM(0x0244)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700229#define MDP_CC_REG REG_MM(0x00C0)
230#define MDP_LUT_CC_REG REG_MM(0x016C)
231#define MDP_MD0_REG REG_MM(0x00C4)
232#define MDP_MD1_REG REG_MM(0x00C8)
233#define MDP_NS_REG REG_MM(0x00D0)
234#define MISC_CC_REG REG_MM(0x0058)
235#define MISC_CC2_REG REG_MM(0x005C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700236#define MISC_CC3_REG REG_MM(0x0238)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700237#define MM_PLL1_MODE_REG REG_MM(0x031C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700238#define MM_PLL1_L_VAL_REG REG_MM(0x0320)
239#define MM_PLL1_M_VAL_REG REG_MM(0x0324)
240#define MM_PLL1_N_VAL_REG REG_MM(0x0328)
241#define MM_PLL1_CONFIG_REG REG_MM(0x032C)
242#define MM_PLL1_TEST_CTL_REG REG_MM(0x0330)
243#define MM_PLL1_STATUS_REG REG_MM(0x0334)
244#define MM_PLL3_MODE_REG REG_MM(0x0338)
Tianyi Gou621f8742011-09-01 21:45:01 -0700245#define MM_PLL3_L_VAL_REG REG_MM(0x033C)
246#define MM_PLL3_M_VAL_REG REG_MM(0x0340)
247#define MM_PLL3_N_VAL_REG REG_MM(0x0344)
248#define MM_PLL3_CONFIG_REG REG_MM(0x0348)
249#define MM_PLL3_TEST_CTL_REG REG_MM(0x034C)
250#define MM_PLL3_STATUS_REG REG_MM(0x0350)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700251#define ROT_CC_REG REG_MM(0x00E0)
252#define ROT_NS_REG REG_MM(0x00E8)
253#define SAXI_EN_REG REG_MM(0x0030)
254#define SW_RESET_AHB_REG REG_MM(0x020C)
255#define SW_RESET_AHB2_REG REG_MM(0x0200)
256#define SW_RESET_ALL_REG REG_MM(0x0204)
257#define SW_RESET_AXI_REG REG_MM(0x0208)
258#define SW_RESET_CORE_REG REG_MM(0x0210)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700259#define SW_RESET_CORE2_REG REG_MM(0x0214)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700260#define TV_CC_REG REG_MM(0x00EC)
261#define TV_CC2_REG REG_MM(0x0124)
262#define TV_MD_REG REG_MM(0x00F0)
263#define TV_NS_REG REG_MM(0x00F4)
264#define VCODEC_CC_REG REG_MM(0x00F8)
265#define VCODEC_MD0_REG REG_MM(0x00FC)
266#define VCODEC_MD1_REG REG_MM(0x0128)
267#define VCODEC_NS_REG REG_MM(0x0100)
268#define VFE_CC_REG REG_MM(0x0104)
269#define VFE_MD_REG REG_MM(0x0108)
270#define VFE_NS_REG REG_MM(0x010C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700271#define VFE_CC2_REG REG_MM(0x023C)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700272#define VPE_CC_REG REG_MM(0x0110)
273#define VPE_NS_REG REG_MM(0x0118)
274
275/* Low-power Audio clock registers. */
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700276#define LCC_CLK_HS_DEBUG_CFG_REG REG_LPA(0x00A4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700277#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
278#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
279#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
280#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
281#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
282#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
283#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
284#define LCC_MI2S_MD_REG REG_LPA(0x004C)
285#define LCC_MI2S_NS_REG REG_LPA(0x0048)
286#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
287#define LCC_PCM_MD_REG REG_LPA(0x0058)
288#define LCC_PCM_NS_REG REG_LPA(0x0054)
289#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700290#define LCC_PLL0_MODE_REG REG_LPA(0x0000)
291#define LCC_PLL0_L_VAL_REG REG_LPA(0x0004)
292#define LCC_PLL0_M_VAL_REG REG_LPA(0x0008)
293#define LCC_PLL0_N_VAL_REG REG_LPA(0x000C)
294#define LCC_PLL0_CONFIG_REG REG_LPA(0x0014)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700295#define LCC_PLL0_STATUS_REG REG_LPA(0x0018)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700296#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
297#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
298#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
299#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
300#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
301#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
302#define LCC_SLIMBUS_NS_REG REG_LPA(0x00CC)
303#define LCC_SLIMBUS_MD_REG REG_LPA(0x00D0)
304#define LCC_SLIMBUS_STATUS_REG REG_LPA(0x00D4)
305#define LCC_AHBEX_BRANCH_CTL_REG REG_LPA(0x00E4)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700306#define LCC_PRI_PLL_CLK_CTL_REG REG_LPA(0x00C4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700307
Matt Wagantall8b38f942011-08-02 18:23:18 -0700308#define GCC_APCS_CLK_DIAG REG_GCC(0x001C)
309
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700310/* MUX source input identifiers. */
311#define pxo_to_bb_mux 0
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700312#define cxo_to_bb_mux 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700313#define pll0_to_bb_mux 2
314#define pll8_to_bb_mux 3
315#define pll6_to_bb_mux 4
316#define gnd_to_bb_mux 5
Stephen Boyd94625ef2011-07-12 17:06:01 -0700317#define pll3_to_bb_mux 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700318#define pxo_to_mm_mux 0
319#define pll1_to_mm_mux 1
Tianyi Gou41515e22011-09-01 19:37:43 -0700320#define pll2_to_mm_mux 1 /* or MMCC_PLL1 */
321#define pll8_to_mm_mux 2 /* or GCC_PERF */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700322#define pll0_to_mm_mux 3
Tianyi Gou41515e22011-09-01 19:37:43 -0700323#define pll15_to_mm_mux 3 /* or MM_PLL3 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700324#define gnd_to_mm_mux 4
Stephen Boyd7a776cd2011-10-20 12:46:04 -0700325#define pll3_to_mm_mux 3 /* or MMCC_PLL2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700326#define hdmi_pll_to_mm_mux 3
327#define cxo_to_xo_mux 0
328#define pxo_to_xo_mux 1
329#define gnd_to_xo_mux 3
330#define pxo_to_lpa_mux 0
331#define cxo_to_lpa_mux 1
332#define pll4_to_lpa_mux 2
333#define gnd_to_lpa_mux 6
Tianyi Gou41515e22011-09-01 19:37:43 -0700334#define pxo_to_pcie_mux 0
335#define pll3_to_pcie_mux 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700336
337/* Test Vector Macros */
338#define TEST_TYPE_PER_LS 1
339#define TEST_TYPE_PER_HS 2
340#define TEST_TYPE_MM_LS 3
341#define TEST_TYPE_MM_HS 4
342#define TEST_TYPE_LPA 5
Matt Wagantall8b38f942011-08-02 18:23:18 -0700343#define TEST_TYPE_CPUL2 6
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700344#define TEST_TYPE_LPA_HS 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700345#define TEST_TYPE_SHIFT 24
346#define TEST_CLK_SEL_MASK BM(23, 0)
347#define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s)))
348#define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS)
349#define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS)
350#define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS)
351#define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS)
352#define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA)
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700353#define TEST_LPA_HS(s) TEST_VECTOR((s), TEST_TYPE_LPA_HS)
Matt Wagantall8b38f942011-08-02 18:23:18 -0700354#define TEST_CPUL2(s) TEST_VECTOR((s), TEST_TYPE_CPUL2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700355
356#define MN_MODE_DUAL_EDGE 0x2
357
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700358struct pll_rate {
359 const uint32_t l_val;
360 const uint32_t m_val;
361 const uint32_t n_val;
362 const uint32_t vco;
363 const uint32_t post_div;
364 const uint32_t i_bits;
365};
366#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
367
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700368enum vdd_dig_levels {
369 VDD_DIG_NONE,
370 VDD_DIG_LOW,
371 VDD_DIG_NOMINAL,
372 VDD_DIG_HIGH
373};
374
Saravana Kannan298ec392012-02-08 19:21:47 -0800375static int set_vdd_dig_8960(struct clk_vdd_class *vdd_class, int level)
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700376{
377 static const int vdd_uv[] = {
378 [VDD_DIG_NONE] = 0,
379 [VDD_DIG_LOW] = 945000,
380 [VDD_DIG_NOMINAL] = 1050000,
381 [VDD_DIG_HIGH] = 1150000
382 };
Saravana Kannan298ec392012-02-08 19:21:47 -0800383 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700384 vdd_uv[level], 1150000, 1);
385}
386
Saravana Kannan298ec392012-02-08 19:21:47 -0800387static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig_8960);
388
389static int set_vdd_dig_8930(struct clk_vdd_class *vdd_class, int level)
390{
391 static const int vdd_uv[] = {
392 [VDD_DIG_NONE] = 0,
393 [VDD_DIG_LOW] = 945000,
394 [VDD_DIG_NOMINAL] = 1050000,
395 [VDD_DIG_HIGH] = 1150000
396 };
397 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8038_S1, RPM_VREG_VOTER3,
398 vdd_uv[level], 1150000, 1);
399}
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700400
401#define VDD_DIG_FMAX_MAP1(l1, f1) \
402 .vdd_class = &vdd_dig, \
403 .fmax[VDD_DIG_##l1] = (f1)
404#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
405 .vdd_class = &vdd_dig, \
406 .fmax[VDD_DIG_##l1] = (f1), \
407 .fmax[VDD_DIG_##l2] = (f2)
408#define VDD_DIG_FMAX_MAP3(l1, f1, l2, f2, l3, f3) \
409 .vdd_class = &vdd_dig, \
410 .fmax[VDD_DIG_##l1] = (f1), \
411 .fmax[VDD_DIG_##l2] = (f2), \
412 .fmax[VDD_DIG_##l3] = (f3)
413
Tianyi Goue1faaf22012-01-24 16:07:19 -0800414enum vdd_sr2_pll_levels {
415 VDD_SR2_PLL_OFF,
416 VDD_SR2_PLL_ON
Matt Wagantallc57577d2011-10-06 17:06:53 -0700417};
418
Saravana Kannan298ec392012-02-08 19:21:47 -0800419static int set_vdd_sr2_pll_8960(struct clk_vdd_class *vdd_class, int level)
Matt Wagantallc57577d2011-10-06 17:06:53 -0700420{
Tianyi Goubf3d0b12012-01-23 14:37:28 -0800421 int rc = 0;
Saravana Kannan298ec392012-02-08 19:21:47 -0800422
423 if (level == VDD_SR2_PLL_OFF) {
424 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
425 RPM_VREG_VOTER3, 0, 0, 1);
426 if (rc)
427 return rc;
428 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
429 RPM_VREG_VOTER3, 0, 0, 1);
430 if (rc)
431 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
432 RPM_VREG_VOTER3, 1800000, 1800000, 1);
Tianyi Goue1faaf22012-01-24 16:07:19 -0800433 } else {
Saravana Kannan298ec392012-02-08 19:21:47 -0800434 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
435 RPM_VREG_VOTER3, 2100000, 2100000, 1);
436 if (rc)
437 return rc;
438 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
439 RPM_VREG_VOTER3, 1800000, 1800000, 1);
440 if (rc)
441 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
Tianyi Goubf3d0b12012-01-23 14:37:28 -0800442 RPM_VREG_VOTER3, 0, 0, 1);
Matt Wagantallc57577d2011-10-06 17:06:53 -0700443 }
444
445 return rc;
446}
447
Saravana Kannan298ec392012-02-08 19:21:47 -0800448static DEFINE_VDD_CLASS(vdd_sr2_pll, set_vdd_sr2_pll_8960);
449
450static int sr2_lreg_uv[] = {
451 [VDD_SR2_PLL_OFF] = 0,
452 [VDD_SR2_PLL_ON] = 1800000,
453};
454
455static int set_vdd_sr2_pll_8064(struct clk_vdd_class *vdd_class, int level)
456{
457 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_LVS7, RPM_VREG_VOTER3,
458 sr2_lreg_uv[level], sr2_lreg_uv[level], 1);
459}
460
461static int set_vdd_sr2_pll_8930(struct clk_vdd_class *vdd_class, int level)
462{
463 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8038_L23, RPM_VREG_VOTER3,
464 sr2_lreg_uv[level], sr2_lreg_uv[level], 1);
465}
Matt Wagantallc57577d2011-10-06 17:06:53 -0700466
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700467/*
468 * Clock Descriptions
469 */
470
471static struct msm_xo_voter *xo_pxo, *xo_cxo;
472
473static int pxo_clk_enable(struct clk *clk)
474{
475 return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON);
476}
477
478static void pxo_clk_disable(struct clk *clk)
479{
Tianyi Gou41515e22011-09-01 19:37:43 -0700480 msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700481}
482
483static struct clk_ops clk_ops_pxo = {
484 .enable = pxo_clk_enable,
485 .disable = pxo_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700486 .is_local = local_clk_is_local,
487};
488
489static struct fixed_clk pxo_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700490 .c = {
491 .dbg_name = "pxo_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800492 .rate = 27000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700493 .ops = &clk_ops_pxo,
494 CLK_INIT(pxo_clk.c),
495 },
496};
497
498static int cxo_clk_enable(struct clk *clk)
499{
500 return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON);
501}
502
503static void cxo_clk_disable(struct clk *clk)
504{
505 msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF);
506}
507
508static struct clk_ops clk_ops_cxo = {
509 .enable = cxo_clk_enable,
510 .disable = cxo_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700511 .is_local = local_clk_is_local,
512};
513
514static struct fixed_clk cxo_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700515 .c = {
516 .dbg_name = "cxo_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800517 .rate = 19200000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700518 .ops = &clk_ops_cxo,
519 CLK_INIT(cxo_clk.c),
520 },
521};
522
523static struct pll_clk pll2_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700524 .mode_reg = MM_PLL1_MODE_REG,
525 .parent = &pxo_clk.c,
526 .c = {
527 .dbg_name = "pll2_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800528 .rate = 800000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700529 .ops = &clk_ops_pll,
530 CLK_INIT(pll2_clk.c),
531 },
532};
533
Stephen Boyd94625ef2011-07-12 17:06:01 -0700534static struct pll_clk pll3_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -0700535 .mode_reg = BB_MMCC_PLL2_MODE_REG,
536 .parent = &pxo_clk.c,
537 .c = {
538 .dbg_name = "pll3_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800539 .rate = 1200000000,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700540 .ops = &clk_ops_pll,
Tianyi Goue1faaf22012-01-24 16:07:19 -0800541 .vdd_class = &vdd_sr2_pll,
542 .fmax[VDD_SR2_PLL_ON] = ULONG_MAX,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700543 CLK_INIT(pll3_clk.c),
544 },
545};
546
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700547static struct pll_vote_clk pll4_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700548 .en_reg = BB_PLL_ENA_SC0_REG,
549 .en_mask = BIT(4),
550 .status_reg = LCC_PLL0_STATUS_REG,
551 .parent = &pxo_clk.c,
552 .c = {
553 .dbg_name = "pll4_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800554 .rate = 393216000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700555 .ops = &clk_ops_pll_vote,
556 CLK_INIT(pll4_clk.c),
557 },
558};
559
560static struct pll_vote_clk pll8_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700561 .en_reg = BB_PLL_ENA_SC0_REG,
562 .en_mask = BIT(8),
563 .status_reg = BB_PLL8_STATUS_REG,
564 .parent = &pxo_clk.c,
565 .c = {
566 .dbg_name = "pll8_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800567 .rate = 384000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700568 .ops = &clk_ops_pll_vote,
569 CLK_INIT(pll8_clk.c),
570 },
571};
572
Stephen Boyd94625ef2011-07-12 17:06:01 -0700573static struct pll_vote_clk pll14_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -0700574 .en_reg = BB_PLL_ENA_SC0_REG,
575 .en_mask = BIT(14),
576 .status_reg = BB_PLL14_STATUS_REG,
577 .parent = &pxo_clk.c,
578 .c = {
579 .dbg_name = "pll14_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800580 .rate = 480000000,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700581 .ops = &clk_ops_pll_vote,
582 CLK_INIT(pll14_clk.c),
583 },
584};
585
Tianyi Gou41515e22011-09-01 19:37:43 -0700586static struct pll_clk pll15_clk = {
Tianyi Gou41515e22011-09-01 19:37:43 -0700587 .mode_reg = MM_PLL3_MODE_REG,
588 .parent = &pxo_clk.c,
589 .c = {
590 .dbg_name = "pll15_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800591 .rate = 975000000,
Tianyi Gou41515e22011-09-01 19:37:43 -0700592 .ops = &clk_ops_pll,
593 CLK_INIT(pll15_clk.c),
594 },
595};
596
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700597static struct clk_ops clk_ops_rcg_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700598 .enable = rcg_clk_enable,
599 .disable = rcg_clk_disable,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800600 .enable_hwcg = rcg_clk_enable_hwcg,
601 .disable_hwcg = rcg_clk_disable_hwcg,
602 .in_hwcg_mode = rcg_clk_in_hwcg_mode,
Matt Wagantall41af0772011-09-17 12:21:39 -0700603 .auto_off = rcg_clk_disable,
Matt Wagantall53d968f2011-07-19 13:22:53 -0700604 .handoff = rcg_clk_handoff,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700605 .set_rate = rcg_clk_set_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700606 .list_rate = rcg_clk_list_rate,
607 .is_enabled = rcg_clk_is_enabled,
608 .round_rate = rcg_clk_round_rate,
Stephen Boyd7bf28142011-12-07 00:30:52 -0800609 .reset = rcg_clk_reset,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700610 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700611 .get_parent = rcg_clk_get_parent,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800612 .set_flags = rcg_clk_set_flags,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700613};
614
615static struct clk_ops clk_ops_branch = {
616 .enable = branch_clk_enable,
617 .disable = branch_clk_disable,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800618 .enable_hwcg = branch_clk_enable_hwcg,
619 .disable_hwcg = branch_clk_disable_hwcg,
620 .in_hwcg_mode = branch_clk_in_hwcg_mode,
Matt Wagantall41af0772011-09-17 12:21:39 -0700621 .auto_off = branch_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700622 .is_enabled = branch_clk_is_enabled,
623 .reset = branch_clk_reset,
624 .is_local = local_clk_is_local,
625 .get_parent = branch_clk_get_parent,
626 .set_parent = branch_clk_set_parent,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800627 .handoff = branch_clk_handoff,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800628 .set_flags = branch_clk_set_flags,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700629};
630
631static struct clk_ops clk_ops_reset = {
632 .reset = branch_clk_reset,
633 .is_local = local_clk_is_local,
634};
635
636/* AXI Interfaces */
637static struct branch_clk gmem_axi_clk = {
638 .b = {
639 .ctl_reg = MAXI_EN_REG,
640 .en_mask = BIT(24),
641 .halt_reg = DBG_BUS_VEC_E_REG,
642 .halt_bit = 6,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800643 .retain_reg = MAXI_EN2_REG,
644 .retain_mask = BIT(21),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700645 },
646 .c = {
647 .dbg_name = "gmem_axi_clk",
648 .ops = &clk_ops_branch,
649 CLK_INIT(gmem_axi_clk.c),
650 },
651};
652
653static struct branch_clk ijpeg_axi_clk = {
654 .b = {
655 .ctl_reg = MAXI_EN_REG,
656 .en_mask = BIT(21),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800657 .hwcg_reg = MAXI_EN_REG,
658 .hwcg_mask = BIT(11),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700659 .reset_reg = SW_RESET_AXI_REG,
660 .reset_mask = BIT(14),
661 .halt_reg = DBG_BUS_VEC_E_REG,
662 .halt_bit = 4,
663 },
664 .c = {
665 .dbg_name = "ijpeg_axi_clk",
666 .ops = &clk_ops_branch,
667 CLK_INIT(ijpeg_axi_clk.c),
668 },
669};
670
671static struct branch_clk imem_axi_clk = {
672 .b = {
673 .ctl_reg = MAXI_EN_REG,
674 .en_mask = BIT(22),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800675 .hwcg_reg = MAXI_EN_REG,
676 .hwcg_mask = BIT(15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700677 .reset_reg = SW_RESET_CORE_REG,
678 .reset_mask = BIT(10),
679 .halt_reg = DBG_BUS_VEC_E_REG,
680 .halt_bit = 7,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800681 .retain_reg = MAXI_EN2_REG,
682 .retain_mask = BIT(10),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700683 },
684 .c = {
685 .dbg_name = "imem_axi_clk",
686 .ops = &clk_ops_branch,
687 CLK_INIT(imem_axi_clk.c),
688 },
689};
690
691static struct branch_clk jpegd_axi_clk = {
692 .b = {
693 .ctl_reg = MAXI_EN_REG,
694 .en_mask = BIT(25),
695 .halt_reg = DBG_BUS_VEC_E_REG,
696 .halt_bit = 5,
697 },
698 .c = {
699 .dbg_name = "jpegd_axi_clk",
700 .ops = &clk_ops_branch,
701 CLK_INIT(jpegd_axi_clk.c),
702 },
703};
704
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700705static struct branch_clk vcodec_axi_b_clk = {
706 .b = {
707 .ctl_reg = MAXI_EN4_REG,
708 .en_mask = BIT(23),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800709 .hwcg_reg = MAXI_EN4_REG,
710 .hwcg_mask = BIT(22),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700711 .halt_reg = DBG_BUS_VEC_I_REG,
712 .halt_bit = 25,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800713 .retain_reg = MAXI_EN4_REG,
714 .retain_mask = BIT(21),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700715 },
716 .c = {
717 .dbg_name = "vcodec_axi_b_clk",
718 .ops = &clk_ops_branch,
719 CLK_INIT(vcodec_axi_b_clk.c),
720 },
721};
722
Matt Wagantall91f42702011-07-14 12:01:15 -0700723static struct branch_clk vcodec_axi_a_clk = {
724 .b = {
725 .ctl_reg = MAXI_EN4_REG,
726 .en_mask = BIT(25),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800727 .hwcg_reg = MAXI_EN4_REG,
728 .hwcg_mask = BIT(24),
Matt Wagantall91f42702011-07-14 12:01:15 -0700729 .halt_reg = DBG_BUS_VEC_I_REG,
730 .halt_bit = 26,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800731 .retain_reg = MAXI_EN4_REG,
732 .retain_mask = BIT(10),
Matt Wagantall91f42702011-07-14 12:01:15 -0700733 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700734 .c = {
735 .dbg_name = "vcodec_axi_a_clk",
736 .ops = &clk_ops_branch,
737 CLK_INIT(vcodec_axi_a_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700738 .depends = &vcodec_axi_b_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700739 },
740};
741
742static struct branch_clk vcodec_axi_clk = {
743 .b = {
744 .ctl_reg = MAXI_EN_REG,
745 .en_mask = BIT(19),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800746 .hwcg_reg = MAXI_EN_REG,
747 .hwcg_mask = BIT(13),
Matt Wagantall91f42702011-07-14 12:01:15 -0700748 .reset_reg = SW_RESET_AXI_REG,
Gopikrishnaiah Anandan83b6e852012-01-05 17:47:02 -0800749 .reset_mask = BIT(4)|BIT(5)|BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700750 .halt_reg = DBG_BUS_VEC_E_REG,
751 .halt_bit = 3,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800752 .retain_reg = MAXI_EN2_REG,
753 .retain_mask = BIT(28),
Matt Wagantall91f42702011-07-14 12:01:15 -0700754 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700755 .c = {
756 .dbg_name = "vcodec_axi_clk",
757 .ops = &clk_ops_branch,
758 CLK_INIT(vcodec_axi_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700759 .depends = &vcodec_axi_a_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700760 },
761};
762
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700763static struct branch_clk vfe_axi_clk = {
764 .b = {
765 .ctl_reg = MAXI_EN_REG,
766 .en_mask = BIT(18),
767 .reset_reg = SW_RESET_AXI_REG,
768 .reset_mask = BIT(9),
769 .halt_reg = DBG_BUS_VEC_E_REG,
770 .halt_bit = 0,
771 },
772 .c = {
773 .dbg_name = "vfe_axi_clk",
774 .ops = &clk_ops_branch,
775 CLK_INIT(vfe_axi_clk.c),
776 },
777};
778
779static struct branch_clk mdp_axi_clk = {
780 .b = {
781 .ctl_reg = MAXI_EN_REG,
782 .en_mask = BIT(23),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800783 .hwcg_reg = MAXI_EN_REG,
784 .hwcg_mask = BIT(16),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700785 .reset_reg = SW_RESET_AXI_REG,
786 .reset_mask = BIT(13),
787 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700788 .halt_bit = 8,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800789 .retain_reg = MAXI_EN_REG,
790 .retain_mask = BIT(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700791 },
792 .c = {
793 .dbg_name = "mdp_axi_clk",
794 .ops = &clk_ops_branch,
795 CLK_INIT(mdp_axi_clk.c),
796 },
797};
798
799static struct branch_clk rot_axi_clk = {
800 .b = {
801 .ctl_reg = MAXI_EN2_REG,
802 .en_mask = BIT(24),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800803 .hwcg_reg = MAXI_EN2_REG,
804 .hwcg_mask = BIT(25),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700805 .reset_reg = SW_RESET_AXI_REG,
806 .reset_mask = BIT(6),
807 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700808 .halt_bit = 2,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800809 .retain_reg = MAXI_EN3_REG,
810 .retain_mask = BIT(10),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700811 },
812 .c = {
813 .dbg_name = "rot_axi_clk",
814 .ops = &clk_ops_branch,
815 CLK_INIT(rot_axi_clk.c),
816 },
817};
818
819static struct branch_clk vpe_axi_clk = {
820 .b = {
821 .ctl_reg = MAXI_EN2_REG,
822 .en_mask = BIT(26),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800823 .hwcg_reg = MAXI_EN2_REG,
824 .hwcg_mask = BIT(27),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700825 .reset_reg = SW_RESET_AXI_REG,
826 .reset_mask = BIT(15),
827 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700828 .halt_bit = 1,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800829 .retain_reg = MAXI_EN3_REG,
830 .retain_mask = BIT(21),
831
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700832 },
833 .c = {
834 .dbg_name = "vpe_axi_clk",
835 .ops = &clk_ops_branch,
836 CLK_INIT(vpe_axi_clk.c),
837 },
838};
839
Tianyi Gou41515e22011-09-01 19:37:43 -0700840static struct branch_clk vcap_axi_clk = {
841 .b = {
842 .ctl_reg = MAXI_EN5_REG,
843 .en_mask = BIT(12),
844 .reset_reg = SW_RESET_AXI_REG,
845 .reset_mask = BIT(16),
846 .halt_reg = DBG_BUS_VEC_J_REG,
847 .halt_bit = 20,
848 },
849 .c = {
850 .dbg_name = "vcap_axi_clk",
851 .ops = &clk_ops_branch,
852 CLK_INIT(vcap_axi_clk.c),
853 },
854};
855
Tianyi Gou621f8742011-09-01 21:45:01 -0700856/* For 8064, gfx3d_axi_clk is set as a dependency of gmem_axi_clk at runtime */
857static struct branch_clk gfx3d_axi_clk = {
858 .b = {
859 .ctl_reg = MAXI_EN5_REG,
860 .en_mask = BIT(25),
861 .reset_reg = SW_RESET_AXI_REG,
862 .reset_mask = BIT(17),
863 .halt_reg = DBG_BUS_VEC_J_REG,
864 .halt_bit = 30,
865 },
866 .c = {
867 .dbg_name = "gfx3d_axi_clk",
868 .ops = &clk_ops_branch,
869 CLK_INIT(gfx3d_axi_clk.c),
870 },
871};
872
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700873/* AHB Interfaces */
874static struct branch_clk amp_p_clk = {
875 .b = {
876 .ctl_reg = AHB_EN_REG,
877 .en_mask = BIT(24),
878 .halt_reg = DBG_BUS_VEC_F_REG,
879 .halt_bit = 18,
880 },
881 .c = {
882 .dbg_name = "amp_p_clk",
883 .ops = &clk_ops_branch,
884 CLK_INIT(amp_p_clk.c),
885 },
886};
887
Matt Wagantallc23eee92011-08-16 23:06:52 -0700888static struct branch_clk csi_p_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700889 .b = {
890 .ctl_reg = AHB_EN_REG,
891 .en_mask = BIT(7),
892 .reset_reg = SW_RESET_AHB_REG,
893 .reset_mask = BIT(17),
894 .halt_reg = DBG_BUS_VEC_F_REG,
895 .halt_bit = 16,
896 },
897 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -0700898 .dbg_name = "csi_p_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700899 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -0700900 CLK_INIT(csi_p_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700901 },
902};
903
904static struct branch_clk dsi1_m_p_clk = {
905 .b = {
906 .ctl_reg = AHB_EN_REG,
907 .en_mask = BIT(9),
908 .reset_reg = SW_RESET_AHB_REG,
909 .reset_mask = BIT(6),
910 .halt_reg = DBG_BUS_VEC_F_REG,
911 .halt_bit = 19,
912 },
913 .c = {
914 .dbg_name = "dsi1_m_p_clk",
915 .ops = &clk_ops_branch,
916 CLK_INIT(dsi1_m_p_clk.c),
917 },
918};
919
920static struct branch_clk dsi1_s_p_clk = {
921 .b = {
922 .ctl_reg = AHB_EN_REG,
923 .en_mask = BIT(18),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800924 .hwcg_reg = AHB_EN2_REG,
925 .hwcg_mask = BIT(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700926 .reset_reg = SW_RESET_AHB_REG,
927 .reset_mask = BIT(5),
928 .halt_reg = DBG_BUS_VEC_F_REG,
929 .halt_bit = 21,
930 },
931 .c = {
932 .dbg_name = "dsi1_s_p_clk",
933 .ops = &clk_ops_branch,
934 CLK_INIT(dsi1_s_p_clk.c),
935 },
936};
937
938static struct branch_clk dsi2_m_p_clk = {
939 .b = {
940 .ctl_reg = AHB_EN_REG,
941 .en_mask = BIT(17),
942 .reset_reg = SW_RESET_AHB2_REG,
943 .reset_mask = BIT(1),
944 .halt_reg = DBG_BUS_VEC_E_REG,
945 .halt_bit = 18,
946 },
947 .c = {
948 .dbg_name = "dsi2_m_p_clk",
949 .ops = &clk_ops_branch,
950 CLK_INIT(dsi2_m_p_clk.c),
951 },
952};
953
954static struct branch_clk dsi2_s_p_clk = {
955 .b = {
956 .ctl_reg = AHB_EN_REG,
957 .en_mask = BIT(22),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800958 .hwcg_reg = AHB_EN2_REG,
959 .hwcg_mask = BIT(15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700960 .reset_reg = SW_RESET_AHB2_REG,
961 .reset_mask = BIT(0),
962 .halt_reg = DBG_BUS_VEC_F_REG,
963 .halt_bit = 20,
964 },
965 .c = {
966 .dbg_name = "dsi2_s_p_clk",
967 .ops = &clk_ops_branch,
968 CLK_INIT(dsi2_s_p_clk.c),
969 },
970};
971
972static struct branch_clk gfx2d0_p_clk = {
973 .b = {
974 .ctl_reg = AHB_EN_REG,
975 .en_mask = BIT(19),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800976 .hwcg_reg = AHB_EN2_REG,
977 .hwcg_mask = BIT(28),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700978 .reset_reg = SW_RESET_AHB_REG,
979 .reset_mask = BIT(12),
980 .halt_reg = DBG_BUS_VEC_F_REG,
981 .halt_bit = 2,
982 },
983 .c = {
984 .dbg_name = "gfx2d0_p_clk",
985 .ops = &clk_ops_branch,
986 CLK_INIT(gfx2d0_p_clk.c),
987 },
988};
989
990static struct branch_clk gfx2d1_p_clk = {
991 .b = {
992 .ctl_reg = AHB_EN_REG,
993 .en_mask = BIT(2),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800994 .hwcg_reg = AHB_EN2_REG,
995 .hwcg_mask = BIT(29),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700996 .reset_reg = SW_RESET_AHB_REG,
997 .reset_mask = BIT(11),
998 .halt_reg = DBG_BUS_VEC_F_REG,
999 .halt_bit = 3,
1000 },
1001 .c = {
1002 .dbg_name = "gfx2d1_p_clk",
1003 .ops = &clk_ops_branch,
1004 CLK_INIT(gfx2d1_p_clk.c),
1005 },
1006};
1007
1008static struct branch_clk gfx3d_p_clk = {
1009 .b = {
1010 .ctl_reg = AHB_EN_REG,
1011 .en_mask = BIT(3),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001012 .hwcg_reg = AHB_EN2_REG,
1013 .hwcg_mask = BIT(27),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001014 .reset_reg = SW_RESET_AHB_REG,
1015 .reset_mask = BIT(10),
1016 .halt_reg = DBG_BUS_VEC_F_REG,
1017 .halt_bit = 4,
1018 },
1019 .c = {
1020 .dbg_name = "gfx3d_p_clk",
1021 .ops = &clk_ops_branch,
1022 CLK_INIT(gfx3d_p_clk.c),
1023 },
1024};
1025
1026static struct branch_clk hdmi_m_p_clk = {
1027 .b = {
1028 .ctl_reg = AHB_EN_REG,
1029 .en_mask = BIT(14),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001030 .hwcg_reg = AHB_EN2_REG,
1031 .hwcg_mask = BIT(21),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001032 .reset_reg = SW_RESET_AHB_REG,
1033 .reset_mask = BIT(9),
1034 .halt_reg = DBG_BUS_VEC_F_REG,
1035 .halt_bit = 5,
1036 },
1037 .c = {
1038 .dbg_name = "hdmi_m_p_clk",
1039 .ops = &clk_ops_branch,
1040 CLK_INIT(hdmi_m_p_clk.c),
1041 },
1042};
1043
1044static struct branch_clk hdmi_s_p_clk = {
1045 .b = {
1046 .ctl_reg = AHB_EN_REG,
1047 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001048 .hwcg_reg = AHB_EN2_REG,
1049 .hwcg_mask = BIT(22),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001050 .reset_reg = SW_RESET_AHB_REG,
1051 .reset_mask = BIT(9),
1052 .halt_reg = DBG_BUS_VEC_F_REG,
1053 .halt_bit = 6,
1054 },
1055 .c = {
1056 .dbg_name = "hdmi_s_p_clk",
1057 .ops = &clk_ops_branch,
1058 CLK_INIT(hdmi_s_p_clk.c),
1059 },
1060};
1061
1062static struct branch_clk ijpeg_p_clk = {
1063 .b = {
1064 .ctl_reg = AHB_EN_REG,
1065 .en_mask = BIT(5),
1066 .reset_reg = SW_RESET_AHB_REG,
1067 .reset_mask = BIT(7),
1068 .halt_reg = DBG_BUS_VEC_F_REG,
1069 .halt_bit = 9,
1070 },
1071 .c = {
1072 .dbg_name = "ijpeg_p_clk",
1073 .ops = &clk_ops_branch,
1074 CLK_INIT(ijpeg_p_clk.c),
1075 },
1076};
1077
1078static struct branch_clk imem_p_clk = {
1079 .b = {
1080 .ctl_reg = AHB_EN_REG,
1081 .en_mask = BIT(6),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001082 .hwcg_reg = AHB_EN2_REG,
1083 .hwcg_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001084 .reset_reg = SW_RESET_AHB_REG,
1085 .reset_mask = BIT(8),
1086 .halt_reg = DBG_BUS_VEC_F_REG,
1087 .halt_bit = 10,
1088 },
1089 .c = {
1090 .dbg_name = "imem_p_clk",
1091 .ops = &clk_ops_branch,
1092 CLK_INIT(imem_p_clk.c),
1093 },
1094};
1095
1096static struct branch_clk jpegd_p_clk = {
1097 .b = {
1098 .ctl_reg = AHB_EN_REG,
1099 .en_mask = BIT(21),
1100 .reset_reg = SW_RESET_AHB_REG,
1101 .reset_mask = BIT(4),
1102 .halt_reg = DBG_BUS_VEC_F_REG,
1103 .halt_bit = 7,
1104 },
1105 .c = {
1106 .dbg_name = "jpegd_p_clk",
1107 .ops = &clk_ops_branch,
1108 CLK_INIT(jpegd_p_clk.c),
1109 },
1110};
1111
1112static struct branch_clk mdp_p_clk = {
1113 .b = {
1114 .ctl_reg = AHB_EN_REG,
1115 .en_mask = BIT(10),
1116 .reset_reg = SW_RESET_AHB_REG,
1117 .reset_mask = BIT(3),
1118 .halt_reg = DBG_BUS_VEC_F_REG,
1119 .halt_bit = 11,
1120 },
1121 .c = {
1122 .dbg_name = "mdp_p_clk",
1123 .ops = &clk_ops_branch,
1124 CLK_INIT(mdp_p_clk.c),
1125 },
1126};
1127
1128static struct branch_clk rot_p_clk = {
1129 .b = {
1130 .ctl_reg = AHB_EN_REG,
1131 .en_mask = BIT(12),
1132 .reset_reg = SW_RESET_AHB_REG,
1133 .reset_mask = BIT(2),
1134 .halt_reg = DBG_BUS_VEC_F_REG,
1135 .halt_bit = 13,
1136 },
1137 .c = {
1138 .dbg_name = "rot_p_clk",
1139 .ops = &clk_ops_branch,
1140 CLK_INIT(rot_p_clk.c),
1141 },
1142};
1143
1144static struct branch_clk smmu_p_clk = {
1145 .b = {
1146 .ctl_reg = AHB_EN_REG,
1147 .en_mask = BIT(15),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001148 .hwcg_reg = AHB_EN_REG,
1149 .hwcg_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001150 .halt_reg = DBG_BUS_VEC_F_REG,
1151 .halt_bit = 22,
1152 },
1153 .c = {
1154 .dbg_name = "smmu_p_clk",
1155 .ops = &clk_ops_branch,
1156 CLK_INIT(smmu_p_clk.c),
1157 },
1158};
1159
1160static struct branch_clk tv_enc_p_clk = {
1161 .b = {
1162 .ctl_reg = AHB_EN_REG,
1163 .en_mask = BIT(25),
1164 .reset_reg = SW_RESET_AHB_REG,
1165 .reset_mask = BIT(15),
1166 .halt_reg = DBG_BUS_VEC_F_REG,
1167 .halt_bit = 23,
1168 },
1169 .c = {
1170 .dbg_name = "tv_enc_p_clk",
1171 .ops = &clk_ops_branch,
1172 CLK_INIT(tv_enc_p_clk.c),
1173 },
1174};
1175
1176static struct branch_clk vcodec_p_clk = {
1177 .b = {
1178 .ctl_reg = AHB_EN_REG,
1179 .en_mask = BIT(11),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001180 .hwcg_reg = AHB_EN2_REG,
1181 .hwcg_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001182 .reset_reg = SW_RESET_AHB_REG,
1183 .reset_mask = BIT(1),
1184 .halt_reg = DBG_BUS_VEC_F_REG,
1185 .halt_bit = 12,
1186 },
1187 .c = {
1188 .dbg_name = "vcodec_p_clk",
1189 .ops = &clk_ops_branch,
1190 CLK_INIT(vcodec_p_clk.c),
1191 },
1192};
1193
1194static struct branch_clk vfe_p_clk = {
1195 .b = {
1196 .ctl_reg = AHB_EN_REG,
1197 .en_mask = BIT(13),
1198 .reset_reg = SW_RESET_AHB_REG,
1199 .reset_mask = BIT(0),
1200 .halt_reg = DBG_BUS_VEC_F_REG,
1201 .halt_bit = 14,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08001202 .retain_reg = AHB_EN2_REG,
1203 .retain_mask = BIT(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001204 },
1205 .c = {
1206 .dbg_name = "vfe_p_clk",
1207 .ops = &clk_ops_branch,
1208 CLK_INIT(vfe_p_clk.c),
1209 },
1210};
1211
1212static struct branch_clk vpe_p_clk = {
1213 .b = {
1214 .ctl_reg = AHB_EN_REG,
1215 .en_mask = BIT(16),
1216 .reset_reg = SW_RESET_AHB_REG,
1217 .reset_mask = BIT(14),
1218 .halt_reg = DBG_BUS_VEC_F_REG,
1219 .halt_bit = 15,
1220 },
1221 .c = {
1222 .dbg_name = "vpe_p_clk",
1223 .ops = &clk_ops_branch,
1224 CLK_INIT(vpe_p_clk.c),
1225 },
1226};
1227
Tianyi Gou41515e22011-09-01 19:37:43 -07001228static struct branch_clk vcap_p_clk = {
1229 .b = {
1230 .ctl_reg = AHB_EN3_REG,
1231 .en_mask = BIT(1),
1232 .reset_reg = SW_RESET_AHB2_REG,
1233 .reset_mask = BIT(2),
1234 .halt_reg = DBG_BUS_VEC_J_REG,
1235 .halt_bit = 23,
1236 },
1237 .c = {
1238 .dbg_name = "vcap_p_clk",
1239 .ops = &clk_ops_branch,
1240 CLK_INIT(vcap_p_clk.c),
1241 },
1242};
1243
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001244/*
1245 * Peripheral Clocks
1246 */
Matt Wagantall7625a4c2011-11-01 16:17:53 -07001247#define CLK_GP(i, n, h_r, h_b) \
1248 struct rcg_clk i##_clk = { \
1249 .b = { \
1250 .ctl_reg = GPn_NS_REG(n), \
1251 .en_mask = BIT(9), \
1252 .halt_reg = h_r, \
1253 .halt_bit = h_b, \
1254 }, \
1255 .ns_reg = GPn_NS_REG(n), \
1256 .md_reg = GPn_MD_REG(n), \
1257 .root_en_mask = BIT(11), \
1258 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001259 .mnd_en_mask = BIT(8), \
Matt Wagantall7625a4c2011-11-01 16:17:53 -07001260 .set_rate = set_rate_mnd, \
1261 .freq_tbl = clk_tbl_gp, \
1262 .current_freq = &rcg_dummy_freq, \
1263 .c = { \
1264 .dbg_name = #i "_clk", \
1265 .ops = &clk_ops_rcg_8960, \
1266 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000), \
1267 CLK_INIT(i##_clk.c), \
1268 }, \
1269 }
1270#define F_GP(f, s, d, m, n) \
1271 { \
1272 .freq_hz = f, \
1273 .src_clk = &s##_clk.c, \
1274 .md_val = MD8(16, m, 0, n), \
1275 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Matt Wagantall7625a4c2011-11-01 16:17:53 -07001276 }
1277static struct clk_freq_tbl clk_tbl_gp[] = {
1278 F_GP( 0, gnd, 1, 0, 0),
1279 F_GP( 9600000, cxo, 2, 0, 0),
1280 F_GP( 13500000, pxo, 2, 0, 0),
1281 F_GP( 19200000, cxo, 1, 0, 0),
1282 F_GP( 27000000, pxo, 1, 0, 0),
1283 F_GP( 64000000, pll8, 2, 1, 3),
1284 F_GP( 76800000, pll8, 1, 1, 5),
1285 F_GP( 96000000, pll8, 4, 0, 0),
1286 F_GP(128000000, pll8, 3, 0, 0),
1287 F_GP(192000000, pll8, 2, 0, 0),
1288 F_GP(384000000, pll8, 1, 0, 0),
1289 F_END
1290};
1291
1292static CLK_GP(gp0, 0, CLK_HALT_SFPB_MISC_STATE_REG, 7);
1293static CLK_GP(gp1, 1, CLK_HALT_SFPB_MISC_STATE_REG, 6);
1294static CLK_GP(gp2, 2, CLK_HALT_SFPB_MISC_STATE_REG, 5);
1295
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001296#define CLK_GSBI_UART(i, n, h_r, h_b) \
1297 struct rcg_clk i##_clk = { \
1298 .b = { \
1299 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
1300 .en_mask = BIT(9), \
1301 .reset_reg = GSBIn_RESET_REG(n), \
1302 .reset_mask = BIT(0), \
1303 .halt_reg = h_r, \
1304 .halt_bit = h_b, \
1305 }, \
1306 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
1307 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
1308 .root_en_mask = BIT(11), \
1309 .ns_mask = (BM(31, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001310 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001311 .set_rate = set_rate_mnd, \
1312 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001313 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001314 .c = { \
1315 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001316 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001317 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001318 CLK_INIT(i##_clk.c), \
1319 }, \
1320 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001321#define F_GSBI_UART(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001322 { \
1323 .freq_hz = f, \
1324 .src_clk = &s##_clk.c, \
1325 .md_val = MD16(m, n), \
1326 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001327 }
1328static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001329 F_GSBI_UART( 0, gnd, 1, 0, 0),
Matt Wagantall9a561f72012-01-19 16:13:12 -08001330 F_GSBI_UART( 1843200, pll8, 2, 6, 625),
1331 F_GSBI_UART( 3686400, pll8, 2, 12, 625),
1332 F_GSBI_UART( 7372800, pll8, 2, 24, 625),
1333 F_GSBI_UART(14745600, pll8, 2, 48, 625),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001334 F_GSBI_UART(16000000, pll8, 4, 1, 6),
1335 F_GSBI_UART(24000000, pll8, 4, 1, 4),
1336 F_GSBI_UART(32000000, pll8, 4, 1, 3),
1337 F_GSBI_UART(40000000, pll8, 1, 5, 48),
1338 F_GSBI_UART(46400000, pll8, 1, 29, 240),
1339 F_GSBI_UART(48000000, pll8, 4, 1, 2),
1340 F_GSBI_UART(51200000, pll8, 1, 2, 15),
1341 F_GSBI_UART(56000000, pll8, 1, 7, 48),
1342 F_GSBI_UART(58982400, pll8, 1, 96, 625),
1343 F_GSBI_UART(64000000, pll8, 2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001344 F_END
1345};
1346
1347static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1348static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1349static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1350static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1351static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1352static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1353static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1354static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1355static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1356static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1357static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1358static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1359
1360#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1361 struct rcg_clk i##_clk = { \
1362 .b = { \
1363 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1364 .en_mask = BIT(9), \
1365 .reset_reg = GSBIn_RESET_REG(n), \
1366 .reset_mask = BIT(0), \
1367 .halt_reg = h_r, \
1368 .halt_bit = h_b, \
1369 }, \
1370 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1371 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1372 .root_en_mask = BIT(11), \
1373 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001374 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001375 .set_rate = set_rate_mnd, \
1376 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001377 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001378 .c = { \
1379 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001380 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001381 VDD_DIG_FMAX_MAP2(LOW, 24000000, NOMINAL, 52000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001382 CLK_INIT(i##_clk.c), \
1383 }, \
1384 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001385#define F_GSBI_QUP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001386 { \
1387 .freq_hz = f, \
1388 .src_clk = &s##_clk.c, \
1389 .md_val = MD8(16, m, 0, n), \
1390 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001391 }
1392static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001393 F_GSBI_QUP( 0, gnd, 1, 0, 0),
1394 F_GSBI_QUP( 1100000, pxo, 1, 2, 49),
1395 F_GSBI_QUP( 5400000, pxo, 1, 1, 5),
1396 F_GSBI_QUP(10800000, pxo, 1, 2, 5),
1397 F_GSBI_QUP(15060000, pll8, 1, 2, 51),
1398 F_GSBI_QUP(24000000, pll8, 4, 1, 4),
1399 F_GSBI_QUP(25600000, pll8, 1, 1, 15),
1400 F_GSBI_QUP(27000000, pxo, 1, 0, 0),
1401 F_GSBI_QUP(48000000, pll8, 4, 1, 2),
1402 F_GSBI_QUP(51200000, pll8, 1, 2, 15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001403 F_END
1404};
1405
1406static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1407static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1408static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1409static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1410static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1411static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1412static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1413static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1414static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1415static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1416static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1417static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1418
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001419#define F_PDM(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001420 { \
1421 .freq_hz = f, \
1422 .src_clk = &s##_clk.c, \
1423 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001424 }
1425static struct clk_freq_tbl clk_tbl_pdm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001426 F_PDM( 0, gnd, 1),
1427 F_PDM(27000000, pxo, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001428 F_END
1429};
1430
1431static struct rcg_clk pdm_clk = {
1432 .b = {
1433 .ctl_reg = PDM_CLK_NS_REG,
1434 .en_mask = BIT(9),
1435 .reset_reg = PDM_CLK_NS_REG,
1436 .reset_mask = BIT(12),
1437 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1438 .halt_bit = 3,
1439 },
1440 .ns_reg = PDM_CLK_NS_REG,
1441 .root_en_mask = BIT(11),
1442 .ns_mask = BM(1, 0),
1443 .set_rate = set_rate_nop,
1444 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001445 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001446 .c = {
1447 .dbg_name = "pdm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001448 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001449 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001450 CLK_INIT(pdm_clk.c),
1451 },
1452};
1453
1454static struct branch_clk pmem_clk = {
1455 .b = {
1456 .ctl_reg = PMEM_ACLK_CTL_REG,
1457 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001458 .hwcg_reg = PMEM_ACLK_CTL_REG,
1459 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001460 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1461 .halt_bit = 20,
1462 },
1463 .c = {
1464 .dbg_name = "pmem_clk",
1465 .ops = &clk_ops_branch,
1466 CLK_INIT(pmem_clk.c),
1467 },
1468};
1469
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001470#define F_PRNG(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001471 { \
1472 .freq_hz = f, \
1473 .src_clk = &s##_clk.c, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001474 }
1475static struct clk_freq_tbl clk_tbl_prng[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001476 F_PRNG(64000000, pll8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001477 F_END
1478};
1479
1480static struct rcg_clk prng_clk = {
1481 .b = {
1482 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1483 .en_mask = BIT(10),
1484 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1485 .halt_check = HALT_VOTED,
1486 .halt_bit = 10,
1487 },
1488 .set_rate = set_rate_nop,
1489 .freq_tbl = clk_tbl_prng,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001490 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001491 .c = {
1492 .dbg_name = "prng_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001493 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001494 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 65000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001495 CLK_INIT(prng_clk.c),
1496 },
1497};
1498
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001499#define CLK_SDC(name, n, h_b, fmax_low, fmax_nom) \
Stephen Boyda78a7402011-08-02 11:23:39 -07001500 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001501 .b = { \
1502 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1503 .en_mask = BIT(9), \
1504 .reset_reg = SDCn_RESET_REG(n), \
1505 .reset_mask = BIT(0), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001506 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001507 .halt_bit = h_b, \
1508 }, \
1509 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1510 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1511 .root_en_mask = BIT(11), \
1512 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001513 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001514 .set_rate = set_rate_mnd, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001515 .freq_tbl = clk_tbl_sdc, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001516 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001517 .c = { \
Stephen Boyda78a7402011-08-02 11:23:39 -07001518 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001519 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001520 VDD_DIG_FMAX_MAP2(LOW, fmax_low, NOMINAL, fmax_nom), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001521 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001522 }, \
1523 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001524#define F_SDC(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001525 { \
1526 .freq_hz = f, \
1527 .src_clk = &s##_clk.c, \
1528 .md_val = MD8(16, m, 0, n), \
1529 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001530 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001531static struct clk_freq_tbl clk_tbl_sdc[] = {
1532 F_SDC( 0, gnd, 1, 0, 0),
1533 F_SDC( 144000, pxo, 3, 2, 125),
1534 F_SDC( 400000, pll8, 4, 1, 240),
1535 F_SDC( 16000000, pll8, 4, 1, 6),
1536 F_SDC( 17070000, pll8, 1, 2, 45),
1537 F_SDC( 20210000, pll8, 1, 1, 19),
1538 F_SDC( 24000000, pll8, 4, 1, 4),
1539 F_SDC( 48000000, pll8, 4, 1, 2),
1540 F_SDC( 64000000, pll8, 3, 1, 2),
1541 F_SDC( 96000000, pll8, 4, 0, 0),
Subhash Jadavanibd238ba2011-11-24 15:12:39 +05301542 F_SDC(192000000, pll8, 2, 0, 0),
Stephen Boyda78a7402011-08-02 11:23:39 -07001543 F_END
1544};
1545
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001546static CLK_SDC(sdc1_clk, 1, 6, 52000000, 104000000);
1547static CLK_SDC(sdc2_clk, 2, 5, 52000000, 104000000);
1548static CLK_SDC(sdc3_clk, 3, 4, 104000000, 208000000);
1549static CLK_SDC(sdc4_clk, 4, 3, 33000000, 67000000);
1550static CLK_SDC(sdc5_clk, 5, 2, 33000000, 67000000);
Stephen Boyda78a7402011-08-02 11:23:39 -07001551
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001552#define F_TSIF_REF(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001553 { \
1554 .freq_hz = f, \
1555 .src_clk = &s##_clk.c, \
1556 .md_val = MD16(m, n), \
1557 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001558 }
1559static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001560 F_TSIF_REF( 0, gnd, 1, 0, 0),
1561 F_TSIF_REF(105000, pxo, 1, 1, 256),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001562 F_END
1563};
1564
1565static struct rcg_clk tsif_ref_clk = {
1566 .b = {
1567 .ctl_reg = TSIF_REF_CLK_NS_REG,
1568 .en_mask = BIT(9),
1569 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1570 .halt_bit = 5,
1571 },
1572 .ns_reg = TSIF_REF_CLK_NS_REG,
1573 .md_reg = TSIF_REF_CLK_MD_REG,
1574 .root_en_mask = BIT(11),
1575 .ns_mask = (BM(31, 16) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08001576 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001577 .set_rate = set_rate_mnd,
1578 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001579 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001580 .c = {
1581 .dbg_name = "tsif_ref_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001582 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001583 VDD_DIG_FMAX_MAP2(LOW, 27000000, NOMINAL, 54000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001584 CLK_INIT(tsif_ref_clk.c),
1585 },
1586};
1587
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001588#define F_TSSC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001589 { \
1590 .freq_hz = f, \
1591 .src_clk = &s##_clk.c, \
1592 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001593 }
1594static struct clk_freq_tbl clk_tbl_tssc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001595 F_TSSC( 0, gnd),
1596 F_TSSC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001597 F_END
1598};
1599
1600static struct rcg_clk tssc_clk = {
1601 .b = {
1602 .ctl_reg = TSSC_CLK_CTL_REG,
1603 .en_mask = BIT(4),
1604 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1605 .halt_bit = 4,
1606 },
1607 .ns_reg = TSSC_CLK_CTL_REG,
1608 .ns_mask = BM(1, 0),
1609 .set_rate = set_rate_nop,
1610 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001611 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001612 .c = {
1613 .dbg_name = "tssc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001614 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001615 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001616 CLK_INIT(tssc_clk.c),
1617 },
1618};
1619
Tianyi Gou41515e22011-09-01 19:37:43 -07001620#define CLK_USB_HS(name, n, h_b) \
1621 static struct rcg_clk name = { \
1622 .b = { \
1623 .ctl_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1624 .en_mask = BIT(9), \
1625 .reset_reg = USB_HS##n##_RESET_REG, \
1626 .reset_mask = BIT(0), \
1627 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
1628 .halt_bit = h_b, \
1629 }, \
1630 .ns_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1631 .md_reg = USB_HS##n##_XCVR_FS_CLK_MD_REG, \
1632 .root_en_mask = BIT(11), \
1633 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001634 .mnd_en_mask = BIT(8), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001635 .set_rate = set_rate_mnd, \
1636 .freq_tbl = clk_tbl_usb, \
1637 .current_freq = &rcg_dummy_freq, \
1638 .c = { \
1639 .dbg_name = #name, \
1640 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001641 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001642 CLK_INIT(name.c), \
1643 }, \
1644}
1645
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001646#define F_USB(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001647 { \
1648 .freq_hz = f, \
1649 .src_clk = &s##_clk.c, \
1650 .md_val = MD8(16, m, 0, n), \
1651 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001652 }
1653static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001654 F_USB( 0, gnd, 1, 0, 0),
1655 F_USB(60000000, pll8, 1, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001656 F_END
1657};
1658
Tianyi Gou41515e22011-09-01 19:37:43 -07001659CLK_USB_HS(usb_hs1_xcvr_clk, 1, 0);
1660CLK_USB_HS(usb_hs3_xcvr_clk, 3, 30);
1661CLK_USB_HS(usb_hs4_xcvr_clk, 4, 2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001662
Stephen Boyd94625ef2011-07-12 17:06:01 -07001663static struct clk_freq_tbl clk_tbl_usb_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001664 F_USB( 0, gnd, 1, 0, 0),
1665 F_USB(60000000, pll8, 1, 5, 32),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001666 F_END
1667};
1668
1669static struct rcg_clk usb_hsic_xcvr_fs_clk = {
1670 .b = {
1671 .ctl_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1672 .en_mask = BIT(9),
1673 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1674 .halt_bit = 26,
1675 },
1676 .ns_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1677 .md_reg = USB_HSIC_XCVR_FS_CLK_MD_REG,
1678 .root_en_mask = BIT(11),
1679 .ns_mask = (BM(23, 16) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08001680 .mnd_en_mask = BIT(8),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001681 .set_rate = set_rate_mnd,
1682 .freq_tbl = clk_tbl_usb_hsic,
1683 .current_freq = &rcg_dummy_freq,
1684 .c = {
1685 .dbg_name = "usb_hsic_xcvr_fs_clk",
1686 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001687 VDD_DIG_FMAX_MAP1(LOW, 60000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001688 CLK_INIT(usb_hsic_xcvr_fs_clk.c),
1689 },
1690};
1691
1692static struct branch_clk usb_hsic_system_clk = {
1693 .b = {
1694 .ctl_reg = USB_HSIC_SYSTEM_CLK_CTL_REG,
1695 .en_mask = BIT(4),
1696 .reset_reg = USB_HSIC_RESET_REG,
1697 .reset_mask = BIT(0),
1698 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1699 .halt_bit = 24,
1700 },
1701 .parent = &usb_hsic_xcvr_fs_clk.c,
1702 .c = {
1703 .dbg_name = "usb_hsic_system_clk",
1704 .ops = &clk_ops_branch,
1705 CLK_INIT(usb_hsic_system_clk.c),
1706 },
1707};
1708
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001709#define F_USB_HSIC(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001710 { \
1711 .freq_hz = f, \
1712 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001713 }
1714static struct clk_freq_tbl clk_tbl_usb2_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001715 F_USB_HSIC(480000000, pll14),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001716 F_END
1717};
1718
1719static struct rcg_clk usb_hsic_hsic_src_clk = {
1720 .b = {
1721 .ctl_reg = USB_HSIC_HSIC_CLK_SRC_CTL_REG,
1722 .halt_check = NOCHECK,
1723 },
1724 .root_en_mask = BIT(0),
1725 .set_rate = set_rate_nop,
1726 .freq_tbl = clk_tbl_usb2_hsic,
1727 .current_freq = &rcg_dummy_freq,
1728 .c = {
1729 .dbg_name = "usb_hsic_hsic_src_clk",
1730 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001731 VDD_DIG_FMAX_MAP1(LOW, 480000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001732 CLK_INIT(usb_hsic_hsic_src_clk.c),
1733 },
1734};
1735
1736static struct branch_clk usb_hsic_hsic_clk = {
1737 .b = {
1738 .ctl_reg = USB_HSIC_HSIC_CLK_CTL_REG,
1739 .en_mask = BIT(0),
1740 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1741 .halt_bit = 19,
1742 },
1743 .parent = &usb_hsic_hsic_src_clk.c,
1744 .c = {
1745 .dbg_name = "usb_hsic_hsic_clk",
1746 .ops = &clk_ops_branch,
1747 CLK_INIT(usb_hsic_hsic_clk.c),
1748 },
1749};
1750
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001751#define F_USB_HSIO_CAL(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001752 { \
1753 .freq_hz = f, \
1754 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001755 }
1756static struct clk_freq_tbl clk_tbl_usb_hsio_cal[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001757 F_USB_HSIO_CAL(9000000, pxo),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001758 F_END
1759};
1760
1761static struct rcg_clk usb_hsic_hsio_cal_clk = {
1762 .b = {
1763 .ctl_reg = USB_HSIC_HSIO_CAL_CLK_CTL_REG,
1764 .en_mask = BIT(0),
1765 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1766 .halt_bit = 23,
1767 },
1768 .set_rate = set_rate_nop,
1769 .freq_tbl = clk_tbl_usb_hsio_cal,
1770 .current_freq = &rcg_dummy_freq,
1771 .c = {
1772 .dbg_name = "usb_hsic_hsio_cal_clk",
Stephen Boyda0e82ec2011-09-19 12:18:45 -07001773 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001774 VDD_DIG_FMAX_MAP1(LOW, 10000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001775 CLK_INIT(usb_hsic_hsio_cal_clk.c),
1776 },
1777};
1778
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001779static struct branch_clk usb_phy0_clk = {
1780 .b = {
1781 .reset_reg = USB_PHY0_RESET_REG,
1782 .reset_mask = BIT(0),
1783 },
1784 .c = {
1785 .dbg_name = "usb_phy0_clk",
1786 .ops = &clk_ops_reset,
1787 CLK_INIT(usb_phy0_clk.c),
1788 },
1789};
1790
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001791#define CLK_USB_FS(i, n, fmax_nom) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001792 struct rcg_clk i##_clk = { \
1793 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1794 .b = { \
1795 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1796 .halt_check = NOCHECK, \
1797 }, \
1798 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
1799 .root_en_mask = BIT(11), \
1800 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001801 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001802 .set_rate = set_rate_mnd, \
1803 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001804 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001805 .c = { \
1806 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001807 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001808 VDD_DIG_FMAX_MAP1(NOMINAL, fmax_nom), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001809 CLK_INIT(i##_clk.c), \
1810 }, \
1811 }
1812
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001813static CLK_USB_FS(usb_fs1_src, 1, 64000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001814static struct branch_clk usb_fs1_xcvr_clk = {
1815 .b = {
1816 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
1817 .en_mask = BIT(9),
1818 .reset_reg = USB_FSn_RESET_REG(1),
1819 .reset_mask = BIT(1),
1820 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1821 .halt_bit = 15,
1822 },
1823 .parent = &usb_fs1_src_clk.c,
1824 .c = {
1825 .dbg_name = "usb_fs1_xcvr_clk",
1826 .ops = &clk_ops_branch,
1827 CLK_INIT(usb_fs1_xcvr_clk.c),
1828 },
1829};
1830
1831static struct branch_clk usb_fs1_sys_clk = {
1832 .b = {
1833 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
1834 .en_mask = BIT(4),
1835 .reset_reg = USB_FSn_RESET_REG(1),
1836 .reset_mask = BIT(0),
1837 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1838 .halt_bit = 16,
1839 },
1840 .parent = &usb_fs1_src_clk.c,
1841 .c = {
1842 .dbg_name = "usb_fs1_sys_clk",
1843 .ops = &clk_ops_branch,
1844 CLK_INIT(usb_fs1_sys_clk.c),
1845 },
1846};
1847
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001848static CLK_USB_FS(usb_fs2_src, 2, 60000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001849static struct branch_clk usb_fs2_xcvr_clk = {
1850 .b = {
1851 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
1852 .en_mask = BIT(9),
1853 .reset_reg = USB_FSn_RESET_REG(2),
1854 .reset_mask = BIT(1),
1855 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1856 .halt_bit = 12,
1857 },
1858 .parent = &usb_fs2_src_clk.c,
1859 .c = {
1860 .dbg_name = "usb_fs2_xcvr_clk",
1861 .ops = &clk_ops_branch,
1862 CLK_INIT(usb_fs2_xcvr_clk.c),
1863 },
1864};
1865
1866static struct branch_clk usb_fs2_sys_clk = {
1867 .b = {
1868 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
1869 .en_mask = BIT(4),
1870 .reset_reg = USB_FSn_RESET_REG(2),
1871 .reset_mask = BIT(0),
1872 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1873 .halt_bit = 13,
1874 },
1875 .parent = &usb_fs2_src_clk.c,
1876 .c = {
1877 .dbg_name = "usb_fs2_sys_clk",
1878 .ops = &clk_ops_branch,
1879 CLK_INIT(usb_fs2_sys_clk.c),
1880 },
1881};
1882
1883/* Fast Peripheral Bus Clocks */
1884static struct branch_clk ce1_core_clk = {
1885 .b = {
1886 .ctl_reg = CE1_CORE_CLK_CTL_REG,
1887 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001888 .hwcg_reg = CE1_CORE_CLK_CTL_REG,
1889 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001890 .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};
Tianyi Gou41515e22011-09-01 19:37:43 -07001899
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001900static struct branch_clk ce1_p_clk = {
1901 .b = {
1902 .ctl_reg = CE1_HCLK_CTL_REG,
1903 .en_mask = BIT(4),
1904 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1905 .halt_bit = 1,
1906 },
1907 .c = {
1908 .dbg_name = "ce1_p_clk",
1909 .ops = &clk_ops_branch,
1910 CLK_INIT(ce1_p_clk.c),
1911 },
1912};
1913
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001914#define F_CE3(f, s, d) \
Tianyi Gou41515e22011-09-01 19:37:43 -07001915 { \
1916 .freq_hz = f, \
1917 .src_clk = &s##_clk.c, \
1918 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001919 }
1920
1921static struct clk_freq_tbl clk_tbl_ce3[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001922 F_CE3( 0, gnd, 1),
1923 F_CE3( 48000000, pll8, 8),
1924 F_CE3(100000000, pll3, 12),
Tianyi Gou41515e22011-09-01 19:37:43 -07001925 F_END
1926};
1927
1928static struct rcg_clk ce3_src_clk = {
1929 .b = {
1930 .ctl_reg = CE3_CLK_SRC_NS_REG,
1931 .halt_check = NOCHECK,
1932 },
1933 .ns_reg = CE3_CLK_SRC_NS_REG,
1934 .root_en_mask = BIT(7),
1935 .ns_mask = BM(6, 0),
1936 .set_rate = set_rate_nop,
1937 .freq_tbl = clk_tbl_ce3,
1938 .current_freq = &rcg_dummy_freq,
1939 .c = {
1940 .dbg_name = "ce3_src_clk",
1941 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001942 VDD_DIG_FMAX_MAP2(LOW, 50000000, NOMINAL, 100000000),
Tianyi Gou41515e22011-09-01 19:37:43 -07001943 CLK_INIT(ce3_src_clk.c),
1944 },
1945};
1946
1947static struct branch_clk ce3_core_clk = {
1948 .b = {
1949 .ctl_reg = CE3_CORE_CLK_CTL_REG,
1950 .en_mask = BIT(4),
1951 .reset_reg = CE3_CORE_CLK_CTL_REG,
1952 .reset_mask = BIT(7),
1953 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1954 .halt_bit = 5,
1955 },
1956 .parent = &ce3_src_clk.c,
1957 .c = {
1958 .dbg_name = "ce3_core_clk",
1959 .ops = &clk_ops_branch,
1960 CLK_INIT(ce3_core_clk.c),
1961 }
1962};
1963
1964static struct branch_clk ce3_p_clk = {
1965 .b = {
1966 .ctl_reg = CE3_HCLK_CTL_REG,
1967 .en_mask = BIT(4),
1968 .reset_reg = CE3_HCLK_CTL_REG,
1969 .reset_mask = BIT(7),
1970 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
1971 .halt_bit = 16,
1972 },
1973 .parent = &ce3_src_clk.c,
1974 .c = {
1975 .dbg_name = "ce3_p_clk",
1976 .ops = &clk_ops_branch,
1977 CLK_INIT(ce3_p_clk.c),
1978 }
1979};
1980
1981static struct branch_clk sata_phy_ref_clk = {
1982 .b = {
1983 .ctl_reg = SATA_PHY_REF_CLK_CTL_REG,
1984 .en_mask = BIT(4),
1985 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1986 .halt_bit = 24,
1987 },
1988 .parent = &pxo_clk.c,
1989 .c = {
1990 .dbg_name = "sata_phy_ref_clk",
1991 .ops = &clk_ops_branch,
1992 CLK_INIT(sata_phy_ref_clk.c),
1993 },
1994};
1995
1996static struct branch_clk pcie_p_clk = {
1997 .b = {
1998 .ctl_reg = PCIE_HCLK_CTL_REG,
1999 .en_mask = BIT(4),
2000 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2001 .halt_bit = 8,
2002 },
2003 .c = {
2004 .dbg_name = "pcie_p_clk",
2005 .ops = &clk_ops_branch,
2006 CLK_INIT(pcie_p_clk.c),
2007 },
2008};
2009
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002010static struct branch_clk dma_bam_p_clk = {
2011 .b = {
2012 .ctl_reg = DMA_BAM_HCLK_CTL,
2013 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002014 .hwcg_reg = DMA_BAM_HCLK_CTL,
2015 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002016 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2017 .halt_bit = 12,
2018 },
2019 .c = {
2020 .dbg_name = "dma_bam_p_clk",
2021 .ops = &clk_ops_branch,
2022 CLK_INIT(dma_bam_p_clk.c),
2023 },
2024};
2025
2026static struct branch_clk gsbi1_p_clk = {
2027 .b = {
2028 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
2029 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002030 .hwcg_reg = GSBIn_HCLK_CTL_REG(1),
2031 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002032 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2033 .halt_bit = 11,
2034 },
2035 .c = {
2036 .dbg_name = "gsbi1_p_clk",
2037 .ops = &clk_ops_branch,
2038 CLK_INIT(gsbi1_p_clk.c),
2039 },
2040};
2041
2042static struct branch_clk gsbi2_p_clk = {
2043 .b = {
2044 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
2045 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002046 .hwcg_reg = GSBIn_HCLK_CTL_REG(2),
2047 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002048 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2049 .halt_bit = 7,
2050 },
2051 .c = {
2052 .dbg_name = "gsbi2_p_clk",
2053 .ops = &clk_ops_branch,
2054 CLK_INIT(gsbi2_p_clk.c),
2055 },
2056};
2057
2058static struct branch_clk gsbi3_p_clk = {
2059 .b = {
2060 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
2061 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002062 .hwcg_reg = GSBIn_HCLK_CTL_REG(3),
2063 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002064 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2065 .halt_bit = 3,
2066 },
2067 .c = {
2068 .dbg_name = "gsbi3_p_clk",
2069 .ops = &clk_ops_branch,
2070 CLK_INIT(gsbi3_p_clk.c),
2071 },
2072};
2073
2074static struct branch_clk gsbi4_p_clk = {
2075 .b = {
2076 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
2077 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002078 .hwcg_reg = GSBIn_HCLK_CTL_REG(4),
2079 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002080 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2081 .halt_bit = 27,
2082 },
2083 .c = {
2084 .dbg_name = "gsbi4_p_clk",
2085 .ops = &clk_ops_branch,
2086 CLK_INIT(gsbi4_p_clk.c),
2087 },
2088};
2089
2090static struct branch_clk gsbi5_p_clk = {
2091 .b = {
2092 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
2093 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002094 .hwcg_reg = GSBIn_HCLK_CTL_REG(5),
2095 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002096 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2097 .halt_bit = 23,
2098 },
2099 .c = {
2100 .dbg_name = "gsbi5_p_clk",
2101 .ops = &clk_ops_branch,
2102 CLK_INIT(gsbi5_p_clk.c),
2103 },
2104};
2105
2106static struct branch_clk gsbi6_p_clk = {
2107 .b = {
2108 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
2109 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002110 .hwcg_reg = GSBIn_HCLK_CTL_REG(6),
2111 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002112 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2113 .halt_bit = 19,
2114 },
2115 .c = {
2116 .dbg_name = "gsbi6_p_clk",
2117 .ops = &clk_ops_branch,
2118 CLK_INIT(gsbi6_p_clk.c),
2119 },
2120};
2121
2122static struct branch_clk gsbi7_p_clk = {
2123 .b = {
2124 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
2125 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002126 .hwcg_reg = GSBIn_HCLK_CTL_REG(7),
2127 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002128 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2129 .halt_bit = 15,
2130 },
2131 .c = {
2132 .dbg_name = "gsbi7_p_clk",
2133 .ops = &clk_ops_branch,
2134 CLK_INIT(gsbi7_p_clk.c),
2135 },
2136};
2137
2138static struct branch_clk gsbi8_p_clk = {
2139 .b = {
2140 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
2141 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002142 .hwcg_reg = GSBIn_HCLK_CTL_REG(8),
2143 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002144 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2145 .halt_bit = 11,
2146 },
2147 .c = {
2148 .dbg_name = "gsbi8_p_clk",
2149 .ops = &clk_ops_branch,
2150 CLK_INIT(gsbi8_p_clk.c),
2151 },
2152};
2153
2154static struct branch_clk gsbi9_p_clk = {
2155 .b = {
2156 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
2157 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002158 .hwcg_reg = GSBIn_HCLK_CTL_REG(9),
2159 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002160 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2161 .halt_bit = 7,
2162 },
2163 .c = {
2164 .dbg_name = "gsbi9_p_clk",
2165 .ops = &clk_ops_branch,
2166 CLK_INIT(gsbi9_p_clk.c),
2167 },
2168};
2169
2170static struct branch_clk gsbi10_p_clk = {
2171 .b = {
2172 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
2173 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002174 .hwcg_reg = GSBIn_HCLK_CTL_REG(10),
2175 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002176 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2177 .halt_bit = 3,
2178 },
2179 .c = {
2180 .dbg_name = "gsbi10_p_clk",
2181 .ops = &clk_ops_branch,
2182 CLK_INIT(gsbi10_p_clk.c),
2183 },
2184};
2185
2186static struct branch_clk gsbi11_p_clk = {
2187 .b = {
2188 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
2189 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002190 .hwcg_reg = GSBIn_HCLK_CTL_REG(11),
2191 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002192 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2193 .halt_bit = 18,
2194 },
2195 .c = {
2196 .dbg_name = "gsbi11_p_clk",
2197 .ops = &clk_ops_branch,
2198 CLK_INIT(gsbi11_p_clk.c),
2199 },
2200};
2201
2202static struct branch_clk gsbi12_p_clk = {
2203 .b = {
2204 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
2205 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002206 .hwcg_reg = GSBIn_HCLK_CTL_REG(12),
2207 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002208 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2209 .halt_bit = 14,
2210 },
2211 .c = {
2212 .dbg_name = "gsbi12_p_clk",
2213 .ops = &clk_ops_branch,
2214 CLK_INIT(gsbi12_p_clk.c),
2215 },
2216};
2217
Tianyi Gou41515e22011-09-01 19:37:43 -07002218static struct branch_clk sata_phy_cfg_clk = {
2219 .b = {
2220 .ctl_reg = SATA_PHY_CFG_CLK_CTL_REG,
2221 .en_mask = BIT(4),
2222 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2223 .halt_bit = 12,
2224 },
2225 .c = {
2226 .dbg_name = "sata_phy_cfg_clk",
2227 .ops = &clk_ops_branch,
2228 CLK_INIT(sata_phy_cfg_clk.c),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002229 },
2230};
2231
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002232static struct branch_clk tsif_p_clk = {
2233 .b = {
2234 .ctl_reg = TSIF_HCLK_CTL_REG,
2235 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002236 .hwcg_reg = TSIF_HCLK_CTL_REG,
2237 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002238 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2239 .halt_bit = 7,
2240 },
2241 .c = {
2242 .dbg_name = "tsif_p_clk",
2243 .ops = &clk_ops_branch,
2244 CLK_INIT(tsif_p_clk.c),
2245 },
2246};
2247
2248static struct branch_clk usb_fs1_p_clk = {
2249 .b = {
2250 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
2251 .en_mask = BIT(4),
2252 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2253 .halt_bit = 17,
2254 },
2255 .c = {
2256 .dbg_name = "usb_fs1_p_clk",
2257 .ops = &clk_ops_branch,
2258 CLK_INIT(usb_fs1_p_clk.c),
2259 },
2260};
2261
2262static struct branch_clk usb_fs2_p_clk = {
2263 .b = {
2264 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
2265 .en_mask = BIT(4),
2266 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2267 .halt_bit = 14,
2268 },
2269 .c = {
2270 .dbg_name = "usb_fs2_p_clk",
2271 .ops = &clk_ops_branch,
2272 CLK_INIT(usb_fs2_p_clk.c),
2273 },
2274};
2275
2276static struct branch_clk usb_hs1_p_clk = {
2277 .b = {
2278 .ctl_reg = USB_HS1_HCLK_CTL_REG,
2279 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002280 .hwcg_reg = USB_HS1_HCLK_CTL_REG,
2281 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002282 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2283 .halt_bit = 1,
2284 },
2285 .c = {
2286 .dbg_name = "usb_hs1_p_clk",
2287 .ops = &clk_ops_branch,
2288 CLK_INIT(usb_hs1_p_clk.c),
2289 },
2290};
2291
Tianyi Gou41515e22011-09-01 19:37:43 -07002292static struct branch_clk usb_hs3_p_clk = {
2293 .b = {
2294 .ctl_reg = USB_HS3_HCLK_CTL_REG,
2295 .en_mask = BIT(4),
2296 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2297 .halt_bit = 31,
2298 },
2299 .c = {
2300 .dbg_name = "usb_hs3_p_clk",
2301 .ops = &clk_ops_branch,
2302 CLK_INIT(usb_hs3_p_clk.c),
2303 },
2304};
2305
2306static struct branch_clk usb_hs4_p_clk = {
2307 .b = {
2308 .ctl_reg = USB_HS4_HCLK_CTL_REG,
2309 .en_mask = BIT(4),
2310 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2311 .halt_bit = 7,
2312 },
2313 .c = {
2314 .dbg_name = "usb_hs4_p_clk",
2315 .ops = &clk_ops_branch,
2316 CLK_INIT(usb_hs4_p_clk.c),
2317 },
2318};
2319
Stephen Boyd94625ef2011-07-12 17:06:01 -07002320static struct branch_clk usb_hsic_p_clk = {
2321 .b = {
2322 .ctl_reg = USB_HSIC_HCLK_CTL_REG,
2323 .en_mask = BIT(4),
2324 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2325 .halt_bit = 28,
2326 },
2327 .c = {
2328 .dbg_name = "usb_hsic_p_clk",
2329 .ops = &clk_ops_branch,
2330 CLK_INIT(usb_hsic_p_clk.c),
2331 },
2332};
2333
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002334static struct branch_clk sdc1_p_clk = {
2335 .b = {
2336 .ctl_reg = SDCn_HCLK_CTL_REG(1),
2337 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002338 .hwcg_reg = SDCn_HCLK_CTL_REG(1),
2339 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002340 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2341 .halt_bit = 11,
2342 },
2343 .c = {
2344 .dbg_name = "sdc1_p_clk",
2345 .ops = &clk_ops_branch,
2346 CLK_INIT(sdc1_p_clk.c),
2347 },
2348};
2349
2350static struct branch_clk sdc2_p_clk = {
2351 .b = {
2352 .ctl_reg = SDCn_HCLK_CTL_REG(2),
2353 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002354 .hwcg_reg = SDCn_HCLK_CTL_REG(2),
2355 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002356 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2357 .halt_bit = 10,
2358 },
2359 .c = {
2360 .dbg_name = "sdc2_p_clk",
2361 .ops = &clk_ops_branch,
2362 CLK_INIT(sdc2_p_clk.c),
2363 },
2364};
2365
2366static struct branch_clk sdc3_p_clk = {
2367 .b = {
2368 .ctl_reg = SDCn_HCLK_CTL_REG(3),
2369 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002370 .hwcg_reg = SDCn_HCLK_CTL_REG(3),
2371 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002372 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2373 .halt_bit = 9,
2374 },
2375 .c = {
2376 .dbg_name = "sdc3_p_clk",
2377 .ops = &clk_ops_branch,
2378 CLK_INIT(sdc3_p_clk.c),
2379 },
2380};
2381
2382static struct branch_clk sdc4_p_clk = {
2383 .b = {
2384 .ctl_reg = SDCn_HCLK_CTL_REG(4),
2385 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002386 .hwcg_reg = SDCn_HCLK_CTL_REG(4),
2387 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002388 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2389 .halt_bit = 8,
2390 },
2391 .c = {
2392 .dbg_name = "sdc4_p_clk",
2393 .ops = &clk_ops_branch,
2394 CLK_INIT(sdc4_p_clk.c),
2395 },
2396};
2397
2398static struct branch_clk sdc5_p_clk = {
2399 .b = {
2400 .ctl_reg = SDCn_HCLK_CTL_REG(5),
2401 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002402 .hwcg_reg = SDCn_HCLK_CTL_REG(5),
2403 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002404 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2405 .halt_bit = 7,
2406 },
2407 .c = {
2408 .dbg_name = "sdc5_p_clk",
2409 .ops = &clk_ops_branch,
2410 CLK_INIT(sdc5_p_clk.c),
2411 },
2412};
2413
2414/* HW-Voteable Clocks */
2415static struct branch_clk adm0_clk = {
2416 .b = {
2417 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2418 .en_mask = BIT(2),
2419 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2420 .halt_check = HALT_VOTED,
2421 .halt_bit = 14,
2422 },
2423 .c = {
2424 .dbg_name = "adm0_clk",
2425 .ops = &clk_ops_branch,
2426 CLK_INIT(adm0_clk.c),
2427 },
2428};
2429
2430static struct branch_clk adm0_p_clk = {
2431 .b = {
2432 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2433 .en_mask = BIT(3),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002434 .hwcg_reg = ADM0_PBUS_CLK_CTL_REG,
2435 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002436 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2437 .halt_check = HALT_VOTED,
2438 .halt_bit = 13,
2439 },
2440 .c = {
2441 .dbg_name = "adm0_p_clk",
2442 .ops = &clk_ops_branch,
2443 CLK_INIT(adm0_p_clk.c),
2444 },
2445};
2446
2447static struct branch_clk pmic_arb0_p_clk = {
2448 .b = {
2449 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2450 .en_mask = BIT(8),
2451 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2452 .halt_check = HALT_VOTED,
2453 .halt_bit = 22,
2454 },
2455 .c = {
2456 .dbg_name = "pmic_arb0_p_clk",
2457 .ops = &clk_ops_branch,
2458 CLK_INIT(pmic_arb0_p_clk.c),
2459 },
2460};
2461
2462static struct branch_clk pmic_arb1_p_clk = {
2463 .b = {
2464 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2465 .en_mask = BIT(9),
2466 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2467 .halt_check = HALT_VOTED,
2468 .halt_bit = 21,
2469 },
2470 .c = {
2471 .dbg_name = "pmic_arb1_p_clk",
2472 .ops = &clk_ops_branch,
2473 CLK_INIT(pmic_arb1_p_clk.c),
2474 },
2475};
2476
2477static struct branch_clk pmic_ssbi2_clk = {
2478 .b = {
2479 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2480 .en_mask = BIT(7),
2481 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2482 .halt_check = HALT_VOTED,
2483 .halt_bit = 23,
2484 },
2485 .c = {
2486 .dbg_name = "pmic_ssbi2_clk",
2487 .ops = &clk_ops_branch,
2488 CLK_INIT(pmic_ssbi2_clk.c),
2489 },
2490};
2491
2492static struct branch_clk rpm_msg_ram_p_clk = {
2493 .b = {
2494 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2495 .en_mask = BIT(6),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002496 .hwcg_reg = RPM_MSG_RAM_HCLK_CTL_REG,
2497 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002498 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2499 .halt_check = HALT_VOTED,
2500 .halt_bit = 12,
2501 },
2502 .c = {
2503 .dbg_name = "rpm_msg_ram_p_clk",
2504 .ops = &clk_ops_branch,
2505 CLK_INIT(rpm_msg_ram_p_clk.c),
2506 },
2507};
2508
2509/*
2510 * Multimedia Clocks
2511 */
2512
2513static struct branch_clk amp_clk = {
2514 .b = {
2515 .reset_reg = SW_RESET_CORE_REG,
2516 .reset_mask = BIT(20),
2517 },
2518 .c = {
2519 .dbg_name = "amp_clk",
2520 .ops = &clk_ops_reset,
2521 CLK_INIT(amp_clk.c),
2522 },
2523};
2524
Stephen Boyd94625ef2011-07-12 17:06:01 -07002525#define CLK_CAM(name, n, hb) \
2526 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002527 .b = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002528 .ctl_reg = CAMCLK##n##_CC_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002529 .en_mask = BIT(0), \
2530 .halt_reg = DBG_BUS_VEC_I_REG, \
2531 .halt_bit = hb, \
2532 }, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002533 .ns_reg = CAMCLK##n##_NS_REG, \
2534 .md_reg = CAMCLK##n##_MD_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002535 .root_en_mask = BIT(2), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002536 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0), \
Matt Wagantall07c45472012-02-10 23:27:24 -08002537 .mnd_en_mask = BIT(5), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002538 .ctl_mask = BM(7, 6), \
2539 .set_rate = set_rate_mnd_8, \
2540 .freq_tbl = clk_tbl_cam, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002541 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002542 .c = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002543 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002544 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002545 VDD_DIG_FMAX_MAP2(LOW, 64000000, NOMINAL, 128000000), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002546 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002547 }, \
2548 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002549#define F_CAM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002550 { \
2551 .freq_hz = f, \
2552 .src_clk = &s##_clk.c, \
2553 .md_val = MD8(8, m, 0, n), \
2554 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2555 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002556 }
2557static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002558 F_CAM( 0, gnd, 1, 0, 0),
2559 F_CAM( 6000000, pll8, 4, 1, 16),
2560 F_CAM( 8000000, pll8, 4, 1, 12),
2561 F_CAM( 12000000, pll8, 4, 1, 8),
2562 F_CAM( 16000000, pll8, 4, 1, 6),
2563 F_CAM( 19200000, pll8, 4, 1, 5),
2564 F_CAM( 24000000, pll8, 4, 1, 4),
2565 F_CAM( 32000000, pll8, 4, 1, 3),
2566 F_CAM( 48000000, pll8, 4, 1, 2),
2567 F_CAM( 64000000, pll8, 3, 1, 2),
2568 F_CAM( 96000000, pll8, 4, 0, 0),
2569 F_CAM(128000000, pll8, 3, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002570 F_END
2571};
2572
Stephen Boyd94625ef2011-07-12 17:06:01 -07002573static CLK_CAM(cam0_clk, 0, 15);
2574static CLK_CAM(cam1_clk, 1, 16);
2575static CLK_CAM(cam2_clk, 2, 31);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002576
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002577#define F_CSI(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002578 { \
2579 .freq_hz = f, \
2580 .src_clk = &s##_clk.c, \
2581 .md_val = MD8(8, m, 0, n), \
2582 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2583 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002584 }
2585static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002586 F_CSI( 0, gnd, 1, 0, 0),
Stephen Boyd092fd182011-10-21 15:56:30 -07002587 F_CSI( 27000000, pxo, 1, 0, 0),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002588 F_CSI( 85330000, pll8, 1, 2, 9),
2589 F_CSI(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002590 F_END
2591};
2592
2593static struct rcg_clk csi0_src_clk = {
2594 .ns_reg = CSI0_NS_REG,
2595 .b = {
2596 .ctl_reg = CSI0_CC_REG,
2597 .halt_check = NOCHECK,
2598 },
2599 .md_reg = CSI0_MD_REG,
2600 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002601 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Matt Wagantall07c45472012-02-10 23:27:24 -08002602 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002603 .ctl_mask = BM(7, 6),
2604 .set_rate = set_rate_mnd,
2605 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002606 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002607 .c = {
2608 .dbg_name = "csi0_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002609 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002610 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002611 CLK_INIT(csi0_src_clk.c),
2612 },
2613};
2614
2615static struct branch_clk csi0_clk = {
2616 .b = {
2617 .ctl_reg = CSI0_CC_REG,
2618 .en_mask = BIT(0),
2619 .reset_reg = SW_RESET_CORE_REG,
2620 .reset_mask = BIT(8),
2621 .halt_reg = DBG_BUS_VEC_B_REG,
2622 .halt_bit = 13,
2623 },
2624 .parent = &csi0_src_clk.c,
2625 .c = {
2626 .dbg_name = "csi0_clk",
2627 .ops = &clk_ops_branch,
2628 CLK_INIT(csi0_clk.c),
2629 },
2630};
2631
2632static struct branch_clk csi0_phy_clk = {
2633 .b = {
2634 .ctl_reg = CSI0_CC_REG,
2635 .en_mask = BIT(8),
2636 .reset_reg = SW_RESET_CORE_REG,
2637 .reset_mask = BIT(29),
2638 .halt_reg = DBG_BUS_VEC_I_REG,
2639 .halt_bit = 9,
2640 },
2641 .parent = &csi0_src_clk.c,
2642 .c = {
2643 .dbg_name = "csi0_phy_clk",
2644 .ops = &clk_ops_branch,
2645 CLK_INIT(csi0_phy_clk.c),
2646 },
2647};
2648
2649static struct rcg_clk csi1_src_clk = {
2650 .ns_reg = CSI1_NS_REG,
2651 .b = {
2652 .ctl_reg = CSI1_CC_REG,
2653 .halt_check = NOCHECK,
2654 },
2655 .md_reg = CSI1_MD_REG,
2656 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002657 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Matt Wagantall07c45472012-02-10 23:27:24 -08002658 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002659 .ctl_mask = BM(7, 6),
2660 .set_rate = set_rate_mnd,
2661 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002662 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002663 .c = {
2664 .dbg_name = "csi1_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002665 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002666 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002667 CLK_INIT(csi1_src_clk.c),
2668 },
2669};
2670
2671static struct branch_clk csi1_clk = {
2672 .b = {
2673 .ctl_reg = CSI1_CC_REG,
2674 .en_mask = BIT(0),
2675 .reset_reg = SW_RESET_CORE_REG,
2676 .reset_mask = BIT(18),
2677 .halt_reg = DBG_BUS_VEC_B_REG,
2678 .halt_bit = 14,
2679 },
2680 .parent = &csi1_src_clk.c,
2681 .c = {
2682 .dbg_name = "csi1_clk",
2683 .ops = &clk_ops_branch,
2684 CLK_INIT(csi1_clk.c),
2685 },
2686};
2687
2688static struct branch_clk csi1_phy_clk = {
2689 .b = {
2690 .ctl_reg = CSI1_CC_REG,
2691 .en_mask = BIT(8),
2692 .reset_reg = SW_RESET_CORE_REG,
2693 .reset_mask = BIT(28),
2694 .halt_reg = DBG_BUS_VEC_I_REG,
2695 .halt_bit = 10,
2696 },
2697 .parent = &csi1_src_clk.c,
2698 .c = {
2699 .dbg_name = "csi1_phy_clk",
2700 .ops = &clk_ops_branch,
2701 CLK_INIT(csi1_phy_clk.c),
2702 },
2703};
2704
Stephen Boyd94625ef2011-07-12 17:06:01 -07002705static struct rcg_clk csi2_src_clk = {
2706 .ns_reg = CSI2_NS_REG,
2707 .b = {
2708 .ctl_reg = CSI2_CC_REG,
2709 .halt_check = NOCHECK,
2710 },
2711 .md_reg = CSI2_MD_REG,
2712 .root_en_mask = BIT(2),
2713 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Matt Wagantall07c45472012-02-10 23:27:24 -08002714 .mnd_en_mask = BIT(5),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002715 .ctl_mask = BM(7, 6),
2716 .set_rate = set_rate_mnd,
2717 .freq_tbl = clk_tbl_csi,
2718 .current_freq = &rcg_dummy_freq,
2719 .c = {
2720 .dbg_name = "csi2_src_clk",
2721 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002722 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002723 CLK_INIT(csi2_src_clk.c),
2724 },
2725};
2726
2727static struct branch_clk csi2_clk = {
2728 .b = {
2729 .ctl_reg = CSI2_CC_REG,
2730 .en_mask = BIT(0),
2731 .reset_reg = SW_RESET_CORE2_REG,
2732 .reset_mask = BIT(2),
2733 .halt_reg = DBG_BUS_VEC_B_REG,
2734 .halt_bit = 29,
2735 },
2736 .parent = &csi2_src_clk.c,
2737 .c = {
2738 .dbg_name = "csi2_clk",
2739 .ops = &clk_ops_branch,
2740 CLK_INIT(csi2_clk.c),
2741 },
2742};
2743
2744static struct branch_clk csi2_phy_clk = {
2745 .b = {
2746 .ctl_reg = CSI2_CC_REG,
2747 .en_mask = BIT(8),
2748 .reset_reg = SW_RESET_CORE_REG,
2749 .reset_mask = BIT(31),
2750 .halt_reg = DBG_BUS_VEC_I_REG,
2751 .halt_bit = 29,
2752 },
2753 .parent = &csi2_src_clk.c,
2754 .c = {
2755 .dbg_name = "csi2_phy_clk",
2756 .ops = &clk_ops_branch,
2757 CLK_INIT(csi2_phy_clk.c),
2758 },
2759};
2760
Stephen Boyd092fd182011-10-21 15:56:30 -07002761static struct clk *pix_rdi_mux_map[] = {
2762 [0] = &csi0_clk.c,
2763 [1] = &csi1_clk.c,
2764 [2] = &csi2_clk.c,
2765 NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002766};
2767
Stephen Boyd092fd182011-10-21 15:56:30 -07002768struct pix_rdi_clk {
2769 bool enabled;
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002770 unsigned long cur_rate;
Stephen Boyd092fd182011-10-21 15:56:30 -07002771
2772 void __iomem *const s_reg;
2773 u32 s_mask;
2774
2775 void __iomem *const s2_reg;
2776 u32 s2_mask;
2777
2778 struct branch b;
2779 struct clk c;
2780};
2781
2782static inline struct pix_rdi_clk *to_pix_rdi_clk(struct clk *clk)
2783{
2784 return container_of(clk, struct pix_rdi_clk, c);
2785}
2786
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002787static int pix_rdi_clk_set_rate(struct clk *c, unsigned long rate)
Stephen Boyd092fd182011-10-21 15:56:30 -07002788{
2789 int ret, i;
2790 u32 reg;
2791 unsigned long flags;
2792 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2793 struct clk **mux_map = pix_rdi_mux_map;
2794
2795 /*
2796 * These clocks select three inputs via two muxes. One mux selects
2797 * between csi0 and csi1 and the second mux selects between that mux's
2798 * output and csi2. The source and destination selections for each
2799 * mux must be clocking for the switch to succeed so just turn on
2800 * all three sources because it's easier than figuring out what source
2801 * needs to be on at what time.
2802 */
2803 for (i = 0; mux_map[i]; i++) {
2804 ret = clk_enable(mux_map[i]);
2805 if (ret)
2806 goto err;
2807 }
2808 if (rate >= i) {
2809 ret = -EINVAL;
2810 goto err;
2811 }
2812 /* Keep the new source on when switching inputs of an enabled clock */
2813 if (clk->enabled) {
2814 clk_disable(mux_map[clk->cur_rate]);
2815 clk_enable(mux_map[rate]);
2816 }
2817 spin_lock_irqsave(&local_clock_reg_lock, flags);
2818 reg = readl_relaxed(clk->s2_reg);
2819 reg &= ~clk->s2_mask;
2820 reg |= rate == 2 ? clk->s2_mask : 0;
2821 writel_relaxed(reg, clk->s2_reg);
2822 /*
2823 * Wait at least 6 cycles of slowest clock
2824 * for the glitch-free MUX to fully switch sources.
2825 */
2826 mb();
2827 udelay(1);
2828 reg = readl_relaxed(clk->s_reg);
2829 reg &= ~clk->s_mask;
2830 reg |= rate == 1 ? clk->s_mask : 0;
2831 writel_relaxed(reg, clk->s_reg);
2832 /*
2833 * Wait at least 6 cycles of slowest clock
2834 * for the glitch-free MUX to fully switch sources.
2835 */
2836 mb();
2837 udelay(1);
2838 clk->cur_rate = rate;
2839 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2840err:
2841 for (i--; i >= 0; i--)
2842 clk_disable(mux_map[i]);
2843
2844 return 0;
2845}
2846
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002847static unsigned long pix_rdi_clk_get_rate(struct clk *c)
Stephen Boyd092fd182011-10-21 15:56:30 -07002848{
2849 return to_pix_rdi_clk(c)->cur_rate;
2850}
2851
2852static int pix_rdi_clk_enable(struct clk *c)
2853{
2854 unsigned long flags;
2855 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2856
2857 spin_lock_irqsave(&local_clock_reg_lock, flags);
2858 __branch_clk_enable_reg(&clk->b, clk->c.dbg_name);
2859 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2860 clk->enabled = true;
2861
2862 return 0;
2863}
2864
2865static void pix_rdi_clk_disable(struct clk *c)
2866{
2867 unsigned long flags;
2868 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2869
2870 spin_lock_irqsave(&local_clock_reg_lock, flags);
2871 __branch_clk_disable_reg(&clk->b, clk->c.dbg_name);
2872 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2873 clk->enabled = false;
2874}
2875
2876static int pix_rdi_clk_reset(struct clk *clk, enum clk_reset_action action)
2877{
2878 return branch_reset(&to_pix_rdi_clk(clk)->b, action);
2879}
2880
2881static struct clk *pix_rdi_clk_get_parent(struct clk *c)
2882{
2883 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2884
2885 return pix_rdi_mux_map[clk->cur_rate];
2886}
2887
2888static int pix_rdi_clk_list_rate(struct clk *c, unsigned n)
2889{
2890 if (pix_rdi_mux_map[n])
2891 return n;
2892 return -ENXIO;
2893}
2894
2895static int pix_rdi_clk_handoff(struct clk *c)
2896{
2897 u32 reg;
2898 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2899
2900 reg = readl_relaxed(clk->s_reg);
2901 clk->cur_rate = reg & clk->s_mask ? 1 : 0;
2902 reg = readl_relaxed(clk->s2_reg);
2903 clk->cur_rate = reg & clk->s2_mask ? 2 : clk->cur_rate;
2904 return 0;
2905}
2906
2907static struct clk_ops clk_ops_pix_rdi_8960 = {
2908 .enable = pix_rdi_clk_enable,
2909 .disable = pix_rdi_clk_disable,
2910 .auto_off = pix_rdi_clk_disable,
2911 .handoff = pix_rdi_clk_handoff,
2912 .set_rate = pix_rdi_clk_set_rate,
2913 .get_rate = pix_rdi_clk_get_rate,
2914 .list_rate = pix_rdi_clk_list_rate,
2915 .reset = pix_rdi_clk_reset,
2916 .is_local = local_clk_is_local,
2917 .get_parent = pix_rdi_clk_get_parent,
2918};
2919
2920static struct pix_rdi_clk csi_pix_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002921 .b = {
2922 .ctl_reg = MISC_CC_REG,
2923 .en_mask = BIT(26),
2924 .halt_check = DELAY,
2925 .reset_reg = SW_RESET_CORE_REG,
2926 .reset_mask = BIT(26),
2927 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002928 .s_reg = MISC_CC_REG,
2929 .s_mask = BIT(25),
2930 .s2_reg = MISC_CC3_REG,
2931 .s2_mask = BIT(13),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002932 .c = {
2933 .dbg_name = "csi_pix_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002934 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002935 CLK_INIT(csi_pix_clk.c),
2936 },
2937};
2938
Stephen Boyd092fd182011-10-21 15:56:30 -07002939static struct pix_rdi_clk csi_pix1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07002940 .b = {
2941 .ctl_reg = MISC_CC3_REG,
2942 .en_mask = BIT(10),
2943 .halt_check = DELAY,
2944 .reset_reg = SW_RESET_CORE_REG,
2945 .reset_mask = BIT(30),
2946 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002947 .s_reg = MISC_CC3_REG,
2948 .s_mask = BIT(8),
2949 .s2_reg = MISC_CC3_REG,
2950 .s2_mask = BIT(9),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002951 .c = {
2952 .dbg_name = "csi_pix1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002953 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07002954 CLK_INIT(csi_pix1_clk.c),
2955 },
2956};
2957
Stephen Boyd092fd182011-10-21 15:56:30 -07002958static struct pix_rdi_clk csi_rdi_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002959 .b = {
2960 .ctl_reg = MISC_CC_REG,
2961 .en_mask = BIT(13),
2962 .halt_check = DELAY,
2963 .reset_reg = SW_RESET_CORE_REG,
2964 .reset_mask = BIT(27),
2965 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002966 .s_reg = MISC_CC_REG,
2967 .s_mask = BIT(12),
2968 .s2_reg = MISC_CC3_REG,
2969 .s2_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002970 .c = {
2971 .dbg_name = "csi_rdi_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002972 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002973 CLK_INIT(csi_rdi_clk.c),
2974 },
2975};
2976
Stephen Boyd092fd182011-10-21 15:56:30 -07002977static struct pix_rdi_clk csi_rdi1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07002978 .b = {
2979 .ctl_reg = MISC_CC3_REG,
2980 .en_mask = BIT(2),
2981 .halt_check = DELAY,
2982 .reset_reg = SW_RESET_CORE2_REG,
2983 .reset_mask = BIT(1),
2984 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002985 .s_reg = MISC_CC3_REG,
2986 .s_mask = BIT(0),
2987 .s2_reg = MISC_CC3_REG,
2988 .s2_mask = BIT(1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002989 .c = {
2990 .dbg_name = "csi_rdi1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002991 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07002992 CLK_INIT(csi_rdi1_clk.c),
2993 },
2994};
2995
Stephen Boyd092fd182011-10-21 15:56:30 -07002996static struct pix_rdi_clk csi_rdi2_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07002997 .b = {
2998 .ctl_reg = MISC_CC3_REG,
2999 .en_mask = BIT(6),
3000 .halt_check = DELAY,
3001 .reset_reg = SW_RESET_CORE2_REG,
3002 .reset_mask = BIT(0),
3003 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003004 .s_reg = MISC_CC3_REG,
3005 .s_mask = BIT(4),
3006 .s2_reg = MISC_CC3_REG,
3007 .s2_mask = BIT(5),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003008 .c = {
3009 .dbg_name = "csi_rdi2_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003010 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003011 CLK_INIT(csi_rdi2_clk.c),
3012 },
3013};
3014
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003015#define F_CSI_PHYTIMER(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003016 { \
3017 .freq_hz = f, \
3018 .src_clk = &s##_clk.c, \
3019 .md_val = MD8(8, m, 0, n), \
3020 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3021 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003022 }
3023static struct clk_freq_tbl clk_tbl_csi_phytimer[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003024 F_CSI_PHYTIMER( 0, gnd, 1, 0, 0),
3025 F_CSI_PHYTIMER( 85330000, pll8, 1, 2, 9),
3026 F_CSI_PHYTIMER(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003027 F_END
3028};
3029
3030static struct rcg_clk csiphy_timer_src_clk = {
3031 .ns_reg = CSIPHYTIMER_NS_REG,
3032 .b = {
3033 .ctl_reg = CSIPHYTIMER_CC_REG,
3034 .halt_check = NOCHECK,
3035 },
3036 .md_reg = CSIPHYTIMER_MD_REG,
3037 .root_en_mask = BIT(2),
3038 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08003039 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003040 .ctl_mask = BM(7, 6),
3041 .set_rate = set_rate_mnd_8,
3042 .freq_tbl = clk_tbl_csi_phytimer,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003043 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003044 .c = {
3045 .dbg_name = "csiphy_timer_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003046 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003047 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003048 CLK_INIT(csiphy_timer_src_clk.c),
3049 },
3050};
3051
3052static struct branch_clk csi0phy_timer_clk = {
3053 .b = {
3054 .ctl_reg = CSIPHYTIMER_CC_REG,
3055 .en_mask = BIT(0),
3056 .halt_reg = DBG_BUS_VEC_I_REG,
3057 .halt_bit = 17,
3058 },
3059 .parent = &csiphy_timer_src_clk.c,
3060 .c = {
3061 .dbg_name = "csi0phy_timer_clk",
3062 .ops = &clk_ops_branch,
3063 CLK_INIT(csi0phy_timer_clk.c),
3064 },
3065};
3066
3067static struct branch_clk csi1phy_timer_clk = {
3068 .b = {
3069 .ctl_reg = CSIPHYTIMER_CC_REG,
3070 .en_mask = BIT(9),
3071 .halt_reg = DBG_BUS_VEC_I_REG,
3072 .halt_bit = 18,
3073 },
3074 .parent = &csiphy_timer_src_clk.c,
3075 .c = {
3076 .dbg_name = "csi1phy_timer_clk",
3077 .ops = &clk_ops_branch,
3078 CLK_INIT(csi1phy_timer_clk.c),
3079 },
3080};
3081
Stephen Boyd94625ef2011-07-12 17:06:01 -07003082static struct branch_clk csi2phy_timer_clk = {
3083 .b = {
3084 .ctl_reg = CSIPHYTIMER_CC_REG,
3085 .en_mask = BIT(11),
3086 .halt_reg = DBG_BUS_VEC_I_REG,
3087 .halt_bit = 30,
3088 },
3089 .parent = &csiphy_timer_src_clk.c,
3090 .c = {
3091 .dbg_name = "csi2phy_timer_clk",
3092 .ops = &clk_ops_branch,
3093 CLK_INIT(csi2phy_timer_clk.c),
3094 },
3095};
3096
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003097#define F_DSI(d) \
3098 { \
3099 .freq_hz = d, \
3100 .ns_val = BVAL(15, 12, (d-1)), \
3101 }
3102/*
3103 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
3104 * without this clock driver knowing. So, overload the clk_set_rate() to set
3105 * the divider (1 to 16) of the clock with respect to the PLL rate.
3106 */
3107static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
3108 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
3109 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
3110 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
3111 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
3112 F_END
3113};
3114
3115static struct rcg_clk dsi1_byte_clk = {
3116 .b = {
3117 .ctl_reg = DSI1_BYTE_CC_REG,
3118 .en_mask = BIT(0),
3119 .reset_reg = SW_RESET_CORE_REG,
3120 .reset_mask = BIT(7),
3121 .halt_reg = DBG_BUS_VEC_B_REG,
3122 .halt_bit = 21,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003123 .retain_reg = DSI1_BYTE_CC_REG,
3124 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003125 },
3126 .ns_reg = DSI1_BYTE_NS_REG,
3127 .root_en_mask = BIT(2),
3128 .ns_mask = BM(15, 12),
3129 .set_rate = set_rate_nop,
3130 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003131 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003132 .c = {
3133 .dbg_name = "dsi1_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003134 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003135 CLK_INIT(dsi1_byte_clk.c),
3136 },
3137};
3138
3139static struct rcg_clk dsi2_byte_clk = {
3140 .b = {
3141 .ctl_reg = DSI2_BYTE_CC_REG,
3142 .en_mask = BIT(0),
3143 .reset_reg = SW_RESET_CORE_REG,
3144 .reset_mask = BIT(25),
3145 .halt_reg = DBG_BUS_VEC_B_REG,
3146 .halt_bit = 20,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003147 .retain_reg = DSI2_BYTE_CC_REG,
3148 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003149 },
3150 .ns_reg = DSI2_BYTE_NS_REG,
3151 .root_en_mask = BIT(2),
3152 .ns_mask = BM(15, 12),
3153 .set_rate = set_rate_nop,
3154 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003155 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003156 .c = {
3157 .dbg_name = "dsi2_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003158 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003159 CLK_INIT(dsi2_byte_clk.c),
3160 },
3161};
3162
3163static struct rcg_clk dsi1_esc_clk = {
3164 .b = {
3165 .ctl_reg = DSI1_ESC_CC_REG,
3166 .en_mask = BIT(0),
3167 .reset_reg = SW_RESET_CORE_REG,
3168 .halt_reg = DBG_BUS_VEC_I_REG,
3169 .halt_bit = 1,
3170 },
3171 .ns_reg = DSI1_ESC_NS_REG,
3172 .root_en_mask = BIT(2),
3173 .ns_mask = BM(15, 12),
3174 .set_rate = set_rate_nop,
3175 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003176 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003177 .c = {
3178 .dbg_name = "dsi1_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003179 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003180 CLK_INIT(dsi1_esc_clk.c),
3181 },
3182};
3183
3184static struct rcg_clk dsi2_esc_clk = {
3185 .b = {
3186 .ctl_reg = DSI2_ESC_CC_REG,
3187 .en_mask = BIT(0),
3188 .halt_reg = DBG_BUS_VEC_I_REG,
3189 .halt_bit = 3,
3190 },
3191 .ns_reg = DSI2_ESC_NS_REG,
3192 .root_en_mask = BIT(2),
3193 .ns_mask = BM(15, 12),
3194 .set_rate = set_rate_nop,
3195 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003196 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003197 .c = {
3198 .dbg_name = "dsi2_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003199 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003200 CLK_INIT(dsi2_esc_clk.c),
3201 },
3202};
3203
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003204#define F_GFX2D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003205 { \
3206 .freq_hz = f, \
3207 .src_clk = &s##_clk.c, \
3208 .md_val = MD4(4, m, 0, n), \
3209 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
3210 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003211 }
3212static struct clk_freq_tbl clk_tbl_gfx2d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003213 F_GFX2D( 0, gnd, 0, 0),
3214 F_GFX2D( 27000000, pxo, 0, 0),
3215 F_GFX2D( 48000000, pll8, 1, 8),
3216 F_GFX2D( 54857000, pll8, 1, 7),
3217 F_GFX2D( 64000000, pll8, 1, 6),
3218 F_GFX2D( 76800000, pll8, 1, 5),
3219 F_GFX2D( 96000000, pll8, 1, 4),
3220 F_GFX2D(128000000, pll8, 1, 3),
3221 F_GFX2D(145455000, pll2, 2, 11),
3222 F_GFX2D(160000000, pll2, 1, 5),
3223 F_GFX2D(177778000, pll2, 2, 9),
3224 F_GFX2D(200000000, pll2, 1, 4),
3225 F_GFX2D(228571000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003226 F_END
3227};
3228
3229static struct bank_masks bmnd_info_gfx2d0 = {
3230 .bank_sel_mask = BIT(11),
3231 .bank0_mask = {
3232 .md_reg = GFX2D0_MD0_REG,
3233 .ns_mask = BM(23, 20) | BM(5, 3),
3234 .rst_mask = BIT(25),
3235 .mnd_en_mask = BIT(8),
3236 .mode_mask = BM(10, 9),
3237 },
3238 .bank1_mask = {
3239 .md_reg = GFX2D0_MD1_REG,
3240 .ns_mask = BM(19, 16) | BM(2, 0),
3241 .rst_mask = BIT(24),
3242 .mnd_en_mask = BIT(5),
3243 .mode_mask = BM(7, 6),
3244 },
3245};
3246
3247static struct rcg_clk gfx2d0_clk = {
3248 .b = {
3249 .ctl_reg = GFX2D0_CC_REG,
3250 .en_mask = BIT(0),
3251 .reset_reg = SW_RESET_CORE_REG,
3252 .reset_mask = BIT(14),
3253 .halt_reg = DBG_BUS_VEC_A_REG,
3254 .halt_bit = 9,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003255 .retain_reg = GFX2D0_CC_REG,
3256 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003257 },
3258 .ns_reg = GFX2D0_NS_REG,
3259 .root_en_mask = BIT(2),
3260 .set_rate = set_rate_mnd_banked,
3261 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003262 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003263 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003264 .c = {
3265 .dbg_name = "gfx2d0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003266 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003267 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3268 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003269 CLK_INIT(gfx2d0_clk.c),
3270 },
3271};
3272
3273static struct bank_masks bmnd_info_gfx2d1 = {
3274 .bank_sel_mask = BIT(11),
3275 .bank0_mask = {
3276 .md_reg = GFX2D1_MD0_REG,
3277 .ns_mask = BM(23, 20) | BM(5, 3),
3278 .rst_mask = BIT(25),
3279 .mnd_en_mask = BIT(8),
3280 .mode_mask = BM(10, 9),
3281 },
3282 .bank1_mask = {
3283 .md_reg = GFX2D1_MD1_REG,
3284 .ns_mask = BM(19, 16) | BM(2, 0),
3285 .rst_mask = BIT(24),
3286 .mnd_en_mask = BIT(5),
3287 .mode_mask = BM(7, 6),
3288 },
3289};
3290
3291static struct rcg_clk gfx2d1_clk = {
3292 .b = {
3293 .ctl_reg = GFX2D1_CC_REG,
3294 .en_mask = BIT(0),
3295 .reset_reg = SW_RESET_CORE_REG,
3296 .reset_mask = BIT(13),
3297 .halt_reg = DBG_BUS_VEC_A_REG,
3298 .halt_bit = 14,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003299 .retain_reg = GFX2D1_CC_REG,
3300 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003301 },
3302 .ns_reg = GFX2D1_NS_REG,
3303 .root_en_mask = BIT(2),
3304 .set_rate = set_rate_mnd_banked,
3305 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003306 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003307 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003308 .c = {
3309 .dbg_name = "gfx2d1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003310 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003311 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3312 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003313 CLK_INIT(gfx2d1_clk.c),
3314 },
3315};
3316
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003317#define F_GFX3D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003318 { \
3319 .freq_hz = f, \
3320 .src_clk = &s##_clk.c, \
3321 .md_val = MD4(4, m, 0, n), \
3322 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3323 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003324 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003325
3326static struct clk_freq_tbl clk_tbl_gfx3d_8960[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003327 F_GFX3D( 0, gnd, 0, 0),
3328 F_GFX3D( 27000000, pxo, 0, 0),
3329 F_GFX3D( 48000000, pll8, 1, 8),
3330 F_GFX3D( 54857000, pll8, 1, 7),
3331 F_GFX3D( 64000000, pll8, 1, 6),
3332 F_GFX3D( 76800000, pll8, 1, 5),
3333 F_GFX3D( 96000000, pll8, 1, 4),
3334 F_GFX3D(128000000, pll8, 1, 3),
3335 F_GFX3D(145455000, pll2, 2, 11),
3336 F_GFX3D(160000000, pll2, 1, 5),
3337 F_GFX3D(177778000, pll2, 2, 9),
3338 F_GFX3D(200000000, pll2, 1, 4),
3339 F_GFX3D(228571000, pll2, 2, 7),
3340 F_GFX3D(266667000, pll2, 1, 3),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003341 F_GFX3D(300000000, pll3, 1, 4),
3342 F_GFX3D(320000000, pll2, 2, 5),
3343 F_GFX3D(400000000, pll2, 1, 2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003344 F_END
3345};
3346
Tianyi Gou41515e22011-09-01 19:37:43 -07003347static struct clk_freq_tbl clk_tbl_gfx3d_8064[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003348 F_GFX3D( 0, gnd, 0, 0),
3349 F_GFX3D( 27000000, pxo, 0, 0),
3350 F_GFX3D( 48000000, pll8, 1, 8),
3351 F_GFX3D( 54857000, pll8, 1, 7),
3352 F_GFX3D( 64000000, pll8, 1, 6),
3353 F_GFX3D( 76800000, pll8, 1, 5),
3354 F_GFX3D( 96000000, pll8, 1, 4),
3355 F_GFX3D(128000000, pll8, 1, 3),
3356 F_GFX3D(145455000, pll2, 2, 11),
3357 F_GFX3D(160000000, pll2, 1, 5),
3358 F_GFX3D(177778000, pll2, 2, 9),
3359 F_GFX3D(200000000, pll2, 1, 4),
3360 F_GFX3D(228571000, pll2, 2, 7),
3361 F_GFX3D(266667000, pll2, 1, 3),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07003362 F_GFX3D(325000000, pll15, 1, 3),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003363 F_GFX3D(400000000, pll2, 1, 2),
Tianyi Gou41515e22011-09-01 19:37:43 -07003364 F_END
3365};
3366
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003367static unsigned long fmax_gfx3d_8064[MAX_VDD_LEVELS] __initdata = {
3368 [VDD_DIG_LOW] = 128000000,
3369 [VDD_DIG_NOMINAL] = 325000000,
3370 [VDD_DIG_HIGH] = 400000000
3371};
3372
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003373static struct bank_masks bmnd_info_gfx3d = {
3374 .bank_sel_mask = BIT(11),
3375 .bank0_mask = {
3376 .md_reg = GFX3D_MD0_REG,
3377 .ns_mask = BM(21, 18) | BM(5, 3),
3378 .rst_mask = BIT(23),
3379 .mnd_en_mask = BIT(8),
3380 .mode_mask = BM(10, 9),
3381 },
3382 .bank1_mask = {
3383 .md_reg = GFX3D_MD1_REG,
3384 .ns_mask = BM(17, 14) | BM(2, 0),
3385 .rst_mask = BIT(22),
3386 .mnd_en_mask = BIT(5),
3387 .mode_mask = BM(7, 6),
3388 },
3389};
3390
3391static struct rcg_clk gfx3d_clk = {
3392 .b = {
3393 .ctl_reg = GFX3D_CC_REG,
3394 .en_mask = BIT(0),
3395 .reset_reg = SW_RESET_CORE_REG,
3396 .reset_mask = BIT(12),
3397 .halt_reg = DBG_BUS_VEC_A_REG,
3398 .halt_bit = 4,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003399 .retain_reg = GFX3D_CC_REG,
3400 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003401 },
3402 .ns_reg = GFX3D_NS_REG,
3403 .root_en_mask = BIT(2),
3404 .set_rate = set_rate_mnd_banked,
Tianyi Gou41515e22011-09-01 19:37:43 -07003405 .freq_tbl = clk_tbl_gfx3d_8960,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003406 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003407 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003408 .c = {
3409 .dbg_name = "gfx3d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003410 .ops = &clk_ops_rcg_8960,
Tianyi Gou3022dfd2012-01-25 15:50:05 -08003411 VDD_DIG_FMAX_MAP3(LOW, 128000000, NOMINAL, 300000000,
3412 HIGH, 400000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003413 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003414 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003415 },
3416};
3417
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003418#define F_VCAP(f, s, m, n) \
Tianyi Gou621f8742011-09-01 21:45:01 -07003419 { \
3420 .freq_hz = f, \
3421 .src_clk = &s##_clk.c, \
3422 .md_val = MD4(4, m, 0, n), \
3423 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3424 .ctl_val = CC_BANKED(9, 6, n), \
Tianyi Gou621f8742011-09-01 21:45:01 -07003425 }
3426
3427static struct clk_freq_tbl clk_tbl_vcap[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003428 F_VCAP( 0, gnd, 0, 0),
3429 F_VCAP( 27000000, pxo, 0, 0),
3430 F_VCAP( 54860000, pll8, 1, 7),
3431 F_VCAP( 64000000, pll8, 1, 6),
3432 F_VCAP( 76800000, pll8, 1, 5),
3433 F_VCAP(128000000, pll8, 1, 3),
3434 F_VCAP(160000000, pll2, 1, 5),
3435 F_VCAP(200000000, pll2, 1, 4),
Tianyi Gou621f8742011-09-01 21:45:01 -07003436 F_END
3437};
3438
3439static struct bank_masks bmnd_info_vcap = {
3440 .bank_sel_mask = BIT(11),
3441 .bank0_mask = {
3442 .md_reg = VCAP_MD0_REG,
3443 .ns_mask = BM(21, 18) | BM(5, 3),
3444 .rst_mask = BIT(23),
3445 .mnd_en_mask = BIT(8),
3446 .mode_mask = BM(10, 9),
3447 },
3448 .bank1_mask = {
3449 .md_reg = VCAP_MD1_REG,
3450 .ns_mask = BM(17, 14) | BM(2, 0),
3451 .rst_mask = BIT(22),
3452 .mnd_en_mask = BIT(5),
3453 .mode_mask = BM(7, 6),
3454 },
3455};
3456
3457static struct rcg_clk vcap_clk = {
3458 .b = {
3459 .ctl_reg = VCAP_CC_REG,
3460 .en_mask = BIT(0),
3461 .halt_reg = DBG_BUS_VEC_J_REG,
3462 .halt_bit = 15,
3463 },
3464 .ns_reg = VCAP_NS_REG,
3465 .root_en_mask = BIT(2),
3466 .set_rate = set_rate_mnd_banked,
3467 .freq_tbl = clk_tbl_vcap,
3468 .bank_info = &bmnd_info_vcap,
3469 .current_freq = &rcg_dummy_freq,
3470 .c = {
3471 .dbg_name = "vcap_clk",
3472 .ops = &clk_ops_rcg_8960,
3473 .depends = &vcap_axi_clk.c,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003474 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000),
Tianyi Gou621f8742011-09-01 21:45:01 -07003475 CLK_INIT(vcap_clk.c),
3476 },
3477};
3478
3479static struct branch_clk vcap_npl_clk = {
3480 .b = {
3481 .ctl_reg = VCAP_CC_REG,
3482 .en_mask = BIT(13),
3483 .halt_reg = DBG_BUS_VEC_J_REG,
3484 .halt_bit = 25,
3485 },
3486 .parent = &vcap_clk.c,
3487 .c = {
3488 .dbg_name = "vcap_npl_clk",
3489 .ops = &clk_ops_branch,
3490 CLK_INIT(vcap_npl_clk.c),
3491 },
3492};
3493
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003494#define F_IJPEG(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003495 { \
3496 .freq_hz = f, \
3497 .src_clk = &s##_clk.c, \
3498 .md_val = MD8(8, m, 0, n), \
3499 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
3500 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003501 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003502
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003503static struct clk_freq_tbl clk_tbl_ijpeg[] = {
3504 F_IJPEG( 0, gnd, 1, 0, 0),
3505 F_IJPEG( 27000000, pxo, 1, 0, 0),
3506 F_IJPEG( 36570000, pll8, 1, 2, 21),
3507 F_IJPEG( 54860000, pll8, 7, 0, 0),
3508 F_IJPEG( 96000000, pll8, 4, 0, 0),
3509 F_IJPEG(109710000, pll8, 1, 2, 7),
3510 F_IJPEG(128000000, pll8, 3, 0, 0),
3511 F_IJPEG(153600000, pll8, 1, 2, 5),
3512 F_IJPEG(200000000, pll2, 4, 0, 0),
3513 F_IJPEG(228571000, pll2, 1, 2, 7),
3514 F_IJPEG(266667000, pll2, 1, 1, 3),
3515 F_IJPEG(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003516 F_END
3517};
3518
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003519static unsigned long fmax_ijpeg_8064[MAX_VDD_LEVELS] __initdata = {
3520 [VDD_DIG_LOW] = 128000000,
3521 [VDD_DIG_NOMINAL] = 266667000,
3522 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07003523};
3524
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003525static struct rcg_clk ijpeg_clk = {
3526 .b = {
3527 .ctl_reg = IJPEG_CC_REG,
3528 .en_mask = BIT(0),
3529 .reset_reg = SW_RESET_CORE_REG,
3530 .reset_mask = BIT(9),
3531 .halt_reg = DBG_BUS_VEC_A_REG,
3532 .halt_bit = 24,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003533 .retain_reg = IJPEG_CC_REG,
3534 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003535 },
3536 .ns_reg = IJPEG_NS_REG,
3537 .md_reg = IJPEG_MD_REG,
3538 .root_en_mask = BIT(2),
3539 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08003540 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003541 .ctl_mask = BM(7, 6),
3542 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003543 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003544 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003545 .c = {
3546 .dbg_name = "ijpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003547 .ops = &clk_ops_rcg_8960,
Tianyi Gou3022dfd2012-01-25 15:50:05 -08003548 VDD_DIG_FMAX_MAP3(LOW, 110000000, NOMINAL, 266667000,
3549 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003550 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003551 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003552 },
3553};
3554
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003555#define F_JPEGD(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003556 { \
3557 .freq_hz = f, \
3558 .src_clk = &s##_clk.c, \
3559 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003560 }
3561static struct clk_freq_tbl clk_tbl_jpegd[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003562 F_JPEGD( 0, gnd, 1),
3563 F_JPEGD( 64000000, pll8, 6),
3564 F_JPEGD( 76800000, pll8, 5),
3565 F_JPEGD( 96000000, pll8, 4),
3566 F_JPEGD(160000000, pll2, 5),
3567 F_JPEGD(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003568 F_END
3569};
3570
3571static struct rcg_clk jpegd_clk = {
3572 .b = {
3573 .ctl_reg = JPEGD_CC_REG,
3574 .en_mask = BIT(0),
3575 .reset_reg = SW_RESET_CORE_REG,
3576 .reset_mask = BIT(19),
3577 .halt_reg = DBG_BUS_VEC_A_REG,
3578 .halt_bit = 19,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003579 .retain_reg = JPEGD_CC_REG,
3580 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003581 },
3582 .ns_reg = JPEGD_NS_REG,
3583 .root_en_mask = BIT(2),
3584 .ns_mask = (BM(15, 12) | BM(2, 0)),
3585 .set_rate = set_rate_nop,
3586 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003587 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003588 .c = {
3589 .dbg_name = "jpegd_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003590 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003591 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003592 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003593 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003594 },
3595};
3596
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003597#define F_MDP(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003598 { \
3599 .freq_hz = f, \
3600 .src_clk = &s##_clk.c, \
3601 .md_val = MD8(8, m, 0, n), \
3602 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
3603 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003604 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003605static struct clk_freq_tbl clk_tbl_mdp[] = {
3606 F_MDP( 0, gnd, 0, 0),
3607 F_MDP( 9600000, pll8, 1, 40),
3608 F_MDP( 13710000, pll8, 1, 28),
3609 F_MDP( 27000000, pxo, 0, 0),
3610 F_MDP( 29540000, pll8, 1, 13),
3611 F_MDP( 34910000, pll8, 1, 11),
3612 F_MDP( 38400000, pll8, 1, 10),
3613 F_MDP( 59080000, pll8, 2, 13),
3614 F_MDP( 76800000, pll8, 1, 5),
3615 F_MDP( 85330000, pll8, 2, 9),
3616 F_MDP( 96000000, pll8, 1, 4),
3617 F_MDP(128000000, pll8, 1, 3),
3618 F_MDP(160000000, pll2, 1, 5),
3619 F_MDP(177780000, pll2, 2, 9),
3620 F_MDP(200000000, pll2, 1, 4),
3621 F_MDP(266667000, pll2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003622 F_END
3623};
3624
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003625static unsigned long fmax_mdp_8064[MAX_VDD_LEVELS] __initdata = {
3626 [VDD_DIG_LOW] = 128000000,
3627 [VDD_DIG_NOMINAL] = 266667000
Tianyi Gou621f8742011-09-01 21:45:01 -07003628};
3629
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003630static struct bank_masks bmnd_info_mdp = {
3631 .bank_sel_mask = BIT(11),
3632 .bank0_mask = {
3633 .md_reg = MDP_MD0_REG,
3634 .ns_mask = BM(29, 22) | BM(5, 3),
3635 .rst_mask = BIT(31),
3636 .mnd_en_mask = BIT(8),
3637 .mode_mask = BM(10, 9),
3638 },
3639 .bank1_mask = {
3640 .md_reg = MDP_MD1_REG,
3641 .ns_mask = BM(21, 14) | BM(2, 0),
3642 .rst_mask = BIT(30),
3643 .mnd_en_mask = BIT(5),
3644 .mode_mask = BM(7, 6),
3645 },
3646};
3647
3648static struct rcg_clk mdp_clk = {
3649 .b = {
3650 .ctl_reg = MDP_CC_REG,
3651 .en_mask = BIT(0),
3652 .reset_reg = SW_RESET_CORE_REG,
3653 .reset_mask = BIT(21),
3654 .halt_reg = DBG_BUS_VEC_C_REG,
3655 .halt_bit = 10,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003656 .retain_reg = MDP_CC_REG,
3657 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003658 },
3659 .ns_reg = MDP_NS_REG,
3660 .root_en_mask = BIT(2),
3661 .set_rate = set_rate_mnd_banked,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003662 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003663 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003664 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003665 .c = {
3666 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003667 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003668 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003669 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003670 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003671 },
3672};
3673
3674static struct branch_clk lut_mdp_clk = {
3675 .b = {
3676 .ctl_reg = MDP_LUT_CC_REG,
3677 .en_mask = BIT(0),
3678 .halt_reg = DBG_BUS_VEC_I_REG,
3679 .halt_bit = 13,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003680 .retain_reg = MDP_LUT_CC_REG,
3681 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003682 },
3683 .parent = &mdp_clk.c,
3684 .c = {
3685 .dbg_name = "lut_mdp_clk",
3686 .ops = &clk_ops_branch,
3687 CLK_INIT(lut_mdp_clk.c),
3688 },
3689};
3690
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003691#define F_MDP_VSYNC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003692 { \
3693 .freq_hz = f, \
3694 .src_clk = &s##_clk.c, \
3695 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003696 }
3697static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003698 F_MDP_VSYNC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003699 F_END
3700};
3701
3702static struct rcg_clk mdp_vsync_clk = {
3703 .b = {
3704 .ctl_reg = MISC_CC_REG,
3705 .en_mask = BIT(6),
3706 .reset_reg = SW_RESET_CORE_REG,
3707 .reset_mask = BIT(3),
3708 .halt_reg = DBG_BUS_VEC_B_REG,
3709 .halt_bit = 22,
3710 },
3711 .ns_reg = MISC_CC2_REG,
3712 .ns_mask = BIT(13),
3713 .set_rate = set_rate_nop,
3714 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003715 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003716 .c = {
3717 .dbg_name = "mdp_vsync_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003718 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003719 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003720 CLK_INIT(mdp_vsync_clk.c),
3721 },
3722};
3723
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003724#define F_ROT(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003725 { \
3726 .freq_hz = f, \
3727 .src_clk = &s##_clk.c, \
3728 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
3729 21, 19, 18, 16, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003730 }
3731static struct clk_freq_tbl clk_tbl_rot[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003732 F_ROT( 0, gnd, 1),
3733 F_ROT( 27000000, pxo, 1),
3734 F_ROT( 29540000, pll8, 13),
3735 F_ROT( 32000000, pll8, 12),
3736 F_ROT( 38400000, pll8, 10),
3737 F_ROT( 48000000, pll8, 8),
3738 F_ROT( 54860000, pll8, 7),
3739 F_ROT( 64000000, pll8, 6),
3740 F_ROT( 76800000, pll8, 5),
3741 F_ROT( 96000000, pll8, 4),
3742 F_ROT(100000000, pll2, 8),
3743 F_ROT(114290000, pll2, 7),
3744 F_ROT(133330000, pll2, 6),
3745 F_ROT(160000000, pll2, 5),
3746 F_ROT(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003747 F_END
3748};
3749
3750static struct bank_masks bdiv_info_rot = {
3751 .bank_sel_mask = BIT(30),
3752 .bank0_mask = {
3753 .ns_mask = BM(25, 22) | BM(18, 16),
3754 },
3755 .bank1_mask = {
3756 .ns_mask = BM(29, 26) | BM(21, 19),
3757 },
3758};
3759
3760static struct rcg_clk rot_clk = {
3761 .b = {
3762 .ctl_reg = ROT_CC_REG,
3763 .en_mask = BIT(0),
3764 .reset_reg = SW_RESET_CORE_REG,
3765 .reset_mask = BIT(2),
3766 .halt_reg = DBG_BUS_VEC_C_REG,
3767 .halt_bit = 15,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003768 .retain_reg = ROT_CC_REG,
3769 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003770 },
3771 .ns_reg = ROT_NS_REG,
3772 .root_en_mask = BIT(2),
3773 .set_rate = set_rate_div_banked,
3774 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003775 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003776 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003777 .c = {
3778 .dbg_name = "rot_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003779 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003780 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003781 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003782 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003783 },
3784};
3785
3786static int hdmi_pll_clk_enable(struct clk *clk)
3787{
3788 int ret;
3789 unsigned long flags;
3790 spin_lock_irqsave(&local_clock_reg_lock, flags);
3791 ret = hdmi_pll_enable();
3792 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3793 return ret;
3794}
3795
3796static void hdmi_pll_clk_disable(struct clk *clk)
3797{
3798 unsigned long flags;
3799 spin_lock_irqsave(&local_clock_reg_lock, flags);
3800 hdmi_pll_disable();
3801 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3802}
3803
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003804static unsigned long hdmi_pll_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003805{
3806 return hdmi_pll_get_rate();
3807}
3808
Stephen Boyd5b35dee2011-09-21 12:17:38 -07003809static struct clk *hdmi_pll_clk_get_parent(struct clk *clk)
3810{
3811 return &pxo_clk.c;
3812}
3813
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003814static struct clk_ops clk_ops_hdmi_pll = {
3815 .enable = hdmi_pll_clk_enable,
3816 .disable = hdmi_pll_clk_disable,
3817 .get_rate = hdmi_pll_clk_get_rate,
3818 .is_local = local_clk_is_local,
Stephen Boyd5b35dee2011-09-21 12:17:38 -07003819 .get_parent = hdmi_pll_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003820};
3821
3822static struct clk hdmi_pll_clk = {
3823 .dbg_name = "hdmi_pll_clk",
3824 .ops = &clk_ops_hdmi_pll,
3825 CLK_INIT(hdmi_pll_clk),
3826};
3827
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003828#define F_TV_GND(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003829 { \
3830 .freq_hz = f, \
3831 .src_clk = &s##_clk.c, \
3832 .md_val = MD8(8, m, 0, n), \
3833 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3834 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003835 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003836#define F_TV(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003837 { \
3838 .freq_hz = f, \
3839 .src_clk = &s##_clk, \
3840 .md_val = MD8(8, m, 0, n), \
3841 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3842 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003843 .extra_freq_data = (void *)p_r, \
3844 }
3845/* Switching TV freqs requires PLL reconfiguration. */
3846static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003847 F_TV_GND( 0, gnd, 0, 1, 0, 0),
3848 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0),
3849 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0),
3850 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0),
3851 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0),
3852 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003853 F_END
3854};
3855
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003856static unsigned long fmax_tv_src_8064[MAX_VDD_LEVELS] __initdata = {
3857 [VDD_DIG_LOW] = 74250000,
3858 [VDD_DIG_NOMINAL] = 149000000
3859};
3860
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003861/*
3862 * Unlike other clocks, the TV rate is adjusted through PLL
3863 * re-programming. It is also routed through an MND divider.
3864 */
3865void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
3866{
3867 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
3868 if (pll_rate)
3869 hdmi_pll_set_rate(pll_rate);
3870 set_rate_mnd(clk, nf);
3871}
3872
3873static struct rcg_clk tv_src_clk = {
3874 .ns_reg = TV_NS_REG,
3875 .b = {
3876 .ctl_reg = TV_CC_REG,
3877 .halt_check = NOCHECK,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003878 .retain_reg = TV_CC_REG,
3879 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003880 },
3881 .md_reg = TV_MD_REG,
3882 .root_en_mask = BIT(2),
3883 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08003884 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003885 .ctl_mask = BM(7, 6),
3886 .set_rate = set_rate_tv,
3887 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003888 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003889 .c = {
3890 .dbg_name = "tv_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003891 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003892 VDD_DIG_FMAX_MAP2(LOW, 27030000, NOMINAL, 149000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003893 CLK_INIT(tv_src_clk.c),
3894 },
3895};
3896
Tianyi Gou51918802012-01-26 14:05:43 -08003897static struct cdiv_clk tv_src_div_clk = {
3898 .b = {
3899 .ctl_reg = TV_NS_REG,
3900 .halt_check = NOCHECK,
3901 },
3902 .ns_reg = TV_NS_REG,
3903 .div_offset = 6,
3904 .max_div = 2,
3905 .c = {
3906 .dbg_name = "tv_src_div_clk",
3907 .ops = &clk_ops_cdiv,
3908 CLK_INIT(tv_src_div_clk.c),
3909 },
3910};
3911
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003912static struct branch_clk tv_enc_clk = {
3913 .b = {
3914 .ctl_reg = TV_CC_REG,
3915 .en_mask = BIT(8),
3916 .reset_reg = SW_RESET_CORE_REG,
3917 .reset_mask = BIT(0),
3918 .halt_reg = DBG_BUS_VEC_D_REG,
3919 .halt_bit = 9,
3920 },
3921 .parent = &tv_src_clk.c,
3922 .c = {
3923 .dbg_name = "tv_enc_clk",
3924 .ops = &clk_ops_branch,
3925 CLK_INIT(tv_enc_clk.c),
3926 },
3927};
3928
3929static struct branch_clk tv_dac_clk = {
3930 .b = {
3931 .ctl_reg = TV_CC_REG,
3932 .en_mask = BIT(10),
3933 .halt_reg = DBG_BUS_VEC_D_REG,
3934 .halt_bit = 10,
3935 },
3936 .parent = &tv_src_clk.c,
3937 .c = {
3938 .dbg_name = "tv_dac_clk",
3939 .ops = &clk_ops_branch,
3940 CLK_INIT(tv_dac_clk.c),
3941 },
3942};
3943
3944static struct branch_clk mdp_tv_clk = {
3945 .b = {
3946 .ctl_reg = TV_CC_REG,
3947 .en_mask = BIT(0),
3948 .reset_reg = SW_RESET_CORE_REG,
3949 .reset_mask = BIT(4),
3950 .halt_reg = DBG_BUS_VEC_D_REG,
3951 .halt_bit = 12,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003952 .retain_reg = TV_CC2_REG,
3953 .retain_mask = BIT(10),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003954 },
3955 .parent = &tv_src_clk.c,
3956 .c = {
3957 .dbg_name = "mdp_tv_clk",
3958 .ops = &clk_ops_branch,
3959 CLK_INIT(mdp_tv_clk.c),
3960 },
3961};
3962
3963static struct branch_clk hdmi_tv_clk = {
3964 .b = {
3965 .ctl_reg = TV_CC_REG,
3966 .en_mask = BIT(12),
3967 .reset_reg = SW_RESET_CORE_REG,
3968 .reset_mask = BIT(1),
3969 .halt_reg = DBG_BUS_VEC_D_REG,
3970 .halt_bit = 11,
3971 },
3972 .parent = &tv_src_clk.c,
3973 .c = {
3974 .dbg_name = "hdmi_tv_clk",
3975 .ops = &clk_ops_branch,
3976 CLK_INIT(hdmi_tv_clk.c),
3977 },
3978};
3979
Tianyi Gou51918802012-01-26 14:05:43 -08003980static struct branch_clk rgb_tv_clk = {
3981 .b = {
3982 .ctl_reg = TV_CC2_REG,
3983 .en_mask = BIT(14),
3984 .halt_reg = DBG_BUS_VEC_J_REG,
3985 .halt_bit = 27,
3986 },
3987 .parent = &tv_src_clk.c,
3988 .c = {
3989 .dbg_name = "rgb_tv_clk",
3990 .ops = &clk_ops_branch,
3991 CLK_INIT(rgb_tv_clk.c),
3992 },
3993};
3994
3995static struct branch_clk npl_tv_clk = {
3996 .b = {
3997 .ctl_reg = TV_CC2_REG,
3998 .en_mask = BIT(16),
3999 .halt_reg = DBG_BUS_VEC_J_REG,
4000 .halt_bit = 26,
4001 },
4002 .parent = &tv_src_clk.c,
4003 .c = {
4004 .dbg_name = "npl_tv_clk",
4005 .ops = &clk_ops_branch,
4006 CLK_INIT(npl_tv_clk.c),
4007 },
4008};
4009
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004010static struct branch_clk hdmi_app_clk = {
4011 .b = {
4012 .ctl_reg = MISC_CC2_REG,
4013 .en_mask = BIT(11),
4014 .reset_reg = SW_RESET_CORE_REG,
4015 .reset_mask = BIT(11),
4016 .halt_reg = DBG_BUS_VEC_B_REG,
4017 .halt_bit = 25,
4018 },
4019 .c = {
4020 .dbg_name = "hdmi_app_clk",
4021 .ops = &clk_ops_branch,
4022 CLK_INIT(hdmi_app_clk.c),
4023 },
4024};
4025
4026static struct bank_masks bmnd_info_vcodec = {
4027 .bank_sel_mask = BIT(13),
4028 .bank0_mask = {
4029 .md_reg = VCODEC_MD0_REG,
4030 .ns_mask = BM(18, 11) | BM(2, 0),
4031 .rst_mask = BIT(31),
4032 .mnd_en_mask = BIT(5),
4033 .mode_mask = BM(7, 6),
4034 },
4035 .bank1_mask = {
4036 .md_reg = VCODEC_MD1_REG,
4037 .ns_mask = BM(26, 19) | BM(29, 27),
4038 .rst_mask = BIT(30),
4039 .mnd_en_mask = BIT(10),
4040 .mode_mask = BM(12, 11),
4041 },
4042};
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004043#define F_VCODEC(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004044 { \
4045 .freq_hz = f, \
4046 .src_clk = &s##_clk.c, \
4047 .md_val = MD8(8, m, 0, n), \
4048 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
4049 .ctl_val = CC_BANKED(6, 11, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004050 }
4051static struct clk_freq_tbl clk_tbl_vcodec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004052 F_VCODEC( 0, gnd, 0, 0),
4053 F_VCODEC( 27000000, pxo, 0, 0),
4054 F_VCODEC( 32000000, pll8, 1, 12),
4055 F_VCODEC( 48000000, pll8, 1, 8),
4056 F_VCODEC( 54860000, pll8, 1, 7),
4057 F_VCODEC( 96000000, pll8, 1, 4),
4058 F_VCODEC(133330000, pll2, 1, 6),
4059 F_VCODEC(200000000, pll2, 1, 4),
4060 F_VCODEC(228570000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004061 F_END
4062};
4063
4064static struct rcg_clk vcodec_clk = {
4065 .b = {
4066 .ctl_reg = VCODEC_CC_REG,
4067 .en_mask = BIT(0),
4068 .reset_reg = SW_RESET_CORE_REG,
4069 .reset_mask = BIT(6),
4070 .halt_reg = DBG_BUS_VEC_C_REG,
4071 .halt_bit = 29,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08004072 .retain_reg = VCODEC_CC_REG,
4073 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004074 },
4075 .ns_reg = VCODEC_NS_REG,
4076 .root_en_mask = BIT(2),
4077 .set_rate = set_rate_mnd_banked,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004078 .bank_info = &bmnd_info_vcodec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004079 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004080 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004081 .c = {
4082 .dbg_name = "vcodec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004083 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004084 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
4085 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004086 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004087 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004088 },
4089};
4090
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004091#define F_VPE(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004092 { \
4093 .freq_hz = f, \
4094 .src_clk = &s##_clk.c, \
4095 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004096 }
4097static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004098 F_VPE( 0, gnd, 1),
4099 F_VPE( 27000000, pxo, 1),
4100 F_VPE( 34909000, pll8, 11),
4101 F_VPE( 38400000, pll8, 10),
4102 F_VPE( 64000000, pll8, 6),
4103 F_VPE( 76800000, pll8, 5),
4104 F_VPE( 96000000, pll8, 4),
4105 F_VPE(100000000, pll2, 8),
4106 F_VPE(160000000, pll2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004107 F_END
4108};
4109
4110static struct rcg_clk vpe_clk = {
4111 .b = {
4112 .ctl_reg = VPE_CC_REG,
4113 .en_mask = BIT(0),
4114 .reset_reg = SW_RESET_CORE_REG,
4115 .reset_mask = BIT(17),
4116 .halt_reg = DBG_BUS_VEC_A_REG,
4117 .halt_bit = 28,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08004118 .retain_reg = VPE_CC_REG,
4119 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004120 },
4121 .ns_reg = VPE_NS_REG,
4122 .root_en_mask = BIT(2),
4123 .ns_mask = (BM(15, 12) | BM(2, 0)),
4124 .set_rate = set_rate_nop,
4125 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004126 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004127 .c = {
4128 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004129 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004130 VDD_DIG_FMAX_MAP2(LOW, 76800000, NOMINAL, 160000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004131 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004132 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004133 },
4134};
4135
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004136#define F_VFE(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004137 { \
4138 .freq_hz = f, \
4139 .src_clk = &s##_clk.c, \
4140 .md_val = MD8(8, m, 0, n), \
4141 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
4142 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004143 }
Tianyi Gou41515e22011-09-01 19:37:43 -07004144
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004145static struct clk_freq_tbl clk_tbl_vfe[] = {
4146 F_VFE( 0, gnd, 1, 0, 0),
4147 F_VFE( 13960000, pll8, 1, 2, 55),
4148 F_VFE( 27000000, pxo, 1, 0, 0),
4149 F_VFE( 36570000, pll8, 1, 2, 21),
4150 F_VFE( 38400000, pll8, 2, 1, 5),
4151 F_VFE( 45180000, pll8, 1, 2, 17),
4152 F_VFE( 48000000, pll8, 2, 1, 4),
4153 F_VFE( 54860000, pll8, 1, 1, 7),
4154 F_VFE( 64000000, pll8, 2, 1, 3),
4155 F_VFE( 76800000, pll8, 1, 1, 5),
4156 F_VFE( 96000000, pll8, 2, 1, 2),
4157 F_VFE(109710000, pll8, 1, 2, 7),
4158 F_VFE(128000000, pll8, 1, 1, 3),
4159 F_VFE(153600000, pll8, 1, 2, 5),
4160 F_VFE(200000000, pll2, 2, 1, 2),
4161 F_VFE(228570000, pll2, 1, 2, 7),
4162 F_VFE(266667000, pll2, 1, 1, 3),
4163 F_VFE(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004164 F_END
4165};
4166
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004167static unsigned long fmax_vfe_8064[MAX_VDD_LEVELS] __initdata = {
4168 [VDD_DIG_LOW] = 128000000,
4169 [VDD_DIG_NOMINAL] = 266667000,
4170 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07004171};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004172
4173static struct rcg_clk vfe_clk = {
4174 .b = {
4175 .ctl_reg = VFE_CC_REG,
4176 .reset_reg = SW_RESET_CORE_REG,
4177 .reset_mask = BIT(15),
4178 .halt_reg = DBG_BUS_VEC_B_REG,
4179 .halt_bit = 6,
4180 .en_mask = BIT(0),
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08004181 .retain_reg = VFE_CC2_REG,
4182 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004183 },
4184 .ns_reg = VFE_NS_REG,
4185 .md_reg = VFE_MD_REG,
4186 .root_en_mask = BIT(2),
4187 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08004188 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004189 .ctl_mask = BM(7, 6),
4190 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004191 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004192 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004193 .c = {
4194 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004195 .ops = &clk_ops_rcg_8960,
Tianyi Gou3022dfd2012-01-25 15:50:05 -08004196 VDD_DIG_FMAX_MAP3(LOW, 110000000, NOMINAL, 266667000,
4197 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004198 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004199 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004200 },
4201};
4202
Matt Wagantallc23eee92011-08-16 23:06:52 -07004203static struct branch_clk csi_vfe_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004204 .b = {
4205 .ctl_reg = VFE_CC_REG,
4206 .en_mask = BIT(12),
4207 .reset_reg = SW_RESET_CORE_REG,
4208 .reset_mask = BIT(24),
4209 .halt_reg = DBG_BUS_VEC_B_REG,
4210 .halt_bit = 8,
4211 },
4212 .parent = &vfe_clk.c,
4213 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -07004214 .dbg_name = "csi_vfe_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004215 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -07004216 CLK_INIT(csi_vfe_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004217 },
4218};
4219
4220/*
4221 * Low Power Audio Clocks
4222 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004223#define F_AIF_OSR(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004224 { \
4225 .freq_hz = f, \
4226 .src_clk = &s##_clk.c, \
4227 .md_val = MD8(8, m, 0, n), \
4228 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004229 }
4230static struct clk_freq_tbl clk_tbl_aif_osr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004231 F_AIF_OSR( 0, gnd, 1, 0, 0),
4232 F_AIF_OSR( 512000, pll4, 4, 1, 192),
4233 F_AIF_OSR( 768000, pll4, 4, 1, 128),
4234 F_AIF_OSR( 1024000, pll4, 4, 1, 96),
4235 F_AIF_OSR( 1536000, pll4, 4, 1, 64),
4236 F_AIF_OSR( 2048000, pll4, 4, 1, 48),
4237 F_AIF_OSR( 3072000, pll4, 4, 1, 32),
4238 F_AIF_OSR( 4096000, pll4, 4, 1, 24),
4239 F_AIF_OSR( 6144000, pll4, 4, 1, 16),
4240 F_AIF_OSR( 8192000, pll4, 4, 1, 12),
4241 F_AIF_OSR(12288000, pll4, 4, 1, 8),
4242 F_AIF_OSR(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004243 F_END
4244};
4245
4246#define CLK_AIF_OSR(i, ns, md, h_r) \
4247 struct rcg_clk i##_clk = { \
4248 .b = { \
4249 .ctl_reg = ns, \
4250 .en_mask = BIT(17), \
4251 .reset_reg = ns, \
4252 .reset_mask = BIT(19), \
4253 .halt_reg = h_r, \
4254 .halt_check = ENABLE, \
4255 .halt_bit = 1, \
4256 }, \
4257 .ns_reg = ns, \
4258 .md_reg = md, \
4259 .root_en_mask = BIT(9), \
4260 .ns_mask = (BM(31, 24) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08004261 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004262 .set_rate = set_rate_mnd, \
4263 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004264 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004265 .c = { \
4266 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004267 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004268 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004269 CLK_INIT(i##_clk.c), \
4270 }, \
4271 }
4272#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
4273 struct rcg_clk i##_clk = { \
4274 .b = { \
4275 .ctl_reg = ns, \
4276 .en_mask = BIT(21), \
4277 .reset_reg = ns, \
4278 .reset_mask = BIT(23), \
4279 .halt_reg = h_r, \
4280 .halt_check = ENABLE, \
4281 .halt_bit = 1, \
4282 }, \
4283 .ns_reg = ns, \
4284 .md_reg = md, \
4285 .root_en_mask = BIT(9), \
4286 .ns_mask = (BM(31, 24) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08004287 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004288 .set_rate = set_rate_mnd, \
4289 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004290 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004291 .c = { \
4292 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004293 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004294 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004295 CLK_INIT(i##_clk.c), \
4296 }, \
4297 }
4298
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004299#define CLK_AIF_BIT(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004300 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004301 .b = { \
4302 .ctl_reg = ns, \
4303 .en_mask = BIT(15), \
4304 .halt_reg = h_r, \
4305 .halt_check = DELAY, \
4306 }, \
4307 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004308 .ext_mask = BIT(14), \
4309 .div_offset = 10, \
4310 .max_div = 16, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004311 .c = { \
4312 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004313 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004314 CLK_INIT(i##_clk.c), \
4315 }, \
4316 }
4317
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004318#define CLK_AIF_BIT_DIV(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004319 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004320 .b = { \
4321 .ctl_reg = ns, \
4322 .en_mask = BIT(19), \
4323 .halt_reg = h_r, \
Stephen Boyd7bb9cf82012-01-25 18:09:01 -08004324 .halt_check = DELAY, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004325 }, \
4326 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004327 .ext_mask = BIT(18), \
4328 .div_offset = 10, \
4329 .max_div = 256, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004330 .c = { \
4331 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004332 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004333 CLK_INIT(i##_clk.c), \
4334 }, \
4335 }
4336
4337static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
4338 LCC_MI2S_STATUS_REG);
4339static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
4340
4341static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
4342 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
4343static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
4344 LCC_CODEC_I2S_MIC_STATUS_REG);
4345
4346static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
4347 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
4348static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
4349 LCC_SPARE_I2S_MIC_STATUS_REG);
4350
4351static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
4352 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
4353static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
4354 LCC_CODEC_I2S_SPKR_STATUS_REG);
4355
4356static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
4357 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
4358static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
4359 LCC_SPARE_I2S_SPKR_STATUS_REG);
4360
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004361#define F_PCM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004362 { \
4363 .freq_hz = f, \
4364 .src_clk = &s##_clk.c, \
4365 .md_val = MD16(m, n), \
4366 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004367 }
4368static struct clk_freq_tbl clk_tbl_pcm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004369 F_PCM( 0, gnd, 1, 0, 0),
4370 F_PCM( 512000, pll4, 4, 1, 192),
4371 F_PCM( 768000, pll4, 4, 1, 128),
4372 F_PCM( 1024000, pll4, 4, 1, 96),
4373 F_PCM( 1536000, pll4, 4, 1, 64),
4374 F_PCM( 2048000, pll4, 4, 1, 48),
4375 F_PCM( 3072000, pll4, 4, 1, 32),
4376 F_PCM( 4096000, pll4, 4, 1, 24),
4377 F_PCM( 6144000, pll4, 4, 1, 16),
4378 F_PCM( 8192000, pll4, 4, 1, 12),
4379 F_PCM(12288000, pll4, 4, 1, 8),
4380 F_PCM(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004381 F_END
4382};
4383
4384static struct rcg_clk pcm_clk = {
4385 .b = {
4386 .ctl_reg = LCC_PCM_NS_REG,
4387 .en_mask = BIT(11),
4388 .reset_reg = LCC_PCM_NS_REG,
4389 .reset_mask = BIT(13),
4390 .halt_reg = LCC_PCM_STATUS_REG,
4391 .halt_check = ENABLE,
4392 .halt_bit = 0,
4393 },
4394 .ns_reg = LCC_PCM_NS_REG,
4395 .md_reg = LCC_PCM_MD_REG,
4396 .root_en_mask = BIT(9),
4397 .ns_mask = (BM(31, 16) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08004398 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004399 .set_rate = set_rate_mnd,
4400 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004401 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004402 .c = {
4403 .dbg_name = "pcm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004404 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004405 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004406 CLK_INIT(pcm_clk.c),
4407 },
4408};
4409
4410static struct rcg_clk audio_slimbus_clk = {
4411 .b = {
4412 .ctl_reg = LCC_SLIMBUS_NS_REG,
4413 .en_mask = BIT(10),
4414 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
4415 .reset_mask = BIT(5),
4416 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4417 .halt_check = ENABLE,
4418 .halt_bit = 0,
4419 },
4420 .ns_reg = LCC_SLIMBUS_NS_REG,
4421 .md_reg = LCC_SLIMBUS_MD_REG,
4422 .root_en_mask = BIT(9),
4423 .ns_mask = (BM(31, 24) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08004424 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004425 .set_rate = set_rate_mnd,
4426 .freq_tbl = clk_tbl_aif_osr,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004427 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004428 .c = {
4429 .dbg_name = "audio_slimbus_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004430 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004431 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004432 CLK_INIT(audio_slimbus_clk.c),
4433 },
4434};
4435
4436static struct branch_clk sps_slimbus_clk = {
4437 .b = {
4438 .ctl_reg = LCC_SLIMBUS_NS_REG,
4439 .en_mask = BIT(12),
4440 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4441 .halt_check = ENABLE,
4442 .halt_bit = 1,
4443 },
4444 .parent = &audio_slimbus_clk.c,
4445 .c = {
4446 .dbg_name = "sps_slimbus_clk",
4447 .ops = &clk_ops_branch,
4448 CLK_INIT(sps_slimbus_clk.c),
4449 },
4450};
4451
4452static struct branch_clk slimbus_xo_src_clk = {
4453 .b = {
4454 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
4455 .en_mask = BIT(2),
4456 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004457 .halt_bit = 28,
4458 },
4459 .parent = &sps_slimbus_clk.c,
4460 .c = {
4461 .dbg_name = "slimbus_xo_src_clk",
4462 .ops = &clk_ops_branch,
4463 CLK_INIT(slimbus_xo_src_clk.c),
4464 },
4465};
4466
Matt Wagantall735f01a2011-08-12 12:40:28 -07004467DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
4468DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
4469DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
4470DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
4471DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
4472DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
4473DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
4474DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004475
Stephen Boydd7a143a2012-02-16 17:59:26 -08004476static DEFINE_CLK_VOTER(sfab_msmbus_a_clk, &sfab_a_clk.c);
4477static DEFINE_CLK_VOTER(sfab_tmr_a_clk, &sfab_a_clk.c);
4478
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004479static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
4480static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
Manu Gautam7483f172011-11-08 15:22:26 +05304481static DEFINE_CLK_VOTER(dfab_usb_hs3_clk, &dfab_clk.c);
4482static DEFINE_CLK_VOTER(dfab_usb_hs4_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004483static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
4484static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
4485static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
4486static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
4487static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
4488static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
Stephen Boyd1c51a492011-10-26 12:11:47 -07004489static DEFINE_CLK_VOTER(dfab_bam_dmux_clk, &dfab_clk.c);
Stephen Boydef5d1c42011-12-15 20:47:14 -08004490static DEFINE_CLK_VOTER(dfab_scm_clk, &dfab_clk.c);
Ramesh Masavarapua1bc0e42012-03-05 07:42:48 -08004491static DEFINE_CLK_VOTER(dfab_qseecom_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004492
4493static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
Stephen Boyd36466ae2012-01-18 20:58:27 -08004494static DEFINE_CLK_VOTER(ebi1_adm_clk, &ebi1_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004495
4496#ifdef CONFIG_DEBUG_FS
4497struct measure_sel {
4498 u32 test_vector;
4499 struct clk *clk;
4500};
4501
Matt Wagantall8b38f942011-08-02 18:23:18 -07004502static DEFINE_CLK_MEASURE(l2_m_clk);
4503static DEFINE_CLK_MEASURE(krait0_m_clk);
4504static DEFINE_CLK_MEASURE(krait1_m_clk);
Tianyi Gou455c13c2012-02-02 16:33:24 -08004505static DEFINE_CLK_MEASURE(krait2_m_clk);
4506static DEFINE_CLK_MEASURE(krait3_m_clk);
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004507static DEFINE_CLK_MEASURE(q6sw_clk);
4508static DEFINE_CLK_MEASURE(q6fw_clk);
4509static DEFINE_CLK_MEASURE(q6_func_clk);
Matt Wagantall8b38f942011-08-02 18:23:18 -07004510
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004511static struct measure_sel measure_mux[] = {
4512 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
4513 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
4514 { TEST_PER_LS(0x13), &sdc1_clk.c },
4515 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
4516 { TEST_PER_LS(0x15), &sdc2_clk.c },
4517 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
4518 { TEST_PER_LS(0x17), &sdc3_clk.c },
4519 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
4520 { TEST_PER_LS(0x19), &sdc4_clk.c },
4521 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
4522 { TEST_PER_LS(0x1B), &sdc5_clk.c },
Matt Wagantall7625a4c2011-11-01 16:17:53 -07004523 { TEST_PER_LS(0x1F), &gp0_clk.c },
4524 { TEST_PER_LS(0x20), &gp1_clk.c },
4525 { TEST_PER_LS(0x21), &gp2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004526 { TEST_PER_LS(0x25), &dfab_clk.c },
4527 { TEST_PER_LS(0x25), &dfab_a_clk.c },
4528 { TEST_PER_LS(0x26), &pmem_clk.c },
4529 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
4530 { TEST_PER_LS(0x33), &cfpb_clk.c },
4531 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
4532 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
4533 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
4534 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
4535 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
4536 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
4537 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
4538 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
4539 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
4540 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
4541 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
4542 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
4543 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
4544 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
4545 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
4546 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
4547 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
4548 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
4549 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
4550 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
4551 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
4552 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
4553 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
4554 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
4555 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
4556 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
4557 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
4558 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
4559 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
4560 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
4561 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
4562 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
4563 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
4564 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
4565 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
4566 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
4567 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004568 { TEST_PER_LS(0x5E), &pcie_p_clk.c },
4569 { TEST_PER_LS(0x5F), &ce3_p_clk.c },
4570 { TEST_PER_LS(0x60), &ce3_core_clk.c },
4571 { TEST_PER_LS(0x63), &usb_hs3_p_clk.c },
4572 { TEST_PER_LS(0x64), &usb_hs3_xcvr_clk.c },
4573 { TEST_PER_LS(0x65), &usb_hs4_p_clk.c },
4574 { TEST_PER_LS(0x66), &usb_hs4_xcvr_clk.c },
4575 { TEST_PER_LS(0x6B), &sata_phy_ref_clk.c },
4576 { TEST_PER_LS(0x6C), &sata_phy_cfg_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004577 { TEST_PER_LS(0x78), &sfpb_clk.c },
4578 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
4579 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
4580 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
4581 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
4582 { TEST_PER_LS(0x7D), &prng_clk.c },
4583 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
4584 { TEST_PER_LS(0x80), &adm0_p_clk.c },
4585 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
4586 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004587 { TEST_PER_LS(0x86), &usb_hsic_p_clk.c },
4588 { TEST_PER_LS(0x87), &usb_hsic_system_clk.c },
4589 { TEST_PER_LS(0x88), &usb_hsic_xcvr_fs_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004590 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
4591 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
4592 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
4593 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
4594 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
4595 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
4596 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
4597 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
4598 { TEST_PER_LS(0x92), &ce1_p_clk.c },
4599 { TEST_PER_LS(0x94), &tssc_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004600 { TEST_PER_LS(0x9D), &usb_hsic_hsio_cal_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004601 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
4602
4603 { TEST_PER_HS(0x07), &afab_clk.c },
4604 { TEST_PER_HS(0x07), &afab_a_clk.c },
4605 { TEST_PER_HS(0x18), &sfab_clk.c },
4606 { TEST_PER_HS(0x18), &sfab_a_clk.c },
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004607 { TEST_PER_HS(0x26), &q6sw_clk },
4608 { TEST_PER_HS(0x27), &q6fw_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004609 { TEST_PER_HS(0x2A), &adm0_clk.c },
4610 { TEST_PER_HS(0x34), &ebi1_clk.c },
4611 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004612 { TEST_PER_HS(0x50), &usb_hsic_hsic_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004613
4614 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
4615 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
4616 { TEST_MM_LS(0x02), &cam1_clk.c },
4617 { TEST_MM_LS(0x06), &amp_p_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004618 { TEST_MM_LS(0x07), &csi_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004619 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
4620 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
4621 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
4622 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
4623 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
4624 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
4625 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
4626 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
4627 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
4628 { TEST_MM_LS(0x12), &imem_p_clk.c },
4629 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
4630 { TEST_MM_LS(0x14), &mdp_p_clk.c },
4631 { TEST_MM_LS(0x16), &rot_p_clk.c },
4632 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
4633 { TEST_MM_LS(0x18), &smmu_p_clk.c },
4634 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
4635 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
4636 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
4637 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
4638 { TEST_MM_LS(0x1D), &cam0_clk.c },
4639 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
4640 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
4641 { TEST_MM_LS(0x21), &tv_dac_clk.c },
4642 { TEST_MM_LS(0x22), &tv_enc_clk.c },
4643 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
4644 { TEST_MM_LS(0x25), &mmfpb_clk.c },
4645 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
4646 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004647 { TEST_MM_LS(0x27), &cam2_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004648 { TEST_MM_LS(0x28), &vcap_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004649
4650 { TEST_MM_HS(0x00), &csi0_clk.c },
4651 { TEST_MM_HS(0x01), &csi1_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004652 { TEST_MM_HS(0x04), &csi_vfe_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004653 { TEST_MM_HS(0x05), &ijpeg_clk.c },
4654 { TEST_MM_HS(0x06), &vfe_clk.c },
4655 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
4656 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
4657 { TEST_MM_HS(0x09), &gfx3d_clk.c },
4658 { TEST_MM_HS(0x0A), &jpegd_clk.c },
4659 { TEST_MM_HS(0x0B), &vcodec_clk.c },
4660 { TEST_MM_HS(0x0F), &mmfab_clk.c },
4661 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
4662 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
4663 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
4664 { TEST_MM_HS(0x13), &imem_axi_clk.c },
4665 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
4666 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
4667 { TEST_MM_HS(0x16), &rot_axi_clk.c },
4668 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
4669 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
4670 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
4671 { TEST_MM_HS(0x1A), &mdp_clk.c },
4672 { TEST_MM_HS(0x1B), &rot_clk.c },
4673 { TEST_MM_HS(0x1C), &vpe_clk.c },
4674 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
4675 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
4676 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
4677 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
4678 { TEST_MM_HS(0x26), &csi_pix_clk.c },
4679 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
4680 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
4681 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
4682 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
4683 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
4684 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004685 { TEST_MM_HS(0x2D), &csi2_clk.c },
4686 { TEST_MM_HS(0x2E), &csi2_phy_clk.c },
4687 { TEST_MM_HS(0x2F), &csi2phy_timer_clk.c },
4688 { TEST_MM_HS(0x30), &csi_pix1_clk.c },
4689 { TEST_MM_HS(0x31), &csi_rdi1_clk.c },
4690 { TEST_MM_HS(0x32), &csi_rdi2_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004691 { TEST_MM_HS(0x33), &vcap_clk.c },
4692 { TEST_MM_HS(0x34), &vcap_npl_clk.c },
Tianyi Gou7747a962012-02-03 15:03:55 -08004693 { TEST_MM_HS(0x35), &vcap_axi_clk.c },
Tianyi Gou51918802012-01-26 14:05:43 -08004694 { TEST_MM_HS(0x36), &rgb_tv_clk.c },
4695 { TEST_MM_HS(0x37), &npl_tv_clk.c },
Tianyi Gou7747a962012-02-03 15:03:55 -08004696 { TEST_MM_HS(0x38), &gfx3d_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004697
4698 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
4699 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
4700 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
4701 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
4702 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
4703 { TEST_LPA(0x14), &pcm_clk.c },
4704 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
Matt Wagantall8b38f942011-08-02 18:23:18 -07004705
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004706 { TEST_LPA_HS(0x00), &q6_func_clk },
4707
Stephen Boyd46fdf0d2011-11-22 12:25:09 -08004708 { TEST_CPUL2(0x2), &l2_m_clk },
4709 { TEST_CPUL2(0x0), &krait0_m_clk },
4710 { TEST_CPUL2(0x1), &krait1_m_clk },
Tianyi Gou455c13c2012-02-02 16:33:24 -08004711 { TEST_CPUL2(0x4), &krait2_m_clk },
4712 { TEST_CPUL2(0x5), &krait3_m_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004713};
4714
4715static struct measure_sel *find_measure_sel(struct clk *clk)
4716{
4717 int i;
4718
4719 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
4720 if (measure_mux[i].clk == clk)
4721 return &measure_mux[i];
4722 return NULL;
4723}
4724
Matt Wagantall8b38f942011-08-02 18:23:18 -07004725static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004726{
4727 int ret = 0;
4728 u32 clk_sel;
4729 struct measure_sel *p;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004730 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004731 unsigned long flags;
4732
4733 if (!parent)
4734 return -EINVAL;
4735
4736 p = find_measure_sel(parent);
4737 if (!p)
4738 return -EINVAL;
4739
4740 spin_lock_irqsave(&local_clock_reg_lock, flags);
4741
Matt Wagantall8b38f942011-08-02 18:23:18 -07004742 /*
4743 * Program the test vector, measurement period (sample_ticks)
4744 * and scaling multiplier.
4745 */
4746 clk->sample_ticks = 0x10000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004747 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004748 clk->multiplier = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004749 switch (p->test_vector >> TEST_TYPE_SHIFT) {
4750 case TEST_TYPE_PER_LS:
4751 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
4752 break;
4753 case TEST_TYPE_PER_HS:
4754 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
4755 break;
4756 case TEST_TYPE_MM_LS:
4757 writel_relaxed(0x4030D97, CLK_TEST_REG);
4758 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
4759 break;
4760 case TEST_TYPE_MM_HS:
4761 writel_relaxed(0x402B800, CLK_TEST_REG);
4762 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
4763 break;
4764 case TEST_TYPE_LPA:
4765 writel_relaxed(0x4030D98, CLK_TEST_REG);
4766 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
4767 LCC_CLK_LS_DEBUG_CFG_REG);
4768 break;
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004769 case TEST_TYPE_LPA_HS:
4770 writel_relaxed(0x402BC00, CLK_TEST_REG);
4771 writel_relaxed(BVAL(2, 1, clk_sel)|BIT(0),
4772 LCC_CLK_HS_DEBUG_CFG_REG);
4773 break;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004774 case TEST_TYPE_CPUL2:
4775 writel_relaxed(0x4030400, CLK_TEST_REG);
4776 writel_relaxed(0x80|BVAL(5, 3, clk_sel), GCC_APCS_CLK_DIAG);
4777 clk->sample_ticks = 0x4000;
4778 clk->multiplier = 2;
4779 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004780 default:
4781 ret = -EPERM;
4782 }
4783 /* Make sure test vector is set before starting measurements. */
4784 mb();
4785
4786 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4787
4788 return ret;
4789}
4790
4791/* Sample clock for 'ticks' reference clock ticks. */
4792static u32 run_measurement(unsigned ticks)
4793{
4794 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004795 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
4796
4797 /* Wait for timer to become ready. */
4798 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
4799 cpu_relax();
4800
4801 /* Run measurement and wait for completion. */
4802 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
4803 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
4804 cpu_relax();
4805
4806 /* Stop counters. */
4807 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
4808
4809 /* Return measured ticks. */
4810 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
4811}
4812
4813
4814/* Perform a hardware rate measurement for a given clock.
4815 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07004816static unsigned long measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004817{
4818 unsigned long flags;
4819 u32 pdm_reg_backup, ringosc_reg_backup;
4820 u64 raw_count_short, raw_count_full;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004821 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004822 unsigned ret;
4823
Stephen Boyd3a35f0b2012-01-11 16:18:26 -08004824 ret = clk_enable(&cxo_clk.c);
4825 if (ret) {
4826 pr_warning("CXO clock failed to enable. Can't measure\n");
4827 return 0;
4828 }
4829
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004830 spin_lock_irqsave(&local_clock_reg_lock, flags);
4831
4832 /* Enable CXO/4 and RINGOSC branch and root. */
4833 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
4834 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
4835 writel_relaxed(0x2898, PDM_CLK_NS_REG);
4836 writel_relaxed(0xA00, RINGOSC_NS_REG);
4837
4838 /*
4839 * The ring oscillator counter will not reset if the measured clock
4840 * is not running. To detect this, run a short measurement before
4841 * the full measurement. If the raw results of the two are the same
4842 * then the clock must be off.
4843 */
4844
4845 /* Run a short measurement. (~1 ms) */
4846 raw_count_short = run_measurement(0x1000);
4847 /* Run a full measurement. (~14 ms) */
Matt Wagantall8b38f942011-08-02 18:23:18 -07004848 raw_count_full = run_measurement(clk->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004849
4850 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
4851 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
4852
4853 /* Return 0 if the clock is off. */
4854 if (raw_count_full == raw_count_short)
4855 ret = 0;
4856 else {
4857 /* Compute rate in Hz. */
4858 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004859 do_div(raw_count_full, ((clk->sample_ticks * 10) + 35));
4860 ret = (raw_count_full * clk->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004861 }
4862
4863 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07004864 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004865 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4866
Stephen Boyd3a35f0b2012-01-11 16:18:26 -08004867 clk_disable(&cxo_clk.c);
4868
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004869 return ret;
4870}
4871#else /* !CONFIG_DEBUG_FS */
4872static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
4873{
4874 return -EINVAL;
4875}
4876
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07004877static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004878{
4879 return 0;
4880}
4881#endif /* CONFIG_DEBUG_FS */
4882
4883static struct clk_ops measure_clk_ops = {
4884 .set_parent = measure_clk_set_parent,
4885 .get_rate = measure_clk_get_rate,
4886 .is_local = local_clk_is_local,
4887};
4888
Matt Wagantall8b38f942011-08-02 18:23:18 -07004889static struct measure_clk measure_clk = {
4890 .c = {
4891 .dbg_name = "measure_clk",
4892 .ops = &measure_clk_ops,
4893 CLK_INIT(measure_clk.c),
4894 },
4895 .multiplier = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004896};
4897
Tianyi Goua8b3cce2011-11-08 14:37:26 -08004898static struct clk_lookup msm_clocks_8064[] = {
Stephen Boyd7dd22662012-01-26 16:09:31 -08004899 CLK_LOOKUP("xo", cxo_clk.c, "msm_otg"),
Stephen Boyded630b02012-01-26 15:26:47 -08004900 CLK_LOOKUP("cxo", cxo_clk.c, "wcnss_wlan.0"),
4901 CLK_LOOKUP("cxo", cxo_clk.c, "pil_riva"),
4902 CLK_LOOKUP("xo", pxo_clk.c, "pil_qdsp6v4.0"),
4903 CLK_LOOKUP("xo", cxo_clk.c, "pil_qdsp6v4.1"),
4904 CLK_LOOKUP("xo", cxo_clk.c, "pil_qdsp6v4.2"),
Matt Wagantall292aace2012-01-26 19:12:34 -08004905 CLK_LOOKUP("xo", cxo_clk.c, "pil_gss"),
Stephen Boyd69d35e32012-02-14 15:33:30 -08004906 CLK_LOOKUP("xo", cxo_clk.c, "BAM_RMNT"),
Stephen Boyded630b02012-01-26 15:26:47 -08004907 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
4908 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
4909 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
4910 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Tianyi Gou41515e22011-09-01 19:37:43 -07004911
Tianyi Gou21a0e802012-02-04 22:34:10 -08004912 CLK_LOOKUP("bus_clk", afab_clk.c, "msm_apps_fab"),
4913 CLK_LOOKUP("bus_a_clk", afab_a_clk.c, "msm_apps_fab"),
4914 CLK_LOOKUP("bus_clk", cfpb_clk.c, "msm_cpss_fpb"),
4915 CLK_LOOKUP("bus_a_clk", cfpb_a_clk.c, "msm_cpss_fpb"),
4916 CLK_LOOKUP("bus_clk", sfab_clk.c, "msm_sys_fab"),
Stephen Boydd7a143a2012-02-16 17:59:26 -08004917 CLK_LOOKUP("bus_a_clk", sfab_msmbus_a_clk.c, "msm_sys_fab"),
Tianyi Gou21a0e802012-02-04 22:34:10 -08004918 CLK_LOOKUP("bus_clk", sfpb_clk.c, "msm_sys_fpb"),
4919 CLK_LOOKUP("bus_a_clk", sfpb_a_clk.c, "msm_sys_fpb"),
4920 CLK_LOOKUP("bus_clk", mmfab_clk.c, "msm_mm_fab"),
4921 CLK_LOOKUP("bus_a_clk", mmfab_a_clk.c, "msm_mm_fab"),
4922 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
4923 CLK_LOOKUP("mem_a_clk", ebi1_a_clk.c, "msm_bus"),
Matt Wagantallb2710b82011-11-16 19:55:17 -08004924
Tianyi Gou21a0e802012-02-04 22:34:10 -08004925 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, ""),
4926 CLK_LOOKUP("dfab_clk", dfab_clk.c, ""),
4927 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, ""),
4928 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, ""),
4929 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8960"),
4930 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, "clock-8960"),
Tianyi Gou41515e22011-09-01 19:37:43 -07004931
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004932 CLK_LOOKUP("core_clk", gp0_clk.c, ""),
4933 CLK_LOOKUP("core_clk", gp1_clk.c, ""),
4934 CLK_LOOKUP("core_clk", gp2_clk.c, ""),
Jin Hong4bbbfba2012-02-02 21:48:07 -08004935 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, "msm_serial_hsl.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004936 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, ""),
4937 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, ""),
4938 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, ""),
4939 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, ""),
4940 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, ""),
Jin Hong4bbbfba2012-02-02 21:48:07 -08004941 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, "msm_serial_hsl.0"),
David Keitel3c40fc52012-02-09 17:53:52 -08004942 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "qup_i2c.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004943 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, ""),
Jing Lin04601f92012-02-05 15:36:07 -08004944 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
Kevin Chand07220e2012-02-13 15:52:22 -08004945 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Stepan Moskovchenko64999002012-01-31 15:52:59 -08004946 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004947 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, ""),
4948 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, ""),
4949 CLK_LOOKUP("core_clk", pdm_clk.c, ""),
Tianyi Gou50f23812012-02-06 16:04:19 -08004950 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_sps"),
Tianyi Gou05e01102012-02-08 22:15:49 -08004951 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Tianyi Gou43208a02011-09-27 15:35:13 -07004952 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
4953 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
4954 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
4955 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004956 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, ""),
4957 CLK_LOOKUP("core_clk", tssc_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08004958 CLK_LOOKUP("alt_core_clk", usb_hs1_xcvr_clk.c, "msm_otg"),
4959 CLK_LOOKUP("alt_core_clk", usb_hs3_xcvr_clk.c, "msm_ehci_host.0"),
4960 CLK_LOOKUP("alt_core_clk", usb_hs4_xcvr_clk.c, "msm_ehci_host.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004961 CLK_LOOKUP("src_clk", usb_fs1_src_clk.c, ""),
4962 CLK_LOOKUP("alt_core_clk", usb_fs1_xcvr_clk.c, ""),
4963 CLK_LOOKUP("sys_clk", usb_fs1_sys_clk.c, ""),
4964 CLK_LOOKUP("iface_clk", ce1_p_clk.c, ""),
4965 CLK_LOOKUP("core_clk", ce1_core_clk.c, ""),
4966 CLK_LOOKUP("ref_clk", sata_phy_ref_clk.c, ""),
4967 CLK_LOOKUP("cfg_clk", sata_phy_cfg_clk.c, ""),
Ramesh Masavarapu28311912011-10-27 11:04:12 -07004968 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qce.0"),
4969 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qcrypto.0"),
4970 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qce.0"),
4971 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qcrypto.0"),
4972 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qce.0"),
4973 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qcrypto.0"),
Tianyi Gou41515e22011-09-01 19:37:43 -07004974 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Jin Hong4bbbfba2012-02-02 21:48:07 -08004975 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "msm_serial_hsl.1"),
David Keitel3c40fc52012-02-09 17:53:52 -08004976 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "qup_i2c.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004977 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, ""),
Jing Lin04601f92012-02-05 15:36:07 -08004978 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
Kevin Chand07220e2012-02-13 15:52:22 -08004979 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Stepan Moskovchenko64999002012-01-31 15:52:59 -08004980 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004981 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, ""),
Jin Hong4bbbfba2012-02-02 21:48:07 -08004982 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, "msm_serial_hsl.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004983 CLK_LOOKUP("iface_clk", tsif_p_clk.c, ""),
4984 CLK_LOOKUP("iface_clk", usb_fs1_p_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08004985 CLK_LOOKUP("iface_clk", usb_hs1_p_clk.c, "msm_otg"),
Manu Gautam7483f172011-11-08 15:22:26 +05304986 CLK_LOOKUP("iface_clk", usb_hs3_p_clk.c, "msm_ehci_host.0"),
4987 CLK_LOOKUP("iface_clk", usb_hs4_p_clk.c, "msm_ehci_host.1"),
Tianyi Gou43208a02011-09-27 15:35:13 -07004988 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
4989 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
4990 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
4991 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004992 CLK_LOOKUP("iface_clk", pcie_p_clk.c, ""),
Tianyi Gou41515e22011-09-01 19:37:43 -07004993 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
4994 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004995 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, ""),
4996 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, ""),
4997 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, ""),
4998 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, ""),
4999 CLK_LOOKUP("core_clk", amp_clk.c, ""),
Kevin Chand07220e2012-02-13 15:52:22 -08005000 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-001a"),
Sreesudhan Ramakrish Ramkumar6c6f57c2012-02-21 15:12:44 -08005001 CLK_LOOKUP("cam_clk", cam1_clk.c, "4-0048"),
Kevin Chand07220e2012-02-13 15:52:22 -08005002 CLK_LOOKUP("cam_clk", cam1_clk.c, "4-006c"),
5003 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_csid.0"),
5004 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_csid.1"),
5005 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, "msm_csid.2"),
5006 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_csid.0"),
5007 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csid.1"),
5008 CLK_LOOKUP("csi_clk", csi2_clk.c, "msm_csid.2"),
5009 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_csid.0"),
5010 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_csid.1"),
5011 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, "msm_csid.2"),
5012 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, "msm_ispif.0"),
5013 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, "msm_ispif.0"),
5014 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, "msm_ispif.0"),
5015 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, "msm_ispif.0"),
5016 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, "msm_ispif.0"),
5017 CLK_LOOKUP("csiphy_timer_src_clk",
5018 csiphy_timer_src_clk.c, "msm_csiphy.0"),
5019 CLK_LOOKUP("csiphy_timer_src_clk",
5020 csiphy_timer_src_clk.c, "msm_csiphy.1"),
5021 CLK_LOOKUP("csiphy_timer_src_clk",
5022 csiphy_timer_src_clk.c, "msm_csiphy.2"),
5023 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, "msm_csiphy.0"),
5024 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, "msm_csiphy.1"),
5025 CLK_LOOKUP("csiphy_timer_clk", csi2phy_timer_clk.c, "msm_csiphy.2"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005026 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5027 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5028 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5029 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
Tianyi Gou51918802012-01-26 14:05:43 -08005030 CLK_LOOKUP("rgb_clk", rgb_tv_clk.c, ""),
5031 CLK_LOOKUP("npl_clk", npl_tv_clk.c, ""),
5032
Pu Chen86b4be92011-11-03 17:27:57 -07005033 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005034 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5035 CLK_LOOKUP("bus_clk", gfx3d_axi_clk.c, "footswitch-8x60.2"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005036 CLK_LOOKUP("iface_clk", vcap_p_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005037 CLK_LOOKUP("iface_clk", vcap_p_clk.c, "footswitch-8x60.10"),
5038 CLK_LOOKUP("bus_clk", vcap_axi_clk.c, "footswitch-8x60.10"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005039 CLK_LOOKUP("core_clk", vcap_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005040 CLK_LOOKUP("core_clk", vcap_clk.c, "footswitch-8x60.10"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005041 CLK_LOOKUP("vcap_npl_clk", vcap_npl_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005042 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005043 CLK_LOOKUP("mem_clk", imem_axi_clk.c, ""),
5044 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005045 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005046 CLK_LOOKUP("core_clk", jpegd_clk.c, ""),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005047 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005048 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005049 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005050 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005051 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005052 CLK_LOOKUP("lut_clk", lut_mdp_clk.c, "footswitch-8x60.4"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005053 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005054 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Matt Wagantall61286312012-02-22 15:55:09 -08005055 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, "footswitch-8x60.4"),
Aravind Venkateswaran0507c8c2012-02-16 17:16:05 -08005056 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
5057 CLK_LOOKUP("tv_src_div_clk", tv_src_div_clk.c, NULL),
Greg Griscofa47b532011-11-11 10:32:06 -08005058 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005059 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Aravind Venkateswaran0507c8c2012-02-16 17:16:05 -08005060 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
Tianyi Gou51918802012-01-26 14:05:43 -08005061 CLK_LOOKUP("tv_clk", mdp_tv_clk.c, "footswitch-8x60.4"),
Aravind Venkateswaran0507c8c2012-02-16 17:16:05 -08005062 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
5063 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
5064 CLK_LOOKUP("vpe_clk", vpe_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005065 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Kevin Chand07220e2012-02-13 15:52:22 -08005066 CLK_LOOKUP("vfe_clk", vfe_clk.c, "msm_vfe.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005067 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Kevin Chand07220e2012-02-13 15:52:22 -08005068 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, "msm_vfe.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005069 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5070 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5071 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5072 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5073 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5074 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5075 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005076 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Kevin Chand07220e2012-02-13 15:52:22 -08005077 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.0"),
5078 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.1"),
5079 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.2"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005080 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5081 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5082 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5083 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Pu Chen86b4be92011-11-03 17:27:57 -07005084 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005085 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Aravind Venkateswaran0507c8c2012-02-16 17:16:05 -08005086 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
5087 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005088 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005089 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005090 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, ""),
Matt Wagantall5d44ef22012-01-23 11:01:05 -08005091 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, "kgsl-3d0.0"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005092 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005093 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Stepan Moskovchenko279b7852012-01-31 20:42:46 -08005094 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005095 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005096 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Greg Griscofa47b532011-11-11 10:32:06 -08005097 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005098 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Kevin Chand07220e2012-02-13 15:52:22 -08005099 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, "msm_vfe.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005100 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Kevin Chanb20742b2012-02-27 15:47:35 -08005101 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, "msm_vpe.0"),
Matt Wagantall61286312012-02-22 15:55:09 -08005102 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Tianyi Gou21a0e802012-02-04 22:34:10 -08005103
Kuirong Wanga9c3acc2012-02-09 17:00:45 -08005104 CLK_LOOKUP("bit_clk", mi2s_bit_clk.c, "msm-dai-q6.6"),
5105 CLK_LOOKUP("osr_clk", mi2s_osr_clk.c, "msm-dai-q6.6"),
5106 CLK_LOOKUP("bit_clk", codec_i2s_mic_bit_clk.c,
5107 "msm-dai-q6.1"),
5108 CLK_LOOKUP("osr_clk", codec_i2s_mic_osr_clk.c,
5109 "msm-dai-q6.1"),
5110 CLK_LOOKUP("bit_clk", spare_i2s_mic_bit_clk.c,
5111 "msm-dai-q6.5"),
5112 CLK_LOOKUP("osr_clk", spare_i2s_mic_osr_clk.c,
5113 "msm-dai-q6.5"),
5114 CLK_LOOKUP("bit_clk", codec_i2s_spkr_bit_clk.c,
5115 "msm-dai-q6.16384"),
5116 CLK_LOOKUP("osr_clk", codec_i2s_spkr_osr_clk.c,
5117 "msm-dai-q6.16384"),
5118 CLK_LOOKUP("bit_clk", spare_i2s_spkr_bit_clk.c,
5119 "msm-dai-q6.4"),
5120 CLK_LOOKUP("osr_clk", spare_i2s_spkr_osr_clk.c,
5121 "msm-dai-q6.4"),
5122 CLK_LOOKUP("pcm_clk", pcm_clk.c, "msm-dai-q6.2"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005123 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, ""),
Tianyi Gou44a81b02012-02-06 17:49:07 -08005124 CLK_LOOKUP("core_clk", audio_slimbus_clk.c, "msm_slim_ctrl.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005125 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, ""),
5126 CLK_LOOKUP("core_clk", vpe_axi_clk.c, ""),
5127 CLK_LOOKUP("core_clk", mdp_axi_clk.c, ""),
5128 CLK_LOOKUP("core_clk", vcap_axi_clk.c, ""),
5129 CLK_LOOKUP("core_clk", rot_axi_clk.c, ""),
5130 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, ""),
5131 CLK_LOOKUP("core_clk", vfe_axi_clk.c, ""),
5132 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, ""),
5133 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, ""),
5134 CLK_LOOKUP("core_clk", gfx3d_axi_clk.c, ""),
Tianyi Gou21a0e802012-02-04 22:34:10 -08005135
5136 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
5137 CLK_LOOKUP("core_clk", dfab_usb_hs_clk.c, "msm_otg"),
5138 CLK_LOOKUP("core_clk", dfab_usb_hs3_clk.c, "msm_ehci_host.0"),
5139 CLK_LOOKUP("core_clk", dfab_usb_hs3_clk.c, "msm_ehci_host.1"),
5140 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
5141 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
5142 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
5143 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
5144 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
5145 CLK_LOOKUP("bus_clk", dfab_bam_dmux_clk.c, "BAM_RMNT"),
5146 CLK_LOOKUP("bus_clk", dfab_scm_clk.c, "scm"),
Ramesh Masavarapua1bc0e42012-03-05 07:42:48 -08005147 CLK_LOOKUP("bus_clk", dfab_qseecom_clk.c, "qseecom"),
Tianyi Gou21a0e802012-02-04 22:34:10 -08005148
Manu Gautam5143b252012-01-05 19:25:23 -08005149 CLK_LOOKUP("alt_core_clk", usb_hsic_xcvr_fs_clk.c, "msm_hsic_host"),
5150 CLK_LOOKUP("phy_clk", usb_hsic_hsic_clk.c, "msm_hsic_host"),
5151 CLK_LOOKUP("cal_clk", usb_hsic_hsio_cal_clk.c, "msm_hsic_host"),
5152 CLK_LOOKUP("core_clk", usb_hsic_system_clk.c, "msm_hsic_host"),
5153 CLK_LOOKUP("iface_clk", usb_hsic_p_clk.c, "msm_hsic_host"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005154
Stepan Moskovchenko279b7852012-01-31 20:42:46 -08005155 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
5156 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
5157 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
5158 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
5159 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
5160 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
5161 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
5162 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
5163 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
5164 CLK_LOOKUP("core_clk", gfx3d_axi_clk.c, "msm_iommu.9"),
5165 CLK_LOOKUP("core_clk", gfx3d_axi_clk.c, "msm_iommu.10"),
5166 CLK_LOOKUP("core_clk", vcap_axi_clk.c, "msm_iommu.11"),
5167
Jeff Ohlstein8c116c72011-10-27 17:34:48 -07005168 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005169
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005170 CLK_LOOKUP("l2_mclk", l2_m_clk, ""),
5171 CLK_LOOKUP("krait0_mclk", krait0_m_clk, ""),
5172 CLK_LOOKUP("krait1_mclk", krait1_m_clk, ""),
Tianyi Gou455c13c2012-02-02 16:33:24 -08005173 CLK_LOOKUP("krait2_mclk", krait2_m_clk, ""),
5174 CLK_LOOKUP("krait3_mclk", krait3_m_clk, ""),
Tianyi Gou41515e22011-09-01 19:37:43 -07005175};
5176
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005177static struct clk_lookup msm_clocks_8960[] = {
Stephen Boyd7dd22662012-01-26 16:09:31 -08005178 CLK_LOOKUP("xo", cxo_clk.c, "msm_otg"),
Stephen Boyded630b02012-01-26 15:26:47 -08005179 CLK_LOOKUP("cxo", cxo_clk.c, "wcnss_wlan.0"),
5180 CLK_LOOKUP("cxo", cxo_clk.c, "pil_riva"),
5181 CLK_LOOKUP("xo", pxo_clk.c, "pil_qdsp6v4.0"),
5182 CLK_LOOKUP("xo", cxo_clk.c, "pil_qdsp6v4.1"),
5183 CLK_LOOKUP("xo", cxo_clk.c, "pil_qdsp6v4.2"),
Stephen Boyd69d35e32012-02-14 15:33:30 -08005184 CLK_LOOKUP("xo", cxo_clk.c, "BAM_RMNT"),
Stephen Boyded630b02012-01-26 15:26:47 -08005185 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
5186 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
5187 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
5188 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005189
Matt Wagantallb2710b82011-11-16 19:55:17 -08005190 CLK_LOOKUP("bus_clk", afab_clk.c, "msm_apps_fab"),
5191 CLK_LOOKUP("bus_a_clk", afab_a_clk.c, "msm_apps_fab"),
5192 CLK_LOOKUP("bus_clk", cfpb_clk.c, "msm_cpss_fpb"),
5193 CLK_LOOKUP("bus_a_clk", cfpb_a_clk.c, "msm_cpss_fpb"),
5194 CLK_LOOKUP("bus_clk", sfab_clk.c, "msm_sys_fab"),
Stephen Boydd7a143a2012-02-16 17:59:26 -08005195 CLK_LOOKUP("bus_a_clk", sfab_msmbus_a_clk.c, "msm_sys_fab"),
Matt Wagantallb2710b82011-11-16 19:55:17 -08005196 CLK_LOOKUP("bus_clk", sfpb_clk.c, "msm_sys_fpb"),
5197 CLK_LOOKUP("bus_a_clk", sfpb_a_clk.c, "msm_sys_fpb"),
5198 CLK_LOOKUP("bus_clk", mmfab_clk.c, "msm_mm_fab"),
5199 CLK_LOOKUP("bus_a_clk", mmfab_a_clk.c, "msm_mm_fab"),
5200 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
5201 CLK_LOOKUP("mem_a_clk", ebi1_a_clk.c, "msm_bus"),
5202
5203 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
5204 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
5205 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
5206 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
5207 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8960"),
5208 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005209
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005210 CLK_LOOKUP("core_clk", gp0_clk.c, ""),
5211 CLK_LOOKUP("core_clk", gp1_clk.c, ""),
5212 CLK_LOOKUP("core_clk", gp2_clk.c, ""),
5213 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, ""),
5214 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, ""),
5215 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, ""),
5216 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07005217 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
5218 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005219 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, ""),
5220 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, ""),
5221 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, ""),
5222 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, ""),
5223 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, ""),
5224 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005225 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005226 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005227 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
5228 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005229 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, ""),
5230 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, ""),
5231 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, ""),
5232 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, ""),
5233 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005234 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005235 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005236 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005237 CLK_LOOKUP("core_clk", pdm_clk.c, ""),
Vikram Mulukutladd0a2372011-09-19 15:58:21 -07005238 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_sps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07005239 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005240 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5241 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5242 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5243 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
5244 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005245 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005246 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, ""),
5247 CLK_LOOKUP("core_clk", tssc_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08005248 CLK_LOOKUP("alt_core_clk", usb_hs1_xcvr_clk.c, "msm_otg"),
5249 CLK_LOOKUP("phy_clk", usb_phy0_clk.c, "msm_otg"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005250 CLK_LOOKUP("alt_core_clk", usb_fs1_xcvr_clk.c, ""),
5251 CLK_LOOKUP("sys_clk", usb_fs1_sys_clk.c, ""),
5252 CLK_LOOKUP("src_clk", usb_fs1_src_clk.c, ""),
5253 CLK_LOOKUP("alt_core_clk", usb_fs2_xcvr_clk.c, ""),
5254 CLK_LOOKUP("sys_clk", usb_fs2_sys_clk.c, ""),
5255 CLK_LOOKUP("src_clk", usb_fs2_src_clk.c, ""),
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005256 CLK_LOOKUP("alt_core_clk", usb_hsic_xcvr_fs_clk.c, "msm_hsic_host"),
5257 CLK_LOOKUP("phy_clk", usb_hsic_hsic_clk.c, "msm_hsic_host"),
5258 CLK_LOOKUP("cal_clk", usb_hsic_hsio_cal_clk.c, "msm_hsic_host"),
5259 CLK_LOOKUP("core_clk", usb_hsic_system_clk.c, "msm_hsic_host"),
5260 CLK_LOOKUP("iface_clk", usb_hsic_p_clk.c, "msm_hsic_host"),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005261 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005262 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qcrypto.0"),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005263 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005264 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qcrypto.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005265 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005266 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005267 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005268 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
5269 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07005270 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
5271 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005272 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, ""),
5273 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, ""),
5274 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005275 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "qup_i2c.10"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005276 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005277 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.12"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005278 CLK_LOOKUP("iface_clk", tsif_p_clk.c, ""),
5279 CLK_LOOKUP("iface_clk", usb_fs1_p_clk.c, ""),
5280 CLK_LOOKUP("iface_clk", usb_fs2_p_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08005281 CLK_LOOKUP("iface_clk", usb_hs1_p_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005282 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5283 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5284 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5285 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
5286 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005287 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5288 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005289 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, ""),
5290 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, ""),
5291 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, ""),
5292 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, ""),
5293 CLK_LOOKUP("core_clk", amp_clk.c, ""),
Kevin Chan09f4e662011-12-16 08:17:02 -08005294 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-001a"),
5295 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-006c"),
5296 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-0048"),
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005297 CLK_LOOKUP("cam_clk", cam2_clk.c, NULL),
Sreesudhan Ramakrish Ramkumar8f11b8b2012-01-04 17:09:05 -08005298 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-0020"),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005299 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_csid.0"),
5300 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_csid.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005301 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, "msm_csid.2"),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005302 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_csid.0"),
5303 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csid.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005304 CLK_LOOKUP("csi_clk", csi2_clk.c, "msm_csid.2"),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005305 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_csid.0"),
5306 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_csid.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005307 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, "msm_csid.2"),
Kevin Chane12c6672011-10-26 11:55:26 -07005308 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, "msm_ispif.0"),
5309 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, "msm_ispif.0"),
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005310 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
5311 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
5312 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, "msm_ispif.0"),
5313 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, "msm_ispif.0"),
5314 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, "msm_ispif.0"),
5315 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
5316 CLK_LOOKUP("csi2phy_timer_clk", csi2phy_timer_clk.c, NULL),
Kevin Chanf6216f22011-10-25 18:40:11 -07005317 CLK_LOOKUP("csiphy_timer_src_clk",
5318 csiphy_timer_src_clk.c, "msm_csiphy.0"),
5319 CLK_LOOKUP("csiphy_timer_src_clk",
5320 csiphy_timer_src_clk.c, "msm_csiphy.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005321 CLK_LOOKUP("csiphy_timer_src_clk",
5322 csiphy_timer_src_clk.c, "msm_csiphy.2"),
Kevin Chanf6216f22011-10-25 18:40:11 -07005323 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, "msm_csiphy.0"),
5324 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, "msm_csiphy.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005325 CLK_LOOKUP("csiphy_timer_clk", csi2phy_timer_clk.c, "msm_csiphy.2"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005326 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5327 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5328 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5329 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005330 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005331 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005332 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005333 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005334 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005335 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5336 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Jignesh Mehta95dd6e12011-11-18 17:21:16 -08005337 CLK_LOOKUP("imem_clk", imem_axi_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005338 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005339 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005340 CLK_LOOKUP("core_clk", jpegd_clk.c, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005341 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005342 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005343 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005344 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005345 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005346 CLK_LOOKUP("lut_clk", lut_mdp_clk.c, "footswitch-8x60.4"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005347 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005348 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005349 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005350 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005351 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
5352 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005353 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005354 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005355 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005356 CLK_LOOKUP("tv_clk", mdp_tv_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005357 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005358 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Kevin Chana0853122011-11-07 19:48:44 -08005359 CLK_LOOKUP("vpe_clk", vpe_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005360 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Kevin Chan5827c552011-10-28 18:36:32 -07005361 CLK_LOOKUP("vfe_clk", vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005362 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Kevin Chan5827c552011-10-28 18:36:32 -07005363 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005364 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5365 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5366 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5367 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5368 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5369 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5370 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005371 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005372 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.0"),
5373 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005374 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.2"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005375 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5376 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5377 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5378 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005379 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005380 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005381 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005382 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005383 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005384 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005385 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
5386 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005387 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005388 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005389 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, ""),
Matt Wagantall5d44ef22012-01-23 11:01:05 -08005390 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, "kgsl-3d0.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005391 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005392 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07005393 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005394 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005395 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005396 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005397 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005398 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Kevin Chan5827c552011-10-28 18:36:32 -07005399 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005400 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Kevin Chana0853122011-11-07 19:48:44 -08005401 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005402 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Kuirong Wanga9c3acc2012-02-09 17:00:45 -08005403 CLK_LOOKUP("bit_clk", mi2s_bit_clk.c, "msm-dai-q6.6"),
5404 CLK_LOOKUP("osr_clk", mi2s_osr_clk.c, "msm-dai-q6.6"),
5405 CLK_LOOKUP("bit_clk", codec_i2s_mic_bit_clk.c,
5406 "msm-dai-q6.1"),
5407 CLK_LOOKUP("osr_clk", codec_i2s_mic_osr_clk.c,
5408 "msm-dai-q6.1"),
5409 CLK_LOOKUP("bit_clk", spare_i2s_mic_bit_clk.c,
5410 "msm-dai-q6.5"),
5411 CLK_LOOKUP("osr_clk", spare_i2s_mic_osr_clk.c,
5412 "msm-dai-q6.5"),
5413 CLK_LOOKUP("bit_clk", codec_i2s_spkr_bit_clk.c,
5414 "msm-dai-q6.16384"),
5415 CLK_LOOKUP("osr_clk", codec_i2s_spkr_osr_clk.c,
5416 "msm-dai-q6.16384"),
5417 CLK_LOOKUP("bit_clk", spare_i2s_spkr_bit_clk.c,
5418 "msm-dai-q6.4"),
5419 CLK_LOOKUP("osr_clk", spare_i2s_spkr_osr_clk.c,
5420 "msm-dai-q6.4"),
5421 CLK_LOOKUP("pcm_clk", pcm_clk.c, "msm-dai-q6.2"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005422 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
Tianyi Gou44a81b02012-02-06 17:49:07 -08005423 CLK_LOOKUP("core_clk", audio_slimbus_clk.c, "msm_slim_ctrl.1"),
Matt Wagantalle604d712011-10-21 15:38:18 -07005424 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
5425 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
5426 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
5427 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
5428 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
5429 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
5430 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
5431 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
5432 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
5433 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
5434 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
5435 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Gopikrishnaiah Anandan4d05ed32012-01-13 11:08:44 -08005436
5437 CLK_LOOKUP("mdp_iommu_clk", mdp_axi_clk.c, "msm_vidc.0"),
5438 CLK_LOOKUP("rot_iommu_clk", rot_axi_clk.c, "msm_vidc.0"),
5439 CLK_LOOKUP("vcodec_iommu0_clk", vcodec_axi_a_clk.c, "msm_vidc.0"),
5440 CLK_LOOKUP("vcodec_iommu1_clk", vcodec_axi_b_clk.c, "msm_vidc.0"),
5441 CLK_LOOKUP("smmu_iface_clk", smmu_p_clk.c, "msm_vidc.0"),
5442
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005443 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
Manu Gautam5143b252012-01-05 19:25:23 -08005444 CLK_LOOKUP("core_clk", dfab_usb_hs_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005445 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
5446 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
5447 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
5448 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
5449 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Yan He160633e2011-06-30 12:18:56 -07005450 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
Stephen Boyd1c51a492011-10-26 12:11:47 -07005451 CLK_LOOKUP("bus_clk", dfab_bam_dmux_clk.c, "BAM_RMNT"),
Stephen Boydef5d1c42011-12-15 20:47:14 -08005452 CLK_LOOKUP("bus_clk", dfab_scm_clk.c, "scm"),
Ramesh Masavarapua1bc0e42012-03-05 07:42:48 -08005453 CLK_LOOKUP("bus_clk", dfab_qseecom_clk.c, "qseecom"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005454
Matt Wagantalle1a86062011-08-18 17:46:10 -07005455 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005456
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005457 CLK_LOOKUP("l2_mclk", l2_m_clk, ""),
5458 CLK_LOOKUP("krait0_mclk", krait0_m_clk, ""),
5459 CLK_LOOKUP("krait1_mclk", krait1_m_clk, ""),
5460 CLK_LOOKUP("q6sw_clk", q6sw_clk, ""),
5461 CLK_LOOKUP("q6fw_clk", q6fw_clk, ""),
5462 CLK_LOOKUP("q6_func_clk", q6_func_clk, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005463};
5464
5465/*
5466 * Miscellaneous clock register initializations
5467 */
5468
5469/* Read, modify, then write-back a register. */
5470static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
5471{
5472 uint32_t regval = readl_relaxed(reg);
5473 regval &= ~mask;
5474 regval |= val;
5475 writel_relaxed(regval, reg);
5476}
5477
Tianyi Gou41515e22011-09-01 19:37:43 -07005478static void __init set_fsm_mode(void __iomem *mode_reg)
5479{
5480 u32 regval = readl_relaxed(mode_reg);
5481
5482 /*De-assert reset to FSM */
5483 regval &= ~BIT(21);
5484 writel_relaxed(regval, mode_reg);
5485
5486 /* Program bias count */
Tianyi Gou358c3862011-10-18 17:03:41 -07005487 regval &= ~BM(19, 14);
5488 regval |= BVAL(19, 14, 0x1);
5489 writel_relaxed(regval, mode_reg);
5490
5491 /* Program lock count */
Tianyi Gou41515e22011-09-01 19:37:43 -07005492 regval &= ~BM(13, 8);
5493 regval |= BVAL(13, 8, 0x8);
5494 writel_relaxed(regval, mode_reg);
5495
5496 /*Enable PLL FSM voting */
5497 regval |= BIT(20);
5498 writel_relaxed(regval, mode_reg);
5499}
5500
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005501static void __init reg_init(void)
5502{
Stephen Boydd471e7a2011-11-19 01:37:39 -08005503 void __iomem *imem_reg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005504 /* Deassert MM SW_RESET_ALL signal. */
5505 writel_relaxed(0, SW_RESET_ALL_REG);
5506
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005507 /*
5508 * Some bits are only used on either 8960 or 8064 and are marked as
5509 * reserved bits on the other SoC. Writing to these reserved bits
5510 * should have no effect.
5511 */
Stephen Boydd471e7a2011-11-19 01:37:39 -08005512 /*
5513 * Initialize MM AHB registers: Enable the FPB clock and disable HW
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005514 * gating on non-8960 for all clocks. Also set VFE_AHB's
Stephen Boydd471e7a2011-11-19 01:37:39 -08005515 * FORCE_CORE_ON bit to prevent its memory from being collapsed when
5516 * the clock is halted. The sleep and wake-up delays are set to safe
5517 * values.
5518 */
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005519 if (cpu_is_msm8960()) {
Stephen Boydd471e7a2011-11-19 01:37:39 -08005520 rmwreg(0x44000000, AHB_EN_REG, 0x6C000103);
5521 writel_relaxed(0x3C7097F9, AHB_EN2_REG);
5522 } else {
5523 rmwreg(0x00000003, AHB_EN_REG, 0x6C000103);
5524 writel_relaxed(0x000007F9, AHB_EN2_REG);
5525 }
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005526 if (cpu_is_apq8064())
5527 rmwreg(0x00000000, AHB_EN3_REG, 0x00000001);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005528
5529 /* Deassert all locally-owned MM AHB resets. */
5530 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
Tianyi Gou41515e22011-09-01 19:37:43 -07005531 rmwreg(0, SW_RESET_AHB2_REG, 0x0000000F);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005532
5533 /* Initialize MM AXI registers: Enable HW gating for all clocks that
5534 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
5535 * delays to safe values. */
Stephen Boydd471e7a2011-11-19 01:37:39 -08005536 if (cpu_is_msm8960() &&
5537 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 3) {
5538 rmwreg(0x0003AFF9, MAXI_EN_REG, 0x0803FFFF);
5539 rmwreg(0x3A27FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
Gopikrishnaiah Anandan83b6e852012-01-05 17:47:02 -08005540 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
Stephen Boydd471e7a2011-11-19 01:37:39 -08005541 } else {
5542 rmwreg(0x000007F9, MAXI_EN_REG, 0x0803FFFF);
5543 rmwreg(0x3027FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
5544 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
5545 }
Matt Wagantall53d968f2011-07-19 13:22:53 -07005546 rmwreg(0x0027FCFF, MAXI_EN3_REG, 0x003FFFFF);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005547 if (cpu_is_apq8064())
5548 rmwreg(0x009FE4FF, MAXI_EN5_REG, 0x01FFEFFF);
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005549 if (cpu_is_msm8960())
Stephen Boydd471e7a2011-11-19 01:37:39 -08005550 rmwreg(0x00003C38, SAXI_EN_REG, 0x00003FFF);
5551 else
5552 rmwreg(0x000003C7, SAXI_EN_REG, 0x00003FFF);
5553
5554 /* Enable IMEM's clk_on signal */
5555 imem_reg = ioremap(0x04b00040, 4);
5556 if (imem_reg) {
5557 writel_relaxed(0x3, imem_reg);
5558 iounmap(imem_reg);
5559 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005560
5561 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
5562 * memories retain state even when not clocked. Also, set sleep and
5563 * wake-up delays to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005564 rmwreg(0x00000000, CSI0_CC_REG, 0x00000410);
5565 rmwreg(0x00000000, CSI1_CC_REG, 0x00000410);
5566 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, 0xE0FF0010);
5567 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, 0xE0FF0010);
5568 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, 0xE0FF0010);
5569 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, 0xE0FF0010);
Tarun Karra6fbc00a2011-12-13 09:23:47 -07005570 rmwreg(0xC0FF0000, GFX3D_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005571 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0010);
5572 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0010);
5573 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
5574 rmwreg(0x80FF0000, MDP_LUT_CC_REG, 0xE0FF0010);
5575 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005576 rmwreg(0x000004FF, TV_CC2_REG, 0x000007FF);
5577 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
5578 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FF4010);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005579 rmwreg(0x800000FF, VFE_CC2_REG, 0xE00000FF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005580 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005581 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005582 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
5583 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
5584 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
5585 }
5586 if (cpu_is_apq8064()) {
5587 rmwreg(0x00000000, TV_CC_REG, 0x00004010);
Tianyi Gou621f8742011-09-01 21:45:01 -07005588 rmwreg(0x80FF0000, VCAP_CC_REG, 0xE0FF1010);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005589 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005590
Tianyi Gou41515e22011-09-01 19:37:43 -07005591 /*
5592 * Initialize USB_HS_HCLK_FS registers: Set FORCE_C_ON bits so that
5593 * core remain active during halt state of the clk. Also, set sleep
5594 * and wake-up value to max.
5595 */
5596 rmwreg(0x0000004F, USB_HS1_HCLK_FS_REG, 0x0000007F);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005597 if (cpu_is_apq8064()) {
5598 rmwreg(0x0000004F, USB_HS3_HCLK_FS_REG, 0x0000007F);
5599 rmwreg(0x0000004F, USB_HS4_HCLK_FS_REG, 0x0000007F);
5600 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005601
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005602 /* De-assert MM AXI resets to all hardware blocks. */
5603 writel_relaxed(0, SW_RESET_AXI_REG);
5604
5605 /* Deassert all MM core resets. */
5606 writel_relaxed(0, SW_RESET_CORE_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005607 writel_relaxed(0, SW_RESET_CORE2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005608
5609 /* Reset 3D core once more, with its clock enabled. This can
5610 * eventually be done as part of the GDFS footswitch driver. */
5611 clk_set_rate(&gfx3d_clk.c, 27000000);
5612 clk_enable(&gfx3d_clk.c);
5613 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
5614 mb();
5615 udelay(5);
5616 writel_relaxed(0, SW_RESET_CORE_REG);
5617 /* Make sure reset is de-asserted before clock is disabled. */
5618 mb();
5619 clk_disable(&gfx3d_clk.c);
5620
5621 /* Enable TSSC and PDM PXO sources. */
5622 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
5623 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
5624
5625 /* Source SLIMBus xo src from slimbus reference clock */
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005626 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005627 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005628
5629 /* Source the dsi_byte_clks from the DSI PHY PLLs */
5630 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
5631 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
Tianyi Gou41515e22011-09-01 19:37:43 -07005632
5633 /* Source the sata_phy_ref_clk from PXO */
5634 if (cpu_is_apq8064())
5635 rmwreg(0, SATA_PHY_REF_CLK_CTL_REG, 0x1);
5636
5637 /*
Tianyi Gou05e01102012-02-08 22:15:49 -08005638 * TODO: Programming below PLLs and prng_clk is temporary and
5639 * needs to be removed after bootloaders program them.
Tianyi Gou41515e22011-09-01 19:37:43 -07005640 */
5641 if (cpu_is_apq8064()) {
Tianyi Gou317aa862012-02-06 14:31:07 -08005642 u32 is_pll_enabled;
Tianyi Gou41515e22011-09-01 19:37:43 -07005643
5644 /* Program pxo_src_clk to source from PXO */
5645 rmwreg(0x1, PXO_SRC_CLK_CTL_REG, 0x7);
5646
Tianyi Gou41515e22011-09-01 19:37:43 -07005647 /* Check if PLL14 is active */
5648 is_pll_enabled = readl_relaxed(BB_PLL14_STATUS_REG) & BIT(16);
5649 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005650 /* Ref clk = 27MHz and program pll14 to 480MHz */
Tianyi Gou317aa862012-02-06 14:31:07 -08005651 writel_relaxed(0x00031011, BB_PLL14_L_VAL_REG);
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005652 writel_relaxed(0x7, BB_PLL14_M_VAL_REG);
5653 writel_relaxed(0x9, BB_PLL14_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005654
Tianyi Gou317aa862012-02-06 14:31:07 -08005655 /*
5656 * Enable the main output and the MN accumulator
5657 * Set pre-divider and post-divider values to 1 and 1
5658 */
5659 writel_relaxed(0x00C00000, BB_PLL14_CONFIG_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005660
Tianyi Gou41515e22011-09-01 19:37:43 -07005661 set_fsm_mode(BB_PLL14_MODE_REG);
5662 }
Tianyi Gou621f8742011-09-01 21:45:01 -07005663
Tianyi Gou621f8742011-09-01 21:45:01 -07005664 /* Program PLL15 to 975MHz with ref clk = 27MHz */
Tianyi Gou317aa862012-02-06 14:31:07 -08005665 writel_relaxed(0x31024, MM_PLL3_L_VAL_REG);
5666 writel_relaxed(0x1, MM_PLL3_M_VAL_REG);
5667 writel_relaxed(0x9, MM_PLL3_N_VAL_REG);
Tianyi Gou621f8742011-09-01 21:45:01 -07005668
Tianyi Gou317aa862012-02-06 14:31:07 -08005669 writel_relaxed(0xC20000, MM_PLL3_CONFIG_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005670
5671 /* Check if PLL4 is active */
5672 is_pll_enabled = readl_relaxed(LCC_PLL0_STATUS_REG) & BIT(16);
5673 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005674 /* Ref clk = 27MHz and program pll4 to 393.2160MHz */
5675 writel_relaxed(0xE, LCC_PLL0_L_VAL_REG);
5676 writel_relaxed(0x27A, LCC_PLL0_M_VAL_REG);
5677 writel_relaxed(0x465, LCC_PLL0_N_VAL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005678
Tianyi Gou317aa862012-02-06 14:31:07 -08005679 writel_relaxed(0xC00000, LCC_PLL0_CONFIG_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005680
5681 set_fsm_mode(LCC_PLL0_MODE_REG);
5682 }
5683
5684 /* Enable PLL4 source on the LPASS Primary PLL Mux */
5685 writel_relaxed(0x1, LCC_PRI_PLL_CLK_CTL_REG);
Tianyi Gou05e01102012-02-08 22:15:49 -08005686
5687 /* Program prng_clk to 64MHz if it isn't configured */
5688 if (!readl_relaxed(PRNG_CLK_NS_REG))
5689 writel_relaxed(0x2B, PRNG_CLK_NS_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005690 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005691}
5692
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005693/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07005694static void __init msm8960_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005695{
Tianyi Gou41515e22011-09-01 19:37:43 -07005696
Saravana Kannan298ec392012-02-08 19:21:47 -08005697 if (cpu_is_apq8064()) {
5698 vdd_sr2_pll.set_vdd = set_vdd_sr2_pll_8064;
Tianyi Goue1faaf22012-01-24 16:07:19 -08005699 } else if (cpu_is_msm8930() || cpu_is_msm8627()) {
Saravana Kannan298ec392012-02-08 19:21:47 -08005700 vdd_dig.set_vdd = set_vdd_dig_8930;
5701 vdd_sr2_pll.set_vdd = set_vdd_sr2_pll_8930;
Tianyi Goue1faaf22012-01-24 16:07:19 -08005702 }
Tianyi Goubf3d0b12012-01-23 14:37:28 -08005703
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005704 xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8960");
5705 if (IS_ERR(xo_pxo)) {
5706 pr_err("%s: msm_xo_get(PXO) failed.\n", __func__);
5707 BUG();
5708 }
Matt Wagantalled90b002011-12-12 21:22:43 -08005709 xo_cxo = msm_xo_get(MSM_XO_CXO, "clock-8960");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005710 if (IS_ERR(xo_cxo)) {
5711 pr_err("%s: msm_xo_get(CXO) failed.\n", __func__);
5712 BUG();
5713 }
5714
Tianyi Gou41515e22011-09-01 19:37:43 -07005715 /*
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005716 * Change the freq tables for and voltage requirements for
5717 * clocks which differ between 8960 and 8064.
Tianyi Gou41515e22011-09-01 19:37:43 -07005718 */
5719 if (cpu_is_apq8064()) {
5720 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8064;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005721
5722 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8064,
5723 sizeof(gfx3d_clk.c.fmax));
5724 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8064,
5725 sizeof(ijpeg_clk.c.fmax));
5726 memcpy(mdp_clk.c.fmax, fmax_mdp_8064,
5727 sizeof(ijpeg_clk.c.fmax));
5728 memcpy(tv_src_clk.c.fmax, fmax_tv_src_8064,
5729 sizeof(tv_src_clk.c.fmax));
5730 memcpy(vfe_clk.c.fmax, fmax_vfe_8064,
5731 sizeof(vfe_clk.c.fmax));
5732
Tianyi Gou621f8742011-09-01 21:45:01 -07005733 gmem_axi_clk.c.depends = &gfx3d_axi_clk.c;
Tianyi Gou41515e22011-09-01 19:37:43 -07005734 }
Stephen Boyd94625ef2011-07-12 17:06:01 -07005735
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005736 vote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005737
Vikram Mulukutla489e39e2011-08-31 18:04:05 -07005738 clk_ops_pll.enable = sr_pll_clk_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005739
5740 /* Initialize clock registers. */
5741 reg_init();
5742
5743 /* Initialize rates for clocks that only support one. */
5744 clk_set_rate(&pdm_clk.c, 27000000);
5745 clk_set_rate(&prng_clk.c, 64000000);
5746 clk_set_rate(&mdp_vsync_clk.c, 27000000);
5747 clk_set_rate(&tsif_ref_clk.c, 105000);
5748 clk_set_rate(&tssc_clk.c, 27000000);
5749 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
Tianyi Gou41515e22011-09-01 19:37:43 -07005750 if (cpu_is_apq8064()) {
5751 clk_set_rate(&usb_hs3_xcvr_clk.c, 60000000);
5752 clk_set_rate(&usb_hs4_xcvr_clk.c, 60000000);
5753 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005754 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005755 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou41515e22011-09-01 19:37:43 -07005756 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005757 clk_set_rate(&usb_hsic_xcvr_fs_clk.c, 60000000);
5758 clk_set_rate(&usb_hsic_hsic_src_clk.c, 480000000);
5759 clk_set_rate(&usb_hsic_hsio_cal_clk.c, 9000000);
Lena Salman127823f2012-02-14 17:13:53 +02005760 clk_set_rate(&usb_hsic_system_clk.c, 60000000);
Stephen Boyd092fd182011-10-21 15:56:30 -07005761 /*
5762 * Set the CSI rates to a safe default to avoid warnings when
5763 * switching csi pix and rdi clocks.
5764 */
5765 clk_set_rate(&csi0_src_clk.c, 27000000);
5766 clk_set_rate(&csi1_src_clk.c, 27000000);
5767 clk_set_rate(&csi2_src_clk.c, 27000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005768
5769 /*
Stephen Boyd60496bb2011-10-17 13:51:37 -07005770 * The halt status bits for these clocks may be incorrect at boot.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005771 * Toggle these clocks on and off to refresh them.
5772 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07005773 rcg_clk_enable(&pdm_clk.c);
5774 rcg_clk_disable(&pdm_clk.c);
5775 rcg_clk_enable(&tssc_clk.c);
5776 rcg_clk_disable(&tssc_clk.c);
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005777 clk_enable(&usb_hsic_hsic_clk.c);
5778 clk_disable(&usb_hsic_hsic_clk.c);
Stephen Boydd7a143a2012-02-16 17:59:26 -08005779
5780 /*
5781 * Keep sfab floor @ 54MHz so that Krait AHB is at least 27MHz at all
5782 * times when Apps CPU is active. This ensures the timer's requirement
5783 * of Krait AHB running 4 times as fast as the timer itself.
5784 */
5785 clk_set_rate(&sfab_tmr_a_clk.c, 54000000);
5786 clk_enable(&sfab_tmr_a_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005787}
5788
Stephen Boydbb600ae2011-08-02 20:11:40 -07005789static int __init msm8960_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005790{
Stephen Boyda3787f32011-09-16 18:55:13 -07005791 int rc;
5792 struct clk *mmfpb_a_clk = clk_get_sys("clock-8960", "mmfpb_a_clk");
Stephen Boyd85436132011-09-16 18:55:13 -07005793 struct clk *cfpb_a_clk = clk_get_sys("clock-8960", "cfpb_a_clk");
Stephen Boyda3787f32011-09-16 18:55:13 -07005794
5795 /* Vote for MMFPB to be at least 76.8MHz when an Apps CPU is active. */
5796 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
5797 PTR_ERR(mmfpb_a_clk)))
5798 return PTR_ERR(mmfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08005799 rc = clk_set_rate(mmfpb_a_clk, 76800000);
Stephen Boyda3787f32011-09-16 18:55:13 -07005800 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
5801 return rc;
5802 rc = clk_enable(mmfpb_a_clk);
5803 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
5804 return rc;
5805
Stephen Boyd85436132011-09-16 18:55:13 -07005806 /* Vote for CFPB to be at least 64MHz when an Apps CPU is active. */
5807 if (WARN(IS_ERR(cfpb_a_clk), "cfpb_a_clk not found (%ld)\n",
5808 PTR_ERR(cfpb_a_clk)))
5809 return PTR_ERR(cfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08005810 rc = clk_set_rate(cfpb_a_clk, 64000000);
Stephen Boyd85436132011-09-16 18:55:13 -07005811 if (WARN(rc, "cfpb_a_clk rate was not set (%d)\n", rc))
5812 return rc;
5813 rc = clk_enable(cfpb_a_clk);
5814 if (WARN(rc, "cfpb_a_clk not enabled (%d)\n", rc))
5815 return rc;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005816
5817 return unvote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005818}
Stephen Boydbb600ae2011-08-02 20:11:40 -07005819
5820struct clock_init_data msm8960_clock_init_data __initdata = {
5821 .table = msm_clocks_8960,
5822 .size = ARRAY_SIZE(msm_clocks_8960),
5823 .init = msm8960_clock_init,
5824 .late_init = msm8960_clock_late_init,
5825};
Tianyi Gou41515e22011-09-01 19:37:43 -07005826
5827struct clock_init_data apq8064_clock_init_data __initdata = {
5828 .table = msm_clocks_8064,
5829 .size = ARRAY_SIZE(msm_clocks_8064),
5830 .init = msm8960_clock_init,
5831 .late_init = msm8960_clock_late_init,
5832};