linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] Add enhanced strobe support for emmc version 5.1 or later
@ 2016-03-03  2:35 Shawn Lin
  2016-03-03  2:36 ` [RFC PATCH 1/4] mmc: core: add cap-enhanced-strobe support Shawn Lin
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Shawn Lin @ 2016-03-03  2:35 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson
  Cc: Michal Simek, soren.brinkmann, linux-mmc, linux-kernel, Shawn Lin


Hello Ulf and Adrian,

This RFC patch is going to support enhanced strobe function
for emmc version 5.1+ introduced by JEDEC recently.

Firstly,from the former discussion of sdhci, I write these code
inspired by Adrian's patch[0] for variant drivers to overwrite the
callback in order not to add new callback into sdhci. And enchanced
strobe is a optional function, so we add a new cap* for drivers to
decide whether to use it.

1. History
   When introduing hs400 mode, JEDEC asks controllers to use data strobe line
to latch the data from emmc devives. But for cmd-reponse, not mentioned yet.
Since emmc version 5.1 published, JEDEC adds enhanced strobe function to deal
with cmd-response the same way as dara-read. This feature is optional.

2. Current situation
   I can't find a upstreamed controller claimed to support it, as well as the
mmc stack. But my "arasan,sdhci-5.1" actially supports this function. So I decide
to work for this part.

3. About the code
   1)This patchset is taken from Yi Sun's patch[1], but after reviewing the details
and applying to test, I find some problems. We ask devices to switch to enhanced
strobe mode, but we don't notify drivers to enable enhanced strobe mode. And we can't
force controller to use enhanced strobe even if devices claims to support it. So I
rework most of the code and take over the ownership from Yi Sun(If any objections
here, please let know).
   2)By looking into the SDHCI spec, I find there isn't any registers to enable the
enhanced strobe function. But from my "arasan,sdhci-5.1" databook, it describes a
register called VENDOR_REGISTER(0x78) to trigger this mode. So I guess other sdhci
variant drivers may also need s vendor specific register to deal with it.

4. Howto
   If we are sure that our controller supports enhanced strobe mode, just add
cap-enhanced-strobe in DT. Once emmc devices claims to support this mode,
we enable it automatically. Of course, other sdhci*/non-sdhci drivers should
implement/overwrite the prepare_enhanced_strobe by themselves. I believe all of the
platforms which need to support this mode should do some basic preparation for their
controllers.

Reference:
[0]: https://patchwork.kernel.org/patch/8262231/
[1]: https://patchwork.kernel.org/patch/6545421/



Shawn Lin (4):
  mmc: core: add cap-enhanced-strobe support
  mmc: core: implement enhanced strobe support
  mmc: sdhci: implement enhanced strobe callback
  mmc: sdhci-of-arasan: overwrite enhanced strobe callback

 Documentation/devicetree/bindings/mmc/mmc.txt |  1 +
 drivers/mmc/core/host.c                       |  2 +
 drivers/mmc/core/mmc.c                        | 54 ++++++++++++++++++++++++++-
 drivers/mmc/host/sdhci-of-arasan.c            | 20 ++++++++++
 drivers/mmc/host/sdhci.c                      | 11 ++++++
 include/linux/mmc/card.h                      |  1 +
 include/linux/mmc/host.h                      |  8 ++++
 include/linux/mmc/mmc.h                       |  2 +
 8 files changed, 98 insertions(+), 1 deletion(-)

-- 
2.3.7

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

* [RFC PATCH 1/4] mmc: core: add cap-enhanced-strobe support
  2016-03-03  2:35 [RFC PATCH 0/4] Add enhanced strobe support for emmc version 5.1 or later Shawn Lin
@ 2016-03-03  2:36 ` Shawn Lin
  2016-03-03 12:08   ` Jaehoon Chung
  2016-03-03  2:36 ` [RFC PATCH 2/4] mmc: core: implement enhanced strobe support Shawn Lin
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Shawn Lin @ 2016-03-03  2:36 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson
  Cc: Michal Simek, soren.brinkmann, linux-mmc, linux-kernel, Shawn Lin

This patch introduce cap-enhanced-strobe for platforms which
want to enable enhanced strobe function from DT if the mmc host
controller claims to support enhanced strobe.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

---

 Documentation/devicetree/bindings/mmc/mmc.txt | 1 +
 drivers/mmc/core/host.c                       | 2 ++
 include/linux/mmc/host.h                      | 6 ++++++
 3 files changed, 9 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt
index ed23b9b..51ec979 100644
--- a/Documentation/devicetree/bindings/mmc/mmc.txt
+++ b/Documentation/devicetree/bindings/mmc/mmc.txt
@@ -39,6 +39,7 @@ Optional properties:
 - cap-power-off-card: powering off the card is safe
 - cap-mmc-hw-reset: eMMC hardware reset is supported
 - cap-sdio-irq: enable SDIO IRQ signalling on this interface
+- cap-enhanced-strobe: enable enhanced strobe function for emmc v5.1+
 - full-pwr-cycle: full power cycle of the card is supported
 - mmc-ddr-1_8v: eMMC high-speed DDR mode(1.8V I/O) is supported
 - mmc-ddr-1_2v: eMMC high-speed DDR mode(1.2V I/O) is supported
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 1d94607..b49d786 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -270,6 +270,8 @@ int mmc_of_parse(struct mmc_host *host)
 		host->caps |= MMC_CAP_HW_RESET;
 	if (of_property_read_bool(np, "cap-sdio-irq"))
 		host->caps |= MMC_CAP_SDIO_IRQ;
+	if (of_property_read_bool(np, "cap-enhanced-strobe"))
+		host->caps |= MMC_CAP_ENHANCED_STROBE;
 	if (of_property_read_bool(np, "full-pwr-cycle"))
 		host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE;
 	if (of_property_read_bool(np, "keep-power-in-suspend"))
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 8dd4d29..2a292b3 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -264,6 +264,7 @@ struct mmc_host {
 #define MMC_CAP_DRIVER_TYPE_A	(1 << 23)	/* Host supports Driver Type A */
 #define MMC_CAP_DRIVER_TYPE_C	(1 << 24)	/* Host supports Driver Type C */
 #define MMC_CAP_DRIVER_TYPE_D	(1 << 25)	/* Host supports Driver Type D */
+#define MMC_CAP_ENHANCED_STROBE	(1 << 20)	/* Host supports enhanced strobe */
 #define MMC_CAP_CMD23		(1 << 30)	/* CMD23 supported. */
 #define MMC_CAP_HW_RESET	(1 << 31)	/* Hardware reset */
 
@@ -469,6 +470,11 @@ static inline int mmc_host_uhs(struct mmc_host *host)
 		 MMC_CAP_UHS_DDR50);
 }
 
+static inline int mmc_host_enhanced_strobe(struct mmc_host *host)
+{
+	return host->caps & MMC_CAP_ENHANCED_STROBE;
+}
+
 static inline int mmc_host_packed_wr(struct mmc_host *host)
 {
 	return host->caps2 & MMC_CAP2_PACKED_WR;
-- 
2.3.7

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

* [RFC PATCH 2/4] mmc: core: implement enhanced strobe support
  2016-03-03  2:35 [RFC PATCH 0/4] Add enhanced strobe support for emmc version 5.1 or later Shawn Lin
  2016-03-03  2:36 ` [RFC PATCH 1/4] mmc: core: add cap-enhanced-strobe support Shawn Lin
@ 2016-03-03  2:36 ` Shawn Lin
  2016-03-03 13:37   ` Adrian Hunter
  2016-03-03  2:36 ` [RFC PATCH 3/4] mmc: sdhci: implement enhanced strobe callback Shawn Lin
  2016-03-03  2:36 ` [RFC PATCH 4/4] mmc: sdhci-of-arasan: overwrite " Shawn Lin
  3 siblings, 1 reply; 11+ messages in thread
From: Shawn Lin @ 2016-03-03  2:36 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson
  Cc: Michal Simek, soren.brinkmann, linux-mmc, linux-kernel, Shawn Lin

Controllers use data strobe line to latch data from devices
under hs400 mode, but not for cmd line. So from emmc 5.1, JEDEC
introduces enhanced strobe mode for latching cmd response from
emmc devices to host controllers. This new feature is optional.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/core/mmc.c   | 54 +++++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/mmc/card.h |  1 +
 include/linux/mmc/host.h |  2 ++
 include/linux/mmc/mmc.h  |  2 ++
 4 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 4dbe3df..701ab27 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -585,6 +585,12 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
 		card->ext_csd.ffu_capable =
 			(ext_csd[EXT_CSD_SUPPORTED_MODE] & 0x1) &&
 			!(ext_csd[EXT_CSD_FW_CONFIG] & 0x1);
+		/*
+		* Enhance Strobe is supported since v5.1 which rev should be
+		* 8 but some eMMC devices can support it with rev 7. So handle
+		* Enhance Strobe here.
+		*/
+		card->ext_csd.strobe_support = ext_csd[EXT_CSD_STROBE_SUPPORT];
 	}
 out:
 	return err;
@@ -1097,9 +1103,26 @@ static int mmc_select_hs400(struct mmc_card *card)
 	}
 
 	/* Switch card to DDR */
+	val = EXT_CSD_DDR_BUS_WIDTH_8;
+	if (card->ext_csd.strobe_support && mmc_host_enhanced_strobe(host)) {
+		val |= EXT_CSD_BUS_WIDTH_STROBE;
+		/*
+		* Make sure we are in non-enhanced strobe mode before we
+		* actually enable it in ext_csd.
+		*/
+		if (host->ops->prepare_enhanced_strobe)
+			err = host->ops->prepare_enhanced_strobe(host, false);
+
+		if (err) {
+			pr_err("%s: unprepare_enhanced strobe failed, err:%d\n",
+				mmc_hostname(host), err);
+			return err;
+		}
+	}
+
 	err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
 			 EXT_CSD_BUS_WIDTH,
-			 EXT_CSD_DDR_BUS_WIDTH_8,
+			 val,
 			 card->ext_csd.generic_cmd6_time);
 	if (err) {
 		pr_err("%s: switch to bus width for hs400 failed, err:%d\n",
@@ -1107,6 +1130,35 @@ static int mmc_select_hs400(struct mmc_card *card)
 		return err;
 	}
 
+	if (card->ext_csd.strobe_support && mmc_host_enhanced_strobe(host)) {
+		/* Controller enable enhanced strobe function */
+		if (host->ops->prepare_enhanced_strobe)
+			err = host->ops->prepare_enhanced_strobe(host, true);
+
+		if (err) {
+			pr_err("%s: prepare enhanced strobe failed, err:%d\n",
+				mmc_hostname(host), err);
+			return err;
+		}
+
+		mmc_set_bus_width(host, MMC_BUS_WIDTH_8);
+		/*
+		 * If controller can't handle bus width test,
+		 * compare ext_csd previously read in 1 bit mode
+		 * against ext_csd at new bus width
+		 */
+		if (!(host->caps & MMC_CAP_BUS_WIDTH_TEST))
+			err = mmc_compare_ext_csds(card, MMC_BUS_WIDTH_8);
+		else
+			err = mmc_bus_test(card, MMC_BUS_WIDTH_8);
+
+		if (err) {
+			pr_warn("%s: switch to enhanced strobe failed\n",
+				mmc_hostname(host));
+			return err;
+		}
+	}
+
 	/* Switch card to HS400 */
 	val = EXT_CSD_TIMING_HS400 |
 	      card->drive_strength << EXT_CSD_DRV_STR_SHIFT;
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index eb0151b..22defc2 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -95,6 +95,7 @@ struct mmc_ext_csd {
 	u8			raw_partition_support;	/* 160 */
 	u8			raw_rpmb_size_mult;	/* 168 */
 	u8			raw_erased_mem_count;	/* 181 */
+	u8			strobe_support;		/* 184 */
 	u8			raw_ext_csd_structure;	/* 194 */
 	u8			raw_card_type;		/* 196 */
 	u8			raw_driver_strength;	/* 197 */
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 2a292b3..8ef3bde 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -132,6 +132,8 @@ struct mmc_host_ops {
 
 	/* Prepare HS400 target operating frequency depending host driver */
 	int	(*prepare_hs400_tuning)(struct mmc_host *host, struct mmc_ios *ios);
+	/* Prepare enhanced strobe depending host driver */
+	int	(*prepare_enhanced_strobe)(struct mmc_host *host, bool enable);
 	int	(*select_drive_strength)(struct mmc_card *card,
 					 unsigned int max_dtr, int host_drv,
 					 int card_drv, int *drv_type);
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 15f2c4a..593c605 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -297,6 +297,7 @@ struct _mmc_csd {
 #define EXT_CSD_PART_CONFIG		179	/* R/W */
 #define EXT_CSD_ERASED_MEM_CONT		181	/* RO */
 #define EXT_CSD_BUS_WIDTH		183	/* R/W */
+#define EXT_CSD_STROBE_SUPPORT		184	/* RO */
 #define EXT_CSD_HS_TIMING		185	/* R/W */
 #define EXT_CSD_POWER_CLASS		187	/* R/W */
 #define EXT_CSD_REV			192	/* RO */
@@ -386,6 +387,7 @@ struct _mmc_csd {
 #define EXT_CSD_BUS_WIDTH_8	2	/* Card is in 8 bit mode */
 #define EXT_CSD_DDR_BUS_WIDTH_4	5	/* Card is in 4 bit DDR mode */
 #define EXT_CSD_DDR_BUS_WIDTH_8	6	/* Card is in 8 bit DDR mode */
+#define EXT_CSD_BUS_WIDTH_STROBE BIT(7)	/* Enhanced strobe mode */
 
 #define EXT_CSD_TIMING_BC	0	/* Backwards compatility */
 #define EXT_CSD_TIMING_HS	1	/* High speed */
-- 
2.3.7

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

* [RFC PATCH 3/4] mmc: sdhci: implement enhanced strobe callback
  2016-03-03  2:35 [RFC PATCH 0/4] Add enhanced strobe support for emmc version 5.1 or later Shawn Lin
  2016-03-03  2:36 ` [RFC PATCH 1/4] mmc: core: add cap-enhanced-strobe support Shawn Lin
  2016-03-03  2:36 ` [RFC PATCH 2/4] mmc: core: implement enhanced strobe support Shawn Lin
@ 2016-03-03  2:36 ` Shawn Lin
  2016-03-03  2:36 ` [RFC PATCH 4/4] mmc: sdhci-of-arasan: overwrite " Shawn Lin
  3 siblings, 0 replies; 11+ messages in thread
From: Shawn Lin @ 2016-03-03  2:36 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson
  Cc: Michal Simek, soren.brinkmann, linux-mmc, linux-kernel, Shawn Lin

Enhanced strobe stuff currently is beyond the scope
of Secure Digital Host Controller Interface. So we can't
find a register here to enable/disable it. We experct
variant drivers to finish the details according to their
vendor settings.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/host/sdhci.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 03fbb36..61a1af1 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2007,6 +2007,16 @@ out_unlock:
 	return err;
 }
 
+static int sdhci_prepare_enhanced_strobe(struct mmc_host *mmc, bool enable)
+{
+	/*
+	* Currently we can't find a register to enable enhanced strobe
+	* function for standard sdhci, so we expect variant drivers to
+	* overwrite it.
+	*/
+	return -EINVAL;
+}
+
 static int sdhci_select_drive_strength(struct mmc_card *card,
 				       unsigned int max_dtr, int host_drv,
 				       int card_drv, int *drv_type)
@@ -2116,6 +2126,7 @@ static const struct mmc_host_ops sdhci_ops = {
 	.enable_sdio_irq = sdhci_enable_sdio_irq,
 	.start_signal_voltage_switch	= sdhci_start_signal_voltage_switch,
 	.prepare_hs400_tuning		= sdhci_prepare_hs400_tuning,
+	.prepare_enhanced_strobe	= sdhci_prepare_enhanced_strobe,
 	.execute_tuning			= sdhci_execute_tuning,
 	.select_drive_strength		= sdhci_select_drive_strength,
 	.card_event			= sdhci_card_event,
-- 
2.3.7

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

* [RFC PATCH 4/4] mmc: sdhci-of-arasan: overwrite enhanced strobe callback
  2016-03-03  2:35 [RFC PATCH 0/4] Add enhanced strobe support for emmc version 5.1 or later Shawn Lin
                   ` (2 preceding siblings ...)
  2016-03-03  2:36 ` [RFC PATCH 3/4] mmc: sdhci: implement enhanced strobe callback Shawn Lin
@ 2016-03-03  2:36 ` Shawn Lin
  2016-03-03 11:02   ` Michal Simek
  3 siblings, 1 reply; 11+ messages in thread
From: Shawn Lin @ 2016-03-03  2:36 UTC (permalink / raw)
  To: Adrian Hunter, Ulf Hansson
  Cc: Michal Simek, soren.brinkmann, linux-mmc, linux-kernel, Shawn Lin

Currently sdhci-arasan 5.1 can support enhanced strobe function,
but considering the potential requirement in the future for other
version IP, we don't limit it just for "arasan,sdhci-5.1". Add
cap-enhanced-strobe in DT to enable the function if we'r sure our
controller can support it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

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

diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index 1e4b5e0..31f3494 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -24,7 +24,9 @@
 #include "sdhci-pltfm.h"
 
 #define SDHCI_ARASAN_CLK_CTRL_OFFSET	0x2c
+#define SDHCI_ARASAN_VENDOR_REGISTER	0x78
 
+#define VENDOR_ENHANCED_STROBE		BIT(0)
 #define CLK_CTRL_TIMEOUT_SHIFT		16
 #define CLK_CTRL_TIMEOUT_MASK		(0xf << CLK_CTRL_TIMEOUT_SHIFT)
 #define CLK_CTRL_TIMEOUT_MIN_EXP	13
@@ -52,6 +54,21 @@ static unsigned int sdhci_arasan_get_timeout_clock(struct sdhci_host *host)
 	return freq;
 }
 
+static int sdhci_arasan_enhanced_strobe(struct sdhci_host *host, bool enable)
+{
+	u32 vendor;
+
+	vendor = readl(host->ioaddr + SDHCI_ARASAN_VENDOR_REGISTER);
+	if (enable)
+		vendor |= VENDOR_ENHANCED_STROBE;
+	else
+		vendor &= (~VENDOR_ENHANCED_STROBE);
+
+	writel(vendor, host->ioaddr + SDHCI_ARASAN_VENDOR_REGISTER);
+
+	return 0;
+}
+
 static struct sdhci_ops sdhci_arasan_ops = {
 	.set_clock = sdhci_set_clock,
 	.get_max_clock = sdhci_pltfm_clk_get_max_clock,
@@ -172,6 +189,9 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
 	sdhci_get_of_property(pdev);
 	pltfm_host->clk = clk_xin;
 
+	host->mmc_host_ops.prepare_enhanced_strobe =
+					sdhci_arasan_enhanced_strobe;
+
 	ret = mmc_of_parse(host->mmc);
 	if (ret) {
 		dev_err(&pdev->dev, "parsing dt failed (%u)\n", ret);
-- 
2.3.7

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

* Re: [RFC PATCH 4/4] mmc: sdhci-of-arasan: overwrite enhanced strobe callback
  2016-03-03  2:36 ` [RFC PATCH 4/4] mmc: sdhci-of-arasan: overwrite " Shawn Lin
@ 2016-03-03 11:02   ` Michal Simek
  2016-03-03 11:37     ` Shawn Lin
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Simek @ 2016-03-03 11:02 UTC (permalink / raw)
  To: Shawn Lin, Adrian Hunter, Ulf Hansson
  Cc: Michal Simek, soren.brinkmann, linux-mmc, linux-kernel

On 3.3.2016 03:36, Shawn Lin wrote:
> Currently sdhci-arasan 5.1 can support enhanced strobe function,
> but considering the potential requirement in the future for other
> version IP, we don't limit it just for "arasan,sdhci-5.1". Add
> cap-enhanced-strobe in DT to enable the function if we'r sure our
> controller can support it.
> 
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
> 
>  drivers/mmc/host/sdhci-of-arasan.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
> index 1e4b5e0..31f3494 100644
> --- a/drivers/mmc/host/sdhci-of-arasan.c
> +++ b/drivers/mmc/host/sdhci-of-arasan.c
> @@ -24,7 +24,9 @@
>  #include "sdhci-pltfm.h"
>  
>  #define SDHCI_ARASAN_CLK_CTRL_OFFSET	0x2c
> +#define SDHCI_ARASAN_VENDOR_REGISTER	0x78

I was checking our register map and we even don't have this register
listed as reserved.
It looks like that this will be related to certain SoC and different SoC
can use it different location.
That's why I think this feature and setup should be related to certain
SoC specific compatible string.

Thanks,
Michal

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

* Re: [RFC PATCH 4/4] mmc: sdhci-of-arasan: overwrite enhanced strobe callback
  2016-03-03 11:02   ` Michal Simek
@ 2016-03-03 11:37     ` Shawn Lin
  0 siblings, 0 replies; 11+ messages in thread
From: Shawn Lin @ 2016-03-03 11:37 UTC (permalink / raw)
  To: Michal Simek, Adrian Hunter, Ulf Hansson
  Cc: shawn.lin, shawn.lin, soren.brinkmann, linux-mmc, linux-kernel

On 2016/3/3 19:02, Michal Simek wrote:
> On 3.3.2016 03:36, Shawn Lin wrote:
>> Currently sdhci-arasan 5.1 can support enhanced strobe function,
>> but considering the potential requirement in the future for other
>> version IP, we don't limit it just for "arasan,sdhci-5.1". Add
>> cap-enhanced-strobe in DT to enable the function if we'r sure our
>> controller can support it.
>>
>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>> ---
>>
>>   drivers/mmc/host/sdhci-of-arasan.c | 20 ++++++++++++++++++++
>>   1 file changed, 20 insertions(+)
>>
>> diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
>> index 1e4b5e0..31f3494 100644
>> --- a/drivers/mmc/host/sdhci-of-arasan.c
>> +++ b/drivers/mmc/host/sdhci-of-arasan.c
>> @@ -24,7 +24,9 @@
>>   #include "sdhci-pltfm.h"
>>
>>   #define SDHCI_ARASAN_CLK_CTRL_OFFSET	0x2c
>> +#define SDHCI_ARASAN_VENDOR_REGISTER	0x78
>
> I was checking our register map and we even don't have this register
> listed as reserved.
> It looks like that this will be related to certain SoC and different SoC
> can use it different location.
> That's why I think this feature and setup should be related to certain
> SoC specific compatible string.

Hi Michal,

I think that is IP version specific because it's inside controller's
databook. But I only have a datasheet released by arasan for 5.1 
controller, so I didn't know if your databook has this register. And
I can't find sdhci spec has a reg to enable this feature either. Looks
strange, but maybe you are right: it also related to certain Soc for
other sdhci variant drivers. But for sdhci-of-arsan, it more likes to
use this register from now on for the future IP version to enable this
feature inside the controller register-range.

Thanks for checking that. Now, I'm more sure about that we should limit
it for 5.1 currently by checking the compatible string.

I expect more comments from ulf and adrian about the other part of code
until I respin the next version.

>
> Thanks,
> Michal
>
>
>
>


-- 
Best Regards
Shawn Lin

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

* Re: [RFC PATCH 1/4] mmc: core: add cap-enhanced-strobe support
  2016-03-03  2:36 ` [RFC PATCH 1/4] mmc: core: add cap-enhanced-strobe support Shawn Lin
@ 2016-03-03 12:08   ` Jaehoon Chung
  2016-03-04  1:39     ` Shawn Lin
  0 siblings, 1 reply; 11+ messages in thread
From: Jaehoon Chung @ 2016-03-03 12:08 UTC (permalink / raw)
  To: Shawn Lin, Adrian Hunter, Ulf Hansson
  Cc: Michal Simek, soren.brinkmann, linux-mmc, linux-kernel

Hi Shawn,

On 03/03/2016 11:36 AM, Shawn Lin wrote:
> This patch introduce cap-enhanced-strobe for platforms which
> want to enable enhanced strobe function from DT if the mmc host
> controller claims to support enhanced strobe.

I don't know why need to add the capability and property.

> 
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> 
> ---
> 
>  Documentation/devicetree/bindings/mmc/mmc.txt | 1 +
>  drivers/mmc/core/host.c                       | 2 ++
>  include/linux/mmc/host.h                      | 6 ++++++
>  3 files changed, 9 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt
> index ed23b9b..51ec979 100644
> --- a/Documentation/devicetree/bindings/mmc/mmc.txt
> +++ b/Documentation/devicetree/bindings/mmc/mmc.txt
> @@ -39,6 +39,7 @@ Optional properties:
>  - cap-power-off-card: powering off the card is safe
>  - cap-mmc-hw-reset: eMMC hardware reset is supported
>  - cap-sdio-irq: enable SDIO IRQ signalling on this interface
> +- cap-enhanced-strobe: enable enhanced strobe function for emmc v5.1+
>  - full-pwr-cycle: full power cycle of the card is supported
>  - mmc-ddr-1_8v: eMMC high-speed DDR mode(1.8V I/O) is supported
>  - mmc-ddr-1_2v: eMMC high-speed DDR mode(1.2V I/O) is supported
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 1d94607..b49d786 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -270,6 +270,8 @@ int mmc_of_parse(struct mmc_host *host)
>  		host->caps |= MMC_CAP_HW_RESET;
>  	if (of_property_read_bool(np, "cap-sdio-irq"))
>  		host->caps |= MMC_CAP_SDIO_IRQ;
> +	if (of_property_read_bool(np, "cap-enhanced-strobe"))
> +		host->caps |= MMC_CAP_ENHANCED_STROBE;
>  	if (of_property_read_bool(np, "full-pwr-cycle"))
>  		host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE;
>  	if (of_property_read_bool(np, "keep-power-in-suspend"))
> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> index 8dd4d29..2a292b3 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -264,6 +264,7 @@ struct mmc_host {
>  #define MMC_CAP_DRIVER_TYPE_A	(1 << 23)	/* Host supports Driver Type A */
>  #define MMC_CAP_DRIVER_TYPE_C	(1 << 24)	/* Host supports Driver Type C */
>  #define MMC_CAP_DRIVER_TYPE_D	(1 << 25)	/* Host supports Driver Type D */
> +#define MMC_CAP_ENHANCED_STROBE	(1 << 20)	/* Host supports enhanced strobe */

Need to fix ordering.

>  #define MMC_CAP_CMD23		(1 << 30)	/* CMD23 supported. */
>  #define MMC_CAP_HW_RESET	(1 << 31)	/* Hardware reset */
>  
> @@ -469,6 +470,11 @@ static inline int mmc_host_uhs(struct mmc_host *host)
>  		 MMC_CAP_UHS_DDR50);
>  }
>  
> +static inline int mmc_host_enhanced_strobe(struct mmc_host *host)
> +{
> +	return host->caps & MMC_CAP_ENHANCED_STROBE;
> +}
> +
>  static inline int mmc_host_packed_wr(struct mmc_host *host)
>  {
>  	return host->caps2 & MMC_CAP2_PACKED_WR;
> 

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

* Re: [RFC PATCH 2/4] mmc: core: implement enhanced strobe support
  2016-03-03  2:36 ` [RFC PATCH 2/4] mmc: core: implement enhanced strobe support Shawn Lin
@ 2016-03-03 13:37   ` Adrian Hunter
  2016-03-04  2:00     ` Shawn Lin
  0 siblings, 1 reply; 11+ messages in thread
From: Adrian Hunter @ 2016-03-03 13:37 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Ulf Hansson, Michal Simek, soren.brinkmann, linux-mmc, linux-kernel

On 03/03/16 04:36, Shawn Lin wrote:
> Controllers use data strobe line to latch data from devices
> under hs400 mode, but not for cmd line. So from emmc 5.1, JEDEC
> introduces enhanced strobe mode for latching cmd response from
> emmc devices to host controllers. This new feature is optional.

As I currently understand it, HS400ES does not require tuning.
Consequently you can go straight to HS400ES and do not need to do
HS200 first.  If that is the case then more changes are needed.

Also it would be nice if the transfer mode displayed reflected enhanced
strobe e.g.

	Currently

		mmc1: new HS400 MMC card at address 0001

	Change for enhance strobe supported

		mmc1: new HS400ES MMC card at address 0001

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

* Re: [RFC PATCH 1/4] mmc: core: add cap-enhanced-strobe support
  2016-03-03 12:08   ` Jaehoon Chung
@ 2016-03-04  1:39     ` Shawn Lin
  0 siblings, 0 replies; 11+ messages in thread
From: Shawn Lin @ 2016-03-04  1:39 UTC (permalink / raw)
  To: Jaehoon Chung, Shawn Lin, Adrian Hunter, Ulf Hansson
  Cc: Michal Simek, soren.brinkmann, linux-mmc, linux-kernel

Hi Jaehoon,

On 2016/3/3 20:08, Jaehoon Chung wrote:
> Hi Shawn,
>
> On 03/03/2016 11:36 AM, Shawn Lin wrote:
>> This patch introduce cap-enhanced-strobe for platforms which
>> want to enable enhanced strobe function from DT if the mmc host
>> controller claims to support enhanced strobe.
>
> I don't know why need to add the capability and property.
>

 From my point, HS400-ES is a optional feature, so we should leave it
for people to decide whether to use it. Just as my controller supports 
hs400, but I can't force all the people using my platform to use hs400?
That's why we add mmc-hs400-* in DT.

But maybe I can change the name to mmc-hs400es-* ?


[...]

>>   #define MMC_CAP_DRIVER_TYPE_A	(1 << 23)	/* Host supports Driver Type A */
>>   #define MMC_CAP_DRIVER_TYPE_C	(1 << 24)	/* Host supports Driver Type C */
>>   #define MMC_CAP_DRIVER_TYPE_D	(1 << 25)	/* Host supports Driver Type D */
>> +#define MMC_CAP_ENHANCED_STROBE	(1 << 20)	/* Host supports enhanced strobe */
>
> Need to fix ordering.

yeah~~ good catch!

>
>>   #define MMC_CAP_CMD23		(1 << 30)	/* CMD23 supported. */
>>   #define MMC_CAP_HW_RESET	(1 << 31)	/* Hardware reset */
>>
>> @@ -469,6 +470,11 @@ static inline int mmc_host_uhs(struct mmc_host *host)
>>   		 MMC_CAP_UHS_DDR50);
>>   }
>>
>> +static inline int mmc_host_enhanced_strobe(struct mmc_host *host)
>> +{
>> +	return host->caps & MMC_CAP_ENHANCED_STROBE;
>> +}
>> +
>>   static inline int mmc_host_packed_wr(struct mmc_host *host)
>>   {
>>   	return host->caps2 & MMC_CAP2_PACKED_WR;
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


-- 
Best Regards
Shawn Lin

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

* Re: [RFC PATCH 2/4] mmc: core: implement enhanced strobe support
  2016-03-03 13:37   ` Adrian Hunter
@ 2016-03-04  2:00     ` Shawn Lin
  0 siblings, 0 replies; 11+ messages in thread
From: Shawn Lin @ 2016-03-04  2:00 UTC (permalink / raw)
  To: Adrian Hunter, Shawn Lin
  Cc: Ulf Hansson, Michal Simek, soren.brinkmann, linux-mmc, linux-kernel

Hi Adrian,

On 2016/3/3 21:37, Adrian Hunter wrote:
> On 03/03/16 04:36, Shawn Lin wrote:
>> Controllers use data strobe line to latch data from devices
>> under hs400 mode, but not for cmd line. So from emmc 5.1, JEDEC
>> introduces enhanced strobe mode for latching cmd response from
>> emmc devices to host controllers. This new feature is optional.
>
> As I currently understand it, HS400ES does not require tuning.
> Consequently you can go straight to HS400ES and do not need to do
> HS200 first.  If that is the case then more changes are needed.
>

That's the case, and it's already in my plan before I going to remove
"RFC" prefix. From my experience of developing emmc-device firmware, the
only reason we need tuning for HS200 before we switch it into HS400
is that although data-line can be latched by DS but the cmd-line is 
still in SDR mode when runing in HS400. With hs400-es setuped, tuning
and retune stuff is meaningless. ALl the SI should be guranteed by HW
design to regulate the PCB payload.


> Also it would be nice if the transfer mode displayed reflected enhanced
> strobe e.g.

Great idea! And maybe more thing should be done for core/debugfs.c
It seems to big change for init_card, so I need more time to split my
step for changing it to make the change will not do any side effect from
non-hs400es procedure. :)

Thanks.

>
> 	Currently
>
> 		mmc1: new HS400 MMC card at address 0001
>
> 	Change for enhance strobe supported
>
> 		mmc1: new HS400ES MMC card at address 0001
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

end of thread, other threads:[~2016-03-04  2:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-03  2:35 [RFC PATCH 0/4] Add enhanced strobe support for emmc version 5.1 or later Shawn Lin
2016-03-03  2:36 ` [RFC PATCH 1/4] mmc: core: add cap-enhanced-strobe support Shawn Lin
2016-03-03 12:08   ` Jaehoon Chung
2016-03-04  1:39     ` Shawn Lin
2016-03-03  2:36 ` [RFC PATCH 2/4] mmc: core: implement enhanced strobe support Shawn Lin
2016-03-03 13:37   ` Adrian Hunter
2016-03-04  2:00     ` Shawn Lin
2016-03-03  2:36 ` [RFC PATCH 3/4] mmc: sdhci: implement enhanced strobe callback Shawn Lin
2016-03-03  2:36 ` [RFC PATCH 4/4] mmc: sdhci-of-arasan: overwrite " Shawn Lin
2016-03-03 11:02   ` Michal Simek
2016-03-03 11:37     ` Shawn Lin

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