Commit c2bcfe7c authored by David Lechner's avatar David Lechner Committed by Mark Brown

spi: stm32: move splitting transfers to optimize_message

Since splitting transfers was moved to spi_optimize_message() in the
core SPI code, we now need to use the optimize_message callback in the
STM32 SPI driver to ensure that the operation is only performed once
when spi_optimize_message() is used by peripheral drivers explicitly.
Signed-off-by: default avatarDavid Lechner <dlechner@baylibre.com>
Link: https://msgid.link/r/20240219-mainline-spi-precook-message-v2-3-4a762c6701b9@baylibre.comReviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent fab53fea
...@@ -1118,6 +1118,21 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id) ...@@ -1118,6 +1118,21 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int stm32_spi_optimize_message(struct spi_message *msg)
{
struct spi_controller *ctrl = msg->spi->controller;
struct stm32_spi *spi = spi_controller_get_devdata(ctrl);
/* On STM32H7, messages should not exceed a maximum size set
* later via the set_number_of_data function. In order to
* ensure that, split large messages into several messages
*/
if (spi->cfg->set_number_of_data)
return spi_split_transfers_maxwords(ctrl, msg, spi->t_size_max);
return 0;
}
/** /**
* stm32_spi_prepare_msg - set up the controller to transfer a single message * stm32_spi_prepare_msg - set up the controller to transfer a single message
* @ctrl: controller interface * @ctrl: controller interface
...@@ -1163,18 +1178,6 @@ static int stm32_spi_prepare_msg(struct spi_controller *ctrl, ...@@ -1163,18 +1178,6 @@ static int stm32_spi_prepare_msg(struct spi_controller *ctrl,
!!(spi_dev->mode & SPI_LSB_FIRST), !!(spi_dev->mode & SPI_LSB_FIRST),
!!(spi_dev->mode & SPI_CS_HIGH)); !!(spi_dev->mode & SPI_CS_HIGH));
/* On STM32H7, messages should not exceed a maximum size setted
* afterward via the set_number_of_data function. In order to
* ensure that, split large messages into several messages
*/
if (spi->cfg->set_number_of_data) {
int ret;
ret = spi_split_transfers_maxwords(ctrl, msg, spi->t_size_max);
if (ret)
return ret;
}
spin_lock_irqsave(&spi->lock, flags); spin_lock_irqsave(&spi->lock, flags);
/* CPOL, CPHA and LSB FIRST bits have common register */ /* CPOL, CPHA and LSB FIRST bits have common register */
...@@ -2180,6 +2183,7 @@ static int stm32_spi_probe(struct platform_device *pdev) ...@@ -2180,6 +2183,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
ctrl->max_speed_hz = spi->clk_rate / spi->cfg->baud_rate_div_min; ctrl->max_speed_hz = spi->clk_rate / spi->cfg->baud_rate_div_min;
ctrl->min_speed_hz = spi->clk_rate / spi->cfg->baud_rate_div_max; ctrl->min_speed_hz = spi->clk_rate / spi->cfg->baud_rate_div_max;
ctrl->use_gpio_descriptors = true; ctrl->use_gpio_descriptors = true;
ctrl->optimize_message = stm32_spi_optimize_message;
ctrl->prepare_message = stm32_spi_prepare_msg; ctrl->prepare_message = stm32_spi_prepare_msg;
ctrl->transfer_one = stm32_spi_transfer_one; ctrl->transfer_one = stm32_spi_transfer_one;
ctrl->unprepare_message = stm32_spi_unprepare_msg; ctrl->unprepare_message = stm32_spi_unprepare_msg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment