aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2013-10-31 08:44:23 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2013-11-18 07:32:26 -0500
commitd0f58bd3bba3877fb1af4664c4e33273d36f00e4 (patch)
tree83051d3197332e7cf6d4bd54dd266f1b5d9a1113
parent6e555e2752ea284bda55b0ee477a512e1525b84a (diff)
OMAPDSS: remove struct dss_clock_info
Remove struct dss_clock_info, as it is not usable in a case where DSS fclk comes from a dedicated PLL. Instead, just use the fclk rate in place of dss_clock_info, as that is all that's needed. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--drivers/video/omap2/dss/dpi.c13
-rw-r--r--drivers/video/omap2/dss/dss.c59
-rw-r--r--drivers/video/omap2/dss/dss.h13
-rw-r--r--drivers/video/omap2/dss/sdi.c19
4 files changed, 30 insertions, 74 deletions
diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index bd48cde53561..16acdddc94e3 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -117,7 +117,7 @@ struct dpi_clk_calc_ctx {
117 /* outputs */ 117 /* outputs */
118 118
119 struct dsi_clock_info dsi_cinfo; 119 struct dsi_clock_info dsi_cinfo;
120 struct dss_clock_info dss_cinfo; 120 unsigned long long fck;
121 struct dispc_clock_info dispc_cinfo; 121 struct dispc_clock_info dispc_cinfo;
122}; 122};
123 123
@@ -184,12 +184,11 @@ static bool dpi_calc_pll_cb(int regn, int regm, unsigned long fint,
184 dpi_calc_hsdiv_cb, ctx); 184 dpi_calc_hsdiv_cb, ctx);
185} 185}
186 186
187static bool dpi_calc_dss_cb(int fckd, unsigned long fck, void *data) 187static bool dpi_calc_dss_cb(unsigned long fck, void *data)
188{ 188{
189 struct dpi_clk_calc_ctx *ctx = data; 189 struct dpi_clk_calc_ctx *ctx = data;
190 190
191 ctx->dss_cinfo.fck = fck; 191 ctx->fck = fck;
192 ctx->dss_cinfo.fck_div = fckd;
193 192
194 return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max, 193 return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max,
195 dpi_calc_dispc_cb, ctx); 194 dpi_calc_dispc_cb, ctx);
@@ -286,13 +285,13 @@ static int dpi_set_dispc_clk(unsigned long pck_req, unsigned long *fck,
286 if (!ok) 285 if (!ok)
287 return -EINVAL; 286 return -EINVAL;
288 287
289 r = dss_set_clock_div(&ctx.dss_cinfo); 288 r = dss_set_fck_rate(ctx.fck);
290 if (r) 289 if (r)
291 return r; 290 return r;
292 291
293 dpi.mgr_config.clock_info = ctx.dispc_cinfo; 292 dpi.mgr_config.clock_info = ctx.dispc_cinfo;
294 293
295 *fck = ctx.dss_cinfo.fck; 294 *fck = ctx.fck;
296 *lck_div = ctx.dispc_cinfo.lck_div; 295 *lck_div = ctx.dispc_cinfo.lck_div;
297 *pck_div = ctx.dispc_cinfo.pck_div; 296 *pck_div = ctx.dispc_cinfo.pck_div;
298 297
@@ -495,7 +494,7 @@ static int dpi_check_timings(struct omap_dss_device *dssdev,
495 if (!ok) 494 if (!ok)
496 return -EINVAL; 495 return -EINVAL;
497 496
498 fck = ctx.dss_cinfo.fck; 497 fck = ctx.fck;
499 } 498 }
500 499
501 lck_div = ctx.dispc_cinfo.lck_div; 500 lck_div = ctx.dispc_cinfo.lck_div;
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index e59577a2c41c..c37d934e1a57 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -81,7 +81,6 @@ static struct {
81 81
82 unsigned long cache_req_pck; 82 unsigned long cache_req_pck;
83 unsigned long cache_prate; 83 unsigned long cache_prate;
84 struct dss_clock_info cache_dss_cinfo;
85 struct dispc_clock_info cache_dispc_cinfo; 84 struct dispc_clock_info cache_dispc_cinfo;
86 85
87 enum omap_dss_clk_source dsi_clk_source[MAX_NUM_DSI]; 86 enum omap_dss_clk_source dsi_clk_source[MAX_NUM_DSI];
@@ -451,29 +450,6 @@ enum omap_dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel)
451 } 450 }
452} 451}
453 452
454/* calculate clock rates using dividers in cinfo */
455int dss_calc_clock_rates(struct dss_clock_info *cinfo)
456{
457 if (dss.dpll4_m4_ck) {
458 unsigned long prate;
459
460 if (cinfo->fck_div > dss.feat->fck_div_max ||
461 cinfo->fck_div == 0)
462 return -EINVAL;
463
464 prate = clk_get_rate(clk_get_parent(dss.dpll4_m4_ck));
465
466 cinfo->fck = prate / cinfo->fck_div *
467 dss.feat->dss_fck_multiplier;
468 } else {
469 if (cinfo->fck_div != 0)
470 return -EINVAL;
471 cinfo->fck = clk_get_rate(dss.dss_clk);
472 }
473
474 return 0;
475}
476
477bool dss_div_calc(unsigned long fck_min, dss_div_calc_func func, void *data) 453bool dss_div_calc(unsigned long fck_min, dss_div_calc_func func, void *data)
478{ 454{
479 int fckd, fckd_start, fckd_stop; 455 int fckd, fckd_start, fckd_stop;
@@ -485,8 +461,7 @@ bool dss_div_calc(unsigned long fck_min, dss_div_calc_func func, void *data)
485 461
486 if (dss.dpll4_m4_ck == NULL) { 462 if (dss.dpll4_m4_ck == NULL) {
487 fck = clk_get_rate(dss.dss_clk); 463 fck = clk_get_rate(dss.dss_clk);
488 fckd = 1; 464 return func(fck, data);
489 return func(fckd, fck, data);
490 } 465 }
491 466
492 fck_hw_max = dss_feat_get_param_max(FEAT_PARAM_DSS_FCK); 467 fck_hw_max = dss_feat_get_param_max(FEAT_PARAM_DSS_FCK);
@@ -503,38 +478,35 @@ bool dss_div_calc(unsigned long fck_min, dss_div_calc_func func, void *data)
503 for (fckd = fckd_start; fckd >= fckd_stop; --fckd) { 478 for (fckd = fckd_start; fckd >= fckd_stop; --fckd) {
504 fck = prate / fckd * m; 479 fck = prate / fckd * m;
505 480
506 if (func(fckd, fck, data)) 481 if (func(fck, data))
507 return true; 482 return true;
508 } 483 }
509 484
510 return false; 485 return false;
511} 486}
512 487
513int dss_set_clock_div(struct dss_clock_info *cinfo) 488int dss_set_fck_rate(unsigned long rate)
514{ 489{
490 DSSDBG("set fck to %lu\n", rate);
491
515 if (dss.dpll4_m4_ck) { 492 if (dss.dpll4_m4_ck) {
516 unsigned long prate; 493 unsigned long prate;
494 unsigned m;
517 int r; 495 int r;
518 496
519 prate = clk_get_rate(clk_get_parent(dss.dpll4_m4_ck)); 497 prate = clk_get_rate(clk_get_parent(dss.dpll4_m4_ck));
520 DSSDBG("dpll4_m4 = %ld\n", prate); 498 m = dss.feat->dss_fck_multiplier;
521 499
522 r = clk_set_rate(dss.dpll4_m4_ck, 500 r = clk_set_rate(dss.dpll4_m4_ck, rate * m);
523 DIV_ROUND_UP(prate, cinfo->fck_div));
524 if (r) 501 if (r)
525 return r; 502 return r;
526 } else {
527 if (cinfo->fck_div != 0)
528 return -EINVAL;
529 } 503 }
530 504
531 dss.dss_clk_rate = clk_get_rate(dss.dss_clk); 505 dss.dss_clk_rate = clk_get_rate(dss.dss_clk);
532 506
533 WARN_ONCE(dss.dss_clk_rate != cinfo->fck, 507 WARN_ONCE(dss.dss_clk_rate != rate,
534 "clk rate mismatch: %lu != %lu", dss.dss_clk_rate, 508 "clk rate mismatch: %lu != %lu", dss.dss_clk_rate,
535 cinfo->fck); 509 rate);
536
537 DSSDBG("fck = %ld (%d)\n", cinfo->fck, cinfo->fck_div);
538 510
539 return 0; 511 return 0;
540} 512}
@@ -555,8 +527,8 @@ unsigned long dss_get_dispc_clk_rate(void)
555static int dss_setup_default_clock(void) 527static int dss_setup_default_clock(void)
556{ 528{
557 unsigned long max_dss_fck, prate; 529 unsigned long max_dss_fck, prate;
530 unsigned long fck;
558 unsigned fck_div; 531 unsigned fck_div;
559 struct dss_clock_info dss_cinfo = { 0 };
560 int r; 532 int r;
561 533
562 if (dss.dpll4_m4_ck == NULL) 534 if (dss.dpll4_m4_ck == NULL)
@@ -568,14 +540,9 @@ static int dss_setup_default_clock(void)
568 540
569 fck_div = DIV_ROUND_UP(prate * dss.feat->dss_fck_multiplier, 541 fck_div = DIV_ROUND_UP(prate * dss.feat->dss_fck_multiplier,
570 max_dss_fck); 542 max_dss_fck);
543 fck = prate / fck_div * dss.feat->dss_fck_multiplier;
571 544
572 dss_cinfo.fck_div = fck_div; 545 r = dss_set_fck_rate(fck);
573
574 r = dss_calc_clock_rates(&dss_cinfo);
575 if (r)
576 return r;
577
578 r = dss_set_clock_div(&dss_cinfo);
579 if (r) 546 if (r)
580 return r; 547 return r;
581 548
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index e172531d196b..ead1960ad9d8 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -100,14 +100,6 @@ enum dss_writeback_channel {
100 DSS_WB_LCD3_MGR = 7, 100 DSS_WB_LCD3_MGR = 7,
101}; 101};
102 102
103struct dss_clock_info {
104 /* rates that we get with dividers below */
105 unsigned long fck;
106
107 /* dividers */
108 u16 fck_div;
109};
110
111struct dispc_clock_info { 103struct dispc_clock_info {
112 /* rates that we get with dividers below */ 104 /* rates that we get with dividers below */
113 unsigned long lck; 105 unsigned long lck;
@@ -251,10 +243,9 @@ void dss_set_venc_output(enum omap_dss_venc_type type);
251void dss_set_dac_pwrdn_bgz(bool enable); 243void dss_set_dac_pwrdn_bgz(bool enable);
252 244
253unsigned long dss_get_dpll4_rate(void); 245unsigned long dss_get_dpll4_rate(void);
254int dss_calc_clock_rates(struct dss_clock_info *cinfo); 246int dss_set_fck_rate(unsigned long rate);
255int dss_set_clock_div(struct dss_clock_info *cinfo);
256 247
257typedef bool (*dss_div_calc_func)(int fckd, unsigned long fck, void *data); 248typedef bool (*dss_div_calc_func)(unsigned long fck, void *data);
258bool dss_div_calc(unsigned long fck_min, dss_div_calc_func func, void *data); 249bool dss_div_calc(unsigned long fck_min, dss_div_calc_func func, void *data);
259 250
260/* SDI */ 251/* SDI */
diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c
index ccc569ae7cca..221fd34c42ff 100644
--- a/drivers/video/omap2/dss/sdi.c
+++ b/drivers/video/omap2/dss/sdi.c
@@ -46,7 +46,7 @@ static struct {
46struct sdi_clk_calc_ctx { 46struct sdi_clk_calc_ctx {
47 unsigned long pck_min, pck_max; 47 unsigned long pck_min, pck_max;
48 48
49 struct dss_clock_info dss_cinfo; 49 unsigned long long fck;
50 struct dispc_clock_info dispc_cinfo; 50 struct dispc_clock_info dispc_cinfo;
51}; 51};
52 52
@@ -63,19 +63,18 @@ static bool dpi_calc_dispc_cb(int lckd, int pckd, unsigned long lck,
63 return true; 63 return true;
64} 64}
65 65
66static bool dpi_calc_dss_cb(int fckd, unsigned long fck, void *data) 66static bool dpi_calc_dss_cb(unsigned long fck, void *data)
67{ 67{
68 struct sdi_clk_calc_ctx *ctx = data; 68 struct sdi_clk_calc_ctx *ctx = data;
69 69
70 ctx->dss_cinfo.fck = fck; 70 ctx->fck = fck;
71 ctx->dss_cinfo.fck_div = fckd;
72 71
73 return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max, 72 return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max,
74 dpi_calc_dispc_cb, ctx); 73 dpi_calc_dispc_cb, ctx);
75} 74}
76 75
77static int sdi_calc_clock_div(unsigned long pclk, 76static int sdi_calc_clock_div(unsigned long pclk,
78 struct dss_clock_info *dss_cinfo, 77 unsigned long *fck,
79 struct dispc_clock_info *dispc_cinfo) 78 struct dispc_clock_info *dispc_cinfo)
80{ 79{
81 int i; 80 int i;
@@ -100,7 +99,7 @@ static int sdi_calc_clock_div(unsigned long pclk,
100 99
101 ok = dss_div_calc(ctx.pck_min, dpi_calc_dss_cb, &ctx); 100 ok = dss_div_calc(ctx.pck_min, dpi_calc_dss_cb, &ctx);
102 if (ok) { 101 if (ok) {
103 *dss_cinfo = ctx.dss_cinfo; 102 *fck = ctx.fck;
104 *dispc_cinfo = ctx.dispc_cinfo; 103 *dispc_cinfo = ctx.dispc_cinfo;
105 return 0; 104 return 0;
106 } 105 }
@@ -128,7 +127,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
128{ 127{
129 struct omap_dss_device *out = &sdi.output; 128 struct omap_dss_device *out = &sdi.output;
130 struct omap_video_timings *t = &sdi.timings; 129 struct omap_video_timings *t = &sdi.timings;
131 struct dss_clock_info dss_cinfo; 130 unsigned long fck;
132 struct dispc_clock_info dispc_cinfo; 131 struct dispc_clock_info dispc_cinfo;
133 unsigned long pck; 132 unsigned long pck;
134 int r; 133 int r;
@@ -150,13 +149,13 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
150 t->data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE; 149 t->data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE;
151 t->sync_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE; 150 t->sync_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE;
152 151
153 r = sdi_calc_clock_div(t->pixel_clock * 1000, &dss_cinfo, &dispc_cinfo); 152 r = sdi_calc_clock_div(t->pixel_clock * 1000, &fck, &dispc_cinfo);
154 if (r) 153 if (r)
155 goto err_calc_clock_div; 154 goto err_calc_clock_div;
156 155
157 sdi.mgr_config.clock_info = dispc_cinfo; 156 sdi.mgr_config.clock_info = dispc_cinfo;
158 157
159 pck = dss_cinfo.fck / dispc_cinfo.lck_div / dispc_cinfo.pck_div / 1000; 158 pck = fck / dispc_cinfo.lck_div / dispc_cinfo.pck_div / 1000;
160 159
161 if (pck != t->pixel_clock) { 160 if (pck != t->pixel_clock) {
162 DSSWARN("Could not find exact pixel clock. Requested %d kHz, " 161 DSSWARN("Could not find exact pixel clock. Requested %d kHz, "
@@ -169,7 +168,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
169 168
170 dss_mgr_set_timings(out->manager, t); 169 dss_mgr_set_timings(out->manager, t);
171 170
172 r = dss_set_clock_div(&dss_cinfo); 171 r = dss_set_fck_rate(fck);
173 if (r) 172 if (r)
174 goto err_set_dss_clock_div; 173 goto err_set_dss_clock_div;
175 174