b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #ifndef __ASR_COMMON_H__ |
| 2 | #define __ASR_COMMON_H__ |
| 3 | |
| 4 | #include "asr_flag.h" |
| 5 | |
| 6 | #include "asr_flash.h" |
| 7 | #include "mv_cp.h" |
| 8 | #include "tim.h" |
| 9 | |
| 10 | struct cp_img_flash_layout |
| 11 | { |
| 12 | u32 arbel_offset; |
| 13 | u32 msa_offset; |
| 14 | u32 rf_offset; |
| 15 | u32 bx2_offset; |
| 16 | u32 cp_rd_offset; |
| 17 | u32 cp_rd_bk_offset; |
| 18 | u32 ap_rd_offset; |
| 19 | u32 ap_rd_bk_offset; |
| 20 | u32 nvm_tbl_size; |
| 21 | struct nvm_load_info *nvm_tbl; |
| 22 | }; |
| 23 | |
| 24 | struct ap_img_info |
| 25 | { |
| 26 | u32 image_id; |
| 27 | u32 load_addr; |
| 28 | u32 flash_offset; |
| 29 | u32 image_size; |
| 30 | }; |
| 31 | |
| 32 | enum nsaid_perm { |
| 33 | DDR_PERM_RW, |
| 34 | DDR_PERM_RD, |
| 35 | DDR_PERM_WR, |
| 36 | DDR_PERM_ABORT, |
| 37 | }; |
| 38 | |
| 39 | union nsaid_perm_desc { |
| 40 | struct { |
| 41 | u32 range0_perm:2; |
| 42 | u32 range1_perm:2; |
| 43 | u32 range2_perm:2; |
| 44 | u32 range3_perm:2; |
| 45 | u32 range4_perm:2; |
| 46 | u32 range5_perm:2; |
| 47 | u32 range6_perm:2; |
| 48 | u32 range7_perm:2; |
| 49 | u32 range8_perm:2; |
| 50 | u32 range9_perm:2; |
| 51 | u32 rangea_perm:2; |
| 52 | u32 rangeb_perm:2; |
| 53 | u32 rangec_perm:2; |
| 54 | u32 ranged_perm:2; |
| 55 | u32 rangee_perm:2; |
| 56 | u32 rangef_perm:2; |
| 57 | } b; |
| 58 | |
| 59 | u32 value; |
| 60 | }; |
| 61 | |
| 62 | struct nsaid_range_desc { |
| 63 | u32 buff_start; |
| 64 | u32 buff_end; |
| 65 | union nsaid_perm_desc perm_desc; |
| 66 | }; |
| 67 | |
| 68 | /* resever a 128 bytes(0x300 to 0x380) structure to save asr memory flags */ |
| 69 | struct asr_mflag { |
| 70 | u32 reserved1[0x28 / sizeof(u32)]; |
| 71 | |
| 72 | u32 diag_buff_magic; |
| 73 | u32 diag_buff_addr; |
| 74 | u32 diag_buff_len; |
| 75 | |
| 76 | u32 fastboot_flag; /* fast boot mode flag, offset 0x34 */ |
| 77 | u32 ubifs_error_magic; /* ubifs error magic offset 0x38 */ |
| 78 | u32 ubifs_error_type; /* ubifs error magic offset 0x3c */ |
| 79 | u32 reserved2[0x40 / sizeof(u32)]; |
| 80 | } __attribute__ ((__packed__)); |
| 81 | |
| 82 | #define ASR_MFLAG_OFFSET_FROM_CRASHKERNEL (0x300) |
| 83 | |
| 84 | #define AP_DIAG_BUF_SET_MAGIC (0x41504447) /* APDG */ |
| 85 | #define AP_DIAG_BUF_SET_MAGIC2 (0x41504467) /* APDg */ |
| 86 | |
| 87 | #define CONFIG_MAX_DIAG_BUFF_LEN (12 * 1024 * 1024) |
| 88 | |
| 89 | #define CONFIG_DIAG_BUF_START_ADDR (36 * 1024* 1024) /* none tos mode diag buff start address */ |
| 90 | |
| 91 | |
| 92 | #define DDR_RANGE_ACCESS_CTRL (0xc000007c) |
| 93 | #define DDR_RANGE0_LOW_CFG (0xc0000080) |
| 94 | #define DDR_RANGE0_HIGH_CFG (0xc0000084) |
| 95 | |
| 96 | #define DDR_ADC_ERR_INFO (0xc0000150) |
| 97 | |
| 98 | #define DDR_RANGE0_TOP_LOW_CFG (0xc0000A40) |
| 99 | #define DDR_RANGE0_TOP_HIGH_CFG (0xc0000A44) |
| 100 | |
| 101 | #define DDR_RANGE0_MASK_CFG (0xc0000A00) |
| 102 | |
| 103 | #define NSAID_ALL_READ_ONLY (0x55555555) |
| 104 | #define NSAID_ALL_READ_WRITE (0x00000000) |
| 105 | #define NSAID_ALL_WRITE_ONLY (0xAAAAAAAA) |
| 106 | #define NSAID_ALL_ABORT (0xFFFFFFFF) |
| 107 | |
| 108 | #define NR_NSAID_RANGES (16) |
| 109 | |
| 110 | |
| 111 | #define BOOT_LOG_MAGIC 0x42474f4c /* "LOGB" */ |
| 112 | |
| 113 | #define BOARD_ID_MAGIC 0x44494442 /* "BDID" */ |
| 114 | |
| 115 | enum BOARD_ID { |
| 116 | ASR1901_P5N = 5, |
| 117 | }; |
| 118 | |
| 119 | pTIM asr_get_dtim_primary(void); |
| 120 | int asr_load_verify_ap_images(struct ap_img_info * ap_imgs, int num); |
| 121 | int set_nocp_mode(int nocpmode); |
| 122 | int asr_load_verify_cp_images(u32 cpbt_mode, struct cp_img_flash_layout *lwg_layout); |
| 123 | |
| 124 | int asr_get_sim_lock_fuse(void); |
| 125 | |
| 126 | void nsaid_config_one_range(struct nsaid_range_desc *desc); |
| 127 | void nsaid_basic_init(void); |
| 128 | extern u32 extern_get_prod_mode(void); |
| 129 | extern int extern_get_cpmem(void); |
| 130 | extern int do_uboot_mem_test(u32 ddr_end_addr, u32 sec_ddr_start, u32 sec_ddr_end); |
| 131 | extern struct asr_mflag * get_asr_mflag(void); |
| 132 | extern u32 get_mem_size_bytes(void); |
| 133 | extern int prepare_ap_diag_buff(u32 buff_st, u32 buf_end); |
| 134 | |
| 135 | |
| 136 | #ifdef CONFIG_PXA182X |
| 137 | #include <asm/arch/pxa182x.h> |
| 138 | #endif |
| 139 | |
| 140 | #ifdef CONFIG_ASR1802S |
| 141 | #include <asm/arch/asr1802.h> |
| 142 | #endif |
| 143 | |
| 144 | #endif |