diff --git a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_board_config.h b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_board_config.h index 1aff3729..a79578db 100644 --- a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_board_config.h +++ b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_board_config.h @@ -53,7 +53,8 @@ void Board_deinit(void); /* FLASH Instance Macros */ #define CONFIG_FLASH0 (0U) -#define CONFIG_FLASH_NUM_INSTANCES (1U) +#define CONFIG_FLASH1 (1U) // added 1 more flash +#define CONFIG_FLASH_NUM_INSTANCES (2U) // mnumber of flash instances bumped from 1 to 2 #ifdef __cplusplus diff --git a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_board_open_close.c b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_board_open_close.c index 8c78e4b8..4df20d15 100644 --- a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_board_open_close.c +++ b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_board_open_close.c @@ -62,6 +62,13 @@ Flash_NorOspiObject gFlashObject_S28HS512T = .rdDummyValPhyMode = FLASH_NOR_UPDATE_RD_DUMMY_VALUE, }; +// adding another flash object + +Flash_NorOspiObject gFlashObject_S28HS512T_1 = +{ + .rdDummyValPhyMode = FLASH_NOR_UPDATE_RD_DUMMY_VALUE, +}; + Flash_NorOspiFallBackCfg gFlashFallBackCfg_S28HS512T = { .fallBackFreq = 200000000U, @@ -90,12 +97,48 @@ Flash_NorOspiFallBackCfg gFlashFallBackCfg_S28HS512T = }, }; +// adding another flash here +Flash_NorOspiFallBackCfg gFlashFallBackCfg_S28HS512T_1 = +{ + .fallBackFreq = 200000000U, + .ddrBaudRateDiv = 8U, + .sdrBaudRateDiv = 4U, + .protoCfg1s = { + .protocol = FLASH_CFG_PROTO_1S_1S_1S, + .isDtr = FALSE, + .cmdRd = 0x03, + .cmdWr = 0x02, + .modeClksCmd = 0, + .modeClksRd = 0, + .dummyClksCmd = 0, + .dummyClksRd = 0, + .enableType = 0xFF, + .enableSeq = 0xFF, + .dummyCfg = { + .isAddrReg = FALSE, + .cmdRegRd = 0x00, + .cmdRegWr = 0x00, + .cfgReg = 0x00, + .shift = 0, + .mask = 0x00, + .cfgRegBitP = 0, + }, + }, +}; + Flash_NorOspiHybridLayoutCfg gFlashHybridLayoutCfg_S28HS512T = { .isHybridLayout = 0U, .hybridLayoutType = 0U, }; +// adding another flash +Flash_NorOspiHybridLayoutCfg gFlashHybridLayoutCfg_S28HS512T_1 = +{ + .isHybridLayout = 0U, + .hybridLayoutType = 0U, +}; + /* FLASH Attrs */ Flash_Attrs gFlashAttrs_S28HS512T = { @@ -112,6 +155,23 @@ Flash_Attrs gFlashAttrs_S28HS512T = .sectorSize = 4096, }; +// adding flash attributes for another flash + +Flash_Attrs gFlashAttrs_S28HS512T_1 = +{ + .flashType = CONFIG_FLASH_TYPE_SERIAL, + .flashName = "S28HS512T", + .deviceId = 0x5B1A, + .manufacturerId = 0x34, + .flashSize = 67108864, + .blockCount = 256, + .blockSize = 262144, + .pageCount = 1024, + .pageSize = 256, + .sectorCount = 16384, + .sectorSize = 4096, +}; + /* FLASH DevConfig */ Flash_DevConfig gFlashDevCfg_S28HS512T = { @@ -186,6 +246,81 @@ Flash_DevConfig gFlashDevCfg_S28HS512T = .flashBusyTimeout = 256000000, }; +// adding another flash + +Flash_DevConfig gFlashDevCfg_S28HS512T_1 = +{ + .cmdExtType = OSPI_CMD_EXT_TYPE_REPEAT, + .enable4BAddr = TRUE, + .addrByteSupport = 1, + .fourByteAddrEnSeq = 0xA1, + .cmdWren = 0x06, + .cmdRdsr = 0x05, + .cmdWrsr = 0x00, + .srWip = (1 << 0), + .srWel = (1 << 1), + .xspiWipRdCmd = 0x65, + .xspiWipReg = 0x00800000, + .xspiWipBit = (1 << 0), + .resetType = 0x10, + .eraseCfg = { + .blockSize = 262144, + .sectorSize = 4096, + .cmdBlockErase3B = 0xDC, + .cmdBlockErase4B = 0xDC, + .cmdSectorErase3B = 0x21, + .cmdSectorErase4B = 0x21, + .cmdChipErase = 0xC7, + }, + .idCfg = { + .cmd = 0x9F, + .numBytes = 3, + .dummy4 = 0, + .dummy8 = 0, + }, + .protocolCfg = { + .protocol = FLASH_CFG_PROTO_8D_8D_8D, + .isDtr = TRUE, + .cmdRd = 0xEE, + .cmdWr = 0x12, + .modeClksCmd = 0, + .modeClksRd = 0, + .dummyClksCmd = 3, + .dummyClksRd = 20, + .enableType = 0, + .enableSeq = 0x00, + .protoCfg = { + .isAddrReg = TRUE, + .cmdRegRd = 0x65, + .cmdRegWr = 0x71, + .cfgReg = 0x00800006, + .shift = 0, + .mask = 0x01, + .cfgRegBitP = 1, + }, + .strDtrCfg = { + .isAddrReg = TRUE, + .cmdRegRd = 0x65, + .cmdRegWr = 0x71, + .cfgReg = 0x00800006, + .shift = 1, + .mask = 0x02, + .cfgRegBitP = 1, + }, + .dummyCfg = { + .isAddrReg = TRUE, + .cmdRegRd = 0x65, + .cmdRegWr = 0x71, + .cfgReg = 0x00800003, + .shift = 0, + .mask = 0x0F, + .cfgRegBitP = 8, + }, + }, + .flashWriteTimeout = 512, + .flashBusyTimeout = 256000000, +}; + /* Externs of quirk functions and custom protocol functions */ extern int32_t Flash_quirkSpansionConfigureLayout(Flash_Config *config); extern int32_t Flash_quirkSpansionSafebootDetection(Flash_Config *config); @@ -206,6 +341,14 @@ Flash_Config gFlashConfig[CONFIG_FLASH_NUM_INSTANCES] = .fallBackCfg = (void *)&gFlashFallBackCfg_S28HS512T, .layoutCfg = (void *)&gFlashHybridLayoutCfg_S28HS512T, }, + { + .attrs = &gFlashAttrs_S28HS512T_1, // added another entry to flash config + .fxns = &gFlashNorOspiFxns, + .devConfig = &gFlashDevCfg_S28HS512T_1, + .object = (void *)&gFlashObject_S28HS512T_1, + .fallBackCfg = (void *)&gFlashFallBackCfg_S28HS512T_1, + .layoutCfg = (void *)&gFlashHybridLayoutCfg_S28HS512T_1, + }, }; /* FLASH Open Params - populated from SysConfig options */ @@ -216,6 +359,11 @@ Flash_Params gFlashParams[CONFIG_FLASH_NUM_INSTANCES] = .bootQuirksFxn = Flash_quirkSpansionSafebootDetection, .custProtoFxn = NULL, }, + { + .quirksFxn = Flash_quirkSpansionConfigureLayout, // added another entry to flash parameters + .bootQuirksFxn = Flash_quirkSpansionSafebootDetection, + .custProtoFxn = NULL, + }, }; uint32_t gFlashConfigNum = CONFIG_FLASH_NUM_INSTANCES; @@ -233,6 +381,7 @@ int32_t Board_flashOpen() /* Set the underlying driver instance to the FLASH config */ gFlashAttrs_S28HS512T.driverInstance = CONFIG_OSPI0; + gFlashAttrs_S28HS512T_1.driverInstance = CONFIG_OSPI1; // binded the second flash to OSPI1 /* Open all instances */ for(instCnt = 0U; instCnt < CONFIG_FLASH_NUM_INSTANCES; instCnt++) diff --git a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_config.c b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_config.c index 7893bf5a..d8ab5423 100644 --- a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_config.c +++ b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_config.c @@ -134,6 +134,45 @@ static OSPI_Attrs gOspiAttrs[CONFIG_OSPI_NUM_INSTANCES] = } } }, + { + .baseAddr = CSL_FSS1_OSPI1_CTRL_BASE, // check with Nikhil what will be the right value + .dataBaseAddr = CSL_FSS1_DAT_REG1_BASE, // check with Nikhil what will be the right value + .moduleId = TISCI_DEV_FSS1, + .clkId = TISCI_DEV_FSS1_OSPI_1_OSPI_HCLK_CLK, + .inputClkFreq = 166666666U, + .intrNum = 0U, + .intrEnable = FALSE, + .intrPriority = 4U, + .dmaEnable = TRUE, + .phyEnable = FALSE, + .phySkipTuning = FALSE, + .dacEnable = FALSE, + .chipSelect = OSPI_CS0, + .frmFmt = OSPI_FF_POL0_PHA0, + .decChipSelect = OSPI_DECODER_SELECT4, + .readMode = OSPI_READ_MODE_DAC, + .baudRateDiv = 8, + .phaseDelayElement = 3, + .validateOtp = FALSE, + .dmaRestrictedRegions = gOspiDmaRestrictRegions, + .phyConfiguration = { + .phyControlMode = OSPI_FLASH_CFG_PHY_MASTER_CONTROL_REG_PHY_MASTER_MODE, + .dllLockMode = OSPI_PHY_DLL_HALF_CYCLE_LOCK, + .phyParams = { + .radius = 5, + .rxTxDllMin = 0, + .rxTxDllMax = 127, + .minReadDelay = 0, + .maxReadDelay = 4, + .minPassSize = 100, + .diagonalShift = 10, + .maxDiagonalShift = 70, + .numConsecutiveFail = 5, + .numConsecutivePass = 10, + .rdDelaySearchStep = 16, + } + } + }, }; /* OSPI objects - initialized by the driver */ static OSPI_Object gOspiObjects[CONFIG_OSPI_NUM_INSTANCES]; @@ -144,6 +183,10 @@ OSPI_Config gOspiConfig[CONFIG_OSPI_NUM_INSTANCES] = &gOspiAttrs[CONFIG_OSPI0], &gOspiObjects[CONFIG_OSPI0], }, + { + &gOspiAttrs[CONFIG_OSPI1], + &gOspiObjects[CONFIG_OSPI1], + }, }; uint32_t gOspiConfigNum = CONFIG_OSPI_NUM_INSTANCES; @@ -158,7 +201,7 @@ uint32_t gOspiConfigNum = CONFIG_OSPI_NUM_INSTANCES; #define OSPI_UDMA_BLK_COPY_CH_RING_ELEM_CNT (1U) #define OSPI_UDMA_BLK_COPY_CH_RING_MEM_SIZE (((OSPI_UDMA_BLK_COPY_CH_RING_ELEM_CNT * 8U) + UDMA_CACHELINE_ALIGNMENT) & ~(UDMA_CACHELINE_ALIGNMENT - 1U)) #define OSPI_UDMA_BLK_COPY_CH_TRPD_MEM_SIZE (UDMA_GET_TRPD_TR15_SIZE(1U)) -#define OSPI_UDMA_NUM_BLKCOPY_CH (1U) +#define OSPI_UDMA_NUM_BLKCOPY_CH (2U) // bumped to 2 /* OSPI UDMA Blockcopy Channel Objects */ static Udma_ChObject gOspiUdmaBlkCopyChObj[OSPI_UDMA_NUM_BLKCOPY_CH]; @@ -169,6 +212,11 @@ static uint8_t gOspiUdmaBlkCopyCh0RingMem[OSPI_UDMA_BLK_COPY_CH_RING_MEM_SIZE] _ /* OSPI UDMA Blockcopy Channel TRPD Mem */ static uint8_t gOspiUdmaBlkCopyCh0TrpdMem[OSPI_UDMA_BLK_COPY_CH_TRPD_MEM_SIZE] __attribute__((aligned(UDMA_CACHELINE_ALIGNMENT))); +// for the second flash +static uint8_t gOspiUdmaBlkCopyCh1RingMem[OSPI_UDMA_BLK_COPY_CH_RING_MEM_SIZE] __attribute__((aligned(UDMA_CACHELINE_ALIGNMENT))); + +static uint8_t gOspiUdmaBlkCopyCh1TrpdMem[OSPI_UDMA_BLK_COPY_CH_TRPD_MEM_SIZE] __attribute__((aligned(UDMA_CACHELINE_ALIGNMENT))); + OspiDma_UdmaArgs gOspiUdma0Args = { .drvHandle = &gUdmaDrvObj[CONFIG_UDMA0], @@ -179,11 +227,28 @@ OspiDma_UdmaArgs gOspiUdma0Args = .ringMemSize = OSPI_UDMA_BLK_COPY_CH_RING_MEM_SIZE, .ringElemCount = OSPI_UDMA_BLK_COPY_CH_RING_ELEM_CNT, }; + +// for the second flash +OspiDma_UdmaArgs gOspiUdma1Args = +{ + .drvHandle = &gUdmaDrvObj[CONFIG_UDMA0], + .chHandle = &gOspiUdmaBlkCopyChObj[1], + .trpdMem = &gOspiUdmaBlkCopyCh1TrpdMem, + .trpdMemSize = OSPI_UDMA_BLK_COPY_CH_TRPD_MEM_SIZE, + .ringMem = &gOspiUdmaBlkCopyCh1RingMem, + .ringMemSize = OSPI_UDMA_BLK_COPY_CH_RING_MEM_SIZE, + .ringElemCount = OSPI_UDMA_BLK_COPY_CH_RING_ELEM_CNT, +}; + OSPI_DmaConfig gOspiDmaConfig[CONFIG_OSPI_NUM_DMA_INSTANCES] = { { .fxns = &gOspiDmaUdmaFxns, .ospiDmaArgs = (void *)&gOspiUdma0Args, + }, + { + .fxns = &gOspiDmaUdmaFxns, + .ospiDmaArgs = (void *)&gOspiUdma1Args, } }; diff --git a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_config.h b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_config.h index a8c0000c..2ea87c2e 100644 --- a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_config.h +++ b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_config.h @@ -60,8 +60,9 @@ void System_deinit(void); /* OSPI Instance Macros */ #define CONFIG_OSPI0 (0U) -#define CONFIG_OSPI_NUM_INSTANCES (1U) -#define CONFIG_OSPI_NUM_DMA_INSTANCES (1U) +#define CONFIG_OSPI1 (1U) // added another OSPI1 Controller +#define CONFIG_OSPI_NUM_INSTANCES (2U) // bumped this to 2 +#define CONFIG_OSPI_NUM_DMA_INSTANCES (2U) // bumped this to 2 /* * UDMA */ diff --git a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_open_close.c b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_open_close.c index 7e5772a3..7e0775b8 100644 --- a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_open_close.c +++ b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_drivers_open_close.c @@ -70,6 +70,9 @@ OSPI_Params gOspiParams[CONFIG_OSPI_NUM_INSTANCES] = { .ospiDmaChIndex = 0, }, + { + .ospiDmaChIndex = 1, + }, }; diff --git a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_pinmux_config.c b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_pinmux_config.c index b31a2d3c..99b43154 100644 --- a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_pinmux_config.c +++ b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_pinmux_config.c @@ -94,6 +94,56 @@ static Pinmux_PerCfg_t gPinMuxMainDomainCfg[] = { ( PIN_MODE(0) | PIN_INPUT_ENABLE | PIN_PULL_DISABLE | PIN_DRV_STR_NOMINAL ) }, + /* OSPI1_CLK */ + { + PIN_OSPI1_CLK, + ( PIN_MODE(0) | PIN_PULL_DISABLE | PIN_DRV_STR_FAST ) + }, + /* OSPI1_CSn0 */ + { + PIN_OSPI1_CSN0, + ( PIN_MODE(0) | PIN_PULL_DISABLE | PIN_DRV_STR_FAST ) + }, + /* OSPI1_D0 */ + { + PIN_OSPI1_D0, + ( PIN_MODE(0) | PIN_INPUT_ENABLE | PIN_PULL_DISABLE | PIN_DRV_STR_FAST ) + }, + /* OSPI1_D1 */ + { + PIN_OSPI1_D1, + ( PIN_MODE(0) | PIN_INPUT_ENABLE | PIN_PULL_DISABLE | PIN_DRV_STR_FAST ) + }, + /* OSPI1_D2 */ + { + PIN_OSPI1_D2, + ( PIN_MODE(0) | PIN_INPUT_ENABLE | PIN_PULL_DISABLE | PIN_DRV_STR_FAST ) + }, + /* OSPI1_D3 */ + { + PIN_OSPI1_D3, + ( PIN_MODE(0) | PIN_INPUT_ENABLE | PIN_PULL_DISABLE | PIN_DRV_STR_FAST ) + }, + /* OSPI1_D4 */ + { + PIN_OSPI1_D4, + ( PIN_MODE(0) | PIN_INPUT_ENABLE | PIN_PULL_DISABLE | PIN_DRV_STR_FAST ) + }, + /* OSPI1_D5 */ + { + PIN_OSPI1_D5, + ( PIN_MODE(0) | PIN_INPUT_ENABLE | PIN_PULL_DISABLE | PIN_DRV_STR_FAST ) + }, + /* OSPI1_D6 */ + { + PIN_OSPI1_D6, + ( PIN_MODE(0) | PIN_INPUT_ENABLE | PIN_PULL_DISABLE | PIN_DRV_STR_FAST ) + }, + /* OSPI1_D7 */ + { + PIN_OSPI1_D7, + ( PIN_MODE(0) | PIN_INPUT_ENABLE | PIN_PULL_DISABLE | PIN_DRV_STR_FAST ) + }, /* UART0_RXD -> MCASP4_AXR0 (F19) */ { diff --git a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_power_clock_config.c b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_power_clock_config.c index 42b02933..3ebc9858 100644 --- a/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_power_clock_config.c +++ b/examples/drivers/ospi/ospi_flash_io/am275x-evm/r5fss0-0_freertos/ti-arm-clang/generated/ti_power_clock_config.c @@ -47,7 +47,9 @@ typedef struct { uint32_t gSocModules[] = { TISCI_DEV_FSS0, - + TISCI_DEV_FSS1, + TISCI_DEV_FSS1_FSAS_0, + TISCI_DEV_FSS1_OSPI_1, TISCI_DEV_UART0, SOC_MODULES_END, diff --git a/examples/drivers/ospi/ospi_flash_io/ospi_flash_io.c b/examples/drivers/ospi/ospi_flash_io/ospi_flash_io.c index b04a2748..3325c9b8 100644 --- a/examples/drivers/ospi/ospi_flash_io/ospi_flash_io.c +++ b/examples/drivers/ospi/ospi_flash_io/ospi_flash_io.c @@ -71,8 +71,10 @@ void ospi_flash_io_main(void *args) uint32_t offset; uint32_t blk, page; Flash_Attrs *flashAttrs; + Flash_Attrs *flashAttrs1; - flashAttrs = Flash_getAttrs(CONFIG_FLASH0); + flashAttrs = Flash_getAttrs(CONFIG_FLASH0); + flashAttrs1 = Flash_getAttrs(CONFIG_FLASH1); if(flashAttrs != NULL) { @@ -106,6 +108,33 @@ void ospi_flash_io_main(void *args) } } + if(flashAttrs1 != NULL) + { + offset = APP_OSPI_FLASH_OFFSET_BASE; + ospi_flash_io_fill_buffers(); + Flash_offsetToBlkPage(gFlashHandle[CONFIG_FLASH1], offset, &blk, &page); + Flash_eraseBlk(gFlashHandle[CONFIG_FLASH1], blk); + Flash_write(gFlashHandle[CONFIG_FLASH1], offset, gOspiTxBuf, APP_OSPI_DATA_SIZE); + Flash_read(gFlashHandle[CONFIG_FLASH1], offset, gOspiRxBuf, APP_OSPI_DATA_SIZE); + status |= ospi_flash_io_compare_buffers(); + + offset = APP_OSPI_FLASH_OFFSET_BASE + (flashAttrs1->pageSize*16); + ospi_flash_io_fill_buffers(); + Flash_offsetToBlkPage(gFlashHandle[CONFIG_FLASH1], offset, &blk, &page); + Flash_eraseBlk(gFlashHandle[CONFIG_FLASH1], blk); + Flash_write(gFlashHandle[CONFIG_FLASH1], offset, gOspiTxBuf, APP_OSPI_DATA_SIZE); + Flash_read(gFlashHandle[CONFIG_FLASH1], offset, gOspiRxBuf, APP_OSPI_DATA_SIZE); + status |= ospi_flash_io_compare_buffers(); + } + else + { + DebugP_log("flashAttrs1 are NULL!!\r\n"); + if(SystemP_SUCCESS == status) + { + status = SystemP_FAILURE; + } + } + if(SystemP_SUCCESS == status) { DebugP_log("All tests have passed!!\r\n");