This is necessary to support the sun6i-a31.
Signed-off-by: Hans de Goede <[email protected]>
---
drivers/mmc/host/sunxi-mmc.c | 19 +++++++++++++++++++
drivers/mmc/host/sunxi-mmc.h | 1 +
2 files changed, 20 insertions(+)
diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
index a16abd2..6b864165 100644
--- a/drivers/mmc/host/sunxi-mmc.c
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -31,6 +31,7 @@
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/regulator/consumer.h>
+#include <linux/reset.h>
#include <linux/of_address.h>
#include <linux/of_gpio.h>
@@ -64,6 +65,16 @@ static int sunxi_mmc_init_host(struct mmc_host *mmc)
return ret;
}
+ if (smc_host->reset) {
+ ret = reset_control_deassert(smc_host->reset);
+ if (ret) {
+ dev_err(mmc_dev(smc_host->mmc), "reset err %d\n", ret);
+ clk_disable_unprepare(smc_host->clk_ahb);
+ clk_disable_unprepare(smc_host->clk_mod);
+ return ret;
+ }
+ }
+
/* reset controller */
rval = mci_readl(smc_host, REG_GCTRL) | SDXC_HARDWARE_RESET;
mci_writel(smc_host, REG_GCTRL, rval);
@@ -85,6 +96,10 @@ static int sunxi_mmc_init_host(struct mmc_host *mmc)
static void sunxi_mmc_exit_host(struct sunxi_mmc_host *smc_host)
{
mci_writel(smc_host, REG_GCTRL, SDXC_HARDWARE_RESET);
+
+ if (smc_host->reset)
+ reset_control_assert(smc_host->reset);
+
clk_disable_unprepare(smc_host->clk_ahb);
clk_disable_unprepare(smc_host->clk_mod);
}
@@ -738,6 +753,10 @@ static int sunxi_mmc_resource_request(struct
sunxi_mmc_host *host,
return PTR_ERR(host->clk_mod);
}
+ host->reset = devm_reset_control_get(&pdev->dev, "reset");
+ if (IS_ERR(host->reset))
+ host->reset = NULL; /* Having a reset controller is optional */
+
/* Make sure the controller is in a sane state before enabling irqs */
ret = sunxi_mmc_init_host(host->mmc);
if (ret)
diff --git a/drivers/mmc/host/sunxi-mmc.h b/drivers/mmc/host/sunxi-mmc.h
index 84bab99..792af8c 100644
--- a/drivers/mmc/host/sunxi-mmc.h
+++ b/drivers/mmc/host/sunxi-mmc.h
@@ -186,6 +186,7 @@ struct sunxi_idma_des {
struct sunxi_mmc_host {
struct mmc_host *mmc;
struct regulator *vmmc;
+ struct reset_control *reset;
/* IO mapping base */
void __iomem *reg_base;
--
1.9.0
--
You received this message because you are subscribed to the Google Groups
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.