aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-shmobile/board-ag5evm.c36
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c25
-rw-r--r--drivers/video/sh_mipi_dsi.c45
-rw-r--r--include/video/sh_mipi_dsi.h3
4 files changed, 70 insertions, 39 deletions
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index 6993844424c6..15072c51e035 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -321,6 +321,36 @@ static struct resource mipidsi0_resources[] = {
321 }, 321 },
322}; 322};
323 323
324#define DSI0PHYCR 0xe615006c
325static int sh_mipi_set_dot_clock(struct platform_device *pdev,
326 void __iomem *base,
327 int enable)
328{
329 struct clk *pck;
330 int ret;
331
332 pck = clk_get(&pdev->dev, "dsip_clk");
333 if (IS_ERR(pck)) {
334 ret = PTR_ERR(pck);
335 goto sh_mipi_set_dot_clock_pck_err;
336 }
337
338 if (enable) {
339 clk_set_rate(pck, clk_round_rate(pck, 24000000));
340 __raw_writel(0x2a809010, DSI0PHYCR);
341 clk_enable(pck);
342 } else {
343 clk_disable(pck);
344 }
345
346 ret = 0;
347
348 clk_put(pck);
349
350sh_mipi_set_dot_clock_pck_err:
351 return ret;
352}
353
324static struct sh_mipi_dsi_info mipidsi0_info = { 354static struct sh_mipi_dsi_info mipidsi0_info = {
325 .data_format = MIPI_RGB888, 355 .data_format = MIPI_RGB888,
326 .lcd_chan = &lcdc0_info.ch[0], 356 .lcd_chan = &lcdc0_info.ch[0],
@@ -329,6 +359,7 @@ static struct sh_mipi_dsi_info mipidsi0_info = {
329 .clksrc = 1, 359 .clksrc = 1,
330 .flags = SH_MIPI_DSI_HSABM | 360 .flags = SH_MIPI_DSI_HSABM |
331 SH_MIPI_DSI_SYNC_PULSES_MODE, 361 SH_MIPI_DSI_SYNC_PULSES_MODE,
362 .set_dot_clock = sh_mipi_set_dot_clock,
332}; 363};
333 364
334static struct platform_device mipidsi0_device = { 365static struct platform_device mipidsi0_device = {
@@ -476,8 +507,6 @@ static void __init ag5evm_map_io(void)
476 shmobile_setup_console(); 507 shmobile_setup_console();
477} 508}
478 509
479#define DSI0PHYCR 0xe615006c
480
481static void __init ag5evm_init(void) 510static void __init ag5evm_init(void)
482{ 511{
483 sh73a0_pinmux_init(); 512 sh73a0_pinmux_init();
@@ -558,9 +587,6 @@ static void __init ag5evm_init(void)
558 gpio_direction_output(GPIO_PORT235, 0); 587 gpio_direction_output(GPIO_PORT235, 0);
559 lcd_backlight_reset(); 588 lcd_backlight_reset();
560 589
561 /* MIPI-DSI clock setup */
562 __raw_writel(0x2a809010, DSI0PHYCR);
563
564 /* enable SDHI0 on CN15 [SD I/F] */ 590 /* enable SDHI0 on CN15 [SD I/F] */
565 gpio_request(GPIO_FN_SDHICD0, NULL); 591 gpio_request(GPIO_FN_SDHICD0, NULL);
566 gpio_request(GPIO_FN_SDHIWP0, NULL); 592 gpio_request(GPIO_FN_SDHIWP0, NULL);
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index b2e32c8c9e54..73503ed8bde2 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -564,6 +564,30 @@ static struct platform_device keysc_device = {
564}; 564};
565 565
566/* MIPI-DSI */ 566/* MIPI-DSI */
567#define PHYCTRL 0x0070
568static int sh_mipi_set_dot_clock(struct platform_device *pdev,
569 void __iomem *base,
570 int enable)
571{
572 struct clk *pck = clk_get(&pdev->dev, "dsip_clk");
573 void __iomem *phy = base + PHYCTRL;
574
575 if (IS_ERR(pck))
576 return PTR_ERR(pck);
577
578 if (enable) {
579 clk_set_rate(pck, clk_round_rate(pck, 24000000));
580 iowrite32(ioread32(phy) | (0xb << 8), phy);
581 clk_enable(pck);
582 } else {
583 clk_disable(pck);
584 }
585
586 clk_put(pck);
587
588 return 0;
589}
590
567static struct resource mipidsi0_resources[] = { 591static struct resource mipidsi0_resources[] = {
568 [0] = { 592 [0] = {
569 .start = 0xffc60000, 593 .start = 0xffc60000,
@@ -583,6 +607,7 @@ static struct sh_mipi_dsi_info mipidsi0_info = {
583 .lane = 2, 607 .lane = 2,
584 .vsynw_offset = 17, 608 .vsynw_offset = 17,
585 .flags = SH_MIPI_DSI_SYNC_PULSES_MODE, 609 .flags = SH_MIPI_DSI_SYNC_PULSES_MODE,
610 .set_dot_clock = sh_mipi_set_dot_clock,
586}; 611};
587 612
588static struct platform_device mipidsi0_device = { 613static struct platform_device mipidsi0_device = {
diff --git a/drivers/video/sh_mipi_dsi.c b/drivers/video/sh_mipi_dsi.c
index 190e941cf25d..77743f4388a0 100644
--- a/drivers/video/sh_mipi_dsi.c
+++ b/drivers/video/sh_mipi_dsi.c
@@ -53,7 +53,6 @@ struct sh_mipi {
53 void __iomem *base; 53 void __iomem *base;
54 void __iomem *linkbase; 54 void __iomem *linkbase;
55 struct clk *dsit_clk; 55 struct clk *dsit_clk;
56 struct clk *dsip_clk;
57 struct device *dev; 56 struct device *dev;
58 57
59 void *next_board_data; 58 void *next_board_data;
@@ -307,8 +306,8 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
307 /* DSI-Tx bias on */ 306 /* DSI-Tx bias on */
308 iowrite32(0x00000001, base + PHYCTRL); 307 iowrite32(0x00000001, base + PHYCTRL);
309 udelay(200); 308 udelay(200);
310 /* Deassert resets, power on, set multiplier */ 309 /* Deassert resets, power on */
311 iowrite32(0x03070b01, base + PHYCTRL); 310 iowrite32(0x03070001, base + PHYCTRL);
312 311
313 /* setup l-bridge */ 312 /* setup l-bridge */
314 313
@@ -421,6 +420,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
421 if (!res || !res2 || idx >= ARRAY_SIZE(mipi_dsi) || !pdata) 420 if (!res || !res2 || idx >= ARRAY_SIZE(mipi_dsi) || !pdata)
422 return -ENODEV; 421 return -ENODEV;
423 422
423 if (!pdata->set_dot_clock)
424 return -EINVAL;
425
424 mutex_lock(&array_lock); 426 mutex_lock(&array_lock);
425 if (idx < 0) 427 if (idx < 0)
426 for (idx = 0; idx < ARRAY_SIZE(mipi_dsi) && mipi_dsi[idx]; idx++) 428 for (idx = 0; idx < ARRAY_SIZE(mipi_dsi) && mipi_dsi[idx]; idx++)
@@ -481,34 +483,10 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
481 483
482 dev_dbg(&pdev->dev, "DSI-T clk %lu -> %lu\n", f_current, rate); 484 dev_dbg(&pdev->dev, "DSI-T clk %lu -> %lu\n", f_current, rate);
483 485
484 mipi->dsip_clk = clk_get(&pdev->dev, "dsip_clk");
485 if (IS_ERR(mipi->dsip_clk)) {
486 ret = PTR_ERR(mipi->dsip_clk);
487 goto eclkpget;
488 }
489
490 f_current = clk_get_rate(mipi->dsip_clk);
491 /* Between 10 and 50MHz */
492 rate = clk_round_rate(mipi->dsip_clk, 24000000);
493 if (rate > 0 && rate != f_current)
494 ret = clk_set_rate(mipi->dsip_clk, rate);
495 else
496 ret = rate;
497 if (ret < 0)
498 goto esetprate;
499
500 dev_dbg(&pdev->dev, "DSI-P clk %lu -> %lu\n", f_current, rate);
501
502 msleep(10);
503
504 ret = clk_enable(mipi->dsit_clk); 486 ret = clk_enable(mipi->dsit_clk);
505 if (ret < 0) 487 if (ret < 0)
506 goto eclkton; 488 goto eclkton;
507 489
508 ret = clk_enable(mipi->dsip_clk);
509 if (ret < 0)
510 goto eclkpon;
511
512 mipi_dsi[idx] = mipi; 490 mipi_dsi[idx] = mipi;
513 491
514 pm_runtime_enable(&pdev->dev); 492 pm_runtime_enable(&pdev->dev);
@@ -518,6 +496,10 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
518 if (ret < 0) 496 if (ret < 0)
519 goto emipisetup; 497 goto emipisetup;
520 498
499 ret = pdata->set_dot_clock(pdev, mipi->base, 1);
500 if (ret < 0)
501 goto emipisetup;
502
521 mutex_unlock(&array_lock); 503 mutex_unlock(&array_lock);
522 platform_set_drvdata(pdev, mipi); 504 platform_set_drvdata(pdev, mipi);
523 505
@@ -537,13 +519,8 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
537emipisetup: 519emipisetup:
538 mipi_dsi[idx] = NULL; 520 mipi_dsi[idx] = NULL;
539 pm_runtime_disable(&pdev->dev); 521 pm_runtime_disable(&pdev->dev);
540 clk_disable(mipi->dsip_clk);
541eclkpon:
542 clk_disable(mipi->dsit_clk); 522 clk_disable(mipi->dsit_clk);
543eclkton: 523eclkton:
544esetprate:
545 clk_put(mipi->dsip_clk);
546eclkpget:
547esettrate: 524esettrate:
548 clk_put(mipi->dsit_clk); 525 clk_put(mipi->dsit_clk);
549eclktget: 526eclktget:
@@ -594,10 +571,10 @@ static int __exit sh_mipi_remove(struct platform_device *pdev)
594 pdata->lcd_chan->board_cfg.board_data = NULL; 571 pdata->lcd_chan->board_cfg.board_data = NULL;
595 572
596 pm_runtime_disable(&pdev->dev); 573 pm_runtime_disable(&pdev->dev);
597 clk_disable(mipi->dsip_clk);
598 clk_disable(mipi->dsit_clk); 574 clk_disable(mipi->dsit_clk);
599 clk_put(mipi->dsit_clk); 575 clk_put(mipi->dsit_clk);
600 clk_put(mipi->dsip_clk); 576 pdata->set_dot_clock(pdev, mipi->base, 0);
577
601 iounmap(mipi->linkbase); 578 iounmap(mipi->linkbase);
602 if (res2) 579 if (res2)
603 release_mem_region(res2->start, resource_size(res2)); 580 release_mem_region(res2->start, resource_size(res2));
diff --git a/include/video/sh_mipi_dsi.h b/include/video/sh_mipi_dsi.h
index c8225b4fe8e6..310b883bb312 100644
--- a/include/video/sh_mipi_dsi.h
+++ b/include/video/sh_mipi_dsi.h
@@ -48,6 +48,9 @@ struct sh_mipi_dsi_info {
48 unsigned long flags; 48 unsigned long flags;
49 u32 clksrc; 49 u32 clksrc;
50 unsigned int vsynw_offset; 50 unsigned int vsynw_offset;
51 int (*set_dot_clock)(struct platform_device *pdev,
52 void __iomem *base,
53 int enable);
51}; 54};
52 55
53#endif 56#endif