Skip to content

Commit

Permalink
drivers: flash: stm32 qspi driver reads sfdp table
Browse files Browse the repository at this point in the history
Fix the SFDP command to be sent by the qspi driver
to get the SFDP table from the NOR quad flash.
Note that CONFIG_FLASH_STM32_QSPI=y and CONFIG_SPI_NOR=n
HAL_DMA_Abort declared as  weak to fix compilation error with stm32f7x

Signed-off-by: Francois Ramu <francois.ramu@st.com>
  • Loading branch information
FRASTM authored and carlescufi committed Nov 3, 2023
1 parent 58ec905 commit ba9ebb7
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion drivers/flash/flash_stm32_qspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,13 @@ static int qspi_read_jedec_id(const struct device *dev, uint8_t *id)
static int qspi_read_sfdp(const struct device *dev, off_t addr, void *data,
size_t size)
{
struct flash_stm32_qspi_data *dev_data = dev->data;
HAL_StatusTypeDef hal_ret;

__ASSERT(data != NULL, "null destination");

LOG_INF("Reading SFDP");

QSPI_CommandTypeDef cmd = {
.Instruction = JESD216_CMD_READ_SFDP,
.Address = addr,
Expand All @@ -346,9 +351,26 @@ static int qspi_read_sfdp(const struct device *dev, off_t addr, void *data,
.InstructionMode = QSPI_INSTRUCTION_1_LINE,
.AddressMode = QSPI_ADDRESS_1_LINE,
.DataMode = QSPI_DATA_1_LINE,
.NbData = size,
};

return qspi_read_access(dev, &cmd, (uint8_t *)data, size);
hal_ret = HAL_QSPI_Command(&dev_data->hqspi, &cmd,
HAL_QSPI_TIMEOUT_DEFAULT_VALUE);
if (hal_ret != HAL_OK) {
LOG_ERR("%d: Failed to send SFDP instruction", hal_ret);
return -EIO;
}

hal_ret = HAL_QSPI_Receive(&dev_data->hqspi, (uint8_t *)data,
HAL_QSPI_TIMEOUT_DEFAULT_VALUE);
if (hal_ret != HAL_OK) {
LOG_ERR("%d: Failed to read SFDP", hal_ret);
return -EIO;
}

dev_data->cmd_status = 0;

return 0;
}

static bool qspi_address_is_valid(const struct device *dev, off_t addr,
Expand Down Expand Up @@ -615,6 +637,11 @@ static void qspi_dma_callback(const struct device *dev, void *arg,
}
#endif

__weak HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
{
return HAL_OK;
}

__weak HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
{
return HAL_OK;
Expand Down

0 comments on commit ba9ebb7

Please sign in to comment.