From: jean.pihet@newoldbits.com (Jean Pihet)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv3 03/20] ARM: OMAP4: PM: add support for device off
Date: Wed, 13 Jun 2012 17:21:45 +0200 [thread overview]
Message-ID: <CAORVsuUJOpQu1qE7qmK9PS79JZJ065egqcpfgmsWNHwnhLUdvw@mail.gmail.com> (raw)
In-Reply-To: <1339515095-9908-4-git-send-email-t-kristo@ti.com>
Hi Tero,
I have a few remarks regarding the genericity of this code. I think it
is better if the code in powerdomain.c stays generic and that the
platform specific checks and operations be moved in the specific
functions (via the pwrdm_ops struct).
On Tue, Jun 12, 2012 at 5:31 PM, Tero Kristo <t-kristo@ti.com> wrote:
> On OMAP4+, device wide off-mode has its own enable mechanism in addition
> to powerdomain target states. This patch adds support for this on top
> of functional power states by overloading the OFF state for core pwrdm.
> On pwrdm level, the deepest power state supported by core pwrdm is OSWR.
> When user (e.g. suspend) programs core pwrdm target as OFF, the functional
> power state for the domain will be OSWR with the additional device off
> enabled. Previous power state information will reflect this also.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> ---
> ?arch/arm/mach-omap2/powerdomain.c ? ? ? ? ? | ? 17 +++++++++
> ?arch/arm/mach-omap2/powerdomain.h ? ? ? ? ? | ? 13 +++++++-
> ?arch/arm/mach-omap2/powerdomain44xx.c ? ? ? | ? 48 +++++++++++++++++++++++++++
> ?arch/arm/mach-omap2/powerdomains44xx_data.c | ? ?3 +-
> ?4 files changed, 79 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
> index ac63f86..78a9308 100644
> --- a/arch/arm/mach-omap2/powerdomain.c
> +++ b/arch/arm/mach-omap2/powerdomain.c
> @@ -677,6 +677,8 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 func_pwrst)
> ? ? ? ?int sleep_switch = -1, ret = 0, hwsup = 0;
> ? ? ? ?int new_func_pwrst, next_func_pwrst, pwrst, logic;
> ? ? ? ?u8 curr_pwrst;
> + ? ? ? bool extra_off_enable = false;
> + ? ? ? bool has_extra_off = false;
>
> ? ? ? ?if (!pwrdm || IS_ERR(pwrdm)) {
> ? ? ? ? ? ? ? ?pr_debug("%s: invalid params: pwrdm=%p\n", __func__, pwrdm);
> @@ -687,6 +689,13 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 func_pwrst)
>
> ? ? ? ?mutex_lock(&pwrdm->lock);
>
> + ? ? ? /* Check if powerdomain has extra off mode handling */
> + ? ? ? if (pwrdm->flags & PWRDM_HAS_EXTRA_OFF_ENABLE) {
> + ? ? ? ? ? ? ? has_extra_off = true;
> + ? ? ? ? ? ? ? if (func_pwrst == PWRDM_FUNC_PWRST_OFF)
> + ? ? ? ? ? ? ? ? ? ? ? extra_off_enable = true;
> + ? ? ? }
Could those checks be moved in the OMAP4 specific functions, so that
the power domain code stays generic?
> +
> ? ? ? ?new_func_pwrst = pwrdm_get_achievable_func_pwrst(pwrdm, func_pwrst);
> ? ? ? ?pwrst = pwrdm_func_to_pwrst(pwrdm, new_func_pwrst);
> ? ? ? ?logic = pwrdm_func_to_logic_pwrst(pwrdm, new_func_pwrst);
> @@ -741,6 +750,9 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 func_pwrst)
> ? ? ? ? ? ? ? ?break;
> ? ? ? ?}
>
> + ? ? ? if (has_extra_off && arch_pwrdm->pwrdm_enable_off)
> + ? ? ? ? ? ? ? arch_pwrdm->pwrdm_enable_off(pwrdm, extra_off_enable);
> +
> ?out:
> ? ? ? ?mutex_unlock(&pwrdm->lock);
> ? ? ? ?return ret;
> @@ -810,6 +822,11 @@ int pwrdm_read_next_func_pwrst(struct powerdomain *pwrdm)
> ? ? ? ?int next_pwrst = pwrdm_read_next_pwrst(pwrdm);
> ? ? ? ?int next_logic = pwrdm_read_logic_retst(pwrdm);
>
> + ? ? ? if (pwrdm->flags & PWRDM_HAS_EXTRA_OFF_ENABLE &&
> + ? ? ? ? ? arch_pwrdm->pwrdm_read_next_off &&
> + ? ? ? ? ? arch_pwrdm->pwrdm_read_next_off(pwrdm))
> + ? ? ? ? ? ? ? return PWRDM_FUNC_PWRST_OFF;
> +
Same comment here. The OMAP4 specific function for
pwrdm_read_next_pwrst could return PWRDM_FUNC_PWRST_OFF.
> ? ? ? ?return pwrdm_pwrst_to_func(pwrdm, next_pwrst, next_logic);
> ?}
>
> diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
> index 0729d91..cc30b94 100644
> --- a/arch/arm/mach-omap2/powerdomain.h
> +++ b/arch/arm/mach-omap2/powerdomain.h
> @@ -75,6 +75,13 @@
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?* state without waking up the
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?* powerdomain
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?*/
> +/*
> + * OMAP4+ has device off feature, which must be enabled separately in
> + * addition to power domain next state setup. This feature is overloaded
> + * as EXTRA_OFF_ENABLE for core_pwrdm, and is implemented on top of
> + * functional power state
> + */
> +#define PWRDM_HAS_EXTRA_OFF_ENABLE ? ? (1 << 3)
>
> ?/*
> ?* Number of memory banks that are power-controllable. On OMAP4430, the
> @@ -173,7 +180,9 @@ struct powerdomain {
> ?* @pwrdm_disable_hdwr_sar: Disable Hardware Save-Restore feature for a pd
> ?* @pwrdm_set_lowpwrstchange: Enable pd transitions from a shallow to deep sleep
> ?* @pwrdm_wait_transition: Wait for a pd state transition to complete
> - * @pwrdm_lost_context_rff: Check if pd has lost RFF context (entered off)
> + * @pwrdm_lost_context_rff: Check if pd has lost RFF context (omap4+ device off)
> + * @pwrdm_enable_off: Extra off mode enable for pd (omap4+ device off)
> + * @pwrdm_read_next_off: Check if pd next state is off (omap4+ device off)
> ?*/
> ?struct pwrdm_ops {
> ? ? ? ?int ? ? (*pwrdm_func_to_pwrst)(struct powerdomain *pwrdm, u8 func_pwrst);
> @@ -199,6 +208,8 @@ struct pwrdm_ops {
> ? ? ? ?int ? ? (*pwrdm_set_lowpwrstchange)(struct powerdomain *pwrdm);
> ? ? ? ?int ? ? (*pwrdm_wait_transition)(struct powerdomain *pwrdm);
> ? ? ? ?bool ? ?(*pwrdm_lost_context_rff)(struct powerdomain *pwrdm);
> + ? ? ? void ? ?(*pwrdm_enable_off)(struct powerdomain *pwrdm, bool enable);
> + ? ? ? bool ? ?(*pwrdm_read_next_off)(struct powerdomain *pwrdm);
> ?};
>
> ?int pwrdm_register_platform_funcs(struct pwrdm_ops *custom_funcs);
> diff --git a/arch/arm/mach-omap2/powerdomain44xx.c b/arch/arm/mach-omap2/powerdomain44xx.c
> index 562f78a..b2bdc0f 100644
> --- a/arch/arm/mach-omap2/powerdomain44xx.c
> +++ b/arch/arm/mach-omap2/powerdomain44xx.c
> @@ -358,6 +358,52 @@ bool omap4_pwrdm_lost_context_rff(struct powerdomain *pwrdm)
> ? ? ? ?return false;
> ?}
>
> +/**
> + * omap4_device_set_next_state_off - setup device off state
> + * @pwrdm: struct powerdomain * to target powerdomain
> + * @enable: true if off-mode should be enabled
> + *
> + * When Device OFF is enabled, Device is allowed to perform
> + * transition to off mode as soon as all power domains in MPU, IVA
> + * and CORE voltage are in OFF or OSWR state (open switch retention)
> + */
> +void omap4_device_set_next_state_off(struct powerdomain *pwrdm, bool enable)
> +{
> + ? ? ? u8 val = enable ? 0x1 : 0x0;
> +
> + ? ? ? if (!(pwrdm->flags & PWRDM_HAS_EXTRA_OFF_ENABLE))
> + ? ? ? ? ? ? ? return;
> +
> + ? ? ? omap4_prminst_write_inst_reg(val << OMAP4430_DEVICE_OFF_ENABLE_SHIFT,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?OMAP4430_PRM_PARTITION,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?OMAP4430_PRM_DEVICE_INST,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?OMAP4_PRM_DEVICE_OFF_CTRL_OFFSET);
> +}
> +
> +
> +/**
> + * omap4_device_read_next_state_off - read device off state
> + * @pwrdm: struct powerdomain * to target powerdomain
> + *
> + * Checks if device off is enabled or not.
> + * Returns true if enabled, false otherwise.
> + */
> +bool omap4_device_read_next_state_off(struct powerdomain *pwrdm)
> +{
> + ? ? ? u32 val;
> +
> + ? ? ? if (!(pwrdm->flags & PWRDM_HAS_EXTRA_OFF_ENABLE))
> + ? ? ? ? ? ? ? return false;
> +
> + ? ? ? val = omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4430_PRM_DEVICE_INST,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4_PRM_DEVICE_OFF_CTRL_OFFSET);
> +
> + ? ? ? val &= OMAP4430_DEVICE_OFF_ENABLE_MASK;
> +
> + ? ? ? return val ? true : false;
> +}
> +
> ?struct pwrdm_ops omap4_pwrdm_operations = {
> ? ? ? ?.pwrdm_func_to_pwrst ? ?= omap2_pwrdm_func_to_pwrst,
> ? ? ? ?.pwrdm_func_to_logic_pwrst ? ? ?= omap2_pwrdm_func_to_logic_pwrst,
> @@ -381,4 +427,6 @@ struct pwrdm_ops omap4_pwrdm_operations = {
> ? ? ? ?.pwrdm_enable_hdwr_sar ?= omap4_pwrdm_enable_hdwr_sar,
> ? ? ? ?.pwrdm_disable_hdwr_sar = omap4_pwrdm_disable_hdwr_sar,
> ? ? ? ?.pwrdm_lost_context_rff = omap4_pwrdm_lost_context_rff,
> + ? ? ? .pwrdm_enable_off ? ? ? = omap4_device_set_next_state_off,
> + ? ? ? .pwrdm_read_next_off ? ?= omap4_device_read_next_state_off,
> ?};
> diff --git a/arch/arm/mach-omap2/powerdomains44xx_data.c b/arch/arm/mach-omap2/powerdomains44xx_data.c
> index c4de02f..13db876 100644
> --- a/arch/arm/mach-omap2/powerdomains44xx_data.c
> +++ b/arch/arm/mach-omap2/powerdomains44xx_data.c
> @@ -54,7 +54,8 @@ static struct powerdomain core_44xx_pwrdm = {
> ? ? ? ? ? ? ? ?[3] = PWRSTS_ON, ? ? ? ?/* ducati_l2ram */
> ? ? ? ? ? ? ? ?[4] = PWRSTS_ON, ? ? ? ?/* ducati_unicache */
> ? ? ? ?},
> - ? ? ? .flags ? ? ? ? ? ?= PWRDM_HAS_LOWPOWERSTATECHANGE,
> + ? ? ? .flags ? ? ? ? ? ?= PWRDM_HAS_LOWPOWERSTATECHANGE |
> + ? ? ? ? ? ? ? ? ? ? ? ? ? PWRDM_HAS_EXTRA_OFF_ENABLE,
> ?};
>
> ?/* gfx_44xx_pwrdm: 3D accelerator power domain */
Regards,
Jean
> --
> 1.7.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-06-13 15:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-12 15:31 [PATCHv3 00/20] ARM: OMAP4: device off support Tero Kristo
2012-06-12 15:31 ` [PATCHv3 01/20] ARM: OMAP4: PM: powerdomain: Add HWSAR flag to L3INIT Tero Kristo
2012-06-12 15:31 ` [PATCHv3 02/20] ARM: OMAP4: powerdomain: update mpu / core off counters during device off Tero Kristo
2012-06-12 15:31 ` [PATCHv3 03/20] ARM: OMAP4: PM: add support for " Tero Kristo
2012-06-13 15:21 ` Jean Pihet [this message]
2012-06-14 9:18 ` Tero Kristo
2012-06-14 13:53 ` Tero Kristo
2012-06-12 15:31 ` [PATCHv3 04/20] ARM: OMAP4: PM: update ROM return address for OSWR and OFF Tero Kristo
2012-06-12 15:31 ` [PATCHv3 05/20] OMAP4: PM: clockdomain: workaround for l4_secure_clkdm HWSUP Tero Kristo
2012-06-12 15:31 ` [PATCHv3 06/20] ARM: OMAP4: secure: move GIC / wakeupgen save restore to secure CPU PM notifier Tero Kristo
2012-06-12 15:31 ` [PATCHv3 07/20] ARM: OMAP4: secure: add support for device off Tero Kristo
2012-06-12 15:31 ` [PATCHv3 08/20] ARM: OMAP4: PM: add MPUSS power domain device off support Tero Kristo
2012-06-12 15:31 ` [PATCHv3 09/20] ARM: OMAP4: PM: save/restore all DPLL settings in OFF mode Tero Kristo
2012-06-12 15:31 ` [PATCHv3 10/20] ARM: OMAP4: PM: save/restore all CM1/2 " Tero Kristo
2012-06-12 15:31 ` [PATCHv3 11/20] ARM: OMAP4: PM: Add SAR backup support towards device OFF Tero Kristo
2012-06-12 15:31 ` [PATCHv3 12/20] ARM: OMAP4: PM: Work-around for ROM code BUG of IVAHD/TESLA Tero Kristo
2012-06-12 15:31 ` [PATCHv3 13/20] ARM: OMAP4: PM: save/restore CM L3INSTR registers when MPU hits OSWR/OFF mode Tero Kristo
2012-06-12 15:31 ` [PATCHv3 14/20] ARM: OMAP4: PM: Mark the PPI and SPI interrupts as non-secure for GP Tero Kristo
2012-06-12 15:31 ` [PATCHv3 15/20] ARM: OMAP4430: PM: workaround for DDR corruption on second CS Tero Kristo
2012-06-12 15:31 ` [PATCHv3 16/20] TEMP: ARM: OMAP4: prevent voltage transitions Tero Kristo
2012-06-12 15:31 ` [PATCHv3 17/20] ARM: OMAP4: put cpu1 back to sleep if no wake request Tero Kristo
2012-06-12 15:31 ` [PATCHv3 18/20] ARM: OMAP4460: wakeupgen: set GIC_CPU0 backup status flag always Tero Kristo
2012-06-12 15:31 ` [PATCHv3 19/20] ARM: OMAP4: PM: enable off mode by default Tero Kristo
2012-06-12 15:41 ` [PATCHv3 20/20] ARM: OMAP4430: PM: errata i625, WUGEN lost for GP devices after OFF mode Tero Kristo
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=CAORVsuUJOpQu1qE7qmK9PS79JZJ065egqcpfgmsWNHwnhLUdvw@mail.gmail.com \
--to=jean.pihet@newoldbits.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).