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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



在 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@xxxxxxxxxxx>
---
 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;



--
Best Regards
Shawn Lin

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



[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux