[PATCH 4/4] bsps/xqspipsu: Use device information from the FCT
Kinsey Moore
kinsey.moore at oarcorp.com
Wed Jun 7 19:13:47 UTC 2023
Instead of statically defining the device parameters, use the device
information available via the NOR device layer's Flash Configuration
Table.
---
bsps/aarch64/xilinx-zynqmp/jffs2_xqspipsu.c | 12 +++++-----
bsps/include/dev/spi/xqspipsu-flash-helper.h | 24 ++++++++++++++++++++
bsps/shared/dev/spi/xqspipsu-flash-helper.c | 16 +++++++++++++
3 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/bsps/aarch64/xilinx-zynqmp/jffs2_xqspipsu.c b/bsps/aarch64/xilinx-zynqmp/jffs2_xqspipsu.c
index f647c19ec1..70d954550d 100644
--- a/bsps/aarch64/xilinx-zynqmp/jffs2_xqspipsu.c
+++ b/bsps/aarch64/xilinx-zynqmp/jffs2_xqspipsu.c
@@ -38,9 +38,6 @@ typedef struct {
XQspiPsu *qspipsu;
} flash_control;
-/* From the N25Q512A datasheet */
-#define BLOCK_SIZE (64UL * 1024UL)
-#define FLASH_SIZE (1024UL * BLOCK_SIZE)
#define FLASH_DEVICE_ID 0xbb20 /* Type: 0xbb, Capacity: 0x20 */
static flash_control *get_flash_control( rtems_jffs2_flash_control *super )
@@ -117,7 +114,7 @@ static int do_erase(
Status = QspiPsu_NOR_Erase(
QspiPsuPtr,
offset,
- BLOCK_SIZE
+ super->block_size
);
if ( Status != XST_SUCCESS ) {
return Status;
@@ -139,8 +136,6 @@ static void do_destroy( rtems_jffs2_flash_control *super )
static flash_control flash_instance = {
.super = {
- .block_size = BLOCK_SIZE,
- .flash_size = FLASH_SIZE,
.read = do_read,
.write = do_write,
.erase = do_erase,
@@ -171,6 +166,11 @@ int xilinx_zynqmp_nor_jffs2_initialize(
return rv;
}
+ uint32_t sect_size = QspiPsu_NOR_Get_Sector_Size(qspipsu_ptr);
+ uint32_t flash_size = QspiPsu_NOR_Get_Device_Size(qspipsu_ptr);
+ flash_instance.super.flash_size = flash_size;
+ flash_instance.super.block_size = sect_size;
+
rv = mount(
NULL,
mount_dir,
diff --git a/bsps/include/dev/spi/xqspipsu-flash-helper.h b/bsps/include/dev/spi/xqspipsu-flash-helper.h
index 1e16acaf06..5e4233e64e 100644
--- a/bsps/include/dev/spi/xqspipsu-flash-helper.h
+++ b/bsps/include/dev/spi/xqspipsu-flash-helper.h
@@ -131,3 +131,27 @@ int QspiPsu_NOR_Read_Ecc(
u32 Address,
u8 *ReadBfrPtr
);
+
+/*****************************************************************************/
+/**
+ *
+ * This function returns the size of attached flash parts.
+ *
+ * @param QspiPsuPtr is a pointer to the QSPIPSU driver component to use.
+ *
+ * @return The size of attached flash in bytes.
+ *
+ ******************************************************************************/
+u32 QspiPsu_NOR_Get_Device_Size(XQspiPsu *QspiPsuPtr);
+
+/*****************************************************************************/
+/**
+ *
+ * This function returns the sector size of attached flash parts.
+ *
+ * @param QspiPsuPtr is a pointer to the QSPIPSU driver component to use.
+ *
+ * @return The sector size of attached flash in bytes.
+ *
+ ******************************************************************************/
+u32 QspiPsu_NOR_Get_Sector_Size(XQspiPsu *QspiPsuPtr);
diff --git a/bsps/shared/dev/spi/xqspipsu-flash-helper.c b/bsps/shared/dev/spi/xqspipsu-flash-helper.c
index cb705ab505..4e018bf2fa 100644
--- a/bsps/shared/dev/spi/xqspipsu-flash-helper.c
+++ b/bsps/shared/dev/spi/xqspipsu-flash-helper.c
@@ -2258,3 +2258,19 @@ static int MultiDieReadEcc(
}
return 0;
}
+
+u32 QspiPsu_NOR_Get_Sector_Size(XQspiPsu *QspiPsuPtr)
+{
+ if(QspiPsuPtr->Config.ConnectionMode == XQSPIPSU_CONNECTION_MODE_PARALLEL) {
+ return Flash_Config_Table[FCTIndex].SectSize * 2;
+ }
+ return Flash_Config_Table[FCTIndex].SectSize;
+}
+
+u32 QspiPsu_NOR_Get_Device_Size(XQspiPsu *QspiPsuPtr)
+{
+ if(QspiPsuPtr->Config.ConnectionMode == XQSPIPSU_CONNECTION_MODE_STACKED) {
+ return Flash_Config_Table[FCTIndex].FlashDeviceSize * 2;
+ }
+ return Flash_Config_Table[FCTIndex].FlashDeviceSize;
+}
--
2.30.2
More information about the devel
mailing list