blob: d9cf60a38ea329d3f4b3dcfc704acb0325fcc394 [file] [log] [blame]
Yeleswarapu, Nagaradheshbbba6e32013-12-20 18:09:17 +05301/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +05302 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12#include <linux/bitops.h>
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/sched.h>
16#include <linux/irq.h>
17#include <linux/mfd/core.h>
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -070018#include <linux/mfd/wcd9xxx/core-resource.h>
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053019#include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
20#include <linux/mfd/wcd9xxx/wcd9310_registers.h>
Joonwoo Parkf6574c72012-10-10 17:29:57 -070021#include <linux/delay.h>
22#include <linux/irqdomain.h>
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053023#include <linux/interrupt.h>
Joonwoo Parkf6574c72012-10-10 17:29:57 -070024#include <linux/of.h>
25#include <linux/of_irq.h>
26#include <linux/slab.h>
Joonwoo Park1c958f1a2013-04-23 19:41:46 -070027#include <linux/ratelimit.h>
Stephen Boyd2fcabf92012-05-30 10:41:11 -070028#include <mach/cpuidle.h>
29
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053030#define BYTE_BIT_MASK(nr) (1UL << ((nr) % BITS_PER_BYTE))
31#define BIT_BYTE(nr) ((nr) / BITS_PER_BYTE)
32
Joonwoo Park18383dc2012-09-20 17:45:57 -070033#define WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS 100
34
Joonwoo Parkf6574c72012-10-10 17:29:57 -070035#ifdef CONFIG_OF
36struct wcd9xxx_irq_drv_data {
37 struct irq_domain *domain;
38 int irq;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053039};
Joonwoo Parkf6574c72012-10-10 17:29:57 -070040#endif
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053041
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -070042static int virq_to_phyirq(
43 struct wcd9xxx_core_resource *wcd9xxx_res, int virq);
44static int phyirq_to_virq(
45 struct wcd9xxx_core_resource *wcd9xxx_res, int irq);
46static unsigned int wcd9xxx_irq_get_upstream_irq(
47 struct wcd9xxx_core_resource *wcd9xxx_res);
48static void wcd9xxx_irq_put_upstream_irq(
49 struct wcd9xxx_core_resource *wcd9xxx_res);
50static int wcd9xxx_map_irq(
51 struct wcd9xxx_core_resource *wcd9xxx_res, int irq);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053052
53static void wcd9xxx_irq_lock(struct irq_data *data)
54{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -070055 struct wcd9xxx_core_resource *wcd9xxx_res =
56 irq_data_get_irq_chip_data(data);
57 mutex_lock(&wcd9xxx_res->irq_lock);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053058}
59
60static void wcd9xxx_irq_sync_unlock(struct irq_data *data)
61{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -070062 struct wcd9xxx_core_resource *wcd9xxx_res =
63 irq_data_get_irq_chip_data(data);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053064 int i;
65
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -070066 if ((ARRAY_SIZE(wcd9xxx_res->irq_masks_cur) >
67 WCD9XXX_MAX_IRQ_REGS) ||
68 (ARRAY_SIZE(wcd9xxx_res->irq_masks_cache) >
69 WCD9XXX_MAX_IRQ_REGS)) {
Simmi Pateriya4fd69932012-10-26 00:57:06 +053070 pr_err("%s: Array Size out of bound\n", __func__);
71 return;
72 }
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -070073 if (!wcd9xxx_res->codec_reg_write) {
74 pr_err("%s: Codec reg write callback function not defined\n",
75 __func__);
76 return;
77 }
Simmi Pateriya4fd69932012-10-26 00:57:06 +053078
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -070079 for (i = 0; i < ARRAY_SIZE(wcd9xxx_res->irq_masks_cur); i++) {
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053080 /* If there's been a change in the mask write it back
81 * to the hardware.
82 */
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -070083 if (wcd9xxx_res->irq_masks_cur[i] !=
84 wcd9xxx_res->irq_masks_cache[i]) {
85
86 wcd9xxx_res->irq_masks_cache[i] =
87 wcd9xxx_res->irq_masks_cur[i];
88 wcd9xxx_res->codec_reg_write(wcd9xxx_res,
Joonwoo Parkf6574c72012-10-10 17:29:57 -070089 WCD9XXX_A_INTR_MASK0 + i,
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -070090 wcd9xxx_res->irq_masks_cur[i]);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053091 }
92 }
93
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -070094 mutex_unlock(&wcd9xxx_res->irq_lock);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053095}
96
97static void wcd9xxx_irq_enable(struct irq_data *data)
98{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -070099 struct wcd9xxx_core_resource *wcd9xxx_res =
100 irq_data_get_irq_chip_data(data);
101 int wcd9xxx_irq = virq_to_phyirq(wcd9xxx_res, data->irq);
102 wcd9xxx_res->irq_masks_cur[BIT_BYTE(wcd9xxx_irq)] &=
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530103 ~(BYTE_BIT_MASK(wcd9xxx_irq));
104}
105
106static void wcd9xxx_irq_disable(struct irq_data *data)
107{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700108 struct wcd9xxx_core_resource *wcd9xxx_res =
109 irq_data_get_irq_chip_data(data);
110 int wcd9xxx_irq = virq_to_phyirq(wcd9xxx_res, data->irq);
111 wcd9xxx_res->irq_masks_cur[BIT_BYTE(wcd9xxx_irq)]
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700112 |= BYTE_BIT_MASK(wcd9xxx_irq);
113}
114
115static void wcd9xxx_irq_mask(struct irq_data *d)
116{
117 /* do nothing but required as linux calls irq_mask without NULL check */
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530118}
119
120static struct irq_chip wcd9xxx_irq_chip = {
121 .name = "wcd9xxx",
122 .irq_bus_lock = wcd9xxx_irq_lock,
123 .irq_bus_sync_unlock = wcd9xxx_irq_sync_unlock,
124 .irq_disable = wcd9xxx_irq_disable,
125 .irq_enable = wcd9xxx_irq_enable,
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700126 .irq_mask = wcd9xxx_irq_mask,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530127};
128
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700129bool wcd9xxx_lock_sleep(
130 struct wcd9xxx_core_resource *wcd9xxx_res)
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530131{
132 enum wcd9xxx_pm_state os;
133
Joonwoo Park18383dc2012-09-20 17:45:57 -0700134 /*
135 * wcd9xxx_{lock/unlock}_sleep will be called by wcd9xxx_irq_thread
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530136 * and its subroutines only motly.
137 * but btn0_lpress_fn is not wcd9xxx_irq_thread's subroutine and
Joonwoo Park18383dc2012-09-20 17:45:57 -0700138 * It can race with wcd9xxx_irq_thread.
139 * So need to embrace wlock_holders with mutex.
140 *
141 * If system didn't resume, we can simply return false so codec driver's
142 * IRQ handler can return without handling IRQ.
143 * As interrupt line is still active, codec will have another IRQ to
144 * retry shortly.
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530145 */
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700146 mutex_lock(&wcd9xxx_res->pm_lock);
147 if (wcd9xxx_res->wlock_holders++ == 0) {
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -0700148 pr_debug("%s: holding wake lock\n", __func__);
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700149 pm_qos_update_request(&wcd9xxx_res->pm_qos_req,
Stephen Boyd2fcabf92012-05-30 10:41:11 -0700150 msm_cpuidle_get_deep_idle_latency());
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -0700151 }
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700152 mutex_unlock(&wcd9xxx_res->pm_lock);
Bhalchandra Gajareea7bd6f2013-10-17 15:21:25 -0700153
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700154 if (!wait_event_timeout(wcd9xxx_res->pm_wq,
Bhalchandra Gajareea7bd6f2013-10-17 15:21:25 -0700155 ((os = wcd9xxx_pm_cmpxchg(wcd9xxx_res,
156 WCD9XXX_PM_SLEEPABLE,
157 WCD9XXX_PM_AWAKE)) ==
158 WCD9XXX_PM_SLEEPABLE ||
159 (os == WCD9XXX_PM_AWAKE)),
160 msecs_to_jiffies(
161 WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS))) {
Joonwoo Park18383dc2012-09-20 17:45:57 -0700162 pr_warn("%s: system didn't resume within %dms, s %d, w %d\n",
163 __func__,
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700164 WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS, wcd9xxx_res->pm_state,
165 wcd9xxx_res->wlock_holders);
166 wcd9xxx_unlock_sleep(wcd9xxx_res);
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -0700167 return false;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530168 }
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700169 wake_up_all(&wcd9xxx_res->pm_wq);
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -0700170 return true;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530171}
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700172EXPORT_SYMBOL(wcd9xxx_lock_sleep);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530173
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700174void wcd9xxx_unlock_sleep(
175 struct wcd9xxx_core_resource *wcd9xxx_res)
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530176{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700177 mutex_lock(&wcd9xxx_res->pm_lock);
178 if (--wcd9xxx_res->wlock_holders == 0) {
Joonwoo Park18383dc2012-09-20 17:45:57 -0700179 pr_debug("%s: releasing wake lock pm_state %d -> %d\n",
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700180 __func__, wcd9xxx_res->pm_state, WCD9XXX_PM_SLEEPABLE);
Joonwoo Park18383dc2012-09-20 17:45:57 -0700181 /*
182 * if wcd9xxx_lock_sleep failed, pm_state would be still
183 * WCD9XXX_PM_ASLEEP, don't overwrite
184 */
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700185 if (likely(wcd9xxx_res->pm_state == WCD9XXX_PM_AWAKE))
186 wcd9xxx_res->pm_state = WCD9XXX_PM_SLEEPABLE;
187 pm_qos_update_request(&wcd9xxx_res->pm_qos_req,
Stephen Boyd2fcabf92012-05-30 10:41:11 -0700188 PM_QOS_DEFAULT_VALUE);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530189 }
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700190 mutex_unlock(&wcd9xxx_res->pm_lock);
191 wake_up_all(&wcd9xxx_res->pm_wq);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530192}
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700193EXPORT_SYMBOL(wcd9xxx_unlock_sleep);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530194
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700195void wcd9xxx_nested_irq_lock(struct wcd9xxx_core_resource *wcd9xxx_res)
Joonwoo Park1f9d7fd2013-01-07 12:40:03 -0800196{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700197 mutex_lock(&wcd9xxx_res->nested_irq_lock);
Joonwoo Park1f9d7fd2013-01-07 12:40:03 -0800198}
199
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700200void wcd9xxx_nested_irq_unlock(struct wcd9xxx_core_resource *wcd9xxx_res)
Joonwoo Park1f9d7fd2013-01-07 12:40:03 -0800201{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700202 mutex_unlock(&wcd9xxx_res->nested_irq_lock);
Joonwoo Park1f9d7fd2013-01-07 12:40:03 -0800203}
204
Joonwoo Park055ae4f2013-05-28 19:09:56 -0700205
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700206static void wcd9xxx_irq_dispatch(struct wcd9xxx_core_resource *wcd9xxx_res,
207 struct intr_data *irqdata)
Joonwoo Park055ae4f2013-05-28 19:09:56 -0700208{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700209 int irqbit = irqdata->intr_num;
210 if (!wcd9xxx_res->codec_reg_write) {
211 pr_err("%s: codec read/write callback not defined\n",
212 __func__);
213 return;
Joonwoo Park03324832012-03-19 19:36:16 -0700214 }
Joonwoo Park03324832012-03-19 19:36:16 -0700215
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700216 if (irqdata->clear_first) {
217 wcd9xxx_nested_irq_lock(wcd9xxx_res);
218 wcd9xxx_res->codec_reg_write(wcd9xxx_res,
219 WCD9XXX_A_INTR_CLEAR0 + BIT_BYTE(irqbit),
220 BYTE_BIT_MASK(irqbit));
221
222 if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
223 wcd9xxx_res->codec_reg_write(wcd9xxx_res,
224 WCD9XXX_A_INTR_MODE, 0x02);
225 handle_nested_irq(phyirq_to_virq(wcd9xxx_res, irqbit));
226 wcd9xxx_nested_irq_unlock(wcd9xxx_res);
227 } else {
228 wcd9xxx_nested_irq_lock(wcd9xxx_res);
229 handle_nested_irq(phyirq_to_virq(wcd9xxx_res, irqbit));
230 wcd9xxx_res->codec_reg_write(wcd9xxx_res,
231 WCD9XXX_A_INTR_CLEAR0 + BIT_BYTE(irqbit),
232 BYTE_BIT_MASK(irqbit));
233 if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
234 wcd9xxx_res->codec_reg_write(wcd9xxx_res,
235 WCD9XXX_A_INTR_MODE, 0x02);
236
237 wcd9xxx_nested_irq_unlock(wcd9xxx_res);
238 }
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700239}
240
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530241static irqreturn_t wcd9xxx_irq_thread(int irq, void *data)
242{
243 int ret;
Joonwoo Park03324832012-03-19 19:36:16 -0700244 int i;
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700245 struct intr_data irqdata;
Joonwoo Park1c958f1a2013-04-23 19:41:46 -0700246 char linebuf[128];
Joonwoo Park1c958f1a2013-04-23 19:41:46 -0700247 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 1);
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700248 struct wcd9xxx_core_resource *wcd9xxx_res = data;
249 int num_irq_regs = wcd9xxx_res->num_irq_regs;
250 u8 status[num_irq_regs], status1[num_irq_regs];
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530251
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700252 if (unlikely(wcd9xxx_lock_sleep(wcd9xxx_res) == false)) {
253 dev_err(wcd9xxx_res->dev, "Failed to hold suspend\n");
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -0700254 return IRQ_NONE;
255 }
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700256
257 if (!wcd9xxx_res->codec_bulk_read) {
258 dev_err(wcd9xxx_res->dev,
259 "%s: Codec Bulk Register read callback not supplied\n",
260 __func__);
261 goto err_disable_irq;
262 }
263
264 ret = wcd9xxx_res->codec_bulk_read(wcd9xxx_res,
265 WCD9XXX_A_INTR_STATUS0,
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700266 num_irq_regs, status);
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700267
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530268 if (ret < 0) {
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700269 dev_err(wcd9xxx_res->dev,
270 "Failed to read interrupt status: %d\n", ret);
271 goto err_disable_irq;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530272 }
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700273
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530274 /* Apply masking */
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700275 for (i = 0; i < num_irq_regs; i++)
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700276 status[i] &= ~wcd9xxx_res->irq_masks_cur[i];
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530277
Joonwoo Park1c958f1a2013-04-23 19:41:46 -0700278 memcpy(status1, status, sizeof(status1));
279
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530280 /* Find out which interrupt was triggered and call that interrupt's
281 * handler function
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700282 *
283 * Since codec has only one hardware irq line which is shared by
Joonwoo Park03324832012-03-19 19:36:16 -0700284 * codec's different internal interrupts, so it's possible master irq
285 * handler dispatches multiple nested irq handlers after breaking
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700286 * order. Dispatch interrupts in the order that is maintained by
287 * the interrupt table.
288 */
289 for (i = 0; i < wcd9xxx_res->intr_table_size; i++) {
290 irqdata = wcd9xxx_res->intr_table[i];
291 if (status[BIT_BYTE(irqdata.intr_num)] &
292 BYTE_BIT_MASK(irqdata.intr_num)) {
293 wcd9xxx_irq_dispatch(wcd9xxx_res, &irqdata);
294 status1[BIT_BYTE(irqdata.intr_num)] &=
295 ~BYTE_BIT_MASK(irqdata.intr_num);
Joonwoo Park1c958f1a2013-04-23 19:41:46 -0700296 }
297 }
298
299 /*
300 * As a failsafe if unhandled irq is found, clear it to prevent
301 * interrupt storm.
302 * Note that we can say there was an unhandled irq only when no irq
303 * handled by nested irq handler since Taiko supports qdsp as irqs'
304 * destination for few irqs. Therefore driver shouldn't clear pending
305 * irqs when few handled while few others not.
306 */
307 if (unlikely(!memcmp(status, status1, sizeof(status)))) {
308 if (__ratelimit(&ratelimit)) {
309 pr_warn("%s: Unhandled irq found\n", __func__);
310 hex_dump_to_buffer(status, sizeof(status), 16, 1,
311 linebuf, sizeof(linebuf), false);
312 pr_warn("%s: status0 : %s\n", __func__, linebuf);
313 hex_dump_to_buffer(status1, sizeof(status1), 16, 1,
314 linebuf, sizeof(linebuf), false);
315 pr_warn("%s: status1 : %s\n", __func__, linebuf);
316 }
317
Joonwoo Park66485a92013-04-25 13:06:34 -0700318 memset(status, 0xff, num_irq_regs);
Yeleswarapu, Nagaradheshbbba6e32013-12-20 18:09:17 +0530319
320 ret = wcd9xxx_res->codec_bulk_write(wcd9xxx_res,
321 WCD9XXX_A_INTR_CLEAR0,
322 num_irq_regs, status);
Joonwoo Park66485a92013-04-25 13:06:34 -0700323 if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C)
Yeleswarapu, Nagaradheshbbba6e32013-12-20 18:09:17 +0530324 wcd9xxx_res->codec_reg_write(wcd9xxx_res,
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700325 WCD9XXX_A_INTR_MODE, 0x02);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530326 }
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700327 wcd9xxx_unlock_sleep(wcd9xxx_res);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530328
329 return IRQ_HANDLED;
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700330
331err_disable_irq:
332 dev_err(wcd9xxx_res->dev,
333 "Disable irq %d\n", wcd9xxx_res->irq);
334
335 disable_irq_wake(wcd9xxx_res->irq);
336 disable_irq_nosync(wcd9xxx_res->irq);
337 wcd9xxx_unlock_sleep(wcd9xxx_res);
338 return IRQ_NONE;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530339}
340
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700341void wcd9xxx_free_irq(struct wcd9xxx_core_resource *wcd9xxx_res,
342 int irq, void *data)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700343{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700344 free_irq(phyirq_to_virq(wcd9xxx_res, irq), data);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700345}
346
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700347void wcd9xxx_enable_irq(struct wcd9xxx_core_resource *wcd9xxx_res, int irq)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700348{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700349 enable_irq(phyirq_to_virq(wcd9xxx_res, irq));
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700350}
351
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700352void wcd9xxx_disable_irq(struct wcd9xxx_core_resource *wcd9xxx_res, int irq)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700353{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700354 disable_irq_nosync(phyirq_to_virq(wcd9xxx_res, irq));
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700355}
356
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700357void wcd9xxx_disable_irq_sync(
358 struct wcd9xxx_core_resource *wcd9xxx_res, int irq)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700359{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700360 disable_irq(phyirq_to_virq(wcd9xxx_res, irq));
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700361}
362
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700363static int wcd9xxx_irq_setup_downstream_irq(
364 struct wcd9xxx_core_resource *wcd9xxx_res)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700365{
366 int irq, virq, ret;
367
368 pr_debug("%s: enter\n", __func__);
369
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700370 for (irq = 0; irq < wcd9xxx_res->num_irqs; irq++) {
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700371 /* Map OF irq */
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700372 virq = wcd9xxx_map_irq(wcd9xxx_res, irq);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700373 pr_debug("%s: irq %d -> %d\n", __func__, irq, virq);
374 if (virq == NO_IRQ) {
375 pr_err("%s, No interrupt specifier for irq %d\n",
376 __func__, irq);
377 return NO_IRQ;
378 }
379
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700380 ret = irq_set_chip_data(virq, wcd9xxx_res);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700381 if (ret) {
382 pr_err("%s: Failed to configure irq %d (%d)\n",
383 __func__, irq, ret);
384 return ret;
385 }
386
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700387 if (wcd9xxx_res->irq_level_high[irq])
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700388 irq_set_chip_and_handler(virq, &wcd9xxx_irq_chip,
389 handle_level_irq);
390 else
391 irq_set_chip_and_handler(virq, &wcd9xxx_irq_chip,
392 handle_edge_irq);
393
394 irq_set_nested_thread(virq, 1);
395 }
396
397 pr_debug("%s: leave\n", __func__);
398
399 return 0;
400}
401
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700402int wcd9xxx_irq_init(struct wcd9xxx_core_resource *wcd9xxx_res)
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530403{
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700404 int i, ret;
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700405 u8 irq_level[wcd9xxx_res->num_irq_regs];
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530406
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700407 mutex_init(&wcd9xxx_res->irq_lock);
408 mutex_init(&wcd9xxx_res->nested_irq_lock);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530409
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700410 wcd9xxx_res->irq = wcd9xxx_irq_get_upstream_irq(wcd9xxx_res);
411 if (!wcd9xxx_res->irq) {
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700412 pr_warn("%s: irq driver is not yet initialized\n", __func__);
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700413 mutex_destroy(&wcd9xxx_res->irq_lock);
414 mutex_destroy(&wcd9xxx_res->nested_irq_lock);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700415 return -EPROBE_DEFER;
416 }
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700417 pr_debug("%s: probed irq %d\n", __func__, wcd9xxx_res->irq);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700418
419 /* Setup downstream IRQs */
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700420 ret = wcd9xxx_irq_setup_downstream_irq(wcd9xxx_res);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700421 if (ret) {
422 pr_err("%s: Failed to setup downstream IRQ\n", __func__);
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700423 wcd9xxx_irq_put_upstream_irq(wcd9xxx_res);
424 mutex_destroy(&wcd9xxx_res->irq_lock);
425 mutex_destroy(&wcd9xxx_res->nested_irq_lock);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700426 return ret;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530427 }
428
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700429 /* All other wcd9xxx interrupts are edge triggered */
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700430 wcd9xxx_res->irq_level_high[0] = true;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530431
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700432 /* mask all the interrupts */
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700433 memset(irq_level, 0, wcd9xxx_res->num_irq_regs);
434 for (i = 0; i < wcd9xxx_res->num_irqs; i++) {
435 wcd9xxx_res->irq_masks_cur[BIT_BYTE(i)] |= BYTE_BIT_MASK(i);
436 wcd9xxx_res->irq_masks_cache[BIT_BYTE(i)] |= BYTE_BIT_MASK(i);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700437 irq_level[BIT_BYTE(i)] |=
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700438 wcd9xxx_res->irq_level_high[i] << (i % BITS_PER_BYTE);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530439 }
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700440
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700441 if (!wcd9xxx_res->codec_reg_write) {
442 dev_err(wcd9xxx_res->dev,
443 "%s: Codec Register write callback not defined\n",
444 __func__);
445 ret = -EINVAL;
446 goto fail_irq_init;
447 }
448
449 for (i = 0; i < wcd9xxx_res->num_irq_regs; i++) {
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530450 /* Initialize interrupt mask and level registers */
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700451 wcd9xxx_res->codec_reg_write(wcd9xxx_res,
452 WCD9XXX_A_INTR_LEVEL0 + i,
453 irq_level[i]);
454 wcd9xxx_res->codec_reg_write(wcd9xxx_res,
455 WCD9XXX_A_INTR_MASK0 + i,
456 wcd9xxx_res->irq_masks_cur[i]);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530457 }
458
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700459 ret = request_threaded_irq(wcd9xxx_res->irq, NULL, wcd9xxx_irq_thread,
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530460 IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700461 "wcd9xxx", wcd9xxx_res);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530462 if (ret != 0)
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700463 dev_err(wcd9xxx_res->dev, "Failed to request IRQ %d: %d\n",
464 wcd9xxx_res->irq, ret);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530465 else {
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700466 ret = enable_irq_wake(wcd9xxx_res->irq);
Joonwoo Parkc98049a2013-07-30 16:43:34 -0700467 if (ret)
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700468 dev_err(wcd9xxx_res->dev,
469 "Failed to set wake interrupt on IRQ %d: %d\n",
470 wcd9xxx_res->irq, ret);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530471 if (ret)
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700472 free_irq(wcd9xxx_res->irq, wcd9xxx_res);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530473 }
474
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700475 if (ret)
476 goto fail_irq_init;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530477
478 return ret;
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700479
480fail_irq_init:
481 dev_err(wcd9xxx_res->dev,
482 "%s: Failed to init wcd9xxx irq\n", __func__);
483 wcd9xxx_irq_put_upstream_irq(wcd9xxx_res);
484 mutex_destroy(&wcd9xxx_res->irq_lock);
485 mutex_destroy(&wcd9xxx_res->nested_irq_lock);
486 return ret;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530487}
488
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700489int wcd9xxx_request_irq(struct wcd9xxx_core_resource *wcd9xxx_res,
490 int irq, irq_handler_t handler,
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700491 const char *name, void *data)
492{
493 int virq;
494
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700495 virq = phyirq_to_virq(wcd9xxx_res, irq);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700496
497 /*
498 * ARM needs us to explicitly flag the IRQ as valid
499 * and will set them noprobe when we do so.
500 */
501#ifdef CONFIG_ARM
502 set_irq_flags(virq, IRQF_VALID);
503#else
504 set_irq_noprobe(virq);
505#endif
506
507 return request_threaded_irq(virq, NULL, handler, IRQF_TRIGGER_RISING,
508 name, data);
509}
510
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700511void wcd9xxx_irq_exit(struct wcd9xxx_core_resource *wcd9xxx_res)
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530512{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700513 dev_dbg(wcd9xxx_res->dev, "%s: Cleaning up irq %d\n", __func__,
514 wcd9xxx_res->irq);
515
516 if (wcd9xxx_res->irq) {
517 disable_irq_wake(wcd9xxx_res->irq);
518 free_irq(wcd9xxx_res->irq, wcd9xxx_res);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700519 /* Release parent's of node */
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700520 wcd9xxx_irq_put_upstream_irq(wcd9xxx_res);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530521 }
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700522 mutex_destroy(&wcd9xxx_res->irq_lock);
523 mutex_destroy(&wcd9xxx_res->nested_irq_lock);
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530524}
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700525
526#ifndef CONFIG_OF
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700527static int phyirq_to_virq(
528 struct wcd9xxx_core_resource *wcd9xxx_res,
529 int offset)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700530{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700531 return wcd9xxx_res->irq_base + offset;
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700532}
533
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700534static int virq_to_phyirq(
535 struct wcd9xxx_core_resource *wcd9xxx_res,
536 int virq)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700537{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700538 return virq - wcd9xxx_res->irq_base;
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700539}
540
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700541static unsigned int wcd9xxx_irq_get_upstream_irq(
542 struct wcd9xxx_core_resource *wcd9xxx_res)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700543{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700544 return wcd9xxx_res->irq;
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700545}
546
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700547static void wcd9xxx_irq_put_upstream_irq(
548 struct wcd9xxx_core_resource *wcd9xxx_res)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700549{
550 /* Do nothing */
551}
552
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700553static int wcd9xxx_map_irq(
554 struct wcd9xxx_core_resource *wcd9xxx_core_res, int irq)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700555{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700556 return phyirq_to_virq(wcd9xxx_core_res, irq);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700557}
558#else
559int __init wcd9xxx_irq_of_init(struct device_node *node,
560 struct device_node *parent)
561{
562 struct wcd9xxx_irq_drv_data *data;
563
564 pr_debug("%s: node %s, node parent %s\n", __func__,
565 node->name, node->parent->name);
566
567 data = kzalloc(sizeof(*data), GFP_KERNEL);
568 if (!data)
569 return -ENOMEM;
570
571 /*
572 * wcd9xxx_intc interrupt controller supports N to N irq mapping with
573 * single cell binding with irq numbers(offsets) only.
574 * Use irq_domain_simple_ops that has irq_domain_simple_map and
575 * irq_domain_xlate_onetwocell.
576 */
577 data->domain = irq_domain_add_linear(node, WCD9XXX_MAX_NUM_IRQS,
578 &irq_domain_simple_ops, data);
579 if (!data->domain) {
580 kfree(data);
581 return -ENOMEM;
582 }
583
584 return 0;
585}
586
587static struct wcd9xxx_irq_drv_data *
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700588wcd9xxx_get_irq_drv_d(const struct wcd9xxx_core_resource *wcd9xxx_res)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700589{
590 struct device_node *pnode;
591 struct irq_domain *domain;
592
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700593 pnode = of_irq_find_parent(wcd9xxx_res->dev->of_node);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700594 /* Shouldn't happen */
595 if (unlikely(!pnode))
596 return NULL;
597
598 domain = irq_find_host(pnode);
599 return (struct wcd9xxx_irq_drv_data *)domain->host_data;
600}
601
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700602static int phyirq_to_virq(struct wcd9xxx_core_resource *wcd9xxx_res, int offset)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700603{
604 struct wcd9xxx_irq_drv_data *data;
605
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700606 data = wcd9xxx_get_irq_drv_d(wcd9xxx_res);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700607 if (!data) {
608 pr_warn("%s: not registered to interrupt controller\n",
609 __func__);
610 return -EINVAL;
611 }
612 return irq_linear_revmap(data->domain, offset);
613}
614
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700615static int virq_to_phyirq(struct wcd9xxx_core_resource *wcd9xxx_res, int virq)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700616{
617 struct irq_data *irq_data = irq_get_irq_data(virq);
Aravind Kumar320ef3a2014-03-21 12:32:34 +0530618 if (unlikely(!irq_data)) {
619 pr_err("%s: irq_data is NULL", __func__);
620 return -EINVAL;
621 }
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700622 return irq_data->hwirq;
623}
624
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700625static unsigned int wcd9xxx_irq_get_upstream_irq(
626 struct wcd9xxx_core_resource *wcd9xxx_res)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700627{
628 struct wcd9xxx_irq_drv_data *data;
629
630 /* Hold parent's of node */
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700631 if (!of_node_get(of_irq_find_parent(wcd9xxx_res->dev->of_node)))
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700632 return -EINVAL;
633
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700634 data = wcd9xxx_get_irq_drv_d(wcd9xxx_res);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700635 if (!data) {
636 pr_err("%s: interrupt controller is not registerd\n", __func__);
637 return 0;
638 }
639
640 rmb();
641 return data->irq;
642}
643
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700644static void wcd9xxx_irq_put_upstream_irq(
645 struct wcd9xxx_core_resource *wcd9xxx_res)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700646{
647 /* Hold parent's of node */
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700648 of_node_put(of_irq_find_parent(wcd9xxx_res->dev->of_node));
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700649}
650
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700651static int wcd9xxx_map_irq(struct wcd9xxx_core_resource *wcd9xxx_res, int irq)
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700652{
Bhalchandra Gajare9b4eb3b2013-04-30 12:00:41 -0700653 return of_irq_to_resource(wcd9xxx_res->dev->of_node, irq, NULL);
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700654}
655
656static int __devinit wcd9xxx_irq_probe(struct platform_device *pdev)
657{
658 int irq;
659 struct irq_domain *domain;
660 struct wcd9xxx_irq_drv_data *data;
661 int ret = -EINVAL;
662
663 irq = platform_get_irq_byname(pdev, "cdc-int");
664 if (irq < 0) {
665 dev_err(&pdev->dev, "%s: Couldn't find cdc-int node(%d)\n",
666 __func__, irq);
667 return -EINVAL;
668 } else {
669 dev_dbg(&pdev->dev, "%s: virq = %d\n", __func__, irq);
670 domain = irq_find_host(pdev->dev.of_node);
Aravind Kumar320ef3a2014-03-21 12:32:34 +0530671 if (unlikely(!domain)) {
672 pr_err("%s: domain is NULL", __func__);
673 return -EINVAL;
674 }
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700675 data = (struct wcd9xxx_irq_drv_data *)domain->host_data;
676 data->irq = irq;
677 wmb();
678 ret = 0;
679 }
680
681 return ret;
682}
683
684static int wcd9xxx_irq_remove(struct platform_device *pdev)
685{
686 struct irq_domain *domain;
687 struct wcd9xxx_irq_drv_data *data;
688
689 domain = irq_find_host(pdev->dev.of_node);
Aravind Kumar320ef3a2014-03-21 12:32:34 +0530690 if (unlikely(!domain)) {
691 pr_err("%s: domain is NULL", __func__);
692 return -EINVAL;
693 }
Joonwoo Parkf6574c72012-10-10 17:29:57 -0700694 data = (struct wcd9xxx_irq_drv_data *)domain->host_data;
695 data->irq = 0;
696 wmb();
697
698 return 0;
699}
700
701static const struct of_device_id of_match[] = {
702 { .compatible = "qcom,wcd9xxx-irq" },
703 { }
704};
705
706static struct platform_driver wcd9xxx_irq_driver = {
707 .probe = wcd9xxx_irq_probe,
708 .remove = wcd9xxx_irq_remove,
709 .driver = {
710 .name = "wcd9xxx_intc",
711 .owner = THIS_MODULE,
712 .of_match_table = of_match_ptr(of_match),
713 },
714};
715
716static int wcd9xxx_irq_drv_init(void)
717{
718 return platform_driver_register(&wcd9xxx_irq_driver);
719}
720subsys_initcall(wcd9xxx_irq_drv_init);
721
722static void wcd9xxx_irq_drv_exit(void)
723{
724 platform_driver_unregister(&wcd9xxx_irq_driver);
725}
726module_exit(wcd9xxx_irq_drv_exit);
727#endif /* CONFIG_OF */