HID: wiimote: Select INPUT_FF_MEMLESS
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-omap2 / clockdomain2xxx_3xxx.c
bloba0d68dbecfa3bb96cd52226b0f8d7965379d1252
1 /*
2 * OMAP2 and OMAP3 clockdomain control
4 * Copyright (C) 2008-2010 Texas Instruments, Inc.
5 * Copyright (C) 2008-2010 Nokia Corporation
7 * Derived from mach-omap2/clockdomain.c written by Paul Walmsley
8 * Rajendra Nayak <rnayak@ti.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/types.h>
16 #include <plat/prcm.h>
17 #include "prm.h"
18 #include "prm2xxx_3xxx.h"
19 #include "cm.h"
20 #include "cm2xxx_3xxx.h"
21 #include "cm-regbits-24xx.h"
22 #include "cm-regbits-34xx.h"
23 #include "prm-regbits-24xx.h"
24 #include "clockdomain.h"
26 static int omap2_clkdm_add_wkdep(struct clockdomain *clkdm1,
27 struct clockdomain *clkdm2)
29 omap2_prm_set_mod_reg_bits((1 << clkdm2->dep_bit),
30 clkdm1->pwrdm.ptr->prcm_offs, PM_WKDEP);
31 return 0;
34 static int omap2_clkdm_del_wkdep(struct clockdomain *clkdm1,
35 struct clockdomain *clkdm2)
37 omap2_prm_clear_mod_reg_bits((1 << clkdm2->dep_bit),
38 clkdm1->pwrdm.ptr->prcm_offs, PM_WKDEP);
39 return 0;
42 static int omap2_clkdm_read_wkdep(struct clockdomain *clkdm1,
43 struct clockdomain *clkdm2)
45 return omap2_prm_read_mod_bits_shift(clkdm1->pwrdm.ptr->prcm_offs,
46 PM_WKDEP, (1 << clkdm2->dep_bit));
49 static int omap2_clkdm_clear_all_wkdeps(struct clockdomain *clkdm)
51 struct clkdm_dep *cd;
52 u32 mask = 0;
54 for (cd = clkdm->wkdep_srcs; cd && cd->clkdm_name; cd++) {
55 if (!cd->clkdm)
56 continue; /* only happens if data is erroneous */
58 /* PRM accesses are slow, so minimize them */
59 mask |= 1 << cd->clkdm->dep_bit;
60 atomic_set(&cd->wkdep_usecount, 0);
63 omap2_prm_clear_mod_reg_bits(mask, clkdm->pwrdm.ptr->prcm_offs,
64 PM_WKDEP);
65 return 0;
68 static int omap3_clkdm_add_sleepdep(struct clockdomain *clkdm1,
69 struct clockdomain *clkdm2)
71 omap2_cm_set_mod_reg_bits((1 << clkdm2->dep_bit),
72 clkdm1->pwrdm.ptr->prcm_offs,
73 OMAP3430_CM_SLEEPDEP);
74 return 0;
77 static int omap3_clkdm_del_sleepdep(struct clockdomain *clkdm1,
78 struct clockdomain *clkdm2)
80 omap2_cm_clear_mod_reg_bits((1 << clkdm2->dep_bit),
81 clkdm1->pwrdm.ptr->prcm_offs,
82 OMAP3430_CM_SLEEPDEP);
83 return 0;
86 static int omap3_clkdm_read_sleepdep(struct clockdomain *clkdm1,
87 struct clockdomain *clkdm2)
89 return omap2_prm_read_mod_bits_shift(clkdm1->pwrdm.ptr->prcm_offs,
90 OMAP3430_CM_SLEEPDEP, (1 << clkdm2->dep_bit));
93 static int omap3_clkdm_clear_all_sleepdeps(struct clockdomain *clkdm)
95 struct clkdm_dep *cd;
96 u32 mask = 0;
98 for (cd = clkdm->sleepdep_srcs; cd && cd->clkdm_name; cd++) {
99 if (!cd->clkdm)
100 continue; /* only happens if data is erroneous */
102 /* PRM accesses are slow, so minimize them */
103 mask |= 1 << cd->clkdm->dep_bit;
104 atomic_set(&cd->sleepdep_usecount, 0);
106 omap2_prm_clear_mod_reg_bits(mask, clkdm->pwrdm.ptr->prcm_offs,
107 OMAP3430_CM_SLEEPDEP);
108 return 0;
111 static int omap2_clkdm_sleep(struct clockdomain *clkdm)
113 omap2_cm_set_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
114 clkdm->pwrdm.ptr->prcm_offs,
115 OMAP2_PM_PWSTCTRL);
116 return 0;
119 static int omap2_clkdm_wakeup(struct clockdomain *clkdm)
121 omap2_cm_clear_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
122 clkdm->pwrdm.ptr->prcm_offs,
123 OMAP2_PM_PWSTCTRL);
124 return 0;
127 static void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
129 if (atomic_read(&clkdm->usecount) > 0)
130 _clkdm_add_autodeps(clkdm);
132 omap2xxx_cm_clkdm_enable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
133 clkdm->clktrctrl_mask);
136 static void omap2_clkdm_deny_idle(struct clockdomain *clkdm)
138 omap2xxx_cm_clkdm_disable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
139 clkdm->clktrctrl_mask);
141 if (atomic_read(&clkdm->usecount) > 0)
142 _clkdm_del_autodeps(clkdm);
145 static void _enable_hwsup(struct clockdomain *clkdm)
147 if (cpu_is_omap24xx())
148 omap2xxx_cm_clkdm_enable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
149 clkdm->clktrctrl_mask);
150 else if (cpu_is_omap34xx())
151 omap3xxx_cm_clkdm_enable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
152 clkdm->clktrctrl_mask);
155 static void _disable_hwsup(struct clockdomain *clkdm)
157 if (cpu_is_omap24xx())
158 omap2xxx_cm_clkdm_disable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
159 clkdm->clktrctrl_mask);
160 else if (cpu_is_omap34xx())
161 omap3xxx_cm_clkdm_disable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
162 clkdm->clktrctrl_mask);
166 static int omap2_clkdm_clk_enable(struct clockdomain *clkdm)
168 bool hwsup = false;
170 if (!clkdm->clktrctrl_mask)
171 return 0;
173 hwsup = omap2_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs,
174 clkdm->clktrctrl_mask);
176 if (hwsup) {
177 /* Disable HW transitions when we are changing deps */
178 _disable_hwsup(clkdm);
179 _clkdm_add_autodeps(clkdm);
180 _enable_hwsup(clkdm);
181 } else {
182 if (clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)
183 omap2_clkdm_wakeup(clkdm);
186 return 0;
189 static int omap2_clkdm_clk_disable(struct clockdomain *clkdm)
191 bool hwsup = false;
193 if (!clkdm->clktrctrl_mask)
194 return 0;
196 hwsup = omap2_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs,
197 clkdm->clktrctrl_mask);
199 if (hwsup) {
200 /* Disable HW transitions when we are changing deps */
201 _disable_hwsup(clkdm);
202 _clkdm_del_autodeps(clkdm);
203 _enable_hwsup(clkdm);
204 } else {
205 if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP)
206 omap2_clkdm_sleep(clkdm);
209 return 0;
212 static int omap3_clkdm_sleep(struct clockdomain *clkdm)
214 omap3xxx_cm_clkdm_force_sleep(clkdm->pwrdm.ptr->prcm_offs,
215 clkdm->clktrctrl_mask);
216 return 0;
219 static int omap3_clkdm_wakeup(struct clockdomain *clkdm)
221 omap3xxx_cm_clkdm_force_wakeup(clkdm->pwrdm.ptr->prcm_offs,
222 clkdm->clktrctrl_mask);
223 return 0;
226 static void omap3_clkdm_allow_idle(struct clockdomain *clkdm)
228 if (atomic_read(&clkdm->usecount) > 0)
229 _clkdm_add_autodeps(clkdm);
231 omap3xxx_cm_clkdm_enable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
232 clkdm->clktrctrl_mask);
235 static void omap3_clkdm_deny_idle(struct clockdomain *clkdm)
237 omap3xxx_cm_clkdm_disable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
238 clkdm->clktrctrl_mask);
240 if (atomic_read(&clkdm->usecount) > 0)
241 _clkdm_del_autodeps(clkdm);
244 struct clkdm_ops omap2_clkdm_operations = {
245 .clkdm_add_wkdep = omap2_clkdm_add_wkdep,
246 .clkdm_del_wkdep = omap2_clkdm_del_wkdep,
247 .clkdm_read_wkdep = omap2_clkdm_read_wkdep,
248 .clkdm_clear_all_wkdeps = omap2_clkdm_clear_all_wkdeps,
249 .clkdm_sleep = omap2_clkdm_sleep,
250 .clkdm_wakeup = omap2_clkdm_wakeup,
251 .clkdm_allow_idle = omap2_clkdm_allow_idle,
252 .clkdm_deny_idle = omap2_clkdm_deny_idle,
253 .clkdm_clk_enable = omap2_clkdm_clk_enable,
254 .clkdm_clk_disable = omap2_clkdm_clk_disable,
257 struct clkdm_ops omap3_clkdm_operations = {
258 .clkdm_add_wkdep = omap2_clkdm_add_wkdep,
259 .clkdm_del_wkdep = omap2_clkdm_del_wkdep,
260 .clkdm_read_wkdep = omap2_clkdm_read_wkdep,
261 .clkdm_clear_all_wkdeps = omap2_clkdm_clear_all_wkdeps,
262 .clkdm_add_sleepdep = omap3_clkdm_add_sleepdep,
263 .clkdm_del_sleepdep = omap3_clkdm_del_sleepdep,
264 .clkdm_read_sleepdep = omap3_clkdm_read_sleepdep,
265 .clkdm_clear_all_sleepdeps = omap3_clkdm_clear_all_sleepdeps,
266 .clkdm_sleep = omap3_clkdm_sleep,
267 .clkdm_wakeup = omap3_clkdm_wakeup,
268 .clkdm_allow_idle = omap3_clkdm_allow_idle,
269 .clkdm_deny_idle = omap3_clkdm_deny_idle,
270 .clkdm_clk_enable = omap2_clkdm_clk_enable,
271 .clkdm_clk_disable = omap2_clkdm_clk_disable,