|
@@ -1795,6 +1795,46 @@ static int mmc_power_restore(struct mmc_host *host)
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+int mmc_can_reset(struct mmc_card *card)
|
|
|
|
+{
|
|
|
|
+ u8 rst_n_function;
|
|
|
|
+
|
|
|
|
+ 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_reset(struct mmc_host *host)
|
|
|
|
+{
|
|
|
|
+ struct mmc_card *card = host->card;
|
|
|
|
+ u32 status;
|
|
|
|
+
|
|
|
|
+ if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
|
|
|
|
+ return -EOPNOTSUPP;
|
|
|
|
+
|
|
|
|
+ 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 (!mmc_send_status(card, &status)) {
|
|
|
|
+ mmc_host_clk_release(host);
|
|
|
|
+ return -ENOSYS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* Set initial state and call mmc_set_ios */
|
|
|
|
+ mmc_set_initial_state(host);
|
|
|
|
+ mmc_host_clk_release(host);
|
|
|
|
+
|
|
|
|
+ return mmc_power_restore(host);
|
|
|
|
+}
|
|
|
|
+
|
|
static const struct mmc_bus_ops mmc_ops = {
|
|
static const struct mmc_bus_ops mmc_ops = {
|
|
.remove = mmc_remove,
|
|
.remove = mmc_remove,
|
|
.detect = mmc_detect,
|
|
.detect = mmc_detect,
|
|
@@ -1805,6 +1845,7 @@ static const struct mmc_bus_ops mmc_ops = {
|
|
.power_restore = mmc_power_restore,
|
|
.power_restore = mmc_power_restore,
|
|
.alive = mmc_alive,
|
|
.alive = mmc_alive,
|
|
.shutdown = mmc_shutdown,
|
|
.shutdown = mmc_shutdown,
|
|
|
|
+ .reset = mmc_reset,
|
|
};
|
|
};
|
|
|
|
|
|
/*
|
|
/*
|