diff options
author | Kishon Vijay Abraham I | 2017-01-31 06:26:22 -0600 |
---|---|---|
committer | Kishon Vijay Abraham I | 2017-06-16 07:25:34 -0500 |
commit | 515e6db3803af2bea5b967bacc2d8f11dea131f0 (patch) | |
tree | 826b27c7191cda4956e370654a35c9799371f324 | |
parent | 1acc8ed40c017129c3225f41befaf02313617109 (diff) | |
download | linux-phy-515e6db3803af2bea5b967bacc2d8f11dea131f0.tar.gz linux-phy-515e6db3803af2bea5b967bacc2d8f11dea131f0.tar.xz linux-phy-515e6db3803af2bea5b967bacc2d8f11dea131f0.zip |
mmc: host: omap_hsmmc: Support pbias and vmmc_aux to switch to 1.8v
Add support for vmmc_aux to switch to 1.8v. Also use "iov" instead of
"vdd" to indicate io voltage. This is in preparation for adding support
for io signal voltage switch.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
-rw-r--r-- | drivers/mmc/host/omap_hsmmc.c | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 7c12f3715676..48bb06788d9f 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c | |||
@@ -244,11 +244,12 @@ static int omap_hsmmc_get_cover_state(struct device *dev) | |||
244 | return mmc_gpio_get_cd(host->mmc); | 244 | return mmc_gpio_get_cd(host->mmc); |
245 | } | 245 | } |
246 | 246 | ||
247 | static int omap_hsmmc_enable_supply(struct mmc_host *mmc) | 247 | static int omap_hsmmc_enable_supply(struct mmc_host *mmc, int iov) |
248 | { | 248 | { |
249 | int ret; | 249 | int ret; |
250 | struct omap_hsmmc_host *host = mmc_priv(mmc); | 250 | struct omap_hsmmc_host *host = mmc_priv(mmc); |
251 | struct mmc_ios *ios = &mmc->ios; | 251 | struct mmc_ios *ios = &mmc->ios; |
252 | int uvoltage; | ||
252 | 253 | ||
253 | if (!IS_ERR(mmc->supply.vmmc)) { | 254 | if (!IS_ERR(mmc->supply.vmmc)) { |
254 | ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); | 255 | ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); |
@@ -257,7 +258,25 @@ static int omap_hsmmc_enable_supply(struct mmc_host *mmc) | |||
257 | } | 258 | } |
258 | 259 | ||
259 | /* Enable interface voltage rail, if needed */ | 260 | /* Enable interface voltage rail, if needed */ |
260 | if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) { | 261 | if (!IS_ERR(mmc->supply.vqmmc)) { |
262 | if (host->vqmmc_enabled) { | ||
263 | ret = regulator_disable(mmc->supply.vqmmc); | ||
264 | if (ret) { | ||
265 | dev_err(mmc_dev(mmc), | ||
266 | "vmmc_aux reg disable failed\n"); | ||
267 | goto err_vqmmc; | ||
268 | } | ||
269 | host->vqmmc_enabled = 0; | ||
270 | } | ||
271 | |||
272 | uvoltage = (iov == VDD_165_195) ? VDD_1V8 : VDD_3V0; | ||
273 | ret = regulator_set_voltage(mmc->supply.vqmmc, uvoltage, | ||
274 | uvoltage); | ||
275 | if (ret) { | ||
276 | dev_err(mmc_dev(mmc), "vmmc_aux set voltage failed\n"); | ||
277 | goto err_vqmmc; | ||
278 | } | ||
279 | |||
261 | ret = regulator_enable(mmc->supply.vqmmc); | 280 | ret = regulator_enable(mmc->supply.vqmmc); |
262 | if (ret) { | 281 | if (ret) { |
263 | dev_err(mmc_dev(mmc), "vmmc_aux reg enable failed\n"); | 282 | dev_err(mmc_dev(mmc), "vmmc_aux reg enable failed\n"); |
@@ -309,22 +328,19 @@ err_set_ocr: | |||
309 | } | 328 | } |
310 | 329 | ||
311 | static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on, | 330 | static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on, |
312 | int vdd) | 331 | int iov) |
313 | { | 332 | { |
314 | int ret; | 333 | int ret; |
334 | int uvoltage; | ||
315 | 335 | ||
316 | if (IS_ERR(host->pbias)) | 336 | if (IS_ERR(host->pbias)) |
317 | return 0; | 337 | return 0; |
318 | 338 | ||
319 | if (power_on) { | 339 | if (power_on) { |
320 | if (vdd <= VDD_165_195) | 340 | uvoltage = (iov <= VDD_165_195) ? VDD_1V8 : VDD_3V0; |
321 | ret = regulator_set_voltage(host->pbias, VDD_1V8, | 341 | ret = regulator_set_voltage(host->pbias, uvoltage, uvoltage); |
322 | VDD_1V8); | 342 | if (ret) { |
323 | else | 343 | dev_err(host->dev, "pbias set voltage failed\n"); |
324 | ret = regulator_set_voltage(host->pbias, VDD_3V0, | ||
325 | VDD_3V0); | ||
326 | if (ret < 0) { | ||
327 | dev_err(host->dev, "pbias set voltage fail\n"); | ||
328 | return ret; | 344 | return ret; |
329 | } | 345 | } |
330 | 346 | ||
@@ -351,13 +367,13 @@ static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on, | |||
351 | } | 367 | } |
352 | 368 | ||
353 | static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on, | 369 | static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on, |
354 | int vdd) | 370 | int iov) |
355 | { | 371 | { |
356 | struct mmc_host *mmc = host->mmc; | 372 | struct mmc_host *mmc = host->mmc; |
357 | int ret = 0; | 373 | int ret = 0; |
358 | 374 | ||
359 | if (mmc_pdata(host)->set_power) | 375 | if (mmc_pdata(host)->set_power) |
360 | return mmc_pdata(host)->set_power(host->dev, power_on, vdd); | 376 | return mmc_pdata(host)->set_power(host->dev, power_on, iov); |
361 | 377 | ||
362 | /* | 378 | /* |
363 | * If we don't see a Vcc regulator, assume it's a fixed | 379 | * If we don't see a Vcc regulator, assume it's a fixed |
@@ -367,7 +383,7 @@ static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on, | |||
367 | return 0; | 383 | return 0; |
368 | 384 | ||
369 | if (mmc_pdata(host)->before_set_reg) | 385 | if (mmc_pdata(host)->before_set_reg) |
370 | mmc_pdata(host)->before_set_reg(host->dev, power_on, vdd); | 386 | mmc_pdata(host)->before_set_reg(host->dev, power_on, iov); |
371 | 387 | ||
372 | ret = omap_hsmmc_set_pbias(host, false, 0); | 388 | ret = omap_hsmmc_set_pbias(host, false, 0); |
373 | if (ret) | 389 | if (ret) |
@@ -387,11 +403,11 @@ static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on, | |||
387 | * chips/cards need an interface voltage rail too. | 403 | * chips/cards need an interface voltage rail too. |
388 | */ | 404 | */ |
389 | if (power_on) { | 405 | if (power_on) { |
390 | ret = omap_hsmmc_enable_supply(mmc); | 406 | ret = omap_hsmmc_enable_supply(mmc, iov); |
391 | if (ret) | 407 | if (ret) |
392 | return ret; | 408 | return ret; |
393 | 409 | ||
394 | ret = omap_hsmmc_set_pbias(host, true, vdd); | 410 | ret = omap_hsmmc_set_pbias(host, true, iov); |
395 | if (ret) | 411 | if (ret) |
396 | goto err_set_voltage; | 412 | goto err_set_voltage; |
397 | } else { | 413 | } else { |
@@ -401,7 +417,7 @@ static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on, | |||
401 | } | 417 | } |
402 | 418 | ||
403 | if (mmc_pdata(host)->after_set_reg) | 419 | if (mmc_pdata(host)->after_set_reg) |
404 | mmc_pdata(host)->after_set_reg(host->dev, power_on, vdd); | 420 | mmc_pdata(host)->after_set_reg(host->dev, power_on, iov); |
405 | 421 | ||
406 | return 0; | 422 | return 0; |
407 | 423 | ||