diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2015-08-27 05:14:01 -0400 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2015-08-27 08:54:06 -0400 |
commit | ec85c95e8ce5df18608ee9aa6a2626d903f548af (patch) | |
tree | e53cd5173d33858911fd9d190d6a4508e31d4ce9 | |
parent | 2a17f84442e22cd1522400fcc0356c4a36b38361 (diff) |
mmc: host: omap_hsmmc: add separate function to set pbias
No functional change. Cleanup omap_hsmmc_set_power by adding separate
functions to set pbias and invoke it from omap_hsmmc_set_power.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r-- | drivers/mmc/host/omap_hsmmc.c | 78 |
1 files changed, 48 insertions, 30 deletions
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 3fa78d477a41..810d612f58a0 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c | |||
@@ -305,6 +305,48 @@ err_set_ocr: | |||
305 | return ret; | 305 | return ret; |
306 | } | 306 | } |
307 | 307 | ||
308 | static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on, | ||
309 | int vdd) | ||
310 | { | ||
311 | int ret; | ||
312 | |||
313 | if (!host->pbias) | ||
314 | return 0; | ||
315 | |||
316 | if (power_on) { | ||
317 | if (vdd <= VDD_165_195) | ||
318 | ret = regulator_set_voltage(host->pbias, VDD_1V8, | ||
319 | VDD_1V8); | ||
320 | else | ||
321 | ret = regulator_set_voltage(host->pbias, VDD_3V0, | ||
322 | VDD_3V0); | ||
323 | if (ret < 0) { | ||
324 | dev_err(host->dev, "pbias set voltage fail\n"); | ||
325 | return ret; | ||
326 | } | ||
327 | |||
328 | if (host->pbias_enabled == 0) { | ||
329 | ret = regulator_enable(host->pbias); | ||
330 | if (ret) { | ||
331 | dev_err(host->dev, "pbias reg enable fail\n"); | ||
332 | return ret; | ||
333 | } | ||
334 | host->pbias_enabled = 1; | ||
335 | } | ||
336 | } else { | ||
337 | if (host->pbias_enabled == 1) { | ||
338 | ret = regulator_disable(host->pbias); | ||
339 | if (ret) { | ||
340 | dev_err(host->dev, "pbias reg disable fail\n"); | ||
341 | return ret; | ||
342 | } | ||
343 | host->pbias_enabled = 0; | ||
344 | } | ||
345 | } | ||
346 | |||
347 | return 0; | ||
348 | } | ||
349 | |||
308 | static int omap_hsmmc_set_power(struct device *dev, int power_on, int vdd) | 350 | static int omap_hsmmc_set_power(struct device *dev, int power_on, int vdd) |
309 | { | 351 | { |
310 | struct omap_hsmmc_host *host = | 352 | struct omap_hsmmc_host *host = |
@@ -325,16 +367,9 @@ static int omap_hsmmc_set_power(struct device *dev, int power_on, int vdd) | |||
325 | if (mmc_pdata(host)->before_set_reg) | 367 | if (mmc_pdata(host)->before_set_reg) |
326 | mmc_pdata(host)->before_set_reg(dev, power_on, vdd); | 368 | mmc_pdata(host)->before_set_reg(dev, power_on, vdd); |
327 | 369 | ||
328 | if (host->pbias) { | 370 | ret = omap_hsmmc_set_pbias(host, false, 0); |
329 | if (host->pbias_enabled == 1) { | 371 | if (ret) |
330 | ret = regulator_disable(host->pbias); | 372 | return ret; |
331 | if (ret) { | ||
332 | dev_err(dev, "pbias reg disable failed\n"); | ||
333 | return ret; | ||
334 | } | ||
335 | host->pbias_enabled = 0; | ||
336 | } | ||
337 | } | ||
338 | 373 | ||
339 | /* | 374 | /* |
340 | * Assume Vcc regulator is used only to power the card ... OMAP | 375 | * Assume Vcc regulator is used only to power the card ... OMAP |
@@ -359,26 +394,9 @@ static int omap_hsmmc_set_power(struct device *dev, int power_on, int vdd) | |||
359 | return ret; | 394 | return ret; |
360 | } | 395 | } |
361 | 396 | ||
362 | if (host->pbias) { | 397 | ret = omap_hsmmc_set_pbias(host, true, vdd); |
363 | if (vdd <= VDD_165_195) | 398 | if (ret) |
364 | ret = regulator_set_voltage(host->pbias, VDD_1V8, | 399 | goto err_set_voltage; |
365 | VDD_1V8); | ||
366 | else | ||
367 | ret = regulator_set_voltage(host->pbias, VDD_3V0, | ||
368 | VDD_3V0); | ||
369 | if (ret < 0) | ||
370 | goto err_set_voltage; | ||
371 | |||
372 | if (host->pbias_enabled == 0) { | ||
373 | ret = regulator_enable(host->pbias); | ||
374 | if (ret) { | ||
375 | dev_err(dev, "pbias reg enable failed\n"); | ||
376 | goto err_set_voltage; | ||
377 | } else { | ||
378 | host->pbias_enabled = 1; | ||
379 | } | ||
380 | } | ||
381 | } | ||
382 | 400 | ||
383 | if (mmc_pdata(host)->after_set_reg) | 401 | if (mmc_pdata(host)->after_set_reg) |
384 | mmc_pdata(host)->after_set_reg(dev, power_on, vdd); | 402 | mmc_pdata(host)->after_set_reg(dev, power_on, vdd); |