powerdomain.h 5.1 KB
Newer Older
1 2 3
/*
 * OMAP2/3 powerdomain control
 *
4 5
 * Copyright (C) 2007-2008 Texas Instruments, Inc.
 * Copyright (C) 2007-2009 Nokia Corporation
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 * 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>

22
#include <plat/cpu.h>
23 24 25 26 27 28 29 30


/* Powerdomain basic power states */
#define PWRDM_POWER_OFF		0x0
#define PWRDM_POWER_RET		0x1
#define PWRDM_POWER_INACTIVE	0x2
#define PWRDM_POWER_ON		0x3

31 32
#define PWRDM_MAX_PWRSTS	4

33
/* Powerdomain allowable state bitfields */
34
#define PWRSTS_ON		(1 << PWRDM_POWER_ON)
35
#define PWRSTS_OFF		(1 << PWRDM_POWER_OFF)
36 37 38 39 40 41
#define PWRSTS_OFF_ON		((1 << PWRDM_POWER_OFF) | \
				 (1 << PWRDM_POWER_ON))

#define PWRSTS_OFF_RET		((1 << PWRDM_POWER_OFF) | \
				 (1 << PWRDM_POWER_RET))

42 43 44
#define PWRSTS_RET_ON		((1 << PWRDM_POWER_RET) | \
				 (1 << PWRDM_POWER_ON))

45 46 47
#define PWRSTS_OFF_RET_ON	(PWRSTS_OFF_RET | (1 << PWRDM_POWER_ON))


48 49
/* Powerdomain flags */
#define PWRDM_HAS_HDWR_SAR	(1 << 0) /* hardware save-and-restore support */
50 51 52 53
#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
					  */
54 55 56 57 58 59
#define PWRDM_HAS_LOWPOWERSTATECHANGE	(1 << 2) /*
						  * support to transition from a
						  * sleep state to a lower sleep
						  * state without waking up the
						  * powerdomain
						  */
60

61
/*
62 63
 * Number of memory banks that are power-controllable.	On OMAP4430, the
 * maximum is 5.
64
 */
65
#define PWRDM_MAX_MEM_BANKS	5
66

67 68
/*
 * Maximum number of clockdomains that can be associated with a powerdomain.
69
 * CORE powerdomain on OMAP4 is the worst case
70
 */
71
#define PWRDM_MAX_CLKDMS	9
72

73 74 75
/* XXX A completely arbitrary number. What is reasonable here? */
#define PWRDM_TRANSITION_BAILOUT 100000

76
struct clockdomain;
77 78
struct powerdomain;

79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
/**
 * struct powerdomain - OMAP powerdomain
 * @name: Powerdomain name
 * @omap_chip: represents the OMAP chip types containing this pwrdm
 * @prcm_offs: the address offset from CM_BASE/PRM_BASE
 * @pwrsts: Possible powerdomain power states
 * @pwrsts_logic_ret: Possible logic power states when pwrdm in RETENTION
 * @flags: Powerdomain flags
 * @banks: Number of software-controllable memory banks in this powerdomain
 * @pwrsts_mem_ret: Possible memory bank pwrstates when pwrdm in RETENTION
 * @pwrsts_mem_on: Possible memory bank pwrstates when pwrdm in ON
 * @pwrdm_clkdms: Clockdomains in this powerdomain
 * @node: list_head linking all powerdomains
 * @state:
 * @state_counter:
 * @timer:
 * @state_timer:
 */
97 98 99
struct powerdomain {
	const char *name;
	const struct omap_chip_id omap_chip;
100
	const s16 prcm_offs;
101 102
	const u8 pwrsts;
	const u8 pwrsts_logic_ret;
103
	const u8 flags;
104 105 106
	const u8 banks;
	const u8 pwrsts_mem_ret[PWRDM_MAX_MEM_BANKS];
	const u8 pwrsts_mem_on[PWRDM_MAX_MEM_BANKS];
107
	struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS];
108
	struct list_head node;
109
	int state;
110
	unsigned state_counter[PWRDM_MAX_PWRSTS];
111 112
	unsigned ret_logic_off_counter;
	unsigned ret_mem_off_counter[PWRDM_MAX_MEM_BANKS];
113 114 115

#ifdef CONFIG_PM_DEBUG
	s64 timer;
116
	s64 state_timer[PWRDM_MAX_PWRSTS];
117
#endif
118 119 120 121 122 123 124
};


void pwrdm_init(struct powerdomain **pwrdm_list);

struct powerdomain *pwrdm_lookup(const char *name);

125 126
int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user),
			void *user);
127 128
int pwrdm_for_each_nolock(int (*fn)(struct powerdomain *pwrdm, void *user),
			void *user);
129

130 131 132 133 134 135
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));

136 137 138 139
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);
140
int pwrdm_read_pwrst(struct powerdomain *pwrdm);
141 142 143 144 145 146 147 148 149
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);
150
int pwrdm_read_logic_retst(struct powerdomain *pwrdm);
151 152
int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
153
int pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank);
154

155 156 157 158
int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm);
int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm);
bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm);

159 160
int pwrdm_wait_transition(struct powerdomain *pwrdm);

161 162 163 164
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);
165
int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm);
166

167
#endif