blob: b207a72317e49dea4251520709340ca5bc5a8f0c [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/err.h>
16#include <linux/ctype.h>
17#include <linux/bitops.h>
18#include <linux/io.h>
19#include <linux/spinlock.h>
20#include <linux/delay.h>
21#include <linux/clk.h>
22
23#include <asm/clkdev.h>
24#include <asm/mach-types.h>
25
26#include <mach/msm_iomap.h>
27#include <mach/clk.h>
28#include <mach/rpm-regulator.h>
29#include <mach/msm_xo.h>
Stephen Boyd94625ef2011-07-12 17:06:01 -070030#include <mach/socinfo.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070031
32#include "clock-local.h"
33#include "clock-rpm.h"
34#include "clock-voter.h"
35#include "clock-dss-8960.h"
36#include "devices.h"
37
38#define REG(off) (MSM_CLK_CTL_BASE + (off))
39#define REG_MM(off) (MSM_MMSS_CLK_CTL_BASE + (off))
40#define REG_LPA(off) (MSM_LPASS_CLK_CTL_BASE + (off))
Matt Wagantall8b38f942011-08-02 18:23:18 -070041#define REG_GCC(off) (MSM_APCS_GCC_BASE + (off))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070042
43/* Peripheral clock registers. */
Stephen Boyda52d7e32011-11-10 11:59:00 -080044#define ADM0_PBUS_CLK_CTL_REG REG(0x2208)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070045#define CE1_HCLK_CTL_REG REG(0x2720)
46#define CE1_CORE_CLK_CTL_REG REG(0x2724)
Tianyi Gou41515e22011-09-01 19:37:43 -070047#define CE3_HCLK_CTL_REG REG(0x36C4)
48#define CE3_CORE_CLK_CTL_REG REG(0x36CC)
49#define CE3_CLK_SRC_NS_REG REG(0x36C0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050#define DMA_BAM_HCLK_CTL REG(0x25C0)
Tianyi Gou41515e22011-09-01 19:37:43 -070051#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052#define CLK_HALT_CFPB_STATEA_REG REG(0x2FCC)
53#define CLK_HALT_CFPB_STATEB_REG REG(0x2FD0)
54#define CLK_HALT_CFPB_STATEC_REG REG(0x2FD4)
55#define CLK_HALT_DFAB_STATE_REG REG(0x2FC8)
Tianyi Gou41515e22011-09-01 19:37:43 -070056/* 8064 name CLK_HALT_GSS_KPSS_MISC_STATE_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057#define CLK_HALT_MSS_SMPSS_MISC_STATE_REG REG(0x2FDC)
58#define CLK_HALT_SFPB_MISC_STATE_REG REG(0x2FD8)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070059#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060#define CLK_TEST_REG REG(0x2FA0)
Matt Wagantall7625a4c2011-11-01 16:17:53 -070061#define GPn_MD_REG(n) REG(0x2D00+(0x20*(n)))
62#define GPn_NS_REG(n) REG(0x2D24+(0x20*(n)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070063#define GSBIn_HCLK_CTL_REG(n) REG(0x29C0+(0x20*((n)-1)))
64#define GSBIn_QUP_APPS_MD_REG(n) REG(0x29C8+(0x20*((n)-1)))
65#define GSBIn_QUP_APPS_NS_REG(n) REG(0x29CC+(0x20*((n)-1)))
66#define GSBIn_RESET_REG(n) REG(0x29DC+(0x20*((n)-1)))
67#define GSBIn_UART_APPS_MD_REG(n) REG(0x29D0+(0x20*((n)-1)))
68#define GSBIn_UART_APPS_NS_REG(n) REG(0x29D4+(0x20*((n)-1)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069#define PDM_CLK_NS_REG REG(0x2CC0)
Tianyi Gou41515e22011-09-01 19:37:43 -070070/* 8064 name BB_PLL_ENA_APCS_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070071#define BB_PLL_ENA_SC0_REG REG(0x34C0)
72#define BB_PLL0_STATUS_REG REG(0x30D8)
73#define BB_PLL5_STATUS_REG REG(0x30F8)
74#define BB_PLL6_STATUS_REG REG(0x3118)
75#define BB_PLL7_STATUS_REG REG(0x3138)
76#define BB_PLL8_L_VAL_REG REG(0x3144)
77#define BB_PLL8_M_VAL_REG REG(0x3148)
78#define BB_PLL8_MODE_REG REG(0x3140)
79#define BB_PLL8_N_VAL_REG REG(0x314C)
80#define BB_PLL8_STATUS_REG REG(0x3158)
81#define BB_PLL8_CONFIG_REG REG(0x3154)
82#define BB_PLL8_TEST_CTL_REG REG(0x3150)
Stephen Boyd94625ef2011-07-12 17:06:01 -070083#define BB_MMCC_PLL2_MODE_REG REG(0x3160)
84#define BB_MMCC_PLL2_TEST_CTL_REG REG(0x3170)
Tianyi Gou41515e22011-09-01 19:37:43 -070085#define BB_PLL14_MODE_REG REG(0x31C0)
86#define BB_PLL14_L_VAL_REG REG(0x31C4)
87#define BB_PLL14_M_VAL_REG REG(0x31C8)
88#define BB_PLL14_N_VAL_REG REG(0x31CC)
89#define BB_PLL14_TEST_CTL_REG REG(0x31D0)
90#define BB_PLL14_CONFIG_REG REG(0x31D4)
Stephen Boyd94625ef2011-07-12 17:06:01 -070091#define BB_PLL14_STATUS_REG REG(0x31D8)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092#define PLLTEST_PAD_CFG_REG REG(0x2FA4)
93#define PMEM_ACLK_CTL_REG REG(0x25A0)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070094#define QDSS_AT_CLK_SRC0_NS_REG REG(0x2180)
95#define QDSS_AT_CLK_SRC1_NS_REG REG(0x2184)
96#define QDSS_AT_CLK_SRC_CTL_REG REG(0x2188)
97#define QDSS_AT_CLK_NS_REG REG(0x218C)
98#define QDSS_HCLK_CTL_REG REG(0x22A0)
99#define QDSS_RESETS_REG REG(0x2260)
100#define QDSS_STM_CLK_CTL_REG REG(0x2060)
101#define QDSS_TRACECLKIN_CLK_SRC0_NS_REG REG(0x21A0)
102#define QDSS_TRACECLKIN_CLK_SRC1_NS_REG REG(0x21A4)
103#define QDSS_TRACECLKIN_CLK_SRC_CTL_REG REG(0x21A8)
104#define QDSS_TRACECLKIN_CTL_REG REG(0x21AC)
105#define QDSS_TSCTR_CLK_SRC0_NS_REG REG(0x21C0)
106#define QDSS_TSCTR_CLK_SRC1_NS_REG REG(0x21C4)
107#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
108#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
109#define QDSS_TSCTR_CTL_REG REG(0x21CC)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700110#define RINGOSC_NS_REG REG(0x2DC0)
111#define RINGOSC_STATUS_REG REG(0x2DCC)
112#define RINGOSC_TCXO_CTL_REG REG(0x2DC4)
Stephen Boyda52d7e32011-11-10 11:59:00 -0800113#define RPM_MSG_RAM_HCLK_CTL_REG REG(0x27E0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700114#define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080)
115#define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1)))
116#define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1)))
117#define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1)))
118#define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1)))
119#define SLIMBUS_XO_SRC_CLK_CTL_REG REG(0x2628)
120#define TSIF_HCLK_CTL_REG REG(0x2700)
121#define TSIF_REF_CLK_MD_REG REG(0x270C)
122#define TSIF_REF_CLK_NS_REG REG(0x2710)
123#define TSSC_CLK_CTL_REG REG(0x2CA0)
Tianyi Gou41515e22011-09-01 19:37:43 -0700124#define SATA_CLK_SRC_NS_REG REG(0x2C08)
125#define SATA_RXOOB_CLK_CTL_REG REG(0x2C0C)
126#define SATA_PMALIVE_CLK_CTL_REG REG(0x2C10)
127#define SATA_PHY_REF_CLK_CTL_REG REG(0x2C14)
128#define SATA_PHY_CFG_CLK_CTL_REG REG(0x2C40)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700129#define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1)))
130#define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1)))
131#define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1)))
132#define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1)))
133#define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1)))
134#define USB_HS1_HCLK_CTL_REG REG(0x2900)
Tianyi Gou41515e22011-09-01 19:37:43 -0700135#define USB_HS1_HCLK_FS_REG REG(0x2904)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700136#define USB_HS1_RESET_REG REG(0x2910)
137#define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908)
138#define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700139#define USB_HS3_HCLK_CTL_REG REG(0x3700)
140#define USB_HS3_HCLK_FS_REG REG(0x3704)
141#define USB_HS3_RESET_REG REG(0x3710)
142#define USB_HS3_XCVR_FS_CLK_MD_REG REG(0X3708)
143#define USB_HS3_XCVR_FS_CLK_NS_REG REG(0X370C)
144#define USB_HS4_HCLK_CTL_REG REG(0x3720)
145#define USB_HS4_HCLK_FS_REG REG(0x3724)
146#define USB_HS4_RESET_REG REG(0x3730)
147#define USB_HS4_XCVR_FS_CLK_MD_REG REG(0X3728)
148#define USB_HS4_XCVR_FS_CLK_NS_REG REG(0X372C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700149#define USB_HSIC_HCLK_CTL_REG REG(0x2920)
150#define USB_HSIC_HSIC_CLK_CTL_REG REG(0x2B44)
151#define USB_HSIC_HSIC_CLK_SRC_CTL_REG REG(0x2B40)
152#define USB_HSIC_HSIO_CAL_CLK_CTL_REG REG(0x2B48)
153#define USB_HSIC_RESET_REG REG(0x2934)
154#define USB_HSIC_SYSTEM_CLK_CTL_REG REG(0x292C)
155#define USB_HSIC_XCVR_FS_CLK_MD_REG REG(0x2924)
156#define USB_HSIC_XCVR_FS_CLK_NS_REG REG(0x2928)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700157#define USB_PHY0_RESET_REG REG(0x2E20)
Tianyi Gou41515e22011-09-01 19:37:43 -0700158#define PCIE_ALT_REF_CLK_NS_REG REG(0x3860)
159#define PCIE_HCLK_CTL_REG REG(0x22CC)
160#define GPLL1_MODE_REG REG(0x3160)
161#define GPLL1_L_VAL_REG REG(0x3164)
162#define GPLL1_M_VAL_REG REG(0x3168)
163#define GPLL1_N_VAL_REG REG(0x316C)
164#define GPLL1_CONFIG_REG REG(0x3174)
165#define GPLL1_STATUS_REG REG(0x3178)
166#define PXO_SRC_CLK_CTL_REG REG(0x2EA0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700167
168/* Multimedia clock registers. */
169#define AHB_EN_REG REG_MM(0x0008)
170#define AHB_EN2_REG REG_MM(0x0038)
Tianyi Gou41515e22011-09-01 19:37:43 -0700171#define AHB_EN3_REG REG_MM(0x0248)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700172#define AHB_NS_REG REG_MM(0x0004)
173#define AXI_NS_REG REG_MM(0x0014)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700174#define CAMCLK0_NS_REG REG_MM(0x0148)
175#define CAMCLK0_CC_REG REG_MM(0x0140)
176#define CAMCLK0_MD_REG REG_MM(0x0144)
177#define CAMCLK1_NS_REG REG_MM(0x015C)
178#define CAMCLK1_CC_REG REG_MM(0x0154)
179#define CAMCLK1_MD_REG REG_MM(0x0158)
180#define CAMCLK2_NS_REG REG_MM(0x0228)
181#define CAMCLK2_CC_REG REG_MM(0x0220)
182#define CAMCLK2_MD_REG REG_MM(0x0224)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700183#define CSI0_NS_REG REG_MM(0x0048)
184#define CSI0_CC_REG REG_MM(0x0040)
185#define CSI0_MD_REG REG_MM(0x0044)
186#define CSI1_NS_REG REG_MM(0x0010)
187#define CSI1_CC_REG REG_MM(0x0024)
188#define CSI1_MD_REG REG_MM(0x0028)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700189#define CSI2_NS_REG REG_MM(0x0234)
190#define CSI2_CC_REG REG_MM(0x022C)
191#define CSI2_MD_REG REG_MM(0x0230)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700192#define CSIPHYTIMER_CC_REG REG_MM(0x0160)
193#define CSIPHYTIMER_MD_REG REG_MM(0x0164)
194#define CSIPHYTIMER_NS_REG REG_MM(0x0168)
195#define DSI1_BYTE_NS_REG REG_MM(0x00B0)
196#define DSI1_BYTE_CC_REG REG_MM(0x0090)
197#define DSI2_BYTE_NS_REG REG_MM(0x00BC)
198#define DSI2_BYTE_CC_REG REG_MM(0x00B4)
199#define DSI1_ESC_NS_REG REG_MM(0x011C)
200#define DSI1_ESC_CC_REG REG_MM(0x00CC)
201#define DSI2_ESC_NS_REG REG_MM(0x0150)
202#define DSI2_ESC_CC_REG REG_MM(0x013C)
203#define DSI_PIXEL_CC_REG REG_MM(0x0130)
204#define DSI2_PIXEL_CC_REG REG_MM(0x0094)
205#define DBG_BUS_VEC_A_REG REG_MM(0x01C8)
206#define DBG_BUS_VEC_B_REG REG_MM(0x01CC)
207#define DBG_BUS_VEC_C_REG REG_MM(0x01D0)
208#define DBG_BUS_VEC_D_REG REG_MM(0x01D4)
209#define DBG_BUS_VEC_E_REG REG_MM(0x01D8)
210#define DBG_BUS_VEC_F_REG REG_MM(0x01DC)
211#define DBG_BUS_VEC_G_REG REG_MM(0x01E0)
212#define DBG_BUS_VEC_H_REG REG_MM(0x01E4)
213#define DBG_BUS_VEC_I_REG REG_MM(0x01E8)
Tianyi Gou41515e22011-09-01 19:37:43 -0700214#define DBG_BUS_VEC_J_REG REG_MM(0x0240)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700215#define DBG_CFG_REG_HS_REG REG_MM(0x01B4)
216#define DBG_CFG_REG_LS_REG REG_MM(0x01B8)
217#define GFX2D0_CC_REG REG_MM(0x0060)
218#define GFX2D0_MD0_REG REG_MM(0x0064)
219#define GFX2D0_MD1_REG REG_MM(0x0068)
220#define GFX2D0_NS_REG REG_MM(0x0070)
221#define GFX2D1_CC_REG REG_MM(0x0074)
222#define GFX2D1_MD0_REG REG_MM(0x0078)
223#define GFX2D1_MD1_REG REG_MM(0x006C)
224#define GFX2D1_NS_REG REG_MM(0x007C)
225#define GFX3D_CC_REG REG_MM(0x0080)
226#define GFX3D_MD0_REG REG_MM(0x0084)
227#define GFX3D_MD1_REG REG_MM(0x0088)
228#define GFX3D_NS_REG REG_MM(0x008C)
229#define IJPEG_CC_REG REG_MM(0x0098)
230#define IJPEG_MD_REG REG_MM(0x009C)
231#define IJPEG_NS_REG REG_MM(0x00A0)
232#define JPEGD_CC_REG REG_MM(0x00A4)
233#define JPEGD_NS_REG REG_MM(0x00AC)
Tianyi Gou41515e22011-09-01 19:37:43 -0700234#define VCAP_CC_REG REG_MM(0x0178)
235#define VCAP_NS_REG REG_MM(0x021C)
236#define VCAP_MD0_REG REG_MM(0x01EC)
237#define VCAP_MD1_REG REG_MM(0x0218)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700238#define MAXI_EN_REG REG_MM(0x0018)
239#define MAXI_EN2_REG REG_MM(0x0020)
240#define MAXI_EN3_REG REG_MM(0x002C)
241#define MAXI_EN4_REG REG_MM(0x0114)
Tianyi Gou41515e22011-09-01 19:37:43 -0700242#define MAXI_EN5_REG REG_MM(0x0244)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700243#define MDP_CC_REG REG_MM(0x00C0)
244#define MDP_LUT_CC_REG REG_MM(0x016C)
245#define MDP_MD0_REG REG_MM(0x00C4)
246#define MDP_MD1_REG REG_MM(0x00C8)
247#define MDP_NS_REG REG_MM(0x00D0)
248#define MISC_CC_REG REG_MM(0x0058)
249#define MISC_CC2_REG REG_MM(0x005C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700250#define MISC_CC3_REG REG_MM(0x0238)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700251#define MM_PLL1_MODE_REG REG_MM(0x031C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700252#define MM_PLL1_L_VAL_REG REG_MM(0x0320)
253#define MM_PLL1_M_VAL_REG REG_MM(0x0324)
254#define MM_PLL1_N_VAL_REG REG_MM(0x0328)
255#define MM_PLL1_CONFIG_REG REG_MM(0x032C)
256#define MM_PLL1_TEST_CTL_REG REG_MM(0x0330)
257#define MM_PLL1_STATUS_REG REG_MM(0x0334)
258#define MM_PLL3_MODE_REG REG_MM(0x0338)
Tianyi Gou621f8742011-09-01 21:45:01 -0700259#define MM_PLL3_L_VAL_REG REG_MM(0x033C)
260#define MM_PLL3_M_VAL_REG REG_MM(0x0340)
261#define MM_PLL3_N_VAL_REG REG_MM(0x0344)
262#define MM_PLL3_CONFIG_REG REG_MM(0x0348)
263#define MM_PLL3_TEST_CTL_REG REG_MM(0x034C)
264#define MM_PLL3_STATUS_REG REG_MM(0x0350)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700265#define ROT_CC_REG REG_MM(0x00E0)
266#define ROT_NS_REG REG_MM(0x00E8)
267#define SAXI_EN_REG REG_MM(0x0030)
268#define SW_RESET_AHB_REG REG_MM(0x020C)
269#define SW_RESET_AHB2_REG REG_MM(0x0200)
270#define SW_RESET_ALL_REG REG_MM(0x0204)
271#define SW_RESET_AXI_REG REG_MM(0x0208)
272#define SW_RESET_CORE_REG REG_MM(0x0210)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700273#define SW_RESET_CORE2_REG REG_MM(0x0214)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700274#define TV_CC_REG REG_MM(0x00EC)
275#define TV_CC2_REG REG_MM(0x0124)
276#define TV_MD_REG REG_MM(0x00F0)
277#define TV_NS_REG REG_MM(0x00F4)
278#define VCODEC_CC_REG REG_MM(0x00F8)
279#define VCODEC_MD0_REG REG_MM(0x00FC)
280#define VCODEC_MD1_REG REG_MM(0x0128)
281#define VCODEC_NS_REG REG_MM(0x0100)
282#define VFE_CC_REG REG_MM(0x0104)
283#define VFE_MD_REG REG_MM(0x0108)
284#define VFE_NS_REG REG_MM(0x010C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700285#define VFE_CC2_REG REG_MM(0x023C)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700286#define VPE_CC_REG REG_MM(0x0110)
287#define VPE_NS_REG REG_MM(0x0118)
288
289/* Low-power Audio clock registers. */
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700290#define LCC_CLK_HS_DEBUG_CFG_REG REG_LPA(0x00A4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700291#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
292#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
293#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
294#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
295#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
296#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
297#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
298#define LCC_MI2S_MD_REG REG_LPA(0x004C)
299#define LCC_MI2S_NS_REG REG_LPA(0x0048)
300#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
301#define LCC_PCM_MD_REG REG_LPA(0x0058)
302#define LCC_PCM_NS_REG REG_LPA(0x0054)
303#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700304#define LCC_PLL0_MODE_REG REG_LPA(0x0000)
305#define LCC_PLL0_L_VAL_REG REG_LPA(0x0004)
306#define LCC_PLL0_M_VAL_REG REG_LPA(0x0008)
307#define LCC_PLL0_N_VAL_REG REG_LPA(0x000C)
308#define LCC_PLL0_CONFIG_REG REG_LPA(0x0014)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700309#define LCC_PLL0_STATUS_REG REG_LPA(0x0018)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700310#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
311#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
312#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
313#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
314#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
315#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
316#define LCC_SLIMBUS_NS_REG REG_LPA(0x00CC)
317#define LCC_SLIMBUS_MD_REG REG_LPA(0x00D0)
318#define LCC_SLIMBUS_STATUS_REG REG_LPA(0x00D4)
319#define LCC_AHBEX_BRANCH_CTL_REG REG_LPA(0x00E4)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700320#define LCC_PRI_PLL_CLK_CTL_REG REG_LPA(0x00C4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700321
Matt Wagantall8b38f942011-08-02 18:23:18 -0700322#define GCC_APCS_CLK_DIAG REG_GCC(0x001C)
323
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700324/* MUX source input identifiers. */
325#define pxo_to_bb_mux 0
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700326#define cxo_to_bb_mux 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700327#define pll0_to_bb_mux 2
328#define pll8_to_bb_mux 3
329#define pll6_to_bb_mux 4
330#define gnd_to_bb_mux 5
Stephen Boyd94625ef2011-07-12 17:06:01 -0700331#define pll3_to_bb_mux 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332#define pxo_to_mm_mux 0
333#define pll1_to_mm_mux 1
Tianyi Gou41515e22011-09-01 19:37:43 -0700334#define pll2_to_mm_mux 1 /* or MMCC_PLL1 */
335#define pll8_to_mm_mux 2 /* or GCC_PERF */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700336#define pll0_to_mm_mux 3
Tianyi Gou41515e22011-09-01 19:37:43 -0700337#define pll15_to_mm_mux 3 /* or MM_PLL3 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700338#define gnd_to_mm_mux 4
Stephen Boyd7a776cd2011-10-20 12:46:04 -0700339#define pll3_to_mm_mux 3 /* or MMCC_PLL2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700340#define hdmi_pll_to_mm_mux 3
341#define cxo_to_xo_mux 0
342#define pxo_to_xo_mux 1
343#define gnd_to_xo_mux 3
344#define pxo_to_lpa_mux 0
345#define cxo_to_lpa_mux 1
346#define pll4_to_lpa_mux 2
347#define gnd_to_lpa_mux 6
Tianyi Gou41515e22011-09-01 19:37:43 -0700348#define pxo_to_pcie_mux 0
349#define pll3_to_pcie_mux 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700350
351/* Test Vector Macros */
352#define TEST_TYPE_PER_LS 1
353#define TEST_TYPE_PER_HS 2
354#define TEST_TYPE_MM_LS 3
355#define TEST_TYPE_MM_HS 4
356#define TEST_TYPE_LPA 5
Matt Wagantall8b38f942011-08-02 18:23:18 -0700357#define TEST_TYPE_CPUL2 6
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700358#define TEST_TYPE_LPA_HS 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700359#define TEST_TYPE_SHIFT 24
360#define TEST_CLK_SEL_MASK BM(23, 0)
361#define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s)))
362#define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS)
363#define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS)
364#define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS)
365#define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS)
366#define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA)
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700367#define TEST_LPA_HS(s) TEST_VECTOR((s), TEST_TYPE_LPA_HS)
Matt Wagantall8b38f942011-08-02 18:23:18 -0700368#define TEST_CPUL2(s) TEST_VECTOR((s), TEST_TYPE_CPUL2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700369
370#define MN_MODE_DUAL_EDGE 0x2
371
372/* MD Registers */
373#define MD4(m_lsb, m, n_lsb, n) \
374 (BVAL((m_lsb+3), m_lsb, m) | BVAL((n_lsb+3), n_lsb, ~(n)))
375#define MD8(m_lsb, m, n_lsb, n) \
376 (BVAL((m_lsb+7), m_lsb, m) | BVAL((n_lsb+7), n_lsb, ~(n)))
377#define MD16(m, n) (BVAL(31, 16, m) | BVAL(15, 0, ~(n)))
378
379/* NS Registers */
380#define NS(n_msb, n_lsb, n, m, mde_lsb, d_msb, d_lsb, d, s_msb, s_lsb, s) \
381 (BVAL(n_msb, n_lsb, ~(n-m)) \
382 | (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n)) \
383 | BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
384
385#define NS_MM(n_msb, n_lsb, n, m, d_msb, d_lsb, d, s_msb, s_lsb, s) \
386 (BVAL(n_msb, n_lsb, ~(n-m)) | BVAL(d_msb, d_lsb, (d-1)) \
387 | BVAL(s_msb, s_lsb, s))
388
389#define NS_DIVSRC(d_msb , d_lsb, d, s_msb, s_lsb, s) \
390 (BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
391
392#define NS_DIV(d_msb , d_lsb, d) \
393 BVAL(d_msb, d_lsb, (d-1))
394
395#define NS_SRC_SEL(s_msb, s_lsb, s) \
396 BVAL(s_msb, s_lsb, s)
397
398#define NS_MND_BANKED4(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
399 (BVAL((n0_lsb+3), n0_lsb, ~(n-m)) \
400 | BVAL((n1_lsb+3), n1_lsb, ~(n-m)) \
401 | BVAL((s0_lsb+2), s0_lsb, s) \
402 | BVAL((s1_lsb+2), s1_lsb, s))
403
404#define NS_MND_BANKED8(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
405 (BVAL((n0_lsb+7), n0_lsb, ~(n-m)) \
406 | BVAL((n1_lsb+7), n1_lsb, ~(n-m)) \
407 | BVAL((s0_lsb+2), s0_lsb, s) \
408 | BVAL((s1_lsb+2), s1_lsb, s))
409
410#define NS_DIVSRC_BANKED(d0_msb, d0_lsb, d1_msb, d1_lsb, d, \
411 s0_msb, s0_lsb, s1_msb, s1_lsb, s) \
412 (BVAL(d0_msb, d0_lsb, (d-1)) | BVAL(d1_msb, d1_lsb, (d-1)) \
413 | BVAL(s0_msb, s0_lsb, s) \
414 | BVAL(s1_msb, s1_lsb, s))
415
416/* CC Registers */
417#define CC(mde_lsb, n) (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n))
418#define CC_BANKED(mde0_lsb, mde1_lsb, n) \
419 ((BVAL((mde0_lsb+1), mde0_lsb, MN_MODE_DUAL_EDGE) \
420 | BVAL((mde1_lsb+1), mde1_lsb, MN_MODE_DUAL_EDGE)) \
421 * !!(n))
422
423struct pll_rate {
424 const uint32_t l_val;
425 const uint32_t m_val;
426 const uint32_t n_val;
427 const uint32_t vco;
428 const uint32_t post_div;
429 const uint32_t i_bits;
430};
431#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
432
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700433enum vdd_dig_levels {
434 VDD_DIG_NONE,
435 VDD_DIG_LOW,
436 VDD_DIG_NOMINAL,
437 VDD_DIG_HIGH
438};
439
440static int set_vdd_dig(struct clk_vdd_class *vdd_class, int level)
441{
442 static const int vdd_uv[] = {
443 [VDD_DIG_NONE] = 0,
444 [VDD_DIG_LOW] = 945000,
445 [VDD_DIG_NOMINAL] = 1050000,
446 [VDD_DIG_HIGH] = 1150000
447 };
448
449 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
450 vdd_uv[level], 1150000, 1);
451}
452
453static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig);
454
455#define VDD_DIG_FMAX_MAP1(l1, f1) \
456 .vdd_class = &vdd_dig, \
457 .fmax[VDD_DIG_##l1] = (f1)
458#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
459 .vdd_class = &vdd_dig, \
460 .fmax[VDD_DIG_##l1] = (f1), \
461 .fmax[VDD_DIG_##l2] = (f2)
462#define VDD_DIG_FMAX_MAP3(l1, f1, l2, f2, l3, f3) \
463 .vdd_class = &vdd_dig, \
464 .fmax[VDD_DIG_##l1] = (f1), \
465 .fmax[VDD_DIG_##l2] = (f2), \
466 .fmax[VDD_DIG_##l3] = (f3)
467
Matt Wagantallc57577d2011-10-06 17:06:53 -0700468enum vdd_l23_levels {
469 VDD_L23_OFF,
470 VDD_L23_ON
471};
472
473static int set_vdd_l23(struct clk_vdd_class *vdd_class, int level)
474{
475 int rc;
476
477 if (level == VDD_L23_OFF) {
478 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
479 RPM_VREG_VOTER3, 0, 0, 1);
480 if (rc)
481 return rc;
482 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
483 RPM_VREG_VOTER3, 0, 0, 1);
484 if (rc)
485 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
486 RPM_VREG_VOTER3, 1800000, 1800000, 1);
487 } else {
488 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
489 RPM_VREG_VOTER3, 2200000, 2200000, 1);
490 if (rc)
491 return rc;
492 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
493 RPM_VREG_VOTER3, 1800000, 1800000, 1);
494 if (rc)
495 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
496 RPM_VREG_VOTER3, 0, 0, 1);
497 }
498
499 return rc;
500}
501
502static DEFINE_VDD_CLASS(vdd_l23, set_vdd_l23);
503
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700504/*
505 * Clock Descriptions
506 */
507
508static struct msm_xo_voter *xo_pxo, *xo_cxo;
509
510static int pxo_clk_enable(struct clk *clk)
511{
512 return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON);
513}
514
515static void pxo_clk_disable(struct clk *clk)
516{
Tianyi Gou41515e22011-09-01 19:37:43 -0700517 msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700518}
519
520static struct clk_ops clk_ops_pxo = {
521 .enable = pxo_clk_enable,
522 .disable = pxo_clk_disable,
523 .get_rate = fixed_clk_get_rate,
524 .is_local = local_clk_is_local,
525};
526
527static struct fixed_clk pxo_clk = {
528 .rate = 27000000,
529 .c = {
530 .dbg_name = "pxo_clk",
531 .ops = &clk_ops_pxo,
532 CLK_INIT(pxo_clk.c),
533 },
534};
535
536static int cxo_clk_enable(struct clk *clk)
537{
538 return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON);
539}
540
541static void cxo_clk_disable(struct clk *clk)
542{
543 msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF);
544}
545
546static struct clk_ops clk_ops_cxo = {
547 .enable = cxo_clk_enable,
548 .disable = cxo_clk_disable,
549 .get_rate = fixed_clk_get_rate,
550 .is_local = local_clk_is_local,
551};
552
553static struct fixed_clk cxo_clk = {
554 .rate = 19200000,
555 .c = {
556 .dbg_name = "cxo_clk",
557 .ops = &clk_ops_cxo,
558 CLK_INIT(cxo_clk.c),
559 },
560};
561
562static struct pll_clk pll2_clk = {
563 .rate = 800000000,
564 .mode_reg = MM_PLL1_MODE_REG,
565 .parent = &pxo_clk.c,
566 .c = {
567 .dbg_name = "pll2_clk",
568 .ops = &clk_ops_pll,
569 CLK_INIT(pll2_clk.c),
570 },
571};
572
Stephen Boyd94625ef2011-07-12 17:06:01 -0700573static struct pll_clk pll3_clk = {
574 .rate = 1200000000,
575 .mode_reg = BB_MMCC_PLL2_MODE_REG,
576 .parent = &pxo_clk.c,
577 .c = {
578 .dbg_name = "pll3_clk",
579 .ops = &clk_ops_pll,
Matt Wagantallc57577d2011-10-06 17:06:53 -0700580 .vdd_class = &vdd_l23,
581 .fmax[VDD_L23_ON] = ULONG_MAX,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700582 CLK_INIT(pll3_clk.c),
583 },
584};
585
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700586static struct pll_vote_clk pll4_clk = {
587 .rate = 393216000,
588 .en_reg = BB_PLL_ENA_SC0_REG,
589 .en_mask = BIT(4),
590 .status_reg = LCC_PLL0_STATUS_REG,
591 .parent = &pxo_clk.c,
592 .c = {
593 .dbg_name = "pll4_clk",
594 .ops = &clk_ops_pll_vote,
595 CLK_INIT(pll4_clk.c),
596 },
597};
598
599static struct pll_vote_clk pll8_clk = {
600 .rate = 384000000,
601 .en_reg = BB_PLL_ENA_SC0_REG,
602 .en_mask = BIT(8),
603 .status_reg = BB_PLL8_STATUS_REG,
604 .parent = &pxo_clk.c,
605 .c = {
606 .dbg_name = "pll8_clk",
607 .ops = &clk_ops_pll_vote,
608 CLK_INIT(pll8_clk.c),
609 },
610};
611
Stephen Boyd94625ef2011-07-12 17:06:01 -0700612static struct pll_vote_clk pll14_clk = {
613 .rate = 480000000,
614 .en_reg = BB_PLL_ENA_SC0_REG,
615 .en_mask = BIT(14),
616 .status_reg = BB_PLL14_STATUS_REG,
617 .parent = &pxo_clk.c,
618 .c = {
619 .dbg_name = "pll14_clk",
620 .ops = &clk_ops_pll_vote,
621 CLK_INIT(pll14_clk.c),
622 },
623};
624
Tianyi Gou41515e22011-09-01 19:37:43 -0700625static struct pll_clk pll15_clk = {
626 .rate = 975000000,
627 .mode_reg = MM_PLL3_MODE_REG,
628 .parent = &pxo_clk.c,
629 .c = {
630 .dbg_name = "pll15_clk",
631 .ops = &clk_ops_pll,
632 CLK_INIT(pll15_clk.c),
633 },
634};
635
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700636static struct clk_ops clk_ops_rcg_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700637 .enable = rcg_clk_enable,
638 .disable = rcg_clk_disable,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800639 .enable_hwcg = rcg_clk_enable_hwcg,
640 .disable_hwcg = rcg_clk_disable_hwcg,
641 .in_hwcg_mode = rcg_clk_in_hwcg_mode,
Matt Wagantall41af0772011-09-17 12:21:39 -0700642 .auto_off = rcg_clk_disable,
Matt Wagantall53d968f2011-07-19 13:22:53 -0700643 .handoff = rcg_clk_handoff,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700644 .set_rate = rcg_clk_set_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700645 .get_rate = rcg_clk_get_rate,
646 .list_rate = rcg_clk_list_rate,
647 .is_enabled = rcg_clk_is_enabled,
648 .round_rate = rcg_clk_round_rate,
Stephen Boyd7bf28142011-12-07 00:30:52 -0800649 .reset = rcg_clk_reset,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700650 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700651 .get_parent = rcg_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700652};
653
654static struct clk_ops clk_ops_branch = {
655 .enable = branch_clk_enable,
656 .disable = branch_clk_disable,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800657 .enable_hwcg = branch_clk_enable_hwcg,
658 .disable_hwcg = branch_clk_disable_hwcg,
659 .in_hwcg_mode = branch_clk_in_hwcg_mode,
Matt Wagantall41af0772011-09-17 12:21:39 -0700660 .auto_off = branch_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700661 .is_enabled = branch_clk_is_enabled,
662 .reset = branch_clk_reset,
663 .is_local = local_clk_is_local,
664 .get_parent = branch_clk_get_parent,
665 .set_parent = branch_clk_set_parent,
Stephen Boyda52d7e32011-11-10 11:59:00 -0800666 .handoff = branch_clk_handoff,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700667};
668
669static struct clk_ops clk_ops_reset = {
670 .reset = branch_clk_reset,
671 .is_local = local_clk_is_local,
672};
673
674/* AXI Interfaces */
675static struct branch_clk gmem_axi_clk = {
676 .b = {
677 .ctl_reg = MAXI_EN_REG,
678 .en_mask = BIT(24),
679 .halt_reg = DBG_BUS_VEC_E_REG,
680 .halt_bit = 6,
681 },
682 .c = {
683 .dbg_name = "gmem_axi_clk",
684 .ops = &clk_ops_branch,
685 CLK_INIT(gmem_axi_clk.c),
686 },
687};
688
689static struct branch_clk ijpeg_axi_clk = {
690 .b = {
691 .ctl_reg = MAXI_EN_REG,
692 .en_mask = BIT(21),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800693 .hwcg_reg = MAXI_EN_REG,
694 .hwcg_mask = BIT(11),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700695 .reset_reg = SW_RESET_AXI_REG,
696 .reset_mask = BIT(14),
697 .halt_reg = DBG_BUS_VEC_E_REG,
698 .halt_bit = 4,
699 },
700 .c = {
701 .dbg_name = "ijpeg_axi_clk",
702 .ops = &clk_ops_branch,
703 CLK_INIT(ijpeg_axi_clk.c),
704 },
705};
706
707static struct branch_clk imem_axi_clk = {
708 .b = {
709 .ctl_reg = MAXI_EN_REG,
710 .en_mask = BIT(22),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800711 .hwcg_reg = MAXI_EN_REG,
712 .hwcg_mask = BIT(15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700713 .reset_reg = SW_RESET_CORE_REG,
714 .reset_mask = BIT(10),
715 .halt_reg = DBG_BUS_VEC_E_REG,
716 .halt_bit = 7,
717 },
718 .c = {
719 .dbg_name = "imem_axi_clk",
720 .ops = &clk_ops_branch,
721 CLK_INIT(imem_axi_clk.c),
722 },
723};
724
725static struct branch_clk jpegd_axi_clk = {
726 .b = {
727 .ctl_reg = MAXI_EN_REG,
728 .en_mask = BIT(25),
729 .halt_reg = DBG_BUS_VEC_E_REG,
730 .halt_bit = 5,
731 },
732 .c = {
733 .dbg_name = "jpegd_axi_clk",
734 .ops = &clk_ops_branch,
735 CLK_INIT(jpegd_axi_clk.c),
736 },
737};
738
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700739static struct branch_clk vcodec_axi_b_clk = {
740 .b = {
741 .ctl_reg = MAXI_EN4_REG,
742 .en_mask = BIT(23),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800743 .hwcg_reg = MAXI_EN4_REG,
744 .hwcg_mask = BIT(22),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700745 .halt_reg = DBG_BUS_VEC_I_REG,
746 .halt_bit = 25,
747 },
748 .c = {
749 .dbg_name = "vcodec_axi_b_clk",
750 .ops = &clk_ops_branch,
751 CLK_INIT(vcodec_axi_b_clk.c),
752 },
753};
754
Matt Wagantall91f42702011-07-14 12:01:15 -0700755static struct branch_clk vcodec_axi_a_clk = {
756 .b = {
757 .ctl_reg = MAXI_EN4_REG,
758 .en_mask = BIT(25),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800759 .hwcg_reg = MAXI_EN4_REG,
760 .hwcg_mask = BIT(24),
Matt Wagantall91f42702011-07-14 12:01:15 -0700761 .halt_reg = DBG_BUS_VEC_I_REG,
762 .halt_bit = 26,
763 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700764 .c = {
765 .dbg_name = "vcodec_axi_a_clk",
766 .ops = &clk_ops_branch,
767 CLK_INIT(vcodec_axi_a_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700768 .depends = &vcodec_axi_b_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700769 },
770};
771
772static struct branch_clk vcodec_axi_clk = {
773 .b = {
774 .ctl_reg = MAXI_EN_REG,
775 .en_mask = BIT(19),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800776 .hwcg_reg = MAXI_EN_REG,
777 .hwcg_mask = BIT(13),
Matt Wagantall91f42702011-07-14 12:01:15 -0700778 .reset_reg = SW_RESET_AXI_REG,
Matt Wagantallfe2ee052011-07-14 13:33:44 -0700779 .reset_mask = BIT(4)|BIT(5)|BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700780 .halt_reg = DBG_BUS_VEC_E_REG,
781 .halt_bit = 3,
782 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700783 .c = {
784 .dbg_name = "vcodec_axi_clk",
785 .ops = &clk_ops_branch,
786 CLK_INIT(vcodec_axi_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700787 .depends = &vcodec_axi_a_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700788 },
789};
790
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700791static struct branch_clk vfe_axi_clk = {
792 .b = {
793 .ctl_reg = MAXI_EN_REG,
794 .en_mask = BIT(18),
795 .reset_reg = SW_RESET_AXI_REG,
796 .reset_mask = BIT(9),
797 .halt_reg = DBG_BUS_VEC_E_REG,
798 .halt_bit = 0,
799 },
800 .c = {
801 .dbg_name = "vfe_axi_clk",
802 .ops = &clk_ops_branch,
803 CLK_INIT(vfe_axi_clk.c),
804 },
805};
806
807static struct branch_clk mdp_axi_clk = {
808 .b = {
809 .ctl_reg = MAXI_EN_REG,
810 .en_mask = BIT(23),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800811 .hwcg_reg = MAXI_EN_REG,
812 .hwcg_mask = BIT(16),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700813 .reset_reg = SW_RESET_AXI_REG,
814 .reset_mask = BIT(13),
815 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700816 .halt_bit = 8,
817 },
818 .c = {
819 .dbg_name = "mdp_axi_clk",
820 .ops = &clk_ops_branch,
821 CLK_INIT(mdp_axi_clk.c),
822 },
823};
824
825static struct branch_clk rot_axi_clk = {
826 .b = {
827 .ctl_reg = MAXI_EN2_REG,
828 .en_mask = BIT(24),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800829 .hwcg_reg = MAXI_EN2_REG,
830 .hwcg_mask = BIT(25),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700831 .reset_reg = SW_RESET_AXI_REG,
832 .reset_mask = BIT(6),
833 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700834 .halt_bit = 2,
835 },
836 .c = {
837 .dbg_name = "rot_axi_clk",
838 .ops = &clk_ops_branch,
839 CLK_INIT(rot_axi_clk.c),
840 },
841};
842
843static struct branch_clk vpe_axi_clk = {
844 .b = {
845 .ctl_reg = MAXI_EN2_REG,
846 .en_mask = BIT(26),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800847 .hwcg_reg = MAXI_EN2_REG,
848 .hwcg_mask = BIT(27),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700849 .reset_reg = SW_RESET_AXI_REG,
850 .reset_mask = BIT(15),
851 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700852 .halt_bit = 1,
853 },
854 .c = {
855 .dbg_name = "vpe_axi_clk",
856 .ops = &clk_ops_branch,
857 CLK_INIT(vpe_axi_clk.c),
858 },
859};
860
Tianyi Gou41515e22011-09-01 19:37:43 -0700861static struct branch_clk vcap_axi_clk = {
862 .b = {
863 .ctl_reg = MAXI_EN5_REG,
864 .en_mask = BIT(12),
865 .reset_reg = SW_RESET_AXI_REG,
866 .reset_mask = BIT(16),
867 .halt_reg = DBG_BUS_VEC_J_REG,
868 .halt_bit = 20,
869 },
870 .c = {
871 .dbg_name = "vcap_axi_clk",
872 .ops = &clk_ops_branch,
873 CLK_INIT(vcap_axi_clk.c),
874 },
875};
876
Tianyi Gou621f8742011-09-01 21:45:01 -0700877/* For 8064, gfx3d_axi_clk is set as a dependency of gmem_axi_clk at runtime */
878static struct branch_clk gfx3d_axi_clk = {
879 .b = {
880 .ctl_reg = MAXI_EN5_REG,
881 .en_mask = BIT(25),
882 .reset_reg = SW_RESET_AXI_REG,
883 .reset_mask = BIT(17),
884 .halt_reg = DBG_BUS_VEC_J_REG,
885 .halt_bit = 30,
886 },
887 .c = {
888 .dbg_name = "gfx3d_axi_clk",
889 .ops = &clk_ops_branch,
890 CLK_INIT(gfx3d_axi_clk.c),
891 },
892};
893
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700894/* AHB Interfaces */
895static struct branch_clk amp_p_clk = {
896 .b = {
897 .ctl_reg = AHB_EN_REG,
898 .en_mask = BIT(24),
899 .halt_reg = DBG_BUS_VEC_F_REG,
900 .halt_bit = 18,
901 },
902 .c = {
903 .dbg_name = "amp_p_clk",
904 .ops = &clk_ops_branch,
905 CLK_INIT(amp_p_clk.c),
906 },
907};
908
Matt Wagantallc23eee92011-08-16 23:06:52 -0700909static struct branch_clk csi_p_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700910 .b = {
911 .ctl_reg = AHB_EN_REG,
912 .en_mask = BIT(7),
913 .reset_reg = SW_RESET_AHB_REG,
914 .reset_mask = BIT(17),
915 .halt_reg = DBG_BUS_VEC_F_REG,
916 .halt_bit = 16,
917 },
918 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -0700919 .dbg_name = "csi_p_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700920 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -0700921 CLK_INIT(csi_p_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700922 },
923};
924
925static struct branch_clk dsi1_m_p_clk = {
926 .b = {
927 .ctl_reg = AHB_EN_REG,
928 .en_mask = BIT(9),
929 .reset_reg = SW_RESET_AHB_REG,
930 .reset_mask = BIT(6),
931 .halt_reg = DBG_BUS_VEC_F_REG,
932 .halt_bit = 19,
933 },
934 .c = {
935 .dbg_name = "dsi1_m_p_clk",
936 .ops = &clk_ops_branch,
937 CLK_INIT(dsi1_m_p_clk.c),
938 },
939};
940
941static struct branch_clk dsi1_s_p_clk = {
942 .b = {
943 .ctl_reg = AHB_EN_REG,
944 .en_mask = BIT(18),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800945 .hwcg_reg = AHB_EN2_REG,
946 .hwcg_mask = BIT(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700947 .reset_reg = SW_RESET_AHB_REG,
948 .reset_mask = BIT(5),
949 .halt_reg = DBG_BUS_VEC_F_REG,
950 .halt_bit = 21,
951 },
952 .c = {
953 .dbg_name = "dsi1_s_p_clk",
954 .ops = &clk_ops_branch,
955 CLK_INIT(dsi1_s_p_clk.c),
956 },
957};
958
959static struct branch_clk dsi2_m_p_clk = {
960 .b = {
961 .ctl_reg = AHB_EN_REG,
962 .en_mask = BIT(17),
963 .reset_reg = SW_RESET_AHB2_REG,
964 .reset_mask = BIT(1),
965 .halt_reg = DBG_BUS_VEC_E_REG,
966 .halt_bit = 18,
967 },
968 .c = {
969 .dbg_name = "dsi2_m_p_clk",
970 .ops = &clk_ops_branch,
971 CLK_INIT(dsi2_m_p_clk.c),
972 },
973};
974
975static struct branch_clk dsi2_s_p_clk = {
976 .b = {
977 .ctl_reg = AHB_EN_REG,
978 .en_mask = BIT(22),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800979 .hwcg_reg = AHB_EN2_REG,
980 .hwcg_mask = BIT(15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700981 .reset_reg = SW_RESET_AHB2_REG,
982 .reset_mask = BIT(0),
983 .halt_reg = DBG_BUS_VEC_F_REG,
984 .halt_bit = 20,
985 },
986 .c = {
987 .dbg_name = "dsi2_s_p_clk",
988 .ops = &clk_ops_branch,
989 CLK_INIT(dsi2_s_p_clk.c),
990 },
991};
992
993static struct branch_clk gfx2d0_p_clk = {
994 .b = {
995 .ctl_reg = AHB_EN_REG,
996 .en_mask = BIT(19),
Stephen Boyda52d7e32011-11-10 11:59:00 -0800997 .hwcg_reg = AHB_EN2_REG,
998 .hwcg_mask = BIT(28),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700999 .reset_reg = SW_RESET_AHB_REG,
1000 .reset_mask = BIT(12),
1001 .halt_reg = DBG_BUS_VEC_F_REG,
1002 .halt_bit = 2,
1003 },
1004 .c = {
1005 .dbg_name = "gfx2d0_p_clk",
1006 .ops = &clk_ops_branch,
1007 CLK_INIT(gfx2d0_p_clk.c),
1008 },
1009};
1010
1011static struct branch_clk gfx2d1_p_clk = {
1012 .b = {
1013 .ctl_reg = AHB_EN_REG,
1014 .en_mask = BIT(2),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001015 .hwcg_reg = AHB_EN2_REG,
1016 .hwcg_mask = BIT(29),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001017 .reset_reg = SW_RESET_AHB_REG,
1018 .reset_mask = BIT(11),
1019 .halt_reg = DBG_BUS_VEC_F_REG,
1020 .halt_bit = 3,
1021 },
1022 .c = {
1023 .dbg_name = "gfx2d1_p_clk",
1024 .ops = &clk_ops_branch,
1025 CLK_INIT(gfx2d1_p_clk.c),
1026 },
1027};
1028
1029static struct branch_clk gfx3d_p_clk = {
1030 .b = {
1031 .ctl_reg = AHB_EN_REG,
1032 .en_mask = BIT(3),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001033 .hwcg_reg = AHB_EN2_REG,
1034 .hwcg_mask = BIT(27),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001035 .reset_reg = SW_RESET_AHB_REG,
1036 .reset_mask = BIT(10),
1037 .halt_reg = DBG_BUS_VEC_F_REG,
1038 .halt_bit = 4,
1039 },
1040 .c = {
1041 .dbg_name = "gfx3d_p_clk",
1042 .ops = &clk_ops_branch,
1043 CLK_INIT(gfx3d_p_clk.c),
1044 },
1045};
1046
1047static struct branch_clk hdmi_m_p_clk = {
1048 .b = {
1049 .ctl_reg = AHB_EN_REG,
1050 .en_mask = BIT(14),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001051 .hwcg_reg = AHB_EN2_REG,
1052 .hwcg_mask = BIT(21),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001053 .reset_reg = SW_RESET_AHB_REG,
1054 .reset_mask = BIT(9),
1055 .halt_reg = DBG_BUS_VEC_F_REG,
1056 .halt_bit = 5,
1057 },
1058 .c = {
1059 .dbg_name = "hdmi_m_p_clk",
1060 .ops = &clk_ops_branch,
1061 CLK_INIT(hdmi_m_p_clk.c),
1062 },
1063};
1064
1065static struct branch_clk hdmi_s_p_clk = {
1066 .b = {
1067 .ctl_reg = AHB_EN_REG,
1068 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001069 .hwcg_reg = AHB_EN2_REG,
1070 .hwcg_mask = BIT(22),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001071 .reset_reg = SW_RESET_AHB_REG,
1072 .reset_mask = BIT(9),
1073 .halt_reg = DBG_BUS_VEC_F_REG,
1074 .halt_bit = 6,
1075 },
1076 .c = {
1077 .dbg_name = "hdmi_s_p_clk",
1078 .ops = &clk_ops_branch,
1079 CLK_INIT(hdmi_s_p_clk.c),
1080 },
1081};
1082
1083static struct branch_clk ijpeg_p_clk = {
1084 .b = {
1085 .ctl_reg = AHB_EN_REG,
1086 .en_mask = BIT(5),
1087 .reset_reg = SW_RESET_AHB_REG,
1088 .reset_mask = BIT(7),
1089 .halt_reg = DBG_BUS_VEC_F_REG,
1090 .halt_bit = 9,
1091 },
1092 .c = {
1093 .dbg_name = "ijpeg_p_clk",
1094 .ops = &clk_ops_branch,
1095 CLK_INIT(ijpeg_p_clk.c),
1096 },
1097};
1098
1099static struct branch_clk imem_p_clk = {
1100 .b = {
1101 .ctl_reg = AHB_EN_REG,
1102 .en_mask = BIT(6),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001103 .hwcg_reg = AHB_EN2_REG,
1104 .hwcg_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001105 .reset_reg = SW_RESET_AHB_REG,
1106 .reset_mask = BIT(8),
1107 .halt_reg = DBG_BUS_VEC_F_REG,
1108 .halt_bit = 10,
1109 },
1110 .c = {
1111 .dbg_name = "imem_p_clk",
1112 .ops = &clk_ops_branch,
1113 CLK_INIT(imem_p_clk.c),
1114 },
1115};
1116
1117static struct branch_clk jpegd_p_clk = {
1118 .b = {
1119 .ctl_reg = AHB_EN_REG,
1120 .en_mask = BIT(21),
1121 .reset_reg = SW_RESET_AHB_REG,
1122 .reset_mask = BIT(4),
1123 .halt_reg = DBG_BUS_VEC_F_REG,
1124 .halt_bit = 7,
1125 },
1126 .c = {
1127 .dbg_name = "jpegd_p_clk",
1128 .ops = &clk_ops_branch,
1129 CLK_INIT(jpegd_p_clk.c),
1130 },
1131};
1132
1133static struct branch_clk mdp_p_clk = {
1134 .b = {
1135 .ctl_reg = AHB_EN_REG,
1136 .en_mask = BIT(10),
1137 .reset_reg = SW_RESET_AHB_REG,
1138 .reset_mask = BIT(3),
1139 .halt_reg = DBG_BUS_VEC_F_REG,
1140 .halt_bit = 11,
1141 },
1142 .c = {
1143 .dbg_name = "mdp_p_clk",
1144 .ops = &clk_ops_branch,
1145 CLK_INIT(mdp_p_clk.c),
1146 },
1147};
1148
1149static struct branch_clk rot_p_clk = {
1150 .b = {
1151 .ctl_reg = AHB_EN_REG,
1152 .en_mask = BIT(12),
1153 .reset_reg = SW_RESET_AHB_REG,
1154 .reset_mask = BIT(2),
1155 .halt_reg = DBG_BUS_VEC_F_REG,
1156 .halt_bit = 13,
1157 },
1158 .c = {
1159 .dbg_name = "rot_p_clk",
1160 .ops = &clk_ops_branch,
1161 CLK_INIT(rot_p_clk.c),
1162 },
1163};
1164
1165static struct branch_clk smmu_p_clk = {
1166 .b = {
1167 .ctl_reg = AHB_EN_REG,
1168 .en_mask = BIT(15),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001169 .hwcg_reg = AHB_EN_REG,
1170 .hwcg_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001171 .halt_reg = DBG_BUS_VEC_F_REG,
1172 .halt_bit = 22,
1173 },
1174 .c = {
1175 .dbg_name = "smmu_p_clk",
1176 .ops = &clk_ops_branch,
1177 CLK_INIT(smmu_p_clk.c),
1178 },
1179};
1180
1181static struct branch_clk tv_enc_p_clk = {
1182 .b = {
1183 .ctl_reg = AHB_EN_REG,
1184 .en_mask = BIT(25),
1185 .reset_reg = SW_RESET_AHB_REG,
1186 .reset_mask = BIT(15),
1187 .halt_reg = DBG_BUS_VEC_F_REG,
1188 .halt_bit = 23,
1189 },
1190 .c = {
1191 .dbg_name = "tv_enc_p_clk",
1192 .ops = &clk_ops_branch,
1193 CLK_INIT(tv_enc_p_clk.c),
1194 },
1195};
1196
1197static struct branch_clk vcodec_p_clk = {
1198 .b = {
1199 .ctl_reg = AHB_EN_REG,
1200 .en_mask = BIT(11),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001201 .hwcg_reg = AHB_EN2_REG,
1202 .hwcg_mask = BIT(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001203 .reset_reg = SW_RESET_AHB_REG,
1204 .reset_mask = BIT(1),
1205 .halt_reg = DBG_BUS_VEC_F_REG,
1206 .halt_bit = 12,
1207 },
1208 .c = {
1209 .dbg_name = "vcodec_p_clk",
1210 .ops = &clk_ops_branch,
1211 CLK_INIT(vcodec_p_clk.c),
1212 },
1213};
1214
1215static struct branch_clk vfe_p_clk = {
1216 .b = {
1217 .ctl_reg = AHB_EN_REG,
1218 .en_mask = BIT(13),
1219 .reset_reg = SW_RESET_AHB_REG,
1220 .reset_mask = BIT(0),
1221 .halt_reg = DBG_BUS_VEC_F_REG,
1222 .halt_bit = 14,
1223 },
1224 .c = {
1225 .dbg_name = "vfe_p_clk",
1226 .ops = &clk_ops_branch,
1227 CLK_INIT(vfe_p_clk.c),
1228 },
1229};
1230
1231static struct branch_clk vpe_p_clk = {
1232 .b = {
1233 .ctl_reg = AHB_EN_REG,
1234 .en_mask = BIT(16),
1235 .reset_reg = SW_RESET_AHB_REG,
1236 .reset_mask = BIT(14),
1237 .halt_reg = DBG_BUS_VEC_F_REG,
1238 .halt_bit = 15,
1239 },
1240 .c = {
1241 .dbg_name = "vpe_p_clk",
1242 .ops = &clk_ops_branch,
1243 CLK_INIT(vpe_p_clk.c),
1244 },
1245};
1246
Tianyi Gou41515e22011-09-01 19:37:43 -07001247static struct branch_clk vcap_p_clk = {
1248 .b = {
1249 .ctl_reg = AHB_EN3_REG,
1250 .en_mask = BIT(1),
1251 .reset_reg = SW_RESET_AHB2_REG,
1252 .reset_mask = BIT(2),
1253 .halt_reg = DBG_BUS_VEC_J_REG,
1254 .halt_bit = 23,
1255 },
1256 .c = {
1257 .dbg_name = "vcap_p_clk",
1258 .ops = &clk_ops_branch,
1259 CLK_INIT(vcap_p_clk.c),
1260 },
1261};
1262
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001263/*
1264 * Peripheral Clocks
1265 */
Matt Wagantall7625a4c2011-11-01 16:17:53 -07001266#define CLK_GP(i, n, h_r, h_b) \
1267 struct rcg_clk i##_clk = { \
1268 .b = { \
1269 .ctl_reg = GPn_NS_REG(n), \
1270 .en_mask = BIT(9), \
1271 .halt_reg = h_r, \
1272 .halt_bit = h_b, \
1273 }, \
1274 .ns_reg = GPn_NS_REG(n), \
1275 .md_reg = GPn_MD_REG(n), \
1276 .root_en_mask = BIT(11), \
1277 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1278 .set_rate = set_rate_mnd, \
1279 .freq_tbl = clk_tbl_gp, \
1280 .current_freq = &rcg_dummy_freq, \
1281 .c = { \
1282 .dbg_name = #i "_clk", \
1283 .ops = &clk_ops_rcg_8960, \
1284 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000), \
1285 CLK_INIT(i##_clk.c), \
1286 }, \
1287 }
1288#define F_GP(f, s, d, m, n) \
1289 { \
1290 .freq_hz = f, \
1291 .src_clk = &s##_clk.c, \
1292 .md_val = MD8(16, m, 0, n), \
1293 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1294 .mnd_en_mask = BIT(8) * !!(n), \
1295 }
1296static struct clk_freq_tbl clk_tbl_gp[] = {
1297 F_GP( 0, gnd, 1, 0, 0),
1298 F_GP( 9600000, cxo, 2, 0, 0),
1299 F_GP( 13500000, pxo, 2, 0, 0),
1300 F_GP( 19200000, cxo, 1, 0, 0),
1301 F_GP( 27000000, pxo, 1, 0, 0),
1302 F_GP( 64000000, pll8, 2, 1, 3),
1303 F_GP( 76800000, pll8, 1, 1, 5),
1304 F_GP( 96000000, pll8, 4, 0, 0),
1305 F_GP(128000000, pll8, 3, 0, 0),
1306 F_GP(192000000, pll8, 2, 0, 0),
1307 F_GP(384000000, pll8, 1, 0, 0),
1308 F_END
1309};
1310
1311static CLK_GP(gp0, 0, CLK_HALT_SFPB_MISC_STATE_REG, 7);
1312static CLK_GP(gp1, 1, CLK_HALT_SFPB_MISC_STATE_REG, 6);
1313static CLK_GP(gp2, 2, CLK_HALT_SFPB_MISC_STATE_REG, 5);
1314
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001315#define CLK_GSBI_UART(i, n, h_r, h_b) \
1316 struct rcg_clk i##_clk = { \
1317 .b = { \
1318 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
1319 .en_mask = BIT(9), \
1320 .reset_reg = GSBIn_RESET_REG(n), \
1321 .reset_mask = BIT(0), \
1322 .halt_reg = h_r, \
1323 .halt_bit = h_b, \
1324 }, \
1325 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
1326 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
1327 .root_en_mask = BIT(11), \
1328 .ns_mask = (BM(31, 16) | BM(6, 0)), \
1329 .set_rate = set_rate_mnd, \
1330 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001331 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001332 .c = { \
1333 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001334 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001335 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001336 CLK_INIT(i##_clk.c), \
1337 }, \
1338 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001339#define F_GSBI_UART(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001340 { \
1341 .freq_hz = f, \
1342 .src_clk = &s##_clk.c, \
1343 .md_val = MD16(m, n), \
1344 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1345 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001346 }
1347static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001348 F_GSBI_UART( 0, gnd, 1, 0, 0),
1349 F_GSBI_UART( 1843200, pll8, 1, 3, 625),
1350 F_GSBI_UART( 3686400, pll8, 1, 6, 625),
1351 F_GSBI_UART( 7372800, pll8, 1, 12, 625),
1352 F_GSBI_UART(14745600, pll8, 1, 24, 625),
1353 F_GSBI_UART(16000000, pll8, 4, 1, 6),
1354 F_GSBI_UART(24000000, pll8, 4, 1, 4),
1355 F_GSBI_UART(32000000, pll8, 4, 1, 3),
1356 F_GSBI_UART(40000000, pll8, 1, 5, 48),
1357 F_GSBI_UART(46400000, pll8, 1, 29, 240),
1358 F_GSBI_UART(48000000, pll8, 4, 1, 2),
1359 F_GSBI_UART(51200000, pll8, 1, 2, 15),
1360 F_GSBI_UART(56000000, pll8, 1, 7, 48),
1361 F_GSBI_UART(58982400, pll8, 1, 96, 625),
1362 F_GSBI_UART(64000000, pll8, 2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001363 F_END
1364};
1365
1366static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1367static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1368static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1369static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1370static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1371static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1372static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1373static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1374static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1375static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1376static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1377static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1378
1379#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1380 struct rcg_clk i##_clk = { \
1381 .b = { \
1382 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1383 .en_mask = BIT(9), \
1384 .reset_reg = GSBIn_RESET_REG(n), \
1385 .reset_mask = BIT(0), \
1386 .halt_reg = h_r, \
1387 .halt_bit = h_b, \
1388 }, \
1389 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1390 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1391 .root_en_mask = BIT(11), \
1392 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1393 .set_rate = set_rate_mnd, \
1394 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001395 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001396 .c = { \
1397 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001398 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001399 VDD_DIG_FMAX_MAP2(LOW, 24000000, NOMINAL, 52000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001400 CLK_INIT(i##_clk.c), \
1401 }, \
1402 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001403#define F_GSBI_QUP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001404 { \
1405 .freq_hz = f, \
1406 .src_clk = &s##_clk.c, \
1407 .md_val = MD8(16, m, 0, n), \
1408 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1409 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001410 }
1411static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001412 F_GSBI_QUP( 0, gnd, 1, 0, 0),
1413 F_GSBI_QUP( 1100000, pxo, 1, 2, 49),
1414 F_GSBI_QUP( 5400000, pxo, 1, 1, 5),
1415 F_GSBI_QUP(10800000, pxo, 1, 2, 5),
1416 F_GSBI_QUP(15060000, pll8, 1, 2, 51),
1417 F_GSBI_QUP(24000000, pll8, 4, 1, 4),
1418 F_GSBI_QUP(25600000, pll8, 1, 1, 15),
1419 F_GSBI_QUP(27000000, pxo, 1, 0, 0),
1420 F_GSBI_QUP(48000000, pll8, 4, 1, 2),
1421 F_GSBI_QUP(51200000, pll8, 1, 2, 15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001422 F_END
1423};
1424
1425static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1426static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1427static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1428static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1429static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1430static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1431static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1432static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1433static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1434static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1435static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1436static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1437
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001438#define F_QDSS(f, s, d) \
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001439 { \
1440 .freq_hz = f, \
1441 .src_clk = &s##_clk.c, \
1442 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001443 }
1444static struct clk_freq_tbl clk_tbl_qdss[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001445 F_QDSS( 27000000, pxo, 1),
1446 F_QDSS(128000000, pll8, 3),
1447 F_QDSS(300000000, pll3, 4),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001448 F_END
1449};
1450
1451struct qdss_bank {
1452 const u32 bank_sel_mask;
1453 void __iomem *const ns_reg;
1454 const u32 ns_mask;
1455};
1456
Stephen Boydd4de6d72011-09-13 13:01:40 -07001457#define QDSS_CLK_ROOT_ENA BIT(1)
1458
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001459static int qdss_clk_handoff(struct clk *c)
Stephen Boydd4de6d72011-09-13 13:01:40 -07001460{
1461 struct rcg_clk *clk = to_rcg_clk(c);
1462 const struct qdss_bank *bank = clk->bank_info;
1463 u32 reg, ns_val, bank_sel;
1464 struct clk_freq_tbl *freq;
1465
1466 reg = readl_relaxed(clk->ns_reg);
1467 if (!(reg & QDSS_CLK_ROOT_ENA))
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001468 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001469
1470 bank_sel = reg & bank->bank_sel_mask;
1471 /* Force bank 1 to PXO if bank 0 is in use */
1472 if (bank_sel == 0)
1473 writel_relaxed(0, bank->ns_reg);
1474 ns_val = readl_relaxed(bank->ns_reg) & bank->ns_mask;
1475 for (freq = clk->freq_tbl; freq->freq_hz != FREQ_END; freq++) {
1476 if ((freq->ns_val & bank->ns_mask) == ns_val) {
1477 pr_info("%s rate=%d\n", clk->c.dbg_name, freq->freq_hz);
1478 break;
1479 }
1480 }
1481 if (freq->freq_hz == FREQ_END)
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001482 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001483
1484 clk->current_freq = freq;
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001485
1486 return 1;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001487}
1488
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001489static void set_rate_qdss(struct rcg_clk *clk, struct clk_freq_tbl *nf)
1490{
1491 const struct qdss_bank *bank = clk->bank_info;
1492 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1493
1494 /* Switch to bank 0 (always sourced from PXO) */
1495 reg = readl_relaxed(clk->ns_reg);
1496 reg &= ~bank_sel_mask;
1497 writel_relaxed(reg, clk->ns_reg);
1498 /*
1499 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1500 * MUX to fully switch sources.
1501 */
1502 mb();
1503 udelay(1);
1504
1505 /* Set source and divider */
1506 reg = readl_relaxed(bank->ns_reg);
1507 reg &= ~bank->ns_mask;
1508 reg |= nf->ns_val;
1509 writel_relaxed(reg, bank->ns_reg);
1510
1511 /* Switch to reprogrammed bank */
1512 reg = readl_relaxed(clk->ns_reg);
1513 reg |= bank_sel_mask;
1514 writel_relaxed(reg, clk->ns_reg);
1515 /*
1516 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1517 * MUX to fully switch sources.
1518 */
1519 mb();
1520 udelay(1);
1521}
1522
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001523static int qdss_clk_enable(struct clk *c)
1524{
1525 struct rcg_clk *clk = to_rcg_clk(c);
1526 const struct qdss_bank *bank = clk->bank_info;
1527 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1528 int ret;
1529
1530 /* Switch to bank 1 */
1531 reg = readl_relaxed(clk->ns_reg);
1532 reg |= bank_sel_mask;
1533 writel_relaxed(reg, clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001534
1535 ret = rcg_clk_enable(c);
1536 if (ret) {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001537 /* Switch to bank 0 */
1538 reg &= ~bank_sel_mask;
1539 writel_relaxed(reg, clk->ns_reg);
1540 }
1541 return ret;
1542}
1543
1544static void qdss_clk_disable(struct clk *c)
1545{
1546 struct rcg_clk *clk = to_rcg_clk(c);
1547 const struct qdss_bank *bank = clk->bank_info;
1548 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1549
1550 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001551 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001552 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001553 reg &= ~bank_sel_mask;
1554 writel_relaxed(reg, clk->ns_reg);
1555}
1556
1557static void qdss_clk_auto_off(struct clk *c)
1558{
1559 struct rcg_clk *clk = to_rcg_clk(c);
1560 const struct qdss_bank *bank = clk->bank_info;
1561 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1562
Matt Wagantall41af0772011-09-17 12:21:39 -07001563 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001564 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001565 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001566 reg &= ~bank_sel_mask;
1567 writel_relaxed(reg, clk->ns_reg);
1568}
1569
1570static struct clk_ops clk_ops_qdss = {
1571 .enable = qdss_clk_enable,
1572 .disable = qdss_clk_disable,
1573 .auto_off = qdss_clk_auto_off,
Stephen Boydd4de6d72011-09-13 13:01:40 -07001574 .handoff = qdss_clk_handoff,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001575 .set_rate = rcg_clk_set_rate,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001576 .get_rate = rcg_clk_get_rate,
1577 .list_rate = rcg_clk_list_rate,
1578 .is_enabled = rcg_clk_is_enabled,
1579 .round_rate = rcg_clk_round_rate,
Stephen Boyd7bf28142011-12-07 00:30:52 -08001580 .reset = rcg_clk_reset,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001581 .is_local = local_clk_is_local,
1582 .get_parent = rcg_clk_get_parent,
1583};
1584
1585static struct qdss_bank bdiv_info_qdss = {
1586 .bank_sel_mask = BIT(0),
1587 .ns_reg = QDSS_AT_CLK_SRC1_NS_REG,
1588 .ns_mask = BM(6, 0),
1589};
1590
1591static struct rcg_clk qdss_at_clk = {
1592 .b = {
1593 .ctl_reg = QDSS_AT_CLK_NS_REG,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001594 .reset_reg = QDSS_RESETS_REG,
1595 .reset_mask = BIT(0),
Stephen Boydfcfd4dd2011-09-13 12:49:57 -07001596 .halt_check = NOCHECK,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001597 },
1598 .ns_reg = QDSS_AT_CLK_SRC_CTL_REG,
1599 .set_rate = set_rate_qdss,
1600 .freq_tbl = clk_tbl_qdss,
1601 .bank_info = &bdiv_info_qdss,
1602 .current_freq = &rcg_dummy_freq,
1603 .c = {
1604 .dbg_name = "qdss_at_clk",
1605 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001606 VDD_DIG_FMAX_MAP2(LOW, 150000000, NOMINAL, 300000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001607 CLK_INIT(qdss_at_clk.c),
1608 },
1609};
1610
1611static struct branch_clk qdss_pclkdbg_clk = {
1612 .b = {
1613 .ctl_reg = QDSS_AT_CLK_NS_REG,
1614 .en_mask = BIT(4),
1615 .reset_reg = QDSS_RESETS_REG,
1616 .reset_mask = BIT(0),
1617 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1618 .halt_bit = 9,
1619 .halt_check = HALT_VOTED
1620 },
1621 .parent = &qdss_at_clk.c,
1622 .c = {
1623 .dbg_name = "qdss_pclkdbg_clk",
1624 .ops = &clk_ops_branch,
1625 CLK_INIT(qdss_pclkdbg_clk.c),
1626 },
1627};
1628
1629static struct qdss_bank bdiv_info_qdss_trace = {
1630 .bank_sel_mask = BIT(0),
1631 .ns_reg = QDSS_TRACECLKIN_CLK_SRC1_NS_REG,
1632 .ns_mask = BM(6, 0),
1633};
1634
1635static struct rcg_clk qdss_traceclkin_clk = {
1636 .b = {
1637 .ctl_reg = QDSS_TRACECLKIN_CTL_REG,
1638 .en_mask = BIT(4),
1639 .reset_reg = QDSS_RESETS_REG,
1640 .reset_mask = BIT(0),
1641 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1642 .halt_bit = 8,
1643 .halt_check = HALT_VOTED,
1644 },
1645 .ns_reg = QDSS_TRACECLKIN_CLK_SRC_CTL_REG,
1646 .set_rate = set_rate_qdss,
1647 .freq_tbl = clk_tbl_qdss,
1648 .bank_info = &bdiv_info_qdss_trace,
1649 .current_freq = &rcg_dummy_freq,
1650 .c = {
1651 .dbg_name = "qdss_traceclkin_clk",
1652 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001653 VDD_DIG_FMAX_MAP2(LOW, 150000000, NOMINAL, 300000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001654 CLK_INIT(qdss_traceclkin_clk.c),
1655 },
1656};
1657
1658static struct clk_freq_tbl clk_tbl_qdss_tsctr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001659 F_QDSS( 27000000, pxo, 1),
1660 F_QDSS(200000000, pll3, 6),
1661 F_QDSS(400000000, pll3, 3),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001662 F_END
1663};
1664
1665static struct qdss_bank bdiv_info_qdss_tsctr = {
1666 .bank_sel_mask = BIT(0),
1667 .ns_reg = QDSS_TSCTR_CLK_SRC1_NS_REG,
1668 .ns_mask = BM(6, 0),
1669};
1670
1671static struct rcg_clk qdss_tsctr_clk = {
1672 .b = {
1673 .ctl_reg = QDSS_TSCTR_CTL_REG,
1674 .en_mask = BIT(4),
1675 .reset_reg = QDSS_RESETS_REG,
1676 .reset_mask = BIT(3),
1677 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1678 .halt_bit = 7,
1679 .halt_check = HALT_VOTED,
1680 },
1681 .ns_reg = QDSS_TSCTR_CLK_SRC_CTL_REG,
1682 .set_rate = set_rate_qdss,
1683 .freq_tbl = clk_tbl_qdss_tsctr,
1684 .bank_info = &bdiv_info_qdss_tsctr,
1685 .current_freq = &rcg_dummy_freq,
1686 .c = {
1687 .dbg_name = "qdss_tsctr_clk",
1688 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001689 VDD_DIG_FMAX_MAP2(LOW, 200000000, NOMINAL, 400000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001690 CLK_INIT(qdss_tsctr_clk.c),
1691 },
1692};
1693
1694static struct branch_clk qdss_stm_clk = {
1695 .b = {
1696 .ctl_reg = QDSS_STM_CLK_CTL_REG,
1697 .en_mask = BIT(4),
1698 .reset_reg = QDSS_RESETS_REG,
1699 .reset_mask = BIT(1),
1700 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
1701 .halt_bit = 20,
1702 .halt_check = HALT_VOTED,
1703 },
1704 .c = {
1705 .dbg_name = "qdss_stm_clk",
1706 .ops = &clk_ops_branch,
1707 CLK_INIT(qdss_stm_clk.c),
1708 },
1709};
1710
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001711#define F_PDM(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001712 { \
1713 .freq_hz = f, \
1714 .src_clk = &s##_clk.c, \
1715 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001716 }
1717static struct clk_freq_tbl clk_tbl_pdm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001718 F_PDM( 0, gnd, 1),
1719 F_PDM(27000000, pxo, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001720 F_END
1721};
1722
1723static struct rcg_clk pdm_clk = {
1724 .b = {
1725 .ctl_reg = PDM_CLK_NS_REG,
1726 .en_mask = BIT(9),
1727 .reset_reg = PDM_CLK_NS_REG,
1728 .reset_mask = BIT(12),
1729 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1730 .halt_bit = 3,
1731 },
1732 .ns_reg = PDM_CLK_NS_REG,
1733 .root_en_mask = BIT(11),
1734 .ns_mask = BM(1, 0),
1735 .set_rate = set_rate_nop,
1736 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001737 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001738 .c = {
1739 .dbg_name = "pdm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001740 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001741 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001742 CLK_INIT(pdm_clk.c),
1743 },
1744};
1745
1746static struct branch_clk pmem_clk = {
1747 .b = {
1748 .ctl_reg = PMEM_ACLK_CTL_REG,
1749 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08001750 .hwcg_reg = PMEM_ACLK_CTL_REG,
1751 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001752 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1753 .halt_bit = 20,
1754 },
1755 .c = {
1756 .dbg_name = "pmem_clk",
1757 .ops = &clk_ops_branch,
1758 CLK_INIT(pmem_clk.c),
1759 },
1760};
1761
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001762#define F_PRNG(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001763 { \
1764 .freq_hz = f, \
1765 .src_clk = &s##_clk.c, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001766 }
1767static struct clk_freq_tbl clk_tbl_prng[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001768 F_PRNG(64000000, pll8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001769 F_END
1770};
1771
1772static struct rcg_clk prng_clk = {
1773 .b = {
1774 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1775 .en_mask = BIT(10),
1776 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1777 .halt_check = HALT_VOTED,
1778 .halt_bit = 10,
1779 },
1780 .set_rate = set_rate_nop,
1781 .freq_tbl = clk_tbl_prng,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001782 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001783 .c = {
1784 .dbg_name = "prng_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001785 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001786 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 65000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001787 CLK_INIT(prng_clk.c),
1788 },
1789};
1790
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001791#define CLK_SDC(name, n, h_b, fmax_low, fmax_nom) \
Stephen Boyda78a7402011-08-02 11:23:39 -07001792 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001793 .b = { \
1794 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1795 .en_mask = BIT(9), \
1796 .reset_reg = SDCn_RESET_REG(n), \
1797 .reset_mask = BIT(0), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001798 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001799 .halt_bit = h_b, \
1800 }, \
1801 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1802 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1803 .root_en_mask = BIT(11), \
1804 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1805 .set_rate = set_rate_mnd, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001806 .freq_tbl = clk_tbl_sdc, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001807 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001808 .c = { \
Stephen Boyda78a7402011-08-02 11:23:39 -07001809 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001810 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001811 VDD_DIG_FMAX_MAP2(LOW, fmax_low, NOMINAL, fmax_nom), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001812 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001813 }, \
1814 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001815#define F_SDC(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001816 { \
1817 .freq_hz = f, \
1818 .src_clk = &s##_clk.c, \
1819 .md_val = MD8(16, m, 0, n), \
1820 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1821 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001822 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001823static struct clk_freq_tbl clk_tbl_sdc[] = {
1824 F_SDC( 0, gnd, 1, 0, 0),
1825 F_SDC( 144000, pxo, 3, 2, 125),
1826 F_SDC( 400000, pll8, 4, 1, 240),
1827 F_SDC( 16000000, pll8, 4, 1, 6),
1828 F_SDC( 17070000, pll8, 1, 2, 45),
1829 F_SDC( 20210000, pll8, 1, 1, 19),
1830 F_SDC( 24000000, pll8, 4, 1, 4),
1831 F_SDC( 48000000, pll8, 4, 1, 2),
1832 F_SDC( 64000000, pll8, 3, 1, 2),
1833 F_SDC( 96000000, pll8, 4, 0, 0),
Subhash Jadavanibd238ba2011-11-24 15:12:39 +05301834 F_SDC(192000000, pll8, 2, 0, 0),
Stephen Boyda78a7402011-08-02 11:23:39 -07001835 F_END
1836};
1837
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001838static CLK_SDC(sdc1_clk, 1, 6, 52000000, 104000000);
1839static CLK_SDC(sdc2_clk, 2, 5, 52000000, 104000000);
1840static CLK_SDC(sdc3_clk, 3, 4, 104000000, 208000000);
1841static CLK_SDC(sdc4_clk, 4, 3, 33000000, 67000000);
1842static CLK_SDC(sdc5_clk, 5, 2, 33000000, 67000000);
Stephen Boyda78a7402011-08-02 11:23:39 -07001843
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001844#define F_TSIF_REF(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001845 { \
1846 .freq_hz = f, \
1847 .src_clk = &s##_clk.c, \
1848 .md_val = MD16(m, n), \
1849 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1850 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001851 }
1852static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001853 F_TSIF_REF( 0, gnd, 1, 0, 0),
1854 F_TSIF_REF(105000, pxo, 1, 1, 256),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001855 F_END
1856};
1857
1858static struct rcg_clk tsif_ref_clk = {
1859 .b = {
1860 .ctl_reg = TSIF_REF_CLK_NS_REG,
1861 .en_mask = BIT(9),
1862 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1863 .halt_bit = 5,
1864 },
1865 .ns_reg = TSIF_REF_CLK_NS_REG,
1866 .md_reg = TSIF_REF_CLK_MD_REG,
1867 .root_en_mask = BIT(11),
1868 .ns_mask = (BM(31, 16) | BM(6, 0)),
1869 .set_rate = set_rate_mnd,
1870 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001871 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001872 .c = {
1873 .dbg_name = "tsif_ref_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001874 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001875 VDD_DIG_FMAX_MAP2(LOW, 27000000, NOMINAL, 54000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001876 CLK_INIT(tsif_ref_clk.c),
1877 },
1878};
1879
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001880#define F_TSSC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001881 { \
1882 .freq_hz = f, \
1883 .src_clk = &s##_clk.c, \
1884 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001885 }
1886static struct clk_freq_tbl clk_tbl_tssc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001887 F_TSSC( 0, gnd),
1888 F_TSSC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001889 F_END
1890};
1891
1892static struct rcg_clk tssc_clk = {
1893 .b = {
1894 .ctl_reg = TSSC_CLK_CTL_REG,
1895 .en_mask = BIT(4),
1896 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1897 .halt_bit = 4,
1898 },
1899 .ns_reg = TSSC_CLK_CTL_REG,
1900 .ns_mask = BM(1, 0),
1901 .set_rate = set_rate_nop,
1902 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001903 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001904 .c = {
1905 .dbg_name = "tssc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001906 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001907 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001908 CLK_INIT(tssc_clk.c),
1909 },
1910};
1911
Tianyi Gou41515e22011-09-01 19:37:43 -07001912#define CLK_USB_HS(name, n, h_b) \
1913 static struct rcg_clk name = { \
1914 .b = { \
1915 .ctl_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1916 .en_mask = BIT(9), \
1917 .reset_reg = USB_HS##n##_RESET_REG, \
1918 .reset_mask = BIT(0), \
1919 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
1920 .halt_bit = h_b, \
1921 }, \
1922 .ns_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1923 .md_reg = USB_HS##n##_XCVR_FS_CLK_MD_REG, \
1924 .root_en_mask = BIT(11), \
1925 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1926 .set_rate = set_rate_mnd, \
1927 .freq_tbl = clk_tbl_usb, \
1928 .current_freq = &rcg_dummy_freq, \
1929 .c = { \
1930 .dbg_name = #name, \
1931 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001932 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001933 CLK_INIT(name.c), \
1934 }, \
1935}
1936
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001937#define F_USB(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001938 { \
1939 .freq_hz = f, \
1940 .src_clk = &s##_clk.c, \
1941 .md_val = MD8(16, m, 0, n), \
1942 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1943 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001944 }
1945static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001946 F_USB( 0, gnd, 1, 0, 0),
1947 F_USB(60000000, pll8, 1, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001948 F_END
1949};
1950
Tianyi Gou41515e22011-09-01 19:37:43 -07001951CLK_USB_HS(usb_hs1_xcvr_clk, 1, 0);
1952CLK_USB_HS(usb_hs3_xcvr_clk, 3, 30);
1953CLK_USB_HS(usb_hs4_xcvr_clk, 4, 2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001954
Stephen Boyd94625ef2011-07-12 17:06:01 -07001955static struct clk_freq_tbl clk_tbl_usb_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001956 F_USB( 0, gnd, 1, 0, 0),
1957 F_USB(60000000, pll8, 1, 5, 32),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001958 F_END
1959};
1960
1961static struct rcg_clk usb_hsic_xcvr_fs_clk = {
1962 .b = {
1963 .ctl_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1964 .en_mask = BIT(9),
1965 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1966 .halt_bit = 26,
1967 },
1968 .ns_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1969 .md_reg = USB_HSIC_XCVR_FS_CLK_MD_REG,
1970 .root_en_mask = BIT(11),
1971 .ns_mask = (BM(23, 16) | BM(6, 0)),
1972 .set_rate = set_rate_mnd,
1973 .freq_tbl = clk_tbl_usb_hsic,
1974 .current_freq = &rcg_dummy_freq,
1975 .c = {
1976 .dbg_name = "usb_hsic_xcvr_fs_clk",
1977 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001978 VDD_DIG_FMAX_MAP1(LOW, 60000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001979 CLK_INIT(usb_hsic_xcvr_fs_clk.c),
1980 },
1981};
1982
1983static struct branch_clk usb_hsic_system_clk = {
1984 .b = {
1985 .ctl_reg = USB_HSIC_SYSTEM_CLK_CTL_REG,
1986 .en_mask = BIT(4),
1987 .reset_reg = USB_HSIC_RESET_REG,
1988 .reset_mask = BIT(0),
1989 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1990 .halt_bit = 24,
1991 },
1992 .parent = &usb_hsic_xcvr_fs_clk.c,
1993 .c = {
1994 .dbg_name = "usb_hsic_system_clk",
1995 .ops = &clk_ops_branch,
1996 CLK_INIT(usb_hsic_system_clk.c),
1997 },
1998};
1999
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002000#define F_USB_HSIC(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002001 { \
2002 .freq_hz = f, \
2003 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002004 }
2005static struct clk_freq_tbl clk_tbl_usb2_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002006 F_USB_HSIC(480000000, pll14),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002007 F_END
2008};
2009
2010static struct rcg_clk usb_hsic_hsic_src_clk = {
2011 .b = {
2012 .ctl_reg = USB_HSIC_HSIC_CLK_SRC_CTL_REG,
2013 .halt_check = NOCHECK,
2014 },
2015 .root_en_mask = BIT(0),
2016 .set_rate = set_rate_nop,
2017 .freq_tbl = clk_tbl_usb2_hsic,
2018 .current_freq = &rcg_dummy_freq,
2019 .c = {
2020 .dbg_name = "usb_hsic_hsic_src_clk",
2021 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002022 VDD_DIG_FMAX_MAP1(LOW, 480000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002023 CLK_INIT(usb_hsic_hsic_src_clk.c),
2024 },
2025};
2026
2027static struct branch_clk usb_hsic_hsic_clk = {
2028 .b = {
2029 .ctl_reg = USB_HSIC_HSIC_CLK_CTL_REG,
2030 .en_mask = BIT(0),
2031 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2032 .halt_bit = 19,
2033 },
2034 .parent = &usb_hsic_hsic_src_clk.c,
2035 .c = {
2036 .dbg_name = "usb_hsic_hsic_clk",
2037 .ops = &clk_ops_branch,
2038 CLK_INIT(usb_hsic_hsic_clk.c),
2039 },
2040};
2041
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002042#define F_USB_HSIO_CAL(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002043 { \
2044 .freq_hz = f, \
2045 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002046 }
2047static struct clk_freq_tbl clk_tbl_usb_hsio_cal[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002048 F_USB_HSIO_CAL(9000000, pxo),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002049 F_END
2050};
2051
2052static struct rcg_clk usb_hsic_hsio_cal_clk = {
2053 .b = {
2054 .ctl_reg = USB_HSIC_HSIO_CAL_CLK_CTL_REG,
2055 .en_mask = BIT(0),
2056 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2057 .halt_bit = 23,
2058 },
2059 .set_rate = set_rate_nop,
2060 .freq_tbl = clk_tbl_usb_hsio_cal,
2061 .current_freq = &rcg_dummy_freq,
2062 .c = {
2063 .dbg_name = "usb_hsic_hsio_cal_clk",
Stephen Boyda0e82ec2011-09-19 12:18:45 -07002064 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002065 VDD_DIG_FMAX_MAP1(LOW, 10000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002066 CLK_INIT(usb_hsic_hsio_cal_clk.c),
2067 },
2068};
2069
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002070static struct branch_clk usb_phy0_clk = {
2071 .b = {
2072 .reset_reg = USB_PHY0_RESET_REG,
2073 .reset_mask = BIT(0),
2074 },
2075 .c = {
2076 .dbg_name = "usb_phy0_clk",
2077 .ops = &clk_ops_reset,
2078 CLK_INIT(usb_phy0_clk.c),
2079 },
2080};
2081
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002082#define CLK_USB_FS(i, n, fmax_nom) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002083 struct rcg_clk i##_clk = { \
2084 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
2085 .b = { \
2086 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
2087 .halt_check = NOCHECK, \
2088 }, \
2089 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
2090 .root_en_mask = BIT(11), \
2091 .ns_mask = (BM(23, 16) | BM(6, 0)), \
2092 .set_rate = set_rate_mnd, \
2093 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002094 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002095 .c = { \
2096 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002097 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002098 VDD_DIG_FMAX_MAP1(NOMINAL, fmax_nom), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002099 CLK_INIT(i##_clk.c), \
2100 }, \
2101 }
2102
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002103static CLK_USB_FS(usb_fs1_src, 1, 64000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002104static struct branch_clk usb_fs1_xcvr_clk = {
2105 .b = {
2106 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
2107 .en_mask = BIT(9),
2108 .reset_reg = USB_FSn_RESET_REG(1),
2109 .reset_mask = BIT(1),
2110 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2111 .halt_bit = 15,
2112 },
2113 .parent = &usb_fs1_src_clk.c,
2114 .c = {
2115 .dbg_name = "usb_fs1_xcvr_clk",
2116 .ops = &clk_ops_branch,
2117 CLK_INIT(usb_fs1_xcvr_clk.c),
2118 },
2119};
2120
2121static struct branch_clk usb_fs1_sys_clk = {
2122 .b = {
2123 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
2124 .en_mask = BIT(4),
2125 .reset_reg = USB_FSn_RESET_REG(1),
2126 .reset_mask = BIT(0),
2127 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2128 .halt_bit = 16,
2129 },
2130 .parent = &usb_fs1_src_clk.c,
2131 .c = {
2132 .dbg_name = "usb_fs1_sys_clk",
2133 .ops = &clk_ops_branch,
2134 CLK_INIT(usb_fs1_sys_clk.c),
2135 },
2136};
2137
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002138static CLK_USB_FS(usb_fs2_src, 2, 60000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002139static struct branch_clk usb_fs2_xcvr_clk = {
2140 .b = {
2141 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
2142 .en_mask = BIT(9),
2143 .reset_reg = USB_FSn_RESET_REG(2),
2144 .reset_mask = BIT(1),
2145 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2146 .halt_bit = 12,
2147 },
2148 .parent = &usb_fs2_src_clk.c,
2149 .c = {
2150 .dbg_name = "usb_fs2_xcvr_clk",
2151 .ops = &clk_ops_branch,
2152 CLK_INIT(usb_fs2_xcvr_clk.c),
2153 },
2154};
2155
2156static struct branch_clk usb_fs2_sys_clk = {
2157 .b = {
2158 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
2159 .en_mask = BIT(4),
2160 .reset_reg = USB_FSn_RESET_REG(2),
2161 .reset_mask = BIT(0),
2162 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2163 .halt_bit = 13,
2164 },
2165 .parent = &usb_fs2_src_clk.c,
2166 .c = {
2167 .dbg_name = "usb_fs2_sys_clk",
2168 .ops = &clk_ops_branch,
2169 CLK_INIT(usb_fs2_sys_clk.c),
2170 },
2171};
2172
2173/* Fast Peripheral Bus Clocks */
2174static struct branch_clk ce1_core_clk = {
2175 .b = {
2176 .ctl_reg = CE1_CORE_CLK_CTL_REG,
2177 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002178 .hwcg_reg = CE1_CORE_CLK_CTL_REG,
2179 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002180 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2181 .halt_bit = 27,
2182 },
2183 .c = {
2184 .dbg_name = "ce1_core_clk",
2185 .ops = &clk_ops_branch,
2186 CLK_INIT(ce1_core_clk.c),
2187 },
2188};
Tianyi Gou41515e22011-09-01 19:37:43 -07002189
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002190static struct branch_clk ce1_p_clk = {
2191 .b = {
2192 .ctl_reg = CE1_HCLK_CTL_REG,
2193 .en_mask = BIT(4),
2194 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2195 .halt_bit = 1,
2196 },
2197 .c = {
2198 .dbg_name = "ce1_p_clk",
2199 .ops = &clk_ops_branch,
2200 CLK_INIT(ce1_p_clk.c),
2201 },
2202};
2203
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002204#define F_CE3(f, s, d) \
Tianyi Gou41515e22011-09-01 19:37:43 -07002205 { \
2206 .freq_hz = f, \
2207 .src_clk = &s##_clk.c, \
2208 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Tianyi Gou41515e22011-09-01 19:37:43 -07002209 }
2210
2211static struct clk_freq_tbl clk_tbl_ce3[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002212 F_CE3( 0, gnd, 1),
2213 F_CE3( 48000000, pll8, 8),
2214 F_CE3(100000000, pll3, 12),
Tianyi Gou41515e22011-09-01 19:37:43 -07002215 F_END
2216};
2217
2218static struct rcg_clk ce3_src_clk = {
2219 .b = {
2220 .ctl_reg = CE3_CLK_SRC_NS_REG,
2221 .halt_check = NOCHECK,
2222 },
2223 .ns_reg = CE3_CLK_SRC_NS_REG,
2224 .root_en_mask = BIT(7),
2225 .ns_mask = BM(6, 0),
2226 .set_rate = set_rate_nop,
2227 .freq_tbl = clk_tbl_ce3,
2228 .current_freq = &rcg_dummy_freq,
2229 .c = {
2230 .dbg_name = "ce3_src_clk",
2231 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002232 VDD_DIG_FMAX_MAP2(LOW, 50000000, NOMINAL, 100000000),
Tianyi Gou41515e22011-09-01 19:37:43 -07002233 CLK_INIT(ce3_src_clk.c),
2234 },
2235};
2236
2237static struct branch_clk ce3_core_clk = {
2238 .b = {
2239 .ctl_reg = CE3_CORE_CLK_CTL_REG,
2240 .en_mask = BIT(4),
2241 .reset_reg = CE3_CORE_CLK_CTL_REG,
2242 .reset_mask = BIT(7),
2243 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2244 .halt_bit = 5,
2245 },
2246 .parent = &ce3_src_clk.c,
2247 .c = {
2248 .dbg_name = "ce3_core_clk",
2249 .ops = &clk_ops_branch,
2250 CLK_INIT(ce3_core_clk.c),
2251 }
2252};
2253
2254static struct branch_clk ce3_p_clk = {
2255 .b = {
2256 .ctl_reg = CE3_HCLK_CTL_REG,
2257 .en_mask = BIT(4),
2258 .reset_reg = CE3_HCLK_CTL_REG,
2259 .reset_mask = BIT(7),
2260 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
2261 .halt_bit = 16,
2262 },
2263 .parent = &ce3_src_clk.c,
2264 .c = {
2265 .dbg_name = "ce3_p_clk",
2266 .ops = &clk_ops_branch,
2267 CLK_INIT(ce3_p_clk.c),
2268 }
2269};
2270
2271static struct branch_clk sata_phy_ref_clk = {
2272 .b = {
2273 .ctl_reg = SATA_PHY_REF_CLK_CTL_REG,
2274 .en_mask = BIT(4),
2275 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2276 .halt_bit = 24,
2277 },
2278 .parent = &pxo_clk.c,
2279 .c = {
2280 .dbg_name = "sata_phy_ref_clk",
2281 .ops = &clk_ops_branch,
2282 CLK_INIT(sata_phy_ref_clk.c),
2283 },
2284};
2285
2286static struct branch_clk pcie_p_clk = {
2287 .b = {
2288 .ctl_reg = PCIE_HCLK_CTL_REG,
2289 .en_mask = BIT(4),
2290 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2291 .halt_bit = 8,
2292 },
2293 .c = {
2294 .dbg_name = "pcie_p_clk",
2295 .ops = &clk_ops_branch,
2296 CLK_INIT(pcie_p_clk.c),
2297 },
2298};
2299
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002300static struct branch_clk dma_bam_p_clk = {
2301 .b = {
2302 .ctl_reg = DMA_BAM_HCLK_CTL,
2303 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002304 .hwcg_reg = DMA_BAM_HCLK_CTL,
2305 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002306 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2307 .halt_bit = 12,
2308 },
2309 .c = {
2310 .dbg_name = "dma_bam_p_clk",
2311 .ops = &clk_ops_branch,
2312 CLK_INIT(dma_bam_p_clk.c),
2313 },
2314};
2315
2316static struct branch_clk gsbi1_p_clk = {
2317 .b = {
2318 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
2319 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002320 .hwcg_reg = GSBIn_HCLK_CTL_REG(1),
2321 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002322 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2323 .halt_bit = 11,
2324 },
2325 .c = {
2326 .dbg_name = "gsbi1_p_clk",
2327 .ops = &clk_ops_branch,
2328 CLK_INIT(gsbi1_p_clk.c),
2329 },
2330};
2331
2332static struct branch_clk gsbi2_p_clk = {
2333 .b = {
2334 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
2335 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002336 .hwcg_reg = GSBIn_HCLK_CTL_REG(2),
2337 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002338 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2339 .halt_bit = 7,
2340 },
2341 .c = {
2342 .dbg_name = "gsbi2_p_clk",
2343 .ops = &clk_ops_branch,
2344 CLK_INIT(gsbi2_p_clk.c),
2345 },
2346};
2347
2348static struct branch_clk gsbi3_p_clk = {
2349 .b = {
2350 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
2351 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002352 .hwcg_reg = GSBIn_HCLK_CTL_REG(3),
2353 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002354 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2355 .halt_bit = 3,
2356 },
2357 .c = {
2358 .dbg_name = "gsbi3_p_clk",
2359 .ops = &clk_ops_branch,
2360 CLK_INIT(gsbi3_p_clk.c),
2361 },
2362};
2363
2364static struct branch_clk gsbi4_p_clk = {
2365 .b = {
2366 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
2367 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002368 .hwcg_reg = GSBIn_HCLK_CTL_REG(4),
2369 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002370 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2371 .halt_bit = 27,
2372 },
2373 .c = {
2374 .dbg_name = "gsbi4_p_clk",
2375 .ops = &clk_ops_branch,
2376 CLK_INIT(gsbi4_p_clk.c),
2377 },
2378};
2379
2380static struct branch_clk gsbi5_p_clk = {
2381 .b = {
2382 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
2383 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002384 .hwcg_reg = GSBIn_HCLK_CTL_REG(5),
2385 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002386 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2387 .halt_bit = 23,
2388 },
2389 .c = {
2390 .dbg_name = "gsbi5_p_clk",
2391 .ops = &clk_ops_branch,
2392 CLK_INIT(gsbi5_p_clk.c),
2393 },
2394};
2395
2396static struct branch_clk gsbi6_p_clk = {
2397 .b = {
2398 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
2399 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002400 .hwcg_reg = GSBIn_HCLK_CTL_REG(6),
2401 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002402 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2403 .halt_bit = 19,
2404 },
2405 .c = {
2406 .dbg_name = "gsbi6_p_clk",
2407 .ops = &clk_ops_branch,
2408 CLK_INIT(gsbi6_p_clk.c),
2409 },
2410};
2411
2412static struct branch_clk gsbi7_p_clk = {
2413 .b = {
2414 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
2415 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002416 .hwcg_reg = GSBIn_HCLK_CTL_REG(7),
2417 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002418 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2419 .halt_bit = 15,
2420 },
2421 .c = {
2422 .dbg_name = "gsbi7_p_clk",
2423 .ops = &clk_ops_branch,
2424 CLK_INIT(gsbi7_p_clk.c),
2425 },
2426};
2427
2428static struct branch_clk gsbi8_p_clk = {
2429 .b = {
2430 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
2431 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002432 .hwcg_reg = GSBIn_HCLK_CTL_REG(8),
2433 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002434 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2435 .halt_bit = 11,
2436 },
2437 .c = {
2438 .dbg_name = "gsbi8_p_clk",
2439 .ops = &clk_ops_branch,
2440 CLK_INIT(gsbi8_p_clk.c),
2441 },
2442};
2443
2444static struct branch_clk gsbi9_p_clk = {
2445 .b = {
2446 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
2447 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002448 .hwcg_reg = GSBIn_HCLK_CTL_REG(9),
2449 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002450 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2451 .halt_bit = 7,
2452 },
2453 .c = {
2454 .dbg_name = "gsbi9_p_clk",
2455 .ops = &clk_ops_branch,
2456 CLK_INIT(gsbi9_p_clk.c),
2457 },
2458};
2459
2460static struct branch_clk gsbi10_p_clk = {
2461 .b = {
2462 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
2463 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002464 .hwcg_reg = GSBIn_HCLK_CTL_REG(10),
2465 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002466 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2467 .halt_bit = 3,
2468 },
2469 .c = {
2470 .dbg_name = "gsbi10_p_clk",
2471 .ops = &clk_ops_branch,
2472 CLK_INIT(gsbi10_p_clk.c),
2473 },
2474};
2475
2476static struct branch_clk gsbi11_p_clk = {
2477 .b = {
2478 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
2479 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002480 .hwcg_reg = GSBIn_HCLK_CTL_REG(11),
2481 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002482 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2483 .halt_bit = 18,
2484 },
2485 .c = {
2486 .dbg_name = "gsbi11_p_clk",
2487 .ops = &clk_ops_branch,
2488 CLK_INIT(gsbi11_p_clk.c),
2489 },
2490};
2491
2492static struct branch_clk gsbi12_p_clk = {
2493 .b = {
2494 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
2495 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002496 .hwcg_reg = GSBIn_HCLK_CTL_REG(12),
2497 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002498 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2499 .halt_bit = 14,
2500 },
2501 .c = {
2502 .dbg_name = "gsbi12_p_clk",
2503 .ops = &clk_ops_branch,
2504 CLK_INIT(gsbi12_p_clk.c),
2505 },
2506};
2507
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002508static struct branch_clk qdss_p_clk = {
2509 .b = {
2510 .ctl_reg = QDSS_HCLK_CTL_REG,
2511 .en_mask = BIT(4),
2512 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2513 .halt_bit = 11,
2514 .halt_check = HALT_VOTED,
2515 .reset_reg = QDSS_RESETS_REG,
2516 .reset_mask = BIT(2),
2517 },
2518 .c = {
2519 .dbg_name = "qdss_p_clk",
2520 .ops = &clk_ops_branch,
2521 CLK_INIT(qdss_p_clk.c),
Tianyi Gou41515e22011-09-01 19:37:43 -07002522 }
2523};
2524
2525static struct branch_clk sata_phy_cfg_clk = {
2526 .b = {
2527 .ctl_reg = SATA_PHY_CFG_CLK_CTL_REG,
2528 .en_mask = BIT(4),
2529 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2530 .halt_bit = 12,
2531 },
2532 .c = {
2533 .dbg_name = "sata_phy_cfg_clk",
2534 .ops = &clk_ops_branch,
2535 CLK_INIT(sata_phy_cfg_clk.c),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002536 },
2537};
2538
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002539static struct branch_clk tsif_p_clk = {
2540 .b = {
2541 .ctl_reg = TSIF_HCLK_CTL_REG,
2542 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002543 .hwcg_reg = TSIF_HCLK_CTL_REG,
2544 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002545 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2546 .halt_bit = 7,
2547 },
2548 .c = {
2549 .dbg_name = "tsif_p_clk",
2550 .ops = &clk_ops_branch,
2551 CLK_INIT(tsif_p_clk.c),
2552 },
2553};
2554
2555static struct branch_clk usb_fs1_p_clk = {
2556 .b = {
2557 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
2558 .en_mask = BIT(4),
2559 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2560 .halt_bit = 17,
2561 },
2562 .c = {
2563 .dbg_name = "usb_fs1_p_clk",
2564 .ops = &clk_ops_branch,
2565 CLK_INIT(usb_fs1_p_clk.c),
2566 },
2567};
2568
2569static struct branch_clk usb_fs2_p_clk = {
2570 .b = {
2571 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
2572 .en_mask = BIT(4),
2573 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2574 .halt_bit = 14,
2575 },
2576 .c = {
2577 .dbg_name = "usb_fs2_p_clk",
2578 .ops = &clk_ops_branch,
2579 CLK_INIT(usb_fs2_p_clk.c),
2580 },
2581};
2582
2583static struct branch_clk usb_hs1_p_clk = {
2584 .b = {
2585 .ctl_reg = USB_HS1_HCLK_CTL_REG,
2586 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002587 .hwcg_reg = USB_HS1_HCLK_CTL_REG,
2588 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002589 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2590 .halt_bit = 1,
2591 },
2592 .c = {
2593 .dbg_name = "usb_hs1_p_clk",
2594 .ops = &clk_ops_branch,
2595 CLK_INIT(usb_hs1_p_clk.c),
2596 },
2597};
2598
Tianyi Gou41515e22011-09-01 19:37:43 -07002599static struct branch_clk usb_hs3_p_clk = {
2600 .b = {
2601 .ctl_reg = USB_HS3_HCLK_CTL_REG,
2602 .en_mask = BIT(4),
2603 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2604 .halt_bit = 31,
2605 },
2606 .c = {
2607 .dbg_name = "usb_hs3_p_clk",
2608 .ops = &clk_ops_branch,
2609 CLK_INIT(usb_hs3_p_clk.c),
2610 },
2611};
2612
2613static struct branch_clk usb_hs4_p_clk = {
2614 .b = {
2615 .ctl_reg = USB_HS4_HCLK_CTL_REG,
2616 .en_mask = BIT(4),
2617 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2618 .halt_bit = 7,
2619 },
2620 .c = {
2621 .dbg_name = "usb_hs4_p_clk",
2622 .ops = &clk_ops_branch,
2623 CLK_INIT(usb_hs4_p_clk.c),
2624 },
2625};
2626
Stephen Boyd94625ef2011-07-12 17:06:01 -07002627static struct branch_clk usb_hsic_p_clk = {
2628 .b = {
2629 .ctl_reg = USB_HSIC_HCLK_CTL_REG,
2630 .en_mask = BIT(4),
2631 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2632 .halt_bit = 28,
2633 },
2634 .c = {
2635 .dbg_name = "usb_hsic_p_clk",
2636 .ops = &clk_ops_branch,
2637 CLK_INIT(usb_hsic_p_clk.c),
2638 },
2639};
2640
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002641static struct branch_clk sdc1_p_clk = {
2642 .b = {
2643 .ctl_reg = SDCn_HCLK_CTL_REG(1),
2644 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002645 .hwcg_reg = SDCn_HCLK_CTL_REG(1),
2646 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002647 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2648 .halt_bit = 11,
2649 },
2650 .c = {
2651 .dbg_name = "sdc1_p_clk",
2652 .ops = &clk_ops_branch,
2653 CLK_INIT(sdc1_p_clk.c),
2654 },
2655};
2656
2657static struct branch_clk sdc2_p_clk = {
2658 .b = {
2659 .ctl_reg = SDCn_HCLK_CTL_REG(2),
2660 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002661 .hwcg_reg = SDCn_HCLK_CTL_REG(2),
2662 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002663 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2664 .halt_bit = 10,
2665 },
2666 .c = {
2667 .dbg_name = "sdc2_p_clk",
2668 .ops = &clk_ops_branch,
2669 CLK_INIT(sdc2_p_clk.c),
2670 },
2671};
2672
2673static struct branch_clk sdc3_p_clk = {
2674 .b = {
2675 .ctl_reg = SDCn_HCLK_CTL_REG(3),
2676 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002677 .hwcg_reg = SDCn_HCLK_CTL_REG(3),
2678 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002679 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2680 .halt_bit = 9,
2681 },
2682 .c = {
2683 .dbg_name = "sdc3_p_clk",
2684 .ops = &clk_ops_branch,
2685 CLK_INIT(sdc3_p_clk.c),
2686 },
2687};
2688
2689static struct branch_clk sdc4_p_clk = {
2690 .b = {
2691 .ctl_reg = SDCn_HCLK_CTL_REG(4),
2692 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002693 .hwcg_reg = SDCn_HCLK_CTL_REG(4),
2694 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002695 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2696 .halt_bit = 8,
2697 },
2698 .c = {
2699 .dbg_name = "sdc4_p_clk",
2700 .ops = &clk_ops_branch,
2701 CLK_INIT(sdc4_p_clk.c),
2702 },
2703};
2704
2705static struct branch_clk sdc5_p_clk = {
2706 .b = {
2707 .ctl_reg = SDCn_HCLK_CTL_REG(5),
2708 .en_mask = BIT(4),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002709 .hwcg_reg = SDCn_HCLK_CTL_REG(5),
2710 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002711 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2712 .halt_bit = 7,
2713 },
2714 .c = {
2715 .dbg_name = "sdc5_p_clk",
2716 .ops = &clk_ops_branch,
2717 CLK_INIT(sdc5_p_clk.c),
2718 },
2719};
2720
2721/* HW-Voteable Clocks */
2722static struct branch_clk adm0_clk = {
2723 .b = {
2724 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2725 .en_mask = BIT(2),
2726 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2727 .halt_check = HALT_VOTED,
2728 .halt_bit = 14,
2729 },
2730 .c = {
2731 .dbg_name = "adm0_clk",
2732 .ops = &clk_ops_branch,
2733 CLK_INIT(adm0_clk.c),
2734 },
2735};
2736
2737static struct branch_clk adm0_p_clk = {
2738 .b = {
2739 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2740 .en_mask = BIT(3),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002741 .hwcg_reg = ADM0_PBUS_CLK_CTL_REG,
2742 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002743 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2744 .halt_check = HALT_VOTED,
2745 .halt_bit = 13,
2746 },
2747 .c = {
2748 .dbg_name = "adm0_p_clk",
2749 .ops = &clk_ops_branch,
2750 CLK_INIT(adm0_p_clk.c),
2751 },
2752};
2753
2754static struct branch_clk pmic_arb0_p_clk = {
2755 .b = {
2756 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2757 .en_mask = BIT(8),
2758 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2759 .halt_check = HALT_VOTED,
2760 .halt_bit = 22,
2761 },
2762 .c = {
2763 .dbg_name = "pmic_arb0_p_clk",
2764 .ops = &clk_ops_branch,
2765 CLK_INIT(pmic_arb0_p_clk.c),
2766 },
2767};
2768
2769static struct branch_clk pmic_arb1_p_clk = {
2770 .b = {
2771 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2772 .en_mask = BIT(9),
2773 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2774 .halt_check = HALT_VOTED,
2775 .halt_bit = 21,
2776 },
2777 .c = {
2778 .dbg_name = "pmic_arb1_p_clk",
2779 .ops = &clk_ops_branch,
2780 CLK_INIT(pmic_arb1_p_clk.c),
2781 },
2782};
2783
2784static struct branch_clk pmic_ssbi2_clk = {
2785 .b = {
2786 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2787 .en_mask = BIT(7),
2788 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2789 .halt_check = HALT_VOTED,
2790 .halt_bit = 23,
2791 },
2792 .c = {
2793 .dbg_name = "pmic_ssbi2_clk",
2794 .ops = &clk_ops_branch,
2795 CLK_INIT(pmic_ssbi2_clk.c),
2796 },
2797};
2798
2799static struct branch_clk rpm_msg_ram_p_clk = {
2800 .b = {
2801 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2802 .en_mask = BIT(6),
Stephen Boyda52d7e32011-11-10 11:59:00 -08002803 .hwcg_reg = RPM_MSG_RAM_HCLK_CTL_REG,
2804 .hwcg_mask = BIT(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002805 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2806 .halt_check = HALT_VOTED,
2807 .halt_bit = 12,
2808 },
2809 .c = {
2810 .dbg_name = "rpm_msg_ram_p_clk",
2811 .ops = &clk_ops_branch,
2812 CLK_INIT(rpm_msg_ram_p_clk.c),
2813 },
2814};
2815
2816/*
2817 * Multimedia Clocks
2818 */
2819
2820static struct branch_clk amp_clk = {
2821 .b = {
2822 .reset_reg = SW_RESET_CORE_REG,
2823 .reset_mask = BIT(20),
2824 },
2825 .c = {
2826 .dbg_name = "amp_clk",
2827 .ops = &clk_ops_reset,
2828 CLK_INIT(amp_clk.c),
2829 },
2830};
2831
Stephen Boyd94625ef2011-07-12 17:06:01 -07002832#define CLK_CAM(name, n, hb) \
2833 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002834 .b = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002835 .ctl_reg = CAMCLK##n##_CC_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002836 .en_mask = BIT(0), \
2837 .halt_reg = DBG_BUS_VEC_I_REG, \
2838 .halt_bit = hb, \
2839 }, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002840 .ns_reg = CAMCLK##n##_NS_REG, \
2841 .md_reg = CAMCLK##n##_MD_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002842 .root_en_mask = BIT(2), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002843 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002844 .ctl_mask = BM(7, 6), \
2845 .set_rate = set_rate_mnd_8, \
2846 .freq_tbl = clk_tbl_cam, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002847 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002848 .c = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002849 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002850 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002851 VDD_DIG_FMAX_MAP2(LOW, 64000000, NOMINAL, 128000000), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002852 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002853 }, \
2854 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002855#define F_CAM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002856 { \
2857 .freq_hz = f, \
2858 .src_clk = &s##_clk.c, \
2859 .md_val = MD8(8, m, 0, n), \
2860 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2861 .ctl_val = CC(6, n), \
2862 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002863 }
2864static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002865 F_CAM( 0, gnd, 1, 0, 0),
2866 F_CAM( 6000000, pll8, 4, 1, 16),
2867 F_CAM( 8000000, pll8, 4, 1, 12),
2868 F_CAM( 12000000, pll8, 4, 1, 8),
2869 F_CAM( 16000000, pll8, 4, 1, 6),
2870 F_CAM( 19200000, pll8, 4, 1, 5),
2871 F_CAM( 24000000, pll8, 4, 1, 4),
2872 F_CAM( 32000000, pll8, 4, 1, 3),
2873 F_CAM( 48000000, pll8, 4, 1, 2),
2874 F_CAM( 64000000, pll8, 3, 1, 2),
2875 F_CAM( 96000000, pll8, 4, 0, 0),
2876 F_CAM(128000000, pll8, 3, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002877 F_END
2878};
2879
Stephen Boyd94625ef2011-07-12 17:06:01 -07002880static CLK_CAM(cam0_clk, 0, 15);
2881static CLK_CAM(cam1_clk, 1, 16);
2882static CLK_CAM(cam2_clk, 2, 31);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002883
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002884#define F_CSI(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002885 { \
2886 .freq_hz = f, \
2887 .src_clk = &s##_clk.c, \
2888 .md_val = MD8(8, m, 0, n), \
2889 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2890 .ctl_val = CC(6, n), \
2891 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002892 }
2893static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002894 F_CSI( 0, gnd, 1, 0, 0),
Stephen Boyd092fd182011-10-21 15:56:30 -07002895 F_CSI( 27000000, pxo, 1, 0, 0),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002896 F_CSI( 85330000, pll8, 1, 2, 9),
2897 F_CSI(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002898 F_END
2899};
2900
2901static struct rcg_clk csi0_src_clk = {
2902 .ns_reg = CSI0_NS_REG,
2903 .b = {
2904 .ctl_reg = CSI0_CC_REG,
2905 .halt_check = NOCHECK,
2906 },
2907 .md_reg = CSI0_MD_REG,
2908 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002909 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002910 .ctl_mask = BM(7, 6),
2911 .set_rate = set_rate_mnd,
2912 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002913 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002914 .c = {
2915 .dbg_name = "csi0_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002916 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002917 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002918 CLK_INIT(csi0_src_clk.c),
2919 },
2920};
2921
2922static struct branch_clk csi0_clk = {
2923 .b = {
2924 .ctl_reg = CSI0_CC_REG,
2925 .en_mask = BIT(0),
2926 .reset_reg = SW_RESET_CORE_REG,
2927 .reset_mask = BIT(8),
2928 .halt_reg = DBG_BUS_VEC_B_REG,
2929 .halt_bit = 13,
2930 },
2931 .parent = &csi0_src_clk.c,
2932 .c = {
2933 .dbg_name = "csi0_clk",
2934 .ops = &clk_ops_branch,
2935 CLK_INIT(csi0_clk.c),
2936 },
2937};
2938
2939static struct branch_clk csi0_phy_clk = {
2940 .b = {
2941 .ctl_reg = CSI0_CC_REG,
2942 .en_mask = BIT(8),
2943 .reset_reg = SW_RESET_CORE_REG,
2944 .reset_mask = BIT(29),
2945 .halt_reg = DBG_BUS_VEC_I_REG,
2946 .halt_bit = 9,
2947 },
2948 .parent = &csi0_src_clk.c,
2949 .c = {
2950 .dbg_name = "csi0_phy_clk",
2951 .ops = &clk_ops_branch,
2952 CLK_INIT(csi0_phy_clk.c),
2953 },
2954};
2955
2956static struct rcg_clk csi1_src_clk = {
2957 .ns_reg = CSI1_NS_REG,
2958 .b = {
2959 .ctl_reg = CSI1_CC_REG,
2960 .halt_check = NOCHECK,
2961 },
2962 .md_reg = CSI1_MD_REG,
2963 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002964 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002965 .ctl_mask = BM(7, 6),
2966 .set_rate = set_rate_mnd,
2967 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002968 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002969 .c = {
2970 .dbg_name = "csi1_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002971 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002972 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002973 CLK_INIT(csi1_src_clk.c),
2974 },
2975};
2976
2977static struct branch_clk csi1_clk = {
2978 .b = {
2979 .ctl_reg = CSI1_CC_REG,
2980 .en_mask = BIT(0),
2981 .reset_reg = SW_RESET_CORE_REG,
2982 .reset_mask = BIT(18),
2983 .halt_reg = DBG_BUS_VEC_B_REG,
2984 .halt_bit = 14,
2985 },
2986 .parent = &csi1_src_clk.c,
2987 .c = {
2988 .dbg_name = "csi1_clk",
2989 .ops = &clk_ops_branch,
2990 CLK_INIT(csi1_clk.c),
2991 },
2992};
2993
2994static struct branch_clk csi1_phy_clk = {
2995 .b = {
2996 .ctl_reg = CSI1_CC_REG,
2997 .en_mask = BIT(8),
2998 .reset_reg = SW_RESET_CORE_REG,
2999 .reset_mask = BIT(28),
3000 .halt_reg = DBG_BUS_VEC_I_REG,
3001 .halt_bit = 10,
3002 },
3003 .parent = &csi1_src_clk.c,
3004 .c = {
3005 .dbg_name = "csi1_phy_clk",
3006 .ops = &clk_ops_branch,
3007 CLK_INIT(csi1_phy_clk.c),
3008 },
3009};
3010
Stephen Boyd94625ef2011-07-12 17:06:01 -07003011static struct rcg_clk csi2_src_clk = {
3012 .ns_reg = CSI2_NS_REG,
3013 .b = {
3014 .ctl_reg = CSI2_CC_REG,
3015 .halt_check = NOCHECK,
3016 },
3017 .md_reg = CSI2_MD_REG,
3018 .root_en_mask = BIT(2),
3019 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
3020 .ctl_mask = BM(7, 6),
3021 .set_rate = set_rate_mnd,
3022 .freq_tbl = clk_tbl_csi,
3023 .current_freq = &rcg_dummy_freq,
3024 .c = {
3025 .dbg_name = "csi2_src_clk",
3026 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003027 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003028 CLK_INIT(csi2_src_clk.c),
3029 },
3030};
3031
3032static struct branch_clk csi2_clk = {
3033 .b = {
3034 .ctl_reg = CSI2_CC_REG,
3035 .en_mask = BIT(0),
3036 .reset_reg = SW_RESET_CORE2_REG,
3037 .reset_mask = BIT(2),
3038 .halt_reg = DBG_BUS_VEC_B_REG,
3039 .halt_bit = 29,
3040 },
3041 .parent = &csi2_src_clk.c,
3042 .c = {
3043 .dbg_name = "csi2_clk",
3044 .ops = &clk_ops_branch,
3045 CLK_INIT(csi2_clk.c),
3046 },
3047};
3048
3049static struct branch_clk csi2_phy_clk = {
3050 .b = {
3051 .ctl_reg = CSI2_CC_REG,
3052 .en_mask = BIT(8),
3053 .reset_reg = SW_RESET_CORE_REG,
3054 .reset_mask = BIT(31),
3055 .halt_reg = DBG_BUS_VEC_I_REG,
3056 .halt_bit = 29,
3057 },
3058 .parent = &csi2_src_clk.c,
3059 .c = {
3060 .dbg_name = "csi2_phy_clk",
3061 .ops = &clk_ops_branch,
3062 CLK_INIT(csi2_phy_clk.c),
3063 },
3064};
3065
Stephen Boyd092fd182011-10-21 15:56:30 -07003066static struct clk *pix_rdi_mux_map[] = {
3067 [0] = &csi0_clk.c,
3068 [1] = &csi1_clk.c,
3069 [2] = &csi2_clk.c,
3070 NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003071};
3072
Stephen Boyd092fd182011-10-21 15:56:30 -07003073struct pix_rdi_clk {
3074 bool enabled;
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003075 unsigned long cur_rate;
Stephen Boyd092fd182011-10-21 15:56:30 -07003076
3077 void __iomem *const s_reg;
3078 u32 s_mask;
3079
3080 void __iomem *const s2_reg;
3081 u32 s2_mask;
3082
3083 struct branch b;
3084 struct clk c;
3085};
3086
3087static inline struct pix_rdi_clk *to_pix_rdi_clk(struct clk *clk)
3088{
3089 return container_of(clk, struct pix_rdi_clk, c);
3090}
3091
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003092static int pix_rdi_clk_set_rate(struct clk *c, unsigned long rate)
Stephen Boyd092fd182011-10-21 15:56:30 -07003093{
3094 int ret, i;
3095 u32 reg;
3096 unsigned long flags;
3097 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3098 struct clk **mux_map = pix_rdi_mux_map;
3099
3100 /*
3101 * These clocks select three inputs via two muxes. One mux selects
3102 * between csi0 and csi1 and the second mux selects between that mux's
3103 * output and csi2. The source and destination selections for each
3104 * mux must be clocking for the switch to succeed so just turn on
3105 * all three sources because it's easier than figuring out what source
3106 * needs to be on at what time.
3107 */
3108 for (i = 0; mux_map[i]; i++) {
3109 ret = clk_enable(mux_map[i]);
3110 if (ret)
3111 goto err;
3112 }
3113 if (rate >= i) {
3114 ret = -EINVAL;
3115 goto err;
3116 }
3117 /* Keep the new source on when switching inputs of an enabled clock */
3118 if (clk->enabled) {
3119 clk_disable(mux_map[clk->cur_rate]);
3120 clk_enable(mux_map[rate]);
3121 }
3122 spin_lock_irqsave(&local_clock_reg_lock, flags);
3123 reg = readl_relaxed(clk->s2_reg);
3124 reg &= ~clk->s2_mask;
3125 reg |= rate == 2 ? clk->s2_mask : 0;
3126 writel_relaxed(reg, clk->s2_reg);
3127 /*
3128 * Wait at least 6 cycles of slowest clock
3129 * for the glitch-free MUX to fully switch sources.
3130 */
3131 mb();
3132 udelay(1);
3133 reg = readl_relaxed(clk->s_reg);
3134 reg &= ~clk->s_mask;
3135 reg |= rate == 1 ? clk->s_mask : 0;
3136 writel_relaxed(reg, clk->s_reg);
3137 /*
3138 * Wait at least 6 cycles of slowest clock
3139 * for the glitch-free MUX to fully switch sources.
3140 */
3141 mb();
3142 udelay(1);
3143 clk->cur_rate = rate;
3144 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3145err:
3146 for (i--; i >= 0; i--)
3147 clk_disable(mux_map[i]);
3148
3149 return 0;
3150}
3151
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003152static unsigned long pix_rdi_clk_get_rate(struct clk *c)
Stephen Boyd092fd182011-10-21 15:56:30 -07003153{
3154 return to_pix_rdi_clk(c)->cur_rate;
3155}
3156
3157static int pix_rdi_clk_enable(struct clk *c)
3158{
3159 unsigned long flags;
3160 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3161
3162 spin_lock_irqsave(&local_clock_reg_lock, flags);
3163 __branch_clk_enable_reg(&clk->b, clk->c.dbg_name);
3164 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3165 clk->enabled = true;
3166
3167 return 0;
3168}
3169
3170static void pix_rdi_clk_disable(struct clk *c)
3171{
3172 unsigned long flags;
3173 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3174
3175 spin_lock_irqsave(&local_clock_reg_lock, flags);
3176 __branch_clk_disable_reg(&clk->b, clk->c.dbg_name);
3177 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3178 clk->enabled = false;
3179}
3180
3181static int pix_rdi_clk_reset(struct clk *clk, enum clk_reset_action action)
3182{
3183 return branch_reset(&to_pix_rdi_clk(clk)->b, action);
3184}
3185
3186static struct clk *pix_rdi_clk_get_parent(struct clk *c)
3187{
3188 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3189
3190 return pix_rdi_mux_map[clk->cur_rate];
3191}
3192
3193static int pix_rdi_clk_list_rate(struct clk *c, unsigned n)
3194{
3195 if (pix_rdi_mux_map[n])
3196 return n;
3197 return -ENXIO;
3198}
3199
3200static int pix_rdi_clk_handoff(struct clk *c)
3201{
3202 u32 reg;
3203 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3204
3205 reg = readl_relaxed(clk->s_reg);
3206 clk->cur_rate = reg & clk->s_mask ? 1 : 0;
3207 reg = readl_relaxed(clk->s2_reg);
3208 clk->cur_rate = reg & clk->s2_mask ? 2 : clk->cur_rate;
3209 return 0;
3210}
3211
3212static struct clk_ops clk_ops_pix_rdi_8960 = {
3213 .enable = pix_rdi_clk_enable,
3214 .disable = pix_rdi_clk_disable,
3215 .auto_off = pix_rdi_clk_disable,
3216 .handoff = pix_rdi_clk_handoff,
3217 .set_rate = pix_rdi_clk_set_rate,
3218 .get_rate = pix_rdi_clk_get_rate,
3219 .list_rate = pix_rdi_clk_list_rate,
3220 .reset = pix_rdi_clk_reset,
3221 .is_local = local_clk_is_local,
3222 .get_parent = pix_rdi_clk_get_parent,
3223};
3224
3225static struct pix_rdi_clk csi_pix_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003226 .b = {
3227 .ctl_reg = MISC_CC_REG,
3228 .en_mask = BIT(26),
3229 .halt_check = DELAY,
3230 .reset_reg = SW_RESET_CORE_REG,
3231 .reset_mask = BIT(26),
3232 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003233 .s_reg = MISC_CC_REG,
3234 .s_mask = BIT(25),
3235 .s2_reg = MISC_CC3_REG,
3236 .s2_mask = BIT(13),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003237 .c = {
3238 .dbg_name = "csi_pix_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003239 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003240 CLK_INIT(csi_pix_clk.c),
3241 },
3242};
3243
Stephen Boyd092fd182011-10-21 15:56:30 -07003244static struct pix_rdi_clk csi_pix1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003245 .b = {
3246 .ctl_reg = MISC_CC3_REG,
3247 .en_mask = BIT(10),
3248 .halt_check = DELAY,
3249 .reset_reg = SW_RESET_CORE_REG,
3250 .reset_mask = BIT(30),
3251 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003252 .s_reg = MISC_CC3_REG,
3253 .s_mask = BIT(8),
3254 .s2_reg = MISC_CC3_REG,
3255 .s2_mask = BIT(9),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003256 .c = {
3257 .dbg_name = "csi_pix1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003258 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003259 CLK_INIT(csi_pix1_clk.c),
3260 },
3261};
3262
Stephen Boyd092fd182011-10-21 15:56:30 -07003263static struct pix_rdi_clk csi_rdi_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003264 .b = {
3265 .ctl_reg = MISC_CC_REG,
3266 .en_mask = BIT(13),
3267 .halt_check = DELAY,
3268 .reset_reg = SW_RESET_CORE_REG,
3269 .reset_mask = BIT(27),
3270 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003271 .s_reg = MISC_CC_REG,
3272 .s_mask = BIT(12),
3273 .s2_reg = MISC_CC3_REG,
3274 .s2_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003275 .c = {
3276 .dbg_name = "csi_rdi_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003277 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003278 CLK_INIT(csi_rdi_clk.c),
3279 },
3280};
3281
Stephen Boyd092fd182011-10-21 15:56:30 -07003282static struct pix_rdi_clk csi_rdi1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003283 .b = {
3284 .ctl_reg = MISC_CC3_REG,
3285 .en_mask = BIT(2),
3286 .halt_check = DELAY,
3287 .reset_reg = SW_RESET_CORE2_REG,
3288 .reset_mask = BIT(1),
3289 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003290 .s_reg = MISC_CC3_REG,
3291 .s_mask = BIT(0),
3292 .s2_reg = MISC_CC3_REG,
3293 .s2_mask = BIT(1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003294 .c = {
3295 .dbg_name = "csi_rdi1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003296 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003297 CLK_INIT(csi_rdi1_clk.c),
3298 },
3299};
3300
Stephen Boyd092fd182011-10-21 15:56:30 -07003301static struct pix_rdi_clk csi_rdi2_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003302 .b = {
3303 .ctl_reg = MISC_CC3_REG,
3304 .en_mask = BIT(6),
3305 .halt_check = DELAY,
3306 .reset_reg = SW_RESET_CORE2_REG,
3307 .reset_mask = BIT(0),
3308 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003309 .s_reg = MISC_CC3_REG,
3310 .s_mask = BIT(4),
3311 .s2_reg = MISC_CC3_REG,
3312 .s2_mask = BIT(5),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003313 .c = {
3314 .dbg_name = "csi_rdi2_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003315 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003316 CLK_INIT(csi_rdi2_clk.c),
3317 },
3318};
3319
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003320#define F_CSI_PHYTIMER(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003321 { \
3322 .freq_hz = f, \
3323 .src_clk = &s##_clk.c, \
3324 .md_val = MD8(8, m, 0, n), \
3325 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3326 .ctl_val = CC(6, n), \
3327 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003328 }
3329static struct clk_freq_tbl clk_tbl_csi_phytimer[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003330 F_CSI_PHYTIMER( 0, gnd, 1, 0, 0),
3331 F_CSI_PHYTIMER( 85330000, pll8, 1, 2, 9),
3332 F_CSI_PHYTIMER(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003333 F_END
3334};
3335
3336static struct rcg_clk csiphy_timer_src_clk = {
3337 .ns_reg = CSIPHYTIMER_NS_REG,
3338 .b = {
3339 .ctl_reg = CSIPHYTIMER_CC_REG,
3340 .halt_check = NOCHECK,
3341 },
3342 .md_reg = CSIPHYTIMER_MD_REG,
3343 .root_en_mask = BIT(2),
3344 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
3345 .ctl_mask = BM(7, 6),
3346 .set_rate = set_rate_mnd_8,
3347 .freq_tbl = clk_tbl_csi_phytimer,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003348 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003349 .c = {
3350 .dbg_name = "csiphy_timer_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003351 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003352 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003353 CLK_INIT(csiphy_timer_src_clk.c),
3354 },
3355};
3356
3357static struct branch_clk csi0phy_timer_clk = {
3358 .b = {
3359 .ctl_reg = CSIPHYTIMER_CC_REG,
3360 .en_mask = BIT(0),
3361 .halt_reg = DBG_BUS_VEC_I_REG,
3362 .halt_bit = 17,
3363 },
3364 .parent = &csiphy_timer_src_clk.c,
3365 .c = {
3366 .dbg_name = "csi0phy_timer_clk",
3367 .ops = &clk_ops_branch,
3368 CLK_INIT(csi0phy_timer_clk.c),
3369 },
3370};
3371
3372static struct branch_clk csi1phy_timer_clk = {
3373 .b = {
3374 .ctl_reg = CSIPHYTIMER_CC_REG,
3375 .en_mask = BIT(9),
3376 .halt_reg = DBG_BUS_VEC_I_REG,
3377 .halt_bit = 18,
3378 },
3379 .parent = &csiphy_timer_src_clk.c,
3380 .c = {
3381 .dbg_name = "csi1phy_timer_clk",
3382 .ops = &clk_ops_branch,
3383 CLK_INIT(csi1phy_timer_clk.c),
3384 },
3385};
3386
Stephen Boyd94625ef2011-07-12 17:06:01 -07003387static struct branch_clk csi2phy_timer_clk = {
3388 .b = {
3389 .ctl_reg = CSIPHYTIMER_CC_REG,
3390 .en_mask = BIT(11),
3391 .halt_reg = DBG_BUS_VEC_I_REG,
3392 .halt_bit = 30,
3393 },
3394 .parent = &csiphy_timer_src_clk.c,
3395 .c = {
3396 .dbg_name = "csi2phy_timer_clk",
3397 .ops = &clk_ops_branch,
3398 CLK_INIT(csi2phy_timer_clk.c),
3399 },
3400};
3401
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003402#define F_DSI(d) \
3403 { \
3404 .freq_hz = d, \
3405 .ns_val = BVAL(15, 12, (d-1)), \
3406 }
3407/*
3408 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
3409 * without this clock driver knowing. So, overload the clk_set_rate() to set
3410 * the divider (1 to 16) of the clock with respect to the PLL rate.
3411 */
3412static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
3413 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
3414 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
3415 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
3416 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
3417 F_END
3418};
3419
3420static struct rcg_clk dsi1_byte_clk = {
3421 .b = {
3422 .ctl_reg = DSI1_BYTE_CC_REG,
3423 .en_mask = BIT(0),
3424 .reset_reg = SW_RESET_CORE_REG,
3425 .reset_mask = BIT(7),
3426 .halt_reg = DBG_BUS_VEC_B_REG,
3427 .halt_bit = 21,
3428 },
3429 .ns_reg = DSI1_BYTE_NS_REG,
3430 .root_en_mask = BIT(2),
3431 .ns_mask = BM(15, 12),
3432 .set_rate = set_rate_nop,
3433 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003434 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003435 .c = {
3436 .dbg_name = "dsi1_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003437 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003438 CLK_INIT(dsi1_byte_clk.c),
3439 },
3440};
3441
3442static struct rcg_clk dsi2_byte_clk = {
3443 .b = {
3444 .ctl_reg = DSI2_BYTE_CC_REG,
3445 .en_mask = BIT(0),
3446 .reset_reg = SW_RESET_CORE_REG,
3447 .reset_mask = BIT(25),
3448 .halt_reg = DBG_BUS_VEC_B_REG,
3449 .halt_bit = 20,
3450 },
3451 .ns_reg = DSI2_BYTE_NS_REG,
3452 .root_en_mask = BIT(2),
3453 .ns_mask = BM(15, 12),
3454 .set_rate = set_rate_nop,
3455 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003456 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003457 .c = {
3458 .dbg_name = "dsi2_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003459 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003460 CLK_INIT(dsi2_byte_clk.c),
3461 },
3462};
3463
3464static struct rcg_clk dsi1_esc_clk = {
3465 .b = {
3466 .ctl_reg = DSI1_ESC_CC_REG,
3467 .en_mask = BIT(0),
3468 .reset_reg = SW_RESET_CORE_REG,
3469 .halt_reg = DBG_BUS_VEC_I_REG,
3470 .halt_bit = 1,
3471 },
3472 .ns_reg = DSI1_ESC_NS_REG,
3473 .root_en_mask = BIT(2),
3474 .ns_mask = BM(15, 12),
3475 .set_rate = set_rate_nop,
3476 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003477 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003478 .c = {
3479 .dbg_name = "dsi1_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003480 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003481 CLK_INIT(dsi1_esc_clk.c),
3482 },
3483};
3484
3485static struct rcg_clk dsi2_esc_clk = {
3486 .b = {
3487 .ctl_reg = DSI2_ESC_CC_REG,
3488 .en_mask = BIT(0),
3489 .halt_reg = DBG_BUS_VEC_I_REG,
3490 .halt_bit = 3,
3491 },
3492 .ns_reg = DSI2_ESC_NS_REG,
3493 .root_en_mask = BIT(2),
3494 .ns_mask = BM(15, 12),
3495 .set_rate = set_rate_nop,
3496 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003497 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003498 .c = {
3499 .dbg_name = "dsi2_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003500 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003501 CLK_INIT(dsi2_esc_clk.c),
3502 },
3503};
3504
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003505#define F_GFX2D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003506 { \
3507 .freq_hz = f, \
3508 .src_clk = &s##_clk.c, \
3509 .md_val = MD4(4, m, 0, n), \
3510 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
3511 .ctl_val = CC_BANKED(9, 6, n), \
3512 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003513 }
3514static struct clk_freq_tbl clk_tbl_gfx2d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003515 F_GFX2D( 0, gnd, 0, 0),
3516 F_GFX2D( 27000000, pxo, 0, 0),
3517 F_GFX2D( 48000000, pll8, 1, 8),
3518 F_GFX2D( 54857000, pll8, 1, 7),
3519 F_GFX2D( 64000000, pll8, 1, 6),
3520 F_GFX2D( 76800000, pll8, 1, 5),
3521 F_GFX2D( 96000000, pll8, 1, 4),
3522 F_GFX2D(128000000, pll8, 1, 3),
3523 F_GFX2D(145455000, pll2, 2, 11),
3524 F_GFX2D(160000000, pll2, 1, 5),
3525 F_GFX2D(177778000, pll2, 2, 9),
3526 F_GFX2D(200000000, pll2, 1, 4),
3527 F_GFX2D(228571000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003528 F_END
3529};
3530
3531static struct bank_masks bmnd_info_gfx2d0 = {
3532 .bank_sel_mask = BIT(11),
3533 .bank0_mask = {
3534 .md_reg = GFX2D0_MD0_REG,
3535 .ns_mask = BM(23, 20) | BM(5, 3),
3536 .rst_mask = BIT(25),
3537 .mnd_en_mask = BIT(8),
3538 .mode_mask = BM(10, 9),
3539 },
3540 .bank1_mask = {
3541 .md_reg = GFX2D0_MD1_REG,
3542 .ns_mask = BM(19, 16) | BM(2, 0),
3543 .rst_mask = BIT(24),
3544 .mnd_en_mask = BIT(5),
3545 .mode_mask = BM(7, 6),
3546 },
3547};
3548
3549static struct rcg_clk gfx2d0_clk = {
3550 .b = {
3551 .ctl_reg = GFX2D0_CC_REG,
3552 .en_mask = BIT(0),
3553 .reset_reg = SW_RESET_CORE_REG,
3554 .reset_mask = BIT(14),
3555 .halt_reg = DBG_BUS_VEC_A_REG,
3556 .halt_bit = 9,
3557 },
3558 .ns_reg = GFX2D0_NS_REG,
3559 .root_en_mask = BIT(2),
3560 .set_rate = set_rate_mnd_banked,
3561 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003562 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003563 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003564 .c = {
3565 .dbg_name = "gfx2d0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003566 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003567 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3568 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003569 CLK_INIT(gfx2d0_clk.c),
3570 },
3571};
3572
3573static struct bank_masks bmnd_info_gfx2d1 = {
3574 .bank_sel_mask = BIT(11),
3575 .bank0_mask = {
3576 .md_reg = GFX2D1_MD0_REG,
3577 .ns_mask = BM(23, 20) | BM(5, 3),
3578 .rst_mask = BIT(25),
3579 .mnd_en_mask = BIT(8),
3580 .mode_mask = BM(10, 9),
3581 },
3582 .bank1_mask = {
3583 .md_reg = GFX2D1_MD1_REG,
3584 .ns_mask = BM(19, 16) | BM(2, 0),
3585 .rst_mask = BIT(24),
3586 .mnd_en_mask = BIT(5),
3587 .mode_mask = BM(7, 6),
3588 },
3589};
3590
3591static struct rcg_clk gfx2d1_clk = {
3592 .b = {
3593 .ctl_reg = GFX2D1_CC_REG,
3594 .en_mask = BIT(0),
3595 .reset_reg = SW_RESET_CORE_REG,
3596 .reset_mask = BIT(13),
3597 .halt_reg = DBG_BUS_VEC_A_REG,
3598 .halt_bit = 14,
3599 },
3600 .ns_reg = GFX2D1_NS_REG,
3601 .root_en_mask = BIT(2),
3602 .set_rate = set_rate_mnd_banked,
3603 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003604 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003605 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003606 .c = {
3607 .dbg_name = "gfx2d1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003608 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003609 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3610 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003611 CLK_INIT(gfx2d1_clk.c),
3612 },
3613};
3614
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003615#define F_GFX3D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003616 { \
3617 .freq_hz = f, \
3618 .src_clk = &s##_clk.c, \
3619 .md_val = MD4(4, m, 0, n), \
3620 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3621 .ctl_val = CC_BANKED(9, 6, n), \
3622 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003623 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003624
3625static struct clk_freq_tbl clk_tbl_gfx3d_8960[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003626 F_GFX3D( 0, gnd, 0, 0),
3627 F_GFX3D( 27000000, pxo, 0, 0),
3628 F_GFX3D( 48000000, pll8, 1, 8),
3629 F_GFX3D( 54857000, pll8, 1, 7),
3630 F_GFX3D( 64000000, pll8, 1, 6),
3631 F_GFX3D( 76800000, pll8, 1, 5),
3632 F_GFX3D( 96000000, pll8, 1, 4),
3633 F_GFX3D(128000000, pll8, 1, 3),
3634 F_GFX3D(145455000, pll2, 2, 11),
3635 F_GFX3D(160000000, pll2, 1, 5),
3636 F_GFX3D(177778000, pll2, 2, 9),
3637 F_GFX3D(200000000, pll2, 1, 4),
3638 F_GFX3D(228571000, pll2, 2, 7),
3639 F_GFX3D(266667000, pll2, 1, 3),
3640 F_GFX3D(320000000, pll2, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003641 F_END
3642};
3643
Tianyi Gou41515e22011-09-01 19:37:43 -07003644static struct clk_freq_tbl clk_tbl_gfx3d_8960_v2[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003645 F_GFX3D( 0, gnd, 0, 0),
3646 F_GFX3D( 27000000, pxo, 0, 0),
3647 F_GFX3D( 48000000, pll8, 1, 8),
3648 F_GFX3D( 54857000, pll8, 1, 7),
3649 F_GFX3D( 64000000, pll8, 1, 6),
3650 F_GFX3D( 76800000, pll8, 1, 5),
3651 F_GFX3D( 96000000, pll8, 1, 4),
3652 F_GFX3D(128000000, pll8, 1, 3),
3653 F_GFX3D(145455000, pll2, 2, 11),
3654 F_GFX3D(160000000, pll2, 1, 5),
3655 F_GFX3D(177778000, pll2, 2, 9),
3656 F_GFX3D(200000000, pll2, 1, 4),
3657 F_GFX3D(228571000, pll2, 2, 7),
3658 F_GFX3D(266667000, pll2, 1, 3),
3659 F_GFX3D(300000000, pll3, 1, 4),
3660 F_GFX3D(320000000, pll2, 2, 5),
3661 F_GFX3D(400000000, pll2, 1, 2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003662 F_END
3663};
3664
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003665static unsigned long fmax_gfx3d_8960_v2[MAX_VDD_LEVELS] __initdata = {
3666 [VDD_DIG_LOW] = 128000000,
3667 [VDD_DIG_NOMINAL] = 300000000,
3668 [VDD_DIG_HIGH] = 400000000
3669};
3670
Tianyi Gou41515e22011-09-01 19:37:43 -07003671static struct clk_freq_tbl clk_tbl_gfx3d_8064[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003672 F_GFX3D( 0, gnd, 0, 0),
3673 F_GFX3D( 27000000, pxo, 0, 0),
3674 F_GFX3D( 48000000, pll8, 1, 8),
3675 F_GFX3D( 54857000, pll8, 1, 7),
3676 F_GFX3D( 64000000, pll8, 1, 6),
3677 F_GFX3D( 76800000, pll8, 1, 5),
3678 F_GFX3D( 96000000, pll8, 1, 4),
3679 F_GFX3D(128000000, pll8, 1, 3),
3680 F_GFX3D(145455000, pll2, 2, 11),
3681 F_GFX3D(160000000, pll2, 1, 5),
3682 F_GFX3D(177778000, pll2, 2, 9),
3683 F_GFX3D(200000000, pll2, 1, 4),
3684 F_GFX3D(228571000, pll2, 2, 7),
3685 F_GFX3D(266667000, pll2, 1, 3),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07003686 F_GFX3D(325000000, pll15, 1, 3),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003687 F_GFX3D(400000000, pll2, 1, 2),
Tianyi Gou41515e22011-09-01 19:37:43 -07003688 F_END
3689};
3690
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003691static unsigned long fmax_gfx3d_8064[MAX_VDD_LEVELS] __initdata = {
3692 [VDD_DIG_LOW] = 128000000,
3693 [VDD_DIG_NOMINAL] = 325000000,
3694 [VDD_DIG_HIGH] = 400000000
3695};
3696
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003697static struct bank_masks bmnd_info_gfx3d = {
3698 .bank_sel_mask = BIT(11),
3699 .bank0_mask = {
3700 .md_reg = GFX3D_MD0_REG,
3701 .ns_mask = BM(21, 18) | BM(5, 3),
3702 .rst_mask = BIT(23),
3703 .mnd_en_mask = BIT(8),
3704 .mode_mask = BM(10, 9),
3705 },
3706 .bank1_mask = {
3707 .md_reg = GFX3D_MD1_REG,
3708 .ns_mask = BM(17, 14) | BM(2, 0),
3709 .rst_mask = BIT(22),
3710 .mnd_en_mask = BIT(5),
3711 .mode_mask = BM(7, 6),
3712 },
3713};
3714
3715static struct rcg_clk gfx3d_clk = {
3716 .b = {
3717 .ctl_reg = GFX3D_CC_REG,
3718 .en_mask = BIT(0),
3719 .reset_reg = SW_RESET_CORE_REG,
3720 .reset_mask = BIT(12),
3721 .halt_reg = DBG_BUS_VEC_A_REG,
3722 .halt_bit = 4,
3723 },
3724 .ns_reg = GFX3D_NS_REG,
3725 .root_en_mask = BIT(2),
3726 .set_rate = set_rate_mnd_banked,
Tianyi Gou41515e22011-09-01 19:37:43 -07003727 .freq_tbl = clk_tbl_gfx3d_8960,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003728 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003729 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003730 .c = {
3731 .dbg_name = "gfx3d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003732 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003733 VDD_DIG_FMAX_MAP3(LOW, 128000000, NOMINAL, 266667000,
3734 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003735 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003736 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003737 },
3738};
3739
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003740#define F_VCAP(f, s, m, n) \
Tianyi Gou621f8742011-09-01 21:45:01 -07003741 { \
3742 .freq_hz = f, \
3743 .src_clk = &s##_clk.c, \
3744 .md_val = MD4(4, m, 0, n), \
3745 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3746 .ctl_val = CC_BANKED(9, 6, n), \
3747 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Tianyi Gou621f8742011-09-01 21:45:01 -07003748 }
3749
3750static struct clk_freq_tbl clk_tbl_vcap[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003751 F_VCAP( 0, gnd, 0, 0),
3752 F_VCAP( 27000000, pxo, 0, 0),
3753 F_VCAP( 54860000, pll8, 1, 7),
3754 F_VCAP( 64000000, pll8, 1, 6),
3755 F_VCAP( 76800000, pll8, 1, 5),
3756 F_VCAP(128000000, pll8, 1, 3),
3757 F_VCAP(160000000, pll2, 1, 5),
3758 F_VCAP(200000000, pll2, 1, 4),
Tianyi Gou621f8742011-09-01 21:45:01 -07003759 F_END
3760};
3761
3762static struct bank_masks bmnd_info_vcap = {
3763 .bank_sel_mask = BIT(11),
3764 .bank0_mask = {
3765 .md_reg = VCAP_MD0_REG,
3766 .ns_mask = BM(21, 18) | BM(5, 3),
3767 .rst_mask = BIT(23),
3768 .mnd_en_mask = BIT(8),
3769 .mode_mask = BM(10, 9),
3770 },
3771 .bank1_mask = {
3772 .md_reg = VCAP_MD1_REG,
3773 .ns_mask = BM(17, 14) | BM(2, 0),
3774 .rst_mask = BIT(22),
3775 .mnd_en_mask = BIT(5),
3776 .mode_mask = BM(7, 6),
3777 },
3778};
3779
3780static struct rcg_clk vcap_clk = {
3781 .b = {
3782 .ctl_reg = VCAP_CC_REG,
3783 .en_mask = BIT(0),
3784 .halt_reg = DBG_BUS_VEC_J_REG,
3785 .halt_bit = 15,
3786 },
3787 .ns_reg = VCAP_NS_REG,
3788 .root_en_mask = BIT(2),
3789 .set_rate = set_rate_mnd_banked,
3790 .freq_tbl = clk_tbl_vcap,
3791 .bank_info = &bmnd_info_vcap,
3792 .current_freq = &rcg_dummy_freq,
3793 .c = {
3794 .dbg_name = "vcap_clk",
3795 .ops = &clk_ops_rcg_8960,
3796 .depends = &vcap_axi_clk.c,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003797 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000),
Tianyi Gou621f8742011-09-01 21:45:01 -07003798 CLK_INIT(vcap_clk.c),
3799 },
3800};
3801
3802static struct branch_clk vcap_npl_clk = {
3803 .b = {
3804 .ctl_reg = VCAP_CC_REG,
3805 .en_mask = BIT(13),
3806 .halt_reg = DBG_BUS_VEC_J_REG,
3807 .halt_bit = 25,
3808 },
3809 .parent = &vcap_clk.c,
3810 .c = {
3811 .dbg_name = "vcap_npl_clk",
3812 .ops = &clk_ops_branch,
3813 CLK_INIT(vcap_npl_clk.c),
3814 },
3815};
3816
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003817#define F_IJPEG(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003818 { \
3819 .freq_hz = f, \
3820 .src_clk = &s##_clk.c, \
3821 .md_val = MD8(8, m, 0, n), \
3822 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
3823 .ctl_val = CC(6, n), \
3824 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003825 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003826
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003827static struct clk_freq_tbl clk_tbl_ijpeg[] = {
3828 F_IJPEG( 0, gnd, 1, 0, 0),
3829 F_IJPEG( 27000000, pxo, 1, 0, 0),
3830 F_IJPEG( 36570000, pll8, 1, 2, 21),
3831 F_IJPEG( 54860000, pll8, 7, 0, 0),
3832 F_IJPEG( 96000000, pll8, 4, 0, 0),
3833 F_IJPEG(109710000, pll8, 1, 2, 7),
3834 F_IJPEG(128000000, pll8, 3, 0, 0),
3835 F_IJPEG(153600000, pll8, 1, 2, 5),
3836 F_IJPEG(200000000, pll2, 4, 0, 0),
3837 F_IJPEG(228571000, pll2, 1, 2, 7),
3838 F_IJPEG(266667000, pll2, 1, 1, 3),
3839 F_IJPEG(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003840 F_END
3841};
3842
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003843static unsigned long fmax_ijpeg_8960_v2[MAX_VDD_LEVELS] __initdata = {
3844 [VDD_DIG_LOW] = 110000000,
3845 [VDD_DIG_NOMINAL] = 266667000,
3846 [VDD_DIG_HIGH] = 320000000
3847};
3848
3849static unsigned long fmax_ijpeg_8064[MAX_VDD_LEVELS] __initdata = {
3850 [VDD_DIG_LOW] = 128000000,
3851 [VDD_DIG_NOMINAL] = 266667000,
3852 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07003853};
3854
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003855static struct rcg_clk ijpeg_clk = {
3856 .b = {
3857 .ctl_reg = IJPEG_CC_REG,
3858 .en_mask = BIT(0),
3859 .reset_reg = SW_RESET_CORE_REG,
3860 .reset_mask = BIT(9),
3861 .halt_reg = DBG_BUS_VEC_A_REG,
3862 .halt_bit = 24,
3863 },
3864 .ns_reg = IJPEG_NS_REG,
3865 .md_reg = IJPEG_MD_REG,
3866 .root_en_mask = BIT(2),
3867 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
3868 .ctl_mask = BM(7, 6),
3869 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003870 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003871 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003872 .c = {
3873 .dbg_name = "ijpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003874 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003875 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003876 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003877 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003878 },
3879};
3880
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003881#define F_JPEGD(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003882 { \
3883 .freq_hz = f, \
3884 .src_clk = &s##_clk.c, \
3885 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003886 }
3887static struct clk_freq_tbl clk_tbl_jpegd[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003888 F_JPEGD( 0, gnd, 1),
3889 F_JPEGD( 64000000, pll8, 6),
3890 F_JPEGD( 76800000, pll8, 5),
3891 F_JPEGD( 96000000, pll8, 4),
3892 F_JPEGD(160000000, pll2, 5),
3893 F_JPEGD(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003894 F_END
3895};
3896
3897static struct rcg_clk jpegd_clk = {
3898 .b = {
3899 .ctl_reg = JPEGD_CC_REG,
3900 .en_mask = BIT(0),
3901 .reset_reg = SW_RESET_CORE_REG,
3902 .reset_mask = BIT(19),
3903 .halt_reg = DBG_BUS_VEC_A_REG,
3904 .halt_bit = 19,
3905 },
3906 .ns_reg = JPEGD_NS_REG,
3907 .root_en_mask = BIT(2),
3908 .ns_mask = (BM(15, 12) | BM(2, 0)),
3909 .set_rate = set_rate_nop,
3910 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003911 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003912 .c = {
3913 .dbg_name = "jpegd_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003914 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003915 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003916 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003917 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003918 },
3919};
3920
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003921#define F_MDP(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003922 { \
3923 .freq_hz = f, \
3924 .src_clk = &s##_clk.c, \
3925 .md_val = MD8(8, m, 0, n), \
3926 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
3927 .ctl_val = CC_BANKED(9, 6, n), \
3928 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003929 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003930static struct clk_freq_tbl clk_tbl_mdp[] = {
3931 F_MDP( 0, gnd, 0, 0),
3932 F_MDP( 9600000, pll8, 1, 40),
3933 F_MDP( 13710000, pll8, 1, 28),
3934 F_MDP( 27000000, pxo, 0, 0),
3935 F_MDP( 29540000, pll8, 1, 13),
3936 F_MDP( 34910000, pll8, 1, 11),
3937 F_MDP( 38400000, pll8, 1, 10),
3938 F_MDP( 59080000, pll8, 2, 13),
3939 F_MDP( 76800000, pll8, 1, 5),
3940 F_MDP( 85330000, pll8, 2, 9),
3941 F_MDP( 96000000, pll8, 1, 4),
3942 F_MDP(128000000, pll8, 1, 3),
3943 F_MDP(160000000, pll2, 1, 5),
3944 F_MDP(177780000, pll2, 2, 9),
3945 F_MDP(200000000, pll2, 1, 4),
3946 F_MDP(266667000, pll2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003947 F_END
3948};
3949
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003950static unsigned long fmax_mdp_8064[MAX_VDD_LEVELS] __initdata = {
3951 [VDD_DIG_LOW] = 128000000,
3952 [VDD_DIG_NOMINAL] = 266667000
Tianyi Gou621f8742011-09-01 21:45:01 -07003953};
3954
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003955static struct bank_masks bmnd_info_mdp = {
3956 .bank_sel_mask = BIT(11),
3957 .bank0_mask = {
3958 .md_reg = MDP_MD0_REG,
3959 .ns_mask = BM(29, 22) | BM(5, 3),
3960 .rst_mask = BIT(31),
3961 .mnd_en_mask = BIT(8),
3962 .mode_mask = BM(10, 9),
3963 },
3964 .bank1_mask = {
3965 .md_reg = MDP_MD1_REG,
3966 .ns_mask = BM(21, 14) | BM(2, 0),
3967 .rst_mask = BIT(30),
3968 .mnd_en_mask = BIT(5),
3969 .mode_mask = BM(7, 6),
3970 },
3971};
3972
3973static struct rcg_clk mdp_clk = {
3974 .b = {
3975 .ctl_reg = MDP_CC_REG,
3976 .en_mask = BIT(0),
3977 .reset_reg = SW_RESET_CORE_REG,
3978 .reset_mask = BIT(21),
3979 .halt_reg = DBG_BUS_VEC_C_REG,
3980 .halt_bit = 10,
3981 },
3982 .ns_reg = MDP_NS_REG,
3983 .root_en_mask = BIT(2),
3984 .set_rate = set_rate_mnd_banked,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003985 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003986 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003987 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003988 .c = {
3989 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003990 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003991 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003992 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003993 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003994 },
3995};
3996
3997static struct branch_clk lut_mdp_clk = {
3998 .b = {
3999 .ctl_reg = MDP_LUT_CC_REG,
4000 .en_mask = BIT(0),
4001 .halt_reg = DBG_BUS_VEC_I_REG,
4002 .halt_bit = 13,
4003 },
4004 .parent = &mdp_clk.c,
4005 .c = {
4006 .dbg_name = "lut_mdp_clk",
4007 .ops = &clk_ops_branch,
4008 CLK_INIT(lut_mdp_clk.c),
4009 },
4010};
4011
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004012#define F_MDP_VSYNC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004013 { \
4014 .freq_hz = f, \
4015 .src_clk = &s##_clk.c, \
4016 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004017 }
4018static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004019 F_MDP_VSYNC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004020 F_END
4021};
4022
4023static struct rcg_clk mdp_vsync_clk = {
4024 .b = {
4025 .ctl_reg = MISC_CC_REG,
4026 .en_mask = BIT(6),
4027 .reset_reg = SW_RESET_CORE_REG,
4028 .reset_mask = BIT(3),
4029 .halt_reg = DBG_BUS_VEC_B_REG,
4030 .halt_bit = 22,
4031 },
4032 .ns_reg = MISC_CC2_REG,
4033 .ns_mask = BIT(13),
4034 .set_rate = set_rate_nop,
4035 .freq_tbl = clk_tbl_mdp_vsync,
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 = "mdp_vsync_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_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004041 CLK_INIT(mdp_vsync_clk.c),
4042 },
4043};
4044
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004045#define F_ROT(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004046 { \
4047 .freq_hz = f, \
4048 .src_clk = &s##_clk.c, \
4049 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
4050 21, 19, 18, 16, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004051 }
4052static struct clk_freq_tbl clk_tbl_rot[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004053 F_ROT( 0, gnd, 1),
4054 F_ROT( 27000000, pxo, 1),
4055 F_ROT( 29540000, pll8, 13),
4056 F_ROT( 32000000, pll8, 12),
4057 F_ROT( 38400000, pll8, 10),
4058 F_ROT( 48000000, pll8, 8),
4059 F_ROT( 54860000, pll8, 7),
4060 F_ROT( 64000000, pll8, 6),
4061 F_ROT( 76800000, pll8, 5),
4062 F_ROT( 96000000, pll8, 4),
4063 F_ROT(100000000, pll2, 8),
4064 F_ROT(114290000, pll2, 7),
4065 F_ROT(133330000, pll2, 6),
4066 F_ROT(160000000, pll2, 5),
4067 F_ROT(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004068 F_END
4069};
4070
4071static struct bank_masks bdiv_info_rot = {
4072 .bank_sel_mask = BIT(30),
4073 .bank0_mask = {
4074 .ns_mask = BM(25, 22) | BM(18, 16),
4075 },
4076 .bank1_mask = {
4077 .ns_mask = BM(29, 26) | BM(21, 19),
4078 },
4079};
4080
4081static struct rcg_clk rot_clk = {
4082 .b = {
4083 .ctl_reg = ROT_CC_REG,
4084 .en_mask = BIT(0),
4085 .reset_reg = SW_RESET_CORE_REG,
4086 .reset_mask = BIT(2),
4087 .halt_reg = DBG_BUS_VEC_C_REG,
4088 .halt_bit = 15,
4089 },
4090 .ns_reg = ROT_NS_REG,
4091 .root_en_mask = BIT(2),
4092 .set_rate = set_rate_div_banked,
4093 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004094 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004095 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004096 .c = {
4097 .dbg_name = "rot_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004098 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004099 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004100 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004101 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004102 },
4103};
4104
4105static int hdmi_pll_clk_enable(struct clk *clk)
4106{
4107 int ret;
4108 unsigned long flags;
4109 spin_lock_irqsave(&local_clock_reg_lock, flags);
4110 ret = hdmi_pll_enable();
4111 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4112 return ret;
4113}
4114
4115static void hdmi_pll_clk_disable(struct clk *clk)
4116{
4117 unsigned long flags;
4118 spin_lock_irqsave(&local_clock_reg_lock, flags);
4119 hdmi_pll_disable();
4120 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4121}
4122
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07004123static unsigned long hdmi_pll_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004124{
4125 return hdmi_pll_get_rate();
4126}
4127
Stephen Boyd5b35dee2011-09-21 12:17:38 -07004128static struct clk *hdmi_pll_clk_get_parent(struct clk *clk)
4129{
4130 return &pxo_clk.c;
4131}
4132
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004133static struct clk_ops clk_ops_hdmi_pll = {
4134 .enable = hdmi_pll_clk_enable,
4135 .disable = hdmi_pll_clk_disable,
4136 .get_rate = hdmi_pll_clk_get_rate,
4137 .is_local = local_clk_is_local,
Stephen Boyd5b35dee2011-09-21 12:17:38 -07004138 .get_parent = hdmi_pll_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004139};
4140
4141static struct clk hdmi_pll_clk = {
4142 .dbg_name = "hdmi_pll_clk",
4143 .ops = &clk_ops_hdmi_pll,
4144 CLK_INIT(hdmi_pll_clk),
4145};
4146
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004147#define F_TV_GND(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004148 { \
4149 .freq_hz = f, \
4150 .src_clk = &s##_clk.c, \
4151 .md_val = MD8(8, m, 0, n), \
4152 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
4153 .ctl_val = CC(6, n), \
4154 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004155 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004156#define F_TV(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004157 { \
4158 .freq_hz = f, \
4159 .src_clk = &s##_clk, \
4160 .md_val = MD8(8, m, 0, n), \
4161 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
4162 .ctl_val = CC(6, n), \
4163 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004164 .extra_freq_data = (void *)p_r, \
4165 }
4166/* Switching TV freqs requires PLL reconfiguration. */
4167static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004168 F_TV_GND( 0, gnd, 0, 1, 0, 0),
4169 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0),
4170 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0),
4171 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0),
4172 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0),
4173 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004174 F_END
4175};
4176
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004177static unsigned long fmax_tv_src_8064[MAX_VDD_LEVELS] __initdata = {
4178 [VDD_DIG_LOW] = 74250000,
4179 [VDD_DIG_NOMINAL] = 149000000
4180};
4181
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004182/*
4183 * Unlike other clocks, the TV rate is adjusted through PLL
4184 * re-programming. It is also routed through an MND divider.
4185 */
4186void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
4187{
4188 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
4189 if (pll_rate)
4190 hdmi_pll_set_rate(pll_rate);
4191 set_rate_mnd(clk, nf);
4192}
4193
4194static struct rcg_clk tv_src_clk = {
4195 .ns_reg = TV_NS_REG,
4196 .b = {
4197 .ctl_reg = TV_CC_REG,
4198 .halt_check = NOCHECK,
4199 },
4200 .md_reg = TV_MD_REG,
4201 .root_en_mask = BIT(2),
4202 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
4203 .ctl_mask = BM(7, 6),
4204 .set_rate = set_rate_tv,
4205 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004206 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004207 .c = {
4208 .dbg_name = "tv_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004209 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004210 VDD_DIG_FMAX_MAP2(LOW, 27030000, NOMINAL, 149000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004211 CLK_INIT(tv_src_clk.c),
4212 },
4213};
4214
4215static struct branch_clk tv_enc_clk = {
4216 .b = {
4217 .ctl_reg = TV_CC_REG,
4218 .en_mask = BIT(8),
4219 .reset_reg = SW_RESET_CORE_REG,
4220 .reset_mask = BIT(0),
4221 .halt_reg = DBG_BUS_VEC_D_REG,
4222 .halt_bit = 9,
4223 },
4224 .parent = &tv_src_clk.c,
4225 .c = {
4226 .dbg_name = "tv_enc_clk",
4227 .ops = &clk_ops_branch,
4228 CLK_INIT(tv_enc_clk.c),
4229 },
4230};
4231
4232static struct branch_clk tv_dac_clk = {
4233 .b = {
4234 .ctl_reg = TV_CC_REG,
4235 .en_mask = BIT(10),
4236 .halt_reg = DBG_BUS_VEC_D_REG,
4237 .halt_bit = 10,
4238 },
4239 .parent = &tv_src_clk.c,
4240 .c = {
4241 .dbg_name = "tv_dac_clk",
4242 .ops = &clk_ops_branch,
4243 CLK_INIT(tv_dac_clk.c),
4244 },
4245};
4246
4247static struct branch_clk mdp_tv_clk = {
4248 .b = {
4249 .ctl_reg = TV_CC_REG,
4250 .en_mask = BIT(0),
4251 .reset_reg = SW_RESET_CORE_REG,
4252 .reset_mask = BIT(4),
4253 .halt_reg = DBG_BUS_VEC_D_REG,
4254 .halt_bit = 12,
4255 },
4256 .parent = &tv_src_clk.c,
4257 .c = {
4258 .dbg_name = "mdp_tv_clk",
4259 .ops = &clk_ops_branch,
4260 CLK_INIT(mdp_tv_clk.c),
4261 },
4262};
4263
4264static struct branch_clk hdmi_tv_clk = {
4265 .b = {
4266 .ctl_reg = TV_CC_REG,
4267 .en_mask = BIT(12),
4268 .reset_reg = SW_RESET_CORE_REG,
4269 .reset_mask = BIT(1),
4270 .halt_reg = DBG_BUS_VEC_D_REG,
4271 .halt_bit = 11,
4272 },
4273 .parent = &tv_src_clk.c,
4274 .c = {
4275 .dbg_name = "hdmi_tv_clk",
4276 .ops = &clk_ops_branch,
4277 CLK_INIT(hdmi_tv_clk.c),
4278 },
4279};
4280
4281static struct branch_clk hdmi_app_clk = {
4282 .b = {
4283 .ctl_reg = MISC_CC2_REG,
4284 .en_mask = BIT(11),
4285 .reset_reg = SW_RESET_CORE_REG,
4286 .reset_mask = BIT(11),
4287 .halt_reg = DBG_BUS_VEC_B_REG,
4288 .halt_bit = 25,
4289 },
4290 .c = {
4291 .dbg_name = "hdmi_app_clk",
4292 .ops = &clk_ops_branch,
4293 CLK_INIT(hdmi_app_clk.c),
4294 },
4295};
4296
4297static struct bank_masks bmnd_info_vcodec = {
4298 .bank_sel_mask = BIT(13),
4299 .bank0_mask = {
4300 .md_reg = VCODEC_MD0_REG,
4301 .ns_mask = BM(18, 11) | BM(2, 0),
4302 .rst_mask = BIT(31),
4303 .mnd_en_mask = BIT(5),
4304 .mode_mask = BM(7, 6),
4305 },
4306 .bank1_mask = {
4307 .md_reg = VCODEC_MD1_REG,
4308 .ns_mask = BM(26, 19) | BM(29, 27),
4309 .rst_mask = BIT(30),
4310 .mnd_en_mask = BIT(10),
4311 .mode_mask = BM(12, 11),
4312 },
4313};
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004314#define F_VCODEC(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004315 { \
4316 .freq_hz = f, \
4317 .src_clk = &s##_clk.c, \
4318 .md_val = MD8(8, m, 0, n), \
4319 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
4320 .ctl_val = CC_BANKED(6, 11, n), \
4321 .mnd_en_mask = (BIT(10) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004322 }
4323static struct clk_freq_tbl clk_tbl_vcodec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004324 F_VCODEC( 0, gnd, 0, 0),
4325 F_VCODEC( 27000000, pxo, 0, 0),
4326 F_VCODEC( 32000000, pll8, 1, 12),
4327 F_VCODEC( 48000000, pll8, 1, 8),
4328 F_VCODEC( 54860000, pll8, 1, 7),
4329 F_VCODEC( 96000000, pll8, 1, 4),
4330 F_VCODEC(133330000, pll2, 1, 6),
4331 F_VCODEC(200000000, pll2, 1, 4),
4332 F_VCODEC(228570000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004333 F_END
4334};
4335
4336static struct rcg_clk vcodec_clk = {
4337 .b = {
4338 .ctl_reg = VCODEC_CC_REG,
4339 .en_mask = BIT(0),
4340 .reset_reg = SW_RESET_CORE_REG,
4341 .reset_mask = BIT(6),
4342 .halt_reg = DBG_BUS_VEC_C_REG,
4343 .halt_bit = 29,
4344 },
4345 .ns_reg = VCODEC_NS_REG,
4346 .root_en_mask = BIT(2),
4347 .set_rate = set_rate_mnd_banked,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004348 .bank_info = &bmnd_info_vcodec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004349 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004350 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004351 .c = {
4352 .dbg_name = "vcodec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004353 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004354 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
4355 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004356 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004357 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004358 },
4359};
4360
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004361#define F_VPE(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004362 { \
4363 .freq_hz = f, \
4364 .src_clk = &s##_clk.c, \
4365 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004366 }
4367static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004368 F_VPE( 0, gnd, 1),
4369 F_VPE( 27000000, pxo, 1),
4370 F_VPE( 34909000, pll8, 11),
4371 F_VPE( 38400000, pll8, 10),
4372 F_VPE( 64000000, pll8, 6),
4373 F_VPE( 76800000, pll8, 5),
4374 F_VPE( 96000000, pll8, 4),
4375 F_VPE(100000000, pll2, 8),
4376 F_VPE(160000000, pll2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004377 F_END
4378};
4379
4380static struct rcg_clk vpe_clk = {
4381 .b = {
4382 .ctl_reg = VPE_CC_REG,
4383 .en_mask = BIT(0),
4384 .reset_reg = SW_RESET_CORE_REG,
4385 .reset_mask = BIT(17),
4386 .halt_reg = DBG_BUS_VEC_A_REG,
4387 .halt_bit = 28,
4388 },
4389 .ns_reg = VPE_NS_REG,
4390 .root_en_mask = BIT(2),
4391 .ns_mask = (BM(15, 12) | BM(2, 0)),
4392 .set_rate = set_rate_nop,
4393 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004394 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004395 .c = {
4396 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004397 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004398 VDD_DIG_FMAX_MAP2(LOW, 76800000, NOMINAL, 160000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004399 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004400 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004401 },
4402};
4403
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004404#define F_VFE(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004405 { \
4406 .freq_hz = f, \
4407 .src_clk = &s##_clk.c, \
4408 .md_val = MD8(8, m, 0, n), \
4409 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
4410 .ctl_val = CC(6, n), \
4411 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004412 }
Tianyi Gou41515e22011-09-01 19:37:43 -07004413
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004414static struct clk_freq_tbl clk_tbl_vfe[] = {
4415 F_VFE( 0, gnd, 1, 0, 0),
4416 F_VFE( 13960000, pll8, 1, 2, 55),
4417 F_VFE( 27000000, pxo, 1, 0, 0),
4418 F_VFE( 36570000, pll8, 1, 2, 21),
4419 F_VFE( 38400000, pll8, 2, 1, 5),
4420 F_VFE( 45180000, pll8, 1, 2, 17),
4421 F_VFE( 48000000, pll8, 2, 1, 4),
4422 F_VFE( 54860000, pll8, 1, 1, 7),
4423 F_VFE( 64000000, pll8, 2, 1, 3),
4424 F_VFE( 76800000, pll8, 1, 1, 5),
4425 F_VFE( 96000000, pll8, 2, 1, 2),
4426 F_VFE(109710000, pll8, 1, 2, 7),
4427 F_VFE(128000000, pll8, 1, 1, 3),
4428 F_VFE(153600000, pll8, 1, 2, 5),
4429 F_VFE(200000000, pll2, 2, 1, 2),
4430 F_VFE(228570000, pll2, 1, 2, 7),
4431 F_VFE(266667000, pll2, 1, 1, 3),
4432 F_VFE(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004433 F_END
4434};
4435
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004436static unsigned long fmax_vfe_8960_v2[MAX_VDD_LEVELS] __initdata = {
4437 [VDD_DIG_LOW] = 110000000,
4438 [VDD_DIG_NOMINAL] = 266667000,
4439 [VDD_DIG_HIGH] = 320000000
4440};
4441
4442static unsigned long fmax_vfe_8064[MAX_VDD_LEVELS] __initdata = {
4443 [VDD_DIG_LOW] = 128000000,
4444 [VDD_DIG_NOMINAL] = 266667000,
4445 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07004446};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004447
4448static struct rcg_clk vfe_clk = {
4449 .b = {
4450 .ctl_reg = VFE_CC_REG,
4451 .reset_reg = SW_RESET_CORE_REG,
4452 .reset_mask = BIT(15),
4453 .halt_reg = DBG_BUS_VEC_B_REG,
4454 .halt_bit = 6,
4455 .en_mask = BIT(0),
4456 },
4457 .ns_reg = VFE_NS_REG,
4458 .md_reg = VFE_MD_REG,
4459 .root_en_mask = BIT(2),
4460 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
4461 .ctl_mask = BM(7, 6),
4462 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004463 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004464 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004465 .c = {
4466 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004467 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004468 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004469 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004470 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004471 },
4472};
4473
Matt Wagantallc23eee92011-08-16 23:06:52 -07004474static struct branch_clk csi_vfe_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004475 .b = {
4476 .ctl_reg = VFE_CC_REG,
4477 .en_mask = BIT(12),
4478 .reset_reg = SW_RESET_CORE_REG,
4479 .reset_mask = BIT(24),
4480 .halt_reg = DBG_BUS_VEC_B_REG,
4481 .halt_bit = 8,
4482 },
4483 .parent = &vfe_clk.c,
4484 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -07004485 .dbg_name = "csi_vfe_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004486 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -07004487 CLK_INIT(csi_vfe_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004488 },
4489};
4490
4491/*
4492 * Low Power Audio Clocks
4493 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004494#define F_AIF_OSR(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004495 { \
4496 .freq_hz = f, \
4497 .src_clk = &s##_clk.c, \
4498 .md_val = MD8(8, m, 0, n), \
4499 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4500 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004501 }
4502static struct clk_freq_tbl clk_tbl_aif_osr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004503 F_AIF_OSR( 0, gnd, 1, 0, 0),
4504 F_AIF_OSR( 512000, pll4, 4, 1, 192),
4505 F_AIF_OSR( 768000, pll4, 4, 1, 128),
4506 F_AIF_OSR( 1024000, pll4, 4, 1, 96),
4507 F_AIF_OSR( 1536000, pll4, 4, 1, 64),
4508 F_AIF_OSR( 2048000, pll4, 4, 1, 48),
4509 F_AIF_OSR( 3072000, pll4, 4, 1, 32),
4510 F_AIF_OSR( 4096000, pll4, 4, 1, 24),
4511 F_AIF_OSR( 6144000, pll4, 4, 1, 16),
4512 F_AIF_OSR( 8192000, pll4, 4, 1, 12),
4513 F_AIF_OSR(12288000, pll4, 4, 1, 8),
4514 F_AIF_OSR(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004515 F_END
4516};
4517
4518#define CLK_AIF_OSR(i, ns, md, h_r) \
4519 struct rcg_clk i##_clk = { \
4520 .b = { \
4521 .ctl_reg = ns, \
4522 .en_mask = BIT(17), \
4523 .reset_reg = ns, \
4524 .reset_mask = BIT(19), \
4525 .halt_reg = h_r, \
4526 .halt_check = ENABLE, \
4527 .halt_bit = 1, \
4528 }, \
4529 .ns_reg = ns, \
4530 .md_reg = md, \
4531 .root_en_mask = BIT(9), \
4532 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4533 .set_rate = set_rate_mnd, \
4534 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004535 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004536 .c = { \
4537 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004538 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004539 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004540 CLK_INIT(i##_clk.c), \
4541 }, \
4542 }
4543#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
4544 struct rcg_clk i##_clk = { \
4545 .b = { \
4546 .ctl_reg = ns, \
4547 .en_mask = BIT(21), \
4548 .reset_reg = ns, \
4549 .reset_mask = BIT(23), \
4550 .halt_reg = h_r, \
4551 .halt_check = ENABLE, \
4552 .halt_bit = 1, \
4553 }, \
4554 .ns_reg = ns, \
4555 .md_reg = md, \
4556 .root_en_mask = BIT(9), \
4557 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4558 .set_rate = set_rate_mnd, \
4559 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004560 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004561 .c = { \
4562 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004563 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004564 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004565 CLK_INIT(i##_clk.c), \
4566 }, \
4567 }
4568
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004569#define CLK_AIF_BIT(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004570 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004571 .b = { \
4572 .ctl_reg = ns, \
4573 .en_mask = BIT(15), \
4574 .halt_reg = h_r, \
4575 .halt_check = DELAY, \
4576 }, \
4577 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004578 .ext_mask = BIT(14), \
4579 .div_offset = 10, \
4580 .max_div = 16, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004581 .c = { \
4582 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004583 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004584 CLK_INIT(i##_clk.c), \
4585 }, \
4586 }
4587
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004588#define CLK_AIF_BIT_DIV(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004589 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004590 .b = { \
4591 .ctl_reg = ns, \
4592 .en_mask = BIT(19), \
4593 .halt_reg = h_r, \
4594 .halt_check = ENABLE, \
4595 }, \
4596 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004597 .ext_mask = BIT(18), \
4598 .div_offset = 10, \
4599 .max_div = 256, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004600 .c = { \
4601 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004602 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004603 CLK_INIT(i##_clk.c), \
4604 }, \
4605 }
4606
4607static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
4608 LCC_MI2S_STATUS_REG);
4609static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
4610
4611static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
4612 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
4613static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
4614 LCC_CODEC_I2S_MIC_STATUS_REG);
4615
4616static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
4617 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
4618static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
4619 LCC_SPARE_I2S_MIC_STATUS_REG);
4620
4621static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
4622 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
4623static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
4624 LCC_CODEC_I2S_SPKR_STATUS_REG);
4625
4626static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
4627 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
4628static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
4629 LCC_SPARE_I2S_SPKR_STATUS_REG);
4630
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004631#define F_PCM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004632 { \
4633 .freq_hz = f, \
4634 .src_clk = &s##_clk.c, \
4635 .md_val = MD16(m, n), \
4636 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4637 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004638 }
4639static struct clk_freq_tbl clk_tbl_pcm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004640 F_PCM( 0, gnd, 1, 0, 0),
4641 F_PCM( 512000, pll4, 4, 1, 192),
4642 F_PCM( 768000, pll4, 4, 1, 128),
4643 F_PCM( 1024000, pll4, 4, 1, 96),
4644 F_PCM( 1536000, pll4, 4, 1, 64),
4645 F_PCM( 2048000, pll4, 4, 1, 48),
4646 F_PCM( 3072000, pll4, 4, 1, 32),
4647 F_PCM( 4096000, pll4, 4, 1, 24),
4648 F_PCM( 6144000, pll4, 4, 1, 16),
4649 F_PCM( 8192000, pll4, 4, 1, 12),
4650 F_PCM(12288000, pll4, 4, 1, 8),
4651 F_PCM(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004652 F_END
4653};
4654
4655static struct rcg_clk pcm_clk = {
4656 .b = {
4657 .ctl_reg = LCC_PCM_NS_REG,
4658 .en_mask = BIT(11),
4659 .reset_reg = LCC_PCM_NS_REG,
4660 .reset_mask = BIT(13),
4661 .halt_reg = LCC_PCM_STATUS_REG,
4662 .halt_check = ENABLE,
4663 .halt_bit = 0,
4664 },
4665 .ns_reg = LCC_PCM_NS_REG,
4666 .md_reg = LCC_PCM_MD_REG,
4667 .root_en_mask = BIT(9),
4668 .ns_mask = (BM(31, 16) | BM(6, 0)),
4669 .set_rate = set_rate_mnd,
4670 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004671 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004672 .c = {
4673 .dbg_name = "pcm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004674 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004675 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004676 CLK_INIT(pcm_clk.c),
4677 },
4678};
4679
4680static struct rcg_clk audio_slimbus_clk = {
4681 .b = {
4682 .ctl_reg = LCC_SLIMBUS_NS_REG,
4683 .en_mask = BIT(10),
4684 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
4685 .reset_mask = BIT(5),
4686 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4687 .halt_check = ENABLE,
4688 .halt_bit = 0,
4689 },
4690 .ns_reg = LCC_SLIMBUS_NS_REG,
4691 .md_reg = LCC_SLIMBUS_MD_REG,
4692 .root_en_mask = BIT(9),
4693 .ns_mask = (BM(31, 24) | BM(6, 0)),
4694 .set_rate = set_rate_mnd,
4695 .freq_tbl = clk_tbl_aif_osr,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004696 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004697 .c = {
4698 .dbg_name = "audio_slimbus_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004699 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004700 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004701 CLK_INIT(audio_slimbus_clk.c),
4702 },
4703};
4704
4705static struct branch_clk sps_slimbus_clk = {
4706 .b = {
4707 .ctl_reg = LCC_SLIMBUS_NS_REG,
4708 .en_mask = BIT(12),
4709 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4710 .halt_check = ENABLE,
4711 .halt_bit = 1,
4712 },
4713 .parent = &audio_slimbus_clk.c,
4714 .c = {
4715 .dbg_name = "sps_slimbus_clk",
4716 .ops = &clk_ops_branch,
4717 CLK_INIT(sps_slimbus_clk.c),
4718 },
4719};
4720
4721static struct branch_clk slimbus_xo_src_clk = {
4722 .b = {
4723 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
4724 .en_mask = BIT(2),
4725 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004726 .halt_bit = 28,
4727 },
4728 .parent = &sps_slimbus_clk.c,
4729 .c = {
4730 .dbg_name = "slimbus_xo_src_clk",
4731 .ops = &clk_ops_branch,
4732 CLK_INIT(slimbus_xo_src_clk.c),
4733 },
4734};
4735
Matt Wagantall735f01a2011-08-12 12:40:28 -07004736DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
4737DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
4738DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
4739DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
4740DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
4741DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
4742DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
4743DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004744
4745static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
4746static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
Manu Gautam7483f172011-11-08 15:22:26 +05304747static DEFINE_CLK_VOTER(dfab_usb_hs3_clk, &dfab_clk.c);
4748static DEFINE_CLK_VOTER(dfab_usb_hs4_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004749static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
4750static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
4751static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
4752static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
4753static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
4754static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
Stephen Boyd1c51a492011-10-26 12:11:47 -07004755static DEFINE_CLK_VOTER(dfab_bam_dmux_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004756
4757static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
4758/*
4759 * TODO: replace dummy_clk below with ebi1_clk.c once the
4760 * bus driver starts voting on ebi1 rates.
4761 */
4762static DEFINE_CLK_VOTER(ebi1_adm_clk, &dummy_clk);
4763
4764#ifdef CONFIG_DEBUG_FS
4765struct measure_sel {
4766 u32 test_vector;
4767 struct clk *clk;
4768};
4769
Matt Wagantall8b38f942011-08-02 18:23:18 -07004770static DEFINE_CLK_MEASURE(l2_m_clk);
4771static DEFINE_CLK_MEASURE(krait0_m_clk);
4772static DEFINE_CLK_MEASURE(krait1_m_clk);
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004773static DEFINE_CLK_MEASURE(q6sw_clk);
4774static DEFINE_CLK_MEASURE(q6fw_clk);
4775static DEFINE_CLK_MEASURE(q6_func_clk);
Matt Wagantall8b38f942011-08-02 18:23:18 -07004776
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004777static struct measure_sel measure_mux[] = {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004778 { TEST_PER_LS(0x05), &qdss_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004779 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
4780 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
4781 { TEST_PER_LS(0x13), &sdc1_clk.c },
4782 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
4783 { TEST_PER_LS(0x15), &sdc2_clk.c },
4784 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
4785 { TEST_PER_LS(0x17), &sdc3_clk.c },
4786 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
4787 { TEST_PER_LS(0x19), &sdc4_clk.c },
4788 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
4789 { TEST_PER_LS(0x1B), &sdc5_clk.c },
Matt Wagantall7625a4c2011-11-01 16:17:53 -07004790 { TEST_PER_LS(0x1F), &gp0_clk.c },
4791 { TEST_PER_LS(0x20), &gp1_clk.c },
4792 { TEST_PER_LS(0x21), &gp2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004793 { TEST_PER_LS(0x25), &dfab_clk.c },
4794 { TEST_PER_LS(0x25), &dfab_a_clk.c },
4795 { TEST_PER_LS(0x26), &pmem_clk.c },
4796 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
4797 { TEST_PER_LS(0x33), &cfpb_clk.c },
4798 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
4799 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
4800 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
4801 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
4802 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
4803 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
4804 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
4805 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
4806 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
4807 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
4808 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
4809 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
4810 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
4811 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
4812 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
4813 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
4814 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
4815 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
4816 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
4817 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
4818 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
4819 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
4820 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
4821 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
4822 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
4823 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
4824 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
4825 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
4826 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
4827 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
4828 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
4829 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
4830 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
4831 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
4832 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
4833 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
4834 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004835 { TEST_PER_LS(0x5E), &pcie_p_clk.c },
4836 { TEST_PER_LS(0x5F), &ce3_p_clk.c },
4837 { TEST_PER_LS(0x60), &ce3_core_clk.c },
4838 { TEST_PER_LS(0x63), &usb_hs3_p_clk.c },
4839 { TEST_PER_LS(0x64), &usb_hs3_xcvr_clk.c },
4840 { TEST_PER_LS(0x65), &usb_hs4_p_clk.c },
4841 { TEST_PER_LS(0x66), &usb_hs4_xcvr_clk.c },
4842 { TEST_PER_LS(0x6B), &sata_phy_ref_clk.c },
4843 { TEST_PER_LS(0x6C), &sata_phy_cfg_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004844 { TEST_PER_LS(0x78), &sfpb_clk.c },
4845 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
4846 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
4847 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
4848 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
4849 { TEST_PER_LS(0x7D), &prng_clk.c },
4850 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
4851 { TEST_PER_LS(0x80), &adm0_p_clk.c },
4852 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
4853 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004854 { TEST_PER_LS(0x86), &usb_hsic_p_clk.c },
4855 { TEST_PER_LS(0x87), &usb_hsic_system_clk.c },
4856 { TEST_PER_LS(0x88), &usb_hsic_xcvr_fs_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004857 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
4858 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
4859 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
4860 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
4861 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
4862 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
4863 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
4864 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
4865 { TEST_PER_LS(0x92), &ce1_p_clk.c },
4866 { TEST_PER_LS(0x94), &tssc_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004867 { TEST_PER_LS(0x9D), &usb_hsic_hsio_cal_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004868 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
4869
4870 { TEST_PER_HS(0x07), &afab_clk.c },
4871 { TEST_PER_HS(0x07), &afab_a_clk.c },
4872 { TEST_PER_HS(0x18), &sfab_clk.c },
4873 { TEST_PER_HS(0x18), &sfab_a_clk.c },
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004874 { TEST_PER_HS(0x26), &q6sw_clk },
4875 { TEST_PER_HS(0x27), &q6fw_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004876 { TEST_PER_HS(0x2A), &adm0_clk.c },
4877 { TEST_PER_HS(0x34), &ebi1_clk.c },
4878 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004879 { TEST_PER_HS(0x48), &qdss_at_clk.c },
4880 { TEST_PER_HS(0x49), &qdss_pclkdbg_clk.c },
4881 { TEST_PER_HS(0x4A), &qdss_traceclkin_clk.c },
4882 { TEST_PER_HS(0x4B), &qdss_tsctr_clk.c },
4883 { TEST_PER_HS(0x4F), &qdss_stm_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004884 { TEST_PER_HS(0x50), &usb_hsic_hsic_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004885
4886 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
4887 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
4888 { TEST_MM_LS(0x02), &cam1_clk.c },
4889 { TEST_MM_LS(0x06), &amp_p_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004890 { TEST_MM_LS(0x07), &csi_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004891 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
4892 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
4893 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
4894 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
4895 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
4896 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
4897 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
4898 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
4899 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
4900 { TEST_MM_LS(0x12), &imem_p_clk.c },
4901 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
4902 { TEST_MM_LS(0x14), &mdp_p_clk.c },
4903 { TEST_MM_LS(0x16), &rot_p_clk.c },
4904 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
4905 { TEST_MM_LS(0x18), &smmu_p_clk.c },
4906 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
4907 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
4908 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
4909 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
4910 { TEST_MM_LS(0x1D), &cam0_clk.c },
4911 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
4912 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
4913 { TEST_MM_LS(0x21), &tv_dac_clk.c },
4914 { TEST_MM_LS(0x22), &tv_enc_clk.c },
4915 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
4916 { TEST_MM_LS(0x25), &mmfpb_clk.c },
4917 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
4918 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004919 { TEST_MM_LS(0x27), &cam2_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004920 { TEST_MM_LS(0x28), &vcap_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004921
4922 { TEST_MM_HS(0x00), &csi0_clk.c },
4923 { TEST_MM_HS(0x01), &csi1_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004924 { TEST_MM_HS(0x04), &csi_vfe_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004925 { TEST_MM_HS(0x05), &ijpeg_clk.c },
4926 { TEST_MM_HS(0x06), &vfe_clk.c },
4927 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
4928 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
4929 { TEST_MM_HS(0x09), &gfx3d_clk.c },
4930 { TEST_MM_HS(0x0A), &jpegd_clk.c },
4931 { TEST_MM_HS(0x0B), &vcodec_clk.c },
4932 { TEST_MM_HS(0x0F), &mmfab_clk.c },
4933 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
4934 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
4935 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
4936 { TEST_MM_HS(0x13), &imem_axi_clk.c },
4937 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
4938 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
4939 { TEST_MM_HS(0x16), &rot_axi_clk.c },
4940 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
4941 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
4942 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
4943 { TEST_MM_HS(0x1A), &mdp_clk.c },
4944 { TEST_MM_HS(0x1B), &rot_clk.c },
4945 { TEST_MM_HS(0x1C), &vpe_clk.c },
4946 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
4947 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
4948 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
4949 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
4950 { TEST_MM_HS(0x26), &csi_pix_clk.c },
4951 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
4952 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
4953 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
4954 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
4955 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
4956 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004957 { TEST_MM_HS(0x2D), &csi2_clk.c },
4958 { TEST_MM_HS(0x2E), &csi2_phy_clk.c },
4959 { TEST_MM_HS(0x2F), &csi2phy_timer_clk.c },
4960 { TEST_MM_HS(0x30), &csi_pix1_clk.c },
4961 { TEST_MM_HS(0x31), &csi_rdi1_clk.c },
4962 { TEST_MM_HS(0x32), &csi_rdi2_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004963 { TEST_MM_HS(0x33), &vcap_clk.c },
4964 { TEST_MM_HS(0x34), &vcap_npl_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004965 { TEST_MM_HS(0x36), &vcap_axi_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004966 { TEST_MM_HS(0x39), &gfx3d_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004967
4968 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
4969 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
4970 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
4971 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
4972 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
4973 { TEST_LPA(0x14), &pcm_clk.c },
4974 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
Matt Wagantall8b38f942011-08-02 18:23:18 -07004975
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004976 { TEST_LPA_HS(0x00), &q6_func_clk },
4977
Stephen Boyd46fdf0d2011-11-22 12:25:09 -08004978 { TEST_CPUL2(0x2), &l2_m_clk },
4979 { TEST_CPUL2(0x0), &krait0_m_clk },
4980 { TEST_CPUL2(0x1), &krait1_m_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004981};
4982
4983static struct measure_sel *find_measure_sel(struct clk *clk)
4984{
4985 int i;
4986
4987 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
4988 if (measure_mux[i].clk == clk)
4989 return &measure_mux[i];
4990 return NULL;
4991}
4992
Matt Wagantall8b38f942011-08-02 18:23:18 -07004993static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004994{
4995 int ret = 0;
4996 u32 clk_sel;
4997 struct measure_sel *p;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004998 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004999 unsigned long flags;
5000
5001 if (!parent)
5002 return -EINVAL;
5003
5004 p = find_measure_sel(parent);
5005 if (!p)
5006 return -EINVAL;
5007
5008 spin_lock_irqsave(&local_clock_reg_lock, flags);
5009
Matt Wagantall8b38f942011-08-02 18:23:18 -07005010 /*
5011 * Program the test vector, measurement period (sample_ticks)
5012 * and scaling multiplier.
5013 */
5014 clk->sample_ticks = 0x10000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005015 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantall8b38f942011-08-02 18:23:18 -07005016 clk->multiplier = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005017 switch (p->test_vector >> TEST_TYPE_SHIFT) {
5018 case TEST_TYPE_PER_LS:
5019 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
5020 break;
5021 case TEST_TYPE_PER_HS:
5022 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
5023 break;
5024 case TEST_TYPE_MM_LS:
5025 writel_relaxed(0x4030D97, CLK_TEST_REG);
5026 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
5027 break;
5028 case TEST_TYPE_MM_HS:
5029 writel_relaxed(0x402B800, CLK_TEST_REG);
5030 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
5031 break;
5032 case TEST_TYPE_LPA:
5033 writel_relaxed(0x4030D98, CLK_TEST_REG);
5034 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
5035 LCC_CLK_LS_DEBUG_CFG_REG);
5036 break;
Stephen Boyd3939c8d2011-08-29 17:36:22 -07005037 case TEST_TYPE_LPA_HS:
5038 writel_relaxed(0x402BC00, CLK_TEST_REG);
5039 writel_relaxed(BVAL(2, 1, clk_sel)|BIT(0),
5040 LCC_CLK_HS_DEBUG_CFG_REG);
5041 break;
Matt Wagantall8b38f942011-08-02 18:23:18 -07005042 case TEST_TYPE_CPUL2:
5043 writel_relaxed(0x4030400, CLK_TEST_REG);
5044 writel_relaxed(0x80|BVAL(5, 3, clk_sel), GCC_APCS_CLK_DIAG);
5045 clk->sample_ticks = 0x4000;
5046 clk->multiplier = 2;
5047 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005048 default:
5049 ret = -EPERM;
5050 }
5051 /* Make sure test vector is set before starting measurements. */
5052 mb();
5053
5054 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
5055
5056 return ret;
5057}
5058
5059/* Sample clock for 'ticks' reference clock ticks. */
5060static u32 run_measurement(unsigned ticks)
5061{
5062 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005063 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
5064
5065 /* Wait for timer to become ready. */
5066 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
5067 cpu_relax();
5068
5069 /* Run measurement and wait for completion. */
5070 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
5071 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
5072 cpu_relax();
5073
5074 /* Stop counters. */
5075 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
5076
5077 /* Return measured ticks. */
5078 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
5079}
5080
5081
5082/* Perform a hardware rate measurement for a given clock.
5083 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07005084static unsigned long measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005085{
5086 unsigned long flags;
5087 u32 pdm_reg_backup, ringosc_reg_backup;
5088 u64 raw_count_short, raw_count_full;
Matt Wagantall8b38f942011-08-02 18:23:18 -07005089 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005090 unsigned ret;
5091
5092 spin_lock_irqsave(&local_clock_reg_lock, flags);
5093
5094 /* Enable CXO/4 and RINGOSC branch and root. */
5095 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
5096 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
5097 writel_relaxed(0x2898, PDM_CLK_NS_REG);
5098 writel_relaxed(0xA00, RINGOSC_NS_REG);
5099
5100 /*
5101 * The ring oscillator counter will not reset if the measured clock
5102 * is not running. To detect this, run a short measurement before
5103 * the full measurement. If the raw results of the two are the same
5104 * then the clock must be off.
5105 */
5106
5107 /* Run a short measurement. (~1 ms) */
5108 raw_count_short = run_measurement(0x1000);
5109 /* Run a full measurement. (~14 ms) */
Matt Wagantall8b38f942011-08-02 18:23:18 -07005110 raw_count_full = run_measurement(clk->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005111
5112 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
5113 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
5114
5115 /* Return 0 if the clock is off. */
5116 if (raw_count_full == raw_count_short)
5117 ret = 0;
5118 else {
5119 /* Compute rate in Hz. */
5120 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantall8b38f942011-08-02 18:23:18 -07005121 do_div(raw_count_full, ((clk->sample_ticks * 10) + 35));
5122 ret = (raw_count_full * clk->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005123 }
5124
5125 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07005126 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005127 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
5128
5129 return ret;
5130}
5131#else /* !CONFIG_DEBUG_FS */
5132static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
5133{
5134 return -EINVAL;
5135}
5136
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07005137static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005138{
5139 return 0;
5140}
5141#endif /* CONFIG_DEBUG_FS */
5142
5143static struct clk_ops measure_clk_ops = {
5144 .set_parent = measure_clk_set_parent,
5145 .get_rate = measure_clk_get_rate,
5146 .is_local = local_clk_is_local,
5147};
5148
Matt Wagantall8b38f942011-08-02 18:23:18 -07005149static struct measure_clk measure_clk = {
5150 .c = {
5151 .dbg_name = "measure_clk",
5152 .ops = &measure_clk_ops,
5153 CLK_INIT(measure_clk.c),
5154 },
5155 .multiplier = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005156};
5157
Tianyi Goua8b3cce2011-11-08 14:37:26 -08005158static struct clk_lookup msm_clocks_8064[] = {
Tianyi Gou41515e22011-09-01 19:37:43 -07005159 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005160 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005161 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
Tianyi Gouc29c3242011-10-12 21:02:15 -07005162 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005163 CLK_LOOKUP("measure", measure_clk.c, "debug"),
5164
Matt Wagantallb2710b82011-11-16 19:55:17 -08005165 CLK_DUMMY("bus_clk", AFAB_CLK, "msm_apps_fab", 0),
5166 CLK_DUMMY("bus_a_clk", AFAB_A_CLK, "msm_apps_fab", 0),
5167 CLK_DUMMY("bus_clk", SFAB_CLK, "msm_sys_fab", 0),
5168 CLK_DUMMY("bus_a_clk", SFAB_A_CLK, "msm_sys_fab", 0),
5169 CLK_DUMMY("bus_clk", SFPB_CLK, "msm_sys_fpb", 0),
5170 CLK_DUMMY("bus_a_clk", SFPB_A_CLK, "msm_sys_fpb", 0),
5171 CLK_DUMMY("bus_clk", MMFAB_CLK, "msm_mm_fab", 0),
5172 CLK_DUMMY("bus_a_clk", MMFAB_A_CLK, "msm_mm_fab", 0),
5173 CLK_DUMMY("bus_clk", CFPB_CLK, "msm_cpss_fpb", 0),
5174 CLK_DUMMY("bus_a_clk", CFPB_A_CLK, "msm_cpss_fpb", 0),
5175 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
5176 CLK_DUMMY("mem_a_clk", EBI1_A_CLK, "msm_bus", 0),
5177
5178 CLK_DUMMY("ebi1_clk", EBI1_CLK, NULL, 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005179 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
5180 CLK_DUMMY("dfab_a_clk", DFAB_A_CLK, NULL, 0),
Matt Wagantallb2710b82011-11-16 19:55:17 -08005181 CLK_DUMMY("bus_clk", MMFPB_CLK, NULL, 0),
5182 CLK_DUMMY("bus_a_clk", MMFPB_A_CLK, NULL, 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005183
Matt Wagantall7625a4c2011-11-01 16:17:53 -07005184 CLK_LOOKUP("core_clk", gp0_clk.c, NULL),
5185 CLK_LOOKUP("core_clk", gp1_clk.c, NULL),
5186 CLK_LOOKUP("core_clk", gp2_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005187 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
5188 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
5189 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
5190 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
5191 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, NULL),
5192 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, NULL),
5193 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
5194 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, NULL),
5195 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
5196 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, NULL),
5197 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, NULL),
5198 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
5199 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
5200 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005201 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005202 CLK_LOOKUP("pmem_clk", pmem_clk.c, NULL),
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -07005203 CLK_DUMMY("core_clk", PRNG_CLK, "msm_rng.0", OFF),
Tianyi Gou43208a02011-09-27 15:35:13 -07005204 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5205 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5206 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5207 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005208 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
5209 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005210 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
Manu Gautam7483f172011-11-08 15:22:26 +05305211 CLK_LOOKUP("core_clk", usb_hs3_xcvr_clk.c, "msm_ehci_host.0"),
5212 CLK_LOOKUP("core_clk", usb_hs4_xcvr_clk.c, "msm_ehci_host.1"),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005213 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
5214 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
5215 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005216 CLK_LOOKUP("iface_clk", ce1_p_clk.c, NULL),
5217 CLK_LOOKUP("core_clk", ce1_core_clk.c, NULL),
Ramesh Masavarapu28311912011-10-27 11:04:12 -07005218 CLK_LOOKUP("ref_clk", sata_phy_ref_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005219 CLK_LOOKUP("cfg_clk", sata_phy_cfg_clk.c, NULL),
Ramesh Masavarapu28311912011-10-27 11:04:12 -07005220 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qce.0"),
5221 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qcrypto.0"),
5222 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qce.0"),
5223 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qcrypto.0"),
5224 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qce.0"),
5225 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qcrypto.0"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005226 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
5227 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, NULL),
5228 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
5229 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, NULL),
5230 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, NULL),
5231 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, NULL),
5232 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, NULL),
5233 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005234 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005235 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5236 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Manu Gautam7483f172011-11-08 15:22:26 +05305237 CLK_LOOKUP("iface_clk", usb_hs3_p_clk.c, "msm_ehci_host.0"),
5238 CLK_LOOKUP("iface_clk", usb_hs4_p_clk.c, "msm_ehci_host.1"),
Tianyi Gou43208a02011-09-27 15:35:13 -07005239 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5240 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5241 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5242 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005243 CLK_LOOKUP("iface_clk", pcie_p_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005244 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5245 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005246 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
5247 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
5248 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
5249 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
5250 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005251 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5252 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
5253 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5254 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5255 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005256 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005257 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5258 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5259 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005260 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005261 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5262 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5263 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005264 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005265 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5266 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5267 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005268 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, NULL),
5269 CLK_LOOKUP("csi_pix_clk", csi_pix1_clk.c, NULL),
5270 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, NULL),
5271 CLK_LOOKUP("csi_rdi_clk", csi_rdi1_clk.c, NULL),
5272 CLK_LOOKUP("csi_rdi_clk", csi_rdi2_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005273 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
5274 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, NULL),
5275 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, NULL),
5276 CLK_LOOKUP("csiphy_timer_clk", csi2phy_timer_clk.c, NULL),
5277 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5278 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5279 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5280 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
5281 CLK_DUMMY("rgb_tv_clk", RGB_TV_CLK, NULL, OFF),
5282 CLK_DUMMY("npl_tv_clk", NPL_TV_CLK, NULL, OFF),
Pu Chen86b4be92011-11-03 17:27:57 -07005283 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005284 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5285 CLK_LOOKUP("bus_clk", gfx3d_axi_clk.c, "footswitch-8x60.2"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005286 CLK_LOOKUP("iface_clk", vcap_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005287 CLK_LOOKUP("iface_clk", vcap_p_clk.c, "footswitch-8x60.10"),
5288 CLK_LOOKUP("bus_clk", vcap_axi_clk.c, "footswitch-8x60.10"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005289 CLK_LOOKUP("core_clk", vcap_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005290 CLK_LOOKUP("core_clk", vcap_clk.c, "footswitch-8x60.10"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005291 CLK_LOOKUP("vcap_npl_clk", vcap_npl_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005292 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005293 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
5294 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005295 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005296 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005297 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005298 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005299 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
5300 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005301 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005302 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005303 CLK_DUMMY("tv_src_clk", TV_SRC_CLK, NULL, OFF),
Greg Griscofa47b532011-11-11 10:32:06 -08005304 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005305 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005306 CLK_DUMMY("mdp_tv_clk", MDP_TV_CLK, NULL, OFF),
5307 CLK_DUMMY("hdmi_clk", HDMI_TV_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005308 CLK_LOOKUP("core_clk", hdmi_app_clk.c, NULL),
5309 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005310 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005311 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005312 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005313 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005314 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5315 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5316 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5317 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5318 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5319 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5320 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005321 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
5322 CLK_LOOKUP("csi_pclk", csi_p_clk.c, NULL),
5323 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5324 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5325 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5326 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Pu Chen86b4be92011-11-03 17:27:57 -07005327 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005328 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005329 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, NULL),
5330 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, NULL),
5331 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005332 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005333 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
5334 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005335 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005336 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005337 CLK_LOOKUP("iface_clk", smmu_p_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005338 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005339 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Greg Griscofa47b532011-11-11 10:32:06 -08005340 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005341 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005342 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005343 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005344 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005345 CLK_LOOKUP("iface_pclk", vpe_p_clk.c, "footswitch-8x60.9"),
Tianyi Gouc29c3242011-10-12 21:02:15 -07005346 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5347 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5348 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5349 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5350 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5351 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5352 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5353 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5354 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5355 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5356 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
Tianyi Goudd8138a2011-10-20 15:46:00 -07005357 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5358 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005359 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, NULL),
5360 CLK_LOOKUP("core_clk", vpe_axi_clk.c, NULL),
5361 CLK_LOOKUP("core_clk", mdp_axi_clk.c, NULL),
5362 CLK_LOOKUP("core_clk", vcap_axi_clk.c, NULL),
5363 CLK_LOOKUP("core_clk", rot_axi_clk.c, NULL),
5364 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, NULL),
5365 CLK_LOOKUP("core_clk", vfe_axi_clk.c, NULL),
5366 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, NULL),
5367 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005368 CLK_LOOKUP("core_clk", gfx3d_axi_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005369 CLK_DUMMY("dfab_dsps_clk", DFAB_DSPS_CLK, NULL, 0),
5370 CLK_DUMMY("dfab_usb_hs_clk", DFAB_USB_HS_CLK, NULL, 0),
Manu Gautam7483f172011-11-08 15:22:26 +05305371 CLK_DUMMY("bus_clk", DFAB_USB_HS3_CLK, "msm_ehci_host.0", 0),
5372 CLK_DUMMY("bus_clk", DFAB_USB_HS4_CLK, "msm_ehci_host.1", 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005373 CLK_DUMMY("bus_clk", DFAB_SDC1_CLK, NULL, 0),
5374 CLK_DUMMY("bus_clk", DFAB_SDC2_CLK, NULL, 0),
5375 CLK_DUMMY("bus_clk", DFAB_SDC3_CLK, NULL, 0),
5376 CLK_DUMMY("bus_clk", DFAB_SDC4_CLK, NULL, 0),
5377 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
5378 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5379 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5380 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5381 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5382 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5383
Jeff Ohlstein8c116c72011-10-27 17:34:48 -07005384 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005385
5386 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5387 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5388 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
5389};
5390
Stephen Boyd94625ef2011-07-12 17:06:01 -07005391static struct clk_lookup msm_clocks_8960_v1[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005392 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
5393 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
5394 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
5395 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005396 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005397
Matt Wagantallb2710b82011-11-16 19:55:17 -08005398 CLK_LOOKUP("bus_clk", afab_clk.c, "msm_apps_fab"),
5399 CLK_LOOKUP("bus_a_clk", afab_a_clk.c, "msm_apps_fab"),
5400 CLK_LOOKUP("bus_clk", cfpb_clk.c, "msm_cpss_fpb"),
5401 CLK_LOOKUP("bus_a_clk", cfpb_a_clk.c, "msm_cpss_fpb"),
5402 CLK_LOOKUP("bus_clk", sfab_clk.c, "msm_sys_fab"),
5403 CLK_LOOKUP("bus_a_clk", sfab_a_clk.c, "msm_sys_fab"),
5404 CLK_LOOKUP("bus_clk", sfpb_clk.c, "msm_sys_fpb"),
5405 CLK_LOOKUP("bus_a_clk", sfpb_a_clk.c, "msm_sys_fpb"),
5406 CLK_LOOKUP("bus_clk", mmfab_clk.c, "msm_mm_fab"),
5407 CLK_LOOKUP("bus_a_clk", mmfab_a_clk.c, "msm_mm_fab"),
5408 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
5409 CLK_LOOKUP("mem_a_clk", ebi1_a_clk.c, "msm_bus"),
5410
5411 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
5412 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
5413 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
5414 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
5415 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8960"),
5416 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005417
Matt Wagantall7625a4c2011-11-01 16:17:53 -07005418 CLK_LOOKUP("core_clk", gp0_clk.c, NULL),
5419 CLK_LOOKUP("core_clk", gp1_clk.c, NULL),
5420 CLK_LOOKUP("core_clk", gp2_clk.c, NULL),
Matt Wagantalle2522372011-08-17 14:52:21 -07005421 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
5422 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
5423 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
5424 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
5425 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
5426 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
5427 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
5428 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, NULL),
5429 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, NULL),
5430 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, NULL),
5431 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, NULL),
5432 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005433 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005434 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005435 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
5436 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005437 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
5438 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
5439 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
5440 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, NULL),
5441 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005442 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005443 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005444 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005445 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Vikram Mulukutladd0a2372011-09-19 15:58:21 -07005446 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_sps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07005447 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005448 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5449 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5450 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5451 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
5452 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005453 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005454 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005455 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005456 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
5457 CLK_LOOKUP("usb_phy_clk", usb_phy0_clk.c, NULL),
5458 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
5459 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
5460 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
5461 CLK_LOOKUP("usb_fs_clk", usb_fs2_xcvr_clk.c, NULL),
5462 CLK_LOOKUP("usb_fs_sys_clk", usb_fs2_sys_clk.c, NULL),
5463 CLK_LOOKUP("usb_fs_src_clk", usb_fs2_src_clk.c, NULL),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005464 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005465 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qcrypto.0"),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005466 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005467 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qcrypto.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005468 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005469 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005470 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005471 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
5472 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07005473 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
5474 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005475 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
5476 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, NULL),
5477 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005478 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005479 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005480 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.12"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005481 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005482 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5483 CLK_LOOKUP("usb_fs_pclk", usb_fs2_p_clk.c, NULL),
5484 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005485 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5486 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5487 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5488 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
5489 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005490 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5491 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005492 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
5493 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
5494 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
5495 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
5496 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005497 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5498 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
5499 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_imx074.0"),
Rajakumar Govindaram6bc004a2011-12-05 20:58:19 -08005500 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_mt9m114.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005501 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_ov2720.0"),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005502 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_csid.0"),
5503 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_csid.1"),
5504 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_csid.0"),
5505 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csid.1"),
5506 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_csid.0"),
5507 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_csid.1"),
Kevin Chane12c6672011-10-26 11:55:26 -07005508 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, "msm_ispif.0"),
5509 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, "msm_ispif.0"),
Kevin Chanf6216f22011-10-25 18:40:11 -07005510 CLK_LOOKUP("csiphy_timer_src_clk",
5511 csiphy_timer_src_clk.c, "msm_csiphy.0"),
5512 CLK_LOOKUP("csiphy_timer_src_clk",
5513 csiphy_timer_src_clk.c, "msm_csiphy.1"),
5514 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, "msm_csiphy.0"),
5515 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, "msm_csiphy.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005516 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5517 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5518 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5519 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005520 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005521 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005522 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005523 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005524 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005525 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5526 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005527 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005528 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005529 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005530 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005531 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005532 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005533 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
5534 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07005535 CLK_LOOKUP("qdss_pclk", qdss_p_clk.c, NULL),
5536 CLK_LOOKUP("qdss_at_clk", qdss_at_clk.c, NULL),
5537 CLK_LOOKUP("qdss_pclkdbg_clk", qdss_pclkdbg_clk.c, NULL),
5538 CLK_LOOKUP("qdss_traceclkin_clk", qdss_traceclkin_clk.c, NULL),
5539 CLK_LOOKUP("qdss_tsctr_clk", qdss_tsctr_clk.c, NULL),
5540 CLK_LOOKUP("qdss_stm_clk", qdss_stm_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005541 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005542 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005543 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
5544 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
5545 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005546 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005547 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005548 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
5549 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005550 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Kevin Chana0853122011-11-07 19:48:44 -08005551 CLK_LOOKUP("vpe_clk", vpe_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005552 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Kevin Chan5827c552011-10-28 18:36:32 -07005553 CLK_LOOKUP("vfe_clk", vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005554 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Kevin Chan5827c552011-10-28 18:36:32 -07005555 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005556 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5557 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5558 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5559 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5560 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5561 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5562 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005563 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005564 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.0"),
5565 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005566 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5567 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5568 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5569 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005570 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005571 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005572 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005573 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005574 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005575 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005576 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
5577 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005578 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005579 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005580 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005581 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005582 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005583 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07005584 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005585 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005586 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005587 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005588 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005589 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Kevin Chan5827c552011-10-28 18:36:32 -07005590 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005591 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Kevin Chana0853122011-11-07 19:48:44 -08005592 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005593 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005594 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5595 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5596 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5597 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5598 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5599 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5600 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5601 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5602 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5603 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5604 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
5605 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5606 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Matt Wagantalle604d712011-10-21 15:38:18 -07005607 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
5608 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
5609 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
5610 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
5611 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
5612 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
5613 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
5614 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
5615 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
5616 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
5617 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
5618 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005619 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
5620 CLK_LOOKUP("dfab_usb_hs_clk", dfab_usb_hs_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005621 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
5622 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
5623 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
5624 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
5625 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Yan He160633e2011-06-30 12:18:56 -07005626 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
Stephen Boyd1c51a492011-10-26 12:11:47 -07005627 CLK_LOOKUP("bus_clk", dfab_bam_dmux_clk.c, "BAM_RMNT"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005628
Matt Wagantalle1a86062011-08-18 17:46:10 -07005629 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005630
5631 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5632 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5633 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
Stephen Boyd3939c8d2011-08-29 17:36:22 -07005634 CLK_LOOKUP("q6sw_clk", q6sw_clk, NULL),
5635 CLK_LOOKUP("q6fw_clk", q6fw_clk, NULL),
5636 CLK_LOOKUP("q6_func_clk", q6_func_clk, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005637};
5638
Stephen Boyd94625ef2011-07-12 17:06:01 -07005639static struct clk_lookup msm_clocks_8960_v2[] __initdata = {
5640 CLK_LOOKUP("cam_clk", cam2_clk.c, NULL),
5641 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
5642 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
Kevin Chane12c6672011-10-26 11:55:26 -07005643 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, "msm_ispif.0"),
5644 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, "msm_ispif.0"),
5645 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, "msm_ispif.0"),
Stephen Boyd94625ef2011-07-12 17:06:01 -07005646 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
5647 CLK_LOOKUP("csi2phy_timer_clk", csi2phy_timer_clk.c, NULL),
5648 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5649 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5650 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5651 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5652 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5653};
5654
5655/* Add v2 clocks dynamically at runtime */
5656static struct clk_lookup msm_clocks_8960[ARRAY_SIZE(msm_clocks_8960_v1) +
5657 ARRAY_SIZE(msm_clocks_8960_v2)];
5658
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005659/*
5660 * Miscellaneous clock register initializations
5661 */
5662
5663/* Read, modify, then write-back a register. */
5664static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
5665{
5666 uint32_t regval = readl_relaxed(reg);
5667 regval &= ~mask;
5668 regval |= val;
5669 writel_relaxed(regval, reg);
5670}
5671
Tianyi Gou41515e22011-09-01 19:37:43 -07005672static void __init set_fsm_mode(void __iomem *mode_reg)
5673{
5674 u32 regval = readl_relaxed(mode_reg);
5675
5676 /*De-assert reset to FSM */
5677 regval &= ~BIT(21);
5678 writel_relaxed(regval, mode_reg);
5679
5680 /* Program bias count */
Tianyi Gou358c3862011-10-18 17:03:41 -07005681 regval &= ~BM(19, 14);
5682 regval |= BVAL(19, 14, 0x1);
5683 writel_relaxed(regval, mode_reg);
5684
5685 /* Program lock count */
Tianyi Gou41515e22011-09-01 19:37:43 -07005686 regval &= ~BM(13, 8);
5687 regval |= BVAL(13, 8, 0x8);
5688 writel_relaxed(regval, mode_reg);
5689
5690 /*Enable PLL FSM voting */
5691 regval |= BIT(20);
5692 writel_relaxed(regval, mode_reg);
5693}
5694
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005695static void __init reg_init(void)
5696{
Stephen Boydd471e7a2011-11-19 01:37:39 -08005697 void __iomem *imem_reg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005698 /* Deassert MM SW_RESET_ALL signal. */
5699 writel_relaxed(0, SW_RESET_ALL_REG);
5700
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005701 /*
5702 * Some bits are only used on either 8960 or 8064 and are marked as
5703 * reserved bits on the other SoC. Writing to these reserved bits
5704 * should have no effect.
5705 */
Stephen Boydd471e7a2011-11-19 01:37:39 -08005706 /*
5707 * Initialize MM AHB registers: Enable the FPB clock and disable HW
5708 * gating on 8960v1/8064 for all clocks. Also set VFE_AHB's
5709 * FORCE_CORE_ON bit to prevent its memory from being collapsed when
5710 * the clock is halted. The sleep and wake-up delays are set to safe
5711 * values.
5712 */
5713 if (cpu_is_msm8960() &&
5714 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5715 rmwreg(0x44000000, AHB_EN_REG, 0x6C000103);
5716 writel_relaxed(0x3C7097F9, AHB_EN2_REG);
5717 } else {
5718 rmwreg(0x00000003, AHB_EN_REG, 0x6C000103);
5719 writel_relaxed(0x000007F9, AHB_EN2_REG);
5720 }
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005721 if (cpu_is_apq8064())
5722 rmwreg(0x00000000, AHB_EN3_REG, 0x00000001);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005723
5724 /* Deassert all locally-owned MM AHB resets. */
5725 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
Tianyi Gou41515e22011-09-01 19:37:43 -07005726 rmwreg(0, SW_RESET_AHB2_REG, 0x0000000F);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005727
5728 /* Initialize MM AXI registers: Enable HW gating for all clocks that
5729 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
5730 * delays to safe values. */
Stephen Boydd471e7a2011-11-19 01:37:39 -08005731 if (cpu_is_msm8960() &&
5732 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 3) {
5733 rmwreg(0x0003AFF9, MAXI_EN_REG, 0x0803FFFF);
5734 rmwreg(0x3A27FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
5735 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
5736 } else {
5737 rmwreg(0x000007F9, MAXI_EN_REG, 0x0803FFFF);
5738 rmwreg(0x3027FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
5739 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
5740 }
Matt Wagantall53d968f2011-07-19 13:22:53 -07005741 rmwreg(0x0027FCFF, MAXI_EN3_REG, 0x003FFFFF);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005742 if (cpu_is_apq8064())
5743 rmwreg(0x009FE4FF, MAXI_EN5_REG, 0x01FFEFFF);
Stephen Boydd471e7a2011-11-19 01:37:39 -08005744 if (cpu_is_msm8960() &&
5745 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2)
5746 rmwreg(0x00003C38, SAXI_EN_REG, 0x00003FFF);
5747 else
5748 rmwreg(0x000003C7, SAXI_EN_REG, 0x00003FFF);
5749
5750 /* Enable IMEM's clk_on signal */
5751 imem_reg = ioremap(0x04b00040, 4);
5752 if (imem_reg) {
5753 writel_relaxed(0x3, imem_reg);
5754 iounmap(imem_reg);
5755 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005756
5757 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
5758 * memories retain state even when not clocked. Also, set sleep and
5759 * wake-up delays to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005760 rmwreg(0x00000000, CSI0_CC_REG, 0x00000410);
5761 rmwreg(0x00000000, CSI1_CC_REG, 0x00000410);
5762 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, 0xE0FF0010);
5763 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, 0xE0FF0010);
5764 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, 0xE0FF0010);
5765 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, 0xE0FF0010);
Tarun Karra6fbc00a2011-12-13 09:23:47 -07005766 rmwreg(0xC0FF0000, GFX3D_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005767 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0010);
5768 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0010);
5769 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
5770 rmwreg(0x80FF0000, MDP_LUT_CC_REG, 0xE0FF0010);
5771 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005772 rmwreg(0x000004FF, TV_CC2_REG, 0x000007FF);
5773 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
5774 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FF4010);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005775 rmwreg(0x800000FF, VFE_CC2_REG, 0xE00000FF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005776 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005777 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005778 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
5779 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
5780 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
5781 }
5782 if (cpu_is_apq8064()) {
5783 rmwreg(0x00000000, TV_CC_REG, 0x00004010);
Tianyi Gou621f8742011-09-01 21:45:01 -07005784 rmwreg(0x80FF0000, VCAP_CC_REG, 0xE0FF1010);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005785 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005786
Tianyi Gou41515e22011-09-01 19:37:43 -07005787 /*
5788 * Initialize USB_HS_HCLK_FS registers: Set FORCE_C_ON bits so that
5789 * core remain active during halt state of the clk. Also, set sleep
5790 * and wake-up value to max.
5791 */
5792 rmwreg(0x0000004F, USB_HS1_HCLK_FS_REG, 0x0000007F);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005793 if (cpu_is_apq8064()) {
5794 rmwreg(0x0000004F, USB_HS3_HCLK_FS_REG, 0x0000007F);
5795 rmwreg(0x0000004F, USB_HS4_HCLK_FS_REG, 0x0000007F);
5796 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005797
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005798 /* De-assert MM AXI resets to all hardware blocks. */
5799 writel_relaxed(0, SW_RESET_AXI_REG);
5800
5801 /* Deassert all MM core resets. */
5802 writel_relaxed(0, SW_RESET_CORE_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005803 writel_relaxed(0, SW_RESET_CORE2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005804
5805 /* Reset 3D core once more, with its clock enabled. This can
5806 * eventually be done as part of the GDFS footswitch driver. */
5807 clk_set_rate(&gfx3d_clk.c, 27000000);
5808 clk_enable(&gfx3d_clk.c);
5809 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
5810 mb();
5811 udelay(5);
5812 writel_relaxed(0, SW_RESET_CORE_REG);
5813 /* Make sure reset is de-asserted before clock is disabled. */
5814 mb();
5815 clk_disable(&gfx3d_clk.c);
5816
5817 /* Enable TSSC and PDM PXO sources. */
5818 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
5819 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
5820
5821 /* Source SLIMBus xo src from slimbus reference clock */
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005822 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005823 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005824
5825 /* Source the dsi_byte_clks from the DSI PHY PLLs */
5826 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
5827 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
Tianyi Gou41515e22011-09-01 19:37:43 -07005828
5829 /* Source the sata_phy_ref_clk from PXO */
5830 if (cpu_is_apq8064())
5831 rmwreg(0, SATA_PHY_REF_CLK_CTL_REG, 0x1);
5832
5833 /*
5834 * TODO: Programming below PLLs is temporary and needs to be removed
5835 * after bootloaders program them.
5836 */
5837 if (cpu_is_apq8064()) {
5838 u32 regval, is_pll_enabled;
5839
5840 /* Program pxo_src_clk to source from PXO */
5841 rmwreg(0x1, PXO_SRC_CLK_CTL_REG, 0x7);
5842
5843 /* Check if PLL8 is active */
5844 is_pll_enabled = readl_relaxed(BB_PLL8_STATUS_REG) & BIT(16);
5845 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005846 /* Ref clk = 27MHz and program pll8 to 384MHz */
5847 writel_relaxed(0xE, BB_PLL8_L_VAL_REG);
5848 writel_relaxed(0x2, BB_PLL8_M_VAL_REG);
5849 writel_relaxed(0x9, BB_PLL8_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005850
5851 regval = readl_relaxed(BB_PLL8_CONFIG_REG);
5852
5853 /* Enable the main output and the MN accumulator */
5854 regval |= BIT(23) | BIT(22);
5855
5856 /* Set pre-divider and post-divider values to 1 and 1 */
5857 regval &= ~BIT(19);
5858 regval &= ~BM(21, 20);
5859
5860 writel_relaxed(regval, BB_PLL8_CONFIG_REG);
5861
5862 /* Set VCO frequency */
5863 rmwreg(0x10000, BB_PLL8_CONFIG_REG, 0x30000);
5864
5865 /* Enable AUX output */
5866 regval = readl_relaxed(BB_PLL8_TEST_CTL_REG);
5867 regval |= BIT(12);
5868 writel_relaxed(regval, BB_PLL8_TEST_CTL_REG);
5869
5870 set_fsm_mode(BB_PLL8_MODE_REG);
5871 }
5872 /* Check if PLL3 is active */
5873 is_pll_enabled = readl_relaxed(GPLL1_STATUS_REG) & BIT(16);
5874 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005875 /* Ref clk = 27MHz and program pll3 to 1200MHz */
5876 writel_relaxed(0x2C, GPLL1_L_VAL_REG);
5877 writel_relaxed(0x4, GPLL1_M_VAL_REG);
5878 writel_relaxed(0x9, GPLL1_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005879
5880 regval = readl_relaxed(GPLL1_CONFIG_REG);
5881
5882 /* Set pre-divider and post-divider values to 1 and 1 */
5883 regval &= ~BIT(15);
5884 regval |= BIT(16);
5885
5886 writel_relaxed(regval, GPLL1_CONFIG_REG);
5887
5888 /* Set VCO frequency */
5889 rmwreg(0x180, GPLL1_CONFIG_REG, 0x180);
5890 }
5891 /* Check if PLL14 is active */
5892 is_pll_enabled = readl_relaxed(BB_PLL14_STATUS_REG) & BIT(16);
5893 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005894 /* Ref clk = 27MHz and program pll14 to 480MHz */
5895 writel_relaxed(0x11, BB_PLL14_L_VAL_REG);
5896 writel_relaxed(0x7, BB_PLL14_M_VAL_REG);
5897 writel_relaxed(0x9, BB_PLL14_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005898
5899 regval = readl_relaxed(BB_PLL14_CONFIG_REG);
5900
5901 /* Enable the main output and the MN accumulator */
5902 regval |= BIT(23) | BIT(22);
5903
5904 /* Set pre-divider and post-divider values to 1 and 1 */
5905 regval &= ~BIT(19);
5906 regval &= ~BM(21, 20);
5907
5908 writel_relaxed(regval, BB_PLL14_CONFIG_REG);
5909
5910 /* Set VCO frequency */
5911 rmwreg(0x10000, BB_PLL14_CONFIG_REG, 0x30000);
5912
Tianyi Gou41515e22011-09-01 19:37:43 -07005913 set_fsm_mode(BB_PLL14_MODE_REG);
5914 }
Tianyi Gou621f8742011-09-01 21:45:01 -07005915 /* Program PLL2 to 800MHz with ref clk = 27MHz */
5916 writel_relaxed(0x1D, MM_PLL1_L_VAL_REG);
5917 writel_relaxed(0x11, MM_PLL1_M_VAL_REG);
5918 writel_relaxed(0x1B, MM_PLL1_N_VAL_REG);
5919
5920 regval = readl_relaxed(MM_PLL1_CONFIG_REG);
5921
5922 /* Enable the main output and the MN accumulator */
5923 regval |= BIT(23) | BIT(22);
5924
5925 /* Set pre-divider and post-divider values to 1 and 1 */
5926 regval &= ~BIT(19);
5927 regval &= ~BM(21, 20);
5928
5929 writel_relaxed(regval, MM_PLL1_CONFIG_REG);
5930
5931 /* Set VCO frequency */
5932 rmwreg(0x20000, MM_PLL1_CONFIG_REG, 0x30000);
5933
Tianyi Gou621f8742011-09-01 21:45:01 -07005934 /* Program PLL15 to 975MHz with ref clk = 27MHz */
5935 writel_relaxed(0x24, MM_PLL3_L_VAL_REG);
5936 writel_relaxed(0x1, MM_PLL3_M_VAL_REG);
5937 writel_relaxed(0x9, MM_PLL3_N_VAL_REG);
5938
5939 regval = readl_relaxed(MM_PLL3_CONFIG_REG);
5940
5941 /* Enable the main output and the MN accumulator */
5942 regval |= BIT(23) | BIT(22);
5943
5944 /* Set pre-divider and post-divider values to 1 and 1 */
5945 regval &= ~BIT(19);
5946 regval &= ~BM(21, 20);
5947
5948 writel_relaxed(regval, MM_PLL3_CONFIG_REG);
5949
5950 /* Set VCO frequency */
5951 rmwreg(0x20000, MM_PLL3_CONFIG_REG, 0x30000);
5952
5953 /* Enable AUX output */
5954 regval = readl_relaxed(MM_PLL3_TEST_CTL_REG);
5955 regval |= BIT(12);
5956 writel_relaxed(regval, MM_PLL3_TEST_CTL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005957
5958 /* Check if PLL4 is active */
5959 is_pll_enabled = readl_relaxed(LCC_PLL0_STATUS_REG) & BIT(16);
5960 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005961 /* Ref clk = 27MHz and program pll4 to 393.2160MHz */
5962 writel_relaxed(0xE, LCC_PLL0_L_VAL_REG);
5963 writel_relaxed(0x27A, LCC_PLL0_M_VAL_REG);
5964 writel_relaxed(0x465, LCC_PLL0_N_VAL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005965
5966 regval = readl_relaxed(LCC_PLL0_CONFIG_REG);
5967
5968 /* Enable the main output and the MN accumulator */
5969 regval |= BIT(23) | BIT(22);
5970
5971 /* Set pre-divider and post-divider values to 1 and 1 */
5972 regval &= ~BIT(19);
5973 regval &= ~BM(21, 20);
5974
5975 /* Set VCO frequency */
5976 regval &= ~BM(17, 16);
5977 writel_relaxed(regval, LCC_PLL0_CONFIG_REG);
5978
5979 set_fsm_mode(LCC_PLL0_MODE_REG);
5980 }
5981
5982 /* Enable PLL4 source on the LPASS Primary PLL Mux */
5983 writel_relaxed(0x1, LCC_PRI_PLL_CLK_CTL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005984 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005985}
5986
Stephen Boyd94625ef2011-07-12 17:06:01 -07005987struct clock_init_data msm8960_clock_init_data __initdata;
5988
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005989/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07005990static void __init msm8960_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005991{
Stephen Boyd94625ef2011-07-12 17:06:01 -07005992 size_t num_lookups = ARRAY_SIZE(msm_clocks_8960_v1);
Tianyi Gou41515e22011-09-01 19:37:43 -07005993
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005994 xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8960");
5995 if (IS_ERR(xo_pxo)) {
5996 pr_err("%s: msm_xo_get(PXO) failed.\n", __func__);
5997 BUG();
5998 }
Matt Wagantalled90b002011-12-12 21:22:43 -08005999 xo_cxo = msm_xo_get(MSM_XO_CXO, "clock-8960");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006000 if (IS_ERR(xo_cxo)) {
6001 pr_err("%s: msm_xo_get(CXO) failed.\n", __func__);
6002 BUG();
6003 }
6004
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07006005 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou41515e22011-09-01 19:37:43 -07006006 memcpy(msm_clocks_8960, msm_clocks_8960_v1,
6007 sizeof(msm_clocks_8960_v1));
6008 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
6009 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8960_v2;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07006010
6011 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8960_v2,
6012 sizeof(gfx3d_clk.c.fmax));
6013 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8960_v2,
6014 sizeof(ijpeg_clk.c.fmax));
6015 memcpy(vfe_clk.c.fmax, fmax_vfe_8960_v2,
6016 sizeof(vfe_clk.c.fmax));
6017
Tianyi Gou41515e22011-09-01 19:37:43 -07006018 memcpy(msm_clocks_8960 + ARRAY_SIZE(msm_clocks_8960_v1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07006019 msm_clocks_8960_v2, sizeof(msm_clocks_8960_v2));
Tianyi Gou41515e22011-09-01 19:37:43 -07006020 num_lookups = ARRAY_SIZE(msm_clocks_8960);
6021 }
6022 msm8960_clock_init_data.size = num_lookups;
Stephen Boyd94625ef2011-07-12 17:06:01 -07006023 }
Tianyi Gou41515e22011-09-01 19:37:43 -07006024
6025 /*
Matt Wagantalle18bbc82011-10-06 10:07:28 -07006026 * Change the freq tables for and voltage requirements for
6027 * clocks which differ between 8960 and 8064.
Tianyi Gou41515e22011-09-01 19:37:43 -07006028 */
6029 if (cpu_is_apq8064()) {
6030 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8064;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07006031
6032 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8064,
6033 sizeof(gfx3d_clk.c.fmax));
6034 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8064,
6035 sizeof(ijpeg_clk.c.fmax));
6036 memcpy(mdp_clk.c.fmax, fmax_mdp_8064,
6037 sizeof(ijpeg_clk.c.fmax));
6038 memcpy(tv_src_clk.c.fmax, fmax_tv_src_8064,
6039 sizeof(tv_src_clk.c.fmax));
6040 memcpy(vfe_clk.c.fmax, fmax_vfe_8064,
6041 sizeof(vfe_clk.c.fmax));
6042
Tianyi Gou621f8742011-09-01 21:45:01 -07006043 gmem_axi_clk.c.depends = &gfx3d_axi_clk.c;
Tianyi Gou41515e22011-09-01 19:37:43 -07006044 }
Stephen Boyd94625ef2011-07-12 17:06:01 -07006045
Matt Wagantalle18bbc82011-10-06 10:07:28 -07006046 vote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006047
Vikram Mulukutla489e39e2011-08-31 18:04:05 -07006048 clk_ops_pll.enable = sr_pll_clk_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006049
6050 /* Initialize clock registers. */
6051 reg_init();
6052
6053 /* Initialize rates for clocks that only support one. */
6054 clk_set_rate(&pdm_clk.c, 27000000);
6055 clk_set_rate(&prng_clk.c, 64000000);
6056 clk_set_rate(&mdp_vsync_clk.c, 27000000);
6057 clk_set_rate(&tsif_ref_clk.c, 105000);
6058 clk_set_rate(&tssc_clk.c, 27000000);
6059 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
Tianyi Gou41515e22011-09-01 19:37:43 -07006060 if (cpu_is_apq8064()) {
6061 clk_set_rate(&usb_hs3_xcvr_clk.c, 60000000);
6062 clk_set_rate(&usb_hs4_xcvr_clk.c, 60000000);
6063 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006064 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07006065 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou41515e22011-09-01 19:37:43 -07006066 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
Stephen Boyd94625ef2011-07-12 17:06:01 -07006067 clk_set_rate(&usb_hsic_xcvr_fs_clk.c, 60000000);
6068 clk_set_rate(&usb_hsic_hsic_src_clk.c, 480000000);
6069 clk_set_rate(&usb_hsic_hsio_cal_clk.c, 9000000);
Stephen Boyd092fd182011-10-21 15:56:30 -07006070 /*
6071 * Set the CSI rates to a safe default to avoid warnings when
6072 * switching csi pix and rdi clocks.
6073 */
6074 clk_set_rate(&csi0_src_clk.c, 27000000);
6075 clk_set_rate(&csi1_src_clk.c, 27000000);
6076 clk_set_rate(&csi2_src_clk.c, 27000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006077
6078 /*
Stephen Boyd60496bb2011-10-17 13:51:37 -07006079 * The halt status bits for these clocks may be incorrect at boot.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006080 * Toggle these clocks on and off to refresh them.
6081 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07006082 rcg_clk_enable(&pdm_clk.c);
6083 rcg_clk_disable(&pdm_clk.c);
6084 rcg_clk_enable(&tssc_clk.c);
6085 rcg_clk_disable(&tssc_clk.c);
Stephen Boyd60496bb2011-10-17 13:51:37 -07006086 if (cpu_is_msm8960() &&
6087 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
6088 clk_enable(&usb_hsic_hsic_clk.c);
6089 clk_disable(&usb_hsic_hsic_clk.c);
Stephen Boyd092fd182011-10-21 15:56:30 -07006090 } else
6091 /* CSI2 hardware not present on 8960v1 devices */
6092 pix_rdi_mux_map[2] = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006093
6094 if (machine_is_msm8960_sim()) {
6095 clk_set_rate(&sdc1_clk.c, 48000000);
6096 clk_enable(&sdc1_clk.c);
6097 clk_enable(&sdc1_p_clk.c);
6098 clk_set_rate(&sdc3_clk.c, 48000000);
6099 clk_enable(&sdc3_clk.c);
6100 clk_enable(&sdc3_p_clk.c);
6101 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006102}
6103
Stephen Boydbb600ae2011-08-02 20:11:40 -07006104static int __init msm8960_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006105{
Stephen Boyda3787f32011-09-16 18:55:13 -07006106 int rc;
6107 struct clk *mmfpb_a_clk = clk_get_sys("clock-8960", "mmfpb_a_clk");
Stephen Boyd85436132011-09-16 18:55:13 -07006108 struct clk *cfpb_a_clk = clk_get_sys("clock-8960", "cfpb_a_clk");
Stephen Boyda3787f32011-09-16 18:55:13 -07006109
6110 /* Vote for MMFPB to be at least 76.8MHz when an Apps CPU is active. */
6111 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
6112 PTR_ERR(mmfpb_a_clk)))
6113 return PTR_ERR(mmfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08006114 rc = clk_set_rate(mmfpb_a_clk, 76800000);
Stephen Boyda3787f32011-09-16 18:55:13 -07006115 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
6116 return rc;
6117 rc = clk_enable(mmfpb_a_clk);
6118 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
6119 return rc;
6120
Stephen Boyd85436132011-09-16 18:55:13 -07006121 /* Vote for CFPB to be at least 64MHz when an Apps CPU is active. */
6122 if (WARN(IS_ERR(cfpb_a_clk), "cfpb_a_clk not found (%ld)\n",
6123 PTR_ERR(cfpb_a_clk)))
6124 return PTR_ERR(cfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08006125 rc = clk_set_rate(cfpb_a_clk, 64000000);
Stephen Boyd85436132011-09-16 18:55:13 -07006126 if (WARN(rc, "cfpb_a_clk rate was not set (%d)\n", rc))
6127 return rc;
6128 rc = clk_enable(cfpb_a_clk);
6129 if (WARN(rc, "cfpb_a_clk not enabled (%d)\n", rc))
6130 return rc;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07006131
6132 return unvote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006133}
Stephen Boydbb600ae2011-08-02 20:11:40 -07006134
6135struct clock_init_data msm8960_clock_init_data __initdata = {
6136 .table = msm_clocks_8960,
6137 .size = ARRAY_SIZE(msm_clocks_8960),
6138 .init = msm8960_clock_init,
6139 .late_init = msm8960_clock_late_init,
6140};
Tianyi Gou41515e22011-09-01 19:37:43 -07006141
6142struct clock_init_data apq8064_clock_init_data __initdata = {
6143 .table = msm_clocks_8064,
6144 .size = ARRAY_SIZE(msm_clocks_8064),
6145 .init = msm8960_clock_init,
6146 .late_init = msm8960_clock_late_init,
6147};