2 * linux/arch/arm/mach-omap2/prcm.c
4 * OMAP 24xx Power Reset and Clock Management (PRCM) functions
6 * Copyright (C) 2005 Nokia Corporation
8 * Written by Tony Lindgren <tony.lindgren@nokia.com>
10 * Some pieces of code Copyright (C) 2005 Texas Instruments, Inc.
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.
16 #include <linux/module.h>
17 #include <linux/init.h>
18 #include <linux/clk.h>
21 #include <mach/common.h>
22 #include <mach/prcm.h>
26 #include "prm-regbits-24xx.h"
28 static void __iomem *prm_base;
29 static void __iomem *cm_base;
31 u32 omap_prcm_get_reset_sources(void)
33 /* XXX This presumably needs modification for 34XX */
34 return prm_read_mod_reg(WKUP_MOD, RM_RSTST) & 0x7f;
36 EXPORT_SYMBOL(omap_prcm_get_reset_sources);
38 /* Resets clock rates and reboots the system. Only called from system.h */
39 void omap_prcm_arch_reset(char mode)
42 omap2_clk_prepare_for_reboot();
44 if (cpu_is_omap24xx())
46 else if (cpu_is_omap34xx())
47 prcm_offs = OMAP3430_GR_MOD;
51 prm_set_mod_reg_bits(OMAP_RST_DPLL3, prcm_offs, RM_RSTCTRL);
54 static inline u32 __omap_prcm_read(void __iomem *base, s16 module, u16 reg)
57 return __raw_readl(base + module + reg);
60 static inline void __omap_prcm_write(u32 value, void __iomem *base,
64 __raw_writel(value, base + module + reg);
67 /* Read a register in a PRM module */
68 u32 prm_read_mod_reg(s16 module, u16 idx)
70 return __omap_prcm_read(prm_base, module, idx);
72 EXPORT_SYMBOL(prm_read_mod_reg);
74 /* Write into a register in a PRM module */
75 void prm_write_mod_reg(u32 val, s16 module, u16 idx)
77 __omap_prcm_write(val, prm_base, module, idx);
79 EXPORT_SYMBOL(prm_write_mod_reg);
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)
86 v = prm_read_mod_reg(module, idx);
89 prm_write_mod_reg(v, module, idx);
93 EXPORT_SYMBOL(prm_rmw_mod_reg_bits);
95 /* Read a register in a CM module */
96 u32 cm_read_mod_reg(s16 module, u16 idx)
98 return __omap_prcm_read(cm_base, module, idx);
100 EXPORT_SYMBOL(cm_read_mod_reg);
102 /* Write into a register in a CM module */
103 void cm_write_mod_reg(u32 val, s16 module, u16 idx)
105 __omap_prcm_write(val, cm_base, module, idx);
107 EXPORT_SYMBOL(cm_write_mod_reg);
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)
114 v = cm_read_mod_reg(module, idx);
117 cm_write_mod_reg(v, module, idx);
121 EXPORT_SYMBOL(cm_rmw_mod_reg_bits);
123 void __init omap2_set_globals_prcm(struct omap_globals *omap2_globals)
125 prm_base = omap2_globals->prm;
126 cm_base = omap2_globals->cm;