Skip to content

Commit 0d3f073

Browse files
gregorHerburgerlag-linaro
authored andcommitted
mfd: tqmx86: Add I2C IRQ support
The i2c-ocores controller can run in interrupt mode on tqmx86 modules. Add a module parameter to allow configuring the IRQ number, similar to the handling of the GPIO IRQ. The new code and module parameter refer to the I2C controller as "I2C1", as the TQMx86 PLD actually contains a second I2C controller, for which driver support will be added in the future. Signed-off-by: Gregor Herburger <gregor.herburger@tq-group.com> Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Link: https://lore.kernel.org/r/c1b0769e00a8a4e463cffe725e939b0e5c2992c8.1731325758.git.matthias.schiffer@ew.tq-group.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 1f86fae commit 0d3f073

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

drivers/mfd/tqmx86.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#define TQMX86_REG_IO_EXT_INT_9 2
5151
#define TQMX86_REG_IO_EXT_INT_12 3
5252
#define TQMX86_REG_IO_EXT_INT_MASK 0x3
53+
#define TQMX86_REG_IO_EXT_INT_I2C1_SHIFT 0
5354
#define TQMX86_REG_IO_EXT_INT_GPIO_SHIFT 4
5455
#define TQMX86_REG_SAUC 0x17
5556

@@ -60,8 +61,19 @@ static uint gpio_irq;
6061
module_param(gpio_irq, uint, 0);
6162
MODULE_PARM_DESC(gpio_irq, "GPIO IRQ number (valid parameters: 7, 9, 12)");
6263

63-
static const struct resource tqmx_i2c_soft_resources[] = {
64-
DEFINE_RES_IO(TQMX86_IOBASE_I2C, TQMX86_IOSIZE_I2C),
64+
static uint i2c1_irq;
65+
module_param(i2c1_irq, uint, 0);
66+
MODULE_PARM_DESC(i2c1_irq, "I2C1 IRQ number (valid parameters: 7, 9, 12)");
67+
68+
enum tqmx86_i2c1_resource_type {
69+
TQMX86_I2C1_IO,
70+
TQMX86_I2C1_IRQ,
71+
};
72+
73+
static struct resource tqmx_i2c_soft_resources[] = {
74+
[TQMX86_I2C1_IO] = DEFINE_RES_IO(TQMX86_IOBASE_I2C, TQMX86_IOSIZE_I2C),
75+
/* Placeholder for IRQ resource */
76+
[TQMX86_I2C1_IRQ] = {},
6577
};
6678

6779
static const struct resource tqmx_watchdog_resources[] = {
@@ -264,6 +276,13 @@ static int tqmx86_probe(struct platform_device *pdev)
264276
ocores_platform_data.clock_khz = tqmx86_board_id_to_clk_rate(dev, board_id);
265277

266278
if (i2c_det == TQMX86_REG_I2C_DETECT_SOFT) {
279+
if (i2c1_irq) {
280+
err = tqmx86_setup_irq(dev, "I2C1", i2c1_irq, io_base,
281+
TQMX86_REG_IO_EXT_INT_I2C1_SHIFT);
282+
if (!err)
283+
tqmx_i2c_soft_resources[TQMX86_I2C1_IRQ] = DEFINE_RES_IRQ(i2c1_irq);
284+
}
285+
267286
err = devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE,
268287
tqmx86_i2c_soft_dev,
269288
ARRAY_SIZE(tqmx86_i2c_soft_dev),

0 commit comments

Comments
 (0)