aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2014-10-22 07:49:14 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2014-11-12 06:40:24 -0500
commit2daea7af772ef22d902614fdd1af3bc54c82aae1 (patch)
tree5a0452e93e7fc544eec19fea99c110a40e2ce8c0 /drivers/video
parent0a20170aa5ef1c4935663d88cbfc17b682326fc0 (diff)
OMAPDSS: DSI: use common DSS PLL support
Now that we have the common DSS PLL support, change DSI to use it. This results in quite a lot of changes, but almost all of them are trivial name changes. The functions to calculate and program the PLL settings can be removed from dsi.c, as the common PLL API contains the same functionality. We also need to create struct dss_pll_hw entries for PLL hardware features for different OMAP platforms, instead of using the dss_features.c as the old code does. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/fbdev/omap2/dss/dispc.c20
-rw-r--r--drivers/video/fbdev/omap2/dss/dpi.c82
-rw-r--r--drivers/video/fbdev/omap2/dss/dsi.c566
-rw-r--r--drivers/video/fbdev/omap2/dss/dss.h76
4 files changed, 255 insertions, 489 deletions
diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index 0e9a74bb9fc2..0729c08ac75a 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -3028,7 +3028,7 @@ static void dispc_mgr_get_lcd_divisor(enum omap_channel channel, int *lck_div,
3028 3028
3029unsigned long dispc_fclk_rate(void) 3029unsigned long dispc_fclk_rate(void)
3030{ 3030{
3031 struct platform_device *dsidev; 3031 struct dss_pll *pll;
3032 unsigned long r = 0; 3032 unsigned long r = 0;
3033 3033
3034 switch (dss_get_dispc_clk_source()) { 3034 switch (dss_get_dispc_clk_source()) {
@@ -3036,12 +3036,12 @@ unsigned long dispc_fclk_rate(void)
3036 r = dss_get_dispc_clk_rate(); 3036 r = dss_get_dispc_clk_rate();
3037 break; 3037 break;
3038 case OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC: 3038 case OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC:
3039 dsidev = dsi_get_dsidev_from_id(0); 3039 pll = dss_pll_find("dsi0");
3040 r = dsi_get_pll_hsdiv_dispc_rate(dsidev); 3040 r = pll->cinfo.clkout[0];
3041 break; 3041 break;
3042 case OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC: 3042 case OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC:
3043 dsidev = dsi_get_dsidev_from_id(1); 3043 pll = dss_pll_find("dsi1");
3044 r = dsi_get_pll_hsdiv_dispc_rate(dsidev); 3044 r = pll->cinfo.clkout[0];
3045 break; 3045 break;
3046 default: 3046 default:
3047 BUG(); 3047 BUG();
@@ -3053,7 +3053,7 @@ unsigned long dispc_fclk_rate(void)
3053 3053
3054unsigned long dispc_mgr_lclk_rate(enum omap_channel channel) 3054unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
3055{ 3055{
3056 struct platform_device *dsidev; 3056 struct dss_pll *pll;
3057 int lcd; 3057 int lcd;
3058 unsigned long r; 3058 unsigned long r;
3059 u32 l; 3059 u32 l;
@@ -3068,12 +3068,12 @@ unsigned long dispc_mgr_lclk_rate(enum omap_channel channel)
3068 r = dss_get_dispc_clk_rate(); 3068 r = dss_get_dispc_clk_rate();
3069 break; 3069 break;
3070 case OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC: 3070 case OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC:
3071 dsidev = dsi_get_dsidev_from_id(0); 3071 pll = dss_pll_find("dsi0");
3072 r = dsi_get_pll_hsdiv_dispc_rate(dsidev); 3072 r = pll->cinfo.clkout[0];
3073 break; 3073 break;
3074 case OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC: 3074 case OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC:
3075 dsidev = dsi_get_dsidev_from_id(1); 3075 pll = dss_pll_find("dsi1");
3076 r = dsi_get_pll_hsdiv_dispc_rate(dsidev); 3076 r = pll->cinfo.clkout[0];
3077 break; 3077 break;
3078 default: 3078 default:
3079 BUG(); 3079 BUG();
diff --git a/drivers/video/fbdev/omap2/dss/dpi.c b/drivers/video/fbdev/omap2/dss/dpi.c
index 81dd5e61e75e..2edf5caa002f 100644
--- a/drivers/video/fbdev/omap2/dss/dpi.c
+++ b/drivers/video/fbdev/omap2/dss/dpi.c
@@ -31,6 +31,7 @@
31#include <linux/regulator/consumer.h> 31#include <linux/regulator/consumer.h>
32#include <linux/string.h> 32#include <linux/string.h>
33#include <linux/of.h> 33#include <linux/of.h>
34#include <linux/clk.h>
34 35
35#include <video/omapdss.h> 36#include <video/omapdss.h>
36 37
@@ -43,7 +44,7 @@ struct dpi_data {
43 struct platform_device *pdev; 44 struct platform_device *pdev;
44 45
45 struct regulator *vdds_dsi_reg; 46 struct regulator *vdds_dsi_reg;
46 struct platform_device *dsidev; 47 struct dss_pll *pll;
47 48
48 struct mutex lock; 49 struct mutex lock;
49 50
@@ -67,7 +68,7 @@ static struct dpi_data *dpi_get_data_from_pdev(struct platform_device *pdev)
67 return dev_get_drvdata(&pdev->dev); 68 return dev_get_drvdata(&pdev->dev);
68} 69}
69 70
70static struct platform_device *dpi_get_dsidev(enum omap_channel channel) 71static struct dss_pll *dpi_get_pll(enum omap_channel channel)
71{ 72{
72 /* 73 /*
73 * XXX we can't currently use DSI PLL for DPI with OMAP3, as the DSI PLL 74 * XXX we can't currently use DSI PLL for DPI with OMAP3, as the DSI PLL
@@ -88,9 +89,9 @@ static struct platform_device *dpi_get_dsidev(enum omap_channel channel)
88 case OMAPDSS_VER_OMAP4: 89 case OMAPDSS_VER_OMAP4:
89 switch (channel) { 90 switch (channel) {
90 case OMAP_DSS_CHANNEL_LCD: 91 case OMAP_DSS_CHANNEL_LCD:
91 return dsi_get_dsidev_from_id(0); 92 return dss_pll_find("dsi0");
92 case OMAP_DSS_CHANNEL_LCD2: 93 case OMAP_DSS_CHANNEL_LCD2:
93 return dsi_get_dsidev_from_id(1); 94 return dss_pll_find("dsi1");
94 default: 95 default:
95 return NULL; 96 return NULL;
96 } 97 }
@@ -98,9 +99,9 @@ static struct platform_device *dpi_get_dsidev(enum omap_channel channel)
98 case OMAPDSS_VER_OMAP5: 99 case OMAPDSS_VER_OMAP5:
99 switch (channel) { 100 switch (channel) {
100 case OMAP_DSS_CHANNEL_LCD: 101 case OMAP_DSS_CHANNEL_LCD:
101 return dsi_get_dsidev_from_id(0); 102 return dss_pll_find("dsi0");
102 case OMAP_DSS_CHANNEL_LCD3: 103 case OMAP_DSS_CHANNEL_LCD3:
103 return dsi_get_dsidev_from_id(1); 104 return dss_pll_find("dsi1");
104 default: 105 default:
105 return NULL; 106 return NULL;
106 } 107 }
@@ -127,7 +128,7 @@ static enum omap_dss_clk_source dpi_get_alt_clk_src(enum omap_channel channel)
127} 128}
128 129
129struct dpi_clk_calc_ctx { 130struct dpi_clk_calc_ctx {
130 struct platform_device *dsidev; 131 struct dss_pll *pll;
131 132
132 /* inputs */ 133 /* inputs */
133 134
@@ -135,7 +136,7 @@ struct dpi_clk_calc_ctx {
135 136
136 /* outputs */ 137 /* outputs */
137 138
138 struct dsi_clock_info dsi_cinfo; 139 struct dss_pll_clock_info dsi_cinfo;
139 unsigned long fck; 140 unsigned long fck;
140 struct dispc_clock_info dispc_cinfo; 141 struct dispc_clock_info dispc_cinfo;
141}; 142};
@@ -167,7 +168,7 @@ static bool dpi_calc_dispc_cb(int lckd, int pckd, unsigned long lck,
167} 168}
168 169
169 170
170static bool dpi_calc_hsdiv_cb(int regm_dispc, unsigned long dispc, 171static bool dpi_calc_hsdiv_cb(int m_dispc, unsigned long dispc,
171 void *data) 172 void *data)
172{ 173{
173 struct dpi_clk_calc_ctx *ctx = data; 174 struct dpi_clk_calc_ctx *ctx = data;
@@ -177,10 +178,10 @@ static bool dpi_calc_hsdiv_cb(int regm_dispc, unsigned long dispc,
177 * shifted. So skip all odd dividers when the pixel clock is on the 178 * shifted. So skip all odd dividers when the pixel clock is on the
178 * higher side. 179 * higher side.
179 */ 180 */
180 if (regm_dispc > 1 && regm_dispc % 2 != 0 && ctx->pck_min >= 100000000) 181 if (m_dispc > 1 && m_dispc % 2 != 0 && ctx->pck_min >= 100000000)
181 return false; 182 return false;
182 183
183 ctx->dsi_cinfo.regm_hsdiv[HSDIV_DISPC] = regm_dispc; 184 ctx->dsi_cinfo.mX[HSDIV_DISPC] = m_dispc;
184 ctx->dsi_cinfo.clkout[HSDIV_DISPC] = dispc; 185 ctx->dsi_cinfo.clkout[HSDIV_DISPC] = dispc;
185 186
186 return dispc_div_calc(dispc, ctx->pck_min, ctx->pck_max, 187 return dispc_div_calc(dispc, ctx->pck_min, ctx->pck_max,
@@ -188,19 +189,20 @@ static bool dpi_calc_hsdiv_cb(int regm_dispc, unsigned long dispc,
188} 189}
189 190
190 191
191static bool dpi_calc_pll_cb(int regn, int regm, unsigned long fint, 192static bool dpi_calc_pll_cb(int n, int m, unsigned long fint,
192 unsigned long pll, 193 unsigned long clkdco,
193 void *data) 194 void *data)
194{ 195{
195 struct dpi_clk_calc_ctx *ctx = data; 196 struct dpi_clk_calc_ctx *ctx = data;
196 197
197 ctx->dsi_cinfo.regn = regn; 198 ctx->dsi_cinfo.n = n;
198 ctx->dsi_cinfo.regm = regm; 199 ctx->dsi_cinfo.m = m;
199 ctx->dsi_cinfo.fint = fint; 200 ctx->dsi_cinfo.fint = fint;
200 ctx->dsi_cinfo.clkdco = pll; 201 ctx->dsi_cinfo.clkdco = clkdco;
201 202
202 return dsi_hsdiv_calc(ctx->dsidev, pll, ctx->pck_min, 203 return dss_pll_hsdiv_calc(ctx->pll, clkdco,
203 dpi_calc_hsdiv_cb, ctx); 204 ctx->pck_min, dss_feat_get_param_max(FEAT_PARAM_DSS_FCK),
205 dpi_calc_hsdiv_cb, ctx);
204} 206}
205 207
206static bool dpi_calc_dss_cb(unsigned long fck, void *data) 208static bool dpi_calc_dss_cb(unsigned long fck, void *data)
@@ -219,17 +221,17 @@ static bool dpi_dsi_clk_calc(struct dpi_data *dpi, unsigned long pck,
219 unsigned long clkin; 221 unsigned long clkin;
220 unsigned long pll_min, pll_max; 222 unsigned long pll_min, pll_max;
221 223
222 clkin = dsi_get_pll_clkin(dpi->dsidev);
223
224 memset(ctx, 0, sizeof(*ctx)); 224 memset(ctx, 0, sizeof(*ctx));
225 ctx->dsidev = dpi->dsidev; 225 ctx->pll = dpi->pll;
226 ctx->pck_min = pck - 1000; 226 ctx->pck_min = pck - 1000;
227 ctx->pck_max = pck + 1000; 227 ctx->pck_max = pck + 1000;
228 228
229 pll_min = 0; 229 pll_min = 0;
230 pll_max = 0; 230 pll_max = 0;
231 231
232 return dsi_pll_calc(dpi->dsidev, clkin, 232 clkin = clk_get_rate(ctx->pll->clkin);
233
234 return dss_pll_calc(ctx->pll, clkin,
233 pll_min, pll_max, 235 pll_min, pll_max,
234 dpi_calc_pll_cb, ctx); 236 dpi_calc_pll_cb, ctx);
235} 237}
@@ -277,7 +279,7 @@ static int dpi_set_dsi_clk(struct dpi_data *dpi, enum omap_channel channel,
277 if (!ok) 279 if (!ok)
278 return -EINVAL; 280 return -EINVAL;
279 281
280 r = dsi_pll_set_clock_div(dpi->dsidev, &ctx.dsi_cinfo); 282 r = dss_pll_set_config(dpi->pll, &ctx.dsi_cinfo);
281 if (r) 283 if (r)
282 return r; 284 return r;
283 285
@@ -327,7 +329,7 @@ static int dpi_set_mode(struct dpi_data *dpi)
327 unsigned long pck; 329 unsigned long pck;
328 int r = 0; 330 int r = 0;
329 331
330 if (dpi->dsidev) 332 if (dpi->pll)
331 r = dpi_set_dsi_clk(dpi, mgr->id, t->pixelclock, &fck, 333 r = dpi_set_dsi_clk(dpi, mgr->id, t->pixelclock, &fck,
332 &lck_div, &pck_div); 334 &lck_div, &pck_div);
333 else 335 else
@@ -401,8 +403,8 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
401 if (r) 403 if (r)
402 goto err_src_sel; 404 goto err_src_sel;
403 405
404 if (dpi->dsidev) { 406 if (dpi->pll) {
405 r = dsi_pll_init(dpi->dsidev); 407 r = dss_pll_enable(dpi->pll);
406 if (r) 408 if (r)
407 goto err_dsi_pll_init; 409 goto err_dsi_pll_init;
408 } 410 }
@@ -425,8 +427,8 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
425 427
426err_mgr_enable: 428err_mgr_enable:
427err_set_mode: 429err_set_mode:
428 if (dpi->dsidev) 430 if (dpi->pll)
429 dsi_pll_uninit(dpi->dsidev, true); 431 dss_pll_disable(dpi->pll);
430err_dsi_pll_init: 432err_dsi_pll_init:
431err_src_sel: 433err_src_sel:
432 dispc_runtime_put(); 434 dispc_runtime_put();
@@ -449,9 +451,9 @@ static void dpi_display_disable(struct omap_dss_device *dssdev)
449 451
450 dss_mgr_disable(mgr); 452 dss_mgr_disable(mgr);
451 453
452 if (dpi->dsidev) { 454 if (dpi->pll) {
453 dss_select_lcd_clk_source(mgr->id, OMAP_DSS_CLK_SRC_FCK); 455 dss_select_lcd_clk_source(mgr->id, OMAP_DSS_CLK_SRC_FCK);
454 dsi_pll_uninit(dpi->dsidev, true); 456 dss_pll_disable(dpi->pll);
455 } 457 }
456 458
457 dispc_runtime_put(); 459 dispc_runtime_put();
@@ -505,7 +507,7 @@ static int dpi_check_timings(struct omap_dss_device *dssdev,
505 if (timings->pixelclock == 0) 507 if (timings->pixelclock == 0)
506 return -EINVAL; 508 return -EINVAL;
507 509
508 if (dpi->dsidev) { 510 if (dpi->pll) {
509 ok = dpi_dsi_clk_calc(dpi, timings->pixelclock, &ctx); 511 ok = dpi_dsi_clk_calc(dpi, timings->pixelclock, &ctx);
510 if (!ok) 512 if (!ok)
511 return -EINVAL; 513 return -EINVAL;
@@ -540,17 +542,17 @@ static void dpi_set_data_lines(struct omap_dss_device *dssdev, int data_lines)
540 mutex_unlock(&dpi->lock); 542 mutex_unlock(&dpi->lock);
541} 543}
542 544
543static int dpi_verify_dsi_pll(struct platform_device *dsidev) 545static int dpi_verify_dsi_pll(struct dss_pll *pll)
544{ 546{
545 int r; 547 int r;
546 548
547 /* do initial setup with the PLL to see if it is operational */ 549 /* do initial setup with the PLL to see if it is operational */
548 550
549 r = dsi_pll_init(dsidev); 551 r = dss_pll_enable(pll);
550 if (r) 552 if (r)
551 return r; 553 return r;
552 554
553 dsi_pll_uninit(dsidev, true); 555 dss_pll_disable(pll);
554 556
555 return 0; 557 return 0;
556} 558}
@@ -579,21 +581,21 @@ static int dpi_init_regulator(struct dpi_data *dpi)
579 581
580static void dpi_init_pll(struct dpi_data *dpi) 582static void dpi_init_pll(struct dpi_data *dpi)
581{ 583{
582 struct platform_device *dsidev; 584 struct dss_pll *pll;
583 585
584 if (dpi->dsidev) 586 if (dpi->pll)
585 return; 587 return;
586 588
587 dsidev = dpi_get_dsidev(dpi->output.dispc_channel); 589 pll = dpi_get_pll(dpi->output.dispc_channel);
588 if (!dsidev) 590 if (!pll)
589 return; 591 return;
590 592
591 if (dpi_verify_dsi_pll(dsidev)) { 593 if (dpi_verify_dsi_pll(pll)) {
592 DSSWARN("DSI PLL not operational\n"); 594 DSSWARN("DSI PLL not operational\n");
593 return; 595 return;
594 } 596 }
595 597
596 dpi->dsidev = dsidev; 598 dpi->pll = pll;
597} 599}
598 600
599/* 601/*
diff --git a/drivers/video/fbdev/omap2/dss/dsi.c b/drivers/video/fbdev/omap2/dss/dsi.c
index e8415b5e877e..73af35159468 100644
--- a/drivers/video/fbdev/omap2/dss/dsi.c
+++ b/drivers/video/fbdev/omap2/dss/dsi.c
@@ -275,6 +275,7 @@ struct dsi_isr_tables {
275 275
276struct dsi_clk_calc_ctx { 276struct dsi_clk_calc_ctx {
277 struct platform_device *dsidev; 277 struct platform_device *dsidev;
278 struct dss_pll *pll;
278 279
279 /* inputs */ 280 /* inputs */
280 281
@@ -284,7 +285,7 @@ struct dsi_clk_calc_ctx {
284 285
285 /* outputs */ 286 /* outputs */
286 287
287 struct dsi_clock_info dsi_cinfo; 288 struct dss_pll_clock_info dsi_cinfo;
288 struct dispc_clock_info dispc_cinfo; 289 struct dispc_clock_info dispc_cinfo;
289 290
290 struct omap_video_timings dispc_vm; 291 struct omap_video_timings dispc_vm;
@@ -309,16 +310,15 @@ struct dsi_data {
309 bool is_enabled; 310 bool is_enabled;
310 311
311 struct clk *dss_clk; 312 struct clk *dss_clk;
312 struct clk *sys_clk;
313 313
314 struct dispc_clock_info user_dispc_cinfo; 314 struct dispc_clock_info user_dispc_cinfo;
315 struct dsi_clock_info user_dsi_cinfo; 315 struct dss_pll_clock_info user_dsi_cinfo;
316
317 struct dsi_clock_info current_cinfo;
318 316
319 struct dsi_lp_clock_info user_lp_cinfo; 317 struct dsi_lp_clock_info user_lp_cinfo;
320 struct dsi_lp_clock_info current_lp_cinfo; 318 struct dsi_lp_clock_info current_lp_cinfo;
321 319
320 struct dss_pll pll;
321
322 bool vdds_dsi_enabled; 322 bool vdds_dsi_enabled;
323 struct regulator *vdds_dsi_reg; 323 struct regulator *vdds_dsi_reg;
324 324
@@ -357,7 +357,7 @@ struct dsi_data {
357 357
358 unsigned long cache_req_pck; 358 unsigned long cache_req_pck;
359 unsigned long cache_clk_freq; 359 unsigned long cache_clk_freq;
360 struct dsi_clock_info cache_cinfo; 360 struct dss_pll_clock_info cache_cinfo;
361 361
362 u32 errors; 362 u32 errors;
363 spinlock_t errors_lock; 363 spinlock_t errors_lock;
@@ -372,11 +372,6 @@ struct dsi_data {
372 spinlock_t irq_stats_lock; 372 spinlock_t irq_stats_lock;
373 struct dsi_irq_stats irq_stats; 373 struct dsi_irq_stats irq_stats;
374#endif 374#endif
375 /* DSI PLL Parameter Ranges */
376 unsigned long regm_max, regn_max;
377 unsigned long regm_hsdiv_max;
378 unsigned long fint_min, fint_max;
379 unsigned long lpdiv_max;
380 375
381 unsigned num_lanes_supported; 376 unsigned num_lanes_supported;
382 unsigned line_buffer_size; 377 unsigned line_buffer_size;
@@ -422,7 +417,7 @@ static inline struct platform_device *dsi_get_dsidev_from_dssdev(struct omap_dss
422 return to_platform_device(dssdev->dev); 417 return to_platform_device(dssdev->dev);
423} 418}
424 419
425struct platform_device *dsi_get_dsidev_from_id(int module) 420static struct platform_device *dsi_get_dsidev_from_id(int module)
426{ 421{
427 struct omap_dss_device *out; 422 struct omap_dss_device *out;
428 enum omap_dss_output_id id; 423 enum omap_dss_output_id id;
@@ -1198,18 +1193,6 @@ static int dsi_regulator_init(struct platform_device *dsidev)
1198 return 0; 1193 return 0;
1199} 1194}
1200 1195
1201/* source clock for DSI PLL. this could also be PCLKFREE */
1202static inline void dsi_enable_pll_clock(struct platform_device *dsidev,
1203 bool enable)
1204{
1205 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1206
1207 if (enable)
1208 clk_prepare_enable(dsi->sys_clk);
1209 else
1210 clk_disable_unprepare(dsi->sys_clk);
1211}
1212
1213static void _dsi_print_reset_status(struct platform_device *dsidev) 1196static void _dsi_print_reset_status(struct platform_device *dsidev)
1214{ 1197{
1215 u32 l; 1198 u32 l;
@@ -1261,25 +1244,25 @@ static inline int dsi_if_enable(struct platform_device *dsidev, bool enable)
1261 return 0; 1244 return 0;
1262} 1245}
1263 1246
1264unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev) 1247static unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev)
1265{ 1248{
1266 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 1249 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1267 1250
1268 return dsi->current_cinfo.clkout[HSDIV_DISPC]; 1251 return dsi->pll.cinfo.clkout[HSDIV_DISPC];
1269} 1252}
1270 1253
1271static unsigned long dsi_get_pll_hsdiv_dsi_rate(struct platform_device *dsidev) 1254static unsigned long dsi_get_pll_hsdiv_dsi_rate(struct platform_device *dsidev)
1272{ 1255{
1273 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 1256 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1274 1257
1275 return dsi->current_cinfo.clkout[HSDIV_DSI]; 1258 return dsi->pll.cinfo.clkout[HSDIV_DSI];
1276} 1259}
1277 1260
1278static unsigned long dsi_get_txbyteclkhs(struct platform_device *dsidev) 1261static unsigned long dsi_get_txbyteclkhs(struct platform_device *dsidev)
1279{ 1262{
1280 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 1263 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1281 1264
1282 return dsi->current_cinfo.clkdco / 16; 1265 return dsi->pll.cinfo.clkdco / 16;
1283} 1266}
1284 1267
1285static unsigned long dsi_fclk_rate(struct platform_device *dsidev) 1268static unsigned long dsi_fclk_rate(struct platform_device *dsidev)
@@ -1323,10 +1306,12 @@ static int dsi_set_lp_clk_divisor(struct platform_device *dsidev)
1323 unsigned long dsi_fclk; 1306 unsigned long dsi_fclk;
1324 unsigned lp_clk_div; 1307 unsigned lp_clk_div;
1325 unsigned long lp_clk; 1308 unsigned long lp_clk;
1309 unsigned lpdiv_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_LPDIV);
1310
1326 1311
1327 lp_clk_div = dsi->user_lp_cinfo.lp_clk_div; 1312 lp_clk_div = dsi->user_lp_cinfo.lp_clk_div;
1328 1313
1329 if (lp_clk_div == 0 || lp_clk_div > dsi->lpdiv_max) 1314 if (lp_clk_div == 0 || lp_clk_div > lpdiv_max)
1330 return -EINVAL; 1315 return -EINVAL;
1331 1316
1332 dsi_fclk = dsi_fclk_rate(dsidev); 1317 dsi_fclk = dsi_fclk_rate(dsidev);
@@ -1396,276 +1381,21 @@ static int dsi_pll_power(struct platform_device *dsidev,
1396 return 0; 1381 return 0;
1397} 1382}
1398 1383
1399unsigned long dsi_get_pll_clkin(struct platform_device *dsidev)
1400{
1401 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1402 return clk_get_rate(dsi->sys_clk);
1403}
1404
1405bool dsi_hsdiv_calc(struct platform_device *dsidev, unsigned long pll,
1406 unsigned long out_min, dsi_hsdiv_calc_func func, void *data)
1407{
1408 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1409 int regm, regm_start, regm_stop;
1410 unsigned long out_max;
1411 unsigned long out;
1412
1413 out_min = out_min ? out_min : 1;
1414 out_max = dss_feat_get_param_max(FEAT_PARAM_DSS_FCK);
1415
1416 regm_start = max(DIV_ROUND_UP(pll, out_max), 1ul);
1417 regm_stop = min(pll / out_min, dsi->regm_hsdiv_max);
1418
1419 for (regm = regm_start; regm <= regm_stop; ++regm) {
1420 out = pll / regm;
1421
1422 if (func(regm, out, data))
1423 return true;
1424 }
1425
1426 return false;
1427}
1428
1429bool dsi_pll_calc(struct platform_device *dsidev, unsigned long clkin,
1430 unsigned long pll_min, unsigned long pll_max,
1431 dsi_pll_calc_func func, void *data)
1432{
1433 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1434 int regn, regn_start, regn_stop;
1435 int regm, regm_start, regm_stop;
1436 unsigned long fint, pll;
1437 const unsigned long pll_hw_max = 1800000000;
1438 unsigned long fint_hw_min, fint_hw_max;
1439
1440 fint_hw_min = dsi->fint_min;
1441 fint_hw_max = dsi->fint_max;
1442
1443 regn_start = max(DIV_ROUND_UP(clkin, fint_hw_max), 1ul);
1444 regn_stop = min(clkin / fint_hw_min, dsi->regn_max);
1445
1446 pll_max = pll_max ? pll_max : ULONG_MAX;
1447
1448 for (regn = regn_start; regn <= regn_stop; ++regn) {
1449 fint = clkin / regn;
1450
1451 regm_start = max(DIV_ROUND_UP(DIV_ROUND_UP(pll_min, fint), 2),
1452 1ul);
1453 regm_stop = min3(pll_max / fint / 2,
1454 pll_hw_max / fint / 2,
1455 dsi->regm_max);
1456
1457 for (regm = regm_start; regm <= regm_stop; ++regm) {
1458 pll = 2 * regm * fint;
1459
1460 if (func(regn, regm, fint, pll, data))
1461 return true;
1462 }
1463 }
1464
1465 return false;
1466}
1467
1468/* calculate clock rates using dividers in cinfo */
1469static int dsi_calc_clock_rates(struct platform_device *dsidev,
1470 struct dsi_clock_info *cinfo)
1471{
1472 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1473
1474 if (cinfo->regn == 0 || cinfo->regn > dsi->regn_max)
1475 return -EINVAL;
1476
1477 if (cinfo->regm == 0 || cinfo->regm > dsi->regm_max)
1478 return -EINVAL;
1479
1480 if (cinfo->regm_hsdiv[HSDIV_DISPC] > dsi->regm_hsdiv_max)
1481 return -EINVAL;
1482
1483 if (cinfo->regm_hsdiv[HSDIV_DSI] > dsi->regm_hsdiv_max)
1484 return -EINVAL;
1485
1486 cinfo->fint = clk_get_rate(dsi->sys_clk) / cinfo->regn;
1487
1488 if (cinfo->fint > dsi->fint_max || cinfo->fint < dsi->fint_min)
1489 return -EINVAL;
1490
1491 cinfo->clkdco = 2 * cinfo->regm * cinfo->fint;
1492 1384
1493 if (cinfo->clkdco > 1800 * 1000 * 1000) 1385static void dsi_pll_calc_dsi_fck(struct dss_pll_clock_info *cinfo)
1494 return -EINVAL;
1495
1496 if (cinfo->regm_hsdiv[HSDIV_DISPC])
1497 cinfo->clkout[HSDIV_DISPC] =
1498 cinfo->clkdco / cinfo->regm_hsdiv[HSDIV_DISPC];
1499 else
1500 cinfo->clkout[HSDIV_DISPC] = 0;
1501
1502 if (cinfo->regm_hsdiv[HSDIV_DSI])
1503 cinfo->clkout[HSDIV_DSI] =
1504 cinfo->clkdco / cinfo->regm_hsdiv[HSDIV_DSI];
1505 else
1506 cinfo->clkout[HSDIV_DSI] = 0;
1507
1508 return 0;
1509}
1510
1511static void dsi_pll_calc_dsi_fck(struct dsi_clock_info *cinfo)
1512{ 1386{
1513 unsigned long max_dsi_fck; 1387 unsigned long max_dsi_fck;
1514 1388
1515 max_dsi_fck = dss_feat_get_param_max(FEAT_PARAM_DSI_FCK); 1389 max_dsi_fck = dss_feat_get_param_max(FEAT_PARAM_DSI_FCK);
1516 1390
1517 cinfo->regm_hsdiv[HSDIV_DSI] = DIV_ROUND_UP(cinfo->clkdco, max_dsi_fck); 1391 cinfo->mX[HSDIV_DSI] = DIV_ROUND_UP(cinfo->clkdco, max_dsi_fck);
1518 cinfo->clkout[HSDIV_DSI] = cinfo->clkdco / cinfo->regm_hsdiv[HSDIV_DSI]; 1392 cinfo->clkout[HSDIV_DSI] = cinfo->clkdco / cinfo->mX[HSDIV_DSI];
1519} 1393}
1520 1394
1521static int dsi_wait_hsdiv_ack(struct platform_device *dsidev, u32 hsdiv_ack_mask) 1395static int dsi_pll_enable(struct dss_pll *pll)
1522{ 1396{
1523 int t = 100; 1397 struct dsi_data *dsi = container_of(pll, struct dsi_data, pll);
1524 1398 struct platform_device *dsidev = dsi->pdev;
1525 while (t-- > 0) {
1526 u32 v = dsi_read_reg(dsidev, DSI_PLL_STATUS);
1527 v &= hsdiv_ack_mask;
1528 if (v == hsdiv_ack_mask)
1529 return 0;
1530 }
1531
1532 return -ETIMEDOUT;
1533}
1534
1535int dsi_pll_set_clock_div(struct platform_device *dsidev,
1536 struct dsi_clock_info *cinfo)
1537{
1538 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1539 int r = 0;
1540 u32 l;
1541 int f = 0;
1542 u8 regn_start, regn_end, regm_start, regm_end;
1543 u8 regm_dispc_start, regm_dispc_end, regm_dsi_start, regm_dsi_end;
1544
1545 DSSDBG("DSI PLL clock config starts");
1546
1547 dsi->current_cinfo = *cinfo;
1548
1549 DSSDBG("DSI Fint %ld\n", cinfo->fint);
1550
1551 DSSDBG("clkin rate %ld\n", clk_get_rate(dsi->sys_clk));
1552
1553 /* DSIPHY == CLKIN4DDR */
1554 DSSDBG("CLKIN4DDR = 2 * %d / %d * %lu = %lu\n",
1555 cinfo->regm,
1556 cinfo->regn,
1557 clk_get_rate(dsi->sys_clk),
1558 cinfo->clkdco);
1559
1560 DSSDBG("Data rate on 1 DSI lane %ld Mbps\n",
1561 cinfo->clkdco / 1000 / 1000 / 2);
1562
1563 DSSDBG("Clock lane freq %ld Hz\n", cinfo->clkdco / 4);
1564
1565 DSSDBG("regm_dispc = %d, %s (%s) = %lu\n", cinfo->regm_hsdiv[HSDIV_DISPC],
1566 dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC),
1567 dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC),
1568 cinfo->clkout[HSDIV_DISPC]);
1569 DSSDBG("regm_dsi = %d, %s (%s) = %lu\n", cinfo->regm_hsdiv[HSDIV_DSI],
1570 dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI),
1571 dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI),
1572 cinfo->clkout[HSDIV_DSI]);
1573
1574 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGN, &regn_start, &regn_end);
1575 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM, &regm_start, &regm_end);
1576 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM_DISPC, &regm_dispc_start,
1577 &regm_dispc_end);
1578 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM_DSI, &regm_dsi_start,
1579 &regm_dsi_end);
1580
1581 /* DSI_PLL_AUTOMODE = manual */
1582 REG_FLD_MOD(dsidev, DSI_PLL_CONTROL, 0, 0, 0);
1583
1584 l = dsi_read_reg(dsidev, DSI_PLL_CONFIGURATION1);
1585 l = FLD_MOD(l, 1, 0, 0); /* DSI_PLL_STOPMODE */
1586 /* DSI_PLL_REGN */
1587 l = FLD_MOD(l, cinfo->regn - 1, regn_start, regn_end);
1588 /* DSI_PLL_REGM */
1589 l = FLD_MOD(l, cinfo->regm, regm_start, regm_end);
1590 /* DSI_CLOCK_DIV */
1591 l = FLD_MOD(l, cinfo->regm_hsdiv[HSDIV_DISPC] > 0 ? cinfo->regm_hsdiv[HSDIV_DISPC] - 1 : 0,
1592 regm_dispc_start, regm_dispc_end);
1593 /* DSIPROTO_CLOCK_DIV */
1594 l = FLD_MOD(l, cinfo->regm_hsdiv[HSDIV_DSI] > 0 ? cinfo->regm_hsdiv[HSDIV_DSI] - 1 : 0,
1595 regm_dsi_start, regm_dsi_end);
1596 dsi_write_reg(dsidev, DSI_PLL_CONFIGURATION1, l);
1597
1598 BUG_ON(cinfo->fint < dsi->fint_min || cinfo->fint > dsi->fint_max);
1599
1600 l = dsi_read_reg(dsidev, DSI_PLL_CONFIGURATION2);
1601
1602 if (dss_has_feature(FEAT_DSI_PLL_FREQSEL)) {
1603 f = cinfo->fint < 1000000 ? 0x3 :
1604 cinfo->fint < 1250000 ? 0x4 :
1605 cinfo->fint < 1500000 ? 0x5 :
1606 cinfo->fint < 1750000 ? 0x6 :
1607 0x7;
1608
1609 l = FLD_MOD(l, f, 4, 1); /* DSI_PLL_FREQSEL */
1610 } else if (dss_has_feature(FEAT_DSI_PLL_SELFREQDCO)) {
1611 f = cinfo->clkdco < 1000000000 ? 0x2 : 0x4;
1612
1613 l = FLD_MOD(l, f, 3, 1); /* PLL_SELFREQDCO */
1614 }
1615
1616 l = FLD_MOD(l, 1, 13, 13); /* DSI_PLL_REFEN */
1617 l = FLD_MOD(l, 0, 14, 14); /* DSIPHY_CLKINEN */
1618 l = FLD_MOD(l, 1, 20, 20); /* DSI_HSDIVBYPASS */
1619 if (dss_has_feature(FEAT_DSI_PLL_REFSEL))
1620 l = FLD_MOD(l, 3, 22, 21); /* REF_SYSCLK = sysclk */
1621 dsi_write_reg(dsidev, DSI_PLL_CONFIGURATION2, l);
1622
1623 REG_FLD_MOD(dsidev, DSI_PLL_GO, 1, 0, 0); /* DSI_PLL_GO */
1624
1625 if (wait_for_bit_change(dsidev, DSI_PLL_GO, 0, 0) != 0) {
1626 DSSERR("dsi pll go bit not going down.\n");
1627 r = -EIO;
1628 goto err;
1629 }
1630
1631 if (wait_for_bit_change(dsidev, DSI_PLL_STATUS, 1, 1) != 1) {
1632 DSSERR("cannot lock PLL\n");
1633 r = -EIO;
1634 goto err;
1635 }
1636
1637 l = dsi_read_reg(dsidev, DSI_PLL_CONFIGURATION2);
1638 l = FLD_MOD(l, 0, 0, 0); /* DSI_PLL_IDLE */
1639 l = FLD_MOD(l, 0, 5, 5); /* DSI_PLL_PLLLPMODE */
1640 l = FLD_MOD(l, 0, 6, 6); /* DSI_PLL_LOWCURRSTBY */
1641 l = FLD_MOD(l, 0, 7, 7); /* DSI_PLL_TIGHTPHASELOCK */
1642 l = FLD_MOD(l, 0, 8, 8); /* DSI_PLL_DRIFTGUARDEN */
1643 l = FLD_MOD(l, 0, 10, 9); /* DSI_PLL_LOCKSEL */
1644 l = FLD_MOD(l, 1, 13, 13); /* DSI_PLL_REFEN */
1645 l = FLD_MOD(l, 1, 14, 14); /* DSIPHY_CLKINEN */
1646 l = FLD_MOD(l, 0, 15, 15); /* DSI_BYPASSEN */
1647 l = FLD_MOD(l, 1, 16, 16); /* DSS_CLOCK_EN */
1648 l = FLD_MOD(l, 0, 17, 17); /* DSS_CLOCK_PWDN */
1649 l = FLD_MOD(l, 1, 18, 18); /* DSI_PROTO_CLOCK_EN */
1650 l = FLD_MOD(l, 0, 19, 19); /* DSI_PROTO_CLOCK_PWDN */
1651 l = FLD_MOD(l, 0, 20, 20); /* DSI_HSDIVBYPASS */
1652 dsi_write_reg(dsidev, DSI_PLL_CONFIGURATION2, l);
1653
1654 r = dsi_wait_hsdiv_ack(dsidev, BIT(7) | BIT(8));
1655 if (r) {
1656 DSSERR("failed to enable HSDIV clocks: %d\n", r);
1657 goto err;
1658 }
1659
1660
1661 DSSDBG("PLL config done\n");
1662err:
1663 return r;
1664}
1665
1666int dsi_pll_init(struct platform_device *dsidev)
1667{
1668 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1669 int r = 0; 1399 int r = 0;
1670 1400
1671 DSSDBG("PLL init\n"); 1401 DSSDBG("PLL init\n");
@@ -1678,7 +1408,6 @@ int dsi_pll_init(struct platform_device *dsidev)
1678 if (r) 1408 if (r)
1679 return r; 1409 return r;
1680 1410
1681 dsi_enable_pll_clock(dsidev, 1);
1682 /* 1411 /*
1683 * Note: SCP CLK is not required on OMAP3, but it is required on OMAP4. 1412 * Note: SCP CLK is not required on OMAP3, but it is required on OMAP4.
1684 */ 1413 */
@@ -1720,12 +1449,11 @@ err1:
1720 } 1449 }
1721err0: 1450err0:
1722 dsi_disable_scp_clk(dsidev); 1451 dsi_disable_scp_clk(dsidev);
1723 dsi_enable_pll_clock(dsidev, 0);
1724 dsi_runtime_put(dsidev); 1452 dsi_runtime_put(dsidev);
1725 return r; 1453 return r;
1726} 1454}
1727 1455
1728void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes) 1456static void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes)
1729{ 1457{
1730 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 1458 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1731 1459
@@ -1737,19 +1465,27 @@ void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes)
1737 } 1465 }
1738 1466
1739 dsi_disable_scp_clk(dsidev); 1467 dsi_disable_scp_clk(dsidev);
1740 dsi_enable_pll_clock(dsidev, 0);
1741 dsi_runtime_put(dsidev); 1468 dsi_runtime_put(dsidev);
1742 1469
1743 DSSDBG("PLL uninit done\n"); 1470 DSSDBG("PLL uninit done\n");
1744} 1471}
1745 1472
1473static void dsi_pll_disable(struct dss_pll *pll)
1474{
1475 struct dsi_data *dsi = container_of(pll, struct dsi_data, pll);
1476 struct platform_device *dsidev = dsi->pdev;
1477
1478 dsi_pll_uninit(dsidev, true);
1479}
1480
1746static void dsi_dump_dsidev_clocks(struct platform_device *dsidev, 1481static void dsi_dump_dsidev_clocks(struct platform_device *dsidev,
1747 struct seq_file *s) 1482 struct seq_file *s)
1748{ 1483{
1749 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 1484 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1750 struct dsi_clock_info *cinfo = &dsi->current_cinfo; 1485 struct dss_pll_clock_info *cinfo = &dsi->pll.cinfo;
1751 enum omap_dss_clk_source dispc_clk_src, dsi_clk_src; 1486 enum omap_dss_clk_source dispc_clk_src, dsi_clk_src;
1752 int dsi_module = dsi->module_id; 1487 int dsi_module = dsi->module_id;
1488 struct dss_pll *pll = &dsi->pll;
1753 1489
1754 dispc_clk_src = dss_get_dispc_clk_source(); 1490 dispc_clk_src = dss_get_dispc_clk_source();
1755 dsi_clk_src = dss_get_dsi_clk_source(dsi_module); 1491 dsi_clk_src = dss_get_dsi_clk_source(dsi_module);
@@ -1759,28 +1495,28 @@ static void dsi_dump_dsidev_clocks(struct platform_device *dsidev,
1759 1495
1760 seq_printf(s, "- DSI%d PLL -\n", dsi_module + 1); 1496 seq_printf(s, "- DSI%d PLL -\n", dsi_module + 1);
1761 1497
1762 seq_printf(s, "dsi pll clkin\t%lu\n", clk_get_rate(dsi->sys_clk)); 1498 seq_printf(s, "dsi pll clkin\t%lu\n", clk_get_rate(pll->clkin));
1763 1499
1764 seq_printf(s, "Fint\t\t%-16luregn %u\n", cinfo->fint, cinfo->regn); 1500 seq_printf(s, "Fint\t\t%-16lun %u\n", cinfo->fint, cinfo->n);
1765 1501
1766 seq_printf(s, "CLKIN4DDR\t%-16luregm %u\n", 1502 seq_printf(s, "CLKIN4DDR\t%-16lum %u\n",
1767 cinfo->clkdco, cinfo->regm); 1503 cinfo->clkdco, cinfo->m);
1768 1504
1769 seq_printf(s, "DSI_PLL_HSDIV_DISPC (%s)\t%-16luregm_dispc %u\t(%s)\n", 1505 seq_printf(s, "DSI_PLL_HSDIV_DISPC (%s)\t%-16lum_dispc %u\t(%s)\n",
1770 dss_feat_get_clk_source_name(dsi_module == 0 ? 1506 dss_feat_get_clk_source_name(dsi_module == 0 ?
1771 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC : 1507 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC :
1772 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC), 1508 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC),
1773 cinfo->clkout[HSDIV_DISPC], 1509 cinfo->clkout[HSDIV_DISPC],
1774 cinfo->regm_hsdiv[HSDIV_DISPC], 1510 cinfo->mX[HSDIV_DISPC],
1775 dispc_clk_src == OMAP_DSS_CLK_SRC_FCK ? 1511 dispc_clk_src == OMAP_DSS_CLK_SRC_FCK ?
1776 "off" : "on"); 1512 "off" : "on");
1777 1513
1778 seq_printf(s, "DSI_PLL_HSDIV_DSI (%s)\t%-16luregm_dsi %u\t(%s)\n", 1514 seq_printf(s, "DSI_PLL_HSDIV_DSI (%s)\t%-16lum_dsi %u\t(%s)\n",
1779 dss_feat_get_clk_source_name(dsi_module == 0 ? 1515 dss_feat_get_clk_source_name(dsi_module == 0 ?
1780 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI : 1516 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI :
1781 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI), 1517 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI),
1782 cinfo->clkout[HSDIV_DSI], 1518 cinfo->clkout[HSDIV_DSI],
1783 cinfo->regm_hsdiv[HSDIV_DSI], 1519 cinfo->mX[HSDIV_DSI],
1784 dsi_clk_src == OMAP_DSS_CLK_SRC_FCK ? 1520 dsi_clk_src == OMAP_DSS_CLK_SRC_FCK ?
1785 "off" : "on"); 1521 "off" : "on");
1786 1522
@@ -2132,7 +1868,7 @@ static inline unsigned ns2ddr(struct platform_device *dsidev, unsigned ns)
2132 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 1868 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2133 1869
2134 /* convert time in ns to ddr ticks, rounding up */ 1870 /* convert time in ns to ddr ticks, rounding up */
2135 unsigned long ddr_clk = dsi->current_cinfo.clkdco / 4; 1871 unsigned long ddr_clk = dsi->pll.cinfo.clkdco / 4;
2136 return (ns * (ddr_clk / 1000 / 1000) + 999) / 1000; 1872 return (ns * (ddr_clk / 1000 / 1000) + 999) / 1000;
2137} 1873}
2138 1874
@@ -2140,7 +1876,7 @@ static inline unsigned ddr2ns(struct platform_device *dsidev, unsigned ddr)
2140{ 1876{
2141 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 1877 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2142 1878
2143 unsigned long ddr_clk = dsi->current_cinfo.clkdco / 4; 1879 unsigned long ddr_clk = dsi->pll.cinfo.clkdco / 4;
2144 return ddr * 1000 * 1000 / (ddr_clk / 1000); 1880 return ddr * 1000 * 1000 / (ddr_clk / 1000);
2145} 1881}
2146 1882
@@ -3730,7 +3466,7 @@ static void dsi_config_cmd_mode_interleaving(struct platform_device *dsidev)
3730 struct omap_video_timings *timings = &dsi->timings; 3466 struct omap_video_timings *timings = &dsi->timings;
3731 int bpp = dsi_get_pixel_size(dsi->pix_fmt); 3467 int bpp = dsi_get_pixel_size(dsi->pix_fmt);
3732 int ndl = dsi->num_lanes_used - 1; 3468 int ndl = dsi->num_lanes_used - 1;
3733 int dsi_fclk_hsdiv = dsi->user_dsi_cinfo.regm_hsdiv[HSDIV_DSI] + 1; 3469 int dsi_fclk_hsdiv = dsi->user_dsi_cinfo.mX[HSDIV_DSI] + 1;
3734 int hsa_interleave_hs = 0, hsa_interleave_lp = 0; 3470 int hsa_interleave_hs = 0, hsa_interleave_lp = 0;
3735 int hfp_interleave_hs = 0, hfp_interleave_lp = 0; 3471 int hfp_interleave_hs = 0, hfp_interleave_lp = 0;
3736 int hbp_interleave_hs = 0, hbp_interleave_lp = 0; 3472 int hbp_interleave_hs = 0, hbp_interleave_lp = 0;
@@ -4441,18 +4177,12 @@ static void dsi_display_uninit_dispc(struct platform_device *dsidev,
4441static int dsi_configure_dsi_clocks(struct platform_device *dsidev) 4177static int dsi_configure_dsi_clocks(struct platform_device *dsidev)
4442{ 4178{
4443 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 4179 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4444 struct dsi_clock_info cinfo; 4180 struct dss_pll_clock_info cinfo;
4445 int r; 4181 int r;
4446 4182
4447 cinfo = dsi->user_dsi_cinfo; 4183 cinfo = dsi->user_dsi_cinfo;
4448 4184
4449 r = dsi_calc_clock_rates(dsidev, &cinfo); 4185 r = dss_pll_set_config(&dsi->pll, &cinfo);
4450 if (r) {
4451 DSSERR("Failed to calc dsi clocks\n");
4452 return r;
4453 }
4454
4455 r = dsi_pll_set_clock_div(dsidev, &cinfo);
4456 if (r) { 4186 if (r) {
4457 DSSERR("Failed to set dsi clocks\n"); 4187 DSSERR("Failed to set dsi clocks\n");
4458 return r; 4188 return r;
@@ -4466,7 +4196,7 @@ static int dsi_display_init_dsi(struct platform_device *dsidev)
4466 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 4196 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4467 int r; 4197 int r;
4468 4198
4469 r = dsi_pll_init(dsidev); 4199 r = dss_pll_enable(&dsi->pll);
4470 if (r) 4200 if (r)
4471 goto err0; 4201 goto err0;
4472 4202
@@ -4510,7 +4240,7 @@ err3:
4510err2: 4240err2:
4511 dss_select_dsi_clk_source(dsi->module_id, OMAP_DSS_CLK_SRC_FCK); 4241 dss_select_dsi_clk_source(dsi->module_id, OMAP_DSS_CLK_SRC_FCK);
4512err1: 4242err1:
4513 dsi_pll_uninit(dsidev, true); 4243 dss_pll_disable(&dsi->pll);
4514err0: 4244err0:
4515 return r; 4245 return r;
4516} 4246}
@@ -4551,8 +4281,6 @@ static int dsi_display_enable(struct omap_dss_device *dssdev)
4551 if (r) 4281 if (r)
4552 goto err_get_dsi; 4282 goto err_get_dsi;
4553 4283
4554 dsi_enable_pll_clock(dsidev, 1);
4555
4556 _dsi_initialize_irq(dsidev); 4284 _dsi_initialize_irq(dsidev);
4557 4285
4558 r = dsi_display_init_dsi(dsidev); 4286 r = dsi_display_init_dsi(dsidev);
@@ -4564,7 +4292,6 @@ static int dsi_display_enable(struct omap_dss_device *dssdev)
4564 return 0; 4292 return 0;
4565 4293
4566err_init_dsi: 4294err_init_dsi:
4567 dsi_enable_pll_clock(dsidev, 0);
4568 dsi_runtime_put(dsidev); 4295 dsi_runtime_put(dsidev);
4569err_get_dsi: 4296err_get_dsi:
4570 mutex_unlock(&dsi->lock); 4297 mutex_unlock(&dsi->lock);
@@ -4592,7 +4319,6 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
4592 dsi_display_uninit_dsi(dsidev, disconnect_lanes, enter_ulps); 4319 dsi_display_uninit_dsi(dsidev, disconnect_lanes, enter_ulps);
4593 4320
4594 dsi_runtime_put(dsidev); 4321 dsi_runtime_put(dsidev);
4595 dsi_enable_pll_clock(dsidev, 0);
4596 4322
4597 mutex_unlock(&dsi->lock); 4323 mutex_unlock(&dsi->lock);
4598} 4324}
@@ -4713,29 +4439,30 @@ static bool dsi_cm_calc_dispc_cb(int lckd, int pckd, unsigned long lck,
4713 return true; 4439 return true;
4714} 4440}
4715 4441
4716static bool dsi_cm_calc_hsdiv_cb(int regm_dispc, unsigned long dispc, 4442static bool dsi_cm_calc_hsdiv_cb(int m_dispc, unsigned long dispc,
4717 void *data) 4443 void *data)
4718{ 4444{
4719 struct dsi_clk_calc_ctx *ctx = data; 4445 struct dsi_clk_calc_ctx *ctx = data;
4720 4446
4721 ctx->dsi_cinfo.regm_hsdiv[HSDIV_DISPC] = regm_dispc; 4447 ctx->dsi_cinfo.mX[HSDIV_DISPC] = m_dispc;
4722 ctx->dsi_cinfo.clkout[HSDIV_DISPC] = dispc; 4448 ctx->dsi_cinfo.clkout[HSDIV_DISPC] = dispc;
4723 4449
4724 return dispc_div_calc(dispc, ctx->req_pck_min, ctx->req_pck_max, 4450 return dispc_div_calc(dispc, ctx->req_pck_min, ctx->req_pck_max,
4725 dsi_cm_calc_dispc_cb, ctx); 4451 dsi_cm_calc_dispc_cb, ctx);
4726} 4452}
4727 4453
4728static bool dsi_cm_calc_pll_cb(int regn, int regm, unsigned long fint, 4454static bool dsi_cm_calc_pll_cb(int n, int m, unsigned long fint,
4729 unsigned long pll, void *data) 4455 unsigned long clkdco, void *data)
4730{ 4456{
4731 struct dsi_clk_calc_ctx *ctx = data; 4457 struct dsi_clk_calc_ctx *ctx = data;
4732 4458
4733 ctx->dsi_cinfo.regn = regn; 4459 ctx->dsi_cinfo.n = n;
4734 ctx->dsi_cinfo.regm = regm; 4460 ctx->dsi_cinfo.m = m;
4735 ctx->dsi_cinfo.fint = fint; 4461 ctx->dsi_cinfo.fint = fint;
4736 ctx->dsi_cinfo.clkdco = pll; 4462 ctx->dsi_cinfo.clkdco = clkdco;
4737 4463
4738 return dsi_hsdiv_calc(ctx->dsidev, pll, ctx->req_pck_min, 4464 return dss_pll_hsdiv_calc(ctx->pll, clkdco, ctx->req_pck_min,
4465 dss_feat_get_param_max(FEAT_PARAM_DSS_FCK),
4739 dsi_cm_calc_hsdiv_cb, ctx); 4466 dsi_cm_calc_hsdiv_cb, ctx);
4740} 4467}
4741 4468
@@ -4748,7 +4475,7 @@ static bool dsi_cm_calc(struct dsi_data *dsi,
4748 unsigned long pll_min, pll_max; 4475 unsigned long pll_min, pll_max;
4749 unsigned long pck, txbyteclk; 4476 unsigned long pck, txbyteclk;
4750 4477
4751 clkin = clk_get_rate(dsi->sys_clk); 4478 clkin = clk_get_rate(dsi->pll.clkin);
4752 bitspp = dsi_get_pixel_size(cfg->pixel_format); 4479 bitspp = dsi_get_pixel_size(cfg->pixel_format);
4753 ndl = dsi->num_lanes_used - 1; 4480 ndl = dsi->num_lanes_used - 1;
4754 4481
@@ -4764,6 +4491,7 @@ static bool dsi_cm_calc(struct dsi_data *dsi,
4764 4491
4765 memset(ctx, 0, sizeof(*ctx)); 4492 memset(ctx, 0, sizeof(*ctx));
4766 ctx->dsidev = dsi->pdev; 4493 ctx->dsidev = dsi->pdev;
4494 ctx->pll = &dsi->pll;
4767 ctx->config = cfg; 4495 ctx->config = cfg;
4768 ctx->req_pck_min = pck; 4496 ctx->req_pck_min = pck;
4769 ctx->req_pck_nom = pck; 4497 ctx->req_pck_nom = pck;
@@ -4772,7 +4500,7 @@ static bool dsi_cm_calc(struct dsi_data *dsi,
4772 pll_min = max(cfg->hs_clk_min * 4, txbyteclk * 4 * 4); 4500 pll_min = max(cfg->hs_clk_min * 4, txbyteclk * 4 * 4);
4773 pll_max = cfg->hs_clk_max * 4; 4501 pll_max = cfg->hs_clk_max * 4;
4774 4502
4775 return dsi_pll_calc(dsi->pdev, clkin, 4503 return dss_pll_calc(ctx->pll, clkin,
4776 pll_min, pll_max, 4504 pll_min, pll_max,
4777 dsi_cm_calc_pll_cb, ctx); 4505 dsi_cm_calc_pll_cb, ctx);
4778} 4506}
@@ -4998,13 +4726,13 @@ static bool dsi_vm_calc_dispc_cb(int lckd, int pckd, unsigned long lck,
4998 return true; 4726 return true;
4999} 4727}
5000 4728
5001static bool dsi_vm_calc_hsdiv_cb(int regm_dispc, unsigned long dispc, 4729static bool dsi_vm_calc_hsdiv_cb(int m_dispc, unsigned long dispc,
5002 void *data) 4730 void *data)
5003{ 4731{
5004 struct dsi_clk_calc_ctx *ctx = data; 4732 struct dsi_clk_calc_ctx *ctx = data;
5005 unsigned long pck_max; 4733 unsigned long pck_max;
5006 4734
5007 ctx->dsi_cinfo.regm_hsdiv[HSDIV_DISPC] = regm_dispc; 4735 ctx->dsi_cinfo.mX[HSDIV_DISPC] = m_dispc;
5008 ctx->dsi_cinfo.clkout[HSDIV_DISPC] = dispc; 4736 ctx->dsi_cinfo.clkout[HSDIV_DISPC] = dispc;
5009 4737
5010 /* 4738 /*
@@ -5021,17 +4749,18 @@ static bool dsi_vm_calc_hsdiv_cb(int regm_dispc, unsigned long dispc,
5021 dsi_vm_calc_dispc_cb, ctx); 4749 dsi_vm_calc_dispc_cb, ctx);
5022} 4750}
5023 4751
5024static bool dsi_vm_calc_pll_cb(int regn, int regm, unsigned long fint, 4752static bool dsi_vm_calc_pll_cb(int n, int m, unsigned long fint,
5025 unsigned long pll, void *data) 4753 unsigned long clkdco, void *data)
5026{ 4754{
5027 struct dsi_clk_calc_ctx *ctx = data; 4755 struct dsi_clk_calc_ctx *ctx = data;
5028 4756
5029 ctx->dsi_cinfo.regn = regn; 4757 ctx->dsi_cinfo.n = n;
5030 ctx->dsi_cinfo.regm = regm; 4758 ctx->dsi_cinfo.m = m;
5031 ctx->dsi_cinfo.fint = fint; 4759 ctx->dsi_cinfo.fint = fint;
5032 ctx->dsi_cinfo.clkdco = pll; 4760 ctx->dsi_cinfo.clkdco = clkdco;
5033 4761
5034 return dsi_hsdiv_calc(ctx->dsidev, pll, ctx->req_pck_min, 4762 return dss_pll_hsdiv_calc(ctx->pll, clkdco, ctx->req_pck_min,
4763 dss_feat_get_param_max(FEAT_PARAM_DSS_FCK),
5035 dsi_vm_calc_hsdiv_cb, ctx); 4764 dsi_vm_calc_hsdiv_cb, ctx);
5036} 4765}
5037 4766
@@ -5047,10 +4776,11 @@ static bool dsi_vm_calc(struct dsi_data *dsi,
5047 int bitspp = dsi_get_pixel_size(cfg->pixel_format); 4776 int bitspp = dsi_get_pixel_size(cfg->pixel_format);
5048 unsigned long byteclk_min; 4777 unsigned long byteclk_min;
5049 4778
5050 clkin = clk_get_rate(dsi->sys_clk); 4779 clkin = clk_get_rate(dsi->pll.clkin);
5051 4780
5052 memset(ctx, 0, sizeof(*ctx)); 4781 memset(ctx, 0, sizeof(*ctx));
5053 ctx->dsidev = dsi->pdev; 4782 ctx->dsidev = dsi->pdev;
4783 ctx->pll = &dsi->pll;
5054 ctx->config = cfg; 4784 ctx->config = cfg;
5055 4785
5056 /* these limits should come from the panel driver */ 4786 /* these limits should come from the panel driver */
@@ -5071,7 +4801,7 @@ static bool dsi_vm_calc(struct dsi_data *dsi,
5071 pll_max = byteclk_max * 4 * 4; 4801 pll_max = byteclk_max * 4 * 4;
5072 } 4802 }
5073 4803
5074 return dsi_pll_calc(dsi->pdev, clkin, 4804 return dss_pll_calc(ctx->pll, clkin,
5075 pll_min, pll_max, 4805 pll_min, pll_max,
5076 dsi_vm_calc_pll_cb, ctx); 4806 dsi_vm_calc_pll_cb, ctx);
5077} 4807}
@@ -5232,19 +4962,6 @@ static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
5232} 4962}
5233 4963
5234 4964
5235static void dsi_calc_clock_param_ranges(struct platform_device *dsidev)
5236{
5237 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
5238
5239 dsi->regn_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGN);
5240 dsi->regm_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM);
5241 dsi->regm_hsdiv_max =
5242 dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM_HSDIV);
5243 dsi->fint_min = dss_feat_get_param_min(FEAT_PARAM_DSIPLL_FINT);
5244 dsi->fint_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_FINT);
5245 dsi->lpdiv_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_LPDIV);
5246}
5247
5248static int dsi_get_clocks(struct platform_device *dsidev) 4965static int dsi_get_clocks(struct platform_device *dsidev)
5249{ 4966{
5250 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 4967 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
@@ -5258,14 +4975,6 @@ static int dsi_get_clocks(struct platform_device *dsidev)
5258 4975
5259 dsi->dss_clk = clk; 4976 dsi->dss_clk = clk;
5260 4977
5261 clk = devm_clk_get(&dsidev->dev, "sys_clk");
5262 if (IS_ERR(clk)) {
5263 DSSERR("can't get sys_clk\n");
5264 return PTR_ERR(clk);
5265 }
5266
5267 dsi->sys_clk = clk;
5268
5269 return 0; 4978 return 0;
5270} 4979}
5271 4980
@@ -5434,6 +5143,135 @@ err:
5434 return r; 5143 return r;
5435} 5144}
5436 5145
5146static const struct dss_pll_ops dsi_pll_ops = {
5147 .enable = dsi_pll_enable,
5148 .disable = dsi_pll_disable,
5149 .set_config = dss_pll_write_config_type_a,
5150};
5151
5152static const struct dss_pll_hw dss_omap3_dsi_pll_hw = {
5153 .n_max = (1 << 7) - 1,
5154 .m_max = (1 << 11) - 1,
5155 .mX_max = (1 << 4) - 1,
5156 .fint_min = 750000,
5157 .fint_max = 2100000,
5158 .clkdco_low = 1000000000,
5159 .clkdco_max = 1800000000,
5160
5161 .n_msb = 7,
5162 .n_lsb = 1,
5163 .m_msb = 18,
5164 .m_lsb = 8,
5165
5166 .mX_msb[0] = 22,
5167 .mX_lsb[0] = 19,
5168 .mX_msb[1] = 26,
5169 .mX_lsb[1] = 23,
5170
5171 .has_stopmode = true,
5172 .has_freqsel = true,
5173 .has_selfreqdco = false,
5174 .has_refsel = false,
5175};
5176
5177static const struct dss_pll_hw dss_omap4_dsi_pll_hw = {
5178 .n_max = (1 << 8) - 1,
5179 .m_max = (1 << 12) - 1,
5180 .mX_max = (1 << 5) - 1,
5181 .fint_min = 500000,
5182 .fint_max = 2500000,
5183 .clkdco_low = 1000000000,
5184 .clkdco_max = 1800000000,
5185
5186 .n_msb = 8,
5187 .n_lsb = 1,
5188 .m_msb = 20,
5189 .m_lsb = 9,
5190
5191 .mX_msb[0] = 25,
5192 .mX_lsb[0] = 21,
5193 .mX_msb[1] = 30,
5194 .mX_lsb[1] = 26,
5195
5196 .has_stopmode = true,
5197 .has_freqsel = false,
5198 .has_selfreqdco = false,
5199 .has_refsel = false,
5200};
5201
5202static const struct dss_pll_hw dss_omap5_dsi_pll_hw = {
5203 .n_max = (1 << 8) - 1,
5204 .m_max = (1 << 12) - 1,
5205 .mX_max = (1 << 5) - 1,
5206 .fint_min = 150000,
5207 .fint_max = 52000000,
5208 .clkdco_low = 1000000000,
5209 .clkdco_max = 1800000000,
5210
5211 .n_msb = 8,
5212 .n_lsb = 1,
5213 .m_msb = 20,
5214 .m_lsb = 9,
5215
5216 .mX_msb[0] = 25,
5217 .mX_lsb[0] = 21,
5218 .mX_msb[1] = 30,
5219 .mX_lsb[1] = 26,
5220
5221 .has_stopmode = true,
5222 .has_freqsel = false,
5223 .has_selfreqdco = true,
5224 .has_refsel = true,
5225};
5226
5227static int dsi_init_pll_data(struct platform_device *dsidev)
5228{
5229 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
5230 struct dss_pll *pll = &dsi->pll;
5231 struct clk *clk;
5232 int r;
5233
5234 clk = devm_clk_get(&dsidev->dev, "sys_clk");
5235 if (IS_ERR(clk)) {
5236 DSSERR("can't get sys_clk\n");
5237 return PTR_ERR(clk);
5238 }
5239
5240 pll->name = dsi->module_id == 0 ? "dsi0" : "dsi1";
5241 pll->clkin = clk;
5242 pll->base = dsi->pll_base;
5243
5244 switch (omapdss_get_version()) {
5245 case OMAPDSS_VER_OMAP34xx_ES1:
5246 case OMAPDSS_VER_OMAP34xx_ES3:
5247 case OMAPDSS_VER_OMAP3630:
5248 case OMAPDSS_VER_AM35xx:
5249 pll->hw = &dss_omap3_dsi_pll_hw;
5250 break;
5251
5252 case OMAPDSS_VER_OMAP4430_ES1:
5253 case OMAPDSS_VER_OMAP4430_ES2:
5254 case OMAPDSS_VER_OMAP4:
5255 pll->hw = &dss_omap4_dsi_pll_hw;
5256 break;
5257
5258 case OMAPDSS_VER_OMAP5:
5259 pll->hw = &dss_omap5_dsi_pll_hw;
5260 break;
5261
5262 default:
5263 return -ENODEV;
5264 }
5265
5266 pll->ops = &dsi_pll_ops;
5267
5268 r = dss_pll_register(pll);
5269 if (r)
5270 return r;
5271
5272 return 0;
5273}
5274
5437/* DSI1 HW IP initialisation */ 5275/* DSI1 HW IP initialisation */
5438static int omap_dsihw_probe(struct platform_device *dsidev) 5276static int omap_dsihw_probe(struct platform_device *dsidev)
5439{ 5277{
@@ -5579,12 +5417,12 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
5579 dsi->vc[i].vc_id = 0; 5417 dsi->vc[i].vc_id = 0;
5580 } 5418 }
5581 5419
5582 dsi_calc_clock_param_ranges(dsidev);
5583
5584 r = dsi_get_clocks(dsidev); 5420 r = dsi_get_clocks(dsidev);
5585 if (r) 5421 if (r)
5586 return r; 5422 return r;
5587 5423
5424 dsi_init_pll_data(dsidev);
5425
5588 pm_runtime_enable(&dsidev->dev); 5426 pm_runtime_enable(&dsidev->dev);
5589 5427
5590 r = dsi_runtime_get(dsidev); 5428 r = dsi_runtime_get(dsidev);
@@ -5653,6 +5491,8 @@ static int __exit omap_dsihw_remove(struct platform_device *dsidev)
5653 5491
5654 WARN_ON(dsi->scp_clk_refcount > 0); 5492 WARN_ON(dsi->scp_clk_refcount > 0);
5655 5493
5494 dss_pll_unregister(&dsi->pll);
5495
5656 dsi_uninit_output(dsidev); 5496 dsi_uninit_output(dsidev);
5657 5497
5658 pm_runtime_disable(&dsidev->dev); 5498 pm_runtime_disable(&dsidev->dev);
diff --git a/drivers/video/fbdev/omap2/dss/dss.h b/drivers/video/fbdev/omap2/dss/dss.h
index 8563e2bc702c..14fb0c23f4a2 100644
--- a/drivers/video/fbdev/omap2/dss/dss.h
+++ b/drivers/video/fbdev/omap2/dss/dss.h
@@ -173,18 +173,6 @@ struct dispc_clock_info {
173 u16 pck_div; 173 u16 pck_div;
174}; 174};
175 175
176struct dsi_clock_info {
177 /* rates that we get with dividers below */
178 unsigned long fint;
179 unsigned long clkdco;
180 unsigned long clkout[4];
181
182 /* dividers */
183 u16 regn;
184 u16 regm;
185 u16 regm_hsdiv[4];
186};
187
188struct dss_lcd_mgr_config { 176struct dss_lcd_mgr_config {
189 enum dss_io_pad_mode io_pad_mode; 177 enum dss_io_pad_mode io_pad_mode;
190 178
@@ -318,11 +306,6 @@ static inline void __exit sdi_uninit_port(struct device_node *port)
318 306
319/* DSI */ 307/* DSI */
320 308
321typedef bool (*dsi_pll_calc_func)(int regn, int regm, unsigned long fint,
322 unsigned long pll, void *data);
323typedef bool (*dsi_hsdiv_calc_func)(int regm_dispc, unsigned long dispc,
324 void *data);
325
326#ifdef CONFIG_OMAP2_DSS_DSI 309#ifdef CONFIG_OMAP2_DSS_DSI
327 310
328struct dentry; 311struct dentry;
@@ -336,71 +319,12 @@ void dsi_dump_clocks(struct seq_file *s);
336void dsi_irq_handler(void); 319void dsi_irq_handler(void);
337u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt); 320u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt);
338 321
339unsigned long dsi_get_pll_clkin(struct platform_device *dsidev);
340
341bool dsi_hsdiv_calc(struct platform_device *dsidev, unsigned long pll,
342 unsigned long out_min, dsi_hsdiv_calc_func func, void *data);
343bool dsi_pll_calc(struct platform_device *dsidev, unsigned long clkin,
344 unsigned long pll_min, unsigned long pll_max,
345 dsi_pll_calc_func func, void *data);
346
347unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev);
348int dsi_pll_set_clock_div(struct platform_device *dsidev,
349 struct dsi_clock_info *cinfo);
350int dsi_pll_init(struct platform_device *dsidev);
351void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes);
352struct platform_device *dsi_get_dsidev_from_id(int module);
353#else 322#else
354static inline u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt) 323static inline u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
355{ 324{
356 WARN("%s: DSI not compiled in, returning pixel_size as 0\n", __func__); 325 WARN("%s: DSI not compiled in, returning pixel_size as 0\n", __func__);
357 return 0; 326 return 0;
358} 327}
359static inline unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev)
360{
361 WARN("%s: DSI not compiled in, returning rate as 0\n", __func__);
362 return 0;
363}
364static inline int dsi_pll_set_clock_div(struct platform_device *dsidev,
365 struct dsi_clock_info *cinfo)
366{
367 WARN("%s: DSI not compiled in\n", __func__);
368 return -ENODEV;
369}
370static inline int dsi_pll_init(struct platform_device *dsidev)
371{
372 WARN("%s: DSI not compiled in\n", __func__);
373 return -ENODEV;
374}
375static inline void dsi_pll_uninit(struct platform_device *dsidev,
376 bool disconnect_lanes)
377{
378}
379static inline struct platform_device *dsi_get_dsidev_from_id(int module)
380{
381 return NULL;
382}
383
384static inline unsigned long dsi_get_pll_clkin(struct platform_device *dsidev)
385{
386 return 0;
387}
388
389static inline bool dsi_hsdiv_calc(struct platform_device *dsidev,
390 unsigned long pll, unsigned long out_min,
391 dsi_hsdiv_calc_func func, void *data)
392{
393 return false;
394}
395
396static inline bool dsi_pll_calc(struct platform_device *dsidev,
397 unsigned long clkin,
398 unsigned long pll_min, unsigned long pll_max,
399 dsi_pll_calc_func func, void *data)
400{
401 return false;
402}
403
404#endif 328#endif
405 329
406/* DPI */ 330/* DPI */