OMAP powerdomain: remove pwrdm_clk_state_switch
[linux-block.git] / arch / arm / plat-omap / include / plat / clockdomain.h
CommitLineData
d459bfe0 1/*
5b74c676 2 * arch/arm/plat-omap/include/mach/clockdomain.h
d459bfe0
PW
3 *
4 * OMAP2/3 clockdomain framework functions
5 *
6 * Copyright (C) 2008 Texas Instruments, Inc.
55ed9694 7 * Copyright (C) 2008-2009 Nokia Corporation
d459bfe0
PW
8 *
9 * Written by Paul Walmsley
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#ifndef __ASM_ARM_ARCH_OMAP_CLOCKDOMAIN_H
17#define __ASM_ARM_ARCH_OMAP_CLOCKDOMAIN_H
18
ce491cf8
TL
19#include <plat/powerdomain.h>
20#include <plat/clock.h>
21#include <plat/cpu.h>
d459bfe0
PW
22
23/* Clockdomain capability flags */
24#define CLKDM_CAN_FORCE_SLEEP (1 << 0)
25#define CLKDM_CAN_FORCE_WAKEUP (1 << 1)
26#define CLKDM_CAN_ENABLE_AUTO (1 << 2)
27#define CLKDM_CAN_DISABLE_AUTO (1 << 3)
28
29#define CLKDM_CAN_HWSUP (CLKDM_CAN_ENABLE_AUTO | CLKDM_CAN_DISABLE_AUTO)
30#define CLKDM_CAN_SWSUP (CLKDM_CAN_FORCE_SLEEP | CLKDM_CAN_FORCE_WAKEUP)
31#define CLKDM_CAN_HWSUP_SWSUP (CLKDM_CAN_SWSUP | CLKDM_CAN_HWSUP)
32
33/* OMAP24XX CM_CLKSTCTRL_*.AUTOSTATE_* register bit values */
34#define OMAP24XX_CLKSTCTRL_DISABLE_AUTO 0x0
35#define OMAP24XX_CLKSTCTRL_ENABLE_AUTO 0x1
36
37/* OMAP3XXX CM_CLKSTCTRL_*.CLKTRCTRL_* register bit values */
38#define OMAP34XX_CLKSTCTRL_DISABLE_AUTO 0x0
39#define OMAP34XX_CLKSTCTRL_FORCE_SLEEP 0x1
40#define OMAP34XX_CLKSTCTRL_FORCE_WAKEUP 0x2
41#define OMAP34XX_CLKSTCTRL_ENABLE_AUTO 0x3
42
43/*
55ed9694
PW
44 * struct clkdm_autodep - a clockdomain that should have wkdeps
45 * and sleepdeps added when a clockdomain should stay active in hwsup mode;
46 * and conversely, removed when the clockdomain should be allowed to go
d459bfe0
PW
47 * inactive in hwsup mode.
48 */
55ed9694 49struct clkdm_autodep {
d459bfe0 50
5b74c676 51 union {
55ed9694 52 /* Name of the clockdomain to add a wkdep/sleepdep on */
5b74c676 53 const char *name;
d459bfe0 54
55ed9694
PW
55 /* Clockdomain pointer (looked up at clkdm_init() time) */
56 struct clockdomain *ptr;
57 } clkdm;
d459bfe0
PW
58
59 /* OMAP chip types that this clockdomain dep is valid on */
60 const struct omap_chip_id omap_chip;
61
62};
63
55ed9694
PW
64/* Encodes dependencies between clockdomains - statically defined */
65struct clkdm_dep {
66
67 /* Clockdomain name */
68 const char *clkdm_name;
69
70 /* Clockdomain pointer - resolved by the clockdomain code */
71 struct clockdomain *clkdm;
72
369d5614
PW
73 /* Number of wakeup dependencies causing this clkdm to wake */
74 atomic_t wkdep_usecount;
75
76 /* Number of sleep dependencies that could prevent clkdm from idle */
77 atomic_t sleepdep_usecount;
78
55ed9694
PW
79 /* Flags to mark OMAP chip restrictions, etc. */
80 const struct omap_chip_id omap_chip;
81
82};
83
d459bfe0
PW
84struct clockdomain {
85
86 /* Clockdomain name */
87 const char *name;
88
5b74c676
PW
89 union {
90 /* Powerdomain enclosing this clockdomain */
91 const char *name;
92
93 /* Powerdomain pointer assigned at clkdm_register() */
94 struct powerdomain *ptr;
95 } pwrdm;
d459bfe0 96
84c0c39a
AP
97 /* CLKSTCTRL reg for the given clock domain*/
98 void __iomem *clkstctrl_reg;
99
d459bfe0
PW
100 /* CLKTRCTRL/AUTOSTATE field mask in CM_CLKSTCTRL reg */
101 const u16 clktrctrl_mask;
102
103 /* Clockdomain capability flags */
104 const u8 flags;
105
55ed9694
PW
106 /* Bit shift of this clockdomain's PM_WKDEP/CM_SLEEPDEP bit */
107 const u8 dep_bit;
108
109 /* Clockdomains that can be told to wake this powerdomain up */
110 struct clkdm_dep *wkdep_srcs;
111
112 /* Clockdomains that can be told to keep this clkdm from inactivity */
113 struct clkdm_dep *sleepdep_srcs;
114
d459bfe0
PW
115 /* OMAP chip types that this clockdomain is valid on */
116 const struct omap_chip_id omap_chip;
117
118 /* Usecount tracking */
119 atomic_t usecount;
120
d459bfe0
PW
121 struct list_head node;
122
123};
124
55ed9694 125void clkdm_init(struct clockdomain **clkdms, struct clkdm_autodep *autodeps);
d459bfe0
PW
126struct clockdomain *clkdm_lookup(const char *name);
127
a23456e9
PDS
128int clkdm_for_each(int (*fn)(struct clockdomain *clkdm, void *user),
129 void *user);
d459bfe0
PW
130struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm);
131
55ed9694
PW
132int clkdm_add_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
133int clkdm_del_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
134int clkdm_read_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
369d5614 135int clkdm_clear_all_wkdeps(struct clockdomain *clkdm);
55ed9694
PW
136int clkdm_add_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
137int clkdm_del_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
138int clkdm_read_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
369d5614 139int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm);
55ed9694 140
d459bfe0
PW
141void omap2_clkdm_allow_idle(struct clockdomain *clkdm);
142void omap2_clkdm_deny_idle(struct clockdomain *clkdm);
143
144int omap2_clkdm_wakeup(struct clockdomain *clkdm);
145int omap2_clkdm_sleep(struct clockdomain *clkdm);
146
147int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk);
148int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk);
149
150#endif