common: Drop linux/delay.h from common header
[oweals/u-boot.git] / drivers / mmc / tmio-common.c
index 5a8506dcb6bdecadaccbb5db5690be5682e9997e..20cd237ef0ebccbe2bbcfb1157ca1582fdd54e65 100644 (file)
@@ -4,16 +4,17 @@
  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
  */
 
-#include <asm/dma-mapping.h>
 #include <common.h>
 #include <clk.h>
 #include <cpu_func.h>
 #include <fdtdec.h>
 #include <mmc.h>
 #include <dm.h>
+#include <dm/device_compat.h>
 #include <dm/pinctrl.h>
 #include <linux/compat.h>
-#include <linux/dma-direction.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
 #include <power/regulator.h>
@@ -352,20 +353,22 @@ static int tmio_sd_dma_xfer(struct udevice *dev, struct mmc_data *data)
        if (poll_flag == TMIO_SD_DMA_INFO1_END_RD)
                udelay(1);
 
-       dma_unmap_single(buf, len, dir);
+       dma_unmap_single(dma_addr, len, dir);
 
        return ret;
 }
 
 /* check if the address is DMA'able */
-static bool tmio_sd_addr_is_dmaable(const char *src)
+static bool tmio_sd_addr_is_dmaable(struct mmc_data *data)
 {
-       uintptr_t addr = (uintptr_t)src;
+       uintptr_t addr = (uintptr_t)data->src;
 
        if (!IS_ALIGNED(addr, TMIO_SD_DMA_MINALIGN))
                return false;
 
 #if defined(CONFIG_RCAR_GEN3)
+       if (!(data->flags & MMC_DATA_READ) && !IS_ALIGNED(addr, 128))
+               return false;
        /* Gen3 DMA has 32bit limit */
        if (addr >> 32)
                return false;
@@ -480,7 +483,7 @@ int tmio_sd_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
        if (data) {
                /* use DMA if the HW supports it and the buffer is aligned */
                if (priv->caps & TMIO_SD_CAP_DMA_INTERNAL &&
-                   tmio_sd_addr_is_dmaable(data->src))
+                   tmio_sd_addr_is_dmaable(data))
                        ret = tmio_sd_dma_xfer(dev, data);
                else
                        ret = tmio_sd_pio_xfer(dev, cmd, data);