blob: e15c7e9da975182c0694360a9dcc54e4d0a43762 [file] [log] [blame]
Paul Walmsleyad67ef62008-08-19 11:08:40 +03001/*
2 * OMAP2/3 powerdomain control
3 *
Paul Walmsley55ed9692010-01-26 20:12:59 -07004 * Copyright (C) 2007-2008 Texas Instruments, Inc.
5 * Copyright (C) 2007-2009 Nokia Corporation
Paul Walmsleyad67ef62008-08-19 11:08:40 +03006 *
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
Tony Lindgrence491cf2009-10-20 09:40:47 -070022#include <plat/cpu.h>
Paul Walmsleyad67ef62008-08-19 11:08:40 +030023
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
Paul Walmsley2354eb52009-12-08 16:33:12 -070031#define PWRDM_MAX_PWRSTS 4
32
Paul Walmsleyad67ef62008-08-19 11:08:40 +030033/* 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
Abhijit Pagaref37c6df2010-01-26 20:12:52 -070040#define PWRSTS_RET_ON ((1 << PWRDM_POWER_RET) | \
41 (1 << PWRDM_POWER_ON))
42
Paul Walmsleyad67ef62008-08-19 11:08:40 +030043#define PWRSTS_OFF_RET_ON (PWRSTS_OFF_RET | (1 << PWRDM_POWER_ON))
44
45
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -060046/* Powerdomain flags */
47#define PWRDM_HAS_HDWR_SAR (1 << 0) /* hardware save-and-restore support */
Thara Gopinath3863c742009-12-08 16:33:15 -070048#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 */
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -060052
Paul Walmsleyad67ef62008-08-19 11:08:40 +030053/*
Abhijit Pagare38900c22010-01-26 20:12:52 -070054 * Number of memory banks that are power-controllable. On OMAP4430, the
55 * maximum is 5.
Paul Walmsleyad67ef62008-08-19 11:08:40 +030056 */
Abhijit Pagare38900c22010-01-26 20:12:52 -070057#define PWRDM_MAX_MEM_BANKS 5
Paul Walmsleyad67ef62008-08-19 11:08:40 +030058
Paul Walmsley8420bb12008-08-19 11:08:44 +030059/*
60 * Maximum number of clockdomains that can be associated with a powerdomain.
Abhijit Pagare38900c22010-01-26 20:12:52 -070061 * CORE powerdomain on OMAP4 is the worst case
Paul Walmsley8420bb12008-08-19 11:08:44 +030062 */
Abhijit Pagare38900c22010-01-26 20:12:52 -070063#define PWRDM_MAX_CLKDMS 9
Paul Walmsley8420bb12008-08-19 11:08:44 +030064
Paul Walmsleyad67ef62008-08-19 11:08:40 +030065/* XXX A completely arbitrary number. What is reasonable here? */
66#define PWRDM_TRANSITION_BAILOUT 100000
67
Paul Walmsley8420bb12008-08-19 11:08:44 +030068struct clockdomain;
Paul Walmsleyad67ef62008-08-19 11:08:40 +030069struct powerdomain;
70
Paul Walmsleyf0271d62010-01-26 20:13:02 -070071/**
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 */
Paul Walmsleyad67ef62008-08-19 11:08:40 +030089struct powerdomain {
Paul Walmsleyad67ef62008-08-19 11:08:40 +030090 const char *name;
Paul Walmsleyad67ef62008-08-19 11:08:40 +030091 const struct omap_chip_id omap_chip;
Paul Walmsleye0594b42010-01-26 20:13:01 -070092 const s16 prcm_offs;
Paul Walmsleyad67ef62008-08-19 11:08:40 +030093 const u8 pwrsts;
Paul Walmsleyad67ef62008-08-19 11:08:40 +030094 const u8 pwrsts_logic_ret;
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -060095 const u8 flags;
Paul Walmsleyad67ef62008-08-19 11:08:40 +030096 const u8 banks;
Paul Walmsleyad67ef62008-08-19 11:08:40 +030097 const u8 pwrsts_mem_ret[PWRDM_MAX_MEM_BANKS];
Paul Walmsleyad67ef62008-08-19 11:08:40 +030098 const u8 pwrsts_mem_on[PWRDM_MAX_MEM_BANKS];
Paul Walmsley8420bb12008-08-19 11:08:44 +030099 struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS];
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300100 struct list_head node;
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300101 int state;
Paul Walmsley2354eb52009-12-08 16:33:12 -0700102 unsigned state_counter[PWRDM_MAX_PWRSTS];
Peter 'p2' De Schrijver331b93f2008-10-15 18:13:48 +0300103
104#ifdef CONFIG_PM_DEBUG
105 s64 timer;
Paul Walmsley2354eb52009-12-08 16:33:12 -0700106 s64 state_timer[PWRDM_MAX_PWRSTS];
Peter 'p2' De Schrijver331b93f2008-10-15 18:13:48 +0300107#endif
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300108};
109
110
111void pwrdm_init(struct powerdomain **pwrdm_list);
112
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300113struct powerdomain *pwrdm_lookup(const char *name);
114
Peter 'p2' De Schrijvera23456e2008-10-15 18:13:47 +0300115int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user),
116 void *user);
Artem Bityutskiyee894b12009-10-01 10:01:55 +0300117int pwrdm_for_each_nolock(int (*fn)(struct powerdomain *pwrdm, void *user),
118 void *user);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300119
Paul Walmsley8420bb12008-08-19 11:08:44 +0300120int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
121int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
122int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
123 int (*fn)(struct powerdomain *pwrdm,
124 struct clockdomain *clkdm));
125
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300126int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
127
128int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
129int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
Paul Walmsleyfecb4942009-01-27 19:12:50 -0700130int pwrdm_read_pwrst(struct powerdomain *pwrdm);
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300131int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm);
132int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm);
133
134int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst);
135int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
136int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
137
138int pwrdm_read_logic_pwrst(struct powerdomain *pwrdm);
139int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm);
140int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
141int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
142
Paul Walmsley0b7cbfb2008-06-25 18:09:37 -0600143int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm);
144int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm);
145bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm);
146
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300147int pwrdm_wait_transition(struct powerdomain *pwrdm);
148
Peter 'p2' De Schrijverba20bb12008-10-15 17:48:43 +0300149int pwrdm_state_switch(struct powerdomain *pwrdm);
150int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);
151int pwrdm_pre_transition(void);
152int pwrdm_post_transition(void);
153
Paul Walmsleyad67ef62008-08-19 11:08:40 +0300154#endif