blob: 09f70f1e3f79c4e822f0da60c43b6321d757a3eb [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 Gou41515e22011-09-01 19:37:43 -070047#define CE3_HCLK_CTL_REG REG(0x36C4)
48#define CE3_CORE_CLK_CTL_REG REG(0x36CC)
49#define CE3_CLK_SRC_NS_REG REG(0x36C0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050#define DMA_BAM_HCLK_CTL REG(0x25C0)
Tianyi Gou41515e22011-09-01 19:37:43 -070051#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052#define CLK_HALT_CFPB_STATEA_REG REG(0x2FCC)
53#define CLK_HALT_CFPB_STATEB_REG REG(0x2FD0)
54#define CLK_HALT_CFPB_STATEC_REG REG(0x2FD4)
55#define CLK_HALT_DFAB_STATE_REG REG(0x2FC8)
Tianyi Gou41515e22011-09-01 19:37:43 -070056/* 8064 name CLK_HALT_GSS_KPSS_MISC_STATE_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057#define CLK_HALT_MSS_SMPSS_MISC_STATE_REG REG(0x2FDC)
58#define CLK_HALT_SFPB_MISC_STATE_REG REG(0x2FD8)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070059#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060#define CLK_TEST_REG REG(0x2FA0)
Matt Wagantall7625a4c2011-11-01 16:17:53 -070061#define GPn_MD_REG(n) REG(0x2D00+(0x20*(n)))
62#define GPn_NS_REG(n) REG(0x2D24+(0x20*(n)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070063#define GSBIn_HCLK_CTL_REG(n) REG(0x29C0+(0x20*((n)-1)))
64#define GSBIn_QUP_APPS_MD_REG(n) REG(0x29C8+(0x20*((n)-1)))
65#define GSBIn_QUP_APPS_NS_REG(n) REG(0x29CC+(0x20*((n)-1)))
66#define GSBIn_RESET_REG(n) REG(0x29DC+(0x20*((n)-1)))
67#define GSBIn_UART_APPS_MD_REG(n) REG(0x29D0+(0x20*((n)-1)))
68#define GSBIn_UART_APPS_NS_REG(n) REG(0x29D4+(0x20*((n)-1)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069#define PDM_CLK_NS_REG REG(0x2CC0)
Tianyi Gou41515e22011-09-01 19:37:43 -070070/* 8064 name BB_PLL_ENA_APCS_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070071#define BB_PLL_ENA_SC0_REG REG(0x34C0)
72#define BB_PLL0_STATUS_REG REG(0x30D8)
73#define BB_PLL5_STATUS_REG REG(0x30F8)
74#define BB_PLL6_STATUS_REG REG(0x3118)
75#define BB_PLL7_STATUS_REG REG(0x3138)
76#define BB_PLL8_L_VAL_REG REG(0x3144)
77#define BB_PLL8_M_VAL_REG REG(0x3148)
78#define BB_PLL8_MODE_REG REG(0x3140)
79#define BB_PLL8_N_VAL_REG REG(0x314C)
80#define BB_PLL8_STATUS_REG REG(0x3158)
81#define BB_PLL8_CONFIG_REG REG(0x3154)
82#define BB_PLL8_TEST_CTL_REG REG(0x3150)
Stephen Boyd94625ef2011-07-12 17:06:01 -070083#define BB_MMCC_PLL2_MODE_REG REG(0x3160)
84#define BB_MMCC_PLL2_TEST_CTL_REG REG(0x3170)
Tianyi Gou41515e22011-09-01 19:37:43 -070085#define BB_PLL14_MODE_REG REG(0x31C0)
86#define BB_PLL14_L_VAL_REG REG(0x31C4)
87#define BB_PLL14_M_VAL_REG REG(0x31C8)
88#define BB_PLL14_N_VAL_REG REG(0x31CC)
89#define BB_PLL14_TEST_CTL_REG REG(0x31D0)
90#define BB_PLL14_CONFIG_REG REG(0x31D4)
Stephen Boyd94625ef2011-07-12 17:06:01 -070091#define BB_PLL14_STATUS_REG REG(0x31D8)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092#define PLLTEST_PAD_CFG_REG REG(0x2FA4)
93#define PMEM_ACLK_CTL_REG REG(0x25A0)
94#define RINGOSC_NS_REG REG(0x2DC0)
95#define RINGOSC_STATUS_REG REG(0x2DCC)
96#define RINGOSC_TCXO_CTL_REG REG(0x2DC4)
Stephen Boyda52d7e32011-11-10 11:59:00 -080097#define RPM_MSG_RAM_HCLK_CTL_REG REG(0x27E0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070098#define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080)
99#define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1)))
100#define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1)))
101#define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1)))
102#define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1)))
103#define SLIMBUS_XO_SRC_CLK_CTL_REG REG(0x2628)
104#define TSIF_HCLK_CTL_REG REG(0x2700)
105#define TSIF_REF_CLK_MD_REG REG(0x270C)
106#define TSIF_REF_CLK_NS_REG REG(0x2710)
107#define TSSC_CLK_CTL_REG REG(0x2CA0)
Tianyi Gou41515e22011-09-01 19:37:43 -0700108#define SATA_CLK_SRC_NS_REG REG(0x2C08)
109#define SATA_RXOOB_CLK_CTL_REG REG(0x2C0C)
110#define SATA_PMALIVE_CLK_CTL_REG REG(0x2C10)
111#define SATA_PHY_REF_CLK_CTL_REG REG(0x2C14)
112#define SATA_PHY_CFG_CLK_CTL_REG REG(0x2C40)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700113#define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1)))
114#define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1)))
115#define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1)))
116#define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1)))
117#define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1)))
118#define USB_HS1_HCLK_CTL_REG REG(0x2900)
Tianyi Gou41515e22011-09-01 19:37:43 -0700119#define USB_HS1_HCLK_FS_REG REG(0x2904)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700120#define USB_HS1_RESET_REG REG(0x2910)
121#define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908)
122#define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700123#define USB_HS3_HCLK_CTL_REG REG(0x3700)
124#define USB_HS3_HCLK_FS_REG REG(0x3704)
125#define USB_HS3_RESET_REG REG(0x3710)
126#define USB_HS3_XCVR_FS_CLK_MD_REG REG(0X3708)
127#define USB_HS3_XCVR_FS_CLK_NS_REG REG(0X370C)
128#define USB_HS4_HCLK_CTL_REG REG(0x3720)
129#define USB_HS4_HCLK_FS_REG REG(0x3724)
130#define USB_HS4_RESET_REG REG(0x3730)
131#define USB_HS4_XCVR_FS_CLK_MD_REG REG(0X3728)
132#define USB_HS4_XCVR_FS_CLK_NS_REG REG(0X372C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700133#define USB_HSIC_HCLK_CTL_REG REG(0x2920)
134#define USB_HSIC_HSIC_CLK_CTL_REG REG(0x2B44)
135#define USB_HSIC_HSIC_CLK_SRC_CTL_REG REG(0x2B40)
136#define USB_HSIC_HSIO_CAL_CLK_CTL_REG REG(0x2B48)
137#define USB_HSIC_RESET_REG REG(0x2934)
138#define USB_HSIC_SYSTEM_CLK_CTL_REG REG(0x292C)
139#define USB_HSIC_XCVR_FS_CLK_MD_REG REG(0x2924)
140#define USB_HSIC_XCVR_FS_CLK_NS_REG REG(0x2928)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700141#define USB_PHY0_RESET_REG REG(0x2E20)
Tianyi Gou41515e22011-09-01 19:37:43 -0700142#define PCIE_ALT_REF_CLK_NS_REG REG(0x3860)
143#define PCIE_HCLK_CTL_REG REG(0x22CC)
144#define GPLL1_MODE_REG REG(0x3160)
145#define GPLL1_L_VAL_REG REG(0x3164)
146#define GPLL1_M_VAL_REG REG(0x3168)
147#define GPLL1_N_VAL_REG REG(0x316C)
148#define GPLL1_CONFIG_REG REG(0x3174)
149#define GPLL1_STATUS_REG REG(0x3178)
150#define PXO_SRC_CLK_CTL_REG REG(0x2EA0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700151
152/* Multimedia clock registers. */
153#define AHB_EN_REG REG_MM(0x0008)
154#define AHB_EN2_REG REG_MM(0x0038)
Tianyi Gou41515e22011-09-01 19:37:43 -0700155#define AHB_EN3_REG REG_MM(0x0248)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700156#define AHB_NS_REG REG_MM(0x0004)
157#define AXI_NS_REG REG_MM(0x0014)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700158#define CAMCLK0_NS_REG REG_MM(0x0148)
159#define CAMCLK0_CC_REG REG_MM(0x0140)
160#define CAMCLK0_MD_REG REG_MM(0x0144)
161#define CAMCLK1_NS_REG REG_MM(0x015C)
162#define CAMCLK1_CC_REG REG_MM(0x0154)
163#define CAMCLK1_MD_REG REG_MM(0x0158)
164#define CAMCLK2_NS_REG REG_MM(0x0228)
165#define CAMCLK2_CC_REG REG_MM(0x0220)
166#define CAMCLK2_MD_REG REG_MM(0x0224)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700167#define CSI0_NS_REG REG_MM(0x0048)
168#define CSI0_CC_REG REG_MM(0x0040)
169#define CSI0_MD_REG REG_MM(0x0044)
170#define CSI1_NS_REG REG_MM(0x0010)
171#define CSI1_CC_REG REG_MM(0x0024)
172#define CSI1_MD_REG REG_MM(0x0028)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700173#define CSI2_NS_REG REG_MM(0x0234)
174#define CSI2_CC_REG REG_MM(0x022C)
175#define CSI2_MD_REG REG_MM(0x0230)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700176#define CSIPHYTIMER_CC_REG REG_MM(0x0160)
177#define CSIPHYTIMER_MD_REG REG_MM(0x0164)
178#define CSIPHYTIMER_NS_REG REG_MM(0x0168)
179#define DSI1_BYTE_NS_REG REG_MM(0x00B0)
180#define DSI1_BYTE_CC_REG REG_MM(0x0090)
181#define DSI2_BYTE_NS_REG REG_MM(0x00BC)
182#define DSI2_BYTE_CC_REG REG_MM(0x00B4)
183#define DSI1_ESC_NS_REG REG_MM(0x011C)
184#define DSI1_ESC_CC_REG REG_MM(0x00CC)
185#define DSI2_ESC_NS_REG REG_MM(0x0150)
186#define DSI2_ESC_CC_REG REG_MM(0x013C)
187#define DSI_PIXEL_CC_REG REG_MM(0x0130)
188#define DSI2_PIXEL_CC_REG REG_MM(0x0094)
189#define DBG_BUS_VEC_A_REG REG_MM(0x01C8)
190#define DBG_BUS_VEC_B_REG REG_MM(0x01CC)
191#define DBG_BUS_VEC_C_REG REG_MM(0x01D0)
192#define DBG_BUS_VEC_D_REG REG_MM(0x01D4)
193#define DBG_BUS_VEC_E_REG REG_MM(0x01D8)
194#define DBG_BUS_VEC_F_REG REG_MM(0x01DC)
195#define DBG_BUS_VEC_G_REG REG_MM(0x01E0)
196#define DBG_BUS_VEC_H_REG REG_MM(0x01E4)
197#define DBG_BUS_VEC_I_REG REG_MM(0x01E8)
Tianyi Gou41515e22011-09-01 19:37:43 -0700198#define DBG_BUS_VEC_J_REG REG_MM(0x0240)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700199#define DBG_CFG_REG_HS_REG REG_MM(0x01B4)
200#define DBG_CFG_REG_LS_REG REG_MM(0x01B8)
201#define GFX2D0_CC_REG REG_MM(0x0060)
202#define GFX2D0_MD0_REG REG_MM(0x0064)
203#define GFX2D0_MD1_REG REG_MM(0x0068)
204#define GFX2D0_NS_REG REG_MM(0x0070)
205#define GFX2D1_CC_REG REG_MM(0x0074)
206#define GFX2D1_MD0_REG REG_MM(0x0078)
207#define GFX2D1_MD1_REG REG_MM(0x006C)
208#define GFX2D1_NS_REG REG_MM(0x007C)
209#define GFX3D_CC_REG REG_MM(0x0080)
210#define GFX3D_MD0_REG REG_MM(0x0084)
211#define GFX3D_MD1_REG REG_MM(0x0088)
212#define GFX3D_NS_REG REG_MM(0x008C)
213#define IJPEG_CC_REG REG_MM(0x0098)
214#define IJPEG_MD_REG REG_MM(0x009C)
215#define IJPEG_NS_REG REG_MM(0x00A0)
216#define JPEGD_CC_REG REG_MM(0x00A4)
217#define JPEGD_NS_REG REG_MM(0x00AC)
Tianyi Gou41515e22011-09-01 19:37:43 -0700218#define VCAP_CC_REG REG_MM(0x0178)
219#define VCAP_NS_REG REG_MM(0x021C)
220#define VCAP_MD0_REG REG_MM(0x01EC)
221#define VCAP_MD1_REG REG_MM(0x0218)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700222#define MAXI_EN_REG REG_MM(0x0018)
223#define MAXI_EN2_REG REG_MM(0x0020)
224#define MAXI_EN3_REG REG_MM(0x002C)
225#define MAXI_EN4_REG REG_MM(0x0114)
Tianyi Gou41515e22011-09-01 19:37:43 -0700226#define MAXI_EN5_REG REG_MM(0x0244)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700227#define MDP_CC_REG REG_MM(0x00C0)
228#define MDP_LUT_CC_REG REG_MM(0x016C)
229#define MDP_MD0_REG REG_MM(0x00C4)
230#define MDP_MD1_REG REG_MM(0x00C8)
231#define MDP_NS_REG REG_MM(0x00D0)
232#define MISC_CC_REG REG_MM(0x0058)
233#define MISC_CC2_REG REG_MM(0x005C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700234#define MISC_CC3_REG REG_MM(0x0238)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700235#define MM_PLL1_MODE_REG REG_MM(0x031C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700236#define MM_PLL1_L_VAL_REG REG_MM(0x0320)
237#define MM_PLL1_M_VAL_REG REG_MM(0x0324)
238#define MM_PLL1_N_VAL_REG REG_MM(0x0328)
239#define MM_PLL1_CONFIG_REG REG_MM(0x032C)
240#define MM_PLL1_TEST_CTL_REG REG_MM(0x0330)
241#define MM_PLL1_STATUS_REG REG_MM(0x0334)
242#define MM_PLL3_MODE_REG REG_MM(0x0338)
Tianyi Gou621f8742011-09-01 21:45:01 -0700243#define MM_PLL3_L_VAL_REG REG_MM(0x033C)
244#define MM_PLL3_M_VAL_REG REG_MM(0x0340)
245#define MM_PLL3_N_VAL_REG REG_MM(0x0344)
246#define MM_PLL3_CONFIG_REG REG_MM(0x0348)
247#define MM_PLL3_TEST_CTL_REG REG_MM(0x034C)
248#define MM_PLL3_STATUS_REG REG_MM(0x0350)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700249#define ROT_CC_REG REG_MM(0x00E0)
250#define ROT_NS_REG REG_MM(0x00E8)
251#define SAXI_EN_REG REG_MM(0x0030)
252#define SW_RESET_AHB_REG REG_MM(0x020C)
253#define SW_RESET_AHB2_REG REG_MM(0x0200)
254#define SW_RESET_ALL_REG REG_MM(0x0204)
255#define SW_RESET_AXI_REG REG_MM(0x0208)
256#define SW_RESET_CORE_REG REG_MM(0x0210)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700257#define SW_RESET_CORE2_REG REG_MM(0x0214)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700258#define TV_CC_REG REG_MM(0x00EC)
259#define TV_CC2_REG REG_MM(0x0124)
260#define TV_MD_REG REG_MM(0x00F0)
261#define TV_NS_REG REG_MM(0x00F4)
262#define VCODEC_CC_REG REG_MM(0x00F8)
263#define VCODEC_MD0_REG REG_MM(0x00FC)
264#define VCODEC_MD1_REG REG_MM(0x0128)
265#define VCODEC_NS_REG REG_MM(0x0100)
266#define VFE_CC_REG REG_MM(0x0104)
267#define VFE_MD_REG REG_MM(0x0108)
268#define VFE_NS_REG REG_MM(0x010C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700269#define VFE_CC2_REG REG_MM(0x023C)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700270#define VPE_CC_REG REG_MM(0x0110)
271#define VPE_NS_REG REG_MM(0x0118)
272
273/* Low-power Audio clock registers. */
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700274#define LCC_CLK_HS_DEBUG_CFG_REG REG_LPA(0x00A4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700275#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
276#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
277#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
278#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
279#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
280#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
281#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
282#define LCC_MI2S_MD_REG REG_LPA(0x004C)
283#define LCC_MI2S_NS_REG REG_LPA(0x0048)
284#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
285#define LCC_PCM_MD_REG REG_LPA(0x0058)
286#define LCC_PCM_NS_REG REG_LPA(0x0054)
287#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700288#define LCC_PLL0_MODE_REG REG_LPA(0x0000)
289#define LCC_PLL0_L_VAL_REG REG_LPA(0x0004)
290#define LCC_PLL0_M_VAL_REG REG_LPA(0x0008)
291#define LCC_PLL0_N_VAL_REG REG_LPA(0x000C)
292#define LCC_PLL0_CONFIG_REG REG_LPA(0x0014)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700293#define LCC_PLL0_STATUS_REG REG_LPA(0x0018)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700294#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
295#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
296#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
297#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
298#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
299#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
300#define LCC_SLIMBUS_NS_REG REG_LPA(0x00CC)
301#define LCC_SLIMBUS_MD_REG REG_LPA(0x00D0)
302#define LCC_SLIMBUS_STATUS_REG REG_LPA(0x00D4)
303#define LCC_AHBEX_BRANCH_CTL_REG REG_LPA(0x00E4)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700304#define LCC_PRI_PLL_CLK_CTL_REG REG_LPA(0x00C4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700305
Matt Wagantall8b38f942011-08-02 18:23:18 -0700306#define GCC_APCS_CLK_DIAG REG_GCC(0x001C)
307
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700308/* MUX source input identifiers. */
309#define pxo_to_bb_mux 0
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700310#define cxo_to_bb_mux 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700311#define pll0_to_bb_mux 2
312#define pll8_to_bb_mux 3
313#define pll6_to_bb_mux 4
314#define gnd_to_bb_mux 5
Stephen Boyd94625ef2011-07-12 17:06:01 -0700315#define pll3_to_bb_mux 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700316#define pxo_to_mm_mux 0
317#define pll1_to_mm_mux 1
Tianyi Gou41515e22011-09-01 19:37:43 -0700318#define pll2_to_mm_mux 1 /* or MMCC_PLL1 */
319#define pll8_to_mm_mux 2 /* or GCC_PERF */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700320#define pll0_to_mm_mux 3
Tianyi Gou41515e22011-09-01 19:37:43 -0700321#define pll15_to_mm_mux 3 /* or MM_PLL3 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700322#define gnd_to_mm_mux 4
Stephen Boyd7a776cd2011-10-20 12:46:04 -0700323#define pll3_to_mm_mux 3 /* or MMCC_PLL2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700324#define hdmi_pll_to_mm_mux 3
325#define cxo_to_xo_mux 0
326#define pxo_to_xo_mux 1
327#define gnd_to_xo_mux 3
328#define pxo_to_lpa_mux 0
329#define cxo_to_lpa_mux 1
330#define pll4_to_lpa_mux 2
331#define gnd_to_lpa_mux 6
Tianyi Gou41515e22011-09-01 19:37:43 -0700332#define pxo_to_pcie_mux 0
333#define pll3_to_pcie_mux 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700334
335/* Test Vector Macros */
336#define TEST_TYPE_PER_LS 1
337#define TEST_TYPE_PER_HS 2
338#define TEST_TYPE_MM_LS 3
339#define TEST_TYPE_MM_HS 4
340#define TEST_TYPE_LPA 5
Matt Wagantall8b38f942011-08-02 18:23:18 -0700341#define TEST_TYPE_CPUL2 6
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700342#define TEST_TYPE_LPA_HS 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700343#define TEST_TYPE_SHIFT 24
344#define TEST_CLK_SEL_MASK BM(23, 0)
345#define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s)))
346#define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS)
347#define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS)
348#define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS)
349#define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS)
350#define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA)
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700351#define TEST_LPA_HS(s) TEST_VECTOR((s), TEST_TYPE_LPA_HS)
Matt Wagantall8b38f942011-08-02 18:23:18 -0700352#define TEST_CPUL2(s) TEST_VECTOR((s), TEST_TYPE_CPUL2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700353
354#define MN_MODE_DUAL_EDGE 0x2
355
356/* MD Registers */
357#define MD4(m_lsb, m, n_lsb, n) \
358 (BVAL((m_lsb+3), m_lsb, m) | BVAL((n_lsb+3), n_lsb, ~(n)))
359#define MD8(m_lsb, m, n_lsb, n) \
360 (BVAL((m_lsb+7), m_lsb, m) | BVAL((n_lsb+7), n_lsb, ~(n)))
361#define MD16(m, n) (BVAL(31, 16, m) | BVAL(15, 0, ~(n)))
362
363/* NS Registers */
364#define NS(n_msb, n_lsb, n, m, mde_lsb, d_msb, d_lsb, d, s_msb, s_lsb, s) \
365 (BVAL(n_msb, n_lsb, ~(n-m)) \
366 | (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n)) \
367 | BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
368
369#define NS_MM(n_msb, n_lsb, n, m, d_msb, d_lsb, d, s_msb, s_lsb, s) \
370 (BVAL(n_msb, n_lsb, ~(n-m)) | BVAL(d_msb, d_lsb, (d-1)) \
371 | BVAL(s_msb, s_lsb, s))
372
373#define NS_DIVSRC(d_msb , d_lsb, d, s_msb, s_lsb, s) \
374 (BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
375
376#define NS_DIV(d_msb , d_lsb, d) \
377 BVAL(d_msb, d_lsb, (d-1))
378
379#define NS_SRC_SEL(s_msb, s_lsb, s) \
380 BVAL(s_msb, s_lsb, s)
381
382#define NS_MND_BANKED4(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
383 (BVAL((n0_lsb+3), n0_lsb, ~(n-m)) \
384 | BVAL((n1_lsb+3), n1_lsb, ~(n-m)) \
385 | BVAL((s0_lsb+2), s0_lsb, s) \
386 | BVAL((s1_lsb+2), s1_lsb, s))
387
388#define NS_MND_BANKED8(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
389 (BVAL((n0_lsb+7), n0_lsb, ~(n-m)) \
390 | BVAL((n1_lsb+7), n1_lsb, ~(n-m)) \
391 | BVAL((s0_lsb+2), s0_lsb, s) \
392 | BVAL((s1_lsb+2), s1_lsb, s))
393
394#define NS_DIVSRC_BANKED(d0_msb, d0_lsb, d1_msb, d1_lsb, d, \
395 s0_msb, s0_lsb, s1_msb, s1_lsb, s) \
396 (BVAL(d0_msb, d0_lsb, (d-1)) | BVAL(d1_msb, d1_lsb, (d-1)) \
397 | BVAL(s0_msb, s0_lsb, s) \
398 | BVAL(s1_msb, s1_lsb, s))
399
400/* CC Registers */
401#define CC(mde_lsb, n) (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n))
402#define CC_BANKED(mde0_lsb, mde1_lsb, n) \
403 ((BVAL((mde0_lsb+1), mde0_lsb, MN_MODE_DUAL_EDGE) \
404 | BVAL((mde1_lsb+1), mde1_lsb, MN_MODE_DUAL_EDGE)) \
405 * !!(n))
406
407struct pll_rate {
408 const uint32_t l_val;
409 const uint32_t m_val;
410 const uint32_t n_val;
411 const uint32_t vco;
412 const uint32_t post_div;
413 const uint32_t i_bits;
414};
415#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
416
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700417enum vdd_dig_levels {
418 VDD_DIG_NONE,
419 VDD_DIG_LOW,
420 VDD_DIG_NOMINAL,
421 VDD_DIG_HIGH
422};
423
424static int set_vdd_dig(struct clk_vdd_class *vdd_class, int level)
425{
426 static const int vdd_uv[] = {
427 [VDD_DIG_NONE] = 0,
428 [VDD_DIG_LOW] = 945000,
429 [VDD_DIG_NOMINAL] = 1050000,
430 [VDD_DIG_HIGH] = 1150000
431 };
432
433 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
434 vdd_uv[level], 1150000, 1);
435}
436
437static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig);
438
439#define VDD_DIG_FMAX_MAP1(l1, f1) \
440 .vdd_class = &vdd_dig, \
441 .fmax[VDD_DIG_##l1] = (f1)
442#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
443 .vdd_class = &vdd_dig, \
444 .fmax[VDD_DIG_##l1] = (f1), \
445 .fmax[VDD_DIG_##l2] = (f2)
446#define VDD_DIG_FMAX_MAP3(l1, f1, l2, f2, l3, f3) \
447 .vdd_class = &vdd_dig, \
448 .fmax[VDD_DIG_##l1] = (f1), \
449 .fmax[VDD_DIG_##l2] = (f2), \
450 .fmax[VDD_DIG_##l3] = (f3)
451
Matt Wagantallc57577d2011-10-06 17:06:53 -0700452enum vdd_l23_levels {
453 VDD_L23_OFF,
454 VDD_L23_ON
455};
456
457static int set_vdd_l23(struct clk_vdd_class *vdd_class, int level)
458{
459 int rc;
460
461 if (level == VDD_L23_OFF) {
462 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
463 RPM_VREG_VOTER3, 0, 0, 1);
464 if (rc)
465 return rc;
466 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
467 RPM_VREG_VOTER3, 0, 0, 1);
468 if (rc)
469 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
470 RPM_VREG_VOTER3, 1800000, 1800000, 1);
471 } else {
472 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
473 RPM_VREG_VOTER3, 2200000, 2200000, 1);
474 if (rc)
475 return rc;
476 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
477 RPM_VREG_VOTER3, 1800000, 1800000, 1);
478 if (rc)
479 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
480 RPM_VREG_VOTER3, 0, 0, 1);
481 }
482
483 return rc;
484}
485
486static DEFINE_VDD_CLASS(vdd_l23, set_vdd_l23);
487
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700488/*
489 * Clock Descriptions
490 */
491
492static struct msm_xo_voter *xo_pxo, *xo_cxo;
493
494static int pxo_clk_enable(struct clk *clk)
495{
496 return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON);
497}
498
499static void pxo_clk_disable(struct clk *clk)
500{
Tianyi Gou41515e22011-09-01 19:37:43 -0700501 msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700502}
503
504static struct clk_ops clk_ops_pxo = {
505 .enable = pxo_clk_enable,
506 .disable = pxo_clk_disable,
507 .get_rate = fixed_clk_get_rate,
508 .is_local = local_clk_is_local,
509};
510
511static struct fixed_clk pxo_clk = {
512 .rate = 27000000,
513 .c = {
514 .dbg_name = "pxo_clk",
515 .ops = &clk_ops_pxo,
516 CLK_INIT(pxo_clk.c),
517 },
518};
519
520static int cxo_clk_enable(struct clk *clk)
521{
522 return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON);
523}
524
525static void cxo_clk_disable(struct clk *clk)
526{
527 msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF);
528}
529
530static struct clk_ops clk_ops_cxo = {
531 .enable = cxo_clk_enable,
532 .disable = cxo_clk_disable,
533 .get_rate = fixed_clk_get_rate,
534 .is_local = local_clk_is_local,
535};
536
537static struct fixed_clk cxo_clk = {
538 .rate = 19200000,
539 .c = {
540 .dbg_name = "cxo_clk",
541 .ops = &clk_ops_cxo,
542 CLK_INIT(cxo_clk.c),
543 },
544};
545
546static struct pll_clk pll2_clk = {
547 .rate = 800000000,
548 .mode_reg = MM_PLL1_MODE_REG,
549 .parent = &pxo_clk.c,
550 .c = {
551 .dbg_name = "pll2_clk",
552 .ops = &clk_ops_pll,
553 CLK_INIT(pll2_clk.c),
554 },
555};
556
Stephen Boyd94625ef2011-07-12 17:06:01 -0700557static struct pll_clk pll3_clk = {
558 .rate = 1200000000,
559 .mode_reg = BB_MMCC_PLL2_MODE_REG,
560 .parent = &pxo_clk.c,
561 .c = {
562 .dbg_name = "pll3_clk",
563 .ops = &clk_ops_pll,
Matt Wagantallc57577d2011-10-06 17:06:53 -0700564 .vdd_class = &vdd_l23,
565 .fmax[VDD_L23_ON] = ULONG_MAX,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700566 CLK_INIT(pll3_clk.c),
567 },
568};
569
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700570static struct pll_vote_clk pll4_clk = {
571 .rate = 393216000,
572 .en_reg = BB_PLL_ENA_SC0_REG,
573 .en_mask = BIT(4),
574 .status_reg = LCC_PLL0_STATUS_REG,
575 .parent = &pxo_clk.c,
576 .c = {
577 .dbg_name = "pll4_clk",
578 .ops = &clk_ops_pll_vote,
579 CLK_INIT(pll4_clk.c),
580 },
581};
582
583static struct pll_vote_clk pll8_clk = {
584 .rate = 384000000,
585 .en_reg = BB_PLL_ENA_SC0_REG,
586 .en_mask = BIT(8),
587 .status_reg = BB_PLL8_STATUS_REG,
588 .parent = &pxo_clk.c,
589 .c = {
590 .dbg_name = "pll8_clk",
591 .ops = &clk_ops_pll_vote,
592 CLK_INIT(pll8_clk.c),
593 },
594};
595
Stephen Boyd94625ef2011-07-12 17:06:01 -0700596static struct pll_vote_clk pll14_clk = {
597 .rate = 480000000,
598 .en_reg = BB_PLL_ENA_SC0_REG,
599 .en_mask = BIT(14),
600 .status_reg = BB_PLL14_STATUS_REG,
601 .parent = &pxo_clk.c,
602 .c = {
603 .dbg_name = "pll14_clk",
604 .ops = &clk_ops_pll_vote,
605 CLK_INIT(pll14_clk.c),
606 },
607};
608
Tianyi Gou41515e22011-09-01 19:37:43 -0700609static struct pll_clk pll15_clk = {
610 .rate = 975000000,
611 .mode_reg = MM_PLL3_MODE_REG,
612 .parent = &pxo_clk.c,
613 .c = {
614 .dbg_name = "pll15_clk",
615 .ops = &clk_ops_pll,
616 CLK_INIT(pll15_clk.c),
617 },
618};
619
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700620static struct clk_ops clk_ops_rcg_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700621 .enable = rcg_clk_enable,
622 .disable = rcg_clk_disable,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800623 .enable_hwcg = rcg_clk_enable_hwcg,
624 .disable_hwcg = rcg_clk_disable_hwcg,
625 .in_hwcg_mode = rcg_clk_in_hwcg_mode,
Matt Wagantall41af0772011-09-17 12:21:39 -0700626 .auto_off = rcg_clk_disable,
Matt Wagantall53d968f2011-07-19 13:22:53 -0700627 .handoff = rcg_clk_handoff,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700628 .set_rate = rcg_clk_set_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700629 .get_rate = rcg_clk_get_rate,
630 .list_rate = rcg_clk_list_rate,
631 .is_enabled = rcg_clk_is_enabled,
632 .round_rate = rcg_clk_round_rate,
Stephen Boyd7bf28142011-12-07 00:30:52 -0800633 .reset = rcg_clk_reset,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700634 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700635 .get_parent = rcg_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700636};
637
638static struct clk_ops clk_ops_branch = {
639 .enable = branch_clk_enable,
640 .disable = branch_clk_disable,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800641 .enable_hwcg = branch_clk_enable_hwcg,
642 .disable_hwcg = branch_clk_disable_hwcg,
643 .in_hwcg_mode = branch_clk_in_hwcg_mode,
Matt Wagantall41af0772011-09-17 12:21:39 -0700644 .auto_off = branch_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700645 .is_enabled = branch_clk_is_enabled,
646 .reset = branch_clk_reset,
647 .is_local = local_clk_is_local,
648 .get_parent = branch_clk_get_parent,
649 .set_parent = branch_clk_set_parent,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800650 .handoff = branch_clk_handoff,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700651};
652
653static struct clk_ops clk_ops_reset = {
654 .reset = branch_clk_reset,
655 .is_local = local_clk_is_local,
656};
657
658/* AXI Interfaces */
659static struct branch_clk gmem_axi_clk = {
660 .b = {
661 .ctl_reg = MAXI_EN_REG,
662 .en_mask = BIT(24),
663 .halt_reg = DBG_BUS_VEC_E_REG,
664 .halt_bit = 6,
665 },
666 .c = {
667 .dbg_name = "gmem_axi_clk",
668 .ops = &clk_ops_branch,
669 CLK_INIT(gmem_axi_clk.c),
670 },
671};
672
673static struct branch_clk ijpeg_axi_clk = {
674 .b = {
675 .ctl_reg = MAXI_EN_REG,
676 .en_mask = BIT(21),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800677 .hwcg_reg = MAXI_EN_REG,
678 .hwcg_mask = BIT(11),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700679 .reset_reg = SW_RESET_AXI_REG,
680 .reset_mask = BIT(14),
681 .halt_reg = DBG_BUS_VEC_E_REG,
682 .halt_bit = 4,
683 },
684 .c = {
685 .dbg_name = "ijpeg_axi_clk",
686 .ops = &clk_ops_branch,
687 CLK_INIT(ijpeg_axi_clk.c),
688 },
689};
690
691static struct branch_clk imem_axi_clk = {
692 .b = {
693 .ctl_reg = MAXI_EN_REG,
694 .en_mask = BIT(22),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800695 .hwcg_reg = MAXI_EN_REG,
696 .hwcg_mask = BIT(15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700697 .reset_reg = SW_RESET_CORE_REG,
698 .reset_mask = BIT(10),
699 .halt_reg = DBG_BUS_VEC_E_REG,
700 .halt_bit = 7,
701 },
702 .c = {
703 .dbg_name = "imem_axi_clk",
704 .ops = &clk_ops_branch,
705 CLK_INIT(imem_axi_clk.c),
706 },
707};
708
709static struct branch_clk jpegd_axi_clk = {
710 .b = {
711 .ctl_reg = MAXI_EN_REG,
712 .en_mask = BIT(25),
713 .halt_reg = DBG_BUS_VEC_E_REG,
714 .halt_bit = 5,
715 },
716 .c = {
717 .dbg_name = "jpegd_axi_clk",
718 .ops = &clk_ops_branch,
719 CLK_INIT(jpegd_axi_clk.c),
720 },
721};
722
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700723static struct branch_clk vcodec_axi_b_clk = {
724 .b = {
725 .ctl_reg = MAXI_EN4_REG,
726 .en_mask = BIT(23),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800727 .hwcg_reg = MAXI_EN4_REG,
728 .hwcg_mask = BIT(22),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700729 .halt_reg = DBG_BUS_VEC_I_REG,
730 .halt_bit = 25,
731 },
732 .c = {
733 .dbg_name = "vcodec_axi_b_clk",
734 .ops = &clk_ops_branch,
735 CLK_INIT(vcodec_axi_b_clk.c),
736 },
737};
738
Matt Wagantall91f42702011-07-14 12:01:15 -0700739static struct branch_clk vcodec_axi_a_clk = {
740 .b = {
741 .ctl_reg = MAXI_EN4_REG,
742 .en_mask = BIT(25),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800743 .hwcg_reg = MAXI_EN4_REG,
744 .hwcg_mask = BIT(24),
Matt Wagantall91f42702011-07-14 12:01:15 -0700745 .halt_reg = DBG_BUS_VEC_I_REG,
746 .halt_bit = 26,
747 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700748 .c = {
749 .dbg_name = "vcodec_axi_a_clk",
750 .ops = &clk_ops_branch,
751 CLK_INIT(vcodec_axi_a_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700752 .depends = &vcodec_axi_b_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700753 },
754};
755
756static struct branch_clk vcodec_axi_clk = {
757 .b = {
758 .ctl_reg = MAXI_EN_REG,
759 .en_mask = BIT(19),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800760 .hwcg_reg = MAXI_EN_REG,
761 .hwcg_mask = BIT(13),
Matt Wagantall91f42702011-07-14 12:01:15 -0700762 .reset_reg = SW_RESET_AXI_REG,
Gopikrishnaiah Anandan83b6e852012-01-05 17:47:02 -0800763 .reset_mask = BIT(4)|BIT(5)|BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700764 .halt_reg = DBG_BUS_VEC_E_REG,
765 .halt_bit = 3,
766 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700767 .c = {
768 .dbg_name = "vcodec_axi_clk",
769 .ops = &clk_ops_branch,
770 CLK_INIT(vcodec_axi_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700771 .depends = &vcodec_axi_a_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700772 },
773};
774
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700775static struct branch_clk vfe_axi_clk = {
776 .b = {
777 .ctl_reg = MAXI_EN_REG,
778 .en_mask = BIT(18),
779 .reset_reg = SW_RESET_AXI_REG,
780 .reset_mask = BIT(9),
781 .halt_reg = DBG_BUS_VEC_E_REG,
782 .halt_bit = 0,
783 },
784 .c = {
785 .dbg_name = "vfe_axi_clk",
786 .ops = &clk_ops_branch,
787 CLK_INIT(vfe_axi_clk.c),
788 },
789};
790
791static struct branch_clk mdp_axi_clk = {
792 .b = {
793 .ctl_reg = MAXI_EN_REG,
794 .en_mask = BIT(23),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800795 .hwcg_reg = MAXI_EN_REG,
796 .hwcg_mask = BIT(16),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700797 .reset_reg = SW_RESET_AXI_REG,
798 .reset_mask = BIT(13),
799 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700800 .halt_bit = 8,
801 },
802 .c = {
803 .dbg_name = "mdp_axi_clk",
804 .ops = &clk_ops_branch,
805 CLK_INIT(mdp_axi_clk.c),
806 },
807};
808
809static struct branch_clk rot_axi_clk = {
810 .b = {
811 .ctl_reg = MAXI_EN2_REG,
812 .en_mask = BIT(24),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800813 .hwcg_reg = MAXI_EN2_REG,
814 .hwcg_mask = BIT(25),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700815 .reset_reg = SW_RESET_AXI_REG,
816 .reset_mask = BIT(6),
817 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700818 .halt_bit = 2,
819 },
820 .c = {
821 .dbg_name = "rot_axi_clk",
822 .ops = &clk_ops_branch,
823 CLK_INIT(rot_axi_clk.c),
824 },
825};
826
827static struct branch_clk vpe_axi_clk = {
828 .b = {
829 .ctl_reg = MAXI_EN2_REG,
830 .en_mask = BIT(26),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800831 .hwcg_reg = MAXI_EN2_REG,
832 .hwcg_mask = BIT(27),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700833 .reset_reg = SW_RESET_AXI_REG,
834 .reset_mask = BIT(15),
835 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700836 .halt_bit = 1,
837 },
838 .c = {
839 .dbg_name = "vpe_axi_clk",
840 .ops = &clk_ops_branch,
841 CLK_INIT(vpe_axi_clk.c),
842 },
843};
844
Tianyi Gou41515e22011-09-01 19:37:43 -0700845static struct branch_clk vcap_axi_clk = {
846 .b = {
847 .ctl_reg = MAXI_EN5_REG,
848 .en_mask = BIT(12),
849 .reset_reg = SW_RESET_AXI_REG,
850 .reset_mask = BIT(16),
851 .halt_reg = DBG_BUS_VEC_J_REG,
852 .halt_bit = 20,
853 },
854 .c = {
855 .dbg_name = "vcap_axi_clk",
856 .ops = &clk_ops_branch,
857 CLK_INIT(vcap_axi_clk.c),
858 },
859};
860
Tianyi Gou621f8742011-09-01 21:45:01 -0700861/* For 8064, gfx3d_axi_clk is set as a dependency of gmem_axi_clk at runtime */
862static struct branch_clk gfx3d_axi_clk = {
863 .b = {
864 .ctl_reg = MAXI_EN5_REG,
865 .en_mask = BIT(25),
866 .reset_reg = SW_RESET_AXI_REG,
867 .reset_mask = BIT(17),
868 .halt_reg = DBG_BUS_VEC_J_REG,
869 .halt_bit = 30,
870 },
871 .c = {
872 .dbg_name = "gfx3d_axi_clk",
873 .ops = &clk_ops_branch,
874 CLK_INIT(gfx3d_axi_clk.c),
875 },
876};
877
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700878/* AHB Interfaces */
879static struct branch_clk amp_p_clk = {
880 .b = {
881 .ctl_reg = AHB_EN_REG,
882 .en_mask = BIT(24),
883 .halt_reg = DBG_BUS_VEC_F_REG,
884 .halt_bit = 18,
885 },
886 .c = {
887 .dbg_name = "amp_p_clk",
888 .ops = &clk_ops_branch,
889 CLK_INIT(amp_p_clk.c),
890 },
891};
892
Matt Wagantallc23eee92011-08-16 23:06:52 -0700893static struct branch_clk csi_p_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700894 .b = {
895 .ctl_reg = AHB_EN_REG,
896 .en_mask = BIT(7),
897 .reset_reg = SW_RESET_AHB_REG,
898 .reset_mask = BIT(17),
899 .halt_reg = DBG_BUS_VEC_F_REG,
900 .halt_bit = 16,
901 },
902 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -0700903 .dbg_name = "csi_p_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700904 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -0700905 CLK_INIT(csi_p_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700906 },
907};
908
909static struct branch_clk dsi1_m_p_clk = {
910 .b = {
911 .ctl_reg = AHB_EN_REG,
912 .en_mask = BIT(9),
913 .reset_reg = SW_RESET_AHB_REG,
914 .reset_mask = BIT(6),
915 .halt_reg = DBG_BUS_VEC_F_REG,
916 .halt_bit = 19,
917 },
918 .c = {
919 .dbg_name = "dsi1_m_p_clk",
920 .ops = &clk_ops_branch,
921 CLK_INIT(dsi1_m_p_clk.c),
922 },
923};
924
925static struct branch_clk dsi1_s_p_clk = {
926 .b = {
927 .ctl_reg = AHB_EN_REG,
928 .en_mask = BIT(18),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800929 .hwcg_reg = AHB_EN2_REG,
930 .hwcg_mask = BIT(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700931 .reset_reg = SW_RESET_AHB_REG,
932 .reset_mask = BIT(5),
933 .halt_reg = DBG_BUS_VEC_F_REG,
934 .halt_bit = 21,
935 },
936 .c = {
937 .dbg_name = "dsi1_s_p_clk",
938 .ops = &clk_ops_branch,
939 CLK_INIT(dsi1_s_p_clk.c),
940 },
941};
942
943static struct branch_clk dsi2_m_p_clk = {
944 .b = {
945 .ctl_reg = AHB_EN_REG,
946 .en_mask = BIT(17),
947 .reset_reg = SW_RESET_AHB2_REG,
948 .reset_mask = BIT(1),
949 .halt_reg = DBG_BUS_VEC_E_REG,
950 .halt_bit = 18,
951 },
952 .c = {
953 .dbg_name = "dsi2_m_p_clk",
954 .ops = &clk_ops_branch,
955 CLK_INIT(dsi2_m_p_clk.c),
956 },
957};
958
959static struct branch_clk dsi2_s_p_clk = {
960 .b = {
961 .ctl_reg = AHB_EN_REG,
962 .en_mask = BIT(22),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800963 .hwcg_reg = AHB_EN2_REG,
964 .hwcg_mask = BIT(15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700965 .reset_reg = SW_RESET_AHB2_REG,
966 .reset_mask = BIT(0),
967 .halt_reg = DBG_BUS_VEC_F_REG,
968 .halt_bit = 20,
969 },
970 .c = {
971 .dbg_name = "dsi2_s_p_clk",
972 .ops = &clk_ops_branch,
973 CLK_INIT(dsi2_s_p_clk.c),
974 },
975};
976
977static struct branch_clk gfx2d0_p_clk = {
978 .b = {
979 .ctl_reg = AHB_EN_REG,
980 .en_mask = BIT(19),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800981 .hwcg_reg = AHB_EN2_REG,
982 .hwcg_mask = BIT(28),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700983 .reset_reg = SW_RESET_AHB_REG,
984 .reset_mask = BIT(12),
985 .halt_reg = DBG_BUS_VEC_F_REG,
986 .halt_bit = 2,
987 },
988 .c = {
989 .dbg_name = "gfx2d0_p_clk",
990 .ops = &clk_ops_branch,
991 CLK_INIT(gfx2d0_p_clk.c),
992 },
993};
994
995static struct branch_clk gfx2d1_p_clk = {
996 .b = {
997 .ctl_reg = AHB_EN_REG,
998 .en_mask = BIT(2),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800999 .hwcg_reg = AHB_EN2_REG,
1000 .hwcg_mask = BIT(29),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001001 .reset_reg = SW_RESET_AHB_REG,
1002 .reset_mask = BIT(11),
1003 .halt_reg = DBG_BUS_VEC_F_REG,
1004 .halt_bit = 3,
1005 },
1006 .c = {
1007 .dbg_name = "gfx2d1_p_clk",
1008 .ops = &clk_ops_branch,
1009 CLK_INIT(gfx2d1_p_clk.c),
1010 },
1011};
1012
1013static struct branch_clk gfx3d_p_clk = {
1014 .b = {
1015 .ctl_reg = AHB_EN_REG,
1016 .en_mask = BIT(3),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001017 .hwcg_reg = AHB_EN2_REG,
1018 .hwcg_mask = BIT(27),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001019 .reset_reg = SW_RESET_AHB_REG,
1020 .reset_mask = BIT(10),
1021 .halt_reg = DBG_BUS_VEC_F_REG,
1022 .halt_bit = 4,
1023 },
1024 .c = {
1025 .dbg_name = "gfx3d_p_clk",
1026 .ops = &clk_ops_branch,
1027 CLK_INIT(gfx3d_p_clk.c),
1028 },
1029};
1030
1031static struct branch_clk hdmi_m_p_clk = {
1032 .b = {
1033 .ctl_reg = AHB_EN_REG,
1034 .en_mask = BIT(14),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001035 .hwcg_reg = AHB_EN2_REG,
1036 .hwcg_mask = BIT(21),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001037 .reset_reg = SW_RESET_AHB_REG,
1038 .reset_mask = BIT(9),
1039 .halt_reg = DBG_BUS_VEC_F_REG,
1040 .halt_bit = 5,
1041 },
1042 .c = {
1043 .dbg_name = "hdmi_m_p_clk",
1044 .ops = &clk_ops_branch,
1045 CLK_INIT(hdmi_m_p_clk.c),
1046 },
1047};
1048
1049static struct branch_clk hdmi_s_p_clk = {
1050 .b = {
1051 .ctl_reg = AHB_EN_REG,
1052 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001053 .hwcg_reg = AHB_EN2_REG,
1054 .hwcg_mask = BIT(22),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001055 .reset_reg = SW_RESET_AHB_REG,
1056 .reset_mask = BIT(9),
1057 .halt_reg = DBG_BUS_VEC_F_REG,
1058 .halt_bit = 6,
1059 },
1060 .c = {
1061 .dbg_name = "hdmi_s_p_clk",
1062 .ops = &clk_ops_branch,
1063 CLK_INIT(hdmi_s_p_clk.c),
1064 },
1065};
1066
1067static struct branch_clk ijpeg_p_clk = {
1068 .b = {
1069 .ctl_reg = AHB_EN_REG,
1070 .en_mask = BIT(5),
1071 .reset_reg = SW_RESET_AHB_REG,
1072 .reset_mask = BIT(7),
1073 .halt_reg = DBG_BUS_VEC_F_REG,
1074 .halt_bit = 9,
1075 },
1076 .c = {
1077 .dbg_name = "ijpeg_p_clk",
1078 .ops = &clk_ops_branch,
1079 CLK_INIT(ijpeg_p_clk.c),
1080 },
1081};
1082
1083static struct branch_clk imem_p_clk = {
1084 .b = {
1085 .ctl_reg = AHB_EN_REG,
1086 .en_mask = BIT(6),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001087 .hwcg_reg = AHB_EN2_REG,
1088 .hwcg_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001089 .reset_reg = SW_RESET_AHB_REG,
1090 .reset_mask = BIT(8),
1091 .halt_reg = DBG_BUS_VEC_F_REG,
1092 .halt_bit = 10,
1093 },
1094 .c = {
1095 .dbg_name = "imem_p_clk",
1096 .ops = &clk_ops_branch,
1097 CLK_INIT(imem_p_clk.c),
1098 },
1099};
1100
1101static struct branch_clk jpegd_p_clk = {
1102 .b = {
1103 .ctl_reg = AHB_EN_REG,
1104 .en_mask = BIT(21),
1105 .reset_reg = SW_RESET_AHB_REG,
1106 .reset_mask = BIT(4),
1107 .halt_reg = DBG_BUS_VEC_F_REG,
1108 .halt_bit = 7,
1109 },
1110 .c = {
1111 .dbg_name = "jpegd_p_clk",
1112 .ops = &clk_ops_branch,
1113 CLK_INIT(jpegd_p_clk.c),
1114 },
1115};
1116
1117static struct branch_clk mdp_p_clk = {
1118 .b = {
1119 .ctl_reg = AHB_EN_REG,
1120 .en_mask = BIT(10),
1121 .reset_reg = SW_RESET_AHB_REG,
1122 .reset_mask = BIT(3),
1123 .halt_reg = DBG_BUS_VEC_F_REG,
1124 .halt_bit = 11,
1125 },
1126 .c = {
1127 .dbg_name = "mdp_p_clk",
1128 .ops = &clk_ops_branch,
1129 CLK_INIT(mdp_p_clk.c),
1130 },
1131};
1132
1133static struct branch_clk rot_p_clk = {
1134 .b = {
1135 .ctl_reg = AHB_EN_REG,
1136 .en_mask = BIT(12),
1137 .reset_reg = SW_RESET_AHB_REG,
1138 .reset_mask = BIT(2),
1139 .halt_reg = DBG_BUS_VEC_F_REG,
1140 .halt_bit = 13,
1141 },
1142 .c = {
1143 .dbg_name = "rot_p_clk",
1144 .ops = &clk_ops_branch,
1145 CLK_INIT(rot_p_clk.c),
1146 },
1147};
1148
1149static struct branch_clk smmu_p_clk = {
1150 .b = {
1151 .ctl_reg = AHB_EN_REG,
1152 .en_mask = BIT(15),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001153 .hwcg_reg = AHB_EN_REG,
1154 .hwcg_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001155 .halt_reg = DBG_BUS_VEC_F_REG,
1156 .halt_bit = 22,
1157 },
1158 .c = {
1159 .dbg_name = "smmu_p_clk",
1160 .ops = &clk_ops_branch,
1161 CLK_INIT(smmu_p_clk.c),
1162 },
1163};
1164
1165static struct branch_clk tv_enc_p_clk = {
1166 .b = {
1167 .ctl_reg = AHB_EN_REG,
1168 .en_mask = BIT(25),
1169 .reset_reg = SW_RESET_AHB_REG,
1170 .reset_mask = BIT(15),
1171 .halt_reg = DBG_BUS_VEC_F_REG,
1172 .halt_bit = 23,
1173 },
1174 .c = {
1175 .dbg_name = "tv_enc_p_clk",
1176 .ops = &clk_ops_branch,
1177 CLK_INIT(tv_enc_p_clk.c),
1178 },
1179};
1180
1181static struct branch_clk vcodec_p_clk = {
1182 .b = {
1183 .ctl_reg = AHB_EN_REG,
1184 .en_mask = BIT(11),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001185 .hwcg_reg = AHB_EN2_REG,
1186 .hwcg_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001187 .reset_reg = SW_RESET_AHB_REG,
1188 .reset_mask = BIT(1),
1189 .halt_reg = DBG_BUS_VEC_F_REG,
1190 .halt_bit = 12,
1191 },
1192 .c = {
1193 .dbg_name = "vcodec_p_clk",
1194 .ops = &clk_ops_branch,
1195 CLK_INIT(vcodec_p_clk.c),
1196 },
1197};
1198
1199static struct branch_clk vfe_p_clk = {
1200 .b = {
1201 .ctl_reg = AHB_EN_REG,
1202 .en_mask = BIT(13),
1203 .reset_reg = SW_RESET_AHB_REG,
1204 .reset_mask = BIT(0),
1205 .halt_reg = DBG_BUS_VEC_F_REG,
1206 .halt_bit = 14,
1207 },
1208 .c = {
1209 .dbg_name = "vfe_p_clk",
1210 .ops = &clk_ops_branch,
1211 CLK_INIT(vfe_p_clk.c),
1212 },
1213};
1214
1215static struct branch_clk vpe_p_clk = {
1216 .b = {
1217 .ctl_reg = AHB_EN_REG,
1218 .en_mask = BIT(16),
1219 .reset_reg = SW_RESET_AHB_REG,
1220 .reset_mask = BIT(14),
1221 .halt_reg = DBG_BUS_VEC_F_REG,
1222 .halt_bit = 15,
1223 },
1224 .c = {
1225 .dbg_name = "vpe_p_clk",
1226 .ops = &clk_ops_branch,
1227 CLK_INIT(vpe_p_clk.c),
1228 },
1229};
1230
Tianyi Gou41515e22011-09-01 19:37:43 -07001231static struct branch_clk vcap_p_clk = {
1232 .b = {
1233 .ctl_reg = AHB_EN3_REG,
1234 .en_mask = BIT(1),
1235 .reset_reg = SW_RESET_AHB2_REG,
1236 .reset_mask = BIT(2),
1237 .halt_reg = DBG_BUS_VEC_J_REG,
1238 .halt_bit = 23,
1239 },
1240 .c = {
1241 .dbg_name = "vcap_p_clk",
1242 .ops = &clk_ops_branch,
1243 CLK_INIT(vcap_p_clk.c),
1244 },
1245};
1246
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001247/*
1248 * Peripheral Clocks
1249 */
Matt Wagantall7625a4c2011-11-01 16:17:53 -07001250#define CLK_GP(i, n, h_r, h_b) \
1251 struct rcg_clk i##_clk = { \
1252 .b = { \
1253 .ctl_reg = GPn_NS_REG(n), \
1254 .en_mask = BIT(9), \
1255 .halt_reg = h_r, \
1256 .halt_bit = h_b, \
1257 }, \
1258 .ns_reg = GPn_NS_REG(n), \
1259 .md_reg = GPn_MD_REG(n), \
1260 .root_en_mask = BIT(11), \
1261 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1262 .set_rate = set_rate_mnd, \
1263 .freq_tbl = clk_tbl_gp, \
1264 .current_freq = &rcg_dummy_freq, \
1265 .c = { \
1266 .dbg_name = #i "_clk", \
1267 .ops = &clk_ops_rcg_8960, \
1268 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000), \
1269 CLK_INIT(i##_clk.c), \
1270 }, \
1271 }
1272#define F_GP(f, s, d, m, n) \
1273 { \
1274 .freq_hz = f, \
1275 .src_clk = &s##_clk.c, \
1276 .md_val = MD8(16, m, 0, n), \
1277 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1278 .mnd_en_mask = BIT(8) * !!(n), \
1279 }
1280static struct clk_freq_tbl clk_tbl_gp[] = {
1281 F_GP( 0, gnd, 1, 0, 0),
1282 F_GP( 9600000, cxo, 2, 0, 0),
1283 F_GP( 13500000, pxo, 2, 0, 0),
1284 F_GP( 19200000, cxo, 1, 0, 0),
1285 F_GP( 27000000, pxo, 1, 0, 0),
1286 F_GP( 64000000, pll8, 2, 1, 3),
1287 F_GP( 76800000, pll8, 1, 1, 5),
1288 F_GP( 96000000, pll8, 4, 0, 0),
1289 F_GP(128000000, pll8, 3, 0, 0),
1290 F_GP(192000000, pll8, 2, 0, 0),
1291 F_GP(384000000, pll8, 1, 0, 0),
1292 F_END
1293};
1294
1295static CLK_GP(gp0, 0, CLK_HALT_SFPB_MISC_STATE_REG, 7);
1296static CLK_GP(gp1, 1, CLK_HALT_SFPB_MISC_STATE_REG, 6);
1297static CLK_GP(gp2, 2, CLK_HALT_SFPB_MISC_STATE_REG, 5);
1298
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001299#define CLK_GSBI_UART(i, n, h_r, h_b) \
1300 struct rcg_clk i##_clk = { \
1301 .b = { \
1302 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
1303 .en_mask = BIT(9), \
1304 .reset_reg = GSBIn_RESET_REG(n), \
1305 .reset_mask = BIT(0), \
1306 .halt_reg = h_r, \
1307 .halt_bit = h_b, \
1308 }, \
1309 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
1310 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
1311 .root_en_mask = BIT(11), \
1312 .ns_mask = (BM(31, 16) | BM(6, 0)), \
1313 .set_rate = set_rate_mnd, \
1314 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001315 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001316 .c = { \
1317 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001318 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001319 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001320 CLK_INIT(i##_clk.c), \
1321 }, \
1322 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001323#define F_GSBI_UART(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001324 { \
1325 .freq_hz = f, \
1326 .src_clk = &s##_clk.c, \
1327 .md_val = MD16(m, n), \
1328 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1329 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001330 }
1331static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001332 F_GSBI_UART( 0, gnd, 1, 0, 0),
1333 F_GSBI_UART( 1843200, pll8, 1, 3, 625),
1334 F_GSBI_UART( 3686400, pll8, 1, 6, 625),
1335 F_GSBI_UART( 7372800, pll8, 1, 12, 625),
1336 F_GSBI_UART(14745600, pll8, 1, 24, 625),
1337 F_GSBI_UART(16000000, pll8, 4, 1, 6),
1338 F_GSBI_UART(24000000, pll8, 4, 1, 4),
1339 F_GSBI_UART(32000000, pll8, 4, 1, 3),
1340 F_GSBI_UART(40000000, pll8, 1, 5, 48),
1341 F_GSBI_UART(46400000, pll8, 1, 29, 240),
1342 F_GSBI_UART(48000000, pll8, 4, 1, 2),
1343 F_GSBI_UART(51200000, pll8, 1, 2, 15),
1344 F_GSBI_UART(56000000, pll8, 1, 7, 48),
1345 F_GSBI_UART(58982400, pll8, 1, 96, 625),
1346 F_GSBI_UART(64000000, pll8, 2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001347 F_END
1348};
1349
1350static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1351static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1352static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1353static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1354static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1355static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1356static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1357static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1358static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1359static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1360static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1361static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1362
1363#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1364 struct rcg_clk i##_clk = { \
1365 .b = { \
1366 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1367 .en_mask = BIT(9), \
1368 .reset_reg = GSBIn_RESET_REG(n), \
1369 .reset_mask = BIT(0), \
1370 .halt_reg = h_r, \
1371 .halt_bit = h_b, \
1372 }, \
1373 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1374 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1375 .root_en_mask = BIT(11), \
1376 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1377 .set_rate = set_rate_mnd, \
1378 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001379 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001380 .c = { \
1381 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001382 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001383 VDD_DIG_FMAX_MAP2(LOW, 24000000, NOMINAL, 52000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001384 CLK_INIT(i##_clk.c), \
1385 }, \
1386 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001387#define F_GSBI_QUP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001388 { \
1389 .freq_hz = f, \
1390 .src_clk = &s##_clk.c, \
1391 .md_val = MD8(16, m, 0, n), \
1392 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1393 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001394 }
1395static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001396 F_GSBI_QUP( 0, gnd, 1, 0, 0),
1397 F_GSBI_QUP( 1100000, pxo, 1, 2, 49),
1398 F_GSBI_QUP( 5400000, pxo, 1, 1, 5),
1399 F_GSBI_QUP(10800000, pxo, 1, 2, 5),
1400 F_GSBI_QUP(15060000, pll8, 1, 2, 51),
1401 F_GSBI_QUP(24000000, pll8, 4, 1, 4),
1402 F_GSBI_QUP(25600000, pll8, 1, 1, 15),
1403 F_GSBI_QUP(27000000, pxo, 1, 0, 0),
1404 F_GSBI_QUP(48000000, pll8, 4, 1, 2),
1405 F_GSBI_QUP(51200000, pll8, 1, 2, 15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001406 F_END
1407};
1408
1409static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1410static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1411static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1412static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1413static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1414static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1415static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1416static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1417static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1418static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1419static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1420static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1421
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001422#define F_PDM(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001423 { \
1424 .freq_hz = f, \
1425 .src_clk = &s##_clk.c, \
1426 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001427 }
1428static struct clk_freq_tbl clk_tbl_pdm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001429 F_PDM( 0, gnd, 1),
1430 F_PDM(27000000, pxo, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001431 F_END
1432};
1433
1434static struct rcg_clk pdm_clk = {
1435 .b = {
1436 .ctl_reg = PDM_CLK_NS_REG,
1437 .en_mask = BIT(9),
1438 .reset_reg = PDM_CLK_NS_REG,
1439 .reset_mask = BIT(12),
1440 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1441 .halt_bit = 3,
1442 },
1443 .ns_reg = PDM_CLK_NS_REG,
1444 .root_en_mask = BIT(11),
1445 .ns_mask = BM(1, 0),
1446 .set_rate = set_rate_nop,
1447 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001448 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001449 .c = {
1450 .dbg_name = "pdm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001451 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001452 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001453 CLK_INIT(pdm_clk.c),
1454 },
1455};
1456
1457static struct branch_clk pmem_clk = {
1458 .b = {
1459 .ctl_reg = PMEM_ACLK_CTL_REG,
1460 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001461 .hwcg_reg = PMEM_ACLK_CTL_REG,
1462 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001463 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1464 .halt_bit = 20,
1465 },
1466 .c = {
1467 .dbg_name = "pmem_clk",
1468 .ops = &clk_ops_branch,
1469 CLK_INIT(pmem_clk.c),
1470 },
1471};
1472
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001473#define F_PRNG(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001474 { \
1475 .freq_hz = f, \
1476 .src_clk = &s##_clk.c, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001477 }
1478static struct clk_freq_tbl clk_tbl_prng[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001479 F_PRNG(64000000, pll8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001480 F_END
1481};
1482
1483static struct rcg_clk prng_clk = {
1484 .b = {
1485 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1486 .en_mask = BIT(10),
1487 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1488 .halt_check = HALT_VOTED,
1489 .halt_bit = 10,
1490 },
1491 .set_rate = set_rate_nop,
1492 .freq_tbl = clk_tbl_prng,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001493 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001494 .c = {
1495 .dbg_name = "prng_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001496 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001497 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 65000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001498 CLK_INIT(prng_clk.c),
1499 },
1500};
1501
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001502#define CLK_SDC(name, n, h_b, fmax_low, fmax_nom) \
Stephen Boyda78a7402011-08-02 11:23:39 -07001503 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001504 .b = { \
1505 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1506 .en_mask = BIT(9), \
1507 .reset_reg = SDCn_RESET_REG(n), \
1508 .reset_mask = BIT(0), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001509 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001510 .halt_bit = h_b, \
1511 }, \
1512 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1513 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1514 .root_en_mask = BIT(11), \
1515 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1516 .set_rate = set_rate_mnd, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001517 .freq_tbl = clk_tbl_sdc, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001518 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001519 .c = { \
Stephen Boyda78a7402011-08-02 11:23:39 -07001520 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001521 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001522 VDD_DIG_FMAX_MAP2(LOW, fmax_low, NOMINAL, fmax_nom), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001523 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001524 }, \
1525 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001526#define F_SDC(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001527 { \
1528 .freq_hz = f, \
1529 .src_clk = &s##_clk.c, \
1530 .md_val = MD8(16, m, 0, n), \
1531 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1532 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001533 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001534static struct clk_freq_tbl clk_tbl_sdc[] = {
1535 F_SDC( 0, gnd, 1, 0, 0),
1536 F_SDC( 144000, pxo, 3, 2, 125),
1537 F_SDC( 400000, pll8, 4, 1, 240),
1538 F_SDC( 16000000, pll8, 4, 1, 6),
1539 F_SDC( 17070000, pll8, 1, 2, 45),
1540 F_SDC( 20210000, pll8, 1, 1, 19),
1541 F_SDC( 24000000, pll8, 4, 1, 4),
1542 F_SDC( 48000000, pll8, 4, 1, 2),
1543 F_SDC( 64000000, pll8, 3, 1, 2),
1544 F_SDC( 96000000, pll8, 4, 0, 0),
Subhash Jadavanibd238ba2011-11-24 15:12:39 +05301545 F_SDC(192000000, pll8, 2, 0, 0),
Stephen Boyda78a7402011-08-02 11:23:39 -07001546 F_END
1547};
1548
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001549static CLK_SDC(sdc1_clk, 1, 6, 52000000, 104000000);
1550static CLK_SDC(sdc2_clk, 2, 5, 52000000, 104000000);
1551static CLK_SDC(sdc3_clk, 3, 4, 104000000, 208000000);
1552static CLK_SDC(sdc4_clk, 4, 3, 33000000, 67000000);
1553static CLK_SDC(sdc5_clk, 5, 2, 33000000, 67000000);
Stephen Boyda78a7402011-08-02 11:23:39 -07001554
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001555#define F_TSIF_REF(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001556 { \
1557 .freq_hz = f, \
1558 .src_clk = &s##_clk.c, \
1559 .md_val = MD16(m, n), \
1560 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1561 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001562 }
1563static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001564 F_TSIF_REF( 0, gnd, 1, 0, 0),
1565 F_TSIF_REF(105000, pxo, 1, 1, 256),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001566 F_END
1567};
1568
1569static struct rcg_clk tsif_ref_clk = {
1570 .b = {
1571 .ctl_reg = TSIF_REF_CLK_NS_REG,
1572 .en_mask = BIT(9),
1573 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1574 .halt_bit = 5,
1575 },
1576 .ns_reg = TSIF_REF_CLK_NS_REG,
1577 .md_reg = TSIF_REF_CLK_MD_REG,
1578 .root_en_mask = BIT(11),
1579 .ns_mask = (BM(31, 16) | BM(6, 0)),
1580 .set_rate = set_rate_mnd,
1581 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001582 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001583 .c = {
1584 .dbg_name = "tsif_ref_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001585 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001586 VDD_DIG_FMAX_MAP2(LOW, 27000000, NOMINAL, 54000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001587 CLK_INIT(tsif_ref_clk.c),
1588 },
1589};
1590
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001591#define F_TSSC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001592 { \
1593 .freq_hz = f, \
1594 .src_clk = &s##_clk.c, \
1595 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001596 }
1597static struct clk_freq_tbl clk_tbl_tssc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001598 F_TSSC( 0, gnd),
1599 F_TSSC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001600 F_END
1601};
1602
1603static struct rcg_clk tssc_clk = {
1604 .b = {
1605 .ctl_reg = TSSC_CLK_CTL_REG,
1606 .en_mask = BIT(4),
1607 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1608 .halt_bit = 4,
1609 },
1610 .ns_reg = TSSC_CLK_CTL_REG,
1611 .ns_mask = BM(1, 0),
1612 .set_rate = set_rate_nop,
1613 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001614 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001615 .c = {
1616 .dbg_name = "tssc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001617 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001618 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001619 CLK_INIT(tssc_clk.c),
1620 },
1621};
1622
Tianyi Gou41515e22011-09-01 19:37:43 -07001623#define CLK_USB_HS(name, n, h_b) \
1624 static struct rcg_clk name = { \
1625 .b = { \
1626 .ctl_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1627 .en_mask = BIT(9), \
1628 .reset_reg = USB_HS##n##_RESET_REG, \
1629 .reset_mask = BIT(0), \
1630 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
1631 .halt_bit = h_b, \
1632 }, \
1633 .ns_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1634 .md_reg = USB_HS##n##_XCVR_FS_CLK_MD_REG, \
1635 .root_en_mask = BIT(11), \
1636 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1637 .set_rate = set_rate_mnd, \
1638 .freq_tbl = clk_tbl_usb, \
1639 .current_freq = &rcg_dummy_freq, \
1640 .c = { \
1641 .dbg_name = #name, \
1642 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001643 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001644 CLK_INIT(name.c), \
1645 }, \
1646}
1647
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001648#define F_USB(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001649 { \
1650 .freq_hz = f, \
1651 .src_clk = &s##_clk.c, \
1652 .md_val = MD8(16, m, 0, n), \
1653 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1654 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001655 }
1656static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001657 F_USB( 0, gnd, 1, 0, 0),
1658 F_USB(60000000, pll8, 1, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001659 F_END
1660};
1661
Tianyi Gou41515e22011-09-01 19:37:43 -07001662CLK_USB_HS(usb_hs1_xcvr_clk, 1, 0);
1663CLK_USB_HS(usb_hs3_xcvr_clk, 3, 30);
1664CLK_USB_HS(usb_hs4_xcvr_clk, 4, 2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001665
Stephen Boyd94625ef2011-07-12 17:06:01 -07001666static struct clk_freq_tbl clk_tbl_usb_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001667 F_USB( 0, gnd, 1, 0, 0),
1668 F_USB(60000000, pll8, 1, 5, 32),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001669 F_END
1670};
1671
1672static struct rcg_clk usb_hsic_xcvr_fs_clk = {
1673 .b = {
1674 .ctl_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1675 .en_mask = BIT(9),
1676 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1677 .halt_bit = 26,
1678 },
1679 .ns_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1680 .md_reg = USB_HSIC_XCVR_FS_CLK_MD_REG,
1681 .root_en_mask = BIT(11),
1682 .ns_mask = (BM(23, 16) | BM(6, 0)),
1683 .set_rate = set_rate_mnd,
1684 .freq_tbl = clk_tbl_usb_hsic,
1685 .current_freq = &rcg_dummy_freq,
1686 .c = {
1687 .dbg_name = "usb_hsic_xcvr_fs_clk",
1688 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001689 VDD_DIG_FMAX_MAP1(LOW, 60000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001690 CLK_INIT(usb_hsic_xcvr_fs_clk.c),
1691 },
1692};
1693
1694static struct branch_clk usb_hsic_system_clk = {
1695 .b = {
1696 .ctl_reg = USB_HSIC_SYSTEM_CLK_CTL_REG,
1697 .en_mask = BIT(4),
1698 .reset_reg = USB_HSIC_RESET_REG,
1699 .reset_mask = BIT(0),
1700 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1701 .halt_bit = 24,
1702 },
1703 .parent = &usb_hsic_xcvr_fs_clk.c,
1704 .c = {
1705 .dbg_name = "usb_hsic_system_clk",
1706 .ops = &clk_ops_branch,
1707 CLK_INIT(usb_hsic_system_clk.c),
1708 },
1709};
1710
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001711#define F_USB_HSIC(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001712 { \
1713 .freq_hz = f, \
1714 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001715 }
1716static struct clk_freq_tbl clk_tbl_usb2_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001717 F_USB_HSIC(480000000, pll14),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001718 F_END
1719};
1720
1721static struct rcg_clk usb_hsic_hsic_src_clk = {
1722 .b = {
1723 .ctl_reg = USB_HSIC_HSIC_CLK_SRC_CTL_REG,
1724 .halt_check = NOCHECK,
1725 },
1726 .root_en_mask = BIT(0),
1727 .set_rate = set_rate_nop,
1728 .freq_tbl = clk_tbl_usb2_hsic,
1729 .current_freq = &rcg_dummy_freq,
1730 .c = {
1731 .dbg_name = "usb_hsic_hsic_src_clk",
1732 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001733 VDD_DIG_FMAX_MAP1(LOW, 480000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001734 CLK_INIT(usb_hsic_hsic_src_clk.c),
1735 },
1736};
1737
1738static struct branch_clk usb_hsic_hsic_clk = {
1739 .b = {
1740 .ctl_reg = USB_HSIC_HSIC_CLK_CTL_REG,
1741 .en_mask = BIT(0),
1742 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1743 .halt_bit = 19,
1744 },
1745 .parent = &usb_hsic_hsic_src_clk.c,
1746 .c = {
1747 .dbg_name = "usb_hsic_hsic_clk",
1748 .ops = &clk_ops_branch,
1749 CLK_INIT(usb_hsic_hsic_clk.c),
1750 },
1751};
1752
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001753#define F_USB_HSIO_CAL(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001754 { \
1755 .freq_hz = f, \
1756 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001757 }
1758static struct clk_freq_tbl clk_tbl_usb_hsio_cal[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001759 F_USB_HSIO_CAL(9000000, pxo),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001760 F_END
1761};
1762
1763static struct rcg_clk usb_hsic_hsio_cal_clk = {
1764 .b = {
1765 .ctl_reg = USB_HSIC_HSIO_CAL_CLK_CTL_REG,
1766 .en_mask = BIT(0),
1767 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1768 .halt_bit = 23,
1769 },
1770 .set_rate = set_rate_nop,
1771 .freq_tbl = clk_tbl_usb_hsio_cal,
1772 .current_freq = &rcg_dummy_freq,
1773 .c = {
1774 .dbg_name = "usb_hsic_hsio_cal_clk",
Stephen Boyda0e82ec2011-09-19 12:18:45 -07001775 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001776 VDD_DIG_FMAX_MAP1(LOW, 10000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001777 CLK_INIT(usb_hsic_hsio_cal_clk.c),
1778 },
1779};
1780
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001781static struct branch_clk usb_phy0_clk = {
1782 .b = {
1783 .reset_reg = USB_PHY0_RESET_REG,
1784 .reset_mask = BIT(0),
1785 },
1786 .c = {
1787 .dbg_name = "usb_phy0_clk",
1788 .ops = &clk_ops_reset,
1789 CLK_INIT(usb_phy0_clk.c),
1790 },
1791};
1792
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001793#define CLK_USB_FS(i, n, fmax_nom) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001794 struct rcg_clk i##_clk = { \
1795 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1796 .b = { \
1797 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1798 .halt_check = NOCHECK, \
1799 }, \
1800 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
1801 .root_en_mask = BIT(11), \
1802 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1803 .set_rate = set_rate_mnd, \
1804 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001805 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001806 .c = { \
1807 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001808 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001809 VDD_DIG_FMAX_MAP1(NOMINAL, fmax_nom), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001810 CLK_INIT(i##_clk.c), \
1811 }, \
1812 }
1813
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001814static CLK_USB_FS(usb_fs1_src, 1, 64000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001815static struct branch_clk usb_fs1_xcvr_clk = {
1816 .b = {
1817 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
1818 .en_mask = BIT(9),
1819 .reset_reg = USB_FSn_RESET_REG(1),
1820 .reset_mask = BIT(1),
1821 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1822 .halt_bit = 15,
1823 },
1824 .parent = &usb_fs1_src_clk.c,
1825 .c = {
1826 .dbg_name = "usb_fs1_xcvr_clk",
1827 .ops = &clk_ops_branch,
1828 CLK_INIT(usb_fs1_xcvr_clk.c),
1829 },
1830};
1831
1832static struct branch_clk usb_fs1_sys_clk = {
1833 .b = {
1834 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
1835 .en_mask = BIT(4),
1836 .reset_reg = USB_FSn_RESET_REG(1),
1837 .reset_mask = BIT(0),
1838 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1839 .halt_bit = 16,
1840 },
1841 .parent = &usb_fs1_src_clk.c,
1842 .c = {
1843 .dbg_name = "usb_fs1_sys_clk",
1844 .ops = &clk_ops_branch,
1845 CLK_INIT(usb_fs1_sys_clk.c),
1846 },
1847};
1848
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001849static CLK_USB_FS(usb_fs2_src, 2, 60000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001850static struct branch_clk usb_fs2_xcvr_clk = {
1851 .b = {
1852 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
1853 .en_mask = BIT(9),
1854 .reset_reg = USB_FSn_RESET_REG(2),
1855 .reset_mask = BIT(1),
1856 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1857 .halt_bit = 12,
1858 },
1859 .parent = &usb_fs2_src_clk.c,
1860 .c = {
1861 .dbg_name = "usb_fs2_xcvr_clk",
1862 .ops = &clk_ops_branch,
1863 CLK_INIT(usb_fs2_xcvr_clk.c),
1864 },
1865};
1866
1867static struct branch_clk usb_fs2_sys_clk = {
1868 .b = {
1869 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
1870 .en_mask = BIT(4),
1871 .reset_reg = USB_FSn_RESET_REG(2),
1872 .reset_mask = BIT(0),
1873 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1874 .halt_bit = 13,
1875 },
1876 .parent = &usb_fs2_src_clk.c,
1877 .c = {
1878 .dbg_name = "usb_fs2_sys_clk",
1879 .ops = &clk_ops_branch,
1880 CLK_INIT(usb_fs2_sys_clk.c),
1881 },
1882};
1883
1884/* Fast Peripheral Bus Clocks */
1885static struct branch_clk ce1_core_clk = {
1886 .b = {
1887 .ctl_reg = CE1_CORE_CLK_CTL_REG,
1888 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001889 .hwcg_reg = CE1_CORE_CLK_CTL_REG,
1890 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001891 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1892 .halt_bit = 27,
1893 },
1894 .c = {
1895 .dbg_name = "ce1_core_clk",
1896 .ops = &clk_ops_branch,
1897 CLK_INIT(ce1_core_clk.c),
1898 },
1899};
Tianyi Gou41515e22011-09-01 19:37:43 -07001900
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001901static struct branch_clk ce1_p_clk = {
1902 .b = {
1903 .ctl_reg = CE1_HCLK_CTL_REG,
1904 .en_mask = BIT(4),
1905 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1906 .halt_bit = 1,
1907 },
1908 .c = {
1909 .dbg_name = "ce1_p_clk",
1910 .ops = &clk_ops_branch,
1911 CLK_INIT(ce1_p_clk.c),
1912 },
1913};
1914
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001915#define F_CE3(f, s, d) \
Tianyi Gou41515e22011-09-01 19:37:43 -07001916 { \
1917 .freq_hz = f, \
1918 .src_clk = &s##_clk.c, \
1919 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001920 }
1921
1922static struct clk_freq_tbl clk_tbl_ce3[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001923 F_CE3( 0, gnd, 1),
1924 F_CE3( 48000000, pll8, 8),
1925 F_CE3(100000000, pll3, 12),
Tianyi Gou41515e22011-09-01 19:37:43 -07001926 F_END
1927};
1928
1929static struct rcg_clk ce3_src_clk = {
1930 .b = {
1931 .ctl_reg = CE3_CLK_SRC_NS_REG,
1932 .halt_check = NOCHECK,
1933 },
1934 .ns_reg = CE3_CLK_SRC_NS_REG,
1935 .root_en_mask = BIT(7),
1936 .ns_mask = BM(6, 0),
1937 .set_rate = set_rate_nop,
1938 .freq_tbl = clk_tbl_ce3,
1939 .current_freq = &rcg_dummy_freq,
1940 .c = {
1941 .dbg_name = "ce3_src_clk",
1942 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001943 VDD_DIG_FMAX_MAP2(LOW, 50000000, NOMINAL, 100000000),
Tianyi Gou41515e22011-09-01 19:37:43 -07001944 CLK_INIT(ce3_src_clk.c),
1945 },
1946};
1947
1948static struct branch_clk ce3_core_clk = {
1949 .b = {
1950 .ctl_reg = CE3_CORE_CLK_CTL_REG,
1951 .en_mask = BIT(4),
1952 .reset_reg = CE3_CORE_CLK_CTL_REG,
1953 .reset_mask = BIT(7),
1954 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1955 .halt_bit = 5,
1956 },
1957 .parent = &ce3_src_clk.c,
1958 .c = {
1959 .dbg_name = "ce3_core_clk",
1960 .ops = &clk_ops_branch,
1961 CLK_INIT(ce3_core_clk.c),
1962 }
1963};
1964
1965static struct branch_clk ce3_p_clk = {
1966 .b = {
1967 .ctl_reg = CE3_HCLK_CTL_REG,
1968 .en_mask = BIT(4),
1969 .reset_reg = CE3_HCLK_CTL_REG,
1970 .reset_mask = BIT(7),
1971 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
1972 .halt_bit = 16,
1973 },
1974 .parent = &ce3_src_clk.c,
1975 .c = {
1976 .dbg_name = "ce3_p_clk",
1977 .ops = &clk_ops_branch,
1978 CLK_INIT(ce3_p_clk.c),
1979 }
1980};
1981
1982static struct branch_clk sata_phy_ref_clk = {
1983 .b = {
1984 .ctl_reg = SATA_PHY_REF_CLK_CTL_REG,
1985 .en_mask = BIT(4),
1986 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1987 .halt_bit = 24,
1988 },
1989 .parent = &pxo_clk.c,
1990 .c = {
1991 .dbg_name = "sata_phy_ref_clk",
1992 .ops = &clk_ops_branch,
1993 CLK_INIT(sata_phy_ref_clk.c),
1994 },
1995};
1996
1997static struct branch_clk pcie_p_clk = {
1998 .b = {
1999 .ctl_reg = PCIE_HCLK_CTL_REG,
2000 .en_mask = BIT(4),
2001 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2002 .halt_bit = 8,
2003 },
2004 .c = {
2005 .dbg_name = "pcie_p_clk",
2006 .ops = &clk_ops_branch,
2007 CLK_INIT(pcie_p_clk.c),
2008 },
2009};
2010
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002011static struct branch_clk dma_bam_p_clk = {
2012 .b = {
2013 .ctl_reg = DMA_BAM_HCLK_CTL,
2014 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002015 .hwcg_reg = DMA_BAM_HCLK_CTL,
2016 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002017 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2018 .halt_bit = 12,
2019 },
2020 .c = {
2021 .dbg_name = "dma_bam_p_clk",
2022 .ops = &clk_ops_branch,
2023 CLK_INIT(dma_bam_p_clk.c),
2024 },
2025};
2026
2027static struct branch_clk gsbi1_p_clk = {
2028 .b = {
2029 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
2030 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002031 .hwcg_reg = GSBIn_HCLK_CTL_REG(1),
2032 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002033 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2034 .halt_bit = 11,
2035 },
2036 .c = {
2037 .dbg_name = "gsbi1_p_clk",
2038 .ops = &clk_ops_branch,
2039 CLK_INIT(gsbi1_p_clk.c),
2040 },
2041};
2042
2043static struct branch_clk gsbi2_p_clk = {
2044 .b = {
2045 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
2046 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002047 .hwcg_reg = GSBIn_HCLK_CTL_REG(2),
2048 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002049 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2050 .halt_bit = 7,
2051 },
2052 .c = {
2053 .dbg_name = "gsbi2_p_clk",
2054 .ops = &clk_ops_branch,
2055 CLK_INIT(gsbi2_p_clk.c),
2056 },
2057};
2058
2059static struct branch_clk gsbi3_p_clk = {
2060 .b = {
2061 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
2062 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002063 .hwcg_reg = GSBIn_HCLK_CTL_REG(3),
2064 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002065 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2066 .halt_bit = 3,
2067 },
2068 .c = {
2069 .dbg_name = "gsbi3_p_clk",
2070 .ops = &clk_ops_branch,
2071 CLK_INIT(gsbi3_p_clk.c),
2072 },
2073};
2074
2075static struct branch_clk gsbi4_p_clk = {
2076 .b = {
2077 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
2078 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002079 .hwcg_reg = GSBIn_HCLK_CTL_REG(4),
2080 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002081 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2082 .halt_bit = 27,
2083 },
2084 .c = {
2085 .dbg_name = "gsbi4_p_clk",
2086 .ops = &clk_ops_branch,
2087 CLK_INIT(gsbi4_p_clk.c),
2088 },
2089};
2090
2091static struct branch_clk gsbi5_p_clk = {
2092 .b = {
2093 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
2094 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002095 .hwcg_reg = GSBIn_HCLK_CTL_REG(5),
2096 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002097 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2098 .halt_bit = 23,
2099 },
2100 .c = {
2101 .dbg_name = "gsbi5_p_clk",
2102 .ops = &clk_ops_branch,
2103 CLK_INIT(gsbi5_p_clk.c),
2104 },
2105};
2106
2107static struct branch_clk gsbi6_p_clk = {
2108 .b = {
2109 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
2110 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002111 .hwcg_reg = GSBIn_HCLK_CTL_REG(6),
2112 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002113 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2114 .halt_bit = 19,
2115 },
2116 .c = {
2117 .dbg_name = "gsbi6_p_clk",
2118 .ops = &clk_ops_branch,
2119 CLK_INIT(gsbi6_p_clk.c),
2120 },
2121};
2122
2123static struct branch_clk gsbi7_p_clk = {
2124 .b = {
2125 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
2126 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002127 .hwcg_reg = GSBIn_HCLK_CTL_REG(7),
2128 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002129 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2130 .halt_bit = 15,
2131 },
2132 .c = {
2133 .dbg_name = "gsbi7_p_clk",
2134 .ops = &clk_ops_branch,
2135 CLK_INIT(gsbi7_p_clk.c),
2136 },
2137};
2138
2139static struct branch_clk gsbi8_p_clk = {
2140 .b = {
2141 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
2142 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002143 .hwcg_reg = GSBIn_HCLK_CTL_REG(8),
2144 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002145 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2146 .halt_bit = 11,
2147 },
2148 .c = {
2149 .dbg_name = "gsbi8_p_clk",
2150 .ops = &clk_ops_branch,
2151 CLK_INIT(gsbi8_p_clk.c),
2152 },
2153};
2154
2155static struct branch_clk gsbi9_p_clk = {
2156 .b = {
2157 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
2158 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002159 .hwcg_reg = GSBIn_HCLK_CTL_REG(9),
2160 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002161 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2162 .halt_bit = 7,
2163 },
2164 .c = {
2165 .dbg_name = "gsbi9_p_clk",
2166 .ops = &clk_ops_branch,
2167 CLK_INIT(gsbi9_p_clk.c),
2168 },
2169};
2170
2171static struct branch_clk gsbi10_p_clk = {
2172 .b = {
2173 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
2174 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002175 .hwcg_reg = GSBIn_HCLK_CTL_REG(10),
2176 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002177 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2178 .halt_bit = 3,
2179 },
2180 .c = {
2181 .dbg_name = "gsbi10_p_clk",
2182 .ops = &clk_ops_branch,
2183 CLK_INIT(gsbi10_p_clk.c),
2184 },
2185};
2186
2187static struct branch_clk gsbi11_p_clk = {
2188 .b = {
2189 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
2190 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002191 .hwcg_reg = GSBIn_HCLK_CTL_REG(11),
2192 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002193 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2194 .halt_bit = 18,
2195 },
2196 .c = {
2197 .dbg_name = "gsbi11_p_clk",
2198 .ops = &clk_ops_branch,
2199 CLK_INIT(gsbi11_p_clk.c),
2200 },
2201};
2202
2203static struct branch_clk gsbi12_p_clk = {
2204 .b = {
2205 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
2206 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002207 .hwcg_reg = GSBIn_HCLK_CTL_REG(12),
2208 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002209 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2210 .halt_bit = 14,
2211 },
2212 .c = {
2213 .dbg_name = "gsbi12_p_clk",
2214 .ops = &clk_ops_branch,
2215 CLK_INIT(gsbi12_p_clk.c),
2216 },
2217};
2218
Tianyi Gou41515e22011-09-01 19:37:43 -07002219static struct branch_clk sata_phy_cfg_clk = {
2220 .b = {
2221 .ctl_reg = SATA_PHY_CFG_CLK_CTL_REG,
2222 .en_mask = BIT(4),
2223 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2224 .halt_bit = 12,
2225 },
2226 .c = {
2227 .dbg_name = "sata_phy_cfg_clk",
2228 .ops = &clk_ops_branch,
2229 CLK_INIT(sata_phy_cfg_clk.c),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002230 },
2231};
2232
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002233static struct branch_clk tsif_p_clk = {
2234 .b = {
2235 .ctl_reg = TSIF_HCLK_CTL_REG,
2236 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002237 .hwcg_reg = TSIF_HCLK_CTL_REG,
2238 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002239 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2240 .halt_bit = 7,
2241 },
2242 .c = {
2243 .dbg_name = "tsif_p_clk",
2244 .ops = &clk_ops_branch,
2245 CLK_INIT(tsif_p_clk.c),
2246 },
2247};
2248
2249static struct branch_clk usb_fs1_p_clk = {
2250 .b = {
2251 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
2252 .en_mask = BIT(4),
2253 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2254 .halt_bit = 17,
2255 },
2256 .c = {
2257 .dbg_name = "usb_fs1_p_clk",
2258 .ops = &clk_ops_branch,
2259 CLK_INIT(usb_fs1_p_clk.c),
2260 },
2261};
2262
2263static struct branch_clk usb_fs2_p_clk = {
2264 .b = {
2265 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
2266 .en_mask = BIT(4),
2267 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2268 .halt_bit = 14,
2269 },
2270 .c = {
2271 .dbg_name = "usb_fs2_p_clk",
2272 .ops = &clk_ops_branch,
2273 CLK_INIT(usb_fs2_p_clk.c),
2274 },
2275};
2276
2277static struct branch_clk usb_hs1_p_clk = {
2278 .b = {
2279 .ctl_reg = USB_HS1_HCLK_CTL_REG,
2280 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002281 .hwcg_reg = USB_HS1_HCLK_CTL_REG,
2282 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002283 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2284 .halt_bit = 1,
2285 },
2286 .c = {
2287 .dbg_name = "usb_hs1_p_clk",
2288 .ops = &clk_ops_branch,
2289 CLK_INIT(usb_hs1_p_clk.c),
2290 },
2291};
2292
Tianyi Gou41515e22011-09-01 19:37:43 -07002293static struct branch_clk usb_hs3_p_clk = {
2294 .b = {
2295 .ctl_reg = USB_HS3_HCLK_CTL_REG,
2296 .en_mask = BIT(4),
2297 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2298 .halt_bit = 31,
2299 },
2300 .c = {
2301 .dbg_name = "usb_hs3_p_clk",
2302 .ops = &clk_ops_branch,
2303 CLK_INIT(usb_hs3_p_clk.c),
2304 },
2305};
2306
2307static struct branch_clk usb_hs4_p_clk = {
2308 .b = {
2309 .ctl_reg = USB_HS4_HCLK_CTL_REG,
2310 .en_mask = BIT(4),
2311 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2312 .halt_bit = 7,
2313 },
2314 .c = {
2315 .dbg_name = "usb_hs4_p_clk",
2316 .ops = &clk_ops_branch,
2317 CLK_INIT(usb_hs4_p_clk.c),
2318 },
2319};
2320
Stephen Boyd94625ef2011-07-12 17:06:01 -07002321static struct branch_clk usb_hsic_p_clk = {
2322 .b = {
2323 .ctl_reg = USB_HSIC_HCLK_CTL_REG,
2324 .en_mask = BIT(4),
2325 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2326 .halt_bit = 28,
2327 },
2328 .c = {
2329 .dbg_name = "usb_hsic_p_clk",
2330 .ops = &clk_ops_branch,
2331 CLK_INIT(usb_hsic_p_clk.c),
2332 },
2333};
2334
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002335static struct branch_clk sdc1_p_clk = {
2336 .b = {
2337 .ctl_reg = SDCn_HCLK_CTL_REG(1),
2338 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002339 .hwcg_reg = SDCn_HCLK_CTL_REG(1),
2340 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002341 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2342 .halt_bit = 11,
2343 },
2344 .c = {
2345 .dbg_name = "sdc1_p_clk",
2346 .ops = &clk_ops_branch,
2347 CLK_INIT(sdc1_p_clk.c),
2348 },
2349};
2350
2351static struct branch_clk sdc2_p_clk = {
2352 .b = {
2353 .ctl_reg = SDCn_HCLK_CTL_REG(2),
2354 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002355 .hwcg_reg = SDCn_HCLK_CTL_REG(2),
2356 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002357 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2358 .halt_bit = 10,
2359 },
2360 .c = {
2361 .dbg_name = "sdc2_p_clk",
2362 .ops = &clk_ops_branch,
2363 CLK_INIT(sdc2_p_clk.c),
2364 },
2365};
2366
2367static struct branch_clk sdc3_p_clk = {
2368 .b = {
2369 .ctl_reg = SDCn_HCLK_CTL_REG(3),
2370 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002371 .hwcg_reg = SDCn_HCLK_CTL_REG(3),
2372 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002373 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2374 .halt_bit = 9,
2375 },
2376 .c = {
2377 .dbg_name = "sdc3_p_clk",
2378 .ops = &clk_ops_branch,
2379 CLK_INIT(sdc3_p_clk.c),
2380 },
2381};
2382
2383static struct branch_clk sdc4_p_clk = {
2384 .b = {
2385 .ctl_reg = SDCn_HCLK_CTL_REG(4),
2386 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002387 .hwcg_reg = SDCn_HCLK_CTL_REG(4),
2388 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002389 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2390 .halt_bit = 8,
2391 },
2392 .c = {
2393 .dbg_name = "sdc4_p_clk",
2394 .ops = &clk_ops_branch,
2395 CLK_INIT(sdc4_p_clk.c),
2396 },
2397};
2398
2399static struct branch_clk sdc5_p_clk = {
2400 .b = {
2401 .ctl_reg = SDCn_HCLK_CTL_REG(5),
2402 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002403 .hwcg_reg = SDCn_HCLK_CTL_REG(5),
2404 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002405 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2406 .halt_bit = 7,
2407 },
2408 .c = {
2409 .dbg_name = "sdc5_p_clk",
2410 .ops = &clk_ops_branch,
2411 CLK_INIT(sdc5_p_clk.c),
2412 },
2413};
2414
2415/* HW-Voteable Clocks */
2416static struct branch_clk adm0_clk = {
2417 .b = {
2418 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2419 .en_mask = BIT(2),
2420 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2421 .halt_check = HALT_VOTED,
2422 .halt_bit = 14,
2423 },
2424 .c = {
2425 .dbg_name = "adm0_clk",
2426 .ops = &clk_ops_branch,
2427 CLK_INIT(adm0_clk.c),
2428 },
2429};
2430
2431static struct branch_clk adm0_p_clk = {
2432 .b = {
2433 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2434 .en_mask = BIT(3),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002435 .hwcg_reg = ADM0_PBUS_CLK_CTL_REG,
2436 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002437 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2438 .halt_check = HALT_VOTED,
2439 .halt_bit = 13,
2440 },
2441 .c = {
2442 .dbg_name = "adm0_p_clk",
2443 .ops = &clk_ops_branch,
2444 CLK_INIT(adm0_p_clk.c),
2445 },
2446};
2447
2448static struct branch_clk pmic_arb0_p_clk = {
2449 .b = {
2450 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2451 .en_mask = BIT(8),
2452 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2453 .halt_check = HALT_VOTED,
2454 .halt_bit = 22,
2455 },
2456 .c = {
2457 .dbg_name = "pmic_arb0_p_clk",
2458 .ops = &clk_ops_branch,
2459 CLK_INIT(pmic_arb0_p_clk.c),
2460 },
2461};
2462
2463static struct branch_clk pmic_arb1_p_clk = {
2464 .b = {
2465 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2466 .en_mask = BIT(9),
2467 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2468 .halt_check = HALT_VOTED,
2469 .halt_bit = 21,
2470 },
2471 .c = {
2472 .dbg_name = "pmic_arb1_p_clk",
2473 .ops = &clk_ops_branch,
2474 CLK_INIT(pmic_arb1_p_clk.c),
2475 },
2476};
2477
2478static struct branch_clk pmic_ssbi2_clk = {
2479 .b = {
2480 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2481 .en_mask = BIT(7),
2482 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2483 .halt_check = HALT_VOTED,
2484 .halt_bit = 23,
2485 },
2486 .c = {
2487 .dbg_name = "pmic_ssbi2_clk",
2488 .ops = &clk_ops_branch,
2489 CLK_INIT(pmic_ssbi2_clk.c),
2490 },
2491};
2492
2493static struct branch_clk rpm_msg_ram_p_clk = {
2494 .b = {
2495 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2496 .en_mask = BIT(6),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002497 .hwcg_reg = RPM_MSG_RAM_HCLK_CTL_REG,
2498 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002499 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2500 .halt_check = HALT_VOTED,
2501 .halt_bit = 12,
2502 },
2503 .c = {
2504 .dbg_name = "rpm_msg_ram_p_clk",
2505 .ops = &clk_ops_branch,
2506 CLK_INIT(rpm_msg_ram_p_clk.c),
2507 },
2508};
2509
2510/*
2511 * Multimedia Clocks
2512 */
2513
2514static struct branch_clk amp_clk = {
2515 .b = {
2516 .reset_reg = SW_RESET_CORE_REG,
2517 .reset_mask = BIT(20),
2518 },
2519 .c = {
2520 .dbg_name = "amp_clk",
2521 .ops = &clk_ops_reset,
2522 CLK_INIT(amp_clk.c),
2523 },
2524};
2525
Stephen Boyd94625ef2011-07-12 17:06:01 -07002526#define CLK_CAM(name, n, hb) \
2527 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002528 .b = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002529 .ctl_reg = CAMCLK##n##_CC_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002530 .en_mask = BIT(0), \
2531 .halt_reg = DBG_BUS_VEC_I_REG, \
2532 .halt_bit = hb, \
2533 }, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002534 .ns_reg = CAMCLK##n##_NS_REG, \
2535 .md_reg = CAMCLK##n##_MD_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002536 .root_en_mask = BIT(2), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002537 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0), \
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), \
2556 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002557 }
2558static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002559 F_CAM( 0, gnd, 1, 0, 0),
2560 F_CAM( 6000000, pll8, 4, 1, 16),
2561 F_CAM( 8000000, pll8, 4, 1, 12),
2562 F_CAM( 12000000, pll8, 4, 1, 8),
2563 F_CAM( 16000000, pll8, 4, 1, 6),
2564 F_CAM( 19200000, pll8, 4, 1, 5),
2565 F_CAM( 24000000, pll8, 4, 1, 4),
2566 F_CAM( 32000000, pll8, 4, 1, 3),
2567 F_CAM( 48000000, pll8, 4, 1, 2),
2568 F_CAM( 64000000, pll8, 3, 1, 2),
2569 F_CAM( 96000000, pll8, 4, 0, 0),
2570 F_CAM(128000000, pll8, 3, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002571 F_END
2572};
2573
Stephen Boyd94625ef2011-07-12 17:06:01 -07002574static CLK_CAM(cam0_clk, 0, 15);
2575static CLK_CAM(cam1_clk, 1, 16);
2576static CLK_CAM(cam2_clk, 2, 31);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002577
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002578#define F_CSI(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002579 { \
2580 .freq_hz = f, \
2581 .src_clk = &s##_clk.c, \
2582 .md_val = MD8(8, m, 0, n), \
2583 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2584 .ctl_val = CC(6, n), \
2585 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002586 }
2587static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002588 F_CSI( 0, gnd, 1, 0, 0),
Stephen Boyd092fd182011-10-21 15:56:30 -07002589 F_CSI( 27000000, pxo, 1, 0, 0),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002590 F_CSI( 85330000, pll8, 1, 2, 9),
2591 F_CSI(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002592 F_END
2593};
2594
2595static struct rcg_clk csi0_src_clk = {
2596 .ns_reg = CSI0_NS_REG,
2597 .b = {
2598 .ctl_reg = CSI0_CC_REG,
2599 .halt_check = NOCHECK,
2600 },
2601 .md_reg = CSI0_MD_REG,
2602 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002603 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002604 .ctl_mask = BM(7, 6),
2605 .set_rate = set_rate_mnd,
2606 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002607 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002608 .c = {
2609 .dbg_name = "csi0_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002610 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002611 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002612 CLK_INIT(csi0_src_clk.c),
2613 },
2614};
2615
2616static struct branch_clk csi0_clk = {
2617 .b = {
2618 .ctl_reg = CSI0_CC_REG,
2619 .en_mask = BIT(0),
2620 .reset_reg = SW_RESET_CORE_REG,
2621 .reset_mask = BIT(8),
2622 .halt_reg = DBG_BUS_VEC_B_REG,
2623 .halt_bit = 13,
2624 },
2625 .parent = &csi0_src_clk.c,
2626 .c = {
2627 .dbg_name = "csi0_clk",
2628 .ops = &clk_ops_branch,
2629 CLK_INIT(csi0_clk.c),
2630 },
2631};
2632
2633static struct branch_clk csi0_phy_clk = {
2634 .b = {
2635 .ctl_reg = CSI0_CC_REG,
2636 .en_mask = BIT(8),
2637 .reset_reg = SW_RESET_CORE_REG,
2638 .reset_mask = BIT(29),
2639 .halt_reg = DBG_BUS_VEC_I_REG,
2640 .halt_bit = 9,
2641 },
2642 .parent = &csi0_src_clk.c,
2643 .c = {
2644 .dbg_name = "csi0_phy_clk",
2645 .ops = &clk_ops_branch,
2646 CLK_INIT(csi0_phy_clk.c),
2647 },
2648};
2649
2650static struct rcg_clk csi1_src_clk = {
2651 .ns_reg = CSI1_NS_REG,
2652 .b = {
2653 .ctl_reg = CSI1_CC_REG,
2654 .halt_check = NOCHECK,
2655 },
2656 .md_reg = CSI1_MD_REG,
2657 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002658 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
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),
2714 .ctl_mask = BM(7, 6),
2715 .set_rate = set_rate_mnd,
2716 .freq_tbl = clk_tbl_csi,
2717 .current_freq = &rcg_dummy_freq,
2718 .c = {
2719 .dbg_name = "csi2_src_clk",
2720 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002721 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002722 CLK_INIT(csi2_src_clk.c),
2723 },
2724};
2725
2726static struct branch_clk csi2_clk = {
2727 .b = {
2728 .ctl_reg = CSI2_CC_REG,
2729 .en_mask = BIT(0),
2730 .reset_reg = SW_RESET_CORE2_REG,
2731 .reset_mask = BIT(2),
2732 .halt_reg = DBG_BUS_VEC_B_REG,
2733 .halt_bit = 29,
2734 },
2735 .parent = &csi2_src_clk.c,
2736 .c = {
2737 .dbg_name = "csi2_clk",
2738 .ops = &clk_ops_branch,
2739 CLK_INIT(csi2_clk.c),
2740 },
2741};
2742
2743static struct branch_clk csi2_phy_clk = {
2744 .b = {
2745 .ctl_reg = CSI2_CC_REG,
2746 .en_mask = BIT(8),
2747 .reset_reg = SW_RESET_CORE_REG,
2748 .reset_mask = BIT(31),
2749 .halt_reg = DBG_BUS_VEC_I_REG,
2750 .halt_bit = 29,
2751 },
2752 .parent = &csi2_src_clk.c,
2753 .c = {
2754 .dbg_name = "csi2_phy_clk",
2755 .ops = &clk_ops_branch,
2756 CLK_INIT(csi2_phy_clk.c),
2757 },
2758};
2759
Stephen Boyd092fd182011-10-21 15:56:30 -07002760static struct clk *pix_rdi_mux_map[] = {
2761 [0] = &csi0_clk.c,
2762 [1] = &csi1_clk.c,
2763 [2] = &csi2_clk.c,
2764 NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002765};
2766
Stephen Boyd092fd182011-10-21 15:56:30 -07002767struct pix_rdi_clk {
2768 bool enabled;
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002769 unsigned long cur_rate;
Stephen Boyd092fd182011-10-21 15:56:30 -07002770
2771 void __iomem *const s_reg;
2772 u32 s_mask;
2773
2774 void __iomem *const s2_reg;
2775 u32 s2_mask;
2776
2777 struct branch b;
2778 struct clk c;
2779};
2780
2781static inline struct pix_rdi_clk *to_pix_rdi_clk(struct clk *clk)
2782{
2783 return container_of(clk, struct pix_rdi_clk, c);
2784}
2785
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002786static int pix_rdi_clk_set_rate(struct clk *c, unsigned long rate)
Stephen Boyd092fd182011-10-21 15:56:30 -07002787{
2788 int ret, i;
2789 u32 reg;
2790 unsigned long flags;
2791 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2792 struct clk **mux_map = pix_rdi_mux_map;
2793
2794 /*
2795 * These clocks select three inputs via two muxes. One mux selects
2796 * between csi0 and csi1 and the second mux selects between that mux's
2797 * output and csi2. The source and destination selections for each
2798 * mux must be clocking for the switch to succeed so just turn on
2799 * all three sources because it's easier than figuring out what source
2800 * needs to be on at what time.
2801 */
2802 for (i = 0; mux_map[i]; i++) {
2803 ret = clk_enable(mux_map[i]);
2804 if (ret)
2805 goto err;
2806 }
2807 if (rate >= i) {
2808 ret = -EINVAL;
2809 goto err;
2810 }
2811 /* Keep the new source on when switching inputs of an enabled clock */
2812 if (clk->enabled) {
2813 clk_disable(mux_map[clk->cur_rate]);
2814 clk_enable(mux_map[rate]);
2815 }
2816 spin_lock_irqsave(&local_clock_reg_lock, flags);
2817 reg = readl_relaxed(clk->s2_reg);
2818 reg &= ~clk->s2_mask;
2819 reg |= rate == 2 ? clk->s2_mask : 0;
2820 writel_relaxed(reg, clk->s2_reg);
2821 /*
2822 * Wait at least 6 cycles of slowest clock
2823 * for the glitch-free MUX to fully switch sources.
2824 */
2825 mb();
2826 udelay(1);
2827 reg = readl_relaxed(clk->s_reg);
2828 reg &= ~clk->s_mask;
2829 reg |= rate == 1 ? clk->s_mask : 0;
2830 writel_relaxed(reg, clk->s_reg);
2831 /*
2832 * Wait at least 6 cycles of slowest clock
2833 * for the glitch-free MUX to fully switch sources.
2834 */
2835 mb();
2836 udelay(1);
2837 clk->cur_rate = rate;
2838 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2839err:
2840 for (i--; i >= 0; i--)
2841 clk_disable(mux_map[i]);
2842
2843 return 0;
2844}
2845
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002846static unsigned long pix_rdi_clk_get_rate(struct clk *c)
Stephen Boyd092fd182011-10-21 15:56:30 -07002847{
2848 return to_pix_rdi_clk(c)->cur_rate;
2849}
2850
2851static int pix_rdi_clk_enable(struct clk *c)
2852{
2853 unsigned long flags;
2854 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2855
2856 spin_lock_irqsave(&local_clock_reg_lock, flags);
2857 __branch_clk_enable_reg(&clk->b, clk->c.dbg_name);
2858 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2859 clk->enabled = true;
2860
2861 return 0;
2862}
2863
2864static void pix_rdi_clk_disable(struct clk *c)
2865{
2866 unsigned long flags;
2867 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2868
2869 spin_lock_irqsave(&local_clock_reg_lock, flags);
2870 __branch_clk_disable_reg(&clk->b, clk->c.dbg_name);
2871 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2872 clk->enabled = false;
2873}
2874
2875static int pix_rdi_clk_reset(struct clk *clk, enum clk_reset_action action)
2876{
2877 return branch_reset(&to_pix_rdi_clk(clk)->b, action);
2878}
2879
2880static struct clk *pix_rdi_clk_get_parent(struct clk *c)
2881{
2882 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2883
2884 return pix_rdi_mux_map[clk->cur_rate];
2885}
2886
2887static int pix_rdi_clk_list_rate(struct clk *c, unsigned n)
2888{
2889 if (pix_rdi_mux_map[n])
2890 return n;
2891 return -ENXIO;
2892}
2893
2894static int pix_rdi_clk_handoff(struct clk *c)
2895{
2896 u32 reg;
2897 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2898
2899 reg = readl_relaxed(clk->s_reg);
2900 clk->cur_rate = reg & clk->s_mask ? 1 : 0;
2901 reg = readl_relaxed(clk->s2_reg);
2902 clk->cur_rate = reg & clk->s2_mask ? 2 : clk->cur_rate;
2903 return 0;
2904}
2905
2906static struct clk_ops clk_ops_pix_rdi_8960 = {
2907 .enable = pix_rdi_clk_enable,
2908 .disable = pix_rdi_clk_disable,
2909 .auto_off = pix_rdi_clk_disable,
2910 .handoff = pix_rdi_clk_handoff,
2911 .set_rate = pix_rdi_clk_set_rate,
2912 .get_rate = pix_rdi_clk_get_rate,
2913 .list_rate = pix_rdi_clk_list_rate,
2914 .reset = pix_rdi_clk_reset,
2915 .is_local = local_clk_is_local,
2916 .get_parent = pix_rdi_clk_get_parent,
2917};
2918
2919static struct pix_rdi_clk csi_pix_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002920 .b = {
2921 .ctl_reg = MISC_CC_REG,
2922 .en_mask = BIT(26),
2923 .halt_check = DELAY,
2924 .reset_reg = SW_RESET_CORE_REG,
2925 .reset_mask = BIT(26),
2926 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002927 .s_reg = MISC_CC_REG,
2928 .s_mask = BIT(25),
2929 .s2_reg = MISC_CC3_REG,
2930 .s2_mask = BIT(13),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002931 .c = {
2932 .dbg_name = "csi_pix_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002933 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002934 CLK_INIT(csi_pix_clk.c),
2935 },
2936};
2937
Stephen Boyd092fd182011-10-21 15:56:30 -07002938static struct pix_rdi_clk csi_pix1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07002939 .b = {
2940 .ctl_reg = MISC_CC3_REG,
2941 .en_mask = BIT(10),
2942 .halt_check = DELAY,
2943 .reset_reg = SW_RESET_CORE_REG,
2944 .reset_mask = BIT(30),
2945 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002946 .s_reg = MISC_CC3_REG,
2947 .s_mask = BIT(8),
2948 .s2_reg = MISC_CC3_REG,
2949 .s2_mask = BIT(9),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002950 .c = {
2951 .dbg_name = "csi_pix1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002952 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07002953 CLK_INIT(csi_pix1_clk.c),
2954 },
2955};
2956
Stephen Boyd092fd182011-10-21 15:56:30 -07002957static struct pix_rdi_clk csi_rdi_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002958 .b = {
2959 .ctl_reg = MISC_CC_REG,
2960 .en_mask = BIT(13),
2961 .halt_check = DELAY,
2962 .reset_reg = SW_RESET_CORE_REG,
2963 .reset_mask = BIT(27),
2964 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002965 .s_reg = MISC_CC_REG,
2966 .s_mask = BIT(12),
2967 .s2_reg = MISC_CC3_REG,
2968 .s2_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002969 .c = {
2970 .dbg_name = "csi_rdi_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002971 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002972 CLK_INIT(csi_rdi_clk.c),
2973 },
2974};
2975
Stephen Boyd092fd182011-10-21 15:56:30 -07002976static struct pix_rdi_clk csi_rdi1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07002977 .b = {
2978 .ctl_reg = MISC_CC3_REG,
2979 .en_mask = BIT(2),
2980 .halt_check = DELAY,
2981 .reset_reg = SW_RESET_CORE2_REG,
2982 .reset_mask = BIT(1),
2983 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002984 .s_reg = MISC_CC3_REG,
2985 .s_mask = BIT(0),
2986 .s2_reg = MISC_CC3_REG,
2987 .s2_mask = BIT(1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002988 .c = {
2989 .dbg_name = "csi_rdi1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002990 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07002991 CLK_INIT(csi_rdi1_clk.c),
2992 },
2993};
2994
Stephen Boyd092fd182011-10-21 15:56:30 -07002995static struct pix_rdi_clk csi_rdi2_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07002996 .b = {
2997 .ctl_reg = MISC_CC3_REG,
2998 .en_mask = BIT(6),
2999 .halt_check = DELAY,
3000 .reset_reg = SW_RESET_CORE2_REG,
3001 .reset_mask = BIT(0),
3002 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003003 .s_reg = MISC_CC3_REG,
3004 .s_mask = BIT(4),
3005 .s2_reg = MISC_CC3_REG,
3006 .s2_mask = BIT(5),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003007 .c = {
3008 .dbg_name = "csi_rdi2_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003009 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003010 CLK_INIT(csi_rdi2_clk.c),
3011 },
3012};
3013
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003014#define F_CSI_PHYTIMER(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003015 { \
3016 .freq_hz = f, \
3017 .src_clk = &s##_clk.c, \
3018 .md_val = MD8(8, m, 0, n), \
3019 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3020 .ctl_val = CC(6, n), \
3021 .mnd_en_mask = BIT(5) * !!(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)),
3039 .ctl_mask = BM(7, 6),
3040 .set_rate = set_rate_mnd_8,
3041 .freq_tbl = clk_tbl_csi_phytimer,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003042 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003043 .c = {
3044 .dbg_name = "csiphy_timer_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003045 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003046 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003047 CLK_INIT(csiphy_timer_src_clk.c),
3048 },
3049};
3050
3051static struct branch_clk csi0phy_timer_clk = {
3052 .b = {
3053 .ctl_reg = CSIPHYTIMER_CC_REG,
3054 .en_mask = BIT(0),
3055 .halt_reg = DBG_BUS_VEC_I_REG,
3056 .halt_bit = 17,
3057 },
3058 .parent = &csiphy_timer_src_clk.c,
3059 .c = {
3060 .dbg_name = "csi0phy_timer_clk",
3061 .ops = &clk_ops_branch,
3062 CLK_INIT(csi0phy_timer_clk.c),
3063 },
3064};
3065
3066static struct branch_clk csi1phy_timer_clk = {
3067 .b = {
3068 .ctl_reg = CSIPHYTIMER_CC_REG,
3069 .en_mask = BIT(9),
3070 .halt_reg = DBG_BUS_VEC_I_REG,
3071 .halt_bit = 18,
3072 },
3073 .parent = &csiphy_timer_src_clk.c,
3074 .c = {
3075 .dbg_name = "csi1phy_timer_clk",
3076 .ops = &clk_ops_branch,
3077 CLK_INIT(csi1phy_timer_clk.c),
3078 },
3079};
3080
Stephen Boyd94625ef2011-07-12 17:06:01 -07003081static struct branch_clk csi2phy_timer_clk = {
3082 .b = {
3083 .ctl_reg = CSIPHYTIMER_CC_REG,
3084 .en_mask = BIT(11),
3085 .halt_reg = DBG_BUS_VEC_I_REG,
3086 .halt_bit = 30,
3087 },
3088 .parent = &csiphy_timer_src_clk.c,
3089 .c = {
3090 .dbg_name = "csi2phy_timer_clk",
3091 .ops = &clk_ops_branch,
3092 CLK_INIT(csi2phy_timer_clk.c),
3093 },
3094};
3095
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003096#define F_DSI(d) \
3097 { \
3098 .freq_hz = d, \
3099 .ns_val = BVAL(15, 12, (d-1)), \
3100 }
3101/*
3102 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
3103 * without this clock driver knowing. So, overload the clk_set_rate() to set
3104 * the divider (1 to 16) of the clock with respect to the PLL rate.
3105 */
3106static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
3107 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
3108 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
3109 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
3110 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
3111 F_END
3112};
3113
3114static struct rcg_clk dsi1_byte_clk = {
3115 .b = {
3116 .ctl_reg = DSI1_BYTE_CC_REG,
3117 .en_mask = BIT(0),
3118 .reset_reg = SW_RESET_CORE_REG,
3119 .reset_mask = BIT(7),
3120 .halt_reg = DBG_BUS_VEC_B_REG,
3121 .halt_bit = 21,
3122 },
3123 .ns_reg = DSI1_BYTE_NS_REG,
3124 .root_en_mask = BIT(2),
3125 .ns_mask = BM(15, 12),
3126 .set_rate = set_rate_nop,
3127 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003128 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003129 .c = {
3130 .dbg_name = "dsi1_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003131 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003132 CLK_INIT(dsi1_byte_clk.c),
3133 },
3134};
3135
3136static struct rcg_clk dsi2_byte_clk = {
3137 .b = {
3138 .ctl_reg = DSI2_BYTE_CC_REG,
3139 .en_mask = BIT(0),
3140 .reset_reg = SW_RESET_CORE_REG,
3141 .reset_mask = BIT(25),
3142 .halt_reg = DBG_BUS_VEC_B_REG,
3143 .halt_bit = 20,
3144 },
3145 .ns_reg = DSI2_BYTE_NS_REG,
3146 .root_en_mask = BIT(2),
3147 .ns_mask = BM(15, 12),
3148 .set_rate = set_rate_nop,
3149 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003150 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003151 .c = {
3152 .dbg_name = "dsi2_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003153 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003154 CLK_INIT(dsi2_byte_clk.c),
3155 },
3156};
3157
3158static struct rcg_clk dsi1_esc_clk = {
3159 .b = {
3160 .ctl_reg = DSI1_ESC_CC_REG,
3161 .en_mask = BIT(0),
3162 .reset_reg = SW_RESET_CORE_REG,
3163 .halt_reg = DBG_BUS_VEC_I_REG,
3164 .halt_bit = 1,
3165 },
3166 .ns_reg = DSI1_ESC_NS_REG,
3167 .root_en_mask = BIT(2),
3168 .ns_mask = BM(15, 12),
3169 .set_rate = set_rate_nop,
3170 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003171 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003172 .c = {
3173 .dbg_name = "dsi1_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003174 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003175 CLK_INIT(dsi1_esc_clk.c),
3176 },
3177};
3178
3179static struct rcg_clk dsi2_esc_clk = {
3180 .b = {
3181 .ctl_reg = DSI2_ESC_CC_REG,
3182 .en_mask = BIT(0),
3183 .halt_reg = DBG_BUS_VEC_I_REG,
3184 .halt_bit = 3,
3185 },
3186 .ns_reg = DSI2_ESC_NS_REG,
3187 .root_en_mask = BIT(2),
3188 .ns_mask = BM(15, 12),
3189 .set_rate = set_rate_nop,
3190 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003191 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003192 .c = {
3193 .dbg_name = "dsi2_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003194 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003195 CLK_INIT(dsi2_esc_clk.c),
3196 },
3197};
3198
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003199#define F_GFX2D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003200 { \
3201 .freq_hz = f, \
3202 .src_clk = &s##_clk.c, \
3203 .md_val = MD4(4, m, 0, n), \
3204 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
3205 .ctl_val = CC_BANKED(9, 6, n), \
3206 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003207 }
3208static struct clk_freq_tbl clk_tbl_gfx2d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003209 F_GFX2D( 0, gnd, 0, 0),
3210 F_GFX2D( 27000000, pxo, 0, 0),
3211 F_GFX2D( 48000000, pll8, 1, 8),
3212 F_GFX2D( 54857000, pll8, 1, 7),
3213 F_GFX2D( 64000000, pll8, 1, 6),
3214 F_GFX2D( 76800000, pll8, 1, 5),
3215 F_GFX2D( 96000000, pll8, 1, 4),
3216 F_GFX2D(128000000, pll8, 1, 3),
3217 F_GFX2D(145455000, pll2, 2, 11),
3218 F_GFX2D(160000000, pll2, 1, 5),
3219 F_GFX2D(177778000, pll2, 2, 9),
3220 F_GFX2D(200000000, pll2, 1, 4),
3221 F_GFX2D(228571000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003222 F_END
3223};
3224
3225static struct bank_masks bmnd_info_gfx2d0 = {
3226 .bank_sel_mask = BIT(11),
3227 .bank0_mask = {
3228 .md_reg = GFX2D0_MD0_REG,
3229 .ns_mask = BM(23, 20) | BM(5, 3),
3230 .rst_mask = BIT(25),
3231 .mnd_en_mask = BIT(8),
3232 .mode_mask = BM(10, 9),
3233 },
3234 .bank1_mask = {
3235 .md_reg = GFX2D0_MD1_REG,
3236 .ns_mask = BM(19, 16) | BM(2, 0),
3237 .rst_mask = BIT(24),
3238 .mnd_en_mask = BIT(5),
3239 .mode_mask = BM(7, 6),
3240 },
3241};
3242
3243static struct rcg_clk gfx2d0_clk = {
3244 .b = {
3245 .ctl_reg = GFX2D0_CC_REG,
3246 .en_mask = BIT(0),
3247 .reset_reg = SW_RESET_CORE_REG,
3248 .reset_mask = BIT(14),
3249 .halt_reg = DBG_BUS_VEC_A_REG,
3250 .halt_bit = 9,
3251 },
3252 .ns_reg = GFX2D0_NS_REG,
3253 .root_en_mask = BIT(2),
3254 .set_rate = set_rate_mnd_banked,
3255 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003256 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003257 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003258 .c = {
3259 .dbg_name = "gfx2d0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003260 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003261 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3262 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003263 CLK_INIT(gfx2d0_clk.c),
3264 },
3265};
3266
3267static struct bank_masks bmnd_info_gfx2d1 = {
3268 .bank_sel_mask = BIT(11),
3269 .bank0_mask = {
3270 .md_reg = GFX2D1_MD0_REG,
3271 .ns_mask = BM(23, 20) | BM(5, 3),
3272 .rst_mask = BIT(25),
3273 .mnd_en_mask = BIT(8),
3274 .mode_mask = BM(10, 9),
3275 },
3276 .bank1_mask = {
3277 .md_reg = GFX2D1_MD1_REG,
3278 .ns_mask = BM(19, 16) | BM(2, 0),
3279 .rst_mask = BIT(24),
3280 .mnd_en_mask = BIT(5),
3281 .mode_mask = BM(7, 6),
3282 },
3283};
3284
3285static struct rcg_clk gfx2d1_clk = {
3286 .b = {
3287 .ctl_reg = GFX2D1_CC_REG,
3288 .en_mask = BIT(0),
3289 .reset_reg = SW_RESET_CORE_REG,
3290 .reset_mask = BIT(13),
3291 .halt_reg = DBG_BUS_VEC_A_REG,
3292 .halt_bit = 14,
3293 },
3294 .ns_reg = GFX2D1_NS_REG,
3295 .root_en_mask = BIT(2),
3296 .set_rate = set_rate_mnd_banked,
3297 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003298 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003299 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003300 .c = {
3301 .dbg_name = "gfx2d1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003302 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003303 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3304 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003305 CLK_INIT(gfx2d1_clk.c),
3306 },
3307};
3308
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003309#define F_GFX3D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003310 { \
3311 .freq_hz = f, \
3312 .src_clk = &s##_clk.c, \
3313 .md_val = MD4(4, m, 0, n), \
3314 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3315 .ctl_val = CC_BANKED(9, 6, n), \
3316 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003317 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003318
3319static struct clk_freq_tbl clk_tbl_gfx3d_8960[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003320 F_GFX3D( 0, gnd, 0, 0),
3321 F_GFX3D( 27000000, pxo, 0, 0),
3322 F_GFX3D( 48000000, pll8, 1, 8),
3323 F_GFX3D( 54857000, pll8, 1, 7),
3324 F_GFX3D( 64000000, pll8, 1, 6),
3325 F_GFX3D( 76800000, pll8, 1, 5),
3326 F_GFX3D( 96000000, pll8, 1, 4),
3327 F_GFX3D(128000000, pll8, 1, 3),
3328 F_GFX3D(145455000, pll2, 2, 11),
3329 F_GFX3D(160000000, pll2, 1, 5),
3330 F_GFX3D(177778000, pll2, 2, 9),
3331 F_GFX3D(200000000, pll2, 1, 4),
3332 F_GFX3D(228571000, pll2, 2, 7),
3333 F_GFX3D(266667000, pll2, 1, 3),
3334 F_GFX3D(320000000, pll2, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003335 F_END
3336};
3337
Tianyi Gou41515e22011-09-01 19:37:43 -07003338static struct clk_freq_tbl clk_tbl_gfx3d_8960_v2[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003339 F_GFX3D( 0, gnd, 0, 0),
3340 F_GFX3D( 27000000, pxo, 0, 0),
3341 F_GFX3D( 48000000, pll8, 1, 8),
3342 F_GFX3D( 54857000, pll8, 1, 7),
3343 F_GFX3D( 64000000, pll8, 1, 6),
3344 F_GFX3D( 76800000, pll8, 1, 5),
3345 F_GFX3D( 96000000, pll8, 1, 4),
3346 F_GFX3D(128000000, pll8, 1, 3),
3347 F_GFX3D(145455000, pll2, 2, 11),
3348 F_GFX3D(160000000, pll2, 1, 5),
3349 F_GFX3D(177778000, pll2, 2, 9),
3350 F_GFX3D(200000000, pll2, 1, 4),
3351 F_GFX3D(228571000, pll2, 2, 7),
3352 F_GFX3D(266667000, pll2, 1, 3),
3353 F_GFX3D(300000000, pll3, 1, 4),
3354 F_GFX3D(320000000, pll2, 2, 5),
3355 F_GFX3D(400000000, pll2, 1, 2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003356 F_END
3357};
3358
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003359static unsigned long fmax_gfx3d_8960_v2[MAX_VDD_LEVELS] __initdata = {
3360 [VDD_DIG_LOW] = 128000000,
3361 [VDD_DIG_NOMINAL] = 300000000,
3362 [VDD_DIG_HIGH] = 400000000
3363};
3364
Tianyi Gou41515e22011-09-01 19:37:43 -07003365static struct clk_freq_tbl clk_tbl_gfx3d_8064[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003366 F_GFX3D( 0, gnd, 0, 0),
3367 F_GFX3D( 27000000, pxo, 0, 0),
3368 F_GFX3D( 48000000, pll8, 1, 8),
3369 F_GFX3D( 54857000, pll8, 1, 7),
3370 F_GFX3D( 64000000, pll8, 1, 6),
3371 F_GFX3D( 76800000, pll8, 1, 5),
3372 F_GFX3D( 96000000, pll8, 1, 4),
3373 F_GFX3D(128000000, pll8, 1, 3),
3374 F_GFX3D(145455000, pll2, 2, 11),
3375 F_GFX3D(160000000, pll2, 1, 5),
3376 F_GFX3D(177778000, pll2, 2, 9),
3377 F_GFX3D(200000000, pll2, 1, 4),
3378 F_GFX3D(228571000, pll2, 2, 7),
3379 F_GFX3D(266667000, pll2, 1, 3),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07003380 F_GFX3D(325000000, pll15, 1, 3),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003381 F_GFX3D(400000000, pll2, 1, 2),
Tianyi Gou41515e22011-09-01 19:37:43 -07003382 F_END
3383};
3384
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003385static unsigned long fmax_gfx3d_8064[MAX_VDD_LEVELS] __initdata = {
3386 [VDD_DIG_LOW] = 128000000,
3387 [VDD_DIG_NOMINAL] = 325000000,
3388 [VDD_DIG_HIGH] = 400000000
3389};
3390
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003391static struct bank_masks bmnd_info_gfx3d = {
3392 .bank_sel_mask = BIT(11),
3393 .bank0_mask = {
3394 .md_reg = GFX3D_MD0_REG,
3395 .ns_mask = BM(21, 18) | BM(5, 3),
3396 .rst_mask = BIT(23),
3397 .mnd_en_mask = BIT(8),
3398 .mode_mask = BM(10, 9),
3399 },
3400 .bank1_mask = {
3401 .md_reg = GFX3D_MD1_REG,
3402 .ns_mask = BM(17, 14) | BM(2, 0),
3403 .rst_mask = BIT(22),
3404 .mnd_en_mask = BIT(5),
3405 .mode_mask = BM(7, 6),
3406 },
3407};
3408
3409static struct rcg_clk gfx3d_clk = {
3410 .b = {
3411 .ctl_reg = GFX3D_CC_REG,
3412 .en_mask = BIT(0),
3413 .reset_reg = SW_RESET_CORE_REG,
3414 .reset_mask = BIT(12),
3415 .halt_reg = DBG_BUS_VEC_A_REG,
3416 .halt_bit = 4,
3417 },
3418 .ns_reg = GFX3D_NS_REG,
3419 .root_en_mask = BIT(2),
3420 .set_rate = set_rate_mnd_banked,
Tianyi Gou41515e22011-09-01 19:37:43 -07003421 .freq_tbl = clk_tbl_gfx3d_8960,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003422 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003423 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003424 .c = {
3425 .dbg_name = "gfx3d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003426 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003427 VDD_DIG_FMAX_MAP3(LOW, 128000000, NOMINAL, 266667000,
3428 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003429 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003430 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003431 },
3432};
3433
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003434#define F_VCAP(f, s, m, n) \
Tianyi Gou621f8742011-09-01 21:45:01 -07003435 { \
3436 .freq_hz = f, \
3437 .src_clk = &s##_clk.c, \
3438 .md_val = MD4(4, m, 0, n), \
3439 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3440 .ctl_val = CC_BANKED(9, 6, n), \
3441 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Tianyi Gou621f8742011-09-01 21:45:01 -07003442 }
3443
3444static struct clk_freq_tbl clk_tbl_vcap[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003445 F_VCAP( 0, gnd, 0, 0),
3446 F_VCAP( 27000000, pxo, 0, 0),
3447 F_VCAP( 54860000, pll8, 1, 7),
3448 F_VCAP( 64000000, pll8, 1, 6),
3449 F_VCAP( 76800000, pll8, 1, 5),
3450 F_VCAP(128000000, pll8, 1, 3),
3451 F_VCAP(160000000, pll2, 1, 5),
3452 F_VCAP(200000000, pll2, 1, 4),
Tianyi Gou621f8742011-09-01 21:45:01 -07003453 F_END
3454};
3455
3456static struct bank_masks bmnd_info_vcap = {
3457 .bank_sel_mask = BIT(11),
3458 .bank0_mask = {
3459 .md_reg = VCAP_MD0_REG,
3460 .ns_mask = BM(21, 18) | BM(5, 3),
3461 .rst_mask = BIT(23),
3462 .mnd_en_mask = BIT(8),
3463 .mode_mask = BM(10, 9),
3464 },
3465 .bank1_mask = {
3466 .md_reg = VCAP_MD1_REG,
3467 .ns_mask = BM(17, 14) | BM(2, 0),
3468 .rst_mask = BIT(22),
3469 .mnd_en_mask = BIT(5),
3470 .mode_mask = BM(7, 6),
3471 },
3472};
3473
3474static struct rcg_clk vcap_clk = {
3475 .b = {
3476 .ctl_reg = VCAP_CC_REG,
3477 .en_mask = BIT(0),
3478 .halt_reg = DBG_BUS_VEC_J_REG,
3479 .halt_bit = 15,
3480 },
3481 .ns_reg = VCAP_NS_REG,
3482 .root_en_mask = BIT(2),
3483 .set_rate = set_rate_mnd_banked,
3484 .freq_tbl = clk_tbl_vcap,
3485 .bank_info = &bmnd_info_vcap,
3486 .current_freq = &rcg_dummy_freq,
3487 .c = {
3488 .dbg_name = "vcap_clk",
3489 .ops = &clk_ops_rcg_8960,
3490 .depends = &vcap_axi_clk.c,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003491 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000),
Tianyi Gou621f8742011-09-01 21:45:01 -07003492 CLK_INIT(vcap_clk.c),
3493 },
3494};
3495
3496static struct branch_clk vcap_npl_clk = {
3497 .b = {
3498 .ctl_reg = VCAP_CC_REG,
3499 .en_mask = BIT(13),
3500 .halt_reg = DBG_BUS_VEC_J_REG,
3501 .halt_bit = 25,
3502 },
3503 .parent = &vcap_clk.c,
3504 .c = {
3505 .dbg_name = "vcap_npl_clk",
3506 .ops = &clk_ops_branch,
3507 CLK_INIT(vcap_npl_clk.c),
3508 },
3509};
3510
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003511#define F_IJPEG(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003512 { \
3513 .freq_hz = f, \
3514 .src_clk = &s##_clk.c, \
3515 .md_val = MD8(8, m, 0, n), \
3516 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
3517 .ctl_val = CC(6, n), \
3518 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003519 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003520
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003521static struct clk_freq_tbl clk_tbl_ijpeg[] = {
3522 F_IJPEG( 0, gnd, 1, 0, 0),
3523 F_IJPEG( 27000000, pxo, 1, 0, 0),
3524 F_IJPEG( 36570000, pll8, 1, 2, 21),
3525 F_IJPEG( 54860000, pll8, 7, 0, 0),
3526 F_IJPEG( 96000000, pll8, 4, 0, 0),
3527 F_IJPEG(109710000, pll8, 1, 2, 7),
3528 F_IJPEG(128000000, pll8, 3, 0, 0),
3529 F_IJPEG(153600000, pll8, 1, 2, 5),
3530 F_IJPEG(200000000, pll2, 4, 0, 0),
3531 F_IJPEG(228571000, pll2, 1, 2, 7),
3532 F_IJPEG(266667000, pll2, 1, 1, 3),
3533 F_IJPEG(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003534 F_END
3535};
3536
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003537static unsigned long fmax_ijpeg_8960_v2[MAX_VDD_LEVELS] __initdata = {
3538 [VDD_DIG_LOW] = 110000000,
3539 [VDD_DIG_NOMINAL] = 266667000,
3540 [VDD_DIG_HIGH] = 320000000
3541};
3542
3543static unsigned long fmax_ijpeg_8064[MAX_VDD_LEVELS] __initdata = {
3544 [VDD_DIG_LOW] = 128000000,
3545 [VDD_DIG_NOMINAL] = 266667000,
3546 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07003547};
3548
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003549static struct rcg_clk ijpeg_clk = {
3550 .b = {
3551 .ctl_reg = IJPEG_CC_REG,
3552 .en_mask = BIT(0),
3553 .reset_reg = SW_RESET_CORE_REG,
3554 .reset_mask = BIT(9),
3555 .halt_reg = DBG_BUS_VEC_A_REG,
3556 .halt_bit = 24,
3557 },
3558 .ns_reg = IJPEG_NS_REG,
3559 .md_reg = IJPEG_MD_REG,
3560 .root_en_mask = BIT(2),
3561 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
3562 .ctl_mask = BM(7, 6),
3563 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003564 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003565 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003566 .c = {
3567 .dbg_name = "ijpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003568 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003569 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003570 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003571 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003572 },
3573};
3574
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003575#define F_JPEGD(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003576 { \
3577 .freq_hz = f, \
3578 .src_clk = &s##_clk.c, \
3579 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003580 }
3581static struct clk_freq_tbl clk_tbl_jpegd[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003582 F_JPEGD( 0, gnd, 1),
3583 F_JPEGD( 64000000, pll8, 6),
3584 F_JPEGD( 76800000, pll8, 5),
3585 F_JPEGD( 96000000, pll8, 4),
3586 F_JPEGD(160000000, pll2, 5),
3587 F_JPEGD(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003588 F_END
3589};
3590
3591static struct rcg_clk jpegd_clk = {
3592 .b = {
3593 .ctl_reg = JPEGD_CC_REG,
3594 .en_mask = BIT(0),
3595 .reset_reg = SW_RESET_CORE_REG,
3596 .reset_mask = BIT(19),
3597 .halt_reg = DBG_BUS_VEC_A_REG,
3598 .halt_bit = 19,
3599 },
3600 .ns_reg = JPEGD_NS_REG,
3601 .root_en_mask = BIT(2),
3602 .ns_mask = (BM(15, 12) | BM(2, 0)),
3603 .set_rate = set_rate_nop,
3604 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003605 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003606 .c = {
3607 .dbg_name = "jpegd_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003608 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003609 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003610 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003611 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003612 },
3613};
3614
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003615#define F_MDP(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003616 { \
3617 .freq_hz = f, \
3618 .src_clk = &s##_clk.c, \
3619 .md_val = MD8(8, m, 0, n), \
3620 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
3621 .ctl_val = CC_BANKED(9, 6, n), \
3622 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003623 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003624static struct clk_freq_tbl clk_tbl_mdp[] = {
3625 F_MDP( 0, gnd, 0, 0),
3626 F_MDP( 9600000, pll8, 1, 40),
3627 F_MDP( 13710000, pll8, 1, 28),
3628 F_MDP( 27000000, pxo, 0, 0),
3629 F_MDP( 29540000, pll8, 1, 13),
3630 F_MDP( 34910000, pll8, 1, 11),
3631 F_MDP( 38400000, pll8, 1, 10),
3632 F_MDP( 59080000, pll8, 2, 13),
3633 F_MDP( 76800000, pll8, 1, 5),
3634 F_MDP( 85330000, pll8, 2, 9),
3635 F_MDP( 96000000, pll8, 1, 4),
3636 F_MDP(128000000, pll8, 1, 3),
3637 F_MDP(160000000, pll2, 1, 5),
3638 F_MDP(177780000, pll2, 2, 9),
3639 F_MDP(200000000, pll2, 1, 4),
3640 F_MDP(266667000, pll2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003641 F_END
3642};
3643
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003644static unsigned long fmax_mdp_8064[MAX_VDD_LEVELS] __initdata = {
3645 [VDD_DIG_LOW] = 128000000,
3646 [VDD_DIG_NOMINAL] = 266667000
Tianyi Gou621f8742011-09-01 21:45:01 -07003647};
3648
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003649static struct bank_masks bmnd_info_mdp = {
3650 .bank_sel_mask = BIT(11),
3651 .bank0_mask = {
3652 .md_reg = MDP_MD0_REG,
3653 .ns_mask = BM(29, 22) | BM(5, 3),
3654 .rst_mask = BIT(31),
3655 .mnd_en_mask = BIT(8),
3656 .mode_mask = BM(10, 9),
3657 },
3658 .bank1_mask = {
3659 .md_reg = MDP_MD1_REG,
3660 .ns_mask = BM(21, 14) | BM(2, 0),
3661 .rst_mask = BIT(30),
3662 .mnd_en_mask = BIT(5),
3663 .mode_mask = BM(7, 6),
3664 },
3665};
3666
3667static struct rcg_clk mdp_clk = {
3668 .b = {
3669 .ctl_reg = MDP_CC_REG,
3670 .en_mask = BIT(0),
3671 .reset_reg = SW_RESET_CORE_REG,
3672 .reset_mask = BIT(21),
3673 .halt_reg = DBG_BUS_VEC_C_REG,
3674 .halt_bit = 10,
3675 },
3676 .ns_reg = MDP_NS_REG,
3677 .root_en_mask = BIT(2),
3678 .set_rate = set_rate_mnd_banked,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003679 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003680 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003681 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003682 .c = {
3683 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003684 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003685 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003686 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003687 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003688 },
3689};
3690
3691static struct branch_clk lut_mdp_clk = {
3692 .b = {
3693 .ctl_reg = MDP_LUT_CC_REG,
3694 .en_mask = BIT(0),
3695 .halt_reg = DBG_BUS_VEC_I_REG,
3696 .halt_bit = 13,
3697 },
3698 .parent = &mdp_clk.c,
3699 .c = {
3700 .dbg_name = "lut_mdp_clk",
3701 .ops = &clk_ops_branch,
3702 CLK_INIT(lut_mdp_clk.c),
3703 },
3704};
3705
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003706#define F_MDP_VSYNC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003707 { \
3708 .freq_hz = f, \
3709 .src_clk = &s##_clk.c, \
3710 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003711 }
3712static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003713 F_MDP_VSYNC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003714 F_END
3715};
3716
3717static struct rcg_clk mdp_vsync_clk = {
3718 .b = {
3719 .ctl_reg = MISC_CC_REG,
3720 .en_mask = BIT(6),
3721 .reset_reg = SW_RESET_CORE_REG,
3722 .reset_mask = BIT(3),
3723 .halt_reg = DBG_BUS_VEC_B_REG,
3724 .halt_bit = 22,
3725 },
3726 .ns_reg = MISC_CC2_REG,
3727 .ns_mask = BIT(13),
3728 .set_rate = set_rate_nop,
3729 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003730 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003731 .c = {
3732 .dbg_name = "mdp_vsync_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003733 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003734 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003735 CLK_INIT(mdp_vsync_clk.c),
3736 },
3737};
3738
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003739#define F_ROT(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003740 { \
3741 .freq_hz = f, \
3742 .src_clk = &s##_clk.c, \
3743 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
3744 21, 19, 18, 16, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003745 }
3746static struct clk_freq_tbl clk_tbl_rot[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003747 F_ROT( 0, gnd, 1),
3748 F_ROT( 27000000, pxo, 1),
3749 F_ROT( 29540000, pll8, 13),
3750 F_ROT( 32000000, pll8, 12),
3751 F_ROT( 38400000, pll8, 10),
3752 F_ROT( 48000000, pll8, 8),
3753 F_ROT( 54860000, pll8, 7),
3754 F_ROT( 64000000, pll8, 6),
3755 F_ROT( 76800000, pll8, 5),
3756 F_ROT( 96000000, pll8, 4),
3757 F_ROT(100000000, pll2, 8),
3758 F_ROT(114290000, pll2, 7),
3759 F_ROT(133330000, pll2, 6),
3760 F_ROT(160000000, pll2, 5),
3761 F_ROT(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003762 F_END
3763};
3764
3765static struct bank_masks bdiv_info_rot = {
3766 .bank_sel_mask = BIT(30),
3767 .bank0_mask = {
3768 .ns_mask = BM(25, 22) | BM(18, 16),
3769 },
3770 .bank1_mask = {
3771 .ns_mask = BM(29, 26) | BM(21, 19),
3772 },
3773};
3774
3775static struct rcg_clk rot_clk = {
3776 .b = {
3777 .ctl_reg = ROT_CC_REG,
3778 .en_mask = BIT(0),
3779 .reset_reg = SW_RESET_CORE_REG,
3780 .reset_mask = BIT(2),
3781 .halt_reg = DBG_BUS_VEC_C_REG,
3782 .halt_bit = 15,
3783 },
3784 .ns_reg = ROT_NS_REG,
3785 .root_en_mask = BIT(2),
3786 .set_rate = set_rate_div_banked,
3787 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003788 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003789 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003790 .c = {
3791 .dbg_name = "rot_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003792 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003793 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003794 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003795 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003796 },
3797};
3798
3799static int hdmi_pll_clk_enable(struct clk *clk)
3800{
3801 int ret;
3802 unsigned long flags;
3803 spin_lock_irqsave(&local_clock_reg_lock, flags);
3804 ret = hdmi_pll_enable();
3805 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3806 return ret;
3807}
3808
3809static void hdmi_pll_clk_disable(struct clk *clk)
3810{
3811 unsigned long flags;
3812 spin_lock_irqsave(&local_clock_reg_lock, flags);
3813 hdmi_pll_disable();
3814 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3815}
3816
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003817static unsigned long hdmi_pll_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003818{
3819 return hdmi_pll_get_rate();
3820}
3821
Stephen Boyd5b35dee2011-09-21 12:17:38 -07003822static struct clk *hdmi_pll_clk_get_parent(struct clk *clk)
3823{
3824 return &pxo_clk.c;
3825}
3826
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003827static struct clk_ops clk_ops_hdmi_pll = {
3828 .enable = hdmi_pll_clk_enable,
3829 .disable = hdmi_pll_clk_disable,
3830 .get_rate = hdmi_pll_clk_get_rate,
3831 .is_local = local_clk_is_local,
Stephen Boyd5b35dee2011-09-21 12:17:38 -07003832 .get_parent = hdmi_pll_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003833};
3834
3835static struct clk hdmi_pll_clk = {
3836 .dbg_name = "hdmi_pll_clk",
3837 .ops = &clk_ops_hdmi_pll,
3838 CLK_INIT(hdmi_pll_clk),
3839};
3840
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003841#define F_TV_GND(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003842 { \
3843 .freq_hz = f, \
3844 .src_clk = &s##_clk.c, \
3845 .md_val = MD8(8, m, 0, n), \
3846 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3847 .ctl_val = CC(6, n), \
3848 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003849 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003850#define F_TV(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003851 { \
3852 .freq_hz = f, \
3853 .src_clk = &s##_clk, \
3854 .md_val = MD8(8, m, 0, n), \
3855 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3856 .ctl_val = CC(6, n), \
3857 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003858 .extra_freq_data = (void *)p_r, \
3859 }
3860/* Switching TV freqs requires PLL reconfiguration. */
3861static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003862 F_TV_GND( 0, gnd, 0, 1, 0, 0),
3863 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0),
3864 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0),
3865 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0),
3866 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0),
3867 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003868 F_END
3869};
3870
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003871static unsigned long fmax_tv_src_8064[MAX_VDD_LEVELS] __initdata = {
3872 [VDD_DIG_LOW] = 74250000,
3873 [VDD_DIG_NOMINAL] = 149000000
3874};
3875
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003876/*
3877 * Unlike other clocks, the TV rate is adjusted through PLL
3878 * re-programming. It is also routed through an MND divider.
3879 */
3880void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
3881{
3882 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
3883 if (pll_rate)
3884 hdmi_pll_set_rate(pll_rate);
3885 set_rate_mnd(clk, nf);
3886}
3887
3888static struct rcg_clk tv_src_clk = {
3889 .ns_reg = TV_NS_REG,
3890 .b = {
3891 .ctl_reg = TV_CC_REG,
3892 .halt_check = NOCHECK,
3893 },
3894 .md_reg = TV_MD_REG,
3895 .root_en_mask = BIT(2),
3896 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
3897 .ctl_mask = BM(7, 6),
3898 .set_rate = set_rate_tv,
3899 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003900 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003901 .c = {
3902 .dbg_name = "tv_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003903 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003904 VDD_DIG_FMAX_MAP2(LOW, 27030000, NOMINAL, 149000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003905 CLK_INIT(tv_src_clk.c),
3906 },
3907};
3908
3909static struct branch_clk tv_enc_clk = {
3910 .b = {
3911 .ctl_reg = TV_CC_REG,
3912 .en_mask = BIT(8),
3913 .reset_reg = SW_RESET_CORE_REG,
3914 .reset_mask = BIT(0),
3915 .halt_reg = DBG_BUS_VEC_D_REG,
3916 .halt_bit = 9,
3917 },
3918 .parent = &tv_src_clk.c,
3919 .c = {
3920 .dbg_name = "tv_enc_clk",
3921 .ops = &clk_ops_branch,
3922 CLK_INIT(tv_enc_clk.c),
3923 },
3924};
3925
3926static struct branch_clk tv_dac_clk = {
3927 .b = {
3928 .ctl_reg = TV_CC_REG,
3929 .en_mask = BIT(10),
3930 .halt_reg = DBG_BUS_VEC_D_REG,
3931 .halt_bit = 10,
3932 },
3933 .parent = &tv_src_clk.c,
3934 .c = {
3935 .dbg_name = "tv_dac_clk",
3936 .ops = &clk_ops_branch,
3937 CLK_INIT(tv_dac_clk.c),
3938 },
3939};
3940
3941static struct branch_clk mdp_tv_clk = {
3942 .b = {
3943 .ctl_reg = TV_CC_REG,
3944 .en_mask = BIT(0),
3945 .reset_reg = SW_RESET_CORE_REG,
3946 .reset_mask = BIT(4),
3947 .halt_reg = DBG_BUS_VEC_D_REG,
3948 .halt_bit = 12,
3949 },
3950 .parent = &tv_src_clk.c,
3951 .c = {
3952 .dbg_name = "mdp_tv_clk",
3953 .ops = &clk_ops_branch,
3954 CLK_INIT(mdp_tv_clk.c),
3955 },
3956};
3957
3958static struct branch_clk hdmi_tv_clk = {
3959 .b = {
3960 .ctl_reg = TV_CC_REG,
3961 .en_mask = BIT(12),
3962 .reset_reg = SW_RESET_CORE_REG,
3963 .reset_mask = BIT(1),
3964 .halt_reg = DBG_BUS_VEC_D_REG,
3965 .halt_bit = 11,
3966 },
3967 .parent = &tv_src_clk.c,
3968 .c = {
3969 .dbg_name = "hdmi_tv_clk",
3970 .ops = &clk_ops_branch,
3971 CLK_INIT(hdmi_tv_clk.c),
3972 },
3973};
3974
3975static struct branch_clk hdmi_app_clk = {
3976 .b = {
3977 .ctl_reg = MISC_CC2_REG,
3978 .en_mask = BIT(11),
3979 .reset_reg = SW_RESET_CORE_REG,
3980 .reset_mask = BIT(11),
3981 .halt_reg = DBG_BUS_VEC_B_REG,
3982 .halt_bit = 25,
3983 },
3984 .c = {
3985 .dbg_name = "hdmi_app_clk",
3986 .ops = &clk_ops_branch,
3987 CLK_INIT(hdmi_app_clk.c),
3988 },
3989};
3990
3991static struct bank_masks bmnd_info_vcodec = {
3992 .bank_sel_mask = BIT(13),
3993 .bank0_mask = {
3994 .md_reg = VCODEC_MD0_REG,
3995 .ns_mask = BM(18, 11) | BM(2, 0),
3996 .rst_mask = BIT(31),
3997 .mnd_en_mask = BIT(5),
3998 .mode_mask = BM(7, 6),
3999 },
4000 .bank1_mask = {
4001 .md_reg = VCODEC_MD1_REG,
4002 .ns_mask = BM(26, 19) | BM(29, 27),
4003 .rst_mask = BIT(30),
4004 .mnd_en_mask = BIT(10),
4005 .mode_mask = BM(12, 11),
4006 },
4007};
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004008#define F_VCODEC(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004009 { \
4010 .freq_hz = f, \
4011 .src_clk = &s##_clk.c, \
4012 .md_val = MD8(8, m, 0, n), \
4013 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
4014 .ctl_val = CC_BANKED(6, 11, n), \
4015 .mnd_en_mask = (BIT(10) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004016 }
4017static struct clk_freq_tbl clk_tbl_vcodec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004018 F_VCODEC( 0, gnd, 0, 0),
4019 F_VCODEC( 27000000, pxo, 0, 0),
4020 F_VCODEC( 32000000, pll8, 1, 12),
4021 F_VCODEC( 48000000, pll8, 1, 8),
4022 F_VCODEC( 54860000, pll8, 1, 7),
4023 F_VCODEC( 96000000, pll8, 1, 4),
4024 F_VCODEC(133330000, pll2, 1, 6),
4025 F_VCODEC(200000000, pll2, 1, 4),
4026 F_VCODEC(228570000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004027 F_END
4028};
4029
4030static struct rcg_clk vcodec_clk = {
4031 .b = {
4032 .ctl_reg = VCODEC_CC_REG,
4033 .en_mask = BIT(0),
4034 .reset_reg = SW_RESET_CORE_REG,
4035 .reset_mask = BIT(6),
4036 .halt_reg = DBG_BUS_VEC_C_REG,
4037 .halt_bit = 29,
4038 },
4039 .ns_reg = VCODEC_NS_REG,
4040 .root_en_mask = BIT(2),
4041 .set_rate = set_rate_mnd_banked,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004042 .bank_info = &bmnd_info_vcodec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004043 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004044 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004045 .c = {
4046 .dbg_name = "vcodec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004047 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004048 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
4049 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004050 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004051 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004052 },
4053};
4054
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004055#define F_VPE(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004056 { \
4057 .freq_hz = f, \
4058 .src_clk = &s##_clk.c, \
4059 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004060 }
4061static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004062 F_VPE( 0, gnd, 1),
4063 F_VPE( 27000000, pxo, 1),
4064 F_VPE( 34909000, pll8, 11),
4065 F_VPE( 38400000, pll8, 10),
4066 F_VPE( 64000000, pll8, 6),
4067 F_VPE( 76800000, pll8, 5),
4068 F_VPE( 96000000, pll8, 4),
4069 F_VPE(100000000, pll2, 8),
4070 F_VPE(160000000, pll2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004071 F_END
4072};
4073
4074static struct rcg_clk vpe_clk = {
4075 .b = {
4076 .ctl_reg = VPE_CC_REG,
4077 .en_mask = BIT(0),
4078 .reset_reg = SW_RESET_CORE_REG,
4079 .reset_mask = BIT(17),
4080 .halt_reg = DBG_BUS_VEC_A_REG,
4081 .halt_bit = 28,
4082 },
4083 .ns_reg = VPE_NS_REG,
4084 .root_en_mask = BIT(2),
4085 .ns_mask = (BM(15, 12) | BM(2, 0)),
4086 .set_rate = set_rate_nop,
4087 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004088 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004089 .c = {
4090 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004091 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004092 VDD_DIG_FMAX_MAP2(LOW, 76800000, NOMINAL, 160000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004093 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004094 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004095 },
4096};
4097
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004098#define F_VFE(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004099 { \
4100 .freq_hz = f, \
4101 .src_clk = &s##_clk.c, \
4102 .md_val = MD8(8, m, 0, n), \
4103 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
4104 .ctl_val = CC(6, n), \
4105 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004106 }
Tianyi Gou41515e22011-09-01 19:37:43 -07004107
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004108static struct clk_freq_tbl clk_tbl_vfe[] = {
4109 F_VFE( 0, gnd, 1, 0, 0),
4110 F_VFE( 13960000, pll8, 1, 2, 55),
4111 F_VFE( 27000000, pxo, 1, 0, 0),
4112 F_VFE( 36570000, pll8, 1, 2, 21),
4113 F_VFE( 38400000, pll8, 2, 1, 5),
4114 F_VFE( 45180000, pll8, 1, 2, 17),
4115 F_VFE( 48000000, pll8, 2, 1, 4),
4116 F_VFE( 54860000, pll8, 1, 1, 7),
4117 F_VFE( 64000000, pll8, 2, 1, 3),
4118 F_VFE( 76800000, pll8, 1, 1, 5),
4119 F_VFE( 96000000, pll8, 2, 1, 2),
4120 F_VFE(109710000, pll8, 1, 2, 7),
4121 F_VFE(128000000, pll8, 1, 1, 3),
4122 F_VFE(153600000, pll8, 1, 2, 5),
4123 F_VFE(200000000, pll2, 2, 1, 2),
4124 F_VFE(228570000, pll2, 1, 2, 7),
4125 F_VFE(266667000, pll2, 1, 1, 3),
4126 F_VFE(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004127 F_END
4128};
4129
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004130static unsigned long fmax_vfe_8960_v2[MAX_VDD_LEVELS] __initdata = {
4131 [VDD_DIG_LOW] = 110000000,
4132 [VDD_DIG_NOMINAL] = 266667000,
4133 [VDD_DIG_HIGH] = 320000000
4134};
4135
4136static unsigned long fmax_vfe_8064[MAX_VDD_LEVELS] __initdata = {
4137 [VDD_DIG_LOW] = 128000000,
4138 [VDD_DIG_NOMINAL] = 266667000,
4139 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07004140};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004141
4142static struct rcg_clk vfe_clk = {
4143 .b = {
4144 .ctl_reg = VFE_CC_REG,
4145 .reset_reg = SW_RESET_CORE_REG,
4146 .reset_mask = BIT(15),
4147 .halt_reg = DBG_BUS_VEC_B_REG,
4148 .halt_bit = 6,
4149 .en_mask = BIT(0),
4150 },
4151 .ns_reg = VFE_NS_REG,
4152 .md_reg = VFE_MD_REG,
4153 .root_en_mask = BIT(2),
4154 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
4155 .ctl_mask = BM(7, 6),
4156 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004157 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004158 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004159 .c = {
4160 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004161 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004162 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004163 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004164 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004165 },
4166};
4167
Matt Wagantallc23eee92011-08-16 23:06:52 -07004168static struct branch_clk csi_vfe_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004169 .b = {
4170 .ctl_reg = VFE_CC_REG,
4171 .en_mask = BIT(12),
4172 .reset_reg = SW_RESET_CORE_REG,
4173 .reset_mask = BIT(24),
4174 .halt_reg = DBG_BUS_VEC_B_REG,
4175 .halt_bit = 8,
4176 },
4177 .parent = &vfe_clk.c,
4178 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -07004179 .dbg_name = "csi_vfe_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004180 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -07004181 CLK_INIT(csi_vfe_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004182 },
4183};
4184
4185/*
4186 * Low Power Audio Clocks
4187 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004188#define F_AIF_OSR(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004189 { \
4190 .freq_hz = f, \
4191 .src_clk = &s##_clk.c, \
4192 .md_val = MD8(8, m, 0, n), \
4193 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4194 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004195 }
4196static struct clk_freq_tbl clk_tbl_aif_osr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004197 F_AIF_OSR( 0, gnd, 1, 0, 0),
4198 F_AIF_OSR( 512000, pll4, 4, 1, 192),
4199 F_AIF_OSR( 768000, pll4, 4, 1, 128),
4200 F_AIF_OSR( 1024000, pll4, 4, 1, 96),
4201 F_AIF_OSR( 1536000, pll4, 4, 1, 64),
4202 F_AIF_OSR( 2048000, pll4, 4, 1, 48),
4203 F_AIF_OSR( 3072000, pll4, 4, 1, 32),
4204 F_AIF_OSR( 4096000, pll4, 4, 1, 24),
4205 F_AIF_OSR( 6144000, pll4, 4, 1, 16),
4206 F_AIF_OSR( 8192000, pll4, 4, 1, 12),
4207 F_AIF_OSR(12288000, pll4, 4, 1, 8),
4208 F_AIF_OSR(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004209 F_END
4210};
4211
4212#define CLK_AIF_OSR(i, ns, md, h_r) \
4213 struct rcg_clk i##_clk = { \
4214 .b = { \
4215 .ctl_reg = ns, \
4216 .en_mask = BIT(17), \
4217 .reset_reg = ns, \
4218 .reset_mask = BIT(19), \
4219 .halt_reg = h_r, \
4220 .halt_check = ENABLE, \
4221 .halt_bit = 1, \
4222 }, \
4223 .ns_reg = ns, \
4224 .md_reg = md, \
4225 .root_en_mask = BIT(9), \
4226 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4227 .set_rate = set_rate_mnd, \
4228 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004229 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004230 .c = { \
4231 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004232 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004233 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004234 CLK_INIT(i##_clk.c), \
4235 }, \
4236 }
4237#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
4238 struct rcg_clk i##_clk = { \
4239 .b = { \
4240 .ctl_reg = ns, \
4241 .en_mask = BIT(21), \
4242 .reset_reg = ns, \
4243 .reset_mask = BIT(23), \
4244 .halt_reg = h_r, \
4245 .halt_check = ENABLE, \
4246 .halt_bit = 1, \
4247 }, \
4248 .ns_reg = ns, \
4249 .md_reg = md, \
4250 .root_en_mask = BIT(9), \
4251 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4252 .set_rate = set_rate_mnd, \
4253 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004254 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004255 .c = { \
4256 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004257 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004258 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004259 CLK_INIT(i##_clk.c), \
4260 }, \
4261 }
4262
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004263#define CLK_AIF_BIT(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004264 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004265 .b = { \
4266 .ctl_reg = ns, \
4267 .en_mask = BIT(15), \
4268 .halt_reg = h_r, \
4269 .halt_check = DELAY, \
4270 }, \
4271 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004272 .ext_mask = BIT(14), \
4273 .div_offset = 10, \
4274 .max_div = 16, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004275 .c = { \
4276 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004277 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004278 CLK_INIT(i##_clk.c), \
4279 }, \
4280 }
4281
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004282#define CLK_AIF_BIT_DIV(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004283 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004284 .b = { \
4285 .ctl_reg = ns, \
4286 .en_mask = BIT(19), \
4287 .halt_reg = h_r, \
4288 .halt_check = ENABLE, \
4289 }, \
4290 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004291 .ext_mask = BIT(18), \
4292 .div_offset = 10, \
4293 .max_div = 256, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004294 .c = { \
4295 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004296 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004297 CLK_INIT(i##_clk.c), \
4298 }, \
4299 }
4300
4301static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
4302 LCC_MI2S_STATUS_REG);
4303static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
4304
4305static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
4306 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
4307static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
4308 LCC_CODEC_I2S_MIC_STATUS_REG);
4309
4310static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
4311 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
4312static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
4313 LCC_SPARE_I2S_MIC_STATUS_REG);
4314
4315static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
4316 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
4317static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
4318 LCC_CODEC_I2S_SPKR_STATUS_REG);
4319
4320static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
4321 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
4322static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
4323 LCC_SPARE_I2S_SPKR_STATUS_REG);
4324
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004325#define F_PCM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004326 { \
4327 .freq_hz = f, \
4328 .src_clk = &s##_clk.c, \
4329 .md_val = MD16(m, n), \
4330 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4331 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004332 }
4333static struct clk_freq_tbl clk_tbl_pcm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004334 F_PCM( 0, gnd, 1, 0, 0),
4335 F_PCM( 512000, pll4, 4, 1, 192),
4336 F_PCM( 768000, pll4, 4, 1, 128),
4337 F_PCM( 1024000, pll4, 4, 1, 96),
4338 F_PCM( 1536000, pll4, 4, 1, 64),
4339 F_PCM( 2048000, pll4, 4, 1, 48),
4340 F_PCM( 3072000, pll4, 4, 1, 32),
4341 F_PCM( 4096000, pll4, 4, 1, 24),
4342 F_PCM( 6144000, pll4, 4, 1, 16),
4343 F_PCM( 8192000, pll4, 4, 1, 12),
4344 F_PCM(12288000, pll4, 4, 1, 8),
4345 F_PCM(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004346 F_END
4347};
4348
4349static struct rcg_clk pcm_clk = {
4350 .b = {
4351 .ctl_reg = LCC_PCM_NS_REG,
4352 .en_mask = BIT(11),
4353 .reset_reg = LCC_PCM_NS_REG,
4354 .reset_mask = BIT(13),
4355 .halt_reg = LCC_PCM_STATUS_REG,
4356 .halt_check = ENABLE,
4357 .halt_bit = 0,
4358 },
4359 .ns_reg = LCC_PCM_NS_REG,
4360 .md_reg = LCC_PCM_MD_REG,
4361 .root_en_mask = BIT(9),
4362 .ns_mask = (BM(31, 16) | BM(6, 0)),
4363 .set_rate = set_rate_mnd,
4364 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004365 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004366 .c = {
4367 .dbg_name = "pcm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004368 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004369 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004370 CLK_INIT(pcm_clk.c),
4371 },
4372};
4373
4374static struct rcg_clk audio_slimbus_clk = {
4375 .b = {
4376 .ctl_reg = LCC_SLIMBUS_NS_REG,
4377 .en_mask = BIT(10),
4378 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
4379 .reset_mask = BIT(5),
4380 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4381 .halt_check = ENABLE,
4382 .halt_bit = 0,
4383 },
4384 .ns_reg = LCC_SLIMBUS_NS_REG,
4385 .md_reg = LCC_SLIMBUS_MD_REG,
4386 .root_en_mask = BIT(9),
4387 .ns_mask = (BM(31, 24) | BM(6, 0)),
4388 .set_rate = set_rate_mnd,
4389 .freq_tbl = clk_tbl_aif_osr,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004390 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004391 .c = {
4392 .dbg_name = "audio_slimbus_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004393 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004394 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004395 CLK_INIT(audio_slimbus_clk.c),
4396 },
4397};
4398
4399static struct branch_clk sps_slimbus_clk = {
4400 .b = {
4401 .ctl_reg = LCC_SLIMBUS_NS_REG,
4402 .en_mask = BIT(12),
4403 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4404 .halt_check = ENABLE,
4405 .halt_bit = 1,
4406 },
4407 .parent = &audio_slimbus_clk.c,
4408 .c = {
4409 .dbg_name = "sps_slimbus_clk",
4410 .ops = &clk_ops_branch,
4411 CLK_INIT(sps_slimbus_clk.c),
4412 },
4413};
4414
4415static struct branch_clk slimbus_xo_src_clk = {
4416 .b = {
4417 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
4418 .en_mask = BIT(2),
4419 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004420 .halt_bit = 28,
4421 },
4422 .parent = &sps_slimbus_clk.c,
4423 .c = {
4424 .dbg_name = "slimbus_xo_src_clk",
4425 .ops = &clk_ops_branch,
4426 CLK_INIT(slimbus_xo_src_clk.c),
4427 },
4428};
4429
Matt Wagantall735f01a2011-08-12 12:40:28 -07004430DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
4431DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
4432DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
4433DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
4434DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
4435DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
4436DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
4437DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004438
4439static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
4440static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
Manu Gautam7483f172011-11-08 15:22:26 +05304441static DEFINE_CLK_VOTER(dfab_usb_hs3_clk, &dfab_clk.c);
4442static DEFINE_CLK_VOTER(dfab_usb_hs4_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004443static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
4444static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
4445static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
4446static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
4447static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
4448static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
Stephen Boyd1c51a492011-10-26 12:11:47 -07004449static DEFINE_CLK_VOTER(dfab_bam_dmux_clk, &dfab_clk.c);
Stephen Boydef5d1c42011-12-15 20:47:14 -08004450static DEFINE_CLK_VOTER(dfab_scm_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004451
4452static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
Stephen Boyd36466ae2012-01-18 20:58:27 -08004453static DEFINE_CLK_VOTER(ebi1_adm_clk, &ebi1_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004454
4455#ifdef CONFIG_DEBUG_FS
4456struct measure_sel {
4457 u32 test_vector;
4458 struct clk *clk;
4459};
4460
Matt Wagantall8b38f942011-08-02 18:23:18 -07004461static DEFINE_CLK_MEASURE(l2_m_clk);
4462static DEFINE_CLK_MEASURE(krait0_m_clk);
4463static DEFINE_CLK_MEASURE(krait1_m_clk);
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004464static DEFINE_CLK_MEASURE(q6sw_clk);
4465static DEFINE_CLK_MEASURE(q6fw_clk);
4466static DEFINE_CLK_MEASURE(q6_func_clk);
Matt Wagantall8b38f942011-08-02 18:23:18 -07004467
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004468static struct measure_sel measure_mux[] = {
4469 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
4470 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
4471 { TEST_PER_LS(0x13), &sdc1_clk.c },
4472 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
4473 { TEST_PER_LS(0x15), &sdc2_clk.c },
4474 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
4475 { TEST_PER_LS(0x17), &sdc3_clk.c },
4476 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
4477 { TEST_PER_LS(0x19), &sdc4_clk.c },
4478 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
4479 { TEST_PER_LS(0x1B), &sdc5_clk.c },
Matt Wagantall7625a4c2011-11-01 16:17:53 -07004480 { TEST_PER_LS(0x1F), &gp0_clk.c },
4481 { TEST_PER_LS(0x20), &gp1_clk.c },
4482 { TEST_PER_LS(0x21), &gp2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004483 { TEST_PER_LS(0x25), &dfab_clk.c },
4484 { TEST_PER_LS(0x25), &dfab_a_clk.c },
4485 { TEST_PER_LS(0x26), &pmem_clk.c },
4486 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
4487 { TEST_PER_LS(0x33), &cfpb_clk.c },
4488 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
4489 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
4490 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
4491 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
4492 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
4493 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
4494 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
4495 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
4496 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
4497 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
4498 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
4499 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
4500 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
4501 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
4502 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
4503 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
4504 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
4505 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
4506 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
4507 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
4508 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
4509 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
4510 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
4511 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
4512 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
4513 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
4514 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
4515 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
4516 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
4517 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
4518 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
4519 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
4520 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
4521 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
4522 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
4523 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
4524 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004525 { TEST_PER_LS(0x5E), &pcie_p_clk.c },
4526 { TEST_PER_LS(0x5F), &ce3_p_clk.c },
4527 { TEST_PER_LS(0x60), &ce3_core_clk.c },
4528 { TEST_PER_LS(0x63), &usb_hs3_p_clk.c },
4529 { TEST_PER_LS(0x64), &usb_hs3_xcvr_clk.c },
4530 { TEST_PER_LS(0x65), &usb_hs4_p_clk.c },
4531 { TEST_PER_LS(0x66), &usb_hs4_xcvr_clk.c },
4532 { TEST_PER_LS(0x6B), &sata_phy_ref_clk.c },
4533 { TEST_PER_LS(0x6C), &sata_phy_cfg_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004534 { TEST_PER_LS(0x78), &sfpb_clk.c },
4535 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
4536 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
4537 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
4538 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
4539 { TEST_PER_LS(0x7D), &prng_clk.c },
4540 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
4541 { TEST_PER_LS(0x80), &adm0_p_clk.c },
4542 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
4543 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004544 { TEST_PER_LS(0x86), &usb_hsic_p_clk.c },
4545 { TEST_PER_LS(0x87), &usb_hsic_system_clk.c },
4546 { TEST_PER_LS(0x88), &usb_hsic_xcvr_fs_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004547 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
4548 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
4549 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
4550 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
4551 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
4552 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
4553 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
4554 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
4555 { TEST_PER_LS(0x92), &ce1_p_clk.c },
4556 { TEST_PER_LS(0x94), &tssc_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004557 { TEST_PER_LS(0x9D), &usb_hsic_hsio_cal_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004558 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
4559
4560 { TEST_PER_HS(0x07), &afab_clk.c },
4561 { TEST_PER_HS(0x07), &afab_a_clk.c },
4562 { TEST_PER_HS(0x18), &sfab_clk.c },
4563 { TEST_PER_HS(0x18), &sfab_a_clk.c },
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004564 { TEST_PER_HS(0x26), &q6sw_clk },
4565 { TEST_PER_HS(0x27), &q6fw_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004566 { TEST_PER_HS(0x2A), &adm0_clk.c },
4567 { TEST_PER_HS(0x34), &ebi1_clk.c },
4568 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004569 { TEST_PER_HS(0x50), &usb_hsic_hsic_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004570
4571 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
4572 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
4573 { TEST_MM_LS(0x02), &cam1_clk.c },
4574 { TEST_MM_LS(0x06), &amp_p_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004575 { TEST_MM_LS(0x07), &csi_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004576 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
4577 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
4578 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
4579 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
4580 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
4581 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
4582 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
4583 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
4584 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
4585 { TEST_MM_LS(0x12), &imem_p_clk.c },
4586 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
4587 { TEST_MM_LS(0x14), &mdp_p_clk.c },
4588 { TEST_MM_LS(0x16), &rot_p_clk.c },
4589 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
4590 { TEST_MM_LS(0x18), &smmu_p_clk.c },
4591 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
4592 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
4593 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
4594 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
4595 { TEST_MM_LS(0x1D), &cam0_clk.c },
4596 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
4597 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
4598 { TEST_MM_LS(0x21), &tv_dac_clk.c },
4599 { TEST_MM_LS(0x22), &tv_enc_clk.c },
4600 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
4601 { TEST_MM_LS(0x25), &mmfpb_clk.c },
4602 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
4603 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004604 { TEST_MM_LS(0x27), &cam2_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004605 { TEST_MM_LS(0x28), &vcap_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004606
4607 { TEST_MM_HS(0x00), &csi0_clk.c },
4608 { TEST_MM_HS(0x01), &csi1_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004609 { TEST_MM_HS(0x04), &csi_vfe_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004610 { TEST_MM_HS(0x05), &ijpeg_clk.c },
4611 { TEST_MM_HS(0x06), &vfe_clk.c },
4612 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
4613 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
4614 { TEST_MM_HS(0x09), &gfx3d_clk.c },
4615 { TEST_MM_HS(0x0A), &jpegd_clk.c },
4616 { TEST_MM_HS(0x0B), &vcodec_clk.c },
4617 { TEST_MM_HS(0x0F), &mmfab_clk.c },
4618 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
4619 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
4620 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
4621 { TEST_MM_HS(0x13), &imem_axi_clk.c },
4622 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
4623 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
4624 { TEST_MM_HS(0x16), &rot_axi_clk.c },
4625 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
4626 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
4627 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
4628 { TEST_MM_HS(0x1A), &mdp_clk.c },
4629 { TEST_MM_HS(0x1B), &rot_clk.c },
4630 { TEST_MM_HS(0x1C), &vpe_clk.c },
4631 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
4632 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
4633 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
4634 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
4635 { TEST_MM_HS(0x26), &csi_pix_clk.c },
4636 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
4637 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
4638 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
4639 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
4640 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
4641 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004642 { TEST_MM_HS(0x2D), &csi2_clk.c },
4643 { TEST_MM_HS(0x2E), &csi2_phy_clk.c },
4644 { TEST_MM_HS(0x2F), &csi2phy_timer_clk.c },
4645 { TEST_MM_HS(0x30), &csi_pix1_clk.c },
4646 { TEST_MM_HS(0x31), &csi_rdi1_clk.c },
4647 { TEST_MM_HS(0x32), &csi_rdi2_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004648 { TEST_MM_HS(0x33), &vcap_clk.c },
4649 { TEST_MM_HS(0x34), &vcap_npl_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004650 { TEST_MM_HS(0x36), &vcap_axi_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004651 { TEST_MM_HS(0x39), &gfx3d_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004652
4653 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
4654 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
4655 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
4656 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
4657 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
4658 { TEST_LPA(0x14), &pcm_clk.c },
4659 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
Matt Wagantall8b38f942011-08-02 18:23:18 -07004660
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004661 { TEST_LPA_HS(0x00), &q6_func_clk },
4662
Stephen Boyd46fdf0d2011-11-22 12:25:09 -08004663 { TEST_CPUL2(0x2), &l2_m_clk },
4664 { TEST_CPUL2(0x0), &krait0_m_clk },
4665 { TEST_CPUL2(0x1), &krait1_m_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004666};
4667
4668static struct measure_sel *find_measure_sel(struct clk *clk)
4669{
4670 int i;
4671
4672 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
4673 if (measure_mux[i].clk == clk)
4674 return &measure_mux[i];
4675 return NULL;
4676}
4677
Matt Wagantall8b38f942011-08-02 18:23:18 -07004678static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004679{
4680 int ret = 0;
4681 u32 clk_sel;
4682 struct measure_sel *p;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004683 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004684 unsigned long flags;
4685
4686 if (!parent)
4687 return -EINVAL;
4688
4689 p = find_measure_sel(parent);
4690 if (!p)
4691 return -EINVAL;
4692
4693 spin_lock_irqsave(&local_clock_reg_lock, flags);
4694
Matt Wagantall8b38f942011-08-02 18:23:18 -07004695 /*
4696 * Program the test vector, measurement period (sample_ticks)
4697 * and scaling multiplier.
4698 */
4699 clk->sample_ticks = 0x10000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004700 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004701 clk->multiplier = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004702 switch (p->test_vector >> TEST_TYPE_SHIFT) {
4703 case TEST_TYPE_PER_LS:
4704 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
4705 break;
4706 case TEST_TYPE_PER_HS:
4707 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
4708 break;
4709 case TEST_TYPE_MM_LS:
4710 writel_relaxed(0x4030D97, CLK_TEST_REG);
4711 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
4712 break;
4713 case TEST_TYPE_MM_HS:
4714 writel_relaxed(0x402B800, CLK_TEST_REG);
4715 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
4716 break;
4717 case TEST_TYPE_LPA:
4718 writel_relaxed(0x4030D98, CLK_TEST_REG);
4719 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
4720 LCC_CLK_LS_DEBUG_CFG_REG);
4721 break;
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004722 case TEST_TYPE_LPA_HS:
4723 writel_relaxed(0x402BC00, CLK_TEST_REG);
4724 writel_relaxed(BVAL(2, 1, clk_sel)|BIT(0),
4725 LCC_CLK_HS_DEBUG_CFG_REG);
4726 break;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004727 case TEST_TYPE_CPUL2:
4728 writel_relaxed(0x4030400, CLK_TEST_REG);
4729 writel_relaxed(0x80|BVAL(5, 3, clk_sel), GCC_APCS_CLK_DIAG);
4730 clk->sample_ticks = 0x4000;
4731 clk->multiplier = 2;
4732 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004733 default:
4734 ret = -EPERM;
4735 }
4736 /* Make sure test vector is set before starting measurements. */
4737 mb();
4738
4739 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4740
4741 return ret;
4742}
4743
4744/* Sample clock for 'ticks' reference clock ticks. */
4745static u32 run_measurement(unsigned ticks)
4746{
4747 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004748 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
4749
4750 /* Wait for timer to become ready. */
4751 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
4752 cpu_relax();
4753
4754 /* Run measurement and wait for completion. */
4755 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
4756 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
4757 cpu_relax();
4758
4759 /* Stop counters. */
4760 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
4761
4762 /* Return measured ticks. */
4763 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
4764}
4765
4766
4767/* Perform a hardware rate measurement for a given clock.
4768 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07004769static unsigned long measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004770{
4771 unsigned long flags;
4772 u32 pdm_reg_backup, ringosc_reg_backup;
4773 u64 raw_count_short, raw_count_full;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004774 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004775 unsigned ret;
4776
Stephen Boyd3a35f0b2012-01-11 16:18:26 -08004777 ret = clk_enable(&cxo_clk.c);
4778 if (ret) {
4779 pr_warning("CXO clock failed to enable. Can't measure\n");
4780 return 0;
4781 }
4782
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004783 spin_lock_irqsave(&local_clock_reg_lock, flags);
4784
4785 /* Enable CXO/4 and RINGOSC branch and root. */
4786 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
4787 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
4788 writel_relaxed(0x2898, PDM_CLK_NS_REG);
4789 writel_relaxed(0xA00, RINGOSC_NS_REG);
4790
4791 /*
4792 * The ring oscillator counter will not reset if the measured clock
4793 * is not running. To detect this, run a short measurement before
4794 * the full measurement. If the raw results of the two are the same
4795 * then the clock must be off.
4796 */
4797
4798 /* Run a short measurement. (~1 ms) */
4799 raw_count_short = run_measurement(0x1000);
4800 /* Run a full measurement. (~14 ms) */
Matt Wagantall8b38f942011-08-02 18:23:18 -07004801 raw_count_full = run_measurement(clk->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004802
4803 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
4804 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
4805
4806 /* Return 0 if the clock is off. */
4807 if (raw_count_full == raw_count_short)
4808 ret = 0;
4809 else {
4810 /* Compute rate in Hz. */
4811 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004812 do_div(raw_count_full, ((clk->sample_ticks * 10) + 35));
4813 ret = (raw_count_full * clk->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004814 }
4815
4816 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07004817 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004818 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4819
Stephen Boyd3a35f0b2012-01-11 16:18:26 -08004820 clk_disable(&cxo_clk.c);
4821
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004822 return ret;
4823}
4824#else /* !CONFIG_DEBUG_FS */
4825static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
4826{
4827 return -EINVAL;
4828}
4829
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07004830static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004831{
4832 return 0;
4833}
4834#endif /* CONFIG_DEBUG_FS */
4835
4836static struct clk_ops measure_clk_ops = {
4837 .set_parent = measure_clk_set_parent,
4838 .get_rate = measure_clk_get_rate,
4839 .is_local = local_clk_is_local,
4840};
4841
Matt Wagantall8b38f942011-08-02 18:23:18 -07004842static struct measure_clk measure_clk = {
4843 .c = {
4844 .dbg_name = "measure_clk",
4845 .ops = &measure_clk_ops,
4846 CLK_INIT(measure_clk.c),
4847 },
4848 .multiplier = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004849};
4850
Tianyi Goua8b3cce2011-11-08 14:37:26 -08004851static struct clk_lookup msm_clocks_8064[] = {
Tianyi Gou41515e22011-09-01 19:37:43 -07004852 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07004853 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004854 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
Tianyi Gouc29c3242011-10-12 21:02:15 -07004855 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004856 CLK_LOOKUP("measure", measure_clk.c, "debug"),
4857
Matt Wagantallb2710b82011-11-16 19:55:17 -08004858 CLK_DUMMY("bus_clk", AFAB_CLK, "msm_apps_fab", 0),
4859 CLK_DUMMY("bus_a_clk", AFAB_A_CLK, "msm_apps_fab", 0),
4860 CLK_DUMMY("bus_clk", SFAB_CLK, "msm_sys_fab", 0),
4861 CLK_DUMMY("bus_a_clk", SFAB_A_CLK, "msm_sys_fab", 0),
4862 CLK_DUMMY("bus_clk", SFPB_CLK, "msm_sys_fpb", 0),
4863 CLK_DUMMY("bus_a_clk", SFPB_A_CLK, "msm_sys_fpb", 0),
4864 CLK_DUMMY("bus_clk", MMFAB_CLK, "msm_mm_fab", 0),
4865 CLK_DUMMY("bus_a_clk", MMFAB_A_CLK, "msm_mm_fab", 0),
4866 CLK_DUMMY("bus_clk", CFPB_CLK, "msm_cpss_fpb", 0),
4867 CLK_DUMMY("bus_a_clk", CFPB_A_CLK, "msm_cpss_fpb", 0),
4868 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
4869 CLK_DUMMY("mem_a_clk", EBI1_A_CLK, "msm_bus", 0),
4870
4871 CLK_DUMMY("ebi1_clk", EBI1_CLK, NULL, 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07004872 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
4873 CLK_DUMMY("dfab_a_clk", DFAB_A_CLK, NULL, 0),
Matt Wagantallb2710b82011-11-16 19:55:17 -08004874 CLK_DUMMY("bus_clk", MMFPB_CLK, NULL, 0),
4875 CLK_DUMMY("bus_a_clk", MMFPB_A_CLK, NULL, 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07004876
Matt Wagantall7625a4c2011-11-01 16:17:53 -07004877 CLK_LOOKUP("core_clk", gp0_clk.c, NULL),
4878 CLK_LOOKUP("core_clk", gp1_clk.c, NULL),
4879 CLK_LOOKUP("core_clk", gp2_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004880 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
4881 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
4882 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
4883 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
4884 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, NULL),
4885 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, NULL),
4886 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
4887 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, NULL),
4888 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
4889 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, NULL),
4890 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, NULL),
4891 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
4892 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
4893 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07004894 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004895 CLK_LOOKUP("pmem_clk", pmem_clk.c, NULL),
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -07004896 CLK_DUMMY("core_clk", PRNG_CLK, "msm_rng.0", OFF),
Tianyi Gou43208a02011-09-27 15:35:13 -07004897 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
4898 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
4899 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
4900 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07004901 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
4902 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Manu Gautam5143b252012-01-05 19:25:23 -08004903 CLK_LOOKUP("alt_core_clk", usb_hs1_xcvr_clk.c, "msm_otg"),
4904 CLK_LOOKUP("alt_core_clk", usb_hs3_xcvr_clk.c, "msm_ehci_host.0"),
4905 CLK_LOOKUP("alt_core_clk", usb_hs4_xcvr_clk.c, "msm_ehci_host.1"),
4906 CLK_LOOKUP("src_clk", usb_fs1_src_clk.c, NULL),
4907 CLK_LOOKUP("alt_core_clk", usb_fs1_xcvr_clk.c, NULL),
4908 CLK_LOOKUP("sys_clk", usb_fs1_sys_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07004909 CLK_LOOKUP("iface_clk", ce1_p_clk.c, NULL),
4910 CLK_LOOKUP("core_clk", ce1_core_clk.c, NULL),
Ramesh Masavarapu28311912011-10-27 11:04:12 -07004911 CLK_LOOKUP("ref_clk", sata_phy_ref_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07004912 CLK_LOOKUP("cfg_clk", sata_phy_cfg_clk.c, NULL),
Ramesh Masavarapu28311912011-10-27 11:04:12 -07004913 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qce.0"),
4914 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qcrypto.0"),
4915 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qce.0"),
4916 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qcrypto.0"),
4917 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qce.0"),
4918 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qcrypto.0"),
Tianyi Gou41515e22011-09-01 19:37:43 -07004919 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
4920 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, NULL),
4921 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
4922 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, NULL),
4923 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, NULL),
4924 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, NULL),
4925 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, NULL),
4926 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07004927 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Manu Gautam5143b252012-01-05 19:25:23 -08004928 CLK_LOOKUP("iface_clk", usb_fs1_p_clk.c, NULL),
4929 CLK_LOOKUP("iface_clk", usb_hs1_p_clk.c, "msm_otg"),
Manu Gautam7483f172011-11-08 15:22:26 +05304930 CLK_LOOKUP("iface_clk", usb_hs3_p_clk.c, "msm_ehci_host.0"),
4931 CLK_LOOKUP("iface_clk", usb_hs4_p_clk.c, "msm_ehci_host.1"),
Tianyi Gou43208a02011-09-27 15:35:13 -07004932 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
4933 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
4934 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
4935 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
Tianyi Gou41515e22011-09-01 19:37:43 -07004936 CLK_LOOKUP("iface_clk", pcie_p_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004937 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
4938 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07004939 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
4940 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
4941 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
4942 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
4943 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07004944 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
4945 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
4946 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
4947 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
4948 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07004949 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07004950 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
4951 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
4952 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07004953 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07004954 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
4955 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
4956 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07004957 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07004958 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
4959 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
4960 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07004961 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, NULL),
4962 CLK_LOOKUP("csi_pix_clk", csi_pix1_clk.c, NULL),
4963 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, NULL),
4964 CLK_LOOKUP("csi_rdi_clk", csi_rdi1_clk.c, NULL),
4965 CLK_LOOKUP("csi_rdi_clk", csi_rdi2_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07004966 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
4967 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, NULL),
4968 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, NULL),
4969 CLK_LOOKUP("csiphy_timer_clk", csi2phy_timer_clk.c, NULL),
4970 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
4971 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
4972 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
4973 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
4974 CLK_DUMMY("rgb_tv_clk", RGB_TV_CLK, NULL, OFF),
4975 CLK_DUMMY("npl_tv_clk", NPL_TV_CLK, NULL, OFF),
Pu Chen86b4be92011-11-03 17:27:57 -07004976 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07004977 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
4978 CLK_LOOKUP("bus_clk", gfx3d_axi_clk.c, "footswitch-8x60.2"),
Tianyi Gou621f8742011-09-01 21:45:01 -07004979 CLK_LOOKUP("iface_clk", vcap_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07004980 CLK_LOOKUP("iface_clk", vcap_p_clk.c, "footswitch-8x60.10"),
4981 CLK_LOOKUP("bus_clk", vcap_axi_clk.c, "footswitch-8x60.10"),
Tianyi Gou621f8742011-09-01 21:45:01 -07004982 CLK_LOOKUP("core_clk", vcap_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07004983 CLK_LOOKUP("core_clk", vcap_clk.c, "footswitch-8x60.10"),
Tianyi Gou621f8742011-09-01 21:45:01 -07004984 CLK_LOOKUP("vcap_npl_clk", vcap_npl_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07004985 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Tianyi Gou621f8742011-09-01 21:45:01 -07004986 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
4987 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07004988 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07004989 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07004990 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07004991 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07004992 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08004993 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07004994 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08004995 CLK_LOOKUP("lut_clk", lut_mdp_clk.c, "footswitch-8x60.4"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07004996 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07004997 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Tianyi Gou41515e22011-09-01 19:37:43 -07004998 CLK_DUMMY("tv_src_clk", TV_SRC_CLK, NULL, OFF),
Greg Griscofa47b532011-11-11 10:32:06 -08004999 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005000 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005001 CLK_DUMMY("mdp_tv_clk", MDP_TV_CLK, NULL, OFF),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005002 CLK_DUMMY("tv_clk", MDP_TV_CLK, "footswitch-8x60.4", OFF),
Tianyi Gou41515e22011-09-01 19:37:43 -07005003 CLK_DUMMY("hdmi_clk", HDMI_TV_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005004 CLK_LOOKUP("core_clk", hdmi_app_clk.c, NULL),
5005 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005006 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005007 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005008 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005009 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005010 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5011 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5012 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5013 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5014 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5015 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5016 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005017 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
5018 CLK_LOOKUP("csi_pclk", csi_p_clk.c, NULL),
5019 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5020 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5021 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5022 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Pu Chen86b4be92011-11-03 17:27:57 -07005023 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005024 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005025 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, NULL),
5026 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, NULL),
5027 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005028 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005029 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
5030 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005031 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005032 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005033 CLK_LOOKUP("iface_clk", smmu_p_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005034 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005035 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Greg Griscofa47b532011-11-11 10:32:06 -08005036 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005037 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005038 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005039 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005040 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005041 CLK_LOOKUP("iface_pclk", vpe_p_clk.c, "footswitch-8x60.9"),
Tianyi Gouc29c3242011-10-12 21:02:15 -07005042 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5043 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5044 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5045 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5046 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5047 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5048 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5049 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5050 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5051 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5052 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
Tianyi Goudd8138a2011-10-20 15:46:00 -07005053 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5054 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005055 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, NULL),
5056 CLK_LOOKUP("core_clk", vpe_axi_clk.c, NULL),
5057 CLK_LOOKUP("core_clk", mdp_axi_clk.c, NULL),
5058 CLK_LOOKUP("core_clk", vcap_axi_clk.c, NULL),
5059 CLK_LOOKUP("core_clk", rot_axi_clk.c, NULL),
5060 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, NULL),
5061 CLK_LOOKUP("core_clk", vfe_axi_clk.c, NULL),
5062 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, NULL),
5063 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005064 CLK_LOOKUP("core_clk", gfx3d_axi_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005065 CLK_DUMMY("dfab_dsps_clk", DFAB_DSPS_CLK, NULL, 0),
Manu Gautam5143b252012-01-05 19:25:23 -08005066 CLK_DUMMY("core_clk", DFAB_USB_HS_CLK, "msm_otg", 0),
5067 CLK_DUMMY("core_clk", DFAB_USB_HS3_CLK, "msm_ehci_host.0", 0),
5068 CLK_DUMMY("core_clk", DFAB_USB_HS4_CLK, "msm_ehci_host.1", 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005069 CLK_DUMMY("bus_clk", DFAB_SDC1_CLK, NULL, 0),
5070 CLK_DUMMY("bus_clk", DFAB_SDC2_CLK, NULL, 0),
5071 CLK_DUMMY("bus_clk", DFAB_SDC3_CLK, NULL, 0),
5072 CLK_DUMMY("bus_clk", DFAB_SDC4_CLK, NULL, 0),
5073 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
Stephen Boydef5d1c42011-12-15 20:47:14 -08005074 CLK_DUMMY("bus_clk", DFAB_SCM_CLK, "scm", 0),
Manu Gautam5143b252012-01-05 19:25:23 -08005075 CLK_LOOKUP("alt_core_clk", usb_hsic_xcvr_fs_clk.c, "msm_hsic_host"),
5076 CLK_LOOKUP("phy_clk", usb_hsic_hsic_clk.c, "msm_hsic_host"),
5077 CLK_LOOKUP("cal_clk", usb_hsic_hsio_cal_clk.c, "msm_hsic_host"),
5078 CLK_LOOKUP("core_clk", usb_hsic_system_clk.c, "msm_hsic_host"),
5079 CLK_LOOKUP("iface_clk", usb_hsic_p_clk.c, "msm_hsic_host"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005080
Jeff Ohlstein8c116c72011-10-27 17:34:48 -07005081 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005082
5083 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5084 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5085 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
5086};
5087
Stephen Boyd94625ef2011-07-12 17:06:01 -07005088static struct clk_lookup msm_clocks_8960_v1[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005089 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
5090 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
5091 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
5092 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005093 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005094
Matt Wagantallb2710b82011-11-16 19:55:17 -08005095 CLK_LOOKUP("bus_clk", afab_clk.c, "msm_apps_fab"),
5096 CLK_LOOKUP("bus_a_clk", afab_a_clk.c, "msm_apps_fab"),
5097 CLK_LOOKUP("bus_clk", cfpb_clk.c, "msm_cpss_fpb"),
5098 CLK_LOOKUP("bus_a_clk", cfpb_a_clk.c, "msm_cpss_fpb"),
5099 CLK_LOOKUP("bus_clk", sfab_clk.c, "msm_sys_fab"),
5100 CLK_LOOKUP("bus_a_clk", sfab_a_clk.c, "msm_sys_fab"),
5101 CLK_LOOKUP("bus_clk", sfpb_clk.c, "msm_sys_fpb"),
5102 CLK_LOOKUP("bus_a_clk", sfpb_a_clk.c, "msm_sys_fpb"),
5103 CLK_LOOKUP("bus_clk", mmfab_clk.c, "msm_mm_fab"),
5104 CLK_LOOKUP("bus_a_clk", mmfab_a_clk.c, "msm_mm_fab"),
5105 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
5106 CLK_LOOKUP("mem_a_clk", ebi1_a_clk.c, "msm_bus"),
5107
5108 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
5109 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
5110 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
5111 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
5112 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8960"),
5113 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005114
Matt Wagantall7625a4c2011-11-01 16:17:53 -07005115 CLK_LOOKUP("core_clk", gp0_clk.c, NULL),
5116 CLK_LOOKUP("core_clk", gp1_clk.c, NULL),
5117 CLK_LOOKUP("core_clk", gp2_clk.c, NULL),
Matt Wagantalle2522372011-08-17 14:52:21 -07005118 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
5119 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
5120 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
5121 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
5122 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
5123 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
5124 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
5125 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, NULL),
5126 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, NULL),
5127 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, NULL),
5128 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, NULL),
5129 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005130 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005131 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005132 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
5133 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005134 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
5135 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
5136 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
5137 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, NULL),
5138 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005139 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005140 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005141 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005142 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Vikram Mulukutladd0a2372011-09-19 15:58:21 -07005143 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_sps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07005144 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005145 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5146 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5147 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5148 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
5149 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005150 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005151 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005152 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Manu Gautam5143b252012-01-05 19:25:23 -08005153 CLK_LOOKUP("alt_core_clk", usb_hs1_xcvr_clk.c, "msm_otg"),
5154 CLK_LOOKUP("phy_clk", usb_phy0_clk.c, "msm_otg"),
5155 CLK_LOOKUP("alt_core_clk", usb_fs1_xcvr_clk.c, NULL),
5156 CLK_LOOKUP("sys_clk", usb_fs1_sys_clk.c, NULL),
5157 CLK_LOOKUP("src_clk", usb_fs1_src_clk.c, NULL),
5158 CLK_LOOKUP("alt_core_clk", usb_fs2_xcvr_clk.c, NULL),
5159 CLK_LOOKUP("sys_clk", usb_fs2_sys_clk.c, NULL),
5160 CLK_LOOKUP("src_clk", usb_fs2_src_clk.c, NULL),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005161 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005162 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qcrypto.0"),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005163 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005164 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qcrypto.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005165 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005166 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005167 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005168 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
5169 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07005170 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
5171 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005172 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
5173 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, NULL),
5174 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005175 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005176 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005177 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.12"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005178 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Manu Gautam5143b252012-01-05 19:25:23 -08005179 CLK_LOOKUP("iface_clk", usb_fs1_p_clk.c, NULL),
5180 CLK_LOOKUP("iface_clk", usb_fs2_p_clk.c, NULL),
5181 CLK_LOOKUP("iface_clk", usb_hs1_p_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005182 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5183 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5184 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5185 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
5186 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005187 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5188 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005189 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
5190 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
5191 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
5192 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
5193 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Kevin Chan09f4e662011-12-16 08:17:02 -08005194 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-001a"),
5195 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-006c"),
5196 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-0048"),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005197 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_csid.0"),
5198 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_csid.1"),
5199 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_csid.0"),
5200 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csid.1"),
5201 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_csid.0"),
5202 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_csid.1"),
Kevin Chane12c6672011-10-26 11:55:26 -07005203 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, "msm_ispif.0"),
5204 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, "msm_ispif.0"),
Kevin Chanf6216f22011-10-25 18:40:11 -07005205 CLK_LOOKUP("csiphy_timer_src_clk",
5206 csiphy_timer_src_clk.c, "msm_csiphy.0"),
5207 CLK_LOOKUP("csiphy_timer_src_clk",
5208 csiphy_timer_src_clk.c, "msm_csiphy.1"),
5209 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, "msm_csiphy.0"),
5210 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, "msm_csiphy.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005211 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5212 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5213 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5214 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005215 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005216 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005217 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005218 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005219 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005220 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5221 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005222 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005223 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005224 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005225 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005226 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005227 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005228 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005229 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005230 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005231 CLK_LOOKUP("lut_clk", lut_mdp_clk.c, "footswitch-8x60.4"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005232 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005233 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005234 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005235 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005236 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
5237 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005238 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005239 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005240 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005241 CLK_LOOKUP("tv_clk", mdp_tv_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005242 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005243 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Kevin Chana0853122011-11-07 19:48:44 -08005244 CLK_LOOKUP("vpe_clk", vpe_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005245 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Kevin Chan5827c552011-10-28 18:36:32 -07005246 CLK_LOOKUP("vfe_clk", vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005247 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Kevin Chan5827c552011-10-28 18:36:32 -07005248 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005249 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5250 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5251 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5252 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5253 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5254 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5255 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005256 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005257 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.0"),
5258 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005259 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5260 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5261 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5262 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005263 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005264 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005265 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005266 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005267 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005268 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005269 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
5270 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005271 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005272 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005273 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005274 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005275 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005276 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07005277 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005278 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005279 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005280 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005281 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005282 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Kevin Chan5827c552011-10-28 18:36:32 -07005283 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005284 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Kevin Chana0853122011-11-07 19:48:44 -08005285 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005286 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005287 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5288 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5289 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5290 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5291 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5292 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5293 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5294 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5295 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5296 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5297 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
5298 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5299 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Matt Wagantalle604d712011-10-21 15:38:18 -07005300 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
5301 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
5302 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
5303 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
5304 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
5305 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
5306 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
5307 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
5308 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
5309 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
5310 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
5311 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Gopikrishnaiah Anandan4d05ed32012-01-13 11:08:44 -08005312
5313 CLK_LOOKUP("mdp_iommu_clk", mdp_axi_clk.c, "msm_vidc.0"),
5314 CLK_LOOKUP("rot_iommu_clk", rot_axi_clk.c, "msm_vidc.0"),
5315 CLK_LOOKUP("vcodec_iommu0_clk", vcodec_axi_a_clk.c, "msm_vidc.0"),
5316 CLK_LOOKUP("vcodec_iommu1_clk", vcodec_axi_b_clk.c, "msm_vidc.0"),
5317 CLK_LOOKUP("smmu_iface_clk", smmu_p_clk.c, "msm_vidc.0"),
5318
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005319 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
Manu Gautam5143b252012-01-05 19:25:23 -08005320 CLK_LOOKUP("core_clk", dfab_usb_hs_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005321 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
5322 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
5323 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
5324 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
5325 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Yan He160633e2011-06-30 12:18:56 -07005326 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
Stephen Boyd1c51a492011-10-26 12:11:47 -07005327 CLK_LOOKUP("bus_clk", dfab_bam_dmux_clk.c, "BAM_RMNT"),
Stephen Boydef5d1c42011-12-15 20:47:14 -08005328 CLK_LOOKUP("bus_clk", dfab_scm_clk.c, "scm"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005329
Matt Wagantalle1a86062011-08-18 17:46:10 -07005330 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005331
5332 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5333 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5334 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
Stephen Boyd3939c8d2011-08-29 17:36:22 -07005335 CLK_LOOKUP("q6sw_clk", q6sw_clk, NULL),
5336 CLK_LOOKUP("q6fw_clk", q6fw_clk, NULL),
5337 CLK_LOOKUP("q6_func_clk", q6_func_clk, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005338};
5339
Stephen Boyd94625ef2011-07-12 17:06:01 -07005340static struct clk_lookup msm_clocks_8960_v2[] __initdata = {
5341 CLK_LOOKUP("cam_clk", cam2_clk.c, NULL),
5342 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
5343 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
Kevin Chane12c6672011-10-26 11:55:26 -07005344 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, "msm_ispif.0"),
5345 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, "msm_ispif.0"),
5346 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, "msm_ispif.0"),
Stephen Boyd94625ef2011-07-12 17:06:01 -07005347 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
5348 CLK_LOOKUP("csi2phy_timer_clk", csi2phy_timer_clk.c, NULL),
Manu Gautam5143b252012-01-05 19:25:23 -08005349 CLK_LOOKUP("alt_core_clk", usb_hsic_xcvr_fs_clk.c, "msm_hsic_host"),
5350 CLK_LOOKUP("phy_clk", usb_hsic_hsic_clk.c, "msm_hsic_host"),
5351 CLK_LOOKUP("cal_clk", usb_hsic_hsio_cal_clk.c, "msm_hsic_host"),
5352 CLK_LOOKUP("core_clk", usb_hsic_system_clk.c, "msm_hsic_host"),
5353 CLK_LOOKUP("iface_clk", usb_hsic_p_clk.c, "msm_hsic_host"),
Stephen Boyd94625ef2011-07-12 17:06:01 -07005354};
5355
5356/* Add v2 clocks dynamically at runtime */
5357static struct clk_lookup msm_clocks_8960[ARRAY_SIZE(msm_clocks_8960_v1) +
5358 ARRAY_SIZE(msm_clocks_8960_v2)];
5359
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005360/*
5361 * Miscellaneous clock register initializations
5362 */
5363
5364/* Read, modify, then write-back a register. */
5365static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
5366{
5367 uint32_t regval = readl_relaxed(reg);
5368 regval &= ~mask;
5369 regval |= val;
5370 writel_relaxed(regval, reg);
5371}
5372
Tianyi Gou41515e22011-09-01 19:37:43 -07005373static void __init set_fsm_mode(void __iomem *mode_reg)
5374{
5375 u32 regval = readl_relaxed(mode_reg);
5376
5377 /*De-assert reset to FSM */
5378 regval &= ~BIT(21);
5379 writel_relaxed(regval, mode_reg);
5380
5381 /* Program bias count */
Tianyi Gou358c3862011-10-18 17:03:41 -07005382 regval &= ~BM(19, 14);
5383 regval |= BVAL(19, 14, 0x1);
5384 writel_relaxed(regval, mode_reg);
5385
5386 /* Program lock count */
Tianyi Gou41515e22011-09-01 19:37:43 -07005387 regval &= ~BM(13, 8);
5388 regval |= BVAL(13, 8, 0x8);
5389 writel_relaxed(regval, mode_reg);
5390
5391 /*Enable PLL FSM voting */
5392 regval |= BIT(20);
5393 writel_relaxed(regval, mode_reg);
5394}
5395
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005396static void __init reg_init(void)
5397{
Stephen Boydd471e7a2011-11-19 01:37:39 -08005398 void __iomem *imem_reg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005399 /* Deassert MM SW_RESET_ALL signal. */
5400 writel_relaxed(0, SW_RESET_ALL_REG);
5401
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005402 /*
5403 * Some bits are only used on either 8960 or 8064 and are marked as
5404 * reserved bits on the other SoC. Writing to these reserved bits
5405 * should have no effect.
5406 */
Stephen Boydd471e7a2011-11-19 01:37:39 -08005407 /*
5408 * Initialize MM AHB registers: Enable the FPB clock and disable HW
5409 * gating on 8960v1/8064 for all clocks. Also set VFE_AHB's
5410 * FORCE_CORE_ON bit to prevent its memory from being collapsed when
5411 * the clock is halted. The sleep and wake-up delays are set to safe
5412 * values.
5413 */
5414 if (cpu_is_msm8960() &&
5415 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5416 rmwreg(0x44000000, AHB_EN_REG, 0x6C000103);
5417 writel_relaxed(0x3C7097F9, AHB_EN2_REG);
5418 } else {
5419 rmwreg(0x00000003, AHB_EN_REG, 0x6C000103);
5420 writel_relaxed(0x000007F9, AHB_EN2_REG);
5421 }
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005422 if (cpu_is_apq8064())
5423 rmwreg(0x00000000, AHB_EN3_REG, 0x00000001);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005424
5425 /* Deassert all locally-owned MM AHB resets. */
5426 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
Tianyi Gou41515e22011-09-01 19:37:43 -07005427 rmwreg(0, SW_RESET_AHB2_REG, 0x0000000F);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005428
5429 /* Initialize MM AXI registers: Enable HW gating for all clocks that
5430 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
5431 * delays to safe values. */
Stephen Boydd471e7a2011-11-19 01:37:39 -08005432 if (cpu_is_msm8960() &&
5433 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 3) {
5434 rmwreg(0x0003AFF9, MAXI_EN_REG, 0x0803FFFF);
5435 rmwreg(0x3A27FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
Gopikrishnaiah Anandan83b6e852012-01-05 17:47:02 -08005436 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
Stephen Boydd471e7a2011-11-19 01:37:39 -08005437 } else {
5438 rmwreg(0x000007F9, MAXI_EN_REG, 0x0803FFFF);
5439 rmwreg(0x3027FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
5440 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
5441 }
Matt Wagantall53d968f2011-07-19 13:22:53 -07005442 rmwreg(0x0027FCFF, MAXI_EN3_REG, 0x003FFFFF);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005443 if (cpu_is_apq8064())
5444 rmwreg(0x009FE4FF, MAXI_EN5_REG, 0x01FFEFFF);
Stephen Boydd471e7a2011-11-19 01:37:39 -08005445 if (cpu_is_msm8960() &&
5446 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2)
5447 rmwreg(0x00003C38, SAXI_EN_REG, 0x00003FFF);
5448 else
5449 rmwreg(0x000003C7, SAXI_EN_REG, 0x00003FFF);
5450
5451 /* Enable IMEM's clk_on signal */
5452 imem_reg = ioremap(0x04b00040, 4);
5453 if (imem_reg) {
5454 writel_relaxed(0x3, imem_reg);
5455 iounmap(imem_reg);
5456 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005457
5458 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
5459 * memories retain state even when not clocked. Also, set sleep and
5460 * wake-up delays to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005461 rmwreg(0x00000000, CSI0_CC_REG, 0x00000410);
5462 rmwreg(0x00000000, CSI1_CC_REG, 0x00000410);
5463 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, 0xE0FF0010);
5464 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, 0xE0FF0010);
5465 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, 0xE0FF0010);
5466 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, 0xE0FF0010);
Tarun Karra6fbc00a2011-12-13 09:23:47 -07005467 rmwreg(0xC0FF0000, GFX3D_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005468 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0010);
5469 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0010);
5470 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
5471 rmwreg(0x80FF0000, MDP_LUT_CC_REG, 0xE0FF0010);
5472 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005473 rmwreg(0x000004FF, TV_CC2_REG, 0x000007FF);
5474 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
5475 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FF4010);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005476 rmwreg(0x800000FF, VFE_CC2_REG, 0xE00000FF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005477 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005478 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005479 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
5480 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
5481 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
5482 }
5483 if (cpu_is_apq8064()) {
5484 rmwreg(0x00000000, TV_CC_REG, 0x00004010);
Tianyi Gou621f8742011-09-01 21:45:01 -07005485 rmwreg(0x80FF0000, VCAP_CC_REG, 0xE0FF1010);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005486 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005487
Tianyi Gou41515e22011-09-01 19:37:43 -07005488 /*
5489 * Initialize USB_HS_HCLK_FS registers: Set FORCE_C_ON bits so that
5490 * core remain active during halt state of the clk. Also, set sleep
5491 * and wake-up value to max.
5492 */
5493 rmwreg(0x0000004F, USB_HS1_HCLK_FS_REG, 0x0000007F);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005494 if (cpu_is_apq8064()) {
5495 rmwreg(0x0000004F, USB_HS3_HCLK_FS_REG, 0x0000007F);
5496 rmwreg(0x0000004F, USB_HS4_HCLK_FS_REG, 0x0000007F);
5497 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005498
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005499 /* De-assert MM AXI resets to all hardware blocks. */
5500 writel_relaxed(0, SW_RESET_AXI_REG);
5501
5502 /* Deassert all MM core resets. */
5503 writel_relaxed(0, SW_RESET_CORE_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005504 writel_relaxed(0, SW_RESET_CORE2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005505
5506 /* Reset 3D core once more, with its clock enabled. This can
5507 * eventually be done as part of the GDFS footswitch driver. */
5508 clk_set_rate(&gfx3d_clk.c, 27000000);
5509 clk_enable(&gfx3d_clk.c);
5510 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
5511 mb();
5512 udelay(5);
5513 writel_relaxed(0, SW_RESET_CORE_REG);
5514 /* Make sure reset is de-asserted before clock is disabled. */
5515 mb();
5516 clk_disable(&gfx3d_clk.c);
5517
5518 /* Enable TSSC and PDM PXO sources. */
5519 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
5520 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
5521
5522 /* Source SLIMBus xo src from slimbus reference clock */
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005523 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005524 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005525
5526 /* Source the dsi_byte_clks from the DSI PHY PLLs */
5527 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
5528 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
Tianyi Gou41515e22011-09-01 19:37:43 -07005529
5530 /* Source the sata_phy_ref_clk from PXO */
5531 if (cpu_is_apq8064())
5532 rmwreg(0, SATA_PHY_REF_CLK_CTL_REG, 0x1);
5533
5534 /*
5535 * TODO: Programming below PLLs is temporary and needs to be removed
5536 * after bootloaders program them.
5537 */
5538 if (cpu_is_apq8064()) {
5539 u32 regval, is_pll_enabled;
5540
5541 /* Program pxo_src_clk to source from PXO */
5542 rmwreg(0x1, PXO_SRC_CLK_CTL_REG, 0x7);
5543
5544 /* Check if PLL8 is active */
5545 is_pll_enabled = readl_relaxed(BB_PLL8_STATUS_REG) & BIT(16);
5546 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005547 /* Ref clk = 27MHz and program pll8 to 384MHz */
5548 writel_relaxed(0xE, BB_PLL8_L_VAL_REG);
5549 writel_relaxed(0x2, BB_PLL8_M_VAL_REG);
5550 writel_relaxed(0x9, BB_PLL8_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005551
5552 regval = readl_relaxed(BB_PLL8_CONFIG_REG);
5553
5554 /* Enable the main output and the MN accumulator */
5555 regval |= BIT(23) | BIT(22);
5556
5557 /* Set pre-divider and post-divider values to 1 and 1 */
5558 regval &= ~BIT(19);
5559 regval &= ~BM(21, 20);
5560
5561 writel_relaxed(regval, BB_PLL8_CONFIG_REG);
5562
5563 /* Set VCO frequency */
5564 rmwreg(0x10000, BB_PLL8_CONFIG_REG, 0x30000);
5565
5566 /* Enable AUX output */
5567 regval = readl_relaxed(BB_PLL8_TEST_CTL_REG);
5568 regval |= BIT(12);
5569 writel_relaxed(regval, BB_PLL8_TEST_CTL_REG);
5570
5571 set_fsm_mode(BB_PLL8_MODE_REG);
5572 }
5573 /* Check if PLL3 is active */
5574 is_pll_enabled = readl_relaxed(GPLL1_STATUS_REG) & BIT(16);
5575 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005576 /* Ref clk = 27MHz and program pll3 to 1200MHz */
5577 writel_relaxed(0x2C, GPLL1_L_VAL_REG);
5578 writel_relaxed(0x4, GPLL1_M_VAL_REG);
5579 writel_relaxed(0x9, GPLL1_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005580
5581 regval = readl_relaxed(GPLL1_CONFIG_REG);
5582
5583 /* Set pre-divider and post-divider values to 1 and 1 */
5584 regval &= ~BIT(15);
5585 regval |= BIT(16);
5586
5587 writel_relaxed(regval, GPLL1_CONFIG_REG);
5588
5589 /* Set VCO frequency */
5590 rmwreg(0x180, GPLL1_CONFIG_REG, 0x180);
5591 }
5592 /* Check if PLL14 is active */
5593 is_pll_enabled = readl_relaxed(BB_PLL14_STATUS_REG) & BIT(16);
5594 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005595 /* Ref clk = 27MHz and program pll14 to 480MHz */
5596 writel_relaxed(0x11, BB_PLL14_L_VAL_REG);
5597 writel_relaxed(0x7, BB_PLL14_M_VAL_REG);
5598 writel_relaxed(0x9, BB_PLL14_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005599
5600 regval = readl_relaxed(BB_PLL14_CONFIG_REG);
5601
5602 /* Enable the main output and the MN accumulator */
5603 regval |= BIT(23) | BIT(22);
5604
5605 /* Set pre-divider and post-divider values to 1 and 1 */
5606 regval &= ~BIT(19);
5607 regval &= ~BM(21, 20);
5608
5609 writel_relaxed(regval, BB_PLL14_CONFIG_REG);
5610
5611 /* Set VCO frequency */
5612 rmwreg(0x10000, BB_PLL14_CONFIG_REG, 0x30000);
5613
Tianyi Gou41515e22011-09-01 19:37:43 -07005614 set_fsm_mode(BB_PLL14_MODE_REG);
5615 }
Tianyi Gou621f8742011-09-01 21:45:01 -07005616 /* Program PLL2 to 800MHz with ref clk = 27MHz */
5617 writel_relaxed(0x1D, MM_PLL1_L_VAL_REG);
5618 writel_relaxed(0x11, MM_PLL1_M_VAL_REG);
5619 writel_relaxed(0x1B, MM_PLL1_N_VAL_REG);
5620
5621 regval = readl_relaxed(MM_PLL1_CONFIG_REG);
5622
5623 /* Enable the main output and the MN accumulator */
5624 regval |= BIT(23) | BIT(22);
5625
5626 /* Set pre-divider and post-divider values to 1 and 1 */
5627 regval &= ~BIT(19);
5628 regval &= ~BM(21, 20);
5629
5630 writel_relaxed(regval, MM_PLL1_CONFIG_REG);
5631
5632 /* Set VCO frequency */
5633 rmwreg(0x20000, MM_PLL1_CONFIG_REG, 0x30000);
5634
Tianyi Gou621f8742011-09-01 21:45:01 -07005635 /* Program PLL15 to 975MHz with ref clk = 27MHz */
5636 writel_relaxed(0x24, MM_PLL3_L_VAL_REG);
5637 writel_relaxed(0x1, MM_PLL3_M_VAL_REG);
5638 writel_relaxed(0x9, MM_PLL3_N_VAL_REG);
5639
5640 regval = readl_relaxed(MM_PLL3_CONFIG_REG);
5641
5642 /* Enable the main output and the MN accumulator */
5643 regval |= BIT(23) | BIT(22);
5644
5645 /* Set pre-divider and post-divider values to 1 and 1 */
5646 regval &= ~BIT(19);
5647 regval &= ~BM(21, 20);
5648
5649 writel_relaxed(regval, MM_PLL3_CONFIG_REG);
5650
5651 /* Set VCO frequency */
5652 rmwreg(0x20000, MM_PLL3_CONFIG_REG, 0x30000);
5653
5654 /* Enable AUX output */
5655 regval = readl_relaxed(MM_PLL3_TEST_CTL_REG);
5656 regval |= BIT(12);
5657 writel_relaxed(regval, MM_PLL3_TEST_CTL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005658
5659 /* Check if PLL4 is active */
5660 is_pll_enabled = readl_relaxed(LCC_PLL0_STATUS_REG) & BIT(16);
5661 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005662 /* Ref clk = 27MHz and program pll4 to 393.2160MHz */
5663 writel_relaxed(0xE, LCC_PLL0_L_VAL_REG);
5664 writel_relaxed(0x27A, LCC_PLL0_M_VAL_REG);
5665 writel_relaxed(0x465, LCC_PLL0_N_VAL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005666
5667 regval = readl_relaxed(LCC_PLL0_CONFIG_REG);
5668
5669 /* Enable the main output and the MN accumulator */
5670 regval |= BIT(23) | BIT(22);
5671
5672 /* Set pre-divider and post-divider values to 1 and 1 */
5673 regval &= ~BIT(19);
5674 regval &= ~BM(21, 20);
5675
5676 /* Set VCO frequency */
5677 regval &= ~BM(17, 16);
5678 writel_relaxed(regval, LCC_PLL0_CONFIG_REG);
5679
5680 set_fsm_mode(LCC_PLL0_MODE_REG);
5681 }
5682
5683 /* Enable PLL4 source on the LPASS Primary PLL Mux */
5684 writel_relaxed(0x1, LCC_PRI_PLL_CLK_CTL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005685 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005686}
5687
Stephen Boyd94625ef2011-07-12 17:06:01 -07005688struct clock_init_data msm8960_clock_init_data __initdata;
5689
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005690/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07005691static void __init msm8960_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005692{
Stephen Boyd94625ef2011-07-12 17:06:01 -07005693 size_t num_lookups = ARRAY_SIZE(msm_clocks_8960_v1);
Tianyi Gou41515e22011-09-01 19:37:43 -07005694
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005695 xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8960");
5696 if (IS_ERR(xo_pxo)) {
5697 pr_err("%s: msm_xo_get(PXO) failed.\n", __func__);
5698 BUG();
5699 }
Matt Wagantalled90b002011-12-12 21:22:43 -08005700 xo_cxo = msm_xo_get(MSM_XO_CXO, "clock-8960");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005701 if (IS_ERR(xo_cxo)) {
5702 pr_err("%s: msm_xo_get(CXO) failed.\n", __func__);
5703 BUG();
5704 }
5705
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005706 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou41515e22011-09-01 19:37:43 -07005707 memcpy(msm_clocks_8960, msm_clocks_8960_v1,
5708 sizeof(msm_clocks_8960_v1));
5709 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5710 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8960_v2;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005711
5712 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8960_v2,
5713 sizeof(gfx3d_clk.c.fmax));
5714 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8960_v2,
5715 sizeof(ijpeg_clk.c.fmax));
5716 memcpy(vfe_clk.c.fmax, fmax_vfe_8960_v2,
5717 sizeof(vfe_clk.c.fmax));
5718
Tianyi Gou41515e22011-09-01 19:37:43 -07005719 memcpy(msm_clocks_8960 + ARRAY_SIZE(msm_clocks_8960_v1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07005720 msm_clocks_8960_v2, sizeof(msm_clocks_8960_v2));
Tianyi Gou41515e22011-09-01 19:37:43 -07005721 num_lookups = ARRAY_SIZE(msm_clocks_8960);
5722 }
5723 msm8960_clock_init_data.size = num_lookups;
Stephen Boyd94625ef2011-07-12 17:06:01 -07005724 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005725
5726 /*
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005727 * Change the freq tables for and voltage requirements for
5728 * clocks which differ between 8960 and 8064.
Tianyi Gou41515e22011-09-01 19:37:43 -07005729 */
5730 if (cpu_is_apq8064()) {
5731 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8064;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005732
5733 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8064,
5734 sizeof(gfx3d_clk.c.fmax));
5735 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8064,
5736 sizeof(ijpeg_clk.c.fmax));
5737 memcpy(mdp_clk.c.fmax, fmax_mdp_8064,
5738 sizeof(ijpeg_clk.c.fmax));
5739 memcpy(tv_src_clk.c.fmax, fmax_tv_src_8064,
5740 sizeof(tv_src_clk.c.fmax));
5741 memcpy(vfe_clk.c.fmax, fmax_vfe_8064,
5742 sizeof(vfe_clk.c.fmax));
5743
Tianyi Gou621f8742011-09-01 21:45:01 -07005744 gmem_axi_clk.c.depends = &gfx3d_axi_clk.c;
Tianyi Gou41515e22011-09-01 19:37:43 -07005745 }
Stephen Boyd94625ef2011-07-12 17:06:01 -07005746
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005747 vote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005748
Vikram Mulukutla489e39e2011-08-31 18:04:05 -07005749 clk_ops_pll.enable = sr_pll_clk_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005750
5751 /* Initialize clock registers. */
5752 reg_init();
5753
5754 /* Initialize rates for clocks that only support one. */
5755 clk_set_rate(&pdm_clk.c, 27000000);
5756 clk_set_rate(&prng_clk.c, 64000000);
5757 clk_set_rate(&mdp_vsync_clk.c, 27000000);
5758 clk_set_rate(&tsif_ref_clk.c, 105000);
5759 clk_set_rate(&tssc_clk.c, 27000000);
5760 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
Tianyi Gou41515e22011-09-01 19:37:43 -07005761 if (cpu_is_apq8064()) {
5762 clk_set_rate(&usb_hs3_xcvr_clk.c, 60000000);
5763 clk_set_rate(&usb_hs4_xcvr_clk.c, 60000000);
5764 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005765 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005766 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou41515e22011-09-01 19:37:43 -07005767 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005768 clk_set_rate(&usb_hsic_xcvr_fs_clk.c, 60000000);
5769 clk_set_rate(&usb_hsic_hsic_src_clk.c, 480000000);
5770 clk_set_rate(&usb_hsic_hsio_cal_clk.c, 9000000);
Stephen Boyd092fd182011-10-21 15:56:30 -07005771 /*
5772 * Set the CSI rates to a safe default to avoid warnings when
5773 * switching csi pix and rdi clocks.
5774 */
5775 clk_set_rate(&csi0_src_clk.c, 27000000);
5776 clk_set_rate(&csi1_src_clk.c, 27000000);
5777 clk_set_rate(&csi2_src_clk.c, 27000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005778
5779 /*
Stephen Boyd60496bb2011-10-17 13:51:37 -07005780 * The halt status bits for these clocks may be incorrect at boot.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005781 * Toggle these clocks on and off to refresh them.
5782 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07005783 rcg_clk_enable(&pdm_clk.c);
5784 rcg_clk_disable(&pdm_clk.c);
5785 rcg_clk_enable(&tssc_clk.c);
5786 rcg_clk_disable(&tssc_clk.c);
Stephen Boyd60496bb2011-10-17 13:51:37 -07005787 if (cpu_is_msm8960() &&
5788 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5789 clk_enable(&usb_hsic_hsic_clk.c);
5790 clk_disable(&usb_hsic_hsic_clk.c);
Stephen Boyd092fd182011-10-21 15:56:30 -07005791 } else
5792 /* CSI2 hardware not present on 8960v1 devices */
5793 pix_rdi_mux_map[2] = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005794
5795 if (machine_is_msm8960_sim()) {
5796 clk_set_rate(&sdc1_clk.c, 48000000);
5797 clk_enable(&sdc1_clk.c);
5798 clk_enable(&sdc1_p_clk.c);
5799 clk_set_rate(&sdc3_clk.c, 48000000);
5800 clk_enable(&sdc3_clk.c);
5801 clk_enable(&sdc3_p_clk.c);
5802 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005803}
5804
Stephen Boydbb600ae2011-08-02 20:11:40 -07005805static int __init msm8960_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005806{
Stephen Boyda3787f32011-09-16 18:55:13 -07005807 int rc;
5808 struct clk *mmfpb_a_clk = clk_get_sys("clock-8960", "mmfpb_a_clk");
Stephen Boyd85436132011-09-16 18:55:13 -07005809 struct clk *cfpb_a_clk = clk_get_sys("clock-8960", "cfpb_a_clk");
Stephen Boyda3787f32011-09-16 18:55:13 -07005810
5811 /* Vote for MMFPB to be at least 76.8MHz when an Apps CPU is active. */
5812 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
5813 PTR_ERR(mmfpb_a_clk)))
5814 return PTR_ERR(mmfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08005815 rc = clk_set_rate(mmfpb_a_clk, 76800000);
Stephen Boyda3787f32011-09-16 18:55:13 -07005816 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
5817 return rc;
5818 rc = clk_enable(mmfpb_a_clk);
5819 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
5820 return rc;
5821
Stephen Boyd85436132011-09-16 18:55:13 -07005822 /* Vote for CFPB to be at least 64MHz when an Apps CPU is active. */
5823 if (WARN(IS_ERR(cfpb_a_clk), "cfpb_a_clk not found (%ld)\n",
5824 PTR_ERR(cfpb_a_clk)))
5825 return PTR_ERR(cfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08005826 rc = clk_set_rate(cfpb_a_clk, 64000000);
Stephen Boyd85436132011-09-16 18:55:13 -07005827 if (WARN(rc, "cfpb_a_clk rate was not set (%d)\n", rc))
5828 return rc;
5829 rc = clk_enable(cfpb_a_clk);
5830 if (WARN(rc, "cfpb_a_clk not enabled (%d)\n", rc))
5831 return rc;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005832
5833 return unvote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005834}
Stephen Boydbb600ae2011-08-02 20:11:40 -07005835
5836struct clock_init_data msm8960_clock_init_data __initdata = {
5837 .table = msm_clocks_8960,
5838 .size = ARRAY_SIZE(msm_clocks_8960),
5839 .init = msm8960_clock_init,
5840 .late_init = msm8960_clock_late_init,
5841};
Tianyi Gou41515e22011-09-01 19:37:43 -07005842
5843struct clock_init_data apq8064_clock_init_data __initdata = {
5844 .table = msm_clocks_8064,
5845 .size = ARRAY_SIZE(msm_clocks_8064),
5846 .init = msm8960_clock_init,
5847 .late_init = msm8960_clock_late_init,
5848};