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 <asm/arch/common.h>
22 #include <asm/arch/prcm.h>
26 #include "prm-regbits-24xx.h"
28 static void __iomem *prm_base;
29 static void __iomem *cm_base;
31 extern void omap2_clk_prepare_for_reboot(void);
33 u32 omap_prcm_get_reset_sources(void)
35 return prm_read_mod_reg(WKUP_MOD, RM_RSTST) & 0x7f;
37 EXPORT_SYMBOL(omap_prcm_get_reset_sources);
39 /* Resets clock rates and reboots the system. Only called from system.h */
40 void omap_prcm_arch_reset(char mode)
43 omap2_clk_prepare_for_reboot();
45 if (cpu_is_omap24xx()) {
46 wkup = prm_read_mod_reg(WKUP_MOD, RM_RSTCTRL) | OMAP_RST_DPLL3;
47 prm_write_mod_reg(wkup, WKUP_MOD, RM_RSTCTRL);
51 static inline u32 __omap_prcm_read(void __iomem *base, s16 module, u16 reg)
54 return __raw_readl(base + module + reg);
57 static inline void __omap_prcm_write(u32 value, void __iomem *base,
61 __raw_writel(value, base + module + reg);
64 /* Read a register in a PRM module */
65 u32 prm_read_mod_reg(s16 module, u16 idx)
67 return __omap_prcm_read(prm_base, module, idx);
69 EXPORT_SYMBOL(prm_read_mod_reg);
71 /* Write into a register in a PRM module */
72 void prm_write_mod_reg(u32 val, s16 module, u16 idx)
74 __omap_prcm_write(val, prm_base, module, idx);
76 EXPORT_SYMBOL(prm_write_mod_reg);
78 /* Read a register in a CM module */
79 u32 cm_read_mod_reg(s16 module, u16 idx)
81 return __omap_prcm_read(cm_base, module, idx);
83 EXPORT_SYMBOL(cm_read_mod_reg);
85 /* Write into a register in a CM module */
86 void cm_write_mod_reg(u32 val, s16 module, u16 idx)
88 __omap_prcm_write(val, cm_base, module, idx);
90 EXPORT_SYMBOL(cm_write_mod_reg);
92 void __init omap2_set_globals_prcm(struct omap_globals *omap2_globals)
94 prm_base = omap2_globals->prm;
95 cm_base = omap2_globals->cm;