1 /* 2 * Routines to access hardware 3 * 4 * Copyright (c) 2013 Realtek Semiconductor Corp. 5 * 6 * This module is a confidential and proprietary property of RealTek and 7 * possession or use of this module requires written permission of RealTek. 8 */ 9 #ifndef _HAL_8721D_H_ 10 #define _HAL_8721D_H_ 11 12 #include "platform_autoconf.h" 13 #include "basic_types.h" 14 #include "section_config.h" 15 #include "memproc.h" 16 #include "rtl8721d_sys_on.h" 17 #include "rtl8721d_peri_on.h" 18 #include "hal_platform.h" 19 #include "rtl8721d_vector.h" 20 #include "rtl8721d_loguart.h" 21 #include "rtl8721d_soc_ps.h" 22 #include "diag.h" 23 #include "shell.h" 24 #include "rand.h" 25 #include "monitor_rom.h" 26 #include "rtl8721d_syscfg.h" 27 #include "rtl8721d_pmc.h" 28 #include "rtl8721d_clk.h" 29 #include "rtl8721d_bor.h" 30 #include "rtl8721d_crypto.h" 31 #include "rtl8721d_crypto_api.h" 32 #include "rtl8721d_boot.h" 33 #include "rtl8721d_wl_on.h" 34 #include "rtl8721d_otf.h" 35 #include "rtl8721d_flash.h" 36 #include "rtl8721d_backup_reg.h" 37 #include "rtl8721d_pinmap.h" 38 #include "rtl8721d_ipc.h" 39 #include "rtl8721dhp_sysreg.h" 40 #include "rtl8721dlp_sysreg.h" 41 #include "rtl8721d_pinmux.h" 42 #ifndef CONFIG_BUILD_ROM 43 #include "rtl8721d_ipc_api.h" 44 #endif 45 #include "xmodem_update_rom.h" 46 47 48 #if defined (ARM_CORE_CM4) 49 #include "rtl8721dhp_rcc.h" 50 #else 51 #include "rtl8721dlp_rcc.h" 52 #endif 53 54 /* =========================== Configuration of the ARM ARMV8MBL Processor and Core Peripherals ============================ */ 55 56 #if defined (ARM_CORE_CM4) 57 #ifdef AMEBAD_TODO 58 #define __ARMV8MML_REV 0x0000U /*!< ARMV8MML Core Revision */ 59 #define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ 60 #define __VTOR_PRESENT 1 /*!< Set to 1 if CPU supports Vector Table Offset Register */ 61 #define __FPU_DP 0 /*!< Double Precision FPU */ 62 #endif 63 #define __CM3_REV 0x0200 /**< Core revision r0p0 */ 64 #define __MPU_PRESENT 1 /**< Defines if an MPU is present or not */ 65 #define __NVIC_PRIO_BITS 3 /**< Number of priority bits implemented in the NVIC */ 66 #define __Vendor_SysTickConfig 0 /**< Vendor specific implementation of SysTickConfig is defined *///see vPortSetupTimerInterrupt 67 #define __SAUREGION_PRESENT 1 /*!< SAU present or not */ 68 69 #define __FPU_PRESENT 1 /*!< FPU present */ 70 #define __VFP_FP__ 1 71 #ifndef __ARM_FEATURE_CMSE 72 #define __ARM_FEATURE_CMSE 3 73 #endif 74 #include <arm_cmse.h> /* Use CMSE intrinsics */ 75 #include "core_armv8mml.h" 76 #include "core_cache.h" 77 #elif defined (ARM_CORE_CM0) 78 #define __ARMV8MBL_REV 0x0000U /*!< ARMV8MBL Core Revision */ 79 #define __NVIC_PRIO_BITS 2 /*!< Number of Bits used for Priority Levels */ 80 #define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ 81 #define __VTOR_PRESENT 1 /*!< Set to 1 if CPU supports Vector Table Offset Register */ 82 #define __SAU_REGION_PRESENT 0 /*!< SAU present or not */ 83 84 #define __MPU_PRESENT 1 /**< Defines if an MPU is present or not */ 85 #include "core_armv8mbl.h" 86 #include "core_cache.h" 87 #endif 88 #include "rtl8721d_trustzone.h" 89 #include "mpu_config.h" 90 91 #include "rtl8721d_gdma.h" 92 #include "rtl8721d_tim.h" 93 #include "rtl8721d_gpio.h" 94 #include "rtl8721d_ssi.h" 95 #include "rtl8721d_uart.h" 96 #include "rtl8721d_i2c.h" 97 #include "rtl8721d_i2s.h" 98 #include "rtl8721d_adc.h" 99 #include "rtl8721d_comparator.h" 100 #include "rtl8721d_sdio.h" 101 #include "rtl8721d_wdg.h" 102 #include "rtl8721d_rtc.h" 103 #include "rtl8721d_delay.h" 104 #include "rtl8721d_ir.h" 105 #include "rtl8721d_keyscan.h" 106 #include "rtl8721d_sgpio.h" 107 #include "rtl8721d_qdec.h" 108 #include "rtl8721d_usi.h" 109 #include "rtl8721d_usi_uart.h" 110 #include "rtl8721d_usi_ssi.h" 111 #include "rtl8721d_usi_i2c.h" 112 #include "rtl8721d_crc.h" 113 #include "rtl8721d_lcdc.h" 114 #include "rtl8721d_audio.h" 115 #include "rtl8721d_efuse.h" 116 #include "rtl8721d_cache.h" 117 #include "rtl8721d_psram.h" 118 #include "rtl8721d_sdioh.h" 119 #include "rtl8721dhp_sd.h" 120 121 // firmware information, located at the header of Image2 122 #define FW_VERSION (0x0100) 123 #define FW_SUBVERSION (0x0001) 124 #define FW_CHIP_ID (0x8195) 125 #define FW_CHIP_VER (0x01) 126 #define FW_BUS_TYPE (0x01) // the iNIC firmware type: USB/SDIO 127 #define FW_INFO_RSV1 (0x00) // the firmware information reserved 128 #define FW_INFO_RSV2 (0x00) // the firmware information reserved 129 #define FW_INFO_RSV3 (0x00) // the firmware information reserved 130 #define FW_INFO_RSV4 (0x00) // the firmware information reserved 131 132 #define FLASH_HS_BOOT_ADDR (SPI_FLASH_BASE + 0x4000) 133 #define FLASH_RESERVED_DATA_BASE 0x2000 // reserve 8K for Image1 134 #define FLASH_SYSTEM_DATA_ADDR 0x3000 // reserve 8K+4K for Image1 + Reserved data 135 #define FLASH_OTA1_CODE_ADDR 0x6020 136 #define FLASH_SECTOR_SIZE 0x1000 137 //BT calibration Data 138 #define FLASH_BT_PARA_ADDR 0x5FF0 139 140 /* Spic_Mode */ 141 #define ReadQuadIOMode 0 142 #define ReadQuadOMode 1 143 #define ReadDualIOMode 2 144 #define ReadDualOMode 3 145 #define ReadOneMode 4 146 147 #define IMAGE_HEADER_LEN 0x20 148 typedef struct { 149 u32 signature[2]; 150 u32 image_size; 151 u32 image_addr; 152 153 /* reserved for extention */ 154 u32 sb_header; 155 u32 reserved[3]; 156 } IMAGE_HEADER; 157 158 typedef struct { 159 /* 0x00 */ 160 u32 Rsvd00; 161 u32 Valid_Image2; 162 u32 Rsvd01[2]; 163 164 /* 0x10 */ 165 u32 Rsvd10[4]; 166 167 /* 0x20 */ 168 u32 Rsvd20[2]; 169 u32 BT_FW_DBG; 170 u32 FTL_GC_Status; 171 172 } SYSTEM_DATA; 173 174 175 typedef struct { 176 u32 reserved[12]; 177 178 unsigned char sb_sig[64]; 179 } SB_HEADER; 180 181 typedef enum _HAL_Status 182 { 183 HAL_OK = 0x00, 184 HAL_BUSY = 0x01, 185 HAL_TIMEOUT = 0x02, 186 HAL_ERR_PARA = 0x03, // error with invaild parameters 187 HAL_ERR_MEM = 0x04, // error with memory allocation failed 188 HAL_ERR_HW = 0x05, // error with hardware error 189 190 HAL_ERR_UNKNOWN = 0xee // unknown error 191 192 } HAL_Status; 193 194 195 #define USE_FULL_ASSERT 196 197 #ifdef USE_FULL_ASSERT 198 /** 199 * @brief The assert_param macro is used for function's parameters check. 200 * @param expr: If expr is false, it calls assert_failed function which reports 201 * the name of the source file and the source line number of the call 202 * that failed. If expr is true, it returns no value. 203 * @retval None 204 */ 205 #define assert_param(expr) ((expr) ? (void)0 : io_assert_failed((uint8_t *)__FUNCTION__, __LINE__)) 206 /* Exported functions ------------------------------------------------------- */ 207 void io_assert_failed(uint8_t* file, uint32_t line); 208 #else 209 #define assert_param(expr) ((void)0) 210 #endif /* USE_FULL_ASSERT */ 211 212 #endif //_HAL_8721D_H_ 213