All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: linux-omap@vger.kernel.org, khilman@ti.com, paul@pwsan.com
Cc: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv7 21/21] ARM: OMAP4: vc: auto retention support
Date: Tue, 25 Sep 2012 19:33:53 +0300	[thread overview]
Message-ID: <1348590833-12335-22-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1348590833-12335-1-git-send-email-t-kristo@ti.com>

This patch adds callbacks for the voltdm sleep / wakeups, which are now
used for enabling / disabling auto retention voltage control. Once a
voltage domain is ready to idle, its auto retention mode is enabled.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/prm-regbits-44xx.h |    5 +++
 arch/arm/mach-omap2/vc.c               |   52 ++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/vc.h               |    4 ++
 arch/arm/mach-omap2/vc44xx_data.c      |    6 ++++
 4 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/prm-regbits-44xx.h b/arch/arm/mach-omap2/prm-regbits-44xx.h
index 3cb247b..15b9599 100644
--- a/arch/arm/mach-omap2/prm-regbits-44xx.h
+++ b/arch/arm/mach-omap2/prm-regbits-44xx.h
@@ -81,6 +81,11 @@
 #define OMAP4430_AIPOFF_MASK						(1 << 8)
 
 /* Used by PRM_VOLTCTRL */
+#define OMAP4430_AUTO_CTRL_VDD_DISABLED					0
+#define OMAP4430_AUTO_CTRL_VDD_SLEEP					1
+#define OMAP4430_AUTO_CTRL_VDD_RET					2
+
+/* Used by PRM_VOLTCTRL */
 #define OMAP4430_AUTO_CTRL_VDD_CORE_L_SHIFT				0
 #define OMAP4430_AUTO_CTRL_VDD_CORE_L_MASK				(0x3 << 0)
 
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index d217bbf..c607a0c 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -568,11 +568,63 @@ static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
 	__raw_writel(val, OMAP4_SCRM_CLKSETUPTIME);
 }
 
+/**
+ * omap4_vc_sleep - voltagedomain sleep entry callback
+ * @voltdm: domain which is entering idle
+ *
+ * This function is called once a voltagedomain is ready to enter idle.
+ * Sets up AUTO_RET / AUTO_SLEEP command to be sent through the I2C
+ * to the PMIC.
+ */
+static void omap4_vc_sleep(struct voltagedomain *voltdm)
+{
+	u32 val;
+	u32 voltctrl;
+
+	switch (voltdm->target_state) {
+	case PWRDM_POWER_OFF:
+	case PWRDM_POWER_RET:
+		val = OMAP4430_AUTO_CTRL_VDD_RET;
+		break;
+	default:
+		val = OMAP4430_AUTO_CTRL_VDD_SLEEP;
+		break;
+	}
+	voltctrl = voltdm->read(OMAP4_PRM_VOLTCTRL_OFFSET);
+
+	voltctrl &= ~(u32)voltdm->vc->voltctrl_mask;
+
+	voltctrl |= val << voltdm->vc->voltctrl_shift;
+
+	voltdm->write(voltctrl, OMAP4_PRM_VOLTCTRL_OFFSET);
+}
+
+/**
+ * omap4_vc_wakeup - voltagedomain wakeup callback
+ * @voltdm: domain which is leaving idle
+ *
+ * This function is called once a voltagedomain is becoming active.
+ * Disables AUTO_RET / AUTO_SLEEP for the domain.
+ */
+static void omap4_vc_wakeup(struct voltagedomain *voltdm)
+{
+	u32 voltctrl;
+
+	voltctrl = voltdm->read(OMAP4_PRM_VOLTCTRL_OFFSET);
+
+	voltctrl &= ~(u32)voltdm->vc->voltctrl_mask;
+
+	voltdm->write(voltctrl, OMAP4_PRM_VOLTCTRL_OFFSET);
+}
+
 /* OMAP4 specific voltage init functions */
 static void __init omap4_vc_init_channel(struct voltagedomain *voltdm)
 {
 	omap4_set_timings(voltdm, true);
 	omap4_set_timings(voltdm, false);
+
+	voltdm->sleep = omap4_vc_sleep;
+	voltdm->wakeup = omap4_vc_wakeup;
 }
 
 struct i2c_init_data {
diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h
index 91c8d75..8357d57 100644
--- a/arch/arm/mach-omap2/vc.h
+++ b/arch/arm/mach-omap2/vc.h
@@ -79,6 +79,8 @@ struct omap_vc_common {
  * @smps_cmdra_reg: Offset of PRM_VC_SMPS_CMD_RA reg from PRM start
  * @cfg_channel_reg: VC channel configuration register
  * @cfg_channel_sa_shift: bit shift for slave address cfg_channel register
+ * @voltctrl_shift: bit shift for voltctrl register field
+ * @voltctrl_mask: bit mask for voltctrl register field
  * @flags: VC channel-specific flags (optional)
  */
 struct omap_vc_channel {
@@ -100,6 +102,8 @@ struct omap_vc_channel {
 	u8 smps_cmdra_reg;
 	u8 cfg_channel_reg;
 	u8 cfg_channel_sa_shift;
+	u8 voltctrl_shift;
+	u8 voltctrl_mask;
 	u8 flags;
 };
 
diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c
index 085e5d6..a003a1f 100644
--- a/arch/arm/mach-omap2/vc44xx_data.c
+++ b/arch/arm/mach-omap2/vc44xx_data.c
@@ -59,6 +59,8 @@ struct omap_vc_channel omap4_vc_mpu = {
 	.smps_volra_mask = OMAP4430_VOLRA_VDD_MPU_L_MASK,
 	.smps_cmdra_mask = OMAP4430_CMDRA_VDD_MPU_L_MASK,
 	.cfg_channel_sa_shift = OMAP4430_SA_VDD_MPU_L_SHIFT,
+	.voltctrl_shift = OMAP4430_AUTO_CTRL_VDD_MPU_L_SHIFT,
+	.voltctrl_mask = OMAP4430_AUTO_CTRL_VDD_MPU_L_MASK,
 };
 
 struct omap_vc_channel omap4_vc_iva = {
@@ -72,6 +74,8 @@ struct omap_vc_channel omap4_vc_iva = {
 	.smps_volra_mask = OMAP4430_VOLRA_VDD_IVA_L_MASK,
 	.smps_cmdra_mask = OMAP4430_CMDRA_VDD_IVA_L_MASK,
 	.cfg_channel_sa_shift = OMAP4430_SA_VDD_IVA_L_SHIFT,
+	.voltctrl_shift = OMAP4430_AUTO_CTRL_VDD_IVA_L_SHIFT,
+	.voltctrl_mask = OMAP4430_AUTO_CTRL_VDD_IVA_L_MASK,
 };
 
 struct omap_vc_channel omap4_vc_core = {
@@ -85,6 +89,8 @@ struct omap_vc_channel omap4_vc_core = {
 	.smps_volra_mask = OMAP4430_VOLRA_VDD_CORE_L_MASK,
 	.smps_cmdra_mask = OMAP4430_CMDRA_VDD_CORE_L_MASK,
 	.cfg_channel_sa_shift = OMAP4430_SA_VDD_CORE_L_SHIFT,
+	.voltctrl_shift = OMAP4430_AUTO_CTRL_VDD_CORE_L_SHIFT,
+	.voltctrl_mask = OMAP4430_AUTO_CTRL_VDD_CORE_L_MASK,
 };
 
 /*
-- 
1.7.4.1


WARNING: multiple messages have this Message-ID (diff)
From: t-kristo@ti.com (Tero Kristo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv7 21/21] ARM: OMAP4: vc: auto retention support
Date: Tue, 25 Sep 2012 19:33:53 +0300	[thread overview]
Message-ID: <1348590833-12335-22-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1348590833-12335-1-git-send-email-t-kristo@ti.com>

This patch adds callbacks for the voltdm sleep / wakeups, which are now
used for enabling / disabling auto retention voltage control. Once a
voltage domain is ready to idle, its auto retention mode is enabled.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/prm-regbits-44xx.h |    5 +++
 arch/arm/mach-omap2/vc.c               |   52 ++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/vc.h               |    4 ++
 arch/arm/mach-omap2/vc44xx_data.c      |    6 ++++
 4 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/prm-regbits-44xx.h b/arch/arm/mach-omap2/prm-regbits-44xx.h
index 3cb247b..15b9599 100644
--- a/arch/arm/mach-omap2/prm-regbits-44xx.h
+++ b/arch/arm/mach-omap2/prm-regbits-44xx.h
@@ -81,6 +81,11 @@
 #define OMAP4430_AIPOFF_MASK						(1 << 8)
 
 /* Used by PRM_VOLTCTRL */
+#define OMAP4430_AUTO_CTRL_VDD_DISABLED					0
+#define OMAP4430_AUTO_CTRL_VDD_SLEEP					1
+#define OMAP4430_AUTO_CTRL_VDD_RET					2
+
+/* Used by PRM_VOLTCTRL */
 #define OMAP4430_AUTO_CTRL_VDD_CORE_L_SHIFT				0
 #define OMAP4430_AUTO_CTRL_VDD_CORE_L_MASK				(0x3 << 0)
 
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index d217bbf..c607a0c 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -568,11 +568,63 @@ static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
 	__raw_writel(val, OMAP4_SCRM_CLKSETUPTIME);
 }
 
+/**
+ * omap4_vc_sleep - voltagedomain sleep entry callback
+ * @voltdm: domain which is entering idle
+ *
+ * This function is called once a voltagedomain is ready to enter idle.
+ * Sets up AUTO_RET / AUTO_SLEEP command to be sent through the I2C
+ * to the PMIC.
+ */
+static void omap4_vc_sleep(struct voltagedomain *voltdm)
+{
+	u32 val;
+	u32 voltctrl;
+
+	switch (voltdm->target_state) {
+	case PWRDM_POWER_OFF:
+	case PWRDM_POWER_RET:
+		val = OMAP4430_AUTO_CTRL_VDD_RET;
+		break;
+	default:
+		val = OMAP4430_AUTO_CTRL_VDD_SLEEP;
+		break;
+	}
+	voltctrl = voltdm->read(OMAP4_PRM_VOLTCTRL_OFFSET);
+
+	voltctrl &= ~(u32)voltdm->vc->voltctrl_mask;
+
+	voltctrl |= val << voltdm->vc->voltctrl_shift;
+
+	voltdm->write(voltctrl, OMAP4_PRM_VOLTCTRL_OFFSET);
+}
+
+/**
+ * omap4_vc_wakeup - voltagedomain wakeup callback
+ * @voltdm: domain which is leaving idle
+ *
+ * This function is called once a voltagedomain is becoming active.
+ * Disables AUTO_RET / AUTO_SLEEP for the domain.
+ */
+static void omap4_vc_wakeup(struct voltagedomain *voltdm)
+{
+	u32 voltctrl;
+
+	voltctrl = voltdm->read(OMAP4_PRM_VOLTCTRL_OFFSET);
+
+	voltctrl &= ~(u32)voltdm->vc->voltctrl_mask;
+
+	voltdm->write(voltctrl, OMAP4_PRM_VOLTCTRL_OFFSET);
+}
+
 /* OMAP4 specific voltage init functions */
 static void __init omap4_vc_init_channel(struct voltagedomain *voltdm)
 {
 	omap4_set_timings(voltdm, true);
 	omap4_set_timings(voltdm, false);
+
+	voltdm->sleep = omap4_vc_sleep;
+	voltdm->wakeup = omap4_vc_wakeup;
 }
 
 struct i2c_init_data {
diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h
index 91c8d75..8357d57 100644
--- a/arch/arm/mach-omap2/vc.h
+++ b/arch/arm/mach-omap2/vc.h
@@ -79,6 +79,8 @@ struct omap_vc_common {
  * @smps_cmdra_reg: Offset of PRM_VC_SMPS_CMD_RA reg from PRM start
  * @cfg_channel_reg: VC channel configuration register
  * @cfg_channel_sa_shift: bit shift for slave address cfg_channel register
+ * @voltctrl_shift: bit shift for voltctrl register field
+ * @voltctrl_mask: bit mask for voltctrl register field
  * @flags: VC channel-specific flags (optional)
  */
 struct omap_vc_channel {
@@ -100,6 +102,8 @@ struct omap_vc_channel {
 	u8 smps_cmdra_reg;
 	u8 cfg_channel_reg;
 	u8 cfg_channel_sa_shift;
+	u8 voltctrl_shift;
+	u8 voltctrl_mask;
 	u8 flags;
 };
 
diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c
index 085e5d6..a003a1f 100644
--- a/arch/arm/mach-omap2/vc44xx_data.c
+++ b/arch/arm/mach-omap2/vc44xx_data.c
@@ -59,6 +59,8 @@ struct omap_vc_channel omap4_vc_mpu = {
 	.smps_volra_mask = OMAP4430_VOLRA_VDD_MPU_L_MASK,
 	.smps_cmdra_mask = OMAP4430_CMDRA_VDD_MPU_L_MASK,
 	.cfg_channel_sa_shift = OMAP4430_SA_VDD_MPU_L_SHIFT,
+	.voltctrl_shift = OMAP4430_AUTO_CTRL_VDD_MPU_L_SHIFT,
+	.voltctrl_mask = OMAP4430_AUTO_CTRL_VDD_MPU_L_MASK,
 };
 
 struct omap_vc_channel omap4_vc_iva = {
@@ -72,6 +74,8 @@ struct omap_vc_channel omap4_vc_iva = {
 	.smps_volra_mask = OMAP4430_VOLRA_VDD_IVA_L_MASK,
 	.smps_cmdra_mask = OMAP4430_CMDRA_VDD_IVA_L_MASK,
 	.cfg_channel_sa_shift = OMAP4430_SA_VDD_IVA_L_SHIFT,
+	.voltctrl_shift = OMAP4430_AUTO_CTRL_VDD_IVA_L_SHIFT,
+	.voltctrl_mask = OMAP4430_AUTO_CTRL_VDD_IVA_L_MASK,
 };
 
 struct omap_vc_channel omap4_vc_core = {
@@ -85,6 +89,8 @@ struct omap_vc_channel omap4_vc_core = {
 	.smps_volra_mask = OMAP4430_VOLRA_VDD_CORE_L_MASK,
 	.smps_cmdra_mask = OMAP4430_CMDRA_VDD_CORE_L_MASK,
 	.cfg_channel_sa_shift = OMAP4430_SA_VDD_CORE_L_SHIFT,
+	.voltctrl_shift = OMAP4430_AUTO_CTRL_VDD_CORE_L_SHIFT,
+	.voltctrl_mask = OMAP4430_AUTO_CTRL_VDD_CORE_L_MASK,
 };
 
 /*
-- 
1.7.4.1

  parent reply	other threads:[~2012-09-25 16:34 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-25 16:33 [PATCHv7 00/21] ARM: OMAP3+: auto retention support Tero Kristo
2012-09-25 16:33 ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 01/21] ARM: OMAP3+: PM: VP: use uV for max and min voltage limits Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 02/21] ARM: OMAP: voltage: renamed vp_vddmin and vp_vddmax fields Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 03/21] ARM: OMAP3+: voltage: introduce omap vc / vp params for voltagedomains Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 04/21] ARM: OMAP3: VC: calculate ramp times Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 05/21] ARM: OMAP4: voltage: add support for VOLTSETUP_x_OFF register Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 06/21] ARM: OMAP4: VC: calculate ramp times Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 07/21] ARM: OMAP: add support for oscillator setup Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 08/21] ARM: OMAP3+: vp: use new vp_params for calculating vddmin and vddmax Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 09/21] ARM: OMAP3+: voltage: use oscillator data to calculate setup times Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 10/21] ARM: OMAP: TWL: change the vddmin / vddmax voltages to spec Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 11/21] TEMP: ARM: OMAP3: beagle rev-c4: enable OPP6 Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 12/21] ARM: OMAP: beagle: set oscillator startup time to 10ms for rev c4 Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 13/21] ARM: OMAP3: vc: auto_ret / auto_off support Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 14/21] ARM: OMAP3+: voltage: remove unused volt_setup_time parameter Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 15/21] ARM: OMAP4: vc: fix channel configuration Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 16/21] ARM: OMAP4: VC: setup I2C parameters based on board data Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 17/21] ARM: OMAP4: TWL: enable high speed mode for PMIC communication Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-26 11:39   ` Peter Ujfalusi
2012-09-26 11:39     ` Peter Ujfalusi
2012-09-26 12:06     ` Tero Kristo
2012-09-26 12:06       ` Tero Kristo
2012-09-26 12:23       ` Peter Ujfalusi
2012-09-26 12:23         ` Peter Ujfalusi
2012-09-25 16:33 ` [PATCHv7 18/21] ARM: OMAP4: OPP: add OMAP4460 definitions Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 19/21] ARM: OMAP3+: PM: introduce a central pmic control Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` [PATCHv7 20/21] ARM: OMAP2+ PM: Add support for TPS62361 Tero Kristo
2012-09-25 16:33   ` Tero Kristo
2012-09-25 16:33 ` Tero Kristo [this message]
2012-09-25 16:33   ` [PATCHv7 21/21] ARM: OMAP4: vc: auto retention support Tero Kristo
2012-11-06  1:02 ` [PATCHv7 00/21] ARM: OMAP3+: " Kevin Hilman
2012-11-06  1:02   ` Kevin Hilman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348590833-12335-22-git-send-email-t-kristo@ti.com \
    --to=t-kristo@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.