mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mci: arasan: add dma write support
@ 2024-03-08 10:49 Steffen Trumtrar
  2024-03-13  7:44 ` Sascha Hauer
  2024-03-13  7:45 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Steffen Trumtrar @ 2024-03-08 10:49 UTC (permalink / raw)
  To: barebox

Switch from PIO to DMA mode in send_cmd.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
Everything needed for the Arasan SDHCI to use DMA instead of PIO is
already present. Switch to it.

Tested on: ZynqMP.
---
 drivers/mci/arasan-sdhci.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/mci/arasan-sdhci.c b/drivers/mci/arasan-sdhci.c
index 59afac7372..973e08779d 100644
--- a/drivers/mci/arasan-sdhci.c
+++ b/drivers/mci/arasan-sdhci.c
@@ -147,6 +147,7 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 {
 	struct arasan_sdhci_host *host = to_arasan_sdhci_host(mci);
 	u32 mask, command, xfer;
+	dma_addr_t dma;
 	int ret;
 
 	ret = sdhci_wait_idle(&host->sdhci, cmd);
@@ -156,13 +157,14 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 	sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, ~0);
 
 	mask = SDHCI_INT_CMD_COMPLETE;
-	if (data && data->flags == MMC_DATA_READ)
-		mask |= SDHCI_INT_DATA_AVAIL;
 	if (cmd->resp_type & MMC_RSP_BUSY)
 		mask |= SDHCI_INT_XFER_COMPLETE;
 
-	sdhci_set_cmd_xfer_mode(&host->sdhci,
-				cmd, data, false, &command, &xfer);
+	sdhci_setup_data_dma(&host->sdhci, data, &dma);
+
+	sdhci_set_cmd_xfer_mode(&host->sdhci, cmd, data,
+				dma == SDHCI_NO_DMA ? false : true,
+				&command, &xfer);
 
 	sdhci_write8(&host->sdhci, SDHCI_TIMEOUT_CONTROL, TIMEOUT_VAL);
 	if (data) {
@@ -174,15 +176,15 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 	sdhci_write32(&host->sdhci, SDHCI_ARGUMENT, cmd->cmdarg);
 	sdhci_write16(&host->sdhci, SDHCI_COMMAND, command);
 
-	ret = sdhci_wait_for_done(&host->sdhci, mask);
+	ret = sdhci_wait_for_done(&host->sdhci, SDHCI_INT_CMD_COMPLETE);
 	if (ret)
 		goto error;
 
 	sdhci_read_response(&host->sdhci, cmd);
-	sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, mask);
+	sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, SDHCI_INT_CMD_COMPLETE);
 
 	if (data)
-		ret = sdhci_transfer_data_pio(&host->sdhci, data);
+		ret = sdhci_transfer_data_dma(&host->sdhci, data, dma);
 
 error:
 	if (ret) {

---
base-commit: ed7c14536d521793199abf0597164a46ba68e8e5
change-id: 20240308-v2024-02-0-topic-arasan-dma-support-edd318cce298

Best regards,
-- 
Steffen Trumtrar <s.trumtrar@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mci: arasan: add dma write support
  2024-03-08 10:49 [PATCH] mci: arasan: add dma write support Steffen Trumtrar
@ 2024-03-13  7:44 ` Sascha Hauer
  2024-03-13  7:45 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-03-13  7:44 UTC (permalink / raw)
  To: barebox, Steffen Trumtrar


On Fri, 08 Mar 2024 11:49:59 +0100, Steffen Trumtrar wrote:
> Switch from PIO to DMA mode in send_cmd.
> 
> 

Applied, thanks!

[1/1] mci: arasan: add dma write support
      https://git.pengutronix.de/cgit/barebox/commit/?id=b80c0e1ec64c (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mci: arasan: add dma write support
  2024-03-08 10:49 [PATCH] mci: arasan: add dma write support Steffen Trumtrar
  2024-03-13  7:44 ` Sascha Hauer
@ 2024-03-13  7:45 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-03-13  7:45 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox

On Fri, Mar 08, 2024 at 11:49:59AM +0100, Steffen Trumtrar wrote:
> Switch from PIO to DMA mode in send_cmd.
> 
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
> Everything needed for the Arasan SDHCI to use DMA instead of PIO is
> already present. Switch to it.
> 
> Tested on: ZynqMP.
> ---
>  drivers/mci/arasan-sdhci.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)

The subject says the patch adds DMA *write* support. It's generally DMA
support, not only for write, right? I fixed that up accordingly while
applying.

Sascha

> 
> diff --git a/drivers/mci/arasan-sdhci.c b/drivers/mci/arasan-sdhci.c
> index 59afac7372..973e08779d 100644
> --- a/drivers/mci/arasan-sdhci.c
> +++ b/drivers/mci/arasan-sdhci.c
> @@ -147,6 +147,7 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
>  {
>  	struct arasan_sdhci_host *host = to_arasan_sdhci_host(mci);
>  	u32 mask, command, xfer;
> +	dma_addr_t dma;
>  	int ret;
>  
>  	ret = sdhci_wait_idle(&host->sdhci, cmd);
> @@ -156,13 +157,14 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
>  	sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, ~0);
>  
>  	mask = SDHCI_INT_CMD_COMPLETE;
> -	if (data && data->flags == MMC_DATA_READ)
> -		mask |= SDHCI_INT_DATA_AVAIL;
>  	if (cmd->resp_type & MMC_RSP_BUSY)
>  		mask |= SDHCI_INT_XFER_COMPLETE;
>  
> -	sdhci_set_cmd_xfer_mode(&host->sdhci,
> -				cmd, data, false, &command, &xfer);
> +	sdhci_setup_data_dma(&host->sdhci, data, &dma);
> +
> +	sdhci_set_cmd_xfer_mode(&host->sdhci, cmd, data,
> +				dma == SDHCI_NO_DMA ? false : true,
> +				&command, &xfer);
>  
>  	sdhci_write8(&host->sdhci, SDHCI_TIMEOUT_CONTROL, TIMEOUT_VAL);
>  	if (data) {
> @@ -174,15 +176,15 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
>  	sdhci_write32(&host->sdhci, SDHCI_ARGUMENT, cmd->cmdarg);
>  	sdhci_write16(&host->sdhci, SDHCI_COMMAND, command);
>  
> -	ret = sdhci_wait_for_done(&host->sdhci, mask);
> +	ret = sdhci_wait_for_done(&host->sdhci, SDHCI_INT_CMD_COMPLETE);
>  	if (ret)
>  		goto error;
>  
>  	sdhci_read_response(&host->sdhci, cmd);
> -	sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, mask);
> +	sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, SDHCI_INT_CMD_COMPLETE);
>  
>  	if (data)
> -		ret = sdhci_transfer_data_pio(&host->sdhci, data);
> +		ret = sdhci_transfer_data_dma(&host->sdhci, data, dma);
>  
>  error:
>  	if (ret) {
> 
> ---
> base-commit: ed7c14536d521793199abf0597164a46ba68e8e5
> change-id: 20240308-v2024-02-0-topic-arasan-dma-support-edd318cce298
> 
> Best regards,
> -- 
> Steffen Trumtrar <s.trumtrar@pengutronix.de>
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-13  7:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-08 10:49 [PATCH] mci: arasan: add dma write support Steffen Trumtrar
2024-03-13  7:44 ` Sascha Hauer
2024-03-13  7:45 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox