All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] mmc: tmio: remove confusing TMIO_MMC_HAVE_HIGH_REG flag
@ 2018-10-03 11:36 Masahiro Yamada
  2018-10-03 11:36 ` [PATCH v2 1/2] mmc: tmio: move MFD variant reset to a platform hook Masahiro Yamada
  2018-10-03 11:36 ` [PATCH v2 2/2] mmc: tmio: remove TMIO_MMC_HAVE_HIGH_REG flag Masahiro Yamada
  0 siblings, 2 replies; 5+ messages in thread
From: Masahiro Yamada @ 2018-10-03 11:36 UTC (permalink / raw)
  To: Wolfram Sang, linux-mmc
  Cc: Ulf Hansson, linux-renesas-soc, Masahiro Yamada, Lee Jones, linux-kernel

CTL_SDIO_REGS is a register specific to tmio_mmc.c

Currently, we handle it in tmio_mmc_core.c, hence need
TMIO_MMC_HAVE_HIGH_REG flag to prevent the other platforms
from accessing to it.

We can just move CTL_SDIO_REGS to tmio_mmc.c
and delete the confusing TMIO_MMC_HAVE_HIGH_REG flag.


Masahiro Yamada (2):
  mmc: tmio: move MFD variant reset to a platform hook
  mmc: tmio: remove TMIO_MMC_HAVE_HIGH_REG flag

 drivers/mmc/host/tmio_mmc.c      | 24 ++++++++++++++++++++++--
 drivers/mmc/host/tmio_mmc.h      |  4 +---
 drivers/mmc/host/tmio_mmc_core.c |  8 +++-----
 include/linux/mfd/tmio.h         |  7 -------
 4 files changed, 26 insertions(+), 17 deletions(-)

-- 
2.7.4


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

* [PATCH v2 1/2] mmc: tmio: move MFD variant reset to a platform hook
  2018-10-03 11:36 [PATCH v2 0/2] mmc: tmio: remove confusing TMIO_MMC_HAVE_HIGH_REG flag Masahiro Yamada
@ 2018-10-03 11:36 ` Masahiro Yamada
  2018-10-09 23:48   ` Wolfram Sang
  2018-10-03 11:36 ` [PATCH v2 2/2] mmc: tmio: remove TMIO_MMC_HAVE_HIGH_REG flag Masahiro Yamada
  1 sibling, 1 reply; 5+ messages in thread
From: Masahiro Yamada @ 2018-10-03 11:36 UTC (permalink / raw)
  To: Wolfram Sang, linux-mmc
  Cc: Ulf Hansson, linux-renesas-soc, Masahiro Yamada, linux-kernel

CTL_RESET_SDIO register is specific to the TMIO MFD (tmio_mmc.c).

Add a new hook host->reset for performing a platform-specific reset
sequence, and move CTL_RESET_SDIO over there.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v2:
  - Preserve the current sequence for tmio_mmc.c

 drivers/mmc/host/tmio_mmc.c      | 17 +++++++++++++++++
 drivers/mmc/host/tmio_mmc.h      |  1 +
 drivers/mmc/host/tmio_mmc_core.c |  8 +++-----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index e04c322..00d291c 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -78,6 +78,22 @@ static void tmio_mmc_set_clock(struct tmio_mmc_host *host,
 	tmio_mmc_clk_start(host);
 }
 
+static void tmio_mmc_reset(struct tmio_mmc_host *host)
+{
+	/* FIXME - should we set stop clock reg here */
+	sd_ctrl_write16(host, CTL_RESET_SD, 0x0000);
+	sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0000);
+	usleep_range(10000, 11000);
+	sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
+	sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0001);
+	usleep_range(10000, 11000);
+
+	if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {
+		sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
+		sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
+	}
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int tmio_mmc_suspend(struct device *dev)
 {
@@ -156,6 +172,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;
 	host->set_clock = tmio_mmc_set_clock;
+	host->reset = tmio_mmc_reset;
 
 	host->mmc->f_max = pdata->hclk;
 	host->mmc->f_min = pdata->hclk / 512;
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index e6aa13a..a1a661b 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -176,6 +176,7 @@ struct tmio_mmc_host {
 	int (*multi_io_quirk)(struct mmc_card *card,
 			      unsigned int direction, int blk_size);
 	int (*write16_hook)(struct tmio_mmc_host *host, int addr);
+	void (*reset)(struct tmio_mmc_host *host);
 	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);
diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 0611824..9bcc760 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -164,19 +164,14 @@ static void tmio_mmc_reset(struct tmio_mmc_host *host)
 {
 	/* FIXME - should we set stop clock reg here */
 	sd_ctrl_write16(host, CTL_RESET_SD, 0x0000);
-	if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG)
-		sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0000);
 	usleep_range(10000, 11000);
 	sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
-	if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG)
-		sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0001);
 	usleep_range(10000, 11000);
 
 	if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {
 		sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
 		sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
 	}
-
 }
 
 static void tmio_mmc_reset_work(struct work_struct *work)
@@ -1212,6 +1207,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
 				  mmc->caps & MMC_CAP_NEEDS_POLL ||
 				  !mmc_card_is_removable(mmc));
 
+	if (!_host->reset)
+		_host->reset = tmio_mmc_reset;
+
 	/*
 	 * On Gen2+, eMMC with NONREMOVABLE currently fails because native
 	 * hotplug gets disabled. It seems RuntimePM related yet we need further
-- 
2.7.4


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

* [PATCH v2 2/2] mmc: tmio: remove TMIO_MMC_HAVE_HIGH_REG flag
  2018-10-03 11:36 [PATCH v2 0/2] mmc: tmio: remove confusing TMIO_MMC_HAVE_HIGH_REG flag Masahiro Yamada
  2018-10-03 11:36 ` [PATCH v2 1/2] mmc: tmio: move MFD variant reset to a platform hook Masahiro Yamada
@ 2018-10-03 11:36 ` Masahiro Yamada
  1 sibling, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2018-10-03 11:36 UTC (permalink / raw)
  To: Wolfram Sang, linux-mmc
  Cc: Ulf Hansson, linux-renesas-soc, Masahiro Yamada, Lee Jones, linux-kernel

TMIO_MMC_HAVE_HIGH_REG is confusing due to its counter-intuitive name.

All the TMIO MMC variants (TMIO MMC, Renesas SDHI, UniPhier SD) actually
have high registers.  It is just that each of them implements its own
registers there.  The original IP from Panasonic only defines registers
0x00-0xff in the bus_shift=1 review.  The register area above them is
platform-dependent.

In fact, TMIO_MMC_HAVE_HIGH_REG is set only by tmio-mmc.c and used to
test the accessibility of CTL_SDIO_REGS.  Because it is specific to
the TMIO MFD variant, the right thing to do is to move such registers
to tmio_mmc.c and delete the TMIO_MMC_HAVE_HIGH_REG flag.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v2: None

 drivers/mmc/host/tmio_mmc.c | 7 +++++--
 drivers/mmc/host/tmio_mmc.h | 3 ---
 include/linux/mfd/tmio.h    | 7 -------
 3 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index 00d291c..4e91020 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -24,6 +24,11 @@
 
 #include "tmio_mmc.h"
 
+/* Registers specific to this variant */
+#define CTL_SDIO_REGS		0x100
+#define CTL_CLK_AND_WAIT_CTL	0x138
+#define CTL_RESET_SDIO		0x1e0
+
 static void tmio_mmc_clk_start(struct tmio_mmc_host *host)
 {
 	sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN |
@@ -161,8 +166,6 @@ static int tmio_mmc_probe(struct platform_device *pdev)
 		goto cell_disable;
 	}
 
-	pdata->flags |= TMIO_MMC_HAVE_HIGH_REG;
-
 	host = tmio_mmc_host_alloc(pdev, pdata);
 	if (IS_ERR(host)) {
 		ret = PTR_ERR(host);
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index a1a661b..18b4308 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -47,9 +47,6 @@
 #define CTL_RESET_SD 0xe0
 #define CTL_VERSION 0xe2
 #define CTL_SDIF_MODE 0xe6
-#define CTL_SDIO_REGS 0x100
-#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)
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index 7786621..1e70060 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -62,13 +62,6 @@
 #define TMIO_MMC_USE_GPIO_CD		BIT(5)
 
 /*
- * Some controllers doesn't have over 0x100 register.
- * it is used to checking accessibility of
- * CTL_SD_CARD_CLK_CTL / CTL_CLK_AND_WAIT_CTL
- */
-#define TMIO_MMC_HAVE_HIGH_REG		BIT(6)
-
-/*
  * Some controllers have CMD12 automatically
  * issue/non-issue register
  */
-- 
2.7.4


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

* Re: [PATCH v2 1/2] mmc: tmio: move MFD variant reset to a platform hook
  2018-10-03 11:36 ` [PATCH v2 1/2] mmc: tmio: move MFD variant reset to a platform hook Masahiro Yamada
@ 2018-10-09 23:48   ` Wolfram Sang
  2018-10-10  3:47     ` Masahiro Yamada
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2018-10-09 23:48 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Wolfram Sang, linux-mmc, Ulf Hansson, linux-renesas-soc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 812 bytes --]


> +static void tmio_mmc_reset(struct tmio_mmc_host *host)
> +{
> +	/* FIXME - should we set stop clock reg here */
> +	sd_ctrl_write16(host, CTL_RESET_SD, 0x0000);
> +	sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0000);
> +	usleep_range(10000, 11000);
> +	sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
> +	sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0001);
> +	usleep_range(10000, 11000);
> +
> +	if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {
> +		sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
> +		sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
> +	}
> +}

Yes, looks much safer now.

> +	host->reset = tmio_mmc_reset;

So, you populate the new pointer here...

> +	if (!_host->reset)
> +		_host->reset = tmio_mmc_reset;

... and here. But it seems never used anywhere? Or am I missing
something?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2 1/2] mmc: tmio: move MFD variant reset to a platform hook
  2018-10-09 23:48   ` Wolfram Sang
@ 2018-10-10  3:47     ` Masahiro Yamada
  0 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2018-10-10  3:47 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Wolfram Sang, linux-mmc, Ulf Hansson, Linux-Renesas,
	Linux Kernel Mailing List

On Wed, Oct 10, 2018 at 8:49 AM Wolfram Sang <wsa@the-dreams.de> wrote:
>
>
> > +static void tmio_mmc_reset(struct tmio_mmc_host *host)
> > +{
> > +     /* FIXME - should we set stop clock reg here */
> > +     sd_ctrl_write16(host, CTL_RESET_SD, 0x0000);
> > +     sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0000);
> > +     usleep_range(10000, 11000);
> > +     sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
> > +     sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0001);
> > +     usleep_range(10000, 11000);
> > +
> > +     if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {
> > +             sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
> > +             sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
> > +     }
> > +}
>
> Yes, looks much safer now.
>
> > +     host->reset = tmio_mmc_reset;
>
> So, you populate the new pointer here...
>
> > +     if (!_host->reset)
> > +             _host->reset = tmio_mmc_reset;
>
> ... and here. But it seems never used anywhere? Or am I missing
> something?
>

Bummer. I am totally screwed up.

V3 is right away.


Thanks!


-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2018-10-10  3:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 11:36 [PATCH v2 0/2] mmc: tmio: remove confusing TMIO_MMC_HAVE_HIGH_REG flag Masahiro Yamada
2018-10-03 11:36 ` [PATCH v2 1/2] mmc: tmio: move MFD variant reset to a platform hook Masahiro Yamada
2018-10-09 23:48   ` Wolfram Sang
2018-10-10  3:47     ` Masahiro Yamada
2018-10-03 11:36 ` [PATCH v2 2/2] mmc: tmio: remove TMIO_MMC_HAVE_HIGH_REG flag Masahiro Yamada

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.