aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c39
-rw-r--r--arch/arm/mach-shmobile/clock-sh7372.c13
-rw-r--r--drivers/video/sh_mipi_dsi.c36
-rw-r--r--include/video/sh_mipi_dsi.h6
4 files changed, 43 insertions, 51 deletions
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index a054f0d450d8..b1222dc43380 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -514,6 +514,7 @@ static struct resource mipidsi0_resources[] = {
514static struct sh_mipi_dsi_info mipidsi0_info = { 514static struct sh_mipi_dsi_info mipidsi0_info = {
515 .data_format = MIPI_RGB888, 515 .data_format = MIPI_RGB888,
516 .lcd_chan = &lcdc_info.ch[0], 516 .lcd_chan = &lcdc_info.ch[0],
517 .vsynw_offset = 17,
517}; 518};
518 519
519static struct platform_device mipidsi0_device = { 520static struct platform_device mipidsi0_device = {
@@ -526,44 +527,6 @@ static struct platform_device mipidsi0_device = {
526 }, 527 },
527}; 528};
528 529
529/* This function will disappear when we switch to (runtime) PM */
530static int __init ap4evb_init_display_clk(void)
531{
532 struct clk *lcdc_clk;
533 struct clk *dsitx_clk;
534 int ret;
535
536 lcdc_clk = clk_get(&lcdc_device.dev, "sh_mobile_lcdc_fb.0");
537 if (IS_ERR(lcdc_clk))
538 return PTR_ERR(lcdc_clk);
539
540 dsitx_clk = clk_get(&mipidsi0_device.dev, "sh-mipi-dsi.0");
541 if (IS_ERR(dsitx_clk)) {
542 ret = PTR_ERR(dsitx_clk);
543 goto eclkdsitxget;
544 }
545
546 ret = clk_enable(lcdc_clk);
547 if (ret < 0)
548 goto eclklcdcon;
549
550 ret = clk_enable(dsitx_clk);
551 if (ret < 0)
552 goto eclkdsitxon;
553
554 return 0;
555
556eclkdsitxon:
557 clk_disable(lcdc_clk);
558eclklcdcon:
559 clk_put(dsitx_clk);
560eclkdsitxget:
561 clk_put(lcdc_clk);
562
563 return ret;
564}
565device_initcall(ap4evb_init_display_clk);
566
567static struct platform_device *qhd_devices[] __initdata = { 530static struct platform_device *qhd_devices[] __initdata = {
568 &mipidsi0_device, 531 &mipidsi0_device,
569 &keysc_device, 532 &keysc_device,
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
index 3aa026069435..66663adb21f8 100644
--- a/arch/arm/mach-shmobile/clock-sh7372.c
+++ b/arch/arm/mach-shmobile/clock-sh7372.c
@@ -507,7 +507,7 @@ enum { MSTP001,
507 MSTP223, 507 MSTP223,
508 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, 508 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
509 MSTP329, MSTP328, MSTP323, MSTP322, MSTP314, MSTP313, MSTP312, 509 MSTP329, MSTP328, MSTP323, MSTP322, MSTP314, MSTP313, MSTP312,
510 MSTP415, MSTP413, MSTP411, MSTP410, MSTP406, MSTP403, 510 MSTP423, MSTP415, MSTP413, MSTP411, MSTP410, MSTP406, MSTP403,
511 MSTP_NR }; 511 MSTP_NR };
512 512
513#define MSTP(_parent, _reg, _bit, _flags) \ 513#define MSTP(_parent, _reg, _bit, _flags) \
@@ -543,6 +543,7 @@ static struct clk mstp_clks[MSTP_NR] = {
543 [MSTP314] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 14, 0), /* SDHI0 */ 543 [MSTP314] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 14, 0), /* SDHI0 */
544 [MSTP313] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 13, 0), /* SDHI1 */ 544 [MSTP313] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 13, 0), /* SDHI1 */
545 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMC */ 545 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMC */
546 [MSTP423] = MSTP(&div4_clks[DIV4_B], SMSTPCR4, 23, 0), /* DSITX1 */
546 [MSTP415] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 15, 0), /* SDHI2 */ 547 [MSTP415] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 15, 0), /* SDHI2 */
547 [MSTP413] = MSTP(&pllc1_div2_clk, SMSTPCR4, 13, 0), /* HDMI */ 548 [MSTP413] = MSTP(&pllc1_div2_clk, SMSTPCR4, 13, 0), /* HDMI */
548 [MSTP411] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR4, 11, 0), /* IIC3 */ 549 [MSTP411] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR4, 11, 0), /* IIC3 */
@@ -596,9 +597,10 @@ static struct clk_lookup lookups[] = {
596 CLKDEV_CON_ID("spu_clk", &div6_clks[DIV6_SPU]), 597 CLKDEV_CON_ID("spu_clk", &div6_clks[DIV6_SPU]),
597 CLKDEV_CON_ID("vou_clk", &div6_clks[DIV6_VOU]), 598 CLKDEV_CON_ID("vou_clk", &div6_clks[DIV6_VOU]),
598 CLKDEV_CON_ID("hdmi_clk", &div6_reparent_clks[DIV6_HDMI]), 599 CLKDEV_CON_ID("hdmi_clk", &div6_reparent_clks[DIV6_HDMI]),
599 CLKDEV_CON_ID("dsit_clk", &div6_clks[DIV6_DSIT]), 600 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSIT]),
600 CLKDEV_CON_ID("dsi0p_clk", &div6_clks[DIV6_DSI0P]), 601 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSIT]),
601 CLKDEV_CON_ID("dsi1p_clk", &div6_clks[DIV6_DSI1P]), 602 CLKDEV_ICK_ID("dsi0p_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSI0P]),
603 CLKDEV_ICK_ID("dsi1p_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSI1P]),
602 604
603 /* MSTP32 clocks */ 605 /* MSTP32 clocks */
604 CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* IIC2 */ 606 CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* IIC2 */
@@ -610,7 +612,7 @@ static struct clk_lookup lookups[] = {
610 CLKDEV_DEV_ID("sh-mobile-csi2.0", &mstp_clks[MSTP126]), /* CSI2 */ 612 CLKDEV_DEV_ID("sh-mobile-csi2.0", &mstp_clks[MSTP126]), /* CSI2 */
611 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */ 613 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */
612 CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */ 614 CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */
613 CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX */ 615 CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX0 */
614 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), /* LCDC1 */ 616 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), /* LCDC1 */
615 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* IIC0 */ 617 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* IIC0 */
616 CLKDEV_DEV_ID("uio_pdrv_genirq.5", &mstp_clks[MSTP106]), /* JPU */ 618 CLKDEV_DEV_ID("uio_pdrv_genirq.5", &mstp_clks[MSTP106]), /* JPU */
@@ -633,6 +635,7 @@ static struct clk_lookup lookups[] = {
633 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]), /* SDHI0 */ 635 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]), /* SDHI0 */
634 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]), /* SDHI1 */ 636 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]), /* SDHI1 */
635 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMC */ 637 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMC */
638 CLKDEV_DEV_ID("sh-mipi-dsi.1", &mstp_clks[MSTP423]), /* DSITX1 */
636 CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP415]), /* SDHI2 */ 639 CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP415]), /* SDHI2 */
637 CLKDEV_DEV_ID("sh-mobile-hdmi", &mstp_clks[MSTP413]), /* HDMI */ 640 CLKDEV_DEV_ID("sh-mobile-hdmi", &mstp_clks[MSTP413]), /* HDMI */
638 CLKDEV_DEV_ID("i2c-sh_mobile.3", &mstp_clks[MSTP411]), /* IIC3 */ 641 CLKDEV_DEV_ID("i2c-sh_mobile.3", &mstp_clks[MSTP411]), /* IIC3 */
diff --git a/drivers/video/sh_mipi_dsi.c b/drivers/video/sh_mipi_dsi.c
index b40dc423cbdf..24640c8458ab 100644
--- a/drivers/video/sh_mipi_dsi.c
+++ b/drivers/video/sh_mipi_dsi.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/pm_runtime.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17#include <linux/string.h> 18#include <linux/string.h>
18#include <linux/types.h> 19#include <linux/types.h>
@@ -50,9 +51,11 @@ struct sh_mipi {
50 void __iomem *linkbase; 51 void __iomem *linkbase;
51 struct clk *dsit_clk; 52 struct clk *dsit_clk;
52 struct clk *dsip_clk; 53 struct clk *dsip_clk;
53 void *next_board_data; 54 struct device *dev;
54 void (*next_display_on)(void *board_data, struct fb_info *info); 55
55 void (*next_display_off)(void *board_data); 56 void *next_board_data;
57 void (*next_display_on)(void *board_data, struct fb_info *info);
58 void (*next_display_off)(void *board_data);
56}; 59};
57 60
58static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI]; 61static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI];
@@ -124,6 +127,7 @@ static void mipi_display_on(void *arg, struct fb_info *info)
124{ 127{
125 struct sh_mipi *mipi = arg; 128 struct sh_mipi *mipi = arg;
126 129
130 pm_runtime_get_sync(mipi->dev);
127 sh_mipi_dsi_enable(mipi, true); 131 sh_mipi_dsi_enable(mipi, true);
128 132
129 if (mipi->next_display_on) 133 if (mipi->next_display_on)
@@ -138,6 +142,7 @@ static void mipi_display_off(void *arg)
138 mipi->next_display_off(mipi->next_board_data); 142 mipi->next_display_off(mipi->next_board_data);
139 143
140 sh_mipi_dsi_enable(mipi, false); 144 sh_mipi_dsi_enable(mipi, false);
145 pm_runtime_put(mipi->dev);
141} 146}
142 147
143static int __init sh_mipi_setup(struct sh_mipi *mipi, 148static int __init sh_mipi_setup(struct sh_mipi *mipi,
@@ -145,8 +150,7 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
145{ 150{
146 void __iomem *base = mipi->base; 151 void __iomem *base = mipi->base;
147 struct sh_mobile_lcdc_chan_cfg *ch = pdata->lcd_chan; 152 struct sh_mobile_lcdc_chan_cfg *ch = pdata->lcd_chan;
148 u32 pctype, datatype, pixfmt; 153 u32 pctype, datatype, pixfmt, linelength, vmctr2 = 0x00e00000;
149 u32 linelength;
150 bool yuv; 154 bool yuv;
151 155
152 /* 156 /*
@@ -303,17 +307,24 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
303 */ 307 */
304 iowrite32(0x00000006, mipi->linkbase + DTCTR); 308 iowrite32(0x00000006, mipi->linkbase + DTCTR);
305 /* VSYNC width = 2 (<< 17) */ 309 /* VSYNC width = 2 (<< 17) */
306 iowrite32(0x00040000 | (pctype << 12) | datatype, 310 iowrite32((ch->lcd_cfg[0].vsync_len << pdata->vsynw_offset) |
311 (pdata->clksrc << 16) | (pctype << 12) | datatype,
307 mipi->linkbase + VMCTR1); 312 mipi->linkbase + VMCTR1);
313
308 /* 314 /*
309 * Non-burst mode with sync pulses: VSE and HSE are output, 315 * Non-burst mode with sync pulses: VSE and HSE are output,
310 * HSA period allowed, no commands in LP 316 * HSA period allowed, no commands in LP
311 */ 317 */
312 iowrite32(0x00e00000, mipi->linkbase + VMCTR2); 318 if (pdata->flags & SH_MIPI_DSI_HSABM)
319 vmctr2 |= 0x20;
320 if (pdata->flags & SH_MIPI_DSI_HSPBM)
321 vmctr2 |= 0x10;
322 iowrite32(vmctr2, mipi->linkbase + VMCTR2);
323
313 /* 324 /*
314 * 0x660 = 1632 bytes per line (RGB24, 544 pixels: see 325 * 0x660 = 1632 bytes per line (RGB24, 544 pixels: see
315 * sh_mobile_lcdc_info.ch[0].lcd_cfg[0].xres), HSALEN = 1 - default 326 * sh_mobile_lcdc_info.ch[0].lcd_cfg[0].xres), HSALEN = 1 - default
316 * (unused, since VMCTR2[HSABM] = 0) 327 * (unused if VMCTR2[HSABM] = 0)
317 */ 328 */
318 iowrite32(1 | (linelength << 16), mipi->linkbase + VMLEN1); 329 iowrite32(1 | (linelength << 16), mipi->linkbase + VMLEN1);
319 330
@@ -396,6 +407,8 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
396 goto emap2; 407 goto emap2;
397 } 408 }
398 409
410 mipi->dev = &pdev->dev;
411
399 mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk"); 412 mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk");
400 if (IS_ERR(mipi->dsit_clk)) { 413 if (IS_ERR(mipi->dsit_clk)) {
401 ret = PTR_ERR(mipi->dsit_clk); 414 ret = PTR_ERR(mipi->dsit_clk);
@@ -445,6 +458,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
445 458
446 mipi_dsi[idx] = mipi; 459 mipi_dsi[idx] = mipi;
447 460
461 pm_runtime_enable(&pdev->dev);
462 pm_runtime_resume(&pdev->dev);
463
448 ret = sh_mipi_setup(mipi, pdata); 464 ret = sh_mipi_setup(mipi, pdata);
449 if (ret < 0) 465 if (ret < 0)
450 goto emipisetup; 466 goto emipisetup;
@@ -461,11 +477,13 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
461 pdata->lcd_chan->board_cfg.board_data = mipi; 477 pdata->lcd_chan->board_cfg.board_data = mipi;
462 pdata->lcd_chan->board_cfg.display_on = mipi_display_on; 478 pdata->lcd_chan->board_cfg.display_on = mipi_display_on;
463 pdata->lcd_chan->board_cfg.display_off = mipi_display_off; 479 pdata->lcd_chan->board_cfg.display_off = mipi_display_off;
480 pdata->lcd_chan->board_cfg.owner = THIS_MODULE;
464 481
465 return 0; 482 return 0;
466 483
467emipisetup: 484emipisetup:
468 mipi_dsi[idx] = NULL; 485 mipi_dsi[idx] = NULL;
486 pm_runtime_disable(&pdev->dev);
469 clk_disable(mipi->dsip_clk); 487 clk_disable(mipi->dsip_clk);
470eclkpon: 488eclkpon:
471 clk_disable(mipi->dsit_clk); 489 clk_disable(mipi->dsit_clk);
@@ -517,10 +535,12 @@ static int __exit sh_mipi_remove(struct platform_device *pdev)
517 if (ret < 0) 535 if (ret < 0)
518 return ret; 536 return ret;
519 537
538 pdata->lcd_chan->board_cfg.owner = NULL;
520 pdata->lcd_chan->board_cfg.display_on = NULL; 539 pdata->lcd_chan->board_cfg.display_on = NULL;
521 pdata->lcd_chan->board_cfg.display_off = NULL; 540 pdata->lcd_chan->board_cfg.display_off = NULL;
522 pdata->lcd_chan->board_cfg.board_data = NULL; 541 pdata->lcd_chan->board_cfg.board_data = NULL;
523 542
543 pm_runtime_disable(&pdev->dev);
524 clk_disable(mipi->dsip_clk); 544 clk_disable(mipi->dsip_clk);
525 clk_disable(mipi->dsit_clk); 545 clk_disable(mipi->dsit_clk);
526 clk_put(mipi->dsit_clk); 546 clk_put(mipi->dsit_clk);
diff --git a/include/video/sh_mipi_dsi.h b/include/video/sh_mipi_dsi.h
index 18bca08f9f59..6cb95c977de9 100644
--- a/include/video/sh_mipi_dsi.h
+++ b/include/video/sh_mipi_dsi.h
@@ -27,9 +27,15 @@ enum sh_mipi_dsi_data_fmt {
27 27
28struct sh_mobile_lcdc_chan_cfg; 28struct sh_mobile_lcdc_chan_cfg;
29 29
30#define SH_MIPI_DSI_HSABM (1 << 0)
31#define SH_MIPI_DSI_HSPBM (1 << 1)
32
30struct sh_mipi_dsi_info { 33struct sh_mipi_dsi_info {
31 enum sh_mipi_dsi_data_fmt data_format; 34 enum sh_mipi_dsi_data_fmt data_format;
32 struct sh_mobile_lcdc_chan_cfg *lcd_chan; 35 struct sh_mobile_lcdc_chan_cfg *lcd_chan;
36 unsigned long flags;
37 u32 clksrc;
38 unsigned int vsynw_offset;
33}; 39};
34 40
35#endif 41#endif