aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2012-06-14 08:24:35 -0400
committerChris Ball <cjb@laptop.org>2012-07-21 00:02:22 -0400
commite480606ad43bb72fd82a9bd99cdcf21829a6e9c0 (patch)
tree1f41c40d38f9d75371907474c5c6b44c3c6b5aab /drivers/mmc
parentd9adcc12860d76cf3401c6ab7c0406b15b356b7a (diff)
mmc: sh_mmcif: support generic card-detection
Extend the sh_mmcif driver to support GPIO card detection, provided by the slot function module. The original .get_cd() platform callback is also preserved for now. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/sh_mmcif.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 68b31f7c290..b2af7136cd2 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -54,6 +54,7 @@
54#include <linux/mmc/mmc.h> 54#include <linux/mmc/mmc.h>
55#include <linux/mmc/sdio.h> 55#include <linux/mmc/sdio.h>
56#include <linux/mmc/sh_mmcif.h> 56#include <linux/mmc/sh_mmcif.h>
57#include <linux/mmc/slot-gpio.h>
57#include <linux/mod_devicetable.h> 58#include <linux/mod_devicetable.h>
58#include <linux/pagemap.h> 59#include <linux/pagemap.h>
59#include <linux/platform_device.h> 60#include <linux/platform_device.h>
@@ -1000,6 +1001,10 @@ static int sh_mmcif_get_cd(struct mmc_host *mmc)
1000{ 1001{
1001 struct sh_mmcif_host *host = mmc_priv(mmc); 1002 struct sh_mmcif_host *host = mmc_priv(mmc);
1002 struct sh_mmcif_plat_data *p = host->pd->dev.platform_data; 1003 struct sh_mmcif_plat_data *p = host->pd->dev.platform_data;
1004 int ret = mmc_gpio_get_cd(mmc);
1005
1006 if (ret >= 0)
1007 return ret;
1003 1008
1004 if (!p || !p->get_cd) 1009 if (!p || !p->get_cd)
1005 return -ENOSYS; 1010 return -ENOSYS;
@@ -1372,6 +1377,12 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
1372 goto ereqirq1; 1377 goto ereqirq1;
1373 } 1378 }
1374 1379
1380 if (pd && pd->use_cd_gpio) {
1381 ret = mmc_gpio_request_cd(mmc, pd->cd_gpio);
1382 if (ret < 0)
1383 goto erqcd;
1384 }
1385
1375 clk_disable(host->hclk); 1386 clk_disable(host->hclk);
1376 ret = mmc_add_host(mmc); 1387 ret = mmc_add_host(mmc);
1377 if (ret < 0) 1388 if (ret < 0)
@@ -1385,6 +1396,9 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
1385 return ret; 1396 return ret;
1386 1397
1387emmcaddh: 1398emmcaddh:
1399 if (pd && pd->use_cd_gpio)
1400 mmc_gpio_free_cd(mmc);
1401erqcd:
1388 free_irq(irq[1], host); 1402 free_irq(irq[1], host);
1389ereqirq1: 1403ereqirq1:
1390 free_irq(irq[0], host); 1404 free_irq(irq[0], host);
@@ -1405,6 +1419,7 @@ ealloch:
1405static int __devexit sh_mmcif_remove(struct platform_device *pdev) 1419static int __devexit sh_mmcif_remove(struct platform_device *pdev)
1406{ 1420{
1407 struct sh_mmcif_host *host = platform_get_drvdata(pdev); 1421 struct sh_mmcif_host *host = platform_get_drvdata(pdev);
1422 struct sh_mmcif_plat_data *pd = pdev->dev.platform_data;
1408 int irq[2]; 1423 int irq[2];
1409 1424
1410 host->dying = true; 1425 host->dying = true;
@@ -1413,6 +1428,9 @@ static int __devexit sh_mmcif_remove(struct platform_device *pdev)
1413 1428
1414 dev_pm_qos_hide_latency_limit(&pdev->dev); 1429 dev_pm_qos_hide_latency_limit(&pdev->dev);
1415 1430
1431 if (pd && pd->use_cd_gpio)
1432 mmc_gpio_free_cd(host->mmc);
1433
1416 mmc_remove_host(host->mmc); 1434 mmc_remove_host(host->mmc);
1417 sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL); 1435 sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL);
1418 1436