]> Pileus Git - ~andy/linux/blob - arch/arm/mach-omap2/prm2xxx.c
Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6
[~andy/linux] / arch / arm / mach-omap2 / prm2xxx.c
1 /*
2  * OMAP2xxx PRM module functions
3  *
4  * Copyright (C) 2010-2012 Texas Instruments, Inc.
5  * Copyright (C) 2010 Nokia Corporation
6  * BenoĆ®t Cousson
7  * Paul Walmsley
8  * Rajendra Nayak <rnayak@ti.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/errno.h>
17 #include <linux/err.h>
18 #include <linux/io.h>
19 #include <linux/irq.h>
20
21 #include "soc.h"
22 #include "common.h"
23 #include "vp.h"
24 #include "powerdomain.h"
25 #include "clockdomain.h"
26 #include "prm2xxx.h"
27 #include "cm2xxx_3xxx.h"
28 #include "prm-regbits-24xx.h"
29
30 /*
31  * omap2xxx_prm_reset_src_map - map from bits in the PRM_RSTST_WKUP
32  *   hardware register (which are specific to the OMAP2xxx SoCs) to
33  *   reset source ID bit shifts (which is an OMAP SoC-independent
34  *   enumeration)
35  */
36 static struct prm_reset_src_map omap2xxx_prm_reset_src_map[] = {
37         { OMAP_GLOBALCOLD_RST_SHIFT, OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT },
38         { OMAP_GLOBALWARM_RST_SHIFT, OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT },
39         { OMAP24XX_SECU_VIOL_RST_SHIFT, OMAP_SECU_VIOL_RST_SRC_ID_SHIFT },
40         { OMAP24XX_MPU_WD_RST_SHIFT, OMAP_MPU_WD_RST_SRC_ID_SHIFT },
41         { OMAP24XX_SECU_WD_RST_SHIFT, OMAP_SECU_WD_RST_SRC_ID_SHIFT },
42         { OMAP24XX_EXTWMPU_RST_SHIFT, OMAP_EXTWARM_RST_SRC_ID_SHIFT },
43         { -1, -1 },
44 };
45
46 /**
47  * omap2xxx_prm_read_reset_sources - return the last SoC reset source
48  *
49  * Return a u32 representing the last reset sources of the SoC.  The
50  * returned reset source bits are standardized across OMAP SoCs.
51  */
52 static u32 omap2xxx_prm_read_reset_sources(void)
53 {
54         struct prm_reset_src_map *p;
55         u32 r = 0;
56         u32 v;
57
58         v = omap2_prm_read_mod_reg(WKUP_MOD, OMAP2_RM_RSTST);
59
60         p = omap2xxx_prm_reset_src_map;
61         while (p->reg_shift >= 0 && p->std_shift >= 0) {
62                 if (v & (1 << p->reg_shift))
63                         r |= 1 << p->std_shift;
64                 p++;
65         }
66
67         return r;
68 }
69
70 /**
71  * omap2xxx_prm_dpll_reset - use DPLL reset to reboot the OMAP SoC
72  *
73  * Set the DPLL reset bit, which should reboot the SoC.  This is the
74  * recommended way to restart the SoC.  No return value.
75  */
76 void omap2xxx_prm_dpll_reset(void)
77 {
78         omap2_prm_set_mod_reg_bits(OMAP_RST_DPLL3_MASK, WKUP_MOD,
79                                    OMAP2_RM_RSTCTRL);
80         /* OCP barrier */
81         omap2_prm_read_mod_reg(WKUP_MOD, OMAP2_RM_RSTCTRL);
82 }
83
84 int omap2xxx_clkdm_sleep(struct clockdomain *clkdm)
85 {
86         omap2_prm_set_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
87                                    clkdm->pwrdm.ptr->prcm_offs,
88                                    OMAP2_PM_PWSTCTRL);
89         return 0;
90 }
91
92 int omap2xxx_clkdm_wakeup(struct clockdomain *clkdm)
93 {
94         omap2_prm_clear_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
95                                      clkdm->pwrdm.ptr->prcm_offs,
96                                      OMAP2_PM_PWSTCTRL);
97         return 0;
98 }
99
100 struct pwrdm_ops omap2_pwrdm_operations = {
101         .pwrdm_set_next_pwrst   = omap2_pwrdm_set_next_pwrst,
102         .pwrdm_read_next_pwrst  = omap2_pwrdm_read_next_pwrst,
103         .pwrdm_read_pwrst       = omap2_pwrdm_read_pwrst,
104         .pwrdm_set_logic_retst  = omap2_pwrdm_set_logic_retst,
105         .pwrdm_set_mem_onst     = omap2_pwrdm_set_mem_onst,
106         .pwrdm_set_mem_retst    = omap2_pwrdm_set_mem_retst,
107         .pwrdm_read_mem_pwrst   = omap2_pwrdm_read_mem_pwrst,
108         .pwrdm_read_mem_retst   = omap2_pwrdm_read_mem_retst,
109         .pwrdm_wait_transition  = omap2_pwrdm_wait_transition,
110 };
111
112 /*
113  *
114  */
115
116 static struct prm_ll_data omap2xxx_prm_ll_data = {
117         .read_reset_sources = &omap2xxx_prm_read_reset_sources,
118 };
119
120 int __init omap2xxx_prm_init(void)
121 {
122         if (!cpu_is_omap24xx())
123                 return 0;
124
125         return prm_register(&omap2xxx_prm_ll_data);
126 }
127
128 static void __exit omap2xxx_prm_exit(void)
129 {
130         if (!cpu_is_omap24xx())
131                 return;
132
133         /* Should never happen */
134         WARN(prm_unregister(&omap2xxx_prm_ll_data),
135              "%s: prm_ll_data function pointer mismatch\n", __func__);
136 }
137 __exitcall(omap2xxx_prm_exit);