All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] mfd: tqmx86: new hardware and GPIO/I2C IRQ improvements/additions
@ 2024-06-17 12:22 Matthias Schiffer
  2024-06-17 12:22 ` [PATCH v2 1/5] mfd: tqmx86: add board definitions for TQMx120UC, TQMx130UC and TQMxE41S Matthias Schiffer
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Matthias Schiffer @ 2024-06-17 12:22 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, Gregor Herburger, linux, Matthias Schiffer

Patch 1 adds support for 3 new TQMx86 COMs. GPIO support on SMARC
modules is currently limited (not all GPIOs can be controlled, pins use
incorrect default directions, IRQ configuration is handled incorrectly),
however this is a preexisting issue also effecting the TQMxE39S and
TQMxE40S, not only the new TQMxE41S. This will be addressed by a future
patch series involving both the TQMx86 MFD and GPIO drivers.

Patches 2-5 improve module parameter description and error handling of
GPIO IRQ configuration and add support for configuring an IRQ for the
TQMx86's OpenCores I2C controller in the same way.

Changelog:

v2: improve module parameter description (new patch 2, adjusted patch 5)

Gregor Herburger (1):
  mfd: tqmx86: add I2C IRQ support

Matthias Schiffer (4):
  mfd: tqmx86: add board definitions for TQMx120UC, TQMx130UC and
    TQMxE41S
  mfd: tqmx86: improve gpio_irq module parameter description
  mfd: tqmx86: refactor GPIO IRQ setup
  mfd: tqmx86: make IRQ setup errors non-fatal

 drivers/mfd/tqmx86.c | 111 +++++++++++++++++++++++++++++++------------
 1 file changed, 80 insertions(+), 31 deletions(-)

-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/5] mfd: tqmx86: add board definitions for TQMx120UC, TQMx130UC and TQMxE41S
  2024-06-17 12:22 [PATCH v2 0/5] mfd: tqmx86: new hardware and GPIO/I2C IRQ improvements/additions Matthias Schiffer
@ 2024-06-17 12:22 ` Matthias Schiffer
  2024-06-17 12:22 ` [PATCH v2 2/5] mfd: tqmx86: improve gpio_irq module parameter description Matthias Schiffer
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Matthias Schiffer @ 2024-06-17 12:22 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, Gregor Herburger, linux, Matthias Schiffer

This adds support for 3 new TQMx86 COMs:

- TQMx120UC/TQMx130UC: COM Express Compact Type 6 modules with 12th and
  13th Generation Intel Core CPUs ([1, 2])
- TQMxE41S: SMARC 2.1 module with Intel Atom x7000E and compatible CPUs [3]

[1] https://www.tq-group.com/en/products/tq-embedded/x86-architecture/tqmx120uc/
[2] https://www.tq-group.com/en/products/tq-embedded/x86-architecture/tqmx130uc/
[3] https://www.tq-group.com/en/products/tq-embedded/x86-architecture/tqmxe41s/

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---

v2: no changes

 drivers/mfd/tqmx86.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
index fac02875fe7d9..e15b9be98c2db 100644
--- a/drivers/mfd/tqmx86.c
+++ b/drivers/mfd/tqmx86.c
@@ -35,11 +35,14 @@
 #define TQMX86_REG_BOARD_ID_E39C2	7
 #define TQMX86_REG_BOARD_ID_70EB	8
 #define TQMX86_REG_BOARD_ID_80UC	9
+#define TQMX86_REG_BOARD_ID_120UC	10
 #define TQMX86_REG_BOARD_ID_110EB	11
 #define TQMX86_REG_BOARD_ID_E40M	12
 #define TQMX86_REG_BOARD_ID_E40S	13
 #define TQMX86_REG_BOARD_ID_E40C1	14
 #define TQMX86_REG_BOARD_ID_E40C2	15
+#define TQMX86_REG_BOARD_ID_130UC	16
+#define TQMX86_REG_BOARD_ID_E41S	19
 #define TQMX86_REG_BOARD_REV	0x01
 #define TQMX86_REG_IO_EXT_INT	0x06
 #define TQMX86_REG_IO_EXT_INT_NONE		0
@@ -132,6 +135,8 @@ static const char *tqmx86_board_id_to_name(u8 board_id, u8 sauc)
 		return "TQMx70EB";
 	case TQMX86_REG_BOARD_ID_80UC:
 		return "TQMx80UC";
+	case TQMX86_REG_BOARD_ID_120UC:
+		return "TQMx120UC";
 	case TQMX86_REG_BOARD_ID_110EB:
 		return "TQMx110EB";
 	case TQMX86_REG_BOARD_ID_E40M:
@@ -142,6 +147,10 @@ static const char *tqmx86_board_id_to_name(u8 board_id, u8 sauc)
 		return "TQMxE40C1";
 	case TQMX86_REG_BOARD_ID_E40C2:
 		return "TQMxE40C2";
+	case TQMX86_REG_BOARD_ID_130UC:
+		return "TQMx130UC";
+	case TQMX86_REG_BOARD_ID_E41S:
+		return "TQMxE41S";
 	default:
 		return "Unknown";
 	}
@@ -154,11 +163,14 @@ static int tqmx86_board_id_to_clk_rate(struct device *dev, u8 board_id)
 	case TQMX86_REG_BOARD_ID_60EB:
 	case TQMX86_REG_BOARD_ID_70EB:
 	case TQMX86_REG_BOARD_ID_80UC:
+	case TQMX86_REG_BOARD_ID_120UC:
 	case TQMX86_REG_BOARD_ID_110EB:
 	case TQMX86_REG_BOARD_ID_E40M:
 	case TQMX86_REG_BOARD_ID_E40S:
 	case TQMX86_REG_BOARD_ID_E40C1:
 	case TQMX86_REG_BOARD_ID_E40C2:
+	case TQMX86_REG_BOARD_ID_130UC:
+	case TQMX86_REG_BOARD_ID_E41S:
 		return 24000;
 	case TQMX86_REG_BOARD_ID_E39MS:
 	case TQMX86_REG_BOARD_ID_E39C1:
-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/5] mfd: tqmx86: improve gpio_irq module parameter description
  2024-06-17 12:22 [PATCH v2 0/5] mfd: tqmx86: new hardware and GPIO/I2C IRQ improvements/additions Matthias Schiffer
  2024-06-17 12:22 ` [PATCH v2 1/5] mfd: tqmx86: add board definitions for TQMx120UC, TQMx130UC and TQMxE41S Matthias Schiffer
@ 2024-06-17 12:22 ` Matthias Schiffer
  2024-06-17 12:23 ` [PATCH v2 3/5] mfd: tqmx86: refactor GPIO IRQ setup Matthias Schiffer
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Matthias Schiffer @ 2024-06-17 12:22 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, Gregor Herburger, linux, Matthias Schiffer

Clarify that "7, 9, 12" refers to the valid arguments that can be
passed as gpio_irq.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---

v2: new patch

 drivers/mfd/tqmx86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
index e15b9be98c2db..7b2f9490a9af5 100644
--- a/drivers/mfd/tqmx86.c
+++ b/drivers/mfd/tqmx86.c
@@ -58,7 +58,7 @@
 
 static uint gpio_irq;
 module_param(gpio_irq, uint, 0);
-MODULE_PARM_DESC(gpio_irq, "GPIO IRQ number (7, 9, 12)");
+MODULE_PARM_DESC(gpio_irq, "GPIO IRQ number (valid parameters: 7, 9, 12)");
 
 static const struct resource tqmx_i2c_soft_resources[] = {
 	DEFINE_RES_IO(TQMX86_IOBASE_I2C, TQMX86_IOSIZE_I2C),
-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/5] mfd: tqmx86: refactor GPIO IRQ setup
  2024-06-17 12:22 [PATCH v2 0/5] mfd: tqmx86: new hardware and GPIO/I2C IRQ improvements/additions Matthias Schiffer
  2024-06-17 12:22 ` [PATCH v2 1/5] mfd: tqmx86: add board definitions for TQMx120UC, TQMx130UC and TQMxE41S Matthias Schiffer
  2024-06-17 12:22 ` [PATCH v2 2/5] mfd: tqmx86: improve gpio_irq module parameter description Matthias Schiffer
@ 2024-06-17 12:23 ` Matthias Schiffer
  2024-06-17 12:23 ` [PATCH v2 4/5] mfd: tqmx86: make IRQ setup errors non-fatal Matthias Schiffer
  2024-06-17 12:23 ` [PATCH v2 5/5] mfd: tqmx86: add I2C IRQ support Matthias Schiffer
  4 siblings, 0 replies; 9+ messages in thread
From: Matthias Schiffer @ 2024-06-17 12:23 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, Gregor Herburger, linux, Matthias Schiffer

Move IRQ setup into a helper function. The string "GPIO" for error
messages is replaced with a label argument to prepare for reusing the
function for the I2C IRQ.

No functional change intended.

Co-developed-by: Gregor Herburger <gregor.herburger@tq-group.com>
Signed-off-by: Gregor Herburger <gregor.herburger@tq-group.com>
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---

v2: no changes (was patch 2/4)

 drivers/mfd/tqmx86.c | 72 +++++++++++++++++++++++++++-----------------
 1 file changed, 45 insertions(+), 27 deletions(-)

diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
index 7b2f9490a9af5..5aa51ead00a28 100644
--- a/drivers/mfd/tqmx86.c
+++ b/drivers/mfd/tqmx86.c
@@ -186,32 +186,54 @@ static int tqmx86_board_id_to_clk_rate(struct device *dev, u8 board_id)
 	}
 }
 
-static int tqmx86_probe(struct platform_device *pdev)
+static int tqmx86_irq_to_irq_cfg(struct device *dev, const char *label, u8 irq)
 {
-	u8 board_id, sauc, rev, i2c_det, io_ext_int_val;
-	struct device *dev = &pdev->dev;
-	u8 gpio_irq_cfg, readback;
-	const char *board_name;
-	void __iomem *io_base;
-	int err;
-
-	switch (gpio_irq) {
+	switch (irq) {
 	case 0:
-		gpio_irq_cfg = TQMX86_REG_IO_EXT_INT_NONE;
-		break;
+		return TQMX86_REG_IO_EXT_INT_NONE;
 	case 7:
-		gpio_irq_cfg = TQMX86_REG_IO_EXT_INT_7;
-		break;
+		return TQMX86_REG_IO_EXT_INT_7;
 	case 9:
-		gpio_irq_cfg = TQMX86_REG_IO_EXT_INT_9;
-		break;
+		return TQMX86_REG_IO_EXT_INT_9;
 	case 12:
-		gpio_irq_cfg = TQMX86_REG_IO_EXT_INT_12;
-		break;
+		return TQMX86_REG_IO_EXT_INT_12;
 	default:
-		pr_err("tqmx86: Invalid GPIO IRQ (%d)\n", gpio_irq);
+		dev_err(dev, "invalid %s IRQ (%d)\n", label, irq);
 		return -EINVAL;
 	}
+}
+
+static int tqmx86_setup_irq(struct device *dev, const char *label, u8 irq,
+			    void __iomem *io_base, u8 reg_shift)
+{
+	u8 val, readback;
+	int irq_cfg;
+
+	irq_cfg = tqmx86_irq_to_irq_cfg(dev, label, irq);
+	if (irq_cfg < 0)
+		return irq_cfg;
+
+	val = ioread8(io_base + TQMX86_REG_IO_EXT_INT);
+	val &= ~(TQMX86_REG_IO_EXT_INT_MASK << reg_shift);
+	val |= (irq_cfg & TQMX86_REG_IO_EXT_INT_MASK) << reg_shift;
+
+	iowrite8(val, io_base + TQMX86_REG_IO_EXT_INT);
+	readback = ioread8(io_base + TQMX86_REG_IO_EXT_INT);
+	if (readback != val) {
+		dev_warn(dev, "%s interrupts not supported\n", label);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int tqmx86_probe(struct platform_device *pdev)
+{
+	u8 board_id, sauc, rev, i2c_det;
+	struct device *dev = &pdev->dev;
+	const char *board_name;
+	void __iomem *io_base;
+	int err;
 
 	io_base = devm_ioport_map(dev, TQMX86_IOBASE, TQMX86_IOSIZE);
 	if (!io_base)
@@ -233,15 +255,11 @@ static int tqmx86_probe(struct platform_device *pdev)
 	 */
 	i2c_det = inb(TQMX86_REG_I2C_DETECT);
 
-	if (gpio_irq_cfg) {
-		io_ext_int_val =
-			gpio_irq_cfg << TQMX86_REG_IO_EXT_INT_GPIO_SHIFT;
-		iowrite8(io_ext_int_val, io_base + TQMX86_REG_IO_EXT_INT);
-		readback = ioread8(io_base + TQMX86_REG_IO_EXT_INT);
-		if (readback != io_ext_int_val) {
-			dev_warn(dev, "GPIO interrupts not supported.\n");
-			return -EINVAL;
-		}
+	if (gpio_irq) {
+		err = tqmx86_setup_irq(dev, "GPIO", gpio_irq, io_base,
+				       TQMX86_REG_IO_EXT_INT_GPIO_SHIFT);
+		if (err)
+			return err;
 
 		/* Assumes the IRQ resource is first. */
 		tqmx_gpio_resources[0].start = gpio_irq;
-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 4/5] mfd: tqmx86: make IRQ setup errors non-fatal
  2024-06-17 12:22 [PATCH v2 0/5] mfd: tqmx86: new hardware and GPIO/I2C IRQ improvements/additions Matthias Schiffer
                   ` (2 preceding siblings ...)
  2024-06-17 12:23 ` [PATCH v2 3/5] mfd: tqmx86: refactor GPIO IRQ setup Matthias Schiffer
@ 2024-06-17 12:23 ` Matthias Schiffer
  2024-06-20 16:35   ` Lee Jones
  2024-06-17 12:23 ` [PATCH v2 5/5] mfd: tqmx86: add I2C IRQ support Matthias Schiffer
  4 siblings, 1 reply; 9+ messages in thread
From: Matthias Schiffer @ 2024-06-17 12:23 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, Gregor Herburger, linux, Matthias Schiffer

GPIO IRQ setup can fail either because an invalid IRQ was passed as a
parameter, or because the GPIO controller does not support interrupts.
Neither is severe enough to stop the whole probe; simply disable IRQ
support in the GPIO resource when setup fails.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---

v2: no changes (was patch 3/4)

 drivers/mfd/tqmx86.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
index 5aa51ead00a28..7f9ccd83278dd 100644
--- a/drivers/mfd/tqmx86.c
+++ b/drivers/mfd/tqmx86.c
@@ -259,13 +259,14 @@ static int tqmx86_probe(struct platform_device *pdev)
 		err = tqmx86_setup_irq(dev, "GPIO", gpio_irq, io_base,
 				       TQMX86_REG_IO_EXT_INT_GPIO_SHIFT);
 		if (err)
-			return err;
+			gpio_irq = 0;
+	}
 
+	if (gpio_irq)
 		/* Assumes the IRQ resource is first. */
 		tqmx_gpio_resources[0].start = gpio_irq;
-	} else {
+	else
 		tqmx_gpio_resources[0].flags = 0;
-	}
 
 	ocores_platform_data.clock_khz = tqmx86_board_id_to_clk_rate(dev, board_id);
 
-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 5/5] mfd: tqmx86: add I2C IRQ support
  2024-06-17 12:22 [PATCH v2 0/5] mfd: tqmx86: new hardware and GPIO/I2C IRQ improvements/additions Matthias Schiffer
                   ` (3 preceding siblings ...)
  2024-06-17 12:23 ` [PATCH v2 4/5] mfd: tqmx86: make IRQ setup errors non-fatal Matthias Schiffer
@ 2024-06-17 12:23 ` Matthias Schiffer
  4 siblings, 0 replies; 9+ messages in thread
From: Matthias Schiffer @ 2024-06-17 12:23 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, Gregor Herburger, linux, Matthias Schiffer

From: Gregor Herburger <gregor.herburger@tq-group.com>

The i2c-ocores controller can run in interrupt mode on tqmx86 modules.
Add module parameter to allow configuring the IRQ number, similar to the
handling of the GPIO IRQ.

Signed-off-by: Gregor Herburger <gregor.herburger@tq-group.com>
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---

v2: improve module parameter description (was patch 4/4)

 drivers/mfd/tqmx86.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
index 7f9ccd83278dd..dcd5fa3e18c50 100644
--- a/drivers/mfd/tqmx86.c
+++ b/drivers/mfd/tqmx86.c
@@ -50,6 +50,7 @@
 #define TQMX86_REG_IO_EXT_INT_9			2
 #define TQMX86_REG_IO_EXT_INT_12		3
 #define TQMX86_REG_IO_EXT_INT_MASK		0x3
+#define TQMX86_REG_IO_EXT_INT_I2C_SHIFT		0
 #define TQMX86_REG_IO_EXT_INT_GPIO_SHIFT	4
 #define TQMX86_REG_SAUC		0x17
 
@@ -60,7 +61,12 @@ static uint gpio_irq;
 module_param(gpio_irq, uint, 0);
 MODULE_PARM_DESC(gpio_irq, "GPIO IRQ number (valid parameters: 7, 9, 12)");
 
-static const struct resource tqmx_i2c_soft_resources[] = {
+static uint i2c_irq;
+module_param(i2c_irq, uint, 0);
+MODULE_PARM_DESC(i2c_irq, "I2C IRQ number (valid parameters: 7, 9, 12)");
+
+static struct resource tqmx_i2c_soft_resources[] = {
+	DEFINE_RES_IRQ(0),
 	DEFINE_RES_IO(TQMX86_IOBASE_I2C, TQMX86_IOSIZE_I2C),
 };
 
@@ -271,6 +277,18 @@ static int tqmx86_probe(struct platform_device *pdev)
 	ocores_platform_data.clock_khz = tqmx86_board_id_to_clk_rate(dev, board_id);
 
 	if (i2c_det == TQMX86_REG_I2C_DETECT_SOFT) {
+		if (i2c_irq) {
+			err = tqmx86_setup_irq(dev, "I2C", i2c_irq, io_base,
+					       TQMX86_REG_IO_EXT_INT_I2C_SHIFT);
+			if (err)
+				i2c_irq = 0;
+		}
+
+		if (i2c_irq)
+			tqmx_i2c_soft_resources[0].start = i2c_irq;
+		else
+			tqmx_i2c_soft_resources[0].flags = 0;
+
 		err = devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE,
 					   tqmx86_i2c_soft_dev,
 					   ARRAY_SIZE(tqmx86_i2c_soft_dev),
-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 4/5] mfd: tqmx86: make IRQ setup errors non-fatal
  2024-06-17 12:23 ` [PATCH v2 4/5] mfd: tqmx86: make IRQ setup errors non-fatal Matthias Schiffer
@ 2024-06-20 16:35   ` Lee Jones
  2024-06-24  7:43     ` Matthias Schiffer
  0 siblings, 1 reply; 9+ messages in thread
From: Lee Jones @ 2024-06-20 16:35 UTC (permalink / raw)
  To: Matthias Schiffer; +Cc: linux-kernel, Gregor Herburger, linux

On Mon, 17 Jun 2024, Matthias Schiffer wrote:

> GPIO IRQ setup can fail either because an invalid IRQ was passed as a
> parameter, or because the GPIO controller does not support interrupts.
> Neither is severe enough to stop the whole probe; simply disable IRQ
> support in the GPIO resource when setup fails.
> 
> Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> ---
> 
> v2: no changes (was patch 3/4)
> 
>  drivers/mfd/tqmx86.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
> index 5aa51ead00a28..7f9ccd83278dd 100644
> --- a/drivers/mfd/tqmx86.c
> +++ b/drivers/mfd/tqmx86.c
> @@ -259,13 +259,14 @@ static int tqmx86_probe(struct platform_device *pdev)
>  		err = tqmx86_setup_irq(dev, "GPIO", gpio_irq, io_base,
>  				       TQMX86_REG_IO_EXT_INT_GPIO_SHIFT);
>  		if (err)
> -			return err;
> +			gpio_irq = 0;
> +	}
>  
> +	if (gpio_irq)

Stacking identical if()s one after another doesn't sound very efficient.

Why not put the contents of this one inside the one above?

>  		/* Assumes the IRQ resource is first. */
>  		tqmx_gpio_resources[0].start = gpio_irq;
> -	} else {
> +	else
>  		tqmx_gpio_resources[0].flags = 0;
> -	}
>  
>  	ocores_platform_data.clock_khz = tqmx86_board_id_to_clk_rate(dev, board_id);
>  
> -- 
> TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
> Amtsgericht München, HRB 105018
> Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
> https://www.tq-group.com/
> 

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 4/5] mfd: tqmx86: make IRQ setup errors non-fatal
  2024-06-20 16:35   ` Lee Jones
@ 2024-06-24  7:43     ` Matthias Schiffer
  2024-06-24 10:47       ` Lee Jones
  0 siblings, 1 reply; 9+ messages in thread
From: Matthias Schiffer @ 2024-06-24  7:43 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, Gregor Herburger, linux

On Thu, 2024-06-20 at 17:35 +0100, Lee Jones wrote:
> 
> On Mon, 17 Jun 2024, Matthias Schiffer wrote:
> 
> > GPIO IRQ setup can fail either because an invalid IRQ was passed as a
> > parameter, or because the GPIO controller does not support interrupts.
> > Neither is severe enough to stop the whole probe; simply disable IRQ
> > support in the GPIO resource when setup fails.
> > 
> > Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> > ---
> > 
> > v2: no changes (was patch 3/4)
> > 
> >  drivers/mfd/tqmx86.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
> > index 5aa51ead00a28..7f9ccd83278dd 100644
> > --- a/drivers/mfd/tqmx86.c
> > +++ b/drivers/mfd/tqmx86.c
> > @@ -259,13 +259,14 @@ static int tqmx86_probe(struct platform_device *pdev)
> >  		err = tqmx86_setup_irq(dev, "GPIO", gpio_irq, io_base,
> >  				       TQMX86_REG_IO_EXT_INT_GPIO_SHIFT);
> >  		if (err)
> > -			return err;
> > +			gpio_irq = 0;
> > +	}
> >  
> > +	if (gpio_irq)
> 
> Stacking identical if()s one after another doesn't sound very efficient.
> 
> Why not put the contents of this one inside the one above?

The intention was to have the "else" branch be executed both when gpio_irq was reset to 0 in the
above error path, and when gpio_irq was 0 in the first place (so the above section running
tqmx86_setup_irq() hasn't even been executed).

I got a better idea now however - by initializing flags to 0 and only setting it together with the
IRQ in the success path, no (!gpio_irq) branch is needed here at all. Will change in v3.

Best regards,
Matthias



> 
> >  		/* Assumes the IRQ resource is first. */
> >  		tqmx_gpio_resources[0].start = gpio_irq;
> > -	} else {
> > +	else
> >  		tqmx_gpio_resources[0].flags = 0;
> > -	}
> >  
> >  	ocores_platform_data.clock_khz = tqmx86_board_id_to_clk_rate(dev, board_id);
> >  
> > -- 
> > TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
> > Amtsgericht München, HRB 105018
> > Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
> > https://www.tq-group.com/
> > 
> 

-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 4/5] mfd: tqmx86: make IRQ setup errors non-fatal
  2024-06-24  7:43     ` Matthias Schiffer
@ 2024-06-24 10:47       ` Lee Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2024-06-24 10:47 UTC (permalink / raw)
  To: Matthias Schiffer; +Cc: linux-kernel, Gregor Herburger, linux

On Mon, 24 Jun 2024, Matthias Schiffer wrote:

> On Thu, 2024-06-20 at 17:35 +0100, Lee Jones wrote:
> > 
> > On Mon, 17 Jun 2024, Matthias Schiffer wrote:
> > 
> > > GPIO IRQ setup can fail either because an invalid IRQ was passed as a
> > > parameter, or because the GPIO controller does not support interrupts.
> > > Neither is severe enough to stop the whole probe; simply disable IRQ
> > > support in the GPIO resource when setup fails.
> > > 
> > > Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> > > ---
> > > 
> > > v2: no changes (was patch 3/4)
> > > 
> > >  drivers/mfd/tqmx86.c | 7 ++++---
> > >  1 file changed, 4 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
> > > index 5aa51ead00a28..7f9ccd83278dd 100644
> > > --- a/drivers/mfd/tqmx86.c
> > > +++ b/drivers/mfd/tqmx86.c
> > > @@ -259,13 +259,14 @@ static int tqmx86_probe(struct platform_device *pdev)
> > >  		err = tqmx86_setup_irq(dev, "GPIO", gpio_irq, io_base,
> > >  				       TQMX86_REG_IO_EXT_INT_GPIO_SHIFT);
> > >  		if (err)
> > > -			return err;
> > > +			gpio_irq = 0;
> > > +	}
> > >  
> > > +	if (gpio_irq)
> > 
> > Stacking identical if()s one after another doesn't sound very efficient.
> > 
> > Why not put the contents of this one inside the one above?
> 
> The intention was to have the "else" branch be executed both when gpio_irq was reset to 0 in the
> above error path, and when gpio_irq was 0 in the first place (so the above section running
> tqmx86_setup_irq() hasn't even been executed).
> 
> I got a better idea now however - by initializing flags to 0 and only setting it together with the
> IRQ in the success path, no (!gpio_irq) branch is needed here at all. Will change in v3.

That sounds like a better approach, thanks.

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-06-24 10:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-17 12:22 [PATCH v2 0/5] mfd: tqmx86: new hardware and GPIO/I2C IRQ improvements/additions Matthias Schiffer
2024-06-17 12:22 ` [PATCH v2 1/5] mfd: tqmx86: add board definitions for TQMx120UC, TQMx130UC and TQMxE41S Matthias Schiffer
2024-06-17 12:22 ` [PATCH v2 2/5] mfd: tqmx86: improve gpio_irq module parameter description Matthias Schiffer
2024-06-17 12:23 ` [PATCH v2 3/5] mfd: tqmx86: refactor GPIO IRQ setup Matthias Schiffer
2024-06-17 12:23 ` [PATCH v2 4/5] mfd: tqmx86: make IRQ setup errors non-fatal Matthias Schiffer
2024-06-20 16:35   ` Lee Jones
2024-06-24  7:43     ` Matthias Schiffer
2024-06-24 10:47       ` Lee Jones
2024-06-17 12:23 ` [PATCH v2 5/5] mfd: tqmx86: add I2C IRQ support Matthias Schiffer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.