Skip to content

Commit 5a0054b

Browse files
committed
Merge tag 'mvebu-arm-6.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/gclement/mvebu into soc/arm
mvebu arm for 6.10 (part 1) Decrease the usage of global GPIO numbers for LEDs for Orion5x boards * tag 'mvebu-arm-6.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/gclement/mvebu: ARM: orion5x: Convert TS409 board to GPIO descriptors for LEDs ARM: orion5x: Convert Net2big board to GPIO descriptors for LEDs ARM: orion5x: Convert MV2120 board to GPIO descriptors for LEDs ARM: orion5x: Convert DNS323 board to GPIO descriptors for LEDs ARM: orion5x: Convert D2Net board to GPIO descriptors for LEDs Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]>
2 parents e29d430 + 3153eb8 commit 5a0054b

File tree

5 files changed

+116
-38
lines changed

5 files changed

+116
-38
lines changed

arch/arm/mach-orion5x/board-d2net.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/irq.h>
1515
#include <linux/leds.h>
1616
#include <linux/gpio.h>
17+
#include <linux/gpio/machine.h>
1718
#include <asm/mach-types.h>
1819
#include <asm/mach/arch.h>
1920
#include <asm/mach/pci.h>
@@ -55,12 +56,9 @@ static struct gpio_led d2net_leds[] = {
5556
{
5657
.name = "d2net:blue:sata",
5758
.default_trigger = "default-on",
58-
.gpio = D2NET_GPIO_BLUE_LED_OFF,
59-
.active_low = 1,
6059
},
6160
{
6261
.name = "d2net:red:fail",
63-
.gpio = D2NET_GPIO_RED_LED,
6462
},
6563
};
6664

@@ -77,6 +75,17 @@ static struct platform_device d2net_gpio_leds = {
7775
},
7876
};
7977

78+
static struct gpiod_lookup_table d2net_leds_gpio_table = {
79+
.dev_id = "leds-gpio",
80+
.table = {
81+
GPIO_LOOKUP_IDX("orion_gpio0", D2NET_GPIO_BLUE_LED_OFF, NULL,
82+
0, GPIO_ACTIVE_LOW),
83+
GPIO_LOOKUP_IDX("orion_gpio0", D2NET_GPIO_RED_LED, NULL,
84+
1, GPIO_ACTIVE_HIGH),
85+
{ },
86+
},
87+
};
88+
8089
static void __init d2net_gpio_leds_init(void)
8190
{
8291
int err;
@@ -91,6 +100,7 @@ static void __init d2net_gpio_leds_init(void)
91100
if (err)
92101
pr_err("d2net: failed to configure blue LED blink GPIO\n");
93102

103+
gpiod_add_lookup_table(&d2net_leds_gpio_table);
94104
platform_device_register(&d2net_gpio_leds);
95105
}
96106

arch/arm/mach-orion5x/dns323-setup.c

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*
1515
*/
1616
#include <linux/gpio.h>
17+
#include <linux/gpio/machine.h>
1718
#include <linux/kernel.h>
1819
#include <linux/init.h>
1920
#include <linux/delay.h>
@@ -254,37 +255,64 @@ static int __init dns323_read_mac_addr(void)
254255
static struct gpio_led dns323ab_leds[] = {
255256
{
256257
.name = "power:blue",
257-
.gpio = DNS323_GPIO_LED_POWER2,
258258
.default_trigger = "default-on",
259259
}, {
260260
.name = "right:amber",
261-
.gpio = DNS323_GPIO_LED_RIGHT_AMBER,
262-
.active_low = 1,
263261
}, {
264262
.name = "left:amber",
265-
.gpio = DNS323_GPIO_LED_LEFT_AMBER,
266-
.active_low = 1,
267263
},
268264
};
269265

266+
static struct gpiod_lookup_table dns323a1_leds_gpio_table = {
267+
.dev_id = "leds-gpio",
268+
.table = {
269+
GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_POWER2, NULL,
270+
0, GPIO_ACTIVE_LOW),
271+
GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_RIGHT_AMBER, NULL,
272+
1, GPIO_ACTIVE_LOW),
273+
GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_LEFT_AMBER, NULL,
274+
2, GPIO_ACTIVE_LOW),
275+
{ },
276+
},
277+
};
278+
279+
/* B1 is the same but power LED is active high */
280+
static struct gpiod_lookup_table dns323b1_leds_gpio_table = {
281+
.dev_id = "leds-gpio",
282+
.table = {
283+
GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_POWER2, NULL,
284+
0, GPIO_ACTIVE_HIGH),
285+
GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_RIGHT_AMBER, NULL,
286+
1, GPIO_ACTIVE_LOW),
287+
GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_LEFT_AMBER, NULL,
288+
2, GPIO_ACTIVE_LOW),
289+
{ },
290+
},
291+
};
270292

271293
static struct gpio_led dns323c_leds[] = {
272294
{
273295
.name = "power:blue",
274-
.gpio = DNS323C_GPIO_LED_POWER,
275296
.default_trigger = "timer",
276-
.active_low = 1,
277297
}, {
278298
.name = "right:amber",
279-
.gpio = DNS323C_GPIO_LED_RIGHT_AMBER,
280-
.active_low = 1,
281299
}, {
282300
.name = "left:amber",
283-
.gpio = DNS323C_GPIO_LED_LEFT_AMBER,
284-
.active_low = 1,
285301
},
286302
};
287303

304+
static struct gpiod_lookup_table dns323c_leds_gpio_table = {
305+
.dev_id = "leds-gpio",
306+
.table = {
307+
GPIO_LOOKUP_IDX("orion_gpio0", DNS323C_GPIO_LED_POWER, NULL,
308+
0, GPIO_ACTIVE_LOW),
309+
GPIO_LOOKUP_IDX("orion_gpio0", DNS323C_GPIO_LED_RIGHT_AMBER, NULL,
310+
1, GPIO_ACTIVE_LOW),
311+
GPIO_LOOKUP_IDX("orion_gpio0", DNS323C_GPIO_LED_LEFT_AMBER, NULL,
312+
2, GPIO_ACTIVE_LOW),
313+
{ },
314+
},
315+
};
288316

289317
static struct gpio_led_platform_data dns323ab_led_data = {
290318
.num_leds = ARRAY_SIZE(dns323ab_leds),
@@ -621,16 +649,21 @@ static void __init dns323_init(void)
621649
/* The 5181 power LED is active low and requires
622650
* DNS323_GPIO_LED_POWER1 to also be low.
623651
*/
624-
dns323ab_leds[0].active_low = 1;
625-
gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable");
626-
gpio_direction_output(DNS323_GPIO_LED_POWER1, 0);
627-
fallthrough;
652+
gpiod_add_lookup_table(&dns323a1_leds_gpio_table);
653+
gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable");
654+
gpio_direction_output(DNS323_GPIO_LED_POWER1, 0);
655+
i2c_register_board_info(0, dns323ab_i2c_devices,
656+
ARRAY_SIZE(dns323ab_i2c_devices));
657+
658+
break;
628659
case DNS323_REV_B1:
660+
gpiod_add_lookup_table(&dns323b1_leds_gpio_table);
629661
i2c_register_board_info(0, dns323ab_i2c_devices,
630662
ARRAY_SIZE(dns323ab_i2c_devices));
631663
break;
632664
case DNS323_REV_C1:
633665
/* Hookup LEDs & Buttons */
666+
gpiod_add_lookup_table(&dns323c_leds_gpio_table);
634667
dns323_gpio_leds.dev.platform_data = &dns323c_led_data;
635668
dns323_button_device.dev.platform_data = &dns323c_button_data;
636669

arch/arm/mach-orion5x/mv2120-setup.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* License, or (at your option) any later version.
99
*/
1010
#include <linux/gpio.h>
11+
#include <linux/gpio/machine.h>
1112
#include <linux/kernel.h>
1213
#include <linux/init.h>
1314
#include <linux/platform_device.h>
@@ -139,34 +140,45 @@ static struct i2c_board_info __initdata mv2120_i2c_rtc = {
139140
static struct gpio_led mv2120_led_pins[] = {
140141
{
141142
.name = "mv2120:blue:health",
142-
.gpio = 0,
143143
},
144144
{
145145
.name = "mv2120:red:health",
146-
.gpio = 1,
147146
},
148147
{
149148
.name = "mv2120:led:bright",
150-
.gpio = 4,
151149
.default_trigger = "default-on",
152150
},
153151
{
154152
.name = "mv2120:led:dimmed",
155-
.gpio = 5,
156153
},
157154
{
158155
.name = "mv2120:red:sata0",
159-
.gpio = 8,
160-
.active_low = 1,
161156
},
162157
{
163158
.name = "mv2120:red:sata1",
164-
.gpio = 9,
165-
.active_low = 1,
166159
},
167160

168161
};
169162

163+
static struct gpiod_lookup_table mv2120_leds_gpio_table = {
164+
.dev_id = "leds-gpio",
165+
.table = {
166+
GPIO_LOOKUP_IDX("orion_gpio0", 0, NULL,
167+
0, GPIO_ACTIVE_HIGH),
168+
GPIO_LOOKUP_IDX("orion_gpio0", 1, NULL,
169+
1, GPIO_ACTIVE_HIGH),
170+
GPIO_LOOKUP_IDX("orion_gpio0", 4, NULL,
171+
2, GPIO_ACTIVE_HIGH),
172+
GPIO_LOOKUP_IDX("orion_gpio0", 5, NULL,
173+
3, GPIO_ACTIVE_HIGH),
174+
GPIO_LOOKUP_IDX("orion_gpio0", 8, NULL,
175+
4, GPIO_ACTIVE_LOW),
176+
GPIO_LOOKUP_IDX("orion_gpio0", 9, NULL,
177+
5, GPIO_ACTIVE_LOW),
178+
{ },
179+
},
180+
};
181+
170182
static struct gpio_led_platform_data mv2120_led_data = {
171183
.leds = mv2120_led_pins,
172184
.num_leds = ARRAY_SIZE(mv2120_led_pins),
@@ -219,6 +231,7 @@ static void __init mv2120_init(void)
219231
gpio_free(MV2120_GPIO_RTC_IRQ);
220232
}
221233
i2c_register_board_info(0, &mv2120_i2c_rtc, 1);
234+
gpiod_add_lookup_table(&mv2120_leds_gpio_table);
222235
platform_device_register(&mv2120_leds);
223236

224237
/* register mv2120 specific power-off method */

arch/arm/mach-orion5x/net2big-setup.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/i2c.h>
1919
#include <linux/ata_platform.h>
2020
#include <linux/gpio.h>
21+
#include <linux/gpio/machine.h>
2122
#include <linux/delay.h>
2223
#include <asm/mach-types.h>
2324
#include <asm/mach/arch.h>
@@ -214,19 +215,30 @@ static void __init net2big_sata_power_init(void)
214215
static struct gpio_led net2big_leds[] = {
215216
{
216217
.name = "net2big:red:power",
217-
.gpio = NET2BIG_GPIO_PWR_RED_LED,
218218
},
219219
{
220220
.name = "net2big:blue:power",
221-
.gpio = NET2BIG_GPIO_PWR_BLUE_LED,
222221
},
223222
{
224223
.name = "net2big:red:sata0",
225-
.gpio = NET2BIG_GPIO_SATA0_RED_LED,
226224
},
227225
{
228226
.name = "net2big:red:sata1",
229-
.gpio = NET2BIG_GPIO_SATA1_RED_LED,
227+
},
228+
};
229+
230+
static struct gpiod_lookup_table net2big_leds_gpio_table = {
231+
.dev_id = "leds-gpio",
232+
.table = {
233+
GPIO_LOOKUP_IDX("orion_gpio0", NET2BIG_GPIO_PWR_RED_LED, NULL,
234+
0, GPIO_ACTIVE_HIGH),
235+
GPIO_LOOKUP_IDX("orion_gpio0", NET2BIG_GPIO_PWR_BLUE_LED, NULL,
236+
1, GPIO_ACTIVE_HIGH),
237+
GPIO_LOOKUP_IDX("orion_gpio0", NET2BIG_GPIO_SATA0_RED_LED, NULL,
238+
2, GPIO_ACTIVE_HIGH),
239+
GPIO_LOOKUP_IDX("orion_gpio0", NET2BIG_GPIO_SATA1_RED_LED, NULL,
240+
3, GPIO_ACTIVE_HIGH),
241+
{ },
230242
},
231243
};
232244

@@ -282,6 +294,7 @@ static void __init net2big_gpio_leds_init(void)
282294
if (err)
283295
pr_err("net2big: failed to setup SATA1 blue LED GPIO\n");
284296

297+
gpiod_add_lookup_table(&net2big_leds_gpio_table);
285298
platform_device_register(&net2big_gpio_leds);
286299
}
287300

arch/arm/mach-orion5x/ts409-setup.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Copyright (C) 2008 Martin Michlmayr <[email protected]>
99
*/
1010
#include <linux/gpio.h>
11+
#include <linux/gpio/machine.h>
1112
#include <linux/kernel.h>
1213
#include <linux/init.h>
1314
#include <linux/platform_device.h>
@@ -168,20 +169,27 @@ static struct i2c_board_info __initdata qnap_ts409_i2c_rtc = {
168169
static struct gpio_led ts409_led_pins[] = {
169170
{
170171
.name = "ts409:red:sata1",
171-
.gpio = 4,
172-
.active_low = 1,
173172
}, {
174173
.name = "ts409:red:sata2",
175-
.gpio = 5,
176-
.active_low = 1,
177174
}, {
178175
.name = "ts409:red:sata3",
179-
.gpio = 6,
180-
.active_low = 1,
181176
}, {
182177
.name = "ts409:red:sata4",
183-
.gpio = 7,
184-
.active_low = 1,
178+
},
179+
};
180+
181+
static struct gpiod_lookup_table ts409_leds_gpio_table = {
182+
.dev_id = "leds-gpio",
183+
.table = {
184+
GPIO_LOOKUP_IDX("orion_gpio0", 4, NULL,
185+
0, GPIO_ACTIVE_LOW),
186+
GPIO_LOOKUP_IDX("orion_gpio0", 5, NULL,
187+
1, GPIO_ACTIVE_LOW),
188+
GPIO_LOOKUP_IDX("orion_gpio0", 6, NULL,
189+
2, GPIO_ACTIVE_LOW),
190+
GPIO_LOOKUP_IDX("orion_gpio0", 7, NULL,
191+
3, GPIO_ACTIVE_LOW),
192+
{ },
185193
},
186194
};
187195

@@ -300,6 +308,7 @@ static void __init qnap_ts409_init(void)
300308
if (qnap_ts409_i2c_rtc.irq == 0)
301309
pr_warn("qnap_ts409_init: failed to get RTC IRQ\n");
302310
i2c_register_board_info(0, &qnap_ts409_i2c_rtc, 1);
311+
gpiod_add_lookup_table(&ts409_leds_gpio_table);
303312
platform_device_register(&ts409_leds);
304313

305314
/* register tsx09 specific power-off method */

0 commit comments

Comments
 (0)