blob: ba86a918c2dace19be14235f484f380a970d667e [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>
Chanwoo Choi54e88272014-06-25 16:14:44 +090023#include <linux/mfd/samsung/s2mpu02.h>
Sangbeom Kim54227bc2012-07-11 21:07:16 +090024#include <linux/mfd/samsung/s5m8763.h>
25#include <linux/mfd/samsung/s5m8767.h>
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +090026
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +010027static const struct regmap_irq s2mps11_irqs[] = {
Sangbeom Kim6445b842012-07-11 21:08:11 +090028 [S2MPS11_IRQ_PWRONF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053029 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090030 .mask = S2MPS11_IRQ_PWRONF_MASK,
31 },
32 [S2MPS11_IRQ_PWRONR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053033 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090034 .mask = S2MPS11_IRQ_PWRONR_MASK,
35 },
36 [S2MPS11_IRQ_JIGONBF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053037 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090038 .mask = S2MPS11_IRQ_JIGONBF_MASK,
39 },
40 [S2MPS11_IRQ_JIGONBR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053041 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090042 .mask = S2MPS11_IRQ_JIGONBR_MASK,
43 },
44 [S2MPS11_IRQ_ACOKBF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053045 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090046 .mask = S2MPS11_IRQ_ACOKBF_MASK,
47 },
48 [S2MPS11_IRQ_ACOKBR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053049 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090050 .mask = S2MPS11_IRQ_ACOKBR_MASK,
51 },
52 [S2MPS11_IRQ_PWRON1S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053053 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090054 .mask = S2MPS11_IRQ_PWRON1S_MASK,
55 },
56 [S2MPS11_IRQ_MRB] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053057 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090058 .mask = S2MPS11_IRQ_MRB_MASK,
59 },
60 [S2MPS11_IRQ_RTC60S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053061 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090062 .mask = S2MPS11_IRQ_RTC60S_MASK,
63 },
Krzysztof Kozlowski67762092014-02-28 11:41:43 +010064 [S2MPS11_IRQ_RTCA0] = {
65 .reg_offset = 1,
66 .mask = S2MPS11_IRQ_RTCA0_MASK,
67 },
Sangbeom Kim6445b842012-07-11 21:08:11 +090068 [S2MPS11_IRQ_RTCA1] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053069 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090070 .mask = S2MPS11_IRQ_RTCA1_MASK,
71 },
Sangbeom Kim6445b842012-07-11 21:08:11 +090072 [S2MPS11_IRQ_SMPL] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053073 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090074 .mask = S2MPS11_IRQ_SMPL_MASK,
75 },
76 [S2MPS11_IRQ_RTC1S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053077 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090078 .mask = S2MPS11_IRQ_RTC1S_MASK,
79 },
80 [S2MPS11_IRQ_WTSR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053081 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090082 .mask = S2MPS11_IRQ_WTSR_MASK,
83 },
84 [S2MPS11_IRQ_INT120C] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053085 .reg_offset = 2,
Sangbeom Kim6445b842012-07-11 21:08:11 +090086 .mask = S2MPS11_IRQ_INT120C_MASK,
87 },
88 [S2MPS11_IRQ_INT140C] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +053089 .reg_offset = 2,
Sangbeom Kim6445b842012-07-11 21:08:11 +090090 .mask = S2MPS11_IRQ_INT140C_MASK,
91 },
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +090092};
93
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +010094static const struct regmap_irq s2mps14_irqs[] = {
95 [S2MPS14_IRQ_PWRONF] = {
96 .reg_offset = 0,
97 .mask = S2MPS11_IRQ_PWRONF_MASK,
98 },
99 [S2MPS14_IRQ_PWRONR] = {
100 .reg_offset = 0,
101 .mask = S2MPS11_IRQ_PWRONR_MASK,
102 },
103 [S2MPS14_IRQ_JIGONBF] = {
104 .reg_offset = 0,
105 .mask = S2MPS11_IRQ_JIGONBF_MASK,
106 },
107 [S2MPS14_IRQ_JIGONBR] = {
108 .reg_offset = 0,
109 .mask = S2MPS11_IRQ_JIGONBR_MASK,
110 },
111 [S2MPS14_IRQ_ACOKBF] = {
112 .reg_offset = 0,
113 .mask = S2MPS11_IRQ_ACOKBF_MASK,
114 },
115 [S2MPS14_IRQ_ACOKBR] = {
116 .reg_offset = 0,
117 .mask = S2MPS11_IRQ_ACOKBR_MASK,
118 },
119 [S2MPS14_IRQ_PWRON1S] = {
120 .reg_offset = 0,
121 .mask = S2MPS11_IRQ_PWRON1S_MASK,
122 },
123 [S2MPS14_IRQ_MRB] = {
124 .reg_offset = 0,
125 .mask = S2MPS11_IRQ_MRB_MASK,
126 },
127 [S2MPS14_IRQ_RTC60S] = {
128 .reg_offset = 1,
129 .mask = S2MPS11_IRQ_RTC60S_MASK,
130 },
131 [S2MPS14_IRQ_RTCA1] = {
132 .reg_offset = 1,
133 .mask = S2MPS11_IRQ_RTCA1_MASK,
134 },
135 [S2MPS14_IRQ_RTCA0] = {
136 .reg_offset = 1,
137 .mask = S2MPS11_IRQ_RTCA0_MASK,
138 },
139 [S2MPS14_IRQ_SMPL] = {
140 .reg_offset = 1,
141 .mask = S2MPS11_IRQ_SMPL_MASK,
142 },
143 [S2MPS14_IRQ_RTC1S] = {
144 .reg_offset = 1,
145 .mask = S2MPS11_IRQ_RTC1S_MASK,
146 },
147 [S2MPS14_IRQ_WTSR] = {
148 .reg_offset = 1,
149 .mask = S2MPS11_IRQ_WTSR_MASK,
150 },
151 [S2MPS14_IRQ_INT120C] = {
152 .reg_offset = 2,
153 .mask = S2MPS11_IRQ_INT120C_MASK,
154 },
155 [S2MPS14_IRQ_INT140C] = {
156 .reg_offset = 2,
157 .mask = S2MPS11_IRQ_INT140C_MASK,
158 },
159 [S2MPS14_IRQ_TSD] = {
160 .reg_offset = 2,
161 .mask = S2MPS14_IRQ_TSD_MASK,
162 },
163};
Sangbeom Kim6445b842012-07-11 21:08:11 +0900164
Chanwoo Choi54e88272014-06-25 16:14:44 +0900165static const struct regmap_irq s2mpu02_irqs[] = {
166 [S2MPU02_IRQ_PWRONF] = {
167 .reg_offset = 0,
168 .mask = S2MPS11_IRQ_PWRONF_MASK,
169 },
170 [S2MPU02_IRQ_PWRONR] = {
171 .reg_offset = 0,
172 .mask = S2MPS11_IRQ_PWRONR_MASK,
173 },
174 [S2MPU02_IRQ_JIGONBF] = {
175 .reg_offset = 0,
176 .mask = S2MPS11_IRQ_JIGONBF_MASK,
177 },
178 [S2MPU02_IRQ_JIGONBR] = {
179 .reg_offset = 0,
180 .mask = S2MPS11_IRQ_JIGONBR_MASK,
181 },
182 [S2MPU02_IRQ_ACOKBF] = {
183 .reg_offset = 0,
184 .mask = S2MPS11_IRQ_ACOKBF_MASK,
185 },
186 [S2MPU02_IRQ_ACOKBR] = {
187 .reg_offset = 0,
188 .mask = S2MPS11_IRQ_ACOKBR_MASK,
189 },
190 [S2MPU02_IRQ_PWRON1S] = {
191 .reg_offset = 0,
192 .mask = S2MPS11_IRQ_PWRON1S_MASK,
193 },
194 [S2MPU02_IRQ_MRB] = {
195 .reg_offset = 0,
196 .mask = S2MPS11_IRQ_MRB_MASK,
197 },
198 [S2MPU02_IRQ_RTC60S] = {
199 .reg_offset = 1,
200 .mask = S2MPS11_IRQ_RTC60S_MASK,
201 },
202 [S2MPU02_IRQ_RTCA1] = {
203 .reg_offset = 1,
204 .mask = S2MPS11_IRQ_RTCA1_MASK,
205 },
206 [S2MPU02_IRQ_RTCA0] = {
207 .reg_offset = 1,
208 .mask = S2MPS11_IRQ_RTCA0_MASK,
209 },
210 [S2MPU02_IRQ_SMPL] = {
211 .reg_offset = 1,
212 .mask = S2MPS11_IRQ_SMPL_MASK,
213 },
214 [S2MPU02_IRQ_RTC1S] = {
215 .reg_offset = 1,
216 .mask = S2MPS11_IRQ_RTC1S_MASK,
217 },
218 [S2MPU02_IRQ_WTSR] = {
219 .reg_offset = 1,
220 .mask = S2MPS11_IRQ_WTSR_MASK,
221 },
222 [S2MPU02_IRQ_INT120C] = {
223 .reg_offset = 2,
224 .mask = S2MPS11_IRQ_INT120C_MASK,
225 },
226 [S2MPU02_IRQ_INT140C] = {
227 .reg_offset = 2,
228 .mask = S2MPS11_IRQ_INT140C_MASK,
229 },
230 [S2MPU02_IRQ_TSD] = {
231 .reg_offset = 2,
232 .mask = S2MPS14_IRQ_TSD_MASK,
233 },
234};
235
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100236static const struct regmap_irq s5m8767_irqs[] = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900237 [S5M8767_IRQ_PWRR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530238 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900239 .mask = S5M8767_IRQ_PWRR_MASK,
240 },
241 [S5M8767_IRQ_PWRF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530242 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900243 .mask = S5M8767_IRQ_PWRF_MASK,
244 },
245 [S5M8767_IRQ_PWR1S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530246 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900247 .mask = S5M8767_IRQ_PWR1S_MASK,
248 },
249 [S5M8767_IRQ_JIGR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530250 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900251 .mask = S5M8767_IRQ_JIGR_MASK,
252 },
253 [S5M8767_IRQ_JIGF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530254 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900255 .mask = S5M8767_IRQ_JIGF_MASK,
256 },
257 [S5M8767_IRQ_LOWBAT2] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530258 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900259 .mask = S5M8767_IRQ_LOWBAT2_MASK,
260 },
261 [S5M8767_IRQ_LOWBAT1] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530262 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900263 .mask = S5M8767_IRQ_LOWBAT1_MASK,
264 },
265 [S5M8767_IRQ_MRB] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530266 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900267 .mask = S5M8767_IRQ_MRB_MASK,
268 },
269 [S5M8767_IRQ_DVSOK2] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530270 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900271 .mask = S5M8767_IRQ_DVSOK2_MASK,
272 },
273 [S5M8767_IRQ_DVSOK3] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530274 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900275 .mask = S5M8767_IRQ_DVSOK3_MASK,
276 },
277 [S5M8767_IRQ_DVSOK4] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530278 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900279 .mask = S5M8767_IRQ_DVSOK4_MASK,
280 },
281 [S5M8767_IRQ_RTC60S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530282 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900283 .mask = S5M8767_IRQ_RTC60S_MASK,
284 },
285 [S5M8767_IRQ_RTCA1] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530286 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900287 .mask = S5M8767_IRQ_RTCA1_MASK,
288 },
289 [S5M8767_IRQ_RTCA2] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530290 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900291 .mask = S5M8767_IRQ_RTCA2_MASK,
292 },
293 [S5M8767_IRQ_SMPL] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530294 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900295 .mask = S5M8767_IRQ_SMPL_MASK,
296 },
297 [S5M8767_IRQ_RTC1S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530298 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900299 .mask = S5M8767_IRQ_RTC1S_MASK,
300 },
301 [S5M8767_IRQ_WTSR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530302 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900303 .mask = S5M8767_IRQ_WTSR_MASK,
304 },
305};
306
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100307static const struct regmap_irq s5m8763_irqs[] = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900308 [S5M8763_IRQ_DCINF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530309 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900310 .mask = S5M8763_IRQ_DCINF_MASK,
311 },
312 [S5M8763_IRQ_DCINR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530313 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900314 .mask = S5M8763_IRQ_DCINR_MASK,
315 },
316 [S5M8763_IRQ_JIGF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530317 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900318 .mask = S5M8763_IRQ_JIGF_MASK,
319 },
320 [S5M8763_IRQ_JIGR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530321 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900322 .mask = S5M8763_IRQ_JIGR_MASK,
323 },
324 [S5M8763_IRQ_PWRONF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530325 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900326 .mask = S5M8763_IRQ_PWRONF_MASK,
327 },
328 [S5M8763_IRQ_PWRONR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530329 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900330 .mask = S5M8763_IRQ_PWRONR_MASK,
331 },
332 [S5M8763_IRQ_WTSREVNT] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530333 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900334 .mask = S5M8763_IRQ_WTSREVNT_MASK,
335 },
336 [S5M8763_IRQ_SMPLEVNT] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530337 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900338 .mask = S5M8763_IRQ_SMPLEVNT_MASK,
339 },
340 [S5M8763_IRQ_ALARM1] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530341 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900342 .mask = S5M8763_IRQ_ALARM1_MASK,
343 },
344 [S5M8763_IRQ_ALARM0] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530345 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900346 .mask = S5M8763_IRQ_ALARM0_MASK,
347 },
348 [S5M8763_IRQ_ONKEY1S] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530349 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900350 .mask = S5M8763_IRQ_ONKEY1S_MASK,
351 },
352 [S5M8763_IRQ_TOPOFFR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530353 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900354 .mask = S5M8763_IRQ_TOPOFFR_MASK,
355 },
356 [S5M8763_IRQ_DCINOVPR] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530357 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900358 .mask = S5M8763_IRQ_DCINOVPR_MASK,
359 },
360 [S5M8763_IRQ_CHGRSTF] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530361 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900362 .mask = S5M8763_IRQ_CHGRSTF_MASK,
363 },
364 [S5M8763_IRQ_DONER] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530365 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900366 .mask = S5M8763_IRQ_DONER_MASK,
367 },
368 [S5M8763_IRQ_CHGFAULT] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530369 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900370 .mask = S5M8763_IRQ_CHGFAULT_MASK,
371 },
372 [S5M8763_IRQ_LOBAT1] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530373 .reg_offset = 3,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900374 .mask = S5M8763_IRQ_LOBAT1_MASK,
375 },
376 [S5M8763_IRQ_LOBAT2] = {
Inderpal Singh5e393a22012-10-17 11:48:55 +0530377 .reg_offset = 3,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900378 .mask = S5M8763_IRQ_LOBAT2_MASK,
379 },
380};
381
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100382static const struct regmap_irq_chip s2mps11_irq_chip = {
Sangbeom Kim6445b842012-07-11 21:08:11 +0900383 .name = "s2mps11",
384 .irqs = s2mps11_irqs,
385 .num_irqs = ARRAY_SIZE(s2mps11_irqs),
386 .num_regs = 3,
387 .status_base = S2MPS11_REG_INT1,
388 .mask_base = S2MPS11_REG_INT1M,
389 .ack_base = S2MPS11_REG_INT1,
390};
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900391
Chanwoo Choi3bc2ee92014-11-18 17:59:39 +0900392#define S2MPS1X_IRQ_CHIP_COMMON_DATA \
393 .irqs = s2mps14_irqs, \
394 .num_irqs = ARRAY_SIZE(s2mps14_irqs), \
395 .num_regs = 3, \
396 .status_base = S2MPS14_REG_INT1, \
397 .mask_base = S2MPS14_REG_INT1M, \
398 .ack_base = S2MPS14_REG_INT1 \
399
400static const struct regmap_irq_chip s2mps13_irq_chip = {
401 .name = "s2mps13",
402 S2MPS1X_IRQ_CHIP_COMMON_DATA,
403};
404
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +0100405static const struct regmap_irq_chip s2mps14_irq_chip = {
406 .name = "s2mps14",
Chanwoo Choi3bc2ee92014-11-18 17:59:39 +0900407 S2MPS1X_IRQ_CHIP_COMMON_DATA,
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +0100408};
409
Chanwoo Choi54e88272014-06-25 16:14:44 +0900410static const struct regmap_irq_chip s2mpu02_irq_chip = {
411 .name = "s2mpu02",
412 .irqs = s2mpu02_irqs,
413 .num_irqs = ARRAY_SIZE(s2mpu02_irqs),
414 .num_regs = 3,
415 .status_base = S2MPU02_REG_INT1,
416 .mask_base = S2MPU02_REG_INT1M,
417 .ack_base = S2MPU02_REG_INT1,
418};
419
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100420static const struct regmap_irq_chip s5m8767_irq_chip = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900421 .name = "s5m8767",
Sangbeom Kim6445b842012-07-11 21:08:11 +0900422 .irqs = s5m8767_irqs,
423 .num_irqs = ARRAY_SIZE(s5m8767_irqs),
424 .num_regs = 3,
425 .status_base = S5M8767_REG_INT1,
426 .mask_base = S5M8767_REG_INT1M,
427 .ack_base = S5M8767_REG_INT1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900428};
429
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100430static const struct regmap_irq_chip s5m8763_irq_chip = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900431 .name = "s5m8763",
Sangbeom Kim6445b842012-07-11 21:08:11 +0900432 .irqs = s5m8763_irqs,
433 .num_irqs = ARRAY_SIZE(s5m8763_irqs),
434 .num_regs = 4,
435 .status_base = S5M8763_REG_IRQ1,
436 .mask_base = S5M8763_REG_IRQM1,
437 .ack_base = S5M8763_REG_IRQ1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900438};
439
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900440int sec_irq_init(struct sec_pmic_dev *sec_pmic)
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900441{
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900442 int ret = 0;
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900443 int type = sec_pmic->device_type;
Chanwoo Choi54e88272014-06-25 16:14:44 +0900444 const struct regmap_irq_chip *sec_irq_chip;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900445
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900446 if (!sec_pmic->irq) {
447 dev_warn(sec_pmic->dev,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900448 "No interrupt specified, no interrupts\n");
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900449 sec_pmic->irq_base = 0;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900450 return 0;
451 }
452
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900453 switch (type) {
454 case S5M8763X:
Chanwoo Choi54e88272014-06-25 16:14:44 +0900455 sec_irq_chip = &s5m8763_irq_chip;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900456 break;
457 case S5M8767X:
Chanwoo Choi54e88272014-06-25 16:14:44 +0900458 sec_irq_chip = &s5m8767_irq_chip;
Sangbeom Kim6445b842012-07-11 21:08:11 +0900459 break;
460 case S2MPS11X:
Chanwoo Choi54e88272014-06-25 16:14:44 +0900461 sec_irq_chip = &s2mps11_irq_chip;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900462 break;
Chanwoo Choi3bc2ee92014-11-18 17:59:39 +0900463 case S2MPS13X:
464 sec_irq_chip = &s2mps13_irq_chip;
465 break;
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +0100466 case S2MPS14X:
Chanwoo Choi54e88272014-06-25 16:14:44 +0900467 sec_irq_chip = &s2mps14_irq_chip;
468 break;
469 case S2MPU02:
470 sec_irq_chip = &s2mpu02_irq_chip;
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +0100471 break;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900472 default:
Krzysztof Kozlowski9549b5f2014-04-23 16:13:05 +0200473 dev_err(sec_pmic->dev, "Unknown device type %lu\n",
Sangbeom Kim6445b842012-07-11 21:08:11 +0900474 sec_pmic->device_type);
Jonghwan Choic7a1fcf2012-02-20 16:22:56 +0100475 return -EINVAL;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900476 }
477
Chanwoo Choi54e88272014-06-25 16:14:44 +0900478 ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq,
479 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
480 sec_pmic->irq_base, sec_irq_chip,
481 &sec_pmic->irq_data);
Sangbeom Kim6445b842012-07-11 21:08:11 +0900482 if (ret != 0) {
483 dev_err(sec_pmic->dev, "Failed to register IRQ chip: %d\n", ret);
Jonghwan Choic7a1fcf2012-02-20 16:22:56 +0100484 return ret;
485 }
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900486
487 return 0;
488}
489
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900490void sec_irq_exit(struct sec_pmic_dev *sec_pmic)
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900491{
Sangbeom Kim6445b842012-07-11 21:08:11 +0900492 regmap_del_irq_chip(sec_pmic->irq, sec_pmic->irq_data);
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900493}