blob: 4ce0cf6358e47607a142e41dfb9c1823966a58e0 [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
429/*
430 * Clock Descriptions
431 */
432
433static struct msm_xo_voter *xo_pxo, *xo_cxo;
434
435static int pxo_clk_enable(struct clk *clk)
436{
437 return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON);
438}
439
440static void pxo_clk_disable(struct clk *clk)
441{
Tianyi Gou41515e22011-09-01 19:37:43 -0700442 msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700443}
444
445static struct clk_ops clk_ops_pxo = {
446 .enable = pxo_clk_enable,
447 .disable = pxo_clk_disable,
448 .get_rate = fixed_clk_get_rate,
449 .is_local = local_clk_is_local,
450};
451
452static struct fixed_clk pxo_clk = {
453 .rate = 27000000,
454 .c = {
455 .dbg_name = "pxo_clk",
456 .ops = &clk_ops_pxo,
457 CLK_INIT(pxo_clk.c),
458 },
459};
460
461static int cxo_clk_enable(struct clk *clk)
462{
463 return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON);
464}
465
466static void cxo_clk_disable(struct clk *clk)
467{
468 msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF);
469}
470
471static struct clk_ops clk_ops_cxo = {
472 .enable = cxo_clk_enable,
473 .disable = cxo_clk_disable,
474 .get_rate = fixed_clk_get_rate,
475 .is_local = local_clk_is_local,
476};
477
478static struct fixed_clk cxo_clk = {
479 .rate = 19200000,
480 .c = {
481 .dbg_name = "cxo_clk",
482 .ops = &clk_ops_cxo,
483 CLK_INIT(cxo_clk.c),
484 },
485};
486
487static struct pll_clk pll2_clk = {
488 .rate = 800000000,
489 .mode_reg = MM_PLL1_MODE_REG,
490 .parent = &pxo_clk.c,
491 .c = {
492 .dbg_name = "pll2_clk",
493 .ops = &clk_ops_pll,
494 CLK_INIT(pll2_clk.c),
495 },
496};
497
Stephen Boyd94625ef2011-07-12 17:06:01 -0700498static struct pll_clk pll3_clk = {
499 .rate = 1200000000,
500 .mode_reg = BB_MMCC_PLL2_MODE_REG,
501 .parent = &pxo_clk.c,
502 .c = {
503 .dbg_name = "pll3_clk",
504 .ops = &clk_ops_pll,
505 CLK_INIT(pll3_clk.c),
506 },
507};
508
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700509static struct pll_vote_clk pll4_clk = {
510 .rate = 393216000,
511 .en_reg = BB_PLL_ENA_SC0_REG,
512 .en_mask = BIT(4),
513 .status_reg = LCC_PLL0_STATUS_REG,
514 .parent = &pxo_clk.c,
515 .c = {
516 .dbg_name = "pll4_clk",
517 .ops = &clk_ops_pll_vote,
518 CLK_INIT(pll4_clk.c),
519 },
520};
521
522static struct pll_vote_clk pll8_clk = {
523 .rate = 384000000,
524 .en_reg = BB_PLL_ENA_SC0_REG,
525 .en_mask = BIT(8),
526 .status_reg = BB_PLL8_STATUS_REG,
527 .parent = &pxo_clk.c,
528 .c = {
529 .dbg_name = "pll8_clk",
530 .ops = &clk_ops_pll_vote,
531 CLK_INIT(pll8_clk.c),
532 },
533};
534
Stephen Boyd94625ef2011-07-12 17:06:01 -0700535static struct pll_vote_clk pll14_clk = {
536 .rate = 480000000,
537 .en_reg = BB_PLL_ENA_SC0_REG,
538 .en_mask = BIT(14),
539 .status_reg = BB_PLL14_STATUS_REG,
540 .parent = &pxo_clk.c,
541 .c = {
542 .dbg_name = "pll14_clk",
543 .ops = &clk_ops_pll_vote,
544 CLK_INIT(pll14_clk.c),
545 },
546};
547
Tianyi Gou41515e22011-09-01 19:37:43 -0700548static struct pll_clk pll15_clk = {
549 .rate = 975000000,
550 .mode_reg = MM_PLL3_MODE_REG,
551 .parent = &pxo_clk.c,
552 .c = {
553 .dbg_name = "pll15_clk",
554 .ops = &clk_ops_pll,
555 CLK_INIT(pll15_clk.c),
556 },
557};
558
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700559/*
560 * SoC-specific functions required by clock-local driver
561 */
562
563/* Update the sys_vdd voltage given a level. */
564static int msm8960_update_sys_vdd(enum sys_vdd_level level)
565{
566 static const int vdd_uv[] = {
Matt Wagantallb6f30f02011-09-07 16:48:56 -0700567 [NONE] = 0,
568 [LOW] = 945000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700569 [NOMINAL] = 1050000,
570 [HIGH] = 1150000,
571 };
572
573 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
574 vdd_uv[level], vdd_uv[HIGH], 1);
575}
576
577static int soc_clk_reset(struct clk *clk, enum clk_reset_action action)
578{
579 return branch_reset(&to_rcg_clk(clk)->b, action);
580}
581
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700582static struct clk_ops clk_ops_rcg_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700583 .enable = rcg_clk_enable,
584 .disable = rcg_clk_disable,
585 .auto_off = rcg_clk_auto_off,
Matt Wagantall53d968f2011-07-19 13:22:53 -0700586 .handoff = rcg_clk_handoff,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700587 .set_rate = rcg_clk_set_rate,
588 .set_min_rate = rcg_clk_set_min_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700589 .get_rate = rcg_clk_get_rate,
590 .list_rate = rcg_clk_list_rate,
591 .is_enabled = rcg_clk_is_enabled,
592 .round_rate = rcg_clk_round_rate,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700593 .reset = soc_clk_reset,
594 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700595 .get_parent = rcg_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700596};
597
598static struct clk_ops clk_ops_branch = {
599 .enable = branch_clk_enable,
600 .disable = branch_clk_disable,
601 .auto_off = branch_clk_auto_off,
602 .is_enabled = branch_clk_is_enabled,
603 .reset = branch_clk_reset,
604 .is_local = local_clk_is_local,
605 .get_parent = branch_clk_get_parent,
606 .set_parent = branch_clk_set_parent,
607};
608
609static struct clk_ops clk_ops_reset = {
610 .reset = branch_clk_reset,
611 .is_local = local_clk_is_local,
612};
613
614/* AXI Interfaces */
615static struct branch_clk gmem_axi_clk = {
616 .b = {
617 .ctl_reg = MAXI_EN_REG,
618 .en_mask = BIT(24),
619 .halt_reg = DBG_BUS_VEC_E_REG,
620 .halt_bit = 6,
621 },
622 .c = {
623 .dbg_name = "gmem_axi_clk",
624 .ops = &clk_ops_branch,
625 CLK_INIT(gmem_axi_clk.c),
626 },
627};
628
629static struct branch_clk ijpeg_axi_clk = {
630 .b = {
631 .ctl_reg = MAXI_EN_REG,
632 .en_mask = BIT(21),
633 .reset_reg = SW_RESET_AXI_REG,
634 .reset_mask = BIT(14),
635 .halt_reg = DBG_BUS_VEC_E_REG,
636 .halt_bit = 4,
637 },
638 .c = {
639 .dbg_name = "ijpeg_axi_clk",
640 .ops = &clk_ops_branch,
641 CLK_INIT(ijpeg_axi_clk.c),
642 },
643};
644
645static struct branch_clk imem_axi_clk = {
646 .b = {
647 .ctl_reg = MAXI_EN_REG,
648 .en_mask = BIT(22),
649 .reset_reg = SW_RESET_CORE_REG,
650 .reset_mask = BIT(10),
651 .halt_reg = DBG_BUS_VEC_E_REG,
652 .halt_bit = 7,
653 },
654 .c = {
655 .dbg_name = "imem_axi_clk",
656 .ops = &clk_ops_branch,
657 CLK_INIT(imem_axi_clk.c),
658 },
659};
660
661static struct branch_clk jpegd_axi_clk = {
662 .b = {
663 .ctl_reg = MAXI_EN_REG,
664 .en_mask = BIT(25),
665 .halt_reg = DBG_BUS_VEC_E_REG,
666 .halt_bit = 5,
667 },
668 .c = {
669 .dbg_name = "jpegd_axi_clk",
670 .ops = &clk_ops_branch,
671 CLK_INIT(jpegd_axi_clk.c),
672 },
673};
674
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700675static struct branch_clk vcodec_axi_b_clk = {
676 .b = {
677 .ctl_reg = MAXI_EN4_REG,
678 .en_mask = BIT(23),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700679 .halt_reg = DBG_BUS_VEC_I_REG,
680 .halt_bit = 25,
681 },
682 .c = {
683 .dbg_name = "vcodec_axi_b_clk",
684 .ops = &clk_ops_branch,
685 CLK_INIT(vcodec_axi_b_clk.c),
686 },
687};
688
Matt Wagantall91f42702011-07-14 12:01:15 -0700689static struct branch_clk vcodec_axi_a_clk = {
690 .b = {
691 .ctl_reg = MAXI_EN4_REG,
692 .en_mask = BIT(25),
Matt Wagantall91f42702011-07-14 12:01:15 -0700693 .halt_reg = DBG_BUS_VEC_I_REG,
694 .halt_bit = 26,
695 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700696 .c = {
697 .dbg_name = "vcodec_axi_a_clk",
698 .ops = &clk_ops_branch,
699 CLK_INIT(vcodec_axi_a_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700700 .depends = &vcodec_axi_b_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700701 },
702};
703
704static struct branch_clk vcodec_axi_clk = {
705 .b = {
706 .ctl_reg = MAXI_EN_REG,
707 .en_mask = BIT(19),
708 .reset_reg = SW_RESET_AXI_REG,
Matt Wagantallfe2ee052011-07-14 13:33:44 -0700709 .reset_mask = BIT(4)|BIT(5)|BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700710 .halt_reg = DBG_BUS_VEC_E_REG,
711 .halt_bit = 3,
712 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700713 .c = {
714 .dbg_name = "vcodec_axi_clk",
715 .ops = &clk_ops_branch,
716 CLK_INIT(vcodec_axi_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700717 .depends = &vcodec_axi_a_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700718 },
719};
720
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700721static struct branch_clk vfe_axi_clk = {
722 .b = {
723 .ctl_reg = MAXI_EN_REG,
724 .en_mask = BIT(18),
725 .reset_reg = SW_RESET_AXI_REG,
726 .reset_mask = BIT(9),
727 .halt_reg = DBG_BUS_VEC_E_REG,
728 .halt_bit = 0,
729 },
730 .c = {
731 .dbg_name = "vfe_axi_clk",
732 .ops = &clk_ops_branch,
733 CLK_INIT(vfe_axi_clk.c),
734 },
735};
736
737static struct branch_clk mdp_axi_clk = {
738 .b = {
739 .ctl_reg = MAXI_EN_REG,
740 .en_mask = BIT(23),
741 .reset_reg = SW_RESET_AXI_REG,
742 .reset_mask = BIT(13),
743 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700744 .halt_bit = 8,
745 },
746 .c = {
747 .dbg_name = "mdp_axi_clk",
748 .ops = &clk_ops_branch,
749 CLK_INIT(mdp_axi_clk.c),
750 },
751};
752
753static struct branch_clk rot_axi_clk = {
754 .b = {
755 .ctl_reg = MAXI_EN2_REG,
756 .en_mask = BIT(24),
757 .reset_reg = SW_RESET_AXI_REG,
758 .reset_mask = BIT(6),
759 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700760 .halt_bit = 2,
761 },
762 .c = {
763 .dbg_name = "rot_axi_clk",
764 .ops = &clk_ops_branch,
765 CLK_INIT(rot_axi_clk.c),
766 },
767};
768
769static struct branch_clk vpe_axi_clk = {
770 .b = {
771 .ctl_reg = MAXI_EN2_REG,
772 .en_mask = BIT(26),
773 .reset_reg = SW_RESET_AXI_REG,
774 .reset_mask = BIT(15),
775 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700776 .halt_bit = 1,
777 },
778 .c = {
779 .dbg_name = "vpe_axi_clk",
780 .ops = &clk_ops_branch,
781 CLK_INIT(vpe_axi_clk.c),
782 },
783};
784
Tianyi Gou41515e22011-09-01 19:37:43 -0700785static struct branch_clk vcap_axi_clk = {
786 .b = {
787 .ctl_reg = MAXI_EN5_REG,
788 .en_mask = BIT(12),
789 .reset_reg = SW_RESET_AXI_REG,
790 .reset_mask = BIT(16),
791 .halt_reg = DBG_BUS_VEC_J_REG,
792 .halt_bit = 20,
793 },
794 .c = {
795 .dbg_name = "vcap_axi_clk",
796 .ops = &clk_ops_branch,
797 CLK_INIT(vcap_axi_clk.c),
798 },
799};
800
Tianyi Gou621f8742011-09-01 21:45:01 -0700801/* For 8064, gfx3d_axi_clk is set as a dependency of gmem_axi_clk at runtime */
802static struct branch_clk gfx3d_axi_clk = {
803 .b = {
804 .ctl_reg = MAXI_EN5_REG,
805 .en_mask = BIT(25),
806 .reset_reg = SW_RESET_AXI_REG,
807 .reset_mask = BIT(17),
808 .halt_reg = DBG_BUS_VEC_J_REG,
809 .halt_bit = 30,
810 },
811 .c = {
812 .dbg_name = "gfx3d_axi_clk",
813 .ops = &clk_ops_branch,
814 CLK_INIT(gfx3d_axi_clk.c),
815 },
816};
817
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700818/* AHB Interfaces */
819static struct branch_clk amp_p_clk = {
820 .b = {
821 .ctl_reg = AHB_EN_REG,
822 .en_mask = BIT(24),
823 .halt_reg = DBG_BUS_VEC_F_REG,
824 .halt_bit = 18,
825 },
826 .c = {
827 .dbg_name = "amp_p_clk",
828 .ops = &clk_ops_branch,
829 CLK_INIT(amp_p_clk.c),
830 },
831};
832
Matt Wagantallc23eee92011-08-16 23:06:52 -0700833static struct branch_clk csi_p_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700834 .b = {
835 .ctl_reg = AHB_EN_REG,
836 .en_mask = BIT(7),
837 .reset_reg = SW_RESET_AHB_REG,
838 .reset_mask = BIT(17),
839 .halt_reg = DBG_BUS_VEC_F_REG,
840 .halt_bit = 16,
841 },
842 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -0700843 .dbg_name = "csi_p_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700844 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -0700845 CLK_INIT(csi_p_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700846 },
847};
848
849static struct branch_clk dsi1_m_p_clk = {
850 .b = {
851 .ctl_reg = AHB_EN_REG,
852 .en_mask = BIT(9),
853 .reset_reg = SW_RESET_AHB_REG,
854 .reset_mask = BIT(6),
855 .halt_reg = DBG_BUS_VEC_F_REG,
856 .halt_bit = 19,
857 },
858 .c = {
859 .dbg_name = "dsi1_m_p_clk",
860 .ops = &clk_ops_branch,
861 CLK_INIT(dsi1_m_p_clk.c),
862 },
863};
864
865static struct branch_clk dsi1_s_p_clk = {
866 .b = {
867 .ctl_reg = AHB_EN_REG,
868 .en_mask = BIT(18),
869 .reset_reg = SW_RESET_AHB_REG,
870 .reset_mask = BIT(5),
871 .halt_reg = DBG_BUS_VEC_F_REG,
872 .halt_bit = 21,
873 },
874 .c = {
875 .dbg_name = "dsi1_s_p_clk",
876 .ops = &clk_ops_branch,
877 CLK_INIT(dsi1_s_p_clk.c),
878 },
879};
880
881static struct branch_clk dsi2_m_p_clk = {
882 .b = {
883 .ctl_reg = AHB_EN_REG,
884 .en_mask = BIT(17),
885 .reset_reg = SW_RESET_AHB2_REG,
886 .reset_mask = BIT(1),
887 .halt_reg = DBG_BUS_VEC_E_REG,
888 .halt_bit = 18,
889 },
890 .c = {
891 .dbg_name = "dsi2_m_p_clk",
892 .ops = &clk_ops_branch,
893 CLK_INIT(dsi2_m_p_clk.c),
894 },
895};
896
897static struct branch_clk dsi2_s_p_clk = {
898 .b = {
899 .ctl_reg = AHB_EN_REG,
900 .en_mask = BIT(22),
901 .reset_reg = SW_RESET_AHB2_REG,
902 .reset_mask = BIT(0),
903 .halt_reg = DBG_BUS_VEC_F_REG,
904 .halt_bit = 20,
905 },
906 .c = {
907 .dbg_name = "dsi2_s_p_clk",
908 .ops = &clk_ops_branch,
909 CLK_INIT(dsi2_s_p_clk.c),
910 },
911};
912
913static struct branch_clk gfx2d0_p_clk = {
914 .b = {
915 .ctl_reg = AHB_EN_REG,
916 .en_mask = BIT(19),
917 .reset_reg = SW_RESET_AHB_REG,
918 .reset_mask = BIT(12),
919 .halt_reg = DBG_BUS_VEC_F_REG,
920 .halt_bit = 2,
921 },
922 .c = {
923 .dbg_name = "gfx2d0_p_clk",
924 .ops = &clk_ops_branch,
925 CLK_INIT(gfx2d0_p_clk.c),
926 },
927};
928
929static struct branch_clk gfx2d1_p_clk = {
930 .b = {
931 .ctl_reg = AHB_EN_REG,
932 .en_mask = BIT(2),
933 .reset_reg = SW_RESET_AHB_REG,
934 .reset_mask = BIT(11),
935 .halt_reg = DBG_BUS_VEC_F_REG,
936 .halt_bit = 3,
937 },
938 .c = {
939 .dbg_name = "gfx2d1_p_clk",
940 .ops = &clk_ops_branch,
941 CLK_INIT(gfx2d1_p_clk.c),
942 },
943};
944
945static struct branch_clk gfx3d_p_clk = {
946 .b = {
947 .ctl_reg = AHB_EN_REG,
948 .en_mask = BIT(3),
949 .reset_reg = SW_RESET_AHB_REG,
950 .reset_mask = BIT(10),
951 .halt_reg = DBG_BUS_VEC_F_REG,
952 .halt_bit = 4,
953 },
954 .c = {
955 .dbg_name = "gfx3d_p_clk",
956 .ops = &clk_ops_branch,
957 CLK_INIT(gfx3d_p_clk.c),
958 },
959};
960
961static struct branch_clk hdmi_m_p_clk = {
962 .b = {
963 .ctl_reg = AHB_EN_REG,
964 .en_mask = BIT(14),
965 .reset_reg = SW_RESET_AHB_REG,
966 .reset_mask = BIT(9),
967 .halt_reg = DBG_BUS_VEC_F_REG,
968 .halt_bit = 5,
969 },
970 .c = {
971 .dbg_name = "hdmi_m_p_clk",
972 .ops = &clk_ops_branch,
973 CLK_INIT(hdmi_m_p_clk.c),
974 },
975};
976
977static struct branch_clk hdmi_s_p_clk = {
978 .b = {
979 .ctl_reg = AHB_EN_REG,
980 .en_mask = BIT(4),
981 .reset_reg = SW_RESET_AHB_REG,
982 .reset_mask = BIT(9),
983 .halt_reg = DBG_BUS_VEC_F_REG,
984 .halt_bit = 6,
985 },
986 .c = {
987 .dbg_name = "hdmi_s_p_clk",
988 .ops = &clk_ops_branch,
989 CLK_INIT(hdmi_s_p_clk.c),
990 },
991};
992
993static struct branch_clk ijpeg_p_clk = {
994 .b = {
995 .ctl_reg = AHB_EN_REG,
996 .en_mask = BIT(5),
997 .reset_reg = SW_RESET_AHB_REG,
998 .reset_mask = BIT(7),
999 .halt_reg = DBG_BUS_VEC_F_REG,
1000 .halt_bit = 9,
1001 },
1002 .c = {
1003 .dbg_name = "ijpeg_p_clk",
1004 .ops = &clk_ops_branch,
1005 CLK_INIT(ijpeg_p_clk.c),
1006 },
1007};
1008
1009static struct branch_clk imem_p_clk = {
1010 .b = {
1011 .ctl_reg = AHB_EN_REG,
1012 .en_mask = BIT(6),
1013 .reset_reg = SW_RESET_AHB_REG,
1014 .reset_mask = BIT(8),
1015 .halt_reg = DBG_BUS_VEC_F_REG,
1016 .halt_bit = 10,
1017 },
1018 .c = {
1019 .dbg_name = "imem_p_clk",
1020 .ops = &clk_ops_branch,
1021 CLK_INIT(imem_p_clk.c),
1022 },
1023};
1024
1025static struct branch_clk jpegd_p_clk = {
1026 .b = {
1027 .ctl_reg = AHB_EN_REG,
1028 .en_mask = BIT(21),
1029 .reset_reg = SW_RESET_AHB_REG,
1030 .reset_mask = BIT(4),
1031 .halt_reg = DBG_BUS_VEC_F_REG,
1032 .halt_bit = 7,
1033 },
1034 .c = {
1035 .dbg_name = "jpegd_p_clk",
1036 .ops = &clk_ops_branch,
1037 CLK_INIT(jpegd_p_clk.c),
1038 },
1039};
1040
1041static struct branch_clk mdp_p_clk = {
1042 .b = {
1043 .ctl_reg = AHB_EN_REG,
1044 .en_mask = BIT(10),
1045 .reset_reg = SW_RESET_AHB_REG,
1046 .reset_mask = BIT(3),
1047 .halt_reg = DBG_BUS_VEC_F_REG,
1048 .halt_bit = 11,
1049 },
1050 .c = {
1051 .dbg_name = "mdp_p_clk",
1052 .ops = &clk_ops_branch,
1053 CLK_INIT(mdp_p_clk.c),
1054 },
1055};
1056
1057static struct branch_clk rot_p_clk = {
1058 .b = {
1059 .ctl_reg = AHB_EN_REG,
1060 .en_mask = BIT(12),
1061 .reset_reg = SW_RESET_AHB_REG,
1062 .reset_mask = BIT(2),
1063 .halt_reg = DBG_BUS_VEC_F_REG,
1064 .halt_bit = 13,
1065 },
1066 .c = {
1067 .dbg_name = "rot_p_clk",
1068 .ops = &clk_ops_branch,
1069 CLK_INIT(rot_p_clk.c),
1070 },
1071};
1072
1073static struct branch_clk smmu_p_clk = {
1074 .b = {
1075 .ctl_reg = AHB_EN_REG,
1076 .en_mask = BIT(15),
1077 .halt_reg = DBG_BUS_VEC_F_REG,
1078 .halt_bit = 22,
1079 },
1080 .c = {
1081 .dbg_name = "smmu_p_clk",
1082 .ops = &clk_ops_branch,
1083 CLK_INIT(smmu_p_clk.c),
1084 },
1085};
1086
1087static struct branch_clk tv_enc_p_clk = {
1088 .b = {
1089 .ctl_reg = AHB_EN_REG,
1090 .en_mask = BIT(25),
1091 .reset_reg = SW_RESET_AHB_REG,
1092 .reset_mask = BIT(15),
1093 .halt_reg = DBG_BUS_VEC_F_REG,
1094 .halt_bit = 23,
1095 },
1096 .c = {
1097 .dbg_name = "tv_enc_p_clk",
1098 .ops = &clk_ops_branch,
1099 CLK_INIT(tv_enc_p_clk.c),
1100 },
1101};
1102
1103static struct branch_clk vcodec_p_clk = {
1104 .b = {
1105 .ctl_reg = AHB_EN_REG,
1106 .en_mask = BIT(11),
1107 .reset_reg = SW_RESET_AHB_REG,
1108 .reset_mask = BIT(1),
1109 .halt_reg = DBG_BUS_VEC_F_REG,
1110 .halt_bit = 12,
1111 },
1112 .c = {
1113 .dbg_name = "vcodec_p_clk",
1114 .ops = &clk_ops_branch,
1115 CLK_INIT(vcodec_p_clk.c),
1116 },
1117};
1118
1119static struct branch_clk vfe_p_clk = {
1120 .b = {
1121 .ctl_reg = AHB_EN_REG,
1122 .en_mask = BIT(13),
1123 .reset_reg = SW_RESET_AHB_REG,
1124 .reset_mask = BIT(0),
1125 .halt_reg = DBG_BUS_VEC_F_REG,
1126 .halt_bit = 14,
1127 },
1128 .c = {
1129 .dbg_name = "vfe_p_clk",
1130 .ops = &clk_ops_branch,
1131 CLK_INIT(vfe_p_clk.c),
1132 },
1133};
1134
1135static struct branch_clk vpe_p_clk = {
1136 .b = {
1137 .ctl_reg = AHB_EN_REG,
1138 .en_mask = BIT(16),
1139 .reset_reg = SW_RESET_AHB_REG,
1140 .reset_mask = BIT(14),
1141 .halt_reg = DBG_BUS_VEC_F_REG,
1142 .halt_bit = 15,
1143 },
1144 .c = {
1145 .dbg_name = "vpe_p_clk",
1146 .ops = &clk_ops_branch,
1147 CLK_INIT(vpe_p_clk.c),
1148 },
1149};
1150
Tianyi Gou41515e22011-09-01 19:37:43 -07001151static struct branch_clk vcap_p_clk = {
1152 .b = {
1153 .ctl_reg = AHB_EN3_REG,
1154 .en_mask = BIT(1),
1155 .reset_reg = SW_RESET_AHB2_REG,
1156 .reset_mask = BIT(2),
1157 .halt_reg = DBG_BUS_VEC_J_REG,
1158 .halt_bit = 23,
1159 },
1160 .c = {
1161 .dbg_name = "vcap_p_clk",
1162 .ops = &clk_ops_branch,
1163 CLK_INIT(vcap_p_clk.c),
1164 },
1165};
1166
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001167/*
1168 * Peripheral Clocks
1169 */
1170#define CLK_GSBI_UART(i, n, h_r, h_b) \
1171 struct rcg_clk i##_clk = { \
1172 .b = { \
1173 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
1174 .en_mask = BIT(9), \
1175 .reset_reg = GSBIn_RESET_REG(n), \
1176 .reset_mask = BIT(0), \
1177 .halt_reg = h_r, \
1178 .halt_bit = h_b, \
1179 }, \
1180 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
1181 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
1182 .root_en_mask = BIT(11), \
1183 .ns_mask = (BM(31, 16) | BM(6, 0)), \
1184 .set_rate = set_rate_mnd, \
1185 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001186 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001187 .c = { \
1188 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001189 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001190 CLK_INIT(i##_clk.c), \
1191 }, \
1192 }
1193#define F_GSBI_UART(f, s, d, m, n, v) \
1194 { \
1195 .freq_hz = f, \
1196 .src_clk = &s##_clk.c, \
1197 .md_val = MD16(m, n), \
1198 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1199 .mnd_en_mask = BIT(8) * !!(n), \
1200 .sys_vdd = v, \
1201 }
1202static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
1203 F_GSBI_UART( 0, gnd, 1, 0, 0, NONE),
1204 F_GSBI_UART( 1843200, pll8, 1, 3, 625, LOW),
1205 F_GSBI_UART( 3686400, pll8, 1, 6, 625, LOW),
1206 F_GSBI_UART( 7372800, pll8, 1, 12, 625, LOW),
1207 F_GSBI_UART(14745600, pll8, 1, 24, 625, LOW),
1208 F_GSBI_UART(16000000, pll8, 4, 1, 6, LOW),
1209 F_GSBI_UART(24000000, pll8, 4, 1, 4, LOW),
1210 F_GSBI_UART(32000000, pll8, 4, 1, 3, LOW),
1211 F_GSBI_UART(40000000, pll8, 1, 5, 48, NOMINAL),
1212 F_GSBI_UART(46400000, pll8, 1, 29, 240, NOMINAL),
1213 F_GSBI_UART(48000000, pll8, 4, 1, 2, NOMINAL),
1214 F_GSBI_UART(51200000, pll8, 1, 2, 15, NOMINAL),
1215 F_GSBI_UART(56000000, pll8, 1, 7, 48, NOMINAL),
1216 F_GSBI_UART(58982400, pll8, 1, 96, 625, NOMINAL),
1217 F_GSBI_UART(64000000, pll8, 2, 1, 3, NOMINAL),
1218 F_END
1219};
1220
1221static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1222static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1223static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1224static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1225static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1226static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1227static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1228static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1229static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1230static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1231static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1232static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1233
1234#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1235 struct rcg_clk i##_clk = { \
1236 .b = { \
1237 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1238 .en_mask = BIT(9), \
1239 .reset_reg = GSBIn_RESET_REG(n), \
1240 .reset_mask = BIT(0), \
1241 .halt_reg = h_r, \
1242 .halt_bit = h_b, \
1243 }, \
1244 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1245 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1246 .root_en_mask = BIT(11), \
1247 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1248 .set_rate = set_rate_mnd, \
1249 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001250 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001251 .c = { \
1252 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001253 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001254 CLK_INIT(i##_clk.c), \
1255 }, \
1256 }
1257#define F_GSBI_QUP(f, s, d, m, n, v) \
1258 { \
1259 .freq_hz = f, \
1260 .src_clk = &s##_clk.c, \
1261 .md_val = MD8(16, m, 0, n), \
1262 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1263 .mnd_en_mask = BIT(8) * !!(n), \
1264 .sys_vdd = v, \
1265 }
1266static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
1267 F_GSBI_QUP( 0, gnd, 1, 0, 0, NONE),
1268 F_GSBI_QUP( 1100000, pxo, 1, 2, 49, LOW),
1269 F_GSBI_QUP( 5400000, pxo, 1, 1, 5, LOW),
1270 F_GSBI_QUP(10800000, pxo, 1, 2, 5, LOW),
1271 F_GSBI_QUP(15060000, pll8, 1, 2, 51, LOW),
1272 F_GSBI_QUP(24000000, pll8, 4, 1, 4, LOW),
1273 F_GSBI_QUP(25600000, pll8, 1, 1, 15, NOMINAL),
1274 F_GSBI_QUP(27000000, pxo, 1, 0, 0, NOMINAL),
1275 F_GSBI_QUP(48000000, pll8, 4, 1, 2, NOMINAL),
1276 F_GSBI_QUP(51200000, pll8, 1, 2, 15, NOMINAL),
1277 F_END
1278};
1279
1280static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1281static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1282static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1283static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1284static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1285static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1286static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1287static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1288static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1289static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1290static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1291static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1292
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001293#define F_QDSS(f, s, d, v) \
1294 { \
1295 .freq_hz = f, \
1296 .src_clk = &s##_clk.c, \
1297 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
1298 .sys_vdd = v, \
1299 }
1300static struct clk_freq_tbl clk_tbl_qdss[] = {
Stephen Boydd4de6d72011-09-13 13:01:40 -07001301 F_QDSS( 27000000, pxo, 1, LOW),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001302 F_QDSS(128000000, pll8, 3, LOW),
1303 F_QDSS(300000000, pll3, 4, NOMINAL),
1304 F_END
1305};
1306
1307struct qdss_bank {
1308 const u32 bank_sel_mask;
1309 void __iomem *const ns_reg;
1310 const u32 ns_mask;
1311};
1312
Stephen Boydd4de6d72011-09-13 13:01:40 -07001313#define QDSS_CLK_ROOT_ENA BIT(1)
1314
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001315static int qdss_clk_handoff(struct clk *c)
Stephen Boydd4de6d72011-09-13 13:01:40 -07001316{
1317 struct rcg_clk *clk = to_rcg_clk(c);
1318 const struct qdss_bank *bank = clk->bank_info;
1319 u32 reg, ns_val, bank_sel;
1320 struct clk_freq_tbl *freq;
1321
1322 reg = readl_relaxed(clk->ns_reg);
1323 if (!(reg & QDSS_CLK_ROOT_ENA))
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001324 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001325
1326 bank_sel = reg & bank->bank_sel_mask;
1327 /* Force bank 1 to PXO if bank 0 is in use */
1328 if (bank_sel == 0)
1329 writel_relaxed(0, bank->ns_reg);
1330 ns_val = readl_relaxed(bank->ns_reg) & bank->ns_mask;
1331 for (freq = clk->freq_tbl; freq->freq_hz != FREQ_END; freq++) {
1332 if ((freq->ns_val & bank->ns_mask) == ns_val) {
1333 pr_info("%s rate=%d\n", clk->c.dbg_name, freq->freq_hz);
1334 break;
1335 }
1336 }
1337 if (freq->freq_hz == FREQ_END)
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001338 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001339
1340 clk->current_freq = freq;
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001341
1342 return 1;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001343}
1344
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001345static void set_rate_qdss(struct rcg_clk *clk, struct clk_freq_tbl *nf)
1346{
1347 const struct qdss_bank *bank = clk->bank_info;
1348 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1349
1350 /* Switch to bank 0 (always sourced from PXO) */
1351 reg = readl_relaxed(clk->ns_reg);
1352 reg &= ~bank_sel_mask;
1353 writel_relaxed(reg, clk->ns_reg);
1354 /*
1355 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1356 * MUX to fully switch sources.
1357 */
1358 mb();
1359 udelay(1);
1360
1361 /* Set source and divider */
1362 reg = readl_relaxed(bank->ns_reg);
1363 reg &= ~bank->ns_mask;
1364 reg |= nf->ns_val;
1365 writel_relaxed(reg, bank->ns_reg);
1366
1367 /* Switch to reprogrammed bank */
1368 reg = readl_relaxed(clk->ns_reg);
1369 reg |= bank_sel_mask;
1370 writel_relaxed(reg, clk->ns_reg);
1371 /*
1372 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1373 * MUX to fully switch sources.
1374 */
1375 mb();
1376 udelay(1);
1377}
1378
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001379static int qdss_clk_enable(struct clk *c)
1380{
1381 struct rcg_clk *clk = to_rcg_clk(c);
1382 const struct qdss_bank *bank = clk->bank_info;
1383 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1384 int ret;
1385
1386 /* Switch to bank 1 */
1387 reg = readl_relaxed(clk->ns_reg);
1388 reg |= bank_sel_mask;
1389 writel_relaxed(reg, clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001390
1391 ret = rcg_clk_enable(c);
1392 if (ret) {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001393 /* Switch to bank 0 */
1394 reg &= ~bank_sel_mask;
1395 writel_relaxed(reg, clk->ns_reg);
1396 }
1397 return ret;
1398}
1399
1400static void qdss_clk_disable(struct clk *c)
1401{
1402 struct rcg_clk *clk = to_rcg_clk(c);
1403 const struct qdss_bank *bank = clk->bank_info;
1404 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1405
1406 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001407 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001408 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001409 reg &= ~bank_sel_mask;
1410 writel_relaxed(reg, clk->ns_reg);
1411}
1412
1413static void qdss_clk_auto_off(struct clk *c)
1414{
1415 struct rcg_clk *clk = to_rcg_clk(c);
1416 const struct qdss_bank *bank = clk->bank_info;
1417 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1418
1419 rcg_clk_auto_off(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001420 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001421 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001422 reg &= ~bank_sel_mask;
1423 writel_relaxed(reg, clk->ns_reg);
1424}
1425
1426static struct clk_ops clk_ops_qdss = {
1427 .enable = qdss_clk_enable,
1428 .disable = qdss_clk_disable,
1429 .auto_off = qdss_clk_auto_off,
Stephen Boydd4de6d72011-09-13 13:01:40 -07001430 .handoff = qdss_clk_handoff,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001431 .set_rate = rcg_clk_set_rate,
1432 .set_min_rate = rcg_clk_set_min_rate,
1433 .get_rate = rcg_clk_get_rate,
1434 .list_rate = rcg_clk_list_rate,
1435 .is_enabled = rcg_clk_is_enabled,
1436 .round_rate = rcg_clk_round_rate,
1437 .reset = soc_clk_reset,
1438 .is_local = local_clk_is_local,
1439 .get_parent = rcg_clk_get_parent,
1440};
1441
1442static struct qdss_bank bdiv_info_qdss = {
1443 .bank_sel_mask = BIT(0),
1444 .ns_reg = QDSS_AT_CLK_SRC1_NS_REG,
1445 .ns_mask = BM(6, 0),
1446};
1447
1448static struct rcg_clk qdss_at_clk = {
1449 .b = {
1450 .ctl_reg = QDSS_AT_CLK_NS_REG,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001451 .reset_reg = QDSS_RESETS_REG,
1452 .reset_mask = BIT(0),
Stephen Boydfcfd4dd2011-09-13 12:49:57 -07001453 .halt_check = NOCHECK,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001454 },
1455 .ns_reg = QDSS_AT_CLK_SRC_CTL_REG,
1456 .set_rate = set_rate_qdss,
1457 .freq_tbl = clk_tbl_qdss,
1458 .bank_info = &bdiv_info_qdss,
1459 .current_freq = &rcg_dummy_freq,
1460 .c = {
1461 .dbg_name = "qdss_at_clk",
1462 .ops = &clk_ops_qdss,
1463 CLK_INIT(qdss_at_clk.c),
1464 },
1465};
1466
1467static struct branch_clk qdss_pclkdbg_clk = {
1468 .b = {
1469 .ctl_reg = QDSS_AT_CLK_NS_REG,
1470 .en_mask = BIT(4),
1471 .reset_reg = QDSS_RESETS_REG,
1472 .reset_mask = BIT(0),
1473 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1474 .halt_bit = 9,
1475 .halt_check = HALT_VOTED
1476 },
1477 .parent = &qdss_at_clk.c,
1478 .c = {
1479 .dbg_name = "qdss_pclkdbg_clk",
1480 .ops = &clk_ops_branch,
1481 CLK_INIT(qdss_pclkdbg_clk.c),
1482 },
1483};
1484
1485static struct qdss_bank bdiv_info_qdss_trace = {
1486 .bank_sel_mask = BIT(0),
1487 .ns_reg = QDSS_TRACECLKIN_CLK_SRC1_NS_REG,
1488 .ns_mask = BM(6, 0),
1489};
1490
1491static struct rcg_clk qdss_traceclkin_clk = {
1492 .b = {
1493 .ctl_reg = QDSS_TRACECLKIN_CTL_REG,
1494 .en_mask = BIT(4),
1495 .reset_reg = QDSS_RESETS_REG,
1496 .reset_mask = BIT(0),
1497 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1498 .halt_bit = 8,
1499 .halt_check = HALT_VOTED,
1500 },
1501 .ns_reg = QDSS_TRACECLKIN_CLK_SRC_CTL_REG,
1502 .set_rate = set_rate_qdss,
1503 .freq_tbl = clk_tbl_qdss,
1504 .bank_info = &bdiv_info_qdss_trace,
1505 .current_freq = &rcg_dummy_freq,
1506 .c = {
1507 .dbg_name = "qdss_traceclkin_clk",
1508 .ops = &clk_ops_qdss,
1509 CLK_INIT(qdss_traceclkin_clk.c),
1510 },
1511};
1512
1513static struct clk_freq_tbl clk_tbl_qdss_tsctr[] = {
Stephen Boydd4de6d72011-09-13 13:01:40 -07001514 F_QDSS( 27000000, pxo, 1, LOW),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001515 F_QDSS(200000000, pll3, 6, LOW),
1516 F_QDSS(400000000, pll3, 3, NOMINAL),
1517 F_END
1518};
1519
1520static struct qdss_bank bdiv_info_qdss_tsctr = {
1521 .bank_sel_mask = BIT(0),
1522 .ns_reg = QDSS_TSCTR_CLK_SRC1_NS_REG,
1523 .ns_mask = BM(6, 0),
1524};
1525
1526static struct rcg_clk qdss_tsctr_clk = {
1527 .b = {
1528 .ctl_reg = QDSS_TSCTR_CTL_REG,
1529 .en_mask = BIT(4),
1530 .reset_reg = QDSS_RESETS_REG,
1531 .reset_mask = BIT(3),
1532 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1533 .halt_bit = 7,
1534 .halt_check = HALT_VOTED,
1535 },
1536 .ns_reg = QDSS_TSCTR_CLK_SRC_CTL_REG,
1537 .set_rate = set_rate_qdss,
1538 .freq_tbl = clk_tbl_qdss_tsctr,
1539 .bank_info = &bdiv_info_qdss_tsctr,
1540 .current_freq = &rcg_dummy_freq,
1541 .c = {
1542 .dbg_name = "qdss_tsctr_clk",
1543 .ops = &clk_ops_qdss,
1544 CLK_INIT(qdss_tsctr_clk.c),
1545 },
1546};
1547
1548static struct branch_clk qdss_stm_clk = {
1549 .b = {
1550 .ctl_reg = QDSS_STM_CLK_CTL_REG,
1551 .en_mask = BIT(4),
1552 .reset_reg = QDSS_RESETS_REG,
1553 .reset_mask = BIT(1),
1554 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
1555 .halt_bit = 20,
1556 .halt_check = HALT_VOTED,
1557 },
1558 .c = {
1559 .dbg_name = "qdss_stm_clk",
1560 .ops = &clk_ops_branch,
1561 CLK_INIT(qdss_stm_clk.c),
1562 },
1563};
1564
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001565#define F_PDM(f, s, d, v) \
1566 { \
1567 .freq_hz = f, \
1568 .src_clk = &s##_clk.c, \
1569 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
1570 .sys_vdd = v, \
1571 }
1572static struct clk_freq_tbl clk_tbl_pdm[] = {
1573 F_PDM( 0, gnd, 1, NONE),
1574 F_PDM(27000000, pxo, 1, LOW),
1575 F_END
1576};
1577
1578static struct rcg_clk pdm_clk = {
1579 .b = {
1580 .ctl_reg = PDM_CLK_NS_REG,
1581 .en_mask = BIT(9),
1582 .reset_reg = PDM_CLK_NS_REG,
1583 .reset_mask = BIT(12),
1584 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1585 .halt_bit = 3,
1586 },
1587 .ns_reg = PDM_CLK_NS_REG,
1588 .root_en_mask = BIT(11),
1589 .ns_mask = BM(1, 0),
1590 .set_rate = set_rate_nop,
1591 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001592 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001593 .c = {
1594 .dbg_name = "pdm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001595 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001596 CLK_INIT(pdm_clk.c),
1597 },
1598};
1599
1600static struct branch_clk pmem_clk = {
1601 .b = {
1602 .ctl_reg = PMEM_ACLK_CTL_REG,
1603 .en_mask = BIT(4),
1604 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1605 .halt_bit = 20,
1606 },
1607 .c = {
1608 .dbg_name = "pmem_clk",
1609 .ops = &clk_ops_branch,
1610 CLK_INIT(pmem_clk.c),
1611 },
1612};
1613
1614#define F_PRNG(f, s, v) \
1615 { \
1616 .freq_hz = f, \
1617 .src_clk = &s##_clk.c, \
1618 .sys_vdd = v, \
1619 }
1620static struct clk_freq_tbl clk_tbl_prng[] = {
1621 F_PRNG(64000000, pll8, NOMINAL),
1622 F_END
1623};
1624
1625static struct rcg_clk prng_clk = {
1626 .b = {
1627 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1628 .en_mask = BIT(10),
1629 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1630 .halt_check = HALT_VOTED,
1631 .halt_bit = 10,
1632 },
1633 .set_rate = set_rate_nop,
1634 .freq_tbl = clk_tbl_prng,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001635 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001636 .c = {
1637 .dbg_name = "prng_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001638 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001639 CLK_INIT(prng_clk.c),
1640 },
1641};
1642
Stephen Boyda78a7402011-08-02 11:23:39 -07001643#define CLK_SDC(name, n, h_b, f_table) \
1644 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001645 .b = { \
1646 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1647 .en_mask = BIT(9), \
1648 .reset_reg = SDCn_RESET_REG(n), \
1649 .reset_mask = BIT(0), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001650 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001651 .halt_bit = h_b, \
1652 }, \
1653 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1654 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1655 .root_en_mask = BIT(11), \
1656 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1657 .set_rate = set_rate_mnd, \
Stephen Boyda78a7402011-08-02 11:23:39 -07001658 .freq_tbl = f_table, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001659 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001660 .c = { \
Stephen Boyda78a7402011-08-02 11:23:39 -07001661 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001662 .ops = &clk_ops_rcg_8960, \
Stephen Boyda78a7402011-08-02 11:23:39 -07001663 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001664 }, \
1665 }
1666#define F_SDC(f, s, d, m, n, v) \
1667 { \
1668 .freq_hz = f, \
1669 .src_clk = &s##_clk.c, \
1670 .md_val = MD8(16, m, 0, n), \
1671 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1672 .mnd_en_mask = BIT(8) * !!(n), \
1673 .sys_vdd = v, \
1674 }
Stephen Boyda78a7402011-08-02 11:23:39 -07001675static struct clk_freq_tbl clk_tbl_sdc1_2[] = {
1676 F_SDC( 0, gnd, 1, 0, 0, NONE),
1677 F_SDC( 144000, pxo, 3, 2, 125, LOW),
1678 F_SDC( 400000, pll8, 4, 1, 240, LOW),
1679 F_SDC( 16000000, pll8, 4, 1, 6, LOW),
1680 F_SDC( 17070000, pll8, 1, 2, 45, LOW),
1681 F_SDC( 20210000, pll8, 1, 1, 19, LOW),
1682 F_SDC( 24000000, pll8, 4, 1, 4, LOW),
1683 F_SDC( 48000000, pll8, 4, 1, 2, LOW),
1684 F_SDC( 64000000, pll8, 3, 1, 2, NOMINAL),
1685 F_SDC( 96000000, pll8, 4, 0, 0, NOMINAL),
1686 F_END
1687};
1688
1689static CLK_SDC(sdc1_clk, 1, 6, clk_tbl_sdc1_2);
1690static CLK_SDC(sdc2_clk, 2, 5, clk_tbl_sdc1_2);
1691
1692static struct clk_freq_tbl clk_tbl_sdc3[] = {
1693 F_SDC( 0, gnd, 1, 0, 0, NONE),
1694 F_SDC( 144000, pxo, 3, 2, 125, LOW),
1695 F_SDC( 400000, pll8, 4, 1, 240, LOW),
1696 F_SDC( 16000000, pll8, 4, 1, 6, LOW),
1697 F_SDC( 17070000, pll8, 1, 2, 45, LOW),
1698 F_SDC( 20210000, pll8, 1, 1, 19, LOW),
1699 F_SDC( 24000000, pll8, 4, 1, 4, LOW),
1700 F_SDC( 48000000, pll8, 4, 1, 2, LOW),
1701 F_SDC( 64000000, pll8, 3, 1, 2, LOW),
1702 F_SDC( 96000000, pll8, 4, 0, 0, LOW),
1703 F_SDC(192000000, pll8, 2, 0, 0, NOMINAL),
1704 F_END
1705};
1706
1707static CLK_SDC(sdc3_clk, 3, 4, clk_tbl_sdc3);
1708
1709static struct clk_freq_tbl clk_tbl_sdc4_5[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001710 F_SDC( 0, gnd, 1, 0, 0, NONE),
1711 F_SDC( 144000, pxo, 3, 2, 125, LOW),
1712 F_SDC( 400000, pll8, 4, 1, 240, LOW),
1713 F_SDC( 16000000, pll8, 4, 1, 6, LOW),
1714 F_SDC( 17070000, pll8, 1, 2, 45, LOW),
1715 F_SDC( 20210000, pll8, 1, 1, 19, LOW),
1716 F_SDC( 24000000, pll8, 4, 1, 4, LOW),
1717 F_SDC( 48000000, pll8, 4, 1, 2, NOMINAL),
1718 F_SDC( 64000000, pll8, 3, 1, 2, NOMINAL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001719 F_END
1720};
1721
Stephen Boyda78a7402011-08-02 11:23:39 -07001722static CLK_SDC(sdc4_clk, 4, 3, clk_tbl_sdc4_5);
1723static CLK_SDC(sdc5_clk, 5, 2, clk_tbl_sdc4_5);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001724
1725#define F_TSIF_REF(f, s, d, m, n, v) \
1726 { \
1727 .freq_hz = f, \
1728 .src_clk = &s##_clk.c, \
1729 .md_val = MD16(m, n), \
1730 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1731 .mnd_en_mask = BIT(8) * !!(n), \
1732 .sys_vdd = v, \
1733 }
1734static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
1735 F_TSIF_REF( 0, gnd, 1, 0, 0, NONE),
1736 F_TSIF_REF(105000, pxo, 1, 1, 256, LOW),
1737 F_END
1738};
1739
1740static struct rcg_clk tsif_ref_clk = {
1741 .b = {
1742 .ctl_reg = TSIF_REF_CLK_NS_REG,
1743 .en_mask = BIT(9),
1744 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1745 .halt_bit = 5,
1746 },
1747 .ns_reg = TSIF_REF_CLK_NS_REG,
1748 .md_reg = TSIF_REF_CLK_MD_REG,
1749 .root_en_mask = BIT(11),
1750 .ns_mask = (BM(31, 16) | BM(6, 0)),
1751 .set_rate = set_rate_mnd,
1752 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001753 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001754 .c = {
1755 .dbg_name = "tsif_ref_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001756 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001757 CLK_INIT(tsif_ref_clk.c),
1758 },
1759};
1760
1761#define F_TSSC(f, s, v) \
1762 { \
1763 .freq_hz = f, \
1764 .src_clk = &s##_clk.c, \
1765 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
1766 .sys_vdd = v, \
1767 }
1768static struct clk_freq_tbl clk_tbl_tssc[] = {
1769 F_TSSC( 0, gnd, NONE),
1770 F_TSSC(27000000, pxo, LOW),
1771 F_END
1772};
1773
1774static struct rcg_clk tssc_clk = {
1775 .b = {
1776 .ctl_reg = TSSC_CLK_CTL_REG,
1777 .en_mask = BIT(4),
1778 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1779 .halt_bit = 4,
1780 },
1781 .ns_reg = TSSC_CLK_CTL_REG,
1782 .ns_mask = BM(1, 0),
1783 .set_rate = set_rate_nop,
1784 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001785 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001786 .c = {
1787 .dbg_name = "tssc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001788 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001789 CLK_INIT(tssc_clk.c),
1790 },
1791};
1792
Tianyi Gou41515e22011-09-01 19:37:43 -07001793#define CLK_USB_HS(name, n, h_b) \
1794 static struct rcg_clk name = { \
1795 .b = { \
1796 .ctl_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1797 .en_mask = BIT(9), \
1798 .reset_reg = USB_HS##n##_RESET_REG, \
1799 .reset_mask = BIT(0), \
1800 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
1801 .halt_bit = h_b, \
1802 }, \
1803 .ns_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1804 .md_reg = USB_HS##n##_XCVR_FS_CLK_MD_REG, \
1805 .root_en_mask = BIT(11), \
1806 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1807 .set_rate = set_rate_mnd, \
1808 .freq_tbl = clk_tbl_usb, \
1809 .current_freq = &rcg_dummy_freq, \
1810 .c = { \
1811 .dbg_name = #name, \
1812 .ops = &clk_ops_rcg_8960, \
1813 CLK_INIT(name.c), \
1814 }, \
1815}
1816
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001817#define F_USB(f, s, d, m, n, v) \
1818 { \
1819 .freq_hz = f, \
1820 .src_clk = &s##_clk.c, \
1821 .md_val = MD8(16, m, 0, n), \
1822 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1823 .mnd_en_mask = BIT(8) * !!(n), \
1824 .sys_vdd = v, \
1825 }
1826static struct clk_freq_tbl clk_tbl_usb[] = {
1827 F_USB( 0, gnd, 1, 0, 0, NONE),
1828 F_USB(60000000, pll8, 1, 5, 32, NOMINAL),
1829 F_END
1830};
1831
Tianyi Gou41515e22011-09-01 19:37:43 -07001832CLK_USB_HS(usb_hs1_xcvr_clk, 1, 0);
1833CLK_USB_HS(usb_hs3_xcvr_clk, 3, 30);
1834CLK_USB_HS(usb_hs4_xcvr_clk, 4, 2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001835
Stephen Boyd94625ef2011-07-12 17:06:01 -07001836static struct clk_freq_tbl clk_tbl_usb_hsic[] = {
1837 F_USB( 0, gnd, 1, 0, 0, NONE),
1838 F_USB(60000000, pll8, 1, 5, 32, LOW),
1839 F_END
1840};
1841
1842static struct rcg_clk usb_hsic_xcvr_fs_clk = {
1843 .b = {
1844 .ctl_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1845 .en_mask = BIT(9),
1846 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1847 .halt_bit = 26,
1848 },
1849 .ns_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1850 .md_reg = USB_HSIC_XCVR_FS_CLK_MD_REG,
1851 .root_en_mask = BIT(11),
1852 .ns_mask = (BM(23, 16) | BM(6, 0)),
1853 .set_rate = set_rate_mnd,
1854 .freq_tbl = clk_tbl_usb_hsic,
1855 .current_freq = &rcg_dummy_freq,
1856 .c = {
1857 .dbg_name = "usb_hsic_xcvr_fs_clk",
1858 .ops = &clk_ops_rcg_8960,
1859 CLK_INIT(usb_hsic_xcvr_fs_clk.c),
1860 },
1861};
1862
1863static struct branch_clk usb_hsic_system_clk = {
1864 .b = {
1865 .ctl_reg = USB_HSIC_SYSTEM_CLK_CTL_REG,
1866 .en_mask = BIT(4),
1867 .reset_reg = USB_HSIC_RESET_REG,
1868 .reset_mask = BIT(0),
1869 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1870 .halt_bit = 24,
1871 },
1872 .parent = &usb_hsic_xcvr_fs_clk.c,
1873 .c = {
1874 .dbg_name = "usb_hsic_system_clk",
1875 .ops = &clk_ops_branch,
1876 CLK_INIT(usb_hsic_system_clk.c),
1877 },
1878};
1879
1880#define F_USB_HSIC(f, s, v) \
1881 { \
1882 .freq_hz = f, \
1883 .src_clk = &s##_clk.c, \
1884 .sys_vdd = v, \
1885 }
1886static struct clk_freq_tbl clk_tbl_usb2_hsic[] = {
1887 F_USB_HSIC(480000000, pll14, LOW),
1888 F_END
1889};
1890
1891static struct rcg_clk usb_hsic_hsic_src_clk = {
1892 .b = {
1893 .ctl_reg = USB_HSIC_HSIC_CLK_SRC_CTL_REG,
1894 .halt_check = NOCHECK,
1895 },
1896 .root_en_mask = BIT(0),
1897 .set_rate = set_rate_nop,
1898 .freq_tbl = clk_tbl_usb2_hsic,
1899 .current_freq = &rcg_dummy_freq,
1900 .c = {
1901 .dbg_name = "usb_hsic_hsic_src_clk",
1902 .ops = &clk_ops_rcg_8960,
1903 CLK_INIT(usb_hsic_hsic_src_clk.c),
1904 },
1905};
1906
1907static struct branch_clk usb_hsic_hsic_clk = {
1908 .b = {
1909 .ctl_reg = USB_HSIC_HSIC_CLK_CTL_REG,
1910 .en_mask = BIT(0),
1911 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1912 .halt_bit = 19,
1913 },
1914 .parent = &usb_hsic_hsic_src_clk.c,
1915 .c = {
1916 .dbg_name = "usb_hsic_hsic_clk",
1917 .ops = &clk_ops_branch,
1918 CLK_INIT(usb_hsic_hsic_clk.c),
1919 },
1920};
1921
1922#define F_USB_HSIO_CAL(f, s, v) \
1923 { \
1924 .freq_hz = f, \
1925 .src_clk = &s##_clk.c, \
1926 .sys_vdd = v, \
1927 }
1928static struct clk_freq_tbl clk_tbl_usb_hsio_cal[] = {
1929 F_USB_HSIO_CAL(9000000, pxo, LOW),
1930 F_END
1931};
1932
1933static struct rcg_clk usb_hsic_hsio_cal_clk = {
1934 .b = {
1935 .ctl_reg = USB_HSIC_HSIO_CAL_CLK_CTL_REG,
1936 .en_mask = BIT(0),
1937 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1938 .halt_bit = 23,
1939 },
1940 .set_rate = set_rate_nop,
1941 .freq_tbl = clk_tbl_usb_hsio_cal,
1942 .current_freq = &rcg_dummy_freq,
1943 .c = {
1944 .dbg_name = "usb_hsic_hsio_cal_clk",
Stephen Boyda0e82ec2011-09-19 12:18:45 -07001945 .ops = &clk_ops_rcg_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07001946 CLK_INIT(usb_hsic_hsio_cal_clk.c),
1947 },
1948};
1949
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001950static struct branch_clk usb_phy0_clk = {
1951 .b = {
1952 .reset_reg = USB_PHY0_RESET_REG,
1953 .reset_mask = BIT(0),
1954 },
1955 .c = {
1956 .dbg_name = "usb_phy0_clk",
1957 .ops = &clk_ops_reset,
1958 CLK_INIT(usb_phy0_clk.c),
1959 },
1960};
1961
1962#define CLK_USB_FS(i, n) \
1963 struct rcg_clk i##_clk = { \
1964 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1965 .b = { \
1966 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1967 .halt_check = NOCHECK, \
1968 }, \
1969 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
1970 .root_en_mask = BIT(11), \
1971 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1972 .set_rate = set_rate_mnd, \
1973 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001974 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001975 .c = { \
1976 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001977 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001978 CLK_INIT(i##_clk.c), \
1979 }, \
1980 }
1981
1982static CLK_USB_FS(usb_fs1_src, 1);
1983static struct branch_clk usb_fs1_xcvr_clk = {
1984 .b = {
1985 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
1986 .en_mask = BIT(9),
1987 .reset_reg = USB_FSn_RESET_REG(1),
1988 .reset_mask = BIT(1),
1989 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1990 .halt_bit = 15,
1991 },
1992 .parent = &usb_fs1_src_clk.c,
1993 .c = {
1994 .dbg_name = "usb_fs1_xcvr_clk",
1995 .ops = &clk_ops_branch,
1996 CLK_INIT(usb_fs1_xcvr_clk.c),
1997 },
1998};
1999
2000static struct branch_clk usb_fs1_sys_clk = {
2001 .b = {
2002 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
2003 .en_mask = BIT(4),
2004 .reset_reg = USB_FSn_RESET_REG(1),
2005 .reset_mask = BIT(0),
2006 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2007 .halt_bit = 16,
2008 },
2009 .parent = &usb_fs1_src_clk.c,
2010 .c = {
2011 .dbg_name = "usb_fs1_sys_clk",
2012 .ops = &clk_ops_branch,
2013 CLK_INIT(usb_fs1_sys_clk.c),
2014 },
2015};
2016
2017static CLK_USB_FS(usb_fs2_src, 2);
2018static struct branch_clk usb_fs2_xcvr_clk = {
2019 .b = {
2020 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
2021 .en_mask = BIT(9),
2022 .reset_reg = USB_FSn_RESET_REG(2),
2023 .reset_mask = BIT(1),
2024 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2025 .halt_bit = 12,
2026 },
2027 .parent = &usb_fs2_src_clk.c,
2028 .c = {
2029 .dbg_name = "usb_fs2_xcvr_clk",
2030 .ops = &clk_ops_branch,
2031 CLK_INIT(usb_fs2_xcvr_clk.c),
2032 },
2033};
2034
2035static struct branch_clk usb_fs2_sys_clk = {
2036 .b = {
2037 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
2038 .en_mask = BIT(4),
2039 .reset_reg = USB_FSn_RESET_REG(2),
2040 .reset_mask = BIT(0),
2041 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2042 .halt_bit = 13,
2043 },
2044 .parent = &usb_fs2_src_clk.c,
2045 .c = {
2046 .dbg_name = "usb_fs2_sys_clk",
2047 .ops = &clk_ops_branch,
2048 CLK_INIT(usb_fs2_sys_clk.c),
2049 },
2050};
2051
2052/* Fast Peripheral Bus Clocks */
2053static struct branch_clk ce1_core_clk = {
2054 .b = {
2055 .ctl_reg = CE1_CORE_CLK_CTL_REG,
2056 .en_mask = BIT(4),
2057 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2058 .halt_bit = 27,
2059 },
2060 .c = {
2061 .dbg_name = "ce1_core_clk",
2062 .ops = &clk_ops_branch,
2063 CLK_INIT(ce1_core_clk.c),
2064 },
2065};
Tianyi Gou41515e22011-09-01 19:37:43 -07002066
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002067static struct branch_clk ce1_p_clk = {
2068 .b = {
2069 .ctl_reg = CE1_HCLK_CTL_REG,
2070 .en_mask = BIT(4),
2071 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2072 .halt_bit = 1,
2073 },
2074 .c = {
2075 .dbg_name = "ce1_p_clk",
2076 .ops = &clk_ops_branch,
2077 CLK_INIT(ce1_p_clk.c),
2078 },
2079};
2080
Tianyi Gou41515e22011-09-01 19:37:43 -07002081#define F_CE3(f, s, d, v) \
2082 { \
2083 .freq_hz = f, \
2084 .src_clk = &s##_clk.c, \
2085 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
2086 .sys_vdd = v, \
2087 }
2088
2089static struct clk_freq_tbl clk_tbl_ce3[] = {
2090 F_CE3( 0, gnd, 1, NONE),
2091 F_CE3( 48000000, pll8, 8, LOW),
2092 F_CE3(100000000, pll3, 12, NOMINAL),
2093 F_END
2094};
2095
2096static struct rcg_clk ce3_src_clk = {
2097 .b = {
2098 .ctl_reg = CE3_CLK_SRC_NS_REG,
2099 .halt_check = NOCHECK,
2100 },
2101 .ns_reg = CE3_CLK_SRC_NS_REG,
2102 .root_en_mask = BIT(7),
2103 .ns_mask = BM(6, 0),
2104 .set_rate = set_rate_nop,
2105 .freq_tbl = clk_tbl_ce3,
2106 .current_freq = &rcg_dummy_freq,
2107 .c = {
2108 .dbg_name = "ce3_src_clk",
2109 .ops = &clk_ops_rcg_8960,
2110 CLK_INIT(ce3_src_clk.c),
2111 },
2112};
2113
2114static struct branch_clk ce3_core_clk = {
2115 .b = {
2116 .ctl_reg = CE3_CORE_CLK_CTL_REG,
2117 .en_mask = BIT(4),
2118 .reset_reg = CE3_CORE_CLK_CTL_REG,
2119 .reset_mask = BIT(7),
2120 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2121 .halt_bit = 5,
2122 },
2123 .parent = &ce3_src_clk.c,
2124 .c = {
2125 .dbg_name = "ce3_core_clk",
2126 .ops = &clk_ops_branch,
2127 CLK_INIT(ce3_core_clk.c),
2128 }
2129};
2130
2131static struct branch_clk ce3_p_clk = {
2132 .b = {
2133 .ctl_reg = CE3_HCLK_CTL_REG,
2134 .en_mask = BIT(4),
2135 .reset_reg = CE3_HCLK_CTL_REG,
2136 .reset_mask = BIT(7),
2137 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
2138 .halt_bit = 16,
2139 },
2140 .parent = &ce3_src_clk.c,
2141 .c = {
2142 .dbg_name = "ce3_p_clk",
2143 .ops = &clk_ops_branch,
2144 CLK_INIT(ce3_p_clk.c),
2145 }
2146};
2147
2148static struct branch_clk sata_phy_ref_clk = {
2149 .b = {
2150 .ctl_reg = SATA_PHY_REF_CLK_CTL_REG,
2151 .en_mask = BIT(4),
2152 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2153 .halt_bit = 24,
2154 },
2155 .parent = &pxo_clk.c,
2156 .c = {
2157 .dbg_name = "sata_phy_ref_clk",
2158 .ops = &clk_ops_branch,
2159 CLK_INIT(sata_phy_ref_clk.c),
2160 },
2161};
2162
2163static struct branch_clk pcie_p_clk = {
2164 .b = {
2165 .ctl_reg = PCIE_HCLK_CTL_REG,
2166 .en_mask = BIT(4),
2167 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2168 .halt_bit = 8,
2169 },
2170 .c = {
2171 .dbg_name = "pcie_p_clk",
2172 .ops = &clk_ops_branch,
2173 CLK_INIT(pcie_p_clk.c),
2174 },
2175};
2176
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002177static struct branch_clk dma_bam_p_clk = {
2178 .b = {
2179 .ctl_reg = DMA_BAM_HCLK_CTL,
2180 .en_mask = BIT(4),
2181 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2182 .halt_bit = 12,
2183 },
2184 .c = {
2185 .dbg_name = "dma_bam_p_clk",
2186 .ops = &clk_ops_branch,
2187 CLK_INIT(dma_bam_p_clk.c),
2188 },
2189};
2190
2191static struct branch_clk gsbi1_p_clk = {
2192 .b = {
2193 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
2194 .en_mask = BIT(4),
2195 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2196 .halt_bit = 11,
2197 },
2198 .c = {
2199 .dbg_name = "gsbi1_p_clk",
2200 .ops = &clk_ops_branch,
2201 CLK_INIT(gsbi1_p_clk.c),
2202 },
2203};
2204
2205static struct branch_clk gsbi2_p_clk = {
2206 .b = {
2207 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
2208 .en_mask = BIT(4),
2209 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2210 .halt_bit = 7,
2211 },
2212 .c = {
2213 .dbg_name = "gsbi2_p_clk",
2214 .ops = &clk_ops_branch,
2215 CLK_INIT(gsbi2_p_clk.c),
2216 },
2217};
2218
2219static struct branch_clk gsbi3_p_clk = {
2220 .b = {
2221 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
2222 .en_mask = BIT(4),
2223 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2224 .halt_bit = 3,
2225 },
2226 .c = {
2227 .dbg_name = "gsbi3_p_clk",
2228 .ops = &clk_ops_branch,
2229 CLK_INIT(gsbi3_p_clk.c),
2230 },
2231};
2232
2233static struct branch_clk gsbi4_p_clk = {
2234 .b = {
2235 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
2236 .en_mask = BIT(4),
2237 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2238 .halt_bit = 27,
2239 },
2240 .c = {
2241 .dbg_name = "gsbi4_p_clk",
2242 .ops = &clk_ops_branch,
2243 CLK_INIT(gsbi4_p_clk.c),
2244 },
2245};
2246
2247static struct branch_clk gsbi5_p_clk = {
2248 .b = {
2249 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
2250 .en_mask = BIT(4),
2251 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2252 .halt_bit = 23,
2253 },
2254 .c = {
2255 .dbg_name = "gsbi5_p_clk",
2256 .ops = &clk_ops_branch,
2257 CLK_INIT(gsbi5_p_clk.c),
2258 },
2259};
2260
2261static struct branch_clk gsbi6_p_clk = {
2262 .b = {
2263 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
2264 .en_mask = BIT(4),
2265 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2266 .halt_bit = 19,
2267 },
2268 .c = {
2269 .dbg_name = "gsbi6_p_clk",
2270 .ops = &clk_ops_branch,
2271 CLK_INIT(gsbi6_p_clk.c),
2272 },
2273};
2274
2275static struct branch_clk gsbi7_p_clk = {
2276 .b = {
2277 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
2278 .en_mask = BIT(4),
2279 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2280 .halt_bit = 15,
2281 },
2282 .c = {
2283 .dbg_name = "gsbi7_p_clk",
2284 .ops = &clk_ops_branch,
2285 CLK_INIT(gsbi7_p_clk.c),
2286 },
2287};
2288
2289static struct branch_clk gsbi8_p_clk = {
2290 .b = {
2291 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
2292 .en_mask = BIT(4),
2293 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2294 .halt_bit = 11,
2295 },
2296 .c = {
2297 .dbg_name = "gsbi8_p_clk",
2298 .ops = &clk_ops_branch,
2299 CLK_INIT(gsbi8_p_clk.c),
2300 },
2301};
2302
2303static struct branch_clk gsbi9_p_clk = {
2304 .b = {
2305 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
2306 .en_mask = BIT(4),
2307 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2308 .halt_bit = 7,
2309 },
2310 .c = {
2311 .dbg_name = "gsbi9_p_clk",
2312 .ops = &clk_ops_branch,
2313 CLK_INIT(gsbi9_p_clk.c),
2314 },
2315};
2316
2317static struct branch_clk gsbi10_p_clk = {
2318 .b = {
2319 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
2320 .en_mask = BIT(4),
2321 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2322 .halt_bit = 3,
2323 },
2324 .c = {
2325 .dbg_name = "gsbi10_p_clk",
2326 .ops = &clk_ops_branch,
2327 CLK_INIT(gsbi10_p_clk.c),
2328 },
2329};
2330
2331static struct branch_clk gsbi11_p_clk = {
2332 .b = {
2333 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
2334 .en_mask = BIT(4),
2335 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2336 .halt_bit = 18,
2337 },
2338 .c = {
2339 .dbg_name = "gsbi11_p_clk",
2340 .ops = &clk_ops_branch,
2341 CLK_INIT(gsbi11_p_clk.c),
2342 },
2343};
2344
2345static struct branch_clk gsbi12_p_clk = {
2346 .b = {
2347 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
2348 .en_mask = BIT(4),
2349 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2350 .halt_bit = 14,
2351 },
2352 .c = {
2353 .dbg_name = "gsbi12_p_clk",
2354 .ops = &clk_ops_branch,
2355 CLK_INIT(gsbi12_p_clk.c),
2356 },
2357};
2358
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002359static struct branch_clk qdss_p_clk = {
2360 .b = {
2361 .ctl_reg = QDSS_HCLK_CTL_REG,
2362 .en_mask = BIT(4),
2363 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2364 .halt_bit = 11,
2365 .halt_check = HALT_VOTED,
2366 .reset_reg = QDSS_RESETS_REG,
2367 .reset_mask = BIT(2),
2368 },
2369 .c = {
2370 .dbg_name = "qdss_p_clk",
2371 .ops = &clk_ops_branch,
2372 CLK_INIT(qdss_p_clk.c),
Tianyi Gou41515e22011-09-01 19:37:43 -07002373 }
2374};
2375
2376static struct branch_clk sata_phy_cfg_clk = {
2377 .b = {
2378 .ctl_reg = SATA_PHY_CFG_CLK_CTL_REG,
2379 .en_mask = BIT(4),
2380 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2381 .halt_bit = 12,
2382 },
2383 .c = {
2384 .dbg_name = "sata_phy_cfg_clk",
2385 .ops = &clk_ops_branch,
2386 CLK_INIT(sata_phy_cfg_clk.c),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002387 },
2388};
2389
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002390static struct branch_clk tsif_p_clk = {
2391 .b = {
2392 .ctl_reg = TSIF_HCLK_CTL_REG,
2393 .en_mask = BIT(4),
2394 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2395 .halt_bit = 7,
2396 },
2397 .c = {
2398 .dbg_name = "tsif_p_clk",
2399 .ops = &clk_ops_branch,
2400 CLK_INIT(tsif_p_clk.c),
2401 },
2402};
2403
2404static struct branch_clk usb_fs1_p_clk = {
2405 .b = {
2406 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
2407 .en_mask = BIT(4),
2408 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2409 .halt_bit = 17,
2410 },
2411 .c = {
2412 .dbg_name = "usb_fs1_p_clk",
2413 .ops = &clk_ops_branch,
2414 CLK_INIT(usb_fs1_p_clk.c),
2415 },
2416};
2417
2418static struct branch_clk usb_fs2_p_clk = {
2419 .b = {
2420 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
2421 .en_mask = BIT(4),
2422 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2423 .halt_bit = 14,
2424 },
2425 .c = {
2426 .dbg_name = "usb_fs2_p_clk",
2427 .ops = &clk_ops_branch,
2428 CLK_INIT(usb_fs2_p_clk.c),
2429 },
2430};
2431
2432static struct branch_clk usb_hs1_p_clk = {
2433 .b = {
2434 .ctl_reg = USB_HS1_HCLK_CTL_REG,
2435 .en_mask = BIT(4),
2436 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2437 .halt_bit = 1,
2438 },
2439 .c = {
2440 .dbg_name = "usb_hs1_p_clk",
2441 .ops = &clk_ops_branch,
2442 CLK_INIT(usb_hs1_p_clk.c),
2443 },
2444};
2445
Tianyi Gou41515e22011-09-01 19:37:43 -07002446static struct branch_clk usb_hs3_p_clk = {
2447 .b = {
2448 .ctl_reg = USB_HS3_HCLK_CTL_REG,
2449 .en_mask = BIT(4),
2450 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2451 .halt_bit = 31,
2452 },
2453 .c = {
2454 .dbg_name = "usb_hs3_p_clk",
2455 .ops = &clk_ops_branch,
2456 CLK_INIT(usb_hs3_p_clk.c),
2457 },
2458};
2459
2460static struct branch_clk usb_hs4_p_clk = {
2461 .b = {
2462 .ctl_reg = USB_HS4_HCLK_CTL_REG,
2463 .en_mask = BIT(4),
2464 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2465 .halt_bit = 7,
2466 },
2467 .c = {
2468 .dbg_name = "usb_hs4_p_clk",
2469 .ops = &clk_ops_branch,
2470 CLK_INIT(usb_hs4_p_clk.c),
2471 },
2472};
2473
Stephen Boyd94625ef2011-07-12 17:06:01 -07002474static struct branch_clk usb_hsic_p_clk = {
2475 .b = {
2476 .ctl_reg = USB_HSIC_HCLK_CTL_REG,
2477 .en_mask = BIT(4),
2478 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2479 .halt_bit = 28,
2480 },
2481 .c = {
2482 .dbg_name = "usb_hsic_p_clk",
2483 .ops = &clk_ops_branch,
2484 CLK_INIT(usb_hsic_p_clk.c),
2485 },
2486};
2487
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002488static struct branch_clk sdc1_p_clk = {
2489 .b = {
2490 .ctl_reg = SDCn_HCLK_CTL_REG(1),
2491 .en_mask = BIT(4),
2492 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2493 .halt_bit = 11,
2494 },
2495 .c = {
2496 .dbg_name = "sdc1_p_clk",
2497 .ops = &clk_ops_branch,
2498 CLK_INIT(sdc1_p_clk.c),
2499 },
2500};
2501
2502static struct branch_clk sdc2_p_clk = {
2503 .b = {
2504 .ctl_reg = SDCn_HCLK_CTL_REG(2),
2505 .en_mask = BIT(4),
2506 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2507 .halt_bit = 10,
2508 },
2509 .c = {
2510 .dbg_name = "sdc2_p_clk",
2511 .ops = &clk_ops_branch,
2512 CLK_INIT(sdc2_p_clk.c),
2513 },
2514};
2515
2516static struct branch_clk sdc3_p_clk = {
2517 .b = {
2518 .ctl_reg = SDCn_HCLK_CTL_REG(3),
2519 .en_mask = BIT(4),
2520 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2521 .halt_bit = 9,
2522 },
2523 .c = {
2524 .dbg_name = "sdc3_p_clk",
2525 .ops = &clk_ops_branch,
2526 CLK_INIT(sdc3_p_clk.c),
2527 },
2528};
2529
2530static struct branch_clk sdc4_p_clk = {
2531 .b = {
2532 .ctl_reg = SDCn_HCLK_CTL_REG(4),
2533 .en_mask = BIT(4),
2534 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2535 .halt_bit = 8,
2536 },
2537 .c = {
2538 .dbg_name = "sdc4_p_clk",
2539 .ops = &clk_ops_branch,
2540 CLK_INIT(sdc4_p_clk.c),
2541 },
2542};
2543
2544static struct branch_clk sdc5_p_clk = {
2545 .b = {
2546 .ctl_reg = SDCn_HCLK_CTL_REG(5),
2547 .en_mask = BIT(4),
2548 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2549 .halt_bit = 7,
2550 },
2551 .c = {
2552 .dbg_name = "sdc5_p_clk",
2553 .ops = &clk_ops_branch,
2554 CLK_INIT(sdc5_p_clk.c),
2555 },
2556};
2557
2558/* HW-Voteable Clocks */
2559static struct branch_clk adm0_clk = {
2560 .b = {
2561 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2562 .en_mask = BIT(2),
2563 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2564 .halt_check = HALT_VOTED,
2565 .halt_bit = 14,
2566 },
2567 .c = {
2568 .dbg_name = "adm0_clk",
2569 .ops = &clk_ops_branch,
2570 CLK_INIT(adm0_clk.c),
2571 },
2572};
2573
2574static struct branch_clk adm0_p_clk = {
2575 .b = {
2576 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2577 .en_mask = BIT(3),
2578 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2579 .halt_check = HALT_VOTED,
2580 .halt_bit = 13,
2581 },
2582 .c = {
2583 .dbg_name = "adm0_p_clk",
2584 .ops = &clk_ops_branch,
2585 CLK_INIT(adm0_p_clk.c),
2586 },
2587};
2588
2589static struct branch_clk pmic_arb0_p_clk = {
2590 .b = {
2591 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2592 .en_mask = BIT(8),
2593 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2594 .halt_check = HALT_VOTED,
2595 .halt_bit = 22,
2596 },
2597 .c = {
2598 .dbg_name = "pmic_arb0_p_clk",
2599 .ops = &clk_ops_branch,
2600 CLK_INIT(pmic_arb0_p_clk.c),
2601 },
2602};
2603
2604static struct branch_clk pmic_arb1_p_clk = {
2605 .b = {
2606 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2607 .en_mask = BIT(9),
2608 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2609 .halt_check = HALT_VOTED,
2610 .halt_bit = 21,
2611 },
2612 .c = {
2613 .dbg_name = "pmic_arb1_p_clk",
2614 .ops = &clk_ops_branch,
2615 CLK_INIT(pmic_arb1_p_clk.c),
2616 },
2617};
2618
2619static struct branch_clk pmic_ssbi2_clk = {
2620 .b = {
2621 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2622 .en_mask = BIT(7),
2623 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2624 .halt_check = HALT_VOTED,
2625 .halt_bit = 23,
2626 },
2627 .c = {
2628 .dbg_name = "pmic_ssbi2_clk",
2629 .ops = &clk_ops_branch,
2630 CLK_INIT(pmic_ssbi2_clk.c),
2631 },
2632};
2633
2634static struct branch_clk rpm_msg_ram_p_clk = {
2635 .b = {
2636 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2637 .en_mask = BIT(6),
2638 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2639 .halt_check = HALT_VOTED,
2640 .halt_bit = 12,
2641 },
2642 .c = {
2643 .dbg_name = "rpm_msg_ram_p_clk",
2644 .ops = &clk_ops_branch,
2645 CLK_INIT(rpm_msg_ram_p_clk.c),
2646 },
2647};
2648
2649/*
2650 * Multimedia Clocks
2651 */
2652
2653static struct branch_clk amp_clk = {
2654 .b = {
2655 .reset_reg = SW_RESET_CORE_REG,
2656 .reset_mask = BIT(20),
2657 },
2658 .c = {
2659 .dbg_name = "amp_clk",
2660 .ops = &clk_ops_reset,
2661 CLK_INIT(amp_clk.c),
2662 },
2663};
2664
Stephen Boyd94625ef2011-07-12 17:06:01 -07002665#define CLK_CAM(name, n, hb) \
2666 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002667 .b = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002668 .ctl_reg = CAMCLK##n##_CC_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002669 .en_mask = BIT(0), \
2670 .halt_reg = DBG_BUS_VEC_I_REG, \
2671 .halt_bit = hb, \
2672 }, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002673 .ns_reg = CAMCLK##n##_NS_REG, \
2674 .md_reg = CAMCLK##n##_MD_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002675 .root_en_mask = BIT(2), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002676 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002677 .ctl_mask = BM(7, 6), \
2678 .set_rate = set_rate_mnd_8, \
2679 .freq_tbl = clk_tbl_cam, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002680 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002681 .c = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002682 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002683 .ops = &clk_ops_rcg_8960, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002684 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002685 }, \
2686 }
2687#define F_CAM(f, s, d, m, n, v) \
2688 { \
2689 .freq_hz = f, \
2690 .src_clk = &s##_clk.c, \
2691 .md_val = MD8(8, m, 0, n), \
2692 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2693 .ctl_val = CC(6, n), \
2694 .mnd_en_mask = BIT(5) * !!(n), \
2695 .sys_vdd = v, \
2696 }
2697static struct clk_freq_tbl clk_tbl_cam[] = {
2698 F_CAM( 0, gnd, 1, 0, 0, NONE),
2699 F_CAM( 6000000, pll8, 4, 1, 16, LOW),
2700 F_CAM( 8000000, pll8, 4, 1, 12, LOW),
2701 F_CAM( 12000000, pll8, 4, 1, 8, LOW),
2702 F_CAM( 16000000, pll8, 4, 1, 6, LOW),
2703 F_CAM( 19200000, pll8, 4, 1, 5, LOW),
2704 F_CAM( 24000000, pll8, 4, 1, 4, LOW),
2705 F_CAM( 32000000, pll8, 4, 1, 3, LOW),
2706 F_CAM( 48000000, pll8, 4, 1, 2, LOW),
2707 F_CAM( 64000000, pll8, 3, 1, 2, LOW),
2708 F_CAM( 96000000, pll8, 4, 0, 0, NOMINAL),
2709 F_CAM(128000000, pll8, 3, 0, 0, NOMINAL),
2710 F_END
2711};
2712
Stephen Boyd94625ef2011-07-12 17:06:01 -07002713static CLK_CAM(cam0_clk, 0, 15);
2714static CLK_CAM(cam1_clk, 1, 16);
2715static CLK_CAM(cam2_clk, 2, 31);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002716
2717#define F_CSI(f, s, d, m, n, v) \
2718 { \
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), \
2725 .sys_vdd = v, \
2726 }
2727static struct clk_freq_tbl clk_tbl_csi[] = {
2728 F_CSI( 0, gnd, 1, 0, 0, NONE),
2729 F_CSI( 85330000, pll8, 1, 2, 9, LOW),
2730 F_CSI(177780000, pll2, 1, 2, 9, NOMINAL),
2731 F_END
2732};
2733
2734static struct rcg_clk csi0_src_clk = {
2735 .ns_reg = CSI0_NS_REG,
2736 .b = {
2737 .ctl_reg = CSI0_CC_REG,
2738 .halt_check = NOCHECK,
2739 },
2740 .md_reg = CSI0_MD_REG,
2741 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002742 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002743 .ctl_mask = BM(7, 6),
2744 .set_rate = set_rate_mnd,
2745 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002746 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002747 .c = {
2748 .dbg_name = "csi0_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002749 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002750 CLK_INIT(csi0_src_clk.c),
2751 },
2752};
2753
2754static struct branch_clk csi0_clk = {
2755 .b = {
2756 .ctl_reg = CSI0_CC_REG,
2757 .en_mask = BIT(0),
2758 .reset_reg = SW_RESET_CORE_REG,
2759 .reset_mask = BIT(8),
2760 .halt_reg = DBG_BUS_VEC_B_REG,
2761 .halt_bit = 13,
2762 },
2763 .parent = &csi0_src_clk.c,
2764 .c = {
2765 .dbg_name = "csi0_clk",
2766 .ops = &clk_ops_branch,
2767 CLK_INIT(csi0_clk.c),
2768 },
2769};
2770
2771static struct branch_clk csi0_phy_clk = {
2772 .b = {
2773 .ctl_reg = CSI0_CC_REG,
2774 .en_mask = BIT(8),
2775 .reset_reg = SW_RESET_CORE_REG,
2776 .reset_mask = BIT(29),
2777 .halt_reg = DBG_BUS_VEC_I_REG,
2778 .halt_bit = 9,
2779 },
2780 .parent = &csi0_src_clk.c,
2781 .c = {
2782 .dbg_name = "csi0_phy_clk",
2783 .ops = &clk_ops_branch,
2784 CLK_INIT(csi0_phy_clk.c),
2785 },
2786};
2787
2788static struct rcg_clk csi1_src_clk = {
2789 .ns_reg = CSI1_NS_REG,
2790 .b = {
2791 .ctl_reg = CSI1_CC_REG,
2792 .halt_check = NOCHECK,
2793 },
2794 .md_reg = CSI1_MD_REG,
2795 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002796 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002797 .ctl_mask = BM(7, 6),
2798 .set_rate = set_rate_mnd,
2799 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002800 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002801 .c = {
2802 .dbg_name = "csi1_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002803 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002804 CLK_INIT(csi1_src_clk.c),
2805 },
2806};
2807
2808static struct branch_clk csi1_clk = {
2809 .b = {
2810 .ctl_reg = CSI1_CC_REG,
2811 .en_mask = BIT(0),
2812 .reset_reg = SW_RESET_CORE_REG,
2813 .reset_mask = BIT(18),
2814 .halt_reg = DBG_BUS_VEC_B_REG,
2815 .halt_bit = 14,
2816 },
2817 .parent = &csi1_src_clk.c,
2818 .c = {
2819 .dbg_name = "csi1_clk",
2820 .ops = &clk_ops_branch,
2821 CLK_INIT(csi1_clk.c),
2822 },
2823};
2824
2825static struct branch_clk csi1_phy_clk = {
2826 .b = {
2827 .ctl_reg = CSI1_CC_REG,
2828 .en_mask = BIT(8),
2829 .reset_reg = SW_RESET_CORE_REG,
2830 .reset_mask = BIT(28),
2831 .halt_reg = DBG_BUS_VEC_I_REG,
2832 .halt_bit = 10,
2833 },
2834 .parent = &csi1_src_clk.c,
2835 .c = {
2836 .dbg_name = "csi1_phy_clk",
2837 .ops = &clk_ops_branch,
2838 CLK_INIT(csi1_phy_clk.c),
2839 },
2840};
2841
Stephen Boyd94625ef2011-07-12 17:06:01 -07002842static struct rcg_clk csi2_src_clk = {
2843 .ns_reg = CSI2_NS_REG,
2844 .b = {
2845 .ctl_reg = CSI2_CC_REG,
2846 .halt_check = NOCHECK,
2847 },
2848 .md_reg = CSI2_MD_REG,
2849 .root_en_mask = BIT(2),
2850 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
2851 .ctl_mask = BM(7, 6),
2852 .set_rate = set_rate_mnd,
2853 .freq_tbl = clk_tbl_csi,
2854 .current_freq = &rcg_dummy_freq,
2855 .c = {
2856 .dbg_name = "csi2_src_clk",
2857 .ops = &clk_ops_rcg_8960,
2858 CLK_INIT(csi2_src_clk.c),
2859 },
2860};
2861
2862static struct branch_clk csi2_clk = {
2863 .b = {
2864 .ctl_reg = CSI2_CC_REG,
2865 .en_mask = BIT(0),
2866 .reset_reg = SW_RESET_CORE2_REG,
2867 .reset_mask = BIT(2),
2868 .halt_reg = DBG_BUS_VEC_B_REG,
2869 .halt_bit = 29,
2870 },
2871 .parent = &csi2_src_clk.c,
2872 .c = {
2873 .dbg_name = "csi2_clk",
2874 .ops = &clk_ops_branch,
2875 CLK_INIT(csi2_clk.c),
2876 },
2877};
2878
2879static struct branch_clk csi2_phy_clk = {
2880 .b = {
2881 .ctl_reg = CSI2_CC_REG,
2882 .en_mask = BIT(8),
2883 .reset_reg = SW_RESET_CORE_REG,
2884 .reset_mask = BIT(31),
2885 .halt_reg = DBG_BUS_VEC_I_REG,
2886 .halt_bit = 29,
2887 },
2888 .parent = &csi2_src_clk.c,
2889 .c = {
2890 .dbg_name = "csi2_phy_clk",
2891 .ops = &clk_ops_branch,
2892 CLK_INIT(csi2_phy_clk.c),
2893 },
2894};
2895
2896/*
2897 * The csi pix and csi rdi clocks have two bits in two registers to control a
2898 * three input mux. So we have the generic rcg_clk_enable() path handle the
2899 * first bit, and this function handle the second bit.
2900 */
2901static void set_rate_pix_rdi(struct rcg_clk *clk, struct clk_freq_tbl *nf)
2902{
2903 u32 reg = readl_relaxed(MISC_CC3_REG);
2904 u32 bit = (u32)nf->extra_freq_data;
2905 if (nf->freq_hz == 2)
2906 reg |= bit;
2907 else
2908 reg &= ~bit;
2909 writel_relaxed(reg, MISC_CC3_REG);
2910}
2911
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002912#define F_CSI_PIX(s) \
2913 { \
2914 .src_clk = &csi##s##_clk.c, \
2915 .freq_hz = s, \
2916 .ns_val = BVAL(25, 25, s), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002917 .extra_freq_data = (void *)BIT(13), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002918 }
2919static struct clk_freq_tbl clk_tbl_csi_pix[] = {
2920 F_CSI_PIX(0), /* CSI0 source */
2921 F_CSI_PIX(1), /* CSI1 source */
Stephen Boyd94625ef2011-07-12 17:06:01 -07002922 F_CSI_PIX(2), /* CSI2 source */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002923 F_END
2924};
2925
2926static struct rcg_clk csi_pix_clk = {
2927 .b = {
2928 .ctl_reg = MISC_CC_REG,
2929 .en_mask = BIT(26),
2930 .halt_check = DELAY,
2931 .reset_reg = SW_RESET_CORE_REG,
2932 .reset_mask = BIT(26),
2933 },
2934 .ns_reg = MISC_CC_REG,
2935 .ns_mask = BIT(25),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002936 .set_rate = set_rate_pix_rdi,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002937 .freq_tbl = clk_tbl_csi_pix,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002938 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002939 .c = {
2940 .dbg_name = "csi_pix_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002941 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002942 CLK_INIT(csi_pix_clk.c),
2943 },
2944};
2945
Stephen Boyd94625ef2011-07-12 17:06:01 -07002946#define F_CSI_PIX1(s) \
2947 { \
2948 .src_clk = &csi##s##_clk.c, \
2949 .freq_hz = s, \
2950 .ns_val = BVAL(9, 8, s), \
2951 }
2952static struct clk_freq_tbl clk_tbl_csi_pix1[] = {
2953 F_CSI_PIX1(0), /* CSI0 source */
2954 F_CSI_PIX1(1), /* CSI1 source */
2955 F_CSI_PIX1(2), /* CSI2 source */
2956 F_END
2957};
2958
2959static struct rcg_clk csi_pix1_clk = {
2960 .b = {
2961 .ctl_reg = MISC_CC3_REG,
2962 .en_mask = BIT(10),
2963 .halt_check = DELAY,
2964 .reset_reg = SW_RESET_CORE_REG,
2965 .reset_mask = BIT(30),
2966 },
2967 .ns_reg = MISC_CC3_REG,
2968 .ns_mask = BM(9, 8),
2969 .set_rate = set_rate_nop,
2970 .freq_tbl = clk_tbl_csi_pix1,
2971 .current_freq = &rcg_dummy_freq,
2972 .c = {
2973 .dbg_name = "csi_pix1_clk",
2974 .ops = &clk_ops_rcg_8960,
2975 CLK_INIT(csi_pix1_clk.c),
2976 },
2977};
2978
2979#define F_CSI_RDI(s) \
2980 { \
2981 .src_clk = &csi##s##_clk.c, \
2982 .freq_hz = s, \
2983 .ns_val = BVAL(12, 12, s), \
2984 .extra_freq_data = (void *)BIT(12), \
2985 }
2986static struct clk_freq_tbl clk_tbl_csi_rdi[] = {
2987 F_CSI_RDI(0), /* CSI0 source */
2988 F_CSI_RDI(1), /* CSI1 source */
2989 F_CSI_RDI(2), /* CSI2 source */
2990 F_END
2991};
2992
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002993static struct rcg_clk csi_rdi_clk = {
2994 .b = {
2995 .ctl_reg = MISC_CC_REG,
2996 .en_mask = BIT(13),
2997 .halt_check = DELAY,
2998 .reset_reg = SW_RESET_CORE_REG,
2999 .reset_mask = BIT(27),
3000 },
3001 .ns_reg = MISC_CC_REG,
3002 .ns_mask = BIT(12),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003003 .set_rate = set_rate_pix_rdi,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003004 .freq_tbl = clk_tbl_csi_rdi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003005 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003006 .c = {
3007 .dbg_name = "csi_rdi_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003008 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003009 CLK_INIT(csi_rdi_clk.c),
3010 },
3011};
3012
Stephen Boyd94625ef2011-07-12 17:06:01 -07003013#define F_CSI_RDI1(s) \
3014 { \
3015 .src_clk = &csi##s##_clk.c, \
3016 .freq_hz = s, \
3017 .ns_val = BVAL(1, 0, s), \
3018 }
3019static struct clk_freq_tbl clk_tbl_csi_rdi1[] = {
3020 F_CSI_RDI1(0), /* CSI0 source */
3021 F_CSI_RDI1(1), /* CSI1 source */
3022 F_CSI_RDI1(2), /* CSI2 source */
3023 F_END
3024};
3025
3026static struct rcg_clk csi_rdi1_clk = {
3027 .b = {
3028 .ctl_reg = MISC_CC3_REG,
3029 .en_mask = BIT(2),
3030 .halt_check = DELAY,
3031 .reset_reg = SW_RESET_CORE2_REG,
3032 .reset_mask = BIT(1),
3033 },
3034 .ns_reg = MISC_CC3_REG,
3035 .ns_mask = BM(1, 0),
3036 .set_rate = set_rate_nop,
3037 .freq_tbl = clk_tbl_csi_rdi1,
3038 .current_freq = &rcg_dummy_freq,
3039 .c = {
3040 .dbg_name = "csi_rdi1_clk",
3041 .ops = &clk_ops_rcg_8960,
3042 CLK_INIT(csi_rdi1_clk.c),
3043 },
3044};
3045
3046#define F_CSI_RDI2(s) \
3047 { \
3048 .src_clk = &csi##s##_clk.c, \
3049 .freq_hz = s, \
3050 .ns_val = BVAL(5, 4, s), \
3051 }
3052static struct clk_freq_tbl clk_tbl_csi_rdi2[] = {
3053 F_CSI_RDI2(0), /* CSI0 source */
3054 F_CSI_RDI2(1), /* CSI1 source */
3055 F_CSI_RDI2(2), /* CSI2 source */
3056 F_END
3057};
3058
3059static struct rcg_clk csi_rdi2_clk = {
3060 .b = {
3061 .ctl_reg = MISC_CC3_REG,
3062 .en_mask = BIT(6),
3063 .halt_check = DELAY,
3064 .reset_reg = SW_RESET_CORE2_REG,
3065 .reset_mask = BIT(0),
3066 },
3067 .ns_reg = MISC_CC3_REG,
3068 .ns_mask = BM(5, 4),
3069 .set_rate = set_rate_nop,
3070 .freq_tbl = clk_tbl_csi_rdi2,
3071 .current_freq = &rcg_dummy_freq,
3072 .c = {
3073 .dbg_name = "csi_rdi2_clk",
3074 .ops = &clk_ops_rcg_8960,
3075 CLK_INIT(csi_rdi2_clk.c),
3076 },
3077};
3078
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003079#define F_CSI_PHYTIMER(f, s, d, m, n, v) \
3080 { \
3081 .freq_hz = f, \
3082 .src_clk = &s##_clk.c, \
3083 .md_val = MD8(8, m, 0, n), \
3084 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3085 .ctl_val = CC(6, n), \
3086 .mnd_en_mask = BIT(5) * !!(n), \
3087 .sys_vdd = v, \
3088 }
3089static struct clk_freq_tbl clk_tbl_csi_phytimer[] = {
3090 F_CSI_PHYTIMER( 0, gnd, 1, 0, 0, NONE),
3091 F_CSI_PHYTIMER( 85330000, pll8, 1, 2, 9, LOW),
3092 F_CSI_PHYTIMER(177780000, pll2, 1, 2, 9, NOMINAL),
3093 F_END
3094};
3095
3096static struct rcg_clk csiphy_timer_src_clk = {
3097 .ns_reg = CSIPHYTIMER_NS_REG,
3098 .b = {
3099 .ctl_reg = CSIPHYTIMER_CC_REG,
3100 .halt_check = NOCHECK,
3101 },
3102 .md_reg = CSIPHYTIMER_MD_REG,
3103 .root_en_mask = BIT(2),
3104 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
3105 .ctl_mask = BM(7, 6),
3106 .set_rate = set_rate_mnd_8,
3107 .freq_tbl = clk_tbl_csi_phytimer,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003108 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003109 .c = {
3110 .dbg_name = "csiphy_timer_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003111 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003112 CLK_INIT(csiphy_timer_src_clk.c),
3113 },
3114};
3115
3116static struct branch_clk csi0phy_timer_clk = {
3117 .b = {
3118 .ctl_reg = CSIPHYTIMER_CC_REG,
3119 .en_mask = BIT(0),
3120 .halt_reg = DBG_BUS_VEC_I_REG,
3121 .halt_bit = 17,
3122 },
3123 .parent = &csiphy_timer_src_clk.c,
3124 .c = {
3125 .dbg_name = "csi0phy_timer_clk",
3126 .ops = &clk_ops_branch,
3127 CLK_INIT(csi0phy_timer_clk.c),
3128 },
3129};
3130
3131static struct branch_clk csi1phy_timer_clk = {
3132 .b = {
3133 .ctl_reg = CSIPHYTIMER_CC_REG,
3134 .en_mask = BIT(9),
3135 .halt_reg = DBG_BUS_VEC_I_REG,
3136 .halt_bit = 18,
3137 },
3138 .parent = &csiphy_timer_src_clk.c,
3139 .c = {
3140 .dbg_name = "csi1phy_timer_clk",
3141 .ops = &clk_ops_branch,
3142 CLK_INIT(csi1phy_timer_clk.c),
3143 },
3144};
3145
Stephen Boyd94625ef2011-07-12 17:06:01 -07003146static struct branch_clk csi2phy_timer_clk = {
3147 .b = {
3148 .ctl_reg = CSIPHYTIMER_CC_REG,
3149 .en_mask = BIT(11),
3150 .halt_reg = DBG_BUS_VEC_I_REG,
3151 .halt_bit = 30,
3152 },
3153 .parent = &csiphy_timer_src_clk.c,
3154 .c = {
3155 .dbg_name = "csi2phy_timer_clk",
3156 .ops = &clk_ops_branch,
3157 CLK_INIT(csi2phy_timer_clk.c),
3158 },
3159};
3160
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003161#define F_DSI(d) \
3162 { \
3163 .freq_hz = d, \
3164 .ns_val = BVAL(15, 12, (d-1)), \
3165 }
3166/*
3167 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
3168 * without this clock driver knowing. So, overload the clk_set_rate() to set
3169 * the divider (1 to 16) of the clock with respect to the PLL rate.
3170 */
3171static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
3172 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
3173 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
3174 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
3175 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
3176 F_END
3177};
3178
3179static struct rcg_clk dsi1_byte_clk = {
3180 .b = {
3181 .ctl_reg = DSI1_BYTE_CC_REG,
3182 .en_mask = BIT(0),
3183 .reset_reg = SW_RESET_CORE_REG,
3184 .reset_mask = BIT(7),
3185 .halt_reg = DBG_BUS_VEC_B_REG,
3186 .halt_bit = 21,
3187 },
3188 .ns_reg = DSI1_BYTE_NS_REG,
3189 .root_en_mask = BIT(2),
3190 .ns_mask = BM(15, 12),
3191 .set_rate = set_rate_nop,
3192 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003193 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003194 .c = {
3195 .dbg_name = "dsi1_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003196 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003197 CLK_INIT(dsi1_byte_clk.c),
3198 },
3199};
3200
3201static struct rcg_clk dsi2_byte_clk = {
3202 .b = {
3203 .ctl_reg = DSI2_BYTE_CC_REG,
3204 .en_mask = BIT(0),
3205 .reset_reg = SW_RESET_CORE_REG,
3206 .reset_mask = BIT(25),
3207 .halt_reg = DBG_BUS_VEC_B_REG,
3208 .halt_bit = 20,
3209 },
3210 .ns_reg = DSI2_BYTE_NS_REG,
3211 .root_en_mask = BIT(2),
3212 .ns_mask = BM(15, 12),
3213 .set_rate = set_rate_nop,
3214 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003215 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003216 .c = {
3217 .dbg_name = "dsi2_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003218 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003219 CLK_INIT(dsi2_byte_clk.c),
3220 },
3221};
3222
3223static struct rcg_clk dsi1_esc_clk = {
3224 .b = {
3225 .ctl_reg = DSI1_ESC_CC_REG,
3226 .en_mask = BIT(0),
3227 .reset_reg = SW_RESET_CORE_REG,
3228 .halt_reg = DBG_BUS_VEC_I_REG,
3229 .halt_bit = 1,
3230 },
3231 .ns_reg = DSI1_ESC_NS_REG,
3232 .root_en_mask = BIT(2),
3233 .ns_mask = BM(15, 12),
3234 .set_rate = set_rate_nop,
3235 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003236 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003237 .c = {
3238 .dbg_name = "dsi1_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003239 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003240 CLK_INIT(dsi1_esc_clk.c),
3241 },
3242};
3243
3244static struct rcg_clk dsi2_esc_clk = {
3245 .b = {
3246 .ctl_reg = DSI2_ESC_CC_REG,
3247 .en_mask = BIT(0),
3248 .halt_reg = DBG_BUS_VEC_I_REG,
3249 .halt_bit = 3,
3250 },
3251 .ns_reg = DSI2_ESC_NS_REG,
3252 .root_en_mask = BIT(2),
3253 .ns_mask = BM(15, 12),
3254 .set_rate = set_rate_nop,
3255 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003256 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003257 .c = {
3258 .dbg_name = "dsi2_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003259 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003260 CLK_INIT(dsi2_esc_clk.c),
3261 },
3262};
3263
3264#define F_GFX2D(f, s, m, n, v) \
3265 { \
3266 .freq_hz = f, \
3267 .src_clk = &s##_clk.c, \
3268 .md_val = MD4(4, m, 0, n), \
3269 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
3270 .ctl_val = CC_BANKED(9, 6, n), \
3271 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
3272 .sys_vdd = v, \
3273 }
3274static struct clk_freq_tbl clk_tbl_gfx2d[] = {
3275 F_GFX2D( 0, gnd, 0, 0, NONE),
3276 F_GFX2D( 27000000, pxo, 0, 0, LOW),
3277 F_GFX2D( 48000000, pll8, 1, 8, LOW),
3278 F_GFX2D( 54857000, pll8, 1, 7, LOW),
3279 F_GFX2D( 64000000, pll8, 1, 6, LOW),
3280 F_GFX2D( 76800000, pll8, 1, 5, LOW),
3281 F_GFX2D( 96000000, pll8, 1, 4, LOW),
3282 F_GFX2D(128000000, pll8, 1, 3, NOMINAL),
3283 F_GFX2D(145455000, pll2, 2, 11, NOMINAL),
3284 F_GFX2D(160000000, pll2, 1, 5, NOMINAL),
3285 F_GFX2D(177778000, pll2, 2, 9, NOMINAL),
3286 F_GFX2D(200000000, pll2, 1, 4, NOMINAL),
3287 F_GFX2D(228571000, pll2, 2, 7, HIGH),
3288 F_END
3289};
3290
3291static struct bank_masks bmnd_info_gfx2d0 = {
3292 .bank_sel_mask = BIT(11),
3293 .bank0_mask = {
3294 .md_reg = GFX2D0_MD0_REG,
3295 .ns_mask = BM(23, 20) | BM(5, 3),
3296 .rst_mask = BIT(25),
3297 .mnd_en_mask = BIT(8),
3298 .mode_mask = BM(10, 9),
3299 },
3300 .bank1_mask = {
3301 .md_reg = GFX2D0_MD1_REG,
3302 .ns_mask = BM(19, 16) | BM(2, 0),
3303 .rst_mask = BIT(24),
3304 .mnd_en_mask = BIT(5),
3305 .mode_mask = BM(7, 6),
3306 },
3307};
3308
3309static struct rcg_clk gfx2d0_clk = {
3310 .b = {
3311 .ctl_reg = GFX2D0_CC_REG,
3312 .en_mask = BIT(0),
3313 .reset_reg = SW_RESET_CORE_REG,
3314 .reset_mask = BIT(14),
3315 .halt_reg = DBG_BUS_VEC_A_REG,
3316 .halt_bit = 9,
3317 },
3318 .ns_reg = GFX2D0_NS_REG,
3319 .root_en_mask = BIT(2),
3320 .set_rate = set_rate_mnd_banked,
3321 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003322 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003323 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003324 .c = {
3325 .dbg_name = "gfx2d0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003326 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003327 CLK_INIT(gfx2d0_clk.c),
3328 },
3329};
3330
3331static struct bank_masks bmnd_info_gfx2d1 = {
3332 .bank_sel_mask = BIT(11),
3333 .bank0_mask = {
3334 .md_reg = GFX2D1_MD0_REG,
3335 .ns_mask = BM(23, 20) | BM(5, 3),
3336 .rst_mask = BIT(25),
3337 .mnd_en_mask = BIT(8),
3338 .mode_mask = BM(10, 9),
3339 },
3340 .bank1_mask = {
3341 .md_reg = GFX2D1_MD1_REG,
3342 .ns_mask = BM(19, 16) | BM(2, 0),
3343 .rst_mask = BIT(24),
3344 .mnd_en_mask = BIT(5),
3345 .mode_mask = BM(7, 6),
3346 },
3347};
3348
3349static struct rcg_clk gfx2d1_clk = {
3350 .b = {
3351 .ctl_reg = GFX2D1_CC_REG,
3352 .en_mask = BIT(0),
3353 .reset_reg = SW_RESET_CORE_REG,
3354 .reset_mask = BIT(13),
3355 .halt_reg = DBG_BUS_VEC_A_REG,
3356 .halt_bit = 14,
3357 },
3358 .ns_reg = GFX2D1_NS_REG,
3359 .root_en_mask = BIT(2),
3360 .set_rate = set_rate_mnd_banked,
3361 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003362 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003363 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003364 .c = {
3365 .dbg_name = "gfx2d1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003366 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003367 CLK_INIT(gfx2d1_clk.c),
3368 },
3369};
3370
3371#define F_GFX3D(f, s, m, n, v) \
3372 { \
3373 .freq_hz = f, \
3374 .src_clk = &s##_clk.c, \
3375 .md_val = MD4(4, m, 0, n), \
3376 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3377 .ctl_val = CC_BANKED(9, 6, n), \
3378 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
3379 .sys_vdd = v, \
3380 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003381
3382static struct clk_freq_tbl clk_tbl_gfx3d_8960[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003383 F_GFX3D( 0, gnd, 0, 0, NONE),
3384 F_GFX3D( 27000000, pxo, 0, 0, LOW),
3385 F_GFX3D( 48000000, pll8, 1, 8, LOW),
3386 F_GFX3D( 54857000, pll8, 1, 7, LOW),
3387 F_GFX3D( 64000000, pll8, 1, 6, LOW),
3388 F_GFX3D( 76800000, pll8, 1, 5, LOW),
3389 F_GFX3D( 96000000, pll8, 1, 4, LOW),
Stephen Boydd7797422011-08-10 16:01:45 -07003390 F_GFX3D(128000000, pll8, 1, 3, LOW),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003391 F_GFX3D(145455000, pll2, 2, 11, NOMINAL),
3392 F_GFX3D(160000000, pll2, 1, 5, NOMINAL),
3393 F_GFX3D(177778000, pll2, 2, 9, NOMINAL),
3394 F_GFX3D(200000000, pll2, 1, 4, NOMINAL),
3395 F_GFX3D(228571000, pll2, 2, 7, NOMINAL),
3396 F_GFX3D(266667000, pll2, 1, 3, NOMINAL),
3397 F_GFX3D(320000000, pll2, 2, 5, HIGH),
3398 F_END
3399};
3400
Tianyi Gou41515e22011-09-01 19:37:43 -07003401static struct clk_freq_tbl clk_tbl_gfx3d_8960_v2[] = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003402 F_GFX3D( 0, gnd, 0, 0, NONE),
3403 F_GFX3D( 27000000, pxo, 0, 0, LOW),
3404 F_GFX3D( 48000000, pll8, 1, 8, LOW),
3405 F_GFX3D( 54857000, pll8, 1, 7, LOW),
3406 F_GFX3D( 64000000, pll8, 1, 6, LOW),
3407 F_GFX3D( 76800000, pll8, 1, 5, LOW),
3408 F_GFX3D( 96000000, pll8, 1, 4, LOW),
3409 F_GFX3D(128000000, pll8, 1, 3, LOW),
3410 F_GFX3D(145455000, pll2, 2, 11, NOMINAL),
3411 F_GFX3D(160000000, pll2, 1, 5, NOMINAL),
3412 F_GFX3D(177778000, pll2, 2, 9, NOMINAL),
3413 F_GFX3D(200000000, pll2, 1, 4, NOMINAL),
3414 F_GFX3D(228571000, pll2, 2, 7, NOMINAL),
3415 F_GFX3D(266667000, pll2, 1, 3, NOMINAL),
3416 F_GFX3D(300000000, pll3, 1, 4, NOMINAL),
3417 F_GFX3D(320000000, pll2, 2, 5, HIGH),
3418 F_GFX3D(400000000, pll2, 1, 2, HIGH),
3419 F_END
3420};
3421
Tianyi Gou621f8742011-09-01 21:45:01 -07003422/* TODO: need to add 325MHz back once it is fixed in the simulation model */
Tianyi Gou41515e22011-09-01 19:37:43 -07003423static struct clk_freq_tbl clk_tbl_gfx3d_8064[] = {
3424 F_GFX3D( 0, gnd, 0, 0, NONE),
3425 F_GFX3D( 27000000, pxo, 0, 0, LOW),
3426 F_GFX3D( 48000000, pll8, 1, 8, LOW),
3427 F_GFX3D( 54857000, pll8, 1, 7, LOW),
3428 F_GFX3D( 64000000, pll8, 1, 6, LOW),
3429 F_GFX3D( 76800000, pll8, 1, 5, LOW),
3430 F_GFX3D( 96000000, pll8, 1, 4, LOW),
3431 F_GFX3D(128000000, pll8, 1, 3, LOW),
3432 F_GFX3D(145455000, pll2, 2, 11, NOMINAL),
3433 F_GFX3D(160000000, pll2, 1, 5, NOMINAL),
3434 F_GFX3D(177778000, pll2, 2, 9, NOMINAL),
3435 F_GFX3D(200000000, pll2, 1, 4, NOMINAL),
3436 F_GFX3D(228571000, pll2, 2, 7, NOMINAL),
3437 F_GFX3D(266667000, pll2, 1, 3, NOMINAL),
Tianyi Gou41515e22011-09-01 19:37:43 -07003438 F_GFX3D(400000000, pll2, 1, 2, HIGH),
3439 F_END
3440};
3441
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003442static struct bank_masks bmnd_info_gfx3d = {
3443 .bank_sel_mask = BIT(11),
3444 .bank0_mask = {
3445 .md_reg = GFX3D_MD0_REG,
3446 .ns_mask = BM(21, 18) | BM(5, 3),
3447 .rst_mask = BIT(23),
3448 .mnd_en_mask = BIT(8),
3449 .mode_mask = BM(10, 9),
3450 },
3451 .bank1_mask = {
3452 .md_reg = GFX3D_MD1_REG,
3453 .ns_mask = BM(17, 14) | BM(2, 0),
3454 .rst_mask = BIT(22),
3455 .mnd_en_mask = BIT(5),
3456 .mode_mask = BM(7, 6),
3457 },
3458};
3459
3460static struct rcg_clk gfx3d_clk = {
3461 .b = {
3462 .ctl_reg = GFX3D_CC_REG,
3463 .en_mask = BIT(0),
3464 .reset_reg = SW_RESET_CORE_REG,
3465 .reset_mask = BIT(12),
3466 .halt_reg = DBG_BUS_VEC_A_REG,
3467 .halt_bit = 4,
3468 },
3469 .ns_reg = GFX3D_NS_REG,
3470 .root_en_mask = BIT(2),
3471 .set_rate = set_rate_mnd_banked,
Tianyi Gou41515e22011-09-01 19:37:43 -07003472 .freq_tbl = clk_tbl_gfx3d_8960,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003473 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003474 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003475 .c = {
3476 .dbg_name = "gfx3d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003477 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003478 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003479 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003480 },
3481};
3482
Tianyi Gou621f8742011-09-01 21:45:01 -07003483#define F_VCAP(f, s, m, n, v) \
3484 { \
3485 .freq_hz = f, \
3486 .src_clk = &s##_clk.c, \
3487 .md_val = MD4(4, m, 0, n), \
3488 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3489 .ctl_val = CC_BANKED(9, 6, n), \
3490 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
3491 .sys_vdd = v, \
3492 }
3493
3494static struct clk_freq_tbl clk_tbl_vcap[] = {
3495 F_VCAP( 0, gnd, 0, 0, NONE),
3496 F_VCAP( 27000000, pxo, 0, 0, LOW),
3497 F_VCAP( 54860000, pll8, 1, 7, LOW),
3498 F_VCAP( 64000000, pll8, 1, 6, LOW),
3499 F_VCAP( 76800000, pll8, 1, 5, LOW),
3500 F_VCAP(128000000, pll8, 1, 3, NOMINAL),
3501 F_VCAP(160000000, pll2, 1, 5, NOMINAL),
3502 F_VCAP(200000000, pll2, 1, 4, NOMINAL),
3503 F_END
3504};
3505
3506static struct bank_masks bmnd_info_vcap = {
3507 .bank_sel_mask = BIT(11),
3508 .bank0_mask = {
3509 .md_reg = VCAP_MD0_REG,
3510 .ns_mask = BM(21, 18) | BM(5, 3),
3511 .rst_mask = BIT(23),
3512 .mnd_en_mask = BIT(8),
3513 .mode_mask = BM(10, 9),
3514 },
3515 .bank1_mask = {
3516 .md_reg = VCAP_MD1_REG,
3517 .ns_mask = BM(17, 14) | BM(2, 0),
3518 .rst_mask = BIT(22),
3519 .mnd_en_mask = BIT(5),
3520 .mode_mask = BM(7, 6),
3521 },
3522};
3523
3524static struct rcg_clk vcap_clk = {
3525 .b = {
3526 .ctl_reg = VCAP_CC_REG,
3527 .en_mask = BIT(0),
3528 .halt_reg = DBG_BUS_VEC_J_REG,
3529 .halt_bit = 15,
3530 },
3531 .ns_reg = VCAP_NS_REG,
3532 .root_en_mask = BIT(2),
3533 .set_rate = set_rate_mnd_banked,
3534 .freq_tbl = clk_tbl_vcap,
3535 .bank_info = &bmnd_info_vcap,
3536 .current_freq = &rcg_dummy_freq,
3537 .c = {
3538 .dbg_name = "vcap_clk",
3539 .ops = &clk_ops_rcg_8960,
3540 .depends = &vcap_axi_clk.c,
3541 CLK_INIT(vcap_clk.c),
3542 },
3543};
3544
3545static struct branch_clk vcap_npl_clk = {
3546 .b = {
3547 .ctl_reg = VCAP_CC_REG,
3548 .en_mask = BIT(13),
3549 .halt_reg = DBG_BUS_VEC_J_REG,
3550 .halt_bit = 25,
3551 },
3552 .parent = &vcap_clk.c,
3553 .c = {
3554 .dbg_name = "vcap_npl_clk",
3555 .ops = &clk_ops_branch,
3556 CLK_INIT(vcap_npl_clk.c),
3557 },
3558};
3559
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003560#define F_IJPEG(f, s, d, m, n, v) \
3561 { \
3562 .freq_hz = f, \
3563 .src_clk = &s##_clk.c, \
3564 .md_val = MD8(8, m, 0, n), \
3565 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
3566 .ctl_val = CC(6, n), \
3567 .mnd_en_mask = BIT(5) * !!(n), \
3568 .sys_vdd = v, \
3569 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003570
3571static struct clk_freq_tbl clk_tbl_ijpeg_8960[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003572 F_IJPEG( 0, gnd, 1, 0, 0, NONE),
3573 F_IJPEG( 27000000, pxo, 1, 0, 0, LOW),
3574 F_IJPEG( 36570000, pll8, 1, 2, 21, LOW),
3575 F_IJPEG( 54860000, pll8, 7, 0, 0, LOW),
3576 F_IJPEG( 96000000, pll8, 4, 0, 0, LOW),
3577 F_IJPEG(109710000, pll8, 1, 2, 7, LOW),
3578 F_IJPEG(128000000, pll8, 3, 0, 0, NOMINAL),
3579 F_IJPEG(153600000, pll8, 1, 2, 5, NOMINAL),
3580 F_IJPEG(200000000, pll2, 4, 0, 0, NOMINAL),
3581 F_IJPEG(228571000, pll2, 1, 2, 7, NOMINAL),
Matt Wagantall393bdb52011-09-07 10:15:28 -07003582 F_IJPEG(266667000, pll2, 1, 1, 3, NOMINAL),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003583 F_IJPEG(320000000, pll2, 1, 2, 5, HIGH),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003584 F_END
3585};
3586
Tianyi Gou41515e22011-09-01 19:37:43 -07003587static struct clk_freq_tbl clk_tbl_ijpeg_8064[] = {
3588 F_IJPEG( 0, gnd, 1, 0, 0, NONE),
3589 F_IJPEG( 36570000, pll8, 1, 2, 21, LOW),
3590 F_IJPEG( 54860000, pll8, 7, 0, 0, LOW),
3591 F_IJPEG( 96000000, pll8, 4, 0, 0, LOW),
3592 F_IJPEG(109710000, pll8, 1, 2, 7, LOW),
3593 F_IJPEG(128000000, pll8, 3, 0, 0, LOW),
3594 F_IJPEG(153600000, pll8, 1, 2, 5, NOMINAL),
3595 F_IJPEG(200000000, pll2, 4, 0, 0, NOMINAL),
Tianyi Gou621f8742011-09-01 21:45:01 -07003596 F_IJPEG(228571000, pll2, 1, 2, 7, NOMINAL),
Tianyi Gou41515e22011-09-01 19:37:43 -07003597 F_IJPEG(320000000, pll2, 1, 2, 5, HIGH),
3598 F_END
3599};
3600
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003601static struct rcg_clk ijpeg_clk = {
3602 .b = {
3603 .ctl_reg = IJPEG_CC_REG,
3604 .en_mask = BIT(0),
3605 .reset_reg = SW_RESET_CORE_REG,
3606 .reset_mask = BIT(9),
3607 .halt_reg = DBG_BUS_VEC_A_REG,
3608 .halt_bit = 24,
3609 },
3610 .ns_reg = IJPEG_NS_REG,
3611 .md_reg = IJPEG_MD_REG,
3612 .root_en_mask = BIT(2),
3613 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
3614 .ctl_mask = BM(7, 6),
3615 .set_rate = set_rate_mnd,
Tianyi Gou41515e22011-09-01 19:37:43 -07003616 .freq_tbl = clk_tbl_ijpeg_8960,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003617 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003618 .c = {
3619 .dbg_name = "ijpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003620 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003621 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003622 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003623 },
3624};
3625
3626#define F_JPEGD(f, s, d, v) \
3627 { \
3628 .freq_hz = f, \
3629 .src_clk = &s##_clk.c, \
3630 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
3631 .sys_vdd = v, \
3632 }
3633static struct clk_freq_tbl clk_tbl_jpegd[] = {
3634 F_JPEGD( 0, gnd, 1, NONE),
3635 F_JPEGD( 64000000, pll8, 6, LOW),
3636 F_JPEGD( 76800000, pll8, 5, LOW),
3637 F_JPEGD( 96000000, pll8, 4, LOW),
3638 F_JPEGD(160000000, pll2, 5, NOMINAL),
3639 F_JPEGD(200000000, pll2, 4, NOMINAL),
3640 F_END
3641};
3642
3643static struct rcg_clk jpegd_clk = {
3644 .b = {
3645 .ctl_reg = JPEGD_CC_REG,
3646 .en_mask = BIT(0),
3647 .reset_reg = SW_RESET_CORE_REG,
3648 .reset_mask = BIT(19),
3649 .halt_reg = DBG_BUS_VEC_A_REG,
3650 .halt_bit = 19,
3651 },
3652 .ns_reg = JPEGD_NS_REG,
3653 .root_en_mask = BIT(2),
3654 .ns_mask = (BM(15, 12) | BM(2, 0)),
3655 .set_rate = set_rate_nop,
3656 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003657 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003658 .c = {
3659 .dbg_name = "jpegd_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003660 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003661 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003662 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003663 },
3664};
3665
3666#define F_MDP(f, s, m, n, v) \
3667 { \
3668 .freq_hz = f, \
3669 .src_clk = &s##_clk.c, \
3670 .md_val = MD8(8, m, 0, n), \
3671 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
3672 .ctl_val = CC_BANKED(9, 6, n), \
3673 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
3674 .sys_vdd = v, \
3675 }
Tianyi Gou621f8742011-09-01 21:45:01 -07003676static struct clk_freq_tbl clk_tbl_mdp_8960[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003677 F_MDP( 0, gnd, 0, 0, NONE),
3678 F_MDP( 9600000, pll8, 1, 40, LOW),
3679 F_MDP( 13710000, pll8, 1, 28, LOW),
3680 F_MDP( 27000000, pxo, 0, 0, LOW),
3681 F_MDP( 29540000, pll8, 1, 13, LOW),
3682 F_MDP( 34910000, pll8, 1, 11, LOW),
3683 F_MDP( 38400000, pll8, 1, 10, LOW),
3684 F_MDP( 59080000, pll8, 2, 13, LOW),
3685 F_MDP( 76800000, pll8, 1, 5, LOW),
3686 F_MDP( 85330000, pll8, 2, 9, LOW),
3687 F_MDP( 96000000, pll8, 1, 4, NOMINAL),
3688 F_MDP(128000000, pll8, 1, 3, NOMINAL),
3689 F_MDP(160000000, pll2, 1, 5, NOMINAL),
3690 F_MDP(177780000, pll2, 2, 9, NOMINAL),
3691 F_MDP(200000000, pll2, 1, 4, NOMINAL),
3692 F_END
3693};
3694
Tianyi Gou621f8742011-09-01 21:45:01 -07003695static struct clk_freq_tbl clk_tbl_mdp_8064[] = {
3696 F_MDP( 0, gnd, 0, 0, NONE),
3697 F_MDP( 9600000, pll8, 1, 40, LOW),
3698 F_MDP( 13710000, pll8, 1, 28, LOW),
3699 F_MDP( 29540000, pll8, 1, 13, LOW),
3700 F_MDP( 34910000, pll8, 1, 11, LOW),
3701 F_MDP( 38400000, pll8, 1, 10, LOW),
3702 F_MDP( 59080000, pll8, 2, 13, LOW),
3703 F_MDP( 76800000, pll8, 1, 5, LOW),
3704 F_MDP( 85330000, pll8, 2, 9, LOW),
3705 F_MDP( 96000000, pll8, 1, 4, LOW),
3706 F_MDP(128000000, pll8, 1, 3, LOW),
3707 F_MDP(160000000, pll2, 1, 5, NOMINAL),
3708 F_MDP(177780000, pll2, 2, 9, NOMINAL),
3709 F_MDP(200000000, pll2, 1, 4, NOMINAL),
3710 F_MDP(266000000, pll2, 1, 3, NOMINAL),
3711 F_END
3712};
3713
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003714static struct bank_masks bmnd_info_mdp = {
3715 .bank_sel_mask = BIT(11),
3716 .bank0_mask = {
3717 .md_reg = MDP_MD0_REG,
3718 .ns_mask = BM(29, 22) | BM(5, 3),
3719 .rst_mask = BIT(31),
3720 .mnd_en_mask = BIT(8),
3721 .mode_mask = BM(10, 9),
3722 },
3723 .bank1_mask = {
3724 .md_reg = MDP_MD1_REG,
3725 .ns_mask = BM(21, 14) | BM(2, 0),
3726 .rst_mask = BIT(30),
3727 .mnd_en_mask = BIT(5),
3728 .mode_mask = BM(7, 6),
3729 },
3730};
3731
3732static struct rcg_clk mdp_clk = {
3733 .b = {
3734 .ctl_reg = MDP_CC_REG,
3735 .en_mask = BIT(0),
3736 .reset_reg = SW_RESET_CORE_REG,
3737 .reset_mask = BIT(21),
3738 .halt_reg = DBG_BUS_VEC_C_REG,
3739 .halt_bit = 10,
3740 },
3741 .ns_reg = MDP_NS_REG,
3742 .root_en_mask = BIT(2),
3743 .set_rate = set_rate_mnd_banked,
Tianyi Gou621f8742011-09-01 21:45:01 -07003744 .freq_tbl = clk_tbl_mdp_8960,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003745 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003746 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003747 .c = {
3748 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003749 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003750 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003751 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003752 },
3753};
3754
3755static struct branch_clk lut_mdp_clk = {
3756 .b = {
3757 .ctl_reg = MDP_LUT_CC_REG,
3758 .en_mask = BIT(0),
3759 .halt_reg = DBG_BUS_VEC_I_REG,
3760 .halt_bit = 13,
3761 },
3762 .parent = &mdp_clk.c,
3763 .c = {
3764 .dbg_name = "lut_mdp_clk",
3765 .ops = &clk_ops_branch,
3766 CLK_INIT(lut_mdp_clk.c),
3767 },
3768};
3769
3770#define F_MDP_VSYNC(f, s, v) \
3771 { \
3772 .freq_hz = f, \
3773 .src_clk = &s##_clk.c, \
3774 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
3775 .sys_vdd = v, \
3776 }
3777static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
3778 F_MDP_VSYNC(27000000, pxo, LOW),
3779 F_END
3780};
3781
3782static struct rcg_clk mdp_vsync_clk = {
3783 .b = {
3784 .ctl_reg = MISC_CC_REG,
3785 .en_mask = BIT(6),
3786 .reset_reg = SW_RESET_CORE_REG,
3787 .reset_mask = BIT(3),
3788 .halt_reg = DBG_BUS_VEC_B_REG,
3789 .halt_bit = 22,
3790 },
3791 .ns_reg = MISC_CC2_REG,
3792 .ns_mask = BIT(13),
3793 .set_rate = set_rate_nop,
3794 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003795 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003796 .c = {
3797 .dbg_name = "mdp_vsync_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003798 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003799 CLK_INIT(mdp_vsync_clk.c),
3800 },
3801};
3802
3803#define F_ROT(f, s, d, v) \
3804 { \
3805 .freq_hz = f, \
3806 .src_clk = &s##_clk.c, \
3807 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
3808 21, 19, 18, 16, s##_to_mm_mux), \
3809 .sys_vdd = v, \
3810 }
3811static struct clk_freq_tbl clk_tbl_rot[] = {
3812 F_ROT( 0, gnd, 1, NONE),
3813 F_ROT( 27000000, pxo, 1, LOW),
3814 F_ROT( 29540000, pll8, 13, LOW),
3815 F_ROT( 32000000, pll8, 12, LOW),
3816 F_ROT( 38400000, pll8, 10, LOW),
3817 F_ROT( 48000000, pll8, 8, LOW),
3818 F_ROT( 54860000, pll8, 7, LOW),
3819 F_ROT( 64000000, pll8, 6, LOW),
3820 F_ROT( 76800000, pll8, 5, LOW),
Matt Wagantall448db0f2011-09-07 10:17:40 -07003821 F_ROT( 96000000, pll8, 4, LOW),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003822 F_ROT(100000000, pll2, 8, NOMINAL),
3823 F_ROT(114290000, pll2, 7, NOMINAL),
3824 F_ROT(133330000, pll2, 6, NOMINAL),
3825 F_ROT(160000000, pll2, 5, NOMINAL),
Stephen Boyd8487f712011-08-29 12:10:09 -07003826 F_ROT(200000000, pll2, 4, NOMINAL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003827 F_END
3828};
3829
3830static struct bank_masks bdiv_info_rot = {
3831 .bank_sel_mask = BIT(30),
3832 .bank0_mask = {
3833 .ns_mask = BM(25, 22) | BM(18, 16),
3834 },
3835 .bank1_mask = {
3836 .ns_mask = BM(29, 26) | BM(21, 19),
3837 },
3838};
3839
3840static struct rcg_clk rot_clk = {
3841 .b = {
3842 .ctl_reg = ROT_CC_REG,
3843 .en_mask = BIT(0),
3844 .reset_reg = SW_RESET_CORE_REG,
3845 .reset_mask = BIT(2),
3846 .halt_reg = DBG_BUS_VEC_C_REG,
3847 .halt_bit = 15,
3848 },
3849 .ns_reg = ROT_NS_REG,
3850 .root_en_mask = BIT(2),
3851 .set_rate = set_rate_div_banked,
3852 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003853 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003854 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003855 .c = {
3856 .dbg_name = "rot_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003857 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003858 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003859 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003860 },
3861};
3862
3863static int hdmi_pll_clk_enable(struct clk *clk)
3864{
3865 int ret;
3866 unsigned long flags;
3867 spin_lock_irqsave(&local_clock_reg_lock, flags);
3868 ret = hdmi_pll_enable();
3869 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3870 return ret;
3871}
3872
3873static void hdmi_pll_clk_disable(struct clk *clk)
3874{
3875 unsigned long flags;
3876 spin_lock_irqsave(&local_clock_reg_lock, flags);
3877 hdmi_pll_disable();
3878 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3879}
3880
3881static unsigned hdmi_pll_clk_get_rate(struct clk *clk)
3882{
3883 return hdmi_pll_get_rate();
3884}
3885
Stephen Boyd5b35dee2011-09-21 12:17:38 -07003886static struct clk *hdmi_pll_clk_get_parent(struct clk *clk)
3887{
3888 return &pxo_clk.c;
3889}
3890
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003891static struct clk_ops clk_ops_hdmi_pll = {
3892 .enable = hdmi_pll_clk_enable,
3893 .disable = hdmi_pll_clk_disable,
3894 .get_rate = hdmi_pll_clk_get_rate,
3895 .is_local = local_clk_is_local,
Stephen Boyd5b35dee2011-09-21 12:17:38 -07003896 .get_parent = hdmi_pll_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003897};
3898
3899static struct clk hdmi_pll_clk = {
3900 .dbg_name = "hdmi_pll_clk",
3901 .ops = &clk_ops_hdmi_pll,
3902 CLK_INIT(hdmi_pll_clk),
3903};
3904
3905#define F_TV_GND(f, s, p_r, d, m, n, v) \
3906 { \
3907 .freq_hz = f, \
3908 .src_clk = &s##_clk.c, \
3909 .md_val = MD8(8, m, 0, n), \
3910 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3911 .ctl_val = CC(6, n), \
3912 .mnd_en_mask = BIT(5) * !!(n), \
3913 .sys_vdd = v, \
3914 }
3915#define F_TV(f, s, p_r, d, m, n, v) \
3916 { \
3917 .freq_hz = f, \
3918 .src_clk = &s##_clk, \
3919 .md_val = MD8(8, m, 0, n), \
3920 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3921 .ctl_val = CC(6, n), \
3922 .mnd_en_mask = BIT(5) * !!(n), \
3923 .sys_vdd = v, \
3924 .extra_freq_data = (void *)p_r, \
3925 }
3926/* Switching TV freqs requires PLL reconfiguration. */
3927static struct clk_freq_tbl clk_tbl_tv[] = {
3928 F_TV_GND( 0, gnd, 0, 1, 0, 0, NONE),
3929 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0, LOW),
3930 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0, LOW),
3931 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0, LOW),
3932 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0, NOMINAL),
3933 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0, NOMINAL),
3934 F_END
3935};
3936
3937/*
3938 * Unlike other clocks, the TV rate is adjusted through PLL
3939 * re-programming. It is also routed through an MND divider.
3940 */
3941void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
3942{
3943 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
3944 if (pll_rate)
3945 hdmi_pll_set_rate(pll_rate);
3946 set_rate_mnd(clk, nf);
3947}
3948
3949static struct rcg_clk tv_src_clk = {
3950 .ns_reg = TV_NS_REG,
3951 .b = {
3952 .ctl_reg = TV_CC_REG,
3953 .halt_check = NOCHECK,
3954 },
3955 .md_reg = TV_MD_REG,
3956 .root_en_mask = BIT(2),
3957 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
3958 .ctl_mask = BM(7, 6),
3959 .set_rate = set_rate_tv,
3960 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003961 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003962 .c = {
3963 .dbg_name = "tv_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003964 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003965 CLK_INIT(tv_src_clk.c),
3966 },
3967};
3968
3969static struct branch_clk tv_enc_clk = {
3970 .b = {
3971 .ctl_reg = TV_CC_REG,
3972 .en_mask = BIT(8),
3973 .reset_reg = SW_RESET_CORE_REG,
3974 .reset_mask = BIT(0),
3975 .halt_reg = DBG_BUS_VEC_D_REG,
3976 .halt_bit = 9,
3977 },
3978 .parent = &tv_src_clk.c,
3979 .c = {
3980 .dbg_name = "tv_enc_clk",
3981 .ops = &clk_ops_branch,
3982 CLK_INIT(tv_enc_clk.c),
3983 },
3984};
3985
3986static struct branch_clk tv_dac_clk = {
3987 .b = {
3988 .ctl_reg = TV_CC_REG,
3989 .en_mask = BIT(10),
3990 .halt_reg = DBG_BUS_VEC_D_REG,
3991 .halt_bit = 10,
3992 },
3993 .parent = &tv_src_clk.c,
3994 .c = {
3995 .dbg_name = "tv_dac_clk",
3996 .ops = &clk_ops_branch,
3997 CLK_INIT(tv_dac_clk.c),
3998 },
3999};
4000
4001static struct branch_clk mdp_tv_clk = {
4002 .b = {
4003 .ctl_reg = TV_CC_REG,
4004 .en_mask = BIT(0),
4005 .reset_reg = SW_RESET_CORE_REG,
4006 .reset_mask = BIT(4),
4007 .halt_reg = DBG_BUS_VEC_D_REG,
4008 .halt_bit = 12,
4009 },
4010 .parent = &tv_src_clk.c,
4011 .c = {
4012 .dbg_name = "mdp_tv_clk",
4013 .ops = &clk_ops_branch,
4014 CLK_INIT(mdp_tv_clk.c),
4015 },
4016};
4017
4018static struct branch_clk hdmi_tv_clk = {
4019 .b = {
4020 .ctl_reg = TV_CC_REG,
4021 .en_mask = BIT(12),
4022 .reset_reg = SW_RESET_CORE_REG,
4023 .reset_mask = BIT(1),
4024 .halt_reg = DBG_BUS_VEC_D_REG,
4025 .halt_bit = 11,
4026 },
4027 .parent = &tv_src_clk.c,
4028 .c = {
4029 .dbg_name = "hdmi_tv_clk",
4030 .ops = &clk_ops_branch,
4031 CLK_INIT(hdmi_tv_clk.c),
4032 },
4033};
4034
4035static struct branch_clk hdmi_app_clk = {
4036 .b = {
4037 .ctl_reg = MISC_CC2_REG,
4038 .en_mask = BIT(11),
4039 .reset_reg = SW_RESET_CORE_REG,
4040 .reset_mask = BIT(11),
4041 .halt_reg = DBG_BUS_VEC_B_REG,
4042 .halt_bit = 25,
4043 },
4044 .c = {
4045 .dbg_name = "hdmi_app_clk",
4046 .ops = &clk_ops_branch,
4047 CLK_INIT(hdmi_app_clk.c),
4048 },
4049};
4050
4051static struct bank_masks bmnd_info_vcodec = {
4052 .bank_sel_mask = BIT(13),
4053 .bank0_mask = {
4054 .md_reg = VCODEC_MD0_REG,
4055 .ns_mask = BM(18, 11) | BM(2, 0),
4056 .rst_mask = BIT(31),
4057 .mnd_en_mask = BIT(5),
4058 .mode_mask = BM(7, 6),
4059 },
4060 .bank1_mask = {
4061 .md_reg = VCODEC_MD1_REG,
4062 .ns_mask = BM(26, 19) | BM(29, 27),
4063 .rst_mask = BIT(30),
4064 .mnd_en_mask = BIT(10),
4065 .mode_mask = BM(12, 11),
4066 },
4067};
4068#define F_VCODEC(f, s, m, n, v) \
4069 { \
4070 .freq_hz = f, \
4071 .src_clk = &s##_clk.c, \
4072 .md_val = MD8(8, m, 0, n), \
4073 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
4074 .ctl_val = CC_BANKED(6, 11, n), \
4075 .mnd_en_mask = (BIT(10) | BIT(5)) * !!(n), \
4076 .sys_vdd = v, \
4077 }
4078static struct clk_freq_tbl clk_tbl_vcodec[] = {
4079 F_VCODEC( 0, gnd, 0, 0, NONE),
4080 F_VCODEC( 27000000, pxo, 0, 0, LOW),
4081 F_VCODEC( 32000000, pll8, 1, 12, LOW),
4082 F_VCODEC( 48000000, pll8, 1, 8, LOW),
4083 F_VCODEC( 54860000, pll8, 1, 7, LOW),
4084 F_VCODEC( 96000000, pll8, 1, 4, LOW),
4085 F_VCODEC(133330000, pll2, 1, 6, NOMINAL),
4086 F_VCODEC(200000000, pll2, 1, 4, NOMINAL),
4087 F_VCODEC(228570000, pll2, 2, 7, HIGH),
4088 F_END
4089};
4090
4091static struct rcg_clk vcodec_clk = {
4092 .b = {
4093 .ctl_reg = VCODEC_CC_REG,
4094 .en_mask = BIT(0),
4095 .reset_reg = SW_RESET_CORE_REG,
4096 .reset_mask = BIT(6),
4097 .halt_reg = DBG_BUS_VEC_C_REG,
4098 .halt_bit = 29,
4099 },
4100 .ns_reg = VCODEC_NS_REG,
4101 .root_en_mask = BIT(2),
4102 .set_rate = set_rate_mnd_banked,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004103 .bank_info = &bmnd_info_vcodec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004104 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004105 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004106 .c = {
4107 .dbg_name = "vcodec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004108 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004109 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004110 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004111 },
4112};
4113
4114#define F_VPE(f, s, d, v) \
4115 { \
4116 .freq_hz = f, \
4117 .src_clk = &s##_clk.c, \
4118 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
4119 .sys_vdd = v, \
4120 }
4121static struct clk_freq_tbl clk_tbl_vpe[] = {
4122 F_VPE( 0, gnd, 1, NONE),
4123 F_VPE( 27000000, pxo, 1, LOW),
4124 F_VPE( 34909000, pll8, 11, LOW),
4125 F_VPE( 38400000, pll8, 10, LOW),
4126 F_VPE( 64000000, pll8, 6, LOW),
4127 F_VPE( 76800000, pll8, 5, LOW),
4128 F_VPE( 96000000, pll8, 4, NOMINAL),
4129 F_VPE(100000000, pll2, 8, NOMINAL),
4130 F_VPE(160000000, pll2, 5, NOMINAL),
4131 F_END
4132};
4133
4134static struct rcg_clk vpe_clk = {
4135 .b = {
4136 .ctl_reg = VPE_CC_REG,
4137 .en_mask = BIT(0),
4138 .reset_reg = SW_RESET_CORE_REG,
4139 .reset_mask = BIT(17),
4140 .halt_reg = DBG_BUS_VEC_A_REG,
4141 .halt_bit = 28,
4142 },
4143 .ns_reg = VPE_NS_REG,
4144 .root_en_mask = BIT(2),
4145 .ns_mask = (BM(15, 12) | BM(2, 0)),
4146 .set_rate = set_rate_nop,
4147 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004148 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004149 .c = {
4150 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004151 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004152 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004153 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004154 },
4155};
4156
4157#define F_VFE(f, s, d, m, n, v) \
4158 { \
4159 .freq_hz = f, \
4160 .src_clk = &s##_clk.c, \
4161 .md_val = MD8(8, m, 0, n), \
4162 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
4163 .ctl_val = CC(6, n), \
4164 .mnd_en_mask = BIT(5) * !!(n), \
4165 .sys_vdd = v, \
4166 }
Tianyi Gou41515e22011-09-01 19:37:43 -07004167
4168static struct clk_freq_tbl clk_tbl_vfe_8960[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004169 F_VFE( 0, gnd, 1, 0, 0, NONE),
4170 F_VFE( 13960000, pll8, 1, 2, 55, LOW),
4171 F_VFE( 27000000, pxo, 1, 0, 0, LOW),
4172 F_VFE( 36570000, pll8, 1, 2, 21, LOW),
4173 F_VFE( 38400000, pll8, 2, 1, 5, LOW),
4174 F_VFE( 45180000, pll8, 1, 2, 17, LOW),
4175 F_VFE( 48000000, pll8, 2, 1, 4, LOW),
4176 F_VFE( 54860000, pll8, 1, 1, 7, LOW),
4177 F_VFE( 64000000, pll8, 2, 1, 3, LOW),
4178 F_VFE( 76800000, pll8, 1, 1, 5, LOW),
4179 F_VFE( 96000000, pll8, 2, 1, 2, LOW),
4180 F_VFE(109710000, pll8, 1, 2, 7, LOW),
4181 F_VFE(128000000, pll8, 1, 1, 3, NOMINAL),
4182 F_VFE(153600000, pll8, 1, 2, 5, NOMINAL),
4183 F_VFE(200000000, pll2, 2, 1, 2, NOMINAL),
4184 F_VFE(228570000, pll2, 1, 2, 7, NOMINAL),
4185 F_VFE(266667000, pll2, 1, 1, 3, NOMINAL),
Stephen Boyd94625ef2011-07-12 17:06:01 -07004186 F_VFE(320000000, pll2, 1, 2, 5, HIGH),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004187 F_END
4188};
4189
Tianyi Gou41515e22011-09-01 19:37:43 -07004190static struct clk_freq_tbl clk_tbl_vfe_8064[] = {
4191 F_VFE( 0, gnd, 1, 0, 0, NONE),
4192 F_VFE( 13960000, pll8, 1, 2, 55, LOW),
4193 F_VFE( 36570000, pll8, 1, 2, 21, LOW),
4194 F_VFE( 38400000, pll8, 2, 1, 5, LOW),
4195 F_VFE( 45180000, pll8, 1, 2, 17, LOW),
4196 F_VFE( 48000000, pll8, 2, 1, 4, LOW),
4197 F_VFE( 54860000, pll8, 1, 1, 7, LOW),
4198 F_VFE( 64000000, pll8, 2, 1, 3, LOW),
4199 F_VFE( 76800000, pll8, 1, 1, 5, LOW),
4200 F_VFE( 96000000, pll8, 2, 1, 2, LOW),
4201 F_VFE(109710000, pll8, 1, 2, 7, LOW),
4202 F_VFE(128000000, pll8, 1, 1, 3, LOW),
4203 F_VFE(153600000, pll8, 1, 2, 5, NOMINAL),
4204 F_VFE(200000000, pll2, 2, 1, 2, NOMINAL),
4205 F_VFE(228570000, pll2, 1, 2, 7, NOMINAL),
4206 F_VFE(266667000, pll2, 1, 1, 3, NOMINAL),
4207 F_VFE(320000000, pll2, 1, 2, 5, HIGH),
4208 F_END
4209};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004210
4211static struct rcg_clk vfe_clk = {
4212 .b = {
4213 .ctl_reg = VFE_CC_REG,
4214 .reset_reg = SW_RESET_CORE_REG,
4215 .reset_mask = BIT(15),
4216 .halt_reg = DBG_BUS_VEC_B_REG,
4217 .halt_bit = 6,
4218 .en_mask = BIT(0),
4219 },
4220 .ns_reg = VFE_NS_REG,
4221 .md_reg = VFE_MD_REG,
4222 .root_en_mask = BIT(2),
4223 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
4224 .ctl_mask = BM(7, 6),
4225 .set_rate = set_rate_mnd,
Tianyi Gou41515e22011-09-01 19:37:43 -07004226 .freq_tbl = clk_tbl_vfe_8960,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004227 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004228 .c = {
4229 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004230 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004231 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004232 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004233 },
4234};
4235
Matt Wagantallc23eee92011-08-16 23:06:52 -07004236static struct branch_clk csi_vfe_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004237 .b = {
4238 .ctl_reg = VFE_CC_REG,
4239 .en_mask = BIT(12),
4240 .reset_reg = SW_RESET_CORE_REG,
4241 .reset_mask = BIT(24),
4242 .halt_reg = DBG_BUS_VEC_B_REG,
4243 .halt_bit = 8,
4244 },
4245 .parent = &vfe_clk.c,
4246 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -07004247 .dbg_name = "csi_vfe_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004248 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -07004249 CLK_INIT(csi_vfe_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004250 },
4251};
4252
4253/*
4254 * Low Power Audio Clocks
4255 */
4256#define F_AIF_OSR(f, s, d, m, n, v) \
4257 { \
4258 .freq_hz = f, \
4259 .src_clk = &s##_clk.c, \
4260 .md_val = MD8(8, m, 0, n), \
4261 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4262 .mnd_en_mask = BIT(8) * !!(n), \
4263 .sys_vdd = v, \
4264 }
4265static struct clk_freq_tbl clk_tbl_aif_osr[] = {
4266 F_AIF_OSR( 0, gnd, 1, 0, 0, NONE),
Vikram Mulukutla6abb4fc2011-08-23 11:08:00 -07004267 F_AIF_OSR( 512000, pll4, 4, 1, 192, LOW),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004268 F_AIF_OSR( 768000, pll4, 4, 1, 128, LOW),
4269 F_AIF_OSR( 1024000, pll4, 4, 1, 96, LOW),
4270 F_AIF_OSR( 1536000, pll4, 4, 1, 64, LOW),
4271 F_AIF_OSR( 2048000, pll4, 4, 1, 48, LOW),
4272 F_AIF_OSR( 3072000, pll4, 4, 1, 32, LOW),
4273 F_AIF_OSR( 4096000, pll4, 4, 1, 24, LOW),
4274 F_AIF_OSR( 6144000, pll4, 4, 1, 16, LOW),
4275 F_AIF_OSR( 8192000, pll4, 4, 1, 12, LOW),
4276 F_AIF_OSR(12288000, pll4, 4, 1, 8, LOW),
4277 F_AIF_OSR(24576000, pll4, 4, 1, 4, LOW),
4278 F_END
4279};
4280
4281#define CLK_AIF_OSR(i, ns, md, h_r) \
4282 struct rcg_clk i##_clk = { \
4283 .b = { \
4284 .ctl_reg = ns, \
4285 .en_mask = BIT(17), \
4286 .reset_reg = ns, \
4287 .reset_mask = BIT(19), \
4288 .halt_reg = h_r, \
4289 .halt_check = ENABLE, \
4290 .halt_bit = 1, \
4291 }, \
4292 .ns_reg = ns, \
4293 .md_reg = md, \
4294 .root_en_mask = BIT(9), \
4295 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4296 .set_rate = set_rate_mnd, \
4297 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004298 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004299 .c = { \
4300 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004301 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004302 CLK_INIT(i##_clk.c), \
4303 }, \
4304 }
4305#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
4306 struct rcg_clk i##_clk = { \
4307 .b = { \
4308 .ctl_reg = ns, \
4309 .en_mask = BIT(21), \
4310 .reset_reg = ns, \
4311 .reset_mask = BIT(23), \
4312 .halt_reg = h_r, \
4313 .halt_check = ENABLE, \
4314 .halt_bit = 1, \
4315 }, \
4316 .ns_reg = ns, \
4317 .md_reg = md, \
4318 .root_en_mask = BIT(9), \
4319 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4320 .set_rate = set_rate_mnd, \
4321 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004322 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004323 .c = { \
4324 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004325 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004326 CLK_INIT(i##_clk.c), \
4327 }, \
4328 }
4329
4330#define F_AIF_BIT(d, s) \
4331 { \
4332 .freq_hz = d, \
4333 .ns_val = (BVAL(14, 14, s) | BVAL(13, 10, (d-1))) \
4334 }
4335static struct clk_freq_tbl clk_tbl_aif_bit[] = {
4336 F_AIF_BIT(0, 1), /* Use external clock. */
4337 F_AIF_BIT(1, 0), F_AIF_BIT(2, 0), F_AIF_BIT(3, 0), F_AIF_BIT(4, 0),
4338 F_AIF_BIT(5, 0), F_AIF_BIT(6, 0), F_AIF_BIT(7, 0), F_AIF_BIT(8, 0),
4339 F_AIF_BIT(9, 0), F_AIF_BIT(10, 0), F_AIF_BIT(11, 0), F_AIF_BIT(12, 0),
4340 F_AIF_BIT(13, 0), F_AIF_BIT(14, 0), F_AIF_BIT(15, 0), F_AIF_BIT(16, 0),
4341 F_END
4342};
4343
4344#define CLK_AIF_BIT(i, ns, h_r) \
4345 struct rcg_clk i##_clk = { \
4346 .b = { \
4347 .ctl_reg = ns, \
4348 .en_mask = BIT(15), \
4349 .halt_reg = h_r, \
4350 .halt_check = DELAY, \
4351 }, \
4352 .ns_reg = ns, \
4353 .ns_mask = BM(14, 10), \
4354 .set_rate = set_rate_nop, \
4355 .freq_tbl = clk_tbl_aif_bit, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004356 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004357 .c = { \
4358 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004359 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004360 CLK_INIT(i##_clk.c), \
4361 }, \
4362 }
4363
4364#define F_AIF_BIT_D(d, s) \
4365 { \
4366 .freq_hz = d, \
4367 .ns_val = (BVAL(18, 18, s) | BVAL(17, 10, (d-1))) \
4368 }
4369static struct clk_freq_tbl clk_tbl_aif_bit_div[] = {
4370 F_AIF_BIT_D(0, 1), /* Use external clock. */
4371 F_AIF_BIT_D(1, 0), F_AIF_BIT_D(2, 0), F_AIF_BIT_D(3, 0),
4372 F_AIF_BIT_D(4, 0), F_AIF_BIT_D(5, 0), F_AIF_BIT_D(6, 0),
4373 F_AIF_BIT_D(7, 0), F_AIF_BIT_D(8, 0), F_AIF_BIT_D(9, 0),
4374 F_AIF_BIT_D(10, 0), F_AIF_BIT_D(11, 0), F_AIF_BIT_D(12, 0),
4375 F_AIF_BIT_D(13, 0), F_AIF_BIT_D(14, 0), F_AIF_BIT_D(15, 0),
4376 F_AIF_BIT_D(16, 0),
4377 F_END
4378};
4379
4380#define CLK_AIF_BIT_DIV(i, ns, h_r) \
4381 struct rcg_clk i##_clk = { \
4382 .b = { \
4383 .ctl_reg = ns, \
4384 .en_mask = BIT(19), \
4385 .halt_reg = h_r, \
4386 .halt_check = ENABLE, \
4387 }, \
4388 .ns_reg = ns, \
4389 .ns_mask = BM(18, 10), \
4390 .set_rate = set_rate_nop, \
4391 .freq_tbl = clk_tbl_aif_bit_div, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004392 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004393 .c = { \
4394 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004395 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004396 CLK_INIT(i##_clk.c), \
4397 }, \
4398 }
4399
4400static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
4401 LCC_MI2S_STATUS_REG);
4402static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
4403
4404static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
4405 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
4406static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
4407 LCC_CODEC_I2S_MIC_STATUS_REG);
4408
4409static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
4410 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
4411static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
4412 LCC_SPARE_I2S_MIC_STATUS_REG);
4413
4414static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
4415 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
4416static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
4417 LCC_CODEC_I2S_SPKR_STATUS_REG);
4418
4419static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
4420 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
4421static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
4422 LCC_SPARE_I2S_SPKR_STATUS_REG);
4423
4424#define F_PCM(f, s, d, m, n, v) \
4425 { \
4426 .freq_hz = f, \
4427 .src_clk = &s##_clk.c, \
4428 .md_val = MD16(m, n), \
4429 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4430 .mnd_en_mask = BIT(8) * !!(n), \
4431 .sys_vdd = v, \
4432 }
4433static struct clk_freq_tbl clk_tbl_pcm[] = {
4434 F_PCM( 0, gnd, 1, 0, 0, NONE),
4435 F_PCM( 512000, pll4, 4, 1, 192, LOW),
4436 F_PCM( 768000, pll4, 4, 1, 128, LOW),
4437 F_PCM( 1024000, pll4, 4, 1, 96, LOW),
4438 F_PCM( 1536000, pll4, 4, 1, 64, LOW),
4439 F_PCM( 2048000, pll4, 4, 1, 48, LOW),
4440 F_PCM( 3072000, pll4, 4, 1, 32, LOW),
4441 F_PCM( 4096000, pll4, 4, 1, 24, LOW),
4442 F_PCM( 6144000, pll4, 4, 1, 16, LOW),
4443 F_PCM( 8192000, pll4, 4, 1, 12, LOW),
4444 F_PCM(12288000, pll4, 4, 1, 8, LOW),
4445 F_PCM(24576000, pll4, 4, 1, 4, LOW),
4446 F_END
4447};
4448
4449static struct rcg_clk pcm_clk = {
4450 .b = {
4451 .ctl_reg = LCC_PCM_NS_REG,
4452 .en_mask = BIT(11),
4453 .reset_reg = LCC_PCM_NS_REG,
4454 .reset_mask = BIT(13),
4455 .halt_reg = LCC_PCM_STATUS_REG,
4456 .halt_check = ENABLE,
4457 .halt_bit = 0,
4458 },
4459 .ns_reg = LCC_PCM_NS_REG,
4460 .md_reg = LCC_PCM_MD_REG,
4461 .root_en_mask = BIT(9),
4462 .ns_mask = (BM(31, 16) | BM(6, 0)),
4463 .set_rate = set_rate_mnd,
4464 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004465 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004466 .c = {
4467 .dbg_name = "pcm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004468 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004469 CLK_INIT(pcm_clk.c),
4470 },
4471};
4472
4473static struct rcg_clk audio_slimbus_clk = {
4474 .b = {
4475 .ctl_reg = LCC_SLIMBUS_NS_REG,
4476 .en_mask = BIT(10),
4477 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
4478 .reset_mask = BIT(5),
4479 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4480 .halt_check = ENABLE,
4481 .halt_bit = 0,
4482 },
4483 .ns_reg = LCC_SLIMBUS_NS_REG,
4484 .md_reg = LCC_SLIMBUS_MD_REG,
4485 .root_en_mask = BIT(9),
4486 .ns_mask = (BM(31, 24) | BM(6, 0)),
4487 .set_rate = set_rate_mnd,
4488 .freq_tbl = clk_tbl_aif_osr,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004489 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004490 .c = {
4491 .dbg_name = "audio_slimbus_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004492 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004493 CLK_INIT(audio_slimbus_clk.c),
4494 },
4495};
4496
4497static struct branch_clk sps_slimbus_clk = {
4498 .b = {
4499 .ctl_reg = LCC_SLIMBUS_NS_REG,
4500 .en_mask = BIT(12),
4501 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4502 .halt_check = ENABLE,
4503 .halt_bit = 1,
4504 },
4505 .parent = &audio_slimbus_clk.c,
4506 .c = {
4507 .dbg_name = "sps_slimbus_clk",
4508 .ops = &clk_ops_branch,
4509 CLK_INIT(sps_slimbus_clk.c),
4510 },
4511};
4512
4513static struct branch_clk slimbus_xo_src_clk = {
4514 .b = {
4515 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
4516 .en_mask = BIT(2),
4517 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004518 .halt_bit = 28,
4519 },
4520 .parent = &sps_slimbus_clk.c,
4521 .c = {
4522 .dbg_name = "slimbus_xo_src_clk",
4523 .ops = &clk_ops_branch,
4524 CLK_INIT(slimbus_xo_src_clk.c),
4525 },
4526};
4527
Matt Wagantall735f01a2011-08-12 12:40:28 -07004528DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
4529DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
4530DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
4531DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
4532DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
4533DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
4534DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
4535DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004536
4537static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
4538static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
4539static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
4540static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
4541static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
4542static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
4543static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
4544static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
4545
4546static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
4547/*
4548 * TODO: replace dummy_clk below with ebi1_clk.c once the
4549 * bus driver starts voting on ebi1 rates.
4550 */
4551static DEFINE_CLK_VOTER(ebi1_adm_clk, &dummy_clk);
4552
4553#ifdef CONFIG_DEBUG_FS
4554struct measure_sel {
4555 u32 test_vector;
4556 struct clk *clk;
4557};
4558
Matt Wagantall8b38f942011-08-02 18:23:18 -07004559static DEFINE_CLK_MEASURE(l2_m_clk);
4560static DEFINE_CLK_MEASURE(krait0_m_clk);
4561static DEFINE_CLK_MEASURE(krait1_m_clk);
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004562static DEFINE_CLK_MEASURE(q6sw_clk);
4563static DEFINE_CLK_MEASURE(q6fw_clk);
4564static DEFINE_CLK_MEASURE(q6_func_clk);
Matt Wagantall8b38f942011-08-02 18:23:18 -07004565
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004566static struct measure_sel measure_mux[] = {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004567 { TEST_PER_LS(0x05), &qdss_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004568 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
4569 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
4570 { TEST_PER_LS(0x13), &sdc1_clk.c },
4571 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
4572 { TEST_PER_LS(0x15), &sdc2_clk.c },
4573 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
4574 { TEST_PER_LS(0x17), &sdc3_clk.c },
4575 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
4576 { TEST_PER_LS(0x19), &sdc4_clk.c },
4577 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
4578 { TEST_PER_LS(0x1B), &sdc5_clk.c },
4579 { TEST_PER_LS(0x25), &dfab_clk.c },
4580 { TEST_PER_LS(0x25), &dfab_a_clk.c },
4581 { TEST_PER_LS(0x26), &pmem_clk.c },
4582 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
4583 { TEST_PER_LS(0x33), &cfpb_clk.c },
4584 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
4585 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
4586 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
4587 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
4588 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
4589 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
4590 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
4591 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
4592 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
4593 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
4594 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
4595 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
4596 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
4597 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
4598 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
4599 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
4600 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
4601 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
4602 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
4603 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
4604 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
4605 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
4606 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
4607 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
4608 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
4609 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
4610 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
4611 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
4612 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
4613 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
4614 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
4615 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
4616 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
4617 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
4618 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
4619 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
4620 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004621 { TEST_PER_LS(0x5E), &pcie_p_clk.c },
4622 { TEST_PER_LS(0x5F), &ce3_p_clk.c },
4623 { TEST_PER_LS(0x60), &ce3_core_clk.c },
4624 { TEST_PER_LS(0x63), &usb_hs3_p_clk.c },
4625 { TEST_PER_LS(0x64), &usb_hs3_xcvr_clk.c },
4626 { TEST_PER_LS(0x65), &usb_hs4_p_clk.c },
4627 { TEST_PER_LS(0x66), &usb_hs4_xcvr_clk.c },
4628 { TEST_PER_LS(0x6B), &sata_phy_ref_clk.c },
4629 { TEST_PER_LS(0x6C), &sata_phy_cfg_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004630 { TEST_PER_LS(0x78), &sfpb_clk.c },
4631 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
4632 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
4633 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
4634 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
4635 { TEST_PER_LS(0x7D), &prng_clk.c },
4636 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
4637 { TEST_PER_LS(0x80), &adm0_p_clk.c },
4638 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
4639 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004640 { TEST_PER_LS(0x86), &usb_hsic_p_clk.c },
4641 { TEST_PER_LS(0x87), &usb_hsic_system_clk.c },
4642 { TEST_PER_LS(0x88), &usb_hsic_xcvr_fs_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004643 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
4644 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
4645 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
4646 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
4647 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
4648 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
4649 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
4650 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
4651 { TEST_PER_LS(0x92), &ce1_p_clk.c },
4652 { TEST_PER_LS(0x94), &tssc_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004653 { TEST_PER_LS(0x9D), &usb_hsic_hsio_cal_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004654 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
4655
4656 { TEST_PER_HS(0x07), &afab_clk.c },
4657 { TEST_PER_HS(0x07), &afab_a_clk.c },
4658 { TEST_PER_HS(0x18), &sfab_clk.c },
4659 { TEST_PER_HS(0x18), &sfab_a_clk.c },
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004660 { TEST_PER_HS(0x26), &q6sw_clk },
4661 { TEST_PER_HS(0x27), &q6fw_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004662 { TEST_PER_HS(0x2A), &adm0_clk.c },
4663 { TEST_PER_HS(0x34), &ebi1_clk.c },
4664 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004665 { TEST_PER_HS(0x48), &qdss_at_clk.c },
4666 { TEST_PER_HS(0x49), &qdss_pclkdbg_clk.c },
4667 { TEST_PER_HS(0x4A), &qdss_traceclkin_clk.c },
4668 { TEST_PER_HS(0x4B), &qdss_tsctr_clk.c },
4669 { TEST_PER_HS(0x4F), &qdss_stm_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004670 { TEST_PER_HS(0x50), &usb_hsic_hsic_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004671
4672 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
4673 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
4674 { TEST_MM_LS(0x02), &cam1_clk.c },
4675 { TEST_MM_LS(0x06), &amp_p_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004676 { TEST_MM_LS(0x07), &csi_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004677 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
4678 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
4679 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
4680 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
4681 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
4682 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
4683 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
4684 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
4685 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
4686 { TEST_MM_LS(0x12), &imem_p_clk.c },
4687 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
4688 { TEST_MM_LS(0x14), &mdp_p_clk.c },
4689 { TEST_MM_LS(0x16), &rot_p_clk.c },
4690 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
4691 { TEST_MM_LS(0x18), &smmu_p_clk.c },
4692 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
4693 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
4694 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
4695 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
4696 { TEST_MM_LS(0x1D), &cam0_clk.c },
4697 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
4698 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
4699 { TEST_MM_LS(0x21), &tv_dac_clk.c },
4700 { TEST_MM_LS(0x22), &tv_enc_clk.c },
4701 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
4702 { TEST_MM_LS(0x25), &mmfpb_clk.c },
4703 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
4704 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004705 { TEST_MM_LS(0x27), &cam2_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004706 { TEST_MM_LS(0x28), &vcap_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004707
4708 { TEST_MM_HS(0x00), &csi0_clk.c },
4709 { TEST_MM_HS(0x01), &csi1_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004710 { TEST_MM_HS(0x04), &csi_vfe_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004711 { TEST_MM_HS(0x05), &ijpeg_clk.c },
4712 { TEST_MM_HS(0x06), &vfe_clk.c },
4713 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
4714 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
4715 { TEST_MM_HS(0x09), &gfx3d_clk.c },
4716 { TEST_MM_HS(0x0A), &jpegd_clk.c },
4717 { TEST_MM_HS(0x0B), &vcodec_clk.c },
4718 { TEST_MM_HS(0x0F), &mmfab_clk.c },
4719 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
4720 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
4721 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
4722 { TEST_MM_HS(0x13), &imem_axi_clk.c },
4723 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
4724 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
4725 { TEST_MM_HS(0x16), &rot_axi_clk.c },
4726 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
4727 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
4728 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
4729 { TEST_MM_HS(0x1A), &mdp_clk.c },
4730 { TEST_MM_HS(0x1B), &rot_clk.c },
4731 { TEST_MM_HS(0x1C), &vpe_clk.c },
4732 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
4733 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
4734 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
4735 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
4736 { TEST_MM_HS(0x26), &csi_pix_clk.c },
4737 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
4738 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
4739 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
4740 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
4741 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
4742 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004743 { TEST_MM_HS(0x2D), &csi2_clk.c },
4744 { TEST_MM_HS(0x2E), &csi2_phy_clk.c },
4745 { TEST_MM_HS(0x2F), &csi2phy_timer_clk.c },
4746 { TEST_MM_HS(0x30), &csi_pix1_clk.c },
4747 { TEST_MM_HS(0x31), &csi_rdi1_clk.c },
4748 { TEST_MM_HS(0x32), &csi_rdi2_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004749 { TEST_MM_HS(0x33), &vcap_clk.c },
4750 { TEST_MM_HS(0x34), &vcap_npl_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004751 { TEST_MM_HS(0x36), &vcap_axi_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004752 { TEST_MM_HS(0x39), &gfx3d_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004753
4754 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
4755 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
4756 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
4757 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
4758 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
4759 { TEST_LPA(0x14), &pcm_clk.c },
4760 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
Matt Wagantall8b38f942011-08-02 18:23:18 -07004761
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004762 { TEST_LPA_HS(0x00), &q6_func_clk },
4763
Matt Wagantall8b38f942011-08-02 18:23:18 -07004764 { TEST_CPUL2(0x1), &l2_m_clk },
4765 { TEST_CPUL2(0x2), &krait0_m_clk },
4766 { TEST_CPUL2(0x3), &krait1_m_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004767};
4768
4769static struct measure_sel *find_measure_sel(struct clk *clk)
4770{
4771 int i;
4772
4773 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
4774 if (measure_mux[i].clk == clk)
4775 return &measure_mux[i];
4776 return NULL;
4777}
4778
Matt Wagantall8b38f942011-08-02 18:23:18 -07004779static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004780{
4781 int ret = 0;
4782 u32 clk_sel;
4783 struct measure_sel *p;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004784 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004785 unsigned long flags;
4786
4787 if (!parent)
4788 return -EINVAL;
4789
4790 p = find_measure_sel(parent);
4791 if (!p)
4792 return -EINVAL;
4793
4794 spin_lock_irqsave(&local_clock_reg_lock, flags);
4795
Matt Wagantall8b38f942011-08-02 18:23:18 -07004796 /*
4797 * Program the test vector, measurement period (sample_ticks)
4798 * and scaling multiplier.
4799 */
4800 clk->sample_ticks = 0x10000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004801 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004802 clk->multiplier = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004803 switch (p->test_vector >> TEST_TYPE_SHIFT) {
4804 case TEST_TYPE_PER_LS:
4805 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
4806 break;
4807 case TEST_TYPE_PER_HS:
4808 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
4809 break;
4810 case TEST_TYPE_MM_LS:
4811 writel_relaxed(0x4030D97, CLK_TEST_REG);
4812 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
4813 break;
4814 case TEST_TYPE_MM_HS:
4815 writel_relaxed(0x402B800, CLK_TEST_REG);
4816 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
4817 break;
4818 case TEST_TYPE_LPA:
4819 writel_relaxed(0x4030D98, CLK_TEST_REG);
4820 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
4821 LCC_CLK_LS_DEBUG_CFG_REG);
4822 break;
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004823 case TEST_TYPE_LPA_HS:
4824 writel_relaxed(0x402BC00, CLK_TEST_REG);
4825 writel_relaxed(BVAL(2, 1, clk_sel)|BIT(0),
4826 LCC_CLK_HS_DEBUG_CFG_REG);
4827 break;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004828 case TEST_TYPE_CPUL2:
4829 writel_relaxed(0x4030400, CLK_TEST_REG);
4830 writel_relaxed(0x80|BVAL(5, 3, clk_sel), GCC_APCS_CLK_DIAG);
4831 clk->sample_ticks = 0x4000;
4832 clk->multiplier = 2;
4833 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004834 default:
4835 ret = -EPERM;
4836 }
4837 /* Make sure test vector is set before starting measurements. */
4838 mb();
4839
4840 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4841
4842 return ret;
4843}
4844
4845/* Sample clock for 'ticks' reference clock ticks. */
4846static u32 run_measurement(unsigned ticks)
4847{
4848 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004849 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
4850
4851 /* Wait for timer to become ready. */
4852 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
4853 cpu_relax();
4854
4855 /* Run measurement and wait for completion. */
4856 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
4857 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
4858 cpu_relax();
4859
4860 /* Stop counters. */
4861 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
4862
4863 /* Return measured ticks. */
4864 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
4865}
4866
4867
4868/* Perform a hardware rate measurement for a given clock.
4869 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall8b38f942011-08-02 18:23:18 -07004870static unsigned measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004871{
4872 unsigned long flags;
4873 u32 pdm_reg_backup, ringosc_reg_backup;
4874 u64 raw_count_short, raw_count_full;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004875 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004876 unsigned ret;
4877
4878 spin_lock_irqsave(&local_clock_reg_lock, flags);
4879
4880 /* Enable CXO/4 and RINGOSC branch and root. */
4881 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
4882 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
4883 writel_relaxed(0x2898, PDM_CLK_NS_REG);
4884 writel_relaxed(0xA00, RINGOSC_NS_REG);
4885
4886 /*
4887 * The ring oscillator counter will not reset if the measured clock
4888 * is not running. To detect this, run a short measurement before
4889 * the full measurement. If the raw results of the two are the same
4890 * then the clock must be off.
4891 */
4892
4893 /* Run a short measurement. (~1 ms) */
4894 raw_count_short = run_measurement(0x1000);
4895 /* Run a full measurement. (~14 ms) */
Matt Wagantall8b38f942011-08-02 18:23:18 -07004896 raw_count_full = run_measurement(clk->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004897
4898 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
4899 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
4900
4901 /* Return 0 if the clock is off. */
4902 if (raw_count_full == raw_count_short)
4903 ret = 0;
4904 else {
4905 /* Compute rate in Hz. */
4906 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004907 do_div(raw_count_full, ((clk->sample_ticks * 10) + 35));
4908 ret = (raw_count_full * clk->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004909 }
4910
4911 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07004912 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004913 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4914
4915 return ret;
4916}
4917#else /* !CONFIG_DEBUG_FS */
4918static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
4919{
4920 return -EINVAL;
4921}
4922
4923static unsigned measure_clk_get_rate(struct clk *clk)
4924{
4925 return 0;
4926}
4927#endif /* CONFIG_DEBUG_FS */
4928
4929static struct clk_ops measure_clk_ops = {
4930 .set_parent = measure_clk_set_parent,
4931 .get_rate = measure_clk_get_rate,
4932 .is_local = local_clk_is_local,
4933};
4934
Matt Wagantall8b38f942011-08-02 18:23:18 -07004935static struct measure_clk measure_clk = {
4936 .c = {
4937 .dbg_name = "measure_clk",
4938 .ops = &measure_clk_ops,
4939 CLK_INIT(measure_clk.c),
4940 },
4941 .multiplier = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004942};
4943
Tianyi Gou41515e22011-09-01 19:37:43 -07004944static struct clk_lookup msm_clocks_8064[] __initdata = {
4945 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07004946 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004947 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
Tianyi Gouc29c3242011-10-12 21:02:15 -07004948 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004949 CLK_LOOKUP("measure", measure_clk.c, "debug"),
4950
4951 CLK_DUMMY("afab_clk", AFAB_CLK, NULL, 0),
4952 CLK_DUMMY("afab_a_clk", AFAB_A_CLK, NULL, 0),
4953 CLK_DUMMY("cfpb_clk", CFPB_CLK, NULL, 0),
4954 CLK_DUMMY("cfpb_a_clk", CFPB_A_CLK, NULL, 0),
4955 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
4956 CLK_DUMMY("dfab_a_clk", DFAB_A_CLK, NULL, 0),
4957 CLK_DUMMY("ebi1_clk", EBI1_CLK, NULL, 0),
4958 CLK_DUMMY("ebi1_a_clk", EBI1_A_CLK, NULL, 0),
4959 CLK_DUMMY("mmfab_clk", MMFAB_CLK, NULL, 0),
4960 CLK_DUMMY("mmfab_a_clk", MMFAB_A_CLK, NULL, 0),
4961 CLK_DUMMY("mmfpb_clk", MMFPB_CLK, NULL, 0),
4962 CLK_DUMMY("mmfpb_a_clk", MMFPB_A_CLK, NULL, 0),
4963 CLK_DUMMY("sfab_clk", SFAB_CLK, NULL, 0),
4964 CLK_DUMMY("sfab_a_clk", SFAB_A_CLK, NULL, 0),
4965 CLK_DUMMY("sfpb_clk", SFPB_CLK, NULL, 0),
4966 CLK_DUMMY("sfpb_a_clk", SFPB_A_CLK, NULL, 0),
4967
4968 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
4969 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
4970 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
4971 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
4972 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, NULL),
4973 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, NULL),
4974 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
4975 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, NULL),
4976 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
4977 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, NULL),
4978 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, NULL),
4979 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
4980 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
4981 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
4982 CLK_LOOKUP("pdm_clk", pdm_clk.c, NULL),
4983 CLK_LOOKUP("pmem_clk", pmem_clk.c, NULL),
4984 CLK_DUMMY("core_clk", PRNG_CLK, NULL, OFF),
Tianyi Gou43208a02011-09-27 15:35:13 -07004985 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
4986 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
4987 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
4988 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
Tianyi Gou41515e22011-09-01 19:37:43 -07004989 CLK_LOOKUP("tsif_ref_clk", tsif_ref_clk.c, NULL),
4990 CLK_LOOKUP("tssc_clk", tssc_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07004991 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004992 CLK_LOOKUP("core_clk", usb_hs3_xcvr_clk.c, NULL),
4993 CLK_LOOKUP("core_clk", usb_hs4_xcvr_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07004994 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
4995 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
4996 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004997 CLK_LOOKUP("ce_pclk", ce1_p_clk.c, NULL),
4998 CLK_LOOKUP("ce_clk", ce1_core_clk.c, NULL),
4999 CLK_LOOKUP("sata_phy_ref_clk", sata_phy_ref_clk.c, NULL),
5000 CLK_LOOKUP("sata_phy_cfg_clk", sata_phy_cfg_clk.c, NULL),
5001 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
5002 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, NULL),
5003 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
5004 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, NULL),
5005 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, NULL),
5006 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, NULL),
5007 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, NULL),
5008 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
5009 CLK_LOOKUP("tsif_pclk", tsif_p_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005010 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5011 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005012 CLK_LOOKUP("iface_clk", usb_hs3_p_clk.c, NULL),
5013 CLK_LOOKUP("iface_clk", usb_hs4_p_clk.c, NULL),
Tianyi Gou43208a02011-09-27 15:35:13 -07005014 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5015 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5016 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5017 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005018 CLK_LOOKUP("iface_clk", pcie_p_clk.c, NULL),
5019 CLK_LOOKUP("core_src_clk", ce3_src_clk.c, NULL),
5020 CLK_LOOKUP("core_clk", ce3_core_clk.c, NULL),
5021 CLK_LOOKUP("iface_clk", ce3_p_clk.c, NULL),
5022 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5023 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
5024 CLK_LOOKUP("pmic_arb_pclk", pmic_arb0_p_clk.c, NULL),
5025 CLK_LOOKUP("pmic_arb_pclk", pmic_arb1_p_clk.c, NULL),
5026 CLK_LOOKUP("pmic_ssbi2", pmic_ssbi2_clk.c, NULL),
5027 CLK_LOOKUP("rpm_msg_ram_pclk", rpm_msg_ram_p_clk.c, NULL),
5028 CLK_LOOKUP("amp_clk", amp_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005029 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5030 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
5031 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5032 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5033 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005034 CLK_DUMMY("csi_src_clk", CSI0_SRC_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005035 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5036 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5037 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005038 CLK_DUMMY("csi_clk", CSI0_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005039 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5040 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5041 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
5042 CLK_DUMMY("csi_phy_clk", CSI0_PHY_CLK, NULL, OFF),
5043 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5044 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5045 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005046 CLK_DUMMY("csi_pix_clk", CSI_PIX_CLK, NULL, OFF),
5047 CLK_DUMMY("csi_rdi_clk", CSI_RDI_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005048 CLK_DUMMY("csi_pix_clk", CSI_PIX1_CLK, NULL, OFF),
5049 CLK_DUMMY("csi_rdi_clk", CSI_RDI1_CLK, NULL, OFF),
5050 CLK_DUMMY("csi_rdi_clk", CSI_RDI2_CLK, NULL, OFF),
5051 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
5052 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, NULL),
5053 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, NULL),
5054 CLK_LOOKUP("csiphy_timer_clk", csi2phy_timer_clk.c, NULL),
5055 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5056 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5057 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5058 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
5059 CLK_DUMMY("rgb_tv_clk", RGB_TV_CLK, NULL, OFF),
5060 CLK_DUMMY("npl_tv_clk", NPL_TV_CLK, NULL, OFF),
5061 CLK_LOOKUP("core_clk", gfx3d_clk.c, NULL),
5062 CLK_LOOKUP("iface_clk", vcap_p_clk.c, NULL),
5063 CLK_LOOKUP("bus_clk", vcap_axi_clk.c, NULL),
5064 CLK_LOOKUP("core_clk", vcap_clk.c, NULL),
5065 CLK_LOOKUP("vcap_npl_clk", vcap_npl_clk.c, NULL),
5066 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, NULL),
5067 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
5068 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
5069 CLK_LOOKUP("jpegd_clk", jpegd_clk.c, NULL),
5070 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
5071 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
5072 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
5073 CLK_LOOKUP("rot_clk", rot_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005074 CLK_DUMMY("tv_src_clk", TV_SRC_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005075 CLK_LOOKUP("core_clk", vcodec_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005076 CLK_DUMMY("mdp_tv_clk", MDP_TV_CLK, NULL, OFF),
5077 CLK_DUMMY("hdmi_clk", HDMI_TV_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005078 CLK_LOOKUP("core_clk", hdmi_app_clk.c, NULL),
5079 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
5080 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
5081 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, NULL),
5082 CLK_LOOKUP("vfe_axi_clk", vfe_axi_clk.c, NULL),
5083 CLK_LOOKUP("mdp_axi_clk", mdp_axi_clk.c, NULL),
5084 CLK_LOOKUP("rot_axi_clk", rot_axi_clk.c, NULL),
5085 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, NULL),
5086 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, NULL),
5087 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, NULL),
5088 CLK_LOOKUP("vpe_axi_clk", vpe_axi_clk.c, NULL),
5089 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
5090 CLK_LOOKUP("csi_pclk", csi_p_clk.c, NULL),
5091 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5092 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5093 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5094 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
5095 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, NULL),
5096 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, NULL),
5097 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, NULL),
5098 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
5099 CLK_LOOKUP("jpegd_pclk", jpegd_p_clk.c, NULL),
5100 CLK_LOOKUP("imem_pclk", imem_p_clk.c, NULL),
5101 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
5102 CLK_LOOKUP("iface_clk", smmu_p_clk.c, NULL),
5103 CLK_LOOKUP("rotator_pclk", rot_p_clk.c, NULL),
5104 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, NULL),
5105 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
5106 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Tianyi Gouc29c3242011-10-12 21:02:15 -07005107 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5108 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5109 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5110 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5111 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5112 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5113 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5114 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5115 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5116 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5117 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
Tianyi Goudd8138a2011-10-20 15:46:00 -07005118 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5119 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005120 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, NULL),
5121 CLK_LOOKUP("core_clk", vpe_axi_clk.c, NULL),
5122 CLK_LOOKUP("core_clk", mdp_axi_clk.c, NULL),
5123 CLK_LOOKUP("core_clk", vcap_axi_clk.c, NULL),
5124 CLK_LOOKUP("core_clk", rot_axi_clk.c, NULL),
5125 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, NULL),
5126 CLK_LOOKUP("core_clk", vfe_axi_clk.c, NULL),
5127 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, NULL),
5128 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, NULL),
5129 CLK_DUMMY("core_clk", GFX3D_AXI_CLK, NULL, 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005130 CLK_DUMMY("dfab_dsps_clk", DFAB_DSPS_CLK, NULL, 0),
5131 CLK_DUMMY("dfab_usb_hs_clk", DFAB_USB_HS_CLK, NULL, 0),
5132 CLK_DUMMY("bus_clk", DFAB_SDC1_CLK, NULL, 0),
5133 CLK_DUMMY("bus_clk", DFAB_SDC2_CLK, NULL, 0),
5134 CLK_DUMMY("bus_clk", DFAB_SDC3_CLK, NULL, 0),
5135 CLK_DUMMY("bus_clk", DFAB_SDC4_CLK, NULL, 0),
5136 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
5137 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5138 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5139 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5140 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5141 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5142
5143 CLK_LOOKUP("ebi1_msmbus_clk", ebi1_msmbus_clk.c, NULL),
5144 CLK_LOOKUP("ebi1_clk", ebi1_adm_clk.c, "msm_dmov"),
5145
5146 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5147 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5148 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
5149};
5150
Stephen Boyd94625ef2011-07-12 17:06:01 -07005151static struct clk_lookup msm_clocks_8960_v1[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005152 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
5153 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
5154 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
5155 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005156 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005157
5158 CLK_LOOKUP("afab_clk", afab_clk.c, NULL),
5159 CLK_LOOKUP("afab_a_clk", afab_a_clk.c, NULL),
5160 CLK_LOOKUP("cfpb_clk", cfpb_clk.c, NULL),
5161 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, NULL),
Stephen Boyd85436132011-09-16 18:55:13 -07005162 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005163 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
5164 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
5165 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
5166 CLK_LOOKUP("ebi1_a_clk", ebi1_a_clk.c, NULL),
5167 CLK_LOOKUP("mmfab_clk", mmfab_clk.c, NULL),
5168 CLK_LOOKUP("mmfab_a_clk", mmfab_a_clk.c, NULL),
5169 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
5170 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, NULL),
Stephen Boyda3787f32011-09-16 18:55:13 -07005171 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005172 CLK_LOOKUP("sfab_clk", sfab_clk.c, NULL),
5173 CLK_LOOKUP("sfab_a_clk", sfab_a_clk.c, NULL),
5174 CLK_LOOKUP("sfpb_clk", sfpb_clk.c, NULL),
5175 CLK_LOOKUP("sfpb_a_clk", sfpb_a_clk.c, NULL),
5176
Matt Wagantalle2522372011-08-17 14:52:21 -07005177 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
5178 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
5179 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
5180 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
5181 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
5182 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
5183 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
5184 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, NULL),
5185 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, NULL),
5186 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, NULL),
5187 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, NULL),
5188 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005189 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005190 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005191 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
5192 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005193 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
5194 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
5195 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
5196 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, NULL),
5197 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005198 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005199 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005200 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
Joel Nider93c8c6a2011-10-16 16:58:18 +02005201 CLK_LOOKUP("tsif_pclk", tsif_p_clk.c, NULL),
5202 CLK_LOOKUP("tsif_ref_clk", tsif_ref_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005203 CLK_LOOKUP("pdm_clk", pdm_clk.c, NULL),
Vikram Mulukutladd0a2372011-09-19 15:58:21 -07005204 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_sps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07005205 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005206 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5207 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5208 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5209 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
5210 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005211 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005212 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005213 CLK_LOOKUP("tssc_clk", tssc_clk.c, NULL),
5214 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
5215 CLK_LOOKUP("usb_phy_clk", usb_phy0_clk.c, NULL),
5216 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
5217 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
5218 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
5219 CLK_LOOKUP("usb_fs_clk", usb_fs2_xcvr_clk.c, NULL),
5220 CLK_LOOKUP("usb_fs_sys_clk", usb_fs2_sys_clk.c, NULL),
5221 CLK_LOOKUP("usb_fs_src_clk", usb_fs2_src_clk.c, NULL),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005222 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005223 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qcrypto.0"),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005224 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005225 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qcrypto.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005226 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005227 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005228 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005229 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
5230 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07005231 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
5232 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005233 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
5234 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, NULL),
5235 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005236 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005237 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005238 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.12"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005239 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005240 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5241 CLK_LOOKUP("usb_fs_pclk", usb_fs2_p_clk.c, NULL),
5242 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005243 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5244 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5245 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5246 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
5247 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005248 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5249 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005250 CLK_LOOKUP("pmic_arb_pclk", pmic_arb0_p_clk.c, NULL),
5251 CLK_LOOKUP("pmic_arb_pclk", pmic_arb1_p_clk.c, NULL),
5252 CLK_LOOKUP("pmic_ssbi2", pmic_ssbi2_clk.c, NULL),
5253 CLK_LOOKUP("rpm_msg_ram_pclk", rpm_msg_ram_p_clk.c, NULL),
5254 CLK_LOOKUP("amp_clk", amp_clk.c, NULL),
5255 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5256 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
5257 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_imx074.0"),
5258 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_ov2720.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07005259 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005260 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, NULL),
5261 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5262 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07005263 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005264 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_camera_ov2720.0"),
5265 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
5266 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5267 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07005268 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005269 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov2720.0"),
5270 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, NULL),
5271 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5272 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07005273 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005274 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_camera_ov2720.0"),
5275 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, NULL),
5276 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, NULL),
5277 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
5278 CLK_LOOKUP("csi0phy_timer_clk", csi0phy_timer_clk.c, NULL),
5279 CLK_LOOKUP("csi1phy_timer_clk", csi1phy_timer_clk.c, NULL),
5280 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5281 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5282 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5283 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005284 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005285 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005286 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005287 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005288 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005289 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5290 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005291 CLK_LOOKUP("imem_axi_clk", imem_axi_clk.c, NULL),
5292 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005293 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005294 CLK_LOOKUP("jpegd_clk", jpegd_clk.c, NULL),
5295 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005296 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005297 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
5298 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07005299 CLK_LOOKUP("qdss_pclk", qdss_p_clk.c, NULL),
5300 CLK_LOOKUP("qdss_at_clk", qdss_at_clk.c, NULL),
5301 CLK_LOOKUP("qdss_pclkdbg_clk", qdss_pclkdbg_clk.c, NULL),
5302 CLK_LOOKUP("qdss_traceclkin_clk", qdss_traceclkin_clk.c, NULL),
5303 CLK_LOOKUP("qdss_tsctr_clk", qdss_tsctr_clk.c, NULL),
5304 CLK_LOOKUP("qdss_stm_clk", qdss_stm_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005305 CLK_LOOKUP("rot_clk", rot_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005306 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005307 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
5308 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
5309 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005310 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005311 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005312 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
5313 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005314 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005315 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005316 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005317 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005318 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Matt Wagantallc23eee92011-08-16 23:06:52 -07005319 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005320 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5321 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5322 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5323 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5324 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5325 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5326 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005327 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Matt Wagantallc23eee92011-08-16 23:06:52 -07005328 CLK_LOOKUP("csi_pclk", csi_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005329 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5330 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5331 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5332 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005333 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005334 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005335 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005336 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005337 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005338 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005339 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
5340 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005341 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005342 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005343 CLK_LOOKUP("jpegd_pclk", jpegd_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005344 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005345 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005346 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07005347 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005348 CLK_LOOKUP("rotator_pclk", rot_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005349 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005350 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005351 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005352 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005353 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005354 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005355 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005356 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005357 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5358 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5359 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5360 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5361 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5362 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5363 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5364 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5365 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5366 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5367 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
5368 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5369 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Matt Wagantalle604d712011-10-21 15:38:18 -07005370 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
5371 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
5372 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
5373 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
5374 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
5375 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
5376 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
5377 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
5378 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
5379 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
5380 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
5381 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005382 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
5383 CLK_LOOKUP("dfab_usb_hs_clk", dfab_usb_hs_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005384 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
5385 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
5386 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
5387 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
5388 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Yan He160633e2011-06-30 12:18:56 -07005389 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005390
5391 CLK_LOOKUP("ebi1_msmbus_clk", ebi1_msmbus_clk.c, NULL),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005392 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005393
5394 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5395 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5396 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
Stephen Boyd3939c8d2011-08-29 17:36:22 -07005397 CLK_LOOKUP("q6sw_clk", q6sw_clk, NULL),
5398 CLK_LOOKUP("q6fw_clk", q6fw_clk, NULL),
5399 CLK_LOOKUP("q6_func_clk", q6_func_clk, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005400};
5401
Stephen Boyd94625ef2011-07-12 17:06:01 -07005402static struct clk_lookup msm_clocks_8960_v2[] __initdata = {
5403 CLK_LOOKUP("cam_clk", cam2_clk.c, NULL),
5404 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
5405 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
5406 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, NULL),
5407 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, NULL),
5408 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, NULL),
5409 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
5410 CLK_LOOKUP("csi2phy_timer_clk", csi2phy_timer_clk.c, NULL),
5411 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5412 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5413 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5414 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5415 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5416};
5417
5418/* Add v2 clocks dynamically at runtime */
5419static struct clk_lookup msm_clocks_8960[ARRAY_SIZE(msm_clocks_8960_v1) +
5420 ARRAY_SIZE(msm_clocks_8960_v2)];
5421
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005422/*
5423 * Miscellaneous clock register initializations
5424 */
5425
5426/* Read, modify, then write-back a register. */
5427static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
5428{
5429 uint32_t regval = readl_relaxed(reg);
5430 regval &= ~mask;
5431 regval |= val;
5432 writel_relaxed(regval, reg);
5433}
5434
Tianyi Gou41515e22011-09-01 19:37:43 -07005435static void __init set_fsm_mode(void __iomem *mode_reg)
5436{
5437 u32 regval = readl_relaxed(mode_reg);
5438
5439 /*De-assert reset to FSM */
5440 regval &= ~BIT(21);
5441 writel_relaxed(regval, mode_reg);
5442
5443 /* Program bias count */
Tianyi Gou358c3862011-10-18 17:03:41 -07005444 regval &= ~BM(19, 14);
5445 regval |= BVAL(19, 14, 0x1);
5446 writel_relaxed(regval, mode_reg);
5447
5448 /* Program lock count */
Tianyi Gou41515e22011-09-01 19:37:43 -07005449 regval &= ~BM(13, 8);
5450 regval |= BVAL(13, 8, 0x8);
5451 writel_relaxed(regval, mode_reg);
5452
5453 /*Enable PLL FSM voting */
5454 regval |= BIT(20);
5455 writel_relaxed(regval, mode_reg);
5456}
5457
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005458static void __init reg_init(void)
5459{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005460 /* Deassert MM SW_RESET_ALL signal. */
5461 writel_relaxed(0, SW_RESET_ALL_REG);
5462
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005463 /*
5464 * Some bits are only used on either 8960 or 8064 and are marked as
5465 * reserved bits on the other SoC. Writing to these reserved bits
5466 * should have no effect.
5467 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005468 /* Initialize MM AHB registers: Enable the FPB clock and disable HW
5469 * gating for all clocks. Also set VFE_AHB's FORCE_CORE_ON bit to
5470 * prevent its memory from being collapsed when the clock is halted.
5471 * The sleep and wake-up delays are set to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005472 rmwreg(0x00000003, AHB_EN_REG, 0x6C000103);
5473 writel_relaxed(0x000007F9, AHB_EN2_REG);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005474 if (cpu_is_apq8064())
5475 rmwreg(0x00000000, AHB_EN3_REG, 0x00000001);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005476
5477 /* Deassert all locally-owned MM AHB resets. */
5478 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
Tianyi Gou41515e22011-09-01 19:37:43 -07005479 rmwreg(0, SW_RESET_AHB2_REG, 0x0000000F);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005480
5481 /* Initialize MM AXI registers: Enable HW gating for all clocks that
5482 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
5483 * delays to safe values. */
5484 /* TODO: Enable HW Gating */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005485 rmwreg(0x000007F9, MAXI_EN_REG, 0x0803FFFF);
5486 rmwreg(0x3027FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
5487 rmwreg(0x0027FCFF, MAXI_EN3_REG, 0x003FFFFF);
5488 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005489 if (cpu_is_apq8064())
5490 rmwreg(0x009FE4FF, MAXI_EN5_REG, 0x01FFEFFF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005491 rmwreg(0x000003C7, SAXI_EN_REG, 0x00003FFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005492
5493 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
5494 * memories retain state even when not clocked. Also, set sleep and
5495 * wake-up delays to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005496 rmwreg(0x00000000, CSI0_CC_REG, 0x00000410);
5497 rmwreg(0x00000000, CSI1_CC_REG, 0x00000410);
5498 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, 0xE0FF0010);
5499 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, 0xE0FF0010);
5500 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, 0xE0FF0010);
5501 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005502 rmwreg(0x80FF0000, GFX3D_CC_REG, 0xE0FF0010);
5503 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0010);
5504 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0010);
5505 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
5506 rmwreg(0x80FF0000, MDP_LUT_CC_REG, 0xE0FF0010);
5507 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005508 rmwreg(0x000004FF, TV_CC2_REG, 0x000007FF);
5509 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
5510 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FF4010);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005511 rmwreg(0x800000FF, VFE_CC2_REG, 0xE00000FF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005512 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005513 if (cpu_is_msm8960()) {
5514 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
5515 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
5516 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
5517 }
5518 if (cpu_is_apq8064()) {
5519 rmwreg(0x00000000, TV_CC_REG, 0x00004010);
Tianyi Gou621f8742011-09-01 21:45:01 -07005520 rmwreg(0x80FF0000, VCAP_CC_REG, 0xE0FF1010);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005521 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005522
Tianyi Gou41515e22011-09-01 19:37:43 -07005523 /*
5524 * Initialize USB_HS_HCLK_FS registers: Set FORCE_C_ON bits so that
5525 * core remain active during halt state of the clk. Also, set sleep
5526 * and wake-up value to max.
5527 */
5528 rmwreg(0x0000004F, USB_HS1_HCLK_FS_REG, 0x0000007F);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005529 if (cpu_is_apq8064()) {
5530 rmwreg(0x0000004F, USB_HS3_HCLK_FS_REG, 0x0000007F);
5531 rmwreg(0x0000004F, USB_HS4_HCLK_FS_REG, 0x0000007F);
5532 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005533
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005534 /* De-assert MM AXI resets to all hardware blocks. */
5535 writel_relaxed(0, SW_RESET_AXI_REG);
5536
5537 /* Deassert all MM core resets. */
5538 writel_relaxed(0, SW_RESET_CORE_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005539 writel_relaxed(0, SW_RESET_CORE2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005540
5541 /* Reset 3D core once more, with its clock enabled. This can
5542 * eventually be done as part of the GDFS footswitch driver. */
5543 clk_set_rate(&gfx3d_clk.c, 27000000);
5544 clk_enable(&gfx3d_clk.c);
5545 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
5546 mb();
5547 udelay(5);
5548 writel_relaxed(0, SW_RESET_CORE_REG);
5549 /* Make sure reset is de-asserted before clock is disabled. */
5550 mb();
5551 clk_disable(&gfx3d_clk.c);
5552
5553 /* Enable TSSC and PDM PXO sources. */
5554 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
5555 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
5556
5557 /* Source SLIMBus xo src from slimbus reference clock */
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005558 if (cpu_is_msm8960())
5559 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005560
5561 /* Source the dsi_byte_clks from the DSI PHY PLLs */
5562 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
5563 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
Tianyi Gou41515e22011-09-01 19:37:43 -07005564
5565 /* Source the sata_phy_ref_clk from PXO */
5566 if (cpu_is_apq8064())
5567 rmwreg(0, SATA_PHY_REF_CLK_CTL_REG, 0x1);
5568
5569 /*
5570 * TODO: Programming below PLLs is temporary and needs to be removed
5571 * after bootloaders program them.
5572 */
5573 if (cpu_is_apq8064()) {
5574 u32 regval, is_pll_enabled;
5575
5576 /* Program pxo_src_clk to source from PXO */
5577 rmwreg(0x1, PXO_SRC_CLK_CTL_REG, 0x7);
5578
5579 /* Check if PLL8 is active */
5580 is_pll_enabled = readl_relaxed(BB_PLL8_STATUS_REG) & BIT(16);
5581 if (!is_pll_enabled) {
5582 /* Ref clk = 24.5MHz and program pll8 to 384MHz */
5583 writel_relaxed(0xF, BB_PLL8_L_VAL_REG);
5584 writel_relaxed(0x21, BB_PLL8_M_VAL_REG);
5585 writel_relaxed(0x31, BB_PLL8_N_VAL_REG);
5586
5587 regval = readl_relaxed(BB_PLL8_CONFIG_REG);
5588
5589 /* Enable the main output and the MN accumulator */
5590 regval |= BIT(23) | BIT(22);
5591
5592 /* Set pre-divider and post-divider values to 1 and 1 */
5593 regval &= ~BIT(19);
5594 regval &= ~BM(21, 20);
5595
5596 writel_relaxed(regval, BB_PLL8_CONFIG_REG);
5597
5598 /* Set VCO frequency */
5599 rmwreg(0x10000, BB_PLL8_CONFIG_REG, 0x30000);
5600
5601 /* Enable AUX output */
5602 regval = readl_relaxed(BB_PLL8_TEST_CTL_REG);
5603 regval |= BIT(12);
5604 writel_relaxed(regval, BB_PLL8_TEST_CTL_REG);
5605
5606 set_fsm_mode(BB_PLL8_MODE_REG);
5607 }
5608 /* Check if PLL3 is active */
5609 is_pll_enabled = readl_relaxed(GPLL1_STATUS_REG) & BIT(16);
5610 if (!is_pll_enabled) {
5611 /* Ref clk = 24.5MHz and program pll3 to 1200MHz */
5612 writel_relaxed(0x30, GPLL1_L_VAL_REG);
5613 writel_relaxed(0x30, GPLL1_M_VAL_REG);
5614 writel_relaxed(0x31, GPLL1_N_VAL_REG);
5615
5616 regval = readl_relaxed(GPLL1_CONFIG_REG);
5617
5618 /* Set pre-divider and post-divider values to 1 and 1 */
5619 regval &= ~BIT(15);
5620 regval |= BIT(16);
5621
5622 writel_relaxed(regval, GPLL1_CONFIG_REG);
5623
5624 /* Set VCO frequency */
5625 rmwreg(0x180, GPLL1_CONFIG_REG, 0x180);
5626 }
5627 /* Check if PLL14 is active */
5628 is_pll_enabled = readl_relaxed(BB_PLL14_STATUS_REG) & BIT(16);
5629 if (!is_pll_enabled) {
5630 /* Ref clk = 24.5MHz and program pll14 to 480MHz */
5631 writel_relaxed(0x13, BB_PLL14_L_VAL_REG);
5632 writel_relaxed(0x1D, BB_PLL14_M_VAL_REG);
5633 writel_relaxed(0x31, BB_PLL14_N_VAL_REG);
5634
5635 regval = readl_relaxed(BB_PLL14_CONFIG_REG);
5636
5637 /* Enable the main output and the MN accumulator */
5638 regval |= BIT(23) | BIT(22);
5639
5640 /* Set pre-divider and post-divider values to 1 and 1 */
5641 regval &= ~BIT(19);
5642 regval &= ~BM(21, 20);
5643
5644 writel_relaxed(regval, BB_PLL14_CONFIG_REG);
5645
5646 /* Set VCO frequency */
5647 rmwreg(0x10000, BB_PLL14_CONFIG_REG, 0x30000);
5648
Tianyi Gou41515e22011-09-01 19:37:43 -07005649 set_fsm_mode(BB_PLL14_MODE_REG);
5650 }
Tianyi Gou621f8742011-09-01 21:45:01 -07005651 /* Program PLL2 to 800MHz with ref clk = 27MHz */
5652 writel_relaxed(0x1D, MM_PLL1_L_VAL_REG);
5653 writel_relaxed(0x11, MM_PLL1_M_VAL_REG);
5654 writel_relaxed(0x1B, MM_PLL1_N_VAL_REG);
5655
5656 regval = readl_relaxed(MM_PLL1_CONFIG_REG);
5657
5658 /* Enable the main output and the MN accumulator */
5659 regval |= BIT(23) | BIT(22);
5660
5661 /* Set pre-divider and post-divider values to 1 and 1 */
5662 regval &= ~BIT(19);
5663 regval &= ~BM(21, 20);
5664
5665 writel_relaxed(regval, MM_PLL1_CONFIG_REG);
5666
5667 /* Set VCO frequency */
5668 rmwreg(0x20000, MM_PLL1_CONFIG_REG, 0x30000);
5669
Tianyi Gou621f8742011-09-01 21:45:01 -07005670 /* Program PLL15 to 975MHz with ref clk = 27MHz */
5671 writel_relaxed(0x24, MM_PLL3_L_VAL_REG);
5672 writel_relaxed(0x1, MM_PLL3_M_VAL_REG);
5673 writel_relaxed(0x9, MM_PLL3_N_VAL_REG);
5674
5675 regval = readl_relaxed(MM_PLL3_CONFIG_REG);
5676
5677 /* Enable the main output and the MN accumulator */
5678 regval |= BIT(23) | BIT(22);
5679
5680 /* Set pre-divider and post-divider values to 1 and 1 */
5681 regval &= ~BIT(19);
5682 regval &= ~BM(21, 20);
5683
5684 writel_relaxed(regval, MM_PLL3_CONFIG_REG);
5685
5686 /* Set VCO frequency */
5687 rmwreg(0x20000, MM_PLL3_CONFIG_REG, 0x30000);
5688
5689 /* Enable AUX output */
5690 regval = readl_relaxed(MM_PLL3_TEST_CTL_REG);
5691 regval |= BIT(12);
5692 writel_relaxed(regval, MM_PLL3_TEST_CTL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005693
5694 /* Check if PLL4 is active */
5695 is_pll_enabled = readl_relaxed(LCC_PLL0_STATUS_REG) & BIT(16);
5696 if (!is_pll_enabled) {
5697 /* Ref clk = 24.5MHz and program pll4 to 393.2160MHz */
5698 writel_relaxed(0x10, LCC_PLL0_L_VAL_REG);
5699 writel_relaxed(0x130, LCC_PLL0_M_VAL_REG);
5700 writel_relaxed(0x17ED, LCC_PLL0_N_VAL_REG);
5701
5702 regval = readl_relaxed(LCC_PLL0_CONFIG_REG);
5703
5704 /* Enable the main output and the MN accumulator */
5705 regval |= BIT(23) | BIT(22);
5706
5707 /* Set pre-divider and post-divider values to 1 and 1 */
5708 regval &= ~BIT(19);
5709 regval &= ~BM(21, 20);
5710
5711 /* Set VCO frequency */
5712 regval &= ~BM(17, 16);
5713 writel_relaxed(regval, LCC_PLL0_CONFIG_REG);
5714
5715 set_fsm_mode(LCC_PLL0_MODE_REG);
5716 }
5717
5718 /* Enable PLL4 source on the LPASS Primary PLL Mux */
5719 writel_relaxed(0x1, LCC_PRI_PLL_CLK_CTL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005720 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005721}
5722
Stephen Boyd94625ef2011-07-12 17:06:01 -07005723struct clock_init_data msm8960_clock_init_data __initdata;
5724
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005725/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07005726static void __init msm8960_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005727{
Stephen Boyd94625ef2011-07-12 17:06:01 -07005728 size_t num_lookups = ARRAY_SIZE(msm_clocks_8960_v1);
Tianyi Gou41515e22011-09-01 19:37:43 -07005729
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005730 xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8960");
5731 if (IS_ERR(xo_pxo)) {
5732 pr_err("%s: msm_xo_get(PXO) failed.\n", __func__);
5733 BUG();
5734 }
5735 xo_cxo = msm_xo_get(MSM_XO_TCXO_D0, "clock-8960");
5736 if (IS_ERR(xo_cxo)) {
5737 pr_err("%s: msm_xo_get(CXO) failed.\n", __func__);
5738 BUG();
5739 }
5740
Tianyi Gou41515e22011-09-01 19:37:43 -07005741 if (cpu_is_msm8960()) {
5742 memcpy(msm_clocks_8960, msm_clocks_8960_v1,
5743 sizeof(msm_clocks_8960_v1));
5744 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5745 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8960_v2;
5746 memcpy(msm_clocks_8960 + ARRAY_SIZE(msm_clocks_8960_v1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07005747 msm_clocks_8960_v2, sizeof(msm_clocks_8960_v2));
Tianyi Gou41515e22011-09-01 19:37:43 -07005748 num_lookups = ARRAY_SIZE(msm_clocks_8960);
5749 }
5750 msm8960_clock_init_data.size = num_lookups;
Stephen Boyd94625ef2011-07-12 17:06:01 -07005751 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005752
5753 /*
5754 * Change the freq tables for gfx3d_clk, ijpeg_clk, mdp_clk,
Tianyi Gou621f8742011-09-01 21:45:01 -07005755 * tv_src_clk and vfe_clk at runtime and chain gmem_axi_clk
5756 * with gfx3d_axi_clk for 8064.
Tianyi Gou41515e22011-09-01 19:37:43 -07005757 */
5758 if (cpu_is_apq8064()) {
5759 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8064;
5760 ijpeg_clk.freq_tbl = clk_tbl_ijpeg_8064;
Tianyi Gou621f8742011-09-01 21:45:01 -07005761 mdp_clk.freq_tbl = clk_tbl_mdp_8064;
Tianyi Gou41515e22011-09-01 19:37:43 -07005762 vfe_clk.freq_tbl = clk_tbl_vfe_8064;
Tianyi Gou621f8742011-09-01 21:45:01 -07005763 gmem_axi_clk.c.depends = &gfx3d_axi_clk.c;
Tianyi Gou41515e22011-09-01 19:37:43 -07005764 }
Stephen Boyd94625ef2011-07-12 17:06:01 -07005765
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005766 soc_update_sys_vdd = msm8960_update_sys_vdd;
5767 local_vote_sys_vdd(HIGH);
5768
Vikram Mulukutla489e39e2011-08-31 18:04:05 -07005769 clk_ops_pll.enable = sr_pll_clk_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005770
5771 /* Initialize clock registers. */
5772 reg_init();
5773
5774 /* Initialize rates for clocks that only support one. */
5775 clk_set_rate(&pdm_clk.c, 27000000);
5776 clk_set_rate(&prng_clk.c, 64000000);
5777 clk_set_rate(&mdp_vsync_clk.c, 27000000);
5778 clk_set_rate(&tsif_ref_clk.c, 105000);
5779 clk_set_rate(&tssc_clk.c, 27000000);
5780 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
Tianyi Gou41515e22011-09-01 19:37:43 -07005781 if (cpu_is_apq8064()) {
5782 clk_set_rate(&usb_hs3_xcvr_clk.c, 60000000);
5783 clk_set_rate(&usb_hs4_xcvr_clk.c, 60000000);
5784 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005785 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
Tianyi Gou41515e22011-09-01 19:37:43 -07005786 if (cpu_is_msm8960())
5787 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005788 clk_set_rate(&usb_hsic_xcvr_fs_clk.c, 60000000);
5789 clk_set_rate(&usb_hsic_hsic_src_clk.c, 480000000);
5790 clk_set_rate(&usb_hsic_hsio_cal_clk.c, 9000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005791
5792 /*
Stephen Boyd60496bb2011-10-17 13:51:37 -07005793 * The halt status bits for these clocks may be incorrect at boot.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005794 * Toggle these clocks on and off to refresh them.
5795 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07005796 rcg_clk_enable(&pdm_clk.c);
5797 rcg_clk_disable(&pdm_clk.c);
5798 rcg_clk_enable(&tssc_clk.c);
5799 rcg_clk_disable(&tssc_clk.c);
Stephen Boyd60496bb2011-10-17 13:51:37 -07005800 if (cpu_is_msm8960() &&
5801 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5802 clk_enable(&usb_hsic_hsic_clk.c);
5803 clk_disable(&usb_hsic_hsic_clk.c);
5804 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005805
5806 if (machine_is_msm8960_sim()) {
5807 clk_set_rate(&sdc1_clk.c, 48000000);
5808 clk_enable(&sdc1_clk.c);
5809 clk_enable(&sdc1_p_clk.c);
5810 clk_set_rate(&sdc3_clk.c, 48000000);
5811 clk_enable(&sdc3_clk.c);
5812 clk_enable(&sdc3_p_clk.c);
5813 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005814}
5815
Stephen Boydbb600ae2011-08-02 20:11:40 -07005816static int __init msm8960_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005817{
Stephen Boyda3787f32011-09-16 18:55:13 -07005818 int rc;
5819 struct clk *mmfpb_a_clk = clk_get_sys("clock-8960", "mmfpb_a_clk");
Stephen Boyd85436132011-09-16 18:55:13 -07005820 struct clk *cfpb_a_clk = clk_get_sys("clock-8960", "cfpb_a_clk");
Stephen Boyda3787f32011-09-16 18:55:13 -07005821
5822 /* Vote for MMFPB to be at least 76.8MHz when an Apps CPU is active. */
5823 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
5824 PTR_ERR(mmfpb_a_clk)))
5825 return PTR_ERR(mmfpb_a_clk);
5826 rc = clk_set_min_rate(mmfpb_a_clk, 76800000);
5827 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
5828 return rc;
5829 rc = clk_enable(mmfpb_a_clk);
5830 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
5831 return rc;
5832
Stephen Boyd85436132011-09-16 18:55:13 -07005833 /* Vote for CFPB to be at least 64MHz when an Apps CPU is active. */
5834 if (WARN(IS_ERR(cfpb_a_clk), "cfpb_a_clk not found (%ld)\n",
5835 PTR_ERR(cfpb_a_clk)))
5836 return PTR_ERR(cfpb_a_clk);
5837 rc = clk_set_min_rate(cfpb_a_clk, 64000000);
5838 if (WARN(rc, "cfpb_a_clk rate was not set (%d)\n", rc))
5839 return rc;
5840 rc = clk_enable(cfpb_a_clk);
5841 if (WARN(rc, "cfpb_a_clk not enabled (%d)\n", rc))
5842 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005843 return local_unvote_sys_vdd(HIGH);
5844}
Stephen Boydbb600ae2011-08-02 20:11:40 -07005845
5846struct clock_init_data msm8960_clock_init_data __initdata = {
5847 .table = msm_clocks_8960,
5848 .size = ARRAY_SIZE(msm_clocks_8960),
5849 .init = msm8960_clock_init,
5850 .late_init = msm8960_clock_late_init,
5851};
Tianyi Gou41515e22011-09-01 19:37:43 -07005852
5853struct clock_init_data apq8064_clock_init_data __initdata = {
5854 .table = msm_clocks_8064,
5855 .size = ARRAY_SIZE(msm_clocks_8064),
5856 .init = msm8960_clock_init,
5857 .late_init = msm8960_clock_late_init,
5858};