hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/mmc/host/sdhci-pltfm.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * sdhci-pltfm.c Support for SDHCI platform devices
34 * Copyright (c) 2009 Intel Corporation
....@@ -7,19 +8,6 @@
78 *
89 * Authors: Xiaobo Xie <X.Xie@freescale.com>
910 * Anton Vorontsov <avorontsov@ru.mvista.com>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License version 2 as
13
- * published by the Free Software Foundation.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with this program; if not, write to the Free Software
22
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2311 */
2412
2513 /* Supports:
....@@ -30,6 +18,7 @@
3018
3119 #include <linux/err.h>
3220 #include <linux/module.h>
21
+#include <linux/property.h>
3322 #include <linux/of.h>
3423 #ifdef CONFIG_PPC
3524 #include <asm/machdep.h>
....@@ -51,11 +40,10 @@
5140 .set_uhs_signaling = sdhci_set_uhs_signaling,
5241 };
5342
54
-#ifdef CONFIG_OF
55
-static bool sdhci_of_wp_inverted(struct device_node *np)
43
+static bool sdhci_wp_inverted(struct device *dev)
5644 {
57
- if (of_get_property(np, "sdhci,wp-inverted", NULL) ||
58
- of_get_property(np, "wp-inverted", NULL))
45
+ if (device_property_present(dev, "sdhci,wp-inverted") ||
46
+ device_property_present(dev, "wp-inverted"))
5947 return true;
6048
6149 /* Old device trees don't have the wp-inverted property. */
....@@ -66,29 +54,14 @@
6654 #endif /* CONFIG_PPC */
6755 }
6856
69
-void sdhci_get_of_property(struct platform_device *pdev)
57
+#ifdef CONFIG_OF
58
+static void sdhci_get_compatibility(struct platform_device *pdev)
7059 {
71
- struct device_node *np = pdev->dev.of_node;
7260 struct sdhci_host *host = platform_get_drvdata(pdev);
73
- struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
74
- u32 bus_width;
61
+ struct device_node *np = pdev->dev.of_node;
7562
76
- if (of_get_property(np, "sdhci,auto-cmd12", NULL))
77
- host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
78
-
79
- if (of_get_property(np, "sdhci,1-bit-only", NULL) ||
80
- (of_property_read_u32(np, "bus-width", &bus_width) == 0 &&
81
- bus_width == 1))
82
- host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;
83
-
84
- if (sdhci_of_wp_inverted(np))
85
- host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT;
86
-
87
- if (of_get_property(np, "broken-cd", NULL))
88
- host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
89
-
90
- if (of_get_property(np, "no-1-8-v", NULL))
91
- host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
63
+ if (!np)
64
+ return;
9265
9366 if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc"))
9467 host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
....@@ -98,32 +71,57 @@
9871 of_device_is_compatible(np, "fsl,t4240-esdhc") ||
9972 of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
10073 host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
101
-
102
- of_property_read_u32(np, "clock-frequency", &pltfm_host->clock);
103
-
104
- if (of_find_property(np, "keep-power-in-suspend", NULL))
105
- host->mmc->pm_caps |= MMC_PM_KEEP_POWER;
106
-
107
- if (of_property_read_bool(np, "wakeup-source") ||
108
- of_property_read_bool(np, "enable-sdio-wakeup")) /* legacy */
109
- host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;
11074 }
11175 #else
112
-void sdhci_get_of_property(struct platform_device *pdev) {}
76
+void sdhci_get_compatibility(struct platform_device *pdev) {}
11377 #endif /* CONFIG_OF */
114
-EXPORT_SYMBOL_GPL(sdhci_get_of_property);
78
+
79
+void sdhci_get_property(struct platform_device *pdev)
80
+{
81
+ struct device *dev = &pdev->dev;
82
+ struct sdhci_host *host = platform_get_drvdata(pdev);
83
+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
84
+ u32 bus_width;
85
+
86
+ if (device_property_present(dev, "sdhci,auto-cmd12"))
87
+ host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
88
+
89
+ if (device_property_present(dev, "sdhci,1-bit-only") ||
90
+ (device_property_read_u32(dev, "bus-width", &bus_width) == 0 &&
91
+ bus_width == 1))
92
+ host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;
93
+
94
+ if (sdhci_wp_inverted(dev))
95
+ host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT;
96
+
97
+ if (device_property_present(dev, "broken-cd"))
98
+ host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
99
+
100
+ if (device_property_present(dev, "no-1-8-v"))
101
+ host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
102
+
103
+ sdhci_get_compatibility(pdev);
104
+
105
+ device_property_read_u32(dev, "clock-frequency", &pltfm_host->clock);
106
+
107
+ if (device_property_present(dev, "keep-power-in-suspend"))
108
+ host->mmc->pm_caps |= MMC_PM_KEEP_POWER;
109
+
110
+ if (device_property_read_bool(dev, "wakeup-source") ||
111
+ device_property_read_bool(dev, "enable-sdio-wakeup")) /* legacy */
112
+ host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;
113
+}
114
+EXPORT_SYMBOL_GPL(sdhci_get_property);
115115
116116 struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
117117 const struct sdhci_pltfm_data *pdata,
118118 size_t priv_size)
119119 {
120120 struct sdhci_host *host;
121
- struct resource *iomem;
122121 void __iomem *ioaddr;
123122 int irq, ret;
124123
125
- iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
126
- ioaddr = devm_ioremap_resource(&pdev->dev, iomem);
124
+ ioaddr = devm_platform_ioremap_resource(pdev, 0);
127125 if (IS_ERR(ioaddr)) {
128126 ret = PTR_ERR(ioaddr);
129127 goto err;
....@@ -131,7 +129,6 @@
131129
132130 irq = platform_get_irq(pdev, 0);
133131 if (irq < 0) {
134
- dev_err(&pdev->dev, "failed to get IRQ number\n");
135132 ret = irq;
136133 goto err;
137134 }
....@@ -184,7 +181,7 @@
184181 if (IS_ERR(host))
185182 return PTR_ERR(host);
186183
187
- sdhci_get_of_property(pdev);
184
+ sdhci_get_property(pdev);
188185
189186 ret = sdhci_add_host(host);
190187 if (ret)