/** NVT common header file Define common functions @file nvt_common.h @ingroup @note Copyright Novatek Microelectronics Corp. 2016. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. */ #ifndef __ARCH_COMMON_NVT_COMMON_H__ #define __ARCH_COMMON_NVT_COMMON_H__ #include #include #include #include #include #include extern unsigned long nvt_tm0_cnt_beg; extern unsigned long nvt_tm0_cnt_end; extern unsigned long nvt_shminfo_comm_uboot_boot_func; extern unsigned long nvt_shminfo_comm_core1_start; extern unsigned long nvt_shminfo_comm_core2_start; extern unsigned long nvt_shminfo_comm_itron_comp_addr; extern unsigned long nvt_shminfo_comm_itron_comp_len; extern unsigned long nvt_shminfo_comm_fw_update_addr; extern unsigned long nvt_shminfo_comm_fw_update_len; extern unsigned int nvt_shminfo_boot_fdt_addr; extern unsigned long nvt_ramdisk_addr; extern unsigned long nvt_ramdisk_size; extern unsigned long nvt_ker_img_addr; extern unsigned long nvt_ker_img_size; extern uint8_t *nvt_fdt_buffer; extern void nvt_rtc_init(void); extern char *nvt_bin_name; extern char *nvt_bin_name_t; extern char *nvt_bin_name_r; extern char *nvt_bin_name_modelext; extern u32 nvt_flash_ecc_err_pages[100]; extern u32 uart_disable_anchor; extern u32 rtos_disable_anchor; extern EMB_PARTITION_FDT_TRANSLATE_TABLE emb_part_fdt_map[EMBTYPE_TOTAL_SIZE]; extern EMB_PARTITION emb_partition_info_data_curr[EMB_PARTITION_INFO_COUNT]; extern EMB_PARTITION emb_partition_info_data_new[EMB_PARTITION_INFO_COUNT]; /* print color setting */ #define ANSI_COLOR_RED "\x1b[31m" #define ANSI_COLOR_GREEN "\x1b[32m" #define ANSI_COLOR_YELLOW "\x1b[33m" #define ANSI_COLOR_BLUE "\x1b[34m" #define ANSI_COLOR_MAGENTA "\x1b[35m" #define ANSI_COLOR_CYAN "\x1b[36m" #define ANSI_COLOR_WHITE "\x1b[37m" #define ANSI_COLOR_RESET "\x1b[0m" /* RTOS codeinfo */ #define RTOS_CODEINFO_OFFSET 0x3F0 #define RTOS_CODEINFO_SUB_ZI_LIMIT 0x14 //(image_general_zi_zi_limit,uboot_end) /* Error code for update all-in-one */ #define ERR_NVT_UPDATE_FAILED -1 #define ERR_NVT_UPDATE_OPENFAILED -2 #define ERR_NVT_UPDATE_READ_FAILED -3 #define ERR_NVT_UPDATE_NO_NEED -4 /*Bininfo boot info. */ #define COMM_UBOOT_BOOT_FUNC_BOOT_UPDFIRM 1 #define COMM_UBOOT_BOOT_FUNC_BOOT_UPD_FRM_USB 2 #define COMM_UBOOT_BOOT_FUNC_BOOT_UPD_FRM_ETH 3 #define COMM_UBOOT_BOOT_FUNC_BOOT_FORMAT_ROOTFS 4 #define COMM_UBOOT_BOOT_FUNC_BOOT_RECOVERY_SYS 5 #define COMM_UBOOT_BOOT_FUNC_BOOT_REASON_MASK 0xff << 0 #define COMM_UBOOT_BOOT_FUNC_BOOT_DONE 1 << 8 #define COMM_UBOOT_BOOT_FUNC_BOOT_NG 2 << 8 #define COMM_UBOOT_BOOT_FUNC_BOOT_DONE_MASK 0xff << 8 #define COMM_UBOOT_BOOT_FUNC_LOAD_DSP_MASK 0xff << 16 #define COMM_UBOOT_BOOT_FUNC_LOAD_DSP_DONE 1 << 16 #define COMM_UBOOT_BOOT_FUNC_LOAD_DSP_NG 2 << 16 #define nvt_readb(offset) readb(offset) #define nvt_readw(offset) readw(offset) #define nvt_readl(offset) readl(offset) #define nvt_writeb(val, offset) writeb(val, offset) #define nvt_writew(val, offset) writew(val, offset) #define nvt_writel(val, offset) writel(val, offset) #define NVT_FDT_MEM_SIZE (SZ_1K * 10) #define FDT_SIZE SZ_128K #ifdef CONFIG_NVT_IVOT_NVT_DBG #define NVT_DBG_FATAL 0 #define NVT_DBG_ERR 1 #define NVT_DBG_WRN 2 #define NVT_DBG_UNIT 3 #define NVT_DBG_FUNC 4 #define NVT_DBG_IND 5 #define NVT_DBG_MSG 6 #define NVT_DBG_VALUE 7 #define NVT_DBG_USER 8 #define nvt_dbg(level, fmt, args...) \ do { \ if (unlikely(NVT_DBG_##level <= CONFIG_NVT_IVOT_DEBUG_LEVEL)) { \ if (NVT_DBG_##level < NVT_DBG_WRN) \ printf("%s %s: %s" fmt, ANSI_COLOR_RED, __func__, ANSI_COLOR_RESET, ##args); \ else if (NVT_DBG_##level < NVT_DBG_IND) \ printf("%s %s: %s" fmt, ANSI_COLOR_YELLOW, __func__, ANSI_COLOR_RESET, ##args); \ else \ printf("%s: " fmt, __func__, ##args); \ } \ } while (0) #else #define nvt_dbg(level, fmt, args...) \ do { \ } while (0) #endif typedef enum { NVT_BIN_NAME_TYPE_FW = 1, NVT_BIN_NAME_TYPE_RUNFW, NVT_BIN_NAME_TYPE_RECOVERY_FW, NVT_BIN_NAME_TYPE_MODELEXT, } NVT_BIN_NAME_TYPE; typedef struct _FASTBOOTPSTORE { UINT32 uiDataSize; ///