Joonwoo Park | 1277cb6 | 2013-03-19 14:16:51 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 2 | * |
| 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> |
| 18 | #include <linux/mfd/wcd9xxx/core.h> |
| 19 | #include <linux/mfd/wcd9xxx/wcd9xxx_registers.h> |
| 20 | #include <linux/mfd/wcd9xxx/wcd9310_registers.h> |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 21 | #include <linux/mfd/wcd9xxx/wcd9xxx-slimslave.h> |
| 22 | #include <linux/delay.h> |
| 23 | #include <linux/irqdomain.h> |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 24 | #include <linux/interrupt.h> |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 25 | #include <linux/of.h> |
| 26 | #include <linux/of_irq.h> |
| 27 | #include <linux/slab.h> |
Joonwoo Park | 1c958f1a | 2013-04-23 19:41:46 -0700 | [diff] [blame] | 28 | #include <linux/ratelimit.h> |
Stephen Boyd | 2fcabf9 | 2012-05-30 10:41:11 -0700 | [diff] [blame] | 29 | #include <mach/cpuidle.h> |
| 30 | |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 31 | #define BYTE_BIT_MASK(nr) (1UL << ((nr) % BITS_PER_BYTE)) |
| 32 | #define BIT_BYTE(nr) ((nr) / BITS_PER_BYTE) |
| 33 | |
Joonwoo Park | 18383dc | 2012-09-20 17:45:57 -0700 | [diff] [blame] | 34 | #define WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS 100 |
| 35 | |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 36 | #ifdef CONFIG_OF |
| 37 | struct wcd9xxx_irq_drv_data { |
| 38 | struct irq_domain *domain; |
| 39 | int irq; |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 40 | }; |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 41 | #endif |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 42 | |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 43 | static int virq_to_phyirq(struct wcd9xxx *wcd9xxx, int virq); |
| 44 | static int phyirq_to_virq(struct wcd9xxx *wcd9xxx, int irq); |
| 45 | static unsigned int wcd9xxx_irq_get_upstream_irq(struct wcd9xxx *wcd9xxx); |
| 46 | static void wcd9xxx_irq_put_upstream_irq(struct wcd9xxx *wcd9xxx); |
| 47 | static int wcd9xxx_map_irq(struct wcd9xxx *wcd9xxx, int irq); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 48 | |
| 49 | static void wcd9xxx_irq_lock(struct irq_data *data) |
| 50 | { |
| 51 | struct wcd9xxx *wcd9xxx = irq_data_get_irq_chip_data(data); |
| 52 | mutex_lock(&wcd9xxx->irq_lock); |
| 53 | } |
| 54 | |
| 55 | static void wcd9xxx_irq_sync_unlock(struct irq_data *data) |
| 56 | { |
| 57 | struct wcd9xxx *wcd9xxx = irq_data_get_irq_chip_data(data); |
| 58 | int i; |
| 59 | |
Simmi Pateriya | 4fd6993 | 2012-10-26 00:57:06 +0530 | [diff] [blame] | 60 | if (ARRAY_SIZE(wcd9xxx->irq_masks_cur) > WCD9XXX_NUM_IRQ_REGS || |
| 61 | ARRAY_SIZE(wcd9xxx->irq_masks_cache) > WCD9XXX_NUM_IRQ_REGS) { |
| 62 | pr_err("%s: Array Size out of bound\n", __func__); |
| 63 | return; |
| 64 | } |
| 65 | |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 66 | for (i = 0; i < ARRAY_SIZE(wcd9xxx->irq_masks_cur); i++) { |
| 67 | /* If there's been a change in the mask write it back |
| 68 | * to the hardware. |
| 69 | */ |
| 70 | if (wcd9xxx->irq_masks_cur[i] != wcd9xxx->irq_masks_cache[i]) { |
| 71 | wcd9xxx->irq_masks_cache[i] = wcd9xxx->irq_masks_cur[i]; |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 72 | wcd9xxx_reg_write(wcd9xxx, |
| 73 | WCD9XXX_A_INTR_MASK0 + i, |
| 74 | wcd9xxx->irq_masks_cur[i]); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 75 | } |
| 76 | } |
| 77 | |
| 78 | mutex_unlock(&wcd9xxx->irq_lock); |
| 79 | } |
| 80 | |
| 81 | static void wcd9xxx_irq_enable(struct irq_data *data) |
| 82 | { |
| 83 | struct wcd9xxx *wcd9xxx = irq_data_get_irq_chip_data(data); |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 84 | int wcd9xxx_irq = virq_to_phyirq(wcd9xxx, data->irq); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 85 | wcd9xxx->irq_masks_cur[BIT_BYTE(wcd9xxx_irq)] &= |
| 86 | ~(BYTE_BIT_MASK(wcd9xxx_irq)); |
| 87 | } |
| 88 | |
| 89 | static void wcd9xxx_irq_disable(struct irq_data *data) |
| 90 | { |
| 91 | struct wcd9xxx *wcd9xxx = irq_data_get_irq_chip_data(data); |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 92 | int wcd9xxx_irq = virq_to_phyirq(wcd9xxx, data->irq); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 93 | wcd9xxx->irq_masks_cur[BIT_BYTE(wcd9xxx_irq)] |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 94 | |= BYTE_BIT_MASK(wcd9xxx_irq); |
| 95 | } |
| 96 | |
| 97 | static void wcd9xxx_irq_mask(struct irq_data *d) |
| 98 | { |
| 99 | /* do nothing but required as linux calls irq_mask without NULL check */ |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | static struct irq_chip wcd9xxx_irq_chip = { |
| 103 | .name = "wcd9xxx", |
| 104 | .irq_bus_lock = wcd9xxx_irq_lock, |
| 105 | .irq_bus_sync_unlock = wcd9xxx_irq_sync_unlock, |
| 106 | .irq_disable = wcd9xxx_irq_disable, |
| 107 | .irq_enable = wcd9xxx_irq_enable, |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 108 | .irq_mask = wcd9xxx_irq_mask, |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | enum wcd9xxx_pm_state wcd9xxx_pm_cmpxchg(struct wcd9xxx *wcd9xxx, |
| 112 | enum wcd9xxx_pm_state o, |
| 113 | enum wcd9xxx_pm_state n) |
| 114 | { |
| 115 | enum wcd9xxx_pm_state old; |
| 116 | mutex_lock(&wcd9xxx->pm_lock); |
| 117 | old = wcd9xxx->pm_state; |
| 118 | if (old == o) |
| 119 | wcd9xxx->pm_state = n; |
| 120 | mutex_unlock(&wcd9xxx->pm_lock); |
| 121 | return old; |
| 122 | } |
| 123 | EXPORT_SYMBOL_GPL(wcd9xxx_pm_cmpxchg); |
| 124 | |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 125 | bool wcd9xxx_lock_sleep(struct wcd9xxx *wcd9xxx) |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 126 | { |
| 127 | enum wcd9xxx_pm_state os; |
| 128 | |
Joonwoo Park | 18383dc | 2012-09-20 17:45:57 -0700 | [diff] [blame] | 129 | /* |
| 130 | * wcd9xxx_{lock/unlock}_sleep will be called by wcd9xxx_irq_thread |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 131 | * and its subroutines only motly. |
| 132 | * but btn0_lpress_fn is not wcd9xxx_irq_thread's subroutine and |
Joonwoo Park | 18383dc | 2012-09-20 17:45:57 -0700 | [diff] [blame] | 133 | * It can race with wcd9xxx_irq_thread. |
| 134 | * So need to embrace wlock_holders with mutex. |
| 135 | * |
| 136 | * If system didn't resume, we can simply return false so codec driver's |
| 137 | * IRQ handler can return without handling IRQ. |
| 138 | * As interrupt line is still active, codec will have another IRQ to |
| 139 | * retry shortly. |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 140 | */ |
| 141 | mutex_lock(&wcd9xxx->pm_lock); |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 142 | if (wcd9xxx->wlock_holders++ == 0) { |
| 143 | pr_debug("%s: holding wake lock\n", __func__); |
Stephen Boyd | 2fcabf9 | 2012-05-30 10:41:11 -0700 | [diff] [blame] | 144 | pm_qos_update_request(&wcd9xxx->pm_qos_req, |
| 145 | msm_cpuidle_get_deep_idle_latency()); |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 146 | } |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 147 | mutex_unlock(&wcd9xxx->pm_lock); |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 148 | if (!wait_event_timeout(wcd9xxx->pm_wq, |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 149 | ((os = wcd9xxx_pm_cmpxchg(wcd9xxx, WCD9XXX_PM_SLEEPABLE, |
| 150 | WCD9XXX_PM_AWAKE)) == |
| 151 | WCD9XXX_PM_SLEEPABLE || |
| 152 | (os == WCD9XXX_PM_AWAKE)), |
Joonwoo Park | 18383dc | 2012-09-20 17:45:57 -0700 | [diff] [blame] | 153 | msecs_to_jiffies(WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS))) { |
| 154 | pr_warn("%s: system didn't resume within %dms, s %d, w %d\n", |
| 155 | __func__, |
| 156 | WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS, wcd9xxx->pm_state, |
| 157 | wcd9xxx->wlock_holders); |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 158 | wcd9xxx_unlock_sleep(wcd9xxx); |
| 159 | return false; |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 160 | } |
| 161 | wake_up_all(&wcd9xxx->pm_wq); |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 162 | return true; |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 163 | } |
| 164 | EXPORT_SYMBOL_GPL(wcd9xxx_lock_sleep); |
| 165 | |
| 166 | void wcd9xxx_unlock_sleep(struct wcd9xxx *wcd9xxx) |
| 167 | { |
| 168 | mutex_lock(&wcd9xxx->pm_lock); |
| 169 | if (--wcd9xxx->wlock_holders == 0) { |
Joonwoo Park | 18383dc | 2012-09-20 17:45:57 -0700 | [diff] [blame] | 170 | pr_debug("%s: releasing wake lock pm_state %d -> %d\n", |
| 171 | __func__, wcd9xxx->pm_state, WCD9XXX_PM_SLEEPABLE); |
| 172 | /* |
| 173 | * if wcd9xxx_lock_sleep failed, pm_state would be still |
| 174 | * WCD9XXX_PM_ASLEEP, don't overwrite |
| 175 | */ |
| 176 | if (likely(wcd9xxx->pm_state == WCD9XXX_PM_AWAKE)) |
| 177 | wcd9xxx->pm_state = WCD9XXX_PM_SLEEPABLE; |
Stephen Boyd | 2fcabf9 | 2012-05-30 10:41:11 -0700 | [diff] [blame] | 178 | pm_qos_update_request(&wcd9xxx->pm_qos_req, |
| 179 | PM_QOS_DEFAULT_VALUE); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 180 | } |
| 181 | mutex_unlock(&wcd9xxx->pm_lock); |
| 182 | wake_up_all(&wcd9xxx->pm_wq); |
| 183 | } |
| 184 | EXPORT_SYMBOL_GPL(wcd9xxx_unlock_sleep); |
| 185 | |
Joonwoo Park | 1f9d7fd | 2013-01-07 12:40:03 -0800 | [diff] [blame] | 186 | void wcd9xxx_nested_irq_lock(struct wcd9xxx *wcd9xxx) |
| 187 | { |
| 188 | mutex_lock(&wcd9xxx->nested_irq_lock); |
| 189 | } |
| 190 | |
| 191 | void wcd9xxx_nested_irq_unlock(struct wcd9xxx *wcd9xxx) |
| 192 | { |
| 193 | mutex_unlock(&wcd9xxx->nested_irq_lock); |
| 194 | } |
| 195 | |
Joonwoo Park | 0332483 | 2012-03-19 19:36:16 -0700 | [diff] [blame] | 196 | static void wcd9xxx_irq_dispatch(struct wcd9xxx *wcd9xxx, int irqbit) |
| 197 | { |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 198 | if ((irqbit <= WCD9XXX_IRQ_MBHC_INSERTION) && |
| 199 | (irqbit >= WCD9XXX_IRQ_MBHC_REMOVAL)) { |
Joonwoo Park | 1f9d7fd | 2013-01-07 12:40:03 -0800 | [diff] [blame] | 200 | wcd9xxx_nested_irq_lock(wcd9xxx); |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 201 | wcd9xxx_reg_write(wcd9xxx, WCD9XXX_A_INTR_CLEAR0 + |
| 202 | BIT_BYTE(irqbit), |
| 203 | BYTE_BIT_MASK(irqbit)); |
Joonwoo Park | 0332483 | 2012-03-19 19:36:16 -0700 | [diff] [blame] | 204 | if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 205 | wcd9xxx_reg_write(wcd9xxx, WCD9XXX_A_INTR_MODE, 0x02); |
| 206 | handle_nested_irq(phyirq_to_virq(wcd9xxx, irqbit)); |
Joonwoo Park | 1f9d7fd | 2013-01-07 12:40:03 -0800 | [diff] [blame] | 207 | wcd9xxx_nested_irq_unlock(wcd9xxx); |
Joonwoo Park | 0332483 | 2012-03-19 19:36:16 -0700 | [diff] [blame] | 208 | } else { |
Joonwoo Park | 1f9d7fd | 2013-01-07 12:40:03 -0800 | [diff] [blame] | 209 | wcd9xxx_nested_irq_lock(wcd9xxx); |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 210 | handle_nested_irq(phyirq_to_virq(wcd9xxx, irqbit)); |
| 211 | wcd9xxx_reg_write(wcd9xxx, WCD9XXX_A_INTR_CLEAR0 + |
| 212 | BIT_BYTE(irqbit), |
| 213 | BYTE_BIT_MASK(irqbit)); |
Joonwoo Park | 0332483 | 2012-03-19 19:36:16 -0700 | [diff] [blame] | 214 | if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 215 | wcd9xxx_reg_write(wcd9xxx, WCD9XXX_A_INTR_MODE, 0x02); |
Joonwoo Park | 1f9d7fd | 2013-01-07 12:40:03 -0800 | [diff] [blame] | 216 | wcd9xxx_nested_irq_unlock(wcd9xxx); |
Joonwoo Park | 0332483 | 2012-03-19 19:36:16 -0700 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 220 | static int wcd9xxx_num_irq_regs(const struct wcd9xxx *wcd9xxx) |
| 221 | { |
Joonwoo Park | 1277cb6 | 2013-03-19 14:16:51 -0700 | [diff] [blame] | 222 | return (wcd9xxx->codec_type->num_irqs / 8) + |
| 223 | ((wcd9xxx->codec_type->num_irqs % 8) ? 1 : 0); |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 224 | } |
| 225 | |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 226 | static irqreturn_t wcd9xxx_irq_thread(int irq, void *data) |
| 227 | { |
| 228 | int ret; |
Joonwoo Park | 0332483 | 2012-03-19 19:36:16 -0700 | [diff] [blame] | 229 | int i; |
Joonwoo Park | 1c958f1a | 2013-04-23 19:41:46 -0700 | [diff] [blame] | 230 | char linebuf[128]; |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 231 | struct wcd9xxx *wcd9xxx = data; |
| 232 | int num_irq_regs = wcd9xxx_num_irq_regs(wcd9xxx); |
Joonwoo Park | 1c958f1a | 2013-04-23 19:41:46 -0700 | [diff] [blame] | 233 | u8 status[num_irq_regs], status1[num_irq_regs]; |
| 234 | static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 1); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 235 | |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 236 | if (unlikely(wcd9xxx_lock_sleep(wcd9xxx) == false)) { |
| 237 | dev_err(wcd9xxx->dev, "Failed to hold suspend\n"); |
| 238 | return IRQ_NONE; |
| 239 | } |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 240 | ret = wcd9xxx_bulk_read(wcd9xxx, WCD9XXX_A_INTR_STATUS0, |
| 241 | num_irq_regs, status); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 242 | if (ret < 0) { |
| 243 | dev_err(wcd9xxx->dev, "Failed to read interrupt status: %d\n", |
| 244 | ret); |
Joonwoo Park | 0732919 | 2012-10-23 13:08:37 -0700 | [diff] [blame] | 245 | dev_err(wcd9xxx->dev, "Disable irq %d\n", wcd9xxx->irq); |
Joonwoo Park | 6183dbd | 2012-10-26 16:39:20 -0700 | [diff] [blame] | 246 | disable_irq_wake(wcd9xxx->irq); |
Joonwoo Park | 0732919 | 2012-10-23 13:08:37 -0700 | [diff] [blame] | 247 | disable_irq_nosync(wcd9xxx->irq); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 248 | wcd9xxx_unlock_sleep(wcd9xxx); |
| 249 | return IRQ_NONE; |
| 250 | } |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 251 | |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 252 | /* Apply masking */ |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 253 | for (i = 0; i < num_irq_regs; i++) |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 254 | status[i] &= ~wcd9xxx->irq_masks_cur[i]; |
| 255 | |
Joonwoo Park | 1c958f1a | 2013-04-23 19:41:46 -0700 | [diff] [blame] | 256 | memcpy(status1, status, sizeof(status1)); |
| 257 | |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 258 | /* Find out which interrupt was triggered and call that interrupt's |
| 259 | * handler function |
| 260 | */ |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 261 | if (status[BIT_BYTE(WCD9XXX_IRQ_SLIMBUS)] & |
Joonwoo Park | 1c958f1a | 2013-04-23 19:41:46 -0700 | [diff] [blame] | 262 | BYTE_BIT_MASK(WCD9XXX_IRQ_SLIMBUS)) { |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 263 | wcd9xxx_irq_dispatch(wcd9xxx, WCD9XXX_IRQ_SLIMBUS); |
Joonwoo Park | 1c958f1a | 2013-04-23 19:41:46 -0700 | [diff] [blame] | 264 | status1[BIT_BYTE(WCD9XXX_IRQ_SLIMBUS)] &= |
| 265 | ~BYTE_BIT_MASK(WCD9XXX_IRQ_SLIMBUS); |
| 266 | } |
Joonwoo Park | 0332483 | 2012-03-19 19:36:16 -0700 | [diff] [blame] | 267 | |
| 268 | /* Since codec has only one hardware irq line which is shared by |
| 269 | * codec's different internal interrupts, so it's possible master irq |
| 270 | * handler dispatches multiple nested irq handlers after breaking |
| 271 | * order. Dispatch MBHC interrupts order to follow MBHC state |
| 272 | * machine's order */ |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 273 | for (i = WCD9XXX_IRQ_MBHC_INSERTION; |
| 274 | i >= WCD9XXX_IRQ_MBHC_REMOVAL; i--) { |
Joonwoo Park | 1c958f1a | 2013-04-23 19:41:46 -0700 | [diff] [blame] | 275 | if (status[BIT_BYTE(i)] & BYTE_BIT_MASK(i)) { |
Joonwoo Park | 0332483 | 2012-03-19 19:36:16 -0700 | [diff] [blame] | 276 | wcd9xxx_irq_dispatch(wcd9xxx, i); |
Joonwoo Park | 1c958f1a | 2013-04-23 19:41:46 -0700 | [diff] [blame] | 277 | status1[BIT_BYTE(i)] &= ~BYTE_BIT_MASK(i); |
| 278 | } |
Joonwoo Park | 0332483 | 2012-03-19 19:36:16 -0700 | [diff] [blame] | 279 | } |
Joonwoo Park | 1277cb6 | 2013-03-19 14:16:51 -0700 | [diff] [blame] | 280 | for (i = WCD9XXX_IRQ_BG_PRECHARGE; i < wcd9xxx->codec_type->num_irqs; |
| 281 | i++) { |
Joonwoo Park | 1c958f1a | 2013-04-23 19:41:46 -0700 | [diff] [blame] | 282 | if (status[BIT_BYTE(i)] & BYTE_BIT_MASK(i)) { |
Joonwoo Park | 0332483 | 2012-03-19 19:36:16 -0700 | [diff] [blame] | 283 | wcd9xxx_irq_dispatch(wcd9xxx, i); |
Joonwoo Park | 1c958f1a | 2013-04-23 19:41:46 -0700 | [diff] [blame] | 284 | status1[BIT_BYTE(i)] &= ~BYTE_BIT_MASK(i); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | /* |
| 289 | * As a failsafe if unhandled irq is found, clear it to prevent |
| 290 | * interrupt storm. |
| 291 | * Note that we can say there was an unhandled irq only when no irq |
| 292 | * handled by nested irq handler since Taiko supports qdsp as irqs' |
| 293 | * destination for few irqs. Therefore driver shouldn't clear pending |
| 294 | * irqs when few handled while few others not. |
| 295 | */ |
| 296 | if (unlikely(!memcmp(status, status1, sizeof(status)))) { |
| 297 | if (__ratelimit(&ratelimit)) { |
| 298 | pr_warn("%s: Unhandled irq found\n", __func__); |
| 299 | hex_dump_to_buffer(status, sizeof(status), 16, 1, |
| 300 | linebuf, sizeof(linebuf), false); |
| 301 | pr_warn("%s: status0 : %s\n", __func__, linebuf); |
| 302 | hex_dump_to_buffer(status1, sizeof(status1), 16, 1, |
| 303 | linebuf, sizeof(linebuf), false); |
| 304 | pr_warn("%s: status1 : %s\n", __func__, linebuf); |
| 305 | } |
| 306 | |
| 307 | memset(status, 0, num_irq_regs); |
| 308 | wcd9xxx_bulk_write(wcd9xxx, WCD9XXX_A_INTR_STATUS0, |
| 309 | num_irq_regs, status); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 310 | } |
| 311 | wcd9xxx_unlock_sleep(wcd9xxx); |
| 312 | |
| 313 | return IRQ_HANDLED; |
| 314 | } |
| 315 | |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 316 | void wcd9xxx_free_irq(struct wcd9xxx *wcd9xxx, int irq, void *data) |
| 317 | { |
| 318 | free_irq(phyirq_to_virq(wcd9xxx, irq), data); |
| 319 | } |
| 320 | |
| 321 | void wcd9xxx_enable_irq(struct wcd9xxx *wcd9xxx, int irq) |
| 322 | { |
| 323 | enable_irq(phyirq_to_virq(wcd9xxx, irq)); |
| 324 | } |
| 325 | |
| 326 | void wcd9xxx_disable_irq(struct wcd9xxx *wcd9xxx, int irq) |
| 327 | { |
| 328 | disable_irq_nosync(phyirq_to_virq(wcd9xxx, irq)); |
| 329 | } |
| 330 | |
| 331 | void wcd9xxx_disable_irq_sync(struct wcd9xxx *wcd9xxx, int irq) |
| 332 | { |
| 333 | disable_irq(phyirq_to_virq(wcd9xxx, irq)); |
| 334 | } |
| 335 | |
| 336 | static int wcd9xxx_irq_setup_downstream_irq(struct wcd9xxx *wcd9xxx) |
| 337 | { |
| 338 | int irq, virq, ret; |
| 339 | |
| 340 | pr_debug("%s: enter\n", __func__); |
| 341 | |
Joonwoo Park | 1277cb6 | 2013-03-19 14:16:51 -0700 | [diff] [blame] | 342 | for (irq = 0; irq < wcd9xxx->codec_type->num_irqs; irq++) { |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 343 | /* Map OF irq */ |
| 344 | virq = wcd9xxx_map_irq(wcd9xxx, irq); |
| 345 | pr_debug("%s: irq %d -> %d\n", __func__, irq, virq); |
| 346 | if (virq == NO_IRQ) { |
| 347 | pr_err("%s, No interrupt specifier for irq %d\n", |
| 348 | __func__, irq); |
| 349 | return NO_IRQ; |
| 350 | } |
| 351 | |
| 352 | ret = irq_set_chip_data(virq, wcd9xxx); |
| 353 | if (ret) { |
| 354 | pr_err("%s: Failed to configure irq %d (%d)\n", |
| 355 | __func__, irq, ret); |
| 356 | return ret; |
| 357 | } |
| 358 | |
| 359 | if (wcd9xxx->irq_level_high[irq]) |
| 360 | irq_set_chip_and_handler(virq, &wcd9xxx_irq_chip, |
| 361 | handle_level_irq); |
| 362 | else |
| 363 | irq_set_chip_and_handler(virq, &wcd9xxx_irq_chip, |
| 364 | handle_edge_irq); |
| 365 | |
| 366 | irq_set_nested_thread(virq, 1); |
| 367 | } |
| 368 | |
| 369 | pr_debug("%s: leave\n", __func__); |
| 370 | |
| 371 | return 0; |
| 372 | } |
| 373 | |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 374 | int wcd9xxx_irq_init(struct wcd9xxx *wcd9xxx) |
| 375 | { |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 376 | int i, ret; |
| 377 | u8 irq_level[wcd9xxx_num_irq_regs(wcd9xxx)]; |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 378 | |
| 379 | mutex_init(&wcd9xxx->irq_lock); |
Joonwoo Park | 1f9d7fd | 2013-01-07 12:40:03 -0800 | [diff] [blame] | 380 | mutex_init(&wcd9xxx->nested_irq_lock); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 381 | |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 382 | wcd9xxx->irq = wcd9xxx_irq_get_upstream_irq(wcd9xxx); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 383 | if (!wcd9xxx->irq) { |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 384 | pr_warn("%s: irq driver is not yet initialized\n", __func__); |
| 385 | mutex_destroy(&wcd9xxx->irq_lock); |
Joonwoo Park | 1f9d7fd | 2013-01-07 12:40:03 -0800 | [diff] [blame] | 386 | mutex_destroy(&wcd9xxx->nested_irq_lock); |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 387 | return -EPROBE_DEFER; |
| 388 | } |
| 389 | pr_debug("%s: probed irq %d\n", __func__, wcd9xxx->irq); |
| 390 | |
| 391 | /* Setup downstream IRQs */ |
| 392 | ret = wcd9xxx_irq_setup_downstream_irq(wcd9xxx); |
| 393 | if (ret) { |
| 394 | pr_err("%s: Failed to setup downstream IRQ\n", __func__); |
| 395 | wcd9xxx_irq_put_upstream_irq(wcd9xxx); |
Joonwoo Park | 1f9d7fd | 2013-01-07 12:40:03 -0800 | [diff] [blame] | 396 | mutex_destroy(&wcd9xxx->irq_lock); |
| 397 | mutex_destroy(&wcd9xxx->nested_irq_lock); |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 398 | return ret; |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 399 | } |
| 400 | |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 401 | /* All other wcd9xxx interrupts are edge triggered */ |
| 402 | wcd9xxx->irq_level_high[0] = true; |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 403 | |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 404 | /* mask all the interrupts */ |
| 405 | memset(irq_level, 0, wcd9xxx_num_irq_regs(wcd9xxx)); |
Joonwoo Park | 1277cb6 | 2013-03-19 14:16:51 -0700 | [diff] [blame] | 406 | for (i = 0; i < wcd9xxx->codec_type->num_irqs; i++) { |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 407 | wcd9xxx->irq_masks_cur[BIT_BYTE(i)] |= BYTE_BIT_MASK(i); |
| 408 | wcd9xxx->irq_masks_cache[BIT_BYTE(i)] |= BYTE_BIT_MASK(i); |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 409 | irq_level[BIT_BYTE(i)] |= |
| 410 | wcd9xxx->irq_level_high[i] << (i % BITS_PER_BYTE); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 411 | } |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 412 | |
| 413 | for (i = 0; i < wcd9xxx_num_irq_regs(wcd9xxx); i++) { |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 414 | /* Initialize interrupt mask and level registers */ |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 415 | wcd9xxx_reg_write(wcd9xxx, WCD9XXX_A_INTR_LEVEL0 + i, |
| 416 | irq_level[i]); |
| 417 | wcd9xxx_reg_write(wcd9xxx, WCD9XXX_A_INTR_MASK0 + i, |
| 418 | wcd9xxx->irq_masks_cur[i]); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | ret = request_threaded_irq(wcd9xxx->irq, NULL, wcd9xxx_irq_thread, |
| 422 | IRQF_TRIGGER_HIGH | IRQF_ONESHOT, |
| 423 | "wcd9xxx", wcd9xxx); |
| 424 | if (ret != 0) |
| 425 | dev_err(wcd9xxx->dev, "Failed to request IRQ %d: %d\n", |
| 426 | wcd9xxx->irq, ret); |
| 427 | else { |
| 428 | ret = enable_irq_wake(wcd9xxx->irq); |
| 429 | if (ret == 0) { |
| 430 | ret = device_init_wakeup(wcd9xxx->dev, 1); |
| 431 | if (ret) { |
| 432 | dev_err(wcd9xxx->dev, "Failed to init device" |
| 433 | "wakeup : %d\n", ret); |
| 434 | disable_irq_wake(wcd9xxx->irq); |
| 435 | } |
| 436 | } else |
| 437 | dev_err(wcd9xxx->dev, "Failed to set wake interrupt on" |
| 438 | " IRQ %d: %d\n", wcd9xxx->irq, ret); |
| 439 | if (ret) |
| 440 | free_irq(wcd9xxx->irq, wcd9xxx); |
| 441 | } |
| 442 | |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 443 | if (ret) { |
| 444 | pr_err("%s: Failed to init wcd9xxx irq\n", __func__); |
| 445 | wcd9xxx_irq_put_upstream_irq(wcd9xxx); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 446 | mutex_destroy(&wcd9xxx->irq_lock); |
Joonwoo Park | 1f9d7fd | 2013-01-07 12:40:03 -0800 | [diff] [blame] | 447 | mutex_destroy(&wcd9xxx->nested_irq_lock); |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 448 | } |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 449 | |
| 450 | return ret; |
| 451 | } |
| 452 | |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 453 | int wcd9xxx_request_irq(struct wcd9xxx *wcd9xxx, int irq, irq_handler_t handler, |
| 454 | const char *name, void *data) |
| 455 | { |
| 456 | int virq; |
| 457 | |
| 458 | virq = phyirq_to_virq(wcd9xxx, irq); |
| 459 | |
| 460 | /* |
| 461 | * ARM needs us to explicitly flag the IRQ as valid |
| 462 | * and will set them noprobe when we do so. |
| 463 | */ |
| 464 | #ifdef CONFIG_ARM |
| 465 | set_irq_flags(virq, IRQF_VALID); |
| 466 | #else |
| 467 | set_irq_noprobe(virq); |
| 468 | #endif |
| 469 | |
| 470 | return request_threaded_irq(virq, NULL, handler, IRQF_TRIGGER_RISING, |
| 471 | name, data); |
| 472 | } |
| 473 | |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 474 | void wcd9xxx_irq_exit(struct wcd9xxx *wcd9xxx) |
| 475 | { |
| 476 | if (wcd9xxx->irq) { |
| 477 | disable_irq_wake(wcd9xxx->irq); |
| 478 | free_irq(wcd9xxx->irq, wcd9xxx); |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 479 | /* Release parent's of node */ |
| 480 | wcd9xxx_irq_put_upstream_irq(wcd9xxx); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 481 | device_init_wakeup(wcd9xxx->dev, 0); |
| 482 | } |
| 483 | mutex_destroy(&wcd9xxx->irq_lock); |
Joonwoo Park | 1f9d7fd | 2013-01-07 12:40:03 -0800 | [diff] [blame] | 484 | mutex_destroy(&wcd9xxx->nested_irq_lock); |
Asish Bhattacharya | b1aeae2 | 2012-02-15 08:29:28 +0530 | [diff] [blame] | 485 | } |
Joonwoo Park | f6574c7 | 2012-10-10 17:29:57 -0700 | [diff] [blame] | 486 | |
| 487 | #ifndef CONFIG_OF |
| 488 | static int phyirq_to_virq(struct wcd9xxx *wcd9xxx, int offset) |
| 489 | { |
| 490 | return wcd9xxx->irq_base + offset; |
| 491 | } |
| 492 | |
| 493 | static int virq_to_phyirq(struct wcd9xxx *wcd9xxx, int virq) |
| 494 | { |
| 495 | return virq - wcd9xxx->irq_base; |
| 496 | } |
| 497 | |
| 498 | static unsigned int wcd9xxx_irq_get_upstream_irq(struct wcd9xxx *wcd9xxx) |
| 499 | { |
| 500 | return wcd9xxx->irq; |
| 501 | } |
| 502 | |
| 503 | static void wcd9xxx_irq_put_upstream_irq(struct wcd9xxx *wcd9xxx) |
| 504 | { |
| 505 | /* Do nothing */ |
| 506 | } |
| 507 | |
| 508 | static int wcd9xxx_map_irq(struct wcd9xxx *wcd9xxx, int irq) |
| 509 | { |
| 510 | return phyirq_to_virq(wcd9xxx, irq); |
| 511 | } |
| 512 | #else |
| 513 | int __init wcd9xxx_irq_of_init(struct device_node *node, |
| 514 | struct device_node *parent) |
| 515 | { |
| 516 | struct wcd9xxx_irq_drv_data *data; |
| 517 | |
| 518 | pr_debug("%s: node %s, node parent %s\n", __func__, |
| 519 | node->name, node->parent->name); |
| 520 | |
| 521 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
| 522 | if (!data) |
| 523 | return -ENOMEM; |
| 524 | |
| 525 | /* |
| 526 | * wcd9xxx_intc interrupt controller supports N to N irq mapping with |
| 527 | * single cell binding with irq numbers(offsets) only. |
| 528 | * Use irq_domain_simple_ops that has irq_domain_simple_map and |
| 529 | * irq_domain_xlate_onetwocell. |
| 530 | */ |
| 531 | data->domain = irq_domain_add_linear(node, WCD9XXX_MAX_NUM_IRQS, |
| 532 | &irq_domain_simple_ops, data); |
| 533 | if (!data->domain) { |
| 534 | kfree(data); |
| 535 | return -ENOMEM; |
| 536 | } |
| 537 | |
| 538 | return 0; |
| 539 | } |
| 540 | |
| 541 | static struct wcd9xxx_irq_drv_data * |
| 542 | wcd9xxx_get_irq_drv_d(const struct wcd9xxx *wcd9xxx) |
| 543 | { |
| 544 | struct device_node *pnode; |
| 545 | struct irq_domain *domain; |
| 546 | |
| 547 | pnode = of_irq_find_parent(wcd9xxx->dev->of_node); |
| 548 | /* Shouldn't happen */ |
| 549 | if (unlikely(!pnode)) |
| 550 | return NULL; |
| 551 | |
| 552 | domain = irq_find_host(pnode); |
| 553 | return (struct wcd9xxx_irq_drv_data *)domain->host_data; |
| 554 | } |
| 555 | |
| 556 | static int phyirq_to_virq(struct wcd9xxx *wcd9xxx, int offset) |
| 557 | { |
| 558 | struct wcd9xxx_irq_drv_data *data; |
| 559 | |
| 560 | data = wcd9xxx_get_irq_drv_d(wcd9xxx); |
| 561 | if (!data) { |
| 562 | pr_warn("%s: not registered to interrupt controller\n", |
| 563 | __func__); |
| 564 | return -EINVAL; |
| 565 | } |
| 566 | return irq_linear_revmap(data->domain, offset); |
| 567 | } |
| 568 | |
| 569 | static int virq_to_phyirq(struct wcd9xxx *wcd9xxx, int virq) |
| 570 | { |
| 571 | struct irq_data *irq_data = irq_get_irq_data(virq); |
| 572 | return irq_data->hwirq; |
| 573 | } |
| 574 | |
| 575 | static unsigned int wcd9xxx_irq_get_upstream_irq(struct wcd9xxx *wcd9xxx) |
| 576 | { |
| 577 | struct wcd9xxx_irq_drv_data *data; |
| 578 | |
| 579 | /* Hold parent's of node */ |
| 580 | if (!of_node_get(of_irq_find_parent(wcd9xxx->dev->of_node))) |
| 581 | return -EINVAL; |
| 582 | |
| 583 | data = wcd9xxx_get_irq_drv_d(wcd9xxx); |
| 584 | if (!data) { |
| 585 | pr_err("%s: interrupt controller is not registerd\n", __func__); |
| 586 | return 0; |
| 587 | } |
| 588 | |
| 589 | rmb(); |
| 590 | return data->irq; |
| 591 | } |
| 592 | |
| 593 | static void wcd9xxx_irq_put_upstream_irq(struct wcd9xxx *wcd9xxx) |
| 594 | { |
| 595 | /* Hold parent's of node */ |
| 596 | of_node_put(of_irq_find_parent(wcd9xxx->dev->of_node)); |
| 597 | } |
| 598 | |
| 599 | static int wcd9xxx_map_irq(struct wcd9xxx *wcd9xxx, int irq) |
| 600 | { |
| 601 | return of_irq_to_resource(wcd9xxx->dev->of_node, irq, NULL); |
| 602 | } |
| 603 | |
| 604 | static int __devinit wcd9xxx_irq_probe(struct platform_device *pdev) |
| 605 | { |
| 606 | int irq; |
| 607 | struct irq_domain *domain; |
| 608 | struct wcd9xxx_irq_drv_data *data; |
| 609 | int ret = -EINVAL; |
| 610 | |
| 611 | irq = platform_get_irq_byname(pdev, "cdc-int"); |
| 612 | if (irq < 0) { |
| 613 | dev_err(&pdev->dev, "%s: Couldn't find cdc-int node(%d)\n", |
| 614 | __func__, irq); |
| 615 | return -EINVAL; |
| 616 | } else { |
| 617 | dev_dbg(&pdev->dev, "%s: virq = %d\n", __func__, irq); |
| 618 | domain = irq_find_host(pdev->dev.of_node); |
| 619 | data = (struct wcd9xxx_irq_drv_data *)domain->host_data; |
| 620 | data->irq = irq; |
| 621 | wmb(); |
| 622 | ret = 0; |
| 623 | } |
| 624 | |
| 625 | return ret; |
| 626 | } |
| 627 | |
| 628 | static int wcd9xxx_irq_remove(struct platform_device *pdev) |
| 629 | { |
| 630 | struct irq_domain *domain; |
| 631 | struct wcd9xxx_irq_drv_data *data; |
| 632 | |
| 633 | domain = irq_find_host(pdev->dev.of_node); |
| 634 | data = (struct wcd9xxx_irq_drv_data *)domain->host_data; |
| 635 | data->irq = 0; |
| 636 | wmb(); |
| 637 | |
| 638 | return 0; |
| 639 | } |
| 640 | |
| 641 | static const struct of_device_id of_match[] = { |
| 642 | { .compatible = "qcom,wcd9xxx-irq" }, |
| 643 | { } |
| 644 | }; |
| 645 | |
| 646 | static struct platform_driver wcd9xxx_irq_driver = { |
| 647 | .probe = wcd9xxx_irq_probe, |
| 648 | .remove = wcd9xxx_irq_remove, |
| 649 | .driver = { |
| 650 | .name = "wcd9xxx_intc", |
| 651 | .owner = THIS_MODULE, |
| 652 | .of_match_table = of_match_ptr(of_match), |
| 653 | }, |
| 654 | }; |
| 655 | |
| 656 | static int wcd9xxx_irq_drv_init(void) |
| 657 | { |
| 658 | return platform_driver_register(&wcd9xxx_irq_driver); |
| 659 | } |
| 660 | subsys_initcall(wcd9xxx_irq_drv_init); |
| 661 | |
| 662 | static void wcd9xxx_irq_drv_exit(void) |
| 663 | { |
| 664 | platform_driver_unregister(&wcd9xxx_irq_driver); |
| 665 | } |
| 666 | module_exit(wcd9xxx_irq_drv_exit); |
| 667 | #endif /* CONFIG_OF */ |