blob: cf2df1875e7ba770458ec7944fc0fa704c386cd9 [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
Huaibin Yang3931cb72013-07-12 10:48:59 -070034#define GDSC_PHYS 0xFD8C2300
35#define GDSC_SIZE 0x8
Matt Wagantall7cf535b2013-02-28 16:16:51 -080036
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
Huaibin Yang3931cb72013-07-12 10:48:59 -0700166 return (readl_relaxed(gdsc_base + 0x4) & BIT(31)) &&
167 (!(readl_relaxed(gdsc_base) & BIT(0)));
Matt Wagantall7cf535b2013-02-28 16:16:51 -0800168}
169
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700170void hdmi_pll_disable(void)
171{
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700172 clk_enable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700173 REG_W(0x0, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
174 udelay(5);
175 REG_W(0x0, hdmi_phy_base + HDMI_PHY_GLB_CFG);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700176 clk_disable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700177
178 hdmi_pll_on = 0;
179} /* hdmi_pll_disable */
180
181int hdmi_pll_enable(void)
182{
183 u32 status;
184 u32 max_reads, timeout_us;
185
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700186 clk_enable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700187 /* Global Enable */
188 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
189 /* Power up power gen */
190 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
191 udelay(350);
192
193 /* PLL Power-Up */
194 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
195 udelay(5);
196 /* Power up PLL LDO */
197 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
198 udelay(350);
199
200 /* PLL Power-Up */
201 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
202 udelay(350);
203
204 /* poll for PLL ready status */
205 max_reads = 20;
206 timeout_us = 100;
207 if (readl_poll_timeout_noirq((hdmi_phy_pll_base + HDMI_UNI_PLL_STATUS),
208 status, ((status & BIT(0)) == 1), max_reads, timeout_us)) {
209 pr_err("%s: hdmi phy pll status=%x failed to Lock\n",
210 __func__, status);
211 hdmi_pll_disable();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700212 clk_disable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700213 return -EINVAL;
214 }
215 pr_debug("%s: hdmi phy pll is locked\n", __func__);
216
217 udelay(350);
218 /* poll for PHY ready status */
219 max_reads = 20;
220 timeout_us = 100;
221 if (readl_poll_timeout_noirq((hdmi_phy_base + HDMI_PHY_STATUS),
222 status, ((status & BIT(0)) == 1), max_reads, timeout_us)) {
223 pr_err("%s: hdmi phy status=%x failed to Lock\n",
224 __func__, status);
225 hdmi_pll_disable();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700226 clk_disable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700227 return -EINVAL;
228 }
229 pr_debug("%s: hdmi phy is locked\n", __func__);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700230 clk_disable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700231
232 hdmi_pll_on = 1;
233
234 return 0;
235} /* hdmi_pll_enable */
236
237int hdmi_pll_set_rate(unsigned long rate)
238{
239 unsigned int set_power_dwn = 0;
240
241 if (hdmi_pll_on) {
242 hdmi_pll_disable();
243 set_power_dwn = 1;
244 }
245
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700246 clk_enable(mdss_ahb_clk);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700247 pr_debug("%s: rate=%ld\n", __func__, rate);
248 switch (rate) {
249 case 0:
250 /* This case is needed for suspend/resume. */
251 break;
252
253 case 25200000:
254 /* 640x480p60 */
Ujwal Patelc8017652012-11-15 18:03:01 -0800255 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
256 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
257 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
258 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
259 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
260 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
261 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
262 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
263 REG_W(0x52, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700264 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
Ujwal Patelc8017652012-11-15 18:03:01 -0800265 REG_W(0xB0, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700266 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
267 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
268 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
269 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
Ujwal Patelc8017652012-11-15 18:03:01 -0800270 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700271 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
272 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
Ujwal Patelc8017652012-11-15 18:03:01 -0800273 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700274 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
275 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
Ujwal Patelc8017652012-11-15 18:03:01 -0800276 REG_W(0xF4, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
277 REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
278 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
279 udelay(50);
280
281 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
282 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
283 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
284 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
285 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
286 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
287 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
288 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
289 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
290 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
291 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
292 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
293 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
294 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
295 udelay(200);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700296 break;
297
Ujwal Patele698fae2012-11-29 14:04:33 -0800298 case 27000000:
299 /* 576p50/576i50 case */
300 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
301 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
302 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
303 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
304 REG_W(0X0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
305 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
306 REG_W(0X0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
307 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
308 REG_W(0x54, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
309 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
310 REG_W(0x18, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
311 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
312 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
313 REG_W(0X1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
314 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
315 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
316 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
317 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
318 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
319 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
320 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
321 REG_W(0x2a, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
322 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
323 REG_W(0X1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
324 udelay(50);
325
326 REG_W(0X0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
327 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
328 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
329 REG_W(0XDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
330 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
331 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
332 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
333 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
334 REG_W(0XD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
335 REG_W(0X1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
336 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
337 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
338 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
339 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
340 udelay(200);
341 break;
342
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700343 case 27030000:
344 /* 480p60/480i60 case */
Ujwal Patelc8017652012-11-15 18:03:01 -0800345 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
346 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
347 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
348 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
349 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
350 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
351 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
352 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
353 REG_W(0x54, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
354 REG_W(0x66, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700355 REG_W(0x1D, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
356 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
357 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
358 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
359 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
360 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
361 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
362 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
Ujwal Patelc8017652012-11-15 18:03:01 -0800363 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700364 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
365 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
366 REG_W(0x2A, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
367 REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
Ujwal Patelc8017652012-11-15 18:03:01 -0800368 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
369 udelay(50);
370
371 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
372 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
373 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
374 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
375 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
376 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
377 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
378 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
379 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
380 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
381 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
382 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
383 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
384 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
385 udelay(200);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700386 break;
Manoj Rao6c1d2792013-05-08 11:59:38 -0700387 case 65000000:
388 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
389 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
390 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
391 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
392 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
393 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
394 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
395 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
396 REG_W(0x4F, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
397 REG_W(0x55, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
398 REG_W(0xED, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
399 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
400 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
401 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
402 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
403 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
404 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
405 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
406 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
407 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
408 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
409 REG_W(0x8A, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
410 REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
411 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
412 udelay(50);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700413
Manoj Rao6c1d2792013-05-08 11:59:38 -0700414 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
415 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
416 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
417 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
418 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
419 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
420 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
421 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
422 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
423 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
424 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
425 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
426 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
427 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
428 udelay(200);
429 break;
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700430 case 74250000:
431 /*
432 * 720p60/720p50/1080i60/1080i50
433 * 1080p24/1080p30/1080p25 case
434 */
Ujwal Patelc8017652012-11-15 18:03:01 -0800435 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
436 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
437 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
438 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
439 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
440 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
441 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
442 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700443 REG_W(0x52, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
Ujwal Patelc8017652012-11-15 18:03:01 -0800444 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
445 REG_W(0x56, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700446 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
447 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
448 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
449 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
Ujwal Patelc8017652012-11-15 18:03:01 -0800450 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700451 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
452 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
Ujwal Patelc8017652012-11-15 18:03:01 -0800453 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700454 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
455 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
456 REG_W(0xE6, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
457 REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
Ujwal Patelc8017652012-11-15 18:03:01 -0800458 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
459 udelay(50);
460
461 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
462 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
463 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
464 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
465 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
466 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
467 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
468 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
469 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
470 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
471 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
472 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
473 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
474 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
475 udelay(200);
476 break;
477
Manoj Rao6c1d2792013-05-08 11:59:38 -0700478 case 108000000:
479 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
480 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
481 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
482 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
483 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
484 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
485 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
486 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
487 REG_W(0x5B, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
488 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
489 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
490 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
491 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
492 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
493 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
494 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
495 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
496 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
497 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
498 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
499 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
500 REG_W(0x38, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
501 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
502 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
503 udelay(50);
504
505 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
506 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
507 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
508 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
509 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
510 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
511 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
512 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
513 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
514 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
515 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
516 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
517 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
518 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
519 udelay(200);
520 break;
521
Ujwal Patelc8017652012-11-15 18:03:01 -0800522 case 148500000:
523 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
524 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
525 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
526 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
527 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
528 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
529 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
530 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
531 REG_W(0x52, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
532 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
533 REG_W(0x56, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
534 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
535 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
536 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
537 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
538 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
539 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
540 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
541 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
542 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
543 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
544 REG_W(0xE6, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
545 REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
546 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
547 udelay(50);
548
549 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
550 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
551 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
552 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
553 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
554 REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
555 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
556 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
557 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
558 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
559 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
560 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
561 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
562 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
563 udelay(200);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700564 break;
565
Ujwal Patele698fae2012-11-29 14:04:33 -0800566 case 268500000:
567 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
568 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
569 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
570 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
571 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
572 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
573 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
574 REG_W(0x36, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
575 REG_W(0x61, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
576 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
577 REG_W(0xF6, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
578 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
579 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
580 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
581 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
582 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
583 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
584 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
585 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
586 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
587 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
588 REG_W(0x3E, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
589 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
590 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
591 udelay(50);
592
593 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
594 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
595 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
596 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
597 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
598 REG_W(0x05, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
599 REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
600 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
601 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
602 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
603 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
604 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
605 REG_W(0x11, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
606 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
607 udelay(200);
608 break;
609
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700610 case 297000000:
Ujwal Patelc8017652012-11-15 18:03:01 -0800611 REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
612 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
613 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
614 REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
615 REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
616 REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
617 REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
618 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700619 REG_W(0x65, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
Ujwal Patelc8017652012-11-15 18:03:01 -0800620 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700621 REG_W(0xAC, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
622 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
623 REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
624 REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
625 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
626 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
627 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
628 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
Ujwal Patelc8017652012-11-15 18:03:01 -0800629 REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700630 REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
631 REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
632 REG_W(0xCD, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
633 REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
Ujwal Patelc8017652012-11-15 18:03:01 -0800634 REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
635 udelay(50);
636
637 REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
638 REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
639 REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
640 REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
641 REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
642 REG_W(0x06, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
643 REG_W(0x03, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
644 REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
645 REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
646 REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
647 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
648 REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
649 REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
650 REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
651 udelay(200);
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700652 break;
653
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700654 default:
655 pr_err("%s: not supported rate=%ld\n", __func__, rate);
656 }
657
658 /* Make sure writes complete before disabling iface clock */
659 mb();
660
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700661 clk_disable(mdss_ahb_clk);
Vikram Mulukutla5d581bd2012-11-30 11:51:41 -0800662
Abhishek Kharbandac1559842012-08-13 18:45:02 -0700663 if (set_power_dwn)
664 hdmi_pll_enable();
665
666 return 0;
667} /* hdmi_pll_set_rate */
668
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700669/* Auto PLL calibaration */
670int mdss_ahb_clk_enable(int enable)
671{
672 int rc = 0;
673
674 /* todo: Ideally, we should enable/disable GDSC whenever we are
675 * attempting to enable/disable MDSS AHB clock.
676 * For now, just return error if GDSC is not enabled.
677 */
678 if (!mdss_gdsc_enabled())
679 return -EPERM;
680
681 if (enable)
682 rc = clk_prepare_enable(mdss_ahb_clk);
683 else
684 clk_disable_unprepare(mdss_ahb_clk);
685
686 return rc;
687}
688
689int set_byte_mux_sel(struct mux_clk *clk, int sel)
690{
691 pr_debug("%s: byte mux set to %s mode\n", __func__,
692 sel ? "indirect" : "direct");
693 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_VREG_CFG,
694 (sel << 1));
695 return 0;
696}
697
698int get_byte_mux_sel(struct mux_clk *clk)
699{
700 int mux_mode;
701
702 if (mdss_ahb_clk_enable(1)) {
703 pr_debug("%s: Failed to enable mdss ahb clock\n", __func__);
704 return 0;
705 }
706
707 mux_mode = DSS_REG_R(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_VREG_CFG)
708 & BIT(1);
709 pr_debug("%s: byte mux mode = %s", __func__,
710 mux_mode ? "indirect" : "direct");
711
712 mdss_ahb_clk_enable(0);
713 return !!mux_mode;
714}
715
716static inline struct dsi_pll_vco_clk *to_vco_clk(struct clk *clk)
717{
718 return container_of(clk, struct dsi_pll_vco_clk, c);
719}
720
721/*
722 * When the display is turned off, the display registers are wiped out.
723 * Temporarily use the prepare ops to restore the register values.
724 *
725*/
726int div_prepare(struct clk *c)
727{
728 struct div_clk *div = to_div_clk(c);
729 /* Restore the divider's value */
730 return div->ops->set_div(div, div->div);
731}
732
733int mux_prepare(struct clk *c)
734{
735 struct mux_clk *mux = to_mux_clk(c);
736 int i, rc, sel = 0;
737
738 rc = mdss_ahb_clk_enable(1);
739 if (rc) {
740 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
741 __func__, rc);
742 return rc;
743 }
744
745 for (i = 0; i < mux->num_parents; i++)
746 if (mux->parents[i].src == c->parent) {
747 sel = mux->parents[i].sel;
748 break;
749 }
750
751 if (i == mux->num_parents) {
752 rc = -EINVAL;
753 goto error;
754 }
755
756 /* Restore the mux source select value */
757 rc = mux->ops->set_mux_sel(mux, sel);
758
759error:
760 mdss_ahb_clk_enable(0);
761 return rc;
762}
763
764static int fixed_4div_set_div(struct div_clk *clk, int div)
765{
766 int rc = 0;
767
768 rc = mdss_ahb_clk_enable(1);
769 if (rc) {
770 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
771 __func__, rc);
772 return rc;
773 }
774
775 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV2_CFG,
776 (div - 1));
777
778 mdss_ahb_clk_enable(0);
779 return 0;
780}
781
782static int fixed_4div_get_div(struct div_clk *clk)
783{
784 int div = 0;
785
786 if (mdss_ahb_clk_enable(1)) {
787 pr_debug("%s: Failed to enable mdss ahb clock\n", __func__);
788 return 1;
789 }
790 div = DSS_REG_R(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV2_CFG);
791 mdss_ahb_clk_enable(0);
792 return div + 1;
793}
794
795static int digital_set_div(struct div_clk *clk, int div)
796{
797 int rc = 0;
798
799 rc = mdss_ahb_clk_enable(1);
800 if (rc) {
801 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
802 __func__, rc);
803 return rc;
804 }
805
806 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV3_CFG,
807 (div - 1));
808
809 mdss_ahb_clk_enable(0);
810 return 0;
811}
812
813static int digital_get_div(struct div_clk *clk)
814{
815 int div = 0;
816
817 if (mdss_ahb_clk_enable(1)) {
818 pr_debug("%s: Failed to enable mdss ahb clock\n", __func__);
819 return 1;
820 }
821 div = DSS_REG_R(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV3_CFG);
822 mdss_ahb_clk_enable(0);
823 return div + 1;
824}
825
826static int analog_set_div(struct div_clk *clk, int div)
827{
828 int rc = 0;
829
830 rc = mdss_ahb_clk_enable(1);
831 if (rc) {
832 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
833 __func__, rc);
834 return rc;
835 }
836
837 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV1_CFG,
838 div - 1);
839
840 mdss_ahb_clk_enable(0);
841 return 0;
842}
843
844static int analog_get_div(struct div_clk *clk)
845{
846 int div = 0;
847
848 if (mdss_ahb_clk_enable(1)) {
849 pr_debug("%s: Failed to enable mdss ahb clock\n", __func__);
850 return 1;
851 }
852 div = DSS_REG_R(mdss_dsi_base,
853 DSI_0_PHY_PLL_UNIPHY_PLL_POSTDIV1_CFG) + 1;
854 mdss_ahb_clk_enable(0);
855 return div;
856}
857
Aravind Venkateswaranb38f8302013-06-27 16:49:44 -0700858static void dsi_pll_toggle_lock_detect(void)
859{
860 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2,
861 0x05);
862 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2,
863 0x04);
864 udelay(1);
865 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2,
866 0x05);
867}
868
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700869static int dsi_pll_lock_status(void)
870{
871 u32 status;
872 int pll_locked = 0;
873
874 /* poll for PLL ready status */
875 if (readl_poll_timeout_noirq((mdss_dsi_base +
876 DSI_0_PHY_PLL_UNIPHY_PLL_STATUS),
877 status,
878 ((status & BIT(0)) == 1),
879 PLL_POLL_MAX_READS, PLL_POLL_TIMEOUT_US)) {
880 pr_debug("%s: DSI PLL status=%x failed to Lock\n",
881 __func__, status);
882 pll_locked = 0;
883 } else {
884 pll_locked = 1;
885 }
886
887 return pll_locked;
888}
889
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -0700890static inline int dsi_pll_toggle_lock_detect_and_check_status(void)
891{
892 dsi_pll_toggle_lock_detect();
893 return dsi_pll_lock_status();
894}
895
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700896static void dsi_pll_software_reset(void)
897{
898 /*
899 * Add HW recommended delays after toggling the software
900 * reset bit off and back on.
901 */
902 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_TEST_CFG, 0x01);
903 udelay(1000);
904 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_TEST_CFG, 0x00);
905 udelay(1000);
906}
907
908static int dsi_pll_enable_seq_m(void)
909{
910 int i = 0;
911 int pll_locked = 0;
912
913 dsi_pll_software_reset();
914
915 /*
916 * Add hardware recommended delays between register writes for
917 * the updates to take effect. These delays are necessary for the
918 * PLL to successfully lock
919 */
920 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
921 udelay(200);
922 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
923 udelay(200);
924 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
925 udelay(1000);
926
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -0700927 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700928 for (i = 0; (i < 4) && !pll_locked; i++) {
929 DSS_REG_W(mdss_dsi_base,
930 DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x07);
931 if (i != 0)
932 DSS_REG_W(mdss_dsi_base,
933 DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG1, 0x34);
934 udelay(1);
935 DSS_REG_W(mdss_dsi_base,
936 DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
937 udelay(1000);
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -0700938 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700939 }
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700940
941 if (pll_locked)
942 pr_debug("%s: PLL Locked at attempt #%d\n", __func__, i);
943 else
944 pr_debug("%s: PLL failed to lock after %d attempt(s)\n",
945 __func__, i);
946
947 return pll_locked ? 0 : -EINVAL;
948}
949
950static int dsi_pll_enable_seq_d(void)
951{
952 int pll_locked = 0;
953
954 dsi_pll_software_reset();
955
956 /*
957 * Add hardware recommended delays between register writes for
958 * the updates to take effect. These delays are necessary for the
959 * PLL to successfully lock
960 */
961 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700962 udelay(200);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700963 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700964 udelay(200);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700965 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x07);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700966 udelay(200);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700967 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700968 udelay(200);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700969 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x07);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700970 udelay(200);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700971 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -0700972 udelay(1000);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700973
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -0700974 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -0700975 pr_debug("%s: PLL status = %s\n", __func__,
976 pll_locked ? "Locked" : "Unlocked");
977
978 return pll_locked ? 0 : -EINVAL;
979}
980
981static int dsi_pll_enable_seq_f1(void)
982{
983 int pll_locked = 0;
984
985 dsi_pll_software_reset();
986
987 /*
988 * Add hardware recommended delays between register writes for
989 * the updates to take effect. These delays are necessary for the
990 * PLL to successfully lock
991 */
992 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
993 udelay(200);
994 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
995 udelay(200);
996 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
997 udelay(200);
998 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0d);
999 udelay(200);
1000 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
1001 udelay(1000);
1002
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -07001003 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001004 pr_debug("%s: PLL status = %s\n", __func__,
1005 pll_locked ? "Locked" : "Unlocked");
1006
1007 return pll_locked ? 0 : -EINVAL;
1008}
1009
1010static int dsi_pll_enable_seq_c(void)
1011{
1012 int pll_locked = 0;
1013
1014 dsi_pll_software_reset();
1015
1016 /*
1017 * Add hardware recommended delays between register writes for
1018 * the updates to take effect. These delays are necessary for the
1019 * PLL to successfully lock
1020 */
1021 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
1022 udelay(200);
1023 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
1024 udelay(200);
1025 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
1026 udelay(1000);
1027
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -07001028 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001029 pr_debug("%s: PLL status = %s\n", __func__,
1030 pll_locked ? "Locked" : "Unlocked");
1031
1032 return pll_locked ? 0 : -EINVAL;
1033}
1034
1035static int dsi_pll_enable_seq_e(void)
1036{
1037 int pll_locked = 0;
1038
1039 dsi_pll_software_reset();
1040
1041 /*
1042 * Add hardware recommended delays between register writes for
1043 * the updates to take effect. These delays are necessary for the
1044 * PLL to successfully lock
1045 */
1046 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
1047 udelay(200);
1048 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
1049 udelay(200);
1050 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0d);
Aravind Venkateswarand3f41e52013-06-18 12:07:14 -07001051 udelay(1);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001052 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
1053 udelay(1000);
1054
Aravind Venkateswaranfe2fa6e2013-07-06 22:42:58 -07001055 pll_locked = dsi_pll_toggle_lock_detect_and_check_status();
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001056 pr_debug("%s: PLL status = %s\n", __func__,
1057 pll_locked ? "Locked" : "Unlocked");
1058
1059 return pll_locked ? 0 : -EINVAL;
1060}
1061
1062static int dsi_pll_enable_seq_8974(void)
1063{
1064 int i, rc = 0;
1065 u32 status, max_reads, timeout_us;
1066
1067 dsi_pll_software_reset();
1068
1069 /*
1070 * PLL power up sequence.
1071 * Add necessary delays recommeded by hardware.
1072 */
1073 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x01);
1074 udelay(1000);
1075 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x05);
1076 udelay(1000);
1077 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x07);
1078 udelay(1000);
1079 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x0f);
1080 udelay(1000);
1081
1082 for (i = 0; i < 3; i++) {
1083 /* DSI Uniphy lock detect setting */
1084 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2,
1085 0x04);
1086 udelay(100);
1087 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2,
1088 0x05);
1089 udelay(500);
1090 /* poll for PLL ready status */
1091 max_reads = 5;
1092 timeout_us = 100;
1093 if (readl_poll_timeout_noirq((mdss_dsi_base +
1094 DSI_0_PHY_PLL_UNIPHY_PLL_STATUS),
1095 status,
1096 ((status & 0x01) == 1),
1097 max_reads, timeout_us)) {
1098 pr_debug("%s: DSI PLL status=%x failed to Lock\n",
1099 __func__, status);
1100 pr_debug("%s:Trying to power UP PLL again\n",
1101 __func__);
1102 } else {
1103 break;
1104 }
1105
1106 dsi_pll_software_reset();
1107 /*
1108 * PLL power up sequence.
1109 * Add necessary delays recommeded by hardware.
1110 */
1111 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x1);
1112 udelay(1000);
1113 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x5);
1114 udelay(1000);
1115 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x7);
1116 udelay(1000);
1117 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x5);
1118 udelay(1000);
1119 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x7);
1120 udelay(1000);
1121 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0xf);
1122 udelay(2000);
1123
1124 }
1125
1126 if ((status & 0x01) != 1) {
1127 pr_debug("%s: DSI PLL status=%x failed to Lock\n",
1128 __func__, status);
1129 rc = -EINVAL;
1130 goto error;
1131 }
1132
1133 pr_debug("%s: DSI PLL Lock success\n", __func__);
1134
1135error:
1136 return rc;
1137}
1138
Aravind Venkateswaranae7c52f2013-07-13 14:47:14 -07001139static int dsi_pll_enable(struct clk *c)
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001140{
1141 int i, rc = 0;
1142 struct dsi_pll_vco_clk *vco = to_vco_clk(c);
1143
Huaibin Yang3931cb72013-07-12 10:48:59 -07001144 if (!mdss_gdsc_enabled()) {
1145 pr_err("%s: mdss GDSC is not enabled\n", __func__);
1146 return -EPERM;
1147 }
1148
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001149 rc = clk_enable(mdss_ahb_clk);
1150 if (rc) {
1151 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
1152 __func__, rc);
1153 return rc;
1154 }
1155
1156 /* Try all enable sequences until one succeeds */
1157 for (i = 0; i < vco->pll_en_seq_cnt; i++) {
1158 rc = vco->pll_enable_seqs[i]();
1159 pr_debug("%s: DSI PLL %s after sequence #%d\n", __func__,
1160 rc ? "unlocked" : "locked", i + 1);
1161 if (!rc)
1162 break;
1163 }
1164 clk_disable(mdss_ahb_clk);
1165
1166 if (rc)
1167 pr_err("%s: DSI PLL failed to lock\n", __func__);
1168
1169 return rc;
1170}
1171
Aravind Venkateswaranae7c52f2013-07-13 14:47:14 -07001172static void dsi_pll_disable(struct clk *c)
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001173{
1174 int rc = 0;
1175
Huaibin Yang3931cb72013-07-12 10:48:59 -07001176 if (!mdss_gdsc_enabled()) {
1177 pr_warn("%s: mdss GDSC disabled before disabling DSI PLL\n",
1178 __func__);
1179 return;
1180 }
1181
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001182 rc = clk_enable(mdss_ahb_clk);
1183 if (rc) {
1184 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
1185 __func__, rc);
1186 return;
1187 }
1188
1189 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_GLB_CFG, 0x00);
1190
1191 clk_disable(mdss_ahb_clk);
1192 pr_debug("%s: DSI PLL Disabled\n", __func__);
1193 return;
1194}
1195
1196static int vco_set_rate(struct clk *c, unsigned long rate)
1197{
1198 s64 vco_clk_rate = rate;
1199 s32 rem;
1200 s64 refclk_cfg, frac_n_mode, ref_doubler_en_b;
1201 s64 ref_clk_to_pll, div_fbx1000, frac_n_value;
1202 s64 sdm_cfg0, sdm_cfg1, sdm_cfg2, sdm_cfg3;
1203 s64 gen_vco_clk, cal_cfg10, cal_cfg11;
1204 u32 res;
1205 int i, rc = 0;
1206 struct dsi_pll_vco_clk *vco = to_vco_clk(c);
1207
1208 rc = mdss_ahb_clk_enable(1);
1209 if (rc) {
1210 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
1211 __func__, rc);
1212 return rc;
1213 }
1214
1215 /* Configure the Loop filter resistance */
1216 for (i = 0; i < vco->lpfr_lut_size; i++)
1217 if (vco_clk_rate <= vco->lpfr_lut[i].vco_rate)
1218 break;
1219 if (i == vco->lpfr_lut_size) {
1220 pr_err("%s: unable to get loop filter resistance. vco=%ld\n",
1221 __func__, rate);
1222 rc = -EINVAL;
1223 goto error;
1224 }
1225 res = vco->lpfr_lut[i].r;
1226 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LPFR_CFG, res);
1227
1228 /* Loop filter capacitance values : c1 and c2 */
1229 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LPFC1_CFG, 0x70);
1230 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LPFC2_CFG, 0x15);
1231
1232 div_s64_rem(vco_clk_rate, vco->ref_clk_rate, &rem);
1233 if (rem) {
1234 refclk_cfg = 0x1;
1235 frac_n_mode = 1;
1236 ref_doubler_en_b = 0;
1237 } else {
1238 refclk_cfg = 0x0;
1239 frac_n_mode = 0;
1240 ref_doubler_en_b = 1;
1241 }
1242
1243 pr_debug("%s:refclk_cfg = %lld\n", __func__, refclk_cfg);
1244
1245 ref_clk_to_pll = ((vco->ref_clk_rate * 2 * (refclk_cfg))
1246 + (ref_doubler_en_b * vco->ref_clk_rate));
1247 div_fbx1000 = div_s64((vco_clk_rate * 1000), ref_clk_to_pll);
1248
1249 div_s64_rem(div_fbx1000, 1000, &rem);
1250 frac_n_value = div_s64((rem * (1 << 16)), 1000);
1251 gen_vco_clk = div_s64(div_fbx1000 * ref_clk_to_pll, 1000);
1252
1253 pr_debug("%s:ref_clk_to_pll = %lld\n", __func__, ref_clk_to_pll);
1254 pr_debug("%s:div_fb = %lld\n", __func__, div_fbx1000);
1255 pr_debug("%s:frac_n_value = %lld\n", __func__, frac_n_value);
1256
1257 pr_debug("%s:Generated VCO Clock: %lld\n", __func__, gen_vco_clk);
1258 rem = 0;
1259 if (frac_n_mode) {
1260 sdm_cfg0 = (0x0 << 5);
1261 sdm_cfg0 |= (0x0 & 0x3f);
1262 sdm_cfg1 = (div_s64(div_fbx1000, 1000) & 0x3f) - 1;
1263 sdm_cfg3 = div_s64_rem(frac_n_value, 256, &rem);
1264 sdm_cfg2 = rem;
1265 } else {
1266 sdm_cfg0 = (0x1 << 5);
1267 sdm_cfg0 |= (div_s64(div_fbx1000, 1000) & 0x3f) - 1;
1268 sdm_cfg1 = (0x0 & 0x3f);
1269 sdm_cfg2 = 0;
1270 sdm_cfg3 = 0;
1271 }
1272
1273 pr_debug("%s: sdm_cfg0=%lld\n", __func__, sdm_cfg0);
1274 pr_debug("%s: sdm_cfg1=%lld\n", __func__, sdm_cfg1);
1275 pr_debug("%s: sdm_cfg2=%lld\n", __func__, sdm_cfg2);
1276 pr_debug("%s: sdm_cfg3=%lld\n", __func__, sdm_cfg3);
1277
1278 cal_cfg11 = div_s64_rem(gen_vco_clk, 256 * 1000000, &rem);
1279 cal_cfg10 = rem / 1000000;
1280 pr_debug("%s: cal_cfg10=%lld, cal_cfg11=%lld\n", __func__,
1281 cal_cfg10, cal_cfg11);
1282
1283 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CHGPUMP_CFG, 0x02);
1284 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG3, 0x2b);
1285 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG4, 0x66);
1286 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_LKDET_CFG2, 0x05);
1287
1288 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG1,
1289 (u32)(sdm_cfg1 & 0xff));
1290 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG2,
1291 (u32)(sdm_cfg2 & 0xff));
1292 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG3,
1293 (u32)(sdm_cfg3 & 0xff));
1294 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG4, 0x00);
1295
1296 /* Add hardware recommended delay for correct PLL configuration */
1297 udelay(1000);
1298
1299 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_REFCLK_CFG,
1300 (u32)refclk_cfg);
1301 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_PWRGEN_CFG, 0x00);
1302 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_VCOLPF_CFG, 0x71);
1303 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG0,
1304 (u32)sdm_cfg0);
1305 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG0, 0x0a);
1306 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG6, 0x30);
1307 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG7, 0x00);
1308 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG8, 0x60);
1309 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG9, 0x00);
1310 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG10,
1311 (u32)(cal_cfg10 & 0xff));
1312 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_CAL_CFG11,
1313 (u32)(cal_cfg11 & 0xff));
1314 DSS_REG_W(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_EFUSE_CFG, 0x20);
1315
1316error:
1317 mdss_ahb_clk_enable(0);
1318 return rc;
1319}
1320
1321/* rate is the bit clk rate */
1322static long vco_round_rate(struct clk *c, unsigned long rate)
1323{
1324 unsigned long rrate = rate;
1325 struct dsi_pll_vco_clk *vco = to_vco_clk(c);
1326
1327 if (rate < vco->min_rate)
1328 rrate = vco->min_rate;
1329 if (rate > vco->max_rate)
1330 rrate = vco->max_rate;
1331
1332 return rrate;
1333}
1334
1335static unsigned long vco_get_rate(struct clk *c)
1336{
1337 u32 sdm0, doubler, sdm_byp_div;
1338 u64 vco_rate;
1339 u32 sdm_dc_off, sdm_freq_seed, sdm2, sdm3;
1340 struct dsi_pll_vco_clk *vco = to_vco_clk(c);
1341 u64 ref_clk = vco->ref_clk_rate;
1342
1343 /* Check to see if the ref clk doubler is enabled */
1344 doubler = DSS_REG_R(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_REFCLK_CFG)
1345 & BIT(0);
1346 ref_clk += (doubler * vco->ref_clk_rate);
1347
1348 /* see if it is integer mode or sdm mode */
1349 sdm0 = DSS_REG_R(mdss_dsi_base, DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG0);
1350 if (sdm0 & BIT(6)) {
1351 /* integer mode */
1352 sdm_byp_div = (DSS_REG_R(mdss_dsi_base,
1353 DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG0) & 0x3f) + 1;
1354 vco_rate = ref_clk * sdm_byp_div;
1355 } else {
1356 /* sdm mode */
1357 sdm_dc_off = DSS_REG_R(mdss_dsi_base,
1358 DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG1) & 0xFF;
1359 pr_debug("%s: sdm_dc_off = %d\n", __func__, sdm_dc_off);
1360 sdm2 = DSS_REG_R(mdss_dsi_base,
1361 DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG2) & 0xFF;
1362 sdm3 = DSS_REG_R(mdss_dsi_base,
1363 DSI_0_PHY_PLL_UNIPHY_PLL_SDM_CFG3) & 0xFF;
1364 sdm_freq_seed = (sdm3 << 8) | sdm2;
1365 pr_debug("%s: sdm_freq_seed = %d\n", __func__, sdm_freq_seed);
1366
1367 vco_rate = (ref_clk * (sdm_dc_off + 1)) +
1368 mult_frac(ref_clk, sdm_freq_seed, BIT(16));
1369 pr_debug("%s: vco rate = %lld", __func__, vco_rate);
1370 }
1371
1372 pr_debug("%s: returning vco rate = %lu\n", __func__,
1373 (unsigned long)vco_rate);
1374 return (unsigned long)vco_rate;
1375}
1376
1377static enum handoff vco_handoff(struct clk *c)
1378{
1379 int rc = 0;
1380 enum handoff ret = HANDOFF_DISABLED_CLK;
1381
1382 rc = mdss_ahb_clk_enable(1);
1383 if (rc) {
1384 pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
1385 __func__, rc);
1386 return ret;
1387 }
1388 if (dsi_pll_lock_status()) {
1389 c->rate = vco_get_rate(c);
1390 ret = HANDOFF_ENABLED_CLK;
1391 }
1392
1393 mdss_ahb_clk_enable(0);
1394 return ret;
1395}
1396
1397static int vco_prepare(struct clk *c)
1398{
Aravind Venkateswaranae7c52f2013-07-13 14:47:14 -07001399 int rc = 0;
1400
Chandan Uddaraju834d4832013-08-27 13:18:08 -07001401 if ((vco_cached_rate != 0)
1402 && (vco_cached_rate == c->rate)) {
Aravind Venkateswaranae7c52f2013-07-13 14:47:14 -07001403 rc = vco_set_rate(c, vco_cached_rate);
1404 if (rc) {
1405 pr_err("%s: vco_set_rate failed. rc=%d\n",
1406 __func__, rc);
1407 goto error;
1408 }
1409 }
1410
1411 rc = dsi_pll_enable(c);
1412
1413error:
1414 return rc;
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001415}
1416
1417static void vco_unprepare(struct clk *c)
1418{
1419 vco_cached_rate = c->rate;
Aravind Venkateswaranae7c52f2013-07-13 14:47:14 -07001420 dsi_pll_disable(c);
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001421}
1422
1423/* Op structures */
1424
1425static struct clk_ops clk_ops_dsi_vco = {
Vikram Mulukutla853e2fa2013-05-02 20:02:13 -07001426 .set_rate = vco_set_rate,
1427 .round_rate = vco_round_rate,
1428 .handoff = vco_handoff,
1429 .prepare = vco_prepare,
1430 .unprepare = vco_unprepare,
1431};
1432
1433static struct clk_div_ops fixed_2div_ops;
1434
1435static struct clk_div_ops fixed_4div_ops = {
1436 .set_div = fixed_4div_set_div,
1437 .get_div = fixed_4div_get_div,
1438};
1439
1440static struct clk_div_ops analog_postdiv_ops = {
1441 .set_div = analog_set_div,
1442 .get_div = analog_get_div,
1443};
1444
1445static struct clk_div_ops digital_postdiv_ops = {
1446 .set_div = digital_set_div,
1447 .get_div = digital_get_div,
1448};
1449
1450struct clk_mux_ops byte_mux_ops = {
1451 .set_mux_sel = set_byte_mux_sel,
1452 .get_mux_sel = get_byte_mux_sel,
1453};
1454
1455struct clk_ops byte_mux_clk_ops;
1456
1457static struct clk_ops pixel_clk_src_ops;
1458static struct clk_ops byte_clk_src_ops;
1459static struct clk_ops analog_potsdiv_clk_ops;
1460
1461/* Display clocks */
1462
1463struct dsi_pll_vco_clk dsi_vco_clk_8226 = {
1464 .ref_clk_rate = 19200000,
1465 .min_rate = 350000000,
1466 .max_rate = 750000000,
1467 .pll_en_seq_cnt = 6,
1468 .pll_enable_seqs[0] = dsi_pll_enable_seq_m,
1469 .pll_enable_seqs[1] = dsi_pll_enable_seq_d,
1470 .pll_enable_seqs[2] = dsi_pll_enable_seq_d,
1471 .pll_enable_seqs[3] = dsi_pll_enable_seq_f1,
1472 .pll_enable_seqs[4] = dsi_pll_enable_seq_c,
1473 .pll_enable_seqs[5] = dsi_pll_enable_seq_e,
1474 .lpfr_lut_size = 10,
1475 .lpfr_lut = (struct lpfr_cfg[]){
1476 {479500000, 8},
1477 {480000000, 11},
1478 {575500000, 8},
1479 {576000000, 12},
1480 {610500000, 8},
1481 {659500000, 9},
1482 {671500000, 10},
1483 {672000000, 14},
1484 {708500000, 10},
1485 {750000000, 11},
1486 },
1487 .c = {
1488 .dbg_name = "dsi_vco_clk",
1489 .ops = &clk_ops_dsi_vco,
1490 CLK_INIT(dsi_vco_clk_8226.c),
1491 },
1492};
1493
1494struct div_clk analog_postdiv_clk_8226 = {
1495 .max_div = 255,
1496 .min_div = 1,
1497 .ops = &analog_postdiv_ops,
1498 .c = {
1499 .parent = &dsi_vco_clk_8226.c,
1500 .dbg_name = "analog_postdiv_clk",
1501 .ops = &analog_potsdiv_clk_ops,
1502 .flags = CLKFLAG_NO_RATE_CACHE,
1503 CLK_INIT(analog_postdiv_clk_8226.c),
1504 },
1505};
1506
1507struct div_clk indirect_path_div2_clk_8226 = {
1508 .ops = &fixed_2div_ops,
1509 .div = 2,
1510 .c = {
1511 .parent = &analog_postdiv_clk_8226.c,
1512 .dbg_name = "indirect_path_div2_clk",
1513 .ops = &clk_ops_div,
1514 .flags = CLKFLAG_NO_RATE_CACHE,
1515 CLK_INIT(indirect_path_div2_clk_8226.c),
1516 },
1517};
1518
1519struct div_clk pixel_clk_src_8226 = {
1520 .max_div = 255,
1521 .min_div = 1,
1522 .ops = &digital_postdiv_ops,
1523 .c = {
1524 .parent = &dsi_vco_clk_8226.c,
1525 .dbg_name = "pixel_clk_src",
1526 .ops = &pixel_clk_src_ops,
1527 .flags = CLKFLAG_NO_RATE_CACHE,
1528 CLK_INIT(pixel_clk_src_8226.c),
1529 },
1530};
1531
1532struct mux_clk byte_mux_8226 = {
1533 .num_parents = 2,
1534 .parents = (struct clk_src[]){
1535 {&dsi_vco_clk_8226.c, 0},
1536 {&indirect_path_div2_clk_8226.c, 1},
1537 },
1538 .ops = &byte_mux_ops,
1539 .c = {
1540 .parent = &dsi_vco_clk_8226.c,
1541 .dbg_name = "byte_mux",
1542 .ops = &byte_mux_clk_ops,
1543 CLK_INIT(byte_mux_8226.c),
1544 },
1545};
1546
1547struct div_clk byte_clk_src_8226 = {
1548 .ops = &fixed_4div_ops,
1549 .min_div = 4,
1550 .max_div = 4,
1551 .c = {
1552 .parent = &byte_mux_8226.c,
1553 .dbg_name = "byte_clk_src",
1554 .ops = &byte_clk_src_ops,
1555 CLK_INIT(byte_clk_src_8226.c),
1556 },
1557};
1558
1559struct dsi_pll_vco_clk dsi_vco_clk_8974 = {
1560 .ref_clk_rate = 19200000,
1561 .min_rate = 350000000,
1562 .max_rate = 750000000,
1563 .pll_en_seq_cnt = 3,
1564 .pll_enable_seqs[0] = dsi_pll_enable_seq_8974,
1565 .pll_enable_seqs[1] = dsi_pll_enable_seq_8974,
1566 .pll_enable_seqs[2] = dsi_pll_enable_seq_8974,
1567 .lpfr_lut_size = 10,
1568 .lpfr_lut = (struct lpfr_cfg[]){
1569 {479500000, 8},
1570 {480000000, 11},
1571 {575500000, 8},
1572 {576000000, 12},
1573 {610500000, 8},
1574 {659500000, 9},
1575 {671500000, 10},
1576 {672000000, 14},
1577 {708500000, 10},
1578 {750000000, 11},
1579 },
1580 .c = {
1581 .dbg_name = "dsi_vco_clk",
1582 .ops = &clk_ops_dsi_vco,
1583 CLK_INIT(dsi_vco_clk_8974.c),
1584 },
1585};
1586
1587struct div_clk analog_postdiv_clk_8974 = {
1588 .max_div = 255,
1589 .min_div = 1,
1590 .ops = &analog_postdiv_ops,
1591 .c = {
1592 .parent = &dsi_vco_clk_8974.c,
1593 .dbg_name = "analog_postdiv_clk",
1594 .ops = &analog_potsdiv_clk_ops,
1595 .flags = CLKFLAG_NO_RATE_CACHE,
1596 CLK_INIT(analog_postdiv_clk_8974.c),
1597 },
1598};
1599
1600struct div_clk indirect_path_div2_clk_8974 = {
1601 .ops = &fixed_2div_ops,
1602 .div = 2,
1603 .c = {
1604 .parent = &analog_postdiv_clk_8974.c,
1605 .dbg_name = "indirect_path_div2_clk",
1606 .ops = &clk_ops_div,
1607 .flags = CLKFLAG_NO_RATE_CACHE,
1608 CLK_INIT(indirect_path_div2_clk_8974.c),
1609 },
1610};
1611
1612struct div_clk pixel_clk_src_8974 = {
1613 .max_div = 255,
1614 .min_div = 1,
1615 .ops = &digital_postdiv_ops,
1616 .c = {
1617 .parent = &dsi_vco_clk_8974.c,
1618 .dbg_name = "pixel_clk_src",
1619 .ops = &pixel_clk_src_ops,
1620 .flags = CLKFLAG_NO_RATE_CACHE,
1621 CLK_INIT(pixel_clk_src_8974.c),
1622 },
1623};
1624
1625struct mux_clk byte_mux_8974 = {
1626 .num_parents = 2,
1627 .parents = (struct clk_src[]){
1628 {&dsi_vco_clk_8974.c, 0},
1629 {&indirect_path_div2_clk_8974.c, 1},
1630 },
1631 .ops = &byte_mux_ops,
1632 .c = {
1633 .parent = &dsi_vco_clk_8974.c,
1634 .dbg_name = "byte_mux",
1635 .ops = &byte_mux_clk_ops,
1636 CLK_INIT(byte_mux_8974.c),
1637 },
1638};
1639
1640struct div_clk byte_clk_src_8974 = {
1641 .ops = &fixed_4div_ops,
1642 .min_div = 4,
1643 .max_div = 4,
1644 .c = {
1645 .parent = &byte_mux_8974.c,
1646 .dbg_name = "byte_clk_src",
1647 .ops = &byte_clk_src_ops,
1648 CLK_INIT(byte_clk_src_8974.c),
1649 },
1650};
1651
1652void __init mdss_clk_ctrl_pre_init(struct clk *ahb_clk)
1653{
1654 BUG_ON(ahb_clk == NULL);
1655
1656 gdsc_base = ioremap(GDSC_PHYS, GDSC_SIZE);
1657 if (!gdsc_base)
1658 pr_err("%s: unable to remap gdsc base", __func__);
1659
1660 mdss_dsi_base = ioremap(DSI_PHY_PHYS, DSI_PHY_SIZE);
1661 if (!mdss_dsi_base)
1662 pr_err("%s: unable to remap dsi base", __func__);
1663
1664 mdss_ahb_clk = ahb_clk;
1665
1666 hdmi_phy_base = ioremap(HDMI_PHY_PHYS, HDMI_PHY_SIZE);
1667 if (!hdmi_phy_base)
1668 pr_err("%s: unable to ioremap hdmi phy base", __func__);
1669
1670 hdmi_phy_pll_base = ioremap(HDMI_PHY_PLL_PHYS, HDMI_PHY_PLL_SIZE);
1671 if (!hdmi_phy_pll_base)
1672 pr_err("%s: unable to ioremap hdmi phy pll base", __func__);
1673
1674 pixel_clk_src_ops = clk_ops_slave_div;
1675 pixel_clk_src_ops.prepare = div_prepare;
1676
1677 byte_clk_src_ops = clk_ops_div;
1678 byte_clk_src_ops.prepare = div_prepare;
1679
1680 analog_potsdiv_clk_ops = clk_ops_div;
1681 analog_potsdiv_clk_ops.prepare = div_prepare;
1682
1683 byte_mux_clk_ops = clk_ops_gen_mux;
1684 byte_mux_clk_ops.prepare = mux_prepare;
1685}
1686