All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/19] generic clk module removal
@ 2010-04-08 23:15 Omar Ramirez Luna
  2010-04-08 23:15 ` [PATCH 01/19] DSPBRIDGE: rename generic clk_handle for iva2_clk Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:15 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

This set of patches remove clk module from the services layer.

Now:
- GPT 5-8 are controlled through DM Timer framework.
- MCBSP clocks are enabled by requesting the proper mcbsp device.
- WDT is left for bridge driver to control rather than on request from dsp.
- SSI is controlled by enabling/disabling its sst, ssr and ick clocks.

Omar Ramirez Luna (19):
  DSPBRIDGE: rename generic clk_handle for iva2_clk
  DSPBRIDGE: remove iva2 clk control from custom framework
  DSPBRIDGE: fail if clk handle is NULL
  DSPBRIDGE: Now actually fail if a clk handle is wrong
  DSPBRIDGE: Rename services_clk_* to dsp_clk_*
  DSPBRIDGE: remove unused clock sys_ck
  DSPBRIDGE: remove function clk_set32k_hz
  DSPBRIDGE: remove clk_get_use_cnt
  DSPBRIDGE: trivial clock cleanup for unused code
  DSPBRIDGE: function to get the type of clock requested by dsp
  DSPBRIDGE: use dm timer framework for gpt timers
  DSPBRIDGE: use omap mcbsp to enable mcbsp clocks
  DSPBRIDGE: remove wdt3 from dsp control
  DSPBRIDGE: ssi clock fixes
  DSPBRIDGE: use one call for both ick and fck clocks
  DSPBRIDGE: Move MCBSP_CLOCKS code to a common place
  DSPBRIDGE: Balance the number of enable/disable
  DSPBRIDGE: move clk to dsp-clock
  DSPBRIDGE: reorganize the code to handle peripheral clocks

 arch/arm/plat-omap/include/dspbridge/clk.h |  123 ++--------
 drivers/dsp/bridge/Makefile                |    4 +-
 drivers/dsp/bridge/rmgr/drv_interface.c    |   42 +++-
 drivers/dsp/bridge/services/clk.c          |  326 ---------------------------
 drivers/dsp/bridge/services/services.c     |    9 +-
 drivers/dsp/bridge/wmd/_tiomap.h           |   25 +-
 drivers/dsp/bridge/wmd/_tiomap_pwr.h       |   17 --
 drivers/dsp/bridge/wmd/dsp-clock.c         |  330 ++++++++++++++++++++++++++++
 drivers/dsp/bridge/wmd/tiomap3430.c        |   67 +------
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c    |  138 +-----------
 drivers/dsp/bridge/wmd/tiomap_io.c         |    4 +-
 drivers/dsp/bridge/wmd/ue_deh.c            |    2 +-
 12 files changed, 414 insertions(+), 673 deletions(-)
 delete mode 100644 drivers/dsp/bridge/services/clk.c
 create mode 100644 drivers/dsp/bridge/wmd/dsp-clock.c


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 01/19] DSPBRIDGE: rename generic clk_handle for iva2_clk
  2010-04-08 23:15 [PATCH 00/19] generic clk module removal Omar Ramirez Luna
@ 2010-04-08 23:15 ` Omar Ramirez Luna
  2010-04-08 23:15   ` [PATCH 02/19] DSPBRIDGE: remove iva2 clk control from custom framework Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:15 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

In the contexts is being used clk_handle refers to iva2_clk
handle only.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/rmgr/drv_interface.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/dsp/bridge/rmgr/drv_interface.c b/drivers/dsp/bridge/rmgr/drv_interface.c
index d592181..862e01b 100644
--- a/drivers/dsp/bridge/rmgr/drv_interface.c
+++ b/drivers/dsp/bridge/rmgr/drv_interface.c
@@ -150,7 +150,7 @@ static struct file_operations bridge_fops = {
 #ifdef CONFIG_PM
 static u32 time_out = 1000;
 #ifdef CONFIG_BRIDGE_DVFS
-static struct clk *clk_handle;
+static struct clk *iva2_clk;
 s32 dsp_max_opps = VDD1_OPP5;
 #endif
 
@@ -306,11 +306,11 @@ static int __devinit omap34_xx_bridge_probe(struct platform_device *pdev)
 		for (i = 0; i < 6; i++)
 			pdata->mpu_speed[i] = vdd1_rate_table_bridge[i].rate;
 
-		clk_handle = clk_get(NULL, "iva2_ck");
-		if (!clk_handle)
+		iva2_clk = clk_get(NULL, "iva2_ck");
+		if (!iva2_clk)
 			pr_err("%s: clk_get failed to get iva2_ck\n", __func__);
 
-		if (clk_notifier_register(clk_handle, &iva_clk_notifier))
+		if (clk_notifier_register(iva2_clk, &iva_clk_notifier))
 			pr_err("%s: clk_notifier_register failed for iva2_ck\n",
 			       __func__);
 #endif
@@ -346,7 +346,7 @@ static int __devexit omap34_xx_bridge_remove(struct platform_device *pdev)
 		goto func_cont;
 
 #ifdef CONFIG_BRIDGE_DVFS
-	if (clk_notifier_unregister(clk_handle, &iva_clk_notifier))
+	if (clk_notifier_unregister(iva2_clk, &iva_clk_notifier))
 		pr_err("%s: clk_notifier_unregister failed for iva2_ck\n",
 		       __func__);
 #endif /* #ifdef CONFIG_BRIDGE_DVFS */
@@ -358,8 +358,8 @@ static int __devexit omap34_xx_bridge_remove(struct platform_device *pdev)
 		DBC_ASSERT(ret == true);
 	}
 #ifdef CONFIG_BRIDGE_DVFS
-	clk_put(clk_handle);
-	clk_handle = NULL;
+	clk_put(iva2_clk);
+	iva2_clk = NULL;
 #endif /* #ifdef CONFIG_BRIDGE_DVFS */
 
 func_cont:
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 02/19] DSPBRIDGE: remove iva2 clk control from custom framework
  2010-04-08 23:15 ` [PATCH 01/19] DSPBRIDGE: rename generic clk_handle for iva2_clk Omar Ramirez Luna
@ 2010-04-08 23:15   ` Omar Ramirez Luna
  2010-04-08 23:15     ` [PATCH 03/19] DSPBRIDGE: fail if clk handle is NULL Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:15 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

IVA2 has been separated from custom clock framework to be
enabled when the driver is installed and disabled when
driver is removed.

Also as it seems dsp needs to know iva clk rate when changing
to running state, a separate function has been kept to
retrieve the clk rate at that specific point of time.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 arch/arm/plat-omap/include/dspbridge/clk.h |   16 +-----------
 drivers/dsp/bridge/rmgr/drv_interface.c    |   33 +++++++++++++++++++++------
 drivers/dsp/bridge/services/clk.c          |   32 ---------------------------
 drivers/dsp/bridge/wmd/tiomap3430.c        |   16 ++-----------
 4 files changed, 30 insertions(+), 67 deletions(-)

diff --git a/arch/arm/plat-omap/include/dspbridge/clk.h b/arch/arm/plat-omap/include/dspbridge/clk.h
index 89dd4d2..29874a5 100644
--- a/arch/arm/plat-omap/include/dspbridge/clk.h
+++ b/arch/arm/plat-omap/include/dspbridge/clk.h
@@ -22,7 +22,6 @@
 	/* Generic TIMER object: */
 struct timer_object;
 enum services_clk_id {
-	SERVICESCLK_IVA2_CK = 0,
 	SERVICESCLK_GPT5_FCK,
 	SERVICESCLK_GPT5_ICK,
 	SERVICESCLK_GPT6_FCK,
@@ -104,19 +103,6 @@ extern dsp_status services_clk_enable(IN enum services_clk_id clk_id);
 extern dsp_status services_clk_disable(IN enum services_clk_id clk_id);
 
 /*
- *  ======== services_clk_get_rate ========
- *  Purpose:
- *      Get the clock rate of requested clock.
- *  Parameters:
- *  Returns:
- *      DSP_SOK:        Success.
- *      DSP_EFAIL:      Error occured while Getting the clock rate.
- *  Requires:
- *  Ensures:
- */
-extern dsp_status services_clk_get_rate(IN enum services_clk_id clk_id,
-					u32 *speedMhz);
-/*
  *  ======== clk_set32k_hz ========
  *  Purpose:
  *      Set the requested clock to 32KHz.
@@ -143,4 +129,6 @@ extern void ssi_clk_prepare(bool FLAG);
  */
 extern s32 clk_get_use_cnt(IN enum services_clk_id clk_id);
 
+u32 omap_bridge_get_iva2_rate(void);
+
 #endif /* _SYNC_H */
diff --git a/drivers/dsp/bridge/rmgr/drv_interface.c b/drivers/dsp/bridge/rmgr/drv_interface.c
index 862e01b..435c266 100644
--- a/drivers/dsp/bridge/rmgr/drv_interface.c
+++ b/drivers/dsp/bridge/rmgr/drv_interface.c
@@ -41,6 +41,7 @@
 
 /*  ----------------------------------- OS Adaptation Layer */
 #include <dspbridge/services.h>
+#include <dspbridge/clk.h>
 #include <dspbridge/sync.h>
 #include <dspbridge/reg.h>
 
@@ -147,10 +148,11 @@ static struct file_operations bridge_fops = {
 	.mmap = bridge_mmap,
 };
 
+static struct clk *iva2_clk;
+
 #ifdef CONFIG_PM
 static u32 time_out = 1000;
 #ifdef CONFIG_BRIDGE_DVFS
-static struct clk *iva2_clk;
 s32 dsp_max_opps = VDD1_OPP5;
 #endif
 
@@ -302,14 +304,14 @@ static int __devinit omap34_xx_bridge_probe(struct platform_device *pdev)
 			      sizeof(tc_wordswapon));
 	}
 	if (DSP_SUCCEEDED(init_status)) {
+		iva2_clk = clk_get(&pdev->dev, "iva2_ck");
+		if (clk_enable(iva2_clk))
+			pr_err("%s: clk_get failed to get iva2_ck\n", __func__);
+
 #ifdef CONFIG_BRIDGE_DVFS
 		for (i = 0; i < 6; i++)
 			pdata->mpu_speed[i] = vdd1_rate_table_bridge[i].rate;
 
-		iva2_clk = clk_get(NULL, "iva2_ck");
-		if (!iva2_clk)
-			pr_err("%s: clk_get failed to get iva2_ck\n", __func__);
-
 		if (clk_notifier_register(iva2_clk, &iva_clk_notifier))
 			pr_err("%s: clk_notifier_register failed for iva2_ck\n",
 			       __func__);
@@ -357,10 +359,10 @@ static int __devexit omap34_xx_bridge_remove(struct platform_device *pdev)
 		driver_context = 0;
 		DBC_ASSERT(ret == true);
 	}
-#ifdef CONFIG_BRIDGE_DVFS
+
+	clk_disable(iva2_clk);
 	clk_put(iva2_clk);
-	iva2_clk = NULL;
-#endif /* #ifdef CONFIG_BRIDGE_DVFS */
+
 
 func_cont:
 	mem_ext_phys_pool_release();
@@ -565,6 +567,21 @@ dsp_status drv_remove_all_resources(bhandle hPCtxt)
 	return status;
 }
 
+/**
+ * clk_get_iva2_rate - Get the clock rate of iva2 clock.
+ *
+ * Returns the rate of iva2 clock or zero on error.
+ */
+u32 omap_bridge_get_iva2_rate(void)
+{
+	u32 rate;
+
+	rate = clk_get_rate(iva2_clk) / 1000;
+	dev_dbg(bridge, "%s: DSP clk rate (KHZ) %d\n", __func__, rate);
+
+	return rate;
+}
+
 /* Bridge driver initialization and de-initialization functions */
 module_init(bridge_init);
 module_exit(bridge_exit);
diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index a398dc4..5ed6bb5 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -55,7 +55,6 @@ struct services_clk_t {
  * 'services_clk_id' provided in the header file.. any changes in the
  * enumerations needs to be fixed in the array as well */
 static struct services_clk_t services_clks[] = {
-	{NULL, "iva2_ck", -1},
 	{NULL, "gpt5_fck", -1},
 	{NULL, "gpt5_ick", -1},
 	{NULL, "gpt6_fck", -1},
@@ -246,37 +245,6 @@ dsp_status services_clk_disable(IN enum services_clk_id clk_id)
 	return status;
 }
 
-/*
- *  ======== services_clk_get_rate ========
- *  Purpose:
- *      GetClock Speed.
- *
- */
-
-dsp_status services_clk_get_rate(IN enum services_clk_id clk_id, u32 *speedKhz)
-{
-	dsp_status status = DSP_SOK;
-	struct clk *clk_handle;
-	u32 clk_speed_hz;
-
-	DBC_REQUIRE(clk_id < SERVICESCLK_NOT_DEFINED);
-	*speedKhz = 0x0;
-
-	clk_handle = services_clks[clk_id].clk_handle;
-	if (clk_handle) {
-		clk_speed_hz = clk_get_rate(clk_handle);
-		*speedKhz = clk_speed_hz / 1000;
-		dev_dbg(bridge, "%s: clk_speed_hz = %d, speedinKhz = %d\n",
-			__func__, clk_speed_hz, *speedKhz);
-	} else {
-		pr_err("%s: failed to get %s, dev Id = %d\n", __func__,
-		       services_clks[clk_id].clk_name,
-		       services_clks[clk_id].id);
-		status = DSP_EFAIL;
-	}
-	return status;
-}
-
 s32 clk_get_use_cnt(IN enum services_clk_id clk_id)
 {
 	dsp_status status = DSP_SOK;
diff --git a/drivers/dsp/bridge/wmd/tiomap3430.c b/drivers/dsp/bridge/wmd/tiomap3430.c
index a972ea2..e6fd7ab 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430.c
@@ -348,7 +348,6 @@ static dsp_status bridge_brd_monitor(struct wmd_dev_context *hDevContext)
 
 	get_hw_regs(resources.dw_prm_base, resources.dw_cm_base);
 	hw_rst_un_reset(resources.dw_prm_base, HW_RST2_IVA2);
-	services_clk_enable(SERVICESCLK_IVA2_CK);
 
 	if (DSP_SUCCEEDED(status)) {
 		/* set the device state to IDLE */
@@ -653,11 +652,9 @@ static dsp_status bridge_brd_start(struct wmd_dev_context *hDevContext,
 		*((reg_uword32 *) ((u32) (resources.dw_cm_base) + 0x34)) =
 		    (u32) temp;
 		if ((unsigned int *)ul_dsp_clk_addr != NULL) {
-			/* Get the clock rate */
-			status = services_clk_get_rate(SERVICESCLK_IVA2_CK,
-						       &ul_dsp_clk_rate);
-			dev_dbg(bridge, "%s: DSP clock rate (KHZ): 0x%x \n",
-				__func__, ul_dsp_clk_rate);
+			/* Get the iva2 clock rate */
+			ul_dsp_clk_rate = omap_bridge_get_iva2_rate();
+
 			(void)bridge_brd_write(dev_context,
 					       (u8 *) &ul_dsp_clk_rate,
 					       ul_dsp_clk_addr, sizeof(u32), 0);
@@ -757,7 +754,6 @@ static dsp_status bridge_brd_stop(struct wmd_dev_context *hDevContext)
 	struct cfg_hostres resources;
 	struct pg_table_attrs *pt_attrs;
 	u32 dsp_pwr_state;
-	dsp_status clk_status;
 
 	if (dev_context->dw_brd_state == BRD_STOPPED)
 		return status;
@@ -778,8 +774,6 @@ static dsp_status bridge_brd_stop(struct wmd_dev_context *hDevContext)
 		get_hw_regs(resources.dw_prm_base, resources.dw_cm_base);
 		udelay(50);
 
-		clk_status = services_clk_disable(SERVICESCLK_IVA2_CK);
-
 		/* IVA2 is not in OFF state */
 		/* Set PM_PWSTCTRL_IVA2  to OFF */
 		hw_pwr_iva2_power_state_set(resources.dw_prm_base,
@@ -788,8 +782,6 @@ static dsp_status bridge_brd_stop(struct wmd_dev_context *hDevContext)
 		/* Set the SW supervised state transition for Sleep */
 		hw_pwr_clkctrl_iva2_reg_set(resources.dw_cm_base,
 					    HW_SW_SUP_SLEEP);
-	} else {
-		clk_status = services_clk_disable(SERVICESCLK_IVA2_CK);
 	}
 	udelay(10);
 	/* Release the Ext Base virtual Address as the next DSP Program
@@ -835,7 +827,6 @@ static dsp_status wmd_brd_delete(struct wmd_dev_context *hDevContext)
 	struct wmd_dev_context *dev_context = hDevContext;
 	struct cfg_hostres resources;
 	struct pg_table_attrs *pt_attrs;
-	dsp_status clk_status;
 
 	if (dev_context->dw_brd_state == BRD_STOPPED)
 		return status;
@@ -851,7 +842,6 @@ static dsp_status wmd_brd_delete(struct wmd_dev_context *hDevContext)
 		return DSP_EFAIL;
 
 	status = sleep_dsp(dev_context, PWR_EMERGENCYDEEPSLEEP, NULL);
-	clk_status = services_clk_disable(SERVICESCLK_IVA2_CK);
 
 	/* Release the Ext Base virtual Address as the next DSP Program
 	 * may have a different load address */
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 03/19] DSPBRIDGE: fail if clk handle is NULL
  2010-04-08 23:15   ` [PATCH 02/19] DSPBRIDGE: remove iva2 clk control from custom framework Omar Ramirez Luna
@ 2010-04-08 23:15     ` Omar Ramirez Luna
  2010-04-08 23:15       ` [PATCH 04/19] DSPBRIDGE: Now actually fail if a clk handle is wrong Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:15 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

If we fail if a clk handle is NULL during initialization
then there is no need to keep checking every time if the
handle is NULL for enable/disable/set_32k/get_use_cnt.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/services/clk.c |   54 +++++++++++--------------------------
 1 files changed, 16 insertions(+), 38 deletions(-)

diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index 5ed6bb5..57cf6e3 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -132,7 +132,7 @@ bool services_clk_init(void)
 			pr_err("%s: failed to get clk handle %s, dev id = %d\n",
 			       __func__, services_clks[i].clk_name,
 			       services_clks[i].id);
-			/* should we fail here?? */
+			return false;
 		}
 		services_clks[i].clk_handle = clk_handle;
 		i++;
@@ -155,17 +155,11 @@ dsp_status services_clk_enable(IN enum services_clk_id clk_id)
 	DBC_REQUIRE(clk_id < SERVICESCLK_NOT_DEFINED);
 
 	clk_handle = services_clks[clk_id].clk_handle;
-	if (clk_handle) {
-		if (clk_enable(clk_handle)) {
-			pr_err("services_clk_enable: failed to Enable CLK %s, "
-			       "CLK dev id = %d\n",
-			       services_clks[clk_id].clk_name,
-			       services_clks[clk_id].id);
-			status = DSP_EFAIL;
-		}
-	} else {
-		pr_err("%s: failed to get CLK %s, CLK dev id = %d\n", __func__,
-		     services_clks[clk_id].clk_name, services_clks[clk_id].id);
+	if (clk_enable(clk_handle)) {
+		pr_err("services_clk_enable: failed to Enable CLK %s, "
+		       "CLK dev id = %d\n",
+		       services_clks[clk_id].clk_name,
+		       services_clks[clk_id].id);
 		status = DSP_EFAIL;
 	}
 	/* The SSI module need to configured not to have the Forced idle for
@@ -195,13 +189,11 @@ dsp_status clk_set32k_hz(IN enum services_clk_id clk_id)
 	DBC_REQUIRE(clk_id < SERVICESCLK_NOT_DEFINED);
 
 	clk_handle = services_clks[clk_id].clk_handle;
-	if (clk_handle) {
-		if (!(clk_set_parent(clk_handle, clk_parent) == 0x0)) {
-			pr_err("%s: failed for %s, dev id = %d\n", __func__,
-			       services_clks[clk_id].clk_name,
-			       services_clks[clk_id].id);
-			status = DSP_EFAIL;
-		}
+	if (!(clk_set_parent(clk_handle, clk_parent) == 0x0)) {
+		pr_err("%s: failed for %s, dev id = %d\n", __func__,
+		       services_clks[clk_id].clk_name,
+		       services_clks[clk_id].id);
+		status = DSP_EFAIL;
 	}
 	return status;
 }
@@ -233,36 +225,22 @@ dsp_status services_clk_disable(IN enum services_clk_id clk_id)
 	if (clk_id == SERVICESCLK_SSI_ICK)
 		ssi_clk_prepare(false);
 
-	if (clk_handle) {
-		clk_disable(clk_handle);
-	} else {
-		pr_err("services_clk_disable: failed to get CLK %s,"
-		       "CLK dev id = %d\n",
-		       services_clks[clk_id].clk_name,
-		       services_clks[clk_id].id);
-		status = DSP_EFAIL;
-	}
+	clk_disable(clk_handle);
+
 	return status;
 }
 
 s32 clk_get_use_cnt(IN enum services_clk_id clk_id)
 {
-	dsp_status status = DSP_SOK;
 	struct clk *clk_handle;
 	s32 use_count = -1;
 	DBC_REQUIRE(clk_id < SERVICESCLK_NOT_DEFINED);
 
 	clk_handle = services_clks[clk_id].clk_handle;
 
-	if (clk_handle) {
-		/* FIXME: usecount shouldn't be used */
-		use_count = clk_handle->usecount;
-	} else {
-		pr_err("%s: failed to get %s, dev Id = %d\n", __func__,
-		       services_clks[clk_id].clk_name,
-		       services_clks[clk_id].id);
-		status = DSP_EFAIL;
-	}
+	/* FIXME: usecount shouldn't be used */
+	use_count = clk_handle->usecount;
+
 	return use_count;
 }
 
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 04/19] DSPBRIDGE: Now actually fail if a clk handle is wrong
  2010-04-08 23:15     ` [PATCH 03/19] DSPBRIDGE: fail if clk handle is NULL Omar Ramirez Luna
@ 2010-04-08 23:15       ` Omar Ramirez Luna
  2010-04-08 23:15         ` [PATCH 05/19] DSPBRIDGE: Rename services_clk_* to dsp_clk_* Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:15 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

The value returned by clk_get on error is not NULL.

This checks if the value returned is an error or not.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/services/clk.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index 57cf6e3..74542c7 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -128,7 +128,7 @@ bool services_clk_init(void)
 		clk_handle = clk_get(&dspbridge_device.dev,
 				     services_clks[i].clk_name);
 
-		if (!clk_handle) {
+		if (IS_ERR(clk_handle)) {
 			pr_err("%s: failed to get clk handle %s, dev id = %d\n",
 			       __func__, services_clks[i].clk_name,
 			       services_clks[i].id);
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 05/19] DSPBRIDGE: Rename services_clk_* to dsp_clk_*
  2010-04-08 23:15       ` [PATCH 04/19] DSPBRIDGE: Now actually fail if a clk handle is wrong Omar Ramirez Luna
@ 2010-04-08 23:15         ` Omar Ramirez Luna
  2010-04-08 23:15           ` [PATCH 06/19] DSPBRIDGE: remove unused clock sys_ck Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:15 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

Rename services_clk_* to dsp_clk_*

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 arch/arm/plat-omap/include/dspbridge/clk.h |   72 ++++++++++++------------
 drivers/dsp/bridge/services/clk.c          |   82 ++++++++++++++--------------
 drivers/dsp/bridge/services/services.c     |    6 +-
 drivers/dsp/bridge/wmd/_tiomap.h           |   26 +++++-----
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c    |   16 +++---
 5 files changed, 101 insertions(+), 101 deletions(-)

diff --git a/arch/arm/plat-omap/include/dspbridge/clk.h b/arch/arm/plat-omap/include/dspbridge/clk.h
index 29874a5..6088647 100644
--- a/arch/arm/plat-omap/include/dspbridge/clk.h
+++ b/arch/arm/plat-omap/include/dspbridge/clk.h
@@ -21,36 +21,36 @@
 
 	/* Generic TIMER object: */
 struct timer_object;
-enum services_clk_id {
-	SERVICESCLK_GPT5_FCK,
-	SERVICESCLK_GPT5_ICK,
-	SERVICESCLK_GPT6_FCK,
-	SERVICESCLK_GPT6_ICK,
-	SERVICESCLK_GPT7_FCK,
-	SERVICESCLK_GPT7_ICK,
-	SERVICESCLK_GPT8_FCK,
-	SERVICESCLK_GPT8_ICK,
-	SERVICESCLK_WDT3_FCK,
-	SERVICESCLK_WDT3_ICK,
-	SERVICESCLK_MCBSP1_FCK,
-	SERVICESCLK_MCBSP1_ICK,
-	SERVICESCLK_MCBSP2_FCK,
-	SERVICESCLK_MCBSP2_ICK,
-	SERVICESCLK_MCBSP3_FCK,
-	SERVICESCLK_MCBSP3_ICK,
-	SERVICESCLK_MCBSP4_FCK,
-	SERVICESCLK_MCBSP4_ICK,
-	SERVICESCLK_MCBSP5_FCK,
-	SERVICESCLK_MCBSP5_ICK,
-	SERVICESCLK_SSI_FCK,
-	SERVICESCLK_SSI_ICK,
-	SERVICESCLK_SYS32K_CK,
-	SERVICESCLK_SYS_CK,
-	SERVICESCLK_NOT_DEFINED
+enum dsp_clk_id {
+	DSP_CLK_GPT5_FCK,
+	DSP_CLK_GPT5_ICK,
+	DSP_CLK_GPT6_FCK,
+	DSP_CLK_GPT6_ICK,
+	DSP_CLK_GPT7_FCK,
+	DSP_CLK_GPT7_ICK,
+	DSP_CLK_GPT8_FCK,
+	DSP_CLK_GPT8_ICK,
+	DSP_CLK_WDT3_FCK,
+	DSP_CLK_WDT3_ICK,
+	DSP_CLK_MCBSP1_FCK,
+	DSP_CLK_MCBSP1_ICK,
+	DSP_CLK_MCBSP2_FCK,
+	DSP_CLK_MCBSP2_ICK,
+	DSP_CLK_MCBSP3_FCK,
+	DSP_CLK_MCBSP3_ICK,
+	DSP_CLK_MCBSP4_FCK,
+	DSP_CLK_MCBSP4_ICK,
+	DSP_CLK_MCBSP5_FCK,
+	DSP_CLK_MCBSP5_ICK,
+	DSP_CLK_SSI_FCK,
+	DSP_CLK_SSI_ICK,
+	DSP_CLK_SYS32K_CK,
+	DSP_CLK_SYS_CK,
+	DSP_CLK_NOT_DEFINED
 };
 
 /*
- *  ======== clk_exit ========
+ *  ======== dsp_clk_exit ========
  *  Purpose:
  *      Discontinue usage of module; free resources when reference count
  *      reaches 0.
@@ -61,10 +61,10 @@ enum services_clk_id {
  *  Ensures:
  *      Resources used by module are freed when cRef reaches zero.
  */
-extern void clk_exit(void);
+extern void dsp_clk_exit(void);
 
 /*
- *  ======== services_clk_init ========
+ *  ======== dsp_clk_init ========
  *  Purpose:
  *      Initializes private state of CLK module.
  *  Parameters:
@@ -74,10 +74,10 @@ extern void clk_exit(void);
  *  Ensures:
  *      CLK initialized.
  */
-extern bool services_clk_init(void);
+extern bool dsp_clk_init(void);
 
 /*
- *  ======== services_clk_enable ========
+ *  ======== dsp_clk_enable ========
  *  Purpose:
  *      Enables the clock requested.
  *  Parameters:
@@ -87,10 +87,10 @@ extern bool services_clk_init(void);
  *  Requires:
  *  Ensures:
  */
-extern dsp_status services_clk_enable(IN enum services_clk_id clk_id);
+extern dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id);
 
 /*
- *  ======== services_clk_disable ========
+ *  ======== dsp_clk_disable ========
  *  Purpose:
  *      Disables the clock requested.
  *  Parameters:
@@ -100,7 +100,7 @@ extern dsp_status services_clk_enable(IN enum services_clk_id clk_id);
  *  Requires:
  *  Ensures:
  */
-extern dsp_status services_clk_disable(IN enum services_clk_id clk_id);
+extern dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id);
 
 /*
  *  ======== clk_set32k_hz ========
@@ -113,7 +113,7 @@ extern dsp_status services_clk_disable(IN enum services_clk_id clk_id);
  *  Requires:
  *  Ensures:
  */
-extern dsp_status clk_set32k_hz(IN enum services_clk_id clk_id);
+extern dsp_status clk_set32k_hz(IN enum dsp_clk_id clk_id);
 extern void ssi_clk_prepare(bool FLAG);
 
 /*
@@ -127,7 +127,7 @@ extern void ssi_clk_prepare(bool FLAG);
  *  Requires:
  *  Ensures:
  */
-extern s32 clk_get_use_cnt(IN enum services_clk_id clk_id);
+extern s32 clk_get_use_cnt(IN enum dsp_clk_id clk_id);
 
 u32 omap_bridge_get_iva2_rate(void);
 
diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index 74542c7..6cc1097 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -45,16 +45,16 @@ typedef volatile unsigned long reg_uword32;
 #define SSI_SIDLE_SMARTIDLE		(2 << 3)
 #define SSI_MIDLE_NOIDLE		(1 << 12)
 
-struct services_clk_t {
+struct dsp_clk_t {
 	struct clk *clk_handle;
 	const char *clk_name;
 	int id;
 };
 
 /* The row order of the below array needs to match with the clock enumerations
- * 'services_clk_id' provided in the header file.. any changes in the
+ * 'dsp_clk_id' provided in the header file.. any changes in the
  * enumerations needs to be fixed in the array as well */
-static struct services_clk_t services_clks[] = {
+static struct dsp_clk_t dsp_clks[] = {
 	{NULL, "gpt5_fck", -1},
 	{NULL, "gpt5_ick", -1},
 	{NULL, "gpt6_fck", -1},
@@ -88,31 +88,31 @@ struct timer_object {
 };
 
 /*
- *  ======== clk_exit ========
+ *  ======== dsp_clk_exit ========
  *  Purpose:
  *      Cleanup CLK module.
  */
-void clk_exit(void)
+void dsp_clk_exit(void)
 {
 	int i = 0;
 
 	/* Relinquish the clock handles */
-	while (i < SERVICESCLK_NOT_DEFINED) {
-		if (services_clks[i].clk_handle)
-			clk_put(services_clks[i].clk_handle);
+	while (i < DSP_CLK_NOT_DEFINED) {
+		if (dsp_clks[i].clk_handle)
+			clk_put(dsp_clks[i].clk_handle);
 
-		services_clks[i].clk_handle = NULL;
+		dsp_clks[i].clk_handle = NULL;
 		i++;
 	}
 
 }
 
 /*
- *  ======== services_clk_init ========
+ *  ======== dsp_clk_init ========
  *  Purpose:
  *      Initialize CLK module.
  */
-bool services_clk_init(void)
+bool dsp_clk_init(void)
 {
 	static struct platform_device dspbridge_device;
 	struct clk *clk_handle;
@@ -121,20 +121,20 @@ bool services_clk_init(void)
 	dspbridge_device.dev.bus = &platform_bus_type;
 
 	/* Get the clock handles from base port and store locally */
-	while (i < SERVICESCLK_NOT_DEFINED) {
+	while (i < DSP_CLK_NOT_DEFINED) {
 		/* get the handle from BP */
-		dspbridge_device.id = services_clks[i].id;
+		dspbridge_device.id = dsp_clks[i].id;
 
 		clk_handle = clk_get(&dspbridge_device.dev,
-				     services_clks[i].clk_name);
+				     dsp_clks[i].clk_name);
 
 		if (IS_ERR(clk_handle)) {
 			pr_err("%s: failed to get clk handle %s, dev id = %d\n",
-			       __func__, services_clks[i].clk_name,
-			       services_clks[i].id);
+			       __func__, dsp_clks[i].clk_name,
+			       dsp_clks[i].id);
 			return false;
 		}
-		services_clks[i].clk_handle = clk_handle;
+		dsp_clks[i].clk_handle = clk_handle;
 		i++;
 	}
 
@@ -142,24 +142,24 @@ bool services_clk_init(void)
 }
 
 /*
- *  ======== services_clk_enable ========
+ *  ======== dsp_clk_enable ========
  *  Purpose:
  *      Enable Clock .
  *
  */
-dsp_status services_clk_enable(IN enum services_clk_id clk_id)
+dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 {
 	dsp_status status = DSP_SOK;
 	struct clk *clk_handle;
 
-	DBC_REQUIRE(clk_id < SERVICESCLK_NOT_DEFINED);
+	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
 
-	clk_handle = services_clks[clk_id].clk_handle;
+	clk_handle = dsp_clks[clk_id].clk_handle;
 	if (clk_enable(clk_handle)) {
-		pr_err("services_clk_enable: failed to Enable CLK %s, "
+		pr_err("dsp_clk_enable: failed to Enable CLK %s, "
 		       "CLK dev id = %d\n",
-		       services_clks[clk_id].clk_name,
-		       services_clks[clk_id].id);
+		       dsp_clks[clk_id].clk_name,
+		       dsp_clks[clk_id].id);
 		status = DSP_EFAIL;
 	}
 	/* The SSI module need to configured not to have the Forced idle for
@@ -167,7 +167,7 @@ dsp_status services_clk_enable(IN enum services_clk_id clk_id)
 	 * transitioning to standby thereby causing the client in the DSP hang
 	 * waiting for the SSI module to be active after enabling the clocks
 	 */
-	if (clk_id == SERVICESCLK_SSI_FCK)
+	if (clk_id == DSP_CLK_SSI_FCK)
 		ssi_clk_prepare(true);
 
 	return status;
@@ -179,50 +179,50 @@ dsp_status services_clk_enable(IN enum services_clk_id clk_id)
  *      To Set parent of a clock to 32KHz.
  */
 
-dsp_status clk_set32k_hz(IN enum services_clk_id clk_id)
+dsp_status clk_set32k_hz(IN enum dsp_clk_id clk_id)
 {
 	dsp_status status = DSP_SOK;
 	struct clk *clk_handle;
 	struct clk *clk_parent;
-	clk_parent = services_clks[SERVICESCLK_SYS32K_CK].clk_handle;
+	clk_parent = dsp_clks[DSP_CLK_SYS32K_CK].clk_handle;
 
-	DBC_REQUIRE(clk_id < SERVICESCLK_NOT_DEFINED);
+	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
 
-	clk_handle = services_clks[clk_id].clk_handle;
+	clk_handle = dsp_clks[clk_id].clk_handle;
 	if (!(clk_set_parent(clk_handle, clk_parent) == 0x0)) {
 		pr_err("%s: failed for %s, dev id = %d\n", __func__,
-		       services_clks[clk_id].clk_name,
-		       services_clks[clk_id].id);
+		       dsp_clks[clk_id].clk_name,
+		       dsp_clks[clk_id].id);
 		status = DSP_EFAIL;
 	}
 	return status;
 }
 
 /*
- *  ======== services_clk_disable ========
+ *  ======== dsp_clk_disable ========
  *  Purpose:
  *      Disable the clock.
  *
  */
-dsp_status services_clk_disable(IN enum services_clk_id clk_id)
+dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 {
 	dsp_status status = DSP_SOK;
 	struct clk *clk_handle;
 	s32 clk_use_cnt;
 
-	DBC_REQUIRE(clk_id < SERVICESCLK_NOT_DEFINED);
+	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
 
-	clk_handle = services_clks[clk_id].clk_handle;
+	clk_handle = dsp_clks[clk_id].clk_handle;
 
 	clk_use_cnt = clk_get_use_cnt(clk_id);
 	if (clk_use_cnt == -1) {
 		pr_err("%s: failed to get CLK Use count for CLK %s, CLK dev id"
-		       " = %d\n", __func__, services_clks[clk_id].clk_name,
-		       services_clks[clk_id].id);
+		       " = %d\n", __func__, dsp_clks[clk_id].clk_name,
+		       dsp_clks[clk_id].id);
 	} else if (clk_use_cnt == 0) {
 		return status;
 	}
-	if (clk_id == SERVICESCLK_SSI_ICK)
+	if (clk_id == DSP_CLK_SSI_ICK)
 		ssi_clk_prepare(false);
 
 	clk_disable(clk_handle);
@@ -230,13 +230,13 @@ dsp_status services_clk_disable(IN enum services_clk_id clk_id)
 	return status;
 }
 
-s32 clk_get_use_cnt(IN enum services_clk_id clk_id)
+s32 clk_get_use_cnt(IN enum dsp_clk_id clk_id)
 {
 	struct clk *clk_handle;
 	s32 use_count = -1;
-	DBC_REQUIRE(clk_id < SERVICESCLK_NOT_DEFINED);
+	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
 
-	clk_handle = services_clks[clk_id].clk_handle;
+	clk_handle = dsp_clks[clk_id].clk_handle;
 
 	/* FIXME: usecount shouldn't be used */
 	use_count = clk_handle->usecount;
diff --git a/drivers/dsp/bridge/services/services.c b/drivers/dsp/bridge/services/services.c
index 5bc392a..bfce2f6 100644
--- a/drivers/dsp/bridge/services/services.c
+++ b/drivers/dsp/bridge/services/services.c
@@ -47,7 +47,7 @@ void services_exit(void)
 	/* Uninitialize all SERVICES modules here */
 	ntfy_exit();
 	sync_exit();
-	clk_exit();
+	dsp_clk_exit();
 	reg_exit();
 	cfg_exit();
 	mem_exit();
@@ -69,7 +69,7 @@ bool services_init(void)
 	freg = reg_init();
 	fcfg = cfg_init();
 	fsync = sync_init();
-	fclk = services_clk_init();
+	fclk = dsp_clk_init();
 	fntfy = ntfy_init();
 
 	ret = fcfg && fmem && freg && fsync && fclk;
@@ -82,7 +82,7 @@ bool services_init(void)
 			sync_exit();
 
 		if (fclk)
-			clk_exit();
+			dsp_clk_exit();
 
 		if (freg)
 			reg_exit();
diff --git a/drivers/dsp/bridge/wmd/_tiomap.h b/drivers/dsp/bridge/wmd/_tiomap.h
index 71ef731..5e4e518 100644
--- a/drivers/dsp/bridge/wmd/_tiomap.h
+++ b/drivers/dsp/bridge/wmd/_tiomap.h
@@ -242,22 +242,22 @@ static const u32 bpwr_clkid[] = {
 
 struct bpwr_clk_t {
 	u32 clk_id;
-	enum services_clk_id fun_clk;
-	enum services_clk_id int_clk;
+	enum dsp_clk_id fun_clk;
+	enum dsp_clk_id int_clk;
 };
 
 static const struct bpwr_clk_t bpwr_clks[] = {
-	{(u32) BPWR_GP_TIMER5, SERVICESCLK_GPT5_FCK, SERVICESCLK_GPT5_ICK},
-	{(u32) BPWR_GP_TIMER6, SERVICESCLK_GPT6_FCK, SERVICESCLK_GPT6_ICK},
-	{(u32) BPWR_GP_TIMER7, SERVICESCLK_GPT7_FCK, SERVICESCLK_GPT7_ICK},
-	{(u32) BPWR_GP_TIMER8, SERVICESCLK_GPT8_FCK, SERVICESCLK_GPT8_ICK},
-	{(u32) BPWR_WD_TIMER3, SERVICESCLK_WDT3_FCK, SERVICESCLK_WDT3_ICK},
-	{(u32) BPWR_MCBSP1, SERVICESCLK_MCBSP1_FCK, SERVICESCLK_MCBSP1_ICK},
-	{(u32) BPWR_MCBSP2, SERVICESCLK_MCBSP2_FCK, SERVICESCLK_MCBSP2_ICK},
-	{(u32) BPWR_MCBSP3, SERVICESCLK_MCBSP3_FCK, SERVICESCLK_MCBSP3_ICK},
-	{(u32) BPWR_MCBSP4, SERVICESCLK_MCBSP4_FCK, SERVICESCLK_MCBSP4_ICK},
-	{(u32) BPWR_MCBSP5, SERVICESCLK_MCBSP5_FCK, SERVICESCLK_MCBSP5_ICK},
-	{(u32) BPWR_SSI, SERVICESCLK_SSI_FCK, SERVICESCLK_SSI_ICK}
+	{(u32) BPWR_GP_TIMER5, DSP_CLK_GPT5_FCK, DSP_CLK_GPT5_ICK},
+	{(u32) BPWR_GP_TIMER6, DSP_CLK_GPT6_FCK, DSP_CLK_GPT6_ICK},
+	{(u32) BPWR_GP_TIMER7, DSP_CLK_GPT7_FCK, DSP_CLK_GPT7_ICK},
+	{(u32) BPWR_GP_TIMER8, DSP_CLK_GPT8_FCK, DSP_CLK_GPT8_ICK},
+	{(u32) BPWR_WD_TIMER3, DSP_CLK_WDT3_FCK, DSP_CLK_WDT3_ICK},
+	{(u32) BPWR_MCBSP1, DSP_CLK_MCBSP1_FCK, DSP_CLK_MCBSP1_ICK},
+	{(u32) BPWR_MCBSP2, DSP_CLK_MCBSP2_FCK, DSP_CLK_MCBSP2_ICK},
+	{(u32) BPWR_MCBSP3, DSP_CLK_MCBSP3_FCK, DSP_CLK_MCBSP3_ICK},
+	{(u32) BPWR_MCBSP4, DSP_CLK_MCBSP4_FCK, DSP_CLK_MCBSP4_ICK},
+	{(u32) BPWR_MCBSP5, DSP_CLK_MCBSP5_FCK, DSP_CLK_MCBSP5_ICK},
+	{(u32) BPWR_SSI, DSP_CLK_SSI_FCK, DSP_CLK_SSI_ICK}
 };
 
 /* Interrupt Register Offsets */
diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index 9174a80..087a416 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -335,8 +335,8 @@ dsp_status dsp_peripheral_clk_ctrl(struct wmd_dev_context *dev_context,
 	switch (ext_clk_cmd) {
 	case BPWR_DISABLE_CLOCK:
 		/* Call BP to disable the needed clock */
-		status1 = services_clk_disable(bpwr_clks[clk_id_index].int_clk);
-		status = services_clk_disable(bpwr_clks[clk_id_index].fun_clk);
+		status1 = dsp_clk_disable(bpwr_clks[clk_id_index].int_clk);
+		status = dsp_clk_disable(bpwr_clks[clk_id_index].fun_clk);
 		if (bpwr_clkid[clk_id_index] == BPWR_MCBSP1) {
 			/* clear MCBSP1_CLKS, on McBSP1 OFF */
 			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
@@ -356,8 +356,8 @@ dsp_status dsp_peripheral_clk_ctrl(struct wmd_dev_context *dev_context,
 		}
 		break;
 	case BPWR_ENABLE_CLOCK:
-		status1 = services_clk_enable(bpwr_clks[clk_id_index].int_clk);
-		status = services_clk_enable(bpwr_clks[clk_id_index].fun_clk);
+		status1 = dsp_clk_enable(bpwr_clks[clk_id_index].int_clk);
+		status = dsp_clk_enable(bpwr_clks[clk_id_index].fun_clk);
 		if (bpwr_clkid[clk_id_index] == BPWR_MCBSP1) {
 			/* set MCBSP1_CLKS, on McBSP1 ON */
 			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
@@ -478,7 +478,7 @@ dsp_status dsp_peripheral_clocks_disable(struct wmd_dev_context *dev_context,
 		if (((dev_context->dsp_per_clks) >> clk_idx) & 0x01) {
 			/* Disables the interface clock of the peripheral */
 			status =
-			    services_clk_disable(bpwr_clks[clk_idx].int_clk);
+			    dsp_clk_disable(bpwr_clks[clk_idx].int_clk);
 			if (bpwr_clkid[clk_idx] == BPWR_MCBSP1) {
 				/* clear MCBSP1_CLKS, on McBSP1 OFF */
 				value = __raw_readl(resources.dw_sys_ctrl_base
@@ -497,7 +497,7 @@ dsp_status dsp_peripheral_clocks_disable(struct wmd_dev_context *dev_context,
 
 			/* Disables the functional clock of the periphearl */
 			status =
-			    services_clk_disable(bpwr_clks[clk_idx].fun_clk);
+			    dsp_clk_disable(bpwr_clks[clk_idx].fun_clk);
 		}
 	}
 	return status;
@@ -522,7 +522,7 @@ dsp_status dsp_peripheral_clocks_enable(struct wmd_dev_context *dev_context,
 		if (((dev_context->dsp_per_clks) >> clk_idx) & 0x01) {
 			/* Enable the interface clock of the peripheral */
 			int_clk_status =
-			    services_clk_enable(bpwr_clks[clk_idx].int_clk);
+			    dsp_clk_enable(bpwr_clks[clk_idx].int_clk);
 			if (bpwr_clkid[clk_idx] == BPWR_MCBSP1) {
 				/* set MCBSP1_CLKS, on McBSP1 ON */
 				value = __raw_readl(resources.dw_sys_ctrl_base
@@ -540,7 +540,7 @@ dsp_status dsp_peripheral_clocks_enable(struct wmd_dev_context *dev_context,
 			}
 			/* Enable the functional clock of the periphearl */
 			fun_clk_status =
-			    services_clk_enable(bpwr_clks[clk_idx].fun_clk);
+			    dsp_clk_enable(bpwr_clks[clk_idx].fun_clk);
 		}
 	}
 	if ((int_clk_status | fun_clk_status) != DSP_SOK)
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 06/19] DSPBRIDGE: remove unused clock sys_ck
  2010-04-08 23:15         ` [PATCH 05/19] DSPBRIDGE: Rename services_clk_* to dsp_clk_* Omar Ramirez Luna
@ 2010-04-08 23:15           ` Omar Ramirez Luna
  2010-04-08 23:15             ` [PATCH 07/19] DSPBRIDGE: remove function clk_set32k_hz Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:15 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

Remove unused clock sys_ck

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 arch/arm/plat-omap/include/dspbridge/clk.h |    1 -
 drivers/dsp/bridge/services/clk.c          |    1 -
 2 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-omap/include/dspbridge/clk.h b/arch/arm/plat-omap/include/dspbridge/clk.h
index 6088647..55f5f29 100644
--- a/arch/arm/plat-omap/include/dspbridge/clk.h
+++ b/arch/arm/plat-omap/include/dspbridge/clk.h
@@ -45,7 +45,6 @@ enum dsp_clk_id {
 	DSP_CLK_SSI_FCK,
 	DSP_CLK_SSI_ICK,
 	DSP_CLK_SYS32K_CK,
-	DSP_CLK_SYS_CK,
 	DSP_CLK_NOT_DEFINED
 };
 
diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index 6cc1097..33cb23f 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -78,7 +78,6 @@ static struct dsp_clk_t dsp_clks[] = {
 	{NULL, "ssi_ssr_sst_fck", -1},
 	{NULL, "ssi_ick", -1},
 	{NULL, "omap_32k_fck", -1},
-	{NULL, "sys_ck", -1},
 	{NULL, ""}
 };
 
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 07/19] DSPBRIDGE: remove function clk_set32k_hz
  2010-04-08 23:15           ` [PATCH 06/19] DSPBRIDGE: remove unused clock sys_ck Omar Ramirez Luna
@ 2010-04-08 23:15             ` Omar Ramirez Luna
  2010-04-08 23:15               ` [PATCH 08/19] DSPBRIDGE: remove clk_get_use_cnt Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:15 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

This is only used for GPTs and should be addressed once
those clocks are requested using DM timer framework.

This patch might break functionality.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 arch/arm/plat-omap/include/dspbridge/clk.h |   13 -------------
 drivers/dsp/bridge/services/clk.c          |   26 --------------------------
 drivers/dsp/bridge/wmd/tiomap3430.c        |   15 ---------------
 3 files changed, 0 insertions(+), 54 deletions(-)

diff --git a/arch/arm/plat-omap/include/dspbridge/clk.h b/arch/arm/plat-omap/include/dspbridge/clk.h
index 55f5f29..73d97c7 100644
--- a/arch/arm/plat-omap/include/dspbridge/clk.h
+++ b/arch/arm/plat-omap/include/dspbridge/clk.h
@@ -44,7 +44,6 @@ enum dsp_clk_id {
 	DSP_CLK_MCBSP5_ICK,
 	DSP_CLK_SSI_FCK,
 	DSP_CLK_SSI_ICK,
-	DSP_CLK_SYS32K_CK,
 	DSP_CLK_NOT_DEFINED
 };
 
@@ -101,18 +100,6 @@ extern dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id);
  */
 extern dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id);
 
-/*
- *  ======== clk_set32k_hz ========
- *  Purpose:
- *      Set the requested clock to 32KHz.
- *  Parameters:
- *  Returns:
- *      DSP_SOK:        Success.
- *      DSP_EFAIL:      Error occured while setting the clock parent to 32KHz.
- *  Requires:
- *  Ensures:
- */
-extern dsp_status clk_set32k_hz(IN enum dsp_clk_id clk_id);
 extern void ssi_clk_prepare(bool FLAG);
 
 /*
diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index 33cb23f..d675aba 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -77,7 +77,6 @@ static struct dsp_clk_t dsp_clks[] = {
 	{NULL, "mcbsp_ick", 5},
 	{NULL, "ssi_ssr_sst_fck", -1},
 	{NULL, "ssi_ick", -1},
-	{NULL, "omap_32k_fck", -1},
 	{NULL, ""}
 };
 
@@ -173,31 +172,6 @@ dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 }
 
 /*
- *  ======== clk_set32k_hz ========
- *  Purpose:
- *      To Set parent of a clock to 32KHz.
- */
-
-dsp_status clk_set32k_hz(IN enum dsp_clk_id clk_id)
-{
-	dsp_status status = DSP_SOK;
-	struct clk *clk_handle;
-	struct clk *clk_parent;
-	clk_parent = dsp_clks[DSP_CLK_SYS32K_CK].clk_handle;
-
-	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
-
-	clk_handle = dsp_clks[clk_id].clk_handle;
-	if (!(clk_set_parent(clk_handle, clk_parent) == 0x0)) {
-		pr_err("%s: failed for %s, dev id = %d\n", __func__,
-		       dsp_clks[clk_id].clk_name,
-		       dsp_clks[clk_id].id);
-		status = DSP_EFAIL;
-	}
-	return status;
-}
-
-/*
  *  ======== dsp_clk_disable ========
  *  Purpose:
  *      Disable the clock.
diff --git a/drivers/dsp/bridge/wmd/tiomap3430.c b/drivers/dsp/bridge/wmd/tiomap3430.c
index e6fd7ab..fedd521 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430.c
@@ -587,13 +587,6 @@ static dsp_status bridge_brd_start(struct wmd_dev_context *hDevContext,
 				}
 			}
 
-			if (clk_id_index < MBX_PM_MAX_RESOURCES) {
-				status =
-				    clk_set32k_hz(bpwr_clks
-						  [clk_id_index].fun_clk);
-			} else {
-				status = DSP_EFAIL;
-			}
 			clk_cmd = (BPWR_ENABLE_CLOCK << MBX_PM_CLK_CMDSHIFT) |
 			    ul_load_monitor_timer;
 
@@ -622,14 +615,6 @@ static dsp_status bridge_brd_start(struct wmd_dev_context *hDevContext,
 				}
 			}
 
-			if (clk_id_index < MBX_PM_MAX_RESOURCES) {
-				status =
-				    clk_set32k_hz(bpwr_clks
-						  [clk_id_index].fun_clk);
-			} else {
-				status = DSP_EFAIL;
-			}
-
 			clk_cmd = (BPWR_ENABLE_CLOCK << MBX_PM_CLK_CMDSHIFT) |
 			    ul_bios_gp_timer;
 
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 08/19] DSPBRIDGE: remove clk_get_use_cnt
  2010-04-08 23:15             ` [PATCH 07/19] DSPBRIDGE: remove function clk_set32k_hz Omar Ramirez Luna
@ 2010-04-08 23:15               ` Omar Ramirez Luna
  2010-04-08 23:15                 ` [PATCH 09/19] DSPBRIDGE: trivial clock cleanup for unused code Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:15 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

Instead of querying the use count, balanced number of
enable/disable should be enforced across the system.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 arch/arm/plat-omap/include/dspbridge/clk.h |   13 -------------
 drivers/dsp/bridge/services/clk.c          |   23 -----------------------
 2 files changed, 0 insertions(+), 36 deletions(-)

diff --git a/arch/arm/plat-omap/include/dspbridge/clk.h b/arch/arm/plat-omap/include/dspbridge/clk.h
index 73d97c7..0c16709 100644
--- a/arch/arm/plat-omap/include/dspbridge/clk.h
+++ b/arch/arm/plat-omap/include/dspbridge/clk.h
@@ -102,19 +102,6 @@ extern dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id);
 
 extern void ssi_clk_prepare(bool FLAG);
 
-/*
- *  ======== CLK_Get_RefCnt ========
- *  Purpose:
- *      get the reference count for the clock.
- *  Parameters:
- *  Returns:
- *      s32:        Reference Count for the clock.
- *      DSP_EFAIL:  Error occured while getting the reference count of a clock.
- *  Requires:
- *  Ensures:
- */
-extern s32 clk_get_use_cnt(IN enum dsp_clk_id clk_id);
-
 u32 omap_bridge_get_iva2_rate(void);
 
 #endif /* _SYNC_H */
diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index d675aba..094fe68 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -181,20 +181,11 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 {
 	dsp_status status = DSP_SOK;
 	struct clk *clk_handle;
-	s32 clk_use_cnt;
 
 	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
 
 	clk_handle = dsp_clks[clk_id].clk_handle;
 
-	clk_use_cnt = clk_get_use_cnt(clk_id);
-	if (clk_use_cnt == -1) {
-		pr_err("%s: failed to get CLK Use count for CLK %s, CLK dev id"
-		       " = %d\n", __func__, dsp_clks[clk_id].clk_name,
-		       dsp_clks[clk_id].id);
-	} else if (clk_use_cnt == 0) {
-		return status;
-	}
 	if (clk_id == DSP_CLK_SSI_ICK)
 		ssi_clk_prepare(false);
 
@@ -203,20 +194,6 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 	return status;
 }
 
-s32 clk_get_use_cnt(IN enum dsp_clk_id clk_id)
-{
-	struct clk *clk_handle;
-	s32 use_count = -1;
-	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
-
-	clk_handle = dsp_clks[clk_id].clk_handle;
-
-	/* FIXME: usecount shouldn't be used */
-	use_count = clk_handle->usecount;
-
-	return use_count;
-}
-
 void ssi_clk_prepare(bool FLAG)
 {
 	void __iomem *ssi_base;
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 09/19] DSPBRIDGE: trivial clock cleanup for unused code
  2010-04-08 23:15               ` [PATCH 08/19] DSPBRIDGE: remove clk_get_use_cnt Omar Ramirez Luna
@ 2010-04-08 23:15                 ` Omar Ramirez Luna
  2010-04-08 23:15                   ` [PATCH 10/19] DSPBRIDGE: function to get the type of clock requested by dsp Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:15 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

Remove unusued struct and typedef.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 arch/arm/plat-omap/include/dspbridge/clk.h |    2 --
 drivers/dsp/bridge/services/clk.c          |    7 -------
 2 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/arch/arm/plat-omap/include/dspbridge/clk.h b/arch/arm/plat-omap/include/dspbridge/clk.h
index 0c16709..44f0f0e 100644
--- a/arch/arm/plat-omap/include/dspbridge/clk.h
+++ b/arch/arm/plat-omap/include/dspbridge/clk.h
@@ -19,8 +19,6 @@
 #ifndef _CLK_H
 #define _CLK_H
 
-	/* Generic TIMER object: */
-struct timer_object;
 enum dsp_clk_id {
 	DSP_CLK_GPT5_FCK,
 	DSP_CLK_GPT5_ICK,
diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index 094fe68..babf043 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -35,8 +35,6 @@
 
 /*  ----------------------------------- Defines, Data Structures, Typedefs */
 
-typedef volatile unsigned long reg_uword32;
-
 #define OMAP_SSI_OFFSET			0x58000
 #define OMAP_SSI_SIZE			0x1000
 #define OMAP_SSI_SYSCONFIG_OFFSET	0x10
@@ -80,11 +78,6 @@ static struct dsp_clk_t dsp_clks[] = {
 	{NULL, ""}
 };
 
-/* Generic TIMER object: */
-struct timer_object {
-	struct timer_list timer;
-};
-
 /*
  *  ======== dsp_clk_exit ========
  *  Purpose:
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 10/19] DSPBRIDGE: function to get the type of clock requested by dsp
  2010-04-08 23:15                 ` [PATCH 09/19] DSPBRIDGE: trivial clock cleanup for unused code Omar Ramirez Luna
@ 2010-04-08 23:15                   ` Omar Ramirez Luna
  2010-04-08 23:16                     ` [PATCH 11/19] DSPBRIDGE: use dm timer framework for gpt timers Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:15 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

DSP can request between 4 types of clocks: GPT (5-8), WDT (3),
MCBSP (1-5) or SSI clock. This function will be useful in case
a specific clock framework is associated with the clock.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/services/clk.c |   80 ++++++++++++++++++++++++++++---------
 1 files changed, 61 insertions(+), 19 deletions(-)

diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index babf043..6e76dd3 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -43,6 +43,12 @@
 #define SSI_SIDLE_SMARTIDLE		(2 << 3)
 #define SSI_MIDLE_NOIDLE		(1 << 12)
 
+/* Clk types requested by the dsp */
+#define GPT_CLK		0
+#define WDT_CLK		1
+#define MCBSP_CLK	2
+#define SSI_CLK		3
+
 struct dsp_clk_t {
 	struct clk *clk_handle;
 	const char *clk_name;
@@ -78,6 +84,24 @@ static struct dsp_clk_t dsp_clks[] = {
 	{NULL, ""}
 };
 
+static s8 get_clk_type(u8 id)
+{
+	s8 type;
+
+	if (id <= DSP_CLK_GPT8_ICK)
+		type = GPT_CLK;
+	else if (id <= DSP_CLK_WDT3_ICK)
+		type = WDT_CLK;
+	else if (id <= DSP_CLK_MCBSP5_ICK)
+		type = MCBSP_CLK;
+	else if (id < DSP_CLK_SSI_ICK)
+		type = SSI_CLK;
+	else
+		type = -1;
+
+	return type;
+}
+
 /*
  *  ======== dsp_clk_exit ========
  *  Purpose:
@@ -143,23 +167,32 @@ dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 	dsp_status status = DSP_SOK;
 	struct clk *clk_handle;
 
-	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
+	switch (get_clk_type(clk_id)) {
+	case GPT_CLK:
+	case MCBSP_CLK:
+	case WDT_CLK:
+	case SSI_CLK:
+		clk_handle = dsp_clks[clk_id].clk_handle;
+		if (clk_enable(clk_handle)) {
+			pr_err("dsp_clk_enable: failed to Enable CLK %s, "
+				"CLK dev id = %d\n", dsp_clks[clk_id].clk_name,
+				dsp_clks[clk_id].id);
+				status = DSP_EFAIL;
+		}
 
-	clk_handle = dsp_clks[clk_id].clk_handle;
-	if (clk_enable(clk_handle)) {
-		pr_err("dsp_clk_enable: failed to Enable CLK %s, "
-		       "CLK dev id = %d\n",
-		       dsp_clks[clk_id].clk_name,
-		       dsp_clks[clk_id].id);
-		status = DSP_EFAIL;
+		/*
+		 * The SSI module need to configured not to have the Forced
+		 * idle for master interface. If it is set to forced idle,
+		 * the SSI module is transitioning to standby thereby causing
+		 * the client in the DSP hang waiting for the SSI module to
+		 * be active after enabling the clocks
+		 */
+		if (clk_id == DSP_CLK_SSI_ICK)
+			ssi_clk_prepare(true);
+		break;
+	default:
+		dev_err(bridge, "Invalid clock id for enable\n");
 	}
-	/* The SSI module need to configured not to have the Forced idle for
-	 * master interface. If it is set to forced idle, the SSI module is
-	 * transitioning to standby thereby causing the client in the DSP hang
-	 * waiting for the SSI module to be active after enabling the clocks
-	 */
-	if (clk_id == DSP_CLK_SSI_FCK)
-		ssi_clk_prepare(true);
 
 	return status;
 }
@@ -177,12 +210,21 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 
 	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
 
-	clk_handle = dsp_clks[clk_id].clk_handle;
+	switch (get_clk_type(clk_id)) {
+	case GPT_CLK:
+	case MCBSP_CLK:
+	case WDT_CLK:
+	case SSI_CLK:
+		clk_handle = dsp_clks[clk_id].clk_handle;
 
-	if (clk_id == DSP_CLK_SSI_ICK)
-		ssi_clk_prepare(false);
+		if (clk_id == DSP_CLK_SSI_ICK)
+			ssi_clk_prepare(false);
 
-	clk_disable(clk_handle);
+		clk_disable(clk_handle);
+		break;
+	default:
+		dev_err(bridge, "Invalid clock id for disable\n");
+	}
 
 	return status;
 }
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 11/19] DSPBRIDGE: use dm timer framework for gpt timers
  2010-04-08 23:15                   ` [PATCH 10/19] DSPBRIDGE: function to get the type of clock requested by dsp Omar Ramirez Luna
@ 2010-04-08 23:16                     ` Omar Ramirez Luna
  2010-04-08 23:16                       ` [PATCH 12/19] DSPBRIDGE: use omap mcbsp to enable mcbsp clocks Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:16 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna,
	Omar Ramirez Luna

This patch switches to use DM timer framework instead of
a custom one for GPT timers, currently dsp can make use of
gpt 5, 6, 7 or 8.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@hotmail.com>
---
 drivers/dsp/bridge/services/clk.c   |   28 ++++++++++++++------------
 drivers/dsp/bridge/wmd/tiomap3430.c |   36 -----------------------------------
 2 files changed, 15 insertions(+), 49 deletions(-)

diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index 6e76dd3..46b4cab 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -18,6 +18,7 @@
 
 /*  ----------------------------------- Host OS */
 #include <dspbridge/host_os.h>
+#include <plat/dmtimer.h>
 
 /*  ----------------------------------- DSP/BIOS Bridge */
 #include <dspbridge/std.h>
@@ -49,24 +50,21 @@
 #define MCBSP_CLK	2
 #define SSI_CLK		3
 
+/*
+ * Bridge specific DM Timer macro.
+ * Bridge GPT id (0 - 3), DM Timer id (5 - 8)
+ */
+#define DMT_ID(id) ((id) + 5)
+
 struct dsp_clk_t {
 	struct clk *clk_handle;
 	const char *clk_name;
 	int id;
 };
 
-/* The row order of the below array needs to match with the clock enumerations
- * 'dsp_clk_id' provided in the header file.. any changes in the
- * enumerations needs to be fixed in the array as well */
+static struct omap_dm_timer *timer[4];
+
 static struct dsp_clk_t dsp_clks[] = {
-	{NULL, "gpt5_fck", -1},
-	{NULL, "gpt5_ick", -1},
-	{NULL, "gpt6_fck", -1},
-	{NULL, "gpt6_ick", -1},
-	{NULL, "gpt7_fck", -1},
-	{NULL, "gpt7_ick", -1},
-	{NULL, "gpt8_fck", -1},
-	{NULL, "gpt8_ick", -1},
 	{NULL, "wdt_fck", 3},
 	{NULL, "wdt_ick", 3},
 	{NULL, "mcbsp_fck", 1},
@@ -81,7 +79,6 @@ static struct dsp_clk_t dsp_clks[] = {
 	{NULL, "mcbsp_ick", 5},
 	{NULL, "ssi_ssr_sst_fck", -1},
 	{NULL, "ssi_ick", -1},
-	{NULL, ""}
 };
 
 static s8 get_clk_type(u8 id)
@@ -132,11 +129,12 @@ bool dsp_clk_init(void)
 	static struct platform_device dspbridge_device;
 	struct clk *clk_handle;
 	int i = 0;
+	int num_clks = ARRAY_SIZE(dsp_clks);
 
 	dspbridge_device.dev.bus = &platform_bus_type;
 
 	/* Get the clock handles from base port and store locally */
-	while (i < DSP_CLK_NOT_DEFINED) {
+	while (i < num_clks) {
 		/* get the handle from BP */
 		dspbridge_device.id = dsp_clks[i].id;
 
@@ -169,6 +167,8 @@ dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 
 	switch (get_clk_type(clk_id)) {
 	case GPT_CLK:
+		timer[clk_id] = omap_dm_timer_request_specific(DMT_ID(clk_id));
+		break;
 	case MCBSP_CLK:
 	case WDT_CLK:
 	case SSI_CLK:
@@ -212,6 +212,8 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 
 	switch (get_clk_type(clk_id)) {
 	case GPT_CLK:
+		omap_dm_timer_free(timer[clk_id]);
+		break;
 	case MCBSP_CLK:
 	case WDT_CLK:
 	case SSI_CLK:
diff --git a/drivers/dsp/bridge/wmd/tiomap3430.c b/drivers/dsp/bridge/wmd/tiomap3430.c
index fedd521..f3b5bdb 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430.c
@@ -436,9 +436,6 @@ static dsp_status bridge_brd_start(struct wmd_dev_context *hDevContext,
 	u32 clk_cmd;
 	struct io_mgr *hio_mgr;
 	u32 ul_load_monitor_timer;
-	u32 ext_clk_id = 0;
-	u32 tmp_index;
-	u32 clk_id_index = MBX_PM_MAX_RESOURCES;
 
 	/* The device context contains all the mmu setup info from when the
 	 * last dsp base image was loaded. The first entry is always
@@ -573,25 +570,9 @@ static dsp_status bridge_brd_start(struct wmd_dev_context *hDevContext,
 
 	if (DSP_SUCCEEDED(status)) {
 		if (ul_load_monitor_timer != 0xFFFF) {
-			clk_cmd = (BPWR_DISABLE_CLOCK << MBX_PM_CLK_CMDSHIFT) |
-			    ul_load_monitor_timer;
-
-			dsp_peripheral_clk_ctrl(dev_context, &clk_cmd);
-
-			ext_clk_id = clk_cmd & MBX_PM_CLK_IDMASK;
-			for (tmp_index = 0; tmp_index < MBX_PM_MAX_RESOURCES;
-			     tmp_index++) {
-				if (ext_clk_id == bpwr_clkid[tmp_index]) {
-					clk_id_index = tmp_index;
-					break;
-				}
-			}
-
 			clk_cmd = (BPWR_ENABLE_CLOCK << MBX_PM_CLK_CMDSHIFT) |
 			    ul_load_monitor_timer;
-
 			dsp_peripheral_clk_ctrl(dev_context, &clk_cmd);
-
 		} else {
 			dev_dbg(bridge, "Not able to get the symbol for Load "
 				"Monitor Timer\n");
@@ -600,26 +581,9 @@ static dsp_status bridge_brd_start(struct wmd_dev_context *hDevContext,
 
 	if (DSP_SUCCEEDED(status)) {
 		if (ul_bios_gp_timer != 0xFFFF) {
-			clk_cmd = (BPWR_DISABLE_CLOCK << MBX_PM_CLK_CMDSHIFT) |
-			    ul_bios_gp_timer;
-
-			dsp_peripheral_clk_ctrl(dev_context, &clk_cmd);
-
-			ext_clk_id = clk_cmd & MBX_PM_CLK_IDMASK;
-
-			for (tmp_index = 0; tmp_index < MBX_PM_MAX_RESOURCES;
-			     tmp_index++) {
-				if (ext_clk_id == bpwr_clkid[tmp_index]) {
-					clk_id_index = tmp_index;
-					break;
-				}
-			}
-
 			clk_cmd = (BPWR_ENABLE_CLOCK << MBX_PM_CLK_CMDSHIFT) |
 			    ul_bios_gp_timer;
-
 			dsp_peripheral_clk_ctrl(dev_context, &clk_cmd);
-
 		} else {
 			dev_dbg(bridge,
 				"Not able to get the symbol for BIOS Timer\n");
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 12/19] DSPBRIDGE: use omap mcbsp to enable mcbsp clocks
  2010-04-08 23:16                     ` [PATCH 11/19] DSPBRIDGE: use dm timer framework for gpt timers Omar Ramirez Luna
@ 2010-04-08 23:16                       ` Omar Ramirez Luna
  2010-04-08 23:16                         ` [PATCH 13/19] DSPBRIDGE: remove wdt3 from dsp control Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:16 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

Use omap mcbsp to enable mcbsp clocks

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/services/clk.c |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index 46b4cab..ae46e47 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -19,6 +19,7 @@
 /*  ----------------------------------- Host OS */
 #include <dspbridge/host_os.h>
 #include <plat/dmtimer.h>
+#include <plat/mcbsp.h>
 
 /*  ----------------------------------- DSP/BIOS Bridge */
 #include <dspbridge/std.h>
@@ -50,12 +51,12 @@
 #define MCBSP_CLK	2
 #define SSI_CLK		3
 
-/*
- * Bridge specific DM Timer macro.
- * Bridge GPT id (0 - 3), DM Timer id (5 - 8)
- */
+/* Bridge GPT id (0 - 3), DM Timer id (5 - 8) */
 #define DMT_ID(id) ((id) + 5)
 
+/* Bridge MCBSP id (5 - 9), OMAP Mcbsp id (1 - 5) */
+#define MCBSP_ID(id) ((id) - 12)
+
 struct dsp_clk_t {
 	struct clk *clk_handle;
 	const char *clk_name;
@@ -67,16 +68,6 @@ static struct omap_dm_timer *timer[4];
 static struct dsp_clk_t dsp_clks[] = {
 	{NULL, "wdt_fck", 3},
 	{NULL, "wdt_ick", 3},
-	{NULL, "mcbsp_fck", 1},
-	{NULL, "mcbsp_ick", 1},
-	{NULL, "mcbsp_fck", 2},
-	{NULL, "mcbsp_ick", 2},
-	{NULL, "mcbsp_fck", 3},
-	{NULL, "mcbsp_ick", 3},
-	{NULL, "mcbsp_fck", 4},
-	{NULL, "mcbsp_ick", 4},
-	{NULL, "mcbsp_fck", 5},
-	{NULL, "mcbsp_ick", 5},
 	{NULL, "ssi_ssr_sst_fck", -1},
 	{NULL, "ssi_ick", -1},
 };
@@ -170,6 +161,9 @@ dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 		timer[clk_id] = omap_dm_timer_request_specific(DMT_ID(clk_id));
 		break;
 	case MCBSP_CLK:
+		omap_mcbsp_set_io_type(MCBSP_ID(clk_id), OMAP_MCBSP_POLL_IO);
+		omap_mcbsp_request(MCBSP_ID(clk_id));
+		break;
 	case WDT_CLK:
 	case SSI_CLK:
 		clk_handle = dsp_clks[clk_id].clk_handle;
@@ -215,6 +209,8 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 		omap_dm_timer_free(timer[clk_id]);
 		break;
 	case MCBSP_CLK:
+		omap_mcbsp_free(MCBSP_ID(clk_id));
+		break;
 	case WDT_CLK:
 	case SSI_CLK:
 		clk_handle = dsp_clks[clk_id].clk_handle;
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 13/19] DSPBRIDGE: remove wdt3 from dsp control
  2010-04-08 23:16                       ` [PATCH 12/19] DSPBRIDGE: use omap mcbsp to enable mcbsp clocks Omar Ramirez Luna
@ 2010-04-08 23:16                         ` Omar Ramirez Luna
  2010-04-08 23:16                           ` [PATCH 14/19] DSPBRIDGE: ssi clock fixes Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:16 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

WDT3 is used as a way to detect dsp hangs, as of now its
control is left to arm side driver, so, no requests should
be received by the dsp to enable/disable this clock.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/services/clk.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index ae46e47..a7d82bd 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -66,8 +66,6 @@ struct dsp_clk_t {
 static struct omap_dm_timer *timer[4];
 
 static struct dsp_clk_t dsp_clks[] = {
-	{NULL, "wdt_fck", 3},
-	{NULL, "wdt_ick", 3},
 	{NULL, "ssi_ssr_sst_fck", -1},
 	{NULL, "ssi_ick", -1},
 };
@@ -165,6 +163,8 @@ dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 		omap_mcbsp_request(MCBSP_ID(clk_id));
 		break;
 	case WDT_CLK:
+		dev_err(bridge, "ERROR: DSP requested to enable WDT3 clk\n");
+		break;
 	case SSI_CLK:
 		clk_handle = dsp_clks[clk_id].clk_handle;
 		if (clk_enable(clk_handle)) {
@@ -212,6 +212,8 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 		omap_mcbsp_free(MCBSP_ID(clk_id));
 		break;
 	case WDT_CLK:
+		dev_err(bridge, "ERROR: DSP requested to disable WDT3 clk\n");
+		break;
 	case SSI_CLK:
 		clk_handle = dsp_clks[clk_id].clk_handle;
 
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 14/19] DSPBRIDGE: ssi clock fixes
  2010-04-08 23:16                         ` [PATCH 13/19] DSPBRIDGE: remove wdt3 from dsp control Omar Ramirez Luna
@ 2010-04-08 23:16                           ` Omar Ramirez Luna
  2010-04-08 23:16                             ` [PATCH 15/19] DSPBRIDGE: use one call for both ick and fck clocks Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:16 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

- Fixing wrong name for ssi clock, split into ssr and sst for fck.
- Handle ick/ssr_fck/sst_fck clocks with one call to disable/enable.
- Since clk_init only initializes ssi clk changed its name and body.
- Remove ssi prepare from header file.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 arch/arm/plat-omap/include/dspbridge/clk.h |   31 +------
 drivers/dsp/bridge/rmgr/drv_interface.c    |    3 +
 drivers/dsp/bridge/services/clk.c          |  145 ++++++++++------------------
 drivers/dsp/bridge/services/services.c     |    9 +--
 4 files changed, 58 insertions(+), 130 deletions(-)

diff --git a/arch/arm/plat-omap/include/dspbridge/clk.h b/arch/arm/plat-omap/include/dspbridge/clk.h
index 44f0f0e..a51308e 100644
--- a/arch/arm/plat-omap/include/dspbridge/clk.h
+++ b/arch/arm/plat-omap/include/dspbridge/clk.h
@@ -46,33 +46,6 @@ enum dsp_clk_id {
 };
 
 /*
- *  ======== dsp_clk_exit ========
- *  Purpose:
- *      Discontinue usage of module; free resources when reference count
- *      reaches 0.
- *  Parameters:
- *  Returns:
- *  Requires:
- *      CLK initialized.
- *  Ensures:
- *      Resources used by module are freed when cRef reaches zero.
- */
-extern void dsp_clk_exit(void);
-
-/*
- *  ======== dsp_clk_init ========
- *  Purpose:
- *      Initializes private state of CLK module.
- *  Parameters:
- *  Returns:
- *      TRUE if initialized; FALSE if error occured.
- *  Requires:
- *  Ensures:
- *      CLK initialized.
- */
-extern bool dsp_clk_init(void);
-
-/*
  *  ======== dsp_clk_enable ========
  *  Purpose:
  *      Enables the clock requested.
@@ -98,7 +71,9 @@ extern dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id);
  */
 extern dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id);
 
-extern void ssi_clk_prepare(bool FLAG);
+void ssi_clk_exit(void);
+
+void ssi_clk_init(void);
 
 u32 omap_bridge_get_iva2_rate(void);
 
diff --git a/drivers/dsp/bridge/rmgr/drv_interface.c b/drivers/dsp/bridge/rmgr/drv_interface.c
index 435c266..49c6047 100644
--- a/drivers/dsp/bridge/rmgr/drv_interface.c
+++ b/drivers/dsp/bridge/rmgr/drv_interface.c
@@ -308,6 +308,8 @@ static int __devinit omap34_xx_bridge_probe(struct platform_device *pdev)
 		if (clk_enable(iva2_clk))
 			pr_err("%s: clk_get failed to get iva2_ck\n", __func__);
 
+		ssi_clk_init();
+
 #ifdef CONFIG_BRIDGE_DVFS
 		for (i = 0; i < 6; i++)
 			pdata->mpu_speed[i] = vdd1_rate_table_bridge[i].rate;
@@ -360,6 +362,7 @@ static int __devexit omap34_xx_bridge_remove(struct platform_device *pdev)
 		DBC_ASSERT(ret == true);
 	}
 
+	ssi_clk_exit();
 	clk_disable(iva2_clk);
 	clk_put(iva2_clk);
 
diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index a7d82bd..af3c5a2 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -57,19 +57,16 @@
 /* Bridge MCBSP id (5 - 9), OMAP Mcbsp id (1 - 5) */
 #define MCBSP_ID(id) ((id) - 12)
 
-struct dsp_clk_t {
-	struct clk *clk_handle;
-	const char *clk_name;
-	int id;
-};
-
 static struct omap_dm_timer *timer[4];
 
-static struct dsp_clk_t dsp_clks[] = {
-	{NULL, "ssi_ssr_sst_fck", -1},
-	{NULL, "ssi_ick", -1},
+struct dsp_ssi {
+	struct clk *sst_fck;
+	struct clk *ssr_fck;
+	struct clk *ick;
 };
 
+static struct dsp_ssi ssi;
+
 static s8 get_clk_type(u8 id)
 {
 	s8 type;
@@ -88,59 +85,53 @@ static s8 get_clk_type(u8 id)
 	return type;
 }
 
-/*
- *  ======== dsp_clk_exit ========
- *  Purpose:
- *      Cleanup CLK module.
- */
-void dsp_clk_exit(void)
+void ssi_clk_exit(void)
+{
+	clk_put(ssi.sst_fck);
+	clk_put(ssi.ssr_fck);
+	clk_put(ssi.ick);
+}
+
+void ssi_clk_init(void)
 {
-	int i = 0;
+	static struct platform_device dspbridge_device;
 
-	/* Relinquish the clock handles */
-	while (i < DSP_CLK_NOT_DEFINED) {
-		if (dsp_clks[i].clk_handle)
-			clk_put(dsp_clks[i].clk_handle);
+	dspbridge_device.dev.bus = &platform_bus_type;
 
-		dsp_clks[i].clk_handle = NULL;
-		i++;
-	}
+	ssi.sst_fck = clk_get(&dspbridge_device.dev, "ssi_sst_fck");
+	ssi.ssr_fck = clk_get(&dspbridge_device.dev, "ssi_ssr_fck");
+	ssi.ick = clk_get(&dspbridge_device.dev, "ssi_ick");
 
+	if (IS_ERR(ssi.sst_fck) || IS_ERR(ssi.ssr_fck) || IS_ERR(ssi.ick))
+		dev_err(bridge, "failed to get ssi: sst %p, ssr %p, ick %p\n",
+					ssi.sst_fck, ssi.ssr_fck, ssi.ick);
 }
 
-/*
- *  ======== dsp_clk_init ========
- *  Purpose:
- *      Initialize CLK module.
- */
-bool dsp_clk_init(void)
+static void ssi_clk_prepare(bool FLAG)
 {
-	static struct platform_device dspbridge_device;
-	struct clk *clk_handle;
-	int i = 0;
-	int num_clks = ARRAY_SIZE(dsp_clks);
+	void __iomem *ssi_base;
+	unsigned int value;
 
-	dspbridge_device.dev.bus = &platform_bus_type;
+	ssi_base = ioremap(L4_34XX_BASE + OMAP_SSI_OFFSET, OMAP_SSI_SIZE);
+	if (!ssi_base) {
+		pr_err("%s: error, SSI not configured\n", __func__);
+		return;
+	}
 
-	/* Get the clock handles from base port and store locally */
-	while (i < num_clks) {
-		/* get the handle from BP */
-		dspbridge_device.id = dsp_clks[i].id;
-
-		clk_handle = clk_get(&dspbridge_device.dev,
-				     dsp_clks[i].clk_name);
-
-		if (IS_ERR(clk_handle)) {
-			pr_err("%s: failed to get clk handle %s, dev id = %d\n",
-			       __func__, dsp_clks[i].clk_name,
-			       dsp_clks[i].id);
-			return false;
-		}
-		dsp_clks[i].clk_handle = clk_handle;
-		i++;
+	if (FLAG) {
+		/* Set Autoidle, SIDLEMode to smart idle, and MIDLEmode to
+		 * no idle
+		 */
+		value = SSI_AUTOIDLE | SSI_SIDLE_SMARTIDLE | SSI_MIDLE_NOIDLE;
+	} else {
+		/* Set Autoidle, SIDLEMode to forced idle, and MIDLEmode to
+		 * forced idle
+		 */
+		value = SSI_AUTOIDLE;
 	}
 
-	return true;
+	__raw_writel(value, ssi_base + OMAP_SSI_SYSCONFIG_OFFSET);
+	iounmap(ssi_base);
 }
 
 /*
@@ -152,7 +143,6 @@ bool dsp_clk_init(void)
 dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 {
 	dsp_status status = DSP_SOK;
-	struct clk *clk_handle;
 
 	switch (get_clk_type(clk_id)) {
 	case GPT_CLK:
@@ -166,13 +156,9 @@ dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 		dev_err(bridge, "ERROR: DSP requested to enable WDT3 clk\n");
 		break;
 	case SSI_CLK:
-		clk_handle = dsp_clks[clk_id].clk_handle;
-		if (clk_enable(clk_handle)) {
-			pr_err("dsp_clk_enable: failed to Enable CLK %s, "
-				"CLK dev id = %d\n", dsp_clks[clk_id].clk_name,
-				dsp_clks[clk_id].id);
-				status = DSP_EFAIL;
-		}
+		clk_enable(ssi.sst_fck);
+		clk_enable(ssi.ssr_fck);
+		clk_enable(ssi.ick);
 
 		/*
 		 * The SSI module need to configured not to have the Forced
@@ -181,8 +167,7 @@ dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 		 * the client in the DSP hang waiting for the SSI module to
 		 * be active after enabling the clocks
 		 */
-		if (clk_id == DSP_CLK_SSI_ICK)
-			ssi_clk_prepare(true);
+		ssi_clk_prepare(true);
 		break;
 	default:
 		dev_err(bridge, "Invalid clock id for enable\n");
@@ -200,7 +185,6 @@ dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 {
 	dsp_status status = DSP_SOK;
-	struct clk *clk_handle;
 
 	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
 
@@ -215,12 +199,10 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 		dev_err(bridge, "ERROR: DSP requested to disable WDT3 clk\n");
 		break;
 	case SSI_CLK:
-		clk_handle = dsp_clks[clk_id].clk_handle;
-
-		if (clk_id == DSP_CLK_SSI_ICK)
-			ssi_clk_prepare(false);
-
-		clk_disable(clk_handle);
+		ssi_clk_prepare(false);
+		clk_disable(ssi.sst_fck);
+		clk_disable(ssi.ssr_fck);
+		clk_disable(ssi.ick);
 		break;
 	default:
 		dev_err(bridge, "Invalid clock id for disable\n");
@@ -228,30 +210,3 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 
 	return status;
 }
-
-void ssi_clk_prepare(bool FLAG)
-{
-	void __iomem *ssi_base;
-	unsigned int value;
-
-	ssi_base = ioremap(L4_34XX_BASE + OMAP_SSI_OFFSET, OMAP_SSI_SIZE);
-	if (!ssi_base) {
-		pr_err("%s: error, SSI not configured\n", __func__);
-		return;
-	}
-
-	if (FLAG) {
-		/* Set Autoidle, SIDLEMode to smart idle, and MIDLEmode to
-		 * no idle
-		 */
-		value = SSI_AUTOIDLE | SSI_SIDLE_SMARTIDLE | SSI_MIDLE_NOIDLE;
-	} else {
-		/* Set Autoidle, SIDLEMode to forced idle, and MIDLEmode to
-		 * forced idle
-		 */
-		value = SSI_AUTOIDLE;
-	}
-
-	__raw_writel(value, ssi_base + OMAP_SSI_SYSCONFIG_OFFSET);
-	iounmap(ssi_base);
-}
diff --git a/drivers/dsp/bridge/services/services.c b/drivers/dsp/bridge/services/services.c
index bfce2f6..6c04df4 100644
--- a/drivers/dsp/bridge/services/services.c
+++ b/drivers/dsp/bridge/services/services.c
@@ -47,7 +47,6 @@ void services_exit(void)
 	/* Uninitialize all SERVICES modules here */
 	ntfy_exit();
 	sync_exit();
-	dsp_clk_exit();
 	reg_exit();
 	cfg_exit();
 	mem_exit();
@@ -62,17 +61,16 @@ bool services_init(void)
 {
 	bool ret = true;
 	bool fcfg, fmem;
-	bool freg, fsync, fclk, fntfy;
+	bool freg, fsync, fntfy;
 
 	/* Perform required initialization of SERVICES modules. */
 	fmem = services_mem_init();
 	freg = reg_init();
 	fcfg = cfg_init();
 	fsync = sync_init();
-	fclk = dsp_clk_init();
 	fntfy = ntfy_init();
 
-	ret = fcfg && fmem && freg && fsync && fclk;
+	ret = fcfg && fmem && freg && fsync;
 
 	if (!ret) {
 		if (fntfy)
@@ -81,9 +79,6 @@ bool services_init(void)
 		if (fsync)
 			sync_exit();
 
-		if (fclk)
-			dsp_clk_exit();
-
 		if (freg)
 			reg_exit();
 
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 15/19] DSPBRIDGE: use one call for both ick and fck clocks
  2010-04-08 23:16                           ` [PATCH 14/19] DSPBRIDGE: ssi clock fixes Omar Ramirez Luna
@ 2010-04-08 23:16                             ` Omar Ramirez Luna
  2010-04-08 23:16                               ` [PATCH 16/19] DSPBRIDGE: Move MCBSP_CLOCKS code to a common place Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:16 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

Instead of two calls to enable/disable for ick and fck use
one call to enable/disable both.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 arch/arm/plat-omap/include/dspbridge/clk.h |   33 ++++++++-----------------
 drivers/dsp/bridge/services/clk.c          |   12 ++++----
 drivers/dsp/bridge/wmd/_tiomap.h           |   25 +++++++++----------
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c    |   35 ++++++++--------------------
 4 files changed, 39 insertions(+), 66 deletions(-)

diff --git a/arch/arm/plat-omap/include/dspbridge/clk.h b/arch/arm/plat-omap/include/dspbridge/clk.h
index a51308e..da2549d 100644
--- a/arch/arm/plat-omap/include/dspbridge/clk.h
+++ b/arch/arm/plat-omap/include/dspbridge/clk.h
@@ -20,28 +20,17 @@
 #define _CLK_H
 
 enum dsp_clk_id {
-	DSP_CLK_GPT5_FCK,
-	DSP_CLK_GPT5_ICK,
-	DSP_CLK_GPT6_FCK,
-	DSP_CLK_GPT6_ICK,
-	DSP_CLK_GPT7_FCK,
-	DSP_CLK_GPT7_ICK,
-	DSP_CLK_GPT8_FCK,
-	DSP_CLK_GPT8_ICK,
-	DSP_CLK_WDT3_FCK,
-	DSP_CLK_WDT3_ICK,
-	DSP_CLK_MCBSP1_FCK,
-	DSP_CLK_MCBSP1_ICK,
-	DSP_CLK_MCBSP2_FCK,
-	DSP_CLK_MCBSP2_ICK,
-	DSP_CLK_MCBSP3_FCK,
-	DSP_CLK_MCBSP3_ICK,
-	DSP_CLK_MCBSP4_FCK,
-	DSP_CLK_MCBSP4_ICK,
-	DSP_CLK_MCBSP5_FCK,
-	DSP_CLK_MCBSP5_ICK,
-	DSP_CLK_SSI_FCK,
-	DSP_CLK_SSI_ICK,
+	DSP_CLK_GPT5,
+	DSP_CLK_GPT6,
+	DSP_CLK_GPT7,
+	DSP_CLK_GPT8,
+	DSP_CLK_WDT3,
+	DSP_CLK_MCBSP1,
+	DSP_CLK_MCBSP2,
+	DSP_CLK_MCBSP3,
+	DSP_CLK_MCBSP4,
+	DSP_CLK_MCBSP5,
+	DSP_CLK_SSI,
 	DSP_CLK_NOT_DEFINED
 };
 
diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index af3c5a2..aa706ce 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -54,8 +54,8 @@
 /* Bridge GPT id (0 - 3), DM Timer id (5 - 8) */
 #define DMT_ID(id) ((id) + 5)
 
-/* Bridge MCBSP id (5 - 9), OMAP Mcbsp id (1 - 5) */
-#define MCBSP_ID(id) ((id) - 12)
+/* Bridge MCBSP id (5 - 9), OMAP Mcbsp id (0 - 4) */
+#define MCBSP_ID(id) ((id) - 5)
 
 static struct omap_dm_timer *timer[4];
 
@@ -71,13 +71,13 @@ static s8 get_clk_type(u8 id)
 {
 	s8 type;
 
-	if (id <= DSP_CLK_GPT8_ICK)
+	if (id <= DSP_CLK_GPT8)
 		type = GPT_CLK;
-	else if (id <= DSP_CLK_WDT3_ICK)
+	else if (id == DSP_CLK_WDT3)
 		type = WDT_CLK;
-	else if (id <= DSP_CLK_MCBSP5_ICK)
+	else if (id <= DSP_CLK_MCBSP5)
 		type = MCBSP_CLK;
-	else if (id < DSP_CLK_SSI_ICK)
+	else if (id == DSP_CLK_SSI)
 		type = SSI_CLK;
 	else
 		type = -1;
diff --git a/drivers/dsp/bridge/wmd/_tiomap.h b/drivers/dsp/bridge/wmd/_tiomap.h
index 5e4e518..927fc6a 100644
--- a/drivers/dsp/bridge/wmd/_tiomap.h
+++ b/drivers/dsp/bridge/wmd/_tiomap.h
@@ -242,22 +242,21 @@ static const u32 bpwr_clkid[] = {
 
 struct bpwr_clk_t {
 	u32 clk_id;
-	enum dsp_clk_id fun_clk;
-	enum dsp_clk_id int_clk;
+	enum dsp_clk_id clk;
 };
 
 static const struct bpwr_clk_t bpwr_clks[] = {
-	{(u32) BPWR_GP_TIMER5, DSP_CLK_GPT5_FCK, DSP_CLK_GPT5_ICK},
-	{(u32) BPWR_GP_TIMER6, DSP_CLK_GPT6_FCK, DSP_CLK_GPT6_ICK},
-	{(u32) BPWR_GP_TIMER7, DSP_CLK_GPT7_FCK, DSP_CLK_GPT7_ICK},
-	{(u32) BPWR_GP_TIMER8, DSP_CLK_GPT8_FCK, DSP_CLK_GPT8_ICK},
-	{(u32) BPWR_WD_TIMER3, DSP_CLK_WDT3_FCK, DSP_CLK_WDT3_ICK},
-	{(u32) BPWR_MCBSP1, DSP_CLK_MCBSP1_FCK, DSP_CLK_MCBSP1_ICK},
-	{(u32) BPWR_MCBSP2, DSP_CLK_MCBSP2_FCK, DSP_CLK_MCBSP2_ICK},
-	{(u32) BPWR_MCBSP3, DSP_CLK_MCBSP3_FCK, DSP_CLK_MCBSP3_ICK},
-	{(u32) BPWR_MCBSP4, DSP_CLK_MCBSP4_FCK, DSP_CLK_MCBSP4_ICK},
-	{(u32) BPWR_MCBSP5, DSP_CLK_MCBSP5_FCK, DSP_CLK_MCBSP5_ICK},
-	{(u32) BPWR_SSI, DSP_CLK_SSI_FCK, DSP_CLK_SSI_ICK}
+	{(u32) BPWR_GP_TIMER5, DSP_CLK_GPT5},
+	{(u32) BPWR_GP_TIMER6, DSP_CLK_GPT6},
+	{(u32) BPWR_GP_TIMER7, DSP_CLK_GPT7},
+	{(u32) BPWR_GP_TIMER8, DSP_CLK_GPT8},
+	{(u32) BPWR_WD_TIMER3, DSP_CLK_WDT3},
+	{(u32) BPWR_MCBSP1, DSP_CLK_MCBSP1},
+	{(u32) BPWR_MCBSP2, DSP_CLK_MCBSP2},
+	{(u32) BPWR_MCBSP3, DSP_CLK_MCBSP3},
+	{(u32) BPWR_MCBSP4, DSP_CLK_MCBSP4},
+	{(u32) BPWR_MCBSP5, DSP_CLK_MCBSP5},
+	{(u32) BPWR_SSI, DSP_CLK_SSI}
 };
 
 /* Interrupt Register Offsets */
diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index 087a416..5c518d0 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -300,7 +300,6 @@ dsp_status dsp_peripheral_clk_ctrl(struct wmd_dev_context *dev_context,
 	u32 tmp_index;
 	u32 dsp_per_clks_before;
 	dsp_status status = DSP_SOK;
-	dsp_status status1 = DSP_SOK;
 	struct cfg_hostres resources;
 	u32 value;
 
@@ -334,9 +333,6 @@ dsp_status dsp_peripheral_clk_ctrl(struct wmd_dev_context *dev_context,
 	ext_clk_cmd = (ext_clk >> MBX_PM_CLK_CMDSHIFT) & MBX_PM_CLK_CMDMASK;
 	switch (ext_clk_cmd) {
 	case BPWR_DISABLE_CLOCK:
-		/* Call BP to disable the needed clock */
-		status1 = dsp_clk_disable(bpwr_clks[clk_id_index].int_clk);
-		status = dsp_clk_disable(bpwr_clks[clk_id_index].fun_clk);
 		if (bpwr_clkid[clk_id_index] == BPWR_MCBSP1) {
 			/* clear MCBSP1_CLKS, on McBSP1 OFF */
 			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
@@ -348,16 +344,16 @@ dsp_status dsp_peripheral_clk_ctrl(struct wmd_dev_context *dev_context,
 			value &= ~(1 << 6);
 			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
 		}
+		status = dsp_clk_disable(bpwr_clks[clk_id_index].clk);
 		dsp_clk_wakeup_event_ctrl(bpwr_clks[clk_id_index].clk_id,
 					  false);
-		if ((DSP_SUCCEEDED(status)) && (DSP_SUCCEEDED(status1))) {
+		if (DSP_SUCCEEDED(status)) {
 			(dev_context->dsp_per_clks) &=
 			    (~((u32) (1 << clk_id_index)));
 		}
 		break;
 	case BPWR_ENABLE_CLOCK:
-		status1 = dsp_clk_enable(bpwr_clks[clk_id_index].int_clk);
-		status = dsp_clk_enable(bpwr_clks[clk_id_index].fun_clk);
+		status = dsp_clk_enable(bpwr_clks[clk_id_index].clk);
 		if (bpwr_clkid[clk_id_index] == BPWR_MCBSP1) {
 			/* set MCBSP1_CLKS, on McBSP1 ON */
 			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
@@ -370,9 +366,8 @@ dsp_status dsp_peripheral_clk_ctrl(struct wmd_dev_context *dev_context,
 			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
 		}
 		dsp_clk_wakeup_event_ctrl(bpwr_clks[clk_id_index].clk_id, true);
-		if ((DSP_SUCCEEDED(status)) && (DSP_SUCCEEDED(status1))) {
+		if (DSP_SUCCEEDED(status))
 			(dev_context->dsp_per_clks) |= (1 << clk_id_index);
-		}
 		break;
 	default:
 		dev_dbg(bridge, "%s: Unsupported CMD\n", __func__);
@@ -476,9 +471,6 @@ dsp_status dsp_peripheral_clocks_disable(struct wmd_dev_context *dev_context,
 
 	for (clk_idx = 0; clk_idx < MBX_PM_MAX_RESOURCES; clk_idx++) {
 		if (((dev_context->dsp_per_clks) >> clk_idx) & 0x01) {
-			/* Disables the interface clock of the peripheral */
-			status =
-			    dsp_clk_disable(bpwr_clks[clk_idx].int_clk);
 			if (bpwr_clkid[clk_idx] == BPWR_MCBSP1) {
 				/* clear MCBSP1_CLKS, on McBSP1 OFF */
 				value = __raw_readl(resources.dw_sys_ctrl_base
@@ -495,9 +487,8 @@ dsp_status dsp_peripheral_clocks_disable(struct wmd_dev_context *dev_context,
 					     + 0x274);
 			}
 
-			/* Disables the functional clock of the periphearl */
-			status =
-			    dsp_clk_disable(bpwr_clks[clk_idx].fun_clk);
+			/* Disables the clocks of the peripheral */
+			status = dsp_clk_disable(bpwr_clks[clk_idx].clk);
 		}
 	}
 	return status;
@@ -511,7 +502,7 @@ dsp_status dsp_peripheral_clocks_enable(struct wmd_dev_context *dev_context,
 					IN void *pargs)
 {
 	u32 clk_idx;
-	dsp_status int_clk_status = DSP_EFAIL, fun_clk_status = DSP_EFAIL;
+	dsp_status clk_status = DSP_EFAIL;
 	struct cfg_hostres resources;
 	u32 value;
 
@@ -520,9 +511,8 @@ dsp_status dsp_peripheral_clocks_enable(struct wmd_dev_context *dev_context,
 
 	for (clk_idx = 0; clk_idx < MBX_PM_MAX_RESOURCES; clk_idx++) {
 		if (((dev_context->dsp_per_clks) >> clk_idx) & 0x01) {
-			/* Enable the interface clock of the peripheral */
-			int_clk_status =
-			    dsp_clk_enable(bpwr_clks[clk_idx].int_clk);
+			/* Enable the clocks of the peripheral */
+			clk_status = dsp_clk_enable(bpwr_clks[clk_idx].clk);
 			if (bpwr_clkid[clk_idx] == BPWR_MCBSP1) {
 				/* set MCBSP1_CLKS, on McBSP1 ON */
 				value = __raw_readl(resources.dw_sys_ctrl_base
@@ -538,14 +528,9 @@ dsp_status dsp_peripheral_clocks_enable(struct wmd_dev_context *dev_context,
 				__raw_writel(value, resources.dw_sys_ctrl_base
 					     + 0x274);
 			}
-			/* Enable the functional clock of the periphearl */
-			fun_clk_status =
-			    dsp_clk_enable(bpwr_clks[clk_idx].fun_clk);
 		}
 	}
-	if ((int_clk_status | fun_clk_status) != DSP_SOK)
-		return DSP_EFAIL;
-	return DSP_SOK;
+	return clk_status;
 }
 
 void dsp_clk_wakeup_event_ctrl(u32 ClkId, bool enable)
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 16/19] DSPBRIDGE: Move MCBSP_CLOCKS code to a common place
  2010-04-08 23:16                             ` [PATCH 15/19] DSPBRIDGE: use one call for both ick and fck clocks Omar Ramirez Luna
@ 2010-04-08 23:16                               ` Omar Ramirez Luna
  2010-04-08 23:16                                 ` [PATCH 17/19] DSPBRIDGE: Balance the number of enable/disable Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:16 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

Given that:
"Bridge should enable McBSP_CLKS (using T2 clock) so that DPLL4
 can be gated. Once McBSP2 clock is released, it should disable
 McBSP_CLKS as it prevents PER and CORE domain transitions when
 OFF is set to target power state."

It seems this code was duplicated, now it has been moved to be
called only when dsp is requesting a MCBSP clock.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/services/clk.c       |   40 +++++++++++++++++
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |   73 -------------------------------
 2 files changed, 40 insertions(+), 73 deletions(-)

diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index aa706ce..711bae4 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -25,6 +25,8 @@
 #include <dspbridge/std.h>
 #include <dspbridge/dbdefs.h>
 #include <dspbridge/errbase.h>
+#include <dspbridge/cfg.h>
+#include <dspbridge/drv.h>
 
 /*  ----------------------------------- Trace & Debug */
 #include <dspbridge/dbc.h>
@@ -134,6 +136,42 @@ static void ssi_clk_prepare(bool FLAG)
 	iounmap(ssi_base);
 }
 
+static void mcbsp_clk_prepare(bool flag, u8 id)
+{
+	struct cfg_hostres resources;
+	u32 value;
+
+	cfg_get_host_resources((struct cfg_devnode *)
+			       drv_get_first_dev_extension(), &resources);
+
+	if (flag) {
+		if (id == DSP_CLK_MCBSP1) {
+			/* set MCBSP1_CLKS, on McBSP1 ON */
+			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
+			value |= 1 << 2;
+			__raw_writel(value, resources.dw_sys_ctrl_base
+					     + 0x274);
+		} else if (id == DSP_CLK_MCBSP2) {
+			/* set MCBSP2_CLKS, on McBSP2 ON */
+			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
+			value |= 1 << 6;
+			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
+		}
+	} else {
+		if (id == DSP_CLK_MCBSP1) {
+			/* clear MCBSP1_CLKS, on McBSP1 OFF */
+			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
+			value &= ~(1 << 2);
+			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
+		} else if (id == DSP_CLK_MCBSP2) {
+			/* clear MCBSP2_CLKS, on McBSP2 OFF */
+			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
+			value &= ~(1 << 6);
+			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
+		}
+	}
+}
+
 /*
  *  ======== dsp_clk_enable ========
  *  Purpose:
@@ -149,6 +187,7 @@ dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 		timer[clk_id] = omap_dm_timer_request_specific(DMT_ID(clk_id));
 		break;
 	case MCBSP_CLK:
+		mcbsp_clk_prepare(true, clk_id);
 		omap_mcbsp_set_io_type(MCBSP_ID(clk_id), OMAP_MCBSP_POLL_IO);
 		omap_mcbsp_request(MCBSP_ID(clk_id));
 		break;
@@ -193,6 +232,7 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 		omap_dm_timer_free(timer[clk_id]);
 		break;
 	case MCBSP_CLK:
+		mcbsp_clk_prepare(false, clk_id);
 		omap_mcbsp_free(MCBSP_ID(clk_id));
 		break;
 	case WDT_CLK:
diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index 5c518d0..a6e8e57 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -300,20 +300,11 @@ dsp_status dsp_peripheral_clk_ctrl(struct wmd_dev_context *dev_context,
 	u32 tmp_index;
 	u32 dsp_per_clks_before;
 	dsp_status status = DSP_SOK;
-	struct cfg_hostres resources;
-	u32 value;
 
 	dsp_per_clks_before = dev_context->dsp_per_clks;
 
 	ext_clk = (u32) *((u32 *) pargs);
 
-	status = cfg_get_host_resources((struct cfg_devnode *)
-					drv_get_first_dev_extension(),
-					&resources);
-
-	if (DSP_FAILED(status))
-		return DSP_EFAIL;
-
 	ext_clk_id = ext_clk & MBX_PM_CLK_IDMASK;
 
 	/* process the power message -- TODO, keep it in a separate function */
@@ -333,17 +324,6 @@ dsp_status dsp_peripheral_clk_ctrl(struct wmd_dev_context *dev_context,
 	ext_clk_cmd = (ext_clk >> MBX_PM_CLK_CMDSHIFT) & MBX_PM_CLK_CMDMASK;
 	switch (ext_clk_cmd) {
 	case BPWR_DISABLE_CLOCK:
-		if (bpwr_clkid[clk_id_index] == BPWR_MCBSP1) {
-			/* clear MCBSP1_CLKS, on McBSP1 OFF */
-			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
-			value &= ~(1 << 2);
-			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
-		} else if (bpwr_clkid[clk_id_index] == BPWR_MCBSP2) {
-			/* clear MCBSP2_CLKS, on McBSP2 OFF */
-			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
-			value &= ~(1 << 6);
-			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
-		}
 		status = dsp_clk_disable(bpwr_clks[clk_id_index].clk);
 		dsp_clk_wakeup_event_ctrl(bpwr_clks[clk_id_index].clk_id,
 					  false);
@@ -354,17 +334,6 @@ dsp_status dsp_peripheral_clk_ctrl(struct wmd_dev_context *dev_context,
 		break;
 	case BPWR_ENABLE_CLOCK:
 		status = dsp_clk_enable(bpwr_clks[clk_id_index].clk);
-		if (bpwr_clkid[clk_id_index] == BPWR_MCBSP1) {
-			/* set MCBSP1_CLKS, on McBSP1 ON */
-			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
-			value |= 1 << 2;
-			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
-		} else if (bpwr_clkid[clk_id_index] == BPWR_MCBSP2) {
-			/* set MCBSP2_CLKS, on McBSP2 ON */
-			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
-			value |= 1 << 6;
-			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
-		}
 		dsp_clk_wakeup_event_ctrl(bpwr_clks[clk_id_index].clk_id, true);
 		if (DSP_SUCCEEDED(status))
 			(dev_context->dsp_per_clks) |= (1 << clk_id_index);
@@ -462,31 +431,9 @@ dsp_status dsp_peripheral_clocks_disable(struct wmd_dev_context *dev_context,
 {
 	u32 clk_idx;
 	dsp_status status = DSP_SOK;
-	struct cfg_hostres resources;
-	u32 value;
-
-	status = cfg_get_host_resources((struct cfg_devnode *)
-					drv_get_first_dev_extension(),
-					&resources);
 
 	for (clk_idx = 0; clk_idx < MBX_PM_MAX_RESOURCES; clk_idx++) {
 		if (((dev_context->dsp_per_clks) >> clk_idx) & 0x01) {
-			if (bpwr_clkid[clk_idx] == BPWR_MCBSP1) {
-				/* clear MCBSP1_CLKS, on McBSP1 OFF */
-				value = __raw_readl(resources.dw_sys_ctrl_base
-						    + 0x274);
-				value &= ~(1 << 2);
-				__raw_writel(value, resources.dw_sys_ctrl_base
-					     + 0x274);
-			} else if (bpwr_clkid[clk_idx] == BPWR_MCBSP2) {
-				/* clear MCBSP2_CLKS, on McBSP2 OFF */
-				value = __raw_readl(resources.dw_sys_ctrl_base
-						    + 0x274);
-				value &= ~(1 << 6);
-				__raw_writel(value, resources.dw_sys_ctrl_base
-					     + 0x274);
-			}
-
 			/* Disables the clocks of the peripheral */
 			status = dsp_clk_disable(bpwr_clks[clk_idx].clk);
 		}
@@ -503,31 +450,11 @@ dsp_status dsp_peripheral_clocks_enable(struct wmd_dev_context *dev_context,
 {
 	u32 clk_idx;
 	dsp_status clk_status = DSP_EFAIL;
-	struct cfg_hostres resources;
-	u32 value;
-
-	cfg_get_host_resources((struct cfg_devnode *)
-			       drv_get_first_dev_extension(), &resources);
 
 	for (clk_idx = 0; clk_idx < MBX_PM_MAX_RESOURCES; clk_idx++) {
 		if (((dev_context->dsp_per_clks) >> clk_idx) & 0x01) {
 			/* Enable the clocks of the peripheral */
 			clk_status = dsp_clk_enable(bpwr_clks[clk_idx].clk);
-			if (bpwr_clkid[clk_idx] == BPWR_MCBSP1) {
-				/* set MCBSP1_CLKS, on McBSP1 ON */
-				value = __raw_readl(resources.dw_sys_ctrl_base
-						    + 0x274);
-				value |= 1 << 2;
-				__raw_writel(value, resources.dw_sys_ctrl_base
-					     + 0x274);
-			} else if (bpwr_clkid[clk_idx] == BPWR_MCBSP2) {
-				/* set MCBSP2_CLKS, on McBSP2 ON */
-				value = __raw_readl(resources.dw_sys_ctrl_base
-						    + 0x274);
-				value |= 1 << 6;
-				__raw_writel(value, resources.dw_sys_ctrl_base
-					     + 0x274);
-			}
 		}
 	}
 	return clk_status;
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 17/19] DSPBRIDGE: Balance the number of enable/disable
  2010-04-08 23:16                               ` [PATCH 16/19] DSPBRIDGE: Move MCBSP_CLOCKS code to a common place Omar Ramirez Luna
@ 2010-04-08 23:16                                 ` Omar Ramirez Luna
  2010-04-08 23:16                                   ` [PATCH 18/19] DSPBRIDGE: move clk to dsp-clock Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:16 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

This patch ensure a balanced number of enable/disable
calls is made.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/services/clk.c |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
index 711bae4..8f539fd 100644
--- a/drivers/dsp/bridge/services/clk.c
+++ b/drivers/dsp/bridge/services/clk.c
@@ -69,6 +69,23 @@ struct dsp_ssi {
 
 static struct dsp_ssi ssi;
 
+static u32 dsp_clocks;
+
+static inline u32 is_dsp_clk_active(u32 clk, u8 id)
+{
+	return clk & (1 << id);
+}
+
+static inline void set_dsp_clk_active(u32 *clk, u8 id)
+{
+	*clk |= (1 << id);
+}
+
+static inline void set_dsp_clk_inactive(u32 *clk, u8 id)
+{
+	*clk &= ~(1 << id);
+}
+
 static s8 get_clk_type(u8 id)
 {
 	s8 type;
@@ -182,6 +199,11 @@ dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 {
 	dsp_status status = DSP_SOK;
 
+	if (is_dsp_clk_active(dsp_clocks, clk_id)) {
+		dev_err(bridge, "WARN: clock id %d already enabled\n", clk_id);
+		goto out;
+	}
+
 	switch (get_clk_type(clk_id)) {
 	case GPT_CLK:
 		timer[clk_id] = omap_dm_timer_request_specific(DMT_ID(clk_id));
@@ -210,8 +232,13 @@ dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
 		break;
 	default:
 		dev_err(bridge, "Invalid clock id for enable\n");
+		status = DSP_EFAIL;
 	}
 
+	if (DSP_SUCCEEDED(status))
+		set_dsp_clk_active(&dsp_clocks, clk_id);
+
+out:
 	return status;
 }
 
@@ -227,6 +254,11 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 
 	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
 
+	if (!is_dsp_clk_active(dsp_clocks, clk_id)) {
+		dev_err(bridge, "ERR: clock id %d already disabled\n", clk_id);
+		goto out;
+	}
+
 	switch (get_clk_type(clk_id)) {
 	case GPT_CLK:
 		omap_dm_timer_free(timer[clk_id]);
@@ -246,7 +278,12 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 		break;
 	default:
 		dev_err(bridge, "Invalid clock id for disable\n");
+		status = DSP_EFAIL;
 	}
 
+	if (DSP_SUCCEEDED(status))
+		set_dsp_clk_inactive(&dsp_clocks, clk_id);
+
+out:
 	return status;
 }
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 18/19] DSPBRIDGE: move clk to dsp-clock
  2010-04-08 23:16                                 ` [PATCH 17/19] DSPBRIDGE: Balance the number of enable/disable Omar Ramirez Luna
@ 2010-04-08 23:16                                   ` Omar Ramirez Luna
  2010-04-08 23:16                                     ` [PATCH 19/19] DSPBRIDGE: reorganize the code to handle peripheral clocks Omar Ramirez Luna
  0 siblings, 1 reply; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:16 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna

Rename file and move it outside services layer.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/dsp/bridge/Makefile        |    4 +-
 drivers/dsp/bridge/services/clk.c  |  289 ------------------------------------
 drivers/dsp/bridge/wmd/dsp-clock.c |  289 ++++++++++++++++++++++++++++++++++++
 3 files changed, 291 insertions(+), 291 deletions(-)
 delete mode 100644 drivers/dsp/bridge/services/clk.c
 create mode 100644 drivers/dsp/bridge/wmd/dsp-clock.c

diff --git a/drivers/dsp/bridge/Makefile b/drivers/dsp/bridge/Makefile
index 2b4f92c..1dde54f 100644
--- a/drivers/dsp/bridge/Makefile
+++ b/drivers/dsp/bridge/Makefile
@@ -2,12 +2,12 @@ obj-$(CONFIG_MPU_BRIDGE)	+= bridgedriver.o
 
 libgen = gen/gb.o gen/gs.o gen/gh.o gen/uuidutil.o
 libservices = services/mem.o services/sync.o \
-		services/clk.o services/cfg.o services/reg.o \
+		services/cfg.o services/reg.o \
                services/regsup.o services/ntfy.o \
 		services/services.o
 libwmd = wmd/chnl_sm.o wmd/msg_sm.o wmd/io_sm.o wmd/tiomap3430.o \
 		wmd/tiomap3430_pwr.o wmd/tiomap_io.o \
-		wmd/mmu_fault.o wmd/ue_deh.o
+		wmd/mmu_fault.o wmd/ue_deh.o wmd/dsp-clock.o
 libpmgr = pmgr/chnl.o pmgr/io.o pmgr/msg.o pmgr/cod.o pmgr/dev.o pmgr/wcd.o \
 		pmgr/dmm.o pmgr/cmm.o pmgr/dbll.o
 librmgr = rmgr/dbdcd.o rmgr/disp.o rmgr/drv.o rmgr/mgr.o rmgr/node.o \
diff --git a/drivers/dsp/bridge/services/clk.c b/drivers/dsp/bridge/services/clk.c
deleted file mode 100644
index 8f539fd..0000000
--- a/drivers/dsp/bridge/services/clk.c
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * clk.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Clock and Timer services.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-#include <plat/dmtimer.h>
-#include <plat/mcbsp.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/std.h>
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/errbase.h>
-#include <dspbridge/cfg.h>
-#include <dspbridge/drv.h>
-
-/*  ----------------------------------- Trace & Debug */
-#include <dspbridge/dbc.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/mem.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/clk.h>
-
-/*  ----------------------------------- Defines, Data Structures, Typedefs */
-
-#define OMAP_SSI_OFFSET			0x58000
-#define OMAP_SSI_SIZE			0x1000
-#define OMAP_SSI_SYSCONFIG_OFFSET	0x10
-
-#define SSI_AUTOIDLE			(1 << 0)
-#define SSI_SIDLE_SMARTIDLE		(2 << 3)
-#define SSI_MIDLE_NOIDLE		(1 << 12)
-
-/* Clk types requested by the dsp */
-#define GPT_CLK		0
-#define WDT_CLK		1
-#define MCBSP_CLK	2
-#define SSI_CLK		3
-
-/* Bridge GPT id (0 - 3), DM Timer id (5 - 8) */
-#define DMT_ID(id) ((id) + 5)
-
-/* Bridge MCBSP id (5 - 9), OMAP Mcbsp id (0 - 4) */
-#define MCBSP_ID(id) ((id) - 5)
-
-static struct omap_dm_timer *timer[4];
-
-struct dsp_ssi {
-	struct clk *sst_fck;
-	struct clk *ssr_fck;
-	struct clk *ick;
-};
-
-static struct dsp_ssi ssi;
-
-static u32 dsp_clocks;
-
-static inline u32 is_dsp_clk_active(u32 clk, u8 id)
-{
-	return clk & (1 << id);
-}
-
-static inline void set_dsp_clk_active(u32 *clk, u8 id)
-{
-	*clk |= (1 << id);
-}
-
-static inline void set_dsp_clk_inactive(u32 *clk, u8 id)
-{
-	*clk &= ~(1 << id);
-}
-
-static s8 get_clk_type(u8 id)
-{
-	s8 type;
-
-	if (id <= DSP_CLK_GPT8)
-		type = GPT_CLK;
-	else if (id == DSP_CLK_WDT3)
-		type = WDT_CLK;
-	else if (id <= DSP_CLK_MCBSP5)
-		type = MCBSP_CLK;
-	else if (id == DSP_CLK_SSI)
-		type = SSI_CLK;
-	else
-		type = -1;
-
-	return type;
-}
-
-void ssi_clk_exit(void)
-{
-	clk_put(ssi.sst_fck);
-	clk_put(ssi.ssr_fck);
-	clk_put(ssi.ick);
-}
-
-void ssi_clk_init(void)
-{
-	static struct platform_device dspbridge_device;
-
-	dspbridge_device.dev.bus = &platform_bus_type;
-
-	ssi.sst_fck = clk_get(&dspbridge_device.dev, "ssi_sst_fck");
-	ssi.ssr_fck = clk_get(&dspbridge_device.dev, "ssi_ssr_fck");
-	ssi.ick = clk_get(&dspbridge_device.dev, "ssi_ick");
-
-	if (IS_ERR(ssi.sst_fck) || IS_ERR(ssi.ssr_fck) || IS_ERR(ssi.ick))
-		dev_err(bridge, "failed to get ssi: sst %p, ssr %p, ick %p\n",
-					ssi.sst_fck, ssi.ssr_fck, ssi.ick);
-}
-
-static void ssi_clk_prepare(bool FLAG)
-{
-	void __iomem *ssi_base;
-	unsigned int value;
-
-	ssi_base = ioremap(L4_34XX_BASE + OMAP_SSI_OFFSET, OMAP_SSI_SIZE);
-	if (!ssi_base) {
-		pr_err("%s: error, SSI not configured\n", __func__);
-		return;
-	}
-
-	if (FLAG) {
-		/* Set Autoidle, SIDLEMode to smart idle, and MIDLEmode to
-		 * no idle
-		 */
-		value = SSI_AUTOIDLE | SSI_SIDLE_SMARTIDLE | SSI_MIDLE_NOIDLE;
-	} else {
-		/* Set Autoidle, SIDLEMode to forced idle, and MIDLEmode to
-		 * forced idle
-		 */
-		value = SSI_AUTOIDLE;
-	}
-
-	__raw_writel(value, ssi_base + OMAP_SSI_SYSCONFIG_OFFSET);
-	iounmap(ssi_base);
-}
-
-static void mcbsp_clk_prepare(bool flag, u8 id)
-{
-	struct cfg_hostres resources;
-	u32 value;
-
-	cfg_get_host_resources((struct cfg_devnode *)
-			       drv_get_first_dev_extension(), &resources);
-
-	if (flag) {
-		if (id == DSP_CLK_MCBSP1) {
-			/* set MCBSP1_CLKS, on McBSP1 ON */
-			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
-			value |= 1 << 2;
-			__raw_writel(value, resources.dw_sys_ctrl_base
-					     + 0x274);
-		} else if (id == DSP_CLK_MCBSP2) {
-			/* set MCBSP2_CLKS, on McBSP2 ON */
-			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
-			value |= 1 << 6;
-			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
-		}
-	} else {
-		if (id == DSP_CLK_MCBSP1) {
-			/* clear MCBSP1_CLKS, on McBSP1 OFF */
-			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
-			value &= ~(1 << 2);
-			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
-		} else if (id == DSP_CLK_MCBSP2) {
-			/* clear MCBSP2_CLKS, on McBSP2 OFF */
-			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
-			value &= ~(1 << 6);
-			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
-		}
-	}
-}
-
-/*
- *  ======== dsp_clk_enable ========
- *  Purpose:
- *      Enable Clock .
- *
- */
-dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
-{
-	dsp_status status = DSP_SOK;
-
-	if (is_dsp_clk_active(dsp_clocks, clk_id)) {
-		dev_err(bridge, "WARN: clock id %d already enabled\n", clk_id);
-		goto out;
-	}
-
-	switch (get_clk_type(clk_id)) {
-	case GPT_CLK:
-		timer[clk_id] = omap_dm_timer_request_specific(DMT_ID(clk_id));
-		break;
-	case MCBSP_CLK:
-		mcbsp_clk_prepare(true, clk_id);
-		omap_mcbsp_set_io_type(MCBSP_ID(clk_id), OMAP_MCBSP_POLL_IO);
-		omap_mcbsp_request(MCBSP_ID(clk_id));
-		break;
-	case WDT_CLK:
-		dev_err(bridge, "ERROR: DSP requested to enable WDT3 clk\n");
-		break;
-	case SSI_CLK:
-		clk_enable(ssi.sst_fck);
-		clk_enable(ssi.ssr_fck);
-		clk_enable(ssi.ick);
-
-		/*
-		 * The SSI module need to configured not to have the Forced
-		 * idle for master interface. If it is set to forced idle,
-		 * the SSI module is transitioning to standby thereby causing
-		 * the client in the DSP hang waiting for the SSI module to
-		 * be active after enabling the clocks
-		 */
-		ssi_clk_prepare(true);
-		break;
-	default:
-		dev_err(bridge, "Invalid clock id for enable\n");
-		status = DSP_EFAIL;
-	}
-
-	if (DSP_SUCCEEDED(status))
-		set_dsp_clk_active(&dsp_clocks, clk_id);
-
-out:
-	return status;
-}
-
-/*
- *  ======== dsp_clk_disable ========
- *  Purpose:
- *      Disable the clock.
- *
- */
-dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
-{
-	dsp_status status = DSP_SOK;
-
-	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
-
-	if (!is_dsp_clk_active(dsp_clocks, clk_id)) {
-		dev_err(bridge, "ERR: clock id %d already disabled\n", clk_id);
-		goto out;
-	}
-
-	switch (get_clk_type(clk_id)) {
-	case GPT_CLK:
-		omap_dm_timer_free(timer[clk_id]);
-		break;
-	case MCBSP_CLK:
-		mcbsp_clk_prepare(false, clk_id);
-		omap_mcbsp_free(MCBSP_ID(clk_id));
-		break;
-	case WDT_CLK:
-		dev_err(bridge, "ERROR: DSP requested to disable WDT3 clk\n");
-		break;
-	case SSI_CLK:
-		ssi_clk_prepare(false);
-		clk_disable(ssi.sst_fck);
-		clk_disable(ssi.ssr_fck);
-		clk_disable(ssi.ick);
-		break;
-	default:
-		dev_err(bridge, "Invalid clock id for disable\n");
-		status = DSP_EFAIL;
-	}
-
-	if (DSP_SUCCEEDED(status))
-		set_dsp_clk_inactive(&dsp_clocks, clk_id);
-
-out:
-	return status;
-}
diff --git a/drivers/dsp/bridge/wmd/dsp-clock.c b/drivers/dsp/bridge/wmd/dsp-clock.c
new file mode 100644
index 0000000..8f539fd
--- /dev/null
+++ b/drivers/dsp/bridge/wmd/dsp-clock.c
@@ -0,0 +1,289 @@
+/*
+ * clk.c
+ *
+ * DSP-BIOS Bridge driver support functions for TI OMAP processors.
+ *
+ * Clock and Timer services.
+ *
+ * Copyright (C) 2005-2006 Texas Instruments, Inc.
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*  ----------------------------------- Host OS */
+#include <dspbridge/host_os.h>
+#include <plat/dmtimer.h>
+#include <plat/mcbsp.h>
+
+/*  ----------------------------------- DSP/BIOS Bridge */
+#include <dspbridge/std.h>
+#include <dspbridge/dbdefs.h>
+#include <dspbridge/errbase.h>
+#include <dspbridge/cfg.h>
+#include <dspbridge/drv.h>
+
+/*  ----------------------------------- Trace & Debug */
+#include <dspbridge/dbc.h>
+
+/*  ----------------------------------- OS Adaptation Layer */
+#include <dspbridge/mem.h>
+
+/*  ----------------------------------- This */
+#include <dspbridge/clk.h>
+
+/*  ----------------------------------- Defines, Data Structures, Typedefs */
+
+#define OMAP_SSI_OFFSET			0x58000
+#define OMAP_SSI_SIZE			0x1000
+#define OMAP_SSI_SYSCONFIG_OFFSET	0x10
+
+#define SSI_AUTOIDLE			(1 << 0)
+#define SSI_SIDLE_SMARTIDLE		(2 << 3)
+#define SSI_MIDLE_NOIDLE		(1 << 12)
+
+/* Clk types requested by the dsp */
+#define GPT_CLK		0
+#define WDT_CLK		1
+#define MCBSP_CLK	2
+#define SSI_CLK		3
+
+/* Bridge GPT id (0 - 3), DM Timer id (5 - 8) */
+#define DMT_ID(id) ((id) + 5)
+
+/* Bridge MCBSP id (5 - 9), OMAP Mcbsp id (0 - 4) */
+#define MCBSP_ID(id) ((id) - 5)
+
+static struct omap_dm_timer *timer[4];
+
+struct dsp_ssi {
+	struct clk *sst_fck;
+	struct clk *ssr_fck;
+	struct clk *ick;
+};
+
+static struct dsp_ssi ssi;
+
+static u32 dsp_clocks;
+
+static inline u32 is_dsp_clk_active(u32 clk, u8 id)
+{
+	return clk & (1 << id);
+}
+
+static inline void set_dsp_clk_active(u32 *clk, u8 id)
+{
+	*clk |= (1 << id);
+}
+
+static inline void set_dsp_clk_inactive(u32 *clk, u8 id)
+{
+	*clk &= ~(1 << id);
+}
+
+static s8 get_clk_type(u8 id)
+{
+	s8 type;
+
+	if (id <= DSP_CLK_GPT8)
+		type = GPT_CLK;
+	else if (id == DSP_CLK_WDT3)
+		type = WDT_CLK;
+	else if (id <= DSP_CLK_MCBSP5)
+		type = MCBSP_CLK;
+	else if (id == DSP_CLK_SSI)
+		type = SSI_CLK;
+	else
+		type = -1;
+
+	return type;
+}
+
+void ssi_clk_exit(void)
+{
+	clk_put(ssi.sst_fck);
+	clk_put(ssi.ssr_fck);
+	clk_put(ssi.ick);
+}
+
+void ssi_clk_init(void)
+{
+	static struct platform_device dspbridge_device;
+
+	dspbridge_device.dev.bus = &platform_bus_type;
+
+	ssi.sst_fck = clk_get(&dspbridge_device.dev, "ssi_sst_fck");
+	ssi.ssr_fck = clk_get(&dspbridge_device.dev, "ssi_ssr_fck");
+	ssi.ick = clk_get(&dspbridge_device.dev, "ssi_ick");
+
+	if (IS_ERR(ssi.sst_fck) || IS_ERR(ssi.ssr_fck) || IS_ERR(ssi.ick))
+		dev_err(bridge, "failed to get ssi: sst %p, ssr %p, ick %p\n",
+					ssi.sst_fck, ssi.ssr_fck, ssi.ick);
+}
+
+static void ssi_clk_prepare(bool FLAG)
+{
+	void __iomem *ssi_base;
+	unsigned int value;
+
+	ssi_base = ioremap(L4_34XX_BASE + OMAP_SSI_OFFSET, OMAP_SSI_SIZE);
+	if (!ssi_base) {
+		pr_err("%s: error, SSI not configured\n", __func__);
+		return;
+	}
+
+	if (FLAG) {
+		/* Set Autoidle, SIDLEMode to smart idle, and MIDLEmode to
+		 * no idle
+		 */
+		value = SSI_AUTOIDLE | SSI_SIDLE_SMARTIDLE | SSI_MIDLE_NOIDLE;
+	} else {
+		/* Set Autoidle, SIDLEMode to forced idle, and MIDLEmode to
+		 * forced idle
+		 */
+		value = SSI_AUTOIDLE;
+	}
+
+	__raw_writel(value, ssi_base + OMAP_SSI_SYSCONFIG_OFFSET);
+	iounmap(ssi_base);
+}
+
+static void mcbsp_clk_prepare(bool flag, u8 id)
+{
+	struct cfg_hostres resources;
+	u32 value;
+
+	cfg_get_host_resources((struct cfg_devnode *)
+			       drv_get_first_dev_extension(), &resources);
+
+	if (flag) {
+		if (id == DSP_CLK_MCBSP1) {
+			/* set MCBSP1_CLKS, on McBSP1 ON */
+			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
+			value |= 1 << 2;
+			__raw_writel(value, resources.dw_sys_ctrl_base
+					     + 0x274);
+		} else if (id == DSP_CLK_MCBSP2) {
+			/* set MCBSP2_CLKS, on McBSP2 ON */
+			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
+			value |= 1 << 6;
+			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
+		}
+	} else {
+		if (id == DSP_CLK_MCBSP1) {
+			/* clear MCBSP1_CLKS, on McBSP1 OFF */
+			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
+			value &= ~(1 << 2);
+			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
+		} else if (id == DSP_CLK_MCBSP2) {
+			/* clear MCBSP2_CLKS, on McBSP2 OFF */
+			value = __raw_readl(resources.dw_sys_ctrl_base + 0x274);
+			value &= ~(1 << 6);
+			__raw_writel(value, resources.dw_sys_ctrl_base + 0x274);
+		}
+	}
+}
+
+/*
+ *  ======== dsp_clk_enable ========
+ *  Purpose:
+ *      Enable Clock .
+ *
+ */
+dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id)
+{
+	dsp_status status = DSP_SOK;
+
+	if (is_dsp_clk_active(dsp_clocks, clk_id)) {
+		dev_err(bridge, "WARN: clock id %d already enabled\n", clk_id);
+		goto out;
+	}
+
+	switch (get_clk_type(clk_id)) {
+	case GPT_CLK:
+		timer[clk_id] = omap_dm_timer_request_specific(DMT_ID(clk_id));
+		break;
+	case MCBSP_CLK:
+		mcbsp_clk_prepare(true, clk_id);
+		omap_mcbsp_set_io_type(MCBSP_ID(clk_id), OMAP_MCBSP_POLL_IO);
+		omap_mcbsp_request(MCBSP_ID(clk_id));
+		break;
+	case WDT_CLK:
+		dev_err(bridge, "ERROR: DSP requested to enable WDT3 clk\n");
+		break;
+	case SSI_CLK:
+		clk_enable(ssi.sst_fck);
+		clk_enable(ssi.ssr_fck);
+		clk_enable(ssi.ick);
+
+		/*
+		 * The SSI module need to configured not to have the Forced
+		 * idle for master interface. If it is set to forced idle,
+		 * the SSI module is transitioning to standby thereby causing
+		 * the client in the DSP hang waiting for the SSI module to
+		 * be active after enabling the clocks
+		 */
+		ssi_clk_prepare(true);
+		break;
+	default:
+		dev_err(bridge, "Invalid clock id for enable\n");
+		status = DSP_EFAIL;
+	}
+
+	if (DSP_SUCCEEDED(status))
+		set_dsp_clk_active(&dsp_clocks, clk_id);
+
+out:
+	return status;
+}
+
+/*
+ *  ======== dsp_clk_disable ========
+ *  Purpose:
+ *      Disable the clock.
+ *
+ */
+dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
+{
+	dsp_status status = DSP_SOK;
+
+	DBC_REQUIRE(clk_id < DSP_CLK_NOT_DEFINED);
+
+	if (!is_dsp_clk_active(dsp_clocks, clk_id)) {
+		dev_err(bridge, "ERR: clock id %d already disabled\n", clk_id);
+		goto out;
+	}
+
+	switch (get_clk_type(clk_id)) {
+	case GPT_CLK:
+		omap_dm_timer_free(timer[clk_id]);
+		break;
+	case MCBSP_CLK:
+		mcbsp_clk_prepare(false, clk_id);
+		omap_mcbsp_free(MCBSP_ID(clk_id));
+		break;
+	case WDT_CLK:
+		dev_err(bridge, "ERROR: DSP requested to disable WDT3 clk\n");
+		break;
+	case SSI_CLK:
+		ssi_clk_prepare(false);
+		clk_disable(ssi.sst_fck);
+		clk_disable(ssi.ssr_fck);
+		clk_disable(ssi.ick);
+		break;
+	default:
+		dev_err(bridge, "Invalid clock id for disable\n");
+		status = DSP_EFAIL;
+	}
+
+	if (DSP_SUCCEEDED(status))
+		set_dsp_clk_inactive(&dsp_clocks, clk_id);
+
+out:
+	return status;
+}
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 19/19] DSPBRIDGE: reorganize the code to handle peripheral clocks
  2010-04-08 23:16                                   ` [PATCH 18/19] DSPBRIDGE: move clk to dsp-clock Omar Ramirez Luna
@ 2010-04-08 23:16                                     ` Omar Ramirez Luna
  0 siblings, 0 replies; 20+ messages in thread
From: Omar Ramirez Luna @ 2010-04-08 23:16 UTC (permalink / raw)
  To: linux-omap
  Cc: Paul Walmsley, Hiroshi DOYU, Felipe Contreras, Ameya Palande,
	Guzman Lugo Fernando, Nishanth Menon, Omar Ramirez Luna,
	Omar Ramirez Luna

This patch moves and simplifies the code used to enable/disable
all the requested peripheral clocks.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@hotmail.com>
---
 arch/arm/plat-omap/include/dspbridge/clk.h |    4 ++
 drivers/dsp/bridge/wmd/_tiomap_pwr.h       |   17 -----------
 drivers/dsp/bridge/wmd/dsp-clock.c         |   41 +++++++++++++++++++++++++++
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c    |   42 +--------------------------
 drivers/dsp/bridge/wmd/tiomap_io.c         |    4 +-
 drivers/dsp/bridge/wmd/ue_deh.c            |    2 +-
 6 files changed, 50 insertions(+), 60 deletions(-)

diff --git a/arch/arm/plat-omap/include/dspbridge/clk.h b/arch/arm/plat-omap/include/dspbridge/clk.h
index da2549d..7b43852 100644
--- a/arch/arm/plat-omap/include/dspbridge/clk.h
+++ b/arch/arm/plat-omap/include/dspbridge/clk.h
@@ -47,6 +47,8 @@ enum dsp_clk_id {
  */
 extern dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id);
 
+u32 dsp_clock_enable_all(u32 dsp_per_clocks);
+
 /*
  *  ======== dsp_clk_disable ========
  *  Purpose:
@@ -60,6 +62,8 @@ extern dsp_status dsp_clk_enable(IN enum dsp_clk_id clk_id);
  */
 extern dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id);
 
+u32 dsp_clock_disable_all(u32 dsp_per_clocks);
+
 void ssi_clk_exit(void);
 
 void ssi_clk_init(void);
diff --git a/drivers/dsp/bridge/wmd/_tiomap_pwr.h b/drivers/dsp/bridge/wmd/_tiomap_pwr.h
index a7a4fc2..1948e83 100644
--- a/drivers/dsp/bridge/wmd/_tiomap_pwr.h
+++ b/drivers/dsp/bridge/wmd/_tiomap_pwr.h
@@ -64,23 +64,6 @@ dsp_status pre_scale_dsp(struct wmd_dev_context *dev_context, IN void *pargs);
  */
 dsp_status handle_constraints_set(struct wmd_dev_context *dev_context,
 				  IN void *pargs);
-/*
- *  ======== dsp_peripheral_clocks_disable ========
- *  	This function disables all the peripheral clocks that
- *	were enabled by DSP. Call this function only when
- *	DSP is entering Hibernation or when DSP is in
- *	Error state
- */
-dsp_status dsp_peripheral_clocks_disable(struct wmd_dev_context *dev_context,
-					 IN void *pargs);
-
-/*
- *  ======== dsp_peripheral_clocks_enable ========
- *  	This function enables all the peripheral clocks that
- *	were requested by DSP.
- */
-dsp_status dsp_peripheral_clocks_enable(struct wmd_dev_context *dev_context,
-					IN void *pargs);
 
 /*
  *  ======== dsp_clk_wakeup_event_ctrl ========
diff --git a/drivers/dsp/bridge/wmd/dsp-clock.c b/drivers/dsp/bridge/wmd/dsp-clock.c
index 8f539fd..187c71c 100644
--- a/drivers/dsp/bridge/wmd/dsp-clock.c
+++ b/drivers/dsp/bridge/wmd/dsp-clock.c
@@ -242,6 +242,25 @@ out:
 	return status;
 }
 
+/**
+ * dsp_clock_enable_all - Enable clocks used by the DSP
+ * @dev_context		Driver's device context strucure
+ *
+ * This function enables all the peripheral clocks that were requested by DSP.
+ */
+u32 dsp_clock_enable_all(u32 dsp_per_clocks)
+{
+	u32 clk_id;
+	u32 status = DSP_EFAIL;
+
+	for (clk_id = 0; clk_id < DSP_CLK_NOT_DEFINED; clk_id++) {
+		if (is_dsp_clk_active(dsp_per_clocks, clk_id))
+			status = dsp_clk_enable(clk_id);
+	}
+
+	return status;
+}
+
 /*
  *  ======== dsp_clk_disable ========
  *  Purpose:
@@ -287,3 +306,25 @@ dsp_status dsp_clk_disable(IN enum dsp_clk_id clk_id)
 out:
 	return status;
 }
+
+/**
+ * dsp_clock_disable_all - Disable all active clocks
+ * @dev_context		Driver's device context structure
+ *
+ * This function disables all the peripheral clocks that were enabled by DSP.
+ * It is meant to be called only when DSP is entering hibernation or when DSP
+ * is in error state.
+ */
+u32 dsp_clock_disable_all(u32 dsp_per_clocks)
+{
+	u32 clk_id;
+	u32 status = DSP_EFAIL;
+
+	for (clk_id = 0; clk_id < DSP_CLK_NOT_DEFINED; clk_id++) {
+		if (is_dsp_clk_active(dsp_per_clocks, clk_id))
+			status = dsp_clk_disable(clk_id);
+	}
+
+	return status;
+}
+
diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index a6e8e57..5db2076 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -123,7 +123,7 @@ dsp_status handle_hibernation_from_dsp(struct wmd_dev_context *dev_context)
 		omap_mbox_save_ctx(dev_context->mbox);
 
 		/* Turn off DSP Peripheral clocks and DSP Load monitor timer */
-		status = dsp_peripheral_clocks_disable(dev_context, NULL);
+		status = dsp_clock_disable_all(dev_context->dsp_per_clks);
 
 		if (DSP_SUCCEEDED(status)) {
 			/* Update the Bridger Driver state */
@@ -240,7 +240,7 @@ dsp_status sleep_dsp(struct wmd_dev_context *dev_context, IN u32 dw_cmd,
 			dev_context->dw_brd_state = BRD_RETENTION;
 
 		/* Turn off DSP Peripheral clocks */
-		status = dsp_peripheral_clocks_disable(dev_context, NULL);
+		status = dsp_clock_disable_all(dev_context->dsp_per_clks);
 		if (DSP_FAILED(status)) {
 			return status;
 		}
@@ -422,44 +422,6 @@ dsp_status post_scale_dsp(struct wmd_dev_context *dev_context, IN void *pargs)
 	return status;
 }
 
-/*
- *  ========dsp_peripheral_clocks_disable========
- *  Disables all the peripheral clocks that were requested by DSP
- */
-dsp_status dsp_peripheral_clocks_disable(struct wmd_dev_context *dev_context,
-					 IN void *pargs)
-{
-	u32 clk_idx;
-	dsp_status status = DSP_SOK;
-
-	for (clk_idx = 0; clk_idx < MBX_PM_MAX_RESOURCES; clk_idx++) {
-		if (((dev_context->dsp_per_clks) >> clk_idx) & 0x01) {
-			/* Disables the clocks of the peripheral */
-			status = dsp_clk_disable(bpwr_clks[clk_idx].clk);
-		}
-	}
-	return status;
-}
-
-/*
- *  ========dsp_peripheral_clocks_enable========
- *  Enables all the peripheral clocks that were requested by DSP
- */
-dsp_status dsp_peripheral_clocks_enable(struct wmd_dev_context *dev_context,
-					IN void *pargs)
-{
-	u32 clk_idx;
-	dsp_status clk_status = DSP_EFAIL;
-
-	for (clk_idx = 0; clk_idx < MBX_PM_MAX_RESOURCES; clk_idx++) {
-		if (((dev_context->dsp_per_clks) >> clk_idx) & 0x01) {
-			/* Enable the clocks of the peripheral */
-			clk_status = dsp_clk_enable(bpwr_clks[clk_idx].clk);
-		}
-	}
-	return clk_status;
-}
-
 void dsp_clk_wakeup_event_ctrl(u32 ClkId, bool enable)
 {
 	struct cfg_hostres resources;
diff --git a/drivers/dsp/bridge/wmd/tiomap_io.c b/drivers/dsp/bridge/wmd/tiomap_io.c
index b5504a9..b4c30be 100644
--- a/drivers/dsp/bridge/wmd/tiomap_io.c
+++ b/drivers/dsp/bridge/wmd/tiomap_io.c
@@ -425,7 +425,7 @@ dsp_status sm_interrupt_dsp(struct wmd_dev_context *dev_context, u16 mb_val)
 		}
 #endif
 		/* Restart the peripheral clocks */
-		dsp_peripheral_clocks_enable(dev_context, NULL);
+		dsp_clock_enable_all(dev_context->dsp_per_clks);
 
 		/*
 		 * 2:0 AUTO_IVA2_DPLL - Enabling IVA2 DPLL auto control
@@ -451,7 +451,7 @@ dsp_status sm_interrupt_dsp(struct wmd_dev_context *dev_context, u16 mb_val)
 		dev_context->dw_brd_state = BRD_RUNNING;
 	} else if (dev_context->dw_brd_state == BRD_RETENTION) {
 		/* Restart the peripheral clocks */
-		dsp_peripheral_clocks_enable(dev_context, NULL);
+		dsp_clock_enable_all(dev_context->dsp_per_clks);
 	}
 
 	status = omap_mbox_msg_send(dev_context->mbox, mb_val);
diff --git a/drivers/dsp/bridge/wmd/ue_deh.c b/drivers/dsp/bridge/wmd/ue_deh.c
index b88112e..68d6b22 100644
--- a/drivers/dsp/bridge/wmd/ue_deh.c
+++ b/drivers/dsp/bridge/wmd/ue_deh.c
@@ -283,7 +283,7 @@ void bridge_deh_notify(struct deh_mgr *hdeh_mgr, u32 ulEventMask, u32 dwErrInfo)
 		/* Set the Board state as ERROR */
 		dev_context->dw_brd_state = BRD_ERROR;
 		/* Disable all the clocks that were enabled by DSP */
-		(void)dsp_peripheral_clocks_disable(dev_context, NULL);
+		dsp_clock_disable_all(dev_context->dsp_per_clks);
 		/* Call DSP Trace Buffer */
 		print_dsp_trace_buffer(hdeh_mgr->hwmd_context);
 
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2010-04-08 23:00 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-08 23:15 [PATCH 00/19] generic clk module removal Omar Ramirez Luna
2010-04-08 23:15 ` [PATCH 01/19] DSPBRIDGE: rename generic clk_handle for iva2_clk Omar Ramirez Luna
2010-04-08 23:15   ` [PATCH 02/19] DSPBRIDGE: remove iva2 clk control from custom framework Omar Ramirez Luna
2010-04-08 23:15     ` [PATCH 03/19] DSPBRIDGE: fail if clk handle is NULL Omar Ramirez Luna
2010-04-08 23:15       ` [PATCH 04/19] DSPBRIDGE: Now actually fail if a clk handle is wrong Omar Ramirez Luna
2010-04-08 23:15         ` [PATCH 05/19] DSPBRIDGE: Rename services_clk_* to dsp_clk_* Omar Ramirez Luna
2010-04-08 23:15           ` [PATCH 06/19] DSPBRIDGE: remove unused clock sys_ck Omar Ramirez Luna
2010-04-08 23:15             ` [PATCH 07/19] DSPBRIDGE: remove function clk_set32k_hz Omar Ramirez Luna
2010-04-08 23:15               ` [PATCH 08/19] DSPBRIDGE: remove clk_get_use_cnt Omar Ramirez Luna
2010-04-08 23:15                 ` [PATCH 09/19] DSPBRIDGE: trivial clock cleanup for unused code Omar Ramirez Luna
2010-04-08 23:15                   ` [PATCH 10/19] DSPBRIDGE: function to get the type of clock requested by dsp Omar Ramirez Luna
2010-04-08 23:16                     ` [PATCH 11/19] DSPBRIDGE: use dm timer framework for gpt timers Omar Ramirez Luna
2010-04-08 23:16                       ` [PATCH 12/19] DSPBRIDGE: use omap mcbsp to enable mcbsp clocks Omar Ramirez Luna
2010-04-08 23:16                         ` [PATCH 13/19] DSPBRIDGE: remove wdt3 from dsp control Omar Ramirez Luna
2010-04-08 23:16                           ` [PATCH 14/19] DSPBRIDGE: ssi clock fixes Omar Ramirez Luna
2010-04-08 23:16                             ` [PATCH 15/19] DSPBRIDGE: use one call for both ick and fck clocks Omar Ramirez Luna
2010-04-08 23:16                               ` [PATCH 16/19] DSPBRIDGE: Move MCBSP_CLOCKS code to a common place Omar Ramirez Luna
2010-04-08 23:16                                 ` [PATCH 17/19] DSPBRIDGE: Balance the number of enable/disable Omar Ramirez Luna
2010-04-08 23:16                                   ` [PATCH 18/19] DSPBRIDGE: move clk to dsp-clock Omar Ramirez Luna
2010-04-08 23:16                                     ` [PATCH 19/19] DSPBRIDGE: reorganize the code to handle peripheral clocks Omar Ramirez Luna

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.