diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-03-26 12:49:15 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-04-05 14:18:07 -0400 |
commit | c9fbf7e070bbf9cc7adc1420df87706c62cb04ed (patch) | |
tree | 38770c150750f3f11b59643302312762494b546e /include/linux/mfd | |
parent | 8c0d8fa26ba5ec1f69e88044c671dab58c51e0e1 (diff) |
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>
Diffstat (limited to 'include/linux/mfd')
-rw-r--r-- | include/linux/mfd/wm8994/core.h | 53 | ||||
-rw-r--r-- | include/linux/mfd/wm8994/pdata.h | 1 |
2 files changed, 53 insertions, 1 deletions
diff --git a/include/linux/mfd/wm8994/core.h b/include/linux/mfd/wm8994/core.h index b06ff2846748..de79baee4925 100644 --- a/include/linux/mfd/wm8994/core.h +++ b/include/linux/mfd/wm8994/core.h | |||
@@ -15,14 +15,38 @@ | |||
15 | #ifndef __MFD_WM8994_CORE_H__ | 15 | #ifndef __MFD_WM8994_CORE_H__ |
16 | #define __MFD_WM8994_CORE_H__ | 16 | #define __MFD_WM8994_CORE_H__ |
17 | 17 | ||
18 | #include <linux/interrupt.h> | ||
19 | |||
18 | struct regulator_dev; | 20 | struct regulator_dev; |
19 | struct regulator_bulk_data; | 21 | struct regulator_bulk_data; |
20 | 22 | ||
21 | #define WM8994_NUM_GPIO_REGS 11 | 23 | #define WM8994_NUM_GPIO_REGS 11 |
22 | #define WM8994_NUM_LDO_REGS 2 | 24 | #define WM8994_NUM_LDO_REGS 2 |
25 | #define WM8994_NUM_IRQ_REGS 2 | ||
26 | |||
27 | #define WM8994_IRQ_TEMP_SHUT 0 | ||
28 | #define WM8994_IRQ_MIC1_DET 1 | ||
29 | #define WM8994_IRQ_MIC1_SHRT 2 | ||
30 | #define WM8994_IRQ_MIC2_DET 3 | ||
31 | #define WM8994_IRQ_MIC2_SHRT 4 | ||
32 | #define WM8994_IRQ_FLL1_LOCK 5 | ||
33 | #define WM8994_IRQ_FLL2_LOCK 6 | ||
34 | #define WM8994_IRQ_SRC1_LOCK 7 | ||
35 | #define WM8994_IRQ_SRC2_LOCK 8 | ||
36 | #define WM8994_IRQ_AIF1DRC1_SIG_DET 9 | ||
37 | #define WM8994_IRQ_AIF1DRC2_SIG_DET 10 | ||
38 | #define WM8994_IRQ_AIF2DRC_SIG_DET 11 | ||
39 | #define WM8994_IRQ_FIFOS_ERR 12 | ||
40 | #define WM8994_IRQ_WSEQ_DONE 13 | ||
41 | #define WM8994_IRQ_DCS_DONE 14 | ||
42 | #define WM8994_IRQ_TEMP_WARN 15 | ||
43 | |||
44 | /* GPIOs in the chip are numbered from 1-11 */ | ||
45 | #define WM8994_IRQ_GPIO(x) (x + WM8994_IRQ_TEMP_WARN) | ||
23 | 46 | ||
24 | struct wm8994 { | 47 | struct wm8994 { |
25 | struct mutex io_lock; | 48 | struct mutex io_lock; |
49 | struct mutex irq_lock; | ||
26 | 50 | ||
27 | struct device *dev; | 51 | struct device *dev; |
28 | int (*read_dev)(struct wm8994 *wm8994, unsigned short reg, | 52 | int (*read_dev)(struct wm8994 *wm8994, unsigned short reg, |
@@ -33,6 +57,11 @@ struct wm8994 { | |||
33 | void *control_data; | 57 | void *control_data; |
34 | 58 | ||
35 | int gpio_base; | 59 | int gpio_base; |
60 | int irq_base; | ||
61 | |||
62 | int irq; | ||
63 | u16 irq_masks_cur[WM8994_NUM_IRQ_REGS]; | ||
64 | u16 irq_masks_cache[WM8994_NUM_IRQ_REGS]; | ||
36 | 65 | ||
37 | /* Used over suspend/resume */ | 66 | /* Used over suspend/resume */ |
38 | u16 ldo_regs[WM8994_NUM_LDO_REGS]; | 67 | u16 ldo_regs[WM8994_NUM_LDO_REGS]; |
@@ -51,4 +80,26 @@ int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg, | |||
51 | int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg, | 80 | int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg, |
52 | int count, u16 *buf); | 81 | int count, u16 *buf); |
53 | 82 | ||
83 | |||
84 | /* Helper to save on boilerplate */ | ||
85 | static inline int wm8994_request_irq(struct wm8994 *wm8994, int irq, | ||
86 | irq_handler_t handler, const char *name, | ||
87 | void *data) | ||
88 | { | ||
89 | if (!wm8994->irq_base) | ||
90 | return -EINVAL; | ||
91 | return request_threaded_irq(wm8994->irq_base + irq, NULL, handler, | ||
92 | IRQF_TRIGGER_RISING, name, | ||
93 | data); | ||
94 | } | ||
95 | static inline void wm8994_free_irq(struct wm8994 *wm8994, int irq, void *data) | ||
96 | { | ||
97 | if (!wm8994->irq_base) | ||
98 | return; | ||
99 | free_irq(wm8994->irq_base + irq, data); | ||
100 | } | ||
101 | |||
102 | int wm8994_irq_init(struct wm8994 *wm8994); | ||
103 | void wm8994_irq_exit(struct wm8994 *wm8994); | ||
104 | |||
54 | #endif | 105 | #endif |
diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h index 70d6a8687dc5..5c51f367c061 100644 --- a/include/linux/mfd/wm8994/pdata.h +++ b/include/linux/mfd/wm8994/pdata.h | |||
@@ -70,6 +70,7 @@ struct wm8994_pdata { | |||
70 | 70 | ||
71 | struct wm8994_ldo_pdata ldo[WM8994_NUM_LDO]; | 71 | struct wm8994_ldo_pdata ldo[WM8994_NUM_LDO]; |
72 | 72 | ||
73 | int irq_base; /** Base IRQ number for WM8994, required for IRQs */ | ||
73 | 74 | ||
74 | int num_drc_cfgs; | 75 | int num_drc_cfgs; |
75 | struct wm8994_drc_cfg *drc_cfgs; | 76 | struct wm8994_drc_cfg *drc_cfgs; |