return r;
}
+
+#define BOOT_MODE_SERIAL_ROM (0x00000030)
+#define PERSIST_WATCHDOG_RESET_BOOT (0x10000000)
+/*BOOT_CFG1[7..4] = 0x3 Boot from Serial ROM (I2C/SPI)*/
+
+#ifdef CONFIG_MXC_REBOOT_MFGMODE
+void do_switch_mfgmode(void)
+{
+ u32 reg;
+
+ /*
+ * During reset, if GPR10[28] is 1, ROM will copy GPR9[25:0]
+ * to SBMR1, which will determine what is the boot device.
+ * Here SERIAL_ROM mode is selected
+ */
+ reg = __raw_readl(SRC_BASE_ADDR + SRC_GPR9);
+ reg |= BOOT_MODE_SERIAL_ROM;
+ __raw_writel(reg, SRC_BASE_ADDR + SRC_GPR9);
+
+ reg = __raw_readl(SRC_BASE_ADDR + SRC_GPR10);
+ reg |= PERSIST_WATCHDOG_RESET_BOOT;
+ __raw_writel(reg, SRC_BASE_ADDR + SRC_GPR10);
+
+}
+
+void mxc_clear_mfgmode(void)
+{
+ u32 reg;
+ reg = __raw_readl(SRC_BASE_ADDR + SRC_GPR9);
+
+ reg &= ~BOOT_MODE_SERIAL_ROM;
+ __raw_writel(reg, SRC_BASE_ADDR + SRC_GPR9);
+
+ reg = __raw_readl(SRC_BASE_ADDR + SRC_GPR10);
+ reg &= ~PERSIST_WATCHDOG_RESET_BOOT;
+ __raw_writel(reg, SRC_BASE_ADDR + SRC_GPR10);
+}
+#endif
+
+#ifdef CONFIG_MXC_REBOOT_ANDROID_CMD
+/* This function will set a bit on SRC_GPR10[7-8] bits to enter
+ * special boot mode. These bits will not clear by watchdog reset, so
+ * it can be checked by bootloader to choose enter different mode.*/
+
+#define ANDROID_RECOVERY_BOOT (1 << 7)
+#define ANDROID_FASTBOOT_BOOT (1 << 8)
+
+void do_switch_recovery(void)
+{
+ u32 reg;
+
+ reg = __raw_readl(SRC_BASE_ADDR + SRC_GPR10);
+ reg |= ANDROID_RECOVERY_BOOT;
+ __raw_writel(reg, SRC_BASE_ADDR + SRC_GPR10);
+}
+
+void do_switch_fastboot(void)
+{
+ u32 reg;
+
+ reg = __raw_readl(SRC_BASE_ADDR + SRC_GPR10);
+ reg |= ANDROID_FASTBOOT_BOOT;
+ __raw_writel(reg, SRC_BASE_ADDR + SRC_GPR10);
+}
+#endif
+
int mxs_reset_block(void __iomem *hwreg)
{
return _mxs_reset_block(hwreg, false);
config HAVE_EPIT
bool
+config MXC_REBOOT_MFGMODE
+ bool "Enable reboot to MFG mode function"
+ help
+ Enable this config to perform "reboot download" to enter download mode.
+
+config MXC_REBOOT_ANDROID_CMD
+ bool "Enable reboot to android recovery and android fastboot"
+ help
+ Enable this config to use "reboot fastboot", "reboot recovery" to
+ enter fastboot and recovery mode.
+
config MXC_USE_EPIT
bool "Use EPIT instead of GPT"
depends on HAVE_EPIT
static void __iomem *wdog_base;
+#ifdef CONFIG_MXC_REBOOT_MFGMODE
+void do_switch_mfgmode(void);
+void mxc_clear_mfgmode(void);
+#else
+void do_switch_mfgmode() {}
+void mxc_clear_mfgmode() {}
+#endif
+
+#ifdef CONFIG_MXC_REBOOT_ANDROID_CMD
+void do_switch_recovery(void);
+void do_switch_fastboot(void);
+#else
+void do_switch_recovery() {}
+void do_switch_fastboot() {}
+#endif
+
+static void arch_reset_special_mode(char mode, const char *cmd)
+{
+ if (strcmp(cmd, "download") == 0)
+ do_switch_mfgmode();
+ else if (strcmp(cmd, "recovery") == 0)
+ do_switch_recovery();
+ else if (strcmp(cmd, "fastboot") == 0)
+ do_switch_fastboot();
+}
+
/*
* Reset the system. It is called by machine_restart().
*/
{
unsigned int wcr_enable;
+ arch_reset_special_mode(mode, cmd);
+
#ifdef CONFIG_ARCH_MX6
/* wait for reset to assert... */
#ifdef CONFIG_MX6_INTER_LDO_BYPASS