common: Drop linux/delay.h from common header
[oweals/u-boot.git] / drivers / mmc / kona_sdhci.c
index 77e42c8afe87c1d4cce3abe9fe377df497491c3d..2bbe673b91299d0d6d61b975cd43c44eb9e97f2f 100644 (file)
@@ -1,13 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2013 Broadcom Corporation.
- *
- * SPDX-License-Identifier:      GPL-2.0+
  */
 
 #include <common.h>
 #include <malloc.h>
 #include <sdhci.h>
-#include <asm/errno.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
 #include <asm/kona-common/clk.h>
 
 #define SDHCI_CORECTRL_OFFSET          0x00008000
@@ -27,7 +27,7 @@ static int init_kona_mmc_core(struct sdhci_host *host)
 
        if (sdhci_readb(host, SDHCI_SOFTWARE_RESET) & SDHCI_RESET_ALL) {
                printf("%s: sd host controller reset error\n", __func__);
-               return 1;
+               return -EBUSY;
        }
 
        /* For kona a hardware reset before anything else. */
@@ -39,7 +39,7 @@ static int init_kona_mmc_core(struct sdhci_host *host)
        do {
                if (timeout == 0) {
                        printf("%s: reset timeout error\n", __func__);
-                       return 1;
+                       return -ETIMEDOUT;
                }
                timeout--;
                udelay(100);
@@ -67,7 +67,7 @@ static int init_kona_mmc_core(struct sdhci_host *host)
        while (!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
                if (timeout == 0) {
                        printf("%s: CARD DETECT timeout error\n", __func__);
-                       return 1;
+                       return -ETIMEDOUT;
                }
                timeout--;
                udelay(100);
@@ -113,22 +113,21 @@ int kona_sdhci_init(int dev_index, u32 min_clk, u32 quirks)
                       __func__, dev_index);
                ret = -EINVAL;
        }
-       if (ret)
+       if (ret) {
+               free(host);
                return ret;
+       }
 
        host->name = "kona-sdhci";
        host->ioaddr = reg_base;
        host->quirks = quirks;
-       host->host_caps = MMC_MODE_HC;
+       host->max_clk = max_clk;
 
-       if (init_kona_mmc_core(host))
+       if (init_kona_mmc_core(host)) {
+               free(host);
                return -EINVAL;
+       }
 
-       if (quirks & SDHCI_QUIRK_REG32_RW)
-               host->version = sdhci_readl(host, SDHCI_HOST_VERSION - 2) >> 16;
-       else
-               host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
-
-       add_sdhci(host, max_clk, min_clk);
+       add_sdhci(host, 0, min_clk);
        return ret;
 }