]>
Commit | Line | Data |
---|---|---|
ad67ef68 PW |
1 | /* |
2 | * OMAP2/3 powerdomain control | |
3 | * | |
55ed9694 PW |
4 | * Copyright (C) 2007-2008 Texas Instruments, Inc. |
5 | * Copyright (C) 2007-2009 Nokia Corporation | |
ad67ef68 PW |
6 | * |
7 | * Written by Paul Walmsley | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License version 2 as | |
11 | * published by the Free Software Foundation. | |
12 | */ | |
13 | ||
14 | #ifndef ASM_ARM_ARCH_OMAP_POWERDOMAIN | |
15 | #define ASM_ARM_ARCH_OMAP_POWERDOMAIN | |
16 | ||
17 | #include <linux/types.h> | |
18 | #include <linux/list.h> | |
19 | ||
20 | #include <asm/atomic.h> | |
21 | ||
ce491cf8 | 22 | #include <plat/cpu.h> |
ad67ef68 PW |
23 | |
24 | ||
25 | /* Powerdomain basic power states */ | |
26 | #define PWRDM_POWER_OFF 0x0 | |
27 | #define PWRDM_POWER_RET 0x1 | |
28 | #define PWRDM_POWER_INACTIVE 0x2 | |
29 | #define PWRDM_POWER_ON 0x3 | |
30 | ||
2354eb5a PW |
31 | #define PWRDM_MAX_PWRSTS 4 |
32 | ||
ad67ef68 PW |
33 | /* Powerdomain allowable state bitfields */ |
34 | #define PWRSTS_OFF_ON ((1 << PWRDM_POWER_OFF) | \ | |
35 | (1 << PWRDM_POWER_ON)) | |
36 | ||
37 | #define PWRSTS_OFF_RET ((1 << PWRDM_POWER_OFF) | \ | |
38 | (1 << PWRDM_POWER_RET)) | |
39 | ||
f37c6dfa AP |
40 | #define PWRSTS_RET_ON ((1 << PWRDM_POWER_RET) | \ |
41 | (1 << PWRDM_POWER_ON)) | |
42 | ||
ad67ef68 PW |
43 | #define PWRSTS_OFF_RET_ON (PWRSTS_OFF_RET | (1 << PWRDM_POWER_ON)) |
44 | ||
45 | ||
0b7cbfb5 PW |
46 | /* Powerdomain flags */ |
47 | #define PWRDM_HAS_HDWR_SAR (1 << 0) /* hardware save-and-restore support */ | |
3863c74b TG |
48 | #define PWRDM_HAS_MPU_QUIRK (1 << 1) /* MPU pwr domain has MEM bank 0 bits |
49 | * in MEM bank 1 position. This is | |
50 | * true for OMAP3430 | |
51 | */ | |
0b7cbfb5 | 52 | |
ad67ef68 | 53 | /* |
38900c27 AP |
54 | * Number of memory banks that are power-controllable. On OMAP4430, the |
55 | * maximum is 5. | |
ad67ef68 | 56 | */ |
38900c27 | 57 | #define PWRDM_MAX_MEM_BANKS 5 |
ad67ef68 | 58 | |
8420bb13 PW |
59 | /* |
60 | * Maximum number of clockdomains that can be associated with a powerdomain. | |
38900c27 | 61 | * CORE powerdomain on OMAP4 is the worst case |
8420bb13 | 62 | */ |
38900c27 | 63 | #define PWRDM_MAX_CLKDMS 9 |
8420bb13 | 64 | |
ad67ef68 PW |
65 | /* XXX A completely arbitrary number. What is reasonable here? */ |
66 | #define PWRDM_TRANSITION_BAILOUT 100000 | |
67 | ||
8420bb13 | 68 | struct clockdomain; |
ad67ef68 PW |
69 | struct powerdomain; |
70 | ||
f0271d65 PW |
71 | /** |
72 | * struct powerdomain - OMAP powerdomain | |
73 | * @name: Powerdomain name | |
74 | * @omap_chip: represents the OMAP chip types containing this pwrdm | |
75 | * @prcm_offs: the address offset from CM_BASE/PRM_BASE | |
76 | * @pwrsts: Possible powerdomain power states | |
77 | * @pwrsts_logic_ret: Possible logic power states when pwrdm in RETENTION | |
78 | * @flags: Powerdomain flags | |
79 | * @banks: Number of software-controllable memory banks in this powerdomain | |
80 | * @pwrsts_mem_ret: Possible memory bank pwrstates when pwrdm in RETENTION | |
81 | * @pwrsts_mem_on: Possible memory bank pwrstates when pwrdm in ON | |
82 | * @pwrdm_clkdms: Clockdomains in this powerdomain | |
83 | * @node: list_head linking all powerdomains | |
84 | * @state: | |
85 | * @state_counter: | |
86 | * @timer: | |
87 | * @state_timer: | |
88 | */ | |
ad67ef68 | 89 | struct powerdomain { |
ad67ef68 | 90 | const char *name; |
ad67ef68 | 91 | const struct omap_chip_id omap_chip; |
e0594b44 | 92 | const s16 prcm_offs; |
ad67ef68 | 93 | const u8 pwrsts; |
ad67ef68 | 94 | const u8 pwrsts_logic_ret; |
0b7cbfb5 | 95 | const u8 flags; |
ad67ef68 | 96 | const u8 banks; |
ad67ef68 | 97 | const u8 pwrsts_mem_ret[PWRDM_MAX_MEM_BANKS]; |
ad67ef68 | 98 | const u8 pwrsts_mem_on[PWRDM_MAX_MEM_BANKS]; |
8420bb13 | 99 | struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS]; |
ad67ef68 | 100 | struct list_head node; |
ba20bb12 | 101 | int state; |
2354eb5a | 102 | unsigned state_counter[PWRDM_MAX_PWRSTS]; |
331b93f4 PDS |
103 | |
104 | #ifdef CONFIG_PM_DEBUG | |
105 | s64 timer; | |
2354eb5a | 106 | s64 state_timer[PWRDM_MAX_PWRSTS]; |
331b93f4 | 107 | #endif |
ad67ef68 PW |
108 | }; |
109 | ||
110 | ||
111 | void pwrdm_init(struct powerdomain **pwrdm_list); | |
112 | ||
ad67ef68 PW |
113 | struct powerdomain *pwrdm_lookup(const char *name); |
114 | ||
a23456e9 PDS |
115 | int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user), |
116 | void *user); | |
ee894b18 AB |
117 | int pwrdm_for_each_nolock(int (*fn)(struct powerdomain *pwrdm, void *user), |
118 | void *user); | |
ad67ef68 | 119 | |
8420bb13 PW |
120 | int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm); |
121 | int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm); | |
122 | int pwrdm_for_each_clkdm(struct powerdomain *pwrdm, | |
123 | int (*fn)(struct powerdomain *pwrdm, | |
124 | struct clockdomain *clkdm)); | |
125 | ||
ad67ef68 PW |
126 | int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm); |
127 | ||
128 | int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst); | |
129 | int pwrdm_read_next_pwrst(struct powerdomain *pwrdm); | |
fecb494b | 130 | int pwrdm_read_pwrst(struct powerdomain *pwrdm); |
ad67ef68 PW |
131 | int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm); |
132 | int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm); | |
133 | ||
134 | int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst); | |
135 | int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst); | |
136 | int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst); | |
137 | ||
138 | int pwrdm_read_logic_pwrst(struct powerdomain *pwrdm); | |
139 | int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm); | |
1e3d0d2b | 140 | int pwrdm_read_logic_retst(struct powerdomain *pwrdm); |
ad67ef68 PW |
141 | int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank); |
142 | int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank); | |
1e3d0d2b | 143 | int pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank); |
ad67ef68 | 144 | |
0b7cbfb5 PW |
145 | int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm); |
146 | int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm); | |
147 | bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm); | |
148 | ||
ad67ef68 PW |
149 | int pwrdm_wait_transition(struct powerdomain *pwrdm); |
150 | ||
ba20bb12 PDS |
151 | int pwrdm_state_switch(struct powerdomain *pwrdm); |
152 | int pwrdm_clkdm_state_switch(struct clockdomain *clkdm); | |
153 | int pwrdm_pre_transition(void); | |
154 | int pwrdm_post_transition(void); | |
155 | ||
ad67ef68 | 156 | #endif |