blob: c147a336c8bd4ebf5d9a886938a04e82f12a43b7 [file] [log] [blame]
Ajay Singh Parmar25c91bb2013-01-23 18:47:04 +05301/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/io.h>
15#include <linux/errno.h>
16#include <linux/delay.h>
17#include <asm/processor.h>
18#include <mach/msm_iomap.h>
19#include "clock-dss-8960.h"
20
21/* HDMI PLL macros */
22#define HDMI_PHY_PLL_REFCLK_CFG (MSM_HDMI_BASE + 0x00000500)
23#define HDMI_PHY_PLL_CHRG_PUMP_CFG (MSM_HDMI_BASE + 0x00000504)
24#define HDMI_PHY_PLL_LOOP_FLT_CFG0 (MSM_HDMI_BASE + 0x00000508)
25#define HDMI_PHY_PLL_LOOP_FLT_CFG1 (MSM_HDMI_BASE + 0x0000050c)
26#define HDMI_PHY_PLL_IDAC_ADJ_CFG (MSM_HDMI_BASE + 0x00000510)
27#define HDMI_PHY_PLL_I_VI_KVCO_CFG (MSM_HDMI_BASE + 0x00000514)
28#define HDMI_PHY_PLL_PWRDN_B (MSM_HDMI_BASE + 0x00000518)
29#define HDMI_PHY_PLL_SDM_CFG0 (MSM_HDMI_BASE + 0x0000051c)
30#define HDMI_PHY_PLL_SDM_CFG1 (MSM_HDMI_BASE + 0x00000520)
31#define HDMI_PHY_PLL_SDM_CFG2 (MSM_HDMI_BASE + 0x00000524)
32#define HDMI_PHY_PLL_SDM_CFG3 (MSM_HDMI_BASE + 0x00000528)
33#define HDMI_PHY_PLL_SDM_CFG4 (MSM_HDMI_BASE + 0x0000052c)
34#define HDMI_PHY_PLL_SSC_CFG0 (MSM_HDMI_BASE + 0x00000530)
35#define HDMI_PHY_PLL_SSC_CFG1 (MSM_HDMI_BASE + 0x00000534)
36#define HDMI_PHY_PLL_SSC_CFG2 (MSM_HDMI_BASE + 0x00000538)
37#define HDMI_PHY_PLL_SSC_CFG3 (MSM_HDMI_BASE + 0x0000053c)
38#define HDMI_PHY_PLL_LOCKDET_CFG0 (MSM_HDMI_BASE + 0x00000540)
39#define HDMI_PHY_PLL_LOCKDET_CFG1 (MSM_HDMI_BASE + 0x00000544)
40#define HDMI_PHY_PLL_LOCKDET_CFG2 (MSM_HDMI_BASE + 0x00000548)
41#define HDMI_PHY_PLL_VCOCAL_CFG0 (MSM_HDMI_BASE + 0x0000054c)
42#define HDMI_PHY_PLL_VCOCAL_CFG1 (MSM_HDMI_BASE + 0x00000550)
43#define HDMI_PHY_PLL_VCOCAL_CFG2 (MSM_HDMI_BASE + 0x00000554)
44#define HDMI_PHY_PLL_VCOCAL_CFG3 (MSM_HDMI_BASE + 0x00000558)
45#define HDMI_PHY_PLL_VCOCAL_CFG4 (MSM_HDMI_BASE + 0x0000055c)
46#define HDMI_PHY_PLL_VCOCAL_CFG5 (MSM_HDMI_BASE + 0x00000560)
47#define HDMI_PHY_PLL_VCOCAL_CFG6 (MSM_HDMI_BASE + 0x00000564)
48#define HDMI_PHY_PLL_VCOCAL_CFG7 (MSM_HDMI_BASE + 0x00000568)
49#define HDMI_PHY_PLL_DEBUG_SEL (MSM_HDMI_BASE + 0x0000056c)
50#define HDMI_PHY_PLL_MISC0 (MSM_HDMI_BASE + 0x00000570)
51#define HDMI_PHY_PLL_MISC1 (MSM_HDMI_BASE + 0x00000574)
52#define HDMI_PHY_PLL_MISC2 (MSM_HDMI_BASE + 0x00000578)
53#define HDMI_PHY_PLL_MISC3 (MSM_HDMI_BASE + 0x0000057c)
54#define HDMI_PHY_PLL_MISC4 (MSM_HDMI_BASE + 0x00000580)
55#define HDMI_PHY_PLL_MISC5 (MSM_HDMI_BASE + 0x00000584)
56#define HDMI_PHY_PLL_MISC6 (MSM_HDMI_BASE + 0x00000588)
57#define HDMI_PHY_PLL_DEBUG_BUS0 (MSM_HDMI_BASE + 0x0000058c)
58#define HDMI_PHY_PLL_DEBUG_BUS1 (MSM_HDMI_BASE + 0x00000590)
59#define HDMI_PHY_PLL_DEBUG_BUS2 (MSM_HDMI_BASE + 0x00000594)
60#define HDMI_PHY_PLL_STATUS0 (MSM_HDMI_BASE + 0x00000598)
61#define HDMI_PHY_PLL_STATUS1 (MSM_HDMI_BASE + 0x0000059c)
62#define HDMI_PHY_CTRL (MSM_HDMI_BASE + 0x000002D4)
63#define HDMI_PHY_REG_0 (MSM_HDMI_BASE + 0x00000400)
64#define HDMI_PHY_REG_1 (MSM_HDMI_BASE + 0x00000404)
65#define HDMI_PHY_REG_2 (MSM_HDMI_BASE + 0x00000408)
66#define HDMI_PHY_REG_3 (MSM_HDMI_BASE + 0x0000040c)
67#define HDMI_PHY_REG_4 (MSM_HDMI_BASE + 0x00000410)
68#define HDMI_PHY_REG_5 (MSM_HDMI_BASE + 0x00000414)
69#define HDMI_PHY_REG_6 (MSM_HDMI_BASE + 0x00000418)
70#define HDMI_PHY_REG_7 (MSM_HDMI_BASE + 0x0000041c)
71#define HDMI_PHY_REG_8 (MSM_HDMI_BASE + 0x00000420)
72#define HDMI_PHY_REG_9 (MSM_HDMI_BASE + 0x00000424)
73#define HDMI_PHY_REG_10 (MSM_HDMI_BASE + 0x00000428)
74#define HDMI_PHY_REG_11 (MSM_HDMI_BASE + 0x0000042c)
75#define HDMI_PHY_REG_12 (MSM_HDMI_BASE + 0x00000430)
76#define HDMI_PHY_REG_BIST_CFG (MSM_HDMI_BASE + 0x00000434)
77#define HDMI_PHY_DEBUG_BUS_SEL (MSM_HDMI_BASE + 0x00000438)
78#define HDMI_PHY_REG_MISC0 (MSM_HDMI_BASE + 0x0000043c)
79#define HDMI_PHY_REG_13 (MSM_HDMI_BASE + 0x00000440)
80#define HDMI_PHY_REG_14 (MSM_HDMI_BASE + 0x00000444)
81#define HDMI_PHY_REG_15 (MSM_HDMI_BASE + 0x00000448)
82
83#define AHB_EN_REG (MSM_MMSS_CLK_CTL_BASE + 0x0008)
84
85/* HDMI PHY/PLL bit field macros */
86#define SW_RESET BIT(2)
87#define SW_RESET_PLL BIT(0)
88#define PWRDN_B BIT(7)
89
90#define PLL_PWRDN_B BIT(3)
91#define PD_PLL BIT(1)
92
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093static unsigned hdmi_pll_on;
94
95int hdmi_pll_enable(void)
96{
97 unsigned int val;
98 u32 ahb_en_reg, ahb_enabled;
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +053099 unsigned int timeout_count;
Ajay Singh Parmaref2d34e2012-06-22 16:38:14 +0530100 int pll_lock_retry = 10;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700101
102 ahb_en_reg = readl_relaxed(AHB_EN_REG);
103 ahb_enabled = ahb_en_reg & BIT(4);
104 if (!ahb_enabled) {
105 writel_relaxed(ahb_en_reg | BIT(4), AHB_EN_REG);
Ravishangar Kalyanam700e3072012-01-19 15:57:54 -0800106 /* Make sure iface clock is enabled before register access */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107 mb();
108 }
109
Ravishangar Kalyanam700e3072012-01-19 15:57:54 -0800110 /* Assert PLL S/W reset */
111 writel_relaxed(0x8D, HDMI_PHY_PLL_LOCKDET_CFG2);
112 writel_relaxed(0x10, HDMI_PHY_PLL_LOCKDET_CFG0);
113 writel_relaxed(0x1A, HDMI_PHY_PLL_LOCKDET_CFG1);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530114 /* Wait for a short time before de-asserting
115 * to allow the hardware to complete its job.
116 * This much of delay should be fine for hardware
117 * to assert and de-assert.
118 */
119 udelay(10);
Ravishangar Kalyanam700e3072012-01-19 15:57:54 -0800120 /* De-assert PLL S/W reset */
121 writel_relaxed(0x0D, HDMI_PHY_PLL_LOCKDET_CFG2);
122
123 val = readl_relaxed(HDMI_PHY_REG_12);
124 val |= BIT(5);
125 /* Assert PHY S/W reset */
126 writel_relaxed(val, HDMI_PHY_REG_12);
127 val &= ~BIT(5);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530128 /* Wait for a short time before de-asserting
129 to allow the hardware to complete its job.
130 This much of delay should be fine for hardware
131 to assert and de-assert. */
132 udelay(10);
Ravishangar Kalyanam700e3072012-01-19 15:57:54 -0800133 /* De-assert PHY S/W reset */
134 writel_relaxed(val, HDMI_PHY_REG_12);
135 writel_relaxed(0x3f, HDMI_PHY_REG_2);
136
137 val = readl_relaxed(HDMI_PHY_REG_12);
138 val |= PWRDN_B;
139 writel_relaxed(val, HDMI_PHY_REG_12);
140 /* Wait 10 us for enabling global power for PHY */
141 mb();
142 udelay(10);
143
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700144 val = readl_relaxed(HDMI_PHY_PLL_PWRDN_B);
145 val |= PLL_PWRDN_B;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700146 val &= ~PD_PLL;
147 writel_relaxed(val, HDMI_PHY_PLL_PWRDN_B);
Ravishangar Kalyanam700e3072012-01-19 15:57:54 -0800148 writel_relaxed(0x80, HDMI_PHY_REG_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700149
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530150 timeout_count = 1000;
151 while (!(readl_relaxed(HDMI_PHY_PLL_STATUS0) & BIT(0)) &&
Ajay Singh Parmaref2d34e2012-06-22 16:38:14 +0530152 timeout_count && pll_lock_retry) {
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530153 if (--timeout_count == 0) {
154 /*
155 * PLL has still not locked.
156 * Do a software reset and try again
157 * Assert PLL S/W reset first
158 */
159 writel_relaxed(0x8D, HDMI_PHY_PLL_LOCKDET_CFG2);
160
161 /* Wait for a short time before de-asserting
162 * to allow the hardware to complete its job.
163 * This much of delay should be fine for hardware
164 * to assert and de-assert.
165 */
166 udelay(10);
167 writel_relaxed(0x0D, HDMI_PHY_PLL_LOCKDET_CFG2);
Aravind Venkateswaran53223912012-07-13 16:32:21 -0700168
169 /*
170 * Wait for a short duration for the PLL calibration
171 * before checking if the PLL gets locked
172 */
173 udelay(350);
174
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530175 timeout_count = 1000;
Ajay Singh Parmaref2d34e2012-06-22 16:38:14 +0530176 pll_lock_retry--;
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530177 }
178 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700179
180 if (!ahb_enabled)
181 writel_relaxed(ahb_en_reg & ~BIT(4), AHB_EN_REG);
Ajay Singh Parmaref2d34e2012-06-22 16:38:14 +0530182
183 if (!pll_lock_retry) {
184 pr_err("%s: HDMI PLL not locked\n", __func__);
Aravind Venkateswaran53223912012-07-13 16:32:21 -0700185 hdmi_pll_disable();
Ajay Singh Parmaref2d34e2012-06-22 16:38:14 +0530186 return -EAGAIN;
187 }
188
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700189 hdmi_pll_on = 1;
190 return 0;
191}
192
193void hdmi_pll_disable(void)
194{
195 unsigned int val;
196 u32 ahb_en_reg, ahb_enabled;
197
198 ahb_en_reg = readl_relaxed(AHB_EN_REG);
199 ahb_enabled = ahb_en_reg & BIT(4);
200 if (!ahb_enabled) {
201 writel_relaxed(ahb_en_reg | BIT(4), AHB_EN_REG);
202 mb();
203 }
204
Ravishangar Kalyanam700e3072012-01-19 15:57:54 -0800205 val = readl_relaxed(HDMI_PHY_REG_12);
206 val &= (~PWRDN_B);
207 writel_relaxed(val, HDMI_PHY_REG_12);
208
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700209 val = readl_relaxed(HDMI_PHY_PLL_PWRDN_B);
210 val |= PD_PLL;
Ravishangar Kalyanam700e3072012-01-19 15:57:54 -0800211 val &= (~PLL_PWRDN_B);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700212 writel_relaxed(val, HDMI_PHY_PLL_PWRDN_B);
Ravishangar Kalyanam700e3072012-01-19 15:57:54 -0800213 /* Make sure HDMI PHY/PLL are powered down */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700214 mb();
215
216 if (!ahb_enabled)
217 writel_relaxed(ahb_en_reg & ~BIT(4), AHB_EN_REG);
218 hdmi_pll_on = 0;
219}
220
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700221int hdmi_pll_set_rate(unsigned rate)
222{
223 unsigned int set_power_dwn = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700224 u32 ahb_en_reg = readl_relaxed(AHB_EN_REG);
225 u32 ahb_enabled = ahb_en_reg & BIT(4);
226
227 if (!ahb_enabled) {
228 writel_relaxed(ahb_en_reg | BIT(4), AHB_EN_REG);
Ravishangar Kalyanam700e3072012-01-19 15:57:54 -0800229 /* Make sure iface clock is enabled before register access */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700230 mb();
231 }
232
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700233 if (hdmi_pll_on) {
234 hdmi_pll_disable();
235 set_power_dwn = 1;
236 }
237
238 switch (rate) {
239 case 27030000:
240 /* 480p60/480i60 case */
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800241 writel_relaxed(0xA, HDMI_PHY_PLL_PWRDN_B);
242 writel_relaxed(0x38, HDMI_PHY_PLL_REFCLK_CFG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700243 writel_relaxed(0x2, HDMI_PHY_PLL_CHRG_PUMP_CFG);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800244 writel_relaxed(0x20, HDMI_PHY_PLL_LOOP_FLT_CFG0);
245 writel_relaxed(0xFF, HDMI_PHY_PLL_LOOP_FLT_CFG1);
246 writel_relaxed(0x00, HDMI_PHY_PLL_SDM_CFG0);
247 writel_relaxed(0x4E, HDMI_PHY_PLL_SDM_CFG1);
248 writel_relaxed(0xD7, HDMI_PHY_PLL_SDM_CFG2);
249 writel_relaxed(0x03, HDMI_PHY_PLL_SDM_CFG3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700250 writel_relaxed(0x00, HDMI_PHY_PLL_SDM_CFG4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700251 writel_relaxed(0x2A, HDMI_PHY_PLL_VCOCAL_CFG0);
252 writel_relaxed(0x03, HDMI_PHY_PLL_VCOCAL_CFG1);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800253 writel_relaxed(0x3B, HDMI_PHY_PLL_VCOCAL_CFG2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700254 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG3);
255 writel_relaxed(0x86, HDMI_PHY_PLL_VCOCAL_CFG4);
256 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG5);
257 writel_relaxed(0x33, HDMI_PHY_PLL_VCOCAL_CFG6);
258 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG7);
259 break;
260
261 case 25200000:
262 /* 640x480p60 */
263 writel_relaxed(0x32, HDMI_PHY_PLL_REFCLK_CFG);
264 writel_relaxed(0x2, HDMI_PHY_PLL_CHRG_PUMP_CFG);
265 writel_relaxed(0x01, HDMI_PHY_PLL_LOOP_FLT_CFG0);
266 writel_relaxed(0x33, HDMI_PHY_PLL_LOOP_FLT_CFG1);
267 writel_relaxed(0x2C, HDMI_PHY_PLL_IDAC_ADJ_CFG);
268 writel_relaxed(0x6, HDMI_PHY_PLL_I_VI_KVCO_CFG);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800269 writel_relaxed(0xA, HDMI_PHY_PLL_PWRDN_B);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700270 writel_relaxed(0x77, HDMI_PHY_PLL_SDM_CFG0);
271 writel_relaxed(0x4C, HDMI_PHY_PLL_SDM_CFG1);
272 writel_relaxed(0x00, HDMI_PHY_PLL_SDM_CFG2);
273 writel_relaxed(0xC0, HDMI_PHY_PLL_SDM_CFG3);
274 writel_relaxed(0x00, HDMI_PHY_PLL_SDM_CFG4);
275 writel_relaxed(0x9A, HDMI_PHY_PLL_SSC_CFG0);
276 writel_relaxed(0x00, HDMI_PHY_PLL_SSC_CFG1);
277 writel_relaxed(0x00, HDMI_PHY_PLL_SSC_CFG2);
278 writel_relaxed(0x20, HDMI_PHY_PLL_SSC_CFG3);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800279 writel_relaxed(0x10, HDMI_PHY_PLL_LOCKDET_CFG0);
280 writel_relaxed(0x1A, HDMI_PHY_PLL_LOCKDET_CFG1);
281 writel_relaxed(0x0D, HDMI_PHY_PLL_LOCKDET_CFG2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700282 writel_relaxed(0xF4, HDMI_PHY_PLL_VCOCAL_CFG0);
283 writel_relaxed(0x02, HDMI_PHY_PLL_VCOCAL_CFG1);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800284 writel_relaxed(0x3B, HDMI_PHY_PLL_VCOCAL_CFG2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700285 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG3);
286 writel_relaxed(0x86, HDMI_PHY_PLL_VCOCAL_CFG4);
287 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG5);
288 writel_relaxed(0x33, HDMI_PHY_PLL_VCOCAL_CFG6);
289 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG7);
290 break;
291
292 case 27000000:
293 /* 576p50/576i50 case */
294 writel_relaxed(0x32, HDMI_PHY_PLL_REFCLK_CFG);
295 writel_relaxed(0x2, HDMI_PHY_PLL_CHRG_PUMP_CFG);
296 writel_relaxed(0x01, HDMI_PHY_PLL_LOOP_FLT_CFG0);
297 writel_relaxed(0x33, HDMI_PHY_PLL_LOOP_FLT_CFG1);
298 writel_relaxed(0x2C, HDMI_PHY_PLL_IDAC_ADJ_CFG);
299 writel_relaxed(0x6, HDMI_PHY_PLL_I_VI_KVCO_CFG);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800300 writel_relaxed(0xA, HDMI_PHY_PLL_PWRDN_B);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700301 writel_relaxed(0x7B, HDMI_PHY_PLL_SDM_CFG0);
302 writel_relaxed(0x01, HDMI_PHY_PLL_SDM_CFG1);
303 writel_relaxed(0x4C, HDMI_PHY_PLL_SDM_CFG2);
304 writel_relaxed(0xC0, HDMI_PHY_PLL_SDM_CFG3);
305 writel_relaxed(0x00, HDMI_PHY_PLL_SDM_CFG4);
306 writel_relaxed(0x9A, HDMI_PHY_PLL_SSC_CFG0);
307 writel_relaxed(0x00, HDMI_PHY_PLL_SSC_CFG1);
308 writel_relaxed(0x00, HDMI_PHY_PLL_SSC_CFG2);
309 writel_relaxed(0x00, HDMI_PHY_PLL_SSC_CFG3);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800310 writel_relaxed(0x10, HDMI_PHY_PLL_LOCKDET_CFG0);
311 writel_relaxed(0x1A, HDMI_PHY_PLL_LOCKDET_CFG1);
312 writel_relaxed(0x0D, HDMI_PHY_PLL_LOCKDET_CFG2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700313 writel_relaxed(0x2a, HDMI_PHY_PLL_VCOCAL_CFG0);
314 writel_relaxed(0x03, HDMI_PHY_PLL_VCOCAL_CFG1);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800315 writel_relaxed(0x3B, HDMI_PHY_PLL_VCOCAL_CFG2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700316 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG3);
317 writel_relaxed(0x86, HDMI_PHY_PLL_VCOCAL_CFG4);
318 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG5);
319 writel_relaxed(0x33, HDMI_PHY_PLL_VCOCAL_CFG6);
320 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG7);
321 break;
322
323 case 74250000:
324 /* 720p60/720p50/1080i60/1080i50
325 * 1080p24/1080p30/1080p25 case
326 */
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800327 writel_relaxed(0xA, HDMI_PHY_PLL_PWRDN_B);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700328 writel_relaxed(0x12, HDMI_PHY_PLL_REFCLK_CFG);
329 writel_relaxed(0x01, HDMI_PHY_PLL_LOOP_FLT_CFG0);
330 writel_relaxed(0x33, HDMI_PHY_PLL_LOOP_FLT_CFG1);
331 writel_relaxed(0x76, HDMI_PHY_PLL_SDM_CFG0);
332 writel_relaxed(0xE6, HDMI_PHY_PLL_VCOCAL_CFG0);
333 writel_relaxed(0x02, HDMI_PHY_PLL_VCOCAL_CFG1);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800334 writel_relaxed(0x3B, HDMI_PHY_PLL_VCOCAL_CFG2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700335 break;
336
Ajay Singh Parmar25c91bb2013-01-23 18:47:04 +0530337 case 108000000:
338 writel_relaxed(0x08, HDMI_PHY_PLL_REFCLK_CFG);
339 writel_relaxed(0x21, HDMI_PHY_PLL_LOOP_FLT_CFG0);
340 writel_relaxed(0xF9, HDMI_PHY_PLL_LOOP_FLT_CFG1);
341 writel_relaxed(0x1C, HDMI_PHY_PLL_VCOCAL_CFG0);
342 writel_relaxed(0x02, HDMI_PHY_PLL_VCOCAL_CFG1);
343 writel_relaxed(0x3B, HDMI_PHY_PLL_VCOCAL_CFG2);
344 writel_relaxed(0x86, HDMI_PHY_PLL_VCOCAL_CFG4);
345 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG5);
346 writel_relaxed(0x49, HDMI_PHY_PLL_SDM_CFG0);
347 writel_relaxed(0x49, HDMI_PHY_PLL_SDM_CFG1);
348 writel_relaxed(0x00, HDMI_PHY_PLL_SDM_CFG2);
349 writel_relaxed(0x00, HDMI_PHY_PLL_SDM_CFG3);
350 writel_relaxed(0x00, HDMI_PHY_PLL_SDM_CFG4);
351 break;
352
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700353 case 148500000:
354 /* 1080p60/1080p50 case */
355 writel_relaxed(0x2, HDMI_PHY_PLL_REFCLK_CFG);
356 writel_relaxed(0x2, HDMI_PHY_PLL_CHRG_PUMP_CFG);
357 writel_relaxed(0x01, HDMI_PHY_PLL_LOOP_FLT_CFG0);
358 writel_relaxed(0x33, HDMI_PHY_PLL_LOOP_FLT_CFG1);
359 writel_relaxed(0x2C, HDMI_PHY_PLL_IDAC_ADJ_CFG);
360 writel_relaxed(0x6, HDMI_PHY_PLL_I_VI_KVCO_CFG);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800361 writel_relaxed(0xA, HDMI_PHY_PLL_PWRDN_B);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700362 writel_relaxed(0x76, HDMI_PHY_PLL_SDM_CFG0);
363 writel_relaxed(0x01, HDMI_PHY_PLL_SDM_CFG1);
364 writel_relaxed(0x4C, HDMI_PHY_PLL_SDM_CFG2);
365 writel_relaxed(0xC0, HDMI_PHY_PLL_SDM_CFG3);
366 writel_relaxed(0x00, HDMI_PHY_PLL_SDM_CFG4);
367 writel_relaxed(0x9A, HDMI_PHY_PLL_SSC_CFG0);
368 writel_relaxed(0x00, HDMI_PHY_PLL_SSC_CFG1);
369 writel_relaxed(0x00, HDMI_PHY_PLL_SSC_CFG2);
370 writel_relaxed(0x00, HDMI_PHY_PLL_SSC_CFG3);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800371 writel_relaxed(0x10, HDMI_PHY_PLL_LOCKDET_CFG0);
372 writel_relaxed(0x1A, HDMI_PHY_PLL_LOCKDET_CFG1);
373 writel_relaxed(0x0D, HDMI_PHY_PLL_LOCKDET_CFG2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700374 writel_relaxed(0xe6, HDMI_PHY_PLL_VCOCAL_CFG0);
375 writel_relaxed(0x02, HDMI_PHY_PLL_VCOCAL_CFG1);
Aravind Venkateswaran6e250f02012-03-01 22:40:45 -0800376 writel_relaxed(0x3B, HDMI_PHY_PLL_VCOCAL_CFG2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700377 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG3);
378 writel_relaxed(0x86, HDMI_PHY_PLL_VCOCAL_CFG4);
379 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG5);
380 writel_relaxed(0x33, HDMI_PHY_PLL_VCOCAL_CFG6);
381 writel_relaxed(0x00, HDMI_PHY_PLL_VCOCAL_CFG7);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700382 break;
383 }
384
Ravishangar Kalyanam700e3072012-01-19 15:57:54 -0800385 /* Make sure writes complete before disabling iface clock */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700386 mb();
387
388 if (set_power_dwn)
389 hdmi_pll_enable();
390
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700391 if (!ahb_enabled)
392 writel_relaxed(ahb_en_reg & ~BIT(4), AHB_EN_REG);
393
394 return 0;
395}