drivers: flash: stm32 qspi driver reads sfdp table
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>
This commit is contained in:
parent
58ec905c0e
commit
ba9ebb7dbd
1 changed files with 28 additions and 1 deletions
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue