Commit db4a0d05 authored by Ulf Hansson's avatar Ulf Hansson Committed by Chris Ball

mmc: core: Cleanup code for setting ocr mask for SDIO

At several places in mmc_sdio_init_card function the cached mask in
host->ocr were being updated. To simplify code, we make use of an
local ocr parameter instead.
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent ec2ed700
...@@ -593,23 +593,27 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, ...@@ -593,23 +593,27 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
struct mmc_card *card; struct mmc_card *card;
int err; int err;
int retries = 10; int retries = 10;
u32 rocr = 0;
BUG_ON(!host); BUG_ON(!host);
WARN_ON(!host->claimed); WARN_ON(!host->claimed);
/* to query card if 1.8V signalling is supported */
if (mmc_host_uhs(host))
ocr |= R4_18V_PRESENT;
try_again: try_again:
if (!retries) { if (!retries) {
pr_warning("%s: Skipping voltage switch\n", pr_warning("%s: Skipping voltage switch\n",
mmc_hostname(host)); mmc_hostname(host));
ocr &= ~R4_18V_PRESENT; ocr &= ~R4_18V_PRESENT;
host->ocr &= ~R4_18V_PRESENT;
} }
/* /*
* Inform the card of the voltage * Inform the card of the voltage
*/ */
if (!powered_resume) { if (!powered_resume) {
err = mmc_send_io_op_cond(host, host->ocr, &ocr); err = mmc_send_io_op_cond(host, ocr, &rocr);
if (err) if (err)
goto err; goto err;
} }
...@@ -632,8 +636,8 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, ...@@ -632,8 +636,8 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
goto err; goto err;
} }
if ((ocr & R4_MEMORY_PRESENT) && if ((rocr & R4_MEMORY_PRESENT) &&
mmc_sd_get_cid(host, host->ocr & ocr, card->raw_cid, NULL) == 0) { mmc_sd_get_cid(host, ocr & rocr, card->raw_cid, NULL) == 0) {
card->type = MMC_TYPE_SD_COMBO; card->type = MMC_TYPE_SD_COMBO;
if (oldcard && (oldcard->type != MMC_TYPE_SD_COMBO || if (oldcard && (oldcard->type != MMC_TYPE_SD_COMBO ||
...@@ -663,9 +667,9 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, ...@@ -663,9 +667,9 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
* systems that claim 1.8v signalling in fact do not support * systems that claim 1.8v signalling in fact do not support
* it. * it.
*/ */
if (!powered_resume && (ocr & R4_18V_PRESENT) && mmc_host_uhs(host)) { if (!powered_resume && (rocr & ocr & R4_18V_PRESENT)) {
err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180,
host->ocr); ocr);
if (err == -EAGAIN) { if (err == -EAGAIN) {
sdio_reset(host); sdio_reset(host);
mmc_go_idle(host); mmc_go_idle(host);
...@@ -675,12 +679,10 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, ...@@ -675,12 +679,10 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
goto try_again; goto try_again;
} else if (err) { } else if (err) {
ocr &= ~R4_18V_PRESENT; ocr &= ~R4_18V_PRESENT;
host->ocr &= ~R4_18V_PRESENT;
} }
err = 0; err = 0;
} else { } else {
ocr &= ~R4_18V_PRESENT; ocr &= ~R4_18V_PRESENT;
host->ocr &= ~R4_18V_PRESENT;
} }
/* /*
...@@ -1084,10 +1086,6 @@ static int mmc_sdio_power_restore(struct mmc_host *host) ...@@ -1084,10 +1086,6 @@ static int mmc_sdio_power_restore(struct mmc_host *host)
goto out; goto out;
} }
if (mmc_host_uhs(host))
/* to query card if 1.8V signalling is supported */
host->ocr |= R4_18V_PRESENT;
ret = mmc_sdio_init_card(host, host->ocr, host->card, ret = mmc_sdio_init_card(host, host->ocr, host->card,
mmc_card_keep_power(host)); mmc_card_keep_power(host));
if (!ret && host->sdio_irqs) if (!ret && host->sdio_irqs)
...@@ -1170,10 +1168,6 @@ int mmc_attach_sdio(struct mmc_host *host) ...@@ -1170,10 +1168,6 @@ int mmc_attach_sdio(struct mmc_host *host)
/* /*
* Detect and init the card. * Detect and init the card.
*/ */
if (mmc_host_uhs(host))
/* to query card if 1.8V signalling is supported */
host->ocr |= R4_18V_PRESENT;
err = mmc_sdio_init_card(host, host->ocr, NULL, 0); err = mmc_sdio_init_card(host, host->ocr, NULL, 0);
if (err) if (err)
goto err; goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment