diff options
Diffstat (limited to 'arch/arm/mach-omap2/prcm.c')
-rw-r--r-- | arch/arm/mach-omap2/prcm.c | 98 |
1 files changed, 91 insertions, 7 deletions
diff --git a/arch/arm/mach-omap2/prcm.c b/arch/arm/mach-omap2/prcm.c index b12f423b8595..fd92a80f38f2 100644 --- a/arch/arm/mach-omap2/prcm.c +++ b/arch/arm/mach-omap2/prcm.c | |||
@@ -16,16 +16,21 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
19 | #include <linux/io.h> | ||
19 | 20 | ||
20 | #include <asm/io.h> | 21 | #include <asm/arch/common.h> |
22 | #include <asm/arch/prcm.h> | ||
21 | 23 | ||
24 | #include "clock.h" | ||
22 | #include "prm.h" | 25 | #include "prm.h" |
23 | #include "prm-regbits-24xx.h" | 26 | #include "prm-regbits-24xx.h" |
24 | 27 | ||
25 | extern void omap2_clk_prepare_for_reboot(void); | 28 | static void __iomem *prm_base; |
29 | static void __iomem *cm_base; | ||
26 | 30 | ||
27 | u32 omap_prcm_get_reset_sources(void) | 31 | u32 omap_prcm_get_reset_sources(void) |
28 | { | 32 | { |
33 | /* XXX This presumably needs modification for 34XX */ | ||
29 | return prm_read_mod_reg(WKUP_MOD, RM_RSTST) & 0x7f; | 34 | return prm_read_mod_reg(WKUP_MOD, RM_RSTST) & 0x7f; |
30 | } | 35 | } |
31 | EXPORT_SYMBOL(omap_prcm_get_reset_sources); | 36 | EXPORT_SYMBOL(omap_prcm_get_reset_sources); |
@@ -33,11 +38,90 @@ EXPORT_SYMBOL(omap_prcm_get_reset_sources); | |||
33 | /* Resets clock rates and reboots the system. Only called from system.h */ | 38 | /* Resets clock rates and reboots the system. Only called from system.h */ |
34 | void omap_prcm_arch_reset(char mode) | 39 | void omap_prcm_arch_reset(char mode) |
35 | { | 40 | { |
36 | u32 wkup; | 41 | s16 prcm_offs; |
37 | omap2_clk_prepare_for_reboot(); | 42 | omap2_clk_prepare_for_reboot(); |
38 | 43 | ||
39 | if (cpu_is_omap24xx()) { | 44 | if (cpu_is_omap24xx()) |
40 | wkup = prm_read_mod_reg(WKUP_MOD, RM_RSTCTRL) | OMAP_RST_DPLL3; | 45 | prcm_offs = WKUP_MOD; |
41 | prm_write_mod_reg(wkup, WKUP_MOD, RM_RSTCTRL); | 46 | else if (cpu_is_omap34xx()) |
42 | } | 47 | prcm_offs = OMAP3430_GR_MOD; |
48 | else | ||
49 | WARN_ON(1); | ||
50 | |||
51 | prm_set_mod_reg_bits(OMAP_RST_DPLL3, prcm_offs, RM_RSTCTRL); | ||
52 | } | ||
53 | |||
54 | static inline u32 __omap_prcm_read(void __iomem *base, s16 module, u16 reg) | ||
55 | { | ||
56 | BUG_ON(!base); | ||
57 | return __raw_readl(base + module + reg); | ||
58 | } | ||
59 | |||
60 | static inline void __omap_prcm_write(u32 value, void __iomem *base, | ||
61 | s16 module, u16 reg) | ||
62 | { | ||
63 | BUG_ON(!base); | ||
64 | __raw_writel(value, base + module + reg); | ||
65 | } | ||
66 | |||
67 | /* Read a register in a PRM module */ | ||
68 | u32 prm_read_mod_reg(s16 module, u16 idx) | ||
69 | { | ||
70 | return __omap_prcm_read(prm_base, module, idx); | ||
71 | } | ||
72 | EXPORT_SYMBOL(prm_read_mod_reg); | ||
73 | |||
74 | /* Write into a register in a PRM module */ | ||
75 | void prm_write_mod_reg(u32 val, s16 module, u16 idx) | ||
76 | { | ||
77 | __omap_prcm_write(val, prm_base, module, idx); | ||
78 | } | ||
79 | EXPORT_SYMBOL(prm_write_mod_reg); | ||
80 | |||
81 | /* Read-modify-write a register in a PRM module. Caller must lock */ | ||
82 | u32 prm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx) | ||
83 | { | ||
84 | u32 v; | ||
85 | |||
86 | v = prm_read_mod_reg(module, idx); | ||
87 | v &= ~mask; | ||
88 | v |= bits; | ||
89 | prm_write_mod_reg(v, module, idx); | ||
90 | |||
91 | return v; | ||
92 | } | ||
93 | EXPORT_SYMBOL(prm_rmw_mod_reg_bits); | ||
94 | |||
95 | /* Read a register in a CM module */ | ||
96 | u32 cm_read_mod_reg(s16 module, u16 idx) | ||
97 | { | ||
98 | return __omap_prcm_read(cm_base, module, idx); | ||
99 | } | ||
100 | EXPORT_SYMBOL(cm_read_mod_reg); | ||
101 | |||
102 | /* Write into a register in a CM module */ | ||
103 | void cm_write_mod_reg(u32 val, s16 module, u16 idx) | ||
104 | { | ||
105 | __omap_prcm_write(val, cm_base, module, idx); | ||
106 | } | ||
107 | EXPORT_SYMBOL(cm_write_mod_reg); | ||
108 | |||
109 | /* Read-modify-write a register in a CM module. Caller must lock */ | ||
110 | u32 cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx) | ||
111 | { | ||
112 | u32 v; | ||
113 | |||
114 | v = cm_read_mod_reg(module, idx); | ||
115 | v &= ~mask; | ||
116 | v |= bits; | ||
117 | cm_write_mod_reg(v, module, idx); | ||
118 | |||
119 | return v; | ||
120 | } | ||
121 | EXPORT_SYMBOL(cm_rmw_mod_reg_bits); | ||
122 | |||
123 | void __init omap2_set_globals_prcm(struct omap_globals *omap2_globals) | ||
124 | { | ||
125 | prm_base = omap2_globals->prm; | ||
126 | cm_base = omap2_globals->cm; | ||
43 | } | 127 | } |