From e696f7dac56591a5616b397bc32a1d9bb57147ee Mon Sep 17 00:00:00 2001 From: Eric Sun Date: Wed, 30 Nov 2011 13:41:04 +0800 Subject: ENGR00163513 MX6Q-UBOOT : Add download_mode cmd Add "download_mode" command to U-Boot. It will force a system reset and let boot running in "boot from serial rom" mode, which can be used by manufacturing tool. The command will triggle a write to SRC_GPR9 and SRC_GPR10, then triggle a watchdog reset. GPR9 and GPR10 can maintain their value during the reset, the value in it make ROM to start in "boot from serial rom" mode. After that GPR9 and GPR10 are written by their original value for normal boot. Signed-off-by: Eric Sun --- cpu/arm_cortexa8/mx6/generic.c | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'cpu') diff --git a/cpu/arm_cortexa8/mx6/generic.c b/cpu/arm_cortexa8/mx6/generic.c index 175cd03..8e5c9a6 100644 --- a/cpu/arm_cortexa8/mx6/generic.c +++ b/cpu/arm_cortexa8/mx6/generic.c @@ -889,4 +889,54 @@ int otp_clk_disable(void) return 0; } +#ifdef CONFIG_CMD_IMX_DOWNLOAD_MODE +#define PERSIST_WATCHDOG_RESET_BOOT (0x10000000) +/*BOOT_CFG1[7..4] = 0x3 Boot from Serial ROM (I2C/SPI)*/ +#define BOOT_MODE_SERIAL_ROM (0x00000030) + +/* this function should call before enter linux, otherwise, you + * watchdog reset will enter mfg download mode again, clear this bit + * to prevent this behavior */ +void clear_mfgmode_mem(void) +{ + u32 reg; + reg = readl(SRC_BASE_ADDR + SRC_GPR9); + + reg &= ~BOOT_MODE_SERIAL_ROM; + writel(reg, SRC_BASE_ADDR + SRC_GPR9); + + reg = readl(SRC_BASE_ADDR + SRC_GPR10); + reg &= ~PERSIST_WATCHDOG_RESET_BOOT; + reg = writel(reg, SRC_BASE_ADDR + SRC_GPR10); +} + +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 = readl(SRC_BASE_ADDR + SRC_GPR9); + reg |= BOOT_MODE_SERIAL_ROM; + writel(reg, SRC_BASE_ADDR + SRC_GPR9); + + reg = readl(SRC_BASE_ADDR + SRC_GPR10); + reg |= PERSIST_WATCHDOG_RESET_BOOT; + writel(reg, SRC_BASE_ADDR + SRC_GPR10); + + /* + * this watchdog reset will let chip enter mfgtool download + * mode. + */ + do_reset(NULL, 0, 0, NULL); +} + +U_BOOT_CMD( + download_mode, 1, 1, do_switch_mfgmode, + "download_mode - enter i.MX serial/usb download mode", + ""); +#endif -- cgit v1.1