From: Gregor Herburger <[email protected]>
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 <[email protected]>
Signed-off-by: Matthias Schiffer <[email protected]>
---
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 cf27497245322..b96af7091b6bc 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 (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 (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/
On Wed, 05 Jun 2024, Matthias Schiffer wrote:
> From: Gregor Herburger <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Matthias Schiffer <[email protected]>
> ---
> 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 cf27497245322..b96af7091b6bc 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 (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 (7, 9, 12)");
Just one question; what is (7, 9, 12)?
And why is it the same as the GPIO one? Copy/paste error?
> +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/
>
--
Lee Jones [李琼斯]
On Thu, Jun 13, 2024 at 04:42:34PM +0100, Lee Jones wrote:
> Just one question; what is (7, 9, 12)?
>
> And why is it the same as the GPIO one? Copy/paste error?
>
Those are the IRQ numbers of the PLD. Both blocks, GPIO and I2C, can be
configured to use IRQ12, IRQ9 or IRQ7.
Gregor
--
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/
Note: Careful not to cut away too much context when replying.
On Fri, 14 Jun 2024, Gregor Herburger wrote:
> On Thu, Jun 13, 2024 at 04:42:34PM +0100, Lee Jones wrote:
> > Just one question; what is (7, 9, 12)?
> >
> > And why is it the same as the GPIO one? Copy/paste error?
> >
> Those are the IRQ numbers of the PLD. Both blocks, GPIO and I2C, can be
> configured to use IRQ12, IRQ9 or IRQ7.
Might I suggest we make that super clear in the help?
(IRQ7, IRQ9 {and,or} IRQ12)
Or similar.
--
Lee Jones [李琼斯]