[fix][flash] fix flash init, move bflb_ef_ctrl_get_device_info before flash config

This commit is contained in:
jzlv 2022-11-29 15:45:19 +08:00
parent f83c0655cc
commit fe3c57a68d
2 changed files with 9 additions and 5 deletions

View file

@ -11,6 +11,8 @@ static uint32_t g_jedec_id2 = 0;
static SPI_Flash_Cfg_Type g_flash_cfg;
static SPI_Flash_Cfg_Type g_flash2_cfg;
static bflb_efuse_device_info_type deviceInfo;
uint32_t bflb_flash2_get_jedec_id(void)
{
uint32_t jid = 0;
@ -112,7 +114,7 @@ static int ATTR_TCM_SECTION flash2_init(void)
int stat = -1;
uint32_t ret = 0;
uint32_t jid = 0;
bflb_efuse_device_info_type deviceInfo;
SF_Ctrl_Bank2_Cfg sfBank2Cfg = {
.sbus2Select = ENABLE,
.bank2RxClkInvertSrc = DISABLE,
@ -133,7 +135,6 @@ static int ATTR_TCM_SECTION flash2_init(void)
.cmdsWrapLen = SF_CTRL_WRAP_LEN_4096,
};
bflb_ef_ctrl_get_device_info(&deviceInfo);
if (deviceInfo.memoryInfo == 0) {
/* memoryInfo==0, external flash */
flash1_size = 64 * 1024 * 1024;
@ -189,6 +190,8 @@ int ATTR_TCM_SECTION bflb_flash_init(void)
uint32_t jedec_id = 0;
uintptr_t flag;
bflb_ef_ctrl_get_device_info(&deviceInfo);
jedec_id = GLB_Get_Flash_Id_Value();
if (jedec_id != 0) {
ret = SF_Cfg_Get_Flash_Cfg_Need_Lock_Ext(jedec_id, &g_flash_cfg);

View file

@ -9,6 +9,8 @@
static uint32_t g_jedec_id = 0;
static SPI_Flash_Cfg_Type g_flash_cfg;
static bflb_efuse_device_info_type devInfo;
static void ATTR_TCM_SECTION flash_set_qspi_enable(SPI_Flash_Cfg_Type *p_flash_cfg)
{
if ((p_flash_cfg->ioMode & 0x0f) == SF_CTRL_QO_MODE || (p_flash_cfg->ioMode & 0x0f) == SF_CTRL_QIO_MODE) {
@ -31,9 +33,6 @@ static void ATTR_TCM_SECTION flash_set_l1c_wrap(SPI_Flash_Cfg_Type *p_flash_cfg)
static void ATTR_TCM_SECTION flash_sf2_gpio_init(void)
{
uint32_t tmpVal;
bflb_efuse_device_info_type devInfo;
bflb_ef_ctrl_get_device_info(&devInfo);
/* flash_cfg != BFLB_FLASH_CFG_SF1_EXT_17_22, flash pad use SF2 */
if (devInfo.flash_cfg != BFLB_FLASH_CFG_SF1_EXT_17_22) {
@ -93,6 +92,8 @@ int ATTR_TCM_SECTION bflb_flash_init(void)
uint32_t jedec_id = 0;
uintptr_t flag;
bflb_ef_ctrl_get_device_info(&devInfo);
flag = bflb_irq_save();
L1C_Cache_Flush();
SF_Cfg_Get_Flash_Cfg_Need_Lock_Ext(0, &g_flash_cfg);