All of lore.kernel.org
 help / color / mirror / Atom feed
* [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support
@ 2019-11-19 13:35 Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 01/31] mmc: tmio-mmc: add support for 32bit data port Biju Das
                   ` (32 more replies)
  0 siblings, 33 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

This patch series add SD/eMMC support support for RZ/G1C sbc.

RZ/G1C eMMC IP is different from other RZ/G1 SoC's. It is having an 
internal DMA for data transfer which is similar to R-Car Gen3.

Support for internal DMAC is added in 4.14 kernel and support for 
RZ/G1C added on 4.20 kernel.

Backported the relevent patches to linux-4.4.y-cip.

This patch series is based on linux-4.4.y-cip and all the patches
in this series are cherry-picked from linux rc tree.

V1-->V2
  * Incorporated pavel's review comments.
  https://lists.cip-project.org/pipermail/cip-dev/2019-November/003770.html

Ai Kyuse (3):
  mmc: tmio: enhance illegal sequence handling
  mmc: tmio: Add hw reset support
  mmc: tmio: Add tuning support

Chris Brandt (2):
  mmc: tmio-mmc: add support for 32bit data port
  mmc: sh_mobile_sdhi: add ocr_mask option

Masaharu Hayakawa (1):
  mmc: tmio: always get number of taps

Simon Horman (5):
  mmc: tmio: document mandatory and optional callbacks
  mmc: core: Add helper to see if a host can be retuned
  mmc: sh_mobile_sdhi: Add tuning support
  mmc: tmio: drop filenames from comment at top of source
  mmc: renesas-sdhi, tmio: make dma more modular

Ulf Hansson (1):
  mmc: tmio: Remove redundant check of mmc->slot.cd_irq

Wolfram Sang (19):
  mmc: tmio: fix wrong bitmask for SDIO irqs
  mmc: tmio: remove SDIO from TODO list
  mmc: tmio: use SDIO master interrupt bit only when allowed
  mmc: sh_mobile_sdhi: simplify accessing DT data
  mmc: sh_mobile_sdhi: improve prerequisite for hw_reset
  mmc: sh_mobile_sdhi: remove superfluous check in hw_reset
  mmc: sh_mobile_sdhi: improve prerequisites for tuning
  mmc: sh_mobile_sdhi: remove superfluous check in SCC error check
  mmc: sh_mobile_sdhi: remove superfluous check in init_tuning
  mmc: sh_mobile_sdhi: enable HS200
  mmc: host: tmio: drop superfluous exit path
  mmc: host: tmio: disable clocks when unbinding
  mmc: host: tmio: refactor calls to sdio irq
  mmc: host: tmio: SDIO_STATUS_QUIRK is rather SDIO_STATUS_SETBITS
  mmc: tmio: discard obsolete SDIO irqs before enabling irqs
  mmc: tmio: ensure end of DMA and SD access are in sync
  mmc: host: tmio: use defines for CTL_STOP_INTERNAL_ACTION values
  mmc: host: tmio: don't BUG on unsupported stop commands
  mmc: host: tmio: fill in response from auto cmd12

 drivers/mmc/host/Makefile         |   3 +-
 drivers/mmc/host/sh_mobile_sdhi.c | 267 ++++++++++++++++++++++++++++++++++++--
 drivers/mmc/host/tmio_mmc.c       |  10 +-
 drivers/mmc/host/tmio_mmc.h       | 102 +++++++++------
 drivers/mmc/host/tmio_mmc_dma.c   |  86 +++++++-----
 drivers/mmc/host/tmio_mmc_pio.c   | 248 ++++++++++++++++++++++++++++-------
 include/linux/mfd/tmio.h          |   7 +-
 include/linux/mmc/host.h          |   5 +
 8 files changed, 588 insertions(+), 140 deletions(-)

-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 01/31] mmc: tmio-mmc: add support for 32bit data port
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 02/31] mmc: sh_mobile_sdhi: add ocr_mask option Biju Das
                   ` (31 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Chris Brandt <chris.brandt@renesas.com>

commit 8185e51f358a8dd4801b67e8c66f03eb9eeaba75 upstream.

For the r7s72100 SOC, the DATA_PORT register was changed to 32-bits wide.
Therefore a new flag has been created that will allow 32-bit reads/writes
to the DATA_PORT register instead of 16-bit (because 16-bits accesses are
not supported).

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
[biju: backported the upstream commit 9c284c41c0886f09e75c323a16278b6d353b0b4a]
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc.h     | 12 ++++++++++++
 drivers/mmc/host/tmio_mmc_pio.c | 29 +++++++++++++++++++++++++++++
 include/linux/mfd/tmio.h        |  5 +++++
 3 files changed, 46 insertions(+)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index eafd92d..c4131d9 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -245,6 +245,12 @@ static inline u32 sd_ctrl_read16_and_16_as_32(struct tmio_mmc_host *host, int ad
 	       readw(host->ctl + ((addr + 2) << host->bus_shift)) << 16;
 }
 
+static inline void sd_ctrl_read32_rep(struct tmio_mmc_host *host, int addr,
+		u32 *buf, int count)
+{
+	readsl(host->ctl + (addr << host->bus_shift), buf, count);
+}
+
 static inline void sd_ctrl_write16(struct tmio_mmc_host *host, int addr, u16 val)
 {
 	/* If there is a hook and it returns non-zero then there
@@ -267,4 +273,10 @@ static inline void sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host, int
 	writew(val >> 16, host->ctl + ((addr + 2) << host->bus_shift));
 }
 
+static inline void sd_ctrl_write32_rep(struct tmio_mmc_host *host, int addr,
+		const u32 *buf, int count)
+{
+	writesl(host->ctl + (addr << host->bus_shift), buf, count);
+}
+
 #endif
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index c927916..2010372 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -393,6 +393,35 @@ static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
 	/*
 	 * Transfer the data
 	 */
+	if (host->pdata->flags & TMIO_MMC_32BIT_DATA_PORT) {
+		u32 data = 0;
+		u32 *buf32 = (u32 *)buf;
+
+		if (is_read)
+			sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, buf32,
+					   count >> 2);
+		else
+			sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, buf32,
+					    count >> 2);
+
+		/* if count was multiple of 4 */
+		if (!(count & 0x3))
+			return;
+
+		buf32 += count >> 2;
+		count %= 4;
+
+		if (is_read) {
+			sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, &data, 1);
+			memcpy(buf32, &data, count);
+		} else {
+			memcpy(&data, buf32, count);
+			sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, &data, 1);
+		}
+
+		return;
+	}
+
 	if (is_read)
 		sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
 	else
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index 7a26286..fba44ab 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -100,6 +100,11 @@
 #define TMIO_MMC_SDIO_STATUS_QUIRK	(1 << 8)
 
 /*
+ * Some controllers have a 32-bit wide data port register
+ */
+#define TMIO_MMC_32BIT_DATA_PORT	(1 << 9)
+
+/*
  * Some controllers allows to set SDx actual clock
  */
 #define TMIO_MMC_CLK_ACTUAL		(1 << 10)
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 02/31] mmc: sh_mobile_sdhi: add ocr_mask option
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 01/31] mmc: tmio-mmc: add support for 32bit data port Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 03/31] mmc: tmio: enhance illegal sequence handling Biju Das
                   ` (30 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Chris Brandt <chris.brandt@renesas.com>

commit f19417f38264f9a2f7b4627aa4060133c237b211 upstream.

In moving platforms from board files to DT, there still needs to be a way
to set the ocr_mask setting for the tmio driver during probe. Without this
setting, the probe will fail because the supported voltages are not known.

This patch will also traditional platform registration platforms to
migrate to DT.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 3d186cc..9124246 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -49,6 +49,7 @@
 
 struct sh_mobile_sdhi_of_data {
 	unsigned long tmio_flags;
+	u32	      tmio_ocr_mask;
 	unsigned long capabilities;
 	unsigned long capabilities2;
 	enum dma_slave_buswidth dma_buswidth;
@@ -370,6 +371,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 		const struct sh_mobile_sdhi_of_data *of_data = of_id->data;
 
 		mmc_data->flags |= of_data->tmio_flags;
+		mmc_data->ocr_mask = of_data->tmio_ocr_mask;
 		mmc_data->capabilities |= of_data->capabilities;
 		mmc_data->capabilities2 |= of_data->capabilities2;
 		mmc_data->dma_rx_offset = of_data->dma_rx_offset;
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 03/31] mmc: tmio: enhance illegal sequence handling
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 01/31] mmc: tmio-mmc: add support for 32bit data port Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 02/31] mmc: sh_mobile_sdhi: add ocr_mask option Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-21  0:41   ` Nobuhiro Iwamatsu
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 04/31] mmc: tmio: document mandatory and optional callbacks Biju Das
                   ` (29 subsequent siblings)
  32 siblings, 1 reply; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Ai Kyuse <ai.kyuse.uw@renesas.com>

commit 96e0b2ba00ee5dacb12bed6585145ce784ec9153 upstream.

An illegal sequence command error may occur if there is a stopbit or
cmd_index error as well as a CRC error. The correct course of action
is to re-enable IRQs

An illegal sequence data error may occur if there is a CRC or stopbit
error,  or underrun. In this case set data->error correctly.

This is in preparation for enabling tuning support which relies on
differentiating between illegal sequence and other errors.

Signed-off-by: Ai Kyuse <ai.kyuse.uw@renesas.com>
[simon: broken out of a larger patch]
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 2010372..0775a19 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -551,7 +551,7 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
 	schedule_work(&host->done);
 }
 
-static void tmio_mmc_data_irq(struct tmio_mmc_host *host)
+static void tmio_mmc_data_irq(struct tmio_mmc_host *host, unsigned int stat)
 {
 	struct mmc_data *data;
 	spin_lock(&host->lock);
@@ -560,6 +560,9 @@ static void tmio_mmc_data_irq(struct tmio_mmc_host *host)
 	if (!data)
 		goto out;
 
+	if (stat & TMIO_STAT_CRCFAIL || stat & TMIO_STAT_STOPBIT_ERR ||
+	    stat & TMIO_STAT_TXUNDERRUN)
+		data->error = -EILSEQ;
 	if (host->chan_tx && (data->flags & MMC_DATA_WRITE) && !host->force_pio) {
 		u32 status = sd_ctrl_read16_and_16_as_32(host, CTL_STATUS);
 		bool done = false;
@@ -608,8 +611,6 @@ static void tmio_mmc_cmd_irq(struct tmio_mmc_host *host,
 		goto out;
 	}
 
-	host->cmd = NULL;
-
 	/* This controller is sicker than the PXA one. Not only do we need to
 	 * drop the top 8 bits of the first response word, we also need to
 	 * modify the order of the response for short response command types.
@@ -629,14 +630,16 @@ static void tmio_mmc_cmd_irq(struct tmio_mmc_host *host,
 
 	if (stat & TMIO_STAT_CMDTIMEOUT)
 		cmd->error = -ETIMEDOUT;
-	else if (stat & TMIO_STAT_CRCFAIL && cmd->flags & MMC_RSP_CRC)
+	else if ((stat & TMIO_STAT_CRCFAIL && cmd->flags & MMC_RSP_CRC) ||
+		 stat & TMIO_STAT_STOPBIT_ERR ||
+		 stat & TMIO_STAT_CMD_IDX_ERR)
 		cmd->error = -EILSEQ;
 
 	/* If there is data to handle we enable data IRQs here, and
 	 * we will ultimatley finish the request in the data_end handler.
 	 * If theres no data or we encountered an error, finish now.
 	 */
-	if (host->data && !cmd->error) {
+	if (host->data && (!cmd->error || cmd->error == -EILSEQ)) {
 		if (host->data->flags & MMC_DATA_READ) {
 			if (host->force_pio || !host->chan_rx)
 				tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_READOP);
@@ -697,7 +700,7 @@ static bool __tmio_mmc_sdcard_irq(struct tmio_mmc_host *host,
 	/* Data transfer completion */
 	if (ireg & TMIO_STAT_DATAEND) {
 		tmio_mmc_ack_mmc_irqs(host, TMIO_STAT_DATAEND);
-		tmio_mmc_data_irq(host);
+		tmio_mmc_data_irq(host, status);
 		return true;
 	}
 
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 04/31] mmc: tmio: document mandatory and optional callbacks
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (2 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 03/31] mmc: tmio: enhance illegal sequence handling Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 05/31] mmc: tmio: Add hw reset support Biju Das
                   ` (28 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Simon Horman <horms+renesas@verge.net.au>

commit 2f87365f832bbc26e32f23588aaeb40abe15ff0d upstream.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index c4131d9..d3d24e1 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -154,8 +154,10 @@ struct tmio_mmc_host {
 	bool			native_hotplug;
 	bool			sdio_irq_enabled;
 
-	int (*write16_hook)(struct tmio_mmc_host *host, int addr);
+	/* Mandatory callback */
 	int (*clk_enable)(struct tmio_mmc_host *host);
+
+	/* Optional callbacks */
 	unsigned int (*clk_update)(struct tmio_mmc_host *host,
 				   unsigned int new_clock);
 	void (*clk_disable)(struct tmio_mmc_host *host);
@@ -164,6 +166,7 @@ struct tmio_mmc_host {
 	int (*card_busy)(struct mmc_host *mmc);
 	int (*start_signal_voltage_switch)(struct mmc_host *mmc,
 					   struct mmc_ios *ios);
+	int (*write16_hook)(struct tmio_mmc_host *host, int addr);
 };
 
 struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev);
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 05/31] mmc: tmio: Add hw reset support
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (3 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 04/31] mmc: tmio: document mandatory and optional callbacks Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 06/31] mmc: core: Add helper to see if a host can be retuned Biju Das
                   ` (27 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Ai Kyuse <ai.kyuse.uw@renesas.com>

commit e8f36b5d3b54a49df02c950050659a5082e2c880 upstream.

Add hw reset support.

Signed-off-by: Ai Kyuse <ai.kyuse.uw@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc.h     | 1 +
 drivers/mmc/host/tmio_mmc_pio.c | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index d3d24e1..8b4869e 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -167,6 +167,7 @@ struct tmio_mmc_host {
 	int (*start_signal_voltage_switch)(struct mmc_host *mmc,
 					   struct mmc_ios *ios);
 	int (*write16_hook)(struct tmio_mmc_host *host, int addr);
+	void (*hw_reset)(struct tmio_mmc_host *host);
 };
 
 struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev);
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 0775a19..8bc2ab6 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -791,6 +791,14 @@ static int tmio_mmc_start_data(struct tmio_mmc_host *host,
 	return 0;
 }
 
+static void tmio_mmc_hw_reset(struct mmc_host *mmc)
+{
+	struct tmio_mmc_host *host = mmc_priv(mmc);
+
+	if (host->hw_reset)
+		host->hw_reset(host);
+}
+
 /* Process requests from the MMC layer */
 static void tmio_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
 {
@@ -1007,6 +1015,7 @@ static struct mmc_host_ops tmio_mmc_ops = {
 	.get_cd		= mmc_gpio_get_cd,
 	.enable_sdio_irq = tmio_mmc_enable_sdio_irq,
 	.multi_io_quirk	= tmio_multi_io_quirk,
+	.hw_reset	= tmio_mmc_hw_reset,
 };
 
 static int tmio_mmc_init_ocr(struct tmio_mmc_host *host)
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 06/31] mmc: core: Add helper to see if a host can be retuned
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (4 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 05/31] mmc: tmio: Add hw reset support Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 07/31] mmc: tmio: Add tuning support Biju Das
                   ` (26 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Simon Horman <horms+renesas@verge.net.au>

commit c820af5f18ec248b3cb61a9a9ce47ef0f2e9ec63 upstream.

This is in preparation for restoring saved tuning parameters
when resuming the TMIO driver.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 include/linux/mmc/host.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 8673ffe..1c483d9 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -515,4 +515,9 @@ static inline void mmc_retune_recheck(struct mmc_host *host)
 		host->retune_now = 1;
 }
 
+static inline bool mmc_can_retune(struct mmc_host *host)
+{
+	return host->can_retune == 1;
+}
+
 #endif /* LINUX_MMC_HOST_H */
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 07/31] mmc: tmio: Add tuning support
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (5 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 06/31] mmc: core: Add helper to see if a host can be retuned Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 08/31] mmc: sh_mobile_sdhi: " Biju Das
                   ` (25 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Ai Kyuse <ai.kyuse.uw@renesas.com>

commit 4f11997773b6b452b5a0d620c5ac5050e75c227e upstream.

Add tuning support for use with SDR104 mode

Signed-off-by: Ai Kyuse <ai.kyuse.uw@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc.h     | 14 ++++++++++
 drivers/mmc/host/tmio_mmc_pio.c | 62 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 8b4869e..ba2838c 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -153,6 +153,7 @@ struct tmio_mmc_host {
 	struct mutex		ios_lock;	/* protect set_ios() context */
 	bool			native_hotplug;
 	bool			sdio_irq_enabled;
+	u32			scc_tappos;
 
 	/* Mandatory callback */
 	int (*clk_enable)(struct tmio_mmc_host *host);
@@ -168,6 +169,19 @@ struct tmio_mmc_host {
 					   struct mmc_ios *ios);
 	int (*write16_hook)(struct tmio_mmc_host *host, int addr);
 	void (*hw_reset)(struct tmio_mmc_host *host);
+	void (*prepare_tuning)(struct tmio_mmc_host *host, unsigned long tap);
+	bool (*check_scc_error)(struct tmio_mmc_host *host);
+
+	/*
+	 * Mandatory callback for tuning to occur which is optional for SDR50
+	 * and mandatory for SDR104.
+	 */
+	unsigned int (*init_tuning)(struct tmio_mmc_host *host);
+	int (*select_tuning)(struct tmio_mmc_host *host);
+
+	/* Tuning values: 1 for success, 0 for failure */
+	DECLARE_BITMAP(taps, BITS_PER_BYTE * sizeof(long));
+	unsigned int tap_num;
 };
 
 struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev);
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 8bc2ab6..b569ef3 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -36,6 +36,7 @@
 #include <linux/io.h>
 #include <linux/irq.h>
 #include <linux/mfd/tmio.h>
+#include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
 #include <linux/mmc/slot-gpio.h>
@@ -298,6 +299,9 @@ static void tmio_mmc_finish_request(struct tmio_mmc_host *host)
 	if (mrq->cmd->error || (mrq->data && mrq->data->error))
 		tmio_mmc_abort_dma(host);
 
+	if (host->check_scc_error)
+		host->check_scc_error(host);
+
 	mmc_request_done(host->mmc, mrq);
 }
 
@@ -799,6 +803,55 @@ static void tmio_mmc_hw_reset(struct mmc_host *mmc)
 		host->hw_reset(host);
 }
 
+static int tmio_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
+{
+	struct tmio_mmc_host *host = mmc_priv(mmc);
+	int i, ret = 0;
+
+	if (!host->tap_num) {
+		if (!host->init_tuning || !host->select_tuning)
+			/* Tuning is not supported */
+			goto out;
+
+		host->tap_num = host->init_tuning(host);
+		if (!host->tap_num)
+			/* Tuning is not supported */
+			goto out;
+	}
+
+	if (host->tap_num * 2 >= sizeof(host->taps) * BITS_PER_BYTE) {
+		dev_warn_once(&host->pdev->dev,
+		      "Too many taps, skipping tuning. Please consider updating size of taps field of tmio_mmc_host\n");
+		goto out;
+	}
+
+	bitmap_zero(host->taps, host->tap_num * 2);
+
+	/* Issue CMD19 twice for each tap */
+	for (i = 0; i < 2 * host->tap_num; i++) {
+		if (host->prepare_tuning)
+			host->prepare_tuning(host, i % host->tap_num);
+
+		ret = mmc_send_tuning(mmc, opcode, NULL);
+		if (ret && ret != -EILSEQ)
+			goto out;
+		if (ret == 0)
+			set_bit(i, host->taps);
+
+		mdelay(1);
+	}
+
+	ret = host->select_tuning(host);
+
+out:
+	if (ret < 0) {
+		dev_warn(&host->pdev->dev, "Tuning procedure failed\n");
+		tmio_mmc_hw_reset(mmc);
+	}
+
+	return ret;
+}
+
 /* Process requests from the MMC layer */
 static void tmio_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
 {
@@ -1016,6 +1069,7 @@ static struct mmc_host_ops tmio_mmc_ops = {
 	.enable_sdio_irq = tmio_mmc_enable_sdio_irq,
 	.multi_io_quirk	= tmio_multi_io_quirk,
 	.hw_reset	= tmio_mmc_hw_reset,
+	.execute_tuning = tmio_mmc_execute_tuning,
 };
 
 static int tmio_mmc_init_ocr(struct tmio_mmc_host *host)
@@ -1262,6 +1316,11 @@ int tmio_mmc_host_runtime_suspend(struct device *dev)
 }
 EXPORT_SYMBOL(tmio_mmc_host_runtime_suspend);
 
+static bool tmio_mmc_can_retune(struct tmio_mmc_host *host)
+{
+	return host->tap_num && mmc_can_retune(host->mmc);
+}
+
 int tmio_mmc_host_runtime_resume(struct device *dev)
 {
 	struct mmc_host *mmc = dev_get_drvdata(dev);
@@ -1275,6 +1334,9 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
 
 	tmio_mmc_enable_dma(host, true);
 
+	if (tmio_mmc_can_retune(host) && host->select_tuning(host))
+		dev_warn(&host->pdev->dev, "Tuning selection failed\n");
+
 	return 0;
 }
 EXPORT_SYMBOL(tmio_mmc_host_runtime_resume);
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 08/31] mmc: sh_mobile_sdhi: Add tuning support
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (6 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 07/31] mmc: tmio: Add tuning support Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 09/31] mmc: tmio: fix wrong bitmask for SDIO irqs Biju Das
                   ` (24 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Simon Horman <horms+renesas@verge.net.au>

commit 06f438dd389a699d27585f2a4d3685fd1ce05a75 upstream.

Add tuning support for use with SDR104 mode
This includes adding support for the sampling clock controller (SCC).

Based on work by Ai Kyuse.

Cc: Ai Kyuse <ai.kyuse.uw@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 265 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 264 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 9124246..d1ec75c 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -47,6 +47,11 @@
 
 #define host_to_priv(host) container_of((host)->pdata, struct sh_mobile_sdhi, mmc_data)
 
+struct sh_mobile_sdhi_scc {
+	unsigned long clk_rate;	/* clock rate for SDR104 */
+	u32 tap;		/* sampling clock position for SDR104 */
+};
+
 struct sh_mobile_sdhi_of_data {
 	unsigned long tmio_flags;
 	u32	      tmio_ocr_mask;
@@ -55,6 +60,9 @@ struct sh_mobile_sdhi_of_data {
 	enum dma_slave_buswidth dma_buswidth;
 	dma_addr_t dma_rx_offset;
 	unsigned bus_shift;
+	int scc_offset;
+	struct sh_mobile_sdhi_scc *taps;
+	int taps_num;
 };
 
 static const struct sh_mobile_sdhi_of_data sh_mobile_sdhi_of_cfg[] = {
@@ -69,12 +77,35 @@ static const struct sh_mobile_sdhi_of_data of_rcar_gen1_compatible = {
 	.capabilities	= MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
 };
 
+/* Definitions for sampling clocks */
+static struct sh_mobile_sdhi_scc rcar_gen2_scc_taps[] = {
+	{
+		.clk_rate = 156000000,
+		.tap = 0x00000703,
+	},
+	{
+		.clk_rate = 0,
+		.tap = 0x00000300,
+	},
+};
+
 static const struct sh_mobile_sdhi_of_data of_rcar_gen2_compatible = {
 	.tmio_flags	= TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE |
 			  TMIO_MMC_CLK_ACTUAL | TMIO_MMC_MIN_RCAR2,
 	.capabilities	= MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
 	.dma_buswidth	= DMA_SLAVE_BUSWIDTH_4_BYTES,
 	.dma_rx_offset	= 0x2000,
+	.scc_offset	= 0x0300,
+	.taps		= rcar_gen2_scc_taps,
+	.taps_num	= ARRAY_SIZE(rcar_gen2_scc_taps),
+};
+
+/* Definitions for sampling clocks */
+static struct sh_mobile_sdhi_scc rcar_gen3_scc_taps[] = {
+	{
+		.clk_rate = 0,
+		.tap = 0x00000300,
+	},
 };
 
 static const struct sh_mobile_sdhi_of_data of_rcar_gen3_compatible = {
@@ -82,6 +113,9 @@ static const struct sh_mobile_sdhi_of_data of_rcar_gen3_compatible = {
 			  TMIO_MMC_CLK_ACTUAL | TMIO_MMC_MIN_RCAR2,
 	.capabilities	= MMC_CAP_SD_HIGHSPEED,
 	.bus_shift	= 2,
+	.scc_offset	= 0x1000,
+	.taps		= rcar_gen3_scc_taps,
+	.taps_num	= ARRAY_SIZE(rcar_gen3_scc_taps),
 };
 
 static const struct of_device_id sh_mobile_sdhi_of_match[] = {
@@ -109,6 +143,7 @@ struct sh_mobile_sdhi {
 	struct tmio_mmc_dma dma_priv;
 	struct pinctrl *pinctrl;
 	struct pinctrl_state *pins_default, *pins_uhs;
+	void __iomem *scc_ctl;
 };
 
 static void sh_mobile_sdhi_sdbuf_width(struct tmio_mmc_host *host, int width)
@@ -263,6 +298,201 @@ static int sh_mobile_sdhi_start_signal_voltage_switch(struct mmc_host *mmc,
 	return 0;
 }
 
+/* SCC registers */
+#define SH_MOBILE_SDHI_SCC_DTCNTL	0x000
+#define SH_MOBILE_SDHI_SCC_TAPSET	0x002
+#define SH_MOBILE_SDHI_SCC_DT2FF	0x004
+#define SH_MOBILE_SDHI_SCC_CKSEL	0x006
+#define SH_MOBILE_SDHI_SCC_RVSCNTL	0x008
+#define SH_MOBILE_SDHI_SCC_RVSREQ	0x00A
+
+/* Definitions for values the SH_MOBILE_SDHI_SCC_DTCNTL register */
+#define SH_MOBILE_SDHI_SCC_DTCNTL_TAPEN		BIT(0)
+#define SH_MOBILE_SDHI_SCC_DTCNTL_TAPNUM_SHIFT	16
+#define SH_MOBILE_SDHI_SCC_DTCNTL_TAPNUM_MASK	0xff
+
+/* Definitions for values the SH_MOBILE_SDHI_SCC_CKSEL register */
+#define SH_MOBILE_SDHI_SCC_CKSEL_DTSEL		BIT(0)
+/* Definitions for values the SH_MOBILE_SDHI_SCC_RVSCNTL register */
+#define SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN	BIT(0)
+/* Definitions for values the SH_MOBILE_SDHI_SCC_RVSREQ register */
+#define SH_MOBILE_SDHI_SCC_RVSREQ_RVSERR	BIT(2)
+
+static inline u32 sd_scc_read32(struct tmio_mmc_host *host,
+				struct sh_mobile_sdhi *priv, int addr)
+{
+	return readl(priv->scc_ctl + (addr << host->bus_shift));
+}
+
+static inline void sd_scc_write32(struct tmio_mmc_host *host,
+				  struct sh_mobile_sdhi *priv,
+				  int addr, u32 val)
+{
+	writel(val, priv->scc_ctl + (addr << host->bus_shift));
+}
+
+static unsigned int sh_mobile_sdhi_init_tuning(struct tmio_mmc_host *host)
+{
+	struct sh_mobile_sdhi *priv;
+
+	if (!(host->mmc->caps & MMC_CAP_UHS_SDR104))
+		return 0;
+
+	priv = host_to_priv(host);
+
+	/* set sampling clock selection range */
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_DTCNTL,
+		       0x8 << SH_MOBILE_SDHI_SCC_DTCNTL_TAPNUM_SHIFT);
+
+	/* Initialize SCC */
+	sd_ctrl_write32_as_16_and_16(host, CTL_STATUS, 0x0);
+
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_DTCNTL,
+		       SH_MOBILE_SDHI_SCC_DTCNTL_TAPEN |
+		       sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_DTCNTL));
+
+	sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, ~CLK_CTL_SCLKEN &
+			sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));
+
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_CKSEL,
+		       SH_MOBILE_SDHI_SCC_CKSEL_DTSEL |
+		       sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_CKSEL));
+
+	sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN |
+			sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));
+
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL,
+		       ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &
+		       sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
+
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_DT2FF, host->scc_tappos);
+
+	/* Read TAPNUM */
+	return (sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_DTCNTL) >>
+		SH_MOBILE_SDHI_SCC_DTCNTL_TAPNUM_SHIFT) &
+		SH_MOBILE_SDHI_SCC_DTCNTL_TAPNUM_MASK;
+}
+
+static void sh_mobile_sdhi_prepare_tuning(struct tmio_mmc_host *host,
+					 unsigned long tap)
+{
+	struct sh_mobile_sdhi *priv = host_to_priv(host);
+
+	/* Set sampling clock position */
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET, tap);
+}
+
+#define SH_MOBILE_SDHI_MAX_TAP 3
+
+static int sh_mobile_sdhi_select_tuning(struct tmio_mmc_host *host)
+{
+	struct sh_mobile_sdhi *priv = host_to_priv(host);
+	unsigned long tap_cnt;  /* counter of tuning success */
+	unsigned long tap_set;  /* tap position */
+	unsigned long tap_start;/* start position of tuning success */
+	unsigned long tap_end;  /* end position of tuning success */
+	unsigned long ntap;     /* temporary counter of tuning success */
+	unsigned long i;
+
+	/* Clear SCC_RVSREQ */
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSREQ, 0);
+
+	/*
+	 * Find the longest consecutive run of successful probes.  If that
+	 * is more than SH_MOBILE_SDHI_MAX_TAP probes long then use the
+	 * center index as the tap.
+	 */
+	tap_cnt = 0;
+	ntap = 0;
+	tap_start = 0;
+	tap_end = 0;
+	for (i = 0; i < host->tap_num * 2; i++) {
+		if (test_bit(i, host->taps))
+			ntap++;
+		else {
+			if (ntap > tap_cnt) {
+				tap_start = i - ntap;
+				tap_end = i - 1;
+				tap_cnt = ntap;
+			}
+			ntap = 0;
+		}
+	}
+
+	if (ntap > tap_cnt) {
+		tap_start = i - ntap;
+		tap_end = i - 1;
+		tap_cnt = ntap;
+	}
+
+	if (tap_cnt >= SH_MOBILE_SDHI_MAX_TAP)
+		tap_set = (tap_start + tap_end) / 2 % host->tap_num;
+	else
+		return -EIO;
+
+	/* Set SCC */
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET, tap_set);
+
+	/* Enable auto re-tuning */
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL,
+		       SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN |
+		       sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
+
+	return 0;
+}
+
+
+static bool sh_mobile_sdhi_check_scc_error(struct tmio_mmc_host *host)
+{
+	struct sh_mobile_sdhi *priv;
+
+	if (!(host->mmc->caps & MMC_CAP_UHS_SDR104))
+		return 0;
+
+	priv = host_to_priv(host);
+
+	/* Check SCC error */
+	if (sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL) &
+	    SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &&
+	    sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSREQ) &
+	    SH_MOBILE_SDHI_SCC_RVSREQ_RVSERR) {
+		/* Clear SCC error */
+		sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSREQ, 0);
+		return true;
+	}
+
+	return false;
+}
+
+static void sh_mobile_sdhi_hw_reset(struct tmio_mmc_host *host)
+{
+	struct sh_mobile_sdhi *priv;
+
+	if (!(host->mmc->caps & MMC_CAP_UHS_SDR104))
+		return;
+
+	priv = host_to_priv(host);
+
+	/* Reset SCC */
+	sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, ~CLK_CTL_SCLKEN &
+			sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));
+
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_CKSEL,
+		       ~SH_MOBILE_SDHI_SCC_CKSEL_DTSEL &
+		       sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_CKSEL));
+
+	sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN |
+			sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));
+
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL,
+		       ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &
+		       sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
+
+	sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL,
+		       ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &
+		       sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
+}
+
 static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host *host)
 {
 	int timeout = 1000;
@@ -332,7 +562,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 	struct tmio_mmc_data *mmd = pdev->dev.platform_data;
 	struct tmio_mmc_host *host;
 	struct resource *res;
-	int irq, ret, i = 0;
+	int irq, ret, i;
 	struct tmio_mmc_dma *dma_priv;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -392,6 +622,11 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 		host->card_busy	= sh_mobile_sdhi_card_busy;
 		host->start_signal_voltage_switch =
 			sh_mobile_sdhi_start_signal_voltage_switch;
+		host->init_tuning	= sh_mobile_sdhi_init_tuning;
+		host->prepare_tuning	= sh_mobile_sdhi_prepare_tuning;
+		host->select_tuning	= sh_mobile_sdhi_select_tuning;
+		host->check_scc_error	= sh_mobile_sdhi_check_scc_error;
+		host->hw_reset		= sh_mobile_sdhi_hw_reset;
 	}
 
 	/* Orginally registers were 16 bit apart, could be 32 or 64 nowadays */
@@ -432,6 +667,34 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto efree;
 
+	if (host->mmc->caps & MMC_CAP_UHS_SDR104) {
+		host->mmc->caps |= MMC_CAP_HW_RESET;
+
+		if (of_id && of_id->data) {
+			const struct sh_mobile_sdhi_of_data *of_data;
+			const struct sh_mobile_sdhi_scc *taps;
+			bool hit = false;
+
+			of_data = of_id->data;
+			taps = of_data->taps;
+
+			for (i = 0; i < of_data->taps_num; i++) {
+				if (taps[i].clk_rate == 0 ||
+				    taps[i].clk_rate == host->mmc->f_max) {
+					host->scc_tappos = taps->tap;
+					hit = true;
+					break;
+				}
+			}
+
+			if (!hit)
+				dev_warn(&host->pdev->dev, "Unknown clock rate for SDR104\n");
+
+			priv->scc_ctl = host->ctl + of_data->scc_offset;
+		}
+	}
+
+	i = 0;
 	while (1) {
 		irq = platform_get_irq(pdev, i);
 		if (irq < 0)
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 09/31] mmc: tmio: fix wrong bitmask for SDIO irqs
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (7 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 08/31] mmc: sh_mobile_sdhi: " Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 10/31] mmc: tmio: remove SDIO from TODO list Biju Das
                   ` (23 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit 0c4bf5beff79fd32c5a3b2b511ed6527861ada18 upstream.

Commit 7729c7a232a953 ("mmc: tmio: Provide separate interrupt handlers")
refactored the sdio irq handler and wrongly used the mask for SD irqs,
not for SDIO irqs. This doesn't really matter in practice because both
values keep the only interrupt we are interested in. But still, this is
wrong and wants to be fixed.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index b569ef3..5460fda 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -723,7 +723,7 @@ static bool tmio_mmc_sdio_irq(int irq, void *devid)
 		return false;
 
 	status = sd_ctrl_read16(host, CTL_SDIO_STATUS);
-	ireg = status & TMIO_SDIO_MASK_ALL & ~host->sdcard_irq_mask;
+	ireg = status & TMIO_SDIO_MASK_ALL & ~host->sdio_irq_mask;
 
 	sdio_status = status & ~TMIO_SDIO_MASK_ALL;
 	if (pdata->flags & TMIO_MMC_SDIO_STATUS_QUIRK)
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 10/31] mmc: tmio: remove SDIO from TODO list
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (8 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 09/31] mmc: tmio: fix wrong bitmask for SDIO irqs Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 11/31] mmc: tmio: use SDIO master interrupt bit only when allowed Biju Das
                   ` (22 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit e726e8c959fc735473f248e142de4d4f77ed342b upstream.

We surely have SDIO support by now :)

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 5460fda..13afe1f 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -22,7 +22,6 @@
  * TODO:
  *   Investigate using a workqueue for PIO transfers
  *   Eliminate FIXMEs
- *   SDIO support
  *   Better Power management
  *   Handle MMC errors better
  *   double buffer support
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 11/31] mmc: tmio: use SDIO master interrupt bit only when allowed
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (9 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 10/31] mmc: tmio: remove SDIO from TODO list Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 12/31] mmc: sh_mobile_sdhi: simplify accessing DT data Biju Das
                   ` (21 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit c51ff6c6180e76a1ba96aef799a9c41aa80fcc95 upstream.

The master bit to enable SDIO interrupts can only be accessed if
SCLKDIVEN bit allows that. However, the core uses the SDIO enable
callback at times when SCLKDIVEN forbids the change. This leads to
"timeout waiting for SD bus idle" messages.

We now activate the master bit in probe once if SDIO is supported. IRQ
en-/disabling will be done now by the individual IRQ enablement bits
only.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Yasushi SHOJI <yashi@atmark-techno.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 13afe1f..9854d0f 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -140,12 +140,10 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 
 		host->sdio_irq_mask = TMIO_SDIO_MASK_ALL &
 					~TMIO_SDIO_STAT_IOIRQ;
-		sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
 		sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
 	} else if (!enable && host->sdio_irq_enabled) {
 		host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
 		sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
-		sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0000);
 
 		host->sdio_irq_enabled = false;
 		pm_runtime_mark_last_busy(mmc_dev(mmc));
@@ -1234,7 +1232,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 	if (pdata->flags & TMIO_MMC_SDIO_IRQ) {
 		_host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
 		sd_ctrl_write16(_host, CTL_SDIO_IRQ_MASK, _host->sdio_irq_mask);
-		sd_ctrl_write16(_host, CTL_TRANSACTION_CTL, 0x0000);
+		sd_ctrl_write16(_host, CTL_TRANSACTION_CTL, 0x0001);
 	}
 
 	spin_lock_init(&_host->lock);
@@ -1282,6 +1280,9 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
 	struct platform_device *pdev = host->pdev;
 	struct mmc_host *mmc = host->mmc;
 
+	if (host->pdata->flags & TMIO_MMC_SDIO_IRQ)
+		sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0000);
+
 	if (!host->native_hotplug)
 		pm_runtime_get_sync(&pdev->dev);
 
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 12/31] mmc: sh_mobile_sdhi: simplify accessing DT data
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (10 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 11/31] mmc: tmio: use SDIO master interrupt bit only when allowed Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 13/31] mmc: sh_mobile_sdhi: improve prerequisite for hw_reset Biju Das
                   ` (20 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit dc9f1a8d790ee766c47eca163261225680691e64 upstream.

By using the helper of_device_get_match_data(), we can skip some
checking and make the code simpler.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index d1ec75c..9af62dd 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -555,8 +555,7 @@ static void sh_mobile_sdhi_enable_dma(struct tmio_mmc_host *host, bool enable)
 
 static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *of_id =
-		of_match_device(sh_mobile_sdhi_of_match, &pdev->dev);
+	const struct sh_mobile_sdhi_of_data *of_data = of_device_get_match_data(&pdev->dev);
 	struct sh_mobile_sdhi *priv;
 	struct tmio_mmc_data *mmc_data;
 	struct tmio_mmc_data *mmd = pdev->dev.platform_data;
@@ -597,9 +596,8 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 		goto eprobe;
 	}
 
-	if (of_id && of_id->data) {
-		const struct sh_mobile_sdhi_of_data *of_data = of_id->data;
 
+	if (of_data) {
 		mmc_data->flags |= of_data->tmio_flags;
 		mmc_data->ocr_mask = of_data->tmio_ocr_mask;
 		mmc_data->capabilities |= of_data->capabilities;
@@ -670,14 +668,10 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 	if (host->mmc->caps & MMC_CAP_UHS_SDR104) {
 		host->mmc->caps |= MMC_CAP_HW_RESET;
 
-		if (of_id && of_id->data) {
-			const struct sh_mobile_sdhi_of_data *of_data;
-			const struct sh_mobile_sdhi_scc *taps;
+		if (of_data) {
+			const struct sh_mobile_sdhi_scc *taps = of_data->taps;
 			bool hit = false;
 
-			of_data = of_id->data;
-			taps = of_data->taps;
-
 			for (i = 0; i < of_data->taps_num; i++) {
 				if (taps[i].clk_rate == 0 ||
 				    taps[i].clk_rate == host->mmc->f_max) {
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 13/31] mmc: sh_mobile_sdhi: improve prerequisite for hw_reset
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (11 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 12/31] mmc: sh_mobile_sdhi: simplify accessing DT data Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 14/31] mmc: sh_mobile_sdhi: remove superfluous check in hw_reset Biju Das
                   ` (19 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit 6ade9a2c2da855ff38e74c4298976400feca968e upstream.

We need a SCC unit for hw_reset. Those units can only be described in
of_data. So, of_data and a valid SCC offset are prerequisites for
enabling the hw_reset capability. Merge the two 'if' conditions into one
and add a check for an scc offset.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 9af62dd..9bf1f5e 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -665,27 +665,25 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto efree;
 
-	if (host->mmc->caps & MMC_CAP_UHS_SDR104) {
+	if (of_data && of_data->scc_offset && host->mmc->caps & MMC_CAP_UHS_SDR104) {
+		const struct sh_mobile_sdhi_scc *taps = of_data->taps;
+		bool hit = false;
+
 		host->mmc->caps |= MMC_CAP_HW_RESET;
 
-		if (of_data) {
-			const struct sh_mobile_sdhi_scc *taps = of_data->taps;
-			bool hit = false;
-
-			for (i = 0; i < of_data->taps_num; i++) {
-				if (taps[i].clk_rate == 0 ||
-				    taps[i].clk_rate == host->mmc->f_max) {
-					host->scc_tappos = taps->tap;
-					hit = true;
-					break;
-				}
+		for (i = 0; i < of_data->taps_num; i++) {
+			if (taps[i].clk_rate == 0 ||
+			    taps[i].clk_rate == host->mmc->f_max) {
+				host->scc_tappos = taps->tap;
+				hit = true;
+				break;
 			}
+		}
 
-			if (!hit)
-				dev_warn(&host->pdev->dev, "Unknown clock rate for SDR104\n");
+		if (!hit)
+			dev_warn(&host->pdev->dev, "Unknown clock rate for SDR104\n");
 
-			priv->scc_ctl = host->ctl + of_data->scc_offset;
-		}
+		priv->scc_ctl = host->ctl + of_data->scc_offset;
 	}
 
 	i = 0;
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 14/31] mmc: sh_mobile_sdhi: remove superfluous check in hw_reset
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (12 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 13/31] mmc: sh_mobile_sdhi: improve prerequisite for hw_reset Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 15/31] mmc: sh_mobile_sdhi: improve prerequisites for tuning Biju Das
                   ` (18 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit 97c64b2cd57608f7064810780056d17944f49128 upstream.

The capability for HW_RESET is only activated if SDR104 is present, so
no need to check for SDR104 in the function itself again.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 9bf1f5e..d3d1db0 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -468,9 +468,6 @@ static void sh_mobile_sdhi_hw_reset(struct tmio_mmc_host *host)
 {
 	struct sh_mobile_sdhi *priv;
 
-	if (!(host->mmc->caps & MMC_CAP_UHS_SDR104))
-		return;
-
 	priv = host_to_priv(host);
 
 	/* Reset SCC */
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 15/31] mmc: sh_mobile_sdhi: improve prerequisites for tuning
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (13 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 14/31] mmc: sh_mobile_sdhi: remove superfluous check in hw_reset Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 16/31] mmc: sh_mobile_sdhi: remove superfluous check in SCC error check Biju Das
                   ` (17 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit e831ead3b3ddc4227cef10dc63d919fd7242d7b8 upstream.

Prerequisites for tuning are the same as for hw_reset. We need an SCC
and a supported mode. Populate the tuning related functions only when
those conditions are met. This also removes a tiny race window.
Previously, the functions were populated when the SCC offset was not
initialized which could have led to an OOPS.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index d3d1db0..30956c7 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -617,11 +617,6 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 		host->card_busy	= sh_mobile_sdhi_card_busy;
 		host->start_signal_voltage_switch =
 			sh_mobile_sdhi_start_signal_voltage_switch;
-		host->init_tuning	= sh_mobile_sdhi_init_tuning;
-		host->prepare_tuning	= sh_mobile_sdhi_prepare_tuning;
-		host->select_tuning	= sh_mobile_sdhi_select_tuning;
-		host->check_scc_error	= sh_mobile_sdhi_check_scc_error;
-		host->hw_reset		= sh_mobile_sdhi_hw_reset;
 	}
 
 	/* Orginally registers were 16 bit apart, could be 32 or 64 nowadays */
@@ -662,6 +657,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto efree;
 
+	/* Enable tuning iff we have an SCC and a supported mode */
 	if (of_data && of_data->scc_offset && host->mmc->caps & MMC_CAP_UHS_SDR104) {
 		const struct sh_mobile_sdhi_scc *taps = of_data->taps;
 		bool hit = false;
@@ -681,6 +677,11 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 			dev_warn(&host->pdev->dev, "Unknown clock rate for SDR104\n");
 
 		priv->scc_ctl = host->ctl + of_data->scc_offset;
+		host->init_tuning = sh_mobile_sdhi_init_tuning;
+		host->prepare_tuning = sh_mobile_sdhi_prepare_tuning;
+		host->select_tuning = sh_mobile_sdhi_select_tuning;
+		host->check_scc_error = sh_mobile_sdhi_check_scc_error;
+		host->hw_reset = sh_mobile_sdhi_hw_reset;
 	}
 
 	i = 0;
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 16/31] mmc: sh_mobile_sdhi: remove superfluous check in SCC error check
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (14 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 15/31] mmc: sh_mobile_sdhi: improve prerequisites for tuning Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 17/31] mmc: sh_mobile_sdhi: remove superfluous check in init_tuning Biju Das
                   ` (16 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit 03c5b0d90300fc725fc1fb644872b522483a2d7e upstream.

The function will only be available if SDR104 was detected in probe,
so no need to check in the function itself again.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 30956c7..59cc513 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -444,12 +444,7 @@ static int sh_mobile_sdhi_select_tuning(struct tmio_mmc_host *host)
 
 static bool sh_mobile_sdhi_check_scc_error(struct tmio_mmc_host *host)
 {
-	struct sh_mobile_sdhi *priv;
-
-	if (!(host->mmc->caps & MMC_CAP_UHS_SDR104))
-		return 0;
-
-	priv = host_to_priv(host);
+	struct sh_mobile_sdhi *priv = host_to_priv(host);
 
 	/* Check SCC error */
 	if (sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL) &
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 17/31] mmc: sh_mobile_sdhi: remove superfluous check in init_tuning
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (15 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 16/31] mmc: sh_mobile_sdhi: remove superfluous check in SCC error check Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 18/31] mmc: sh_mobile_sdhi: enable HS200 Biju Das
                   ` (15 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit 7f9096f1c89ea698c22fde91285de2ef3eabd614 upstream.

The function will only be available if SDR104 was detected in probe,
so no need to check in the function itself again.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 59cc513..d851535 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -335,9 +335,6 @@ static unsigned int sh_mobile_sdhi_init_tuning(struct tmio_mmc_host *host)
 {
 	struct sh_mobile_sdhi *priv;
 
-	if (!(host->mmc->caps & MMC_CAP_UHS_SDR104))
-		return 0;
-
 	priv = host_to_priv(host);
 
 	/* set sampling clock selection range */
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 18/31] mmc: sh_mobile_sdhi: enable HS200
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (16 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 17/31] mmc: sh_mobile_sdhi: remove superfluous check in init_tuning Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 19/31] mmc: host: tmio: drop superfluous exit path Biju Das
                   ` (14 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit b1c95170f97ef19ff63a6da1eb2c70899186aecc upstream.

Setup tuning when the board is HS200 enabled.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index d851535..8e90670 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -650,7 +650,9 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 		goto efree;
 
 	/* Enable tuning iff we have an SCC and a supported mode */
-	if (of_data && of_data->scc_offset && host->mmc->caps & MMC_CAP_UHS_SDR104) {
+	if (of_data && of_data->scc_offset &&
+	    (host->mmc->caps & MMC_CAP_UHS_SDR104 ||
+	     host->mmc->caps2 & MMC_CAP2_HS200_1_8V_SDR)) {
 		const struct sh_mobile_sdhi_scc *taps = of_data->taps;
 		bool hit = false;
 
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 19/31] mmc: host: tmio: drop superfluous exit path
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (17 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 18/31] mmc: sh_mobile_sdhi: enable HS200 Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 20/31] mmc: tmio: Remove redundant check of mmc->slot.cd_irq Biju Das
                   ` (13 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit ad7014b3949b6c2b6ce46a546d6d204b5643e621 upstream.

The probe exit path on error does nothing since commit 94b110aff8679b
("mmc: tmio: add tmio_mmc_host_alloc/free()"), so we can bail out
immediately.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 9854d0f..2736edf 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1145,7 +1145,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 
 	ret = mmc_of_parse(mmc);
 	if (ret < 0)
-		goto host_free;
+		return ret;
 
 	_host->pdata = pdata;
 	platform_set_drvdata(pdev, mmc);
@@ -1155,14 +1155,12 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 
 	ret = tmio_mmc_init_ocr(_host);
 	if (ret < 0)
-		goto host_free;
+		return ret;
 
 	_host->ctl = devm_ioremap(&pdev->dev,
 				  res_ctl->start, resource_size(res_ctl));
-	if (!_host->ctl) {
-		ret = -ENOMEM;
-		goto host_free;
-	}
+	if (!_host->ctl)
+		return -ENOMEM;
 
 	tmio_mmc_ops.card_busy = _host->card_busy;
 	tmio_mmc_ops.start_signal_voltage_switch = _host->start_signal_voltage_switch;
@@ -1200,10 +1198,8 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 	 * Check the sanity of mmc->f_min to prevent tmio_mmc_set_clock() from
 	 * looping forever...
 	 */
-	if (mmc->f_min == 0) {
-		ret = -EINVAL;
-		goto host_free;
-	}
+	if (mmc->f_min == 0)
+		return -EINVAL;
 
 	/*
 	 * While using internal tmio hardware logic for card detection, we need
@@ -1268,10 +1264,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 	}
 
 	return 0;
-
-host_free:
-
-	return ret;
 }
 EXPORT_SYMBOL(tmio_mmc_host_probe);
 
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 20/31] mmc: tmio: Remove redundant check of mmc->slot.cd_irq
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (18 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 19/31] mmc: host: tmio: drop superfluous exit path Biju Das
@ 2019-11-19 13:35 ` Biju Das
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 21/31] mmc: host: tmio: disable clocks when unbinding Biju Das
                   ` (12 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:35 UTC (permalink / raw)
  To: cip-dev

From: Ulf Hansson <ulf.hansson@linaro.org>

commit efd7be7bfc8eb8942ba3dc319f323cfd0eda99e2 upstream.

To validate whether native hotplug needs to be used, the tmio driver checks
whether the mmc->slot.cd_irq has been successfully assigned.

This check is redundant at its current place in tmio_mmc_host_probe(), as
the mmc core assigns mmc->slot.cd_irq a valid value first when
mmc_gpiod_request_cd_irq() is called. Therefore, let's just remove the
check for now, as that also removes a layering violation of the tmio driver
accessing core specific data via ->slot.cd_irq.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 2736edf..14a094c 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1177,8 +1177,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 
 	_host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD ||
 				  mmc->caps & MMC_CAP_NEEDS_POLL ||
-				  mmc->caps & MMC_CAP_NONREMOVABLE ||
-				  mmc->slot.cd_irq >= 0);
+				  !mmc_card_is_removable(mmc));
 
 	/*
 	 * On Gen2+, eMMC with NONREMOVABLE currently fails because native
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 21/31] mmc: host: tmio: disable clocks when unbinding
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (19 preceding siblings ...)
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 20/31] mmc: tmio: Remove redundant check of mmc->slot.cd_irq Biju Das
@ 2019-11-19 13:36 ` Biju Das
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 22/31] mmc: host: tmio: refactor calls to sdio irq Biju Das
                   ` (11 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:36 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit dfcba5ffca989749d1fc49d5b82a2d007b1295b7 upstream.

Create a helper function to disable clocks and use it in remove(), too.
Now, clk_summary in debugfs reports the clocks as disabled and
unprepared after unbinding.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 14a094c..eaed795 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -902,6 +902,12 @@ static int tmio_mmc_clk_enable(struct tmio_mmc_host *host)
 	return host->clk_enable(host);
 }
 
+static void tmio_mmc_clk_disable(struct tmio_mmc_host *host)
+{
+	if (host->clk_disable)
+		host->clk_disable(host);
+}
+
 static void tmio_mmc_power_on(struct tmio_mmc_host *host, unsigned short vdd)
 {
 	struct mmc_host *mmc = host->mmc;
@@ -1286,6 +1292,8 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
 
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
+
+	tmio_mmc_clk_disable(host);
 }
 EXPORT_SYMBOL(tmio_mmc_host_remove);
 
@@ -1300,8 +1308,7 @@ int tmio_mmc_host_runtime_suspend(struct device *dev)
 	if (host->clk_cache)
 		tmio_mmc_clk_stop(host);
 
-	if (host->clk_disable)
-		host->clk_disable(host);
+	tmio_mmc_clk_disable(host);
 
 	return 0;
 }
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 22/31] mmc: host: tmio: refactor calls to sdio irq
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (20 preceding siblings ...)
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 21/31] mmc: host: tmio: disable clocks when unbinding Biju Das
@ 2019-11-19 13:36 ` Biju Das
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 23/31] mmc: host: tmio: SDIO_STATUS_QUIRK is rather SDIO_STATUS_SETBITS Biju Das
                   ` (10 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:36 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit e4f38eb18aedd098b3019e82df07f583a5cbcc58 upstream.

tmio_mmc_sdio_irq() is not used as a seperate irq handler anymore, so we
can make it similar to the other irq helper functions, namely:

* only give the host as argument function which is what it really needs
* prefix function name with __

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index eaed795..09574e5 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -708,9 +708,8 @@ static bool __tmio_mmc_sdcard_irq(struct tmio_mmc_host *host,
 	return false;
 }
 
-static bool tmio_mmc_sdio_irq(int irq, void *devid)
+static bool __tmio_mmc_sdio_irq(struct tmio_mmc_host *host)
 {
-	struct tmio_mmc_host *host = devid;
 	struct mmc_host *mmc = host->mmc;
 	struct tmio_mmc_data *pdata = host->pdata;
 	unsigned int ireg, status;
@@ -753,7 +752,7 @@ irqreturn_t tmio_mmc_irq(int irq, void *devid)
 	if (__tmio_mmc_sdcard_irq(host, ireg, status))
 		return IRQ_HANDLED;
 
-	if (tmio_mmc_sdio_irq(irq, devid))
+	if (__tmio_mmc_sdio_irq(host))
 		return IRQ_HANDLED;
 
 	return IRQ_NONE;
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 23/31] mmc: host: tmio: SDIO_STATUS_QUIRK is rather SDIO_STATUS_SETBITS
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (21 preceding siblings ...)
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 22/31] mmc: host: tmio: refactor calls to sdio irq Biju Das
@ 2019-11-19 13:36 ` Biju Das
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 24/31] mmc: tmio: discard obsolete SDIO irqs before enabling irqs Biju Das
                   ` (9 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:36 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit 20dd03734cac41a0545dd24f5e81d8ff0c80874b upstream.

QUIRK sounds like there is something wrong, but actually there are just
some bits which need to be 1. Rename it to be more clear.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 6 ++----
 drivers/mmc/host/tmio_mmc_pio.c   | 2 +-
 include/linux/mfd/tmio.h          | 6 ++----
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 8e90670..a723550 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -640,10 +640,8 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 	 */
 	mmc_data->flags |= TMIO_MMC_HAVE_CMD12_CTRL;
 
-	/*
-	 * All SDHI need SDIO_INFO1 reserved bit
-	 */
-	mmc_data->flags |= TMIO_MMC_SDIO_STATUS_QUIRK;
+	/* All SDHI have SDIO status bits which must be 1 */
+	mmc_data->flags |= TMIO_MMC_SDIO_STATUS_SETBITS;
 
 	ret = tmio_mmc_host_probe(host, mmc_data);
 	if (ret < 0)
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 09574e5..32f6cb8 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -722,7 +722,7 @@ static bool __tmio_mmc_sdio_irq(struct tmio_mmc_host *host)
 	ireg = status & TMIO_SDIO_MASK_ALL & ~host->sdio_irq_mask;
 
 	sdio_status = status & ~TMIO_SDIO_MASK_ALL;
-	if (pdata->flags & TMIO_MMC_SDIO_STATUS_QUIRK)
+	if (pdata->flags & TMIO_MMC_SDIO_STATUS_SETBITS)
 		sdio_status |= 6;
 
 	sd_ctrl_write16(host, CTL_SDIO_STATUS, sdio_status);
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index fba44ab..a1520d8 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -94,10 +94,8 @@
  */
 #define TMIO_MMC_HAVE_CMD12_CTRL	(1 << 7)
 
-/*
- * Some controllers needs to set 1 on SDIO status reserved bits
- */
-#define TMIO_MMC_SDIO_STATUS_QUIRK	(1 << 8)
+/* Controller has some SDIO status bits which must be 1 */
+#define TMIO_MMC_SDIO_STATUS_SETBITS	(1 << 8)
 
 /*
  * Some controllers have a 32-bit wide data port register
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 24/31] mmc: tmio: discard obsolete SDIO irqs before enabling irqs
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (22 preceding siblings ...)
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 23/31] mmc: host: tmio: SDIO_STATUS_QUIRK is rather SDIO_STATUS_SETBITS Biju Das
@ 2019-11-19 13:36 ` Biju Das
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 25/31] mmc: tmio: ensure end of DMA and SD access are in sync Biju Das
                   ` (8 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:36 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit ee28981535f4261ed5d127ddf4d1a3f8778f520d upstream.

Before enabling SDIO irqs, clear the status bit, so we discard old and
stale interrupts. Needed to get two wireless cards working. Use the
newly introduced macro in all places.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc.h     |  2 ++
 drivers/mmc/host/tmio_mmc_pio.c | 13 +++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index ba2838c..e414670 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -90,6 +90,8 @@
 #define TMIO_SDIO_STAT_EXWT	0x8000
 #define TMIO_SDIO_MASK_ALL	0xc007
 
+#define TMIO_SDIO_SETBITS_MASK	0x0006
+
 /* Define some IRQ masks */
 /* This is the mask used at reset by the chip */
 #define TMIO_MASK_ALL           0x837f031d
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 32f6cb8..3ec58b44 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -134,12 +134,21 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 	struct tmio_mmc_host *host = mmc_priv(mmc);
 
 	if (enable && !host->sdio_irq_enabled) {
+		u16 sdio_status;
+
 		/* Keep device active while SDIO irq is enabled */
 		pm_runtime_get_sync(mmc_dev(mmc));
-		host->sdio_irq_enabled = true;
 
+		host->sdio_irq_enabled = true;
 		host->sdio_irq_mask = TMIO_SDIO_MASK_ALL &
 					~TMIO_SDIO_STAT_IOIRQ;
+
+		/* Clear obsolete interrupts before enabling */
+		sdio_status = sd_ctrl_read16(host, CTL_SDIO_STATUS) & ~TMIO_SDIO_MASK_ALL;
+		if (host->pdata->flags & TMIO_MMC_SDIO_STATUS_SETBITS)
+			sdio_status |= TMIO_SDIO_SETBITS_MASK;
+		sd_ctrl_write16(host, CTL_SDIO_STATUS, sdio_status);
+
 		sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
 	} else if (!enable && host->sdio_irq_enabled) {
 		host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
@@ -723,7 +732,7 @@ static bool __tmio_mmc_sdio_irq(struct tmio_mmc_host *host)
 
 	sdio_status = status & ~TMIO_SDIO_MASK_ALL;
 	if (pdata->flags & TMIO_MMC_SDIO_STATUS_SETBITS)
-		sdio_status |= 6;
+		sdio_status |= TMIO_SDIO_SETBITS_MASK;
 
 	sd_ctrl_write16(host, CTL_SDIO_STATUS, sdio_status);
 
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 25/31] mmc: tmio: ensure end of DMA and SD access are in sync
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (23 preceding siblings ...)
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 24/31] mmc: tmio: discard obsolete SDIO irqs before enabling irqs Biju Das
@ 2019-11-19 13:36 ` Biju Das
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 26/31] mmc: host: tmio: use defines for CTL_STOP_INTERNAL_ACTION values Biju Das
                   ` (7 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:36 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit 52ad9a8e854ca13151f4af8140297f73d49e318a upstream.

The current code assumes that DMA is finished before SD access end is
flagged. Thus, it schedules the 'dma_complete' tasklet in the SD card
interrupt routine when DATAEND is set. The assumption is not safe,
though. Even by mounting an SD card, it can be seen that sometimes DMA
complete is first, sometimes DATAEND. It seems they are usually close
enough timewise to not cause problems. However, a customer reported that
with CMD53 sometimes things really break apart. As a result, the BSP has
a patch which introduces flags for both events and makes sure both flags
are set before scheduling the tasklet. The customer accepted the patch,
yet it doesn't seem a proper upstream solution to me.

This patch refactors the code to replace the tasklet with already
existing and more lightweight mechanisms. First of all, we set the
callback in a DMA descriptor to automatically get notified when DMA is
done. In the callback, we then use a completion to make sure the SD
access has already ended. Then, we proceed as before.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc.h     |  2 +-
 drivers/mmc/host/tmio_mmc_dma.c | 58 ++++++++++++++++++++++++-----------------
 drivers/mmc/host/tmio_mmc_pio.c |  4 +--
 3 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index e414670..f864be46 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -136,7 +136,7 @@ struct tmio_mmc_host {
 	bool			force_pio;
 	struct dma_chan		*chan_rx;
 	struct dma_chan		*chan_tx;
-	struct tasklet_struct	dma_complete;
+	struct completion	dma_dataend;
 	struct tasklet_struct	dma_issue;
 	struct scatterlist	bounce_sg;
 	u8			*bounce_buf;
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
index d157368..cef1eb4 100644
--- a/drivers/mmc/host/tmio_mmc_dma.c
+++ b/drivers/mmc/host/tmio_mmc_dma.c
@@ -43,6 +43,31 @@ void tmio_mmc_abort_dma(struct tmio_mmc_host *host)
 	tmio_mmc_enable_dma(host, true);
 }
 
+static void tmio_mmc_dma_callback(void *arg)
+{
+	struct tmio_mmc_host *host = arg;
+
+	wait_for_completion(&host->dma_dataend);
+
+	spin_lock_irq(&host->lock);
+
+	if (!host->data)
+		goto out;
+
+	if (host->data->flags & MMC_DATA_READ)
+		dma_unmap_sg(host->chan_rx->device->dev,
+			     host->sg_ptr, host->sg_len,
+			     DMA_FROM_DEVICE);
+	else
+		dma_unmap_sg(host->chan_tx->device->dev,
+			     host->sg_ptr, host->sg_len,
+			     DMA_TO_DEVICE);
+
+	tmio_mmc_do_data_irq(host);
+out:
+	spin_unlock_irq(&host->lock);
+}
+
 static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host)
 {
 	struct scatterlist *sg = host->sg_ptr, *sg_tmp;
@@ -88,6 +113,10 @@ static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host)
 			DMA_DEV_TO_MEM, DMA_CTRL_ACK);
 
 	if (desc) {
+		reinit_completion(&host->dma_dataend);
+		desc->callback = tmio_mmc_dma_callback;
+		desc->callback_param = host;
+
 		cookie = dmaengine_submit(desc);
 		if (cookie < 0) {
 			desc = NULL;
@@ -162,6 +191,10 @@ static void tmio_mmc_start_dma_tx(struct tmio_mmc_host *host)
 			DMA_MEM_TO_DEV, DMA_CTRL_ACK);
 
 	if (desc) {
+		reinit_completion(&host->dma_dataend);
+		desc->callback = tmio_mmc_dma_callback;
+		desc->callback_param = host;
+
 		cookie = dmaengine_submit(desc);
 		if (cookie < 0) {
 			desc = NULL;
@@ -221,29 +254,6 @@ static void tmio_mmc_issue_tasklet_fn(unsigned long priv)
 		dma_async_issue_pending(chan);
 }
 
-static void tmio_mmc_tasklet_fn(unsigned long arg)
-{
-	struct tmio_mmc_host *host = (struct tmio_mmc_host *)arg;
-
-	spin_lock_irq(&host->lock);
-
-	if (!host->data)
-		goto out;
-
-	if (host->data->flags & MMC_DATA_READ)
-		dma_unmap_sg(host->chan_rx->device->dev,
-			     host->sg_ptr, host->sg_len,
-			     DMA_FROM_DEVICE);
-	else
-		dma_unmap_sg(host->chan_tx->device->dev,
-			     host->sg_ptr, host->sg_len,
-			     DMA_TO_DEVICE);
-
-	tmio_mmc_do_data_irq(host);
-out:
-	spin_unlock_irq(&host->lock);
-}
-
 void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata)
 {
 	/* We can only either use DMA for both Tx and Rx or not use it at all */
@@ -306,7 +316,7 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
 		if (!host->bounce_buf)
 			goto ebouncebuf;
 
-		tasklet_init(&host->dma_complete, tmio_mmc_tasklet_fn, (unsigned long)host);
+		init_completion(&host->dma_dataend);
 		tasklet_init(&host->dma_issue, tmio_mmc_issue_tasklet_fn, (unsigned long)host);
 	}
 
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 3ec58b44..7cb30d3 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -595,11 +595,11 @@ static void tmio_mmc_data_irq(struct tmio_mmc_host *host, unsigned int stat)
 
 		if (done) {
 			tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_DATAEND);
-			tasklet_schedule(&host->dma_complete);
+			complete(&host->dma_dataend);
 		}
 	} else if (host->chan_rx && (data->flags & MMC_DATA_READ) && !host->force_pio) {
 		tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_DATAEND);
-		tasklet_schedule(&host->dma_complete);
+		complete(&host->dma_dataend);
 	} else {
 		tmio_mmc_do_data_irq(host);
 		tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_READOP | TMIO_MASK_WRITEOP);
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 26/31] mmc: host: tmio: use defines for CTL_STOP_INTERNAL_ACTION values
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (24 preceding siblings ...)
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 25/31] mmc: tmio: ensure end of DMA and SD access are in sync Biju Das
@ 2019-11-19 13:36 ` Biju Das
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 27/31] mmc: host: tmio: don't BUG on unsupported stop commands Biju Das
                   ` (6 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:36 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit 9afcbf4a6f1995f3b47088764eaef7b56154beb9 upstream.

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc.h     | 4 ++++
 drivers/mmc/host/tmio_mmc_pio.c | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index f864be46..3164e7c 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -49,6 +49,10 @@
 #define CTL_CLK_AND_WAIT_CTL 0x138
 #define CTL_RESET_SDIO 0x1e0
 
+/* Definitions for values the CTL_STOP_INTERNAL_ACTION register can take */
+#define TMIO_STOP_STP		BIT(0)
+#define TMIO_STOP_SEC		BIT(8)
+
 /* Definitions for values the CTRL_STATUS register can take. */
 #define TMIO_STAT_CMDRESPEND    BIT(0)
 #define TMIO_STAT_DATAEND       BIT(2)
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 7cb30d3..3004d90 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -340,7 +340,7 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command
 
 	/* CMD12 is handled by hardware */
 	if (cmd->opcode == MMC_STOP_TRANSMISSION && !cmd->arg) {
-		sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x001);
+		sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, TMIO_STOP_STP);
 		return 0;
 	}
 
@@ -367,7 +367,7 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command
 	if (data) {
 		c |= DATA_PRESENT;
 		if (data->blocks > 1) {
-			sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x100);
+			sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, TMIO_STOP_SEC);
 			c |= TRANSFER_MULTI;
 
 			/*
@@ -553,7 +553,7 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
 
 	if (stop) {
 		if (stop->opcode == MMC_STOP_TRANSMISSION && !stop->arg)
-			sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x000);
+			sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
 		else
 			BUG();
 	}
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 27/31] mmc: host: tmio: don't BUG on unsupported stop commands
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (25 preceding siblings ...)
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 26/31] mmc: host: tmio: use defines for CTL_STOP_INTERNAL_ACTION values Biju Das
@ 2019-11-19 13:36 ` Biju Das
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 28/31] mmc: host: tmio: fill in response from auto cmd12 Biju Das
                   ` (5 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:36 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit 022f731e03d190d0e4f52f2b1bd90fae0eadd56d upstream.

Halting the kernel on an unsupported stop command seems overkill, report
the error and say what we already did (due to autocmd12) instead.

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 3004d90..4faacd5 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -552,10 +552,11 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
 	}
 
 	if (stop) {
-		if (stop->opcode == MMC_STOP_TRANSMISSION && !stop->arg)
-			sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
-		else
-			BUG();
+		if (stop->opcode != MMC_STOP_TRANSMISSION || stop->arg)
+			dev_err(&host->pdev->dev, "unsupported stop: CMD%u,0x%x. We did CMD12,0\n",
+				stop->opcode, stop->arg);
+
+		sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
 	}
 
 	schedule_work(&host->done);
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 28/31] mmc: host: tmio: fill in response from auto cmd12
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (26 preceding siblings ...)
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 27/31] mmc: host: tmio: don't BUG on unsupported stop commands Biju Das
@ 2019-11-19 13:36 ` Biju Das
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 29/31] mmc: tmio: always get number of taps Biju Das
                   ` (4 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:36 UTC (permalink / raw)
  To: cip-dev

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

commit eb7c00e1461124ad0e85f1a9a3954d7164809c13 upstream.

After we received the dataend interrupt, R1 response register carries
the value from the automatically generated stop command. Report that
info back to the MMC block layer, so we will be notified in case of e.g.
ECC errors which happened during the last transfer.

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 4faacd5..163646f 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -556,6 +556,9 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
 			dev_err(&host->pdev->dev, "unsupported stop: CMD%u,0x%x. We did CMD12,0\n",
 				stop->opcode, stop->arg);
 
+		/* fill in response from auto CMD12 */
+		stop->resp[0] = sd_ctrl_read16_and_16_as_32(host, CTL_RESPONSE);
+
 		sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0);
 	}
 
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 29/31] mmc: tmio: always get number of taps
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (27 preceding siblings ...)
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 28/31] mmc: host: tmio: fill in response from auto cmd12 Biju Das
@ 2019-11-19 13:36 ` Biju Das
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 30/31] mmc: tmio: drop filenames from comment at top of source Biju Das
                   ` (3 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:36 UTC (permalink / raw)
  To: cip-dev

From: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>

commit 43b0b361b0170030603cf76f70b099f3323edcf3 upstream.

Current code gets number of taps only once and keeps the value. This is
not correct, we need to obtain it every time before executing tuning,
so remove the outer if-block.

Signed-off-by: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>
[wsa: extracted from a larger patch and reworded commit message]
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc_pio.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 163646f..bcca0e2 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -817,16 +817,14 @@ static int tmio_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
 	struct tmio_mmc_host *host = mmc_priv(mmc);
 	int i, ret = 0;
 
-	if (!host->tap_num) {
-		if (!host->init_tuning || !host->select_tuning)
-			/* Tuning is not supported */
-			goto out;
+	if (!host->init_tuning || !host->select_tuning)
+		/* Tuning is not supported */
+		goto out;
 
-		host->tap_num = host->init_tuning(host);
-		if (!host->tap_num)
-			/* Tuning is not supported */
-			goto out;
-	}
+	host->tap_num = host->init_tuning(host);
+	if (!host->tap_num)
+		/* Tuning is not supported */
+		goto out;
 
 	if (host->tap_num * 2 >= sizeof(host->taps) * BITS_PER_BYTE) {
 		dev_warn_once(&host->pdev->dev,
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 30/31] mmc: tmio: drop filenames from comment at top of source
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (28 preceding siblings ...)
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 29/31] mmc: tmio: always get number of taps Biju Das
@ 2019-11-19 13:36 ` Biju Das
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 31/31] mmc: renesas-sdhi, tmio: make dma more modular Biju Das
                   ` (2 subsequent siblings)
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:36 UTC (permalink / raw)
  To: cip-dev

From: Simon Horman <horms+renesas@verge.net.au>

commit b21f13d8f7bf1b65b2e5396fbd8bfb857627b666 upstream.

Reshuffle the comment at the top of the source
dropping filenames and moving up human readable strings.

This seems to be somewhat more useful information to start the
source file with. It is also less fragile, f.e. to file renames.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/tmio_mmc.c     | 8 +++-----
 drivers/mmc/host/tmio_mmc.h     | 7 +++----
 drivers/mmc/host/tmio_mmc_dma.c | 4 +---
 drivers/mmc/host/tmio_mmc_pio.c | 8 +++-----
 4 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index e897e7f..ff14311 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -1,5 +1,7 @@
 /*
- * linux/drivers/mmc/host/tmio_mmc.c
+ * Driver for the MMC / SD / SDIO cell found in:
+ *
+ * TC6393XB TC6391XB TC6387XB T7L66XB ASIC3
  *
  * Copyright (C) 2007 Ian Molton
  * Copyright (C) 2004 Ian Molton
@@ -7,10 +9,6 @@
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
- *
- * Driver for the MMC / SD / SDIO cell found in:
- *
- * TC6393XB TC6391XB TC6387XB T7L66XB ASIC3
  */
 
 #include <linux/device.h>
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 3164e7c..d01776e 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -1,5 +1,7 @@
 /*
- * linux/drivers/mmc/host/tmio_mmc.h
+ * Driver for the MMC / SD / SDIO cell found in:
+ *
+ * TC6393XB TC6391XB TC6387XB T7L66XB ASIC3
  *
  * Copyright (C) 2016 Sang Engineering, Wolfram Sang
  * Copyright (C) 2015-16 Renesas Electronics Corporation
@@ -10,9 +12,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * Driver for the MMC / SD / SDIO cell found in:
- *
- * TC6393XB TC6391XB TC6387XB T7L66XB ASIC3
  */
 
 #ifndef TMIO_MMC_H
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
index cef1eb4..f668441 100644
--- a/drivers/mmc/host/tmio_mmc_dma.c
+++ b/drivers/mmc/host/tmio_mmc_dma.c
@@ -1,13 +1,11 @@
 /*
- * linux/drivers/mmc/tmio_mmc_dma.c
+ * DMA function for TMIO MMC implementations
  *
  * Copyright (C) 2010-2011 Guennadi Liakhovetski
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
- *
- * DMA function for TMIO MMC implementations
  */
 
 #include <linux/device.h>
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index bcca0e2..f512be4 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1,5 +1,7 @@
 /*
- * linux/drivers/mmc/host/tmio_mmc_pio.c
+ * Driver for the MMC / SD / SDIO IP found in:
+ *
+ * TC6393XB, TC6391XB, TC6387XB, T7L66XB, ASIC3, SH-Mobile SoCs
  *
  * Copyright (C) 2016 Sang Engineering, Wolfram Sang
  * Copyright (C) 2015-16 Renesas Electronics Corporation
@@ -11,10 +13,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * Driver for the MMC / SD / SDIO IP found in:
- *
- * TC6393XB, TC6391XB, TC6387XB, T7L66XB, ASIC3, SH-Mobile SoCs
- *
  * This driver draws mainly on scattered spec sheets, Reverse engineering
  * of the toshiba e800  SD driver and some parts of the 2.4 ASIC3 driver (4 bit
  * support). (Further 4 bit support from a later datasheet).
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 31/31] mmc: renesas-sdhi, tmio: make dma more modular
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (29 preceding siblings ...)
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 30/31] mmc: tmio: drop filenames from comment at top of source Biju Das
@ 2019-11-19 13:36 ` Biju Das
  2019-11-21  1:13 ` [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Nobuhiro Iwamatsu
  2019-11-21  8:33 ` Pavel Machek
  32 siblings, 0 replies; 37+ messages in thread
From: Biju Das @ 2019-11-19 13:36 UTC (permalink / raw)
  To: cip-dev

From: Simon Horman <horms+renesas@verge.net.au>

commit 631fa73cfba8dcfd0d1db8eb608527183ed95648 upstream.

Refactor DMA support to allow it to be provided by a set of call-backs
that are provided by a host driver. The motivation is to allow multiple
DMA implementations to be provided and instantiated at run-time.

Instantiate the existing DMA implementation from the sh_mobile_sdhi driver
which appears to match the current use-case. This has the side effect
of moving the DMA code from the tmio_core to the sh_mobile_sdhi driver.

A follow-up patch will change the source file for the SDHI DMA
implementation accordingly. Another follow-up patch will re-organise the
SDHI driver removing the need for tmio_mmc_get_dma_ops().

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
 drivers/mmc/host/Makefile         |  3 +--
 drivers/mmc/host/sh_mobile_sdhi.c |  2 +-
 drivers/mmc/host/tmio_mmc.c       |  2 +-
 drivers/mmc/host/tmio_mmc.h       | 55 ++++++++++++++++-----------------------
 drivers/mmc/host/tmio_mmc_dma.c   | 24 +++++++++++++----
 drivers/mmc/host/tmio_mmc_pio.c   | 43 +++++++++++++++++++++++++++++-
 6 files changed, 86 insertions(+), 43 deletions(-)

diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 3595f83..bf399b8 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -37,8 +37,7 @@ obj-$(CONFIG_MMC_SDRICOH_CS)	+= sdricoh_cs.o
 obj-$(CONFIG_MMC_TMIO)		+= tmio_mmc.o
 obj-$(CONFIG_MMC_TMIO_CORE)	+= tmio_mmc_core.o
 tmio_mmc_core-y			:= tmio_mmc_pio.o
-tmio_mmc_core-$(subst m,y,$(CONFIG_MMC_SDHI))	+= tmio_mmc_dma.o
-obj-$(CONFIG_MMC_SDHI)		+= sh_mobile_sdhi.o
+obj-$(CONFIG_MMC_SDHI)		+= sh_mobile_sdhi.o tmio_mmc_dma.o
 obj-$(CONFIG_MMC_CB710)		+= cb710-mmc.o
 obj-$(CONFIG_MMC_VIA_SDMMC)	+= via-sdmmc.o
 obj-$(CONFIG_SDH_BFIN)		+= bfin_sdh.o
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index a723550..05edac3 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -643,7 +643,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 	/* All SDHI have SDIO status bits which must be 1 */
 	mmc_data->flags |= TMIO_MMC_SDIO_STATUS_SETBITS;
 
-	ret = tmio_mmc_host_probe(host, mmc_data);
+	ret = tmio_mmc_host_probe(host, mmc_data, tmio_mmc_get_dma_ops());
 	if (ret < 0)
 		goto efree;
 
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index ff14311..5988014 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -97,7 +97,7 @@ static int tmio_mmc_probe(struct platform_device *pdev)
 	/* SD control register space size is 0x200, 0x400 for bus_shift=1 */
 	host->bus_shift = resource_size(res) >> 10;
 
-	ret = tmio_mmc_host_probe(host, pdata);
+	ret = tmio_mmc_host_probe(host, pdata, NULL);
 	if (ret)
 		goto host_free;
 
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index d01776e..86aa49f3 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -113,6 +113,15 @@ struct tmio_mmc_dma {
 	void (*enable)(struct tmio_mmc_host *host, bool enable);
 };
 
+struct tmio_mmc_dma_ops {
+	void (*start)(struct tmio_mmc_host *host, struct mmc_data *data);
+	void (*enable)(struct tmio_mmc_host *host, bool enable);
+	void (*request)(struct tmio_mmc_host *host,
+			struct tmio_mmc_data *pdata);
+	void (*release)(struct tmio_mmc_host *host);
+	void (*abort)(struct tmio_mmc_host *host);
+};
+
 struct tmio_mmc_host {
 	void __iomem *ctl;
 	struct mmc_command      *cmd;
@@ -187,12 +196,15 @@ struct tmio_mmc_host {
 	/* Tuning values: 1 for success, 0 for failure */
 	DECLARE_BITMAP(taps, BITS_PER_BYTE * sizeof(long));
 	unsigned int tap_num;
+
+	const struct tmio_mmc_dma_ops *dma_ops;
 };
 
 struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev);
 void tmio_mmc_host_free(struct tmio_mmc_host *host);
 int tmio_mmc_host_probe(struct tmio_mmc_host *host,
-			struct tmio_mmc_data *pdata);
+			struct tmio_mmc_data *pdata,
+			const struct tmio_mmc_dma_ops *dma_ops);
 void tmio_mmc_host_remove(struct tmio_mmc_host *host);
 void tmio_mmc_do_data_irq(struct tmio_mmc_host *host);
 
@@ -200,6 +212,15 @@ void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i);
 void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i);
 irqreturn_t tmio_mmc_irq(int irq, void *devid);
 
+#if IS_ENABLED(CONFIG_MMC_SDHI)
+const struct tmio_mmc_dma_ops *tmio_mmc_get_dma_ops(void);
+#else
+static inline const struct tmio_mmc_dma_ops *tmio_mmc_get_dma_ops(void)
+{
+	return NULL;
+}
+#endif
+
 static inline char *tmio_mmc_kmap_atomic(struct scatterlist *sg,
 					 unsigned long *flags)
 {
@@ -214,38 +235,6 @@ static inline void tmio_mmc_kunmap_atomic(struct scatterlist *sg,
 	local_irq_restore(*flags);
 }
 
-#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
-void tmio_mmc_start_dma(struct tmio_mmc_host *host, struct mmc_data *data);
-void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable);
-void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata);
-void tmio_mmc_release_dma(struct tmio_mmc_host *host);
-void tmio_mmc_abort_dma(struct tmio_mmc_host *host);
-#else
-static inline void tmio_mmc_start_dma(struct tmio_mmc_host *host,
-			       struct mmc_data *data)
-{
-}
-
-static inline void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)
-{
-}
-
-static inline void tmio_mmc_request_dma(struct tmio_mmc_host *host,
-				 struct tmio_mmc_data *pdata)
-{
-	host->chan_tx = NULL;
-	host->chan_rx = NULL;
-}
-
-static inline void tmio_mmc_release_dma(struct tmio_mmc_host *host)
-{
-}
-
-static inline void tmio_mmc_abort_dma(struct tmio_mmc_host *host)
-{
-}
-#endif
-
 #ifdef CONFIG_PM
 int tmio_mmc_host_runtime_suspend(struct device *dev);
 int tmio_mmc_host_runtime_resume(struct device *dev);
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
index f668441..e743684 100644
--- a/drivers/mmc/host/tmio_mmc_dma.c
+++ b/drivers/mmc/host/tmio_mmc_dma.c
@@ -20,7 +20,7 @@
 
 #define TMIO_MMC_MIN_DMA_LEN 8
 
-void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)
+static void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)
 {
 	if (!host->chan_tx || !host->chan_rx)
 		return;
@@ -29,7 +29,7 @@ void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)
 		host->dma->enable(host, enable);
 }
 
-void tmio_mmc_abort_dma(struct tmio_mmc_host *host)
+static void tmio_mmc_abort_dma(struct tmio_mmc_host *host)
 {
 	tmio_mmc_enable_dma(host, false);
 
@@ -218,7 +218,7 @@ pio:
 	}
 }
 
-void tmio_mmc_start_dma(struct tmio_mmc_host *host,
+static void tmio_mmc_start_dma(struct tmio_mmc_host *host,
 			       struct mmc_data *data)
 {
 	if (data->flags & MMC_DATA_READ) {
@@ -252,7 +252,8 @@ static void tmio_mmc_issue_tasklet_fn(unsigned long priv)
 		dma_async_issue_pending(chan);
 }
 
-void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata)
+static void tmio_mmc_request_dma(struct tmio_mmc_host *host,
+				 struct tmio_mmc_data *pdata)
 {
 	/* We can only either use DMA for both Tx and Rx or not use it at all */
 	if (!host->dma || (!host->pdev->dev.of_node &&
@@ -332,7 +333,7 @@ ecfgtx:
 	host->chan_tx = NULL;
 }
 
-void tmio_mmc_release_dma(struct tmio_mmc_host *host)
+static void tmio_mmc_release_dma(struct tmio_mmc_host *host)
 {
 	if (host->chan_tx) {
 		struct dma_chan *chan = host->chan_tx;
@@ -349,3 +350,16 @@ void tmio_mmc_release_dma(struct tmio_mmc_host *host)
 		host->bounce_buf = NULL;
 	}
 }
+
+static const struct tmio_mmc_dma_ops tmio_mmc_dma_ops = {
+	.start = tmio_mmc_start_dma,
+	.enable = tmio_mmc_enable_dma,
+	.request = tmio_mmc_request_dma,
+	.release = tmio_mmc_release_dma,
+	.abort = tmio_mmc_abort_dma,
+};
+
+const struct tmio_mmc_dma_ops *tmio_mmc_get_dma_ops(void)
+{
+	return &tmio_mmc_dma_ops;
+}
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index f512be4..0132a52 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -50,17 +50,55 @@
 
 #include "tmio_mmc.h"
 
+static inline void tmio_mmc_start_dma(struct tmio_mmc_host *host,
+				      struct mmc_data *data)
+{
+	if (host->dma_ops)
+		host->dma_ops->start(host, data);
+}
+
+static inline void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)
+{
+	if (host->dma_ops)
+		host->dma_ops->enable(host, enable);
+}
+
+static inline void tmio_mmc_request_dma(struct tmio_mmc_host *host,
+					struct tmio_mmc_data *pdata)
+{
+	if (host->dma_ops) {
+		host->dma_ops->request(host, pdata);
+	} else {
+		host->chan_tx = NULL;
+		host->chan_rx = NULL;
+	}
+}
+
+static inline void tmio_mmc_release_dma(struct tmio_mmc_host *host)
+{
+	if (host->dma_ops)
+		host->dma_ops->release(host);
+}
+
+static inline void tmio_mmc_abort_dma(struct tmio_mmc_host *host)
+{
+	if (host->dma_ops)
+		host->dma_ops->abort(host);
+}
+
 void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i)
 {
 	host->sdcard_irq_mask &= ~(i & TMIO_MASK_IRQ);
 	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask);
 }
+EXPORT_SYMBOL(tmio_mmc_enable_mmc_irqs);
 
 void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i)
 {
 	host->sdcard_irq_mask |= (i & TMIO_MASK_IRQ);
 	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask);
 }
+EXPORT_SYMBOL(tmio_mmc_disable_mmc_irqs);
 
 static void tmio_mmc_ack_mmc_irqs(struct tmio_mmc_host *host, u32 i)
 {
@@ -562,6 +600,7 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
 
 	schedule_work(&host->done);
 }
+EXPORT_SYMBOL(tmio_mmc_do_data_irq);
 
 static void tmio_mmc_data_irq(struct tmio_mmc_host *host, unsigned int stat)
 {
@@ -1140,7 +1179,8 @@ void tmio_mmc_host_free(struct tmio_mmc_host *host)
 EXPORT_SYMBOL(tmio_mmc_host_free);
 
 int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
-			struct tmio_mmc_data *pdata)
+			struct tmio_mmc_data *pdata,
+			const struct tmio_mmc_dma_ops *dma_ops)
 {
 	struct platform_device *pdev = _host->pdev;
 	struct mmc_host *mmc = _host->mmc;
@@ -1252,6 +1292,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 	INIT_WORK(&_host->done, tmio_mmc_done_work);
 
 	/* See if we also get DMA */
+	_host->dma_ops = dma_ops;
 	tmio_mmc_request_dma(_host, pdata);
 
 	pm_runtime_set_active(&pdev->dev);
-- 
2.7.4

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

* [cip-dev] [PATCH 4.4.y-cip 03/31] mmc: tmio: enhance illegal sequence handling
  2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 03/31] mmc: tmio: enhance illegal sequence handling Biju Das
@ 2019-11-21  0:41   ` Nobuhiro Iwamatsu
  2019-11-21  7:42     ` Biju Das
  0 siblings, 1 reply; 37+ messages in thread
From: Nobuhiro Iwamatsu @ 2019-11-21  0:41 UTC (permalink / raw)
  To: cip-dev

Hi Biju,

2019?11?19?(?) 22:42 Biju Das <biju.das@bp.renesas.com>:
>
> From: Ai Kyuse <ai.kyuse.uw@renesas.com>
>
> commit 96e0b2ba00ee5dacb12bed6585145ce784ec9153 upstream.
>
> An illegal sequence command error may occur if there is a stopbit or
> cmd_index error as well as a CRC error. The correct course of action
> is to re-enable IRQs
>
> An illegal sequence data error may occur if there is a CRC or stopbit
> error,  or underrun. In this case set data->error correctly.
>
> This is in preparation for enabling tuning support which relies on
> differentiating between illegal sequence and other errors.
>
> Signed-off-by: Ai Kyuse <ai.kyuse.uw@renesas.com>
> [simon: broken out of a larger patch]
> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
> Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>

Here is the addition of line breaks.

> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> ---
>  drivers/mmc/host/tmio_mmc_pio.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)

Best regards,
  Nobuhiro

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

* [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (30 preceding siblings ...)
  2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 31/31] mmc: renesas-sdhi, tmio: make dma more modular Biju Das
@ 2019-11-21  1:13 ` Nobuhiro Iwamatsu
  2019-11-21  8:33 ` Pavel Machek
  32 siblings, 0 replies; 37+ messages in thread
From: Nobuhiro Iwamatsu @ 2019-11-21  1:13 UTC (permalink / raw)
  To: cip-dev

Hi Biju,

2019?11?19?(?) 22:42 Biju Das <biju.das@bp.renesas.com>:
>
> This patch series add SD/eMMC support support for RZ/G1C sbc.
>
> RZ/G1C eMMC IP is different from other RZ/G1 SoC's. It is having an
> internal DMA for data transfer which is similar to R-Car Gen3.
>
> Support for internal DMAC is added in 4.14 kernel and support for
> RZ/G1C added on 4.20 kernel.
>
> Backported the relevent patches to linux-4.4.y-cip.
>
> This patch series is based on linux-4.4.y-cip and all the patches
> in this series are cherry-picked from linux rc tree.
>
> V1-->V2
>   * Incorporated pavel's review comments.
>   https://lists.cip-project.org/pipermail/cip-dev/2019-November/003770.html
>

I checked this series, looks good to me with out patch 03.

Best regards,
  Nobuhiro



> Ai Kyuse (3):
>   mmc: tmio: enhance illegal sequence handling
>   mmc: tmio: Add hw reset support
>   mmc: tmio: Add tuning support
>
> Chris Brandt (2):
>   mmc: tmio-mmc: add support for 32bit data port
>   mmc: sh_mobile_sdhi: add ocr_mask option
>
> Masaharu Hayakawa (1):
>   mmc: tmio: always get number of taps
>
> Simon Horman (5):
>   mmc: tmio: document mandatory and optional callbacks
>   mmc: core: Add helper to see if a host can be retuned
>   mmc: sh_mobile_sdhi: Add tuning support
>   mmc: tmio: drop filenames from comment at top of source
>   mmc: renesas-sdhi, tmio: make dma more modular
>
> Ulf Hansson (1):
>   mmc: tmio: Remove redundant check of mmc->slot.cd_irq
>
> Wolfram Sang (19):
>   mmc: tmio: fix wrong bitmask for SDIO irqs
>   mmc: tmio: remove SDIO from TODO list
>   mmc: tmio: use SDIO master interrupt bit only when allowed
>   mmc: sh_mobile_sdhi: simplify accessing DT data
>   mmc: sh_mobile_sdhi: improve prerequisite for hw_reset
>   mmc: sh_mobile_sdhi: remove superfluous check in hw_reset
>   mmc: sh_mobile_sdhi: improve prerequisites for tuning
>   mmc: sh_mobile_sdhi: remove superfluous check in SCC error check
>   mmc: sh_mobile_sdhi: remove superfluous check in init_tuning
>   mmc: sh_mobile_sdhi: enable HS200
>   mmc: host: tmio: drop superfluous exit path
>   mmc: host: tmio: disable clocks when unbinding
>   mmc: host: tmio: refactor calls to sdio irq
>   mmc: host: tmio: SDIO_STATUS_QUIRK is rather SDIO_STATUS_SETBITS
>   mmc: tmio: discard obsolete SDIO irqs before enabling irqs
>   mmc: tmio: ensure end of DMA and SD access are in sync
>   mmc: host: tmio: use defines for CTL_STOP_INTERNAL_ACTION values
>   mmc: host: tmio: don't BUG on unsupported stop commands
>   mmc: host: tmio: fill in response from auto cmd12
>
>  drivers/mmc/host/Makefile         |   3 +-
>  drivers/mmc/host/sh_mobile_sdhi.c | 267 ++++++++++++++++++++++++++++++++++++--
>  drivers/mmc/host/tmio_mmc.c       |  10 +-
>  drivers/mmc/host/tmio_mmc.h       | 102 +++++++++------
>  drivers/mmc/host/tmio_mmc_dma.c   |  86 +++++++-----
>  drivers/mmc/host/tmio_mmc_pio.c   | 248 ++++++++++++++++++++++++++++-------
>  include/linux/mfd/tmio.h          |   7 +-
>  include/linux/mmc/host.h          |   5 +
>  8 files changed, 588 insertions(+), 140 deletions(-)
>
> --
> 2.7.4
>
> _______________________________________________
> cip-dev mailing list
> cip-dev at lists.cip-project.org
> https://lists.cip-project.org/mailman/listinfo/cip-dev



--
Nobuhiro Iwamatsu
   iwamatsu at {nigauri.org / debian.org}
   GPG ID: 40AD1FA6

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

* [cip-dev] [PATCH 4.4.y-cip 03/31] mmc: tmio: enhance illegal sequence handling
  2019-11-21  0:41   ` Nobuhiro Iwamatsu
@ 2019-11-21  7:42     ` Biju Das
  2019-11-21  8:12       ` Pavel Machek
  0 siblings, 1 reply; 37+ messages in thread
From: Biju Das @ 2019-11-21  7:42 UTC (permalink / raw)
  To: cip-dev

Hi Nobuhiro-San,

Thanks for the feedback.

> Subject: Re: [cip-dev] [PATCH 4.4.y-cip 03/31] mmc: tmio: enhance illegal
> sequence handling
> 
> Hi Biju,
> 
> 2019?11?19?(?) 22:42 Biju Das <biju.das@bp.renesas.com>:
> >
> > From: Ai Kyuse <ai.kyuse.uw@renesas.com>
> >
> > commit 96e0b2ba00ee5dacb12bed6585145ce784ec9153 upstream.
> >
> > An illegal sequence command error may occur if there is a stopbit or
> > cmd_index error as well as a CRC error. The correct course of action
> > is to re-enable IRQs
> >
> > An illegal sequence data error may occur if there is a CRC or stopbit
> > error,  or underrun. In this case set data->error correctly.
> >
> > This is in preparation for enabling tuning support which relies on
> > differentiating between illegal sequence and other errors.
> >
> > Signed-off-by: Ai Kyuse <ai.kyuse.uw@renesas.com>
> > [simon: broken out of a larger patch]
> > Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
> > Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> >
> 
> Here is the addition of line breaks.

Can you please fix this while applying or do you want me to send another patch?

Regards,
Biju

> > Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> > ---
> >  drivers/mmc/host/tmio_mmc_pio.c | 15 +++++++++------
> >  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> Best regards,
>   Nobuhiro

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

* [cip-dev] [PATCH 4.4.y-cip 03/31] mmc: tmio: enhance illegal sequence handling
  2019-11-21  7:42     ` Biju Das
@ 2019-11-21  8:12       ` Pavel Machek
  0 siblings, 0 replies; 37+ messages in thread
From: Pavel Machek @ 2019-11-21  8:12 UTC (permalink / raw)
  To: cip-dev

Hi!

> > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> > >
> > 
> > Here is the addition of line breaks.
> 
> Can you please fix this while applying or do you want me to send another patch?

It will be easier to fix it while applying.

Best regards,
								Pavel
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.cip-project.org/pipermail/cip-dev/attachments/20191121/9fbe288a/attachment-0001.sig>

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

* [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support
  2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
                   ` (31 preceding siblings ...)
  2019-11-21  1:13 ` [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Nobuhiro Iwamatsu
@ 2019-11-21  8:33 ` Pavel Machek
  32 siblings, 0 replies; 37+ messages in thread
From: Pavel Machek @ 2019-11-21  8:33 UTC (permalink / raw)
  To: cip-dev

Hi!

> This patch series add SD/eMMC support support for RZ/G1C sbc.
> 
> RZ/G1C eMMC IP is different from other RZ/G1 SoC's. It is having an 
> internal DMA for data transfer which is similar to R-Car Gen3.
> 
> Support for internal DMAC is added in 4.14 kernel and support for 
> RZ/G1C added on 4.20 kernel.
> 
> Backported the relevent patches to linux-4.4.y-cip.
> 
> This patch series is based on linux-4.4.y-cip and all the patches
> in this series are cherry-picked from linux rc tree.

Thanks, applied and pushed out.

Best regards,
								Pavel
								
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.cip-project.org/pipermail/cip-dev/attachments/20191121/f427e7e5/attachment.sig>

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

end of thread, other threads:[~2019-11-21  8:33 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-19 13:35 [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 01/31] mmc: tmio-mmc: add support for 32bit data port Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 02/31] mmc: sh_mobile_sdhi: add ocr_mask option Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 03/31] mmc: tmio: enhance illegal sequence handling Biju Das
2019-11-21  0:41   ` Nobuhiro Iwamatsu
2019-11-21  7:42     ` Biju Das
2019-11-21  8:12       ` Pavel Machek
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 04/31] mmc: tmio: document mandatory and optional callbacks Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 05/31] mmc: tmio: Add hw reset support Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 06/31] mmc: core: Add helper to see if a host can be retuned Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 07/31] mmc: tmio: Add tuning support Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 08/31] mmc: sh_mobile_sdhi: " Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 09/31] mmc: tmio: fix wrong bitmask for SDIO irqs Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 10/31] mmc: tmio: remove SDIO from TODO list Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 11/31] mmc: tmio: use SDIO master interrupt bit only when allowed Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 12/31] mmc: sh_mobile_sdhi: simplify accessing DT data Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 13/31] mmc: sh_mobile_sdhi: improve prerequisite for hw_reset Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 14/31] mmc: sh_mobile_sdhi: remove superfluous check in hw_reset Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 15/31] mmc: sh_mobile_sdhi: improve prerequisites for tuning Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 16/31] mmc: sh_mobile_sdhi: remove superfluous check in SCC error check Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 17/31] mmc: sh_mobile_sdhi: remove superfluous check in init_tuning Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 18/31] mmc: sh_mobile_sdhi: enable HS200 Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 19/31] mmc: host: tmio: drop superfluous exit path Biju Das
2019-11-19 13:35 ` [cip-dev] [PATCH 4.4.y-cip 20/31] mmc: tmio: Remove redundant check of mmc->slot.cd_irq Biju Das
2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 21/31] mmc: host: tmio: disable clocks when unbinding Biju Das
2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 22/31] mmc: host: tmio: refactor calls to sdio irq Biju Das
2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 23/31] mmc: host: tmio: SDIO_STATUS_QUIRK is rather SDIO_STATUS_SETBITS Biju Das
2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 24/31] mmc: tmio: discard obsolete SDIO irqs before enabling irqs Biju Das
2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 25/31] mmc: tmio: ensure end of DMA and SD access are in sync Biju Das
2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 26/31] mmc: host: tmio: use defines for CTL_STOP_INTERNAL_ACTION values Biju Das
2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 27/31] mmc: host: tmio: don't BUG on unsupported stop commands Biju Das
2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 28/31] mmc: host: tmio: fill in response from auto cmd12 Biju Das
2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 29/31] mmc: tmio: always get number of taps Biju Das
2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 30/31] mmc: tmio: drop filenames from comment at top of source Biju Das
2019-11-19 13:36 ` [cip-dev] [PATCH 4.4.y-cip 31/31] mmc: renesas-sdhi, tmio: make dma more modular Biju Das
2019-11-21  1:13 ` [cip-dev] [PATCH 4.4.y-cip 00/31] Add RZ/G1C SD/eMMC support Nobuhiro Iwamatsu
2019-11-21  8:33 ` Pavel Machek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.