}
 EXPORT_SYMBOL(mmc_set_blocklen);
 
+static void mmc_hw_reset_for_init(struct mmc_host *host)
+{
+       if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
+               return;
+       mmc_host_clk_hold(host);
+       host->ops->hw_reset(host);
+       mmc_host_clk_release(host);
+}
+
+int mmc_can_reset(struct mmc_card *card)
+{
+       u8 rst_n_function;
+
+       if (!mmc_card_mmc(card))
+               return 0;
+       rst_n_function = card->ext_csd.rst_n_function;
+       if ((rst_n_function & EXT_CSD_RST_N_EN_MASK) != EXT_CSD_RST_N_ENABLED)
+               return 0;
+       return 1;
+}
+EXPORT_SYMBOL(mmc_can_reset);
+
+static int mmc_do_hw_reset(struct mmc_host *host, int check)
+{
+       struct mmc_card *card = host->card;
+
+       if (!host->bus_ops->power_restore)
+               return -EOPNOTSUPP;
+
+       if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
+               return -EOPNOTSUPP;
+
+       if (!card)
+               return -EINVAL;
+
+       if (!mmc_can_reset(card))
+               return -EOPNOTSUPP;
+
+       mmc_host_clk_hold(host);
+       mmc_set_clock(host, host->f_init);
+
+       host->ops->hw_reset(host);
+
+       /* If the reset has happened, then a status command will fail */
+       if (check) {
+               struct mmc_command cmd = {0};
+               int err;
+
+               cmd.opcode = MMC_SEND_STATUS;
+               if (!mmc_host_is_spi(card->host))
+                       cmd.arg = card->rca << 16;
+               cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC;
+               err = mmc_wait_for_cmd(card->host, &cmd, 0);
+               if (!err) {
+                       mmc_host_clk_release(host);
+                       return -ENOSYS;
+               }
+       }
+
+       host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_DDR);
+       if (mmc_host_is_spi(host)) {
+               host->ios.chip_select = MMC_CS_HIGH;
+               host->ios.bus_mode = MMC_BUSMODE_PUSHPULL;
+       } else {
+               host->ios.chip_select = MMC_CS_DONTCARE;
+               host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
+       }
+       host->ios.bus_width = MMC_BUS_WIDTH_1;
+       host->ios.timing = MMC_TIMING_LEGACY;
+       mmc_set_ios(host);
+
+       mmc_host_clk_release(host);
+
+       return host->bus_ops->power_restore(host);
+}
+
+int mmc_hw_reset(struct mmc_host *host)
+{
+       return mmc_do_hw_reset(host, 0);
+}
+EXPORT_SYMBOL(mmc_hw_reset);
+
+int mmc_hw_reset_check(struct mmc_host *host)
+{
+       return mmc_do_hw_reset(host, 1);
+}
+EXPORT_SYMBOL(mmc_hw_reset_check);
+
 static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
 {
        host->f_init = freq;
 #endif
        mmc_power_up(host);
 
+       /*
+        * Some eMMCs (with VCCQ always on) may not be reset after power up, so
+        * do a hardware reset if possible.
+        */
+       mmc_hw_reset_for_init(host);
+
        /*
         * sdio_reset sends CMD52 to reset card.  Since we do not know
         * if the card is being re-initialized, just send it.  CMD52
 
        int     (*execute_tuning)(struct mmc_host *host);
        void    (*enable_preset_value)(struct mmc_host *host, bool enable);
        int     (*select_drive_strength)(unsigned int max_dtr, int host_drv, int card_drv);
+       void    (*hw_reset)(struct mmc_host *host);
 };
 
 struct mmc_card;
 #define MMC_CAP_MAX_CURRENT_600        (1 << 28)       /* Host max current limit is 600mA */
 #define MMC_CAP_MAX_CURRENT_800        (1 << 29)       /* Host max current limit is 800mA */
 #define MMC_CAP_CMD23          (1 << 30)       /* CMD23 supported. */
+#define MMC_CAP_HW_RESET       (1 << 31)       /* Hardware reset */
 
        mmc_pm_flag_t           pm_caps;        /* supported pm features */
 
 
 
 #define EXT_CSD_PARTITION_ATTRIBUTE    156     /* R/W */
 #define EXT_CSD_PARTITION_SUPPORT      160     /* RO */
+#define EXT_CSD_RST_N_FUNCTION         162     /* R/W */
 #define EXT_CSD_WR_REL_PARAM           166     /* RO */
 #define EXT_CSD_ERASE_GROUP_DEF                175     /* R/W */
 #define EXT_CSD_PART_CONFIG            179     /* R/W */
 #define EXT_CSD_SEC_BD_BLK_EN  BIT(2)
 #define EXT_CSD_SEC_GB_CL_EN   BIT(4)
 
+#define EXT_CSD_RST_N_EN_MASK  0x3
+#define EXT_CSD_RST_N_ENABLED  1       /* RST_n is enabled on card */
+
 /*
  * MMC_SWITCH access modes
  */