leds: simatic-ipc-leds-gpio: split up
Subsystems (2)
v3 cover leds: simatic-ipc-leds-gpio: split up
changes sinve v2:
- some more style changes from review
changes since v1:
- move from header- to -core.c-based implementation
- style changes from review
This series mainly splits the one GPIO driver into two. The split allows to clearly model runtime and compile time dependencies on the GPIO chip drivers.
p1 is kind of not too related to that split but also prepares for more GPIO based drivers to come.
p2 takes the driver we had and puts some of its content into a -core, to be used by the two drivers.
p3 deals with more fine-grained configuration posibilities and compile time dependencies.
Henning Schild (3):
leds: simatic-ipc-leds-gpio: move two extra gpio pins into another
table
leds: simatic-ipc-leds-gpio: split up into multiple drivers
leds: simatic-ipc-leds-gpio: introduce more Kconfig switches
drivers/leds/simple/Kconfig | 31 +++- drivers/leds/simple/Makefile | 5 +- .../simple/simatic-ipc-leds-gpio-apollolake.c | 64 ++++++++ .../leds/simple/simatic-ipc-leds-gpio-core.c | 104 +++++++++++++ .../simple/simatic-ipc-leds-gpio-f7188x.c | 64 ++++++++ drivers/leds/simple/simatic-ipc-leds-gpio.c | 139 ------------------ drivers/leds/simple/simatic-ipc-leds-gpio.h | 22 +++ drivers/leds/simple/simatic-ipc-leds.c | 1 - drivers/platform/x86/simatic-ipc.c | 7 +- 9 files changed, 289 insertions(+), 148 deletions(-) create mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c create mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio-core.c create mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c delete mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio.c create mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio.h
Signature · 1 line
2.39.3
PATCH v3 1/3 leds: simatic-ipc-leds-gpio: move two extra gpio pins into another table
There are two special pins needed to init the LEDs. We used to have them at the end of the gpiod_lookup table to give to "leds-gpio". A cleaner way is to have a dedicated table for the special pins.
--- drivers/leds/simple/simatic-ipc-leds-gpio.c | 26 ++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
drivers/leds/simple/simatic-ipc-leds-gpio.c +23 -3
@@ -16,6 +16,7 @@#include <linux/platform_data/x86/simatic-ipc-base.h> static struct gpiod_lookup_table *simatic_ipc_led_gpio_table; +static struct gpiod_lookup_table *simatic_ipc_led_gpio_table_extra;static struct gpiod_lookup_table simatic_ipc_led_gpio_table_127e = { .dev_id ="leds-gpio" ,
@@ -26,6 +27,12 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_127e = {GPIO_LOOKUP_IDX ("apollolake-pinctrl.0" ,58 ,NULL ,3 ,GPIO_ACTIVE_LOW ),GPIO_LOOKUP_IDX ("apollolake-pinctrl.0" ,60 ,NULL ,4 ,GPIO_ACTIVE_LOW ), GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 51, NULL, 5, GPIO_ACTIVE_LOW), + }, +}; + +static struct gpiod_lookup_table simatic_ipc_led_gpio_table_127e_extra = { + .dev_id =NULL ,/* Filled during initialization */ + .table = {GPIO_LOOKUP_IDX ("apollolake-pinctrl.0" ,56 ,NULL ,6 ,GPIO_ACTIVE_LOW ),GPIO_LOOKUP_IDX ("apollolake-pinctrl.0" ,59 ,NULL ,7 ,GPIO_ACTIVE_HIGH ), },
@@ -40,9 +47,15 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g = {GPIO_LOOKUP_IDX ("gpio-f7188x-2" ,3 ,NULL ,3 ,GPIO_ACTIVE_LOW ),GPIO_LOOKUP_IDX ("gpio-f7188x-2" ,4 ,NULL ,4 ,GPIO_ACTIVE_LOW ), GPIO_LOOKUP_IDX("gpio-f7188x-2", 5, NULL, 5, GPIO_ACTIVE_LOW), + }, +}; + +static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g_extra = { + .dev_id =NULL ,/* Filled during initialization */ + .table = {GPIO_LOOKUP_IDX ("gpio-f7188x-3" ,6 ,NULL ,6 ,GPIO_ACTIVE_HIGH ),GPIO_LOOKUP_IDX ("gpio-f7188x-3" ,7 ,NULL ,7 ,GPIO_ACTIVE_HIGH ), - } + }, }; static const struct gpio_led simatic_ipc_gpio_leds[] = {
@@ -64,6 +77,7 @@ static struct platform_device *simatic_leds_pdev;static int simatic_ipc_leds_gpio_remove (struct platform_device *pdev) {gpiod_remove_lookup_table (simatic_ipc_led_gpio_table); +gpiod_remove_lookup_table (simatic_ipc_led_gpio_table_extra);platform_device_unregister (simatic_leds_pdev);return 0 ;
@@ -72,6 +86,7 @@ static int simatic_ipc_leds_gpio_remove(struct platform_device *pdev)static int simatic_ipc_leds_gpio_probe (struct platform_device *pdev) {const struct simatic_ipc_platform *plat = pdev->dev.platform_data; +struct device *dev = &pdev->dev;struct gpio_desc *gpiod;int err;
@@ -80,12 +95,14 @@ static int simatic_ipc_leds_gpio_probe(struct platform_device *pdev)if (!IS_ENABLED (CONFIG_PINCTRL_BROXTON ))return -ENODEV ; simatic_ipc_led_gpio_table = &simatic_ipc_led_gpio_table_127e; + simatic_ipc_led_gpio_table_extra = &simatic_ipc_led_gpio_table_127e_extra;break ;case SIMATIC_IPC_DEVICE_227G :if (!IS_ENABLED (CONFIG_GPIO_F7188X ))return -ENODEV ;request_module ("gpio-f7188x" ); simatic_ipc_led_gpio_table = &simatic_ipc_led_gpio_table_227g; + simatic_ipc_led_gpio_table_extra = &simatic_ipc_led_gpio_table_227g_extra;break ;default :return -ENODEV ;
@@ -101,8 +118,11 @@ static int simatic_ipc_leds_gpio_probe(struct platform_device *pdev) goto out; } + simatic_ipc_led_gpio_table_extra->dev_id =dev_name (dev); +gpiod_add_lookup_table (simatic_ipc_led_gpio_table_extra); +/* PM_BIOS_BOOT_N */ - gpiod =gpiod_get_index (&simatic_leds_pdev->dev,NULL ,6 ,GPIOD_OUT_LOW ); + gpiod =gpiod_get_index (dev,NULL ,6 ,GPIOD_OUT_LOW );if (IS_ERR (gpiod)) { err =PTR_ERR (gpiod); goto out;
@@ -110,7 +130,7 @@ static int simatic_ipc_leds_gpio_probe(struct platform_device *pdev)gpiod_put (gpiod);/* PM_WDT_OUT */ - gpiod =gpiod_get_index (&simatic_leds_pdev->dev,NULL ,7 ,GPIOD_OUT_LOW ); + gpiod =gpiod_get_index (dev,NULL ,7 ,GPIOD_OUT_LOW );if (IS_ERR (gpiod)) { err =PTR_ERR (gpiod); goto out;
Signature · 1 line
2.39.3
Re: [PATCH v3 1/3] leds: simatic-ipc-leds-gpio: move two extra gpio pins into another table
Quoted 3 lines · Henning Schild
There are two special pins needed to init the LEDs. We used to have them at the end of the
gpiod_lookuptable to give to "leds-gpio". A cleaner way is to have a dedicated table for the special pins.
...
drivers/leds/simple/simatic-ipc-leds-gpio.c static struct gpiod_lookup_table simatic_ipc_led_gpio_table_127e = { · line 29
Quoted 6 lines
static struct
gpiod_lookup_tablesimatic_ipc_led_gpio_table_127e= {drivers/leds/simple/simatic-ipc-leds-gpio.c +0
-0.dev_id = "leds-gpio",@@ -26,6 +27,12 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_127e = {GPIO_LOOKUP_IDX ("apollolake-pinctrl.0" ,58 ,NULL ,3 ,GPIO_ACTIVE_LOW ),GPIO_LOOKUP_IDX ("apollolake-pinctrl.0" ,60 ,NULL ,4 ,GPIO_ACTIVE_LOW ), GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 51, NULL, 5, GPIO_ACTIVE_LOW),
Missing terminator. I'm wondering how this works...
drivers/leds/simple/simatic-ipc-leds-gpio.c static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g = { · line 49
Quoted 13 lines
drivers/leds/simple/simatic-ipc-leds-gpio.c +6
-0+ }, +}; + +static struct gpiod_lookup_table simatic_ipc_led_gpio_table_127e_extra = { + .dev_id =NULL ,/* Filled during initialization */ + .table = {GPIO_LOOKUP_IDX ("apollolake-pinctrl.0" ,56 ,NULL ,6 ,GPIO_ACTIVE_LOW ),GPIO_LOOKUP_IDX ("apollolake-pinctrl.0" ,59 ,NULL ,7 ,GPIO_ACTIVE_HIGH ), },@@ -40,9 +47,15 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g = {GPIO_LOOKUP_IDX ("gpio-f7188x-2" ,3 ,NULL ,3 ,GPIO_ACTIVE_LOW ),GPIO_LOOKUP_IDX ("gpio-f7188x-2" ,4 ,NULL ,4 ,GPIO_ACTIVE_LOW ), GPIO_LOOKUP_IDX("gpio-f7188x-2", 5, NULL, 5, GPIO_ACTIVE_LOW),
Ditto.
drivers/leds/simple/simatic-ipc-leds-gpio.c static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g = { · line 57
Quoted 8 lines
drivers/leds/simple/simatic-ipc-leds-gpio.c +6
-0+ }, +}; + +static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g_extra = { + .dev_id =NULL ,/* Filled during initialization */ + .table = {GPIO_LOOKUP_IDX ("gpio-f7188x-3" ,6 ,NULL ,6 ,GPIO_ACTIVE_HIGH ),GPIO_LOOKUP_IDX ("gpio-f7188x-3" ,7 ,NULL ,7 ,GPIO_ACTIVE_HIGH ),
Ditto.
Quoted 3 lines
drivers/leds/simple/simatic-ipc-leds-gpio.c +1
-1- } + }, };
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 2/3 leds: simatic-ipc-leds-gpio: split up into multiple drivers
In reply to Henning SchildIn order to clearly describe the dependencies between the GPIO controller drivers and the users the driver is split up into a core, two drivers and a common header.
--- drivers/leds/simple/Makefile | 4 +- .../simple/simatic-ipc-leds-gpio-apollolake.c | 64 +++++++ .../leds/simple/simatic-ipc-leds-gpio-core.c | 104 ++++++++++++ .../simple/simatic-ipc-leds-gpio-f7188x.c | 64 +++++++ drivers/leds/simple/simatic-ipc-leds-gpio.c | 159 ------------------ drivers/leds/simple/simatic-ipc-leds-gpio.h | 22 +++ drivers/leds/simple/simatic-ipc-leds.c | 1 - drivers/platform/x86/simatic-ipc.c | 7 +- 8 files changed, 261 insertions(+), 164 deletions(-) create mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c create mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio-core.c create mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c delete mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio.c create mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio.h
drivers/leds/simple/Makefile +3 -1
@@ -1,3 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds.o -obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds-gpio.o +obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds-gpio-core.o +obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds-gpio-apollolake.o +obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds-gpio-f7188x.o
drivers/leds/simple/simatic-ipc-leds-gpio-apollolake.c new file +64 -0
64 lines not on this page · raw message
drivers/leds/simple/simatic-ipc-leds-gpio-core.c new file +104 -0
104 lines not on this page · raw message
drivers/leds/simple/simatic-ipc-leds-gpio-f7188x.c new file +64 -0
64 lines not on this page · raw message
drivers/leds/simple/simatic-ipc-leds-gpio.c deleted +0 -159
159 lines not on this page · raw message
drivers/leds/simple/simatic-ipc-leds-gpio.h new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Siemens SIMATIC IPC driver for GPIO based LEDs +* +* Copyright (c) Siemens AG, 2023 +* +* Author: +* Henning Schild <[email protected]> +*/ + +#ifndef _SIMATIC_IPC_LEDS_GPIO_H +#define _SIMATIC_IPC_LEDS_GPIO_H + +int simatic_ipc_leds_gpio_probe (struct platform_device *pdev, +struct gpiod_lookup_table *table, +struct gpiod_lookup_table *table_extra); + +int simatic_ipc_leds_gpio_remove (struct platform_device *pdev, +struct gpiod_lookup_table *table, +struct gpiod_lookup_table *table_extra); + +#endif /* _SIMATIC_IPC_LEDS_GPIO_H */
drivers/leds/simple/simatic-ipc-leds.c +0 -1
@@ -126,7 +126,6 @@ static struct platform_driver simatic_ipc_led_driver = { .name = KBUILD_MODNAME, } }; -module_platform_driver (simatic_ipc_led_driver);MODULE_LICENSE ("GPL v2" );
drivers/platform/x86/simatic-ipc.c +4 -3
@@ -68,9 +68,10 @@ static int register_platform_devices(u32 station_id) }if (ledmode !=SIMATIC_IPC_DEVICE_NONE ) { -if (ledmode ==SIMATIC_IPC_DEVICE_127E || - ledmode ==SIMATIC_IPC_DEVICE_227G ) - pdevname =KBUILD_MODNAME "_leds_gpio" ; +if (ledmode ==SIMATIC_IPC_DEVICE_127E ) + pdevname =KBUILD_MODNAME "_leds_gpio_apollolake" ; +if (ledmode ==SIMATIC_IPC_DEVICE_227G ) + pdevname =KBUILD_MODNAME "_leds_gpio_f7188x" ; platform_data.devmode = ledmode; ipc_led_platform_device = platform_device_register_data(NULL,
Signature · 1 line
2.39.3
Re: [PATCH v3 2/3] leds: simatic-ipc-leds-gpio: split up into multiple drivers
Quoted 3 lines · Henning Schild
In order to clearly describe the dependencies between the GPIO controller drivers and the users the driver is split up into a core, two drivers and a common header.
AFAIU the GPIO lookup tables need a terminator entry.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 2/3] leds: simatic-ipc-leds-gpio: split up into multiple drivers
Am Tue, 16 May 2023 00:41:30 +0300
schrieb Andy Shevchenko <[email protected]>:
Quoted 6 lines · Henning Schild
Quoted 3 lines
In order to clearly describe the dependencies between the GPIO controller drivers and the users the driver is split up into a core, two drivers and a common header.
AFAIU the GPIO lookup tables need a terminator entry.
They never had one in the first place and that worked, i did not add terminators here and that also works. My guess is that .num_leds = ARRAY_SIZE(simatic_ipc_gpio_leds) tells "leds-gpio" how many entries there are. (another array without a terminator)
But i will add them in a v4 so things are explicit and aligned with other similar drivers.
Henning
PATCH v3 3/3 leds: simatic-ipc-leds-gpio: introduce more Kconfig switches
In reply to Henning SchildTo describe the dependency chain better and allow for potential fine-grained config tuning, introduce Kconfig switch for the individual GPIO based drivers.
--- drivers/leds/simple/Kconfig | 31 ++++++++++++++++++++++++++++--- drivers/leds/simple/Makefile | 7 +++---- 2 files changed, 31 insertions(+), 7 deletions(-)
drivers/leds/simple/Kconfig +28 -3
@@ -1,11 +1,36 @@ # SPDX-License-Identifier: GPL-2.0-only config LEDS_SIEMENS_SIMATIC_IPC tristate "LED driver for Siemens Simatic IPCs" - depends on LEDS_GPIO depends on SIEMENS_SIMATIC_IPC help This option enables support for the LEDs of several Industrial PCs from Siemens. - To compile this driver as a module, choose M here: the modules - will be called simatic-ipc-leds and simatic-ipc-leds-gpio. + To compile this driver as a module, choose M here: the module + will be called simatic-ipc-leds. + +config LEDS_SIEMENS_SIMATIC_IPC_APOLLOLAKE + tristate "LED driver for Siemens Simatic IPCs based on Intel Apollo Lake GPIO" + depends on LEDS_GPIO + depends on PINCTRL_BROXTON + 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 Apollo Lake GPIO i.e. IPC127E. + + To compile this driver as a module, choose M here: the module + will be called simatic-ipc-leds-gpio-apollolake. + +config LEDS_SIEMENS_SIMATIC_IPC_F7188X + tristate "LED driver for Siemens Simatic IPCs based on Nuvoton GPIO" + depends on LEDS_GPIO + depends on GPIO_F7188X + 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 Nuvoton GPIO i.e. IPC227G. + + To compile this driver as a module, choose M here: the module + will be called simatic-ipc-leds-gpio-f7188x.
drivers/leds/simple/Makefile +3 -4
@@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds.o -obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds-gpio-core.o -obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds-gpio-apollolake.o -obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds-gpio-f7188x.o +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
Signature · 1 line
2.39.3