From: Jaehoon Chung <jh80.chung@samsung.com>
To: Shawn Lin <shawn.lin@rock-chips.com>, linux-mmc@vger.kernel.org
Cc: ulf.hansson@linaro.org
Subject: Re: [PATCH v2 3/3] mmc: dw_mmc: prevent to set the wrong value
Date: Wed, 22 Jun 2016 13:15:37 +0900 [thread overview]
Message-ID: <576A10E9.30101@samsung.com> (raw)
In-Reply-To: <ab1a9cae-b841-4ec2-8382-7f355b352382@rock-chips.com>
On 06/21/2016 05:13 PM, Shawn Lin wrote:
> On 2016/6/21 13:35, Jaehoon Chung wrote:
>> If there ins no vqmmc, voltage should not be changed.
>> Then it nees to maintain the previous status for USH_REG register.
>> To use the standard spec, it should be returned error when voltage
>> can't switch.
>>
>> Note:
>> Dwmmc controller will not make any exception case.(like exynos.)
>> If card isn't working well after appling this patch, it needs to check
>> the regulator side.
>>
>> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
>> ---
>> Changelog V2:
>> -Fix the typo
>>
>> drivers/mmc/host/dw_mmc.c | 40 ++++++++++++++++++++++------------------
>> 1 file changed, 22 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
>> index ec3f0a8..56c48fb 100644
>> --- a/drivers/mmc/host/dw_mmc.c
>> +++ b/drivers/mmc/host/dw_mmc.c
>> @@ -1404,33 +1404,37 @@ static int dw_mci_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
>> struct dw_mci_slot *slot = mmc_priv(mmc);
>> struct dw_mci *host = slot->host;
>> const struct dw_mci_drv_data *drv_data = host->drv_data;
>> - u32 uhs;
>> + u32 uhs = 0;
>> u32 v18 = SDMMC_UHS_18V << slot->id;
>> int ret;
>>
>> if (drv_data && drv_data->switch_voltage)
>> return drv_data->switch_voltage(mmc, ios);
>>
>> - /*
>> - * Program the voltage. Note that some instances of dw_mmc may use
>> - * the UHS_REG for this. For other instances (like exynos) the UHS_REG
>> - * does no harm but you need to set the regulator directly. Try both.
>> - */
>> + if (IS_ERR(mmc->supply.vqmmc)) {
>> + dev_dbg(&mmc->class_dev,
>> + "vqmmc not available.(Skip the switching voltage)\n");
>> + return -EINVAL;
>> + }
>> +
>> + ret = mmc_regulator_set_vqmmc(mmc, ios);
>> + if (ret) {
>> + dev_err(&mmc->class_dev,
>> + "Regulator set error %d - %s V\n",
>> + ret, uhs & v18 ? "1.8" : "3.3");
>> + return ret;
>> + }
>> +
>> uhs = mci_readl(host, UHS_REG);
>> - if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
>
> uhs is still zero now, so maybe we can remove this switch branch and
> only need a simple checking like this:
>
> if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
> uhs |= v18;
It's not enough to set the correct value.
So i will maintain this patch..
In future, i will add the MMC_SIGNAL_VOLTAGE_120 for USH_REG_EXT register.
At that time, switch statement should be better than "if" statement.. :)
Anyway, I applied this patch on my repository. If you have any objection, i will accept your opinion. :)
Best Regards,
Jaehoon Chung
>
> otherwise, it looks good to me.
>
>> + switch (ios->signal_voltage) {
>> + case MMC_SIGNAL_VOLTAGE_330:
>> uhs &= ~v18;
>> - else
>> + break;
>> + case MMC_SIGNAL_VOLTAGE_180:
>> uhs |= v18;
>> -
>> - if (!IS_ERR(mmc->supply.vqmmc)) {
>> - ret = mmc_regulator_set_vqmmc(mmc, ios);
>> -
>> - if (ret) {
>> - dev_dbg(&mmc->class_dev,
>> - "Regulator set error %d - %s V\n",
>> - ret, uhs & v18 ? "1.8" : "3.3");
>> - return ret;
>> - }
>> + break;
>> + default:
>> + uhs &= ~v18;
>> }
>> mci_writel(host, UHS_REG, uhs);
>>
>>
>
>
next prev parent reply other threads:[~2016-06-22 4:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20160621053541epcas1p3387b723d08d124864a03a3abe082821f@epcas1p3.samsung.com>
2016-06-21 5:35 ` [PATCH v2 1/3] mmc: dw_mmc: remove the quirks flags Jaehoon Chung
2016-06-21 5:35 ` [PATCH v2 2/3] mmc: dw_mmc: add the card write threshold for HS400 mode Jaehoon Chung
2016-06-21 8:05 ` Shawn Lin
2016-06-22 4:16 ` Jaehoon Chung
2016-06-21 5:35 ` [PATCH v2 3/3] mmc: dw_mmc: prevent to set the wrong value Jaehoon Chung
2016-06-21 8:13 ` Shawn Lin
2016-06-22 4:15 ` Jaehoon Chung [this message]
2016-06-22 4:16 ` [PATCH v2 1/3] mmc: dw_mmc: remove the quirks flags Jaehoon Chung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=576A10E9.30101@samsung.com \
--to=jh80.chung@samsung.com \
--cc=linux-mmc@vger.kernel.org \
--cc=shawn.lin@rock-chips.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox