blob: e3c44977679be7dd68dbb537d78b49e43527d3a5 [file] [log] [blame]
Dhaval Patele890ef22016-02-08 16:56:05 -08001/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
Dhaval Patelffb7b592015-03-23 23:34:07 -07002 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29#include <debug.h>
30#include <bits.h>
31#include <reg.h>
32#include <err.h>
33#include <smem.h>
34#include <board.h>
35#include <mipi_dsi.h>
36#include <mipi_dsi_autopll_thulium.h>
37#include <platform/iomap.h>
38#include <qtimer.h>
39#include <arch/defines.h>
40
41#define DATALANE_OFFSET_FROM_BASE_THULIUM 0x100
42#define DATALANE_SIZE_THULIUM 0x80
43#define MMSS_DSI_DSIPHY_CMN_LDO_CTRL 0x4c
44
45#define VCO_REF_CLK_RATE 19200000
46
Padmanabhan Komanduru0740fa82016-04-05 16:59:38 +053047#define CEIL(x, y) (((x) + ((y)-1)) / (y))
48
Dhaval Patelffb7b592015-03-23 23:34:07 -070049static void mdss_mdp_pll_input_init(struct dsi_pll_db *pdb)
50{
51 pdb->in.fref = 19200000; /* 19.2 Mhz*/
52 pdb->in.fdata = 0; /* bit clock rate */
53 pdb->in.dsiclk_sel = 1; /* 1, reg: 0x0014 */
Padmanabhan Komanduru0740fa82016-04-05 16:59:38 +053054 pdb->in.ssc_en = 1; /* 1, reg: 0x0494, bit 0 */
Dhaval Patelffb7b592015-03-23 23:34:07 -070055 pdb->in.ldo_en = 0; /* 0, reg: 0x004c, bit 0 */
56
57 /* fixed input */
58 pdb->in.refclk_dbler_en = 0; /* 0, reg: 0x04c0, bit 1 */
59 pdb->in.vco_measure_time = 5; /* 5, unknown */
60 pdb->in.kvco_measure_time = 5; /* 5, unknown */
61 pdb->in.bandgap_timer = 4; /* 4, reg: 0x0430, bit 3 - 5 */
62 pdb->in.pll_wakeup_timer = 5; /* 5, reg: 0x043c, bit 0 - 2 */
63 pdb->in.plllock_cnt = 1; /* 1, reg: 0x0488, bit 1 - 2 */
64 pdb->in.plllock_rng = 0; /* 0, reg: 0x0488, bit 3 - 4 */
65 pdb->in.ssc_center_spread = 0; /* 0, reg: 0x0494, bit 1 */
66 pdb->in.ssc_adj_per = 37; /* 37, reg: 0x498, bit 0 - 9 */
67 pdb->in.ssc_spread = 5; /* 0.005, 5kppm */
68 pdb->in.ssc_freq = 31500; /* 31.5 khz */
69
70 pdb->in.pll_ie_trim = 4; /* 4, reg: 0x0400 */
71 pdb->in.pll_ip_trim = 4; /* 4, reg: 0x0404 */
72 pdb->in.pll_cpcset_cur = 1; /* 1, reg: 0x04f0, bit 0 - 2 */
73 pdb->in.pll_cpmset_cur = 1; /* 1, reg: 0x04f0, bit 3 - 5 */
Sivasri Kumar Vanka9d6ef1c2020-05-11 22:17:24 +053074 pdb->in.pll_icpmset = 7; /* 7, reg: 0x04fc, bit 3 - 5 */
75 pdb->in.pll_icpcset = 7; /* 7, reg: 0x04fc, bit 0 - 2 */
Dhaval Patelffb7b592015-03-23 23:34:07 -070076 pdb->in.pll_icpmset_p = 0; /* 0, reg: 0x04f4, bit 0 - 2 */
77 pdb->in.pll_icpmset_m = 0; /* 0, reg: 0x04f4, bit 3 - 5 */
78 pdb->in.pll_icpcset_p = 0; /* 0, reg: 0x04f8, bit 0 - 2 */
79 pdb->in.pll_icpcset_m = 0; /* 0, reg: 0x04f8, bit 3 - 5 */
80 pdb->in.pll_lpf_res1 = 3; /* 3, reg: 0x0504, bit 0 - 3 */
81 pdb->in.pll_lpf_cap1 = 11; /* 11, reg: 0x0500, bit 0 - 3 */
Chandan Uddaraju5fb979f2016-01-29 10:02:20 -080082 pdb->in.pll_lpf_cap2 = 1; /* 1, reg: 0x0500, bit 4 - 7 */
Dhaval Patelffb7b592015-03-23 23:34:07 -070083 pdb->in.pll_iptat_trim = 7;
84 pdb->in.pll_c3ctrl = 2; /* 2 */
85 pdb->in.pll_r3ctrl = 1; /* 1 */
86}
87
88static void mdss_mdp_pll_dec_frac_calc(struct dsi_pll_db *pdb,
89 uint32_t vco_clk_rate, uint32_t fref)
90{
91 uint64_t vco_clk;
92 uint64_t multiplier = BIT(20);
93 uint64_t dec_start_multiple, dec_start, pll_comp_val;
94 uint32_t duration, div_frac_start;
95
96 vco_clk = vco_clk_rate * multiplier;
97
98 dec_start_multiple = (uint64_t) vco_clk / fref;
99 div_frac_start = (uint32_t) dec_start_multiple % multiplier;
100
101 dec_start = dec_start_multiple / multiplier;
102
103 pdb->out.dec_start = (uint32_t)dec_start;
104 pdb->out.div_frac_start = div_frac_start;
105
106 if (pdb->in.plllock_cnt == 0)
107 duration = 1024;
108 else if (pdb->in.plllock_cnt == 1)
109 duration = 256;
110 else if (pdb->in.plllock_cnt == 2)
111 duration = 128;
112 else
113 duration = 32;
114
115 pll_comp_val = (uint64_t)duration * dec_start_multiple;
116 pll_comp_val /= (multiplier * 10);
117
118 pdb->out.plllock_cmp = (uint32_t)pll_comp_val;
119
120 pdb->out.pll_txclk_en = 1;
Dhaval Patele890ef22016-02-08 16:56:05 -0800121 pdb->out.cmn_ldo_cntrl = 0x3c;
Dhaval Patelffb7b592015-03-23 23:34:07 -0700122}
123
Padmanabhan Komanduru0740fa82016-04-05 16:59:38 +0530124static void mdss_mdp_pll_ssc_calc(struct dsi_pll_db *pdb,
125 uint32_t vco_clk_rate, uint32_t fref)
126{
127 uint32_t period, ssc_period;
128 uint32_t ref, rem;
129 uint64_t step_size;
130
131 ssc_period = pdb->in.ssc_freq / 500;
132 period = (unsigned long)fref / 1000;
133 ssc_period = CEIL(period, ssc_period);
134 ssc_period -= 1;
135 pdb->out.ssc_per = ssc_period;
136
137 step_size = vco_clk_rate;
138 ref = fref;
139
140 ref /= 1000;
141 step_size /= ref;
142 step_size <<= 20;
143 step_size /= 1000;
144 step_size *= pdb->in.ssc_spread;
145 step_size /= 1000;
146 step_size *= (pdb->in.ssc_adj_per + 1);
147
148 rem = 0;
149 rem = step_size % (ssc_period + 1);
150 if (rem)
151 step_size++;
152
153 step_size &= 0x0ffff; /* take lower 16 bits */
154 pdb->out.ssc_step_size = step_size;
155}
156
Dhaval Patelffb7b592015-03-23 23:34:07 -0700157static uint32_t mdss_mdp_pll_kvco_slop(uint32_t vrate)
158{
159 uint32_t slop = 0;
160
161 if (vrate > 1300000000 && vrate <= 1800000000)
162 slop = 600;
163 else if (vrate > 1800000000 && vrate < 2300000000)
164 slop = 400;
165 else if (vrate > 2300000000 && vrate < 2600000000)
166 slop = 280;
167
168 return slop;
169}
170
Ingrid Gallardo2b831f32016-06-15 15:08:08 -0700171static inline uint32_t mdss_mdp_pll_calc_kvco_code(uint32_t vco_clk_rate)
172{
173 uint32_t kvco_code;
174
175 if ((vco_clk_rate >= 2300000000ULL) &&
176 (vco_clk_rate <= 2600000000ULL))
177 kvco_code = 0x2f;
178 else if ((vco_clk_rate >= 1800000000ULL) &&
179 (vco_clk_rate < 2300000000ULL))
180 kvco_code = 0x2c;
181 else
182 kvco_code = 0x28;
183
184 return kvco_code;
185}
186
Dhaval Patelffb7b592015-03-23 23:34:07 -0700187static void mdss_mdp_pll_calc_vco_count(struct dsi_pll_db *pdb,
188 uint32_t vco_clk_rate, uint32_t fref)
189{
190 uint64_t data;
191 uint32_t cnt;
192
193 data = fref * pdb->in.vco_measure_time;
194 data /= 1000000;
195 data &= 0x03ff; /* 10 bits */
196 data -= 2;
197 pdb->out.pll_vco_div_ref = data;
198
199 data = vco_clk_rate / 1000000; /* unit is Mhz */
200 data *= pdb->in.vco_measure_time;
201 data /= 10;
202 pdb->out.pll_vco_count = data; /* reg: 0x0474, 0x0478 */
203
204 data = fref * pdb->in.kvco_measure_time;
205 data /= 1000000;
206 data &= 0x03ff; /* 10 bits */
207 data -= 1;
208 pdb->out.pll_kvco_div_ref = data;
209
210 cnt = mdss_mdp_pll_kvco_slop(vco_clk_rate);
211 cnt *= 2;
212 cnt /= 100;
213 cnt *= pdb->in.kvco_measure_time;
214 pdb->out.pll_kvco_count = cnt;
215
216 pdb->out.pll_misc1 = 16;
Chandan Uddaraju5fb979f2016-01-29 10:02:20 -0800217 pdb->out.pll_resetsm_cntrl = 48;
Dhaval Patelffb7b592015-03-23 23:34:07 -0700218 pdb->out.pll_resetsm_cntrl2 = pdb->in.bandgap_timer << 3;
219 pdb->out.pll_resetsm_cntrl5 = pdb->in.pll_wakeup_timer;
Ingrid Gallardo2b831f32016-06-15 15:08:08 -0700220 pdb->out.pll_kvco_code = mdss_mdp_pll_calc_kvco_code(vco_clk_rate);
Dhaval Patelffb7b592015-03-23 23:34:07 -0700221}
222
223static void mdss_mdp_pll_assert_and_div_cfg(uint32_t phy_base,
224 struct dsi_pll_db *pdb)
225{
226 uint32_t n2div = 0;
227
228 n2div = readl(phy_base + DSIPHY_CMN_CLK_CFG0);
229 n2div &= ~(0xf0);
230 n2div |= (pdb->out.pll_n2div << 4);
231 writel(n2div, phy_base + DSIPHY_CMN_CLK_CFG0);
232
233 dmb();
234}
235
236static void mdss_mdp_pll_nonfreq_config(uint32_t phy_base, struct dsi_pll_db *pdb)
237{
238 uint32_t data;
239
240 writel(pdb->out.cmn_ldo_cntrl, phy_base + DSIPHY_CMN_LDO_CNTRL);
241 writel(0x0, phy_base + DSIPHY_PLL_SYSCLK_EN_RESET);
242
243 data = pdb->out.pll_txclk_en;
244 writel(pdb->out.pll_txclk_en, phy_base + DSIPHY_PLL_TXCLK_EN);
245
246 writel(pdb->out.pll_resetsm_cntrl, phy_base + DSIPHY_PLL_RESETSM_CNTRL);
247 writel(pdb->out.pll_resetsm_cntrl2, phy_base + DSIPHY_PLL_RESETSM_CNTRL2);
248 writel(pdb->out.pll_resetsm_cntrl5, phy_base + DSIPHY_PLL_RESETSM_CNTRL5);
249
250 data = pdb->out.pll_vco_div_ref;
251 data &= 0x0ff;
252 writel(data, phy_base + DSIPHY_PLL_VCO_DIV_REF1);
253 data = (pdb->out.pll_vco_div_ref >> 8);
254 data &= 0x03;
255 writel(data, phy_base + DSIPHY_PLL_VCO_DIV_REF2);
256
257 data = pdb->out.pll_kvco_div_ref;
258 data &= 0x0ff;
259 writel(data, phy_base + DSIPHY_PLL_KVCO_DIV_REF1);
260 data = (pdb->out.pll_kvco_div_ref >> 8);
261 data &= 0x03;
262 writel(data, phy_base + DSIPHY_PLL_KVCO_DIV_REF2);
263
264 writel(pdb->out.pll_misc1, phy_base + DSIPHY_PLL_PLL_MISC1);
265
266 writel(pdb->in.pll_ie_trim, phy_base + DSIPHY_PLL_IE_TRIM);
267
268 writel(pdb->in.pll_ip_trim, phy_base + DSIPHY_PLL_IP_TRIM);
269
270 data = ((pdb->in.pll_cpmset_cur << 3) | pdb->in.pll_cpcset_cur);
271 writel(data, phy_base + DSIPHY_PLL_CP_SET_CUR);
272
273 data = ((pdb->in.pll_icpcset_p << 3) | pdb->in.pll_icpcset_m);
274 writel(data, phy_base + DSIPHY_PLL_PLL_ICPCSET);
275
276 data = ((pdb->in.pll_icpmset_p << 3) | pdb->in.pll_icpcset_m);
277 writel(data, phy_base + DSIPHY_PLL_PLL_ICPMSET);
278
279 data = ((pdb->in.pll_icpmset << 3) | pdb->in.pll_icpcset);
280 writel(data, phy_base + DSIPHY_PLL_PLL_ICP_SET);
281
282 data = ((pdb->in.pll_lpf_cap2 << 4) | pdb->in.pll_lpf_cap1);
283 writel(data, phy_base + DSIPHY_PLL_PLL_LPF1);
284
285 writel(pdb->in.pll_iptat_trim, phy_base + DSIPHY_PLL_IPTAT_TRIM);
286
287 data = (pdb->in.pll_c3ctrl | (pdb->in.pll_r3ctrl << 4));
288 writel(data, phy_base + DSIPHY_PLL_PLL_CRCTRL);
289 dmb();
290}
291
292static void mdss_mdp_pll_freq_config(uint32_t phy_base, struct dsi_pll_db *pdb)
293{
294 uint32_t data;
295
296 writel(0x0, phy_base + DSIPHY_CMN_PLL_CNTRL);
297 /* reset digital block */
298 writel(0x20, phy_base + DSIPHY_CMN_CTRL_1);
299 dmb();
300 udelay(10);
301 writel(0x00, phy_base + DSIPHY_CMN_CTRL_1);
302 dmb();
303
304 writel(pdb->in.dsiclk_sel, phy_base + DSIPHY_CMN_CLK_CFG1);
305 writel(0xff, phy_base + DSIPHY_CMN_CTRL_0);
306 writel(pdb->out.dec_start, phy_base + DSIPHY_PLL_DEC_START);
307
308 data = pdb->out.div_frac_start;
309 data &= 0x0ff;
310 writel(data, phy_base + DSIPHY_PLL_DIV_FRAC_START1);
311 data = (pdb->out.div_frac_start >> 8);
312 data &= 0x0ff;
313 writel(data, phy_base + DSIPHY_PLL_DIV_FRAC_START2);
314 data = (pdb->out.div_frac_start >> 16);
315 data &= 0x0f;
316 writel(data, phy_base + DSIPHY_PLL_DIV_FRAC_START3);
317
318 data = pdb->out.plllock_cmp;
319 data &= 0x0ff;
320 writel(data, phy_base + DSIPHY_PLL_PLLLOCK_CMP1);
321 data = (pdb->out.plllock_cmp >> 8);
322 data &= 0x0ff;
323 writel(data, phy_base + DSIPHY_PLL_PLLLOCK_CMP2);
324 data = (pdb->out.plllock_cmp >> 16);
325 data &= 0x03;
326 writel(data, phy_base + DSIPHY_PLL_PLLLOCK_CMP3);
327
328 data = ((pdb->in.plllock_cnt << 1) | (pdb->in.plllock_rng << 3));
329 writel(data, phy_base + DSIPHY_PLL_PLLLOCK_CMP_EN);
330
331 data = pdb->out.pll_vco_count;
332 data &= 0x0ff;
333 writel(data, phy_base + DSIPHY_PLL_VCO_COUNT1);
334 data = (pdb->out.pll_vco_count >> 8);
335 data &= 0x0ff;
336 writel(data, phy_base + DSIPHY_PLL_VCO_COUNT2);
337
338 data = pdb->out.pll_kvco_count;
339 data &= 0x0ff;
340 writel(data, phy_base + DSIPHY_PLL_KVCO_COUNT1);
341 data = (pdb->out.pll_kvco_count >> 8);
342 data &= 0x03;
343 writel(data, phy_base + DSIPHY_PLL_KVCO_COUNT2);
344
Ingrid Gallardo2b831f32016-06-15 15:08:08 -0700345 data = pdb->out.pll_kvco_code;
346 writel(data, phy_base + DSIPHY_PLL_KVCO_CODE);
347
Dhaval Patelffb7b592015-03-23 23:34:07 -0700348 /*
349 * tx_band = pll_postdiv
350 * 0: divided by 1 <== for now
351 * 1: divided by 2
352 * 2: divided by 4
353 * 3: divided by 8
354 */
355 if (pdb->out.pll_postdiv)
356 data = (((pdb->out.pll_postdiv - 1) << 4) |
357 pdb->in.pll_lpf_res1);
358 else
359 data = pdb->in.pll_lpf_res1;
360 writel(data, phy_base + DSIPHY_PLL_PLL_LPF2_POSTDIV);
361
362 data = (pdb->out.pll_n1div | (pdb->out.pll_n2div << 4));
363 writel(data, phy_base + DSIPHY_CMN_CLK_CFG0);
364
365 dmb(); /* make sure register committed */
366}
367
Padmanabhan Komanduru0740fa82016-04-05 16:59:38 +0530368static void mdss_mdp_pll_ssc_config(uint32_t phy_base, struct dsi_pll_db *pdb)
369{
370 uint32_t data;
371
372 data = pdb->in.ssc_adj_per;
373 data &= 0x0ff;
374 writel(data, phy_base + DSIPHY_PLL_SSC_ADJ_PER1);
375 data = (pdb->in.ssc_adj_per >> 8);
376 data &= 0x03;
377 writel(data, phy_base + DSIPHY_PLL_SSC_ADJ_PER2);
378
379 data = pdb->out.ssc_per;
380 data &= 0x0ff;
381 writel(data, phy_base + DSIPHY_PLL_SSC_PER1);
382 data = (pdb->out.ssc_per >> 8);
383 data &= 0x0ff;
384 writel(data, phy_base + DSIPHY_PLL_SSC_PER2);
385
386 data = pdb->out.ssc_step_size;
387 data &= 0x0ff;
388 writel(data, phy_base + DSIPHY_PLL_SSC_STEP_SIZE1);
389 data = (pdb->out.ssc_step_size >> 8);
390 data &= 0x0ff;
391 writel(data, phy_base + DSIPHY_PLL_SSC_STEP_SIZE2);
392
393 data = (pdb->in.ssc_center_spread & 0x01);
394 data <<= 1;
395 data |= 0x01; /* enable */
396 writel(data, phy_base + DSIPHY_PLL_SSC_EN_CENTER);
397}
398
Dhaval Patelffb7b592015-03-23 23:34:07 -0700399static int mdss_dsi_phy_14nm_init(struct msm_panel_info *pinfo,
400 uint32_t phy_base)
401{
402 struct mdss_dsi_phy_ctrl *pd;
403 struct mipi_panel_info *mipi;
404 int j, off, ln, cnt, ln_off;
405 uint32_t base;
406 uint32_t data;
407
408 mipi = &pinfo->mipi;
409 pd = (mipi->mdss_dsi_phy_db);
410
411 /* Strength ctrl 0 */
412 writel(0x1c, phy_base + MMSS_DSI_DSIPHY_CMN_LDO_CTRL);
413 writel(0x1, phy_base + DSIPHY_CMN_GLBL_TEST_CTRL);
414
415 /* 4 lanes + clk lane configuration */
416 for (ln = 0; ln < 5; ln++) {
417 /*
418 * data lane offset frome base: 0x100
419 * data lane size: 0x80
420 */
421 base = phy_base + DATALANE_OFFSET_FROM_BASE_THULIUM;
422 base += (ln * DATALANE_SIZE_THULIUM); /* lane base */
423
424 /* lane cfg, 4 * 5 */
425 cnt = 4;
426 ln_off = cnt * ln;
427 off = 0x0;
428 for (j = 0; j < cnt; j++, off += 4)
429 writel(pd->laneCfg[ln_off + j], base + off);
430
431 /* test str */
432 writel(0x88, base + 0x14);
433
434 /* phy timing, 8 * 5 */
435 cnt = 8;
436 ln_off = cnt * ln;
437 off = 0x18;
438 for (j = 0; j < cnt; j++, off += 4)
439 writel(pd->timing[ln_off + j], base + off);
440
441 /* strength, 2 * 5 */
442 cnt = 2;
443 ln_off = cnt * ln;
444 off = 0x38;
445 for (j = 0; j < cnt; j++, off += 4)
446 writel(pd->strength[ln_off + j], base + off);
447
448 /* vreg ctrl, 1 * 5 */
449 off = 0x64;
450 writel(pd->regulator[cnt], base + off);
451 }
452 dmb();
453
454 /* reset digital block */
455 writel(0x80, phy_base + DSIPHY_CMN_CTRL_1);
456 dmb();
457 udelay(100);
458 writel(0x00, phy_base + DSIPHY_CMN_CTRL_1);
459
460 if (pinfo->lcdc.split_display) {
461 if (mipi->phy_base == phy_base) {
462 writel(0x3, phy_base + DSIPHY_PLL_CLKBUFLR_EN);
463 data = readl(phy_base + DSIPHY_CMN_GLBL_TEST_CTRL);
464 data &= ~BIT(2);
465 writel(data, phy_base + DSIPHY_CMN_GLBL_TEST_CTRL);
466 } else {
467 writel(0x0, phy_base + DSIPHY_PLL_CLKBUFLR_EN);
468 data = readl(phy_base + DSIPHY_CMN_GLBL_TEST_CTRL);
469 data |= BIT(2);
470 writel(data, phy_base + DSIPHY_CMN_GLBL_TEST_CTRL);
471 writel(0x3, phy_base + DSIPHY_PLL_PLL_BANDGAP);
472 }
473 } else {
474 writel(0x1, phy_base + DSIPHY_PLL_CLKBUFLR_EN);
475 data = readl(phy_base + DSIPHY_CMN_GLBL_TEST_CTRL);
476 data &= ~BIT(2);
477 writel(data, phy_base + DSIPHY_CMN_GLBL_TEST_CTRL);
478 }
479
480 dmb();
481 return 0;
482}
483
484void mdss_dsi_auto_pll_thulium_config(struct msm_panel_info *pinfo)
485{
486 struct dsi_pll_db pdb;
487 struct mdss_dsi_pll_config *pll_data = pinfo->mipi.dsi_pll_config;
488 uint32_t phy_base = pinfo->mipi.phy_base;
489 uint32_t phy_1_base = pinfo->mipi.sphy_base;
490
491 mdss_dsi_phy_sw_reset(pinfo->mipi.ctl_base);
492 if (pinfo->mipi.dual_dsi)
493 mdss_dsi_phy_sw_reset(pinfo->mipi.sctl_base);
494
495 mdss_dsi_phy_14nm_init(pinfo, phy_base);
496 if (pinfo->mipi.dual_dsi)
497 mdss_dsi_phy_14nm_init(pinfo, phy_1_base);
498
499 mdss_mdp_pll_input_init(&pdb);
500 pdb.out.pll_postdiv = pll_data->ndiv;
501 pdb.out.pll_n1div = pll_data->n1div;
502 pdb.out.pll_n2div = pll_data->n2div;
503
504 mdss_mdp_pll_dec_frac_calc(&pdb, pll_data->vco_clock, VCO_REF_CLK_RATE);
Padmanabhan Komanduru0740fa82016-04-05 16:59:38 +0530505 if (pdb.in.ssc_en)
506 mdss_mdp_pll_ssc_calc(&pdb, pll_data->vco_clock,
507 VCO_REF_CLK_RATE);
Dhaval Patelffb7b592015-03-23 23:34:07 -0700508 mdss_mdp_pll_calc_vco_count(&pdb, pll_data->vco_clock, VCO_REF_CLK_RATE);
509
510 /* de-assert pll and start */
511 mdss_mdp_pll_assert_and_div_cfg(phy_base, &pdb);
512 writel(pdb.in.dsiclk_sel, phy_base + DSIPHY_CMN_CLK_CFG1);
513 if (pinfo->lcdc.split_display)
514 mdss_mdp_pll_assert_and_div_cfg(phy_1_base, &pdb);
515
516 /* configure frequence */
517 mdss_mdp_pll_nonfreq_config(phy_base, &pdb);
518 mdss_mdp_pll_freq_config(phy_base, &pdb);
Padmanabhan Komanduru0740fa82016-04-05 16:59:38 +0530519 if (pdb.in.ssc_en)
520 mdss_mdp_pll_ssc_config(phy_base, &pdb);
Dhaval Patelffb7b592015-03-23 23:34:07 -0700521
522 if (pinfo->lcdc.split_display) {
523 mdss_mdp_pll_nonfreq_config(phy_1_base, &pdb);
524 mdss_mdp_pll_freq_config(phy_1_base, &pdb);
Padmanabhan Komanduru0740fa82016-04-05 16:59:38 +0530525 if (pdb.in.ssc_en)
526 mdss_mdp_pll_ssc_config(phy_1_base, &pdb);
Dhaval Patelffb7b592015-03-23 23:34:07 -0700527 }
528}