void sunxi_board_close_source(void) { // axp_set_vbus_limit_dc(); #ifdef CONFIG_BOOT_A15 extern int do_savecfg(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); extern void clear_boot_cpu_flag(void); do_savecfg(0,0,1,NULL); clear_boot_cpu_flag(); #endif mmc_exit(); timer_exit(); sunxi_key_exit(); #ifdef CONFIG_SUN6I p2wi_exit(); #endif sunxi_flash_exit(1); //强制关闭FLASH sunxi_sprite_exit(1); sunxi_dma_exit(); disable_interrupts(); interrupt_exit(); #if defined(CONFIG_ARCH_SUN9IW1P1) *( volatile unsigned int *)(0x008000e0) = 0x16aa0000; #endif return ; }
/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ int sunxi_board_shutdown(void) { #if defined(CONFIG_SUNXI_RTC) printf("rtc disable\n"); rtc_disable(); #endif printf("set next system normal\n"); axp_set_next_poweron_status(0x0); board_display_set_exit_mode(0); #ifdef CONFIG_SUNXI_DISPLAY drv_disp_exit(); #endif sunxi_flash_exit(1); //强制关闭FLASH sunxi_sprite_exit(1); disable_interrupts(); interrupt_exit(); tick_printf("power off\n"); axp_set_hardware_poweroff_vol(); axp_set_power_off(); #if defined(CONFIG_ARCH_SUN8IW7P1) power_off(); #endif return 0; }
void sunxi_board_close_source(void) { mmc_exit(); timer_exit(); sunxi_key_exit(); sunxi_flash_exit(1); sunxi_sprite_exit(1); sunxi_dma_exit(); disable_interrupts(); interrupt_exit(); return ; }
/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ int sunxi_sprite_force_erase_key(void) { char buf[SUNXI_MBR_SIZE * SUNXI_MBR_COPY_NUM]; if(sunxi_sprite_init(1)) { printf("sunxi sprite pre init fail\n"); return -1; } //读出量产介质上的MBR if(!sunxi_sprite_read(0, (SUNXI_MBR_SIZE * SUNXI_MBR_COPY_NUM)/512, buf)) { printf("read local mbr on flash failed\n"); sunxi_sprite_exit(1); return -1; } //校验MBR if(sunxi_sprite_verify_mbr(buf)) { printf("the mbr on flash is bad\n"); sunxi_sprite_exit(1); return -1; } if(sunxi_sprite_erase_private_key(buf)) { printf("erase key fail \n"); return -1; } #ifdef CONFIG_SUNXI_SECURE_STORAGE if(sunxi_secure_storage_init()) return -1; if(sunxi_secure_storage_erase("key_burned_flag") == -1) return -1; #endif printf("erase key success \n"); return 0; }
/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ int sunxi_sprite_download_mbr(void *buffer, uint buffer_size) { int ret; if(buffer_size != (SUNXI_MBR_SIZE * SUNXI_MBR_COPY_NUM)) { printf("the mbr size is bad\n"); return -1; } if(sunxi_sprite_init(0)) { printf("sunxi sprite init fail when downlaod mbr\n"); return -1; } if(sunxi_sprite_write(0, buffer_size/512, buffer) == (buffer_size/512)) { debug("mbr write ok\n"); ret = 0; } else { debug("mbr write fail\n"); ret = -1; } if(uboot_spare_head.boot_data.storage_type == 2) { printf("begin to write standard mbr\n"); if(card_download_standard_mbr(buffer)) { printf("write standard mbr err\n"); return -1; } printf("successed to write standard mbr\n"); } if(sunxi_sprite_exit(0)) { printf("sunxi sprite exit fail when downlaod mbr\n"); return -1; } return ret; }
void sunxi_board_close_source(void) { // axp_set_vbus_limit_dc(); mmc_exit(); timer_exit(); sunxi_key_exit(); #ifdef CONFIG_SUN6I p2wi_exit(); #endif sunxi_flash_exit(1); //强制关闭FLASH sunxi_sprite_exit(1); sunxi_dma_exit(); disable_interrupts(); interrupt_exit(); return ; }
/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ void sunxi_board_close_source(void) { // axp_set_vbus_limit_dc(); timer_exit(); sunxi_key_exit(); #ifdef CONFIG_SUN6I p2wi_exit(); #endif sunxi_dma_exit(); sunxi_flash_exit(1); //强制关闭FLASH sunxi_sprite_exit(1); disable_interrupts(); interrupt_exit(); #if defined(CONFIG_ARCH_SUN9IW1P1) *( volatile unsigned int *)(0x008000e0) = 0x16aa0000; #endif return ; }
int sunxi_board_shutdown(void) { printf("set next system normal\n"); axp_set_next_poweron_status(0x0); #ifdef CONFIG_SUNXI_DISPLAY board_display_set_exit_mode(0); drv_disp_exit(); #endif sunxi_flash_exit(1); sunxi_sprite_exit(1); disable_interrupts(); interrupt_exit(); tick_printf("power off\n"); axp_set_hardware_poweroff_vol(); axp_set_power_off(); return 0; }
/* ************************************************************************************************************ * * function * * name : * * parmeters : * * return : * * note : * * ************************************************************************************************************ */ int sunxi_sprite_erase_flash(void *img_mbr_buffer) { uint32_t need_erase_flag = 0; char buf[SUNXI_MBR_SIZE * SUNXI_MBR_COPY_NUM]; //int ret; int nodeoffset; if(sunxi_sprite_erase(0, img_mbr_buffer) > 0) { printf("flash already erased\n"); return 0; } //获取擦除信息,查看是否需要擦除flash //ret = script_parser_fetch("platform", "eraseflag", &need_erase_flag, 1); nodeoffset = fdt_path_offset(working_fdt,FDT_PATH_PLATFORM); if(nodeoffset > 0) { fdt_getprop_u32(working_fdt,nodeoffset,"eraseflag",&need_erase_flag); } if(need_erase_flag) { printf("do need erase flash\n"); } else { printf("not need erase flash\n"); } //当要求强制擦除,不处理私有数据 if(need_erase_flag == 0x11) { printf("force erase flash\n"); sunxi_sprite_erase(1, img_mbr_buffer); return 0; } //检测不到private分区,即不用保护用户数据 if(!sunxi_sprite_probe_prvt(img_mbr_buffer)) { printf("no part need to protect user data\n"); sunxi_sprite_erase(need_erase_flag, img_mbr_buffer); return 0; } //当初始化失败的时候,直接擦除,不处理私有数据 if(sunxi_sprite_init(1)) { debug("sunxi sprite pre init fail, we have to erase it\n"); sunxi_sprite_exit(1); sunxi_sprite_erase(need_erase_flag, img_mbr_buffer); return 0; } debug("nand pre init ok\n"); //读出量产介质上的MBR if(!sunxi_sprite_read(0, (SUNXI_MBR_SIZE * SUNXI_MBR_COPY_NUM)/512, buf)) { printf("read local mbr on flash failed\n"); sunxi_sprite_exit(1); sunxi_sprite_erase(need_erase_flag, img_mbr_buffer); return 0; } //校验MBR if(sunxi_sprite_verify_mbr(buf)) { printf("the mbr on flash is bad\n"); sunxi_sprite_exit(1); sunxi_sprite_erase(need_erase_flag, img_mbr_buffer); return 0; } printf("begin to store data\n"); if(sunxi_sprite_store_part_data(buf) < 0) { sunxi_sprite_exit(1); return -1; } sunxi_sprite_exit(1); printf("need_erase_flag = %d\n", need_erase_flag); //开始擦除 printf("begin to erase\n"); sunxi_sprite_erase(need_erase_flag, img_mbr_buffer); //开始回写private printf("finish erase\n"); sunxi_sprite_init(0); printf("rewrite\n"); if(sunxi_sprite_restore_part_data(img_mbr_buffer)) { sunxi_sprite_exit(0); return -1; } printf("flash exit\n"); sunxi_sprite_exit(0); return 0; }