Patchwork [08/20] Replace clk_enable/disable APIs with HWMOD APIs

login
register
mail settings
Submitter Senthilvadivu Guruswamy
Date Aug. 23, 2010, 3:57 p.m.
Message ID <1282579089-10487-9-git-send-email-svadivu@ti.com>
Download mbox | patch
Permalink /patch/124641/
State Changes Requested
Delegated to: Kevin Hilman
Headers show

Comments

Patch

diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 15d0399..098ff96 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -61,6 +61,7 @@  struct dss_reg {
 
 static struct {
 	struct platform_device *pdev;
+	struct omap_display_platform_data *pdata;
 
 	void __iomem    *base;
 	int		ctx_id;
@@ -310,14 +311,26 @@  static unsigned count_clk_bits(enum dss_clock clks)
 	return num_clks;
 }
 
+static inline void enable_clocks(bool enable)
+ {
+	static int use_count;
+
+	use_count += enable ? 1 : -1;
+	if (use_count < 0)
+		use_count = 0;
+
+	if (enable && use_count == 1)
+		dss.pdata->device_enable(dss.pdev);
+	else if (!enable && use_count == 0)
+		dss.pdata->device_idle(dss.pdev);
+}
+
 static void dss_clk_enable_no_ctx(enum dss_clock clks)
 {
 	unsigned num_clks = count_clk_bits(clks);
 
-	if (clks & DSS_CLK_ICK)
-		clk_enable(dss.dss_ick);
-	if (clks & DSS_CLK_FCK1)
-		clk_enable(dss.dss1_fck);
+	if ((clks & DSS_CLK_ICK) || (clks & DSS_CLK_FCK1))
+		enable_clocks(1);
 	if (clks & DSS_CLK_FCK2)
 		clk_enable(dss.dss2_fck);
 	if (clks & DSS_CLK_54M)
@@ -342,10 +355,8 @@  static void dss_clk_disable_no_ctx(enum dss_clock clks)
 {
 	unsigned num_clks = count_clk_bits(clks);
 
-	if (clks & DSS_CLK_ICK)
-		clk_disable(dss.dss_ick);
-	if (clks & DSS_CLK_FCK1)
-		clk_disable(dss.dss1_fck);
+	if ((clks & DSS_CLK_ICK) || (clks & DSS_CLK_FCK1))
+		enable_clocks(0);
 	if (clks & DSS_CLK_FCK2)
 		clk_disable(dss.dss2_fck);
 	if (clks & DSS_CLK_54M)
@@ -447,6 +458,7 @@  static int omap_dsshw_probe(struct platform_device *pdev)
 	int r;
 
 	dss.pdev = pdev;
+	dss.pdata = dss.pdev->dev.platform_data;
 
 	r = dss_get_clocks();
 	if (r)