Skip to contentSkip to conversation

leds: simatic-ipc-leds-gpio: split up

PATCH Applied Henning Schild 4 participants 18 messages May 24, 2023 – Jun 12, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover leds: simatic-ipc-leds-gpio: split up

changes since v3:
- add terminator entries to all gpio lookup tables as new p1

changes since 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.

p2 is kind of not too related to that split but also prepares for more GPIO based drivers to come.

p3 takes the driver we had and puts some of its content into a -core, to be used by the two drivers.

p4 deals with more fine-grained configuration posibilities and compile time dependencies.

Henning Schild (4):
leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables
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 |  66 +++++++++
 .../leds/simple/simatic-ipc-leds-gpio-core.c  | 104 +++++++++++++
 .../simple/simatic-ipc-leds-gpio-f7188x.c     |  66 +++++++++
 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, 293 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
#1 lore raw

PATCH v4 1/4 leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables

The entries do not seem to be stricly needed when the number of entries is given via the number of LEDs. But adding them is a safeguard should anyone ever iterate over the tables to their end, it also gets us in line with other drivers that register "leds-gpio" tables.

---
 drivers/leds/simple/simatic-ipc-leds-gpio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/leds/simple/simatic-ipc-leds-gpio.c +2 -0
index e8d329b5a68c..1a1cfdad6218 100644
@@ -28,6 +28,7 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_127e = {
 		GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 51, NULL, 5, GPIO_ACTIVE_LOW),
 		GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 56, NULL, 6, GPIO_ACTIVE_LOW),
 		GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 59, NULL, 7, GPIO_ACTIVE_HIGH),
+		{} /* Terminating entry */
 	},
 };
 
@@ -42,6 +43,7 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g = {
 		GPIO_LOOKUP_IDX("gpio-f7188x-2", 5, NULL, 5, GPIO_ACTIVE_LOW),
 		GPIO_LOOKUP_IDX("gpio-f7188x-3", 6, NULL, 6, GPIO_ACTIVE_HIGH),
 		GPIO_LOOKUP_IDX("gpio-f7188x-3", 7, NULL, 7, GPIO_ACTIVE_HIGH),
+		{} /* Terminating entry */
 	}
 };
 
Signature · 1 line
2.39.3
Reviewed-by on v4 1/4
#2 lore raw

Re: [PATCH v4 1/4] leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables

Quoted 4 lines · Henning Schild

The entries do not seem to be stricly needed when the number of entries is given via the number of LEDs. But adding them is a safeguard should anyone ever iterate over the tables to their end, it also gets us in line with other drivers that register "leds-gpio" tables.

Reported-by?

Quoted 28 lines
---
 drivers/leds/simple/simatic-ipc-leds-gpio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/leds/simple/simatic-ipc-leds-gpio.c +2 -0
index e8d329b5a68c..1a1cfdad6218 100644
@@ -28,6 +28,7 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_127e = {
 		GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 51, NULL, 5, GPIO_ACTIVE_LOW),
 		GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 56, NULL, 6, GPIO_ACTIVE_LOW),
 		GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 59, NULL, 7, GPIO_ACTIVE_HIGH),
+		{} /* Terminating entry */
 	},
 };
 
@@ -42,6 +43,7 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g = {
 		GPIO_LOOKUP_IDX("gpio-f7188x-2", 5, NULL, 5, GPIO_ACTIVE_LOW),
 		GPIO_LOOKUP_IDX("gpio-f7188x-3", 6, NULL, 6, GPIO_ACTIVE_HIGH),
 		GPIO_LOOKUP_IDX("gpio-f7188x-3", 7, NULL, 7, GPIO_ACTIVE_HIGH),
+		{} /* Terminating entry */
 	}
 };
 
Signature · 1 line
2.39.3
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

Re: [PATCH v4 1/4] leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables

Am Sat, 27 May 2023 11:54:08 +0300
schrieb Andy Shevchenko <[email protected]>:

Quoted 9 lines · Henning Schild
Quoted 5 lines

The entries do not seem to be stricly needed when the number of entries is given via the number of LEDs. But adding them is a safeguard should anyone ever iterate over the tables to their end, it also gets us in line with other drivers that register "leds-gpio" tables.

Reported-by?

I think we could do

on merge. But i would not want to send the whole series again for that one line.

Thanks!
Henning

Quoted 32 lines
Quoted 31 lines
---
 drivers/leds/simple/simatic-ipc-leds-gpio.c | 2 ++
 1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/drivers/leds/simple/simatic-ipc-leds-gpio.c index e8d329b5a68c..1a1cfdad6218 100644 --- a/drivers/leds/simple/simatic-ipc-leds-gpio.c +++ b/drivers/leds/simple/simatic-ipc-leds-gpio.c @@ -28,6 +28,7 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_127e = { GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 51, NULL, 5, GPIO_ACTIVE_LOW), GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 56, NULL, 6, GPIO_ACTIVE_LOW), GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 59, NULL, 7, GPIO_ACTIVE_HIGH),

drivers/leds/simple/simatic-ipc-leds-gpio.c +2 -0
+		{} /* Terminating entry */
 	},
 };
@@ -42,6 +43,7 @@ static struct gpiod_lookup_table
 simatic_ipc_led_gpio_table_227g = {
 GPIO_LOOKUP_IDX("gpio-f7188x-2", 5, NULL, 5, GPIO_ACTIVE_LOW),
 GPIO_LOOKUP_IDX("gpio-f7188x-3", 6, NULL, 6, GPIO_ACTIVE_HIGH),
 GPIO_LOOKUP_IDX("gpio-f7188x-3", 7, NULL, 7, GPIO_ACTIVE_HIGH),
+		{} /* Terminating entry */
 	}
 };
Signature · 2 lines
-- 
2.39.3
#4 lore raw

Re: [PATCH v4 1/4] leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables

Quoted 13 lines · Henning Schild

Am Sat, 27 May 2023 11:54:08 +0300
schrieb Andy Shevchenko <[email protected]>:

Quoted 9 lines · Henning Schild
Quoted 5 lines

The entries do not seem to be stricly needed when the number of entries is given via the number of LEDs. But adding them is a safeguard should anyone ever iterate over the tables to their end, it also gets us in line with other drivers that register "leds-gpio" tables.

Reported-by?

Quoted 6 lines

I think we could do

on merge. But i would not want to send the whole series again for that one line.

Since you added it, b4 will happily take it, I believe no manual work even needed for that, thank you!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#5 lore raw

Re: [PATCH v4 1/4] leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables

Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Henning Schild

Am Sat, 27 May 2023 11:54:08 +0300
schrieb Andy Shevchenko <[email protected]>:

Quoted 9 lines · Henning Schild
Quoted 5 lines

The entries do not seem to be stricly needed when the number of entries is given via the number of LEDs. But adding them is a safeguard should anyone ever iterate over the tables to their end, it also gets us in line with other drivers that register "leds-gpio" tables.

Reported-by?

I think we could do

Quoted 7 lines
Quoted 4 lines

on merge. But i would not want to send the whole series again for that one line.

Since you added it, b4 will happily take it, I believe no manual work even needed for that, thank you!

b4 didn't pick this up. Nor the whole-series Ack provided by Hans.

I added both manually.

Signature · 1 line
Lee Jones [李琼斯]
#6 lore raw

Re: [PATCH v4 1/4] leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables

Quoted 22 lines · Lee Jones
Quoted 21 lines · Andy Shevchenko
Quoted 19 lines · Henning Schild

Am Sat, 27 May 2023 11:54:08 +0300
schrieb Andy Shevchenko <[email protected]>:

Quoted 9 lines · Henning Schild
Quoted 5 lines

The entries do not seem to be stricly needed when the number of entries is given via the number of LEDs. But adding them is a safeguard should anyone ever iterate over the tables to their end, it also gets us in line with other drivers that register "leds-gpio" tables.

Reported-by?

I think we could do

on merge. But i would not want to send the whole series again for that one line.

Quoted 6 lines
Quoted 2 lines

Since you added it, b4 will happily take it, I believe no manual work even needed for that, thank you!

b4 didn't pick this up. Nor the whole-series Ack provided by Hans.

I added both manually.

There is an option to take this

-t, --apply-cover-trailers
Apply trailers sent to the cover letter to all patches

have you tried it?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#7 lore raw

Re: [PATCH v4 1/4] leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables

Quoted 28 lines · Andy Shevchenko
Quoted 27 lines · Lee Jones
Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Henning Schild

Am Sat, 27 May 2023 11:54:08 +0300
schrieb Andy Shevchenko <[email protected]>:

Quoted 9 lines · Henning Schild
Quoted 5 lines

The entries do not seem to be stricly needed when the number of entries is given via the number of LEDs. But adding them is a safeguard should anyone ever iterate over the tables to their end, it also gets us in line with other drivers that register "leds-gpio" tables.

Reported-by?

I think we could do

Quoted 7 lines
Quoted 4 lines

on merge. But i would not want to send the whole series again for that one line.

Since you added it, b4 will happily take it, I believe no manual work even needed for that, thank you!

b4 didn't pick this up. Nor the whole-series Ack provided by Hans.

Quoted 8 lines
Quoted 1 line

I added both manually.

There is an option to take this

-t, --apply-cover-trailers
Apply trailers sent to the cover letter to all patches

have you tried it?

Doesn't look like it:

  b4 am -3 -slt -P_ -o - ${id} | git am -3 --reject

Can't remember if I had it before then removed it, or never had it.

I'll attempt to add it now and see what happens.

Signature · 1 line
Lee Jones [李琼斯]
maintainer
#8 lore raw

Re: [PATCH v4 1/4] leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables

Quoted 34 lines · Lee Jones
Quoted 32 lines · Andy Shevchenko
Quoted 22 lines · Lee Jones
Quoted 21 lines · Andy Shevchenko
Quoted 19 lines · Henning Schild

Am Sat, 27 May 2023 11:54:08 +0300
schrieb Andy Shevchenko <[email protected]>:

Quoted 9 lines · Henning Schild
Quoted 5 lines

The entries do not seem to be stricly needed when the number of entries is given via the number of LEDs. But adding them is a safeguard should anyone ever iterate over the tables to their end, it also gets us in line with other drivers that register "leds-gpio" tables.

Reported-by?

I think we could do

on merge. But i would not want to send the whole series again for that one line.

Quoted 6 lines
Quoted 2 lines

Since you added it, b4 will happily take it, I believe no manual work even needed for that, thank you!

b4 didn't pick this up. Nor the whole-series Ack provided by Hans.

I added both manually.

There is an option to take this

Quoted 8 lines
Quoted 4 lines

-t, --apply-cover-trailers
Apply trailers sent to the cover letter to all patches

have you tried it?

Doesn't look like it:

  b4 am -3 -slt -P_ -o - ${id} | git am -3 --reject

No wait - it's there.

Quoted 3 lines

Can't remember if I had it before then removed it, or never had it.

I'll attempt to add it now and see what happens.

Signature · 1 line
Lee Jones [李琼斯]
maintainer Applied
#9 lore raw

Re: [PATCH v4 1/4] leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables

In reply to Henning Schild
Quoted 9 lines · Henning Schild

The entries do not seem to be stricly needed when the number of entries is given via the number of LEDs. But adding them is a safeguard should anyone ever iterate over the tables to their end, it also gets us in line with other drivers that register "leds-gpio" tables.

---
 drivers/leds/simple/simatic-ipc-leds-gpio.c | 2 ++
 1 file changed, 2 insertions(+)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]
#10 lore raw

PATCH v4 2/4 leds: simatic-ipc-leds-gpio: move two extra gpio pins into another table

In reply to Henning Schild

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 | 28 ++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
drivers/leds/simple/simatic-ipc-leds-gpio.c +25 -3
index 1a1cfdad6218..0f1fde44e8d9 100644
@@ -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,13 @@ 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),
+		{} /* Terminating entry */
+	},
+};
+
+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),
 		{} /* Terminating entry */
@@ -41,10 +49,17 @@ 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),
+		{} /* Terminating entry */
+	},
+};
+
+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),
 		{} /* Terminating entry */
-	}
+	},
 };
 
 static const struct gpio_led simatic_ipc_gpio_leds[] = {
@@ -66,6 +81,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;
@@ -74,6 +90,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;
 
@@ -82,12 +99,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;
@@ -103,8 +122,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;
@@ -112,7 +134,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
maintainer Applied
#11 lore raw

Re: [PATCH v4 2/4] leds: simatic-ipc-leds-gpio: move two extra gpio pins into another table

Quoted 8 lines · Henning Schild

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 | 28 ++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]
#12 lore raw

PATCH v4 3/4 leds: simatic-ipc-leds-gpio: split up into multiple drivers

In reply to 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.

---
 drivers/leds/simple/Makefile                  |   4 +-
 .../simple/simatic-ipc-leds-gpio-apollolake.c |  66 +++++++
 .../leds/simple/simatic-ipc-leds-gpio-core.c  | 104 +++++++++++
 .../simple/simatic-ipc-leds-gpio-f7188x.c     |  66 +++++++
 drivers/leds/simple/simatic-ipc-leds-gpio.c   | 163 ------------------
 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, 265 insertions(+), 168 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
index 1c7ef5e1324b..ed9057f7b6da 100644
@@ -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 +66 -0

66 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 +66 -0

66 lines not on this page · raw message

drivers/leds/simple/simatic-ipc-leds-gpio.c deleted +0 -163

163 lines not on this page · raw message

drivers/leds/simple/simatic-ipc-leds-gpio.h new file +22 -0
new file mode 100644
index 000000000000..bf258c32f83d
@@ -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
index 4894c228c165..2124f6d09930 100644
@@ -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
index b3622419cd1a..c773995b230d 100644
@@ -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
maintainer Applied
#13 lore raw

Re: [PATCH v4 3/4] leds: simatic-ipc-leds-gpio: split up into multiple drivers

Quoted 5 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.

Quoted 15 lines
---
 drivers/leds/simple/Makefile                  |   4 +-
 .../simple/simatic-ipc-leds-gpio-apollolake.c |  66 +++++++
 .../leds/simple/simatic-ipc-leds-gpio-core.c  | 104 +++++++++++
 .../simple/simatic-ipc-leds-gpio-f7188x.c     |  66 +++++++
 drivers/leds/simple/simatic-ipc-leds-gpio.c   | 163 ------------------
 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, 265 insertions(+), 168 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

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]
#14 lore raw

PATCH v4 4/4 leds: simatic-ipc-leds-gpio: introduce more Kconfig switches

In reply to Henning Schild

To 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
index fd2b8225d926..44fa0f93cb3b 100644
@@ -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
index ed9057f7b6da..e3e840cea275 100644
@@ -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
maintainer Applied
#15 lore raw

Re: [PATCH v4 4/4] leds: simatic-ipc-leds-gpio: introduce more Kconfig switches

Quoted 10 lines · Henning Schild

To 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(-)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]
Acked-by on the v4 series
#16 lore raw
In reply to Henning Schild

Hi,

Quoted 2 lines · Henning Schild

changes since v3:
- add terminator entries to all gpio lookup tables as new p1

Thank you. The entire series looks good to me:

for the entire series.

Regards,

Hans

Quoted 44 lines

changes since 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.

p2 is kind of not too related to that split but also prepares for more GPIO based drivers to come.

p3 takes the driver we had and puts some of its content into a -core, to be used by the two drivers.

p4 deals with more fine-grained configuration posibilities and compile time dependencies.

Henning Schild (4):
leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables
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 |  66 +++++++++
 .../leds/simple/simatic-ipc-leds-gpio-core.c  | 104 +++++++++++++
 .../simple/simatic-ipc-leds-gpio-f7188x.c     |  66 +++++++++
 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, 293 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
Reviewed-by on the v4 series
#17 lore raw
In reply to Henning Schild
Quoted 14 lines · Henning Schild

changes since v3:
- add terminator entries to all gpio lookup tables as new p1

changes since 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.

Quoted 8 lines

p2 is kind of not too related to that split but also prepares for more GPIO based drivers to come.

p3 takes the driver we had and puts some of its content into a -core, to be used by the two drivers.

p4 deals with more fine-grained configuration posibilities and compile time dependencies.

For non-commented patches

Quoted 26 lines

Henning Schild (4):
leds: simatic-ipc-leds-gpio: add terminating entries to gpio tables
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 |  66 +++++++++
 .../leds/simple/simatic-ipc-leds-gpio-core.c  | 104 +++++++++++++
 .../simple/simatic-ipc-leds-gpio-f7188x.c     |  66 +++++++++
 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, 293 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
Signature · 2 lines
With Best Regards,
Andy Shevchenko