linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] a few fixes for sprd's sd host controller
@ 2019-08-26  3:18 Chunyan Zhang
  2019-08-26  3:18 ` [PATCH 1/5] mmc: sdhci-sprd: fixed incorrect clock divider Chunyan Zhang
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Chunyan Zhang @ 2019-08-26  3:18 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter, Orson Zhai, Baolin Wang
  Cc: linux-mmc, linux-kernel, Chunyan Zhang

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

With this patch-set, both sd card and mmc can be setup.  This patch-set was
verified on Unisoc's Whale2 and another mobile phone platform SC9863A.

Chunyan Zhang (5):
  mmc: sdhci-sprd: fixed incorrect clock divider
  mmc: sdhci: sprd: add get_ro hook function
  mmc: sdhci: sprd: add SDHCI_QUIRK2_PRESET_VALUE_BROKEN
  mms: sdhci: sprd: add SDHCI_QUIRK_BROKEN_CARD_DETECTION
  mmc: sdhci: sprd: clear the UHS-I modes read from registers

 drivers/mmc/host/sdhci-sprd.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

-- 
2.20.1


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

* [PATCH 1/5] mmc: sdhci-sprd: fixed incorrect clock divider
  2019-08-26  3:18 [PATCH 0/5] a few fixes for sprd's sd host controller Chunyan Zhang
@ 2019-08-26  3:18 ` Chunyan Zhang
  2019-08-26  3:18 ` [PATCH 2/5] mmc: sdhci-sprd: add get_ro hook function Chunyan Zhang
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Chunyan Zhang @ 2019-08-26  3:18 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter, Orson Zhai, Baolin Wang
  Cc: linux-mmc, linux-kernel, Chunyan Zhang

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

The register SDHCI_CLOCK_CONTROL should be cleared before config clock
divider, otherwise the frequency configured maybe lower than we
expected.

Fixes: fb8bd90f83c4 ("mmc: sdhci-sprd: Add Spreadtrum's initial host
controller")
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Signed-off-by: Chunyan Zhang <zhang.lyra@gmail.com>
---
 drivers/mmc/host/sdhci-sprd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index 6ee340a3fb3a..d5871865a1e9 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -217,10 +217,11 @@ static inline void _sdhci_sprd_set_clock(struct sdhci_host *host,
 	struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host);
 	u32 div, val, mask;
 
-	div = sdhci_sprd_calc_div(sprd_host->base_rate, clk);
+	sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
 
-	clk |= ((div & 0x300) >> 2) | ((div & 0xFF) << 8);
-	sdhci_enable_clk(host, clk);
+	div = sdhci_sprd_calc_div(sprd_host->base_rate, clk);
+	div = ((div & 0x300) >> 2) | ((div & 0xFF) << 8);
+	sdhci_enable_clk(host, div);
 
 	/* enable auto gate sdhc_enable_auto_gate */
 	val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
-- 
2.20.1


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

* [PATCH 2/5] mmc: sdhci-sprd: add get_ro hook function
  2019-08-26  3:18 [PATCH 0/5] a few fixes for sprd's sd host controller Chunyan Zhang
  2019-08-26  3:18 ` [PATCH 1/5] mmc: sdhci-sprd: fixed incorrect clock divider Chunyan Zhang
@ 2019-08-26  3:18 ` Chunyan Zhang
  2019-08-26  3:18 ` [PATCH 3/5] mmc: sdhci-sprd: add SDHCI_QUIRK2_PRESET_VALUE_BROKEN Chunyan Zhang
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Chunyan Zhang @ 2019-08-26  3:18 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter, Orson Zhai, Baolin Wang
  Cc: linux-mmc, linux-kernel, Chunyan Zhang

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

sprd's sd host controller doesn't support write protect to sd card.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Signed-off-by: Chunyan Zhang <zhang.lyra@gmail.com>
---
 drivers/mmc/host/sdhci-sprd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index d5871865a1e9..90cb2af91159 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -374,6 +374,11 @@ static unsigned int sdhci_sprd_get_max_timeout_count(struct sdhci_host *host)
 	return 1 << 31;
 }
 
+static unsigned int sdhci_sprd_get_ro(struct sdhci_host *host)
+{
+	return 0;
+}
+
 static struct sdhci_ops sdhci_sprd_ops = {
 	.read_l = sdhci_sprd_readl,
 	.write_l = sdhci_sprd_writel,
@@ -386,6 +391,7 @@ static struct sdhci_ops sdhci_sprd_ops = {
 	.set_uhs_signaling = sdhci_sprd_set_uhs_signaling,
 	.hw_reset = sdhci_sprd_hw_reset,
 	.get_max_timeout_count = sdhci_sprd_get_max_timeout_count,
+	.get_ro = sdhci_sprd_get_ro,
 };
 
 static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq)
-- 
2.20.1


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

* [PATCH 3/5] mmc: sdhci-sprd: add SDHCI_QUIRK2_PRESET_VALUE_BROKEN
  2019-08-26  3:18 [PATCH 0/5] a few fixes for sprd's sd host controller Chunyan Zhang
  2019-08-26  3:18 ` [PATCH 1/5] mmc: sdhci-sprd: fixed incorrect clock divider Chunyan Zhang
  2019-08-26  3:18 ` [PATCH 2/5] mmc: sdhci-sprd: add get_ro hook function Chunyan Zhang
@ 2019-08-26  3:18 ` Chunyan Zhang
  2019-08-26  3:18 ` [PATCH 4/5] mms: sdhci-sprd: add SDHCI_QUIRK_BROKEN_CARD_DETECTION Chunyan Zhang
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Chunyan Zhang @ 2019-08-26  3:18 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter, Orson Zhai, Baolin Wang
  Cc: linux-mmc, linux-kernel, Chunyan Zhang

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

The bit of PRESET_VAL_ENABLE in HOST_CONTROL2 register is reserved on
sprd's sd host controller, set quirk2 to disable configuring this.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Signed-off-by: Chunyan Zhang <zhang.lyra@gmail.com>
---
 drivers/mmc/host/sdhci-sprd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index 90cb2af91159..27d0b57f3f89 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -510,7 +510,8 @@ static void sdhci_sprd_phy_param_parse(struct sdhci_sprd_host *sprd_host,
 static const struct sdhci_pltfm_data sdhci_sprd_pdata = {
 	.quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK,
 	.quirks2 = SDHCI_QUIRK2_BROKEN_HS200 |
-		   SDHCI_QUIRK2_USE_32BIT_BLK_CNT,
+		   SDHCI_QUIRK2_USE_32BIT_BLK_CNT |
+		   SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
 	.ops = &sdhci_sprd_ops,
 };
 
-- 
2.20.1


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

* [PATCH 4/5] mms: sdhci-sprd: add SDHCI_QUIRK_BROKEN_CARD_DETECTION
  2019-08-26  3:18 [PATCH 0/5] a few fixes for sprd's sd host controller Chunyan Zhang
                   ` (2 preceding siblings ...)
  2019-08-26  3:18 ` [PATCH 3/5] mmc: sdhci-sprd: add SDHCI_QUIRK2_PRESET_VALUE_BROKEN Chunyan Zhang
@ 2019-08-26  3:18 ` Chunyan Zhang
  2019-08-26  3:18 ` [PATCH 5/5] mmc: sdhci-sprd: clear the UHS-I modes read from registers Chunyan Zhang
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Chunyan Zhang @ 2019-08-26  3:18 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter, Orson Zhai, Baolin Wang
  Cc: linux-mmc, linux-kernel, Chunyan Zhang

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

sprd's sd host controller doesn't support detection to
card insert or remove.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Signed-off-by: Chunyan Zhang <zhang.lyra@gmail.com>
---
 drivers/mmc/host/sdhci-sprd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index 27d0b57f3f89..1fecf055682c 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -508,7 +508,8 @@ static void sdhci_sprd_phy_param_parse(struct sdhci_sprd_host *sprd_host,
 }
 
 static const struct sdhci_pltfm_data sdhci_sprd_pdata = {
-	.quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK,
+	.quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION |
+		  SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK,
 	.quirks2 = SDHCI_QUIRK2_BROKEN_HS200 |
 		   SDHCI_QUIRK2_USE_32BIT_BLK_CNT |
 		   SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
-- 
2.20.1


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

* [PATCH 5/5] mmc: sdhci-sprd: clear the UHS-I modes read from registers
  2019-08-26  3:18 [PATCH 0/5] a few fixes for sprd's sd host controller Chunyan Zhang
                   ` (3 preceding siblings ...)
  2019-08-26  3:18 ` [PATCH 4/5] mms: sdhci-sprd: add SDHCI_QUIRK_BROKEN_CARD_DETECTION Chunyan Zhang
@ 2019-08-26  3:18 ` Chunyan Zhang
  2019-08-26  5:56 ` [PATCH 0/5] a few fixes for sprd's sd host controller Baolin Wang
  2019-08-27 13:46 ` Ulf Hansson
  6 siblings, 0 replies; 9+ messages in thread
From: Chunyan Zhang @ 2019-08-26  3:18 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter, Orson Zhai, Baolin Wang
  Cc: linux-mmc, linux-kernel, Chunyan Zhang

From: Chunyan Zhang <chunyan.zhang@unisoc.com>

sprd's sd host controller supports SDR50/SDR104/DDR50 though, the UHS-I
mode used by the specific card can be selected via devicetree only.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Signed-off-by: Chunyan Zhang <zhang.lyra@gmail.com>
---
 drivers/mmc/host/sdhci-sprd.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index 1fecf055682c..d3c3e95676f0 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -509,7 +509,8 @@ static void sdhci_sprd_phy_param_parse(struct sdhci_sprd_host *sprd_host,
 
 static const struct sdhci_pltfm_data sdhci_sprd_pdata = {
 	.quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION |
-		  SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK,
+		  SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
+		  SDHCI_QUIRK_MISSING_CAPS,
 	.quirks2 = SDHCI_QUIRK2_BROKEN_HS200 |
 		   SDHCI_QUIRK2_USE_32BIT_BLK_CNT |
 		   SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
@@ -614,6 +615,16 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 
 	sdhci_enable_v4_mode(host);
 
+	/*
+	 * Supply the existing CAPS, but clear the UHS-I modes. This
+	 * will allow these modes to be specified only by device
+	 * tree properties through mmc_of_parse().
+	 */
+	host->caps = sdhci_readl(host, SDHCI_CAPABILITIES);
+	host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
+	host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
+			 SDHCI_SUPPORT_DDR50);
+
 	ret = sdhci_setup_host(host);
 	if (ret)
 		goto pm_runtime_disable;
-- 
2.20.1


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

* Re: [PATCH 0/5] a few fixes for sprd's sd host controller
  2019-08-26  3:18 [PATCH 0/5] a few fixes for sprd's sd host controller Chunyan Zhang
                   ` (4 preceding siblings ...)
  2019-08-26  3:18 ` [PATCH 5/5] mmc: sdhci-sprd: clear the UHS-I modes read from registers Chunyan Zhang
@ 2019-08-26  5:56 ` Baolin Wang
  2019-08-27 13:46 ` Ulf Hansson
  6 siblings, 0 replies; 9+ messages in thread
From: Baolin Wang @ 2019-08-26  5:56 UTC (permalink / raw)
  To: Chunyan Zhang; +Cc: Ulf Hansson, Adrian Hunter, Orson Zhai, linux-mmc, LKML

On Mon, 26 Aug 2019 at 11:18, Chunyan Zhang <zhang.lyra@gmail.com> wrote:
>
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
>
> With this patch-set, both sd card and mmc can be setup.  This patch-set was
> verified on Unisoc's Whale2 and another mobile phone platform SC9863A.

Tested on my board, so for the whole patch set.
Reviewed-by: Baolin Wang <baolin.wang@linaro.org>
Tested-by: Baolin Wang <baolin.wang@linaro.org>

> Chunyan Zhang (5):
>   mmc: sdhci-sprd: fixed incorrect clock divider
>   mmc: sdhci: sprd: add get_ro hook function
>   mmc: sdhci: sprd: add SDHCI_QUIRK2_PRESET_VALUE_BROKEN
>   mms: sdhci: sprd: add SDHCI_QUIRK_BROKEN_CARD_DETECTION
>   mmc: sdhci: sprd: clear the UHS-I modes read from registers
>
>  drivers/mmc/host/sdhci-sprd.c | 30 +++++++++++++++++++++++++-----
>  1 file changed, 25 insertions(+), 5 deletions(-)
>
> --
> 2.20.1
>


-- 
Baolin Wang
Best Regards

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

* Re: [PATCH 0/5] a few fixes for sprd's sd host controller
  2019-08-26  3:18 [PATCH 0/5] a few fixes for sprd's sd host controller Chunyan Zhang
                   ` (5 preceding siblings ...)
  2019-08-26  5:56 ` [PATCH 0/5] a few fixes for sprd's sd host controller Baolin Wang
@ 2019-08-27 13:46 ` Ulf Hansson
  2019-08-28  2:01   ` Chunyan Zhang
  6 siblings, 1 reply; 9+ messages in thread
From: Ulf Hansson @ 2019-08-27 13:46 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: Adrian Hunter, Orson Zhai, Baolin Wang, linux-mmc,
	Linux Kernel Mailing List

On Mon, 26 Aug 2019 at 05:18, Chunyan Zhang <zhang.lyra@gmail.com> wrote:
>
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
>
> With this patch-set, both sd card and mmc can be setup.  This patch-set was
> verified on Unisoc's Whale2 and another mobile phone platform SC9863A.
>
> Chunyan Zhang (5):
>   mmc: sdhci-sprd: fixed incorrect clock divider
>   mmc: sdhci: sprd: add get_ro hook function
>   mmc: sdhci: sprd: add SDHCI_QUIRK2_PRESET_VALUE_BROKEN
>   mms: sdhci: sprd: add SDHCI_QUIRK_BROKEN_CARD_DETECTION
>   mmc: sdhci: sprd: clear the UHS-I modes read from registers
>
>  drivers/mmc/host/sdhci-sprd.c | 30 +++++++++++++++++++++++++-----
>  1 file changed, 25 insertions(+), 5 deletions(-)
>
> --
> 2.20.1
>

Looks like the entire series should be tagged for stable and having
the same fixes tag as patch1. No?

Kind regards
Uffe

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

* Re: [PATCH 0/5] a few fixes for sprd's sd host controller
  2019-08-27 13:46 ` Ulf Hansson
@ 2019-08-28  2:01   ` Chunyan Zhang
  0 siblings, 0 replies; 9+ messages in thread
From: Chunyan Zhang @ 2019-08-28  2:01 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Adrian Hunter, Orson Zhai, Baolin Wang, linux-mmc,
	Linux Kernel Mailing List

On Tue, 27 Aug 2019 at 21:47, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Mon, 26 Aug 2019 at 05:18, Chunyan Zhang <zhang.lyra@gmail.com> wrote:
> >
> > From: Chunyan Zhang <chunyan.zhang@unisoc.com>
> >
> > With this patch-set, both sd card and mmc can be setup.  This patch-set was
> > verified on Unisoc's Whale2 and another mobile phone platform SC9863A.
> >
> > Chunyan Zhang (5):
> >   mmc: sdhci-sprd: fixed incorrect clock divider
> >   mmc: sdhci: sprd: add get_ro hook function
> >   mmc: sdhci: sprd: add SDHCI_QUIRK2_PRESET_VALUE_BROKEN
> >   mms: sdhci: sprd: add SDHCI_QUIRK_BROKEN_CARD_DETECTION
> >   mmc: sdhci: sprd: clear the UHS-I modes read from registers
> >
> >  drivers/mmc/host/sdhci-sprd.c | 30 +++++++++++++++++++++++++-----
> >  1 file changed, 25 insertions(+), 5 deletions(-)
> >
> > --
> > 2.20.1
> >
>
> Looks like the entire series should be tagged for stable and having
> the same fixes tag as patch1. No?

Ok.

>
> Kind regards
> Uffe

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

end of thread, other threads:[~2019-08-28  2:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-26  3:18 [PATCH 0/5] a few fixes for sprd's sd host controller Chunyan Zhang
2019-08-26  3:18 ` [PATCH 1/5] mmc: sdhci-sprd: fixed incorrect clock divider Chunyan Zhang
2019-08-26  3:18 ` [PATCH 2/5] mmc: sdhci-sprd: add get_ro hook function Chunyan Zhang
2019-08-26  3:18 ` [PATCH 3/5] mmc: sdhci-sprd: add SDHCI_QUIRK2_PRESET_VALUE_BROKEN Chunyan Zhang
2019-08-26  3:18 ` [PATCH 4/5] mms: sdhci-sprd: add SDHCI_QUIRK_BROKEN_CARD_DETECTION Chunyan Zhang
2019-08-26  3:18 ` [PATCH 5/5] mmc: sdhci-sprd: clear the UHS-I modes read from registers Chunyan Zhang
2019-08-26  5:56 ` [PATCH 0/5] a few fixes for sprd's sd host controller Baolin Wang
2019-08-27 13:46 ` Ulf Hansson
2019-08-28  2:01   ` Chunyan Zhang

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).