From 4111c672962a8df130b294961ab552fef6a498d9 Mon Sep 17 00:00:00 2001
From: Roger Quadros <roger.quadros@nokia.com>
Date: Wed, 17 Mar 2010 12:35:21 +0000
Subject: [PATCH 2/10] OMAP: DSS2: Use vdds_sdi regulator supply in SDI

From: Roger Quadros <roger.quadros@nokia.com>

Patch-mainline: 2.6.35?
Git-repo: http://www.gitorious.org/linux-omap-dss2/linux/commit/1d5c6663d92b37539617d833e6049e5dd21751c4

This patch enables the use of vdds_sdi regulator in SDI subsystem.
We can disable the vdds_sdi voltage when not in use to save
power.

Signed-off-by: Roger Quadros <roger.quadros@nokia.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com>
---
 drivers/video/omap2/dss/core.c |    2 +-
 drivers/video/omap2/dss/dss.h  |    2 +-
 drivers/video/omap2/dss/sdi.c  |   17 ++++++++++++++++-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index 0988781..97f929b 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -495,7 +495,7 @@ static int omap_dss_probe(struct platform_device *pdev)
 #endif
 	if (cpu_is_omap34xx()) {
 #ifdef CONFIG_OMAP2_DSS_SDI
-		r = sdi_init(skip_init);
+		r = sdi_init(pdev, skip_init);
 		if (r) {
 			DSSERR("Failed to initialize SDI\n");
 			goto fail0;
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index 2bcb124..8490bdf 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -231,7 +231,7 @@ int dss_calc_clock_div(bool is_tft, unsigned long req_pck,
 		struct dispc_clock_info *dispc_cinfo);
 
 /* SDI */
-int sdi_init(bool skip_init);
+int sdi_init(struct platform_device *pdev, bool skip_init);
 void sdi_exit(void);
 int sdi_init_display(struct omap_dss_device *display);
 
diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c
index c24f307..025c56c 100644
--- a/drivers/video/omap2/dss/sdi.c
+++ b/drivers/video/omap2/dss/sdi.c
@@ -23,6 +23,8 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 
 #include <plat/display.h>
 #include "dss.h"
@@ -30,6 +32,7 @@
 static struct {
 	bool skip_init;
 	bool update_enabled;
+	struct regulator *vdds_sdi_reg;
 } sdi;
 
 static void sdi_basic_init(void)
@@ -63,6 +66,10 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
 		goto err1;
 	}
 
+	r = regulator_enable(sdi.vdds_sdi_reg);
+	if (r)
+		goto err1;
+
 	/* In case of skip_init sdi_init has already enabled the clocks */
 	if (!sdi.skip_init)
 		dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK1);
@@ -136,6 +143,7 @@ err3:
 	dispc_enable_lcd_out(0);
 err2:
 	dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK1);
+	regulator_disable(sdi.vdds_sdi_reg);
 err1:
 	omap_dss_stop_device(dssdev);
 err0:
@@ -164,6 +172,8 @@ static void sdi_display_disable(struct omap_dss_device *dssdev)
 
 	dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
 
+	regulator_disable(sdi.vdds_sdi_reg);
+
 	omap_dss_stop_device(dssdev);
 }
 
@@ -258,11 +268,16 @@ int sdi_init_display(struct omap_dss_device *dssdev)
 	return 0;
 }
 
-int sdi_init(bool skip_init)
+int sdi_init(struct platform_device *pdev, bool skip_init)
 {
 	/* we store this for first display enable, then clear it */
 	sdi.skip_init = skip_init;
 
+	sdi.vdds_sdi_reg = regulator_get(&pdev->dev, "vdds_sdi");
+	if (IS_ERR(sdi.vdds_sdi_reg)) {
+		DSSERR("can't get VDDS_SDI regulator\n");
+		return PTR_ERR(sdi.vdds_sdi_reg);
+	}
 	/*
 	 * Enable clocks already here, otherwise there would be a toggle
 	 * of them until sdi_display_enable is called.
-- 
1.6.0.4

