mmc: host: Prepare host drivers for mmc_regulator_set_vqmmc() returning > 0
Patch all drivers which use mmc_regulator_set_vqmmc() and prepare them for the fact that mmc_regulator_set_vqmmc() can return a value > 0, which would happen if the signal voltage switch did NOT happen, because the voltage was already set correctly. Signed-off-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20200416163649.336967-1-marex@denx.de [Ulf: Re-worked/simplified the code a bit] Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
@@ -424,7 +424,7 @@ static int dw_mci_hi3660_switch_voltage(struct mmc_host *mmc,
|
|||||||
|
|
||||||
if (!IS_ERR(mmc->supply.vqmmc)) {
|
if (!IS_ERR(mmc->supply.vqmmc)) {
|
||||||
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
||||||
if (ret) {
|
if (ret < 0) {
|
||||||
dev_err(host->dev, "Regulator set error %d\n", ret);
|
dev_err(host->dev, "Regulator set error %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -1546,8 +1546,7 @@ static int dw_mci_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
|
|||||||
|
|
||||||
if (!IS_ERR(mmc->supply.vqmmc)) {
|
if (!IS_ERR(mmc->supply.vqmmc)) {
|
||||||
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
||||||
|
if (ret < 0) {
|
||||||
if (ret) {
|
|
||||||
dev_dbg(&mmc->class_dev,
|
dev_dbg(&mmc->class_dev,
|
||||||
"Regulator set error %d - %s V\n",
|
"Regulator set error %d - %s V\n",
|
||||||
ret, uhs & v18 ? "1.8" : "3.3");
|
ret, uhs & v18 ? "1.8" : "3.3");
|
||||||
|
@@ -1004,6 +1004,8 @@ static int meson_mmc_card_busy(struct mmc_host *mmc)
|
|||||||
|
|
||||||
static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
|
static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* vqmmc regulator is available */
|
/* vqmmc regulator is available */
|
||||||
if (!IS_ERR(mmc->supply.vqmmc)) {
|
if (!IS_ERR(mmc->supply.vqmmc)) {
|
||||||
/*
|
/*
|
||||||
@@ -1013,7 +1015,8 @@ static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
|
|||||||
* to 1.8v. Please make sure the regulator framework is aware
|
* to 1.8v. Please make sure the regulator framework is aware
|
||||||
* of your own regulator constraints
|
* of your own regulator constraints
|
||||||
*/
|
*/
|
||||||
return mmc_regulator_set_vqmmc(mmc, ios);
|
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
||||||
|
return ret < 0 ? ret : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no vqmmc regulator, assume fixed regulator at 3/3.3V */
|
/* no vqmmc regulator, assume fixed regulator at 3/3.3V */
|
||||||
|
@@ -1369,7 +1369,7 @@ static void msdc_set_buswidth(struct msdc_host *host, u32 width)
|
|||||||
static int msdc_ops_switch_volt(struct mmc_host *mmc, struct mmc_ios *ios)
|
static int msdc_ops_switch_volt(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
{
|
{
|
||||||
struct msdc_host *host = mmc_priv(mmc);
|
struct msdc_host *host = mmc_priv(mmc);
|
||||||
int ret = 0;
|
int ret;
|
||||||
|
|
||||||
if (!IS_ERR(mmc->supply.vqmmc)) {
|
if (!IS_ERR(mmc->supply.vqmmc)) {
|
||||||
if (ios->signal_voltage != MMC_SIGNAL_VOLTAGE_330 &&
|
if (ios->signal_voltage != MMC_SIGNAL_VOLTAGE_330 &&
|
||||||
@@ -1379,18 +1379,19 @@ static int msdc_ops_switch_volt(struct mmc_host *mmc, struct mmc_ios *ios)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
||||||
if (ret) {
|
if (ret < 0) {
|
||||||
dev_dbg(host->dev, "Regulator set error %d (%d)\n",
|
dev_dbg(host->dev, "Regulator set error %d (%d)\n",
|
||||||
ret, ios->signal_voltage);
|
ret, ios->signal_voltage);
|
||||||
} else {
|
return ret;
|
||||||
/* Apply different pinctrl settings for different signal voltage */
|
|
||||||
if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
|
|
||||||
pinctrl_select_state(host->pinctrl, host->pins_uhs);
|
|
||||||
else
|
|
||||||
pinctrl_select_state(host->pinctrl, host->pins_default);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Apply different pinctrl settings for different signal voltage */
|
||||||
|
if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
|
||||||
|
pinctrl_select_state(host->pinctrl, host->pins_uhs);
|
||||||
|
else
|
||||||
|
pinctrl_select_state(host->pinctrl, host->pins_default);
|
||||||
}
|
}
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int msdc_card_busy(struct mmc_host *mmc)
|
static int msdc_card_busy(struct mmc_host *mmc)
|
||||||
|
@@ -237,7 +237,7 @@ static int renesas_sdhi_start_signal_voltage_switch(struct mmc_host *mmc,
|
|||||||
MMC_SIGNAL_VOLTAGE_330 ? 0 : -EINVAL;
|
MMC_SIGNAL_VOLTAGE_330 ? 0 : -EINVAL;
|
||||||
|
|
||||||
ret = mmc_regulator_set_vqmmc(host->mmc, ios);
|
ret = mmc_regulator_set_vqmmc(host->mmc, ios);
|
||||||
if (ret)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return pinctrl_select_state(priv->pinctrl, pin_state);
|
return pinctrl_select_state(priv->pinctrl, pin_state);
|
||||||
|
@@ -434,7 +434,7 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
|
|||||||
|
|
||||||
if (!IS_ERR(mmc->supply.vqmmc)) {
|
if (!IS_ERR(mmc->supply.vqmmc)) {
|
||||||
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
||||||
if (ret) {
|
if (ret < 0) {
|
||||||
pr_err("%s: Switching signalling voltage failed\n",
|
pr_err("%s: Switching signalling voltage failed\n",
|
||||||
mmc_hostname(mmc));
|
mmc_hostname(mmc));
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -2411,7 +2411,7 @@ int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
|
|||||||
|
|
||||||
if (!IS_ERR(mmc->supply.vqmmc)) {
|
if (!IS_ERR(mmc->supply.vqmmc)) {
|
||||||
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
||||||
if (ret) {
|
if (ret < 0) {
|
||||||
pr_warn("%s: Switching to 3.3V signalling voltage failed\n",
|
pr_warn("%s: Switching to 3.3V signalling voltage failed\n",
|
||||||
mmc_hostname(mmc));
|
mmc_hostname(mmc));
|
||||||
return -EIO;
|
return -EIO;
|
||||||
@@ -2434,7 +2434,7 @@ int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (!IS_ERR(mmc->supply.vqmmc)) {
|
if (!IS_ERR(mmc->supply.vqmmc)) {
|
||||||
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
||||||
if (ret) {
|
if (ret < 0) {
|
||||||
pr_warn("%s: Switching to 1.8V signalling voltage failed\n",
|
pr_warn("%s: Switching to 1.8V signalling voltage failed\n",
|
||||||
mmc_hostname(mmc));
|
mmc_hostname(mmc));
|
||||||
return -EIO;
|
return -EIO;
|
||||||
@@ -2466,7 +2466,7 @@ int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (!IS_ERR(mmc->supply.vqmmc)) {
|
if (!IS_ERR(mmc->supply.vqmmc)) {
|
||||||
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
||||||
if (ret) {
|
if (ret < 0) {
|
||||||
pr_warn("%s: Switching to 1.2V signalling voltage failed\n",
|
pr_warn("%s: Switching to 1.2V signalling voltage failed\n",
|
||||||
mmc_hostname(mmc));
|
mmc_hostname(mmc));
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
@@ -951,9 +951,13 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
|||||||
|
|
||||||
static int sunxi_mmc_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
|
static int sunxi_mmc_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* vqmmc regulator is available */
|
/* vqmmc regulator is available */
|
||||||
if (!IS_ERR(mmc->supply.vqmmc))
|
if (!IS_ERR(mmc->supply.vqmmc)) {
|
||||||
return mmc_regulator_set_vqmmc(mmc, ios);
|
ret = mmc_regulator_set_vqmmc(mmc, ios);
|
||||||
|
return ret < 0 ? ret : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* no vqmmc regulator, assume fixed regulator at 3/3.3V */
|
/* no vqmmc regulator, assume fixed regulator at 3/3.3V */
|
||||||
if (mmc->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330)
|
if (mmc->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330)
|
||||||
|
Reference in New Issue
Block a user