blob: 1f777bf2bc8f152071bd05a12279499927c23dd5 [file] [log] [blame]
Paul Walmsley49815392012-10-21 01:01:10 -06001/*
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 "common.h"
22#include <plat/cpu.h>
23#include <plat/prcm.h>
24
25#include "vp.h"
26#include "powerdomain.h"
Paul Walmsley4bd52592012-10-21 01:01:11 -060027#include "clockdomain.h"
Paul Walmsley49815392012-10-21 01:01:10 -060028#include "prm2xxx.h"
29#include "cm2xxx_3xxx.h"
30#include "prm-regbits-24xx.h"
31
Paul Walmsley2bb2a5d2012-10-21 01:01:13 -060032/*
33 * omap2xxx_prm_reset_src_map - map from bits in the PRM_RSTST_WKUP
34 * hardware register (which are specific to the OMAP2xxx SoCs) to
35 * reset source ID bit shifts (which is an OMAP SoC-independent
36 * enumeration)
37 */
38static struct prm_reset_src_map omap2xxx_prm_reset_src_map[] = {
39 { OMAP_GLOBALCOLD_RST_SHIFT, OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT },
40 { OMAP_GLOBALWARM_RST_SHIFT, OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT },
41 { OMAP24XX_SECU_VIOL_RST_SHIFT, OMAP_SECU_VIOL_RST_SRC_ID_SHIFT },
42 { OMAP24XX_MPU_WD_RST_SHIFT, OMAP_MPU_WD_RST_SRC_ID_SHIFT },
43 { OMAP24XX_SECU_WD_RST_SHIFT, OMAP_SECU_WD_RST_SRC_ID_SHIFT },
44 { OMAP24XX_EXTWMPU_RST_SHIFT, OMAP_EXTWARM_RST_SRC_ID_SHIFT },
45 { -1, -1 },
46};
47
48/**
49 * omap2xxx_prm_read_reset_sources - return the last SoC reset source
50 *
51 * Return a u32 representing the last reset sources of the SoC. The
52 * returned reset source bits are standardized across OMAP SoCs.
53 */
54static u32 omap2xxx_prm_read_reset_sources(void)
55{
56 struct prm_reset_src_map *p;
57 u32 r = 0;
58 u32 v;
59
60 v = omap2_prm_read_mod_reg(WKUP_MOD, OMAP2_RM_RSTST);
61
62 p = omap2xxx_prm_reset_src_map;
63 while (p->reg_shift >= 0 && p->std_shift >= 0) {
64 if (v & (1 << p->reg_shift))
65 r |= 1 << p->std_shift;
66 p++;
67 }
68
69 return r;
70}
71
Paul Walmsleyd08cce62012-10-29 20:55:46 -060072/**
73 * omap2xxx_prm_dpll_reset - use DPLL reset to reboot the OMAP SoC
74 *
75 * Set the DPLL reset bit, which should reboot the SoC. This is the
76 * recommended way to restart the SoC. No return value.
77 */
78void omap2xxx_prm_dpll_reset(void)
79{
80 omap2_prm_set_mod_reg_bits(OMAP_RST_DPLL3_MASK, WKUP_MOD,
81 OMAP2_RM_RSTCTRL);
82 /* OCP barrier */
83 omap2_prm_read_mod_reg(WKUP_MOD, OMAP2_RM_RSTCTRL);
84}
85
Paul Walmsley4bd52592012-10-21 01:01:11 -060086int omap2xxx_clkdm_sleep(struct clockdomain *clkdm)
87{
88 omap2_prm_set_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
89 clkdm->pwrdm.ptr->prcm_offs,
90 OMAP2_PM_PWSTCTRL);
91 return 0;
92}
93
94int omap2xxx_clkdm_wakeup(struct clockdomain *clkdm)
95{
96 omap2_prm_clear_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
97 clkdm->pwrdm.ptr->prcm_offs,
98 OMAP2_PM_PWSTCTRL);
99 return 0;
100}
101
Paul Walmsley49815392012-10-21 01:01:10 -0600102struct pwrdm_ops omap2_pwrdm_operations = {
103 .pwrdm_set_next_pwrst = omap2_pwrdm_set_next_pwrst,
104 .pwrdm_read_next_pwrst = omap2_pwrdm_read_next_pwrst,
105 .pwrdm_read_pwrst = omap2_pwrdm_read_pwrst,
106 .pwrdm_set_logic_retst = omap2_pwrdm_set_logic_retst,
107 .pwrdm_set_mem_onst = omap2_pwrdm_set_mem_onst,
108 .pwrdm_set_mem_retst = omap2_pwrdm_set_mem_retst,
109 .pwrdm_read_mem_pwrst = omap2_pwrdm_read_mem_pwrst,
110 .pwrdm_read_mem_retst = omap2_pwrdm_read_mem_retst,
111 .pwrdm_wait_transition = omap2_pwrdm_wait_transition,
112};
Paul Walmsley2bb2a5d2012-10-21 01:01:13 -0600113
114/*
115 *
116 */
117
118static struct prm_ll_data omap2xxx_prm_ll_data = {
119 .read_reset_sources = &omap2xxx_prm_read_reset_sources,
120};
121
122static int __init omap2xxx_prm_init(void)
123{
124 if (!cpu_is_omap24xx())
125 return 0;
126
127 return prm_register(&omap2xxx_prm_ll_data);
128}
129subsys_initcall(omap2xxx_prm_init);
130
131static void __exit omap2xxx_prm_exit(void)
132{
133 if (!cpu_is_omap24xx())
134 return;
135
136 /* Should never happen */
137 WARN(prm_unregister(&omap2xxx_prm_ll_data),
138 "%s: prm_ll_data function pointer mismatch\n", __func__);
139}
140__exitcall(omap2xxx_prm_exit);