hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/mfd/dm355evm_msp.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * dm355evm_msp.c - driver for MSP430 firmware on DM355EVM board
34 *
45 * Copyright (C) 2008 David Brownell
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
106 */
117
128 #include <linux/init.h>
....@@ -16,6 +12,7 @@
1612 #include <linux/module.h>
1713 #include <linux/err.h>
1814 #include <linux/gpio.h>
15
+#include <linux/gpio/machine.h>
1916 #include <linux/leds.h>
2017 #include <linux/i2c.h>
2118 #include <linux/mfd/dm355evm_msp.h>
....@@ -118,6 +115,54 @@
118115 */
119116 MSP_GPIO(2, SDMMC), MSP_GPIO(1, SDMMC), /* mmc0 WP, nCD */
120117 MSP_GPIO(4, SDMMC), MSP_GPIO(3, SDMMC), /* mmc1 WP, nCD */
118
+};
119
+
120
+static struct gpio_led evm_leds[] = {
121
+ { .name = "dm355evm::ds14",
122
+ .default_trigger = "heartbeat", },
123
+ { .name = "dm355evm::ds15",
124
+ .default_trigger = "mmc0", },
125
+ { .name = "dm355evm::ds16",
126
+ /* could also be a CE-ATA drive */
127
+ .default_trigger = "mmc1", },
128
+ { .name = "dm355evm::ds17",
129
+ .default_trigger = "nand-disk", },
130
+ { .name = "dm355evm::ds18", },
131
+ { .name = "dm355evm::ds19", },
132
+ { .name = "dm355evm::ds20", },
133
+ { .name = "dm355evm::ds21", },
134
+};
135
+
136
+static struct gpio_led_platform_data evm_led_data = {
137
+ .num_leds = ARRAY_SIZE(evm_leds),
138
+ .leds = evm_leds,
139
+};
140
+
141
+static struct gpiod_lookup_table evm_leds_gpio_table = {
142
+ .dev_id = "leds-gpio",
143
+ .table = {
144
+ /*
145
+ * These GPIOs are on the dm355evm_msp
146
+ * GPIO chip at index 0..7
147
+ */
148
+ GPIO_LOOKUP_IDX("dm355evm_msp", 0, NULL,
149
+ 0, GPIO_ACTIVE_LOW),
150
+ GPIO_LOOKUP_IDX("dm355evm_msp", 1, NULL,
151
+ 1, GPIO_ACTIVE_LOW),
152
+ GPIO_LOOKUP_IDX("dm355evm_msp", 2, NULL,
153
+ 2, GPIO_ACTIVE_LOW),
154
+ GPIO_LOOKUP_IDX("dm355evm_msp", 3, NULL,
155
+ 3, GPIO_ACTIVE_LOW),
156
+ GPIO_LOOKUP_IDX("dm355evm_msp", 4, NULL,
157
+ 4, GPIO_ACTIVE_LOW),
158
+ GPIO_LOOKUP_IDX("dm355evm_msp", 5, NULL,
159
+ 5, GPIO_ACTIVE_LOW),
160
+ GPIO_LOOKUP_IDX("dm355evm_msp", 6, NULL,
161
+ 6, GPIO_ACTIVE_LOW),
162
+ GPIO_LOOKUP_IDX("dm355evm_msp", 7, NULL,
163
+ 7, GPIO_ACTIVE_LOW),
164
+ { },
165
+ },
121166 };
122167
123168 #define MSP_GPIO_REG(offset) (msp_gpios[(offset)] >> 3)
....@@ -264,32 +309,7 @@
264309
265310 /* LED output */
266311 if (msp_has_leds()) {
267
-#define GPIO_LED(l) .name = l, .active_low = true
268
- static struct gpio_led evm_leds[] = {
269
- { GPIO_LED("dm355evm::ds14"),
270
- .default_trigger = "heartbeat", },
271
- { GPIO_LED("dm355evm::ds15"),
272
- .default_trigger = "mmc0", },
273
- { GPIO_LED("dm355evm::ds16"),
274
- /* could also be a CE-ATA drive */
275
- .default_trigger = "mmc1", },
276
- { GPIO_LED("dm355evm::ds17"),
277
- .default_trigger = "nand-disk", },
278
- { GPIO_LED("dm355evm::ds18"), },
279
- { GPIO_LED("dm355evm::ds19"), },
280
- { GPIO_LED("dm355evm::ds20"), },
281
- { GPIO_LED("dm355evm::ds21"), },
282
- };
283
-#undef GPIO_LED
284
-
285
- struct gpio_led_platform_data evm_led_data = {
286
- .num_leds = ARRAY_SIZE(evm_leds),
287
- .leds = evm_leds,
288
- };
289
-
290
- for (i = 0; i < ARRAY_SIZE(evm_leds); i++)
291
- evm_leds[i].gpio = i + dm355evm_msp_gpio.base;
292
-
312
+ gpiod_add_lookup_table(&evm_leds_gpio_table);
293313 /* NOTE: these are the only fully programmable LEDs
294314 * on the board, since GPIO-61/ds22 (and many signals
295315 * going to DC7) must be used for AEMIF address lines