blob: 64e7913aadc6cf3fbe68389edd8ba986e7a1ec8c [file] [log] [blame]
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +09001/*
Sangbeom Kim63063bf2012-07-11 21:06:55 +09002 * sec-irq.c
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +09003 *
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +01004 * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +09005 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#include <linux/device.h>
15#include <linux/interrupt.h>
16#include <linux/irq.h>
Sangbeom Kim6445b842012-07-11 21:08:11 +090017#include <linux/regmap.h>
18
Sangbeom Kim54227bc2012-07-11 21:07:16 +090019#include <linux/mfd/samsung/core.h>
20#include <linux/mfd/samsung/irq.h>
Sangbeom Kim6445b842012-07-11 21:08:11 +090021#include <linux/mfd/samsung/s2mps11.h>
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +010022#include <linux/mfd/samsung/s2mps14.h>
Sangbeom Kim54227bc2012-07-11 21:07:16 +090023#include <linux/mfd/samsung/s5m8763.h>
24#include <linux/mfd/samsung/s5m8767.h>
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +090025
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +010026static const struct regmap_irq s2mps11_irqs[] = {
Sangbeom Kim6445b842012-07-11 21:08:11 +090027 [S2MPS11_IRQ_PWRONF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053028 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090029 .mask = S2MPS11_IRQ_PWRONF_MASK,
30 },
31 [S2MPS11_IRQ_PWRONR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053032 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090033 .mask = S2MPS11_IRQ_PWRONR_MASK,
34 },
35 [S2MPS11_IRQ_JIGONBF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053036 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090037 .mask = S2MPS11_IRQ_JIGONBF_MASK,
38 },
39 [S2MPS11_IRQ_JIGONBR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053040 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090041 .mask = S2MPS11_IRQ_JIGONBR_MASK,
42 },
43 [S2MPS11_IRQ_ACOKBF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053044 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090045 .mask = S2MPS11_IRQ_ACOKBF_MASK,
46 },
47 [S2MPS11_IRQ_ACOKBR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053048 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090049 .mask = S2MPS11_IRQ_ACOKBR_MASK,
50 },
51 [S2MPS11_IRQ_PWRON1S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053052 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090053 .mask = S2MPS11_IRQ_PWRON1S_MASK,
54 },
55 [S2MPS11_IRQ_MRB] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053056 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090057 .mask = S2MPS11_IRQ_MRB_MASK,
58 },
59 [S2MPS11_IRQ_RTC60S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053060 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090061 .mask = S2MPS11_IRQ_RTC60S_MASK,
62 },
Krzysztof Kozlowski67762092014-02-28 11:41:43 +010063 [S2MPS11_IRQ_RTCA0] = {
64 .reg_offset = 1,
65 .mask = S2MPS11_IRQ_RTCA0_MASK,
66 },
Sangbeom Kim6445b842012-07-11 21:08:11 +090067 [S2MPS11_IRQ_RTCA1] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053068 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090069 .mask = S2MPS11_IRQ_RTCA1_MASK,
70 },
Sangbeom Kim6445b842012-07-11 21:08:11 +090071 [S2MPS11_IRQ_SMPL] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053072 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090073 .mask = S2MPS11_IRQ_SMPL_MASK,
74 },
75 [S2MPS11_IRQ_RTC1S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053076 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090077 .mask = S2MPS11_IRQ_RTC1S_MASK,
78 },
79 [S2MPS11_IRQ_WTSR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053080 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090081 .mask = S2MPS11_IRQ_WTSR_MASK,
82 },
83 [S2MPS11_IRQ_INT120C] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053084 .reg_offset = 2,
Sangbeom Kim6445b842012-07-11 21:08:11 +090085 .mask = S2MPS11_IRQ_INT120C_MASK,
86 },
87 [S2MPS11_IRQ_INT140C] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053088 .reg_offset = 2,
Sangbeom Kim6445b842012-07-11 21:08:11 +090089 .mask = S2MPS11_IRQ_INT140C_MASK,
90 },
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +090091};
92
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +010093static const struct regmap_irq s2mps14_irqs[] = {
94 [S2MPS14_IRQ_PWRONF] = {
95 .reg_offset = 0,
96 .mask = S2MPS11_IRQ_PWRONF_MASK,
97 },
98 [S2MPS14_IRQ_PWRONR] = {
99 .reg_offset = 0,
100 .mask = S2MPS11_IRQ_PWRONR_MASK,
101 },
102 [S2MPS14_IRQ_JIGONBF] = {
103 .reg_offset = 0,
104 .mask = S2MPS11_IRQ_JIGONBF_MASK,
105 },
106 [S2MPS14_IRQ_JIGONBR] = {
107 .reg_offset = 0,
108 .mask = S2MPS11_IRQ_JIGONBR_MASK,
109 },
110 [S2MPS14_IRQ_ACOKBF] = {
111 .reg_offset = 0,
112 .mask = S2MPS11_IRQ_ACOKBF_MASK,
113 },
114 [S2MPS14_IRQ_ACOKBR] = {
115 .reg_offset = 0,
116 .mask = S2MPS11_IRQ_ACOKBR_MASK,
117 },
118 [S2MPS14_IRQ_PWRON1S] = {
119 .reg_offset = 0,
120 .mask = S2MPS11_IRQ_PWRON1S_MASK,
121 },
122 [S2MPS14_IRQ_MRB] = {
123 .reg_offset = 0,
124 .mask = S2MPS11_IRQ_MRB_MASK,
125 },
126 [S2MPS14_IRQ_RTC60S] = {
127 .reg_offset = 1,
128 .mask = S2MPS11_IRQ_RTC60S_MASK,
129 },
130 [S2MPS14_IRQ_RTCA1] = {
131 .reg_offset = 1,
132 .mask = S2MPS11_IRQ_RTCA1_MASK,
133 },
134 [S2MPS14_IRQ_RTCA0] = {
135 .reg_offset = 1,
136 .mask = S2MPS11_IRQ_RTCA0_MASK,
137 },
138 [S2MPS14_IRQ_SMPL] = {
139 .reg_offset = 1,
140 .mask = S2MPS11_IRQ_SMPL_MASK,
141 },
142 [S2MPS14_IRQ_RTC1S] = {
143 .reg_offset = 1,
144 .mask = S2MPS11_IRQ_RTC1S_MASK,
145 },
146 [S2MPS14_IRQ_WTSR] = {
147 .reg_offset = 1,
148 .mask = S2MPS11_IRQ_WTSR_MASK,
149 },
150 [S2MPS14_IRQ_INT120C] = {
151 .reg_offset = 2,
152 .mask = S2MPS11_IRQ_INT120C_MASK,
153 },
154 [S2MPS14_IRQ_INT140C] = {
155 .reg_offset = 2,
156 .mask = S2MPS11_IRQ_INT140C_MASK,
157 },
158 [S2MPS14_IRQ_TSD] = {
159 .reg_offset = 2,
160 .mask = S2MPS14_IRQ_TSD_MASK,
161 },
162};
Sangbeom Kim6445b842012-07-11 21:08:11 +0900163
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100164static const struct regmap_irq s5m8767_irqs[] = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900165 [S5M8767_IRQ_PWRR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530166 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900167 .mask = S5M8767_IRQ_PWRR_MASK,
168 },
169 [S5M8767_IRQ_PWRF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530170 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900171 .mask = S5M8767_IRQ_PWRF_MASK,
172 },
173 [S5M8767_IRQ_PWR1S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530174 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900175 .mask = S5M8767_IRQ_PWR1S_MASK,
176 },
177 [S5M8767_IRQ_JIGR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530178 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900179 .mask = S5M8767_IRQ_JIGR_MASK,
180 },
181 [S5M8767_IRQ_JIGF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530182 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900183 .mask = S5M8767_IRQ_JIGF_MASK,
184 },
185 [S5M8767_IRQ_LOWBAT2] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530186 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900187 .mask = S5M8767_IRQ_LOWBAT2_MASK,
188 },
189 [S5M8767_IRQ_LOWBAT1] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530190 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900191 .mask = S5M8767_IRQ_LOWBAT1_MASK,
192 },
193 [S5M8767_IRQ_MRB] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530194 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900195 .mask = S5M8767_IRQ_MRB_MASK,
196 },
197 [S5M8767_IRQ_DVSOK2] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530198 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900199 .mask = S5M8767_IRQ_DVSOK2_MASK,
200 },
201 [S5M8767_IRQ_DVSOK3] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530202 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900203 .mask = S5M8767_IRQ_DVSOK3_MASK,
204 },
205 [S5M8767_IRQ_DVSOK4] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530206 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900207 .mask = S5M8767_IRQ_DVSOK4_MASK,
208 },
209 [S5M8767_IRQ_RTC60S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530210 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900211 .mask = S5M8767_IRQ_RTC60S_MASK,
212 },
213 [S5M8767_IRQ_RTCA1] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530214 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900215 .mask = S5M8767_IRQ_RTCA1_MASK,
216 },
217 [S5M8767_IRQ_RTCA2] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530218 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900219 .mask = S5M8767_IRQ_RTCA2_MASK,
220 },
221 [S5M8767_IRQ_SMPL] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530222 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900223 .mask = S5M8767_IRQ_SMPL_MASK,
224 },
225 [S5M8767_IRQ_RTC1S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530226 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900227 .mask = S5M8767_IRQ_RTC1S_MASK,
228 },
229 [S5M8767_IRQ_WTSR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530230 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900231 .mask = S5M8767_IRQ_WTSR_MASK,
232 },
233};
234
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100235static const struct regmap_irq s5m8763_irqs[] = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900236 [S5M8763_IRQ_DCINF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530237 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900238 .mask = S5M8763_IRQ_DCINF_MASK,
239 },
240 [S5M8763_IRQ_DCINR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530241 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900242 .mask = S5M8763_IRQ_DCINR_MASK,
243 },
244 [S5M8763_IRQ_JIGF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530245 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900246 .mask = S5M8763_IRQ_JIGF_MASK,
247 },
248 [S5M8763_IRQ_JIGR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530249 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900250 .mask = S5M8763_IRQ_JIGR_MASK,
251 },
252 [S5M8763_IRQ_PWRONF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530253 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900254 .mask = S5M8763_IRQ_PWRONF_MASK,
255 },
256 [S5M8763_IRQ_PWRONR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530257 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900258 .mask = S5M8763_IRQ_PWRONR_MASK,
259 },
260 [S5M8763_IRQ_WTSREVNT] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530261 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900262 .mask = S5M8763_IRQ_WTSREVNT_MASK,
263 },
264 [S5M8763_IRQ_SMPLEVNT] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530265 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900266 .mask = S5M8763_IRQ_SMPLEVNT_MASK,
267 },
268 [S5M8763_IRQ_ALARM1] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530269 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900270 .mask = S5M8763_IRQ_ALARM1_MASK,
271 },
272 [S5M8763_IRQ_ALARM0] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530273 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900274 .mask = S5M8763_IRQ_ALARM0_MASK,
275 },
276 [S5M8763_IRQ_ONKEY1S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530277 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900278 .mask = S5M8763_IRQ_ONKEY1S_MASK,
279 },
280 [S5M8763_IRQ_TOPOFFR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530281 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900282 .mask = S5M8763_IRQ_TOPOFFR_MASK,
283 },
284 [S5M8763_IRQ_DCINOVPR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530285 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900286 .mask = S5M8763_IRQ_DCINOVPR_MASK,
287 },
288 [S5M8763_IRQ_CHGRSTF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530289 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900290 .mask = S5M8763_IRQ_CHGRSTF_MASK,
291 },
292 [S5M8763_IRQ_DONER] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530293 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900294 .mask = S5M8763_IRQ_DONER_MASK,
295 },
296 [S5M8763_IRQ_CHGFAULT] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530297 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900298 .mask = S5M8763_IRQ_CHGFAULT_MASK,
299 },
300 [S5M8763_IRQ_LOBAT1] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530301 .reg_offset = 3,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900302 .mask = S5M8763_IRQ_LOBAT1_MASK,
303 },
304 [S5M8763_IRQ_LOBAT2] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530305 .reg_offset = 3,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900306 .mask = S5M8763_IRQ_LOBAT2_MASK,
307 },
308};
309
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100310static const struct regmap_irq_chip s2mps11_irq_chip = {
Sangbeom Kim6445b842012-07-11 21:08:11 +0900311 .name = "s2mps11",
312 .irqs = s2mps11_irqs,
313 .num_irqs = ARRAY_SIZE(s2mps11_irqs),
314 .num_regs = 3,
315 .status_base = S2MPS11_REG_INT1,
316 .mask_base = S2MPS11_REG_INT1M,
317 .ack_base = S2MPS11_REG_INT1,
318};
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900319
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +0100320static const struct regmap_irq_chip s2mps14_irq_chip = {
321 .name = "s2mps14",
322 .irqs = s2mps14_irqs,
323 .num_irqs = ARRAY_SIZE(s2mps14_irqs),
324 .num_regs = 3,
325 .status_base = S2MPS14_REG_INT1,
326 .mask_base = S2MPS14_REG_INT1M,
327 .ack_base = S2MPS14_REG_INT1,
328};
329
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100330static const struct regmap_irq_chip s5m8767_irq_chip = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900331 .name = "s5m8767",
Sangbeom Kim6445b842012-07-11 21:08:11 +0900332 .irqs = s5m8767_irqs,
333 .num_irqs = ARRAY_SIZE(s5m8767_irqs),
334 .num_regs = 3,
335 .status_base = S5M8767_REG_INT1,
336 .mask_base = S5M8767_REG_INT1M,
337 .ack_base = S5M8767_REG_INT1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900338};
339
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100340static const struct regmap_irq_chip s5m8763_irq_chip = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900341 .name = "s5m8763",
Sangbeom Kim6445b842012-07-11 21:08:11 +0900342 .irqs = s5m8763_irqs,
343 .num_irqs = ARRAY_SIZE(s5m8763_irqs),
344 .num_regs = 4,
345 .status_base = S5M8763_REG_IRQ1,
346 .mask_base = S5M8763_REG_IRQM1,
347 .ack_base = S5M8763_REG_IRQ1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900348};
349
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900350int sec_irq_init(struct sec_pmic_dev *sec_pmic)
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900351{
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900352 int ret = 0;
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900353 int type = sec_pmic->device_type;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900354
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900355 if (!sec_pmic->irq) {
356 dev_warn(sec_pmic->dev,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900357 "No interrupt specified, no interrupts\n");
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900358 sec_pmic->irq_base = 0;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900359 return 0;
360 }
361
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900362 switch (type) {
363 case S5M8763X:
Krzysztof Kozlowski3e1e4a52013-12-12 17:12:31 -0800364 ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq,
Sangbeom Kim6445b842012-07-11 21:08:11 +0900365 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
366 sec_pmic->irq_base, &s5m8763_irq_chip,
367 &sec_pmic->irq_data);
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900368 break;
369 case S5M8767X:
Krzysztof Kozlowski3e1e4a52013-12-12 17:12:31 -0800370 ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq,
Sangbeom Kim6445b842012-07-11 21:08:11 +0900371 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
372 sec_pmic->irq_base, &s5m8767_irq_chip,
373 &sec_pmic->irq_data);
374 break;
375 case S2MPS11X:
Krzysztof Kozlowski3e1e4a52013-12-12 17:12:31 -0800376 ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq,
Sangbeom Kim6445b842012-07-11 21:08:11 +0900377 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
378 sec_pmic->irq_base, &s2mps11_irq_chip,
379 &sec_pmic->irq_data);
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900380 break;
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +0100381 case S2MPS14X:
382 ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq,
383 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
384 sec_pmic->irq_base, &s2mps14_irq_chip,
385 &sec_pmic->irq_data);
386 break;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900387 default:
Sangbeom Kim6445b842012-07-11 21:08:11 +0900388 dev_err(sec_pmic->dev, "Unknown device type %d\n",
389 sec_pmic->device_type);
Jonghwan Choic7a1fcf2012-02-20 16:22:56 +0100390 return -EINVAL;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900391 }
392
Sangbeom Kim6445b842012-07-11 21:08:11 +0900393 if (ret != 0) {
394 dev_err(sec_pmic->dev, "Failed to register IRQ chip: %d\n", ret);
Jonghwan Choic7a1fcf2012-02-20 16:22:56 +0100395 return ret;
396 }
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900397
398 return 0;
399}
400
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900401void sec_irq_exit(struct sec_pmic_dev *sec_pmic)
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900402{
Sangbeom Kim6445b842012-07-11 21:08:11 +0900403 regmap_del_irq_chip(sec_pmic->irq, sec_pmic->irq_data);
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900404}