@@ -1170,7 +1170,7 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
11701170host -> clock = clock ;
11711171}
11721172
1173- static void sdhci_set_power (struct sdhci_host * host , unsigned short power )
1173+ static int sdhci_set_power (struct sdhci_host * host , unsigned short power )
11741174{
11751175u8 pwr = 0 ;
11761176
@@ -1193,13 +1193,13 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
11931193}
11941194
11951195if (host -> pwr == pwr )
1196- return ;
1196+ return -1 ;
11971197
11981198host -> pwr = pwr ;
11991199
12001200if (pwr == 0 ) {
12011201sdhci_writeb (host , 0 , SDHCI_POWER_CONTROL );
1202- return ;
1202+ return 0 ;
12031203}
12041204
12051205/*
@@ -1226,6 +1226,8 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
12261226 */
12271227if (host -> quirks & SDHCI_QUIRK_DELAY_AFTER_POWER )
12281228mdelay (10 );
1229+
1230+ return power ;
12291231}
12301232
12311233/*****************************************************************************\
@@ -1307,12 +1309,17 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
13071309static void sdhci_do_set_ios (struct sdhci_host * host , struct mmc_ios * ios )
13081310{
13091311unsigned long flags ;
1312+ int vdd_bit = -1 ;
13101313u8 ctrl ;
13111314
13121315spin_lock_irqsave (& host -> lock , flags );
13131316
1314- if (host -> flags & SDHCI_DEVICE_DEAD )
1315- goto out ;
1317+ if (host -> flags & SDHCI_DEVICE_DEAD ) {
1318+ spin_unlock_irqrestore (& host -> lock , flags );
1319+ if (host -> vmmc && ios -> power_mode == MMC_POWER_OFF )
1320+ mmc_regulator_set_ocr (host -> mmc , host -> vmmc , 0 );
1321+ return ;
1322+ }
13161323
13171324/*
13181325 * Reset the chip on each power off.
@@ -1326,9 +1333,15 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
13261333sdhci_set_clock (host , ios -> clock );
13271334
13281335if (ios -> power_mode == MMC_POWER_OFF )
1329- sdhci_set_power (host , -1 );
1336+ vdd_bit = sdhci_set_power (host , -1 );
13301337else
1331- sdhci_set_power (host , ios -> vdd );
1338+ vdd_bit = sdhci_set_power (host , ios -> vdd );
1339+
1340+ if (host -> vmmc && vdd_bit != -1 ) {
1341+ spin_unlock_irqrestore (& host -> lock , flags );
1342+ mmc_regulator_set_ocr (host -> mmc , host -> vmmc , vdd_bit );
1343+ spin_lock_irqsave (& host -> lock , flags );
1344+ }
13321345
13331346if (host -> ops -> platform_send_init_74_clocks )
13341347host -> ops -> platform_send_init_74_clocks (host , ios -> power_mode );
@@ -1453,7 +1466,6 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
14531466if (host -> quirks & SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS )
14541467sdhci_reset (host , SDHCI_RESET_CMD | SDHCI_RESET_DATA );
14551468
1456- out :
14571469mmiowb ();
14581470spin_unlock_irqrestore (& host -> lock , flags );
14591471}
@@ -2357,9 +2369,6 @@ int sdhci_suspend_host(struct sdhci_host *host)
23572369
23582370free_irq (host -> irq , host );
23592371
2360- if (host -> vmmc )
2361- ret = regulator_disable (host -> vmmc );
2362-
23632372return ret ;
23642373}
23652374
@@ -2369,12 +2378,6 @@ int sdhci_resume_host(struct sdhci_host *host)
23692378{
23702379int ret ;
23712380
2372- if (host -> vmmc ) {
2373- int ret = regulator_enable (host -> vmmc );
2374- if (ret )
2375- return ret ;
2376- }
2377-
23782381if (host -> flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA )) {
23792382if (host -> ops -> enable_dma )
23802383host -> ops -> enable_dma (host );
@@ -2936,8 +2939,6 @@ int sdhci_add_host(struct sdhci_host *host)
29362939if (IS_ERR (host -> vmmc )) {
29372940pr_info ("%s: no vmmc regulator found\n" , mmc_hostname (mmc ));
29382941host -> vmmc = NULL ;
2939- } else {
2940- regulator_enable (host -> vmmc );
29412942}
29422943
29432944sdhci_init (host , 0 );
@@ -3026,10 +3027,8 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
30263027tasklet_kill (& host -> card_tasklet );
30273028tasklet_kill (& host -> finish_tasklet );
30283029
3029- if (host -> vmmc ) {
3030- regulator_disable (host -> vmmc );
3030+ if (host -> vmmc )
30313031regulator_put (host -> vmmc );
3032- }
30333032
30343033kfree (host -> adma_desc );
30353034kfree (host -> align_buffer );
0 commit comments