diff options
Diffstat (limited to 'board/samsung/koi/koi.c')
-rw-r--r-- | board/samsung/koi/koi.c | 258 |
1 files changed, 99 insertions, 159 deletions
diff --git a/board/samsung/koi/koi.c b/board/samsung/koi/koi.c index 4ba7c151e..31f4cd416 100644 --- a/board/samsung/koi/koi.c +++ b/board/samsung/koi/koi.c @@ -53,6 +53,10 @@ static unsigned long part_blknum[MAX_GPT_PART] = { }; #endif +void Lcd_copy_old_logo(void); +void Lcd_read_bootlogo(void); +int s5p_lcd_draw_bootlogo(void); + #define DEV_NUM 0 DECLARE_GLOBAL_DATA_PTR; @@ -334,15 +338,8 @@ static void set_dieid(char *buf) setenv("dieid#", &dieid); } -#define INFO_ENTRY_NUM 7 -/* - * return: - * 0: all information was already written - * -1: empty - * 1=<: information is insufficient - */ -static int get_bootarg_from_info_partition(char *buf) +static int get_bootarg_from_nvinfo_partition(char *buf) { unsigned long start, count; unsigned char pid; @@ -351,9 +348,8 @@ static int get_bootarg_from_info_partition(char *buf) char startstr[20]; char arg[50]; char *p; - int entry_num = INFO_ENTRY_NUM; - get_boot_part_info(dev_num, 7, &start, &count, &pid); + get_boot_part_info(dev_num, PART_NUM_NVINFO, &start, &count, &pid); if (pid != 0x83 && pid != 0xee) return -1; @@ -381,31 +377,25 @@ static int get_bootarg_from_info_partition(char *buf) strncat(buf, p, 16); /* also set the die-id based on serial no */ set_dieid(p); - --entry_num; } else { - return -1; + strcat(buf, " androidboot.serialno=0123456789abcdef"); } if (strncmp("btmac", (char *)0x48000018, 5) == 0) { p = (char *)0x4800001e; strcat(buf, " board_shiri_bluetooth.btmac="); strncat(buf, p, 17); - --entry_num; } if (strncmp("wifimac", (char *)0x48000030, 7) == 0) { p = (char *)0x48000038; strcat(buf, " board_wifi_bcm.wifimac="); strncat(buf, p, 17); - --entry_num; - } - if (strncmp("mfprocno", (char *)0x4800004a, 8) == 0) { - --entry_num; - } - if (strncmp("mfchkunit", (char *)0x48000059, 9) == 0) { - --entry_num; - } - if (strncmp("mfchkdate", (char *)0x48000073, 9) == 0) { - --entry_num; } +// if (strncmp("mfprocno", (char *)0x4800004a, 8) == 0) { +// } +// if (strncmp("mfchkunit", (char *)0x48000059, 9) == 0) { +// } +// if (strncmp("mfchkdate", (char *)0x48000073, 9) == 0) { +// } if (strncmp("micgain", (char *)0x480000b7, 7) == 0) { p = (char *)0x480000bf; strcat(buf, " snd_soc_koi_ak4678.MicGain="); @@ -417,23 +407,8 @@ static int get_bootarg_from_info_partition(char *buf) sprintf(startstr, "%d", tmp); strcat(buf, " snd_soc_koi_ak4678.IDVol="); strcat(buf, startstr); - --entry_num; - } - return entry_num; -} - -static int copy_info_partition(void) -{ - char arg[50]; - - strcpy(arg, "mmc read 0 0x48000000 0x72AD10 0x1"); - run_command(arg, 0); - if (strncmp("serial", (char *)0x48000000, 6) == 0) { - strcpy(arg, "mmc write 0 0x48000000 0x72C000 0x1"); - run_command(arg, 0); - return 0; } - return -1; + return 0; } @@ -450,50 +425,61 @@ static void get_bootarg_from_img_hdr(char *buf) } } +static int restore_recovery(void) +{ + struct fastboot_boot_img_hdr *fb_hdr = (struct fastboot_boot_img_hdr *)mkbootimg_hdr; + char arg[50]; + + if (memcmp(fb_hdr->magic, (void *)FASTBOOT_BOOT_MAGIC, 8) == 0) + return 0; + + sprintf(arg, "mmc read 0 0x48000000 0x%x 0xA000", CONFIG_RECOVERY_PARTITION_OLD_BLK); + run_command(arg, 0); + if (memcmp((void *)0x48000000, (void *)FASTBOOT_BOOT_MAGIC, 8)) { + printf("There is no valid recovery\n"); + return 0; + } + sprintf(arg, "mmc write 0 0x48000000 0x%x 0xA000", CONFIG_RECOVERY_PARTITION_BLK); + run_command(arg, 0); + memcpy(mkbootimg_hdr, (void *)0x48000000, CFG_FASTBOOT_MKBOOTIMAGE_PAGE_SIZE); + + return 1; +} + static void rw_img_hdr(int recovery, char *rw) { char arg[50]; - char str[20]; - int partition_blk; + int partition_blk = recovery ? CONFIG_RECOVERY_PARTITION_BLK : CONFIG_BOOT_PARTITION_BLK; - sprintf(arg, "mmc %s 0 0x%x ", rw, mkbootimg_hdr); - if (recovery) - partition_blk = CONFIG_RECOVERY_PARTITION_BLK; - else - partition_blk = CONFIG_BOOT_PARTITION_BLK; - sprintf(str, "0x%x 0x4", partition_blk); - strcat(arg, str); + sprintf(arg, "mmc %s 0 0x%x 0x%x 0x4", rw, mkbootimg_hdr, partition_blk); run_command(arg, 0); } -void check_update_bootloader(void) +static int check_update_bootloader(void) { unsigned long start, count; unsigned char pid; int dev_num = 0; - char startstr[20]; char arg[50]; - get_boot_part_info(dev_num, 8, &start, &count, &pid); + get_boot_part_info(dev_num, PART_NUM_BLOADER, &start, &count, &pid); if (pid != 0x83 && pid != 0xee) - return; + return 0; - strcpy(arg, "mmc read 0 0x48000000 "); - sprintf(startstr, "0x%x ", start); - strcat(arg, startstr); - strcat(arg, "0x1000"); + sprintf(arg, "mmc read 0 0x48000000 0x%x 0x1000", start); run_command(arg, 0); - if (memcmp(FASTBOOT_BOOTLOADER_MAGIC, (char *)0x48000000, 8) == 0) { - write_bootloader_img((unsigned char *)0x48000000); - /* zero-out the first byte of bootloader partition */ - memset((void *)0x48000000, 0, 4); - strcpy(arg, "mmc write 0 0x48000000 "); - sprintf(startstr, "0x%x ", start); - strcat(arg, startstr); - strcat(arg, "0x1"); - run_command(arg, 0); - } + if (memcmp(FASTBOOT_BOOTLOADER_MAGIC, (char *)0x48000000, 8)) + return 0; + + write_bootloader_img((unsigned char *)0x48000000); + + /* zero-out the first byte of bootloader partition */ + memset((void *)0x48000000, 0, 8); + sprintf(arg, "mmc write 0 0x48000000 0x%x 0x1", start); + run_command(arg, 0); + + return 1; } static int rw_raw_kernel(int recovery, unsigned char *buffer, char *rw) @@ -547,6 +533,7 @@ void boot_kernel(int recovery) struct fastboot_boot_img_hdr *fb_hdr = (struct fastboot_boot_img_hdr *)mkbootimg_hdr; char ramdisk_size[32]; + printf("boot_kernel %d\n", recovery); /* write protect boot(u-boot, bl1, ...) partition */ run_command("mmc_wp 0x0 1 0", 0); rw_raw_kernel(recovery, NULL, "read"); @@ -723,20 +710,18 @@ static int check_recovery_in_misc(void) unsigned long start, count; unsigned char pid; int dev_num = 0; - char startstr[20]; char arg[50]; - get_boot_part_info(dev_num, 5, &start, &count, &pid); + get_boot_part_info(dev_num, PART_NUM_MISC, &start, &count, &pid); if (pid != 0x83 && pid != 0xee) return 0; - strcpy(arg, "mmc read 0 0x48000000 "); - sprintf(startstr, "0x%x ", start); - strcat(arg, startstr); - strcat(arg, "0x1"); + sprintf(arg, "mmc read 0 0x48000000 0x%x 0x1", start); run_command(arg, 0); - if (strncmp("boot-recovery", (char *)0x48000000, 13) == 0) + if (strncmp("boot-recovery", (char *)0x48000000, 13) == 0) { + printf("found boot-recovery\n"); return 1; + } return 0; } @@ -787,48 +772,32 @@ int board_late_init(void) pmic_set_ldo2_voltage(); } -#ifdef CONFIG_RECOVERY_MODE - u32 second_boot_info = readl(CONFIG_SECONDARY_BOOT_INFORM_BASE); + if (OmPin != BOOT_MMCSD) { + run_command("lcd 0", 0); - if (second_boot_info == 1) { - printf("###Recovery Mode(SDMMC)###\n"); - writel(0x0, CONFIG_SECONDARY_BOOT_INFORM_BASE); - setenv("bootcmd", CONFIG_RECOVERYCOMMAND_SDMMC); - } -#ifdef CONFIG_EXYNOS_DA - second_boot_info = readl(CONFIG_SECONDARY_BOOT_INFORM_BASE); - if (second_boot_info == 2) { - printf("###USB Download### om:%d\n", readl(&pmu->inform3)); - writel(0x0, CONFIG_SECONDARY_BOOT_INFORM_BASE); - writel(BOOT_EMMC_4_4, &pmu->inform3); - run_command(CFG_DNW_AUTO_CFG_PARTITION, 0); // make partition - setenv("bootcmd", "dnw v05"); - printf("###USB Download### om:%d\n", readl(&pmu->inform3)); - } -#endif -#endif - if (OmPin != BOOT_MMCSD) { - run_command("lcd 0", 0); - - mode = readl(&pmu->inform4); - if (mode == 0) { // normal boot - pressed_key = check_key(); - if (pressed_key & 1) { // Volume up - if (select_mode() == 0) { - mode = CONFIG_FASTBOOT_MODE; - show_selected(0, 1); - } else { - mode = CONFIG_FACTORY_RESET_MODE; - show_selected(1, 1); + Lcd_read_bootlogo(); + if (s5p_lcd_draw_bootlogo()) { + Lcd_copy_old_logo(); + s5p_lcd_draw_bootlogo(); + } + + mode = readl(&pmu->inform4); + if (mode == 0) { // normal boot + pressed_key = check_key(); + if (pressed_key & 1) { // Volume up + if (select_mode() == 0) { + mode = CONFIG_FASTBOOT_MODE; + show_selected(0, 1); + } else { + mode = CONFIG_FACTORY_RESET_MODE; + show_selected(1, 1); + } } + } else if (mode == CONFIG_FASTBOOT_MODE) { + show_selected(0, 1); } - } else if (mode == CONFIG_FASTBOOT_MODE) { - show_selected(0, 1); - } else if (mode == CONFIG_FACTORY_RESET_MODE) { - Lcd_read_bootlogo(); - s5p_lcd_draw_bootlogo(); } - } + memset(tmp_buf,0,sizeof(tmp_buf)); if (OmPin == BOOT_MMCSD) { @@ -846,42 +815,14 @@ int board_late_init(void) } else { int create_gpt = 0; - if (find_gpt_part_name("recovery") != 0 - || find_gpt_part_name("boot") != 0 - || find_gpt_part_name("info") != 0 - || find_gpt_part_name("bootloader") != 0) { + if (find_gpt_part_name("nvinfo") != 0 || + find_gpt_part_name("bloader") != 0) { create_gpt = 1; } else if (model && find_gpt_part_name("oem") != 0) { create_gpt = 1; } else if (model == 0 && find_gpt_part_name("oem") == 0) { create_gpt = 1; } - #if 0 - else { - unsigned long start, count; - unsigned char pid; - int i; - - /* check if partitions are aligned with the partition - * information obtained from the partition table. - */ - for (i = 0; i < MAX_GPT_PART; i++) { - get_boot_part_info(DEV_NUM, i+1, &start, &count, &pid); - if (i == 0 && start != CONFIG_GPT_RECOVERY_START_BLK) { - create_gpt = 1; - break; - } else if (pid != 0xee) { - printf("Part%d: NOT GPT PARTITION ERROR !!\n", i); - create_gpt = 1; - break; - } else if (count != part_blknum[i]) { - printf("Part%d: Block Number differ!!\n", i); - create_gpt = 1; - break; - } - } - } - #endif if (create_gpt) { run_command("env default -f",0); // run_command("run make_gpt_part",0); @@ -899,37 +840,36 @@ int board_late_init(void) else strcat(tmp_buf, "androidboot.hardware=koi"); - if ((ret = get_bootarg_from_info_partition(tmp_buf)) < 0) { - if (copy_info_partition() == 0) // copy from old location - ret = get_bootarg_from_info_partition(tmp_buf); // retry - } + ret = get_bootarg_from_nvinfo_partition(tmp_buf); if (ret == 0) { /* power-on write protect info partition */ run_command("mmc_wp 0x72c000 1 1", 0); } - if (check_recovery_in_misc()) - mode = CONFIG_FACTORY_RESET_MODE; - rw_img_hdr(mode==CONFIG_FACTORY_RESET_MODE ? 1:0, "read"); - get_bootarg_from_img_hdr(tmp_buf); - setenv("bootargs", tmp_buf); - - if (mode == CONFIG_FACTORY_RESET_MODE) { + if (check_update_bootloader()) { writel(CONFIG_UPDATE_RESET_MODE, &pmu->inform4); - boot_kernel(1); + printf("bootloader update complete\n"); + run_command("reset", 0); } - if (mode == CONFIG_UPDATE_RESET_MODE) { + rw_img_hdr(1, "read"); + if (restore_recovery() || mode == CONFIG_UPDATE_RESET_MODE) { + mode = CONFIG_FACTORY_RESET_MODE; + printf("goto recovery 2nd-phase\n"); writel(0x0, &pmu->inform4); - /* check if we need to update the bootloader as well */ - check_update_bootloader(); - - run_command(CONFIG_UPDATE_RESET_COMMAND, 0); } + if (mode == 0 && check_recovery_in_misc()) + mode = CONFIG_FACTORY_RESET_MODE; + rw_img_hdr(mode == CONFIG_FACTORY_RESET_MODE ? 1 : 0, "read"); + get_bootarg_from_img_hdr(tmp_buf); + setenv("bootargs", tmp_buf); + + if (mode == CONFIG_FACTORY_RESET_MODE) + boot_kernel(1); - if(mode == CONFIG_FASTBOOT_MODE) { + if (mode == CONFIG_FASTBOOT_MODE) { writel(0x0, &pmu->inform4); printf("Download Mode \n"); run_command("fastboot", 0); |