Skip to content

Commit 6b0d685

Browse files
Xing Tong Wulag-linaro
authored andcommitted
leds: simatic-ipc-leds-gpio: Add support for module BX-59A
This is used for the Siemens Simatic IPC BX-59A, which has its LEDs connected to GPIOs provided by the Nuvoton NCT6126D. Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Xing Tong Wu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 016cfc4 commit 6b0d685

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed

drivers/leds/simple/simatic-ipc-leds-gpio-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ int simatic_ipc_leds_gpio_probe(struct platform_device *pdev,
5656
case SIMATIC_IPC_DEVICE_127E:
5757
case SIMATIC_IPC_DEVICE_227G:
5858
case SIMATIC_IPC_DEVICE_BX_21A:
59+
case SIMATIC_IPC_DEVICE_BX_59A:
5960
break;
6061
default:
6162
return -ENODEV;

drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717

1818
#include "simatic-ipc-leds-gpio.h"
1919

20-
static struct gpiod_lookup_table simatic_ipc_led_gpio_table = {
20+
struct simatic_ipc_led_tables {
21+
struct gpiod_lookup_table *led_lookup_table;
22+
struct gpiod_lookup_table *led_lookup_table_extra;
23+
};
24+
25+
static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g = {
2126
.dev_id = "leds-gpio",
2227
.table = {
2328
GPIO_LOOKUP_IDX("gpio-f7188x-2", 0, NULL, 0, GPIO_ACTIVE_LOW),
@@ -30,7 +35,7 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table = {
3035
},
3136
};
3237

33-
static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra = {
38+
static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra_227g = {
3439
.dev_id = NULL, /* Filled during initialization */
3540
.table = {
3641
GPIO_LOOKUP_IDX("gpio-f7188x-3", 6, NULL, 6, GPIO_ACTIVE_HIGH),
@@ -39,16 +44,51 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra = {
3944
},
4045
};
4146

47+
static struct gpiod_lookup_table simatic_ipc_led_gpio_table_bx_59a = {
48+
.dev_id = "leds-gpio",
49+
.table = {
50+
GPIO_LOOKUP_IDX("gpio-f7188x-2", 0, NULL, 0, GPIO_ACTIVE_LOW),
51+
GPIO_LOOKUP_IDX("gpio-f7188x-2", 3, NULL, 1, GPIO_ACTIVE_LOW),
52+
GPIO_LOOKUP_IDX("gpio-f7188x-5", 3, NULL, 2, GPIO_ACTIVE_LOW),
53+
GPIO_LOOKUP_IDX("gpio-f7188x-5", 2, NULL, 3, GPIO_ACTIVE_LOW),
54+
GPIO_LOOKUP_IDX("gpio-f7188x-7", 7, NULL, 4, GPIO_ACTIVE_LOW),
55+
GPIO_LOOKUP_IDX("gpio-f7188x-7", 4, NULL, 5, GPIO_ACTIVE_LOW),
56+
{} /* Terminating entry */
57+
}
58+
};
59+
4260
static int simatic_ipc_leds_gpio_f7188x_probe(struct platform_device *pdev)
4361
{
44-
return simatic_ipc_leds_gpio_probe(pdev, &simatic_ipc_led_gpio_table,
45-
&simatic_ipc_led_gpio_table_extra);
62+
const struct simatic_ipc_platform *plat = dev_get_platdata(&pdev->dev);
63+
struct simatic_ipc_led_tables *led_tables;
64+
65+
led_tables = devm_kzalloc(&pdev->dev, sizeof(*led_tables), GFP_KERNEL);
66+
if (!led_tables)
67+
return -ENOMEM;
68+
69+
switch (plat->devmode) {
70+
case SIMATIC_IPC_DEVICE_227G:
71+
led_tables->led_lookup_table = &simatic_ipc_led_gpio_table_227g;
72+
led_tables->led_lookup_table_extra = &simatic_ipc_led_gpio_table_extra_227g;
73+
break;
74+
case SIMATIC_IPC_DEVICE_BX_59A:
75+
led_tables->led_lookup_table = &simatic_ipc_led_gpio_table_bx_59a;
76+
break;
77+
default:
78+
return -ENODEV;
79+
}
80+
81+
platform_set_drvdata(pdev, led_tables);
82+
return simatic_ipc_leds_gpio_probe(pdev, led_tables->led_lookup_table,
83+
led_tables->led_lookup_table_extra);
4684
}
4785

4886
static void simatic_ipc_leds_gpio_f7188x_remove(struct platform_device *pdev)
4987
{
50-
simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table,
51-
&simatic_ipc_led_gpio_table_extra);
88+
struct simatic_ipc_led_tables *led_tables = platform_get_drvdata(pdev);
89+
90+
simatic_ipc_leds_gpio_remove(pdev, led_tables->led_lookup_table,
91+
led_tables->led_lookup_table_extra);
5292
}
5393

5494
static struct platform_driver simatic_ipc_led_gpio_driver = {

0 commit comments

Comments
 (0)