mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] mmc: sdhci-of-arasan: Support for emmc hardware reset
@ 2024-10-07  9:54 Paul Alvin
  2024-10-07 16:34 ` Adrian Hunter
  2024-10-08 14:36 ` Ulf Hansson
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Alvin @ 2024-10-07  9:54 UTC (permalink / raw)
  To: michal.simek, adrian.hunter, ulf.hansson
  Cc: git, alvin.paulp, linux-arm-kernel, linux-mmc, linux-kernel

Add hw_reset callback to support emmc hardware reset, this callback get
called from the mmc core only when "cap-mmc-hw-reset" property is
defined in the DT.

Signed-off-by: Paul Alvin <alvin.paulp@amd.com>
---

Changes in v2:
- Updated the CC list

 drivers/mmc/host/sdhci-of-arasan.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index 5edd024347bd..0cb05bdec34d 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -76,6 +76,8 @@
 #define FREQSEL_225M_200M		0x7
 #define PHY_DLL_TIMEOUT_MS		100
 
+#define SDHCI_HW_RST_EN		BIT(4)
+
 /* Default settings for ZynqMP Clock Phases */
 #define ZYNQMP_ICLK_PHASE {0, 63, 63, 0, 63,  0,   0, 183, 54,  0, 0}
 #define ZYNQMP_OCLK_PHASE {0, 72, 60, 0, 60, 72, 135, 48, 72, 135, 0}
@@ -475,6 +477,21 @@ static void sdhci_arasan_reset(struct sdhci_host *host, u8 mask)
 	}
 }
 
+static void sdhci_arasan_hw_reset(struct sdhci_host *host)
+{
+	u8 reg;
+
+	reg = sdhci_readb(host, SDHCI_POWER_CONTROL);
+	reg |= SDHCI_HW_RST_EN;
+	sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
+	/* As per eMMC spec, minimum 1us is required but give it 2us for good measure */
+	usleep_range(2, 5);
+	reg &= ~SDHCI_HW_RST_EN;
+	sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
+	/* As per eMMC spec, minimum 200us is required but give it 300us for good measure */
+	usleep_range(300, 500);
+}
+
 static int sdhci_arasan_voltage_switch(struct mmc_host *mmc,
 				       struct mmc_ios *ios)
 {
@@ -505,6 +522,7 @@ static const struct sdhci_ops sdhci_arasan_ops = {
 	.reset = sdhci_arasan_reset,
 	.set_uhs_signaling = sdhci_set_uhs_signaling,
 	.set_power = sdhci_set_power_and_bus_voltage,
+	.hw_reset = sdhci_arasan_hw_reset,
 };
 
 static u32 sdhci_arasan_cqhci_irq(struct sdhci_host *host, u32 intmask)
-- 
2.17.1


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

* Re: [PATCH v2] mmc: sdhci-of-arasan: Support for emmc hardware reset
  2024-10-07  9:54 [PATCH v2] mmc: sdhci-of-arasan: Support for emmc hardware reset Paul Alvin
@ 2024-10-07 16:34 ` Adrian Hunter
  2024-10-08 14:36 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Adrian Hunter @ 2024-10-07 16:34 UTC (permalink / raw)
  To: Paul Alvin, michal.simek, ulf.hansson
  Cc: git, linux-arm-kernel, linux-mmc, linux-kernel

On 7/10/24 12:54, Paul Alvin wrote:
> Add hw_reset callback to support emmc hardware reset, this callback get
> called from the mmc core only when "cap-mmc-hw-reset" property is
> defined in the DT.
> 
> Signed-off-by: Paul Alvin <alvin.paulp@amd.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> 
> Changes in v2:
> - Updated the CC list
> 
>  drivers/mmc/host/sdhci-of-arasan.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
> index 5edd024347bd..0cb05bdec34d 100644
> --- a/drivers/mmc/host/sdhci-of-arasan.c
> +++ b/drivers/mmc/host/sdhci-of-arasan.c
> @@ -76,6 +76,8 @@
>  #define FREQSEL_225M_200M		0x7
>  #define PHY_DLL_TIMEOUT_MS		100
>  
> +#define SDHCI_HW_RST_EN		BIT(4)
> +
>  /* Default settings for ZynqMP Clock Phases */
>  #define ZYNQMP_ICLK_PHASE {0, 63, 63, 0, 63,  0,   0, 183, 54,  0, 0}
>  #define ZYNQMP_OCLK_PHASE {0, 72, 60, 0, 60, 72, 135, 48, 72, 135, 0}
> @@ -475,6 +477,21 @@ static void sdhci_arasan_reset(struct sdhci_host *host, u8 mask)
>  	}
>  }
>  
> +static void sdhci_arasan_hw_reset(struct sdhci_host *host)
> +{
> +	u8 reg;
> +
> +	reg = sdhci_readb(host, SDHCI_POWER_CONTROL);
> +	reg |= SDHCI_HW_RST_EN;
> +	sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
> +	/* As per eMMC spec, minimum 1us is required but give it 2us for good measure */
> +	usleep_range(2, 5);
> +	reg &= ~SDHCI_HW_RST_EN;
> +	sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
> +	/* As per eMMC spec, minimum 200us is required but give it 300us for good measure */
> +	usleep_range(300, 500);
> +}
> +
>  static int sdhci_arasan_voltage_switch(struct mmc_host *mmc,
>  				       struct mmc_ios *ios)
>  {
> @@ -505,6 +522,7 @@ static const struct sdhci_ops sdhci_arasan_ops = {
>  	.reset = sdhci_arasan_reset,
>  	.set_uhs_signaling = sdhci_set_uhs_signaling,
>  	.set_power = sdhci_set_power_and_bus_voltage,
> +	.hw_reset = sdhci_arasan_hw_reset,
>  };
>  
>  static u32 sdhci_arasan_cqhci_irq(struct sdhci_host *host, u32 intmask)


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

* Re: [PATCH v2] mmc: sdhci-of-arasan: Support for emmc hardware reset
  2024-10-07  9:54 [PATCH v2] mmc: sdhci-of-arasan: Support for emmc hardware reset Paul Alvin
  2024-10-07 16:34 ` Adrian Hunter
@ 2024-10-08 14:36 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2024-10-08 14:36 UTC (permalink / raw)
  To: Paul Alvin
  Cc: michal.simek, adrian.hunter, git, linux-arm-kernel, linux-mmc,
	linux-kernel

On Mon, 7 Oct 2024 at 11:54, Paul Alvin <alvin.paulp@amd.com> wrote:
>
> Add hw_reset callback to support emmc hardware reset, this callback get
> called from the mmc core only when "cap-mmc-hw-reset" property is
> defined in the DT.
>
> Signed-off-by: Paul Alvin <alvin.paulp@amd.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>
> Changes in v2:
> - Updated the CC list
>
>  drivers/mmc/host/sdhci-of-arasan.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
> index 5edd024347bd..0cb05bdec34d 100644
> --- a/drivers/mmc/host/sdhci-of-arasan.c
> +++ b/drivers/mmc/host/sdhci-of-arasan.c
> @@ -76,6 +76,8 @@
>  #define FREQSEL_225M_200M              0x7
>  #define PHY_DLL_TIMEOUT_MS             100
>
> +#define SDHCI_HW_RST_EN                BIT(4)
> +
>  /* Default settings for ZynqMP Clock Phases */
>  #define ZYNQMP_ICLK_PHASE {0, 63, 63, 0, 63,  0,   0, 183, 54,  0, 0}
>  #define ZYNQMP_OCLK_PHASE {0, 72, 60, 0, 60, 72, 135, 48, 72, 135, 0}
> @@ -475,6 +477,21 @@ static void sdhci_arasan_reset(struct sdhci_host *host, u8 mask)
>         }
>  }
>
> +static void sdhci_arasan_hw_reset(struct sdhci_host *host)
> +{
> +       u8 reg;
> +
> +       reg = sdhci_readb(host, SDHCI_POWER_CONTROL);
> +       reg |= SDHCI_HW_RST_EN;
> +       sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
> +       /* As per eMMC spec, minimum 1us is required but give it 2us for good measure */
> +       usleep_range(2, 5);
> +       reg &= ~SDHCI_HW_RST_EN;
> +       sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
> +       /* As per eMMC spec, minimum 200us is required but give it 300us for good measure */
> +       usleep_range(300, 500);
> +}
> +
>  static int sdhci_arasan_voltage_switch(struct mmc_host *mmc,
>                                        struct mmc_ios *ios)
>  {
> @@ -505,6 +522,7 @@ static const struct sdhci_ops sdhci_arasan_ops = {
>         .reset = sdhci_arasan_reset,
>         .set_uhs_signaling = sdhci_set_uhs_signaling,
>         .set_power = sdhci_set_power_and_bus_voltage,
> +       .hw_reset = sdhci_arasan_hw_reset,
>  };
>
>  static u32 sdhci_arasan_cqhci_irq(struct sdhci_host *host, u32 intmask)
> --
> 2.17.1
>

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

end of thread, other threads:[~2024-10-08 14:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-07  9:54 [PATCH v2] mmc: sdhci-of-arasan: Support for emmc hardware reset Paul Alvin
2024-10-07 16:34 ` Adrian Hunter
2024-10-08 14:36 ` Ulf Hansson

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

all inboxes | Powered by JetHome®