From 05d294b9461aaf4e3bc796c4db5cb5563ce1e25f Mon Sep 17 00:00:00 2001 From: surenyi Date: Wed, 23 Oct 2024 18:05:04 +0800 Subject: [PATCH] fix qspi capacity reg Signed-off-by: surenyi --- bspStubs.c | 2 +- hwconf.c | 3 +-- vxbFtQspi.c | 13 +++++++++---- vxbLfsLib.c | 2 ++ vxbSp25SpiFlash.c | 5 +++-- vxbSp25SpiFlash.h | 3 ++- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/bspStubs.c b/bspStubs.c index def98dd..faece0b 100644 --- a/bspStubs.c +++ b/bspStubs.c @@ -32,7 +32,7 @@ int bspLoadUserApp() SEGMENT_ID seg; SYMBOL_DESC symDesc; struct stat stbuf; - MODULE_ID module = ld(1, 0, USER_APP_PATH); + MODULE_ID module; void (*appEntry)(void) = NULL; if (stat(USER_APP_PATH, &stbuf) != 0) { diff --git a/hwconf.c b/hwconf.c index 1a8e090..1241122 100644 --- a/hwconf.c +++ b/hwconf.c @@ -248,7 +248,7 @@ struct vxbSpiDevInfo qspiDevTbl[] = { struct hcfResource qspiResources[] = { { "regBase", HCF_RES_INT, { (void *)(0x28014000) } }, { "capacity", HCF_RES_INT, { (void *)(QSPI_FLASH_CAP_32MB) } }, - { "clkDiv", HCF_RES_INT, { (void *)(QSPI_SCK_DIV_128) } }, + { "clkDiv", HCF_RES_INT, { (void *)(QSPI_SCK_DIV_32) } }, { "transMode", HCF_RES_INT, { (void *)(QSPI_TRANSFER_1_1_1) } }, { "addrMode", HCF_RES_INT, { (void *)(QSPI_ADDR_SEL_4) } }, { "spiDev", HCF_RES_ADDR, { (void *)&qspiDevTbl[0]} }, @@ -518,7 +518,6 @@ struct hcfResource lfsResources[] = { { "mountPoint" , HCF_RES_STRING, {(void *)TFFS_FLASH_MOUNT_POINTOT}}, { "flashName" , HCF_RES_STRING, {(void *)TFFS_PART0_FLASH_NAME}}, { "flashOffset", HCF_RES_INT, {(void *)(TFFS_PART0_FLASH_BOOT_SIZE)}}, - { "flashSize" , HCF_RES_INT, {(void *)((TFFS_PART0_FLASH_SIZE) - (TFFS_PART0_FLASH_BOOT_SIZE))}}, { "autoFormat", HCF_RES_INT, {(void *)(1)}}, }; #define lfsResNum NELEMENTS(lfsResources) diff --git a/vxbFtQspi.c b/vxbFtQspi.c index 7751140..29f9390 100644 --- a/vxbFtQspi.c +++ b/vxbFtQspi.c @@ -294,10 +294,15 @@ LOCAL void vxbFtQspiCtrlInit ) { FT_QSPI_CTRL * pDrvCtrl; + UINT8 ndev; pDrvCtrl = (FT_QSPI_CTRL *) pDev->pDrvCtrl; - - CSR_WRITE_4 (pDev, REG_QSPI_CAP, CAP_FLASH_NUM(pDrvCtrl->spiDevNum) | CAP_FLASH_CAP(pDrvCtrl->capacity)); + + ndev = pDrvCtrl->spiDevNum & 0x3; + if (ndev > 0) { + ndev -= 1; + } + CSR_WRITE_4 (pDev, REG_QSPI_CAP, CAP_FLASH_NUM(ndev) | CAP_FLASH_CAP(pDrvCtrl->capacity)); pDrvCtrl->initDone = TRUE; } @@ -947,12 +952,12 @@ LOCAL STATUS vxbFtQspiTransfer vxbFtQspiFlashRegGet(pDev); break; case QSPI_FLASH_CMD_4BAM: + vxbFtQspiFlashRegSet(pDev); pDrvCtrl->addrMode = QSPI_ADDR_SEL_4; - /*vxbFtQspiFlashRegSet(pDev);*/ break; case QSPI_FLASH_CMD_4BEX: + vxbFtQspiFlashRegSet(pDev); pDrvCtrl->addrMode = QSPI_ADDR_SEL_3; - /*vxbFtQspiFlashRegSet(pDev);*/ break; case QSPI_FLASH_CMD_WREN: case QSPI_FLASH_CMD_WRDI: diff --git a/vxbLfsLib.c b/vxbLfsLib.c index af9ef23..44d9de3 100644 --- a/vxbLfsLib.c +++ b/vxbLfsLib.c @@ -23,6 +23,8 @@ #define LFS_NO_ASSERT 1 #define LFS_THREADSAFE 1 +#define LFS_NO_DEBUG 1 +#define LFS_NO_WARN 1 #include "lfs/lfs.c" #include "lfs/lfs_util.c" diff --git a/vxbSp25SpiFlash.c b/vxbSp25SpiFlash.c index 7883379..271f377 100644 --- a/vxbSp25SpiFlash.c +++ b/vxbSp25SpiFlash.c @@ -620,7 +620,8 @@ LOCAL char * vendorGet case SAMSUNG: return "Samsung"; - + case GIGADEVICE: + return "GigaDevice"; default: return "Unknown"; } @@ -1724,7 +1725,7 @@ LOCAL STATUS enter4BMode break; else return ERROR; - + case GIGADEVICE: case MXIC: case EON: case WINBOND: diff --git a/vxbSp25SpiFlash.h b/vxbSp25SpiFlash.h index 3078d8d..4f7e01e 100644 --- a/vxbSp25SpiFlash.h +++ b/vxbSp25SpiFlash.h @@ -61,8 +61,9 @@ extern "C" #define MXIC (0xC2) /* The manufacturer id for MXIC */ #define SAMSUNG (0xEC) /* The manufacturer id for SAMSUNG */ #define WINBOND (0xEF) /* The manufacturer id for SAMSUNG */ +#define GIGADEVICE (0xC8) /* The manufacturer id for GigaDevice */ #define MISSING (0xFF) - + /* Spansion SPI Flash Commands info */ #define SPI_WRSR_CMD (0x01)