Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <andy.shevchenko@gmail.com>
Signed-off-by: Xing Tong Wu <xingtong.wu@siemens.com>
Link: https://lore.kernel.org/r/20240314070506.2384-1-xingtong_wu@163.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Xing Tong Wu and committed by
Lee Jones
6b0d685d 016cfc41

+47 -6
+1
drivers/leds/simple/simatic-ipc-leds-gpio-core.c
··· 56 56 case SIMATIC_IPC_DEVICE_127E: 57 57 case SIMATIC_IPC_DEVICE_227G: 58 58 case SIMATIC_IPC_DEVICE_BX_21A: 59 + case SIMATIC_IPC_DEVICE_BX_59A: 59 60 break; 60 61 default: 61 62 return -ENODEV;
+46 -6
drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c
··· 17 17 18 18 #include "simatic-ipc-leds-gpio.h" 19 19 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 = { 21 26 .dev_id = "leds-gpio", 22 27 .table = { 23 28 GPIO_LOOKUP_IDX("gpio-f7188x-2", 0, NULL, 0, GPIO_ACTIVE_LOW), ··· 35 30 }, 36 31 }; 37 32 38 - static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra = { 33 + static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra_227g = { 39 34 .dev_id = NULL, /* Filled during initialization */ 40 35 .table = { 41 36 GPIO_LOOKUP_IDX("gpio-f7188x-3", 6, NULL, 6, GPIO_ACTIVE_HIGH), ··· 44 39 }, 45 40 }; 46 41 42 + static struct gpiod_lookup_table simatic_ipc_led_gpio_table_bx_59a = { 43 + .dev_id = "leds-gpio", 44 + .table = { 45 + GPIO_LOOKUP_IDX("gpio-f7188x-2", 0, NULL, 0, GPIO_ACTIVE_LOW), 46 + GPIO_LOOKUP_IDX("gpio-f7188x-2", 3, NULL, 1, GPIO_ACTIVE_LOW), 47 + GPIO_LOOKUP_IDX("gpio-f7188x-5", 3, NULL, 2, GPIO_ACTIVE_LOW), 48 + GPIO_LOOKUP_IDX("gpio-f7188x-5", 2, NULL, 3, GPIO_ACTIVE_LOW), 49 + GPIO_LOOKUP_IDX("gpio-f7188x-7", 7, NULL, 4, GPIO_ACTIVE_LOW), 50 + GPIO_LOOKUP_IDX("gpio-f7188x-7", 4, NULL, 5, GPIO_ACTIVE_LOW), 51 + {} /* Terminating entry */ 52 + } 53 + }; 54 + 47 55 static int simatic_ipc_leds_gpio_f7188x_probe(struct platform_device *pdev) 48 56 { 49 - return simatic_ipc_leds_gpio_probe(pdev, &simatic_ipc_led_gpio_table, 50 - &simatic_ipc_led_gpio_table_extra); 57 + const struct simatic_ipc_platform *plat = dev_get_platdata(&pdev->dev); 58 + struct simatic_ipc_led_tables *led_tables; 59 + 60 + led_tables = devm_kzalloc(&pdev->dev, sizeof(*led_tables), GFP_KERNEL); 61 + if (!led_tables) 62 + return -ENOMEM; 63 + 64 + switch (plat->devmode) { 65 + case SIMATIC_IPC_DEVICE_227G: 66 + led_tables->led_lookup_table = &simatic_ipc_led_gpio_table_227g; 67 + led_tables->led_lookup_table_extra = &simatic_ipc_led_gpio_table_extra_227g; 68 + break; 69 + case SIMATIC_IPC_DEVICE_BX_59A: 70 + led_tables->led_lookup_table = &simatic_ipc_led_gpio_table_bx_59a; 71 + break; 72 + default: 73 + return -ENODEV; 74 + } 75 + 76 + platform_set_drvdata(pdev, led_tables); 77 + return simatic_ipc_leds_gpio_probe(pdev, led_tables->led_lookup_table, 78 + led_tables->led_lookup_table_extra); 51 79 } 52 80 53 81 static void simatic_ipc_leds_gpio_f7188x_remove(struct platform_device *pdev) 54 82 { 55 - simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table, 56 - &simatic_ipc_led_gpio_table_extra); 83 + struct simatic_ipc_led_tables *led_tables = platform_get_drvdata(pdev); 84 + 85 + simatic_ipc_leds_gpio_remove(pdev, led_tables->led_lookup_table, 86 + led_tables->led_lookup_table_extra); 57 87 } 58 88 59 89 static struct platform_driver simatic_ipc_led_gpio_driver = {