git: c8dbee973e50 - stable/13 - dwmmc: Fix MMCCAM block size support

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Mon, 16 May 2022 09:45:29 UTC
The branch stable/13 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=c8dbee973e50d57f8814cce604267ef1e25929b1

commit c8dbee973e50d57f8814cce604267ef1e25929b1
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2021-07-14 15:25:05 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-05-16 09:33:41 +0000

    dwmmc: Fix MMCCAM block size support
    
    When using SDIO the block size if per function and most of the time
    not equal to MMC_SECTOR_SIZE, fix sdio on dwmmc by setting the correct
    block size in the mmc registers.
    
    MFC after:    1 month
    Sponsored by:   Diablotin Systems
    
    (cherry picked from commit 990a1dbf6fe1a9f4dc491d3e4e276034919b94f3)
---
 sys/dev/mmc/host/dwmmc.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/sys/dev/mmc/host/dwmmc.c b/sys/dev/mmc/host/dwmmc.c
index f0cd8c1b4378..9910db2e50cb 100644
--- a/sys/dev/mmc/host/dwmmc.c
+++ b/sys/dev/mmc/host/dwmmc.c
@@ -1162,10 +1162,18 @@ dwmmc_start_cmd(struct dwmmc_softc *sc, struct mmc_command *cmd)
 			cmdr |= SDMMC_CMD_DATA_WRITE;
 
 		WRITE4(sc, SDMMC_TMOUT, 0xffffffff);
-		WRITE4(sc, SDMMC_BYTCNT, data->len);
-		blksz = (data->len < MMC_SECTOR_SIZE) ? \
-			 data->len : MMC_SECTOR_SIZE;
-		WRITE4(sc, SDMMC_BLKSIZ, blksz);
+#ifdef MMCCAM
+		if (cmd->data->flags & MMC_DATA_BLOCK_SIZE) {
+			WRITE4(sc, SDMMC_BLKSIZ, cmd->data->block_size);
+			WRITE4(sc, SDMMC_BYTCNT, cmd->data->len);
+		} else
+#endif
+		{
+			WRITE4(sc, SDMMC_BYTCNT, data->len);
+			blksz = (data->len < MMC_SECTOR_SIZE) ? \
+				data->len : MMC_SECTOR_SIZE;
+			WRITE4(sc, SDMMC_BLKSIZ, blksz);
+		}
 
 		if (sc->use_pio) {
 			pio_prepare(sc, cmd);