OMAP2+: PM: idle clkdms only if already in idle
[deliverable/linux.git] / arch / arm / mach-omap2 / 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.
570b54c7 7 * Copyright (C) 2008-2011 Nokia Corporation
d459bfe0 8 *
dc0b3a70 9 * Paul Walmsley
d459bfe0
PW
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
1540f214
PW
16#ifndef __ARCH_ARM_MACH_OMAP2_CLOCKDOMAIN_H
17#define __ARCH_ARM_MACH_OMAP2_CLOCKDOMAIN_H
d459bfe0 18
dc0b3a70
PW
19#include <linux/init.h>
20
72e06d08 21#include "powerdomain.h"
ce491cf8 22#include <plat/clock.h>
113a7413 23#include <plat/omap_hwmod.h>
ce491cf8 24#include <plat/cpu.h>
d459bfe0 25
570b54c7
PW
26/*
27 * Clockdomain flags
28 *
29 * XXX Document CLKDM_CAN_* flags
30 *
31 * CLKDM_NO_AUTODEPS: Prevent "autodeps" from being added/removed from this
32 * clockdomain. (Currently, this applies to OMAP3 clockdomains only.)
33 */
d459bfe0
PW
34#define CLKDM_CAN_FORCE_SLEEP (1 << 0)
35#define CLKDM_CAN_FORCE_WAKEUP (1 << 1)
36#define CLKDM_CAN_ENABLE_AUTO (1 << 2)
37#define CLKDM_CAN_DISABLE_AUTO (1 << 3)
570b54c7 38#define CLKDM_NO_AUTODEPS (1 << 4)
d459bfe0
PW
39
40#define CLKDM_CAN_HWSUP (CLKDM_CAN_ENABLE_AUTO | CLKDM_CAN_DISABLE_AUTO)
41#define CLKDM_CAN_SWSUP (CLKDM_CAN_FORCE_SLEEP | CLKDM_CAN_FORCE_WAKEUP)
42#define CLKDM_CAN_HWSUP_SWSUP (CLKDM_CAN_SWSUP | CLKDM_CAN_HWSUP)
43
f0271d65
PW
44/**
45 * struct clkdm_autodep - clkdm deps to add when entering/exiting hwsup mode
46 * @clkdm: clockdomain to add wkdep+sleepdep on - set name member only
47 * @omap_chip: OMAP chip types that this autodep is valid on
48 *
49 * A clockdomain that should have wkdeps and sleepdeps added when a
50 * clockdomain should stay active in hwsup mode; and conversely,
51 * removed when the clockdomain should be allowed to go inactive in
52 * hwsup mode.
53 *
54 * Autodeps are deprecated and should be removed after
55 * omap_hwmod-based fine-grained module idle control is added.
d459bfe0 56 */
55ed9694 57struct clkdm_autodep {
5b74c676 58 union {
5b74c676 59 const char *name;
55ed9694
PW
60 struct clockdomain *ptr;
61 } clkdm;
d459bfe0 62 const struct omap_chip_id omap_chip;
d459bfe0
PW
63};
64
f0271d65
PW
65/**
66 * struct clkdm_dep - encode dependencies between clockdomains
67 * @clkdm_name: clockdomain name
68 * @clkdm: pointer to the struct clockdomain of @clkdm_name
69 * @omap_chip: OMAP chip types that this dependency is valid on
70 * @wkdep_usecount: Number of wakeup dependencies causing this clkdm to wake
71 * @sleepdep_usecount: Number of sleep deps that could prevent clkdm from idle
72 *
73 * Statically defined. @clkdm is resolved from @clkdm_name at runtime and
74 * should not be pre-initialized.
75 *
76 * XXX Should also include hardware (fixed) dependencies.
77 */
55ed9694 78struct clkdm_dep {
55ed9694 79 const char *clkdm_name;
55ed9694 80 struct clockdomain *clkdm;
369d5614 81 atomic_t wkdep_usecount;
369d5614 82 atomic_t sleepdep_usecount;
55ed9694 83 const struct omap_chip_id omap_chip;
55ed9694
PW
84};
85
32a363c0
PW
86/* Possible flags for struct clockdomain._flags */
87#define _CLKDM_FLAG_HWSUP_ENABLED BIT(0)
88
f0271d65
PW
89/**
90 * struct clockdomain - OMAP clockdomain
91 * @name: clockdomain name
92 * @pwrdm: powerdomain containing this clockdomain
93 * @clktrctrl_reg: CLKSTCTRL reg for the given clock domain
94 * @clktrctrl_mask: CLKTRCTRL/AUTOSTATE field mask in CM_CLKSTCTRL reg
95 * @flags: Clockdomain capability flags
32a363c0 96 * @_flags: Flags for use only by internal clockdomain code
f0271d65 97 * @dep_bit: Bit shift of this clockdomain's PM_WKDEP/CM_SLEEPDEP bit
bd2122ca
PW
98 * @prcm_partition: (OMAP4 only) PRCM partition ID for this clkdm's registers
99 * @cm_inst: (OMAP4 only) CM instance register offset
100 * @clkdm_offs: (OMAP4 only) CM clockdomain register offset
f0271d65
PW
101 * @wkdep_srcs: Clockdomains that can be told to wake this powerdomain up
102 * @sleepdep_srcs: Clockdomains that can be told to keep this clkdm from inact
103 * @omap_chip: OMAP chip types that this clockdomain is valid on
104 * @usecount: Usecount tracking
105 * @node: list_head to link all clockdomains together
bd2122ca
PW
106 *
107 * @prcm_partition should be a macro from mach-omap2/prcm44xx.h (OMAP4 only)
108 * @cm_inst should be a macro ending in _INST from the OMAP4 CM instance
109 * definitions (OMAP4 only)
110 * @clkdm_offs should be a macro ending in _CDOFFS from the OMAP4 CM instance
111 * definitions (OMAP4 only)
f0271d65 112 */
d459bfe0 113struct clockdomain {
d459bfe0 114 const char *name;
5b74c676 115 union {
5b74c676 116 const char *name;
5b74c676
PW
117 struct powerdomain *ptr;
118 } pwrdm;
d459bfe0 119 const u16 clktrctrl_mask;
d459bfe0 120 const u8 flags;
32a363c0 121 u8 _flags;
55ed9694 122 const u8 dep_bit;
bd2122ca
PW
123 const u8 prcm_partition;
124 const s16 cm_inst;
125 const u16 clkdm_offs;
55ed9694 126 struct clkdm_dep *wkdep_srcs;
55ed9694 127 struct clkdm_dep *sleepdep_srcs;
d459bfe0 128 const struct omap_chip_id omap_chip;
d459bfe0 129 atomic_t usecount;
d459bfe0 130 struct list_head node;
d459bfe0
PW
131};
132
32d4034e 133/**
25985edc 134 * struct clkdm_ops - Arch specific function implementations
32d4034e
RN
135 * @clkdm_add_wkdep: Add a wakeup dependency between clk domains
136 * @clkdm_del_wkdep: Delete a wakeup dependency between clk domains
137 * @clkdm_read_wkdep: Read wakeup dependency state between clk domains
138 * @clkdm_clear_all_wkdeps: Remove all wakeup dependencies from the clk domain
139 * @clkdm_add_sleepdep: Add a sleep dependency between clk domains
140 * @clkdm_del_sleepdep: Delete a sleep dependency between clk domains
141 * @clkdm_read_sleepdep: Read sleep dependency state between clk domains
142 * @clkdm_clear_all_sleepdeps: Remove all sleep dependencies from the clk domain
143 * @clkdm_sleep: Force a clockdomain to sleep
144 * @clkdm_wakeup: Force a clockdomain to wakeup
145 * @clkdm_allow_idle: Enable hw supervised idle transitions for clock domain
146 * @clkdm_deny_idle: Disable hw supervised idle transitions for clock domain
147 * @clkdm_clk_enable: Put the clkdm in right state for a clock enable
148 * @clkdm_clk_disable: Put the clkdm in right state for a clock disable
149 */
150struct clkdm_ops {
151 int (*clkdm_add_wkdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
152 int (*clkdm_del_wkdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
153 int (*clkdm_read_wkdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
154 int (*clkdm_clear_all_wkdeps)(struct clockdomain *clkdm);
155 int (*clkdm_add_sleepdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
156 int (*clkdm_del_sleepdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
157 int (*clkdm_read_sleepdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
158 int (*clkdm_clear_all_sleepdeps)(struct clockdomain *clkdm);
159 int (*clkdm_sleep)(struct clockdomain *clkdm);
160 int (*clkdm_wakeup)(struct clockdomain *clkdm);
161 void (*clkdm_allow_idle)(struct clockdomain *clkdm);
162 void (*clkdm_deny_idle)(struct clockdomain *clkdm);
163 int (*clkdm_clk_enable)(struct clockdomain *clkdm);
164 int (*clkdm_clk_disable)(struct clockdomain *clkdm);
165};
166
167void clkdm_init(struct clockdomain **clkdms, struct clkdm_autodep *autodeps,
168 struct clkdm_ops *custom_funcs);
d459bfe0
PW
169struct clockdomain *clkdm_lookup(const char *name);
170
a23456e9
PDS
171int clkdm_for_each(int (*fn)(struct clockdomain *clkdm, void *user),
172 void *user);
d459bfe0
PW
173struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm);
174
55ed9694
PW
175int clkdm_add_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
176int clkdm_del_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
177int clkdm_read_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
369d5614 178int clkdm_clear_all_wkdeps(struct clockdomain *clkdm);
55ed9694
PW
179int clkdm_add_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
180int clkdm_del_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
181int clkdm_read_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
369d5614 182int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm);
55ed9694 183
5cd1937b
RN
184void clkdm_allow_idle(struct clockdomain *clkdm);
185void clkdm_deny_idle(struct clockdomain *clkdm);
32a363c0 186bool clkdm_in_hwsup(struct clockdomain *clkdm);
d459bfe0 187
68b921ad
RN
188int clkdm_wakeup(struct clockdomain *clkdm);
189int clkdm_sleep(struct clockdomain *clkdm);
d459bfe0 190
4da71ae6
RN
191int clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk);
192int clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk);
113a7413
BC
193int clkdm_hwmod_enable(struct clockdomain *clkdm, struct omap_hwmod *oh);
194int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh);
d459bfe0 195
4aef7a2a
RN
196extern void __init omap2xxx_clockdomains_init(void);
197extern void __init omap3xxx_clockdomains_init(void);
dc0b3a70 198extern void __init omap44xx_clockdomains_init(void);
5cd1937b
RN
199extern void _clkdm_add_autodeps(struct clockdomain *clkdm);
200extern void _clkdm_del_autodeps(struct clockdomain *clkdm);
dc0b3a70 201
4aef7a2a
RN
202extern struct clkdm_ops omap2_clkdm_operations;
203extern struct clkdm_ops omap3_clkdm_operations;
68b921ad 204extern struct clkdm_ops omap4_clkdm_operations;
dc0b3a70 205
d459bfe0 206#endif
This page took 0.232256 seconds and 5 git commands to generate.