From 93b6d5554ddd92f8ed9d9a2df8436a9ab3a0d819 Mon Sep 17 00:00:00 2001 From: rogeryou Date: Wed, 3 Feb 2021 16:55:18 +0800 Subject: [PATCH] add MX25LW51245G_config.h --- .../include/OSPIF/MX25LM51245G_config.h | 24 ----------- .../include/OSPIF/OSPIFBlockDevice.h | 10 ++++- .../source/OSPIFBlockDevice.cpp | 40 +++++++++---------- 3 files changed, 28 insertions(+), 46 deletions(-) diff --git a/storage/blockdevice/COMPONENT_OSPIF/include/OSPIF/MX25LM51245G_config.h b/storage/blockdevice/COMPONENT_OSPIF/include/OSPIF/MX25LM51245G_config.h index e74c34be22..d9a8913059 100644 --- a/storage/blockdevice/COMPONENT_OSPIF/include/OSPIF/MX25LM51245G_config.h +++ b/storage/blockdevice/COMPONENT_OSPIF/include/OSPIF/MX25LM51245G_config.h @@ -17,7 +17,6 @@ #ifndef MBED_OSPI_FLASH_MX25LM51245G_H #define MBED_OSPI_FLASH_MX25LM51245G_H - #define OSPI_FLASH_CHIP_STRING "macronix MX25LM51245G" // This is a workaround, @@ -26,33 +25,10 @@ // The code below can be removed when users test with the new flash. #define NEED_DEFINE_SFDP_PARA -#ifdef NEED_DEFINE_SFDP_PARA -uint8_t _sfdp_head_table[32] = {0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x02, 0xFF, 0x00, 0x06, 0x01, - 0x10, 0x30, 0x00, 0x00, 0xFF, 0xC2, 0x00, 0x01, 0x04, 0x10, 0x01, - 0x00, 0xFF, 0x84, 0x00, 0x01, 0x02, 0xC0, 0x00, 0x00, 0xFF - }; -uint8_t _sfdp_basic_param_table[64] = {0x30, 0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x14, 0xEC, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0x20, - 0x10, 0xDC, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x50, 0xF9, 0x80 - }; -uint8_t _sfdp_4_byte_inst_table[8] = {0x7F, 0xEF, 0xFF, 0xFF, 0x21, 0x5C, 0xDC, 0x14}; -#endif - -//#define MX_FLASH_SUPPORT_RWW 1 - #define MX25LM51245G_FLASH_SIZE 0x4000000 /* 512 MBits => 64 MBytes */ #define MX25LM51245G_BLOCK_SIZE 0x10000 /* 1024 blocks of 64 KBytes */ #define MX25LM51245G_SECTOR_SIZE 0x1000 /* 16384 sectors of 4 kBytes */ #define MX25LM51245G_PAGE_SIZE 0x100 /* 262144 pages of 256 bytes */ #define MX25LM51245G_CHUNK_SIZE 0x10 /* fred: 16 bytes */ -#ifdef MX_FLASH_SUPPORT_RWW -#define MX25LM51245G_BANK_SIZE 0x01000000 /* fred: 16 MBytes */ -#define MX25LM51245G_BANK_SIZE_MASK ~(MX25LM51245G_BANK_SIZE - 1) /* fred: 0xFF000000 */ -#endif - #endif // MBED_OSPI_FLASH_MX25LM51245G_H diff --git a/storage/blockdevice/COMPONENT_OSPIF/include/OSPIF/OSPIFBlockDevice.h b/storage/blockdevice/COMPONENT_OSPIF/include/OSPIF/OSPIFBlockDevice.h index 7881c3f939..da769de4b2 100644 --- a/storage/blockdevice/COMPONENT_OSPIF/include/OSPIF/OSPIFBlockDevice.h +++ b/storage/blockdevice/COMPONENT_OSPIF/include/OSPIF/OSPIFBlockDevice.h @@ -22,6 +22,14 @@ #include "blockdevice/BlockDevice.h" #include "platform/Callback.h" +#if defined(TARGET_MX25LM51245G) +#include "MX25LM51245G_config.h" +#endif + +#if defined(TARGET_MX25LW51245G) +#include "MX25LW51245G_config.h" +#endif + #ifndef MBED_CONF_OSPIF_OSPI_IO0 #define MBED_CONF_OSPIF_OSPI_IO0 NC #endif @@ -62,8 +70,6 @@ #define MBED_CONF_OSPIF_OSPI_FREQ 40000000 #endif -#define MX_FLASH_SUPPORT_RWW - /** Enum ospif standard error codes * * @enum ospif_bd_error diff --git a/storage/blockdevice/COMPONENT_OSPIF/source/OSPIFBlockDevice.cpp b/storage/blockdevice/COMPONENT_OSPIF/source/OSPIFBlockDevice.cpp index 271f915ff9..3c4506f7a3 100644 --- a/storage/blockdevice/COMPONENT_OSPIF/source/OSPIFBlockDevice.cpp +++ b/storage/blockdevice/COMPONENT_OSPIF/source/OSPIFBlockDevice.cpp @@ -20,9 +20,6 @@ #include "OSPIFBlockDevice.h" #include #include "rtos/ThisThread.h" -#if defined(TARGET_MX25LM51245G) -#include "MX25LM51245G_config.h" -#endif #ifndef MBED_CONF_MBED_TRACE_ENABLE #define MBED_CONF_MBED_TRACE_ENABLE 0 @@ -51,18 +48,6 @@ using namespace mbed; #define OSPIF_STATUS_BIT_WEL 0x2 // Write Enable Latch #define OSPIF_NO_QUAD_ENABLE (-1) -// Configuration Register2 address -#define OSPIF_CR2_OPI_EN_ADDR 0x00000000 -#define OSPIF_CR2_BANK_STATUS_ADDR 0xc0000000 -#define OSPIF_CR2_RWWDI ((uint8_t)0x00) /*!< No active program or erase operation */ -#define OSPIF_CR2_RWWDS ((uint8_t)0x01) /*!< Program/erase in other bank */ -#define OSPIF_CR2_RWWBS ((uint8_t)0x03) /*!< program/erase operation in addressed bank */ - -#ifdef MX_FLASH_SUPPORT_RWW -#define MX25LM51245G_BANK_SIZE 0x01000000 /* 16 MBytes */ -#define MX25LM51245G_BANK_SIZE_MASK ~(MX25LM51245G_BANK_SIZE - 1) /* 0xFF000000 */ -#endif - /* SFDP Header Parsing */ /***********************/ #define OSPIF_RSFDP_DUMMY_CYCLES 8 @@ -177,6 +162,21 @@ using namespace mbed; // Length of data returned from RDID instruction #define OSPI_RDID_DATA_LENGTH 3 +#ifdef NEED_DEFINE_SFDP_PARA +uint8_t _sfdp_head_table[32] = {0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x02, 0xFF, 0x00, 0x06, 0x01, + 0x10, 0x30, 0x00, 0x00, 0xFF, 0xC2, 0x00, 0x01, 0x04, 0x10, 0x01, + 0x00, 0xFF, 0x84, 0x00, 0x01, 0x02, 0xC0, 0x00, 0x00, 0xFF + }; +uint8_t _sfdp_basic_param_table[64] = {0x30, 0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x14, 0xEC, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0x20, + 0x10, 0xDC, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x50, 0xF9, 0x80 + }; +uint8_t _sfdp_4_byte_inst_table[8] = {0x7F, 0xEF, 0xFF, 0xFF, 0x21, 0x5C, 0xDC, 0x14}; +#endif /* Init function to initialize Different Devices CS static list */ static PinName *generate_initialized_active_ospif_csel_arr(); @@ -407,7 +407,7 @@ int OSPIFBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size) #ifdef MX_FLASH_SUPPORT_RWW bool need_wait; - need_wait = (_wait_flag != NOT_STARTED) && ((addr & MX25LM51245G_BANK_SIZE_MASK) == _busy_bank); + need_wait = (_wait_flag != NOT_STARTED) && ((addr & MX25LW51245G_BANK_SIZE_MASK) == _busy_bank); // Wait for ready if (need_wait) { @@ -499,7 +499,7 @@ int OSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size #ifdef MX_FLASH_SUPPORT_RWW _wait_flag = WRITE_WAIT_STARTED; - _busy_bank = addr & MX25LM51245G_BANK_SIZE_MASK; + _busy_bank = addr & MX25LW51245G_BANK_SIZE_MASK; _mutex.unlock(); @@ -512,7 +512,7 @@ int OSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size goto exit_point; } _mutex.unlock(); -#endif +#endif buffer = static_cast(buffer) + chunk; addr += chunk; size -= chunk; @@ -606,7 +606,7 @@ int OSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t size) #ifdef MX_FLASH_SUPPORT_RWW _wait_flag = ERASE_WAIT_STARTED; - _busy_bank = addr & MX25LM51245G_BANK_SIZE_MASK; + _busy_bank = addr & MX25LW51245G_BANK_SIZE_MASK; _mutex.unlock(); @@ -1631,7 +1631,7 @@ bool OSPIFBlockDevice::_is_mem_ready_rww(bd_addr_t addr, uint8_t rw) static uint32_t rww_cnt = 0; // For testing static uint32_t rwe_cnt = 0; // For testing - bd_addr_t bank_addr = addr & MX25LM51245G_BANK_SIZE_MASK; + bd_addr_t bank_addr = addr & MX25LW51245G_BANK_SIZE_MASK; if ((_wait_flag == NOT_STARTED) || (!rw && bank_addr != _busy_bank)) { return mem_ready;