2 * Copyright (C) 2012 Spreadtrum Communications Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <soc/sprd/sys_reset.h>
15 #include <linux/string.h>
16 #include <asm/bitops.h>
18 void sprd_set_reboot_mode(const char *cmd)
21 printk("sprd_set_reboot_mode:cmd=%s\n",cmd);
22 if (cmd && !(strncmp(cmd, "recovery", 8))) {
23 sci_adi_raw_write(ANA_RST_STATUS, HWRST_STATUS_RECOVERY);
24 } else if (cmd && !strncmp(cmd, "alarm", 5)) {
25 sci_adi_raw_write(ANA_RST_STATUS, HWRST_STATUS_ALARM);
26 } else if (cmd && !strncmp(cmd, "fastsleep", 9)) {
27 sci_adi_raw_write(ANA_RST_STATUS, HWRST_STATUS_SLEEP);
28 } else if (cmd && !strncmp(cmd, "bootloader", 10)) {
29 sci_adi_raw_write(ANA_RST_STATUS, HWRST_STATUS_FASTBOOT);
30 } else if (cmd && !strncmp(cmd, "panic", 5)) {
31 sci_adi_raw_write(ANA_RST_STATUS, HWRST_STATUS_PANIC);
32 } else if (cmd && !strncmp(cmd, "special", 7)) {
33 sci_adi_raw_write(ANA_RST_STATUS, HWRST_STATUS_SPECIAL);
34 } else if (cmd && !strncmp(cmd, "cftreboot", 9)) {
35 sci_adi_raw_write(ANA_RST_STATUS, HWRST_STATUS_CFTREBOOT);
36 } else if (cmd && !strncmp(cmd, "autodloader", 11)) {
37 sci_adi_raw_write(ANA_RST_STATUS, HWRST_STATUS_AUTODLOADER);
38 } else if (cmd && !strncmp(cmd, "iqmode", 6)) {
39 sci_adi_raw_write(ANA_RST_STATUS, HWRST_STATUS_IQMODE);
41 sci_adi_raw_write(ANA_RST_STATUS, HWRST_STATUS_NORMAL);
43 sci_adi_raw_write(ANA_RST_STATUS, HWRST_STATUS_SPECIAL);
47 void sprd_turnon_watchdog(unsigned int ms)
51 cnt = (ms * 1000) / WDG_CLK;
53 /*enable interface clk*/
54 sci_adi_set(ANA_AGEN, AGEN_WDG_EN);
56 sci_adi_set(ANA_RTC_CLK_EN, AGEN_RTC_WDG_EN);
57 sci_adi_raw_write(WDG_LOCK, WDG_UNLOCK_KEY);
58 sci_adi_set(WDG_CTRL, WDG_NEW_VER_EN);
59 WDG_LOAD_TIMER_VALUE(cnt);
60 sci_adi_set(WDG_CTRL, WDG_CNT_EN_BIT | WDG_RST_EN_BIT);
61 sci_adi_raw_write(WDG_LOCK, (uint16_t) (~WDG_UNLOCK_KEY));
64 void sprd_turnoff_watchdog(void)
66 sci_adi_raw_write(WDG_LOCK, WDG_UNLOCK_KEY);
68 sci_adi_clr(WDG_CTRL, WDG_CNT_EN_BIT);
69 /*disable the reset mode*/
70 sci_adi_clr(WDG_CTRL, WDG_RST_EN_BIT);
71 sci_adi_raw_write(WDG_LOCK, (uint16_t) (~WDG_UNLOCK_KEY));
72 /*stop the interface and work clk*/
73 sci_adi_clr(ANA_AGEN, AGEN_WDG_EN);
74 sci_adi_clr(ANA_RTC_CLK_EN, AGEN_RTC_WDG_EN);