net: mt7628-eth: add support to isolate LAN/WAN ports
[oweals/u-boot.git] / drivers / mmc / stm32_sdmmc2.c
index ed31ca126e934011bbb55e9feb00dafa1e19561e..1726ed72efcae87ab35006b9c985e483cc8a27b3 100644 (file)
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <linux/iopoll.h>
+#include <watchdog.h>
 
 struct stm32_sdmmc2_plat {
        struct mmc_config cfg;
@@ -190,7 +191,7 @@ struct stm32_sdmmc2_ctx {
 #define SDMMC_IDMACTRL_IDMAEN          BIT(0)
 
 #define SDMMC_CMD_TIMEOUT              0xFFFFFFFF
-#define SDMMC_BUSYD0END_TIMEOUT_US     1000000
+#define SDMMC_BUSYD0END_TIMEOUT_US     2000000
 
 static void stm32_sdmmc2_start_data(struct stm32_sdmmc2_priv *priv,
                                    struct mmc_data *data,
@@ -432,6 +433,8 @@ static int stm32_sdmmc2_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
        u32 cmdat = data ? SDMMC_CMD_CMDTRANS : 0;
        int ret, retry = 3;
 
+       WATCHDOG_RESET();
+
 retry_cmd:
        ctx.data_length = 0;
        ctx.dpsm_abort = false;
@@ -521,8 +524,6 @@ static void stm32_sdmmc2_pwrcycle(struct stm32_sdmmc2_priv *priv)
                return;
 
        stm32_sdmmc2_reset(priv);
-       writel(SDMMC_POWER_PWRCTRL_CYCLE | priv->pwr_reg_msk,
-              priv->base + SDMMC_POWER);
 }
 
 /*
@@ -616,10 +617,21 @@ static int stm32_sdmmc2_getcd(struct udevice *dev)
        return 1;
 }
 
+static int stm32_sdmmc2_host_power_cycle(struct udevice *dev)
+{
+       struct stm32_sdmmc2_priv *priv = dev_get_priv(dev);
+
+       writel(SDMMC_POWER_PWRCTRL_CYCLE | priv->pwr_reg_msk,
+              priv->base + SDMMC_POWER);
+
+       return 0;
+}
+
 static const struct dm_mmc_ops stm32_sdmmc2_ops = {
        .send_cmd = stm32_sdmmc2_send_cmd,
        .set_ios = stm32_sdmmc2_set_ios,
        .get_cd = stm32_sdmmc2_getcd,
+       .host_power_cycle = stm32_sdmmc2_host_power_cycle,
 };
 
 static int stm32_sdmmc2_probe(struct udevice *dev)
@@ -669,6 +681,7 @@ static int stm32_sdmmc2_probe(struct udevice *dev)
        switch (dev_read_u32_default(dev, "bus-width", 1)) {
        case 8:
                cfg->host_caps |= MMC_MODE_8BIT;
+               /* fall through */
        case 4:
                cfg->host_caps |= MMC_MODE_4BIT;
                break;
@@ -692,7 +705,7 @@ clk_free:
        return ret;
 }
 
-int stm32_sdmmc_bind(struct udevice *dev)
+static int stm32_sdmmc_bind(struct udevice *dev)
 {
        struct stm32_sdmmc2_plat *plat = dev_get_platdata(dev);