]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/prcm.c
Fix compile for the previous patch.
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / prcm.c
1 /*
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  *
10  * Some pieces of code Copyright (C) 2005 Texas Instruments, Inc.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2 as
14  * published by the Free Software Foundation.
15  */
16 #include <linux/module.h>
17 #include <linux/init.h>
18 #include <linux/clk.h>
19 #include <linux/io.h>
20
21 #include <mach/common.h>
22 #include <mach/control.h>
23 #include <mach/prcm.h>
24
25 #include "clock.h"
26 #include "prm.h"
27 #include "prm-regbits-24xx.h"
28
29 static void __iomem *prm_base;
30 static void __iomem *cm_base;
31
32 u32 omap_prcm_get_reset_sources(void)
33 {
34         /* XXX This presumably needs modification for 34XX */
35         return prm_read_mod_reg(WKUP_MOD, RM_RSTST) & 0x7f;
36 }
37 EXPORT_SYMBOL(omap_prcm_get_reset_sources);
38
39 /* Resets clock rates and reboots the system. Only called from system.h */
40 void omap_prcm_arch_reset(char mode)
41 {
42         s16 prcm_offs;
43         omap2_clk_prepare_for_reboot();
44
45         if (cpu_is_omap24xx())
46                 prcm_offs = WKUP_MOD;
47         else if (cpu_is_omap34xx()) {
48                 u32 l;
49
50                 prcm_offs = OMAP3430_GR_MOD;
51                 l = ('B' << 24) | ('M' << 16) | mode;
52                 /* Reserve the first word in scratchpad for communicating
53                  * with the boot ROM. A pointer to a data structure
54                  * describing the boot process can be stored there,
55                  * cf. OMAP34xx TRM, Initialization / Software Booting
56                  * Configuration. */
57                 omap_writel(l, OMAP343X_SCRATCHPAD + 4);
58         } else
59                 WARN_ON(1);
60
61         prm_set_mod_reg_bits(OMAP_RST_DPLL3, prcm_offs, RM_RSTCTRL);
62 }
63
64 static inline u32 __omap_prcm_read(void __iomem *base, s16 module, u16 reg)
65 {
66         BUG_ON(!base);
67         return __raw_readl(base + module + reg);
68 }
69
70 static inline void __omap_prcm_write(u32 value, void __iomem *base,
71                                                 s16 module, u16 reg)
72 {
73         BUG_ON(!base);
74         __raw_writel(value, base + module + reg);
75 }
76
77 /* Read a register in a PRM module */
78 u32 prm_read_mod_reg(s16 module, u16 idx)
79 {
80         return __omap_prcm_read(prm_base, module, idx);
81 }
82 EXPORT_SYMBOL(prm_read_mod_reg);
83
84 /* Write into a register in a PRM module */
85 void prm_write_mod_reg(u32 val, s16 module, u16 idx)
86 {
87         __omap_prcm_write(val, prm_base, module, idx);
88 }
89 EXPORT_SYMBOL(prm_write_mod_reg);
90
91 /* Read-modify-write a register in a PRM module. Caller must lock */
92 u32 prm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
93 {
94         u32 v;
95
96         v = prm_read_mod_reg(module, idx);
97         v &= ~mask;
98         v |= bits;
99         prm_write_mod_reg(v, module, idx);
100
101         return v;
102 }
103 EXPORT_SYMBOL(prm_rmw_mod_reg_bits);
104
105 /* Read a register in a CM module */
106 u32 cm_read_mod_reg(s16 module, u16 idx)
107 {
108         return __omap_prcm_read(cm_base, module, idx);
109 }
110 EXPORT_SYMBOL(cm_read_mod_reg);
111
112 /* Write into a register in a CM module */
113 void cm_write_mod_reg(u32 val, s16 module, u16 idx)
114 {
115         __omap_prcm_write(val, cm_base, module, idx);
116 }
117 EXPORT_SYMBOL(cm_write_mod_reg);
118
119 /* Read-modify-write a register in a CM module. Caller must lock */
120 u32 cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
121 {
122         u32 v;
123
124         v = cm_read_mod_reg(module, idx);
125         v &= ~mask;
126         v |= bits;
127         cm_write_mod_reg(v, module, idx);
128
129         return v;
130 }
131 EXPORT_SYMBOL(cm_rmw_mod_reg_bits);
132
133 void __init omap2_set_globals_prcm(struct omap_globals *omap2_globals)
134 {
135         prm_base = omap2_globals->prm;
136         cm_base = omap2_globals->cm;
137 }