mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] mci: rockchip-dwcmshc-sdhci: use sdhci_reset()
@ 2023-03-28 10:10 Sascha Hauer
  2023-03-28 10:10 ` [PATCH 2/2] mci: arasan: " Sascha Hauer
  2023-03-28 12:32 ` [PATCH 1/2] mci: rockchip-dwcmshc-sdhci: " Rouven Czerwinski
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-03-28 10:10 UTC (permalink / raw)
  To: Barebox List

We have sdhci_reset() which does the same as the driver specific
variant. Use the common function instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/rockchip-dwcmshc-sdhci.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/mci/rockchip-dwcmshc-sdhci.c b/drivers/mci/rockchip-dwcmshc-sdhci.c
index a98600cc4c..e1eb4fc788 100644
--- a/drivers/mci/rockchip-dwcmshc-sdhci.c
+++ b/drivers/mci/rockchip-dwcmshc-sdhci.c
@@ -87,26 +87,12 @@ static int rk_sdhci_card_present(struct mci_host *mci)
 	return !!(sdhci_read32(&host->sdhci, SDHCI_PRESENT_STATE) & SDHCI_CARD_DETECT);
 }
 
-static int rk_sdhci_reset(struct rk_sdhci_host *host, u8 mask)
-{
-	sdhci_write8(&host->sdhci, SDHCI_SOFTWARE_RESET, mask);
-
-	/* wait for reset completion */
-	if (wait_on_timeout(100 * MSECOND,
-			!(sdhci_read8(&host->sdhci, SDHCI_SOFTWARE_RESET) & mask))){
-		dev_err(host->mci.hw_dev, "SDHCI reset timeout\n");
-		return -ETIMEDOUT;
-	}
-
-	return 0;
-}
-
 static int rk_sdhci_init(struct mci_host *mci, struct device *dev)
 {
 	struct rk_sdhci_host *host = to_rk_sdhci_host(mci);
 	int ret;
 
-	ret = rk_sdhci_reset(host, SDHCI_RESET_ALL);
+	ret = sdhci_reset(&host->sdhci, SDHCI_RESET_ALL);
 	if (ret)
 		return ret;
 
@@ -274,8 +260,8 @@ static int rk_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 error:
 	if (ret) {
 		print_error(host, cmd->cmdidx);
-		rk_sdhci_reset(host, BIT(1)); /* SDHCI_RESET_CMD */
-		rk_sdhci_reset(host, BIT(2)); /* SDHCI_RESET_DATA */
+		sdhci_reset(&host->sdhci, SDHCI_RESET_CMD);
+		sdhci_reset(&host->sdhci, SDHCI_RESET_DATA);
 	}
 
 	sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, ~0);
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] mci: arasan: use sdhci_reset()
  2023-03-28 10:10 [PATCH 1/2] mci: rockchip-dwcmshc-sdhci: use sdhci_reset() Sascha Hauer
@ 2023-03-28 10:10 ` Sascha Hauer
  2023-03-28 12:32 ` [PATCH 1/2] mci: rockchip-dwcmshc-sdhci: " Rouven Czerwinski
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-03-28 10:10 UTC (permalink / raw)
  To: Barebox List

We have sdhci_reset(), use it instead of open coded variant in the
driver.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/arasan-sdhci.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/mci/arasan-sdhci.c b/drivers/mci/arasan-sdhci.c
index 650de22b69..0b839ee7dc 100644
--- a/drivers/mci/arasan-sdhci.c
+++ b/drivers/mci/arasan-sdhci.c
@@ -73,14 +73,11 @@ static int arasan_sdhci_card_write_protected(struct mci_host *mci)
 
 static int arasan_sdhci_reset(struct arasan_sdhci_host *host, u8 mask)
 {
-	sdhci_write8(&host->sdhci, SDHCI_SOFTWARE_RESET, mask);
+	int ret;
 
-	/* wait for reset completion */
-	if (wait_on_timeout(100 * MSECOND,
-			    !(sdhci_read8(&host->sdhci, SDHCI_SOFTWARE_RESET) & mask))) {
-		dev_err(host->mci.hw_dev, "SDHCI reset timeout\n");
-		return -ETIMEDOUT;
-	}
+	ret = sdhci_reset(&host->sdhci, mask);
+	if (ret)
+		return ret;
 
 	if (host->quirks & SDHCI_ARASAN_QUIRK_FORCE_CDTEST) {
 		u8 ctrl;
@@ -199,8 +196,8 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 error:
 	if (ret) {
 		print_error(host, cmd->cmdidx, ret);
-		arasan_sdhci_reset(host, BIT(1)); // SDHCI_RESET_CMD
-		arasan_sdhci_reset(host, BIT(2)); // SDHCI_RESET_DATA
+		arasan_sdhci_reset(host, SDHCI_RESET_CMD);
+		arasan_sdhci_reset(host, SDHCI_RESET_DATA);
 	}
 
 	sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, ~0);
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] mci: rockchip-dwcmshc-sdhci: use sdhci_reset()
  2023-03-28 10:10 [PATCH 1/2] mci: rockchip-dwcmshc-sdhci: use sdhci_reset() Sascha Hauer
  2023-03-28 10:10 ` [PATCH 2/2] mci: arasan: " Sascha Hauer
@ 2023-03-28 12:32 ` Rouven Czerwinski
  1 sibling, 0 replies; 3+ messages in thread
From: Rouven Czerwinski @ 2023-03-28 12:32 UTC (permalink / raw)
  To: Sascha Hauer, Barebox List

Hi,

On Tue, 2023-03-28 at 12:10 +0200, Sascha Hauer wrote:
> We have sdhci_reset() which does the same as the driver specific
> variant. Use the common function instead.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

this is:

Tested-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> ---
>  drivers/mci/rockchip-dwcmshc-sdhci.c | 20 +++-----------------
>  1 file changed, 3 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/mci/rockchip-dwcmshc-sdhci.c
> b/drivers/mci/rockchip-dwcmshc-sdhci.c
> index a98600cc4c..e1eb4fc788 100644
> --- a/drivers/mci/rockchip-dwcmshc-sdhci.c
> +++ b/drivers/mci/rockchip-dwcmshc-sdhci.c
> @@ -87,26 +87,12 @@ static int rk_sdhci_card_present(struct mci_host
> *mci)
>         return !!(sdhci_read32(&host->sdhci, SDHCI_PRESENT_STATE) &
> SDHCI_CARD_DETECT);
>  }
>  
> -static int rk_sdhci_reset(struct rk_sdhci_host *host, u8 mask)
> -{
> -       sdhci_write8(&host->sdhci, SDHCI_SOFTWARE_RESET, mask);
> -
> -       /* wait for reset completion */
> -       if (wait_on_timeout(100 * MSECOND,
> -                       !(sdhci_read8(&host->sdhci,
> SDHCI_SOFTWARE_RESET) & mask))){
> -               dev_err(host->mci.hw_dev, "SDHCI reset timeout\n");
> -               return -ETIMEDOUT;
> -       }
> -
> -       return 0;
> -}
> -
>  static int rk_sdhci_init(struct mci_host *mci, struct device *dev)
>  {
>         struct rk_sdhci_host *host = to_rk_sdhci_host(mci);
>         int ret;
>  
> -       ret = rk_sdhci_reset(host, SDHCI_RESET_ALL);
> +       ret = sdhci_reset(&host->sdhci, SDHCI_RESET_ALL);
>         if (ret)
>                 return ret;
>  
> @@ -274,8 +260,8 @@ static int rk_sdhci_send_cmd(struct mci_host
> *mci, struct mci_cmd *cmd,
>  error:
>         if (ret) {
>                 print_error(host, cmd->cmdidx);
> -               rk_sdhci_reset(host, BIT(1)); /* SDHCI_RESET_CMD */
> -               rk_sdhci_reset(host, BIT(2)); /* SDHCI_RESET_DATA */
> +               sdhci_reset(&host->sdhci, SDHCI_RESET_CMD);
> +               sdhci_reset(&host->sdhci, SDHCI_RESET_DATA);
>         }
>  
>         sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, ~0);


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-28 12:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28 10:10 [PATCH 1/2] mci: rockchip-dwcmshc-sdhci: use sdhci_reset() Sascha Hauer
2023-03-28 10:10 ` [PATCH 2/2] mci: arasan: " Sascha Hauer
2023-03-28 12:32 ` [PATCH 1/2] mci: rockchip-dwcmshc-sdhci: " Rouven Czerwinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox