2008-08-19 04:08:40 -04:00
|
|
|
/*
|
|
|
|
* OMAP2/3 powerdomain control
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007-8 Texas Instruments, Inc.
|
|
|
|
* Copyright (C) 2007-8 Nokia Corporation
|
|
|
|
*
|
|
|
|
* Written by Paul Walmsley
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ASM_ARM_ARCH_OMAP_POWERDOMAIN
|
|
|
|
#define ASM_ARM_ARCH_OMAP_POWERDOMAIN
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
|
|
|
|
#include <asm/atomic.h>
|
|
|
|
|
2009-10-20 12:40:47 -04:00
|
|
|
#include <plat/cpu.h>
|
2008-08-19 04:08:40 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* Powerdomain basic power states */
|
|
|
|
#define PWRDM_POWER_OFF 0x0
|
|
|
|
#define PWRDM_POWER_RET 0x1
|
|
|
|
#define PWRDM_POWER_INACTIVE 0x2
|
|
|
|
#define PWRDM_POWER_ON 0x3
|
|
|
|
|
2009-12-08 18:33:12 -05:00
|
|
|
#define PWRDM_MAX_PWRSTS 4
|
|
|
|
|
2008-08-19 04:08:40 -04:00
|
|
|
/* Powerdomain allowable state bitfields */
|
|
|
|
#define PWRSTS_OFF_ON ((1 << PWRDM_POWER_OFF) | \
|
|
|
|
(1 << PWRDM_POWER_ON))
|
|
|
|
|
|
|
|
#define PWRSTS_OFF_RET ((1 << PWRDM_POWER_OFF) | \
|
|
|
|
(1 << PWRDM_POWER_RET))
|
|
|
|
|
|
|
|
#define PWRSTS_OFF_RET_ON (PWRSTS_OFF_RET | (1 << PWRDM_POWER_ON))
|
|
|
|
|
|
|
|
|
[ARM] OMAP3 pwrdm: add hardware save-and-restore (SAR) support
OMAP3430ES2+ introduces a new feature: optional powerdomain context
hardware save-and-restore (SAR). Currently, this feature only applies
to USBHOST and USBTLL module context when the USBHOST or CORE
powerdomains enter a low-power sleep state[1]. This feature avoids
re-enumeration of USB devices when the powerdomains return from idle,
which is potentially time-consuming.
This patch adds support for enabling and disabling hardware
save-and-restore to the powerdomain code. Three new functions are
added, pwrdm_enable_hdwr_sar(), pwrdm_disable_hdwr_sar(), and
pwrdm_can_hdwr_sar(). A new struct powerdomain "flags" field is
added, with a PWRDM_HAS_HDWR_SAR flag to indicate powerdomains with
SAR support.
Thanks to Jouni Högander <jouni.hogander@nokia.com> for reviewing an
earlier version of these patches, and Richard Woodruff <r-woodruff2@ti.com>
for clarifying the purpose of these bits.
1. For the USBHOST controller module, context loss occurs when the
USBHOST powerdomain enters off-idle. For USBTLL, context loss
occurs either if CORE enters off-idle, or if the CORE logic is
configured to turn off when CORE enters retention-idle (OSWR).
34xx ES2 TRM 4.8.6.1.1, 4.8.6.1.2
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-06-25 20:09:37 -04:00
|
|
|
/* Powerdomain flags */
|
|
|
|
#define PWRDM_HAS_HDWR_SAR (1 << 0) /* hardware save-and-restore support */
|
2009-12-08 18:33:15 -05:00
|
|
|
#define PWRDM_HAS_MPU_QUIRK (1 << 1) /* MPU pwr domain has MEM bank 0 bits
|
|
|
|
* in MEM bank 1 position. This is
|
|
|
|
* true for OMAP3430
|
|
|
|
*/
|
[ARM] OMAP3 pwrdm: add hardware save-and-restore (SAR) support
OMAP3430ES2+ introduces a new feature: optional powerdomain context
hardware save-and-restore (SAR). Currently, this feature only applies
to USBHOST and USBTLL module context when the USBHOST or CORE
powerdomains enter a low-power sleep state[1]. This feature avoids
re-enumeration of USB devices when the powerdomains return from idle,
which is potentially time-consuming.
This patch adds support for enabling and disabling hardware
save-and-restore to the powerdomain code. Three new functions are
added, pwrdm_enable_hdwr_sar(), pwrdm_disable_hdwr_sar(), and
pwrdm_can_hdwr_sar(). A new struct powerdomain "flags" field is
added, with a PWRDM_HAS_HDWR_SAR flag to indicate powerdomains with
SAR support.
Thanks to Jouni Högander <jouni.hogander@nokia.com> for reviewing an
earlier version of these patches, and Richard Woodruff <r-woodruff2@ti.com>
for clarifying the purpose of these bits.
1. For the USBHOST controller module, context loss occurs when the
USBHOST powerdomain enters off-idle. For USBTLL, context loss
occurs either if CORE enters off-idle, or if the CORE logic is
configured to turn off when CORE enters retention-idle (OSWR).
34xx ES2 TRM 4.8.6.1.1, 4.8.6.1.2
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-06-25 20:09:37 -04:00
|
|
|
|
2008-08-19 04:08:40 -04:00
|
|
|
/*
|
|
|
|
* Number of memory banks that are power-controllable. On OMAP3430, the
|
|
|
|
* maximum is 4.
|
|
|
|
*/
|
|
|
|
#define PWRDM_MAX_MEM_BANKS 4
|
|
|
|
|
2008-08-19 04:08:44 -04:00
|
|
|
/*
|
|
|
|
* Maximum number of clockdomains that can be associated with a powerdomain.
|
2008-09-10 12:47:36 -04:00
|
|
|
* CORE powerdomain on OMAP3 is the worst case
|
2008-08-19 04:08:44 -04:00
|
|
|
*/
|
2008-09-10 12:47:36 -04:00
|
|
|
#define PWRDM_MAX_CLKDMS 4
|
2008-08-19 04:08:44 -04:00
|
|
|
|
2008-08-19 04:08:40 -04:00
|
|
|
/* XXX A completely arbitrary number. What is reasonable here? */
|
|
|
|
#define PWRDM_TRANSITION_BAILOUT 100000
|
|
|
|
|
2008-08-19 04:08:44 -04:00
|
|
|
struct clockdomain;
|
2008-08-19 04:08:40 -04:00
|
|
|
struct powerdomain;
|
|
|
|
|
|
|
|
/* Encodes dependencies between powerdomains - statically defined */
|
|
|
|
struct pwrdm_dep {
|
|
|
|
|
|
|
|
/* Powerdomain name */
|
|
|
|
const char *pwrdm_name;
|
|
|
|
|
|
|
|
/* Powerdomain pointer - resolved by the powerdomain code */
|
|
|
|
struct powerdomain *pwrdm;
|
|
|
|
|
|
|
|
/* Flags to mark OMAP chip restrictions, etc. */
|
|
|
|
const struct omap_chip_id omap_chip;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct powerdomain {
|
|
|
|
|
|
|
|
/* Powerdomain name */
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/* the address offset from CM_BASE/PRM_BASE */
|
|
|
|
const s16 prcm_offs;
|
|
|
|
|
|
|
|
/* Used to represent the OMAP chip types containing this pwrdm */
|
|
|
|
const struct omap_chip_id omap_chip;
|
|
|
|
|
|
|
|
/* Powerdomains that can be told to wake this powerdomain up */
|
|
|
|
struct pwrdm_dep *wkdep_srcs;
|
|
|
|
|
|
|
|
/* Powerdomains that can be told to keep this pwrdm from inactivity */
|
|
|
|
struct pwrdm_dep *sleepdep_srcs;
|
2009-12-08 18:33:13 -05:00
|
|
|
|
|
|
|
/* Bit shift of this powerdomain's PM_WKDEP/CM_SLEEPDEP bit */
|
|
|
|
const u8 dep_bit;
|
2008-08-19 04:08:40 -04:00
|
|
|
|
|
|
|
/* Possible powerdomain power states */
|
|
|
|
const u8 pwrsts;
|
|
|
|
|
|
|
|
/* Possible logic power states when pwrdm in RETENTION */
|
|
|
|
const u8 pwrsts_logic_ret;
|
|
|
|
|
[ARM] OMAP3 pwrdm: add hardware save-and-restore (SAR) support
OMAP3430ES2+ introduces a new feature: optional powerdomain context
hardware save-and-restore (SAR). Currently, this feature only applies
to USBHOST and USBTLL module context when the USBHOST or CORE
powerdomains enter a low-power sleep state[1]. This feature avoids
re-enumeration of USB devices when the powerdomains return from idle,
which is potentially time-consuming.
This patch adds support for enabling and disabling hardware
save-and-restore to the powerdomain code. Three new functions are
added, pwrdm_enable_hdwr_sar(), pwrdm_disable_hdwr_sar(), and
pwrdm_can_hdwr_sar(). A new struct powerdomain "flags" field is
added, with a PWRDM_HAS_HDWR_SAR flag to indicate powerdomains with
SAR support.
Thanks to Jouni Högander <jouni.hogander@nokia.com> for reviewing an
earlier version of these patches, and Richard Woodruff <r-woodruff2@ti.com>
for clarifying the purpose of these bits.
1. For the USBHOST controller module, context loss occurs when the
USBHOST powerdomain enters off-idle. For USBTLL, context loss
occurs either if CORE enters off-idle, or if the CORE logic is
configured to turn off when CORE enters retention-idle (OSWR).
34xx ES2 TRM 4.8.6.1.1, 4.8.6.1.2
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-06-25 20:09:37 -04:00
|
|
|
/* Powerdomain flags */
|
|
|
|
const u8 flags;
|
|
|
|
|
2008-08-19 04:08:40 -04:00
|
|
|
/* Number of software-controllable memory banks in this powerdomain */
|
|
|
|
const u8 banks;
|
|
|
|
|
|
|
|
/* Possible memory bank pwrstates when pwrdm in RETENTION */
|
|
|
|
const u8 pwrsts_mem_ret[PWRDM_MAX_MEM_BANKS];
|
|
|
|
|
|
|
|
/* Possible memory bank pwrstates when pwrdm is ON */
|
|
|
|
const u8 pwrsts_mem_on[PWRDM_MAX_MEM_BANKS];
|
|
|
|
|
2008-08-19 04:08:44 -04:00
|
|
|
/* Clockdomains in this powerdomain */
|
|
|
|
struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS];
|
|
|
|
|
2008-08-19 04:08:40 -04:00
|
|
|
struct list_head node;
|
|
|
|
|
2008-10-15 10:48:43 -04:00
|
|
|
int state;
|
2009-12-08 18:33:12 -05:00
|
|
|
unsigned state_counter[PWRDM_MAX_PWRSTS];
|
2008-10-15 11:13:48 -04:00
|
|
|
|
|
|
|
#ifdef CONFIG_PM_DEBUG
|
|
|
|
s64 timer;
|
2009-12-08 18:33:12 -05:00
|
|
|
s64 state_timer[PWRDM_MAX_PWRSTS];
|
2008-10-15 11:13:48 -04:00
|
|
|
#endif
|
2008-08-19 04:08:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void pwrdm_init(struct powerdomain **pwrdm_list);
|
|
|
|
|
|
|
|
int pwrdm_register(struct powerdomain *pwrdm);
|
|
|
|
int pwrdm_unregister(struct powerdomain *pwrdm);
|
|
|
|
struct powerdomain *pwrdm_lookup(const char *name);
|
|
|
|
|
2008-10-15 11:13:47 -04:00
|
|
|
int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user),
|
|
|
|
void *user);
|
2009-10-01 03:01:55 -04:00
|
|
|
int pwrdm_for_each_nolock(int (*fn)(struct powerdomain *pwrdm, void *user),
|
|
|
|
void *user);
|
2008-08-19 04:08:40 -04:00
|
|
|
|
2008-08-19 04:08:44 -04:00
|
|
|
int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
|
|
|
|
int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
|
|
|
|
int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
|
|
|
|
int (*fn)(struct powerdomain *pwrdm,
|
|
|
|
struct clockdomain *clkdm));
|
|
|
|
|
2008-08-19 04:08:40 -04:00
|
|
|
int pwrdm_add_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
|
|
|
|
int pwrdm_del_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
|
|
|
|
int pwrdm_read_wkdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
|
|
|
|
int pwrdm_add_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
|
|
|
|
int pwrdm_del_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
|
|
|
|
int pwrdm_read_sleepdep(struct powerdomain *pwrdm1, struct powerdomain *pwrdm2);
|
|
|
|
|
|
|
|
int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
|
|
|
|
|
|
|
|
int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
|
|
|
|
int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
|
2009-01-27 21:12:50 -05:00
|
|
|
int pwrdm_read_pwrst(struct powerdomain *pwrdm);
|
2008-08-19 04:08:40 -04:00
|
|
|
int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm);
|
|
|
|
int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm);
|
|
|
|
|
|
|
|
int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst);
|
|
|
|
int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
|
|
|
|
int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
|
|
|
|
|
|
|
|
int pwrdm_read_logic_pwrst(struct powerdomain *pwrdm);
|
|
|
|
int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm);
|
|
|
|
int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
|
|
|
|
int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
|
|
|
|
|
[ARM] OMAP3 pwrdm: add hardware save-and-restore (SAR) support
OMAP3430ES2+ introduces a new feature: optional powerdomain context
hardware save-and-restore (SAR). Currently, this feature only applies
to USBHOST and USBTLL module context when the USBHOST or CORE
powerdomains enter a low-power sleep state[1]. This feature avoids
re-enumeration of USB devices when the powerdomains return from idle,
which is potentially time-consuming.
This patch adds support for enabling and disabling hardware
save-and-restore to the powerdomain code. Three new functions are
added, pwrdm_enable_hdwr_sar(), pwrdm_disable_hdwr_sar(), and
pwrdm_can_hdwr_sar(). A new struct powerdomain "flags" field is
added, with a PWRDM_HAS_HDWR_SAR flag to indicate powerdomains with
SAR support.
Thanks to Jouni Högander <jouni.hogander@nokia.com> for reviewing an
earlier version of these patches, and Richard Woodruff <r-woodruff2@ti.com>
for clarifying the purpose of these bits.
1. For the USBHOST controller module, context loss occurs when the
USBHOST powerdomain enters off-idle. For USBTLL, context loss
occurs either if CORE enters off-idle, or if the CORE logic is
configured to turn off when CORE enters retention-idle (OSWR).
34xx ES2 TRM 4.8.6.1.1, 4.8.6.1.2
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2008-06-25 20:09:37 -04:00
|
|
|
int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm);
|
|
|
|
int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm);
|
|
|
|
bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm);
|
|
|
|
|
2008-08-19 04:08:40 -04:00
|
|
|
int pwrdm_wait_transition(struct powerdomain *pwrdm);
|
|
|
|
|
2008-10-15 10:48:43 -04:00
|
|
|
int pwrdm_state_switch(struct powerdomain *pwrdm);
|
|
|
|
int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);
|
|
|
|
int pwrdm_pre_transition(void);
|
|
|
|
int pwrdm_post_transition(void);
|
|
|
|
|
2008-08-19 04:08:40 -04:00
|
|
|
#endif
|