This is an automated email from the ASF dual-hosted git repository.

agross pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit d28a5944fcb88993387ae3471d0690a5247f0df2
Author: Andy Gross <[email protected]>
AuthorDate: Mon Sep 26 18:17:55 2022 -0500

    da146x: hal_flash: Add RDID accessor helper function
    
    This patch adds a helper function that provides access to the RDID 
information
    of the flash device.  During flash init, the flash device is queried and the
    RDID structure is identified.  This information can be used by other 
software
    to make decisions about special actions taken with specific flash devices.
    
    Signed-off-by: Andy Gross <[email protected]>
---
 hw/mcu/dialog/da1469x/include/mcu/da1469x_hal.h |  2 ++
 hw/mcu/dialog/da1469x/src/hal_flash.c           | 21 ++++++++++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/hw/mcu/dialog/da1469x/include/mcu/da1469x_hal.h 
b/hw/mcu/dialog/da1469x/include/mcu/da1469x_hal.h
index 26c5f3c4c..78e167528 100755
--- a/hw/mcu/dialog/da1469x/include/mcu/da1469x_hal.h
+++ b/hw/mcu/dialog/da1469x/include/mcu/da1469x_hal.h
@@ -85,6 +85,8 @@ struct qspi_flash_config {
 extern const struct qspi_flash_config rdids[];
 extern const int qspi_flash_config_array_size;
 
+const struct qspi_flash_config *da1469x_qspi_get_config(void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/hw/mcu/dialog/da1469x/src/hal_flash.c 
b/hw/mcu/dialog/da1469x/src/hal_flash.c
index 6004e2594..0ee84923b 100644
--- a/hw/mcu/dialog/da1469x/src/hal_flash.c
+++ b/hw/mcu/dialog/da1469x/src/hal_flash.c
@@ -31,9 +31,11 @@
 union da1469x_qspi_data_reg {
     uint32_t d32;
     uint16_t d16;
-    uint8_t  d8;
+    uint8_t d8;
 };
 
+static const struct qspi_flash_config *rdid_detected = NULL;
+
 static int da1469x_hff_read(const struct hal_flash *dev, uint32_t address,
                             void *dst, uint32_t num_bytes);
 static int da1469x_hff_write(const struct hal_flash *dev, uint32_t address,
@@ -61,6 +63,12 @@ const struct hal_flash da1469x_flash_dev = {
     .hf_erased_val = 0xff,
 };
 
+const struct qspi_flash_config *
+da1469x_qspi_get_config(void)
+{
+    return rdid_detected;
+}
+
 CODE_QSPI_INLINE static uint8_t
 da1469x_qspi_read8(const struct hal_flash *dev)
 {
@@ -453,20 +461,19 @@ qspi_read_rdid(const struct hal_flash *dev)
 static sec_text_ram_core void
 da1469x_hff_mcu_custom_init(const struct hal_flash *dev)
 {
-    const struct qspi_flash_config *config = NULL;
     uint32_t primask;
 
     __HAL_DISABLE_INTERRUPTS(primask);
 
     /* detect flash device and use correct configuration */
-    config = qspi_read_rdid(dev);
-    assert(config);
+    rdid_detected = qspi_read_rdid(dev);
+    assert(rdid_detected);
 
-    QSPIC->QSPIC_BURSTCMDA_REG = config->cmda;
-    QSPIC->QSPIC_BURSTCMDB_REG = config->cmdb;
+    QSPIC->QSPIC_BURSTCMDA_REG = rdid_detected->cmda;
+    QSPIC->QSPIC_BURSTCMDB_REG = rdid_detected->cmdb;
 
     /* provision attached QSPI device for proper quad operation */
-    qspi_qe_enable(dev, &config->qe);
+    qspi_qe_enable(dev, &rdid_detected->qe);
 
     /*
      * Set auto mode, read pipe delay to 0x7, read pipe enable

Reply via email to