Skip to content

Commit c9fbf7e

Browse files
committed
mfd: Add WM8994 interrupt controller support
The WM8994 has an interrupt controller which supports interrupts for both CODEC and GPIO portions of the chip. Support this using genirq, while allowing for systems that do not have an interrupt hooked up. Wrapper functions are provided for the IRQ request and free to simplify the code in consumer drivers when handling cases where IRQs are not set up. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 8c0d8fa commit c9fbf7e

6 files changed

Lines changed: 406 additions & 7 deletions

File tree

‎drivers/mfd/Kconfig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ config MFD_WM8350_I2C
301301
selected to enable support for the functionality of the chip.
302302

303303
config MFD_WM8994
304-
tristate "Support Wolfson Microelectronics WM8994"
304+
bool "Support Wolfson Microelectronics WM8994"
305305
select MFD_CORE
306-
depends on I2C
306+
depends on I2C=y && GENERIC_HARDIRQS
307307
help
308308
The WM8994 is a highly integrated hi-fi CODEC designed for
309309
smartphone applicatiosn. As well as audio functionality it

‎drivers/mfd/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ wm8350-objs := wm8350-core.o wm8350-regmap.o wm8350-gpio.o
2626
wm8350-objs += wm8350-irq.o
2727
obj-$(CONFIG_MFD_WM8350) += wm8350.o
2828
obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o
29-
obj-$(CONFIG_MFD_WM8994) += wm8994-core.o
29+
obj-$(CONFIG_MFD_WM8994) += wm8994-core.o wm8994-irq.o
3030

3131
obj-$(CONFIG_TPS65010) += tps65010.o
3232
obj-$(CONFIG_MENELAUS) += menelaus.o

‎drivers/mfd/wm8994-core.c‎

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,34 @@ static struct mfd_cell wm8994_regulator_devs[] = {
172172
{ .name = "wm8994-ldo", .id = 2 },
173173
};
174174

175+
static struct resource wm8994_codec_resources[] = {
176+
{
177+
.start = WM8994_IRQ_TEMP_SHUT,
178+
.end = WM8994_IRQ_TEMP_WARN,
179+
.flags = IORESOURCE_IRQ,
180+
},
181+
};
182+
183+
static struct resource wm8994_gpio_resources[] = {
184+
{
185+
.start = WM8994_IRQ_GPIO(1),
186+
.end = WM8994_IRQ_GPIO(11),
187+
.flags = IORESOURCE_IRQ,
188+
},
189+
};
190+
175191
static struct mfd_cell wm8994_devs[] = {
176-
{ .name = "wm8994-codec" },
177-
{ .name = "wm8994-gpio" },
192+
{
193+
.name = "wm8994-codec",
194+
.num_resources = ARRAY_SIZE(wm8994_codec_resources),
195+
.resources = wm8994_codec_resources,
196+
},
197+
198+
{
199+
.name = "wm8994-gpio",
200+
.num_resources = ARRAY_SIZE(wm8994_gpio_resources),
201+
.resources = wm8994_gpio_resources,
202+
},
178203
};
179204

180205
/*
@@ -235,6 +260,11 @@ static int wm8994_device_resume(struct device *dev)
235260
return ret;
236261
}
237262

263+
ret = wm8994_write(wm8994, WM8994_INTERRUPT_STATUS_1_MASK,
264+
WM8994_NUM_IRQ_REGS * 2, &wm8994->irq_masks_cur);
265+
if (ret < 0)
266+
dev_err(dev, "Failed to restore interrupt masks: %d\n", ret);
267+
238268
ret = wm8994_write(wm8994, WM8994_LDO_1, WM8994_NUM_LDO_REGS * 2,
239269
&wm8994->ldo_regs);
240270
if (ret < 0)
@@ -347,6 +377,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, unsigned long id, int irq)
347377

348378

349379
if (pdata) {
380+
wm8994->irq_base = pdata->irq_base;
350381
wm8994->gpio_base = pdata->gpio_base;
351382

352383
/* GPIO configuration is only applied if it's non-zero */
@@ -374,16 +405,20 @@ static int wm8994_device_init(struct wm8994 *wm8994, unsigned long id, int irq)
374405
WM8994_LDO1_DISCH, 0);
375406
}
376407

408+
wm8994_irq_init(wm8994);
409+
377410
ret = mfd_add_devices(wm8994->dev, -1,
378411
wm8994_devs, ARRAY_SIZE(wm8994_devs),
379412
NULL, 0);
380413
if (ret != 0) {
381414
dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
382-
goto err_enable;
415+
goto err_irq;
383416
}
384417

385418
return 0;
386419

420+
err_irq:
421+
wm8994_irq_exit(wm8994);
387422
err_enable:
388423
regulator_bulk_disable(ARRAY_SIZE(wm8994_main_supplies),
389424
wm8994->supplies);
@@ -400,6 +435,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, unsigned long id, int irq)
400435
static void wm8994_device_exit(struct wm8994 *wm8994)
401436
{
402437
mfd_remove_devices(wm8994->dev);
438+
wm8994_irq_exit(wm8994);
403439
regulator_bulk_disable(ARRAY_SIZE(wm8994_main_supplies),
404440
wm8994->supplies);
405441
regulator_bulk_free(ARRAY_SIZE(wm8994_main_supplies), wm8994->supplies);
@@ -468,6 +504,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c,
468504
wm8994->control_data = i2c;
469505
wm8994->read_dev = wm8994_i2c_read_device;
470506
wm8994->write_dev = wm8994_i2c_write_device;
507+
wm8994->irq = i2c->irq;
471508

472509
return wm8994_device_init(wm8994, id->driver_data, i2c->irq);
473510
}

0 commit comments

Comments
 (0)