serial: 8250_pci: add support for another kind of NetMos Technology PCI 9835 Multi...
[linux/fpc-iii.git] / drivers / mfd / wm8994-irq.c
bloba050e56a9bbdcf16f200dbe363391393ce4f6756
1 /*
2 * wm8994-irq.c -- Interrupt controller support for Wolfson WM8994
4 * Copyright 2010 Wolfson Microelectronics PLC.
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
15 #include <linux/kernel.h>
16 #include <linux/module.h>
17 #include <linux/i2c.h>
18 #include <linux/irq.h>
19 #include <linux/mfd/core.h>
20 #include <linux/interrupt.h>
21 #include <linux/regmap.h>
23 #include <linux/mfd/wm8994/core.h>
24 #include <linux/mfd/wm8994/pdata.h>
25 #include <linux/mfd/wm8994/registers.h>
27 #include <linux/delay.h>
29 static struct regmap_irq wm8994_irqs[] = {
30 [WM8994_IRQ_TEMP_SHUT] = {
31 .reg_offset = 1,
32 .mask = WM8994_TEMP_SHUT_EINT,
34 [WM8994_IRQ_MIC1_DET] = {
35 .reg_offset = 1,
36 .mask = WM8994_MIC1_DET_EINT,
38 [WM8994_IRQ_MIC1_SHRT] = {
39 .reg_offset = 1,
40 .mask = WM8994_MIC1_SHRT_EINT,
42 [WM8994_IRQ_MIC2_DET] = {
43 .reg_offset = 1,
44 .mask = WM8994_MIC2_DET_EINT,
46 [WM8994_IRQ_MIC2_SHRT] = {
47 .reg_offset = 1,
48 .mask = WM8994_MIC2_SHRT_EINT,
50 [WM8994_IRQ_FLL1_LOCK] = {
51 .reg_offset = 1,
52 .mask = WM8994_FLL1_LOCK_EINT,
54 [WM8994_IRQ_FLL2_LOCK] = {
55 .reg_offset = 1,
56 .mask = WM8994_FLL2_LOCK_EINT,
58 [WM8994_IRQ_SRC1_LOCK] = {
59 .reg_offset = 1,
60 .mask = WM8994_SRC1_LOCK_EINT,
62 [WM8994_IRQ_SRC2_LOCK] = {
63 .reg_offset = 1,
64 .mask = WM8994_SRC2_LOCK_EINT,
66 [WM8994_IRQ_AIF1DRC1_SIG_DET] = {
67 .reg_offset = 1,
68 .mask = WM8994_AIF1DRC1_SIG_DET,
70 [WM8994_IRQ_AIF1DRC2_SIG_DET] = {
71 .reg_offset = 1,
72 .mask = WM8994_AIF1DRC2_SIG_DET_EINT,
74 [WM8994_IRQ_AIF2DRC_SIG_DET] = {
75 .reg_offset = 1,
76 .mask = WM8994_AIF2DRC_SIG_DET_EINT,
78 [WM8994_IRQ_FIFOS_ERR] = {
79 .reg_offset = 1,
80 .mask = WM8994_FIFOS_ERR_EINT,
82 [WM8994_IRQ_WSEQ_DONE] = {
83 .reg_offset = 1,
84 .mask = WM8994_WSEQ_DONE_EINT,
86 [WM8994_IRQ_DCS_DONE] = {
87 .reg_offset = 1,
88 .mask = WM8994_DCS_DONE_EINT,
90 [WM8994_IRQ_TEMP_WARN] = {
91 .reg_offset = 1,
92 .mask = WM8994_TEMP_WARN_EINT,
94 [WM8994_IRQ_GPIO(1)] = {
95 .mask = WM8994_GP1_EINT,
97 [WM8994_IRQ_GPIO(2)] = {
98 .mask = WM8994_GP2_EINT,
100 [WM8994_IRQ_GPIO(3)] = {
101 .mask = WM8994_GP3_EINT,
103 [WM8994_IRQ_GPIO(4)] = {
104 .mask = WM8994_GP4_EINT,
106 [WM8994_IRQ_GPIO(5)] = {
107 .mask = WM8994_GP5_EINT,
109 [WM8994_IRQ_GPIO(6)] = {
110 .mask = WM8994_GP6_EINT,
112 [WM8994_IRQ_GPIO(7)] = {
113 .mask = WM8994_GP7_EINT,
115 [WM8994_IRQ_GPIO(8)] = {
116 .mask = WM8994_GP8_EINT,
118 [WM8994_IRQ_GPIO(9)] = {
119 .mask = WM8994_GP8_EINT,
121 [WM8994_IRQ_GPIO(10)] = {
122 .mask = WM8994_GP10_EINT,
124 [WM8994_IRQ_GPIO(11)] = {
125 .mask = WM8994_GP11_EINT,
129 static struct regmap_irq_chip wm8994_irq_chip = {
130 .name = "wm8994",
131 .irqs = wm8994_irqs,
132 .num_irqs = ARRAY_SIZE(wm8994_irqs),
134 .num_regs = 2,
135 .status_base = WM8994_INTERRUPT_STATUS_1,
136 .mask_base = WM8994_INTERRUPT_STATUS_1_MASK,
137 .ack_base = WM8994_INTERRUPT_STATUS_1,
138 .runtime_pm = true,
141 int wm8994_irq_init(struct wm8994 *wm8994)
143 int ret;
144 unsigned long irqflags;
145 struct wm8994_pdata *pdata = wm8994->dev->platform_data;
147 if (!wm8994->irq) {
148 dev_warn(wm8994->dev,
149 "No interrupt specified, no interrupts\n");
150 wm8994->irq_base = 0;
151 return 0;
154 /* select user or default irq flags */
155 irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT;
156 if (pdata->irq_flags)
157 irqflags = pdata->irq_flags;
159 ret = regmap_add_irq_chip(wm8994->regmap, wm8994->irq,
160 irqflags,
161 wm8994->irq_base, &wm8994_irq_chip,
162 &wm8994->irq_data);
163 if (ret != 0) {
164 dev_err(wm8994->dev, "Failed to register IRQ chip: %d\n", ret);
165 return ret;
168 /* Enable top level interrupt if it was masked */
169 wm8994_reg_write(wm8994, WM8994_INTERRUPT_CONTROL, 0);
171 return 0;
174 void wm8994_irq_exit(struct wm8994 *wm8994)
176 regmap_del_irq_chip(wm8994->irq, wm8994->irq_data);