4 * Copyright (c) 2011 Samsung Electronics Co., Ltd
5 * http://www.samsung.com
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.
14 #include <linux/device.h>
15 #include <linux/interrupt.h>
16 #include <linux/irq.h>
17 #include <linux/regmap.h>
19 #include <linux/mfd/samsung/core.h>
20 #include <linux/mfd/samsung/irq.h>
21 #include <linux/mfd/samsung/s2mps11.h>
22 #include <linux/mfd/samsung/s5m8763.h>
23 #include <linux/mfd/samsung/s5m8767.h>
25 static const struct regmap_irq s2mps11_irqs[] = {
26 [S2MPS11_IRQ_PWRONF] = {
28 .mask = S2MPS11_IRQ_PWRONF_MASK,
30 [S2MPS11_IRQ_PWRONR] = {
32 .mask = S2MPS11_IRQ_PWRONR_MASK,
34 [S2MPS11_IRQ_JIGONBF] = {
36 .mask = S2MPS11_IRQ_JIGONBF_MASK,
38 [S2MPS11_IRQ_JIGONBR] = {
40 .mask = S2MPS11_IRQ_JIGONBR_MASK,
42 [S2MPS11_IRQ_ACOKBF] = {
44 .mask = S2MPS11_IRQ_ACOKBF_MASK,
46 [S2MPS11_IRQ_ACOKBR] = {
48 .mask = S2MPS11_IRQ_ACOKBR_MASK,
50 [S2MPS11_IRQ_PWRON1S] = {
52 .mask = S2MPS11_IRQ_PWRON1S_MASK,
56 .mask = S2MPS11_IRQ_MRB_MASK,
58 [S2MPS11_IRQ_RTC60S] = {
60 .mask = S2MPS11_IRQ_RTC60S_MASK,
62 [S2MPS11_IRQ_RTCA1] = {
64 .mask = S2MPS11_IRQ_RTCA1_MASK,
66 [S2MPS11_IRQ_RTCA2] = {
68 .mask = S2MPS11_IRQ_RTCA2_MASK,
70 [S2MPS11_IRQ_SMPL] = {
72 .mask = S2MPS11_IRQ_SMPL_MASK,
74 [S2MPS11_IRQ_RTC1S] = {
76 .mask = S2MPS11_IRQ_RTC1S_MASK,
78 [S2MPS11_IRQ_WTSR] = {
80 .mask = S2MPS11_IRQ_WTSR_MASK,
82 [S2MPS11_IRQ_INT120C] = {
84 .mask = S2MPS11_IRQ_INT120C_MASK,
86 [S2MPS11_IRQ_INT140C] = {
88 .mask = S2MPS11_IRQ_INT140C_MASK,
93 static const struct regmap_irq s5m8767_irqs[] = {
94 [S5M8767_IRQ_PWRR] = {
96 .mask = S5M8767_IRQ_PWRR_MASK,
98 [S5M8767_IRQ_PWRF] = {
100 .mask = S5M8767_IRQ_PWRF_MASK,
102 [S5M8767_IRQ_PWR1S] = {
104 .mask = S5M8767_IRQ_PWR1S_MASK,
106 [S5M8767_IRQ_JIGR] = {
108 .mask = S5M8767_IRQ_JIGR_MASK,
110 [S5M8767_IRQ_JIGF] = {
112 .mask = S5M8767_IRQ_JIGF_MASK,
114 [S5M8767_IRQ_LOWBAT2] = {
116 .mask = S5M8767_IRQ_LOWBAT2_MASK,
118 [S5M8767_IRQ_LOWBAT1] = {
120 .mask = S5M8767_IRQ_LOWBAT1_MASK,
122 [S5M8767_IRQ_MRB] = {
124 .mask = S5M8767_IRQ_MRB_MASK,
126 [S5M8767_IRQ_DVSOK2] = {
128 .mask = S5M8767_IRQ_DVSOK2_MASK,
130 [S5M8767_IRQ_DVSOK3] = {
132 .mask = S5M8767_IRQ_DVSOK3_MASK,
134 [S5M8767_IRQ_DVSOK4] = {
136 .mask = S5M8767_IRQ_DVSOK4_MASK,
138 [S5M8767_IRQ_RTC60S] = {
140 .mask = S5M8767_IRQ_RTC60S_MASK,
142 [S5M8767_IRQ_RTCA1] = {
144 .mask = S5M8767_IRQ_RTCA1_MASK,
146 [S5M8767_IRQ_RTCA2] = {
148 .mask = S5M8767_IRQ_RTCA2_MASK,
150 [S5M8767_IRQ_SMPL] = {
152 .mask = S5M8767_IRQ_SMPL_MASK,
154 [S5M8767_IRQ_RTC1S] = {
156 .mask = S5M8767_IRQ_RTC1S_MASK,
158 [S5M8767_IRQ_WTSR] = {
160 .mask = S5M8767_IRQ_WTSR_MASK,
164 static const struct regmap_irq s5m8763_irqs[] = {
165 [S5M8763_IRQ_DCINF] = {
167 .mask = S5M8763_IRQ_DCINF_MASK,
169 [S5M8763_IRQ_DCINR] = {
171 .mask = S5M8763_IRQ_DCINR_MASK,
173 [S5M8763_IRQ_JIGF] = {
175 .mask = S5M8763_IRQ_JIGF_MASK,
177 [S5M8763_IRQ_JIGR] = {
179 .mask = S5M8763_IRQ_JIGR_MASK,
181 [S5M8763_IRQ_PWRONF] = {
183 .mask = S5M8763_IRQ_PWRONF_MASK,
185 [S5M8763_IRQ_PWRONR] = {
187 .mask = S5M8763_IRQ_PWRONR_MASK,
189 [S5M8763_IRQ_WTSREVNT] = {
191 .mask = S5M8763_IRQ_WTSREVNT_MASK,
193 [S5M8763_IRQ_SMPLEVNT] = {
195 .mask = S5M8763_IRQ_SMPLEVNT_MASK,
197 [S5M8763_IRQ_ALARM1] = {
199 .mask = S5M8763_IRQ_ALARM1_MASK,
201 [S5M8763_IRQ_ALARM0] = {
203 .mask = S5M8763_IRQ_ALARM0_MASK,
205 [S5M8763_IRQ_ONKEY1S] = {
207 .mask = S5M8763_IRQ_ONKEY1S_MASK,
209 [S5M8763_IRQ_TOPOFFR] = {
211 .mask = S5M8763_IRQ_TOPOFFR_MASK,
213 [S5M8763_IRQ_DCINOVPR] = {
215 .mask = S5M8763_IRQ_DCINOVPR_MASK,
217 [S5M8763_IRQ_CHGRSTF] = {
219 .mask = S5M8763_IRQ_CHGRSTF_MASK,
221 [S5M8763_IRQ_DONER] = {
223 .mask = S5M8763_IRQ_DONER_MASK,
225 [S5M8763_IRQ_CHGFAULT] = {
227 .mask = S5M8763_IRQ_CHGFAULT_MASK,
229 [S5M8763_IRQ_LOBAT1] = {
231 .mask = S5M8763_IRQ_LOBAT1_MASK,
233 [S5M8763_IRQ_LOBAT2] = {
235 .mask = S5M8763_IRQ_LOBAT2_MASK,
239 static const struct regmap_irq_chip s2mps11_irq_chip = {
241 .irqs = s2mps11_irqs,
242 .num_irqs = ARRAY_SIZE(s2mps11_irqs),
244 .status_base = S2MPS11_REG_INT1,
245 .mask_base = S2MPS11_REG_INT1M,
246 .ack_base = S2MPS11_REG_INT1,
249 static const struct regmap_irq_chip s5m8767_irq_chip = {
251 .irqs = s5m8767_irqs,
252 .num_irqs = ARRAY_SIZE(s5m8767_irqs),
254 .status_base = S5M8767_REG_INT1,
255 .mask_base = S5M8767_REG_INT1M,
256 .ack_base = S5M8767_REG_INT1,
259 static const struct regmap_irq_chip s5m8763_irq_chip = {
261 .irqs = s5m8763_irqs,
262 .num_irqs = ARRAY_SIZE(s5m8763_irqs),
264 .status_base = S5M8763_REG_IRQ1,
265 .mask_base = S5M8763_REG_IRQM1,
266 .ack_base = S5M8763_REG_IRQ1,
269 int sec_irq_init(struct sec_pmic_dev *sec_pmic)
272 int type = sec_pmic->device_type;
274 if (!sec_pmic->irq) {
275 dev_warn(sec_pmic->dev,
276 "No interrupt specified, no interrupts\n");
277 sec_pmic->irq_base = 0;
283 ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq,
284 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
285 sec_pmic->irq_base, &s5m8763_irq_chip,
286 &sec_pmic->irq_data);
289 ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq,
290 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
291 sec_pmic->irq_base, &s5m8767_irq_chip,
292 &sec_pmic->irq_data);
295 ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq,
296 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
297 sec_pmic->irq_base, &s2mps11_irq_chip,
298 &sec_pmic->irq_data);
301 dev_err(sec_pmic->dev, "Unknown device type %d\n",
302 sec_pmic->device_type);
307 dev_err(sec_pmic->dev, "Failed to register IRQ chip: %d\n", ret);
314 void sec_irq_exit(struct sec_pmic_dev *sec_pmic)
316 regmap_del_irq_chip(sec_pmic->irq, sec_pmic->irq_data);