blob: 69b92afac421ed059591155c1cdaf0ee610036c3 [file] [log] [blame]
Manu Gautam5143b252012-01-05 19:25:23 -08001/* Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/err.h>
16#include <linux/ctype.h>
17#include <linux/bitops.h>
18#include <linux/io.h>
19#include <linux/spinlock.h>
20#include <linux/delay.h>
21#include <linux/clk.h>
22
23#include <asm/clkdev.h>
24#include <asm/mach-types.h>
25
26#include <mach/msm_iomap.h>
27#include <mach/clk.h>
28#include <mach/rpm-regulator.h>
Stephen Boyd94625ef2011-07-12 17:06:01 -070029#include <mach/socinfo.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070030
31#include "clock-local.h"
32#include "clock-rpm.h"
33#include "clock-voter.h"
34#include "clock-dss-8960.h"
35#include "devices.h"
36
37#define REG(off) (MSM_CLK_CTL_BASE + (off))
38#define REG_MM(off) (MSM_MMSS_CLK_CTL_BASE + (off))
39#define REG_LPA(off) (MSM_LPASS_CLK_CTL_BASE + (off))
Matt Wagantall8b38f942011-08-02 18:23:18 -070040#define REG_GCC(off) (MSM_APCS_GCC_BASE + (off))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070041
42/* Peripheral clock registers. */
Stephen Boyda52d7e32011-11-10 11:59:00 -080043#define ADM0_PBUS_CLK_CTL_REG REG(0x2208)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070044#define CE1_HCLK_CTL_REG REG(0x2720)
45#define CE1_CORE_CLK_CTL_REG REG(0x2724)
Tianyi Gou05e01102012-02-08 22:15:49 -080046#define PRNG_CLK_NS_REG REG(0x2E80)
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)
Tianyi Gou59608a72012-01-31 22:19:30 -080072#define BB_PLL_ENA_RPM_REG REG(0x34A0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073#define BB_PLL0_STATUS_REG REG(0x30D8)
74#define BB_PLL5_STATUS_REG REG(0x30F8)
75#define BB_PLL6_STATUS_REG REG(0x3118)
76#define BB_PLL7_STATUS_REG REG(0x3138)
77#define BB_PLL8_L_VAL_REG REG(0x3144)
78#define BB_PLL8_M_VAL_REG REG(0x3148)
79#define BB_PLL8_MODE_REG REG(0x3140)
80#define BB_PLL8_N_VAL_REG REG(0x314C)
81#define BB_PLL8_STATUS_REG REG(0x3158)
82#define BB_PLL8_CONFIG_REG REG(0x3154)
83#define BB_PLL8_TEST_CTL_REG REG(0x3150)
Stephen Boyd94625ef2011-07-12 17:06:01 -070084#define BB_MMCC_PLL2_MODE_REG REG(0x3160)
85#define BB_MMCC_PLL2_TEST_CTL_REG REG(0x3170)
Tianyi Gou41515e22011-09-01 19:37:43 -070086#define BB_PLL14_MODE_REG REG(0x31C0)
87#define BB_PLL14_L_VAL_REG REG(0x31C4)
88#define BB_PLL14_M_VAL_REG REG(0x31C8)
89#define BB_PLL14_N_VAL_REG REG(0x31CC)
90#define BB_PLL14_TEST_CTL_REG REG(0x31D0)
91#define BB_PLL14_CONFIG_REG REG(0x31D4)
Stephen Boyd94625ef2011-07-12 17:06:01 -070092#define BB_PLL14_STATUS_REG REG(0x31D8)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093#define PLLTEST_PAD_CFG_REG REG(0x2FA4)
94#define PMEM_ACLK_CTL_REG REG(0x25A0)
95#define RINGOSC_NS_REG REG(0x2DC0)
96#define RINGOSC_STATUS_REG REG(0x2DCC)
97#define RINGOSC_TCXO_CTL_REG REG(0x2DC4)
Stephen Boyda52d7e32011-11-10 11:59:00 -080098#define RPM_MSG_RAM_HCLK_CTL_REG REG(0x27E0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070099#define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080)
100#define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1)))
101#define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1)))
102#define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1)))
103#define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1)))
104#define SLIMBUS_XO_SRC_CLK_CTL_REG REG(0x2628)
105#define TSIF_HCLK_CTL_REG REG(0x2700)
106#define TSIF_REF_CLK_MD_REG REG(0x270C)
107#define TSIF_REF_CLK_NS_REG REG(0x2710)
108#define TSSC_CLK_CTL_REG REG(0x2CA0)
Tianyi Gou41515e22011-09-01 19:37:43 -0700109#define SATA_CLK_SRC_NS_REG REG(0x2C08)
110#define SATA_RXOOB_CLK_CTL_REG REG(0x2C0C)
111#define SATA_PMALIVE_CLK_CTL_REG REG(0x2C10)
112#define SATA_PHY_REF_CLK_CTL_REG REG(0x2C14)
113#define SATA_PHY_CFG_CLK_CTL_REG REG(0x2C40)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700114#define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1)))
115#define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1)))
116#define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1)))
117#define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1)))
118#define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1)))
119#define USB_HS1_HCLK_CTL_REG REG(0x2900)
Tianyi Gou41515e22011-09-01 19:37:43 -0700120#define USB_HS1_HCLK_FS_REG REG(0x2904)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700121#define USB_HS1_RESET_REG REG(0x2910)
122#define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908)
123#define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700124#define USB_HS3_HCLK_CTL_REG REG(0x3700)
125#define USB_HS3_HCLK_FS_REG REG(0x3704)
126#define USB_HS3_RESET_REG REG(0x3710)
127#define USB_HS3_XCVR_FS_CLK_MD_REG REG(0X3708)
128#define USB_HS3_XCVR_FS_CLK_NS_REG REG(0X370C)
129#define USB_HS4_HCLK_CTL_REG REG(0x3720)
130#define USB_HS4_HCLK_FS_REG REG(0x3724)
131#define USB_HS4_RESET_REG REG(0x3730)
132#define USB_HS4_XCVR_FS_CLK_MD_REG REG(0X3728)
133#define USB_HS4_XCVR_FS_CLK_NS_REG REG(0X372C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700134#define USB_HSIC_HCLK_CTL_REG REG(0x2920)
135#define USB_HSIC_HSIC_CLK_CTL_REG REG(0x2B44)
136#define USB_HSIC_HSIC_CLK_SRC_CTL_REG REG(0x2B40)
137#define USB_HSIC_HSIO_CAL_CLK_CTL_REG REG(0x2B48)
138#define USB_HSIC_RESET_REG REG(0x2934)
139#define USB_HSIC_SYSTEM_CLK_CTL_REG REG(0x292C)
140#define USB_HSIC_XCVR_FS_CLK_MD_REG REG(0x2924)
141#define USB_HSIC_XCVR_FS_CLK_NS_REG REG(0x2928)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700142#define USB_PHY0_RESET_REG REG(0x2E20)
Tianyi Gou41515e22011-09-01 19:37:43 -0700143#define PCIE_ALT_REF_CLK_NS_REG REG(0x3860)
144#define PCIE_HCLK_CTL_REG REG(0x22CC)
145#define GPLL1_MODE_REG REG(0x3160)
146#define GPLL1_L_VAL_REG REG(0x3164)
147#define GPLL1_M_VAL_REG REG(0x3168)
148#define GPLL1_N_VAL_REG REG(0x316C)
149#define GPLL1_CONFIG_REG REG(0x3174)
150#define GPLL1_STATUS_REG REG(0x3178)
151#define PXO_SRC_CLK_CTL_REG REG(0x2EA0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700152
153/* Multimedia clock registers. */
154#define AHB_EN_REG REG_MM(0x0008)
155#define AHB_EN2_REG REG_MM(0x0038)
Tianyi Gou41515e22011-09-01 19:37:43 -0700156#define AHB_EN3_REG REG_MM(0x0248)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700157#define AHB_NS_REG REG_MM(0x0004)
158#define AXI_NS_REG REG_MM(0x0014)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700159#define CAMCLK0_NS_REG REG_MM(0x0148)
160#define CAMCLK0_CC_REG REG_MM(0x0140)
161#define CAMCLK0_MD_REG REG_MM(0x0144)
162#define CAMCLK1_NS_REG REG_MM(0x015C)
163#define CAMCLK1_CC_REG REG_MM(0x0154)
164#define CAMCLK1_MD_REG REG_MM(0x0158)
165#define CAMCLK2_NS_REG REG_MM(0x0228)
166#define CAMCLK2_CC_REG REG_MM(0x0220)
167#define CAMCLK2_MD_REG REG_MM(0x0224)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700168#define CSI0_NS_REG REG_MM(0x0048)
169#define CSI0_CC_REG REG_MM(0x0040)
170#define CSI0_MD_REG REG_MM(0x0044)
171#define CSI1_NS_REG REG_MM(0x0010)
172#define CSI1_CC_REG REG_MM(0x0024)
173#define CSI1_MD_REG REG_MM(0x0028)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700174#define CSI2_NS_REG REG_MM(0x0234)
175#define CSI2_CC_REG REG_MM(0x022C)
176#define CSI2_MD_REG REG_MM(0x0230)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700177#define CSIPHYTIMER_CC_REG REG_MM(0x0160)
178#define CSIPHYTIMER_MD_REG REG_MM(0x0164)
179#define CSIPHYTIMER_NS_REG REG_MM(0x0168)
180#define DSI1_BYTE_NS_REG REG_MM(0x00B0)
181#define DSI1_BYTE_CC_REG REG_MM(0x0090)
182#define DSI2_BYTE_NS_REG REG_MM(0x00BC)
183#define DSI2_BYTE_CC_REG REG_MM(0x00B4)
184#define DSI1_ESC_NS_REG REG_MM(0x011C)
185#define DSI1_ESC_CC_REG REG_MM(0x00CC)
186#define DSI2_ESC_NS_REG REG_MM(0x0150)
187#define DSI2_ESC_CC_REG REG_MM(0x013C)
188#define DSI_PIXEL_CC_REG REG_MM(0x0130)
189#define DSI2_PIXEL_CC_REG REG_MM(0x0094)
190#define DBG_BUS_VEC_A_REG REG_MM(0x01C8)
191#define DBG_BUS_VEC_B_REG REG_MM(0x01CC)
192#define DBG_BUS_VEC_C_REG REG_MM(0x01D0)
193#define DBG_BUS_VEC_D_REG REG_MM(0x01D4)
194#define DBG_BUS_VEC_E_REG REG_MM(0x01D8)
195#define DBG_BUS_VEC_F_REG REG_MM(0x01DC)
196#define DBG_BUS_VEC_G_REG REG_MM(0x01E0)
197#define DBG_BUS_VEC_H_REG REG_MM(0x01E4)
198#define DBG_BUS_VEC_I_REG REG_MM(0x01E8)
Tianyi Gou41515e22011-09-01 19:37:43 -0700199#define DBG_BUS_VEC_J_REG REG_MM(0x0240)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700200#define DBG_CFG_REG_HS_REG REG_MM(0x01B4)
201#define DBG_CFG_REG_LS_REG REG_MM(0x01B8)
202#define GFX2D0_CC_REG REG_MM(0x0060)
203#define GFX2D0_MD0_REG REG_MM(0x0064)
204#define GFX2D0_MD1_REG REG_MM(0x0068)
205#define GFX2D0_NS_REG REG_MM(0x0070)
206#define GFX2D1_CC_REG REG_MM(0x0074)
207#define GFX2D1_MD0_REG REG_MM(0x0078)
208#define GFX2D1_MD1_REG REG_MM(0x006C)
209#define GFX2D1_NS_REG REG_MM(0x007C)
210#define GFX3D_CC_REG REG_MM(0x0080)
211#define GFX3D_MD0_REG REG_MM(0x0084)
212#define GFX3D_MD1_REG REG_MM(0x0088)
213#define GFX3D_NS_REG REG_MM(0x008C)
214#define IJPEG_CC_REG REG_MM(0x0098)
215#define IJPEG_MD_REG REG_MM(0x009C)
216#define IJPEG_NS_REG REG_MM(0x00A0)
217#define JPEGD_CC_REG REG_MM(0x00A4)
218#define JPEGD_NS_REG REG_MM(0x00AC)
Tianyi Gou41515e22011-09-01 19:37:43 -0700219#define VCAP_CC_REG REG_MM(0x0178)
220#define VCAP_NS_REG REG_MM(0x021C)
221#define VCAP_MD0_REG REG_MM(0x01EC)
222#define VCAP_MD1_REG REG_MM(0x0218)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700223#define MAXI_EN_REG REG_MM(0x0018)
224#define MAXI_EN2_REG REG_MM(0x0020)
225#define MAXI_EN3_REG REG_MM(0x002C)
226#define MAXI_EN4_REG REG_MM(0x0114)
Tianyi Gou41515e22011-09-01 19:37:43 -0700227#define MAXI_EN5_REG REG_MM(0x0244)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700228#define MDP_CC_REG REG_MM(0x00C0)
229#define MDP_LUT_CC_REG REG_MM(0x016C)
230#define MDP_MD0_REG REG_MM(0x00C4)
231#define MDP_MD1_REG REG_MM(0x00C8)
232#define MDP_NS_REG REG_MM(0x00D0)
233#define MISC_CC_REG REG_MM(0x0058)
234#define MISC_CC2_REG REG_MM(0x005C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700235#define MISC_CC3_REG REG_MM(0x0238)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700236#define MM_PLL1_MODE_REG REG_MM(0x031C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700237#define MM_PLL1_L_VAL_REG REG_MM(0x0320)
238#define MM_PLL1_M_VAL_REG REG_MM(0x0324)
239#define MM_PLL1_N_VAL_REG REG_MM(0x0328)
240#define MM_PLL1_CONFIG_REG REG_MM(0x032C)
241#define MM_PLL1_TEST_CTL_REG REG_MM(0x0330)
242#define MM_PLL1_STATUS_REG REG_MM(0x0334)
243#define MM_PLL3_MODE_REG REG_MM(0x0338)
Tianyi Gou621f8742011-09-01 21:45:01 -0700244#define MM_PLL3_L_VAL_REG REG_MM(0x033C)
245#define MM_PLL3_M_VAL_REG REG_MM(0x0340)
246#define MM_PLL3_N_VAL_REG REG_MM(0x0344)
247#define MM_PLL3_CONFIG_REG REG_MM(0x0348)
248#define MM_PLL3_TEST_CTL_REG REG_MM(0x034C)
249#define MM_PLL3_STATUS_REG REG_MM(0x0350)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700250#define ROT_CC_REG REG_MM(0x00E0)
251#define ROT_NS_REG REG_MM(0x00E8)
252#define SAXI_EN_REG REG_MM(0x0030)
253#define SW_RESET_AHB_REG REG_MM(0x020C)
254#define SW_RESET_AHB2_REG REG_MM(0x0200)
255#define SW_RESET_ALL_REG REG_MM(0x0204)
256#define SW_RESET_AXI_REG REG_MM(0x0208)
257#define SW_RESET_CORE_REG REG_MM(0x0210)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700258#define SW_RESET_CORE2_REG REG_MM(0x0214)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700259#define TV_CC_REG REG_MM(0x00EC)
260#define TV_CC2_REG REG_MM(0x0124)
261#define TV_MD_REG REG_MM(0x00F0)
262#define TV_NS_REG REG_MM(0x00F4)
263#define VCODEC_CC_REG REG_MM(0x00F8)
264#define VCODEC_MD0_REG REG_MM(0x00FC)
265#define VCODEC_MD1_REG REG_MM(0x0128)
266#define VCODEC_NS_REG REG_MM(0x0100)
267#define VFE_CC_REG REG_MM(0x0104)
268#define VFE_MD_REG REG_MM(0x0108)
269#define VFE_NS_REG REG_MM(0x010C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700270#define VFE_CC2_REG REG_MM(0x023C)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700271#define VPE_CC_REG REG_MM(0x0110)
272#define VPE_NS_REG REG_MM(0x0118)
273
274/* Low-power Audio clock registers. */
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700275#define LCC_CLK_HS_DEBUG_CFG_REG REG_LPA(0x00A4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700276#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
277#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
278#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
279#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
280#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
281#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
282#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
283#define LCC_MI2S_MD_REG REG_LPA(0x004C)
284#define LCC_MI2S_NS_REG REG_LPA(0x0048)
285#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
286#define LCC_PCM_MD_REG REG_LPA(0x0058)
287#define LCC_PCM_NS_REG REG_LPA(0x0054)
288#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700289#define LCC_PLL0_MODE_REG REG_LPA(0x0000)
290#define LCC_PLL0_L_VAL_REG REG_LPA(0x0004)
291#define LCC_PLL0_M_VAL_REG REG_LPA(0x0008)
292#define LCC_PLL0_N_VAL_REG REG_LPA(0x000C)
293#define LCC_PLL0_CONFIG_REG REG_LPA(0x0014)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700294#define LCC_PLL0_STATUS_REG REG_LPA(0x0018)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700295#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
296#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
297#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
298#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
299#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
300#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
301#define LCC_SLIMBUS_NS_REG REG_LPA(0x00CC)
302#define LCC_SLIMBUS_MD_REG REG_LPA(0x00D0)
303#define LCC_SLIMBUS_STATUS_REG REG_LPA(0x00D4)
304#define LCC_AHBEX_BRANCH_CTL_REG REG_LPA(0x00E4)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700305#define LCC_PRI_PLL_CLK_CTL_REG REG_LPA(0x00C4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700306
Matt Wagantall8b38f942011-08-02 18:23:18 -0700307#define GCC_APCS_CLK_DIAG REG_GCC(0x001C)
308
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700309/* MUX source input identifiers. */
310#define pxo_to_bb_mux 0
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700311#define cxo_to_bb_mux 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700312#define pll0_to_bb_mux 2
313#define pll8_to_bb_mux 3
314#define pll6_to_bb_mux 4
315#define gnd_to_bb_mux 5
Stephen Boyd94625ef2011-07-12 17:06:01 -0700316#define pll3_to_bb_mux 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700317#define pxo_to_mm_mux 0
318#define pll1_to_mm_mux 1
Tianyi Gou41515e22011-09-01 19:37:43 -0700319#define pll2_to_mm_mux 1 /* or MMCC_PLL1 */
320#define pll8_to_mm_mux 2 /* or GCC_PERF */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700321#define pll0_to_mm_mux 3
Tianyi Gou41515e22011-09-01 19:37:43 -0700322#define pll15_to_mm_mux 3 /* or MM_PLL3 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700323#define gnd_to_mm_mux 4
Stephen Boyd7a776cd2011-10-20 12:46:04 -0700324#define pll3_to_mm_mux 3 /* or MMCC_PLL2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700325#define hdmi_pll_to_mm_mux 3
326#define cxo_to_xo_mux 0
327#define pxo_to_xo_mux 1
328#define gnd_to_xo_mux 3
329#define pxo_to_lpa_mux 0
330#define cxo_to_lpa_mux 1
331#define pll4_to_lpa_mux 2
332#define gnd_to_lpa_mux 6
Tianyi Gou41515e22011-09-01 19:37:43 -0700333#define pxo_to_pcie_mux 0
334#define pll3_to_pcie_mux 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700335
336/* Test Vector Macros */
337#define TEST_TYPE_PER_LS 1
338#define TEST_TYPE_PER_HS 2
339#define TEST_TYPE_MM_LS 3
340#define TEST_TYPE_MM_HS 4
341#define TEST_TYPE_LPA 5
Matt Wagantall8b38f942011-08-02 18:23:18 -0700342#define TEST_TYPE_CPUL2 6
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700343#define TEST_TYPE_LPA_HS 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700344#define TEST_TYPE_SHIFT 24
345#define TEST_CLK_SEL_MASK BM(23, 0)
346#define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s)))
347#define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS)
348#define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS)
349#define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS)
350#define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS)
351#define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA)
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700352#define TEST_LPA_HS(s) TEST_VECTOR((s), TEST_TYPE_LPA_HS)
Matt Wagantall8b38f942011-08-02 18:23:18 -0700353#define TEST_CPUL2(s) TEST_VECTOR((s), TEST_TYPE_CPUL2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700354
355#define MN_MODE_DUAL_EDGE 0x2
356
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700357struct pll_rate {
358 const uint32_t l_val;
359 const uint32_t m_val;
360 const uint32_t n_val;
361 const uint32_t vco;
362 const uint32_t post_div;
363 const uint32_t i_bits;
364};
365#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
366
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700367enum vdd_dig_levels {
368 VDD_DIG_NONE,
369 VDD_DIG_LOW,
370 VDD_DIG_NOMINAL,
371 VDD_DIG_HIGH
372};
373
Saravana Kannan298ec392012-02-08 19:21:47 -0800374static int set_vdd_dig_8960(struct clk_vdd_class *vdd_class, int level)
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700375{
376 static const int vdd_uv[] = {
377 [VDD_DIG_NONE] = 0,
378 [VDD_DIG_LOW] = 945000,
379 [VDD_DIG_NOMINAL] = 1050000,
380 [VDD_DIG_HIGH] = 1150000
381 };
Saravana Kannan298ec392012-02-08 19:21:47 -0800382 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700383 vdd_uv[level], 1150000, 1);
384}
385
Saravana Kannan298ec392012-02-08 19:21:47 -0800386static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig_8960);
387
388static int set_vdd_dig_8930(struct clk_vdd_class *vdd_class, int level)
389{
390 static const int vdd_uv[] = {
391 [VDD_DIG_NONE] = 0,
392 [VDD_DIG_LOW] = 945000,
393 [VDD_DIG_NOMINAL] = 1050000,
394 [VDD_DIG_HIGH] = 1150000
395 };
396 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8038_S1, RPM_VREG_VOTER3,
397 vdd_uv[level], 1150000, 1);
398}
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700399
400#define VDD_DIG_FMAX_MAP1(l1, f1) \
401 .vdd_class = &vdd_dig, \
402 .fmax[VDD_DIG_##l1] = (f1)
403#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
404 .vdd_class = &vdd_dig, \
405 .fmax[VDD_DIG_##l1] = (f1), \
406 .fmax[VDD_DIG_##l2] = (f2)
407#define VDD_DIG_FMAX_MAP3(l1, f1, l2, f2, l3, f3) \
408 .vdd_class = &vdd_dig, \
409 .fmax[VDD_DIG_##l1] = (f1), \
410 .fmax[VDD_DIG_##l2] = (f2), \
411 .fmax[VDD_DIG_##l3] = (f3)
412
Tianyi Goue1faaf22012-01-24 16:07:19 -0800413enum vdd_sr2_pll_levels {
414 VDD_SR2_PLL_OFF,
415 VDD_SR2_PLL_ON
Matt Wagantallc57577d2011-10-06 17:06:53 -0700416};
417
Saravana Kannan298ec392012-02-08 19:21:47 -0800418static int set_vdd_sr2_pll_8960(struct clk_vdd_class *vdd_class, int level)
Matt Wagantallc57577d2011-10-06 17:06:53 -0700419{
Tianyi Goubf3d0b12012-01-23 14:37:28 -0800420 int rc = 0;
Saravana Kannan298ec392012-02-08 19:21:47 -0800421
422 if (level == VDD_SR2_PLL_OFF) {
423 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
424 RPM_VREG_VOTER3, 0, 0, 1);
425 if (rc)
426 return rc;
427 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
428 RPM_VREG_VOTER3, 0, 0, 1);
429 if (rc)
430 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
431 RPM_VREG_VOTER3, 1800000, 1800000, 1);
Tianyi Goue1faaf22012-01-24 16:07:19 -0800432 } else {
Saravana Kannan298ec392012-02-08 19:21:47 -0800433 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
434 RPM_VREG_VOTER3, 2100000, 2100000, 1);
435 if (rc)
436 return rc;
437 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
438 RPM_VREG_VOTER3, 1800000, 1800000, 1);
439 if (rc)
440 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
Tianyi Goubf3d0b12012-01-23 14:37:28 -0800441 RPM_VREG_VOTER3, 0, 0, 1);
Matt Wagantallc57577d2011-10-06 17:06:53 -0700442 }
443
444 return rc;
445}
446
Saravana Kannan298ec392012-02-08 19:21:47 -0800447static DEFINE_VDD_CLASS(vdd_sr2_pll, set_vdd_sr2_pll_8960);
448
449static int sr2_lreg_uv[] = {
450 [VDD_SR2_PLL_OFF] = 0,
451 [VDD_SR2_PLL_ON] = 1800000,
452};
453
454static int set_vdd_sr2_pll_8064(struct clk_vdd_class *vdd_class, int level)
455{
456 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_LVS7, RPM_VREG_VOTER3,
457 sr2_lreg_uv[level], sr2_lreg_uv[level], 1);
458}
459
460static int set_vdd_sr2_pll_8930(struct clk_vdd_class *vdd_class, int level)
461{
462 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8038_L23, RPM_VREG_VOTER3,
463 sr2_lreg_uv[level], sr2_lreg_uv[level], 1);
464}
Matt Wagantallc57577d2011-10-06 17:06:53 -0700465
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700466/*
467 * Clock Descriptions
468 */
469
Stephen Boyd72a80352012-01-26 15:57:38 -0800470DEFINE_CLK_RPM_BRANCH(pxo_clk, pxo_a_clk, PXO, 27000000);
471DEFINE_CLK_RPM_BRANCH(cxo_clk, cxo_a_clk, CXO, 19200000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700472
473static struct pll_clk pll2_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700474 .mode_reg = MM_PLL1_MODE_REG,
475 .parent = &pxo_clk.c,
476 .c = {
477 .dbg_name = "pll2_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800478 .rate = 800000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700479 .ops = &clk_ops_pll,
480 CLK_INIT(pll2_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800481 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700482 },
483};
484
Stephen Boyd94625ef2011-07-12 17:06:01 -0700485static struct pll_clk pll3_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -0700486 .mode_reg = BB_MMCC_PLL2_MODE_REG,
487 .parent = &pxo_clk.c,
488 .c = {
489 .dbg_name = "pll3_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800490 .rate = 1200000000,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700491 .ops = &clk_ops_pll,
Tianyi Goue1faaf22012-01-24 16:07:19 -0800492 .vdd_class = &vdd_sr2_pll,
493 .fmax[VDD_SR2_PLL_ON] = ULONG_MAX,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700494 CLK_INIT(pll3_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800495 .warned = true,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700496 },
497};
498
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700499static struct pll_vote_clk pll4_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700500 .en_reg = BB_PLL_ENA_SC0_REG,
501 .en_mask = BIT(4),
502 .status_reg = LCC_PLL0_STATUS_REG,
503 .parent = &pxo_clk.c,
504 .c = {
505 .dbg_name = "pll4_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800506 .rate = 393216000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700507 .ops = &clk_ops_pll_vote,
508 CLK_INIT(pll4_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800509 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700510 },
511};
512
513static struct pll_vote_clk pll8_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700514 .en_reg = BB_PLL_ENA_SC0_REG,
515 .en_mask = BIT(8),
516 .status_reg = BB_PLL8_STATUS_REG,
517 .parent = &pxo_clk.c,
518 .c = {
519 .dbg_name = "pll8_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800520 .rate = 384000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700521 .ops = &clk_ops_pll_vote,
522 CLK_INIT(pll8_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800523 .warned = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700524 },
525};
526
Stephen Boyd94625ef2011-07-12 17:06:01 -0700527static struct pll_vote_clk pll14_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -0700528 .en_reg = BB_PLL_ENA_SC0_REG,
529 .en_mask = BIT(14),
530 .status_reg = BB_PLL14_STATUS_REG,
531 .parent = &pxo_clk.c,
532 .c = {
533 .dbg_name = "pll14_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800534 .rate = 480000000,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700535 .ops = &clk_ops_pll_vote,
536 CLK_INIT(pll14_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800537 .warned = true,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700538 },
539};
540
Tianyi Gou41515e22011-09-01 19:37:43 -0700541static struct pll_clk pll15_clk = {
Tianyi Gou41515e22011-09-01 19:37:43 -0700542 .mode_reg = MM_PLL3_MODE_REG,
543 .parent = &pxo_clk.c,
544 .c = {
545 .dbg_name = "pll15_clk",
Tianyi Gou7949ecb2012-02-14 14:25:32 -0800546 .rate = 975000000,
Tianyi Gou41515e22011-09-01 19:37:43 -0700547 .ops = &clk_ops_pll,
548 CLK_INIT(pll15_clk.c),
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800549 .warned = true,
Tianyi Gou41515e22011-09-01 19:37:43 -0700550 },
551};
552
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700553static struct clk_ops clk_ops_rcg_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700554 .enable = rcg_clk_enable,
555 .disable = rcg_clk_disable,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800556 .enable_hwcg = rcg_clk_enable_hwcg,
557 .disable_hwcg = rcg_clk_disable_hwcg,
558 .in_hwcg_mode = rcg_clk_in_hwcg_mode,
Matt Wagantall41af0772011-09-17 12:21:39 -0700559 .auto_off = rcg_clk_disable,
Matt Wagantall53d968f2011-07-19 13:22:53 -0700560 .handoff = rcg_clk_handoff,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700561 .set_rate = rcg_clk_set_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700562 .list_rate = rcg_clk_list_rate,
563 .is_enabled = rcg_clk_is_enabled,
564 .round_rate = rcg_clk_round_rate,
Stephen Boyd7bf28142011-12-07 00:30:52 -0800565 .reset = rcg_clk_reset,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700566 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700567 .get_parent = rcg_clk_get_parent,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800568 .set_flags = rcg_clk_set_flags,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700569};
570
571static struct clk_ops clk_ops_branch = {
572 .enable = branch_clk_enable,
573 .disable = branch_clk_disable,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800574 .enable_hwcg = branch_clk_enable_hwcg,
575 .disable_hwcg = branch_clk_disable_hwcg,
576 .in_hwcg_mode = branch_clk_in_hwcg_mode,
Matt Wagantall41af0772011-09-17 12:21:39 -0700577 .auto_off = branch_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700578 .is_enabled = branch_clk_is_enabled,
579 .reset = branch_clk_reset,
580 .is_local = local_clk_is_local,
581 .get_parent = branch_clk_get_parent,
582 .set_parent = branch_clk_set_parent,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800583 .handoff = branch_clk_handoff,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800584 .set_flags = branch_clk_set_flags,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700585};
586
587static struct clk_ops clk_ops_reset = {
588 .reset = branch_clk_reset,
589 .is_local = local_clk_is_local,
590};
591
592/* AXI Interfaces */
593static struct branch_clk gmem_axi_clk = {
594 .b = {
595 .ctl_reg = MAXI_EN_REG,
596 .en_mask = BIT(24),
597 .halt_reg = DBG_BUS_VEC_E_REG,
598 .halt_bit = 6,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800599 .retain_reg = MAXI_EN2_REG,
600 .retain_mask = BIT(21),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700601 },
602 .c = {
603 .dbg_name = "gmem_axi_clk",
604 .ops = &clk_ops_branch,
605 CLK_INIT(gmem_axi_clk.c),
606 },
607};
608
609static struct branch_clk ijpeg_axi_clk = {
610 .b = {
611 .ctl_reg = MAXI_EN_REG,
612 .en_mask = BIT(21),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800613 .hwcg_reg = MAXI_EN_REG,
614 .hwcg_mask = BIT(11),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700615 .reset_reg = SW_RESET_AXI_REG,
616 .reset_mask = BIT(14),
617 .halt_reg = DBG_BUS_VEC_E_REG,
618 .halt_bit = 4,
619 },
620 .c = {
621 .dbg_name = "ijpeg_axi_clk",
622 .ops = &clk_ops_branch,
623 CLK_INIT(ijpeg_axi_clk.c),
624 },
625};
626
627static struct branch_clk imem_axi_clk = {
628 .b = {
629 .ctl_reg = MAXI_EN_REG,
630 .en_mask = BIT(22),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800631 .hwcg_reg = MAXI_EN_REG,
632 .hwcg_mask = BIT(15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700633 .reset_reg = SW_RESET_CORE_REG,
634 .reset_mask = BIT(10),
635 .halt_reg = DBG_BUS_VEC_E_REG,
636 .halt_bit = 7,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800637 .retain_reg = MAXI_EN2_REG,
638 .retain_mask = BIT(10),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700639 },
640 .c = {
641 .dbg_name = "imem_axi_clk",
642 .ops = &clk_ops_branch,
643 CLK_INIT(imem_axi_clk.c),
644 },
645};
646
647static struct branch_clk jpegd_axi_clk = {
648 .b = {
649 .ctl_reg = MAXI_EN_REG,
650 .en_mask = BIT(25),
651 .halt_reg = DBG_BUS_VEC_E_REG,
652 .halt_bit = 5,
653 },
654 .c = {
655 .dbg_name = "jpegd_axi_clk",
656 .ops = &clk_ops_branch,
657 CLK_INIT(jpegd_axi_clk.c),
658 },
659};
660
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700661static struct branch_clk vcodec_axi_b_clk = {
662 .b = {
663 .ctl_reg = MAXI_EN4_REG,
664 .en_mask = BIT(23),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800665 .hwcg_reg = MAXI_EN4_REG,
666 .hwcg_mask = BIT(22),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700667 .halt_reg = DBG_BUS_VEC_I_REG,
668 .halt_bit = 25,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800669 .retain_reg = MAXI_EN4_REG,
670 .retain_mask = BIT(21),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700671 },
672 .c = {
673 .dbg_name = "vcodec_axi_b_clk",
674 .ops = &clk_ops_branch,
675 CLK_INIT(vcodec_axi_b_clk.c),
676 },
677};
678
Matt Wagantall91f42702011-07-14 12:01:15 -0700679static struct branch_clk vcodec_axi_a_clk = {
680 .b = {
681 .ctl_reg = MAXI_EN4_REG,
682 .en_mask = BIT(25),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800683 .hwcg_reg = MAXI_EN4_REG,
684 .hwcg_mask = BIT(24),
Matt Wagantall91f42702011-07-14 12:01:15 -0700685 .halt_reg = DBG_BUS_VEC_I_REG,
686 .halt_bit = 26,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800687 .retain_reg = MAXI_EN4_REG,
688 .retain_mask = BIT(10),
Matt Wagantall91f42702011-07-14 12:01:15 -0700689 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700690 .c = {
691 .dbg_name = "vcodec_axi_a_clk",
692 .ops = &clk_ops_branch,
693 CLK_INIT(vcodec_axi_a_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700694 .depends = &vcodec_axi_b_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700695 },
696};
697
698static struct branch_clk vcodec_axi_clk = {
699 .b = {
700 .ctl_reg = MAXI_EN_REG,
701 .en_mask = BIT(19),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800702 .hwcg_reg = MAXI_EN_REG,
703 .hwcg_mask = BIT(13),
Matt Wagantall91f42702011-07-14 12:01:15 -0700704 .reset_reg = SW_RESET_AXI_REG,
Gopikrishnaiah Anandan83b6e852012-01-05 17:47:02 -0800705 .reset_mask = BIT(4)|BIT(5)|BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700706 .halt_reg = DBG_BUS_VEC_E_REG,
707 .halt_bit = 3,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800708 .retain_reg = MAXI_EN2_REG,
709 .retain_mask = BIT(28),
Matt Wagantall91f42702011-07-14 12:01:15 -0700710 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700711 .c = {
712 .dbg_name = "vcodec_axi_clk",
713 .ops = &clk_ops_branch,
714 CLK_INIT(vcodec_axi_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700715 .depends = &vcodec_axi_a_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700716 },
717};
718
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700719static struct branch_clk vfe_axi_clk = {
720 .b = {
721 .ctl_reg = MAXI_EN_REG,
722 .en_mask = BIT(18),
723 .reset_reg = SW_RESET_AXI_REG,
724 .reset_mask = BIT(9),
725 .halt_reg = DBG_BUS_VEC_E_REG,
726 .halt_bit = 0,
727 },
728 .c = {
729 .dbg_name = "vfe_axi_clk",
730 .ops = &clk_ops_branch,
731 CLK_INIT(vfe_axi_clk.c),
732 },
733};
734
735static struct branch_clk mdp_axi_clk = {
736 .b = {
737 .ctl_reg = MAXI_EN_REG,
738 .en_mask = BIT(23),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800739 .hwcg_reg = MAXI_EN_REG,
740 .hwcg_mask = BIT(16),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700741 .reset_reg = SW_RESET_AXI_REG,
742 .reset_mask = BIT(13),
743 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700744 .halt_bit = 8,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800745 .retain_reg = MAXI_EN_REG,
746 .retain_mask = BIT(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700747 },
748 .c = {
749 .dbg_name = "mdp_axi_clk",
750 .ops = &clk_ops_branch,
751 CLK_INIT(mdp_axi_clk.c),
752 },
753};
754
755static struct branch_clk rot_axi_clk = {
756 .b = {
757 .ctl_reg = MAXI_EN2_REG,
758 .en_mask = BIT(24),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800759 .hwcg_reg = MAXI_EN2_REG,
760 .hwcg_mask = BIT(25),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700761 .reset_reg = SW_RESET_AXI_REG,
762 .reset_mask = BIT(6),
763 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700764 .halt_bit = 2,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800765 .retain_reg = MAXI_EN3_REG,
766 .retain_mask = BIT(10),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700767 },
768 .c = {
769 .dbg_name = "rot_axi_clk",
770 .ops = &clk_ops_branch,
771 CLK_INIT(rot_axi_clk.c),
772 },
773};
774
775static struct branch_clk vpe_axi_clk = {
776 .b = {
777 .ctl_reg = MAXI_EN2_REG,
778 .en_mask = BIT(26),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800779 .hwcg_reg = MAXI_EN2_REG,
780 .hwcg_mask = BIT(27),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700781 .reset_reg = SW_RESET_AXI_REG,
782 .reset_mask = BIT(15),
783 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700784 .halt_bit = 1,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -0800785 .retain_reg = MAXI_EN3_REG,
786 .retain_mask = BIT(21),
787
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700788 },
789 .c = {
790 .dbg_name = "vpe_axi_clk",
791 .ops = &clk_ops_branch,
792 CLK_INIT(vpe_axi_clk.c),
793 },
794};
795
Tianyi Gou41515e22011-09-01 19:37:43 -0700796static struct branch_clk vcap_axi_clk = {
797 .b = {
798 .ctl_reg = MAXI_EN5_REG,
799 .en_mask = BIT(12),
800 .reset_reg = SW_RESET_AXI_REG,
801 .reset_mask = BIT(16),
802 .halt_reg = DBG_BUS_VEC_J_REG,
803 .halt_bit = 20,
804 },
805 .c = {
806 .dbg_name = "vcap_axi_clk",
807 .ops = &clk_ops_branch,
808 CLK_INIT(vcap_axi_clk.c),
809 },
810};
811
Tianyi Gou621f8742011-09-01 21:45:01 -0700812/* For 8064, gfx3d_axi_clk is set as a dependency of gmem_axi_clk at runtime */
813static struct branch_clk gfx3d_axi_clk = {
814 .b = {
815 .ctl_reg = MAXI_EN5_REG,
816 .en_mask = BIT(25),
817 .reset_reg = SW_RESET_AXI_REG,
818 .reset_mask = BIT(17),
819 .halt_reg = DBG_BUS_VEC_J_REG,
820 .halt_bit = 30,
821 },
822 .c = {
823 .dbg_name = "gfx3d_axi_clk",
824 .ops = &clk_ops_branch,
825 CLK_INIT(gfx3d_axi_clk.c),
826 },
827};
828
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700829/* AHB Interfaces */
830static struct branch_clk amp_p_clk = {
831 .b = {
832 .ctl_reg = AHB_EN_REG,
833 .en_mask = BIT(24),
834 .halt_reg = DBG_BUS_VEC_F_REG,
835 .halt_bit = 18,
836 },
837 .c = {
838 .dbg_name = "amp_p_clk",
839 .ops = &clk_ops_branch,
840 CLK_INIT(amp_p_clk.c),
841 },
842};
843
Matt Wagantallc23eee92011-08-16 23:06:52 -0700844static struct branch_clk csi_p_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700845 .b = {
846 .ctl_reg = AHB_EN_REG,
847 .en_mask = BIT(7),
848 .reset_reg = SW_RESET_AHB_REG,
849 .reset_mask = BIT(17),
850 .halt_reg = DBG_BUS_VEC_F_REG,
851 .halt_bit = 16,
852 },
853 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -0700854 .dbg_name = "csi_p_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700855 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -0700856 CLK_INIT(csi_p_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700857 },
858};
859
860static struct branch_clk dsi1_m_p_clk = {
861 .b = {
862 .ctl_reg = AHB_EN_REG,
863 .en_mask = BIT(9),
864 .reset_reg = SW_RESET_AHB_REG,
865 .reset_mask = BIT(6),
866 .halt_reg = DBG_BUS_VEC_F_REG,
867 .halt_bit = 19,
868 },
869 .c = {
870 .dbg_name = "dsi1_m_p_clk",
871 .ops = &clk_ops_branch,
872 CLK_INIT(dsi1_m_p_clk.c),
873 },
874};
875
876static struct branch_clk dsi1_s_p_clk = {
877 .b = {
878 .ctl_reg = AHB_EN_REG,
879 .en_mask = BIT(18),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800880 .hwcg_reg = AHB_EN2_REG,
881 .hwcg_mask = BIT(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700882 .reset_reg = SW_RESET_AHB_REG,
883 .reset_mask = BIT(5),
884 .halt_reg = DBG_BUS_VEC_F_REG,
885 .halt_bit = 21,
886 },
887 .c = {
888 .dbg_name = "dsi1_s_p_clk",
889 .ops = &clk_ops_branch,
890 CLK_INIT(dsi1_s_p_clk.c),
891 },
892};
893
894static struct branch_clk dsi2_m_p_clk = {
895 .b = {
896 .ctl_reg = AHB_EN_REG,
897 .en_mask = BIT(17),
898 .reset_reg = SW_RESET_AHB2_REG,
899 .reset_mask = BIT(1),
900 .halt_reg = DBG_BUS_VEC_E_REG,
901 .halt_bit = 18,
902 },
903 .c = {
904 .dbg_name = "dsi2_m_p_clk",
905 .ops = &clk_ops_branch,
906 CLK_INIT(dsi2_m_p_clk.c),
907 },
908};
909
910static struct branch_clk dsi2_s_p_clk = {
911 .b = {
912 .ctl_reg = AHB_EN_REG,
913 .en_mask = BIT(22),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800914 .hwcg_reg = AHB_EN2_REG,
915 .hwcg_mask = BIT(15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700916 .reset_reg = SW_RESET_AHB2_REG,
917 .reset_mask = BIT(0),
918 .halt_reg = DBG_BUS_VEC_F_REG,
919 .halt_bit = 20,
920 },
921 .c = {
922 .dbg_name = "dsi2_s_p_clk",
923 .ops = &clk_ops_branch,
924 CLK_INIT(dsi2_s_p_clk.c),
925 },
926};
927
928static struct branch_clk gfx2d0_p_clk = {
929 .b = {
930 .ctl_reg = AHB_EN_REG,
931 .en_mask = BIT(19),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800932 .hwcg_reg = AHB_EN2_REG,
933 .hwcg_mask = BIT(28),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700934 .reset_reg = SW_RESET_AHB_REG,
935 .reset_mask = BIT(12),
936 .halt_reg = DBG_BUS_VEC_F_REG,
937 .halt_bit = 2,
938 },
939 .c = {
940 .dbg_name = "gfx2d0_p_clk",
941 .ops = &clk_ops_branch,
942 CLK_INIT(gfx2d0_p_clk.c),
943 },
944};
945
946static struct branch_clk gfx2d1_p_clk = {
947 .b = {
948 .ctl_reg = AHB_EN_REG,
949 .en_mask = BIT(2),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800950 .hwcg_reg = AHB_EN2_REG,
951 .hwcg_mask = BIT(29),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700952 .reset_reg = SW_RESET_AHB_REG,
953 .reset_mask = BIT(11),
954 .halt_reg = DBG_BUS_VEC_F_REG,
955 .halt_bit = 3,
956 },
957 .c = {
958 .dbg_name = "gfx2d1_p_clk",
959 .ops = &clk_ops_branch,
960 CLK_INIT(gfx2d1_p_clk.c),
961 },
962};
963
964static struct branch_clk gfx3d_p_clk = {
965 .b = {
966 .ctl_reg = AHB_EN_REG,
967 .en_mask = BIT(3),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800968 .hwcg_reg = AHB_EN2_REG,
969 .hwcg_mask = BIT(27),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700970 .reset_reg = SW_RESET_AHB_REG,
971 .reset_mask = BIT(10),
972 .halt_reg = DBG_BUS_VEC_F_REG,
973 .halt_bit = 4,
974 },
975 .c = {
976 .dbg_name = "gfx3d_p_clk",
977 .ops = &clk_ops_branch,
978 CLK_INIT(gfx3d_p_clk.c),
979 },
980};
981
982static struct branch_clk hdmi_m_p_clk = {
983 .b = {
984 .ctl_reg = AHB_EN_REG,
985 .en_mask = BIT(14),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800986 .hwcg_reg = AHB_EN2_REG,
987 .hwcg_mask = BIT(21),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700988 .reset_reg = SW_RESET_AHB_REG,
989 .reset_mask = BIT(9),
990 .halt_reg = DBG_BUS_VEC_F_REG,
991 .halt_bit = 5,
992 },
993 .c = {
994 .dbg_name = "hdmi_m_p_clk",
995 .ops = &clk_ops_branch,
996 CLK_INIT(hdmi_m_p_clk.c),
997 },
998};
999
1000static struct branch_clk hdmi_s_p_clk = {
1001 .b = {
1002 .ctl_reg = AHB_EN_REG,
1003 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001004 .hwcg_reg = AHB_EN2_REG,
1005 .hwcg_mask = BIT(22),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001006 .reset_reg = SW_RESET_AHB_REG,
1007 .reset_mask = BIT(9),
1008 .halt_reg = DBG_BUS_VEC_F_REG,
1009 .halt_bit = 6,
1010 },
1011 .c = {
1012 .dbg_name = "hdmi_s_p_clk",
1013 .ops = &clk_ops_branch,
1014 CLK_INIT(hdmi_s_p_clk.c),
1015 },
1016};
1017
1018static struct branch_clk ijpeg_p_clk = {
1019 .b = {
1020 .ctl_reg = AHB_EN_REG,
1021 .en_mask = BIT(5),
1022 .reset_reg = SW_RESET_AHB_REG,
1023 .reset_mask = BIT(7),
1024 .halt_reg = DBG_BUS_VEC_F_REG,
1025 .halt_bit = 9,
1026 },
1027 .c = {
1028 .dbg_name = "ijpeg_p_clk",
1029 .ops = &clk_ops_branch,
1030 CLK_INIT(ijpeg_p_clk.c),
1031 },
1032};
1033
1034static struct branch_clk imem_p_clk = {
1035 .b = {
1036 .ctl_reg = AHB_EN_REG,
1037 .en_mask = BIT(6),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001038 .hwcg_reg = AHB_EN2_REG,
1039 .hwcg_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001040 .reset_reg = SW_RESET_AHB_REG,
1041 .reset_mask = BIT(8),
1042 .halt_reg = DBG_BUS_VEC_F_REG,
1043 .halt_bit = 10,
1044 },
1045 .c = {
1046 .dbg_name = "imem_p_clk",
1047 .ops = &clk_ops_branch,
1048 CLK_INIT(imem_p_clk.c),
1049 },
1050};
1051
1052static struct branch_clk jpegd_p_clk = {
1053 .b = {
1054 .ctl_reg = AHB_EN_REG,
1055 .en_mask = BIT(21),
1056 .reset_reg = SW_RESET_AHB_REG,
1057 .reset_mask = BIT(4),
1058 .halt_reg = DBG_BUS_VEC_F_REG,
1059 .halt_bit = 7,
1060 },
1061 .c = {
1062 .dbg_name = "jpegd_p_clk",
1063 .ops = &clk_ops_branch,
1064 CLK_INIT(jpegd_p_clk.c),
1065 },
1066};
1067
1068static struct branch_clk mdp_p_clk = {
1069 .b = {
1070 .ctl_reg = AHB_EN_REG,
1071 .en_mask = BIT(10),
1072 .reset_reg = SW_RESET_AHB_REG,
1073 .reset_mask = BIT(3),
1074 .halt_reg = DBG_BUS_VEC_F_REG,
1075 .halt_bit = 11,
1076 },
1077 .c = {
1078 .dbg_name = "mdp_p_clk",
1079 .ops = &clk_ops_branch,
1080 CLK_INIT(mdp_p_clk.c),
1081 },
1082};
1083
1084static struct branch_clk rot_p_clk = {
1085 .b = {
1086 .ctl_reg = AHB_EN_REG,
1087 .en_mask = BIT(12),
1088 .reset_reg = SW_RESET_AHB_REG,
1089 .reset_mask = BIT(2),
1090 .halt_reg = DBG_BUS_VEC_F_REG,
1091 .halt_bit = 13,
1092 },
1093 .c = {
1094 .dbg_name = "rot_p_clk",
1095 .ops = &clk_ops_branch,
1096 CLK_INIT(rot_p_clk.c),
1097 },
1098};
1099
1100static struct branch_clk smmu_p_clk = {
1101 .b = {
1102 .ctl_reg = AHB_EN_REG,
1103 .en_mask = BIT(15),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001104 .hwcg_reg = AHB_EN_REG,
1105 .hwcg_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001106 .halt_reg = DBG_BUS_VEC_F_REG,
1107 .halt_bit = 22,
1108 },
1109 .c = {
1110 .dbg_name = "smmu_p_clk",
1111 .ops = &clk_ops_branch,
1112 CLK_INIT(smmu_p_clk.c),
1113 },
1114};
1115
1116static struct branch_clk tv_enc_p_clk = {
1117 .b = {
1118 .ctl_reg = AHB_EN_REG,
1119 .en_mask = BIT(25),
1120 .reset_reg = SW_RESET_AHB_REG,
1121 .reset_mask = BIT(15),
1122 .halt_reg = DBG_BUS_VEC_F_REG,
1123 .halt_bit = 23,
1124 },
1125 .c = {
1126 .dbg_name = "tv_enc_p_clk",
1127 .ops = &clk_ops_branch,
1128 CLK_INIT(tv_enc_p_clk.c),
1129 },
1130};
1131
1132static struct branch_clk vcodec_p_clk = {
1133 .b = {
1134 .ctl_reg = AHB_EN_REG,
1135 .en_mask = BIT(11),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001136 .hwcg_reg = AHB_EN2_REG,
1137 .hwcg_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001138 .reset_reg = SW_RESET_AHB_REG,
1139 .reset_mask = BIT(1),
1140 .halt_reg = DBG_BUS_VEC_F_REG,
1141 .halt_bit = 12,
1142 },
1143 .c = {
1144 .dbg_name = "vcodec_p_clk",
1145 .ops = &clk_ops_branch,
1146 CLK_INIT(vcodec_p_clk.c),
1147 },
1148};
1149
1150static struct branch_clk vfe_p_clk = {
1151 .b = {
1152 .ctl_reg = AHB_EN_REG,
1153 .en_mask = BIT(13),
1154 .reset_reg = SW_RESET_AHB_REG,
1155 .reset_mask = BIT(0),
1156 .halt_reg = DBG_BUS_VEC_F_REG,
1157 .halt_bit = 14,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08001158 .retain_reg = AHB_EN2_REG,
1159 .retain_mask = BIT(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001160 },
1161 .c = {
1162 .dbg_name = "vfe_p_clk",
1163 .ops = &clk_ops_branch,
1164 CLK_INIT(vfe_p_clk.c),
1165 },
1166};
1167
1168static struct branch_clk vpe_p_clk = {
1169 .b = {
1170 .ctl_reg = AHB_EN_REG,
1171 .en_mask = BIT(16),
1172 .reset_reg = SW_RESET_AHB_REG,
1173 .reset_mask = BIT(14),
1174 .halt_reg = DBG_BUS_VEC_F_REG,
1175 .halt_bit = 15,
1176 },
1177 .c = {
1178 .dbg_name = "vpe_p_clk",
1179 .ops = &clk_ops_branch,
1180 CLK_INIT(vpe_p_clk.c),
1181 },
1182};
1183
Tianyi Gou41515e22011-09-01 19:37:43 -07001184static struct branch_clk vcap_p_clk = {
1185 .b = {
1186 .ctl_reg = AHB_EN3_REG,
1187 .en_mask = BIT(1),
1188 .reset_reg = SW_RESET_AHB2_REG,
1189 .reset_mask = BIT(2),
1190 .halt_reg = DBG_BUS_VEC_J_REG,
1191 .halt_bit = 23,
1192 },
1193 .c = {
1194 .dbg_name = "vcap_p_clk",
1195 .ops = &clk_ops_branch,
1196 CLK_INIT(vcap_p_clk.c),
1197 },
1198};
1199
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001200/*
1201 * Peripheral Clocks
1202 */
Matt Wagantall7625a4c2011-11-01 16:17:53 -07001203#define CLK_GP(i, n, h_r, h_b) \
1204 struct rcg_clk i##_clk = { \
1205 .b = { \
1206 .ctl_reg = GPn_NS_REG(n), \
1207 .en_mask = BIT(9), \
1208 .halt_reg = h_r, \
1209 .halt_bit = h_b, \
1210 }, \
1211 .ns_reg = GPn_NS_REG(n), \
1212 .md_reg = GPn_MD_REG(n), \
1213 .root_en_mask = BIT(11), \
1214 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001215 .mnd_en_mask = BIT(8), \
Matt Wagantall7625a4c2011-11-01 16:17:53 -07001216 .set_rate = set_rate_mnd, \
1217 .freq_tbl = clk_tbl_gp, \
1218 .current_freq = &rcg_dummy_freq, \
1219 .c = { \
1220 .dbg_name = #i "_clk", \
1221 .ops = &clk_ops_rcg_8960, \
1222 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000), \
1223 CLK_INIT(i##_clk.c), \
1224 }, \
1225 }
1226#define F_GP(f, s, d, m, n) \
1227 { \
1228 .freq_hz = f, \
1229 .src_clk = &s##_clk.c, \
1230 .md_val = MD8(16, m, 0, n), \
1231 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Matt Wagantall7625a4c2011-11-01 16:17:53 -07001232 }
1233static struct clk_freq_tbl clk_tbl_gp[] = {
1234 F_GP( 0, gnd, 1, 0, 0),
1235 F_GP( 9600000, cxo, 2, 0, 0),
1236 F_GP( 13500000, pxo, 2, 0, 0),
1237 F_GP( 19200000, cxo, 1, 0, 0),
1238 F_GP( 27000000, pxo, 1, 0, 0),
1239 F_GP( 64000000, pll8, 2, 1, 3),
1240 F_GP( 76800000, pll8, 1, 1, 5),
1241 F_GP( 96000000, pll8, 4, 0, 0),
1242 F_GP(128000000, pll8, 3, 0, 0),
1243 F_GP(192000000, pll8, 2, 0, 0),
1244 F_GP(384000000, pll8, 1, 0, 0),
1245 F_END
1246};
1247
1248static CLK_GP(gp0, 0, CLK_HALT_SFPB_MISC_STATE_REG, 7);
1249static CLK_GP(gp1, 1, CLK_HALT_SFPB_MISC_STATE_REG, 6);
1250static CLK_GP(gp2, 2, CLK_HALT_SFPB_MISC_STATE_REG, 5);
1251
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001252#define CLK_GSBI_UART(i, n, h_r, h_b) \
1253 struct rcg_clk i##_clk = { \
1254 .b = { \
1255 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
1256 .en_mask = BIT(9), \
1257 .reset_reg = GSBIn_RESET_REG(n), \
1258 .reset_mask = BIT(0), \
1259 .halt_reg = h_r, \
1260 .halt_bit = h_b, \
1261 }, \
1262 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
1263 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
1264 .root_en_mask = BIT(11), \
1265 .ns_mask = (BM(31, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001266 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001267 .set_rate = set_rate_mnd, \
1268 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001269 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001270 .c = { \
1271 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001272 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001273 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001274 CLK_INIT(i##_clk.c), \
1275 }, \
1276 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001277#define F_GSBI_UART(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001278 { \
1279 .freq_hz = f, \
1280 .src_clk = &s##_clk.c, \
1281 .md_val = MD16(m, n), \
1282 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001283 }
1284static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001285 F_GSBI_UART( 0, gnd, 1, 0, 0),
Matt Wagantall9a561f72012-01-19 16:13:12 -08001286 F_GSBI_UART( 1843200, pll8, 2, 6, 625),
1287 F_GSBI_UART( 3686400, pll8, 2, 12, 625),
1288 F_GSBI_UART( 7372800, pll8, 2, 24, 625),
1289 F_GSBI_UART(14745600, pll8, 2, 48, 625),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001290 F_GSBI_UART(16000000, pll8, 4, 1, 6),
1291 F_GSBI_UART(24000000, pll8, 4, 1, 4),
1292 F_GSBI_UART(32000000, pll8, 4, 1, 3),
1293 F_GSBI_UART(40000000, pll8, 1, 5, 48),
1294 F_GSBI_UART(46400000, pll8, 1, 29, 240),
1295 F_GSBI_UART(48000000, pll8, 4, 1, 2),
1296 F_GSBI_UART(51200000, pll8, 1, 2, 15),
1297 F_GSBI_UART(56000000, pll8, 1, 7, 48),
1298 F_GSBI_UART(58982400, pll8, 1, 96, 625),
1299 F_GSBI_UART(64000000, pll8, 2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001300 F_END
1301};
1302
1303static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1304static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1305static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1306static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1307static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1308static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1309static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1310static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1311static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1312static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1313static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1314static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1315
1316#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1317 struct rcg_clk i##_clk = { \
1318 .b = { \
1319 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1320 .en_mask = BIT(9), \
1321 .reset_reg = GSBIn_RESET_REG(n), \
1322 .reset_mask = BIT(0), \
1323 .halt_reg = h_r, \
1324 .halt_bit = h_b, \
1325 }, \
1326 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1327 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1328 .root_en_mask = BIT(11), \
1329 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001330 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001331 .set_rate = set_rate_mnd, \
1332 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001333 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001334 .c = { \
1335 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001336 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001337 VDD_DIG_FMAX_MAP2(LOW, 24000000, NOMINAL, 52000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001338 CLK_INIT(i##_clk.c), \
1339 }, \
1340 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001341#define F_GSBI_QUP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001342 { \
1343 .freq_hz = f, \
1344 .src_clk = &s##_clk.c, \
1345 .md_val = MD8(16, m, 0, n), \
1346 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001347 }
1348static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001349 F_GSBI_QUP( 0, gnd, 1, 0, 0),
1350 F_GSBI_QUP( 1100000, pxo, 1, 2, 49),
1351 F_GSBI_QUP( 5400000, pxo, 1, 1, 5),
1352 F_GSBI_QUP(10800000, pxo, 1, 2, 5),
1353 F_GSBI_QUP(15060000, pll8, 1, 2, 51),
1354 F_GSBI_QUP(24000000, pll8, 4, 1, 4),
1355 F_GSBI_QUP(25600000, pll8, 1, 1, 15),
1356 F_GSBI_QUP(27000000, pxo, 1, 0, 0),
1357 F_GSBI_QUP(48000000, pll8, 4, 1, 2),
1358 F_GSBI_QUP(51200000, pll8, 1, 2, 15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001359 F_END
1360};
1361
1362static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1363static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1364static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1365static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1366static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1367static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1368static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1369static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1370static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1371static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1372static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1373static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1374
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001375#define F_PDM(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001376 { \
1377 .freq_hz = f, \
1378 .src_clk = &s##_clk.c, \
1379 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001380 }
1381static struct clk_freq_tbl clk_tbl_pdm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001382 F_PDM( 0, gnd, 1),
1383 F_PDM(27000000, pxo, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001384 F_END
1385};
1386
1387static struct rcg_clk pdm_clk = {
1388 .b = {
1389 .ctl_reg = PDM_CLK_NS_REG,
1390 .en_mask = BIT(9),
1391 .reset_reg = PDM_CLK_NS_REG,
1392 .reset_mask = BIT(12),
1393 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1394 .halt_bit = 3,
1395 },
1396 .ns_reg = PDM_CLK_NS_REG,
1397 .root_en_mask = BIT(11),
1398 .ns_mask = BM(1, 0),
1399 .set_rate = set_rate_nop,
1400 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001401 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001402 .c = {
1403 .dbg_name = "pdm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001404 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001405 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001406 CLK_INIT(pdm_clk.c),
1407 },
1408};
1409
1410static struct branch_clk pmem_clk = {
1411 .b = {
1412 .ctl_reg = PMEM_ACLK_CTL_REG,
1413 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001414 .hwcg_reg = PMEM_ACLK_CTL_REG,
1415 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001416 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1417 .halt_bit = 20,
1418 },
1419 .c = {
1420 .dbg_name = "pmem_clk",
1421 .ops = &clk_ops_branch,
1422 CLK_INIT(pmem_clk.c),
1423 },
1424};
1425
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001426#define F_PRNG(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001427 { \
1428 .freq_hz = f, \
1429 .src_clk = &s##_clk.c, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001430 }
1431static struct clk_freq_tbl clk_tbl_prng[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001432 F_PRNG(64000000, pll8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001433 F_END
1434};
1435
1436static struct rcg_clk prng_clk = {
1437 .b = {
1438 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1439 .en_mask = BIT(10),
1440 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1441 .halt_check = HALT_VOTED,
1442 .halt_bit = 10,
1443 },
1444 .set_rate = set_rate_nop,
1445 .freq_tbl = clk_tbl_prng,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001446 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001447 .c = {
1448 .dbg_name = "prng_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001449 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001450 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 65000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001451 CLK_INIT(prng_clk.c),
1452 },
1453};
1454
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001455#define CLK_SDC(name, n, h_b, fmax_low, fmax_nom) \
Stephen Boyda78a7402011-08-02 11:23:39 -07001456 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001457 .b = { \
1458 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1459 .en_mask = BIT(9), \
1460 .reset_reg = SDCn_RESET_REG(n), \
1461 .reset_mask = BIT(0), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001462 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001463 .halt_bit = h_b, \
1464 }, \
1465 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1466 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1467 .root_en_mask = BIT(11), \
1468 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001469 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001470 .set_rate = set_rate_mnd, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001471 .freq_tbl = clk_tbl_sdc, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001472 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001473 .c = { \
Stephen Boyda78a7402011-08-02 11:23:39 -07001474 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001475 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001476 VDD_DIG_FMAX_MAP2(LOW, fmax_low, NOMINAL, fmax_nom), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001477 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001478 }, \
1479 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001480#define F_SDC(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001481 { \
1482 .freq_hz = f, \
1483 .src_clk = &s##_clk.c, \
1484 .md_val = MD8(16, m, 0, n), \
1485 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001486 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001487static struct clk_freq_tbl clk_tbl_sdc[] = {
1488 F_SDC( 0, gnd, 1, 0, 0),
1489 F_SDC( 144000, pxo, 3, 2, 125),
1490 F_SDC( 400000, pll8, 4, 1, 240),
1491 F_SDC( 16000000, pll8, 4, 1, 6),
1492 F_SDC( 17070000, pll8, 1, 2, 45),
1493 F_SDC( 20210000, pll8, 1, 1, 19),
1494 F_SDC( 24000000, pll8, 4, 1, 4),
1495 F_SDC( 48000000, pll8, 4, 1, 2),
1496 F_SDC( 64000000, pll8, 3, 1, 2),
1497 F_SDC( 96000000, pll8, 4, 0, 0),
Subhash Jadavanibd238ba2011-11-24 15:12:39 +05301498 F_SDC(192000000, pll8, 2, 0, 0),
Stephen Boyda78a7402011-08-02 11:23:39 -07001499 F_END
1500};
1501
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001502static CLK_SDC(sdc1_clk, 1, 6, 52000000, 104000000);
1503static CLK_SDC(sdc2_clk, 2, 5, 52000000, 104000000);
1504static CLK_SDC(sdc3_clk, 3, 4, 104000000, 208000000);
1505static CLK_SDC(sdc4_clk, 4, 3, 33000000, 67000000);
1506static CLK_SDC(sdc5_clk, 5, 2, 33000000, 67000000);
Stephen Boyda78a7402011-08-02 11:23:39 -07001507
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001508#define F_TSIF_REF(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001509 { \
1510 .freq_hz = f, \
1511 .src_clk = &s##_clk.c, \
1512 .md_val = MD16(m, n), \
1513 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001514 }
1515static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001516 F_TSIF_REF( 0, gnd, 1, 0, 0),
1517 F_TSIF_REF(105000, pxo, 1, 1, 256),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001518 F_END
1519};
1520
1521static struct rcg_clk tsif_ref_clk = {
1522 .b = {
1523 .ctl_reg = TSIF_REF_CLK_NS_REG,
1524 .en_mask = BIT(9),
1525 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1526 .halt_bit = 5,
1527 },
1528 .ns_reg = TSIF_REF_CLK_NS_REG,
1529 .md_reg = TSIF_REF_CLK_MD_REG,
1530 .root_en_mask = BIT(11),
1531 .ns_mask = (BM(31, 16) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08001532 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001533 .set_rate = set_rate_mnd,
1534 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001535 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001536 .c = {
1537 .dbg_name = "tsif_ref_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001538 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001539 VDD_DIG_FMAX_MAP2(LOW, 27000000, NOMINAL, 54000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001540 CLK_INIT(tsif_ref_clk.c),
1541 },
1542};
1543
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001544#define F_TSSC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001545 { \
1546 .freq_hz = f, \
1547 .src_clk = &s##_clk.c, \
1548 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001549 }
1550static struct clk_freq_tbl clk_tbl_tssc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001551 F_TSSC( 0, gnd),
1552 F_TSSC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001553 F_END
1554};
1555
1556static struct rcg_clk tssc_clk = {
1557 .b = {
1558 .ctl_reg = TSSC_CLK_CTL_REG,
1559 .en_mask = BIT(4),
1560 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1561 .halt_bit = 4,
1562 },
1563 .ns_reg = TSSC_CLK_CTL_REG,
1564 .ns_mask = BM(1, 0),
1565 .set_rate = set_rate_nop,
1566 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001567 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001568 .c = {
1569 .dbg_name = "tssc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001570 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001571 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001572 CLK_INIT(tssc_clk.c),
1573 },
1574};
1575
Tianyi Gou41515e22011-09-01 19:37:43 -07001576#define CLK_USB_HS(name, n, h_b) \
1577 static struct rcg_clk name = { \
1578 .b = { \
1579 .ctl_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1580 .en_mask = BIT(9), \
1581 .reset_reg = USB_HS##n##_RESET_REG, \
1582 .reset_mask = BIT(0), \
1583 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
1584 .halt_bit = h_b, \
1585 }, \
1586 .ns_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1587 .md_reg = USB_HS##n##_XCVR_FS_CLK_MD_REG, \
1588 .root_en_mask = BIT(11), \
1589 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001590 .mnd_en_mask = BIT(8), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001591 .set_rate = set_rate_mnd, \
1592 .freq_tbl = clk_tbl_usb, \
1593 .current_freq = &rcg_dummy_freq, \
1594 .c = { \
1595 .dbg_name = #name, \
1596 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001597 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001598 CLK_INIT(name.c), \
1599 }, \
1600}
1601
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001602#define F_USB(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001603 { \
1604 .freq_hz = f, \
1605 .src_clk = &s##_clk.c, \
1606 .md_val = MD8(16, m, 0, n), \
1607 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001608 }
1609static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001610 F_USB( 0, gnd, 1, 0, 0),
1611 F_USB(60000000, pll8, 1, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001612 F_END
1613};
1614
Tianyi Gou41515e22011-09-01 19:37:43 -07001615CLK_USB_HS(usb_hs1_xcvr_clk, 1, 0);
1616CLK_USB_HS(usb_hs3_xcvr_clk, 3, 30);
1617CLK_USB_HS(usb_hs4_xcvr_clk, 4, 2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001618
Stephen Boyd94625ef2011-07-12 17:06:01 -07001619static struct clk_freq_tbl clk_tbl_usb_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001620 F_USB( 0, gnd, 1, 0, 0),
1621 F_USB(60000000, pll8, 1, 5, 32),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001622 F_END
1623};
1624
1625static struct rcg_clk usb_hsic_xcvr_fs_clk = {
1626 .b = {
1627 .ctl_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1628 .en_mask = BIT(9),
1629 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1630 .halt_bit = 26,
1631 },
1632 .ns_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1633 .md_reg = USB_HSIC_XCVR_FS_CLK_MD_REG,
1634 .root_en_mask = BIT(11),
1635 .ns_mask = (BM(23, 16) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08001636 .mnd_en_mask = BIT(8),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001637 .set_rate = set_rate_mnd,
1638 .freq_tbl = clk_tbl_usb_hsic,
1639 .current_freq = &rcg_dummy_freq,
1640 .c = {
1641 .dbg_name = "usb_hsic_xcvr_fs_clk",
1642 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001643 VDD_DIG_FMAX_MAP1(LOW, 60000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001644 CLK_INIT(usb_hsic_xcvr_fs_clk.c),
1645 },
1646};
1647
1648static struct branch_clk usb_hsic_system_clk = {
1649 .b = {
1650 .ctl_reg = USB_HSIC_SYSTEM_CLK_CTL_REG,
1651 .en_mask = BIT(4),
1652 .reset_reg = USB_HSIC_RESET_REG,
1653 .reset_mask = BIT(0),
1654 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1655 .halt_bit = 24,
1656 },
1657 .parent = &usb_hsic_xcvr_fs_clk.c,
1658 .c = {
1659 .dbg_name = "usb_hsic_system_clk",
1660 .ops = &clk_ops_branch,
1661 CLK_INIT(usb_hsic_system_clk.c),
1662 },
1663};
1664
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001665#define F_USB_HSIC(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001666 { \
1667 .freq_hz = f, \
1668 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001669 }
1670static struct clk_freq_tbl clk_tbl_usb2_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001671 F_USB_HSIC(480000000, pll14),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001672 F_END
1673};
1674
1675static struct rcg_clk usb_hsic_hsic_src_clk = {
1676 .b = {
1677 .ctl_reg = USB_HSIC_HSIC_CLK_SRC_CTL_REG,
1678 .halt_check = NOCHECK,
1679 },
1680 .root_en_mask = BIT(0),
1681 .set_rate = set_rate_nop,
1682 .freq_tbl = clk_tbl_usb2_hsic,
1683 .current_freq = &rcg_dummy_freq,
1684 .c = {
1685 .dbg_name = "usb_hsic_hsic_src_clk",
1686 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001687 VDD_DIG_FMAX_MAP1(LOW, 480000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001688 CLK_INIT(usb_hsic_hsic_src_clk.c),
1689 },
1690};
1691
1692static struct branch_clk usb_hsic_hsic_clk = {
1693 .b = {
1694 .ctl_reg = USB_HSIC_HSIC_CLK_CTL_REG,
1695 .en_mask = BIT(0),
1696 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1697 .halt_bit = 19,
1698 },
1699 .parent = &usb_hsic_hsic_src_clk.c,
1700 .c = {
1701 .dbg_name = "usb_hsic_hsic_clk",
1702 .ops = &clk_ops_branch,
1703 CLK_INIT(usb_hsic_hsic_clk.c),
1704 },
1705};
1706
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001707#define F_USB_HSIO_CAL(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001708 { \
1709 .freq_hz = f, \
1710 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001711 }
1712static struct clk_freq_tbl clk_tbl_usb_hsio_cal[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001713 F_USB_HSIO_CAL(9000000, pxo),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001714 F_END
1715};
1716
1717static struct rcg_clk usb_hsic_hsio_cal_clk = {
1718 .b = {
1719 .ctl_reg = USB_HSIC_HSIO_CAL_CLK_CTL_REG,
1720 .en_mask = BIT(0),
1721 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1722 .halt_bit = 23,
1723 },
1724 .set_rate = set_rate_nop,
1725 .freq_tbl = clk_tbl_usb_hsio_cal,
1726 .current_freq = &rcg_dummy_freq,
1727 .c = {
1728 .dbg_name = "usb_hsic_hsio_cal_clk",
Stephen Boyda0e82ec2011-09-19 12:18:45 -07001729 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001730 VDD_DIG_FMAX_MAP1(LOW, 10000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001731 CLK_INIT(usb_hsic_hsio_cal_clk.c),
1732 },
1733};
1734
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001735static struct branch_clk usb_phy0_clk = {
1736 .b = {
1737 .reset_reg = USB_PHY0_RESET_REG,
1738 .reset_mask = BIT(0),
1739 },
1740 .c = {
1741 .dbg_name = "usb_phy0_clk",
1742 .ops = &clk_ops_reset,
1743 CLK_INIT(usb_phy0_clk.c),
1744 },
1745};
1746
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001747#define CLK_USB_FS(i, n, fmax_nom) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001748 struct rcg_clk i##_clk = { \
1749 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1750 .b = { \
1751 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
1752 .halt_check = NOCHECK, \
1753 }, \
1754 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
1755 .root_en_mask = BIT(11), \
1756 .ns_mask = (BM(23, 16) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08001757 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001758 .set_rate = set_rate_mnd, \
1759 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001760 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001761 .c = { \
1762 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001763 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001764 VDD_DIG_FMAX_MAP1(NOMINAL, fmax_nom), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001765 CLK_INIT(i##_clk.c), \
1766 }, \
1767 }
1768
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001769static CLK_USB_FS(usb_fs1_src, 1, 64000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001770static struct branch_clk usb_fs1_xcvr_clk = {
1771 .b = {
1772 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
1773 .en_mask = BIT(9),
1774 .reset_reg = USB_FSn_RESET_REG(1),
1775 .reset_mask = BIT(1),
1776 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1777 .halt_bit = 15,
1778 },
1779 .parent = &usb_fs1_src_clk.c,
1780 .c = {
1781 .dbg_name = "usb_fs1_xcvr_clk",
1782 .ops = &clk_ops_branch,
1783 CLK_INIT(usb_fs1_xcvr_clk.c),
1784 },
1785};
1786
1787static struct branch_clk usb_fs1_sys_clk = {
1788 .b = {
1789 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
1790 .en_mask = BIT(4),
1791 .reset_reg = USB_FSn_RESET_REG(1),
1792 .reset_mask = BIT(0),
1793 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1794 .halt_bit = 16,
1795 },
1796 .parent = &usb_fs1_src_clk.c,
1797 .c = {
1798 .dbg_name = "usb_fs1_sys_clk",
1799 .ops = &clk_ops_branch,
1800 CLK_INIT(usb_fs1_sys_clk.c),
1801 },
1802};
1803
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001804static CLK_USB_FS(usb_fs2_src, 2, 60000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001805static struct branch_clk usb_fs2_xcvr_clk = {
1806 .b = {
1807 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
1808 .en_mask = BIT(9),
1809 .reset_reg = USB_FSn_RESET_REG(2),
1810 .reset_mask = BIT(1),
1811 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1812 .halt_bit = 12,
1813 },
1814 .parent = &usb_fs2_src_clk.c,
1815 .c = {
1816 .dbg_name = "usb_fs2_xcvr_clk",
1817 .ops = &clk_ops_branch,
1818 CLK_INIT(usb_fs2_xcvr_clk.c),
1819 },
1820};
1821
1822static struct branch_clk usb_fs2_sys_clk = {
1823 .b = {
1824 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
1825 .en_mask = BIT(4),
1826 .reset_reg = USB_FSn_RESET_REG(2),
1827 .reset_mask = BIT(0),
1828 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1829 .halt_bit = 13,
1830 },
1831 .parent = &usb_fs2_src_clk.c,
1832 .c = {
1833 .dbg_name = "usb_fs2_sys_clk",
1834 .ops = &clk_ops_branch,
1835 CLK_INIT(usb_fs2_sys_clk.c),
1836 },
1837};
1838
1839/* Fast Peripheral Bus Clocks */
1840static struct branch_clk ce1_core_clk = {
1841 .b = {
1842 .ctl_reg = CE1_CORE_CLK_CTL_REG,
1843 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001844 .hwcg_reg = CE1_CORE_CLK_CTL_REG,
1845 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001846 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1847 .halt_bit = 27,
1848 },
1849 .c = {
1850 .dbg_name = "ce1_core_clk",
1851 .ops = &clk_ops_branch,
1852 CLK_INIT(ce1_core_clk.c),
1853 },
1854};
Tianyi Gou41515e22011-09-01 19:37:43 -07001855
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001856static struct branch_clk ce1_p_clk = {
1857 .b = {
1858 .ctl_reg = CE1_HCLK_CTL_REG,
1859 .en_mask = BIT(4),
1860 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1861 .halt_bit = 1,
1862 },
1863 .c = {
1864 .dbg_name = "ce1_p_clk",
1865 .ops = &clk_ops_branch,
1866 CLK_INIT(ce1_p_clk.c),
1867 },
1868};
1869
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001870#define F_CE3(f, s, d) \
Tianyi Gou41515e22011-09-01 19:37:43 -07001871 { \
1872 .freq_hz = f, \
1873 .src_clk = &s##_clk.c, \
1874 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001875 }
1876
1877static struct clk_freq_tbl clk_tbl_ce3[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001878 F_CE3( 0, gnd, 1),
1879 F_CE3( 48000000, pll8, 8),
1880 F_CE3(100000000, pll3, 12),
Tianyi Gou41515e22011-09-01 19:37:43 -07001881 F_END
1882};
1883
1884static struct rcg_clk ce3_src_clk = {
1885 .b = {
1886 .ctl_reg = CE3_CLK_SRC_NS_REG,
1887 .halt_check = NOCHECK,
1888 },
1889 .ns_reg = CE3_CLK_SRC_NS_REG,
1890 .root_en_mask = BIT(7),
1891 .ns_mask = BM(6, 0),
1892 .set_rate = set_rate_nop,
1893 .freq_tbl = clk_tbl_ce3,
1894 .current_freq = &rcg_dummy_freq,
1895 .c = {
1896 .dbg_name = "ce3_src_clk",
1897 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001898 VDD_DIG_FMAX_MAP2(LOW, 50000000, NOMINAL, 100000000),
Tianyi Gou41515e22011-09-01 19:37:43 -07001899 CLK_INIT(ce3_src_clk.c),
1900 },
1901};
1902
1903static struct branch_clk ce3_core_clk = {
1904 .b = {
1905 .ctl_reg = CE3_CORE_CLK_CTL_REG,
1906 .en_mask = BIT(4),
1907 .reset_reg = CE3_CORE_CLK_CTL_REG,
1908 .reset_mask = BIT(7),
1909 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1910 .halt_bit = 5,
1911 },
1912 .parent = &ce3_src_clk.c,
1913 .c = {
1914 .dbg_name = "ce3_core_clk",
1915 .ops = &clk_ops_branch,
1916 CLK_INIT(ce3_core_clk.c),
1917 }
1918};
1919
1920static struct branch_clk ce3_p_clk = {
1921 .b = {
1922 .ctl_reg = CE3_HCLK_CTL_REG,
1923 .en_mask = BIT(4),
1924 .reset_reg = CE3_HCLK_CTL_REG,
1925 .reset_mask = BIT(7),
1926 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
1927 .halt_bit = 16,
1928 },
1929 .parent = &ce3_src_clk.c,
1930 .c = {
1931 .dbg_name = "ce3_p_clk",
1932 .ops = &clk_ops_branch,
1933 CLK_INIT(ce3_p_clk.c),
1934 }
1935};
1936
1937static struct branch_clk sata_phy_ref_clk = {
1938 .b = {
1939 .ctl_reg = SATA_PHY_REF_CLK_CTL_REG,
1940 .en_mask = BIT(4),
1941 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1942 .halt_bit = 24,
1943 },
1944 .parent = &pxo_clk.c,
1945 .c = {
1946 .dbg_name = "sata_phy_ref_clk",
1947 .ops = &clk_ops_branch,
1948 CLK_INIT(sata_phy_ref_clk.c),
1949 },
1950};
1951
1952static struct branch_clk pcie_p_clk = {
1953 .b = {
1954 .ctl_reg = PCIE_HCLK_CTL_REG,
1955 .en_mask = BIT(4),
1956 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1957 .halt_bit = 8,
1958 },
1959 .c = {
1960 .dbg_name = "pcie_p_clk",
1961 .ops = &clk_ops_branch,
1962 CLK_INIT(pcie_p_clk.c),
1963 },
1964};
1965
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001966static struct branch_clk dma_bam_p_clk = {
1967 .b = {
1968 .ctl_reg = DMA_BAM_HCLK_CTL,
1969 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001970 .hwcg_reg = DMA_BAM_HCLK_CTL,
1971 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001972 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1973 .halt_bit = 12,
1974 },
1975 .c = {
1976 .dbg_name = "dma_bam_p_clk",
1977 .ops = &clk_ops_branch,
1978 CLK_INIT(dma_bam_p_clk.c),
1979 },
1980};
1981
1982static struct branch_clk gsbi1_p_clk = {
1983 .b = {
1984 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
1985 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001986 .hwcg_reg = GSBIn_HCLK_CTL_REG(1),
1987 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001988 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1989 .halt_bit = 11,
1990 },
1991 .c = {
1992 .dbg_name = "gsbi1_p_clk",
1993 .ops = &clk_ops_branch,
1994 CLK_INIT(gsbi1_p_clk.c),
1995 },
1996};
1997
1998static struct branch_clk gsbi2_p_clk = {
1999 .b = {
2000 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
2001 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002002 .hwcg_reg = GSBIn_HCLK_CTL_REG(2),
2003 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002004 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2005 .halt_bit = 7,
2006 },
2007 .c = {
2008 .dbg_name = "gsbi2_p_clk",
2009 .ops = &clk_ops_branch,
2010 CLK_INIT(gsbi2_p_clk.c),
2011 },
2012};
2013
2014static struct branch_clk gsbi3_p_clk = {
2015 .b = {
2016 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
2017 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002018 .hwcg_reg = GSBIn_HCLK_CTL_REG(3),
2019 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002020 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2021 .halt_bit = 3,
2022 },
2023 .c = {
2024 .dbg_name = "gsbi3_p_clk",
2025 .ops = &clk_ops_branch,
2026 CLK_INIT(gsbi3_p_clk.c),
2027 },
2028};
2029
2030static struct branch_clk gsbi4_p_clk = {
2031 .b = {
2032 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
2033 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002034 .hwcg_reg = GSBIn_HCLK_CTL_REG(4),
2035 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002036 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2037 .halt_bit = 27,
2038 },
2039 .c = {
2040 .dbg_name = "gsbi4_p_clk",
2041 .ops = &clk_ops_branch,
2042 CLK_INIT(gsbi4_p_clk.c),
2043 },
2044};
2045
2046static struct branch_clk gsbi5_p_clk = {
2047 .b = {
2048 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
2049 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002050 .hwcg_reg = GSBIn_HCLK_CTL_REG(5),
2051 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002052 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2053 .halt_bit = 23,
2054 },
2055 .c = {
2056 .dbg_name = "gsbi5_p_clk",
2057 .ops = &clk_ops_branch,
2058 CLK_INIT(gsbi5_p_clk.c),
2059 },
2060};
2061
2062static struct branch_clk gsbi6_p_clk = {
2063 .b = {
2064 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
2065 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002066 .hwcg_reg = GSBIn_HCLK_CTL_REG(6),
2067 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002068 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2069 .halt_bit = 19,
2070 },
2071 .c = {
2072 .dbg_name = "gsbi6_p_clk",
2073 .ops = &clk_ops_branch,
2074 CLK_INIT(gsbi6_p_clk.c),
2075 },
2076};
2077
2078static struct branch_clk gsbi7_p_clk = {
2079 .b = {
2080 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
2081 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002082 .hwcg_reg = GSBIn_HCLK_CTL_REG(7),
2083 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002084 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2085 .halt_bit = 15,
2086 },
2087 .c = {
2088 .dbg_name = "gsbi7_p_clk",
2089 .ops = &clk_ops_branch,
2090 CLK_INIT(gsbi7_p_clk.c),
2091 },
2092};
2093
2094static struct branch_clk gsbi8_p_clk = {
2095 .b = {
2096 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
2097 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002098 .hwcg_reg = GSBIn_HCLK_CTL_REG(8),
2099 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002100 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2101 .halt_bit = 11,
2102 },
2103 .c = {
2104 .dbg_name = "gsbi8_p_clk",
2105 .ops = &clk_ops_branch,
2106 CLK_INIT(gsbi8_p_clk.c),
2107 },
2108};
2109
2110static struct branch_clk gsbi9_p_clk = {
2111 .b = {
2112 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
2113 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002114 .hwcg_reg = GSBIn_HCLK_CTL_REG(9),
2115 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002116 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2117 .halt_bit = 7,
2118 },
2119 .c = {
2120 .dbg_name = "gsbi9_p_clk",
2121 .ops = &clk_ops_branch,
2122 CLK_INIT(gsbi9_p_clk.c),
2123 },
2124};
2125
2126static struct branch_clk gsbi10_p_clk = {
2127 .b = {
2128 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
2129 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002130 .hwcg_reg = GSBIn_HCLK_CTL_REG(10),
2131 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002132 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2133 .halt_bit = 3,
2134 },
2135 .c = {
2136 .dbg_name = "gsbi10_p_clk",
2137 .ops = &clk_ops_branch,
2138 CLK_INIT(gsbi10_p_clk.c),
2139 },
2140};
2141
2142static struct branch_clk gsbi11_p_clk = {
2143 .b = {
2144 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
2145 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002146 .hwcg_reg = GSBIn_HCLK_CTL_REG(11),
2147 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002148 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2149 .halt_bit = 18,
2150 },
2151 .c = {
2152 .dbg_name = "gsbi11_p_clk",
2153 .ops = &clk_ops_branch,
2154 CLK_INIT(gsbi11_p_clk.c),
2155 },
2156};
2157
2158static struct branch_clk gsbi12_p_clk = {
2159 .b = {
2160 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
2161 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002162 .hwcg_reg = GSBIn_HCLK_CTL_REG(12),
2163 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002164 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2165 .halt_bit = 14,
2166 },
2167 .c = {
2168 .dbg_name = "gsbi12_p_clk",
2169 .ops = &clk_ops_branch,
2170 CLK_INIT(gsbi12_p_clk.c),
2171 },
2172};
2173
Tianyi Gou41515e22011-09-01 19:37:43 -07002174static struct branch_clk sata_phy_cfg_clk = {
2175 .b = {
2176 .ctl_reg = SATA_PHY_CFG_CLK_CTL_REG,
2177 .en_mask = BIT(4),
2178 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2179 .halt_bit = 12,
2180 },
2181 .c = {
2182 .dbg_name = "sata_phy_cfg_clk",
2183 .ops = &clk_ops_branch,
2184 CLK_INIT(sata_phy_cfg_clk.c),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002185 },
2186};
2187
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002188static struct branch_clk tsif_p_clk = {
2189 .b = {
2190 .ctl_reg = TSIF_HCLK_CTL_REG,
2191 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002192 .hwcg_reg = TSIF_HCLK_CTL_REG,
2193 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002194 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2195 .halt_bit = 7,
2196 },
2197 .c = {
2198 .dbg_name = "tsif_p_clk",
2199 .ops = &clk_ops_branch,
2200 CLK_INIT(tsif_p_clk.c),
2201 },
2202};
2203
2204static struct branch_clk usb_fs1_p_clk = {
2205 .b = {
2206 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
2207 .en_mask = BIT(4),
2208 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2209 .halt_bit = 17,
2210 },
2211 .c = {
2212 .dbg_name = "usb_fs1_p_clk",
2213 .ops = &clk_ops_branch,
2214 CLK_INIT(usb_fs1_p_clk.c),
2215 },
2216};
2217
2218static struct branch_clk usb_fs2_p_clk = {
2219 .b = {
2220 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
2221 .en_mask = BIT(4),
2222 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2223 .halt_bit = 14,
2224 },
2225 .c = {
2226 .dbg_name = "usb_fs2_p_clk",
2227 .ops = &clk_ops_branch,
2228 CLK_INIT(usb_fs2_p_clk.c),
2229 },
2230};
2231
2232static struct branch_clk usb_hs1_p_clk = {
2233 .b = {
2234 .ctl_reg = USB_HS1_HCLK_CTL_REG,
2235 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002236 .hwcg_reg = USB_HS1_HCLK_CTL_REG,
2237 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002238 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2239 .halt_bit = 1,
2240 },
2241 .c = {
2242 .dbg_name = "usb_hs1_p_clk",
2243 .ops = &clk_ops_branch,
2244 CLK_INIT(usb_hs1_p_clk.c),
2245 },
2246};
2247
Tianyi Gou41515e22011-09-01 19:37:43 -07002248static struct branch_clk usb_hs3_p_clk = {
2249 .b = {
2250 .ctl_reg = USB_HS3_HCLK_CTL_REG,
2251 .en_mask = BIT(4),
2252 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2253 .halt_bit = 31,
2254 },
2255 .c = {
2256 .dbg_name = "usb_hs3_p_clk",
2257 .ops = &clk_ops_branch,
2258 CLK_INIT(usb_hs3_p_clk.c),
2259 },
2260};
2261
2262static struct branch_clk usb_hs4_p_clk = {
2263 .b = {
2264 .ctl_reg = USB_HS4_HCLK_CTL_REG,
2265 .en_mask = BIT(4),
2266 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2267 .halt_bit = 7,
2268 },
2269 .c = {
2270 .dbg_name = "usb_hs4_p_clk",
2271 .ops = &clk_ops_branch,
2272 CLK_INIT(usb_hs4_p_clk.c),
2273 },
2274};
2275
Stephen Boyd94625ef2011-07-12 17:06:01 -07002276static struct branch_clk usb_hsic_p_clk = {
2277 .b = {
2278 .ctl_reg = USB_HSIC_HCLK_CTL_REG,
2279 .en_mask = BIT(4),
2280 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2281 .halt_bit = 28,
2282 },
2283 .c = {
2284 .dbg_name = "usb_hsic_p_clk",
2285 .ops = &clk_ops_branch,
2286 CLK_INIT(usb_hsic_p_clk.c),
2287 },
2288};
2289
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002290static struct branch_clk sdc1_p_clk = {
2291 .b = {
2292 .ctl_reg = SDCn_HCLK_CTL_REG(1),
2293 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002294 .hwcg_reg = SDCn_HCLK_CTL_REG(1),
2295 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002296 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2297 .halt_bit = 11,
2298 },
2299 .c = {
2300 .dbg_name = "sdc1_p_clk",
2301 .ops = &clk_ops_branch,
2302 CLK_INIT(sdc1_p_clk.c),
2303 },
2304};
2305
2306static struct branch_clk sdc2_p_clk = {
2307 .b = {
2308 .ctl_reg = SDCn_HCLK_CTL_REG(2),
2309 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002310 .hwcg_reg = SDCn_HCLK_CTL_REG(2),
2311 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002312 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2313 .halt_bit = 10,
2314 },
2315 .c = {
2316 .dbg_name = "sdc2_p_clk",
2317 .ops = &clk_ops_branch,
2318 CLK_INIT(sdc2_p_clk.c),
2319 },
2320};
2321
2322static struct branch_clk sdc3_p_clk = {
2323 .b = {
2324 .ctl_reg = SDCn_HCLK_CTL_REG(3),
2325 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002326 .hwcg_reg = SDCn_HCLK_CTL_REG(3),
2327 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002328 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2329 .halt_bit = 9,
2330 },
2331 .c = {
2332 .dbg_name = "sdc3_p_clk",
2333 .ops = &clk_ops_branch,
2334 CLK_INIT(sdc3_p_clk.c),
2335 },
2336};
2337
2338static struct branch_clk sdc4_p_clk = {
2339 .b = {
2340 .ctl_reg = SDCn_HCLK_CTL_REG(4),
2341 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002342 .hwcg_reg = SDCn_HCLK_CTL_REG(4),
2343 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002344 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2345 .halt_bit = 8,
2346 },
2347 .c = {
2348 .dbg_name = "sdc4_p_clk",
2349 .ops = &clk_ops_branch,
2350 CLK_INIT(sdc4_p_clk.c),
2351 },
2352};
2353
2354static struct branch_clk sdc5_p_clk = {
2355 .b = {
2356 .ctl_reg = SDCn_HCLK_CTL_REG(5),
2357 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002358 .hwcg_reg = SDCn_HCLK_CTL_REG(5),
2359 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002360 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2361 .halt_bit = 7,
2362 },
2363 .c = {
2364 .dbg_name = "sdc5_p_clk",
2365 .ops = &clk_ops_branch,
2366 CLK_INIT(sdc5_p_clk.c),
2367 },
2368};
2369
2370/* HW-Voteable Clocks */
2371static struct branch_clk adm0_clk = {
2372 .b = {
2373 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2374 .en_mask = BIT(2),
2375 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2376 .halt_check = HALT_VOTED,
2377 .halt_bit = 14,
2378 },
2379 .c = {
2380 .dbg_name = "adm0_clk",
2381 .ops = &clk_ops_branch,
2382 CLK_INIT(adm0_clk.c),
2383 },
2384};
2385
2386static struct branch_clk adm0_p_clk = {
2387 .b = {
2388 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2389 .en_mask = BIT(3),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002390 .hwcg_reg = ADM0_PBUS_CLK_CTL_REG,
2391 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002392 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2393 .halt_check = HALT_VOTED,
2394 .halt_bit = 13,
2395 },
2396 .c = {
2397 .dbg_name = "adm0_p_clk",
2398 .ops = &clk_ops_branch,
2399 CLK_INIT(adm0_p_clk.c),
2400 },
2401};
2402
2403static struct branch_clk pmic_arb0_p_clk = {
2404 .b = {
2405 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2406 .en_mask = BIT(8),
2407 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2408 .halt_check = HALT_VOTED,
2409 .halt_bit = 22,
2410 },
2411 .c = {
2412 .dbg_name = "pmic_arb0_p_clk",
2413 .ops = &clk_ops_branch,
2414 CLK_INIT(pmic_arb0_p_clk.c),
2415 },
2416};
2417
2418static struct branch_clk pmic_arb1_p_clk = {
2419 .b = {
2420 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2421 .en_mask = BIT(9),
2422 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2423 .halt_check = HALT_VOTED,
2424 .halt_bit = 21,
2425 },
2426 .c = {
2427 .dbg_name = "pmic_arb1_p_clk",
2428 .ops = &clk_ops_branch,
2429 CLK_INIT(pmic_arb1_p_clk.c),
2430 },
2431};
2432
2433static struct branch_clk pmic_ssbi2_clk = {
2434 .b = {
2435 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2436 .en_mask = BIT(7),
2437 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2438 .halt_check = HALT_VOTED,
2439 .halt_bit = 23,
2440 },
2441 .c = {
2442 .dbg_name = "pmic_ssbi2_clk",
2443 .ops = &clk_ops_branch,
2444 CLK_INIT(pmic_ssbi2_clk.c),
2445 },
2446};
2447
2448static struct branch_clk rpm_msg_ram_p_clk = {
2449 .b = {
2450 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2451 .en_mask = BIT(6),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002452 .hwcg_reg = RPM_MSG_RAM_HCLK_CTL_REG,
2453 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002454 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2455 .halt_check = HALT_VOTED,
2456 .halt_bit = 12,
2457 },
2458 .c = {
2459 .dbg_name = "rpm_msg_ram_p_clk",
2460 .ops = &clk_ops_branch,
2461 CLK_INIT(rpm_msg_ram_p_clk.c),
2462 },
2463};
2464
2465/*
2466 * Multimedia Clocks
2467 */
2468
2469static struct branch_clk amp_clk = {
2470 .b = {
2471 .reset_reg = SW_RESET_CORE_REG,
2472 .reset_mask = BIT(20),
2473 },
2474 .c = {
2475 .dbg_name = "amp_clk",
2476 .ops = &clk_ops_reset,
2477 CLK_INIT(amp_clk.c),
2478 },
2479};
2480
Stephen Boyd94625ef2011-07-12 17:06:01 -07002481#define CLK_CAM(name, n, hb) \
2482 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002483 .b = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002484 .ctl_reg = CAMCLK##n##_CC_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002485 .en_mask = BIT(0), \
2486 .halt_reg = DBG_BUS_VEC_I_REG, \
2487 .halt_bit = hb, \
2488 }, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002489 .ns_reg = CAMCLK##n##_NS_REG, \
2490 .md_reg = CAMCLK##n##_MD_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002491 .root_en_mask = BIT(2), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002492 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0), \
Matt Wagantall07c45472012-02-10 23:27:24 -08002493 .mnd_en_mask = BIT(5), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002494 .ctl_mask = BM(7, 6), \
2495 .set_rate = set_rate_mnd_8, \
2496 .freq_tbl = clk_tbl_cam, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002497 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002498 .c = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002499 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002500 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002501 VDD_DIG_FMAX_MAP2(LOW, 64000000, NOMINAL, 128000000), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002502 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002503 }, \
2504 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002505#define F_CAM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002506 { \
2507 .freq_hz = f, \
2508 .src_clk = &s##_clk.c, \
2509 .md_val = MD8(8, m, 0, n), \
2510 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2511 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002512 }
2513static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002514 F_CAM( 0, gnd, 1, 0, 0),
2515 F_CAM( 6000000, pll8, 4, 1, 16),
2516 F_CAM( 8000000, pll8, 4, 1, 12),
2517 F_CAM( 12000000, pll8, 4, 1, 8),
2518 F_CAM( 16000000, pll8, 4, 1, 6),
2519 F_CAM( 19200000, pll8, 4, 1, 5),
2520 F_CAM( 24000000, pll8, 4, 1, 4),
2521 F_CAM( 32000000, pll8, 4, 1, 3),
2522 F_CAM( 48000000, pll8, 4, 1, 2),
2523 F_CAM( 64000000, pll8, 3, 1, 2),
2524 F_CAM( 96000000, pll8, 4, 0, 0),
2525 F_CAM(128000000, pll8, 3, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002526 F_END
2527};
2528
Stephen Boyd94625ef2011-07-12 17:06:01 -07002529static CLK_CAM(cam0_clk, 0, 15);
2530static CLK_CAM(cam1_clk, 1, 16);
2531static CLK_CAM(cam2_clk, 2, 31);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002532
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002533#define F_CSI(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002534 { \
2535 .freq_hz = f, \
2536 .src_clk = &s##_clk.c, \
2537 .md_val = MD8(8, m, 0, n), \
2538 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2539 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002540 }
2541static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002542 F_CSI( 0, gnd, 1, 0, 0),
Stephen Boyd092fd182011-10-21 15:56:30 -07002543 F_CSI( 27000000, pxo, 1, 0, 0),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002544 F_CSI( 85330000, pll8, 1, 2, 9),
2545 F_CSI(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002546 F_END
2547};
2548
2549static struct rcg_clk csi0_src_clk = {
2550 .ns_reg = CSI0_NS_REG,
2551 .b = {
2552 .ctl_reg = CSI0_CC_REG,
2553 .halt_check = NOCHECK,
2554 },
2555 .md_reg = CSI0_MD_REG,
2556 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002557 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Matt Wagantall07c45472012-02-10 23:27:24 -08002558 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002559 .ctl_mask = BM(7, 6),
2560 .set_rate = set_rate_mnd,
2561 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002562 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002563 .c = {
2564 .dbg_name = "csi0_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002565 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002566 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002567 CLK_INIT(csi0_src_clk.c),
2568 },
2569};
2570
2571static struct branch_clk csi0_clk = {
2572 .b = {
2573 .ctl_reg = CSI0_CC_REG,
2574 .en_mask = BIT(0),
2575 .reset_reg = SW_RESET_CORE_REG,
2576 .reset_mask = BIT(8),
2577 .halt_reg = DBG_BUS_VEC_B_REG,
2578 .halt_bit = 13,
2579 },
2580 .parent = &csi0_src_clk.c,
2581 .c = {
2582 .dbg_name = "csi0_clk",
2583 .ops = &clk_ops_branch,
2584 CLK_INIT(csi0_clk.c),
2585 },
2586};
2587
2588static struct branch_clk csi0_phy_clk = {
2589 .b = {
2590 .ctl_reg = CSI0_CC_REG,
2591 .en_mask = BIT(8),
2592 .reset_reg = SW_RESET_CORE_REG,
2593 .reset_mask = BIT(29),
2594 .halt_reg = DBG_BUS_VEC_I_REG,
2595 .halt_bit = 9,
2596 },
2597 .parent = &csi0_src_clk.c,
2598 .c = {
2599 .dbg_name = "csi0_phy_clk",
2600 .ops = &clk_ops_branch,
2601 CLK_INIT(csi0_phy_clk.c),
2602 },
2603};
2604
2605static struct rcg_clk csi1_src_clk = {
2606 .ns_reg = CSI1_NS_REG,
2607 .b = {
2608 .ctl_reg = CSI1_CC_REG,
2609 .halt_check = NOCHECK,
2610 },
2611 .md_reg = CSI1_MD_REG,
2612 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002613 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Matt Wagantall07c45472012-02-10 23:27:24 -08002614 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002615 .ctl_mask = BM(7, 6),
2616 .set_rate = set_rate_mnd,
2617 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002618 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002619 .c = {
2620 .dbg_name = "csi1_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002621 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002622 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002623 CLK_INIT(csi1_src_clk.c),
2624 },
2625};
2626
2627static struct branch_clk csi1_clk = {
2628 .b = {
2629 .ctl_reg = CSI1_CC_REG,
2630 .en_mask = BIT(0),
2631 .reset_reg = SW_RESET_CORE_REG,
2632 .reset_mask = BIT(18),
2633 .halt_reg = DBG_BUS_VEC_B_REG,
2634 .halt_bit = 14,
2635 },
2636 .parent = &csi1_src_clk.c,
2637 .c = {
2638 .dbg_name = "csi1_clk",
2639 .ops = &clk_ops_branch,
2640 CLK_INIT(csi1_clk.c),
2641 },
2642};
2643
2644static struct branch_clk csi1_phy_clk = {
2645 .b = {
2646 .ctl_reg = CSI1_CC_REG,
2647 .en_mask = BIT(8),
2648 .reset_reg = SW_RESET_CORE_REG,
2649 .reset_mask = BIT(28),
2650 .halt_reg = DBG_BUS_VEC_I_REG,
2651 .halt_bit = 10,
2652 },
2653 .parent = &csi1_src_clk.c,
2654 .c = {
2655 .dbg_name = "csi1_phy_clk",
2656 .ops = &clk_ops_branch,
2657 CLK_INIT(csi1_phy_clk.c),
2658 },
2659};
2660
Stephen Boyd94625ef2011-07-12 17:06:01 -07002661static struct rcg_clk csi2_src_clk = {
2662 .ns_reg = CSI2_NS_REG,
2663 .b = {
2664 .ctl_reg = CSI2_CC_REG,
2665 .halt_check = NOCHECK,
2666 },
2667 .md_reg = CSI2_MD_REG,
2668 .root_en_mask = BIT(2),
2669 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Matt Wagantall07c45472012-02-10 23:27:24 -08002670 .mnd_en_mask = BIT(5),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002671 .ctl_mask = BM(7, 6),
2672 .set_rate = set_rate_mnd,
2673 .freq_tbl = clk_tbl_csi,
2674 .current_freq = &rcg_dummy_freq,
2675 .c = {
2676 .dbg_name = "csi2_src_clk",
2677 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002678 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002679 CLK_INIT(csi2_src_clk.c),
2680 },
2681};
2682
2683static struct branch_clk csi2_clk = {
2684 .b = {
2685 .ctl_reg = CSI2_CC_REG,
2686 .en_mask = BIT(0),
2687 .reset_reg = SW_RESET_CORE2_REG,
2688 .reset_mask = BIT(2),
2689 .halt_reg = DBG_BUS_VEC_B_REG,
2690 .halt_bit = 29,
2691 },
2692 .parent = &csi2_src_clk.c,
2693 .c = {
2694 .dbg_name = "csi2_clk",
2695 .ops = &clk_ops_branch,
2696 CLK_INIT(csi2_clk.c),
2697 },
2698};
2699
2700static struct branch_clk csi2_phy_clk = {
2701 .b = {
2702 .ctl_reg = CSI2_CC_REG,
2703 .en_mask = BIT(8),
2704 .reset_reg = SW_RESET_CORE_REG,
2705 .reset_mask = BIT(31),
2706 .halt_reg = DBG_BUS_VEC_I_REG,
2707 .halt_bit = 29,
2708 },
2709 .parent = &csi2_src_clk.c,
2710 .c = {
2711 .dbg_name = "csi2_phy_clk",
2712 .ops = &clk_ops_branch,
2713 CLK_INIT(csi2_phy_clk.c),
2714 },
2715};
2716
Stephen Boyd092fd182011-10-21 15:56:30 -07002717static struct clk *pix_rdi_mux_map[] = {
2718 [0] = &csi0_clk.c,
2719 [1] = &csi1_clk.c,
2720 [2] = &csi2_clk.c,
2721 NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002722};
2723
Stephen Boyd092fd182011-10-21 15:56:30 -07002724struct pix_rdi_clk {
2725 bool enabled;
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002726 unsigned long cur_rate;
Stephen Boyd092fd182011-10-21 15:56:30 -07002727
2728 void __iomem *const s_reg;
2729 u32 s_mask;
2730
2731 void __iomem *const s2_reg;
2732 u32 s2_mask;
2733
2734 struct branch b;
2735 struct clk c;
2736};
2737
2738static inline struct pix_rdi_clk *to_pix_rdi_clk(struct clk *clk)
2739{
2740 return container_of(clk, struct pix_rdi_clk, c);
2741}
2742
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002743static int pix_rdi_clk_set_rate(struct clk *c, unsigned long rate)
Stephen Boyd092fd182011-10-21 15:56:30 -07002744{
2745 int ret, i;
2746 u32 reg;
2747 unsigned long flags;
2748 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2749 struct clk **mux_map = pix_rdi_mux_map;
2750
2751 /*
2752 * These clocks select three inputs via two muxes. One mux selects
2753 * between csi0 and csi1 and the second mux selects between that mux's
2754 * output and csi2. The source and destination selections for each
2755 * mux must be clocking for the switch to succeed so just turn on
2756 * all three sources because it's easier than figuring out what source
2757 * needs to be on at what time.
2758 */
2759 for (i = 0; mux_map[i]; i++) {
2760 ret = clk_enable(mux_map[i]);
2761 if (ret)
2762 goto err;
2763 }
2764 if (rate >= i) {
2765 ret = -EINVAL;
2766 goto err;
2767 }
2768 /* Keep the new source on when switching inputs of an enabled clock */
2769 if (clk->enabled) {
2770 clk_disable(mux_map[clk->cur_rate]);
2771 clk_enable(mux_map[rate]);
2772 }
2773 spin_lock_irqsave(&local_clock_reg_lock, flags);
2774 reg = readl_relaxed(clk->s2_reg);
2775 reg &= ~clk->s2_mask;
2776 reg |= rate == 2 ? clk->s2_mask : 0;
2777 writel_relaxed(reg, clk->s2_reg);
2778 /*
2779 * Wait at least 6 cycles of slowest clock
2780 * for the glitch-free MUX to fully switch sources.
2781 */
2782 mb();
2783 udelay(1);
2784 reg = readl_relaxed(clk->s_reg);
2785 reg &= ~clk->s_mask;
2786 reg |= rate == 1 ? clk->s_mask : 0;
2787 writel_relaxed(reg, clk->s_reg);
2788 /*
2789 * Wait at least 6 cycles of slowest clock
2790 * for the glitch-free MUX to fully switch sources.
2791 */
2792 mb();
2793 udelay(1);
2794 clk->cur_rate = rate;
2795 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2796err:
2797 for (i--; i >= 0; i--)
2798 clk_disable(mux_map[i]);
2799
2800 return 0;
2801}
2802
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002803static unsigned long pix_rdi_clk_get_rate(struct clk *c)
Stephen Boyd092fd182011-10-21 15:56:30 -07002804{
2805 return to_pix_rdi_clk(c)->cur_rate;
2806}
2807
2808static int pix_rdi_clk_enable(struct clk *c)
2809{
2810 unsigned long flags;
2811 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2812
2813 spin_lock_irqsave(&local_clock_reg_lock, flags);
2814 __branch_clk_enable_reg(&clk->b, clk->c.dbg_name);
2815 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2816 clk->enabled = true;
2817
2818 return 0;
2819}
2820
2821static void pix_rdi_clk_disable(struct clk *c)
2822{
2823 unsigned long flags;
2824 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2825
2826 spin_lock_irqsave(&local_clock_reg_lock, flags);
2827 __branch_clk_disable_reg(&clk->b, clk->c.dbg_name);
2828 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
2829 clk->enabled = false;
2830}
2831
2832static int pix_rdi_clk_reset(struct clk *clk, enum clk_reset_action action)
2833{
2834 return branch_reset(&to_pix_rdi_clk(clk)->b, action);
2835}
2836
2837static struct clk *pix_rdi_clk_get_parent(struct clk *c)
2838{
2839 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2840
2841 return pix_rdi_mux_map[clk->cur_rate];
2842}
2843
2844static int pix_rdi_clk_list_rate(struct clk *c, unsigned n)
2845{
2846 if (pix_rdi_mux_map[n])
2847 return n;
2848 return -ENXIO;
2849}
2850
2851static int pix_rdi_clk_handoff(struct clk *c)
2852{
2853 u32 reg;
2854 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
2855
2856 reg = readl_relaxed(clk->s_reg);
2857 clk->cur_rate = reg & clk->s_mask ? 1 : 0;
2858 reg = readl_relaxed(clk->s2_reg);
2859 clk->cur_rate = reg & clk->s2_mask ? 2 : clk->cur_rate;
2860 return 0;
2861}
2862
2863static struct clk_ops clk_ops_pix_rdi_8960 = {
2864 .enable = pix_rdi_clk_enable,
2865 .disable = pix_rdi_clk_disable,
2866 .auto_off = pix_rdi_clk_disable,
2867 .handoff = pix_rdi_clk_handoff,
2868 .set_rate = pix_rdi_clk_set_rate,
2869 .get_rate = pix_rdi_clk_get_rate,
2870 .list_rate = pix_rdi_clk_list_rate,
2871 .reset = pix_rdi_clk_reset,
2872 .is_local = local_clk_is_local,
2873 .get_parent = pix_rdi_clk_get_parent,
2874};
2875
2876static struct pix_rdi_clk csi_pix_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002877 .b = {
2878 .ctl_reg = MISC_CC_REG,
2879 .en_mask = BIT(26),
2880 .halt_check = DELAY,
2881 .reset_reg = SW_RESET_CORE_REG,
2882 .reset_mask = BIT(26),
2883 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002884 .s_reg = MISC_CC_REG,
2885 .s_mask = BIT(25),
2886 .s2_reg = MISC_CC3_REG,
2887 .s2_mask = BIT(13),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002888 .c = {
2889 .dbg_name = "csi_pix_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002890 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002891 CLK_INIT(csi_pix_clk.c),
2892 },
2893};
2894
Stephen Boyd092fd182011-10-21 15:56:30 -07002895static struct pix_rdi_clk csi_pix1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07002896 .b = {
2897 .ctl_reg = MISC_CC3_REG,
2898 .en_mask = BIT(10),
2899 .halt_check = DELAY,
2900 .reset_reg = SW_RESET_CORE_REG,
2901 .reset_mask = BIT(30),
2902 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002903 .s_reg = MISC_CC3_REG,
2904 .s_mask = BIT(8),
2905 .s2_reg = MISC_CC3_REG,
2906 .s2_mask = BIT(9),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002907 .c = {
2908 .dbg_name = "csi_pix1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002909 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07002910 CLK_INIT(csi_pix1_clk.c),
2911 },
2912};
2913
Stephen Boyd092fd182011-10-21 15:56:30 -07002914static struct pix_rdi_clk csi_rdi_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002915 .b = {
2916 .ctl_reg = MISC_CC_REG,
2917 .en_mask = BIT(13),
2918 .halt_check = DELAY,
2919 .reset_reg = SW_RESET_CORE_REG,
2920 .reset_mask = BIT(27),
2921 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002922 .s_reg = MISC_CC_REG,
2923 .s_mask = BIT(12),
2924 .s2_reg = MISC_CC3_REG,
2925 .s2_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002926 .c = {
2927 .dbg_name = "csi_rdi_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002928 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002929 CLK_INIT(csi_rdi_clk.c),
2930 },
2931};
2932
Stephen Boyd092fd182011-10-21 15:56:30 -07002933static struct pix_rdi_clk csi_rdi1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07002934 .b = {
2935 .ctl_reg = MISC_CC3_REG,
2936 .en_mask = BIT(2),
2937 .halt_check = DELAY,
2938 .reset_reg = SW_RESET_CORE2_REG,
2939 .reset_mask = BIT(1),
2940 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002941 .s_reg = MISC_CC3_REG,
2942 .s_mask = BIT(0),
2943 .s2_reg = MISC_CC3_REG,
2944 .s2_mask = BIT(1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002945 .c = {
2946 .dbg_name = "csi_rdi1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002947 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07002948 CLK_INIT(csi_rdi1_clk.c),
2949 },
2950};
2951
Stephen Boyd092fd182011-10-21 15:56:30 -07002952static struct pix_rdi_clk csi_rdi2_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07002953 .b = {
2954 .ctl_reg = MISC_CC3_REG,
2955 .en_mask = BIT(6),
2956 .halt_check = DELAY,
2957 .reset_reg = SW_RESET_CORE2_REG,
2958 .reset_mask = BIT(0),
2959 },
Stephen Boyd092fd182011-10-21 15:56:30 -07002960 .s_reg = MISC_CC3_REG,
2961 .s_mask = BIT(4),
2962 .s2_reg = MISC_CC3_REG,
2963 .s2_mask = BIT(5),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002964 .c = {
2965 .dbg_name = "csi_rdi2_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07002966 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07002967 CLK_INIT(csi_rdi2_clk.c),
2968 },
2969};
2970
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002971#define F_CSI_PHYTIMER(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002972 { \
2973 .freq_hz = f, \
2974 .src_clk = &s##_clk.c, \
2975 .md_val = MD8(8, m, 0, n), \
2976 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2977 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002978 }
2979static struct clk_freq_tbl clk_tbl_csi_phytimer[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002980 F_CSI_PHYTIMER( 0, gnd, 1, 0, 0),
2981 F_CSI_PHYTIMER( 85330000, pll8, 1, 2, 9),
2982 F_CSI_PHYTIMER(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002983 F_END
2984};
2985
2986static struct rcg_clk csiphy_timer_src_clk = {
2987 .ns_reg = CSIPHYTIMER_NS_REG,
2988 .b = {
2989 .ctl_reg = CSIPHYTIMER_CC_REG,
2990 .halt_check = NOCHECK,
2991 },
2992 .md_reg = CSIPHYTIMER_MD_REG,
2993 .root_en_mask = BIT(2),
2994 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08002995 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002996 .ctl_mask = BM(7, 6),
2997 .set_rate = set_rate_mnd_8,
2998 .freq_tbl = clk_tbl_csi_phytimer,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002999 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003000 .c = {
3001 .dbg_name = "csiphy_timer_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003002 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003003 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003004 CLK_INIT(csiphy_timer_src_clk.c),
3005 },
3006};
3007
3008static struct branch_clk csi0phy_timer_clk = {
3009 .b = {
3010 .ctl_reg = CSIPHYTIMER_CC_REG,
3011 .en_mask = BIT(0),
3012 .halt_reg = DBG_BUS_VEC_I_REG,
3013 .halt_bit = 17,
3014 },
3015 .parent = &csiphy_timer_src_clk.c,
3016 .c = {
3017 .dbg_name = "csi0phy_timer_clk",
3018 .ops = &clk_ops_branch,
3019 CLK_INIT(csi0phy_timer_clk.c),
3020 },
3021};
3022
3023static struct branch_clk csi1phy_timer_clk = {
3024 .b = {
3025 .ctl_reg = CSIPHYTIMER_CC_REG,
3026 .en_mask = BIT(9),
3027 .halt_reg = DBG_BUS_VEC_I_REG,
3028 .halt_bit = 18,
3029 },
3030 .parent = &csiphy_timer_src_clk.c,
3031 .c = {
3032 .dbg_name = "csi1phy_timer_clk",
3033 .ops = &clk_ops_branch,
3034 CLK_INIT(csi1phy_timer_clk.c),
3035 },
3036};
3037
Stephen Boyd94625ef2011-07-12 17:06:01 -07003038static struct branch_clk csi2phy_timer_clk = {
3039 .b = {
3040 .ctl_reg = CSIPHYTIMER_CC_REG,
3041 .en_mask = BIT(11),
3042 .halt_reg = DBG_BUS_VEC_I_REG,
3043 .halt_bit = 30,
3044 },
3045 .parent = &csiphy_timer_src_clk.c,
3046 .c = {
3047 .dbg_name = "csi2phy_timer_clk",
3048 .ops = &clk_ops_branch,
3049 CLK_INIT(csi2phy_timer_clk.c),
3050 },
3051};
3052
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003053#define F_DSI(d) \
3054 { \
3055 .freq_hz = d, \
3056 .ns_val = BVAL(15, 12, (d-1)), \
3057 }
3058/*
3059 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
3060 * without this clock driver knowing. So, overload the clk_set_rate() to set
3061 * the divider (1 to 16) of the clock with respect to the PLL rate.
3062 */
3063static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
3064 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
3065 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
3066 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
3067 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
3068 F_END
3069};
3070
3071static struct rcg_clk dsi1_byte_clk = {
3072 .b = {
3073 .ctl_reg = DSI1_BYTE_CC_REG,
3074 .en_mask = BIT(0),
3075 .reset_reg = SW_RESET_CORE_REG,
3076 .reset_mask = BIT(7),
3077 .halt_reg = DBG_BUS_VEC_B_REG,
3078 .halt_bit = 21,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003079 .retain_reg = DSI1_BYTE_CC_REG,
3080 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003081 },
3082 .ns_reg = DSI1_BYTE_NS_REG,
3083 .root_en_mask = BIT(2),
3084 .ns_mask = BM(15, 12),
3085 .set_rate = set_rate_nop,
3086 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003087 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003088 .c = {
3089 .dbg_name = "dsi1_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003090 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003091 CLK_INIT(dsi1_byte_clk.c),
3092 },
3093};
3094
3095static struct rcg_clk dsi2_byte_clk = {
3096 .b = {
3097 .ctl_reg = DSI2_BYTE_CC_REG,
3098 .en_mask = BIT(0),
3099 .reset_reg = SW_RESET_CORE_REG,
3100 .reset_mask = BIT(25),
3101 .halt_reg = DBG_BUS_VEC_B_REG,
3102 .halt_bit = 20,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003103 .retain_reg = DSI2_BYTE_CC_REG,
3104 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003105 },
3106 .ns_reg = DSI2_BYTE_NS_REG,
3107 .root_en_mask = BIT(2),
3108 .ns_mask = BM(15, 12),
3109 .set_rate = set_rate_nop,
3110 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003111 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003112 .c = {
3113 .dbg_name = "dsi2_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003114 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003115 CLK_INIT(dsi2_byte_clk.c),
3116 },
3117};
3118
3119static struct rcg_clk dsi1_esc_clk = {
3120 .b = {
3121 .ctl_reg = DSI1_ESC_CC_REG,
3122 .en_mask = BIT(0),
3123 .reset_reg = SW_RESET_CORE_REG,
3124 .halt_reg = DBG_BUS_VEC_I_REG,
3125 .halt_bit = 1,
3126 },
3127 .ns_reg = DSI1_ESC_NS_REG,
3128 .root_en_mask = BIT(2),
3129 .ns_mask = BM(15, 12),
3130 .set_rate = set_rate_nop,
3131 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003132 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003133 .c = {
3134 .dbg_name = "dsi1_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003135 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003136 CLK_INIT(dsi1_esc_clk.c),
3137 },
3138};
3139
3140static struct rcg_clk dsi2_esc_clk = {
3141 .b = {
3142 .ctl_reg = DSI2_ESC_CC_REG,
3143 .en_mask = BIT(0),
3144 .halt_reg = DBG_BUS_VEC_I_REG,
3145 .halt_bit = 3,
3146 },
3147 .ns_reg = DSI2_ESC_NS_REG,
3148 .root_en_mask = BIT(2),
3149 .ns_mask = BM(15, 12),
3150 .set_rate = set_rate_nop,
3151 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003152 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003153 .c = {
3154 .dbg_name = "dsi2_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003155 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003156 CLK_INIT(dsi2_esc_clk.c),
3157 },
3158};
3159
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003160#define F_GFX2D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003161 { \
3162 .freq_hz = f, \
3163 .src_clk = &s##_clk.c, \
3164 .md_val = MD4(4, m, 0, n), \
3165 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
3166 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003167 }
3168static struct clk_freq_tbl clk_tbl_gfx2d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003169 F_GFX2D( 0, gnd, 0, 0),
3170 F_GFX2D( 27000000, pxo, 0, 0),
3171 F_GFX2D( 48000000, pll8, 1, 8),
3172 F_GFX2D( 54857000, pll8, 1, 7),
3173 F_GFX2D( 64000000, pll8, 1, 6),
3174 F_GFX2D( 76800000, pll8, 1, 5),
3175 F_GFX2D( 96000000, pll8, 1, 4),
3176 F_GFX2D(128000000, pll8, 1, 3),
3177 F_GFX2D(145455000, pll2, 2, 11),
3178 F_GFX2D(160000000, pll2, 1, 5),
3179 F_GFX2D(177778000, pll2, 2, 9),
3180 F_GFX2D(200000000, pll2, 1, 4),
3181 F_GFX2D(228571000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003182 F_END
3183};
3184
3185static struct bank_masks bmnd_info_gfx2d0 = {
3186 .bank_sel_mask = BIT(11),
3187 .bank0_mask = {
3188 .md_reg = GFX2D0_MD0_REG,
3189 .ns_mask = BM(23, 20) | BM(5, 3),
3190 .rst_mask = BIT(25),
3191 .mnd_en_mask = BIT(8),
3192 .mode_mask = BM(10, 9),
3193 },
3194 .bank1_mask = {
3195 .md_reg = GFX2D0_MD1_REG,
3196 .ns_mask = BM(19, 16) | BM(2, 0),
3197 .rst_mask = BIT(24),
3198 .mnd_en_mask = BIT(5),
3199 .mode_mask = BM(7, 6),
3200 },
3201};
3202
3203static struct rcg_clk gfx2d0_clk = {
3204 .b = {
3205 .ctl_reg = GFX2D0_CC_REG,
3206 .en_mask = BIT(0),
3207 .reset_reg = SW_RESET_CORE_REG,
3208 .reset_mask = BIT(14),
3209 .halt_reg = DBG_BUS_VEC_A_REG,
3210 .halt_bit = 9,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003211 .retain_reg = GFX2D0_CC_REG,
3212 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003213 },
3214 .ns_reg = GFX2D0_NS_REG,
3215 .root_en_mask = BIT(2),
3216 .set_rate = set_rate_mnd_banked,
3217 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003218 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003219 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003220 .c = {
3221 .dbg_name = "gfx2d0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003222 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003223 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3224 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003225 CLK_INIT(gfx2d0_clk.c),
3226 },
3227};
3228
3229static struct bank_masks bmnd_info_gfx2d1 = {
3230 .bank_sel_mask = BIT(11),
3231 .bank0_mask = {
3232 .md_reg = GFX2D1_MD0_REG,
3233 .ns_mask = BM(23, 20) | BM(5, 3),
3234 .rst_mask = BIT(25),
3235 .mnd_en_mask = BIT(8),
3236 .mode_mask = BM(10, 9),
3237 },
3238 .bank1_mask = {
3239 .md_reg = GFX2D1_MD1_REG,
3240 .ns_mask = BM(19, 16) | BM(2, 0),
3241 .rst_mask = BIT(24),
3242 .mnd_en_mask = BIT(5),
3243 .mode_mask = BM(7, 6),
3244 },
3245};
3246
3247static struct rcg_clk gfx2d1_clk = {
3248 .b = {
3249 .ctl_reg = GFX2D1_CC_REG,
3250 .en_mask = BIT(0),
3251 .reset_reg = SW_RESET_CORE_REG,
3252 .reset_mask = BIT(13),
3253 .halt_reg = DBG_BUS_VEC_A_REG,
3254 .halt_bit = 14,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003255 .retain_reg = GFX2D1_CC_REG,
3256 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003257 },
3258 .ns_reg = GFX2D1_NS_REG,
3259 .root_en_mask = BIT(2),
3260 .set_rate = set_rate_mnd_banked,
3261 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003262 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003263 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003264 .c = {
3265 .dbg_name = "gfx2d1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003266 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003267 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3268 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003269 CLK_INIT(gfx2d1_clk.c),
3270 },
3271};
3272
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003273#define F_GFX3D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003274 { \
3275 .freq_hz = f, \
3276 .src_clk = &s##_clk.c, \
3277 .md_val = MD4(4, m, 0, n), \
3278 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3279 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003280 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003281
3282static struct clk_freq_tbl clk_tbl_gfx3d_8960[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003283 F_GFX3D( 0, gnd, 0, 0),
3284 F_GFX3D( 27000000, pxo, 0, 0),
3285 F_GFX3D( 48000000, pll8, 1, 8),
3286 F_GFX3D( 54857000, pll8, 1, 7),
3287 F_GFX3D( 64000000, pll8, 1, 6),
3288 F_GFX3D( 76800000, pll8, 1, 5),
3289 F_GFX3D( 96000000, pll8, 1, 4),
3290 F_GFX3D(128000000, pll8, 1, 3),
3291 F_GFX3D(145455000, pll2, 2, 11),
3292 F_GFX3D(160000000, pll2, 1, 5),
3293 F_GFX3D(177778000, pll2, 2, 9),
3294 F_GFX3D(200000000, pll2, 1, 4),
3295 F_GFX3D(228571000, pll2, 2, 7),
3296 F_GFX3D(266667000, pll2, 1, 3),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003297 F_GFX3D(300000000, pll3, 1, 4),
3298 F_GFX3D(320000000, pll2, 2, 5),
3299 F_GFX3D(400000000, pll2, 1, 2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003300 F_END
3301};
3302
Tianyi Gou41515e22011-09-01 19:37:43 -07003303static struct clk_freq_tbl clk_tbl_gfx3d_8064[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003304 F_GFX3D( 0, gnd, 0, 0),
3305 F_GFX3D( 27000000, pxo, 0, 0),
3306 F_GFX3D( 48000000, pll8, 1, 8),
3307 F_GFX3D( 54857000, pll8, 1, 7),
3308 F_GFX3D( 64000000, pll8, 1, 6),
3309 F_GFX3D( 76800000, pll8, 1, 5),
3310 F_GFX3D( 96000000, pll8, 1, 4),
3311 F_GFX3D(128000000, pll8, 1, 3),
3312 F_GFX3D(145455000, pll2, 2, 11),
3313 F_GFX3D(160000000, pll2, 1, 5),
3314 F_GFX3D(177778000, pll2, 2, 9),
3315 F_GFX3D(200000000, pll2, 1, 4),
3316 F_GFX3D(228571000, pll2, 2, 7),
3317 F_GFX3D(266667000, pll2, 1, 3),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07003318 F_GFX3D(325000000, pll15, 1, 3),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003319 F_GFX3D(400000000, pll2, 1, 2),
Tianyi Gou41515e22011-09-01 19:37:43 -07003320 F_END
3321};
3322
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003323static unsigned long fmax_gfx3d_8064[MAX_VDD_LEVELS] __initdata = {
3324 [VDD_DIG_LOW] = 128000000,
3325 [VDD_DIG_NOMINAL] = 325000000,
3326 [VDD_DIG_HIGH] = 400000000
3327};
3328
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003329static struct bank_masks bmnd_info_gfx3d = {
3330 .bank_sel_mask = BIT(11),
3331 .bank0_mask = {
3332 .md_reg = GFX3D_MD0_REG,
3333 .ns_mask = BM(21, 18) | BM(5, 3),
3334 .rst_mask = BIT(23),
3335 .mnd_en_mask = BIT(8),
3336 .mode_mask = BM(10, 9),
3337 },
3338 .bank1_mask = {
3339 .md_reg = GFX3D_MD1_REG,
3340 .ns_mask = BM(17, 14) | BM(2, 0),
3341 .rst_mask = BIT(22),
3342 .mnd_en_mask = BIT(5),
3343 .mode_mask = BM(7, 6),
3344 },
3345};
3346
3347static struct rcg_clk gfx3d_clk = {
3348 .b = {
3349 .ctl_reg = GFX3D_CC_REG,
3350 .en_mask = BIT(0),
3351 .reset_reg = SW_RESET_CORE_REG,
3352 .reset_mask = BIT(12),
3353 .halt_reg = DBG_BUS_VEC_A_REG,
3354 .halt_bit = 4,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003355 .retain_reg = GFX3D_CC_REG,
3356 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003357 },
3358 .ns_reg = GFX3D_NS_REG,
3359 .root_en_mask = BIT(2),
3360 .set_rate = set_rate_mnd_banked,
Tianyi Gou41515e22011-09-01 19:37:43 -07003361 .freq_tbl = clk_tbl_gfx3d_8960,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003362 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003363 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003364 .c = {
3365 .dbg_name = "gfx3d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003366 .ops = &clk_ops_rcg_8960,
Tianyi Gou3022dfd2012-01-25 15:50:05 -08003367 VDD_DIG_FMAX_MAP3(LOW, 128000000, NOMINAL, 300000000,
3368 HIGH, 400000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003369 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003370 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003371 },
3372};
3373
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003374#define F_VCAP(f, s, m, n) \
Tianyi Gou621f8742011-09-01 21:45:01 -07003375 { \
3376 .freq_hz = f, \
3377 .src_clk = &s##_clk.c, \
3378 .md_val = MD4(4, m, 0, n), \
3379 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3380 .ctl_val = CC_BANKED(9, 6, n), \
Tianyi Gou621f8742011-09-01 21:45:01 -07003381 }
3382
3383static struct clk_freq_tbl clk_tbl_vcap[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003384 F_VCAP( 0, gnd, 0, 0),
3385 F_VCAP( 27000000, pxo, 0, 0),
3386 F_VCAP( 54860000, pll8, 1, 7),
3387 F_VCAP( 64000000, pll8, 1, 6),
3388 F_VCAP( 76800000, pll8, 1, 5),
3389 F_VCAP(128000000, pll8, 1, 3),
3390 F_VCAP(160000000, pll2, 1, 5),
3391 F_VCAP(200000000, pll2, 1, 4),
Tianyi Gou621f8742011-09-01 21:45:01 -07003392 F_END
3393};
3394
3395static struct bank_masks bmnd_info_vcap = {
3396 .bank_sel_mask = BIT(11),
3397 .bank0_mask = {
3398 .md_reg = VCAP_MD0_REG,
3399 .ns_mask = BM(21, 18) | BM(5, 3),
3400 .rst_mask = BIT(23),
3401 .mnd_en_mask = BIT(8),
3402 .mode_mask = BM(10, 9),
3403 },
3404 .bank1_mask = {
3405 .md_reg = VCAP_MD1_REG,
3406 .ns_mask = BM(17, 14) | BM(2, 0),
3407 .rst_mask = BIT(22),
3408 .mnd_en_mask = BIT(5),
3409 .mode_mask = BM(7, 6),
3410 },
3411};
3412
3413static struct rcg_clk vcap_clk = {
3414 .b = {
3415 .ctl_reg = VCAP_CC_REG,
3416 .en_mask = BIT(0),
3417 .halt_reg = DBG_BUS_VEC_J_REG,
3418 .halt_bit = 15,
3419 },
3420 .ns_reg = VCAP_NS_REG,
3421 .root_en_mask = BIT(2),
3422 .set_rate = set_rate_mnd_banked,
3423 .freq_tbl = clk_tbl_vcap,
3424 .bank_info = &bmnd_info_vcap,
3425 .current_freq = &rcg_dummy_freq,
3426 .c = {
3427 .dbg_name = "vcap_clk",
3428 .ops = &clk_ops_rcg_8960,
3429 .depends = &vcap_axi_clk.c,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003430 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000),
Tianyi Gou621f8742011-09-01 21:45:01 -07003431 CLK_INIT(vcap_clk.c),
3432 },
3433};
3434
3435static struct branch_clk vcap_npl_clk = {
3436 .b = {
3437 .ctl_reg = VCAP_CC_REG,
3438 .en_mask = BIT(13),
3439 .halt_reg = DBG_BUS_VEC_J_REG,
3440 .halt_bit = 25,
3441 },
3442 .parent = &vcap_clk.c,
3443 .c = {
3444 .dbg_name = "vcap_npl_clk",
3445 .ops = &clk_ops_branch,
3446 CLK_INIT(vcap_npl_clk.c),
3447 },
3448};
3449
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003450#define F_IJPEG(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003451 { \
3452 .freq_hz = f, \
3453 .src_clk = &s##_clk.c, \
3454 .md_val = MD8(8, m, 0, n), \
3455 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
3456 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003457 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003458
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003459static struct clk_freq_tbl clk_tbl_ijpeg[] = {
3460 F_IJPEG( 0, gnd, 1, 0, 0),
3461 F_IJPEG( 27000000, pxo, 1, 0, 0),
3462 F_IJPEG( 36570000, pll8, 1, 2, 21),
3463 F_IJPEG( 54860000, pll8, 7, 0, 0),
3464 F_IJPEG( 96000000, pll8, 4, 0, 0),
3465 F_IJPEG(109710000, pll8, 1, 2, 7),
3466 F_IJPEG(128000000, pll8, 3, 0, 0),
3467 F_IJPEG(153600000, pll8, 1, 2, 5),
3468 F_IJPEG(200000000, pll2, 4, 0, 0),
3469 F_IJPEG(228571000, pll2, 1, 2, 7),
3470 F_IJPEG(266667000, pll2, 1, 1, 3),
3471 F_IJPEG(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003472 F_END
3473};
3474
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003475static unsigned long fmax_ijpeg_8064[MAX_VDD_LEVELS] __initdata = {
3476 [VDD_DIG_LOW] = 128000000,
3477 [VDD_DIG_NOMINAL] = 266667000,
3478 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07003479};
3480
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003481static struct rcg_clk ijpeg_clk = {
3482 .b = {
3483 .ctl_reg = IJPEG_CC_REG,
3484 .en_mask = BIT(0),
3485 .reset_reg = SW_RESET_CORE_REG,
3486 .reset_mask = BIT(9),
3487 .halt_reg = DBG_BUS_VEC_A_REG,
3488 .halt_bit = 24,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003489 .retain_reg = IJPEG_CC_REG,
3490 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003491 },
3492 .ns_reg = IJPEG_NS_REG,
3493 .md_reg = IJPEG_MD_REG,
3494 .root_en_mask = BIT(2),
3495 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08003496 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003497 .ctl_mask = BM(7, 6),
3498 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003499 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003500 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003501 .c = {
3502 .dbg_name = "ijpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003503 .ops = &clk_ops_rcg_8960,
Tianyi Gou3022dfd2012-01-25 15:50:05 -08003504 VDD_DIG_FMAX_MAP3(LOW, 110000000, NOMINAL, 266667000,
3505 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003506 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003507 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003508 },
3509};
3510
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003511#define F_JPEGD(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003512 { \
3513 .freq_hz = f, \
3514 .src_clk = &s##_clk.c, \
3515 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003516 }
3517static struct clk_freq_tbl clk_tbl_jpegd[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003518 F_JPEGD( 0, gnd, 1),
3519 F_JPEGD( 64000000, pll8, 6),
3520 F_JPEGD( 76800000, pll8, 5),
3521 F_JPEGD( 96000000, pll8, 4),
3522 F_JPEGD(160000000, pll2, 5),
3523 F_JPEGD(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003524 F_END
3525};
3526
3527static struct rcg_clk jpegd_clk = {
3528 .b = {
3529 .ctl_reg = JPEGD_CC_REG,
3530 .en_mask = BIT(0),
3531 .reset_reg = SW_RESET_CORE_REG,
3532 .reset_mask = BIT(19),
3533 .halt_reg = DBG_BUS_VEC_A_REG,
3534 .halt_bit = 19,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003535 .retain_reg = JPEGD_CC_REG,
3536 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003537 },
3538 .ns_reg = JPEGD_NS_REG,
3539 .root_en_mask = BIT(2),
3540 .ns_mask = (BM(15, 12) | BM(2, 0)),
3541 .set_rate = set_rate_nop,
3542 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003543 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003544 .c = {
3545 .dbg_name = "jpegd_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003546 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003547 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003548 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003549 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003550 },
3551};
3552
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003553#define F_MDP(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003554 { \
3555 .freq_hz = f, \
3556 .src_clk = &s##_clk.c, \
3557 .md_val = MD8(8, m, 0, n), \
3558 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
3559 .ctl_val = CC_BANKED(9, 6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003560 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003561static struct clk_freq_tbl clk_tbl_mdp[] = {
3562 F_MDP( 0, gnd, 0, 0),
3563 F_MDP( 9600000, pll8, 1, 40),
3564 F_MDP( 13710000, pll8, 1, 28),
3565 F_MDP( 27000000, pxo, 0, 0),
3566 F_MDP( 29540000, pll8, 1, 13),
3567 F_MDP( 34910000, pll8, 1, 11),
3568 F_MDP( 38400000, pll8, 1, 10),
3569 F_MDP( 59080000, pll8, 2, 13),
3570 F_MDP( 76800000, pll8, 1, 5),
3571 F_MDP( 85330000, pll8, 2, 9),
3572 F_MDP( 96000000, pll8, 1, 4),
3573 F_MDP(128000000, pll8, 1, 3),
3574 F_MDP(160000000, pll2, 1, 5),
3575 F_MDP(177780000, pll2, 2, 9),
3576 F_MDP(200000000, pll2, 1, 4),
3577 F_MDP(266667000, pll2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003578 F_END
3579};
3580
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003581static unsigned long fmax_mdp_8064[MAX_VDD_LEVELS] __initdata = {
3582 [VDD_DIG_LOW] = 128000000,
3583 [VDD_DIG_NOMINAL] = 266667000
Tianyi Gou621f8742011-09-01 21:45:01 -07003584};
3585
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003586static struct bank_masks bmnd_info_mdp = {
3587 .bank_sel_mask = BIT(11),
3588 .bank0_mask = {
3589 .md_reg = MDP_MD0_REG,
3590 .ns_mask = BM(29, 22) | BM(5, 3),
3591 .rst_mask = BIT(31),
3592 .mnd_en_mask = BIT(8),
3593 .mode_mask = BM(10, 9),
3594 },
3595 .bank1_mask = {
3596 .md_reg = MDP_MD1_REG,
3597 .ns_mask = BM(21, 14) | BM(2, 0),
3598 .rst_mask = BIT(30),
3599 .mnd_en_mask = BIT(5),
3600 .mode_mask = BM(7, 6),
3601 },
3602};
3603
3604static struct rcg_clk mdp_clk = {
3605 .b = {
3606 .ctl_reg = MDP_CC_REG,
3607 .en_mask = BIT(0),
3608 .reset_reg = SW_RESET_CORE_REG,
3609 .reset_mask = BIT(21),
3610 .halt_reg = DBG_BUS_VEC_C_REG,
3611 .halt_bit = 10,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003612 .retain_reg = MDP_CC_REG,
3613 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003614 },
3615 .ns_reg = MDP_NS_REG,
3616 .root_en_mask = BIT(2),
3617 .set_rate = set_rate_mnd_banked,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003618 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003619 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003620 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003621 .c = {
3622 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003623 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003624 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003625 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003626 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003627 },
3628};
3629
3630static struct branch_clk lut_mdp_clk = {
3631 .b = {
3632 .ctl_reg = MDP_LUT_CC_REG,
3633 .en_mask = BIT(0),
3634 .halt_reg = DBG_BUS_VEC_I_REG,
3635 .halt_bit = 13,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003636 .retain_reg = MDP_LUT_CC_REG,
3637 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003638 },
3639 .parent = &mdp_clk.c,
3640 .c = {
3641 .dbg_name = "lut_mdp_clk",
3642 .ops = &clk_ops_branch,
3643 CLK_INIT(lut_mdp_clk.c),
3644 },
3645};
3646
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003647#define F_MDP_VSYNC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003648 { \
3649 .freq_hz = f, \
3650 .src_clk = &s##_clk.c, \
3651 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003652 }
3653static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003654 F_MDP_VSYNC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003655 F_END
3656};
3657
3658static struct rcg_clk mdp_vsync_clk = {
3659 .b = {
3660 .ctl_reg = MISC_CC_REG,
3661 .en_mask = BIT(6),
3662 .reset_reg = SW_RESET_CORE_REG,
3663 .reset_mask = BIT(3),
3664 .halt_reg = DBG_BUS_VEC_B_REG,
3665 .halt_bit = 22,
3666 },
3667 .ns_reg = MISC_CC2_REG,
3668 .ns_mask = BIT(13),
3669 .set_rate = set_rate_nop,
3670 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003671 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003672 .c = {
3673 .dbg_name = "mdp_vsync_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003674 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003675 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003676 CLK_INIT(mdp_vsync_clk.c),
3677 },
3678};
3679
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003680#define F_ROT(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003681 { \
3682 .freq_hz = f, \
3683 .src_clk = &s##_clk.c, \
3684 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
3685 21, 19, 18, 16, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003686 }
3687static struct clk_freq_tbl clk_tbl_rot[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003688 F_ROT( 0, gnd, 1),
3689 F_ROT( 27000000, pxo, 1),
3690 F_ROT( 29540000, pll8, 13),
3691 F_ROT( 32000000, pll8, 12),
3692 F_ROT( 38400000, pll8, 10),
3693 F_ROT( 48000000, pll8, 8),
3694 F_ROT( 54860000, pll8, 7),
3695 F_ROT( 64000000, pll8, 6),
3696 F_ROT( 76800000, pll8, 5),
3697 F_ROT( 96000000, pll8, 4),
3698 F_ROT(100000000, pll2, 8),
3699 F_ROT(114290000, pll2, 7),
3700 F_ROT(133330000, pll2, 6),
3701 F_ROT(160000000, pll2, 5),
3702 F_ROT(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003703 F_END
3704};
3705
3706static struct bank_masks bdiv_info_rot = {
3707 .bank_sel_mask = BIT(30),
3708 .bank0_mask = {
3709 .ns_mask = BM(25, 22) | BM(18, 16),
3710 },
3711 .bank1_mask = {
3712 .ns_mask = BM(29, 26) | BM(21, 19),
3713 },
3714};
3715
3716static struct rcg_clk rot_clk = {
3717 .b = {
3718 .ctl_reg = ROT_CC_REG,
3719 .en_mask = BIT(0),
3720 .reset_reg = SW_RESET_CORE_REG,
3721 .reset_mask = BIT(2),
3722 .halt_reg = DBG_BUS_VEC_C_REG,
3723 .halt_bit = 15,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003724 .retain_reg = ROT_CC_REG,
3725 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003726 },
3727 .ns_reg = ROT_NS_REG,
3728 .root_en_mask = BIT(2),
3729 .set_rate = set_rate_div_banked,
3730 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003731 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003732 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003733 .c = {
3734 .dbg_name = "rot_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003735 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003736 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003737 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003738 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003739 },
3740};
3741
3742static int hdmi_pll_clk_enable(struct clk *clk)
3743{
3744 int ret;
3745 unsigned long flags;
3746 spin_lock_irqsave(&local_clock_reg_lock, flags);
3747 ret = hdmi_pll_enable();
3748 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3749 return ret;
3750}
3751
3752static void hdmi_pll_clk_disable(struct clk *clk)
3753{
3754 unsigned long flags;
3755 spin_lock_irqsave(&local_clock_reg_lock, flags);
3756 hdmi_pll_disable();
3757 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3758}
3759
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003760static unsigned long hdmi_pll_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003761{
3762 return hdmi_pll_get_rate();
3763}
3764
Stephen Boyd5b35dee2011-09-21 12:17:38 -07003765static struct clk *hdmi_pll_clk_get_parent(struct clk *clk)
3766{
3767 return &pxo_clk.c;
3768}
3769
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003770static struct clk_ops clk_ops_hdmi_pll = {
3771 .enable = hdmi_pll_clk_enable,
3772 .disable = hdmi_pll_clk_disable,
3773 .get_rate = hdmi_pll_clk_get_rate,
3774 .is_local = local_clk_is_local,
Stephen Boyd5b35dee2011-09-21 12:17:38 -07003775 .get_parent = hdmi_pll_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003776};
3777
3778static struct clk hdmi_pll_clk = {
3779 .dbg_name = "hdmi_pll_clk",
3780 .ops = &clk_ops_hdmi_pll,
3781 CLK_INIT(hdmi_pll_clk),
3782};
3783
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003784#define F_TV_GND(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003785 { \
3786 .freq_hz = f, \
3787 .src_clk = &s##_clk.c, \
3788 .md_val = MD8(8, m, 0, n), \
3789 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3790 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003791 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003792#define F_TV(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003793 { \
3794 .freq_hz = f, \
3795 .src_clk = &s##_clk, \
3796 .md_val = MD8(8, m, 0, n), \
3797 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3798 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003799 .extra_freq_data = (void *)p_r, \
3800 }
3801/* Switching TV freqs requires PLL reconfiguration. */
3802static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003803 F_TV_GND( 0, gnd, 0, 1, 0, 0),
3804 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0),
3805 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0),
3806 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0),
3807 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0),
3808 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003809 F_END
3810};
3811
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003812static unsigned long fmax_tv_src_8064[MAX_VDD_LEVELS] __initdata = {
3813 [VDD_DIG_LOW] = 74250000,
3814 [VDD_DIG_NOMINAL] = 149000000
3815};
3816
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003817/*
3818 * Unlike other clocks, the TV rate is adjusted through PLL
3819 * re-programming. It is also routed through an MND divider.
3820 */
3821void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
3822{
3823 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
3824 if (pll_rate)
3825 hdmi_pll_set_rate(pll_rate);
3826 set_rate_mnd(clk, nf);
3827}
3828
3829static struct rcg_clk tv_src_clk = {
3830 .ns_reg = TV_NS_REG,
3831 .b = {
3832 .ctl_reg = TV_CC_REG,
3833 .halt_check = NOCHECK,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003834 .retain_reg = TV_CC_REG,
3835 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003836 },
3837 .md_reg = TV_MD_REG,
3838 .root_en_mask = BIT(2),
3839 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08003840 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003841 .ctl_mask = BM(7, 6),
3842 .set_rate = set_rate_tv,
3843 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003844 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003845 .c = {
3846 .dbg_name = "tv_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003847 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003848 VDD_DIG_FMAX_MAP2(LOW, 27030000, NOMINAL, 149000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003849 CLK_INIT(tv_src_clk.c),
3850 },
3851};
3852
Tianyi Gou51918802012-01-26 14:05:43 -08003853static struct cdiv_clk tv_src_div_clk = {
3854 .b = {
3855 .ctl_reg = TV_NS_REG,
3856 .halt_check = NOCHECK,
3857 },
3858 .ns_reg = TV_NS_REG,
3859 .div_offset = 6,
3860 .max_div = 2,
3861 .c = {
3862 .dbg_name = "tv_src_div_clk",
3863 .ops = &clk_ops_cdiv,
3864 CLK_INIT(tv_src_div_clk.c),
3865 },
3866};
3867
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003868static struct branch_clk tv_enc_clk = {
3869 .b = {
3870 .ctl_reg = TV_CC_REG,
3871 .en_mask = BIT(8),
3872 .reset_reg = SW_RESET_CORE_REG,
3873 .reset_mask = BIT(0),
3874 .halt_reg = DBG_BUS_VEC_D_REG,
3875 .halt_bit = 9,
3876 },
3877 .parent = &tv_src_clk.c,
3878 .c = {
3879 .dbg_name = "tv_enc_clk",
3880 .ops = &clk_ops_branch,
3881 CLK_INIT(tv_enc_clk.c),
3882 },
3883};
3884
3885static struct branch_clk tv_dac_clk = {
3886 .b = {
3887 .ctl_reg = TV_CC_REG,
3888 .en_mask = BIT(10),
3889 .halt_reg = DBG_BUS_VEC_D_REG,
3890 .halt_bit = 10,
3891 },
3892 .parent = &tv_src_clk.c,
3893 .c = {
3894 .dbg_name = "tv_dac_clk",
3895 .ops = &clk_ops_branch,
3896 CLK_INIT(tv_dac_clk.c),
3897 },
3898};
3899
3900static struct branch_clk mdp_tv_clk = {
3901 .b = {
3902 .ctl_reg = TV_CC_REG,
3903 .en_mask = BIT(0),
3904 .reset_reg = SW_RESET_CORE_REG,
3905 .reset_mask = BIT(4),
3906 .halt_reg = DBG_BUS_VEC_D_REG,
3907 .halt_bit = 12,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08003908 .retain_reg = TV_CC2_REG,
3909 .retain_mask = BIT(10),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003910 },
3911 .parent = &tv_src_clk.c,
3912 .c = {
3913 .dbg_name = "mdp_tv_clk",
3914 .ops = &clk_ops_branch,
3915 CLK_INIT(mdp_tv_clk.c),
3916 },
3917};
3918
3919static struct branch_clk hdmi_tv_clk = {
3920 .b = {
3921 .ctl_reg = TV_CC_REG,
3922 .en_mask = BIT(12),
3923 .reset_reg = SW_RESET_CORE_REG,
3924 .reset_mask = BIT(1),
3925 .halt_reg = DBG_BUS_VEC_D_REG,
3926 .halt_bit = 11,
3927 },
3928 .parent = &tv_src_clk.c,
3929 .c = {
3930 .dbg_name = "hdmi_tv_clk",
3931 .ops = &clk_ops_branch,
3932 CLK_INIT(hdmi_tv_clk.c),
3933 },
3934};
3935
Tianyi Gou51918802012-01-26 14:05:43 -08003936static struct branch_clk rgb_tv_clk = {
3937 .b = {
3938 .ctl_reg = TV_CC2_REG,
3939 .en_mask = BIT(14),
3940 .halt_reg = DBG_BUS_VEC_J_REG,
3941 .halt_bit = 27,
3942 },
3943 .parent = &tv_src_clk.c,
3944 .c = {
3945 .dbg_name = "rgb_tv_clk",
3946 .ops = &clk_ops_branch,
3947 CLK_INIT(rgb_tv_clk.c),
3948 },
3949};
3950
3951static struct branch_clk npl_tv_clk = {
3952 .b = {
3953 .ctl_reg = TV_CC2_REG,
3954 .en_mask = BIT(16),
3955 .halt_reg = DBG_BUS_VEC_J_REG,
3956 .halt_bit = 26,
3957 },
3958 .parent = &tv_src_clk.c,
3959 .c = {
3960 .dbg_name = "npl_tv_clk",
3961 .ops = &clk_ops_branch,
3962 CLK_INIT(npl_tv_clk.c),
3963 },
3964};
3965
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003966static struct branch_clk hdmi_app_clk = {
3967 .b = {
3968 .ctl_reg = MISC_CC2_REG,
3969 .en_mask = BIT(11),
3970 .reset_reg = SW_RESET_CORE_REG,
3971 .reset_mask = BIT(11),
3972 .halt_reg = DBG_BUS_VEC_B_REG,
3973 .halt_bit = 25,
3974 },
3975 .c = {
3976 .dbg_name = "hdmi_app_clk",
3977 .ops = &clk_ops_branch,
3978 CLK_INIT(hdmi_app_clk.c),
3979 },
3980};
3981
3982static struct bank_masks bmnd_info_vcodec = {
3983 .bank_sel_mask = BIT(13),
3984 .bank0_mask = {
3985 .md_reg = VCODEC_MD0_REG,
3986 .ns_mask = BM(18, 11) | BM(2, 0),
3987 .rst_mask = BIT(31),
3988 .mnd_en_mask = BIT(5),
3989 .mode_mask = BM(7, 6),
3990 },
3991 .bank1_mask = {
3992 .md_reg = VCODEC_MD1_REG,
3993 .ns_mask = BM(26, 19) | BM(29, 27),
3994 .rst_mask = BIT(30),
3995 .mnd_en_mask = BIT(10),
3996 .mode_mask = BM(12, 11),
3997 },
3998};
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003999#define F_VCODEC(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004000 { \
4001 .freq_hz = f, \
4002 .src_clk = &s##_clk.c, \
4003 .md_val = MD8(8, m, 0, n), \
4004 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
4005 .ctl_val = CC_BANKED(6, 11, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004006 }
4007static struct clk_freq_tbl clk_tbl_vcodec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004008 F_VCODEC( 0, gnd, 0, 0),
4009 F_VCODEC( 27000000, pxo, 0, 0),
4010 F_VCODEC( 32000000, pll8, 1, 12),
4011 F_VCODEC( 48000000, pll8, 1, 8),
4012 F_VCODEC( 54860000, pll8, 1, 7),
4013 F_VCODEC( 96000000, pll8, 1, 4),
4014 F_VCODEC(133330000, pll2, 1, 6),
4015 F_VCODEC(200000000, pll2, 1, 4),
4016 F_VCODEC(228570000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004017 F_END
4018};
4019
4020static struct rcg_clk vcodec_clk = {
4021 .b = {
4022 .ctl_reg = VCODEC_CC_REG,
4023 .en_mask = BIT(0),
4024 .reset_reg = SW_RESET_CORE_REG,
4025 .reset_mask = BIT(6),
4026 .halt_reg = DBG_BUS_VEC_C_REG,
4027 .halt_bit = 29,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08004028 .retain_reg = VCODEC_CC_REG,
4029 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004030 },
4031 .ns_reg = VCODEC_NS_REG,
4032 .root_en_mask = BIT(2),
4033 .set_rate = set_rate_mnd_banked,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004034 .bank_info = &bmnd_info_vcodec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004035 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004036 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004037 .c = {
4038 .dbg_name = "vcodec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004039 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004040 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
4041 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004042 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004043 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004044 },
4045};
4046
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004047#define F_VPE(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004048 { \
4049 .freq_hz = f, \
4050 .src_clk = &s##_clk.c, \
4051 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004052 }
4053static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004054 F_VPE( 0, gnd, 1),
4055 F_VPE( 27000000, pxo, 1),
4056 F_VPE( 34909000, pll8, 11),
4057 F_VPE( 38400000, pll8, 10),
4058 F_VPE( 64000000, pll8, 6),
4059 F_VPE( 76800000, pll8, 5),
4060 F_VPE( 96000000, pll8, 4),
4061 F_VPE(100000000, pll2, 8),
4062 F_VPE(160000000, pll2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004063 F_END
4064};
4065
4066static struct rcg_clk vpe_clk = {
4067 .b = {
4068 .ctl_reg = VPE_CC_REG,
4069 .en_mask = BIT(0),
4070 .reset_reg = SW_RESET_CORE_REG,
4071 .reset_mask = BIT(17),
4072 .halt_reg = DBG_BUS_VEC_A_REG,
4073 .halt_bit = 28,
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08004074 .retain_reg = VPE_CC_REG,
4075 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004076 },
4077 .ns_reg = VPE_NS_REG,
4078 .root_en_mask = BIT(2),
4079 .ns_mask = (BM(15, 12) | BM(2, 0)),
4080 .set_rate = set_rate_nop,
4081 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004082 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004083 .c = {
4084 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004085 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004086 VDD_DIG_FMAX_MAP2(LOW, 76800000, NOMINAL, 160000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004087 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004088 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004089 },
4090};
4091
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004092#define F_VFE(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004093 { \
4094 .freq_hz = f, \
4095 .src_clk = &s##_clk.c, \
4096 .md_val = MD8(8, m, 0, n), \
4097 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
4098 .ctl_val = CC(6, n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004099 }
Tianyi Gou41515e22011-09-01 19:37:43 -07004100
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004101static struct clk_freq_tbl clk_tbl_vfe[] = {
4102 F_VFE( 0, gnd, 1, 0, 0),
4103 F_VFE( 13960000, pll8, 1, 2, 55),
4104 F_VFE( 27000000, pxo, 1, 0, 0),
4105 F_VFE( 36570000, pll8, 1, 2, 21),
4106 F_VFE( 38400000, pll8, 2, 1, 5),
4107 F_VFE( 45180000, pll8, 1, 2, 17),
4108 F_VFE( 48000000, pll8, 2, 1, 4),
4109 F_VFE( 54860000, pll8, 1, 1, 7),
4110 F_VFE( 64000000, pll8, 2, 1, 3),
4111 F_VFE( 76800000, pll8, 1, 1, 5),
4112 F_VFE( 96000000, pll8, 2, 1, 2),
4113 F_VFE(109710000, pll8, 1, 2, 7),
4114 F_VFE(128000000, pll8, 1, 1, 3),
4115 F_VFE(153600000, pll8, 1, 2, 5),
4116 F_VFE(200000000, pll2, 2, 1, 2),
4117 F_VFE(228570000, pll2, 1, 2, 7),
4118 F_VFE(266667000, pll2, 1, 1, 3),
4119 F_VFE(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004120 F_END
4121};
4122
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004123static unsigned long fmax_vfe_8064[MAX_VDD_LEVELS] __initdata = {
4124 [VDD_DIG_LOW] = 128000000,
4125 [VDD_DIG_NOMINAL] = 266667000,
4126 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07004127};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004128
4129static struct rcg_clk vfe_clk = {
4130 .b = {
4131 .ctl_reg = VFE_CC_REG,
4132 .reset_reg = SW_RESET_CORE_REG,
4133 .reset_mask = BIT(15),
4134 .halt_reg = DBG_BUS_VEC_B_REG,
4135 .halt_bit = 6,
4136 .en_mask = BIT(0),
Matt Wagantall7e0b6c92012-01-20 18:48:05 -08004137 .retain_reg = VFE_CC2_REG,
4138 .retain_mask = BIT(31),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004139 },
4140 .ns_reg = VFE_NS_REG,
4141 .md_reg = VFE_MD_REG,
4142 .root_en_mask = BIT(2),
4143 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08004144 .mnd_en_mask = BIT(5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004145 .ctl_mask = BM(7, 6),
4146 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004147 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004148 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004149 .c = {
4150 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004151 .ops = &clk_ops_rcg_8960,
Tianyi Gou3022dfd2012-01-25 15:50:05 -08004152 VDD_DIG_FMAX_MAP3(LOW, 110000000, NOMINAL, 266667000,
4153 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004154 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004155 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004156 },
4157};
4158
Matt Wagantallc23eee92011-08-16 23:06:52 -07004159static struct branch_clk csi_vfe_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004160 .b = {
4161 .ctl_reg = VFE_CC_REG,
4162 .en_mask = BIT(12),
4163 .reset_reg = SW_RESET_CORE_REG,
4164 .reset_mask = BIT(24),
4165 .halt_reg = DBG_BUS_VEC_B_REG,
4166 .halt_bit = 8,
4167 },
4168 .parent = &vfe_clk.c,
4169 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -07004170 .dbg_name = "csi_vfe_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004171 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -07004172 CLK_INIT(csi_vfe_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004173 },
4174};
4175
4176/*
4177 * Low Power Audio Clocks
4178 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004179#define F_AIF_OSR(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004180 { \
4181 .freq_hz = f, \
4182 .src_clk = &s##_clk.c, \
4183 .md_val = MD8(8, m, 0, n), \
4184 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004185 }
4186static struct clk_freq_tbl clk_tbl_aif_osr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004187 F_AIF_OSR( 0, gnd, 1, 0, 0),
4188 F_AIF_OSR( 512000, pll4, 4, 1, 192),
4189 F_AIF_OSR( 768000, pll4, 4, 1, 128),
4190 F_AIF_OSR( 1024000, pll4, 4, 1, 96),
4191 F_AIF_OSR( 1536000, pll4, 4, 1, 64),
4192 F_AIF_OSR( 2048000, pll4, 4, 1, 48),
4193 F_AIF_OSR( 3072000, pll4, 4, 1, 32),
4194 F_AIF_OSR( 4096000, pll4, 4, 1, 24),
4195 F_AIF_OSR( 6144000, pll4, 4, 1, 16),
4196 F_AIF_OSR( 8192000, pll4, 4, 1, 12),
4197 F_AIF_OSR(12288000, pll4, 4, 1, 8),
4198 F_AIF_OSR(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004199 F_END
4200};
4201
4202#define CLK_AIF_OSR(i, ns, md, h_r) \
4203 struct rcg_clk i##_clk = { \
4204 .b = { \
4205 .ctl_reg = ns, \
4206 .en_mask = BIT(17), \
4207 .reset_reg = ns, \
4208 .reset_mask = BIT(19), \
4209 .halt_reg = h_r, \
4210 .halt_check = ENABLE, \
4211 .halt_bit = 1, \
4212 }, \
4213 .ns_reg = ns, \
4214 .md_reg = md, \
4215 .root_en_mask = BIT(9), \
4216 .ns_mask = (BM(31, 24) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08004217 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004218 .set_rate = set_rate_mnd, \
4219 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004220 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004221 .c = { \
4222 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004223 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004224 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004225 CLK_INIT(i##_clk.c), \
4226 }, \
4227 }
4228#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
4229 struct rcg_clk i##_clk = { \
4230 .b = { \
4231 .ctl_reg = ns, \
4232 .en_mask = BIT(21), \
4233 .reset_reg = ns, \
4234 .reset_mask = BIT(23), \
4235 .halt_reg = h_r, \
4236 .halt_check = ENABLE, \
4237 .halt_bit = 1, \
4238 }, \
4239 .ns_reg = ns, \
4240 .md_reg = md, \
4241 .root_en_mask = BIT(9), \
4242 .ns_mask = (BM(31, 24) | BM(6, 0)), \
Matt Wagantall07c45472012-02-10 23:27:24 -08004243 .mnd_en_mask = BIT(8), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004244 .set_rate = set_rate_mnd, \
4245 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004246 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004247 .c = { \
4248 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004249 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004250 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004251 CLK_INIT(i##_clk.c), \
4252 }, \
4253 }
4254
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004255#define CLK_AIF_BIT(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004256 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004257 .b = { \
4258 .ctl_reg = ns, \
4259 .en_mask = BIT(15), \
4260 .halt_reg = h_r, \
4261 .halt_check = DELAY, \
4262 }, \
4263 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004264 .ext_mask = BIT(14), \
4265 .div_offset = 10, \
4266 .max_div = 16, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004267 .c = { \
4268 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004269 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004270 CLK_INIT(i##_clk.c), \
4271 }, \
4272 }
4273
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004274#define CLK_AIF_BIT_DIV(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004275 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004276 .b = { \
4277 .ctl_reg = ns, \
4278 .en_mask = BIT(19), \
4279 .halt_reg = h_r, \
Stephen Boyd7bb9cf82012-01-25 18:09:01 -08004280 .halt_check = DELAY, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004281 }, \
4282 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004283 .ext_mask = BIT(18), \
4284 .div_offset = 10, \
4285 .max_div = 256, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004286 .c = { \
4287 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004288 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004289 CLK_INIT(i##_clk.c), \
4290 }, \
4291 }
4292
4293static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
4294 LCC_MI2S_STATUS_REG);
4295static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
4296
4297static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
4298 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
4299static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
4300 LCC_CODEC_I2S_MIC_STATUS_REG);
4301
4302static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
4303 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
4304static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
4305 LCC_SPARE_I2S_MIC_STATUS_REG);
4306
4307static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
4308 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
4309static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
4310 LCC_CODEC_I2S_SPKR_STATUS_REG);
4311
4312static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
4313 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
4314static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
4315 LCC_SPARE_I2S_SPKR_STATUS_REG);
4316
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004317#define F_PCM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004318 { \
4319 .freq_hz = f, \
4320 .src_clk = &s##_clk.c, \
4321 .md_val = MD16(m, n), \
4322 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004323 }
4324static struct clk_freq_tbl clk_tbl_pcm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004325 F_PCM( 0, gnd, 1, 0, 0),
4326 F_PCM( 512000, pll4, 4, 1, 192),
4327 F_PCM( 768000, pll4, 4, 1, 128),
4328 F_PCM( 1024000, pll4, 4, 1, 96),
4329 F_PCM( 1536000, pll4, 4, 1, 64),
4330 F_PCM( 2048000, pll4, 4, 1, 48),
4331 F_PCM( 3072000, pll4, 4, 1, 32),
4332 F_PCM( 4096000, pll4, 4, 1, 24),
4333 F_PCM( 6144000, pll4, 4, 1, 16),
4334 F_PCM( 8192000, pll4, 4, 1, 12),
4335 F_PCM(12288000, pll4, 4, 1, 8),
4336 F_PCM(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004337 F_END
4338};
4339
4340static struct rcg_clk pcm_clk = {
4341 .b = {
4342 .ctl_reg = LCC_PCM_NS_REG,
4343 .en_mask = BIT(11),
4344 .reset_reg = LCC_PCM_NS_REG,
4345 .reset_mask = BIT(13),
4346 .halt_reg = LCC_PCM_STATUS_REG,
4347 .halt_check = ENABLE,
4348 .halt_bit = 0,
4349 },
4350 .ns_reg = LCC_PCM_NS_REG,
4351 .md_reg = LCC_PCM_MD_REG,
4352 .root_en_mask = BIT(9),
4353 .ns_mask = (BM(31, 16) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08004354 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004355 .set_rate = set_rate_mnd,
4356 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004357 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004358 .c = {
4359 .dbg_name = "pcm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004360 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004361 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004362 CLK_INIT(pcm_clk.c),
4363 },
4364};
4365
4366static struct rcg_clk audio_slimbus_clk = {
4367 .b = {
4368 .ctl_reg = LCC_SLIMBUS_NS_REG,
4369 .en_mask = BIT(10),
4370 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
4371 .reset_mask = BIT(5),
4372 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4373 .halt_check = ENABLE,
4374 .halt_bit = 0,
4375 },
4376 .ns_reg = LCC_SLIMBUS_NS_REG,
4377 .md_reg = LCC_SLIMBUS_MD_REG,
4378 .root_en_mask = BIT(9),
4379 .ns_mask = (BM(31, 24) | BM(6, 0)),
Matt Wagantall07c45472012-02-10 23:27:24 -08004380 .mnd_en_mask = BIT(8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004381 .set_rate = set_rate_mnd,
4382 .freq_tbl = clk_tbl_aif_osr,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004383 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004384 .c = {
4385 .dbg_name = "audio_slimbus_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004386 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004387 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004388 CLK_INIT(audio_slimbus_clk.c),
4389 },
4390};
4391
4392static struct branch_clk sps_slimbus_clk = {
4393 .b = {
4394 .ctl_reg = LCC_SLIMBUS_NS_REG,
4395 .en_mask = BIT(12),
4396 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4397 .halt_check = ENABLE,
4398 .halt_bit = 1,
4399 },
4400 .parent = &audio_slimbus_clk.c,
4401 .c = {
4402 .dbg_name = "sps_slimbus_clk",
4403 .ops = &clk_ops_branch,
4404 CLK_INIT(sps_slimbus_clk.c),
4405 },
4406};
4407
4408static struct branch_clk slimbus_xo_src_clk = {
4409 .b = {
4410 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
4411 .en_mask = BIT(2),
4412 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004413 .halt_bit = 28,
4414 },
4415 .parent = &sps_slimbus_clk.c,
4416 .c = {
4417 .dbg_name = "slimbus_xo_src_clk",
4418 .ops = &clk_ops_branch,
4419 CLK_INIT(slimbus_xo_src_clk.c),
4420 },
4421};
4422
Matt Wagantall735f01a2011-08-12 12:40:28 -07004423DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
4424DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
4425DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
4426DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
4427DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
4428DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
4429DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
4430DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004431
Stephen Boydd7a143a2012-02-16 17:59:26 -08004432static DEFINE_CLK_VOTER(sfab_msmbus_a_clk, &sfab_a_clk.c);
4433static DEFINE_CLK_VOTER(sfab_tmr_a_clk, &sfab_a_clk.c);
4434
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004435static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
4436static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
Manu Gautam7483f172011-11-08 15:22:26 +05304437static DEFINE_CLK_VOTER(dfab_usb_hs3_clk, &dfab_clk.c);
4438static DEFINE_CLK_VOTER(dfab_usb_hs4_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004439static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
4440static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
4441static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
4442static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
4443static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
4444static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
Stephen Boyd1c51a492011-10-26 12:11:47 -07004445static DEFINE_CLK_VOTER(dfab_bam_dmux_clk, &dfab_clk.c);
Stephen Boydef5d1c42011-12-15 20:47:14 -08004446static DEFINE_CLK_VOTER(dfab_scm_clk, &dfab_clk.c);
Ramesh Masavarapua1bc0e42012-03-05 07:42:48 -08004447static DEFINE_CLK_VOTER(dfab_qseecom_clk, &dfab_clk.c);
Ramesh Masavarapueb6e9342012-02-13 19:59:50 -08004448static DEFINE_CLK_VOTER(dfab_tzcom_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004449
4450static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
Stephen Boyd36466ae2012-01-18 20:58:27 -08004451static DEFINE_CLK_VOTER(ebi1_adm_clk, &ebi1_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004452
4453#ifdef CONFIG_DEBUG_FS
4454struct measure_sel {
4455 u32 test_vector;
4456 struct clk *clk;
4457};
4458
Matt Wagantall8b38f942011-08-02 18:23:18 -07004459static DEFINE_CLK_MEASURE(l2_m_clk);
4460static DEFINE_CLK_MEASURE(krait0_m_clk);
4461static DEFINE_CLK_MEASURE(krait1_m_clk);
Tianyi Gou455c13c2012-02-02 16:33:24 -08004462static DEFINE_CLK_MEASURE(krait2_m_clk);
4463static DEFINE_CLK_MEASURE(krait3_m_clk);
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004464static DEFINE_CLK_MEASURE(q6sw_clk);
4465static DEFINE_CLK_MEASURE(q6fw_clk);
4466static DEFINE_CLK_MEASURE(q6_func_clk);
Matt Wagantall8b38f942011-08-02 18:23:18 -07004467
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004468static struct measure_sel measure_mux[] = {
4469 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
4470 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
4471 { TEST_PER_LS(0x13), &sdc1_clk.c },
4472 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
4473 { TEST_PER_LS(0x15), &sdc2_clk.c },
4474 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
4475 { TEST_PER_LS(0x17), &sdc3_clk.c },
4476 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
4477 { TEST_PER_LS(0x19), &sdc4_clk.c },
4478 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
4479 { TEST_PER_LS(0x1B), &sdc5_clk.c },
Matt Wagantall7625a4c2011-11-01 16:17:53 -07004480 { TEST_PER_LS(0x1F), &gp0_clk.c },
4481 { TEST_PER_LS(0x20), &gp1_clk.c },
4482 { TEST_PER_LS(0x21), &gp2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004483 { TEST_PER_LS(0x25), &dfab_clk.c },
4484 { TEST_PER_LS(0x25), &dfab_a_clk.c },
4485 { TEST_PER_LS(0x26), &pmem_clk.c },
4486 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
4487 { TEST_PER_LS(0x33), &cfpb_clk.c },
4488 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
4489 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
4490 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
4491 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
4492 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
4493 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
4494 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
4495 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
4496 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
4497 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
4498 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
4499 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
4500 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
4501 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
4502 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
4503 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
4504 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
4505 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
4506 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
4507 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
4508 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
4509 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
4510 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
4511 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
4512 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
4513 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
4514 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
4515 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
4516 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
4517 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
4518 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
4519 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
4520 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
4521 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
4522 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
4523 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
4524 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004525 { TEST_PER_LS(0x5E), &pcie_p_clk.c },
4526 { TEST_PER_LS(0x5F), &ce3_p_clk.c },
4527 { TEST_PER_LS(0x60), &ce3_core_clk.c },
4528 { TEST_PER_LS(0x63), &usb_hs3_p_clk.c },
4529 { TEST_PER_LS(0x64), &usb_hs3_xcvr_clk.c },
4530 { TEST_PER_LS(0x65), &usb_hs4_p_clk.c },
4531 { TEST_PER_LS(0x66), &usb_hs4_xcvr_clk.c },
4532 { TEST_PER_LS(0x6B), &sata_phy_ref_clk.c },
4533 { TEST_PER_LS(0x6C), &sata_phy_cfg_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004534 { TEST_PER_LS(0x78), &sfpb_clk.c },
4535 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
4536 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
4537 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
4538 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
4539 { TEST_PER_LS(0x7D), &prng_clk.c },
4540 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
4541 { TEST_PER_LS(0x80), &adm0_p_clk.c },
4542 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
4543 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004544 { TEST_PER_LS(0x86), &usb_hsic_p_clk.c },
4545 { TEST_PER_LS(0x87), &usb_hsic_system_clk.c },
4546 { TEST_PER_LS(0x88), &usb_hsic_xcvr_fs_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004547 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
4548 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
4549 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
4550 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
4551 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
4552 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
4553 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
4554 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
4555 { TEST_PER_LS(0x92), &ce1_p_clk.c },
4556 { TEST_PER_LS(0x94), &tssc_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004557 { TEST_PER_LS(0x9D), &usb_hsic_hsio_cal_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004558 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
4559
4560 { TEST_PER_HS(0x07), &afab_clk.c },
4561 { TEST_PER_HS(0x07), &afab_a_clk.c },
4562 { TEST_PER_HS(0x18), &sfab_clk.c },
4563 { TEST_PER_HS(0x18), &sfab_a_clk.c },
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004564 { TEST_PER_HS(0x26), &q6sw_clk },
4565 { TEST_PER_HS(0x27), &q6fw_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004566 { TEST_PER_HS(0x2A), &adm0_clk.c },
4567 { TEST_PER_HS(0x34), &ebi1_clk.c },
4568 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004569 { TEST_PER_HS(0x50), &usb_hsic_hsic_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004570
4571 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
4572 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
4573 { TEST_MM_LS(0x02), &cam1_clk.c },
4574 { TEST_MM_LS(0x06), &amp_p_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004575 { TEST_MM_LS(0x07), &csi_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004576 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
4577 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
4578 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
4579 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
4580 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
4581 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
4582 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
4583 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
4584 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
4585 { TEST_MM_LS(0x12), &imem_p_clk.c },
4586 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
4587 { TEST_MM_LS(0x14), &mdp_p_clk.c },
4588 { TEST_MM_LS(0x16), &rot_p_clk.c },
4589 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
4590 { TEST_MM_LS(0x18), &smmu_p_clk.c },
4591 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
4592 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
4593 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
4594 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
4595 { TEST_MM_LS(0x1D), &cam0_clk.c },
4596 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
4597 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
4598 { TEST_MM_LS(0x21), &tv_dac_clk.c },
4599 { TEST_MM_LS(0x22), &tv_enc_clk.c },
4600 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
4601 { TEST_MM_LS(0x25), &mmfpb_clk.c },
4602 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
4603 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004604 { TEST_MM_LS(0x27), &cam2_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004605 { TEST_MM_LS(0x28), &vcap_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004606
4607 { TEST_MM_HS(0x00), &csi0_clk.c },
4608 { TEST_MM_HS(0x01), &csi1_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004609 { TEST_MM_HS(0x04), &csi_vfe_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004610 { TEST_MM_HS(0x05), &ijpeg_clk.c },
4611 { TEST_MM_HS(0x06), &vfe_clk.c },
4612 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
4613 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
4614 { TEST_MM_HS(0x09), &gfx3d_clk.c },
4615 { TEST_MM_HS(0x0A), &jpegd_clk.c },
4616 { TEST_MM_HS(0x0B), &vcodec_clk.c },
4617 { TEST_MM_HS(0x0F), &mmfab_clk.c },
4618 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
4619 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
4620 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
4621 { TEST_MM_HS(0x13), &imem_axi_clk.c },
4622 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
4623 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
4624 { TEST_MM_HS(0x16), &rot_axi_clk.c },
4625 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
4626 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
4627 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
4628 { TEST_MM_HS(0x1A), &mdp_clk.c },
4629 { TEST_MM_HS(0x1B), &rot_clk.c },
4630 { TEST_MM_HS(0x1C), &vpe_clk.c },
4631 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
4632 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
4633 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
4634 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
4635 { TEST_MM_HS(0x26), &csi_pix_clk.c },
4636 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
4637 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
4638 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
4639 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
4640 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
4641 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004642 { TEST_MM_HS(0x2D), &csi2_clk.c },
4643 { TEST_MM_HS(0x2E), &csi2_phy_clk.c },
4644 { TEST_MM_HS(0x2F), &csi2phy_timer_clk.c },
4645 { TEST_MM_HS(0x30), &csi_pix1_clk.c },
4646 { TEST_MM_HS(0x31), &csi_rdi1_clk.c },
4647 { TEST_MM_HS(0x32), &csi_rdi2_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004648 { TEST_MM_HS(0x33), &vcap_clk.c },
4649 { TEST_MM_HS(0x34), &vcap_npl_clk.c },
Tianyi Gou7747a962012-02-03 15:03:55 -08004650 { TEST_MM_HS(0x35), &vcap_axi_clk.c },
Tianyi Gou51918802012-01-26 14:05:43 -08004651 { TEST_MM_HS(0x36), &rgb_tv_clk.c },
4652 { TEST_MM_HS(0x37), &npl_tv_clk.c },
Tianyi Gou7747a962012-02-03 15:03:55 -08004653 { TEST_MM_HS(0x38), &gfx3d_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004654
4655 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
4656 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
4657 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
4658 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
4659 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
4660 { TEST_LPA(0x14), &pcm_clk.c },
4661 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
Matt Wagantall8b38f942011-08-02 18:23:18 -07004662
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004663 { TEST_LPA_HS(0x00), &q6_func_clk },
4664
Stephen Boyd46fdf0d2011-11-22 12:25:09 -08004665 { TEST_CPUL2(0x2), &l2_m_clk },
4666 { TEST_CPUL2(0x0), &krait0_m_clk },
4667 { TEST_CPUL2(0x1), &krait1_m_clk },
Tianyi Gou455c13c2012-02-02 16:33:24 -08004668 { TEST_CPUL2(0x4), &krait2_m_clk },
4669 { TEST_CPUL2(0x5), &krait3_m_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004670};
4671
4672static struct measure_sel *find_measure_sel(struct clk *clk)
4673{
4674 int i;
4675
4676 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
4677 if (measure_mux[i].clk == clk)
4678 return &measure_mux[i];
4679 return NULL;
4680}
4681
Matt Wagantall8b38f942011-08-02 18:23:18 -07004682static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004683{
4684 int ret = 0;
4685 u32 clk_sel;
4686 struct measure_sel *p;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004687 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004688 unsigned long flags;
4689
4690 if (!parent)
4691 return -EINVAL;
4692
4693 p = find_measure_sel(parent);
4694 if (!p)
4695 return -EINVAL;
4696
4697 spin_lock_irqsave(&local_clock_reg_lock, flags);
4698
Matt Wagantall8b38f942011-08-02 18:23:18 -07004699 /*
4700 * Program the test vector, measurement period (sample_ticks)
4701 * and scaling multiplier.
4702 */
4703 clk->sample_ticks = 0x10000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004704 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004705 clk->multiplier = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004706 switch (p->test_vector >> TEST_TYPE_SHIFT) {
4707 case TEST_TYPE_PER_LS:
4708 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
4709 break;
4710 case TEST_TYPE_PER_HS:
4711 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
4712 break;
4713 case TEST_TYPE_MM_LS:
4714 writel_relaxed(0x4030D97, CLK_TEST_REG);
4715 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
4716 break;
4717 case TEST_TYPE_MM_HS:
4718 writel_relaxed(0x402B800, CLK_TEST_REG);
4719 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
4720 break;
4721 case TEST_TYPE_LPA:
4722 writel_relaxed(0x4030D98, CLK_TEST_REG);
4723 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
4724 LCC_CLK_LS_DEBUG_CFG_REG);
4725 break;
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004726 case TEST_TYPE_LPA_HS:
4727 writel_relaxed(0x402BC00, CLK_TEST_REG);
4728 writel_relaxed(BVAL(2, 1, clk_sel)|BIT(0),
4729 LCC_CLK_HS_DEBUG_CFG_REG);
4730 break;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004731 case TEST_TYPE_CPUL2:
4732 writel_relaxed(0x4030400, CLK_TEST_REG);
4733 writel_relaxed(0x80|BVAL(5, 3, clk_sel), GCC_APCS_CLK_DIAG);
4734 clk->sample_ticks = 0x4000;
4735 clk->multiplier = 2;
4736 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004737 default:
4738 ret = -EPERM;
4739 }
4740 /* Make sure test vector is set before starting measurements. */
4741 mb();
4742
4743 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4744
4745 return ret;
4746}
4747
4748/* Sample clock for 'ticks' reference clock ticks. */
4749static u32 run_measurement(unsigned ticks)
4750{
4751 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004752 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
4753
4754 /* Wait for timer to become ready. */
4755 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
4756 cpu_relax();
4757
4758 /* Run measurement and wait for completion. */
4759 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
4760 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
4761 cpu_relax();
4762
4763 /* Stop counters. */
4764 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
4765
4766 /* Return measured ticks. */
4767 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
4768}
4769
4770
4771/* Perform a hardware rate measurement for a given clock.
4772 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07004773static unsigned long measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004774{
4775 unsigned long flags;
4776 u32 pdm_reg_backup, ringosc_reg_backup;
4777 u64 raw_count_short, raw_count_full;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004778 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004779 unsigned ret;
4780
Stephen Boyd3a35f0b2012-01-11 16:18:26 -08004781 ret = clk_enable(&cxo_clk.c);
4782 if (ret) {
4783 pr_warning("CXO clock failed to enable. Can't measure\n");
4784 return 0;
4785 }
4786
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004787 spin_lock_irqsave(&local_clock_reg_lock, flags);
4788
4789 /* Enable CXO/4 and RINGOSC branch and root. */
4790 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
4791 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
4792 writel_relaxed(0x2898, PDM_CLK_NS_REG);
4793 writel_relaxed(0xA00, RINGOSC_NS_REG);
4794
4795 /*
4796 * The ring oscillator counter will not reset if the measured clock
4797 * is not running. To detect this, run a short measurement before
4798 * the full measurement. If the raw results of the two are the same
4799 * then the clock must be off.
4800 */
4801
4802 /* Run a short measurement. (~1 ms) */
4803 raw_count_short = run_measurement(0x1000);
4804 /* Run a full measurement. (~14 ms) */
Matt Wagantall8b38f942011-08-02 18:23:18 -07004805 raw_count_full = run_measurement(clk->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004806
4807 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
4808 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
4809
4810 /* Return 0 if the clock is off. */
4811 if (raw_count_full == raw_count_short)
4812 ret = 0;
4813 else {
4814 /* Compute rate in Hz. */
4815 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004816 do_div(raw_count_full, ((clk->sample_ticks * 10) + 35));
4817 ret = (raw_count_full * clk->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004818 }
4819
4820 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07004821 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004822 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4823
Stephen Boyd3a35f0b2012-01-11 16:18:26 -08004824 clk_disable(&cxo_clk.c);
4825
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004826 return ret;
4827}
4828#else /* !CONFIG_DEBUG_FS */
4829static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
4830{
4831 return -EINVAL;
4832}
4833
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07004834static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004835{
4836 return 0;
4837}
4838#endif /* CONFIG_DEBUG_FS */
4839
4840static struct clk_ops measure_clk_ops = {
4841 .set_parent = measure_clk_set_parent,
4842 .get_rate = measure_clk_get_rate,
4843 .is_local = local_clk_is_local,
4844};
4845
Matt Wagantall8b38f942011-08-02 18:23:18 -07004846static struct measure_clk measure_clk = {
4847 .c = {
4848 .dbg_name = "measure_clk",
4849 .ops = &measure_clk_ops,
4850 CLK_INIT(measure_clk.c),
4851 },
4852 .multiplier = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004853};
4854
Tianyi Goua8b3cce2011-11-08 14:37:26 -08004855static struct clk_lookup msm_clocks_8064[] = {
Stephen Boyd72a80352012-01-26 15:57:38 -08004856 CLK_LOOKUP("xo", cxo_a_clk.c, ""),
4857 CLK_LOOKUP("xo", pxo_a_clk.c, ""),
Stephen Boyd7dd22662012-01-26 16:09:31 -08004858 CLK_LOOKUP("xo", cxo_clk.c, "msm_otg"),
Stephen Boyded630b02012-01-26 15:26:47 -08004859 CLK_LOOKUP("cxo", cxo_clk.c, "wcnss_wlan.0"),
4860 CLK_LOOKUP("cxo", cxo_clk.c, "pil_riva"),
4861 CLK_LOOKUP("xo", pxo_clk.c, "pil_qdsp6v4.0"),
4862 CLK_LOOKUP("xo", cxo_clk.c, "pil_qdsp6v4.1"),
4863 CLK_LOOKUP("xo", cxo_clk.c, "pil_qdsp6v4.2"),
Matt Wagantall292aace2012-01-26 19:12:34 -08004864 CLK_LOOKUP("xo", cxo_clk.c, "pil_gss"),
Stephen Boyd69d35e32012-02-14 15:33:30 -08004865 CLK_LOOKUP("xo", cxo_clk.c, "BAM_RMNT"),
Stephen Boyded630b02012-01-26 15:26:47 -08004866 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
4867 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
4868 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
4869 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Tianyi Gou41515e22011-09-01 19:37:43 -07004870
Tianyi Gou21a0e802012-02-04 22:34:10 -08004871 CLK_LOOKUP("bus_clk", afab_clk.c, "msm_apps_fab"),
4872 CLK_LOOKUP("bus_a_clk", afab_a_clk.c, "msm_apps_fab"),
4873 CLK_LOOKUP("bus_clk", cfpb_clk.c, "msm_cpss_fpb"),
4874 CLK_LOOKUP("bus_a_clk", cfpb_a_clk.c, "msm_cpss_fpb"),
4875 CLK_LOOKUP("bus_clk", sfab_clk.c, "msm_sys_fab"),
Stephen Boydd7a143a2012-02-16 17:59:26 -08004876 CLK_LOOKUP("bus_a_clk", sfab_msmbus_a_clk.c, "msm_sys_fab"),
Tianyi Gou21a0e802012-02-04 22:34:10 -08004877 CLK_LOOKUP("bus_clk", sfpb_clk.c, "msm_sys_fpb"),
4878 CLK_LOOKUP("bus_a_clk", sfpb_a_clk.c, "msm_sys_fpb"),
4879 CLK_LOOKUP("bus_clk", mmfab_clk.c, "msm_mm_fab"),
4880 CLK_LOOKUP("bus_a_clk", mmfab_a_clk.c, "msm_mm_fab"),
4881 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
4882 CLK_LOOKUP("mem_a_clk", ebi1_a_clk.c, "msm_bus"),
Matt Wagantallb2710b82011-11-16 19:55:17 -08004883
Tianyi Gou21a0e802012-02-04 22:34:10 -08004884 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, ""),
4885 CLK_LOOKUP("dfab_clk", dfab_clk.c, ""),
4886 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, ""),
4887 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, ""),
4888 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8960"),
4889 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, "clock-8960"),
Tianyi Gou41515e22011-09-01 19:37:43 -07004890
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004891 CLK_LOOKUP("core_clk", gp0_clk.c, ""),
4892 CLK_LOOKUP("core_clk", gp1_clk.c, ""),
4893 CLK_LOOKUP("core_clk", gp2_clk.c, ""),
Jin Hong4bbbfba2012-02-02 21:48:07 -08004894 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, "msm_serial_hsl.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004895 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, ""),
4896 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, ""),
4897 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, ""),
4898 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, ""),
4899 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, ""),
Jin Hong4bbbfba2012-02-02 21:48:07 -08004900 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, "msm_serial_hsl.0"),
David Keitel3c40fc52012-02-09 17:53:52 -08004901 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "qup_i2c.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004902 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, ""),
Jing Lin04601f92012-02-05 15:36:07 -08004903 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
Kevin Chand07220e2012-02-13 15:52:22 -08004904 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Stepan Moskovchenko64999002012-01-31 15:52:59 -08004905 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004906 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, ""),
4907 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, ""),
4908 CLK_LOOKUP("core_clk", pdm_clk.c, ""),
Tianyi Gou50f23812012-02-06 16:04:19 -08004909 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_sps"),
Tianyi Gou05e01102012-02-08 22:15:49 -08004910 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Tianyi Gou43208a02011-09-27 15:35:13 -07004911 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
4912 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
4913 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
4914 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004915 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, ""),
4916 CLK_LOOKUP("core_clk", tssc_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08004917 CLK_LOOKUP("alt_core_clk", usb_hs1_xcvr_clk.c, "msm_otg"),
4918 CLK_LOOKUP("alt_core_clk", usb_hs3_xcvr_clk.c, "msm_ehci_host.0"),
4919 CLK_LOOKUP("alt_core_clk", usb_hs4_xcvr_clk.c, "msm_ehci_host.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004920 CLK_LOOKUP("src_clk", usb_fs1_src_clk.c, ""),
4921 CLK_LOOKUP("alt_core_clk", usb_fs1_xcvr_clk.c, ""),
4922 CLK_LOOKUP("sys_clk", usb_fs1_sys_clk.c, ""),
4923 CLK_LOOKUP("iface_clk", ce1_p_clk.c, ""),
4924 CLK_LOOKUP("core_clk", ce1_core_clk.c, ""),
4925 CLK_LOOKUP("ref_clk", sata_phy_ref_clk.c, ""),
4926 CLK_LOOKUP("cfg_clk", sata_phy_cfg_clk.c, ""),
Ramesh Masavarapu28311912011-10-27 11:04:12 -07004927 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qce.0"),
4928 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qcrypto.0"),
4929 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qce.0"),
4930 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qcrypto.0"),
4931 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qce.0"),
4932 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qcrypto.0"),
Tianyi Gou41515e22011-09-01 19:37:43 -07004933 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Jin Hong4bbbfba2012-02-02 21:48:07 -08004934 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "msm_serial_hsl.1"),
David Keitel3c40fc52012-02-09 17:53:52 -08004935 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "qup_i2c.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004936 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, ""),
Jing Lin04601f92012-02-05 15:36:07 -08004937 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
Kevin Chand07220e2012-02-13 15:52:22 -08004938 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Stepan Moskovchenko64999002012-01-31 15:52:59 -08004939 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004940 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, ""),
Jin Hong4bbbfba2012-02-02 21:48:07 -08004941 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, "msm_serial_hsl.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004942 CLK_LOOKUP("iface_clk", tsif_p_clk.c, ""),
4943 CLK_LOOKUP("iface_clk", usb_fs1_p_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08004944 CLK_LOOKUP("iface_clk", usb_hs1_p_clk.c, "msm_otg"),
Manu Gautam7483f172011-11-08 15:22:26 +05304945 CLK_LOOKUP("iface_clk", usb_hs3_p_clk.c, "msm_ehci_host.0"),
4946 CLK_LOOKUP("iface_clk", usb_hs4_p_clk.c, "msm_ehci_host.1"),
Tianyi Gou43208a02011-09-27 15:35:13 -07004947 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
4948 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
4949 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
4950 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004951 CLK_LOOKUP("iface_clk", pcie_p_clk.c, ""),
Tianyi Gou41515e22011-09-01 19:37:43 -07004952 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
4953 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004954 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, ""),
4955 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, ""),
4956 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, ""),
4957 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, ""),
4958 CLK_LOOKUP("core_clk", amp_clk.c, ""),
Kevin Chand07220e2012-02-13 15:52:22 -08004959 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-001a"),
Sreesudhan Ramakrish Ramkumar6c6f57c2012-02-21 15:12:44 -08004960 CLK_LOOKUP("cam_clk", cam1_clk.c, "4-0048"),
Kevin Chand07220e2012-02-13 15:52:22 -08004961 CLK_LOOKUP("cam_clk", cam1_clk.c, "4-006c"),
4962 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_csid.0"),
4963 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_csid.1"),
4964 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, "msm_csid.2"),
4965 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_csid.0"),
4966 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csid.1"),
4967 CLK_LOOKUP("csi_clk", csi2_clk.c, "msm_csid.2"),
4968 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_csid.0"),
4969 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_csid.1"),
4970 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, "msm_csid.2"),
4971 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, "msm_ispif.0"),
4972 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, "msm_ispif.0"),
4973 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, "msm_ispif.0"),
4974 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, "msm_ispif.0"),
4975 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, "msm_ispif.0"),
4976 CLK_LOOKUP("csiphy_timer_src_clk",
4977 csiphy_timer_src_clk.c, "msm_csiphy.0"),
4978 CLK_LOOKUP("csiphy_timer_src_clk",
4979 csiphy_timer_src_clk.c, "msm_csiphy.1"),
4980 CLK_LOOKUP("csiphy_timer_src_clk",
4981 csiphy_timer_src_clk.c, "msm_csiphy.2"),
4982 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, "msm_csiphy.0"),
4983 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, "msm_csiphy.1"),
4984 CLK_LOOKUP("csiphy_timer_clk", csi2phy_timer_clk.c, "msm_csiphy.2"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08004985 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
4986 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
4987 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
4988 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
Tianyi Gou51918802012-01-26 14:05:43 -08004989 CLK_LOOKUP("rgb_clk", rgb_tv_clk.c, ""),
4990 CLK_LOOKUP("npl_clk", npl_tv_clk.c, ""),
4991
Pu Chen86b4be92011-11-03 17:27:57 -07004992 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07004993 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
4994 CLK_LOOKUP("bus_clk", gfx3d_axi_clk.c, "footswitch-8x60.2"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004995 CLK_LOOKUP("iface_clk", vcap_p_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07004996 CLK_LOOKUP("iface_clk", vcap_p_clk.c, "footswitch-8x60.10"),
4997 CLK_LOOKUP("bus_clk", vcap_axi_clk.c, "footswitch-8x60.10"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08004998 CLK_LOOKUP("core_clk", vcap_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07004999 CLK_LOOKUP("core_clk", vcap_clk.c, "footswitch-8x60.10"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005000 CLK_LOOKUP("vcap_npl_clk", vcap_npl_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005001 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005002 CLK_LOOKUP("mem_clk", imem_axi_clk.c, ""),
5003 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005004 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005005 CLK_LOOKUP("core_clk", jpegd_clk.c, ""),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005006 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005007 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005008 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005009 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "footswitch-8x60.4"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005010 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005011 CLK_LOOKUP("lut_clk", lut_mdp_clk.c, "footswitch-8x60.4"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005012 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005013 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Matt Wagantall61286312012-02-22 15:55:09 -08005014 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, "footswitch-8x60.4"),
Aravind Venkateswaran0507c8c2012-02-16 17:16:05 -08005015 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
5016 CLK_LOOKUP("tv_src_div_clk", tv_src_div_clk.c, NULL),
Greg Griscofa47b532011-11-11 10:32:06 -08005017 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005018 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Aravind Venkateswaran0507c8c2012-02-16 17:16:05 -08005019 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
Tianyi Gou51918802012-01-26 14:05:43 -08005020 CLK_LOOKUP("tv_clk", mdp_tv_clk.c, "footswitch-8x60.4"),
Aravind Venkateswaran0507c8c2012-02-16 17:16:05 -08005021 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
5022 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
5023 CLK_LOOKUP("vpe_clk", vpe_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005024 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Kevin Chand07220e2012-02-13 15:52:22 -08005025 CLK_LOOKUP("vfe_clk", vfe_clk.c, "msm_vfe.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005026 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Kevin Chand07220e2012-02-13 15:52:22 -08005027 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, "msm_vfe.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005028 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5029 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5030 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5031 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5032 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5033 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5034 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005035 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Kevin Chand07220e2012-02-13 15:52:22 -08005036 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.0"),
5037 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.1"),
5038 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.2"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005039 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5040 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5041 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5042 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Pu Chen86b4be92011-11-03 17:27:57 -07005043 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005044 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Aravind Venkateswaran0507c8c2012-02-16 17:16:05 -08005045 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
5046 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005047 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, ""),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005048 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005049 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, ""),
Matt Wagantall5d44ef22012-01-23 11:01:05 -08005050 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, "kgsl-3d0.0"),
Ravishangar Kalyanamc2fee312012-02-09 19:11:22 -08005051 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005052 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Stepan Moskovchenko279b7852012-01-31 20:42:46 -08005053 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005054 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005055 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Greg Griscofa47b532011-11-11 10:32:06 -08005056 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005057 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Kevin Chand07220e2012-02-13 15:52:22 -08005058 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, "msm_vfe.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005059 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Kevin Chanb20742b2012-02-27 15:47:35 -08005060 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, "msm_vpe.0"),
Matt Wagantall61286312012-02-22 15:55:09 -08005061 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Tianyi Gou21a0e802012-02-04 22:34:10 -08005062
Kuirong Wanga9c3acc2012-02-09 17:00:45 -08005063 CLK_LOOKUP("bit_clk", mi2s_bit_clk.c, "msm-dai-q6.6"),
5064 CLK_LOOKUP("osr_clk", mi2s_osr_clk.c, "msm-dai-q6.6"),
5065 CLK_LOOKUP("bit_clk", codec_i2s_mic_bit_clk.c,
5066 "msm-dai-q6.1"),
5067 CLK_LOOKUP("osr_clk", codec_i2s_mic_osr_clk.c,
5068 "msm-dai-q6.1"),
5069 CLK_LOOKUP("bit_clk", spare_i2s_mic_bit_clk.c,
5070 "msm-dai-q6.5"),
5071 CLK_LOOKUP("osr_clk", spare_i2s_mic_osr_clk.c,
5072 "msm-dai-q6.5"),
5073 CLK_LOOKUP("bit_clk", codec_i2s_spkr_bit_clk.c,
5074 "msm-dai-q6.16384"),
5075 CLK_LOOKUP("osr_clk", codec_i2s_spkr_osr_clk.c,
5076 "msm-dai-q6.16384"),
5077 CLK_LOOKUP("bit_clk", spare_i2s_spkr_bit_clk.c,
5078 "msm-dai-q6.4"),
5079 CLK_LOOKUP("osr_clk", spare_i2s_spkr_osr_clk.c,
5080 "msm-dai-q6.4"),
5081 CLK_LOOKUP("pcm_clk", pcm_clk.c, "msm-dai-q6.2"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005082 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, ""),
Tianyi Gou44a81b02012-02-06 17:49:07 -08005083 CLK_LOOKUP("core_clk", audio_slimbus_clk.c, "msm_slim_ctrl.1"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005084 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, ""),
5085 CLK_LOOKUP("core_clk", vpe_axi_clk.c, ""),
5086 CLK_LOOKUP("core_clk", mdp_axi_clk.c, ""),
5087 CLK_LOOKUP("core_clk", vcap_axi_clk.c, ""),
5088 CLK_LOOKUP("core_clk", rot_axi_clk.c, ""),
5089 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, ""),
5090 CLK_LOOKUP("core_clk", vfe_axi_clk.c, ""),
5091 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, ""),
5092 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, ""),
5093 CLK_LOOKUP("core_clk", gfx3d_axi_clk.c, ""),
Tianyi Gou21a0e802012-02-04 22:34:10 -08005094
5095 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
5096 CLK_LOOKUP("core_clk", dfab_usb_hs_clk.c, "msm_otg"),
5097 CLK_LOOKUP("core_clk", dfab_usb_hs3_clk.c, "msm_ehci_host.0"),
5098 CLK_LOOKUP("core_clk", dfab_usb_hs3_clk.c, "msm_ehci_host.1"),
5099 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
5100 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
5101 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
5102 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
5103 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
5104 CLK_LOOKUP("bus_clk", dfab_bam_dmux_clk.c, "BAM_RMNT"),
5105 CLK_LOOKUP("bus_clk", dfab_scm_clk.c, "scm"),
Ramesh Masavarapua1bc0e42012-03-05 07:42:48 -08005106 CLK_LOOKUP("bus_clk", dfab_qseecom_clk.c, "qseecom"),
Ramesh Masavarapueb6e9342012-02-13 19:59:50 -08005107 CLK_LOOKUP("bus_clk", dfab_tzcom_clk.c, "tzcom"),
Tianyi Gou21a0e802012-02-04 22:34:10 -08005108
Manu Gautam5143b252012-01-05 19:25:23 -08005109 CLK_LOOKUP("alt_core_clk", usb_hsic_xcvr_fs_clk.c, "msm_hsic_host"),
5110 CLK_LOOKUP("phy_clk", usb_hsic_hsic_clk.c, "msm_hsic_host"),
5111 CLK_LOOKUP("cal_clk", usb_hsic_hsio_cal_clk.c, "msm_hsic_host"),
5112 CLK_LOOKUP("core_clk", usb_hsic_system_clk.c, "msm_hsic_host"),
5113 CLK_LOOKUP("iface_clk", usb_hsic_p_clk.c, "msm_hsic_host"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005114
Stepan Moskovchenko279b7852012-01-31 20:42:46 -08005115 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
5116 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
5117 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
5118 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
5119 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
5120 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
5121 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
5122 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
5123 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
5124 CLK_LOOKUP("core_clk", gfx3d_axi_clk.c, "msm_iommu.9"),
5125 CLK_LOOKUP("core_clk", gfx3d_axi_clk.c, "msm_iommu.10"),
5126 CLK_LOOKUP("core_clk", vcap_axi_clk.c, "msm_iommu.11"),
5127
Jeff Ohlstein8c116c72011-10-27 17:34:48 -07005128 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005129
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005130 CLK_LOOKUP("l2_mclk", l2_m_clk, ""),
5131 CLK_LOOKUP("krait0_mclk", krait0_m_clk, ""),
5132 CLK_LOOKUP("krait1_mclk", krait1_m_clk, ""),
Tianyi Gou455c13c2012-02-02 16:33:24 -08005133 CLK_LOOKUP("krait2_mclk", krait2_m_clk, ""),
5134 CLK_LOOKUP("krait3_mclk", krait3_m_clk, ""),
Tianyi Gou41515e22011-09-01 19:37:43 -07005135};
5136
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005137static struct clk_lookup msm_clocks_8960[] = {
Stephen Boyd72a80352012-01-26 15:57:38 -08005138 CLK_LOOKUP("xo", cxo_a_clk.c, ""),
5139 CLK_LOOKUP("xo", pxo_a_clk.c, ""),
Stephen Boyd7dd22662012-01-26 16:09:31 -08005140 CLK_LOOKUP("xo", cxo_clk.c, "msm_otg"),
Stephen Boyded630b02012-01-26 15:26:47 -08005141 CLK_LOOKUP("cxo", cxo_clk.c, "wcnss_wlan.0"),
5142 CLK_LOOKUP("cxo", cxo_clk.c, "pil_riva"),
5143 CLK_LOOKUP("xo", pxo_clk.c, "pil_qdsp6v4.0"),
5144 CLK_LOOKUP("xo", cxo_clk.c, "pil_qdsp6v4.1"),
5145 CLK_LOOKUP("xo", cxo_clk.c, "pil_qdsp6v4.2"),
Stephen Boyd69d35e32012-02-14 15:33:30 -08005146 CLK_LOOKUP("xo", cxo_clk.c, "BAM_RMNT"),
Stephen Boyded630b02012-01-26 15:26:47 -08005147 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
5148 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
5149 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
5150 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005151
Matt Wagantallb2710b82011-11-16 19:55:17 -08005152 CLK_LOOKUP("bus_clk", afab_clk.c, "msm_apps_fab"),
5153 CLK_LOOKUP("bus_a_clk", afab_a_clk.c, "msm_apps_fab"),
5154 CLK_LOOKUP("bus_clk", cfpb_clk.c, "msm_cpss_fpb"),
5155 CLK_LOOKUP("bus_a_clk", cfpb_a_clk.c, "msm_cpss_fpb"),
5156 CLK_LOOKUP("bus_clk", sfab_clk.c, "msm_sys_fab"),
Stephen Boydd7a143a2012-02-16 17:59:26 -08005157 CLK_LOOKUP("bus_a_clk", sfab_msmbus_a_clk.c, "msm_sys_fab"),
Matt Wagantallb2710b82011-11-16 19:55:17 -08005158 CLK_LOOKUP("bus_clk", sfpb_clk.c, "msm_sys_fpb"),
5159 CLK_LOOKUP("bus_a_clk", sfpb_a_clk.c, "msm_sys_fpb"),
5160 CLK_LOOKUP("bus_clk", mmfab_clk.c, "msm_mm_fab"),
5161 CLK_LOOKUP("bus_a_clk", mmfab_a_clk.c, "msm_mm_fab"),
5162 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
5163 CLK_LOOKUP("mem_a_clk", ebi1_a_clk.c, "msm_bus"),
5164
5165 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
5166 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
5167 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
5168 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
5169 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8960"),
5170 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005171
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005172 CLK_LOOKUP("core_clk", gp0_clk.c, ""),
5173 CLK_LOOKUP("core_clk", gp1_clk.c, ""),
5174 CLK_LOOKUP("core_clk", gp2_clk.c, ""),
5175 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, ""),
5176 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, ""),
5177 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, ""),
5178 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, ""),
Matt Wagantalle2522372011-08-17 14:52:21 -07005179 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
5180 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005181 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, ""),
5182 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, ""),
5183 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, ""),
5184 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, ""),
5185 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, ""),
5186 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005187 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005188 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005189 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
5190 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005191 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, ""),
5192 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, ""),
5193 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, ""),
5194 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, ""),
5195 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005196 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005197 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005198 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005199 CLK_LOOKUP("core_clk", pdm_clk.c, ""),
Vikram Mulukutladd0a2372011-09-19 15:58:21 -07005200 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_sps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07005201 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005202 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5203 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5204 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5205 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
5206 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005207 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005208 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, ""),
5209 CLK_LOOKUP("core_clk", tssc_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08005210 CLK_LOOKUP("alt_core_clk", usb_hs1_xcvr_clk.c, "msm_otg"),
5211 CLK_LOOKUP("phy_clk", usb_phy0_clk.c, "msm_otg"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005212 CLK_LOOKUP("alt_core_clk", usb_fs1_xcvr_clk.c, ""),
5213 CLK_LOOKUP("sys_clk", usb_fs1_sys_clk.c, ""),
5214 CLK_LOOKUP("src_clk", usb_fs1_src_clk.c, ""),
5215 CLK_LOOKUP("alt_core_clk", usb_fs2_xcvr_clk.c, ""),
5216 CLK_LOOKUP("sys_clk", usb_fs2_sys_clk.c, ""),
5217 CLK_LOOKUP("src_clk", usb_fs2_src_clk.c, ""),
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005218 CLK_LOOKUP("alt_core_clk", usb_hsic_xcvr_fs_clk.c, "msm_hsic_host"),
5219 CLK_LOOKUP("phy_clk", usb_hsic_hsic_clk.c, "msm_hsic_host"),
5220 CLK_LOOKUP("cal_clk", usb_hsic_hsio_cal_clk.c, "msm_hsic_host"),
5221 CLK_LOOKUP("core_clk", usb_hsic_system_clk.c, "msm_hsic_host"),
5222 CLK_LOOKUP("iface_clk", usb_hsic_p_clk.c, "msm_hsic_host"),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005223 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005224 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qcrypto.0"),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005225 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005226 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qcrypto.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005227 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005228 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005229 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005230 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
5231 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07005232 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
5233 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005234 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, ""),
5235 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, ""),
5236 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005237 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "qup_i2c.10"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005238 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, ""),
Matt Wagantallac294852011-08-17 15:44:58 -07005239 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.12"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005240 CLK_LOOKUP("iface_clk", tsif_p_clk.c, ""),
5241 CLK_LOOKUP("iface_clk", usb_fs1_p_clk.c, ""),
5242 CLK_LOOKUP("iface_clk", usb_fs2_p_clk.c, ""),
Manu Gautam5143b252012-01-05 19:25:23 -08005243 CLK_LOOKUP("iface_clk", usb_hs1_p_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -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"),
5248 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005249 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5250 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005251 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, ""),
5252 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, ""),
5253 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, ""),
5254 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, ""),
5255 CLK_LOOKUP("core_clk", amp_clk.c, ""),
Kevin Chan09f4e662011-12-16 08:17:02 -08005256 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-001a"),
5257 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-006c"),
5258 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-0048"),
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005259 CLK_LOOKUP("cam_clk", cam2_clk.c, NULL),
Sreesudhan Ramakrish Ramkumar8f11b8b2012-01-04 17:09:05 -08005260 CLK_LOOKUP("cam_clk", cam0_clk.c, "4-0020"),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005261 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_csid.0"),
5262 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_csid.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005263 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, "msm_csid.2"),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005264 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_csid.0"),
5265 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csid.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005266 CLK_LOOKUP("csi_clk", csi2_clk.c, "msm_csid.2"),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005267 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_csid.0"),
5268 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_csid.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005269 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, "msm_csid.2"),
Kevin Chane12c6672011-10-26 11:55:26 -07005270 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, "msm_ispif.0"),
5271 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, "msm_ispif.0"),
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005272 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
5273 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
5274 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, "msm_ispif.0"),
5275 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, "msm_ispif.0"),
5276 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, "msm_ispif.0"),
5277 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
5278 CLK_LOOKUP("csi2phy_timer_clk", csi2phy_timer_clk.c, NULL),
Kevin Chanf6216f22011-10-25 18:40:11 -07005279 CLK_LOOKUP("csiphy_timer_src_clk",
5280 csiphy_timer_src_clk.c, "msm_csiphy.0"),
5281 CLK_LOOKUP("csiphy_timer_src_clk",
5282 csiphy_timer_src_clk.c, "msm_csiphy.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005283 CLK_LOOKUP("csiphy_timer_src_clk",
5284 csiphy_timer_src_clk.c, "msm_csiphy.2"),
Kevin Chanf6216f22011-10-25 18:40:11 -07005285 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, "msm_csiphy.0"),
5286 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, "msm_csiphy.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005287 CLK_LOOKUP("csiphy_timer_clk", csi2phy_timer_clk.c, "msm_csiphy.2"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005288 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5289 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5290 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5291 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005292 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005293 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005294 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005295 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005296 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005297 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5298 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Jignesh Mehta95dd6e12011-11-18 17:21:16 -08005299 CLK_LOOKUP("imem_clk", imem_axi_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005300 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005301 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005302 CLK_LOOKUP("core_clk", jpegd_clk.c, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005303 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005304 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005305 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005306 CLK_LOOKUP("vsync_clk", mdp_vsync_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005307 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005308 CLK_LOOKUP("lut_clk", lut_mdp_clk.c, "footswitch-8x60.4"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005309 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005310 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005311 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005312 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005313 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
5314 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005315 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005316 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005317 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
Matt Wagantallb82a5132011-12-12 22:26:41 -08005318 CLK_LOOKUP("tv_clk", mdp_tv_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005319 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005320 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Kevin Chana0853122011-11-07 19:48:44 -08005321 CLK_LOOKUP("vpe_clk", vpe_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005322 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Kevin Chan5827c552011-10-28 18:36:32 -07005323 CLK_LOOKUP("vfe_clk", vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005324 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Kevin Chan5827c552011-10-28 18:36:32 -07005325 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005326 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5327 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5328 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5329 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5330 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5331 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5332 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005333 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005334 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.0"),
5335 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.1"),
Sreesudhan Ramakrish Ramkumarb1edcd02012-01-17 11:33:05 -08005336 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.2"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005337 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5338 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5339 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5340 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005341 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005342 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005343 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005344 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005345 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005346 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005347 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
5348 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005349 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005350 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005351 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, ""),
Matt Wagantall5d44ef22012-01-23 11:01:05 -08005352 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, "kgsl-3d0.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005353 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005354 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07005355 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005356 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005357 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005358 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005359 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005360 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Kevin Chan5827c552011-10-28 18:36:32 -07005361 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005362 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Kevin Chana0853122011-11-07 19:48:44 -08005363 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005364 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Kuirong Wanga9c3acc2012-02-09 17:00:45 -08005365 CLK_LOOKUP("bit_clk", mi2s_bit_clk.c, "msm-dai-q6.6"),
5366 CLK_LOOKUP("osr_clk", mi2s_osr_clk.c, "msm-dai-q6.6"),
5367 CLK_LOOKUP("bit_clk", codec_i2s_mic_bit_clk.c,
5368 "msm-dai-q6.1"),
5369 CLK_LOOKUP("osr_clk", codec_i2s_mic_osr_clk.c,
5370 "msm-dai-q6.1"),
5371 CLK_LOOKUP("bit_clk", spare_i2s_mic_bit_clk.c,
5372 "msm-dai-q6.5"),
5373 CLK_LOOKUP("osr_clk", spare_i2s_mic_osr_clk.c,
5374 "msm-dai-q6.5"),
5375 CLK_LOOKUP("bit_clk", codec_i2s_spkr_bit_clk.c,
5376 "msm-dai-q6.16384"),
5377 CLK_LOOKUP("osr_clk", codec_i2s_spkr_osr_clk.c,
5378 "msm-dai-q6.16384"),
5379 CLK_LOOKUP("bit_clk", spare_i2s_spkr_bit_clk.c,
5380 "msm-dai-q6.4"),
5381 CLK_LOOKUP("osr_clk", spare_i2s_spkr_osr_clk.c,
5382 "msm-dai-q6.4"),
5383 CLK_LOOKUP("pcm_clk", pcm_clk.c, "msm-dai-q6.2"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005384 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
Tianyi Gou44a81b02012-02-06 17:49:07 -08005385 CLK_LOOKUP("core_clk", audio_slimbus_clk.c, "msm_slim_ctrl.1"),
Matt Wagantalle604d712011-10-21 15:38:18 -07005386 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
5387 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
5388 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
5389 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
5390 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
5391 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
5392 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
5393 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
5394 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
5395 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
5396 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
5397 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Gopikrishnaiah Anandan4d05ed32012-01-13 11:08:44 -08005398
5399 CLK_LOOKUP("mdp_iommu_clk", mdp_axi_clk.c, "msm_vidc.0"),
5400 CLK_LOOKUP("rot_iommu_clk", rot_axi_clk.c, "msm_vidc.0"),
5401 CLK_LOOKUP("vcodec_iommu0_clk", vcodec_axi_a_clk.c, "msm_vidc.0"),
5402 CLK_LOOKUP("vcodec_iommu1_clk", vcodec_axi_b_clk.c, "msm_vidc.0"),
5403 CLK_LOOKUP("smmu_iface_clk", smmu_p_clk.c, "msm_vidc.0"),
5404
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005405 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
Manu Gautam5143b252012-01-05 19:25:23 -08005406 CLK_LOOKUP("core_clk", dfab_usb_hs_clk.c, "msm_otg"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005407 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
5408 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
5409 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
5410 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
5411 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Yan He160633e2011-06-30 12:18:56 -07005412 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
Stephen Boyd1c51a492011-10-26 12:11:47 -07005413 CLK_LOOKUP("bus_clk", dfab_bam_dmux_clk.c, "BAM_RMNT"),
Stephen Boydef5d1c42011-12-15 20:47:14 -08005414 CLK_LOOKUP("bus_clk", dfab_scm_clk.c, "scm"),
Ramesh Masavarapua1bc0e42012-03-05 07:42:48 -08005415 CLK_LOOKUP("bus_clk", dfab_qseecom_clk.c, "qseecom"),
Ramesh Masavarapueb6e9342012-02-13 19:59:50 -08005416 CLK_LOOKUP("bus_clk", dfab_tzcom_clk.c, "tzcom"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005417
Matt Wagantalle1a86062011-08-18 17:46:10 -07005418 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005419
Matt Wagantallc00f95d2012-01-05 14:22:45 -08005420 CLK_LOOKUP("l2_mclk", l2_m_clk, ""),
5421 CLK_LOOKUP("krait0_mclk", krait0_m_clk, ""),
5422 CLK_LOOKUP("krait1_mclk", krait1_m_clk, ""),
5423 CLK_LOOKUP("q6sw_clk", q6sw_clk, ""),
5424 CLK_LOOKUP("q6fw_clk", q6fw_clk, ""),
5425 CLK_LOOKUP("q6_func_clk", q6_func_clk, ""),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005426};
5427
5428/*
5429 * Miscellaneous clock register initializations
5430 */
5431
5432/* Read, modify, then write-back a register. */
5433static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
5434{
5435 uint32_t regval = readl_relaxed(reg);
5436 regval &= ~mask;
5437 regval |= val;
5438 writel_relaxed(regval, reg);
5439}
5440
Tianyi Gou41515e22011-09-01 19:37:43 -07005441static void __init set_fsm_mode(void __iomem *mode_reg)
5442{
5443 u32 regval = readl_relaxed(mode_reg);
5444
5445 /*De-assert reset to FSM */
5446 regval &= ~BIT(21);
5447 writel_relaxed(regval, mode_reg);
5448
5449 /* Program bias count */
Tianyi Gou358c3862011-10-18 17:03:41 -07005450 regval &= ~BM(19, 14);
5451 regval |= BVAL(19, 14, 0x1);
5452 writel_relaxed(regval, mode_reg);
5453
5454 /* Program lock count */
Tianyi Gou41515e22011-09-01 19:37:43 -07005455 regval &= ~BM(13, 8);
5456 regval |= BVAL(13, 8, 0x8);
5457 writel_relaxed(regval, mode_reg);
5458
5459 /*Enable PLL FSM voting */
5460 regval |= BIT(20);
5461 writel_relaxed(regval, mode_reg);
5462}
5463
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005464static void __init reg_init(void)
5465{
Stephen Boydd471e7a2011-11-19 01:37:39 -08005466 void __iomem *imem_reg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005467 /* Deassert MM SW_RESET_ALL signal. */
5468 writel_relaxed(0, SW_RESET_ALL_REG);
5469
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005470 /*
5471 * Some bits are only used on either 8960 or 8064 and are marked as
5472 * reserved bits on the other SoC. Writing to these reserved bits
5473 * should have no effect.
5474 */
Stephen Boydd471e7a2011-11-19 01:37:39 -08005475 /*
5476 * Initialize MM AHB registers: Enable the FPB clock and disable HW
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005477 * gating on non-8960 for all clocks. Also set VFE_AHB's
Stephen Boydd471e7a2011-11-19 01:37:39 -08005478 * FORCE_CORE_ON bit to prevent its memory from being collapsed when
5479 * the clock is halted. The sleep and wake-up delays are set to safe
5480 * values.
5481 */
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005482 if (cpu_is_msm8960()) {
Stephen Boydd471e7a2011-11-19 01:37:39 -08005483 rmwreg(0x44000000, AHB_EN_REG, 0x6C000103);
5484 writel_relaxed(0x3C7097F9, AHB_EN2_REG);
5485 } else {
5486 rmwreg(0x00000003, AHB_EN_REG, 0x6C000103);
5487 writel_relaxed(0x000007F9, AHB_EN2_REG);
5488 }
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005489 if (cpu_is_apq8064())
5490 rmwreg(0x00000000, AHB_EN3_REG, 0x00000001);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005491
5492 /* Deassert all locally-owned MM AHB resets. */
5493 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
Tianyi Gou41515e22011-09-01 19:37:43 -07005494 rmwreg(0, SW_RESET_AHB2_REG, 0x0000000F);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005495
5496 /* Initialize MM AXI registers: Enable HW gating for all clocks that
5497 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
5498 * delays to safe values. */
Stephen Boydd471e7a2011-11-19 01:37:39 -08005499 if (cpu_is_msm8960() &&
5500 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 3) {
5501 rmwreg(0x0003AFF9, MAXI_EN_REG, 0x0803FFFF);
5502 rmwreg(0x3A27FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
Gopikrishnaiah Anandan83b6e852012-01-05 17:47:02 -08005503 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
Stephen Boydd471e7a2011-11-19 01:37:39 -08005504 } else {
5505 rmwreg(0x000007F9, MAXI_EN_REG, 0x0803FFFF);
5506 rmwreg(0x3027FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
5507 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
5508 }
Matt Wagantall53d968f2011-07-19 13:22:53 -07005509 rmwreg(0x0027FCFF, MAXI_EN3_REG, 0x003FFFFF);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005510 if (cpu_is_apq8064())
5511 rmwreg(0x009FE4FF, MAXI_EN5_REG, 0x01FFEFFF);
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005512 if (cpu_is_msm8960())
Stephen Boydd471e7a2011-11-19 01:37:39 -08005513 rmwreg(0x00003C38, SAXI_EN_REG, 0x00003FFF);
5514 else
5515 rmwreg(0x000003C7, SAXI_EN_REG, 0x00003FFF);
5516
5517 /* Enable IMEM's clk_on signal */
5518 imem_reg = ioremap(0x04b00040, 4);
5519 if (imem_reg) {
5520 writel_relaxed(0x3, imem_reg);
5521 iounmap(imem_reg);
5522 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005523
5524 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
5525 * memories retain state even when not clocked. Also, set sleep and
5526 * wake-up delays to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005527 rmwreg(0x00000000, CSI0_CC_REG, 0x00000410);
5528 rmwreg(0x00000000, CSI1_CC_REG, 0x00000410);
5529 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, 0xE0FF0010);
5530 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, 0xE0FF0010);
5531 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, 0xE0FF0010);
5532 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, 0xE0FF0010);
Tarun Karra6fbc00a2011-12-13 09:23:47 -07005533 rmwreg(0xC0FF0000, GFX3D_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005534 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0010);
5535 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0010);
5536 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
5537 rmwreg(0x80FF0000, MDP_LUT_CC_REG, 0xE0FF0010);
5538 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005539 rmwreg(0x000004FF, TV_CC2_REG, 0x000007FF);
5540 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
5541 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FF4010);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005542 rmwreg(0x800000FF, VFE_CC2_REG, 0xE00000FF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005543 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005544 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005545 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
5546 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
5547 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
5548 }
5549 if (cpu_is_apq8064()) {
5550 rmwreg(0x00000000, TV_CC_REG, 0x00004010);
Tianyi Gou621f8742011-09-01 21:45:01 -07005551 rmwreg(0x80FF0000, VCAP_CC_REG, 0xE0FF1010);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005552 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005553
Tianyi Gou41515e22011-09-01 19:37:43 -07005554 /*
5555 * Initialize USB_HS_HCLK_FS registers: Set FORCE_C_ON bits so that
5556 * core remain active during halt state of the clk. Also, set sleep
5557 * and wake-up value to max.
5558 */
5559 rmwreg(0x0000004F, USB_HS1_HCLK_FS_REG, 0x0000007F);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005560 if (cpu_is_apq8064()) {
5561 rmwreg(0x0000004F, USB_HS3_HCLK_FS_REG, 0x0000007F);
5562 rmwreg(0x0000004F, USB_HS4_HCLK_FS_REG, 0x0000007F);
5563 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005564
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005565 /* De-assert MM AXI resets to all hardware blocks. */
5566 writel_relaxed(0, SW_RESET_AXI_REG);
5567
5568 /* Deassert all MM core resets. */
5569 writel_relaxed(0, SW_RESET_CORE_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005570 writel_relaxed(0, SW_RESET_CORE2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005571
5572 /* Reset 3D core once more, with its clock enabled. This can
5573 * eventually be done as part of the GDFS footswitch driver. */
5574 clk_set_rate(&gfx3d_clk.c, 27000000);
5575 clk_enable(&gfx3d_clk.c);
5576 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
5577 mb();
5578 udelay(5);
5579 writel_relaxed(0, SW_RESET_CORE_REG);
5580 /* Make sure reset is de-asserted before clock is disabled. */
5581 mb();
5582 clk_disable(&gfx3d_clk.c);
5583
5584 /* Enable TSSC and PDM PXO sources. */
5585 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
5586 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
5587
5588 /* Source SLIMBus xo src from slimbus reference clock */
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005589 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005590 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005591
5592 /* Source the dsi_byte_clks from the DSI PHY PLLs */
5593 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
5594 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
Tianyi Gou41515e22011-09-01 19:37:43 -07005595
5596 /* Source the sata_phy_ref_clk from PXO */
5597 if (cpu_is_apq8064())
5598 rmwreg(0, SATA_PHY_REF_CLK_CTL_REG, 0x1);
5599
5600 /*
Tianyi Gou05e01102012-02-08 22:15:49 -08005601 * TODO: Programming below PLLs and prng_clk is temporary and
5602 * needs to be removed after bootloaders program them.
Tianyi Gou41515e22011-09-01 19:37:43 -07005603 */
5604 if (cpu_is_apq8064()) {
Tianyi Gou317aa862012-02-06 14:31:07 -08005605 u32 is_pll_enabled;
Tianyi Gou41515e22011-09-01 19:37:43 -07005606
5607 /* Program pxo_src_clk to source from PXO */
5608 rmwreg(0x1, PXO_SRC_CLK_CTL_REG, 0x7);
5609
Tianyi Gou41515e22011-09-01 19:37:43 -07005610 /* Check if PLL14 is active */
5611 is_pll_enabled = readl_relaxed(BB_PLL14_STATUS_REG) & BIT(16);
5612 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005613 /* Ref clk = 27MHz and program pll14 to 480MHz */
Tianyi Gou317aa862012-02-06 14:31:07 -08005614 writel_relaxed(0x00031011, BB_PLL14_L_VAL_REG);
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005615 writel_relaxed(0x7, BB_PLL14_M_VAL_REG);
5616 writel_relaxed(0x9, BB_PLL14_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005617
Tianyi Gou317aa862012-02-06 14:31:07 -08005618 /*
5619 * Enable the main output and the MN accumulator
5620 * Set pre-divider and post-divider values to 1 and 1
5621 */
5622 writel_relaxed(0x00C00000, BB_PLL14_CONFIG_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005623
Tianyi Gou41515e22011-09-01 19:37:43 -07005624 set_fsm_mode(BB_PLL14_MODE_REG);
5625 }
Tianyi Gou621f8742011-09-01 21:45:01 -07005626
Tianyi Gou621f8742011-09-01 21:45:01 -07005627 /* Program PLL15 to 975MHz with ref clk = 27MHz */
Tianyi Gou317aa862012-02-06 14:31:07 -08005628 writel_relaxed(0x31024, MM_PLL3_L_VAL_REG);
5629 writel_relaxed(0x1, MM_PLL3_M_VAL_REG);
5630 writel_relaxed(0x9, MM_PLL3_N_VAL_REG);
Tianyi Gou621f8742011-09-01 21:45:01 -07005631
Tianyi Gou317aa862012-02-06 14:31:07 -08005632 writel_relaxed(0xC20000, MM_PLL3_CONFIG_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005633
5634 /* Check if PLL4 is active */
5635 is_pll_enabled = readl_relaxed(LCC_PLL0_STATUS_REG) & BIT(16);
5636 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005637 /* Ref clk = 27MHz and program pll4 to 393.2160MHz */
5638 writel_relaxed(0xE, LCC_PLL0_L_VAL_REG);
5639 writel_relaxed(0x27A, LCC_PLL0_M_VAL_REG);
5640 writel_relaxed(0x465, LCC_PLL0_N_VAL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005641
Tianyi Gou317aa862012-02-06 14:31:07 -08005642 writel_relaxed(0xC00000, LCC_PLL0_CONFIG_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005643
5644 set_fsm_mode(LCC_PLL0_MODE_REG);
5645 }
5646
5647 /* Enable PLL4 source on the LPASS Primary PLL Mux */
5648 writel_relaxed(0x1, LCC_PRI_PLL_CLK_CTL_REG);
Tianyi Gou05e01102012-02-08 22:15:49 -08005649
5650 /* Program prng_clk to 64MHz if it isn't configured */
5651 if (!readl_relaxed(PRNG_CLK_NS_REG))
5652 writel_relaxed(0x2B, PRNG_CLK_NS_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005653 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005654}
5655
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005656/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07005657static void __init msm8960_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005658{
Stephen Boyd72a80352012-01-26 15:57:38 -08005659 /* Keep PXO on whenever APPS cpu is active */
5660 clk_prepare_enable(&pxo_a_clk.c);
Tianyi Gou41515e22011-09-01 19:37:43 -07005661
Saravana Kannan298ec392012-02-08 19:21:47 -08005662 if (cpu_is_apq8064()) {
5663 vdd_sr2_pll.set_vdd = set_vdd_sr2_pll_8064;
Tianyi Goue1faaf22012-01-24 16:07:19 -08005664 } else if (cpu_is_msm8930() || cpu_is_msm8627()) {
Saravana Kannan298ec392012-02-08 19:21:47 -08005665 vdd_dig.set_vdd = set_vdd_dig_8930;
5666 vdd_sr2_pll.set_vdd = set_vdd_sr2_pll_8930;
Tianyi Goue1faaf22012-01-24 16:07:19 -08005667 }
Tianyi Goubf3d0b12012-01-23 14:37:28 -08005668
Tianyi Gou41515e22011-09-01 19:37:43 -07005669 /*
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005670 * Change the freq tables for and voltage requirements for
5671 * clocks which differ between 8960 and 8064.
Tianyi Gou41515e22011-09-01 19:37:43 -07005672 */
5673 if (cpu_is_apq8064()) {
5674 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8064;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005675
5676 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8064,
5677 sizeof(gfx3d_clk.c.fmax));
5678 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8064,
5679 sizeof(ijpeg_clk.c.fmax));
5680 memcpy(mdp_clk.c.fmax, fmax_mdp_8064,
5681 sizeof(ijpeg_clk.c.fmax));
5682 memcpy(tv_src_clk.c.fmax, fmax_tv_src_8064,
5683 sizeof(tv_src_clk.c.fmax));
5684 memcpy(vfe_clk.c.fmax, fmax_vfe_8064,
5685 sizeof(vfe_clk.c.fmax));
5686
Tianyi Gou621f8742011-09-01 21:45:01 -07005687 gmem_axi_clk.c.depends = &gfx3d_axi_clk.c;
Tianyi Gou41515e22011-09-01 19:37:43 -07005688 }
Stephen Boyd94625ef2011-07-12 17:06:01 -07005689
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005690 vote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005691
Vikram Mulukutla489e39e2011-08-31 18:04:05 -07005692 clk_ops_pll.enable = sr_pll_clk_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005693
5694 /* Initialize clock registers. */
5695 reg_init();
5696
5697 /* Initialize rates for clocks that only support one. */
5698 clk_set_rate(&pdm_clk.c, 27000000);
5699 clk_set_rate(&prng_clk.c, 64000000);
5700 clk_set_rate(&mdp_vsync_clk.c, 27000000);
5701 clk_set_rate(&tsif_ref_clk.c, 105000);
5702 clk_set_rate(&tssc_clk.c, 27000000);
5703 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
Tianyi Gou41515e22011-09-01 19:37:43 -07005704 if (cpu_is_apq8064()) {
5705 clk_set_rate(&usb_hs3_xcvr_clk.c, 60000000);
5706 clk_set_rate(&usb_hs4_xcvr_clk.c, 60000000);
5707 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005708 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005709 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou41515e22011-09-01 19:37:43 -07005710 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005711 clk_set_rate(&usb_hsic_xcvr_fs_clk.c, 60000000);
5712 clk_set_rate(&usb_hsic_hsic_src_clk.c, 480000000);
5713 clk_set_rate(&usb_hsic_hsio_cal_clk.c, 9000000);
Lena Salman127823f2012-02-14 17:13:53 +02005714 clk_set_rate(&usb_hsic_system_clk.c, 60000000);
Stephen Boyd092fd182011-10-21 15:56:30 -07005715 /*
5716 * Set the CSI rates to a safe default to avoid warnings when
5717 * switching csi pix and rdi clocks.
5718 */
5719 clk_set_rate(&csi0_src_clk.c, 27000000);
5720 clk_set_rate(&csi1_src_clk.c, 27000000);
5721 clk_set_rate(&csi2_src_clk.c, 27000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005722
5723 /*
Stephen Boyd60496bb2011-10-17 13:51:37 -07005724 * The halt status bits for these clocks may be incorrect at boot.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005725 * Toggle these clocks on and off to refresh them.
5726 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07005727 rcg_clk_enable(&pdm_clk.c);
5728 rcg_clk_disable(&pdm_clk.c);
5729 rcg_clk_enable(&tssc_clk.c);
5730 rcg_clk_disable(&tssc_clk.c);
Tianyi Gou3022dfd2012-01-25 15:50:05 -08005731 clk_enable(&usb_hsic_hsic_clk.c);
5732 clk_disable(&usb_hsic_hsic_clk.c);
Stephen Boydd7a143a2012-02-16 17:59:26 -08005733
5734 /*
5735 * Keep sfab floor @ 54MHz so that Krait AHB is at least 27MHz at all
5736 * times when Apps CPU is active. This ensures the timer's requirement
5737 * of Krait AHB running 4 times as fast as the timer itself.
5738 */
5739 clk_set_rate(&sfab_tmr_a_clk.c, 54000000);
5740 clk_enable(&sfab_tmr_a_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005741}
5742
Stephen Boydbb600ae2011-08-02 20:11:40 -07005743static int __init msm8960_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005744{
Stephen Boyda3787f32011-09-16 18:55:13 -07005745 int rc;
5746 struct clk *mmfpb_a_clk = clk_get_sys("clock-8960", "mmfpb_a_clk");
Stephen Boyd85436132011-09-16 18:55:13 -07005747 struct clk *cfpb_a_clk = clk_get_sys("clock-8960", "cfpb_a_clk");
Stephen Boyda3787f32011-09-16 18:55:13 -07005748
5749 /* Vote for MMFPB to be at least 76.8MHz when an Apps CPU is active. */
5750 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
5751 PTR_ERR(mmfpb_a_clk)))
5752 return PTR_ERR(mmfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08005753 rc = clk_set_rate(mmfpb_a_clk, 76800000);
Stephen Boyda3787f32011-09-16 18:55:13 -07005754 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
5755 return rc;
5756 rc = clk_enable(mmfpb_a_clk);
5757 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
5758 return rc;
5759
Stephen Boyd85436132011-09-16 18:55:13 -07005760 /* Vote for CFPB to be at least 64MHz when an Apps CPU is active. */
5761 if (WARN(IS_ERR(cfpb_a_clk), "cfpb_a_clk not found (%ld)\n",
5762 PTR_ERR(cfpb_a_clk)))
5763 return PTR_ERR(cfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08005764 rc = clk_set_rate(cfpb_a_clk, 64000000);
Stephen Boyd85436132011-09-16 18:55:13 -07005765 if (WARN(rc, "cfpb_a_clk rate was not set (%d)\n", rc))
5766 return rc;
5767 rc = clk_enable(cfpb_a_clk);
5768 if (WARN(rc, "cfpb_a_clk not enabled (%d)\n", rc))
5769 return rc;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005770
5771 return unvote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005772}
Stephen Boydbb600ae2011-08-02 20:11:40 -07005773
5774struct clock_init_data msm8960_clock_init_data __initdata = {
5775 .table = msm_clocks_8960,
5776 .size = ARRAY_SIZE(msm_clocks_8960),
5777 .init = msm8960_clock_init,
5778 .late_init = msm8960_clock_late_init,
5779};
Tianyi Gou41515e22011-09-01 19:37:43 -07005780
5781struct clock_init_data apq8064_clock_init_data __initdata = {
5782 .table = msm_clocks_8064,
5783 .size = ARRAY_SIZE(msm_clocks_8064),
5784 .init = msm8960_clock_init,
5785 .late_init = msm8960_clock_late_init,
5786};