From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/8] mci: imx-esdhc: Do not reset twice
Date: Wed, 6 Feb 2019 08:49:14 +0100 [thread overview]
Message-ID: <20190206074921.11115-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20190206074921.11115-1-s.hauer@pengutronix.de>
The esdhc controller is resetted once during probe by calling
esdhc_reset() and once open coded in esdhc_init(). Resetting it once is
enough, so drop the open coded reset from esdhc_init() and call
esdhc_reset() there. With this we can remove the call to esdhc_reset()
during probe.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mci/imx-esdhc.c | 81 +++++++++++++++++------------------------
1 file changed, 34 insertions(+), 47 deletions(-)
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 09df7945cb..a33d654f38 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -519,46 +519,6 @@ static int esdhc_card_present(struct mci_host *mci)
return 0;
}
-static int esdhc_init(struct mci_host *mci, struct device_d *dev)
-{
- struct fsl_esdhc_host *host = to_fsl_esdhc(mci);
- void __iomem *regs = host->regs;
- int timeout = 1000;
- int ret = 0;
-
- /* Reset the entire host controller */
- esdhc_write32(regs + SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET,
- SYSCTL_RSTA);
-
- /* Wait until the controller is available */
- while ((esdhc_read32(regs + SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET)
- & SYSCTL_RSTA) && --timeout)
- udelay(1000);
-
- esdhc_write32(regs + SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET,
- SYSCTL_HCKEN | SYSCTL_IPGEN);
-
- /* RSTA doesn't reset MMC_BOOT register, so manually reset it */
- esdhc_write32(regs + SDHCI_MMC_BOOT, 0);
-
- /* Set the initial clock speed */
- set_sysctl(mci, 400000);
-
- writel(IRQSTATEN_CC | IRQSTATEN_TC | IRQSTATEN_CINT | IRQSTATEN_CTOE |
- IRQSTATEN_CCE | IRQSTATEN_CEBE | IRQSTATEN_CIE | IRQSTATEN_DTOE |
- IRQSTATEN_DCE | IRQSTATEN_DEBE | IRQSTATEN_DINT, regs + SDHCI_INT_ENABLE);
-
- /* Put the PROCTL reg back to the default */
- esdhc_write32(regs + SDHCI_HOST_CONTROL__POWER_CONTROL__BLOCK_GAP_CONTROL,
- PROCTL_INIT);
-
- /* Set timout to the maximum value */
- esdhc_clrsetbits32(regs + SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET,
- SYSCTL_TIMEOUT_MASK, 14 << 16);
-
- return ret;
-}
-
static int esdhc_reset(struct fsl_esdhc_host *host)
{
void __iomem *regs = host->regs;
@@ -595,6 +555,40 @@ static int esdhc_reset(struct fsl_esdhc_host *host)
return 0;
}
+static int esdhc_init(struct mci_host *mci, struct device_d *dev)
+{
+ struct fsl_esdhc_host *host = to_fsl_esdhc(mci);
+ void __iomem *regs = host->regs;
+ int ret;
+
+ ret = esdhc_reset(host);
+ if (ret)
+ return ret;
+
+ esdhc_write32(regs + SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET,
+ SYSCTL_HCKEN | SYSCTL_IPGEN);
+
+ /* RSTA doesn't reset MMC_BOOT register, so manually reset it */
+ esdhc_write32(regs + SDHCI_MMC_BOOT, 0);
+
+ /* Set the initial clock speed */
+ set_sysctl(mci, 400000);
+
+ writel(IRQSTATEN_CC | IRQSTATEN_TC | IRQSTATEN_CINT | IRQSTATEN_CTOE |
+ IRQSTATEN_CCE | IRQSTATEN_CEBE | IRQSTATEN_CIE | IRQSTATEN_DTOE |
+ IRQSTATEN_DCE | IRQSTATEN_DEBE | IRQSTATEN_DINT, regs + SDHCI_INT_ENABLE);
+
+ /* Put the PROCTL reg back to the default */
+ esdhc_write32(regs + SDHCI_HOST_CONTROL__POWER_CONTROL__BLOCK_GAP_CONTROL,
+ PROCTL_INIT);
+
+ /* Set timout to the maximum value */
+ esdhc_clrsetbits32(regs + SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET,
+ SYSCTL_TIMEOUT_MASK, 14 << 16);
+
+ return ret;
+}
+
static int fsl_esdhc_detect(struct device_d *dev)
{
struct fsl_esdhc_host *host = dev->priv;
@@ -648,13 +642,6 @@ static int fsl_esdhc_probe(struct device_d *dev)
return PTR_ERR(iores);
host->regs = IOMEM(iores->start);
- /* First reset the eSDHC controller */
- ret = esdhc_reset(host);
- if (ret) {
- free(host);
- return ret;
- }
-
caps = esdhc_read32(host->regs + SDHCI_CAPABILITIES);
if (caps & ESDHC_HOSTCAPBLT_VS18)
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-02-06 7:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-06 7:49 [PATCH 0/8] MMC: esdhc: Add Layerscape support Sascha Hauer
2019-02-06 7:49 ` Sascha Hauer [this message]
2019-02-06 7:49 ` [PATCH 2/8] mci: imx-esdhc: use dev_id Sascha Hauer
2019-02-06 7:49 ` [PATCH 3/8] mci: imx-esdhc: move platform_data Sascha Hauer
2019-02-06 7:49 ` [PATCH 4/8] mci: imx-esdhc: make clkidx configurable Sascha Hauer
2019-02-06 7:49 ` [PATCH 5/8] mci: imx-esdhc: remove unnecessary include Sascha Hauer
2019-02-06 7:49 ` [PATCH 6/8] mci: imx-esdhc: implement static inline io wrappers Sascha Hauer
2019-02-07 0:55 ` Andrey Smirnov
2019-02-07 7:56 ` Sascha Hauer
2019-02-06 7:49 ` [PATCH 7/8] mci: imx-esdhc: Add bigendian register access support Sascha Hauer
2019-02-06 7:49 ` [PATCH 8/8] mci: imx-esdhc: Add layerscape support Sascha Hauer
2019-02-07 1:02 ` Andrey Smirnov
2019-02-12 8:42 ` Sascha Hauer
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=20190206074921.11115-2-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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