blob: 96f461682c91d11c65b379c9e3a0979ee6f423c1 [file] [log] [blame]
Tony Lindgrenb824efa2006-04-02 17:46:20 +01001/*
2 * linux/arch/arm/mach-omap2/prcm.c
3 *
4 * OMAP 24xx Power Reset and Clock Management (PRCM) functions
5 *
6 * Copyright (C) 2005 Nokia Corporation
7 *
8 * Written by Tony Lindgren <tony.lindgren@nokia.com>
9 *
Rajendra Nayakc171a252008-09-26 17:48:31 +053010 * Copyright (C) 2007 Texas Instruments, Inc.
11 * Rajendra Nayak <rnayak@ti.com>
12 *
Tony Lindgrenb824efa2006-04-02 17:46:20 +010013 * Some pieces of code Copyright (C) 2005 Texas Instruments, Inc.
Abhijit Pagare37903002010-01-26 20:12:51 -070014 * Upgraded with OMAP4 support by Abhijit Pagare <abhijitpagare@ti.com>
Tony Lindgrenb824efa2006-04-02 17:46:20 +010015 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation.
19 */
Tony Lindgrenb824efa2006-04-02 17:46:20 +010020#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/clk.h>
Tony Lindgrena58caad2008-07-03 12:24:44 +030023#include <linux/io.h>
Paul Walmsley72350b22009-07-24 19:44:03 -060024#include <linux/delay.h>
Tony Lindgrenb824efa2006-04-02 17:46:20 +010025
Tony Lindgrence491cf2009-10-20 09:40:47 -070026#include <plat/common.h>
27#include <plat/prcm.h>
Rajendra Nayakc171a252008-09-26 17:48:31 +053028#include <plat/irqs.h>
29#include <plat/control.h>
Paul Walmsley44595982008-03-18 10:04:51 +020030
Tony Lindgrena58caad2008-07-03 12:24:44 +030031#include "clock.h"
Paul Walmsleyfeec1272010-01-26 20:13:11 -070032#include "clock2xxx.h"
Rajendra Nayakc171a252008-09-26 17:48:31 +053033#include "cm.h"
Paul Walmsley44595982008-03-18 10:04:51 +020034#include "prm.h"
35#include "prm-regbits-24xx.h"
Rajeev Kulkarniff4d3e12010-09-21 10:34:09 -060036#include "prm-regbits-44xx.h"
Tony Lindgrenb824efa2006-04-02 17:46:20 +010037
Tony Lindgrena58caad2008-07-03 12:24:44 +030038static void __iomem *prm_base;
39static void __iomem *cm_base;
Rajendra Nayak9ef89152009-12-08 18:24:49 -070040static void __iomem *cm2_base;
Tony Lindgrena58caad2008-07-03 12:24:44 +030041
Paul Walmsley72350b22009-07-24 19:44:03 -060042#define MAX_MODULE_ENABLE_WAIT 100000
43
Rajendra Nayakc171a252008-09-26 17:48:31 +053044struct omap3_prcm_regs {
45 u32 control_padconf_sys_nirq;
Jouni Hogander133464d2009-02-05 13:34:01 +020046 u32 iva2_cm_clksel1;
Rajendra Nayakc171a252008-09-26 17:48:31 +053047 u32 iva2_cm_clksel2;
48 u32 cm_sysconfig;
49 u32 sgx_cm_clksel;
Rajendra Nayakc171a252008-09-26 17:48:31 +053050 u32 dss_cm_clksel;
51 u32 cam_cm_clksel;
52 u32 per_cm_clksel;
53 u32 emu_cm_clksel;
54 u32 emu_cm_clkstctrl;
55 u32 pll_cm_autoidle2;
56 u32 pll_cm_clksel4;
57 u32 pll_cm_clksel5;
Rajendra Nayakc171a252008-09-26 17:48:31 +053058 u32 pll_cm_clken2;
59 u32 cm_polctrl;
60 u32 iva2_cm_fclken;
61 u32 iva2_cm_clken_pll;
62 u32 core_cm_fclken1;
63 u32 core_cm_fclken3;
64 u32 sgx_cm_fclken;
65 u32 wkup_cm_fclken;
66 u32 dss_cm_fclken;
67 u32 cam_cm_fclken;
68 u32 per_cm_fclken;
69 u32 usbhost_cm_fclken;
70 u32 core_cm_iclken1;
71 u32 core_cm_iclken2;
72 u32 core_cm_iclken3;
73 u32 sgx_cm_iclken;
74 u32 wkup_cm_iclken;
75 u32 dss_cm_iclken;
76 u32 cam_cm_iclken;
77 u32 per_cm_iclken;
78 u32 usbhost_cm_iclken;
79 u32 iva2_cm_autiidle2;
80 u32 mpu_cm_autoidle2;
Rajendra Nayakc171a252008-09-26 17:48:31 +053081 u32 iva2_cm_clkstctrl;
82 u32 mpu_cm_clkstctrl;
83 u32 core_cm_clkstctrl;
84 u32 sgx_cm_clkstctrl;
85 u32 dss_cm_clkstctrl;
86 u32 cam_cm_clkstctrl;
87 u32 per_cm_clkstctrl;
88 u32 neon_cm_clkstctrl;
89 u32 usbhost_cm_clkstctrl;
90 u32 core_cm_autoidle1;
91 u32 core_cm_autoidle2;
92 u32 core_cm_autoidle3;
93 u32 wkup_cm_autoidle;
94 u32 dss_cm_autoidle;
95 u32 cam_cm_autoidle;
96 u32 per_cm_autoidle;
97 u32 usbhost_cm_autoidle;
98 u32 sgx_cm_sleepdep;
99 u32 dss_cm_sleepdep;
100 u32 cam_cm_sleepdep;
101 u32 per_cm_sleepdep;
102 u32 usbhost_cm_sleepdep;
103 u32 cm_clkout_ctrl;
104 u32 prm_clkout_ctrl;
105 u32 sgx_pm_wkdep;
106 u32 dss_pm_wkdep;
107 u32 cam_pm_wkdep;
108 u32 per_pm_wkdep;
109 u32 neon_pm_wkdep;
110 u32 usbhost_pm_wkdep;
111 u32 core_pm_mpugrpsel1;
112 u32 iva2_pm_ivagrpsel1;
113 u32 core_pm_mpugrpsel3;
114 u32 core_pm_ivagrpsel3;
115 u32 wkup_pm_mpugrpsel;
116 u32 wkup_pm_ivagrpsel;
117 u32 per_pm_mpugrpsel;
118 u32 per_pm_ivagrpsel;
119 u32 wkup_pm_wken;
120};
121
122struct omap3_prcm_regs prcm_context;
123
Tony Lindgrenb824efa2006-04-02 17:46:20 +0100124u32 omap_prcm_get_reset_sources(void)
125{
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300126 /* XXX This presumably needs modification for 34XX */
Rajendra Nayak766d3052010-03-31 04:16:30 -0600127 if (cpu_is_omap24xx() || cpu_is_omap34xx())
Abhijit Pagare37903002010-01-26 20:12:51 -0700128 return prm_read_mod_reg(WKUP_MOD, OMAP2_RM_RSTST) & 0x7f;
129 if (cpu_is_omap44xx())
130 return prm_read_mod_reg(WKUP_MOD, OMAP4_RM_RSTST) & 0x7f;
Kevin Hilman0cc93142010-02-24 12:05:56 -0700131
132 return 0;
Tony Lindgrenb824efa2006-04-02 17:46:20 +0100133}
134EXPORT_SYMBOL(omap_prcm_get_reset_sources);
135
136/* Resets clock rates and reboots the system. Only called from system.h */
Aaro Koskinen29b9a212010-02-26 10:25:28 +0000137void omap_prcm_arch_reset(char mode, const char *cmd)
Tony Lindgrenb824efa2006-04-02 17:46:20 +0100138{
Kevin Hilman0cc93142010-02-24 12:05:56 -0700139 s16 prcm_offs = 0;
Paul Walmsley44595982008-03-18 10:04:51 +0200140
Paul Walmsleyfeec1272010-01-26 20:13:11 -0700141 if (cpu_is_omap24xx()) {
142 omap2xxx_clk_prepare_for_reboot();
143
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300144 prcm_offs = WKUP_MOD;
Paul Walmsleyfeec1272010-01-26 20:13:11 -0700145 } else if (cpu_is_omap34xx()) {
Juha Yrjola692ec4a2009-03-09 21:21:01 +0000146 u32 l;
147
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300148 prcm_offs = OMAP3430_GR_MOD;
Aaro Koskinen29b9a212010-02-26 10:25:28 +0000149 l = ('B' << 24) | ('M' << 16) | (cmd ? (u8)*cmd : 0);
Juha Yrjola692ec4a2009-03-09 21:21:01 +0000150 /* Reserve the first word in scratchpad for communicating
151 * with the boot ROM. A pointer to a data structure
152 * describing the boot process can be stored there,
153 * cf. OMAP34xx TRM, Initialization / Software Booting
154 * Configuration. */
155 omap_writel(l, OMAP343X_SCRATCHPAD + 4);
Abhijit Pagare37903002010-01-26 20:12:51 -0700156 } else if (cpu_is_omap44xx())
157 prcm_offs = OMAP4430_PRM_DEVICE_MOD;
158 else
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300159 WARN_ON(1);
160
Rajendra Nayak766d3052010-03-31 04:16:30 -0600161 if (cpu_is_omap24xx() || cpu_is_omap34xx())
Paul Walmsley2fd0f752010-05-18 18:40:23 -0600162 prm_set_mod_reg_bits(OMAP_RST_DPLL3_MASK, prcm_offs,
Abhijit Pagare37903002010-01-26 20:12:51 -0700163 OMAP2_RM_RSTCTRL);
164 if (cpu_is_omap44xx())
Rajeev Kulkarniff4d3e12010-09-21 10:34:09 -0600165 prm_set_mod_reg_bits(OMAP4430_RST_GLOBAL_WARM_SW_MASK,
166 prcm_offs, OMAP4_RM_RSTCTRL);
Tony Lindgrenb824efa2006-04-02 17:46:20 +0100167}
Tony Lindgrena58caad2008-07-03 12:24:44 +0300168
169static inline u32 __omap_prcm_read(void __iomem *base, s16 module, u16 reg)
170{
171 BUG_ON(!base);
172 return __raw_readl(base + module + reg);
173}
174
175static inline void __omap_prcm_write(u32 value, void __iomem *base,
176 s16 module, u16 reg)
177{
178 BUG_ON(!base);
179 __raw_writel(value, base + module + reg);
180}
181
182/* Read a register in a PRM module */
183u32 prm_read_mod_reg(s16 module, u16 idx)
184{
185 return __omap_prcm_read(prm_base, module, idx);
186}
Tony Lindgrena58caad2008-07-03 12:24:44 +0300187
188/* Write into a register in a PRM module */
189void prm_write_mod_reg(u32 val, s16 module, u16 idx)
190{
191 __omap_prcm_write(val, prm_base, module, idx);
192}
Tony Lindgrena58caad2008-07-03 12:24:44 +0300193
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300194/* Read-modify-write a register in a PRM module. Caller must lock */
195u32 prm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
196{
197 u32 v;
198
199 v = prm_read_mod_reg(module, idx);
200 v &= ~mask;
201 v |= bits;
202 prm_write_mod_reg(v, module, idx);
203
204 return v;
205}
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300206
Paul Walmsley55ed9692010-01-26 20:12:59 -0700207/* Read a PRM register, AND it, and shift the result down to bit 0 */
208u32 prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
209{
210 u32 v;
211
212 v = prm_read_mod_reg(domain, idx);
213 v &= mask;
214 v >>= __ffs(mask);
215
216 return v;
217}
218
Tony Lindgrena58caad2008-07-03 12:24:44 +0300219/* Read a register in a CM module */
220u32 cm_read_mod_reg(s16 module, u16 idx)
221{
222 return __omap_prcm_read(cm_base, module, idx);
223}
Tony Lindgrena58caad2008-07-03 12:24:44 +0300224
225/* Write into a register in a CM module */
226void cm_write_mod_reg(u32 val, s16 module, u16 idx)
227{
228 __omap_prcm_write(val, cm_base, module, idx);
229}
Tony Lindgrena58caad2008-07-03 12:24:44 +0300230
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300231/* Read-modify-write a register in a CM module. Caller must lock */
232u32 cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
233{
234 u32 v;
235
236 v = cm_read_mod_reg(module, idx);
237 v &= ~mask;
238 v |= bits;
239 cm_write_mod_reg(v, module, idx);
240
241 return v;
242}
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300243
Paul Walmsley72350b22009-07-24 19:44:03 -0600244/**
245 * omap2_cm_wait_idlest - wait for IDLEST bit to indicate module readiness
246 * @reg: physical address of module IDLEST register
247 * @mask: value to mask against to determine if the module is active
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -0700248 * @idlest: idle state indicator (0 or 1) for the clock
Paul Walmsley72350b22009-07-24 19:44:03 -0600249 * @name: name of the clock (for printk)
250 *
251 * Returns 1 if the module indicated readiness in time, or 0 if it
252 * failed to enable in roughly MAX_MODULE_ENABLE_WAIT microseconds.
253 */
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -0700254int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, u8 idlest,
255 const char *name)
Paul Walmsley72350b22009-07-24 19:44:03 -0600256{
257 int i = 0;
258 int ena = 0;
259
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -0700260 if (idlest)
Paul Walmsley72350b22009-07-24 19:44:03 -0600261 ena = 0;
262 else
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -0700263 ena = mask;
Paul Walmsley72350b22009-07-24 19:44:03 -0600264
265 /* Wait for lock */
Paul Walmsley6f8b7ff2009-12-08 16:33:16 -0700266 omap_test_timeout(((__raw_readl(reg) & mask) == ena),
267 MAX_MODULE_ENABLE_WAIT, i);
Paul Walmsley72350b22009-07-24 19:44:03 -0600268
269 if (i < MAX_MODULE_ENABLE_WAIT)
270 pr_debug("cm: Module associated with clock %s ready after %d "
271 "loops\n", name, i);
272 else
273 pr_err("cm: Module associated with clock %s didn't enable in "
274 "%d tries\n", name, MAX_MODULE_ENABLE_WAIT);
275
276 return (i < MAX_MODULE_ENABLE_WAIT) ? 1 : 0;
277};
278
Tony Lindgrena58caad2008-07-03 12:24:44 +0300279void __init omap2_set_globals_prcm(struct omap_globals *omap2_globals)
280{
Santosh Shilimkarb7ebb102010-02-15 18:03:37 +0530281 /* Static mapping, never released */
282 if (omap2_globals->prm) {
283 prm_base = ioremap(omap2_globals->prm, SZ_8K);
284 WARN_ON(!prm_base);
285 }
286 if (omap2_globals->cm) {
287 cm_base = ioremap(omap2_globals->cm, SZ_8K);
288 WARN_ON(!cm_base);
289 }
290 if (omap2_globals->cm2) {
291 cm2_base = ioremap(omap2_globals->cm2, SZ_8K);
292 WARN_ON(!cm2_base);
293 }
Tony Lindgrena58caad2008-07-03 12:24:44 +0300294}
Rajendra Nayakc171a252008-09-26 17:48:31 +0530295
296#ifdef CONFIG_ARCH_OMAP3
297void omap3_prcm_save_context(void)
298{
299 prcm_context.control_padconf_sys_nirq =
300 omap_ctrl_readl(OMAP343X_CONTROL_PADCONF_SYSNIRQ);
Jouni Hogander133464d2009-02-05 13:34:01 +0200301 prcm_context.iva2_cm_clksel1 =
302 cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_CLKSEL1);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530303 prcm_context.iva2_cm_clksel2 =
304 cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_CLKSEL2);
305 prcm_context.cm_sysconfig = __raw_readl(OMAP3430_CM_SYSCONFIG);
306 prcm_context.sgx_cm_clksel =
307 cm_read_mod_reg(OMAP3430ES2_SGX_MOD, CM_CLKSEL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530308 prcm_context.dss_cm_clksel =
309 cm_read_mod_reg(OMAP3430_DSS_MOD, CM_CLKSEL);
310 prcm_context.cam_cm_clksel =
311 cm_read_mod_reg(OMAP3430_CAM_MOD, CM_CLKSEL);
312 prcm_context.per_cm_clksel =
313 cm_read_mod_reg(OMAP3430_PER_MOD, CM_CLKSEL);
314 prcm_context.emu_cm_clksel =
315 cm_read_mod_reg(OMAP3430_EMU_MOD, CM_CLKSEL1);
316 prcm_context.emu_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700317 cm_read_mod_reg(OMAP3430_EMU_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530318 prcm_context.pll_cm_autoidle2 =
319 cm_read_mod_reg(PLL_MOD, CM_AUTOIDLE2);
320 prcm_context.pll_cm_clksel4 =
321 cm_read_mod_reg(PLL_MOD, OMAP3430ES2_CM_CLKSEL4);
322 prcm_context.pll_cm_clksel5 =
323 cm_read_mod_reg(PLL_MOD, OMAP3430ES2_CM_CLKSEL5);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530324 prcm_context.pll_cm_clken2 =
325 cm_read_mod_reg(PLL_MOD, OMAP3430ES2_CM_CLKEN2);
326 prcm_context.cm_polctrl = __raw_readl(OMAP3430_CM_POLCTRL);
327 prcm_context.iva2_cm_fclken =
328 cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_FCLKEN);
329 prcm_context.iva2_cm_clken_pll = cm_read_mod_reg(OMAP3430_IVA2_MOD,
330 OMAP3430_CM_CLKEN_PLL);
331 prcm_context.core_cm_fclken1 =
332 cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
333 prcm_context.core_cm_fclken3 =
334 cm_read_mod_reg(CORE_MOD, OMAP3430ES2_CM_FCLKEN3);
335 prcm_context.sgx_cm_fclken =
336 cm_read_mod_reg(OMAP3430ES2_SGX_MOD, CM_FCLKEN);
337 prcm_context.wkup_cm_fclken =
338 cm_read_mod_reg(WKUP_MOD, CM_FCLKEN);
339 prcm_context.dss_cm_fclken =
340 cm_read_mod_reg(OMAP3430_DSS_MOD, CM_FCLKEN);
341 prcm_context.cam_cm_fclken =
342 cm_read_mod_reg(OMAP3430_CAM_MOD, CM_FCLKEN);
343 prcm_context.per_cm_fclken =
344 cm_read_mod_reg(OMAP3430_PER_MOD, CM_FCLKEN);
345 prcm_context.usbhost_cm_fclken =
346 cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN);
347 prcm_context.core_cm_iclken1 =
348 cm_read_mod_reg(CORE_MOD, CM_ICLKEN1);
349 prcm_context.core_cm_iclken2 =
350 cm_read_mod_reg(CORE_MOD, CM_ICLKEN2);
351 prcm_context.core_cm_iclken3 =
352 cm_read_mod_reg(CORE_MOD, CM_ICLKEN3);
353 prcm_context.sgx_cm_iclken =
354 cm_read_mod_reg(OMAP3430ES2_SGX_MOD, CM_ICLKEN);
355 prcm_context.wkup_cm_iclken =
356 cm_read_mod_reg(WKUP_MOD, CM_ICLKEN);
357 prcm_context.dss_cm_iclken =
358 cm_read_mod_reg(OMAP3430_DSS_MOD, CM_ICLKEN);
359 prcm_context.cam_cm_iclken =
360 cm_read_mod_reg(OMAP3430_CAM_MOD, CM_ICLKEN);
361 prcm_context.per_cm_iclken =
362 cm_read_mod_reg(OMAP3430_PER_MOD, CM_ICLKEN);
363 prcm_context.usbhost_cm_iclken =
364 cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD, CM_ICLKEN);
365 prcm_context.iva2_cm_autiidle2 =
366 cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_AUTOIDLE2);
367 prcm_context.mpu_cm_autoidle2 =
368 cm_read_mod_reg(MPU_MOD, CM_AUTOIDLE2);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530369 prcm_context.iva2_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700370 cm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530371 prcm_context.mpu_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700372 cm_read_mod_reg(MPU_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530373 prcm_context.core_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700374 cm_read_mod_reg(CORE_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530375 prcm_context.sgx_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700376 cm_read_mod_reg(OMAP3430ES2_SGX_MOD,
377 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530378 prcm_context.dss_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700379 cm_read_mod_reg(OMAP3430_DSS_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530380 prcm_context.cam_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700381 cm_read_mod_reg(OMAP3430_CAM_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530382 prcm_context.per_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700383 cm_read_mod_reg(OMAP3430_PER_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530384 prcm_context.neon_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700385 cm_read_mod_reg(OMAP3430_NEON_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530386 prcm_context.usbhost_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700387 cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD,
388 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530389 prcm_context.core_cm_autoidle1 =
390 cm_read_mod_reg(CORE_MOD, CM_AUTOIDLE1);
391 prcm_context.core_cm_autoidle2 =
392 cm_read_mod_reg(CORE_MOD, CM_AUTOIDLE2);
393 prcm_context.core_cm_autoidle3 =
394 cm_read_mod_reg(CORE_MOD, CM_AUTOIDLE3);
395 prcm_context.wkup_cm_autoidle =
396 cm_read_mod_reg(WKUP_MOD, CM_AUTOIDLE);
397 prcm_context.dss_cm_autoidle =
398 cm_read_mod_reg(OMAP3430_DSS_MOD, CM_AUTOIDLE);
399 prcm_context.cam_cm_autoidle =
400 cm_read_mod_reg(OMAP3430_CAM_MOD, CM_AUTOIDLE);
401 prcm_context.per_cm_autoidle =
402 cm_read_mod_reg(OMAP3430_PER_MOD, CM_AUTOIDLE);
403 prcm_context.usbhost_cm_autoidle =
404 cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD, CM_AUTOIDLE);
405 prcm_context.sgx_cm_sleepdep =
406 cm_read_mod_reg(OMAP3430ES2_SGX_MOD, OMAP3430_CM_SLEEPDEP);
407 prcm_context.dss_cm_sleepdep =
408 cm_read_mod_reg(OMAP3430_DSS_MOD, OMAP3430_CM_SLEEPDEP);
409 prcm_context.cam_cm_sleepdep =
410 cm_read_mod_reg(OMAP3430_CAM_MOD, OMAP3430_CM_SLEEPDEP);
411 prcm_context.per_cm_sleepdep =
412 cm_read_mod_reg(OMAP3430_PER_MOD, OMAP3430_CM_SLEEPDEP);
413 prcm_context.usbhost_cm_sleepdep =
414 cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD, OMAP3430_CM_SLEEPDEP);
415 prcm_context.cm_clkout_ctrl = cm_read_mod_reg(OMAP3430_CCR_MOD,
416 OMAP3_CM_CLKOUT_CTRL_OFFSET);
417 prcm_context.prm_clkout_ctrl = prm_read_mod_reg(OMAP3430_CCR_MOD,
418 OMAP3_PRM_CLKOUT_CTRL_OFFSET);
419 prcm_context.sgx_pm_wkdep =
420 prm_read_mod_reg(OMAP3430ES2_SGX_MOD, PM_WKDEP);
421 prcm_context.dss_pm_wkdep =
422 prm_read_mod_reg(OMAP3430_DSS_MOD, PM_WKDEP);
423 prcm_context.cam_pm_wkdep =
424 prm_read_mod_reg(OMAP3430_CAM_MOD, PM_WKDEP);
425 prcm_context.per_pm_wkdep =
426 prm_read_mod_reg(OMAP3430_PER_MOD, PM_WKDEP);
427 prcm_context.neon_pm_wkdep =
428 prm_read_mod_reg(OMAP3430_NEON_MOD, PM_WKDEP);
429 prcm_context.usbhost_pm_wkdep =
430 prm_read_mod_reg(OMAP3430ES2_USBHOST_MOD, PM_WKDEP);
431 prcm_context.core_pm_mpugrpsel1 =
432 prm_read_mod_reg(CORE_MOD, OMAP3430_PM_MPUGRPSEL1);
433 prcm_context.iva2_pm_ivagrpsel1 =
434 prm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP3430_PM_IVAGRPSEL1);
435 prcm_context.core_pm_mpugrpsel3 =
436 prm_read_mod_reg(CORE_MOD, OMAP3430ES2_PM_MPUGRPSEL3);
437 prcm_context.core_pm_ivagrpsel3 =
438 prm_read_mod_reg(CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3);
439 prcm_context.wkup_pm_mpugrpsel =
440 prm_read_mod_reg(WKUP_MOD, OMAP3430_PM_MPUGRPSEL);
441 prcm_context.wkup_pm_ivagrpsel =
442 prm_read_mod_reg(WKUP_MOD, OMAP3430_PM_IVAGRPSEL);
443 prcm_context.per_pm_mpugrpsel =
444 prm_read_mod_reg(OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL);
445 prcm_context.per_pm_ivagrpsel =
446 prm_read_mod_reg(OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL);
447 prcm_context.wkup_pm_wken = prm_read_mod_reg(WKUP_MOD, PM_WKEN);
448 return;
449}
450
451void omap3_prcm_restore_context(void)
452{
453 omap_ctrl_writel(prcm_context.control_padconf_sys_nirq,
454 OMAP343X_CONTROL_PADCONF_SYSNIRQ);
Jouni Hogander133464d2009-02-05 13:34:01 +0200455 cm_write_mod_reg(prcm_context.iva2_cm_clksel1, OMAP3430_IVA2_MOD,
456 CM_CLKSEL1);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530457 cm_write_mod_reg(prcm_context.iva2_cm_clksel2, OMAP3430_IVA2_MOD,
458 CM_CLKSEL2);
459 __raw_writel(prcm_context.cm_sysconfig, OMAP3430_CM_SYSCONFIG);
460 cm_write_mod_reg(prcm_context.sgx_cm_clksel, OMAP3430ES2_SGX_MOD,
461 CM_CLKSEL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530462 cm_write_mod_reg(prcm_context.dss_cm_clksel, OMAP3430_DSS_MOD,
463 CM_CLKSEL);
464 cm_write_mod_reg(prcm_context.cam_cm_clksel, OMAP3430_CAM_MOD,
465 CM_CLKSEL);
466 cm_write_mod_reg(prcm_context.per_cm_clksel, OMAP3430_PER_MOD,
467 CM_CLKSEL);
468 cm_write_mod_reg(prcm_context.emu_cm_clksel, OMAP3430_EMU_MOD,
469 CM_CLKSEL1);
470 cm_write_mod_reg(prcm_context.emu_cm_clkstctrl, OMAP3430_EMU_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700471 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530472 cm_write_mod_reg(prcm_context.pll_cm_autoidle2, PLL_MOD,
473 CM_AUTOIDLE2);
474 cm_write_mod_reg(prcm_context.pll_cm_clksel4, PLL_MOD,
475 OMAP3430ES2_CM_CLKSEL4);
476 cm_write_mod_reg(prcm_context.pll_cm_clksel5, PLL_MOD,
477 OMAP3430ES2_CM_CLKSEL5);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530478 cm_write_mod_reg(prcm_context.pll_cm_clken2, PLL_MOD,
479 OMAP3430ES2_CM_CLKEN2);
480 __raw_writel(prcm_context.cm_polctrl, OMAP3430_CM_POLCTRL);
481 cm_write_mod_reg(prcm_context.iva2_cm_fclken, OMAP3430_IVA2_MOD,
482 CM_FCLKEN);
483 cm_write_mod_reg(prcm_context.iva2_cm_clken_pll, OMAP3430_IVA2_MOD,
484 OMAP3430_CM_CLKEN_PLL);
485 cm_write_mod_reg(prcm_context.core_cm_fclken1, CORE_MOD, CM_FCLKEN1);
486 cm_write_mod_reg(prcm_context.core_cm_fclken3, CORE_MOD,
487 OMAP3430ES2_CM_FCLKEN3);
488 cm_write_mod_reg(prcm_context.sgx_cm_fclken, OMAP3430ES2_SGX_MOD,
489 CM_FCLKEN);
490 cm_write_mod_reg(prcm_context.wkup_cm_fclken, WKUP_MOD, CM_FCLKEN);
491 cm_write_mod_reg(prcm_context.dss_cm_fclken, OMAP3430_DSS_MOD,
492 CM_FCLKEN);
493 cm_write_mod_reg(prcm_context.cam_cm_fclken, OMAP3430_CAM_MOD,
494 CM_FCLKEN);
495 cm_write_mod_reg(prcm_context.per_cm_fclken, OMAP3430_PER_MOD,
496 CM_FCLKEN);
497 cm_write_mod_reg(prcm_context.usbhost_cm_fclken,
498 OMAP3430ES2_USBHOST_MOD, CM_FCLKEN);
499 cm_write_mod_reg(prcm_context.core_cm_iclken1, CORE_MOD, CM_ICLKEN1);
500 cm_write_mod_reg(prcm_context.core_cm_iclken2, CORE_MOD, CM_ICLKEN2);
501 cm_write_mod_reg(prcm_context.core_cm_iclken3, CORE_MOD, CM_ICLKEN3);
502 cm_write_mod_reg(prcm_context.sgx_cm_iclken, OMAP3430ES2_SGX_MOD,
503 CM_ICLKEN);
504 cm_write_mod_reg(prcm_context.wkup_cm_iclken, WKUP_MOD, CM_ICLKEN);
505 cm_write_mod_reg(prcm_context.dss_cm_iclken, OMAP3430_DSS_MOD,
506 CM_ICLKEN);
507 cm_write_mod_reg(prcm_context.cam_cm_iclken, OMAP3430_CAM_MOD,
508 CM_ICLKEN);
509 cm_write_mod_reg(prcm_context.per_cm_iclken, OMAP3430_PER_MOD,
510 CM_ICLKEN);
511 cm_write_mod_reg(prcm_context.usbhost_cm_iclken,
512 OMAP3430ES2_USBHOST_MOD, CM_ICLKEN);
513 cm_write_mod_reg(prcm_context.iva2_cm_autiidle2, OMAP3430_IVA2_MOD,
514 CM_AUTOIDLE2);
515 cm_write_mod_reg(prcm_context.mpu_cm_autoidle2, MPU_MOD, CM_AUTOIDLE2);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530516 cm_write_mod_reg(prcm_context.iva2_cm_clkstctrl, OMAP3430_IVA2_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700517 OMAP2_CM_CLKSTCTRL);
518 cm_write_mod_reg(prcm_context.mpu_cm_clkstctrl, MPU_MOD,
519 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530520 cm_write_mod_reg(prcm_context.core_cm_clkstctrl, CORE_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700521 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530522 cm_write_mod_reg(prcm_context.sgx_cm_clkstctrl, OMAP3430ES2_SGX_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700523 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530524 cm_write_mod_reg(prcm_context.dss_cm_clkstctrl, OMAP3430_DSS_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700525 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530526 cm_write_mod_reg(prcm_context.cam_cm_clkstctrl, OMAP3430_CAM_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700527 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530528 cm_write_mod_reg(prcm_context.per_cm_clkstctrl, OMAP3430_PER_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700529 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530530 cm_write_mod_reg(prcm_context.neon_cm_clkstctrl, OMAP3430_NEON_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700531 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530532 cm_write_mod_reg(prcm_context.usbhost_cm_clkstctrl,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700533 OMAP3430ES2_USBHOST_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530534 cm_write_mod_reg(prcm_context.core_cm_autoidle1, CORE_MOD,
535 CM_AUTOIDLE1);
536 cm_write_mod_reg(prcm_context.core_cm_autoidle2, CORE_MOD,
537 CM_AUTOIDLE2);
538 cm_write_mod_reg(prcm_context.core_cm_autoidle3, CORE_MOD,
539 CM_AUTOIDLE3);
540 cm_write_mod_reg(prcm_context.wkup_cm_autoidle, WKUP_MOD, CM_AUTOIDLE);
541 cm_write_mod_reg(prcm_context.dss_cm_autoidle, OMAP3430_DSS_MOD,
542 CM_AUTOIDLE);
543 cm_write_mod_reg(prcm_context.cam_cm_autoidle, OMAP3430_CAM_MOD,
544 CM_AUTOIDLE);
545 cm_write_mod_reg(prcm_context.per_cm_autoidle, OMAP3430_PER_MOD,
546 CM_AUTOIDLE);
547 cm_write_mod_reg(prcm_context.usbhost_cm_autoidle,
548 OMAP3430ES2_USBHOST_MOD, CM_AUTOIDLE);
549 cm_write_mod_reg(prcm_context.sgx_cm_sleepdep, OMAP3430ES2_SGX_MOD,
550 OMAP3430_CM_SLEEPDEP);
551 cm_write_mod_reg(prcm_context.dss_cm_sleepdep, OMAP3430_DSS_MOD,
552 OMAP3430_CM_SLEEPDEP);
553 cm_write_mod_reg(prcm_context.cam_cm_sleepdep, OMAP3430_CAM_MOD,
554 OMAP3430_CM_SLEEPDEP);
555 cm_write_mod_reg(prcm_context.per_cm_sleepdep, OMAP3430_PER_MOD,
556 OMAP3430_CM_SLEEPDEP);
557 cm_write_mod_reg(prcm_context.usbhost_cm_sleepdep,
558 OMAP3430ES2_USBHOST_MOD, OMAP3430_CM_SLEEPDEP);
559 cm_write_mod_reg(prcm_context.cm_clkout_ctrl, OMAP3430_CCR_MOD,
560 OMAP3_CM_CLKOUT_CTRL_OFFSET);
561 prm_write_mod_reg(prcm_context.prm_clkout_ctrl, OMAP3430_CCR_MOD,
562 OMAP3_PRM_CLKOUT_CTRL_OFFSET);
563 prm_write_mod_reg(prcm_context.sgx_pm_wkdep, OMAP3430ES2_SGX_MOD,
564 PM_WKDEP);
565 prm_write_mod_reg(prcm_context.dss_pm_wkdep, OMAP3430_DSS_MOD,
566 PM_WKDEP);
567 prm_write_mod_reg(prcm_context.cam_pm_wkdep, OMAP3430_CAM_MOD,
568 PM_WKDEP);
569 prm_write_mod_reg(prcm_context.per_pm_wkdep, OMAP3430_PER_MOD,
570 PM_WKDEP);
571 prm_write_mod_reg(prcm_context.neon_pm_wkdep, OMAP3430_NEON_MOD,
572 PM_WKDEP);
573 prm_write_mod_reg(prcm_context.usbhost_pm_wkdep,
574 OMAP3430ES2_USBHOST_MOD, PM_WKDEP);
575 prm_write_mod_reg(prcm_context.core_pm_mpugrpsel1, CORE_MOD,
576 OMAP3430_PM_MPUGRPSEL1);
577 prm_write_mod_reg(prcm_context.iva2_pm_ivagrpsel1, OMAP3430_IVA2_MOD,
578 OMAP3430_PM_IVAGRPSEL1);
579 prm_write_mod_reg(prcm_context.core_pm_mpugrpsel3, CORE_MOD,
580 OMAP3430ES2_PM_MPUGRPSEL3);
581 prm_write_mod_reg(prcm_context.core_pm_ivagrpsel3, CORE_MOD,
582 OMAP3430ES2_PM_IVAGRPSEL3);
583 prm_write_mod_reg(prcm_context.wkup_pm_mpugrpsel, WKUP_MOD,
584 OMAP3430_PM_MPUGRPSEL);
585 prm_write_mod_reg(prcm_context.wkup_pm_ivagrpsel, WKUP_MOD,
586 OMAP3430_PM_IVAGRPSEL);
587 prm_write_mod_reg(prcm_context.per_pm_mpugrpsel, OMAP3430_PER_MOD,
588 OMAP3430_PM_MPUGRPSEL);
589 prm_write_mod_reg(prcm_context.per_pm_ivagrpsel, OMAP3430_PER_MOD,
590 OMAP3430_PM_IVAGRPSEL);
591 prm_write_mod_reg(prcm_context.wkup_pm_wken, WKUP_MOD, PM_WKEN);
592 return;
593}
594#endif