aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host
diff options
context:
space:
mode:
authorBastian Hecht <hechtb@googlemail.com>2011-12-23 17:03:13 -0500
committerChris Ball <cjb@laptop.org>2012-01-11 23:58:45 -0500
commitcbb18b309d3d6b6661f931279697eac77b6591c9 (patch)
tree7df65c7d8200b38bef31a3fee09a1af18808f30d /drivers/mmc/host
parent913047e9e5787a90696533a9f109552b7694ecc9 (diff)
mmc: tmio_mmc: Hotplug code regrouping
This patch regroups the code slightly, adds documentation and allows the rtpm counter of MMC_CAP_NEEDS_POLL devices to reach 0 again. Signed-off-by: Bastian Hecht <hechtb@gmail.com> [g.liakhovetski@gmx.de: restore pm_runtime_get_noresume()] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/host')
-rw-r--r--drivers/mmc/host/tmio_mmc_pio.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 4208b3958069..abad01b37cfb 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -800,8 +800,7 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
800 } else if (ios->power_mode != MMC_POWER_UP) { 800 } else if (ios->power_mode != MMC_POWER_UP) {
801 if (host->set_pwr && ios->power_mode == MMC_POWER_OFF) 801 if (host->set_pwr && ios->power_mode == MMC_POWER_OFF)
802 host->set_pwr(host->pdev, 0); 802 host->set_pwr(host->pdev, 0);
803 if ((pdata->flags & TMIO_MMC_HAS_COLD_CD) && 803 if (pdata->power) {
804 pdata->power) {
805 pdata->power = false; 804 pdata->power = false;
806 pm_runtime_put(&host->pdev->dev); 805 pm_runtime_put(&host->pdev->dev);
807 } 806 }
@@ -915,6 +914,23 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host,
915 if (ret < 0) 914 if (ret < 0)
916 goto pm_disable; 915 goto pm_disable;
917 916
917 /*
918 * There are 4 different scenarios for the card detection:
919 * 1) an external gpio irq handles the cd (best for power savings)
920 * 2) internal sdhi irq handles the cd
921 * 3) a worker thread polls the sdhi - indicated by MMC_CAP_NEEDS_POLL
922 * 4) the medium is non-removable - indicated by MMC_CAP_NONREMOVABLE
923 *
924 * While we increment the rtpm counter for all scenarios when the mmc
925 * core activates us by calling an appropriate set_ios(), we must
926 * additionally ensure that in case 2) the tmio mmc hardware stays
927 * powered on during runtime for the card detection to work.
928 */
929 if (!(pdata->flags & TMIO_MMC_HAS_COLD_CD
930 || mmc->caps & MMC_CAP_NEEDS_POLL
931 || mmc->caps & MMC_CAP_NONREMOVABLE))
932 pm_runtime_get_noresume(&pdev->dev);
933
918 tmio_mmc_clk_stop(_host); 934 tmio_mmc_clk_stop(_host);
919 tmio_mmc_reset(_host); 935 tmio_mmc_reset(_host);
920 936
@@ -933,12 +949,6 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host,
933 /* See if we also get DMA */ 949 /* See if we also get DMA */
934 tmio_mmc_request_dma(_host, pdata); 950 tmio_mmc_request_dma(_host, pdata);
935 951
936 /* We have to keep the device powered for its card detection to work */
937 if (!(pdata->flags & TMIO_MMC_HAS_COLD_CD)) {
938 pdata->power = true;
939 pm_runtime_get_noresume(&pdev->dev);
940 }
941
942 mmc_add_host(mmc); 952 mmc_add_host(mmc);
943 953
944 /* Unmask the IRQs we want to know about */ 954 /* Unmask the IRQs we want to know about */
@@ -974,7 +984,9 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
974 * the controller, the runtime PM is suspended and pdata->power == false, 984 * the controller, the runtime PM is suspended and pdata->power == false,
975 * so, our .runtime_resume() will not try to detect a card in the slot. 985 * so, our .runtime_resume() will not try to detect a card in the slot.
976 */ 986 */
977 if (host->pdata->flags & TMIO_MMC_HAS_COLD_CD) 987 if (host->pdata->flags & TMIO_MMC_HAS_COLD_CD
988 || host->mmc->caps & MMC_CAP_NEEDS_POLL
989 || host->mmc->caps & MMC_CAP_NONREMOVABLE)
978 pm_runtime_get_sync(&pdev->dev); 990 pm_runtime_get_sync(&pdev->dev);
979 991
980 mmc_remove_host(host->mmc); 992 mmc_remove_host(host->mmc);