diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2012-06-20 13:10:33 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2012-07-21 00:02:11 -0400 |
commit | b958a67c6bbe0a886bebc618aac7a059cdbab418 (patch) | |
tree | b9006e2907d8a1a4299750bdd307cb35d30338d4 /drivers/mmc | |
parent | 56c492879318f43b1a7911675ff30fb0ede123b5 (diff) |
mmc: tmio: add regulator support
Currently the TMIO MMC driver derives the OCR mask from the platform data
and uses a platform callback to turn card power on and off. This patch adds
regulator support to the driver.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Liam Girdwood <lrg@ti.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/tmio_mmc_pio.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index c6c0334a20e1..b5c32b40ebc1 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c | |||
@@ -768,6 +768,18 @@ static int tmio_mmc_clk_update(struct mmc_host *mmc) | |||
768 | return ret; | 768 | return ret; |
769 | } | 769 | } |
770 | 770 | ||
771 | static void tmio_mmc_set_power(struct tmio_mmc_host *host, struct mmc_ios *ios) | ||
772 | { | ||
773 | struct mmc_host *mmc = host->mmc; | ||
774 | |||
775 | if (host->set_pwr) | ||
776 | host->set_pwr(host->pdev, ios->power_mode != MMC_POWER_OFF); | ||
777 | if (!IS_ERR(mmc->supply.vmmc)) | ||
778 | /* Errors ignored... */ | ||
779 | mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, | ||
780 | ios->power_mode ? ios->vdd : 0); | ||
781 | } | ||
782 | |||
771 | /* Set MMC clock / power. | 783 | /* Set MMC clock / power. |
772 | * Note: This controller uses a simple divider scheme therefore it cannot | 784 | * Note: This controller uses a simple divider scheme therefore it cannot |
773 | * run a MMC card at full speed (20MHz). The max clock is 24MHz on SD, but as | 785 | * run a MMC card at full speed (20MHz). The max clock is 24MHz on SD, but as |
@@ -820,13 +832,12 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
820 | } | 832 | } |
821 | tmio_mmc_set_clock(host, ios->clock); | 833 | tmio_mmc_set_clock(host, ios->clock); |
822 | /* power up SD bus */ | 834 | /* power up SD bus */ |
823 | if (host->set_pwr) | 835 | tmio_mmc_set_power(host, ios); |
824 | host->set_pwr(host->pdev, 1); | ||
825 | /* start bus clock */ | 836 | /* start bus clock */ |
826 | tmio_mmc_clk_start(host); | 837 | tmio_mmc_clk_start(host); |
827 | } else if (ios->power_mode != MMC_POWER_UP) { | 838 | } else if (ios->power_mode != MMC_POWER_UP) { |
828 | if (host->set_pwr && ios->power_mode == MMC_POWER_OFF) | 839 | if (ios->power_mode == MMC_POWER_OFF) |
829 | host->set_pwr(host->pdev, 0); | 840 | tmio_mmc_set_power(host, ios); |
830 | if (host->power) { | 841 | if (host->power) { |
831 | struct tmio_mmc_data *pdata = host->pdata; | 842 | struct tmio_mmc_data *pdata = host->pdata; |
832 | tmio_mmc_clk_stop(host); | 843 | tmio_mmc_clk_stop(host); |
@@ -888,6 +899,19 @@ static const struct mmc_host_ops tmio_mmc_ops = { | |||
888 | .enable_sdio_irq = tmio_mmc_enable_sdio_irq, | 899 | .enable_sdio_irq = tmio_mmc_enable_sdio_irq, |
889 | }; | 900 | }; |
890 | 901 | ||
902 | static void tmio_mmc_init_ocr(struct tmio_mmc_host *host) | ||
903 | { | ||
904 | struct tmio_mmc_data *pdata = host->pdata; | ||
905 | struct mmc_host *mmc = host->mmc; | ||
906 | |||
907 | mmc_regulator_get_supply(mmc); | ||
908 | |||
909 | if (!mmc->ocr_avail) | ||
910 | mmc->ocr_avail = pdata->ocr_mask ? : MMC_VDD_32_33 | MMC_VDD_33_34; | ||
911 | else if (pdata->ocr_mask) | ||
912 | dev_warn(mmc_dev(mmc), "Platform OCR mask is ignored\n"); | ||
913 | } | ||
914 | |||
891 | int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, | 915 | int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, |
892 | struct platform_device *pdev, | 916 | struct platform_device *pdev, |
893 | struct tmio_mmc_data *pdata) | 917 | struct tmio_mmc_data *pdata) |
@@ -933,10 +957,7 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, | |||
933 | mmc->max_segs; | 957 | mmc->max_segs; |
934 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; | 958 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; |
935 | mmc->max_seg_size = mmc->max_req_size; | 959 | mmc->max_seg_size = mmc->max_req_size; |
936 | if (pdata->ocr_mask) | 960 | tmio_mmc_init_ocr(_host); |
937 | mmc->ocr_avail = pdata->ocr_mask; | ||
938 | else | ||
939 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; | ||
940 | 961 | ||
941 | _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD || | 962 | _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD || |
942 | mmc->caps & MMC_CAP_NEEDS_POLL || | 963 | mmc->caps & MMC_CAP_NEEDS_POLL || |