blob: 66c64367a9454cdf06207404df5918db1426b409 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/err.h>
16#include <linux/ctype.h>
17#include <linux/bitops.h>
18#include <linux/io.h>
19#include <linux/spinlock.h>
20#include <linux/delay.h>
21#include <linux/clk.h>
22
23#include <asm/clkdev.h>
24#include <asm/mach-types.h>
25
26#include <mach/msm_iomap.h>
27#include <mach/clk.h>
28#include <mach/rpm-regulator.h>
29#include <mach/msm_xo.h>
Stephen Boyd94625ef2011-07-12 17:06:01 -070030#include <mach/socinfo.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070031
32#include "clock-local.h"
33#include "clock-rpm.h"
34#include "clock-voter.h"
35#include "clock-dss-8960.h"
36#include "devices.h"
37
38#define REG(off) (MSM_CLK_CTL_BASE + (off))
39#define REG_MM(off) (MSM_MMSS_CLK_CTL_BASE + (off))
40#define REG_LPA(off) (MSM_LPASS_CLK_CTL_BASE + (off))
Matt Wagantall8b38f942011-08-02 18:23:18 -070041#define REG_GCC(off) (MSM_APCS_GCC_BASE + (off))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070042
43/* Peripheral clock registers. */
44#define CE1_HCLK_CTL_REG REG(0x2720)
45#define CE1_CORE_CLK_CTL_REG REG(0x2724)
Tianyi Gou41515e22011-09-01 19:37:43 -070046#define CE3_HCLK_CTL_REG REG(0x36C4)
47#define CE3_CORE_CLK_CTL_REG REG(0x36CC)
48#define CE3_CLK_SRC_NS_REG REG(0x36C0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049#define DMA_BAM_HCLK_CTL REG(0x25C0)
Tianyi Gou41515e22011-09-01 19:37:43 -070050#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#define CLK_HALT_CFPB_STATEA_REG REG(0x2FCC)
52#define CLK_HALT_CFPB_STATEB_REG REG(0x2FD0)
53#define CLK_HALT_CFPB_STATEC_REG REG(0x2FD4)
54#define CLK_HALT_DFAB_STATE_REG REG(0x2FC8)
Tianyi Gou41515e22011-09-01 19:37:43 -070055/* 8064 name CLK_HALT_GSS_KPSS_MISC_STATE_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#define CLK_HALT_MSS_SMPSS_MISC_STATE_REG REG(0x2FDC)
57#define CLK_HALT_SFPB_MISC_STATE_REG REG(0x2FD8)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070058#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070059#define CLK_TEST_REG REG(0x2FA0)
60#define GSBIn_HCLK_CTL_REG(n) REG(0x29C0+(0x20*((n)-1)))
61#define GSBIn_QUP_APPS_MD_REG(n) REG(0x29C8+(0x20*((n)-1)))
62#define GSBIn_QUP_APPS_NS_REG(n) REG(0x29CC+(0x20*((n)-1)))
63#define GSBIn_RESET_REG(n) REG(0x29DC+(0x20*((n)-1)))
64#define GSBIn_UART_APPS_MD_REG(n) REG(0x29D0+(0x20*((n)-1)))
65#define GSBIn_UART_APPS_NS_REG(n) REG(0x29D4+(0x20*((n)-1)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070066#define PDM_CLK_NS_REG REG(0x2CC0)
Tianyi Gou41515e22011-09-01 19:37:43 -070067/* 8064 name BB_PLL_ENA_APCS_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070068#define BB_PLL_ENA_SC0_REG REG(0x34C0)
69#define BB_PLL0_STATUS_REG REG(0x30D8)
70#define BB_PLL5_STATUS_REG REG(0x30F8)
71#define BB_PLL6_STATUS_REG REG(0x3118)
72#define BB_PLL7_STATUS_REG REG(0x3138)
73#define BB_PLL8_L_VAL_REG REG(0x3144)
74#define BB_PLL8_M_VAL_REG REG(0x3148)
75#define BB_PLL8_MODE_REG REG(0x3140)
76#define BB_PLL8_N_VAL_REG REG(0x314C)
77#define BB_PLL8_STATUS_REG REG(0x3158)
78#define BB_PLL8_CONFIG_REG REG(0x3154)
79#define BB_PLL8_TEST_CTL_REG REG(0x3150)
Stephen Boyd94625ef2011-07-12 17:06:01 -070080#define BB_MMCC_PLL2_MODE_REG REG(0x3160)
81#define BB_MMCC_PLL2_TEST_CTL_REG REG(0x3170)
Tianyi Gou41515e22011-09-01 19:37:43 -070082#define BB_PLL14_MODE_REG REG(0x31C0)
83#define BB_PLL14_L_VAL_REG REG(0x31C4)
84#define BB_PLL14_M_VAL_REG REG(0x31C8)
85#define BB_PLL14_N_VAL_REG REG(0x31CC)
86#define BB_PLL14_TEST_CTL_REG REG(0x31D0)
87#define BB_PLL14_CONFIG_REG REG(0x31D4)
Stephen Boyd94625ef2011-07-12 17:06:01 -070088#define BB_PLL14_STATUS_REG REG(0x31D8)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089#define PLLTEST_PAD_CFG_REG REG(0x2FA4)
90#define PMEM_ACLK_CTL_REG REG(0x25A0)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070091#define QDSS_AT_CLK_SRC0_NS_REG REG(0x2180)
92#define QDSS_AT_CLK_SRC1_NS_REG REG(0x2184)
93#define QDSS_AT_CLK_SRC_CTL_REG REG(0x2188)
94#define QDSS_AT_CLK_NS_REG REG(0x218C)
95#define QDSS_HCLK_CTL_REG REG(0x22A0)
96#define QDSS_RESETS_REG REG(0x2260)
97#define QDSS_STM_CLK_CTL_REG REG(0x2060)
98#define QDSS_TRACECLKIN_CLK_SRC0_NS_REG REG(0x21A0)
99#define QDSS_TRACECLKIN_CLK_SRC1_NS_REG REG(0x21A4)
100#define QDSS_TRACECLKIN_CLK_SRC_CTL_REG REG(0x21A8)
101#define QDSS_TRACECLKIN_CTL_REG REG(0x21AC)
102#define QDSS_TSCTR_CLK_SRC0_NS_REG REG(0x21C0)
103#define QDSS_TSCTR_CLK_SRC1_NS_REG REG(0x21C4)
104#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
105#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
106#define QDSS_TSCTR_CTL_REG REG(0x21CC)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107#define RINGOSC_NS_REG REG(0x2DC0)
108#define RINGOSC_STATUS_REG REG(0x2DCC)
109#define RINGOSC_TCXO_CTL_REG REG(0x2DC4)
110#define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080)
111#define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1)))
112#define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1)))
113#define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1)))
114#define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1)))
115#define SLIMBUS_XO_SRC_CLK_CTL_REG REG(0x2628)
116#define TSIF_HCLK_CTL_REG REG(0x2700)
117#define TSIF_REF_CLK_MD_REG REG(0x270C)
118#define TSIF_REF_CLK_NS_REG REG(0x2710)
119#define TSSC_CLK_CTL_REG REG(0x2CA0)
Tianyi Gou41515e22011-09-01 19:37:43 -0700120#define SATA_CLK_SRC_NS_REG REG(0x2C08)
121#define SATA_RXOOB_CLK_CTL_REG REG(0x2C0C)
122#define SATA_PMALIVE_CLK_CTL_REG REG(0x2C10)
123#define SATA_PHY_REF_CLK_CTL_REG REG(0x2C14)
124#define SATA_PHY_CFG_CLK_CTL_REG REG(0x2C40)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700125#define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1)))
126#define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1)))
127#define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1)))
128#define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1)))
129#define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1)))
130#define USB_HS1_HCLK_CTL_REG REG(0x2900)
Tianyi Gou41515e22011-09-01 19:37:43 -0700131#define USB_HS1_HCLK_FS_REG REG(0x2904)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700132#define USB_HS1_RESET_REG REG(0x2910)
133#define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908)
134#define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700135#define USB_HS3_HCLK_CTL_REG REG(0x3700)
136#define USB_HS3_HCLK_FS_REG REG(0x3704)
137#define USB_HS3_RESET_REG REG(0x3710)
138#define USB_HS3_XCVR_FS_CLK_MD_REG REG(0X3708)
139#define USB_HS3_XCVR_FS_CLK_NS_REG REG(0X370C)
140#define USB_HS4_HCLK_CTL_REG REG(0x3720)
141#define USB_HS4_HCLK_FS_REG REG(0x3724)
142#define USB_HS4_RESET_REG REG(0x3730)
143#define USB_HS4_XCVR_FS_CLK_MD_REG REG(0X3728)
144#define USB_HS4_XCVR_FS_CLK_NS_REG REG(0X372C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700145#define USB_HSIC_HCLK_CTL_REG REG(0x2920)
146#define USB_HSIC_HSIC_CLK_CTL_REG REG(0x2B44)
147#define USB_HSIC_HSIC_CLK_SRC_CTL_REG REG(0x2B40)
148#define USB_HSIC_HSIO_CAL_CLK_CTL_REG REG(0x2B48)
149#define USB_HSIC_RESET_REG REG(0x2934)
150#define USB_HSIC_SYSTEM_CLK_CTL_REG REG(0x292C)
151#define USB_HSIC_XCVR_FS_CLK_MD_REG REG(0x2924)
152#define USB_HSIC_XCVR_FS_CLK_NS_REG REG(0x2928)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153#define USB_PHY0_RESET_REG REG(0x2E20)
Tianyi Gou41515e22011-09-01 19:37:43 -0700154#define PCIE_ALT_REF_CLK_NS_REG REG(0x3860)
155#define PCIE_HCLK_CTL_REG REG(0x22CC)
156#define GPLL1_MODE_REG REG(0x3160)
157#define GPLL1_L_VAL_REG REG(0x3164)
158#define GPLL1_M_VAL_REG REG(0x3168)
159#define GPLL1_N_VAL_REG REG(0x316C)
160#define GPLL1_CONFIG_REG REG(0x3174)
161#define GPLL1_STATUS_REG REG(0x3178)
162#define PXO_SRC_CLK_CTL_REG REG(0x2EA0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700163
164/* Multimedia clock registers. */
165#define AHB_EN_REG REG_MM(0x0008)
166#define AHB_EN2_REG REG_MM(0x0038)
Tianyi Gou41515e22011-09-01 19:37:43 -0700167#define AHB_EN3_REG REG_MM(0x0248)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700168#define AHB_NS_REG REG_MM(0x0004)
169#define AXI_NS_REG REG_MM(0x0014)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700170#define CAMCLK0_NS_REG REG_MM(0x0148)
171#define CAMCLK0_CC_REG REG_MM(0x0140)
172#define CAMCLK0_MD_REG REG_MM(0x0144)
173#define CAMCLK1_NS_REG REG_MM(0x015C)
174#define CAMCLK1_CC_REG REG_MM(0x0154)
175#define CAMCLK1_MD_REG REG_MM(0x0158)
176#define CAMCLK2_NS_REG REG_MM(0x0228)
177#define CAMCLK2_CC_REG REG_MM(0x0220)
178#define CAMCLK2_MD_REG REG_MM(0x0224)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700179#define CSI0_NS_REG REG_MM(0x0048)
180#define CSI0_CC_REG REG_MM(0x0040)
181#define CSI0_MD_REG REG_MM(0x0044)
182#define CSI1_NS_REG REG_MM(0x0010)
183#define CSI1_CC_REG REG_MM(0x0024)
184#define CSI1_MD_REG REG_MM(0x0028)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700185#define CSI2_NS_REG REG_MM(0x0234)
186#define CSI2_CC_REG REG_MM(0x022C)
187#define CSI2_MD_REG REG_MM(0x0230)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700188#define CSIPHYTIMER_CC_REG REG_MM(0x0160)
189#define CSIPHYTIMER_MD_REG REG_MM(0x0164)
190#define CSIPHYTIMER_NS_REG REG_MM(0x0168)
191#define DSI1_BYTE_NS_REG REG_MM(0x00B0)
192#define DSI1_BYTE_CC_REG REG_MM(0x0090)
193#define DSI2_BYTE_NS_REG REG_MM(0x00BC)
194#define DSI2_BYTE_CC_REG REG_MM(0x00B4)
195#define DSI1_ESC_NS_REG REG_MM(0x011C)
196#define DSI1_ESC_CC_REG REG_MM(0x00CC)
197#define DSI2_ESC_NS_REG REG_MM(0x0150)
198#define DSI2_ESC_CC_REG REG_MM(0x013C)
199#define DSI_PIXEL_CC_REG REG_MM(0x0130)
200#define DSI2_PIXEL_CC_REG REG_MM(0x0094)
201#define DBG_BUS_VEC_A_REG REG_MM(0x01C8)
202#define DBG_BUS_VEC_B_REG REG_MM(0x01CC)
203#define DBG_BUS_VEC_C_REG REG_MM(0x01D0)
204#define DBG_BUS_VEC_D_REG REG_MM(0x01D4)
205#define DBG_BUS_VEC_E_REG REG_MM(0x01D8)
206#define DBG_BUS_VEC_F_REG REG_MM(0x01DC)
207#define DBG_BUS_VEC_G_REG REG_MM(0x01E0)
208#define DBG_BUS_VEC_H_REG REG_MM(0x01E4)
209#define DBG_BUS_VEC_I_REG REG_MM(0x01E8)
Tianyi Gou41515e22011-09-01 19:37:43 -0700210#define DBG_BUS_VEC_J_REG REG_MM(0x0240)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700211#define DBG_CFG_REG_HS_REG REG_MM(0x01B4)
212#define DBG_CFG_REG_LS_REG REG_MM(0x01B8)
213#define GFX2D0_CC_REG REG_MM(0x0060)
214#define GFX2D0_MD0_REG REG_MM(0x0064)
215#define GFX2D0_MD1_REG REG_MM(0x0068)
216#define GFX2D0_NS_REG REG_MM(0x0070)
217#define GFX2D1_CC_REG REG_MM(0x0074)
218#define GFX2D1_MD0_REG REG_MM(0x0078)
219#define GFX2D1_MD1_REG REG_MM(0x006C)
220#define GFX2D1_NS_REG REG_MM(0x007C)
221#define GFX3D_CC_REG REG_MM(0x0080)
222#define GFX3D_MD0_REG REG_MM(0x0084)
223#define GFX3D_MD1_REG REG_MM(0x0088)
224#define GFX3D_NS_REG REG_MM(0x008C)
225#define IJPEG_CC_REG REG_MM(0x0098)
226#define IJPEG_MD_REG REG_MM(0x009C)
227#define IJPEG_NS_REG REG_MM(0x00A0)
228#define JPEGD_CC_REG REG_MM(0x00A4)
229#define JPEGD_NS_REG REG_MM(0x00AC)
Tianyi Gou41515e22011-09-01 19:37:43 -0700230#define VCAP_CC_REG REG_MM(0x0178)
231#define VCAP_NS_REG REG_MM(0x021C)
232#define VCAP_MD0_REG REG_MM(0x01EC)
233#define VCAP_MD1_REG REG_MM(0x0218)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700234#define MAXI_EN_REG REG_MM(0x0018)
235#define MAXI_EN2_REG REG_MM(0x0020)
236#define MAXI_EN3_REG REG_MM(0x002C)
237#define MAXI_EN4_REG REG_MM(0x0114)
Tianyi Gou41515e22011-09-01 19:37:43 -0700238#define MAXI_EN5_REG REG_MM(0x0244)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700239#define MDP_CC_REG REG_MM(0x00C0)
240#define MDP_LUT_CC_REG REG_MM(0x016C)
241#define MDP_MD0_REG REG_MM(0x00C4)
242#define MDP_MD1_REG REG_MM(0x00C8)
243#define MDP_NS_REG REG_MM(0x00D0)
244#define MISC_CC_REG REG_MM(0x0058)
245#define MISC_CC2_REG REG_MM(0x005C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700246#define MISC_CC3_REG REG_MM(0x0238)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700247#define MM_PLL1_MODE_REG REG_MM(0x031C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700248#define MM_PLL1_L_VAL_REG REG_MM(0x0320)
249#define MM_PLL1_M_VAL_REG REG_MM(0x0324)
250#define MM_PLL1_N_VAL_REG REG_MM(0x0328)
251#define MM_PLL1_CONFIG_REG REG_MM(0x032C)
252#define MM_PLL1_TEST_CTL_REG REG_MM(0x0330)
253#define MM_PLL1_STATUS_REG REG_MM(0x0334)
254#define MM_PLL3_MODE_REG REG_MM(0x0338)
Tianyi Gou621f8742011-09-01 21:45:01 -0700255#define MM_PLL3_L_VAL_REG REG_MM(0x033C)
256#define MM_PLL3_M_VAL_REG REG_MM(0x0340)
257#define MM_PLL3_N_VAL_REG REG_MM(0x0344)
258#define MM_PLL3_CONFIG_REG REG_MM(0x0348)
259#define MM_PLL3_TEST_CTL_REG REG_MM(0x034C)
260#define MM_PLL3_STATUS_REG REG_MM(0x0350)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700261#define ROT_CC_REG REG_MM(0x00E0)
262#define ROT_NS_REG REG_MM(0x00E8)
263#define SAXI_EN_REG REG_MM(0x0030)
264#define SW_RESET_AHB_REG REG_MM(0x020C)
265#define SW_RESET_AHB2_REG REG_MM(0x0200)
266#define SW_RESET_ALL_REG REG_MM(0x0204)
267#define SW_RESET_AXI_REG REG_MM(0x0208)
268#define SW_RESET_CORE_REG REG_MM(0x0210)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700269#define SW_RESET_CORE2_REG REG_MM(0x0214)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700270#define TV_CC_REG REG_MM(0x00EC)
271#define TV_CC2_REG REG_MM(0x0124)
272#define TV_MD_REG REG_MM(0x00F0)
273#define TV_NS_REG REG_MM(0x00F4)
274#define VCODEC_CC_REG REG_MM(0x00F8)
275#define VCODEC_MD0_REG REG_MM(0x00FC)
276#define VCODEC_MD1_REG REG_MM(0x0128)
277#define VCODEC_NS_REG REG_MM(0x0100)
278#define VFE_CC_REG REG_MM(0x0104)
279#define VFE_MD_REG REG_MM(0x0108)
280#define VFE_NS_REG REG_MM(0x010C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700281#define VFE_CC2_REG REG_MM(0x023C)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700282#define VPE_CC_REG REG_MM(0x0110)
283#define VPE_NS_REG REG_MM(0x0118)
284
285/* Low-power Audio clock registers. */
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700286#define LCC_CLK_HS_DEBUG_CFG_REG REG_LPA(0x00A4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700287#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
288#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
289#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
290#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
291#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
292#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
293#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
294#define LCC_MI2S_MD_REG REG_LPA(0x004C)
295#define LCC_MI2S_NS_REG REG_LPA(0x0048)
296#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
297#define LCC_PCM_MD_REG REG_LPA(0x0058)
298#define LCC_PCM_NS_REG REG_LPA(0x0054)
299#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700300#define LCC_PLL0_MODE_REG REG_LPA(0x0000)
301#define LCC_PLL0_L_VAL_REG REG_LPA(0x0004)
302#define LCC_PLL0_M_VAL_REG REG_LPA(0x0008)
303#define LCC_PLL0_N_VAL_REG REG_LPA(0x000C)
304#define LCC_PLL0_CONFIG_REG REG_LPA(0x0014)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700305#define LCC_PLL0_STATUS_REG REG_LPA(0x0018)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700306#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
307#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
308#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
309#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
310#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
311#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
312#define LCC_SLIMBUS_NS_REG REG_LPA(0x00CC)
313#define LCC_SLIMBUS_MD_REG REG_LPA(0x00D0)
314#define LCC_SLIMBUS_STATUS_REG REG_LPA(0x00D4)
315#define LCC_AHBEX_BRANCH_CTL_REG REG_LPA(0x00E4)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700316#define LCC_PRI_PLL_CLK_CTL_REG REG_LPA(0x00C4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700317
Matt Wagantall8b38f942011-08-02 18:23:18 -0700318#define GCC_APCS_CLK_DIAG REG_GCC(0x001C)
319
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700320/* MUX source input identifiers. */
321#define pxo_to_bb_mux 0
322#define cxo_to_bb_mux pxo_to_bb_mux
323#define pll0_to_bb_mux 2
324#define pll8_to_bb_mux 3
325#define pll6_to_bb_mux 4
326#define gnd_to_bb_mux 5
Stephen Boyd94625ef2011-07-12 17:06:01 -0700327#define pll3_to_bb_mux 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700328#define pxo_to_mm_mux 0
329#define pll1_to_mm_mux 1
Tianyi Gou41515e22011-09-01 19:37:43 -0700330#define pll2_to_mm_mux 1 /* or MMCC_PLL1 */
331#define pll8_to_mm_mux 2 /* or GCC_PERF */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332#define pll0_to_mm_mux 3
Tianyi Gou41515e22011-09-01 19:37:43 -0700333#define pll15_to_mm_mux 3 /* or MM_PLL3 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700334#define gnd_to_mm_mux 4
Stephen Boyd7a776cd2011-10-20 12:46:04 -0700335#define pll3_to_mm_mux 3 /* or MMCC_PLL2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700336#define hdmi_pll_to_mm_mux 3
337#define cxo_to_xo_mux 0
338#define pxo_to_xo_mux 1
339#define gnd_to_xo_mux 3
340#define pxo_to_lpa_mux 0
341#define cxo_to_lpa_mux 1
342#define pll4_to_lpa_mux 2
343#define gnd_to_lpa_mux 6
Tianyi Gou41515e22011-09-01 19:37:43 -0700344#define pxo_to_pcie_mux 0
345#define pll3_to_pcie_mux 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700346
347/* Test Vector Macros */
348#define TEST_TYPE_PER_LS 1
349#define TEST_TYPE_PER_HS 2
350#define TEST_TYPE_MM_LS 3
351#define TEST_TYPE_MM_HS 4
352#define TEST_TYPE_LPA 5
Matt Wagantall8b38f942011-08-02 18:23:18 -0700353#define TEST_TYPE_CPUL2 6
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700354#define TEST_TYPE_LPA_HS 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700355#define TEST_TYPE_SHIFT 24
356#define TEST_CLK_SEL_MASK BM(23, 0)
357#define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s)))
358#define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS)
359#define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS)
360#define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS)
361#define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS)
362#define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA)
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700363#define TEST_LPA_HS(s) TEST_VECTOR((s), TEST_TYPE_LPA_HS)
Matt Wagantall8b38f942011-08-02 18:23:18 -0700364#define TEST_CPUL2(s) TEST_VECTOR((s), TEST_TYPE_CPUL2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700365
366#define MN_MODE_DUAL_EDGE 0x2
367
368/* MD Registers */
369#define MD4(m_lsb, m, n_lsb, n) \
370 (BVAL((m_lsb+3), m_lsb, m) | BVAL((n_lsb+3), n_lsb, ~(n)))
371#define MD8(m_lsb, m, n_lsb, n) \
372 (BVAL((m_lsb+7), m_lsb, m) | BVAL((n_lsb+7), n_lsb, ~(n)))
373#define MD16(m, n) (BVAL(31, 16, m) | BVAL(15, 0, ~(n)))
374
375/* NS Registers */
376#define NS(n_msb, n_lsb, n, m, mde_lsb, d_msb, d_lsb, d, s_msb, s_lsb, s) \
377 (BVAL(n_msb, n_lsb, ~(n-m)) \
378 | (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n)) \
379 | BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
380
381#define NS_MM(n_msb, n_lsb, n, m, d_msb, d_lsb, d, s_msb, s_lsb, s) \
382 (BVAL(n_msb, n_lsb, ~(n-m)) | BVAL(d_msb, d_lsb, (d-1)) \
383 | BVAL(s_msb, s_lsb, s))
384
385#define NS_DIVSRC(d_msb , d_lsb, d, s_msb, s_lsb, s) \
386 (BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
387
388#define NS_DIV(d_msb , d_lsb, d) \
389 BVAL(d_msb, d_lsb, (d-1))
390
391#define NS_SRC_SEL(s_msb, s_lsb, s) \
392 BVAL(s_msb, s_lsb, s)
393
394#define NS_MND_BANKED4(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
395 (BVAL((n0_lsb+3), n0_lsb, ~(n-m)) \
396 | BVAL((n1_lsb+3), n1_lsb, ~(n-m)) \
397 | BVAL((s0_lsb+2), s0_lsb, s) \
398 | BVAL((s1_lsb+2), s1_lsb, s))
399
400#define NS_MND_BANKED8(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
401 (BVAL((n0_lsb+7), n0_lsb, ~(n-m)) \
402 | BVAL((n1_lsb+7), n1_lsb, ~(n-m)) \
403 | BVAL((s0_lsb+2), s0_lsb, s) \
404 | BVAL((s1_lsb+2), s1_lsb, s))
405
406#define NS_DIVSRC_BANKED(d0_msb, d0_lsb, d1_msb, d1_lsb, d, \
407 s0_msb, s0_lsb, s1_msb, s1_lsb, s) \
408 (BVAL(d0_msb, d0_lsb, (d-1)) | BVAL(d1_msb, d1_lsb, (d-1)) \
409 | BVAL(s0_msb, s0_lsb, s) \
410 | BVAL(s1_msb, s1_lsb, s))
411
412/* CC Registers */
413#define CC(mde_lsb, n) (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n))
414#define CC_BANKED(mde0_lsb, mde1_lsb, n) \
415 ((BVAL((mde0_lsb+1), mde0_lsb, MN_MODE_DUAL_EDGE) \
416 | BVAL((mde1_lsb+1), mde1_lsb, MN_MODE_DUAL_EDGE)) \
417 * !!(n))
418
419struct pll_rate {
420 const uint32_t l_val;
421 const uint32_t m_val;
422 const uint32_t n_val;
423 const uint32_t vco;
424 const uint32_t post_div;
425 const uint32_t i_bits;
426};
427#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
428
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700429enum vdd_dig_levels {
430 VDD_DIG_NONE,
431 VDD_DIG_LOW,
432 VDD_DIG_NOMINAL,
433 VDD_DIG_HIGH
434};
435
436static int set_vdd_dig(struct clk_vdd_class *vdd_class, int level)
437{
438 static const int vdd_uv[] = {
439 [VDD_DIG_NONE] = 0,
440 [VDD_DIG_LOW] = 945000,
441 [VDD_DIG_NOMINAL] = 1050000,
442 [VDD_DIG_HIGH] = 1150000
443 };
444
445 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
446 vdd_uv[level], 1150000, 1);
447}
448
449static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig);
450
451#define VDD_DIG_FMAX_MAP1(l1, f1) \
452 .vdd_class = &vdd_dig, \
453 .fmax[VDD_DIG_##l1] = (f1)
454#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
455 .vdd_class = &vdd_dig, \
456 .fmax[VDD_DIG_##l1] = (f1), \
457 .fmax[VDD_DIG_##l2] = (f2)
458#define VDD_DIG_FMAX_MAP3(l1, f1, l2, f2, l3, f3) \
459 .vdd_class = &vdd_dig, \
460 .fmax[VDD_DIG_##l1] = (f1), \
461 .fmax[VDD_DIG_##l2] = (f2), \
462 .fmax[VDD_DIG_##l3] = (f3)
463
Matt Wagantallc57577d2011-10-06 17:06:53 -0700464enum vdd_l23_levels {
465 VDD_L23_OFF,
466 VDD_L23_ON
467};
468
469static int set_vdd_l23(struct clk_vdd_class *vdd_class, int level)
470{
471 int rc;
472
473 if (level == VDD_L23_OFF) {
474 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
475 RPM_VREG_VOTER3, 0, 0, 1);
476 if (rc)
477 return rc;
478 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
479 RPM_VREG_VOTER3, 0, 0, 1);
480 if (rc)
481 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
482 RPM_VREG_VOTER3, 1800000, 1800000, 1);
483 } else {
484 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
485 RPM_VREG_VOTER3, 2200000, 2200000, 1);
486 if (rc)
487 return rc;
488 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
489 RPM_VREG_VOTER3, 1800000, 1800000, 1);
490 if (rc)
491 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
492 RPM_VREG_VOTER3, 0, 0, 1);
493 }
494
495 return rc;
496}
497
498static DEFINE_VDD_CLASS(vdd_l23, set_vdd_l23);
499
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700500/*
501 * Clock Descriptions
502 */
503
504static struct msm_xo_voter *xo_pxo, *xo_cxo;
505
506static int pxo_clk_enable(struct clk *clk)
507{
508 return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON);
509}
510
511static void pxo_clk_disable(struct clk *clk)
512{
Tianyi Gou41515e22011-09-01 19:37:43 -0700513 msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700514}
515
516static struct clk_ops clk_ops_pxo = {
517 .enable = pxo_clk_enable,
518 .disable = pxo_clk_disable,
519 .get_rate = fixed_clk_get_rate,
520 .is_local = local_clk_is_local,
521};
522
523static struct fixed_clk pxo_clk = {
524 .rate = 27000000,
525 .c = {
526 .dbg_name = "pxo_clk",
527 .ops = &clk_ops_pxo,
528 CLK_INIT(pxo_clk.c),
529 },
530};
531
532static int cxo_clk_enable(struct clk *clk)
533{
534 return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON);
535}
536
537static void cxo_clk_disable(struct clk *clk)
538{
539 msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF);
540}
541
542static struct clk_ops clk_ops_cxo = {
543 .enable = cxo_clk_enable,
544 .disable = cxo_clk_disable,
545 .get_rate = fixed_clk_get_rate,
546 .is_local = local_clk_is_local,
547};
548
549static struct fixed_clk cxo_clk = {
550 .rate = 19200000,
551 .c = {
552 .dbg_name = "cxo_clk",
553 .ops = &clk_ops_cxo,
554 CLK_INIT(cxo_clk.c),
555 },
556};
557
558static struct pll_clk pll2_clk = {
559 .rate = 800000000,
560 .mode_reg = MM_PLL1_MODE_REG,
561 .parent = &pxo_clk.c,
562 .c = {
563 .dbg_name = "pll2_clk",
564 .ops = &clk_ops_pll,
565 CLK_INIT(pll2_clk.c),
566 },
567};
568
Stephen Boyd94625ef2011-07-12 17:06:01 -0700569static struct pll_clk pll3_clk = {
570 .rate = 1200000000,
571 .mode_reg = BB_MMCC_PLL2_MODE_REG,
572 .parent = &pxo_clk.c,
573 .c = {
574 .dbg_name = "pll3_clk",
575 .ops = &clk_ops_pll,
Matt Wagantallc57577d2011-10-06 17:06:53 -0700576 .vdd_class = &vdd_l23,
577 .fmax[VDD_L23_ON] = ULONG_MAX,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700578 CLK_INIT(pll3_clk.c),
579 },
580};
581
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700582static struct pll_vote_clk pll4_clk = {
583 .rate = 393216000,
584 .en_reg = BB_PLL_ENA_SC0_REG,
585 .en_mask = BIT(4),
586 .status_reg = LCC_PLL0_STATUS_REG,
587 .parent = &pxo_clk.c,
588 .c = {
589 .dbg_name = "pll4_clk",
590 .ops = &clk_ops_pll_vote,
591 CLK_INIT(pll4_clk.c),
592 },
593};
594
595static struct pll_vote_clk pll8_clk = {
596 .rate = 384000000,
597 .en_reg = BB_PLL_ENA_SC0_REG,
598 .en_mask = BIT(8),
599 .status_reg = BB_PLL8_STATUS_REG,
600 .parent = &pxo_clk.c,
601 .c = {
602 .dbg_name = "pll8_clk",
603 .ops = &clk_ops_pll_vote,
604 CLK_INIT(pll8_clk.c),
605 },
606};
607
Stephen Boyd94625ef2011-07-12 17:06:01 -0700608static struct pll_vote_clk pll14_clk = {
609 .rate = 480000000,
610 .en_reg = BB_PLL_ENA_SC0_REG,
611 .en_mask = BIT(14),
612 .status_reg = BB_PLL14_STATUS_REG,
613 .parent = &pxo_clk.c,
614 .c = {
615 .dbg_name = "pll14_clk",
616 .ops = &clk_ops_pll_vote,
617 CLK_INIT(pll14_clk.c),
618 },
619};
620
Tianyi Gou41515e22011-09-01 19:37:43 -0700621static struct pll_clk pll15_clk = {
622 .rate = 975000000,
623 .mode_reg = MM_PLL3_MODE_REG,
624 .parent = &pxo_clk.c,
625 .c = {
626 .dbg_name = "pll15_clk",
627 .ops = &clk_ops_pll,
628 CLK_INIT(pll15_clk.c),
629 },
630};
631
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700632static int soc_clk_reset(struct clk *clk, enum clk_reset_action action)
633{
634 return branch_reset(&to_rcg_clk(clk)->b, action);
635}
636
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700637static struct clk_ops clk_ops_rcg_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700638 .enable = rcg_clk_enable,
639 .disable = rcg_clk_disable,
Matt Wagantall41af0772011-09-17 12:21:39 -0700640 .auto_off = rcg_clk_disable,
Matt Wagantall53d968f2011-07-19 13:22:53 -0700641 .handoff = rcg_clk_handoff,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700642 .set_rate = rcg_clk_set_rate,
643 .set_min_rate = rcg_clk_set_min_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700644 .get_rate = rcg_clk_get_rate,
645 .list_rate = rcg_clk_list_rate,
646 .is_enabled = rcg_clk_is_enabled,
647 .round_rate = rcg_clk_round_rate,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700648 .reset = soc_clk_reset,
649 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700650 .get_parent = rcg_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700651};
652
653static struct clk_ops clk_ops_branch = {
654 .enable = branch_clk_enable,
655 .disable = branch_clk_disable,
Matt Wagantall41af0772011-09-17 12:21:39 -0700656 .auto_off = branch_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700657 .is_enabled = branch_clk_is_enabled,
658 .reset = branch_clk_reset,
659 .is_local = local_clk_is_local,
660 .get_parent = branch_clk_get_parent,
661 .set_parent = branch_clk_set_parent,
662};
663
664static struct clk_ops clk_ops_reset = {
665 .reset = branch_clk_reset,
666 .is_local = local_clk_is_local,
667};
668
669/* AXI Interfaces */
670static struct branch_clk gmem_axi_clk = {
671 .b = {
672 .ctl_reg = MAXI_EN_REG,
673 .en_mask = BIT(24),
674 .halt_reg = DBG_BUS_VEC_E_REG,
675 .halt_bit = 6,
676 },
677 .c = {
678 .dbg_name = "gmem_axi_clk",
679 .ops = &clk_ops_branch,
680 CLK_INIT(gmem_axi_clk.c),
681 },
682};
683
684static struct branch_clk ijpeg_axi_clk = {
685 .b = {
686 .ctl_reg = MAXI_EN_REG,
687 .en_mask = BIT(21),
688 .reset_reg = SW_RESET_AXI_REG,
689 .reset_mask = BIT(14),
690 .halt_reg = DBG_BUS_VEC_E_REG,
691 .halt_bit = 4,
692 },
693 .c = {
694 .dbg_name = "ijpeg_axi_clk",
695 .ops = &clk_ops_branch,
696 CLK_INIT(ijpeg_axi_clk.c),
697 },
698};
699
700static struct branch_clk imem_axi_clk = {
701 .b = {
702 .ctl_reg = MAXI_EN_REG,
703 .en_mask = BIT(22),
704 .reset_reg = SW_RESET_CORE_REG,
705 .reset_mask = BIT(10),
706 .halt_reg = DBG_BUS_VEC_E_REG,
707 .halt_bit = 7,
708 },
709 .c = {
710 .dbg_name = "imem_axi_clk",
711 .ops = &clk_ops_branch,
712 CLK_INIT(imem_axi_clk.c),
713 },
714};
715
716static struct branch_clk jpegd_axi_clk = {
717 .b = {
718 .ctl_reg = MAXI_EN_REG,
719 .en_mask = BIT(25),
720 .halt_reg = DBG_BUS_VEC_E_REG,
721 .halt_bit = 5,
722 },
723 .c = {
724 .dbg_name = "jpegd_axi_clk",
725 .ops = &clk_ops_branch,
726 CLK_INIT(jpegd_axi_clk.c),
727 },
728};
729
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700730static struct branch_clk vcodec_axi_b_clk = {
731 .b = {
732 .ctl_reg = MAXI_EN4_REG,
733 .en_mask = BIT(23),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700734 .halt_reg = DBG_BUS_VEC_I_REG,
735 .halt_bit = 25,
736 },
737 .c = {
738 .dbg_name = "vcodec_axi_b_clk",
739 .ops = &clk_ops_branch,
740 CLK_INIT(vcodec_axi_b_clk.c),
741 },
742};
743
Matt Wagantall91f42702011-07-14 12:01:15 -0700744static struct branch_clk vcodec_axi_a_clk = {
745 .b = {
746 .ctl_reg = MAXI_EN4_REG,
747 .en_mask = BIT(25),
Matt Wagantall91f42702011-07-14 12:01:15 -0700748 .halt_reg = DBG_BUS_VEC_I_REG,
749 .halt_bit = 26,
750 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700751 .c = {
752 .dbg_name = "vcodec_axi_a_clk",
753 .ops = &clk_ops_branch,
754 CLK_INIT(vcodec_axi_a_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700755 .depends = &vcodec_axi_b_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700756 },
757};
758
759static struct branch_clk vcodec_axi_clk = {
760 .b = {
761 .ctl_reg = MAXI_EN_REG,
762 .en_mask = BIT(19),
763 .reset_reg = SW_RESET_AXI_REG,
Matt Wagantallfe2ee052011-07-14 13:33:44 -0700764 .reset_mask = BIT(4)|BIT(5)|BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700765 .halt_reg = DBG_BUS_VEC_E_REG,
766 .halt_bit = 3,
767 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700768 .c = {
769 .dbg_name = "vcodec_axi_clk",
770 .ops = &clk_ops_branch,
771 CLK_INIT(vcodec_axi_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700772 .depends = &vcodec_axi_a_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700773 },
774};
775
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700776static struct branch_clk vfe_axi_clk = {
777 .b = {
778 .ctl_reg = MAXI_EN_REG,
779 .en_mask = BIT(18),
780 .reset_reg = SW_RESET_AXI_REG,
781 .reset_mask = BIT(9),
782 .halt_reg = DBG_BUS_VEC_E_REG,
783 .halt_bit = 0,
784 },
785 .c = {
786 .dbg_name = "vfe_axi_clk",
787 .ops = &clk_ops_branch,
788 CLK_INIT(vfe_axi_clk.c),
789 },
790};
791
792static struct branch_clk mdp_axi_clk = {
793 .b = {
794 .ctl_reg = MAXI_EN_REG,
795 .en_mask = BIT(23),
796 .reset_reg = SW_RESET_AXI_REG,
797 .reset_mask = BIT(13),
798 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700799 .halt_bit = 8,
800 },
801 .c = {
802 .dbg_name = "mdp_axi_clk",
803 .ops = &clk_ops_branch,
804 CLK_INIT(mdp_axi_clk.c),
805 },
806};
807
808static struct branch_clk rot_axi_clk = {
809 .b = {
810 .ctl_reg = MAXI_EN2_REG,
811 .en_mask = BIT(24),
812 .reset_reg = SW_RESET_AXI_REG,
813 .reset_mask = BIT(6),
814 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700815 .halt_bit = 2,
816 },
817 .c = {
818 .dbg_name = "rot_axi_clk",
819 .ops = &clk_ops_branch,
820 CLK_INIT(rot_axi_clk.c),
821 },
822};
823
824static struct branch_clk vpe_axi_clk = {
825 .b = {
826 .ctl_reg = MAXI_EN2_REG,
827 .en_mask = BIT(26),
828 .reset_reg = SW_RESET_AXI_REG,
829 .reset_mask = BIT(15),
830 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700831 .halt_bit = 1,
832 },
833 .c = {
834 .dbg_name = "vpe_axi_clk",
835 .ops = &clk_ops_branch,
836 CLK_INIT(vpe_axi_clk.c),
837 },
838};
839
Tianyi Gou41515e22011-09-01 19:37:43 -0700840static struct branch_clk vcap_axi_clk = {
841 .b = {
842 .ctl_reg = MAXI_EN5_REG,
843 .en_mask = BIT(12),
844 .reset_reg = SW_RESET_AXI_REG,
845 .reset_mask = BIT(16),
846 .halt_reg = DBG_BUS_VEC_J_REG,
847 .halt_bit = 20,
848 },
849 .c = {
850 .dbg_name = "vcap_axi_clk",
851 .ops = &clk_ops_branch,
852 CLK_INIT(vcap_axi_clk.c),
853 },
854};
855
Tianyi Gou621f8742011-09-01 21:45:01 -0700856/* For 8064, gfx3d_axi_clk is set as a dependency of gmem_axi_clk at runtime */
857static struct branch_clk gfx3d_axi_clk = {
858 .b = {
859 .ctl_reg = MAXI_EN5_REG,
860 .en_mask = BIT(25),
861 .reset_reg = SW_RESET_AXI_REG,
862 .reset_mask = BIT(17),
863 .halt_reg = DBG_BUS_VEC_J_REG,
864 .halt_bit = 30,
865 },
866 .c = {
867 .dbg_name = "gfx3d_axi_clk",
868 .ops = &clk_ops_branch,
869 CLK_INIT(gfx3d_axi_clk.c),
870 },
871};
872
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700873/* AHB Interfaces */
874static struct branch_clk amp_p_clk = {
875 .b = {
876 .ctl_reg = AHB_EN_REG,
877 .en_mask = BIT(24),
878 .halt_reg = DBG_BUS_VEC_F_REG,
879 .halt_bit = 18,
880 },
881 .c = {
882 .dbg_name = "amp_p_clk",
883 .ops = &clk_ops_branch,
884 CLK_INIT(amp_p_clk.c),
885 },
886};
887
Matt Wagantallc23eee92011-08-16 23:06:52 -0700888static struct branch_clk csi_p_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700889 .b = {
890 .ctl_reg = AHB_EN_REG,
891 .en_mask = BIT(7),
892 .reset_reg = SW_RESET_AHB_REG,
893 .reset_mask = BIT(17),
894 .halt_reg = DBG_BUS_VEC_F_REG,
895 .halt_bit = 16,
896 },
897 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -0700898 .dbg_name = "csi_p_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700899 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -0700900 CLK_INIT(csi_p_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700901 },
902};
903
904static struct branch_clk dsi1_m_p_clk = {
905 .b = {
906 .ctl_reg = AHB_EN_REG,
907 .en_mask = BIT(9),
908 .reset_reg = SW_RESET_AHB_REG,
909 .reset_mask = BIT(6),
910 .halt_reg = DBG_BUS_VEC_F_REG,
911 .halt_bit = 19,
912 },
913 .c = {
914 .dbg_name = "dsi1_m_p_clk",
915 .ops = &clk_ops_branch,
916 CLK_INIT(dsi1_m_p_clk.c),
917 },
918};
919
920static struct branch_clk dsi1_s_p_clk = {
921 .b = {
922 .ctl_reg = AHB_EN_REG,
923 .en_mask = BIT(18),
924 .reset_reg = SW_RESET_AHB_REG,
925 .reset_mask = BIT(5),
926 .halt_reg = DBG_BUS_VEC_F_REG,
927 .halt_bit = 21,
928 },
929 .c = {
930 .dbg_name = "dsi1_s_p_clk",
931 .ops = &clk_ops_branch,
932 CLK_INIT(dsi1_s_p_clk.c),
933 },
934};
935
936static struct branch_clk dsi2_m_p_clk = {
937 .b = {
938 .ctl_reg = AHB_EN_REG,
939 .en_mask = BIT(17),
940 .reset_reg = SW_RESET_AHB2_REG,
941 .reset_mask = BIT(1),
942 .halt_reg = DBG_BUS_VEC_E_REG,
943 .halt_bit = 18,
944 },
945 .c = {
946 .dbg_name = "dsi2_m_p_clk",
947 .ops = &clk_ops_branch,
948 CLK_INIT(dsi2_m_p_clk.c),
949 },
950};
951
952static struct branch_clk dsi2_s_p_clk = {
953 .b = {
954 .ctl_reg = AHB_EN_REG,
955 .en_mask = BIT(22),
956 .reset_reg = SW_RESET_AHB2_REG,
957 .reset_mask = BIT(0),
958 .halt_reg = DBG_BUS_VEC_F_REG,
959 .halt_bit = 20,
960 },
961 .c = {
962 .dbg_name = "dsi2_s_p_clk",
963 .ops = &clk_ops_branch,
964 CLK_INIT(dsi2_s_p_clk.c),
965 },
966};
967
968static struct branch_clk gfx2d0_p_clk = {
969 .b = {
970 .ctl_reg = AHB_EN_REG,
971 .en_mask = BIT(19),
972 .reset_reg = SW_RESET_AHB_REG,
973 .reset_mask = BIT(12),
974 .halt_reg = DBG_BUS_VEC_F_REG,
975 .halt_bit = 2,
976 },
977 .c = {
978 .dbg_name = "gfx2d0_p_clk",
979 .ops = &clk_ops_branch,
980 CLK_INIT(gfx2d0_p_clk.c),
981 },
982};
983
984static struct branch_clk gfx2d1_p_clk = {
985 .b = {
986 .ctl_reg = AHB_EN_REG,
987 .en_mask = BIT(2),
988 .reset_reg = SW_RESET_AHB_REG,
989 .reset_mask = BIT(11),
990 .halt_reg = DBG_BUS_VEC_F_REG,
991 .halt_bit = 3,
992 },
993 .c = {
994 .dbg_name = "gfx2d1_p_clk",
995 .ops = &clk_ops_branch,
996 CLK_INIT(gfx2d1_p_clk.c),
997 },
998};
999
1000static struct branch_clk gfx3d_p_clk = {
1001 .b = {
1002 .ctl_reg = AHB_EN_REG,
1003 .en_mask = BIT(3),
1004 .reset_reg = SW_RESET_AHB_REG,
1005 .reset_mask = BIT(10),
1006 .halt_reg = DBG_BUS_VEC_F_REG,
1007 .halt_bit = 4,
1008 },
1009 .c = {
1010 .dbg_name = "gfx3d_p_clk",
1011 .ops = &clk_ops_branch,
1012 CLK_INIT(gfx3d_p_clk.c),
1013 },
1014};
1015
1016static struct branch_clk hdmi_m_p_clk = {
1017 .b = {
1018 .ctl_reg = AHB_EN_REG,
1019 .en_mask = BIT(14),
1020 .reset_reg = SW_RESET_AHB_REG,
1021 .reset_mask = BIT(9),
1022 .halt_reg = DBG_BUS_VEC_F_REG,
1023 .halt_bit = 5,
1024 },
1025 .c = {
1026 .dbg_name = "hdmi_m_p_clk",
1027 .ops = &clk_ops_branch,
1028 CLK_INIT(hdmi_m_p_clk.c),
1029 },
1030};
1031
1032static struct branch_clk hdmi_s_p_clk = {
1033 .b = {
1034 .ctl_reg = AHB_EN_REG,
1035 .en_mask = BIT(4),
1036 .reset_reg = SW_RESET_AHB_REG,
1037 .reset_mask = BIT(9),
1038 .halt_reg = DBG_BUS_VEC_F_REG,
1039 .halt_bit = 6,
1040 },
1041 .c = {
1042 .dbg_name = "hdmi_s_p_clk",
1043 .ops = &clk_ops_branch,
1044 CLK_INIT(hdmi_s_p_clk.c),
1045 },
1046};
1047
1048static struct branch_clk ijpeg_p_clk = {
1049 .b = {
1050 .ctl_reg = AHB_EN_REG,
1051 .en_mask = BIT(5),
1052 .reset_reg = SW_RESET_AHB_REG,
1053 .reset_mask = BIT(7),
1054 .halt_reg = DBG_BUS_VEC_F_REG,
1055 .halt_bit = 9,
1056 },
1057 .c = {
1058 .dbg_name = "ijpeg_p_clk",
1059 .ops = &clk_ops_branch,
1060 CLK_INIT(ijpeg_p_clk.c),
1061 },
1062};
1063
1064static struct branch_clk imem_p_clk = {
1065 .b = {
1066 .ctl_reg = AHB_EN_REG,
1067 .en_mask = BIT(6),
1068 .reset_reg = SW_RESET_AHB_REG,
1069 .reset_mask = BIT(8),
1070 .halt_reg = DBG_BUS_VEC_F_REG,
1071 .halt_bit = 10,
1072 },
1073 .c = {
1074 .dbg_name = "imem_p_clk",
1075 .ops = &clk_ops_branch,
1076 CLK_INIT(imem_p_clk.c),
1077 },
1078};
1079
1080static struct branch_clk jpegd_p_clk = {
1081 .b = {
1082 .ctl_reg = AHB_EN_REG,
1083 .en_mask = BIT(21),
1084 .reset_reg = SW_RESET_AHB_REG,
1085 .reset_mask = BIT(4),
1086 .halt_reg = DBG_BUS_VEC_F_REG,
1087 .halt_bit = 7,
1088 },
1089 .c = {
1090 .dbg_name = "jpegd_p_clk",
1091 .ops = &clk_ops_branch,
1092 CLK_INIT(jpegd_p_clk.c),
1093 },
1094};
1095
1096static struct branch_clk mdp_p_clk = {
1097 .b = {
1098 .ctl_reg = AHB_EN_REG,
1099 .en_mask = BIT(10),
1100 .reset_reg = SW_RESET_AHB_REG,
1101 .reset_mask = BIT(3),
1102 .halt_reg = DBG_BUS_VEC_F_REG,
1103 .halt_bit = 11,
1104 },
1105 .c = {
1106 .dbg_name = "mdp_p_clk",
1107 .ops = &clk_ops_branch,
1108 CLK_INIT(mdp_p_clk.c),
1109 },
1110};
1111
1112static struct branch_clk rot_p_clk = {
1113 .b = {
1114 .ctl_reg = AHB_EN_REG,
1115 .en_mask = BIT(12),
1116 .reset_reg = SW_RESET_AHB_REG,
1117 .reset_mask = BIT(2),
1118 .halt_reg = DBG_BUS_VEC_F_REG,
1119 .halt_bit = 13,
1120 },
1121 .c = {
1122 .dbg_name = "rot_p_clk",
1123 .ops = &clk_ops_branch,
1124 CLK_INIT(rot_p_clk.c),
1125 },
1126};
1127
1128static struct branch_clk smmu_p_clk = {
1129 .b = {
1130 .ctl_reg = AHB_EN_REG,
1131 .en_mask = BIT(15),
1132 .halt_reg = DBG_BUS_VEC_F_REG,
1133 .halt_bit = 22,
1134 },
1135 .c = {
1136 .dbg_name = "smmu_p_clk",
1137 .ops = &clk_ops_branch,
1138 CLK_INIT(smmu_p_clk.c),
1139 },
1140};
1141
1142static struct branch_clk tv_enc_p_clk = {
1143 .b = {
1144 .ctl_reg = AHB_EN_REG,
1145 .en_mask = BIT(25),
1146 .reset_reg = SW_RESET_AHB_REG,
1147 .reset_mask = BIT(15),
1148 .halt_reg = DBG_BUS_VEC_F_REG,
1149 .halt_bit = 23,
1150 },
1151 .c = {
1152 .dbg_name = "tv_enc_p_clk",
1153 .ops = &clk_ops_branch,
1154 CLK_INIT(tv_enc_p_clk.c),
1155 },
1156};
1157
1158static struct branch_clk vcodec_p_clk = {
1159 .b = {
1160 .ctl_reg = AHB_EN_REG,
1161 .en_mask = BIT(11),
1162 .reset_reg = SW_RESET_AHB_REG,
1163 .reset_mask = BIT(1),
1164 .halt_reg = DBG_BUS_VEC_F_REG,
1165 .halt_bit = 12,
1166 },
1167 .c = {
1168 .dbg_name = "vcodec_p_clk",
1169 .ops = &clk_ops_branch,
1170 CLK_INIT(vcodec_p_clk.c),
1171 },
1172};
1173
1174static struct branch_clk vfe_p_clk = {
1175 .b = {
1176 .ctl_reg = AHB_EN_REG,
1177 .en_mask = BIT(13),
1178 .reset_reg = SW_RESET_AHB_REG,
1179 .reset_mask = BIT(0),
1180 .halt_reg = DBG_BUS_VEC_F_REG,
1181 .halt_bit = 14,
1182 },
1183 .c = {
1184 .dbg_name = "vfe_p_clk",
1185 .ops = &clk_ops_branch,
1186 CLK_INIT(vfe_p_clk.c),
1187 },
1188};
1189
1190static struct branch_clk vpe_p_clk = {
1191 .b = {
1192 .ctl_reg = AHB_EN_REG,
1193 .en_mask = BIT(16),
1194 .reset_reg = SW_RESET_AHB_REG,
1195 .reset_mask = BIT(14),
1196 .halt_reg = DBG_BUS_VEC_F_REG,
1197 .halt_bit = 15,
1198 },
1199 .c = {
1200 .dbg_name = "vpe_p_clk",
1201 .ops = &clk_ops_branch,
1202 CLK_INIT(vpe_p_clk.c),
1203 },
1204};
1205
Tianyi Gou41515e22011-09-01 19:37:43 -07001206static struct branch_clk vcap_p_clk = {
1207 .b = {
1208 .ctl_reg = AHB_EN3_REG,
1209 .en_mask = BIT(1),
1210 .reset_reg = SW_RESET_AHB2_REG,
1211 .reset_mask = BIT(2),
1212 .halt_reg = DBG_BUS_VEC_J_REG,
1213 .halt_bit = 23,
1214 },
1215 .c = {
1216 .dbg_name = "vcap_p_clk",
1217 .ops = &clk_ops_branch,
1218 CLK_INIT(vcap_p_clk.c),
1219 },
1220};
1221
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001222/*
1223 * Peripheral Clocks
1224 */
1225#define CLK_GSBI_UART(i, n, h_r, h_b) \
1226 struct rcg_clk i##_clk = { \
1227 .b = { \
1228 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
1229 .en_mask = BIT(9), \
1230 .reset_reg = GSBIn_RESET_REG(n), \
1231 .reset_mask = BIT(0), \
1232 .halt_reg = h_r, \
1233 .halt_bit = h_b, \
1234 }, \
1235 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
1236 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
1237 .root_en_mask = BIT(11), \
1238 .ns_mask = (BM(31, 16) | BM(6, 0)), \
1239 .set_rate = set_rate_mnd, \
1240 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001241 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001242 .c = { \
1243 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001244 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001245 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001246 CLK_INIT(i##_clk.c), \
1247 }, \
1248 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001249#define F_GSBI_UART(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001250 { \
1251 .freq_hz = f, \
1252 .src_clk = &s##_clk.c, \
1253 .md_val = MD16(m, n), \
1254 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1255 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001256 }
1257static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001258 F_GSBI_UART( 0, gnd, 1, 0, 0),
1259 F_GSBI_UART( 1843200, pll8, 1, 3, 625),
1260 F_GSBI_UART( 3686400, pll8, 1, 6, 625),
1261 F_GSBI_UART( 7372800, pll8, 1, 12, 625),
1262 F_GSBI_UART(14745600, pll8, 1, 24, 625),
1263 F_GSBI_UART(16000000, pll8, 4, 1, 6),
1264 F_GSBI_UART(24000000, pll8, 4, 1, 4),
1265 F_GSBI_UART(32000000, pll8, 4, 1, 3),
1266 F_GSBI_UART(40000000, pll8, 1, 5, 48),
1267 F_GSBI_UART(46400000, pll8, 1, 29, 240),
1268 F_GSBI_UART(48000000, pll8, 4, 1, 2),
1269 F_GSBI_UART(51200000, pll8, 1, 2, 15),
1270 F_GSBI_UART(56000000, pll8, 1, 7, 48),
1271 F_GSBI_UART(58982400, pll8, 1, 96, 625),
1272 F_GSBI_UART(64000000, pll8, 2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001273 F_END
1274};
1275
1276static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1277static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1278static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1279static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1280static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1281static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1282static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1283static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1284static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1285static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1286static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1287static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1288
1289#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1290 struct rcg_clk i##_clk = { \
1291 .b = { \
1292 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1293 .en_mask = BIT(9), \
1294 .reset_reg = GSBIn_RESET_REG(n), \
1295 .reset_mask = BIT(0), \
1296 .halt_reg = h_r, \
1297 .halt_bit = h_b, \
1298 }, \
1299 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1300 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1301 .root_en_mask = BIT(11), \
1302 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1303 .set_rate = set_rate_mnd, \
1304 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001305 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001306 .c = { \
1307 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001308 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001309 VDD_DIG_FMAX_MAP2(LOW, 24000000, NOMINAL, 52000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001310 CLK_INIT(i##_clk.c), \
1311 }, \
1312 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001313#define F_GSBI_QUP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001314 { \
1315 .freq_hz = f, \
1316 .src_clk = &s##_clk.c, \
1317 .md_val = MD8(16, m, 0, n), \
1318 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1319 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001320 }
1321static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001322 F_GSBI_QUP( 0, gnd, 1, 0, 0),
1323 F_GSBI_QUP( 1100000, pxo, 1, 2, 49),
1324 F_GSBI_QUP( 5400000, pxo, 1, 1, 5),
1325 F_GSBI_QUP(10800000, pxo, 1, 2, 5),
1326 F_GSBI_QUP(15060000, pll8, 1, 2, 51),
1327 F_GSBI_QUP(24000000, pll8, 4, 1, 4),
1328 F_GSBI_QUP(25600000, pll8, 1, 1, 15),
1329 F_GSBI_QUP(27000000, pxo, 1, 0, 0),
1330 F_GSBI_QUP(48000000, pll8, 4, 1, 2),
1331 F_GSBI_QUP(51200000, pll8, 1, 2, 15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001332 F_END
1333};
1334
1335static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1336static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1337static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1338static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1339static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1340static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1341static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1342static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1343static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1344static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1345static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1346static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1347
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001348#define F_QDSS(f, s, d) \
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001349 { \
1350 .freq_hz = f, \
1351 .src_clk = &s##_clk.c, \
1352 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001353 }
1354static struct clk_freq_tbl clk_tbl_qdss[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001355 F_QDSS( 27000000, pxo, 1),
1356 F_QDSS(128000000, pll8, 3),
1357 F_QDSS(300000000, pll3, 4),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001358 F_END
1359};
1360
1361struct qdss_bank {
1362 const u32 bank_sel_mask;
1363 void __iomem *const ns_reg;
1364 const u32 ns_mask;
1365};
1366
Stephen Boydd4de6d72011-09-13 13:01:40 -07001367#define QDSS_CLK_ROOT_ENA BIT(1)
1368
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001369static int qdss_clk_handoff(struct clk *c)
Stephen Boydd4de6d72011-09-13 13:01:40 -07001370{
1371 struct rcg_clk *clk = to_rcg_clk(c);
1372 const struct qdss_bank *bank = clk->bank_info;
1373 u32 reg, ns_val, bank_sel;
1374 struct clk_freq_tbl *freq;
1375
1376 reg = readl_relaxed(clk->ns_reg);
1377 if (!(reg & QDSS_CLK_ROOT_ENA))
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001378 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001379
1380 bank_sel = reg & bank->bank_sel_mask;
1381 /* Force bank 1 to PXO if bank 0 is in use */
1382 if (bank_sel == 0)
1383 writel_relaxed(0, bank->ns_reg);
1384 ns_val = readl_relaxed(bank->ns_reg) & bank->ns_mask;
1385 for (freq = clk->freq_tbl; freq->freq_hz != FREQ_END; freq++) {
1386 if ((freq->ns_val & bank->ns_mask) == ns_val) {
1387 pr_info("%s rate=%d\n", clk->c.dbg_name, freq->freq_hz);
1388 break;
1389 }
1390 }
1391 if (freq->freq_hz == FREQ_END)
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001392 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001393
1394 clk->current_freq = freq;
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001395
1396 return 1;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001397}
1398
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001399static void set_rate_qdss(struct rcg_clk *clk, struct clk_freq_tbl *nf)
1400{
1401 const struct qdss_bank *bank = clk->bank_info;
1402 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1403
1404 /* Switch to bank 0 (always sourced from PXO) */
1405 reg = readl_relaxed(clk->ns_reg);
1406 reg &= ~bank_sel_mask;
1407 writel_relaxed(reg, clk->ns_reg);
1408 /*
1409 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1410 * MUX to fully switch sources.
1411 */
1412 mb();
1413 udelay(1);
1414
1415 /* Set source and divider */
1416 reg = readl_relaxed(bank->ns_reg);
1417 reg &= ~bank->ns_mask;
1418 reg |= nf->ns_val;
1419 writel_relaxed(reg, bank->ns_reg);
1420
1421 /* Switch to reprogrammed bank */
1422 reg = readl_relaxed(clk->ns_reg);
1423 reg |= bank_sel_mask;
1424 writel_relaxed(reg, clk->ns_reg);
1425 /*
1426 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1427 * MUX to fully switch sources.
1428 */
1429 mb();
1430 udelay(1);
1431}
1432
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001433static int qdss_clk_enable(struct clk *c)
1434{
1435 struct rcg_clk *clk = to_rcg_clk(c);
1436 const struct qdss_bank *bank = clk->bank_info;
1437 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1438 int ret;
1439
1440 /* Switch to bank 1 */
1441 reg = readl_relaxed(clk->ns_reg);
1442 reg |= bank_sel_mask;
1443 writel_relaxed(reg, clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001444
1445 ret = rcg_clk_enable(c);
1446 if (ret) {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001447 /* Switch to bank 0 */
1448 reg &= ~bank_sel_mask;
1449 writel_relaxed(reg, clk->ns_reg);
1450 }
1451 return ret;
1452}
1453
1454static void qdss_clk_disable(struct clk *c)
1455{
1456 struct rcg_clk *clk = to_rcg_clk(c);
1457 const struct qdss_bank *bank = clk->bank_info;
1458 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1459
1460 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001461 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001462 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001463 reg &= ~bank_sel_mask;
1464 writel_relaxed(reg, clk->ns_reg);
1465}
1466
1467static void qdss_clk_auto_off(struct clk *c)
1468{
1469 struct rcg_clk *clk = to_rcg_clk(c);
1470 const struct qdss_bank *bank = clk->bank_info;
1471 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1472
Matt Wagantall41af0772011-09-17 12:21:39 -07001473 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001474 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001475 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001476 reg &= ~bank_sel_mask;
1477 writel_relaxed(reg, clk->ns_reg);
1478}
1479
1480static struct clk_ops clk_ops_qdss = {
1481 .enable = qdss_clk_enable,
1482 .disable = qdss_clk_disable,
1483 .auto_off = qdss_clk_auto_off,
Stephen Boydd4de6d72011-09-13 13:01:40 -07001484 .handoff = qdss_clk_handoff,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001485 .set_rate = rcg_clk_set_rate,
1486 .set_min_rate = rcg_clk_set_min_rate,
1487 .get_rate = rcg_clk_get_rate,
1488 .list_rate = rcg_clk_list_rate,
1489 .is_enabled = rcg_clk_is_enabled,
1490 .round_rate = rcg_clk_round_rate,
1491 .reset = soc_clk_reset,
1492 .is_local = local_clk_is_local,
1493 .get_parent = rcg_clk_get_parent,
1494};
1495
1496static struct qdss_bank bdiv_info_qdss = {
1497 .bank_sel_mask = BIT(0),
1498 .ns_reg = QDSS_AT_CLK_SRC1_NS_REG,
1499 .ns_mask = BM(6, 0),
1500};
1501
1502static struct rcg_clk qdss_at_clk = {
1503 .b = {
1504 .ctl_reg = QDSS_AT_CLK_NS_REG,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001505 .reset_reg = QDSS_RESETS_REG,
1506 .reset_mask = BIT(0),
Stephen Boydfcfd4dd2011-09-13 12:49:57 -07001507 .halt_check = NOCHECK,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001508 },
1509 .ns_reg = QDSS_AT_CLK_SRC_CTL_REG,
1510 .set_rate = set_rate_qdss,
1511 .freq_tbl = clk_tbl_qdss,
1512 .bank_info = &bdiv_info_qdss,
1513 .current_freq = &rcg_dummy_freq,
1514 .c = {
1515 .dbg_name = "qdss_at_clk",
1516 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001517 VDD_DIG_FMAX_MAP2(LOW, 150000000, NOMINAL, 300000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001518 CLK_INIT(qdss_at_clk.c),
1519 },
1520};
1521
1522static struct branch_clk qdss_pclkdbg_clk = {
1523 .b = {
1524 .ctl_reg = QDSS_AT_CLK_NS_REG,
1525 .en_mask = BIT(4),
1526 .reset_reg = QDSS_RESETS_REG,
1527 .reset_mask = BIT(0),
1528 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1529 .halt_bit = 9,
1530 .halt_check = HALT_VOTED
1531 },
1532 .parent = &qdss_at_clk.c,
1533 .c = {
1534 .dbg_name = "qdss_pclkdbg_clk",
1535 .ops = &clk_ops_branch,
1536 CLK_INIT(qdss_pclkdbg_clk.c),
1537 },
1538};
1539
1540static struct qdss_bank bdiv_info_qdss_trace = {
1541 .bank_sel_mask = BIT(0),
1542 .ns_reg = QDSS_TRACECLKIN_CLK_SRC1_NS_REG,
1543 .ns_mask = BM(6, 0),
1544};
1545
1546static struct rcg_clk qdss_traceclkin_clk = {
1547 .b = {
1548 .ctl_reg = QDSS_TRACECLKIN_CTL_REG,
1549 .en_mask = BIT(4),
1550 .reset_reg = QDSS_RESETS_REG,
1551 .reset_mask = BIT(0),
1552 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1553 .halt_bit = 8,
1554 .halt_check = HALT_VOTED,
1555 },
1556 .ns_reg = QDSS_TRACECLKIN_CLK_SRC_CTL_REG,
1557 .set_rate = set_rate_qdss,
1558 .freq_tbl = clk_tbl_qdss,
1559 .bank_info = &bdiv_info_qdss_trace,
1560 .current_freq = &rcg_dummy_freq,
1561 .c = {
1562 .dbg_name = "qdss_traceclkin_clk",
1563 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001564 VDD_DIG_FMAX_MAP2(LOW, 150000000, NOMINAL, 300000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001565 CLK_INIT(qdss_traceclkin_clk.c),
1566 },
1567};
1568
1569static struct clk_freq_tbl clk_tbl_qdss_tsctr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001570 F_QDSS( 27000000, pxo, 1),
1571 F_QDSS(200000000, pll3, 6),
1572 F_QDSS(400000000, pll3, 3),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001573 F_END
1574};
1575
1576static struct qdss_bank bdiv_info_qdss_tsctr = {
1577 .bank_sel_mask = BIT(0),
1578 .ns_reg = QDSS_TSCTR_CLK_SRC1_NS_REG,
1579 .ns_mask = BM(6, 0),
1580};
1581
1582static struct rcg_clk qdss_tsctr_clk = {
1583 .b = {
1584 .ctl_reg = QDSS_TSCTR_CTL_REG,
1585 .en_mask = BIT(4),
1586 .reset_reg = QDSS_RESETS_REG,
1587 .reset_mask = BIT(3),
1588 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1589 .halt_bit = 7,
1590 .halt_check = HALT_VOTED,
1591 },
1592 .ns_reg = QDSS_TSCTR_CLK_SRC_CTL_REG,
1593 .set_rate = set_rate_qdss,
1594 .freq_tbl = clk_tbl_qdss_tsctr,
1595 .bank_info = &bdiv_info_qdss_tsctr,
1596 .current_freq = &rcg_dummy_freq,
1597 .c = {
1598 .dbg_name = "qdss_tsctr_clk",
1599 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001600 VDD_DIG_FMAX_MAP2(LOW, 200000000, NOMINAL, 400000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001601 CLK_INIT(qdss_tsctr_clk.c),
1602 },
1603};
1604
1605static struct branch_clk qdss_stm_clk = {
1606 .b = {
1607 .ctl_reg = QDSS_STM_CLK_CTL_REG,
1608 .en_mask = BIT(4),
1609 .reset_reg = QDSS_RESETS_REG,
1610 .reset_mask = BIT(1),
1611 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
1612 .halt_bit = 20,
1613 .halt_check = HALT_VOTED,
1614 },
1615 .c = {
1616 .dbg_name = "qdss_stm_clk",
1617 .ops = &clk_ops_branch,
1618 CLK_INIT(qdss_stm_clk.c),
1619 },
1620};
1621
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001622#define F_PDM(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001623 { \
1624 .freq_hz = f, \
1625 .src_clk = &s##_clk.c, \
1626 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001627 }
1628static struct clk_freq_tbl clk_tbl_pdm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001629 F_PDM( 0, gnd, 1),
1630 F_PDM(27000000, pxo, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001631 F_END
1632};
1633
1634static struct rcg_clk pdm_clk = {
1635 .b = {
1636 .ctl_reg = PDM_CLK_NS_REG,
1637 .en_mask = BIT(9),
1638 .reset_reg = PDM_CLK_NS_REG,
1639 .reset_mask = BIT(12),
1640 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1641 .halt_bit = 3,
1642 },
1643 .ns_reg = PDM_CLK_NS_REG,
1644 .root_en_mask = BIT(11),
1645 .ns_mask = BM(1, 0),
1646 .set_rate = set_rate_nop,
1647 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001648 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001649 .c = {
1650 .dbg_name = "pdm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001651 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001652 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001653 CLK_INIT(pdm_clk.c),
1654 },
1655};
1656
1657static struct branch_clk pmem_clk = {
1658 .b = {
1659 .ctl_reg = PMEM_ACLK_CTL_REG,
1660 .en_mask = BIT(4),
1661 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1662 .halt_bit = 20,
1663 },
1664 .c = {
1665 .dbg_name = "pmem_clk",
1666 .ops = &clk_ops_branch,
1667 CLK_INIT(pmem_clk.c),
1668 },
1669};
1670
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001671#define F_PRNG(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001672 { \
1673 .freq_hz = f, \
1674 .src_clk = &s##_clk.c, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001675 }
1676static struct clk_freq_tbl clk_tbl_prng[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001677 F_PRNG(64000000, pll8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001678 F_END
1679};
1680
1681static struct rcg_clk prng_clk = {
1682 .b = {
1683 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1684 .en_mask = BIT(10),
1685 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1686 .halt_check = HALT_VOTED,
1687 .halt_bit = 10,
1688 },
1689 .set_rate = set_rate_nop,
1690 .freq_tbl = clk_tbl_prng,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001691 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001692 .c = {
1693 .dbg_name = "prng_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001694 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001695 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 65000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001696 CLK_INIT(prng_clk.c),
1697 },
1698};
1699
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001700#define CLK_SDC(name, n, h_b, fmax_low, fmax_nom) \
Stephen Boyda78a7402011-08-02 11:23:39 -07001701 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001702 .b = { \
1703 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1704 .en_mask = BIT(9), \
1705 .reset_reg = SDCn_RESET_REG(n), \
1706 .reset_mask = BIT(0), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001707 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001708 .halt_bit = h_b, \
1709 }, \
1710 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1711 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1712 .root_en_mask = BIT(11), \
1713 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1714 .set_rate = set_rate_mnd, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001715 .freq_tbl = clk_tbl_sdc, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001716 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001717 .c = { \
Stephen Boyda78a7402011-08-02 11:23:39 -07001718 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001719 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001720 VDD_DIG_FMAX_MAP2(LOW, fmax_low, NOMINAL, fmax_nom), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001721 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001722 }, \
1723 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001724#define F_SDC(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001725 { \
1726 .freq_hz = f, \
1727 .src_clk = &s##_clk.c, \
1728 .md_val = MD8(16, m, 0, n), \
1729 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1730 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001731 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001732static struct clk_freq_tbl clk_tbl_sdc[] = {
1733 F_SDC( 0, gnd, 1, 0, 0),
1734 F_SDC( 144000, pxo, 3, 2, 125),
1735 F_SDC( 400000, pll8, 4, 1, 240),
1736 F_SDC( 16000000, pll8, 4, 1, 6),
1737 F_SDC( 17070000, pll8, 1, 2, 45),
1738 F_SDC( 20210000, pll8, 1, 1, 19),
1739 F_SDC( 24000000, pll8, 4, 1, 4),
1740 F_SDC( 48000000, pll8, 4, 1, 2),
1741 F_SDC( 64000000, pll8, 3, 1, 2),
1742 F_SDC( 96000000, pll8, 4, 0, 0),
Stephen Boyda78a7402011-08-02 11:23:39 -07001743 F_END
1744};
1745
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001746static CLK_SDC(sdc1_clk, 1, 6, 52000000, 104000000);
1747static CLK_SDC(sdc2_clk, 2, 5, 52000000, 104000000);
1748static CLK_SDC(sdc3_clk, 3, 4, 104000000, 208000000);
1749static CLK_SDC(sdc4_clk, 4, 3, 33000000, 67000000);
1750static CLK_SDC(sdc5_clk, 5, 2, 33000000, 67000000);
Stephen Boyda78a7402011-08-02 11:23:39 -07001751
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001752#define F_TSIF_REF(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001753 { \
1754 .freq_hz = f, \
1755 .src_clk = &s##_clk.c, \
1756 .md_val = MD16(m, n), \
1757 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1758 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001759 }
1760static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001761 F_TSIF_REF( 0, gnd, 1, 0, 0),
1762 F_TSIF_REF(105000, pxo, 1, 1, 256),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001763 F_END
1764};
1765
1766static struct rcg_clk tsif_ref_clk = {
1767 .b = {
1768 .ctl_reg = TSIF_REF_CLK_NS_REG,
1769 .en_mask = BIT(9),
1770 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1771 .halt_bit = 5,
1772 },
1773 .ns_reg = TSIF_REF_CLK_NS_REG,
1774 .md_reg = TSIF_REF_CLK_MD_REG,
1775 .root_en_mask = BIT(11),
1776 .ns_mask = (BM(31, 16) | BM(6, 0)),
1777 .set_rate = set_rate_mnd,
1778 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001779 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001780 .c = {
1781 .dbg_name = "tsif_ref_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001782 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001783 VDD_DIG_FMAX_MAP2(LOW, 27000000, NOMINAL, 54000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001784 CLK_INIT(tsif_ref_clk.c),
1785 },
1786};
1787
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001788#define F_TSSC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001789 { \
1790 .freq_hz = f, \
1791 .src_clk = &s##_clk.c, \
1792 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001793 }
1794static struct clk_freq_tbl clk_tbl_tssc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001795 F_TSSC( 0, gnd),
1796 F_TSSC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001797 F_END
1798};
1799
1800static struct rcg_clk tssc_clk = {
1801 .b = {
1802 .ctl_reg = TSSC_CLK_CTL_REG,
1803 .en_mask = BIT(4),
1804 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1805 .halt_bit = 4,
1806 },
1807 .ns_reg = TSSC_CLK_CTL_REG,
1808 .ns_mask = BM(1, 0),
1809 .set_rate = set_rate_nop,
1810 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001811 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001812 .c = {
1813 .dbg_name = "tssc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001814 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001815 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001816 CLK_INIT(tssc_clk.c),
1817 },
1818};
1819
Tianyi Gou41515e22011-09-01 19:37:43 -07001820#define CLK_USB_HS(name, n, h_b) \
1821 static struct rcg_clk name = { \
1822 .b = { \
1823 .ctl_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1824 .en_mask = BIT(9), \
1825 .reset_reg = USB_HS##n##_RESET_REG, \
1826 .reset_mask = BIT(0), \
1827 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
1828 .halt_bit = h_b, \
1829 }, \
1830 .ns_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1831 .md_reg = USB_HS##n##_XCVR_FS_CLK_MD_REG, \
1832 .root_en_mask = BIT(11), \
1833 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1834 .set_rate = set_rate_mnd, \
1835 .freq_tbl = clk_tbl_usb, \
1836 .current_freq = &rcg_dummy_freq, \
1837 .c = { \
1838 .dbg_name = #name, \
1839 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001840 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001841 CLK_INIT(name.c), \
1842 }, \
1843}
1844
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001845#define F_USB(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001846 { \
1847 .freq_hz = f, \
1848 .src_clk = &s##_clk.c, \
1849 .md_val = MD8(16, m, 0, n), \
1850 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1851 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001852 }
1853static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001854 F_USB( 0, gnd, 1, 0, 0),
1855 F_USB(60000000, pll8, 1, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001856 F_END
1857};
1858
Tianyi Gou41515e22011-09-01 19:37:43 -07001859CLK_USB_HS(usb_hs1_xcvr_clk, 1, 0);
1860CLK_USB_HS(usb_hs3_xcvr_clk, 3, 30);
1861CLK_USB_HS(usb_hs4_xcvr_clk, 4, 2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001862
Stephen Boyd94625ef2011-07-12 17:06:01 -07001863static struct clk_freq_tbl clk_tbl_usb_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001864 F_USB( 0, gnd, 1, 0, 0),
1865 F_USB(60000000, pll8, 1, 5, 32),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001866 F_END
1867};
1868
1869static struct rcg_clk usb_hsic_xcvr_fs_clk = {
1870 .b = {
1871 .ctl_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1872 .en_mask = BIT(9),
1873 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1874 .halt_bit = 26,
1875 },
1876 .ns_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1877 .md_reg = USB_HSIC_XCVR_FS_CLK_MD_REG,
1878 .root_en_mask = BIT(11),
1879 .ns_mask = (BM(23, 16) | BM(6, 0)),
1880 .set_rate = set_rate_mnd,
1881 .freq_tbl = clk_tbl_usb_hsic,
1882 .current_freq = &rcg_dummy_freq,
1883 .c = {
1884 .dbg_name = "usb_hsic_xcvr_fs_clk",
1885 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001886 VDD_DIG_FMAX_MAP1(LOW, 60000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001887 CLK_INIT(usb_hsic_xcvr_fs_clk.c),
1888 },
1889};
1890
1891static struct branch_clk usb_hsic_system_clk = {
1892 .b = {
1893 .ctl_reg = USB_HSIC_SYSTEM_CLK_CTL_REG,
1894 .en_mask = BIT(4),
1895 .reset_reg = USB_HSIC_RESET_REG,
1896 .reset_mask = BIT(0),
1897 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1898 .halt_bit = 24,
1899 },
1900 .parent = &usb_hsic_xcvr_fs_clk.c,
1901 .c = {
1902 .dbg_name = "usb_hsic_system_clk",
1903 .ops = &clk_ops_branch,
1904 CLK_INIT(usb_hsic_system_clk.c),
1905 },
1906};
1907
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001908#define F_USB_HSIC(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001909 { \
1910 .freq_hz = f, \
1911 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001912 }
1913static struct clk_freq_tbl clk_tbl_usb2_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001914 F_USB_HSIC(480000000, pll14),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001915 F_END
1916};
1917
1918static struct rcg_clk usb_hsic_hsic_src_clk = {
1919 .b = {
1920 .ctl_reg = USB_HSIC_HSIC_CLK_SRC_CTL_REG,
1921 .halt_check = NOCHECK,
1922 },
1923 .root_en_mask = BIT(0),
1924 .set_rate = set_rate_nop,
1925 .freq_tbl = clk_tbl_usb2_hsic,
1926 .current_freq = &rcg_dummy_freq,
1927 .c = {
1928 .dbg_name = "usb_hsic_hsic_src_clk",
1929 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001930 VDD_DIG_FMAX_MAP1(LOW, 480000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001931 CLK_INIT(usb_hsic_hsic_src_clk.c),
1932 },
1933};
1934
1935static struct branch_clk usb_hsic_hsic_clk = {
1936 .b = {
1937 .ctl_reg = USB_HSIC_HSIC_CLK_CTL_REG,
1938 .en_mask = BIT(0),
1939 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1940 .halt_bit = 19,
1941 },
1942 .parent = &usb_hsic_hsic_src_clk.c,
1943 .c = {
1944 .dbg_name = "usb_hsic_hsic_clk",
1945 .ops = &clk_ops_branch,
1946 CLK_INIT(usb_hsic_hsic_clk.c),
1947 },
1948};
1949
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001950#define F_USB_HSIO_CAL(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001951 { \
1952 .freq_hz = f, \
1953 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001954 }
1955static struct clk_freq_tbl clk_tbl_usb_hsio_cal[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001956 F_USB_HSIO_CAL(9000000, pxo),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001957 F_END
1958};
1959
1960static struct rcg_clk usb_hsic_hsio_cal_clk = {
1961 .b = {
1962 .ctl_reg = USB_HSIC_HSIO_CAL_CLK_CTL_REG,
1963 .en_mask = BIT(0),
1964 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1965 .halt_bit = 23,
1966 },
1967 .set_rate = set_rate_nop,
1968 .freq_tbl = clk_tbl_usb_hsio_cal,
1969 .current_freq = &rcg_dummy_freq,
1970 .c = {
1971 .dbg_name = "usb_hsic_hsio_cal_clk",
Stephen Boyda0e82ec2011-09-19 12:18:45 -07001972 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001973 VDD_DIG_FMAX_MAP1(LOW, 10000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001974 CLK_INIT(usb_hsic_hsio_cal_clk.c),
1975 },
1976};
1977
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001978static struct branch_clk usb_phy0_clk = {
1979 .b = {
1980 .reset_reg = USB_PHY0_RESET_REG,
1981 .reset_mask = BIT(0),
1982 },
1983 .c = {
1984 .dbg_name = "usb_phy0_clk",
1985 .ops = &clk_ops_reset,
1986 CLK_INIT(usb_phy0_clk.c),
1987 },
1988};
1989
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001990#define CLK_USB_FS(i, n, fmax_nom) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001991 struct rcg_clk i##_clk = { \
1992 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1993 .b = { \
1994 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1995 .halt_check = NOCHECK, \
1996 }, \
1997 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
1998 .root_en_mask = BIT(11), \
1999 .ns_mask = (BM(23, 16) | BM(6, 0)), \
2000 .set_rate = set_rate_mnd, \
2001 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002002 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002003 .c = { \
2004 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002005 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002006 VDD_DIG_FMAX_MAP1(NOMINAL, fmax_nom), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002007 CLK_INIT(i##_clk.c), \
2008 }, \
2009 }
2010
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002011static CLK_USB_FS(usb_fs1_src, 1, 64000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002012static struct branch_clk usb_fs1_xcvr_clk = {
2013 .b = {
2014 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
2015 .en_mask = BIT(9),
2016 .reset_reg = USB_FSn_RESET_REG(1),
2017 .reset_mask = BIT(1),
2018 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2019 .halt_bit = 15,
2020 },
2021 .parent = &usb_fs1_src_clk.c,
2022 .c = {
2023 .dbg_name = "usb_fs1_xcvr_clk",
2024 .ops = &clk_ops_branch,
2025 CLK_INIT(usb_fs1_xcvr_clk.c),
2026 },
2027};
2028
2029static struct branch_clk usb_fs1_sys_clk = {
2030 .b = {
2031 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
2032 .en_mask = BIT(4),
2033 .reset_reg = USB_FSn_RESET_REG(1),
2034 .reset_mask = BIT(0),
2035 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2036 .halt_bit = 16,
2037 },
2038 .parent = &usb_fs1_src_clk.c,
2039 .c = {
2040 .dbg_name = "usb_fs1_sys_clk",
2041 .ops = &clk_ops_branch,
2042 CLK_INIT(usb_fs1_sys_clk.c),
2043 },
2044};
2045
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002046static CLK_USB_FS(usb_fs2_src, 2, 60000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002047static struct branch_clk usb_fs2_xcvr_clk = {
2048 .b = {
2049 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
2050 .en_mask = BIT(9),
2051 .reset_reg = USB_FSn_RESET_REG(2),
2052 .reset_mask = BIT(1),
2053 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2054 .halt_bit = 12,
2055 },
2056 .parent = &usb_fs2_src_clk.c,
2057 .c = {
2058 .dbg_name = "usb_fs2_xcvr_clk",
2059 .ops = &clk_ops_branch,
2060 CLK_INIT(usb_fs2_xcvr_clk.c),
2061 },
2062};
2063
2064static struct branch_clk usb_fs2_sys_clk = {
2065 .b = {
2066 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
2067 .en_mask = BIT(4),
2068 .reset_reg = USB_FSn_RESET_REG(2),
2069 .reset_mask = BIT(0),
2070 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2071 .halt_bit = 13,
2072 },
2073 .parent = &usb_fs2_src_clk.c,
2074 .c = {
2075 .dbg_name = "usb_fs2_sys_clk",
2076 .ops = &clk_ops_branch,
2077 CLK_INIT(usb_fs2_sys_clk.c),
2078 },
2079};
2080
2081/* Fast Peripheral Bus Clocks */
2082static struct branch_clk ce1_core_clk = {
2083 .b = {
2084 .ctl_reg = CE1_CORE_CLK_CTL_REG,
2085 .en_mask = BIT(4),
2086 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2087 .halt_bit = 27,
2088 },
2089 .c = {
2090 .dbg_name = "ce1_core_clk",
2091 .ops = &clk_ops_branch,
2092 CLK_INIT(ce1_core_clk.c),
2093 },
2094};
Tianyi Gou41515e22011-09-01 19:37:43 -07002095
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002096static struct branch_clk ce1_p_clk = {
2097 .b = {
2098 .ctl_reg = CE1_HCLK_CTL_REG,
2099 .en_mask = BIT(4),
2100 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2101 .halt_bit = 1,
2102 },
2103 .c = {
2104 .dbg_name = "ce1_p_clk",
2105 .ops = &clk_ops_branch,
2106 CLK_INIT(ce1_p_clk.c),
2107 },
2108};
2109
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002110#define F_CE3(f, s, d) \
Tianyi Gou41515e22011-09-01 19:37:43 -07002111 { \
2112 .freq_hz = f, \
2113 .src_clk = &s##_clk.c, \
2114 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Tianyi Gou41515e22011-09-01 19:37:43 -07002115 }
2116
2117static struct clk_freq_tbl clk_tbl_ce3[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002118 F_CE3( 0, gnd, 1),
2119 F_CE3( 48000000, pll8, 8),
2120 F_CE3(100000000, pll3, 12),
Tianyi Gou41515e22011-09-01 19:37:43 -07002121 F_END
2122};
2123
2124static struct rcg_clk ce3_src_clk = {
2125 .b = {
2126 .ctl_reg = CE3_CLK_SRC_NS_REG,
2127 .halt_check = NOCHECK,
2128 },
2129 .ns_reg = CE3_CLK_SRC_NS_REG,
2130 .root_en_mask = BIT(7),
2131 .ns_mask = BM(6, 0),
2132 .set_rate = set_rate_nop,
2133 .freq_tbl = clk_tbl_ce3,
2134 .current_freq = &rcg_dummy_freq,
2135 .c = {
2136 .dbg_name = "ce3_src_clk",
2137 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002138 VDD_DIG_FMAX_MAP2(LOW, 50000000, NOMINAL, 100000000),
Tianyi Gou41515e22011-09-01 19:37:43 -07002139 CLK_INIT(ce3_src_clk.c),
2140 },
2141};
2142
2143static struct branch_clk ce3_core_clk = {
2144 .b = {
2145 .ctl_reg = CE3_CORE_CLK_CTL_REG,
2146 .en_mask = BIT(4),
2147 .reset_reg = CE3_CORE_CLK_CTL_REG,
2148 .reset_mask = BIT(7),
2149 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2150 .halt_bit = 5,
2151 },
2152 .parent = &ce3_src_clk.c,
2153 .c = {
2154 .dbg_name = "ce3_core_clk",
2155 .ops = &clk_ops_branch,
2156 CLK_INIT(ce3_core_clk.c),
2157 }
2158};
2159
2160static struct branch_clk ce3_p_clk = {
2161 .b = {
2162 .ctl_reg = CE3_HCLK_CTL_REG,
2163 .en_mask = BIT(4),
2164 .reset_reg = CE3_HCLK_CTL_REG,
2165 .reset_mask = BIT(7),
2166 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
2167 .halt_bit = 16,
2168 },
2169 .parent = &ce3_src_clk.c,
2170 .c = {
2171 .dbg_name = "ce3_p_clk",
2172 .ops = &clk_ops_branch,
2173 CLK_INIT(ce3_p_clk.c),
2174 }
2175};
2176
2177static struct branch_clk sata_phy_ref_clk = {
2178 .b = {
2179 .ctl_reg = SATA_PHY_REF_CLK_CTL_REG,
2180 .en_mask = BIT(4),
2181 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2182 .halt_bit = 24,
2183 },
2184 .parent = &pxo_clk.c,
2185 .c = {
2186 .dbg_name = "sata_phy_ref_clk",
2187 .ops = &clk_ops_branch,
2188 CLK_INIT(sata_phy_ref_clk.c),
2189 },
2190};
2191
2192static struct branch_clk pcie_p_clk = {
2193 .b = {
2194 .ctl_reg = PCIE_HCLK_CTL_REG,
2195 .en_mask = BIT(4),
2196 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2197 .halt_bit = 8,
2198 },
2199 .c = {
2200 .dbg_name = "pcie_p_clk",
2201 .ops = &clk_ops_branch,
2202 CLK_INIT(pcie_p_clk.c),
2203 },
2204};
2205
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002206static struct branch_clk dma_bam_p_clk = {
2207 .b = {
2208 .ctl_reg = DMA_BAM_HCLK_CTL,
2209 .en_mask = BIT(4),
2210 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2211 .halt_bit = 12,
2212 },
2213 .c = {
2214 .dbg_name = "dma_bam_p_clk",
2215 .ops = &clk_ops_branch,
2216 CLK_INIT(dma_bam_p_clk.c),
2217 },
2218};
2219
2220static struct branch_clk gsbi1_p_clk = {
2221 .b = {
2222 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
2223 .en_mask = BIT(4),
2224 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2225 .halt_bit = 11,
2226 },
2227 .c = {
2228 .dbg_name = "gsbi1_p_clk",
2229 .ops = &clk_ops_branch,
2230 CLK_INIT(gsbi1_p_clk.c),
2231 },
2232};
2233
2234static struct branch_clk gsbi2_p_clk = {
2235 .b = {
2236 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
2237 .en_mask = BIT(4),
2238 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2239 .halt_bit = 7,
2240 },
2241 .c = {
2242 .dbg_name = "gsbi2_p_clk",
2243 .ops = &clk_ops_branch,
2244 CLK_INIT(gsbi2_p_clk.c),
2245 },
2246};
2247
2248static struct branch_clk gsbi3_p_clk = {
2249 .b = {
2250 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
2251 .en_mask = BIT(4),
2252 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2253 .halt_bit = 3,
2254 },
2255 .c = {
2256 .dbg_name = "gsbi3_p_clk",
2257 .ops = &clk_ops_branch,
2258 CLK_INIT(gsbi3_p_clk.c),
2259 },
2260};
2261
2262static struct branch_clk gsbi4_p_clk = {
2263 .b = {
2264 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
2265 .en_mask = BIT(4),
2266 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2267 .halt_bit = 27,
2268 },
2269 .c = {
2270 .dbg_name = "gsbi4_p_clk",
2271 .ops = &clk_ops_branch,
2272 CLK_INIT(gsbi4_p_clk.c),
2273 },
2274};
2275
2276static struct branch_clk gsbi5_p_clk = {
2277 .b = {
2278 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
2279 .en_mask = BIT(4),
2280 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2281 .halt_bit = 23,
2282 },
2283 .c = {
2284 .dbg_name = "gsbi5_p_clk",
2285 .ops = &clk_ops_branch,
2286 CLK_INIT(gsbi5_p_clk.c),
2287 },
2288};
2289
2290static struct branch_clk gsbi6_p_clk = {
2291 .b = {
2292 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
2293 .en_mask = BIT(4),
2294 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2295 .halt_bit = 19,
2296 },
2297 .c = {
2298 .dbg_name = "gsbi6_p_clk",
2299 .ops = &clk_ops_branch,
2300 CLK_INIT(gsbi6_p_clk.c),
2301 },
2302};
2303
2304static struct branch_clk gsbi7_p_clk = {
2305 .b = {
2306 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
2307 .en_mask = BIT(4),
2308 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2309 .halt_bit = 15,
2310 },
2311 .c = {
2312 .dbg_name = "gsbi7_p_clk",
2313 .ops = &clk_ops_branch,
2314 CLK_INIT(gsbi7_p_clk.c),
2315 },
2316};
2317
2318static struct branch_clk gsbi8_p_clk = {
2319 .b = {
2320 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
2321 .en_mask = BIT(4),
2322 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2323 .halt_bit = 11,
2324 },
2325 .c = {
2326 .dbg_name = "gsbi8_p_clk",
2327 .ops = &clk_ops_branch,
2328 CLK_INIT(gsbi8_p_clk.c),
2329 },
2330};
2331
2332static struct branch_clk gsbi9_p_clk = {
2333 .b = {
2334 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
2335 .en_mask = BIT(4),
2336 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2337 .halt_bit = 7,
2338 },
2339 .c = {
2340 .dbg_name = "gsbi9_p_clk",
2341 .ops = &clk_ops_branch,
2342 CLK_INIT(gsbi9_p_clk.c),
2343 },
2344};
2345
2346static struct branch_clk gsbi10_p_clk = {
2347 .b = {
2348 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
2349 .en_mask = BIT(4),
2350 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2351 .halt_bit = 3,
2352 },
2353 .c = {
2354 .dbg_name = "gsbi10_p_clk",
2355 .ops = &clk_ops_branch,
2356 CLK_INIT(gsbi10_p_clk.c),
2357 },
2358};
2359
2360static struct branch_clk gsbi11_p_clk = {
2361 .b = {
2362 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
2363 .en_mask = BIT(4),
2364 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2365 .halt_bit = 18,
2366 },
2367 .c = {
2368 .dbg_name = "gsbi11_p_clk",
2369 .ops = &clk_ops_branch,
2370 CLK_INIT(gsbi11_p_clk.c),
2371 },
2372};
2373
2374static struct branch_clk gsbi12_p_clk = {
2375 .b = {
2376 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
2377 .en_mask = BIT(4),
2378 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2379 .halt_bit = 14,
2380 },
2381 .c = {
2382 .dbg_name = "gsbi12_p_clk",
2383 .ops = &clk_ops_branch,
2384 CLK_INIT(gsbi12_p_clk.c),
2385 },
2386};
2387
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002388static struct branch_clk qdss_p_clk = {
2389 .b = {
2390 .ctl_reg = QDSS_HCLK_CTL_REG,
2391 .en_mask = BIT(4),
2392 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2393 .halt_bit = 11,
2394 .halt_check = HALT_VOTED,
2395 .reset_reg = QDSS_RESETS_REG,
2396 .reset_mask = BIT(2),
2397 },
2398 .c = {
2399 .dbg_name = "qdss_p_clk",
2400 .ops = &clk_ops_branch,
2401 CLK_INIT(qdss_p_clk.c),
Tianyi Gou41515e22011-09-01 19:37:43 -07002402 }
2403};
2404
2405static struct branch_clk sata_phy_cfg_clk = {
2406 .b = {
2407 .ctl_reg = SATA_PHY_CFG_CLK_CTL_REG,
2408 .en_mask = BIT(4),
2409 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2410 .halt_bit = 12,
2411 },
2412 .c = {
2413 .dbg_name = "sata_phy_cfg_clk",
2414 .ops = &clk_ops_branch,
2415 CLK_INIT(sata_phy_cfg_clk.c),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002416 },
2417};
2418
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002419static struct branch_clk tsif_p_clk = {
2420 .b = {
2421 .ctl_reg = TSIF_HCLK_CTL_REG,
2422 .en_mask = BIT(4),
2423 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2424 .halt_bit = 7,
2425 },
2426 .c = {
2427 .dbg_name = "tsif_p_clk",
2428 .ops = &clk_ops_branch,
2429 CLK_INIT(tsif_p_clk.c),
2430 },
2431};
2432
2433static struct branch_clk usb_fs1_p_clk = {
2434 .b = {
2435 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
2436 .en_mask = BIT(4),
2437 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2438 .halt_bit = 17,
2439 },
2440 .c = {
2441 .dbg_name = "usb_fs1_p_clk",
2442 .ops = &clk_ops_branch,
2443 CLK_INIT(usb_fs1_p_clk.c),
2444 },
2445};
2446
2447static struct branch_clk usb_fs2_p_clk = {
2448 .b = {
2449 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
2450 .en_mask = BIT(4),
2451 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2452 .halt_bit = 14,
2453 },
2454 .c = {
2455 .dbg_name = "usb_fs2_p_clk",
2456 .ops = &clk_ops_branch,
2457 CLK_INIT(usb_fs2_p_clk.c),
2458 },
2459};
2460
2461static struct branch_clk usb_hs1_p_clk = {
2462 .b = {
2463 .ctl_reg = USB_HS1_HCLK_CTL_REG,
2464 .en_mask = BIT(4),
2465 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2466 .halt_bit = 1,
2467 },
2468 .c = {
2469 .dbg_name = "usb_hs1_p_clk",
2470 .ops = &clk_ops_branch,
2471 CLK_INIT(usb_hs1_p_clk.c),
2472 },
2473};
2474
Tianyi Gou41515e22011-09-01 19:37:43 -07002475static struct branch_clk usb_hs3_p_clk = {
2476 .b = {
2477 .ctl_reg = USB_HS3_HCLK_CTL_REG,
2478 .en_mask = BIT(4),
2479 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2480 .halt_bit = 31,
2481 },
2482 .c = {
2483 .dbg_name = "usb_hs3_p_clk",
2484 .ops = &clk_ops_branch,
2485 CLK_INIT(usb_hs3_p_clk.c),
2486 },
2487};
2488
2489static struct branch_clk usb_hs4_p_clk = {
2490 .b = {
2491 .ctl_reg = USB_HS4_HCLK_CTL_REG,
2492 .en_mask = BIT(4),
2493 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2494 .halt_bit = 7,
2495 },
2496 .c = {
2497 .dbg_name = "usb_hs4_p_clk",
2498 .ops = &clk_ops_branch,
2499 CLK_INIT(usb_hs4_p_clk.c),
2500 },
2501};
2502
Stephen Boyd94625ef2011-07-12 17:06:01 -07002503static struct branch_clk usb_hsic_p_clk = {
2504 .b = {
2505 .ctl_reg = USB_HSIC_HCLK_CTL_REG,
2506 .en_mask = BIT(4),
2507 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2508 .halt_bit = 28,
2509 },
2510 .c = {
2511 .dbg_name = "usb_hsic_p_clk",
2512 .ops = &clk_ops_branch,
2513 CLK_INIT(usb_hsic_p_clk.c),
2514 },
2515};
2516
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002517static struct branch_clk sdc1_p_clk = {
2518 .b = {
2519 .ctl_reg = SDCn_HCLK_CTL_REG(1),
2520 .en_mask = BIT(4),
2521 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2522 .halt_bit = 11,
2523 },
2524 .c = {
2525 .dbg_name = "sdc1_p_clk",
2526 .ops = &clk_ops_branch,
2527 CLK_INIT(sdc1_p_clk.c),
2528 },
2529};
2530
2531static struct branch_clk sdc2_p_clk = {
2532 .b = {
2533 .ctl_reg = SDCn_HCLK_CTL_REG(2),
2534 .en_mask = BIT(4),
2535 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2536 .halt_bit = 10,
2537 },
2538 .c = {
2539 .dbg_name = "sdc2_p_clk",
2540 .ops = &clk_ops_branch,
2541 CLK_INIT(sdc2_p_clk.c),
2542 },
2543};
2544
2545static struct branch_clk sdc3_p_clk = {
2546 .b = {
2547 .ctl_reg = SDCn_HCLK_CTL_REG(3),
2548 .en_mask = BIT(4),
2549 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2550 .halt_bit = 9,
2551 },
2552 .c = {
2553 .dbg_name = "sdc3_p_clk",
2554 .ops = &clk_ops_branch,
2555 CLK_INIT(sdc3_p_clk.c),
2556 },
2557};
2558
2559static struct branch_clk sdc4_p_clk = {
2560 .b = {
2561 .ctl_reg = SDCn_HCLK_CTL_REG(4),
2562 .en_mask = BIT(4),
2563 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2564 .halt_bit = 8,
2565 },
2566 .c = {
2567 .dbg_name = "sdc4_p_clk",
2568 .ops = &clk_ops_branch,
2569 CLK_INIT(sdc4_p_clk.c),
2570 },
2571};
2572
2573static struct branch_clk sdc5_p_clk = {
2574 .b = {
2575 .ctl_reg = SDCn_HCLK_CTL_REG(5),
2576 .en_mask = BIT(4),
2577 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2578 .halt_bit = 7,
2579 },
2580 .c = {
2581 .dbg_name = "sdc5_p_clk",
2582 .ops = &clk_ops_branch,
2583 CLK_INIT(sdc5_p_clk.c),
2584 },
2585};
2586
2587/* HW-Voteable Clocks */
2588static struct branch_clk adm0_clk = {
2589 .b = {
2590 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2591 .en_mask = BIT(2),
2592 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2593 .halt_check = HALT_VOTED,
2594 .halt_bit = 14,
2595 },
2596 .c = {
2597 .dbg_name = "adm0_clk",
2598 .ops = &clk_ops_branch,
2599 CLK_INIT(adm0_clk.c),
2600 },
2601};
2602
2603static struct branch_clk adm0_p_clk = {
2604 .b = {
2605 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2606 .en_mask = BIT(3),
2607 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2608 .halt_check = HALT_VOTED,
2609 .halt_bit = 13,
2610 },
2611 .c = {
2612 .dbg_name = "adm0_p_clk",
2613 .ops = &clk_ops_branch,
2614 CLK_INIT(adm0_p_clk.c),
2615 },
2616};
2617
2618static struct branch_clk pmic_arb0_p_clk = {
2619 .b = {
2620 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2621 .en_mask = BIT(8),
2622 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2623 .halt_check = HALT_VOTED,
2624 .halt_bit = 22,
2625 },
2626 .c = {
2627 .dbg_name = "pmic_arb0_p_clk",
2628 .ops = &clk_ops_branch,
2629 CLK_INIT(pmic_arb0_p_clk.c),
2630 },
2631};
2632
2633static struct branch_clk pmic_arb1_p_clk = {
2634 .b = {
2635 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2636 .en_mask = BIT(9),
2637 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2638 .halt_check = HALT_VOTED,
2639 .halt_bit = 21,
2640 },
2641 .c = {
2642 .dbg_name = "pmic_arb1_p_clk",
2643 .ops = &clk_ops_branch,
2644 CLK_INIT(pmic_arb1_p_clk.c),
2645 },
2646};
2647
2648static struct branch_clk pmic_ssbi2_clk = {
2649 .b = {
2650 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2651 .en_mask = BIT(7),
2652 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2653 .halt_check = HALT_VOTED,
2654 .halt_bit = 23,
2655 },
2656 .c = {
2657 .dbg_name = "pmic_ssbi2_clk",
2658 .ops = &clk_ops_branch,
2659 CLK_INIT(pmic_ssbi2_clk.c),
2660 },
2661};
2662
2663static struct branch_clk rpm_msg_ram_p_clk = {
2664 .b = {
2665 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2666 .en_mask = BIT(6),
2667 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2668 .halt_check = HALT_VOTED,
2669 .halt_bit = 12,
2670 },
2671 .c = {
2672 .dbg_name = "rpm_msg_ram_p_clk",
2673 .ops = &clk_ops_branch,
2674 CLK_INIT(rpm_msg_ram_p_clk.c),
2675 },
2676};
2677
2678/*
2679 * Multimedia Clocks
2680 */
2681
2682static struct branch_clk amp_clk = {
2683 .b = {
2684 .reset_reg = SW_RESET_CORE_REG,
2685 .reset_mask = BIT(20),
2686 },
2687 .c = {
2688 .dbg_name = "amp_clk",
2689 .ops = &clk_ops_reset,
2690 CLK_INIT(amp_clk.c),
2691 },
2692};
2693
Stephen Boyd94625ef2011-07-12 17:06:01 -07002694#define CLK_CAM(name, n, hb) \
2695 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002696 .b = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002697 .ctl_reg = CAMCLK##n##_CC_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002698 .en_mask = BIT(0), \
2699 .halt_reg = DBG_BUS_VEC_I_REG, \
2700 .halt_bit = hb, \
2701 }, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002702 .ns_reg = CAMCLK##n##_NS_REG, \
2703 .md_reg = CAMCLK##n##_MD_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002704 .root_en_mask = BIT(2), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002705 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002706 .ctl_mask = BM(7, 6), \
2707 .set_rate = set_rate_mnd_8, \
2708 .freq_tbl = clk_tbl_cam, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002709 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002710 .c = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002711 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002712 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002713 VDD_DIG_FMAX_MAP2(LOW, 64000000, NOMINAL, 128000000), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002714 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002715 }, \
2716 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002717#define F_CAM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002718 { \
2719 .freq_hz = f, \
2720 .src_clk = &s##_clk.c, \
2721 .md_val = MD8(8, m, 0, n), \
2722 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2723 .ctl_val = CC(6, n), \
2724 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002725 }
2726static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002727 F_CAM( 0, gnd, 1, 0, 0),
2728 F_CAM( 6000000, pll8, 4, 1, 16),
2729 F_CAM( 8000000, pll8, 4, 1, 12),
2730 F_CAM( 12000000, pll8, 4, 1, 8),
2731 F_CAM( 16000000, pll8, 4, 1, 6),
2732 F_CAM( 19200000, pll8, 4, 1, 5),
2733 F_CAM( 24000000, pll8, 4, 1, 4),
2734 F_CAM( 32000000, pll8, 4, 1, 3),
2735 F_CAM( 48000000, pll8, 4, 1, 2),
2736 F_CAM( 64000000, pll8, 3, 1, 2),
2737 F_CAM( 96000000, pll8, 4, 0, 0),
2738 F_CAM(128000000, pll8, 3, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002739 F_END
2740};
2741
Stephen Boyd94625ef2011-07-12 17:06:01 -07002742static CLK_CAM(cam0_clk, 0, 15);
2743static CLK_CAM(cam1_clk, 1, 16);
2744static CLK_CAM(cam2_clk, 2, 31);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002745
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002746#define F_CSI(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002747 { \
2748 .freq_hz = f, \
2749 .src_clk = &s##_clk.c, \
2750 .md_val = MD8(8, m, 0, n), \
2751 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2752 .ctl_val = CC(6, n), \
2753 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002754 }
2755static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002756 F_CSI( 0, gnd, 1, 0, 0),
Stephen Boyd092fd182011-10-21 15:56:30 -07002757 F_CSI( 27000000, pxo, 1, 0, 0),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002758 F_CSI( 85330000, pll8, 1, 2, 9),
2759 F_CSI(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002760 F_END
2761};
2762
2763static struct rcg_clk csi0_src_clk = {
2764 .ns_reg = CSI0_NS_REG,
2765 .b = {
2766 .ctl_reg = CSI0_CC_REG,
2767 .halt_check = NOCHECK,
2768 },
2769 .md_reg = CSI0_MD_REG,
2770 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002771 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002772 .ctl_mask = BM(7, 6),
2773 .set_rate = set_rate_mnd,
2774 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002775 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002776 .c = {
2777 .dbg_name = "csi0_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002778 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002779 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002780 CLK_INIT(csi0_src_clk.c),
2781 },
2782};
2783
2784static struct branch_clk csi0_clk = {
2785 .b = {
2786 .ctl_reg = CSI0_CC_REG,
2787 .en_mask = BIT(0),
2788 .reset_reg = SW_RESET_CORE_REG,
2789 .reset_mask = BIT(8),
2790 .halt_reg = DBG_BUS_VEC_B_REG,
2791 .halt_bit = 13,
2792 },
2793 .parent = &csi0_src_clk.c,
2794 .c = {
2795 .dbg_name = "csi0_clk",
2796 .ops = &clk_ops_branch,
2797 CLK_INIT(csi0_clk.c),
2798 },
2799};
2800
2801static struct branch_clk csi0_phy_clk = {
2802 .b = {
2803 .ctl_reg = CSI0_CC_REG,
2804 .en_mask = BIT(8),
2805 .reset_reg = SW_RESET_CORE_REG,
2806 .reset_mask = BIT(29),
2807 .halt_reg = DBG_BUS_VEC_I_REG,
2808 .halt_bit = 9,
2809 },
2810 .parent = &csi0_src_clk.c,
2811 .c = {
2812 .dbg_name = "csi0_phy_clk",
2813 .ops = &clk_ops_branch,
2814 CLK_INIT(csi0_phy_clk.c),
2815 },
2816};
2817
2818static struct rcg_clk csi1_src_clk = {
2819 .ns_reg = CSI1_NS_REG,
2820 .b = {
2821 .ctl_reg = CSI1_CC_REG,
2822 .halt_check = NOCHECK,
2823 },
2824 .md_reg = CSI1_MD_REG,
2825 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002826 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002827 .ctl_mask = BM(7, 6),
2828 .set_rate = set_rate_mnd,
2829 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002830 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002831 .c = {
2832 .dbg_name = "csi1_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002833 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002834 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002835 CLK_INIT(csi1_src_clk.c),
2836 },
2837};
2838
2839static struct branch_clk csi1_clk = {
2840 .b = {
2841 .ctl_reg = CSI1_CC_REG,
2842 .en_mask = BIT(0),
2843 .reset_reg = SW_RESET_CORE_REG,
2844 .reset_mask = BIT(18),
2845 .halt_reg = DBG_BUS_VEC_B_REG,
2846 .halt_bit = 14,
2847 },
2848 .parent = &csi1_src_clk.c,
2849 .c = {
2850 .dbg_name = "csi1_clk",
2851 .ops = &clk_ops_branch,
2852 CLK_INIT(csi1_clk.c),
2853 },
2854};
2855
2856static struct branch_clk csi1_phy_clk = {
2857 .b = {
2858 .ctl_reg = CSI1_CC_REG,
2859 .en_mask = BIT(8),
2860 .reset_reg = SW_RESET_CORE_REG,
2861 .reset_mask = BIT(28),
2862 .halt_reg = DBG_BUS_VEC_I_REG,
2863 .halt_bit = 10,
2864 },
2865 .parent = &csi1_src_clk.c,
2866 .c = {
2867 .dbg_name = "csi1_phy_clk",
2868 .ops = &clk_ops_branch,
2869 CLK_INIT(csi1_phy_clk.c),
2870 },
2871};
2872
Stephen Boyd94625ef2011-07-12 17:06:01 -07002873static struct rcg_clk csi2_src_clk = {
2874 .ns_reg = CSI2_NS_REG,
2875 .b = {
2876 .ctl_reg = CSI2_CC_REG,
2877 .halt_check = NOCHECK,
2878 },
2879 .md_reg = CSI2_MD_REG,
2880 .root_en_mask = BIT(2),
2881 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
2882 .ctl_mask = BM(7, 6),
2883 .set_rate = set_rate_mnd,
2884 .freq_tbl = clk_tbl_csi,
2885 .current_freq = &rcg_dummy_freq,
2886 .c = {
2887 .dbg_name = "csi2_src_clk",
2888 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002889 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002890 CLK_INIT(csi2_src_clk.c),
2891 },
2892};
2893
2894static struct branch_clk csi2_clk = {
2895 .b = {
2896 .ctl_reg = CSI2_CC_REG,
2897 .en_mask = BIT(0),
2898 .reset_reg = SW_RESET_CORE2_REG,
2899 .reset_mask = BIT(2),
2900 .halt_reg = DBG_BUS_VEC_B_REG,
2901 .halt_bit = 29,
2902 },
2903 .parent = &csi2_src_clk.c,
2904 .c = {
2905 .dbg_name = "csi2_clk",
2906 .ops = &clk_ops_branch,
2907 CLK_INIT(csi2_clk.c),
2908 },
2909};
2910
2911static struct branch_clk csi2_phy_clk = {
2912 .b = {
2913 .ctl_reg = CSI2_CC_REG,
2914 .en_mask = BIT(8),
2915 .reset_reg = SW_RESET_CORE_REG,
2916 .reset_mask = BIT(31),
2917 .halt_reg = DBG_BUS_VEC_I_REG,
2918 .halt_bit = 29,
2919 },
2920 .parent = &csi2_src_clk.c,
2921 .c = {
2922 .dbg_name = "csi2_phy_clk",
2923 .ops = &clk_ops_branch,
2924 CLK_INIT(csi2_phy_clk.c),
2925 },
2926};
2927
Stephen Boyd092fd182011-10-21 15:56:30 -07002928static struct clk *pix_rdi_mux_map[] = {
2929 [0] = &csi0_clk.c,
2930 [1] = &csi1_clk.c,
2931 [2] = &csi2_clk.c,
2932 NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002933};
2934
Stephen Boyd092fd182011-10-21 15:56:30 -07002935struct pix_rdi_clk {
2936 bool enabled;
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002937 unsigned long cur_rate;
Stephen Boyd092fd182011-10-21 15:56:30 -07002938
2939 void __iomem *const s_reg;
2940 u32 s_mask;
2941
2942 void __iomem *const s2_reg;
2943 u32 s2_mask;
2944
2945 struct branch b;
2946 struct clk c;
2947};
2948
2949static inline struct pix_rdi_clk *to_pix_rdi_clk(struct clk *clk)
2950{
2951 return container_of(clk, struct pix_rdi_clk, c);
2952}
2953
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002954static int pix_rdi_clk_set_rate(struct clk *c, unsigned long rate)
Stephen Boyd092fd182011-10-21 15:56:30 -07002955{
2956 int ret, i;
2957 u32 reg;
2958 unsigned long flags;
2959 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2960 struct clk **mux_map = pix_rdi_mux_map;
2961
2962 /*
2963 * These clocks select three inputs via two muxes. One mux selects
2964 * between csi0 and csi1 and the second mux selects between that mux's
2965 * output and csi2. The source and destination selections for each
2966 * mux must be clocking for the switch to succeed so just turn on
2967 * all three sources because it's easier than figuring out what source
2968 * needs to be on at what time.
2969 */
2970 for (i = 0; mux_map[i]; i++) {
2971 ret = clk_enable(mux_map[i]);
2972 if (ret)
2973 goto err;
2974 }
2975 if (rate >= i) {
2976 ret = -EINVAL;
2977 goto err;
2978 }
2979 /* Keep the new source on when switching inputs of an enabled clock */
2980 if (clk->enabled) {
2981 clk_disable(mux_map[clk->cur_rate]);
2982 clk_enable(mux_map[rate]);
2983 }
2984 spin_lock_irqsave(&local_clock_reg_lock, flags);
2985 reg = readl_relaxed(clk->s2_reg);
2986 reg &= ~clk->s2_mask;
2987 reg |= rate == 2 ? clk->s2_mask : 0;
2988 writel_relaxed(reg, clk->s2_reg);
2989 /*
2990 * Wait at least 6 cycles of slowest clock
2991 * for the glitch-free MUX to fully switch sources.
2992 */
2993 mb();
2994 udelay(1);
2995 reg = readl_relaxed(clk->s_reg);
2996 reg &= ~clk->s_mask;
2997 reg |= rate == 1 ? clk->s_mask : 0;
2998 writel_relaxed(reg, clk->s_reg);
2999 /*
3000 * Wait at least 6 cycles of slowest clock
3001 * for the glitch-free MUX to fully switch sources.
3002 */
3003 mb();
3004 udelay(1);
3005 clk->cur_rate = rate;
3006 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3007err:
3008 for (i--; i >= 0; i--)
3009 clk_disable(mux_map[i]);
3010
3011 return 0;
3012}
3013
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003014static unsigned long pix_rdi_clk_get_rate(struct clk *c)
Stephen Boyd092fd182011-10-21 15:56:30 -07003015{
3016 return to_pix_rdi_clk(c)->cur_rate;
3017}
3018
3019static int pix_rdi_clk_enable(struct clk *c)
3020{
3021 unsigned long flags;
3022 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3023
3024 spin_lock_irqsave(&local_clock_reg_lock, flags);
3025 __branch_clk_enable_reg(&clk->b, clk->c.dbg_name);
3026 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3027 clk->enabled = true;
3028
3029 return 0;
3030}
3031
3032static void pix_rdi_clk_disable(struct clk *c)
3033{
3034 unsigned long flags;
3035 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3036
3037 spin_lock_irqsave(&local_clock_reg_lock, flags);
3038 __branch_clk_disable_reg(&clk->b, clk->c.dbg_name);
3039 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3040 clk->enabled = false;
3041}
3042
3043static int pix_rdi_clk_reset(struct clk *clk, enum clk_reset_action action)
3044{
3045 return branch_reset(&to_pix_rdi_clk(clk)->b, action);
3046}
3047
3048static struct clk *pix_rdi_clk_get_parent(struct clk *c)
3049{
3050 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3051
3052 return pix_rdi_mux_map[clk->cur_rate];
3053}
3054
3055static int pix_rdi_clk_list_rate(struct clk *c, unsigned n)
3056{
3057 if (pix_rdi_mux_map[n])
3058 return n;
3059 return -ENXIO;
3060}
3061
3062static int pix_rdi_clk_handoff(struct clk *c)
3063{
3064 u32 reg;
3065 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3066
3067 reg = readl_relaxed(clk->s_reg);
3068 clk->cur_rate = reg & clk->s_mask ? 1 : 0;
3069 reg = readl_relaxed(clk->s2_reg);
3070 clk->cur_rate = reg & clk->s2_mask ? 2 : clk->cur_rate;
3071 return 0;
3072}
3073
3074static struct clk_ops clk_ops_pix_rdi_8960 = {
3075 .enable = pix_rdi_clk_enable,
3076 .disable = pix_rdi_clk_disable,
3077 .auto_off = pix_rdi_clk_disable,
3078 .handoff = pix_rdi_clk_handoff,
3079 .set_rate = pix_rdi_clk_set_rate,
3080 .get_rate = pix_rdi_clk_get_rate,
3081 .list_rate = pix_rdi_clk_list_rate,
3082 .reset = pix_rdi_clk_reset,
3083 .is_local = local_clk_is_local,
3084 .get_parent = pix_rdi_clk_get_parent,
3085};
3086
3087static struct pix_rdi_clk csi_pix_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003088 .b = {
3089 .ctl_reg = MISC_CC_REG,
3090 .en_mask = BIT(26),
3091 .halt_check = DELAY,
3092 .reset_reg = SW_RESET_CORE_REG,
3093 .reset_mask = BIT(26),
3094 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003095 .s_reg = MISC_CC_REG,
3096 .s_mask = BIT(25),
3097 .s2_reg = MISC_CC3_REG,
3098 .s2_mask = BIT(13),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003099 .c = {
3100 .dbg_name = "csi_pix_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003101 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003102 CLK_INIT(csi_pix_clk.c),
3103 },
3104};
3105
Stephen Boyd092fd182011-10-21 15:56:30 -07003106static struct pix_rdi_clk csi_pix1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003107 .b = {
3108 .ctl_reg = MISC_CC3_REG,
3109 .en_mask = BIT(10),
3110 .halt_check = DELAY,
3111 .reset_reg = SW_RESET_CORE_REG,
3112 .reset_mask = BIT(30),
3113 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003114 .s_reg = MISC_CC3_REG,
3115 .s_mask = BIT(8),
3116 .s2_reg = MISC_CC3_REG,
3117 .s2_mask = BIT(9),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003118 .c = {
3119 .dbg_name = "csi_pix1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003120 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003121 CLK_INIT(csi_pix1_clk.c),
3122 },
3123};
3124
Stephen Boyd092fd182011-10-21 15:56:30 -07003125static struct pix_rdi_clk csi_rdi_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003126 .b = {
3127 .ctl_reg = MISC_CC_REG,
3128 .en_mask = BIT(13),
3129 .halt_check = DELAY,
3130 .reset_reg = SW_RESET_CORE_REG,
3131 .reset_mask = BIT(27),
3132 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003133 .s_reg = MISC_CC_REG,
3134 .s_mask = BIT(12),
3135 .s2_reg = MISC_CC3_REG,
3136 .s2_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003137 .c = {
3138 .dbg_name = "csi_rdi_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003139 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003140 CLK_INIT(csi_rdi_clk.c),
3141 },
3142};
3143
Stephen Boyd092fd182011-10-21 15:56:30 -07003144static struct pix_rdi_clk csi_rdi1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003145 .b = {
3146 .ctl_reg = MISC_CC3_REG,
3147 .en_mask = BIT(2),
3148 .halt_check = DELAY,
3149 .reset_reg = SW_RESET_CORE2_REG,
3150 .reset_mask = BIT(1),
3151 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003152 .s_reg = MISC_CC3_REG,
3153 .s_mask = BIT(0),
3154 .s2_reg = MISC_CC3_REG,
3155 .s2_mask = BIT(1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003156 .c = {
3157 .dbg_name = "csi_rdi1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003158 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003159 CLK_INIT(csi_rdi1_clk.c),
3160 },
3161};
3162
Stephen Boyd092fd182011-10-21 15:56:30 -07003163static struct pix_rdi_clk csi_rdi2_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003164 .b = {
3165 .ctl_reg = MISC_CC3_REG,
3166 .en_mask = BIT(6),
3167 .halt_check = DELAY,
3168 .reset_reg = SW_RESET_CORE2_REG,
3169 .reset_mask = BIT(0),
3170 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003171 .s_reg = MISC_CC3_REG,
3172 .s_mask = BIT(4),
3173 .s2_reg = MISC_CC3_REG,
3174 .s2_mask = BIT(5),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003175 .c = {
3176 .dbg_name = "csi_rdi2_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003177 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003178 CLK_INIT(csi_rdi2_clk.c),
3179 },
3180};
3181
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003182#define F_CSI_PHYTIMER(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003183 { \
3184 .freq_hz = f, \
3185 .src_clk = &s##_clk.c, \
3186 .md_val = MD8(8, m, 0, n), \
3187 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3188 .ctl_val = CC(6, n), \
3189 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003190 }
3191static struct clk_freq_tbl clk_tbl_csi_phytimer[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003192 F_CSI_PHYTIMER( 0, gnd, 1, 0, 0),
3193 F_CSI_PHYTIMER( 85330000, pll8, 1, 2, 9),
3194 F_CSI_PHYTIMER(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003195 F_END
3196};
3197
3198static struct rcg_clk csiphy_timer_src_clk = {
3199 .ns_reg = CSIPHYTIMER_NS_REG,
3200 .b = {
3201 .ctl_reg = CSIPHYTIMER_CC_REG,
3202 .halt_check = NOCHECK,
3203 },
3204 .md_reg = CSIPHYTIMER_MD_REG,
3205 .root_en_mask = BIT(2),
3206 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
3207 .ctl_mask = BM(7, 6),
3208 .set_rate = set_rate_mnd_8,
3209 .freq_tbl = clk_tbl_csi_phytimer,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003210 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003211 .c = {
3212 .dbg_name = "csiphy_timer_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003213 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003214 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003215 CLK_INIT(csiphy_timer_src_clk.c),
3216 },
3217};
3218
3219static struct branch_clk csi0phy_timer_clk = {
3220 .b = {
3221 .ctl_reg = CSIPHYTIMER_CC_REG,
3222 .en_mask = BIT(0),
3223 .halt_reg = DBG_BUS_VEC_I_REG,
3224 .halt_bit = 17,
3225 },
3226 .parent = &csiphy_timer_src_clk.c,
3227 .c = {
3228 .dbg_name = "csi0phy_timer_clk",
3229 .ops = &clk_ops_branch,
3230 CLK_INIT(csi0phy_timer_clk.c),
3231 },
3232};
3233
3234static struct branch_clk csi1phy_timer_clk = {
3235 .b = {
3236 .ctl_reg = CSIPHYTIMER_CC_REG,
3237 .en_mask = BIT(9),
3238 .halt_reg = DBG_BUS_VEC_I_REG,
3239 .halt_bit = 18,
3240 },
3241 .parent = &csiphy_timer_src_clk.c,
3242 .c = {
3243 .dbg_name = "csi1phy_timer_clk",
3244 .ops = &clk_ops_branch,
3245 CLK_INIT(csi1phy_timer_clk.c),
3246 },
3247};
3248
Stephen Boyd94625ef2011-07-12 17:06:01 -07003249static struct branch_clk csi2phy_timer_clk = {
3250 .b = {
3251 .ctl_reg = CSIPHYTIMER_CC_REG,
3252 .en_mask = BIT(11),
3253 .halt_reg = DBG_BUS_VEC_I_REG,
3254 .halt_bit = 30,
3255 },
3256 .parent = &csiphy_timer_src_clk.c,
3257 .c = {
3258 .dbg_name = "csi2phy_timer_clk",
3259 .ops = &clk_ops_branch,
3260 CLK_INIT(csi2phy_timer_clk.c),
3261 },
3262};
3263
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003264#define F_DSI(d) \
3265 { \
3266 .freq_hz = d, \
3267 .ns_val = BVAL(15, 12, (d-1)), \
3268 }
3269/*
3270 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
3271 * without this clock driver knowing. So, overload the clk_set_rate() to set
3272 * the divider (1 to 16) of the clock with respect to the PLL rate.
3273 */
3274static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
3275 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
3276 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
3277 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
3278 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
3279 F_END
3280};
3281
3282static struct rcg_clk dsi1_byte_clk = {
3283 .b = {
3284 .ctl_reg = DSI1_BYTE_CC_REG,
3285 .en_mask = BIT(0),
3286 .reset_reg = SW_RESET_CORE_REG,
3287 .reset_mask = BIT(7),
3288 .halt_reg = DBG_BUS_VEC_B_REG,
3289 .halt_bit = 21,
3290 },
3291 .ns_reg = DSI1_BYTE_NS_REG,
3292 .root_en_mask = BIT(2),
3293 .ns_mask = BM(15, 12),
3294 .set_rate = set_rate_nop,
3295 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003296 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003297 .c = {
3298 .dbg_name = "dsi1_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003299 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003300 CLK_INIT(dsi1_byte_clk.c),
3301 },
3302};
3303
3304static struct rcg_clk dsi2_byte_clk = {
3305 .b = {
3306 .ctl_reg = DSI2_BYTE_CC_REG,
3307 .en_mask = BIT(0),
3308 .reset_reg = SW_RESET_CORE_REG,
3309 .reset_mask = BIT(25),
3310 .halt_reg = DBG_BUS_VEC_B_REG,
3311 .halt_bit = 20,
3312 },
3313 .ns_reg = DSI2_BYTE_NS_REG,
3314 .root_en_mask = BIT(2),
3315 .ns_mask = BM(15, 12),
3316 .set_rate = set_rate_nop,
3317 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003318 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003319 .c = {
3320 .dbg_name = "dsi2_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003321 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003322 CLK_INIT(dsi2_byte_clk.c),
3323 },
3324};
3325
3326static struct rcg_clk dsi1_esc_clk = {
3327 .b = {
3328 .ctl_reg = DSI1_ESC_CC_REG,
3329 .en_mask = BIT(0),
3330 .reset_reg = SW_RESET_CORE_REG,
3331 .halt_reg = DBG_BUS_VEC_I_REG,
3332 .halt_bit = 1,
3333 },
3334 .ns_reg = DSI1_ESC_NS_REG,
3335 .root_en_mask = BIT(2),
3336 .ns_mask = BM(15, 12),
3337 .set_rate = set_rate_nop,
3338 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003339 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003340 .c = {
3341 .dbg_name = "dsi1_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003342 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003343 CLK_INIT(dsi1_esc_clk.c),
3344 },
3345};
3346
3347static struct rcg_clk dsi2_esc_clk = {
3348 .b = {
3349 .ctl_reg = DSI2_ESC_CC_REG,
3350 .en_mask = BIT(0),
3351 .halt_reg = DBG_BUS_VEC_I_REG,
3352 .halt_bit = 3,
3353 },
3354 .ns_reg = DSI2_ESC_NS_REG,
3355 .root_en_mask = BIT(2),
3356 .ns_mask = BM(15, 12),
3357 .set_rate = set_rate_nop,
3358 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003359 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003360 .c = {
3361 .dbg_name = "dsi2_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003362 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003363 CLK_INIT(dsi2_esc_clk.c),
3364 },
3365};
3366
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003367#define F_GFX2D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003368 { \
3369 .freq_hz = f, \
3370 .src_clk = &s##_clk.c, \
3371 .md_val = MD4(4, m, 0, n), \
3372 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
3373 .ctl_val = CC_BANKED(9, 6, n), \
3374 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003375 }
3376static struct clk_freq_tbl clk_tbl_gfx2d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003377 F_GFX2D( 0, gnd, 0, 0),
3378 F_GFX2D( 27000000, pxo, 0, 0),
3379 F_GFX2D( 48000000, pll8, 1, 8),
3380 F_GFX2D( 54857000, pll8, 1, 7),
3381 F_GFX2D( 64000000, pll8, 1, 6),
3382 F_GFX2D( 76800000, pll8, 1, 5),
3383 F_GFX2D( 96000000, pll8, 1, 4),
3384 F_GFX2D(128000000, pll8, 1, 3),
3385 F_GFX2D(145455000, pll2, 2, 11),
3386 F_GFX2D(160000000, pll2, 1, 5),
3387 F_GFX2D(177778000, pll2, 2, 9),
3388 F_GFX2D(200000000, pll2, 1, 4),
3389 F_GFX2D(228571000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003390 F_END
3391};
3392
3393static struct bank_masks bmnd_info_gfx2d0 = {
3394 .bank_sel_mask = BIT(11),
3395 .bank0_mask = {
3396 .md_reg = GFX2D0_MD0_REG,
3397 .ns_mask = BM(23, 20) | BM(5, 3),
3398 .rst_mask = BIT(25),
3399 .mnd_en_mask = BIT(8),
3400 .mode_mask = BM(10, 9),
3401 },
3402 .bank1_mask = {
3403 .md_reg = GFX2D0_MD1_REG,
3404 .ns_mask = BM(19, 16) | BM(2, 0),
3405 .rst_mask = BIT(24),
3406 .mnd_en_mask = BIT(5),
3407 .mode_mask = BM(7, 6),
3408 },
3409};
3410
3411static struct rcg_clk gfx2d0_clk = {
3412 .b = {
3413 .ctl_reg = GFX2D0_CC_REG,
3414 .en_mask = BIT(0),
3415 .reset_reg = SW_RESET_CORE_REG,
3416 .reset_mask = BIT(14),
3417 .halt_reg = DBG_BUS_VEC_A_REG,
3418 .halt_bit = 9,
3419 },
3420 .ns_reg = GFX2D0_NS_REG,
3421 .root_en_mask = BIT(2),
3422 .set_rate = set_rate_mnd_banked,
3423 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003424 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003425 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003426 .c = {
3427 .dbg_name = "gfx2d0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003428 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003429 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3430 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003431 CLK_INIT(gfx2d0_clk.c),
3432 },
3433};
3434
3435static struct bank_masks bmnd_info_gfx2d1 = {
3436 .bank_sel_mask = BIT(11),
3437 .bank0_mask = {
3438 .md_reg = GFX2D1_MD0_REG,
3439 .ns_mask = BM(23, 20) | BM(5, 3),
3440 .rst_mask = BIT(25),
3441 .mnd_en_mask = BIT(8),
3442 .mode_mask = BM(10, 9),
3443 },
3444 .bank1_mask = {
3445 .md_reg = GFX2D1_MD1_REG,
3446 .ns_mask = BM(19, 16) | BM(2, 0),
3447 .rst_mask = BIT(24),
3448 .mnd_en_mask = BIT(5),
3449 .mode_mask = BM(7, 6),
3450 },
3451};
3452
3453static struct rcg_clk gfx2d1_clk = {
3454 .b = {
3455 .ctl_reg = GFX2D1_CC_REG,
3456 .en_mask = BIT(0),
3457 .reset_reg = SW_RESET_CORE_REG,
3458 .reset_mask = BIT(13),
3459 .halt_reg = DBG_BUS_VEC_A_REG,
3460 .halt_bit = 14,
3461 },
3462 .ns_reg = GFX2D1_NS_REG,
3463 .root_en_mask = BIT(2),
3464 .set_rate = set_rate_mnd_banked,
3465 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003466 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003467 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003468 .c = {
3469 .dbg_name = "gfx2d1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003470 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003471 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3472 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003473 CLK_INIT(gfx2d1_clk.c),
3474 },
3475};
3476
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003477#define F_GFX3D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003478 { \
3479 .freq_hz = f, \
3480 .src_clk = &s##_clk.c, \
3481 .md_val = MD4(4, m, 0, n), \
3482 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3483 .ctl_val = CC_BANKED(9, 6, n), \
3484 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003485 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003486
3487static struct clk_freq_tbl clk_tbl_gfx3d_8960[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003488 F_GFX3D( 0, gnd, 0, 0),
3489 F_GFX3D( 27000000, pxo, 0, 0),
3490 F_GFX3D( 48000000, pll8, 1, 8),
3491 F_GFX3D( 54857000, pll8, 1, 7),
3492 F_GFX3D( 64000000, pll8, 1, 6),
3493 F_GFX3D( 76800000, pll8, 1, 5),
3494 F_GFX3D( 96000000, pll8, 1, 4),
3495 F_GFX3D(128000000, pll8, 1, 3),
3496 F_GFX3D(145455000, pll2, 2, 11),
3497 F_GFX3D(160000000, pll2, 1, 5),
3498 F_GFX3D(177778000, pll2, 2, 9),
3499 F_GFX3D(200000000, pll2, 1, 4),
3500 F_GFX3D(228571000, pll2, 2, 7),
3501 F_GFX3D(266667000, pll2, 1, 3),
3502 F_GFX3D(320000000, pll2, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003503 F_END
3504};
3505
Tianyi Gou41515e22011-09-01 19:37:43 -07003506static struct clk_freq_tbl clk_tbl_gfx3d_8960_v2[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003507 F_GFX3D( 0, gnd, 0, 0),
3508 F_GFX3D( 27000000, pxo, 0, 0),
3509 F_GFX3D( 48000000, pll8, 1, 8),
3510 F_GFX3D( 54857000, pll8, 1, 7),
3511 F_GFX3D( 64000000, pll8, 1, 6),
3512 F_GFX3D( 76800000, pll8, 1, 5),
3513 F_GFX3D( 96000000, pll8, 1, 4),
3514 F_GFX3D(128000000, pll8, 1, 3),
3515 F_GFX3D(145455000, pll2, 2, 11),
3516 F_GFX3D(160000000, pll2, 1, 5),
3517 F_GFX3D(177778000, pll2, 2, 9),
3518 F_GFX3D(200000000, pll2, 1, 4),
3519 F_GFX3D(228571000, pll2, 2, 7),
3520 F_GFX3D(266667000, pll2, 1, 3),
3521 F_GFX3D(300000000, pll3, 1, 4),
3522 F_GFX3D(320000000, pll2, 2, 5),
3523 F_GFX3D(400000000, pll2, 1, 2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003524 F_END
3525};
3526
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003527static unsigned long fmax_gfx3d_8960_v2[MAX_VDD_LEVELS] __initdata = {
3528 [VDD_DIG_LOW] = 128000000,
3529 [VDD_DIG_NOMINAL] = 300000000,
3530 [VDD_DIG_HIGH] = 400000000
3531};
3532
Tianyi Gou41515e22011-09-01 19:37:43 -07003533static struct clk_freq_tbl clk_tbl_gfx3d_8064[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003534 F_GFX3D( 0, gnd, 0, 0),
3535 F_GFX3D( 27000000, pxo, 0, 0),
3536 F_GFX3D( 48000000, pll8, 1, 8),
3537 F_GFX3D( 54857000, pll8, 1, 7),
3538 F_GFX3D( 64000000, pll8, 1, 6),
3539 F_GFX3D( 76800000, pll8, 1, 5),
3540 F_GFX3D( 96000000, pll8, 1, 4),
3541 F_GFX3D(128000000, pll8, 1, 3),
3542 F_GFX3D(145455000, pll2, 2, 11),
3543 F_GFX3D(160000000, pll2, 1, 5),
3544 F_GFX3D(177778000, pll2, 2, 9),
3545 F_GFX3D(200000000, pll2, 1, 4),
3546 F_GFX3D(228571000, pll2, 2, 7),
3547 F_GFX3D(266667000, pll2, 1, 3),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07003548 F_GFX3D(325000000, pll15, 1, 3),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003549 F_GFX3D(400000000, pll2, 1, 2),
Tianyi Gou41515e22011-09-01 19:37:43 -07003550 F_END
3551};
3552
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003553static unsigned long fmax_gfx3d_8064[MAX_VDD_LEVELS] __initdata = {
3554 [VDD_DIG_LOW] = 128000000,
3555 [VDD_DIG_NOMINAL] = 325000000,
3556 [VDD_DIG_HIGH] = 400000000
3557};
3558
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003559static struct bank_masks bmnd_info_gfx3d = {
3560 .bank_sel_mask = BIT(11),
3561 .bank0_mask = {
3562 .md_reg = GFX3D_MD0_REG,
3563 .ns_mask = BM(21, 18) | BM(5, 3),
3564 .rst_mask = BIT(23),
3565 .mnd_en_mask = BIT(8),
3566 .mode_mask = BM(10, 9),
3567 },
3568 .bank1_mask = {
3569 .md_reg = GFX3D_MD1_REG,
3570 .ns_mask = BM(17, 14) | BM(2, 0),
3571 .rst_mask = BIT(22),
3572 .mnd_en_mask = BIT(5),
3573 .mode_mask = BM(7, 6),
3574 },
3575};
3576
3577static struct rcg_clk gfx3d_clk = {
3578 .b = {
3579 .ctl_reg = GFX3D_CC_REG,
3580 .en_mask = BIT(0),
3581 .reset_reg = SW_RESET_CORE_REG,
3582 .reset_mask = BIT(12),
3583 .halt_reg = DBG_BUS_VEC_A_REG,
3584 .halt_bit = 4,
3585 },
3586 .ns_reg = GFX3D_NS_REG,
3587 .root_en_mask = BIT(2),
3588 .set_rate = set_rate_mnd_banked,
Tianyi Gou41515e22011-09-01 19:37:43 -07003589 .freq_tbl = clk_tbl_gfx3d_8960,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003590 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003591 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003592 .c = {
3593 .dbg_name = "gfx3d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003594 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003595 VDD_DIG_FMAX_MAP3(LOW, 128000000, NOMINAL, 266667000,
3596 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003597 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003598 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003599 },
3600};
3601
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003602#define F_VCAP(f, s, m, n) \
Tianyi Gou621f8742011-09-01 21:45:01 -07003603 { \
3604 .freq_hz = f, \
3605 .src_clk = &s##_clk.c, \
3606 .md_val = MD4(4, m, 0, n), \
3607 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3608 .ctl_val = CC_BANKED(9, 6, n), \
3609 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Tianyi Gou621f8742011-09-01 21:45:01 -07003610 }
3611
3612static struct clk_freq_tbl clk_tbl_vcap[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003613 F_VCAP( 0, gnd, 0, 0),
3614 F_VCAP( 27000000, pxo, 0, 0),
3615 F_VCAP( 54860000, pll8, 1, 7),
3616 F_VCAP( 64000000, pll8, 1, 6),
3617 F_VCAP( 76800000, pll8, 1, 5),
3618 F_VCAP(128000000, pll8, 1, 3),
3619 F_VCAP(160000000, pll2, 1, 5),
3620 F_VCAP(200000000, pll2, 1, 4),
Tianyi Gou621f8742011-09-01 21:45:01 -07003621 F_END
3622};
3623
3624static struct bank_masks bmnd_info_vcap = {
3625 .bank_sel_mask = BIT(11),
3626 .bank0_mask = {
3627 .md_reg = VCAP_MD0_REG,
3628 .ns_mask = BM(21, 18) | BM(5, 3),
3629 .rst_mask = BIT(23),
3630 .mnd_en_mask = BIT(8),
3631 .mode_mask = BM(10, 9),
3632 },
3633 .bank1_mask = {
3634 .md_reg = VCAP_MD1_REG,
3635 .ns_mask = BM(17, 14) | BM(2, 0),
3636 .rst_mask = BIT(22),
3637 .mnd_en_mask = BIT(5),
3638 .mode_mask = BM(7, 6),
3639 },
3640};
3641
3642static struct rcg_clk vcap_clk = {
3643 .b = {
3644 .ctl_reg = VCAP_CC_REG,
3645 .en_mask = BIT(0),
3646 .halt_reg = DBG_BUS_VEC_J_REG,
3647 .halt_bit = 15,
3648 },
3649 .ns_reg = VCAP_NS_REG,
3650 .root_en_mask = BIT(2),
3651 .set_rate = set_rate_mnd_banked,
3652 .freq_tbl = clk_tbl_vcap,
3653 .bank_info = &bmnd_info_vcap,
3654 .current_freq = &rcg_dummy_freq,
3655 .c = {
3656 .dbg_name = "vcap_clk",
3657 .ops = &clk_ops_rcg_8960,
3658 .depends = &vcap_axi_clk.c,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003659 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000),
Tianyi Gou621f8742011-09-01 21:45:01 -07003660 CLK_INIT(vcap_clk.c),
3661 },
3662};
3663
3664static struct branch_clk vcap_npl_clk = {
3665 .b = {
3666 .ctl_reg = VCAP_CC_REG,
3667 .en_mask = BIT(13),
3668 .halt_reg = DBG_BUS_VEC_J_REG,
3669 .halt_bit = 25,
3670 },
3671 .parent = &vcap_clk.c,
3672 .c = {
3673 .dbg_name = "vcap_npl_clk",
3674 .ops = &clk_ops_branch,
3675 CLK_INIT(vcap_npl_clk.c),
3676 },
3677};
3678
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003679#define F_IJPEG(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003680 { \
3681 .freq_hz = f, \
3682 .src_clk = &s##_clk.c, \
3683 .md_val = MD8(8, m, 0, n), \
3684 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
3685 .ctl_val = CC(6, n), \
3686 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003687 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003688
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003689static struct clk_freq_tbl clk_tbl_ijpeg[] = {
3690 F_IJPEG( 0, gnd, 1, 0, 0),
3691 F_IJPEG( 27000000, pxo, 1, 0, 0),
3692 F_IJPEG( 36570000, pll8, 1, 2, 21),
3693 F_IJPEG( 54860000, pll8, 7, 0, 0),
3694 F_IJPEG( 96000000, pll8, 4, 0, 0),
3695 F_IJPEG(109710000, pll8, 1, 2, 7),
3696 F_IJPEG(128000000, pll8, 3, 0, 0),
3697 F_IJPEG(153600000, pll8, 1, 2, 5),
3698 F_IJPEG(200000000, pll2, 4, 0, 0),
3699 F_IJPEG(228571000, pll2, 1, 2, 7),
3700 F_IJPEG(266667000, pll2, 1, 1, 3),
3701 F_IJPEG(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003702 F_END
3703};
3704
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003705static unsigned long fmax_ijpeg_8960_v2[MAX_VDD_LEVELS] __initdata = {
3706 [VDD_DIG_LOW] = 110000000,
3707 [VDD_DIG_NOMINAL] = 266667000,
3708 [VDD_DIG_HIGH] = 320000000
3709};
3710
3711static unsigned long fmax_ijpeg_8064[MAX_VDD_LEVELS] __initdata = {
3712 [VDD_DIG_LOW] = 128000000,
3713 [VDD_DIG_NOMINAL] = 266667000,
3714 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07003715};
3716
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003717static struct rcg_clk ijpeg_clk = {
3718 .b = {
3719 .ctl_reg = IJPEG_CC_REG,
3720 .en_mask = BIT(0),
3721 .reset_reg = SW_RESET_CORE_REG,
3722 .reset_mask = BIT(9),
3723 .halt_reg = DBG_BUS_VEC_A_REG,
3724 .halt_bit = 24,
3725 },
3726 .ns_reg = IJPEG_NS_REG,
3727 .md_reg = IJPEG_MD_REG,
3728 .root_en_mask = BIT(2),
3729 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
3730 .ctl_mask = BM(7, 6),
3731 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003732 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003733 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003734 .c = {
3735 .dbg_name = "ijpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003736 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003737 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003738 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003739 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003740 },
3741};
3742
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003743#define F_JPEGD(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003744 { \
3745 .freq_hz = f, \
3746 .src_clk = &s##_clk.c, \
3747 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003748 }
3749static struct clk_freq_tbl clk_tbl_jpegd[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003750 F_JPEGD( 0, gnd, 1),
3751 F_JPEGD( 64000000, pll8, 6),
3752 F_JPEGD( 76800000, pll8, 5),
3753 F_JPEGD( 96000000, pll8, 4),
3754 F_JPEGD(160000000, pll2, 5),
3755 F_JPEGD(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003756 F_END
3757};
3758
3759static struct rcg_clk jpegd_clk = {
3760 .b = {
3761 .ctl_reg = JPEGD_CC_REG,
3762 .en_mask = BIT(0),
3763 .reset_reg = SW_RESET_CORE_REG,
3764 .reset_mask = BIT(19),
3765 .halt_reg = DBG_BUS_VEC_A_REG,
3766 .halt_bit = 19,
3767 },
3768 .ns_reg = JPEGD_NS_REG,
3769 .root_en_mask = BIT(2),
3770 .ns_mask = (BM(15, 12) | BM(2, 0)),
3771 .set_rate = set_rate_nop,
3772 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003773 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003774 .c = {
3775 .dbg_name = "jpegd_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003776 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003777 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003778 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003779 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003780 },
3781};
3782
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003783#define F_MDP(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003784 { \
3785 .freq_hz = f, \
3786 .src_clk = &s##_clk.c, \
3787 .md_val = MD8(8, m, 0, n), \
3788 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
3789 .ctl_val = CC_BANKED(9, 6, n), \
3790 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003791 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003792static struct clk_freq_tbl clk_tbl_mdp[] = {
3793 F_MDP( 0, gnd, 0, 0),
3794 F_MDP( 9600000, pll8, 1, 40),
3795 F_MDP( 13710000, pll8, 1, 28),
3796 F_MDP( 27000000, pxo, 0, 0),
3797 F_MDP( 29540000, pll8, 1, 13),
3798 F_MDP( 34910000, pll8, 1, 11),
3799 F_MDP( 38400000, pll8, 1, 10),
3800 F_MDP( 59080000, pll8, 2, 13),
3801 F_MDP( 76800000, pll8, 1, 5),
3802 F_MDP( 85330000, pll8, 2, 9),
3803 F_MDP( 96000000, pll8, 1, 4),
3804 F_MDP(128000000, pll8, 1, 3),
3805 F_MDP(160000000, pll2, 1, 5),
3806 F_MDP(177780000, pll2, 2, 9),
3807 F_MDP(200000000, pll2, 1, 4),
3808 F_MDP(266667000, pll2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003809 F_END
3810};
3811
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003812static unsigned long fmax_mdp_8064[MAX_VDD_LEVELS] __initdata = {
3813 [VDD_DIG_LOW] = 128000000,
3814 [VDD_DIG_NOMINAL] = 266667000
Tianyi Gou621f8742011-09-01 21:45:01 -07003815};
3816
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003817static struct bank_masks bmnd_info_mdp = {
3818 .bank_sel_mask = BIT(11),
3819 .bank0_mask = {
3820 .md_reg = MDP_MD0_REG,
3821 .ns_mask = BM(29, 22) | BM(5, 3),
3822 .rst_mask = BIT(31),
3823 .mnd_en_mask = BIT(8),
3824 .mode_mask = BM(10, 9),
3825 },
3826 .bank1_mask = {
3827 .md_reg = MDP_MD1_REG,
3828 .ns_mask = BM(21, 14) | BM(2, 0),
3829 .rst_mask = BIT(30),
3830 .mnd_en_mask = BIT(5),
3831 .mode_mask = BM(7, 6),
3832 },
3833};
3834
3835static struct rcg_clk mdp_clk = {
3836 .b = {
3837 .ctl_reg = MDP_CC_REG,
3838 .en_mask = BIT(0),
3839 .reset_reg = SW_RESET_CORE_REG,
3840 .reset_mask = BIT(21),
3841 .halt_reg = DBG_BUS_VEC_C_REG,
3842 .halt_bit = 10,
3843 },
3844 .ns_reg = MDP_NS_REG,
3845 .root_en_mask = BIT(2),
3846 .set_rate = set_rate_mnd_banked,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003847 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003848 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003849 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003850 .c = {
3851 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003852 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003853 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003854 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003855 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003856 },
3857};
3858
3859static struct branch_clk lut_mdp_clk = {
3860 .b = {
3861 .ctl_reg = MDP_LUT_CC_REG,
3862 .en_mask = BIT(0),
3863 .halt_reg = DBG_BUS_VEC_I_REG,
3864 .halt_bit = 13,
3865 },
3866 .parent = &mdp_clk.c,
3867 .c = {
3868 .dbg_name = "lut_mdp_clk",
3869 .ops = &clk_ops_branch,
3870 CLK_INIT(lut_mdp_clk.c),
3871 },
3872};
3873
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003874#define F_MDP_VSYNC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003875 { \
3876 .freq_hz = f, \
3877 .src_clk = &s##_clk.c, \
3878 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003879 }
3880static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003881 F_MDP_VSYNC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003882 F_END
3883};
3884
3885static struct rcg_clk mdp_vsync_clk = {
3886 .b = {
3887 .ctl_reg = MISC_CC_REG,
3888 .en_mask = BIT(6),
3889 .reset_reg = SW_RESET_CORE_REG,
3890 .reset_mask = BIT(3),
3891 .halt_reg = DBG_BUS_VEC_B_REG,
3892 .halt_bit = 22,
3893 },
3894 .ns_reg = MISC_CC2_REG,
3895 .ns_mask = BIT(13),
3896 .set_rate = set_rate_nop,
3897 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003898 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003899 .c = {
3900 .dbg_name = "mdp_vsync_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003901 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003902 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003903 CLK_INIT(mdp_vsync_clk.c),
3904 },
3905};
3906
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003907#define F_ROT(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003908 { \
3909 .freq_hz = f, \
3910 .src_clk = &s##_clk.c, \
3911 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
3912 21, 19, 18, 16, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003913 }
3914static struct clk_freq_tbl clk_tbl_rot[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003915 F_ROT( 0, gnd, 1),
3916 F_ROT( 27000000, pxo, 1),
3917 F_ROT( 29540000, pll8, 13),
3918 F_ROT( 32000000, pll8, 12),
3919 F_ROT( 38400000, pll8, 10),
3920 F_ROT( 48000000, pll8, 8),
3921 F_ROT( 54860000, pll8, 7),
3922 F_ROT( 64000000, pll8, 6),
3923 F_ROT( 76800000, pll8, 5),
3924 F_ROT( 96000000, pll8, 4),
3925 F_ROT(100000000, pll2, 8),
3926 F_ROT(114290000, pll2, 7),
3927 F_ROT(133330000, pll2, 6),
3928 F_ROT(160000000, pll2, 5),
3929 F_ROT(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003930 F_END
3931};
3932
3933static struct bank_masks bdiv_info_rot = {
3934 .bank_sel_mask = BIT(30),
3935 .bank0_mask = {
3936 .ns_mask = BM(25, 22) | BM(18, 16),
3937 },
3938 .bank1_mask = {
3939 .ns_mask = BM(29, 26) | BM(21, 19),
3940 },
3941};
3942
3943static struct rcg_clk rot_clk = {
3944 .b = {
3945 .ctl_reg = ROT_CC_REG,
3946 .en_mask = BIT(0),
3947 .reset_reg = SW_RESET_CORE_REG,
3948 .reset_mask = BIT(2),
3949 .halt_reg = DBG_BUS_VEC_C_REG,
3950 .halt_bit = 15,
3951 },
3952 .ns_reg = ROT_NS_REG,
3953 .root_en_mask = BIT(2),
3954 .set_rate = set_rate_div_banked,
3955 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003956 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003957 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003958 .c = {
3959 .dbg_name = "rot_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003960 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003961 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003962 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003963 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003964 },
3965};
3966
3967static int hdmi_pll_clk_enable(struct clk *clk)
3968{
3969 int ret;
3970 unsigned long flags;
3971 spin_lock_irqsave(&local_clock_reg_lock, flags);
3972 ret = hdmi_pll_enable();
3973 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3974 return ret;
3975}
3976
3977static void hdmi_pll_clk_disable(struct clk *clk)
3978{
3979 unsigned long flags;
3980 spin_lock_irqsave(&local_clock_reg_lock, flags);
3981 hdmi_pll_disable();
3982 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3983}
3984
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003985static unsigned long hdmi_pll_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003986{
3987 return hdmi_pll_get_rate();
3988}
3989
Stephen Boyd5b35dee2011-09-21 12:17:38 -07003990static struct clk *hdmi_pll_clk_get_parent(struct clk *clk)
3991{
3992 return &pxo_clk.c;
3993}
3994
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003995static struct clk_ops clk_ops_hdmi_pll = {
3996 .enable = hdmi_pll_clk_enable,
3997 .disable = hdmi_pll_clk_disable,
3998 .get_rate = hdmi_pll_clk_get_rate,
3999 .is_local = local_clk_is_local,
Stephen Boyd5b35dee2011-09-21 12:17:38 -07004000 .get_parent = hdmi_pll_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004001};
4002
4003static struct clk hdmi_pll_clk = {
4004 .dbg_name = "hdmi_pll_clk",
4005 .ops = &clk_ops_hdmi_pll,
4006 CLK_INIT(hdmi_pll_clk),
4007};
4008
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004009#define F_TV_GND(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004010 { \
4011 .freq_hz = f, \
4012 .src_clk = &s##_clk.c, \
4013 .md_val = MD8(8, m, 0, n), \
4014 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
4015 .ctl_val = CC(6, n), \
4016 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004017 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004018#define F_TV(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004019 { \
4020 .freq_hz = f, \
4021 .src_clk = &s##_clk, \
4022 .md_val = MD8(8, m, 0, n), \
4023 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
4024 .ctl_val = CC(6, n), \
4025 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004026 .extra_freq_data = (void *)p_r, \
4027 }
4028/* Switching TV freqs requires PLL reconfiguration. */
4029static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004030 F_TV_GND( 0, gnd, 0, 1, 0, 0),
4031 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0),
4032 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0),
4033 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0),
4034 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0),
4035 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004036 F_END
4037};
4038
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004039static unsigned long fmax_tv_src_8064[MAX_VDD_LEVELS] __initdata = {
4040 [VDD_DIG_LOW] = 74250000,
4041 [VDD_DIG_NOMINAL] = 149000000
4042};
4043
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004044/*
4045 * Unlike other clocks, the TV rate is adjusted through PLL
4046 * re-programming. It is also routed through an MND divider.
4047 */
4048void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
4049{
4050 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
4051 if (pll_rate)
4052 hdmi_pll_set_rate(pll_rate);
4053 set_rate_mnd(clk, nf);
4054}
4055
4056static struct rcg_clk tv_src_clk = {
4057 .ns_reg = TV_NS_REG,
4058 .b = {
4059 .ctl_reg = TV_CC_REG,
4060 .halt_check = NOCHECK,
4061 },
4062 .md_reg = TV_MD_REG,
4063 .root_en_mask = BIT(2),
4064 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
4065 .ctl_mask = BM(7, 6),
4066 .set_rate = set_rate_tv,
4067 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004068 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004069 .c = {
4070 .dbg_name = "tv_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004071 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004072 VDD_DIG_FMAX_MAP2(LOW, 27030000, NOMINAL, 149000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004073 CLK_INIT(tv_src_clk.c),
4074 },
4075};
4076
4077static struct branch_clk tv_enc_clk = {
4078 .b = {
4079 .ctl_reg = TV_CC_REG,
4080 .en_mask = BIT(8),
4081 .reset_reg = SW_RESET_CORE_REG,
4082 .reset_mask = BIT(0),
4083 .halt_reg = DBG_BUS_VEC_D_REG,
4084 .halt_bit = 9,
4085 },
4086 .parent = &tv_src_clk.c,
4087 .c = {
4088 .dbg_name = "tv_enc_clk",
4089 .ops = &clk_ops_branch,
4090 CLK_INIT(tv_enc_clk.c),
4091 },
4092};
4093
4094static struct branch_clk tv_dac_clk = {
4095 .b = {
4096 .ctl_reg = TV_CC_REG,
4097 .en_mask = BIT(10),
4098 .halt_reg = DBG_BUS_VEC_D_REG,
4099 .halt_bit = 10,
4100 },
4101 .parent = &tv_src_clk.c,
4102 .c = {
4103 .dbg_name = "tv_dac_clk",
4104 .ops = &clk_ops_branch,
4105 CLK_INIT(tv_dac_clk.c),
4106 },
4107};
4108
4109static struct branch_clk mdp_tv_clk = {
4110 .b = {
4111 .ctl_reg = TV_CC_REG,
4112 .en_mask = BIT(0),
4113 .reset_reg = SW_RESET_CORE_REG,
4114 .reset_mask = BIT(4),
4115 .halt_reg = DBG_BUS_VEC_D_REG,
4116 .halt_bit = 12,
4117 },
4118 .parent = &tv_src_clk.c,
4119 .c = {
4120 .dbg_name = "mdp_tv_clk",
4121 .ops = &clk_ops_branch,
4122 CLK_INIT(mdp_tv_clk.c),
4123 },
4124};
4125
4126static struct branch_clk hdmi_tv_clk = {
4127 .b = {
4128 .ctl_reg = TV_CC_REG,
4129 .en_mask = BIT(12),
4130 .reset_reg = SW_RESET_CORE_REG,
4131 .reset_mask = BIT(1),
4132 .halt_reg = DBG_BUS_VEC_D_REG,
4133 .halt_bit = 11,
4134 },
4135 .parent = &tv_src_clk.c,
4136 .c = {
4137 .dbg_name = "hdmi_tv_clk",
4138 .ops = &clk_ops_branch,
4139 CLK_INIT(hdmi_tv_clk.c),
4140 },
4141};
4142
4143static struct branch_clk hdmi_app_clk = {
4144 .b = {
4145 .ctl_reg = MISC_CC2_REG,
4146 .en_mask = BIT(11),
4147 .reset_reg = SW_RESET_CORE_REG,
4148 .reset_mask = BIT(11),
4149 .halt_reg = DBG_BUS_VEC_B_REG,
4150 .halt_bit = 25,
4151 },
4152 .c = {
4153 .dbg_name = "hdmi_app_clk",
4154 .ops = &clk_ops_branch,
4155 CLK_INIT(hdmi_app_clk.c),
4156 },
4157};
4158
4159static struct bank_masks bmnd_info_vcodec = {
4160 .bank_sel_mask = BIT(13),
4161 .bank0_mask = {
4162 .md_reg = VCODEC_MD0_REG,
4163 .ns_mask = BM(18, 11) | BM(2, 0),
4164 .rst_mask = BIT(31),
4165 .mnd_en_mask = BIT(5),
4166 .mode_mask = BM(7, 6),
4167 },
4168 .bank1_mask = {
4169 .md_reg = VCODEC_MD1_REG,
4170 .ns_mask = BM(26, 19) | BM(29, 27),
4171 .rst_mask = BIT(30),
4172 .mnd_en_mask = BIT(10),
4173 .mode_mask = BM(12, 11),
4174 },
4175};
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004176#define F_VCODEC(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004177 { \
4178 .freq_hz = f, \
4179 .src_clk = &s##_clk.c, \
4180 .md_val = MD8(8, m, 0, n), \
4181 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
4182 .ctl_val = CC_BANKED(6, 11, n), \
4183 .mnd_en_mask = (BIT(10) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004184 }
4185static struct clk_freq_tbl clk_tbl_vcodec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004186 F_VCODEC( 0, gnd, 0, 0),
4187 F_VCODEC( 27000000, pxo, 0, 0),
4188 F_VCODEC( 32000000, pll8, 1, 12),
4189 F_VCODEC( 48000000, pll8, 1, 8),
4190 F_VCODEC( 54860000, pll8, 1, 7),
4191 F_VCODEC( 96000000, pll8, 1, 4),
4192 F_VCODEC(133330000, pll2, 1, 6),
4193 F_VCODEC(200000000, pll2, 1, 4),
4194 F_VCODEC(228570000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004195 F_END
4196};
4197
4198static struct rcg_clk vcodec_clk = {
4199 .b = {
4200 .ctl_reg = VCODEC_CC_REG,
4201 .en_mask = BIT(0),
4202 .reset_reg = SW_RESET_CORE_REG,
4203 .reset_mask = BIT(6),
4204 .halt_reg = DBG_BUS_VEC_C_REG,
4205 .halt_bit = 29,
4206 },
4207 .ns_reg = VCODEC_NS_REG,
4208 .root_en_mask = BIT(2),
4209 .set_rate = set_rate_mnd_banked,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004210 .bank_info = &bmnd_info_vcodec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004211 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004212 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004213 .c = {
4214 .dbg_name = "vcodec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004215 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004216 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
4217 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004218 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004219 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004220 },
4221};
4222
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004223#define F_VPE(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004224 { \
4225 .freq_hz = f, \
4226 .src_clk = &s##_clk.c, \
4227 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004228 }
4229static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004230 F_VPE( 0, gnd, 1),
4231 F_VPE( 27000000, pxo, 1),
4232 F_VPE( 34909000, pll8, 11),
4233 F_VPE( 38400000, pll8, 10),
4234 F_VPE( 64000000, pll8, 6),
4235 F_VPE( 76800000, pll8, 5),
4236 F_VPE( 96000000, pll8, 4),
4237 F_VPE(100000000, pll2, 8),
4238 F_VPE(160000000, pll2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004239 F_END
4240};
4241
4242static struct rcg_clk vpe_clk = {
4243 .b = {
4244 .ctl_reg = VPE_CC_REG,
4245 .en_mask = BIT(0),
4246 .reset_reg = SW_RESET_CORE_REG,
4247 .reset_mask = BIT(17),
4248 .halt_reg = DBG_BUS_VEC_A_REG,
4249 .halt_bit = 28,
4250 },
4251 .ns_reg = VPE_NS_REG,
4252 .root_en_mask = BIT(2),
4253 .ns_mask = (BM(15, 12) | BM(2, 0)),
4254 .set_rate = set_rate_nop,
4255 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004256 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004257 .c = {
4258 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004259 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004260 VDD_DIG_FMAX_MAP2(LOW, 76800000, NOMINAL, 160000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004261 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004262 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004263 },
4264};
4265
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004266#define F_VFE(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004267 { \
4268 .freq_hz = f, \
4269 .src_clk = &s##_clk.c, \
4270 .md_val = MD8(8, m, 0, n), \
4271 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
4272 .ctl_val = CC(6, n), \
4273 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004274 }
Tianyi Gou41515e22011-09-01 19:37:43 -07004275
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004276static struct clk_freq_tbl clk_tbl_vfe[] = {
4277 F_VFE( 0, gnd, 1, 0, 0),
4278 F_VFE( 13960000, pll8, 1, 2, 55),
4279 F_VFE( 27000000, pxo, 1, 0, 0),
4280 F_VFE( 36570000, pll8, 1, 2, 21),
4281 F_VFE( 38400000, pll8, 2, 1, 5),
4282 F_VFE( 45180000, pll8, 1, 2, 17),
4283 F_VFE( 48000000, pll8, 2, 1, 4),
4284 F_VFE( 54860000, pll8, 1, 1, 7),
4285 F_VFE( 64000000, pll8, 2, 1, 3),
4286 F_VFE( 76800000, pll8, 1, 1, 5),
4287 F_VFE( 96000000, pll8, 2, 1, 2),
4288 F_VFE(109710000, pll8, 1, 2, 7),
4289 F_VFE(128000000, pll8, 1, 1, 3),
4290 F_VFE(153600000, pll8, 1, 2, 5),
4291 F_VFE(200000000, pll2, 2, 1, 2),
4292 F_VFE(228570000, pll2, 1, 2, 7),
4293 F_VFE(266667000, pll2, 1, 1, 3),
4294 F_VFE(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004295 F_END
4296};
4297
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004298static unsigned long fmax_vfe_8960_v2[MAX_VDD_LEVELS] __initdata = {
4299 [VDD_DIG_LOW] = 110000000,
4300 [VDD_DIG_NOMINAL] = 266667000,
4301 [VDD_DIG_HIGH] = 320000000
4302};
4303
4304static unsigned long fmax_vfe_8064[MAX_VDD_LEVELS] __initdata = {
4305 [VDD_DIG_LOW] = 128000000,
4306 [VDD_DIG_NOMINAL] = 266667000,
4307 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07004308};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004309
4310static struct rcg_clk vfe_clk = {
4311 .b = {
4312 .ctl_reg = VFE_CC_REG,
4313 .reset_reg = SW_RESET_CORE_REG,
4314 .reset_mask = BIT(15),
4315 .halt_reg = DBG_BUS_VEC_B_REG,
4316 .halt_bit = 6,
4317 .en_mask = BIT(0),
4318 },
4319 .ns_reg = VFE_NS_REG,
4320 .md_reg = VFE_MD_REG,
4321 .root_en_mask = BIT(2),
4322 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
4323 .ctl_mask = BM(7, 6),
4324 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004325 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004326 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004327 .c = {
4328 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004329 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004330 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004331 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004332 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004333 },
4334};
4335
Matt Wagantallc23eee92011-08-16 23:06:52 -07004336static struct branch_clk csi_vfe_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004337 .b = {
4338 .ctl_reg = VFE_CC_REG,
4339 .en_mask = BIT(12),
4340 .reset_reg = SW_RESET_CORE_REG,
4341 .reset_mask = BIT(24),
4342 .halt_reg = DBG_BUS_VEC_B_REG,
4343 .halt_bit = 8,
4344 },
4345 .parent = &vfe_clk.c,
4346 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -07004347 .dbg_name = "csi_vfe_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004348 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -07004349 CLK_INIT(csi_vfe_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004350 },
4351};
4352
4353/*
4354 * Low Power Audio Clocks
4355 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004356#define F_AIF_OSR(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004357 { \
4358 .freq_hz = f, \
4359 .src_clk = &s##_clk.c, \
4360 .md_val = MD8(8, m, 0, n), \
4361 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4362 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004363 }
4364static struct clk_freq_tbl clk_tbl_aif_osr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004365 F_AIF_OSR( 0, gnd, 1, 0, 0),
4366 F_AIF_OSR( 512000, pll4, 4, 1, 192),
4367 F_AIF_OSR( 768000, pll4, 4, 1, 128),
4368 F_AIF_OSR( 1024000, pll4, 4, 1, 96),
4369 F_AIF_OSR( 1536000, pll4, 4, 1, 64),
4370 F_AIF_OSR( 2048000, pll4, 4, 1, 48),
4371 F_AIF_OSR( 3072000, pll4, 4, 1, 32),
4372 F_AIF_OSR( 4096000, pll4, 4, 1, 24),
4373 F_AIF_OSR( 6144000, pll4, 4, 1, 16),
4374 F_AIF_OSR( 8192000, pll4, 4, 1, 12),
4375 F_AIF_OSR(12288000, pll4, 4, 1, 8),
4376 F_AIF_OSR(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004377 F_END
4378};
4379
4380#define CLK_AIF_OSR(i, ns, md, h_r) \
4381 struct rcg_clk i##_clk = { \
4382 .b = { \
4383 .ctl_reg = ns, \
4384 .en_mask = BIT(17), \
4385 .reset_reg = ns, \
4386 .reset_mask = BIT(19), \
4387 .halt_reg = h_r, \
4388 .halt_check = ENABLE, \
4389 .halt_bit = 1, \
4390 }, \
4391 .ns_reg = ns, \
4392 .md_reg = md, \
4393 .root_en_mask = BIT(9), \
4394 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4395 .set_rate = set_rate_mnd, \
4396 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004397 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004398 .c = { \
4399 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004400 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004401 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004402 CLK_INIT(i##_clk.c), \
4403 }, \
4404 }
4405#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
4406 struct rcg_clk i##_clk = { \
4407 .b = { \
4408 .ctl_reg = ns, \
4409 .en_mask = BIT(21), \
4410 .reset_reg = ns, \
4411 .reset_mask = BIT(23), \
4412 .halt_reg = h_r, \
4413 .halt_check = ENABLE, \
4414 .halt_bit = 1, \
4415 }, \
4416 .ns_reg = ns, \
4417 .md_reg = md, \
4418 .root_en_mask = BIT(9), \
4419 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4420 .set_rate = set_rate_mnd, \
4421 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004422 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004423 .c = { \
4424 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004425 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004426 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004427 CLK_INIT(i##_clk.c), \
4428 }, \
4429 }
4430
4431#define F_AIF_BIT(d, s) \
4432 { \
4433 .freq_hz = d, \
4434 .ns_val = (BVAL(14, 14, s) | BVAL(13, 10, (d-1))) \
4435 }
4436static struct clk_freq_tbl clk_tbl_aif_bit[] = {
4437 F_AIF_BIT(0, 1), /* Use external clock. */
4438 F_AIF_BIT(1, 0), F_AIF_BIT(2, 0), F_AIF_BIT(3, 0), F_AIF_BIT(4, 0),
4439 F_AIF_BIT(5, 0), F_AIF_BIT(6, 0), F_AIF_BIT(7, 0), F_AIF_BIT(8, 0),
4440 F_AIF_BIT(9, 0), F_AIF_BIT(10, 0), F_AIF_BIT(11, 0), F_AIF_BIT(12, 0),
4441 F_AIF_BIT(13, 0), F_AIF_BIT(14, 0), F_AIF_BIT(15, 0), F_AIF_BIT(16, 0),
4442 F_END
4443};
4444
4445#define CLK_AIF_BIT(i, ns, h_r) \
4446 struct rcg_clk i##_clk = { \
4447 .b = { \
4448 .ctl_reg = ns, \
4449 .en_mask = BIT(15), \
4450 .halt_reg = h_r, \
4451 .halt_check = DELAY, \
4452 }, \
4453 .ns_reg = ns, \
4454 .ns_mask = BM(14, 10), \
4455 .set_rate = set_rate_nop, \
4456 .freq_tbl = clk_tbl_aif_bit, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004457 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004458 .c = { \
4459 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004460 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004461 CLK_INIT(i##_clk.c), \
4462 }, \
4463 }
4464
4465#define F_AIF_BIT_D(d, s) \
4466 { \
4467 .freq_hz = d, \
4468 .ns_val = (BVAL(18, 18, s) | BVAL(17, 10, (d-1))) \
4469 }
4470static struct clk_freq_tbl clk_tbl_aif_bit_div[] = {
4471 F_AIF_BIT_D(0, 1), /* Use external clock. */
4472 F_AIF_BIT_D(1, 0), F_AIF_BIT_D(2, 0), F_AIF_BIT_D(3, 0),
4473 F_AIF_BIT_D(4, 0), F_AIF_BIT_D(5, 0), F_AIF_BIT_D(6, 0),
4474 F_AIF_BIT_D(7, 0), F_AIF_BIT_D(8, 0), F_AIF_BIT_D(9, 0),
4475 F_AIF_BIT_D(10, 0), F_AIF_BIT_D(11, 0), F_AIF_BIT_D(12, 0),
4476 F_AIF_BIT_D(13, 0), F_AIF_BIT_D(14, 0), F_AIF_BIT_D(15, 0),
4477 F_AIF_BIT_D(16, 0),
4478 F_END
4479};
4480
4481#define CLK_AIF_BIT_DIV(i, ns, h_r) \
4482 struct rcg_clk i##_clk = { \
4483 .b = { \
4484 .ctl_reg = ns, \
4485 .en_mask = BIT(19), \
4486 .halt_reg = h_r, \
4487 .halt_check = ENABLE, \
4488 }, \
4489 .ns_reg = ns, \
4490 .ns_mask = BM(18, 10), \
4491 .set_rate = set_rate_nop, \
4492 .freq_tbl = clk_tbl_aif_bit_div, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004493 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004494 .c = { \
4495 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004496 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004497 CLK_INIT(i##_clk.c), \
4498 }, \
4499 }
4500
4501static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
4502 LCC_MI2S_STATUS_REG);
4503static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
4504
4505static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
4506 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
4507static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
4508 LCC_CODEC_I2S_MIC_STATUS_REG);
4509
4510static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
4511 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
4512static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
4513 LCC_SPARE_I2S_MIC_STATUS_REG);
4514
4515static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
4516 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
4517static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
4518 LCC_CODEC_I2S_SPKR_STATUS_REG);
4519
4520static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
4521 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
4522static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
4523 LCC_SPARE_I2S_SPKR_STATUS_REG);
4524
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004525#define F_PCM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004526 { \
4527 .freq_hz = f, \
4528 .src_clk = &s##_clk.c, \
4529 .md_val = MD16(m, n), \
4530 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4531 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004532 }
4533static struct clk_freq_tbl clk_tbl_pcm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004534 F_PCM( 0, gnd, 1, 0, 0),
4535 F_PCM( 512000, pll4, 4, 1, 192),
4536 F_PCM( 768000, pll4, 4, 1, 128),
4537 F_PCM( 1024000, pll4, 4, 1, 96),
4538 F_PCM( 1536000, pll4, 4, 1, 64),
4539 F_PCM( 2048000, pll4, 4, 1, 48),
4540 F_PCM( 3072000, pll4, 4, 1, 32),
4541 F_PCM( 4096000, pll4, 4, 1, 24),
4542 F_PCM( 6144000, pll4, 4, 1, 16),
4543 F_PCM( 8192000, pll4, 4, 1, 12),
4544 F_PCM(12288000, pll4, 4, 1, 8),
4545 F_PCM(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004546 F_END
4547};
4548
4549static struct rcg_clk pcm_clk = {
4550 .b = {
4551 .ctl_reg = LCC_PCM_NS_REG,
4552 .en_mask = BIT(11),
4553 .reset_reg = LCC_PCM_NS_REG,
4554 .reset_mask = BIT(13),
4555 .halt_reg = LCC_PCM_STATUS_REG,
4556 .halt_check = ENABLE,
4557 .halt_bit = 0,
4558 },
4559 .ns_reg = LCC_PCM_NS_REG,
4560 .md_reg = LCC_PCM_MD_REG,
4561 .root_en_mask = BIT(9),
4562 .ns_mask = (BM(31, 16) | BM(6, 0)),
4563 .set_rate = set_rate_mnd,
4564 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004565 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004566 .c = {
4567 .dbg_name = "pcm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004568 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004569 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004570 CLK_INIT(pcm_clk.c),
4571 },
4572};
4573
4574static struct rcg_clk audio_slimbus_clk = {
4575 .b = {
4576 .ctl_reg = LCC_SLIMBUS_NS_REG,
4577 .en_mask = BIT(10),
4578 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
4579 .reset_mask = BIT(5),
4580 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4581 .halt_check = ENABLE,
4582 .halt_bit = 0,
4583 },
4584 .ns_reg = LCC_SLIMBUS_NS_REG,
4585 .md_reg = LCC_SLIMBUS_MD_REG,
4586 .root_en_mask = BIT(9),
4587 .ns_mask = (BM(31, 24) | BM(6, 0)),
4588 .set_rate = set_rate_mnd,
4589 .freq_tbl = clk_tbl_aif_osr,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004590 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004591 .c = {
4592 .dbg_name = "audio_slimbus_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004593 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004594 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004595 CLK_INIT(audio_slimbus_clk.c),
4596 },
4597};
4598
4599static struct branch_clk sps_slimbus_clk = {
4600 .b = {
4601 .ctl_reg = LCC_SLIMBUS_NS_REG,
4602 .en_mask = BIT(12),
4603 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4604 .halt_check = ENABLE,
4605 .halt_bit = 1,
4606 },
4607 .parent = &audio_slimbus_clk.c,
4608 .c = {
4609 .dbg_name = "sps_slimbus_clk",
4610 .ops = &clk_ops_branch,
4611 CLK_INIT(sps_slimbus_clk.c),
4612 },
4613};
4614
4615static struct branch_clk slimbus_xo_src_clk = {
4616 .b = {
4617 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
4618 .en_mask = BIT(2),
4619 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004620 .halt_bit = 28,
4621 },
4622 .parent = &sps_slimbus_clk.c,
4623 .c = {
4624 .dbg_name = "slimbus_xo_src_clk",
4625 .ops = &clk_ops_branch,
4626 CLK_INIT(slimbus_xo_src_clk.c),
4627 },
4628};
4629
Matt Wagantall735f01a2011-08-12 12:40:28 -07004630DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
4631DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
4632DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
4633DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
4634DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
4635DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
4636DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
4637DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004638
4639static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
4640static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
Manu Gautam7483f172011-11-08 15:22:26 +05304641static DEFINE_CLK_VOTER(dfab_usb_hs3_clk, &dfab_clk.c);
4642static DEFINE_CLK_VOTER(dfab_usb_hs4_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004643static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
4644static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
4645static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
4646static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
4647static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
4648static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
Stephen Boyd1c51a492011-10-26 12:11:47 -07004649static DEFINE_CLK_VOTER(dfab_bam_dmux_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004650
4651static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
4652/*
4653 * TODO: replace dummy_clk below with ebi1_clk.c once the
4654 * bus driver starts voting on ebi1 rates.
4655 */
4656static DEFINE_CLK_VOTER(ebi1_adm_clk, &dummy_clk);
4657
4658#ifdef CONFIG_DEBUG_FS
4659struct measure_sel {
4660 u32 test_vector;
4661 struct clk *clk;
4662};
4663
Matt Wagantall8b38f942011-08-02 18:23:18 -07004664static DEFINE_CLK_MEASURE(l2_m_clk);
4665static DEFINE_CLK_MEASURE(krait0_m_clk);
4666static DEFINE_CLK_MEASURE(krait1_m_clk);
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004667static DEFINE_CLK_MEASURE(q6sw_clk);
4668static DEFINE_CLK_MEASURE(q6fw_clk);
4669static DEFINE_CLK_MEASURE(q6_func_clk);
Matt Wagantall8b38f942011-08-02 18:23:18 -07004670
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004671static struct measure_sel measure_mux[] = {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004672 { TEST_PER_LS(0x05), &qdss_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004673 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
4674 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
4675 { TEST_PER_LS(0x13), &sdc1_clk.c },
4676 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
4677 { TEST_PER_LS(0x15), &sdc2_clk.c },
4678 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
4679 { TEST_PER_LS(0x17), &sdc3_clk.c },
4680 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
4681 { TEST_PER_LS(0x19), &sdc4_clk.c },
4682 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
4683 { TEST_PER_LS(0x1B), &sdc5_clk.c },
4684 { TEST_PER_LS(0x25), &dfab_clk.c },
4685 { TEST_PER_LS(0x25), &dfab_a_clk.c },
4686 { TEST_PER_LS(0x26), &pmem_clk.c },
4687 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
4688 { TEST_PER_LS(0x33), &cfpb_clk.c },
4689 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
4690 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
4691 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
4692 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
4693 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
4694 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
4695 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
4696 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
4697 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
4698 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
4699 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
4700 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
4701 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
4702 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
4703 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
4704 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
4705 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
4706 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
4707 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
4708 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
4709 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
4710 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
4711 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
4712 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
4713 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
4714 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
4715 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
4716 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
4717 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
4718 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
4719 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
4720 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
4721 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
4722 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
4723 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
4724 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
4725 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004726 { TEST_PER_LS(0x5E), &pcie_p_clk.c },
4727 { TEST_PER_LS(0x5F), &ce3_p_clk.c },
4728 { TEST_PER_LS(0x60), &ce3_core_clk.c },
4729 { TEST_PER_LS(0x63), &usb_hs3_p_clk.c },
4730 { TEST_PER_LS(0x64), &usb_hs3_xcvr_clk.c },
4731 { TEST_PER_LS(0x65), &usb_hs4_p_clk.c },
4732 { TEST_PER_LS(0x66), &usb_hs4_xcvr_clk.c },
4733 { TEST_PER_LS(0x6B), &sata_phy_ref_clk.c },
4734 { TEST_PER_LS(0x6C), &sata_phy_cfg_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004735 { TEST_PER_LS(0x78), &sfpb_clk.c },
4736 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
4737 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
4738 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
4739 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
4740 { TEST_PER_LS(0x7D), &prng_clk.c },
4741 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
4742 { TEST_PER_LS(0x80), &adm0_p_clk.c },
4743 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
4744 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004745 { TEST_PER_LS(0x86), &usb_hsic_p_clk.c },
4746 { TEST_PER_LS(0x87), &usb_hsic_system_clk.c },
4747 { TEST_PER_LS(0x88), &usb_hsic_xcvr_fs_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004748 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
4749 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
4750 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
4751 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
4752 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
4753 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
4754 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
4755 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
4756 { TEST_PER_LS(0x92), &ce1_p_clk.c },
4757 { TEST_PER_LS(0x94), &tssc_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004758 { TEST_PER_LS(0x9D), &usb_hsic_hsio_cal_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004759 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
4760
4761 { TEST_PER_HS(0x07), &afab_clk.c },
4762 { TEST_PER_HS(0x07), &afab_a_clk.c },
4763 { TEST_PER_HS(0x18), &sfab_clk.c },
4764 { TEST_PER_HS(0x18), &sfab_a_clk.c },
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004765 { TEST_PER_HS(0x26), &q6sw_clk },
4766 { TEST_PER_HS(0x27), &q6fw_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004767 { TEST_PER_HS(0x2A), &adm0_clk.c },
4768 { TEST_PER_HS(0x34), &ebi1_clk.c },
4769 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004770 { TEST_PER_HS(0x48), &qdss_at_clk.c },
4771 { TEST_PER_HS(0x49), &qdss_pclkdbg_clk.c },
4772 { TEST_PER_HS(0x4A), &qdss_traceclkin_clk.c },
4773 { TEST_PER_HS(0x4B), &qdss_tsctr_clk.c },
4774 { TEST_PER_HS(0x4F), &qdss_stm_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004775 { TEST_PER_HS(0x50), &usb_hsic_hsic_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004776
4777 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
4778 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
4779 { TEST_MM_LS(0x02), &cam1_clk.c },
4780 { TEST_MM_LS(0x06), &amp_p_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004781 { TEST_MM_LS(0x07), &csi_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004782 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
4783 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
4784 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
4785 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
4786 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
4787 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
4788 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
4789 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
4790 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
4791 { TEST_MM_LS(0x12), &imem_p_clk.c },
4792 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
4793 { TEST_MM_LS(0x14), &mdp_p_clk.c },
4794 { TEST_MM_LS(0x16), &rot_p_clk.c },
4795 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
4796 { TEST_MM_LS(0x18), &smmu_p_clk.c },
4797 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
4798 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
4799 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
4800 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
4801 { TEST_MM_LS(0x1D), &cam0_clk.c },
4802 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
4803 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
4804 { TEST_MM_LS(0x21), &tv_dac_clk.c },
4805 { TEST_MM_LS(0x22), &tv_enc_clk.c },
4806 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
4807 { TEST_MM_LS(0x25), &mmfpb_clk.c },
4808 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
4809 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004810 { TEST_MM_LS(0x27), &cam2_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004811 { TEST_MM_LS(0x28), &vcap_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004812
4813 { TEST_MM_HS(0x00), &csi0_clk.c },
4814 { TEST_MM_HS(0x01), &csi1_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004815 { TEST_MM_HS(0x04), &csi_vfe_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004816 { TEST_MM_HS(0x05), &ijpeg_clk.c },
4817 { TEST_MM_HS(0x06), &vfe_clk.c },
4818 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
4819 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
4820 { TEST_MM_HS(0x09), &gfx3d_clk.c },
4821 { TEST_MM_HS(0x0A), &jpegd_clk.c },
4822 { TEST_MM_HS(0x0B), &vcodec_clk.c },
4823 { TEST_MM_HS(0x0F), &mmfab_clk.c },
4824 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
4825 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
4826 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
4827 { TEST_MM_HS(0x13), &imem_axi_clk.c },
4828 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
4829 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
4830 { TEST_MM_HS(0x16), &rot_axi_clk.c },
4831 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
4832 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
4833 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
4834 { TEST_MM_HS(0x1A), &mdp_clk.c },
4835 { TEST_MM_HS(0x1B), &rot_clk.c },
4836 { TEST_MM_HS(0x1C), &vpe_clk.c },
4837 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
4838 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
4839 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
4840 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
4841 { TEST_MM_HS(0x26), &csi_pix_clk.c },
4842 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
4843 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
4844 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
4845 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
4846 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
4847 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004848 { TEST_MM_HS(0x2D), &csi2_clk.c },
4849 { TEST_MM_HS(0x2E), &csi2_phy_clk.c },
4850 { TEST_MM_HS(0x2F), &csi2phy_timer_clk.c },
4851 { TEST_MM_HS(0x30), &csi_pix1_clk.c },
4852 { TEST_MM_HS(0x31), &csi_rdi1_clk.c },
4853 { TEST_MM_HS(0x32), &csi_rdi2_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004854 { TEST_MM_HS(0x33), &vcap_clk.c },
4855 { TEST_MM_HS(0x34), &vcap_npl_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004856 { TEST_MM_HS(0x36), &vcap_axi_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004857 { TEST_MM_HS(0x39), &gfx3d_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004858
4859 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
4860 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
4861 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
4862 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
4863 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
4864 { TEST_LPA(0x14), &pcm_clk.c },
4865 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
Matt Wagantall8b38f942011-08-02 18:23:18 -07004866
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004867 { TEST_LPA_HS(0x00), &q6_func_clk },
4868
Matt Wagantall8b38f942011-08-02 18:23:18 -07004869 { TEST_CPUL2(0x1), &l2_m_clk },
4870 { TEST_CPUL2(0x2), &krait0_m_clk },
4871 { TEST_CPUL2(0x3), &krait1_m_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004872};
4873
4874static struct measure_sel *find_measure_sel(struct clk *clk)
4875{
4876 int i;
4877
4878 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
4879 if (measure_mux[i].clk == clk)
4880 return &measure_mux[i];
4881 return NULL;
4882}
4883
Matt Wagantall8b38f942011-08-02 18:23:18 -07004884static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004885{
4886 int ret = 0;
4887 u32 clk_sel;
4888 struct measure_sel *p;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004889 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004890 unsigned long flags;
4891
4892 if (!parent)
4893 return -EINVAL;
4894
4895 p = find_measure_sel(parent);
4896 if (!p)
4897 return -EINVAL;
4898
4899 spin_lock_irqsave(&local_clock_reg_lock, flags);
4900
Matt Wagantall8b38f942011-08-02 18:23:18 -07004901 /*
4902 * Program the test vector, measurement period (sample_ticks)
4903 * and scaling multiplier.
4904 */
4905 clk->sample_ticks = 0x10000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004906 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004907 clk->multiplier = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004908 switch (p->test_vector >> TEST_TYPE_SHIFT) {
4909 case TEST_TYPE_PER_LS:
4910 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
4911 break;
4912 case TEST_TYPE_PER_HS:
4913 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
4914 break;
4915 case TEST_TYPE_MM_LS:
4916 writel_relaxed(0x4030D97, CLK_TEST_REG);
4917 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
4918 break;
4919 case TEST_TYPE_MM_HS:
4920 writel_relaxed(0x402B800, CLK_TEST_REG);
4921 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
4922 break;
4923 case TEST_TYPE_LPA:
4924 writel_relaxed(0x4030D98, CLK_TEST_REG);
4925 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
4926 LCC_CLK_LS_DEBUG_CFG_REG);
4927 break;
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004928 case TEST_TYPE_LPA_HS:
4929 writel_relaxed(0x402BC00, CLK_TEST_REG);
4930 writel_relaxed(BVAL(2, 1, clk_sel)|BIT(0),
4931 LCC_CLK_HS_DEBUG_CFG_REG);
4932 break;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004933 case TEST_TYPE_CPUL2:
4934 writel_relaxed(0x4030400, CLK_TEST_REG);
4935 writel_relaxed(0x80|BVAL(5, 3, clk_sel), GCC_APCS_CLK_DIAG);
4936 clk->sample_ticks = 0x4000;
4937 clk->multiplier = 2;
4938 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004939 default:
4940 ret = -EPERM;
4941 }
4942 /* Make sure test vector is set before starting measurements. */
4943 mb();
4944
4945 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4946
4947 return ret;
4948}
4949
4950/* Sample clock for 'ticks' reference clock ticks. */
4951static u32 run_measurement(unsigned ticks)
4952{
4953 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004954 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
4955
4956 /* Wait for timer to become ready. */
4957 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
4958 cpu_relax();
4959
4960 /* Run measurement and wait for completion. */
4961 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
4962 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
4963 cpu_relax();
4964
4965 /* Stop counters. */
4966 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
4967
4968 /* Return measured ticks. */
4969 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
4970}
4971
4972
4973/* Perform a hardware rate measurement for a given clock.
4974 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07004975static unsigned long measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004976{
4977 unsigned long flags;
4978 u32 pdm_reg_backup, ringosc_reg_backup;
4979 u64 raw_count_short, raw_count_full;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004980 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004981 unsigned ret;
4982
4983 spin_lock_irqsave(&local_clock_reg_lock, flags);
4984
4985 /* Enable CXO/4 and RINGOSC branch and root. */
4986 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
4987 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
4988 writel_relaxed(0x2898, PDM_CLK_NS_REG);
4989 writel_relaxed(0xA00, RINGOSC_NS_REG);
4990
4991 /*
4992 * The ring oscillator counter will not reset if the measured clock
4993 * is not running. To detect this, run a short measurement before
4994 * the full measurement. If the raw results of the two are the same
4995 * then the clock must be off.
4996 */
4997
4998 /* Run a short measurement. (~1 ms) */
4999 raw_count_short = run_measurement(0x1000);
5000 /* Run a full measurement. (~14 ms) */
Matt Wagantall8b38f942011-08-02 18:23:18 -07005001 raw_count_full = run_measurement(clk->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005002
5003 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
5004 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
5005
5006 /* Return 0 if the clock is off. */
5007 if (raw_count_full == raw_count_short)
5008 ret = 0;
5009 else {
5010 /* Compute rate in Hz. */
5011 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantall8b38f942011-08-02 18:23:18 -07005012 do_div(raw_count_full, ((clk->sample_ticks * 10) + 35));
5013 ret = (raw_count_full * clk->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005014 }
5015
5016 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07005017 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005018 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
5019
5020 return ret;
5021}
5022#else /* !CONFIG_DEBUG_FS */
5023static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
5024{
5025 return -EINVAL;
5026}
5027
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07005028static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005029{
5030 return 0;
5031}
5032#endif /* CONFIG_DEBUG_FS */
5033
5034static struct clk_ops measure_clk_ops = {
5035 .set_parent = measure_clk_set_parent,
5036 .get_rate = measure_clk_get_rate,
5037 .is_local = local_clk_is_local,
5038};
5039
Matt Wagantall8b38f942011-08-02 18:23:18 -07005040static struct measure_clk measure_clk = {
5041 .c = {
5042 .dbg_name = "measure_clk",
5043 .ops = &measure_clk_ops,
5044 CLK_INIT(measure_clk.c),
5045 },
5046 .multiplier = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005047};
5048
Tianyi Goua8b3cce2011-11-08 14:37:26 -08005049static struct clk_lookup msm_clocks_8064[] = {
Tianyi Gou41515e22011-09-01 19:37:43 -07005050 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005051 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005052 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
Tianyi Gouc29c3242011-10-12 21:02:15 -07005053 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005054 CLK_LOOKUP("measure", measure_clk.c, "debug"),
5055
5056 CLK_DUMMY("afab_clk", AFAB_CLK, NULL, 0),
5057 CLK_DUMMY("afab_a_clk", AFAB_A_CLK, NULL, 0),
5058 CLK_DUMMY("cfpb_clk", CFPB_CLK, NULL, 0),
5059 CLK_DUMMY("cfpb_a_clk", CFPB_A_CLK, NULL, 0),
5060 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
5061 CLK_DUMMY("dfab_a_clk", DFAB_A_CLK, NULL, 0),
5062 CLK_DUMMY("ebi1_clk", EBI1_CLK, NULL, 0),
5063 CLK_DUMMY("ebi1_a_clk", EBI1_A_CLK, NULL, 0),
5064 CLK_DUMMY("mmfab_clk", MMFAB_CLK, NULL, 0),
5065 CLK_DUMMY("mmfab_a_clk", MMFAB_A_CLK, NULL, 0),
5066 CLK_DUMMY("mmfpb_clk", MMFPB_CLK, NULL, 0),
5067 CLK_DUMMY("mmfpb_a_clk", MMFPB_A_CLK, NULL, 0),
5068 CLK_DUMMY("sfab_clk", SFAB_CLK, NULL, 0),
5069 CLK_DUMMY("sfab_a_clk", SFAB_A_CLK, NULL, 0),
5070 CLK_DUMMY("sfpb_clk", SFPB_CLK, NULL, 0),
5071 CLK_DUMMY("sfpb_a_clk", SFPB_A_CLK, NULL, 0),
5072
5073 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
5074 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
5075 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
5076 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
5077 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, NULL),
5078 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, NULL),
5079 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
5080 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, NULL),
5081 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
5082 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, NULL),
5083 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, NULL),
5084 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
5085 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
5086 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005087 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005088 CLK_LOOKUP("pmem_clk", pmem_clk.c, NULL),
5089 CLK_DUMMY("core_clk", PRNG_CLK, NULL, OFF),
Tianyi Gou43208a02011-09-27 15:35:13 -07005090 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5091 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5092 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5093 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005094 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
5095 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005096 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
Manu Gautam7483f172011-11-08 15:22:26 +05305097 CLK_LOOKUP("core_clk", usb_hs3_xcvr_clk.c, "msm_ehci_host.0"),
5098 CLK_LOOKUP("core_clk", usb_hs4_xcvr_clk.c, "msm_ehci_host.1"),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005099 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
5100 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
5101 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005102 CLK_LOOKUP("iface_clk", ce1_p_clk.c, NULL),
5103 CLK_LOOKUP("core_clk", ce1_core_clk.c, NULL),
5104 CLK_LOOKUP("ref_clk", sata_phy_ref_clk.c, NULL),
5105 CLK_LOOKUP("cfg_clk", sata_phy_cfg_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005106 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
5107 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, NULL),
5108 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
5109 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, NULL),
5110 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, NULL),
5111 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, NULL),
5112 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, NULL),
5113 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005114 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005115 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5116 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Manu Gautam7483f172011-11-08 15:22:26 +05305117 CLK_LOOKUP("iface_clk", usb_hs3_p_clk.c, "msm_ehci_host.0"),
5118 CLK_LOOKUP("iface_clk", usb_hs4_p_clk.c, "msm_ehci_host.1"),
Tianyi Gou43208a02011-09-27 15:35:13 -07005119 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5120 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5121 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5122 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005123 CLK_LOOKUP("iface_clk", pcie_p_clk.c, NULL),
5124 CLK_LOOKUP("core_src_clk", ce3_src_clk.c, NULL),
5125 CLK_LOOKUP("core_clk", ce3_core_clk.c, NULL),
5126 CLK_LOOKUP("iface_clk", ce3_p_clk.c, NULL),
5127 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5128 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005129 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
5130 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
5131 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
5132 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
5133 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005134 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5135 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
5136 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5137 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5138 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005139 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005140 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5141 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5142 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005143 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005144 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5145 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5146 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005147 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005148 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5149 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5150 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005151 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, NULL),
5152 CLK_LOOKUP("csi_pix_clk", csi_pix1_clk.c, NULL),
5153 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, NULL),
5154 CLK_LOOKUP("csi_rdi_clk", csi_rdi1_clk.c, NULL),
5155 CLK_LOOKUP("csi_rdi_clk", csi_rdi2_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005156 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
5157 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, NULL),
5158 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, NULL),
5159 CLK_LOOKUP("csiphy_timer_clk", csi2phy_timer_clk.c, NULL),
5160 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5161 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5162 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5163 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
5164 CLK_DUMMY("rgb_tv_clk", RGB_TV_CLK, NULL, OFF),
5165 CLK_DUMMY("npl_tv_clk", NPL_TV_CLK, NULL, OFF),
5166 CLK_LOOKUP("core_clk", gfx3d_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005167 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5168 CLK_LOOKUP("bus_clk", gfx3d_axi_clk.c, "footswitch-8x60.2"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005169 CLK_LOOKUP("iface_clk", vcap_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005170 CLK_LOOKUP("iface_clk", vcap_p_clk.c, "footswitch-8x60.10"),
5171 CLK_LOOKUP("bus_clk", vcap_axi_clk.c, "footswitch-8x60.10"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005172 CLK_LOOKUP("core_clk", vcap_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005173 CLK_LOOKUP("core_clk", vcap_clk.c, "footswitch-8x60.10"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005174 CLK_LOOKUP("vcap_npl_clk", vcap_npl_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005175 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005176 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
5177 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005178 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005179 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005180 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005181 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005182 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
5183 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005184 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005185 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005186 CLK_DUMMY("tv_src_clk", TV_SRC_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005187 CLK_LOOKUP("core_clk", vcodec_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005188 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005189 CLK_DUMMY("mdp_tv_clk", MDP_TV_CLK, NULL, OFF),
5190 CLK_DUMMY("hdmi_clk", HDMI_TV_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005191 CLK_LOOKUP("core_clk", hdmi_app_clk.c, NULL),
5192 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005193 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005194 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005195 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005196 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005197 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5198 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5199 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5200 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5201 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5202 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5203 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005204 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
5205 CLK_LOOKUP("csi_pclk", csi_p_clk.c, NULL),
5206 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5207 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5208 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5209 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
5210 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005211 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005212 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, NULL),
5213 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, NULL),
5214 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005215 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005216 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
5217 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005218 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005219 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005220 CLK_LOOKUP("iface_clk", smmu_p_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005221 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005222 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005223 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005224 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005225 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005226 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005227 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005228 CLK_LOOKUP("iface_pclk", vpe_p_clk.c, "footswitch-8x60.9"),
Tianyi Gouc29c3242011-10-12 21:02:15 -07005229 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5230 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5231 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5232 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5233 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5234 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5235 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5236 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5237 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5238 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5239 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
Tianyi Goudd8138a2011-10-20 15:46:00 -07005240 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5241 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005242 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, NULL),
5243 CLK_LOOKUP("core_clk", vpe_axi_clk.c, NULL),
5244 CLK_LOOKUP("core_clk", mdp_axi_clk.c, NULL),
5245 CLK_LOOKUP("core_clk", vcap_axi_clk.c, NULL),
5246 CLK_LOOKUP("core_clk", rot_axi_clk.c, NULL),
5247 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, NULL),
5248 CLK_LOOKUP("core_clk", vfe_axi_clk.c, NULL),
5249 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, NULL),
5250 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005251 CLK_LOOKUP("core_clk", gfx3d_axi_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005252 CLK_DUMMY("dfab_dsps_clk", DFAB_DSPS_CLK, NULL, 0),
5253 CLK_DUMMY("dfab_usb_hs_clk", DFAB_USB_HS_CLK, NULL, 0),
Manu Gautam7483f172011-11-08 15:22:26 +05305254 CLK_DUMMY("bus_clk", DFAB_USB_HS3_CLK, "msm_ehci_host.0", 0),
5255 CLK_DUMMY("bus_clk", DFAB_USB_HS4_CLK, "msm_ehci_host.1", 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005256 CLK_DUMMY("bus_clk", DFAB_SDC1_CLK, NULL, 0),
5257 CLK_DUMMY("bus_clk", DFAB_SDC2_CLK, NULL, 0),
5258 CLK_DUMMY("bus_clk", DFAB_SDC3_CLK, NULL, 0),
5259 CLK_DUMMY("bus_clk", DFAB_SDC4_CLK, NULL, 0),
5260 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
5261 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5262 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5263 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5264 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5265 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5266
5267 CLK_LOOKUP("ebi1_msmbus_clk", ebi1_msmbus_clk.c, NULL),
Jeff Ohlstein8c116c72011-10-27 17:34:48 -07005268 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005269
5270 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5271 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5272 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
5273};
5274
Stephen Boyd94625ef2011-07-12 17:06:01 -07005275static struct clk_lookup msm_clocks_8960_v1[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005276 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
5277 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
5278 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
5279 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005280 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005281
5282 CLK_LOOKUP("afab_clk", afab_clk.c, NULL),
5283 CLK_LOOKUP("afab_a_clk", afab_a_clk.c, NULL),
5284 CLK_LOOKUP("cfpb_clk", cfpb_clk.c, NULL),
5285 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, NULL),
Stephen Boyd85436132011-09-16 18:55:13 -07005286 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005287 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
5288 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
5289 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
5290 CLK_LOOKUP("ebi1_a_clk", ebi1_a_clk.c, NULL),
5291 CLK_LOOKUP("mmfab_clk", mmfab_clk.c, NULL),
5292 CLK_LOOKUP("mmfab_a_clk", mmfab_a_clk.c, NULL),
5293 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
5294 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, NULL),
Stephen Boyda3787f32011-09-16 18:55:13 -07005295 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005296 CLK_LOOKUP("sfab_clk", sfab_clk.c, NULL),
5297 CLK_LOOKUP("sfab_a_clk", sfab_a_clk.c, NULL),
5298 CLK_LOOKUP("sfpb_clk", sfpb_clk.c, NULL),
5299 CLK_LOOKUP("sfpb_a_clk", sfpb_a_clk.c, NULL),
5300
Matt Wagantalle2522372011-08-17 14:52:21 -07005301 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
5302 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
5303 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
5304 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
5305 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
5306 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
5307 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
5308 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, NULL),
5309 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, NULL),
5310 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, NULL),
5311 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, NULL),
5312 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005313 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005314 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005315 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
5316 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005317 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
5318 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
5319 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
5320 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, NULL),
5321 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005322 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005323 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005324 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005325 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Vikram Mulukutladd0a2372011-09-19 15:58:21 -07005326 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_sps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07005327 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005328 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5329 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5330 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5331 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
5332 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005333 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005334 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005335 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005336 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
5337 CLK_LOOKUP("usb_phy_clk", usb_phy0_clk.c, NULL),
5338 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
5339 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
5340 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
5341 CLK_LOOKUP("usb_fs_clk", usb_fs2_xcvr_clk.c, NULL),
5342 CLK_LOOKUP("usb_fs_sys_clk", usb_fs2_sys_clk.c, NULL),
5343 CLK_LOOKUP("usb_fs_src_clk", usb_fs2_src_clk.c, NULL),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005344 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005345 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qcrypto.0"),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005346 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005347 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qcrypto.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005348 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005349 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005350 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005351 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
5352 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07005353 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
5354 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005355 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
5356 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, NULL),
5357 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005358 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005359 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005360 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.12"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005361 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005362 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5363 CLK_LOOKUP("usb_fs_pclk", usb_fs2_p_clk.c, NULL),
5364 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005365 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5366 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5367 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5368 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
5369 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005370 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5371 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005372 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
5373 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
5374 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
5375 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
5376 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005377 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5378 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
5379 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_imx074.0"),
5380 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_ov2720.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07005381 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_qs_mt9p017.0"),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005382 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_csid.0"),
5383 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_csid.1"),
5384 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_csid.0"),
5385 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csid.1"),
5386 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_csid.0"),
5387 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_csid.1"),
Kevin Chane12c6672011-10-26 11:55:26 -07005388 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, "msm_ispif.0"),
5389 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, "msm_ispif.0"),
Kevin Chanf6216f22011-10-25 18:40:11 -07005390 CLK_LOOKUP("csiphy_timer_src_clk",
5391 csiphy_timer_src_clk.c, "msm_csiphy.0"),
5392 CLK_LOOKUP("csiphy_timer_src_clk",
5393 csiphy_timer_src_clk.c, "msm_csiphy.1"),
5394 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, "msm_csiphy.0"),
5395 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, "msm_csiphy.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005396 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5397 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5398 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5399 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005400 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005401 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005402 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005403 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005404 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005405 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5406 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005407 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005408 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005409 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005410 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005411 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005412 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005413 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
5414 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07005415 CLK_LOOKUP("qdss_pclk", qdss_p_clk.c, NULL),
5416 CLK_LOOKUP("qdss_at_clk", qdss_at_clk.c, NULL),
5417 CLK_LOOKUP("qdss_pclkdbg_clk", qdss_pclkdbg_clk.c, NULL),
5418 CLK_LOOKUP("qdss_traceclkin_clk", qdss_traceclkin_clk.c, NULL),
5419 CLK_LOOKUP("qdss_tsctr_clk", qdss_tsctr_clk.c, NULL),
5420 CLK_LOOKUP("qdss_stm_clk", qdss_stm_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005421 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005422 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005423 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
5424 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
5425 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005426 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005427 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005428 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
5429 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005430 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Kevin Chana0853122011-11-07 19:48:44 -08005431 CLK_LOOKUP("vpe_clk", vpe_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005432 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Kevin Chan5827c552011-10-28 18:36:32 -07005433 CLK_LOOKUP("vfe_clk", vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005434 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Kevin Chan5827c552011-10-28 18:36:32 -07005435 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005436 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5437 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5438 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5439 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5440 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5441 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5442 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005443 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005444 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.0"),
5445 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005446 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5447 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5448 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5449 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005450 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005451 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005452 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005453 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005454 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005455 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005456 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
5457 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005458 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005459 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005460 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005461 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005462 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005463 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07005464 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005465 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005466 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005467 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005468 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005469 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Kevin Chan5827c552011-10-28 18:36:32 -07005470 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005471 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Kevin Chana0853122011-11-07 19:48:44 -08005472 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005473 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005474 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5475 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5476 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5477 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5478 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5479 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5480 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5481 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5482 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5483 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5484 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
5485 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5486 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Matt Wagantalle604d712011-10-21 15:38:18 -07005487 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
5488 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
5489 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
5490 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
5491 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
5492 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
5493 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
5494 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
5495 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
5496 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
5497 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
5498 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005499 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
5500 CLK_LOOKUP("dfab_usb_hs_clk", dfab_usb_hs_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005501 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
5502 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
5503 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
5504 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
5505 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Yan He160633e2011-06-30 12:18:56 -07005506 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
Stephen Boyd1c51a492011-10-26 12:11:47 -07005507 CLK_LOOKUP("bus_clk", dfab_bam_dmux_clk.c, "BAM_RMNT"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005508
5509 CLK_LOOKUP("ebi1_msmbus_clk", ebi1_msmbus_clk.c, NULL),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005510 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005511
5512 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5513 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5514 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
Stephen Boyd3939c8d2011-08-29 17:36:22 -07005515 CLK_LOOKUP("q6sw_clk", q6sw_clk, NULL),
5516 CLK_LOOKUP("q6fw_clk", q6fw_clk, NULL),
5517 CLK_LOOKUP("q6_func_clk", q6_func_clk, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005518};
5519
Stephen Boyd94625ef2011-07-12 17:06:01 -07005520static struct clk_lookup msm_clocks_8960_v2[] __initdata = {
5521 CLK_LOOKUP("cam_clk", cam2_clk.c, NULL),
5522 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
5523 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
Kevin Chane12c6672011-10-26 11:55:26 -07005524 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, "msm_ispif.0"),
5525 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, "msm_ispif.0"),
5526 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, "msm_ispif.0"),
Stephen Boyd94625ef2011-07-12 17:06:01 -07005527 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
5528 CLK_LOOKUP("csi2phy_timer_clk", csi2phy_timer_clk.c, NULL),
5529 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5530 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5531 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5532 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5533 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5534};
5535
5536/* Add v2 clocks dynamically at runtime */
5537static struct clk_lookup msm_clocks_8960[ARRAY_SIZE(msm_clocks_8960_v1) +
5538 ARRAY_SIZE(msm_clocks_8960_v2)];
5539
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005540/*
5541 * Miscellaneous clock register initializations
5542 */
5543
5544/* Read, modify, then write-back a register. */
5545static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
5546{
5547 uint32_t regval = readl_relaxed(reg);
5548 regval &= ~mask;
5549 regval |= val;
5550 writel_relaxed(regval, reg);
5551}
5552
Tianyi Gou41515e22011-09-01 19:37:43 -07005553static void __init set_fsm_mode(void __iomem *mode_reg)
5554{
5555 u32 regval = readl_relaxed(mode_reg);
5556
5557 /*De-assert reset to FSM */
5558 regval &= ~BIT(21);
5559 writel_relaxed(regval, mode_reg);
5560
5561 /* Program bias count */
Tianyi Gou358c3862011-10-18 17:03:41 -07005562 regval &= ~BM(19, 14);
5563 regval |= BVAL(19, 14, 0x1);
5564 writel_relaxed(regval, mode_reg);
5565
5566 /* Program lock count */
Tianyi Gou41515e22011-09-01 19:37:43 -07005567 regval &= ~BM(13, 8);
5568 regval |= BVAL(13, 8, 0x8);
5569 writel_relaxed(regval, mode_reg);
5570
5571 /*Enable PLL FSM voting */
5572 regval |= BIT(20);
5573 writel_relaxed(regval, mode_reg);
5574}
5575
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005576static void __init reg_init(void)
5577{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005578 /* Deassert MM SW_RESET_ALL signal. */
5579 writel_relaxed(0, SW_RESET_ALL_REG);
5580
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005581 /*
5582 * Some bits are only used on either 8960 or 8064 and are marked as
5583 * reserved bits on the other SoC. Writing to these reserved bits
5584 * should have no effect.
5585 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005586 /* Initialize MM AHB registers: Enable the FPB clock and disable HW
5587 * gating for all clocks. Also set VFE_AHB's FORCE_CORE_ON bit to
5588 * prevent its memory from being collapsed when the clock is halted.
5589 * The sleep and wake-up delays are set to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005590 rmwreg(0x00000003, AHB_EN_REG, 0x6C000103);
5591 writel_relaxed(0x000007F9, AHB_EN2_REG);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005592 if (cpu_is_apq8064())
5593 rmwreg(0x00000000, AHB_EN3_REG, 0x00000001);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005594
5595 /* Deassert all locally-owned MM AHB resets. */
5596 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
Tianyi Gou41515e22011-09-01 19:37:43 -07005597 rmwreg(0, SW_RESET_AHB2_REG, 0x0000000F);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005598
5599 /* Initialize MM AXI registers: Enable HW gating for all clocks that
5600 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
5601 * delays to safe values. */
5602 /* TODO: Enable HW Gating */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005603 rmwreg(0x000007F9, MAXI_EN_REG, 0x0803FFFF);
5604 rmwreg(0x3027FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
5605 rmwreg(0x0027FCFF, MAXI_EN3_REG, 0x003FFFFF);
5606 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005607 if (cpu_is_apq8064())
5608 rmwreg(0x009FE4FF, MAXI_EN5_REG, 0x01FFEFFF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005609 rmwreg(0x000003C7, SAXI_EN_REG, 0x00003FFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005610
5611 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
5612 * memories retain state even when not clocked. Also, set sleep and
5613 * wake-up delays to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005614 rmwreg(0x00000000, CSI0_CC_REG, 0x00000410);
5615 rmwreg(0x00000000, CSI1_CC_REG, 0x00000410);
5616 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, 0xE0FF0010);
5617 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, 0xE0FF0010);
5618 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, 0xE0FF0010);
5619 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005620 rmwreg(0x80FF0000, GFX3D_CC_REG, 0xE0FF0010);
5621 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0010);
5622 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0010);
5623 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
5624 rmwreg(0x80FF0000, MDP_LUT_CC_REG, 0xE0FF0010);
5625 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005626 rmwreg(0x000004FF, TV_CC2_REG, 0x000007FF);
5627 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
5628 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FF4010);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005629 rmwreg(0x800000FF, VFE_CC2_REG, 0xE00000FF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005630 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005631 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005632 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
5633 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
5634 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
5635 }
5636 if (cpu_is_apq8064()) {
5637 rmwreg(0x00000000, TV_CC_REG, 0x00004010);
Tianyi Gou621f8742011-09-01 21:45:01 -07005638 rmwreg(0x80FF0000, VCAP_CC_REG, 0xE0FF1010);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005639 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005640
Tianyi Gou41515e22011-09-01 19:37:43 -07005641 /*
5642 * Initialize USB_HS_HCLK_FS registers: Set FORCE_C_ON bits so that
5643 * core remain active during halt state of the clk. Also, set sleep
5644 * and wake-up value to max.
5645 */
5646 rmwreg(0x0000004F, USB_HS1_HCLK_FS_REG, 0x0000007F);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005647 if (cpu_is_apq8064()) {
5648 rmwreg(0x0000004F, USB_HS3_HCLK_FS_REG, 0x0000007F);
5649 rmwreg(0x0000004F, USB_HS4_HCLK_FS_REG, 0x0000007F);
5650 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005651
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005652 /* De-assert MM AXI resets to all hardware blocks. */
5653 writel_relaxed(0, SW_RESET_AXI_REG);
5654
5655 /* Deassert all MM core resets. */
5656 writel_relaxed(0, SW_RESET_CORE_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005657 writel_relaxed(0, SW_RESET_CORE2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005658
5659 /* Reset 3D core once more, with its clock enabled. This can
5660 * eventually be done as part of the GDFS footswitch driver. */
5661 clk_set_rate(&gfx3d_clk.c, 27000000);
5662 clk_enable(&gfx3d_clk.c);
5663 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
5664 mb();
5665 udelay(5);
5666 writel_relaxed(0, SW_RESET_CORE_REG);
5667 /* Make sure reset is de-asserted before clock is disabled. */
5668 mb();
5669 clk_disable(&gfx3d_clk.c);
5670
5671 /* Enable TSSC and PDM PXO sources. */
5672 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
5673 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
5674
5675 /* Source SLIMBus xo src from slimbus reference clock */
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005676 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005677 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005678
5679 /* Source the dsi_byte_clks from the DSI PHY PLLs */
5680 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
5681 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
Tianyi Gou41515e22011-09-01 19:37:43 -07005682
5683 /* Source the sata_phy_ref_clk from PXO */
5684 if (cpu_is_apq8064())
5685 rmwreg(0, SATA_PHY_REF_CLK_CTL_REG, 0x1);
5686
5687 /*
5688 * TODO: Programming below PLLs is temporary and needs to be removed
5689 * after bootloaders program them.
5690 */
5691 if (cpu_is_apq8064()) {
5692 u32 regval, is_pll_enabled;
5693
5694 /* Program pxo_src_clk to source from PXO */
5695 rmwreg(0x1, PXO_SRC_CLK_CTL_REG, 0x7);
5696
5697 /* Check if PLL8 is active */
5698 is_pll_enabled = readl_relaxed(BB_PLL8_STATUS_REG) & BIT(16);
5699 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005700 /* Ref clk = 27MHz and program pll8 to 384MHz */
5701 writel_relaxed(0xE, BB_PLL8_L_VAL_REG);
5702 writel_relaxed(0x2, BB_PLL8_M_VAL_REG);
5703 writel_relaxed(0x9, BB_PLL8_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005704
5705 regval = readl_relaxed(BB_PLL8_CONFIG_REG);
5706
5707 /* Enable the main output and the MN accumulator */
5708 regval |= BIT(23) | BIT(22);
5709
5710 /* Set pre-divider and post-divider values to 1 and 1 */
5711 regval &= ~BIT(19);
5712 regval &= ~BM(21, 20);
5713
5714 writel_relaxed(regval, BB_PLL8_CONFIG_REG);
5715
5716 /* Set VCO frequency */
5717 rmwreg(0x10000, BB_PLL8_CONFIG_REG, 0x30000);
5718
5719 /* Enable AUX output */
5720 regval = readl_relaxed(BB_PLL8_TEST_CTL_REG);
5721 regval |= BIT(12);
5722 writel_relaxed(regval, BB_PLL8_TEST_CTL_REG);
5723
5724 set_fsm_mode(BB_PLL8_MODE_REG);
5725 }
5726 /* Check if PLL3 is active */
5727 is_pll_enabled = readl_relaxed(GPLL1_STATUS_REG) & BIT(16);
5728 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005729 /* Ref clk = 27MHz and program pll3 to 1200MHz */
5730 writel_relaxed(0x2C, GPLL1_L_VAL_REG);
5731 writel_relaxed(0x4, GPLL1_M_VAL_REG);
5732 writel_relaxed(0x9, GPLL1_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005733
5734 regval = readl_relaxed(GPLL1_CONFIG_REG);
5735
5736 /* Set pre-divider and post-divider values to 1 and 1 */
5737 regval &= ~BIT(15);
5738 regval |= BIT(16);
5739
5740 writel_relaxed(regval, GPLL1_CONFIG_REG);
5741
5742 /* Set VCO frequency */
5743 rmwreg(0x180, GPLL1_CONFIG_REG, 0x180);
5744 }
5745 /* Check if PLL14 is active */
5746 is_pll_enabled = readl_relaxed(BB_PLL14_STATUS_REG) & BIT(16);
5747 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005748 /* Ref clk = 27MHz and program pll14 to 480MHz */
5749 writel_relaxed(0x11, BB_PLL14_L_VAL_REG);
5750 writel_relaxed(0x7, BB_PLL14_M_VAL_REG);
5751 writel_relaxed(0x9, BB_PLL14_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005752
5753 regval = readl_relaxed(BB_PLL14_CONFIG_REG);
5754
5755 /* Enable the main output and the MN accumulator */
5756 regval |= BIT(23) | BIT(22);
5757
5758 /* Set pre-divider and post-divider values to 1 and 1 */
5759 regval &= ~BIT(19);
5760 regval &= ~BM(21, 20);
5761
5762 writel_relaxed(regval, BB_PLL14_CONFIG_REG);
5763
5764 /* Set VCO frequency */
5765 rmwreg(0x10000, BB_PLL14_CONFIG_REG, 0x30000);
5766
Tianyi Gou41515e22011-09-01 19:37:43 -07005767 set_fsm_mode(BB_PLL14_MODE_REG);
5768 }
Tianyi Gou621f8742011-09-01 21:45:01 -07005769 /* Program PLL2 to 800MHz with ref clk = 27MHz */
5770 writel_relaxed(0x1D, MM_PLL1_L_VAL_REG);
5771 writel_relaxed(0x11, MM_PLL1_M_VAL_REG);
5772 writel_relaxed(0x1B, MM_PLL1_N_VAL_REG);
5773
5774 regval = readl_relaxed(MM_PLL1_CONFIG_REG);
5775
5776 /* Enable the main output and the MN accumulator */
5777 regval |= BIT(23) | BIT(22);
5778
5779 /* Set pre-divider and post-divider values to 1 and 1 */
5780 regval &= ~BIT(19);
5781 regval &= ~BM(21, 20);
5782
5783 writel_relaxed(regval, MM_PLL1_CONFIG_REG);
5784
5785 /* Set VCO frequency */
5786 rmwreg(0x20000, MM_PLL1_CONFIG_REG, 0x30000);
5787
Tianyi Gou621f8742011-09-01 21:45:01 -07005788 /* Program PLL15 to 975MHz with ref clk = 27MHz */
5789 writel_relaxed(0x24, MM_PLL3_L_VAL_REG);
5790 writel_relaxed(0x1, MM_PLL3_M_VAL_REG);
5791 writel_relaxed(0x9, MM_PLL3_N_VAL_REG);
5792
5793 regval = readl_relaxed(MM_PLL3_CONFIG_REG);
5794
5795 /* Enable the main output and the MN accumulator */
5796 regval |= BIT(23) | BIT(22);
5797
5798 /* Set pre-divider and post-divider values to 1 and 1 */
5799 regval &= ~BIT(19);
5800 regval &= ~BM(21, 20);
5801
5802 writel_relaxed(regval, MM_PLL3_CONFIG_REG);
5803
5804 /* Set VCO frequency */
5805 rmwreg(0x20000, MM_PLL3_CONFIG_REG, 0x30000);
5806
5807 /* Enable AUX output */
5808 regval = readl_relaxed(MM_PLL3_TEST_CTL_REG);
5809 regval |= BIT(12);
5810 writel_relaxed(regval, MM_PLL3_TEST_CTL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005811
5812 /* Check if PLL4 is active */
5813 is_pll_enabled = readl_relaxed(LCC_PLL0_STATUS_REG) & BIT(16);
5814 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005815 /* Ref clk = 27MHz and program pll4 to 393.2160MHz */
5816 writel_relaxed(0xE, LCC_PLL0_L_VAL_REG);
5817 writel_relaxed(0x27A, LCC_PLL0_M_VAL_REG);
5818 writel_relaxed(0x465, LCC_PLL0_N_VAL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005819
5820 regval = readl_relaxed(LCC_PLL0_CONFIG_REG);
5821
5822 /* Enable the main output and the MN accumulator */
5823 regval |= BIT(23) | BIT(22);
5824
5825 /* Set pre-divider and post-divider values to 1 and 1 */
5826 regval &= ~BIT(19);
5827 regval &= ~BM(21, 20);
5828
5829 /* Set VCO frequency */
5830 regval &= ~BM(17, 16);
5831 writel_relaxed(regval, LCC_PLL0_CONFIG_REG);
5832
5833 set_fsm_mode(LCC_PLL0_MODE_REG);
5834 }
5835
5836 /* Enable PLL4 source on the LPASS Primary PLL Mux */
5837 writel_relaxed(0x1, LCC_PRI_PLL_CLK_CTL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005838 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005839}
5840
Stephen Boyd94625ef2011-07-12 17:06:01 -07005841struct clock_init_data msm8960_clock_init_data __initdata;
5842
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005843/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07005844static void __init msm8960_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005845{
Stephen Boyd94625ef2011-07-12 17:06:01 -07005846 size_t num_lookups = ARRAY_SIZE(msm_clocks_8960_v1);
Tianyi Gou41515e22011-09-01 19:37:43 -07005847
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005848 xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8960");
5849 if (IS_ERR(xo_pxo)) {
5850 pr_err("%s: msm_xo_get(PXO) failed.\n", __func__);
5851 BUG();
5852 }
5853 xo_cxo = msm_xo_get(MSM_XO_TCXO_D0, "clock-8960");
5854 if (IS_ERR(xo_cxo)) {
5855 pr_err("%s: msm_xo_get(CXO) failed.\n", __func__);
5856 BUG();
5857 }
5858
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005859 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou41515e22011-09-01 19:37:43 -07005860 memcpy(msm_clocks_8960, msm_clocks_8960_v1,
5861 sizeof(msm_clocks_8960_v1));
5862 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5863 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8960_v2;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005864
5865 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8960_v2,
5866 sizeof(gfx3d_clk.c.fmax));
5867 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8960_v2,
5868 sizeof(ijpeg_clk.c.fmax));
5869 memcpy(vfe_clk.c.fmax, fmax_vfe_8960_v2,
5870 sizeof(vfe_clk.c.fmax));
5871
Tianyi Gou41515e22011-09-01 19:37:43 -07005872 memcpy(msm_clocks_8960 + ARRAY_SIZE(msm_clocks_8960_v1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07005873 msm_clocks_8960_v2, sizeof(msm_clocks_8960_v2));
Tianyi Gou41515e22011-09-01 19:37:43 -07005874 num_lookups = ARRAY_SIZE(msm_clocks_8960);
5875 }
5876 msm8960_clock_init_data.size = num_lookups;
Stephen Boyd94625ef2011-07-12 17:06:01 -07005877 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005878
5879 /*
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005880 * Change the freq tables for and voltage requirements for
5881 * clocks which differ between 8960 and 8064.
Tianyi Gou41515e22011-09-01 19:37:43 -07005882 */
5883 if (cpu_is_apq8064()) {
5884 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8064;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005885
5886 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8064,
5887 sizeof(gfx3d_clk.c.fmax));
5888 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8064,
5889 sizeof(ijpeg_clk.c.fmax));
5890 memcpy(mdp_clk.c.fmax, fmax_mdp_8064,
5891 sizeof(ijpeg_clk.c.fmax));
5892 memcpy(tv_src_clk.c.fmax, fmax_tv_src_8064,
5893 sizeof(tv_src_clk.c.fmax));
5894 memcpy(vfe_clk.c.fmax, fmax_vfe_8064,
5895 sizeof(vfe_clk.c.fmax));
5896
Tianyi Gou621f8742011-09-01 21:45:01 -07005897 gmem_axi_clk.c.depends = &gfx3d_axi_clk.c;
Tianyi Gou41515e22011-09-01 19:37:43 -07005898 }
Stephen Boyd94625ef2011-07-12 17:06:01 -07005899
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005900 vote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005901
Vikram Mulukutla489e39e2011-08-31 18:04:05 -07005902 clk_ops_pll.enable = sr_pll_clk_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005903
5904 /* Initialize clock registers. */
5905 reg_init();
5906
5907 /* Initialize rates for clocks that only support one. */
5908 clk_set_rate(&pdm_clk.c, 27000000);
5909 clk_set_rate(&prng_clk.c, 64000000);
5910 clk_set_rate(&mdp_vsync_clk.c, 27000000);
5911 clk_set_rate(&tsif_ref_clk.c, 105000);
5912 clk_set_rate(&tssc_clk.c, 27000000);
5913 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
Tianyi Gou41515e22011-09-01 19:37:43 -07005914 if (cpu_is_apq8064()) {
5915 clk_set_rate(&usb_hs3_xcvr_clk.c, 60000000);
5916 clk_set_rate(&usb_hs4_xcvr_clk.c, 60000000);
5917 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005918 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005919 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou41515e22011-09-01 19:37:43 -07005920 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005921 clk_set_rate(&usb_hsic_xcvr_fs_clk.c, 60000000);
5922 clk_set_rate(&usb_hsic_hsic_src_clk.c, 480000000);
5923 clk_set_rate(&usb_hsic_hsio_cal_clk.c, 9000000);
Stephen Boyd092fd182011-10-21 15:56:30 -07005924 /*
5925 * Set the CSI rates to a safe default to avoid warnings when
5926 * switching csi pix and rdi clocks.
5927 */
5928 clk_set_rate(&csi0_src_clk.c, 27000000);
5929 clk_set_rate(&csi1_src_clk.c, 27000000);
5930 clk_set_rate(&csi2_src_clk.c, 27000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005931
5932 /*
Stephen Boyd60496bb2011-10-17 13:51:37 -07005933 * The halt status bits for these clocks may be incorrect at boot.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005934 * Toggle these clocks on and off to refresh them.
5935 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07005936 rcg_clk_enable(&pdm_clk.c);
5937 rcg_clk_disable(&pdm_clk.c);
5938 rcg_clk_enable(&tssc_clk.c);
5939 rcg_clk_disable(&tssc_clk.c);
Stephen Boyd60496bb2011-10-17 13:51:37 -07005940 if (cpu_is_msm8960() &&
5941 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5942 clk_enable(&usb_hsic_hsic_clk.c);
5943 clk_disable(&usb_hsic_hsic_clk.c);
Stephen Boyd092fd182011-10-21 15:56:30 -07005944 } else
5945 /* CSI2 hardware not present on 8960v1 devices */
5946 pix_rdi_mux_map[2] = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005947
5948 if (machine_is_msm8960_sim()) {
5949 clk_set_rate(&sdc1_clk.c, 48000000);
5950 clk_enable(&sdc1_clk.c);
5951 clk_enable(&sdc1_p_clk.c);
5952 clk_set_rate(&sdc3_clk.c, 48000000);
5953 clk_enable(&sdc3_clk.c);
5954 clk_enable(&sdc3_p_clk.c);
5955 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005956}
5957
Stephen Boydbb600ae2011-08-02 20:11:40 -07005958static int __init msm8960_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005959{
Stephen Boyda3787f32011-09-16 18:55:13 -07005960 int rc;
5961 struct clk *mmfpb_a_clk = clk_get_sys("clock-8960", "mmfpb_a_clk");
Stephen Boyd85436132011-09-16 18:55:13 -07005962 struct clk *cfpb_a_clk = clk_get_sys("clock-8960", "cfpb_a_clk");
Stephen Boyda3787f32011-09-16 18:55:13 -07005963
5964 /* Vote for MMFPB to be at least 76.8MHz when an Apps CPU is active. */
5965 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
5966 PTR_ERR(mmfpb_a_clk)))
5967 return PTR_ERR(mmfpb_a_clk);
5968 rc = clk_set_min_rate(mmfpb_a_clk, 76800000);
5969 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
5970 return rc;
5971 rc = clk_enable(mmfpb_a_clk);
5972 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
5973 return rc;
5974
Stephen Boyd85436132011-09-16 18:55:13 -07005975 /* Vote for CFPB to be at least 64MHz when an Apps CPU is active. */
5976 if (WARN(IS_ERR(cfpb_a_clk), "cfpb_a_clk not found (%ld)\n",
5977 PTR_ERR(cfpb_a_clk)))
5978 return PTR_ERR(cfpb_a_clk);
5979 rc = clk_set_min_rate(cfpb_a_clk, 64000000);
5980 if (WARN(rc, "cfpb_a_clk rate was not set (%d)\n", rc))
5981 return rc;
5982 rc = clk_enable(cfpb_a_clk);
5983 if (WARN(rc, "cfpb_a_clk not enabled (%d)\n", rc))
5984 return rc;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005985
5986 return unvote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005987}
Stephen Boydbb600ae2011-08-02 20:11:40 -07005988
5989struct clock_init_data msm8960_clock_init_data __initdata = {
5990 .table = msm_clocks_8960,
5991 .size = ARRAY_SIZE(msm_clocks_8960),
5992 .init = msm8960_clock_init,
5993 .late_init = msm8960_clock_late_init,
5994};
Tianyi Gou41515e22011-09-01 19:37:43 -07005995
5996struct clock_init_data apq8064_clock_init_data __initdata = {
5997 .table = msm_clocks_8064,
5998 .size = ARRAY_SIZE(msm_clocks_8064),
5999 .init = msm8960_clock_init,
6000 .late_init = msm8960_clock_late_init,
6001};