aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ab8500-sysctrl.c
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2013-02-12 10:11:19 -0500
committerLee Jones <lee.jones@linaro.org>2013-03-06 23:28:16 -0500
commit75932094601b404fc9ef28f7b6c0aa83dd619af0 (patch)
tree721cb5fc4835fa602eae0b011d1d08627cfb147f /drivers/mfd/ab8500-sysctrl.c
parent9581ae39de8833a7affaef24caadef2830603fef (diff)
mfd: ab8500-sysctrl: Add new reset function
Add a new reset function which uses the AB WD with 0 timeout. Signed-off-by: Lee Jones <lee.jones@linaro.org> Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/ab8500-sysctrl.c')
-rw-r--r--drivers/mfd/ab8500-sysctrl.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
index 6ac63a05893c..f43c42b9f32c 100644
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -15,6 +15,12 @@
15#include <linux/mfd/abx500/ab8500.h> 15#include <linux/mfd/abx500/ab8500.h>
16#include <linux/mfd/abx500/ab8500-sysctrl.h> 16#include <linux/mfd/abx500/ab8500-sysctrl.h>
17 17
18/* RtcCtrl bits */
19#define AB8500_ALARM_MIN_LOW 0x08
20#define AB8500_ALARM_MIN_MID 0x09
21#define RTC_CTRL 0x0B
22#define RTC_ALARM_ENABLE 0x4
23
18static struct device *sysctrl_dev; 24static struct device *sysctrl_dev;
19 25
20void ab8500_power_off(void) 26void ab8500_power_off(void)
@@ -79,6 +85,63 @@ shutdown:
79 } 85 }
80} 86}
81 87
88/*
89 * Use the AB WD to reset the platform. It will perform a hard
90 * reset instead of a soft reset. Write the reset reason to
91 * the AB before reset, which can be read upon restart.
92 */
93void ab8500_restart(char mode, const char *cmd)
94{
95 struct ab8500_platform_data *plat;
96 struct ab8500_sysctrl_platform_data *pdata;
97 u16 reason = 0;
98 u8 val;
99
100 if (sysctrl_dev == NULL) {
101 pr_err("%s: sysctrl not initialized\n", __func__);
102 return;
103 }
104
105 plat = dev_get_platdata(sysctrl_dev->parent);
106 pdata = plat->sysctrl;
107 if (pdata->reboot_reason_code)
108 reason = pdata->reboot_reason_code(cmd);
109 else
110 pr_warn("[%s] No reboot reason set. Default reason %d\n",
111 __func__, reason);
112
113 /*
114 * Disable RTC alarm, just a precaution so that no alarm
115 * is running when WD reset is executed.
116 */
117 abx500_get_register_interruptible(sysctrl_dev, AB8500_RTC,
118 RTC_CTRL , &val);
119 abx500_set_register_interruptible(sysctrl_dev, AB8500_RTC,
120 RTC_CTRL , (val & ~RTC_ALARM_ENABLE));
121
122 /*
123 * Android is not using the RTC alarm registers during reboot
124 * so we borrow them for writing the reason of reset
125 */
126
127 /* reason[8 LSB] */
128 val = reason & 0xFF;
129 abx500_set_register_interruptible(sysctrl_dev, AB8500_RTC,
130 AB8500_ALARM_MIN_LOW , val);
131
132 /* reason[8 MSB] */
133 val = (reason>>8) & 0xFF;
134 abx500_set_register_interruptible(sysctrl_dev, AB8500_RTC,
135 AB8500_ALARM_MIN_MID , val);
136
137 /* Setting WD timeout to 0 */
138 ab8500_sysctrl_write(AB8500_MAINWDOGTIMER, 0xFF, 0x0);
139
140 /* Setting the parameters to AB8500 WD*/
141 ab8500_sysctrl_write(AB8500_MAINWDOGCTRL, 0xFF, (AB8500_ENABLE_WD |
142 AB8500_WD_RESTART_ON_EXPIRE | AB8500_KICK_WD));
143}
144
82static inline bool valid_bank(u8 bank) 145static inline bool valid_bank(u8 bank)
83{ 146{
84 return ((bank == AB8500_SYS_CTRL1_BLOCK) || 147 return ((bank == AB8500_SYS_CTRL1_BLOCK) ||