linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "David Lanzendörfer" <david.lanzendoerfer-Z7Kmv9EsliU@public.gmane.org>
Cc: Maxime Ripard
	<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
	Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH 1/2] sunxi-mci: Move clk_enable / disable into host_init / exit
Date: Fri,  7 Feb 2014 15:00:40 +0100	[thread overview]
Message-ID: <1391781641-7382-2-git-send-email-hdegoede@redhat.com> (raw)
In-Reply-To: <1391781641-7382-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 drivers/mmc/host/sunxi-mci.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/host/sunxi-mci.c b/drivers/mmc/host/sunxi-mci.c
index 627d0ee..0eb59be 100644
--- a/drivers/mmc/host/sunxi-mci.c
+++ b/drivers/mmc/host/sunxi-mci.c
@@ -45,10 +45,23 @@
 
 #include "sunxi-mci.h"
 
-static void sunxi_mmc_init_host(struct mmc_host *mmc)
+static int sunxi_mmc_init_host(struct mmc_host *mmc)
 {
 	u32 rval;
 	struct sunxi_mmc_host *smc_host = mmc_priv(mmc);
+	int ret;
+
+	ret =  clk_prepare_enable(smc_host->clk_ahb);
+	if (ret) {
+		dev_err(mmc_dev(smc_host->mmc), "AHB clk err %d\n", ret);
+		return ret;
+	}
+	ret =  clk_prepare_enable(smc_host->clk_mod);
+	if (ret) {
+		dev_err(mmc_dev(smc_host->mmc), "MOD clk err %d\n", ret);
+		clk_disable_unprepare(smc_host->clk_ahb);
+		return ret;
+	}
 
 	/* reset controller */
 	rval = mci_readl(smc_host, REG_GCTRL) | SDXC_HWReset;
@@ -64,11 +77,15 @@ static void sunxi_mmc_init_host(struct mmc_host *mmc)
 	rval = mci_readl(smc_host, REG_GCTRL)|SDXC_INTEnb;
 	rval &= ~SDXC_AccessDoneDirect;
 	mci_writel(smc_host, REG_GCTRL, rval);
+
+	return 0;
 }
 
 static void sunxi_mmc_exit_host(struct sunxi_mmc_host *smc_host)
 {
 	mci_writel(smc_host, REG_GCTRL, SDXC_HWReset);
+	clk_disable_unprepare(smc_host->clk_ahb);
+	clk_disable_unprepare(smc_host->clk_mod);
 }
 
 /* /\* UHS-I Operation Modes */
@@ -515,21 +532,11 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 			udelay(200);
 		}
 
-		err =  clk_prepare_enable(host->clk_ahb);
-		if (err) {
-			dev_err(mmc_dev(host->mmc), "AHB clk err %d\n", err);
-			host->ferror = 1;
-			return;
-		}
-		err =  clk_prepare_enable(host->clk_mod);
+		err = sunxi_mmc_init_host(mmc);
 		if (err) {
-			dev_err(mmc_dev(host->mmc), "MOD clk err %d\n", err);
-			clk_disable_unprepare(host->clk_ahb);
 			host->ferror = 1;
 			return;
 		}
-
-		sunxi_mmc_init_host(mmc);
 		enable_irq(host->irq);
 
 		dev_dbg(mmc_dev(host->mmc), "power on!\n");
@@ -540,8 +547,6 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		dev_dbg(mmc_dev(host->mmc), "power off!\n");
 		disable_irq(host->irq);
 		sunxi_mmc_exit_host(host);
-		clk_disable_unprepare(host->clk_ahb);
-		clk_disable_unprepare(host->clk_mod);
 		if (!IS_ERR(host->vmmc))
 			mmc_regulator_set_ocr(host->mmc, host->vmmc, 0);
 		host->ferror = 0;
-- 
1.8.4.2

  parent reply	other threads:[~2014-02-07 14:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07 14:00 [PATCH 0/2] sunxi-mci: Fix hang on boot caused by irq storm Hans de Goede
     [not found] ` <1391781641-7382-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-02-07 14:00   ` Hans de Goede [this message]
2014-02-07 14:00   ` [PATCH 2/2] " Hans de Goede
2014-02-07 14:31   ` [PATCH 0/2] " David Lanzendörfer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391781641-7382-2-git-send-email-hdegoede@redhat.com \
    --to=hdegoede-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=david.lanzendoerfer-Z7Kmv9EsliU@public.gmane.org \
    --cc=linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).