linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] mmc: kona/spear updates
@ 2014-02-28 21:29 Russell King - ARM Linux
  2014-02-28 21:32 ` [PATCH 1/6] mmc: sdhci-bcm-kona: fix build errors when built-in Russell King
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Russell King - ARM Linux @ 2014-02-28 21:29 UTC (permalink / raw)
  To: Chris Ball
  Cc: Christian Daudt, linux-mmc, Markus Mayer, Matt Porter,
	spear-devel, Viresh Kumar

Chris,

Here's the latest patches for these fixups.  They've been in my build
system for a while, and allyesconfig/allmodconfig show no problems.

Probably want to get some acks/tested-bys from people before applying
these.

 drivers/mmc/host/sdhci-bcm-kona.c |   2 +-
 drivers/mmc/host/sdhci-spear.c    | 191 +++++++++++++++++++----------------------------------------------------------------
 include/linux/mmc/sdhci-spear.h   |   8 ----
 3 files changed, 45 insertions(+), 156 deletions(-)

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.

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

* [PATCH 1/6] mmc: sdhci-bcm-kona: fix build errors when built-in
  2014-02-28 21:29 [PATCH 0/6] mmc: kona/spear updates Russell King - ARM Linux
@ 2014-02-28 21:32 ` Russell King
  2014-02-28 21:54   ` Markus Mayer
  2014-03-04  7:17   ` Matt Porter
  2014-02-28 21:32 ` [PATCH 2/6] mmc: sdhci-spear: fix error handling paths for DT Russell King
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 10+ messages in thread
From: Russell King @ 2014-02-28 21:32 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Markus Mayer, Christian Daudt, Matt Porter

`sdhci_bcm_kona_remove' referenced in section `.data' of drivers/built-in.o: defined in discarded section `.exit.text' of drivers/built-in.o

Fixes: 058feb53666f ("mmc: sdhci-bcm-kona: make linker-section warning go away")
Cc: Markus Mayer <markus.mayer@linaro.org>
Cc: Christian Daudt <csd@broadcom.com>
Cc: Matt Porter <matt.porter@linaro.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/mmc/host/sdhci-bcm-kona.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c
index 7a190fe4dff1..e5565aa5ed36 100644
--- a/drivers/mmc/host/sdhci-bcm-kona.c
+++ b/drivers/mmc/host/sdhci-bcm-kona.c
@@ -314,7 +314,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev)
+static int sdhci_bcm_kona_remove(struct platform_device *pdev)
 {
 	return sdhci_pltfm_unregister(pdev);
 }
-- 
1.8.3.1


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

* [PATCH 2/6] mmc: sdhci-spear: fix error handling paths for DT
  2014-02-28 21:29 [PATCH 0/6] mmc: kona/spear updates Russell King - ARM Linux
  2014-02-28 21:32 ` [PATCH 1/6] mmc: sdhci-bcm-kona: fix build errors when built-in Russell King
@ 2014-02-28 21:32 ` Russell King
  2014-02-28 21:32 ` [PATCH 3/6] mmc: sdhci-spear: fix platform_data usage Russell King
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Russell King @ 2014-02-28 21:32 UTC (permalink / raw)
  To: Chris Ball; +Cc: Viresh Kumar, spear-devel, linux-mmc

Fix the error handling paths for DT and simplify using the devm_* API
for clk_get().

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/mmc/host/sdhci-spear.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
index 2dba9f8d1760..3cb0087ad98b 100644
--- a/drivers/mmc/host/sdhci-spear.c
+++ b/drivers/mmc/host/sdhci-spear.c
@@ -131,7 +131,7 @@ static int sdhci_probe(struct platform_device *pdev)
 	}
 
 	/* clk enable */
-	sdhci->clk = clk_get(&pdev->dev, NULL);
+	sdhci->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(sdhci->clk)) {
 		ret = PTR_ERR(sdhci->clk);
 		dev_dbg(&pdev->dev, "Error getting clock\n");
@@ -141,7 +141,7 @@ static int sdhci_probe(struct platform_device *pdev)
 	ret = clk_prepare_enable(sdhci->clk);
 	if (ret) {
 		dev_dbg(&pdev->dev, "Error enabling clock\n");
-		goto put_clk;
+		goto err;
 	}
 
 	ret = clk_set_rate(sdhci->clk, 50000000);
@@ -153,7 +153,7 @@ static int sdhci_probe(struct platform_device *pdev)
 		sdhci->data = sdhci_probe_config_dt(pdev);
 		if (IS_ERR(sdhci->data)) {
 			dev_err(&pdev->dev, "DT: Failed to get pdata\n");
-			return -ENODEV;
+			goto disable_clk;
 		}
 	} else {
 		sdhci->data = dev_get_platdata(&pdev->dev);
@@ -263,8 +263,6 @@ static int sdhci_probe(struct platform_device *pdev)
 	sdhci_free_host(host);
 disable_clk:
 	clk_disable_unprepare(sdhci->clk);
-put_clk:
-	clk_put(sdhci->clk);
 err:
 	dev_err(&pdev->dev, "spear-sdhci probe failed: %d\n", ret);
 	return ret;
@@ -284,7 +282,6 @@ static int sdhci_remove(struct platform_device *pdev)
 	sdhci_remove_host(host, dead);
 	sdhci_free_host(host);
 	clk_disable_unprepare(sdhci->clk);
-	clk_put(sdhci->clk);
 
 	return 0;
 }
-- 
1.8.3.1


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

* [PATCH 3/6] mmc: sdhci-spear: fix platform_data usage
  2014-02-28 21:29 [PATCH 0/6] mmc: kona/spear updates Russell King - ARM Linux
  2014-02-28 21:32 ` [PATCH 1/6] mmc: sdhci-bcm-kona: fix build errors when built-in Russell King
  2014-02-28 21:32 ` [PATCH 2/6] mmc: sdhci-spear: fix error handling paths for DT Russell King
@ 2014-02-28 21:32 ` Russell King
  2014-02-28 21:32 ` [PATCH 4/6] mmc: sdhci-spear: simplify resource handling Russell King
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Russell King @ 2014-02-28 21:32 UTC (permalink / raw)
  To: Chris Ball; +Cc: Viresh Kumar, spear-devel, linux-mmc

sdhci-spear is unsafe should a probe fail or defer, since it overwrites
the platform_data with its own driver-private data.  It's trivial to
fix as SDHCI allows for driver-private data to be appended to its own
structure - we just need to arrange the code to allow this.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/mmc/host/sdhci-spear.c | 43 +++++++++++++++++-------------------------
 1 file changed, 17 insertions(+), 26 deletions(-)

diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
index 3cb0087ad98b..663222f6c1c3 100644
--- a/drivers/mmc/host/sdhci-spear.c
+++ b/drivers/mmc/host/sdhci-spear.c
@@ -107,6 +107,7 @@ static int sdhci_probe(struct platform_device *pdev)
 	struct sdhci_host *host;
 	struct resource *iomem;
 	struct spear_sdhci *sdhci;
+	struct device *dev;
 	int ret;
 
 	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -123,25 +124,28 @@ static int sdhci_probe(struct platform_device *pdev)
 		goto err;
 	}
 
-	sdhci = devm_kzalloc(&pdev->dev, sizeof(*sdhci), GFP_KERNEL);
-	if (!sdhci) {
-		ret = -ENOMEM;
+	dev = pdev->dev.parent ? pdev->dev.parent : &pdev->dev;
+	host = sdhci_alloc_host(dev, sizeof(*sdhci));
+	if (IS_ERR(host)) {
+		ret = PTR_ERR(host);
 		dev_dbg(&pdev->dev, "cannot allocate memory for sdhci\n");
 		goto err;
 	}
 
+	sdhci = sdhci_priv(host);
+
 	/* clk enable */
 	sdhci->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(sdhci->clk)) {
 		ret = PTR_ERR(sdhci->clk);
 		dev_dbg(&pdev->dev, "Error getting clock\n");
-		goto err;
+		goto err_host;
 	}
 
 	ret = clk_prepare_enable(sdhci->clk);
 	if (ret) {
 		dev_dbg(&pdev->dev, "Error enabling clock\n");
-		goto err;
+		goto err_host;
 	}
 
 	ret = clk_set_rate(sdhci->clk, 50000000);
@@ -159,19 +163,6 @@ static int sdhci_probe(struct platform_device *pdev)
 		sdhci->data = dev_get_platdata(&pdev->dev);
 	}
 
-	pdev->dev.platform_data = sdhci;
-
-	if (pdev->dev.parent)
-		host = sdhci_alloc_host(pdev->dev.parent, 0);
-	else
-		host = sdhci_alloc_host(&pdev->dev, 0);
-
-	if (IS_ERR(host)) {
-		ret = PTR_ERR(host);
-		dev_dbg(&pdev->dev, "error allocating host\n");
-		goto disable_clk;
-	}
-
 	host->hw_name = "sdhci";
 	host->ops = &sdhci_pltfm_ops;
 	host->irq = platform_get_irq(pdev, 0);
@@ -182,13 +173,13 @@ static int sdhci_probe(struct platform_device *pdev)
 	if (!host->ioaddr) {
 		ret = -ENOMEM;
 		dev_dbg(&pdev->dev, "failed to remap registers\n");
-		goto free_host;
+		goto disable_clk;
 	}
 
 	ret = sdhci_add_host(host);
 	if (ret) {
 		dev_dbg(&pdev->dev, "error adding host\n");
-		goto free_host;
+		goto disable_clk;
 	}
 
 	platform_set_drvdata(pdev, host);
@@ -259,10 +250,10 @@ static int sdhci_probe(struct platform_device *pdev)
 
 set_drvdata:
 	sdhci_remove_host(host, 1);
-free_host:
-	sdhci_free_host(host);
 disable_clk:
 	clk_disable_unprepare(sdhci->clk);
+err_host:
+	sdhci_free_host(host);
 err:
 	dev_err(&pdev->dev, "spear-sdhci probe failed: %d\n", ret);
 	return ret;
@@ -271,7 +262,7 @@ static int sdhci_probe(struct platform_device *pdev)
 static int sdhci_remove(struct platform_device *pdev)
 {
 	struct sdhci_host *host = platform_get_drvdata(pdev);
-	struct spear_sdhci *sdhci = dev_get_platdata(&pdev->dev);
+	struct spear_sdhci *sdhci = sdhci_priv(host);
 	int dead = 0;
 	u32 scratch;
 
@@ -280,8 +271,8 @@ static int sdhci_remove(struct platform_device *pdev)
 		dead = 1;
 
 	sdhci_remove_host(host, dead);
-	sdhci_free_host(host);
 	clk_disable_unprepare(sdhci->clk);
+	sdhci_free_host(host);
 
 	return 0;
 }
@@ -290,7 +281,7 @@ static int sdhci_remove(struct platform_device *pdev)
 static int sdhci_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
-	struct spear_sdhci *sdhci = dev_get_platdata(dev);
+	struct spear_sdhci *sdhci = sdhci_priv(host);
 	int ret;
 
 	ret = sdhci_suspend_host(host);
@@ -303,7 +294,7 @@ static int sdhci_suspend(struct device *dev)
 static int sdhci_resume(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
-	struct spear_sdhci *sdhci = dev_get_platdata(dev);
+	struct spear_sdhci *sdhci = sdhci_priv(host);
 	int ret;
 
 	ret = clk_enable(sdhci->clk);
-- 
1.8.3.1


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

* [PATCH 4/6] mmc: sdhci-spear: simplify resource handling
  2014-02-28 21:29 [PATCH 0/6] mmc: kona/spear updates Russell King - ARM Linux
                   ` (2 preceding siblings ...)
  2014-02-28 21:32 ` [PATCH 3/6] mmc: sdhci-spear: fix platform_data usage Russell King
@ 2014-02-28 21:32 ` Russell King
  2014-02-28 21:32 ` [PATCH 5/6] mmc: sdhci-spear: remove support for power gpio Russell King
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Russell King @ 2014-02-28 21:32 UTC (permalink / raw)
  To: Chris Ball; +Cc: Viresh Kumar, spear-devel, linux-mmc

Use devm_ioremap_resource() to simplify iomem resource handling in the
probe path.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/mmc/host/sdhci-spear.c | 40 +++++++++++++---------------------------
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
index 663222f6c1c3..fca8ed1167cb 100644
--- a/drivers/mmc/host/sdhci-spear.c
+++ b/drivers/mmc/host/sdhci-spear.c
@@ -110,20 +110,6 @@ static int sdhci_probe(struct platform_device *pdev)
 	struct device *dev;
 	int ret;
 
-	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!iomem) {
-		ret = -ENOMEM;
-		dev_dbg(&pdev->dev, "memory resource not defined\n");
-		goto err;
-	}
-
-	if (!devm_request_mem_region(&pdev->dev, iomem->start,
-				resource_size(iomem), "spear-sdhci")) {
-		ret = -EBUSY;
-		dev_dbg(&pdev->dev, "cannot request region\n");
-		goto err;
-	}
-
 	dev = pdev->dev.parent ? pdev->dev.parent : &pdev->dev;
 	host = sdhci_alloc_host(dev, sizeof(*sdhci));
 	if (IS_ERR(host)) {
@@ -132,6 +118,19 @@ static int sdhci_probe(struct platform_device *pdev)
 		goto err;
 	}
 
+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	host->ioaddr = devm_ioremap_resource(&pdev->dev, iomem);
+	if (IS_ERR(host->ioaddr)) {
+		ret = PTR_ERR(host->ioaddr);
+		dev_dbg(&pdev->dev, "unable to map iomem: %d\n", ret);
+		goto err_host;
+	}
+
+	host->hw_name = "sdhci";
+	host->ops = &sdhci_pltfm_ops;
+	host->irq = platform_get_irq(pdev, 0);
+	host->quirks = SDHCI_QUIRK_BROKEN_ADMA;
+
 	sdhci = sdhci_priv(host);
 
 	/* clk enable */
@@ -163,19 +162,6 @@ static int sdhci_probe(struct platform_device *pdev)
 		sdhci->data = dev_get_platdata(&pdev->dev);
 	}
 
-	host->hw_name = "sdhci";
-	host->ops = &sdhci_pltfm_ops;
-	host->irq = platform_get_irq(pdev, 0);
-	host->quirks = SDHCI_QUIRK_BROKEN_ADMA;
-
-	host->ioaddr = devm_ioremap(&pdev->dev, iomem->start,
-			resource_size(iomem));
-	if (!host->ioaddr) {
-		ret = -ENOMEM;
-		dev_dbg(&pdev->dev, "failed to remap registers\n");
-		goto disable_clk;
-	}
-
 	ret = sdhci_add_host(host);
 	if (ret) {
 		dev_dbg(&pdev->dev, "error adding host\n");
-- 
1.8.3.1


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

* [PATCH 5/6] mmc: sdhci-spear: remove support for power gpio
  2014-02-28 21:29 [PATCH 0/6] mmc: kona/spear updates Russell King - ARM Linux
                   ` (3 preceding siblings ...)
  2014-02-28 21:32 ` [PATCH 4/6] mmc: sdhci-spear: simplify resource handling Russell King
@ 2014-02-28 21:32 ` Russell King
  2014-02-28 21:32 ` [PATCH 6/6] mmc: sdhci-spear: use generic card detection gpio support Russell King
  2014-03-04 21:30 ` [PATCH 0/6] mmc: kona/spear updates Chris Ball
  6 siblings, 0 replies; 10+ messages in thread
From: Russell King @ 2014-02-28 21:32 UTC (permalink / raw)
  To: Chris Ball; +Cc: Viresh Kumar, spear-devel, linux-mmc

None of this code is currently used: there are no definitions of
struct sdhci_plat_data in arch/arm, neither are there any DT properties
which use card_power_gpio/power_active_high/power_always_enb.  In any
case, slot power control should be rigged up via vmmc and the regulator
subsystem in the DT case.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/mmc/host/sdhci-spear.c  | 32 --------------------------------
 include/linux/mmc/sdhci-spear.h |  8 --------
 2 files changed, 40 deletions(-)

diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
index fca8ed1167cb..2a208a9b4de1 100644
--- a/drivers/mmc/host/sdhci-spear.c
+++ b/drivers/mmc/host/sdhci-spear.c
@@ -56,14 +56,6 @@ static irqreturn_t sdhci_gpio_irq(int irq, void *dev_id)
 	gpio_irq_type = val ? IRQF_TRIGGER_LOW : IRQF_TRIGGER_HIGH;
 	irq_set_irq_type(irq, gpio_irq_type);
 
-	if (sdhci->data->card_power_gpio >= 0) {
-		if (!sdhci->data->power_always_enb) {
-			/* if card inserted, give power, otherwise remove it */
-			val = sdhci->data->power_active_high ? !val : val ;
-			gpio_set_value(sdhci->data->card_power_gpio, val);
-		}
-	}
-
 	/* inform sdhci driver about card insertion/removal */
 	tasklet_schedule(&host->card_tasklet);
 
@@ -181,30 +173,6 @@ static int sdhci_probe(struct platform_device *pdev)
 	if (!sdhci->data)
 		return 0;
 
-	if (sdhci->data->card_power_gpio >= 0) {
-		int val = 0;
-
-		ret = devm_gpio_request(&pdev->dev,
-				sdhci->data->card_power_gpio, "sdhci");
-		if (ret < 0) {
-			dev_dbg(&pdev->dev, "gpio request fail: %d\n",
-					sdhci->data->card_power_gpio);
-			goto set_drvdata;
-		}
-
-		if (sdhci->data->power_always_enb)
-			val = sdhci->data->power_active_high;
-		else
-			val = !sdhci->data->power_active_high;
-
-		ret = gpio_direction_output(sdhci->data->card_power_gpio, val);
-		if (ret) {
-			dev_dbg(&pdev->dev, "gpio set direction fail: %d\n",
-					sdhci->data->card_power_gpio);
-			goto set_drvdata;
-		}
-	}
-
 	if (sdhci->data->card_int_gpio >= 0) {
 		ret = devm_gpio_request(&pdev->dev, sdhci->data->card_int_gpio,
 				"sdhci");
diff --git a/include/linux/mmc/sdhci-spear.h b/include/linux/mmc/sdhci-spear.h
index e78c0e236e9d..8cc095a76cf8 100644
--- a/include/linux/mmc/sdhci-spear.h
+++ b/include/linux/mmc/sdhci-spear.h
@@ -18,17 +18,9 @@
 /*
  * struct sdhci_plat_data: spear sdhci platform data structure
  *
- * @card_power_gpio: gpio pin for enabling/disabling power to sdhci socket
- * @power_active_high: if set, enable power to sdhci socket by setting
- *			card_power_gpio
- * @power_always_enb: If set, then enable power on probe, otherwise enable only
- *			on card insertion and disable on card removal.
  * card_int_gpio: gpio pin used for card detection
  */
 struct sdhci_plat_data {
-	int card_power_gpio;
-	int power_active_high;
-	int power_always_enb;
 	int card_int_gpio;
 };
 
-- 
1.8.3.1


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

* [PATCH 6/6] mmc: sdhci-spear: use generic card detection gpio support
  2014-02-28 21:29 [PATCH 0/6] mmc: kona/spear updates Russell King - ARM Linux
                   ` (4 preceding siblings ...)
  2014-02-28 21:32 ` [PATCH 5/6] mmc: sdhci-spear: remove support for power gpio Russell King
@ 2014-02-28 21:32 ` Russell King
  2014-03-04 21:30 ` [PATCH 0/6] mmc: kona/spear updates Chris Ball
  6 siblings, 0 replies; 10+ messages in thread
From: Russell King @ 2014-02-28 21:32 UTC (permalink / raw)
  To: Chris Ball; +Cc: Viresh Kumar, spear-devel, linux-mmc

sdhci has support for using GPIOs for card detection.  If we have a
GPIO specified, we can use that directly, without needing our own
interrupt handler.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/mmc/host/sdhci-spear.c | 79 +++++++++---------------------------------
 1 file changed, 17 insertions(+), 62 deletions(-)

diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
index 2a208a9b4de1..87e737c00876 100644
--- a/drivers/mmc/host/sdhci-spear.c
+++ b/drivers/mmc/host/sdhci-spear.c
@@ -27,6 +27,7 @@
 #include <linux/slab.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/sdhci-spear.h>
+#include <linux/mmc/slot-gpio.h>
 #include <linux/io.h>
 #include "sdhci.h"
 
@@ -40,28 +41,6 @@ static const struct sdhci_ops sdhci_pltfm_ops = {
 	/* Nothing to do for now. */
 };
 
-/* gpio card detection interrupt handler */
-static irqreturn_t sdhci_gpio_irq(int irq, void *dev_id)
-{
-	struct platform_device *pdev = dev_id;
-	struct sdhci_host *host = platform_get_drvdata(pdev);
-	struct spear_sdhci *sdhci = dev_get_platdata(&pdev->dev);
-	unsigned long gpio_irq_type;
-	int val;
-
-	val = gpio_get_value(sdhci->data->card_int_gpio);
-
-	/* val == 1 -> card removed, val == 0 -> card inserted */
-	/* if card removed - set irq for low level, else vice versa */
-	gpio_irq_type = val ? IRQF_TRIGGER_LOW : IRQF_TRIGGER_HIGH;
-	irq_set_irq_type(irq, gpio_irq_type);
-
-	/* inform sdhci driver about card insertion/removal */
-	tasklet_schedule(&host->card_tasklet);
-
-	return IRQ_HANDLED;
-}
-
 #ifdef CONFIG_OF
 static struct sdhci_plat_data *sdhci_probe_config_dt(struct platform_device *pdev)
 {
@@ -154,6 +133,22 @@ static int sdhci_probe(struct platform_device *pdev)
 		sdhci->data = dev_get_platdata(&pdev->dev);
 	}
 
+	/*
+	 * It is optional to use GPIOs for sdhci card detection. If
+	 * sdhci->data is NULL, then use original sdhci lines otherwise
+	 * GPIO lines. We use the built-in GPIO support for this.
+	 */
+	if (sdhci->data && sdhci->data->card_int_gpio >= 0) {
+		ret = mmc_gpio_request_cd(host->mmc,
+					  sdhci->data->card_int_gpio, 0);
+		if (ret < 0) {
+			dev_dbg(&pdev->dev,
+				"failed to request card-detect gpio%d\n",
+				sdhci->data->card_int_gpio);
+			goto disable_clk;
+		}
+	}
+
 	ret = sdhci_add_host(host);
 	if (ret) {
 		dev_dbg(&pdev->dev, "error adding host\n");
@@ -162,48 +157,8 @@ static int sdhci_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, host);
 
-	/*
-	 * It is optional to use GPIOs for sdhci Power control & sdhci card
-	 * interrupt detection. If sdhci->data is NULL, then use original sdhci
-	 * lines otherwise GPIO lines.
-	 * If GPIO is selected for power control, then power should be disabled
-	 * after card removal and should be enabled when card insertion
-	 * interrupt occurs
-	 */
-	if (!sdhci->data)
-		return 0;
-
-	if (sdhci->data->card_int_gpio >= 0) {
-		ret = devm_gpio_request(&pdev->dev, sdhci->data->card_int_gpio,
-				"sdhci");
-		if (ret < 0) {
-			dev_dbg(&pdev->dev, "gpio request fail: %d\n",
-					sdhci->data->card_int_gpio);
-			goto set_drvdata;
-		}
-
-		ret = gpio_direction_input(sdhci->data->card_int_gpio);
-		if (ret) {
-			dev_dbg(&pdev->dev, "gpio set direction fail: %d\n",
-					sdhci->data->card_int_gpio);
-			goto set_drvdata;
-		}
-		ret = devm_request_irq(&pdev->dev,
-				gpio_to_irq(sdhci->data->card_int_gpio),
-				sdhci_gpio_irq, IRQF_TRIGGER_LOW,
-				mmc_hostname(host->mmc), pdev);
-		if (ret) {
-			dev_dbg(&pdev->dev, "gpio request irq fail: %d\n",
-					sdhci->data->card_int_gpio);
-			goto set_drvdata;
-		}
-
-	}
-
 	return 0;
 
-set_drvdata:
-	sdhci_remove_host(host, 1);
 disable_clk:
 	clk_disable_unprepare(sdhci->clk);
 err_host:
-- 
1.8.3.1


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

* Re: [PATCH 1/6] mmc: sdhci-bcm-kona: fix build errors when built-in
  2014-02-28 21:32 ` [PATCH 1/6] mmc: sdhci-bcm-kona: fix build errors when built-in Russell King
@ 2014-02-28 21:54   ` Markus Mayer
  2014-03-04  7:17   ` Matt Porter
  1 sibling, 0 replies; 10+ messages in thread
From: Markus Mayer @ 2014-02-28 21:54 UTC (permalink / raw)
  To: Russell King; +Cc: Chris Ball, linux-mmc, Christian Daudt, Matt Porter

On 28 February 2014 13:32, Russell King <rmk+kernel@arm.linux.org.uk> wrote:
> `sdhci_bcm_kona_remove' referenced in section `.data' of drivers/built-in.o: defined in discarded section `.exit.text' of drivers/built-in.o
>
> Fixes: 058feb53666f ("mmc: sdhci-bcm-kona: make linker-section warning go away")
> Cc: Markus Mayer <markus.mayer@linaro.org>
> Cc: Christian Daudt <csd@broadcom.com>
> Cc: Matt Porter <matt.porter@linaro.org>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
>  drivers/mmc/host/sdhci-bcm-kona.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c
> index 7a190fe4dff1..e5565aa5ed36 100644
> --- a/drivers/mmc/host/sdhci-bcm-kona.c
> +++ b/drivers/mmc/host/sdhci-bcm-kona.c
> @@ -314,7 +314,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
>         return ret;
>  }
>
> -static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev)
> +static int sdhci_bcm_kona_remove(struct platform_device *pdev)
>  {
>         return sdhci_pltfm_unregister(pdev);
>  }
> --
> 1.8.3.1
>

Tested-by: Markus Mayer <markus.mayer@linaro.org>

-- 
Markus Mayer
Broadcom Landing Team

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

* Re: [PATCH 1/6] mmc: sdhci-bcm-kona: fix build errors when built-in
  2014-02-28 21:32 ` [PATCH 1/6] mmc: sdhci-bcm-kona: fix build errors when built-in Russell King
  2014-02-28 21:54   ` Markus Mayer
@ 2014-03-04  7:17   ` Matt Porter
  1 sibling, 0 replies; 10+ messages in thread
From: Matt Porter @ 2014-03-04  7:17 UTC (permalink / raw)
  To: Russell King; +Cc: Chris Ball, linux-mmc, Markus Mayer, Christian Daudt

On Fri, Feb 28, 2014 at 09:32:24PM +0000, Russell King wrote:
> `sdhci_bcm_kona_remove' referenced in section `.data' of drivers/built-in.o: defined in discarded section `.exit.text' of drivers/built-in.o
> 
> Fixes: 058feb53666f ("mmc: sdhci-bcm-kona: make linker-section warning go away")
> Cc: Markus Mayer <markus.mayer@linaro.org>
> Cc: Christian Daudt <csd@broadcom.com>
> Cc: Matt Porter <matt.porter@linaro.org>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Acked-by: Matt Porter <mporter@linaro.org>

> ---
>  drivers/mmc/host/sdhci-bcm-kona.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c
> index 7a190fe4dff1..e5565aa5ed36 100644
> --- a/drivers/mmc/host/sdhci-bcm-kona.c
> +++ b/drivers/mmc/host/sdhci-bcm-kona.c
> @@ -314,7 +314,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> -static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev)
> +static int sdhci_bcm_kona_remove(struct platform_device *pdev)
>  {
>  	return sdhci_pltfm_unregister(pdev);
>  }
> -- 
> 1.8.3.1
> 

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

* Re: [PATCH 0/6] mmc: kona/spear updates
  2014-02-28 21:29 [PATCH 0/6] mmc: kona/spear updates Russell King - ARM Linux
                   ` (5 preceding siblings ...)
  2014-02-28 21:32 ` [PATCH 6/6] mmc: sdhci-spear: use generic card detection gpio support Russell King
@ 2014-03-04 21:30 ` Chris Ball
  6 siblings, 0 replies; 10+ messages in thread
From: Chris Ball @ 2014-03-04 21:30 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Christian Daudt, linux-mmc, Markus Mayer, Matt Porter,
	spear-devel, Viresh Kumar

Hi Russell,

On Fri, Feb 28 2014, Russell King - ARM Linux wrote:
> Here's the latest patches for these fixups.  They've been in my build
> system for a while, and allyesconfig/allmodconfig show no problems.
>
> Probably want to get some acks/tested-bys from people before applying
> these.

Thanks, all pushed to mmc-next.

- Chris.
-- 
Chris Ball   <chris@printf.net>   <http://printf.net/>

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

end of thread, other threads:[~2014-03-04 21:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-28 21:29 [PATCH 0/6] mmc: kona/spear updates Russell King - ARM Linux
2014-02-28 21:32 ` [PATCH 1/6] mmc: sdhci-bcm-kona: fix build errors when built-in Russell King
2014-02-28 21:54   ` Markus Mayer
2014-03-04  7:17   ` Matt Porter
2014-02-28 21:32 ` [PATCH 2/6] mmc: sdhci-spear: fix error handling paths for DT Russell King
2014-02-28 21:32 ` [PATCH 3/6] mmc: sdhci-spear: fix platform_data usage Russell King
2014-02-28 21:32 ` [PATCH 4/6] mmc: sdhci-spear: simplify resource handling Russell King
2014-02-28 21:32 ` [PATCH 5/6] mmc: sdhci-spear: remove support for power gpio Russell King
2014-02-28 21:32 ` [PATCH 6/6] mmc: sdhci-spear: use generic card detection gpio support Russell King
2014-03-04 21:30 ` [PATCH 0/6] mmc: kona/spear updates Chris Ball

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).