diff mbox series

[v2] mmc: mmci: use peripheral flow control for STM32

Message ID 20230928135644.1489691-1-ben.wolsieffer@hefring.com
State Superseded
Headers show
Series [v2] mmc: mmci: use peripheral flow control for STM32 | expand

Commit Message

Ben Wolsieffer Sept. 28, 2023, 1:56 p.m. UTC
From: Ben Wolsieffer <Ben.Wolsieffer@hefring.com>

The STM32 SDMMC peripheral (at least for the STM32F429, STM32F469 and
STM32F746, which are all the currently supported devices using periphid
0x00880180) requires DMA to be performed in peripheral flow controller
mode. From the STM32F74/5 reference manual, section 35.3.2:

"SDMMC host allows only to use the DMA in peripheral flow controller
mode. DMA stream used to serve SDMMC must be configured in peripheral
flow controller mode"

This patch adds a variant option to control peripheral flow control and
enables it for the STM32 variant.

Signed-off-by: Ben Wolsieffer <Ben.Wolsieffer@hefring.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
Changes in v2: use bool instead of u8:1

 drivers/mmc/host/mmci.c | 3 ++-
 drivers/mmc/host/mmci.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Ulf Hansson Oct. 10, 2023, 2:27 p.m. UTC | #1
On Thu, 28 Sept 2023 at 15:57, Ben Wolsieffer
<ben.wolsieffer@hefring.com> wrote:
>
> From: Ben Wolsieffer <Ben.Wolsieffer@hefring.com>
>
> The STM32 SDMMC peripheral (at least for the STM32F429, STM32F469 and
> STM32F746, which are all the currently supported devices using periphid
> 0x00880180) requires DMA to be performed in peripheral flow controller
> mode. From the STM32F74/5 reference manual, section 35.3.2:
>
> "SDMMC host allows only to use the DMA in peripheral flow controller
> mode. DMA stream used to serve SDMMC must be configured in peripheral
> flow controller mode"
>
> This patch adds a variant option to control peripheral flow control and
> enables it for the STM32 variant.
>
> Signed-off-by: Ben Wolsieffer <Ben.Wolsieffer@hefring.com>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Applied for next, thanks!

Kind regards
Uffe


> ---
> Changes in v2: use bool instead of u8:1
>
>  drivers/mmc/host/mmci.c | 3 ++-
>  drivers/mmc/host/mmci.h | 2 ++
>  2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index 769b34afa835..90e32f18abbc 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
> @@ -249,6 +249,7 @@ static struct variant_data variant_stm32 = {
>         .f_max                  = 48000000,
>         .pwrreg_clkgate         = true,
>         .pwrreg_nopower         = true,
> +       .dma_flow_controller    = true,
>         .init                   = mmci_variant_init,
>  };
>
> @@ -1012,7 +1013,7 @@ static int _mmci_dmae_prep_data(struct mmci_host *host, struct mmc_data *data,
>                 .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
>                 .src_maxburst = variant->fifohalfsize >> 2, /* # of words */
>                 .dst_maxburst = variant->fifohalfsize >> 2, /* # of words */
> -               .device_fc = false,
> +               .device_fc = variant->dma_flow_controller,
>         };
>         struct dma_chan *chan;
>         struct dma_device *device;
> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
> index 253197f132fc..34d9897c289b 100644
> --- a/drivers/mmc/host/mmci.h
> +++ b/drivers/mmc/host/mmci.h
> @@ -332,6 +332,7 @@ enum mmci_busy_state {
>   * @opendrain: bitmask identifying the OPENDRAIN bit inside MMCIPOWER register
>   * @dma_lli: true if variant has dma link list feature.
>   * @stm32_idmabsize_mask: stm32 sdmmc idma buffer size.
> + * @dma_flow_controller: use peripheral as flow controller for DMA.
>   */
>  struct variant_data {
>         unsigned int            clkreg;
> @@ -378,6 +379,7 @@ struct variant_data {
>         u8                      dma_lli:1;
>         u32                     stm32_idmabsize_mask;
>         u32                     stm32_idmabsize_align;
> +       bool                    dma_flow_controller;
>         void (*init)(struct mmci_host *host);
>  };
>
> --
> 2.42.0
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 769b34afa835..90e32f18abbc 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -249,6 +249,7 @@  static struct variant_data variant_stm32 = {
 	.f_max			= 48000000,
 	.pwrreg_clkgate		= true,
 	.pwrreg_nopower		= true,
+	.dma_flow_controller	= true,
 	.init			= mmci_variant_init,
 };
 
@@ -1012,7 +1013,7 @@  static int _mmci_dmae_prep_data(struct mmci_host *host, struct mmc_data *data,
 		.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
 		.src_maxburst = variant->fifohalfsize >> 2, /* # of words */
 		.dst_maxburst = variant->fifohalfsize >> 2, /* # of words */
-		.device_fc = false,
+		.device_fc = variant->dma_flow_controller,
 	};
 	struct dma_chan *chan;
 	struct dma_device *device;
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index 253197f132fc..34d9897c289b 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -332,6 +332,7 @@  enum mmci_busy_state {
  * @opendrain: bitmask identifying the OPENDRAIN bit inside MMCIPOWER register
  * @dma_lli: true if variant has dma link list feature.
  * @stm32_idmabsize_mask: stm32 sdmmc idma buffer size.
+ * @dma_flow_controller: use peripheral as flow controller for DMA.
  */
 struct variant_data {
 	unsigned int		clkreg;
@@ -378,6 +379,7 @@  struct variant_data {
 	u8			dma_lli:1;
 	u32			stm32_idmabsize_mask;
 	u32			stm32_idmabsize_align;
+	bool			dma_flow_controller;
 	void (*init)(struct mmci_host *host);
 };