.. | .. |
---|
15 | 15 | |
---|
16 | 16 | #include <linux/clk.h> |
---|
17 | 17 | #include <linux/delay.h> |
---|
18 | | -#include <linux/gpio.h> |
---|
19 | 18 | #include <linux/highmem.h> |
---|
20 | 19 | #include <linux/module.h> |
---|
21 | 20 | #include <linux/interrupt.h> |
---|
22 | 21 | #include <linux/irq.h> |
---|
23 | 22 | #include <linux/of.h> |
---|
24 | | -#include <linux/of_gpio.h> |
---|
25 | 23 | #include <linux/platform_device.h> |
---|
26 | 24 | #include <linux/pm.h> |
---|
27 | 25 | #include <linux/slab.h> |
---|
.. | .. |
---|
32 | 30 | |
---|
33 | 31 | struct spear_sdhci { |
---|
34 | 32 | struct clk *clk; |
---|
35 | | - int card_int_gpio; |
---|
36 | 33 | }; |
---|
37 | 34 | |
---|
38 | 35 | /* sdhci ops */ |
---|
.. | .. |
---|
43 | 40 | .set_uhs_signaling = sdhci_set_uhs_signaling, |
---|
44 | 41 | }; |
---|
45 | 42 | |
---|
46 | | -static void sdhci_probe_config_dt(struct device_node *np, |
---|
47 | | - struct spear_sdhci *host) |
---|
48 | | -{ |
---|
49 | | - int cd_gpio; |
---|
50 | | - |
---|
51 | | - cd_gpio = of_get_named_gpio(np, "cd-gpios", 0); |
---|
52 | | - if (!gpio_is_valid(cd_gpio)) |
---|
53 | | - cd_gpio = -1; |
---|
54 | | - |
---|
55 | | - host->card_int_gpio = cd_gpio; |
---|
56 | | -} |
---|
57 | | - |
---|
58 | 43 | static int sdhci_probe(struct platform_device *pdev) |
---|
59 | 44 | { |
---|
60 | 45 | struct sdhci_host *host; |
---|
61 | | - struct resource *iomem; |
---|
62 | 46 | struct spear_sdhci *sdhci; |
---|
63 | 47 | struct device *dev; |
---|
64 | 48 | int ret; |
---|
.. | .. |
---|
71 | 55 | goto err; |
---|
72 | 56 | } |
---|
73 | 57 | |
---|
74 | | - iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
75 | | - host->ioaddr = devm_ioremap_resource(&pdev->dev, iomem); |
---|
| 58 | + host->ioaddr = devm_platform_ioremap_resource(pdev, 0); |
---|
76 | 59 | if (IS_ERR(host->ioaddr)) { |
---|
77 | 60 | ret = PTR_ERR(host->ioaddr); |
---|
78 | 61 | dev_dbg(&pdev->dev, "unable to map iomem: %d\n", ret); |
---|
.. | .. |
---|
109 | 92 | dev_dbg(&pdev->dev, "Error setting desired clk, clk=%lu\n", |
---|
110 | 93 | clk_get_rate(sdhci->clk)); |
---|
111 | 94 | |
---|
112 | | - sdhci_probe_config_dt(pdev->dev.of_node, sdhci); |
---|
113 | 95 | /* |
---|
114 | | - * It is optional to use GPIOs for sdhci card detection. If |
---|
115 | | - * sdhci->card_int_gpio < 0, then use original sdhci lines otherwise |
---|
116 | | - * GPIO lines. We use the built-in GPIO support for this. |
---|
| 96 | + * It is optional to use GPIOs for sdhci card detection. If we |
---|
| 97 | + * find a descriptor using slot GPIO, we use it. |
---|
117 | 98 | */ |
---|
118 | | - if (sdhci->card_int_gpio >= 0) { |
---|
119 | | - ret = mmc_gpio_request_cd(host->mmc, sdhci->card_int_gpio, 0); |
---|
120 | | - if (ret < 0) { |
---|
121 | | - dev_dbg(&pdev->dev, |
---|
122 | | - "failed to request card-detect gpio%d\n", |
---|
123 | | - sdhci->card_int_gpio); |
---|
124 | | - goto disable_clk; |
---|
125 | | - } |
---|
126 | | - } |
---|
| 99 | + ret = mmc_gpiod_request_cd(host->mmc, "cd", 0, false, 0); |
---|
| 100 | + if (ret == -EPROBE_DEFER) |
---|
| 101 | + goto disable_clk; |
---|
127 | 102 | |
---|
128 | 103 | ret = sdhci_add_host(host); |
---|
129 | 104 | if (ret) |
---|