diff options
-rw-r--r-- | drivers/mmc/core/host.c | 68 |
1 files changed, 23 insertions, 45 deletions
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index d572b2beb65a..31969436d77c 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c | |||
@@ -310,9 +310,7 @@ int mmc_of_parse(struct mmc_host *host) | |||
310 | { | 310 | { |
311 | struct device_node *np; | 311 | struct device_node *np; |
312 | u32 bus_width; | 312 | u32 bus_width; |
313 | bool explicit_inv_wp, gpio_inv_wp = false; | 313 | int len, ret; |
314 | enum of_gpio_flags flags; | ||
315 | int len, ret, gpio; | ||
316 | 314 | ||
317 | if (!host->parent || !host->parent->of_node) | 315 | if (!host->parent || !host->parent->of_node) |
318 | return 0; | 316 | return 0; |
@@ -360,60 +358,40 @@ int mmc_of_parse(struct mmc_host *host) | |||
360 | if (of_find_property(np, "non-removable", &len)) { | 358 | if (of_find_property(np, "non-removable", &len)) { |
361 | host->caps |= MMC_CAP_NONREMOVABLE; | 359 | host->caps |= MMC_CAP_NONREMOVABLE; |
362 | } else { | 360 | } else { |
363 | bool explicit_inv_cd, gpio_inv_cd = false; | 361 | if (of_property_read_bool(np, "cd-inverted")) |
364 | 362 | host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; | |
365 | explicit_inv_cd = of_property_read_bool(np, "cd-inverted"); | ||
366 | 363 | ||
367 | if (of_find_property(np, "broken-cd", &len)) | 364 | if (of_find_property(np, "broken-cd", &len)) |
368 | host->caps |= MMC_CAP_NEEDS_POLL; | 365 | host->caps |= MMC_CAP_NEEDS_POLL; |
369 | 366 | ||
370 | gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, &flags); | 367 | ret = mmc_gpiod_request_cd(host, "cd", 0, false, 0); |
371 | if (gpio == -EPROBE_DEFER) | 368 | if (ret) { |
372 | return gpio; | 369 | if (ret == -EPROBE_DEFER) |
373 | if (gpio_is_valid(gpio)) { | ||
374 | if (!(flags & OF_GPIO_ACTIVE_LOW)) | ||
375 | gpio_inv_cd = true; | ||
376 | |||
377 | ret = mmc_gpio_request_cd(host, gpio, 0); | ||
378 | if (ret < 0) { | ||
379 | dev_err(host->parent, | ||
380 | "Failed to request CD GPIO #%d: %d!\n", | ||
381 | gpio, ret); | ||
382 | return ret; | 370 | return ret; |
383 | } else { | 371 | if (ret != -ENOENT) { |
384 | dev_info(host->parent, "Got CD GPIO #%d.\n", | 372 | dev_err(host->parent, |
385 | gpio); | 373 | "Failed to request CD GPIO: %d\n", |
374 | ret); | ||
386 | } | 375 | } |
387 | } | 376 | } else |
388 | 377 | dev_info(host->parent, "Got CD GPIO\n"); | |
389 | if (explicit_inv_cd ^ gpio_inv_cd) | ||
390 | host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; | ||
391 | } | 378 | } |
392 | 379 | ||
393 | /* Parse Write Protection */ | 380 | /* Parse Write Protection */ |
394 | explicit_inv_wp = of_property_read_bool(np, "wp-inverted"); | 381 | if (of_property_read_bool(np, "wp-inverted")) |
395 | 382 | host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; | |
396 | gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags); | ||
397 | if (gpio == -EPROBE_DEFER) { | ||
398 | ret = -EPROBE_DEFER; | ||
399 | goto out; | ||
400 | } | ||
401 | if (gpio_is_valid(gpio)) { | ||
402 | if (!(flags & OF_GPIO_ACTIVE_LOW)) | ||
403 | gpio_inv_wp = true; | ||
404 | 383 | ||
405 | ret = mmc_gpio_request_ro(host, gpio); | 384 | ret = mmc_gpiod_request_ro(host, "wp", 0, false, 0); |
406 | if (ret < 0) { | 385 | if (ret) { |
407 | dev_err(host->parent, | 386 | if (ret == -EPROBE_DEFER) |
408 | "Failed to request WP GPIO: %d!\n", ret); | ||
409 | goto out; | 387 | goto out; |
410 | } else { | 388 | if (ret != -ENOENT) { |
411 | dev_info(host->parent, "Got WP GPIO #%d.\n", | 389 | dev_err(host->parent, |
412 | gpio); | 390 | "Failed to request WP GPIO: %d\n", |
391 | ret); | ||
413 | } | 392 | } |
414 | } | 393 | } else |
415 | if (explicit_inv_wp ^ gpio_inv_wp) | 394 | dev_info(host->parent, "Got WP GPIO\n"); |
416 | host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; | ||
417 | 395 | ||
418 | if (of_find_property(np, "cap-sd-highspeed", &len)) | 396 | if (of_find_property(np, "cap-sd-highspeed", &len)) |
419 | host->caps |= MMC_CAP_SD_HIGHSPEED; | 397 | host->caps |= MMC_CAP_SD_HIGHSPEED; |