aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorJaehoon Chung <jh80.chung@samsung.com>2011-02-24 21:08:14 -0500
committerChris Ball <cjb@laptop.org>2011-03-17 15:35:22 -0400
commitc07946a3350244d7c3d9bc1032325e04dd11575b (patch)
tree8cab4261ebbdb857e7f46fe2dc6ed3d4652369f4 /drivers/mmc
parente61cf1184d72e574460492fd6c6b6d8a3ace2089 (diff)
mmc: dw_mmc: support mmc power control with regulator
This patch adds support for power regulators. Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> Signed-off-by: kyungmin Park <kyungmin.park@samsung.com> Acked-by: Will Newton <will.newton@imgtec.com> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/dw_mmc.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 51ee2f5909d4..5a614069cb00 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -32,6 +32,7 @@
32#include <linux/mmc/mmc.h> 32#include <linux/mmc/mmc.h>
33#include <linux/mmc/dw_mmc.h> 33#include <linux/mmc/dw_mmc.h>
34#include <linux/bitops.h> 34#include <linux/bitops.h>
35#include <linux/regulator/consumer.h>
35 36
36#include "dw_mmc.h" 37#include "dw_mmc.h"
37 38
@@ -1440,6 +1441,13 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id)
1440 } 1441 }
1441#endif /* CONFIG_MMC_DW_IDMAC */ 1442#endif /* CONFIG_MMC_DW_IDMAC */
1442 1443
1444 host->vmmc = regulator_get(mmc_dev(mmc), "vmmc");
1445 if (IS_ERR(host->vmmc)) {
1446 printk(KERN_INFO "%s: no vmmc regulator found\n", mmc_hostname(mmc));
1447 host->vmmc = NULL;
1448 } else
1449 regulator_enable(host->vmmc);
1450
1443 if (dw_mci_get_cd(mmc)) 1451 if (dw_mci_get_cd(mmc))
1444 set_bit(DW_MMC_CARD_PRESENT, &slot->flags); 1452 set_bit(DW_MMC_CARD_PRESENT, &slot->flags);
1445 else 1453 else
@@ -1704,6 +1712,12 @@ err_dmaunmap:
1704 host->sg_cpu, host->sg_dma); 1712 host->sg_cpu, host->sg_dma);
1705 iounmap(host->regs); 1713 iounmap(host->regs);
1706 1714
1715 if (host->vmmc) {
1716 regulator_disable(host->vmmc);
1717 regulator_put(host->vmmc);
1718 }
1719
1720
1707err_freehost: 1721err_freehost:
1708 kfree(host); 1722 kfree(host);
1709 return ret; 1723 return ret;
@@ -1735,6 +1749,11 @@ static int __exit dw_mci_remove(struct platform_device *pdev)
1735 if (host->use_dma && host->dma_ops->exit) 1749 if (host->use_dma && host->dma_ops->exit)
1736 host->dma_ops->exit(host); 1750 host->dma_ops->exit(host);
1737 1751
1752 if (host->vmmc) {
1753 regulator_disable(host->vmmc);
1754 regulator_put(host->vmmc);
1755 }
1756
1738 iounmap(host->regs); 1757 iounmap(host->regs);
1739 1758
1740 kfree(host); 1759 kfree(host);
@@ -1750,6 +1769,9 @@ static int dw_mci_suspend(struct platform_device *pdev, pm_message_t mesg)
1750 int i, ret; 1769 int i, ret;
1751 struct dw_mci *host = platform_get_drvdata(pdev); 1770 struct dw_mci *host = platform_get_drvdata(pdev);
1752 1771
1772 if (host->vmmc)
1773 regulator_enable(host->vmmc);
1774
1753 for (i = 0; i < host->num_slots; i++) { 1775 for (i = 0; i < host->num_slots; i++) {
1754 struct dw_mci_slot *slot = host->slot[i]; 1776 struct dw_mci_slot *slot = host->slot[i];
1755 if (!slot) 1777 if (!slot)
@@ -1765,6 +1787,9 @@ static int dw_mci_suspend(struct platform_device *pdev, pm_message_t mesg)
1765 } 1787 }
1766 } 1788 }
1767 1789
1790 if (host->vmmc)
1791 regulator_disable(host->vmmc);
1792
1768 return 0; 1793 return 0;
1769} 1794}
1770 1795