blob: d27cdbaeea55fea892209895cd3673cdcf633756 [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>
Paul Walmsley44595982008-03-18 10:04:51 +020029
Tony Lindgrena58caad2008-07-03 12:24:44 +030030#include "clock.h"
Paul Walmsleyfeec1272010-01-26 20:13:11 -070031#include "clock2xxx.h"
Rajendra Nayakc171a252008-09-26 17:48:31 +053032#include "cm.h"
Paul Walmsley44595982008-03-18 10:04:51 +020033#include "prm.h"
34#include "prm-regbits-24xx.h"
Rajeev Kulkarniff4d3e12010-09-21 10:34:09 -060035#include "prm-regbits-44xx.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060036#include "control.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 {
Jouni Hogander133464d2009-02-05 13:34:01 +020045 u32 iva2_cm_clksel1;
Rajendra Nayakc171a252008-09-26 17:48:31 +053046 u32 iva2_cm_clksel2;
47 u32 cm_sysconfig;
48 u32 sgx_cm_clksel;
Rajendra Nayakc171a252008-09-26 17:48:31 +053049 u32 dss_cm_clksel;
50 u32 cam_cm_clksel;
51 u32 per_cm_clksel;
52 u32 emu_cm_clksel;
53 u32 emu_cm_clkstctrl;
54 u32 pll_cm_autoidle2;
55 u32 pll_cm_clksel4;
56 u32 pll_cm_clksel5;
Rajendra Nayakc171a252008-09-26 17:48:31 +053057 u32 pll_cm_clken2;
58 u32 cm_polctrl;
59 u32 iva2_cm_fclken;
60 u32 iva2_cm_clken_pll;
61 u32 core_cm_fclken1;
62 u32 core_cm_fclken3;
63 u32 sgx_cm_fclken;
64 u32 wkup_cm_fclken;
65 u32 dss_cm_fclken;
66 u32 cam_cm_fclken;
67 u32 per_cm_fclken;
68 u32 usbhost_cm_fclken;
69 u32 core_cm_iclken1;
70 u32 core_cm_iclken2;
71 u32 core_cm_iclken3;
72 u32 sgx_cm_iclken;
73 u32 wkup_cm_iclken;
74 u32 dss_cm_iclken;
75 u32 cam_cm_iclken;
76 u32 per_cm_iclken;
77 u32 usbhost_cm_iclken;
78 u32 iva2_cm_autiidle2;
79 u32 mpu_cm_autoidle2;
Rajendra Nayakc171a252008-09-26 17:48:31 +053080 u32 iva2_cm_clkstctrl;
81 u32 mpu_cm_clkstctrl;
82 u32 core_cm_clkstctrl;
83 u32 sgx_cm_clkstctrl;
84 u32 dss_cm_clkstctrl;
85 u32 cam_cm_clkstctrl;
86 u32 per_cm_clkstctrl;
87 u32 neon_cm_clkstctrl;
88 u32 usbhost_cm_clkstctrl;
89 u32 core_cm_autoidle1;
90 u32 core_cm_autoidle2;
91 u32 core_cm_autoidle3;
92 u32 wkup_cm_autoidle;
93 u32 dss_cm_autoidle;
94 u32 cam_cm_autoidle;
95 u32 per_cm_autoidle;
96 u32 usbhost_cm_autoidle;
97 u32 sgx_cm_sleepdep;
98 u32 dss_cm_sleepdep;
99 u32 cam_cm_sleepdep;
100 u32 per_cm_sleepdep;
101 u32 usbhost_cm_sleepdep;
102 u32 cm_clkout_ctrl;
103 u32 prm_clkout_ctrl;
104 u32 sgx_pm_wkdep;
105 u32 dss_pm_wkdep;
106 u32 cam_pm_wkdep;
107 u32 per_pm_wkdep;
108 u32 neon_pm_wkdep;
109 u32 usbhost_pm_wkdep;
110 u32 core_pm_mpugrpsel1;
111 u32 iva2_pm_ivagrpsel1;
112 u32 core_pm_mpugrpsel3;
113 u32 core_pm_ivagrpsel3;
114 u32 wkup_pm_mpugrpsel;
115 u32 wkup_pm_ivagrpsel;
116 u32 per_pm_mpugrpsel;
117 u32 per_pm_ivagrpsel;
118 u32 wkup_pm_wken;
119};
120
Manjunath Kondaiah G38815732010-10-08 09:56:37 -0700121static struct omap3_prcm_regs prcm_context;
Rajendra Nayakc171a252008-09-26 17:48:31 +0530122
Tony Lindgrenb824efa2006-04-02 17:46:20 +0100123u32 omap_prcm_get_reset_sources(void)
124{
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300125 /* XXX This presumably needs modification for 34XX */
Rajendra Nayak766d3052010-03-31 04:16:30 -0600126 if (cpu_is_omap24xx() || cpu_is_omap34xx())
Abhijit Pagare37903002010-01-26 20:12:51 -0700127 return prm_read_mod_reg(WKUP_MOD, OMAP2_RM_RSTST) & 0x7f;
128 if (cpu_is_omap44xx())
129 return prm_read_mod_reg(WKUP_MOD, OMAP4_RM_RSTST) & 0x7f;
Kevin Hilman0cc93142010-02-24 12:05:56 -0700130
131 return 0;
Tony Lindgrenb824efa2006-04-02 17:46:20 +0100132}
133EXPORT_SYMBOL(omap_prcm_get_reset_sources);
134
135/* Resets clock rates and reboots the system. Only called from system.h */
Aaro Koskinen29b9a212010-02-26 10:25:28 +0000136void omap_prcm_arch_reset(char mode, const char *cmd)
Tony Lindgrenb824efa2006-04-02 17:46:20 +0100137{
Kevin Hilman0cc93142010-02-24 12:05:56 -0700138 s16 prcm_offs = 0;
Paul Walmsley44595982008-03-18 10:04:51 +0200139
Paul Walmsleyfeec1272010-01-26 20:13:11 -0700140 if (cpu_is_omap24xx()) {
141 omap2xxx_clk_prepare_for_reboot();
142
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300143 prcm_offs = WKUP_MOD;
Paul Walmsleyfeec1272010-01-26 20:13:11 -0700144 } else if (cpu_is_omap34xx()) {
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300145 prcm_offs = OMAP3430_GR_MOD;
Paul Walmsley166353b2010-12-21 20:01:21 -0700146 omap3_ctrl_write_boot_mode((cmd ? (u8)*cmd : 0));
Abhijit Pagare37903002010-01-26 20:12:51 -0700147 } else if (cpu_is_omap44xx())
148 prcm_offs = OMAP4430_PRM_DEVICE_MOD;
149 else
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300150 WARN_ON(1);
151
Rajendra Nayak766d3052010-03-31 04:16:30 -0600152 if (cpu_is_omap24xx() || cpu_is_omap34xx())
Paul Walmsley2fd0f752010-05-18 18:40:23 -0600153 prm_set_mod_reg_bits(OMAP_RST_DPLL3_MASK, prcm_offs,
Abhijit Pagare37903002010-01-26 20:12:51 -0700154 OMAP2_RM_RSTCTRL);
155 if (cpu_is_omap44xx())
Rajeev Kulkarniff4d3e12010-09-21 10:34:09 -0600156 prm_set_mod_reg_bits(OMAP4430_RST_GLOBAL_WARM_SW_MASK,
157 prcm_offs, OMAP4_RM_RSTCTRL);
Tony Lindgrenb824efa2006-04-02 17:46:20 +0100158}
Tony Lindgrena58caad2008-07-03 12:24:44 +0300159
160static inline u32 __omap_prcm_read(void __iomem *base, s16 module, u16 reg)
161{
162 BUG_ON(!base);
163 return __raw_readl(base + module + reg);
164}
165
166static inline void __omap_prcm_write(u32 value, void __iomem *base,
167 s16 module, u16 reg)
168{
169 BUG_ON(!base);
170 __raw_writel(value, base + module + reg);
171}
172
173/* Read a register in a PRM module */
174u32 prm_read_mod_reg(s16 module, u16 idx)
175{
176 return __omap_prcm_read(prm_base, module, idx);
177}
Tony Lindgrena58caad2008-07-03 12:24:44 +0300178
179/* Write into a register in a PRM module */
180void prm_write_mod_reg(u32 val, s16 module, u16 idx)
181{
182 __omap_prcm_write(val, prm_base, module, idx);
183}
Tony Lindgrena58caad2008-07-03 12:24:44 +0300184
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300185/* Read-modify-write a register in a PRM module. Caller must lock */
186u32 prm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
187{
188 u32 v;
189
190 v = prm_read_mod_reg(module, idx);
191 v &= ~mask;
192 v |= bits;
193 prm_write_mod_reg(v, module, idx);
194
195 return v;
196}
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300197
Paul Walmsley55ed9692010-01-26 20:12:59 -0700198/* Read a PRM register, AND it, and shift the result down to bit 0 */
199u32 prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
200{
201 u32 v;
202
203 v = prm_read_mod_reg(domain, idx);
204 v &= mask;
205 v >>= __ffs(mask);
206
207 return v;
208}
209
Benoit Cousson16b04012010-09-21 10:34:10 -0600210/* Read a PRM register, AND it, and shift the result down to bit 0 */
211u32 omap4_prm_read_bits_shift(void __iomem *reg, u32 mask)
212{
213 u32 v;
214
215 v = __raw_readl(reg);
216 v &= mask;
217 v >>= __ffs(mask);
218
219 return v;
220}
221
222/* Read-modify-write a register in a PRM module. Caller must lock */
223u32 omap4_prm_rmw_reg_bits(u32 mask, u32 bits, void __iomem *reg)
224{
225 u32 v;
226
227 v = __raw_readl(reg);
228 v &= ~mask;
229 v |= bits;
230 __raw_writel(v, reg);
231
232 return v;
233}
Tony Lindgrena58caad2008-07-03 12:24:44 +0300234/* Read a register in a CM module */
235u32 cm_read_mod_reg(s16 module, u16 idx)
236{
237 return __omap_prcm_read(cm_base, module, idx);
238}
Tony Lindgrena58caad2008-07-03 12:24:44 +0300239
240/* Write into a register in a CM module */
241void cm_write_mod_reg(u32 val, s16 module, u16 idx)
242{
243 __omap_prcm_write(val, cm_base, module, idx);
244}
Tony Lindgrena58caad2008-07-03 12:24:44 +0300245
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300246/* Read-modify-write a register in a CM module. Caller must lock */
247u32 cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
248{
249 u32 v;
250
251 v = cm_read_mod_reg(module, idx);
252 v &= ~mask;
253 v |= bits;
254 cm_write_mod_reg(v, module, idx);
255
256 return v;
257}
Tony Lindgrenff00fcc2008-07-03 12:24:44 +0300258
Paul Walmsley72350b22009-07-24 19:44:03 -0600259/**
260 * omap2_cm_wait_idlest - wait for IDLEST bit to indicate module readiness
261 * @reg: physical address of module IDLEST register
262 * @mask: value to mask against to determine if the module is active
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -0700263 * @idlest: idle state indicator (0 or 1) for the clock
Paul Walmsley72350b22009-07-24 19:44:03 -0600264 * @name: name of the clock (for printk)
265 *
266 * Returns 1 if the module indicated readiness in time, or 0 if it
267 * failed to enable in roughly MAX_MODULE_ENABLE_WAIT microseconds.
268 */
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -0700269int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, u8 idlest,
270 const char *name)
Paul Walmsley72350b22009-07-24 19:44:03 -0600271{
272 int i = 0;
273 int ena = 0;
274
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -0700275 if (idlest)
Paul Walmsley72350b22009-07-24 19:44:03 -0600276 ena = 0;
277 else
Ranjith Lohithakshan419cc972010-02-24 12:05:54 -0700278 ena = mask;
Paul Walmsley72350b22009-07-24 19:44:03 -0600279
280 /* Wait for lock */
Paul Walmsley6f8b7ff2009-12-08 16:33:16 -0700281 omap_test_timeout(((__raw_readl(reg) & mask) == ena),
282 MAX_MODULE_ENABLE_WAIT, i);
Paul Walmsley72350b22009-07-24 19:44:03 -0600283
284 if (i < MAX_MODULE_ENABLE_WAIT)
285 pr_debug("cm: Module associated with clock %s ready after %d "
286 "loops\n", name, i);
287 else
288 pr_err("cm: Module associated with clock %s didn't enable in "
289 "%d tries\n", name, MAX_MODULE_ENABLE_WAIT);
290
291 return (i < MAX_MODULE_ENABLE_WAIT) ? 1 : 0;
292};
293
Tony Lindgrena58caad2008-07-03 12:24:44 +0300294void __init omap2_set_globals_prcm(struct omap_globals *omap2_globals)
295{
Santosh Shilimkarb7ebb102010-02-15 18:03:37 +0530296 /* Static mapping, never released */
297 if (omap2_globals->prm) {
298 prm_base = ioremap(omap2_globals->prm, SZ_8K);
299 WARN_ON(!prm_base);
300 }
301 if (omap2_globals->cm) {
302 cm_base = ioremap(omap2_globals->cm, SZ_8K);
303 WARN_ON(!cm_base);
304 }
305 if (omap2_globals->cm2) {
306 cm2_base = ioremap(omap2_globals->cm2, SZ_8K);
307 WARN_ON(!cm2_base);
308 }
Tony Lindgrena58caad2008-07-03 12:24:44 +0300309}
Rajendra Nayakc171a252008-09-26 17:48:31 +0530310
311#ifdef CONFIG_ARCH_OMAP3
312void omap3_prcm_save_context(void)
313{
Jouni Hogander133464d2009-02-05 13:34:01 +0200314 prcm_context.iva2_cm_clksel1 =
315 cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_CLKSEL1);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530316 prcm_context.iva2_cm_clksel2 =
317 cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_CLKSEL2);
318 prcm_context.cm_sysconfig = __raw_readl(OMAP3430_CM_SYSCONFIG);
319 prcm_context.sgx_cm_clksel =
320 cm_read_mod_reg(OMAP3430ES2_SGX_MOD, CM_CLKSEL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530321 prcm_context.dss_cm_clksel =
322 cm_read_mod_reg(OMAP3430_DSS_MOD, CM_CLKSEL);
323 prcm_context.cam_cm_clksel =
324 cm_read_mod_reg(OMAP3430_CAM_MOD, CM_CLKSEL);
325 prcm_context.per_cm_clksel =
326 cm_read_mod_reg(OMAP3430_PER_MOD, CM_CLKSEL);
327 prcm_context.emu_cm_clksel =
328 cm_read_mod_reg(OMAP3430_EMU_MOD, CM_CLKSEL1);
329 prcm_context.emu_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700330 cm_read_mod_reg(OMAP3430_EMU_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530331 prcm_context.pll_cm_autoidle2 =
332 cm_read_mod_reg(PLL_MOD, CM_AUTOIDLE2);
333 prcm_context.pll_cm_clksel4 =
334 cm_read_mod_reg(PLL_MOD, OMAP3430ES2_CM_CLKSEL4);
335 prcm_context.pll_cm_clksel5 =
336 cm_read_mod_reg(PLL_MOD, OMAP3430ES2_CM_CLKSEL5);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530337 prcm_context.pll_cm_clken2 =
338 cm_read_mod_reg(PLL_MOD, OMAP3430ES2_CM_CLKEN2);
339 prcm_context.cm_polctrl = __raw_readl(OMAP3430_CM_POLCTRL);
340 prcm_context.iva2_cm_fclken =
341 cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_FCLKEN);
342 prcm_context.iva2_cm_clken_pll = cm_read_mod_reg(OMAP3430_IVA2_MOD,
343 OMAP3430_CM_CLKEN_PLL);
344 prcm_context.core_cm_fclken1 =
345 cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
346 prcm_context.core_cm_fclken3 =
347 cm_read_mod_reg(CORE_MOD, OMAP3430ES2_CM_FCLKEN3);
348 prcm_context.sgx_cm_fclken =
349 cm_read_mod_reg(OMAP3430ES2_SGX_MOD, CM_FCLKEN);
350 prcm_context.wkup_cm_fclken =
351 cm_read_mod_reg(WKUP_MOD, CM_FCLKEN);
352 prcm_context.dss_cm_fclken =
353 cm_read_mod_reg(OMAP3430_DSS_MOD, CM_FCLKEN);
354 prcm_context.cam_cm_fclken =
355 cm_read_mod_reg(OMAP3430_CAM_MOD, CM_FCLKEN);
356 prcm_context.per_cm_fclken =
357 cm_read_mod_reg(OMAP3430_PER_MOD, CM_FCLKEN);
358 prcm_context.usbhost_cm_fclken =
359 cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN);
360 prcm_context.core_cm_iclken1 =
361 cm_read_mod_reg(CORE_MOD, CM_ICLKEN1);
362 prcm_context.core_cm_iclken2 =
363 cm_read_mod_reg(CORE_MOD, CM_ICLKEN2);
364 prcm_context.core_cm_iclken3 =
365 cm_read_mod_reg(CORE_MOD, CM_ICLKEN3);
366 prcm_context.sgx_cm_iclken =
367 cm_read_mod_reg(OMAP3430ES2_SGX_MOD, CM_ICLKEN);
368 prcm_context.wkup_cm_iclken =
369 cm_read_mod_reg(WKUP_MOD, CM_ICLKEN);
370 prcm_context.dss_cm_iclken =
371 cm_read_mod_reg(OMAP3430_DSS_MOD, CM_ICLKEN);
372 prcm_context.cam_cm_iclken =
373 cm_read_mod_reg(OMAP3430_CAM_MOD, CM_ICLKEN);
374 prcm_context.per_cm_iclken =
375 cm_read_mod_reg(OMAP3430_PER_MOD, CM_ICLKEN);
376 prcm_context.usbhost_cm_iclken =
377 cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD, CM_ICLKEN);
378 prcm_context.iva2_cm_autiidle2 =
379 cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_AUTOIDLE2);
380 prcm_context.mpu_cm_autoidle2 =
381 cm_read_mod_reg(MPU_MOD, CM_AUTOIDLE2);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530382 prcm_context.iva2_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700383 cm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530384 prcm_context.mpu_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700385 cm_read_mod_reg(MPU_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530386 prcm_context.core_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700387 cm_read_mod_reg(CORE_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530388 prcm_context.sgx_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700389 cm_read_mod_reg(OMAP3430ES2_SGX_MOD,
390 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530391 prcm_context.dss_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700392 cm_read_mod_reg(OMAP3430_DSS_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530393 prcm_context.cam_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700394 cm_read_mod_reg(OMAP3430_CAM_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530395 prcm_context.per_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700396 cm_read_mod_reg(OMAP3430_PER_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530397 prcm_context.neon_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700398 cm_read_mod_reg(OMAP3430_NEON_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530399 prcm_context.usbhost_cm_clkstctrl =
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700400 cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD,
401 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530402 prcm_context.core_cm_autoidle1 =
403 cm_read_mod_reg(CORE_MOD, CM_AUTOIDLE1);
404 prcm_context.core_cm_autoidle2 =
405 cm_read_mod_reg(CORE_MOD, CM_AUTOIDLE2);
406 prcm_context.core_cm_autoidle3 =
407 cm_read_mod_reg(CORE_MOD, CM_AUTOIDLE3);
408 prcm_context.wkup_cm_autoidle =
409 cm_read_mod_reg(WKUP_MOD, CM_AUTOIDLE);
410 prcm_context.dss_cm_autoidle =
411 cm_read_mod_reg(OMAP3430_DSS_MOD, CM_AUTOIDLE);
412 prcm_context.cam_cm_autoidle =
413 cm_read_mod_reg(OMAP3430_CAM_MOD, CM_AUTOIDLE);
414 prcm_context.per_cm_autoidle =
415 cm_read_mod_reg(OMAP3430_PER_MOD, CM_AUTOIDLE);
416 prcm_context.usbhost_cm_autoidle =
417 cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD, CM_AUTOIDLE);
418 prcm_context.sgx_cm_sleepdep =
419 cm_read_mod_reg(OMAP3430ES2_SGX_MOD, OMAP3430_CM_SLEEPDEP);
420 prcm_context.dss_cm_sleepdep =
421 cm_read_mod_reg(OMAP3430_DSS_MOD, OMAP3430_CM_SLEEPDEP);
422 prcm_context.cam_cm_sleepdep =
423 cm_read_mod_reg(OMAP3430_CAM_MOD, OMAP3430_CM_SLEEPDEP);
424 prcm_context.per_cm_sleepdep =
425 cm_read_mod_reg(OMAP3430_PER_MOD, OMAP3430_CM_SLEEPDEP);
426 prcm_context.usbhost_cm_sleepdep =
427 cm_read_mod_reg(OMAP3430ES2_USBHOST_MOD, OMAP3430_CM_SLEEPDEP);
428 prcm_context.cm_clkout_ctrl = cm_read_mod_reg(OMAP3430_CCR_MOD,
429 OMAP3_CM_CLKOUT_CTRL_OFFSET);
430 prcm_context.prm_clkout_ctrl = prm_read_mod_reg(OMAP3430_CCR_MOD,
431 OMAP3_PRM_CLKOUT_CTRL_OFFSET);
432 prcm_context.sgx_pm_wkdep =
433 prm_read_mod_reg(OMAP3430ES2_SGX_MOD, PM_WKDEP);
434 prcm_context.dss_pm_wkdep =
435 prm_read_mod_reg(OMAP3430_DSS_MOD, PM_WKDEP);
436 prcm_context.cam_pm_wkdep =
437 prm_read_mod_reg(OMAP3430_CAM_MOD, PM_WKDEP);
438 prcm_context.per_pm_wkdep =
439 prm_read_mod_reg(OMAP3430_PER_MOD, PM_WKDEP);
440 prcm_context.neon_pm_wkdep =
441 prm_read_mod_reg(OMAP3430_NEON_MOD, PM_WKDEP);
442 prcm_context.usbhost_pm_wkdep =
443 prm_read_mod_reg(OMAP3430ES2_USBHOST_MOD, PM_WKDEP);
444 prcm_context.core_pm_mpugrpsel1 =
445 prm_read_mod_reg(CORE_MOD, OMAP3430_PM_MPUGRPSEL1);
446 prcm_context.iva2_pm_ivagrpsel1 =
447 prm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP3430_PM_IVAGRPSEL1);
448 prcm_context.core_pm_mpugrpsel3 =
449 prm_read_mod_reg(CORE_MOD, OMAP3430ES2_PM_MPUGRPSEL3);
450 prcm_context.core_pm_ivagrpsel3 =
451 prm_read_mod_reg(CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3);
452 prcm_context.wkup_pm_mpugrpsel =
453 prm_read_mod_reg(WKUP_MOD, OMAP3430_PM_MPUGRPSEL);
454 prcm_context.wkup_pm_ivagrpsel =
455 prm_read_mod_reg(WKUP_MOD, OMAP3430_PM_IVAGRPSEL);
456 prcm_context.per_pm_mpugrpsel =
457 prm_read_mod_reg(OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL);
458 prcm_context.per_pm_ivagrpsel =
459 prm_read_mod_reg(OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL);
460 prcm_context.wkup_pm_wken = prm_read_mod_reg(WKUP_MOD, PM_WKEN);
461 return;
462}
463
464void omap3_prcm_restore_context(void)
465{
Jouni Hogander133464d2009-02-05 13:34:01 +0200466 cm_write_mod_reg(prcm_context.iva2_cm_clksel1, OMAP3430_IVA2_MOD,
467 CM_CLKSEL1);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530468 cm_write_mod_reg(prcm_context.iva2_cm_clksel2, OMAP3430_IVA2_MOD,
469 CM_CLKSEL2);
470 __raw_writel(prcm_context.cm_sysconfig, OMAP3430_CM_SYSCONFIG);
471 cm_write_mod_reg(prcm_context.sgx_cm_clksel, OMAP3430ES2_SGX_MOD,
472 CM_CLKSEL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530473 cm_write_mod_reg(prcm_context.dss_cm_clksel, OMAP3430_DSS_MOD,
474 CM_CLKSEL);
475 cm_write_mod_reg(prcm_context.cam_cm_clksel, OMAP3430_CAM_MOD,
476 CM_CLKSEL);
477 cm_write_mod_reg(prcm_context.per_cm_clksel, OMAP3430_PER_MOD,
478 CM_CLKSEL);
479 cm_write_mod_reg(prcm_context.emu_cm_clksel, OMAP3430_EMU_MOD,
480 CM_CLKSEL1);
481 cm_write_mod_reg(prcm_context.emu_cm_clkstctrl, OMAP3430_EMU_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700482 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530483 cm_write_mod_reg(prcm_context.pll_cm_autoidle2, PLL_MOD,
484 CM_AUTOIDLE2);
485 cm_write_mod_reg(prcm_context.pll_cm_clksel4, PLL_MOD,
486 OMAP3430ES2_CM_CLKSEL4);
487 cm_write_mod_reg(prcm_context.pll_cm_clksel5, PLL_MOD,
488 OMAP3430ES2_CM_CLKSEL5);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530489 cm_write_mod_reg(prcm_context.pll_cm_clken2, PLL_MOD,
490 OMAP3430ES2_CM_CLKEN2);
491 __raw_writel(prcm_context.cm_polctrl, OMAP3430_CM_POLCTRL);
492 cm_write_mod_reg(prcm_context.iva2_cm_fclken, OMAP3430_IVA2_MOD,
493 CM_FCLKEN);
494 cm_write_mod_reg(prcm_context.iva2_cm_clken_pll, OMAP3430_IVA2_MOD,
495 OMAP3430_CM_CLKEN_PLL);
496 cm_write_mod_reg(prcm_context.core_cm_fclken1, CORE_MOD, CM_FCLKEN1);
497 cm_write_mod_reg(prcm_context.core_cm_fclken3, CORE_MOD,
498 OMAP3430ES2_CM_FCLKEN3);
499 cm_write_mod_reg(prcm_context.sgx_cm_fclken, OMAP3430ES2_SGX_MOD,
500 CM_FCLKEN);
501 cm_write_mod_reg(prcm_context.wkup_cm_fclken, WKUP_MOD, CM_FCLKEN);
502 cm_write_mod_reg(prcm_context.dss_cm_fclken, OMAP3430_DSS_MOD,
503 CM_FCLKEN);
504 cm_write_mod_reg(prcm_context.cam_cm_fclken, OMAP3430_CAM_MOD,
505 CM_FCLKEN);
506 cm_write_mod_reg(prcm_context.per_cm_fclken, OMAP3430_PER_MOD,
507 CM_FCLKEN);
508 cm_write_mod_reg(prcm_context.usbhost_cm_fclken,
509 OMAP3430ES2_USBHOST_MOD, CM_FCLKEN);
510 cm_write_mod_reg(prcm_context.core_cm_iclken1, CORE_MOD, CM_ICLKEN1);
511 cm_write_mod_reg(prcm_context.core_cm_iclken2, CORE_MOD, CM_ICLKEN2);
512 cm_write_mod_reg(prcm_context.core_cm_iclken3, CORE_MOD, CM_ICLKEN3);
513 cm_write_mod_reg(prcm_context.sgx_cm_iclken, OMAP3430ES2_SGX_MOD,
514 CM_ICLKEN);
515 cm_write_mod_reg(prcm_context.wkup_cm_iclken, WKUP_MOD, CM_ICLKEN);
516 cm_write_mod_reg(prcm_context.dss_cm_iclken, OMAP3430_DSS_MOD,
517 CM_ICLKEN);
518 cm_write_mod_reg(prcm_context.cam_cm_iclken, OMAP3430_CAM_MOD,
519 CM_ICLKEN);
520 cm_write_mod_reg(prcm_context.per_cm_iclken, OMAP3430_PER_MOD,
521 CM_ICLKEN);
522 cm_write_mod_reg(prcm_context.usbhost_cm_iclken,
523 OMAP3430ES2_USBHOST_MOD, CM_ICLKEN);
524 cm_write_mod_reg(prcm_context.iva2_cm_autiidle2, OMAP3430_IVA2_MOD,
525 CM_AUTOIDLE2);
526 cm_write_mod_reg(prcm_context.mpu_cm_autoidle2, MPU_MOD, CM_AUTOIDLE2);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530527 cm_write_mod_reg(prcm_context.iva2_cm_clkstctrl, OMAP3430_IVA2_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700528 OMAP2_CM_CLKSTCTRL);
529 cm_write_mod_reg(prcm_context.mpu_cm_clkstctrl, MPU_MOD,
530 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530531 cm_write_mod_reg(prcm_context.core_cm_clkstctrl, CORE_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700532 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530533 cm_write_mod_reg(prcm_context.sgx_cm_clkstctrl, OMAP3430ES2_SGX_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700534 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530535 cm_write_mod_reg(prcm_context.dss_cm_clkstctrl, OMAP3430_DSS_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700536 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530537 cm_write_mod_reg(prcm_context.cam_cm_clkstctrl, OMAP3430_CAM_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700538 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530539 cm_write_mod_reg(prcm_context.per_cm_clkstctrl, OMAP3430_PER_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700540 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530541 cm_write_mod_reg(prcm_context.neon_cm_clkstctrl, OMAP3430_NEON_MOD,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700542 OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530543 cm_write_mod_reg(prcm_context.usbhost_cm_clkstctrl,
Abhijit Pagare84c0c392010-01-26 20:12:53 -0700544 OMAP3430ES2_USBHOST_MOD, OMAP2_CM_CLKSTCTRL);
Rajendra Nayakc171a252008-09-26 17:48:31 +0530545 cm_write_mod_reg(prcm_context.core_cm_autoidle1, CORE_MOD,
546 CM_AUTOIDLE1);
547 cm_write_mod_reg(prcm_context.core_cm_autoidle2, CORE_MOD,
548 CM_AUTOIDLE2);
549 cm_write_mod_reg(prcm_context.core_cm_autoidle3, CORE_MOD,
550 CM_AUTOIDLE3);
551 cm_write_mod_reg(prcm_context.wkup_cm_autoidle, WKUP_MOD, CM_AUTOIDLE);
552 cm_write_mod_reg(prcm_context.dss_cm_autoidle, OMAP3430_DSS_MOD,
553 CM_AUTOIDLE);
554 cm_write_mod_reg(prcm_context.cam_cm_autoidle, OMAP3430_CAM_MOD,
555 CM_AUTOIDLE);
556 cm_write_mod_reg(prcm_context.per_cm_autoidle, OMAP3430_PER_MOD,
557 CM_AUTOIDLE);
558 cm_write_mod_reg(prcm_context.usbhost_cm_autoidle,
559 OMAP3430ES2_USBHOST_MOD, CM_AUTOIDLE);
560 cm_write_mod_reg(prcm_context.sgx_cm_sleepdep, OMAP3430ES2_SGX_MOD,
561 OMAP3430_CM_SLEEPDEP);
562 cm_write_mod_reg(prcm_context.dss_cm_sleepdep, OMAP3430_DSS_MOD,
563 OMAP3430_CM_SLEEPDEP);
564 cm_write_mod_reg(prcm_context.cam_cm_sleepdep, OMAP3430_CAM_MOD,
565 OMAP3430_CM_SLEEPDEP);
566 cm_write_mod_reg(prcm_context.per_cm_sleepdep, OMAP3430_PER_MOD,
567 OMAP3430_CM_SLEEPDEP);
568 cm_write_mod_reg(prcm_context.usbhost_cm_sleepdep,
569 OMAP3430ES2_USBHOST_MOD, OMAP3430_CM_SLEEPDEP);
570 cm_write_mod_reg(prcm_context.cm_clkout_ctrl, OMAP3430_CCR_MOD,
571 OMAP3_CM_CLKOUT_CTRL_OFFSET);
572 prm_write_mod_reg(prcm_context.prm_clkout_ctrl, OMAP3430_CCR_MOD,
573 OMAP3_PRM_CLKOUT_CTRL_OFFSET);
574 prm_write_mod_reg(prcm_context.sgx_pm_wkdep, OMAP3430ES2_SGX_MOD,
575 PM_WKDEP);
576 prm_write_mod_reg(prcm_context.dss_pm_wkdep, OMAP3430_DSS_MOD,
577 PM_WKDEP);
578 prm_write_mod_reg(prcm_context.cam_pm_wkdep, OMAP3430_CAM_MOD,
579 PM_WKDEP);
580 prm_write_mod_reg(prcm_context.per_pm_wkdep, OMAP3430_PER_MOD,
581 PM_WKDEP);
582 prm_write_mod_reg(prcm_context.neon_pm_wkdep, OMAP3430_NEON_MOD,
583 PM_WKDEP);
584 prm_write_mod_reg(prcm_context.usbhost_pm_wkdep,
585 OMAP3430ES2_USBHOST_MOD, PM_WKDEP);
586 prm_write_mod_reg(prcm_context.core_pm_mpugrpsel1, CORE_MOD,
587 OMAP3430_PM_MPUGRPSEL1);
588 prm_write_mod_reg(prcm_context.iva2_pm_ivagrpsel1, OMAP3430_IVA2_MOD,
589 OMAP3430_PM_IVAGRPSEL1);
590 prm_write_mod_reg(prcm_context.core_pm_mpugrpsel3, CORE_MOD,
591 OMAP3430ES2_PM_MPUGRPSEL3);
592 prm_write_mod_reg(prcm_context.core_pm_ivagrpsel3, CORE_MOD,
593 OMAP3430ES2_PM_IVAGRPSEL3);
594 prm_write_mod_reg(prcm_context.wkup_pm_mpugrpsel, WKUP_MOD,
595 OMAP3430_PM_MPUGRPSEL);
596 prm_write_mod_reg(prcm_context.wkup_pm_ivagrpsel, WKUP_MOD,
597 OMAP3430_PM_IVAGRPSEL);
598 prm_write_mod_reg(prcm_context.per_pm_mpugrpsel, OMAP3430_PER_MOD,
599 OMAP3430_PM_MPUGRPSEL);
600 prm_write_mod_reg(prcm_context.per_pm_ivagrpsel, OMAP3430_PER_MOD,
601 OMAP3430_PM_IVAGRPSEL);
602 prm_write_mod_reg(prcm_context.wkup_pm_wken, WKUP_MOD, PM_WKEN);
603 return;
604}
605#endif