Skip to contentSkip to conversation

mfd: Add WM8994 interrupt controller support

PATCH In review Mark Brown 2 participants 6 messages Mar 29, 2010 – Apr 2, 2010

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 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.

---

Since the major consumer of this is going to be the CODEC driver for the device it'd be very helpful if it were possible to merge this via ASoC, but it's a relatively big change for that.

 drivers/mfd/Kconfig              |    4 +-
 drivers/mfd/Makefile             |    2 +-
 drivers/mfd/wm8994-core.c        |   38 +++++-
 drivers/mfd/wm8994-irq.c         |  268 ++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/wm8994/core.h  |   53 ++++++++-
 include/linux/mfd/wm8994/pdata.h |    1 +
 6 files changed, 359 insertions(+), 7 deletions(-)
 create mode 100644 drivers/mfd/wm8994-irq.c
drivers/mfd/Kconfig +2 -2
index b36249f..0dfcae2 100644
@@ -301,9 +301,9 @@ config MFD_WM8350_I2C
 	  selected to enable support for the functionality of the chip.
 
 config MFD_WM8994
-	tristate "Support Wolfson Microelectronics WM8994"
+	bool "Support Wolfson Microelectronics WM8994"
 	select MFD_CORE
-	depends on I2C
+	depends on I2C=y && GENERIC_HARDIRQS
 	help
 	  The WM8994 is a highly integrated hi-fi CODEC designed for
 	  smartphone applicatiosn.  As well as audio functionality it
drivers/mfd/Makefile +1 -1
index 80fdb63..f177e06 100644
@@ -26,7 +26,7 @@ wm8350-objs			:= wm8350-core.o wm8350-regmap.o wm8350-gpio.o
 wm8350-objs			+= wm8350-irq.o
 obj-$(CONFIG_MFD_WM8350)	+= wm8350.o
 obj-$(CONFIG_MFD_WM8350_I2C)	+= wm8350-i2c.o
-obj-$(CONFIG_MFD_WM8994)	+= wm8994-core.o
+obj-$(CONFIG_MFD_WM8994)	+= wm8994-core.o wm8994-irq.o
 
 obj-$(CONFIG_TPS65010)		+= tps65010.o
 obj-$(CONFIG_MENELAUS)		+= menelaus.o
drivers/mfd/wm8994-core.c +35 -3
index cc524df..675aea5 100644
@@ -173,9 +173,34 @@ static struct mfd_cell wm8994_regulator_devs[] = {
 	{ .name = "wm8994-ldo", .id = 2 },
 };
 
+static struct resource wm8994_codec_resources[] = {
+	{
+		.start = WM8994_IRQ_TEMP_SHUT,
+		.end   = WM8994_IRQ_TEMP_WARN,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+
+static struct resource wm8994_gpio_resources[] = {
+	{
+		.start = WM8994_IRQ_GPIO(1),
+		.end   = WM8994_IRQ_GPIO(11),
+		.flags = IORESOURCE_IRQ,
+	},
+};
+
 static struct mfd_cell wm8994_devs[] = {
-	{ .name = "wm8994-codec" },
-	{ .name = "wm8994-gpio" },
+	{
+		.name = "wm8994-codec",
+		.num_resources = ARRAY_SIZE(wm8994_codec_resources),
+		.resources = wm8994_codec_resources,
+	},
+
+	{
+		.name = "wm8994-gpio",
+		.num_resources = ARRAY_SIZE(wm8994_gpio_resources),
+		.resources = wm8994_gpio_resources,
+	},
 };
 
 /*
@@ -348,6 +373,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, unsigned long id, int irq)
 
 
 	if (pdata) {
+		wm8994->irq_base = pdata->irq_base;
 		wm8994->gpio_base = pdata->gpio_base;
 
 		/* GPIO configuration is only applied if it's non-zero */
@@ -375,16 +401,20 @@ static int wm8994_device_init(struct wm8994 *wm8994, unsigned long id, int irq)
 					WM8994_LDO1_DISCH, 0);
 	}
 
+	wm8994_irq_init(wm8994);
+
 	ret = mfd_add_devices(wm8994->dev, -1,
 			      wm8994_devs, ARRAY_SIZE(wm8994_devs),
 			      NULL, 0);
 	if (ret != 0) {
 		dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
-		goto err_enable;
+		goto err_irq;
 	}
 
 	return 0;
 
+err_irq:
+	wm8994_irq_exit(wm8994);
 err_enable:
 	regulator_bulk_disable(ARRAY_SIZE(wm8994_main_supplies),
 			       wm8994->supplies);
@@ -401,6 +431,7 @@ err:
 static void wm8994_device_exit(struct wm8994 *wm8994)
 {
 	mfd_remove_devices(wm8994->dev);
+	wm8994_irq_exit(wm8994);
 	regulator_bulk_disable(ARRAY_SIZE(wm8994_main_supplies),
 			       wm8994->supplies);
 	regulator_bulk_free(ARRAY_SIZE(wm8994_main_supplies), wm8994->supplies);
@@ -469,6 +500,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c,
 	wm8994->control_data = i2c;
 	wm8994->read_dev = wm8994_i2c_read_device;
 	wm8994->write_dev = wm8994_i2c_write_device;
+	wm8994->irq = i2c->irq;
 
 	return wm8994_device_init(wm8994, id->driver_data, i2c->irq);
 }
drivers/mfd/wm8994-irq.c new file +268 -0

268 lines not on this page · raw message

include/linux/mfd/wm8994/core.h +52 -1

76 lines not on this page · raw message

include/linux/mfd/wm8994/pdata.h +1 -0
index 70d6a86..5c51f36 100644
@@ -70,6 +70,7 @@ struct wm8994_pdata {
 
 	struct wm8994_ldo_pdata ldo[WM8994_NUM_LDO];
 
+	int irq_base;  /** Base IRQ number for WM8994, required for IRQs */
 
         int num_drc_cfgs;
         struct wm8994_drc_cfg *drc_cfgs;
Signature · 1 line
1.7.0.3
author
#1 lore raw

drivers/mfd/wm8994-irq.c line 182

Quoted 1 line · Mark Brown
drivers/mfd/wm8994-irq.c new file +1 -0
+	printk(KERN_CRIT "%x %x\n", status[0], status[1]);

Clearly this is debug code and shouldn't be there in an actual version. I'll remove this when resubmitting after review & merge path are sorted out.

#2 lore raw

Hi Mark,

Quoted 7 lines · Mark Brown

drivers/mfd/wm8994-irq.c line 182

Quoted 1 line · Mark Brown
drivers/mfd/wm8994-irq.c new file +1 -0
+	printk(KERN_CRIT "%x %x\n", status[0], status[1]);

Clearly this is debug code and shouldn't be there in an actual version. I'll remove this when resubmitting after review & merge path are sorted out.

All right, I won't merge it for now.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
author
#3 lore raw
Quoted 5 lines · Samuel Ortiz

Hi Mark,

Quoted 2 lines · Mark Brown

On Mon, Mar 29, 2010 at 09:28:45PM +0100, Mark Brown wrote:

Quoted 7 lines
Quoted 5 lines

drivers/mfd/wm8994-irq.c line 182

Quoted 1 line
drivers/mfd/wm8994-irq.c new file +1 -0
+	printk(KERN_CRIT "%x %x\n", status[0], status[1]);

Clearly this is debug code and shouldn't be there in an actual version. I'll remove this when resubmitting after review & merge path are sorted out.

All right, I won't merge it for now.

Did you see the question in the original posting about where this should be merged? The bulk of the code using these interrupts will be the CODEC driver for the device, but the CODEC driver needs to be able to check if interrupts are set up at all (since commonly CODECs don't have an IRQ line wired up) so it'd be nice if it were possible to merge via ASoC.

Acked-by
#4 lore raw
Quoted 12 lines · Mark Brown
Quoted 10 lines · Samuel Ortiz

Hi Mark,

Quoted 7 lines · Mark Brown

drivers/mfd/wm8994-irq.c line 182

Quoted 1 line · Mark Brown
drivers/mfd/wm8994-irq.c new file +1 -0
+	printk(KERN_CRIT "%x %x\n", status[0], status[1]);

Clearly this is debug code and shouldn't be there in an actual version. I'll remove this when resubmitting after review & merge path are sorted out.

Quoted 4 lines
Quoted 1 line

All right, I won't merge it for now.

Did you see the question in the original posting about where this should be merged?

Sorry, I missed that part.

Quoted 5 lines

The bulk of the code using these interrupts will be the CODEC driver for the device, but the CODEC driver needs to be able to check if interrupts are set up at all (since commonly CODECs don't have an IRQ line wired up) so it'd be nice if it were possible to merge via ASoC.

I'm fine with that, please carry this patch. During the next merge window I'll wait for your code to be merged upstream, fix any potential merge conflicts and send my pull request.
Also, I had a look at the code and feel free to add my:

to it.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
author
#5 lore raw
Quoted 9 lines · Samuel Ortiz
Quoted 5 lines

The bulk of the code using these interrupts will be the CODEC driver for the device, but the CODEC driver needs to be able to check if interrupts are set up at all (since commonly CODECs don't have an IRQ line wired up) so it'd be nice if it were possible to merge via ASoC.

I'm fine with that, please carry this patch. During the next merge window I'll wait for your code to be merged upstream, fix any potential merge conflicts and send my pull request.

Thanks. I'd expect that if things are fine in -next you can probably not worry about this either way, but given that Takashi normally sends his pull request very early it probably won't make any difference anyway.

Quoted 12 lines

Also, I had a look at the code and feel free to add my:

to it.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/