leds: simatic-ipc-leds-gpio: Add Elkhart Lake version
authorHenning Schild <henning.schild@siemens.com>
Thu, 13 Jul 2023 11:56:39 +0000 (13:56 +0200)
committerLee Jones <lee@kernel.org>
Fri, 28 Jul 2023 08:57:53 +0000 (09:57 +0100)
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>
drivers/leds/simple/Kconfig
drivers/leds/simple/Makefile
drivers/leds/simple/simatic-ipc-leds-gpio-core.c
drivers/leds/simple/simatic-ipc-leds-gpio-elkhartlake.c [new file with mode: 0644]

index 02443e745ff3b76db74648a2dfc024df19f8cdff..4496373bfe2439f80e1be521c0e58c53fdbeaaff 100644 (file)
@@ -35,3 +35,16 @@ config LEDS_SIEMENS_SIMATIC_IPC_F7188X
 
          To compile this driver as a module, choose M here: the module
          will be called simatic-ipc-leds-gpio-f7188x.
+
+config LEDS_SIEMENS_SIMATIC_IPC_ELKHARTLAKE
+       tristate "LED driver for Siemens Simatic IPCs based on Intel Elkhart Lake GPIO"
+       depends on LEDS_GPIO
+       depends on PINCTRL_ELKHARTLAKE
+       depends on SIEMENS_SIMATIC_IPC
+       default LEDS_SIEMENS_SIMATIC_IPC
+       help
+         This option enables support for the LEDs of several Industrial PCs
+         from Siemens based on Elkhart Lake GPIO i.e. BX-21A.
+
+         To compile this driver as a module, choose M here: the module
+         will be called simatic-ipc-leds-gpio-elkhartlake.
index e3e840cea275ca8870aaddee09d46670f1025912..783578f11bb0a1462263cdb9ad4266d7bfd1a3ed 100644 (file)
@@ -2,3 +2,4 @@
 obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC)                 += simatic-ipc-leds.o
 obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC_APOLLOLAKE)      += simatic-ipc-leds-gpio-core.o simatic-ipc-leds-gpio-apollolake.o
 obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC_F7188X)          += simatic-ipc-leds-gpio-core.o simatic-ipc-leds-gpio-f7188x.o
+obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC_ELKHARTLAKE)     += simatic-ipc-leds-gpio-core.o simatic-ipc-leds-gpio-elkhartlake.o
index 2a21b663df8746f4c285ea411f837a6a2a84cb1a..c552ea73ed9df62d345174cb0b7033a1d03ec6f0 100644 (file)
@@ -57,6 +57,7 @@ int simatic_ipc_leds_gpio_probe(struct platform_device *pdev,
        switch (plat->devmode) {
        case SIMATIC_IPC_DEVICE_127E:
        case SIMATIC_IPC_DEVICE_227G:
+       case SIMATIC_IPC_DEVICE_BX_21A:
                break;
        default:
                return -ENODEV;
@@ -72,6 +73,9 @@ int simatic_ipc_leds_gpio_probe(struct platform_device *pdev,
                goto out;
        }
 
+       if (!table_extra)
+               return 0;
+
        table_extra->dev_id = dev_name(dev);
        gpiod_add_lookup_table(table_extra);
 
diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio-elkhartlake.c b/drivers/leds/simple/simatic-ipc-leds-gpio-elkhartlake.c
new file mode 100644 (file)
index 0000000..6ba21db
--- /dev/null
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Siemens SIMATIC IPC driver for GPIO based LEDs
+ *
+ * Copyright (c) Siemens AG, 2023
+ *
+ * Author:
+ *  Henning Schild <henning.schild@siemens.com>
+ */
+
+#include <linux/gpio/machine.h>
+#include <linux/gpio/consumer.h>
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/platform_data/x86/simatic-ipc-base.h>
+
+#include "simatic-ipc-leds-gpio.h"
+
+static struct gpiod_lookup_table simatic_ipc_led_gpio_table = {
+       .dev_id = "leds-gpio",
+       .table = {
+               GPIO_LOOKUP_IDX("INTC1020:04", 72, NULL, 0, GPIO_ACTIVE_HIGH),
+               GPIO_LOOKUP_IDX("INTC1020:04", 77, NULL, 1, GPIO_ACTIVE_HIGH),
+               GPIO_LOOKUP_IDX("INTC1020:04", 78, NULL, 2, GPIO_ACTIVE_HIGH),
+               GPIO_LOOKUP_IDX("INTC1020:04", 58, NULL, 3, GPIO_ACTIVE_HIGH),
+               GPIO_LOOKUP_IDX("INTC1020:04", 60, NULL, 4, GPIO_ACTIVE_HIGH),
+               GPIO_LOOKUP_IDX("INTC1020:04", 62, NULL, 5, GPIO_ACTIVE_HIGH),
+               {} /* Terminating entry */
+       },
+};
+
+static int simatic_ipc_leds_gpio_elkhartlake_probe(struct platform_device *pdev)
+{
+       return simatic_ipc_leds_gpio_probe(pdev, &simatic_ipc_led_gpio_table,
+                                          NULL);
+}
+
+static int simatic_ipc_leds_gpio_elkhartlake_remove(struct platform_device *pdev)
+{
+       return simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table,
+                                           NULL);
+}
+
+static struct platform_driver simatic_ipc_led_gpio_elkhartlake_driver = {
+       .probe = simatic_ipc_leds_gpio_elkhartlake_probe,
+       .remove = simatic_ipc_leds_gpio_elkhartlake_remove,
+       .driver = {
+               .name = KBUILD_MODNAME,
+       },
+};
+module_platform_driver(simatic_ipc_led_gpio_elkhartlake_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:" KBUILD_MODNAME);
+MODULE_SOFTDEP("pre: simatic-ipc-leds-gpio-core platform:elkhartlake-pinctrl");
+MODULE_AUTHOR("Henning Schild <henning.schild@siemens.com>");