Skip to content

Commit f7f611f

Browse files
linuswkrzk
authored andcommitted
ARM: s3c24xx: leds: Convert to use GPIO descriptors
This converts the s3c24xx LED driver to use GPIO descriptors and also modify all board files to account for these changes by registering the appropriate GPIO tables for each board. The driver was using a custom flag to indicate open drain (tristate) but this can be handled by standard descriptor machine tables. The driver was setting non-pull-up for the pin using the custom S3C24xx GPIO API, but this is a custom pin control system used by the S3C24xx and no generic GPIO function, so this has simply been pushed back into the respective board files. Signed-off-by: Linus Walleij <[email protected]> Acked-by: Jacek Anaszewski <[email protected]> Signed-off-by: Krzysztof Kozlowski <[email protected]>
1 parent ea9dd8f commit f7f611f

File tree

7 files changed

+199
-77
lines changed

7 files changed

+199
-77
lines changed

arch/arm/mach-s3c24xx/common-smdk.c

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/timer.h>
1515
#include <linux/init.h>
1616
#include <linux/gpio.h>
17+
#include <linux/gpio/machine.h>
1718
#include <linux/device.h>
1819
#include <linux/platform_device.h>
1920

@@ -44,29 +45,53 @@
4445

4546
/* LED devices */
4647

48+
static struct gpiod_lookup_table smdk_led4_gpio_table = {
49+
.dev_id = "s3c24xx_led.0",
50+
.table = {
51+
GPIO_LOOKUP("GPF", 4, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
52+
{ },
53+
},
54+
};
55+
56+
static struct gpiod_lookup_table smdk_led5_gpio_table = {
57+
.dev_id = "s3c24xx_led.1",
58+
.table = {
59+
GPIO_LOOKUP("GPF", 5, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
60+
{ },
61+
},
62+
};
63+
64+
static struct gpiod_lookup_table smdk_led6_gpio_table = {
65+
.dev_id = "s3c24xx_led.2",
66+
.table = {
67+
GPIO_LOOKUP("GPF", 6, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
68+
{ },
69+
},
70+
};
71+
72+
static struct gpiod_lookup_table smdk_led7_gpio_table = {
73+
.dev_id = "s3c24xx_led.3",
74+
.table = {
75+
GPIO_LOOKUP("GPF", 7, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
76+
{ },
77+
},
78+
};
79+
4780
static struct s3c24xx_led_platdata smdk_pdata_led4 = {
48-
.gpio = S3C2410_GPF(4),
49-
.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
5081
.name = "led4",
5182
.def_trigger = "timer",
5283
};
5384

5485
static struct s3c24xx_led_platdata smdk_pdata_led5 = {
55-
.gpio = S3C2410_GPF(5),
56-
.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
5786
.name = "led5",
5887
.def_trigger = "nand-disk",
5988
};
6089

6190
static struct s3c24xx_led_platdata smdk_pdata_led6 = {
62-
.gpio = S3C2410_GPF(6),
63-
.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
6491
.name = "led6",
6592
};
6693

6794
static struct s3c24xx_led_platdata smdk_pdata_led7 = {
68-
.gpio = S3C2410_GPF(7),
69-
.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
7095
.name = "led7",
7196
};
7297

@@ -179,27 +204,25 @@ static struct platform_device __initdata *smdk_devs[] = {
179204
&smdk_led7,
180205
};
181206

182-
static const struct gpio smdk_led_gpios[] = {
183-
{ S3C2410_GPF(4), GPIOF_OUT_INIT_HIGH, NULL },
184-
{ S3C2410_GPF(5), GPIOF_OUT_INIT_HIGH, NULL },
185-
{ S3C2410_GPF(6), GPIOF_OUT_INIT_HIGH, NULL },
186-
{ S3C2410_GPF(7), GPIOF_OUT_INIT_HIGH, NULL },
187-
};
188-
189207
void __init smdk_machine_init(void)
190208
{
191-
/* Configure the LEDs (even if we have no LED support)*/
192-
193-
int ret = gpio_request_array(smdk_led_gpios,
194-
ARRAY_SIZE(smdk_led_gpios));
195-
if (!WARN_ON(ret < 0))
196-
gpio_free_array(smdk_led_gpios, ARRAY_SIZE(smdk_led_gpios));
197-
198209
if (machine_is_smdk2443())
199210
smdk_nand_info.twrph0 = 50;
200211

201212
s3c_nand_set_platdata(&smdk_nand_info);
202213

214+
/* Disable pull-up on the LED lines */
215+
s3c_gpio_setpull(S3C2410_GPF(4), S3C_GPIO_PULL_NONE);
216+
s3c_gpio_setpull(S3C2410_GPF(5), S3C_GPIO_PULL_NONE);
217+
s3c_gpio_setpull(S3C2410_GPF(6), S3C_GPIO_PULL_NONE);
218+
s3c_gpio_setpull(S3C2410_GPF(7), S3C_GPIO_PULL_NONE);
219+
220+
/* Add lookups for the lines */
221+
gpiod_add_lookup_table(&smdk_led4_gpio_table);
222+
gpiod_add_lookup_table(&smdk_led5_gpio_table);
223+
gpiod_add_lookup_table(&smdk_led6_gpio_table);
224+
gpiod_add_lookup_table(&smdk_led7_gpio_table);
225+
203226
platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));
204227

205228
s3c_pm_init();

arch/arm/mach-s3c24xx/mach-mini2440.c

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,37 +402,68 @@ static struct platform_device mini2440_button_device = {
402402

403403
/* LEDS */
404404

405+
static struct gpiod_lookup_table mini2440_led1_gpio_table = {
406+
.dev_id = "s3c24xx_led.1",
407+
.table = {
408+
GPIO_LOOKUP("GPB", 5, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
409+
{ },
410+
},
411+
};
412+
413+
static struct gpiod_lookup_table mini2440_led2_gpio_table = {
414+
.dev_id = "s3c24xx_led.2",
415+
.table = {
416+
GPIO_LOOKUP("GPB", 6, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
417+
{ },
418+
},
419+
};
420+
421+
static struct gpiod_lookup_table mini2440_led3_gpio_table = {
422+
.dev_id = "s3c24xx_led.3",
423+
.table = {
424+
GPIO_LOOKUP("GPB", 7, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
425+
{ },
426+
},
427+
};
428+
429+
static struct gpiod_lookup_table mini2440_led4_gpio_table = {
430+
.dev_id = "s3c24xx_led.4",
431+
.table = {
432+
GPIO_LOOKUP("GPB", 8, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
433+
{ },
434+
},
435+
};
436+
437+
static struct gpiod_lookup_table mini2440_backlight_gpio_table = {
438+
.dev_id = "s3c24xx_led.5",
439+
.table = {
440+
GPIO_LOOKUP("GPG", 4, NULL, GPIO_ACTIVE_HIGH),
441+
{ },
442+
},
443+
};
444+
405445
static struct s3c24xx_led_platdata mini2440_led1_pdata = {
406446
.name = "led1",
407-
.gpio = S3C2410_GPB(5),
408-
.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
409447
.def_trigger = "heartbeat",
410448
};
411449

412450
static struct s3c24xx_led_platdata mini2440_led2_pdata = {
413451
.name = "led2",
414-
.gpio = S3C2410_GPB(6),
415-
.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
416452
.def_trigger = "nand-disk",
417453
};
418454

419455
static struct s3c24xx_led_platdata mini2440_led3_pdata = {
420456
.name = "led3",
421-
.gpio = S3C2410_GPB(7),
422-
.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
423457
.def_trigger = "mmc0",
424458
};
425459

426460
static struct s3c24xx_led_platdata mini2440_led4_pdata = {
427461
.name = "led4",
428-
.gpio = S3C2410_GPB(8),
429-
.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
430462
.def_trigger = "",
431463
};
432464

433465
static struct s3c24xx_led_platdata mini2440_led_backlight_pdata = {
434466
.name = "backlight",
435-
.gpio = S3C2410_GPG(4),
436467
.def_trigger = "backlight",
437468
};
438469

@@ -714,6 +745,20 @@ static void __init mini2440_init(void)
714745
i2c_register_board_info(0, mini2440_i2c_devs,
715746
ARRAY_SIZE(mini2440_i2c_devs));
716747

748+
/* Disable pull-up on the LED lines */
749+
s3c_gpio_setpull(S3C2410_GPB(5), S3C_GPIO_PULL_NONE);
750+
s3c_gpio_setpull(S3C2410_GPB(6), S3C_GPIO_PULL_NONE);
751+
s3c_gpio_setpull(S3C2410_GPB(7), S3C_GPIO_PULL_NONE);
752+
s3c_gpio_setpull(S3C2410_GPB(8), S3C_GPIO_PULL_NONE);
753+
s3c_gpio_setpull(S3C2410_GPG(4), S3C_GPIO_PULL_NONE);
754+
755+
/* Add lookups for the lines */
756+
gpiod_add_lookup_table(&mini2440_led1_gpio_table);
757+
gpiod_add_lookup_table(&mini2440_led2_gpio_table);
758+
gpiod_add_lookup_table(&mini2440_led3_gpio_table);
759+
gpiod_add_lookup_table(&mini2440_led4_gpio_table);
760+
gpiod_add_lookup_table(&mini2440_backlight_gpio_table);
761+
717762
platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices));
718763

719764
if (features.count) /* the optional features */

arch/arm/mach-s3c24xx/mach-n30.c

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
#include <plat/cpu.h>
4747
#include <plat/devs.h>
48+
#include <plat/gpio-cfg.h>
4849
#include <linux/platform_data/mmc-s3cmci.h>
4950
#include <linux/platform_data/usb-s3c2410_udc.h>
5051
#include <plat/samsung-time.h>
@@ -246,35 +247,64 @@ static struct platform_device n35_button_device = {
246247
};
247248

248249
/* This is the bluetooth LED on the device. */
250+
251+
static struct gpiod_lookup_table n30_blue_led_gpio_table = {
252+
.dev_id = "s3c24xx_led.1",
253+
.table = {
254+
GPIO_LOOKUP("GPG", 6, NULL, GPIO_ACTIVE_HIGH),
255+
{ },
256+
},
257+
};
258+
249259
static struct s3c24xx_led_platdata n30_blue_led_pdata = {
250260
.name = "blue_led",
251-
.gpio = S3C2410_GPG(6),
252261
.def_trigger = "",
253262
};
254263

255264
/* This is the blue LED on the device. Originally used to indicate GPS activity
256265
* by flashing. */
266+
267+
static struct gpiod_lookup_table n35_blue_led_gpio_table = {
268+
.dev_id = "s3c24xx_led.1",
269+
.table = {
270+
GPIO_LOOKUP("GPD", 8, NULL, GPIO_ACTIVE_HIGH),
271+
{ },
272+
},
273+
};
274+
257275
static struct s3c24xx_led_platdata n35_blue_led_pdata = {
258276
.name = "blue_led",
259-
.gpio = S3C2410_GPD(8),
260277
.def_trigger = "",
261278
};
262279

263280
/* This LED is driven by the battery microcontroller, and is blinking
264281
* red, blinking green or solid green when the battery is low,
265282
* charging or full respectively. By driving GPD9 low, it's possible
266283
* to force the LED to blink red, so call that warning LED. */
284+
285+
static struct gpiod_lookup_table n30_warning_led_gpio_table = {
286+
.dev_id = "s3c24xx_led.2",
287+
.table = {
288+
GPIO_LOOKUP("GPD", 9, NULL, GPIO_ACTIVE_LOW),
289+
{ },
290+
},
291+
};
292+
267293
static struct s3c24xx_led_platdata n30_warning_led_pdata = {
268294
.name = "warning_led",
269-
.flags = S3C24XX_LEDF_ACTLOW,
270-
.gpio = S3C2410_GPD(9),
271295
.def_trigger = "",
272296
};
273297

298+
static struct gpiod_lookup_table n35_warning_led_gpio_table = {
299+
.dev_id = "s3c24xx_led.2",
300+
.table = {
301+
GPIO_LOOKUP("GPD", 9, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
302+
{ },
303+
},
304+
};
305+
274306
static struct s3c24xx_led_platdata n35_warning_led_pdata = {
275307
.name = "warning_led",
276-
.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
277-
.gpio = S3C2410_GPD(9),
278308
.def_trigger = "",
279309
};
280310

@@ -577,6 +607,12 @@ static void __init n30_init(void)
577607
S3C2410_MISCCR_USBSUSPND0 |
578608
S3C2410_MISCCR_USBSUSPND1, 0x0);
579609

610+
/* Disable pull-up and add GPIO tables */
611+
s3c_gpio_setpull(S3C2410_GPG(6), S3C_GPIO_PULL_NONE);
612+
s3c_gpio_setpull(S3C2410_GPD(9), S3C_GPIO_PULL_NONE);
613+
gpiod_add_lookup_table(&n30_blue_led_gpio_table);
614+
gpiod_add_lookup_table(&n30_warning_led_gpio_table);
615+
580616
platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));
581617
}
582618

@@ -594,6 +630,12 @@ static void __init n30_init(void)
594630
S3C2410_MISCCR_USBSUSPND1,
595631
S3C2410_MISCCR_USBSUSPND0);
596632

633+
/* Disable pull-up and add GPIO tables */
634+
s3c_gpio_setpull(S3C2410_GPD(8), S3C_GPIO_PULL_NONE);
635+
s3c_gpio_setpull(S3C2410_GPD(9), S3C_GPIO_PULL_NONE);
636+
gpiod_add_lookup_table(&n35_blue_led_gpio_table);
637+
gpiod_add_lookup_table(&n35_warning_led_gpio_table);
638+
597639
platform_add_devices(n35_devices, ARRAY_SIZE(n35_devices));
598640
}
599641
}

arch/arm/mach-s3c24xx/mach-qt2410.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,15 @@ static struct platform_device qt2410_cs89x0 = {
177177

178178
/* LED */
179179

180+
static struct gpiod_lookup_table qt2410_led_gpio_table = {
181+
.dev_id = "s3c24xx_led.0",
182+
.table = {
183+
GPIO_LOOKUP("GPB", 0, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
184+
{ },
185+
},
186+
};
187+
180188
static struct s3c24xx_led_platdata qt2410_pdata_led = {
181-
.gpio = S3C2410_GPB(0),
182-
.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
183189
.name = "led",
184190
.def_trigger = "timer",
185191
};
@@ -338,6 +344,8 @@ static void __init qt2410_machine_init(void)
338344
s3c_i2c0_set_platdata(NULL);
339345

340346
gpiod_add_lookup_table(&qt2410_spi_gpiod_table);
347+
s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
348+
gpiod_add_lookup_table(&qt2410_led_gpio_table);
341349
platform_add_devices(qt2410_devices, ARRAY_SIZE(qt2410_devices));
342350
s3c_pm_init();
343351
}

0 commit comments

Comments
 (0)