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 Elkhart Lake version

This is used for the Siemens Simatic IPC BX-21A, which has its LEDs
connected to GPIOs provided by the Intel Elkhart Lake pinctrl driver.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Link: https://lore.kernel.org/r/20230713115639.16419-3-henning.schild@siemens.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Henning Schild and committed by
Lee Jones
7e6d86e9 ee4e80b2

+75
+13
drivers/leds/simple/Kconfig
··· 35 35 36 36 To compile this driver as a module, choose M here: the module 37 37 will be called simatic-ipc-leds-gpio-f7188x. 38 + 39 + config LEDS_SIEMENS_SIMATIC_IPC_ELKHARTLAKE 40 + tristate "LED driver for Siemens Simatic IPCs based on Intel Elkhart Lake GPIO" 41 + depends on LEDS_GPIO 42 + depends on PINCTRL_ELKHARTLAKE 43 + depends on SIEMENS_SIMATIC_IPC 44 + default LEDS_SIEMENS_SIMATIC_IPC 45 + help 46 + This option enables support for the LEDs of several Industrial PCs 47 + from Siemens based on Elkhart Lake GPIO i.e. BX-21A. 48 + 49 + To compile this driver as a module, choose M here: the module 50 + will be called simatic-ipc-leds-gpio-elkhartlake.
+1
drivers/leds/simple/Makefile
··· 2 2 obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds.o 3 3 obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC_APOLLOLAKE) += simatic-ipc-leds-gpio-core.o simatic-ipc-leds-gpio-apollolake.o 4 4 obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC_F7188X) += simatic-ipc-leds-gpio-core.o simatic-ipc-leds-gpio-f7188x.o 5 + obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC_ELKHARTLAKE) += simatic-ipc-leds-gpio-core.o simatic-ipc-leds-gpio-elkhartlake.o
+4
drivers/leds/simple/simatic-ipc-leds-gpio-core.c
··· 57 57 switch (plat->devmode) { 58 58 case SIMATIC_IPC_DEVICE_127E: 59 59 case SIMATIC_IPC_DEVICE_227G: 60 + case SIMATIC_IPC_DEVICE_BX_21A: 60 61 break; 61 62 default: 62 63 return -ENODEV; ··· 72 71 err = PTR_ERR(simatic_leds_pdev); 73 72 goto out; 74 73 } 74 + 75 + if (!table_extra) 76 + return 0; 75 77 76 78 table_extra->dev_id = dev_name(dev); 77 79 gpiod_add_lookup_table(table_extra);
+57
drivers/leds/simple/simatic-ipc-leds-gpio-elkhartlake.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Siemens SIMATIC IPC driver for GPIO based LEDs 4 + * 5 + * Copyright (c) Siemens AG, 2023 6 + * 7 + * Author: 8 + * Henning Schild <henning.schild@siemens.com> 9 + */ 10 + 11 + #include <linux/gpio/machine.h> 12 + #include <linux/gpio/consumer.h> 13 + #include <linux/leds.h> 14 + #include <linux/module.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/platform_data/x86/simatic-ipc-base.h> 17 + 18 + #include "simatic-ipc-leds-gpio.h" 19 + 20 + static struct gpiod_lookup_table simatic_ipc_led_gpio_table = { 21 + .dev_id = "leds-gpio", 22 + .table = { 23 + GPIO_LOOKUP_IDX("INTC1020:04", 72, NULL, 0, GPIO_ACTIVE_HIGH), 24 + GPIO_LOOKUP_IDX("INTC1020:04", 77, NULL, 1, GPIO_ACTIVE_HIGH), 25 + GPIO_LOOKUP_IDX("INTC1020:04", 78, NULL, 2, GPIO_ACTIVE_HIGH), 26 + GPIO_LOOKUP_IDX("INTC1020:04", 58, NULL, 3, GPIO_ACTIVE_HIGH), 27 + GPIO_LOOKUP_IDX("INTC1020:04", 60, NULL, 4, GPIO_ACTIVE_HIGH), 28 + GPIO_LOOKUP_IDX("INTC1020:04", 62, NULL, 5, GPIO_ACTIVE_HIGH), 29 + {} /* Terminating entry */ 30 + }, 31 + }; 32 + 33 + static int simatic_ipc_leds_gpio_elkhartlake_probe(struct platform_device *pdev) 34 + { 35 + return simatic_ipc_leds_gpio_probe(pdev, &simatic_ipc_led_gpio_table, 36 + NULL); 37 + } 38 + 39 + static int simatic_ipc_leds_gpio_elkhartlake_remove(struct platform_device *pdev) 40 + { 41 + return simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table, 42 + NULL); 43 + } 44 + 45 + static struct platform_driver simatic_ipc_led_gpio_elkhartlake_driver = { 46 + .probe = simatic_ipc_leds_gpio_elkhartlake_probe, 47 + .remove = simatic_ipc_leds_gpio_elkhartlake_remove, 48 + .driver = { 49 + .name = KBUILD_MODNAME, 50 + }, 51 + }; 52 + module_platform_driver(simatic_ipc_led_gpio_elkhartlake_driver); 53 + 54 + MODULE_LICENSE("GPL v2"); 55 + MODULE_ALIAS("platform:" KBUILD_MODNAME); 56 + MODULE_SOFTDEP("pre: simatic-ipc-leds-gpio-core platform:elkhartlake-pinctrl"); 57 + MODULE_AUTHOR("Henning Schild <henning.schild@siemens.com>");