blob: fd268b82f615a3850c6014422901698ed93f4ed4 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/err.h>
16#include <linux/ctype.h>
17#include <linux/bitops.h>
18#include <linux/io.h>
19#include <linux/spinlock.h>
20#include <linux/delay.h>
21#include <linux/clk.h>
22
23#include <asm/clkdev.h>
24#include <asm/mach-types.h>
25
26#include <mach/msm_iomap.h>
27#include <mach/clk.h>
28#include <mach/rpm-regulator.h>
29#include <mach/msm_xo.h>
Stephen Boyd94625ef2011-07-12 17:06:01 -070030#include <mach/socinfo.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070031
32#include "clock-local.h"
33#include "clock-rpm.h"
34#include "clock-voter.h"
35#include "clock-dss-8960.h"
36#include "devices.h"
37
38#define REG(off) (MSM_CLK_CTL_BASE + (off))
39#define REG_MM(off) (MSM_MMSS_CLK_CTL_BASE + (off))
40#define REG_LPA(off) (MSM_LPASS_CLK_CTL_BASE + (off))
Matt Wagantall8b38f942011-08-02 18:23:18 -070041#define REG_GCC(off) (MSM_APCS_GCC_BASE + (off))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070042
43/* Peripheral clock registers. */
44#define CE1_HCLK_CTL_REG REG(0x2720)
45#define CE1_CORE_CLK_CTL_REG REG(0x2724)
Tianyi Gou41515e22011-09-01 19:37:43 -070046#define CE3_HCLK_CTL_REG REG(0x36C4)
47#define CE3_CORE_CLK_CTL_REG REG(0x36CC)
48#define CE3_CLK_SRC_NS_REG REG(0x36C0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049#define DMA_BAM_HCLK_CTL REG(0x25C0)
Tianyi Gou41515e22011-09-01 19:37:43 -070050#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#define CLK_HALT_CFPB_STATEA_REG REG(0x2FCC)
52#define CLK_HALT_CFPB_STATEB_REG REG(0x2FD0)
53#define CLK_HALT_CFPB_STATEC_REG REG(0x2FD4)
54#define CLK_HALT_DFAB_STATE_REG REG(0x2FC8)
Tianyi Gou41515e22011-09-01 19:37:43 -070055/* 8064 name CLK_HALT_GSS_KPSS_MISC_STATE_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#define CLK_HALT_MSS_SMPSS_MISC_STATE_REG REG(0x2FDC)
57#define CLK_HALT_SFPB_MISC_STATE_REG REG(0x2FD8)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070058#define CLK_HALT_AFAB_SFAB_STATEB_REG REG(0x2FC4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070059#define CLK_TEST_REG REG(0x2FA0)
Matt Wagantall7625a4c2011-11-01 16:17:53 -070060#define GPn_MD_REG(n) REG(0x2D00+(0x20*(n)))
61#define GPn_NS_REG(n) REG(0x2D24+(0x20*(n)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062#define GSBIn_HCLK_CTL_REG(n) REG(0x29C0+(0x20*((n)-1)))
63#define GSBIn_QUP_APPS_MD_REG(n) REG(0x29C8+(0x20*((n)-1)))
64#define GSBIn_QUP_APPS_NS_REG(n) REG(0x29CC+(0x20*((n)-1)))
65#define GSBIn_RESET_REG(n) REG(0x29DC+(0x20*((n)-1)))
66#define GSBIn_UART_APPS_MD_REG(n) REG(0x29D0+(0x20*((n)-1)))
67#define GSBIn_UART_APPS_NS_REG(n) REG(0x29D4+(0x20*((n)-1)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070068#define PDM_CLK_NS_REG REG(0x2CC0)
Tianyi Gou41515e22011-09-01 19:37:43 -070069/* 8064 name BB_PLL_ENA_APCS_REG */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070#define BB_PLL_ENA_SC0_REG REG(0x34C0)
71#define BB_PLL0_STATUS_REG REG(0x30D8)
72#define BB_PLL5_STATUS_REG REG(0x30F8)
73#define BB_PLL6_STATUS_REG REG(0x3118)
74#define BB_PLL7_STATUS_REG REG(0x3138)
75#define BB_PLL8_L_VAL_REG REG(0x3144)
76#define BB_PLL8_M_VAL_REG REG(0x3148)
77#define BB_PLL8_MODE_REG REG(0x3140)
78#define BB_PLL8_N_VAL_REG REG(0x314C)
79#define BB_PLL8_STATUS_REG REG(0x3158)
80#define BB_PLL8_CONFIG_REG REG(0x3154)
81#define BB_PLL8_TEST_CTL_REG REG(0x3150)
Stephen Boyd94625ef2011-07-12 17:06:01 -070082#define BB_MMCC_PLL2_MODE_REG REG(0x3160)
83#define BB_MMCC_PLL2_TEST_CTL_REG REG(0x3170)
Tianyi Gou41515e22011-09-01 19:37:43 -070084#define BB_PLL14_MODE_REG REG(0x31C0)
85#define BB_PLL14_L_VAL_REG REG(0x31C4)
86#define BB_PLL14_M_VAL_REG REG(0x31C8)
87#define BB_PLL14_N_VAL_REG REG(0x31CC)
88#define BB_PLL14_TEST_CTL_REG REG(0x31D0)
89#define BB_PLL14_CONFIG_REG REG(0x31D4)
Stephen Boyd94625ef2011-07-12 17:06:01 -070090#define BB_PLL14_STATUS_REG REG(0x31D8)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091#define PLLTEST_PAD_CFG_REG REG(0x2FA4)
92#define PMEM_ACLK_CTL_REG REG(0x25A0)
Stephen Boyd973e4ba2011-07-12 17:06:01 -070093#define QDSS_AT_CLK_SRC0_NS_REG REG(0x2180)
94#define QDSS_AT_CLK_SRC1_NS_REG REG(0x2184)
95#define QDSS_AT_CLK_SRC_CTL_REG REG(0x2188)
96#define QDSS_AT_CLK_NS_REG REG(0x218C)
97#define QDSS_HCLK_CTL_REG REG(0x22A0)
98#define QDSS_RESETS_REG REG(0x2260)
99#define QDSS_STM_CLK_CTL_REG REG(0x2060)
100#define QDSS_TRACECLKIN_CLK_SRC0_NS_REG REG(0x21A0)
101#define QDSS_TRACECLKIN_CLK_SRC1_NS_REG REG(0x21A4)
102#define QDSS_TRACECLKIN_CLK_SRC_CTL_REG REG(0x21A8)
103#define QDSS_TRACECLKIN_CTL_REG REG(0x21AC)
104#define QDSS_TSCTR_CLK_SRC0_NS_REG REG(0x21C0)
105#define QDSS_TSCTR_CLK_SRC1_NS_REG REG(0x21C4)
106#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
107#define QDSS_TSCTR_CLK_SRC_CTL_REG REG(0x21C8)
108#define QDSS_TSCTR_CTL_REG REG(0x21CC)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700109#define RINGOSC_NS_REG REG(0x2DC0)
110#define RINGOSC_STATUS_REG REG(0x2DCC)
111#define RINGOSC_TCXO_CTL_REG REG(0x2DC4)
112#define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080)
113#define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1)))
114#define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1)))
115#define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1)))
116#define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1)))
117#define SLIMBUS_XO_SRC_CLK_CTL_REG REG(0x2628)
118#define TSIF_HCLK_CTL_REG REG(0x2700)
119#define TSIF_REF_CLK_MD_REG REG(0x270C)
120#define TSIF_REF_CLK_NS_REG REG(0x2710)
121#define TSSC_CLK_CTL_REG REG(0x2CA0)
Tianyi Gou41515e22011-09-01 19:37:43 -0700122#define SATA_CLK_SRC_NS_REG REG(0x2C08)
123#define SATA_RXOOB_CLK_CTL_REG REG(0x2C0C)
124#define SATA_PMALIVE_CLK_CTL_REG REG(0x2C10)
125#define SATA_PHY_REF_CLK_CTL_REG REG(0x2C14)
126#define SATA_PHY_CFG_CLK_CTL_REG REG(0x2C40)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700127#define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1)))
128#define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1)))
129#define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1)))
130#define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1)))
131#define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1)))
132#define USB_HS1_HCLK_CTL_REG REG(0x2900)
Tianyi Gou41515e22011-09-01 19:37:43 -0700133#define USB_HS1_HCLK_FS_REG REG(0x2904)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700134#define USB_HS1_RESET_REG REG(0x2910)
135#define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908)
136#define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700137#define USB_HS3_HCLK_CTL_REG REG(0x3700)
138#define USB_HS3_HCLK_FS_REG REG(0x3704)
139#define USB_HS3_RESET_REG REG(0x3710)
140#define USB_HS3_XCVR_FS_CLK_MD_REG REG(0X3708)
141#define USB_HS3_XCVR_FS_CLK_NS_REG REG(0X370C)
142#define USB_HS4_HCLK_CTL_REG REG(0x3720)
143#define USB_HS4_HCLK_FS_REG REG(0x3724)
144#define USB_HS4_RESET_REG REG(0x3730)
145#define USB_HS4_XCVR_FS_CLK_MD_REG REG(0X3728)
146#define USB_HS4_XCVR_FS_CLK_NS_REG REG(0X372C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700147#define USB_HSIC_HCLK_CTL_REG REG(0x2920)
148#define USB_HSIC_HSIC_CLK_CTL_REG REG(0x2B44)
149#define USB_HSIC_HSIC_CLK_SRC_CTL_REG REG(0x2B40)
150#define USB_HSIC_HSIO_CAL_CLK_CTL_REG REG(0x2B48)
151#define USB_HSIC_RESET_REG REG(0x2934)
152#define USB_HSIC_SYSTEM_CLK_CTL_REG REG(0x292C)
153#define USB_HSIC_XCVR_FS_CLK_MD_REG REG(0x2924)
154#define USB_HSIC_XCVR_FS_CLK_NS_REG REG(0x2928)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700155#define USB_PHY0_RESET_REG REG(0x2E20)
Tianyi Gou41515e22011-09-01 19:37:43 -0700156#define PCIE_ALT_REF_CLK_NS_REG REG(0x3860)
157#define PCIE_HCLK_CTL_REG REG(0x22CC)
158#define GPLL1_MODE_REG REG(0x3160)
159#define GPLL1_L_VAL_REG REG(0x3164)
160#define GPLL1_M_VAL_REG REG(0x3168)
161#define GPLL1_N_VAL_REG REG(0x316C)
162#define GPLL1_CONFIG_REG REG(0x3174)
163#define GPLL1_STATUS_REG REG(0x3178)
164#define PXO_SRC_CLK_CTL_REG REG(0x2EA0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700165
166/* Multimedia clock registers. */
167#define AHB_EN_REG REG_MM(0x0008)
168#define AHB_EN2_REG REG_MM(0x0038)
Tianyi Gou41515e22011-09-01 19:37:43 -0700169#define AHB_EN3_REG REG_MM(0x0248)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700170#define AHB_NS_REG REG_MM(0x0004)
171#define AXI_NS_REG REG_MM(0x0014)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700172#define CAMCLK0_NS_REG REG_MM(0x0148)
173#define CAMCLK0_CC_REG REG_MM(0x0140)
174#define CAMCLK0_MD_REG REG_MM(0x0144)
175#define CAMCLK1_NS_REG REG_MM(0x015C)
176#define CAMCLK1_CC_REG REG_MM(0x0154)
177#define CAMCLK1_MD_REG REG_MM(0x0158)
178#define CAMCLK2_NS_REG REG_MM(0x0228)
179#define CAMCLK2_CC_REG REG_MM(0x0220)
180#define CAMCLK2_MD_REG REG_MM(0x0224)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700181#define CSI0_NS_REG REG_MM(0x0048)
182#define CSI0_CC_REG REG_MM(0x0040)
183#define CSI0_MD_REG REG_MM(0x0044)
184#define CSI1_NS_REG REG_MM(0x0010)
185#define CSI1_CC_REG REG_MM(0x0024)
186#define CSI1_MD_REG REG_MM(0x0028)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700187#define CSI2_NS_REG REG_MM(0x0234)
188#define CSI2_CC_REG REG_MM(0x022C)
189#define CSI2_MD_REG REG_MM(0x0230)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700190#define CSIPHYTIMER_CC_REG REG_MM(0x0160)
191#define CSIPHYTIMER_MD_REG REG_MM(0x0164)
192#define CSIPHYTIMER_NS_REG REG_MM(0x0168)
193#define DSI1_BYTE_NS_REG REG_MM(0x00B0)
194#define DSI1_BYTE_CC_REG REG_MM(0x0090)
195#define DSI2_BYTE_NS_REG REG_MM(0x00BC)
196#define DSI2_BYTE_CC_REG REG_MM(0x00B4)
197#define DSI1_ESC_NS_REG REG_MM(0x011C)
198#define DSI1_ESC_CC_REG REG_MM(0x00CC)
199#define DSI2_ESC_NS_REG REG_MM(0x0150)
200#define DSI2_ESC_CC_REG REG_MM(0x013C)
201#define DSI_PIXEL_CC_REG REG_MM(0x0130)
202#define DSI2_PIXEL_CC_REG REG_MM(0x0094)
203#define DBG_BUS_VEC_A_REG REG_MM(0x01C8)
204#define DBG_BUS_VEC_B_REG REG_MM(0x01CC)
205#define DBG_BUS_VEC_C_REG REG_MM(0x01D0)
206#define DBG_BUS_VEC_D_REG REG_MM(0x01D4)
207#define DBG_BUS_VEC_E_REG REG_MM(0x01D8)
208#define DBG_BUS_VEC_F_REG REG_MM(0x01DC)
209#define DBG_BUS_VEC_G_REG REG_MM(0x01E0)
210#define DBG_BUS_VEC_H_REG REG_MM(0x01E4)
211#define DBG_BUS_VEC_I_REG REG_MM(0x01E8)
Tianyi Gou41515e22011-09-01 19:37:43 -0700212#define DBG_BUS_VEC_J_REG REG_MM(0x0240)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700213#define DBG_CFG_REG_HS_REG REG_MM(0x01B4)
214#define DBG_CFG_REG_LS_REG REG_MM(0x01B8)
215#define GFX2D0_CC_REG REG_MM(0x0060)
216#define GFX2D0_MD0_REG REG_MM(0x0064)
217#define GFX2D0_MD1_REG REG_MM(0x0068)
218#define GFX2D0_NS_REG REG_MM(0x0070)
219#define GFX2D1_CC_REG REG_MM(0x0074)
220#define GFX2D1_MD0_REG REG_MM(0x0078)
221#define GFX2D1_MD1_REG REG_MM(0x006C)
222#define GFX2D1_NS_REG REG_MM(0x007C)
223#define GFX3D_CC_REG REG_MM(0x0080)
224#define GFX3D_MD0_REG REG_MM(0x0084)
225#define GFX3D_MD1_REG REG_MM(0x0088)
226#define GFX3D_NS_REG REG_MM(0x008C)
227#define IJPEG_CC_REG REG_MM(0x0098)
228#define IJPEG_MD_REG REG_MM(0x009C)
229#define IJPEG_NS_REG REG_MM(0x00A0)
230#define JPEGD_CC_REG REG_MM(0x00A4)
231#define JPEGD_NS_REG REG_MM(0x00AC)
Tianyi Gou41515e22011-09-01 19:37:43 -0700232#define VCAP_CC_REG REG_MM(0x0178)
233#define VCAP_NS_REG REG_MM(0x021C)
234#define VCAP_MD0_REG REG_MM(0x01EC)
235#define VCAP_MD1_REG REG_MM(0x0218)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700236#define MAXI_EN_REG REG_MM(0x0018)
237#define MAXI_EN2_REG REG_MM(0x0020)
238#define MAXI_EN3_REG REG_MM(0x002C)
239#define MAXI_EN4_REG REG_MM(0x0114)
Tianyi Gou41515e22011-09-01 19:37:43 -0700240#define MAXI_EN5_REG REG_MM(0x0244)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700241#define MDP_CC_REG REG_MM(0x00C0)
242#define MDP_LUT_CC_REG REG_MM(0x016C)
243#define MDP_MD0_REG REG_MM(0x00C4)
244#define MDP_MD1_REG REG_MM(0x00C8)
245#define MDP_NS_REG REG_MM(0x00D0)
246#define MISC_CC_REG REG_MM(0x0058)
247#define MISC_CC2_REG REG_MM(0x005C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700248#define MISC_CC3_REG REG_MM(0x0238)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700249#define MM_PLL1_MODE_REG REG_MM(0x031C)
Tianyi Gou41515e22011-09-01 19:37:43 -0700250#define MM_PLL1_L_VAL_REG REG_MM(0x0320)
251#define MM_PLL1_M_VAL_REG REG_MM(0x0324)
252#define MM_PLL1_N_VAL_REG REG_MM(0x0328)
253#define MM_PLL1_CONFIG_REG REG_MM(0x032C)
254#define MM_PLL1_TEST_CTL_REG REG_MM(0x0330)
255#define MM_PLL1_STATUS_REG REG_MM(0x0334)
256#define MM_PLL3_MODE_REG REG_MM(0x0338)
Tianyi Gou621f8742011-09-01 21:45:01 -0700257#define MM_PLL3_L_VAL_REG REG_MM(0x033C)
258#define MM_PLL3_M_VAL_REG REG_MM(0x0340)
259#define MM_PLL3_N_VAL_REG REG_MM(0x0344)
260#define MM_PLL3_CONFIG_REG REG_MM(0x0348)
261#define MM_PLL3_TEST_CTL_REG REG_MM(0x034C)
262#define MM_PLL3_STATUS_REG REG_MM(0x0350)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700263#define ROT_CC_REG REG_MM(0x00E0)
264#define ROT_NS_REG REG_MM(0x00E8)
265#define SAXI_EN_REG REG_MM(0x0030)
266#define SW_RESET_AHB_REG REG_MM(0x020C)
267#define SW_RESET_AHB2_REG REG_MM(0x0200)
268#define SW_RESET_ALL_REG REG_MM(0x0204)
269#define SW_RESET_AXI_REG REG_MM(0x0208)
270#define SW_RESET_CORE_REG REG_MM(0x0210)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700271#define SW_RESET_CORE2_REG REG_MM(0x0214)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700272#define TV_CC_REG REG_MM(0x00EC)
273#define TV_CC2_REG REG_MM(0x0124)
274#define TV_MD_REG REG_MM(0x00F0)
275#define TV_NS_REG REG_MM(0x00F4)
276#define VCODEC_CC_REG REG_MM(0x00F8)
277#define VCODEC_MD0_REG REG_MM(0x00FC)
278#define VCODEC_MD1_REG REG_MM(0x0128)
279#define VCODEC_NS_REG REG_MM(0x0100)
280#define VFE_CC_REG REG_MM(0x0104)
281#define VFE_MD_REG REG_MM(0x0108)
282#define VFE_NS_REG REG_MM(0x010C)
Stephen Boyd94625ef2011-07-12 17:06:01 -0700283#define VFE_CC2_REG REG_MM(0x023C)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700284#define VPE_CC_REG REG_MM(0x0110)
285#define VPE_NS_REG REG_MM(0x0118)
286
287/* Low-power Audio clock registers. */
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700288#define LCC_CLK_HS_DEBUG_CFG_REG REG_LPA(0x00A4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700289#define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8)
290#define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064)
291#define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060)
292#define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068)
293#define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070)
294#define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C)
295#define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074)
296#define LCC_MI2S_MD_REG REG_LPA(0x004C)
297#define LCC_MI2S_NS_REG REG_LPA(0x0048)
298#define LCC_MI2S_STATUS_REG REG_LPA(0x0050)
299#define LCC_PCM_MD_REG REG_LPA(0x0058)
300#define LCC_PCM_NS_REG REG_LPA(0x0054)
301#define LCC_PCM_STATUS_REG REG_LPA(0x005C)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700302#define LCC_PLL0_MODE_REG REG_LPA(0x0000)
303#define LCC_PLL0_L_VAL_REG REG_LPA(0x0004)
304#define LCC_PLL0_M_VAL_REG REG_LPA(0x0008)
305#define LCC_PLL0_N_VAL_REG REG_LPA(0x000C)
306#define LCC_PLL0_CONFIG_REG REG_LPA(0x0014)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700307#define LCC_PLL0_STATUS_REG REG_LPA(0x0018)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700308#define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C)
309#define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078)
310#define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080)
311#define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088)
312#define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084)
313#define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C)
314#define LCC_SLIMBUS_NS_REG REG_LPA(0x00CC)
315#define LCC_SLIMBUS_MD_REG REG_LPA(0x00D0)
316#define LCC_SLIMBUS_STATUS_REG REG_LPA(0x00D4)
317#define LCC_AHBEX_BRANCH_CTL_REG REG_LPA(0x00E4)
Tianyi Gouc29c3242011-10-12 21:02:15 -0700318#define LCC_PRI_PLL_CLK_CTL_REG REG_LPA(0x00C4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700319
Matt Wagantall8b38f942011-08-02 18:23:18 -0700320#define GCC_APCS_CLK_DIAG REG_GCC(0x001C)
321
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700322/* MUX source input identifiers. */
323#define pxo_to_bb_mux 0
Matt Wagantall7625a4c2011-11-01 16:17:53 -0700324#define cxo_to_bb_mux 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700325#define pll0_to_bb_mux 2
326#define pll8_to_bb_mux 3
327#define pll6_to_bb_mux 4
328#define gnd_to_bb_mux 5
Stephen Boyd94625ef2011-07-12 17:06:01 -0700329#define pll3_to_bb_mux 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700330#define pxo_to_mm_mux 0
331#define pll1_to_mm_mux 1
Tianyi Gou41515e22011-09-01 19:37:43 -0700332#define pll2_to_mm_mux 1 /* or MMCC_PLL1 */
333#define pll8_to_mm_mux 2 /* or GCC_PERF */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700334#define pll0_to_mm_mux 3
Tianyi Gou41515e22011-09-01 19:37:43 -0700335#define pll15_to_mm_mux 3 /* or MM_PLL3 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700336#define gnd_to_mm_mux 4
Stephen Boyd7a776cd2011-10-20 12:46:04 -0700337#define pll3_to_mm_mux 3 /* or MMCC_PLL2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700338#define hdmi_pll_to_mm_mux 3
339#define cxo_to_xo_mux 0
340#define pxo_to_xo_mux 1
341#define gnd_to_xo_mux 3
342#define pxo_to_lpa_mux 0
343#define cxo_to_lpa_mux 1
344#define pll4_to_lpa_mux 2
345#define gnd_to_lpa_mux 6
Tianyi Gou41515e22011-09-01 19:37:43 -0700346#define pxo_to_pcie_mux 0
347#define pll3_to_pcie_mux 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700348
349/* Test Vector Macros */
350#define TEST_TYPE_PER_LS 1
351#define TEST_TYPE_PER_HS 2
352#define TEST_TYPE_MM_LS 3
353#define TEST_TYPE_MM_HS 4
354#define TEST_TYPE_LPA 5
Matt Wagantall8b38f942011-08-02 18:23:18 -0700355#define TEST_TYPE_CPUL2 6
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700356#define TEST_TYPE_LPA_HS 7
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700357#define TEST_TYPE_SHIFT 24
358#define TEST_CLK_SEL_MASK BM(23, 0)
359#define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s)))
360#define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS)
361#define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS)
362#define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS)
363#define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS)
364#define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA)
Stephen Boyd3939c8d2011-08-29 17:36:22 -0700365#define TEST_LPA_HS(s) TEST_VECTOR((s), TEST_TYPE_LPA_HS)
Matt Wagantall8b38f942011-08-02 18:23:18 -0700366#define TEST_CPUL2(s) TEST_VECTOR((s), TEST_TYPE_CPUL2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700367
368#define MN_MODE_DUAL_EDGE 0x2
369
370/* MD Registers */
371#define MD4(m_lsb, m, n_lsb, n) \
372 (BVAL((m_lsb+3), m_lsb, m) | BVAL((n_lsb+3), n_lsb, ~(n)))
373#define MD8(m_lsb, m, n_lsb, n) \
374 (BVAL((m_lsb+7), m_lsb, m) | BVAL((n_lsb+7), n_lsb, ~(n)))
375#define MD16(m, n) (BVAL(31, 16, m) | BVAL(15, 0, ~(n)))
376
377/* NS Registers */
378#define NS(n_msb, n_lsb, n, m, mde_lsb, d_msb, d_lsb, d, s_msb, s_lsb, s) \
379 (BVAL(n_msb, n_lsb, ~(n-m)) \
380 | (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n)) \
381 | BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
382
383#define NS_MM(n_msb, n_lsb, n, m, d_msb, d_lsb, d, s_msb, s_lsb, s) \
384 (BVAL(n_msb, n_lsb, ~(n-m)) | BVAL(d_msb, d_lsb, (d-1)) \
385 | BVAL(s_msb, s_lsb, s))
386
387#define NS_DIVSRC(d_msb , d_lsb, d, s_msb, s_lsb, s) \
388 (BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s))
389
390#define NS_DIV(d_msb , d_lsb, d) \
391 BVAL(d_msb, d_lsb, (d-1))
392
393#define NS_SRC_SEL(s_msb, s_lsb, s) \
394 BVAL(s_msb, s_lsb, s)
395
396#define NS_MND_BANKED4(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
397 (BVAL((n0_lsb+3), n0_lsb, ~(n-m)) \
398 | BVAL((n1_lsb+3), n1_lsb, ~(n-m)) \
399 | BVAL((s0_lsb+2), s0_lsb, s) \
400 | BVAL((s1_lsb+2), s1_lsb, s))
401
402#define NS_MND_BANKED8(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \
403 (BVAL((n0_lsb+7), n0_lsb, ~(n-m)) \
404 | BVAL((n1_lsb+7), n1_lsb, ~(n-m)) \
405 | BVAL((s0_lsb+2), s0_lsb, s) \
406 | BVAL((s1_lsb+2), s1_lsb, s))
407
408#define NS_DIVSRC_BANKED(d0_msb, d0_lsb, d1_msb, d1_lsb, d, \
409 s0_msb, s0_lsb, s1_msb, s1_lsb, s) \
410 (BVAL(d0_msb, d0_lsb, (d-1)) | BVAL(d1_msb, d1_lsb, (d-1)) \
411 | BVAL(s0_msb, s0_lsb, s) \
412 | BVAL(s1_msb, s1_lsb, s))
413
414/* CC Registers */
415#define CC(mde_lsb, n) (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n))
416#define CC_BANKED(mde0_lsb, mde1_lsb, n) \
417 ((BVAL((mde0_lsb+1), mde0_lsb, MN_MODE_DUAL_EDGE) \
418 | BVAL((mde1_lsb+1), mde1_lsb, MN_MODE_DUAL_EDGE)) \
419 * !!(n))
420
421struct pll_rate {
422 const uint32_t l_val;
423 const uint32_t m_val;
424 const uint32_t n_val;
425 const uint32_t vco;
426 const uint32_t post_div;
427 const uint32_t i_bits;
428};
429#define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i }
430
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700431enum vdd_dig_levels {
432 VDD_DIG_NONE,
433 VDD_DIG_LOW,
434 VDD_DIG_NOMINAL,
435 VDD_DIG_HIGH
436};
437
438static int set_vdd_dig(struct clk_vdd_class *vdd_class, int level)
439{
440 static const int vdd_uv[] = {
441 [VDD_DIG_NONE] = 0,
442 [VDD_DIG_LOW] = 945000,
443 [VDD_DIG_NOMINAL] = 1050000,
444 [VDD_DIG_HIGH] = 1150000
445 };
446
447 return rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S3, RPM_VREG_VOTER3,
448 vdd_uv[level], 1150000, 1);
449}
450
451static DEFINE_VDD_CLASS(vdd_dig, set_vdd_dig);
452
453#define VDD_DIG_FMAX_MAP1(l1, f1) \
454 .vdd_class = &vdd_dig, \
455 .fmax[VDD_DIG_##l1] = (f1)
456#define VDD_DIG_FMAX_MAP2(l1, f1, l2, f2) \
457 .vdd_class = &vdd_dig, \
458 .fmax[VDD_DIG_##l1] = (f1), \
459 .fmax[VDD_DIG_##l2] = (f2)
460#define VDD_DIG_FMAX_MAP3(l1, f1, l2, f2, l3, f3) \
461 .vdd_class = &vdd_dig, \
462 .fmax[VDD_DIG_##l1] = (f1), \
463 .fmax[VDD_DIG_##l2] = (f2), \
464 .fmax[VDD_DIG_##l3] = (f3)
465
Matt Wagantallc57577d2011-10-06 17:06:53 -0700466enum vdd_l23_levels {
467 VDD_L23_OFF,
468 VDD_L23_ON
469};
470
471static int set_vdd_l23(struct clk_vdd_class *vdd_class, int level)
472{
473 int rc;
474
475 if (level == VDD_L23_OFF) {
476 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
477 RPM_VREG_VOTER3, 0, 0, 1);
478 if (rc)
479 return rc;
480 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
481 RPM_VREG_VOTER3, 0, 0, 1);
482 if (rc)
483 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
484 RPM_VREG_VOTER3, 1800000, 1800000, 1);
485 } else {
486 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
487 RPM_VREG_VOTER3, 2200000, 2200000, 1);
488 if (rc)
489 return rc;
490 rc = rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_L23,
491 RPM_VREG_VOTER3, 1800000, 1800000, 1);
492 if (rc)
493 rpm_vreg_set_voltage(RPM_VREG_ID_PM8921_S8,
494 RPM_VREG_VOTER3, 0, 0, 1);
495 }
496
497 return rc;
498}
499
500static DEFINE_VDD_CLASS(vdd_l23, set_vdd_l23);
501
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700502/*
503 * Clock Descriptions
504 */
505
506static struct msm_xo_voter *xo_pxo, *xo_cxo;
507
508static int pxo_clk_enable(struct clk *clk)
509{
510 return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON);
511}
512
513static void pxo_clk_disable(struct clk *clk)
514{
Tianyi Gou41515e22011-09-01 19:37:43 -0700515 msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700516}
517
518static struct clk_ops clk_ops_pxo = {
519 .enable = pxo_clk_enable,
520 .disable = pxo_clk_disable,
521 .get_rate = fixed_clk_get_rate,
522 .is_local = local_clk_is_local,
523};
524
525static struct fixed_clk pxo_clk = {
526 .rate = 27000000,
527 .c = {
528 .dbg_name = "pxo_clk",
529 .ops = &clk_ops_pxo,
530 CLK_INIT(pxo_clk.c),
531 },
532};
533
534static int cxo_clk_enable(struct clk *clk)
535{
536 return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON);
537}
538
539static void cxo_clk_disable(struct clk *clk)
540{
541 msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF);
542}
543
544static struct clk_ops clk_ops_cxo = {
545 .enable = cxo_clk_enable,
546 .disable = cxo_clk_disable,
547 .get_rate = fixed_clk_get_rate,
548 .is_local = local_clk_is_local,
549};
550
551static struct fixed_clk cxo_clk = {
552 .rate = 19200000,
553 .c = {
554 .dbg_name = "cxo_clk",
555 .ops = &clk_ops_cxo,
556 CLK_INIT(cxo_clk.c),
557 },
558};
559
560static struct pll_clk pll2_clk = {
561 .rate = 800000000,
562 .mode_reg = MM_PLL1_MODE_REG,
563 .parent = &pxo_clk.c,
564 .c = {
565 .dbg_name = "pll2_clk",
566 .ops = &clk_ops_pll,
567 CLK_INIT(pll2_clk.c),
568 },
569};
570
Stephen Boyd94625ef2011-07-12 17:06:01 -0700571static struct pll_clk pll3_clk = {
572 .rate = 1200000000,
573 .mode_reg = BB_MMCC_PLL2_MODE_REG,
574 .parent = &pxo_clk.c,
575 .c = {
576 .dbg_name = "pll3_clk",
577 .ops = &clk_ops_pll,
Matt Wagantallc57577d2011-10-06 17:06:53 -0700578 .vdd_class = &vdd_l23,
579 .fmax[VDD_L23_ON] = ULONG_MAX,
Stephen Boyd94625ef2011-07-12 17:06:01 -0700580 CLK_INIT(pll3_clk.c),
581 },
582};
583
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700584static struct pll_vote_clk pll4_clk = {
585 .rate = 393216000,
586 .en_reg = BB_PLL_ENA_SC0_REG,
587 .en_mask = BIT(4),
588 .status_reg = LCC_PLL0_STATUS_REG,
589 .parent = &pxo_clk.c,
590 .c = {
591 .dbg_name = "pll4_clk",
592 .ops = &clk_ops_pll_vote,
593 CLK_INIT(pll4_clk.c),
594 },
595};
596
597static struct pll_vote_clk pll8_clk = {
598 .rate = 384000000,
599 .en_reg = BB_PLL_ENA_SC0_REG,
600 .en_mask = BIT(8),
601 .status_reg = BB_PLL8_STATUS_REG,
602 .parent = &pxo_clk.c,
603 .c = {
604 .dbg_name = "pll8_clk",
605 .ops = &clk_ops_pll_vote,
606 CLK_INIT(pll8_clk.c),
607 },
608};
609
Stephen Boyd94625ef2011-07-12 17:06:01 -0700610static struct pll_vote_clk pll14_clk = {
611 .rate = 480000000,
612 .en_reg = BB_PLL_ENA_SC0_REG,
613 .en_mask = BIT(14),
614 .status_reg = BB_PLL14_STATUS_REG,
615 .parent = &pxo_clk.c,
616 .c = {
617 .dbg_name = "pll14_clk",
618 .ops = &clk_ops_pll_vote,
619 CLK_INIT(pll14_clk.c),
620 },
621};
622
Tianyi Gou41515e22011-09-01 19:37:43 -0700623static struct pll_clk pll15_clk = {
624 .rate = 975000000,
625 .mode_reg = MM_PLL3_MODE_REG,
626 .parent = &pxo_clk.c,
627 .c = {
628 .dbg_name = "pll15_clk",
629 .ops = &clk_ops_pll,
630 CLK_INIT(pll15_clk.c),
631 },
632};
633
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700634static struct clk_ops clk_ops_rcg_8960 = {
Matt Wagantall0625ea02011-07-13 18:51:56 -0700635 .enable = rcg_clk_enable,
636 .disable = rcg_clk_disable,
Matt Wagantall41af0772011-09-17 12:21:39 -0700637 .auto_off = rcg_clk_disable,
Matt Wagantall53d968f2011-07-19 13:22:53 -0700638 .handoff = rcg_clk_handoff,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700639 .set_rate = rcg_clk_set_rate,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700640 .get_rate = rcg_clk_get_rate,
641 .list_rate = rcg_clk_list_rate,
642 .is_enabled = rcg_clk_is_enabled,
643 .round_rate = rcg_clk_round_rate,
Stephen Boyd7bf28142011-12-07 00:30:52 -0800644 .reset = rcg_clk_reset,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700645 .is_local = local_clk_is_local,
Matt Wagantall0625ea02011-07-13 18:51:56 -0700646 .get_parent = rcg_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700647};
648
649static struct clk_ops clk_ops_branch = {
650 .enable = branch_clk_enable,
651 .disable = branch_clk_disable,
Matt Wagantall41af0772011-09-17 12:21:39 -0700652 .auto_off = branch_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700653 .is_enabled = branch_clk_is_enabled,
654 .reset = branch_clk_reset,
655 .is_local = local_clk_is_local,
656 .get_parent = branch_clk_get_parent,
657 .set_parent = branch_clk_set_parent,
658};
659
660static struct clk_ops clk_ops_reset = {
661 .reset = branch_clk_reset,
662 .is_local = local_clk_is_local,
663};
664
665/* AXI Interfaces */
666static struct branch_clk gmem_axi_clk = {
667 .b = {
668 .ctl_reg = MAXI_EN_REG,
669 .en_mask = BIT(24),
670 .halt_reg = DBG_BUS_VEC_E_REG,
671 .halt_bit = 6,
672 },
673 .c = {
674 .dbg_name = "gmem_axi_clk",
675 .ops = &clk_ops_branch,
676 CLK_INIT(gmem_axi_clk.c),
677 },
678};
679
680static struct branch_clk ijpeg_axi_clk = {
681 .b = {
682 .ctl_reg = MAXI_EN_REG,
683 .en_mask = BIT(21),
684 .reset_reg = SW_RESET_AXI_REG,
685 .reset_mask = BIT(14),
686 .halt_reg = DBG_BUS_VEC_E_REG,
687 .halt_bit = 4,
688 },
689 .c = {
690 .dbg_name = "ijpeg_axi_clk",
691 .ops = &clk_ops_branch,
692 CLK_INIT(ijpeg_axi_clk.c),
693 },
694};
695
696static struct branch_clk imem_axi_clk = {
697 .b = {
698 .ctl_reg = MAXI_EN_REG,
699 .en_mask = BIT(22),
700 .reset_reg = SW_RESET_CORE_REG,
701 .reset_mask = BIT(10),
702 .halt_reg = DBG_BUS_VEC_E_REG,
703 .halt_bit = 7,
704 },
705 .c = {
706 .dbg_name = "imem_axi_clk",
707 .ops = &clk_ops_branch,
708 CLK_INIT(imem_axi_clk.c),
709 },
710};
711
712static struct branch_clk jpegd_axi_clk = {
713 .b = {
714 .ctl_reg = MAXI_EN_REG,
715 .en_mask = BIT(25),
716 .halt_reg = DBG_BUS_VEC_E_REG,
717 .halt_bit = 5,
718 },
719 .c = {
720 .dbg_name = "jpegd_axi_clk",
721 .ops = &clk_ops_branch,
722 CLK_INIT(jpegd_axi_clk.c),
723 },
724};
725
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700726static struct branch_clk vcodec_axi_b_clk = {
727 .b = {
728 .ctl_reg = MAXI_EN4_REG,
729 .en_mask = BIT(23),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700730 .halt_reg = DBG_BUS_VEC_I_REG,
731 .halt_bit = 25,
732 },
733 .c = {
734 .dbg_name = "vcodec_axi_b_clk",
735 .ops = &clk_ops_branch,
736 CLK_INIT(vcodec_axi_b_clk.c),
737 },
738};
739
Matt Wagantall91f42702011-07-14 12:01:15 -0700740static struct branch_clk vcodec_axi_a_clk = {
741 .b = {
742 .ctl_reg = MAXI_EN4_REG,
743 .en_mask = BIT(25),
Matt Wagantall91f42702011-07-14 12:01:15 -0700744 .halt_reg = DBG_BUS_VEC_I_REG,
745 .halt_bit = 26,
746 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700747 .c = {
748 .dbg_name = "vcodec_axi_a_clk",
749 .ops = &clk_ops_branch,
750 CLK_INIT(vcodec_axi_a_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700751 .depends = &vcodec_axi_b_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700752 },
753};
754
755static struct branch_clk vcodec_axi_clk = {
756 .b = {
757 .ctl_reg = MAXI_EN_REG,
758 .en_mask = BIT(19),
759 .reset_reg = SW_RESET_AXI_REG,
Matt Wagantallfe2ee052011-07-14 13:33:44 -0700760 .reset_mask = BIT(4)|BIT(5)|BIT(7),
Matt Wagantall91f42702011-07-14 12:01:15 -0700761 .halt_reg = DBG_BUS_VEC_E_REG,
762 .halt_bit = 3,
763 },
Matt Wagantall91f42702011-07-14 12:01:15 -0700764 .c = {
765 .dbg_name = "vcodec_axi_clk",
766 .ops = &clk_ops_branch,
767 CLK_INIT(vcodec_axi_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -0700768 .depends = &vcodec_axi_a_clk.c,
Matt Wagantall91f42702011-07-14 12:01:15 -0700769 },
770};
771
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700772static struct branch_clk vfe_axi_clk = {
773 .b = {
774 .ctl_reg = MAXI_EN_REG,
775 .en_mask = BIT(18),
776 .reset_reg = SW_RESET_AXI_REG,
777 .reset_mask = BIT(9),
778 .halt_reg = DBG_BUS_VEC_E_REG,
779 .halt_bit = 0,
780 },
781 .c = {
782 .dbg_name = "vfe_axi_clk",
783 .ops = &clk_ops_branch,
784 CLK_INIT(vfe_axi_clk.c),
785 },
786};
787
788static struct branch_clk mdp_axi_clk = {
789 .b = {
790 .ctl_reg = MAXI_EN_REG,
791 .en_mask = BIT(23),
792 .reset_reg = SW_RESET_AXI_REG,
793 .reset_mask = BIT(13),
794 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700795 .halt_bit = 8,
796 },
797 .c = {
798 .dbg_name = "mdp_axi_clk",
799 .ops = &clk_ops_branch,
800 CLK_INIT(mdp_axi_clk.c),
801 },
802};
803
804static struct branch_clk rot_axi_clk = {
805 .b = {
806 .ctl_reg = MAXI_EN2_REG,
807 .en_mask = BIT(24),
808 .reset_reg = SW_RESET_AXI_REG,
809 .reset_mask = BIT(6),
810 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700811 .halt_bit = 2,
812 },
813 .c = {
814 .dbg_name = "rot_axi_clk",
815 .ops = &clk_ops_branch,
816 CLK_INIT(rot_axi_clk.c),
817 },
818};
819
820static struct branch_clk vpe_axi_clk = {
821 .b = {
822 .ctl_reg = MAXI_EN2_REG,
823 .en_mask = BIT(26),
824 .reset_reg = SW_RESET_AXI_REG,
825 .reset_mask = BIT(15),
826 .halt_reg = DBG_BUS_VEC_E_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700827 .halt_bit = 1,
828 },
829 .c = {
830 .dbg_name = "vpe_axi_clk",
831 .ops = &clk_ops_branch,
832 CLK_INIT(vpe_axi_clk.c),
833 },
834};
835
Tianyi Gou41515e22011-09-01 19:37:43 -0700836static struct branch_clk vcap_axi_clk = {
837 .b = {
838 .ctl_reg = MAXI_EN5_REG,
839 .en_mask = BIT(12),
840 .reset_reg = SW_RESET_AXI_REG,
841 .reset_mask = BIT(16),
842 .halt_reg = DBG_BUS_VEC_J_REG,
843 .halt_bit = 20,
844 },
845 .c = {
846 .dbg_name = "vcap_axi_clk",
847 .ops = &clk_ops_branch,
848 CLK_INIT(vcap_axi_clk.c),
849 },
850};
851
Tianyi Gou621f8742011-09-01 21:45:01 -0700852/* For 8064, gfx3d_axi_clk is set as a dependency of gmem_axi_clk at runtime */
853static struct branch_clk gfx3d_axi_clk = {
854 .b = {
855 .ctl_reg = MAXI_EN5_REG,
856 .en_mask = BIT(25),
857 .reset_reg = SW_RESET_AXI_REG,
858 .reset_mask = BIT(17),
859 .halt_reg = DBG_BUS_VEC_J_REG,
860 .halt_bit = 30,
861 },
862 .c = {
863 .dbg_name = "gfx3d_axi_clk",
864 .ops = &clk_ops_branch,
865 CLK_INIT(gfx3d_axi_clk.c),
866 },
867};
868
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700869/* AHB Interfaces */
870static struct branch_clk amp_p_clk = {
871 .b = {
872 .ctl_reg = AHB_EN_REG,
873 .en_mask = BIT(24),
874 .halt_reg = DBG_BUS_VEC_F_REG,
875 .halt_bit = 18,
876 },
877 .c = {
878 .dbg_name = "amp_p_clk",
879 .ops = &clk_ops_branch,
880 CLK_INIT(amp_p_clk.c),
881 },
882};
883
Matt Wagantallc23eee92011-08-16 23:06:52 -0700884static struct branch_clk csi_p_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700885 .b = {
886 .ctl_reg = AHB_EN_REG,
887 .en_mask = BIT(7),
888 .reset_reg = SW_RESET_AHB_REG,
889 .reset_mask = BIT(17),
890 .halt_reg = DBG_BUS_VEC_F_REG,
891 .halt_bit = 16,
892 },
893 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -0700894 .dbg_name = "csi_p_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700895 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -0700896 CLK_INIT(csi_p_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700897 },
898};
899
900static struct branch_clk dsi1_m_p_clk = {
901 .b = {
902 .ctl_reg = AHB_EN_REG,
903 .en_mask = BIT(9),
904 .reset_reg = SW_RESET_AHB_REG,
905 .reset_mask = BIT(6),
906 .halt_reg = DBG_BUS_VEC_F_REG,
907 .halt_bit = 19,
908 },
909 .c = {
910 .dbg_name = "dsi1_m_p_clk",
911 .ops = &clk_ops_branch,
912 CLK_INIT(dsi1_m_p_clk.c),
913 },
914};
915
916static struct branch_clk dsi1_s_p_clk = {
917 .b = {
918 .ctl_reg = AHB_EN_REG,
919 .en_mask = BIT(18),
920 .reset_reg = SW_RESET_AHB_REG,
921 .reset_mask = BIT(5),
922 .halt_reg = DBG_BUS_VEC_F_REG,
923 .halt_bit = 21,
924 },
925 .c = {
926 .dbg_name = "dsi1_s_p_clk",
927 .ops = &clk_ops_branch,
928 CLK_INIT(dsi1_s_p_clk.c),
929 },
930};
931
932static struct branch_clk dsi2_m_p_clk = {
933 .b = {
934 .ctl_reg = AHB_EN_REG,
935 .en_mask = BIT(17),
936 .reset_reg = SW_RESET_AHB2_REG,
937 .reset_mask = BIT(1),
938 .halt_reg = DBG_BUS_VEC_E_REG,
939 .halt_bit = 18,
940 },
941 .c = {
942 .dbg_name = "dsi2_m_p_clk",
943 .ops = &clk_ops_branch,
944 CLK_INIT(dsi2_m_p_clk.c),
945 },
946};
947
948static struct branch_clk dsi2_s_p_clk = {
949 .b = {
950 .ctl_reg = AHB_EN_REG,
951 .en_mask = BIT(22),
952 .reset_reg = SW_RESET_AHB2_REG,
953 .reset_mask = BIT(0),
954 .halt_reg = DBG_BUS_VEC_F_REG,
955 .halt_bit = 20,
956 },
957 .c = {
958 .dbg_name = "dsi2_s_p_clk",
959 .ops = &clk_ops_branch,
960 CLK_INIT(dsi2_s_p_clk.c),
961 },
962};
963
964static struct branch_clk gfx2d0_p_clk = {
965 .b = {
966 .ctl_reg = AHB_EN_REG,
967 .en_mask = BIT(19),
968 .reset_reg = SW_RESET_AHB_REG,
969 .reset_mask = BIT(12),
970 .halt_reg = DBG_BUS_VEC_F_REG,
971 .halt_bit = 2,
972 },
973 .c = {
974 .dbg_name = "gfx2d0_p_clk",
975 .ops = &clk_ops_branch,
976 CLK_INIT(gfx2d0_p_clk.c),
977 },
978};
979
980static struct branch_clk gfx2d1_p_clk = {
981 .b = {
982 .ctl_reg = AHB_EN_REG,
983 .en_mask = BIT(2),
984 .reset_reg = SW_RESET_AHB_REG,
985 .reset_mask = BIT(11),
986 .halt_reg = DBG_BUS_VEC_F_REG,
987 .halt_bit = 3,
988 },
989 .c = {
990 .dbg_name = "gfx2d1_p_clk",
991 .ops = &clk_ops_branch,
992 CLK_INIT(gfx2d1_p_clk.c),
993 },
994};
995
996static struct branch_clk gfx3d_p_clk = {
997 .b = {
998 .ctl_reg = AHB_EN_REG,
999 .en_mask = BIT(3),
1000 .reset_reg = SW_RESET_AHB_REG,
1001 .reset_mask = BIT(10),
1002 .halt_reg = DBG_BUS_VEC_F_REG,
1003 .halt_bit = 4,
1004 },
1005 .c = {
1006 .dbg_name = "gfx3d_p_clk",
1007 .ops = &clk_ops_branch,
1008 CLK_INIT(gfx3d_p_clk.c),
1009 },
1010};
1011
1012static struct branch_clk hdmi_m_p_clk = {
1013 .b = {
1014 .ctl_reg = AHB_EN_REG,
1015 .en_mask = BIT(14),
1016 .reset_reg = SW_RESET_AHB_REG,
1017 .reset_mask = BIT(9),
1018 .halt_reg = DBG_BUS_VEC_F_REG,
1019 .halt_bit = 5,
1020 },
1021 .c = {
1022 .dbg_name = "hdmi_m_p_clk",
1023 .ops = &clk_ops_branch,
1024 CLK_INIT(hdmi_m_p_clk.c),
1025 },
1026};
1027
1028static struct branch_clk hdmi_s_p_clk = {
1029 .b = {
1030 .ctl_reg = AHB_EN_REG,
1031 .en_mask = BIT(4),
1032 .reset_reg = SW_RESET_AHB_REG,
1033 .reset_mask = BIT(9),
1034 .halt_reg = DBG_BUS_VEC_F_REG,
1035 .halt_bit = 6,
1036 },
1037 .c = {
1038 .dbg_name = "hdmi_s_p_clk",
1039 .ops = &clk_ops_branch,
1040 CLK_INIT(hdmi_s_p_clk.c),
1041 },
1042};
1043
1044static struct branch_clk ijpeg_p_clk = {
1045 .b = {
1046 .ctl_reg = AHB_EN_REG,
1047 .en_mask = BIT(5),
1048 .reset_reg = SW_RESET_AHB_REG,
1049 .reset_mask = BIT(7),
1050 .halt_reg = DBG_BUS_VEC_F_REG,
1051 .halt_bit = 9,
1052 },
1053 .c = {
1054 .dbg_name = "ijpeg_p_clk",
1055 .ops = &clk_ops_branch,
1056 CLK_INIT(ijpeg_p_clk.c),
1057 },
1058};
1059
1060static struct branch_clk imem_p_clk = {
1061 .b = {
1062 .ctl_reg = AHB_EN_REG,
1063 .en_mask = BIT(6),
1064 .reset_reg = SW_RESET_AHB_REG,
1065 .reset_mask = BIT(8),
1066 .halt_reg = DBG_BUS_VEC_F_REG,
1067 .halt_bit = 10,
1068 },
1069 .c = {
1070 .dbg_name = "imem_p_clk",
1071 .ops = &clk_ops_branch,
1072 CLK_INIT(imem_p_clk.c),
1073 },
1074};
1075
1076static struct branch_clk jpegd_p_clk = {
1077 .b = {
1078 .ctl_reg = AHB_EN_REG,
1079 .en_mask = BIT(21),
1080 .reset_reg = SW_RESET_AHB_REG,
1081 .reset_mask = BIT(4),
1082 .halt_reg = DBG_BUS_VEC_F_REG,
1083 .halt_bit = 7,
1084 },
1085 .c = {
1086 .dbg_name = "jpegd_p_clk",
1087 .ops = &clk_ops_branch,
1088 CLK_INIT(jpegd_p_clk.c),
1089 },
1090};
1091
1092static struct branch_clk mdp_p_clk = {
1093 .b = {
1094 .ctl_reg = AHB_EN_REG,
1095 .en_mask = BIT(10),
1096 .reset_reg = SW_RESET_AHB_REG,
1097 .reset_mask = BIT(3),
1098 .halt_reg = DBG_BUS_VEC_F_REG,
1099 .halt_bit = 11,
1100 },
1101 .c = {
1102 .dbg_name = "mdp_p_clk",
1103 .ops = &clk_ops_branch,
1104 CLK_INIT(mdp_p_clk.c),
1105 },
1106};
1107
1108static struct branch_clk rot_p_clk = {
1109 .b = {
1110 .ctl_reg = AHB_EN_REG,
1111 .en_mask = BIT(12),
1112 .reset_reg = SW_RESET_AHB_REG,
1113 .reset_mask = BIT(2),
1114 .halt_reg = DBG_BUS_VEC_F_REG,
1115 .halt_bit = 13,
1116 },
1117 .c = {
1118 .dbg_name = "rot_p_clk",
1119 .ops = &clk_ops_branch,
1120 CLK_INIT(rot_p_clk.c),
1121 },
1122};
1123
1124static struct branch_clk smmu_p_clk = {
1125 .b = {
1126 .ctl_reg = AHB_EN_REG,
1127 .en_mask = BIT(15),
1128 .halt_reg = DBG_BUS_VEC_F_REG,
1129 .halt_bit = 22,
1130 },
1131 .c = {
1132 .dbg_name = "smmu_p_clk",
1133 .ops = &clk_ops_branch,
1134 CLK_INIT(smmu_p_clk.c),
1135 },
1136};
1137
1138static struct branch_clk tv_enc_p_clk = {
1139 .b = {
1140 .ctl_reg = AHB_EN_REG,
1141 .en_mask = BIT(25),
1142 .reset_reg = SW_RESET_AHB_REG,
1143 .reset_mask = BIT(15),
1144 .halt_reg = DBG_BUS_VEC_F_REG,
1145 .halt_bit = 23,
1146 },
1147 .c = {
1148 .dbg_name = "tv_enc_p_clk",
1149 .ops = &clk_ops_branch,
1150 CLK_INIT(tv_enc_p_clk.c),
1151 },
1152};
1153
1154static struct branch_clk vcodec_p_clk = {
1155 .b = {
1156 .ctl_reg = AHB_EN_REG,
1157 .en_mask = BIT(11),
1158 .reset_reg = SW_RESET_AHB_REG,
1159 .reset_mask = BIT(1),
1160 .halt_reg = DBG_BUS_VEC_F_REG,
1161 .halt_bit = 12,
1162 },
1163 .c = {
1164 .dbg_name = "vcodec_p_clk",
1165 .ops = &clk_ops_branch,
1166 CLK_INIT(vcodec_p_clk.c),
1167 },
1168};
1169
1170static struct branch_clk vfe_p_clk = {
1171 .b = {
1172 .ctl_reg = AHB_EN_REG,
1173 .en_mask = BIT(13),
1174 .reset_reg = SW_RESET_AHB_REG,
1175 .reset_mask = BIT(0),
1176 .halt_reg = DBG_BUS_VEC_F_REG,
1177 .halt_bit = 14,
1178 },
1179 .c = {
1180 .dbg_name = "vfe_p_clk",
1181 .ops = &clk_ops_branch,
1182 CLK_INIT(vfe_p_clk.c),
1183 },
1184};
1185
1186static struct branch_clk vpe_p_clk = {
1187 .b = {
1188 .ctl_reg = AHB_EN_REG,
1189 .en_mask = BIT(16),
1190 .reset_reg = SW_RESET_AHB_REG,
1191 .reset_mask = BIT(14),
1192 .halt_reg = DBG_BUS_VEC_F_REG,
1193 .halt_bit = 15,
1194 },
1195 .c = {
1196 .dbg_name = "vpe_p_clk",
1197 .ops = &clk_ops_branch,
1198 CLK_INIT(vpe_p_clk.c),
1199 },
1200};
1201
Tianyi Gou41515e22011-09-01 19:37:43 -07001202static struct branch_clk vcap_p_clk = {
1203 .b = {
1204 .ctl_reg = AHB_EN3_REG,
1205 .en_mask = BIT(1),
1206 .reset_reg = SW_RESET_AHB2_REG,
1207 .reset_mask = BIT(2),
1208 .halt_reg = DBG_BUS_VEC_J_REG,
1209 .halt_bit = 23,
1210 },
1211 .c = {
1212 .dbg_name = "vcap_p_clk",
1213 .ops = &clk_ops_branch,
1214 CLK_INIT(vcap_p_clk.c),
1215 },
1216};
1217
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001218/*
1219 * Peripheral Clocks
1220 */
Matt Wagantall7625a4c2011-11-01 16:17:53 -07001221#define CLK_GP(i, n, h_r, h_b) \
1222 struct rcg_clk i##_clk = { \
1223 .b = { \
1224 .ctl_reg = GPn_NS_REG(n), \
1225 .en_mask = BIT(9), \
1226 .halt_reg = h_r, \
1227 .halt_bit = h_b, \
1228 }, \
1229 .ns_reg = GPn_NS_REG(n), \
1230 .md_reg = GPn_MD_REG(n), \
1231 .root_en_mask = BIT(11), \
1232 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1233 .set_rate = set_rate_mnd, \
1234 .freq_tbl = clk_tbl_gp, \
1235 .current_freq = &rcg_dummy_freq, \
1236 .c = { \
1237 .dbg_name = #i "_clk", \
1238 .ops = &clk_ops_rcg_8960, \
1239 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000), \
1240 CLK_INIT(i##_clk.c), \
1241 }, \
1242 }
1243#define F_GP(f, s, d, m, n) \
1244 { \
1245 .freq_hz = f, \
1246 .src_clk = &s##_clk.c, \
1247 .md_val = MD8(16, m, 0, n), \
1248 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1249 .mnd_en_mask = BIT(8) * !!(n), \
1250 }
1251static struct clk_freq_tbl clk_tbl_gp[] = {
1252 F_GP( 0, gnd, 1, 0, 0),
1253 F_GP( 9600000, cxo, 2, 0, 0),
1254 F_GP( 13500000, pxo, 2, 0, 0),
1255 F_GP( 19200000, cxo, 1, 0, 0),
1256 F_GP( 27000000, pxo, 1, 0, 0),
1257 F_GP( 64000000, pll8, 2, 1, 3),
1258 F_GP( 76800000, pll8, 1, 1, 5),
1259 F_GP( 96000000, pll8, 4, 0, 0),
1260 F_GP(128000000, pll8, 3, 0, 0),
1261 F_GP(192000000, pll8, 2, 0, 0),
1262 F_GP(384000000, pll8, 1, 0, 0),
1263 F_END
1264};
1265
1266static CLK_GP(gp0, 0, CLK_HALT_SFPB_MISC_STATE_REG, 7);
1267static CLK_GP(gp1, 1, CLK_HALT_SFPB_MISC_STATE_REG, 6);
1268static CLK_GP(gp2, 2, CLK_HALT_SFPB_MISC_STATE_REG, 5);
1269
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001270#define CLK_GSBI_UART(i, n, h_r, h_b) \
1271 struct rcg_clk i##_clk = { \
1272 .b = { \
1273 .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \
1274 .en_mask = BIT(9), \
1275 .reset_reg = GSBIn_RESET_REG(n), \
1276 .reset_mask = BIT(0), \
1277 .halt_reg = h_r, \
1278 .halt_bit = h_b, \
1279 }, \
1280 .ns_reg = GSBIn_UART_APPS_NS_REG(n), \
1281 .md_reg = GSBIn_UART_APPS_MD_REG(n), \
1282 .root_en_mask = BIT(11), \
1283 .ns_mask = (BM(31, 16) | BM(6, 0)), \
1284 .set_rate = set_rate_mnd, \
1285 .freq_tbl = clk_tbl_gsbi_uart, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001286 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001287 .c = { \
1288 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001289 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001290 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 64000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001291 CLK_INIT(i##_clk.c), \
1292 }, \
1293 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001294#define F_GSBI_UART(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001295 { \
1296 .freq_hz = f, \
1297 .src_clk = &s##_clk.c, \
1298 .md_val = MD16(m, n), \
1299 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1300 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001301 }
1302static struct clk_freq_tbl clk_tbl_gsbi_uart[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001303 F_GSBI_UART( 0, gnd, 1, 0, 0),
1304 F_GSBI_UART( 1843200, pll8, 1, 3, 625),
1305 F_GSBI_UART( 3686400, pll8, 1, 6, 625),
1306 F_GSBI_UART( 7372800, pll8, 1, 12, 625),
1307 F_GSBI_UART(14745600, pll8, 1, 24, 625),
1308 F_GSBI_UART(16000000, pll8, 4, 1, 6),
1309 F_GSBI_UART(24000000, pll8, 4, 1, 4),
1310 F_GSBI_UART(32000000, pll8, 4, 1, 3),
1311 F_GSBI_UART(40000000, pll8, 1, 5, 48),
1312 F_GSBI_UART(46400000, pll8, 1, 29, 240),
1313 F_GSBI_UART(48000000, pll8, 4, 1, 2),
1314 F_GSBI_UART(51200000, pll8, 1, 2, 15),
1315 F_GSBI_UART(56000000, pll8, 1, 7, 48),
1316 F_GSBI_UART(58982400, pll8, 1, 96, 625),
1317 F_GSBI_UART(64000000, pll8, 2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001318 F_END
1319};
1320
1321static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10);
1322static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6);
1323static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2);
1324static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26);
1325static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22);
1326static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18);
1327static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14);
1328static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10);
1329static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6);
1330static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2);
1331static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17);
1332static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13);
1333
1334#define CLK_GSBI_QUP(i, n, h_r, h_b) \
1335 struct rcg_clk i##_clk = { \
1336 .b = { \
1337 .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \
1338 .en_mask = BIT(9), \
1339 .reset_reg = GSBIn_RESET_REG(n), \
1340 .reset_mask = BIT(0), \
1341 .halt_reg = h_r, \
1342 .halt_bit = h_b, \
1343 }, \
1344 .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \
1345 .md_reg = GSBIn_QUP_APPS_MD_REG(n), \
1346 .root_en_mask = BIT(11), \
1347 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1348 .set_rate = set_rate_mnd, \
1349 .freq_tbl = clk_tbl_gsbi_qup, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001350 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001351 .c = { \
1352 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001353 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001354 VDD_DIG_FMAX_MAP2(LOW, 24000000, NOMINAL, 52000000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001355 CLK_INIT(i##_clk.c), \
1356 }, \
1357 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001358#define F_GSBI_QUP(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001359 { \
1360 .freq_hz = f, \
1361 .src_clk = &s##_clk.c, \
1362 .md_val = MD8(16, m, 0, n), \
1363 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1364 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001365 }
1366static struct clk_freq_tbl clk_tbl_gsbi_qup[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001367 F_GSBI_QUP( 0, gnd, 1, 0, 0),
1368 F_GSBI_QUP( 1100000, pxo, 1, 2, 49),
1369 F_GSBI_QUP( 5400000, pxo, 1, 1, 5),
1370 F_GSBI_QUP(10800000, pxo, 1, 2, 5),
1371 F_GSBI_QUP(15060000, pll8, 1, 2, 51),
1372 F_GSBI_QUP(24000000, pll8, 4, 1, 4),
1373 F_GSBI_QUP(25600000, pll8, 1, 1, 15),
1374 F_GSBI_QUP(27000000, pxo, 1, 0, 0),
1375 F_GSBI_QUP(48000000, pll8, 4, 1, 2),
1376 F_GSBI_QUP(51200000, pll8, 1, 2, 15),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001377 F_END
1378};
1379
1380static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9);
1381static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4);
1382static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0);
1383static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24);
1384static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20);
1385static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16);
1386static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12);
1387static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8);
1388static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4);
1389static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0);
1390static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15);
1391static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11);
1392
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001393#define F_QDSS(f, s, d) \
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001394 { \
1395 .freq_hz = f, \
1396 .src_clk = &s##_clk.c, \
1397 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001398 }
1399static struct clk_freq_tbl clk_tbl_qdss[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001400 F_QDSS( 27000000, pxo, 1),
1401 F_QDSS(128000000, pll8, 3),
1402 F_QDSS(300000000, pll3, 4),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001403 F_END
1404};
1405
1406struct qdss_bank {
1407 const u32 bank_sel_mask;
1408 void __iomem *const ns_reg;
1409 const u32 ns_mask;
1410};
1411
Stephen Boydd4de6d72011-09-13 13:01:40 -07001412#define QDSS_CLK_ROOT_ENA BIT(1)
1413
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001414static int qdss_clk_handoff(struct clk *c)
Stephen Boydd4de6d72011-09-13 13:01:40 -07001415{
1416 struct rcg_clk *clk = to_rcg_clk(c);
1417 const struct qdss_bank *bank = clk->bank_info;
1418 u32 reg, ns_val, bank_sel;
1419 struct clk_freq_tbl *freq;
1420
1421 reg = readl_relaxed(clk->ns_reg);
1422 if (!(reg & QDSS_CLK_ROOT_ENA))
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001423 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001424
1425 bank_sel = reg & bank->bank_sel_mask;
1426 /* Force bank 1 to PXO if bank 0 is in use */
1427 if (bank_sel == 0)
1428 writel_relaxed(0, bank->ns_reg);
1429 ns_val = readl_relaxed(bank->ns_reg) & bank->ns_mask;
1430 for (freq = clk->freq_tbl; freq->freq_hz != FREQ_END; freq++) {
1431 if ((freq->ns_val & bank->ns_mask) == ns_val) {
1432 pr_info("%s rate=%d\n", clk->c.dbg_name, freq->freq_hz);
1433 break;
1434 }
1435 }
1436 if (freq->freq_hz == FREQ_END)
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001437 return 0;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001438
1439 clk->current_freq = freq;
Matt Wagantall271a6cd2011-09-20 16:06:31 -07001440
1441 return 1;
Stephen Boydd4de6d72011-09-13 13:01:40 -07001442}
1443
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001444static void set_rate_qdss(struct rcg_clk *clk, struct clk_freq_tbl *nf)
1445{
1446 const struct qdss_bank *bank = clk->bank_info;
1447 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1448
1449 /* Switch to bank 0 (always sourced from PXO) */
1450 reg = readl_relaxed(clk->ns_reg);
1451 reg &= ~bank_sel_mask;
1452 writel_relaxed(reg, clk->ns_reg);
1453 /*
1454 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1455 * MUX to fully switch sources.
1456 */
1457 mb();
1458 udelay(1);
1459
1460 /* Set source and divider */
1461 reg = readl_relaxed(bank->ns_reg);
1462 reg &= ~bank->ns_mask;
1463 reg |= nf->ns_val;
1464 writel_relaxed(reg, bank->ns_reg);
1465
1466 /* Switch to reprogrammed bank */
1467 reg = readl_relaxed(clk->ns_reg);
1468 reg |= bank_sel_mask;
1469 writel_relaxed(reg, clk->ns_reg);
1470 /*
1471 * Wait at least 6 cycles of slowest bank's clock for the glitch-free
1472 * MUX to fully switch sources.
1473 */
1474 mb();
1475 udelay(1);
1476}
1477
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001478static int qdss_clk_enable(struct clk *c)
1479{
1480 struct rcg_clk *clk = to_rcg_clk(c);
1481 const struct qdss_bank *bank = clk->bank_info;
1482 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1483 int ret;
1484
1485 /* Switch to bank 1 */
1486 reg = readl_relaxed(clk->ns_reg);
1487 reg |= bank_sel_mask;
1488 writel_relaxed(reg, clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001489
1490 ret = rcg_clk_enable(c);
1491 if (ret) {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001492 /* Switch to bank 0 */
1493 reg &= ~bank_sel_mask;
1494 writel_relaxed(reg, clk->ns_reg);
1495 }
1496 return ret;
1497}
1498
1499static void qdss_clk_disable(struct clk *c)
1500{
1501 struct rcg_clk *clk = to_rcg_clk(c);
1502 const struct qdss_bank *bank = clk->bank_info;
1503 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1504
1505 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001506 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001507 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001508 reg &= ~bank_sel_mask;
1509 writel_relaxed(reg, clk->ns_reg);
1510}
1511
1512static void qdss_clk_auto_off(struct clk *c)
1513{
1514 struct rcg_clk *clk = to_rcg_clk(c);
1515 const struct qdss_bank *bank = clk->bank_info;
1516 u32 reg, bank_sel_mask = bank->bank_sel_mask;
1517
Matt Wagantall41af0772011-09-17 12:21:39 -07001518 rcg_clk_disable(c);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001519 /* Switch to bank 0 */
Stephen Boyddbeca472011-09-12 19:21:22 -07001520 reg = readl_relaxed(clk->ns_reg);
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001521 reg &= ~bank_sel_mask;
1522 writel_relaxed(reg, clk->ns_reg);
1523}
1524
1525static struct clk_ops clk_ops_qdss = {
1526 .enable = qdss_clk_enable,
1527 .disable = qdss_clk_disable,
1528 .auto_off = qdss_clk_auto_off,
Stephen Boydd4de6d72011-09-13 13:01:40 -07001529 .handoff = qdss_clk_handoff,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001530 .set_rate = rcg_clk_set_rate,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001531 .get_rate = rcg_clk_get_rate,
1532 .list_rate = rcg_clk_list_rate,
1533 .is_enabled = rcg_clk_is_enabled,
1534 .round_rate = rcg_clk_round_rate,
Stephen Boyd7bf28142011-12-07 00:30:52 -08001535 .reset = rcg_clk_reset,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001536 .is_local = local_clk_is_local,
1537 .get_parent = rcg_clk_get_parent,
1538};
1539
1540static struct qdss_bank bdiv_info_qdss = {
1541 .bank_sel_mask = BIT(0),
1542 .ns_reg = QDSS_AT_CLK_SRC1_NS_REG,
1543 .ns_mask = BM(6, 0),
1544};
1545
1546static struct rcg_clk qdss_at_clk = {
1547 .b = {
1548 .ctl_reg = QDSS_AT_CLK_NS_REG,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001549 .reset_reg = QDSS_RESETS_REG,
1550 .reset_mask = BIT(0),
Stephen Boydfcfd4dd2011-09-13 12:49:57 -07001551 .halt_check = NOCHECK,
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001552 },
1553 .ns_reg = QDSS_AT_CLK_SRC_CTL_REG,
1554 .set_rate = set_rate_qdss,
1555 .freq_tbl = clk_tbl_qdss,
1556 .bank_info = &bdiv_info_qdss,
1557 .current_freq = &rcg_dummy_freq,
1558 .c = {
1559 .dbg_name = "qdss_at_clk",
1560 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001561 VDD_DIG_FMAX_MAP2(LOW, 150000000, NOMINAL, 300000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001562 CLK_INIT(qdss_at_clk.c),
1563 },
1564};
1565
1566static struct branch_clk qdss_pclkdbg_clk = {
1567 .b = {
1568 .ctl_reg = QDSS_AT_CLK_NS_REG,
1569 .en_mask = BIT(4),
1570 .reset_reg = QDSS_RESETS_REG,
1571 .reset_mask = BIT(0),
1572 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1573 .halt_bit = 9,
1574 .halt_check = HALT_VOTED
1575 },
1576 .parent = &qdss_at_clk.c,
1577 .c = {
1578 .dbg_name = "qdss_pclkdbg_clk",
1579 .ops = &clk_ops_branch,
1580 CLK_INIT(qdss_pclkdbg_clk.c),
1581 },
1582};
1583
1584static struct qdss_bank bdiv_info_qdss_trace = {
1585 .bank_sel_mask = BIT(0),
1586 .ns_reg = QDSS_TRACECLKIN_CLK_SRC1_NS_REG,
1587 .ns_mask = BM(6, 0),
1588};
1589
1590static struct rcg_clk qdss_traceclkin_clk = {
1591 .b = {
1592 .ctl_reg = QDSS_TRACECLKIN_CTL_REG,
1593 .en_mask = BIT(4),
1594 .reset_reg = QDSS_RESETS_REG,
1595 .reset_mask = BIT(0),
1596 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1597 .halt_bit = 8,
1598 .halt_check = HALT_VOTED,
1599 },
1600 .ns_reg = QDSS_TRACECLKIN_CLK_SRC_CTL_REG,
1601 .set_rate = set_rate_qdss,
1602 .freq_tbl = clk_tbl_qdss,
1603 .bank_info = &bdiv_info_qdss_trace,
1604 .current_freq = &rcg_dummy_freq,
1605 .c = {
1606 .dbg_name = "qdss_traceclkin_clk",
1607 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001608 VDD_DIG_FMAX_MAP2(LOW, 150000000, NOMINAL, 300000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001609 CLK_INIT(qdss_traceclkin_clk.c),
1610 },
1611};
1612
1613static struct clk_freq_tbl clk_tbl_qdss_tsctr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001614 F_QDSS( 27000000, pxo, 1),
1615 F_QDSS(200000000, pll3, 6),
1616 F_QDSS(400000000, pll3, 3),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001617 F_END
1618};
1619
1620static struct qdss_bank bdiv_info_qdss_tsctr = {
1621 .bank_sel_mask = BIT(0),
1622 .ns_reg = QDSS_TSCTR_CLK_SRC1_NS_REG,
1623 .ns_mask = BM(6, 0),
1624};
1625
1626static struct rcg_clk qdss_tsctr_clk = {
1627 .b = {
1628 .ctl_reg = QDSS_TSCTR_CTL_REG,
1629 .en_mask = BIT(4),
1630 .reset_reg = QDSS_RESETS_REG,
1631 .reset_mask = BIT(3),
1632 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
1633 .halt_bit = 7,
1634 .halt_check = HALT_VOTED,
1635 },
1636 .ns_reg = QDSS_TSCTR_CLK_SRC_CTL_REG,
1637 .set_rate = set_rate_qdss,
1638 .freq_tbl = clk_tbl_qdss_tsctr,
1639 .bank_info = &bdiv_info_qdss_tsctr,
1640 .current_freq = &rcg_dummy_freq,
1641 .c = {
1642 .dbg_name = "qdss_tsctr_clk",
1643 .ops = &clk_ops_qdss,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001644 VDD_DIG_FMAX_MAP2(LOW, 200000000, NOMINAL, 400000000),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07001645 CLK_INIT(qdss_tsctr_clk.c),
1646 },
1647};
1648
1649static struct branch_clk qdss_stm_clk = {
1650 .b = {
1651 .ctl_reg = QDSS_STM_CLK_CTL_REG,
1652 .en_mask = BIT(4),
1653 .reset_reg = QDSS_RESETS_REG,
1654 .reset_mask = BIT(1),
1655 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
1656 .halt_bit = 20,
1657 .halt_check = HALT_VOTED,
1658 },
1659 .c = {
1660 .dbg_name = "qdss_stm_clk",
1661 .ops = &clk_ops_branch,
1662 CLK_INIT(qdss_stm_clk.c),
1663 },
1664};
1665
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001666#define F_PDM(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001667 { \
1668 .freq_hz = f, \
1669 .src_clk = &s##_clk.c, \
1670 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001671 }
1672static struct clk_freq_tbl clk_tbl_pdm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001673 F_PDM( 0, gnd, 1),
1674 F_PDM(27000000, pxo, 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001675 F_END
1676};
1677
1678static struct rcg_clk pdm_clk = {
1679 .b = {
1680 .ctl_reg = PDM_CLK_NS_REG,
1681 .en_mask = BIT(9),
1682 .reset_reg = PDM_CLK_NS_REG,
1683 .reset_mask = BIT(12),
1684 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1685 .halt_bit = 3,
1686 },
1687 .ns_reg = PDM_CLK_NS_REG,
1688 .root_en_mask = BIT(11),
1689 .ns_mask = BM(1, 0),
1690 .set_rate = set_rate_nop,
1691 .freq_tbl = clk_tbl_pdm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001692 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001693 .c = {
1694 .dbg_name = "pdm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001695 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001696 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001697 CLK_INIT(pdm_clk.c),
1698 },
1699};
1700
1701static struct branch_clk pmem_clk = {
1702 .b = {
1703 .ctl_reg = PMEM_ACLK_CTL_REG,
1704 .en_mask = BIT(4),
1705 .halt_reg = CLK_HALT_DFAB_STATE_REG,
1706 .halt_bit = 20,
1707 },
1708 .c = {
1709 .dbg_name = "pmem_clk",
1710 .ops = &clk_ops_branch,
1711 CLK_INIT(pmem_clk.c),
1712 },
1713};
1714
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001715#define F_PRNG(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001716 { \
1717 .freq_hz = f, \
1718 .src_clk = &s##_clk.c, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001719 }
1720static struct clk_freq_tbl clk_tbl_prng[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001721 F_PRNG(64000000, pll8),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001722 F_END
1723};
1724
1725static struct rcg_clk prng_clk = {
1726 .b = {
1727 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
1728 .en_mask = BIT(10),
1729 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
1730 .halt_check = HALT_VOTED,
1731 .halt_bit = 10,
1732 },
1733 .set_rate = set_rate_nop,
1734 .freq_tbl = clk_tbl_prng,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001735 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001736 .c = {
1737 .dbg_name = "prng_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001738 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001739 VDD_DIG_FMAX_MAP2(LOW, 32000000, NOMINAL, 65000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001740 CLK_INIT(prng_clk.c),
1741 },
1742};
1743
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001744#define CLK_SDC(name, n, h_b, fmax_low, fmax_nom) \
Stephen Boyda78a7402011-08-02 11:23:39 -07001745 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001746 .b = { \
1747 .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \
1748 .en_mask = BIT(9), \
1749 .reset_reg = SDCn_RESET_REG(n), \
1750 .reset_mask = BIT(0), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001751 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001752 .halt_bit = h_b, \
1753 }, \
1754 .ns_reg = SDCn_APPS_CLK_NS_REG(n), \
1755 .md_reg = SDCn_APPS_CLK_MD_REG(n), \
1756 .root_en_mask = BIT(11), \
1757 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1758 .set_rate = set_rate_mnd, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001759 .freq_tbl = clk_tbl_sdc, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001760 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001761 .c = { \
Stephen Boyda78a7402011-08-02 11:23:39 -07001762 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001763 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001764 VDD_DIG_FMAX_MAP2(LOW, fmax_low, NOMINAL, fmax_nom), \
Stephen Boyda78a7402011-08-02 11:23:39 -07001765 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001766 }, \
1767 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001768#define F_SDC(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001769 { \
1770 .freq_hz = f, \
1771 .src_clk = &s##_clk.c, \
1772 .md_val = MD8(16, m, 0, n), \
1773 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1774 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001775 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001776static struct clk_freq_tbl clk_tbl_sdc[] = {
1777 F_SDC( 0, gnd, 1, 0, 0),
1778 F_SDC( 144000, pxo, 3, 2, 125),
1779 F_SDC( 400000, pll8, 4, 1, 240),
1780 F_SDC( 16000000, pll8, 4, 1, 6),
1781 F_SDC( 17070000, pll8, 1, 2, 45),
1782 F_SDC( 20210000, pll8, 1, 1, 19),
1783 F_SDC( 24000000, pll8, 4, 1, 4),
1784 F_SDC( 48000000, pll8, 4, 1, 2),
1785 F_SDC( 64000000, pll8, 3, 1, 2),
1786 F_SDC( 96000000, pll8, 4, 0, 0),
Subhash Jadavanibd238ba2011-11-24 15:12:39 +05301787 F_SDC(192000000, pll8, 2, 0, 0),
Stephen Boyda78a7402011-08-02 11:23:39 -07001788 F_END
1789};
1790
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001791static CLK_SDC(sdc1_clk, 1, 6, 52000000, 104000000);
1792static CLK_SDC(sdc2_clk, 2, 5, 52000000, 104000000);
1793static CLK_SDC(sdc3_clk, 3, 4, 104000000, 208000000);
1794static CLK_SDC(sdc4_clk, 4, 3, 33000000, 67000000);
1795static CLK_SDC(sdc5_clk, 5, 2, 33000000, 67000000);
Stephen Boyda78a7402011-08-02 11:23:39 -07001796
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001797#define F_TSIF_REF(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001798 { \
1799 .freq_hz = f, \
1800 .src_clk = &s##_clk.c, \
1801 .md_val = MD16(m, n), \
1802 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1803 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001804 }
1805static struct clk_freq_tbl clk_tbl_tsif_ref[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001806 F_TSIF_REF( 0, gnd, 1, 0, 0),
1807 F_TSIF_REF(105000, pxo, 1, 1, 256),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001808 F_END
1809};
1810
1811static struct rcg_clk tsif_ref_clk = {
1812 .b = {
1813 .ctl_reg = TSIF_REF_CLK_NS_REG,
1814 .en_mask = BIT(9),
1815 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1816 .halt_bit = 5,
1817 },
1818 .ns_reg = TSIF_REF_CLK_NS_REG,
1819 .md_reg = TSIF_REF_CLK_MD_REG,
1820 .root_en_mask = BIT(11),
1821 .ns_mask = (BM(31, 16) | BM(6, 0)),
1822 .set_rate = set_rate_mnd,
1823 .freq_tbl = clk_tbl_tsif_ref,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001824 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001825 .c = {
1826 .dbg_name = "tsif_ref_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001827 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001828 VDD_DIG_FMAX_MAP2(LOW, 27000000, NOMINAL, 54000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001829 CLK_INIT(tsif_ref_clk.c),
1830 },
1831};
1832
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001833#define F_TSSC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001834 { \
1835 .freq_hz = f, \
1836 .src_clk = &s##_clk.c, \
1837 .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001838 }
1839static struct clk_freq_tbl clk_tbl_tssc[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001840 F_TSSC( 0, gnd),
1841 F_TSSC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001842 F_END
1843};
1844
1845static struct rcg_clk tssc_clk = {
1846 .b = {
1847 .ctl_reg = TSSC_CLK_CTL_REG,
1848 .en_mask = BIT(4),
1849 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
1850 .halt_bit = 4,
1851 },
1852 .ns_reg = TSSC_CLK_CTL_REG,
1853 .ns_mask = BM(1, 0),
1854 .set_rate = set_rate_nop,
1855 .freq_tbl = clk_tbl_tssc,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001856 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001857 .c = {
1858 .dbg_name = "tssc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07001859 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001860 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001861 CLK_INIT(tssc_clk.c),
1862 },
1863};
1864
Tianyi Gou41515e22011-09-01 19:37:43 -07001865#define CLK_USB_HS(name, n, h_b) \
1866 static struct rcg_clk name = { \
1867 .b = { \
1868 .ctl_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1869 .en_mask = BIT(9), \
1870 .reset_reg = USB_HS##n##_RESET_REG, \
1871 .reset_mask = BIT(0), \
1872 .halt_reg = CLK_HALT_DFAB_STATE_REG, \
1873 .halt_bit = h_b, \
1874 }, \
1875 .ns_reg = USB_HS##n##_XCVR_FS_CLK_NS_REG, \
1876 .md_reg = USB_HS##n##_XCVR_FS_CLK_MD_REG, \
1877 .root_en_mask = BIT(11), \
1878 .ns_mask = (BM(23, 16) | BM(6, 0)), \
1879 .set_rate = set_rate_mnd, \
1880 .freq_tbl = clk_tbl_usb, \
1881 .current_freq = &rcg_dummy_freq, \
1882 .c = { \
1883 .dbg_name = #name, \
1884 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001885 VDD_DIG_FMAX_MAP1(NOMINAL, 64000000), \
Tianyi Gou41515e22011-09-01 19:37:43 -07001886 CLK_INIT(name.c), \
1887 }, \
1888}
1889
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001890#define F_USB(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001891 { \
1892 .freq_hz = f, \
1893 .src_clk = &s##_clk.c, \
1894 .md_val = MD8(16, m, 0, n), \
1895 .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \
1896 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001897 }
1898static struct clk_freq_tbl clk_tbl_usb[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001899 F_USB( 0, gnd, 1, 0, 0),
1900 F_USB(60000000, pll8, 1, 5, 32),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001901 F_END
1902};
1903
Tianyi Gou41515e22011-09-01 19:37:43 -07001904CLK_USB_HS(usb_hs1_xcvr_clk, 1, 0);
1905CLK_USB_HS(usb_hs3_xcvr_clk, 3, 30);
1906CLK_USB_HS(usb_hs4_xcvr_clk, 4, 2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001907
Stephen Boyd94625ef2011-07-12 17:06:01 -07001908static struct clk_freq_tbl clk_tbl_usb_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001909 F_USB( 0, gnd, 1, 0, 0),
1910 F_USB(60000000, pll8, 1, 5, 32),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001911 F_END
1912};
1913
1914static struct rcg_clk usb_hsic_xcvr_fs_clk = {
1915 .b = {
1916 .ctl_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1917 .en_mask = BIT(9),
1918 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1919 .halt_bit = 26,
1920 },
1921 .ns_reg = USB_HSIC_XCVR_FS_CLK_NS_REG,
1922 .md_reg = USB_HSIC_XCVR_FS_CLK_MD_REG,
1923 .root_en_mask = BIT(11),
1924 .ns_mask = (BM(23, 16) | BM(6, 0)),
1925 .set_rate = set_rate_mnd,
1926 .freq_tbl = clk_tbl_usb_hsic,
1927 .current_freq = &rcg_dummy_freq,
1928 .c = {
1929 .dbg_name = "usb_hsic_xcvr_fs_clk",
1930 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001931 VDD_DIG_FMAX_MAP1(LOW, 60000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001932 CLK_INIT(usb_hsic_xcvr_fs_clk.c),
1933 },
1934};
1935
1936static struct branch_clk usb_hsic_system_clk = {
1937 .b = {
1938 .ctl_reg = USB_HSIC_SYSTEM_CLK_CTL_REG,
1939 .en_mask = BIT(4),
1940 .reset_reg = USB_HSIC_RESET_REG,
1941 .reset_mask = BIT(0),
1942 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1943 .halt_bit = 24,
1944 },
1945 .parent = &usb_hsic_xcvr_fs_clk.c,
1946 .c = {
1947 .dbg_name = "usb_hsic_system_clk",
1948 .ops = &clk_ops_branch,
1949 CLK_INIT(usb_hsic_system_clk.c),
1950 },
1951};
1952
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001953#define F_USB_HSIC(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001954 { \
1955 .freq_hz = f, \
1956 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001957 }
1958static struct clk_freq_tbl clk_tbl_usb2_hsic[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001959 F_USB_HSIC(480000000, pll14),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001960 F_END
1961};
1962
1963static struct rcg_clk usb_hsic_hsic_src_clk = {
1964 .b = {
1965 .ctl_reg = USB_HSIC_HSIC_CLK_SRC_CTL_REG,
1966 .halt_check = NOCHECK,
1967 },
1968 .root_en_mask = BIT(0),
1969 .set_rate = set_rate_nop,
1970 .freq_tbl = clk_tbl_usb2_hsic,
1971 .current_freq = &rcg_dummy_freq,
1972 .c = {
1973 .dbg_name = "usb_hsic_hsic_src_clk",
1974 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001975 VDD_DIG_FMAX_MAP1(LOW, 480000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07001976 CLK_INIT(usb_hsic_hsic_src_clk.c),
1977 },
1978};
1979
1980static struct branch_clk usb_hsic_hsic_clk = {
1981 .b = {
1982 .ctl_reg = USB_HSIC_HSIC_CLK_CTL_REG,
1983 .en_mask = BIT(0),
1984 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
1985 .halt_bit = 19,
1986 },
1987 .parent = &usb_hsic_hsic_src_clk.c,
1988 .c = {
1989 .dbg_name = "usb_hsic_hsic_clk",
1990 .ops = &clk_ops_branch,
1991 CLK_INIT(usb_hsic_hsic_clk.c),
1992 },
1993};
1994
Matt Wagantalle18bbc82011-10-06 10:07:28 -07001995#define F_USB_HSIO_CAL(f, s) \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001996 { \
1997 .freq_hz = f, \
1998 .src_clk = &s##_clk.c, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07001999 }
2000static struct clk_freq_tbl clk_tbl_usb_hsio_cal[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002001 F_USB_HSIO_CAL(9000000, pxo),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002002 F_END
2003};
2004
2005static struct rcg_clk usb_hsic_hsio_cal_clk = {
2006 .b = {
2007 .ctl_reg = USB_HSIC_HSIO_CAL_CLK_CTL_REG,
2008 .en_mask = BIT(0),
2009 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2010 .halt_bit = 23,
2011 },
2012 .set_rate = set_rate_nop,
2013 .freq_tbl = clk_tbl_usb_hsio_cal,
2014 .current_freq = &rcg_dummy_freq,
2015 .c = {
2016 .dbg_name = "usb_hsic_hsio_cal_clk",
Stephen Boyda0e82ec2011-09-19 12:18:45 -07002017 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002018 VDD_DIG_FMAX_MAP1(LOW, 10000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002019 CLK_INIT(usb_hsic_hsio_cal_clk.c),
2020 },
2021};
2022
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002023static struct branch_clk usb_phy0_clk = {
2024 .b = {
2025 .reset_reg = USB_PHY0_RESET_REG,
2026 .reset_mask = BIT(0),
2027 },
2028 .c = {
2029 .dbg_name = "usb_phy0_clk",
2030 .ops = &clk_ops_reset,
2031 CLK_INIT(usb_phy0_clk.c),
2032 },
2033};
2034
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002035#define CLK_USB_FS(i, n, fmax_nom) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002036 struct rcg_clk i##_clk = { \
2037 .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
2038 .b = { \
2039 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \
2040 .halt_check = NOCHECK, \
2041 }, \
2042 .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \
2043 .root_en_mask = BIT(11), \
2044 .ns_mask = (BM(23, 16) | BM(6, 0)), \
2045 .set_rate = set_rate_mnd, \
2046 .freq_tbl = clk_tbl_usb, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002047 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002048 .c = { \
2049 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002050 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002051 VDD_DIG_FMAX_MAP1(NOMINAL, fmax_nom), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002052 CLK_INIT(i##_clk.c), \
2053 }, \
2054 }
2055
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002056static CLK_USB_FS(usb_fs1_src, 1, 64000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002057static struct branch_clk usb_fs1_xcvr_clk = {
2058 .b = {
2059 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1),
2060 .en_mask = BIT(9),
2061 .reset_reg = USB_FSn_RESET_REG(1),
2062 .reset_mask = BIT(1),
2063 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2064 .halt_bit = 15,
2065 },
2066 .parent = &usb_fs1_src_clk.c,
2067 .c = {
2068 .dbg_name = "usb_fs1_xcvr_clk",
2069 .ops = &clk_ops_branch,
2070 CLK_INIT(usb_fs1_xcvr_clk.c),
2071 },
2072};
2073
2074static struct branch_clk usb_fs1_sys_clk = {
2075 .b = {
2076 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1),
2077 .en_mask = BIT(4),
2078 .reset_reg = USB_FSn_RESET_REG(1),
2079 .reset_mask = BIT(0),
2080 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2081 .halt_bit = 16,
2082 },
2083 .parent = &usb_fs1_src_clk.c,
2084 .c = {
2085 .dbg_name = "usb_fs1_sys_clk",
2086 .ops = &clk_ops_branch,
2087 CLK_INIT(usb_fs1_sys_clk.c),
2088 },
2089};
2090
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002091static CLK_USB_FS(usb_fs2_src, 2, 60000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002092static struct branch_clk usb_fs2_xcvr_clk = {
2093 .b = {
2094 .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2),
2095 .en_mask = BIT(9),
2096 .reset_reg = USB_FSn_RESET_REG(2),
2097 .reset_mask = BIT(1),
2098 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2099 .halt_bit = 12,
2100 },
2101 .parent = &usb_fs2_src_clk.c,
2102 .c = {
2103 .dbg_name = "usb_fs2_xcvr_clk",
2104 .ops = &clk_ops_branch,
2105 CLK_INIT(usb_fs2_xcvr_clk.c),
2106 },
2107};
2108
2109static struct branch_clk usb_fs2_sys_clk = {
2110 .b = {
2111 .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2),
2112 .en_mask = BIT(4),
2113 .reset_reg = USB_FSn_RESET_REG(2),
2114 .reset_mask = BIT(0),
2115 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2116 .halt_bit = 13,
2117 },
2118 .parent = &usb_fs2_src_clk.c,
2119 .c = {
2120 .dbg_name = "usb_fs2_sys_clk",
2121 .ops = &clk_ops_branch,
2122 CLK_INIT(usb_fs2_sys_clk.c),
2123 },
2124};
2125
2126/* Fast Peripheral Bus Clocks */
2127static struct branch_clk ce1_core_clk = {
2128 .b = {
2129 .ctl_reg = CE1_CORE_CLK_CTL_REG,
2130 .en_mask = BIT(4),
2131 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2132 .halt_bit = 27,
2133 },
2134 .c = {
2135 .dbg_name = "ce1_core_clk",
2136 .ops = &clk_ops_branch,
2137 CLK_INIT(ce1_core_clk.c),
2138 },
2139};
Tianyi Gou41515e22011-09-01 19:37:43 -07002140
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002141static struct branch_clk ce1_p_clk = {
2142 .b = {
2143 .ctl_reg = CE1_HCLK_CTL_REG,
2144 .en_mask = BIT(4),
2145 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2146 .halt_bit = 1,
2147 },
2148 .c = {
2149 .dbg_name = "ce1_p_clk",
2150 .ops = &clk_ops_branch,
2151 CLK_INIT(ce1_p_clk.c),
2152 },
2153};
2154
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002155#define F_CE3(f, s, d) \
Tianyi Gou41515e22011-09-01 19:37:43 -07002156 { \
2157 .freq_hz = f, \
2158 .src_clk = &s##_clk.c, \
2159 .ns_val = NS_DIVSRC(6, 3, d, 2, 0, s##_to_bb_mux), \
Tianyi Gou41515e22011-09-01 19:37:43 -07002160 }
2161
2162static struct clk_freq_tbl clk_tbl_ce3[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002163 F_CE3( 0, gnd, 1),
2164 F_CE3( 48000000, pll8, 8),
2165 F_CE3(100000000, pll3, 12),
Tianyi Gou41515e22011-09-01 19:37:43 -07002166 F_END
2167};
2168
2169static struct rcg_clk ce3_src_clk = {
2170 .b = {
2171 .ctl_reg = CE3_CLK_SRC_NS_REG,
2172 .halt_check = NOCHECK,
2173 },
2174 .ns_reg = CE3_CLK_SRC_NS_REG,
2175 .root_en_mask = BIT(7),
2176 .ns_mask = BM(6, 0),
2177 .set_rate = set_rate_nop,
2178 .freq_tbl = clk_tbl_ce3,
2179 .current_freq = &rcg_dummy_freq,
2180 .c = {
2181 .dbg_name = "ce3_src_clk",
2182 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002183 VDD_DIG_FMAX_MAP2(LOW, 50000000, NOMINAL, 100000000),
Tianyi Gou41515e22011-09-01 19:37:43 -07002184 CLK_INIT(ce3_src_clk.c),
2185 },
2186};
2187
2188static struct branch_clk ce3_core_clk = {
2189 .b = {
2190 .ctl_reg = CE3_CORE_CLK_CTL_REG,
2191 .en_mask = BIT(4),
2192 .reset_reg = CE3_CORE_CLK_CTL_REG,
2193 .reset_mask = BIT(7),
2194 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2195 .halt_bit = 5,
2196 },
2197 .parent = &ce3_src_clk.c,
2198 .c = {
2199 .dbg_name = "ce3_core_clk",
2200 .ops = &clk_ops_branch,
2201 CLK_INIT(ce3_core_clk.c),
2202 }
2203};
2204
2205static struct branch_clk ce3_p_clk = {
2206 .b = {
2207 .ctl_reg = CE3_HCLK_CTL_REG,
2208 .en_mask = BIT(4),
2209 .reset_reg = CE3_HCLK_CTL_REG,
2210 .reset_mask = BIT(7),
2211 .halt_reg = CLK_HALT_AFAB_SFAB_STATEB_REG,
2212 .halt_bit = 16,
2213 },
2214 .parent = &ce3_src_clk.c,
2215 .c = {
2216 .dbg_name = "ce3_p_clk",
2217 .ops = &clk_ops_branch,
2218 CLK_INIT(ce3_p_clk.c),
2219 }
2220};
2221
2222static struct branch_clk sata_phy_ref_clk = {
2223 .b = {
2224 .ctl_reg = SATA_PHY_REF_CLK_CTL_REG,
2225 .en_mask = BIT(4),
2226 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2227 .halt_bit = 24,
2228 },
2229 .parent = &pxo_clk.c,
2230 .c = {
2231 .dbg_name = "sata_phy_ref_clk",
2232 .ops = &clk_ops_branch,
2233 CLK_INIT(sata_phy_ref_clk.c),
2234 },
2235};
2236
2237static struct branch_clk pcie_p_clk = {
2238 .b = {
2239 .ctl_reg = PCIE_HCLK_CTL_REG,
2240 .en_mask = BIT(4),
2241 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2242 .halt_bit = 8,
2243 },
2244 .c = {
2245 .dbg_name = "pcie_p_clk",
2246 .ops = &clk_ops_branch,
2247 CLK_INIT(pcie_p_clk.c),
2248 },
2249};
2250
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002251static struct branch_clk dma_bam_p_clk = {
2252 .b = {
2253 .ctl_reg = DMA_BAM_HCLK_CTL,
2254 .en_mask = BIT(4),
2255 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2256 .halt_bit = 12,
2257 },
2258 .c = {
2259 .dbg_name = "dma_bam_p_clk",
2260 .ops = &clk_ops_branch,
2261 CLK_INIT(dma_bam_p_clk.c),
2262 },
2263};
2264
2265static struct branch_clk gsbi1_p_clk = {
2266 .b = {
2267 .ctl_reg = GSBIn_HCLK_CTL_REG(1),
2268 .en_mask = BIT(4),
2269 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2270 .halt_bit = 11,
2271 },
2272 .c = {
2273 .dbg_name = "gsbi1_p_clk",
2274 .ops = &clk_ops_branch,
2275 CLK_INIT(gsbi1_p_clk.c),
2276 },
2277};
2278
2279static struct branch_clk gsbi2_p_clk = {
2280 .b = {
2281 .ctl_reg = GSBIn_HCLK_CTL_REG(2),
2282 .en_mask = BIT(4),
2283 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2284 .halt_bit = 7,
2285 },
2286 .c = {
2287 .dbg_name = "gsbi2_p_clk",
2288 .ops = &clk_ops_branch,
2289 CLK_INIT(gsbi2_p_clk.c),
2290 },
2291};
2292
2293static struct branch_clk gsbi3_p_clk = {
2294 .b = {
2295 .ctl_reg = GSBIn_HCLK_CTL_REG(3),
2296 .en_mask = BIT(4),
2297 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2298 .halt_bit = 3,
2299 },
2300 .c = {
2301 .dbg_name = "gsbi3_p_clk",
2302 .ops = &clk_ops_branch,
2303 CLK_INIT(gsbi3_p_clk.c),
2304 },
2305};
2306
2307static struct branch_clk gsbi4_p_clk = {
2308 .b = {
2309 .ctl_reg = GSBIn_HCLK_CTL_REG(4),
2310 .en_mask = BIT(4),
2311 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2312 .halt_bit = 27,
2313 },
2314 .c = {
2315 .dbg_name = "gsbi4_p_clk",
2316 .ops = &clk_ops_branch,
2317 CLK_INIT(gsbi4_p_clk.c),
2318 },
2319};
2320
2321static struct branch_clk gsbi5_p_clk = {
2322 .b = {
2323 .ctl_reg = GSBIn_HCLK_CTL_REG(5),
2324 .en_mask = BIT(4),
2325 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2326 .halt_bit = 23,
2327 },
2328 .c = {
2329 .dbg_name = "gsbi5_p_clk",
2330 .ops = &clk_ops_branch,
2331 CLK_INIT(gsbi5_p_clk.c),
2332 },
2333};
2334
2335static struct branch_clk gsbi6_p_clk = {
2336 .b = {
2337 .ctl_reg = GSBIn_HCLK_CTL_REG(6),
2338 .en_mask = BIT(4),
2339 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2340 .halt_bit = 19,
2341 },
2342 .c = {
2343 .dbg_name = "gsbi6_p_clk",
2344 .ops = &clk_ops_branch,
2345 CLK_INIT(gsbi6_p_clk.c),
2346 },
2347};
2348
2349static struct branch_clk gsbi7_p_clk = {
2350 .b = {
2351 .ctl_reg = GSBIn_HCLK_CTL_REG(7),
2352 .en_mask = BIT(4),
2353 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2354 .halt_bit = 15,
2355 },
2356 .c = {
2357 .dbg_name = "gsbi7_p_clk",
2358 .ops = &clk_ops_branch,
2359 CLK_INIT(gsbi7_p_clk.c),
2360 },
2361};
2362
2363static struct branch_clk gsbi8_p_clk = {
2364 .b = {
2365 .ctl_reg = GSBIn_HCLK_CTL_REG(8),
2366 .en_mask = BIT(4),
2367 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2368 .halt_bit = 11,
2369 },
2370 .c = {
2371 .dbg_name = "gsbi8_p_clk",
2372 .ops = &clk_ops_branch,
2373 CLK_INIT(gsbi8_p_clk.c),
2374 },
2375};
2376
2377static struct branch_clk gsbi9_p_clk = {
2378 .b = {
2379 .ctl_reg = GSBIn_HCLK_CTL_REG(9),
2380 .en_mask = BIT(4),
2381 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2382 .halt_bit = 7,
2383 },
2384 .c = {
2385 .dbg_name = "gsbi9_p_clk",
2386 .ops = &clk_ops_branch,
2387 CLK_INIT(gsbi9_p_clk.c),
2388 },
2389};
2390
2391static struct branch_clk gsbi10_p_clk = {
2392 .b = {
2393 .ctl_reg = GSBIn_HCLK_CTL_REG(10),
2394 .en_mask = BIT(4),
2395 .halt_reg = CLK_HALT_CFPB_STATEB_REG,
2396 .halt_bit = 3,
2397 },
2398 .c = {
2399 .dbg_name = "gsbi10_p_clk",
2400 .ops = &clk_ops_branch,
2401 CLK_INIT(gsbi10_p_clk.c),
2402 },
2403};
2404
2405static struct branch_clk gsbi11_p_clk = {
2406 .b = {
2407 .ctl_reg = GSBIn_HCLK_CTL_REG(11),
2408 .en_mask = BIT(4),
2409 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2410 .halt_bit = 18,
2411 },
2412 .c = {
2413 .dbg_name = "gsbi11_p_clk",
2414 .ops = &clk_ops_branch,
2415 CLK_INIT(gsbi11_p_clk.c),
2416 },
2417};
2418
2419static struct branch_clk gsbi12_p_clk = {
2420 .b = {
2421 .ctl_reg = GSBIn_HCLK_CTL_REG(12),
2422 .en_mask = BIT(4),
2423 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2424 .halt_bit = 14,
2425 },
2426 .c = {
2427 .dbg_name = "gsbi12_p_clk",
2428 .ops = &clk_ops_branch,
2429 CLK_INIT(gsbi12_p_clk.c),
2430 },
2431};
2432
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002433static struct branch_clk qdss_p_clk = {
2434 .b = {
2435 .ctl_reg = QDSS_HCLK_CTL_REG,
2436 .en_mask = BIT(4),
2437 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2438 .halt_bit = 11,
2439 .halt_check = HALT_VOTED,
2440 .reset_reg = QDSS_RESETS_REG,
2441 .reset_mask = BIT(2),
2442 },
2443 .c = {
2444 .dbg_name = "qdss_p_clk",
2445 .ops = &clk_ops_branch,
2446 CLK_INIT(qdss_p_clk.c),
Tianyi Gou41515e22011-09-01 19:37:43 -07002447 }
2448};
2449
2450static struct branch_clk sata_phy_cfg_clk = {
2451 .b = {
2452 .ctl_reg = SATA_PHY_CFG_CLK_CTL_REG,
2453 .en_mask = BIT(4),
2454 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2455 .halt_bit = 12,
2456 },
2457 .c = {
2458 .dbg_name = "sata_phy_cfg_clk",
2459 .ops = &clk_ops_branch,
2460 CLK_INIT(sata_phy_cfg_clk.c),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07002461 },
2462};
2463
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002464static struct branch_clk tsif_p_clk = {
2465 .b = {
2466 .ctl_reg = TSIF_HCLK_CTL_REG,
2467 .en_mask = BIT(4),
2468 .halt_reg = CLK_HALT_CFPB_STATEC_REG,
2469 .halt_bit = 7,
2470 },
2471 .c = {
2472 .dbg_name = "tsif_p_clk",
2473 .ops = &clk_ops_branch,
2474 CLK_INIT(tsif_p_clk.c),
2475 },
2476};
2477
2478static struct branch_clk usb_fs1_p_clk = {
2479 .b = {
2480 .ctl_reg = USB_FSn_HCLK_CTL_REG(1),
2481 .en_mask = BIT(4),
2482 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2483 .halt_bit = 17,
2484 },
2485 .c = {
2486 .dbg_name = "usb_fs1_p_clk",
2487 .ops = &clk_ops_branch,
2488 CLK_INIT(usb_fs1_p_clk.c),
2489 },
2490};
2491
2492static struct branch_clk usb_fs2_p_clk = {
2493 .b = {
2494 .ctl_reg = USB_FSn_HCLK_CTL_REG(2),
2495 .en_mask = BIT(4),
2496 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2497 .halt_bit = 14,
2498 },
2499 .c = {
2500 .dbg_name = "usb_fs2_p_clk",
2501 .ops = &clk_ops_branch,
2502 CLK_INIT(usb_fs2_p_clk.c),
2503 },
2504};
2505
2506static struct branch_clk usb_hs1_p_clk = {
2507 .b = {
2508 .ctl_reg = USB_HS1_HCLK_CTL_REG,
2509 .en_mask = BIT(4),
2510 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2511 .halt_bit = 1,
2512 },
2513 .c = {
2514 .dbg_name = "usb_hs1_p_clk",
2515 .ops = &clk_ops_branch,
2516 CLK_INIT(usb_hs1_p_clk.c),
2517 },
2518};
2519
Tianyi Gou41515e22011-09-01 19:37:43 -07002520static struct branch_clk usb_hs3_p_clk = {
2521 .b = {
2522 .ctl_reg = USB_HS3_HCLK_CTL_REG,
2523 .en_mask = BIT(4),
2524 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2525 .halt_bit = 31,
2526 },
2527 .c = {
2528 .dbg_name = "usb_hs3_p_clk",
2529 .ops = &clk_ops_branch,
2530 CLK_INIT(usb_hs3_p_clk.c),
2531 },
2532};
2533
2534static struct branch_clk usb_hs4_p_clk = {
2535 .b = {
2536 .ctl_reg = USB_HS4_HCLK_CTL_REG,
2537 .en_mask = BIT(4),
2538 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2539 .halt_bit = 7,
2540 },
2541 .c = {
2542 .dbg_name = "usb_hs4_p_clk",
2543 .ops = &clk_ops_branch,
2544 CLK_INIT(usb_hs4_p_clk.c),
2545 },
2546};
2547
Stephen Boyd94625ef2011-07-12 17:06:01 -07002548static struct branch_clk usb_hsic_p_clk = {
2549 .b = {
2550 .ctl_reg = USB_HSIC_HCLK_CTL_REG,
2551 .en_mask = BIT(4),
2552 .halt_reg = CLK_HALT_CFPB_STATEA_REG,
2553 .halt_bit = 28,
2554 },
2555 .c = {
2556 .dbg_name = "usb_hsic_p_clk",
2557 .ops = &clk_ops_branch,
2558 CLK_INIT(usb_hsic_p_clk.c),
2559 },
2560};
2561
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002562static struct branch_clk sdc1_p_clk = {
2563 .b = {
2564 .ctl_reg = SDCn_HCLK_CTL_REG(1),
2565 .en_mask = BIT(4),
2566 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2567 .halt_bit = 11,
2568 },
2569 .c = {
2570 .dbg_name = "sdc1_p_clk",
2571 .ops = &clk_ops_branch,
2572 CLK_INIT(sdc1_p_clk.c),
2573 },
2574};
2575
2576static struct branch_clk sdc2_p_clk = {
2577 .b = {
2578 .ctl_reg = SDCn_HCLK_CTL_REG(2),
2579 .en_mask = BIT(4),
2580 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2581 .halt_bit = 10,
2582 },
2583 .c = {
2584 .dbg_name = "sdc2_p_clk",
2585 .ops = &clk_ops_branch,
2586 CLK_INIT(sdc2_p_clk.c),
2587 },
2588};
2589
2590static struct branch_clk sdc3_p_clk = {
2591 .b = {
2592 .ctl_reg = SDCn_HCLK_CTL_REG(3),
2593 .en_mask = BIT(4),
2594 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2595 .halt_bit = 9,
2596 },
2597 .c = {
2598 .dbg_name = "sdc3_p_clk",
2599 .ops = &clk_ops_branch,
2600 CLK_INIT(sdc3_p_clk.c),
2601 },
2602};
2603
2604static struct branch_clk sdc4_p_clk = {
2605 .b = {
2606 .ctl_reg = SDCn_HCLK_CTL_REG(4),
2607 .en_mask = BIT(4),
2608 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2609 .halt_bit = 8,
2610 },
2611 .c = {
2612 .dbg_name = "sdc4_p_clk",
2613 .ops = &clk_ops_branch,
2614 CLK_INIT(sdc4_p_clk.c),
2615 },
2616};
2617
2618static struct branch_clk sdc5_p_clk = {
2619 .b = {
2620 .ctl_reg = SDCn_HCLK_CTL_REG(5),
2621 .en_mask = BIT(4),
2622 .halt_reg = CLK_HALT_DFAB_STATE_REG,
2623 .halt_bit = 7,
2624 },
2625 .c = {
2626 .dbg_name = "sdc5_p_clk",
2627 .ops = &clk_ops_branch,
2628 CLK_INIT(sdc5_p_clk.c),
2629 },
2630};
2631
2632/* HW-Voteable Clocks */
2633static struct branch_clk adm0_clk = {
2634 .b = {
2635 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2636 .en_mask = BIT(2),
2637 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2638 .halt_check = HALT_VOTED,
2639 .halt_bit = 14,
2640 },
2641 .c = {
2642 .dbg_name = "adm0_clk",
2643 .ops = &clk_ops_branch,
2644 CLK_INIT(adm0_clk.c),
2645 },
2646};
2647
2648static struct branch_clk adm0_p_clk = {
2649 .b = {
2650 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2651 .en_mask = BIT(3),
2652 .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG,
2653 .halt_check = HALT_VOTED,
2654 .halt_bit = 13,
2655 },
2656 .c = {
2657 .dbg_name = "adm0_p_clk",
2658 .ops = &clk_ops_branch,
2659 CLK_INIT(adm0_p_clk.c),
2660 },
2661};
2662
2663static struct branch_clk pmic_arb0_p_clk = {
2664 .b = {
2665 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2666 .en_mask = BIT(8),
2667 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2668 .halt_check = HALT_VOTED,
2669 .halt_bit = 22,
2670 },
2671 .c = {
2672 .dbg_name = "pmic_arb0_p_clk",
2673 .ops = &clk_ops_branch,
2674 CLK_INIT(pmic_arb0_p_clk.c),
2675 },
2676};
2677
2678static struct branch_clk pmic_arb1_p_clk = {
2679 .b = {
2680 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2681 .en_mask = BIT(9),
2682 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2683 .halt_check = HALT_VOTED,
2684 .halt_bit = 21,
2685 },
2686 .c = {
2687 .dbg_name = "pmic_arb1_p_clk",
2688 .ops = &clk_ops_branch,
2689 CLK_INIT(pmic_arb1_p_clk.c),
2690 },
2691};
2692
2693static struct branch_clk pmic_ssbi2_clk = {
2694 .b = {
2695 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2696 .en_mask = BIT(7),
2697 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2698 .halt_check = HALT_VOTED,
2699 .halt_bit = 23,
2700 },
2701 .c = {
2702 .dbg_name = "pmic_ssbi2_clk",
2703 .ops = &clk_ops_branch,
2704 CLK_INIT(pmic_ssbi2_clk.c),
2705 },
2706};
2707
2708static struct branch_clk rpm_msg_ram_p_clk = {
2709 .b = {
2710 .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG,
2711 .en_mask = BIT(6),
2712 .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG,
2713 .halt_check = HALT_VOTED,
2714 .halt_bit = 12,
2715 },
2716 .c = {
2717 .dbg_name = "rpm_msg_ram_p_clk",
2718 .ops = &clk_ops_branch,
2719 CLK_INIT(rpm_msg_ram_p_clk.c),
2720 },
2721};
2722
2723/*
2724 * Multimedia Clocks
2725 */
2726
2727static struct branch_clk amp_clk = {
2728 .b = {
2729 .reset_reg = SW_RESET_CORE_REG,
2730 .reset_mask = BIT(20),
2731 },
2732 .c = {
2733 .dbg_name = "amp_clk",
2734 .ops = &clk_ops_reset,
2735 CLK_INIT(amp_clk.c),
2736 },
2737};
2738
Stephen Boyd94625ef2011-07-12 17:06:01 -07002739#define CLK_CAM(name, n, hb) \
2740 struct rcg_clk name = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002741 .b = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002742 .ctl_reg = CAMCLK##n##_CC_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002743 .en_mask = BIT(0), \
2744 .halt_reg = DBG_BUS_VEC_I_REG, \
2745 .halt_bit = hb, \
2746 }, \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002747 .ns_reg = CAMCLK##n##_NS_REG, \
2748 .md_reg = CAMCLK##n##_MD_REG, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002749 .root_en_mask = BIT(2), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002750 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002751 .ctl_mask = BM(7, 6), \
2752 .set_rate = set_rate_mnd_8, \
2753 .freq_tbl = clk_tbl_cam, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002754 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002755 .c = { \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002756 .dbg_name = #name, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002757 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002758 VDD_DIG_FMAX_MAP2(LOW, 64000000, NOMINAL, 128000000), \
Stephen Boyd94625ef2011-07-12 17:06:01 -07002759 CLK_INIT(name.c), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002760 }, \
2761 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002762#define F_CAM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002763 { \
2764 .freq_hz = f, \
2765 .src_clk = &s##_clk.c, \
2766 .md_val = MD8(8, m, 0, n), \
2767 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2768 .ctl_val = CC(6, n), \
2769 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002770 }
2771static struct clk_freq_tbl clk_tbl_cam[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002772 F_CAM( 0, gnd, 1, 0, 0),
2773 F_CAM( 6000000, pll8, 4, 1, 16),
2774 F_CAM( 8000000, pll8, 4, 1, 12),
2775 F_CAM( 12000000, pll8, 4, 1, 8),
2776 F_CAM( 16000000, pll8, 4, 1, 6),
2777 F_CAM( 19200000, pll8, 4, 1, 5),
2778 F_CAM( 24000000, pll8, 4, 1, 4),
2779 F_CAM( 32000000, pll8, 4, 1, 3),
2780 F_CAM( 48000000, pll8, 4, 1, 2),
2781 F_CAM( 64000000, pll8, 3, 1, 2),
2782 F_CAM( 96000000, pll8, 4, 0, 0),
2783 F_CAM(128000000, pll8, 3, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002784 F_END
2785};
2786
Stephen Boyd94625ef2011-07-12 17:06:01 -07002787static CLK_CAM(cam0_clk, 0, 15);
2788static CLK_CAM(cam1_clk, 1, 16);
2789static CLK_CAM(cam2_clk, 2, 31);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002790
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002791#define F_CSI(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002792 { \
2793 .freq_hz = f, \
2794 .src_clk = &s##_clk.c, \
2795 .md_val = MD8(8, m, 0, n), \
2796 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
2797 .ctl_val = CC(6, n), \
2798 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002799 }
2800static struct clk_freq_tbl clk_tbl_csi[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002801 F_CSI( 0, gnd, 1, 0, 0),
Stephen Boyd092fd182011-10-21 15:56:30 -07002802 F_CSI( 27000000, pxo, 1, 0, 0),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002803 F_CSI( 85330000, pll8, 1, 2, 9),
2804 F_CSI(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002805 F_END
2806};
2807
2808static struct rcg_clk csi0_src_clk = {
2809 .ns_reg = CSI0_NS_REG,
2810 .b = {
2811 .ctl_reg = CSI0_CC_REG,
2812 .halt_check = NOCHECK,
2813 },
2814 .md_reg = CSI0_MD_REG,
2815 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002816 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002817 .ctl_mask = BM(7, 6),
2818 .set_rate = set_rate_mnd,
2819 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002820 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002821 .c = {
2822 .dbg_name = "csi0_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002823 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002824 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002825 CLK_INIT(csi0_src_clk.c),
2826 },
2827};
2828
2829static struct branch_clk csi0_clk = {
2830 .b = {
2831 .ctl_reg = CSI0_CC_REG,
2832 .en_mask = BIT(0),
2833 .reset_reg = SW_RESET_CORE_REG,
2834 .reset_mask = BIT(8),
2835 .halt_reg = DBG_BUS_VEC_B_REG,
2836 .halt_bit = 13,
2837 },
2838 .parent = &csi0_src_clk.c,
2839 .c = {
2840 .dbg_name = "csi0_clk",
2841 .ops = &clk_ops_branch,
2842 CLK_INIT(csi0_clk.c),
2843 },
2844};
2845
2846static struct branch_clk csi0_phy_clk = {
2847 .b = {
2848 .ctl_reg = CSI0_CC_REG,
2849 .en_mask = BIT(8),
2850 .reset_reg = SW_RESET_CORE_REG,
2851 .reset_mask = BIT(29),
2852 .halt_reg = DBG_BUS_VEC_I_REG,
2853 .halt_bit = 9,
2854 },
2855 .parent = &csi0_src_clk.c,
2856 .c = {
2857 .dbg_name = "csi0_phy_clk",
2858 .ops = &clk_ops_branch,
2859 CLK_INIT(csi0_phy_clk.c),
2860 },
2861};
2862
2863static struct rcg_clk csi1_src_clk = {
2864 .ns_reg = CSI1_NS_REG,
2865 .b = {
2866 .ctl_reg = CSI1_CC_REG,
2867 .halt_check = NOCHECK,
2868 },
2869 .md_reg = CSI1_MD_REG,
2870 .root_en_mask = BIT(2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002871 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002872 .ctl_mask = BM(7, 6),
2873 .set_rate = set_rate_mnd,
2874 .freq_tbl = clk_tbl_csi,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002875 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002876 .c = {
2877 .dbg_name = "csi1_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07002878 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002879 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002880 CLK_INIT(csi1_src_clk.c),
2881 },
2882};
2883
2884static struct branch_clk csi1_clk = {
2885 .b = {
2886 .ctl_reg = CSI1_CC_REG,
2887 .en_mask = BIT(0),
2888 .reset_reg = SW_RESET_CORE_REG,
2889 .reset_mask = BIT(18),
2890 .halt_reg = DBG_BUS_VEC_B_REG,
2891 .halt_bit = 14,
2892 },
2893 .parent = &csi1_src_clk.c,
2894 .c = {
2895 .dbg_name = "csi1_clk",
2896 .ops = &clk_ops_branch,
2897 CLK_INIT(csi1_clk.c),
2898 },
2899};
2900
2901static struct branch_clk csi1_phy_clk = {
2902 .b = {
2903 .ctl_reg = CSI1_CC_REG,
2904 .en_mask = BIT(8),
2905 .reset_reg = SW_RESET_CORE_REG,
2906 .reset_mask = BIT(28),
2907 .halt_reg = DBG_BUS_VEC_I_REG,
2908 .halt_bit = 10,
2909 },
2910 .parent = &csi1_src_clk.c,
2911 .c = {
2912 .dbg_name = "csi1_phy_clk",
2913 .ops = &clk_ops_branch,
2914 CLK_INIT(csi1_phy_clk.c),
2915 },
2916};
2917
Stephen Boyd94625ef2011-07-12 17:06:01 -07002918static struct rcg_clk csi2_src_clk = {
2919 .ns_reg = CSI2_NS_REG,
2920 .b = {
2921 .ctl_reg = CSI2_CC_REG,
2922 .halt_check = NOCHECK,
2923 },
2924 .md_reg = CSI2_MD_REG,
2925 .root_en_mask = BIT(2),
2926 .ns_mask = BM(31, 24) | BM(15, 14) | BM(2, 0),
2927 .ctl_mask = BM(7, 6),
2928 .set_rate = set_rate_mnd,
2929 .freq_tbl = clk_tbl_csi,
2930 .current_freq = &rcg_dummy_freq,
2931 .c = {
2932 .dbg_name = "csi2_src_clk",
2933 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07002934 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Stephen Boyd94625ef2011-07-12 17:06:01 -07002935 CLK_INIT(csi2_src_clk.c),
2936 },
2937};
2938
2939static struct branch_clk csi2_clk = {
2940 .b = {
2941 .ctl_reg = CSI2_CC_REG,
2942 .en_mask = BIT(0),
2943 .reset_reg = SW_RESET_CORE2_REG,
2944 .reset_mask = BIT(2),
2945 .halt_reg = DBG_BUS_VEC_B_REG,
2946 .halt_bit = 29,
2947 },
2948 .parent = &csi2_src_clk.c,
2949 .c = {
2950 .dbg_name = "csi2_clk",
2951 .ops = &clk_ops_branch,
2952 CLK_INIT(csi2_clk.c),
2953 },
2954};
2955
2956static struct branch_clk csi2_phy_clk = {
2957 .b = {
2958 .ctl_reg = CSI2_CC_REG,
2959 .en_mask = BIT(8),
2960 .reset_reg = SW_RESET_CORE_REG,
2961 .reset_mask = BIT(31),
2962 .halt_reg = DBG_BUS_VEC_I_REG,
2963 .halt_bit = 29,
2964 },
2965 .parent = &csi2_src_clk.c,
2966 .c = {
2967 .dbg_name = "csi2_phy_clk",
2968 .ops = &clk_ops_branch,
2969 CLK_INIT(csi2_phy_clk.c),
2970 },
2971};
2972
Stephen Boyd092fd182011-10-21 15:56:30 -07002973static struct clk *pix_rdi_mux_map[] = {
2974 [0] = &csi0_clk.c,
2975 [1] = &csi1_clk.c,
2976 [2] = &csi2_clk.c,
2977 NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002978};
2979
Stephen Boyd092fd182011-10-21 15:56:30 -07002980struct pix_rdi_clk {
2981 bool enabled;
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002982 unsigned long cur_rate;
Stephen Boyd092fd182011-10-21 15:56:30 -07002983
2984 void __iomem *const s_reg;
2985 u32 s_mask;
2986
2987 void __iomem *const s2_reg;
2988 u32 s2_mask;
2989
2990 struct branch b;
2991 struct clk c;
2992};
2993
2994static inline struct pix_rdi_clk *to_pix_rdi_clk(struct clk *clk)
2995{
2996 return container_of(clk, struct pix_rdi_clk, c);
2997}
2998
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07002999static int pix_rdi_clk_set_rate(struct clk *c, unsigned long rate)
Stephen Boyd092fd182011-10-21 15:56:30 -07003000{
3001 int ret, i;
3002 u32 reg;
3003 unsigned long flags;
3004 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3005 struct clk **mux_map = pix_rdi_mux_map;
3006
3007 /*
3008 * These clocks select three inputs via two muxes. One mux selects
3009 * between csi0 and csi1 and the second mux selects between that mux's
3010 * output and csi2. The source and destination selections for each
3011 * mux must be clocking for the switch to succeed so just turn on
3012 * all three sources because it's easier than figuring out what source
3013 * needs to be on at what time.
3014 */
3015 for (i = 0; mux_map[i]; i++) {
3016 ret = clk_enable(mux_map[i]);
3017 if (ret)
3018 goto err;
3019 }
3020 if (rate >= i) {
3021 ret = -EINVAL;
3022 goto err;
3023 }
3024 /* Keep the new source on when switching inputs of an enabled clock */
3025 if (clk->enabled) {
3026 clk_disable(mux_map[clk->cur_rate]);
3027 clk_enable(mux_map[rate]);
3028 }
3029 spin_lock_irqsave(&local_clock_reg_lock, flags);
3030 reg = readl_relaxed(clk->s2_reg);
3031 reg &= ~clk->s2_mask;
3032 reg |= rate == 2 ? clk->s2_mask : 0;
3033 writel_relaxed(reg, clk->s2_reg);
3034 /*
3035 * Wait at least 6 cycles of slowest clock
3036 * for the glitch-free MUX to fully switch sources.
3037 */
3038 mb();
3039 udelay(1);
3040 reg = readl_relaxed(clk->s_reg);
3041 reg &= ~clk->s_mask;
3042 reg |= rate == 1 ? clk->s_mask : 0;
3043 writel_relaxed(reg, clk->s_reg);
3044 /*
3045 * Wait at least 6 cycles of slowest clock
3046 * for the glitch-free MUX to fully switch sources.
3047 */
3048 mb();
3049 udelay(1);
3050 clk->cur_rate = rate;
3051 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3052err:
3053 for (i--; i >= 0; i--)
3054 clk_disable(mux_map[i]);
3055
3056 return 0;
3057}
3058
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07003059static unsigned long pix_rdi_clk_get_rate(struct clk *c)
Stephen Boyd092fd182011-10-21 15:56:30 -07003060{
3061 return to_pix_rdi_clk(c)->cur_rate;
3062}
3063
3064static int pix_rdi_clk_enable(struct clk *c)
3065{
3066 unsigned long flags;
3067 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3068
3069 spin_lock_irqsave(&local_clock_reg_lock, flags);
3070 __branch_clk_enable_reg(&clk->b, clk->c.dbg_name);
3071 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3072 clk->enabled = true;
3073
3074 return 0;
3075}
3076
3077static void pix_rdi_clk_disable(struct clk *c)
3078{
3079 unsigned long flags;
3080 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3081
3082 spin_lock_irqsave(&local_clock_reg_lock, flags);
3083 __branch_clk_disable_reg(&clk->b, clk->c.dbg_name);
3084 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
3085 clk->enabled = false;
3086}
3087
3088static int pix_rdi_clk_reset(struct clk *clk, enum clk_reset_action action)
3089{
3090 return branch_reset(&to_pix_rdi_clk(clk)->b, action);
3091}
3092
3093static struct clk *pix_rdi_clk_get_parent(struct clk *c)
3094{
3095 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3096
3097 return pix_rdi_mux_map[clk->cur_rate];
3098}
3099
3100static int pix_rdi_clk_list_rate(struct clk *c, unsigned n)
3101{
3102 if (pix_rdi_mux_map[n])
3103 return n;
3104 return -ENXIO;
3105}
3106
3107static int pix_rdi_clk_handoff(struct clk *c)
3108{
3109 u32 reg;
3110 struct pix_rdi_clk *clk = to_pix_rdi_clk(c);
3111
3112 reg = readl_relaxed(clk->s_reg);
3113 clk->cur_rate = reg & clk->s_mask ? 1 : 0;
3114 reg = readl_relaxed(clk->s2_reg);
3115 clk->cur_rate = reg & clk->s2_mask ? 2 : clk->cur_rate;
3116 return 0;
3117}
3118
3119static struct clk_ops clk_ops_pix_rdi_8960 = {
3120 .enable = pix_rdi_clk_enable,
3121 .disable = pix_rdi_clk_disable,
3122 .auto_off = pix_rdi_clk_disable,
3123 .handoff = pix_rdi_clk_handoff,
3124 .set_rate = pix_rdi_clk_set_rate,
3125 .get_rate = pix_rdi_clk_get_rate,
3126 .list_rate = pix_rdi_clk_list_rate,
3127 .reset = pix_rdi_clk_reset,
3128 .is_local = local_clk_is_local,
3129 .get_parent = pix_rdi_clk_get_parent,
3130};
3131
3132static struct pix_rdi_clk csi_pix_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003133 .b = {
3134 .ctl_reg = MISC_CC_REG,
3135 .en_mask = BIT(26),
3136 .halt_check = DELAY,
3137 .reset_reg = SW_RESET_CORE_REG,
3138 .reset_mask = BIT(26),
3139 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003140 .s_reg = MISC_CC_REG,
3141 .s_mask = BIT(25),
3142 .s2_reg = MISC_CC3_REG,
3143 .s2_mask = BIT(13),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003144 .c = {
3145 .dbg_name = "csi_pix_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003146 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003147 CLK_INIT(csi_pix_clk.c),
3148 },
3149};
3150
Stephen Boyd092fd182011-10-21 15:56:30 -07003151static struct pix_rdi_clk csi_pix1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003152 .b = {
3153 .ctl_reg = MISC_CC3_REG,
3154 .en_mask = BIT(10),
3155 .halt_check = DELAY,
3156 .reset_reg = SW_RESET_CORE_REG,
3157 .reset_mask = BIT(30),
3158 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003159 .s_reg = MISC_CC3_REG,
3160 .s_mask = BIT(8),
3161 .s2_reg = MISC_CC3_REG,
3162 .s2_mask = BIT(9),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003163 .c = {
3164 .dbg_name = "csi_pix1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003165 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003166 CLK_INIT(csi_pix1_clk.c),
3167 },
3168};
3169
Stephen Boyd092fd182011-10-21 15:56:30 -07003170static struct pix_rdi_clk csi_rdi_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003171 .b = {
3172 .ctl_reg = MISC_CC_REG,
3173 .en_mask = BIT(13),
3174 .halt_check = DELAY,
3175 .reset_reg = SW_RESET_CORE_REG,
3176 .reset_mask = BIT(27),
3177 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003178 .s_reg = MISC_CC_REG,
3179 .s_mask = BIT(12),
3180 .s2_reg = MISC_CC3_REG,
3181 .s2_mask = BIT(12),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003182 .c = {
3183 .dbg_name = "csi_rdi_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003184 .ops = &clk_ops_pix_rdi_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003185 CLK_INIT(csi_rdi_clk.c),
3186 },
3187};
3188
Stephen Boyd092fd182011-10-21 15:56:30 -07003189static struct pix_rdi_clk csi_rdi1_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003190 .b = {
3191 .ctl_reg = MISC_CC3_REG,
3192 .en_mask = BIT(2),
3193 .halt_check = DELAY,
3194 .reset_reg = SW_RESET_CORE2_REG,
3195 .reset_mask = BIT(1),
3196 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003197 .s_reg = MISC_CC3_REG,
3198 .s_mask = BIT(0),
3199 .s2_reg = MISC_CC3_REG,
3200 .s2_mask = BIT(1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003201 .c = {
3202 .dbg_name = "csi_rdi1_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003203 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003204 CLK_INIT(csi_rdi1_clk.c),
3205 },
3206};
3207
Stephen Boyd092fd182011-10-21 15:56:30 -07003208static struct pix_rdi_clk csi_rdi2_clk = {
Stephen Boyd94625ef2011-07-12 17:06:01 -07003209 .b = {
3210 .ctl_reg = MISC_CC3_REG,
3211 .en_mask = BIT(6),
3212 .halt_check = DELAY,
3213 .reset_reg = SW_RESET_CORE2_REG,
3214 .reset_mask = BIT(0),
3215 },
Stephen Boyd092fd182011-10-21 15:56:30 -07003216 .s_reg = MISC_CC3_REG,
3217 .s_mask = BIT(4),
3218 .s2_reg = MISC_CC3_REG,
3219 .s2_mask = BIT(5),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003220 .c = {
3221 .dbg_name = "csi_rdi2_clk",
Stephen Boyd092fd182011-10-21 15:56:30 -07003222 .ops = &clk_ops_pix_rdi_8960,
Stephen Boyd94625ef2011-07-12 17:06:01 -07003223 CLK_INIT(csi_rdi2_clk.c),
3224 },
3225};
3226
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003227#define F_CSI_PHYTIMER(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003228 { \
3229 .freq_hz = f, \
3230 .src_clk = &s##_clk.c, \
3231 .md_val = MD8(8, m, 0, n), \
3232 .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
3233 .ctl_val = CC(6, n), \
3234 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003235 }
3236static struct clk_freq_tbl clk_tbl_csi_phytimer[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003237 F_CSI_PHYTIMER( 0, gnd, 1, 0, 0),
3238 F_CSI_PHYTIMER( 85330000, pll8, 1, 2, 9),
3239 F_CSI_PHYTIMER(177780000, pll2, 1, 2, 9),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003240 F_END
3241};
3242
3243static struct rcg_clk csiphy_timer_src_clk = {
3244 .ns_reg = CSIPHYTIMER_NS_REG,
3245 .b = {
3246 .ctl_reg = CSIPHYTIMER_CC_REG,
3247 .halt_check = NOCHECK,
3248 },
3249 .md_reg = CSIPHYTIMER_MD_REG,
3250 .root_en_mask = BIT(2),
3251 .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)),
3252 .ctl_mask = BM(7, 6),
3253 .set_rate = set_rate_mnd_8,
3254 .freq_tbl = clk_tbl_csi_phytimer,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003255 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003256 .c = {
3257 .dbg_name = "csiphy_timer_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003258 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003259 VDD_DIG_FMAX_MAP2(LOW, 86000000, NOMINAL, 178000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003260 CLK_INIT(csiphy_timer_src_clk.c),
3261 },
3262};
3263
3264static struct branch_clk csi0phy_timer_clk = {
3265 .b = {
3266 .ctl_reg = CSIPHYTIMER_CC_REG,
3267 .en_mask = BIT(0),
3268 .halt_reg = DBG_BUS_VEC_I_REG,
3269 .halt_bit = 17,
3270 },
3271 .parent = &csiphy_timer_src_clk.c,
3272 .c = {
3273 .dbg_name = "csi0phy_timer_clk",
3274 .ops = &clk_ops_branch,
3275 CLK_INIT(csi0phy_timer_clk.c),
3276 },
3277};
3278
3279static struct branch_clk csi1phy_timer_clk = {
3280 .b = {
3281 .ctl_reg = CSIPHYTIMER_CC_REG,
3282 .en_mask = BIT(9),
3283 .halt_reg = DBG_BUS_VEC_I_REG,
3284 .halt_bit = 18,
3285 },
3286 .parent = &csiphy_timer_src_clk.c,
3287 .c = {
3288 .dbg_name = "csi1phy_timer_clk",
3289 .ops = &clk_ops_branch,
3290 CLK_INIT(csi1phy_timer_clk.c),
3291 },
3292};
3293
Stephen Boyd94625ef2011-07-12 17:06:01 -07003294static struct branch_clk csi2phy_timer_clk = {
3295 .b = {
3296 .ctl_reg = CSIPHYTIMER_CC_REG,
3297 .en_mask = BIT(11),
3298 .halt_reg = DBG_BUS_VEC_I_REG,
3299 .halt_bit = 30,
3300 },
3301 .parent = &csiphy_timer_src_clk.c,
3302 .c = {
3303 .dbg_name = "csi2phy_timer_clk",
3304 .ops = &clk_ops_branch,
3305 CLK_INIT(csi2phy_timer_clk.c),
3306 },
3307};
3308
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003309#define F_DSI(d) \
3310 { \
3311 .freq_hz = d, \
3312 .ns_val = BVAL(15, 12, (d-1)), \
3313 }
3314/*
3315 * The DSI_BYTE/ESC clock is sourced from the DSI PHY PLL, which may change rate
3316 * without this clock driver knowing. So, overload the clk_set_rate() to set
3317 * the divider (1 to 16) of the clock with respect to the PLL rate.
3318 */
3319static struct clk_freq_tbl clk_tbl_dsi_byte[] = {
3320 F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4),
3321 F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8),
3322 F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12),
3323 F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16),
3324 F_END
3325};
3326
3327static struct rcg_clk dsi1_byte_clk = {
3328 .b = {
3329 .ctl_reg = DSI1_BYTE_CC_REG,
3330 .en_mask = BIT(0),
3331 .reset_reg = SW_RESET_CORE_REG,
3332 .reset_mask = BIT(7),
3333 .halt_reg = DBG_BUS_VEC_B_REG,
3334 .halt_bit = 21,
3335 },
3336 .ns_reg = DSI1_BYTE_NS_REG,
3337 .root_en_mask = BIT(2),
3338 .ns_mask = BM(15, 12),
3339 .set_rate = set_rate_nop,
3340 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003341 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003342 .c = {
3343 .dbg_name = "dsi1_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003344 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003345 CLK_INIT(dsi1_byte_clk.c),
3346 },
3347};
3348
3349static struct rcg_clk dsi2_byte_clk = {
3350 .b = {
3351 .ctl_reg = DSI2_BYTE_CC_REG,
3352 .en_mask = BIT(0),
3353 .reset_reg = SW_RESET_CORE_REG,
3354 .reset_mask = BIT(25),
3355 .halt_reg = DBG_BUS_VEC_B_REG,
3356 .halt_bit = 20,
3357 },
3358 .ns_reg = DSI2_BYTE_NS_REG,
3359 .root_en_mask = BIT(2),
3360 .ns_mask = BM(15, 12),
3361 .set_rate = set_rate_nop,
3362 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003363 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003364 .c = {
3365 .dbg_name = "dsi2_byte_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003366 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003367 CLK_INIT(dsi2_byte_clk.c),
3368 },
3369};
3370
3371static struct rcg_clk dsi1_esc_clk = {
3372 .b = {
3373 .ctl_reg = DSI1_ESC_CC_REG,
3374 .en_mask = BIT(0),
3375 .reset_reg = SW_RESET_CORE_REG,
3376 .halt_reg = DBG_BUS_VEC_I_REG,
3377 .halt_bit = 1,
3378 },
3379 .ns_reg = DSI1_ESC_NS_REG,
3380 .root_en_mask = BIT(2),
3381 .ns_mask = BM(15, 12),
3382 .set_rate = set_rate_nop,
3383 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003384 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003385 .c = {
3386 .dbg_name = "dsi1_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003387 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003388 CLK_INIT(dsi1_esc_clk.c),
3389 },
3390};
3391
3392static struct rcg_clk dsi2_esc_clk = {
3393 .b = {
3394 .ctl_reg = DSI2_ESC_CC_REG,
3395 .en_mask = BIT(0),
3396 .halt_reg = DBG_BUS_VEC_I_REG,
3397 .halt_bit = 3,
3398 },
3399 .ns_reg = DSI2_ESC_NS_REG,
3400 .root_en_mask = BIT(2),
3401 .ns_mask = BM(15, 12),
3402 .set_rate = set_rate_nop,
3403 .freq_tbl = clk_tbl_dsi_byte,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003404 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003405 .c = {
3406 .dbg_name = "dsi2_esc_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003407 .ops = &clk_ops_rcg_8960,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003408 CLK_INIT(dsi2_esc_clk.c),
3409 },
3410};
3411
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003412#define F_GFX2D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003413 { \
3414 .freq_hz = f, \
3415 .src_clk = &s##_clk.c, \
3416 .md_val = MD4(4, m, 0, n), \
3417 .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \
3418 .ctl_val = CC_BANKED(9, 6, n), \
3419 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003420 }
3421static struct clk_freq_tbl clk_tbl_gfx2d[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003422 F_GFX2D( 0, gnd, 0, 0),
3423 F_GFX2D( 27000000, pxo, 0, 0),
3424 F_GFX2D( 48000000, pll8, 1, 8),
3425 F_GFX2D( 54857000, pll8, 1, 7),
3426 F_GFX2D( 64000000, pll8, 1, 6),
3427 F_GFX2D( 76800000, pll8, 1, 5),
3428 F_GFX2D( 96000000, pll8, 1, 4),
3429 F_GFX2D(128000000, pll8, 1, 3),
3430 F_GFX2D(145455000, pll2, 2, 11),
3431 F_GFX2D(160000000, pll2, 1, 5),
3432 F_GFX2D(177778000, pll2, 2, 9),
3433 F_GFX2D(200000000, pll2, 1, 4),
3434 F_GFX2D(228571000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003435 F_END
3436};
3437
3438static struct bank_masks bmnd_info_gfx2d0 = {
3439 .bank_sel_mask = BIT(11),
3440 .bank0_mask = {
3441 .md_reg = GFX2D0_MD0_REG,
3442 .ns_mask = BM(23, 20) | BM(5, 3),
3443 .rst_mask = BIT(25),
3444 .mnd_en_mask = BIT(8),
3445 .mode_mask = BM(10, 9),
3446 },
3447 .bank1_mask = {
3448 .md_reg = GFX2D0_MD1_REG,
3449 .ns_mask = BM(19, 16) | BM(2, 0),
3450 .rst_mask = BIT(24),
3451 .mnd_en_mask = BIT(5),
3452 .mode_mask = BM(7, 6),
3453 },
3454};
3455
3456static struct rcg_clk gfx2d0_clk = {
3457 .b = {
3458 .ctl_reg = GFX2D0_CC_REG,
3459 .en_mask = BIT(0),
3460 .reset_reg = SW_RESET_CORE_REG,
3461 .reset_mask = BIT(14),
3462 .halt_reg = DBG_BUS_VEC_A_REG,
3463 .halt_bit = 9,
3464 },
3465 .ns_reg = GFX2D0_NS_REG,
3466 .root_en_mask = BIT(2),
3467 .set_rate = set_rate_mnd_banked,
3468 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003469 .bank_info = &bmnd_info_gfx2d0,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003470 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003471 .c = {
3472 .dbg_name = "gfx2d0_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003473 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003474 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3475 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003476 CLK_INIT(gfx2d0_clk.c),
3477 },
3478};
3479
3480static struct bank_masks bmnd_info_gfx2d1 = {
3481 .bank_sel_mask = BIT(11),
3482 .bank0_mask = {
3483 .md_reg = GFX2D1_MD0_REG,
3484 .ns_mask = BM(23, 20) | BM(5, 3),
3485 .rst_mask = BIT(25),
3486 .mnd_en_mask = BIT(8),
3487 .mode_mask = BM(10, 9),
3488 },
3489 .bank1_mask = {
3490 .md_reg = GFX2D1_MD1_REG,
3491 .ns_mask = BM(19, 16) | BM(2, 0),
3492 .rst_mask = BIT(24),
3493 .mnd_en_mask = BIT(5),
3494 .mode_mask = BM(7, 6),
3495 },
3496};
3497
3498static struct rcg_clk gfx2d1_clk = {
3499 .b = {
3500 .ctl_reg = GFX2D1_CC_REG,
3501 .en_mask = BIT(0),
3502 .reset_reg = SW_RESET_CORE_REG,
3503 .reset_mask = BIT(13),
3504 .halt_reg = DBG_BUS_VEC_A_REG,
3505 .halt_bit = 14,
3506 },
3507 .ns_reg = GFX2D1_NS_REG,
3508 .root_en_mask = BIT(2),
3509 .set_rate = set_rate_mnd_banked,
3510 .freq_tbl = clk_tbl_gfx2d,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003511 .bank_info = &bmnd_info_gfx2d1,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003512 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003513 .c = {
3514 .dbg_name = "gfx2d1_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003515 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003516 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
3517 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003518 CLK_INIT(gfx2d1_clk.c),
3519 },
3520};
3521
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003522#define F_GFX3D(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003523 { \
3524 .freq_hz = f, \
3525 .src_clk = &s##_clk.c, \
3526 .md_val = MD4(4, m, 0, n), \
3527 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3528 .ctl_val = CC_BANKED(9, 6, n), \
3529 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003530 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003531
3532static struct clk_freq_tbl clk_tbl_gfx3d_8960[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003533 F_GFX3D( 0, gnd, 0, 0),
3534 F_GFX3D( 27000000, pxo, 0, 0),
3535 F_GFX3D( 48000000, pll8, 1, 8),
3536 F_GFX3D( 54857000, pll8, 1, 7),
3537 F_GFX3D( 64000000, pll8, 1, 6),
3538 F_GFX3D( 76800000, pll8, 1, 5),
3539 F_GFX3D( 96000000, pll8, 1, 4),
3540 F_GFX3D(128000000, pll8, 1, 3),
3541 F_GFX3D(145455000, pll2, 2, 11),
3542 F_GFX3D(160000000, pll2, 1, 5),
3543 F_GFX3D(177778000, pll2, 2, 9),
3544 F_GFX3D(200000000, pll2, 1, 4),
3545 F_GFX3D(228571000, pll2, 2, 7),
3546 F_GFX3D(266667000, pll2, 1, 3),
3547 F_GFX3D(320000000, pll2, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003548 F_END
3549};
3550
Tianyi Gou41515e22011-09-01 19:37:43 -07003551static struct clk_freq_tbl clk_tbl_gfx3d_8960_v2[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003552 F_GFX3D( 0, gnd, 0, 0),
3553 F_GFX3D( 27000000, pxo, 0, 0),
3554 F_GFX3D( 48000000, pll8, 1, 8),
3555 F_GFX3D( 54857000, pll8, 1, 7),
3556 F_GFX3D( 64000000, pll8, 1, 6),
3557 F_GFX3D( 76800000, pll8, 1, 5),
3558 F_GFX3D( 96000000, pll8, 1, 4),
3559 F_GFX3D(128000000, pll8, 1, 3),
3560 F_GFX3D(145455000, pll2, 2, 11),
3561 F_GFX3D(160000000, pll2, 1, 5),
3562 F_GFX3D(177778000, pll2, 2, 9),
3563 F_GFX3D(200000000, pll2, 1, 4),
3564 F_GFX3D(228571000, pll2, 2, 7),
3565 F_GFX3D(266667000, pll2, 1, 3),
3566 F_GFX3D(300000000, pll3, 1, 4),
3567 F_GFX3D(320000000, pll2, 2, 5),
3568 F_GFX3D(400000000, pll2, 1, 2),
Stephen Boyd94625ef2011-07-12 17:06:01 -07003569 F_END
3570};
3571
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003572static unsigned long fmax_gfx3d_8960_v2[MAX_VDD_LEVELS] __initdata = {
3573 [VDD_DIG_LOW] = 128000000,
3574 [VDD_DIG_NOMINAL] = 300000000,
3575 [VDD_DIG_HIGH] = 400000000
3576};
3577
Tianyi Gou41515e22011-09-01 19:37:43 -07003578static struct clk_freq_tbl clk_tbl_gfx3d_8064[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003579 F_GFX3D( 0, gnd, 0, 0),
3580 F_GFX3D( 27000000, pxo, 0, 0),
3581 F_GFX3D( 48000000, pll8, 1, 8),
3582 F_GFX3D( 54857000, pll8, 1, 7),
3583 F_GFX3D( 64000000, pll8, 1, 6),
3584 F_GFX3D( 76800000, pll8, 1, 5),
3585 F_GFX3D( 96000000, pll8, 1, 4),
3586 F_GFX3D(128000000, pll8, 1, 3),
3587 F_GFX3D(145455000, pll2, 2, 11),
3588 F_GFX3D(160000000, pll2, 1, 5),
3589 F_GFX3D(177778000, pll2, 2, 9),
3590 F_GFX3D(200000000, pll2, 1, 4),
3591 F_GFX3D(228571000, pll2, 2, 7),
3592 F_GFX3D(266667000, pll2, 1, 3),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07003593 F_GFX3D(325000000, pll15, 1, 3),
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003594 F_GFX3D(400000000, pll2, 1, 2),
Tianyi Gou41515e22011-09-01 19:37:43 -07003595 F_END
3596};
3597
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003598static unsigned long fmax_gfx3d_8064[MAX_VDD_LEVELS] __initdata = {
3599 [VDD_DIG_LOW] = 128000000,
3600 [VDD_DIG_NOMINAL] = 325000000,
3601 [VDD_DIG_HIGH] = 400000000
3602};
3603
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003604static struct bank_masks bmnd_info_gfx3d = {
3605 .bank_sel_mask = BIT(11),
3606 .bank0_mask = {
3607 .md_reg = GFX3D_MD0_REG,
3608 .ns_mask = BM(21, 18) | BM(5, 3),
3609 .rst_mask = BIT(23),
3610 .mnd_en_mask = BIT(8),
3611 .mode_mask = BM(10, 9),
3612 },
3613 .bank1_mask = {
3614 .md_reg = GFX3D_MD1_REG,
3615 .ns_mask = BM(17, 14) | BM(2, 0),
3616 .rst_mask = BIT(22),
3617 .mnd_en_mask = BIT(5),
3618 .mode_mask = BM(7, 6),
3619 },
3620};
3621
3622static struct rcg_clk gfx3d_clk = {
3623 .b = {
3624 .ctl_reg = GFX3D_CC_REG,
3625 .en_mask = BIT(0),
3626 .reset_reg = SW_RESET_CORE_REG,
3627 .reset_mask = BIT(12),
3628 .halt_reg = DBG_BUS_VEC_A_REG,
3629 .halt_bit = 4,
3630 },
3631 .ns_reg = GFX3D_NS_REG,
3632 .root_en_mask = BIT(2),
3633 .set_rate = set_rate_mnd_banked,
Tianyi Gou41515e22011-09-01 19:37:43 -07003634 .freq_tbl = clk_tbl_gfx3d_8960,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003635 .bank_info = &bmnd_info_gfx3d,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003636 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003637 .c = {
3638 .dbg_name = "gfx3d_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003639 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003640 VDD_DIG_FMAX_MAP3(LOW, 128000000, NOMINAL, 266667000,
3641 HIGH, 320000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003642 CLK_INIT(gfx3d_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003643 .depends = &gmem_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003644 },
3645};
3646
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003647#define F_VCAP(f, s, m, n) \
Tianyi Gou621f8742011-09-01 21:45:01 -07003648 { \
3649 .freq_hz = f, \
3650 .src_clk = &s##_clk.c, \
3651 .md_val = MD4(4, m, 0, n), \
3652 .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \
3653 .ctl_val = CC_BANKED(9, 6, n), \
3654 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Tianyi Gou621f8742011-09-01 21:45:01 -07003655 }
3656
3657static struct clk_freq_tbl clk_tbl_vcap[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003658 F_VCAP( 0, gnd, 0, 0),
3659 F_VCAP( 27000000, pxo, 0, 0),
3660 F_VCAP( 54860000, pll8, 1, 7),
3661 F_VCAP( 64000000, pll8, 1, 6),
3662 F_VCAP( 76800000, pll8, 1, 5),
3663 F_VCAP(128000000, pll8, 1, 3),
3664 F_VCAP(160000000, pll2, 1, 5),
3665 F_VCAP(200000000, pll2, 1, 4),
Tianyi Gou621f8742011-09-01 21:45:01 -07003666 F_END
3667};
3668
3669static struct bank_masks bmnd_info_vcap = {
3670 .bank_sel_mask = BIT(11),
3671 .bank0_mask = {
3672 .md_reg = VCAP_MD0_REG,
3673 .ns_mask = BM(21, 18) | BM(5, 3),
3674 .rst_mask = BIT(23),
3675 .mnd_en_mask = BIT(8),
3676 .mode_mask = BM(10, 9),
3677 },
3678 .bank1_mask = {
3679 .md_reg = VCAP_MD1_REG,
3680 .ns_mask = BM(17, 14) | BM(2, 0),
3681 .rst_mask = BIT(22),
3682 .mnd_en_mask = BIT(5),
3683 .mode_mask = BM(7, 6),
3684 },
3685};
3686
3687static struct rcg_clk vcap_clk = {
3688 .b = {
3689 .ctl_reg = VCAP_CC_REG,
3690 .en_mask = BIT(0),
3691 .halt_reg = DBG_BUS_VEC_J_REG,
3692 .halt_bit = 15,
3693 },
3694 .ns_reg = VCAP_NS_REG,
3695 .root_en_mask = BIT(2),
3696 .set_rate = set_rate_mnd_banked,
3697 .freq_tbl = clk_tbl_vcap,
3698 .bank_info = &bmnd_info_vcap,
3699 .current_freq = &rcg_dummy_freq,
3700 .c = {
3701 .dbg_name = "vcap_clk",
3702 .ops = &clk_ops_rcg_8960,
3703 .depends = &vcap_axi_clk.c,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003704 VDD_DIG_FMAX_MAP2(LOW, 100000000, NOMINAL, 200000000),
Tianyi Gou621f8742011-09-01 21:45:01 -07003705 CLK_INIT(vcap_clk.c),
3706 },
3707};
3708
3709static struct branch_clk vcap_npl_clk = {
3710 .b = {
3711 .ctl_reg = VCAP_CC_REG,
3712 .en_mask = BIT(13),
3713 .halt_reg = DBG_BUS_VEC_J_REG,
3714 .halt_bit = 25,
3715 },
3716 .parent = &vcap_clk.c,
3717 .c = {
3718 .dbg_name = "vcap_npl_clk",
3719 .ops = &clk_ops_branch,
3720 CLK_INIT(vcap_npl_clk.c),
3721 },
3722};
3723
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003724#define F_IJPEG(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003725 { \
3726 .freq_hz = f, \
3727 .src_clk = &s##_clk.c, \
3728 .md_val = MD8(8, m, 0, n), \
3729 .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \
3730 .ctl_val = CC(6, n), \
3731 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003732 }
Tianyi Gou41515e22011-09-01 19:37:43 -07003733
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003734static struct clk_freq_tbl clk_tbl_ijpeg[] = {
3735 F_IJPEG( 0, gnd, 1, 0, 0),
3736 F_IJPEG( 27000000, pxo, 1, 0, 0),
3737 F_IJPEG( 36570000, pll8, 1, 2, 21),
3738 F_IJPEG( 54860000, pll8, 7, 0, 0),
3739 F_IJPEG( 96000000, pll8, 4, 0, 0),
3740 F_IJPEG(109710000, pll8, 1, 2, 7),
3741 F_IJPEG(128000000, pll8, 3, 0, 0),
3742 F_IJPEG(153600000, pll8, 1, 2, 5),
3743 F_IJPEG(200000000, pll2, 4, 0, 0),
3744 F_IJPEG(228571000, pll2, 1, 2, 7),
3745 F_IJPEG(266667000, pll2, 1, 1, 3),
3746 F_IJPEG(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003747 F_END
3748};
3749
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003750static unsigned long fmax_ijpeg_8960_v2[MAX_VDD_LEVELS] __initdata = {
3751 [VDD_DIG_LOW] = 110000000,
3752 [VDD_DIG_NOMINAL] = 266667000,
3753 [VDD_DIG_HIGH] = 320000000
3754};
3755
3756static unsigned long fmax_ijpeg_8064[MAX_VDD_LEVELS] __initdata = {
3757 [VDD_DIG_LOW] = 128000000,
3758 [VDD_DIG_NOMINAL] = 266667000,
3759 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07003760};
3761
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003762static struct rcg_clk ijpeg_clk = {
3763 .b = {
3764 .ctl_reg = IJPEG_CC_REG,
3765 .en_mask = BIT(0),
3766 .reset_reg = SW_RESET_CORE_REG,
3767 .reset_mask = BIT(9),
3768 .halt_reg = DBG_BUS_VEC_A_REG,
3769 .halt_bit = 24,
3770 },
3771 .ns_reg = IJPEG_NS_REG,
3772 .md_reg = IJPEG_MD_REG,
3773 .root_en_mask = BIT(2),
3774 .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)),
3775 .ctl_mask = BM(7, 6),
3776 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003777 .freq_tbl = clk_tbl_ijpeg,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003778 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003779 .c = {
3780 .dbg_name = "ijpeg_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003781 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003782 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003783 CLK_INIT(ijpeg_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003784 .depends = &ijpeg_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003785 },
3786};
3787
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003788#define F_JPEGD(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003789 { \
3790 .freq_hz = f, \
3791 .src_clk = &s##_clk.c, \
3792 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003793 }
3794static struct clk_freq_tbl clk_tbl_jpegd[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003795 F_JPEGD( 0, gnd, 1),
3796 F_JPEGD( 64000000, pll8, 6),
3797 F_JPEGD( 76800000, pll8, 5),
3798 F_JPEGD( 96000000, pll8, 4),
3799 F_JPEGD(160000000, pll2, 5),
3800 F_JPEGD(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003801 F_END
3802};
3803
3804static struct rcg_clk jpegd_clk = {
3805 .b = {
3806 .ctl_reg = JPEGD_CC_REG,
3807 .en_mask = BIT(0),
3808 .reset_reg = SW_RESET_CORE_REG,
3809 .reset_mask = BIT(19),
3810 .halt_reg = DBG_BUS_VEC_A_REG,
3811 .halt_bit = 19,
3812 },
3813 .ns_reg = JPEGD_NS_REG,
3814 .root_en_mask = BIT(2),
3815 .ns_mask = (BM(15, 12) | BM(2, 0)),
3816 .set_rate = set_rate_nop,
3817 .freq_tbl = clk_tbl_jpegd,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003818 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003819 .c = {
3820 .dbg_name = "jpegd_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003821 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003822 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003823 CLK_INIT(jpegd_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003824 .depends = &jpegd_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003825 },
3826};
3827
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003828#define F_MDP(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003829 { \
3830 .freq_hz = f, \
3831 .src_clk = &s##_clk.c, \
3832 .md_val = MD8(8, m, 0, n), \
3833 .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \
3834 .ctl_val = CC_BANKED(9, 6, n), \
3835 .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003836 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003837static struct clk_freq_tbl clk_tbl_mdp[] = {
3838 F_MDP( 0, gnd, 0, 0),
3839 F_MDP( 9600000, pll8, 1, 40),
3840 F_MDP( 13710000, pll8, 1, 28),
3841 F_MDP( 27000000, pxo, 0, 0),
3842 F_MDP( 29540000, pll8, 1, 13),
3843 F_MDP( 34910000, pll8, 1, 11),
3844 F_MDP( 38400000, pll8, 1, 10),
3845 F_MDP( 59080000, pll8, 2, 13),
3846 F_MDP( 76800000, pll8, 1, 5),
3847 F_MDP( 85330000, pll8, 2, 9),
3848 F_MDP( 96000000, pll8, 1, 4),
3849 F_MDP(128000000, pll8, 1, 3),
3850 F_MDP(160000000, pll2, 1, 5),
3851 F_MDP(177780000, pll2, 2, 9),
3852 F_MDP(200000000, pll2, 1, 4),
3853 F_MDP(266667000, pll2, 1, 3),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003854 F_END
3855};
3856
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003857static unsigned long fmax_mdp_8064[MAX_VDD_LEVELS] __initdata = {
3858 [VDD_DIG_LOW] = 128000000,
3859 [VDD_DIG_NOMINAL] = 266667000
Tianyi Gou621f8742011-09-01 21:45:01 -07003860};
3861
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003862static struct bank_masks bmnd_info_mdp = {
3863 .bank_sel_mask = BIT(11),
3864 .bank0_mask = {
3865 .md_reg = MDP_MD0_REG,
3866 .ns_mask = BM(29, 22) | BM(5, 3),
3867 .rst_mask = BIT(31),
3868 .mnd_en_mask = BIT(8),
3869 .mode_mask = BM(10, 9),
3870 },
3871 .bank1_mask = {
3872 .md_reg = MDP_MD1_REG,
3873 .ns_mask = BM(21, 14) | BM(2, 0),
3874 .rst_mask = BIT(30),
3875 .mnd_en_mask = BIT(5),
3876 .mode_mask = BM(7, 6),
3877 },
3878};
3879
3880static struct rcg_clk mdp_clk = {
3881 .b = {
3882 .ctl_reg = MDP_CC_REG,
3883 .en_mask = BIT(0),
3884 .reset_reg = SW_RESET_CORE_REG,
3885 .reset_mask = BIT(21),
3886 .halt_reg = DBG_BUS_VEC_C_REG,
3887 .halt_bit = 10,
3888 },
3889 .ns_reg = MDP_NS_REG,
3890 .root_en_mask = BIT(2),
3891 .set_rate = set_rate_mnd_banked,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003892 .freq_tbl = clk_tbl_mdp,
Stephen Boydc78d9a72011-07-20 00:46:24 -07003893 .bank_info = &bmnd_info_mdp,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003894 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003895 .c = {
3896 .dbg_name = "mdp_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003897 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003898 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003899 CLK_INIT(mdp_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07003900 .depends = &mdp_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003901 },
3902};
3903
3904static struct branch_clk lut_mdp_clk = {
3905 .b = {
3906 .ctl_reg = MDP_LUT_CC_REG,
3907 .en_mask = BIT(0),
3908 .halt_reg = DBG_BUS_VEC_I_REG,
3909 .halt_bit = 13,
3910 },
3911 .parent = &mdp_clk.c,
3912 .c = {
3913 .dbg_name = "lut_mdp_clk",
3914 .ops = &clk_ops_branch,
3915 CLK_INIT(lut_mdp_clk.c),
3916 },
3917};
3918
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003919#define F_MDP_VSYNC(f, s) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003920 { \
3921 .freq_hz = f, \
3922 .src_clk = &s##_clk.c, \
3923 .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003924 }
3925static struct clk_freq_tbl clk_tbl_mdp_vsync[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003926 F_MDP_VSYNC(27000000, pxo),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003927 F_END
3928};
3929
3930static struct rcg_clk mdp_vsync_clk = {
3931 .b = {
3932 .ctl_reg = MISC_CC_REG,
3933 .en_mask = BIT(6),
3934 .reset_reg = SW_RESET_CORE_REG,
3935 .reset_mask = BIT(3),
3936 .halt_reg = DBG_BUS_VEC_B_REG,
3937 .halt_bit = 22,
3938 },
3939 .ns_reg = MISC_CC2_REG,
3940 .ns_mask = BIT(13),
3941 .set_rate = set_rate_nop,
3942 .freq_tbl = clk_tbl_mdp_vsync,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003943 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003944 .c = {
3945 .dbg_name = "mdp_vsync_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07003946 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003947 VDD_DIG_FMAX_MAP1(LOW, 27000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003948 CLK_INIT(mdp_vsync_clk.c),
3949 },
3950};
3951
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003952#define F_ROT(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003953 { \
3954 .freq_hz = f, \
3955 .src_clk = &s##_clk.c, \
3956 .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \
3957 21, 19, 18, 16, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003958 }
3959static struct clk_freq_tbl clk_tbl_rot[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07003960 F_ROT( 0, gnd, 1),
3961 F_ROT( 27000000, pxo, 1),
3962 F_ROT( 29540000, pll8, 13),
3963 F_ROT( 32000000, pll8, 12),
3964 F_ROT( 38400000, pll8, 10),
3965 F_ROT( 48000000, pll8, 8),
3966 F_ROT( 54860000, pll8, 7),
3967 F_ROT( 64000000, pll8, 6),
3968 F_ROT( 76800000, pll8, 5),
3969 F_ROT( 96000000, pll8, 4),
3970 F_ROT(100000000, pll2, 8),
3971 F_ROT(114290000, pll2, 7),
3972 F_ROT(133330000, pll2, 6),
3973 F_ROT(160000000, pll2, 5),
3974 F_ROT(200000000, pll2, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003975 F_END
3976};
3977
3978static struct bank_masks bdiv_info_rot = {
3979 .bank_sel_mask = BIT(30),
3980 .bank0_mask = {
3981 .ns_mask = BM(25, 22) | BM(18, 16),
3982 },
3983 .bank1_mask = {
3984 .ns_mask = BM(29, 26) | BM(21, 19),
3985 },
3986};
3987
3988static struct rcg_clk rot_clk = {
3989 .b = {
3990 .ctl_reg = ROT_CC_REG,
3991 .en_mask = BIT(0),
3992 .reset_reg = SW_RESET_CORE_REG,
3993 .reset_mask = BIT(2),
3994 .halt_reg = DBG_BUS_VEC_C_REG,
3995 .halt_bit = 15,
3996 },
3997 .ns_reg = ROT_NS_REG,
3998 .root_en_mask = BIT(2),
3999 .set_rate = set_rate_div_banked,
4000 .freq_tbl = clk_tbl_rot,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004001 .bank_info = &bdiv_info_rot,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004002 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004003 .c = {
4004 .dbg_name = "rot_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004005 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004006 VDD_DIG_FMAX_MAP2(LOW, 96000000, NOMINAL, 200000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004007 CLK_INIT(rot_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004008 .depends = &rot_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004009 },
4010};
4011
4012static int hdmi_pll_clk_enable(struct clk *clk)
4013{
4014 int ret;
4015 unsigned long flags;
4016 spin_lock_irqsave(&local_clock_reg_lock, flags);
4017 ret = hdmi_pll_enable();
4018 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4019 return ret;
4020}
4021
4022static void hdmi_pll_clk_disable(struct clk *clk)
4023{
4024 unsigned long flags;
4025 spin_lock_irqsave(&local_clock_reg_lock, flags);
4026 hdmi_pll_disable();
4027 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4028}
4029
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07004030static unsigned long hdmi_pll_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004031{
4032 return hdmi_pll_get_rate();
4033}
4034
Stephen Boyd5b35dee2011-09-21 12:17:38 -07004035static struct clk *hdmi_pll_clk_get_parent(struct clk *clk)
4036{
4037 return &pxo_clk.c;
4038}
4039
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004040static struct clk_ops clk_ops_hdmi_pll = {
4041 .enable = hdmi_pll_clk_enable,
4042 .disable = hdmi_pll_clk_disable,
4043 .get_rate = hdmi_pll_clk_get_rate,
4044 .is_local = local_clk_is_local,
Stephen Boyd5b35dee2011-09-21 12:17:38 -07004045 .get_parent = hdmi_pll_clk_get_parent,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004046};
4047
4048static struct clk hdmi_pll_clk = {
4049 .dbg_name = "hdmi_pll_clk",
4050 .ops = &clk_ops_hdmi_pll,
4051 CLK_INIT(hdmi_pll_clk),
4052};
4053
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004054#define F_TV_GND(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004055 { \
4056 .freq_hz = f, \
4057 .src_clk = &s##_clk.c, \
4058 .md_val = MD8(8, m, 0, n), \
4059 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
4060 .ctl_val = CC(6, n), \
4061 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004062 }
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004063#define F_TV(f, s, p_r, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004064 { \
4065 .freq_hz = f, \
4066 .src_clk = &s##_clk, \
4067 .md_val = MD8(8, m, 0, n), \
4068 .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \
4069 .ctl_val = CC(6, n), \
4070 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004071 .extra_freq_data = (void *)p_r, \
4072 }
4073/* Switching TV freqs requires PLL reconfiguration. */
4074static struct clk_freq_tbl clk_tbl_tv[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004075 F_TV_GND( 0, gnd, 0, 1, 0, 0),
4076 F_TV( 25200000, hdmi_pll, 25200000, 1, 0, 0),
4077 F_TV( 27000000, hdmi_pll, 27000000, 1, 0, 0),
4078 F_TV( 27030000, hdmi_pll, 27030000, 1, 0, 0),
4079 F_TV( 74250000, hdmi_pll, 74250000, 1, 0, 0),
4080 F_TV(148500000, hdmi_pll, 148500000, 1, 0, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004081 F_END
4082};
4083
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004084static unsigned long fmax_tv_src_8064[MAX_VDD_LEVELS] __initdata = {
4085 [VDD_DIG_LOW] = 74250000,
4086 [VDD_DIG_NOMINAL] = 149000000
4087};
4088
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004089/*
4090 * Unlike other clocks, the TV rate is adjusted through PLL
4091 * re-programming. It is also routed through an MND divider.
4092 */
4093void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf)
4094{
4095 unsigned long pll_rate = (unsigned long)nf->extra_freq_data;
4096 if (pll_rate)
4097 hdmi_pll_set_rate(pll_rate);
4098 set_rate_mnd(clk, nf);
4099}
4100
4101static struct rcg_clk tv_src_clk = {
4102 .ns_reg = TV_NS_REG,
4103 .b = {
4104 .ctl_reg = TV_CC_REG,
4105 .halt_check = NOCHECK,
4106 },
4107 .md_reg = TV_MD_REG,
4108 .root_en_mask = BIT(2),
4109 .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)),
4110 .ctl_mask = BM(7, 6),
4111 .set_rate = set_rate_tv,
4112 .freq_tbl = clk_tbl_tv,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004113 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004114 .c = {
4115 .dbg_name = "tv_src_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004116 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004117 VDD_DIG_FMAX_MAP2(LOW, 27030000, NOMINAL, 149000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004118 CLK_INIT(tv_src_clk.c),
4119 },
4120};
4121
4122static struct branch_clk tv_enc_clk = {
4123 .b = {
4124 .ctl_reg = TV_CC_REG,
4125 .en_mask = BIT(8),
4126 .reset_reg = SW_RESET_CORE_REG,
4127 .reset_mask = BIT(0),
4128 .halt_reg = DBG_BUS_VEC_D_REG,
4129 .halt_bit = 9,
4130 },
4131 .parent = &tv_src_clk.c,
4132 .c = {
4133 .dbg_name = "tv_enc_clk",
4134 .ops = &clk_ops_branch,
4135 CLK_INIT(tv_enc_clk.c),
4136 },
4137};
4138
4139static struct branch_clk tv_dac_clk = {
4140 .b = {
4141 .ctl_reg = TV_CC_REG,
4142 .en_mask = BIT(10),
4143 .halt_reg = DBG_BUS_VEC_D_REG,
4144 .halt_bit = 10,
4145 },
4146 .parent = &tv_src_clk.c,
4147 .c = {
4148 .dbg_name = "tv_dac_clk",
4149 .ops = &clk_ops_branch,
4150 CLK_INIT(tv_dac_clk.c),
4151 },
4152};
4153
4154static struct branch_clk mdp_tv_clk = {
4155 .b = {
4156 .ctl_reg = TV_CC_REG,
4157 .en_mask = BIT(0),
4158 .reset_reg = SW_RESET_CORE_REG,
4159 .reset_mask = BIT(4),
4160 .halt_reg = DBG_BUS_VEC_D_REG,
4161 .halt_bit = 12,
4162 },
4163 .parent = &tv_src_clk.c,
4164 .c = {
4165 .dbg_name = "mdp_tv_clk",
4166 .ops = &clk_ops_branch,
4167 CLK_INIT(mdp_tv_clk.c),
4168 },
4169};
4170
4171static struct branch_clk hdmi_tv_clk = {
4172 .b = {
4173 .ctl_reg = TV_CC_REG,
4174 .en_mask = BIT(12),
4175 .reset_reg = SW_RESET_CORE_REG,
4176 .reset_mask = BIT(1),
4177 .halt_reg = DBG_BUS_VEC_D_REG,
4178 .halt_bit = 11,
4179 },
4180 .parent = &tv_src_clk.c,
4181 .c = {
4182 .dbg_name = "hdmi_tv_clk",
4183 .ops = &clk_ops_branch,
4184 CLK_INIT(hdmi_tv_clk.c),
4185 },
4186};
4187
4188static struct branch_clk hdmi_app_clk = {
4189 .b = {
4190 .ctl_reg = MISC_CC2_REG,
4191 .en_mask = BIT(11),
4192 .reset_reg = SW_RESET_CORE_REG,
4193 .reset_mask = BIT(11),
4194 .halt_reg = DBG_BUS_VEC_B_REG,
4195 .halt_bit = 25,
4196 },
4197 .c = {
4198 .dbg_name = "hdmi_app_clk",
4199 .ops = &clk_ops_branch,
4200 CLK_INIT(hdmi_app_clk.c),
4201 },
4202};
4203
4204static struct bank_masks bmnd_info_vcodec = {
4205 .bank_sel_mask = BIT(13),
4206 .bank0_mask = {
4207 .md_reg = VCODEC_MD0_REG,
4208 .ns_mask = BM(18, 11) | BM(2, 0),
4209 .rst_mask = BIT(31),
4210 .mnd_en_mask = BIT(5),
4211 .mode_mask = BM(7, 6),
4212 },
4213 .bank1_mask = {
4214 .md_reg = VCODEC_MD1_REG,
4215 .ns_mask = BM(26, 19) | BM(29, 27),
4216 .rst_mask = BIT(30),
4217 .mnd_en_mask = BIT(10),
4218 .mode_mask = BM(12, 11),
4219 },
4220};
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004221#define F_VCODEC(f, s, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004222 { \
4223 .freq_hz = f, \
4224 .src_clk = &s##_clk.c, \
4225 .md_val = MD8(8, m, 0, n), \
4226 .ns_val = NS_MND_BANKED8(11, 19, n, m, 0, 27, s##_to_mm_mux), \
4227 .ctl_val = CC_BANKED(6, 11, n), \
4228 .mnd_en_mask = (BIT(10) | BIT(5)) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004229 }
4230static struct clk_freq_tbl clk_tbl_vcodec[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004231 F_VCODEC( 0, gnd, 0, 0),
4232 F_VCODEC( 27000000, pxo, 0, 0),
4233 F_VCODEC( 32000000, pll8, 1, 12),
4234 F_VCODEC( 48000000, pll8, 1, 8),
4235 F_VCODEC( 54860000, pll8, 1, 7),
4236 F_VCODEC( 96000000, pll8, 1, 4),
4237 F_VCODEC(133330000, pll2, 1, 6),
4238 F_VCODEC(200000000, pll2, 1, 4),
4239 F_VCODEC(228570000, pll2, 2, 7),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004240 F_END
4241};
4242
4243static struct rcg_clk vcodec_clk = {
4244 .b = {
4245 .ctl_reg = VCODEC_CC_REG,
4246 .en_mask = BIT(0),
4247 .reset_reg = SW_RESET_CORE_REG,
4248 .reset_mask = BIT(6),
4249 .halt_reg = DBG_BUS_VEC_C_REG,
4250 .halt_bit = 29,
4251 },
4252 .ns_reg = VCODEC_NS_REG,
4253 .root_en_mask = BIT(2),
4254 .set_rate = set_rate_mnd_banked,
Stephen Boydc78d9a72011-07-20 00:46:24 -07004255 .bank_info = &bmnd_info_vcodec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004256 .freq_tbl = clk_tbl_vcodec,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004257 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004258 .c = {
4259 .dbg_name = "vcodec_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004260 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004261 VDD_DIG_FMAX_MAP3(LOW, 100000000, NOMINAL, 200000000,
4262 HIGH, 228571000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004263 CLK_INIT(vcodec_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004264 .depends = &vcodec_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004265 },
4266};
4267
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004268#define F_VPE(f, s, d) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004269 { \
4270 .freq_hz = f, \
4271 .src_clk = &s##_clk.c, \
4272 .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004273 }
4274static struct clk_freq_tbl clk_tbl_vpe[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004275 F_VPE( 0, gnd, 1),
4276 F_VPE( 27000000, pxo, 1),
4277 F_VPE( 34909000, pll8, 11),
4278 F_VPE( 38400000, pll8, 10),
4279 F_VPE( 64000000, pll8, 6),
4280 F_VPE( 76800000, pll8, 5),
4281 F_VPE( 96000000, pll8, 4),
4282 F_VPE(100000000, pll2, 8),
4283 F_VPE(160000000, pll2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004284 F_END
4285};
4286
4287static struct rcg_clk vpe_clk = {
4288 .b = {
4289 .ctl_reg = VPE_CC_REG,
4290 .en_mask = BIT(0),
4291 .reset_reg = SW_RESET_CORE_REG,
4292 .reset_mask = BIT(17),
4293 .halt_reg = DBG_BUS_VEC_A_REG,
4294 .halt_bit = 28,
4295 },
4296 .ns_reg = VPE_NS_REG,
4297 .root_en_mask = BIT(2),
4298 .ns_mask = (BM(15, 12) | BM(2, 0)),
4299 .set_rate = set_rate_nop,
4300 .freq_tbl = clk_tbl_vpe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004301 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004302 .c = {
4303 .dbg_name = "vpe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004304 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004305 VDD_DIG_FMAX_MAP2(LOW, 76800000, NOMINAL, 160000000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004306 CLK_INIT(vpe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004307 .depends = &vpe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004308 },
4309};
4310
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004311#define F_VFE(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004312 { \
4313 .freq_hz = f, \
4314 .src_clk = &s##_clk.c, \
4315 .md_val = MD8(8, m, 0, n), \
4316 .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \
4317 .ctl_val = CC(6, n), \
4318 .mnd_en_mask = BIT(5) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004319 }
Tianyi Gou41515e22011-09-01 19:37:43 -07004320
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004321static struct clk_freq_tbl clk_tbl_vfe[] = {
4322 F_VFE( 0, gnd, 1, 0, 0),
4323 F_VFE( 13960000, pll8, 1, 2, 55),
4324 F_VFE( 27000000, pxo, 1, 0, 0),
4325 F_VFE( 36570000, pll8, 1, 2, 21),
4326 F_VFE( 38400000, pll8, 2, 1, 5),
4327 F_VFE( 45180000, pll8, 1, 2, 17),
4328 F_VFE( 48000000, pll8, 2, 1, 4),
4329 F_VFE( 54860000, pll8, 1, 1, 7),
4330 F_VFE( 64000000, pll8, 2, 1, 3),
4331 F_VFE( 76800000, pll8, 1, 1, 5),
4332 F_VFE( 96000000, pll8, 2, 1, 2),
4333 F_VFE(109710000, pll8, 1, 2, 7),
4334 F_VFE(128000000, pll8, 1, 1, 3),
4335 F_VFE(153600000, pll8, 1, 2, 5),
4336 F_VFE(200000000, pll2, 2, 1, 2),
4337 F_VFE(228570000, pll2, 1, 2, 7),
4338 F_VFE(266667000, pll2, 1, 1, 3),
4339 F_VFE(320000000, pll2, 1, 2, 5),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004340 F_END
4341};
4342
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004343static unsigned long fmax_vfe_8960_v2[MAX_VDD_LEVELS] __initdata = {
4344 [VDD_DIG_LOW] = 110000000,
4345 [VDD_DIG_NOMINAL] = 266667000,
4346 [VDD_DIG_HIGH] = 320000000
4347};
4348
4349static unsigned long fmax_vfe_8064[MAX_VDD_LEVELS] __initdata = {
4350 [VDD_DIG_LOW] = 128000000,
4351 [VDD_DIG_NOMINAL] = 266667000,
4352 [VDD_DIG_HIGH] = 320000000
Tianyi Gou41515e22011-09-01 19:37:43 -07004353};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004354
4355static struct rcg_clk vfe_clk = {
4356 .b = {
4357 .ctl_reg = VFE_CC_REG,
4358 .reset_reg = SW_RESET_CORE_REG,
4359 .reset_mask = BIT(15),
4360 .halt_reg = DBG_BUS_VEC_B_REG,
4361 .halt_bit = 6,
4362 .en_mask = BIT(0),
4363 },
4364 .ns_reg = VFE_NS_REG,
4365 .md_reg = VFE_MD_REG,
4366 .root_en_mask = BIT(2),
4367 .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)),
4368 .ctl_mask = BM(7, 6),
4369 .set_rate = set_rate_mnd,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004370 .freq_tbl = clk_tbl_vfe,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004371 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004372 .c = {
4373 .dbg_name = "vfe_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004374 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004375 VDD_DIG_FMAX_MAP2(LOW, 110000000, NOMINAL, 266667000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004376 CLK_INIT(vfe_clk.c),
Stephen Boyd7fa26742011-08-11 23:22:29 -07004377 .depends = &vfe_axi_clk.c,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004378 },
4379};
4380
Matt Wagantallc23eee92011-08-16 23:06:52 -07004381static struct branch_clk csi_vfe_clk = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004382 .b = {
4383 .ctl_reg = VFE_CC_REG,
4384 .en_mask = BIT(12),
4385 .reset_reg = SW_RESET_CORE_REG,
4386 .reset_mask = BIT(24),
4387 .halt_reg = DBG_BUS_VEC_B_REG,
4388 .halt_bit = 8,
4389 },
4390 .parent = &vfe_clk.c,
4391 .c = {
Matt Wagantallc23eee92011-08-16 23:06:52 -07004392 .dbg_name = "csi_vfe_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004393 .ops = &clk_ops_branch,
Matt Wagantallc23eee92011-08-16 23:06:52 -07004394 CLK_INIT(csi_vfe_clk.c),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004395 },
4396};
4397
4398/*
4399 * Low Power Audio Clocks
4400 */
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004401#define F_AIF_OSR(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004402 { \
4403 .freq_hz = f, \
4404 .src_clk = &s##_clk.c, \
4405 .md_val = MD8(8, m, 0, n), \
4406 .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4407 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004408 }
4409static struct clk_freq_tbl clk_tbl_aif_osr[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004410 F_AIF_OSR( 0, gnd, 1, 0, 0),
4411 F_AIF_OSR( 512000, pll4, 4, 1, 192),
4412 F_AIF_OSR( 768000, pll4, 4, 1, 128),
4413 F_AIF_OSR( 1024000, pll4, 4, 1, 96),
4414 F_AIF_OSR( 1536000, pll4, 4, 1, 64),
4415 F_AIF_OSR( 2048000, pll4, 4, 1, 48),
4416 F_AIF_OSR( 3072000, pll4, 4, 1, 32),
4417 F_AIF_OSR( 4096000, pll4, 4, 1, 24),
4418 F_AIF_OSR( 6144000, pll4, 4, 1, 16),
4419 F_AIF_OSR( 8192000, pll4, 4, 1, 12),
4420 F_AIF_OSR(12288000, pll4, 4, 1, 8),
4421 F_AIF_OSR(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004422 F_END
4423};
4424
4425#define CLK_AIF_OSR(i, ns, md, h_r) \
4426 struct rcg_clk i##_clk = { \
4427 .b = { \
4428 .ctl_reg = ns, \
4429 .en_mask = BIT(17), \
4430 .reset_reg = ns, \
4431 .reset_mask = BIT(19), \
4432 .halt_reg = h_r, \
4433 .halt_check = ENABLE, \
4434 .halt_bit = 1, \
4435 }, \
4436 .ns_reg = ns, \
4437 .md_reg = md, \
4438 .root_en_mask = BIT(9), \
4439 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4440 .set_rate = set_rate_mnd, \
4441 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004442 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004443 .c = { \
4444 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004445 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004446 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004447 CLK_INIT(i##_clk.c), \
4448 }, \
4449 }
4450#define CLK_AIF_OSR_DIV(i, ns, md, h_r) \
4451 struct rcg_clk i##_clk = { \
4452 .b = { \
4453 .ctl_reg = ns, \
4454 .en_mask = BIT(21), \
4455 .reset_reg = ns, \
4456 .reset_mask = BIT(23), \
4457 .halt_reg = h_r, \
4458 .halt_check = ENABLE, \
4459 .halt_bit = 1, \
4460 }, \
4461 .ns_reg = ns, \
4462 .md_reg = md, \
4463 .root_en_mask = BIT(9), \
4464 .ns_mask = (BM(31, 24) | BM(6, 0)), \
4465 .set_rate = set_rate_mnd, \
4466 .freq_tbl = clk_tbl_aif_osr, \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004467 .current_freq = &rcg_dummy_freq, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004468 .c = { \
4469 .dbg_name = #i "_clk", \
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004470 .ops = &clk_ops_rcg_8960, \
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004471 VDD_DIG_FMAX_MAP1(LOW, 24576000), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004472 CLK_INIT(i##_clk.c), \
4473 }, \
4474 }
4475
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004476#define CLK_AIF_BIT(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004477 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004478 .b = { \
4479 .ctl_reg = ns, \
4480 .en_mask = BIT(15), \
4481 .halt_reg = h_r, \
4482 .halt_check = DELAY, \
4483 }, \
4484 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004485 .ext_mask = BIT(14), \
4486 .div_offset = 10, \
4487 .max_div = 16, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004488 .c = { \
4489 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004490 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004491 CLK_INIT(i##_clk.c), \
4492 }, \
4493 }
4494
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004495#define CLK_AIF_BIT_DIV(i, ns, h_r) \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004496 struct cdiv_clk i##_clk = { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004497 .b = { \
4498 .ctl_reg = ns, \
4499 .en_mask = BIT(19), \
4500 .halt_reg = h_r, \
4501 .halt_check = ENABLE, \
4502 }, \
4503 .ns_reg = ns, \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004504 .ext_mask = BIT(18), \
4505 .div_offset = 10, \
4506 .max_div = 256, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004507 .c = { \
4508 .dbg_name = #i "_clk", \
Stephen Boyd9fd19642011-11-16 11:11:09 -08004509 .ops = &clk_ops_cdiv, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004510 CLK_INIT(i##_clk.c), \
4511 }, \
4512 }
4513
4514static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG,
4515 LCC_MI2S_STATUS_REG);
4516static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG);
4517
4518static CLK_AIF_OSR_DIV(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG,
4519 LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG);
4520static CLK_AIF_BIT_DIV(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG,
4521 LCC_CODEC_I2S_MIC_STATUS_REG);
4522
4523static CLK_AIF_OSR_DIV(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG,
4524 LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG);
4525static CLK_AIF_BIT_DIV(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG,
4526 LCC_SPARE_I2S_MIC_STATUS_REG);
4527
4528static CLK_AIF_OSR_DIV(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG,
4529 LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG);
4530static CLK_AIF_BIT_DIV(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG,
4531 LCC_CODEC_I2S_SPKR_STATUS_REG);
4532
4533static CLK_AIF_OSR_DIV(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG,
4534 LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG);
4535static CLK_AIF_BIT_DIV(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG,
4536 LCC_SPARE_I2S_SPKR_STATUS_REG);
4537
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004538#define F_PCM(f, s, d, m, n) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004539 { \
4540 .freq_hz = f, \
4541 .src_clk = &s##_clk.c, \
4542 .md_val = MD16(m, n), \
4543 .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \
4544 .mnd_en_mask = BIT(8) * !!(n), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004545 }
4546static struct clk_freq_tbl clk_tbl_pcm[] = {
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004547 F_PCM( 0, gnd, 1, 0, 0),
4548 F_PCM( 512000, pll4, 4, 1, 192),
4549 F_PCM( 768000, pll4, 4, 1, 128),
4550 F_PCM( 1024000, pll4, 4, 1, 96),
4551 F_PCM( 1536000, pll4, 4, 1, 64),
4552 F_PCM( 2048000, pll4, 4, 1, 48),
4553 F_PCM( 3072000, pll4, 4, 1, 32),
4554 F_PCM( 4096000, pll4, 4, 1, 24),
4555 F_PCM( 6144000, pll4, 4, 1, 16),
4556 F_PCM( 8192000, pll4, 4, 1, 12),
4557 F_PCM(12288000, pll4, 4, 1, 8),
4558 F_PCM(24576000, pll4, 4, 1, 4),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004559 F_END
4560};
4561
4562static struct rcg_clk pcm_clk = {
4563 .b = {
4564 .ctl_reg = LCC_PCM_NS_REG,
4565 .en_mask = BIT(11),
4566 .reset_reg = LCC_PCM_NS_REG,
4567 .reset_mask = BIT(13),
4568 .halt_reg = LCC_PCM_STATUS_REG,
4569 .halt_check = ENABLE,
4570 .halt_bit = 0,
4571 },
4572 .ns_reg = LCC_PCM_NS_REG,
4573 .md_reg = LCC_PCM_MD_REG,
4574 .root_en_mask = BIT(9),
4575 .ns_mask = (BM(31, 16) | BM(6, 0)),
4576 .set_rate = set_rate_mnd,
4577 .freq_tbl = clk_tbl_pcm,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004578 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004579 .c = {
4580 .dbg_name = "pcm_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004581 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004582 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004583 CLK_INIT(pcm_clk.c),
4584 },
4585};
4586
4587static struct rcg_clk audio_slimbus_clk = {
4588 .b = {
4589 .ctl_reg = LCC_SLIMBUS_NS_REG,
4590 .en_mask = BIT(10),
4591 .reset_reg = LCC_AHBEX_BRANCH_CTL_REG,
4592 .reset_mask = BIT(5),
4593 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4594 .halt_check = ENABLE,
4595 .halt_bit = 0,
4596 },
4597 .ns_reg = LCC_SLIMBUS_NS_REG,
4598 .md_reg = LCC_SLIMBUS_MD_REG,
4599 .root_en_mask = BIT(9),
4600 .ns_mask = (BM(31, 24) | BM(6, 0)),
4601 .set_rate = set_rate_mnd,
4602 .freq_tbl = clk_tbl_aif_osr,
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004603 .current_freq = &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004604 .c = {
4605 .dbg_name = "audio_slimbus_clk",
Matt Wagantall84f43fd2011-08-16 23:28:38 -07004606 .ops = &clk_ops_rcg_8960,
Matt Wagantalle18bbc82011-10-06 10:07:28 -07004607 VDD_DIG_FMAX_MAP1(LOW, 24576000),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004608 CLK_INIT(audio_slimbus_clk.c),
4609 },
4610};
4611
4612static struct branch_clk sps_slimbus_clk = {
4613 .b = {
4614 .ctl_reg = LCC_SLIMBUS_NS_REG,
4615 .en_mask = BIT(12),
4616 .halt_reg = LCC_SLIMBUS_STATUS_REG,
4617 .halt_check = ENABLE,
4618 .halt_bit = 1,
4619 },
4620 .parent = &audio_slimbus_clk.c,
4621 .c = {
4622 .dbg_name = "sps_slimbus_clk",
4623 .ops = &clk_ops_branch,
4624 CLK_INIT(sps_slimbus_clk.c),
4625 },
4626};
4627
4628static struct branch_clk slimbus_xo_src_clk = {
4629 .b = {
4630 .ctl_reg = SLIMBUS_XO_SRC_CLK_CTL_REG,
4631 .en_mask = BIT(2),
4632 .halt_reg = CLK_HALT_DFAB_STATE_REG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004633 .halt_bit = 28,
4634 },
4635 .parent = &sps_slimbus_clk.c,
4636 .c = {
4637 .dbg_name = "slimbus_xo_src_clk",
4638 .ops = &clk_ops_branch,
4639 CLK_INIT(slimbus_xo_src_clk.c),
4640 },
4641};
4642
Matt Wagantall735f01a2011-08-12 12:40:28 -07004643DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC, NULL);
4644DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB, NULL);
4645DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC, NULL);
4646DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1, NULL);
4647DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC, NULL);
4648DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB, NULL);
4649DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC, NULL);
4650DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB, NULL);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004651
4652static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c);
4653static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c);
Manu Gautam7483f172011-11-08 15:22:26 +05304654static DEFINE_CLK_VOTER(dfab_usb_hs3_clk, &dfab_clk.c);
4655static DEFINE_CLK_VOTER(dfab_usb_hs4_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004656static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c);
4657static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c);
4658static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c);
4659static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c);
4660static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c);
4661static DEFINE_CLK_VOTER(dfab_sps_clk, &dfab_clk.c);
Stephen Boyd1c51a492011-10-26 12:11:47 -07004662static DEFINE_CLK_VOTER(dfab_bam_dmux_clk, &dfab_clk.c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004663
4664static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c);
4665/*
4666 * TODO: replace dummy_clk below with ebi1_clk.c once the
4667 * bus driver starts voting on ebi1 rates.
4668 */
4669static DEFINE_CLK_VOTER(ebi1_adm_clk, &dummy_clk);
4670
4671#ifdef CONFIG_DEBUG_FS
4672struct measure_sel {
4673 u32 test_vector;
4674 struct clk *clk;
4675};
4676
Matt Wagantall8b38f942011-08-02 18:23:18 -07004677static DEFINE_CLK_MEASURE(l2_m_clk);
4678static DEFINE_CLK_MEASURE(krait0_m_clk);
4679static DEFINE_CLK_MEASURE(krait1_m_clk);
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004680static DEFINE_CLK_MEASURE(q6sw_clk);
4681static DEFINE_CLK_MEASURE(q6fw_clk);
4682static DEFINE_CLK_MEASURE(q6_func_clk);
Matt Wagantall8b38f942011-08-02 18:23:18 -07004683
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004684static struct measure_sel measure_mux[] = {
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004685 { TEST_PER_LS(0x05), &qdss_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004686 { TEST_PER_LS(0x08), &slimbus_xo_src_clk.c },
4687 { TEST_PER_LS(0x12), &sdc1_p_clk.c },
4688 { TEST_PER_LS(0x13), &sdc1_clk.c },
4689 { TEST_PER_LS(0x14), &sdc2_p_clk.c },
4690 { TEST_PER_LS(0x15), &sdc2_clk.c },
4691 { TEST_PER_LS(0x16), &sdc3_p_clk.c },
4692 { TEST_PER_LS(0x17), &sdc3_clk.c },
4693 { TEST_PER_LS(0x18), &sdc4_p_clk.c },
4694 { TEST_PER_LS(0x19), &sdc4_clk.c },
4695 { TEST_PER_LS(0x1A), &sdc5_p_clk.c },
4696 { TEST_PER_LS(0x1B), &sdc5_clk.c },
Matt Wagantall7625a4c2011-11-01 16:17:53 -07004697 { TEST_PER_LS(0x1F), &gp0_clk.c },
4698 { TEST_PER_LS(0x20), &gp1_clk.c },
4699 { TEST_PER_LS(0x21), &gp2_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004700 { TEST_PER_LS(0x25), &dfab_clk.c },
4701 { TEST_PER_LS(0x25), &dfab_a_clk.c },
4702 { TEST_PER_LS(0x26), &pmem_clk.c },
4703 { TEST_PER_LS(0x32), &dma_bam_p_clk.c },
4704 { TEST_PER_LS(0x33), &cfpb_clk.c },
4705 { TEST_PER_LS(0x33), &cfpb_a_clk.c },
4706 { TEST_PER_LS(0x3D), &gsbi1_p_clk.c },
4707 { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c },
4708 { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c },
4709 { TEST_PER_LS(0x41), &gsbi2_p_clk.c },
4710 { TEST_PER_LS(0x42), &gsbi2_uart_clk.c },
4711 { TEST_PER_LS(0x44), &gsbi2_qup_clk.c },
4712 { TEST_PER_LS(0x45), &gsbi3_p_clk.c },
4713 { TEST_PER_LS(0x46), &gsbi3_uart_clk.c },
4714 { TEST_PER_LS(0x48), &gsbi3_qup_clk.c },
4715 { TEST_PER_LS(0x49), &gsbi4_p_clk.c },
4716 { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c },
4717 { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c },
4718 { TEST_PER_LS(0x4D), &gsbi5_p_clk.c },
4719 { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c },
4720 { TEST_PER_LS(0x50), &gsbi5_qup_clk.c },
4721 { TEST_PER_LS(0x51), &gsbi6_p_clk.c },
4722 { TEST_PER_LS(0x52), &gsbi6_uart_clk.c },
4723 { TEST_PER_LS(0x54), &gsbi6_qup_clk.c },
4724 { TEST_PER_LS(0x55), &gsbi7_p_clk.c },
4725 { TEST_PER_LS(0x56), &gsbi7_uart_clk.c },
4726 { TEST_PER_LS(0x58), &gsbi7_qup_clk.c },
4727 { TEST_PER_LS(0x59), &gsbi8_p_clk.c },
4728 { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c },
4729 { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c },
4730 { TEST_PER_LS(0x5D), &gsbi9_p_clk.c },
4731 { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c },
4732 { TEST_PER_LS(0x60), &gsbi9_qup_clk.c },
4733 { TEST_PER_LS(0x61), &gsbi10_p_clk.c },
4734 { TEST_PER_LS(0x62), &gsbi10_uart_clk.c },
4735 { TEST_PER_LS(0x64), &gsbi10_qup_clk.c },
4736 { TEST_PER_LS(0x65), &gsbi11_p_clk.c },
4737 { TEST_PER_LS(0x66), &gsbi11_uart_clk.c },
4738 { TEST_PER_LS(0x68), &gsbi11_qup_clk.c },
4739 { TEST_PER_LS(0x69), &gsbi12_p_clk.c },
4740 { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c },
4741 { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004742 { TEST_PER_LS(0x5E), &pcie_p_clk.c },
4743 { TEST_PER_LS(0x5F), &ce3_p_clk.c },
4744 { TEST_PER_LS(0x60), &ce3_core_clk.c },
4745 { TEST_PER_LS(0x63), &usb_hs3_p_clk.c },
4746 { TEST_PER_LS(0x64), &usb_hs3_xcvr_clk.c },
4747 { TEST_PER_LS(0x65), &usb_hs4_p_clk.c },
4748 { TEST_PER_LS(0x66), &usb_hs4_xcvr_clk.c },
4749 { TEST_PER_LS(0x6B), &sata_phy_ref_clk.c },
4750 { TEST_PER_LS(0x6C), &sata_phy_cfg_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004751 { TEST_PER_LS(0x78), &sfpb_clk.c },
4752 { TEST_PER_LS(0x78), &sfpb_a_clk.c },
4753 { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c },
4754 { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c },
4755 { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c },
4756 { TEST_PER_LS(0x7D), &prng_clk.c },
4757 { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c },
4758 { TEST_PER_LS(0x80), &adm0_p_clk.c },
4759 { TEST_PER_LS(0x84), &usb_hs1_p_clk.c },
4760 { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004761 { TEST_PER_LS(0x86), &usb_hsic_p_clk.c },
4762 { TEST_PER_LS(0x87), &usb_hsic_system_clk.c },
4763 { TEST_PER_LS(0x88), &usb_hsic_xcvr_fs_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004764 { TEST_PER_LS(0x89), &usb_fs1_p_clk.c },
4765 { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c },
4766 { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c },
4767 { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c },
4768 { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c },
4769 { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c },
4770 { TEST_PER_LS(0x8F), &tsif_p_clk.c },
4771 { TEST_PER_LS(0x91), &tsif_ref_clk.c },
4772 { TEST_PER_LS(0x92), &ce1_p_clk.c },
4773 { TEST_PER_LS(0x94), &tssc_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004774 { TEST_PER_LS(0x9D), &usb_hsic_hsio_cal_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004775 { TEST_PER_LS(0xA4), &ce1_core_clk.c },
4776
4777 { TEST_PER_HS(0x07), &afab_clk.c },
4778 { TEST_PER_HS(0x07), &afab_a_clk.c },
4779 { TEST_PER_HS(0x18), &sfab_clk.c },
4780 { TEST_PER_HS(0x18), &sfab_a_clk.c },
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004781 { TEST_PER_HS(0x26), &q6sw_clk },
4782 { TEST_PER_HS(0x27), &q6fw_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004783 { TEST_PER_HS(0x2A), &adm0_clk.c },
4784 { TEST_PER_HS(0x34), &ebi1_clk.c },
4785 { TEST_PER_HS(0x34), &ebi1_a_clk.c },
Stephen Boyd973e4ba2011-07-12 17:06:01 -07004786 { TEST_PER_HS(0x48), &qdss_at_clk.c },
4787 { TEST_PER_HS(0x49), &qdss_pclkdbg_clk.c },
4788 { TEST_PER_HS(0x4A), &qdss_traceclkin_clk.c },
4789 { TEST_PER_HS(0x4B), &qdss_tsctr_clk.c },
4790 { TEST_PER_HS(0x4F), &qdss_stm_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004791 { TEST_PER_HS(0x50), &usb_hsic_hsic_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004792
4793 { TEST_MM_LS(0x00), &dsi1_byte_clk.c },
4794 { TEST_MM_LS(0x01), &dsi2_byte_clk.c },
4795 { TEST_MM_LS(0x02), &cam1_clk.c },
4796 { TEST_MM_LS(0x06), &amp_p_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004797 { TEST_MM_LS(0x07), &csi_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004798 { TEST_MM_LS(0x08), &dsi2_s_p_clk.c },
4799 { TEST_MM_LS(0x09), &dsi1_m_p_clk.c },
4800 { TEST_MM_LS(0x0A), &dsi1_s_p_clk.c },
4801 { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c },
4802 { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c },
4803 { TEST_MM_LS(0x0E), &gfx3d_p_clk.c },
4804 { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c },
4805 { TEST_MM_LS(0x10), &hdmi_s_p_clk.c },
4806 { TEST_MM_LS(0x11), &ijpeg_p_clk.c },
4807 { TEST_MM_LS(0x12), &imem_p_clk.c },
4808 { TEST_MM_LS(0x13), &jpegd_p_clk.c },
4809 { TEST_MM_LS(0x14), &mdp_p_clk.c },
4810 { TEST_MM_LS(0x16), &rot_p_clk.c },
4811 { TEST_MM_LS(0x17), &dsi1_esc_clk.c },
4812 { TEST_MM_LS(0x18), &smmu_p_clk.c },
4813 { TEST_MM_LS(0x19), &tv_enc_p_clk.c },
4814 { TEST_MM_LS(0x1A), &vcodec_p_clk.c },
4815 { TEST_MM_LS(0x1B), &vfe_p_clk.c },
4816 { TEST_MM_LS(0x1C), &vpe_p_clk.c },
4817 { TEST_MM_LS(0x1D), &cam0_clk.c },
4818 { TEST_MM_LS(0x1F), &hdmi_app_clk.c },
4819 { TEST_MM_LS(0x20), &mdp_vsync_clk.c },
4820 { TEST_MM_LS(0x21), &tv_dac_clk.c },
4821 { TEST_MM_LS(0x22), &tv_enc_clk.c },
4822 { TEST_MM_LS(0x23), &dsi2_esc_clk.c },
4823 { TEST_MM_LS(0x25), &mmfpb_clk.c },
4824 { TEST_MM_LS(0x25), &mmfpb_a_clk.c },
4825 { TEST_MM_LS(0x26), &dsi2_m_p_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004826 { TEST_MM_LS(0x27), &cam2_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004827 { TEST_MM_LS(0x28), &vcap_p_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004828
4829 { TEST_MM_HS(0x00), &csi0_clk.c },
4830 { TEST_MM_HS(0x01), &csi1_clk.c },
Matt Wagantallc23eee92011-08-16 23:06:52 -07004831 { TEST_MM_HS(0x04), &csi_vfe_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004832 { TEST_MM_HS(0x05), &ijpeg_clk.c },
4833 { TEST_MM_HS(0x06), &vfe_clk.c },
4834 { TEST_MM_HS(0x07), &gfx2d0_clk.c },
4835 { TEST_MM_HS(0x08), &gfx2d1_clk.c },
4836 { TEST_MM_HS(0x09), &gfx3d_clk.c },
4837 { TEST_MM_HS(0x0A), &jpegd_clk.c },
4838 { TEST_MM_HS(0x0B), &vcodec_clk.c },
4839 { TEST_MM_HS(0x0F), &mmfab_clk.c },
4840 { TEST_MM_HS(0x0F), &mmfab_a_clk.c },
4841 { TEST_MM_HS(0x11), &gmem_axi_clk.c },
4842 { TEST_MM_HS(0x12), &ijpeg_axi_clk.c },
4843 { TEST_MM_HS(0x13), &imem_axi_clk.c },
4844 { TEST_MM_HS(0x14), &jpegd_axi_clk.c },
4845 { TEST_MM_HS(0x15), &mdp_axi_clk.c },
4846 { TEST_MM_HS(0x16), &rot_axi_clk.c },
4847 { TEST_MM_HS(0x17), &vcodec_axi_clk.c },
4848 { TEST_MM_HS(0x18), &vfe_axi_clk.c },
4849 { TEST_MM_HS(0x19), &vpe_axi_clk.c },
4850 { TEST_MM_HS(0x1A), &mdp_clk.c },
4851 { TEST_MM_HS(0x1B), &rot_clk.c },
4852 { TEST_MM_HS(0x1C), &vpe_clk.c },
4853 { TEST_MM_HS(0x1E), &hdmi_tv_clk.c },
4854 { TEST_MM_HS(0x1F), &mdp_tv_clk.c },
4855 { TEST_MM_HS(0x24), &csi0_phy_clk.c },
4856 { TEST_MM_HS(0x25), &csi1_phy_clk.c },
4857 { TEST_MM_HS(0x26), &csi_pix_clk.c },
4858 { TEST_MM_HS(0x27), &csi_rdi_clk.c },
4859 { TEST_MM_HS(0x28), &lut_mdp_clk.c },
4860 { TEST_MM_HS(0x29), &vcodec_axi_a_clk.c },
4861 { TEST_MM_HS(0x2A), &vcodec_axi_b_clk.c },
4862 { TEST_MM_HS(0x2B), &csi1phy_timer_clk.c },
4863 { TEST_MM_HS(0x2C), &csi0phy_timer_clk.c },
Stephen Boyd94625ef2011-07-12 17:06:01 -07004864 { TEST_MM_HS(0x2D), &csi2_clk.c },
4865 { TEST_MM_HS(0x2E), &csi2_phy_clk.c },
4866 { TEST_MM_HS(0x2F), &csi2phy_timer_clk.c },
4867 { TEST_MM_HS(0x30), &csi_pix1_clk.c },
4868 { TEST_MM_HS(0x31), &csi_rdi1_clk.c },
4869 { TEST_MM_HS(0x32), &csi_rdi2_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004870 { TEST_MM_HS(0x33), &vcap_clk.c },
4871 { TEST_MM_HS(0x34), &vcap_npl_clk.c },
Tianyi Gou41515e22011-09-01 19:37:43 -07004872 { TEST_MM_HS(0x36), &vcap_axi_clk.c },
Tianyi Gou621f8742011-09-01 21:45:01 -07004873 { TEST_MM_HS(0x39), &gfx3d_axi_clk.c },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004874
4875 { TEST_LPA(0x0F), &mi2s_bit_clk.c },
4876 { TEST_LPA(0x10), &codec_i2s_mic_bit_clk.c },
4877 { TEST_LPA(0x11), &codec_i2s_spkr_bit_clk.c },
4878 { TEST_LPA(0x12), &spare_i2s_mic_bit_clk.c },
4879 { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c },
4880 { TEST_LPA(0x14), &pcm_clk.c },
4881 { TEST_LPA(0x1D), &audio_slimbus_clk.c },
Matt Wagantall8b38f942011-08-02 18:23:18 -07004882
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004883 { TEST_LPA_HS(0x00), &q6_func_clk },
4884
Stephen Boyd46fdf0d2011-11-22 12:25:09 -08004885 { TEST_CPUL2(0x2), &l2_m_clk },
4886 { TEST_CPUL2(0x0), &krait0_m_clk },
4887 { TEST_CPUL2(0x1), &krait1_m_clk },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004888};
4889
4890static struct measure_sel *find_measure_sel(struct clk *clk)
4891{
4892 int i;
4893
4894 for (i = 0; i < ARRAY_SIZE(measure_mux); i++)
4895 if (measure_mux[i].clk == clk)
4896 return &measure_mux[i];
4897 return NULL;
4898}
4899
Matt Wagantall8b38f942011-08-02 18:23:18 -07004900static int measure_clk_set_parent(struct clk *c, struct clk *parent)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004901{
4902 int ret = 0;
4903 u32 clk_sel;
4904 struct measure_sel *p;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004905 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004906 unsigned long flags;
4907
4908 if (!parent)
4909 return -EINVAL;
4910
4911 p = find_measure_sel(parent);
4912 if (!p)
4913 return -EINVAL;
4914
4915 spin_lock_irqsave(&local_clock_reg_lock, flags);
4916
Matt Wagantall8b38f942011-08-02 18:23:18 -07004917 /*
4918 * Program the test vector, measurement period (sample_ticks)
4919 * and scaling multiplier.
4920 */
4921 clk->sample_ticks = 0x10000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004922 clk_sel = p->test_vector & TEST_CLK_SEL_MASK;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004923 clk->multiplier = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004924 switch (p->test_vector >> TEST_TYPE_SHIFT) {
4925 case TEST_TYPE_PER_LS:
4926 writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG);
4927 break;
4928 case TEST_TYPE_PER_HS:
4929 writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG);
4930 break;
4931 case TEST_TYPE_MM_LS:
4932 writel_relaxed(0x4030D97, CLK_TEST_REG);
4933 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG);
4934 break;
4935 case TEST_TYPE_MM_HS:
4936 writel_relaxed(0x402B800, CLK_TEST_REG);
4937 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG);
4938 break;
4939 case TEST_TYPE_LPA:
4940 writel_relaxed(0x4030D98, CLK_TEST_REG);
4941 writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0),
4942 LCC_CLK_LS_DEBUG_CFG_REG);
4943 break;
Stephen Boyd3939c8d2011-08-29 17:36:22 -07004944 case TEST_TYPE_LPA_HS:
4945 writel_relaxed(0x402BC00, CLK_TEST_REG);
4946 writel_relaxed(BVAL(2, 1, clk_sel)|BIT(0),
4947 LCC_CLK_HS_DEBUG_CFG_REG);
4948 break;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004949 case TEST_TYPE_CPUL2:
4950 writel_relaxed(0x4030400, CLK_TEST_REG);
4951 writel_relaxed(0x80|BVAL(5, 3, clk_sel), GCC_APCS_CLK_DIAG);
4952 clk->sample_ticks = 0x4000;
4953 clk->multiplier = 2;
4954 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004955 default:
4956 ret = -EPERM;
4957 }
4958 /* Make sure test vector is set before starting measurements. */
4959 mb();
4960
4961 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
4962
4963 return ret;
4964}
4965
4966/* Sample clock for 'ticks' reference clock ticks. */
4967static u32 run_measurement(unsigned ticks)
4968{
4969 /* Stop counters and set the XO4 counter start value. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004970 writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG);
4971
4972 /* Wait for timer to become ready. */
4973 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0)
4974 cpu_relax();
4975
4976 /* Run measurement and wait for completion. */
4977 writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG);
4978 while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0)
4979 cpu_relax();
4980
4981 /* Stop counters. */
4982 writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG);
4983
4984 /* Return measured ticks. */
4985 return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0);
4986}
4987
4988
4989/* Perform a hardware rate measurement for a given clock.
4990 FOR DEBUG USE ONLY: Measurements take ~15 ms! */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07004991static unsigned long measure_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004992{
4993 unsigned long flags;
4994 u32 pdm_reg_backup, ringosc_reg_backup;
4995 u64 raw_count_short, raw_count_full;
Matt Wagantall8b38f942011-08-02 18:23:18 -07004996 struct measure_clk *clk = to_measure_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004997 unsigned ret;
4998
4999 spin_lock_irqsave(&local_clock_reg_lock, flags);
5000
5001 /* Enable CXO/4 and RINGOSC branch and root. */
5002 pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG);
5003 ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG);
5004 writel_relaxed(0x2898, PDM_CLK_NS_REG);
5005 writel_relaxed(0xA00, RINGOSC_NS_REG);
5006
5007 /*
5008 * The ring oscillator counter will not reset if the measured clock
5009 * is not running. To detect this, run a short measurement before
5010 * the full measurement. If the raw results of the two are the same
5011 * then the clock must be off.
5012 */
5013
5014 /* Run a short measurement. (~1 ms) */
5015 raw_count_short = run_measurement(0x1000);
5016 /* Run a full measurement. (~14 ms) */
Matt Wagantall8b38f942011-08-02 18:23:18 -07005017 raw_count_full = run_measurement(clk->sample_ticks);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005018
5019 writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG);
5020 writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG);
5021
5022 /* Return 0 if the clock is off. */
5023 if (raw_count_full == raw_count_short)
5024 ret = 0;
5025 else {
5026 /* Compute rate in Hz. */
5027 raw_count_full = ((raw_count_full * 10) + 15) * 4800000;
Matt Wagantall8b38f942011-08-02 18:23:18 -07005028 do_div(raw_count_full, ((clk->sample_ticks * 10) + 35));
5029 ret = (raw_count_full * clk->multiplier);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005030 }
5031
5032 /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */
Stephen Boyd69da8402011-07-14 17:45:31 -07005033 writel_relaxed(0x38F8, PLLTEST_PAD_CFG_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005034 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
5035
5036 return ret;
5037}
5038#else /* !CONFIG_DEBUG_FS */
5039static int measure_clk_set_parent(struct clk *clk, struct clk *parent)
5040{
5041 return -EINVAL;
5042}
5043
Matt Wagantall9de3bfb2011-11-03 20:13:12 -07005044static unsigned long measure_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005045{
5046 return 0;
5047}
5048#endif /* CONFIG_DEBUG_FS */
5049
5050static struct clk_ops measure_clk_ops = {
5051 .set_parent = measure_clk_set_parent,
5052 .get_rate = measure_clk_get_rate,
5053 .is_local = local_clk_is_local,
5054};
5055
Matt Wagantall8b38f942011-08-02 18:23:18 -07005056static struct measure_clk measure_clk = {
5057 .c = {
5058 .dbg_name = "measure_clk",
5059 .ops = &measure_clk_ops,
5060 CLK_INIT(measure_clk.c),
5061 },
5062 .multiplier = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005063};
5064
Tianyi Goua8b3cce2011-11-08 14:37:26 -08005065static struct clk_lookup msm_clocks_8064[] = {
Tianyi Gou41515e22011-09-01 19:37:43 -07005066 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005067 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005068 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
Tianyi Gouc29c3242011-10-12 21:02:15 -07005069 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005070 CLK_LOOKUP("measure", measure_clk.c, "debug"),
5071
Matt Wagantallb2710b82011-11-16 19:55:17 -08005072 CLK_DUMMY("bus_clk", AFAB_CLK, "msm_apps_fab", 0),
5073 CLK_DUMMY("bus_a_clk", AFAB_A_CLK, "msm_apps_fab", 0),
5074 CLK_DUMMY("bus_clk", SFAB_CLK, "msm_sys_fab", 0),
5075 CLK_DUMMY("bus_a_clk", SFAB_A_CLK, "msm_sys_fab", 0),
5076 CLK_DUMMY("bus_clk", SFPB_CLK, "msm_sys_fpb", 0),
5077 CLK_DUMMY("bus_a_clk", SFPB_A_CLK, "msm_sys_fpb", 0),
5078 CLK_DUMMY("bus_clk", MMFAB_CLK, "msm_mm_fab", 0),
5079 CLK_DUMMY("bus_a_clk", MMFAB_A_CLK, "msm_mm_fab", 0),
5080 CLK_DUMMY("bus_clk", CFPB_CLK, "msm_cpss_fpb", 0),
5081 CLK_DUMMY("bus_a_clk", CFPB_A_CLK, "msm_cpss_fpb", 0),
5082 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
5083 CLK_DUMMY("mem_a_clk", EBI1_A_CLK, "msm_bus", 0),
5084
5085 CLK_DUMMY("ebi1_clk", EBI1_CLK, NULL, 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005086 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
5087 CLK_DUMMY("dfab_a_clk", DFAB_A_CLK, NULL, 0),
Matt Wagantallb2710b82011-11-16 19:55:17 -08005088 CLK_DUMMY("bus_clk", MMFPB_CLK, NULL, 0),
5089 CLK_DUMMY("bus_a_clk", MMFPB_A_CLK, NULL, 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005090
Matt Wagantall7625a4c2011-11-01 16:17:53 -07005091 CLK_LOOKUP("core_clk", gp0_clk.c, NULL),
5092 CLK_LOOKUP("core_clk", gp1_clk.c, NULL),
5093 CLK_LOOKUP("core_clk", gp2_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005094 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
5095 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
5096 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
5097 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
5098 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, NULL),
5099 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, NULL),
5100 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
5101 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, NULL),
5102 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
5103 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, NULL),
5104 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, NULL),
5105 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
5106 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
5107 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005108 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005109 CLK_LOOKUP("pmem_clk", pmem_clk.c, NULL),
Ramesh Masavarapuf46be1b2011-11-03 11:13:41 -07005110 CLK_DUMMY("core_clk", PRNG_CLK, "msm_rng.0", OFF),
Tianyi Gou43208a02011-09-27 15:35:13 -07005111 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5112 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5113 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5114 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005115 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
5116 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005117 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
Manu Gautam7483f172011-11-08 15:22:26 +05305118 CLK_LOOKUP("core_clk", usb_hs3_xcvr_clk.c, "msm_ehci_host.0"),
5119 CLK_LOOKUP("core_clk", usb_hs4_xcvr_clk.c, "msm_ehci_host.1"),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005120 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
5121 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
5122 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005123 CLK_LOOKUP("iface_clk", ce1_p_clk.c, NULL),
5124 CLK_LOOKUP("core_clk", ce1_core_clk.c, NULL),
Ramesh Masavarapu28311912011-10-27 11:04:12 -07005125 CLK_LOOKUP("ref_clk", sata_phy_ref_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005126 CLK_LOOKUP("cfg_clk", sata_phy_cfg_clk.c, NULL),
Ramesh Masavarapu28311912011-10-27 11:04:12 -07005127 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qce.0"),
5128 CLK_LOOKUP("iface_clk", ce3_p_clk.c, "qcrypto.0"),
5129 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qce.0"),
5130 CLK_LOOKUP("core_clk", ce3_core_clk.c, "qcrypto.0"),
5131 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qce.0"),
5132 CLK_LOOKUP("ce3_core_src_clk", ce3_src_clk.c, "qcrypto.0"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005133 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
5134 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, NULL),
5135 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
5136 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, NULL),
5137 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, NULL),
5138 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, NULL),
5139 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, NULL),
5140 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005141 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Tianyi Gou4496fba2011-10-12 11:40:15 -07005142 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5143 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Manu Gautam7483f172011-11-08 15:22:26 +05305144 CLK_LOOKUP("iface_clk", usb_hs3_p_clk.c, "msm_ehci_host.0"),
5145 CLK_LOOKUP("iface_clk", usb_hs4_p_clk.c, "msm_ehci_host.1"),
Tianyi Gou43208a02011-09-27 15:35:13 -07005146 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5147 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5148 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5149 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005150 CLK_LOOKUP("iface_clk", pcie_p_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005151 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5152 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005153 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
5154 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
5155 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
5156 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
5157 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005158 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5159 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
5160 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5161 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5162 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005163 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005164 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5165 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, NULL),
5166 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005167 CLK_LOOKUP("csi_clk", csi0_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005168 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5169 CLK_LOOKUP("csi_clk", csi1_clk.c, NULL),
5170 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005171 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005172 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5173 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, NULL),
5174 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005175 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, NULL),
5176 CLK_LOOKUP("csi_pix_clk", csi_pix1_clk.c, NULL),
5177 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, NULL),
5178 CLK_LOOKUP("csi_rdi_clk", csi_rdi1_clk.c, NULL),
5179 CLK_LOOKUP("csi_rdi_clk", csi_rdi2_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005180 CLK_LOOKUP("csiphy_timer_src_clk", csiphy_timer_src_clk.c, NULL),
5181 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, NULL),
5182 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, NULL),
5183 CLK_LOOKUP("csiphy_timer_clk", csi2phy_timer_clk.c, NULL),
5184 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5185 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5186 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5187 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
5188 CLK_DUMMY("rgb_tv_clk", RGB_TV_CLK, NULL, OFF),
5189 CLK_DUMMY("npl_tv_clk", NPL_TV_CLK, NULL, OFF),
Pu Chen86b4be92011-11-03 17:27:57 -07005190 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005191 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5192 CLK_LOOKUP("bus_clk", gfx3d_axi_clk.c, "footswitch-8x60.2"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005193 CLK_LOOKUP("iface_clk", vcap_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005194 CLK_LOOKUP("iface_clk", vcap_p_clk.c, "footswitch-8x60.10"),
5195 CLK_LOOKUP("bus_clk", vcap_axi_clk.c, "footswitch-8x60.10"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005196 CLK_LOOKUP("core_clk", vcap_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005197 CLK_LOOKUP("core_clk", vcap_clk.c, "footswitch-8x60.10"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005198 CLK_LOOKUP("vcap_npl_clk", vcap_npl_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005199 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005200 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
5201 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005202 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005203 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005204 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005205 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005206 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
5207 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005208 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005209 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005210 CLK_DUMMY("tv_src_clk", TV_SRC_CLK, NULL, OFF),
Greg Griscofa47b532011-11-11 10:32:06 -08005211 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005212 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005213 CLK_DUMMY("mdp_tv_clk", MDP_TV_CLK, NULL, OFF),
5214 CLK_DUMMY("hdmi_clk", HDMI_TV_CLK, NULL, OFF),
Tianyi Gou621f8742011-09-01 21:45:01 -07005215 CLK_LOOKUP("core_clk", hdmi_app_clk.c, NULL),
5216 CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005217 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005218 CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005219 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005220 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005221 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5222 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5223 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5224 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5225 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5226 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5227 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005228 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
5229 CLK_LOOKUP("csi_pclk", csi_p_clk.c, NULL),
5230 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5231 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5232 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5233 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Pu Chen86b4be92011-11-03 17:27:57 -07005234 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005235 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005236 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, NULL),
5237 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, NULL),
5238 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005239 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005240 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
5241 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005242 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005243 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005244 CLK_LOOKUP("iface_clk", smmu_p_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005245 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005246 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Greg Griscofa47b532011-11-11 10:32:06 -08005247 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005248 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005249 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005250 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Tianyi Gou621f8742011-09-01 21:45:01 -07005251 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL),
Matt Wagantallc9a780c2011-10-28 12:12:18 -07005252 CLK_LOOKUP("iface_pclk", vpe_p_clk.c, "footswitch-8x60.9"),
Tianyi Gouc29c3242011-10-12 21:02:15 -07005253 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5254 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5255 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5256 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5257 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5258 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5259 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5260 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5261 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5262 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5263 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
Tianyi Goudd8138a2011-10-20 15:46:00 -07005264 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5265 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Tianyi Gou621f8742011-09-01 21:45:01 -07005266 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, NULL),
5267 CLK_LOOKUP("core_clk", vpe_axi_clk.c, NULL),
5268 CLK_LOOKUP("core_clk", mdp_axi_clk.c, NULL),
5269 CLK_LOOKUP("core_clk", vcap_axi_clk.c, NULL),
5270 CLK_LOOKUP("core_clk", rot_axi_clk.c, NULL),
5271 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, NULL),
5272 CLK_LOOKUP("core_clk", vfe_axi_clk.c, NULL),
5273 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, NULL),
5274 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, NULL),
Tianyi Gou0c50fe32011-10-19 15:50:35 -07005275 CLK_LOOKUP("core_clk", gfx3d_axi_clk.c, NULL),
Tianyi Gou41515e22011-09-01 19:37:43 -07005276 CLK_DUMMY("dfab_dsps_clk", DFAB_DSPS_CLK, NULL, 0),
5277 CLK_DUMMY("dfab_usb_hs_clk", DFAB_USB_HS_CLK, NULL, 0),
Manu Gautam7483f172011-11-08 15:22:26 +05305278 CLK_DUMMY("bus_clk", DFAB_USB_HS3_CLK, "msm_ehci_host.0", 0),
5279 CLK_DUMMY("bus_clk", DFAB_USB_HS4_CLK, "msm_ehci_host.1", 0),
Tianyi Gou41515e22011-09-01 19:37:43 -07005280 CLK_DUMMY("bus_clk", DFAB_SDC1_CLK, NULL, 0),
5281 CLK_DUMMY("bus_clk", DFAB_SDC2_CLK, NULL, 0),
5282 CLK_DUMMY("bus_clk", DFAB_SDC3_CLK, NULL, 0),
5283 CLK_DUMMY("bus_clk", DFAB_SDC4_CLK, NULL, 0),
5284 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
5285 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5286 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5287 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5288 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5289 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5290
Jeff Ohlstein8c116c72011-10-27 17:34:48 -07005291 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Tianyi Gou41515e22011-09-01 19:37:43 -07005292
5293 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5294 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5295 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
5296};
5297
Stephen Boyd94625ef2011-07-12 17:06:01 -07005298static struct clk_lookup msm_clocks_8960_v1[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005299 CLK_LOOKUP("cxo", cxo_clk.c, NULL),
5300 CLK_LOOKUP("pll2", pll2_clk.c, NULL),
5301 CLK_LOOKUP("pll8", pll8_clk.c, NULL),
5302 CLK_LOOKUP("pll4", pll4_clk.c, NULL),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005303 CLK_LOOKUP("measure", measure_clk.c, "debug"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005304
Matt Wagantallb2710b82011-11-16 19:55:17 -08005305 CLK_LOOKUP("bus_clk", afab_clk.c, "msm_apps_fab"),
5306 CLK_LOOKUP("bus_a_clk", afab_a_clk.c, "msm_apps_fab"),
5307 CLK_LOOKUP("bus_clk", cfpb_clk.c, "msm_cpss_fpb"),
5308 CLK_LOOKUP("bus_a_clk", cfpb_a_clk.c, "msm_cpss_fpb"),
5309 CLK_LOOKUP("bus_clk", sfab_clk.c, "msm_sys_fab"),
5310 CLK_LOOKUP("bus_a_clk", sfab_a_clk.c, "msm_sys_fab"),
5311 CLK_LOOKUP("bus_clk", sfpb_clk.c, "msm_sys_fpb"),
5312 CLK_LOOKUP("bus_a_clk", sfpb_a_clk.c, "msm_sys_fpb"),
5313 CLK_LOOKUP("bus_clk", mmfab_clk.c, "msm_mm_fab"),
5314 CLK_LOOKUP("bus_a_clk", mmfab_a_clk.c, "msm_mm_fab"),
5315 CLK_LOOKUP("mem_clk", ebi1_msmbus_clk.c, "msm_bus"),
5316 CLK_LOOKUP("mem_a_clk", ebi1_a_clk.c, "msm_bus"),
5317
5318 CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL),
5319 CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL),
5320 CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL),
5321 CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL),
5322 CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, "clock-8960"),
5323 CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, "clock-8960"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005324
Matt Wagantall7625a4c2011-11-01 16:17:53 -07005325 CLK_LOOKUP("core_clk", gp0_clk.c, NULL),
5326 CLK_LOOKUP("core_clk", gp1_clk.c, NULL),
5327 CLK_LOOKUP("core_clk", gp2_clk.c, NULL),
Matt Wagantalle2522372011-08-17 14:52:21 -07005328 CLK_LOOKUP("core_clk", gsbi1_uart_clk.c, NULL),
5329 CLK_LOOKUP("core_clk", gsbi2_uart_clk.c, NULL),
5330 CLK_LOOKUP("core_clk", gsbi3_uart_clk.c, NULL),
5331 CLK_LOOKUP("core_clk", gsbi4_uart_clk.c, NULL),
5332 CLK_LOOKUP("core_clk", gsbi5_uart_clk.c, "msm_serial_hsl.0"),
5333 CLK_LOOKUP("core_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"),
5334 CLK_LOOKUP("core_clk", gsbi7_uart_clk.c, NULL),
5335 CLK_LOOKUP("core_clk", gsbi8_uart_clk.c, NULL),
5336 CLK_LOOKUP("core_clk", gsbi9_uart_clk.c, NULL),
5337 CLK_LOOKUP("core_clk", gsbi10_uart_clk.c, NULL),
5338 CLK_LOOKUP("core_clk", gsbi11_uart_clk.c, NULL),
5339 CLK_LOOKUP("core_clk", gsbi12_uart_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005340 CLK_LOOKUP("core_clk", gsbi1_qup_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005341 CLK_LOOKUP("core_clk", gsbi2_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005342 CLK_LOOKUP("core_clk", gsbi3_qup_clk.c, "qup_i2c.3"),
5343 CLK_LOOKUP("core_clk", gsbi4_qup_clk.c, "qup_i2c.4"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005344 CLK_LOOKUP("core_clk", gsbi5_qup_clk.c, NULL),
5345 CLK_LOOKUP("core_clk", gsbi6_qup_clk.c, NULL),
5346 CLK_LOOKUP("core_clk", gsbi7_qup_clk.c, NULL),
5347 CLK_LOOKUP("core_clk", gsbi8_qup_clk.c, NULL),
5348 CLK_LOOKUP("core_clk", gsbi9_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005349 CLK_LOOKUP("core_clk", gsbi10_qup_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005350 CLK_LOOKUP("core_clk", gsbi11_qup_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005351 CLK_LOOKUP("core_clk", gsbi12_qup_clk.c, "qup_i2c.12"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005352 CLK_LOOKUP("core_clk", pdm_clk.c, NULL),
Vikram Mulukutladd0a2372011-09-19 15:58:21 -07005353 CLK_LOOKUP("mem_clk", pmem_clk.c, "msm_sps"),
Matt Wagantallc1205292011-08-11 17:19:31 -07005354 CLK_LOOKUP("core_clk", prng_clk.c, "msm_rng.0"),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005355 CLK_LOOKUP("core_clk", sdc1_clk.c, "msm_sdcc.1"),
5356 CLK_LOOKUP("core_clk", sdc2_clk.c, "msm_sdcc.2"),
5357 CLK_LOOKUP("core_clk", sdc3_clk.c, "msm_sdcc.3"),
5358 CLK_LOOKUP("core_clk", sdc4_clk.c, "msm_sdcc.4"),
5359 CLK_LOOKUP("core_clk", sdc5_clk.c, "msm_sdcc.5"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005360 CLK_LOOKUP("slimbus_xo_src_clk", slimbus_xo_src_clk.c, NULL),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005361 CLK_LOOKUP("ref_clk", tsif_ref_clk.c, NULL),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005362 CLK_LOOKUP("core_clk", tssc_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005363 CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL),
5364 CLK_LOOKUP("usb_phy_clk", usb_phy0_clk.c, NULL),
5365 CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL),
5366 CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL),
5367 CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL),
5368 CLK_LOOKUP("usb_fs_clk", usb_fs2_xcvr_clk.c, NULL),
5369 CLK_LOOKUP("usb_fs_sys_clk", usb_fs2_sys_clk.c, NULL),
5370 CLK_LOOKUP("usb_fs_src_clk", usb_fs2_src_clk.c, NULL),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005371 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005372 CLK_LOOKUP("iface_clk", ce1_p_clk.c, "qcrypto.0"),
Matt Wagantallc4b3a4d2011-08-17 16:58:39 -07005373 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qce.0"),
Matt Wagantalle0b11452011-09-13 17:25:33 -07005374 CLK_LOOKUP("core_clk", ce1_core_clk.c, "qcrypto.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005375 CLK_LOOKUP("dma_bam_pclk", dma_bam_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005376 CLK_LOOKUP("iface_clk", gsbi1_p_clk.c, "spi_qsd.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005377 CLK_LOOKUP("iface_clk", gsbi2_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005378 CLK_LOOKUP("iface_clk", gsbi3_p_clk.c, "qup_i2c.3"),
5379 CLK_LOOKUP("iface_clk", gsbi4_p_clk.c, "qup_i2c.4"),
Matt Wagantalle2522372011-08-17 14:52:21 -07005380 CLK_LOOKUP("iface_clk", gsbi5_p_clk.c, "msm_serial_hsl.0"),
5381 CLK_LOOKUP("iface_clk", gsbi6_p_clk.c, "msm_serial_hs.0"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005382 CLK_LOOKUP("iface_clk", gsbi7_p_clk.c, NULL),
5383 CLK_LOOKUP("iface_clk", gsbi8_p_clk.c, NULL),
5384 CLK_LOOKUP("iface_clk", gsbi9_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005385 CLK_LOOKUP("iface_clk", gsbi10_p_clk.c, "qup_i2c.10"),
Matt Wagantall62cf63e2011-08-17 16:34:47 -07005386 CLK_LOOKUP("iface_clk", gsbi11_p_clk.c, NULL),
Matt Wagantallac294852011-08-17 15:44:58 -07005387 CLK_LOOKUP("iface_clk", gsbi12_p_clk.c, "qup_i2c.12"),
Matt Wagantall640e5fd2011-08-17 16:08:53 -07005388 CLK_LOOKUP("iface_clk", tsif_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005389 CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL),
5390 CLK_LOOKUP("usb_fs_pclk", usb_fs2_p_clk.c, NULL),
5391 CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005392 CLK_LOOKUP("iface_clk", sdc1_p_clk.c, "msm_sdcc.1"),
5393 CLK_LOOKUP("iface_clk", sdc2_p_clk.c, "msm_sdcc.2"),
5394 CLK_LOOKUP("iface_clk", sdc3_p_clk.c, "msm_sdcc.3"),
5395 CLK_LOOKUP("iface_clk", sdc4_p_clk.c, "msm_sdcc.4"),
5396 CLK_LOOKUP("iface_clk", sdc5_p_clk.c, "msm_sdcc.5"),
Matt Wagantalle1a86062011-08-18 17:46:10 -07005397 CLK_LOOKUP("core_clk", adm0_clk.c, "msm_dmov"),
5398 CLK_LOOKUP("iface_clk", adm0_p_clk.c, "msm_dmov"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005399 CLK_LOOKUP("iface_clk", pmic_arb0_p_clk.c, NULL),
5400 CLK_LOOKUP("iface_clk", pmic_arb1_p_clk.c, NULL),
5401 CLK_LOOKUP("core_clk", pmic_ssbi2_clk.c, NULL),
5402 CLK_LOOKUP("mem_clk", rpm_msg_ram_p_clk.c, NULL),
5403 CLK_LOOKUP("core_clk", amp_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005404 CLK_LOOKUP("cam_clk", cam0_clk.c, NULL),
5405 CLK_LOOKUP("cam_clk", cam1_clk.c, NULL),
5406 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_imx074.0"),
Rajakumar Govindaram6bc004a2011-12-05 20:58:19 -08005407 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_mt9m114.0"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005408 CLK_LOOKUP("cam_clk", cam0_clk.c, "msm_camera_ov2720.0"),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005409 CLK_LOOKUP("csi_src_clk", csi0_src_clk.c, "msm_csid.0"),
5410 CLK_LOOKUP("csi_src_clk", csi1_src_clk.c, "msm_csid.1"),
5411 CLK_LOOKUP("csi_clk", csi0_clk.c, "msm_csid.0"),
5412 CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_csid.1"),
5413 CLK_LOOKUP("csi_phy_clk", csi0_phy_clk.c, "msm_csid.0"),
5414 CLK_LOOKUP("csi_phy_clk", csi1_phy_clk.c, "msm_csid.1"),
Kevin Chane12c6672011-10-26 11:55:26 -07005415 CLK_LOOKUP("csi_pix_clk", csi_pix_clk.c, "msm_ispif.0"),
5416 CLK_LOOKUP("csi_rdi_clk", csi_rdi_clk.c, "msm_ispif.0"),
Kevin Chanf6216f22011-10-25 18:40:11 -07005417 CLK_LOOKUP("csiphy_timer_src_clk",
5418 csiphy_timer_src_clk.c, "msm_csiphy.0"),
5419 CLK_LOOKUP("csiphy_timer_src_clk",
5420 csiphy_timer_src_clk.c, "msm_csiphy.1"),
5421 CLK_LOOKUP("csiphy_timer_clk", csi0phy_timer_clk.c, "msm_csiphy.0"),
5422 CLK_LOOKUP("csiphy_timer_clk", csi1phy_timer_clk.c, "msm_csiphy.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005423 CLK_LOOKUP("dsi_byte_div_clk", dsi1_byte_clk.c, NULL),
5424 CLK_LOOKUP("dsi_byte_div_clk", dsi2_byte_clk.c, NULL),
5425 CLK_LOOKUP("dsi_esc_clk", dsi1_esc_clk.c, NULL),
5426 CLK_LOOKUP("dsi_esc_clk", dsi2_esc_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005427 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005428 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005429 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005430 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005431 CLK_LOOKUP("core_clk", gfx3d_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005432 CLK_LOOKUP("core_clk", gfx3d_clk.c, "footswitch-8x60.2"),
5433 CLK_LOOKUP("bus_clk", ijpeg_axi_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005434 CLK_LOOKUP("mem_clk", imem_axi_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005435 CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005436 CLK_LOOKUP("core_clk", ijpeg_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005437 CLK_LOOKUP("core_clk", jpegd_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005438 CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005439 CLK_LOOKUP("core_clk", mdp_clk.c, "footswitch-8x60.4"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005440 CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL),
5441 CLK_LOOKUP("lut_mdp", lut_mdp_clk.c, NULL),
Stephen Boyd973e4ba2011-07-12 17:06:01 -07005442 CLK_LOOKUP("qdss_pclk", qdss_p_clk.c, NULL),
5443 CLK_LOOKUP("qdss_at_clk", qdss_at_clk.c, NULL),
5444 CLK_LOOKUP("qdss_pclkdbg_clk", qdss_pclkdbg_clk.c, NULL),
5445 CLK_LOOKUP("qdss_traceclkin_clk", qdss_traceclkin_clk.c, NULL),
5446 CLK_LOOKUP("qdss_tsctr_clk", qdss_tsctr_clk.c, NULL),
5447 CLK_LOOKUP("qdss_stm_clk", qdss_stm_clk.c, NULL),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005448 CLK_LOOKUP("core_clk", rot_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005449 CLK_LOOKUP("core_clk", rot_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005450 CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL),
5451 CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL),
5452 CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005453 CLK_LOOKUP("core_clk", vcodec_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005454 CLK_LOOKUP("core_clk", vcodec_clk.c, "footswitch-8x60.7"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005455 CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL),
5456 CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005457 CLK_LOOKUP("core_clk", hdmi_app_clk.c, "hdmi_msm.1"),
Kevin Chana0853122011-11-07 19:48:44 -08005458 CLK_LOOKUP("vpe_clk", vpe_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005459 CLK_LOOKUP("core_clk", vpe_clk.c, "footswitch-8x60.9"),
Kevin Chan5827c552011-10-28 18:36:32 -07005460 CLK_LOOKUP("vfe_clk", vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005461 CLK_LOOKUP("core_clk", vfe_clk.c, "footswitch-8x60.8"),
Kevin Chan5827c552011-10-28 18:36:32 -07005462 CLK_LOOKUP("csi_vfe_clk", csi_vfe_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005463 CLK_LOOKUP("bus_clk", vfe_axi_clk.c, "footswitch-8x60.8"),
5464 CLK_LOOKUP("bus_clk", mdp_axi_clk.c, "footswitch-8x60.4"),
5465 CLK_LOOKUP("bus_clk", rot_axi_clk.c, "footswitch-8x60.6"),
5466 CLK_LOOKUP("bus_clk", vcodec_axi_clk.c, "footswitch-8x60.7"),
5467 CLK_LOOKUP("bus_a_clk", vcodec_axi_a_clk.c, "footswitch-8x60.7"),
5468 CLK_LOOKUP("bus_b_clk", vcodec_axi_b_clk.c, "footswitch-8x60.7"),
5469 CLK_LOOKUP("bus_clk", vpe_axi_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005470 CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL),
Kevin Chanc8b52e82011-10-25 23:20:21 -07005471 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.0"),
5472 CLK_LOOKUP("csi_pclk", csi_p_clk.c, "msm_csid.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005473 CLK_LOOKUP("dsi_m_pclk", dsi1_m_p_clk.c, NULL),
5474 CLK_LOOKUP("dsi_s_pclk", dsi1_s_p_clk.c, NULL),
5475 CLK_LOOKUP("dsi_m_pclk", dsi2_m_p_clk.c, NULL),
5476 CLK_LOOKUP("dsi_s_pclk", dsi2_s_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005477 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "kgsl-2d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005478 CLK_LOOKUP("iface_clk", gfx2d0_p_clk.c, "footswitch-8x60.0"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005479 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "kgsl-2d1.1"),
Matt Wagantall49722712011-08-17 18:50:53 -07005480 CLK_LOOKUP("iface_clk", gfx2d1_p_clk.c, "footswitch-8x60.1"),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005481 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "kgsl-3d0.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005482 CLK_LOOKUP("iface_clk", gfx3d_p_clk.c, "footswitch-8x60.2"),
Matt Wagantall5a4f1ba2011-08-18 18:13:03 -07005483 CLK_LOOKUP("master_iface_clk", hdmi_m_p_clk.c, "hdmi_msm.1"),
5484 CLK_LOOKUP("slave_iface_clk", hdmi_s_p_clk.c, "hdmi_msm.1"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005485 CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005486 CLK_LOOKUP("iface_clk", ijpeg_p_clk.c, "footswitch-8x60.3"),
Matt Wagantallb86ad262011-10-24 19:50:29 -07005487 CLK_LOOKUP("iface_clk", jpegd_p_clk.c, NULL),
Matt Wagantall9dc01632011-08-17 18:55:04 -07005488 CLK_LOOKUP("mem_iface_clk", imem_p_clk.c, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005489 CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL),
Matt Wagantall49722712011-08-17 18:50:53 -07005490 CLK_LOOKUP("iface_clk", mdp_p_clk.c, "footswitch-8x60.4"),
Matt Wagantalle604d712011-10-21 15:38:18 -07005491 CLK_LOOKUP("iface_clk", smmu_p_clk.c, "msm_iommu"),
Matt Wagantallbb90da92011-10-25 15:07:52 -07005492 CLK_LOOKUP("iface_clk", rot_p_clk.c, "msm_rotator.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005493 CLK_LOOKUP("iface_clk", rot_p_clk.c, "footswitch-8x60.6"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005494 CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL),
Matt Wagantall3f7660b2011-08-17 21:25:13 -07005495 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "msm_vidc.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005496 CLK_LOOKUP("iface_clk", vcodec_p_clk.c, "footswitch-8x60.7"),
Kevin Chan5827c552011-10-28 18:36:32 -07005497 CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, "msm_vfe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005498 CLK_LOOKUP("iface_clk", vfe_p_clk.c, "footswitch-8x60.8"),
Kevin Chana0853122011-11-07 19:48:44 -08005499 CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, "msm_vpe.0"),
Matt Wagantall49722712011-08-17 18:50:53 -07005500 CLK_LOOKUP("iface_clk", vpe_p_clk.c, "footswitch-8x60.9"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005501 CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL),
5502 CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL),
5503 CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL),
5504 CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL),
5505 CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL),
5506 CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL),
5507 CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL),
5508 CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL),
5509 CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL),
5510 CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL),
5511 CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL),
5512 CLK_LOOKUP("sps_slimbus_clk", sps_slimbus_clk.c, NULL),
5513 CLK_LOOKUP("audio_slimbus_clk", audio_slimbus_clk.c, NULL),
Matt Wagantalle604d712011-10-21 15:38:18 -07005514 CLK_LOOKUP("core_clk", jpegd_axi_clk.c, "msm_iommu.0"),
5515 CLK_LOOKUP("core_clk", vpe_axi_clk.c, "msm_iommu.1"),
5516 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.2"),
5517 CLK_LOOKUP("core_clk", mdp_axi_clk.c, "msm_iommu.3"),
5518 CLK_LOOKUP("core_clk", rot_axi_clk.c, "msm_iommu.4"),
5519 CLK_LOOKUP("core_clk", ijpeg_axi_clk.c, "msm_iommu.5"),
5520 CLK_LOOKUP("core_clk", vfe_axi_clk.c, "msm_iommu.6"),
5521 CLK_LOOKUP("core_clk", vcodec_axi_a_clk.c, "msm_iommu.7"),
5522 CLK_LOOKUP("core_clk", vcodec_axi_b_clk.c, "msm_iommu.8"),
5523 CLK_LOOKUP("core_clk", gfx3d_clk.c, "msm_iommu.9"),
5524 CLK_LOOKUP("core_clk", gfx2d0_clk.c, "msm_iommu.10"),
5525 CLK_LOOKUP("core_clk", gfx2d1_clk.c, "msm_iommu.11"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005526 CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL),
5527 CLK_LOOKUP("dfab_usb_hs_clk", dfab_usb_hs_clk.c, NULL),
Matt Wagantall37ce3842011-08-17 16:00:36 -07005528 CLK_LOOKUP("bus_clk", dfab_sdc1_clk.c, "msm_sdcc.1"),
5529 CLK_LOOKUP("bus_clk", dfab_sdc2_clk.c, "msm_sdcc.2"),
5530 CLK_LOOKUP("bus_clk", dfab_sdc3_clk.c, "msm_sdcc.3"),
5531 CLK_LOOKUP("bus_clk", dfab_sdc4_clk.c, "msm_sdcc.4"),
5532 CLK_LOOKUP("bus_clk", dfab_sdc5_clk.c, "msm_sdcc.5"),
Yan He160633e2011-06-30 12:18:56 -07005533 CLK_LOOKUP("dfab_clk", dfab_sps_clk.c, "msm_sps"),
Stephen Boyd1c51a492011-10-26 12:11:47 -07005534 CLK_LOOKUP("bus_clk", dfab_bam_dmux_clk.c, "BAM_RMNT"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005535
Matt Wagantalle1a86062011-08-18 17:46:10 -07005536 CLK_LOOKUP("mem_clk", ebi1_adm_clk.c, "msm_dmov"),
Matt Wagantall8b38f942011-08-02 18:23:18 -07005537
5538 CLK_LOOKUP("l2_mclk", l2_m_clk, NULL),
5539 CLK_LOOKUP("krait0_mclk", krait0_m_clk, NULL),
5540 CLK_LOOKUP("krait1_mclk", krait1_m_clk, NULL),
Stephen Boyd3939c8d2011-08-29 17:36:22 -07005541 CLK_LOOKUP("q6sw_clk", q6sw_clk, NULL),
5542 CLK_LOOKUP("q6fw_clk", q6fw_clk, NULL),
5543 CLK_LOOKUP("q6_func_clk", q6_func_clk, NULL),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005544};
5545
Stephen Boyd94625ef2011-07-12 17:06:01 -07005546static struct clk_lookup msm_clocks_8960_v2[] __initdata = {
5547 CLK_LOOKUP("cam_clk", cam2_clk.c, NULL),
5548 CLK_LOOKUP("csi_src_clk", csi2_src_clk.c, NULL),
5549 CLK_LOOKUP("csi_clk", csi2_clk.c, NULL),
Kevin Chane12c6672011-10-26 11:55:26 -07005550 CLK_LOOKUP("csi_pix1_clk", csi_pix1_clk.c, "msm_ispif.0"),
5551 CLK_LOOKUP("csi_rdi1_clk", csi_rdi1_clk.c, "msm_ispif.0"),
5552 CLK_LOOKUP("csi_rdi2_clk", csi_rdi2_clk.c, "msm_ispif.0"),
Stephen Boyd94625ef2011-07-12 17:06:01 -07005553 CLK_LOOKUP("csi_phy_clk", csi2_phy_clk.c, NULL),
5554 CLK_LOOKUP("csi2phy_timer_clk", csi2phy_timer_clk.c, NULL),
5555 CLK_LOOKUP("usb_hsic_xcvr_fs_clk", usb_hsic_xcvr_fs_clk.c, NULL),
5556 CLK_LOOKUP("usb_hsic_hsic_clk", usb_hsic_hsic_clk.c, NULL),
5557 CLK_LOOKUP("usb_hsic_hsio_cal_clk", usb_hsic_hsio_cal_clk.c, NULL),
5558 CLK_LOOKUP("usb_hsic_system_clk", usb_hsic_system_clk.c, NULL),
5559 CLK_LOOKUP("usb_hsic_p_clk", usb_hsic_p_clk.c, NULL),
5560};
5561
5562/* Add v2 clocks dynamically at runtime */
5563static struct clk_lookup msm_clocks_8960[ARRAY_SIZE(msm_clocks_8960_v1) +
5564 ARRAY_SIZE(msm_clocks_8960_v2)];
5565
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005566/*
5567 * Miscellaneous clock register initializations
5568 */
5569
5570/* Read, modify, then write-back a register. */
5571static void __init rmwreg(uint32_t val, void *reg, uint32_t mask)
5572{
5573 uint32_t regval = readl_relaxed(reg);
5574 regval &= ~mask;
5575 regval |= val;
5576 writel_relaxed(regval, reg);
5577}
5578
Tianyi Gou41515e22011-09-01 19:37:43 -07005579static void __init set_fsm_mode(void __iomem *mode_reg)
5580{
5581 u32 regval = readl_relaxed(mode_reg);
5582
5583 /*De-assert reset to FSM */
5584 regval &= ~BIT(21);
5585 writel_relaxed(regval, mode_reg);
5586
5587 /* Program bias count */
Tianyi Gou358c3862011-10-18 17:03:41 -07005588 regval &= ~BM(19, 14);
5589 regval |= BVAL(19, 14, 0x1);
5590 writel_relaxed(regval, mode_reg);
5591
5592 /* Program lock count */
Tianyi Gou41515e22011-09-01 19:37:43 -07005593 regval &= ~BM(13, 8);
5594 regval |= BVAL(13, 8, 0x8);
5595 writel_relaxed(regval, mode_reg);
5596
5597 /*Enable PLL FSM voting */
5598 regval |= BIT(20);
5599 writel_relaxed(regval, mode_reg);
5600}
5601
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005602static void __init reg_init(void)
5603{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005604 /* Deassert MM SW_RESET_ALL signal. */
5605 writel_relaxed(0, SW_RESET_ALL_REG);
5606
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005607 /*
5608 * Some bits are only used on either 8960 or 8064 and are marked as
5609 * reserved bits on the other SoC. Writing to these reserved bits
5610 * should have no effect.
5611 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005612 /* Initialize MM AHB registers: Enable the FPB clock and disable HW
5613 * gating for all clocks. Also set VFE_AHB's FORCE_CORE_ON bit to
5614 * prevent its memory from being collapsed when the clock is halted.
5615 * The sleep and wake-up delays are set to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005616 rmwreg(0x00000003, AHB_EN_REG, 0x6C000103);
5617 writel_relaxed(0x000007F9, AHB_EN2_REG);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005618 if (cpu_is_apq8064())
5619 rmwreg(0x00000000, AHB_EN3_REG, 0x00000001);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005620
5621 /* Deassert all locally-owned MM AHB resets. */
5622 rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF);
Tianyi Gou41515e22011-09-01 19:37:43 -07005623 rmwreg(0, SW_RESET_AHB2_REG, 0x0000000F);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005624
5625 /* Initialize MM AXI registers: Enable HW gating for all clocks that
5626 * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up
5627 * delays to safe values. */
5628 /* TODO: Enable HW Gating */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005629 rmwreg(0x000007F9, MAXI_EN_REG, 0x0803FFFF);
5630 rmwreg(0x3027FCFF, MAXI_EN2_REG, 0x3A3FFFFF);
5631 rmwreg(0x0027FCFF, MAXI_EN3_REG, 0x003FFFFF);
5632 rmwreg(0x0027FCFF, MAXI_EN4_REG, 0x017FFFFF);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005633 if (cpu_is_apq8064())
5634 rmwreg(0x009FE4FF, MAXI_EN5_REG, 0x01FFEFFF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005635 rmwreg(0x000003C7, SAXI_EN_REG, 0x00003FFF);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005636
5637 /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core
5638 * memories retain state even when not clocked. Also, set sleep and
5639 * wake-up delays to safe values. */
Matt Wagantall53d968f2011-07-19 13:22:53 -07005640 rmwreg(0x00000000, CSI0_CC_REG, 0x00000410);
5641 rmwreg(0x00000000, CSI1_CC_REG, 0x00000410);
5642 rmwreg(0x80FF0000, DSI1_BYTE_CC_REG, 0xE0FF0010);
5643 rmwreg(0x80FF0000, DSI2_BYTE_CC_REG, 0xE0FF0010);
5644 rmwreg(0x80FF0000, DSI_PIXEL_CC_REG, 0xE0FF0010);
5645 rmwreg(0x80FF0000, DSI2_PIXEL_CC_REG, 0xE0FF0010);
Tarun Karra6fbc00a2011-12-13 09:23:47 -07005646 rmwreg(0xC0FF0000, GFX3D_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005647 rmwreg(0x80FF0000, IJPEG_CC_REG, 0xE0FF0010);
5648 rmwreg(0x80FF0000, JPEGD_CC_REG, 0xE0FF0010);
5649 rmwreg(0x80FF0000, MDP_CC_REG, 0xE1FF0010);
5650 rmwreg(0x80FF0000, MDP_LUT_CC_REG, 0xE0FF0010);
5651 rmwreg(0x80FF0000, ROT_CC_REG, 0xE0FF0010);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005652 rmwreg(0x000004FF, TV_CC2_REG, 0x000007FF);
5653 rmwreg(0xC0FF0000, VCODEC_CC_REG, 0xE0FF0010);
5654 rmwreg(0x80FF0000, VFE_CC_REG, 0xE0FF4010);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005655 rmwreg(0x800000FF, VFE_CC2_REG, 0xE00000FF);
Matt Wagantall53d968f2011-07-19 13:22:53 -07005656 rmwreg(0x80FF0000, VPE_CC_REG, 0xE0FF0010);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005657 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005658 rmwreg(0x80FF0000, GFX2D0_CC_REG, 0xE0FF0010);
5659 rmwreg(0x80FF0000, GFX2D1_CC_REG, 0xE0FF0010);
5660 rmwreg(0x80FF0000, TV_CC_REG, 0xE1FFC010);
5661 }
5662 if (cpu_is_apq8064()) {
5663 rmwreg(0x00000000, TV_CC_REG, 0x00004010);
Tianyi Gou621f8742011-09-01 21:45:01 -07005664 rmwreg(0x80FF0000, VCAP_CC_REG, 0xE0FF1010);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005665 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005666
Tianyi Gou41515e22011-09-01 19:37:43 -07005667 /*
5668 * Initialize USB_HS_HCLK_FS registers: Set FORCE_C_ON bits so that
5669 * core remain active during halt state of the clk. Also, set sleep
5670 * and wake-up value to max.
5671 */
5672 rmwreg(0x0000004F, USB_HS1_HCLK_FS_REG, 0x0000007F);
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005673 if (cpu_is_apq8064()) {
5674 rmwreg(0x0000004F, USB_HS3_HCLK_FS_REG, 0x0000007F);
5675 rmwreg(0x0000004F, USB_HS4_HCLK_FS_REG, 0x0000007F);
5676 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005677
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005678 /* De-assert MM AXI resets to all hardware blocks. */
5679 writel_relaxed(0, SW_RESET_AXI_REG);
5680
5681 /* Deassert all MM core resets. */
5682 writel_relaxed(0, SW_RESET_CORE_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005683 writel_relaxed(0, SW_RESET_CORE2_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005684
5685 /* Reset 3D core once more, with its clock enabled. This can
5686 * eventually be done as part of the GDFS footswitch driver. */
5687 clk_set_rate(&gfx3d_clk.c, 27000000);
5688 clk_enable(&gfx3d_clk.c);
5689 writel_relaxed(BIT(12), SW_RESET_CORE_REG);
5690 mb();
5691 udelay(5);
5692 writel_relaxed(0, SW_RESET_CORE_REG);
5693 /* Make sure reset is de-asserted before clock is disabled. */
5694 mb();
5695 clk_disable(&gfx3d_clk.c);
5696
5697 /* Enable TSSC and PDM PXO sources. */
5698 writel_relaxed(BIT(11), TSSC_CLK_CTL_REG);
5699 writel_relaxed(BIT(15), PDM_CLK_NS_REG);
5700
5701 /* Source SLIMBus xo src from slimbus reference clock */
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005702 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou8c1a1182011-10-10 14:47:11 -07005703 writel_relaxed(0x3, SLIMBUS_XO_SRC_CLK_CTL_REG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005704
5705 /* Source the dsi_byte_clks from the DSI PHY PLLs */
5706 rmwreg(0x1, DSI1_BYTE_NS_REG, 0x7);
5707 rmwreg(0x2, DSI2_BYTE_NS_REG, 0x7);
Tianyi Gou41515e22011-09-01 19:37:43 -07005708
5709 /* Source the sata_phy_ref_clk from PXO */
5710 if (cpu_is_apq8064())
5711 rmwreg(0, SATA_PHY_REF_CLK_CTL_REG, 0x1);
5712
5713 /*
5714 * TODO: Programming below PLLs is temporary and needs to be removed
5715 * after bootloaders program them.
5716 */
5717 if (cpu_is_apq8064()) {
5718 u32 regval, is_pll_enabled;
5719
5720 /* Program pxo_src_clk to source from PXO */
5721 rmwreg(0x1, PXO_SRC_CLK_CTL_REG, 0x7);
5722
5723 /* Check if PLL8 is active */
5724 is_pll_enabled = readl_relaxed(BB_PLL8_STATUS_REG) & BIT(16);
5725 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005726 /* Ref clk = 27MHz and program pll8 to 384MHz */
5727 writel_relaxed(0xE, BB_PLL8_L_VAL_REG);
5728 writel_relaxed(0x2, BB_PLL8_M_VAL_REG);
5729 writel_relaxed(0x9, BB_PLL8_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005730
5731 regval = readl_relaxed(BB_PLL8_CONFIG_REG);
5732
5733 /* Enable the main output and the MN accumulator */
5734 regval |= BIT(23) | BIT(22);
5735
5736 /* Set pre-divider and post-divider values to 1 and 1 */
5737 regval &= ~BIT(19);
5738 regval &= ~BM(21, 20);
5739
5740 writel_relaxed(regval, BB_PLL8_CONFIG_REG);
5741
5742 /* Set VCO frequency */
5743 rmwreg(0x10000, BB_PLL8_CONFIG_REG, 0x30000);
5744
5745 /* Enable AUX output */
5746 regval = readl_relaxed(BB_PLL8_TEST_CTL_REG);
5747 regval |= BIT(12);
5748 writel_relaxed(regval, BB_PLL8_TEST_CTL_REG);
5749
5750 set_fsm_mode(BB_PLL8_MODE_REG);
5751 }
5752 /* Check if PLL3 is active */
5753 is_pll_enabled = readl_relaxed(GPLL1_STATUS_REG) & BIT(16);
5754 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005755 /* Ref clk = 27MHz and program pll3 to 1200MHz */
5756 writel_relaxed(0x2C, GPLL1_L_VAL_REG);
5757 writel_relaxed(0x4, GPLL1_M_VAL_REG);
5758 writel_relaxed(0x9, GPLL1_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005759
5760 regval = readl_relaxed(GPLL1_CONFIG_REG);
5761
5762 /* Set pre-divider and post-divider values to 1 and 1 */
5763 regval &= ~BIT(15);
5764 regval |= BIT(16);
5765
5766 writel_relaxed(regval, GPLL1_CONFIG_REG);
5767
5768 /* Set VCO frequency */
5769 rmwreg(0x180, GPLL1_CONFIG_REG, 0x180);
5770 }
5771 /* Check if PLL14 is active */
5772 is_pll_enabled = readl_relaxed(BB_PLL14_STATUS_REG) & BIT(16);
5773 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005774 /* Ref clk = 27MHz and program pll14 to 480MHz */
5775 writel_relaxed(0x11, BB_PLL14_L_VAL_REG);
5776 writel_relaxed(0x7, BB_PLL14_M_VAL_REG);
5777 writel_relaxed(0x9, BB_PLL14_N_VAL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005778
5779 regval = readl_relaxed(BB_PLL14_CONFIG_REG);
5780
5781 /* Enable the main output and the MN accumulator */
5782 regval |= BIT(23) | BIT(22);
5783
5784 /* Set pre-divider and post-divider values to 1 and 1 */
5785 regval &= ~BIT(19);
5786 regval &= ~BM(21, 20);
5787
5788 writel_relaxed(regval, BB_PLL14_CONFIG_REG);
5789
5790 /* Set VCO frequency */
5791 rmwreg(0x10000, BB_PLL14_CONFIG_REG, 0x30000);
5792
Tianyi Gou41515e22011-09-01 19:37:43 -07005793 set_fsm_mode(BB_PLL14_MODE_REG);
5794 }
Tianyi Gou621f8742011-09-01 21:45:01 -07005795 /* Program PLL2 to 800MHz with ref clk = 27MHz */
5796 writel_relaxed(0x1D, MM_PLL1_L_VAL_REG);
5797 writel_relaxed(0x11, MM_PLL1_M_VAL_REG);
5798 writel_relaxed(0x1B, MM_PLL1_N_VAL_REG);
5799
5800 regval = readl_relaxed(MM_PLL1_CONFIG_REG);
5801
5802 /* Enable the main output and the MN accumulator */
5803 regval |= BIT(23) | BIT(22);
5804
5805 /* Set pre-divider and post-divider values to 1 and 1 */
5806 regval &= ~BIT(19);
5807 regval &= ~BM(21, 20);
5808
5809 writel_relaxed(regval, MM_PLL1_CONFIG_REG);
5810
5811 /* Set VCO frequency */
5812 rmwreg(0x20000, MM_PLL1_CONFIG_REG, 0x30000);
5813
Tianyi Gou621f8742011-09-01 21:45:01 -07005814 /* Program PLL15 to 975MHz with ref clk = 27MHz */
5815 writel_relaxed(0x24, MM_PLL3_L_VAL_REG);
5816 writel_relaxed(0x1, MM_PLL3_M_VAL_REG);
5817 writel_relaxed(0x9, MM_PLL3_N_VAL_REG);
5818
5819 regval = readl_relaxed(MM_PLL3_CONFIG_REG);
5820
5821 /* Enable the main output and the MN accumulator */
5822 regval |= BIT(23) | BIT(22);
5823
5824 /* Set pre-divider and post-divider values to 1 and 1 */
5825 regval &= ~BIT(19);
5826 regval &= ~BM(21, 20);
5827
5828 writel_relaxed(regval, MM_PLL3_CONFIG_REG);
5829
5830 /* Set VCO frequency */
5831 rmwreg(0x20000, MM_PLL3_CONFIG_REG, 0x30000);
5832
5833 /* Enable AUX output */
5834 regval = readl_relaxed(MM_PLL3_TEST_CTL_REG);
5835 regval |= BIT(12);
5836 writel_relaxed(regval, MM_PLL3_TEST_CTL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005837
5838 /* Check if PLL4 is active */
5839 is_pll_enabled = readl_relaxed(LCC_PLL0_STATUS_REG) & BIT(16);
5840 if (!is_pll_enabled) {
Tianyi Goudf71f2e2011-10-24 22:25:04 -07005841 /* Ref clk = 27MHz and program pll4 to 393.2160MHz */
5842 writel_relaxed(0xE, LCC_PLL0_L_VAL_REG);
5843 writel_relaxed(0x27A, LCC_PLL0_M_VAL_REG);
5844 writel_relaxed(0x465, LCC_PLL0_N_VAL_REG);
Tianyi Gouc29c3242011-10-12 21:02:15 -07005845
5846 regval = readl_relaxed(LCC_PLL0_CONFIG_REG);
5847
5848 /* Enable the main output and the MN accumulator */
5849 regval |= BIT(23) | BIT(22);
5850
5851 /* Set pre-divider and post-divider values to 1 and 1 */
5852 regval &= ~BIT(19);
5853 regval &= ~BM(21, 20);
5854
5855 /* Set VCO frequency */
5856 regval &= ~BM(17, 16);
5857 writel_relaxed(regval, LCC_PLL0_CONFIG_REG);
5858
5859 set_fsm_mode(LCC_PLL0_MODE_REG);
5860 }
5861
5862 /* Enable PLL4 source on the LPASS Primary PLL Mux */
5863 writel_relaxed(0x1, LCC_PRI_PLL_CLK_CTL_REG);
Tianyi Gou41515e22011-09-01 19:37:43 -07005864 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005865}
5866
Stephen Boyd94625ef2011-07-12 17:06:01 -07005867struct clock_init_data msm8960_clock_init_data __initdata;
5868
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005869/* Local clock driver initialization. */
Stephen Boydbb600ae2011-08-02 20:11:40 -07005870static void __init msm8960_clock_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005871{
Stephen Boyd94625ef2011-07-12 17:06:01 -07005872 size_t num_lookups = ARRAY_SIZE(msm_clocks_8960_v1);
Tianyi Gou41515e22011-09-01 19:37:43 -07005873
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005874 xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8960");
5875 if (IS_ERR(xo_pxo)) {
5876 pr_err("%s: msm_xo_get(PXO) failed.\n", __func__);
5877 BUG();
5878 }
5879 xo_cxo = msm_xo_get(MSM_XO_TCXO_D0, "clock-8960");
5880 if (IS_ERR(xo_cxo)) {
5881 pr_err("%s: msm_xo_get(CXO) failed.\n", __func__);
5882 BUG();
5883 }
5884
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005885 if (cpu_is_msm8960() || cpu_is_msm8930()) {
Tianyi Gou41515e22011-09-01 19:37:43 -07005886 memcpy(msm_clocks_8960, msm_clocks_8960_v1,
5887 sizeof(msm_clocks_8960_v1));
5888 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5889 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8960_v2;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005890
5891 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8960_v2,
5892 sizeof(gfx3d_clk.c.fmax));
5893 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8960_v2,
5894 sizeof(ijpeg_clk.c.fmax));
5895 memcpy(vfe_clk.c.fmax, fmax_vfe_8960_v2,
5896 sizeof(vfe_clk.c.fmax));
5897
Tianyi Gou41515e22011-09-01 19:37:43 -07005898 memcpy(msm_clocks_8960 + ARRAY_SIZE(msm_clocks_8960_v1),
Stephen Boyd94625ef2011-07-12 17:06:01 -07005899 msm_clocks_8960_v2, sizeof(msm_clocks_8960_v2));
Tianyi Gou41515e22011-09-01 19:37:43 -07005900 num_lookups = ARRAY_SIZE(msm_clocks_8960);
5901 }
5902 msm8960_clock_init_data.size = num_lookups;
Stephen Boyd94625ef2011-07-12 17:06:01 -07005903 }
Tianyi Gou41515e22011-09-01 19:37:43 -07005904
5905 /*
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005906 * Change the freq tables for and voltage requirements for
5907 * clocks which differ between 8960 and 8064.
Tianyi Gou41515e22011-09-01 19:37:43 -07005908 */
5909 if (cpu_is_apq8064()) {
5910 gfx3d_clk.freq_tbl = clk_tbl_gfx3d_8064;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005911
5912 memcpy(gfx3d_clk.c.fmax, fmax_gfx3d_8064,
5913 sizeof(gfx3d_clk.c.fmax));
5914 memcpy(ijpeg_clk.c.fmax, fmax_ijpeg_8064,
5915 sizeof(ijpeg_clk.c.fmax));
5916 memcpy(mdp_clk.c.fmax, fmax_mdp_8064,
5917 sizeof(ijpeg_clk.c.fmax));
5918 memcpy(tv_src_clk.c.fmax, fmax_tv_src_8064,
5919 sizeof(tv_src_clk.c.fmax));
5920 memcpy(vfe_clk.c.fmax, fmax_vfe_8064,
5921 sizeof(vfe_clk.c.fmax));
5922
Tianyi Gou621f8742011-09-01 21:45:01 -07005923 gmem_axi_clk.c.depends = &gfx3d_axi_clk.c;
Tianyi Gou41515e22011-09-01 19:37:43 -07005924 }
Stephen Boyd94625ef2011-07-12 17:06:01 -07005925
Matt Wagantalle18bbc82011-10-06 10:07:28 -07005926 vote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005927
Vikram Mulukutla489e39e2011-08-31 18:04:05 -07005928 clk_ops_pll.enable = sr_pll_clk_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005929
5930 /* Initialize clock registers. */
5931 reg_init();
5932
5933 /* Initialize rates for clocks that only support one. */
5934 clk_set_rate(&pdm_clk.c, 27000000);
5935 clk_set_rate(&prng_clk.c, 64000000);
5936 clk_set_rate(&mdp_vsync_clk.c, 27000000);
5937 clk_set_rate(&tsif_ref_clk.c, 105000);
5938 clk_set_rate(&tssc_clk.c, 27000000);
5939 clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000);
Tianyi Gou41515e22011-09-01 19:37:43 -07005940 if (cpu_is_apq8064()) {
5941 clk_set_rate(&usb_hs3_xcvr_clk.c, 60000000);
5942 clk_set_rate(&usb_hs4_xcvr_clk.c, 60000000);
5943 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005944 clk_set_rate(&usb_fs1_src_clk.c, 60000000);
Stepan Moskovchenko2429f152011-10-25 14:42:35 -07005945 if (cpu_is_msm8960() || cpu_is_msm8930())
Tianyi Gou41515e22011-09-01 19:37:43 -07005946 clk_set_rate(&usb_fs2_src_clk.c, 60000000);
Stephen Boyd94625ef2011-07-12 17:06:01 -07005947 clk_set_rate(&usb_hsic_xcvr_fs_clk.c, 60000000);
5948 clk_set_rate(&usb_hsic_hsic_src_clk.c, 480000000);
5949 clk_set_rate(&usb_hsic_hsio_cal_clk.c, 9000000);
Stephen Boyd092fd182011-10-21 15:56:30 -07005950 /*
5951 * Set the CSI rates to a safe default to avoid warnings when
5952 * switching csi pix and rdi clocks.
5953 */
5954 clk_set_rate(&csi0_src_clk.c, 27000000);
5955 clk_set_rate(&csi1_src_clk.c, 27000000);
5956 clk_set_rate(&csi2_src_clk.c, 27000000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005957
5958 /*
Stephen Boyd60496bb2011-10-17 13:51:37 -07005959 * The halt status bits for these clocks may be incorrect at boot.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005960 * Toggle these clocks on and off to refresh them.
5961 */
Matt Wagantall0625ea02011-07-13 18:51:56 -07005962 rcg_clk_enable(&pdm_clk.c);
5963 rcg_clk_disable(&pdm_clk.c);
5964 rcg_clk_enable(&tssc_clk.c);
5965 rcg_clk_disable(&tssc_clk.c);
Stephen Boyd60496bb2011-10-17 13:51:37 -07005966 if (cpu_is_msm8960() &&
5967 SOCINFO_VERSION_MAJOR(socinfo_get_version()) >= 2) {
5968 clk_enable(&usb_hsic_hsic_clk.c);
5969 clk_disable(&usb_hsic_hsic_clk.c);
Stephen Boyd092fd182011-10-21 15:56:30 -07005970 } else
5971 /* CSI2 hardware not present on 8960v1 devices */
5972 pix_rdi_mux_map[2] = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005973
5974 if (machine_is_msm8960_sim()) {
5975 clk_set_rate(&sdc1_clk.c, 48000000);
5976 clk_enable(&sdc1_clk.c);
5977 clk_enable(&sdc1_p_clk.c);
5978 clk_set_rate(&sdc3_clk.c, 48000000);
5979 clk_enable(&sdc3_clk.c);
5980 clk_enable(&sdc3_p_clk.c);
5981 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005982}
5983
Stephen Boydbb600ae2011-08-02 20:11:40 -07005984static int __init msm8960_clock_late_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005985{
Stephen Boyda3787f32011-09-16 18:55:13 -07005986 int rc;
5987 struct clk *mmfpb_a_clk = clk_get_sys("clock-8960", "mmfpb_a_clk");
Stephen Boyd85436132011-09-16 18:55:13 -07005988 struct clk *cfpb_a_clk = clk_get_sys("clock-8960", "cfpb_a_clk");
Stephen Boyda3787f32011-09-16 18:55:13 -07005989
5990 /* Vote for MMFPB to be at least 76.8MHz when an Apps CPU is active. */
5991 if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n",
5992 PTR_ERR(mmfpb_a_clk)))
5993 return PTR_ERR(mmfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08005994 rc = clk_set_rate(mmfpb_a_clk, 76800000);
Stephen Boyda3787f32011-09-16 18:55:13 -07005995 if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc))
5996 return rc;
5997 rc = clk_enable(mmfpb_a_clk);
5998 if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc))
5999 return rc;
6000
Stephen Boyd85436132011-09-16 18:55:13 -07006001 /* Vote for CFPB to be at least 64MHz when an Apps CPU is active. */
6002 if (WARN(IS_ERR(cfpb_a_clk), "cfpb_a_clk not found (%ld)\n",
6003 PTR_ERR(cfpb_a_clk)))
6004 return PTR_ERR(cfpb_a_clk);
Matt Wagantallde555f562011-11-08 14:18:07 -08006005 rc = clk_set_rate(cfpb_a_clk, 64000000);
Stephen Boyd85436132011-09-16 18:55:13 -07006006 if (WARN(rc, "cfpb_a_clk rate was not set (%d)\n", rc))
6007 return rc;
6008 rc = clk_enable(cfpb_a_clk);
6009 if (WARN(rc, "cfpb_a_clk not enabled (%d)\n", rc))
6010 return rc;
Matt Wagantalle18bbc82011-10-06 10:07:28 -07006011
6012 return unvote_vdd_level(&vdd_dig, VDD_DIG_HIGH);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006013}
Stephen Boydbb600ae2011-08-02 20:11:40 -07006014
6015struct clock_init_data msm8960_clock_init_data __initdata = {
6016 .table = msm_clocks_8960,
6017 .size = ARRAY_SIZE(msm_clocks_8960),
6018 .init = msm8960_clock_init,
6019 .late_init = msm8960_clock_late_init,
6020};
Tianyi Gou41515e22011-09-01 19:37:43 -07006021
6022struct clock_init_data apq8064_clock_init_data __initdata = {
6023 .table = msm_clocks_8064,
6024 .size = ARRAY_SIZE(msm_clocks_8064),
6025 .init = msm8960_clock_init,
6026 .late_init = msm8960_clock_late_init,
6027};