diff mbox

[2/2] mmc: dw_mmc: prevent to set the wrong value

Message ID 1462346074-19113-2-git-send-email-jh80.chung@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jaehoon Chung May 4, 2016, 7:14 a.m. UTC
If there is no vqmmc, real voltage should not change.
Then it needs to maintain the previous status for UHS_REG register.
It means that it doesn't need to set any bit.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
---
 drivers/mmc/host/dw_mmc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Shawn Lin May 4, 2016, 10:35 a.m. UTC | #1
? 2016/5/4 15:14, Jaehoon Chung ??:
> If there is no vqmmc, real voltage should not change.
> Then it needs to maintain the previous status for UHS_REG register.
> It means that it doesn't need to set any bit.
>
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> ---
>  drivers/mmc/host/dw_mmc.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 28602cc..6bd8018 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -1418,7 +1418,19 @@ static int dw_mci_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
>  					 ret, uhs & v18 ? "1.8" : "3.3");
>  			return -EAGAIN;
>  		}
> +	} else {
> +		/*
> +		 * If there isn't vqmmc, it should fail to switch voltage.
> +		 * Then it needs to maintain the previous status.
> +		 * If ios->signal_voltage is 3.3v, it means that previous
> +		 * voltages was 1.8v.
> +		 */
> +		if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
> +			uhs |= v18;
> +		else
> +			uhs &= ~v18;

I think we can just set uhs after seting vqmmc correctly. So
how about changing like this?

         uhs = mci_readl(host, UHS_REG);

         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 ? "3.3" : "1.8");
                         return -EAGAIN;
                 }
                 if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
                         uhs &= ~v18;
                 else
                         uhs |= v18;
         }
         mci_writel(host, UHS_REG, uhs);


>  	}
> +
>  	mci_writel(host, UHS_REG, uhs);
>
>  	return 0;
>
Jaehoon Chung May 10, 2016, 1:49 a.m. UTC | #2
Hi Shawn,

On 05/04/2016 07:35 PM, Shawn Lin wrote:
> ? 2016/5/4 15:14, Jaehoon Chung ??:
>> If there is no vqmmc, real voltage should not change.
>> Then it needs to maintain the previous status for UHS_REG register.
>> It means that it doesn't need to set any bit.
>>
>> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
>> ---
>>  drivers/mmc/host/dw_mmc.c | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
>> index 28602cc..6bd8018 100644
>> --- a/drivers/mmc/host/dw_mmc.c
>> +++ b/drivers/mmc/host/dw_mmc.c
>> @@ -1418,7 +1418,19 @@ static int dw_mci_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
>>                       ret, uhs & v18 ? "1.8" : "3.3");
>>              return -EAGAIN;
>>          }
>> +    } else {
>> +        /*
>> +         * If there isn't vqmmc, it should fail to switch voltage.
>> +         * Then it needs to maintain the previous status.
>> +         * If ios->signal_voltage is 3.3v, it means that previous
>> +         * voltages was 1.8v.
>> +         */
>> +        if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
>> +            uhs |= v18;
>> +        else
>> +            uhs &= ~v18;
> 
> I think we can just set uhs after seting vqmmc correctly. So
> how about changing like this?

Yes, it's more readable than mine. Thanks.

Best Regards,
Jaehoon Chung

> 
>         uhs = mci_readl(host, UHS_REG);
> 
>         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 ? "3.3" : "1.8");
>                         return -EAGAIN;
>                 }
>                 if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
>                         uhs &= ~v18;
>                 else
>                         uhs |= v18;
>         }
>         mci_writel(host, UHS_REG, uhs);
> 
> 
>>      }
>> +
>>      mci_writel(host, UHS_REG, uhs);
>>
>>      return 0;
>>
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 28602cc..6bd8018 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1418,7 +1418,19 @@  static int dw_mci_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
 					 ret, uhs & v18 ? "1.8" : "3.3");
 			return -EAGAIN;
 		}
+	} else {
+		/*
+		 * If there isn't vqmmc, it should fail to switch voltage.
+		 * Then it needs to maintain the previous status.
+		 * If ios->signal_voltage is 3.3v, it means that previous
+		 * voltages was 1.8v.
+		 */
+		if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
+			uhs |= v18;
+		else
+			uhs &= ~v18;
 	}
+
 	mci_writel(host, UHS_REG, uhs);
 
 	return 0;