blob: f5f59fdc72fec6ffa5fabd8e3e8e7fd646aec895 [file] [log] [blame]
Krzysztof Kozlowski39b27ad2018-08-07 18:11:22 +02001// SPDX-License-Identifier: GPL-2.0+
2//
3// Copyright (c) 2011-2014 Samsung Electronics Co., Ltd
4// http://www.samsung.com
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +09005
6#include <linux/device.h>
7#include <linux/interrupt.h>
8#include <linux/irq.h>
Krzysztof Kozlowskieef05942018-08-07 18:11:25 +02009#include <linux/module.h>
Sangbeom Kim6445b842012-07-11 21:08:11 +090010#include <linux/regmap.h>
11
Sangbeom Kim54227bc2012-07-11 21:07:16 +090012#include <linux/mfd/samsung/core.h>
13#include <linux/mfd/samsung/irq.h>
Sangbeom Kim6445b842012-07-11 21:08:11 +090014#include <linux/mfd/samsung/s2mps11.h>
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +010015#include <linux/mfd/samsung/s2mps14.h>
Chanwoo Choi54e88272014-06-25 16:14:44 +090016#include <linux/mfd/samsung/s2mpu02.h>
Sangbeom Kim54227bc2012-07-11 21:07:16 +090017#include <linux/mfd/samsung/s5m8763.h>
18#include <linux/mfd/samsung/s5m8767.h>
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +090019
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +010020static const struct regmap_irq s2mps11_irqs[] = {
Sangbeom Kim6445b842012-07-11 21:08:11 +090021 [S2MPS11_IRQ_PWRONF] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053022 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090023 .mask = S2MPS11_IRQ_PWRONF_MASK,
24 },
25 [S2MPS11_IRQ_PWRONR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053026 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090027 .mask = S2MPS11_IRQ_PWRONR_MASK,
28 },
29 [S2MPS11_IRQ_JIGONBF] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053030 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090031 .mask = S2MPS11_IRQ_JIGONBF_MASK,
32 },
33 [S2MPS11_IRQ_JIGONBR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053034 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090035 .mask = S2MPS11_IRQ_JIGONBR_MASK,
36 },
37 [S2MPS11_IRQ_ACOKBF] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053038 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090039 .mask = S2MPS11_IRQ_ACOKBF_MASK,
40 },
41 [S2MPS11_IRQ_ACOKBR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053042 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090043 .mask = S2MPS11_IRQ_ACOKBR_MASK,
44 },
45 [S2MPS11_IRQ_PWRON1S] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053046 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090047 .mask = S2MPS11_IRQ_PWRON1S_MASK,
48 },
49 [S2MPS11_IRQ_MRB] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053050 .reg_offset = 0,
Sangbeom Kim6445b842012-07-11 21:08:11 +090051 .mask = S2MPS11_IRQ_MRB_MASK,
52 },
53 [S2MPS11_IRQ_RTC60S] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053054 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090055 .mask = S2MPS11_IRQ_RTC60S_MASK,
56 },
57 [S2MPS11_IRQ_RTCA1] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053058 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090059 .mask = S2MPS11_IRQ_RTCA1_MASK,
60 },
Krzysztof Kozlowskie554a992015-04-02 16:36:15 +020061 [S2MPS11_IRQ_RTCA0] = {
62 .reg_offset = 1,
63 .mask = S2MPS11_IRQ_RTCA0_MASK,
64 },
Sangbeom Kim6445b842012-07-11 21:08:11 +090065 [S2MPS11_IRQ_SMPL] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053066 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090067 .mask = S2MPS11_IRQ_SMPL_MASK,
68 },
69 [S2MPS11_IRQ_RTC1S] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053070 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090071 .mask = S2MPS11_IRQ_RTC1S_MASK,
72 },
73 [S2MPS11_IRQ_WTSR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053074 .reg_offset = 1,
Sangbeom Kim6445b842012-07-11 21:08:11 +090075 .mask = S2MPS11_IRQ_WTSR_MASK,
76 },
77 [S2MPS11_IRQ_INT120C] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053078 .reg_offset = 2,
Sangbeom Kim6445b842012-07-11 21:08:11 +090079 .mask = S2MPS11_IRQ_INT120C_MASK,
80 },
81 [S2MPS11_IRQ_INT140C] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +053082 .reg_offset = 2,
Sangbeom Kim6445b842012-07-11 21:08:11 +090083 .mask = S2MPS11_IRQ_INT140C_MASK,
84 },
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +090085};
86
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +010087static const struct regmap_irq s2mps14_irqs[] = {
88 [S2MPS14_IRQ_PWRONF] = {
89 .reg_offset = 0,
90 .mask = S2MPS11_IRQ_PWRONF_MASK,
91 },
92 [S2MPS14_IRQ_PWRONR] = {
93 .reg_offset = 0,
94 .mask = S2MPS11_IRQ_PWRONR_MASK,
95 },
96 [S2MPS14_IRQ_JIGONBF] = {
97 .reg_offset = 0,
98 .mask = S2MPS11_IRQ_JIGONBF_MASK,
99 },
100 [S2MPS14_IRQ_JIGONBR] = {
101 .reg_offset = 0,
102 .mask = S2MPS11_IRQ_JIGONBR_MASK,
103 },
104 [S2MPS14_IRQ_ACOKBF] = {
105 .reg_offset = 0,
106 .mask = S2MPS11_IRQ_ACOKBF_MASK,
107 },
108 [S2MPS14_IRQ_ACOKBR] = {
109 .reg_offset = 0,
110 .mask = S2MPS11_IRQ_ACOKBR_MASK,
111 },
112 [S2MPS14_IRQ_PWRON1S] = {
113 .reg_offset = 0,
114 .mask = S2MPS11_IRQ_PWRON1S_MASK,
115 },
116 [S2MPS14_IRQ_MRB] = {
117 .reg_offset = 0,
118 .mask = S2MPS11_IRQ_MRB_MASK,
119 },
120 [S2MPS14_IRQ_RTC60S] = {
121 .reg_offset = 1,
122 .mask = S2MPS11_IRQ_RTC60S_MASK,
123 },
124 [S2MPS14_IRQ_RTCA1] = {
125 .reg_offset = 1,
126 .mask = S2MPS11_IRQ_RTCA1_MASK,
127 },
128 [S2MPS14_IRQ_RTCA0] = {
129 .reg_offset = 1,
130 .mask = S2MPS11_IRQ_RTCA0_MASK,
131 },
132 [S2MPS14_IRQ_SMPL] = {
133 .reg_offset = 1,
134 .mask = S2MPS11_IRQ_SMPL_MASK,
135 },
136 [S2MPS14_IRQ_RTC1S] = {
137 .reg_offset = 1,
138 .mask = S2MPS11_IRQ_RTC1S_MASK,
139 },
140 [S2MPS14_IRQ_WTSR] = {
141 .reg_offset = 1,
142 .mask = S2MPS11_IRQ_WTSR_MASK,
143 },
144 [S2MPS14_IRQ_INT120C] = {
145 .reg_offset = 2,
146 .mask = S2MPS11_IRQ_INT120C_MASK,
147 },
148 [S2MPS14_IRQ_INT140C] = {
149 .reg_offset = 2,
150 .mask = S2MPS11_IRQ_INT140C_MASK,
151 },
152 [S2MPS14_IRQ_TSD] = {
153 .reg_offset = 2,
154 .mask = S2MPS14_IRQ_TSD_MASK,
155 },
156};
Sangbeom Kim6445b842012-07-11 21:08:11 +0900157
Chanwoo Choi54e88272014-06-25 16:14:44 +0900158static const struct regmap_irq s2mpu02_irqs[] = {
159 [S2MPU02_IRQ_PWRONF] = {
160 .reg_offset = 0,
161 .mask = S2MPS11_IRQ_PWRONF_MASK,
162 },
163 [S2MPU02_IRQ_PWRONR] = {
164 .reg_offset = 0,
165 .mask = S2MPS11_IRQ_PWRONR_MASK,
166 },
167 [S2MPU02_IRQ_JIGONBF] = {
168 .reg_offset = 0,
169 .mask = S2MPS11_IRQ_JIGONBF_MASK,
170 },
171 [S2MPU02_IRQ_JIGONBR] = {
172 .reg_offset = 0,
173 .mask = S2MPS11_IRQ_JIGONBR_MASK,
174 },
175 [S2MPU02_IRQ_ACOKBF] = {
176 .reg_offset = 0,
177 .mask = S2MPS11_IRQ_ACOKBF_MASK,
178 },
179 [S2MPU02_IRQ_ACOKBR] = {
180 .reg_offset = 0,
181 .mask = S2MPS11_IRQ_ACOKBR_MASK,
182 },
183 [S2MPU02_IRQ_PWRON1S] = {
184 .reg_offset = 0,
185 .mask = S2MPS11_IRQ_PWRON1S_MASK,
186 },
187 [S2MPU02_IRQ_MRB] = {
188 .reg_offset = 0,
189 .mask = S2MPS11_IRQ_MRB_MASK,
190 },
191 [S2MPU02_IRQ_RTC60S] = {
192 .reg_offset = 1,
193 .mask = S2MPS11_IRQ_RTC60S_MASK,
194 },
195 [S2MPU02_IRQ_RTCA1] = {
196 .reg_offset = 1,
197 .mask = S2MPS11_IRQ_RTCA1_MASK,
198 },
199 [S2MPU02_IRQ_RTCA0] = {
200 .reg_offset = 1,
201 .mask = S2MPS11_IRQ_RTCA0_MASK,
202 },
203 [S2MPU02_IRQ_SMPL] = {
204 .reg_offset = 1,
205 .mask = S2MPS11_IRQ_SMPL_MASK,
206 },
207 [S2MPU02_IRQ_RTC1S] = {
208 .reg_offset = 1,
209 .mask = S2MPS11_IRQ_RTC1S_MASK,
210 },
211 [S2MPU02_IRQ_WTSR] = {
212 .reg_offset = 1,
213 .mask = S2MPS11_IRQ_WTSR_MASK,
214 },
215 [S2MPU02_IRQ_INT120C] = {
216 .reg_offset = 2,
217 .mask = S2MPS11_IRQ_INT120C_MASK,
218 },
219 [S2MPU02_IRQ_INT140C] = {
220 .reg_offset = 2,
221 .mask = S2MPS11_IRQ_INT140C_MASK,
222 },
223 [S2MPU02_IRQ_TSD] = {
224 .reg_offset = 2,
225 .mask = S2MPS14_IRQ_TSD_MASK,
226 },
227};
228
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100229static const struct regmap_irq s5m8767_irqs[] = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900230 [S5M8767_IRQ_PWRR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530231 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900232 .mask = S5M8767_IRQ_PWRR_MASK,
233 },
234 [S5M8767_IRQ_PWRF] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530235 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900236 .mask = S5M8767_IRQ_PWRF_MASK,
237 },
238 [S5M8767_IRQ_PWR1S] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530239 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900240 .mask = S5M8767_IRQ_PWR1S_MASK,
241 },
242 [S5M8767_IRQ_JIGR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530243 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900244 .mask = S5M8767_IRQ_JIGR_MASK,
245 },
246 [S5M8767_IRQ_JIGF] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530247 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900248 .mask = S5M8767_IRQ_JIGF_MASK,
249 },
250 [S5M8767_IRQ_LOWBAT2] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530251 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900252 .mask = S5M8767_IRQ_LOWBAT2_MASK,
253 },
254 [S5M8767_IRQ_LOWBAT1] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530255 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900256 .mask = S5M8767_IRQ_LOWBAT1_MASK,
257 },
258 [S5M8767_IRQ_MRB] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530259 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900260 .mask = S5M8767_IRQ_MRB_MASK,
261 },
262 [S5M8767_IRQ_DVSOK2] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530263 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900264 .mask = S5M8767_IRQ_DVSOK2_MASK,
265 },
266 [S5M8767_IRQ_DVSOK3] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530267 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900268 .mask = S5M8767_IRQ_DVSOK3_MASK,
269 },
270 [S5M8767_IRQ_DVSOK4] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530271 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900272 .mask = S5M8767_IRQ_DVSOK4_MASK,
273 },
274 [S5M8767_IRQ_RTC60S] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530275 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900276 .mask = S5M8767_IRQ_RTC60S_MASK,
277 },
278 [S5M8767_IRQ_RTCA1] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530279 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900280 .mask = S5M8767_IRQ_RTCA1_MASK,
281 },
282 [S5M8767_IRQ_RTCA2] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530283 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900284 .mask = S5M8767_IRQ_RTCA2_MASK,
285 },
286 [S5M8767_IRQ_SMPL] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530287 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900288 .mask = S5M8767_IRQ_SMPL_MASK,
289 },
290 [S5M8767_IRQ_RTC1S] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530291 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900292 .mask = S5M8767_IRQ_RTC1S_MASK,
293 },
294 [S5M8767_IRQ_WTSR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530295 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900296 .mask = S5M8767_IRQ_WTSR_MASK,
297 },
298};
299
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100300static const struct regmap_irq s5m8763_irqs[] = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900301 [S5M8763_IRQ_DCINF] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530302 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900303 .mask = S5M8763_IRQ_DCINF_MASK,
304 },
305 [S5M8763_IRQ_DCINR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530306 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900307 .mask = S5M8763_IRQ_DCINR_MASK,
308 },
309 [S5M8763_IRQ_JIGF] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530310 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900311 .mask = S5M8763_IRQ_JIGF_MASK,
312 },
313 [S5M8763_IRQ_JIGR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530314 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900315 .mask = S5M8763_IRQ_JIGR_MASK,
316 },
317 [S5M8763_IRQ_PWRONF] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530318 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900319 .mask = S5M8763_IRQ_PWRONF_MASK,
320 },
321 [S5M8763_IRQ_PWRONR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530322 .reg_offset = 0,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900323 .mask = S5M8763_IRQ_PWRONR_MASK,
324 },
325 [S5M8763_IRQ_WTSREVNT] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530326 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900327 .mask = S5M8763_IRQ_WTSREVNT_MASK,
328 },
329 [S5M8763_IRQ_SMPLEVNT] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530330 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900331 .mask = S5M8763_IRQ_SMPLEVNT_MASK,
332 },
333 [S5M8763_IRQ_ALARM1] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530334 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900335 .mask = S5M8763_IRQ_ALARM1_MASK,
336 },
337 [S5M8763_IRQ_ALARM0] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530338 .reg_offset = 1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900339 .mask = S5M8763_IRQ_ALARM0_MASK,
340 },
341 [S5M8763_IRQ_ONKEY1S] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530342 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900343 .mask = S5M8763_IRQ_ONKEY1S_MASK,
344 },
345 [S5M8763_IRQ_TOPOFFR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530346 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900347 .mask = S5M8763_IRQ_TOPOFFR_MASK,
348 },
349 [S5M8763_IRQ_DCINOVPR] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530350 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900351 .mask = S5M8763_IRQ_DCINOVPR_MASK,
352 },
353 [S5M8763_IRQ_CHGRSTF] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530354 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900355 .mask = S5M8763_IRQ_CHGRSTF_MASK,
356 },
357 [S5M8763_IRQ_DONER] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530358 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900359 .mask = S5M8763_IRQ_DONER_MASK,
360 },
361 [S5M8763_IRQ_CHGFAULT] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530362 .reg_offset = 2,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900363 .mask = S5M8763_IRQ_CHGFAULT_MASK,
364 },
365 [S5M8763_IRQ_LOBAT1] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530366 .reg_offset = 3,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900367 .mask = S5M8763_IRQ_LOBAT1_MASK,
368 },
369 [S5M8763_IRQ_LOBAT2] = {
Inderpal Singh5e393a222012-10-17 11:48:55 +0530370 .reg_offset = 3,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900371 .mask = S5M8763_IRQ_LOBAT2_MASK,
372 },
373};
374
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100375static const struct regmap_irq_chip s2mps11_irq_chip = {
Sangbeom Kim6445b842012-07-11 21:08:11 +0900376 .name = "s2mps11",
377 .irqs = s2mps11_irqs,
378 .num_irqs = ARRAY_SIZE(s2mps11_irqs),
379 .num_regs = 3,
380 .status_base = S2MPS11_REG_INT1,
381 .mask_base = S2MPS11_REG_INT1M,
382 .ack_base = S2MPS11_REG_INT1,
383};
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900384
Chanwoo Choi3bc2ee92014-11-18 17:59:39 +0900385#define S2MPS1X_IRQ_CHIP_COMMON_DATA \
386 .irqs = s2mps14_irqs, \
387 .num_irqs = ARRAY_SIZE(s2mps14_irqs), \
388 .num_regs = 3, \
389 .status_base = S2MPS14_REG_INT1, \
390 .mask_base = S2MPS14_REG_INT1M, \
391 .ack_base = S2MPS14_REG_INT1 \
392
393static const struct regmap_irq_chip s2mps13_irq_chip = {
394 .name = "s2mps13",
395 S2MPS1X_IRQ_CHIP_COMMON_DATA,
396};
397
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +0100398static const struct regmap_irq_chip s2mps14_irq_chip = {
399 .name = "s2mps14",
Chanwoo Choi3bc2ee92014-11-18 17:59:39 +0900400 S2MPS1X_IRQ_CHIP_COMMON_DATA,
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +0100401};
402
Thomas Abraham9e4808d2015-11-20 16:07:51 +0530403static const struct regmap_irq_chip s2mps15_irq_chip = {
404 .name = "s2mps15",
405 S2MPS1X_IRQ_CHIP_COMMON_DATA,
406};
407
Chanwoo Choi54e88272014-06-25 16:14:44 +0900408static const struct regmap_irq_chip s2mpu02_irq_chip = {
409 .name = "s2mpu02",
410 .irqs = s2mpu02_irqs,
411 .num_irqs = ARRAY_SIZE(s2mpu02_irqs),
412 .num_regs = 3,
413 .status_base = S2MPU02_REG_INT1,
414 .mask_base = S2MPU02_REG_INT1M,
415 .ack_base = S2MPU02_REG_INT1,
416};
417
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100418static const struct regmap_irq_chip s5m8767_irq_chip = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900419 .name = "s5m8767",
Sangbeom Kim6445b842012-07-11 21:08:11 +0900420 .irqs = s5m8767_irqs,
421 .num_irqs = ARRAY_SIZE(s5m8767_irqs),
422 .num_regs = 3,
423 .status_base = S5M8767_REG_INT1,
424 .mask_base = S5M8767_REG_INT1M,
425 .ack_base = S5M8767_REG_INT1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900426};
427
Krzysztof Kozlowskia30fffb2013-11-28 09:09:43 +0100428static const struct regmap_irq_chip s5m8763_irq_chip = {
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900429 .name = "s5m8763",
Sangbeom Kim6445b842012-07-11 21:08:11 +0900430 .irqs = s5m8763_irqs,
431 .num_irqs = ARRAY_SIZE(s5m8763_irqs),
432 .num_regs = 4,
433 .status_base = S5M8763_REG_IRQ1,
434 .mask_base = S5M8763_REG_IRQM1,
435 .ack_base = S5M8763_REG_IRQ1,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900436};
437
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900438int sec_irq_init(struct sec_pmic_dev *sec_pmic)
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900439{
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900440 int ret = 0;
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900441 int type = sec_pmic->device_type;
Chanwoo Choi54e88272014-06-25 16:14:44 +0900442 const struct regmap_irq_chip *sec_irq_chip;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900443
Sangbeom Kim63063bf2012-07-11 21:06:55 +0900444 if (!sec_pmic->irq) {
445 dev_warn(sec_pmic->dev,
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900446 "No interrupt specified, no interrupts\n");
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900447 return 0;
448 }
449
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900450 switch (type) {
451 case S5M8763X:
Chanwoo Choi54e88272014-06-25 16:14:44 +0900452 sec_irq_chip = &s5m8763_irq_chip;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900453 break;
454 case S5M8767X:
Chanwoo Choi54e88272014-06-25 16:14:44 +0900455 sec_irq_chip = &s5m8767_irq_chip;
Sangbeom Kim6445b842012-07-11 21:08:11 +0900456 break;
Stuart Menefyec85d4a2019-02-13 22:24:02 +0000457 case S2MPA01:
458 sec_irq_chip = &s2mps14_irq_chip;
459 break;
Sangbeom Kim6445b842012-07-11 21:08:11 +0900460 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;
Thomas Abraham9e4808d2015-11-20 16:07:51 +0530469 case S2MPS15X:
470 sec_irq_chip = &s2mps15_irq_chip;
471 break;
Chanwoo Choi54e88272014-06-25 16:14:44 +0900472 case S2MPU02:
473 sec_irq_chip = &s2mpu02_irq_chip;
Krzysztof Kozlowskidc691962014-02-28 11:41:44 +0100474 break;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900475 default:
Krzysztof Kozlowski9549b5f2014-04-23 16:13:05 +0200476 dev_err(sec_pmic->dev, "Unknown device type %lu\n",
Sangbeom Kim6445b842012-07-11 21:08:11 +0900477 sec_pmic->device_type);
Jonghwan Choic7a1fcf2012-02-20 16:22:56 +0100478 return -EINVAL;
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900479 }
480
Laxman Dewangan3dc6f4a2016-04-21 17:55:56 +0530481 ret = devm_regmap_add_irq_chip(sec_pmic->dev, sec_pmic->regmap_pmic,
Krzysztof Kozlowski6854a102021-06-02 13:04:42 +0200482 sec_pmic->irq, IRQF_ONESHOT,
Krzysztof Kozlowskic1d3ab32021-05-26 08:47:09 -0400483 0, sec_irq_chip, &sec_pmic->irq_data);
Sangbeom Kim6445b842012-07-11 21:08:11 +0900484 if (ret != 0) {
485 dev_err(sec_pmic->dev, "Failed to register IRQ chip: %d\n", ret);
Jonghwan Choic7a1fcf2012-02-20 16:22:56 +0100486 return ret;
487 }
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900488
Krzysztof Kozlowskie554a992015-04-02 16:36:15 +0200489 /*
490 * The rtc-s5m driver requests S2MPS14_IRQ_RTCA0 also for S2MPS11
491 * so the interrupt number must be consistent.
492 */
493 BUILD_BUG_ON(((enum s2mps14_irq)S2MPS11_IRQ_RTCA0) != S2MPS14_IRQ_RTCA0);
494
Sangbeom Kim5ac2ffa72011-12-23 17:28:09 +0900495 return 0;
496}
Krzysztof Kozlowskieef05942018-08-07 18:11:25 +0200497EXPORT_SYMBOL_GPL(sec_irq_init);
498
499MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>");
500MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>");
501MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>");
502MODULE_DESCRIPTION("Interrupt support for the S5M MFD");
503MODULE_LICENSE("GPL");