All of lore.kernel.org
 help / color / mirror / Atom feed
* tmio_mmc: Cleanups
@ 2014-04-30 16:59 Ian Molton
  2014-04-30 16:59 ` [PATCH 1/6] mmc: TMIO: Refactor driver core probe function Ian Molton
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Ian Molton @ 2014-04-30 16:59 UTC (permalink / raw)
  To: linux-mmc; +Cc: grant.likely, chris

This is a series of small cleanups for the tmio_mmc and sh_mobile_sdhi drivers.

Please apply!

-Ian

 [PATCH 1/6] mmc: TMIO: Refactor driver core probe function
 [PATCH 2/6] mmc: TMIO: Fixup error return path
 [PATCH 3/6] mmc: TMIO: Use devm_ioremap()
 [PATCH 4/6] mmc: TMIO: use devm_ for requesting irq
 [PATCH 5/6] shmobile: TMIO: break register specs out from TMIO kernel
 [PATCH 6/6] mmc: TMIO: Move register definitions to where they belong

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

* [PATCH 1/6] mmc: TMIO: Refactor driver core probe function
  2014-04-30 16:59 tmio_mmc: Cleanups Ian Molton
@ 2014-04-30 16:59 ` Ian Molton
  2014-04-30 16:59 ` [PATCH 2/6] mmc: TMIO: Fixup error return path Ian Molton
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Ian Molton @ 2014-04-30 16:59 UTC (permalink / raw)
  To: linux-mmc; +Cc: grant.likely, chris, Ian Molton

	Refactor to remove a return by reference.

Reviewed-by: Violeta Menendez <violeta.menendez@codethink.co.uk>
Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 drivers/mmc/host/sh_mobile_sdhi.c |   8 ++-
 drivers/mmc/host/tmio_mmc.c       |   8 ++-
 drivers/mmc/host/tmio_mmc.h       |   4 +-
 drivers/mmc/host/tmio_mmc_pio.c   | 106 ++++++++++++++++++++------------------
 4 files changed, 73 insertions(+), 53 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 91058da..02c1cc3 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -233,7 +233,13 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 	/* SD control register space size is 0x100, 0x200 for bus_shift=1 */
 	mmc_data->bus_shift = resource_size(res) >> 9;
 
-	ret = tmio_mmc_host_probe(&host, pdev, mmc_data);
+	host = tmio_mmc_alloc_host(pdev, mmc_data);
+	if (!host) {
+		ret = -ENOMEM;
+		goto eprobe;
+	}
+
+	ret = tmio_mmc_host_probe(host);
 	if (ret < 0)
 		goto eprobe;
 
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index cfad844..bf6252c 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -92,7 +92,13 @@ static int tmio_mmc_probe(struct platform_device *pdev)
 	pdata->bus_shift = resource_size(res) >> 10;
 	pdata->flags |= TMIO_MMC_HAVE_HIGH_REG;
 
-	ret = tmio_mmc_host_probe(&host, pdev, pdata);
+	host = tmio_mmc_alloc_host(pdev, pdata);
+	if (!host) {
+		ret = -ENOMEM;
+		goto cell_disable;
+	}
+
+	ret = tmio_mmc_host_probe(host);
 	if (ret)
 		goto cell_disable;
 
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 100ffe0..42894b7 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -103,8 +103,8 @@ struct tmio_mmc_host {
 	bool			resuming;
 };
 
-int tmio_mmc_host_probe(struct tmio_mmc_host **host,
-			struct platform_device *pdev,
+int tmio_mmc_host_probe(struct tmio_mmc_host *host);
+struct tmio_mmc_host *tmio_mmc_alloc_host(struct platform_device *pdev,
 			struct tmio_mmc_data *pdata);
 void tmio_mmc_host_remove(struct tmio_mmc_host *host);
 void tmio_mmc_do_data_irq(struct tmio_mmc_host *host);
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index faf0924..7db9310 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -970,49 +970,59 @@ static void tmio_mmc_of_parse(struct platform_device *pdev,
 		pdata->flags |= TMIO_MMC_WRPROTECT_DISABLE;
 }
 
-int tmio_mmc_host_probe(struct tmio_mmc_host **host,
-				  struct platform_device *pdev,
-				  struct tmio_mmc_data *pdata)
+struct tmio_mmc_host *tmio_mmc_alloc_host(struct platform_device *pdev,
+		struct tmio_mmc_data *pdata)
 {
-	struct tmio_mmc_host *_host;
+	struct tmio_mmc_host *host;
 	struct mmc_host *mmc;
+
+	mmc = mmc_alloc_host(sizeof(struct tmio_mmc_host), &pdev->dev);
+	if (!mmc)
+		return NULL;
+
+	pdata->dev = &pdev->dev;
+
+	host = mmc_priv(mmc);
+	host->pdata = pdata;
+	host->mmc = mmc;
+	host->pdev = pdev;
+
+	platform_set_drvdata(pdev, mmc);
+
+	return host;
+}
+
+int tmio_mmc_host_probe(struct tmio_mmc_host *host)
+{
+	struct mmc_host *mmc = host->mmc;
+	struct tmio_mmc_data *pdata = host->pdata;
+	struct device *dev = &host->pdev->dev;
 	struct resource *res_ctl;
 	int ret;
 	u32 irq_mask = TMIO_MASK_CMD;
 
-	tmio_mmc_of_parse(pdev, pdata);
+	tmio_mmc_of_parse(host->pdev, pdata);
 
 	if (!(pdata->flags & TMIO_MMC_HAS_IDLE_WAIT))
 		pdata->write16_hook = NULL;
 
-	res_ctl = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	res_ctl = platform_get_resource(host->pdev, IORESOURCE_MEM, 0);
 	if (!res_ctl)
 		return -EINVAL;
 
-	mmc = mmc_alloc_host(sizeof(struct tmio_mmc_host), &pdev->dev);
-	if (!mmc)
-		return -ENOMEM;
-
 	ret = mmc_of_parse(mmc);
 	if (ret < 0)
 		goto host_free;
 
-	pdata->dev = &pdev->dev;
-	_host = mmc_priv(mmc);
-	_host->pdata = pdata;
-	_host->mmc = mmc;
-	_host->pdev = pdev;
-	platform_set_drvdata(pdev, mmc);
-
-	_host->set_pwr = pdata->set_pwr;
-	_host->set_clk_div = pdata->set_clk_div;
+	host->set_pwr = pdata->set_pwr;
+	host->set_clk_div = pdata->set_clk_div;
 
-	ret = tmio_mmc_init_ocr(_host);
+	ret = tmio_mmc_init_ocr(host);
 	if (ret < 0)
 		goto host_free;
 
-	_host->ctl = ioremap(res_ctl->start, resource_size(res_ctl));
-	if (!_host->ctl) {
+	host->ctl = ioremap(res_ctl->start, resource_size(res_ctl));
+	if (!host->ctl) {
 		ret = -ENOMEM;
 		goto host_free;
 	}
@@ -1027,14 +1037,14 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
 	mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
 	mmc->max_seg_size = mmc->max_req_size;
 
-	_host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD ||
+	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);
 
-	_host->power = TMIO_MMC_OFF_STOP;
-	pm_runtime_enable(&pdev->dev);
-	ret = pm_runtime_resume(&pdev->dev);
+	host->power = TMIO_MMC_OFF_STOP;
+	pm_runtime_enable(dev);
+	ret = pm_runtime_resume(dev);
 	if (ret < 0)
 		goto pm_disable;
 
@@ -1055,63 +1065,61 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
 	 *  must additionally ensure that in case 2) the tmio mmc hardware stays
 	 *  powered on during runtime for the card detection to work.
 	 */
-	if (_host->native_hotplug)
-		pm_runtime_get_noresume(&pdev->dev);
+	if (host->native_hotplug)
+		pm_runtime_get_noresume(dev);
 
-	tmio_mmc_clk_stop(_host);
-	tmio_mmc_reset(_host);
+	tmio_mmc_clk_stop(host);
+	tmio_mmc_reset(host);
 
-	_host->sdcard_irq_mask = sd_ctrl_read32(_host, CTL_IRQ_MASK);
-	tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL);
+	host->sdcard_irq_mask = sd_ctrl_read32(host, CTL_IRQ_MASK);
+	tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
 
 	/* Unmask the IRQs we want to know about */
-	if (!_host->chan_rx)
+	if (!host->chan_rx)
 		irq_mask |= TMIO_MASK_READOP;
-	if (!_host->chan_tx)
+	if (!host->chan_tx)
 		irq_mask |= TMIO_MASK_WRITEOP;
-	if (!_host->native_hotplug)
+	if (!host->native_hotplug)
 		irq_mask &= ~(TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
 
-	_host->sdcard_irq_mask &= ~irq_mask;
+	host->sdcard_irq_mask &= ~irq_mask;
 
 	if (pdata->flags & TMIO_MMC_SDIO_IRQ)
 		tmio_mmc_enable_sdio_irq(mmc, 0);
 
-	spin_lock_init(&_host->lock);
-	mutex_init(&_host->ios_lock);
+	spin_lock_init(&host->lock);
+	mutex_init(&host->ios_lock);
 
 	/* Init delayed work for request timeouts */
-	INIT_DELAYED_WORK(&_host->delayed_reset_work, tmio_mmc_reset_work);
-	INIT_WORK(&_host->done, tmio_mmc_done_work);
+	INIT_DELAYED_WORK(&host->delayed_reset_work, tmio_mmc_reset_work);
+	INIT_WORK(&host->done, tmio_mmc_done_work);
 
 	/* See if we also get DMA */
-	tmio_mmc_request_dma(_host, pdata);
+	tmio_mmc_request_dma(host, pdata);
 
 	ret = mmc_add_host(mmc);
 	if (pdata->clk_disable)
-		pdata->clk_disable(pdev);
+		pdata->clk_disable(host->pdev);
 	if (ret < 0) {
-		tmio_mmc_host_remove(_host);
+		tmio_mmc_host_remove(host);
 		return ret;
 	}
 
-	dev_pm_qos_expose_latency_limit(&pdev->dev, 100);
+	dev_pm_qos_expose_latency_limit(dev, 100);
 
 	if (pdata->flags & TMIO_MMC_USE_GPIO_CD) {
 		ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0);
 		if (ret < 0) {
-			tmio_mmc_host_remove(_host);
+			tmio_mmc_host_remove(host);
 			return ret;
 		}
 	}
 
-	*host = _host;
-
 	return 0;
 
 pm_disable:
-	pm_runtime_disable(&pdev->dev);
-	iounmap(_host->ctl);
+	pm_runtime_disable(dev);
+	iounmap(host->ctl);
 host_free:
 	mmc_free_host(mmc);
 
-- 
1.9.1


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

* [PATCH 2/6] mmc: TMIO: Fixup error return path
  2014-04-30 16:59 tmio_mmc: Cleanups Ian Molton
  2014-04-30 16:59 ` [PATCH 1/6] mmc: TMIO: Refactor driver core probe function Ian Molton
@ 2014-04-30 16:59 ` Ian Molton
  2014-04-30 16:59 ` [PATCH 3/6] mmc: TMIO: Use devm_ioremap() Ian Molton
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Ian Molton @ 2014-04-30 16:59 UTC (permalink / raw)
  To: linux-mmc; +Cc: grant.likely, chris, Ian Molton

	Trivial patch to correct the error return path.

Reviewed-by: Violeta Menendez <violeta.menendez@codethink.co.uk>
Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 drivers/mmc/host/tmio_mmc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index bf6252c..17415f8 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -85,8 +85,10 @@ static int tmio_mmc_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -EINVAL;
+	if (!res) {
+		ret = -EINVAL;
+		goto cell_disable;
+	}
 
 	/* SD control register space size is 0x200, 0x400 for bus_shift=1 */
 	pdata->bus_shift = resource_size(res) >> 10;
-- 
1.9.1


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

* [PATCH 3/6] mmc: TMIO: Use devm_ioremap()
  2014-04-30 16:59 tmio_mmc: Cleanups Ian Molton
  2014-04-30 16:59 ` [PATCH 1/6] mmc: TMIO: Refactor driver core probe function Ian Molton
  2014-04-30 16:59 ` [PATCH 2/6] mmc: TMIO: Fixup error return path Ian Molton
@ 2014-04-30 16:59 ` Ian Molton
  2014-04-30 16:59 ` [PATCH 4/6] mmc: TMIO: use devm_ for requesting irq Ian Molton
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Ian Molton @ 2014-04-30 16:59 UTC (permalink / raw)
  To: linux-mmc; +Cc: grant.likely, chris, Ian Molton

	Use devm_ioremap for tmio / sh_mobile.

Reviewed-by: Violeta Menendez <violeta.menendez@codethink.co.uk>
Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 drivers/mmc/host/tmio_mmc_pio.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 7db9310..50e8c01 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1021,7 +1021,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *host)
 	if (ret < 0)
 		goto host_free;
 
-	host->ctl = ioremap(res_ctl->start, resource_size(res_ctl));
+	host->ctl = devm_ioremap(dev, res_ctl->start, resource_size(res_ctl));
 	if (!host->ctl) {
 		ret = -ENOMEM;
 		goto host_free;
@@ -1119,7 +1119,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *host)
 
 pm_disable:
 	pm_runtime_disable(dev);
-	iounmap(host->ctl);
 host_free:
 	mmc_free_host(mmc);
 
@@ -1145,7 +1144,6 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-	iounmap(host->ctl);
 	mmc_free_host(mmc);
 }
 EXPORT_SYMBOL(tmio_mmc_host_remove);
-- 
1.9.1


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

* [PATCH 4/6] mmc: TMIO: use devm_ for requesting irq
  2014-04-30 16:59 tmio_mmc: Cleanups Ian Molton
                   ` (2 preceding siblings ...)
  2014-04-30 16:59 ` [PATCH 3/6] mmc: TMIO: Use devm_ioremap() Ian Molton
@ 2014-04-30 16:59 ` Ian Molton
  2014-04-30 16:59 ` [PATCH 5/6] shmobile: TMIO: break register specs out from TMIO kernel driver Ian Molton
  2014-04-30 16:59 ` [PATCH 6/6] mmc: TMIO: Move register definitions to where they belong Ian Molton
  5 siblings, 0 replies; 8+ messages in thread
From: Ian Molton @ 2014-04-30 16:59 UTC (permalink / raw)
  To: linux-mmc; +Cc: grant.likely, chris, Ian Molton

	Trivial patch to cleanup resource allocation and freeing.

Reviewed-by: Violeta Menendez <violeta.menendez@codethink.co.uk>
Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 drivers/mmc/host/tmio_mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index 17415f8..6b5184c 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -104,7 +104,8 @@ static int tmio_mmc_probe(struct platform_device *pdev)
 	if (ret)
 		goto cell_disable;
 
-	ret = request_irq(irq, tmio_mmc_irq, IRQF_TRIGGER_FALLING,
+	ret = devm_request_irq(&pdev->dev, irq, tmio_mmc_irq,
+				IRQF_TRIGGER_FALLING,
 				dev_name(&pdev->dev), host);
 	if (ret)
 		goto host_remove;
@@ -130,7 +131,6 @@ static int tmio_mmc_remove(struct platform_device *pdev)
 
 	if (mmc) {
 		struct tmio_mmc_host *host = mmc_priv(mmc);
-		free_irq(platform_get_irq(pdev, 0), host);
 		tmio_mmc_host_remove(host);
 		if (cell->disable)
 			cell->disable(pdev);
-- 
1.9.1


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

* [PATCH 5/6] shmobile: TMIO: break register specs out from TMIO kernel driver
  2014-04-30 16:59 tmio_mmc: Cleanups Ian Molton
                   ` (3 preceding siblings ...)
  2014-04-30 16:59 ` [PATCH 4/6] mmc: TMIO: use devm_ for requesting irq Ian Molton
@ 2014-04-30 16:59 ` Ian Molton
  2014-04-30 17:58   ` Ben Dooks
  2014-04-30 16:59 ` [PATCH 6/6] mmc: TMIO: Move register definitions to where they belong Ian Molton
  5 siblings, 1 reply; 8+ messages in thread
From: Ian Molton @ 2014-04-30 16:59 UTC (permalink / raw)
  To: linux-mmc; +Cc: grant.likely, chris, Ian Molton

	Right now we have a public header stuffed full of register defs
	that ought to be private to the TMIO MMC driver.

	Break out the definitions required for shmobiles bootloader.

	This commit is in preparation for making the TMIO register defs
	private, as they should be.

Reviewed-by: Violeta Menendez <violeta.menendez@codethink.co.uk>
Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 arch/arm/boot/compressed/sdhi-sh7372.c   |  2 +-
 arch/arm/boot/compressed/sdhi-shmobile.c | 35 +++++++++++++++++++++++++++-----
 arch/arm/boot/compressed/sdhi-shmobile.h |  2 ++
 3 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/compressed/sdhi-sh7372.c b/arch/arm/boot/compressed/sdhi-sh7372.c
index d279294..b05fba6 100644
--- a/arch/arm/boot/compressed/sdhi-sh7372.c
+++ b/arch/arm/boot/compressed/sdhi-sh7372.c
@@ -81,7 +81,7 @@ asmlinkage void mmc_loader(unsigned short *buf, unsigned long len)
 	/* load kernel */
 	if (sdhi_boot_do_read(SDHI_BASE, high_capacity,
 			      0, /* Kernel is at block 1 */
-			      (len + TMIO_BBS - 1) / TMIO_BBS, buf))
+			      (len + BB_SIZE - 1) / BB_SIZE, buf))
 		goto err;
 
         /* Disable clock to SDHI1 hardware block */
diff --git a/arch/arm/boot/compressed/sdhi-shmobile.c b/arch/arm/boot/compressed/sdhi-shmobile.c
index bd3d469..48be885 100644
--- a/arch/arm/boot/compressed/sdhi-shmobile.c
+++ b/arch/arm/boot/compressed/sdhi-shmobile.c
@@ -26,6 +26,17 @@
 
 #define RESP_CMD12		0x00000030
 
+#define CTL_SD_CMD		0x00
+#define CTL_ARG_REG		0x04
+#define CTL_RESPONSE		0x0c
+#define CTL_STATUS		0x1c
+#define CTL_IRQ_MASK		0x20
+#define CTL_SD_CARD_CLK_CTL	0x24
+#define CTL_SD_XFER_LEN		0x26
+#define CTL_SD_MEM_CARD_OPT	0x28
+#define CTL_RESET_SD		0xe0
+#define CTL_CLK_AND_WAIT_CTL	0x138
+
 static inline u16 sd_ctrl_read16(void __iomem *base, int addr)
 {
         return __raw_readw(base + addr);
@@ -48,6 +59,20 @@ static inline void sd_ctrl_write32(void __iomem *base, int addr, u32 val)
 	__raw_writew(val >> 16, base + addr + 2);
 }
 
+#define TMIO_STAT_CMDRESPEND    0x00000001
+#define TMIO_STAT_DATAEND       0x00000004
+#define TMIO_STAT_CMD_IDX_ERR   0x00010000
+#define TMIO_STAT_CRCFAIL       0x00020000
+#define TMIO_STAT_STOPBIT_ERR   0x00040000
+#define TMIO_STAT_DATATIMEOUT   0x00080000
+#define TMIO_STAT_RXOVERFLOW    0x00100000
+#define TMIO_STAT_TXUNDERRUN    0x00200000
+#define TMIO_STAT_CMDTIMEOUT    0x00400000
+#define TMIO_STAT_RXRDY         0x01000000
+#define TMIO_STAT_ILL_FUNC      0x20000000
+#define TMIO_STAT_CMD_BUSY      0x40000000
+#define TMIO_STAT_ILL_ACCESS    0x80000000
+
 #define ALL_ERROR (TMIO_STAT_CMD_IDX_ERR | TMIO_STAT_CRCFAIL |		\
 		   TMIO_STAT_STOPBIT_ERR | TMIO_STAT_DATATIMEOUT |	\
 		   TMIO_STAT_RXOVERFLOW | TMIO_STAT_TXUNDERRUN |	\
@@ -236,7 +261,7 @@ static int sdhi_boot_do_read_single(void __iomem *base, int high_capacity,
 		if (high_capacity)
 			cmd.arg = block;
 		else
-			cmd.arg = block * TMIO_BBS;
+			cmd.arg = block * BB_SIZE;
 		cmd.flags = MMC_RSP_R1;
 		err = sdhi_boot_request(base, &cmd);
 		if (err)
@@ -251,8 +276,8 @@ static int sdhi_boot_do_read_single(void __iomem *base, int high_capacity,
 	if (err)
 		return err;
 
-	sd_ctrl_write16(base, CTL_SD_XFER_LEN, TMIO_BBS);
-	for (i = 0; i < TMIO_BBS / sizeof(*buf); i++)
+	sd_ctrl_write16(base, CTL_SD_XFER_LEN, BB_SIZE);
+	for (i = 0; i < BB_SIZE / sizeof(*buf); i++)
 		*buf++ = sd_ctrl_read16(base, RESP_CMD12);
 
 	err = sdhi_boot_wait_resp_end(base);
@@ -271,7 +296,7 @@ int sdhi_boot_do_read(void __iomem *base, int high_capacity,
 
 	for (i = 0; i < count; i++) {
 		err = sdhi_boot_do_read_single(base, high_capacity, offset + i,
-					       buf + (i * TMIO_BBS /
+					       buf + (i * BB_SIZE /
 						      sizeof(*buf)));
 		if (err)
 			return err;
@@ -438,7 +463,7 @@ int sdhi_boot_init(void __iomem *base)
 	{
 		struct mmc_command cmd;
 		cmd.opcode = MMC_SET_BLOCKLEN;
-		cmd.arg = TMIO_BBS;
+		cmd.arg = BB_SIZE;
 		cmd.flags = MMC_RSP_R1;
 		err = sdhi_boot_request(base, &cmd);
 		if (err)
diff --git a/arch/arm/boot/compressed/sdhi-shmobile.h b/arch/arm/boot/compressed/sdhi-shmobile.h
index 92eaa09..d82e2d5 100644
--- a/arch/arm/boot/compressed/sdhi-shmobile.h
+++ b/arch/arm/boot/compressed/sdhi-shmobile.h
@@ -3,6 +3,8 @@
 
 #include <linux/compiler.h>
 
+#define BB_SIZE 512
+
 int sdhi_boot_do_read(void __iomem *base, int high_capacity,
 		      unsigned long offset, unsigned short count,
 		      unsigned short *buf);
-- 
1.9.1


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

* [PATCH 6/6] mmc: TMIO: Move register definitions to where they belong
  2014-04-30 16:59 tmio_mmc: Cleanups Ian Molton
                   ` (4 preceding siblings ...)
  2014-04-30 16:59 ` [PATCH 5/6] shmobile: TMIO: break register specs out from TMIO kernel driver Ian Molton
@ 2014-04-30 16:59 ` Ian Molton
  5 siblings, 0 replies; 8+ messages in thread
From: Ian Molton @ 2014-04-30 16:59 UTC (permalink / raw)
  To: linux-mmc; +Cc: grant.likely, chris, Ian Molton

	Simple move to remove a redundant header file from public view, when
it only contains driver-internal register definitions.

Reviewed-by: Violeta Menendez <violeta.menendez@codethink.co.uk>
Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 drivers/mmc/host/tmio_mmc.h     | 47 ++++++++++++++++++++++++++++-
 drivers/mmc/host/tmio_mmc_dma.c |  1 -
 drivers/mmc/host/tmio_mmc_pio.c |  1 -
 include/linux/mmc/tmio.h        | 66 -----------------------------------------
 4 files changed, 46 insertions(+), 69 deletions(-)
 delete mode 100644 include/linux/mmc/tmio.h

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 42894b7..08f4739 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -17,12 +17,57 @@
 #define TMIO_MMC_H
 
 #include <linux/highmem.h>
-#include <linux/mmc/tmio.h>
 #include <linux/mutex.h>
 #include <linux/pagemap.h>
 #include <linux/scatterlist.h>
 #include <linux/spinlock.h>
 
+#define CTL_SD_CMD 0x00
+#define CTL_ARG_REG 0x04
+#define CTL_STOP_INTERNAL_ACTION 0x08
+#define CTL_XFER_BLK_COUNT 0xa
+#define CTL_RESPONSE 0x0c
+#define CTL_STATUS 0x1c
+#define CTL_STATUS2 0x1e
+#define CTL_IRQ_MASK 0x20
+#define CTL_SD_CARD_CLK_CTL 0x24
+#define CTL_SD_XFER_LEN 0x26
+#define CTL_SD_MEM_CARD_OPT 0x28
+#define CTL_SD_ERROR_DETAIL_STATUS 0x2c
+#define CTL_SD_DATA_PORT 0x30
+#define CTL_TRANSACTION_CTL 0x34
+#define CTL_SDIO_STATUS 0x36
+#define CTL_SDIO_IRQ_MASK 0x38
+#define CTL_DMA_ENABLE 0xd8
+#define CTL_RESET_SD 0xe0
+#define CTL_VERSION 0xe2
+#define CTL_SDIO_REGS 0x100
+#define CTL_CLK_AND_WAIT_CTL 0x138
+#define CTL_RESET_SDIO 0x1e0
+
+/* Definitions for values the CTRL_STATUS register can take. */
+#define TMIO_STAT_CMDRESPEND    0x00000001
+#define TMIO_STAT_DATAEND       0x00000004
+#define TMIO_STAT_CARD_REMOVE   0x00000008
+#define TMIO_STAT_CARD_INSERT   0x00000010
+#define TMIO_STAT_SIGSTATE      0x00000020
+#define TMIO_STAT_WRPROTECT     0x00000080
+#define TMIO_STAT_CARD_REMOVE_A 0x00000100
+#define TMIO_STAT_CARD_INSERT_A 0x00000200
+#define TMIO_STAT_SIGSTATE_A    0x00000400
+#define TMIO_STAT_CMD_IDX_ERR   0x00010000
+#define TMIO_STAT_CRCFAIL       0x00020000
+#define TMIO_STAT_STOPBIT_ERR   0x00040000
+#define TMIO_STAT_DATATIMEOUT   0x00080000
+#define TMIO_STAT_RXOVERFLOW    0x00100000
+#define TMIO_STAT_TXUNDERRUN    0x00200000
+#define TMIO_STAT_CMDTIMEOUT    0x00400000
+#define TMIO_STAT_RXRDY         0x01000000
+#define TMIO_STAT_TXRQ          0x02000000
+#define TMIO_STAT_ILL_FUNC      0x20000000
+#define TMIO_STAT_CMD_BUSY      0x40000000
+#define TMIO_STAT_ILL_ACCESS    0x80000000
+
 /* Definitions for values the CTRL_SDIO_STATUS register can take. */
 #define TMIO_SDIO_STAT_IOIRQ	0x0001
 #define TMIO_SDIO_STAT_EXPUB52	0x4000
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
index 03e7b28..1872d6c 100644
--- a/drivers/mmc/host/tmio_mmc_dma.c
+++ b/drivers/mmc/host/tmio_mmc_dma.c
@@ -15,7 +15,6 @@
 #include <linux/dmaengine.h>
 #include <linux/mfd/tmio.h>
 #include <linux/mmc/host.h>
-#include <linux/mmc/tmio.h>
 #include <linux/pagemap.h>
 #include <linux/scatterlist.h>
 
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 50e8c01..ed71b73 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -37,7 +37,6 @@
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
 #include <linux/mmc/slot-gpio.h>
-#include <linux/mmc/tmio.h>
 #include <linux/module.h>
 #include <linux/pagemap.h>
 #include <linux/platform_device.h>
diff --git a/include/linux/mmc/tmio.h b/include/linux/mmc/tmio.h
deleted file mode 100644
index 84d9053..0000000
--- a/include/linux/mmc/tmio.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * include/linux/mmc/tmio.h
- *
- * Copyright (C) 2007 Ian Molton
- * Copyright (C) 2004 Ian Molton
- *
- * 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
- */
-#ifndef LINUX_MMC_TMIO_H
-#define LINUX_MMC_TMIO_H
-
-#define CTL_SD_CMD 0x00
-#define CTL_ARG_REG 0x04
-#define CTL_STOP_INTERNAL_ACTION 0x08
-#define CTL_XFER_BLK_COUNT 0xa
-#define CTL_RESPONSE 0x0c
-#define CTL_STATUS 0x1c
-#define CTL_STATUS2 0x1e
-#define CTL_IRQ_MASK 0x20
-#define CTL_SD_CARD_CLK_CTL 0x24
-#define CTL_SD_XFER_LEN 0x26
-#define CTL_SD_MEM_CARD_OPT 0x28
-#define CTL_SD_ERROR_DETAIL_STATUS 0x2c
-#define CTL_SD_DATA_PORT 0x30
-#define CTL_TRANSACTION_CTL 0x34
-#define CTL_SDIO_STATUS 0x36
-#define CTL_SDIO_IRQ_MASK 0x38
-#define CTL_DMA_ENABLE 0xd8
-#define CTL_RESET_SD 0xe0
-#define CTL_VERSION 0xe2
-#define CTL_SDIO_REGS 0x100
-#define CTL_CLK_AND_WAIT_CTL 0x138
-#define CTL_RESET_SDIO 0x1e0
-
-/* Definitions for values the CTRL_STATUS register can take. */
-#define TMIO_STAT_CMDRESPEND    0x00000001
-#define TMIO_STAT_DATAEND       0x00000004
-#define TMIO_STAT_CARD_REMOVE   0x00000008
-#define TMIO_STAT_CARD_INSERT   0x00000010
-#define TMIO_STAT_SIGSTATE      0x00000020
-#define TMIO_STAT_WRPROTECT     0x00000080
-#define TMIO_STAT_CARD_REMOVE_A 0x00000100
-#define TMIO_STAT_CARD_INSERT_A 0x00000200
-#define TMIO_STAT_SIGSTATE_A    0x00000400
-#define TMIO_STAT_CMD_IDX_ERR   0x00010000
-#define TMIO_STAT_CRCFAIL       0x00020000
-#define TMIO_STAT_STOPBIT_ERR   0x00040000
-#define TMIO_STAT_DATATIMEOUT   0x00080000
-#define TMIO_STAT_RXOVERFLOW    0x00100000
-#define TMIO_STAT_TXUNDERRUN    0x00200000
-#define TMIO_STAT_CMDTIMEOUT    0x00400000
-#define TMIO_STAT_RXRDY         0x01000000
-#define TMIO_STAT_TXRQ          0x02000000
-#define TMIO_STAT_ILL_FUNC      0x20000000
-#define TMIO_STAT_CMD_BUSY      0x40000000
-#define TMIO_STAT_ILL_ACCESS    0x80000000
-
-#define TMIO_BBS		512		/* Boot block size */
-
-#endif /* LINUX_MMC_TMIO_H */
-- 
1.9.1


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

* Re: [PATCH 5/6] shmobile: TMIO: break register specs out from TMIO kernel driver
  2014-04-30 16:59 ` [PATCH 5/6] shmobile: TMIO: break register specs out from TMIO kernel driver Ian Molton
@ 2014-04-30 17:58   ` Ben Dooks
  0 siblings, 0 replies; 8+ messages in thread
From: Ben Dooks @ 2014-04-30 17:58 UTC (permalink / raw)
  To: Ian Molton; +Cc: linux-mmc, grant.likely, chris

On Wed, Apr 30, 2014 at 05:59:10PM +0100, Ian Molton wrote:
> 	Right now we have a public header stuffed full of register defs
> 	that ought to be private to the TMIO MMC driver.
> 
> 	Break out the definitions required for shmobiles bootloader.
> 
> 	This commit is in preparation for making the TMIO register defs
> 	private, as they should be.

No need to indent the patch description.
 
> Reviewed-by: Violeta Menendez <violeta.menendez@codethink.co.uk>
> Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
> ---
>  arch/arm/boot/compressed/sdhi-sh7372.c   |  2 +-
>  arch/arm/boot/compressed/sdhi-shmobile.c | 35 +++++++++++++++++++++++++++-----
>  arch/arm/boot/compressed/sdhi-shmobile.h |  2 ++
>  3 files changed, 33 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/boot/compressed/sdhi-sh7372.c b/arch/arm/boot/compressed/sdhi-sh7372.c
> index d279294..b05fba6 100644
> --- a/arch/arm/boot/compressed/sdhi-sh7372.c
> +++ b/arch/arm/boot/compressed/sdhi-sh7372.c
> @@ -81,7 +81,7 @@ asmlinkage void mmc_loader(unsigned short *buf, unsigned long len)
>  	/* load kernel */
>  	if (sdhi_boot_do_read(SDHI_BASE, high_capacity,
>  			      0, /* Kernel is at block 1 */
> -			      (len + TMIO_BBS - 1) / TMIO_BBS, buf))
> +			      (len + BB_SIZE - 1) / BB_SIZE, buf))
>  		goto err;
>  
>          /* Disable clock to SDHI1 hardware block */
> diff --git a/arch/arm/boot/compressed/sdhi-shmobile.c b/arch/arm/boot/compressed/sdhi-shmobile.c
> index bd3d469..48be885 100644
> --- a/arch/arm/boot/compressed/sdhi-shmobile.c
> +++ b/arch/arm/boot/compressed/sdhi-shmobile.c
> @@ -26,6 +26,17 @@
>  
>  #define RESP_CMD12		0x00000030
>  
> +#define CTL_SD_CMD		0x00
> +#define CTL_ARG_REG		0x04
> +#define CTL_RESPONSE		0x0c
> +#define CTL_STATUS		0x1c
> +#define CTL_IRQ_MASK		0x20
> +#define CTL_SD_CARD_CLK_CTL	0x24
> +#define CTL_SD_XFER_LEN		0x26
> +#define CTL_SD_MEM_CARD_OPT	0x28
> +#define CTL_RESET_SD		0xe0
> +#define CTL_CLK_AND_WAIT_CTL	0x138
> +
>  static inline u16 sd_ctrl_read16(void __iomem *base, int addr)
>  {
>          return __raw_readw(base + addr);
> @@ -48,6 +59,20 @@ static inline void sd_ctrl_write32(void __iomem *base, int addr, u32 val)
>  	__raw_writew(val >> 16, base + addr + 2);
>  }
>  
> +#define TMIO_STAT_CMDRESPEND    0x00000001
> +#define TMIO_STAT_DATAEND       0x00000004
> +#define TMIO_STAT_CMD_IDX_ERR   0x00010000
> +#define TMIO_STAT_CRCFAIL       0x00020000
> +#define TMIO_STAT_STOPBIT_ERR   0x00040000
> +#define TMIO_STAT_DATATIMEOUT   0x00080000
> +#define TMIO_STAT_RXOVERFLOW    0x00100000
> +#define TMIO_STAT_TXUNDERRUN    0x00200000
> +#define TMIO_STAT_CMDTIMEOUT    0x00400000
> +#define TMIO_STAT_RXRDY         0x01000000
> +#define TMIO_STAT_ILL_FUNC      0x20000000
> +#define TMIO_STAT_CMD_BUSY      0x40000000
> +#define TMIO_STAT_ILL_ACCESS    0x80000000
> +
>  #define ALL_ERROR (TMIO_STAT_CMD_IDX_ERR | TMIO_STAT_CRCFAIL |		\
>  		   TMIO_STAT_STOPBIT_ERR | TMIO_STAT_DATATIMEOUT |	\
>  		   TMIO_STAT_RXOVERFLOW | TMIO_STAT_TXUNDERRUN |	\
> @@ -236,7 +261,7 @@ static int sdhi_boot_do_read_single(void __iomem *base, int high_capacity,
>  		if (high_capacity)
>  			cmd.arg = block;
>  		else
> -			cmd.arg = block * TMIO_BBS;
> +			cmd.arg = block * BB_SIZE;
>  		cmd.flags = MMC_RSP_R1;
>  		err = sdhi_boot_request(base, &cmd);
>  		if (err)
> @@ -251,8 +276,8 @@ static int sdhi_boot_do_read_single(void __iomem *base, int high_capacity,
>  	if (err)
>  		return err;
>  
> -	sd_ctrl_write16(base, CTL_SD_XFER_LEN, TMIO_BBS);
> -	for (i = 0; i < TMIO_BBS / sizeof(*buf); i++)
> +	sd_ctrl_write16(base, CTL_SD_XFER_LEN, BB_SIZE);
> +	for (i = 0; i < BB_SIZE / sizeof(*buf); i++)
>  		*buf++ = sd_ctrl_read16(base, RESP_CMD12);
>  
>  	err = sdhi_boot_wait_resp_end(base);
> @@ -271,7 +296,7 @@ int sdhi_boot_do_read(void __iomem *base, int high_capacity,
>  
>  	for (i = 0; i < count; i++) {
>  		err = sdhi_boot_do_read_single(base, high_capacity, offset + i,
> -					       buf + (i * TMIO_BBS /
> +					       buf + (i * BB_SIZE /
>  						      sizeof(*buf)));
>  		if (err)
>  			return err;
> @@ -438,7 +463,7 @@ int sdhi_boot_init(void __iomem *base)
>  	{
>  		struct mmc_command cmd;
>  		cmd.opcode = MMC_SET_BLOCKLEN;
> -		cmd.arg = TMIO_BBS;
> +		cmd.arg = BB_SIZE;
>  		cmd.flags = MMC_RSP_R1;
>  		err = sdhi_boot_request(base, &cmd);
>  		if (err)
> diff --git a/arch/arm/boot/compressed/sdhi-shmobile.h b/arch/arm/boot/compressed/sdhi-shmobile.h
> index 92eaa09..d82e2d5 100644
> --- a/arch/arm/boot/compressed/sdhi-shmobile.h
> +++ b/arch/arm/boot/compressed/sdhi-shmobile.h
> @@ -3,6 +3,8 @@
>  
>  #include <linux/compiler.h>
>  
> +#define BB_SIZE 512
> +
>  int sdhi_boot_do_read(void __iomem *base, int high_capacity,
>  		      unsigned long offset, unsigned short count,
>  		      unsigned short *buf);
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben Dooks, ben@fluff.org, http://www.fluff.org/ben/

Large Hadron Colada: A large Pina Colada that makes the universe disappear.


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

end of thread, other threads:[~2014-04-30 18:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-30 16:59 tmio_mmc: Cleanups Ian Molton
2014-04-30 16:59 ` [PATCH 1/6] mmc: TMIO: Refactor driver core probe function Ian Molton
2014-04-30 16:59 ` [PATCH 2/6] mmc: TMIO: Fixup error return path Ian Molton
2014-04-30 16:59 ` [PATCH 3/6] mmc: TMIO: Use devm_ioremap() Ian Molton
2014-04-30 16:59 ` [PATCH 4/6] mmc: TMIO: use devm_ for requesting irq Ian Molton
2014-04-30 16:59 ` [PATCH 5/6] shmobile: TMIO: break register specs out from TMIO kernel driver Ian Molton
2014-04-30 17:58   ` Ben Dooks
2014-04-30 16:59 ` [PATCH 6/6] mmc: TMIO: Move register definitions to where they belong Ian Molton

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.