Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: mxs: use mmc_of_parse to parse devicetree properties

Use generic helper function. This also adds support for the cd-gpios and
max-frequency devicetree properties.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Chris Ball <cjb@laptop.org>

authored by

Sascha Hauer and committed by
Chris Ball
d1a1dfb2 abd37ccc

+11 -26
+11 -26
drivers/mmc/host/mxs-mmc.c
··· 76 76 { 77 77 struct mxs_mmc_host *host = mmc_priv(mmc); 78 78 struct mxs_ssp *ssp = &host->ssp; 79 - int present; 79 + int present, ret; 80 + 81 + ret = mmc_gpio_get_cd(mmc); 82 + if (ret >= 0) 83 + return ret; 80 84 81 85 present = !(readl(ssp->base + HW_SSP_STATUS(ssp)) & 82 86 BM_SSP_STATUS_CARD_DETECT); ··· 568 564 { 569 565 const struct of_device_id *of_id = 570 566 of_match_device(mxs_mmc_dt_ids, &pdev->dev); 571 - struct device_node *np = pdev->dev.of_node; 572 567 struct mxs_mmc_host *host; 573 568 struct mmc_host *mmc; 574 569 struct resource *iores; 575 - int ret = 0, irq_err, gpio; 570 + int ret = 0, irq_err; 576 571 struct regulator *reg_vmmc; 577 - enum of_gpio_flags flags; 578 572 struct mxs_ssp *ssp; 579 - u32 bus_width = 0; 580 573 581 574 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); 582 575 irq_err = platform_get_irq(pdev, 0); ··· 634 633 mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED | 635 634 MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL; 636 635 637 - of_property_read_u32(np, "bus-width", &bus_width); 638 - if (bus_width == 4) 639 - mmc->caps |= MMC_CAP_4_BIT_DATA; 640 - else if (bus_width == 8) 641 - mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; 642 - if (of_property_read_bool(np, "broken-cd")) 643 - mmc->caps |= MMC_CAP_NEEDS_POLL; 644 - if (of_property_read_bool(np, "non-removable")) 645 - mmc->caps |= MMC_CAP_NONREMOVABLE; 646 - gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags); 647 - if (gpio_is_valid(gpio)) { 648 - ret = mmc_gpio_request_ro(mmc, gpio); 649 - if (ret) 650 - goto out_clk_disable; 651 - if (!(flags & OF_GPIO_ACTIVE_LOW)) 652 - mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; 653 - } 654 - 655 - if (of_property_read_bool(np, "cd-inverted")) 656 - mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; 657 - 658 636 mmc->f_min = 400000; 659 637 mmc->f_max = 288000000; 638 + 639 + ret = mmc_of_parse(mmc); 640 + if (ret) 641 + goto out_clk_disable; 642 + 660 643 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; 661 644 662 645 mmc->max_segs = 52;