diff mbox

[PATCHv4,1/8] OMAP3: Clockdomain: Added API for checking if HWSUP is enabled

Message ID alpine.DEB.2.00.1002011502070.20004@utopia.booyaka.com (mailing list archive)
State New, archived
Delegated to: Paul Walmsley
Headers show

Commit Message

Paul Walmsley Feb. 1, 2010, 10:10 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index a38a615..8dce3c9 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -868,6 +868,36 @@  int omap2_clkdm_wakeup(struct clockdomain *clkdm)
 }
 
 /**
+ * omap2_clkdm_read_hwsup - read the hwsup idle transition bit
+ * @clkdm: struct clockdomain *
+ *
+ * Checks whether hardware is allowed to switch the clockdomain @clkdm
+ * automatically into active or idle states. Returns -EINVAL if @clkdm
+ * is NULL; otherwise, 1 if hardware auto-idle is enabled, 0 if not.
+ */
+int omap2_clkdm_read_hwsup(struct clockdomain *clkdm)
+{
+	u32 u, v;
+
+	if (!clkdm)
+		return -EINVAL;
+
+	u = cm_read_mod_reg(clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
+	u &= clkdm->clktrctrl_mask;
+
+	if (cpu_is_omap24xx())
+		v = OMAP24XX_CLKSTCTRL_ENABLE_AUTO;
+	else if (cpu_is_omap34xx() || cpu_is_omap44xx())
+		v = OMAP34XX_CLKSTCTRL_ENABLE_AUTO;
+	else
+		BUG();
+
+	v <<= __ffs(clkdm->clktrctrl_mask);
+
+	return (u == v) ? 1 : 0;
+}
+
+/**
  * omap2_clkdm_allow_idle - enable hwsup idle transitions for clkdm
  * @clkdm: struct clockdomain *
  *
diff --git a/arch/arm/plat-omap/include/plat/clockdomain.h b/arch/arm/plat-omap/include/plat/clockdomain.h
index ba0a6c0..9d25f4e 100644
--- a/arch/arm/plat-omap/include/plat/clockdomain.h
+++ b/arch/arm/plat-omap/include/plat/clockdomain.h
@@ -129,6 +129,7 @@  int clkdm_del_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
 int clkdm_read_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
 int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm);
 
+int omap2_clkdm_read_hwsup(struct clockdomain *clkdm);
 void omap2_clkdm_allow_idle(struct clockdomain *clkdm);
 void omap2_clkdm_deny_idle(struct clockdomain *clkdm);