diff mbox series

[U-Boot,6/7] mmc: uniphier-sd: Handle DMA completion flag differences

Message ID 20180116171703.14361-6-marek.vasut+renesas@gmail.com
State Superseded
Delegated to: Masahiro Yamada
Headers show
Series [U-Boot,1/7] mmc: uniphier-sd: Use mmc_of_parse() | expand

Commit Message

Marek Vasut Jan. 16, 2018, 5:17 p.m. UTC
The DMA READ completion flag position differs on Socionext and Renesas
SoCs. It is bit 20 on Socionext SoCs and using bit 17 is a hardware bug
and forbidden. It is bit 17 on Renesas SoCs and bit 20 does not work on
them.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/mmc/uniphier-sd.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Masahiro Yamada Jan. 25, 2018, 10:49 a.m. UTC | #1
2018-01-17 2:17 GMT+09:00 Marek Vasut <marek.vasut@gmail.com>:
> The DMA READ completion flag position differs on Socionext and Renesas
> SoCs. It is bit 20 on Socionext SoCs and using bit 17 is a hardware bug
> and forbidden. It is bit 17 on Renesas SoCs and bit 20 does not work on
> them.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---

Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
diff mbox series

Patch

diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c
index 2af8244515..3b7f04e59a 100644
--- a/drivers/mmc/uniphier-sd.c
+++ b/drivers/mmc/uniphier-sd.c
@@ -108,8 +108,8 @@  DECLARE_GLOBAL_DATA_PTR;
 #define   UNIPHIER_SD_DMA_RST_RD	BIT(9)
 #define   UNIPHIER_SD_DMA_RST_WR	BIT(8)
 #define UNIPHIER_SD_DMA_INFO1		0x420
-#define   UNIPHIER_SD_DMA_INFO1_END_RD2	BIT(20)	/* DMA from device is complete*/
-#define   UNIPHIER_SD_DMA_INFO1_END_RD	BIT(17)	/* Don't use!  Hardware bug */
+#define   UNIPHIER_SD_DMA_INFO1_END_RD2	BIT(20)	/* DMA from device is complete (uniphier) */
+#define   UNIPHIER_SD_DMA_INFO1_END_RD	BIT(17)	/* DMA from device is complete (renesas) */
 #define   UNIPHIER_SD_DMA_INFO1_END_WR	BIT(16)	/* DMA to device is complete */
 #define UNIPHIER_SD_DMA_INFO1_MASK	0x424
 #define UNIPHIER_SD_DMA_INFO2		0x428
@@ -443,7 +443,15 @@  static int uniphier_sd_dma_xfer(struct udevice *dev, struct mmc_data *data)
 	if (data->flags & MMC_DATA_READ) {
 		buf = data->dest;
 		dir = DMA_FROM_DEVICE;
-		poll_flag = UNIPHIER_SD_DMA_INFO1_END_RD2;
+		/*
+		 * The DMA READ completion flag position differs on Socionext
+		 * and Renesas SoCs. It is bit 20 on Socionext SoCs and using
+		 * bit 17 is a hardware bug and forbidden. It is bit 17 on
+		 * Renesas SoCs and bit 20 does not work on them.
+		 */
+		poll_flag = (priv->caps & UNIPHIER_SD_CAP_RCAR) ?
+			    UNIPHIER_SD_DMA_INFO1_END_RD :
+			    UNIPHIER_SD_DMA_INFO1_END_RD2;
 		tmp |= UNIPHIER_SD_DMA_MODE_DIR_RD;
 	} else {
 		buf = (void *)data->src;