Skip to contentSkip to conversation

mmc: omap: Assorted fixes for 3.4 merge window

GIT PULL In review Venkatraman S 4 participants 16 messages Mar 16, 2012 – Apr 2, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Chris,
Here are a group of fixes posted by Felipe and Balaji for the
OMAP hsmmc driver in the past few days.
I've rebased them to the lastest mmc-next and posted them
here again. These have also been tested on OMAP4 development platform.

Please feel to apply directly or pull if that's convenient.

Changes since yesterday (v1):-
Fixed formatting issues as suggested by Felipe Marked some patches for stable.

The following changes since commit 5f0390f10c0e9c9c504cdbf4af802252628a2490:

mmc: omap_hsmmc: Avoid a regulator voltage change with dt (2012-03-14 11:33:20 -0400)

are available in the git repository at:

git://github.com/svenkatr/linux.git omap-mmc-pending-for-3.4

for you to fetch changes up to 8d54766b608915035b47616ea564e4e9b4dda29c:

mmc: omap4: hsmmc: fix module re-insertion (2012-03-16 11:38:41 +0530)

----------------------------------------------------------------
Balaji T K (5):
mmc: omap: Enable Auto CMD12
mmc: omap: add DDR support to omap_hsmmc
mmc: omap: use runtime put sync in probe error patch
mmc: omap: context save after enabling runtime pm
mmc: omap4: hsmmc: fix module re-insertion

Felipe Balbi (3):
mmc: host: omap_hsmmc: trivial cleanups
mmc: host: omap_hsmmc: make it behave well as a module
mmc: host: omap_hsmmc: convert to module_platform_driver

 drivers/mmc/host/omap_hsmmc.c |  202 ++++++++++++++++++++++------------------------
 1 file changed, 97 insertions(+), 105 deletions(-)
#1 lore raw

PATCH v2 1/8 mmc: omap: Enable Auto CMD12

From: Balaji T K <[email protected]>

Enable Auto-CMD12 for multi block read/write on HSMMC Tested on OMAP4430, OMAP3430 and OMAP2430 SDP

---
 drivers/mmc/host/omap_hsmmc.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/mmc/host/omap_hsmmc.c +13 -3
index f29e1a2..a9ffd70 100644
@@ -85,6 +85,7 @@
 #define BRR_ENABLE		(1 << 5)
 #define DTO_ENABLE		(1 << 20)
 #define INIT_STREAM		(1 << 1)
+#define ACEN_ACMD12		(1 << 2)
 #define DP_SELECT		(1 << 21)
 #define DDIR			(1 << 4)
 #define DMA_EN			0x1
@@ -115,6 +116,7 @@
 #define OMAP_MMC_MAX_CLOCK	52000000
 #define DRIVER_NAME		"omap_hsmmc"
 
+#define AUTO_CMD12		(1 << 0)	/* Auto CMD12 support */
 /*
  * One controller can have multiple slots, like on some omap boards using
  * omap.c controller driver. Luckily this is not currently done on any known
@@ -175,6 +177,7 @@ struct omap_hsmmc_host {
 	int			reqs_blocked;
 	int			use_reg;
 	int			req_in_progress;
+	unsigned int		flags;
 	struct omap_hsmmc_next	next_data;
 
 	struct	omap_mmc_platform_data	*pdata;
@@ -766,6 +769,8 @@ omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd,
 		cmdtype = 0x3;
 
 	cmdreg = (cmd->opcode << 24) | (resptype << 16) | (cmdtype << 22);
+	if ((host->flags & AUTO_CMD12) && mmc_op_multi(cmd->opcode))
+		cmdreg |= ACEN_ACMD12;
 
 	if (data) {
 		cmdreg |= DP_SELECT | MSBS | BCE;
@@ -837,11 +842,15 @@ omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data)
 	else
 		data->bytes_xfered = 0;
 
-	if (!data->stop) {
+	if (data->stop && ((!(host->flags & AUTO_CMD12)) || data->error)) {
+		omap_hsmmc_start_command(host, data->stop, NULL);
+	}
+	else {
+		if (data->stop)
+			data->stop->resp[0] = OMAP_HSMMC_READ(host->base,
+							RSP76);
 		omap_hsmmc_request_done(host, data->mrq);
-		return;
 	}
-	omap_hsmmc_start_command(host, data->stop, NULL);
 }
 
 /*
@@ -1826,6 +1835,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
 	host->mapbase	= res->start;
 	host->base	= ioremap(host->mapbase, SZ_4K);
 	host->power_mode = MMC_POWER_OFF;
+	host->flags	= AUTO_CMD12;
 	host->next_data.cookie = 1;
 
 	platform_set_drvdata(pdev, host);
Signature · 1 line
1.7.10.rc0.41.gfa678
#2 lore raw

Re: [PATCH v2 1/8] mmc: omap: Enable Auto CMD12

Quoted 49 lines · Venkatraman S

From: Balaji T K <[email protected]>

Enable Auto-CMD12 for multi block read/write on HSMMC Tested on OMAP4430, OMAP3430 and OMAP2430 SDP

---
 drivers/mmc/host/omap_hsmmc.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/mmc/host/omap_hsmmc.c +5 -0
index f29e1a2..a9ffd70 100644
@@ -85,6 +85,7 @@
 #define BRR_ENABLE		(1 << 5)
 #define DTO_ENABLE		(1 << 20)
 #define INIT_STREAM		(1 << 1)
+#define ACEN_ACMD12		(1 << 2)
 #define DP_SELECT		(1 << 21)
 #define DDIR			(1 << 4)
 #define DMA_EN			0x1
@@ -115,6 +116,7 @@
 #define OMAP_MMC_MAX_CLOCK	52000000
 #define DRIVER_NAME		"omap_hsmmc"
 
+#define AUTO_CMD12		(1 << 0)	/* Auto CMD12 support */
 /*
  * One controller can have multiple slots, like on some omap boards using
  * omap.c controller driver. Luckily this is not currently done on any known
@@ -175,6 +177,7 @@ struct omap_hsmmc_host {
 	int			reqs_blocked;
 	int			use_reg;
 	int			req_in_progress;
+	unsigned int		flags;
 	struct omap_hsmmc_next	next_data;
 
 	struct	omap_mmc_platform_data	*pdata;
@@ -766,6 +769,8 @@ omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd,
 		cmdtype = 0x3;
 
 	cmdreg = (cmd->opcode << 24) | (resptype << 16) | (cmdtype << 22);
+	if ((host->flags & AUTO_CMD12) && mmc_op_multi(cmd->opcode))
+		cmdreg |= ACEN_ACMD12;
 
 	if (data) {
 		cmdreg |= DP_SELECT | MSBS | BCE;

drivers/mmc/host/omap_hsmmc.c omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data) · line 848

Quoted 8 lines
drivers/mmc/host/omap_hsmmc.c +4 -1
@@ -837,11 +842,15 @@ omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data)
 	else
 		data->bytes_xfered = 0;
 
-	if (!data->stop) {
+	if (data->stop && ((!(host->flags & AUTO_CMD12)) || data->error)) {
+		omap_hsmmc_start_command(host, data->stop, NULL);
+	}
+	else {

while adding the braces, you broke the coding style. Please fix.

Signature · 1 line
balbi
#3 lore raw

Re: [PATCH v2 1/8] mmc: omap: Enable Auto CMD12

Quoted 53 lines · Felipe Balbi
Quoted 52 lines · Venkatraman S

From: Balaji T K <[email protected]>

Enable Auto-CMD12 for multi block read/write on HSMMC Tested on OMAP4430, OMAP3430 and OMAP2430 SDP

---
 drivers/mmc/host/omap_hsmmc.c |   16 +++++++++++++---

 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/mmc/host/omap_hsmmc.c +5 -0
index f29e1a2..a9ffd70 100644
@@ -85,6 +85,7 @@
  #define BRR_ENABLE           (1 << 5)
  #define DTO_ENABLE           (1 << 20)
  #define INIT_STREAM          (1 << 1)
+#define ACEN_ACMD12          (1 << 2)
  #define DP_SELECT            (1 << 21)
  #define DDIR                 (1 << 4)
  #define DMA_EN                       0x1
@@ -115,6 +116,7 @@
  #define OMAP_MMC_MAX_CLOCK   52000000
  #define DRIVER_NAME          "omap_hsmmc"
 
+#define AUTO_CMD12           (1 << 0)        /* Auto CMD12 support */
  /*
   * One controller can have multiple slots, like on some omap boards using
   * omap.c controller driver. Luckily this is not currently done on any known
@@ -175,6 +177,7 @@ struct omap_hsmmc_host {
       int                     reqs_blocked;
       int                     use_reg;
       int                     req_in_progress;
+     unsigned int            flags;
       struct omap_hsmmc_next  next_data;
 
       struct  omap_mmc_platform_data  *pdata;
@@ -766,6 +769,8 @@ omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd,
               cmdtype = 0x3;
 
       cmdreg = (cmd->opcode << 24) | (resptype << 16) | (cmdtype << 22);
+     if ((host->flags & AUTO_CMD12) && mmc_op_multi(cmd->opcode))
+             cmdreg |= ACEN_ACMD12;
 
       if (data) {
               cmdreg |= DP_SELECT | MSBS | BCE;
@@ -837,11 +842,15 @@ omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data)

      else
              data->bytes_xfered = 0;

Quoted 8 lines
Quoted 5 lines

-     if (!data->stop) {
+     if (data->stop && ((!(host->flags & AUTO_CMD12)) || data->error)) {
+             omap_hsmmc_start_command(host, data->stop, NULL);
+     }
+     else {

while adding the braces, you broke the coding style. Please fix.

Oops - now fixed (and pushed out).

From 00ae42358249e879698029201e3cbb9ea155305e Mon Sep 17 00:00:00 2001
From: Balaji T K <[email protected]>
Date: Fri, 24 Feb 2012 21:14:31 +0530
Subject: [PATCH] mmc: omap: Enable Auto CMD12

Enable Auto-CMD12 for multi block read/write on HSMMC Tested on OMAP4430, OMAP3430 and OMAP2430 SDP

---
 drivers/mmc/host/omap_hsmmc.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/mmc/host/omap_hsmmc.c +3 -0
index f29e1a2..729ac72 100644
@@ -85,6 +85,7 @@
 #define BRR_ENABLE		(1 << 5)
 #define DTO_ENABLE		(1 << 20)
 #define INIT_STREAM		(1 << 1)
+#define ACEN_ACMD12		(1 << 2)
 #define DP_SELECT		(1 << 21)
 #define DDIR			(1 << 4)
 #define DMA_EN			0x1
@@ -115,6 +116,7 @@
 #define OMAP_MMC_MAX_CLOCK	52000000
 #define DRIVER_NAME		"omap_hsmmc"
 
+#define AUTO_CMD12		(1 << 0)	/* Auto CMD12 support */
 /*
  * One controller can have multiple slots, like on some omap boards using
  * omap.c controller driver. Luckily this is not currently done on any known
@@ -175,6 +177,7 @@ struct omap_hsmmc_host {
 	int			reqs_blocked;
 	int			use_reg;
 	int			req_in_progress;
+	unsigned int		flags;
 	struct omap_hsmmc_next	next_data;
 
 	struct	omap_mmc_platform_data	*pdata;
@@ -766,6 +769,8 @@ omap_hsmmc_start_command(struct omap_hsmmc_host

*host, struct mmc_command *cmd,
cmdtype = 0x3;

cmdreg = (cmd->opcode << 24) | (resptype << 16) | (cmdtype << 22);
+ if ((host->flags & AUTO_CMD12) && mmc_op_multi(cmd->opcode))
+ cmdreg |= ACEN_ACMD12;

if (data) {
cmdreg |= DP_SELECT | MSBS | BCE;
@@ -837,11 +842,14 @@ omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data)
else
data->bytes_xfered = 0;

- if (!data->stop) {
+ if (data->stop && ((!(host->flags & AUTO_CMD12)) || data->error)) {
+ omap_hsmmc_start_command(host, data->stop, NULL);
+ } else {
+ if (data->stop)
+ data->stop->resp[0] = OMAP_HSMMC_READ(host->base,
+ RSP76);
omap_hsmmc_request_done(host, data->mrq);
- return;
}
- omap_hsmmc_start_command(host, data->stop, NULL);
}

/*
@@ -1826,6 +1834,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
host->mapbase = res->start;
host->base = ioremap(host->mapbase, SZ_4K);
host->power_mode = MMC_POWER_OFF;
+ host->flags = AUTO_CMD12;
host->next_data.cookie = 1;

platform_set_drvdata(pdev, host);

Signature · 1 line
1.7.10.rc0.41.gfa678
#4 lore raw

PATCH v2 2/8 mmc: omap: add DDR support to omap_hsmmc

In reply to Venkatraman S

From: Balaji T K <[email protected]>

Add Dual data rate support for omap_hsmmc

---
 drivers/mmc/host/omap_hsmmc.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/mmc/host/omap_hsmmc.c +5 -0
index a9ffd70..d682c5e 100644
@@ -92,6 +92,7 @@
 #define MSBS			(1 << 5)
 #define BCE			(1 << 1)
 #define FOUR_BIT		(1 << 1)
+#define DDR			(1 << 19)
 #define DW8			(1 << 5)
 #define CC			0x1
 #define TC			0x02
@@ -523,6 +524,10 @@ static void omap_hsmmc_set_bus_width(struct omap_hsmmc_host *host)
 	u32 con;
 
 	con = OMAP_HSMMC_READ(host->base, CON);
+	if (ios->timing == MMC_TIMING_UHS_DDR50)
+		con |= DDR;	/* configure in DDR mode */
+	else
+		con &= ~DDR;
 	switch (ios->bus_width) {
 	case MMC_BUS_WIDTH_8:
 		OMAP_HSMMC_WRITE(host->base, CON, con | DW8);
Signature · 1 line
1.7.10.rc0.41.gfa678
#5 lore raw

PATCH v2 3/8 mmc: omap: use runtime put sync in probe error patch

In reply to Venkatraman S

From: Balaji T K <[email protected]>

pm_runtime_put_sync instead of autosuspend pm runtime API because iounmap(host->base) follows immediately.

---
 drivers/mmc/host/omap_hsmmc.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/host/omap_hsmmc.c +1 -2
index d682c5e..baa06f9 100644
@@ -2013,8 +2013,7 @@ err_reg:
 err_irq_cd_init:
 	free_irq(host->irq, host);
 err_irq:
-	pm_runtime_mark_last_busy(host->dev);
-	pm_runtime_put_autosuspend(host->dev);
+	pm_runtime_put_sync(host->dev);
 	pm_runtime_disable(host->dev);
 	clk_put(host->fclk);
 	if (host->got_dbclk) {
Signature · 1 line
1.7.10.rc0.41.gfa678
#6 lore raw

PATCH v2 4/8 mmc: omap: context save after enabling runtime pm

In reply to Venkatraman S

From: Balaji T K <[email protected]>

call context save api after enabling runtime pm
to make sure register access in context save api happens with clk enabled.

---
 drivers/mmc/host/omap_hsmmc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/omap_hsmmc.c +2 -2
index baa06f9..2822442 100644
@@ -1870,8 +1870,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
 		goto err1;
 	}
 
-	omap_hsmmc_context_save(host);
-
 	if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) {
 		dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n");
 		mmc->caps2 |= MMC_CAP2_NO_MULTI_READ;
@@ -1882,6 +1880,8 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
 	pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY);
 	pm_runtime_use_autosuspend(host->dev);
 
+	omap_hsmmc_context_save(host);
+
 	if (cpu_is_omap2430()) {
 		host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
 		/*
Signature · 1 line
1.7.10.rc0.41.gfa678
#7 lore raw

PATCH v2 5/8 mmc: host: omap_hsmmc: trivial cleanups

In reply to Venkatraman S

From: Felipe Balbi <[email protected]>

a bunch of non-functional cleanups to the omap_hsmmc driver.

It basically decreases indentation level, drop unneded dereferences and drop unneded accesses to the platform_device structure.

---
 drivers/mmc/host/omap_hsmmc.c |  147 ++++++++++++++++++++---------------------
 1 file changed, 70 insertions(+), 77 deletions(-)
drivers/mmc/host/omap_hsmmc.c +70 -77
index 2822442..c16c552 100644
@@ -2036,30 +2036,28 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 	struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
 	struct resource *res;
 
-	if (host) {
-		pm_runtime_get_sync(host->dev);
-		mmc_remove_host(host->mmc);
-		if (host->use_reg)
-			omap_hsmmc_reg_put(host);
-		if (host->pdata->cleanup)
-			host->pdata->cleanup(&pdev->dev);
-		free_irq(host->irq, host);
-		if (mmc_slot(host).card_detect_irq)
-			free_irq(mmc_slot(host).card_detect_irq, host);
-
-		pm_runtime_put_sync(host->dev);
-		pm_runtime_disable(host->dev);
-		clk_put(host->fclk);
-		if (host->got_dbclk) {
-			clk_disable(host->dbclk);
-			clk_put(host->dbclk);
-		}
+	pm_runtime_get_sync(host->dev);
+	mmc_remove_host(host->mmc);
+	if (host->use_reg)
+		omap_hsmmc_reg_put(host);
+	if (host->pdata->cleanup)
+		host->pdata->cleanup(&pdev->dev);
+	free_irq(host->irq, host);
+	if (mmc_slot(host).card_detect_irq)
+		free_irq(mmc_slot(host).card_detect_irq, host);
 
-		mmc_free_host(host->mmc);
-		iounmap(host->base);
-		omap_hsmmc_gpio_free(pdev->dev.platform_data);
+	pm_runtime_put_sync(host->dev);
+	pm_runtime_disable(host->dev);
+	clk_put(host->fclk);
+	if (host->got_dbclk) {
+		clk_disable(host->dbclk);
+		clk_put(host->dbclk);
 	}
 
+	mmc_free_host(host->mmc);
+	iounmap(host->base);
+	omap_hsmmc_gpio_free(pdev->dev.platform_data);
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (res)
 		release_mem_region(res->start, resource_size(res));
@@ -2072,49 +2070,45 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 static int omap_hsmmc_suspend(struct device *dev)
 {
 	int ret = 0;
-	struct platform_device *pdev = to_platform_device(dev);
-	struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
+	struct omap_hsmmc_host *host = dev_get_drvdata(dev);
 
-	if (host && host->suspended)
+	if (!host)
 		return 0;
 
-	if (host) {
-		pm_runtime_get_sync(host->dev);
-		host->suspended = 1;
-		if (host->pdata->suspend) {
-			ret = host->pdata->suspend(&pdev->dev,
-							host->slot_id);
-			if (ret) {
-				dev_dbg(mmc_dev(host->mmc),
-					"Unable to handle MMC board"
-					" level suspend\n");
-				host->suspended = 0;
-				return ret;
-			}
-		}
-		ret = mmc_suspend_host(host->mmc);
+	if (host && host->suspended)
+		return 0;
 
+	pm_runtime_get_sync(host->dev);
+	host->suspended = 1;
+	if (host->pdata->suspend) {
+		ret = host->pdata->suspend(dev, host->slot_id);
 		if (ret) {
+			dev_dbg(dev, "Unable to handle MMC board"
+					" level suspend\n");
 			host->suspended = 0;
-			if (host->pdata->resume) {
-				ret = host->pdata->resume(&pdev->dev,
-							  host->slot_id);
-				if (ret)
-					dev_dbg(mmc_dev(host->mmc),
-						"Unmask interrupt failed\n");
-			}
-			goto err;
+			return ret;
 		}
+	}
+	ret = mmc_suspend_host(host->mmc);
 
-		if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) {
-			omap_hsmmc_disable_irq(host);
-			OMAP_HSMMC_WRITE(host->base, HCTL,
-				OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);
+	if (ret) {
+		host->suspended = 0;
+		if (host->pdata->resume) {
+			ret = host->pdata->resume(dev, host->slot_id);
+			if (ret)
+				dev_dbg(dev, "Unmask interrupt failed\n");
 		}
-		if (host->got_dbclk)
-			clk_disable(host->dbclk);
+		goto err;
+	}
 
+	if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) {
+		omap_hsmmc_disable_irq(host);
+		OMAP_HSMMC_WRITE(host->base, HCTL,
+				OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);
 	}
+
+	if (host->got_dbclk)
+		clk_disable(host->dbclk);
 err:
 	pm_runtime_put_sync(host->dev);
 	return ret;
@@ -2124,38 +2118,37 @@ err:
 static int omap_hsmmc_resume(struct device *dev)
 {
 	int ret = 0;
-	struct platform_device *pdev = to_platform_device(dev);
-	struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
+	struct omap_hsmmc_host *host = dev_get_drvdata(dev);
+
+	if (!host)
+		return 0;
 
 	if (host && !host->suspended)
 		return 0;
 
-	if (host) {
-		pm_runtime_get_sync(host->dev);
+	pm_runtime_get_sync(host->dev);
 
-		if (host->got_dbclk)
-			clk_enable(host->dbclk);
+	if (host->got_dbclk)
+		clk_enable(host->dbclk);
 
-		if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER))
-			omap_hsmmc_conf_bus_power(host);
+	if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER))
+		omap_hsmmc_conf_bus_power(host);
 
-		if (host->pdata->resume) {
-			ret = host->pdata->resume(&pdev->dev, host->slot_id);
-			if (ret)
-				dev_dbg(mmc_dev(host->mmc),
-					"Unmask interrupt failed\n");
-		}
+	if (host->pdata->resume) {
+		ret = host->pdata->resume(dev, host->slot_id);
+		if (ret)
+			dev_dbg(dev, "Unmask interrupt failed\n");
+	}
 
-		omap_hsmmc_protect_card(host);
+	omap_hsmmc_protect_card(host);
 
-		/* Notify the core to resume the host */
-		ret = mmc_resume_host(host->mmc);
-		if (ret == 0)
-			host->suspended = 0;
+	/* Notify the core to resume the host */
+	ret = mmc_resume_host(host->mmc);
+	if (ret == 0)
+		host->suspended = 0;
 
-		pm_runtime_mark_last_busy(host->dev);
-		pm_runtime_put_autosuspend(host->dev);
-	}
+	pm_runtime_mark_last_busy(host->dev);
+	pm_runtime_put_autosuspend(host->dev);
 
 	return ret;
 
@@ -2172,7 +2165,7 @@ static int omap_hsmmc_runtime_suspend(struct device *dev)
 
 	host = platform_get_drvdata(to_platform_device(dev));
 	omap_hsmmc_context_save(host);
-	dev_dbg(mmc_dev(host->mmc), "disabled\n");
+	dev_dbg(dev, "disabled\n");
 
 	return 0;
 }
@@ -2183,7 +2176,7 @@ static int omap_hsmmc_runtime_resume(struct device *dev)
 
 	host = platform_get_drvdata(to_platform_device(dev));
 	omap_hsmmc_context_restore(host);
-	dev_dbg(mmc_dev(host->mmc), "enabled\n");
+	dev_dbg(dev, "enabled\n");
 
 	return 0;
 }
Signature · 1 line
1.7.10.rc0.41.gfa678
#8 lore raw

RE: [PATCH v2 5/8] mmc: host: omap_hsmmc: trivial cleanups

Quoted 6 lines · Venkatraman

From: Felipe Balbi <[email protected]>

a bunch of non-functional cleanups to the omap_hsmmc driver.

It basically decreases indentation level, drop unneeded

s/unneeded/unneeded. Better to use unnecessary

Quoted 1 line

dereferences and drop unneded accesses to the platform_device

Same as above

Quoted 5 lines

structure.

---

..snip..
..snip..

Quoted 9 lines

}

Signature · 6 lines
1.7.10.rc0.41.gfa678

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Regards,
Gururaja

#9 lore raw

Re: [PATCH v2 5/8] mmc: host: omap_hsmmc: trivial cleanups

Quoted 6 lines · Gururaja
Quoted 5 lines · Venkatraman

From: Felipe Balbi <[email protected]>

a bunch of non-functional cleanups to the omap_hsmmc driver.

Quoted 8 lines
Quoted 1 line

It basically decreases indentation level, drop unneeded

s/unneeded/unneeded. Better to use unnecessary

Quoted 1 line

dereferences and drop unneded accesses to the platform_device

Same as above

Thanks. Now updated as below (and pushed out to the same branch)..

Quoted 1 line

From 7174f9a831a8fcd224bf6dc1c2895e40fa252e84 Mon Sep 17 00:00:00 2001

From: Felipe Balbi <[email protected]>
Date: Wed, 14 Mar 2012 11:18:27 +0200
Subject: [PATCH] mmc: host: omap_hsmmc: trivial cleanups

a bunch of non-functional cleanups to the omap_hsmmc driver.

It basically decreases indentation level, drop unneeded dereferences and drop unnecessary accesses to the platform_device structure.

---
 drivers/mmc/host/omap_hsmmc.c |  147 ++++++++++++++++++++---------------------
 1 file changed, 70 insertions(+), 77 deletions(-)
drivers/mmc/host/omap_hsmmc.c +0 -0
index 925d2be..cafd879 100644
@@ -2055,30 +2055,28 @@ static int omap_hsmmc_remove(struct

platform_device *pdev)
struct omap_hsmmc_host *host = platform_get_drvdata(pdev); struct resource *res;

- if (host) {
- pm_runtime_get_sync(host->dev);
- mmc_remove_host(host->mmc);
- if (host->use_reg)
- omap_hsmmc_reg_put(host);
- if (host->pdata->cleanup)
- host->pdata->cleanup(&pdev->dev);
- free_irq(host->irq, host);
- if (mmc_slot(host).card_detect_irq)
- free_irq(mmc_slot(host).card_detect_irq, host);
-
- pm_runtime_put_sync(host->dev);
- pm_runtime_disable(host->dev);
- clk_put(host->fclk);
- if (host->got_dbclk) {
- clk_disable(host->dbclk);
- clk_put(host->dbclk);
- }
+ pm_runtime_get_sync(host->dev);
+ mmc_remove_host(host->mmc);
+ if (host->use_reg)
+ omap_hsmmc_reg_put(host);
+ if (host->pdata->cleanup)
+ host->pdata->cleanup(&pdev->dev);
+ free_irq(host->irq, host);
+ if (mmc_slot(host).card_detect_irq)
+ free_irq(mmc_slot(host).card_detect_irq, host);

- mmc_free_host(host->mmc);
- iounmap(host->base);
- omap_hsmmc_gpio_free(pdev->dev.platform_data);
+ pm_runtime_put_sync(host->dev);
+ pm_runtime_disable(host->dev);
+ clk_put(host->fclk);
+ if (host->got_dbclk) {
+ clk_disable(host->dbclk);
+ clk_put(host->dbclk);
}

+ mmc_free_host(host->mmc);
+ iounmap(host->base);
+ omap_hsmmc_gpio_free(pdev->dev.platform_data);
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res)
release_mem_region(res->start, resource_size(res));
@@ -2091,49 +2089,45 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
static int omap_hsmmc_suspend(struct device *dev)
{
int ret = 0;
- struct platform_device *pdev = to_platform_device(dev);
- struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
+ struct omap_hsmmc_host *host = dev_get_drvdata(dev);

- if (host && host->suspended)
+ if (!host)
return 0;

- if (host) {
- pm_runtime_get_sync(host->dev);
- host->suspended = 1;
- if (host->pdata->suspend) {
- ret = host->pdata->suspend(&pdev->dev,
- host->slot_id);
- if (ret) {
- dev_dbg(mmc_dev(host->mmc),
- "Unable to handle MMC board"
- " level suspend\n");
- host->suspended = 0;
- return ret;
- }
- }
- ret = mmc_suspend_host(host->mmc);
+ if (host && host->suspended)
+ return 0;

+ pm_runtime_get_sync(host->dev);
+ host->suspended = 1;
+ if (host->pdata->suspend) {
+ ret = host->pdata->suspend(dev, host->slot_id);
if (ret) {
+ dev_dbg(dev, "Unable to handle MMC board"
+ " level suspend\n");
host->suspended = 0;
- if (host->pdata->resume) {
- ret = host->pdata->resume(&pdev->dev,
- host->slot_id);
- if (ret)
- dev_dbg(mmc_dev(host->mmc),
- "Unmask interrupt failed\n");
- }
- goto err;
+ return ret;
}
+ }
+ ret = mmc_suspend_host(host->mmc);

- if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) {
- omap_hsmmc_disable_irq(host);
- OMAP_HSMMC_WRITE(host->base, HCTL,
- OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);
+ if (ret) {
+ host->suspended = 0;
+ if (host->pdata->resume) {
+ ret = host->pdata->resume(dev, host->slot_id);
+ if (ret)
+ dev_dbg(dev, "Unmask interrupt failed\n");
}
- if (host->got_dbclk)
- clk_disable(host->dbclk);
+ goto err;
+ }

+ if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) {
+ omap_hsmmc_disable_irq(host);
+ OMAP_HSMMC_WRITE(host->base, HCTL,
+ OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);
}
+
+ if (host->got_dbclk)
+ clk_disable(host->dbclk);
err:
pm_runtime_put_sync(host->dev);
return ret;
@@ -2143,38 +2137,37 @@ err:
static int omap_hsmmc_resume(struct device *dev)
{
int ret = 0;
- struct platform_device *pdev = to_platform_device(dev);
- struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
+ struct omap_hsmmc_host *host = dev_get_drvdata(dev);
+
+ if (!host)
+ return 0;

if (host && !host->suspended)
return 0;

- if (host) {
- pm_runtime_get_sync(host->dev);
+ pm_runtime_get_sync(host->dev);

- if (host->got_dbclk)
- clk_enable(host->dbclk);
+ if (host->got_dbclk)
+ clk_enable(host->dbclk);

- if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER))
- omap_hsmmc_conf_bus_power(host);
+ if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER))
+ omap_hsmmc_conf_bus_power(host);

- if (host->pdata->resume) {
- ret = host->pdata->resume(&pdev->dev, host->slot_id);
- if (ret)
- dev_dbg(mmc_dev(host->mmc),
- "Unmask interrupt failed\n");
- }
+ if (host->pdata->resume) {
+ ret = host->pdata->resume(dev, host->slot_id);
+ if (ret)
+ dev_dbg(dev, "Unmask interrupt failed\n");
+ }

- omap_hsmmc_protect_card(host);
+ omap_hsmmc_protect_card(host);

- /* Notify the core to resume the host */
- ret = mmc_resume_host(host->mmc);
- if (ret == 0)
- host->suspended = 0;
+ /* Notify the core to resume the host */
+ ret = mmc_resume_host(host->mmc);
+ if (ret == 0)
+ host->suspended = 0;

- pm_runtime_mark_last_busy(host->dev);
- pm_runtime_put_autosuspend(host->dev);
- }
+ pm_runtime_mark_last_busy(host->dev);
+ pm_runtime_put_autosuspend(host->dev);

return ret;

@@ -2191,7 +2184,7 @@ static int omap_hsmmc_runtime_suspend(struct device *dev)

host = platform_get_drvdata(to_platform_device(dev)); omap_hsmmc_context_save(host);
- dev_dbg(mmc_dev(host->mmc), "disabled\n");
+ dev_dbg(dev, "disabled\n");

return 0;
}
@@ -2202,7 +2195,7 @@ static int omap_hsmmc_runtime_resume(struct device *dev)

host = platform_get_drvdata(to_platform_device(dev)); omap_hsmmc_context_restore(host);
- dev_dbg(mmc_dev(host->mmc), "enabled\n");
+ dev_dbg(dev, "enabled\n");

return 0;
}

Signature · 1 line
1.7.10.rc0.41.gfa678
#10 lore raw

PATCH v2 6/8 mmc: host: omap_hsmmc: make it behave well as a module

In reply to Venkatraman S

From: Felipe Balbi <[email protected]>

if we put probe() on __init section, that will never work for multiple module insertions/removals.

In order to make it work properly, move probe to __devinit section and use platform_driver_register() instead of platform_driver_probe().

---
 drivers/mmc/host/omap_hsmmc.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/host/omap_hsmmc.c +5 -4
index c16c552..bcb8c5d 100644
@@ -1779,7 +1779,7 @@ static inline struct omap_mmc_platform_data
 }
 #endif
 
-static int __init omap_hsmmc_probe(struct platform_device *pdev)
+static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
 {
 	struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;
 	struct mmc_host *mmc;
@@ -2031,7 +2031,7 @@ err:
 	return ret;
 }
 
-static int omap_hsmmc_remove(struct platform_device *pdev)
+static int __devexit omap_hsmmc_remove(struct platform_device *pdev)
 {
 	struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
 	struct resource *res;
@@ -2189,7 +2189,8 @@ static struct dev_pm_ops omap_hsmmc_dev_pm_ops = {
 };
 
 static struct platform_driver omap_hsmmc_driver = {
-	.remove		= omap_hsmmc_remove,
+	.probe		= omap_hsmmc_probe,
+	.remove		= __devexit_p(omap_hsmmc_remove),
 	.driver		= {
 		.name = DRIVER_NAME,
 		.owner = THIS_MODULE,
@@ -2201,7 +2202,7 @@ static struct platform_driver omap_hsmmc_driver = {
 static int __init omap_hsmmc_init(void)
 {
 	/* Register the MMC driver */
-	return platform_driver_probe(&omap_hsmmc_driver, omap_hsmmc_probe);
+	return platform_driver_register(&omap_hsmmc_driver);
 }
 
 static void __exit omap_hsmmc_cleanup(void)
Signature · 1 line
1.7.10.rc0.41.gfa678
#11 lore raw

PATCH v2 7/8 mmc: host: omap_hsmmc: convert to module_platform_driver

In reply to Venkatraman S

From: Felipe Balbi <[email protected]>

this will delete some boilerplate code, no functional changes.

---
 drivers/mmc/host/omap_hsmmc.c |   16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)
drivers/mmc/host/omap_hsmmc.c +1 -15
index bcb8c5d..6411f9a 100644
@@ -2199,21 +2199,7 @@ static struct platform_driver omap_hsmmc_driver = {
 	},
 };
 
-static int __init omap_hsmmc_init(void)
-{
-	/* Register the MMC driver */
-	return platform_driver_register(&omap_hsmmc_driver);
-}
-
-static void __exit omap_hsmmc_cleanup(void)
-{
-	/* Unregister MMC driver */
-	platform_driver_unregister(&omap_hsmmc_driver);
-}
-
-module_init(omap_hsmmc_init);
-module_exit(omap_hsmmc_cleanup);
-
+module_platform_driver(omap_hsmmc_driver);
 MODULE_DESCRIPTION("OMAP High Speed Multimedia Card driver");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:" DRIVER_NAME);
Signature · 1 line
1.7.10.rc0.41.gfa678
#12 lore raw

PATCH v2 8/8 mmc: omap4: hsmmc: fix module re-insertion

In reply to Venkatraman S

From: Balaji T K <[email protected]>

OMAP4 and OMAP3 HSMMC IP registers differ by 0x100 offset. Addng the offset to platform_device resource structure increments the start address for every insmod operation.
MMC command fails on re-insertion as module due to incorrect register base. Fix this by updating the ioremap base address only.

---
 drivers/mmc/host/omap_hsmmc.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mmc/host/omap_hsmmc.c +1 -3
index 6411f9a..6bef2a8 100644
@@ -1812,8 +1812,6 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
 	if (res == NULL || irq < 0)
 		return -ENXIO;
 
-	res->start += pdata->reg_offset;
-	res->end += pdata->reg_offset;
 	res = request_mem_region(res->start, resource_size(res), pdev->name);
 	if (res == NULL)
 		return -EBUSY;
@@ -1837,7 +1835,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
 	host->dma_ch	= -1;
 	host->irq	= irq;
 	host->slot_id	= 0;
-	host->mapbase	= res->start;
+	host->mapbase	= res->start + pdata->reg_offset;
 	host->base	= ioremap(host->mapbase, SZ_4K);
 	host->power_mode = MMC_POWER_OFF;
 	host->flags	= AUTO_CMD12;
Signature · 1 line
1.7.10.rc0.41.gfa678
#13 lore raw
In reply to Venkatraman S

Hi,

Quoted 16 lines · Venkatraman S

Chris,
Here are a group of fixes posted by Felipe and Balaji for the
OMAP hsmmc driver in the past few days.
I've rebased them to the lastest mmc-next and posted them
here again. These have also been tested on OMAP4 development platform.

Please feel to apply directly or pull if that's convenient.

Changes since yesterday (v1):-
Fixed formatting issues as suggested by Felipe Marked some patches for stable.

The following changes since commit 5f0390f10c0e9c9c504cdbf4af802252628a2490:

mmc: omap_hsmmc: Avoid a regulator voltage change with dt (2012-03-14 11:33:20 -0400)

Quoted 7 lines

are available in the git repository at:

git://github.com/svenkatr/linux.git omap-mmc-pending-for-3.4

for you to fetch changes up to 8d54766b608915035b47616ea564e4e9b4dda29c:

mmc: omap4: hsmmc: fix module re-insertion (2012-03-16 11:38:41 +0530)

I've just rebased mmc-next on top of 3.4-rc1, and now there are many conflicts against your tree -- please could you resend patches 3-8 against that base? I'll take them for 3.4, and will take patches 1-2 for 3.5.

Thanks!

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#14 lore raw
Quoted 23 lines · Chris Ball

Hi,

Quoted 20 lines · Venkatraman S

Chris,
   Here are a group of fixes posted by Felipe and Balaji for the OMAP hsmmc driver in the past few days.
   I've rebased them to the lastest mmc-next and posted them here again. These have also been tested on OMAP4 development platform.

Please feel to apply directly or pull if that's convenient.

Changes since yesterday (v1):-
      Fixed formatting issues as suggested by Felipe Marked some patches for stable.

The following changes since commit 5f0390f10c0e9c9c504cdbf4af802252628a2490:

  mmc: omap_hsmmc: Avoid a regulator voltage change with dt (2012-03-14 11:33:20 -0400)

are available in the git repository at:

  git://github.com/svenkatr/linux.git omap-mmc-pending-for-3.4

Quoted 9 lines
Quoted 3 lines

for you to fetch changes up to 8d54766b608915035b47616ea564e4e9b4dda29c:

  mmc: omap4: hsmmc: fix module re-insertion (2012-03-16 11:38:41 +0530)

I've just rebased mmc-next on top of 3.4-rc1, and now there are many conflicts against your tree -- please could you resend patches 3-8 against that base?  I'll take them for 3.4, and will take patches 1-2 for 3.5.

I've rebased patches 3-8 into a new branch (See below).
I'll send you 1-2 on top of 3.4-rc2 once it's out. Is it Ok ?
==============
The following changes since commit a4dfa827bb5b9a984d4000ffb80134b9495e4d8a:

mmc: sdio: Use empty system suspend/resume callbacks at the bus
level (2012-04-01 00:35:06 -0400)

are available in the git repository at:

git://github.com/svenkatr/linux.git omap-mmc-fixes-3.4

for you to fetch changes up to 80f833a2f77b8d6464209c0bb00a39ad835356a0:

mmc: omap4: hsmmc: fix module re-insertion (2012-04-02 12:26:47 +0530)

----------------------------------------------------------------
Balaji T K (3):
mmc: omap: use runtime put sync in probe error patch
mmc: omap: context save after enabling runtime pm
mmc: omap4: hsmmc: fix module re-insertion

Felipe Balbi (3):
mmc: host: omap_hsmmc: trivial cleanups
mmc: host: omap_hsmmc: make it behave well as a module
mmc: host: omap_hsmmc: convert to module_platform_driver

 drivers/mmc/host/omap_hsmmc.c |  181
+++++++++++++++++++++--------------------------
 1 file changed, 79 insertions(+), 102 deletions(-)

Regards,
Venkat.

Applied
#15 lore raw

Hi,

Quoted 2 lines · Venkatraman

I've rebased patches 3-8 into a new branch (See below). I'll send you 1-2 on top of 3.4-rc2 once it's out. Is it Ok ?

Yes, thanks.

Quoted 20 lines
Quoted 1 line

==============

The following changes since commit a4dfa827bb5b9a984d4000ffb80134b9495e4d8a:

mmc: sdio: Use empty system suspend/resume callbacks at the bus
level (2012-04-01 00:35:06 -0400)

are available in the git repository at:

git://github.com/svenkatr/linux.git omap-mmc-fixes-3.4

for you to fetch changes up to 80f833a2f77b8d6464209c0bb00a39ad835356a0:

mmc: omap4: hsmmc: fix module re-insertion (2012-04-02 12:26:47 +0530)

----------------------------------------------------------------
Balaji T K (3):
mmc: omap: use runtime put sync in probe error patch
mmc: omap: context save after enabling runtime pm
mmc: omap4: hsmmc: fix module re-insertion

Quoted 4 lines

Felipe Balbi (3):
mmc: host: omap_hsmmc: trivial cleanups
mmc: host: omap_hsmmc: make it behave well as a module
mmc: host: omap_hsmmc: convert to module_platform_driver

Pushed to mmc-next for 3.4, and I normalized the commit message first lines to:

mmc: omap_hsmmc: description

Thanks very much,

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child