Skip to content

Commit df545d1

Browse files
ldewanganSamuel Ortiz
authored andcommitted
mfd: palmas: Provide irq flags through DT/platform data
Currently driver sets the irq type to IRQF_TRIGGER_LOW which is causing interrupt registration failure in ARM based SoCs as: [ 0.208479] genirq: Setting trigger mode 8 for irq 118 failed (gic_set_type+0x0/0xf0) [ 0.208513] dummy 0-0059: Failed to request IRQ 118: -22 Provide the irq flags through platform data if device is registered through board file or get the irq type from DT node property in place of hardcoding the irq flag in driver to support multiple platforms. Also configure the device to generate the interrupt signal according to flag type. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 5c854aa commit df545d1

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

drivers/mfd/palmas.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,24 @@ static struct regmap_irq_chip palmas_irq_chip = {
257257
PALMAS_INT1_MASK),
258258
};
259259

260-
static void palmas_dt_to_pdata(struct device_node *node,
260+
static int palmas_set_pdata_irq_flag(struct i2c_client *i2c,
261261
struct palmas_platform_data *pdata)
262262
{
263+
struct irq_data *irq_data = irq_get_irq_data(i2c->irq);
264+
if (!irq_data) {
265+
dev_err(&i2c->dev, "Invalid IRQ: %d\n", i2c->irq);
266+
return -EINVAL;
267+
}
268+
269+
pdata->irq_flags = irqd_get_trigger_type(irq_data);
270+
dev_info(&i2c->dev, "Irq flag is 0x%08x\n", pdata->irq_flags);
271+
return 0;
272+
}
273+
274+
static void palmas_dt_to_pdata(struct i2c_client *i2c,
275+
struct palmas_platform_data *pdata)
276+
{
277+
struct device_node *node = i2c->dev.of_node;
263278
int ret;
264279
u32 prop;
265280

@@ -283,6 +298,8 @@ static void palmas_dt_to_pdata(struct device_node *node,
283298
pdata->power_ctrl = PALMAS_POWER_CTRL_NSLEEP_MASK |
284299
PALMAS_POWER_CTRL_ENABLE1_MASK |
285300
PALMAS_POWER_CTRL_ENABLE2_MASK;
301+
if (i2c->irq)
302+
palmas_set_pdata_irq_flag(i2c, pdata);
286303
}
287304

288305
static int palmas_i2c_probe(struct i2c_client *i2c,
@@ -304,7 +321,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
304321
if (!pdata)
305322
return -ENOMEM;
306323

307-
palmas_dt_to_pdata(node, pdata);
324+
palmas_dt_to_pdata(i2c, pdata);
308325
}
309326

310327
if (!pdata)
@@ -344,6 +361,19 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
344361
}
345362
}
346363

364+
/* Change interrupt line output polarity */
365+
if (pdata->irq_flags & IRQ_TYPE_LEVEL_HIGH)
366+
reg = PALMAS_POLARITY_CTRL_INT_POLARITY;
367+
else
368+
reg = 0;
369+
ret = palmas_update_bits(palmas, PALMAS_PU_PD_OD_BASE,
370+
PALMAS_POLARITY_CTRL, PALMAS_POLARITY_CTRL_INT_POLARITY,
371+
reg);
372+
if (ret < 0) {
373+
dev_err(palmas->dev, "POLARITY_CTRL updat failed: %d\n", ret);
374+
goto err;
375+
}
376+
347377
/* Change IRQ into clear on read mode for efficiency */
348378
slave = PALMAS_BASE_TO_SLAVE(PALMAS_INTERRUPT_BASE);
349379
addr = PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE, PALMAS_INT_CTRL);
@@ -352,7 +382,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
352382
regmap_write(palmas->regmap[slave], addr, reg);
353383

354384
ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq,
355-
IRQF_ONESHOT | IRQF_TRIGGER_LOW, 0, &palmas_irq_chip,
385+
IRQF_ONESHOT | pdata->irq_flags, 0, &palmas_irq_chip,
356386
&palmas->irq_data);
357387
if (ret < 0)
358388
goto err;

include/linux/mfd/palmas.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ struct palmas_clk_platform_data {
221221
};
222222

223223
struct palmas_platform_data {
224+
int irq_flags;
224225
int gpio_base;
225226

226227
/* bit value to be loaded to the POWER_CTRL register */

0 commit comments

Comments
 (0)