Skip to content

Commit 2b40459

Browse files
Yadwinder Singh BrarSamuel Ortiz
authored andcommitted
mfd: Allow to specify max77686 interrupt through DT or platform file also
Presently driver expects irq_gpio pin in platform data and maps it to irq itself. But we can also directly specify the interrupt in DT or platform file. Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 9bdf9b4 commit 2b40459

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

‎drivers/mfd/max77686-irq.c‎

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -252,21 +252,28 @@ int max77686_irq_init(struct max77686_dev *max77686)
252252

253253
mutex_init(&max77686->irqlock);
254254

255-
max77686->irq = gpio_to_irq(max77686->irq_gpio);
256-
257-
if (debug_mask & MAX77686_DEBUG_IRQ_INT) {
258-
ret = gpio_request(max77686->irq_gpio, "pmic_irq");
259-
if (ret < 0) {
260-
dev_err(max77686->dev,
261-
"Failed to request gpio %d with ret: %d\n",
262-
max77686->irq_gpio, ret);
263-
return IRQ_NONE;
255+
if (max77686->irq_gpio && !max77686->irq) {
256+
max77686->irq = gpio_to_irq(max77686->irq_gpio);
257+
258+
if (debug_mask & MAX77686_DEBUG_IRQ_INT) {
259+
ret = gpio_request(max77686->irq_gpio, "pmic_irq");
260+
if (ret < 0) {
261+
dev_err(max77686->dev,
262+
"Failed to request gpio %d with ret:"
263+
"%d\n", max77686->irq_gpio, ret);
264+
return IRQ_NONE;
265+
}
266+
267+
gpio_direction_input(max77686->irq_gpio);
268+
val = gpio_get_value(max77686->irq_gpio);
269+
gpio_free(max77686->irq_gpio);
270+
pr_info("%s: gpio_irq=%x\n", __func__, val);
264271
}
272+
}
265273

266-
gpio_direction_input(max77686->irq_gpio);
267-
val = gpio_get_value(max77686->irq_gpio);
268-
gpio_free(max77686->irq_gpio);
269-
pr_info("%s: gpio_irq=%x\n", __func__, val);
274+
if (!max77686->irq) {
275+
dev_err(max77686->dev, "irq is not specified\n");
276+
return -ENODEV;
270277
}
271278

272279
/* Mask individual interrupt sources */

‎drivers/mfd/max77686.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
7777

7878
max77686->wakeup = pdata->wakeup;
7979
max77686->irq_gpio = pdata->irq_gpio;
80+
max77686->irq = i2c->irq;
8081

8182
if (regmap_read(max77686->regmap,
8283
MAX77686_REG_DEVICE_ID, &data) < 0) {

0 commit comments

Comments
 (0)