blob: 667ac62fd59260a43a6327606fc2f076de4d4741 [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. */
Stephen Boyda52d7e32011-11-10 11:59:00 -080044#define ADM0_PBUS_CLK_CTL_REG REG(0x2208)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070045#define CE1_HCLK_CTL_REG REG(0x2720)
46#define CE1_CORE_CLK_CTL_REG REG(0x2724)
Tianyi Gou41515e22011-09-01 19:37:43 -070047#define CE3_HCLK_CTL_REG REG(0x36C4)
48#define CE3_CORE_CLK_CTL_REG REG(0x36CC)
49#define CE3_CLK_SRC_NS_REG REG(0x36C0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050#define DMA_BAM_HCLK_CTL REG(0x25C0)
Tianyi Gou41515e22011-09-01 19:37:43 -070051#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052#define CLK_HALT_CFPB_STATEA_REG REG(0x2FCC)
53#define CLK_HALT_CFPB_STATEB_REG REG(0x2FD0)
54#define CLK_HALT_CFPB_STATEC_REG REG(0x2FD4)
55#define CLK_HALT_DFAB_STATE_REG REG(0x2FC8)
Tianyi Gou41515e22011-09-01 19:37:43 -070056/* 8064 name CLK_HALT_GSS_KPSS_MISC_STATE_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057#define CLK_HALT_MSS_SMPSS_MISC_STATE_REG REG(0x2FDC)
58#define CLK_HALT_SFPB_MISC_STATE_REG REG(0x2FD8)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070059#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060#define CLK_TEST_REG REG(0x2FA0)
Matt Wagantall7625a4c2011-11-01 16:17:53 -070061#define GPn_MD_REG(n) REG(0x2D00+(0x20*(n)))
62#define GPn_NS_REG(n) REG(0x2D24+(0x20*(n)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070063#define GSBIn_HCLK_CTL_REG(n) REG(0x29C0+(0x20*((n)-1)))
64#define GSBIn_QUP_APPS_MD_REG(n) REG(0x29C8+(0x20*((n)-1)))
65#define GSBIn_QUP_APPS_NS_REG(n) REG(0x29CC+(0x20*((n)-1)))
66#define GSBIn_RESET_REG(n) REG(0x29DC+(0x20*((n)-1)))
67#define GSBIn_UART_APPS_MD_REG(n) REG(0x29D0+(0x20*((n)-1)))
68#define GSBIn_UART_APPS_NS_REG(n) REG(0x29D4+(0x20*((n)-1)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069#define PDM_CLK_NS_REG REG(0x2CC0)
Tianyi Gou41515e22011-09-01 19:37:43 -070070/* 8064 name BB_PLL_ENA_APCS_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070071#define BB_PLL_ENA_SC0_REG REG(0x34C0)
72#define BB_PLL0_STATUS_REG REG(0x30D8)
73#define BB_PLL5_STATUS_REG REG(0x30F8)
74#define BB_PLL6_STATUS_REG REG(0x3118)
75#define BB_PLL7_STATUS_REG REG(0x3138)
76#define BB_PLL8_L_VAL_REG REG(0x3144)
77#define BB_PLL8_M_VAL_REG REG(0x3148)
78#define BB_PLL8_MODE_REG REG(0x3140)
79#define BB_PLL8_N_VAL_REG REG(0x314C)
80#define BB_PLL8_STATUS_REG REG(0x3158)
81#define BB_PLL8_CONFIG_REG REG(0x3154)
82#define BB_PLL8_TEST_CTL_REG REG(0x3150)
Stephen Boyd94625ef2011-07-12 17:06:01 -070083#define BB_MMCC_PLL2_MODE_REG REG(0x3160)
84#define BB_MMCC_PLL2_TEST_CTL_REG REG(0x3170)
Tianyi Gou41515e22011-09-01 19:37:43 -070085#define BB_PLL14_MODE_REG REG(0x31C0)
86#define BB_PLL14_L_VAL_REG REG(0x31C4)
87#define BB_PLL14_M_VAL_REG REG(0x31C8)
88#define BB_PLL14_N_VAL_REG REG(0x31CC)
89#define BB_PLL14_TEST_CTL_REG REG(0x31D0)
90#define BB_PLL14_CONFIG_REG REG(0x31D4)
Stephen Boyd94625ef2011-07-12 17:06:01 -070091#define BB_PLL14_STATUS_REG REG(0x31D8)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092#define PLLTEST_PAD_CFG_REG REG(0x2FA4)
93#define PMEM_ACLK_CTL_REG REG(0x25A0)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070094#define QDSS_AT_CLK_SRC0_NS_REG REG(0x2180)
95#define QDSS_AT_CLK_SRC1_NS_REG REG(0x2184)
96#define QDSS_AT_CLK_SRC_CTL_REG REG(0x2188)
97#define QDSS_AT_CLK_NS_REG REG(0x218C)
98#define QDSS_HCLK_CTL_REG REG(0x22A0)
99#define QDSS_RESETS_REG REG(0x2260)
100#define QDSS_STM_CLK_CTL_REG REG(0x2060)
101#define QDSS_TRACECLKIN_CLK_SRC0_NS_REG REG(0x21A0)
102#define QDSS_TRACECLKIN_CLK_SRC1_NS_REG REG(0x21A4)
103#define QDSS_TRACECLKIN_CLK_SRC_CTL_REG REG(0x21A8)
104#define QDSS_TRACECLKIN_CTL_REG REG(0x21AC)
105#define QDSS_TSCTR_CLK_SRC0_NS_REG REG(0x21C0)
106#define QDSS_TSCTR_CLK_SRC1_NS_REG REG(0x21C4)
107#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
108#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
109#define QDSS_TSCTR_CTL_REG REG(0x21CC)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700110#define RINGOSC_NS_REG REG(0x2DC0)
111#define RINGOSC_STATUS_REG REG(0x2DCC)
112#define RINGOSC_TCXO_CTL_REG REG(0x2DC4)
Stephen Boyda52d7e32011-11-10 11:59:00 -0800113#define RPM_MSG_RAM_HCLK_CTL_REG REG(0x27E0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700114#define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080)
115#define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1)))
116#define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1)))
117#define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1)))
118#define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1)))
119#define SLIMBUS_XO_SRC_CLK_CTL_REG REG(0x2628)
120#define TSIF_HCLK_CTL_REG REG(0x2700)
121#define TSIF_REF_CLK_MD_REG REG(0x270C)
122#define TSIF_REF_CLK_NS_REG REG(0x2710)
123#define TSSC_CLK_CTL_REG REG(0x2CA0)
Tianyi Gou41515e22011-09-01 19:37:43 -0700124#define SATA_CLK_SRC_NS_REG REG(0x2C08)
125#define SATA_RXOOB_CLK_CTL_REG REG(0x2C0C)
126#define SATA_PMALIVE_CLK_CTL_REG REG(0x2C10)
127#define SATA_PHY_REF_CLK_CTL_REG REG(0x2C14)
128#define SATA_PHY_CFG_CLK_CTL_REG REG(0x2C40)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700129#define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1)))
130#define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1)))
131#define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1)))
132#define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1)))
133#define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1)))
134#define USB_HS1_HCLK_CTL_REG REG(0x2900)
Tianyi Gou41515e22011-09-01 19:37:43 -0700135#define USB_HS1_HCLK_FS_REG REG(0x2904)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700136#define USB_HS1_RESET_REG REG(0x2910)
137#define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908)
138#define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700139#define USB_HS3_HCLK_CTL_REG REG(0x3700)
140#define USB_HS3_HCLK_FS_REG REG(0x3704)
141#define USB_HS3_RESET_REG REG(0x3710)
142#define USB_HS3_XCVR_FS_CLK_MD_REG REG(0X3708)
143#define USB_HS3_XCVR_FS_CLK_NS_REG REG(0X370C)
144#define USB_HS4_HCLK_CTL_REG REG(0x3720)
145#define USB_HS4_HCLK_FS_REG REG(0x3724)
146#define USB_HS4_RESET_REG REG(0x3730)
147#define USB_HS4_XCVR_FS_CLK_MD_REG REG(0X3728)
148#define USB_HS4_XCVR_FS_CLK_NS_REG REG(0X372C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700149#define USB_HSIC_HCLK_CTL_REG REG(0x2920)
150#define USB_HSIC_HSIC_CLK_CTL_REG REG(0x2B44)
151#define USB_HSIC_HSIC_CLK_SRC_CTL_REG REG(0x2B40)
152#define USB_HSIC_HSIO_CAL_CLK_CTL_REG REG(0x2B48)
153#define USB_HSIC_RESET_REG REG(0x2934)
154#define USB_HSIC_SYSTEM_CLK_CTL_REG REG(0x292C)
155#define USB_HSIC_XCVR_FS_CLK_MD_REG REG(0x2924)
156#define USB_HSIC_XCVR_FS_CLK_NS_REG REG(0x2928)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700157#define USB_PHY0_RESET_REG REG(0x2E20)
Tianyi Gou41515e22011-09-01 19:37:43 -0700158#define PCIE_ALT_REF_CLK_NS_REG REG(0x3860)
159#define PCIE_HCLK_CTL_REG REG(0x22CC)
160#define GPLL1_MODE_REG REG(0x3160)
161#define GPLL1_L_VAL_REG REG(0x3164)
162#define GPLL1_M_VAL_REG REG(0x3168)
163#define GPLL1_N_VAL_REG REG(0x316C)
164#define GPLL1_CONFIG_REG REG(0x3174)
165#define GPLL1_STATUS_REG REG(0x3178)
166#define PXO_SRC_CLK_CTL_REG REG(0x2EA0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700167
168/* Multimedia clock registers. */
169#define AHB_EN_REG REG_MM(0x0008)
170#define AHB_EN2_REG REG_MM(0x0038)
Tianyi Gou41515e22011-09-01 19:37:43 -0700171#define AHB_EN3_REG REG_MM(0x0248)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700172#define AHB_NS_REG REG_MM(0x0004)
173#define AXI_NS_REG REG_MM(0x0014)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700174#define CAMCLK0_NS_REG REG_MM(0x0148)
175#define CAMCLK0_CC_REG REG_MM(0x0140)
176#define CAMCLK0_MD_REG REG_MM(0x0144)
177#define CAMCLK1_NS_REG REG_MM(0x015C)
178#define CAMCLK1_CC_REG REG_MM(0x0154)
179#define CAMCLK1_MD_REG REG_MM(0x0158)
180#define CAMCLK2_NS_REG REG_MM(0x0228)
181#define CAMCLK2_CC_REG REG_MM(0x0220)
182#define CAMCLK2_MD_REG REG_MM(0x0224)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700183#define CSI0_NS_REG REG_MM(0x0048)
184#define CSI0_CC_REG REG_MM(0x0040)
185#define CSI0_MD_REG REG_MM(0x0044)
186#define CSI1_NS_REG REG_MM(0x0010)
187#define CSI1_CC_REG REG_MM(0x0024)
188#define CSI1_MD_REG REG_MM(0x0028)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700189#define CSI2_NS_REG REG_MM(0x0234)
190#define CSI2_CC_REG REG_MM(0x022C)
191#define CSI2_MD_REG REG_MM(0x0230)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700192#define CSIPHYTIMER_CC_REG REG_MM(0x0160)
193#define CSIPHYTIMER_MD_REG REG_MM(0x0164)
194#define CSIPHYTIMER_NS_REG REG_MM(0x0168)
195#define DSI1_BYTE_NS_REG REG_MM(0x00B0)
196#define DSI1_BYTE_CC_REG REG_MM(0x0090)
197#define DSI2_BYTE_NS_REG REG_MM(0x00BC)
198#define DSI2_BYTE_CC_REG REG_MM(0x00B4)
199#define DSI1_ESC_NS_REG REG_MM(0x011C)
200#define DSI1_ESC_CC_REG REG_MM(0x00CC)
201#define DSI2_ESC_NS_REG REG_MM(0x0150)
202#define DSI2_ESC_CC_REG REG_MM(0x013C)
203#define DSI_PIXEL_CC_REG REG_MM(0x0130)
204#define DSI2_PIXEL_CC_REG REG_MM(0x0094)
205#define DBG_BUS_VEC_A_REG REG_MM(0x01C8)
206#define DBG_BUS_VEC_B_REG REG_MM(0x01CC)
207#define DBG_BUS_VEC_C_REG REG_MM(0x01D0)
208#define DBG_BUS_VEC_D_REG REG_MM(0x01D4)
209#define DBG_BUS_VEC_E_REG REG_MM(0x01D8)
210#define DBG_BUS_VEC_F_REG REG_MM(0x01DC)
211#define DBG_BUS_VEC_G_REG REG_MM(0x01E0)
212#define DBG_BUS_VEC_H_REG REG_MM(0x01E4)
213#define DBG_BUS_VEC_I_REG REG_MM(0x01E8)
Tianyi Gou41515e22011-09-01 19:37:43 -0700214#define DBG_BUS_VEC_J_REG REG_MM(0x0240)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700215#define DBG_CFG_REG_HS_REG REG_MM(0x01B4)
216#define DBG_CFG_REG_LS_REG REG_MM(0x01B8)
217#define GFX2D0_CC_REG REG_MM(0x0060)
218#define GFX2D0_MD0_REG REG_MM(0x0064)
219#define GFX2D0_MD1_REG REG_MM(0x0068)
220#define GFX2D0_NS_REG REG_MM(0x0070)
221#define GFX2D1_CC_REG REG_MM(0x0074)
222#define GFX2D1_MD0_REG REG_MM(0x0078)
223#define GFX2D1_MD1_REG REG_MM(0x006C)
224#define GFX2D1_NS_REG REG_MM(0x007C)
225#define GFX3D_CC_REG REG_MM(0x0080)
226#define GFX3D_MD0_REG REG_MM(0x0084)
227#define GFX3D_MD1_REG REG_MM(0x0088)
228#define GFX3D_NS_REG REG_MM(0x008C)
229#define IJPEG_CC_REG REG_MM(0x0098)
230#define IJPEG_MD_REG REG_MM(0x009C)
231#define IJPEG_NS_REG REG_MM(0x00A0)
232#define JPEGD_CC_REG REG_MM(0x00A4)
233#define JPEGD_NS_REG REG_MM(0x00AC)
Tianyi Gou41515e22011-09-01 19:37:43 -0700234#define VCAP_CC_REG REG_MM(0x0178)
235#define VCAP_NS_REG REG_MM(0x021C)
236#define VCAP_MD0_REG REG_MM(0x01EC)
237#define VCAP_MD1_REG REG_MM(0x0218)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700238#define MAXI_EN_REG REG_MM(0x0018)
239#define MAXI_EN2_REG REG_MM(0x0020)
240#define MAXI_EN3_REG REG_MM(0x002C)
241#define MAXI_EN4_REG REG_MM(0x0114)
Tianyi Gou41515e22011-09-01 19:37:43 -0700242#define MAXI_EN5_REG REG_MM(0x0244)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700243#define MDP_CC_REG REG_MM(0x00C0)
244#define MDP_LUT_CC_REG REG_MM(0x016C)
245#define MDP_MD0_REG REG_MM(0x00C4)
246#define MDP_MD1_REG REG_MM(0x00C8)
247#define MDP_NS_REG REG_MM(0x00D0)
248#define MISC_CC_REG REG_MM(0x0058)
249#define MISC_CC2_REG REG_MM(0x005C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700250#define MISC_CC3_REG REG_MM(0x0238)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700251#define MM_PLL1_MODE_REG REG_MM(0x031C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700252#define MM_PLL1_L_VAL_REG REG_MM(0x0320)
253#define MM_PLL1_M_VAL_REG REG_MM(0x0324)
254#define MM_PLL1_N_VAL_REG REG_MM(0x0328)
255#define MM_PLL1_CONFIG_REG REG_MM(0x032C)
256#define MM_PLL1_TEST_CTL_REG REG_MM(0x0330)
257#define MM_PLL1_STATUS_REG REG_MM(0x0334)
258#define MM_PLL3_MODE_REG REG_MM(0x0338)
Tianyi Gou621f8742011-09-01 21:45:01 -0700259#define MM_PLL3_L_VAL_REG REG_MM(0x033C)
260#define MM_PLL3_M_VAL_REG REG_MM(0x0340)
261#define MM_PLL3_N_VAL_REG REG_MM(0x0344)
262#define MM_PLL3_CONFIG_REG REG_MM(0x0348)
263#define MM_PLL3_TEST_CTL_REG REG_MM(0x034C)
264#define MM_PLL3_STATUS_REG REG_MM(0x0350)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700265#define ROT_CC_REG REG_MM(0x00E0)
266#define ROT_NS_REG REG_MM(0x00E8)
267#define SAXI_EN_REG REG_MM(0x0030)
268#define SW_RESET_AHB_REG REG_MM(0x020C)
269#define SW_RESET_AHB2_REG REG_MM(0x0200)
270#define SW_RESET_ALL_REG REG_MM(0x0204)
271#define SW_RESET_AXI_REG REG_MM(0x0208)
272#define SW_RESET_CORE_REG REG_MM(0x0210)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700273#define SW_RESET_CORE2_REG REG_MM(0x0214)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700274#define TV_CC_REG REG_MM(0x00EC)
275#define TV_CC2_REG REG_MM(0x0124)
276#define TV_MD_REG REG_MM(0x00F0)
277#define TV_NS_REG REG_MM(0x00F4)
278#define VCODEC_CC_REG REG_MM(0x00F8)
279#define VCODEC_MD0_REG REG_MM(0x00FC)
280#define VCODEC_MD1_REG REG_MM(0x0128)
281#define VCODEC_NS_REG REG_MM(0x0100)
282#define VFE_CC_REG REG_MM(0x0104)
283#define VFE_MD_REG REG_MM(0x0108)
284#define VFE_NS_REG REG_MM(0x010C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700285#define VFE_CC2_REG REG_MM(0x023C)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700286#define VPE_CC_REG REG_MM(0x0110)
287#define VPE_NS_REG REG_MM(0x0118)
288
289/* Low-power Audio clock registers. */
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700290#define LCC_CLK_HS_DEBUG_CFG_REG REG_LPA(0x00A4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700291#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
292#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
293#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
294#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
295#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
296#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
297#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
298#define LCC_MI2S_MD_REG REG_LPA(0x004C)
299#define LCC_MI2S_NS_REG REG_LPA(0x0048)
300#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
301#define LCC_PCM_MD_REG REG_LPA(0x0058)
302#define LCC_PCM_NS_REG REG_LPA(0x0054)
303#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700304#define LCC_PLL0_MODE_REG REG_LPA(0x0000)
305#define LCC_PLL0_L_VAL_REG REG_LPA(0x0004)
306#define LCC_PLL0_M_VAL_REG REG_LPA(0x0008)
307#define LCC_PLL0_N_VAL_REG REG_LPA(0x000C)
308#define LCC_PLL0_CONFIG_REG REG_LPA(0x0014)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700309#define LCC_PLL0_STATUS_REG REG_LPA(0x0018)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700310#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
311#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
312#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
313#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
314#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
315#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
316#define LCC_SLIMBUS_NS_REG REG_LPA(0x00CC)
317#define LCC_SLIMBUS_MD_REG REG_LPA(0x00D0)
318#define LCC_SLIMBUS_STATUS_REG REG_LPA(0x00D4)
319#define LCC_AHBEX_BRANCH_CTL_REG REG_LPA(0x00E4)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700320#define LCC_PRI_PLL_CLK_CTL_REG REG_LPA(0x00C4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700321
Matt Wagantall8b38f942011-08-02 18:23:18 -0700322#define GCC_APCS_CLK_DIAG REG_GCC(0x001C)
323
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700324/* MUX source input identifiers. */
325#define pxo_to_bb_mux 0
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700326#define cxo_to_bb_mux 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700327#define pll0_to_bb_mux 2
328#define pll8_to_bb_mux 3
329#define pll6_to_bb_mux 4
330#define gnd_to_bb_mux 5
Stephen Boyd94625ef2011-07-12 17:06:01 -0700331#define pll3_to_bb_mux 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332#define pxo_to_mm_mux 0
333#define pll1_to_mm_mux 1
Tianyi Gou41515e22011-09-01 19:37:43 -0700334#define pll2_to_mm_mux 1 /* or MMCC_PLL1 */
335#define pll8_to_mm_mux 2 /* or GCC_PERF */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700336#define pll0_to_mm_mux 3
Tianyi Gou41515e22011-09-01 19:37:43 -0700337#define pll15_to_mm_mux 3 /* or MM_PLL3 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700338#define gnd_to_mm_mux 4
Stephen Boyd7a776cd2011-10-20 12:46:04 -0700339#define pll3_to_mm_mux 3 /* or MMCC_PLL2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700340#define hdmi_pll_to_mm_mux 3
341#define cxo_to_xo_mux 0
342#define pxo_to_xo_mux 1
343#define gnd_to_xo_mux 3
344#define pxo_to_lpa_mux 0
345#define cxo_to_lpa_mux 1
346#define pll4_to_lpa_mux 2
347#define gnd_to_lpa_mux 6
Tianyi Gou41515e22011-09-01 19:37:43 -0700348#define pxo_to_pcie_mux 0
349#define pll3_to_pcie_mux 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700350
351/* Test Vector Macros */
352#define TEST_TYPE_PER_LS 1
353#define TEST_TYPE_PER_HS 2
354#define TEST_TYPE_MM_LS 3
355#define TEST_TYPE_MM_HS 4
356#define TEST_TYPE_LPA 5
Matt Wagantall8b38f942011-08-02 18:23:18 -0700357#define TEST_TYPE_CPUL2 6
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700358#define TEST_TYPE_LPA_HS 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700359#define TEST_TYPE_SHIFT 24
360#define TEST_CLK_SEL_MASK BM(23, 0)
361#define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s)))
362#define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS)
363#define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS)
364#define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS)
365#define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS)
366#define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA)
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700367#define TEST_LPA_HS(s) TEST_VECTOR((s), TEST_TYPE_LPA_HS)
Matt Wagantall8b38f942011-08-02 18:23:18 -0700368#define TEST_CPUL2(s) TEST_VECTOR((s), TEST_TYPE_CPUL2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700369
370#define MN_MODE_DUAL_EDGE 0x2
371
372/* MD Registers */
373#define MD4(m_lsb, m, n_lsb, n) \
374 (BVAL((m_lsb+3), m_lsb, m) | BVAL((n_lsb+3), n_lsb, ~(n)))
375#define MD8(m_lsb, m, n_lsb, n) \
376 (BVAL((m_lsb+7), m_lsb, m) | BVAL((n_lsb+7), n_lsb, ~(n)))
377#define MD16(m, n) (BVAL(31, 16, m) | BVAL(15, 0, ~(n)))
378
379/* NS Registers */
380#define NS(n_msb, n_lsb, n, m, mde_lsb, d_msb, d_lsb, d, s_msb, s_lsb, s) \
381 (BVAL(n_msb, n_lsb, ~(n-m)) \
382 | (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n)) \
383 | BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
384
385#define NS_MM(n_msb, n_lsb, n, m, d_msb, d_lsb, d, s_msb, s_lsb, s) \
386 (BVAL(n_msb, n_lsb, ~(n-m)) | BVAL(d_msb, d_lsb, (d-1)) \
387 | BVAL(s_msb, s_lsb, s))
388
389#define NS_DIVSRC(d_msb , d_lsb, d, s_msb, s_lsb, s) \
390 (BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
391
392#define NS_DIV(d_msb , d_lsb, d) \
393 BVAL(d_msb, d_lsb, (d-1))
394
395#define NS_SRC_SEL(s_msb, s_lsb, s) \
396 BVAL(s_msb, s_lsb, s)
397
398#define NS_MND_BANKED4(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
399 (BVAL((n0_lsb+3), n0_lsb, ~(n-m)) \
400 | BVAL((n1_lsb+3), n1_lsb, ~(n-m)) \
401 | BVAL((s0_lsb+2), s0_lsb, s) \
402 | BVAL((s1_lsb+2), s1_lsb, s))
403
404#define NS_MND_BANKED8(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
405 (BVAL((n0_lsb+7), n0_lsb, ~(n-m)) \
406 | BVAL((n1_lsb+7), n1_lsb, ~(n-m)) \
407 | BVAL((s0_lsb+2), s0_lsb, s) \
408 | BVAL((s1_lsb+2), s1_lsb, s))
409
410#define NS_DIVSRC_BANKED(d0_msb, d0_lsb, d1_msb, d1_lsb, d, \
411 s0_msb, s0_lsb, s1_msb, s1_lsb, s) \
412 (BVAL(d0_msb, d0_lsb, (d-1)) | BVAL(d1_msb, d1_lsb, (d-1)) \
413 | BVAL(s0_msb, s0_lsb, s) \
414 | BVAL(s1_msb, s1_lsb, s))
415
416/* CC Registers */
417#define CC(mde_lsb, n) (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n))
418#define CC_BANKED(mde0_lsb, mde1_lsb, n) \
419 ((BVAL((mde0_lsb+1), mde0_lsb, MN_MODE_DUAL_EDGE) \
420 | BVAL((mde1_lsb+1), mde1_lsb, MN_MODE_DUAL_EDGE)) \
421 * !!(n))
422
423struct pll_rate {
424 const uint32_t l_val;
425 const uint32_t m_val;
426 const uint32_t n_val;
427 const uint32_t vco;
428 const uint32_t post_div;
429 const uint32_t i_bits;
430};
431#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
432
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700433enum vdd_dig_levels {
434 VDD_DIG_NONE,
435 VDD_DIG_LOW,
436 VDD_DIG_NOMINAL,
437 VDD_DIG_HIGH
438};
439
440static int set_vdd_dig(struct clk_vdd_class *vdd_class, int level)
441{
442 static const int vdd_uv[] = {
443 [VDD_DIG_NONE] = 0,
444 [VDD_DIG_LOW] = 945000,
445 [VDD_DIG_NOMINAL] = 1050000,
446 [VDD_DIG_HIGH] = 1150000
447 };
448
449 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
450 vdd_uv[level], 1150000, 1);
451}
452
453static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig);
454
455#define VDD_DIG_FMAX_MAP1(l1, f1) \
456 .vdd_class = &vdd_dig, \
457 .fmax[VDD_DIG_##l1] = (f1)
458#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
459 .vdd_class = &vdd_dig, \
460 .fmax[VDD_DIG_##l1] = (f1), \
461 .fmax[VDD_DIG_##l2] = (f2)
462#define VDD_DIG_FMAX_MAP3(l1, f1, l2, f2, l3, f3) \
463 .vdd_class = &vdd_dig, \
464 .fmax[VDD_DIG_##l1] = (f1), \
465 .fmax[VDD_DIG_##l2] = (f2), \
466 .fmax[VDD_DIG_##l3] = (f3)
467
Matt Wagantallc57577d2011-10-06 17:06:53 -0700468enum vdd_l23_levels {
469 VDD_L23_OFF,
470 VDD_L23_ON
471};
472
473static int set_vdd_l23(struct clk_vdd_class *vdd_class, int level)
474{
475 int rc;
476
477 if (level == VDD_L23_OFF) {
478 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
479 RPM_VREG_VOTER3, 0, 0, 1);
480 if (rc)
481 return rc;
482 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
483 RPM_VREG_VOTER3, 0, 0, 1);
484 if (rc)
485 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
486 RPM_VREG_VOTER3, 1800000, 1800000, 1);
487 } else {
488 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
489 RPM_VREG_VOTER3, 2200000, 2200000, 1);
490 if (rc)
491 return rc;
492 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
493 RPM_VREG_VOTER3, 1800000, 1800000, 1);
494 if (rc)
495 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
496 RPM_VREG_VOTER3, 0, 0, 1);
497 }
498
499 return rc;
500}
501
502static DEFINE_VDD_CLASS(vdd_l23, set_vdd_l23);
503
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700504/*
505 * Clock Descriptions
506 */
507
508static struct msm_xo_voter *xo_pxo, *xo_cxo;
509
510static int pxo_clk_enable(struct clk *clk)
511{
512 return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON);
513}
514
515static void pxo_clk_disable(struct clk *clk)
516{
Tianyi Gou41515e22011-09-01 19:37:43 -0700517 msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700518}
519
520static struct clk_ops clk_ops_pxo = {
521 .enable = pxo_clk_enable,
522 .disable = pxo_clk_disable,
523 .get_rate = fixed_clk_get_rate,
524 .is_local = local_clk_is_local,
525};
526
527static struct fixed_clk pxo_clk = {
528 .rate = 27000000,
529 .c = {
530 .dbg_name = "pxo_clk",
531 .ops = &clk_ops_pxo,
532 CLK_INIT(pxo_clk.c),
533 },
534};
535
536static int cxo_clk_enable(struct clk *clk)
537{
538 return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON);
539}
540
541static void cxo_clk_disable(struct clk *clk)
542{
543 msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF);
544}
545
546static struct clk_ops clk_ops_cxo = {
547 .enable = cxo_clk_enable,
548 .disable = cxo_clk_disable,
549 .get_rate = fixed_clk_get_rate,
550 .is_local = local_clk_is_local,
551};
552
553static struct fixed_clk cxo_clk = {
554 .rate = 19200000,
555 .c = {
556 .dbg_name = "cxo_clk",
557 .ops = &clk_ops_cxo,
558 CLK_INIT(cxo_clk.c),
559 },
560};
561
562static struct pll_clk pll2_clk = {
563 .rate = 800000000,
564 .mode_reg = MM_PLL1_MODE_REG,
565 .parent = &pxo_clk.c,
566 .c = {
567 .dbg_name = "pll2_clk",
568 .ops = &clk_ops_pll,
569 CLK_INIT(pll2_clk.c),
570 },
571};
572
Stephen Boyd94625ef2011-07-12 17:06:01 -0700573static struct pll_clk pll3_clk = {
574 .rate = 1200000000,
575 .mode_reg = BB_MMCC_PLL2_MODE_REG,
576 .parent = &pxo_clk.c,
577 .c = {
578 .dbg_name = "pll3_clk",
579 .ops = &clk_ops_pll,
Matt Wagantallc57577d2011-10-06 17:06:53 -0700580 .vdd_class = &vdd_l23,
581 .fmax[VDD_L23_ON] = ULONG_MAX,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700582 CLK_INIT(pll3_clk.c),
583 },
584};
585
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700586static struct pll_vote_clk pll4_clk = {
587 .rate = 393216000,
588 .en_reg = BB_PLL_ENA_SC0_REG,
589 .en_mask = BIT(4),
590 .status_reg = LCC_PLL0_STATUS_REG,
591 .parent = &pxo_clk.c,
592 .c = {
593 .dbg_name = "pll4_clk",
594 .ops = &clk_ops_pll_vote,
595 CLK_INIT(pll4_clk.c),
596 },
597};
598
599static struct pll_vote_clk pll8_clk = {
600 .rate = 384000000,
601 .en_reg = BB_PLL_ENA_SC0_REG,
602 .en_mask = BIT(8),
603 .status_reg = BB_PLL8_STATUS_REG,
604 .parent = &pxo_clk.c,
605 .c = {
606 .dbg_name = "pll8_clk",
607 .ops = &clk_ops_pll_vote,
608 CLK_INIT(pll8_clk.c),
609 },
610};
611
Stephen Boyd94625ef2011-07-12 17:06:01 -0700612static struct pll_vote_clk pll14_clk = {
613 .rate = 480000000,
614 .en_reg = BB_PLL_ENA_SC0_REG,
615 .en_mask = BIT(14),
616 .status_reg = BB_PLL14_STATUS_REG,
617 .parent = &pxo_clk.c,
618 .c = {
619 .dbg_name = "pll14_clk",
620 .ops = &clk_ops_pll_vote,
621 CLK_INIT(pll14_clk.c),
622 },
623};
624
Tianyi Gou41515e22011-09-01 19:37:43 -0700625static struct pll_clk pll15_clk = {
626 .rate = 975000000,
627 .mode_reg = MM_PLL3_MODE_REG,
628 .parent = &pxo_clk.c,
629 .c = {
630 .dbg_name = "pll15_clk",
631 .ops = &clk_ops_pll,
632 CLK_INIT(pll15_clk.c),
633 },
634};
635
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700636static struct clk_ops clk_ops_rcg_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700637 .enable = rcg_clk_enable,
638 .disable = rcg_clk_disable,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800639 .enable_hwcg = rcg_clk_enable_hwcg,
640 .disable_hwcg = rcg_clk_disable_hwcg,
641 .in_hwcg_mode = rcg_clk_in_hwcg_mode,
Matt Wagantall41af0772011-09-17 12:21:39 -0700642 .auto_off = rcg_clk_disable,
Matt Wagantall53d968f2011-07-19 13:22:53 -0700643 .handoff = rcg_clk_handoff,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700644 .set_rate = rcg_clk_set_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700645 .get_rate = rcg_clk_get_rate,
646 .list_rate = rcg_clk_list_rate,
647 .is_enabled = rcg_clk_is_enabled,
648 .round_rate = rcg_clk_round_rate,
Stephen Boyd7bf28142011-12-07 00:30:52 -0800649 .reset = rcg_clk_reset,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700650 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700651 .get_parent = rcg_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700652};
653
654static struct clk_ops clk_ops_branch = {
655 .enable = branch_clk_enable,
656 .disable = branch_clk_disable,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800657 .enable_hwcg = branch_clk_enable_hwcg,
658 .disable_hwcg = branch_clk_disable_hwcg,
659 .in_hwcg_mode = branch_clk_in_hwcg_mode,
Matt Wagantall41af0772011-09-17 12:21:39 -0700660 .auto_off = branch_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700661 .is_enabled = branch_clk_is_enabled,
662 .reset = branch_clk_reset,
663 .is_local = local_clk_is_local,
664 .get_parent = branch_clk_get_parent,
665 .set_parent = branch_clk_set_parent,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800666 .handoff = branch_clk_handoff,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700667};
668
669static struct clk_ops clk_ops_reset = {
670 .reset = branch_clk_reset,
671 .is_local = local_clk_is_local,
672};
673
674/* AXI Interfaces */
675static struct branch_clk gmem_axi_clk = {
676 .b = {
677 .ctl_reg = MAXI_EN_REG,
678 .en_mask = BIT(24),
679 .halt_reg = DBG_BUS_VEC_E_REG,
680 .halt_bit = 6,
681 },
682 .c = {
683 .dbg_name = "gmem_axi_clk",
684 .ops = &clk_ops_branch,
685 CLK_INIT(gmem_axi_clk.c),
686 },
687};
688
689static struct branch_clk ijpeg_axi_clk = {
690 .b = {
691 .ctl_reg = MAXI_EN_REG,
692 .en_mask = BIT(21),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800693 .hwcg_reg = MAXI_EN_REG,
694 .hwcg_mask = BIT(11),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700695 .reset_reg = SW_RESET_AXI_REG,
696 .reset_mask = BIT(14),
697 .halt_reg = DBG_BUS_VEC_E_REG,
698 .halt_bit = 4,
699 },
700 .c = {
701 .dbg_name = "ijpeg_axi_clk",
702 .ops = &clk_ops_branch,
703 CLK_INIT(ijpeg_axi_clk.c),
704 },
705};
706
707static struct branch_clk imem_axi_clk = {
708 .b = {
709 .ctl_reg = MAXI_EN_REG,
710 .en_mask = BIT(22),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800711 .hwcg_reg = MAXI_EN_REG,
712 .hwcg_mask = BIT(15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700713 .reset_reg = SW_RESET_CORE_REG,
714 .reset_mask = BIT(10),
715 .halt_reg = DBG_BUS_VEC_E_REG,
716 .halt_bit = 7,
717 },
718 .c = {
719 .dbg_name = "imem_axi_clk",
720 .ops = &clk_ops_branch,
721 CLK_INIT(imem_axi_clk.c),
722 },
723};
724
725static struct branch_clk jpegd_axi_clk = {
726 .b = {
727 .ctl_reg = MAXI_EN_REG,
728 .en_mask = BIT(25),
729 .halt_reg = DBG_BUS_VEC_E_REG,
730 .halt_bit = 5,
731 },
732 .c = {
733 .dbg_name = "jpegd_axi_clk",
734 .ops = &clk_ops_branch,
735 CLK_INIT(jpegd_axi_clk.c),
736 },
737};
738
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700739static struct branch_clk vcodec_axi_b_clk = {
740 .b = {
741 .ctl_reg = MAXI_EN4_REG,
742 .en_mask = BIT(23),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800743 .hwcg_reg = MAXI_EN4_REG,
744 .hwcg_mask = BIT(22),
Stephen Boyd2aa8a4b2011-12-09 18:52:16 -0800745 .reset_reg = SW_RESET_AXI_REG,
746 .reset_mask = BIT(4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700747 .halt_reg = DBG_BUS_VEC_I_REG,
748 .halt_bit = 25,
749 },
750 .c = {
751 .dbg_name = "vcodec_axi_b_clk",
752 .ops = &clk_ops_branch,
753 CLK_INIT(vcodec_axi_b_clk.c),
754 },
755};
756
Matt Wagantall91f42702011-07-14 12:01:15 -0700757static struct branch_clk vcodec_axi_a_clk = {
758 .b = {
759 .ctl_reg = MAXI_EN4_REG,
760 .en_mask = BIT(25),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800761 .hwcg_reg = MAXI_EN4_REG,
762 .hwcg_mask = BIT(24),
Stephen Boyd2aa8a4b2011-12-09 18:52:16 -0800763 .reset_reg = SW_RESET_AXI_REG,
764 .reset_mask = BIT(5),
Matt Wagantall91f42702011-07-14 12:01:15 -0700765 .halt_reg = DBG_BUS_VEC_I_REG,
766 .halt_bit = 26,
767 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700768 .c = {
769 .dbg_name = "vcodec_axi_a_clk",
770 .ops = &clk_ops_branch,
771 CLK_INIT(vcodec_axi_a_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700772 .depends = &vcodec_axi_b_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700773 },
774};
775
776static struct branch_clk vcodec_axi_clk = {
777 .b = {
778 .ctl_reg = MAXI_EN_REG,
779 .en_mask = BIT(19),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800780 .hwcg_reg = MAXI_EN_REG,
781 .hwcg_mask = BIT(13),
Matt Wagantall91f42702011-07-14 12:01:15 -0700782 .reset_reg = SW_RESET_AXI_REG,
Stephen Boyd2aa8a4b2011-12-09 18:52:16 -0800783 .reset_mask = BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700784 .halt_reg = DBG_BUS_VEC_E_REG,
785 .halt_bit = 3,
786 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700787 .c = {
788 .dbg_name = "vcodec_axi_clk",
789 .ops = &clk_ops_branch,
790 CLK_INIT(vcodec_axi_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700791 .depends = &vcodec_axi_a_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700792 },
793};
794
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700795static struct branch_clk vfe_axi_clk = {
796 .b = {
797 .ctl_reg = MAXI_EN_REG,
798 .en_mask = BIT(18),
799 .reset_reg = SW_RESET_AXI_REG,
800 .reset_mask = BIT(9),
801 .halt_reg = DBG_BUS_VEC_E_REG,
802 .halt_bit = 0,
803 },
804 .c = {
805 .dbg_name = "vfe_axi_clk",
806 .ops = &clk_ops_branch,
807 CLK_INIT(vfe_axi_clk.c),
808 },
809};
810
811static struct branch_clk mdp_axi_clk = {
812 .b = {
813 .ctl_reg = MAXI_EN_REG,
814 .en_mask = BIT(23),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800815 .hwcg_reg = MAXI_EN_REG,
816 .hwcg_mask = BIT(16),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700817 .reset_reg = SW_RESET_AXI_REG,
818 .reset_mask = BIT(13),
819 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700820 .halt_bit = 8,
821 },
822 .c = {
823 .dbg_name = "mdp_axi_clk",
824 .ops = &clk_ops_branch,
825 CLK_INIT(mdp_axi_clk.c),
826 },
827};
828
829static struct branch_clk rot_axi_clk = {
830 .b = {
831 .ctl_reg = MAXI_EN2_REG,
832 .en_mask = BIT(24),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800833 .hwcg_reg = MAXI_EN2_REG,
834 .hwcg_mask = BIT(25),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700835 .reset_reg = SW_RESET_AXI_REG,
836 .reset_mask = BIT(6),
837 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700838 .halt_bit = 2,
839 },
840 .c = {
841 .dbg_name = "rot_axi_clk",
842 .ops = &clk_ops_branch,
843 CLK_INIT(rot_axi_clk.c),
844 },
845};
846
847static struct branch_clk vpe_axi_clk = {
848 .b = {
849 .ctl_reg = MAXI_EN2_REG,
850 .en_mask = BIT(26),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800851 .hwcg_reg = MAXI_EN2_REG,
852 .hwcg_mask = BIT(27),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700853 .reset_reg = SW_RESET_AXI_REG,
854 .reset_mask = BIT(15),
855 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700856 .halt_bit = 1,
857 },
858 .c = {
859 .dbg_name = "vpe_axi_clk",
860 .ops = &clk_ops_branch,
861 CLK_INIT(vpe_axi_clk.c),
862 },
863};
864
Tianyi Gou41515e22011-09-01 19:37:43 -0700865static struct branch_clk vcap_axi_clk = {
866 .b = {
867 .ctl_reg = MAXI_EN5_REG,
868 .en_mask = BIT(12),
869 .reset_reg = SW_RESET_AXI_REG,
870 .reset_mask = BIT(16),
871 .halt_reg = DBG_BUS_VEC_J_REG,
872 .halt_bit = 20,
873 },
874 .c = {
875 .dbg_name = "vcap_axi_clk",
876 .ops = &clk_ops_branch,
877 CLK_INIT(vcap_axi_clk.c),
878 },
879};
880
Tianyi Gou621f8742011-09-01 21:45:01 -0700881/* For 8064, gfx3d_axi_clk is set as a dependency of gmem_axi_clk at runtime */
882static struct branch_clk gfx3d_axi_clk = {
883 .b = {
884 .ctl_reg = MAXI_EN5_REG,
885 .en_mask = BIT(25),
886 .reset_reg = SW_RESET_AXI_REG,
887 .reset_mask = BIT(17),
888 .halt_reg = DBG_BUS_VEC_J_REG,
889 .halt_bit = 30,
890 },
891 .c = {
892 .dbg_name = "gfx3d_axi_clk",
893 .ops = &clk_ops_branch,
894 CLK_INIT(gfx3d_axi_clk.c),
895 },
896};
897
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700898/* AHB Interfaces */
899static struct branch_clk amp_p_clk = {
900 .b = {
901 .ctl_reg = AHB_EN_REG,
902 .en_mask = BIT(24),
903 .halt_reg = DBG_BUS_VEC_F_REG,
904 .halt_bit = 18,
905 },
906 .c = {
907 .dbg_name = "amp_p_clk",
908 .ops = &clk_ops_branch,
909 CLK_INIT(amp_p_clk.c),
910 },
911};
912
Matt Wagantallc23eee92011-08-16 23:06:52 -0700913static struct branch_clk csi_p_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700914 .b = {
915 .ctl_reg = AHB_EN_REG,
916 .en_mask = BIT(7),
917 .reset_reg = SW_RESET_AHB_REG,
918 .reset_mask = BIT(17),
919 .halt_reg = DBG_BUS_VEC_F_REG,
920 .halt_bit = 16,
921 },
922 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -0700923 .dbg_name = "csi_p_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700924 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -0700925 CLK_INIT(csi_p_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700926 },
927};
928
929static struct branch_clk dsi1_m_p_clk = {
930 .b = {
931 .ctl_reg = AHB_EN_REG,
932 .en_mask = BIT(9),
933 .reset_reg = SW_RESET_AHB_REG,
934 .reset_mask = BIT(6),
935 .halt_reg = DBG_BUS_VEC_F_REG,
936 .halt_bit = 19,
937 },
938 .c = {
939 .dbg_name = "dsi1_m_p_clk",
940 .ops = &clk_ops_branch,
941 CLK_INIT(dsi1_m_p_clk.c),
942 },
943};
944
945static struct branch_clk dsi1_s_p_clk = {
946 .b = {
947 .ctl_reg = AHB_EN_REG,
948 .en_mask = BIT(18),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800949 .hwcg_reg = AHB_EN2_REG,
950 .hwcg_mask = BIT(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700951 .reset_reg = SW_RESET_AHB_REG,
952 .reset_mask = BIT(5),
953 .halt_reg = DBG_BUS_VEC_F_REG,
954 .halt_bit = 21,
955 },
956 .c = {
957 .dbg_name = "dsi1_s_p_clk",
958 .ops = &clk_ops_branch,
959 CLK_INIT(dsi1_s_p_clk.c),
960 },
961};
962
963static struct branch_clk dsi2_m_p_clk = {
964 .b = {
965 .ctl_reg = AHB_EN_REG,
966 .en_mask = BIT(17),
967 .reset_reg = SW_RESET_AHB2_REG,
968 .reset_mask = BIT(1),
969 .halt_reg = DBG_BUS_VEC_E_REG,
970 .halt_bit = 18,
971 },
972 .c = {
973 .dbg_name = "dsi2_m_p_clk",
974 .ops = &clk_ops_branch,
975 CLK_INIT(dsi2_m_p_clk.c),
976 },
977};
978
979static struct branch_clk dsi2_s_p_clk = {
980 .b = {
981 .ctl_reg = AHB_EN_REG,
982 .en_mask = BIT(22),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800983 .hwcg_reg = AHB_EN2_REG,
984 .hwcg_mask = BIT(15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700985 .reset_reg = SW_RESET_AHB2_REG,
986 .reset_mask = BIT(0),
987 .halt_reg = DBG_BUS_VEC_F_REG,
988 .halt_bit = 20,
989 },
990 .c = {
991 .dbg_name = "dsi2_s_p_clk",
992 .ops = &clk_ops_branch,
993 CLK_INIT(dsi2_s_p_clk.c),
994 },
995};
996
997static struct branch_clk gfx2d0_p_clk = {
998 .b = {
999 .ctl_reg = AHB_EN_REG,
1000 .en_mask = BIT(19),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001001 .hwcg_reg = AHB_EN2_REG,
1002 .hwcg_mask = BIT(28),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001003 .reset_reg = SW_RESET_AHB_REG,
1004 .reset_mask = BIT(12),
1005 .halt_reg = DBG_BUS_VEC_F_REG,
1006 .halt_bit = 2,
1007 },
1008 .c = {
1009 .dbg_name = "gfx2d0_p_clk",
1010 .ops = &clk_ops_branch,
1011 CLK_INIT(gfx2d0_p_clk.c),
1012 },
1013};
1014
1015static struct branch_clk gfx2d1_p_clk = {
1016 .b = {
1017 .ctl_reg = AHB_EN_REG,
1018 .en_mask = BIT(2),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001019 .hwcg_reg = AHB_EN2_REG,
1020 .hwcg_mask = BIT(29),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001021 .reset_reg = SW_RESET_AHB_REG,
1022 .reset_mask = BIT(11),
1023 .halt_reg = DBG_BUS_VEC_F_REG,
1024 .halt_bit = 3,
1025 },
1026 .c = {
1027 .dbg_name = "gfx2d1_p_clk",
1028 .ops = &clk_ops_branch,
1029 CLK_INIT(gfx2d1_p_clk.c),
1030 },
1031};
1032
1033static struct branch_clk gfx3d_p_clk = {
1034 .b = {
1035 .ctl_reg = AHB_EN_REG,
1036 .en_mask = BIT(3),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001037 .hwcg_reg = AHB_EN2_REG,
1038 .hwcg_mask = BIT(27),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001039 .reset_reg = SW_RESET_AHB_REG,
1040 .reset_mask = BIT(10),
1041 .halt_reg = DBG_BUS_VEC_F_REG,
1042 .halt_bit = 4,
1043 },
1044 .c = {
1045 .dbg_name = "gfx3d_p_clk",
1046 .ops = &clk_ops_branch,
1047 CLK_INIT(gfx3d_p_clk.c),
1048 },
1049};
1050
1051static struct branch_clk hdmi_m_p_clk = {
1052 .b = {
1053 .ctl_reg = AHB_EN_REG,
1054 .en_mask = BIT(14),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001055 .hwcg_reg = AHB_EN2_REG,
1056 .hwcg_mask = BIT(21),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001057 .reset_reg = SW_RESET_AHB_REG,
1058 .reset_mask = BIT(9),
1059 .halt_reg = DBG_BUS_VEC_F_REG,
1060 .halt_bit = 5,
1061 },
1062 .c = {
1063 .dbg_name = "hdmi_m_p_clk",
1064 .ops = &clk_ops_branch,
1065 CLK_INIT(hdmi_m_p_clk.c),
1066 },
1067};
1068
1069static struct branch_clk hdmi_s_p_clk = {
1070 .b = {
1071 .ctl_reg = AHB_EN_REG,
1072 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001073 .hwcg_reg = AHB_EN2_REG,
1074 .hwcg_mask = BIT(22),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001075 .reset_reg = SW_RESET_AHB_REG,
1076 .reset_mask = BIT(9),
1077 .halt_reg = DBG_BUS_VEC_F_REG,
1078 .halt_bit = 6,
1079 },
1080 .c = {
1081 .dbg_name = "hdmi_s_p_clk",
1082 .ops = &clk_ops_branch,
1083 CLK_INIT(hdmi_s_p_clk.c),
1084 },
1085};
1086
1087static struct branch_clk ijpeg_p_clk = {
1088 .b = {
1089 .ctl_reg = AHB_EN_REG,
1090 .en_mask = BIT(5),
1091 .reset_reg = SW_RESET_AHB_REG,
1092 .reset_mask = BIT(7),
1093 .halt_reg = DBG_BUS_VEC_F_REG,
1094 .halt_bit = 9,
1095 },
1096 .c = {
1097 .dbg_name = "ijpeg_p_clk",
1098 .ops = &clk_ops_branch,
1099 CLK_INIT(ijpeg_p_clk.c),
1100 },
1101};
1102
1103static struct branch_clk imem_p_clk = {
1104 .b = {
1105 .ctl_reg = AHB_EN_REG,
1106 .en_mask = BIT(6),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001107 .hwcg_reg = AHB_EN2_REG,
1108 .hwcg_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001109 .reset_reg = SW_RESET_AHB_REG,
1110 .reset_mask = BIT(8),
1111 .halt_reg = DBG_BUS_VEC_F_REG,
1112 .halt_bit = 10,
1113 },
1114 .c = {
1115 .dbg_name = "imem_p_clk",
1116 .ops = &clk_ops_branch,
1117 CLK_INIT(imem_p_clk.c),
1118 },
1119};
1120
1121static struct branch_clk jpegd_p_clk = {
1122 .b = {
1123 .ctl_reg = AHB_EN_REG,
1124 .en_mask = BIT(21),
1125 .reset_reg = SW_RESET_AHB_REG,
1126 .reset_mask = BIT(4),
1127 .halt_reg = DBG_BUS_VEC_F_REG,
1128 .halt_bit = 7,
1129 },
1130 .c = {
1131 .dbg_name = "jpegd_p_clk",
1132 .ops = &clk_ops_branch,
1133 CLK_INIT(jpegd_p_clk.c),
1134 },
1135};
1136
1137static struct branch_clk mdp_p_clk = {
1138 .b = {
1139 .ctl_reg = AHB_EN_REG,
1140 .en_mask = BIT(10),
1141 .reset_reg = SW_RESET_AHB_REG,
1142 .reset_mask = BIT(3),
1143 .halt_reg = DBG_BUS_VEC_F_REG,
1144 .halt_bit = 11,
1145 },
1146 .c = {
1147 .dbg_name = "mdp_p_clk",
1148 .ops = &clk_ops_branch,
1149 CLK_INIT(mdp_p_clk.c),
1150 },
1151};
1152
1153static struct branch_clk rot_p_clk = {
1154 .b = {
1155 .ctl_reg = AHB_EN_REG,
1156 .en_mask = BIT(12),
1157 .reset_reg = SW_RESET_AHB_REG,
1158 .reset_mask = BIT(2),
1159 .halt_reg = DBG_BUS_VEC_F_REG,
1160 .halt_bit = 13,
1161 },
1162 .c = {
1163 .dbg_name = "rot_p_clk",
1164 .ops = &clk_ops_branch,
1165 CLK_INIT(rot_p_clk.c),
1166 },
1167};
1168
1169static struct branch_clk smmu_p_clk = {
1170 .b = {
1171 .ctl_reg = AHB_EN_REG,
1172 .en_mask = BIT(15),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001173 .hwcg_reg = AHB_EN_REG,
1174 .hwcg_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001175 .halt_reg = DBG_BUS_VEC_F_REG,
1176 .halt_bit = 22,
1177 },
1178 .c = {
1179 .dbg_name = "smmu_p_clk",
1180 .ops = &clk_ops_branch,
1181 CLK_INIT(smmu_p_clk.c),
1182 },
1183};
1184
1185static struct branch_clk tv_enc_p_clk = {
1186 .b = {
1187 .ctl_reg = AHB_EN_REG,
1188 .en_mask = BIT(25),
1189 .reset_reg = SW_RESET_AHB_REG,
1190 .reset_mask = BIT(15),
1191 .halt_reg = DBG_BUS_VEC_F_REG,
1192 .halt_bit = 23,
1193 },
1194 .c = {
1195 .dbg_name = "tv_enc_p_clk",
1196 .ops = &clk_ops_branch,
1197 CLK_INIT(tv_enc_p_clk.c),
1198 },
1199};
1200
1201static struct branch_clk vcodec_p_clk = {
1202 .b = {
1203 .ctl_reg = AHB_EN_REG,
1204 .en_mask = BIT(11),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001205 .hwcg_reg = AHB_EN2_REG,
1206 .hwcg_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001207 .reset_reg = SW_RESET_AHB_REG,
1208 .reset_mask = BIT(1),
1209 .halt_reg = DBG_BUS_VEC_F_REG,
1210 .halt_bit = 12,
1211 },
1212 .c = {
1213 .dbg_name = "vcodec_p_clk",
1214 .ops = &clk_ops_branch,
1215 CLK_INIT(vcodec_p_clk.c),
1216 },
1217};
1218
1219static struct branch_clk vfe_p_clk = {
1220 .b = {
1221 .ctl_reg = AHB_EN_REG,
1222 .en_mask = BIT(13),
1223 .reset_reg = SW_RESET_AHB_REG,
1224 .reset_mask = BIT(0),
1225 .halt_reg = DBG_BUS_VEC_F_REG,
1226 .halt_bit = 14,
1227 },
1228 .c = {
1229 .dbg_name = "vfe_p_clk",
1230 .ops = &clk_ops_branch,
1231 CLK_INIT(vfe_p_clk.c),
1232 },
1233};
1234
1235static struct branch_clk vpe_p_clk = {
1236 .b = {
1237 .ctl_reg = AHB_EN_REG,
1238 .en_mask = BIT(16),
1239 .reset_reg = SW_RESET_AHB_REG,
1240 .reset_mask = BIT(14),
1241 .halt_reg = DBG_BUS_VEC_F_REG,
1242 .halt_bit = 15,
1243 },
1244 .c = {
1245 .dbg_name = "vpe_p_clk",
1246 .ops = &clk_ops_branch,
1247 CLK_INIT(vpe_p_clk.c),
1248 },
1249};
1250
Tianyi Gou41515e22011-09-01 19:37:43 -07001251static struct branch_clk vcap_p_clk = {
1252 .b = {
1253 .ctl_reg = AHB_EN3_REG,
1254 .en_mask = BIT(1),
1255 .reset_reg = SW_RESET_AHB2_REG,
1256 .reset_mask = BIT(2),
1257 .halt_reg = DBG_BUS_VEC_J_REG,
1258 .halt_bit = 23,
1259 },
1260 .c = {
1261 .dbg_name = "vcap_p_clk",
1262 .ops = &clk_ops_branch,
1263 CLK_INIT(vcap_p_clk.c),
1264 },
1265};
1266
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001267/*
1268 * Peripheral Clocks
1269 */
Matt Wagantall7625a4c2011-11-01 16:17:53 -07001270#define CLK_GP(i, n, h_r, h_b) \
1271 struct rcg_clk i##_clk = { \
1272 .b = { \
1273 .ctl_reg = GPn_NS_REG(n), \
1274 .en_mask = BIT(9), \
1275 .halt_reg = h_r, \
1276 .halt_bit = h_b, \
1277 }, \
1278 .ns_reg = GPn_NS_REG(n), \
1279 .md_reg = GPn_MD_REG(n), \
1280 .root_en_mask = BIT(11), \
1281 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1282 .set_rate = set_rate_mnd, \
1283 .freq_tbl = clk_tbl_gp, \
1284 .current_freq = &rcg_dummy_freq, \
1285 .c = { \
1286 .dbg_name = #i "_clk", \
1287 .ops = &clk_ops_rcg_8960, \
1288 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000), \
1289 CLK_INIT(i##_clk.c), \
1290 }, \
1291 }
1292#define F_GP(f, s, d, m, n) \
1293 { \
1294 .freq_hz = f, \
1295 .src_clk = &s##_clk.c, \
1296 .md_val = MD8(16, m, 0, n), \
1297 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1298 .mnd_en_mask = BIT(8) * !!(n), \
1299 }
1300static struct clk_freq_tbl clk_tbl_gp[] = {
1301 F_GP( 0, gnd, 1, 0, 0),
1302 F_GP( 9600000, cxo, 2, 0, 0),
1303 F_GP( 13500000, pxo, 2, 0, 0),
1304 F_GP( 19200000, cxo, 1, 0, 0),
1305 F_GP( 27000000, pxo, 1, 0, 0),
1306 F_GP( 64000000, pll8, 2, 1, 3),
1307 F_GP( 76800000, pll8, 1, 1, 5),
1308 F_GP( 96000000, pll8, 4, 0, 0),
1309 F_GP(128000000, pll8, 3, 0, 0),
1310 F_GP(192000000, pll8, 2, 0, 0),
1311 F_GP(384000000, pll8, 1, 0, 0),
1312 F_END
1313};
1314
1315static CLK_GP(gp0, 0, CLK_HALT_SFPB_MISC_STATE_REG, 7);
1316static CLK_GP(gp1, 1, CLK_HALT_SFPB_MISC_STATE_REG, 6);
1317static CLK_GP(gp2, 2, CLK_HALT_SFPB_MISC_STATE_REG, 5);
1318
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001319#define CLK_GSBI_UART(i, n, h_r, h_b) \
1320 struct rcg_clk i##_clk = { \
1321 .b = { \
1322 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
1323 .en_mask = BIT(9), \
1324 .reset_reg = GSBIn_RESET_REG(n), \
1325 .reset_mask = BIT(0), \
1326 .halt_reg = h_r, \
1327 .halt_bit = h_b, \
1328 }, \
1329 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
1330 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
1331 .root_en_mask = BIT(11), \
1332 .ns_mask = (BM(31, 16) | BM(6, 0)), \
1333 .set_rate = set_rate_mnd, \
1334 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001335 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001336 .c = { \
1337 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001338 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001339 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001340 CLK_INIT(i##_clk.c), \
1341 }, \
1342 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001343#define F_GSBI_UART(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001344 { \
1345 .freq_hz = f, \
1346 .src_clk = &s##_clk.c, \
1347 .md_val = MD16(m, n), \
1348 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1349 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001350 }
1351static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001352 F_GSBI_UART( 0, gnd, 1, 0, 0),
1353 F_GSBI_UART( 1843200, pll8, 1, 3, 625),
1354 F_GSBI_UART( 3686400, pll8, 1, 6, 625),
1355 F_GSBI_UART( 7372800, pll8, 1, 12, 625),
1356 F_GSBI_UART(14745600, pll8, 1, 24, 625),
1357 F_GSBI_UART(16000000, pll8, 4, 1, 6),
1358 F_GSBI_UART(24000000, pll8, 4, 1, 4),
1359 F_GSBI_UART(32000000, pll8, 4, 1, 3),
1360 F_GSBI_UART(40000000, pll8, 1, 5, 48),
1361 F_GSBI_UART(46400000, pll8, 1, 29, 240),
1362 F_GSBI_UART(48000000, pll8, 4, 1, 2),
1363 F_GSBI_UART(51200000, pll8, 1, 2, 15),
1364 F_GSBI_UART(56000000, pll8, 1, 7, 48),
1365 F_GSBI_UART(58982400, pll8, 1, 96, 625),
1366 F_GSBI_UART(64000000, pll8, 2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001367 F_END
1368};
1369
1370static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1371static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1372static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1373static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1374static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1375static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1376static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1377static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1378static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1379static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1380static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1381static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1382
1383#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1384 struct rcg_clk i##_clk = { \
1385 .b = { \
1386 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1387 .en_mask = BIT(9), \
1388 .reset_reg = GSBIn_RESET_REG(n), \
1389 .reset_mask = BIT(0), \
1390 .halt_reg = h_r, \
1391 .halt_bit = h_b, \
1392 }, \
1393 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1394 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1395 .root_en_mask = BIT(11), \
1396 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1397 .set_rate = set_rate_mnd, \
1398 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001399 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001400 .c = { \
1401 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001402 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001403 VDD_DIG_FMAX_MAP2(LOW, 24000000, NOMINAL, 52000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001404 CLK_INIT(i##_clk.c), \
1405 }, \
1406 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001407#define F_GSBI_QUP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001408 { \
1409 .freq_hz = f, \
1410 .src_clk = &s##_clk.c, \
1411 .md_val = MD8(16, m, 0, n), \
1412 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1413 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001414 }
1415static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001416 F_GSBI_QUP( 0, gnd, 1, 0, 0),
1417 F_GSBI_QUP( 1100000, pxo, 1, 2, 49),
1418 F_GSBI_QUP( 5400000, pxo, 1, 1, 5),
1419 F_GSBI_QUP(10800000, pxo, 1, 2, 5),
1420 F_GSBI_QUP(15060000, pll8, 1, 2, 51),
1421 F_GSBI_QUP(24000000, pll8, 4, 1, 4),
1422 F_GSBI_QUP(25600000, pll8, 1, 1, 15),
1423 F_GSBI_QUP(27000000, pxo, 1, 0, 0),
1424 F_GSBI_QUP(48000000, pll8, 4, 1, 2),
1425 F_GSBI_QUP(51200000, pll8, 1, 2, 15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001426 F_END
1427};
1428
1429static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1430static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1431static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1432static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1433static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1434static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1435static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1436static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1437static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1438static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1439static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1440static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1441
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001442#define F_QDSS(f, s, d) \
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001443 { \
1444 .freq_hz = f, \
1445 .src_clk = &s##_clk.c, \
1446 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001447 }
1448static struct clk_freq_tbl clk_tbl_qdss[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001449 F_QDSS( 27000000, pxo, 1),
1450 F_QDSS(128000000, pll8, 3),
1451 F_QDSS(300000000, pll3, 4),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001452 F_END
1453};
1454
1455struct qdss_bank {
1456 const u32 bank_sel_mask;
1457 void __iomem *const ns_reg;
1458 const u32 ns_mask;
1459};
1460
Stephen Boydd4de6d72011-09-13 13:01:40 -07001461#define QDSS_CLK_ROOT_ENA BIT(1)
1462
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001463static int qdss_clk_handoff(struct clk *c)
Stephen Boydd4de6d72011-09-13 13:01:40 -07001464{
1465 struct rcg_clk *clk = to_rcg_clk(c);
1466 const struct qdss_bank *bank = clk->bank_info;
1467 u32 reg, ns_val, bank_sel;
1468 struct clk_freq_tbl *freq;
1469
1470 reg = readl_relaxed(clk->ns_reg);
1471 if (!(reg & QDSS_CLK_ROOT_ENA))
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001472 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001473
1474 bank_sel = reg & bank->bank_sel_mask;
1475 /* Force bank 1 to PXO if bank 0 is in use */
1476 if (bank_sel == 0)
1477 writel_relaxed(0, bank->ns_reg);
1478 ns_val = readl_relaxed(bank->ns_reg) & bank->ns_mask;
1479 for (freq = clk->freq_tbl; freq->freq_hz != FREQ_END; freq++) {
1480 if ((freq->ns_val & bank->ns_mask) == ns_val) {
1481 pr_info("%s rate=%d\n", clk->c.dbg_name, freq->freq_hz);
1482 break;
1483 }
1484 }
1485 if (freq->freq_hz == FREQ_END)
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001486 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001487
1488 clk->current_freq = freq;
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001489
1490 return 1;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001491}
1492
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001493static void set_rate_qdss(struct rcg_clk *clk, struct clk_freq_tbl *nf)
1494{
1495 const struct qdss_bank *bank = clk->bank_info;
1496 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1497
1498 /* Switch to bank 0 (always sourced from PXO) */
1499 reg = readl_relaxed(clk->ns_reg);
1500 reg &= ~bank_sel_mask;
1501 writel_relaxed(reg, clk->ns_reg);
1502 /*
1503 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1504 * MUX to fully switch sources.
1505 */
1506 mb();
1507 udelay(1);
1508
1509 /* Set source and divider */
1510 reg = readl_relaxed(bank->ns_reg);
1511 reg &= ~bank->ns_mask;
1512 reg |= nf->ns_val;
1513 writel_relaxed(reg, bank->ns_reg);
1514
1515 /* Switch to reprogrammed bank */
1516 reg = readl_relaxed(clk->ns_reg);
1517 reg |= bank_sel_mask;
1518 writel_relaxed(reg, clk->ns_reg);
1519 /*
1520 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1521 * MUX to fully switch sources.
1522 */
1523 mb();
1524 udelay(1);
1525}
1526
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001527static int qdss_clk_enable(struct clk *c)
1528{
1529 struct rcg_clk *clk = to_rcg_clk(c);
1530 const struct qdss_bank *bank = clk->bank_info;
1531 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1532 int ret;
1533
1534 /* Switch to bank 1 */
1535 reg = readl_relaxed(clk->ns_reg);
1536 reg |= bank_sel_mask;
1537 writel_relaxed(reg, clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001538
1539 ret = rcg_clk_enable(c);
1540 if (ret) {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001541 /* Switch to bank 0 */
1542 reg &= ~bank_sel_mask;
1543 writel_relaxed(reg, clk->ns_reg);
1544 }
1545 return ret;
1546}
1547
1548static void qdss_clk_disable(struct clk *c)
1549{
1550 struct rcg_clk *clk = to_rcg_clk(c);
1551 const struct qdss_bank *bank = clk->bank_info;
1552 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1553
1554 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001555 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001556 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001557 reg &= ~bank_sel_mask;
1558 writel_relaxed(reg, clk->ns_reg);
1559}
1560
1561static void qdss_clk_auto_off(struct clk *c)
1562{
1563 struct rcg_clk *clk = to_rcg_clk(c);
1564 const struct qdss_bank *bank = clk->bank_info;
1565 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1566
Matt Wagantall41af0772011-09-17 12:21:39 -07001567 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001568 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001569 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001570 reg &= ~bank_sel_mask;
1571 writel_relaxed(reg, clk->ns_reg);
1572}
1573
1574static struct clk_ops clk_ops_qdss = {
1575 .enable = qdss_clk_enable,
1576 .disable = qdss_clk_disable,
1577 .auto_off = qdss_clk_auto_off,
Stephen Boydd4de6d72011-09-13 13:01:40 -07001578 .handoff = qdss_clk_handoff,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001579 .set_rate = rcg_clk_set_rate,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001580 .get_rate = rcg_clk_get_rate,
1581 .list_rate = rcg_clk_list_rate,
1582 .is_enabled = rcg_clk_is_enabled,
1583 .round_rate = rcg_clk_round_rate,
Stephen Boyd7bf28142011-12-07 00:30:52 -08001584 .reset = rcg_clk_reset,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001585 .is_local = local_clk_is_local,
1586 .get_parent = rcg_clk_get_parent,
1587};
1588
1589static struct qdss_bank bdiv_info_qdss = {
1590 .bank_sel_mask = BIT(0),
1591 .ns_reg = QDSS_AT_CLK_SRC1_NS_REG,
1592 .ns_mask = BM(6, 0),
1593};
1594
1595static struct rcg_clk qdss_at_clk = {
1596 .b = {
1597 .ctl_reg = QDSS_AT_CLK_NS_REG,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001598 .reset_reg = QDSS_RESETS_REG,
1599 .reset_mask = BIT(0),
Stephen Boydfcfd4dd2011-09-13 12:49:57 -07001600 .halt_check = NOCHECK,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001601 },
1602 .ns_reg = QDSS_AT_CLK_SRC_CTL_REG,
1603 .set_rate = set_rate_qdss,
1604 .freq_tbl = clk_tbl_qdss,
1605 .bank_info = &bdiv_info_qdss,
1606 .current_freq = &rcg_dummy_freq,
1607 .c = {
1608 .dbg_name = "qdss_at_clk",
1609 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001610 VDD_DIG_FMAX_MAP2(LOW, 150000000, NOMINAL, 300000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001611 CLK_INIT(qdss_at_clk.c),
1612 },
1613};
1614
1615static struct branch_clk qdss_pclkdbg_clk = {
1616 .b = {
1617 .ctl_reg = QDSS_AT_CLK_NS_REG,
1618 .en_mask = BIT(4),
1619 .reset_reg = QDSS_RESETS_REG,
1620 .reset_mask = BIT(0),
1621 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1622 .halt_bit = 9,
1623 .halt_check = HALT_VOTED
1624 },
1625 .parent = &qdss_at_clk.c,
1626 .c = {
1627 .dbg_name = "qdss_pclkdbg_clk",
1628 .ops = &clk_ops_branch,
1629 CLK_INIT(qdss_pclkdbg_clk.c),
1630 },
1631};
1632
1633static struct qdss_bank bdiv_info_qdss_trace = {
1634 .bank_sel_mask = BIT(0),
1635 .ns_reg = QDSS_TRACECLKIN_CLK_SRC1_NS_REG,
1636 .ns_mask = BM(6, 0),
1637};
1638
1639static struct rcg_clk qdss_traceclkin_clk = {
1640 .b = {
1641 .ctl_reg = QDSS_TRACECLKIN_CTL_REG,
1642 .en_mask = BIT(4),
1643 .reset_reg = QDSS_RESETS_REG,
1644 .reset_mask = BIT(0),
1645 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1646 .halt_bit = 8,
1647 .halt_check = HALT_VOTED,
1648 },
1649 .ns_reg = QDSS_TRACECLKIN_CLK_SRC_CTL_REG,
1650 .set_rate = set_rate_qdss,
1651 .freq_tbl = clk_tbl_qdss,
1652 .bank_info = &bdiv_info_qdss_trace,
1653 .current_freq = &rcg_dummy_freq,
1654 .c = {
1655 .dbg_name = "qdss_traceclkin_clk",
1656 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001657 VDD_DIG_FMAX_MAP2(LOW, 150000000, NOMINAL, 300000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001658 CLK_INIT(qdss_traceclkin_clk.c),
1659 },
1660};
1661
1662static struct clk_freq_tbl clk_tbl_qdss_tsctr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001663 F_QDSS( 27000000, pxo, 1),
1664 F_QDSS(200000000, pll3, 6),
1665 F_QDSS(400000000, pll3, 3),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001666 F_END
1667};
1668
1669static struct qdss_bank bdiv_info_qdss_tsctr = {
1670 .bank_sel_mask = BIT(0),
1671 .ns_reg = QDSS_TSCTR_CLK_SRC1_NS_REG,
1672 .ns_mask = BM(6, 0),
1673};
1674
1675static struct rcg_clk qdss_tsctr_clk = {
1676 .b = {
1677 .ctl_reg = QDSS_TSCTR_CTL_REG,
1678 .en_mask = BIT(4),
1679 .reset_reg = QDSS_RESETS_REG,
1680 .reset_mask = BIT(3),
1681 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1682 .halt_bit = 7,
1683 .halt_check = HALT_VOTED,
1684 },
1685 .ns_reg = QDSS_TSCTR_CLK_SRC_CTL_REG,
1686 .set_rate = set_rate_qdss,
1687 .freq_tbl = clk_tbl_qdss_tsctr,
1688 .bank_info = &bdiv_info_qdss_tsctr,
1689 .current_freq = &rcg_dummy_freq,
1690 .c = {
1691 .dbg_name = "qdss_tsctr_clk",
1692 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001693 VDD_DIG_FMAX_MAP2(LOW, 200000000, NOMINAL, 400000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001694 CLK_INIT(qdss_tsctr_clk.c),
1695 },
1696};
1697
1698static struct branch_clk qdss_stm_clk = {
1699 .b = {
1700 .ctl_reg = QDSS_STM_CLK_CTL_REG,
1701 .en_mask = BIT(4),
1702 .reset_reg = QDSS_RESETS_REG,
1703 .reset_mask = BIT(1),
1704 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
1705 .halt_bit = 20,
1706 .halt_check = HALT_VOTED,
1707 },
1708 .c = {
1709 .dbg_name = "qdss_stm_clk",
1710 .ops = &clk_ops_branch,
1711 CLK_INIT(qdss_stm_clk.c),
1712 },
1713};
1714
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001715#define F_PDM(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001716 { \
1717 .freq_hz = f, \
1718 .src_clk = &s##_clk.c, \
1719 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001720 }
1721static struct clk_freq_tbl clk_tbl_pdm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001722 F_PDM( 0, gnd, 1),
1723 F_PDM(27000000, pxo, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001724 F_END
1725};
1726
1727static struct rcg_clk pdm_clk = {
1728 .b = {
1729 .ctl_reg = PDM_CLK_NS_REG,
1730 .en_mask = BIT(9),
1731 .reset_reg = PDM_CLK_NS_REG,
1732 .reset_mask = BIT(12),
1733 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1734 .halt_bit = 3,
1735 },
1736 .ns_reg = PDM_CLK_NS_REG,
1737 .root_en_mask = BIT(11),
1738 .ns_mask = BM(1, 0),
1739 .set_rate = set_rate_nop,
1740 .freq_tbl = clk_tbl_pdm,
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 = "pdm_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_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001746 CLK_INIT(pdm_clk.c),
1747 },
1748};
1749
1750static struct branch_clk pmem_clk = {
1751 .b = {
1752 .ctl_reg = PMEM_ACLK_CTL_REG,
1753 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001754 .hwcg_reg = PMEM_ACLK_CTL_REG,
1755 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001756 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1757 .halt_bit = 20,
1758 },
1759 .c = {
1760 .dbg_name = "pmem_clk",
1761 .ops = &clk_ops_branch,
1762 CLK_INIT(pmem_clk.c),
1763 },
1764};
1765
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001766#define F_PRNG(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001767 { \
1768 .freq_hz = f, \
1769 .src_clk = &s##_clk.c, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001770 }
1771static struct clk_freq_tbl clk_tbl_prng[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001772 F_PRNG(64000000, pll8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001773 F_END
1774};
1775
1776static struct rcg_clk prng_clk = {
1777 .b = {
1778 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1779 .en_mask = BIT(10),
1780 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1781 .halt_check = HALT_VOTED,
1782 .halt_bit = 10,
1783 },
1784 .set_rate = set_rate_nop,
1785 .freq_tbl = clk_tbl_prng,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001786 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001787 .c = {
1788 .dbg_name = "prng_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001789 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001790 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 65000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001791 CLK_INIT(prng_clk.c),
1792 },
1793};
1794
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001795#define CLK_SDC(name, n, h_b, fmax_low, fmax_nom) \
Stephen Boyda78a7402011-08-02 11:23:39 -07001796 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001797 .b = { \
1798 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1799 .en_mask = BIT(9), \
1800 .reset_reg = SDCn_RESET_REG(n), \
1801 .reset_mask = BIT(0), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001802 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001803 .halt_bit = h_b, \
1804 }, \
1805 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1806 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1807 .root_en_mask = BIT(11), \
1808 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1809 .set_rate = set_rate_mnd, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001810 .freq_tbl = clk_tbl_sdc, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001811 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001812 .c = { \
Stephen Boyda78a7402011-08-02 11:23:39 -07001813 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001814 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001815 VDD_DIG_FMAX_MAP2(LOW, fmax_low, NOMINAL, fmax_nom), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001816 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001817 }, \
1818 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001819#define F_SDC(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001820 { \
1821 .freq_hz = f, \
1822 .src_clk = &s##_clk.c, \
1823 .md_val = MD8(16, m, 0, n), \
1824 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1825 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001826 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001827static struct clk_freq_tbl clk_tbl_sdc[] = {
1828 F_SDC( 0, gnd, 1, 0, 0),
1829 F_SDC( 144000, pxo, 3, 2, 125),
1830 F_SDC( 400000, pll8, 4, 1, 240),
1831 F_SDC( 16000000, pll8, 4, 1, 6),
1832 F_SDC( 17070000, pll8, 1, 2, 45),
1833 F_SDC( 20210000, pll8, 1, 1, 19),
1834 F_SDC( 24000000, pll8, 4, 1, 4),
1835 F_SDC( 48000000, pll8, 4, 1, 2),
1836 F_SDC( 64000000, pll8, 3, 1, 2),
1837 F_SDC( 96000000, pll8, 4, 0, 0),
Subhash Jadavanibd238ba2011-11-24 15:12:39 +05301838 F_SDC(192000000, pll8, 2, 0, 0),
Stephen Boyda78a7402011-08-02 11:23:39 -07001839 F_END
1840};
1841
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001842static CLK_SDC(sdc1_clk, 1, 6, 52000000, 104000000);
1843static CLK_SDC(sdc2_clk, 2, 5, 52000000, 104000000);
1844static CLK_SDC(sdc3_clk, 3, 4, 104000000, 208000000);
1845static CLK_SDC(sdc4_clk, 4, 3, 33000000, 67000000);
1846static CLK_SDC(sdc5_clk, 5, 2, 33000000, 67000000);
Stephen Boyda78a7402011-08-02 11:23:39 -07001847
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001848#define F_TSIF_REF(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001849 { \
1850 .freq_hz = f, \
1851 .src_clk = &s##_clk.c, \
1852 .md_val = MD16(m, n), \
1853 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1854 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001855 }
1856static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001857 F_TSIF_REF( 0, gnd, 1, 0, 0),
1858 F_TSIF_REF(105000, pxo, 1, 1, 256),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001859 F_END
1860};
1861
1862static struct rcg_clk tsif_ref_clk = {
1863 .b = {
1864 .ctl_reg = TSIF_REF_CLK_NS_REG,
1865 .en_mask = BIT(9),
1866 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1867 .halt_bit = 5,
1868 },
1869 .ns_reg = TSIF_REF_CLK_NS_REG,
1870 .md_reg = TSIF_REF_CLK_MD_REG,
1871 .root_en_mask = BIT(11),
1872 .ns_mask = (BM(31, 16) | BM(6, 0)),
1873 .set_rate = set_rate_mnd,
1874 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001875 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001876 .c = {
1877 .dbg_name = "tsif_ref_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001878 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001879 VDD_DIG_FMAX_MAP2(LOW, 27000000, NOMINAL, 54000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001880 CLK_INIT(tsif_ref_clk.c),
1881 },
1882};
1883
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001884#define F_TSSC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001885 { \
1886 .freq_hz = f, \
1887 .src_clk = &s##_clk.c, \
1888 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001889 }
1890static struct clk_freq_tbl clk_tbl_tssc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001891 F_TSSC( 0, gnd),
1892 F_TSSC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001893 F_END
1894};
1895
1896static struct rcg_clk tssc_clk = {
1897 .b = {
1898 .ctl_reg = TSSC_CLK_CTL_REG,
1899 .en_mask = BIT(4),
1900 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1901 .halt_bit = 4,
1902 },
1903 .ns_reg = TSSC_CLK_CTL_REG,
1904 .ns_mask = BM(1, 0),
1905 .set_rate = set_rate_nop,
1906 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001907 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001908 .c = {
1909 .dbg_name = "tssc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001910 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001911 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001912 CLK_INIT(tssc_clk.c),
1913 },
1914};
1915
Tianyi Gou41515e22011-09-01 19:37:43 -07001916#define CLK_USB_HS(name, n, h_b) \
1917 static struct rcg_clk name = { \
1918 .b = { \
1919 .ctl_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1920 .en_mask = BIT(9), \
1921 .reset_reg = USB_HS##n##_RESET_REG, \
1922 .reset_mask = BIT(0), \
1923 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
1924 .halt_bit = h_b, \
1925 }, \
1926 .ns_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1927 .md_reg = USB_HS##n##_XCVR_FS_CLK_MD_REG, \
1928 .root_en_mask = BIT(11), \
1929 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1930 .set_rate = set_rate_mnd, \
1931 .freq_tbl = clk_tbl_usb, \
1932 .current_freq = &rcg_dummy_freq, \
1933 .c = { \
1934 .dbg_name = #name, \
1935 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001936 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001937 CLK_INIT(name.c), \
1938 }, \
1939}
1940
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001941#define F_USB(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001942 { \
1943 .freq_hz = f, \
1944 .src_clk = &s##_clk.c, \
1945 .md_val = MD8(16, m, 0, n), \
1946 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1947 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001948 }
1949static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001950 F_USB( 0, gnd, 1, 0, 0),
1951 F_USB(60000000, pll8, 1, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001952 F_END
1953};
1954
Tianyi Gou41515e22011-09-01 19:37:43 -07001955CLK_USB_HS(usb_hs1_xcvr_clk, 1, 0);
1956CLK_USB_HS(usb_hs3_xcvr_clk, 3, 30);
1957CLK_USB_HS(usb_hs4_xcvr_clk, 4, 2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001958
Stephen Boyd94625ef2011-07-12 17:06:01 -07001959static struct clk_freq_tbl clk_tbl_usb_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001960 F_USB( 0, gnd, 1, 0, 0),
1961 F_USB(60000000, pll8, 1, 5, 32),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001962 F_END
1963};
1964
1965static struct rcg_clk usb_hsic_xcvr_fs_clk = {
1966 .b = {
1967 .ctl_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1968 .en_mask = BIT(9),
1969 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1970 .halt_bit = 26,
1971 },
1972 .ns_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1973 .md_reg = USB_HSIC_XCVR_FS_CLK_MD_REG,
1974 .root_en_mask = BIT(11),
1975 .ns_mask = (BM(23, 16) | BM(6, 0)),
1976 .set_rate = set_rate_mnd,
1977 .freq_tbl = clk_tbl_usb_hsic,
1978 .current_freq = &rcg_dummy_freq,
1979 .c = {
1980 .dbg_name = "usb_hsic_xcvr_fs_clk",
1981 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001982 VDD_DIG_FMAX_MAP1(LOW, 60000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001983 CLK_INIT(usb_hsic_xcvr_fs_clk.c),
1984 },
1985};
1986
1987static struct branch_clk usb_hsic_system_clk = {
1988 .b = {
1989 .ctl_reg = USB_HSIC_SYSTEM_CLK_CTL_REG,
1990 .en_mask = BIT(4),
1991 .reset_reg = USB_HSIC_RESET_REG,
1992 .reset_mask = BIT(0),
1993 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1994 .halt_bit = 24,
1995 },
1996 .parent = &usb_hsic_xcvr_fs_clk.c,
1997 .c = {
1998 .dbg_name = "usb_hsic_system_clk",
1999 .ops = &clk_ops_branch,
2000 CLK_INIT(usb_hsic_system_clk.c),
2001 },
2002};
2003
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002004#define F_USB_HSIC(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002005 { \
2006 .freq_hz = f, \
2007 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002008 }
2009static struct clk_freq_tbl clk_tbl_usb2_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002010 F_USB_HSIC(480000000, pll14),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002011 F_END
2012};
2013
2014static struct rcg_clk usb_hsic_hsic_src_clk = {
2015 .b = {
2016 .ctl_reg = USB_HSIC_HSIC_CLK_SRC_CTL_REG,
2017 .halt_check = NOCHECK,
2018 },
2019 .root_en_mask = BIT(0),
2020 .set_rate = set_rate_nop,
2021 .freq_tbl = clk_tbl_usb2_hsic,
2022 .current_freq = &rcg_dummy_freq,
2023 .c = {
2024 .dbg_name = "usb_hsic_hsic_src_clk",
2025 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002026 VDD_DIG_FMAX_MAP1(LOW, 480000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002027 CLK_INIT(usb_hsic_hsic_src_clk.c),
2028 },
2029};
2030
2031static struct branch_clk usb_hsic_hsic_clk = {
2032 .b = {
2033 .ctl_reg = USB_HSIC_HSIC_CLK_CTL_REG,
2034 .en_mask = BIT(0),
2035 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2036 .halt_bit = 19,
2037 },
2038 .parent = &usb_hsic_hsic_src_clk.c,
2039 .c = {
2040 .dbg_name = "usb_hsic_hsic_clk",
2041 .ops = &clk_ops_branch,
2042 CLK_INIT(usb_hsic_hsic_clk.c),
2043 },
2044};
2045
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002046#define F_USB_HSIO_CAL(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002047 { \
2048 .freq_hz = f, \
2049 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002050 }
2051static struct clk_freq_tbl clk_tbl_usb_hsio_cal[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002052 F_USB_HSIO_CAL(9000000, pxo),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002053 F_END
2054};
2055
2056static struct rcg_clk usb_hsic_hsio_cal_clk = {
2057 .b = {
2058 .ctl_reg = USB_HSIC_HSIO_CAL_CLK_CTL_REG,
2059 .en_mask = BIT(0),
2060 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2061 .halt_bit = 23,
2062 },
2063 .set_rate = set_rate_nop,
2064 .freq_tbl = clk_tbl_usb_hsio_cal,
2065 .current_freq = &rcg_dummy_freq,
2066 .c = {
2067 .dbg_name = "usb_hsic_hsio_cal_clk",
Stephen Boyda0e82ec2011-09-19 12:18:45 -07002068 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002069 VDD_DIG_FMAX_MAP1(LOW, 10000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002070 CLK_INIT(usb_hsic_hsio_cal_clk.c),
2071 },
2072};
2073
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002074static struct branch_clk usb_phy0_clk = {
2075 .b = {
2076 .reset_reg = USB_PHY0_RESET_REG,
2077 .reset_mask = BIT(0),
2078 },
2079 .c = {
2080 .dbg_name = "usb_phy0_clk",
2081 .ops = &clk_ops_reset,
2082 CLK_INIT(usb_phy0_clk.c),
2083 },
2084};
2085
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002086#define CLK_USB_FS(i, n, fmax_nom) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002087 struct rcg_clk i##_clk = { \
2088 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
2089 .b = { \
2090 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
2091 .halt_check = NOCHECK, \
2092 }, \
2093 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
2094 .root_en_mask = BIT(11), \
2095 .ns_mask = (BM(23, 16) | BM(6, 0)), \
2096 .set_rate = set_rate_mnd, \
2097 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002098 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002099 .c = { \
2100 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002101 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002102 VDD_DIG_FMAX_MAP1(NOMINAL, fmax_nom), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002103 CLK_INIT(i##_clk.c), \
2104 }, \
2105 }
2106
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002107static CLK_USB_FS(usb_fs1_src, 1, 64000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002108static struct branch_clk usb_fs1_xcvr_clk = {
2109 .b = {
2110 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
2111 .en_mask = BIT(9),
2112 .reset_reg = USB_FSn_RESET_REG(1),
2113 .reset_mask = BIT(1),
2114 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2115 .halt_bit = 15,
2116 },
2117 .parent = &usb_fs1_src_clk.c,
2118 .c = {
2119 .dbg_name = "usb_fs1_xcvr_clk",
2120 .ops = &clk_ops_branch,
2121 CLK_INIT(usb_fs1_xcvr_clk.c),
2122 },
2123};
2124
2125static struct branch_clk usb_fs1_sys_clk = {
2126 .b = {
2127 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
2128 .en_mask = BIT(4),
2129 .reset_reg = USB_FSn_RESET_REG(1),
2130 .reset_mask = BIT(0),
2131 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2132 .halt_bit = 16,
2133 },
2134 .parent = &usb_fs1_src_clk.c,
2135 .c = {
2136 .dbg_name = "usb_fs1_sys_clk",
2137 .ops = &clk_ops_branch,
2138 CLK_INIT(usb_fs1_sys_clk.c),
2139 },
2140};
2141
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002142static CLK_USB_FS(usb_fs2_src, 2, 60000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002143static struct branch_clk usb_fs2_xcvr_clk = {
2144 .b = {
2145 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
2146 .en_mask = BIT(9),
2147 .reset_reg = USB_FSn_RESET_REG(2),
2148 .reset_mask = BIT(1),
2149 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2150 .halt_bit = 12,
2151 },
2152 .parent = &usb_fs2_src_clk.c,
2153 .c = {
2154 .dbg_name = "usb_fs2_xcvr_clk",
2155 .ops = &clk_ops_branch,
2156 CLK_INIT(usb_fs2_xcvr_clk.c),
2157 },
2158};
2159
2160static struct branch_clk usb_fs2_sys_clk = {
2161 .b = {
2162 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
2163 .en_mask = BIT(4),
2164 .reset_reg = USB_FSn_RESET_REG(2),
2165 .reset_mask = BIT(0),
2166 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2167 .halt_bit = 13,
2168 },
2169 .parent = &usb_fs2_src_clk.c,
2170 .c = {
2171 .dbg_name = "usb_fs2_sys_clk",
2172 .ops = &clk_ops_branch,
2173 CLK_INIT(usb_fs2_sys_clk.c),
2174 },
2175};
2176
2177/* Fast Peripheral Bus Clocks */
2178static struct branch_clk ce1_core_clk = {
2179 .b = {
2180 .ctl_reg = CE1_CORE_CLK_CTL_REG,
2181 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002182 .hwcg_reg = CE1_CORE_CLK_CTL_REG,
2183 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002184 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2185 .halt_bit = 27,
2186 },
2187 .c = {
2188 .dbg_name = "ce1_core_clk",
2189 .ops = &clk_ops_branch,
2190 CLK_INIT(ce1_core_clk.c),
2191 },
2192};
Tianyi Gou41515e22011-09-01 19:37:43 -07002193
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002194static struct branch_clk ce1_p_clk = {
2195 .b = {
2196 .ctl_reg = CE1_HCLK_CTL_REG,
2197 .en_mask = BIT(4),
2198 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2199 .halt_bit = 1,
2200 },
2201 .c = {
2202 .dbg_name = "ce1_p_clk",
2203 .ops = &clk_ops_branch,
2204 CLK_INIT(ce1_p_clk.c),
2205 },
2206};
2207
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002208#define F_CE3(f, s, d) \
Tianyi Gou41515e22011-09-01 19:37:43 -07002209 { \
2210 .freq_hz = f, \
2211 .src_clk = &s##_clk.c, \
2212 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Tianyi Gou41515e22011-09-01 19:37:43 -07002213 }
2214
2215static struct clk_freq_tbl clk_tbl_ce3[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002216 F_CE3( 0, gnd, 1),
2217 F_CE3( 48000000, pll8, 8),
2218 F_CE3(100000000, pll3, 12),
Tianyi Gou41515e22011-09-01 19:37:43 -07002219 F_END
2220};
2221
2222static struct rcg_clk ce3_src_clk = {
2223 .b = {
2224 .ctl_reg = CE3_CLK_SRC_NS_REG,
2225 .halt_check = NOCHECK,
2226 },
2227 .ns_reg = CE3_CLK_SRC_NS_REG,
2228 .root_en_mask = BIT(7),
2229 .ns_mask = BM(6, 0),
2230 .set_rate = set_rate_nop,
2231 .freq_tbl = clk_tbl_ce3,
2232 .current_freq = &rcg_dummy_freq,
2233 .c = {
2234 .dbg_name = "ce3_src_clk",
2235 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002236 VDD_DIG_FMAX_MAP2(LOW, 50000000, NOMINAL, 100000000),
Tianyi Gou41515e22011-09-01 19:37:43 -07002237 CLK_INIT(ce3_src_clk.c),
2238 },
2239};
2240
2241static struct branch_clk ce3_core_clk = {
2242 .b = {
2243 .ctl_reg = CE3_CORE_CLK_CTL_REG,
2244 .en_mask = BIT(4),
2245 .reset_reg = CE3_CORE_CLK_CTL_REG,
2246 .reset_mask = BIT(7),
2247 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2248 .halt_bit = 5,
2249 },
2250 .parent = &ce3_src_clk.c,
2251 .c = {
2252 .dbg_name = "ce3_core_clk",
2253 .ops = &clk_ops_branch,
2254 CLK_INIT(ce3_core_clk.c),
2255 }
2256};
2257
2258static struct branch_clk ce3_p_clk = {
2259 .b = {
2260 .ctl_reg = CE3_HCLK_CTL_REG,
2261 .en_mask = BIT(4),
2262 .reset_reg = CE3_HCLK_CTL_REG,
2263 .reset_mask = BIT(7),
2264 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
2265 .halt_bit = 16,
2266 },
2267 .parent = &ce3_src_clk.c,
2268 .c = {
2269 .dbg_name = "ce3_p_clk",
2270 .ops = &clk_ops_branch,
2271 CLK_INIT(ce3_p_clk.c),
2272 }
2273};
2274
2275static struct branch_clk sata_phy_ref_clk = {
2276 .b = {
2277 .ctl_reg = SATA_PHY_REF_CLK_CTL_REG,
2278 .en_mask = BIT(4),
2279 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2280 .halt_bit = 24,
2281 },
2282 .parent = &pxo_clk.c,
2283 .c = {
2284 .dbg_name = "sata_phy_ref_clk",
2285 .ops = &clk_ops_branch,
2286 CLK_INIT(sata_phy_ref_clk.c),
2287 },
2288};
2289
2290static struct branch_clk pcie_p_clk = {
2291 .b = {
2292 .ctl_reg = PCIE_HCLK_CTL_REG,
2293 .en_mask = BIT(4),
2294 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2295 .halt_bit = 8,
2296 },
2297 .c = {
2298 .dbg_name = "pcie_p_clk",
2299 .ops = &clk_ops_branch,
2300 CLK_INIT(pcie_p_clk.c),
2301 },
2302};
2303
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002304static struct branch_clk dma_bam_p_clk = {
2305 .b = {
2306 .ctl_reg = DMA_BAM_HCLK_CTL,
2307 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002308 .hwcg_reg = DMA_BAM_HCLK_CTL,
2309 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002310 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2311 .halt_bit = 12,
2312 },
2313 .c = {
2314 .dbg_name = "dma_bam_p_clk",
2315 .ops = &clk_ops_branch,
2316 CLK_INIT(dma_bam_p_clk.c),
2317 },
2318};
2319
2320static struct branch_clk gsbi1_p_clk = {
2321 .b = {
2322 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
2323 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002324 .hwcg_reg = GSBIn_HCLK_CTL_REG(1),
2325 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002326 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2327 .halt_bit = 11,
2328 },
2329 .c = {
2330 .dbg_name = "gsbi1_p_clk",
2331 .ops = &clk_ops_branch,
2332 CLK_INIT(gsbi1_p_clk.c),
2333 },
2334};
2335
2336static struct branch_clk gsbi2_p_clk = {
2337 .b = {
2338 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
2339 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002340 .hwcg_reg = GSBIn_HCLK_CTL_REG(2),
2341 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002342 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2343 .halt_bit = 7,
2344 },
2345 .c = {
2346 .dbg_name = "gsbi2_p_clk",
2347 .ops = &clk_ops_branch,
2348 CLK_INIT(gsbi2_p_clk.c),
2349 },
2350};
2351
2352static struct branch_clk gsbi3_p_clk = {
2353 .b = {
2354 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
2355 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002356 .hwcg_reg = GSBIn_HCLK_CTL_REG(3),
2357 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002358 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2359 .halt_bit = 3,
2360 },
2361 .c = {
2362 .dbg_name = "gsbi3_p_clk",
2363 .ops = &clk_ops_branch,
2364 CLK_INIT(gsbi3_p_clk.c),
2365 },
2366};
2367
2368static struct branch_clk gsbi4_p_clk = {
2369 .b = {
2370 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
2371 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002372 .hwcg_reg = GSBIn_HCLK_CTL_REG(4),
2373 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002374 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2375 .halt_bit = 27,
2376 },
2377 .c = {
2378 .dbg_name = "gsbi4_p_clk",
2379 .ops = &clk_ops_branch,
2380 CLK_INIT(gsbi4_p_clk.c),
2381 },
2382};
2383
2384static struct branch_clk gsbi5_p_clk = {
2385 .b = {
2386 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
2387 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002388 .hwcg_reg = GSBIn_HCLK_CTL_REG(5),
2389 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002390 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2391 .halt_bit = 23,
2392 },
2393 .c = {
2394 .dbg_name = "gsbi5_p_clk",
2395 .ops = &clk_ops_branch,
2396 CLK_INIT(gsbi5_p_clk.c),
2397 },
2398};
2399
2400static struct branch_clk gsbi6_p_clk = {
2401 .b = {
2402 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
2403 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002404 .hwcg_reg = GSBIn_HCLK_CTL_REG(6),
2405 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002406 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2407 .halt_bit = 19,
2408 },
2409 .c = {
2410 .dbg_name = "gsbi6_p_clk",
2411 .ops = &clk_ops_branch,
2412 CLK_INIT(gsbi6_p_clk.c),
2413 },
2414};
2415
2416static struct branch_clk gsbi7_p_clk = {
2417 .b = {
2418 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
2419 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002420 .hwcg_reg = GSBIn_HCLK_CTL_REG(7),
2421 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002422 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2423 .halt_bit = 15,
2424 },
2425 .c = {
2426 .dbg_name = "gsbi7_p_clk",
2427 .ops = &clk_ops_branch,
2428 CLK_INIT(gsbi7_p_clk.c),
2429 },
2430};
2431
2432static struct branch_clk gsbi8_p_clk = {
2433 .b = {
2434 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
2435 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002436 .hwcg_reg = GSBIn_HCLK_CTL_REG(8),
2437 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002438 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2439 .halt_bit = 11,
2440 },
2441 .c = {
2442 .dbg_name = "gsbi8_p_clk",
2443 .ops = &clk_ops_branch,
2444 CLK_INIT(gsbi8_p_clk.c),
2445 },
2446};
2447
2448static struct branch_clk gsbi9_p_clk = {
2449 .b = {
2450 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
2451 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002452 .hwcg_reg = GSBIn_HCLK_CTL_REG(9),
2453 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002454 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2455 .halt_bit = 7,
2456 },
2457 .c = {
2458 .dbg_name = "gsbi9_p_clk",
2459 .ops = &clk_ops_branch,
2460 CLK_INIT(gsbi9_p_clk.c),
2461 },
2462};
2463
2464static struct branch_clk gsbi10_p_clk = {
2465 .b = {
2466 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
2467 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002468 .hwcg_reg = GSBIn_HCLK_CTL_REG(10),
2469 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002470 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2471 .halt_bit = 3,
2472 },
2473 .c = {
2474 .dbg_name = "gsbi10_p_clk",
2475 .ops = &clk_ops_branch,
2476 CLK_INIT(gsbi10_p_clk.c),
2477 },
2478};
2479
2480static struct branch_clk gsbi11_p_clk = {
2481 .b = {
2482 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
2483 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002484 .hwcg_reg = GSBIn_HCLK_CTL_REG(11),
2485 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002486 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2487 .halt_bit = 18,
2488 },
2489 .c = {
2490 .dbg_name = "gsbi11_p_clk",
2491 .ops = &clk_ops_branch,
2492 CLK_INIT(gsbi11_p_clk.c),
2493 },
2494};
2495
2496static struct branch_clk gsbi12_p_clk = {
2497 .b = {
2498 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
2499 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002500 .hwcg_reg = GSBIn_HCLK_CTL_REG(12),
2501 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002502 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2503 .halt_bit = 14,
2504 },
2505 .c = {
2506 .dbg_name = "gsbi12_p_clk",
2507 .ops = &clk_ops_branch,
2508 CLK_INIT(gsbi12_p_clk.c),
2509 },
2510};
2511
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002512static struct branch_clk qdss_p_clk = {
2513 .b = {
2514 .ctl_reg = QDSS_HCLK_CTL_REG,
2515 .en_mask = BIT(4),
2516 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2517 .halt_bit = 11,
2518 .halt_check = HALT_VOTED,
2519 .reset_reg = QDSS_RESETS_REG,
2520 .reset_mask = BIT(2),
2521 },
2522 .c = {
2523 .dbg_name = "qdss_p_clk",
2524 .ops = &clk_ops_branch,
2525 CLK_INIT(qdss_p_clk.c),
Tianyi Gou41515e22011-09-01 19:37:43 -07002526 }
2527};
2528
2529static struct branch_clk sata_phy_cfg_clk = {
2530 .b = {
2531 .ctl_reg = SATA_PHY_CFG_CLK_CTL_REG,
2532 .en_mask = BIT(4),
2533 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2534 .halt_bit = 12,
2535 },
2536 .c = {
2537 .dbg_name = "sata_phy_cfg_clk",
2538 .ops = &clk_ops_branch,
2539 CLK_INIT(sata_phy_cfg_clk.c),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002540 },
2541};
2542
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002543static struct branch_clk tsif_p_clk = {
2544 .b = {
2545 .ctl_reg = TSIF_HCLK_CTL_REG,
2546 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002547 .hwcg_reg = TSIF_HCLK_CTL_REG,
2548 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002549 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2550 .halt_bit = 7,
2551 },
2552 .c = {
2553 .dbg_name = "tsif_p_clk",
2554 .ops = &clk_ops_branch,
2555 CLK_INIT(tsif_p_clk.c),
2556 },
2557};
2558
2559static struct branch_clk usb_fs1_p_clk = {
2560 .b = {
2561 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
2562 .en_mask = BIT(4),
2563 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2564 .halt_bit = 17,
2565 },
2566 .c = {
2567 .dbg_name = "usb_fs1_p_clk",
2568 .ops = &clk_ops_branch,
2569 CLK_INIT(usb_fs1_p_clk.c),
2570 },
2571};
2572
2573static struct branch_clk usb_fs2_p_clk = {
2574 .b = {
2575 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
2576 .en_mask = BIT(4),
2577 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2578 .halt_bit = 14,
2579 },
2580 .c = {
2581 .dbg_name = "usb_fs2_p_clk",
2582 .ops = &clk_ops_branch,
2583 CLK_INIT(usb_fs2_p_clk.c),
2584 },
2585};
2586
2587static struct branch_clk usb_hs1_p_clk = {
2588 .b = {
2589 .ctl_reg = USB_HS1_HCLK_CTL_REG,
2590 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002591 .hwcg_reg = USB_HS1_HCLK_CTL_REG,
2592 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002593 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2594 .halt_bit = 1,
2595 },
2596 .c = {
2597 .dbg_name = "usb_hs1_p_clk",
2598 .ops = &clk_ops_branch,
2599 CLK_INIT(usb_hs1_p_clk.c),
2600 },
2601};
2602
Tianyi Gou41515e22011-09-01 19:37:43 -07002603static struct branch_clk usb_hs3_p_clk = {
2604 .b = {
2605 .ctl_reg = USB_HS3_HCLK_CTL_REG,
2606 .en_mask = BIT(4),
2607 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2608 .halt_bit = 31,
2609 },
2610 .c = {
2611 .dbg_name = "usb_hs3_p_clk",
2612 .ops = &clk_ops_branch,
2613 CLK_INIT(usb_hs3_p_clk.c),
2614 },
2615};
2616
2617static struct branch_clk usb_hs4_p_clk = {
2618 .b = {
2619 .ctl_reg = USB_HS4_HCLK_CTL_REG,
2620 .en_mask = BIT(4),
2621 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2622 .halt_bit = 7,
2623 },
2624 .c = {
2625 .dbg_name = "usb_hs4_p_clk",
2626 .ops = &clk_ops_branch,
2627 CLK_INIT(usb_hs4_p_clk.c),
2628 },
2629};
2630
Stephen Boyd94625ef2011-07-12 17:06:01 -07002631static struct branch_clk usb_hsic_p_clk = {
2632 .b = {
2633 .ctl_reg = USB_HSIC_HCLK_CTL_REG,
2634 .en_mask = BIT(4),
2635 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2636 .halt_bit = 28,
2637 },
2638 .c = {
2639 .dbg_name = "usb_hsic_p_clk",
2640 .ops = &clk_ops_branch,
2641 CLK_INIT(usb_hsic_p_clk.c),
2642 },
2643};
2644
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002645static struct branch_clk sdc1_p_clk = {
2646 .b = {
2647 .ctl_reg = SDCn_HCLK_CTL_REG(1),
2648 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002649 .hwcg_reg = SDCn_HCLK_CTL_REG(1),
2650 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002651 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2652 .halt_bit = 11,
2653 },
2654 .c = {
2655 .dbg_name = "sdc1_p_clk",
2656 .ops = &clk_ops_branch,
2657 CLK_INIT(sdc1_p_clk.c),
2658 },
2659};
2660
2661static struct branch_clk sdc2_p_clk = {
2662 .b = {
2663 .ctl_reg = SDCn_HCLK_CTL_REG(2),
2664 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002665 .hwcg_reg = SDCn_HCLK_CTL_REG(2),
2666 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002667 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2668 .halt_bit = 10,
2669 },
2670 .c = {
2671 .dbg_name = "sdc2_p_clk",
2672 .ops = &clk_ops_branch,
2673 CLK_INIT(sdc2_p_clk.c),
2674 },
2675};
2676
2677static struct branch_clk sdc3_p_clk = {
2678 .b = {
2679 .ctl_reg = SDCn_HCLK_CTL_REG(3),
2680 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002681 .hwcg_reg = SDCn_HCLK_CTL_REG(3),
2682 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002683 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2684 .halt_bit = 9,
2685 },
2686 .c = {
2687 .dbg_name = "sdc3_p_clk",
2688 .ops = &clk_ops_branch,
2689 CLK_INIT(sdc3_p_clk.c),
2690 },
2691};
2692
2693static struct branch_clk sdc4_p_clk = {
2694 .b = {
2695 .ctl_reg = SDCn_HCLK_CTL_REG(4),
2696 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002697 .hwcg_reg = SDCn_HCLK_CTL_REG(4),
2698 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002699 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2700 .halt_bit = 8,
2701 },
2702 .c = {
2703 .dbg_name = "sdc4_p_clk",
2704 .ops = &clk_ops_branch,
2705 CLK_INIT(sdc4_p_clk.c),
2706 },
2707};
2708
2709static struct branch_clk sdc5_p_clk = {
2710 .b = {
2711 .ctl_reg = SDCn_HCLK_CTL_REG(5),
2712 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002713 .hwcg_reg = SDCn_HCLK_CTL_REG(5),
2714 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002715 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2716 .halt_bit = 7,
2717 },
2718 .c = {
2719 .dbg_name = "sdc5_p_clk",
2720 .ops = &clk_ops_branch,
2721 CLK_INIT(sdc5_p_clk.c),
2722 },
2723};
2724
2725/* HW-Voteable Clocks */
2726static struct branch_clk adm0_clk = {
2727 .b = {
2728 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2729 .en_mask = BIT(2),
2730 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2731 .halt_check = HALT_VOTED,
2732 .halt_bit = 14,
2733 },
2734 .c = {
2735 .dbg_name = "adm0_clk",
2736 .ops = &clk_ops_branch,
2737 CLK_INIT(adm0_clk.c),
2738 },
2739};
2740
2741static struct branch_clk adm0_p_clk = {
2742 .b = {
2743 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2744 .en_mask = BIT(3),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002745 .hwcg_reg = ADM0_PBUS_CLK_CTL_REG,
2746 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002747 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2748 .halt_check = HALT_VOTED,
2749 .halt_bit = 13,
2750 },
2751 .c = {
2752 .dbg_name = "adm0_p_clk",
2753 .ops = &clk_ops_branch,
2754 CLK_INIT(adm0_p_clk.c),
2755 },
2756};
2757
2758static struct branch_clk pmic_arb0_p_clk = {
2759 .b = {
2760 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2761 .en_mask = BIT(8),
2762 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2763 .halt_check = HALT_VOTED,
2764 .halt_bit = 22,
2765 },
2766 .c = {
2767 .dbg_name = "pmic_arb0_p_clk",
2768 .ops = &clk_ops_branch,
2769 CLK_INIT(pmic_arb0_p_clk.c),
2770 },
2771};
2772
2773static struct branch_clk pmic_arb1_p_clk = {
2774 .b = {
2775 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2776 .en_mask = BIT(9),
2777 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2778 .halt_check = HALT_VOTED,
2779 .halt_bit = 21,
2780 },
2781 .c = {
2782 .dbg_name = "pmic_arb1_p_clk",
2783 .ops = &clk_ops_branch,
2784 CLK_INIT(pmic_arb1_p_clk.c),
2785 },
2786};
2787
2788static struct branch_clk pmic_ssbi2_clk = {
2789 .b = {
2790 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2791 .en_mask = BIT(7),
2792 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2793 .halt_check = HALT_VOTED,
2794 .halt_bit = 23,
2795 },
2796 .c = {
2797 .dbg_name = "pmic_ssbi2_clk",
2798 .ops = &clk_ops_branch,
2799 CLK_INIT(pmic_ssbi2_clk.c),
2800 },
2801};
2802
2803static struct branch_clk rpm_msg_ram_p_clk = {
2804 .b = {
2805 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2806 .en_mask = BIT(6),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002807 .hwcg_reg = RPM_MSG_RAM_HCLK_CTL_REG,
2808 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002809 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2810 .halt_check = HALT_VOTED,
2811 .halt_bit = 12,
2812 },
2813 .c = {
2814 .dbg_name = "rpm_msg_ram_p_clk",
2815 .ops = &clk_ops_branch,
2816 CLK_INIT(rpm_msg_ram_p_clk.c),
2817 },
2818};
2819
2820/*
2821 * Multimedia Clocks
2822 */
2823
2824static struct branch_clk amp_clk = {
2825 .b = {
2826 .reset_reg = SW_RESET_CORE_REG,
2827 .reset_mask = BIT(20),
2828 },
2829 .c = {
2830 .dbg_name = "amp_clk",
2831 .ops = &clk_ops_reset,
2832 CLK_INIT(amp_clk.c),
2833 },
2834};
2835
Stephen Boyd94625ef2011-07-12 17:06:01 -07002836#define CLK_CAM(name, n, hb) \
2837 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002838 .b = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002839 .ctl_reg = CAMCLK##n##_CC_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002840 .en_mask = BIT(0), \
2841 .halt_reg = DBG_BUS_VEC_I_REG, \
2842 .halt_bit = hb, \
2843 }, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002844 .ns_reg = CAMCLK##n##_NS_REG, \
2845 .md_reg = CAMCLK##n##_MD_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002846 .root_en_mask = BIT(2), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002847 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002848 .ctl_mask = BM(7, 6), \
2849 .set_rate = set_rate_mnd_8, \
2850 .freq_tbl = clk_tbl_cam, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002851 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002852 .c = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002853 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002854 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002855 VDD_DIG_FMAX_MAP2(LOW, 64000000, NOMINAL, 128000000), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002856 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002857 }, \
2858 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002859#define F_CAM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002860 { \
2861 .freq_hz = f, \
2862 .src_clk = &s##_clk.c, \
2863 .md_val = MD8(8, m, 0, n), \
2864 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2865 .ctl_val = CC(6, n), \
2866 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002867 }
2868static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002869 F_CAM( 0, gnd, 1, 0, 0),
2870 F_CAM( 6000000, pll8, 4, 1, 16),
2871 F_CAM( 8000000, pll8, 4, 1, 12),
2872 F_CAM( 12000000, pll8, 4, 1, 8),
2873 F_CAM( 16000000, pll8, 4, 1, 6),
2874 F_CAM( 19200000, pll8, 4, 1, 5),
2875 F_CAM( 24000000, pll8, 4, 1, 4),
2876 F_CAM( 32000000, pll8, 4, 1, 3),
2877 F_CAM( 48000000, pll8, 4, 1, 2),
2878 F_CAM( 64000000, pll8, 3, 1, 2),
2879 F_CAM( 96000000, pll8, 4, 0, 0),
2880 F_CAM(128000000, pll8, 3, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002881 F_END
2882};
2883
Stephen Boyd94625ef2011-07-12 17:06:01 -07002884static CLK_CAM(cam0_clk, 0, 15);
2885static CLK_CAM(cam1_clk, 1, 16);
2886static CLK_CAM(cam2_clk, 2, 31);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002887
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002888#define F_CSI(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002889 { \
2890 .freq_hz = f, \
2891 .src_clk = &s##_clk.c, \
2892 .md_val = MD8(8, m, 0, n), \
2893 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2894 .ctl_val = CC(6, n), \
2895 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002896 }
2897static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002898 F_CSI( 0, gnd, 1, 0, 0),
Stephen Boyd092fd182011-10-21 15:56:30 -07002899 F_CSI( 27000000, pxo, 1, 0, 0),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002900 F_CSI( 85330000, pll8, 1, 2, 9),
2901 F_CSI(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002902 F_END
2903};
2904
2905static struct rcg_clk csi0_src_clk = {
2906 .ns_reg = CSI0_NS_REG,
2907 .b = {
2908 .ctl_reg = CSI0_CC_REG,
2909 .halt_check = NOCHECK,
2910 },
2911 .md_reg = CSI0_MD_REG,
2912 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002913 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002914 .ctl_mask = BM(7, 6),
2915 .set_rate = set_rate_mnd,
2916 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002917 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002918 .c = {
2919 .dbg_name = "csi0_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002920 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002921 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002922 CLK_INIT(csi0_src_clk.c),
2923 },
2924};
2925
2926static struct branch_clk csi0_clk = {
2927 .b = {
2928 .ctl_reg = CSI0_CC_REG,
2929 .en_mask = BIT(0),
2930 .reset_reg = SW_RESET_CORE_REG,
2931 .reset_mask = BIT(8),
2932 .halt_reg = DBG_BUS_VEC_B_REG,
2933 .halt_bit = 13,
2934 },
2935 .parent = &csi0_src_clk.c,
2936 .c = {
2937 .dbg_name = "csi0_clk",
2938 .ops = &clk_ops_branch,
2939 CLK_INIT(csi0_clk.c),
2940 },
2941};
2942
2943static struct branch_clk csi0_phy_clk = {
2944 .b = {
2945 .ctl_reg = CSI0_CC_REG,
2946 .en_mask = BIT(8),
2947 .reset_reg = SW_RESET_CORE_REG,
2948 .reset_mask = BIT(29),
2949 .halt_reg = DBG_BUS_VEC_I_REG,
2950 .halt_bit = 9,
2951 },
2952 .parent = &csi0_src_clk.c,
2953 .c = {
2954 .dbg_name = "csi0_phy_clk",
2955 .ops = &clk_ops_branch,
2956 CLK_INIT(csi0_phy_clk.c),
2957 },
2958};
2959
2960static struct rcg_clk csi1_src_clk = {
2961 .ns_reg = CSI1_NS_REG,
2962 .b = {
2963 .ctl_reg = CSI1_CC_REG,
2964 .halt_check = NOCHECK,
2965 },
2966 .md_reg = CSI1_MD_REG,
2967 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002968 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002969 .ctl_mask = BM(7, 6),
2970 .set_rate = set_rate_mnd,
2971 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002972 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002973 .c = {
2974 .dbg_name = "csi1_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002975 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002976 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002977 CLK_INIT(csi1_src_clk.c),
2978 },
2979};
2980
2981static struct branch_clk csi1_clk = {
2982 .b = {
2983 .ctl_reg = CSI1_CC_REG,
2984 .en_mask = BIT(0),
2985 .reset_reg = SW_RESET_CORE_REG,
2986 .reset_mask = BIT(18),
2987 .halt_reg = DBG_BUS_VEC_B_REG,
2988 .halt_bit = 14,
2989 },
2990 .parent = &csi1_src_clk.c,
2991 .c = {
2992 .dbg_name = "csi1_clk",
2993 .ops = &clk_ops_branch,
2994 CLK_INIT(csi1_clk.c),
2995 },
2996};
2997
2998static struct branch_clk csi1_phy_clk = {
2999 .b = {
3000 .ctl_reg = CSI1_CC_REG,
3001 .en_mask = BIT(8),
3002 .reset_reg = SW_RESET_CORE_REG,
3003 .reset_mask = BIT(28),
3004 .halt_reg = DBG_BUS_VEC_I_REG,
3005 .halt_bit = 10,
3006 },
3007 .parent = &csi1_src_clk.c,
3008 .c = {
3009 .dbg_name = "csi1_phy_clk",
3010 .ops = &clk_ops_branch,
3011 CLK_INIT(csi1_phy_clk.c),
3012 },
3013};
3014
Stephen Boyd94625ef2011-07-12 17:06:01 -07003015static struct rcg_clk csi2_src_clk = {
3016 .ns_reg = CSI2_NS_REG,
3017 .b = {
3018 .ctl_reg = CSI2_CC_REG,
3019 .halt_check = NOCHECK,
3020 },
3021 .md_reg = CSI2_MD_REG,
3022 .root_en_mask = BIT(2),
3023 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
3024 .ctl_mask = BM(7, 6),
3025 .set_rate = set_rate_mnd,
3026 .freq_tbl = clk_tbl_csi,
3027 .current_freq = &rcg_dummy_freq,
3028 .c = {
3029 .dbg_name = "csi2_src_clk",
3030 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003031 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003032 CLK_INIT(csi2_src_clk.c),
3033 },
3034};
3035
3036static struct branch_clk csi2_clk = {
3037 .b = {
3038 .ctl_reg = CSI2_CC_REG,
3039 .en_mask = BIT(0),
3040 .reset_reg = SW_RESET_CORE2_REG,
3041 .reset_mask = BIT(2),
3042 .halt_reg = DBG_BUS_VEC_B_REG,
3043 .halt_bit = 29,
3044 },
3045 .parent = &csi2_src_clk.c,
3046 .c = {
3047 .dbg_name = "csi2_clk",
3048 .ops = &clk_ops_branch,
3049 CLK_INIT(csi2_clk.c),
3050 },
3051};
3052
3053static struct branch_clk csi2_phy_clk = {
3054 .b = {
3055 .ctl_reg = CSI2_CC_REG,
3056 .en_mask = BIT(8),
3057 .reset_reg = SW_RESET_CORE_REG,
3058 .reset_mask = BIT(31),
3059 .halt_reg = DBG_BUS_VEC_I_REG,
3060 .halt_bit = 29,
3061 },
3062 .parent = &csi2_src_clk.c,
3063 .c = {
3064 .dbg_name = "csi2_phy_clk",
3065 .ops = &clk_ops_branch,
3066 CLK_INIT(csi2_phy_clk.c),
3067 },
3068};
3069
Stephen Boyd092fd182011-10-21 15:56:30 -07003070static struct clk *pix_rdi_mux_map[] = {
3071 [0] = &csi0_clk.c,
3072 [1] = &csi1_clk.c,
3073 [2] = &csi2_clk.c,
3074 NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003075};
3076
Stephen Boyd092fd182011-10-21 15:56:30 -07003077struct pix_rdi_clk {
3078 bool enabled;
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003079 unsigned long cur_rate;
Stephen Boyd092fd182011-10-21 15:56:30 -07003080
3081 void __iomem *const s_reg;
3082 u32 s_mask;
3083
3084 void __iomem *const s2_reg;
3085 u32 s2_mask;
3086
3087 struct branch b;
3088 struct clk c;
3089};
3090
3091static inline struct pix_rdi_clk *to_pix_rdi_clk(struct clk *clk)
3092{
3093 return container_of(clk, struct pix_rdi_clk, c);
3094}
3095
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003096static int pix_rdi_clk_set_rate(struct clk *c, unsigned long rate)
Stephen Boyd092fd182011-10-21 15:56:30 -07003097{
3098 int ret, i;
3099 u32 reg;
3100 unsigned long flags;
3101 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3102 struct clk **mux_map = pix_rdi_mux_map;
3103
3104 /*
3105 * These clocks select three inputs via two muxes. One mux selects
3106 * between csi0 and csi1 and the second mux selects between that mux's
3107 * output and csi2. The source and destination selections for each
3108 * mux must be clocking for the switch to succeed so just turn on
3109 * all three sources because it's easier than figuring out what source
3110 * needs to be on at what time.
3111 */
3112 for (i = 0; mux_map[i]; i++) {
3113 ret = clk_enable(mux_map[i]);
3114 if (ret)
3115 goto err;
3116 }
3117 if (rate >= i) {
3118 ret = -EINVAL;
3119 goto err;
3120 }
3121 /* Keep the new source on when switching inputs of an enabled clock */
3122 if (clk->enabled) {
3123 clk_disable(mux_map[clk->cur_rate]);
3124 clk_enable(mux_map[rate]);
3125 }
3126 spin_lock_irqsave(&local_clock_reg_lock, flags);
3127 reg = readl_relaxed(clk->s2_reg);
3128 reg &= ~clk->s2_mask;
3129 reg |= rate == 2 ? clk->s2_mask : 0;
3130 writel_relaxed(reg, clk->s2_reg);
3131 /*
3132 * Wait at least 6 cycles of slowest clock
3133 * for the glitch-free MUX to fully switch sources.
3134 */
3135 mb();
3136 udelay(1);
3137 reg = readl_relaxed(clk->s_reg);
3138 reg &= ~clk->s_mask;
3139 reg |= rate == 1 ? clk->s_mask : 0;
3140 writel_relaxed(reg, clk->s_reg);
3141 /*
3142 * Wait at least 6 cycles of slowest clock
3143 * for the glitch-free MUX to fully switch sources.
3144 */
3145 mb();
3146 udelay(1);
3147 clk->cur_rate = rate;
3148 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3149err:
3150 for (i--; i >= 0; i--)
3151 clk_disable(mux_map[i]);
3152
3153 return 0;
3154}
3155
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003156static unsigned long pix_rdi_clk_get_rate(struct clk *c)
Stephen Boyd092fd182011-10-21 15:56:30 -07003157{
3158 return to_pix_rdi_clk(c)->cur_rate;
3159}
3160
3161static int pix_rdi_clk_enable(struct clk *c)
3162{
3163 unsigned long flags;
3164 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3165
3166 spin_lock_irqsave(&local_clock_reg_lock, flags);
3167 __branch_clk_enable_reg(&clk->b, clk->c.dbg_name);
3168 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3169 clk->enabled = true;
3170
3171 return 0;
3172}
3173
3174static void pix_rdi_clk_disable(struct clk *c)
3175{
3176 unsigned long flags;
3177 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3178
3179 spin_lock_irqsave(&local_clock_reg_lock, flags);
3180 __branch_clk_disable_reg(&clk->b, clk->c.dbg_name);
3181 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3182 clk->enabled = false;
3183}
3184
3185static int pix_rdi_clk_reset(struct clk *clk, enum clk_reset_action action)
3186{
3187 return branch_reset(&to_pix_rdi_clk(clk)->b, action);
3188}
3189
3190static struct clk *pix_rdi_clk_get_parent(struct clk *c)
3191{
3192 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3193
3194 return pix_rdi_mux_map[clk->cur_rate];
3195}
3196
3197static int pix_rdi_clk_list_rate(struct clk *c, unsigned n)
3198{
3199 if (pix_rdi_mux_map[n])
3200 return n;
3201 return -ENXIO;
3202}
3203
3204static int pix_rdi_clk_handoff(struct clk *c)
3205{
3206 u32 reg;
3207 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3208
3209 reg = readl_relaxed(clk->s_reg);
3210 clk->cur_rate = reg & clk->s_mask ? 1 : 0;
3211 reg = readl_relaxed(clk->s2_reg);
3212 clk->cur_rate = reg & clk->s2_mask ? 2 : clk->cur_rate;
3213 return 0;
3214}
3215
3216static struct clk_ops clk_ops_pix_rdi_8960 = {
3217 .enable = pix_rdi_clk_enable,
3218 .disable = pix_rdi_clk_disable,
3219 .auto_off = pix_rdi_clk_disable,
3220 .handoff = pix_rdi_clk_handoff,
3221 .set_rate = pix_rdi_clk_set_rate,
3222 .get_rate = pix_rdi_clk_get_rate,
3223 .list_rate = pix_rdi_clk_list_rate,
3224 .reset = pix_rdi_clk_reset,
3225 .is_local = local_clk_is_local,
3226 .get_parent = pix_rdi_clk_get_parent,
3227};
3228
3229static struct pix_rdi_clk csi_pix_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003230 .b = {
3231 .ctl_reg = MISC_CC_REG,
3232 .en_mask = BIT(26),
3233 .halt_check = DELAY,
3234 .reset_reg = SW_RESET_CORE_REG,
3235 .reset_mask = BIT(26),
3236 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003237 .s_reg = MISC_CC_REG,
3238 .s_mask = BIT(25),
3239 .s2_reg = MISC_CC3_REG,
3240 .s2_mask = BIT(13),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003241 .c = {
3242 .dbg_name = "csi_pix_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003243 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003244 CLK_INIT(csi_pix_clk.c),
3245 },
3246};
3247
Stephen Boyd092fd182011-10-21 15:56:30 -07003248static struct pix_rdi_clk csi_pix1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003249 .b = {
3250 .ctl_reg = MISC_CC3_REG,
3251 .en_mask = BIT(10),
3252 .halt_check = DELAY,
3253 .reset_reg = SW_RESET_CORE_REG,
3254 .reset_mask = BIT(30),
3255 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003256 .s_reg = MISC_CC3_REG,
3257 .s_mask = BIT(8),
3258 .s2_reg = MISC_CC3_REG,
3259 .s2_mask = BIT(9),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003260 .c = {
3261 .dbg_name = "csi_pix1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003262 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003263 CLK_INIT(csi_pix1_clk.c),
3264 },
3265};
3266
Stephen Boyd092fd182011-10-21 15:56:30 -07003267static struct pix_rdi_clk csi_rdi_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003268 .b = {
3269 .ctl_reg = MISC_CC_REG,
3270 .en_mask = BIT(13),
3271 .halt_check = DELAY,
3272 .reset_reg = SW_RESET_CORE_REG,
3273 .reset_mask = BIT(27),
3274 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003275 .s_reg = MISC_CC_REG,
3276 .s_mask = BIT(12),
3277 .s2_reg = MISC_CC3_REG,
3278 .s2_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003279 .c = {
3280 .dbg_name = "csi_rdi_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003281 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003282 CLK_INIT(csi_rdi_clk.c),
3283 },
3284};
3285
Stephen Boyd092fd182011-10-21 15:56:30 -07003286static struct pix_rdi_clk csi_rdi1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003287 .b = {
3288 .ctl_reg = MISC_CC3_REG,
3289 .en_mask = BIT(2),
3290 .halt_check = DELAY,
3291 .reset_reg = SW_RESET_CORE2_REG,
3292 .reset_mask = BIT(1),
3293 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003294 .s_reg = MISC_CC3_REG,
3295 .s_mask = BIT(0),
3296 .s2_reg = MISC_CC3_REG,
3297 .s2_mask = BIT(1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003298 .c = {
3299 .dbg_name = "csi_rdi1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003300 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003301 CLK_INIT(csi_rdi1_clk.c),
3302 },
3303};
3304
Stephen Boyd092fd182011-10-21 15:56:30 -07003305static struct pix_rdi_clk csi_rdi2_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003306 .b = {
3307 .ctl_reg = MISC_CC3_REG,
3308 .en_mask = BIT(6),
3309 .halt_check = DELAY,
3310 .reset_reg = SW_RESET_CORE2_REG,
3311 .reset_mask = BIT(0),
3312 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003313 .s_reg = MISC_CC3_REG,
3314 .s_mask = BIT(4),
3315 .s2_reg = MISC_CC3_REG,
3316 .s2_mask = BIT(5),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003317 .c = {
3318 .dbg_name = "csi_rdi2_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003319 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003320 CLK_INIT(csi_rdi2_clk.c),
3321 },
3322};
3323
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003324#define F_CSI_PHYTIMER(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003325 { \
3326 .freq_hz = f, \
3327 .src_clk = &s##_clk.c, \
3328 .md_val = MD8(8, m, 0, n), \
3329 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3330 .ctl_val = CC(6, n), \
3331 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003332 }
3333static struct clk_freq_tbl clk_tbl_csi_phytimer[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003334 F_CSI_PHYTIMER( 0, gnd, 1, 0, 0),
3335 F_CSI_PHYTIMER( 85330000, pll8, 1, 2, 9),
3336 F_CSI_PHYTIMER(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003337 F_END
3338};
3339
3340static struct rcg_clk csiphy_timer_src_clk = {
3341 .ns_reg = CSIPHYTIMER_NS_REG,
3342 .b = {
3343 .ctl_reg = CSIPHYTIMER_CC_REG,
3344 .halt_check = NOCHECK,
3345 },
3346 .md_reg = CSIPHYTIMER_MD_REG,
3347 .root_en_mask = BIT(2),
3348 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
3349 .ctl_mask = BM(7, 6),
3350 .set_rate = set_rate_mnd_8,
3351 .freq_tbl = clk_tbl_csi_phytimer,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003352 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003353 .c = {
3354 .dbg_name = "csiphy_timer_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003355 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003356 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003357 CLK_INIT(csiphy_timer_src_clk.c),
3358 },
3359};
3360
3361static struct branch_clk csi0phy_timer_clk = {
3362 .b = {
3363 .ctl_reg = CSIPHYTIMER_CC_REG,
3364 .en_mask = BIT(0),
3365 .halt_reg = DBG_BUS_VEC_I_REG,
3366 .halt_bit = 17,
3367 },
3368 .parent = &csiphy_timer_src_clk.c,
3369 .c = {
3370 .dbg_name = "csi0phy_timer_clk",
3371 .ops = &clk_ops_branch,
3372 CLK_INIT(csi0phy_timer_clk.c),
3373 },
3374};
3375
3376static struct branch_clk csi1phy_timer_clk = {
3377 .b = {
3378 .ctl_reg = CSIPHYTIMER_CC_REG,
3379 .en_mask = BIT(9),
3380 .halt_reg = DBG_BUS_VEC_I_REG,
3381 .halt_bit = 18,
3382 },
3383 .parent = &csiphy_timer_src_clk.c,
3384 .c = {
3385 .dbg_name = "csi1phy_timer_clk",
3386 .ops = &clk_ops_branch,
3387 CLK_INIT(csi1phy_timer_clk.c),
3388 },
3389};
3390
Stephen Boyd94625ef2011-07-12 17:06:01 -07003391static struct branch_clk csi2phy_timer_clk = {
3392 .b = {
3393 .ctl_reg = CSIPHYTIMER_CC_REG,
3394 .en_mask = BIT(11),
3395 .halt_reg = DBG_BUS_VEC_I_REG,
3396 .halt_bit = 30,
3397 },
3398 .parent = &csiphy_timer_src_clk.c,
3399 .c = {
3400 .dbg_name = "csi2phy_timer_clk",
3401 .ops = &clk_ops_branch,
3402 CLK_INIT(csi2phy_timer_clk.c),
3403 },
3404};
3405
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003406#define F_DSI(d) \
3407 { \
3408 .freq_hz = d, \
3409 .ns_val = BVAL(15, 12, (d-1)), \
3410 }
3411/*
3412 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
3413 * without this clock driver knowing. So, overload the clk_set_rate() to set
3414 * the divider (1 to 16) of the clock with respect to the PLL rate.
3415 */
3416static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
3417 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
3418 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
3419 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
3420 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
3421 F_END
3422};
3423
3424static struct rcg_clk dsi1_byte_clk = {
3425 .b = {
3426 .ctl_reg = DSI1_BYTE_CC_REG,
3427 .en_mask = BIT(0),
3428 .reset_reg = SW_RESET_CORE_REG,
3429 .reset_mask = BIT(7),
3430 .halt_reg = DBG_BUS_VEC_B_REG,
3431 .halt_bit = 21,
3432 },
3433 .ns_reg = DSI1_BYTE_NS_REG,
3434 .root_en_mask = BIT(2),
3435 .ns_mask = BM(15, 12),
3436 .set_rate = set_rate_nop,
3437 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003438 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003439 .c = {
3440 .dbg_name = "dsi1_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003441 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003442 CLK_INIT(dsi1_byte_clk.c),
3443 },
3444};
3445
3446static struct rcg_clk dsi2_byte_clk = {
3447 .b = {
3448 .ctl_reg = DSI2_BYTE_CC_REG,
3449 .en_mask = BIT(0),
3450 .reset_reg = SW_RESET_CORE_REG,
3451 .reset_mask = BIT(25),
3452 .halt_reg = DBG_BUS_VEC_B_REG,
3453 .halt_bit = 20,
3454 },
3455 .ns_reg = DSI2_BYTE_NS_REG,
3456 .root_en_mask = BIT(2),
3457 .ns_mask = BM(15, 12),
3458 .set_rate = set_rate_nop,
3459 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003460 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003461 .c = {
3462 .dbg_name = "dsi2_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003463 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003464 CLK_INIT(dsi2_byte_clk.c),
3465 },
3466};
3467
3468static struct rcg_clk dsi1_esc_clk = {
3469 .b = {
3470 .ctl_reg = DSI1_ESC_CC_REG,
3471 .en_mask = BIT(0),
3472 .reset_reg = SW_RESET_CORE_REG,
3473 .halt_reg = DBG_BUS_VEC_I_REG,
3474 .halt_bit = 1,
3475 },
3476 .ns_reg = DSI1_ESC_NS_REG,
3477 .root_en_mask = BIT(2),
3478 .ns_mask = BM(15, 12),
3479 .set_rate = set_rate_nop,
3480 .freq_tbl = clk_tbl_dsi_byte,
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 = "dsi1_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003484 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003485 CLK_INIT(dsi1_esc_clk.c),
3486 },
3487};
3488
3489static struct rcg_clk dsi2_esc_clk = {
3490 .b = {
3491 .ctl_reg = DSI2_ESC_CC_REG,
3492 .en_mask = BIT(0),
3493 .halt_reg = DBG_BUS_VEC_I_REG,
3494 .halt_bit = 3,
3495 },
3496 .ns_reg = DSI2_ESC_NS_REG,
3497 .root_en_mask = BIT(2),
3498 .ns_mask = BM(15, 12),
3499 .set_rate = set_rate_nop,
3500 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003501 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003502 .c = {
3503 .dbg_name = "dsi2_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003504 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003505 CLK_INIT(dsi2_esc_clk.c),
3506 },
3507};
3508
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003509#define F_GFX2D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003510 { \
3511 .freq_hz = f, \
3512 .src_clk = &s##_clk.c, \
3513 .md_val = MD4(4, m, 0, n), \
3514 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
3515 .ctl_val = CC_BANKED(9, 6, n), \
3516 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003517 }
3518static struct clk_freq_tbl clk_tbl_gfx2d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003519 F_GFX2D( 0, gnd, 0, 0),
3520 F_GFX2D( 27000000, pxo, 0, 0),
3521 F_GFX2D( 48000000, pll8, 1, 8),
3522 F_GFX2D( 54857000, pll8, 1, 7),
3523 F_GFX2D( 64000000, pll8, 1, 6),
3524 F_GFX2D( 76800000, pll8, 1, 5),
3525 F_GFX2D( 96000000, pll8, 1, 4),
3526 F_GFX2D(128000000, pll8, 1, 3),
3527 F_GFX2D(145455000, pll2, 2, 11),
3528 F_GFX2D(160000000, pll2, 1, 5),
3529 F_GFX2D(177778000, pll2, 2, 9),
3530 F_GFX2D(200000000, pll2, 1, 4),
3531 F_GFX2D(228571000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003532 F_END
3533};
3534
3535static struct bank_masks bmnd_info_gfx2d0 = {
3536 .bank_sel_mask = BIT(11),
3537 .bank0_mask = {
3538 .md_reg = GFX2D0_MD0_REG,
3539 .ns_mask = BM(23, 20) | BM(5, 3),
3540 .rst_mask = BIT(25),
3541 .mnd_en_mask = BIT(8),
3542 .mode_mask = BM(10, 9),
3543 },
3544 .bank1_mask = {
3545 .md_reg = GFX2D0_MD1_REG,
3546 .ns_mask = BM(19, 16) | BM(2, 0),
3547 .rst_mask = BIT(24),
3548 .mnd_en_mask = BIT(5),
3549 .mode_mask = BM(7, 6),
3550 },
3551};
3552
3553static struct rcg_clk gfx2d0_clk = {
3554 .b = {
3555 .ctl_reg = GFX2D0_CC_REG,
3556 .en_mask = BIT(0),
3557 .reset_reg = SW_RESET_CORE_REG,
3558 .reset_mask = BIT(14),
3559 .halt_reg = DBG_BUS_VEC_A_REG,
3560 .halt_bit = 9,
3561 },
3562 .ns_reg = GFX2D0_NS_REG,
3563 .root_en_mask = BIT(2),
3564 .set_rate = set_rate_mnd_banked,
3565 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003566 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003567 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003568 .c = {
3569 .dbg_name = "gfx2d0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003570 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003571 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3572 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003573 CLK_INIT(gfx2d0_clk.c),
3574 },
3575};
3576
3577static struct bank_masks bmnd_info_gfx2d1 = {
3578 .bank_sel_mask = BIT(11),
3579 .bank0_mask = {
3580 .md_reg = GFX2D1_MD0_REG,
3581 .ns_mask = BM(23, 20) | BM(5, 3),
3582 .rst_mask = BIT(25),
3583 .mnd_en_mask = BIT(8),
3584 .mode_mask = BM(10, 9),
3585 },
3586 .bank1_mask = {
3587 .md_reg = GFX2D1_MD1_REG,
3588 .ns_mask = BM(19, 16) | BM(2, 0),
3589 .rst_mask = BIT(24),
3590 .mnd_en_mask = BIT(5),
3591 .mode_mask = BM(7, 6),
3592 },
3593};
3594
3595static struct rcg_clk gfx2d1_clk = {
3596 .b = {
3597 .ctl_reg = GFX2D1_CC_REG,
3598 .en_mask = BIT(0),
3599 .reset_reg = SW_RESET_CORE_REG,
3600 .reset_mask = BIT(13),
3601 .halt_reg = DBG_BUS_VEC_A_REG,
3602 .halt_bit = 14,
3603 },
3604 .ns_reg = GFX2D1_NS_REG,
3605 .root_en_mask = BIT(2),
3606 .set_rate = set_rate_mnd_banked,
3607 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003608 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003609 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003610 .c = {
3611 .dbg_name = "gfx2d1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003612 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003613 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3614 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003615 CLK_INIT(gfx2d1_clk.c),
3616 },
3617};
3618
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003619#define F_GFX3D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003620 { \
3621 .freq_hz = f, \
3622 .src_clk = &s##_clk.c, \
3623 .md_val = MD4(4, m, 0, n), \
3624 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3625 .ctl_val = CC_BANKED(9, 6, n), \
3626 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003627 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003628
3629static struct clk_freq_tbl clk_tbl_gfx3d_8960[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003630 F_GFX3D( 0, gnd, 0, 0),
3631 F_GFX3D( 27000000, pxo, 0, 0),
3632 F_GFX3D( 48000000, pll8, 1, 8),
3633 F_GFX3D( 54857000, pll8, 1, 7),
3634 F_GFX3D( 64000000, pll8, 1, 6),
3635 F_GFX3D( 76800000, pll8, 1, 5),
3636 F_GFX3D( 96000000, pll8, 1, 4),
3637 F_GFX3D(128000000, pll8, 1, 3),
3638 F_GFX3D(145455000, pll2, 2, 11),
3639 F_GFX3D(160000000, pll2, 1, 5),
3640 F_GFX3D(177778000, pll2, 2, 9),
3641 F_GFX3D(200000000, pll2, 1, 4),
3642 F_GFX3D(228571000, pll2, 2, 7),
3643 F_GFX3D(266667000, pll2, 1, 3),
3644 F_GFX3D(320000000, pll2, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003645 F_END
3646};
3647
Tianyi Gou41515e22011-09-01 19:37:43 -07003648static struct clk_freq_tbl clk_tbl_gfx3d_8960_v2[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003649 F_GFX3D( 0, gnd, 0, 0),
3650 F_GFX3D( 27000000, pxo, 0, 0),
3651 F_GFX3D( 48000000, pll8, 1, 8),
3652 F_GFX3D( 54857000, pll8, 1, 7),
3653 F_GFX3D( 64000000, pll8, 1, 6),
3654 F_GFX3D( 76800000, pll8, 1, 5),
3655 F_GFX3D( 96000000, pll8, 1, 4),
3656 F_GFX3D(128000000, pll8, 1, 3),
3657 F_GFX3D(145455000, pll2, 2, 11),
3658 F_GFX3D(160000000, pll2, 1, 5),
3659 F_GFX3D(177778000, pll2, 2, 9),
3660 F_GFX3D(200000000, pll2, 1, 4),
3661 F_GFX3D(228571000, pll2, 2, 7),
3662 F_GFX3D(266667000, pll2, 1, 3),
3663 F_GFX3D(300000000, pll3, 1, 4),
3664 F_GFX3D(320000000, pll2, 2, 5),
3665 F_GFX3D(400000000, pll2, 1, 2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003666 F_END
3667};
3668
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003669static unsigned long fmax_gfx3d_8960_v2[MAX_VDD_LEVELS] __initdata = {
3670 [VDD_DIG_LOW] = 128000000,
3671 [VDD_DIG_NOMINAL] = 300000000,
3672 [VDD_DIG_HIGH] = 400000000
3673};
3674
Tianyi Gou41515e22011-09-01 19:37:43 -07003675static struct clk_freq_tbl clk_tbl_gfx3d_8064[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003676 F_GFX3D( 0, gnd, 0, 0),
3677 F_GFX3D( 27000000, pxo, 0, 0),
3678 F_GFX3D( 48000000, pll8, 1, 8),
3679 F_GFX3D( 54857000, pll8, 1, 7),
3680 F_GFX3D( 64000000, pll8, 1, 6),
3681 F_GFX3D( 76800000, pll8, 1, 5),
3682 F_GFX3D( 96000000, pll8, 1, 4),
3683 F_GFX3D(128000000, pll8, 1, 3),
3684 F_GFX3D(145455000, pll2, 2, 11),
3685 F_GFX3D(160000000, pll2, 1, 5),
3686 F_GFX3D(177778000, pll2, 2, 9),
3687 F_GFX3D(200000000, pll2, 1, 4),
3688 F_GFX3D(228571000, pll2, 2, 7),
3689 F_GFX3D(266667000, pll2, 1, 3),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07003690 F_GFX3D(325000000, pll15, 1, 3),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003691 F_GFX3D(400000000, pll2, 1, 2),
Tianyi Gou41515e22011-09-01 19:37:43 -07003692 F_END
3693};
3694
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003695static unsigned long fmax_gfx3d_8064[MAX_VDD_LEVELS] __initdata = {
3696 [VDD_DIG_LOW] = 128000000,
3697 [VDD_DIG_NOMINAL] = 325000000,
3698 [VDD_DIG_HIGH] = 400000000
3699};
3700
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003701static struct bank_masks bmnd_info_gfx3d = {
3702 .bank_sel_mask = BIT(11),
3703 .bank0_mask = {
3704 .md_reg = GFX3D_MD0_REG,
3705 .ns_mask = BM(21, 18) | BM(5, 3),
3706 .rst_mask = BIT(23),
3707 .mnd_en_mask = BIT(8),
3708 .mode_mask = BM(10, 9),
3709 },
3710 .bank1_mask = {
3711 .md_reg = GFX3D_MD1_REG,
3712 .ns_mask = BM(17, 14) | BM(2, 0),
3713 .rst_mask = BIT(22),
3714 .mnd_en_mask = BIT(5),
3715 .mode_mask = BM(7, 6),
3716 },
3717};
3718
3719static struct rcg_clk gfx3d_clk = {
3720 .b = {
3721 .ctl_reg = GFX3D_CC_REG,
3722 .en_mask = BIT(0),
3723 .reset_reg = SW_RESET_CORE_REG,
3724 .reset_mask = BIT(12),
3725 .halt_reg = DBG_BUS_VEC_A_REG,
3726 .halt_bit = 4,
3727 },
3728 .ns_reg = GFX3D_NS_REG,
3729 .root_en_mask = BIT(2),
3730 .set_rate = set_rate_mnd_banked,
Tianyi Gou41515e22011-09-01 19:37:43 -07003731 .freq_tbl = clk_tbl_gfx3d_8960,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003732 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003733 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003734 .c = {
3735 .dbg_name = "gfx3d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003736 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003737 VDD_DIG_FMAX_MAP3(LOW, 128000000, NOMINAL, 266667000,
3738 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003739 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003740 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003741 },
3742};
3743
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003744#define F_VCAP(f, s, m, n) \
Tianyi Gou621f8742011-09-01 21:45:01 -07003745 { \
3746 .freq_hz = f, \
3747 .src_clk = &s##_clk.c, \
3748 .md_val = MD4(4, m, 0, n), \
3749 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3750 .ctl_val = CC_BANKED(9, 6, n), \
3751 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Tianyi Gou621f8742011-09-01 21:45:01 -07003752 }
3753
3754static struct clk_freq_tbl clk_tbl_vcap[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003755 F_VCAP( 0, gnd, 0, 0),
3756 F_VCAP( 27000000, pxo, 0, 0),
3757 F_VCAP( 54860000, pll8, 1, 7),
3758 F_VCAP( 64000000, pll8, 1, 6),
3759 F_VCAP( 76800000, pll8, 1, 5),
3760 F_VCAP(128000000, pll8, 1, 3),
3761 F_VCAP(160000000, pll2, 1, 5),
3762 F_VCAP(200000000, pll2, 1, 4),
Tianyi Gou621f8742011-09-01 21:45:01 -07003763 F_END
3764};
3765
3766static struct bank_masks bmnd_info_vcap = {
3767 .bank_sel_mask = BIT(11),
3768 .bank0_mask = {
3769 .md_reg = VCAP_MD0_REG,
3770 .ns_mask = BM(21, 18) | BM(5, 3),
3771 .rst_mask = BIT(23),
3772 .mnd_en_mask = BIT(8),
3773 .mode_mask = BM(10, 9),
3774 },
3775 .bank1_mask = {
3776 .md_reg = VCAP_MD1_REG,
3777 .ns_mask = BM(17, 14) | BM(2, 0),
3778 .rst_mask = BIT(22),
3779 .mnd_en_mask = BIT(5),
3780 .mode_mask = BM(7, 6),
3781 },
3782};
3783
3784static struct rcg_clk vcap_clk = {
3785 .b = {
3786 .ctl_reg = VCAP_CC_REG,
3787 .en_mask = BIT(0),
3788 .halt_reg = DBG_BUS_VEC_J_REG,
3789 .halt_bit = 15,
3790 },
3791 .ns_reg = VCAP_NS_REG,
3792 .root_en_mask = BIT(2),
3793 .set_rate = set_rate_mnd_banked,
3794 .freq_tbl = clk_tbl_vcap,
3795 .bank_info = &bmnd_info_vcap,
3796 .current_freq = &rcg_dummy_freq,
3797 .c = {
3798 .dbg_name = "vcap_clk",
3799 .ops = &clk_ops_rcg_8960,
3800 .depends = &vcap_axi_clk.c,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003801 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000),
Tianyi Gou621f8742011-09-01 21:45:01 -07003802 CLK_INIT(vcap_clk.c),
3803 },
3804};
3805
3806static struct branch_clk vcap_npl_clk = {
3807 .b = {
3808 .ctl_reg = VCAP_CC_REG,
3809 .en_mask = BIT(13),
3810 .halt_reg = DBG_BUS_VEC_J_REG,
3811 .halt_bit = 25,
3812 },
3813 .parent = &vcap_clk.c,
3814 .c = {
3815 .dbg_name = "vcap_npl_clk",
3816 .ops = &clk_ops_branch,
3817 CLK_INIT(vcap_npl_clk.c),
3818 },
3819};
3820
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003821#define F_IJPEG(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003822 { \
3823 .freq_hz = f, \
3824 .src_clk = &s##_clk.c, \
3825 .md_val = MD8(8, m, 0, n), \
3826 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
3827 .ctl_val = CC(6, n), \
3828 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003829 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003830
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003831static struct clk_freq_tbl clk_tbl_ijpeg[] = {
3832 F_IJPEG( 0, gnd, 1, 0, 0),
3833 F_IJPEG( 27000000, pxo, 1, 0, 0),
3834 F_IJPEG( 36570000, pll8, 1, 2, 21),
3835 F_IJPEG( 54860000, pll8, 7, 0, 0),
3836 F_IJPEG( 96000000, pll8, 4, 0, 0),
3837 F_IJPEG(109710000, pll8, 1, 2, 7),
3838 F_IJPEG(128000000, pll8, 3, 0, 0),
3839 F_IJPEG(153600000, pll8, 1, 2, 5),
3840 F_IJPEG(200000000, pll2, 4, 0, 0),
3841 F_IJPEG(228571000, pll2, 1, 2, 7),
3842 F_IJPEG(266667000, pll2, 1, 1, 3),
3843 F_IJPEG(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003844 F_END
3845};
3846
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003847static unsigned long fmax_ijpeg_8960_v2[MAX_VDD_LEVELS] __initdata = {
3848 [VDD_DIG_LOW] = 110000000,
3849 [VDD_DIG_NOMINAL] = 266667000,
3850 [VDD_DIG_HIGH] = 320000000
3851};
3852
3853static unsigned long fmax_ijpeg_8064[MAX_VDD_LEVELS] __initdata = {
3854 [VDD_DIG_LOW] = 128000000,
3855 [VDD_DIG_NOMINAL] = 266667000,
3856 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07003857};
3858
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003859static struct rcg_clk ijpeg_clk = {
3860 .b = {
3861 .ctl_reg = IJPEG_CC_REG,
3862 .en_mask = BIT(0),
3863 .reset_reg = SW_RESET_CORE_REG,
3864 .reset_mask = BIT(9),
3865 .halt_reg = DBG_BUS_VEC_A_REG,
3866 .halt_bit = 24,
3867 },
3868 .ns_reg = IJPEG_NS_REG,
3869 .md_reg = IJPEG_MD_REG,
3870 .root_en_mask = BIT(2),
3871 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
3872 .ctl_mask = BM(7, 6),
3873 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003874 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003875 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003876 .c = {
3877 .dbg_name = "ijpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003878 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003879 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003880 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003881 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003882 },
3883};
3884
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003885#define F_JPEGD(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003886 { \
3887 .freq_hz = f, \
3888 .src_clk = &s##_clk.c, \
3889 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003890 }
3891static struct clk_freq_tbl clk_tbl_jpegd[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003892 F_JPEGD( 0, gnd, 1),
3893 F_JPEGD( 64000000, pll8, 6),
3894 F_JPEGD( 76800000, pll8, 5),
3895 F_JPEGD( 96000000, pll8, 4),
3896 F_JPEGD(160000000, pll2, 5),
3897 F_JPEGD(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003898 F_END
3899};
3900
3901static struct rcg_clk jpegd_clk = {
3902 .b = {
3903 .ctl_reg = JPEGD_CC_REG,
3904 .en_mask = BIT(0),
3905 .reset_reg = SW_RESET_CORE_REG,
3906 .reset_mask = BIT(19),
3907 .halt_reg = DBG_BUS_VEC_A_REG,
3908 .halt_bit = 19,
3909 },
3910 .ns_reg = JPEGD_NS_REG,
3911 .root_en_mask = BIT(2),
3912 .ns_mask = (BM(15, 12) | BM(2, 0)),
3913 .set_rate = set_rate_nop,
3914 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003915 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003916 .c = {
3917 .dbg_name = "jpegd_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003918 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003919 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003920 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003921 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003922 },
3923};
3924
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003925#define F_MDP(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003926 { \
3927 .freq_hz = f, \
3928 .src_clk = &s##_clk.c, \
3929 .md_val = MD8(8, m, 0, n), \
3930 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
3931 .ctl_val = CC_BANKED(9, 6, n), \
3932 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003933 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003934static struct clk_freq_tbl clk_tbl_mdp[] = {
3935 F_MDP( 0, gnd, 0, 0),
3936 F_MDP( 9600000, pll8, 1, 40),
3937 F_MDP( 13710000, pll8, 1, 28),
3938 F_MDP( 27000000, pxo, 0, 0),
3939 F_MDP( 29540000, pll8, 1, 13),
3940 F_MDP( 34910000, pll8, 1, 11),
3941 F_MDP( 38400000, pll8, 1, 10),
3942 F_MDP( 59080000, pll8, 2, 13),
3943 F_MDP( 76800000, pll8, 1, 5),
3944 F_MDP( 85330000, pll8, 2, 9),
3945 F_MDP( 96000000, pll8, 1, 4),
3946 F_MDP(128000000, pll8, 1, 3),
3947 F_MDP(160000000, pll2, 1, 5),
3948 F_MDP(177780000, pll2, 2, 9),
3949 F_MDP(200000000, pll2, 1, 4),
3950 F_MDP(266667000, pll2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003951 F_END
3952};
3953
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003954static unsigned long fmax_mdp_8064[MAX_VDD_LEVELS] __initdata = {
3955 [VDD_DIG_LOW] = 128000000,
3956 [VDD_DIG_NOMINAL] = 266667000
Tianyi Gou621f8742011-09-01 21:45:01 -07003957};
3958
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003959static struct bank_masks bmnd_info_mdp = {
3960 .bank_sel_mask = BIT(11),
3961 .bank0_mask = {
3962 .md_reg = MDP_MD0_REG,
3963 .ns_mask = BM(29, 22) | BM(5, 3),
3964 .rst_mask = BIT(31),
3965 .mnd_en_mask = BIT(8),
3966 .mode_mask = BM(10, 9),
3967 },
3968 .bank1_mask = {
3969 .md_reg = MDP_MD1_REG,
3970 .ns_mask = BM(21, 14) | BM(2, 0),
3971 .rst_mask = BIT(30),
3972 .mnd_en_mask = BIT(5),
3973 .mode_mask = BM(7, 6),
3974 },
3975};
3976
3977static struct rcg_clk mdp_clk = {
3978 .b = {
3979 .ctl_reg = MDP_CC_REG,
3980 .en_mask = BIT(0),
3981 .reset_reg = SW_RESET_CORE_REG,
3982 .reset_mask = BIT(21),
3983 .halt_reg = DBG_BUS_VEC_C_REG,
3984 .halt_bit = 10,
3985 },
3986 .ns_reg = MDP_NS_REG,
3987 .root_en_mask = BIT(2),
3988 .set_rate = set_rate_mnd_banked,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003989 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003990 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003991 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003992 .c = {
3993 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003994 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003995 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003996 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003997 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003998 },
3999};
4000
4001static struct branch_clk lut_mdp_clk = {
4002 .b = {
4003 .ctl_reg = MDP_LUT_CC_REG,
4004 .en_mask = BIT(0),
4005 .halt_reg = DBG_BUS_VEC_I_REG,
4006 .halt_bit = 13,
4007 },
4008 .parent = &mdp_clk.c,
4009 .c = {
4010 .dbg_name = "lut_mdp_clk",
4011 .ops = &clk_ops_branch,
4012 CLK_INIT(lut_mdp_clk.c),
4013 },
4014};
4015
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004016#define F_MDP_VSYNC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004017 { \
4018 .freq_hz = f, \
4019 .src_clk = &s##_clk.c, \
4020 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004021 }
4022static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004023 F_MDP_VSYNC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004024 F_END
4025};
4026
4027static struct rcg_clk mdp_vsync_clk = {
4028 .b = {
4029 .ctl_reg = MISC_CC_REG,
4030 .en_mask = BIT(6),
4031 .reset_reg = SW_RESET_CORE_REG,
4032 .reset_mask = BIT(3),
4033 .halt_reg = DBG_BUS_VEC_B_REG,
4034 .halt_bit = 22,
4035 },
4036 .ns_reg = MISC_CC2_REG,
4037 .ns_mask = BIT(13),
4038 .set_rate = set_rate_nop,
4039 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004040 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004041 .c = {
4042 .dbg_name = "mdp_vsync_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004043 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004044 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004045 CLK_INIT(mdp_vsync_clk.c),
4046 },
4047};
4048
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004049#define F_ROT(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004050 { \
4051 .freq_hz = f, \
4052 .src_clk = &s##_clk.c, \
4053 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
4054 21, 19, 18, 16, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004055 }
4056static struct clk_freq_tbl clk_tbl_rot[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004057 F_ROT( 0, gnd, 1),
4058 F_ROT( 27000000, pxo, 1),
4059 F_ROT( 29540000, pll8, 13),
4060 F_ROT( 32000000, pll8, 12),
4061 F_ROT( 38400000, pll8, 10),
4062 F_ROT( 48000000, pll8, 8),
4063 F_ROT( 54860000, pll8, 7),
4064 F_ROT( 64000000, pll8, 6),
4065 F_ROT( 76800000, pll8, 5),
4066 F_ROT( 96000000, pll8, 4),
4067 F_ROT(100000000, pll2, 8),
4068 F_ROT(114290000, pll2, 7),
4069 F_ROT(133330000, pll2, 6),
4070 F_ROT(160000000, pll2, 5),
4071 F_ROT(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004072 F_END
4073};
4074
4075static struct bank_masks bdiv_info_rot = {
4076 .bank_sel_mask = BIT(30),
4077 .bank0_mask = {
4078 .ns_mask = BM(25, 22) | BM(18, 16),
4079 },
4080 .bank1_mask = {
4081 .ns_mask = BM(29, 26) | BM(21, 19),
4082 },
4083};
4084
4085static struct rcg_clk rot_clk = {
4086 .b = {
4087 .ctl_reg = ROT_CC_REG,
4088 .en_mask = BIT(0),
4089 .reset_reg = SW_RESET_CORE_REG,
4090 .reset_mask = BIT(2),
4091 .halt_reg = DBG_BUS_VEC_C_REG,
4092 .halt_bit = 15,
4093 },
4094 .ns_reg = ROT_NS_REG,
4095 .root_en_mask = BIT(2),
4096 .set_rate = set_rate_div_banked,
4097 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004098 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004099 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004100 .c = {
4101 .dbg_name = "rot_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004102 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004103 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004104 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004105 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004106 },
4107};
4108
4109static int hdmi_pll_clk_enable(struct clk *clk)
4110{
4111 int ret;
4112 unsigned long flags;
4113 spin_lock_irqsave(&local_clock_reg_lock, flags);
4114 ret = hdmi_pll_enable();
4115 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4116 return ret;
4117}
4118
4119static void hdmi_pll_clk_disable(struct clk *clk)
4120{
4121 unsigned long flags;
4122 spin_lock_irqsave(&local_clock_reg_lock, flags);
4123 hdmi_pll_disable();
4124 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4125}
4126
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07004127static unsigned long hdmi_pll_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004128{
4129 return hdmi_pll_get_rate();
4130}
4131
Stephen Boyd5b35dee2011-09-21 12:17:38 -07004132static struct clk *hdmi_pll_clk_get_parent(struct clk *clk)
4133{
4134 return &pxo_clk.c;
4135}
4136
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004137static struct clk_ops clk_ops_hdmi_pll = {
4138 .enable = hdmi_pll_clk_enable,
4139 .disable = hdmi_pll_clk_disable,
4140 .get_rate = hdmi_pll_clk_get_rate,
4141 .is_local = local_clk_is_local,
Stephen Boyd5b35dee2011-09-21 12:17:38 -07004142 .get_parent = hdmi_pll_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004143};
4144
4145static struct clk hdmi_pll_clk = {
4146 .dbg_name = "hdmi_pll_clk",
4147 .ops = &clk_ops_hdmi_pll,
4148 CLK_INIT(hdmi_pll_clk),
4149};
4150
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004151#define F_TV_GND(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004152 { \
4153 .freq_hz = f, \
4154 .src_clk = &s##_clk.c, \
4155 .md_val = MD8(8, m, 0, n), \
4156 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
4157 .ctl_val = CC(6, n), \
4158 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004159 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004160#define F_TV(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004161 { \
4162 .freq_hz = f, \
4163 .src_clk = &s##_clk, \
4164 .md_val = MD8(8, m, 0, n), \
4165 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
4166 .ctl_val = CC(6, n), \
4167 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004168 .extra_freq_data = (void *)p_r, \
4169 }
4170/* Switching TV freqs requires PLL reconfiguration. */
4171static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004172 F_TV_GND( 0, gnd, 0, 1, 0, 0),
4173 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0),
4174 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0),
4175 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0),
4176 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0),
4177 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004178 F_END
4179};
4180
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004181static unsigned long fmax_tv_src_8064[MAX_VDD_LEVELS] __initdata = {
4182 [VDD_DIG_LOW] = 74250000,
4183 [VDD_DIG_NOMINAL] = 149000000
4184};
4185
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004186/*
4187 * Unlike other clocks, the TV rate is adjusted through PLL
4188 * re-programming. It is also routed through an MND divider.
4189 */
4190void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
4191{
4192 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
4193 if (pll_rate)
4194 hdmi_pll_set_rate(pll_rate);
4195 set_rate_mnd(clk, nf);
4196}
4197
4198static struct rcg_clk tv_src_clk = {
4199 .ns_reg = TV_NS_REG,
4200 .b = {
4201 .ctl_reg = TV_CC_REG,
4202 .halt_check = NOCHECK,
4203 },
4204 .md_reg = TV_MD_REG,
4205 .root_en_mask = BIT(2),
4206 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
4207 .ctl_mask = BM(7, 6),
4208 .set_rate = set_rate_tv,
4209 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004210 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004211 .c = {
4212 .dbg_name = "tv_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004213 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004214 VDD_DIG_FMAX_MAP2(LOW, 27030000, NOMINAL, 149000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004215 CLK_INIT(tv_src_clk.c),
4216 },
4217};
4218
4219static struct branch_clk tv_enc_clk = {
4220 .b = {
4221 .ctl_reg = TV_CC_REG,
4222 .en_mask = BIT(8),
4223 .reset_reg = SW_RESET_CORE_REG,
4224 .reset_mask = BIT(0),
4225 .halt_reg = DBG_BUS_VEC_D_REG,
4226 .halt_bit = 9,
4227 },
4228 .parent = &tv_src_clk.c,
4229 .c = {
4230 .dbg_name = "tv_enc_clk",
4231 .ops = &clk_ops_branch,
4232 CLK_INIT(tv_enc_clk.c),
4233 },
4234};
4235
4236static struct branch_clk tv_dac_clk = {
4237 .b = {
4238 .ctl_reg = TV_CC_REG,
4239 .en_mask = BIT(10),
4240 .halt_reg = DBG_BUS_VEC_D_REG,
4241 .halt_bit = 10,
4242 },
4243 .parent = &tv_src_clk.c,
4244 .c = {
4245 .dbg_name = "tv_dac_clk",
4246 .ops = &clk_ops_branch,
4247 CLK_INIT(tv_dac_clk.c),
4248 },
4249};
4250
4251static struct branch_clk mdp_tv_clk = {
4252 .b = {
4253 .ctl_reg = TV_CC_REG,
4254 .en_mask = BIT(0),
4255 .reset_reg = SW_RESET_CORE_REG,
4256 .reset_mask = BIT(4),
4257 .halt_reg = DBG_BUS_VEC_D_REG,
4258 .halt_bit = 12,
4259 },
4260 .parent = &tv_src_clk.c,
4261 .c = {
4262 .dbg_name = "mdp_tv_clk",
4263 .ops = &clk_ops_branch,
4264 CLK_INIT(mdp_tv_clk.c),
4265 },
4266};
4267
4268static struct branch_clk hdmi_tv_clk = {
4269 .b = {
4270 .ctl_reg = TV_CC_REG,
4271 .en_mask = BIT(12),
4272 .reset_reg = SW_RESET_CORE_REG,
4273 .reset_mask = BIT(1),
4274 .halt_reg = DBG_BUS_VEC_D_REG,
4275 .halt_bit = 11,
4276 },
4277 .parent = &tv_src_clk.c,
4278 .c = {
4279 .dbg_name = "hdmi_tv_clk",
4280 .ops = &clk_ops_branch,
4281 CLK_INIT(hdmi_tv_clk.c),
4282 },
4283};
4284
4285static struct branch_clk hdmi_app_clk = {
4286 .b = {
4287 .ctl_reg = MISC_CC2_REG,
4288 .en_mask = BIT(11),
4289 .reset_reg = SW_RESET_CORE_REG,
4290 .reset_mask = BIT(11),
4291 .halt_reg = DBG_BUS_VEC_B_REG,
4292 .halt_bit = 25,
4293 },
4294 .c = {
4295 .dbg_name = "hdmi_app_clk",
4296 .ops = &clk_ops_branch,
4297 CLK_INIT(hdmi_app_clk.c),
4298 },
4299};
4300
4301static struct bank_masks bmnd_info_vcodec = {
4302 .bank_sel_mask = BIT(13),
4303 .bank0_mask = {
4304 .md_reg = VCODEC_MD0_REG,
4305 .ns_mask = BM(18, 11) | BM(2, 0),
4306 .rst_mask = BIT(31),
4307 .mnd_en_mask = BIT(5),
4308 .mode_mask = BM(7, 6),
4309 },
4310 .bank1_mask = {
4311 .md_reg = VCODEC_MD1_REG,
4312 .ns_mask = BM(26, 19) | BM(29, 27),
4313 .rst_mask = BIT(30),
4314 .mnd_en_mask = BIT(10),
4315 .mode_mask = BM(12, 11),
4316 },
4317};
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004318#define F_VCODEC(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004319 { \
4320 .freq_hz = f, \
4321 .src_clk = &s##_clk.c, \
4322 .md_val = MD8(8, m, 0, n), \
4323 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
4324 .ctl_val = CC_BANKED(6, 11, n), \
4325 .mnd_en_mask = (BIT(10) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004326 }
4327static struct clk_freq_tbl clk_tbl_vcodec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004328 F_VCODEC( 0, gnd, 0, 0),
4329 F_VCODEC( 27000000, pxo, 0, 0),
4330 F_VCODEC( 32000000, pll8, 1, 12),
4331 F_VCODEC( 48000000, pll8, 1, 8),
4332 F_VCODEC( 54860000, pll8, 1, 7),
4333 F_VCODEC( 96000000, pll8, 1, 4),
4334 F_VCODEC(133330000, pll2, 1, 6),
4335 F_VCODEC(200000000, pll2, 1, 4),
4336 F_VCODEC(228570000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004337 F_END
4338};
4339
4340static struct rcg_clk vcodec_clk = {
4341 .b = {
4342 .ctl_reg = VCODEC_CC_REG,
4343 .en_mask = BIT(0),
4344 .reset_reg = SW_RESET_CORE_REG,
4345 .reset_mask = BIT(6),
4346 .halt_reg = DBG_BUS_VEC_C_REG,
4347 .halt_bit = 29,
4348 },
4349 .ns_reg = VCODEC_NS_REG,
4350 .root_en_mask = BIT(2),
4351 .set_rate = set_rate_mnd_banked,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004352 .bank_info = &bmnd_info_vcodec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004353 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004354 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004355 .c = {
4356 .dbg_name = "vcodec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004357 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004358 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
4359 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004360 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004361 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004362 },
4363};
4364
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004365#define F_VPE(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004366 { \
4367 .freq_hz = f, \
4368 .src_clk = &s##_clk.c, \
4369 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004370 }
4371static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004372 F_VPE( 0, gnd, 1),
4373 F_VPE( 27000000, pxo, 1),
4374 F_VPE( 34909000, pll8, 11),
4375 F_VPE( 38400000, pll8, 10),
4376 F_VPE( 64000000, pll8, 6),
4377 F_VPE( 76800000, pll8, 5),
4378 F_VPE( 96000000, pll8, 4),
4379 F_VPE(100000000, pll2, 8),
4380 F_VPE(160000000, pll2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004381 F_END
4382};
4383
4384static struct rcg_clk vpe_clk = {
4385 .b = {
4386 .ctl_reg = VPE_CC_REG,
4387 .en_mask = BIT(0),
4388 .reset_reg = SW_RESET_CORE_REG,
4389 .reset_mask = BIT(17),
4390 .halt_reg = DBG_BUS_VEC_A_REG,
4391 .halt_bit = 28,
4392 },
4393 .ns_reg = VPE_NS_REG,
4394 .root_en_mask = BIT(2),
4395 .ns_mask = (BM(15, 12) | BM(2, 0)),
4396 .set_rate = set_rate_nop,
4397 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004398 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004399 .c = {
4400 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004401 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004402 VDD_DIG_FMAX_MAP2(LOW, 76800000, NOMINAL, 160000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004403 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004404 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004405 },
4406};
4407
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004408#define F_VFE(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004409 { \
4410 .freq_hz = f, \
4411 .src_clk = &s##_clk.c, \
4412 .md_val = MD8(8, m, 0, n), \
4413 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
4414 .ctl_val = CC(6, n), \
4415 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004416 }
Tianyi Gou41515e22011-09-01 19:37:43 -07004417
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004418static struct clk_freq_tbl clk_tbl_vfe[] = {
4419 F_VFE( 0, gnd, 1, 0, 0),
4420 F_VFE( 13960000, pll8, 1, 2, 55),
4421 F_VFE( 27000000, pxo, 1, 0, 0),
4422 F_VFE( 36570000, pll8, 1, 2, 21),
4423 F_VFE( 38400000, pll8, 2, 1, 5),
4424 F_VFE( 45180000, pll8, 1, 2, 17),
4425 F_VFE( 48000000, pll8, 2, 1, 4),
4426 F_VFE( 54860000, pll8, 1, 1, 7),
4427 F_VFE( 64000000, pll8, 2, 1, 3),
4428 F_VFE( 76800000, pll8, 1, 1, 5),
4429 F_VFE( 96000000, pll8, 2, 1, 2),
4430 F_VFE(109710000, pll8, 1, 2, 7),
4431 F_VFE(128000000, pll8, 1, 1, 3),
4432 F_VFE(153600000, pll8, 1, 2, 5),
4433 F_VFE(200000000, pll2, 2, 1, 2),
4434 F_VFE(228570000, pll2, 1, 2, 7),
4435 F_VFE(266667000, pll2, 1, 1, 3),
4436 F_VFE(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004437 F_END
4438};
4439
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004440static unsigned long fmax_vfe_8960_v2[MAX_VDD_LEVELS] __initdata = {
4441 [VDD_DIG_LOW] = 110000000,
4442 [VDD_DIG_NOMINAL] = 266667000,
4443 [VDD_DIG_HIGH] = 320000000
4444};
4445
4446static unsigned long fmax_vfe_8064[MAX_VDD_LEVELS] __initdata = {
4447 [VDD_DIG_LOW] = 128000000,
4448 [VDD_DIG_NOMINAL] = 266667000,
4449 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07004450};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004451
4452static struct rcg_clk vfe_clk = {
4453 .b = {
4454 .ctl_reg = VFE_CC_REG,
4455 .reset_reg = SW_RESET_CORE_REG,
4456 .reset_mask = BIT(15),
4457 .halt_reg = DBG_BUS_VEC_B_REG,
4458 .halt_bit = 6,
4459 .en_mask = BIT(0),
4460 },
4461 .ns_reg = VFE_NS_REG,
4462 .md_reg = VFE_MD_REG,
4463 .root_en_mask = BIT(2),
4464 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
4465 .ctl_mask = BM(7, 6),
4466 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004467 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004468 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004469 .c = {
4470 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004471 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004472 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004473 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004474 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004475 },
4476};
4477
Matt Wagantallc23eee92011-08-16 23:06:52 -07004478static struct branch_clk csi_vfe_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004479 .b = {
4480 .ctl_reg = VFE_CC_REG,
4481 .en_mask = BIT(12),
4482 .reset_reg = SW_RESET_CORE_REG,
4483 .reset_mask = BIT(24),
4484 .halt_reg = DBG_BUS_VEC_B_REG,
4485 .halt_bit = 8,
4486 },
4487 .parent = &vfe_clk.c,
4488 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -07004489 .dbg_name = "csi_vfe_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004490 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -07004491 CLK_INIT(csi_vfe_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004492 },
4493};
4494
4495/*
4496 * Low Power Audio Clocks
4497 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004498#define F_AIF_OSR(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004499 { \
4500 .freq_hz = f, \
4501 .src_clk = &s##_clk.c, \
4502 .md_val = MD8(8, m, 0, n), \
4503 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4504 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004505 }
4506static struct clk_freq_tbl clk_tbl_aif_osr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004507 F_AIF_OSR( 0, gnd, 1, 0, 0),
4508 F_AIF_OSR( 512000, pll4, 4, 1, 192),
4509 F_AIF_OSR( 768000, pll4, 4, 1, 128),
4510 F_AIF_OSR( 1024000, pll4, 4, 1, 96),
4511 F_AIF_OSR( 1536000, pll4, 4, 1, 64),
4512 F_AIF_OSR( 2048000, pll4, 4, 1, 48),
4513 F_AIF_OSR( 3072000, pll4, 4, 1, 32),
4514 F_AIF_OSR( 4096000, pll4, 4, 1, 24),
4515 F_AIF_OSR( 6144000, pll4, 4, 1, 16),
4516 F_AIF_OSR( 8192000, pll4, 4, 1, 12),
4517 F_AIF_OSR(12288000, pll4, 4, 1, 8),
4518 F_AIF_OSR(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004519 F_END
4520};
4521
4522#define CLK_AIF_OSR(i, ns, md, h_r) \
4523 struct rcg_clk i##_clk = { \
4524 .b = { \
4525 .ctl_reg = ns, \
4526 .en_mask = BIT(17), \
4527 .reset_reg = ns, \
4528 .reset_mask = BIT(19), \
4529 .halt_reg = h_r, \
4530 .halt_check = ENABLE, \
4531 .halt_bit = 1, \
4532 }, \
4533 .ns_reg = ns, \
4534 .md_reg = md, \
4535 .root_en_mask = BIT(9), \
4536 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4537 .set_rate = set_rate_mnd, \
4538 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004539 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004540 .c = { \
4541 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004542 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004543 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004544 CLK_INIT(i##_clk.c), \
4545 }, \
4546 }
4547#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
4548 struct rcg_clk i##_clk = { \
4549 .b = { \
4550 .ctl_reg = ns, \
4551 .en_mask = BIT(21), \
4552 .reset_reg = ns, \
4553 .reset_mask = BIT(23), \
4554 .halt_reg = h_r, \
4555 .halt_check = ENABLE, \
4556 .halt_bit = 1, \
4557 }, \
4558 .ns_reg = ns, \
4559 .md_reg = md, \
4560 .root_en_mask = BIT(9), \
4561 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4562 .set_rate = set_rate_mnd, \
4563 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004564 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004565 .c = { \
4566 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004567 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004568 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004569 CLK_INIT(i##_clk.c), \
4570 }, \
4571 }
4572
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004573#define CLK_AIF_BIT(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004574 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004575 .b = { \
4576 .ctl_reg = ns, \
4577 .en_mask = BIT(15), \
4578 .halt_reg = h_r, \
4579 .halt_check = DELAY, \
4580 }, \
4581 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004582 .ext_mask = BIT(14), \
4583 .div_offset = 10, \
4584 .max_div = 16, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004585 .c = { \
4586 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004587 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004588 CLK_INIT(i##_clk.c), \
4589 }, \
4590 }
4591
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004592#define CLK_AIF_BIT_DIV(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004593 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004594 .b = { \
4595 .ctl_reg = ns, \
4596 .en_mask = BIT(19), \
4597 .halt_reg = h_r, \
4598 .halt_check = ENABLE, \
4599 }, \
4600 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004601 .ext_mask = BIT(18), \
4602 .div_offset = 10, \
4603 .max_div = 256, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004604 .c = { \
4605 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004606 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004607 CLK_INIT(i##_clk.c), \
4608 }, \
4609 }
4610
4611static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
4612 LCC_MI2S_STATUS_REG);
4613static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
4614
4615static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
4616 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
4617static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
4618 LCC_CODEC_I2S_MIC_STATUS_REG);
4619
4620static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
4621 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
4622static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
4623 LCC_SPARE_I2S_MIC_STATUS_REG);
4624
4625static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
4626 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
4627static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
4628 LCC_CODEC_I2S_SPKR_STATUS_REG);
4629
4630static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
4631 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
4632static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
4633 LCC_SPARE_I2S_SPKR_STATUS_REG);
4634
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004635#define F_PCM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004636 { \
4637 .freq_hz = f, \
4638 .src_clk = &s##_clk.c, \
4639 .md_val = MD16(m, n), \
4640 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4641 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004642 }
4643static struct clk_freq_tbl clk_tbl_pcm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004644 F_PCM( 0, gnd, 1, 0, 0),
4645 F_PCM( 512000, pll4, 4, 1, 192),
4646 F_PCM( 768000, pll4, 4, 1, 128),
4647 F_PCM( 1024000, pll4, 4, 1, 96),
4648 F_PCM( 1536000, pll4, 4, 1, 64),
4649 F_PCM( 2048000, pll4, 4, 1, 48),
4650 F_PCM( 3072000, pll4, 4, 1, 32),
4651 F_PCM( 4096000, pll4, 4, 1, 24),
4652 F_PCM( 6144000, pll4, 4, 1, 16),
4653 F_PCM( 8192000, pll4, 4, 1, 12),
4654 F_PCM(12288000, pll4, 4, 1, 8),
4655 F_PCM(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004656 F_END
4657};
4658
4659static struct rcg_clk pcm_clk = {
4660 .b = {
4661 .ctl_reg = LCC_PCM_NS_REG,
4662 .en_mask = BIT(11),
4663 .reset_reg = LCC_PCM_NS_REG,
4664 .reset_mask = BIT(13),
4665 .halt_reg = LCC_PCM_STATUS_REG,
4666 .halt_check = ENABLE,
4667 .halt_bit = 0,
4668 },
4669 .ns_reg = LCC_PCM_NS_REG,
4670 .md_reg = LCC_PCM_MD_REG,
4671 .root_en_mask = BIT(9),
4672 .ns_mask = (BM(31, 16) | BM(6, 0)),
4673 .set_rate = set_rate_mnd,
4674 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004675 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004676 .c = {
4677 .dbg_name = "pcm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004678 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004679 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004680 CLK_INIT(pcm_clk.c),
4681 },
4682};
4683
4684static struct rcg_clk audio_slimbus_clk = {
4685 .b = {
4686 .ctl_reg = LCC_SLIMBUS_NS_REG,
4687 .en_mask = BIT(10),
4688 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
4689 .reset_mask = BIT(5),
4690 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4691 .halt_check = ENABLE,
4692 .halt_bit = 0,
4693 },
4694 .ns_reg = LCC_SLIMBUS_NS_REG,
4695 .md_reg = LCC_SLIMBUS_MD_REG,
4696 .root_en_mask = BIT(9),
4697 .ns_mask = (BM(31, 24) | BM(6, 0)),
4698 .set_rate = set_rate_mnd,
4699 .freq_tbl = clk_tbl_aif_osr,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004700 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004701 .c = {
4702 .dbg_name = "audio_slimbus_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004703 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004704 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004705 CLK_INIT(audio_slimbus_clk.c),
4706 },
4707};
4708
4709static struct branch_clk sps_slimbus_clk = {
4710 .b = {
4711 .ctl_reg = LCC_SLIMBUS_NS_REG,
4712 .en_mask = BIT(12),
4713 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4714 .halt_check = ENABLE,
4715 .halt_bit = 1,
4716 },
4717 .parent = &audio_slimbus_clk.c,
4718 .c = {
4719 .dbg_name = "sps_slimbus_clk",
4720 .ops = &clk_ops_branch,
4721 CLK_INIT(sps_slimbus_clk.c),
4722 },
4723};
4724
4725static struct branch_clk slimbus_xo_src_clk = {
4726 .b = {
4727 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
4728 .en_mask = BIT(2),
4729 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004730 .halt_bit = 28,
4731 },
4732 .parent = &sps_slimbus_clk.c,
4733 .c = {
4734 .dbg_name = "slimbus_xo_src_clk",
4735 .ops = &clk_ops_branch,
4736 CLK_INIT(slimbus_xo_src_clk.c),
4737 },
4738};
4739
Matt Wagantall735f01a2011-08-12 12:40:28 -07004740DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
4741DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
4742DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
4743DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
4744DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
4745DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
4746DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
4747DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004748
4749static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
4750static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
Manu Gautam7483f172011-11-08 15:22:26 +05304751static DEFINE_CLK_VOTER(dfab_usb_hs3_clk, &dfab_clk.c);
4752static DEFINE_CLK_VOTER(dfab_usb_hs4_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004753static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
4754static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
4755static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
4756static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
4757static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
4758static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
Stephen Boyd1c51a492011-10-26 12:11:47 -07004759static DEFINE_CLK_VOTER(dfab_bam_dmux_clk, &dfab_clk.c);
Stephen Boydef5d1c42011-12-15 20:47:14 -08004760static DEFINE_CLK_VOTER(dfab_scm_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004761
4762static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
4763/*
4764 * TODO: replace dummy_clk below with ebi1_clk.c once the
4765 * bus driver starts voting on ebi1 rates.
4766 */
4767static DEFINE_CLK_VOTER(ebi1_adm_clk, &dummy_clk);
4768
4769#ifdef CONFIG_DEBUG_FS
4770struct measure_sel {
4771 u32 test_vector;
4772 struct clk *clk;
4773};
4774
Matt Wagantall8b38f942011-08-02 18:23:18 -07004775static DEFINE_CLK_MEASURE(l2_m_clk);
4776static DEFINE_CLK_MEASURE(krait0_m_clk);
4777static DEFINE_CLK_MEASURE(krait1_m_clk);
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004778static DEFINE_CLK_MEASURE(q6sw_clk);
4779static DEFINE_CLK_MEASURE(q6fw_clk);
4780static DEFINE_CLK_MEASURE(q6_func_clk);
Matt Wagantall8b38f942011-08-02 18:23:18 -07004781
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004782static struct measure_sel measure_mux[] = {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004783 { TEST_PER_LS(0x05), &qdss_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004784 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
4785 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
4786 { TEST_PER_LS(0x13), &sdc1_clk.c },
4787 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
4788 { TEST_PER_LS(0x15), &sdc2_clk.c },
4789 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
4790 { TEST_PER_LS(0x17), &sdc3_clk.c },
4791 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
4792 { TEST_PER_LS(0x19), &sdc4_clk.c },
4793 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
4794 { TEST_PER_LS(0x1B), &sdc5_clk.c },
Matt Wagantall7625a4c2011-11-01 16:17:53 -07004795 { TEST_PER_LS(0x1F), &gp0_clk.c },
4796 { TEST_PER_LS(0x20), &gp1_clk.c },
4797 { TEST_PER_LS(0x21), &gp2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004798 { TEST_PER_LS(0x25), &dfab_clk.c },
4799 { TEST_PER_LS(0x25), &dfab_a_clk.c },
4800 { TEST_PER_LS(0x26), &pmem_clk.c },
4801 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
4802 { TEST_PER_LS(0x33), &cfpb_clk.c },
4803 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
4804 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
4805 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
4806 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
4807 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
4808 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
4809 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
4810 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
4811 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
4812 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
4813 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
4814 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
4815 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
4816 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
4817 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
4818 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
4819 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
4820 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
4821 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
4822 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
4823 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
4824 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
4825 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
4826 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
4827 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
4828 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
4829 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
4830 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
4831 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
4832 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
4833 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
4834 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
4835 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
4836 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
4837 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
4838 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
4839 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004840 { TEST_PER_LS(0x5E), &pcie_p_clk.c },
4841 { TEST_PER_LS(0x5F), &ce3_p_clk.c },
4842 { TEST_PER_LS(0x60), &ce3_core_clk.c },
4843 { TEST_PER_LS(0x63), &usb_hs3_p_clk.c },
4844 { TEST_PER_LS(0x64), &usb_hs3_xcvr_clk.c },
4845 { TEST_PER_LS(0x65), &usb_hs4_p_clk.c },
4846 { TEST_PER_LS(0x66), &usb_hs4_xcvr_clk.c },
4847 { TEST_PER_LS(0x6B), &sata_phy_ref_clk.c },
4848 { TEST_PER_LS(0x6C), &sata_phy_cfg_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004849 { TEST_PER_LS(0x78), &sfpb_clk.c },
4850 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
4851 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
4852 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
4853 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
4854 { TEST_PER_LS(0x7D), &prng_clk.c },
4855 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
4856 { TEST_PER_LS(0x80), &adm0_p_clk.c },
4857 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
4858 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004859 { TEST_PER_LS(0x86), &usb_hsic_p_clk.c },
4860 { TEST_PER_LS(0x87), &usb_hsic_system_clk.c },
4861 { TEST_PER_LS(0x88), &usb_hsic_xcvr_fs_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004862 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
4863 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
4864 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
4865 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
4866 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
4867 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
4868 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
4869 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
4870 { TEST_PER_LS(0x92), &ce1_p_clk.c },
4871 { TEST_PER_LS(0x94), &tssc_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004872 { TEST_PER_LS(0x9D), &usb_hsic_hsio_cal_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004873 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
4874
4875 { TEST_PER_HS(0x07), &afab_clk.c },
4876 { TEST_PER_HS(0x07), &afab_a_clk.c },
4877 { TEST_PER_HS(0x18), &sfab_clk.c },
4878 { TEST_PER_HS(0x18), &sfab_a_clk.c },
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004879 { TEST_PER_HS(0x26), &q6sw_clk },
4880 { TEST_PER_HS(0x27), &q6fw_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004881 { TEST_PER_HS(0x2A), &adm0_clk.c },
4882 { TEST_PER_HS(0x34), &ebi1_clk.c },
4883 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004884 { TEST_PER_HS(0x48), &qdss_at_clk.c },
4885 { TEST_PER_HS(0x49), &qdss_pclkdbg_clk.c },
4886 { TEST_PER_HS(0x4A), &qdss_traceclkin_clk.c },
4887 { TEST_PER_HS(0x4B), &qdss_tsctr_clk.c },
4888 { TEST_PER_HS(0x4F), &qdss_stm_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004889 { TEST_PER_HS(0x50), &usb_hsic_hsic_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004890
4891 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
4892 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
4893 { TEST_MM_LS(0x02), &cam1_clk.c },
4894 { TEST_MM_LS(0x06), &amp_p_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004895 { TEST_MM_LS(0x07), &csi_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004896 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
4897 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
4898 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
4899 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
4900 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
4901 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
4902 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
4903 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
4904 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
4905 { TEST_MM_LS(0x12), &imem_p_clk.c },
4906 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
4907 { TEST_MM_LS(0x14), &mdp_p_clk.c },
4908 { TEST_MM_LS(0x16), &rot_p_clk.c },
4909 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
4910 { TEST_MM_LS(0x18), &smmu_p_clk.c },
4911 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
4912 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
4913 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
4914 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
4915 { TEST_MM_LS(0x1D), &cam0_clk.c },
4916 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
4917 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
4918 { TEST_MM_LS(0x21), &tv_dac_clk.c },
4919 { TEST_MM_LS(0x22), &tv_enc_clk.c },
4920 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
4921 { TEST_MM_LS(0x25), &mmfpb_clk.c },
4922 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
4923 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004924 { TEST_MM_LS(0x27), &cam2_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004925 { TEST_MM_LS(0x28), &vcap_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004926
4927 { TEST_MM_HS(0x00), &csi0_clk.c },
4928 { TEST_MM_HS(0x01), &csi1_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004929 { TEST_MM_HS(0x04), &csi_vfe_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004930 { TEST_MM_HS(0x05), &ijpeg_clk.c },
4931 { TEST_MM_HS(0x06), &vfe_clk.c },
4932 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
4933 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
4934 { TEST_MM_HS(0x09), &gfx3d_clk.c },
4935 { TEST_MM_HS(0x0A), &jpegd_clk.c },
4936 { TEST_MM_HS(0x0B), &vcodec_clk.c },
4937 { TEST_MM_HS(0x0F), &mmfab_clk.c },
4938 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
4939 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
4940 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
4941 { TEST_MM_HS(0x13), &imem_axi_clk.c },
4942 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
4943 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
4944 { TEST_MM_HS(0x16), &rot_axi_clk.c },
4945 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
4946 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
4947 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
4948 { TEST_MM_HS(0x1A), &mdp_clk.c },
4949 { TEST_MM_HS(0x1B), &rot_clk.c },
4950 { TEST_MM_HS(0x1C), &vpe_clk.c },
4951 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
4952 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
4953 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
4954 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
4955 { TEST_MM_HS(0x26), &csi_pix_clk.c },
4956 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
4957 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
4958 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
4959 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
4960 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
4961 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004962 { TEST_MM_HS(0x2D), &csi2_clk.c },
4963 { TEST_MM_HS(0x2E), &csi2_phy_clk.c },
4964 { TEST_MM_HS(0x2F), &csi2phy_timer_clk.c },
4965 { TEST_MM_HS(0x30), &csi_pix1_clk.c },
4966 { TEST_MM_HS(0x31), &csi_rdi1_clk.c },
4967 { TEST_MM_HS(0x32), &csi_rdi2_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004968 { TEST_MM_HS(0x33), &vcap_clk.c },
4969 { TEST_MM_HS(0x34), &vcap_npl_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004970 { TEST_MM_HS(0x36), &vcap_axi_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004971 { TEST_MM_HS(0x39), &gfx3d_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004972
4973 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
4974 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
4975 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
4976 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
4977 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
4978 { TEST_LPA(0x14), &pcm_clk.c },
4979 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
Matt Wagantall8b38f942011-08-02 18:23:18 -07004980
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004981 { TEST_LPA_HS(0x00), &q6_func_clk },
4982
Stephen Boyd46fdf0d2011-11-22 12:25:09 -08004983 { TEST_CPUL2(0x2), &l2_m_clk },
4984 { TEST_CPUL2(0x0), &krait0_m_clk },
4985 { TEST_CPUL2(0x1), &krait1_m_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004986};
4987
4988static struct measure_sel *find_measure_sel(struct clk *clk)
4989{
4990 int i;
4991
4992 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
4993 if (measure_mux[i].clk == clk)
4994 return &measure_mux[i];
4995 return NULL;
4996}
4997
Matt Wagantall8b38f942011-08-02 18:23:18 -07004998static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004999{
5000 int ret = 0;
5001 u32 clk_sel;
5002 struct measure_sel *p;
Matt Wagantall8b38f942011-08-02 18:23:18 -07005003 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005004 unsigned long flags;
5005
5006 if (!parent)
5007 return -EINVAL;
5008
5009 p = find_measure_sel(parent);
5010 if (!p)
5011 return -EINVAL;
5012
5013 spin_lock_irqsave(&local_clock_reg_lock, flags);
5014
Matt Wagantall8b38f942011-08-02 18:23:18 -07005015 /*
5016 * Program the test vector, measurement period (sample_ticks)
5017 * and scaling multiplier.
5018 */
5019 clk->sample_ticks = 0x10000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005020 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantall8b38f942011-08-02 18:23:18 -07005021 clk->multiplier = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005022 switch (p->test_vector >> TEST_TYPE_SHIFT) {
5023 case TEST_TYPE_PER_LS:
5024 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
5025 break;
5026 case TEST_TYPE_PER_HS:
5027 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
5028 break;
5029 case TEST_TYPE_MM_LS:
5030 writel_relaxed(0x4030D97, CLK_TEST_REG);
5031 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
5032 break;
5033 case TEST_TYPE_MM_HS:
5034 writel_relaxed(0x402B800, CLK_TEST_REG);
5035 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
5036 break;
5037 case TEST_TYPE_LPA:
5038 writel_relaxed(0x4030D98, CLK_TEST_REG);
5039 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
5040 LCC_CLK_LS_DEBUG_CFG_REG);
5041 break;
Stephen Boyd3939c8d2011-08-29 17:36:22 -07005042 case TEST_TYPE_LPA_HS:
5043 writel_relaxed(0x402BC00, CLK_TEST_REG);
5044 writel_relaxed(BVAL(2, 1, clk_sel)|BIT(0),
5045 LCC_CLK_HS_DEBUG_CFG_REG);
5046 break;
Matt Wagantall8b38f942011-08-02 18:23:18 -07005047 case TEST_TYPE_CPUL2:
5048 writel_relaxed(0x4030400, CLK_TEST_REG);
5049 writel_relaxed(0x80|BVAL(5, 3, clk_sel), GCC_APCS_CLK_DIAG);
5050 clk->sample_ticks = 0x4000;
5051 clk->multiplier = 2;
5052 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005053 default:
5054 ret = -EPERM;
5055 }
5056 /* Make sure test vector is set before starting measurements. */
5057 mb();
5058
5059 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
5060
5061 return ret;
5062}
5063
5064/* Sample clock for 'ticks' reference clock ticks. */
5065static u32 run_measurement(unsigned ticks)
5066{
5067 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005068 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
5069
5070 /* Wait for timer to become ready. */
5071 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
5072 cpu_relax();
5073
5074 /* Run measurement and wait for completion. */
5075 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
5076 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
5077 cpu_relax();
5078
5079 /* Stop counters. */
5080 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
5081
5082 /* Return measured ticks. */
5083 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
5084}
5085
5086
5087/* Perform a hardware rate measurement for a given clock.
5088 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07005089static unsigned long measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005090{
5091 unsigned long flags;
5092 u32 pdm_reg_backup, ringosc_reg_backup;
5093 u64 raw_count_short, raw_count_full;
Matt Wagantall8b38f942011-08-02 18:23:18 -07005094 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005095 unsigned ret;
5096
5097 spin_lock_irqsave(&local_clock_reg_lock, flags);
5098
5099 /* Enable CXO/4 and RINGOSC branch and root. */
5100 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
5101 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
5102 writel_relaxed(0x2898, PDM_CLK_NS_REG);
5103 writel_relaxed(0xA00, RINGOSC_NS_REG);
5104
5105 /*
5106 * The ring oscillator counter will not reset if the measured clock
5107 * is not running. To detect this, run a short measurement before
5108 * the full measurement. If the raw results of the two are the same
5109 * then the clock must be off.
5110 */
5111
5112 /* Run a short measurement. (~1 ms) */
5113 raw_count_short = run_measurement(0x1000);
5114 /* Run a full measurement. (~14 ms) */
Matt Wagantall8b38f942011-08-02 18:23:18 -07005115 raw_count_full = run_measurement(clk->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005116
5117 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
5118 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
5119
5120 /* Return 0 if the clock is off. */
5121 if (raw_count_full == raw_count_short)
5122 ret = 0;
5123 else {
5124 /* Compute rate in Hz. */
5125 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantall8b38f942011-08-02 18:23:18 -07005126 do_div(raw_count_full, ((clk->sample_ticks * 10) + 35));
5127 ret = (raw_count_full * clk->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005128 }
5129
5130 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07005131 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005132 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
5133
5134 return ret;
5135}
5136#else /* !CONFIG_DEBUG_FS */
5137static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
5138{
5139 return -EINVAL;
5140}
5141
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07005142static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005143{
5144 return 0;
5145}
5146#endif /* CONFIG_DEBUG_FS */
5147
5148static struct clk_ops measure_clk_ops = {
5149 .set_parent = measure_clk_set_parent,
5150 .get_rate = measure_clk_get_rate,
5151 .is_local = local_clk_is_local,
5152};
5153
Matt Wagantall8b38f942011-08-02 18:23:18 -07005154static struct measure_clk measure_clk = {
5155 .c = {
5156 .dbg_name = "measure_clk",
5157 .ops = &measure_clk_ops,
5158 CLK_INIT(measure_clk.c),
5159 },
5160 .multiplier = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005161};
5162
Tianyi Goua8b3cce2011-11-08 14:37:26 -08005163static struct clk_lookup msm_clocks_8064[] = {
Tianyi Gou41515e22011-09-01 19:37:43 -07005164 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005165 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005166 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
Tianyi Gouc29c3242011-10-12 21:02:15 -07005167 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005168 CLK_LOOKUP("measure", measure_clk.c, "debug"),
5169
Matt Wagantallb2710b82011-11-16 19:55:17 -08005170 CLK_DUMMY("bus_clk", AFAB_CLK, "msm_apps_fab", 0),
5171 CLK_DUMMY("bus_a_clk", AFAB_A_CLK, "msm_apps_fab", 0),
5172 CLK_DUMMY("bus_clk", SFAB_CLK, "msm_sys_fab", 0),
5173 CLK_DUMMY("bus_a_clk", SFAB_A_CLK, "msm_sys_fab", 0),
5174 CLK_DUMMY("bus_clk", SFPB_CLK, "msm_sys_fpb", 0),
5175 CLK_DUMMY("bus_a_clk", SFPB_A_CLK, "msm_sys_fpb", 0),
5176 CLK_DUMMY("bus_clk", MMFAB_CLK, "msm_mm_fab", 0),
5177 CLK_DUMMY("bus_a_clk", MMFAB_A_CLK, "msm_mm_fab", 0),
5178 CLK_DUMMY("bus_clk", CFPB_CLK, "msm_cpss_fpb", 0),
5179 CLK_DUMMY("bus_a_clk", CFPB_A_CLK, "msm_cpss_fpb", 0),
5180 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
5181 CLK_DUMMY("mem_a_clk", EBI1_A_CLK, "msm_bus", 0),
5182
5183 CLK_DUMMY("ebi1_clk", EBI1_CLK, NULL, 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005184 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
5185 CLK_DUMMY("dfab_a_clk", DFAB_A_CLK, NULL, 0),
Matt Wagantallb2710b82011-11-16 19:55:17 -08005186 CLK_DUMMY("bus_clk", MMFPB_CLK, NULL, 0),
5187 CLK_DUMMY("bus_a_clk", MMFPB_A_CLK, NULL, 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005188
Matt Wagantall7625a4c2011-11-01 16:17:53 -07005189 CLK_LOOKUP("core_clk", gp0_clk.c, NULL),
5190 CLK_LOOKUP("core_clk", gp1_clk.c, NULL),
5191 CLK_LOOKUP("core_clk", gp2_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005192 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
5193 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
5194 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
5195 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
5196 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, NULL),
5197 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, NULL),
5198 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
5199 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, NULL),
5200 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
5201 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, NULL),
5202 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, NULL),
5203 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
5204 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
5205 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005206 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005207 CLK_LOOKUP("pmem_clk", pmem_clk.c, NULL),
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -07005208 CLK_DUMMY("core_clk", PRNG_CLK, "msm_rng.0", OFF),
Tianyi Gou43208a02011-09-27 15:35:13 -07005209 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5210 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5211 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5212 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005213 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
5214 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005215 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
Manu Gautam7483f172011-11-08 15:22:26 +05305216 CLK_LOOKUP("core_clk", usb_hs3_xcvr_clk.c, "msm_ehci_host.0"),
5217 CLK_LOOKUP("core_clk", usb_hs4_xcvr_clk.c, "msm_ehci_host.1"),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005218 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
5219 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
5220 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005221 CLK_LOOKUP("iface_clk", ce1_p_clk.c, NULL),
5222 CLK_LOOKUP("core_clk", ce1_core_clk.c, NULL),
Ramesh Masavarapu28311912011-10-27 11:04:12 -07005223 CLK_LOOKUP("ref_clk", sata_phy_ref_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005224 CLK_LOOKUP("cfg_clk", sata_phy_cfg_clk.c, NULL),
Ramesh Masavarapu28311912011-10-27 11:04:12 -07005225 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qce.0"),
5226 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qcrypto.0"),
5227 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qce.0"),
5228 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qcrypto.0"),
5229 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qce.0"),
5230 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qcrypto.0"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005231 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
5232 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, NULL),
5233 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
5234 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, NULL),
5235 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, NULL),
5236 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, NULL),
5237 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, NULL),
5238 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005239 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005240 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5241 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Manu Gautam7483f172011-11-08 15:22:26 +05305242 CLK_LOOKUP("iface_clk", usb_hs3_p_clk.c, "msm_ehci_host.0"),
5243 CLK_LOOKUP("iface_clk", usb_hs4_p_clk.c, "msm_ehci_host.1"),
Tianyi Gou43208a02011-09-27 15:35:13 -07005244 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5245 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5246 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5247 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005248 CLK_LOOKUP("iface_clk", pcie_p_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005249 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5250 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005251 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
5252 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
5253 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
5254 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
5255 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005256 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5257 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
5258 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5259 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5260 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005261 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005262 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5263 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5264 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005265 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005266 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5267 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5268 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005269 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005270 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5271 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5272 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005273 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, NULL),
5274 CLK_LOOKUP("csi_pix_clk", csi_pix1_clk.c, NULL),
5275 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, NULL),
5276 CLK_LOOKUP("csi_rdi_clk", csi_rdi1_clk.c, NULL),
5277 CLK_LOOKUP("csi_rdi_clk", csi_rdi2_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005278 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
5279 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, NULL),
5280 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, NULL),
5281 CLK_LOOKUP("csiphy_timer_clk", csi2phy_timer_clk.c, NULL),
5282 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5283 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5284 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5285 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
5286 CLK_DUMMY("rgb_tv_clk", RGB_TV_CLK, NULL, OFF),
5287 CLK_DUMMY("npl_tv_clk", NPL_TV_CLK, NULL, OFF),
Pu Chen86b4be92011-11-03 17:27:57 -07005288 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005289 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5290 CLK_LOOKUP("bus_clk", gfx3d_axi_clk.c, "footswitch-8x60.2"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005291 CLK_LOOKUP("iface_clk", vcap_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005292 CLK_LOOKUP("iface_clk", vcap_p_clk.c, "footswitch-8x60.10"),
5293 CLK_LOOKUP("bus_clk", vcap_axi_clk.c, "footswitch-8x60.10"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005294 CLK_LOOKUP("core_clk", vcap_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005295 CLK_LOOKUP("core_clk", vcap_clk.c, "footswitch-8x60.10"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005296 CLK_LOOKUP("vcap_npl_clk", vcap_npl_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005297 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005298 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
5299 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005300 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005301 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005302 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005303 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005304 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005305 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005306 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005307 CLK_LOOKUP("lut_clk", lut_mdp_clk.c, "footswitch-8x60.4"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005308 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005309 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005310 CLK_DUMMY("tv_src_clk", TV_SRC_CLK, NULL, OFF),
Greg Griscofa47b532011-11-11 10:32:06 -08005311 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005312 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005313 CLK_DUMMY("mdp_tv_clk", MDP_TV_CLK, NULL, OFF),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005314 CLK_DUMMY("tv_clk", MDP_TV_CLK, "footswitch-8x60.4", OFF),
Tianyi Gou41515e22011-09-01 19:37:43 -07005315 CLK_DUMMY("hdmi_clk", HDMI_TV_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005316 CLK_LOOKUP("core_clk", hdmi_app_clk.c, NULL),
5317 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005318 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005319 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005320 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005321 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005322 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5323 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5324 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5325 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5326 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5327 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5328 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005329 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
5330 CLK_LOOKUP("csi_pclk", csi_p_clk.c, NULL),
5331 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5332 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5333 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5334 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Pu Chen86b4be92011-11-03 17:27:57 -07005335 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005336 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005337 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, NULL),
5338 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, NULL),
5339 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005340 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005341 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
5342 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005343 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005344 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005345 CLK_LOOKUP("iface_clk", smmu_p_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005346 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005347 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Greg Griscofa47b532011-11-11 10:32:06 -08005348 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005349 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005350 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005351 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005352 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005353 CLK_LOOKUP("iface_pclk", vpe_p_clk.c, "footswitch-8x60.9"),
Tianyi Gouc29c3242011-10-12 21:02:15 -07005354 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5355 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5356 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5357 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5358 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5359 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5360 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5361 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5362 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5363 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5364 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
Tianyi Goudd8138a2011-10-20 15:46:00 -07005365 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5366 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005367 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, NULL),
5368 CLK_LOOKUP("core_clk", vpe_axi_clk.c, NULL),
5369 CLK_LOOKUP("core_clk", mdp_axi_clk.c, NULL),
5370 CLK_LOOKUP("core_clk", vcap_axi_clk.c, NULL),
5371 CLK_LOOKUP("core_clk", rot_axi_clk.c, NULL),
5372 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, NULL),
5373 CLK_LOOKUP("core_clk", vfe_axi_clk.c, NULL),
5374 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, NULL),
5375 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005376 CLK_LOOKUP("core_clk", gfx3d_axi_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005377 CLK_DUMMY("dfab_dsps_clk", DFAB_DSPS_CLK, NULL, 0),
5378 CLK_DUMMY("dfab_usb_hs_clk", DFAB_USB_HS_CLK, NULL, 0),
Manu Gautam7483f172011-11-08 15:22:26 +05305379 CLK_DUMMY("bus_clk", DFAB_USB_HS3_CLK, "msm_ehci_host.0", 0),
5380 CLK_DUMMY("bus_clk", DFAB_USB_HS4_CLK, "msm_ehci_host.1", 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005381 CLK_DUMMY("bus_clk", DFAB_SDC1_CLK, NULL, 0),
5382 CLK_DUMMY("bus_clk", DFAB_SDC2_CLK, NULL, 0),
5383 CLK_DUMMY("bus_clk", DFAB_SDC3_CLK, NULL, 0),
5384 CLK_DUMMY("bus_clk", DFAB_SDC4_CLK, NULL, 0),
5385 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
Stephen Boydef5d1c42011-12-15 20:47:14 -08005386 CLK_DUMMY("bus_clk", DFAB_SCM_CLK, "scm", 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005387 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5388 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5389 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5390 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5391 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5392
Jeff Ohlstein8c116c72011-10-27 17:34:48 -07005393 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005394
5395 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5396 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5397 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
5398};
5399
Stephen Boyd94625ef2011-07-12 17:06:01 -07005400static struct clk_lookup msm_clocks_8960_v1[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005401 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
5402 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
5403 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
5404 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005405 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005406
Matt Wagantallb2710b82011-11-16 19:55:17 -08005407 CLK_LOOKUP("bus_clk", afab_clk.c, "msm_apps_fab"),
5408 CLK_LOOKUP("bus_a_clk", afab_a_clk.c, "msm_apps_fab"),
5409 CLK_LOOKUP("bus_clk", cfpb_clk.c, "msm_cpss_fpb"),
5410 CLK_LOOKUP("bus_a_clk", cfpb_a_clk.c, "msm_cpss_fpb"),
5411 CLK_LOOKUP("bus_clk", sfab_clk.c, "msm_sys_fab"),
5412 CLK_LOOKUP("bus_a_clk", sfab_a_clk.c, "msm_sys_fab"),
5413 CLK_LOOKUP("bus_clk", sfpb_clk.c, "msm_sys_fpb"),
5414 CLK_LOOKUP("bus_a_clk", sfpb_a_clk.c, "msm_sys_fpb"),
5415 CLK_LOOKUP("bus_clk", mmfab_clk.c, "msm_mm_fab"),
5416 CLK_LOOKUP("bus_a_clk", mmfab_a_clk.c, "msm_mm_fab"),
5417 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
5418 CLK_LOOKUP("mem_a_clk", ebi1_a_clk.c, "msm_bus"),
5419
5420 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
5421 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
5422 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
5423 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
5424 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8960"),
5425 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005426
Matt Wagantall7625a4c2011-11-01 16:17:53 -07005427 CLK_LOOKUP("core_clk", gp0_clk.c, NULL),
5428 CLK_LOOKUP("core_clk", gp1_clk.c, NULL),
5429 CLK_LOOKUP("core_clk", gp2_clk.c, NULL),
Matt Wagantalle2522372011-08-17 14:52:21 -07005430 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
5431 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
5432 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
5433 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
5434 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
5435 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
5436 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
5437 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, NULL),
5438 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, NULL),
5439 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, NULL),
5440 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, NULL),
5441 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005442 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005443 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005444 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
5445 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005446 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
5447 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
5448 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
5449 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, NULL),
5450 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005451 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005452 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005453 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005454 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Vikram Mulukutladd0a2372011-09-19 15:58:21 -07005455 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_sps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07005456 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005457 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5458 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5459 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5460 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
5461 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005462 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005463 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005464 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005465 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
5466 CLK_LOOKUP("usb_phy_clk", usb_phy0_clk.c, NULL),
5467 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
5468 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
5469 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
5470 CLK_LOOKUP("usb_fs_clk", usb_fs2_xcvr_clk.c, NULL),
5471 CLK_LOOKUP("usb_fs_sys_clk", usb_fs2_sys_clk.c, NULL),
5472 CLK_LOOKUP("usb_fs_src_clk", usb_fs2_src_clk.c, NULL),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005473 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005474 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qcrypto.0"),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005475 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005476 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qcrypto.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005477 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005478 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005479 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005480 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
5481 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07005482 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
5483 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005484 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
5485 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, NULL),
5486 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005487 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005488 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005489 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.12"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005490 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005491 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5492 CLK_LOOKUP("usb_fs_pclk", usb_fs2_p_clk.c, NULL),
5493 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005494 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5495 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5496 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5497 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
5498 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005499 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5500 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005501 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
5502 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
5503 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
5504 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
5505 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Kevin Chan09f4e662011-12-16 08:17:02 -08005506 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-001a"),
5507 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-006c"),
5508 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-0048"),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005509 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_csid.0"),
5510 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_csid.1"),
5511 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_csid.0"),
5512 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csid.1"),
5513 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_csid.0"),
5514 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_csid.1"),
Kevin Chane12c6672011-10-26 11:55:26 -07005515 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, "msm_ispif.0"),
5516 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, "msm_ispif.0"),
Kevin Chanf6216f22011-10-25 18:40:11 -07005517 CLK_LOOKUP("csiphy_timer_src_clk",
5518 csiphy_timer_src_clk.c, "msm_csiphy.0"),
5519 CLK_LOOKUP("csiphy_timer_src_clk",
5520 csiphy_timer_src_clk.c, "msm_csiphy.1"),
5521 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, "msm_csiphy.0"),
5522 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, "msm_csiphy.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005523 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5524 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5525 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5526 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005527 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005528 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005529 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005530 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005531 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005532 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5533 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005534 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005535 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005536 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005537 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005538 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005539 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005540 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005541 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005542 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005543 CLK_LOOKUP("lut_clk", lut_mdp_clk.c, "footswitch-8x60.4"),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07005544 CLK_LOOKUP("qdss_pclk", qdss_p_clk.c, NULL),
5545 CLK_LOOKUP("qdss_at_clk", qdss_at_clk.c, NULL),
5546 CLK_LOOKUP("qdss_pclkdbg_clk", qdss_pclkdbg_clk.c, NULL),
5547 CLK_LOOKUP("qdss_traceclkin_clk", qdss_traceclkin_clk.c, NULL),
5548 CLK_LOOKUP("qdss_tsctr_clk", qdss_tsctr_clk.c, NULL),
5549 CLK_LOOKUP("qdss_stm_clk", qdss_stm_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005550 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005551 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005552 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005553 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005554 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
5555 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005556 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005557 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005558 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005559 CLK_LOOKUP("tv_clk", mdp_tv_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005560 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005561 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Kevin Chana0853122011-11-07 19:48:44 -08005562 CLK_LOOKUP("vpe_clk", vpe_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005563 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Kevin Chan5827c552011-10-28 18:36:32 -07005564 CLK_LOOKUP("vfe_clk", vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005565 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Kevin Chan5827c552011-10-28 18:36:32 -07005566 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005567 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5568 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5569 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5570 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5571 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5572 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5573 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005574 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005575 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.0"),
5576 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005577 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5578 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5579 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5580 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005581 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005582 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005583 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005584 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005585 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005586 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005587 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
5588 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005589 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005590 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005591 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005592 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005593 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005594 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07005595 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005596 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005597 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005598 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005599 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005600 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Kevin Chan5827c552011-10-28 18:36:32 -07005601 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005602 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Kevin Chana0853122011-11-07 19:48:44 -08005603 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005604 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005605 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5606 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5607 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5608 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5609 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5610 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5611 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5612 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5613 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5614 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5615 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
5616 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5617 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Matt Wagantalle604d712011-10-21 15:38:18 -07005618 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
5619 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
5620 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
5621 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
5622 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
5623 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
5624 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
5625 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
5626 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
5627 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
5628 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
5629 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005630 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
5631 CLK_LOOKUP("dfab_usb_hs_clk", dfab_usb_hs_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005632 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
5633 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
5634 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
5635 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
5636 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Yan He160633e2011-06-30 12:18:56 -07005637 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
Stephen Boyd1c51a492011-10-26 12:11:47 -07005638 CLK_LOOKUP("bus_clk", dfab_bam_dmux_clk.c, "BAM_RMNT"),
Stephen Boydef5d1c42011-12-15 20:47:14 -08005639 CLK_LOOKUP("bus_clk", dfab_scm_clk.c, "scm"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005640
Matt Wagantalle1a86062011-08-18 17:46:10 -07005641 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005642
5643 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5644 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5645 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
Stephen Boyd3939c8d2011-08-29 17:36:22 -07005646 CLK_LOOKUP("q6sw_clk", q6sw_clk, NULL),
5647 CLK_LOOKUP("q6fw_clk", q6fw_clk, NULL),
5648 CLK_LOOKUP("q6_func_clk", q6_func_clk, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005649};
5650
Stephen Boyd94625ef2011-07-12 17:06:01 -07005651static struct clk_lookup msm_clocks_8960_v2[] __initdata = {
5652 CLK_LOOKUP("cam_clk", cam2_clk.c, NULL),
5653 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
5654 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
Kevin Chane12c6672011-10-26 11:55:26 -07005655 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, "msm_ispif.0"),
5656 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, "msm_ispif.0"),
5657 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, "msm_ispif.0"),
Stephen Boyd94625ef2011-07-12 17:06:01 -07005658 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
5659 CLK_LOOKUP("csi2phy_timer_clk", csi2phy_timer_clk.c, NULL),
5660 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5661 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5662 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5663 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5664 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5665};
5666
5667/* Add v2 clocks dynamically at runtime */
5668static struct clk_lookup msm_clocks_8960[ARRAY_SIZE(msm_clocks_8960_v1) +
5669 ARRAY_SIZE(msm_clocks_8960_v2)];
5670
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005671/*
5672 * Miscellaneous clock register initializations
5673 */
5674
5675/* Read, modify, then write-back a register. */
5676static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
5677{
5678 uint32_t regval = readl_relaxed(reg);
5679 regval &= ~mask;
5680 regval |= val;
5681 writel_relaxed(regval, reg);
5682}
5683
Tianyi Gou41515e22011-09-01 19:37:43 -07005684static void __init set_fsm_mode(void __iomem *mode_reg)
5685{
5686 u32 regval = readl_relaxed(mode_reg);
5687
5688 /*De-assert reset to FSM */
5689 regval &= ~BIT(21);
5690 writel_relaxed(regval, mode_reg);
5691
5692 /* Program bias count */
Tianyi Gou358c3862011-10-18 17:03:41 -07005693 regval &= ~BM(19, 14);
5694 regval |= BVAL(19, 14, 0x1);
5695 writel_relaxed(regval, mode_reg);
5696
5697 /* Program lock count */
Tianyi Gou41515e22011-09-01 19:37:43 -07005698 regval &= ~BM(13, 8);
5699 regval |= BVAL(13, 8, 0x8);
5700 writel_relaxed(regval, mode_reg);
5701
5702 /*Enable PLL FSM voting */
5703 regval |= BIT(20);
5704 writel_relaxed(regval, mode_reg);
5705}
5706
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005707static void __init reg_init(void)
5708{
Stephen Boydd471e7a2011-11-19 01:37:39 -08005709 void __iomem *imem_reg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005710 /* Deassert MM SW_RESET_ALL signal. */
5711 writel_relaxed(0, SW_RESET_ALL_REG);
5712
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005713 /*
5714 * Some bits are only used on either 8960 or 8064 and are marked as
5715 * reserved bits on the other SoC. Writing to these reserved bits
5716 * should have no effect.
5717 */
Stephen Boydd471e7a2011-11-19 01:37:39 -08005718 /*
5719 * Initialize MM AHB registers: Enable the FPB clock and disable HW
5720 * gating on 8960v1/8064 for all clocks. Also set VFE_AHB's
5721 * FORCE_CORE_ON bit to prevent its memory from being collapsed when
5722 * the clock is halted. The sleep and wake-up delays are set to safe
5723 * values.
5724 */
5725 if (cpu_is_msm8960() &&
5726 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5727 rmwreg(0x44000000, AHB_EN_REG, 0x6C000103);
5728 writel_relaxed(0x3C7097F9, AHB_EN2_REG);
5729 } else {
5730 rmwreg(0x00000003, AHB_EN_REG, 0x6C000103);
5731 writel_relaxed(0x000007F9, AHB_EN2_REG);
5732 }
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005733 if (cpu_is_apq8064())
5734 rmwreg(0x00000000, AHB_EN3_REG, 0x00000001);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005735
5736 /* Deassert all locally-owned MM AHB resets. */
5737 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
Tianyi Gou41515e22011-09-01 19:37:43 -07005738 rmwreg(0, SW_RESET_AHB2_REG, 0x0000000F);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005739
5740 /* Initialize MM AXI registers: Enable HW gating for all clocks that
5741 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
5742 * delays to safe values. */
Stephen Boydd471e7a2011-11-19 01:37:39 -08005743 if (cpu_is_msm8960() &&
5744 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 3) {
5745 rmwreg(0x0003AFF9, MAXI_EN_REG, 0x0803FFFF);
5746 rmwreg(0x3A27FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
Stephen Boyd2aa8a4b2011-12-09 18:52:16 -08005747 rmwreg(0x0167FCFF, MAXI_EN4_REG, 0x017FFFFF);
Stephen Boydd471e7a2011-11-19 01:37:39 -08005748 } else {
5749 rmwreg(0x000007F9, MAXI_EN_REG, 0x0803FFFF);
5750 rmwreg(0x3027FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
5751 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
5752 }
Matt Wagantall53d968f2011-07-19 13:22:53 -07005753 rmwreg(0x0027FCFF, MAXI_EN3_REG, 0x003FFFFF);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005754 if (cpu_is_apq8064())
5755 rmwreg(0x009FE4FF, MAXI_EN5_REG, 0x01FFEFFF);
Stephen Boydd471e7a2011-11-19 01:37:39 -08005756 if (cpu_is_msm8960() &&
5757 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2)
5758 rmwreg(0x00003C38, SAXI_EN_REG, 0x00003FFF);
5759 else
5760 rmwreg(0x000003C7, SAXI_EN_REG, 0x00003FFF);
5761
5762 /* Enable IMEM's clk_on signal */
5763 imem_reg = ioremap(0x04b00040, 4);
5764 if (imem_reg) {
5765 writel_relaxed(0x3, imem_reg);
5766 iounmap(imem_reg);
5767 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005768
5769 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
5770 * memories retain state even when not clocked. Also, set sleep and
5771 * wake-up delays to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005772 rmwreg(0x00000000, CSI0_CC_REG, 0x00000410);
5773 rmwreg(0x00000000, CSI1_CC_REG, 0x00000410);
5774 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, 0xE0FF0010);
5775 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, 0xE0FF0010);
5776 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, 0xE0FF0010);
5777 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, 0xE0FF0010);
Tarun Karra6fbc00a2011-12-13 09:23:47 -07005778 rmwreg(0xC0FF0000, GFX3D_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005779 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0010);
5780 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0010);
5781 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
5782 rmwreg(0x80FF0000, MDP_LUT_CC_REG, 0xE0FF0010);
5783 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005784 rmwreg(0x000004FF, TV_CC2_REG, 0x000007FF);
5785 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
5786 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FF4010);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005787 rmwreg(0x800000FF, VFE_CC2_REG, 0xE00000FF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005788 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005789 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005790 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
5791 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
5792 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
5793 }
5794 if (cpu_is_apq8064()) {
5795 rmwreg(0x00000000, TV_CC_REG, 0x00004010);
Tianyi Gou621f8742011-09-01 21:45:01 -07005796 rmwreg(0x80FF0000, VCAP_CC_REG, 0xE0FF1010);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005797 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005798
Tianyi Gou41515e22011-09-01 19:37:43 -07005799 /*
5800 * Initialize USB_HS_HCLK_FS registers: Set FORCE_C_ON bits so that
5801 * core remain active during halt state of the clk. Also, set sleep
5802 * and wake-up value to max.
5803 */
5804 rmwreg(0x0000004F, USB_HS1_HCLK_FS_REG, 0x0000007F);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005805 if (cpu_is_apq8064()) {
5806 rmwreg(0x0000004F, USB_HS3_HCLK_FS_REG, 0x0000007F);
5807 rmwreg(0x0000004F, USB_HS4_HCLK_FS_REG, 0x0000007F);
5808 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005809
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005810 /* De-assert MM AXI resets to all hardware blocks. */
5811 writel_relaxed(0, SW_RESET_AXI_REG);
5812
5813 /* Deassert all MM core resets. */
5814 writel_relaxed(0, SW_RESET_CORE_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005815 writel_relaxed(0, SW_RESET_CORE2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005816
5817 /* Reset 3D core once more, with its clock enabled. This can
5818 * eventually be done as part of the GDFS footswitch driver. */
5819 clk_set_rate(&gfx3d_clk.c, 27000000);
5820 clk_enable(&gfx3d_clk.c);
5821 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
5822 mb();
5823 udelay(5);
5824 writel_relaxed(0, SW_RESET_CORE_REG);
5825 /* Make sure reset is de-asserted before clock is disabled. */
5826 mb();
5827 clk_disable(&gfx3d_clk.c);
5828
5829 /* Enable TSSC and PDM PXO sources. */
5830 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
5831 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
5832
5833 /* Source SLIMBus xo src from slimbus reference clock */
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005834 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005835 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005836
5837 /* Source the dsi_byte_clks from the DSI PHY PLLs */
5838 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
5839 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
Tianyi Gou41515e22011-09-01 19:37:43 -07005840
5841 /* Source the sata_phy_ref_clk from PXO */
5842 if (cpu_is_apq8064())
5843 rmwreg(0, SATA_PHY_REF_CLK_CTL_REG, 0x1);
5844
5845 /*
5846 * TODO: Programming below PLLs is temporary and needs to be removed
5847 * after bootloaders program them.
5848 */
5849 if (cpu_is_apq8064()) {
5850 u32 regval, is_pll_enabled;
5851
5852 /* Program pxo_src_clk to source from PXO */
5853 rmwreg(0x1, PXO_SRC_CLK_CTL_REG, 0x7);
5854
5855 /* Check if PLL8 is active */
5856 is_pll_enabled = readl_relaxed(BB_PLL8_STATUS_REG) & BIT(16);
5857 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005858 /* Ref clk = 27MHz and program pll8 to 384MHz */
5859 writel_relaxed(0xE, BB_PLL8_L_VAL_REG);
5860 writel_relaxed(0x2, BB_PLL8_M_VAL_REG);
5861 writel_relaxed(0x9, BB_PLL8_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005862
5863 regval = readl_relaxed(BB_PLL8_CONFIG_REG);
5864
5865 /* Enable the main output and the MN accumulator */
5866 regval |= BIT(23) | BIT(22);
5867
5868 /* Set pre-divider and post-divider values to 1 and 1 */
5869 regval &= ~BIT(19);
5870 regval &= ~BM(21, 20);
5871
5872 writel_relaxed(regval, BB_PLL8_CONFIG_REG);
5873
5874 /* Set VCO frequency */
5875 rmwreg(0x10000, BB_PLL8_CONFIG_REG, 0x30000);
5876
5877 /* Enable AUX output */
5878 regval = readl_relaxed(BB_PLL8_TEST_CTL_REG);
5879 regval |= BIT(12);
5880 writel_relaxed(regval, BB_PLL8_TEST_CTL_REG);
5881
5882 set_fsm_mode(BB_PLL8_MODE_REG);
5883 }
5884 /* Check if PLL3 is active */
5885 is_pll_enabled = readl_relaxed(GPLL1_STATUS_REG) & BIT(16);
5886 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005887 /* Ref clk = 27MHz and program pll3 to 1200MHz */
5888 writel_relaxed(0x2C, GPLL1_L_VAL_REG);
5889 writel_relaxed(0x4, GPLL1_M_VAL_REG);
5890 writel_relaxed(0x9, GPLL1_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005891
5892 regval = readl_relaxed(GPLL1_CONFIG_REG);
5893
5894 /* Set pre-divider and post-divider values to 1 and 1 */
5895 regval &= ~BIT(15);
5896 regval |= BIT(16);
5897
5898 writel_relaxed(regval, GPLL1_CONFIG_REG);
5899
5900 /* Set VCO frequency */
5901 rmwreg(0x180, GPLL1_CONFIG_REG, 0x180);
5902 }
5903 /* Check if PLL14 is active */
5904 is_pll_enabled = readl_relaxed(BB_PLL14_STATUS_REG) & BIT(16);
5905 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005906 /* Ref clk = 27MHz and program pll14 to 480MHz */
5907 writel_relaxed(0x11, BB_PLL14_L_VAL_REG);
5908 writel_relaxed(0x7, BB_PLL14_M_VAL_REG);
5909 writel_relaxed(0x9, BB_PLL14_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005910
5911 regval = readl_relaxed(BB_PLL14_CONFIG_REG);
5912
5913 /* Enable the main output and the MN accumulator */
5914 regval |= BIT(23) | BIT(22);
5915
5916 /* Set pre-divider and post-divider values to 1 and 1 */
5917 regval &= ~BIT(19);
5918 regval &= ~BM(21, 20);
5919
5920 writel_relaxed(regval, BB_PLL14_CONFIG_REG);
5921
5922 /* Set VCO frequency */
5923 rmwreg(0x10000, BB_PLL14_CONFIG_REG, 0x30000);
5924
Tianyi Gou41515e22011-09-01 19:37:43 -07005925 set_fsm_mode(BB_PLL14_MODE_REG);
5926 }
Tianyi Gou621f8742011-09-01 21:45:01 -07005927 /* Program PLL2 to 800MHz with ref clk = 27MHz */
5928 writel_relaxed(0x1D, MM_PLL1_L_VAL_REG);
5929 writel_relaxed(0x11, MM_PLL1_M_VAL_REG);
5930 writel_relaxed(0x1B, MM_PLL1_N_VAL_REG);
5931
5932 regval = readl_relaxed(MM_PLL1_CONFIG_REG);
5933
5934 /* Enable the main output and the MN accumulator */
5935 regval |= BIT(23) | BIT(22);
5936
5937 /* Set pre-divider and post-divider values to 1 and 1 */
5938 regval &= ~BIT(19);
5939 regval &= ~BM(21, 20);
5940
5941 writel_relaxed(regval, MM_PLL1_CONFIG_REG);
5942
5943 /* Set VCO frequency */
5944 rmwreg(0x20000, MM_PLL1_CONFIG_REG, 0x30000);
5945
Tianyi Gou621f8742011-09-01 21:45:01 -07005946 /* Program PLL15 to 975MHz with ref clk = 27MHz */
5947 writel_relaxed(0x24, MM_PLL3_L_VAL_REG);
5948 writel_relaxed(0x1, MM_PLL3_M_VAL_REG);
5949 writel_relaxed(0x9, MM_PLL3_N_VAL_REG);
5950
5951 regval = readl_relaxed(MM_PLL3_CONFIG_REG);
5952
5953 /* Enable the main output and the MN accumulator */
5954 regval |= BIT(23) | BIT(22);
5955
5956 /* Set pre-divider and post-divider values to 1 and 1 */
5957 regval &= ~BIT(19);
5958 regval &= ~BM(21, 20);
5959
5960 writel_relaxed(regval, MM_PLL3_CONFIG_REG);
5961
5962 /* Set VCO frequency */
5963 rmwreg(0x20000, MM_PLL3_CONFIG_REG, 0x30000);
5964
5965 /* Enable AUX output */
5966 regval = readl_relaxed(MM_PLL3_TEST_CTL_REG);
5967 regval |= BIT(12);
5968 writel_relaxed(regval, MM_PLL3_TEST_CTL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005969
5970 /* Check if PLL4 is active */
5971 is_pll_enabled = readl_relaxed(LCC_PLL0_STATUS_REG) & BIT(16);
5972 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005973 /* Ref clk = 27MHz and program pll4 to 393.2160MHz */
5974 writel_relaxed(0xE, LCC_PLL0_L_VAL_REG);
5975 writel_relaxed(0x27A, LCC_PLL0_M_VAL_REG);
5976 writel_relaxed(0x465, LCC_PLL0_N_VAL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005977
5978 regval = readl_relaxed(LCC_PLL0_CONFIG_REG);
5979
5980 /* Enable the main output and the MN accumulator */
5981 regval |= BIT(23) | BIT(22);
5982
5983 /* Set pre-divider and post-divider values to 1 and 1 */
5984 regval &= ~BIT(19);
5985 regval &= ~BM(21, 20);
5986
5987 /* Set VCO frequency */
5988 regval &= ~BM(17, 16);
5989 writel_relaxed(regval, LCC_PLL0_CONFIG_REG);
5990
5991 set_fsm_mode(LCC_PLL0_MODE_REG);
5992 }
5993
5994 /* Enable PLL4 source on the LPASS Primary PLL Mux */
5995 writel_relaxed(0x1, LCC_PRI_PLL_CLK_CTL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005996 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005997}
5998
Stephen Boyd94625ef2011-07-12 17:06:01 -07005999struct clock_init_data msm8960_clock_init_data __initdata;
6000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006001/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07006002static void __init msm8960_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006003{
Stephen Boyd94625ef2011-07-12 17:06:01 -07006004 size_t num_lookups = ARRAY_SIZE(msm_clocks_8960_v1);
Tianyi Gou41515e22011-09-01 19:37:43 -07006005
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006006 xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8960");
6007 if (IS_ERR(xo_pxo)) {
6008 pr_err("%s: msm_xo_get(PXO) failed.\n", __func__);
6009 BUG();
6010 }
Matt Wagantalled90b002011-12-12 21:22:43 -08006011 xo_cxo = msm_xo_get(MSM_XO_CXO, "clock-8960");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006012 if (IS_ERR(xo_cxo)) {
6013 pr_err("%s: msm_xo_get(CXO) failed.\n", __func__);
6014 BUG();
6015 }
6016
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07006017 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou41515e22011-09-01 19:37:43 -07006018 memcpy(msm_clocks_8960, msm_clocks_8960_v1,
6019 sizeof(msm_clocks_8960_v1));
6020 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
6021 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8960_v2;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07006022
6023 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8960_v2,
6024 sizeof(gfx3d_clk.c.fmax));
6025 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8960_v2,
6026 sizeof(ijpeg_clk.c.fmax));
6027 memcpy(vfe_clk.c.fmax, fmax_vfe_8960_v2,
6028 sizeof(vfe_clk.c.fmax));
6029
Tianyi Gou41515e22011-09-01 19:37:43 -07006030 memcpy(msm_clocks_8960 + ARRAY_SIZE(msm_clocks_8960_v1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07006031 msm_clocks_8960_v2, sizeof(msm_clocks_8960_v2));
Tianyi Gou41515e22011-09-01 19:37:43 -07006032 num_lookups = ARRAY_SIZE(msm_clocks_8960);
6033 }
6034 msm8960_clock_init_data.size = num_lookups;
Stephen Boyd94625ef2011-07-12 17:06:01 -07006035 }
Tianyi Gou41515e22011-09-01 19:37:43 -07006036
6037 /*
Matt Wagantalle18bbc82011-10-06 10:07:28 -07006038 * Change the freq tables for and voltage requirements for
6039 * clocks which differ between 8960 and 8064.
Tianyi Gou41515e22011-09-01 19:37:43 -07006040 */
6041 if (cpu_is_apq8064()) {
6042 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8064;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07006043
6044 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8064,
6045 sizeof(gfx3d_clk.c.fmax));
6046 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8064,
6047 sizeof(ijpeg_clk.c.fmax));
6048 memcpy(mdp_clk.c.fmax, fmax_mdp_8064,
6049 sizeof(ijpeg_clk.c.fmax));
6050 memcpy(tv_src_clk.c.fmax, fmax_tv_src_8064,
6051 sizeof(tv_src_clk.c.fmax));
6052 memcpy(vfe_clk.c.fmax, fmax_vfe_8064,
6053 sizeof(vfe_clk.c.fmax));
6054
Tianyi Gou621f8742011-09-01 21:45:01 -07006055 gmem_axi_clk.c.depends = &gfx3d_axi_clk.c;
Tianyi Gou41515e22011-09-01 19:37:43 -07006056 }
Stephen Boyd94625ef2011-07-12 17:06:01 -07006057
Matt Wagantalle18bbc82011-10-06 10:07:28 -07006058 vote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006059
Vikram Mulukutla489e39e2011-08-31 18:04:05 -07006060 clk_ops_pll.enable = sr_pll_clk_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006061
6062 /* Initialize clock registers. */
6063 reg_init();
6064
6065 /* Initialize rates for clocks that only support one. */
6066 clk_set_rate(&pdm_clk.c, 27000000);
6067 clk_set_rate(&prng_clk.c, 64000000);
6068 clk_set_rate(&mdp_vsync_clk.c, 27000000);
6069 clk_set_rate(&tsif_ref_clk.c, 105000);
6070 clk_set_rate(&tssc_clk.c, 27000000);
6071 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
Tianyi Gou41515e22011-09-01 19:37:43 -07006072 if (cpu_is_apq8064()) {
6073 clk_set_rate(&usb_hs3_xcvr_clk.c, 60000000);
6074 clk_set_rate(&usb_hs4_xcvr_clk.c, 60000000);
6075 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006076 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07006077 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou41515e22011-09-01 19:37:43 -07006078 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
Stephen Boyd94625ef2011-07-12 17:06:01 -07006079 clk_set_rate(&usb_hsic_xcvr_fs_clk.c, 60000000);
6080 clk_set_rate(&usb_hsic_hsic_src_clk.c, 480000000);
6081 clk_set_rate(&usb_hsic_hsio_cal_clk.c, 9000000);
Stephen Boyd092fd182011-10-21 15:56:30 -07006082 /*
6083 * Set the CSI rates to a safe default to avoid warnings when
6084 * switching csi pix and rdi clocks.
6085 */
6086 clk_set_rate(&csi0_src_clk.c, 27000000);
6087 clk_set_rate(&csi1_src_clk.c, 27000000);
6088 clk_set_rate(&csi2_src_clk.c, 27000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006089
6090 /*
Stephen Boyd60496bb2011-10-17 13:51:37 -07006091 * The halt status bits for these clocks may be incorrect at boot.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006092 * Toggle these clocks on and off to refresh them.
6093 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07006094 rcg_clk_enable(&pdm_clk.c);
6095 rcg_clk_disable(&pdm_clk.c);
6096 rcg_clk_enable(&tssc_clk.c);
6097 rcg_clk_disable(&tssc_clk.c);
Stephen Boyd60496bb2011-10-17 13:51:37 -07006098 if (cpu_is_msm8960() &&
6099 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
6100 clk_enable(&usb_hsic_hsic_clk.c);
6101 clk_disable(&usb_hsic_hsic_clk.c);
Stephen Boyd092fd182011-10-21 15:56:30 -07006102 } else
6103 /* CSI2 hardware not present on 8960v1 devices */
6104 pix_rdi_mux_map[2] = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006105
6106 if (machine_is_msm8960_sim()) {
6107 clk_set_rate(&sdc1_clk.c, 48000000);
6108 clk_enable(&sdc1_clk.c);
6109 clk_enable(&sdc1_p_clk.c);
6110 clk_set_rate(&sdc3_clk.c, 48000000);
6111 clk_enable(&sdc3_clk.c);
6112 clk_enable(&sdc3_p_clk.c);
6113 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006114}
6115
Stephen Boydbb600ae2011-08-02 20:11:40 -07006116static int __init msm8960_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006117{
Stephen Boyda3787f32011-09-16 18:55:13 -07006118 int rc;
6119 struct clk *mmfpb_a_clk = clk_get_sys("clock-8960", "mmfpb_a_clk");
Stephen Boyd85436132011-09-16 18:55:13 -07006120 struct clk *cfpb_a_clk = clk_get_sys("clock-8960", "cfpb_a_clk");
Stephen Boyda3787f32011-09-16 18:55:13 -07006121
6122 /* Vote for MMFPB to be at least 76.8MHz when an Apps CPU is active. */
6123 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
6124 PTR_ERR(mmfpb_a_clk)))
6125 return PTR_ERR(mmfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08006126 rc = clk_set_rate(mmfpb_a_clk, 76800000);
Stephen Boyda3787f32011-09-16 18:55:13 -07006127 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
6128 return rc;
6129 rc = clk_enable(mmfpb_a_clk);
6130 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
6131 return rc;
6132
Stephen Boyd85436132011-09-16 18:55:13 -07006133 /* Vote for CFPB to be at least 64MHz when an Apps CPU is active. */
6134 if (WARN(IS_ERR(cfpb_a_clk), "cfpb_a_clk not found (%ld)\n",
6135 PTR_ERR(cfpb_a_clk)))
6136 return PTR_ERR(cfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08006137 rc = clk_set_rate(cfpb_a_clk, 64000000);
Stephen Boyd85436132011-09-16 18:55:13 -07006138 if (WARN(rc, "cfpb_a_clk rate was not set (%d)\n", rc))
6139 return rc;
6140 rc = clk_enable(cfpb_a_clk);
6141 if (WARN(rc, "cfpb_a_clk not enabled (%d)\n", rc))
6142 return rc;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07006143
6144 return unvote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006145}
Stephen Boydbb600ae2011-08-02 20:11:40 -07006146
6147struct clock_init_data msm8960_clock_init_data __initdata = {
6148 .table = msm_clocks_8960,
6149 .size = ARRAY_SIZE(msm_clocks_8960),
6150 .init = msm8960_clock_init,
6151 .late_init = msm8960_clock_late_init,
6152};
Tianyi Gou41515e22011-09-01 19:37:43 -07006153
6154struct clock_init_data apq8064_clock_init_data __initdata = {
6155 .table = msm_clocks_8064,
6156 .size = ARRAY_SIZE(msm_clocks_8064),
6157 .init = msm8960_clock_init,
6158 .late_init = msm8960_clock_late_init,
6159};