Skip to content

Commit 1dceb04

Browse files
ahunter6storulf
authored andcommitted
mmc: sdhci: Fix regression setting power on Trats2 board
Several commits relating to setting power have been introducing problems by putting driver-specific rules into generic SDHCI code. Krzysztof Kozlowski reported that after commit 918f4cb ("mmc: sdhci: restore behavior when setting VDD via external regulator") on Trats2 board there are warnings for invalid VDD value (2.8V): [ 3.119656] ------------[ cut here ]------------ [ 3.119666] WARNING: CPU: 3 PID: 90 at ../drivers/mmc/host/sdhci.c:1234 sdhci_do_set_ios+0x4cc/0x5e0 [ 3.119669] mmc0: Invalid vdd 0x10 [ 3.119673] Modules linked in: [ 3.119679] CPU: 3 PID: 90 Comm: kworker/3:1 Tainted: G W 4.5.0-next-20160324 torvalds#23 [ 3.119681] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [ 3.119690] Workqueue: events_freezable mmc_rescan [ 3.119708] [<c010e0ac>] (unwind_backtrace) from [<c010ae10>] (show_stack+0x10/0x14) [ 3.119719] [<c010ae10>] (show_stack) from [<c0323260>] (dump_stack+0x88/0x9c) [ 3.119728] [<c0323260>] (dump_stack) from [<c011b754>] (__warn+0xe8/0x100) [ 3.119734] [<c011b754>] (__warn) from [<c011b7a4>] (warn_slowpath_fmt+0x38/0x48) [ 3.119740] [<c011b7a4>] (warn_slowpath_fmt) from [<c0527d28>] (sdhci_do_set_ios+0x4cc/0x5e0) [ 3.119748] [<c0527d28>] (sdhci_do_set_ios) from [<c0528018>] (sdhci_runtime_resume_host+0x60/0x114) [ 3.119758] [<c0528018>] (sdhci_runtime_resume_host) from [<c0402570>] (__rpm_callback+0x2c/0x60) [ 3.119767] [<c0402570>] (__rpm_callback) from [<c04025c4>] (rpm_callback+0x20/0x80) [ 3.119773] [<c04025c4>] (rpm_callback) from [<c04034b8>] (rpm_resume+0x36c/0x558) [ 3.119780] [<c04034b8>] (rpm_resume) from [<c04036f0>] (__pm_runtime_resume+0x4c/0x64) [ 3.119788] [<c04036f0>] (__pm_runtime_resume) from [<c0512728>] (__mmc_claim_host+0x170/0x1b0) [ 3.119795] [<c0512728>] (__mmc_claim_host) from [<c0514e2c>] (mmc_rescan+0x54/0x348) [ 3.119807] [<c0514e2c>] (mmc_rescan) from [<c0130dac>] (process_one_work+0x120/0x3f4) [ 3.119815] [<c0130dac>] (process_one_work) from [<c01310b8>] (worker_thread+0x38/0x554) [ 3.119823] [<c01310b8>] (worker_thread) from [<c01365a4>] (kthread+0xdc/0xf4) [ 3.119831] [<c01365a4>] (kthread) from [<c0107878>] (ret_from_fork+0x14/0x3c) [ 3.119834] ---[ end trace a22d652aa3276886 ]--- Fix by adding a 'set_power' callback and restoring the default behaviour prior to commit 918f4cb ("mmc: sdhci: restore behavior when setting VDD via external regulator"). The desired behaviour of that commit is gotten by having sdhci-pxav3 provide its own set_power callback. Reported-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Link: http://lkml.kernel.org/r/CAJKOXPcGDnPm-Ykh6wHqV1YxfTaov5E8iVqBoBn4OJc7BnhgEQ@mail.gmail.com Fixes: 918f4cb ("mmc: sdhci: restore behavior when setting VDD...) Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Tested-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: stable@vger.kernel.org # v4.5+ Reviewed-by: Jisheng Zhang <jszhang@marvell.com> Tested-by: Jisheng Zhang <jszhang@marvell.com> Tested-by: Jaehoon Chung <jh80.chung@samsung.com> Tested-by: Anand Moon <linux.amoon@gmail.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent f55532a commit 1dceb04

File tree

3 files changed

+56
-9
lines changed

3 files changed

+56
-9
lines changed

drivers/mmc/host/sdhci-pxav3.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,30 @@ static void pxav3_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs)
309309
__func__, uhs, ctrl_2);
310310
}
311311

312+
static void pxav3_set_power(struct sdhci_host *host, unsigned char mode,
313+
unsigned short vdd)
314+
{
315+
struct mmc_host *mmc = host->mmc;
316+
u8 pwr = host->pwr;
317+
318+
sdhci_set_power(host, mode, vdd);
319+
320+
if (host->pwr == pwr)
321+
return;
322+
323+
if (host->pwr == 0)
324+
vdd = 0;
325+
326+
if (!IS_ERR(mmc->supply.vmmc)) {
327+
spin_unlock_irq(&host->lock);
328+
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
329+
spin_lock_irq(&host->lock);
330+
}
331+
}
332+
312333
static const struct sdhci_ops pxav3_sdhci_ops = {
313334
.set_clock = sdhci_set_clock,
335+
.set_power = pxav3_set_power,
314336
.platform_send_init_74_clocks = pxav3_gen_init_74_clocks,
315337
.get_max_clock = sdhci_pltfm_clk_get_max_clock,
316338
.set_bus_width = sdhci_set_bus_width,

drivers/mmc/host/sdhci.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,10 +1210,24 @@ void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
12101210
}
12111211
EXPORT_SYMBOL_GPL(sdhci_set_clock);
12121212

1213-
static void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
1214-
unsigned short vdd)
1213+
static void sdhci_set_power_reg(struct sdhci_host *host, unsigned char mode,
1214+
unsigned short vdd)
12151215
{
12161216
struct mmc_host *mmc = host->mmc;
1217+
1218+
spin_unlock_irq(&host->lock);
1219+
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
1220+
spin_lock_irq(&host->lock);
1221+
1222+
if (mode != MMC_POWER_OFF)
1223+
sdhci_writeb(host, SDHCI_POWER_ON, SDHCI_POWER_CONTROL);
1224+
else
1225+
sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
1226+
}
1227+
1228+
void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
1229+
unsigned short vdd)
1230+
{
12171231
u8 pwr = 0;
12181232

12191233
if (mode != MMC_POWER_OFF) {
@@ -1245,7 +1259,6 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
12451259
sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
12461260
if (host->quirks2 & SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON)
12471261
sdhci_runtime_pm_bus_off(host);
1248-
vdd = 0;
12491262
} else {
12501263
/*
12511264
* Spec says that we should clear the power reg before setting
@@ -1276,12 +1289,20 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
12761289
if (host->quirks & SDHCI_QUIRK_DELAY_AFTER_POWER)
12771290
mdelay(10);
12781291
}
1292+
}
1293+
EXPORT_SYMBOL_GPL(sdhci_set_power);
12791294

1280-
if (!IS_ERR(mmc->supply.vmmc)) {
1281-
spin_unlock_irq(&host->lock);
1282-
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
1283-
spin_lock_irq(&host->lock);
1284-
}
1295+
static void __sdhci_set_power(struct sdhci_host *host, unsigned char mode,
1296+
unsigned short vdd)
1297+
{
1298+
struct mmc_host *mmc = host->mmc;
1299+
1300+
if (host->ops->set_power)
1301+
host->ops->set_power(host, mode, vdd);
1302+
else if (!IS_ERR(mmc->supply.vmmc))
1303+
sdhci_set_power_reg(host, mode, vdd);
1304+
else
1305+
sdhci_set_power(host, mode, vdd);
12851306
}
12861307

12871308
/*****************************************************************************\
@@ -1431,7 +1452,7 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
14311452
}
14321453
}
14331454

1434-
sdhci_set_power(host, ios->power_mode, ios->vdd);
1455+
__sdhci_set_power(host, ios->power_mode, ios->vdd);
14351456

14361457
if (host->ops->platform_send_init_74_clocks)
14371458
host->ops->platform_send_init_74_clocks(host, ios->power_mode);

drivers/mmc/host/sdhci.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ struct sdhci_ops {
529529
#endif
530530

531531
void (*set_clock)(struct sdhci_host *host, unsigned int clock);
532+
void (*set_power)(struct sdhci_host *host, unsigned char mode,
533+
unsigned short vdd);
532534

533535
int (*enable_dma)(struct sdhci_host *host);
534536
unsigned int (*get_max_clock)(struct sdhci_host *host);
@@ -660,6 +662,8 @@ static inline bool sdhci_sdio_irq_enabled(struct sdhci_host *host)
660662
}
661663

662664
void sdhci_set_clock(struct sdhci_host *host, unsigned int clock);
665+
void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
666+
unsigned short vdd);
663667
void sdhci_set_bus_width(struct sdhci_host *host, int width);
664668
void sdhci_reset(struct sdhci_host *host, u8 mask);
665669
void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing);

0 commit comments

Comments
 (0)