drivers/memory/spiflash: Allow a board/port to configure chip params.

This commit allows the user of this driver to dynamically configure the SPI
flash chip parameters.  For this, enable `MICROPY_HW_SPIFLASH_CHIP_PARAMS`
and then set the `mp_spiflash_t::chip_params` element to point to a valid
`mp_spiflash_chip_params_t` struct.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-04-09 21:30:17 +10:00
parent ef8282c717
commit e7edf0783e

View File

@@ -29,6 +29,11 @@
#include "drivers/bus/spi.h"
#include "drivers/bus/qspi.h"
// Whether to enable dynamic configuration of SPI flash through mp_spiflash_chip_params_t.
#ifndef MICROPY_HW_SPIFLASH_CHIP_PARAMS
#define MICROPY_HW_SPIFLASH_CHIP_PARAMS (0)
#endif
#define MP_SPIFLASH_ERASE_BLOCK_SIZE (4096) // must be a power of 2
enum {
@@ -66,8 +71,20 @@ typedef struct _mp_spiflash_config_t {
#endif
} mp_spiflash_config_t;
#if MICROPY_HW_SPIFLASH_CHIP_PARAMS
typedef struct _mp_spiflash_chip_params_t {
uint32_t jedec_id;
uint8_t memory_size_bytes_log2;
uint8_t qspi_prescaler;
uint8_t qread_num_dummy;
} mp_spiflash_chip_params_t;
#endif
typedef struct _mp_spiflash_t {
const mp_spiflash_config_t *config;
#if MICROPY_HW_SPIFLASH_CHIP_PARAMS
const mp_spiflash_chip_params_t *chip_params;
#endif
volatile uint32_t flags;
} mp_spiflash_t;