diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2011-03-14 08:28:57 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2011-03-18 00:01:01 -0400 |
commit | 0acf659f1469725fb6e39d53af970f36c5f69a41 (patch) | |
tree | 1a2be738a9514b7f0256fe1806b246507fe95b38 /drivers/video | |
parent | 17c84ef1e1265fad787d4082bd40a63eb6f3eeb1 (diff) |
OMAP: DSS2: Clean up for dpll4_m4_ck handling
OMAP2 does not have dpll4_m4_ck source clock for dss functional clock,
but later OMAPs do. Currently we check for cpu type in multiple places
to find out if dpll4_m4_ck is available.
This patch cleans up dss.c by using the fact that dss.dpll4_m4_ck
pointer is NULL on OMAP2. This allows us to remove many of the cpu
checks.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/omap2/dss/dss.c | 93 |
1 files changed, 59 insertions, 34 deletions
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c index f1628bd850d1..9d2390299df7 100644 --- a/drivers/video/omap2/dss/dss.c +++ b/drivers/video/omap2/dss/dss.c | |||
@@ -239,30 +239,40 @@ void dss_dump_clocks(struct seq_file *s) | |||
239 | { | 239 | { |
240 | unsigned long dpll4_ck_rate; | 240 | unsigned long dpll4_ck_rate; |
241 | unsigned long dpll4_m4_ck_rate; | 241 | unsigned long dpll4_m4_ck_rate; |
242 | const char *fclk_name, *fclk_real_name; | ||
243 | unsigned long fclk_rate; | ||
242 | 244 | ||
243 | dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK); | 245 | dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK); |
244 | 246 | ||
245 | dpll4_ck_rate = clk_get_rate(clk_get_parent(dss.dpll4_m4_ck)); | ||
246 | dpll4_m4_ck_rate = clk_get_rate(dss.dpll4_m4_ck); | ||
247 | |||
248 | seq_printf(s, "- DSS -\n"); | 247 | seq_printf(s, "- DSS -\n"); |
249 | 248 | ||
250 | seq_printf(s, "dpll4_ck %lu\n", dpll4_ck_rate); | 249 | fclk_name = dss_get_generic_clk_source_name(DSS_CLK_SRC_FCK); |
250 | fclk_real_name = dss_feat_get_clk_source_name(DSS_CLK_SRC_FCK); | ||
251 | fclk_rate = dss_clk_get_rate(DSS_CLK_FCK); | ||
251 | 252 | ||
252 | if (cpu_is_omap3630()) | 253 | if (dss.dpll4_m4_ck) { |
253 | seq_printf(s, "%s (%s) = %lu / %lu = %lu\n", | 254 | dpll4_ck_rate = clk_get_rate(clk_get_parent(dss.dpll4_m4_ck)); |
254 | dss_get_generic_clk_source_name(DSS_CLK_SRC_FCK), | 255 | dpll4_m4_ck_rate = clk_get_rate(dss.dpll4_m4_ck); |
255 | dss_feat_get_clk_source_name(DSS_CLK_SRC_FCK), | 256 | |
256 | dpll4_ck_rate, | 257 | seq_printf(s, "dpll4_ck %lu\n", dpll4_ck_rate); |
257 | dpll4_ck_rate / dpll4_m4_ck_rate, | 258 | |
258 | dss_clk_get_rate(DSS_CLK_FCK)); | 259 | if (cpu_is_omap3630()) |
259 | else | 260 | seq_printf(s, "%s (%s) = %lu / %lu = %lu\n", |
260 | seq_printf(s, "%s (%s) = %lu / %lu * 2 = %lu\n", | 261 | fclk_name, fclk_real_name, |
261 | dss_get_generic_clk_source_name(DSS_CLK_SRC_FCK), | 262 | dpll4_ck_rate, |
262 | dss_feat_get_clk_source_name(DSS_CLK_SRC_FCK), | 263 | dpll4_ck_rate / dpll4_m4_ck_rate, |
263 | dpll4_ck_rate, | 264 | fclk_rate); |
264 | dpll4_ck_rate / dpll4_m4_ck_rate, | 265 | else |
265 | dss_clk_get_rate(DSS_CLK_FCK)); | 266 | seq_printf(s, "%s (%s) = %lu / %lu * 2 = %lu\n", |
267 | fclk_name, fclk_real_name, | ||
268 | dpll4_ck_rate, | ||
269 | dpll4_ck_rate / dpll4_m4_ck_rate, | ||
270 | fclk_rate); | ||
271 | } else { | ||
272 | seq_printf(s, "%s (%s) = %lu\n", | ||
273 | fclk_name, fclk_real_name, | ||
274 | fclk_rate); | ||
275 | } | ||
266 | 276 | ||
267 | dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK); | 277 | dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK); |
268 | } | 278 | } |
@@ -382,31 +392,40 @@ enum dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel) | |||
382 | /* calculate clock rates using dividers in cinfo */ | 392 | /* calculate clock rates using dividers in cinfo */ |
383 | int dss_calc_clock_rates(struct dss_clock_info *cinfo) | 393 | int dss_calc_clock_rates(struct dss_clock_info *cinfo) |
384 | { | 394 | { |
385 | unsigned long prate; | 395 | if (dss.dpll4_m4_ck) { |
396 | unsigned long prate; | ||
386 | 397 | ||
387 | if (cinfo->fck_div > (cpu_is_omap3630() ? 32 : 16) || | 398 | if (cinfo->fck_div > (cpu_is_omap3630() ? 32 : 16) || |
388 | cinfo->fck_div == 0) | 399 | cinfo->fck_div == 0) |
389 | return -EINVAL; | 400 | return -EINVAL; |
390 | 401 | ||
391 | prate = clk_get_rate(clk_get_parent(dss.dpll4_m4_ck)); | 402 | prate = clk_get_rate(clk_get_parent(dss.dpll4_m4_ck)); |
392 | 403 | ||
393 | cinfo->fck = prate / cinfo->fck_div; | 404 | cinfo->fck = prate / cinfo->fck_div; |
405 | } else { | ||
406 | if (cinfo->fck_div != 0) | ||
407 | return -EINVAL; | ||
408 | cinfo->fck = dss_clk_get_rate(DSS_CLK_FCK); | ||
409 | } | ||
394 | 410 | ||
395 | return 0; | 411 | return 0; |
396 | } | 412 | } |
397 | 413 | ||
398 | int dss_set_clock_div(struct dss_clock_info *cinfo) | 414 | int dss_set_clock_div(struct dss_clock_info *cinfo) |
399 | { | 415 | { |
400 | unsigned long prate; | 416 | if (dss.dpll4_m4_ck) { |
401 | int r; | 417 | unsigned long prate; |
418 | int r; | ||
402 | 419 | ||
403 | if (cpu_is_omap34xx()) { | ||
404 | prate = clk_get_rate(clk_get_parent(dss.dpll4_m4_ck)); | 420 | prate = clk_get_rate(clk_get_parent(dss.dpll4_m4_ck)); |
405 | DSSDBG("dpll4_m4 = %ld\n", prate); | 421 | DSSDBG("dpll4_m4 = %ld\n", prate); |
406 | 422 | ||
407 | r = clk_set_rate(dss.dpll4_m4_ck, prate / cinfo->fck_div); | 423 | r = clk_set_rate(dss.dpll4_m4_ck, prate / cinfo->fck_div); |
408 | if (r) | 424 | if (r) |
409 | return r; | 425 | return r; |
426 | } else { | ||
427 | if (cinfo->fck_div != 0) | ||
428 | return -EINVAL; | ||
410 | } | 429 | } |
411 | 430 | ||
412 | DSSDBG("fck = %ld (%d)\n", cinfo->fck, cinfo->fck_div); | 431 | DSSDBG("fck = %ld (%d)\n", cinfo->fck, cinfo->fck_div); |
@@ -418,9 +437,11 @@ int dss_get_clock_div(struct dss_clock_info *cinfo) | |||
418 | { | 437 | { |
419 | cinfo->fck = dss_clk_get_rate(DSS_CLK_FCK); | 438 | cinfo->fck = dss_clk_get_rate(DSS_CLK_FCK); |
420 | 439 | ||
421 | if (cpu_is_omap34xx()) { | 440 | if (dss.dpll4_m4_ck) { |
422 | unsigned long prate; | 441 | unsigned long prate; |
442 | |||
423 | prate = clk_get_rate(clk_get_parent(dss.dpll4_m4_ck)); | 443 | prate = clk_get_rate(clk_get_parent(dss.dpll4_m4_ck)); |
444 | |||
424 | if (cpu_is_omap3630()) | 445 | if (cpu_is_omap3630()) |
425 | cinfo->fck_div = prate / (cinfo->fck); | 446 | cinfo->fck_div = prate / (cinfo->fck); |
426 | else | 447 | else |
@@ -434,7 +455,7 @@ int dss_get_clock_div(struct dss_clock_info *cinfo) | |||
434 | 455 | ||
435 | unsigned long dss_get_dpll4_rate(void) | 456 | unsigned long dss_get_dpll4_rate(void) |
436 | { | 457 | { |
437 | if (cpu_is_omap34xx()) | 458 | if (dss.dpll4_m4_ck) |
438 | return clk_get_rate(clk_get_parent(dss.dpll4_m4_ck)); | 459 | return clk_get_rate(clk_get_parent(dss.dpll4_m4_ck)); |
439 | else | 460 | else |
440 | return 0; | 461 | return 0; |
@@ -615,6 +636,7 @@ static int dss_init(void) | |||
615 | int r; | 636 | int r; |
616 | u32 rev; | 637 | u32 rev; |
617 | struct resource *dss_mem; | 638 | struct resource *dss_mem; |
639 | struct clk *dpll4_m4_ck; | ||
618 | 640 | ||
619 | dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); | 641 | dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); |
620 | if (!dss_mem) { | 642 | if (!dss_mem) { |
@@ -655,16 +677,19 @@ static int dss_init(void) | |||
655 | REG_FLD_MOD(DSS_CONTROL, 1, 3, 3); /* venc clock 4x enable */ | 677 | REG_FLD_MOD(DSS_CONTROL, 1, 3, 3); /* venc clock 4x enable */ |
656 | REG_FLD_MOD(DSS_CONTROL, 0, 2, 2); /* venc clock mode = normal */ | 678 | REG_FLD_MOD(DSS_CONTROL, 0, 2, 2); /* venc clock mode = normal */ |
657 | #endif | 679 | #endif |
658 | |||
659 | if (cpu_is_omap34xx()) { | 680 | if (cpu_is_omap34xx()) { |
660 | dss.dpll4_m4_ck = clk_get(NULL, "dpll4_m4_ck"); | 681 | dpll4_m4_ck = clk_get(NULL, "dpll4_m4_ck"); |
661 | if (IS_ERR(dss.dpll4_m4_ck)) { | 682 | if (IS_ERR(dpll4_m4_ck)) { |
662 | DSSERR("Failed to get dpll4_m4_ck\n"); | 683 | DSSERR("Failed to get dpll4_m4_ck\n"); |
663 | r = PTR_ERR(dss.dpll4_m4_ck); | 684 | r = PTR_ERR(dpll4_m4_ck); |
664 | goto fail1; | 685 | goto fail1; |
665 | } | 686 | } |
687 | } else { /* omap24xx */ | ||
688 | dpll4_m4_ck = NULL; | ||
666 | } | 689 | } |
667 | 690 | ||
691 | dss.dpll4_m4_ck = dpll4_m4_ck; | ||
692 | |||
668 | dss.dsi_clk_source = DSS_CLK_SRC_FCK; | 693 | dss.dsi_clk_source = DSS_CLK_SRC_FCK; |
669 | dss.dispc_clk_source = DSS_CLK_SRC_FCK; | 694 | dss.dispc_clk_source = DSS_CLK_SRC_FCK; |
670 | dss.lcd_clk_source[0] = DSS_CLK_SRC_FCK; | 695 | dss.lcd_clk_source[0] = DSS_CLK_SRC_FCK; |
@@ -686,7 +711,7 @@ fail0: | |||
686 | 711 | ||
687 | static void dss_exit(void) | 712 | static void dss_exit(void) |
688 | { | 713 | { |
689 | if (cpu_is_omap34xx()) | 714 | if (dss.dpll4_m4_ck) |
690 | clk_put(dss.dpll4_m4_ck); | 715 | clk_put(dss.dpll4_m4_ck); |
691 | 716 | ||
692 | iounmap(dss.base); | 717 | iounmap(dss.base); |