tizen: add recovery boot mode 18/114118/1
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 10 Feb 2017 05:04:42 +0000 (14:04 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 10 Feb 2017 05:15:33 +0000 (14:15 +0900)
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 <sw0312.kim@samsung.com>
arch/arm/cpu/armv7/sc8830/misc.c
include/normal_mode.h
property/boot_mode_regist.c
property/cmd_cboot.c
property/normal_emc_mode.c
property/normal_mode.c

index 33cf5fc..fbe348f 100644 (file)
@@ -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)))
index bd4beba..21d955e 100644 (file)
@@ -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);
 
 
 
index 44dda2d..4d06c1f 100644 (file)
@@ -35,8 +35,8 @@ void cmd_mode_regist(CBOOT_MODE_ENTRY *array)
     MODE_REGIST(CMD_NORMAL_MODE, normal_mode);\r
     MODE_REGIST(CMD_CHARGE_MODE, charge_mode);\r
        MODE_REGIST(CMD_THOR_MODE, thor_mode);\r
-#ifndef CONFIG_TIZEN\r
     MODE_REGIST(CMD_RECOVERY_MODE, recovery_mode);\r
+#ifndef CONFIG_TIZEN\r
     MODE_REGIST(CMD_FACTORYTEST_MODE,factorytest_mode);\r
     MODE_REGIST(CMD_FASTBOOT_MODE, fastboot_mode);\r
     MODE_REGIST(CMD_WATCHDOG_REBOOT, watchdog_mode);\r
index d184fd8..663ad2d 100644 (file)
@@ -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);
                }
 
        }
index cba588b..55b1fa1 100644 (file)
@@ -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 */
index 3ef7204..0e4cd49 100644 (file)
@@ -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