linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support
@ 2018-04-27 11:47 Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 01/14] mmc: sdhci-omap: Fix when capabilities are obtained from SDHCI_CAPABILITIES reg Kishon Vijay Abraham I
                   ` (14 more replies)
  0 siblings, 15 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

Add UHS/HS200 mode support in sdhci-omap. The programming sequence
for voltage switching, tuning is followed from AM572x TRM
http://www.ti.com/lit/ug/spruhz6j/spruhz6j.pdf
(Similar to all AM57x/DRA7x SoCs). The patch series also implements
workaround for errata published in
http://www.ti.com/lit/er/sprz429l/sprz429l.pdf

patches are created on top of
git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next

The patches along with dt has also been pushed to
https://github.com/kishon/linux-wip.git sdhci_uhs_v5

Changes from v4:
*) Added comment in sdhci for disabling HS200/HS400 mode
*) Fixed a couple of chunks in "Program a relatively accurate SW timeout
   value" which were missed in the previous revision
*) Added a patch in sdhci-omap to get IODelay values of 3.3v DDR mode.
*) Added pinctrl binding documentation for sdhci-omap which was missed
   before.

Changes from v3:
*) Fixed Adrian's comment on error handling when __sdhci_add_host()
   fails
*) Used Adrian's patches for programming SW timeout value.

Changes from v2:
*) Patches in v2 already applied to mmc -next are dropped from the
   series.
*) Changed SW timeout logic as per Adrians's suggestion
*) Validated SDIO with the current patches (added a couple of fixes
   found while adding SDIO support).
*) Used soc_device_match() instead of pdata-quirks as per Tony's
   suggestions.

Changes from v1:
*) Only poll on DAT0 and DATI for card_busy status
*) Cleanup iodelay patch as suggested by Tony.
*) Added quirk to disable HW timeout
*) Use the existing data timer but program a relatively accurate
   SW timeout value (Impacts all platforms)
*) Fix a bug in sdhci which was using data_timer for non data line
   commands

Adrian Hunter (2):
  mmc: sdhci: Add quirk to disable HW timeout
  mmc: sdhci: Factor out target_timeout calculation

Kishon Vijay Abraham I (12):
  mmc: sdhci-omap: Fix when capabilities are obtained from
    SDHCI_CAPABILITIES reg
  mmc: sdhci-omap: Remove setting ADMA capability in driver
  mmc: sdhci-omap: Workaround for Errata i843
  mmc: sdhci-omap: Invoke sdhci_get_of_property to read sdhci dt
    properties
  mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't
    support 1.8v
  mmc: sdhci: Program a relatively accurate SW timeout value
  mmc: sdhci-omap: Workaround for Errata i834
  dt-bindings: sdhci-omap: Add K2G specific binding
  mmc: sdhci-omap: Add support for MMC/SD controller in k2g SoC
  mmc: sdhci-omap: Add sdhci_omap specific ops for enable_sdio_irq
  dt-bindings: sdhci-omap: Add pinctrl bindings
  mmc: sdhci-omap: Get IODelay values for 3.3v DDR mode

 .../devicetree/bindings/mmc/sdhci-omap.txt    |   7 +
 drivers/mmc/host/sdhci-omap.c                 |  92 +++++++++--
 drivers/mmc/host/sdhci.c                      | 148 ++++++++++++++----
 drivers/mmc/host/sdhci.h                      |  15 ++
 include/linux/mmc/host.h                      |   4 +
 5 files changed, 226 insertions(+), 40 deletions(-)

-- 
2.17.0

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

* [PATCH v5 01/14] mmc: sdhci-omap: Fix when capabilities are obtained from SDHCI_CAPABILITIES reg
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 02/14] mmc: sdhci-omap: Remove setting ADMA capability in driver Kishon Vijay Abraham I
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

sdhci_omap_config_iodelay_pinctrl_state() requires caps and caps2 to be
initialized (speed mode capabilities like UHS/HS200) before it is
invoked. While mmc_of_parse() initializes caps/caps2 if capabilities is
populated in device tree, it will remain uninitialized for capabilities
obtained from SDHCI_CAPABILITIES register.
Fix sdhci_omap_config_iodelay_pinctrl_state() to be used even while
getting the capabilities from SDHCI_CAPABILITIES register by invoking
sdhci_setup_host() before sdhci_omap_config_iodelay_pinctrl_state().

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-omap.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index 1456abd5eeb9..e7e43f2ae224 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -916,10 +916,6 @@ static int sdhci_omap_probe(struct platform_device *pdev)
 		goto err_put_sync;
 	}
 
-	ret = sdhci_omap_config_iodelay_pinctrl_state(omap_host);
-	if (ret)
-		goto err_put_sync;
-
 	host->mmc_host_ops.get_ro = mmc_gpio_get_ro;
 	host->mmc_host_ops.start_signal_voltage_switch =
 					sdhci_omap_start_signal_voltage_switch;
@@ -930,12 +926,23 @@ static int sdhci_omap_probe(struct platform_device *pdev)
 	sdhci_read_caps(host);
 	host->caps |= SDHCI_CAN_DO_ADMA2;
 
-	ret = sdhci_add_host(host);
+	ret = sdhci_setup_host(host);
 	if (ret)
 		goto err_put_sync;
 
+	ret = sdhci_omap_config_iodelay_pinctrl_state(omap_host);
+	if (ret)
+		goto err_cleanup_host;
+
+	ret = __sdhci_add_host(host);
+	if (ret)
+		goto err_cleanup_host;
+
 	return 0;
 
+err_cleanup_host:
+	sdhci_cleanup_host(host);
+
 err_put_sync:
 	pm_runtime_put_sync(dev);
 
-- 
2.17.0

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

* [PATCH v5 02/14] mmc: sdhci-omap: Remove setting ADMA capability in driver
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 01/14] mmc: sdhci-omap: Fix when capabilities are obtained from SDHCI_CAPABILITIES reg Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 03/14] mmc: sdhci-omap: Workaround for Errata i843 Kishon Vijay Abraham I
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

sdhci can directly get ADMA capability from MMCHS_CAPA register.
Remove explicitly setting ADMA here as some instances might not have
ADMA enabled. (sdhci_read_caps() is also removed from here since
sdhci_setup_host() invokes it).

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mmc/host/sdhci-omap.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index e7e43f2ae224..78f3ceea570e 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -923,9 +923,6 @@ static int sdhci_omap_probe(struct platform_device *pdev)
 	host->mmc_host_ops.card_busy = sdhci_omap_card_busy;
 	host->mmc_host_ops.execute_tuning = sdhci_omap_execute_tuning;
 
-	sdhci_read_caps(host);
-	host->caps |= SDHCI_CAN_DO_ADMA2;
-
 	ret = sdhci_setup_host(host);
 	if (ret)
 		goto err_put_sync;
-- 
2.17.0

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

* [PATCH v5 03/14] mmc: sdhci-omap: Workaround for Errata i843
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 01/14] mmc: sdhci-omap: Fix when capabilities are obtained from SDHCI_CAPABILITIES reg Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 02/14] mmc: sdhci-omap: Remove setting ADMA capability in driver Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 04/14] mmc: sdhci-omap: Invoke sdhci_get_of_property to read sdhci dt properties Kishon Vijay Abraham I
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

Errata i843 in AM572x Sitara Processors Silicon Revision 2.0, 1.1
(SPRZ429K July 2014–Revised March 2017 [1]) mentions
PG 1.0/1.1 silicon has limitations w.r.t frequencies at which MMC1/2/3
can operate.

Use soc_device_match() to identify rev 1.0/1.1 silicon and
override mmc->f_max according to the errata workaround.
"max-frequency" dt property cannot be used since the device
tree is added for rev 2.0 silicon.

soc_device_match() is also used in order to get the IODelay values
for rev 1.0/1.1 silicon.

[1] -> http://www.ti.com/lit/er/sprz429k/sprz429k.pdf

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mmc/host/sdhci-omap.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index 78f3ceea570e..b3dc7f1466e5 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -26,6 +26,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/sys_soc.h>
 
 #include "sdhci-pltfm.h"
 
@@ -100,6 +101,7 @@ struct sdhci_omap_data {
 };
 
 struct sdhci_omap_host {
+	char			*version;
 	void __iomem		*base;
 	struct device		*dev;
 	struct	regulator	*pbias;
@@ -733,12 +735,21 @@ static struct pinctrl_state
 				  u32 *caps, u32 capmask)
 {
 	struct device *dev = omap_host->dev;
+	char *version = omap_host->version;
 	struct pinctrl_state *pinctrl_state = ERR_PTR(-ENODEV);
+	char str[20];
 
 	if (!(*caps & capmask))
 		goto ret;
 
-	pinctrl_state = pinctrl_lookup_state(omap_host->pinctrl, mode);
+	if (version) {
+		snprintf(str, 20, "%s-%s", mode, version);
+		pinctrl_state = pinctrl_lookup_state(omap_host->pinctrl, str);
+	}
+
+	if (IS_ERR(pinctrl_state))
+		pinctrl_state = pinctrl_lookup_state(omap_host->pinctrl, mode);
+
 	if (IS_ERR(pinctrl_state)) {
 		dev_err(dev, "no pinctrl state for %s mode", mode);
 		*caps &= ~capmask;
@@ -830,6 +841,16 @@ static int sdhci_omap_config_iodelay_pinctrl_state(struct sdhci_omap_host
 	return 0;
 }
 
+static const struct soc_device_attribute sdhci_omap_soc_devices[] = {
+	{
+		.machine = "DRA7[45]*",
+		.revision = "ES1.[01]",
+	},
+	{
+		/* sentinel */
+	}
+};
+
 static int sdhci_omap_probe(struct platform_device *pdev)
 {
 	int ret;
@@ -841,6 +862,7 @@ static int sdhci_omap_probe(struct platform_device *pdev)
 	struct mmc_host *mmc;
 	const struct of_device_id *match;
 	struct sdhci_omap_data *data;
+	const struct soc_device_attribute *soc;
 
 	match = of_match_device(omap_sdhci_match, dev);
 	if (!match)
@@ -875,6 +897,17 @@ static int sdhci_omap_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_pltfm_free;
 
+	soc = soc_device_match(sdhci_omap_soc_devices);
+	if (soc) {
+		omap_host->version = "rev11";
+		if (!strcmp(dev_name(dev), "4809c000.mmc"))
+			mmc->f_max = 96000000;
+		if (!strcmp(dev_name(dev), "480b4000.mmc"))
+			mmc->f_max = 48000000;
+		if (!strcmp(dev_name(dev), "480ad000.mmc"))
+			mmc->f_max = 48000000;
+	}
+
 	pltfm_host->clk = devm_clk_get(dev, "fck");
 	if (IS_ERR(pltfm_host->clk)) {
 		ret = PTR_ERR(pltfm_host->clk);
-- 
2.17.0

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

* [PATCH v5 04/14] mmc: sdhci-omap: Invoke sdhci_get_of_property to read sdhci dt properties
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (2 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 03/14] mmc: sdhci-omap: Workaround for Errata i843 Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 05/14] mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't support 1.8v Kishon Vijay Abraham I
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

Invoke sdhci_get_of_property defined in sdhci-pltfm.c to read
sdhci specific properties from dt node.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mmc/host/sdhci-omap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index b3dc7f1466e5..d5c1a9c71f95 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -893,6 +893,7 @@ static int sdhci_omap_probe(struct platform_device *pdev)
 	host->ioaddr += offset;
 
 	mmc = host->mmc;
+	sdhci_get_of_property(pdev);
 	ret = mmc_of_parse(mmc);
 	if (ret)
 		goto err_pltfm_free;
-- 
2.17.0

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

* [PATCH v5 05/14] mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't support 1.8v
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (3 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 04/14] mmc: sdhci-omap: Invoke sdhci_get_of_property to read sdhci dt properties Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 06/14] mmc: sdhci: Add quirk to disable HW timeout Kishon Vijay Abraham I
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

The SDHCI controller in a SoC might support HS200/HS400 (indicated
using mmc-hs200-1_8v/mmc-hs400-1_8v dt property), but if the board is
modeled such that the IO lines are not connected to 1.8v then
HS200/HS400 cannot be supported. Disable HS200/HS400 if the board
does not have 1.8v connected to the IO lines. Also Disable DDR/UHS in 1.8v
if the IO lines are not connected to 1.8v.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mmc/host/sdhci.c | 10 ++++++++++
 include/linux/mmc/host.h |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 2ededa7f43df..0f3cdca3e769 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -3672,6 +3672,16 @@ int sdhci_setup_host(struct sdhci_host *host)
 	if (host->quirks2 & SDHCI_QUIRK2_NO_1_8_V) {
 		host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 |
 				 SDHCI_SUPPORT_DDR50);
+		/*
+		 * The SDHCI controller in a SoC might support HS200/HS400
+		 * (indicated using mmc-hs200-1_8v/mmc-hs400-1_8v dt property),
+		 * but if the board is modeled such that the IO lines are not
+		 * connected to 1.8v then HS200/HS400 cannot be supported.
+		 * Disable HS200/HS400 if the board does not have 1.8v connected
+		 * to the IO lines. (Applicable for other modes in 1.8v)
+		 */
+		mmc->caps2 &= ~(MMC_CAP2_HSX00_1_8V | MMC_CAP2_HS400_ES);
+		mmc->caps &= ~(MMC_CAP_1_8V_DDR | MMC_CAP_UHS);
 	}
 
 	/* Any UHS-I mode in caps implies SDR12 and SDR25 support. */
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 7c6eaf63f5ce..8f1859044db1 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -320,6 +320,9 @@ struct mmc_host {
 #define MMC_CAP_UHS_SDR50	(1 << 18)	/* Host supports UHS SDR50 mode */
 #define MMC_CAP_UHS_SDR104	(1 << 19)	/* Host supports UHS SDR104 mode */
 #define MMC_CAP_UHS_DDR50	(1 << 20)	/* Host supports UHS DDR50 mode */
+#define MMC_CAP_UHS		(MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | \
+				 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | \
+				 MMC_CAP_UHS_DDR50)
 /* (1 << 21) is free for reuse */
 #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 */
@@ -345,6 +348,7 @@ struct mmc_host {
 #define MMC_CAP2_HS400_1_2V	(1 << 16)	/* Can support HS400 1.2V */
 #define MMC_CAP2_HS400		(MMC_CAP2_HS400_1_8V | \
 				 MMC_CAP2_HS400_1_2V)
+#define MMC_CAP2_HSX00_1_8V	(MMC_CAP2_HS200_1_8V_SDR | MMC_CAP2_HS400_1_8V)
 #define MMC_CAP2_HSX00_1_2V	(MMC_CAP2_HS200_1_2V_SDR | MMC_CAP2_HS400_1_2V)
 #define MMC_CAP2_SDIO_IRQ_NOTHREAD (1 << 17)
 #define MMC_CAP2_NO_WRITE_PROTECT (1 << 18)	/* No physical write protect pin, assume that card is always read-write */
-- 
2.17.0

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

* [PATCH v5 06/14] mmc: sdhci: Add quirk to disable HW timeout
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (4 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 05/14] mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't support 1.8v Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 07/14] mmc: sdhci: Factor out target_timeout calculation Kishon Vijay Abraham I
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

From: Adrian Hunter <adrian.hunter@intel.com>

Add quirk to disable HW timeout if the requested timeout is more than the
maximum obtainable timeout.

Also, if the quirk is set and ->get_max_timeout_count() is not implemented,
max_busy_timeout is set to zero.

Based-on-patch-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/mmc/host/sdhci.c | 38 ++++++++++++++++++++++++++++++++++----
 drivers/mmc/host/sdhci.h |  5 +++++
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 0f3cdca3e769..8da118d0d2c4 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -709,12 +709,15 @@ static u32 sdhci_sdma_address(struct sdhci_host *host)
 		return sg_dma_address(host->data->sg);
 }
 
-static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
+static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
+			     bool *too_big)
 {
 	u8 count;
 	struct mmc_data *data = cmd->data;
 	unsigned target_timeout, current_timeout;
 
+	*too_big = true;
+
 	/*
 	 * If the host controller provides us with an incorrect timeout
 	 * value, just skip the check and use 0xE.  The hardware may take
@@ -768,9 +771,12 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
 	}
 
 	if (count >= 0xF) {
-		DBG("Too large timeout 0x%x requested for CMD%d!\n",
-		    count, cmd->opcode);
+		if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
+			DBG("Too large timeout 0x%x requested for CMD%d!\n",
+			    count, cmd->opcode);
 		count = 0xE;
+	} else {
+		*too_big = false;
 	}
 
 	return count;
@@ -790,6 +796,16 @@ static void sdhci_set_transfer_irqs(struct sdhci_host *host)
 	sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
 }
 
+static void sdhci_set_data_timeout_irq(struct sdhci_host *host, bool enable)
+{
+	if (enable)
+		host->ier |= SDHCI_INT_DATA_TIMEOUT;
+	else
+		host->ier &= ~SDHCI_INT_DATA_TIMEOUT;
+	sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
+	sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
+}
+
 static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd)
 {
 	u8 count;
@@ -797,7 +813,17 @@ static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd)
 	if (host->ops->set_timeout) {
 		host->ops->set_timeout(host, cmd);
 	} else {
-		count = sdhci_calc_timeout(host, cmd);
+		bool too_big = false;
+
+		count = sdhci_calc_timeout(host, cmd, &too_big);
+
+		if (too_big &&
+		    host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT) {
+			sdhci_set_data_timeout_irq(host, false);
+		} else if (!(host->ier & SDHCI_INT_DATA_TIMEOUT)) {
+			sdhci_set_data_timeout_irq(host, true);
+		}
+
 		sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL);
 	}
 }
@@ -3616,6 +3642,10 @@ int sdhci_setup_host(struct sdhci_host *host)
 		mmc->max_busy_timeout /= host->timeout_clk;
 	}
 
+	if (host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT &&
+	    !host->ops->get_max_timeout_count)
+		mmc->max_busy_timeout = 0;
+
 	mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
 	mmc->caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD;
 
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index c95b0a4a7594..f6555c0f4ad3 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -437,6 +437,11 @@ struct sdhci_host {
 #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN		(1<<15)
 /* Controller has CRC in 136 bit Command Response */
 #define SDHCI_QUIRK2_RSP_136_HAS_CRC			(1<<16)
+/*
+ * Disable HW timeout if the requested timeout is more than the maximum
+ * obtainable timeout.
+ */
+#define SDHCI_QUIRK2_DISABLE_HW_TIMEOUT			(1<<17)
 
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */
-- 
2.17.0

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

* [PATCH v5 07/14] mmc: sdhci: Factor out target_timeout calculation
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (5 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 06/14] mmc: sdhci: Add quirk to disable HW timeout Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 08/14] mmc: sdhci: Program a relatively accurate SW timeout value Kishon Vijay Abraham I
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

From: Adrian Hunter <adrian.hunter@intel.com>

Factor out the target_timeout calculation so it can be re-used.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/mmc/host/sdhci.c | 48 +++++++++++++++++++++++++---------------
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 8da118d0d2c4..b229354e5b88 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -709,6 +709,35 @@ static u32 sdhci_sdma_address(struct sdhci_host *host)
 		return sg_dma_address(host->data->sg);
 }
 
+static unsigned int sdhci_target_timeout(struct sdhci_host *host,
+					 struct mmc_command *cmd,
+					 struct mmc_data *data)
+{
+	unsigned int target_timeout;
+
+	/* timeout in us */
+	if (!data) {
+		target_timeout = cmd->busy_timeout * 1000;
+	} else {
+		target_timeout = DIV_ROUND_UP(data->timeout_ns, 1000);
+		if (host->clock && data->timeout_clks) {
+			unsigned long long val;
+
+			/*
+			 * data->timeout_clks is in units of clock cycles.
+			 * host->clock is in Hz.  target_timeout is in us.
+			 * Hence, us = 1000000 * cycles / Hz.  Round up.
+			 */
+			val = 1000000ULL * data->timeout_clks;
+			if (do_div(val, host->clock))
+				target_timeout++;
+			target_timeout += val;
+		}
+	}
+
+	return target_timeout;
+}
+
 static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 			     bool *too_big)
 {
@@ -732,24 +761,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 		return 0xE;
 
 	/* timeout in us */
-	if (!data)
-		target_timeout = cmd->busy_timeout * 1000;
-	else {
-		target_timeout = DIV_ROUND_UP(data->timeout_ns, 1000);
-		if (host->clock && data->timeout_clks) {
-			unsigned long long val;
-
-			/*
-			 * data->timeout_clks is in units of clock cycles.
-			 * host->clock is in Hz.  target_timeout is in us.
-			 * Hence, us = 1000000 * cycles / Hz.  Round up.
-			 */
-			val = 1000000ULL * data->timeout_clks;
-			if (do_div(val, host->clock))
-				target_timeout++;
-			target_timeout += val;
-		}
-	}
+	target_timeout = sdhci_target_timeout(host, cmd, data);
 
 	/*
 	 * Figure out needed cycles.
-- 
2.17.0

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

* [PATCH v5 08/14] mmc: sdhci: Program a relatively accurate SW timeout value
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (6 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 07/14] mmc: sdhci: Factor out target_timeout calculation Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 09/14] mmc: sdhci-omap: Workaround for Errata i834 Kishon Vijay Abraham I
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

sdhci has a 10 second timeout to catch devices that stop responding.
In the case of quirk SDHCI_QUIRK2_DISABLE_HW_TIMEOUT, instead of
programming 10 second arbitrary value, calculate the total time it would
take for the entire transfer to happen and program the timeout value
accordingly.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 52 ++++++++++++++++++++++++++++++++++------
 drivers/mmc/host/sdhci.h | 10 ++++++++
 2 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index b229354e5b88..1c828e0e9905 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -738,6 +738,39 @@ static unsigned int sdhci_target_timeout(struct sdhci_host *host,
 	return target_timeout;
 }
 
+static void sdhci_calc_sw_timeout(struct sdhci_host *host,
+				  struct mmc_command *cmd)
+{
+	struct mmc_data *data = cmd->data;
+	struct mmc_host *mmc = host->mmc;
+	struct mmc_ios *ios = &mmc->ios;
+	unsigned char bus_width = 1 << ios->bus_width;
+	unsigned int blksz;
+	unsigned int freq;
+	u64 target_timeout;
+	u64 transfer_time;
+
+	target_timeout = sdhci_target_timeout(host, cmd, data);
+	target_timeout *= NSEC_PER_USEC;
+
+	if (data) {
+		blksz = data->blksz;
+		freq = host->mmc->actual_clock ? : host->clock;
+		transfer_time = (u64)blksz * NSEC_PER_SEC * (8 / bus_width);
+		do_div(transfer_time, freq);
+		/* multiply by '2' to account for any unknowns */
+		transfer_time = transfer_time * 2;
+		/* calculate timeout for the entire data */
+		host->data_timeout = data->blocks * target_timeout +
+				     transfer_time;
+	} else {
+		host->data_timeout = target_timeout;
+	}
+
+	if (host->data_timeout)
+		host->data_timeout += MMC_CMD_TRANSFER_TIME;
+}
+
 static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
 			     bool *too_big)
 {
@@ -831,6 +864,7 @@ static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd)
 
 		if (too_big &&
 		    host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT) {
+			sdhci_calc_sw_timeout(host, cmd);
 			sdhci_set_data_timeout_irq(host, false);
 		} else if (!(host->ier & SDHCI_INT_DATA_TIMEOUT)) {
 			sdhci_set_data_timeout_irq(host, true);
@@ -845,6 +879,8 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)
 	u8 ctrl;
 	struct mmc_data *data = cmd->data;
 
+	host->data_timeout = 0;
+
 	if (sdhci_data_line_cmd(cmd))
 		sdhci_set_timeout(host, cmd);
 
@@ -1198,13 +1234,6 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
 		mdelay(1);
 	}
 
-	timeout = jiffies;
-	if (!cmd->data && cmd->busy_timeout > 9000)
-		timeout += DIV_ROUND_UP(cmd->busy_timeout, 1000) * HZ + HZ;
-	else
-		timeout += 10 * HZ;
-	sdhci_mod_timer(host, cmd->mrq, timeout);
-
 	host->cmd = cmd;
 	if (sdhci_data_line_cmd(cmd)) {
 		WARN_ON(host->data_cmd);
@@ -1244,6 +1273,15 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
 	    cmd->opcode == MMC_SEND_TUNING_BLOCK_HS200)
 		flags |= SDHCI_CMD_DATA;
 
+	timeout = jiffies;
+	if (host->data_timeout)
+		timeout += nsecs_to_jiffies(host->data_timeout);
+	else if (!cmd->data && cmd->busy_timeout > 9000)
+		timeout += DIV_ROUND_UP(cmd->busy_timeout, 1000) * HZ + HZ;
+	else
+		timeout += 10 * HZ;
+	sdhci_mod_timer(host, cmd->mrq, timeout);
+
 	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
 }
 EXPORT_SYMBOL_GPL(sdhci_send_command);
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index f6555c0f4ad3..23966f887da6 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -332,6 +332,14 @@ struct sdhci_adma2_64_desc {
 /* Allow for a a command request and a data request at the same time */
 #define SDHCI_MAX_MRQS		2
 
+/*
+ * 48bit command and 136 bit response in 100KHz clock could take upto 2.48ms.
+ * However since the start time of the command, the time between
+ * command and response, and the time between response and start of data is
+ * not known, set the command transfer time to 10ms.
+ */
+#define MMC_CMD_TRANSFER_TIME	(10 * NSEC_PER_MSEC) /* max 10 ms */
+
 enum sdhci_cookie {
 	COOKIE_UNMAPPED,
 	COOKIE_PRE_MAPPED,	/* mapped by sdhci_pre_req() */
@@ -555,6 +563,8 @@ struct sdhci_host {
 	/* Host SDMA buffer boundary. */
 	u32			sdma_boundary;
 
+	u64			data_timeout;
+
 	unsigned long private[0] ____cacheline_aligned;
 };
 
-- 
2.17.0

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

* [PATCH v5 09/14] mmc: sdhci-omap: Workaround for Errata i834
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (7 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 08/14] mmc: sdhci: Program a relatively accurate SW timeout value Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 10/14] dt-bindings: sdhci-omap: Add K2G specific binding Kishon Vijay Abraham I
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

Errata i834 in AM572x Sitara Processors Silicon Revision 2.0, 1.1
(SPRZ429K July 2014–Revised March 2017 [1]) mentions the maximum
obtainable timeout through MMC host controller is 700ms. And for
commands taking longer than 700ms, hardware timeout should be
disabled and software timeout should be used.

The workaround for Errata i834 can be achieved by adding
SDHCI_QUIRK2_DISABLE_HW_TIMEOUT quirk in sdhci-omap.

[1] -> http://www.ti.com/lit/er/sprz429k/sprz429k.pdf

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-omap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index d5c1a9c71f95..2232a9974b21 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -715,7 +715,8 @@ static const struct sdhci_pltfm_data sdhci_omap_pdata = {
 		  SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC,
 	.quirks2 = SDHCI_QUIRK2_ACMD23_BROKEN |
 		   SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
-		   SDHCI_QUIRK2_RSP_136_HAS_CRC,
+		   SDHCI_QUIRK2_RSP_136_HAS_CRC |
+		   SDHCI_QUIRK2_DISABLE_HW_TIMEOUT,
 	.ops = &sdhci_omap_ops,
 };
 
-- 
2.17.0

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

* [PATCH v5 10/14] dt-bindings: sdhci-omap: Add K2G specific binding
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (8 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 09/14] mmc: sdhci-omap: Workaround for Errata i834 Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 11/14] mmc: sdhci-omap: Add support for MMC/SD controller in k2g SoC Kishon Vijay Abraham I
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

Add binding for the TI's sdhci-omap controller present in K2G.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Tony Lindgren <tony@atomide.com>
---
 Documentation/devicetree/bindings/mmc/sdhci-omap.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/sdhci-omap.txt b/Documentation/devicetree/bindings/mmc/sdhci-omap.txt
index 51775a372c06..8d09b837e350 100644
--- a/Documentation/devicetree/bindings/mmc/sdhci-omap.txt
+++ b/Documentation/devicetree/bindings/mmc/sdhci-omap.txt
@@ -4,7 +4,9 @@ Refer to mmc.txt for standard MMC bindings.
 
 Required properties:
 - compatible: Should be "ti,dra7-sdhci" for DRA7 and DRA72 controllers
+	      Should be "ti,k2g-sdhci" for K2G
 - ti,hwmods: Must be "mmc<n>", <n> is controller instance starting 1
+	     (Not required for K2G).
 
 Example:
 	mmc1: mmc@4809c000 {
-- 
2.17.0

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

* [PATCH v5 11/14] mmc: sdhci-omap: Add support for MMC/SD controller in k2g SoC
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (9 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 10/14] dt-bindings: sdhci-omap: Add K2G specific binding Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 12/14] mmc: sdhci-omap: Add sdhci_omap specific ops for enable_sdio_irq Kishon Vijay Abraham I
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

Add support for the new compatible added specifically to support
k2g's MMC/SD controller.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mmc/host/sdhci-omap.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index 2232a9974b21..b11c846dd8a1 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -720,6 +720,10 @@ static const struct sdhci_pltfm_data sdhci_omap_pdata = {
 	.ops = &sdhci_omap_ops,
 };
 
+static const struct sdhci_omap_data k2g_data = {
+	.offset = 0x200,
+};
+
 static const struct sdhci_omap_data dra7_data = {
 	.offset = 0x200,
 	.flags	= SDHCI_OMAP_REQUIRE_IODELAY,
@@ -727,6 +731,7 @@ static const struct sdhci_omap_data dra7_data = {
 
 static const struct of_device_id omap_sdhci_match[] = {
 	{ .compatible = "ti,dra7-sdhci", .data = &dra7_data },
+	{ .compatible = "ti,k2g-sdhci", .data = &k2g_data },
 	{},
 };
 MODULE_DEVICE_TABLE(of, omap_sdhci_match);
-- 
2.17.0

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

* [PATCH v5 12/14] mmc: sdhci-omap: Add sdhci_omap specific ops for enable_sdio_irq
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (10 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 11/14] mmc: sdhci-omap: Add support for MMC/SD controller in k2g SoC Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 11:47 ` [PATCH v5 13/14] dt-bindings: sdhci-omap: Add pinctrl bindings Kishon Vijay Abraham I
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

Add sdhci_omap_enable_sdio_irq to set CTPL and CLKEXTFREE bits in
MMCHS_CON register required to detect asynchronous card interrupt
on DAT[1].

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mmc/host/sdhci-omap.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index b11c846dd8a1..bd5e03d177e0 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -36,6 +36,7 @@
 #define CON_DDR			BIT(19)
 #define CON_CLKEXTFREE		BIT(16)
 #define CON_PADEN		BIT(15)
+#define CON_CTPL		BIT(11)
 #define CON_INIT		BIT(1)
 #define CON_OD			BIT(0)
 
@@ -226,6 +227,23 @@ static void sdhci_omap_conf_bus_power(struct sdhci_omap_host *omap_host,
 	}
 }
 
+static void sdhci_omap_enable_sdio_irq(struct mmc_host *mmc, int enable)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host);
+	u32 reg;
+
+	reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON);
+	if (enable)
+		reg |= (CON_CTPL | CON_CLKEXTFREE);
+	else
+		reg &= ~(CON_CTPL | CON_CLKEXTFREE);
+	sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg);
+
+	sdhci_enable_sdio_irq(mmc, enable);
+}
+
 static inline void sdhci_omap_set_dll(struct sdhci_omap_host *omap_host,
 				      int count)
 {
@@ -962,6 +980,7 @@ static int sdhci_omap_probe(struct platform_device *pdev)
 	host->mmc_host_ops.set_ios = sdhci_omap_set_ios;
 	host->mmc_host_ops.card_busy = sdhci_omap_card_busy;
 	host->mmc_host_ops.execute_tuning = sdhci_omap_execute_tuning;
+	host->mmc_host_ops.enable_sdio_irq = sdhci_omap_enable_sdio_irq;
 
 	ret = sdhci_setup_host(host);
 	if (ret)
-- 
2.17.0

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

* [PATCH v5 13/14] dt-bindings: sdhci-omap: Add pinctrl bindings
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (11 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 12/14] mmc: sdhci-omap: Add sdhci_omap specific ops for enable_sdio_irq Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-04-27 14:26   ` Rob Herring
  2018-04-27 11:47 ` [PATCH v5 14/14] mmc: sdhci-omap: Get IODelay values for 3.3v DDR mode Kishon Vijay Abraham I
  2018-05-02 13:15 ` [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Ulf Hansson
  14 siblings, 1 reply; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

Add pinctrl binding rquired to get the mux mode and IODelay
values from devicetree.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 Documentation/devicetree/bindings/mmc/sdhci-omap.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/sdhci-omap.txt b/Documentation/devicetree/bindings/mmc/sdhci-omap.txt
index 8d09b837e350..393848c2138e 100644
--- a/Documentation/devicetree/bindings/mmc/sdhci-omap.txt
+++ b/Documentation/devicetree/bindings/mmc/sdhci-omap.txt
@@ -7,6 +7,11 @@ Required properties:
 	      Should be "ti,k2g-sdhci" for K2G
 - ti,hwmods: Must be "mmc<n>", <n> is controller instance starting 1
 	     (Not required for K2G).
+- pinctrl-names: Should be subset of "default", "hs", "sdr12", "sdr25", "sdr50",
+		 "ddr50-rev11", "sdr104-rev11", "ddr50", "sdr104",
+		 "ddr_1_8v-rev11", "ddr_1_8v" or "ddr_3_3v", "hs200_1_8v-rev11",
+		 "hs200_1_8v",
+- pinctrl-<n> : Pinctrl states as described in bindings/pinctrl/pinctrl-bindings.txt
 
 Example:
 	mmc1: mmc@4809c000 {
-- 
2.17.0

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

* [PATCH v5 14/14] mmc: sdhci-omap: Get IODelay values for 3.3v DDR mode
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (12 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 13/14] dt-bindings: sdhci-omap: Add pinctrl bindings Kishon Vijay Abraham I
@ 2018-04-27 11:47 ` Kishon Vijay Abraham I
  2018-05-02 13:15 ` [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Ulf Hansson
  14 siblings, 0 replies; 20+ messages in thread
From: Kishon Vijay Abraham I @ 2018-04-27 11:47 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: Rob Herring, Mark Rutland, linux-mmc, devicetree, linux-kernel,
	linux-omap, kishon

commit 8d20b2eae6c47b095523 ("mmc: sdhci_omap: Add support to set
IODELAY values") stored IODelay values for all MM/SD modes
in pinctrl_state structure member of sdhci_omap_host. However for
DDR mode it gets IODelay values only for 1.8v DDR mode. Since some of
the platforms which uses sdhci-omap has IO lines connected to 3.3v,
get IODelay values for 3.3v DDR mode.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/mmc/host/sdhci-omap.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index bd5e03d177e0..f3a7c8ece4be 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -842,8 +842,15 @@ static int sdhci_omap_config_iodelay_pinctrl_state(struct sdhci_omap_host
 
 	state = sdhci_omap_iodelay_pinctrl_state(omap_host, "ddr_1_8v", caps,
 						 MMC_CAP_1_8V_DDR);
-	if (!IS_ERR(state))
+	if (!IS_ERR(state)) {
 		pinctrl_state[MMC_TIMING_MMC_DDR52] = state;
+	} else {
+		state = sdhci_omap_iodelay_pinctrl_state(omap_host, "ddr_3_3v",
+							 caps,
+							 MMC_CAP_3_3V_DDR);
+		if (!IS_ERR(state))
+			pinctrl_state[MMC_TIMING_MMC_DDR52] = state;
+	}
 
 	state = sdhci_omap_iodelay_pinctrl_state(omap_host, "hs", caps,
 						 MMC_CAP_SD_HIGHSPEED);
-- 
2.17.0

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

* Re: [PATCH v5 13/14] dt-bindings: sdhci-omap: Add pinctrl bindings
  2018-04-27 11:47 ` [PATCH v5 13/14] dt-bindings: sdhci-omap: Add pinctrl bindings Kishon Vijay Abraham I
@ 2018-04-27 14:26   ` Rob Herring
  0 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2018-04-27 14:26 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Ulf Hansson, Adrian Hunter, Mark Rutland, linux-mmc, devicetree,
	linux-kernel, linux-omap

On Fri, Apr 27, 2018 at 05:17:22PM +0530, Kishon Vijay Abraham I wrote:
> Add pinctrl binding rquired to get the mux mode and IODelay
> values from devicetree.
> 
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  Documentation/devicetree/bindings/mmc/sdhci-omap.txt | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support
  2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
                   ` (13 preceding siblings ...)
  2018-04-27 11:47 ` [PATCH v5 14/14] mmc: sdhci-omap: Get IODelay values for 3.3v DDR mode Kishon Vijay Abraham I
@ 2018-05-02 13:15 ` Ulf Hansson
  2018-05-02 14:55   ` Tony Lindgren
  14 siblings, 1 reply; 20+ messages in thread
From: Ulf Hansson @ 2018-05-02 13:15 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Adrian Hunter, Rob Herring, Mark Rutland, linux-mmc, devicetree,
	Linux Kernel Mailing List, linux-omap

On 27 April 2018 at 13:47, Kishon Vijay Abraham I <kishon@ti.com> wrote:
> Add UHS/HS200 mode support in sdhci-omap. The programming sequence
> for voltage switching, tuning is followed from AM572x TRM
> http://www.ti.com/lit/ug/spruhz6j/spruhz6j.pdf
> (Similar to all AM57x/DRA7x SoCs). The patch series also implements
> workaround for errata published in
> http://www.ti.com/lit/er/sprz429l/sprz429l.pdf
>
> patches are created on top of
> git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next
>
> The patches along with dt has also been pushed to
> https://github.com/kishon/linux-wip.git sdhci_uhs_v5

Thanks, applied for next!

Kind regards
Uffe

>
> Changes from v4:
> *) Added comment in sdhci for disabling HS200/HS400 mode
> *) Fixed a couple of chunks in "Program a relatively accurate SW timeout
>    value" which were missed in the previous revision
> *) Added a patch in sdhci-omap to get IODelay values of 3.3v DDR mode.
> *) Added pinctrl binding documentation for sdhci-omap which was missed
>    before.
>
> Changes from v3:
> *) Fixed Adrian's comment on error handling when __sdhci_add_host()
>    fails
> *) Used Adrian's patches for programming SW timeout value.
>
> Changes from v2:
> *) Patches in v2 already applied to mmc -next are dropped from the
>    series.
> *) Changed SW timeout logic as per Adrians's suggestion
> *) Validated SDIO with the current patches (added a couple of fixes
>    found while adding SDIO support).
> *) Used soc_device_match() instead of pdata-quirks as per Tony's
>    suggestions.
>
> Changes from v1:
> *) Only poll on DAT0 and DATI for card_busy status
> *) Cleanup iodelay patch as suggested by Tony.
> *) Added quirk to disable HW timeout
> *) Use the existing data timer but program a relatively accurate
>    SW timeout value (Impacts all platforms)
> *) Fix a bug in sdhci which was using data_timer for non data line
>    commands
>
> Adrian Hunter (2):
>   mmc: sdhci: Add quirk to disable HW timeout
>   mmc: sdhci: Factor out target_timeout calculation
>
> Kishon Vijay Abraham I (12):
>   mmc: sdhci-omap: Fix when capabilities are obtained from
>     SDHCI_CAPABILITIES reg
>   mmc: sdhci-omap: Remove setting ADMA capability in driver
>   mmc: sdhci-omap: Workaround for Errata i843
>   mmc: sdhci-omap: Invoke sdhci_get_of_property to read sdhci dt
>     properties
>   mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't
>     support 1.8v
>   mmc: sdhci: Program a relatively accurate SW timeout value
>   mmc: sdhci-omap: Workaround for Errata i834
>   dt-bindings: sdhci-omap: Add K2G specific binding
>   mmc: sdhci-omap: Add support for MMC/SD controller in k2g SoC
>   mmc: sdhci-omap: Add sdhci_omap specific ops for enable_sdio_irq
>   dt-bindings: sdhci-omap: Add pinctrl bindings
>   mmc: sdhci-omap: Get IODelay values for 3.3v DDR mode
>
>  .../devicetree/bindings/mmc/sdhci-omap.txt    |   7 +
>  drivers/mmc/host/sdhci-omap.c                 |  92 +++++++++--
>  drivers/mmc/host/sdhci.c                      | 148 ++++++++++++++----
>  drivers/mmc/host/sdhci.h                      |  15 ++
>  include/linux/mmc/host.h                      |   4 +
>  5 files changed, 226 insertions(+), 40 deletions(-)
>
> --
> 2.17.0
>

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

* Re: [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support
  2018-05-02 13:15 ` [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Ulf Hansson
@ 2018-05-02 14:55   ` Tony Lindgren
  2018-05-03  8:51     ` Ulf Hansson
  0 siblings, 1 reply; 20+ messages in thread
From: Tony Lindgren @ 2018-05-02 14:55 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Kishon Vijay Abraham I, Adrian Hunter, Rob Herring, Mark Rutland,
	linux-mmc, devicetree, Linux Kernel Mailing List, linux-omap

* Ulf Hansson <ulf.hansson@linaro.org> [180502 13:17]:
> On 27 April 2018 at 13:47, Kishon Vijay Abraham I <kishon@ti.com> wrote:
> > Add UHS/HS200 mode support in sdhci-omap. The programming sequence
> > for voltage switching, tuning is followed from AM572x TRM
> > http://www.ti.com/lit/ug/spruhz6j/spruhz6j.pdf
> > (Similar to all AM57x/DRA7x SoCs). The patch series also implements
> > workaround for errata published in
> > http://www.ti.com/lit/er/sprz429l/sprz429l.pdf
> >
> > patches are created on top of
> > git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next
> >
> > The patches along with dt has also been pushed to
> > https://github.com/kishon/linux-wip.git sdhci_uhs_v5
> 
> Thanks, applied for next!

OK. Ulf, can I use some commit id from your next as a base for
the related dts changes?

Regards,

Tony

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

* Re: [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support
  2018-05-02 14:55   ` Tony Lindgren
@ 2018-05-03  8:51     ` Ulf Hansson
  2018-05-03 14:12       ` Tony Lindgren
  0 siblings, 1 reply; 20+ messages in thread
From: Ulf Hansson @ 2018-05-03  8:51 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Kishon Vijay Abraham I, Adrian Hunter, Rob Herring, Mark Rutland,
	linux-mmc, devicetree, Linux Kernel Mailing List, linux-omap

On 2 May 2018 at 16:55, Tony Lindgren <tony@atomide.com> wrote:
> * Ulf Hansson <ulf.hansson@linaro.org> [180502 13:17]:
>> On 27 April 2018 at 13:47, Kishon Vijay Abraham I <kishon@ti.com> wrote:
>> > Add UHS/HS200 mode support in sdhci-omap. The programming sequence
>> > for voltage switching, tuning is followed from AM572x TRM
>> > http://www.ti.com/lit/ug/spruhz6j/spruhz6j.pdf
>> > (Similar to all AM57x/DRA7x SoCs). The patch series also implements
>> > workaround for errata published in
>> > http://www.ti.com/lit/er/sprz429l/sprz429l.pdf
>> >
>> > patches are created on top of
>> > git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next
>> >
>> > The patches along with dt has also been pushed to
>> > https://github.com/kishon/linux-wip.git sdhci_uhs_v5
>>
>> Thanks, applied for next!
>
> OK. Ulf, can I use some commit id from your next as a base for
> the related dts changes?
>

No, I am re-basing my next branch from time to time so it's not a good idea.

Instead I have shared an immutable branch for your to pull/merge:
git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git sdhci_omap

I also signed the top commit on this branch: sdhci-omap-v4.17-rc3

The branch is based on 4.17-rc3.

Kind regards
Uffe

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

* Re: [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support
  2018-05-03  8:51     ` Ulf Hansson
@ 2018-05-03 14:12       ` Tony Lindgren
  0 siblings, 0 replies; 20+ messages in thread
From: Tony Lindgren @ 2018-05-03 14:12 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Kishon Vijay Abraham I, Adrian Hunter, Rob Herring, Mark Rutland,
	linux-mmc, devicetree, Linux Kernel Mailing List, linux-omap

* Ulf Hansson <ulf.hansson@linaro.org> [180503 08:53]:
> On 2 May 2018 at 16:55, Tony Lindgren <tony@atomide.com> wrote:
> > * Ulf Hansson <ulf.hansson@linaro.org> [180502 13:17]:
> >> On 27 April 2018 at 13:47, Kishon Vijay Abraham I <kishon@ti.com> wrote:
> >> > Add UHS/HS200 mode support in sdhci-omap. The programming sequence
> >> > for voltage switching, tuning is followed from AM572x TRM
> >> > http://www.ti.com/lit/ug/spruhz6j/spruhz6j.pdf
> >> > (Similar to all AM57x/DRA7x SoCs). The patch series also implements
> >> > workaround for errata published in
> >> > http://www.ti.com/lit/er/sprz429l/sprz429l.pdf
> >> >
> >> > patches are created on top of
> >> > git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next
> >> >
> >> > The patches along with dt has also been pushed to
> >> > https://github.com/kishon/linux-wip.git sdhci_uhs_v5
> >>
> >> Thanks, applied for next!
> >
> > OK. Ulf, can I use some commit id from your next as a base for
> > the related dts changes?
> >
> 
> No, I am re-basing my next branch from time to time so it's not a good idea.
> 
> Instead I have shared an immutable branch for your to pull/merge:
> git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git sdhci_omap
> 
> I also signed the top commit on this branch: sdhci-omap-v4.17-rc3
> 
> The branch is based on 4.17-rc3.

OK great, thanks a lot!

Tony

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

end of thread, other threads:[~2018-05-03 14:12 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-27 11:47 [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 01/14] mmc: sdhci-omap: Fix when capabilities are obtained from SDHCI_CAPABILITIES reg Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 02/14] mmc: sdhci-omap: Remove setting ADMA capability in driver Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 03/14] mmc: sdhci-omap: Workaround for Errata i843 Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 04/14] mmc: sdhci-omap: Invoke sdhci_get_of_property to read sdhci dt properties Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 05/14] mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't support 1.8v Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 06/14] mmc: sdhci: Add quirk to disable HW timeout Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 07/14] mmc: sdhci: Factor out target_timeout calculation Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 08/14] mmc: sdhci: Program a relatively accurate SW timeout value Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 09/14] mmc: sdhci-omap: Workaround for Errata i834 Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 10/14] dt-bindings: sdhci-omap: Add K2G specific binding Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 11/14] mmc: sdhci-omap: Add support for MMC/SD controller in k2g SoC Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 12/14] mmc: sdhci-omap: Add sdhci_omap specific ops for enable_sdio_irq Kishon Vijay Abraham I
2018-04-27 11:47 ` [PATCH v5 13/14] dt-bindings: sdhci-omap: Add pinctrl bindings Kishon Vijay Abraham I
2018-04-27 14:26   ` Rob Herring
2018-04-27 11:47 ` [PATCH v5 14/14] mmc: sdhci-omap: Get IODelay values for 3.3v DDR mode Kishon Vijay Abraham I
2018-05-02 13:15 ` [PATCH v5 00/14] mmc: sdhci-omap: Add UHS/HS200 mode support Ulf Hansson
2018-05-02 14:55   ` Tony Lindgren
2018-05-03  8:51     ` Ulf Hansson
2018-05-03 14:12       ` Tony Lindgren

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