hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/mmc/host/of_mmc_spi.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * OpenFirmware bindings for the MMC-over-SPI driver
34 *
45 * Copyright (c) MontaVista Software, Inc. 2008.
56 *
67 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License as published by the
10
- * Free Software Foundation; either version 2 of the License, or (at your
11
- * option) any later version.
128 */
139
1410 #include <linux/kernel.h>
....@@ -16,9 +12,7 @@
1612 #include <linux/device.h>
1713 #include <linux/slab.h>
1814 #include <linux/irq.h>
19
-#include <linux/gpio.h>
2015 #include <linux/of.h>
21
-#include <linux/of_gpio.h>
2216 #include <linux/of_irq.h>
2317 #include <linux/spi/spi.h>
2418 #include <linux/spi/mmc_spi.h>
....@@ -32,15 +26,7 @@
3226
3327 MODULE_LICENSE("GPL");
3428
35
-enum {
36
- CD_GPIO = 0,
37
- WP_GPIO,
38
- NUM_GPIOS,
39
-};
40
-
4129 struct of_mmc_spi {
42
- int gpios[NUM_GPIOS];
43
- bool alow_gpios[NUM_GPIOS];
4430 int detect_irq;
4531 struct mmc_spi_platform_data pdata;
4632 };
....@@ -71,9 +57,6 @@
7157 struct device *dev = &spi->dev;
7258 struct device_node *np = dev->of_node;
7359 struct of_mmc_spi *oms;
74
- const __be32 *voltage_ranges;
75
- int num_ranges;
76
- int i;
7760
7861 if (dev->platform_data || !np)
7962 return dev->platform_data;
....@@ -82,49 +65,8 @@
8265 if (!oms)
8366 return NULL;
8467
85
- voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges);
86
- num_ranges = num_ranges / sizeof(*voltage_ranges) / 2;
87
- if (!voltage_ranges || !num_ranges) {
88
- dev_err(dev, "OF: voltage-ranges unspecified\n");
68
+ if (mmc_of_parse_voltage(np, &oms->pdata.ocr_mask) <= 0)
8969 goto err_ocr;
90
- }
91
-
92
- for (i = 0; i < num_ranges; i++) {
93
- const int j = i * 2;
94
- u32 mask;
95
-
96
- mask = mmc_vddrange_to_ocrmask(be32_to_cpu(voltage_ranges[j]),
97
- be32_to_cpu(voltage_ranges[j + 1]));
98
- if (!mask) {
99
- dev_err(dev, "OF: voltage-range #%d is invalid\n", i);
100
- goto err_ocr;
101
- }
102
- oms->pdata.ocr_mask |= mask;
103
- }
104
-
105
- for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) {
106
- enum of_gpio_flags gpio_flags;
107
-
108
- oms->gpios[i] = of_get_gpio_flags(np, i, &gpio_flags);
109
- if (!gpio_is_valid(oms->gpios[i]))
110
- continue;
111
-
112
- if (gpio_flags & OF_GPIO_ACTIVE_LOW)
113
- oms->alow_gpios[i] = true;
114
- }
115
-
116
- if (gpio_is_valid(oms->gpios[CD_GPIO])) {
117
- oms->pdata.cd_gpio = oms->gpios[CD_GPIO];
118
- oms->pdata.flags |= MMC_SPI_USE_CD_GPIO;
119
- if (!oms->alow_gpios[CD_GPIO])
120
- oms->pdata.caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
121
- }
122
- if (gpio_is_valid(oms->gpios[WP_GPIO])) {
123
- oms->pdata.ro_gpio = oms->gpios[WP_GPIO];
124
- oms->pdata.flags |= MMC_SPI_USE_RO_GPIO;
125
- if (!oms->alow_gpios[WP_GPIO])
126
- oms->pdata.caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
127
- }
12870
12971 oms->detect_irq = irq_of_parse_and_map(np, 0);
13072 if (oms->detect_irq != 0) {