From 236782a5f3674d06865d822092b8a1ea65a44f96 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 27 Dec 2010 10:23:05 +0000 Subject: [PATCH 1/5] fbdev: sh-mobile: implement MIPI DSI runtime PM support On SH-Mobile platforms using runtime PM with the MIPI DSI driver switches the DSI Tx link clock on PM events. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Paul Mundt --- drivers/video/sh_mipi_dsi.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/video/sh_mipi_dsi.c b/drivers/video/sh_mipi_dsi.c index b40dc423cbdf..23231279c387 100644 --- a/drivers/video/sh_mipi_dsi.c +++ b/drivers/video/sh_mipi_dsi.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -50,9 +51,11 @@ struct sh_mipi { void __iomem *linkbase; struct clk *dsit_clk; struct clk *dsip_clk; - void *next_board_data; - void (*next_display_on)(void *board_data, struct fb_info *info); - void (*next_display_off)(void *board_data); + struct device *dev; + + void *next_board_data; + void (*next_display_on)(void *board_data, struct fb_info *info); + void (*next_display_off)(void *board_data); }; static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI]; @@ -124,6 +127,7 @@ static void mipi_display_on(void *arg, struct fb_info *info) { struct sh_mipi *mipi = arg; + pm_runtime_get_sync(mipi->dev); sh_mipi_dsi_enable(mipi, true); if (mipi->next_display_on) @@ -138,6 +142,7 @@ static void mipi_display_off(void *arg) mipi->next_display_off(mipi->next_board_data); sh_mipi_dsi_enable(mipi, false); + pm_runtime_put(mipi->dev); } static int __init sh_mipi_setup(struct sh_mipi *mipi, @@ -396,6 +401,8 @@ static int __init sh_mipi_probe(struct platform_device *pdev) goto emap2; } + mipi->dev = &pdev->dev; + mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk"); if (IS_ERR(mipi->dsit_clk)) { ret = PTR_ERR(mipi->dsit_clk); @@ -445,6 +452,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev) mipi_dsi[idx] = mipi; + pm_runtime_enable(&pdev->dev); + pm_runtime_resume(&pdev->dev); + ret = sh_mipi_setup(mipi, pdata); if (ret < 0) goto emipisetup; @@ -461,11 +471,13 @@ static int __init sh_mipi_probe(struct platform_device *pdev) pdata->lcd_chan->board_cfg.board_data = mipi; pdata->lcd_chan->board_cfg.display_on = mipi_display_on; pdata->lcd_chan->board_cfg.display_off = mipi_display_off; + pdata->lcd_chan->board_cfg.owner = THIS_MODULE; return 0; emipisetup: mipi_dsi[idx] = NULL; + pm_runtime_disable(&pdev->dev); clk_disable(mipi->dsip_clk); eclkpon: clk_disable(mipi->dsit_clk); @@ -517,10 +529,12 @@ static int __exit sh_mipi_remove(struct platform_device *pdev) if (ret < 0) return ret; + pdata->lcd_chan->board_cfg.owner = NULL; pdata->lcd_chan->board_cfg.display_on = NULL; pdata->lcd_chan->board_cfg.display_off = NULL; pdata->lcd_chan->board_cfg.board_data = NULL; + pm_runtime_disable(&pdev->dev); clk_disable(mipi->dsip_clk); clk_disable(mipi->dsit_clk); clk_put(mipi->dsit_clk); From 0851d50dc12a844778a9b243e141f713cd8f074f Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 27 Dec 2010 10:23:09 +0000 Subject: [PATCH 2/5] ARM: mach-shmobile: improve MIPI DSI clock configuration Now, that the MIPI DSI driver implements runtime PM, we don't need anymore to configure clocks statically in the platform code. This patch also adds a DSITX1 clock definition for sh7372 and attaches PHY clocks to respective devices. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Paul Mundt --- arch/arm/mach-shmobile/board-ap4evb.c | 38 --------------------------- arch/arm/mach-shmobile/clock-sh7372.c | 13 +++++---- 2 files changed, 8 insertions(+), 43 deletions(-) diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c index 2f8c83703572..87f9ee9eda41 100644 --- a/arch/arm/mach-shmobile/board-ap4evb.c +++ b/arch/arm/mach-shmobile/board-ap4evb.c @@ -526,44 +526,6 @@ static struct platform_device mipidsi0_device = { }, }; -/* This function will disappear when we switch to (runtime) PM */ -static int __init ap4evb_init_display_clk(void) -{ - struct clk *lcdc_clk; - struct clk *dsitx_clk; - int ret; - - lcdc_clk = clk_get(&lcdc_device.dev, "sh_mobile_lcdc_fb.0"); - if (IS_ERR(lcdc_clk)) - return PTR_ERR(lcdc_clk); - - dsitx_clk = clk_get(&mipidsi0_device.dev, "sh-mipi-dsi.0"); - if (IS_ERR(dsitx_clk)) { - ret = PTR_ERR(dsitx_clk); - goto eclkdsitxget; - } - - ret = clk_enable(lcdc_clk); - if (ret < 0) - goto eclklcdcon; - - ret = clk_enable(dsitx_clk); - if (ret < 0) - goto eclkdsitxon; - - return 0; - -eclkdsitxon: - clk_disable(lcdc_clk); -eclklcdcon: - clk_put(dsitx_clk); -eclkdsitxget: - clk_put(lcdc_clk); - - return ret; -} -device_initcall(ap4evb_init_display_clk); - static struct platform_device *qhd_devices[] __initdata = { &mipidsi0_device, &keysc_device, diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c index 7db31e6c6bf2..f4b9ae211566 100644 --- a/arch/arm/mach-shmobile/clock-sh7372.c +++ b/arch/arm/mach-shmobile/clock-sh7372.c @@ -524,7 +524,7 @@ enum { MSTP001, MSTP223, MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, MSTP329, MSTP328, MSTP323, MSTP322, MSTP314, MSTP313, MSTP312, - MSTP415, MSTP413, MSTP411, MSTP410, MSTP406, MSTP403, + MSTP423, MSTP415, MSTP413, MSTP411, MSTP410, MSTP406, MSTP403, MSTP_NR }; #define MSTP(_parent, _reg, _bit, _flags) \ @@ -560,6 +560,7 @@ static struct clk mstp_clks[MSTP_NR] = { [MSTP314] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 14, 0), /* SDHI0 */ [MSTP313] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 13, 0), /* SDHI1 */ [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMC */ + [MSTP423] = MSTP(&div4_clks[DIV4_B], SMSTPCR4, 23, 0), /* DSITX1 */ [MSTP415] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 15, 0), /* SDHI2 */ [MSTP413] = MSTP(&pllc1_div2_clk, SMSTPCR4, 13, 0), /* HDMI */ [MSTP411] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR4, 11, 0), /* IIC3 */ @@ -615,9 +616,10 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("spu_clk", &div6_clks[DIV6_SPU]), CLKDEV_CON_ID("vou_clk", &div6_clks[DIV6_VOU]), CLKDEV_CON_ID("hdmi_clk", &div6_reparent_clks[DIV6_HDMI]), - CLKDEV_CON_ID("dsit_clk", &div6_clks[DIV6_DSIT]), - CLKDEV_CON_ID("dsi0p_clk", &div6_clks[DIV6_DSI0P]), - CLKDEV_CON_ID("dsi1p_clk", &div6_clks[DIV6_DSI1P]), + CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSIT]), + CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSIT]), + CLKDEV_ICK_ID("dsi0p_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSI0P]), + CLKDEV_ICK_ID("dsi1p_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSI1P]), /* MSTP32 clocks */ CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* IIC2 */ @@ -629,7 +631,7 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("sh-mobile-csi2.0", &mstp_clks[MSTP126]), /* CSI2 */ CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */ CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */ - CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX */ + CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX0 */ CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), /* LCDC1 */ CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* IIC0 */ CLKDEV_DEV_ID("uio_pdrv_genirq.5", &mstp_clks[MSTP106]), /* JPU */ @@ -652,6 +654,7 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]), /* SDHI0 */ CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]), /* SDHI1 */ CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMC */ + CLKDEV_DEV_ID("sh-mipi-dsi.1", &mstp_clks[MSTP423]), /* DSITX1 */ CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP415]), /* SDHI2 */ CLKDEV_DEV_ID("sh-mobile-hdmi", &mstp_clks[MSTP413]), /* HDMI */ CLKDEV_DEV_ID("i2c-sh_mobile.3", &mstp_clks[MSTP411]), /* IIC3 */ From 38f3a8794236af422312d280bbe3801130cfa63b Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 29 Dec 2010 08:12:22 +0000 Subject: [PATCH 3/5] fbdev: sh_mipi_dsi: support different register layouts The register layout of the MIPI DSI unit on sh-mobile SoCs differ. Add platform parameters to support such variations. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Paul Mundt --- include/video/sh_mipi_dsi.h | 6 ++++++ 1 file changed, 6 insertions(+) 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 { struct sh_mobile_lcdc_chan_cfg; +#define SH_MIPI_DSI_HSABM (1 << 0) +#define SH_MIPI_DSI_HSPBM (1 << 1) + struct sh_mipi_dsi_info { enum sh_mipi_dsi_data_fmt data_format; struct sh_mobile_lcdc_chan_cfg *lcd_chan; + unsigned long flags; + u32 clksrc; + unsigned int vsynw_offset; }; #endif From 6fd465956e287f2bff8ff70ad4f27825dc3b468c Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 29 Dec 2010 08:12:26 +0000 Subject: [PATCH 4/5] ARM: mach-shmobile: specify sh7372 MIPI DSI register layout Prepare the ap4evb board for the MIPI DSI driver transition to support different register layouts. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Paul Mundt --- arch/arm/mach-shmobile/board-ap4evb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c index 87f9ee9eda41..acbb4f0579ab 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[] = { static struct sh_mipi_dsi_info mipidsi0_info = { .data_format = MIPI_RGB888, .lcd_chan = &lcdc_info.ch[0], + .vsynw_offset = 17, }; static struct platform_device mipidsi0_device = { From 14bbb7c61557172e4482d4d97a5f56042a12b969 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 29 Dec 2010 08:12:29 +0000 Subject: [PATCH 5/5] fbdev: sh_mipi_dsi: use platform provided register layout and values Different sh-mobile SoCs have variations in their MIPI DSI register layouts, besides, different LCD panels require different configuration parameters. This patch switches the driver to use platform-provided MIPI DSI parameters. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Paul Mundt --- drivers/video/sh_mipi_dsi.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/video/sh_mipi_dsi.c b/drivers/video/sh_mipi_dsi.c index 23231279c387..24640c8458ab 100644 --- a/drivers/video/sh_mipi_dsi.c +++ b/drivers/video/sh_mipi_dsi.c @@ -150,8 +150,7 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi, { void __iomem *base = mipi->base; struct sh_mobile_lcdc_chan_cfg *ch = pdata->lcd_chan; - u32 pctype, datatype, pixfmt; - u32 linelength; + u32 pctype, datatype, pixfmt, linelength, vmctr2 = 0x00e00000; bool yuv; /* @@ -308,17 +307,24 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi, */ iowrite32(0x00000006, mipi->linkbase + DTCTR); /* VSYNC width = 2 (<< 17) */ - iowrite32(0x00040000 | (pctype << 12) | datatype, + iowrite32((ch->lcd_cfg[0].vsync_len << pdata->vsynw_offset) | + (pdata->clksrc << 16) | (pctype << 12) | datatype, mipi->linkbase + VMCTR1); + /* * Non-burst mode with sync pulses: VSE and HSE are output, * HSA period allowed, no commands in LP */ - iowrite32(0x00e00000, mipi->linkbase + VMCTR2); + if (pdata->flags & SH_MIPI_DSI_HSABM) + vmctr2 |= 0x20; + if (pdata->flags & SH_MIPI_DSI_HSPBM) + vmctr2 |= 0x10; + iowrite32(vmctr2, mipi->linkbase + VMCTR2); + /* * 0x660 = 1632 bytes per line (RGB24, 544 pixels: see * sh_mobile_lcdc_info.ch[0].lcd_cfg[0].xres), HSALEN = 1 - default - * (unused, since VMCTR2[HSABM] = 0) + * (unused if VMCTR2[HSABM] = 0) */ iowrite32(1 | (linelength << 16), mipi->linkbase + VMLEN1);