[U-Boot,v6,3/5] mmc: dwmmc: socfpga: Add reset ctrl to driver

Message ID 1528973123-21858-4-git-send-email-ley.foon.tan@intel.com
State Accepted
Delegated to: Tom Rini
Headers show
Series
  • drivers: Add reset ctrl to drivers
Related show

Commit Message

Ley Foon Tan June 14, 2018, 10:45 a.m.
Add code to reset all reset signals as in mmc DT node. A reset property is an optional feature,
so only print out a warning and do not fail if a reset property is not present.

If a reset property is discovered, then use it to deassert, thus bringing the
IP out of reset.

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

---
v3:
- Removed #ifdef CONFIG_DM_RESET switch.

v5:
- Added Simon's Reviewed-by.
---
 drivers/mmc/socfpga_dw_mmc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Tom Rini July 10, 2018, 1:56 p.m. | #1
On Thu, Jun 14, 2018 at 06:45:21PM +0800, Ley Foon Tan wrote:

> Add code to reset all reset signals as in mmc DT node. A reset property is an optional feature,
> so only print out a warning and do not fail if a reset property is not present.
> 
> If a reset property is discovered, then use it to deassert, thus bringing the
> IP out of reset.
> 
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

Patch

diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c
index d0a0362..4be4eb5 100644
--- a/drivers/mmc/socfpga_dw_mmc.c
+++ b/drivers/mmc/socfpga_dw_mmc.c
@@ -13,6 +13,7 @@ 
 #include <linux/libfdt.h>
 #include <linux/err.h>
 #include <malloc.h>
+#include <reset.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -33,6 +34,20 @@  struct dwmci_socfpga_priv_data {
 	unsigned int		smplsel;
 };
 
+static void socfpga_dwmci_reset(struct udevice *dev)
+{
+	struct reset_ctl_bulk reset_bulk;
+	int ret;
+
+	ret = reset_get_bulk(dev, &reset_bulk);
+	if (ret) {
+	       dev_warn(dev, "Can't get reset: %d\n", ret);
+	       return;
+	}
+
+	reset_deassert_bulk(&reset_bulk);
+}
+
 static void socfpga_dwmci_clksel(struct dwmci_host *host)
 {
 	struct dwmci_socfpga_priv_data *priv = host->priv;
@@ -109,6 +124,8 @@  static int socfpga_dwmmc_probe(struct udevice *dev)
 	struct dwmci_socfpga_priv_data *priv = dev_get_priv(dev);
 	struct dwmci_host *host = &priv->host;
 
+	socfpga_dwmci_reset(dev);
+
 #ifdef CONFIG_BLK
 	dwmci_setup_cfg(&plat->cfg, host, host->bus_hz, 400000);
 	host->mmc = &plat->mmc;