From a7359e2fdf25ebe757fdbf54b0571cb85fdb3e10 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Fri, 10 Feb 2017 14:04:42 +0900 Subject: [PATCH] tizen: add recovery boot mode This patch adds recovery boot mode, in which mode, kernel image is loaded from recovery partition and ramdisk image is loaded from ramdisk2 partition. Also, it sets "bootmode=recovery" to bootargs of kernel. Change-Id: I5f6a024962a0d4744266763f7cddec8b6e4e2ea4 Signed-off-by: Seung-Woo Kim --- arch/arm/cpu/armv7/sc8830/misc.c | 15 +++++++++++++++ include/normal_mode.h | 1 + property/boot_mode_regist.c | 2 +- property/cmd_cboot.c | 8 ++++++++ property/normal_emc_mode.c | 8 +++++++- property/normal_mode.c | 15 +++++++++++++-- 6 files changed, 45 insertions(+), 4 deletions(-) diff --git a/arch/arm/cpu/armv7/sc8830/misc.c b/arch/arm/cpu/armv7/sc8830/misc.c index 33cf5fc..fbe348f 100644 --- a/arch/arm/cpu/armv7/sc8830/misc.c +++ b/arch/arm/cpu/armv7/sc8830/misc.c @@ -427,6 +427,7 @@ void pmic_init(void) #define REBOOT_MODE_MASK (0xFFFFFFF0) #define REBOOT_MODE_PREFIX (0x12345670) #define REBOOT_THOR_DOWNLOAD (0x1) +#define REBOOT_RECOVERY (0x4) int tizen_reboot_check(void) { int inform3 = readl(INFORM3); @@ -440,6 +441,20 @@ int tizen_reboot_check(void) return 0; } + +int tizen_reboot_recovery_check(void) +{ + int inform3 = readl(INFORM3); + + if ((inform3 & REBOOT_MODE_MASK) == REBOOT_MODE_PREFIX) { + if ((inform3 & 0xf) == REBOOT_RECOVERY) { + writel(0, INFORM3); + return 1; + } + } + + return 0; +} #endif #define REG32(x) (*((volatile uint32 *)(x))) diff --git a/include/normal_mode.h b/include/normal_mode.h index bd4beba..21d955e 100644 --- a/include/normal_mode.h +++ b/include/normal_mode.h @@ -216,6 +216,7 @@ int creat_cmdline(char * cmdline,boot_img_hdr *hdr); void vlx_entry(); extern char* get_product_sn(void); extern char *calibration_cmd_buf; +void set_recovery_mode(unsigned int recovery_mode); diff --git a/property/boot_mode_regist.c b/property/boot_mode_regist.c index 44dda2d..4d06c1f 100644 --- a/property/boot_mode_regist.c +++ b/property/boot_mode_regist.c @@ -35,8 +35,8 @@ void cmd_mode_regist(CBOOT_MODE_ENTRY *array) MODE_REGIST(CMD_NORMAL_MODE, normal_mode); MODE_REGIST(CMD_CHARGE_MODE, charge_mode); MODE_REGIST(CMD_THOR_MODE, thor_mode); -#ifndef CONFIG_TIZEN MODE_REGIST(CMD_RECOVERY_MODE, recovery_mode); +#ifndef CONFIG_TIZEN MODE_REGIST(CMD_FACTORYTEST_MODE,factorytest_mode); MODE_REGIST(CMD_FASTBOOT_MODE, fastboot_mode); MODE_REGIST(CMD_WATCHDOG_REBOOT, watchdog_mode); diff --git a/property/cmd_cboot.c b/property/cmd_cboot.c index d184fd8..663ad2d 100644 --- a/property/cmd_cboot.c +++ b/property/cmd_cboot.c @@ -230,6 +230,7 @@ boot_mode_enum_type get_mode_from_gpio_extend(void){ #ifdef CONFIG_TIZEN extern int tizen_reboot_check(void); +extern int tizen_reboot_recovery_check(void); #endif int do_cboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) @@ -290,6 +291,13 @@ int do_cboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (tizen_reboot_check()) { bootmode = CMD_THOR_MODE; DBG("do_cboot:boot mode is %d\n",bootmode); + } else if (tizen_reboot_recovery_check()) { +#ifdef CONFIG_RAMDISK_BOOT + bootmode = CMD_RECOVERY_MODE; +#else + bootmode = CMD_NORMAL_MODE; +#endif + DBG("do_cboot:boot mode is %d\n",bootmode); } } diff --git a/property/normal_emc_mode.c b/property/normal_emc_mode.c index cba588b..55b1fa1 100644 --- a/property/normal_emc_mode.c +++ b/property/normal_emc_mode.c @@ -524,6 +524,7 @@ LOCAL int _boot_load_kernel_ramdisk_image(block_dev_desc_t * dev, char *bootmode if (0 == memcmp(bootmode, RECOVERY_PART, strlen(RECOVERY_PART))) { partition = L"recovery"; debugf("enter recovery mode!\n"); + set_recovery_mode(1); } else { partition = L""BOOT_PART; debugf("Enter boot mode (partition name: %s)\n", w2c(partition)); @@ -573,7 +574,12 @@ LOCAL int _boot_load_kernel_ramdisk_image(block_dev_desc_t * dev, char *bootmode #ifdef CONFIG_TIZEN #ifdef CONFIG_RAMDISK_BOOT { - load_ramdisk(PARTS_RAMDISK, RAMDISK_ADR, RAMDISK_SIZE_MB * 1024 * 1024); + char *ramdisk_part; + if (0 == memcmp(bootmode, RECOVERY_PART, strlen(RECOVERY_PART))) + ramdisk_part = PARTS_RAMDISK2; + else + ramdisk_part = PARTS_RAMDISK; + load_ramdisk(ramdisk_part, RAMDISK_ADR, RAMDISK_SIZE_MB * 1024 * 1024); } #endif /* CONFIG_RAMDISK_BOOT */ #else /* CONFIG_TIZEN */ diff --git a/property/normal_mode.c b/property/normal_mode.c index 3ef7204..0e4cd49 100644 --- a/property/normal_mode.c +++ b/property/normal_mode.c @@ -33,6 +33,7 @@ void *harsh_data = harsh_data_buf; unsigned char raw_header[8192]; const int SP09_MAX_PHASE_BUFF_SIZE = sizeof(SP09_PHASE_CHECK_T); unsigned int g_charger_mode = 0; +unsigned int g_recovery_mode = 0; char serial_number_to_transfer[SP09_MAX_SN_LEN]; extern int charger_connected(void); @@ -173,6 +174,9 @@ int fdt_fixup_for_tizen(void *fdt) ptr += sprintf(ptr, CMDLINE_DEFAULT_TIZEN); #ifdef CONFIG_RAMDISK_BOOT + if (g_recovery_mode) + ptr += sprintf(ptr, " bootmode=recovery"); + ptr += sprintf(ptr, " root=/dev/ram0 rw initrd=0x%x,%dM", RAMDISK_ADR, RAMDISK_SIZE_MB); #else @@ -200,11 +204,13 @@ int fdt_fixup_for_tizen(void *fdt) break; case PM_STATE_NORMAL: default: + if (!g_recovery_mode) { #ifdef CONFIG_RAMDISK_BOOT - ptr += sprintf(ptr, " bootmode=ramdisk"); + ptr += sprintf(ptr, " bootmode=ramdisk"); #else - ptr += sprintf(ptr, " bootmode=normal"); + ptr += sprintf(ptr, " bootmode=normal"); #endif + } } thor_save_env("normal"); @@ -389,6 +395,11 @@ static int start_linux() return 0; } +void set_recovery_mode(unsigned int recovery_mode) +{ + g_recovery_mode = recovery_mode; +} + void lcd_display_logo(int backlight_set, ulong bmp_img, size_t size) { #define mdelay(t) ({unsigned long msec=(t); while (msec--) { udelay(1000);}}) //LiWei add -- 2.34.1