17 #ifndef _WLAND_FLASH_H_ 18 #define _WLAND_FLASH_H_ 19 #include "wland_types.h" 20 #include "rda5981_flash.h" 21 #include "rda_ccfg_api.h" 26 #define min(a, b) ((a)<(b)?(a):(b)) 62 #define RDA5991H_USER_DATA_FLAG_UNINITIALIZED (0xFFFFFFFF & \ 63 (~(RDA5991H_USER_DATA_FLAG_MAC | \ 64 RDA5991H_USER_DATA_FLAG_STA | \ 65 RDA5991H_USER_DATA_FLAG_PMK | \ 66 RDA5991H_USER_DATA_FLAG_IP | \ 67 RDA5991H_USER_DATA_FLAG_PARTER_DATA_LEN | \ 68 RDA5991H_USER_DATA_FLAG_TX_POWER | \ 69 RDA5991H_USER_DATA_FLAG_XTAL_CAL | \ 70 RDA5991H_USER_DATA_FLAG_TX_POWER_RF | \ 71 RDA5991H_USER_DATA_FLAG_TX_POWER_PHY_GN | \ 72 RDA5991H_USER_DATA_FLAG_TX_POWER_PHY_B | \ 73 RDA5991H_USER_DATA_FLAG_AP | \ 74 RDA5991H_USER_DATA_FLAG_APNET | \ 75 RDA5991H_USER_DATA_FLAG_DHCP | \ 76 RDA5991H_USER_DATA_FLAG_UART | \ 77 RDA5991H_USER_DATA_FLAG_RF | \ 78 RDA5991H_USER_DATA_FLAG_RF_CHANNELS | \ 79 RDA5991H_USER_DATA_FLAG_PHY | \ 80 RDA5991H_USER_DATA_FLAG_PHY_CHANNELS | \ 81 RDA5991H_USER_DATA_FLAG_TX_POWER_OFFSET))) 83 #define RDA5991H_USER_DATA_IP_LENGTH 8 85 #define RDA5981_FLAG_FLAG "RDA5981" 96 u8 ip[RDA5991H_USER_DATA_IP_LENGTH];
115 #define SECTOR_SIZE 4096 116 #define FLASH_SIZE 0x100000 118 #define RDA5991H_PARTITION_TABLE_END_ADDR 0x18001000 //partition table end addr 120 #define RDA5991H_USER_DATA_ADDR 0x180fb000 //4k(partition table)+500k+500k: 121 #define RDA5991H_3RDPARTER_DATA_ADDR 0x180fc000 122 #define RDA5991H_3RDPARTER_DATA_LEN 0x1000 124 #define FLASH_CTL_REG_BASE 0x17fff000 125 #define FLASH_CTL_TX_CMD_ADDR_REG (FLASH_CTL_REG_BASE + 0x00) 126 #define CMD_64KB_BLOCK_ERASE (0x000000d8UL) 127 #define WRITE_REG32(REG, VAL) ((*(volatile unsigned int*)(REG)) = (unsigned int)(VAL)) 129 #define FLASH_ERASE_FUN_ADDR 0x21f1//smartlink_erase_for_mbed 130 #define FLASH_WRITE_FUN_ADDR 0x2241//smartlink_write_for_mbed 131 #define FLASH_READ_FUN_ADDR 0x2243//smartlink_read_for_mbed 132 #define FLASH_ERASE_PARTITION_FUN_ADDR 0x2139//spi_flash_erase_partition 133 #define SPI_FLASH_READ_DATA_FOR_MBED_ADDR 0x2007//spi_flash_read_data_for_mbed 134 #define spi_flash_disable_cache_addr 0x1eb7//spi_flash_disable_cache 135 #define spi_flash_flush_cache_addr 0x1ecd//spi_flash_flush_cache 136 #define spi_flash_cfg_cache_addr 0x1e9f//spi_flash_cfg_cache 137 #define spi_flash_erase_4KB_sector_addr 0x23a3 138 #define spi_wip_reset_addr 0x1d8b 139 #define spi_write_reset_addr 0x1d9f 140 #define wait_busy_down_addr 0x1d81 142 #define FLASH_ERASE_FUN_ADDR_4 0x2221//smartlink_erase_for_mbed 143 #define FLASH_WRITE_FUN_ADDR_4 0x2271//smartlink_write_for_mbed 144 #define FLASH_READ_FUN_ADDR_4 0x2273//smartlink_read_for_mbed 145 #define FLASH_ERASE_PARTITION_FUN_ADDR_4 0x2169//spi_flash_erase_partition 146 #define SPI_FLASH_READ_DATA_FOR_MBED_ADDR_4 0x2037//spi_flash_read_data_for_mbed 147 #define spi_flash_disable_cache_addr_4 0x1ee7//spi_flash_disable_cache 148 #define spi_flash_flush_cache_addr_4 0x1efd//spi_flash_flush_cache 149 #define spi_flash_cfg_cache_addr_4 0x1ecf//spi_flash_cfg_cache 150 #define spi_flash_erase_4KB_sector_addr_4 0x23d3 151 #define spi_wip_reset_addr_4 0x1dbb 152 #define spi_write_reset_addr_4 0x1dcf 153 #define wait_busy_down_addr_4 0x1db1 158 int rda5981_flash_read_pmk(u8 *pmk);
159 int rda5981_flash_read_sta_data(
char *ssid,
char *passwd);
160 void rda5981_spi_erase_partition(
void *src, u32 counts);
166 #define VERSION_SZ 24 170 u8 version[VERSION_SZ];
179 #define RDA5981_FIRMWARE_MAGIC 0xEAEA 181 static inline void wait_busy_down_2(
void)
183 ((void(*)(void))wait_busy_down_addr)();
186 static inline void spi_write_reset_2(
void)
188 ((void(*)(void))spi_write_reset_addr)();
191 static inline void spi_wip_reset_2(
void)
193 ((void(*)(void))spi_wip_reset_addr)();
196 static inline void wait_busy_down_4(
void)
198 ((void(*)(void))wait_busy_down_addr_4)();
201 static inline void spi_write_reset_4(
void)
203 ((void(*)(void))spi_write_reset_addr_4)();
206 static inline void spi_wip_reset_4(
void)
208 ((void(*)(void))spi_wip_reset_addr_4)();
211 static void wait_busy_down(
void)
213 if (rda_ccfg_hwver() >= 4) {
220 static void spi_write_reset(
void)
222 if (rda_ccfg_hwver() >= 4) {
229 static void spi_wip_reset(
void)
231 if (rda_ccfg_hwver() >= 4) {
238 static inline void spi_flash_enable_cache(
void)
240 unsigned int func = spi_flash_cfg_cache_addr;
241 if (rda_ccfg_hwver() >= 4) {
242 func = spi_flash_cfg_cache_addr_4;
244 ((void(*)(void))func)();
247 static inline void spi_flash_disable_cache(
void)
249 unsigned int func = spi_flash_disable_cache_addr;
250 if (rda_ccfg_hwver() >= 4) {
251 func = spi_flash_disable_cache_addr_4;
253 ((void(*)(void))func)();
256 static inline void spi_flash_flush_cache(
void)
258 unsigned int func = spi_flash_flush_cache_addr;
259 if (rda_ccfg_hwver() >= 4) {
260 func = spi_flash_flush_cache_addr_4;
262 ((void(*)(void))func)();
265 static inline void rda5981_spi_flash_erase_4KB_sector(u32 addr)
267 unsigned int func = spi_flash_erase_4KB_sector_addr;
268 if (rda_ccfg_hwver() >= 4) {
269 func = spi_flash_erase_4KB_sector_addr_4;
271 ((void(*)(u32))func)(addr);
274 static inline void RDA5991H_ERASE_FLASH(
void *addr, u32 len)
276 unsigned int func = FLASH_ERASE_FUN_ADDR;
277 if (rda_ccfg_hwver() >= 4) {
278 func = FLASH_ERASE_FUN_ADDR_4;
280 ((void(*)(
void *, u32))func)(addr, len);
283 static inline void RDA5991H_WRITE_FLASH(u32 addr, u8 *data, u32 len)
285 unsigned int func = FLASH_WRITE_FUN_ADDR;
286 if (rda_ccfg_hwver() >= 4) {
287 func = FLASH_WRITE_FUN_ADDR_4;
289 ((void(*)(u32, u8 *, u32))func)(addr, data, len);
292 static inline void RDA5991H_READ_FLASH(u32 addr, u8 *buf, u32 len)
294 unsigned int func = FLASH_READ_FUN_ADDR;
295 if (rda_ccfg_hwver() >= 4) {
296 func = FLASH_READ_FUN_ADDR_4;
298 ((void(*)(u32, u8 *, u32))func)(addr, buf, len);
301 static inline void SPI_FLASH_READ_DATA_FOR_MBED(
void *addr,
void *buf, u32 len)
303 unsigned int func = SPI_FLASH_READ_DATA_FOR_MBED_ADDR;
304 if (rda_ccfg_hwver() >= 4) {
305 func = SPI_FLASH_READ_DATA_FOR_MBED_ADDR_4;
307 ((void(*)(
void *,
void *, u32))func)(buf, addr, len);
This struct contains ap data, include ssid key and channel.
This struct contains all smartconfig mbed flash parameter.
This struct contains tx power parameter.
This struct contains ap net data.