blob: 615a6b508fcf28b2d58da7d271b999531025af26 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/err.h>
16#include <linux/ctype.h>
17#include <linux/bitops.h>
18#include <linux/io.h>
19#include <linux/spinlock.h>
20#include <linux/delay.h>
21#include <linux/clk.h>
22
23#include <asm/clkdev.h>
24#include <asm/mach-types.h>
25
26#include <mach/msm_iomap.h>
27#include <mach/clk.h>
28#include <mach/rpm-regulator.h>
29#include <mach/msm_xo.h>
Stephen Boyd94625ef2011-07-12 17:06:01 -070030#include <mach/socinfo.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070031
32#include "clock-local.h"
33#include "clock-rpm.h"
34#include "clock-voter.h"
35#include "clock-dss-8960.h"
36#include "devices.h"
37
38#define REG(off) (MSM_CLK_CTL_BASE + (off))
39#define REG_MM(off) (MSM_MMSS_CLK_CTL_BASE + (off))
40#define REG_LPA(off) (MSM_LPASS_CLK_CTL_BASE + (off))
Matt Wagantall8b38f942011-08-02 18:23:18 -070041#define REG_GCC(off) (MSM_APCS_GCC_BASE + (off))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070042
43/* Peripheral clock registers. */
44#define CE1_HCLK_CTL_REG REG(0x2720)
45#define CE1_CORE_CLK_CTL_REG REG(0x2724)
Tianyi Gou41515e22011-09-01 19:37:43 -070046#define CE3_HCLK_CTL_REG REG(0x36C4)
47#define CE3_CORE_CLK_CTL_REG REG(0x36CC)
48#define CE3_CLK_SRC_NS_REG REG(0x36C0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049#define DMA_BAM_HCLK_CTL REG(0x25C0)
Tianyi Gou41515e22011-09-01 19:37:43 -070050#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#define CLK_HALT_CFPB_STATEA_REG REG(0x2FCC)
52#define CLK_HALT_CFPB_STATEB_REG REG(0x2FD0)
53#define CLK_HALT_CFPB_STATEC_REG REG(0x2FD4)
54#define CLK_HALT_DFAB_STATE_REG REG(0x2FC8)
Tianyi Gou41515e22011-09-01 19:37:43 -070055/* 8064 name CLK_HALT_GSS_KPSS_MISC_STATE_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#define CLK_HALT_MSS_SMPSS_MISC_STATE_REG REG(0x2FDC)
57#define CLK_HALT_SFPB_MISC_STATE_REG REG(0x2FD8)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070058#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070059#define CLK_TEST_REG REG(0x2FA0)
60#define GSBIn_HCLK_CTL_REG(n) REG(0x29C0+(0x20*((n)-1)))
61#define GSBIn_QUP_APPS_MD_REG(n) REG(0x29C8+(0x20*((n)-1)))
62#define GSBIn_QUP_APPS_NS_REG(n) REG(0x29CC+(0x20*((n)-1)))
63#define GSBIn_RESET_REG(n) REG(0x29DC+(0x20*((n)-1)))
64#define GSBIn_UART_APPS_MD_REG(n) REG(0x29D0+(0x20*((n)-1)))
65#define GSBIn_UART_APPS_NS_REG(n) REG(0x29D4+(0x20*((n)-1)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070066#define PDM_CLK_NS_REG REG(0x2CC0)
Tianyi Gou41515e22011-09-01 19:37:43 -070067/* 8064 name BB_PLL_ENA_APCS_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070068#define BB_PLL_ENA_SC0_REG REG(0x34C0)
69#define BB_PLL0_STATUS_REG REG(0x30D8)
70#define BB_PLL5_STATUS_REG REG(0x30F8)
71#define BB_PLL6_STATUS_REG REG(0x3118)
72#define BB_PLL7_STATUS_REG REG(0x3138)
73#define BB_PLL8_L_VAL_REG REG(0x3144)
74#define BB_PLL8_M_VAL_REG REG(0x3148)
75#define BB_PLL8_MODE_REG REG(0x3140)
76#define BB_PLL8_N_VAL_REG REG(0x314C)
77#define BB_PLL8_STATUS_REG REG(0x3158)
78#define BB_PLL8_CONFIG_REG REG(0x3154)
79#define BB_PLL8_TEST_CTL_REG REG(0x3150)
Stephen Boyd94625ef2011-07-12 17:06:01 -070080#define BB_MMCC_PLL2_MODE_REG REG(0x3160)
81#define BB_MMCC_PLL2_TEST_CTL_REG REG(0x3170)
Tianyi Gou41515e22011-09-01 19:37:43 -070082#define BB_PLL14_MODE_REG REG(0x31C0)
83#define BB_PLL14_L_VAL_REG REG(0x31C4)
84#define BB_PLL14_M_VAL_REG REG(0x31C8)
85#define BB_PLL14_N_VAL_REG REG(0x31CC)
86#define BB_PLL14_TEST_CTL_REG REG(0x31D0)
87#define BB_PLL14_CONFIG_REG REG(0x31D4)
Stephen Boyd94625ef2011-07-12 17:06:01 -070088#define BB_PLL14_STATUS_REG REG(0x31D8)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089#define PLLTEST_PAD_CFG_REG REG(0x2FA4)
90#define PMEM_ACLK_CTL_REG REG(0x25A0)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070091#define QDSS_AT_CLK_SRC0_NS_REG REG(0x2180)
92#define QDSS_AT_CLK_SRC1_NS_REG REG(0x2184)
93#define QDSS_AT_CLK_SRC_CTL_REG REG(0x2188)
94#define QDSS_AT_CLK_NS_REG REG(0x218C)
95#define QDSS_HCLK_CTL_REG REG(0x22A0)
96#define QDSS_RESETS_REG REG(0x2260)
97#define QDSS_STM_CLK_CTL_REG REG(0x2060)
98#define QDSS_TRACECLKIN_CLK_SRC0_NS_REG REG(0x21A0)
99#define QDSS_TRACECLKIN_CLK_SRC1_NS_REG REG(0x21A4)
100#define QDSS_TRACECLKIN_CLK_SRC_CTL_REG REG(0x21A8)
101#define QDSS_TRACECLKIN_CTL_REG REG(0x21AC)
102#define QDSS_TSCTR_CLK_SRC0_NS_REG REG(0x21C0)
103#define QDSS_TSCTR_CLK_SRC1_NS_REG REG(0x21C4)
104#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
105#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
106#define QDSS_TSCTR_CTL_REG REG(0x21CC)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107#define RINGOSC_NS_REG REG(0x2DC0)
108#define RINGOSC_STATUS_REG REG(0x2DCC)
109#define RINGOSC_TCXO_CTL_REG REG(0x2DC4)
110#define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080)
111#define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1)))
112#define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1)))
113#define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1)))
114#define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1)))
115#define SLIMBUS_XO_SRC_CLK_CTL_REG REG(0x2628)
116#define TSIF_HCLK_CTL_REG REG(0x2700)
117#define TSIF_REF_CLK_MD_REG REG(0x270C)
118#define TSIF_REF_CLK_NS_REG REG(0x2710)
119#define TSSC_CLK_CTL_REG REG(0x2CA0)
Tianyi Gou41515e22011-09-01 19:37:43 -0700120#define SATA_CLK_SRC_NS_REG REG(0x2C08)
121#define SATA_RXOOB_CLK_CTL_REG REG(0x2C0C)
122#define SATA_PMALIVE_CLK_CTL_REG REG(0x2C10)
123#define SATA_PHY_REF_CLK_CTL_REG REG(0x2C14)
124#define SATA_PHY_CFG_CLK_CTL_REG REG(0x2C40)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700125#define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1)))
126#define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1)))
127#define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1)))
128#define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1)))
129#define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1)))
130#define USB_HS1_HCLK_CTL_REG REG(0x2900)
Tianyi Gou41515e22011-09-01 19:37:43 -0700131#define USB_HS1_HCLK_FS_REG REG(0x2904)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700132#define USB_HS1_RESET_REG REG(0x2910)
133#define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908)
134#define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700135#define USB_HS3_HCLK_CTL_REG REG(0x3700)
136#define USB_HS3_HCLK_FS_REG REG(0x3704)
137#define USB_HS3_RESET_REG REG(0x3710)
138#define USB_HS3_XCVR_FS_CLK_MD_REG REG(0X3708)
139#define USB_HS3_XCVR_FS_CLK_NS_REG REG(0X370C)
140#define USB_HS4_HCLK_CTL_REG REG(0x3720)
141#define USB_HS4_HCLK_FS_REG REG(0x3724)
142#define USB_HS4_RESET_REG REG(0x3730)
143#define USB_HS4_XCVR_FS_CLK_MD_REG REG(0X3728)
144#define USB_HS4_XCVR_FS_CLK_NS_REG REG(0X372C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700145#define USB_HSIC_HCLK_CTL_REG REG(0x2920)
146#define USB_HSIC_HSIC_CLK_CTL_REG REG(0x2B44)
147#define USB_HSIC_HSIC_CLK_SRC_CTL_REG REG(0x2B40)
148#define USB_HSIC_HSIO_CAL_CLK_CTL_REG REG(0x2B48)
149#define USB_HSIC_RESET_REG REG(0x2934)
150#define USB_HSIC_SYSTEM_CLK_CTL_REG REG(0x292C)
151#define USB_HSIC_XCVR_FS_CLK_MD_REG REG(0x2924)
152#define USB_HSIC_XCVR_FS_CLK_NS_REG REG(0x2928)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153#define USB_PHY0_RESET_REG REG(0x2E20)
Tianyi Gou41515e22011-09-01 19:37:43 -0700154#define PCIE_ALT_REF_CLK_NS_REG REG(0x3860)
155#define PCIE_HCLK_CTL_REG REG(0x22CC)
156#define GPLL1_MODE_REG REG(0x3160)
157#define GPLL1_L_VAL_REG REG(0x3164)
158#define GPLL1_M_VAL_REG REG(0x3168)
159#define GPLL1_N_VAL_REG REG(0x316C)
160#define GPLL1_CONFIG_REG REG(0x3174)
161#define GPLL1_STATUS_REG REG(0x3178)
162#define PXO_SRC_CLK_CTL_REG REG(0x2EA0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700163
164/* Multimedia clock registers. */
165#define AHB_EN_REG REG_MM(0x0008)
166#define AHB_EN2_REG REG_MM(0x0038)
Tianyi Gou41515e22011-09-01 19:37:43 -0700167#define AHB_EN3_REG REG_MM(0x0248)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700168#define AHB_NS_REG REG_MM(0x0004)
169#define AXI_NS_REG REG_MM(0x0014)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700170#define CAMCLK0_NS_REG REG_MM(0x0148)
171#define CAMCLK0_CC_REG REG_MM(0x0140)
172#define CAMCLK0_MD_REG REG_MM(0x0144)
173#define CAMCLK1_NS_REG REG_MM(0x015C)
174#define CAMCLK1_CC_REG REG_MM(0x0154)
175#define CAMCLK1_MD_REG REG_MM(0x0158)
176#define CAMCLK2_NS_REG REG_MM(0x0228)
177#define CAMCLK2_CC_REG REG_MM(0x0220)
178#define CAMCLK2_MD_REG REG_MM(0x0224)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700179#define CSI0_NS_REG REG_MM(0x0048)
180#define CSI0_CC_REG REG_MM(0x0040)
181#define CSI0_MD_REG REG_MM(0x0044)
182#define CSI1_NS_REG REG_MM(0x0010)
183#define CSI1_CC_REG REG_MM(0x0024)
184#define CSI1_MD_REG REG_MM(0x0028)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700185#define CSI2_NS_REG REG_MM(0x0234)
186#define CSI2_CC_REG REG_MM(0x022C)
187#define CSI2_MD_REG REG_MM(0x0230)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700188#define CSIPHYTIMER_CC_REG REG_MM(0x0160)
189#define CSIPHYTIMER_MD_REG REG_MM(0x0164)
190#define CSIPHYTIMER_NS_REG REG_MM(0x0168)
191#define DSI1_BYTE_NS_REG REG_MM(0x00B0)
192#define DSI1_BYTE_CC_REG REG_MM(0x0090)
193#define DSI2_BYTE_NS_REG REG_MM(0x00BC)
194#define DSI2_BYTE_CC_REG REG_MM(0x00B4)
195#define DSI1_ESC_NS_REG REG_MM(0x011C)
196#define DSI1_ESC_CC_REG REG_MM(0x00CC)
197#define DSI2_ESC_NS_REG REG_MM(0x0150)
198#define DSI2_ESC_CC_REG REG_MM(0x013C)
199#define DSI_PIXEL_CC_REG REG_MM(0x0130)
200#define DSI2_PIXEL_CC_REG REG_MM(0x0094)
201#define DBG_BUS_VEC_A_REG REG_MM(0x01C8)
202#define DBG_BUS_VEC_B_REG REG_MM(0x01CC)
203#define DBG_BUS_VEC_C_REG REG_MM(0x01D0)
204#define DBG_BUS_VEC_D_REG REG_MM(0x01D4)
205#define DBG_BUS_VEC_E_REG REG_MM(0x01D8)
206#define DBG_BUS_VEC_F_REG REG_MM(0x01DC)
207#define DBG_BUS_VEC_G_REG REG_MM(0x01E0)
208#define DBG_BUS_VEC_H_REG REG_MM(0x01E4)
209#define DBG_BUS_VEC_I_REG REG_MM(0x01E8)
Tianyi Gou41515e22011-09-01 19:37:43 -0700210#define DBG_BUS_VEC_J_REG REG_MM(0x0240)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700211#define DBG_CFG_REG_HS_REG REG_MM(0x01B4)
212#define DBG_CFG_REG_LS_REG REG_MM(0x01B8)
213#define GFX2D0_CC_REG REG_MM(0x0060)
214#define GFX2D0_MD0_REG REG_MM(0x0064)
215#define GFX2D0_MD1_REG REG_MM(0x0068)
216#define GFX2D0_NS_REG REG_MM(0x0070)
217#define GFX2D1_CC_REG REG_MM(0x0074)
218#define GFX2D1_MD0_REG REG_MM(0x0078)
219#define GFX2D1_MD1_REG REG_MM(0x006C)
220#define GFX2D1_NS_REG REG_MM(0x007C)
221#define GFX3D_CC_REG REG_MM(0x0080)
222#define GFX3D_MD0_REG REG_MM(0x0084)
223#define GFX3D_MD1_REG REG_MM(0x0088)
224#define GFX3D_NS_REG REG_MM(0x008C)
225#define IJPEG_CC_REG REG_MM(0x0098)
226#define IJPEG_MD_REG REG_MM(0x009C)
227#define IJPEG_NS_REG REG_MM(0x00A0)
228#define JPEGD_CC_REG REG_MM(0x00A4)
229#define JPEGD_NS_REG REG_MM(0x00AC)
Tianyi Gou41515e22011-09-01 19:37:43 -0700230#define VCAP_CC_REG REG_MM(0x0178)
231#define VCAP_NS_REG REG_MM(0x021C)
232#define VCAP_MD0_REG REG_MM(0x01EC)
233#define VCAP_MD1_REG REG_MM(0x0218)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700234#define MAXI_EN_REG REG_MM(0x0018)
235#define MAXI_EN2_REG REG_MM(0x0020)
236#define MAXI_EN3_REG REG_MM(0x002C)
237#define MAXI_EN4_REG REG_MM(0x0114)
Tianyi Gou41515e22011-09-01 19:37:43 -0700238#define MAXI_EN5_REG REG_MM(0x0244)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700239#define MDP_CC_REG REG_MM(0x00C0)
240#define MDP_LUT_CC_REG REG_MM(0x016C)
241#define MDP_MD0_REG REG_MM(0x00C4)
242#define MDP_MD1_REG REG_MM(0x00C8)
243#define MDP_NS_REG REG_MM(0x00D0)
244#define MISC_CC_REG REG_MM(0x0058)
245#define MISC_CC2_REG REG_MM(0x005C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700246#define MISC_CC3_REG REG_MM(0x0238)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700247#define MM_PLL1_MODE_REG REG_MM(0x031C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700248#define MM_PLL1_L_VAL_REG REG_MM(0x0320)
249#define MM_PLL1_M_VAL_REG REG_MM(0x0324)
250#define MM_PLL1_N_VAL_REG REG_MM(0x0328)
251#define MM_PLL1_CONFIG_REG REG_MM(0x032C)
252#define MM_PLL1_TEST_CTL_REG REG_MM(0x0330)
253#define MM_PLL1_STATUS_REG REG_MM(0x0334)
254#define MM_PLL3_MODE_REG REG_MM(0x0338)
Tianyi Gou621f8742011-09-01 21:45:01 -0700255#define MM_PLL3_L_VAL_REG REG_MM(0x033C)
256#define MM_PLL3_M_VAL_REG REG_MM(0x0340)
257#define MM_PLL3_N_VAL_REG REG_MM(0x0344)
258#define MM_PLL3_CONFIG_REG REG_MM(0x0348)
259#define MM_PLL3_TEST_CTL_REG REG_MM(0x034C)
260#define MM_PLL3_STATUS_REG REG_MM(0x0350)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700261#define ROT_CC_REG REG_MM(0x00E0)
262#define ROT_NS_REG REG_MM(0x00E8)
263#define SAXI_EN_REG REG_MM(0x0030)
264#define SW_RESET_AHB_REG REG_MM(0x020C)
265#define SW_RESET_AHB2_REG REG_MM(0x0200)
266#define SW_RESET_ALL_REG REG_MM(0x0204)
267#define SW_RESET_AXI_REG REG_MM(0x0208)
268#define SW_RESET_CORE_REG REG_MM(0x0210)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700269#define SW_RESET_CORE2_REG REG_MM(0x0214)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700270#define TV_CC_REG REG_MM(0x00EC)
271#define TV_CC2_REG REG_MM(0x0124)
272#define TV_MD_REG REG_MM(0x00F0)
273#define TV_NS_REG REG_MM(0x00F4)
274#define VCODEC_CC_REG REG_MM(0x00F8)
275#define VCODEC_MD0_REG REG_MM(0x00FC)
276#define VCODEC_MD1_REG REG_MM(0x0128)
277#define VCODEC_NS_REG REG_MM(0x0100)
278#define VFE_CC_REG REG_MM(0x0104)
279#define VFE_MD_REG REG_MM(0x0108)
280#define VFE_NS_REG REG_MM(0x010C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700281#define VFE_CC2_REG REG_MM(0x023C)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700282#define VPE_CC_REG REG_MM(0x0110)
283#define VPE_NS_REG REG_MM(0x0118)
284
285/* Low-power Audio clock registers. */
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700286#define LCC_CLK_HS_DEBUG_CFG_REG REG_LPA(0x00A4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700287#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
288#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
289#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
290#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
291#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
292#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
293#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
294#define LCC_MI2S_MD_REG REG_LPA(0x004C)
295#define LCC_MI2S_NS_REG REG_LPA(0x0048)
296#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
297#define LCC_PCM_MD_REG REG_LPA(0x0058)
298#define LCC_PCM_NS_REG REG_LPA(0x0054)
299#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700300#define LCC_PLL0_MODE_REG REG_LPA(0x0000)
301#define LCC_PLL0_L_VAL_REG REG_LPA(0x0004)
302#define LCC_PLL0_M_VAL_REG REG_LPA(0x0008)
303#define LCC_PLL0_N_VAL_REG REG_LPA(0x000C)
304#define LCC_PLL0_CONFIG_REG REG_LPA(0x0014)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700305#define LCC_PLL0_STATUS_REG REG_LPA(0x0018)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700306#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
307#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
308#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
309#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
310#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
311#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
312#define LCC_SLIMBUS_NS_REG REG_LPA(0x00CC)
313#define LCC_SLIMBUS_MD_REG REG_LPA(0x00D0)
314#define LCC_SLIMBUS_STATUS_REG REG_LPA(0x00D4)
315#define LCC_AHBEX_BRANCH_CTL_REG REG_LPA(0x00E4)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700316#define LCC_PRI_PLL_CLK_CTL_REG REG_LPA(0x00C4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700317
Matt Wagantall8b38f942011-08-02 18:23:18 -0700318#define GCC_APCS_CLK_DIAG REG_GCC(0x001C)
319
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700320/* MUX source input identifiers. */
321#define pxo_to_bb_mux 0
322#define cxo_to_bb_mux pxo_to_bb_mux
323#define pll0_to_bb_mux 2
324#define pll8_to_bb_mux 3
325#define pll6_to_bb_mux 4
326#define gnd_to_bb_mux 5
Stephen Boyd94625ef2011-07-12 17:06:01 -0700327#define pll3_to_bb_mux 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700328#define pxo_to_mm_mux 0
329#define pll1_to_mm_mux 1
Tianyi Gou41515e22011-09-01 19:37:43 -0700330#define pll2_to_mm_mux 1 /* or MMCC_PLL1 */
331#define pll8_to_mm_mux 2 /* or GCC_PERF */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332#define pll0_to_mm_mux 3
Tianyi Gou41515e22011-09-01 19:37:43 -0700333#define pll15_to_mm_mux 3 /* or MM_PLL3 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700334#define gnd_to_mm_mux 4
Stephen Boyd7a776cd2011-10-20 12:46:04 -0700335#define pll3_to_mm_mux 3 /* or MMCC_PLL2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700336#define hdmi_pll_to_mm_mux 3
337#define cxo_to_xo_mux 0
338#define pxo_to_xo_mux 1
339#define gnd_to_xo_mux 3
340#define pxo_to_lpa_mux 0
341#define cxo_to_lpa_mux 1
342#define pll4_to_lpa_mux 2
343#define gnd_to_lpa_mux 6
Tianyi Gou41515e22011-09-01 19:37:43 -0700344#define pxo_to_pcie_mux 0
345#define pll3_to_pcie_mux 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700346
347/* Test Vector Macros */
348#define TEST_TYPE_PER_LS 1
349#define TEST_TYPE_PER_HS 2
350#define TEST_TYPE_MM_LS 3
351#define TEST_TYPE_MM_HS 4
352#define TEST_TYPE_LPA 5
Matt Wagantall8b38f942011-08-02 18:23:18 -0700353#define TEST_TYPE_CPUL2 6
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700354#define TEST_TYPE_LPA_HS 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700355#define TEST_TYPE_SHIFT 24
356#define TEST_CLK_SEL_MASK BM(23, 0)
357#define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s)))
358#define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS)
359#define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS)
360#define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS)
361#define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS)
362#define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA)
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700363#define TEST_LPA_HS(s) TEST_VECTOR((s), TEST_TYPE_LPA_HS)
Matt Wagantall8b38f942011-08-02 18:23:18 -0700364#define TEST_CPUL2(s) TEST_VECTOR((s), TEST_TYPE_CPUL2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700365
366#define MN_MODE_DUAL_EDGE 0x2
367
368/* MD Registers */
369#define MD4(m_lsb, m, n_lsb, n) \
370 (BVAL((m_lsb+3), m_lsb, m) | BVAL((n_lsb+3), n_lsb, ~(n)))
371#define MD8(m_lsb, m, n_lsb, n) \
372 (BVAL((m_lsb+7), m_lsb, m) | BVAL((n_lsb+7), n_lsb, ~(n)))
373#define MD16(m, n) (BVAL(31, 16, m) | BVAL(15, 0, ~(n)))
374
375/* NS Registers */
376#define NS(n_msb, n_lsb, n, m, mde_lsb, d_msb, d_lsb, d, s_msb, s_lsb, s) \
377 (BVAL(n_msb, n_lsb, ~(n-m)) \
378 | (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n)) \
379 | BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
380
381#define NS_MM(n_msb, n_lsb, n, m, d_msb, d_lsb, d, s_msb, s_lsb, s) \
382 (BVAL(n_msb, n_lsb, ~(n-m)) | BVAL(d_msb, d_lsb, (d-1)) \
383 | BVAL(s_msb, s_lsb, s))
384
385#define NS_DIVSRC(d_msb , d_lsb, d, s_msb, s_lsb, s) \
386 (BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
387
388#define NS_DIV(d_msb , d_lsb, d) \
389 BVAL(d_msb, d_lsb, (d-1))
390
391#define NS_SRC_SEL(s_msb, s_lsb, s) \
392 BVAL(s_msb, s_lsb, s)
393
394#define NS_MND_BANKED4(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
395 (BVAL((n0_lsb+3), n0_lsb, ~(n-m)) \
396 | BVAL((n1_lsb+3), n1_lsb, ~(n-m)) \
397 | BVAL((s0_lsb+2), s0_lsb, s) \
398 | BVAL((s1_lsb+2), s1_lsb, s))
399
400#define NS_MND_BANKED8(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
401 (BVAL((n0_lsb+7), n0_lsb, ~(n-m)) \
402 | BVAL((n1_lsb+7), n1_lsb, ~(n-m)) \
403 | BVAL((s0_lsb+2), s0_lsb, s) \
404 | BVAL((s1_lsb+2), s1_lsb, s))
405
406#define NS_DIVSRC_BANKED(d0_msb, d0_lsb, d1_msb, d1_lsb, d, \
407 s0_msb, s0_lsb, s1_msb, s1_lsb, s) \
408 (BVAL(d0_msb, d0_lsb, (d-1)) | BVAL(d1_msb, d1_lsb, (d-1)) \
409 | BVAL(s0_msb, s0_lsb, s) \
410 | BVAL(s1_msb, s1_lsb, s))
411
412/* CC Registers */
413#define CC(mde_lsb, n) (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n))
414#define CC_BANKED(mde0_lsb, mde1_lsb, n) \
415 ((BVAL((mde0_lsb+1), mde0_lsb, MN_MODE_DUAL_EDGE) \
416 | BVAL((mde1_lsb+1), mde1_lsb, MN_MODE_DUAL_EDGE)) \
417 * !!(n))
418
419struct pll_rate {
420 const uint32_t l_val;
421 const uint32_t m_val;
422 const uint32_t n_val;
423 const uint32_t vco;
424 const uint32_t post_div;
425 const uint32_t i_bits;
426};
427#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
428
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700429enum vdd_dig_levels {
430 VDD_DIG_NONE,
431 VDD_DIG_LOW,
432 VDD_DIG_NOMINAL,
433 VDD_DIG_HIGH
434};
435
436static int set_vdd_dig(struct clk_vdd_class *vdd_class, int level)
437{
438 static const int vdd_uv[] = {
439 [VDD_DIG_NONE] = 0,
440 [VDD_DIG_LOW] = 945000,
441 [VDD_DIG_NOMINAL] = 1050000,
442 [VDD_DIG_HIGH] = 1150000
443 };
444
445 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
446 vdd_uv[level], 1150000, 1);
447}
448
449static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig);
450
451#define VDD_DIG_FMAX_MAP1(l1, f1) \
452 .vdd_class = &vdd_dig, \
453 .fmax[VDD_DIG_##l1] = (f1)
454#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
455 .vdd_class = &vdd_dig, \
456 .fmax[VDD_DIG_##l1] = (f1), \
457 .fmax[VDD_DIG_##l2] = (f2)
458#define VDD_DIG_FMAX_MAP3(l1, f1, l2, f2, l3, f3) \
459 .vdd_class = &vdd_dig, \
460 .fmax[VDD_DIG_##l1] = (f1), \
461 .fmax[VDD_DIG_##l2] = (f2), \
462 .fmax[VDD_DIG_##l3] = (f3)
463
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700464/*
465 * Clock Descriptions
466 */
467
468static struct msm_xo_voter *xo_pxo, *xo_cxo;
469
470static int pxo_clk_enable(struct clk *clk)
471{
472 return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON);
473}
474
475static void pxo_clk_disable(struct clk *clk)
476{
Tianyi Gou41515e22011-09-01 19:37:43 -0700477 msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700478}
479
480static struct clk_ops clk_ops_pxo = {
481 .enable = pxo_clk_enable,
482 .disable = pxo_clk_disable,
483 .get_rate = fixed_clk_get_rate,
484 .is_local = local_clk_is_local,
485};
486
487static struct fixed_clk pxo_clk = {
488 .rate = 27000000,
489 .c = {
490 .dbg_name = "pxo_clk",
491 .ops = &clk_ops_pxo,
492 CLK_INIT(pxo_clk.c),
493 },
494};
495
496static int cxo_clk_enable(struct clk *clk)
497{
498 return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON);
499}
500
501static void cxo_clk_disable(struct clk *clk)
502{
503 msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF);
504}
505
506static struct clk_ops clk_ops_cxo = {
507 .enable = cxo_clk_enable,
508 .disable = cxo_clk_disable,
509 .get_rate = fixed_clk_get_rate,
510 .is_local = local_clk_is_local,
511};
512
513static struct fixed_clk cxo_clk = {
514 .rate = 19200000,
515 .c = {
516 .dbg_name = "cxo_clk",
517 .ops = &clk_ops_cxo,
518 CLK_INIT(cxo_clk.c),
519 },
520};
521
522static struct pll_clk pll2_clk = {
523 .rate = 800000000,
524 .mode_reg = MM_PLL1_MODE_REG,
525 .parent = &pxo_clk.c,
526 .c = {
527 .dbg_name = "pll2_clk",
528 .ops = &clk_ops_pll,
529 CLK_INIT(pll2_clk.c),
530 },
531};
532
Stephen Boyd94625ef2011-07-12 17:06:01 -0700533static struct pll_clk pll3_clk = {
534 .rate = 1200000000,
535 .mode_reg = BB_MMCC_PLL2_MODE_REG,
536 .parent = &pxo_clk.c,
537 .c = {
538 .dbg_name = "pll3_clk",
539 .ops = &clk_ops_pll,
540 CLK_INIT(pll3_clk.c),
541 },
542};
543
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700544static struct pll_vote_clk pll4_clk = {
545 .rate = 393216000,
546 .en_reg = BB_PLL_ENA_SC0_REG,
547 .en_mask = BIT(4),
548 .status_reg = LCC_PLL0_STATUS_REG,
549 .parent = &pxo_clk.c,
550 .c = {
551 .dbg_name = "pll4_clk",
552 .ops = &clk_ops_pll_vote,
553 CLK_INIT(pll4_clk.c),
554 },
555};
556
557static struct pll_vote_clk pll8_clk = {
558 .rate = 384000000,
559 .en_reg = BB_PLL_ENA_SC0_REG,
560 .en_mask = BIT(8),
561 .status_reg = BB_PLL8_STATUS_REG,
562 .parent = &pxo_clk.c,
563 .c = {
564 .dbg_name = "pll8_clk",
565 .ops = &clk_ops_pll_vote,
566 CLK_INIT(pll8_clk.c),
567 },
568};
569
Stephen Boyd94625ef2011-07-12 17:06:01 -0700570static struct pll_vote_clk pll14_clk = {
571 .rate = 480000000,
572 .en_reg = BB_PLL_ENA_SC0_REG,
573 .en_mask = BIT(14),
574 .status_reg = BB_PLL14_STATUS_REG,
575 .parent = &pxo_clk.c,
576 .c = {
577 .dbg_name = "pll14_clk",
578 .ops = &clk_ops_pll_vote,
579 CLK_INIT(pll14_clk.c),
580 },
581};
582
Tianyi Gou41515e22011-09-01 19:37:43 -0700583static struct pll_clk pll15_clk = {
584 .rate = 975000000,
585 .mode_reg = MM_PLL3_MODE_REG,
586 .parent = &pxo_clk.c,
587 .c = {
588 .dbg_name = "pll15_clk",
589 .ops = &clk_ops_pll,
590 CLK_INIT(pll15_clk.c),
591 },
592};
593
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700594static int soc_clk_reset(struct clk *clk, enum clk_reset_action action)
595{
596 return branch_reset(&to_rcg_clk(clk)->b, action);
597}
598
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700599static struct clk_ops clk_ops_rcg_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700600 .enable = rcg_clk_enable,
601 .disable = rcg_clk_disable,
Matt Wagantall41af0772011-09-17 12:21:39 -0700602 .auto_off = rcg_clk_disable,
Matt Wagantall53d968f2011-07-19 13:22:53 -0700603 .handoff = rcg_clk_handoff,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700604 .set_rate = rcg_clk_set_rate,
605 .set_min_rate = rcg_clk_set_min_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700606 .get_rate = rcg_clk_get_rate,
607 .list_rate = rcg_clk_list_rate,
608 .is_enabled = rcg_clk_is_enabled,
609 .round_rate = rcg_clk_round_rate,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700610 .reset = soc_clk_reset,
611 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700612 .get_parent = rcg_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700613};
614
615static struct clk_ops clk_ops_branch = {
616 .enable = branch_clk_enable,
617 .disable = branch_clk_disable,
Matt Wagantall41af0772011-09-17 12:21:39 -0700618 .auto_off = branch_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700619 .is_enabled = branch_clk_is_enabled,
620 .reset = branch_clk_reset,
621 .is_local = local_clk_is_local,
622 .get_parent = branch_clk_get_parent,
623 .set_parent = branch_clk_set_parent,
624};
625
626static struct clk_ops clk_ops_reset = {
627 .reset = branch_clk_reset,
628 .is_local = local_clk_is_local,
629};
630
631/* AXI Interfaces */
632static struct branch_clk gmem_axi_clk = {
633 .b = {
634 .ctl_reg = MAXI_EN_REG,
635 .en_mask = BIT(24),
636 .halt_reg = DBG_BUS_VEC_E_REG,
637 .halt_bit = 6,
638 },
639 .c = {
640 .dbg_name = "gmem_axi_clk",
641 .ops = &clk_ops_branch,
642 CLK_INIT(gmem_axi_clk.c),
643 },
644};
645
646static struct branch_clk ijpeg_axi_clk = {
647 .b = {
648 .ctl_reg = MAXI_EN_REG,
649 .en_mask = BIT(21),
650 .reset_reg = SW_RESET_AXI_REG,
651 .reset_mask = BIT(14),
652 .halt_reg = DBG_BUS_VEC_E_REG,
653 .halt_bit = 4,
654 },
655 .c = {
656 .dbg_name = "ijpeg_axi_clk",
657 .ops = &clk_ops_branch,
658 CLK_INIT(ijpeg_axi_clk.c),
659 },
660};
661
662static struct branch_clk imem_axi_clk = {
663 .b = {
664 .ctl_reg = MAXI_EN_REG,
665 .en_mask = BIT(22),
666 .reset_reg = SW_RESET_CORE_REG,
667 .reset_mask = BIT(10),
668 .halt_reg = DBG_BUS_VEC_E_REG,
669 .halt_bit = 7,
670 },
671 .c = {
672 .dbg_name = "imem_axi_clk",
673 .ops = &clk_ops_branch,
674 CLK_INIT(imem_axi_clk.c),
675 },
676};
677
678static struct branch_clk jpegd_axi_clk = {
679 .b = {
680 .ctl_reg = MAXI_EN_REG,
681 .en_mask = BIT(25),
682 .halt_reg = DBG_BUS_VEC_E_REG,
683 .halt_bit = 5,
684 },
685 .c = {
686 .dbg_name = "jpegd_axi_clk",
687 .ops = &clk_ops_branch,
688 CLK_INIT(jpegd_axi_clk.c),
689 },
690};
691
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700692static struct branch_clk vcodec_axi_b_clk = {
693 .b = {
694 .ctl_reg = MAXI_EN4_REG,
695 .en_mask = BIT(23),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700696 .halt_reg = DBG_BUS_VEC_I_REG,
697 .halt_bit = 25,
698 },
699 .c = {
700 .dbg_name = "vcodec_axi_b_clk",
701 .ops = &clk_ops_branch,
702 CLK_INIT(vcodec_axi_b_clk.c),
703 },
704};
705
Matt Wagantall91f42702011-07-14 12:01:15 -0700706static struct branch_clk vcodec_axi_a_clk = {
707 .b = {
708 .ctl_reg = MAXI_EN4_REG,
709 .en_mask = BIT(25),
Matt Wagantall91f42702011-07-14 12:01:15 -0700710 .halt_reg = DBG_BUS_VEC_I_REG,
711 .halt_bit = 26,
712 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700713 .c = {
714 .dbg_name = "vcodec_axi_a_clk",
715 .ops = &clk_ops_branch,
716 CLK_INIT(vcodec_axi_a_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700717 .depends = &vcodec_axi_b_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700718 },
719};
720
721static struct branch_clk vcodec_axi_clk = {
722 .b = {
723 .ctl_reg = MAXI_EN_REG,
724 .en_mask = BIT(19),
725 .reset_reg = SW_RESET_AXI_REG,
Matt Wagantallfe2ee052011-07-14 13:33:44 -0700726 .reset_mask = BIT(4)|BIT(5)|BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700727 .halt_reg = DBG_BUS_VEC_E_REG,
728 .halt_bit = 3,
729 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700730 .c = {
731 .dbg_name = "vcodec_axi_clk",
732 .ops = &clk_ops_branch,
733 CLK_INIT(vcodec_axi_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700734 .depends = &vcodec_axi_a_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700735 },
736};
737
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700738static struct branch_clk vfe_axi_clk = {
739 .b = {
740 .ctl_reg = MAXI_EN_REG,
741 .en_mask = BIT(18),
742 .reset_reg = SW_RESET_AXI_REG,
743 .reset_mask = BIT(9),
744 .halt_reg = DBG_BUS_VEC_E_REG,
745 .halt_bit = 0,
746 },
747 .c = {
748 .dbg_name = "vfe_axi_clk",
749 .ops = &clk_ops_branch,
750 CLK_INIT(vfe_axi_clk.c),
751 },
752};
753
754static struct branch_clk mdp_axi_clk = {
755 .b = {
756 .ctl_reg = MAXI_EN_REG,
757 .en_mask = BIT(23),
758 .reset_reg = SW_RESET_AXI_REG,
759 .reset_mask = BIT(13),
760 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700761 .halt_bit = 8,
762 },
763 .c = {
764 .dbg_name = "mdp_axi_clk",
765 .ops = &clk_ops_branch,
766 CLK_INIT(mdp_axi_clk.c),
767 },
768};
769
770static struct branch_clk rot_axi_clk = {
771 .b = {
772 .ctl_reg = MAXI_EN2_REG,
773 .en_mask = BIT(24),
774 .reset_reg = SW_RESET_AXI_REG,
775 .reset_mask = BIT(6),
776 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700777 .halt_bit = 2,
778 },
779 .c = {
780 .dbg_name = "rot_axi_clk",
781 .ops = &clk_ops_branch,
782 CLK_INIT(rot_axi_clk.c),
783 },
784};
785
786static struct branch_clk vpe_axi_clk = {
787 .b = {
788 .ctl_reg = MAXI_EN2_REG,
789 .en_mask = BIT(26),
790 .reset_reg = SW_RESET_AXI_REG,
791 .reset_mask = BIT(15),
792 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700793 .halt_bit = 1,
794 },
795 .c = {
796 .dbg_name = "vpe_axi_clk",
797 .ops = &clk_ops_branch,
798 CLK_INIT(vpe_axi_clk.c),
799 },
800};
801
Tianyi Gou41515e22011-09-01 19:37:43 -0700802static struct branch_clk vcap_axi_clk = {
803 .b = {
804 .ctl_reg = MAXI_EN5_REG,
805 .en_mask = BIT(12),
806 .reset_reg = SW_RESET_AXI_REG,
807 .reset_mask = BIT(16),
808 .halt_reg = DBG_BUS_VEC_J_REG,
809 .halt_bit = 20,
810 },
811 .c = {
812 .dbg_name = "vcap_axi_clk",
813 .ops = &clk_ops_branch,
814 CLK_INIT(vcap_axi_clk.c),
815 },
816};
817
Tianyi Gou621f8742011-09-01 21:45:01 -0700818/* For 8064, gfx3d_axi_clk is set as a dependency of gmem_axi_clk at runtime */
819static struct branch_clk gfx3d_axi_clk = {
820 .b = {
821 .ctl_reg = MAXI_EN5_REG,
822 .en_mask = BIT(25),
823 .reset_reg = SW_RESET_AXI_REG,
824 .reset_mask = BIT(17),
825 .halt_reg = DBG_BUS_VEC_J_REG,
826 .halt_bit = 30,
827 },
828 .c = {
829 .dbg_name = "gfx3d_axi_clk",
830 .ops = &clk_ops_branch,
831 CLK_INIT(gfx3d_axi_clk.c),
832 },
833};
834
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700835/* AHB Interfaces */
836static struct branch_clk amp_p_clk = {
837 .b = {
838 .ctl_reg = AHB_EN_REG,
839 .en_mask = BIT(24),
840 .halt_reg = DBG_BUS_VEC_F_REG,
841 .halt_bit = 18,
842 },
843 .c = {
844 .dbg_name = "amp_p_clk",
845 .ops = &clk_ops_branch,
846 CLK_INIT(amp_p_clk.c),
847 },
848};
849
Matt Wagantallc23eee92011-08-16 23:06:52 -0700850static struct branch_clk csi_p_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700851 .b = {
852 .ctl_reg = AHB_EN_REG,
853 .en_mask = BIT(7),
854 .reset_reg = SW_RESET_AHB_REG,
855 .reset_mask = BIT(17),
856 .halt_reg = DBG_BUS_VEC_F_REG,
857 .halt_bit = 16,
858 },
859 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -0700860 .dbg_name = "csi_p_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700861 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -0700862 CLK_INIT(csi_p_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700863 },
864};
865
866static struct branch_clk dsi1_m_p_clk = {
867 .b = {
868 .ctl_reg = AHB_EN_REG,
869 .en_mask = BIT(9),
870 .reset_reg = SW_RESET_AHB_REG,
871 .reset_mask = BIT(6),
872 .halt_reg = DBG_BUS_VEC_F_REG,
873 .halt_bit = 19,
874 },
875 .c = {
876 .dbg_name = "dsi1_m_p_clk",
877 .ops = &clk_ops_branch,
878 CLK_INIT(dsi1_m_p_clk.c),
879 },
880};
881
882static struct branch_clk dsi1_s_p_clk = {
883 .b = {
884 .ctl_reg = AHB_EN_REG,
885 .en_mask = BIT(18),
886 .reset_reg = SW_RESET_AHB_REG,
887 .reset_mask = BIT(5),
888 .halt_reg = DBG_BUS_VEC_F_REG,
889 .halt_bit = 21,
890 },
891 .c = {
892 .dbg_name = "dsi1_s_p_clk",
893 .ops = &clk_ops_branch,
894 CLK_INIT(dsi1_s_p_clk.c),
895 },
896};
897
898static struct branch_clk dsi2_m_p_clk = {
899 .b = {
900 .ctl_reg = AHB_EN_REG,
901 .en_mask = BIT(17),
902 .reset_reg = SW_RESET_AHB2_REG,
903 .reset_mask = BIT(1),
904 .halt_reg = DBG_BUS_VEC_E_REG,
905 .halt_bit = 18,
906 },
907 .c = {
908 .dbg_name = "dsi2_m_p_clk",
909 .ops = &clk_ops_branch,
910 CLK_INIT(dsi2_m_p_clk.c),
911 },
912};
913
914static struct branch_clk dsi2_s_p_clk = {
915 .b = {
916 .ctl_reg = AHB_EN_REG,
917 .en_mask = BIT(22),
918 .reset_reg = SW_RESET_AHB2_REG,
919 .reset_mask = BIT(0),
920 .halt_reg = DBG_BUS_VEC_F_REG,
921 .halt_bit = 20,
922 },
923 .c = {
924 .dbg_name = "dsi2_s_p_clk",
925 .ops = &clk_ops_branch,
926 CLK_INIT(dsi2_s_p_clk.c),
927 },
928};
929
930static struct branch_clk gfx2d0_p_clk = {
931 .b = {
932 .ctl_reg = AHB_EN_REG,
933 .en_mask = BIT(19),
934 .reset_reg = SW_RESET_AHB_REG,
935 .reset_mask = BIT(12),
936 .halt_reg = DBG_BUS_VEC_F_REG,
937 .halt_bit = 2,
938 },
939 .c = {
940 .dbg_name = "gfx2d0_p_clk",
941 .ops = &clk_ops_branch,
942 CLK_INIT(gfx2d0_p_clk.c),
943 },
944};
945
946static struct branch_clk gfx2d1_p_clk = {
947 .b = {
948 .ctl_reg = AHB_EN_REG,
949 .en_mask = BIT(2),
950 .reset_reg = SW_RESET_AHB_REG,
951 .reset_mask = BIT(11),
952 .halt_reg = DBG_BUS_VEC_F_REG,
953 .halt_bit = 3,
954 },
955 .c = {
956 .dbg_name = "gfx2d1_p_clk",
957 .ops = &clk_ops_branch,
958 CLK_INIT(gfx2d1_p_clk.c),
959 },
960};
961
962static struct branch_clk gfx3d_p_clk = {
963 .b = {
964 .ctl_reg = AHB_EN_REG,
965 .en_mask = BIT(3),
966 .reset_reg = SW_RESET_AHB_REG,
967 .reset_mask = BIT(10),
968 .halt_reg = DBG_BUS_VEC_F_REG,
969 .halt_bit = 4,
970 },
971 .c = {
972 .dbg_name = "gfx3d_p_clk",
973 .ops = &clk_ops_branch,
974 CLK_INIT(gfx3d_p_clk.c),
975 },
976};
977
978static struct branch_clk hdmi_m_p_clk = {
979 .b = {
980 .ctl_reg = AHB_EN_REG,
981 .en_mask = BIT(14),
982 .reset_reg = SW_RESET_AHB_REG,
983 .reset_mask = BIT(9),
984 .halt_reg = DBG_BUS_VEC_F_REG,
985 .halt_bit = 5,
986 },
987 .c = {
988 .dbg_name = "hdmi_m_p_clk",
989 .ops = &clk_ops_branch,
990 CLK_INIT(hdmi_m_p_clk.c),
991 },
992};
993
994static struct branch_clk hdmi_s_p_clk = {
995 .b = {
996 .ctl_reg = AHB_EN_REG,
997 .en_mask = BIT(4),
998 .reset_reg = SW_RESET_AHB_REG,
999 .reset_mask = BIT(9),
1000 .halt_reg = DBG_BUS_VEC_F_REG,
1001 .halt_bit = 6,
1002 },
1003 .c = {
1004 .dbg_name = "hdmi_s_p_clk",
1005 .ops = &clk_ops_branch,
1006 CLK_INIT(hdmi_s_p_clk.c),
1007 },
1008};
1009
1010static struct branch_clk ijpeg_p_clk = {
1011 .b = {
1012 .ctl_reg = AHB_EN_REG,
1013 .en_mask = BIT(5),
1014 .reset_reg = SW_RESET_AHB_REG,
1015 .reset_mask = BIT(7),
1016 .halt_reg = DBG_BUS_VEC_F_REG,
1017 .halt_bit = 9,
1018 },
1019 .c = {
1020 .dbg_name = "ijpeg_p_clk",
1021 .ops = &clk_ops_branch,
1022 CLK_INIT(ijpeg_p_clk.c),
1023 },
1024};
1025
1026static struct branch_clk imem_p_clk = {
1027 .b = {
1028 .ctl_reg = AHB_EN_REG,
1029 .en_mask = BIT(6),
1030 .reset_reg = SW_RESET_AHB_REG,
1031 .reset_mask = BIT(8),
1032 .halt_reg = DBG_BUS_VEC_F_REG,
1033 .halt_bit = 10,
1034 },
1035 .c = {
1036 .dbg_name = "imem_p_clk",
1037 .ops = &clk_ops_branch,
1038 CLK_INIT(imem_p_clk.c),
1039 },
1040};
1041
1042static struct branch_clk jpegd_p_clk = {
1043 .b = {
1044 .ctl_reg = AHB_EN_REG,
1045 .en_mask = BIT(21),
1046 .reset_reg = SW_RESET_AHB_REG,
1047 .reset_mask = BIT(4),
1048 .halt_reg = DBG_BUS_VEC_F_REG,
1049 .halt_bit = 7,
1050 },
1051 .c = {
1052 .dbg_name = "jpegd_p_clk",
1053 .ops = &clk_ops_branch,
1054 CLK_INIT(jpegd_p_clk.c),
1055 },
1056};
1057
1058static struct branch_clk mdp_p_clk = {
1059 .b = {
1060 .ctl_reg = AHB_EN_REG,
1061 .en_mask = BIT(10),
1062 .reset_reg = SW_RESET_AHB_REG,
1063 .reset_mask = BIT(3),
1064 .halt_reg = DBG_BUS_VEC_F_REG,
1065 .halt_bit = 11,
1066 },
1067 .c = {
1068 .dbg_name = "mdp_p_clk",
1069 .ops = &clk_ops_branch,
1070 CLK_INIT(mdp_p_clk.c),
1071 },
1072};
1073
1074static struct branch_clk rot_p_clk = {
1075 .b = {
1076 .ctl_reg = AHB_EN_REG,
1077 .en_mask = BIT(12),
1078 .reset_reg = SW_RESET_AHB_REG,
1079 .reset_mask = BIT(2),
1080 .halt_reg = DBG_BUS_VEC_F_REG,
1081 .halt_bit = 13,
1082 },
1083 .c = {
1084 .dbg_name = "rot_p_clk",
1085 .ops = &clk_ops_branch,
1086 CLK_INIT(rot_p_clk.c),
1087 },
1088};
1089
1090static struct branch_clk smmu_p_clk = {
1091 .b = {
1092 .ctl_reg = AHB_EN_REG,
1093 .en_mask = BIT(15),
1094 .halt_reg = DBG_BUS_VEC_F_REG,
1095 .halt_bit = 22,
1096 },
1097 .c = {
1098 .dbg_name = "smmu_p_clk",
1099 .ops = &clk_ops_branch,
1100 CLK_INIT(smmu_p_clk.c),
1101 },
1102};
1103
1104static struct branch_clk tv_enc_p_clk = {
1105 .b = {
1106 .ctl_reg = AHB_EN_REG,
1107 .en_mask = BIT(25),
1108 .reset_reg = SW_RESET_AHB_REG,
1109 .reset_mask = BIT(15),
1110 .halt_reg = DBG_BUS_VEC_F_REG,
1111 .halt_bit = 23,
1112 },
1113 .c = {
1114 .dbg_name = "tv_enc_p_clk",
1115 .ops = &clk_ops_branch,
1116 CLK_INIT(tv_enc_p_clk.c),
1117 },
1118};
1119
1120static struct branch_clk vcodec_p_clk = {
1121 .b = {
1122 .ctl_reg = AHB_EN_REG,
1123 .en_mask = BIT(11),
1124 .reset_reg = SW_RESET_AHB_REG,
1125 .reset_mask = BIT(1),
1126 .halt_reg = DBG_BUS_VEC_F_REG,
1127 .halt_bit = 12,
1128 },
1129 .c = {
1130 .dbg_name = "vcodec_p_clk",
1131 .ops = &clk_ops_branch,
1132 CLK_INIT(vcodec_p_clk.c),
1133 },
1134};
1135
1136static struct branch_clk vfe_p_clk = {
1137 .b = {
1138 .ctl_reg = AHB_EN_REG,
1139 .en_mask = BIT(13),
1140 .reset_reg = SW_RESET_AHB_REG,
1141 .reset_mask = BIT(0),
1142 .halt_reg = DBG_BUS_VEC_F_REG,
1143 .halt_bit = 14,
1144 },
1145 .c = {
1146 .dbg_name = "vfe_p_clk",
1147 .ops = &clk_ops_branch,
1148 CLK_INIT(vfe_p_clk.c),
1149 },
1150};
1151
1152static struct branch_clk vpe_p_clk = {
1153 .b = {
1154 .ctl_reg = AHB_EN_REG,
1155 .en_mask = BIT(16),
1156 .reset_reg = SW_RESET_AHB_REG,
1157 .reset_mask = BIT(14),
1158 .halt_reg = DBG_BUS_VEC_F_REG,
1159 .halt_bit = 15,
1160 },
1161 .c = {
1162 .dbg_name = "vpe_p_clk",
1163 .ops = &clk_ops_branch,
1164 CLK_INIT(vpe_p_clk.c),
1165 },
1166};
1167
Tianyi Gou41515e22011-09-01 19:37:43 -07001168static struct branch_clk vcap_p_clk = {
1169 .b = {
1170 .ctl_reg = AHB_EN3_REG,
1171 .en_mask = BIT(1),
1172 .reset_reg = SW_RESET_AHB2_REG,
1173 .reset_mask = BIT(2),
1174 .halt_reg = DBG_BUS_VEC_J_REG,
1175 .halt_bit = 23,
1176 },
1177 .c = {
1178 .dbg_name = "vcap_p_clk",
1179 .ops = &clk_ops_branch,
1180 CLK_INIT(vcap_p_clk.c),
1181 },
1182};
1183
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001184/*
1185 * Peripheral Clocks
1186 */
1187#define CLK_GSBI_UART(i, n, h_r, h_b) \
1188 struct rcg_clk i##_clk = { \
1189 .b = { \
1190 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
1191 .en_mask = BIT(9), \
1192 .reset_reg = GSBIn_RESET_REG(n), \
1193 .reset_mask = BIT(0), \
1194 .halt_reg = h_r, \
1195 .halt_bit = h_b, \
1196 }, \
1197 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
1198 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
1199 .root_en_mask = BIT(11), \
1200 .ns_mask = (BM(31, 16) | BM(6, 0)), \
1201 .set_rate = set_rate_mnd, \
1202 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001203 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001204 .c = { \
1205 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001206 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001207 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001208 CLK_INIT(i##_clk.c), \
1209 }, \
1210 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001211#define F_GSBI_UART(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001212 { \
1213 .freq_hz = f, \
1214 .src_clk = &s##_clk.c, \
1215 .md_val = MD16(m, n), \
1216 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1217 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001218 }
1219static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001220 F_GSBI_UART( 0, gnd, 1, 0, 0),
1221 F_GSBI_UART( 1843200, pll8, 1, 3, 625),
1222 F_GSBI_UART( 3686400, pll8, 1, 6, 625),
1223 F_GSBI_UART( 7372800, pll8, 1, 12, 625),
1224 F_GSBI_UART(14745600, pll8, 1, 24, 625),
1225 F_GSBI_UART(16000000, pll8, 4, 1, 6),
1226 F_GSBI_UART(24000000, pll8, 4, 1, 4),
1227 F_GSBI_UART(32000000, pll8, 4, 1, 3),
1228 F_GSBI_UART(40000000, pll8, 1, 5, 48),
1229 F_GSBI_UART(46400000, pll8, 1, 29, 240),
1230 F_GSBI_UART(48000000, pll8, 4, 1, 2),
1231 F_GSBI_UART(51200000, pll8, 1, 2, 15),
1232 F_GSBI_UART(56000000, pll8, 1, 7, 48),
1233 F_GSBI_UART(58982400, pll8, 1, 96, 625),
1234 F_GSBI_UART(64000000, pll8, 2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001235 F_END
1236};
1237
1238static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1239static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1240static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1241static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1242static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1243static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1244static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1245static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1246static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1247static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1248static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1249static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1250
1251#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1252 struct rcg_clk i##_clk = { \
1253 .b = { \
1254 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1255 .en_mask = BIT(9), \
1256 .reset_reg = GSBIn_RESET_REG(n), \
1257 .reset_mask = BIT(0), \
1258 .halt_reg = h_r, \
1259 .halt_bit = h_b, \
1260 }, \
1261 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1262 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1263 .root_en_mask = BIT(11), \
1264 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1265 .set_rate = set_rate_mnd, \
1266 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001267 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001268 .c = { \
1269 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001270 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001271 VDD_DIG_FMAX_MAP2(LOW, 24000000, NOMINAL, 52000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001272 CLK_INIT(i##_clk.c), \
1273 }, \
1274 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001275#define F_GSBI_QUP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001276 { \
1277 .freq_hz = f, \
1278 .src_clk = &s##_clk.c, \
1279 .md_val = MD8(16, m, 0, n), \
1280 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1281 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001282 }
1283static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001284 F_GSBI_QUP( 0, gnd, 1, 0, 0),
1285 F_GSBI_QUP( 1100000, pxo, 1, 2, 49),
1286 F_GSBI_QUP( 5400000, pxo, 1, 1, 5),
1287 F_GSBI_QUP(10800000, pxo, 1, 2, 5),
1288 F_GSBI_QUP(15060000, pll8, 1, 2, 51),
1289 F_GSBI_QUP(24000000, pll8, 4, 1, 4),
1290 F_GSBI_QUP(25600000, pll8, 1, 1, 15),
1291 F_GSBI_QUP(27000000, pxo, 1, 0, 0),
1292 F_GSBI_QUP(48000000, pll8, 4, 1, 2),
1293 F_GSBI_QUP(51200000, pll8, 1, 2, 15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001294 F_END
1295};
1296
1297static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1298static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1299static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1300static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1301static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1302static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1303static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1304static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1305static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1306static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1307static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1308static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1309
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001310#define F_QDSS(f, s, d) \
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001311 { \
1312 .freq_hz = f, \
1313 .src_clk = &s##_clk.c, \
1314 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001315 }
1316static struct clk_freq_tbl clk_tbl_qdss[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001317 F_QDSS( 27000000, pxo, 1),
1318 F_QDSS(128000000, pll8, 3),
1319 F_QDSS(300000000, pll3, 4),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001320 F_END
1321};
1322
1323struct qdss_bank {
1324 const u32 bank_sel_mask;
1325 void __iomem *const ns_reg;
1326 const u32 ns_mask;
1327};
1328
Stephen Boydd4de6d72011-09-13 13:01:40 -07001329#define QDSS_CLK_ROOT_ENA BIT(1)
1330
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001331static int qdss_clk_handoff(struct clk *c)
Stephen Boydd4de6d72011-09-13 13:01:40 -07001332{
1333 struct rcg_clk *clk = to_rcg_clk(c);
1334 const struct qdss_bank *bank = clk->bank_info;
1335 u32 reg, ns_val, bank_sel;
1336 struct clk_freq_tbl *freq;
1337
1338 reg = readl_relaxed(clk->ns_reg);
1339 if (!(reg & QDSS_CLK_ROOT_ENA))
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001340 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001341
1342 bank_sel = reg & bank->bank_sel_mask;
1343 /* Force bank 1 to PXO if bank 0 is in use */
1344 if (bank_sel == 0)
1345 writel_relaxed(0, bank->ns_reg);
1346 ns_val = readl_relaxed(bank->ns_reg) & bank->ns_mask;
1347 for (freq = clk->freq_tbl; freq->freq_hz != FREQ_END; freq++) {
1348 if ((freq->ns_val & bank->ns_mask) == ns_val) {
1349 pr_info("%s rate=%d\n", clk->c.dbg_name, freq->freq_hz);
1350 break;
1351 }
1352 }
1353 if (freq->freq_hz == FREQ_END)
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001354 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001355
1356 clk->current_freq = freq;
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001357
1358 return 1;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001359}
1360
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001361static void set_rate_qdss(struct rcg_clk *clk, struct clk_freq_tbl *nf)
1362{
1363 const struct qdss_bank *bank = clk->bank_info;
1364 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1365
1366 /* Switch to bank 0 (always sourced from PXO) */
1367 reg = readl_relaxed(clk->ns_reg);
1368 reg &= ~bank_sel_mask;
1369 writel_relaxed(reg, clk->ns_reg);
1370 /*
1371 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1372 * MUX to fully switch sources.
1373 */
1374 mb();
1375 udelay(1);
1376
1377 /* Set source and divider */
1378 reg = readl_relaxed(bank->ns_reg);
1379 reg &= ~bank->ns_mask;
1380 reg |= nf->ns_val;
1381 writel_relaxed(reg, bank->ns_reg);
1382
1383 /* Switch to reprogrammed bank */
1384 reg = readl_relaxed(clk->ns_reg);
1385 reg |= bank_sel_mask;
1386 writel_relaxed(reg, clk->ns_reg);
1387 /*
1388 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1389 * MUX to fully switch sources.
1390 */
1391 mb();
1392 udelay(1);
1393}
1394
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001395static int qdss_clk_enable(struct clk *c)
1396{
1397 struct rcg_clk *clk = to_rcg_clk(c);
1398 const struct qdss_bank *bank = clk->bank_info;
1399 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1400 int ret;
1401
1402 /* Switch to bank 1 */
1403 reg = readl_relaxed(clk->ns_reg);
1404 reg |= bank_sel_mask;
1405 writel_relaxed(reg, clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001406
1407 ret = rcg_clk_enable(c);
1408 if (ret) {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001409 /* Switch to bank 0 */
1410 reg &= ~bank_sel_mask;
1411 writel_relaxed(reg, clk->ns_reg);
1412 }
1413 return ret;
1414}
1415
1416static void qdss_clk_disable(struct clk *c)
1417{
1418 struct rcg_clk *clk = to_rcg_clk(c);
1419 const struct qdss_bank *bank = clk->bank_info;
1420 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1421
1422 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001423 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001424 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001425 reg &= ~bank_sel_mask;
1426 writel_relaxed(reg, clk->ns_reg);
1427}
1428
1429static void qdss_clk_auto_off(struct clk *c)
1430{
1431 struct rcg_clk *clk = to_rcg_clk(c);
1432 const struct qdss_bank *bank = clk->bank_info;
1433 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1434
Matt Wagantall41af0772011-09-17 12:21:39 -07001435 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001436 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001437 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001438 reg &= ~bank_sel_mask;
1439 writel_relaxed(reg, clk->ns_reg);
1440}
1441
1442static struct clk_ops clk_ops_qdss = {
1443 .enable = qdss_clk_enable,
1444 .disable = qdss_clk_disable,
1445 .auto_off = qdss_clk_auto_off,
Stephen Boydd4de6d72011-09-13 13:01:40 -07001446 .handoff = qdss_clk_handoff,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001447 .set_rate = rcg_clk_set_rate,
1448 .set_min_rate = rcg_clk_set_min_rate,
1449 .get_rate = rcg_clk_get_rate,
1450 .list_rate = rcg_clk_list_rate,
1451 .is_enabled = rcg_clk_is_enabled,
1452 .round_rate = rcg_clk_round_rate,
1453 .reset = soc_clk_reset,
1454 .is_local = local_clk_is_local,
1455 .get_parent = rcg_clk_get_parent,
1456};
1457
1458static struct qdss_bank bdiv_info_qdss = {
1459 .bank_sel_mask = BIT(0),
1460 .ns_reg = QDSS_AT_CLK_SRC1_NS_REG,
1461 .ns_mask = BM(6, 0),
1462};
1463
1464static struct rcg_clk qdss_at_clk = {
1465 .b = {
1466 .ctl_reg = QDSS_AT_CLK_NS_REG,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001467 .reset_reg = QDSS_RESETS_REG,
1468 .reset_mask = BIT(0),
Stephen Boydfcfd4dd2011-09-13 12:49:57 -07001469 .halt_check = NOCHECK,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001470 },
1471 .ns_reg = QDSS_AT_CLK_SRC_CTL_REG,
1472 .set_rate = set_rate_qdss,
1473 .freq_tbl = clk_tbl_qdss,
1474 .bank_info = &bdiv_info_qdss,
1475 .current_freq = &rcg_dummy_freq,
1476 .c = {
1477 .dbg_name = "qdss_at_clk",
1478 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001479 VDD_DIG_FMAX_MAP2(LOW, 150000000, NOMINAL, 300000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001480 CLK_INIT(qdss_at_clk.c),
1481 },
1482};
1483
1484static struct branch_clk qdss_pclkdbg_clk = {
1485 .b = {
1486 .ctl_reg = QDSS_AT_CLK_NS_REG,
1487 .en_mask = BIT(4),
1488 .reset_reg = QDSS_RESETS_REG,
1489 .reset_mask = BIT(0),
1490 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1491 .halt_bit = 9,
1492 .halt_check = HALT_VOTED
1493 },
1494 .parent = &qdss_at_clk.c,
1495 .c = {
1496 .dbg_name = "qdss_pclkdbg_clk",
1497 .ops = &clk_ops_branch,
1498 CLK_INIT(qdss_pclkdbg_clk.c),
1499 },
1500};
1501
1502static struct qdss_bank bdiv_info_qdss_trace = {
1503 .bank_sel_mask = BIT(0),
1504 .ns_reg = QDSS_TRACECLKIN_CLK_SRC1_NS_REG,
1505 .ns_mask = BM(6, 0),
1506};
1507
1508static struct rcg_clk qdss_traceclkin_clk = {
1509 .b = {
1510 .ctl_reg = QDSS_TRACECLKIN_CTL_REG,
1511 .en_mask = BIT(4),
1512 .reset_reg = QDSS_RESETS_REG,
1513 .reset_mask = BIT(0),
1514 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1515 .halt_bit = 8,
1516 .halt_check = HALT_VOTED,
1517 },
1518 .ns_reg = QDSS_TRACECLKIN_CLK_SRC_CTL_REG,
1519 .set_rate = set_rate_qdss,
1520 .freq_tbl = clk_tbl_qdss,
1521 .bank_info = &bdiv_info_qdss_trace,
1522 .current_freq = &rcg_dummy_freq,
1523 .c = {
1524 .dbg_name = "qdss_traceclkin_clk",
1525 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001526 VDD_DIG_FMAX_MAP2(LOW, 150000000, NOMINAL, 300000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001527 CLK_INIT(qdss_traceclkin_clk.c),
1528 },
1529};
1530
1531static struct clk_freq_tbl clk_tbl_qdss_tsctr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001532 F_QDSS( 27000000, pxo, 1),
1533 F_QDSS(200000000, pll3, 6),
1534 F_QDSS(400000000, pll3, 3),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001535 F_END
1536};
1537
1538static struct qdss_bank bdiv_info_qdss_tsctr = {
1539 .bank_sel_mask = BIT(0),
1540 .ns_reg = QDSS_TSCTR_CLK_SRC1_NS_REG,
1541 .ns_mask = BM(6, 0),
1542};
1543
1544static struct rcg_clk qdss_tsctr_clk = {
1545 .b = {
1546 .ctl_reg = QDSS_TSCTR_CTL_REG,
1547 .en_mask = BIT(4),
1548 .reset_reg = QDSS_RESETS_REG,
1549 .reset_mask = BIT(3),
1550 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1551 .halt_bit = 7,
1552 .halt_check = HALT_VOTED,
1553 },
1554 .ns_reg = QDSS_TSCTR_CLK_SRC_CTL_REG,
1555 .set_rate = set_rate_qdss,
1556 .freq_tbl = clk_tbl_qdss_tsctr,
1557 .bank_info = &bdiv_info_qdss_tsctr,
1558 .current_freq = &rcg_dummy_freq,
1559 .c = {
1560 .dbg_name = "qdss_tsctr_clk",
1561 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001562 VDD_DIG_FMAX_MAP2(LOW, 200000000, NOMINAL, 400000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001563 CLK_INIT(qdss_tsctr_clk.c),
1564 },
1565};
1566
1567static struct branch_clk qdss_stm_clk = {
1568 .b = {
1569 .ctl_reg = QDSS_STM_CLK_CTL_REG,
1570 .en_mask = BIT(4),
1571 .reset_reg = QDSS_RESETS_REG,
1572 .reset_mask = BIT(1),
1573 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
1574 .halt_bit = 20,
1575 .halt_check = HALT_VOTED,
1576 },
1577 .c = {
1578 .dbg_name = "qdss_stm_clk",
1579 .ops = &clk_ops_branch,
1580 CLK_INIT(qdss_stm_clk.c),
1581 },
1582};
1583
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001584#define F_PDM(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001585 { \
1586 .freq_hz = f, \
1587 .src_clk = &s##_clk.c, \
1588 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001589 }
1590static struct clk_freq_tbl clk_tbl_pdm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001591 F_PDM( 0, gnd, 1),
1592 F_PDM(27000000, pxo, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001593 F_END
1594};
1595
1596static struct rcg_clk pdm_clk = {
1597 .b = {
1598 .ctl_reg = PDM_CLK_NS_REG,
1599 .en_mask = BIT(9),
1600 .reset_reg = PDM_CLK_NS_REG,
1601 .reset_mask = BIT(12),
1602 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1603 .halt_bit = 3,
1604 },
1605 .ns_reg = PDM_CLK_NS_REG,
1606 .root_en_mask = BIT(11),
1607 .ns_mask = BM(1, 0),
1608 .set_rate = set_rate_nop,
1609 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001610 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001611 .c = {
1612 .dbg_name = "pdm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001613 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001614 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001615 CLK_INIT(pdm_clk.c),
1616 },
1617};
1618
1619static struct branch_clk pmem_clk = {
1620 .b = {
1621 .ctl_reg = PMEM_ACLK_CTL_REG,
1622 .en_mask = BIT(4),
1623 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1624 .halt_bit = 20,
1625 },
1626 .c = {
1627 .dbg_name = "pmem_clk",
1628 .ops = &clk_ops_branch,
1629 CLK_INIT(pmem_clk.c),
1630 },
1631};
1632
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001633#define F_PRNG(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001634 { \
1635 .freq_hz = f, \
1636 .src_clk = &s##_clk.c, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001637 }
1638static struct clk_freq_tbl clk_tbl_prng[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001639 F_PRNG(64000000, pll8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001640 F_END
1641};
1642
1643static struct rcg_clk prng_clk = {
1644 .b = {
1645 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1646 .en_mask = BIT(10),
1647 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1648 .halt_check = HALT_VOTED,
1649 .halt_bit = 10,
1650 },
1651 .set_rate = set_rate_nop,
1652 .freq_tbl = clk_tbl_prng,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001653 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001654 .c = {
1655 .dbg_name = "prng_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001656 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001657 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 65000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001658 CLK_INIT(prng_clk.c),
1659 },
1660};
1661
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001662#define CLK_SDC(name, n, h_b, fmax_low, fmax_nom) \
Stephen Boyda78a7402011-08-02 11:23:39 -07001663 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001664 .b = { \
1665 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1666 .en_mask = BIT(9), \
1667 .reset_reg = SDCn_RESET_REG(n), \
1668 .reset_mask = BIT(0), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001669 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001670 .halt_bit = h_b, \
1671 }, \
1672 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1673 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1674 .root_en_mask = BIT(11), \
1675 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1676 .set_rate = set_rate_mnd, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001677 .freq_tbl = clk_tbl_sdc, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001678 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001679 .c = { \
Stephen Boyda78a7402011-08-02 11:23:39 -07001680 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001681 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001682 VDD_DIG_FMAX_MAP2(LOW, fmax_low, NOMINAL, fmax_nom), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001683 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001684 }, \
1685 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001686#define F_SDC(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001687 { \
1688 .freq_hz = f, \
1689 .src_clk = &s##_clk.c, \
1690 .md_val = MD8(16, m, 0, n), \
1691 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1692 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001693 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001694static struct clk_freq_tbl clk_tbl_sdc[] = {
1695 F_SDC( 0, gnd, 1, 0, 0),
1696 F_SDC( 144000, pxo, 3, 2, 125),
1697 F_SDC( 400000, pll8, 4, 1, 240),
1698 F_SDC( 16000000, pll8, 4, 1, 6),
1699 F_SDC( 17070000, pll8, 1, 2, 45),
1700 F_SDC( 20210000, pll8, 1, 1, 19),
1701 F_SDC( 24000000, pll8, 4, 1, 4),
1702 F_SDC( 48000000, pll8, 4, 1, 2),
1703 F_SDC( 64000000, pll8, 3, 1, 2),
1704 F_SDC( 96000000, pll8, 4, 0, 0),
Stephen Boyda78a7402011-08-02 11:23:39 -07001705 F_END
1706};
1707
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001708static CLK_SDC(sdc1_clk, 1, 6, 52000000, 104000000);
1709static CLK_SDC(sdc2_clk, 2, 5, 52000000, 104000000);
1710static CLK_SDC(sdc3_clk, 3, 4, 104000000, 208000000);
1711static CLK_SDC(sdc4_clk, 4, 3, 33000000, 67000000);
1712static CLK_SDC(sdc5_clk, 5, 2, 33000000, 67000000);
Stephen Boyda78a7402011-08-02 11:23:39 -07001713
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001714#define F_TSIF_REF(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001715 { \
1716 .freq_hz = f, \
1717 .src_clk = &s##_clk.c, \
1718 .md_val = MD16(m, n), \
1719 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1720 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001721 }
1722static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001723 F_TSIF_REF( 0, gnd, 1, 0, 0),
1724 F_TSIF_REF(105000, pxo, 1, 1, 256),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001725 F_END
1726};
1727
1728static struct rcg_clk tsif_ref_clk = {
1729 .b = {
1730 .ctl_reg = TSIF_REF_CLK_NS_REG,
1731 .en_mask = BIT(9),
1732 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1733 .halt_bit = 5,
1734 },
1735 .ns_reg = TSIF_REF_CLK_NS_REG,
1736 .md_reg = TSIF_REF_CLK_MD_REG,
1737 .root_en_mask = BIT(11),
1738 .ns_mask = (BM(31, 16) | BM(6, 0)),
1739 .set_rate = set_rate_mnd,
1740 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001741 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001742 .c = {
1743 .dbg_name = "tsif_ref_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001744 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001745 VDD_DIG_FMAX_MAP2(LOW, 27000000, NOMINAL, 54000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001746 CLK_INIT(tsif_ref_clk.c),
1747 },
1748};
1749
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001750#define F_TSSC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001751 { \
1752 .freq_hz = f, \
1753 .src_clk = &s##_clk.c, \
1754 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001755 }
1756static struct clk_freq_tbl clk_tbl_tssc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001757 F_TSSC( 0, gnd),
1758 F_TSSC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001759 F_END
1760};
1761
1762static struct rcg_clk tssc_clk = {
1763 .b = {
1764 .ctl_reg = TSSC_CLK_CTL_REG,
1765 .en_mask = BIT(4),
1766 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1767 .halt_bit = 4,
1768 },
1769 .ns_reg = TSSC_CLK_CTL_REG,
1770 .ns_mask = BM(1, 0),
1771 .set_rate = set_rate_nop,
1772 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001773 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001774 .c = {
1775 .dbg_name = "tssc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001776 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001777 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001778 CLK_INIT(tssc_clk.c),
1779 },
1780};
1781
Tianyi Gou41515e22011-09-01 19:37:43 -07001782#define CLK_USB_HS(name, n, h_b) \
1783 static struct rcg_clk name = { \
1784 .b = { \
1785 .ctl_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1786 .en_mask = BIT(9), \
1787 .reset_reg = USB_HS##n##_RESET_REG, \
1788 .reset_mask = BIT(0), \
1789 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
1790 .halt_bit = h_b, \
1791 }, \
1792 .ns_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1793 .md_reg = USB_HS##n##_XCVR_FS_CLK_MD_REG, \
1794 .root_en_mask = BIT(11), \
1795 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1796 .set_rate = set_rate_mnd, \
1797 .freq_tbl = clk_tbl_usb, \
1798 .current_freq = &rcg_dummy_freq, \
1799 .c = { \
1800 .dbg_name = #name, \
1801 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001802 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001803 CLK_INIT(name.c), \
1804 }, \
1805}
1806
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001807#define F_USB(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001808 { \
1809 .freq_hz = f, \
1810 .src_clk = &s##_clk.c, \
1811 .md_val = MD8(16, m, 0, n), \
1812 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1813 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001814 }
1815static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001816 F_USB( 0, gnd, 1, 0, 0),
1817 F_USB(60000000, pll8, 1, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001818 F_END
1819};
1820
Tianyi Gou41515e22011-09-01 19:37:43 -07001821CLK_USB_HS(usb_hs1_xcvr_clk, 1, 0);
1822CLK_USB_HS(usb_hs3_xcvr_clk, 3, 30);
1823CLK_USB_HS(usb_hs4_xcvr_clk, 4, 2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001824
Stephen Boyd94625ef2011-07-12 17:06:01 -07001825static struct clk_freq_tbl clk_tbl_usb_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001826 F_USB( 0, gnd, 1, 0, 0),
1827 F_USB(60000000, pll8, 1, 5, 32),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001828 F_END
1829};
1830
1831static struct rcg_clk usb_hsic_xcvr_fs_clk = {
1832 .b = {
1833 .ctl_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1834 .en_mask = BIT(9),
1835 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1836 .halt_bit = 26,
1837 },
1838 .ns_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1839 .md_reg = USB_HSIC_XCVR_FS_CLK_MD_REG,
1840 .root_en_mask = BIT(11),
1841 .ns_mask = (BM(23, 16) | BM(6, 0)),
1842 .set_rate = set_rate_mnd,
1843 .freq_tbl = clk_tbl_usb_hsic,
1844 .current_freq = &rcg_dummy_freq,
1845 .c = {
1846 .dbg_name = "usb_hsic_xcvr_fs_clk",
1847 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001848 VDD_DIG_FMAX_MAP1(LOW, 60000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001849 CLK_INIT(usb_hsic_xcvr_fs_clk.c),
1850 },
1851};
1852
1853static struct branch_clk usb_hsic_system_clk = {
1854 .b = {
1855 .ctl_reg = USB_HSIC_SYSTEM_CLK_CTL_REG,
1856 .en_mask = BIT(4),
1857 .reset_reg = USB_HSIC_RESET_REG,
1858 .reset_mask = BIT(0),
1859 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1860 .halt_bit = 24,
1861 },
1862 .parent = &usb_hsic_xcvr_fs_clk.c,
1863 .c = {
1864 .dbg_name = "usb_hsic_system_clk",
1865 .ops = &clk_ops_branch,
1866 CLK_INIT(usb_hsic_system_clk.c),
1867 },
1868};
1869
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001870#define F_USB_HSIC(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001871 { \
1872 .freq_hz = f, \
1873 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001874 }
1875static struct clk_freq_tbl clk_tbl_usb2_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001876 F_USB_HSIC(480000000, pll14),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001877 F_END
1878};
1879
1880static struct rcg_clk usb_hsic_hsic_src_clk = {
1881 .b = {
1882 .ctl_reg = USB_HSIC_HSIC_CLK_SRC_CTL_REG,
1883 .halt_check = NOCHECK,
1884 },
1885 .root_en_mask = BIT(0),
1886 .set_rate = set_rate_nop,
1887 .freq_tbl = clk_tbl_usb2_hsic,
1888 .current_freq = &rcg_dummy_freq,
1889 .c = {
1890 .dbg_name = "usb_hsic_hsic_src_clk",
1891 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001892 VDD_DIG_FMAX_MAP1(LOW, 480000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001893 CLK_INIT(usb_hsic_hsic_src_clk.c),
1894 },
1895};
1896
1897static struct branch_clk usb_hsic_hsic_clk = {
1898 .b = {
1899 .ctl_reg = USB_HSIC_HSIC_CLK_CTL_REG,
1900 .en_mask = BIT(0),
1901 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1902 .halt_bit = 19,
1903 },
1904 .parent = &usb_hsic_hsic_src_clk.c,
1905 .c = {
1906 .dbg_name = "usb_hsic_hsic_clk",
1907 .ops = &clk_ops_branch,
1908 CLK_INIT(usb_hsic_hsic_clk.c),
1909 },
1910};
1911
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001912#define F_USB_HSIO_CAL(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001913 { \
1914 .freq_hz = f, \
1915 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001916 }
1917static struct clk_freq_tbl clk_tbl_usb_hsio_cal[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001918 F_USB_HSIO_CAL(9000000, pxo),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001919 F_END
1920};
1921
1922static struct rcg_clk usb_hsic_hsio_cal_clk = {
1923 .b = {
1924 .ctl_reg = USB_HSIC_HSIO_CAL_CLK_CTL_REG,
1925 .en_mask = BIT(0),
1926 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1927 .halt_bit = 23,
1928 },
1929 .set_rate = set_rate_nop,
1930 .freq_tbl = clk_tbl_usb_hsio_cal,
1931 .current_freq = &rcg_dummy_freq,
1932 .c = {
1933 .dbg_name = "usb_hsic_hsio_cal_clk",
Stephen Boyda0e82ec2011-09-19 12:18:45 -07001934 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001935 VDD_DIG_FMAX_MAP1(LOW, 10000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001936 CLK_INIT(usb_hsic_hsio_cal_clk.c),
1937 },
1938};
1939
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001940static struct branch_clk usb_phy0_clk = {
1941 .b = {
1942 .reset_reg = USB_PHY0_RESET_REG,
1943 .reset_mask = BIT(0),
1944 },
1945 .c = {
1946 .dbg_name = "usb_phy0_clk",
1947 .ops = &clk_ops_reset,
1948 CLK_INIT(usb_phy0_clk.c),
1949 },
1950};
1951
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001952#define CLK_USB_FS(i, n, fmax_nom) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001953 struct rcg_clk i##_clk = { \
1954 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1955 .b = { \
1956 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1957 .halt_check = NOCHECK, \
1958 }, \
1959 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
1960 .root_en_mask = BIT(11), \
1961 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1962 .set_rate = set_rate_mnd, \
1963 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001964 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001965 .c = { \
1966 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001967 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001968 VDD_DIG_FMAX_MAP1(NOMINAL, fmax_nom), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001969 CLK_INIT(i##_clk.c), \
1970 }, \
1971 }
1972
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001973static CLK_USB_FS(usb_fs1_src, 1, 64000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001974static struct branch_clk usb_fs1_xcvr_clk = {
1975 .b = {
1976 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
1977 .en_mask = BIT(9),
1978 .reset_reg = USB_FSn_RESET_REG(1),
1979 .reset_mask = BIT(1),
1980 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1981 .halt_bit = 15,
1982 },
1983 .parent = &usb_fs1_src_clk.c,
1984 .c = {
1985 .dbg_name = "usb_fs1_xcvr_clk",
1986 .ops = &clk_ops_branch,
1987 CLK_INIT(usb_fs1_xcvr_clk.c),
1988 },
1989};
1990
1991static struct branch_clk usb_fs1_sys_clk = {
1992 .b = {
1993 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
1994 .en_mask = BIT(4),
1995 .reset_reg = USB_FSn_RESET_REG(1),
1996 .reset_mask = BIT(0),
1997 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1998 .halt_bit = 16,
1999 },
2000 .parent = &usb_fs1_src_clk.c,
2001 .c = {
2002 .dbg_name = "usb_fs1_sys_clk",
2003 .ops = &clk_ops_branch,
2004 CLK_INIT(usb_fs1_sys_clk.c),
2005 },
2006};
2007
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002008static CLK_USB_FS(usb_fs2_src, 2, 60000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002009static struct branch_clk usb_fs2_xcvr_clk = {
2010 .b = {
2011 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
2012 .en_mask = BIT(9),
2013 .reset_reg = USB_FSn_RESET_REG(2),
2014 .reset_mask = BIT(1),
2015 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2016 .halt_bit = 12,
2017 },
2018 .parent = &usb_fs2_src_clk.c,
2019 .c = {
2020 .dbg_name = "usb_fs2_xcvr_clk",
2021 .ops = &clk_ops_branch,
2022 CLK_INIT(usb_fs2_xcvr_clk.c),
2023 },
2024};
2025
2026static struct branch_clk usb_fs2_sys_clk = {
2027 .b = {
2028 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
2029 .en_mask = BIT(4),
2030 .reset_reg = USB_FSn_RESET_REG(2),
2031 .reset_mask = BIT(0),
2032 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2033 .halt_bit = 13,
2034 },
2035 .parent = &usb_fs2_src_clk.c,
2036 .c = {
2037 .dbg_name = "usb_fs2_sys_clk",
2038 .ops = &clk_ops_branch,
2039 CLK_INIT(usb_fs2_sys_clk.c),
2040 },
2041};
2042
2043/* Fast Peripheral Bus Clocks */
2044static struct branch_clk ce1_core_clk = {
2045 .b = {
2046 .ctl_reg = CE1_CORE_CLK_CTL_REG,
2047 .en_mask = BIT(4),
2048 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2049 .halt_bit = 27,
2050 },
2051 .c = {
2052 .dbg_name = "ce1_core_clk",
2053 .ops = &clk_ops_branch,
2054 CLK_INIT(ce1_core_clk.c),
2055 },
2056};
Tianyi Gou41515e22011-09-01 19:37:43 -07002057
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002058static struct branch_clk ce1_p_clk = {
2059 .b = {
2060 .ctl_reg = CE1_HCLK_CTL_REG,
2061 .en_mask = BIT(4),
2062 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2063 .halt_bit = 1,
2064 },
2065 .c = {
2066 .dbg_name = "ce1_p_clk",
2067 .ops = &clk_ops_branch,
2068 CLK_INIT(ce1_p_clk.c),
2069 },
2070};
2071
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002072#define F_CE3(f, s, d) \
Tianyi Gou41515e22011-09-01 19:37:43 -07002073 { \
2074 .freq_hz = f, \
2075 .src_clk = &s##_clk.c, \
2076 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Tianyi Gou41515e22011-09-01 19:37:43 -07002077 }
2078
2079static struct clk_freq_tbl clk_tbl_ce3[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002080 F_CE3( 0, gnd, 1),
2081 F_CE3( 48000000, pll8, 8),
2082 F_CE3(100000000, pll3, 12),
Tianyi Gou41515e22011-09-01 19:37:43 -07002083 F_END
2084};
2085
2086static struct rcg_clk ce3_src_clk = {
2087 .b = {
2088 .ctl_reg = CE3_CLK_SRC_NS_REG,
2089 .halt_check = NOCHECK,
2090 },
2091 .ns_reg = CE3_CLK_SRC_NS_REG,
2092 .root_en_mask = BIT(7),
2093 .ns_mask = BM(6, 0),
2094 .set_rate = set_rate_nop,
2095 .freq_tbl = clk_tbl_ce3,
2096 .current_freq = &rcg_dummy_freq,
2097 .c = {
2098 .dbg_name = "ce3_src_clk",
2099 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002100 VDD_DIG_FMAX_MAP2(LOW, 50000000, NOMINAL, 100000000),
Tianyi Gou41515e22011-09-01 19:37:43 -07002101 CLK_INIT(ce3_src_clk.c),
2102 },
2103};
2104
2105static struct branch_clk ce3_core_clk = {
2106 .b = {
2107 .ctl_reg = CE3_CORE_CLK_CTL_REG,
2108 .en_mask = BIT(4),
2109 .reset_reg = CE3_CORE_CLK_CTL_REG,
2110 .reset_mask = BIT(7),
2111 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2112 .halt_bit = 5,
2113 },
2114 .parent = &ce3_src_clk.c,
2115 .c = {
2116 .dbg_name = "ce3_core_clk",
2117 .ops = &clk_ops_branch,
2118 CLK_INIT(ce3_core_clk.c),
2119 }
2120};
2121
2122static struct branch_clk ce3_p_clk = {
2123 .b = {
2124 .ctl_reg = CE3_HCLK_CTL_REG,
2125 .en_mask = BIT(4),
2126 .reset_reg = CE3_HCLK_CTL_REG,
2127 .reset_mask = BIT(7),
2128 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
2129 .halt_bit = 16,
2130 },
2131 .parent = &ce3_src_clk.c,
2132 .c = {
2133 .dbg_name = "ce3_p_clk",
2134 .ops = &clk_ops_branch,
2135 CLK_INIT(ce3_p_clk.c),
2136 }
2137};
2138
2139static struct branch_clk sata_phy_ref_clk = {
2140 .b = {
2141 .ctl_reg = SATA_PHY_REF_CLK_CTL_REG,
2142 .en_mask = BIT(4),
2143 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2144 .halt_bit = 24,
2145 },
2146 .parent = &pxo_clk.c,
2147 .c = {
2148 .dbg_name = "sata_phy_ref_clk",
2149 .ops = &clk_ops_branch,
2150 CLK_INIT(sata_phy_ref_clk.c),
2151 },
2152};
2153
2154static struct branch_clk pcie_p_clk = {
2155 .b = {
2156 .ctl_reg = PCIE_HCLK_CTL_REG,
2157 .en_mask = BIT(4),
2158 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2159 .halt_bit = 8,
2160 },
2161 .c = {
2162 .dbg_name = "pcie_p_clk",
2163 .ops = &clk_ops_branch,
2164 CLK_INIT(pcie_p_clk.c),
2165 },
2166};
2167
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002168static struct branch_clk dma_bam_p_clk = {
2169 .b = {
2170 .ctl_reg = DMA_BAM_HCLK_CTL,
2171 .en_mask = BIT(4),
2172 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2173 .halt_bit = 12,
2174 },
2175 .c = {
2176 .dbg_name = "dma_bam_p_clk",
2177 .ops = &clk_ops_branch,
2178 CLK_INIT(dma_bam_p_clk.c),
2179 },
2180};
2181
2182static struct branch_clk gsbi1_p_clk = {
2183 .b = {
2184 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
2185 .en_mask = BIT(4),
2186 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2187 .halt_bit = 11,
2188 },
2189 .c = {
2190 .dbg_name = "gsbi1_p_clk",
2191 .ops = &clk_ops_branch,
2192 CLK_INIT(gsbi1_p_clk.c),
2193 },
2194};
2195
2196static struct branch_clk gsbi2_p_clk = {
2197 .b = {
2198 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
2199 .en_mask = BIT(4),
2200 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2201 .halt_bit = 7,
2202 },
2203 .c = {
2204 .dbg_name = "gsbi2_p_clk",
2205 .ops = &clk_ops_branch,
2206 CLK_INIT(gsbi2_p_clk.c),
2207 },
2208};
2209
2210static struct branch_clk gsbi3_p_clk = {
2211 .b = {
2212 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
2213 .en_mask = BIT(4),
2214 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2215 .halt_bit = 3,
2216 },
2217 .c = {
2218 .dbg_name = "gsbi3_p_clk",
2219 .ops = &clk_ops_branch,
2220 CLK_INIT(gsbi3_p_clk.c),
2221 },
2222};
2223
2224static struct branch_clk gsbi4_p_clk = {
2225 .b = {
2226 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
2227 .en_mask = BIT(4),
2228 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2229 .halt_bit = 27,
2230 },
2231 .c = {
2232 .dbg_name = "gsbi4_p_clk",
2233 .ops = &clk_ops_branch,
2234 CLK_INIT(gsbi4_p_clk.c),
2235 },
2236};
2237
2238static struct branch_clk gsbi5_p_clk = {
2239 .b = {
2240 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
2241 .en_mask = BIT(4),
2242 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2243 .halt_bit = 23,
2244 },
2245 .c = {
2246 .dbg_name = "gsbi5_p_clk",
2247 .ops = &clk_ops_branch,
2248 CLK_INIT(gsbi5_p_clk.c),
2249 },
2250};
2251
2252static struct branch_clk gsbi6_p_clk = {
2253 .b = {
2254 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
2255 .en_mask = BIT(4),
2256 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2257 .halt_bit = 19,
2258 },
2259 .c = {
2260 .dbg_name = "gsbi6_p_clk",
2261 .ops = &clk_ops_branch,
2262 CLK_INIT(gsbi6_p_clk.c),
2263 },
2264};
2265
2266static struct branch_clk gsbi7_p_clk = {
2267 .b = {
2268 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
2269 .en_mask = BIT(4),
2270 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2271 .halt_bit = 15,
2272 },
2273 .c = {
2274 .dbg_name = "gsbi7_p_clk",
2275 .ops = &clk_ops_branch,
2276 CLK_INIT(gsbi7_p_clk.c),
2277 },
2278};
2279
2280static struct branch_clk gsbi8_p_clk = {
2281 .b = {
2282 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
2283 .en_mask = BIT(4),
2284 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2285 .halt_bit = 11,
2286 },
2287 .c = {
2288 .dbg_name = "gsbi8_p_clk",
2289 .ops = &clk_ops_branch,
2290 CLK_INIT(gsbi8_p_clk.c),
2291 },
2292};
2293
2294static struct branch_clk gsbi9_p_clk = {
2295 .b = {
2296 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
2297 .en_mask = BIT(4),
2298 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2299 .halt_bit = 7,
2300 },
2301 .c = {
2302 .dbg_name = "gsbi9_p_clk",
2303 .ops = &clk_ops_branch,
2304 CLK_INIT(gsbi9_p_clk.c),
2305 },
2306};
2307
2308static struct branch_clk gsbi10_p_clk = {
2309 .b = {
2310 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
2311 .en_mask = BIT(4),
2312 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2313 .halt_bit = 3,
2314 },
2315 .c = {
2316 .dbg_name = "gsbi10_p_clk",
2317 .ops = &clk_ops_branch,
2318 CLK_INIT(gsbi10_p_clk.c),
2319 },
2320};
2321
2322static struct branch_clk gsbi11_p_clk = {
2323 .b = {
2324 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
2325 .en_mask = BIT(4),
2326 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2327 .halt_bit = 18,
2328 },
2329 .c = {
2330 .dbg_name = "gsbi11_p_clk",
2331 .ops = &clk_ops_branch,
2332 CLK_INIT(gsbi11_p_clk.c),
2333 },
2334};
2335
2336static struct branch_clk gsbi12_p_clk = {
2337 .b = {
2338 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
2339 .en_mask = BIT(4),
2340 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2341 .halt_bit = 14,
2342 },
2343 .c = {
2344 .dbg_name = "gsbi12_p_clk",
2345 .ops = &clk_ops_branch,
2346 CLK_INIT(gsbi12_p_clk.c),
2347 },
2348};
2349
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002350static struct branch_clk qdss_p_clk = {
2351 .b = {
2352 .ctl_reg = QDSS_HCLK_CTL_REG,
2353 .en_mask = BIT(4),
2354 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2355 .halt_bit = 11,
2356 .halt_check = HALT_VOTED,
2357 .reset_reg = QDSS_RESETS_REG,
2358 .reset_mask = BIT(2),
2359 },
2360 .c = {
2361 .dbg_name = "qdss_p_clk",
2362 .ops = &clk_ops_branch,
2363 CLK_INIT(qdss_p_clk.c),
Tianyi Gou41515e22011-09-01 19:37:43 -07002364 }
2365};
2366
2367static struct branch_clk sata_phy_cfg_clk = {
2368 .b = {
2369 .ctl_reg = SATA_PHY_CFG_CLK_CTL_REG,
2370 .en_mask = BIT(4),
2371 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2372 .halt_bit = 12,
2373 },
2374 .c = {
2375 .dbg_name = "sata_phy_cfg_clk",
2376 .ops = &clk_ops_branch,
2377 CLK_INIT(sata_phy_cfg_clk.c),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002378 },
2379};
2380
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002381static struct branch_clk tsif_p_clk = {
2382 .b = {
2383 .ctl_reg = TSIF_HCLK_CTL_REG,
2384 .en_mask = BIT(4),
2385 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2386 .halt_bit = 7,
2387 },
2388 .c = {
2389 .dbg_name = "tsif_p_clk",
2390 .ops = &clk_ops_branch,
2391 CLK_INIT(tsif_p_clk.c),
2392 },
2393};
2394
2395static struct branch_clk usb_fs1_p_clk = {
2396 .b = {
2397 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
2398 .en_mask = BIT(4),
2399 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2400 .halt_bit = 17,
2401 },
2402 .c = {
2403 .dbg_name = "usb_fs1_p_clk",
2404 .ops = &clk_ops_branch,
2405 CLK_INIT(usb_fs1_p_clk.c),
2406 },
2407};
2408
2409static struct branch_clk usb_fs2_p_clk = {
2410 .b = {
2411 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
2412 .en_mask = BIT(4),
2413 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2414 .halt_bit = 14,
2415 },
2416 .c = {
2417 .dbg_name = "usb_fs2_p_clk",
2418 .ops = &clk_ops_branch,
2419 CLK_INIT(usb_fs2_p_clk.c),
2420 },
2421};
2422
2423static struct branch_clk usb_hs1_p_clk = {
2424 .b = {
2425 .ctl_reg = USB_HS1_HCLK_CTL_REG,
2426 .en_mask = BIT(4),
2427 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2428 .halt_bit = 1,
2429 },
2430 .c = {
2431 .dbg_name = "usb_hs1_p_clk",
2432 .ops = &clk_ops_branch,
2433 CLK_INIT(usb_hs1_p_clk.c),
2434 },
2435};
2436
Tianyi Gou41515e22011-09-01 19:37:43 -07002437static struct branch_clk usb_hs3_p_clk = {
2438 .b = {
2439 .ctl_reg = USB_HS3_HCLK_CTL_REG,
2440 .en_mask = BIT(4),
2441 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2442 .halt_bit = 31,
2443 },
2444 .c = {
2445 .dbg_name = "usb_hs3_p_clk",
2446 .ops = &clk_ops_branch,
2447 CLK_INIT(usb_hs3_p_clk.c),
2448 },
2449};
2450
2451static struct branch_clk usb_hs4_p_clk = {
2452 .b = {
2453 .ctl_reg = USB_HS4_HCLK_CTL_REG,
2454 .en_mask = BIT(4),
2455 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2456 .halt_bit = 7,
2457 },
2458 .c = {
2459 .dbg_name = "usb_hs4_p_clk",
2460 .ops = &clk_ops_branch,
2461 CLK_INIT(usb_hs4_p_clk.c),
2462 },
2463};
2464
Stephen Boyd94625ef2011-07-12 17:06:01 -07002465static struct branch_clk usb_hsic_p_clk = {
2466 .b = {
2467 .ctl_reg = USB_HSIC_HCLK_CTL_REG,
2468 .en_mask = BIT(4),
2469 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2470 .halt_bit = 28,
2471 },
2472 .c = {
2473 .dbg_name = "usb_hsic_p_clk",
2474 .ops = &clk_ops_branch,
2475 CLK_INIT(usb_hsic_p_clk.c),
2476 },
2477};
2478
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002479static struct branch_clk sdc1_p_clk = {
2480 .b = {
2481 .ctl_reg = SDCn_HCLK_CTL_REG(1),
2482 .en_mask = BIT(4),
2483 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2484 .halt_bit = 11,
2485 },
2486 .c = {
2487 .dbg_name = "sdc1_p_clk",
2488 .ops = &clk_ops_branch,
2489 CLK_INIT(sdc1_p_clk.c),
2490 },
2491};
2492
2493static struct branch_clk sdc2_p_clk = {
2494 .b = {
2495 .ctl_reg = SDCn_HCLK_CTL_REG(2),
2496 .en_mask = BIT(4),
2497 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2498 .halt_bit = 10,
2499 },
2500 .c = {
2501 .dbg_name = "sdc2_p_clk",
2502 .ops = &clk_ops_branch,
2503 CLK_INIT(sdc2_p_clk.c),
2504 },
2505};
2506
2507static struct branch_clk sdc3_p_clk = {
2508 .b = {
2509 .ctl_reg = SDCn_HCLK_CTL_REG(3),
2510 .en_mask = BIT(4),
2511 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2512 .halt_bit = 9,
2513 },
2514 .c = {
2515 .dbg_name = "sdc3_p_clk",
2516 .ops = &clk_ops_branch,
2517 CLK_INIT(sdc3_p_clk.c),
2518 },
2519};
2520
2521static struct branch_clk sdc4_p_clk = {
2522 .b = {
2523 .ctl_reg = SDCn_HCLK_CTL_REG(4),
2524 .en_mask = BIT(4),
2525 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2526 .halt_bit = 8,
2527 },
2528 .c = {
2529 .dbg_name = "sdc4_p_clk",
2530 .ops = &clk_ops_branch,
2531 CLK_INIT(sdc4_p_clk.c),
2532 },
2533};
2534
2535static struct branch_clk sdc5_p_clk = {
2536 .b = {
2537 .ctl_reg = SDCn_HCLK_CTL_REG(5),
2538 .en_mask = BIT(4),
2539 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2540 .halt_bit = 7,
2541 },
2542 .c = {
2543 .dbg_name = "sdc5_p_clk",
2544 .ops = &clk_ops_branch,
2545 CLK_INIT(sdc5_p_clk.c),
2546 },
2547};
2548
2549/* HW-Voteable Clocks */
2550static struct branch_clk adm0_clk = {
2551 .b = {
2552 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2553 .en_mask = BIT(2),
2554 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2555 .halt_check = HALT_VOTED,
2556 .halt_bit = 14,
2557 },
2558 .c = {
2559 .dbg_name = "adm0_clk",
2560 .ops = &clk_ops_branch,
2561 CLK_INIT(adm0_clk.c),
2562 },
2563};
2564
2565static struct branch_clk adm0_p_clk = {
2566 .b = {
2567 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2568 .en_mask = BIT(3),
2569 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2570 .halt_check = HALT_VOTED,
2571 .halt_bit = 13,
2572 },
2573 .c = {
2574 .dbg_name = "adm0_p_clk",
2575 .ops = &clk_ops_branch,
2576 CLK_INIT(adm0_p_clk.c),
2577 },
2578};
2579
2580static struct branch_clk pmic_arb0_p_clk = {
2581 .b = {
2582 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2583 .en_mask = BIT(8),
2584 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2585 .halt_check = HALT_VOTED,
2586 .halt_bit = 22,
2587 },
2588 .c = {
2589 .dbg_name = "pmic_arb0_p_clk",
2590 .ops = &clk_ops_branch,
2591 CLK_INIT(pmic_arb0_p_clk.c),
2592 },
2593};
2594
2595static struct branch_clk pmic_arb1_p_clk = {
2596 .b = {
2597 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2598 .en_mask = BIT(9),
2599 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2600 .halt_check = HALT_VOTED,
2601 .halt_bit = 21,
2602 },
2603 .c = {
2604 .dbg_name = "pmic_arb1_p_clk",
2605 .ops = &clk_ops_branch,
2606 CLK_INIT(pmic_arb1_p_clk.c),
2607 },
2608};
2609
2610static struct branch_clk pmic_ssbi2_clk = {
2611 .b = {
2612 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2613 .en_mask = BIT(7),
2614 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2615 .halt_check = HALT_VOTED,
2616 .halt_bit = 23,
2617 },
2618 .c = {
2619 .dbg_name = "pmic_ssbi2_clk",
2620 .ops = &clk_ops_branch,
2621 CLK_INIT(pmic_ssbi2_clk.c),
2622 },
2623};
2624
2625static struct branch_clk rpm_msg_ram_p_clk = {
2626 .b = {
2627 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2628 .en_mask = BIT(6),
2629 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2630 .halt_check = HALT_VOTED,
2631 .halt_bit = 12,
2632 },
2633 .c = {
2634 .dbg_name = "rpm_msg_ram_p_clk",
2635 .ops = &clk_ops_branch,
2636 CLK_INIT(rpm_msg_ram_p_clk.c),
2637 },
2638};
2639
2640/*
2641 * Multimedia Clocks
2642 */
2643
2644static struct branch_clk amp_clk = {
2645 .b = {
2646 .reset_reg = SW_RESET_CORE_REG,
2647 .reset_mask = BIT(20),
2648 },
2649 .c = {
2650 .dbg_name = "amp_clk",
2651 .ops = &clk_ops_reset,
2652 CLK_INIT(amp_clk.c),
2653 },
2654};
2655
Stephen Boyd94625ef2011-07-12 17:06:01 -07002656#define CLK_CAM(name, n, hb) \
2657 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002658 .b = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002659 .ctl_reg = CAMCLK##n##_CC_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002660 .en_mask = BIT(0), \
2661 .halt_reg = DBG_BUS_VEC_I_REG, \
2662 .halt_bit = hb, \
2663 }, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002664 .ns_reg = CAMCLK##n##_NS_REG, \
2665 .md_reg = CAMCLK##n##_MD_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002666 .root_en_mask = BIT(2), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002667 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002668 .ctl_mask = BM(7, 6), \
2669 .set_rate = set_rate_mnd_8, \
2670 .freq_tbl = clk_tbl_cam, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002671 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002672 .c = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002673 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002674 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002675 VDD_DIG_FMAX_MAP2(LOW, 64000000, NOMINAL, 128000000), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002676 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002677 }, \
2678 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002679#define F_CAM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002680 { \
2681 .freq_hz = f, \
2682 .src_clk = &s##_clk.c, \
2683 .md_val = MD8(8, m, 0, n), \
2684 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2685 .ctl_val = CC(6, n), \
2686 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002687 }
2688static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002689 F_CAM( 0, gnd, 1, 0, 0),
2690 F_CAM( 6000000, pll8, 4, 1, 16),
2691 F_CAM( 8000000, pll8, 4, 1, 12),
2692 F_CAM( 12000000, pll8, 4, 1, 8),
2693 F_CAM( 16000000, pll8, 4, 1, 6),
2694 F_CAM( 19200000, pll8, 4, 1, 5),
2695 F_CAM( 24000000, pll8, 4, 1, 4),
2696 F_CAM( 32000000, pll8, 4, 1, 3),
2697 F_CAM( 48000000, pll8, 4, 1, 2),
2698 F_CAM( 64000000, pll8, 3, 1, 2),
2699 F_CAM( 96000000, pll8, 4, 0, 0),
2700 F_CAM(128000000, pll8, 3, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002701 F_END
2702};
2703
Stephen Boyd94625ef2011-07-12 17:06:01 -07002704static CLK_CAM(cam0_clk, 0, 15);
2705static CLK_CAM(cam1_clk, 1, 16);
2706static CLK_CAM(cam2_clk, 2, 31);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002707
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002708#define F_CSI(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002709 { \
2710 .freq_hz = f, \
2711 .src_clk = &s##_clk.c, \
2712 .md_val = MD8(8, m, 0, n), \
2713 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2714 .ctl_val = CC(6, n), \
2715 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002716 }
2717static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002718 F_CSI( 0, gnd, 1, 0, 0),
2719 F_CSI( 85330000, pll8, 1, 2, 9),
2720 F_CSI(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002721 F_END
2722};
2723
2724static struct rcg_clk csi0_src_clk = {
2725 .ns_reg = CSI0_NS_REG,
2726 .b = {
2727 .ctl_reg = CSI0_CC_REG,
2728 .halt_check = NOCHECK,
2729 },
2730 .md_reg = CSI0_MD_REG,
2731 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002732 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002733 .ctl_mask = BM(7, 6),
2734 .set_rate = set_rate_mnd,
2735 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002736 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002737 .c = {
2738 .dbg_name = "csi0_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002739 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002740 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002741 CLK_INIT(csi0_src_clk.c),
2742 },
2743};
2744
2745static struct branch_clk csi0_clk = {
2746 .b = {
2747 .ctl_reg = CSI0_CC_REG,
2748 .en_mask = BIT(0),
2749 .reset_reg = SW_RESET_CORE_REG,
2750 .reset_mask = BIT(8),
2751 .halt_reg = DBG_BUS_VEC_B_REG,
2752 .halt_bit = 13,
2753 },
2754 .parent = &csi0_src_clk.c,
2755 .c = {
2756 .dbg_name = "csi0_clk",
2757 .ops = &clk_ops_branch,
2758 CLK_INIT(csi0_clk.c),
2759 },
2760};
2761
2762static struct branch_clk csi0_phy_clk = {
2763 .b = {
2764 .ctl_reg = CSI0_CC_REG,
2765 .en_mask = BIT(8),
2766 .reset_reg = SW_RESET_CORE_REG,
2767 .reset_mask = BIT(29),
2768 .halt_reg = DBG_BUS_VEC_I_REG,
2769 .halt_bit = 9,
2770 },
2771 .parent = &csi0_src_clk.c,
2772 .c = {
2773 .dbg_name = "csi0_phy_clk",
2774 .ops = &clk_ops_branch,
2775 CLK_INIT(csi0_phy_clk.c),
2776 },
2777};
2778
2779static struct rcg_clk csi1_src_clk = {
2780 .ns_reg = CSI1_NS_REG,
2781 .b = {
2782 .ctl_reg = CSI1_CC_REG,
2783 .halt_check = NOCHECK,
2784 },
2785 .md_reg = CSI1_MD_REG,
2786 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002787 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002788 .ctl_mask = BM(7, 6),
2789 .set_rate = set_rate_mnd,
2790 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002791 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002792 .c = {
2793 .dbg_name = "csi1_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002794 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002795 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002796 CLK_INIT(csi1_src_clk.c),
2797 },
2798};
2799
2800static struct branch_clk csi1_clk = {
2801 .b = {
2802 .ctl_reg = CSI1_CC_REG,
2803 .en_mask = BIT(0),
2804 .reset_reg = SW_RESET_CORE_REG,
2805 .reset_mask = BIT(18),
2806 .halt_reg = DBG_BUS_VEC_B_REG,
2807 .halt_bit = 14,
2808 },
2809 .parent = &csi1_src_clk.c,
2810 .c = {
2811 .dbg_name = "csi1_clk",
2812 .ops = &clk_ops_branch,
2813 CLK_INIT(csi1_clk.c),
2814 },
2815};
2816
2817static struct branch_clk csi1_phy_clk = {
2818 .b = {
2819 .ctl_reg = CSI1_CC_REG,
2820 .en_mask = BIT(8),
2821 .reset_reg = SW_RESET_CORE_REG,
2822 .reset_mask = BIT(28),
2823 .halt_reg = DBG_BUS_VEC_I_REG,
2824 .halt_bit = 10,
2825 },
2826 .parent = &csi1_src_clk.c,
2827 .c = {
2828 .dbg_name = "csi1_phy_clk",
2829 .ops = &clk_ops_branch,
2830 CLK_INIT(csi1_phy_clk.c),
2831 },
2832};
2833
Stephen Boyd94625ef2011-07-12 17:06:01 -07002834static struct rcg_clk csi2_src_clk = {
2835 .ns_reg = CSI2_NS_REG,
2836 .b = {
2837 .ctl_reg = CSI2_CC_REG,
2838 .halt_check = NOCHECK,
2839 },
2840 .md_reg = CSI2_MD_REG,
2841 .root_en_mask = BIT(2),
2842 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
2843 .ctl_mask = BM(7, 6),
2844 .set_rate = set_rate_mnd,
2845 .freq_tbl = clk_tbl_csi,
2846 .current_freq = &rcg_dummy_freq,
2847 .c = {
2848 .dbg_name = "csi2_src_clk",
2849 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002850 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002851 CLK_INIT(csi2_src_clk.c),
2852 },
2853};
2854
2855static struct branch_clk csi2_clk = {
2856 .b = {
2857 .ctl_reg = CSI2_CC_REG,
2858 .en_mask = BIT(0),
2859 .reset_reg = SW_RESET_CORE2_REG,
2860 .reset_mask = BIT(2),
2861 .halt_reg = DBG_BUS_VEC_B_REG,
2862 .halt_bit = 29,
2863 },
2864 .parent = &csi2_src_clk.c,
2865 .c = {
2866 .dbg_name = "csi2_clk",
2867 .ops = &clk_ops_branch,
2868 CLK_INIT(csi2_clk.c),
2869 },
2870};
2871
2872static struct branch_clk csi2_phy_clk = {
2873 .b = {
2874 .ctl_reg = CSI2_CC_REG,
2875 .en_mask = BIT(8),
2876 .reset_reg = SW_RESET_CORE_REG,
2877 .reset_mask = BIT(31),
2878 .halt_reg = DBG_BUS_VEC_I_REG,
2879 .halt_bit = 29,
2880 },
2881 .parent = &csi2_src_clk.c,
2882 .c = {
2883 .dbg_name = "csi2_phy_clk",
2884 .ops = &clk_ops_branch,
2885 CLK_INIT(csi2_phy_clk.c),
2886 },
2887};
2888
2889/*
2890 * The csi pix and csi rdi clocks have two bits in two registers to control a
2891 * three input mux. So we have the generic rcg_clk_enable() path handle the
2892 * first bit, and this function handle the second bit.
2893 */
2894static void set_rate_pix_rdi(struct rcg_clk *clk, struct clk_freq_tbl *nf)
2895{
2896 u32 reg = readl_relaxed(MISC_CC3_REG);
2897 u32 bit = (u32)nf->extra_freq_data;
2898 if (nf->freq_hz == 2)
2899 reg |= bit;
2900 else
2901 reg &= ~bit;
2902 writel_relaxed(reg, MISC_CC3_REG);
2903}
2904
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002905#define F_CSI_PIX(s) \
2906 { \
2907 .src_clk = &csi##s##_clk.c, \
2908 .freq_hz = s, \
2909 .ns_val = BVAL(25, 25, s), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002910 .extra_freq_data = (void *)BIT(13), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002911 }
2912static struct clk_freq_tbl clk_tbl_csi_pix[] = {
2913 F_CSI_PIX(0), /* CSI0 source */
2914 F_CSI_PIX(1), /* CSI1 source */
Stephen Boyd94625ef2011-07-12 17:06:01 -07002915 F_CSI_PIX(2), /* CSI2 source */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002916 F_END
2917};
2918
2919static struct rcg_clk csi_pix_clk = {
2920 .b = {
2921 .ctl_reg = MISC_CC_REG,
2922 .en_mask = BIT(26),
2923 .halt_check = DELAY,
2924 .reset_reg = SW_RESET_CORE_REG,
2925 .reset_mask = BIT(26),
2926 },
2927 .ns_reg = MISC_CC_REG,
2928 .ns_mask = BIT(25),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002929 .set_rate = set_rate_pix_rdi,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002930 .freq_tbl = clk_tbl_csi_pix,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002931 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002932 .c = {
2933 .dbg_name = "csi_pix_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002934 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002935 CLK_INIT(csi_pix_clk.c),
2936 },
2937};
2938
Stephen Boyd94625ef2011-07-12 17:06:01 -07002939#define F_CSI_PIX1(s) \
2940 { \
2941 .src_clk = &csi##s##_clk.c, \
2942 .freq_hz = s, \
2943 .ns_val = BVAL(9, 8, s), \
2944 }
2945static struct clk_freq_tbl clk_tbl_csi_pix1[] = {
2946 F_CSI_PIX1(0), /* CSI0 source */
2947 F_CSI_PIX1(1), /* CSI1 source */
2948 F_CSI_PIX1(2), /* CSI2 source */
2949 F_END
2950};
2951
2952static struct rcg_clk csi_pix1_clk = {
2953 .b = {
2954 .ctl_reg = MISC_CC3_REG,
2955 .en_mask = BIT(10),
2956 .halt_check = DELAY,
2957 .reset_reg = SW_RESET_CORE_REG,
2958 .reset_mask = BIT(30),
2959 },
2960 .ns_reg = MISC_CC3_REG,
2961 .ns_mask = BM(9, 8),
2962 .set_rate = set_rate_nop,
2963 .freq_tbl = clk_tbl_csi_pix1,
2964 .current_freq = &rcg_dummy_freq,
2965 .c = {
2966 .dbg_name = "csi_pix1_clk",
2967 .ops = &clk_ops_rcg_8960,
2968 CLK_INIT(csi_pix1_clk.c),
2969 },
2970};
2971
2972#define F_CSI_RDI(s) \
2973 { \
2974 .src_clk = &csi##s##_clk.c, \
2975 .freq_hz = s, \
2976 .ns_val = BVAL(12, 12, s), \
2977 .extra_freq_data = (void *)BIT(12), \
2978 }
2979static struct clk_freq_tbl clk_tbl_csi_rdi[] = {
2980 F_CSI_RDI(0), /* CSI0 source */
2981 F_CSI_RDI(1), /* CSI1 source */
2982 F_CSI_RDI(2), /* CSI2 source */
2983 F_END
2984};
2985
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002986static struct rcg_clk csi_rdi_clk = {
2987 .b = {
2988 .ctl_reg = MISC_CC_REG,
2989 .en_mask = BIT(13),
2990 .halt_check = DELAY,
2991 .reset_reg = SW_RESET_CORE_REG,
2992 .reset_mask = BIT(27),
2993 },
2994 .ns_reg = MISC_CC_REG,
2995 .ns_mask = BIT(12),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002996 .set_rate = set_rate_pix_rdi,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002997 .freq_tbl = clk_tbl_csi_rdi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002998 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002999 .c = {
3000 .dbg_name = "csi_rdi_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003001 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003002 CLK_INIT(csi_rdi_clk.c),
3003 },
3004};
3005
Stephen Boyd94625ef2011-07-12 17:06:01 -07003006#define F_CSI_RDI1(s) \
3007 { \
3008 .src_clk = &csi##s##_clk.c, \
3009 .freq_hz = s, \
3010 .ns_val = BVAL(1, 0, s), \
3011 }
3012static struct clk_freq_tbl clk_tbl_csi_rdi1[] = {
3013 F_CSI_RDI1(0), /* CSI0 source */
3014 F_CSI_RDI1(1), /* CSI1 source */
3015 F_CSI_RDI1(2), /* CSI2 source */
3016 F_END
3017};
3018
3019static struct rcg_clk csi_rdi1_clk = {
3020 .b = {
3021 .ctl_reg = MISC_CC3_REG,
3022 .en_mask = BIT(2),
3023 .halt_check = DELAY,
3024 .reset_reg = SW_RESET_CORE2_REG,
3025 .reset_mask = BIT(1),
3026 },
3027 .ns_reg = MISC_CC3_REG,
3028 .ns_mask = BM(1, 0),
3029 .set_rate = set_rate_nop,
3030 .freq_tbl = clk_tbl_csi_rdi1,
3031 .current_freq = &rcg_dummy_freq,
3032 .c = {
3033 .dbg_name = "csi_rdi1_clk",
3034 .ops = &clk_ops_rcg_8960,
3035 CLK_INIT(csi_rdi1_clk.c),
3036 },
3037};
3038
3039#define F_CSI_RDI2(s) \
3040 { \
3041 .src_clk = &csi##s##_clk.c, \
3042 .freq_hz = s, \
3043 .ns_val = BVAL(5, 4, s), \
3044 }
3045static struct clk_freq_tbl clk_tbl_csi_rdi2[] = {
3046 F_CSI_RDI2(0), /* CSI0 source */
3047 F_CSI_RDI2(1), /* CSI1 source */
3048 F_CSI_RDI2(2), /* CSI2 source */
3049 F_END
3050};
3051
3052static struct rcg_clk csi_rdi2_clk = {
3053 .b = {
3054 .ctl_reg = MISC_CC3_REG,
3055 .en_mask = BIT(6),
3056 .halt_check = DELAY,
3057 .reset_reg = SW_RESET_CORE2_REG,
3058 .reset_mask = BIT(0),
3059 },
3060 .ns_reg = MISC_CC3_REG,
3061 .ns_mask = BM(5, 4),
3062 .set_rate = set_rate_nop,
3063 .freq_tbl = clk_tbl_csi_rdi2,
3064 .current_freq = &rcg_dummy_freq,
3065 .c = {
3066 .dbg_name = "csi_rdi2_clk",
3067 .ops = &clk_ops_rcg_8960,
3068 CLK_INIT(csi_rdi2_clk.c),
3069 },
3070};
3071
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003072#define F_CSI_PHYTIMER(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003073 { \
3074 .freq_hz = f, \
3075 .src_clk = &s##_clk.c, \
3076 .md_val = MD8(8, m, 0, n), \
3077 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3078 .ctl_val = CC(6, n), \
3079 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003080 }
3081static struct clk_freq_tbl clk_tbl_csi_phytimer[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003082 F_CSI_PHYTIMER( 0, gnd, 1, 0, 0),
3083 F_CSI_PHYTIMER( 85330000, pll8, 1, 2, 9),
3084 F_CSI_PHYTIMER(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003085 F_END
3086};
3087
3088static struct rcg_clk csiphy_timer_src_clk = {
3089 .ns_reg = CSIPHYTIMER_NS_REG,
3090 .b = {
3091 .ctl_reg = CSIPHYTIMER_CC_REG,
3092 .halt_check = NOCHECK,
3093 },
3094 .md_reg = CSIPHYTIMER_MD_REG,
3095 .root_en_mask = BIT(2),
3096 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
3097 .ctl_mask = BM(7, 6),
3098 .set_rate = set_rate_mnd_8,
3099 .freq_tbl = clk_tbl_csi_phytimer,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003100 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003101 .c = {
3102 .dbg_name = "csiphy_timer_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003103 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003104 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003105 CLK_INIT(csiphy_timer_src_clk.c),
3106 },
3107};
3108
3109static struct branch_clk csi0phy_timer_clk = {
3110 .b = {
3111 .ctl_reg = CSIPHYTIMER_CC_REG,
3112 .en_mask = BIT(0),
3113 .halt_reg = DBG_BUS_VEC_I_REG,
3114 .halt_bit = 17,
3115 },
3116 .parent = &csiphy_timer_src_clk.c,
3117 .c = {
3118 .dbg_name = "csi0phy_timer_clk",
3119 .ops = &clk_ops_branch,
3120 CLK_INIT(csi0phy_timer_clk.c),
3121 },
3122};
3123
3124static struct branch_clk csi1phy_timer_clk = {
3125 .b = {
3126 .ctl_reg = CSIPHYTIMER_CC_REG,
3127 .en_mask = BIT(9),
3128 .halt_reg = DBG_BUS_VEC_I_REG,
3129 .halt_bit = 18,
3130 },
3131 .parent = &csiphy_timer_src_clk.c,
3132 .c = {
3133 .dbg_name = "csi1phy_timer_clk",
3134 .ops = &clk_ops_branch,
3135 CLK_INIT(csi1phy_timer_clk.c),
3136 },
3137};
3138
Stephen Boyd94625ef2011-07-12 17:06:01 -07003139static struct branch_clk csi2phy_timer_clk = {
3140 .b = {
3141 .ctl_reg = CSIPHYTIMER_CC_REG,
3142 .en_mask = BIT(11),
3143 .halt_reg = DBG_BUS_VEC_I_REG,
3144 .halt_bit = 30,
3145 },
3146 .parent = &csiphy_timer_src_clk.c,
3147 .c = {
3148 .dbg_name = "csi2phy_timer_clk",
3149 .ops = &clk_ops_branch,
3150 CLK_INIT(csi2phy_timer_clk.c),
3151 },
3152};
3153
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003154#define F_DSI(d) \
3155 { \
3156 .freq_hz = d, \
3157 .ns_val = BVAL(15, 12, (d-1)), \
3158 }
3159/*
3160 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
3161 * without this clock driver knowing. So, overload the clk_set_rate() to set
3162 * the divider (1 to 16) of the clock with respect to the PLL rate.
3163 */
3164static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
3165 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
3166 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
3167 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
3168 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
3169 F_END
3170};
3171
3172static struct rcg_clk dsi1_byte_clk = {
3173 .b = {
3174 .ctl_reg = DSI1_BYTE_CC_REG,
3175 .en_mask = BIT(0),
3176 .reset_reg = SW_RESET_CORE_REG,
3177 .reset_mask = BIT(7),
3178 .halt_reg = DBG_BUS_VEC_B_REG,
3179 .halt_bit = 21,
3180 },
3181 .ns_reg = DSI1_BYTE_NS_REG,
3182 .root_en_mask = BIT(2),
3183 .ns_mask = BM(15, 12),
3184 .set_rate = set_rate_nop,
3185 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003186 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003187 .c = {
3188 .dbg_name = "dsi1_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003189 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003190 CLK_INIT(dsi1_byte_clk.c),
3191 },
3192};
3193
3194static struct rcg_clk dsi2_byte_clk = {
3195 .b = {
3196 .ctl_reg = DSI2_BYTE_CC_REG,
3197 .en_mask = BIT(0),
3198 .reset_reg = SW_RESET_CORE_REG,
3199 .reset_mask = BIT(25),
3200 .halt_reg = DBG_BUS_VEC_B_REG,
3201 .halt_bit = 20,
3202 },
3203 .ns_reg = DSI2_BYTE_NS_REG,
3204 .root_en_mask = BIT(2),
3205 .ns_mask = BM(15, 12),
3206 .set_rate = set_rate_nop,
3207 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003208 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003209 .c = {
3210 .dbg_name = "dsi2_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003211 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003212 CLK_INIT(dsi2_byte_clk.c),
3213 },
3214};
3215
3216static struct rcg_clk dsi1_esc_clk = {
3217 .b = {
3218 .ctl_reg = DSI1_ESC_CC_REG,
3219 .en_mask = BIT(0),
3220 .reset_reg = SW_RESET_CORE_REG,
3221 .halt_reg = DBG_BUS_VEC_I_REG,
3222 .halt_bit = 1,
3223 },
3224 .ns_reg = DSI1_ESC_NS_REG,
3225 .root_en_mask = BIT(2),
3226 .ns_mask = BM(15, 12),
3227 .set_rate = set_rate_nop,
3228 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003229 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003230 .c = {
3231 .dbg_name = "dsi1_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003232 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003233 CLK_INIT(dsi1_esc_clk.c),
3234 },
3235};
3236
3237static struct rcg_clk dsi2_esc_clk = {
3238 .b = {
3239 .ctl_reg = DSI2_ESC_CC_REG,
3240 .en_mask = BIT(0),
3241 .halt_reg = DBG_BUS_VEC_I_REG,
3242 .halt_bit = 3,
3243 },
3244 .ns_reg = DSI2_ESC_NS_REG,
3245 .root_en_mask = BIT(2),
3246 .ns_mask = BM(15, 12),
3247 .set_rate = set_rate_nop,
3248 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003249 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003250 .c = {
3251 .dbg_name = "dsi2_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003252 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003253 CLK_INIT(dsi2_esc_clk.c),
3254 },
3255};
3256
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003257#define F_GFX2D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003258 { \
3259 .freq_hz = f, \
3260 .src_clk = &s##_clk.c, \
3261 .md_val = MD4(4, m, 0, n), \
3262 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
3263 .ctl_val = CC_BANKED(9, 6, n), \
3264 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003265 }
3266static struct clk_freq_tbl clk_tbl_gfx2d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003267 F_GFX2D( 0, gnd, 0, 0),
3268 F_GFX2D( 27000000, pxo, 0, 0),
3269 F_GFX2D( 48000000, pll8, 1, 8),
3270 F_GFX2D( 54857000, pll8, 1, 7),
3271 F_GFX2D( 64000000, pll8, 1, 6),
3272 F_GFX2D( 76800000, pll8, 1, 5),
3273 F_GFX2D( 96000000, pll8, 1, 4),
3274 F_GFX2D(128000000, pll8, 1, 3),
3275 F_GFX2D(145455000, pll2, 2, 11),
3276 F_GFX2D(160000000, pll2, 1, 5),
3277 F_GFX2D(177778000, pll2, 2, 9),
3278 F_GFX2D(200000000, pll2, 1, 4),
3279 F_GFX2D(228571000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003280 F_END
3281};
3282
3283static struct bank_masks bmnd_info_gfx2d0 = {
3284 .bank_sel_mask = BIT(11),
3285 .bank0_mask = {
3286 .md_reg = GFX2D0_MD0_REG,
3287 .ns_mask = BM(23, 20) | BM(5, 3),
3288 .rst_mask = BIT(25),
3289 .mnd_en_mask = BIT(8),
3290 .mode_mask = BM(10, 9),
3291 },
3292 .bank1_mask = {
3293 .md_reg = GFX2D0_MD1_REG,
3294 .ns_mask = BM(19, 16) | BM(2, 0),
3295 .rst_mask = BIT(24),
3296 .mnd_en_mask = BIT(5),
3297 .mode_mask = BM(7, 6),
3298 },
3299};
3300
3301static struct rcg_clk gfx2d0_clk = {
3302 .b = {
3303 .ctl_reg = GFX2D0_CC_REG,
3304 .en_mask = BIT(0),
3305 .reset_reg = SW_RESET_CORE_REG,
3306 .reset_mask = BIT(14),
3307 .halt_reg = DBG_BUS_VEC_A_REG,
3308 .halt_bit = 9,
3309 },
3310 .ns_reg = GFX2D0_NS_REG,
3311 .root_en_mask = BIT(2),
3312 .set_rate = set_rate_mnd_banked,
3313 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003314 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003315 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003316 .c = {
3317 .dbg_name = "gfx2d0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003318 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003319 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3320 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003321 CLK_INIT(gfx2d0_clk.c),
3322 },
3323};
3324
3325static struct bank_masks bmnd_info_gfx2d1 = {
3326 .bank_sel_mask = BIT(11),
3327 .bank0_mask = {
3328 .md_reg = GFX2D1_MD0_REG,
3329 .ns_mask = BM(23, 20) | BM(5, 3),
3330 .rst_mask = BIT(25),
3331 .mnd_en_mask = BIT(8),
3332 .mode_mask = BM(10, 9),
3333 },
3334 .bank1_mask = {
3335 .md_reg = GFX2D1_MD1_REG,
3336 .ns_mask = BM(19, 16) | BM(2, 0),
3337 .rst_mask = BIT(24),
3338 .mnd_en_mask = BIT(5),
3339 .mode_mask = BM(7, 6),
3340 },
3341};
3342
3343static struct rcg_clk gfx2d1_clk = {
3344 .b = {
3345 .ctl_reg = GFX2D1_CC_REG,
3346 .en_mask = BIT(0),
3347 .reset_reg = SW_RESET_CORE_REG,
3348 .reset_mask = BIT(13),
3349 .halt_reg = DBG_BUS_VEC_A_REG,
3350 .halt_bit = 14,
3351 },
3352 .ns_reg = GFX2D1_NS_REG,
3353 .root_en_mask = BIT(2),
3354 .set_rate = set_rate_mnd_banked,
3355 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003356 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003357 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003358 .c = {
3359 .dbg_name = "gfx2d1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003360 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003361 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3362 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003363 CLK_INIT(gfx2d1_clk.c),
3364 },
3365};
3366
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003367#define F_GFX3D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003368 { \
3369 .freq_hz = f, \
3370 .src_clk = &s##_clk.c, \
3371 .md_val = MD4(4, m, 0, n), \
3372 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3373 .ctl_val = CC_BANKED(9, 6, n), \
3374 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003375 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003376
3377static struct clk_freq_tbl clk_tbl_gfx3d_8960[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003378 F_GFX3D( 0, gnd, 0, 0),
3379 F_GFX3D( 27000000, pxo, 0, 0),
3380 F_GFX3D( 48000000, pll8, 1, 8),
3381 F_GFX3D( 54857000, pll8, 1, 7),
3382 F_GFX3D( 64000000, pll8, 1, 6),
3383 F_GFX3D( 76800000, pll8, 1, 5),
3384 F_GFX3D( 96000000, pll8, 1, 4),
3385 F_GFX3D(128000000, pll8, 1, 3),
3386 F_GFX3D(145455000, pll2, 2, 11),
3387 F_GFX3D(160000000, pll2, 1, 5),
3388 F_GFX3D(177778000, pll2, 2, 9),
3389 F_GFX3D(200000000, pll2, 1, 4),
3390 F_GFX3D(228571000, pll2, 2, 7),
3391 F_GFX3D(266667000, pll2, 1, 3),
3392 F_GFX3D(320000000, pll2, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003393 F_END
3394};
3395
Tianyi Gou41515e22011-09-01 19:37:43 -07003396static struct clk_freq_tbl clk_tbl_gfx3d_8960_v2[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003397 F_GFX3D( 0, gnd, 0, 0),
3398 F_GFX3D( 27000000, pxo, 0, 0),
3399 F_GFX3D( 48000000, pll8, 1, 8),
3400 F_GFX3D( 54857000, pll8, 1, 7),
3401 F_GFX3D( 64000000, pll8, 1, 6),
3402 F_GFX3D( 76800000, pll8, 1, 5),
3403 F_GFX3D( 96000000, pll8, 1, 4),
3404 F_GFX3D(128000000, pll8, 1, 3),
3405 F_GFX3D(145455000, pll2, 2, 11),
3406 F_GFX3D(160000000, pll2, 1, 5),
3407 F_GFX3D(177778000, pll2, 2, 9),
3408 F_GFX3D(200000000, pll2, 1, 4),
3409 F_GFX3D(228571000, pll2, 2, 7),
3410 F_GFX3D(266667000, pll2, 1, 3),
3411 F_GFX3D(300000000, pll3, 1, 4),
3412 F_GFX3D(320000000, pll2, 2, 5),
3413 F_GFX3D(400000000, pll2, 1, 2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003414 F_END
3415};
3416
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003417static unsigned long fmax_gfx3d_8960_v2[MAX_VDD_LEVELS] __initdata = {
3418 [VDD_DIG_LOW] = 128000000,
3419 [VDD_DIG_NOMINAL] = 300000000,
3420 [VDD_DIG_HIGH] = 400000000
3421};
3422
Tianyi Gou621f8742011-09-01 21:45:01 -07003423/* TODO: need to add 325MHz back once it is fixed in the simulation model */
Tianyi Gou41515e22011-09-01 19:37:43 -07003424static struct clk_freq_tbl clk_tbl_gfx3d_8064[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003425 F_GFX3D( 0, gnd, 0, 0),
3426 F_GFX3D( 27000000, pxo, 0, 0),
3427 F_GFX3D( 48000000, pll8, 1, 8),
3428 F_GFX3D( 54857000, pll8, 1, 7),
3429 F_GFX3D( 64000000, pll8, 1, 6),
3430 F_GFX3D( 76800000, pll8, 1, 5),
3431 F_GFX3D( 96000000, pll8, 1, 4),
3432 F_GFX3D(128000000, pll8, 1, 3),
3433 F_GFX3D(145455000, pll2, 2, 11),
3434 F_GFX3D(160000000, pll2, 1, 5),
3435 F_GFX3D(177778000, pll2, 2, 9),
3436 F_GFX3D(200000000, pll2, 1, 4),
3437 F_GFX3D(228571000, pll2, 2, 7),
3438 F_GFX3D(266667000, pll2, 1, 3),
3439 F_GFX3D(400000000, pll2, 1, 2),
Tianyi Gou41515e22011-09-01 19:37:43 -07003440 F_END
3441};
3442
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003443static unsigned long fmax_gfx3d_8064[MAX_VDD_LEVELS] __initdata = {
3444 [VDD_DIG_LOW] = 128000000,
3445 [VDD_DIG_NOMINAL] = 325000000,
3446 [VDD_DIG_HIGH] = 400000000
3447};
3448
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003449static struct bank_masks bmnd_info_gfx3d = {
3450 .bank_sel_mask = BIT(11),
3451 .bank0_mask = {
3452 .md_reg = GFX3D_MD0_REG,
3453 .ns_mask = BM(21, 18) | BM(5, 3),
3454 .rst_mask = BIT(23),
3455 .mnd_en_mask = BIT(8),
3456 .mode_mask = BM(10, 9),
3457 },
3458 .bank1_mask = {
3459 .md_reg = GFX3D_MD1_REG,
3460 .ns_mask = BM(17, 14) | BM(2, 0),
3461 .rst_mask = BIT(22),
3462 .mnd_en_mask = BIT(5),
3463 .mode_mask = BM(7, 6),
3464 },
3465};
3466
3467static struct rcg_clk gfx3d_clk = {
3468 .b = {
3469 .ctl_reg = GFX3D_CC_REG,
3470 .en_mask = BIT(0),
3471 .reset_reg = SW_RESET_CORE_REG,
3472 .reset_mask = BIT(12),
3473 .halt_reg = DBG_BUS_VEC_A_REG,
3474 .halt_bit = 4,
3475 },
3476 .ns_reg = GFX3D_NS_REG,
3477 .root_en_mask = BIT(2),
3478 .set_rate = set_rate_mnd_banked,
Tianyi Gou41515e22011-09-01 19:37:43 -07003479 .freq_tbl = clk_tbl_gfx3d_8960,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003480 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003481 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003482 .c = {
3483 .dbg_name = "gfx3d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003484 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003485 VDD_DIG_FMAX_MAP3(LOW, 128000000, NOMINAL, 266667000,
3486 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003487 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003488 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003489 },
3490};
3491
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003492#define F_VCAP(f, s, m, n) \
Tianyi Gou621f8742011-09-01 21:45:01 -07003493 { \
3494 .freq_hz = f, \
3495 .src_clk = &s##_clk.c, \
3496 .md_val = MD4(4, m, 0, n), \
3497 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3498 .ctl_val = CC_BANKED(9, 6, n), \
3499 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Tianyi Gou621f8742011-09-01 21:45:01 -07003500 }
3501
3502static struct clk_freq_tbl clk_tbl_vcap[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003503 F_VCAP( 0, gnd, 0, 0),
3504 F_VCAP( 27000000, pxo, 0, 0),
3505 F_VCAP( 54860000, pll8, 1, 7),
3506 F_VCAP( 64000000, pll8, 1, 6),
3507 F_VCAP( 76800000, pll8, 1, 5),
3508 F_VCAP(128000000, pll8, 1, 3),
3509 F_VCAP(160000000, pll2, 1, 5),
3510 F_VCAP(200000000, pll2, 1, 4),
Tianyi Gou621f8742011-09-01 21:45:01 -07003511 F_END
3512};
3513
3514static struct bank_masks bmnd_info_vcap = {
3515 .bank_sel_mask = BIT(11),
3516 .bank0_mask = {
3517 .md_reg = VCAP_MD0_REG,
3518 .ns_mask = BM(21, 18) | BM(5, 3),
3519 .rst_mask = BIT(23),
3520 .mnd_en_mask = BIT(8),
3521 .mode_mask = BM(10, 9),
3522 },
3523 .bank1_mask = {
3524 .md_reg = VCAP_MD1_REG,
3525 .ns_mask = BM(17, 14) | BM(2, 0),
3526 .rst_mask = BIT(22),
3527 .mnd_en_mask = BIT(5),
3528 .mode_mask = BM(7, 6),
3529 },
3530};
3531
3532static struct rcg_clk vcap_clk = {
3533 .b = {
3534 .ctl_reg = VCAP_CC_REG,
3535 .en_mask = BIT(0),
3536 .halt_reg = DBG_BUS_VEC_J_REG,
3537 .halt_bit = 15,
3538 },
3539 .ns_reg = VCAP_NS_REG,
3540 .root_en_mask = BIT(2),
3541 .set_rate = set_rate_mnd_banked,
3542 .freq_tbl = clk_tbl_vcap,
3543 .bank_info = &bmnd_info_vcap,
3544 .current_freq = &rcg_dummy_freq,
3545 .c = {
3546 .dbg_name = "vcap_clk",
3547 .ops = &clk_ops_rcg_8960,
3548 .depends = &vcap_axi_clk.c,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003549 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000),
Tianyi Gou621f8742011-09-01 21:45:01 -07003550 CLK_INIT(vcap_clk.c),
3551 },
3552};
3553
3554static struct branch_clk vcap_npl_clk = {
3555 .b = {
3556 .ctl_reg = VCAP_CC_REG,
3557 .en_mask = BIT(13),
3558 .halt_reg = DBG_BUS_VEC_J_REG,
3559 .halt_bit = 25,
3560 },
3561 .parent = &vcap_clk.c,
3562 .c = {
3563 .dbg_name = "vcap_npl_clk",
3564 .ops = &clk_ops_branch,
3565 CLK_INIT(vcap_npl_clk.c),
3566 },
3567};
3568
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003569#define F_IJPEG(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003570 { \
3571 .freq_hz = f, \
3572 .src_clk = &s##_clk.c, \
3573 .md_val = MD8(8, m, 0, n), \
3574 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
3575 .ctl_val = CC(6, n), \
3576 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003577 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003578
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003579static struct clk_freq_tbl clk_tbl_ijpeg[] = {
3580 F_IJPEG( 0, gnd, 1, 0, 0),
3581 F_IJPEG( 27000000, pxo, 1, 0, 0),
3582 F_IJPEG( 36570000, pll8, 1, 2, 21),
3583 F_IJPEG( 54860000, pll8, 7, 0, 0),
3584 F_IJPEG( 96000000, pll8, 4, 0, 0),
3585 F_IJPEG(109710000, pll8, 1, 2, 7),
3586 F_IJPEG(128000000, pll8, 3, 0, 0),
3587 F_IJPEG(153600000, pll8, 1, 2, 5),
3588 F_IJPEG(200000000, pll2, 4, 0, 0),
3589 F_IJPEG(228571000, pll2, 1, 2, 7),
3590 F_IJPEG(266667000, pll2, 1, 1, 3),
3591 F_IJPEG(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003592 F_END
3593};
3594
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003595static unsigned long fmax_ijpeg_8960_v2[MAX_VDD_LEVELS] __initdata = {
3596 [VDD_DIG_LOW] = 110000000,
3597 [VDD_DIG_NOMINAL] = 266667000,
3598 [VDD_DIG_HIGH] = 320000000
3599};
3600
3601static unsigned long fmax_ijpeg_8064[MAX_VDD_LEVELS] __initdata = {
3602 [VDD_DIG_LOW] = 128000000,
3603 [VDD_DIG_NOMINAL] = 266667000,
3604 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07003605};
3606
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003607static struct rcg_clk ijpeg_clk = {
3608 .b = {
3609 .ctl_reg = IJPEG_CC_REG,
3610 .en_mask = BIT(0),
3611 .reset_reg = SW_RESET_CORE_REG,
3612 .reset_mask = BIT(9),
3613 .halt_reg = DBG_BUS_VEC_A_REG,
3614 .halt_bit = 24,
3615 },
3616 .ns_reg = IJPEG_NS_REG,
3617 .md_reg = IJPEG_MD_REG,
3618 .root_en_mask = BIT(2),
3619 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
3620 .ctl_mask = BM(7, 6),
3621 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003622 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003623 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003624 .c = {
3625 .dbg_name = "ijpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003626 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003627 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003628 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003629 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003630 },
3631};
3632
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003633#define F_JPEGD(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003634 { \
3635 .freq_hz = f, \
3636 .src_clk = &s##_clk.c, \
3637 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003638 }
3639static struct clk_freq_tbl clk_tbl_jpegd[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003640 F_JPEGD( 0, gnd, 1),
3641 F_JPEGD( 64000000, pll8, 6),
3642 F_JPEGD( 76800000, pll8, 5),
3643 F_JPEGD( 96000000, pll8, 4),
3644 F_JPEGD(160000000, pll2, 5),
3645 F_JPEGD(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003646 F_END
3647};
3648
3649static struct rcg_clk jpegd_clk = {
3650 .b = {
3651 .ctl_reg = JPEGD_CC_REG,
3652 .en_mask = BIT(0),
3653 .reset_reg = SW_RESET_CORE_REG,
3654 .reset_mask = BIT(19),
3655 .halt_reg = DBG_BUS_VEC_A_REG,
3656 .halt_bit = 19,
3657 },
3658 .ns_reg = JPEGD_NS_REG,
3659 .root_en_mask = BIT(2),
3660 .ns_mask = (BM(15, 12) | BM(2, 0)),
3661 .set_rate = set_rate_nop,
3662 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003663 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003664 .c = {
3665 .dbg_name = "jpegd_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003666 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003667 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003668 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003669 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003670 },
3671};
3672
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003673#define F_MDP(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003674 { \
3675 .freq_hz = f, \
3676 .src_clk = &s##_clk.c, \
3677 .md_val = MD8(8, m, 0, n), \
3678 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
3679 .ctl_val = CC_BANKED(9, 6, n), \
3680 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003681 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003682static struct clk_freq_tbl clk_tbl_mdp[] = {
3683 F_MDP( 0, gnd, 0, 0),
3684 F_MDP( 9600000, pll8, 1, 40),
3685 F_MDP( 13710000, pll8, 1, 28),
3686 F_MDP( 27000000, pxo, 0, 0),
3687 F_MDP( 29540000, pll8, 1, 13),
3688 F_MDP( 34910000, pll8, 1, 11),
3689 F_MDP( 38400000, pll8, 1, 10),
3690 F_MDP( 59080000, pll8, 2, 13),
3691 F_MDP( 76800000, pll8, 1, 5),
3692 F_MDP( 85330000, pll8, 2, 9),
3693 F_MDP( 96000000, pll8, 1, 4),
3694 F_MDP(128000000, pll8, 1, 3),
3695 F_MDP(160000000, pll2, 1, 5),
3696 F_MDP(177780000, pll2, 2, 9),
3697 F_MDP(200000000, pll2, 1, 4),
3698 F_MDP(266667000, pll2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003699 F_END
3700};
3701
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003702static unsigned long fmax_mdp_8064[MAX_VDD_LEVELS] __initdata = {
3703 [VDD_DIG_LOW] = 128000000,
3704 [VDD_DIG_NOMINAL] = 266667000
Tianyi Gou621f8742011-09-01 21:45:01 -07003705};
3706
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003707static struct bank_masks bmnd_info_mdp = {
3708 .bank_sel_mask = BIT(11),
3709 .bank0_mask = {
3710 .md_reg = MDP_MD0_REG,
3711 .ns_mask = BM(29, 22) | BM(5, 3),
3712 .rst_mask = BIT(31),
3713 .mnd_en_mask = BIT(8),
3714 .mode_mask = BM(10, 9),
3715 },
3716 .bank1_mask = {
3717 .md_reg = MDP_MD1_REG,
3718 .ns_mask = BM(21, 14) | BM(2, 0),
3719 .rst_mask = BIT(30),
3720 .mnd_en_mask = BIT(5),
3721 .mode_mask = BM(7, 6),
3722 },
3723};
3724
3725static struct rcg_clk mdp_clk = {
3726 .b = {
3727 .ctl_reg = MDP_CC_REG,
3728 .en_mask = BIT(0),
3729 .reset_reg = SW_RESET_CORE_REG,
3730 .reset_mask = BIT(21),
3731 .halt_reg = DBG_BUS_VEC_C_REG,
3732 .halt_bit = 10,
3733 },
3734 .ns_reg = MDP_NS_REG,
3735 .root_en_mask = BIT(2),
3736 .set_rate = set_rate_mnd_banked,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003737 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003738 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003739 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003740 .c = {
3741 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003742 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003743 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003744 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003745 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003746 },
3747};
3748
3749static struct branch_clk lut_mdp_clk = {
3750 .b = {
3751 .ctl_reg = MDP_LUT_CC_REG,
3752 .en_mask = BIT(0),
3753 .halt_reg = DBG_BUS_VEC_I_REG,
3754 .halt_bit = 13,
3755 },
3756 .parent = &mdp_clk.c,
3757 .c = {
3758 .dbg_name = "lut_mdp_clk",
3759 .ops = &clk_ops_branch,
3760 CLK_INIT(lut_mdp_clk.c),
3761 },
3762};
3763
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003764#define F_MDP_VSYNC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003765 { \
3766 .freq_hz = f, \
3767 .src_clk = &s##_clk.c, \
3768 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003769 }
3770static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003771 F_MDP_VSYNC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003772 F_END
3773};
3774
3775static struct rcg_clk mdp_vsync_clk = {
3776 .b = {
3777 .ctl_reg = MISC_CC_REG,
3778 .en_mask = BIT(6),
3779 .reset_reg = SW_RESET_CORE_REG,
3780 .reset_mask = BIT(3),
3781 .halt_reg = DBG_BUS_VEC_B_REG,
3782 .halt_bit = 22,
3783 },
3784 .ns_reg = MISC_CC2_REG,
3785 .ns_mask = BIT(13),
3786 .set_rate = set_rate_nop,
3787 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003788 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003789 .c = {
3790 .dbg_name = "mdp_vsync_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003791 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003792 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003793 CLK_INIT(mdp_vsync_clk.c),
3794 },
3795};
3796
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003797#define F_ROT(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003798 { \
3799 .freq_hz = f, \
3800 .src_clk = &s##_clk.c, \
3801 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
3802 21, 19, 18, 16, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003803 }
3804static struct clk_freq_tbl clk_tbl_rot[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003805 F_ROT( 0, gnd, 1),
3806 F_ROT( 27000000, pxo, 1),
3807 F_ROT( 29540000, pll8, 13),
3808 F_ROT( 32000000, pll8, 12),
3809 F_ROT( 38400000, pll8, 10),
3810 F_ROT( 48000000, pll8, 8),
3811 F_ROT( 54860000, pll8, 7),
3812 F_ROT( 64000000, pll8, 6),
3813 F_ROT( 76800000, pll8, 5),
3814 F_ROT( 96000000, pll8, 4),
3815 F_ROT(100000000, pll2, 8),
3816 F_ROT(114290000, pll2, 7),
3817 F_ROT(133330000, pll2, 6),
3818 F_ROT(160000000, pll2, 5),
3819 F_ROT(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003820 F_END
3821};
3822
3823static struct bank_masks bdiv_info_rot = {
3824 .bank_sel_mask = BIT(30),
3825 .bank0_mask = {
3826 .ns_mask = BM(25, 22) | BM(18, 16),
3827 },
3828 .bank1_mask = {
3829 .ns_mask = BM(29, 26) | BM(21, 19),
3830 },
3831};
3832
3833static struct rcg_clk rot_clk = {
3834 .b = {
3835 .ctl_reg = ROT_CC_REG,
3836 .en_mask = BIT(0),
3837 .reset_reg = SW_RESET_CORE_REG,
3838 .reset_mask = BIT(2),
3839 .halt_reg = DBG_BUS_VEC_C_REG,
3840 .halt_bit = 15,
3841 },
3842 .ns_reg = ROT_NS_REG,
3843 .root_en_mask = BIT(2),
3844 .set_rate = set_rate_div_banked,
3845 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003846 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003847 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003848 .c = {
3849 .dbg_name = "rot_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003850 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003851 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003852 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003853 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003854 },
3855};
3856
3857static int hdmi_pll_clk_enable(struct clk *clk)
3858{
3859 int ret;
3860 unsigned long flags;
3861 spin_lock_irqsave(&local_clock_reg_lock, flags);
3862 ret = hdmi_pll_enable();
3863 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3864 return ret;
3865}
3866
3867static void hdmi_pll_clk_disable(struct clk *clk)
3868{
3869 unsigned long flags;
3870 spin_lock_irqsave(&local_clock_reg_lock, flags);
3871 hdmi_pll_disable();
3872 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3873}
3874
3875static unsigned hdmi_pll_clk_get_rate(struct clk *clk)
3876{
3877 return hdmi_pll_get_rate();
3878}
3879
Stephen Boyd5b35dee2011-09-21 12:17:38 -07003880static struct clk *hdmi_pll_clk_get_parent(struct clk *clk)
3881{
3882 return &pxo_clk.c;
3883}
3884
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003885static struct clk_ops clk_ops_hdmi_pll = {
3886 .enable = hdmi_pll_clk_enable,
3887 .disable = hdmi_pll_clk_disable,
3888 .get_rate = hdmi_pll_clk_get_rate,
3889 .is_local = local_clk_is_local,
Stephen Boyd5b35dee2011-09-21 12:17:38 -07003890 .get_parent = hdmi_pll_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003891};
3892
3893static struct clk hdmi_pll_clk = {
3894 .dbg_name = "hdmi_pll_clk",
3895 .ops = &clk_ops_hdmi_pll,
3896 CLK_INIT(hdmi_pll_clk),
3897};
3898
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003899#define F_TV_GND(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003900 { \
3901 .freq_hz = f, \
3902 .src_clk = &s##_clk.c, \
3903 .md_val = MD8(8, m, 0, n), \
3904 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3905 .ctl_val = CC(6, n), \
3906 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003907 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003908#define F_TV(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003909 { \
3910 .freq_hz = f, \
3911 .src_clk = &s##_clk, \
3912 .md_val = MD8(8, m, 0, n), \
3913 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3914 .ctl_val = CC(6, n), \
3915 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003916 .extra_freq_data = (void *)p_r, \
3917 }
3918/* Switching TV freqs requires PLL reconfiguration. */
3919static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003920 F_TV_GND( 0, gnd, 0, 1, 0, 0),
3921 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0),
3922 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0),
3923 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0),
3924 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0),
3925 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003926 F_END
3927};
3928
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003929static unsigned long fmax_tv_src_8064[MAX_VDD_LEVELS] __initdata = {
3930 [VDD_DIG_LOW] = 74250000,
3931 [VDD_DIG_NOMINAL] = 149000000
3932};
3933
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003934/*
3935 * Unlike other clocks, the TV rate is adjusted through PLL
3936 * re-programming. It is also routed through an MND divider.
3937 */
3938void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
3939{
3940 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
3941 if (pll_rate)
3942 hdmi_pll_set_rate(pll_rate);
3943 set_rate_mnd(clk, nf);
3944}
3945
3946static struct rcg_clk tv_src_clk = {
3947 .ns_reg = TV_NS_REG,
3948 .b = {
3949 .ctl_reg = TV_CC_REG,
3950 .halt_check = NOCHECK,
3951 },
3952 .md_reg = TV_MD_REG,
3953 .root_en_mask = BIT(2),
3954 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
3955 .ctl_mask = BM(7, 6),
3956 .set_rate = set_rate_tv,
3957 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003958 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003959 .c = {
3960 .dbg_name = "tv_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003961 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003962 VDD_DIG_FMAX_MAP2(LOW, 27030000, NOMINAL, 149000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003963 CLK_INIT(tv_src_clk.c),
3964 },
3965};
3966
3967static struct branch_clk tv_enc_clk = {
3968 .b = {
3969 .ctl_reg = TV_CC_REG,
3970 .en_mask = BIT(8),
3971 .reset_reg = SW_RESET_CORE_REG,
3972 .reset_mask = BIT(0),
3973 .halt_reg = DBG_BUS_VEC_D_REG,
3974 .halt_bit = 9,
3975 },
3976 .parent = &tv_src_clk.c,
3977 .c = {
3978 .dbg_name = "tv_enc_clk",
3979 .ops = &clk_ops_branch,
3980 CLK_INIT(tv_enc_clk.c),
3981 },
3982};
3983
3984static struct branch_clk tv_dac_clk = {
3985 .b = {
3986 .ctl_reg = TV_CC_REG,
3987 .en_mask = BIT(10),
3988 .halt_reg = DBG_BUS_VEC_D_REG,
3989 .halt_bit = 10,
3990 },
3991 .parent = &tv_src_clk.c,
3992 .c = {
3993 .dbg_name = "tv_dac_clk",
3994 .ops = &clk_ops_branch,
3995 CLK_INIT(tv_dac_clk.c),
3996 },
3997};
3998
3999static struct branch_clk mdp_tv_clk = {
4000 .b = {
4001 .ctl_reg = TV_CC_REG,
4002 .en_mask = BIT(0),
4003 .reset_reg = SW_RESET_CORE_REG,
4004 .reset_mask = BIT(4),
4005 .halt_reg = DBG_BUS_VEC_D_REG,
4006 .halt_bit = 12,
4007 },
4008 .parent = &tv_src_clk.c,
4009 .c = {
4010 .dbg_name = "mdp_tv_clk",
4011 .ops = &clk_ops_branch,
4012 CLK_INIT(mdp_tv_clk.c),
4013 },
4014};
4015
4016static struct branch_clk hdmi_tv_clk = {
4017 .b = {
4018 .ctl_reg = TV_CC_REG,
4019 .en_mask = BIT(12),
4020 .reset_reg = SW_RESET_CORE_REG,
4021 .reset_mask = BIT(1),
4022 .halt_reg = DBG_BUS_VEC_D_REG,
4023 .halt_bit = 11,
4024 },
4025 .parent = &tv_src_clk.c,
4026 .c = {
4027 .dbg_name = "hdmi_tv_clk",
4028 .ops = &clk_ops_branch,
4029 CLK_INIT(hdmi_tv_clk.c),
4030 },
4031};
4032
4033static struct branch_clk hdmi_app_clk = {
4034 .b = {
4035 .ctl_reg = MISC_CC2_REG,
4036 .en_mask = BIT(11),
4037 .reset_reg = SW_RESET_CORE_REG,
4038 .reset_mask = BIT(11),
4039 .halt_reg = DBG_BUS_VEC_B_REG,
4040 .halt_bit = 25,
4041 },
4042 .c = {
4043 .dbg_name = "hdmi_app_clk",
4044 .ops = &clk_ops_branch,
4045 CLK_INIT(hdmi_app_clk.c),
4046 },
4047};
4048
4049static struct bank_masks bmnd_info_vcodec = {
4050 .bank_sel_mask = BIT(13),
4051 .bank0_mask = {
4052 .md_reg = VCODEC_MD0_REG,
4053 .ns_mask = BM(18, 11) | BM(2, 0),
4054 .rst_mask = BIT(31),
4055 .mnd_en_mask = BIT(5),
4056 .mode_mask = BM(7, 6),
4057 },
4058 .bank1_mask = {
4059 .md_reg = VCODEC_MD1_REG,
4060 .ns_mask = BM(26, 19) | BM(29, 27),
4061 .rst_mask = BIT(30),
4062 .mnd_en_mask = BIT(10),
4063 .mode_mask = BM(12, 11),
4064 },
4065};
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004066#define F_VCODEC(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004067 { \
4068 .freq_hz = f, \
4069 .src_clk = &s##_clk.c, \
4070 .md_val = MD8(8, m, 0, n), \
4071 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
4072 .ctl_val = CC_BANKED(6, 11, n), \
4073 .mnd_en_mask = (BIT(10) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004074 }
4075static struct clk_freq_tbl clk_tbl_vcodec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004076 F_VCODEC( 0, gnd, 0, 0),
4077 F_VCODEC( 27000000, pxo, 0, 0),
4078 F_VCODEC( 32000000, pll8, 1, 12),
4079 F_VCODEC( 48000000, pll8, 1, 8),
4080 F_VCODEC( 54860000, pll8, 1, 7),
4081 F_VCODEC( 96000000, pll8, 1, 4),
4082 F_VCODEC(133330000, pll2, 1, 6),
4083 F_VCODEC(200000000, pll2, 1, 4),
4084 F_VCODEC(228570000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004085 F_END
4086};
4087
4088static struct rcg_clk vcodec_clk = {
4089 .b = {
4090 .ctl_reg = VCODEC_CC_REG,
4091 .en_mask = BIT(0),
4092 .reset_reg = SW_RESET_CORE_REG,
4093 .reset_mask = BIT(6),
4094 .halt_reg = DBG_BUS_VEC_C_REG,
4095 .halt_bit = 29,
4096 },
4097 .ns_reg = VCODEC_NS_REG,
4098 .root_en_mask = BIT(2),
4099 .set_rate = set_rate_mnd_banked,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004100 .bank_info = &bmnd_info_vcodec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004101 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004102 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004103 .c = {
4104 .dbg_name = "vcodec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004105 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004106 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
4107 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004108 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004109 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004110 },
4111};
4112
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004113#define F_VPE(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004114 { \
4115 .freq_hz = f, \
4116 .src_clk = &s##_clk.c, \
4117 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004118 }
4119static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004120 F_VPE( 0, gnd, 1),
4121 F_VPE( 27000000, pxo, 1),
4122 F_VPE( 34909000, pll8, 11),
4123 F_VPE( 38400000, pll8, 10),
4124 F_VPE( 64000000, pll8, 6),
4125 F_VPE( 76800000, pll8, 5),
4126 F_VPE( 96000000, pll8, 4),
4127 F_VPE(100000000, pll2, 8),
4128 F_VPE(160000000, pll2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004129 F_END
4130};
4131
4132static struct rcg_clk vpe_clk = {
4133 .b = {
4134 .ctl_reg = VPE_CC_REG,
4135 .en_mask = BIT(0),
4136 .reset_reg = SW_RESET_CORE_REG,
4137 .reset_mask = BIT(17),
4138 .halt_reg = DBG_BUS_VEC_A_REG,
4139 .halt_bit = 28,
4140 },
4141 .ns_reg = VPE_NS_REG,
4142 .root_en_mask = BIT(2),
4143 .ns_mask = (BM(15, 12) | BM(2, 0)),
4144 .set_rate = set_rate_nop,
4145 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004146 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004147 .c = {
4148 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004149 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004150 VDD_DIG_FMAX_MAP2(LOW, 76800000, NOMINAL, 160000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004151 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004152 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004153 },
4154};
4155
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004156#define F_VFE(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004157 { \
4158 .freq_hz = f, \
4159 .src_clk = &s##_clk.c, \
4160 .md_val = MD8(8, m, 0, n), \
4161 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
4162 .ctl_val = CC(6, n), \
4163 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004164 }
Tianyi Gou41515e22011-09-01 19:37:43 -07004165
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004166static struct clk_freq_tbl clk_tbl_vfe[] = {
4167 F_VFE( 0, gnd, 1, 0, 0),
4168 F_VFE( 13960000, pll8, 1, 2, 55),
4169 F_VFE( 27000000, pxo, 1, 0, 0),
4170 F_VFE( 36570000, pll8, 1, 2, 21),
4171 F_VFE( 38400000, pll8, 2, 1, 5),
4172 F_VFE( 45180000, pll8, 1, 2, 17),
4173 F_VFE( 48000000, pll8, 2, 1, 4),
4174 F_VFE( 54860000, pll8, 1, 1, 7),
4175 F_VFE( 64000000, pll8, 2, 1, 3),
4176 F_VFE( 76800000, pll8, 1, 1, 5),
4177 F_VFE( 96000000, pll8, 2, 1, 2),
4178 F_VFE(109710000, pll8, 1, 2, 7),
4179 F_VFE(128000000, pll8, 1, 1, 3),
4180 F_VFE(153600000, pll8, 1, 2, 5),
4181 F_VFE(200000000, pll2, 2, 1, 2),
4182 F_VFE(228570000, pll2, 1, 2, 7),
4183 F_VFE(266667000, pll2, 1, 1, 3),
4184 F_VFE(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004185 F_END
4186};
4187
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004188static unsigned long fmax_vfe_8960_v2[MAX_VDD_LEVELS] __initdata = {
4189 [VDD_DIG_LOW] = 110000000,
4190 [VDD_DIG_NOMINAL] = 266667000,
4191 [VDD_DIG_HIGH] = 320000000
4192};
4193
4194static unsigned long fmax_vfe_8064[MAX_VDD_LEVELS] __initdata = {
4195 [VDD_DIG_LOW] = 128000000,
4196 [VDD_DIG_NOMINAL] = 266667000,
4197 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07004198};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004199
4200static struct rcg_clk vfe_clk = {
4201 .b = {
4202 .ctl_reg = VFE_CC_REG,
4203 .reset_reg = SW_RESET_CORE_REG,
4204 .reset_mask = BIT(15),
4205 .halt_reg = DBG_BUS_VEC_B_REG,
4206 .halt_bit = 6,
4207 .en_mask = BIT(0),
4208 },
4209 .ns_reg = VFE_NS_REG,
4210 .md_reg = VFE_MD_REG,
4211 .root_en_mask = BIT(2),
4212 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
4213 .ctl_mask = BM(7, 6),
4214 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004215 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004216 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004217 .c = {
4218 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004219 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004220 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004221 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004222 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004223 },
4224};
4225
Matt Wagantallc23eee92011-08-16 23:06:52 -07004226static struct branch_clk csi_vfe_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004227 .b = {
4228 .ctl_reg = VFE_CC_REG,
4229 .en_mask = BIT(12),
4230 .reset_reg = SW_RESET_CORE_REG,
4231 .reset_mask = BIT(24),
4232 .halt_reg = DBG_BUS_VEC_B_REG,
4233 .halt_bit = 8,
4234 },
4235 .parent = &vfe_clk.c,
4236 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -07004237 .dbg_name = "csi_vfe_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004238 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -07004239 CLK_INIT(csi_vfe_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004240 },
4241};
4242
4243/*
4244 * Low Power Audio Clocks
4245 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004246#define F_AIF_OSR(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004247 { \
4248 .freq_hz = f, \
4249 .src_clk = &s##_clk.c, \
4250 .md_val = MD8(8, m, 0, n), \
4251 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4252 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004253 }
4254static struct clk_freq_tbl clk_tbl_aif_osr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004255 F_AIF_OSR( 0, gnd, 1, 0, 0),
4256 F_AIF_OSR( 512000, pll4, 4, 1, 192),
4257 F_AIF_OSR( 768000, pll4, 4, 1, 128),
4258 F_AIF_OSR( 1024000, pll4, 4, 1, 96),
4259 F_AIF_OSR( 1536000, pll4, 4, 1, 64),
4260 F_AIF_OSR( 2048000, pll4, 4, 1, 48),
4261 F_AIF_OSR( 3072000, pll4, 4, 1, 32),
4262 F_AIF_OSR( 4096000, pll4, 4, 1, 24),
4263 F_AIF_OSR( 6144000, pll4, 4, 1, 16),
4264 F_AIF_OSR( 8192000, pll4, 4, 1, 12),
4265 F_AIF_OSR(12288000, pll4, 4, 1, 8),
4266 F_AIF_OSR(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004267 F_END
4268};
4269
4270#define CLK_AIF_OSR(i, ns, md, h_r) \
4271 struct rcg_clk i##_clk = { \
4272 .b = { \
4273 .ctl_reg = ns, \
4274 .en_mask = BIT(17), \
4275 .reset_reg = ns, \
4276 .reset_mask = BIT(19), \
4277 .halt_reg = h_r, \
4278 .halt_check = ENABLE, \
4279 .halt_bit = 1, \
4280 }, \
4281 .ns_reg = ns, \
4282 .md_reg = md, \
4283 .root_en_mask = BIT(9), \
4284 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4285 .set_rate = set_rate_mnd, \
4286 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004287 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004288 .c = { \
4289 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004290 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004291 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004292 CLK_INIT(i##_clk.c), \
4293 }, \
4294 }
4295#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
4296 struct rcg_clk i##_clk = { \
4297 .b = { \
4298 .ctl_reg = ns, \
4299 .en_mask = BIT(21), \
4300 .reset_reg = ns, \
4301 .reset_mask = BIT(23), \
4302 .halt_reg = h_r, \
4303 .halt_check = ENABLE, \
4304 .halt_bit = 1, \
4305 }, \
4306 .ns_reg = ns, \
4307 .md_reg = md, \
4308 .root_en_mask = BIT(9), \
4309 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4310 .set_rate = set_rate_mnd, \
4311 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004312 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004313 .c = { \
4314 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004315 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004316 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004317 CLK_INIT(i##_clk.c), \
4318 }, \
4319 }
4320
4321#define F_AIF_BIT(d, s) \
4322 { \
4323 .freq_hz = d, \
4324 .ns_val = (BVAL(14, 14, s) | BVAL(13, 10, (d-1))) \
4325 }
4326static struct clk_freq_tbl clk_tbl_aif_bit[] = {
4327 F_AIF_BIT(0, 1), /* Use external clock. */
4328 F_AIF_BIT(1, 0), F_AIF_BIT(2, 0), F_AIF_BIT(3, 0), F_AIF_BIT(4, 0),
4329 F_AIF_BIT(5, 0), F_AIF_BIT(6, 0), F_AIF_BIT(7, 0), F_AIF_BIT(8, 0),
4330 F_AIF_BIT(9, 0), F_AIF_BIT(10, 0), F_AIF_BIT(11, 0), F_AIF_BIT(12, 0),
4331 F_AIF_BIT(13, 0), F_AIF_BIT(14, 0), F_AIF_BIT(15, 0), F_AIF_BIT(16, 0),
4332 F_END
4333};
4334
4335#define CLK_AIF_BIT(i, ns, h_r) \
4336 struct rcg_clk i##_clk = { \
4337 .b = { \
4338 .ctl_reg = ns, \
4339 .en_mask = BIT(15), \
4340 .halt_reg = h_r, \
4341 .halt_check = DELAY, \
4342 }, \
4343 .ns_reg = ns, \
4344 .ns_mask = BM(14, 10), \
4345 .set_rate = set_rate_nop, \
4346 .freq_tbl = clk_tbl_aif_bit, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004347 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004348 .c = { \
4349 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004350 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004351 CLK_INIT(i##_clk.c), \
4352 }, \
4353 }
4354
4355#define F_AIF_BIT_D(d, s) \
4356 { \
4357 .freq_hz = d, \
4358 .ns_val = (BVAL(18, 18, s) | BVAL(17, 10, (d-1))) \
4359 }
4360static struct clk_freq_tbl clk_tbl_aif_bit_div[] = {
4361 F_AIF_BIT_D(0, 1), /* Use external clock. */
4362 F_AIF_BIT_D(1, 0), F_AIF_BIT_D(2, 0), F_AIF_BIT_D(3, 0),
4363 F_AIF_BIT_D(4, 0), F_AIF_BIT_D(5, 0), F_AIF_BIT_D(6, 0),
4364 F_AIF_BIT_D(7, 0), F_AIF_BIT_D(8, 0), F_AIF_BIT_D(9, 0),
4365 F_AIF_BIT_D(10, 0), F_AIF_BIT_D(11, 0), F_AIF_BIT_D(12, 0),
4366 F_AIF_BIT_D(13, 0), F_AIF_BIT_D(14, 0), F_AIF_BIT_D(15, 0),
4367 F_AIF_BIT_D(16, 0),
4368 F_END
4369};
4370
4371#define CLK_AIF_BIT_DIV(i, ns, h_r) \
4372 struct rcg_clk i##_clk = { \
4373 .b = { \
4374 .ctl_reg = ns, \
4375 .en_mask = BIT(19), \
4376 .halt_reg = h_r, \
4377 .halt_check = ENABLE, \
4378 }, \
4379 .ns_reg = ns, \
4380 .ns_mask = BM(18, 10), \
4381 .set_rate = set_rate_nop, \
4382 .freq_tbl = clk_tbl_aif_bit_div, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004383 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004384 .c = { \
4385 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004386 .ops = &clk_ops_rcg_8960, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004387 CLK_INIT(i##_clk.c), \
4388 }, \
4389 }
4390
4391static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
4392 LCC_MI2S_STATUS_REG);
4393static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
4394
4395static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
4396 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
4397static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
4398 LCC_CODEC_I2S_MIC_STATUS_REG);
4399
4400static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
4401 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
4402static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
4403 LCC_SPARE_I2S_MIC_STATUS_REG);
4404
4405static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
4406 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
4407static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
4408 LCC_CODEC_I2S_SPKR_STATUS_REG);
4409
4410static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
4411 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
4412static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
4413 LCC_SPARE_I2S_SPKR_STATUS_REG);
4414
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004415#define F_PCM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004416 { \
4417 .freq_hz = f, \
4418 .src_clk = &s##_clk.c, \
4419 .md_val = MD16(m, n), \
4420 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4421 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004422 }
4423static struct clk_freq_tbl clk_tbl_pcm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004424 F_PCM( 0, gnd, 1, 0, 0),
4425 F_PCM( 512000, pll4, 4, 1, 192),
4426 F_PCM( 768000, pll4, 4, 1, 128),
4427 F_PCM( 1024000, pll4, 4, 1, 96),
4428 F_PCM( 1536000, pll4, 4, 1, 64),
4429 F_PCM( 2048000, pll4, 4, 1, 48),
4430 F_PCM( 3072000, pll4, 4, 1, 32),
4431 F_PCM( 4096000, pll4, 4, 1, 24),
4432 F_PCM( 6144000, pll4, 4, 1, 16),
4433 F_PCM( 8192000, pll4, 4, 1, 12),
4434 F_PCM(12288000, pll4, 4, 1, 8),
4435 F_PCM(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004436 F_END
4437};
4438
4439static struct rcg_clk pcm_clk = {
4440 .b = {
4441 .ctl_reg = LCC_PCM_NS_REG,
4442 .en_mask = BIT(11),
4443 .reset_reg = LCC_PCM_NS_REG,
4444 .reset_mask = BIT(13),
4445 .halt_reg = LCC_PCM_STATUS_REG,
4446 .halt_check = ENABLE,
4447 .halt_bit = 0,
4448 },
4449 .ns_reg = LCC_PCM_NS_REG,
4450 .md_reg = LCC_PCM_MD_REG,
4451 .root_en_mask = BIT(9),
4452 .ns_mask = (BM(31, 16) | BM(6, 0)),
4453 .set_rate = set_rate_mnd,
4454 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004455 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004456 .c = {
4457 .dbg_name = "pcm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004458 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004459 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004460 CLK_INIT(pcm_clk.c),
4461 },
4462};
4463
4464static struct rcg_clk audio_slimbus_clk = {
4465 .b = {
4466 .ctl_reg = LCC_SLIMBUS_NS_REG,
4467 .en_mask = BIT(10),
4468 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
4469 .reset_mask = BIT(5),
4470 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4471 .halt_check = ENABLE,
4472 .halt_bit = 0,
4473 },
4474 .ns_reg = LCC_SLIMBUS_NS_REG,
4475 .md_reg = LCC_SLIMBUS_MD_REG,
4476 .root_en_mask = BIT(9),
4477 .ns_mask = (BM(31, 24) | BM(6, 0)),
4478 .set_rate = set_rate_mnd,
4479 .freq_tbl = clk_tbl_aif_osr,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004480 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004481 .c = {
4482 .dbg_name = "audio_slimbus_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004483 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004484 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004485 CLK_INIT(audio_slimbus_clk.c),
4486 },
4487};
4488
4489static struct branch_clk sps_slimbus_clk = {
4490 .b = {
4491 .ctl_reg = LCC_SLIMBUS_NS_REG,
4492 .en_mask = BIT(12),
4493 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4494 .halt_check = ENABLE,
4495 .halt_bit = 1,
4496 },
4497 .parent = &audio_slimbus_clk.c,
4498 .c = {
4499 .dbg_name = "sps_slimbus_clk",
4500 .ops = &clk_ops_branch,
4501 CLK_INIT(sps_slimbus_clk.c),
4502 },
4503};
4504
4505static struct branch_clk slimbus_xo_src_clk = {
4506 .b = {
4507 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
4508 .en_mask = BIT(2),
4509 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004510 .halt_bit = 28,
4511 },
4512 .parent = &sps_slimbus_clk.c,
4513 .c = {
4514 .dbg_name = "slimbus_xo_src_clk",
4515 .ops = &clk_ops_branch,
4516 CLK_INIT(slimbus_xo_src_clk.c),
4517 },
4518};
4519
Matt Wagantall735f01a2011-08-12 12:40:28 -07004520DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
4521DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
4522DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
4523DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
4524DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
4525DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
4526DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
4527DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004528
4529static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
4530static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
4531static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
4532static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
4533static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
4534static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
4535static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
4536static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
4537
4538static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
4539/*
4540 * TODO: replace dummy_clk below with ebi1_clk.c once the
4541 * bus driver starts voting on ebi1 rates.
4542 */
4543static DEFINE_CLK_VOTER(ebi1_adm_clk, &dummy_clk);
4544
4545#ifdef CONFIG_DEBUG_FS
4546struct measure_sel {
4547 u32 test_vector;
4548 struct clk *clk;
4549};
4550
Matt Wagantall8b38f942011-08-02 18:23:18 -07004551static DEFINE_CLK_MEASURE(l2_m_clk);
4552static DEFINE_CLK_MEASURE(krait0_m_clk);
4553static DEFINE_CLK_MEASURE(krait1_m_clk);
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004554static DEFINE_CLK_MEASURE(q6sw_clk);
4555static DEFINE_CLK_MEASURE(q6fw_clk);
4556static DEFINE_CLK_MEASURE(q6_func_clk);
Matt Wagantall8b38f942011-08-02 18:23:18 -07004557
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004558static struct measure_sel measure_mux[] = {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004559 { TEST_PER_LS(0x05), &qdss_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004560 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
4561 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
4562 { TEST_PER_LS(0x13), &sdc1_clk.c },
4563 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
4564 { TEST_PER_LS(0x15), &sdc2_clk.c },
4565 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
4566 { TEST_PER_LS(0x17), &sdc3_clk.c },
4567 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
4568 { TEST_PER_LS(0x19), &sdc4_clk.c },
4569 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
4570 { TEST_PER_LS(0x1B), &sdc5_clk.c },
4571 { TEST_PER_LS(0x25), &dfab_clk.c },
4572 { TEST_PER_LS(0x25), &dfab_a_clk.c },
4573 { TEST_PER_LS(0x26), &pmem_clk.c },
4574 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
4575 { TEST_PER_LS(0x33), &cfpb_clk.c },
4576 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
4577 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
4578 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
4579 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
4580 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
4581 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
4582 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
4583 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
4584 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
4585 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
4586 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
4587 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
4588 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
4589 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
4590 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
4591 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
4592 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
4593 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
4594 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
4595 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
4596 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
4597 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
4598 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
4599 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
4600 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
4601 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
4602 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
4603 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
4604 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
4605 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
4606 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
4607 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
4608 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
4609 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
4610 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
4611 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
4612 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004613 { TEST_PER_LS(0x5E), &pcie_p_clk.c },
4614 { TEST_PER_LS(0x5F), &ce3_p_clk.c },
4615 { TEST_PER_LS(0x60), &ce3_core_clk.c },
4616 { TEST_PER_LS(0x63), &usb_hs3_p_clk.c },
4617 { TEST_PER_LS(0x64), &usb_hs3_xcvr_clk.c },
4618 { TEST_PER_LS(0x65), &usb_hs4_p_clk.c },
4619 { TEST_PER_LS(0x66), &usb_hs4_xcvr_clk.c },
4620 { TEST_PER_LS(0x6B), &sata_phy_ref_clk.c },
4621 { TEST_PER_LS(0x6C), &sata_phy_cfg_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004622 { TEST_PER_LS(0x78), &sfpb_clk.c },
4623 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
4624 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
4625 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
4626 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
4627 { TEST_PER_LS(0x7D), &prng_clk.c },
4628 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
4629 { TEST_PER_LS(0x80), &adm0_p_clk.c },
4630 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
4631 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004632 { TEST_PER_LS(0x86), &usb_hsic_p_clk.c },
4633 { TEST_PER_LS(0x87), &usb_hsic_system_clk.c },
4634 { TEST_PER_LS(0x88), &usb_hsic_xcvr_fs_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004635 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
4636 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
4637 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
4638 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
4639 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
4640 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
4641 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
4642 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
4643 { TEST_PER_LS(0x92), &ce1_p_clk.c },
4644 { TEST_PER_LS(0x94), &tssc_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004645 { TEST_PER_LS(0x9D), &usb_hsic_hsio_cal_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004646 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
4647
4648 { TEST_PER_HS(0x07), &afab_clk.c },
4649 { TEST_PER_HS(0x07), &afab_a_clk.c },
4650 { TEST_PER_HS(0x18), &sfab_clk.c },
4651 { TEST_PER_HS(0x18), &sfab_a_clk.c },
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004652 { TEST_PER_HS(0x26), &q6sw_clk },
4653 { TEST_PER_HS(0x27), &q6fw_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004654 { TEST_PER_HS(0x2A), &adm0_clk.c },
4655 { TEST_PER_HS(0x34), &ebi1_clk.c },
4656 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004657 { TEST_PER_HS(0x48), &qdss_at_clk.c },
4658 { TEST_PER_HS(0x49), &qdss_pclkdbg_clk.c },
4659 { TEST_PER_HS(0x4A), &qdss_traceclkin_clk.c },
4660 { TEST_PER_HS(0x4B), &qdss_tsctr_clk.c },
4661 { TEST_PER_HS(0x4F), &qdss_stm_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004662 { TEST_PER_HS(0x50), &usb_hsic_hsic_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004663
4664 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
4665 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
4666 { TEST_MM_LS(0x02), &cam1_clk.c },
4667 { TEST_MM_LS(0x06), &amp_p_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004668 { TEST_MM_LS(0x07), &csi_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004669 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
4670 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
4671 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
4672 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
4673 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
4674 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
4675 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
4676 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
4677 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
4678 { TEST_MM_LS(0x12), &imem_p_clk.c },
4679 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
4680 { TEST_MM_LS(0x14), &mdp_p_clk.c },
4681 { TEST_MM_LS(0x16), &rot_p_clk.c },
4682 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
4683 { TEST_MM_LS(0x18), &smmu_p_clk.c },
4684 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
4685 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
4686 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
4687 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
4688 { TEST_MM_LS(0x1D), &cam0_clk.c },
4689 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
4690 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
4691 { TEST_MM_LS(0x21), &tv_dac_clk.c },
4692 { TEST_MM_LS(0x22), &tv_enc_clk.c },
4693 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
4694 { TEST_MM_LS(0x25), &mmfpb_clk.c },
4695 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
4696 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004697 { TEST_MM_LS(0x27), &cam2_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004698 { TEST_MM_LS(0x28), &vcap_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004699
4700 { TEST_MM_HS(0x00), &csi0_clk.c },
4701 { TEST_MM_HS(0x01), &csi1_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004702 { TEST_MM_HS(0x04), &csi_vfe_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004703 { TEST_MM_HS(0x05), &ijpeg_clk.c },
4704 { TEST_MM_HS(0x06), &vfe_clk.c },
4705 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
4706 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
4707 { TEST_MM_HS(0x09), &gfx3d_clk.c },
4708 { TEST_MM_HS(0x0A), &jpegd_clk.c },
4709 { TEST_MM_HS(0x0B), &vcodec_clk.c },
4710 { TEST_MM_HS(0x0F), &mmfab_clk.c },
4711 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
4712 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
4713 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
4714 { TEST_MM_HS(0x13), &imem_axi_clk.c },
4715 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
4716 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
4717 { TEST_MM_HS(0x16), &rot_axi_clk.c },
4718 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
4719 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
4720 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
4721 { TEST_MM_HS(0x1A), &mdp_clk.c },
4722 { TEST_MM_HS(0x1B), &rot_clk.c },
4723 { TEST_MM_HS(0x1C), &vpe_clk.c },
4724 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
4725 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
4726 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
4727 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
4728 { TEST_MM_HS(0x26), &csi_pix_clk.c },
4729 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
4730 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
4731 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
4732 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
4733 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
4734 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004735 { TEST_MM_HS(0x2D), &csi2_clk.c },
4736 { TEST_MM_HS(0x2E), &csi2_phy_clk.c },
4737 { TEST_MM_HS(0x2F), &csi2phy_timer_clk.c },
4738 { TEST_MM_HS(0x30), &csi_pix1_clk.c },
4739 { TEST_MM_HS(0x31), &csi_rdi1_clk.c },
4740 { TEST_MM_HS(0x32), &csi_rdi2_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004741 { TEST_MM_HS(0x33), &vcap_clk.c },
4742 { TEST_MM_HS(0x34), &vcap_npl_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004743 { TEST_MM_HS(0x36), &vcap_axi_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004744 { TEST_MM_HS(0x39), &gfx3d_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004745
4746 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
4747 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
4748 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
4749 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
4750 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
4751 { TEST_LPA(0x14), &pcm_clk.c },
4752 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
Matt Wagantall8b38f942011-08-02 18:23:18 -07004753
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004754 { TEST_LPA_HS(0x00), &q6_func_clk },
4755
Matt Wagantall8b38f942011-08-02 18:23:18 -07004756 { TEST_CPUL2(0x1), &l2_m_clk },
4757 { TEST_CPUL2(0x2), &krait0_m_clk },
4758 { TEST_CPUL2(0x3), &krait1_m_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004759};
4760
4761static struct measure_sel *find_measure_sel(struct clk *clk)
4762{
4763 int i;
4764
4765 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
4766 if (measure_mux[i].clk == clk)
4767 return &measure_mux[i];
4768 return NULL;
4769}
4770
Matt Wagantall8b38f942011-08-02 18:23:18 -07004771static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004772{
4773 int ret = 0;
4774 u32 clk_sel;
4775 struct measure_sel *p;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004776 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004777 unsigned long flags;
4778
4779 if (!parent)
4780 return -EINVAL;
4781
4782 p = find_measure_sel(parent);
4783 if (!p)
4784 return -EINVAL;
4785
4786 spin_lock_irqsave(&local_clock_reg_lock, flags);
4787
Matt Wagantall8b38f942011-08-02 18:23:18 -07004788 /*
4789 * Program the test vector, measurement period (sample_ticks)
4790 * and scaling multiplier.
4791 */
4792 clk->sample_ticks = 0x10000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004793 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004794 clk->multiplier = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004795 switch (p->test_vector >> TEST_TYPE_SHIFT) {
4796 case TEST_TYPE_PER_LS:
4797 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
4798 break;
4799 case TEST_TYPE_PER_HS:
4800 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
4801 break;
4802 case TEST_TYPE_MM_LS:
4803 writel_relaxed(0x4030D97, CLK_TEST_REG);
4804 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
4805 break;
4806 case TEST_TYPE_MM_HS:
4807 writel_relaxed(0x402B800, CLK_TEST_REG);
4808 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
4809 break;
4810 case TEST_TYPE_LPA:
4811 writel_relaxed(0x4030D98, CLK_TEST_REG);
4812 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
4813 LCC_CLK_LS_DEBUG_CFG_REG);
4814 break;
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004815 case TEST_TYPE_LPA_HS:
4816 writel_relaxed(0x402BC00, CLK_TEST_REG);
4817 writel_relaxed(BVAL(2, 1, clk_sel)|BIT(0),
4818 LCC_CLK_HS_DEBUG_CFG_REG);
4819 break;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004820 case TEST_TYPE_CPUL2:
4821 writel_relaxed(0x4030400, CLK_TEST_REG);
4822 writel_relaxed(0x80|BVAL(5, 3, clk_sel), GCC_APCS_CLK_DIAG);
4823 clk->sample_ticks = 0x4000;
4824 clk->multiplier = 2;
4825 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004826 default:
4827 ret = -EPERM;
4828 }
4829 /* Make sure test vector is set before starting measurements. */
4830 mb();
4831
4832 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4833
4834 return ret;
4835}
4836
4837/* Sample clock for 'ticks' reference clock ticks. */
4838static u32 run_measurement(unsigned ticks)
4839{
4840 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004841 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
4842
4843 /* Wait for timer to become ready. */
4844 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
4845 cpu_relax();
4846
4847 /* Run measurement and wait for completion. */
4848 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
4849 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
4850 cpu_relax();
4851
4852 /* Stop counters. */
4853 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
4854
4855 /* Return measured ticks. */
4856 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
4857}
4858
4859
4860/* Perform a hardware rate measurement for a given clock.
4861 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall8b38f942011-08-02 18:23:18 -07004862static unsigned measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004863{
4864 unsigned long flags;
4865 u32 pdm_reg_backup, ringosc_reg_backup;
4866 u64 raw_count_short, raw_count_full;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004867 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004868 unsigned ret;
4869
4870 spin_lock_irqsave(&local_clock_reg_lock, flags);
4871
4872 /* Enable CXO/4 and RINGOSC branch and root. */
4873 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
4874 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
4875 writel_relaxed(0x2898, PDM_CLK_NS_REG);
4876 writel_relaxed(0xA00, RINGOSC_NS_REG);
4877
4878 /*
4879 * The ring oscillator counter will not reset if the measured clock
4880 * is not running. To detect this, run a short measurement before
4881 * the full measurement. If the raw results of the two are the same
4882 * then the clock must be off.
4883 */
4884
4885 /* Run a short measurement. (~1 ms) */
4886 raw_count_short = run_measurement(0x1000);
4887 /* Run a full measurement. (~14 ms) */
Matt Wagantall8b38f942011-08-02 18:23:18 -07004888 raw_count_full = run_measurement(clk->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004889
4890 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
4891 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
4892
4893 /* Return 0 if the clock is off. */
4894 if (raw_count_full == raw_count_short)
4895 ret = 0;
4896 else {
4897 /* Compute rate in Hz. */
4898 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004899 do_div(raw_count_full, ((clk->sample_ticks * 10) + 35));
4900 ret = (raw_count_full * clk->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004901 }
4902
4903 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07004904 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004905 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4906
4907 return ret;
4908}
4909#else /* !CONFIG_DEBUG_FS */
4910static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
4911{
4912 return -EINVAL;
4913}
4914
4915static unsigned measure_clk_get_rate(struct clk *clk)
4916{
4917 return 0;
4918}
4919#endif /* CONFIG_DEBUG_FS */
4920
4921static struct clk_ops measure_clk_ops = {
4922 .set_parent = measure_clk_set_parent,
4923 .get_rate = measure_clk_get_rate,
4924 .is_local = local_clk_is_local,
4925};
4926
Matt Wagantall8b38f942011-08-02 18:23:18 -07004927static struct measure_clk measure_clk = {
4928 .c = {
4929 .dbg_name = "measure_clk",
4930 .ops = &measure_clk_ops,
4931 CLK_INIT(measure_clk.c),
4932 },
4933 .multiplier = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004934};
4935
Tianyi Gou41515e22011-09-01 19:37:43 -07004936static struct clk_lookup msm_clocks_8064[] __initdata = {
4937 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07004938 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004939 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
Tianyi Gouc29c3242011-10-12 21:02:15 -07004940 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004941 CLK_LOOKUP("measure", measure_clk.c, "debug"),
4942
4943 CLK_DUMMY("afab_clk", AFAB_CLK, NULL, 0),
4944 CLK_DUMMY("afab_a_clk", AFAB_A_CLK, NULL, 0),
4945 CLK_DUMMY("cfpb_clk", CFPB_CLK, NULL, 0),
4946 CLK_DUMMY("cfpb_a_clk", CFPB_A_CLK, NULL, 0),
4947 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
4948 CLK_DUMMY("dfab_a_clk", DFAB_A_CLK, NULL, 0),
4949 CLK_DUMMY("ebi1_clk", EBI1_CLK, NULL, 0),
4950 CLK_DUMMY("ebi1_a_clk", EBI1_A_CLK, NULL, 0),
4951 CLK_DUMMY("mmfab_clk", MMFAB_CLK, NULL, 0),
4952 CLK_DUMMY("mmfab_a_clk", MMFAB_A_CLK, NULL, 0),
4953 CLK_DUMMY("mmfpb_clk", MMFPB_CLK, NULL, 0),
4954 CLK_DUMMY("mmfpb_a_clk", MMFPB_A_CLK, NULL, 0),
4955 CLK_DUMMY("sfab_clk", SFAB_CLK, NULL, 0),
4956 CLK_DUMMY("sfab_a_clk", SFAB_A_CLK, NULL, 0),
4957 CLK_DUMMY("sfpb_clk", SFPB_CLK, NULL, 0),
4958 CLK_DUMMY("sfpb_a_clk", SFPB_A_CLK, NULL, 0),
4959
4960 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
4961 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
4962 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
4963 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
4964 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, NULL),
4965 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, NULL),
4966 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
4967 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, NULL),
4968 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
4969 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, NULL),
4970 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, NULL),
4971 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
4972 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
4973 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07004974 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004975 CLK_LOOKUP("pmem_clk", pmem_clk.c, NULL),
4976 CLK_DUMMY("core_clk", PRNG_CLK, NULL, OFF),
Tianyi Gou43208a02011-09-27 15:35:13 -07004977 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
4978 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
4979 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
4980 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07004981 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
4982 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07004983 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004984 CLK_LOOKUP("core_clk", usb_hs3_xcvr_clk.c, NULL),
4985 CLK_LOOKUP("core_clk", usb_hs4_xcvr_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07004986 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
4987 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
4988 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07004989 CLK_LOOKUP("iface_clk", ce1_p_clk.c, NULL),
4990 CLK_LOOKUP("core_clk", ce1_core_clk.c, NULL),
4991 CLK_LOOKUP("ref_clk", sata_phy_ref_clk.c, NULL),
4992 CLK_LOOKUP("cfg_clk", sata_phy_cfg_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07004993 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
4994 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, NULL),
4995 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
4996 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, NULL),
4997 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, NULL),
4998 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, NULL),
4999 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, NULL),
5000 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005001 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005002 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5003 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005004 CLK_LOOKUP("iface_clk", usb_hs3_p_clk.c, NULL),
5005 CLK_LOOKUP("iface_clk", usb_hs4_p_clk.c, NULL),
Tianyi Gou43208a02011-09-27 15:35:13 -07005006 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5007 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5008 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5009 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005010 CLK_LOOKUP("iface_clk", pcie_p_clk.c, NULL),
5011 CLK_LOOKUP("core_src_clk", ce3_src_clk.c, NULL),
5012 CLK_LOOKUP("core_clk", ce3_core_clk.c, NULL),
5013 CLK_LOOKUP("iface_clk", ce3_p_clk.c, NULL),
5014 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5015 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005016 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
5017 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
5018 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
5019 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
5020 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005021 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5022 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
5023 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5024 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5025 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005026 CLK_DUMMY("csi_src_clk", CSI0_SRC_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005027 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5028 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5029 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005030 CLK_DUMMY("csi_clk", CSI0_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005031 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5032 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5033 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
5034 CLK_DUMMY("csi_phy_clk", CSI0_PHY_CLK, NULL, OFF),
5035 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5036 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5037 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005038 CLK_DUMMY("csi_pix_clk", CSI_PIX_CLK, NULL, OFF),
5039 CLK_DUMMY("csi_rdi_clk", CSI_RDI_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005040 CLK_DUMMY("csi_pix_clk", CSI_PIX1_CLK, NULL, OFF),
5041 CLK_DUMMY("csi_rdi_clk", CSI_RDI1_CLK, NULL, OFF),
5042 CLK_DUMMY("csi_rdi_clk", CSI_RDI2_CLK, NULL, OFF),
5043 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
5044 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, NULL),
5045 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, NULL),
5046 CLK_LOOKUP("csiphy_timer_clk", csi2phy_timer_clk.c, NULL),
5047 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5048 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5049 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5050 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
5051 CLK_DUMMY("rgb_tv_clk", RGB_TV_CLK, NULL, OFF),
5052 CLK_DUMMY("npl_tv_clk", NPL_TV_CLK, NULL, OFF),
5053 CLK_LOOKUP("core_clk", gfx3d_clk.c, NULL),
5054 CLK_LOOKUP("iface_clk", vcap_p_clk.c, NULL),
5055 CLK_LOOKUP("bus_clk", vcap_axi_clk.c, NULL),
5056 CLK_LOOKUP("core_clk", vcap_clk.c, NULL),
5057 CLK_LOOKUP("vcap_npl_clk", vcap_npl_clk.c, NULL),
5058 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, NULL),
5059 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
5060 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005061 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005062 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
5063 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
5064 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
5065 CLK_LOOKUP("rot_clk", rot_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005066 CLK_DUMMY("tv_src_clk", TV_SRC_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005067 CLK_LOOKUP("core_clk", vcodec_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005068 CLK_DUMMY("mdp_tv_clk", MDP_TV_CLK, NULL, OFF),
5069 CLK_DUMMY("hdmi_clk", HDMI_TV_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005070 CLK_LOOKUP("core_clk", hdmi_app_clk.c, NULL),
5071 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
5072 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
5073 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, NULL),
5074 CLK_LOOKUP("vfe_axi_clk", vfe_axi_clk.c, NULL),
5075 CLK_LOOKUP("mdp_axi_clk", mdp_axi_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005076 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, NULL),
5077 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, NULL),
5078 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, NULL),
5079 CLK_LOOKUP("vpe_axi_clk", vpe_axi_clk.c, NULL),
5080 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
5081 CLK_LOOKUP("csi_pclk", csi_p_clk.c, NULL),
5082 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5083 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5084 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5085 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
5086 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, NULL),
5087 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, NULL),
5088 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, NULL),
5089 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005090 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
5091 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005092 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
5093 CLK_LOOKUP("iface_clk", smmu_p_clk.c, NULL),
5094 CLK_LOOKUP("rotator_pclk", rot_p_clk.c, NULL),
5095 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, NULL),
5096 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
5097 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Tianyi Gouc29c3242011-10-12 21:02:15 -07005098 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5099 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5100 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5101 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5102 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5103 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5104 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5105 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5106 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5107 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5108 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
Tianyi Goudd8138a2011-10-20 15:46:00 -07005109 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5110 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005111 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, NULL),
5112 CLK_LOOKUP("core_clk", vpe_axi_clk.c, NULL),
5113 CLK_LOOKUP("core_clk", mdp_axi_clk.c, NULL),
5114 CLK_LOOKUP("core_clk", vcap_axi_clk.c, NULL),
5115 CLK_LOOKUP("core_clk", rot_axi_clk.c, NULL),
5116 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, NULL),
5117 CLK_LOOKUP("core_clk", vfe_axi_clk.c, NULL),
5118 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, NULL),
5119 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, NULL),
5120 CLK_DUMMY("core_clk", GFX3D_AXI_CLK, NULL, 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005121 CLK_DUMMY("dfab_dsps_clk", DFAB_DSPS_CLK, NULL, 0),
5122 CLK_DUMMY("dfab_usb_hs_clk", DFAB_USB_HS_CLK, NULL, 0),
5123 CLK_DUMMY("bus_clk", DFAB_SDC1_CLK, NULL, 0),
5124 CLK_DUMMY("bus_clk", DFAB_SDC2_CLK, NULL, 0),
5125 CLK_DUMMY("bus_clk", DFAB_SDC3_CLK, NULL, 0),
5126 CLK_DUMMY("bus_clk", DFAB_SDC4_CLK, NULL, 0),
5127 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
5128 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5129 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5130 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5131 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5132 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5133
5134 CLK_LOOKUP("ebi1_msmbus_clk", ebi1_msmbus_clk.c, NULL),
5135 CLK_LOOKUP("ebi1_clk", ebi1_adm_clk.c, "msm_dmov"),
5136
5137 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5138 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5139 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
5140};
5141
Stephen Boyd94625ef2011-07-12 17:06:01 -07005142static struct clk_lookup msm_clocks_8960_v1[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005143 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
5144 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
5145 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
5146 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005147 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005148
5149 CLK_LOOKUP("afab_clk", afab_clk.c, NULL),
5150 CLK_LOOKUP("afab_a_clk", afab_a_clk.c, NULL),
5151 CLK_LOOKUP("cfpb_clk", cfpb_clk.c, NULL),
5152 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, NULL),
Stephen Boyd85436132011-09-16 18:55:13 -07005153 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005154 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
5155 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
5156 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
5157 CLK_LOOKUP("ebi1_a_clk", ebi1_a_clk.c, NULL),
5158 CLK_LOOKUP("mmfab_clk", mmfab_clk.c, NULL),
5159 CLK_LOOKUP("mmfab_a_clk", mmfab_a_clk.c, NULL),
5160 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
5161 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, NULL),
Stephen Boyda3787f32011-09-16 18:55:13 -07005162 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005163 CLK_LOOKUP("sfab_clk", sfab_clk.c, NULL),
5164 CLK_LOOKUP("sfab_a_clk", sfab_a_clk.c, NULL),
5165 CLK_LOOKUP("sfpb_clk", sfpb_clk.c, NULL),
5166 CLK_LOOKUP("sfpb_a_clk", sfpb_a_clk.c, NULL),
5167
Matt Wagantalle2522372011-08-17 14:52:21 -07005168 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
5169 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
5170 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
5171 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
5172 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
5173 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
5174 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
5175 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, NULL),
5176 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, NULL),
5177 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, NULL),
5178 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, NULL),
5179 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005180 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005181 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005182 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
5183 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005184 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
5185 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
5186 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
5187 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, NULL),
5188 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005189 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005190 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005191 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005192 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Vikram Mulukutladd0a2372011-09-19 15:58:21 -07005193 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_sps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07005194 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005195 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5196 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5197 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5198 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
5199 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005200 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005201 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005202 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005203 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
5204 CLK_LOOKUP("usb_phy_clk", usb_phy0_clk.c, NULL),
5205 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
5206 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
5207 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
5208 CLK_LOOKUP("usb_fs_clk", usb_fs2_xcvr_clk.c, NULL),
5209 CLK_LOOKUP("usb_fs_sys_clk", usb_fs2_sys_clk.c, NULL),
5210 CLK_LOOKUP("usb_fs_src_clk", usb_fs2_src_clk.c, NULL),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005211 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005212 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qcrypto.0"),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005213 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005214 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qcrypto.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005215 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005216 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005217 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005218 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
5219 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07005220 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
5221 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005222 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
5223 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, NULL),
5224 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005225 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005226 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005227 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.12"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005228 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005229 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5230 CLK_LOOKUP("usb_fs_pclk", usb_fs2_p_clk.c, NULL),
5231 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005232 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5233 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5234 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5235 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
5236 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005237 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5238 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005239 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
5240 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
5241 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
5242 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
5243 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005244 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5245 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
5246 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_imx074.0"),
5247 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_ov2720.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07005248 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005249 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, NULL),
5250 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5251 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07005252 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005253 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_camera_ov2720.0"),
5254 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
5255 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5256 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07005257 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005258 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov2720.0"),
5259 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, NULL),
5260 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5261 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_camera_imx074.0"),
Kevin Chandfecce22011-07-13 10:52:41 -07005262 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_camera_qs_mt9p017.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005263 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_camera_ov2720.0"),
5264 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, NULL),
5265 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, NULL),
5266 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
5267 CLK_LOOKUP("csi0phy_timer_clk", csi0phy_timer_clk.c, NULL),
5268 CLK_LOOKUP("csi1phy_timer_clk", csi1phy_timer_clk.c, NULL),
5269 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5270 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5271 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5272 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005273 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005274 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005275 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005276 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005277 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005278 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5279 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005280 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005281 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005282 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005283 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005284 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005285 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005286 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
5287 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07005288 CLK_LOOKUP("qdss_pclk", qdss_p_clk.c, NULL),
5289 CLK_LOOKUP("qdss_at_clk", qdss_at_clk.c, NULL),
5290 CLK_LOOKUP("qdss_pclkdbg_clk", qdss_pclkdbg_clk.c, NULL),
5291 CLK_LOOKUP("qdss_traceclkin_clk", qdss_traceclkin_clk.c, NULL),
5292 CLK_LOOKUP("qdss_tsctr_clk", qdss_tsctr_clk.c, NULL),
5293 CLK_LOOKUP("qdss_stm_clk", qdss_stm_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005294 CLK_LOOKUP("rot_clk", rot_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005295 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005296 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
5297 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
5298 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005299 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005300 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005301 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
5302 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005303 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005304 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005305 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005306 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005307 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Matt Wagantallc23eee92011-08-16 23:06:52 -07005308 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005309 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5310 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5311 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5312 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5313 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5314 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5315 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005316 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Matt Wagantallc23eee92011-08-16 23:06:52 -07005317 CLK_LOOKUP("csi_pclk", csi_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005318 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5319 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5320 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5321 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005322 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005323 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005324 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005325 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005326 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005327 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005328 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
5329 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005330 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005331 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005332 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005333 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005334 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005335 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07005336 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005337 CLK_LOOKUP("rotator_pclk", rot_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005338 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005339 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005340 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005341 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005342 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005343 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005344 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005345 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005346 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5347 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5348 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5349 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5350 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5351 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5352 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5353 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5354 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5355 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5356 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
5357 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5358 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Matt Wagantalle604d712011-10-21 15:38:18 -07005359 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
5360 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
5361 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
5362 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
5363 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
5364 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
5365 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
5366 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
5367 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
5368 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
5369 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
5370 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005371 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
5372 CLK_LOOKUP("dfab_usb_hs_clk", dfab_usb_hs_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005373 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
5374 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
5375 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
5376 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
5377 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Yan He160633e2011-06-30 12:18:56 -07005378 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005379
5380 CLK_LOOKUP("ebi1_msmbus_clk", ebi1_msmbus_clk.c, NULL),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005381 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005382
5383 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5384 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5385 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
Stephen Boyd3939c8d2011-08-29 17:36:22 -07005386 CLK_LOOKUP("q6sw_clk", q6sw_clk, NULL),
5387 CLK_LOOKUP("q6fw_clk", q6fw_clk, NULL),
5388 CLK_LOOKUP("q6_func_clk", q6_func_clk, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005389};
5390
Stephen Boyd94625ef2011-07-12 17:06:01 -07005391static struct clk_lookup msm_clocks_8960_v2[] __initdata = {
5392 CLK_LOOKUP("cam_clk", cam2_clk.c, NULL),
5393 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
5394 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
5395 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, NULL),
5396 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, NULL),
5397 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, NULL),
5398 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
5399 CLK_LOOKUP("csi2phy_timer_clk", csi2phy_timer_clk.c, NULL),
5400 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5401 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5402 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5403 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5404 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5405};
5406
5407/* Add v2 clocks dynamically at runtime */
5408static struct clk_lookup msm_clocks_8960[ARRAY_SIZE(msm_clocks_8960_v1) +
5409 ARRAY_SIZE(msm_clocks_8960_v2)];
5410
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005411/*
5412 * Miscellaneous clock register initializations
5413 */
5414
5415/* Read, modify, then write-back a register. */
5416static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
5417{
5418 uint32_t regval = readl_relaxed(reg);
5419 regval &= ~mask;
5420 regval |= val;
5421 writel_relaxed(regval, reg);
5422}
5423
Tianyi Gou41515e22011-09-01 19:37:43 -07005424static void __init set_fsm_mode(void __iomem *mode_reg)
5425{
5426 u32 regval = readl_relaxed(mode_reg);
5427
5428 /*De-assert reset to FSM */
5429 regval &= ~BIT(21);
5430 writel_relaxed(regval, mode_reg);
5431
5432 /* Program bias count */
Tianyi Gou358c3862011-10-18 17:03:41 -07005433 regval &= ~BM(19, 14);
5434 regval |= BVAL(19, 14, 0x1);
5435 writel_relaxed(regval, mode_reg);
5436
5437 /* Program lock count */
Tianyi Gou41515e22011-09-01 19:37:43 -07005438 regval &= ~BM(13, 8);
5439 regval |= BVAL(13, 8, 0x8);
5440 writel_relaxed(regval, mode_reg);
5441
5442 /*Enable PLL FSM voting */
5443 regval |= BIT(20);
5444 writel_relaxed(regval, mode_reg);
5445}
5446
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005447static void __init reg_init(void)
5448{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005449 /* Deassert MM SW_RESET_ALL signal. */
5450 writel_relaxed(0, SW_RESET_ALL_REG);
5451
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005452 /*
5453 * Some bits are only used on either 8960 or 8064 and are marked as
5454 * reserved bits on the other SoC. Writing to these reserved bits
5455 * should have no effect.
5456 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005457 /* Initialize MM AHB registers: Enable the FPB clock and disable HW
5458 * gating for all clocks. Also set VFE_AHB's FORCE_CORE_ON bit to
5459 * prevent its memory from being collapsed when the clock is halted.
5460 * The sleep and wake-up delays are set to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005461 rmwreg(0x00000003, AHB_EN_REG, 0x6C000103);
5462 writel_relaxed(0x000007F9, AHB_EN2_REG);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005463 if (cpu_is_apq8064())
5464 rmwreg(0x00000000, AHB_EN3_REG, 0x00000001);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005465
5466 /* Deassert all locally-owned MM AHB resets. */
5467 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
Tianyi Gou41515e22011-09-01 19:37:43 -07005468 rmwreg(0, SW_RESET_AHB2_REG, 0x0000000F);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005469
5470 /* Initialize MM AXI registers: Enable HW gating for all clocks that
5471 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
5472 * delays to safe values. */
5473 /* TODO: Enable HW Gating */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005474 rmwreg(0x000007F9, MAXI_EN_REG, 0x0803FFFF);
5475 rmwreg(0x3027FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
5476 rmwreg(0x0027FCFF, MAXI_EN3_REG, 0x003FFFFF);
5477 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005478 if (cpu_is_apq8064())
5479 rmwreg(0x009FE4FF, MAXI_EN5_REG, 0x01FFEFFF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005480 rmwreg(0x000003C7, SAXI_EN_REG, 0x00003FFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005481
5482 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
5483 * memories retain state even when not clocked. Also, set sleep and
5484 * wake-up delays to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005485 rmwreg(0x00000000, CSI0_CC_REG, 0x00000410);
5486 rmwreg(0x00000000, CSI1_CC_REG, 0x00000410);
5487 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, 0xE0FF0010);
5488 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, 0xE0FF0010);
5489 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, 0xE0FF0010);
5490 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005491 rmwreg(0x80FF0000, GFX3D_CC_REG, 0xE0FF0010);
5492 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0010);
5493 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0010);
5494 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
5495 rmwreg(0x80FF0000, MDP_LUT_CC_REG, 0xE0FF0010);
5496 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005497 rmwreg(0x000004FF, TV_CC2_REG, 0x000007FF);
5498 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
5499 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FF4010);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005500 rmwreg(0x800000FF, VFE_CC2_REG, 0xE00000FF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005501 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005502 if (cpu_is_msm8960()) {
5503 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
5504 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
5505 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
5506 }
5507 if (cpu_is_apq8064()) {
5508 rmwreg(0x00000000, TV_CC_REG, 0x00004010);
Tianyi Gou621f8742011-09-01 21:45:01 -07005509 rmwreg(0x80FF0000, VCAP_CC_REG, 0xE0FF1010);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005510 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005511
Tianyi Gou41515e22011-09-01 19:37:43 -07005512 /*
5513 * Initialize USB_HS_HCLK_FS registers: Set FORCE_C_ON bits so that
5514 * core remain active during halt state of the clk. Also, set sleep
5515 * and wake-up value to max.
5516 */
5517 rmwreg(0x0000004F, USB_HS1_HCLK_FS_REG, 0x0000007F);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005518 if (cpu_is_apq8064()) {
5519 rmwreg(0x0000004F, USB_HS3_HCLK_FS_REG, 0x0000007F);
5520 rmwreg(0x0000004F, USB_HS4_HCLK_FS_REG, 0x0000007F);
5521 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005522
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005523 /* De-assert MM AXI resets to all hardware blocks. */
5524 writel_relaxed(0, SW_RESET_AXI_REG);
5525
5526 /* Deassert all MM core resets. */
5527 writel_relaxed(0, SW_RESET_CORE_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005528 writel_relaxed(0, SW_RESET_CORE2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005529
5530 /* Reset 3D core once more, with its clock enabled. This can
5531 * eventually be done as part of the GDFS footswitch driver. */
5532 clk_set_rate(&gfx3d_clk.c, 27000000);
5533 clk_enable(&gfx3d_clk.c);
5534 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
5535 mb();
5536 udelay(5);
5537 writel_relaxed(0, SW_RESET_CORE_REG);
5538 /* Make sure reset is de-asserted before clock is disabled. */
5539 mb();
5540 clk_disable(&gfx3d_clk.c);
5541
5542 /* Enable TSSC and PDM PXO sources. */
5543 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
5544 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
5545
5546 /* Source SLIMBus xo src from slimbus reference clock */
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005547 if (cpu_is_msm8960())
5548 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005549
5550 /* Source the dsi_byte_clks from the DSI PHY PLLs */
5551 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
5552 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
Tianyi Gou41515e22011-09-01 19:37:43 -07005553
5554 /* Source the sata_phy_ref_clk from PXO */
5555 if (cpu_is_apq8064())
5556 rmwreg(0, SATA_PHY_REF_CLK_CTL_REG, 0x1);
5557
5558 /*
5559 * TODO: Programming below PLLs is temporary and needs to be removed
5560 * after bootloaders program them.
5561 */
5562 if (cpu_is_apq8064()) {
5563 u32 regval, is_pll_enabled;
5564
5565 /* Program pxo_src_clk to source from PXO */
5566 rmwreg(0x1, PXO_SRC_CLK_CTL_REG, 0x7);
5567
5568 /* Check if PLL8 is active */
5569 is_pll_enabled = readl_relaxed(BB_PLL8_STATUS_REG) & BIT(16);
5570 if (!is_pll_enabled) {
5571 /* Ref clk = 24.5MHz and program pll8 to 384MHz */
5572 writel_relaxed(0xF, BB_PLL8_L_VAL_REG);
5573 writel_relaxed(0x21, BB_PLL8_M_VAL_REG);
5574 writel_relaxed(0x31, BB_PLL8_N_VAL_REG);
5575
5576 regval = readl_relaxed(BB_PLL8_CONFIG_REG);
5577
5578 /* Enable the main output and the MN accumulator */
5579 regval |= BIT(23) | BIT(22);
5580
5581 /* Set pre-divider and post-divider values to 1 and 1 */
5582 regval &= ~BIT(19);
5583 regval &= ~BM(21, 20);
5584
5585 writel_relaxed(regval, BB_PLL8_CONFIG_REG);
5586
5587 /* Set VCO frequency */
5588 rmwreg(0x10000, BB_PLL8_CONFIG_REG, 0x30000);
5589
5590 /* Enable AUX output */
5591 regval = readl_relaxed(BB_PLL8_TEST_CTL_REG);
5592 regval |= BIT(12);
5593 writel_relaxed(regval, BB_PLL8_TEST_CTL_REG);
5594
5595 set_fsm_mode(BB_PLL8_MODE_REG);
5596 }
5597 /* Check if PLL3 is active */
5598 is_pll_enabled = readl_relaxed(GPLL1_STATUS_REG) & BIT(16);
5599 if (!is_pll_enabled) {
5600 /* Ref clk = 24.5MHz and program pll3 to 1200MHz */
5601 writel_relaxed(0x30, GPLL1_L_VAL_REG);
5602 writel_relaxed(0x30, GPLL1_M_VAL_REG);
5603 writel_relaxed(0x31, GPLL1_N_VAL_REG);
5604
5605 regval = readl_relaxed(GPLL1_CONFIG_REG);
5606
5607 /* Set pre-divider and post-divider values to 1 and 1 */
5608 regval &= ~BIT(15);
5609 regval |= BIT(16);
5610
5611 writel_relaxed(regval, GPLL1_CONFIG_REG);
5612
5613 /* Set VCO frequency */
5614 rmwreg(0x180, GPLL1_CONFIG_REG, 0x180);
5615 }
5616 /* Check if PLL14 is active */
5617 is_pll_enabled = readl_relaxed(BB_PLL14_STATUS_REG) & BIT(16);
5618 if (!is_pll_enabled) {
5619 /* Ref clk = 24.5MHz and program pll14 to 480MHz */
5620 writel_relaxed(0x13, BB_PLL14_L_VAL_REG);
5621 writel_relaxed(0x1D, BB_PLL14_M_VAL_REG);
5622 writel_relaxed(0x31, BB_PLL14_N_VAL_REG);
5623
5624 regval = readl_relaxed(BB_PLL14_CONFIG_REG);
5625
5626 /* Enable the main output and the MN accumulator */
5627 regval |= BIT(23) | BIT(22);
5628
5629 /* Set pre-divider and post-divider values to 1 and 1 */
5630 regval &= ~BIT(19);
5631 regval &= ~BM(21, 20);
5632
5633 writel_relaxed(regval, BB_PLL14_CONFIG_REG);
5634
5635 /* Set VCO frequency */
5636 rmwreg(0x10000, BB_PLL14_CONFIG_REG, 0x30000);
5637
Tianyi Gou41515e22011-09-01 19:37:43 -07005638 set_fsm_mode(BB_PLL14_MODE_REG);
5639 }
Tianyi Gou621f8742011-09-01 21:45:01 -07005640 /* Program PLL2 to 800MHz with ref clk = 27MHz */
5641 writel_relaxed(0x1D, MM_PLL1_L_VAL_REG);
5642 writel_relaxed(0x11, MM_PLL1_M_VAL_REG);
5643 writel_relaxed(0x1B, MM_PLL1_N_VAL_REG);
5644
5645 regval = readl_relaxed(MM_PLL1_CONFIG_REG);
5646
5647 /* Enable the main output and the MN accumulator */
5648 regval |= BIT(23) | BIT(22);
5649
5650 /* Set pre-divider and post-divider values to 1 and 1 */
5651 regval &= ~BIT(19);
5652 regval &= ~BM(21, 20);
5653
5654 writel_relaxed(regval, MM_PLL1_CONFIG_REG);
5655
5656 /* Set VCO frequency */
5657 rmwreg(0x20000, MM_PLL1_CONFIG_REG, 0x30000);
5658
Tianyi Gou621f8742011-09-01 21:45:01 -07005659 /* Program PLL15 to 975MHz with ref clk = 27MHz */
5660 writel_relaxed(0x24, MM_PLL3_L_VAL_REG);
5661 writel_relaxed(0x1, MM_PLL3_M_VAL_REG);
5662 writel_relaxed(0x9, MM_PLL3_N_VAL_REG);
5663
5664 regval = readl_relaxed(MM_PLL3_CONFIG_REG);
5665
5666 /* Enable the main output and the MN accumulator */
5667 regval |= BIT(23) | BIT(22);
5668
5669 /* Set pre-divider and post-divider values to 1 and 1 */
5670 regval &= ~BIT(19);
5671 regval &= ~BM(21, 20);
5672
5673 writel_relaxed(regval, MM_PLL3_CONFIG_REG);
5674
5675 /* Set VCO frequency */
5676 rmwreg(0x20000, MM_PLL3_CONFIG_REG, 0x30000);
5677
5678 /* Enable AUX output */
5679 regval = readl_relaxed(MM_PLL3_TEST_CTL_REG);
5680 regval |= BIT(12);
5681 writel_relaxed(regval, MM_PLL3_TEST_CTL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005682
5683 /* Check if PLL4 is active */
5684 is_pll_enabled = readl_relaxed(LCC_PLL0_STATUS_REG) & BIT(16);
5685 if (!is_pll_enabled) {
5686 /* Ref clk = 24.5MHz and program pll4 to 393.2160MHz */
5687 writel_relaxed(0x10, LCC_PLL0_L_VAL_REG);
5688 writel_relaxed(0x130, LCC_PLL0_M_VAL_REG);
5689 writel_relaxed(0x17ED, LCC_PLL0_N_VAL_REG);
5690
5691 regval = readl_relaxed(LCC_PLL0_CONFIG_REG);
5692
5693 /* Enable the main output and the MN accumulator */
5694 regval |= BIT(23) | BIT(22);
5695
5696 /* Set pre-divider and post-divider values to 1 and 1 */
5697 regval &= ~BIT(19);
5698 regval &= ~BM(21, 20);
5699
5700 /* Set VCO frequency */
5701 regval &= ~BM(17, 16);
5702 writel_relaxed(regval, LCC_PLL0_CONFIG_REG);
5703
5704 set_fsm_mode(LCC_PLL0_MODE_REG);
5705 }
5706
5707 /* Enable PLL4 source on the LPASS Primary PLL Mux */
5708 writel_relaxed(0x1, LCC_PRI_PLL_CLK_CTL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005709 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005710}
5711
Stephen Boyd94625ef2011-07-12 17:06:01 -07005712struct clock_init_data msm8960_clock_init_data __initdata;
5713
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005714/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07005715static void __init msm8960_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005716{
Stephen Boyd94625ef2011-07-12 17:06:01 -07005717 size_t num_lookups = ARRAY_SIZE(msm_clocks_8960_v1);
Tianyi Gou41515e22011-09-01 19:37:43 -07005718
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005719 xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8960");
5720 if (IS_ERR(xo_pxo)) {
5721 pr_err("%s: msm_xo_get(PXO) failed.\n", __func__);
5722 BUG();
5723 }
5724 xo_cxo = msm_xo_get(MSM_XO_TCXO_D0, "clock-8960");
5725 if (IS_ERR(xo_cxo)) {
5726 pr_err("%s: msm_xo_get(CXO) failed.\n", __func__);
5727 BUG();
5728 }
5729
Tianyi Gou41515e22011-09-01 19:37:43 -07005730 if (cpu_is_msm8960()) {
5731 memcpy(msm_clocks_8960, msm_clocks_8960_v1,
5732 sizeof(msm_clocks_8960_v1));
5733 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5734 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8960_v2;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005735
5736 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8960_v2,
5737 sizeof(gfx3d_clk.c.fmax));
5738 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8960_v2,
5739 sizeof(ijpeg_clk.c.fmax));
5740 memcpy(vfe_clk.c.fmax, fmax_vfe_8960_v2,
5741 sizeof(vfe_clk.c.fmax));
5742
Tianyi Gou41515e22011-09-01 19:37:43 -07005743 memcpy(msm_clocks_8960 + ARRAY_SIZE(msm_clocks_8960_v1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07005744 msm_clocks_8960_v2, sizeof(msm_clocks_8960_v2));
Tianyi Gou41515e22011-09-01 19:37:43 -07005745 num_lookups = ARRAY_SIZE(msm_clocks_8960);
5746 }
5747 msm8960_clock_init_data.size = num_lookups;
Stephen Boyd94625ef2011-07-12 17:06:01 -07005748 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005749
5750 /*
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005751 * Change the freq tables for and voltage requirements for
5752 * clocks which differ between 8960 and 8064.
Tianyi Gou41515e22011-09-01 19:37:43 -07005753 */
5754 if (cpu_is_apq8064()) {
5755 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8064;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005756
5757 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8064,
5758 sizeof(gfx3d_clk.c.fmax));
5759 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8064,
5760 sizeof(ijpeg_clk.c.fmax));
5761 memcpy(mdp_clk.c.fmax, fmax_mdp_8064,
5762 sizeof(ijpeg_clk.c.fmax));
5763 memcpy(tv_src_clk.c.fmax, fmax_tv_src_8064,
5764 sizeof(tv_src_clk.c.fmax));
5765 memcpy(vfe_clk.c.fmax, fmax_vfe_8064,
5766 sizeof(vfe_clk.c.fmax));
5767
Tianyi Gou621f8742011-09-01 21:45:01 -07005768 gmem_axi_clk.c.depends = &gfx3d_axi_clk.c;
Tianyi Gou41515e22011-09-01 19:37:43 -07005769 }
Stephen Boyd94625ef2011-07-12 17:06:01 -07005770
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005771 vote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005772
Vikram Mulukutla489e39e2011-08-31 18:04:05 -07005773 clk_ops_pll.enable = sr_pll_clk_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005774
5775 /* Initialize clock registers. */
5776 reg_init();
5777
5778 /* Initialize rates for clocks that only support one. */
5779 clk_set_rate(&pdm_clk.c, 27000000);
5780 clk_set_rate(&prng_clk.c, 64000000);
5781 clk_set_rate(&mdp_vsync_clk.c, 27000000);
5782 clk_set_rate(&tsif_ref_clk.c, 105000);
5783 clk_set_rate(&tssc_clk.c, 27000000);
5784 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
Tianyi Gou41515e22011-09-01 19:37:43 -07005785 if (cpu_is_apq8064()) {
5786 clk_set_rate(&usb_hs3_xcvr_clk.c, 60000000);
5787 clk_set_rate(&usb_hs4_xcvr_clk.c, 60000000);
5788 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005789 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
Tianyi Gou41515e22011-09-01 19:37:43 -07005790 if (cpu_is_msm8960())
5791 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005792 clk_set_rate(&usb_hsic_xcvr_fs_clk.c, 60000000);
5793 clk_set_rate(&usb_hsic_hsic_src_clk.c, 480000000);
5794 clk_set_rate(&usb_hsic_hsio_cal_clk.c, 9000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005795
5796 /*
Stephen Boyd60496bb2011-10-17 13:51:37 -07005797 * The halt status bits for these clocks may be incorrect at boot.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005798 * Toggle these clocks on and off to refresh them.
5799 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07005800 rcg_clk_enable(&pdm_clk.c);
5801 rcg_clk_disable(&pdm_clk.c);
5802 rcg_clk_enable(&tssc_clk.c);
5803 rcg_clk_disable(&tssc_clk.c);
Stephen Boyd60496bb2011-10-17 13:51:37 -07005804 if (cpu_is_msm8960() &&
5805 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5806 clk_enable(&usb_hsic_hsic_clk.c);
5807 clk_disable(&usb_hsic_hsic_clk.c);
5808 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005809
5810 if (machine_is_msm8960_sim()) {
5811 clk_set_rate(&sdc1_clk.c, 48000000);
5812 clk_enable(&sdc1_clk.c);
5813 clk_enable(&sdc1_p_clk.c);
5814 clk_set_rate(&sdc3_clk.c, 48000000);
5815 clk_enable(&sdc3_clk.c);
5816 clk_enable(&sdc3_p_clk.c);
5817 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005818}
5819
Stephen Boydbb600ae2011-08-02 20:11:40 -07005820static int __init msm8960_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005821{
Stephen Boyda3787f32011-09-16 18:55:13 -07005822 int rc;
5823 struct clk *mmfpb_a_clk = clk_get_sys("clock-8960", "mmfpb_a_clk");
Stephen Boyd85436132011-09-16 18:55:13 -07005824 struct clk *cfpb_a_clk = clk_get_sys("clock-8960", "cfpb_a_clk");
Stephen Boyda3787f32011-09-16 18:55:13 -07005825
5826 /* Vote for MMFPB to be at least 76.8MHz when an Apps CPU is active. */
5827 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
5828 PTR_ERR(mmfpb_a_clk)))
5829 return PTR_ERR(mmfpb_a_clk);
5830 rc = clk_set_min_rate(mmfpb_a_clk, 76800000);
5831 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
5832 return rc;
5833 rc = clk_enable(mmfpb_a_clk);
5834 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
5835 return rc;
5836
Stephen Boyd85436132011-09-16 18:55:13 -07005837 /* Vote for CFPB to be at least 64MHz when an Apps CPU is active. */
5838 if (WARN(IS_ERR(cfpb_a_clk), "cfpb_a_clk not found (%ld)\n",
5839 PTR_ERR(cfpb_a_clk)))
5840 return PTR_ERR(cfpb_a_clk);
5841 rc = clk_set_min_rate(cfpb_a_clk, 64000000);
5842 if (WARN(rc, "cfpb_a_clk rate was not set (%d)\n", rc))
5843 return rc;
5844 rc = clk_enable(cfpb_a_clk);
5845 if (WARN(rc, "cfpb_a_clk not enabled (%d)\n", rc))
5846 return rc;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005847
5848 return unvote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005849}
Stephen Boydbb600ae2011-08-02 20:11:40 -07005850
5851struct clock_init_data msm8960_clock_init_data __initdata = {
5852 .table = msm_clocks_8960,
5853 .size = ARRAY_SIZE(msm_clocks_8960),
5854 .init = msm8960_clock_init,
5855 .late_init = msm8960_clock_late_init,
5856};
Tianyi Gou41515e22011-09-01 19:37:43 -07005857
5858struct clock_init_data apq8064_clock_init_data __initdata = {
5859 .table = msm_clocks_8064,
5860 .size = ARRAY_SIZE(msm_clocks_8064),
5861 .init = msm8960_clock_init,
5862 .late_init = msm8960_clock_late_init,
5863};