blob: aeb4e48d31ebf29d0a562e675357766b1eca3ab3 [file] [log] [blame]
Saravana Kannanc85ecf92013-01-21 17:58:35 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Chandan Uddaraju09adf322012-08-16 02:55:23 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/io.h>
15#include <linux/err.h>
16#include <linux/delay.h>
17#include <linux/string.h>
18#include <linux/iopoll.h>
19#include <linux/clk.h>
20
21#include <asm/processor.h>
22#include <mach/msm_iomap.h>
Matt Wagantall33d01f52012-02-23 23:27:44 -080023#include <mach/clk-provider.h>
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -070024#include <mach/clk.h>
25#include <mach/clock-generic.h>
Chandan Uddaraju09adf322012-08-16 02:55:23 -070026
Chandan Uddaraju09adf322012-08-16 02:55:23 -070027#include "clock-mdss-8974.h"
28
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -070029#define REG_R(addr) readl_relaxed(addr)
30#define REG_W(data, addr) writel_relaxed(data, addr)
31#define DSS_REG_W(base, offset, data) REG_W((data), (base) + (offset))
32#define DSS_REG_R(base, offset) REG_R((base) + (offset))
Abhishek Kharbandac1559842012-08-13 18:45:02 -070033
Matt Wagantall7cf535b2013-02-28 16:16:51 -080034#define GDSC_PHYS 0xFD8C2304
35#define GDSC_SIZE 0x4
36
Vikram Mulukutla81e17e52013-05-02 20:31:51 -070037#define DSI_PHY_PHYS 0xFD922A00
38#define DSI_PHY_SIZE 0x000000D4
Abhishek Kharbandac1559842012-08-13 18:45:02 -070039
40#define HDMI_PHY_PHYS 0xFD922500
41#define HDMI_PHY_SIZE 0x0000007C
42
43#define HDMI_PHY_PLL_PHYS 0xFD922700
44#define HDMI_PHY_PLL_SIZE 0x000000D4
45
46/* hdmi phy registers */
Ujwal Patelc8017652012-11-15 18:03:01 -080047#define HDMI_PHY_ANA_CFG0 (0x0000)
48#define HDMI_PHY_ANA_CFG1 (0x0004)
49#define HDMI_PHY_ANA_CFG2 (0x0008)
50#define HDMI_PHY_ANA_CFG3 (0x000C)
51#define HDMI_PHY_PD_CTRL0 (0x0010)
52#define HDMI_PHY_PD_CTRL1 (0x0014)
53#define HDMI_PHY_GLB_CFG (0x0018)
54#define HDMI_PHY_DCC_CFG0 (0x001C)
55#define HDMI_PHY_DCC_CFG1 (0x0020)
56#define HDMI_PHY_TXCAL_CFG0 (0x0024)
57#define HDMI_PHY_TXCAL_CFG1 (0x0028)
58#define HDMI_PHY_TXCAL_CFG2 (0x002C)
59#define HDMI_PHY_TXCAL_CFG3 (0x0030)
60#define HDMI_PHY_BIST_CFG0 (0x0034)
61#define HDMI_PHY_BIST_CFG1 (0x0038)
62#define HDMI_PHY_BIST_PATN0 (0x003C)
63#define HDMI_PHY_BIST_PATN1 (0x0040)
64#define HDMI_PHY_BIST_PATN2 (0x0044)
65#define HDMI_PHY_BIST_PATN3 (0x0048)
66#define HDMI_PHY_STATUS (0x005C)
Abhishek Kharbandac1559842012-08-13 18:45:02 -070067
68/* hdmi phy unified pll registers */
Ujwal Patelc8017652012-11-15 18:03:01 -080069#define HDMI_UNI_PLL_REFCLK_CFG (0x0000)
70#define HDMI_UNI_PLL_POSTDIV1_CFG (0x0004)
71#define HDMI_UNI_PLL_CHFPUMP_CFG (0x0008)
72#define HDMI_UNI_PLL_VCOLPF_CFG (0x000C)
73#define HDMI_UNI_PLL_VREG_CFG (0x0010)
74#define HDMI_UNI_PLL_PWRGEN_CFG (0x0014)
75#define HDMI_UNI_PLL_GLB_CFG (0x0020)
76#define HDMI_UNI_PLL_POSTDIV2_CFG (0x0024)
77#define HDMI_UNI_PLL_POSTDIV3_CFG (0x0028)
78#define HDMI_UNI_PLL_LPFR_CFG (0x002C)
79#define HDMI_UNI_PLL_LPFC1_CFG (0x0030)
80#define HDMI_UNI_PLL_LPFC2_CFG (0x0034)
81#define HDMI_UNI_PLL_SDM_CFG0 (0x0038)
82#define HDMI_UNI_PLL_SDM_CFG1 (0x003C)
83#define HDMI_UNI_PLL_SDM_CFG2 (0x0040)
84#define HDMI_UNI_PLL_SDM_CFG3 (0x0044)
85#define HDMI_UNI_PLL_SDM_CFG4 (0x0048)
86#define HDMI_UNI_PLL_SSC_CFG0 (0x004C)
87#define HDMI_UNI_PLL_SSC_CFG1 (0x0050)
88#define HDMI_UNI_PLL_SSC_CFG2 (0x0054)
89#define HDMI_UNI_PLL_SSC_CFG3 (0x0058)
90#define HDMI_UNI_PLL_LKDET_CFG0 (0x005C)
91#define HDMI_UNI_PLL_LKDET_CFG1 (0x0060)
92#define HDMI_UNI_PLL_LKDET_CFG2 (0x0064)
93#define HDMI_UNI_PLL_CAL_CFG0 (0x006C)
94#define HDMI_UNI_PLL_CAL_CFG1 (0x0070)
95#define HDMI_UNI_PLL_CAL_CFG2 (0x0074)
96#define HDMI_UNI_PLL_CAL_CFG3 (0x0078)
97#define HDMI_UNI_PLL_CAL_CFG4 (0x007C)
98#define HDMI_UNI_PLL_CAL_CFG5 (0x0080)
99#define HDMI_UNI_PLL_CAL_CFG6 (0x0084)
100#define HDMI_UNI_PLL_CAL_CFG7 (0x0088)
101#define HDMI_UNI_PLL_CAL_CFG8 (0x008C)
102#define HDMI_UNI_PLL_CAL_CFG9 (0x0090)
103#define HDMI_UNI_PLL_CAL_CFG10 (0x0094)
104#define HDMI_UNI_PLL_CAL_CFG11 (0x0098)
105#define HDMI_UNI_PLL_STATUS (0x00C0)
Chandan Uddaraju09adf322012-08-16 02:55:23 -0700106
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700107#define DSI_0_PHY_PLL_UNIPHY_PLL_REFCLK_CFG (0x00000000)
108#define DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV1_CFG (0x00000004)
109#define DSI_0_PHY_PLL_UNIPHY_PLL_CHGPUMP_CFG (0x00000008)
110#define DSI_0_PHY_PLL_UNIPHY_PLL_VCOLPF_CFG (0x0000000C)
111#define DSI_0_PHY_PLL_UNIPHY_PLL_VREG_CFG (0x00000010)
112#define DSI_0_PHY_PLL_UNIPHY_PLL_PWRGEN_CFG (0x00000014)
113#define DSI_0_PHY_PLL_UNIPHY_PLL_DMUX_CFG (0x00000018)
114#define DSI_0_PHY_PLL_UNIPHY_PLL_AMUX_CFG (0x0000001C)
115#define DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG (0x00000020)
116#define DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV2_CFG (0x00000024)
117#define DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV3_CFG (0x00000028)
118#define DSI_0_PHY_PLL_UNIPHY_PLL_LPFR_CFG (0x0000002C)
119#define DSI_0_PHY_PLL_UNIPHY_PLL_LPFC1_CFG (0x00000030)
120#define DSI_0_PHY_PLL_UNIPHY_PLL_LPFC2_CFG (0x00000034)
121#define DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG0 (0x00000038)
122#define DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG1 (0x0000003C)
123#define DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG2 (0x00000040)
124#define DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG3 (0x00000044)
125#define DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG4 (0x00000048)
126#define DSI_0_PHY_PLL_UNIPHY_PLL_SSC_CFG0 (0x0000004C)
127#define DSI_0_PHY_PLL_UNIPHY_PLL_SSC_CFG1 (0x00000050)
128#define DSI_0_PHY_PLL_UNIPHY_PLL_SSC_CFG2 (0x00000054)
129#define DSI_0_PHY_PLL_UNIPHY_PLL_SSC_CFG3 (0x00000058)
130#define DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG0 (0x0000005C)
131#define DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG1 (0x00000060)
132#define DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2 (0x00000064)
133#define DSI_0_PHY_PLL_UNIPHY_PLL_TEST_CFG (0x00000068)
134#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG0 (0x0000006C)
135#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG1 (0x00000070)
136#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG2 (0x00000074)
137#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG3 (0x00000078)
138#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG4 (0x0000007C)
139#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG5 (0x00000080)
140#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG6 (0x00000084)
141#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG7 (0x00000088)
142#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG8 (0x0000008C)
143#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG9 (0x00000090)
144#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG10 (0x00000094)
145#define DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG11 (0x00000098)
146#define DSI_0_PHY_PLL_UNIPHY_PLL_EFUSE_CFG (0x0000009C)
147#define DSI_0_PHY_PLL_UNIPHY_PLL_STATUS (0x000000C0)
148
149#define PLL_POLL_MAX_READS 10
150#define PLL_POLL_TIMEOUT_US 50
151
152static long vco_cached_rate;
Chandan Uddaraju09adf322012-08-16 02:55:23 -0700153static unsigned char *mdss_dsi_base;
Matt Wagantall7cf535b2013-02-28 16:16:51 -0800154static unsigned char *gdsc_base;
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700155static struct clk *mdss_ahb_clk;
Chandan Uddaraju09adf322012-08-16 02:55:23 -0700156
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700157static void __iomem *hdmi_phy_base;
158static void __iomem *hdmi_phy_pll_base;
159static unsigned hdmi_pll_on;
160
Matt Wagantall7cf535b2013-02-28 16:16:51 -0800161static int mdss_gdsc_enabled(void)
162{
163 if (!gdsc_base)
164 return 0;
165
166 return !!(readl_relaxed(gdsc_base) & BIT(31));
167}
168
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700169void hdmi_pll_disable(void)
170{
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700171 clk_enable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700172 REG_W(0x0, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
173 udelay(5);
174 REG_W(0x0, hdmi_phy_base + HDMI_PHY_GLB_CFG);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700175 clk_disable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700176
177 hdmi_pll_on = 0;
178} /* hdmi_pll_disable */
179
180int hdmi_pll_enable(void)
181{
182 u32 status;
183 u32 max_reads, timeout_us;
184
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700185 clk_enable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700186 /* Global Enable */
187 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
188 /* Power up power gen */
189 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
190 udelay(350);
191
192 /* PLL Power-Up */
193 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
194 udelay(5);
195 /* Power up PLL LDO */
196 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
197 udelay(350);
198
199 /* PLL Power-Up */
200 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
201 udelay(350);
202
203 /* poll for PLL ready status */
204 max_reads = 20;
205 timeout_us = 100;
206 if (readl_poll_timeout_noirq((hdmi_phy_pll_base + HDMI_UNI_PLL_STATUS),
207 status, ((status & BIT(0)) == 1), max_reads, timeout_us)) {
208 pr_err("%s: hdmi phy pll status=%x failed to Lock\n",
209 __func__, status);
210 hdmi_pll_disable();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700211 clk_disable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700212 return -EINVAL;
213 }
214 pr_debug("%s: hdmi phy pll is locked\n", __func__);
215
216 udelay(350);
217 /* poll for PHY ready status */
218 max_reads = 20;
219 timeout_us = 100;
220 if (readl_poll_timeout_noirq((hdmi_phy_base + HDMI_PHY_STATUS),
221 status, ((status & BIT(0)) == 1), max_reads, timeout_us)) {
222 pr_err("%s: hdmi phy status=%x failed to Lock\n",
223 __func__, status);
224 hdmi_pll_disable();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700225 clk_disable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700226 return -EINVAL;
227 }
228 pr_debug("%s: hdmi phy is locked\n", __func__);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700229 clk_disable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700230
231 hdmi_pll_on = 1;
232
233 return 0;
234} /* hdmi_pll_enable */
235
236int hdmi_pll_set_rate(unsigned long rate)
237{
238 unsigned int set_power_dwn = 0;
239
240 if (hdmi_pll_on) {
241 hdmi_pll_disable();
242 set_power_dwn = 1;
243 }
244
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700245 clk_enable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700246 pr_debug("%s: rate=%ld\n", __func__, rate);
247 switch (rate) {
248 case 0:
249 /* This case is needed for suspend/resume. */
250 break;
251
252 case 25200000:
253 /* 640x480p60 */
Ujwal Patelc8017652012-11-15 18:03:01 -0800254 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
255 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
256 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
257 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
258 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
259 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
260 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
261 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
262 REG_W(0x52, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700263 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
Ujwal Patelc8017652012-11-15 18:03:01 -0800264 REG_W(0xB0, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700265 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
266 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
267 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
268 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
Ujwal Patelc8017652012-11-15 18:03:01 -0800269 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700270 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
271 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
Ujwal Patelc8017652012-11-15 18:03:01 -0800272 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700273 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
274 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
Ujwal Patelc8017652012-11-15 18:03:01 -0800275 REG_W(0xF4, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
276 REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
277 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
278 udelay(50);
279
280 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
281 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
282 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
283 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
284 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
285 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
286 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
287 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
288 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
289 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
290 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
291 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
292 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
293 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
294 udelay(200);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700295 break;
296
Ujwal Patele698fae2012-11-29 14:04:33 -0800297 case 27000000:
298 /* 576p50/576i50 case */
299 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
300 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
301 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
302 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
303 REG_W(0X0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
304 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
305 REG_W(0X0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
306 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
307 REG_W(0x54, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
308 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
309 REG_W(0x18, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
310 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
311 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
312 REG_W(0X1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
313 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
314 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
315 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
316 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
317 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
318 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
319 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
320 REG_W(0x2a, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
321 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
322 REG_W(0X1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
323 udelay(50);
324
325 REG_W(0X0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
326 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
327 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
328 REG_W(0XDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
329 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
330 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
331 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
332 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
333 REG_W(0XD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
334 REG_W(0X1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
335 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
336 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
337 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
338 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
339 udelay(200);
340 break;
341
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700342 case 27030000:
343 /* 480p60/480i60 case */
Ujwal Patelc8017652012-11-15 18:03:01 -0800344 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
345 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
346 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
347 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
348 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
349 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
350 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
351 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
352 REG_W(0x54, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
353 REG_W(0x66, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700354 REG_W(0x1D, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
355 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
356 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
357 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
358 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
359 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
360 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
361 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
Ujwal Patelc8017652012-11-15 18:03:01 -0800362 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700363 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
364 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
365 REG_W(0x2A, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
366 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
Ujwal Patelc8017652012-11-15 18:03:01 -0800367 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
368 udelay(50);
369
370 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
371 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
372 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
373 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
374 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
375 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
376 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
377 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
378 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
379 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
380 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
381 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
382 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
383 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
384 udelay(200);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700385 break;
Manoj Rao6c1d2792013-05-08 11:59:38 -0700386 case 65000000:
387 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
388 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
389 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
390 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
391 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
392 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
393 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
394 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
395 REG_W(0x4F, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
396 REG_W(0x55, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
397 REG_W(0xED, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
398 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
399 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
400 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
401 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
402 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
403 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
404 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
405 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
406 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
407 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
408 REG_W(0x8A, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
409 REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
410 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
411 udelay(50);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700412
Manoj Rao6c1d2792013-05-08 11:59:38 -0700413 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
414 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
415 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
416 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
417 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
418 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
419 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
420 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
421 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
422 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
423 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
424 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
425 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
426 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
427 udelay(200);
428 break;
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700429 case 74250000:
430 /*
431 * 720p60/720p50/1080i60/1080i50
432 * 1080p24/1080p30/1080p25 case
433 */
Ujwal Patelc8017652012-11-15 18:03:01 -0800434 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
435 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
436 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
437 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
438 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
439 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
440 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
441 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700442 REG_W(0x52, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
Ujwal Patelc8017652012-11-15 18:03:01 -0800443 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
444 REG_W(0x56, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700445 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
446 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
447 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
448 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
Ujwal Patelc8017652012-11-15 18:03:01 -0800449 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700450 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
451 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
Ujwal Patelc8017652012-11-15 18:03:01 -0800452 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700453 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
454 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
455 REG_W(0xE6, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
456 REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
Ujwal Patelc8017652012-11-15 18:03:01 -0800457 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
458 udelay(50);
459
460 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
461 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
462 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
463 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
464 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
465 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
466 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
467 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
468 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
469 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
470 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
471 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
472 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
473 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
474 udelay(200);
475 break;
476
Manoj Rao6c1d2792013-05-08 11:59:38 -0700477 case 108000000:
478 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
479 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
480 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
481 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
482 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
483 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
484 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
485 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
486 REG_W(0x5B, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
487 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
488 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
489 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
490 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
491 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
492 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
493 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
494 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
495 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
496 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
497 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
498 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
499 REG_W(0x38, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
500 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
501 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
502 udelay(50);
503
504 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
505 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
506 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
507 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
508 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
509 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
510 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
511 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
512 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
513 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
514 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
515 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
516 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
517 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
518 udelay(200);
519 break;
520
Ujwal Patelc8017652012-11-15 18:03:01 -0800521 case 148500000:
522 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
523 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
524 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
525 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
526 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
527 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
528 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
529 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
530 REG_W(0x52, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
531 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
532 REG_W(0x56, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
533 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
534 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
535 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
536 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
537 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
538 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
539 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
540 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
541 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
542 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
543 REG_W(0xE6, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
544 REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
545 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
546 udelay(50);
547
548 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
549 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
550 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
551 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
552 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
553 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
554 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
555 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
556 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
557 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
558 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
559 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
560 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
561 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
562 udelay(200);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700563 break;
564
Ujwal Patele698fae2012-11-29 14:04:33 -0800565 case 268500000:
566 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
567 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
568 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
569 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
570 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
571 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
572 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
573 REG_W(0x36, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
574 REG_W(0x61, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
575 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
576 REG_W(0xF6, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
577 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
578 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
579 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
580 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
581 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
582 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
583 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
584 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
585 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
586 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
587 REG_W(0x3E, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
588 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
589 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
590 udelay(50);
591
592 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
593 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
594 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
595 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
596 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
597 REG_W(0x05, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
598 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
599 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
600 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
601 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
602 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
603 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
604 REG_W(0x11, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
605 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
606 udelay(200);
607 break;
608
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700609 case 297000000:
Ujwal Patelc8017652012-11-15 18:03:01 -0800610 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
611 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
612 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
613 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
614 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
615 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
616 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
617 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700618 REG_W(0x65, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
Ujwal Patelc8017652012-11-15 18:03:01 -0800619 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700620 REG_W(0xAC, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
621 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
622 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
623 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
624 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
625 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
626 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
627 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
Ujwal Patelc8017652012-11-15 18:03:01 -0800628 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700629 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
630 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
631 REG_W(0xCD, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
632 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
Ujwal Patelc8017652012-11-15 18:03:01 -0800633 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
634 udelay(50);
635
636 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
637 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
638 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
639 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
640 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
641 REG_W(0x06, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
642 REG_W(0x03, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
643 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
644 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
645 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
646 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
647 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
648 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
649 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
650 udelay(200);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700651 break;
652
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700653 default:
654 pr_err("%s: not supported rate=%ld\n", __func__, rate);
655 }
656
657 /* Make sure writes complete before disabling iface clock */
658 mb();
659
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700660 clk_disable(mdss_ahb_clk);
Vikram Mulukutla5d581bd2012-11-30 11:51:41 -0800661
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700662 if (set_power_dwn)
663 hdmi_pll_enable();
664
665 return 0;
666} /* hdmi_pll_set_rate */
667
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700668/* Auto PLL calibaration */
669int mdss_ahb_clk_enable(int enable)
670{
671 int rc = 0;
672
673 /* todo: Ideally, we should enable/disable GDSC whenever we are
674 * attempting to enable/disable MDSS AHB clock.
675 * For now, just return error if GDSC is not enabled.
676 */
677 if (!mdss_gdsc_enabled())
678 return -EPERM;
679
680 if (enable)
681 rc = clk_prepare_enable(mdss_ahb_clk);
682 else
683 clk_disable_unprepare(mdss_ahb_clk);
684
685 return rc;
686}
687
688int set_byte_mux_sel(struct mux_clk *clk, int sel)
689{
690 pr_debug("%s: byte mux set to %s mode\n", __func__,
691 sel ? "indirect" : "direct");
692 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_VREG_CFG,
693 (sel << 1));
694 return 0;
695}
696
697int get_byte_mux_sel(struct mux_clk *clk)
698{
699 int mux_mode;
700
701 if (mdss_ahb_clk_enable(1)) {
702 pr_debug("%s: Failed to enable mdss ahb clock\n", __func__);
703 return 0;
704 }
705
706 mux_mode = DSS_REG_R(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_VREG_CFG)
707 & BIT(1);
708 pr_debug("%s: byte mux mode = %s", __func__,
709 mux_mode ? "indirect" : "direct");
710
711 mdss_ahb_clk_enable(0);
712 return !!mux_mode;
713}
714
715static inline struct dsi_pll_vco_clk *to_vco_clk(struct clk *clk)
716{
717 return container_of(clk, struct dsi_pll_vco_clk, c);
718}
719
720/*
721 * When the display is turned off, the display registers are wiped out.
722 * Temporarily use the prepare ops to restore the register values.
723 *
724*/
725int div_prepare(struct clk *c)
726{
727 struct div_clk *div = to_div_clk(c);
728 /* Restore the divider's value */
729 return div->ops->set_div(div, div->div);
730}
731
732int mux_prepare(struct clk *c)
733{
734 struct mux_clk *mux = to_mux_clk(c);
735 int i, rc, sel = 0;
736
737 rc = mdss_ahb_clk_enable(1);
738 if (rc) {
739 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
740 __func__, rc);
741 return rc;
742 }
743
744 for (i = 0; i < mux->num_parents; i++)
745 if (mux->parents[i].src == c->parent) {
746 sel = mux->parents[i].sel;
747 break;
748 }
749
750 if (i == mux->num_parents) {
751 rc = -EINVAL;
752 goto error;
753 }
754
755 /* Restore the mux source select value */
756 rc = mux->ops->set_mux_sel(mux, sel);
757
758error:
759 mdss_ahb_clk_enable(0);
760 return rc;
761}
762
763static int fixed_4div_set_div(struct div_clk *clk, int div)
764{
765 int rc = 0;
766
767 rc = mdss_ahb_clk_enable(1);
768 if (rc) {
769 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
770 __func__, rc);
771 return rc;
772 }
773
774 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV2_CFG,
775 (div - 1));
776
777 mdss_ahb_clk_enable(0);
778 return 0;
779}
780
781static int fixed_4div_get_div(struct div_clk *clk)
782{
783 int div = 0;
784
785 if (mdss_ahb_clk_enable(1)) {
786 pr_debug("%s: Failed to enable mdss ahb clock\n", __func__);
787 return 1;
788 }
789 div = DSS_REG_R(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV2_CFG);
790 mdss_ahb_clk_enable(0);
791 return div + 1;
792}
793
794static int digital_set_div(struct div_clk *clk, int div)
795{
796 int rc = 0;
797
798 rc = mdss_ahb_clk_enable(1);
799 if (rc) {
800 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
801 __func__, rc);
802 return rc;
803 }
804
805 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV3_CFG,
806 (div - 1));
807
808 mdss_ahb_clk_enable(0);
809 return 0;
810}
811
812static int digital_get_div(struct div_clk *clk)
813{
814 int div = 0;
815
816 if (mdss_ahb_clk_enable(1)) {
817 pr_debug("%s: Failed to enable mdss ahb clock\n", __func__);
818 return 1;
819 }
820 div = DSS_REG_R(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV3_CFG);
821 mdss_ahb_clk_enable(0);
822 return div + 1;
823}
824
825static int analog_set_div(struct div_clk *clk, int div)
826{
827 int rc = 0;
828
829 rc = mdss_ahb_clk_enable(1);
830 if (rc) {
831 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
832 __func__, rc);
833 return rc;
834 }
835
836 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV1_CFG,
837 div - 1);
838
839 mdss_ahb_clk_enable(0);
840 return 0;
841}
842
843static int analog_get_div(struct div_clk *clk)
844{
845 int div = 0;
846
847 if (mdss_ahb_clk_enable(1)) {
848 pr_debug("%s: Failed to enable mdss ahb clock\n", __func__);
849 return 1;
850 }
851 div = DSS_REG_R(mdss_dsi_base,
852 DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV1_CFG) + 1;
853 mdss_ahb_clk_enable(0);
854 return div;
855}
856
Aravind Venkateswaranb38f8302013-06-27 16:49:44 -0700857static void dsi_pll_toggle_lock_detect(void)
858{
859 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2,
860 0x05);
861 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2,
862 0x04);
863 udelay(1);
864 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2,
865 0x05);
866}
867
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700868static int dsi_pll_lock_status(void)
869{
870 u32 status;
871 int pll_locked = 0;
872
873 /* poll for PLL ready status */
874 if (readl_poll_timeout_noirq((mdss_dsi_base +
875 DSI_0_PHY_PLL_UNIPHY_PLL_STATUS),
876 status,
877 ((status & BIT(0)) == 1),
878 PLL_POLL_MAX_READS, PLL_POLL_TIMEOUT_US)) {
879 pr_debug("%s: DSI PLL status=%x failed to Lock\n",
880 __func__, status);
881 pll_locked = 0;
882 } else {
883 pll_locked = 1;
884 }
885
886 return pll_locked;
887}
888
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -0700889static inline int dsi_pll_toggle_lock_detect_and_check_status(void)
890{
891 dsi_pll_toggle_lock_detect();
892 return dsi_pll_lock_status();
893}
894
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700895static void dsi_pll_software_reset(void)
896{
897 /*
898 * Add HW recommended delays after toggling the software
899 * reset bit off and back on.
900 */
901 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_TEST_CFG, 0x01);
902 udelay(1000);
903 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_TEST_CFG, 0x00);
904 udelay(1000);
905}
906
907static int dsi_pll_enable_seq_m(void)
908{
909 int i = 0;
910 int pll_locked = 0;
911
912 dsi_pll_software_reset();
913
914 /*
915 * Add hardware recommended delays between register writes for
916 * the updates to take effect. These delays are necessary for the
917 * PLL to successfully lock
918 */
919 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
920 udelay(200);
921 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
922 udelay(200);
923 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
924 udelay(1000);
925
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -0700926 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700927 for (i = 0; (i < 4) && !pll_locked; i++) {
928 DSS_REG_W(mdss_dsi_base,
929 DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x07);
930 if (i != 0)
931 DSS_REG_W(mdss_dsi_base,
932 DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG1, 0x34);
933 udelay(1);
934 DSS_REG_W(mdss_dsi_base,
935 DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
936 udelay(1000);
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -0700937 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700938 }
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700939
940 if (pll_locked)
941 pr_debug("%s: PLL Locked at attempt #%d\n", __func__, i);
942 else
943 pr_debug("%s: PLL failed to lock after %d attempt(s)\n",
944 __func__, i);
945
946 return pll_locked ? 0 : -EINVAL;
947}
948
949static int dsi_pll_enable_seq_d(void)
950{
951 int pll_locked = 0;
952
953 dsi_pll_software_reset();
954
955 /*
956 * Add hardware recommended delays between register writes for
957 * the updates to take effect. These delays are necessary for the
958 * PLL to successfully lock
959 */
960 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700961 udelay(200);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700962 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700963 udelay(200);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700964 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x07);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700965 udelay(200);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700966 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700967 udelay(200);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700968 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x07);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700969 udelay(200);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700970 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700971 udelay(1000);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700972
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -0700973 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700974 pr_debug("%s: PLL status = %s\n", __func__,
975 pll_locked ? "Locked" : "Unlocked");
976
977 return pll_locked ? 0 : -EINVAL;
978}
979
980static int dsi_pll_enable_seq_f1(void)
981{
982 int pll_locked = 0;
983
984 dsi_pll_software_reset();
985
986 /*
987 * Add hardware recommended delays between register writes for
988 * the updates to take effect. These delays are necessary for the
989 * PLL to successfully lock
990 */
991 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
992 udelay(200);
993 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
994 udelay(200);
995 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
996 udelay(200);
997 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0d);
998 udelay(200);
999 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
1000 udelay(1000);
1001
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -07001002 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001003 pr_debug("%s: PLL status = %s\n", __func__,
1004 pll_locked ? "Locked" : "Unlocked");
1005
1006 return pll_locked ? 0 : -EINVAL;
1007}
1008
1009static int dsi_pll_enable_seq_c(void)
1010{
1011 int pll_locked = 0;
1012
1013 dsi_pll_software_reset();
1014
1015 /*
1016 * Add hardware recommended delays between register writes for
1017 * the updates to take effect. These delays are necessary for the
1018 * PLL to successfully lock
1019 */
1020 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
1021 udelay(200);
1022 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
1023 udelay(200);
1024 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
1025 udelay(1000);
1026
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -07001027 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001028 pr_debug("%s: PLL status = %s\n", __func__,
1029 pll_locked ? "Locked" : "Unlocked");
1030
1031 return pll_locked ? 0 : -EINVAL;
1032}
1033
1034static int dsi_pll_enable_seq_e(void)
1035{
1036 int pll_locked = 0;
1037
1038 dsi_pll_software_reset();
1039
1040 /*
1041 * Add hardware recommended delays between register writes for
1042 * the updates to take effect. These delays are necessary for the
1043 * PLL to successfully lock
1044 */
1045 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
1046 udelay(200);
1047 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
1048 udelay(200);
1049 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0d);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -07001050 udelay(1);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001051 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
1052 udelay(1000);
1053
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -07001054 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001055 pr_debug("%s: PLL status = %s\n", __func__,
1056 pll_locked ? "Locked" : "Unlocked");
1057
1058 return pll_locked ? 0 : -EINVAL;
1059}
1060
1061static int dsi_pll_enable_seq_8974(void)
1062{
1063 int i, rc = 0;
1064 u32 status, max_reads, timeout_us;
1065
1066 dsi_pll_software_reset();
1067
1068 /*
1069 * PLL power up sequence.
1070 * Add necessary delays recommeded by hardware.
1071 */
1072 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
1073 udelay(1000);
1074 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
1075 udelay(1000);
1076 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x07);
1077 udelay(1000);
1078 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
1079 udelay(1000);
1080
1081 for (i = 0; i < 3; i++) {
1082 /* DSI Uniphy lock detect setting */
1083 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2,
1084 0x04);
1085 udelay(100);
1086 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2,
1087 0x05);
1088 udelay(500);
1089 /* poll for PLL ready status */
1090 max_reads = 5;
1091 timeout_us = 100;
1092 if (readl_poll_timeout_noirq((mdss_dsi_base +
1093 DSI_0_PHY_PLL_UNIPHY_PLL_STATUS),
1094 status,
1095 ((status & 0x01) == 1),
1096 max_reads, timeout_us)) {
1097 pr_debug("%s: DSI PLL status=%x failed to Lock\n",
1098 __func__, status);
1099 pr_debug("%s:Trying to power UP PLL again\n",
1100 __func__);
1101 } else {
1102 break;
1103 }
1104
1105 dsi_pll_software_reset();
1106 /*
1107 * PLL power up sequence.
1108 * Add necessary delays recommeded by hardware.
1109 */
1110 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x1);
1111 udelay(1000);
1112 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x5);
1113 udelay(1000);
1114 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x7);
1115 udelay(1000);
1116 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x5);
1117 udelay(1000);
1118 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x7);
1119 udelay(1000);
1120 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0xf);
1121 udelay(2000);
1122
1123 }
1124
1125 if ((status & 0x01) != 1) {
1126 pr_debug("%s: DSI PLL status=%x failed to Lock\n",
1127 __func__, status);
1128 rc = -EINVAL;
1129 goto error;
1130 }
1131
1132 pr_debug("%s: DSI PLL Lock success\n", __func__);
1133
1134error:
1135 return rc;
1136}
1137
1138static int vco_enable(struct clk *c)
1139{
1140 int i, rc = 0;
1141 struct dsi_pll_vco_clk *vco = to_vco_clk(c);
1142
1143 rc = clk_enable(mdss_ahb_clk);
1144 if (rc) {
1145 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
1146 __func__, rc);
1147 return rc;
1148 }
1149
1150 /* Try all enable sequences until one succeeds */
1151 for (i = 0; i < vco->pll_en_seq_cnt; i++) {
1152 rc = vco->pll_enable_seqs[i]();
1153 pr_debug("%s: DSI PLL %s after sequence #%d\n", __func__,
1154 rc ? "unlocked" : "locked", i + 1);
1155 if (!rc)
1156 break;
1157 }
1158 clk_disable(mdss_ahb_clk);
1159
1160 if (rc)
1161 pr_err("%s: DSI PLL failed to lock\n", __func__);
1162
1163 return rc;
1164}
1165
1166static void vco_disable(struct clk *c)
1167{
1168 int rc = 0;
1169
1170 rc = clk_enable(mdss_ahb_clk);
1171 if (rc) {
1172 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
1173 __func__, rc);
1174 return;
1175 }
1176
1177 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x00);
1178
1179 clk_disable(mdss_ahb_clk);
1180 pr_debug("%s: DSI PLL Disabled\n", __func__);
1181 return;
1182}
1183
1184static int vco_set_rate(struct clk *c, unsigned long rate)
1185{
1186 s64 vco_clk_rate = rate;
1187 s32 rem;
1188 s64 refclk_cfg, frac_n_mode, ref_doubler_en_b;
1189 s64 ref_clk_to_pll, div_fbx1000, frac_n_value;
1190 s64 sdm_cfg0, sdm_cfg1, sdm_cfg2, sdm_cfg3;
1191 s64 gen_vco_clk, cal_cfg10, cal_cfg11;
1192 u32 res;
1193 int i, rc = 0;
1194 struct dsi_pll_vco_clk *vco = to_vco_clk(c);
1195
1196 rc = mdss_ahb_clk_enable(1);
1197 if (rc) {
1198 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
1199 __func__, rc);
1200 return rc;
1201 }
1202
1203 /* Configure the Loop filter resistance */
1204 for (i = 0; i < vco->lpfr_lut_size; i++)
1205 if (vco_clk_rate <= vco->lpfr_lut[i].vco_rate)
1206 break;
1207 if (i == vco->lpfr_lut_size) {
1208 pr_err("%s: unable to get loop filter resistance. vco=%ld\n",
1209 __func__, rate);
1210 rc = -EINVAL;
1211 goto error;
1212 }
1213 res = vco->lpfr_lut[i].r;
1214 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LPFR_CFG, res);
1215
1216 /* Loop filter capacitance values : c1 and c2 */
1217 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LPFC1_CFG, 0x70);
1218 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LPFC2_CFG, 0x15);
1219
1220 div_s64_rem(vco_clk_rate, vco->ref_clk_rate, &rem);
1221 if (rem) {
1222 refclk_cfg = 0x1;
1223 frac_n_mode = 1;
1224 ref_doubler_en_b = 0;
1225 } else {
1226 refclk_cfg = 0x0;
1227 frac_n_mode = 0;
1228 ref_doubler_en_b = 1;
1229 }
1230
1231 pr_debug("%s:refclk_cfg = %lld\n", __func__, refclk_cfg);
1232
1233 ref_clk_to_pll = ((vco->ref_clk_rate * 2 * (refclk_cfg))
1234 + (ref_doubler_en_b * vco->ref_clk_rate));
1235 div_fbx1000 = div_s64((vco_clk_rate * 1000), ref_clk_to_pll);
1236
1237 div_s64_rem(div_fbx1000, 1000, &rem);
1238 frac_n_value = div_s64((rem * (1 << 16)), 1000);
1239 gen_vco_clk = div_s64(div_fbx1000 * ref_clk_to_pll, 1000);
1240
1241 pr_debug("%s:ref_clk_to_pll = %lld\n", __func__, ref_clk_to_pll);
1242 pr_debug("%s:div_fb = %lld\n", __func__, div_fbx1000);
1243 pr_debug("%s:frac_n_value = %lld\n", __func__, frac_n_value);
1244
1245 pr_debug("%s:Generated VCO Clock: %lld\n", __func__, gen_vco_clk);
1246 rem = 0;
1247 if (frac_n_mode) {
1248 sdm_cfg0 = (0x0 << 5);
1249 sdm_cfg0 |= (0x0 & 0x3f);
1250 sdm_cfg1 = (div_s64(div_fbx1000, 1000) & 0x3f) - 1;
1251 sdm_cfg3 = div_s64_rem(frac_n_value, 256, &rem);
1252 sdm_cfg2 = rem;
1253 } else {
1254 sdm_cfg0 = (0x1 << 5);
1255 sdm_cfg0 |= (div_s64(div_fbx1000, 1000) & 0x3f) - 1;
1256 sdm_cfg1 = (0x0 & 0x3f);
1257 sdm_cfg2 = 0;
1258 sdm_cfg3 = 0;
1259 }
1260
1261 pr_debug("%s: sdm_cfg0=%lld\n", __func__, sdm_cfg0);
1262 pr_debug("%s: sdm_cfg1=%lld\n", __func__, sdm_cfg1);
1263 pr_debug("%s: sdm_cfg2=%lld\n", __func__, sdm_cfg2);
1264 pr_debug("%s: sdm_cfg3=%lld\n", __func__, sdm_cfg3);
1265
1266 cal_cfg11 = div_s64_rem(gen_vco_clk, 256 * 1000000, &rem);
1267 cal_cfg10 = rem / 1000000;
1268 pr_debug("%s: cal_cfg10=%lld, cal_cfg11=%lld\n", __func__,
1269 cal_cfg10, cal_cfg11);
1270
1271 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CHGPUMP_CFG, 0x02);
1272 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG3, 0x2b);
1273 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG4, 0x66);
1274 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2, 0x05);
1275
1276 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG1,
1277 (u32)(sdm_cfg1 & 0xff));
1278 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG2,
1279 (u32)(sdm_cfg2 & 0xff));
1280 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG3,
1281 (u32)(sdm_cfg3 & 0xff));
1282 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG4, 0x00);
1283
1284 /* Add hardware recommended delay for correct PLL configuration */
1285 udelay(1000);
1286
1287 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_REFCLK_CFG,
1288 (u32)refclk_cfg);
1289 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_PWRGEN_CFG, 0x00);
1290 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_VCOLPF_CFG, 0x71);
1291 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG0,
1292 (u32)sdm_cfg0);
1293 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG0, 0x0a);
1294 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG6, 0x30);
1295 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG7, 0x00);
1296 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG8, 0x60);
1297 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG9, 0x00);
1298 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG10,
1299 (u32)(cal_cfg10 & 0xff));
1300 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG11,
1301 (u32)(cal_cfg11 & 0xff));
1302 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_EFUSE_CFG, 0x20);
1303
1304error:
1305 mdss_ahb_clk_enable(0);
1306 return rc;
1307}
1308
1309/* rate is the bit clk rate */
1310static long vco_round_rate(struct clk *c, unsigned long rate)
1311{
1312 unsigned long rrate = rate;
1313 struct dsi_pll_vco_clk *vco = to_vco_clk(c);
1314
1315 if (rate < vco->min_rate)
1316 rrate = vco->min_rate;
1317 if (rate > vco->max_rate)
1318 rrate = vco->max_rate;
1319
1320 return rrate;
1321}
1322
1323static unsigned long vco_get_rate(struct clk *c)
1324{
1325 u32 sdm0, doubler, sdm_byp_div;
1326 u64 vco_rate;
1327 u32 sdm_dc_off, sdm_freq_seed, sdm2, sdm3;
1328 struct dsi_pll_vco_clk *vco = to_vco_clk(c);
1329 u64 ref_clk = vco->ref_clk_rate;
1330
1331 /* Check to see if the ref clk doubler is enabled */
1332 doubler = DSS_REG_R(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_REFCLK_CFG)
1333 & BIT(0);
1334 ref_clk += (doubler * vco->ref_clk_rate);
1335
1336 /* see if it is integer mode or sdm mode */
1337 sdm0 = DSS_REG_R(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG0);
1338 if (sdm0 & BIT(6)) {
1339 /* integer mode */
1340 sdm_byp_div = (DSS_REG_R(mdss_dsi_base,
1341 DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG0) & 0x3f) + 1;
1342 vco_rate = ref_clk * sdm_byp_div;
1343 } else {
1344 /* sdm mode */
1345 sdm_dc_off = DSS_REG_R(mdss_dsi_base,
1346 DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG1) & 0xFF;
1347 pr_debug("%s: sdm_dc_off = %d\n", __func__, sdm_dc_off);
1348 sdm2 = DSS_REG_R(mdss_dsi_base,
1349 DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG2) & 0xFF;
1350 sdm3 = DSS_REG_R(mdss_dsi_base,
1351 DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG3) & 0xFF;
1352 sdm_freq_seed = (sdm3 << 8) | sdm2;
1353 pr_debug("%s: sdm_freq_seed = %d\n", __func__, sdm_freq_seed);
1354
1355 vco_rate = (ref_clk * (sdm_dc_off + 1)) +
1356 mult_frac(ref_clk, sdm_freq_seed, BIT(16));
1357 pr_debug("%s: vco rate = %lld", __func__, vco_rate);
1358 }
1359
1360 pr_debug("%s: returning vco rate = %lu\n", __func__,
1361 (unsigned long)vco_rate);
1362 return (unsigned long)vco_rate;
1363}
1364
1365static enum handoff vco_handoff(struct clk *c)
1366{
1367 int rc = 0;
1368 enum handoff ret = HANDOFF_DISABLED_CLK;
1369
1370 rc = mdss_ahb_clk_enable(1);
1371 if (rc) {
1372 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
1373 __func__, rc);
1374 return ret;
1375 }
1376 if (dsi_pll_lock_status()) {
1377 c->rate = vco_get_rate(c);
1378 ret = HANDOFF_ENABLED_CLK;
1379 }
1380
1381 mdss_ahb_clk_enable(0);
1382 return ret;
1383}
1384
1385static int vco_prepare(struct clk *c)
1386{
1387 return vco_set_rate(c, vco_cached_rate);
1388}
1389
1390static void vco_unprepare(struct clk *c)
1391{
1392 vco_cached_rate = c->rate;
1393}
1394
1395/* Op structures */
1396
1397static struct clk_ops clk_ops_dsi_vco = {
1398 .enable = vco_enable,
1399 .disable = vco_disable,
1400 .set_rate = vco_set_rate,
1401 .round_rate = vco_round_rate,
1402 .handoff = vco_handoff,
1403 .prepare = vco_prepare,
1404 .unprepare = vco_unprepare,
1405};
1406
1407static struct clk_div_ops fixed_2div_ops;
1408
1409static struct clk_div_ops fixed_4div_ops = {
1410 .set_div = fixed_4div_set_div,
1411 .get_div = fixed_4div_get_div,
1412};
1413
1414static struct clk_div_ops analog_postdiv_ops = {
1415 .set_div = analog_set_div,
1416 .get_div = analog_get_div,
1417};
1418
1419static struct clk_div_ops digital_postdiv_ops = {
1420 .set_div = digital_set_div,
1421 .get_div = digital_get_div,
1422};
1423
1424struct clk_mux_ops byte_mux_ops = {
1425 .set_mux_sel = set_byte_mux_sel,
1426 .get_mux_sel = get_byte_mux_sel,
1427};
1428
1429struct clk_ops byte_mux_clk_ops;
1430
1431static struct clk_ops pixel_clk_src_ops;
1432static struct clk_ops byte_clk_src_ops;
1433static struct clk_ops analog_potsdiv_clk_ops;
1434
1435/* Display clocks */
1436
1437struct dsi_pll_vco_clk dsi_vco_clk_8226 = {
1438 .ref_clk_rate = 19200000,
1439 .min_rate = 350000000,
1440 .max_rate = 750000000,
1441 .pll_en_seq_cnt = 6,
1442 .pll_enable_seqs[0] = dsi_pll_enable_seq_m,
1443 .pll_enable_seqs[1] = dsi_pll_enable_seq_d,
1444 .pll_enable_seqs[2] = dsi_pll_enable_seq_d,
1445 .pll_enable_seqs[3] = dsi_pll_enable_seq_f1,
1446 .pll_enable_seqs[4] = dsi_pll_enable_seq_c,
1447 .pll_enable_seqs[5] = dsi_pll_enable_seq_e,
1448 .lpfr_lut_size = 10,
1449 .lpfr_lut = (struct lpfr_cfg[]){
1450 {479500000, 8},
1451 {480000000, 11},
1452 {575500000, 8},
1453 {576000000, 12},
1454 {610500000, 8},
1455 {659500000, 9},
1456 {671500000, 10},
1457 {672000000, 14},
1458 {708500000, 10},
1459 {750000000, 11},
1460 },
1461 .c = {
1462 .dbg_name = "dsi_vco_clk",
1463 .ops = &clk_ops_dsi_vco,
1464 CLK_INIT(dsi_vco_clk_8226.c),
1465 },
1466};
1467
1468struct div_clk analog_postdiv_clk_8226 = {
1469 .max_div = 255,
1470 .min_div = 1,
1471 .ops = &analog_postdiv_ops,
1472 .c = {
1473 .parent = &dsi_vco_clk_8226.c,
1474 .dbg_name = "analog_postdiv_clk",
1475 .ops = &analog_potsdiv_clk_ops,
1476 .flags = CLKFLAG_NO_RATE_CACHE,
1477 CLK_INIT(analog_postdiv_clk_8226.c),
1478 },
1479};
1480
1481struct div_clk indirect_path_div2_clk_8226 = {
1482 .ops = &fixed_2div_ops,
1483 .div = 2,
1484 .c = {
1485 .parent = &analog_postdiv_clk_8226.c,
1486 .dbg_name = "indirect_path_div2_clk",
1487 .ops = &clk_ops_div,
1488 .flags = CLKFLAG_NO_RATE_CACHE,
1489 CLK_INIT(indirect_path_div2_clk_8226.c),
1490 },
1491};
1492
1493struct div_clk pixel_clk_src_8226 = {
1494 .max_div = 255,
1495 .min_div = 1,
1496 .ops = &digital_postdiv_ops,
1497 .c = {
1498 .parent = &dsi_vco_clk_8226.c,
1499 .dbg_name = "pixel_clk_src",
1500 .ops = &pixel_clk_src_ops,
1501 .flags = CLKFLAG_NO_RATE_CACHE,
1502 CLK_INIT(pixel_clk_src_8226.c),
1503 },
1504};
1505
1506struct mux_clk byte_mux_8226 = {
1507 .num_parents = 2,
1508 .parents = (struct clk_src[]){
1509 {&dsi_vco_clk_8226.c, 0},
1510 {&indirect_path_div2_clk_8226.c, 1},
1511 },
1512 .ops = &byte_mux_ops,
1513 .c = {
1514 .parent = &dsi_vco_clk_8226.c,
1515 .dbg_name = "byte_mux",
1516 .ops = &byte_mux_clk_ops,
1517 CLK_INIT(byte_mux_8226.c),
1518 },
1519};
1520
1521struct div_clk byte_clk_src_8226 = {
1522 .ops = &fixed_4div_ops,
1523 .min_div = 4,
1524 .max_div = 4,
1525 .c = {
1526 .parent = &byte_mux_8226.c,
1527 .dbg_name = "byte_clk_src",
1528 .ops = &byte_clk_src_ops,
1529 CLK_INIT(byte_clk_src_8226.c),
1530 },
1531};
1532
1533struct dsi_pll_vco_clk dsi_vco_clk_8974 = {
1534 .ref_clk_rate = 19200000,
1535 .min_rate = 350000000,
1536 .max_rate = 750000000,
1537 .pll_en_seq_cnt = 3,
1538 .pll_enable_seqs[0] = dsi_pll_enable_seq_8974,
1539 .pll_enable_seqs[1] = dsi_pll_enable_seq_8974,
1540 .pll_enable_seqs[2] = dsi_pll_enable_seq_8974,
1541 .lpfr_lut_size = 10,
1542 .lpfr_lut = (struct lpfr_cfg[]){
1543 {479500000, 8},
1544 {480000000, 11},
1545 {575500000, 8},
1546 {576000000, 12},
1547 {610500000, 8},
1548 {659500000, 9},
1549 {671500000, 10},
1550 {672000000, 14},
1551 {708500000, 10},
1552 {750000000, 11},
1553 },
1554 .c = {
1555 .dbg_name = "dsi_vco_clk",
1556 .ops = &clk_ops_dsi_vco,
1557 CLK_INIT(dsi_vco_clk_8974.c),
1558 },
1559};
1560
1561struct div_clk analog_postdiv_clk_8974 = {
1562 .max_div = 255,
1563 .min_div = 1,
1564 .ops = &analog_postdiv_ops,
1565 .c = {
1566 .parent = &dsi_vco_clk_8974.c,
1567 .dbg_name = "analog_postdiv_clk",
1568 .ops = &analog_potsdiv_clk_ops,
1569 .flags = CLKFLAG_NO_RATE_CACHE,
1570 CLK_INIT(analog_postdiv_clk_8974.c),
1571 },
1572};
1573
1574struct div_clk indirect_path_div2_clk_8974 = {
1575 .ops = &fixed_2div_ops,
1576 .div = 2,
1577 .c = {
1578 .parent = &analog_postdiv_clk_8974.c,
1579 .dbg_name = "indirect_path_div2_clk",
1580 .ops = &clk_ops_div,
1581 .flags = CLKFLAG_NO_RATE_CACHE,
1582 CLK_INIT(indirect_path_div2_clk_8974.c),
1583 },
1584};
1585
1586struct div_clk pixel_clk_src_8974 = {
1587 .max_div = 255,
1588 .min_div = 1,
1589 .ops = &digital_postdiv_ops,
1590 .c = {
1591 .parent = &dsi_vco_clk_8974.c,
1592 .dbg_name = "pixel_clk_src",
1593 .ops = &pixel_clk_src_ops,
1594 .flags = CLKFLAG_NO_RATE_CACHE,
1595 CLK_INIT(pixel_clk_src_8974.c),
1596 },
1597};
1598
1599struct mux_clk byte_mux_8974 = {
1600 .num_parents = 2,
1601 .parents = (struct clk_src[]){
1602 {&dsi_vco_clk_8974.c, 0},
1603 {&indirect_path_div2_clk_8974.c, 1},
1604 },
1605 .ops = &byte_mux_ops,
1606 .c = {
1607 .parent = &dsi_vco_clk_8974.c,
1608 .dbg_name = "byte_mux",
1609 .ops = &byte_mux_clk_ops,
1610 CLK_INIT(byte_mux_8974.c),
1611 },
1612};
1613
1614struct div_clk byte_clk_src_8974 = {
1615 .ops = &fixed_4div_ops,
1616 .min_div = 4,
1617 .max_div = 4,
1618 .c = {
1619 .parent = &byte_mux_8974.c,
1620 .dbg_name = "byte_clk_src",
1621 .ops = &byte_clk_src_ops,
1622 CLK_INIT(byte_clk_src_8974.c),
1623 },
1624};
1625
1626void __init mdss_clk_ctrl_pre_init(struct clk *ahb_clk)
1627{
1628 BUG_ON(ahb_clk == NULL);
1629
1630 gdsc_base = ioremap(GDSC_PHYS, GDSC_SIZE);
1631 if (!gdsc_base)
1632 pr_err("%s: unable to remap gdsc base", __func__);
1633
1634 mdss_dsi_base = ioremap(DSI_PHY_PHYS, DSI_PHY_SIZE);
1635 if (!mdss_dsi_base)
1636 pr_err("%s: unable to remap dsi base", __func__);
1637
1638 mdss_ahb_clk = ahb_clk;
1639
1640 hdmi_phy_base = ioremap(HDMI_PHY_PHYS, HDMI_PHY_SIZE);
1641 if (!hdmi_phy_base)
1642 pr_err("%s: unable to ioremap hdmi phy base", __func__);
1643
1644 hdmi_phy_pll_base = ioremap(HDMI_PHY_PLL_PHYS, HDMI_PHY_PLL_SIZE);
1645 if (!hdmi_phy_pll_base)
1646 pr_err("%s: unable to ioremap hdmi phy pll base", __func__);
1647
1648 pixel_clk_src_ops = clk_ops_slave_div;
1649 pixel_clk_src_ops.prepare = div_prepare;
1650
1651 byte_clk_src_ops = clk_ops_div;
1652 byte_clk_src_ops.prepare = div_prepare;
1653
1654 analog_potsdiv_clk_ops = clk_ops_div;
1655 analog_potsdiv_clk_ops.prepare = div_prepare;
1656
1657 byte_mux_clk_ops = clk_ops_gen_mux;
1658 byte_mux_clk_ops.prepare = mux_prepare;
1659}
1660