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("gpio-f7188x-2", 0, NULL, 0, GPIO_ACTIVE_LOW), 24 GPIO_LOOKUP_IDX("gpio-f7188x-2", 1, NULL, 1, GPIO_ACTIVE_LOW), 25 GPIO_LOOKUP_IDX("gpio-f7188x-2", 2, NULL, 2, GPIO_ACTIVE_LOW), 26 GPIO_LOOKUP_IDX("gpio-f7188x-2", 3, NULL, 3, GPIO_ACTIVE_LOW), 27 GPIO_LOOKUP_IDX("gpio-f7188x-2", 4, NULL, 4, GPIO_ACTIVE_LOW), 28 GPIO_LOOKUP_IDX("gpio-f7188x-2", 5, NULL, 5, GPIO_ACTIVE_LOW), 29 {} /* Terminating entry */ 30 }, 31 }; 32 33 static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra = { 34 .dev_id = NULL, /* Filled during initialization */ 35 .table = { 36 GPIO_LOOKUP_IDX("gpio-f7188x-3", 6, NULL, 6, GPIO_ACTIVE_HIGH), 37 GPIO_LOOKUP_IDX("gpio-f7188x-3", 7, NULL, 7, GPIO_ACTIVE_HIGH), 38 {} /* Terminating entry */ 39 }, 40 }; 41 42 static int simatic_ipc_leds_gpio_f7188x_probe(struct platform_device *pdev) 43 { 44 return simatic_ipc_leds_gpio_probe(pdev, &simatic_ipc_led_gpio_table, 45 &simatic_ipc_led_gpio_table_extra); 46 } 47 48 static void simatic_ipc_leds_gpio_f7188x_remove(struct platform_device *pdev) 49 { 50 simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table, 51 &simatic_ipc_led_gpio_table_extra); 52 } 53 54 static struct platform_driver simatic_ipc_led_gpio_driver = { 55 .probe = simatic_ipc_leds_gpio_f7188x_probe, 56 .remove_new = simatic_ipc_leds_gpio_f7188x_remove, 57 .driver = { 58 .name = KBUILD_MODNAME, 59 }, 60 }; 61 module_platform_driver(simatic_ipc_led_gpio_driver); 62 63 MODULE_LICENSE("GPL v2"); 64 MODULE_ALIAS("platform:" KBUILD_MODNAME); 65 MODULE_SOFTDEP("pre: simatic-ipc-leds-gpio-core gpio_f7188x"); 66 MODULE_AUTHOR("Henning Schild <henning.schild@siemens.com>"); 67