]>
Commit | Line | Data |
---|---|---|
62579266 RV |
1 | /* |
2 | * Copyright (C) ST-Ericsson SA 2010 | |
3 | * | |
4 | * License Terms: GNU General Public License v2 | |
5 | * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> | |
6 | * Author: Rabin Vincent <rabin.vincent@stericsson.com> | |
adceed62 | 7 | * Author: Mattias Wallin <mattias.wallin@stericsson.com> |
62579266 RV |
8 | */ |
9 | ||
10 | #include <linux/kernel.h> | |
11 | #include <linux/slab.h> | |
12 | #include <linux/init.h> | |
13 | #include <linux/irq.h> | |
06e589ef | 14 | #include <linux/irqdomain.h> |
62579266 RV |
15 | #include <linux/delay.h> |
16 | #include <linux/interrupt.h> | |
17 | #include <linux/module.h> | |
18 | #include <linux/platform_device.h> | |
19 | #include <linux/mfd/core.h> | |
47c16975 | 20 | #include <linux/mfd/abx500.h> |
ee66e653 | 21 | #include <linux/mfd/abx500/ab8500.h> |
d28f1db8 | 22 | #include <linux/mfd/dbx500-prcmu.h> |
549931f9 | 23 | #include <linux/regulator/ab8500.h> |
6bc4a568 LJ |
24 | #include <linux/of.h> |
25 | #include <linux/of_device.h> | |
62579266 RV |
26 | |
27 | /* | |
28 | * Interrupt register offsets | |
29 | * Bank : 0x0E | |
30 | */ | |
47c16975 MW |
31 | #define AB8500_IT_SOURCE1_REG 0x00 |
32 | #define AB8500_IT_SOURCE2_REG 0x01 | |
33 | #define AB8500_IT_SOURCE3_REG 0x02 | |
34 | #define AB8500_IT_SOURCE4_REG 0x03 | |
35 | #define AB8500_IT_SOURCE5_REG 0x04 | |
36 | #define AB8500_IT_SOURCE6_REG 0x05 | |
37 | #define AB8500_IT_SOURCE7_REG 0x06 | |
38 | #define AB8500_IT_SOURCE8_REG 0x07 | |
d6255529 | 39 | #define AB9540_IT_SOURCE13_REG 0x0C |
47c16975 MW |
40 | #define AB8500_IT_SOURCE19_REG 0x12 |
41 | #define AB8500_IT_SOURCE20_REG 0x13 | |
42 | #define AB8500_IT_SOURCE21_REG 0x14 | |
43 | #define AB8500_IT_SOURCE22_REG 0x15 | |
44 | #define AB8500_IT_SOURCE23_REG 0x16 | |
45 | #define AB8500_IT_SOURCE24_REG 0x17 | |
62579266 RV |
46 | |
47 | /* | |
48 | * latch registers | |
49 | */ | |
47c16975 MW |
50 | #define AB8500_IT_LATCH1_REG 0x20 |
51 | #define AB8500_IT_LATCH2_REG 0x21 | |
52 | #define AB8500_IT_LATCH3_REG 0x22 | |
53 | #define AB8500_IT_LATCH4_REG 0x23 | |
54 | #define AB8500_IT_LATCH5_REG 0x24 | |
55 | #define AB8500_IT_LATCH6_REG 0x25 | |
56 | #define AB8500_IT_LATCH7_REG 0x26 | |
57 | #define AB8500_IT_LATCH8_REG 0x27 | |
58 | #define AB8500_IT_LATCH9_REG 0x28 | |
59 | #define AB8500_IT_LATCH10_REG 0x29 | |
92d50a41 | 60 | #define AB8500_IT_LATCH12_REG 0x2B |
d6255529 | 61 | #define AB9540_IT_LATCH13_REG 0x2C |
47c16975 MW |
62 | #define AB8500_IT_LATCH19_REG 0x32 |
63 | #define AB8500_IT_LATCH20_REG 0x33 | |
64 | #define AB8500_IT_LATCH21_REG 0x34 | |
65 | #define AB8500_IT_LATCH22_REG 0x35 | |
66 | #define AB8500_IT_LATCH23_REG 0x36 | |
67 | #define AB8500_IT_LATCH24_REG 0x37 | |
62579266 RV |
68 | |
69 | /* | |
70 | * mask registers | |
71 | */ | |
72 | ||
47c16975 MW |
73 | #define AB8500_IT_MASK1_REG 0x40 |
74 | #define AB8500_IT_MASK2_REG 0x41 | |
75 | #define AB8500_IT_MASK3_REG 0x42 | |
76 | #define AB8500_IT_MASK4_REG 0x43 | |
77 | #define AB8500_IT_MASK5_REG 0x44 | |
78 | #define AB8500_IT_MASK6_REG 0x45 | |
79 | #define AB8500_IT_MASK7_REG 0x46 | |
80 | #define AB8500_IT_MASK8_REG 0x47 | |
81 | #define AB8500_IT_MASK9_REG 0x48 | |
82 | #define AB8500_IT_MASK10_REG 0x49 | |
83 | #define AB8500_IT_MASK11_REG 0x4A | |
84 | #define AB8500_IT_MASK12_REG 0x4B | |
85 | #define AB8500_IT_MASK13_REG 0x4C | |
86 | #define AB8500_IT_MASK14_REG 0x4D | |
87 | #define AB8500_IT_MASK15_REG 0x4E | |
88 | #define AB8500_IT_MASK16_REG 0x4F | |
89 | #define AB8500_IT_MASK17_REG 0x50 | |
90 | #define AB8500_IT_MASK18_REG 0x51 | |
91 | #define AB8500_IT_MASK19_REG 0x52 | |
92 | #define AB8500_IT_MASK20_REG 0x53 | |
93 | #define AB8500_IT_MASK21_REG 0x54 | |
94 | #define AB8500_IT_MASK22_REG 0x55 | |
95 | #define AB8500_IT_MASK23_REG 0x56 | |
96 | #define AB8500_IT_MASK24_REG 0x57 | |
97 | ||
7ccfe9b1 MJ |
98 | /* |
99 | * latch hierarchy registers | |
100 | */ | |
101 | #define AB8500_IT_LATCHHIER1_REG 0x60 | |
102 | #define AB8500_IT_LATCHHIER2_REG 0x61 | |
103 | #define AB8500_IT_LATCHHIER3_REG 0x62 | |
104 | ||
105 | #define AB8500_IT_LATCHHIER_NUM 3 | |
106 | ||
47c16975 | 107 | #define AB8500_REV_REG 0x80 |
0f620837 | 108 | #define AB8500_IC_NAME_REG 0x82 |
e5c238c3 | 109 | #define AB8500_SWITCH_OFF_STATUS 0x00 |
62579266 | 110 | |
b4a31037 AL |
111 | #define AB8500_TURN_ON_STATUS 0x00 |
112 | ||
6ef9418c RA |
113 | static bool no_bm; /* No battery management */ |
114 | module_param(no_bm, bool, S_IRUGO); | |
115 | ||
d6255529 LW |
116 | #define AB9540_MODEM_CTRL2_REG 0x23 |
117 | #define AB9540_MODEM_CTRL2_SWDBBRSTN_BIT BIT(2) | |
118 | ||
62579266 RV |
119 | /* |
120 | * Map interrupt numbers to the LATCH and MASK register offsets, Interrupt | |
2ced445e LW |
121 | * numbers are indexed into this array with (num / 8). The interupts are |
122 | * defined in linux/mfd/ab8500.h | |
62579266 RV |
123 | * |
124 | * This is one off from the register names, i.e. AB8500_IT_MASK1_REG is at | |
125 | * offset 0. | |
126 | */ | |
2ced445e | 127 | /* AB8500 support */ |
62579266 | 128 | static const int ab8500_irq_regoffset[AB8500_NUM_IRQ_REGS] = { |
92d50a41 | 129 | 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 18, 19, 20, 21, |
62579266 RV |
130 | }; |
131 | ||
d6255529 LW |
132 | /* AB9540 support */ |
133 | static const int ab9540_irq_regoffset[AB9540_NUM_IRQ_REGS] = { | |
134 | 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 18, 19, 20, 21, 12, 13, 24, | |
135 | }; | |
136 | ||
0f620837 LW |
137 | static const char ab8500_version_str[][7] = { |
138 | [AB8500_VERSION_AB8500] = "AB8500", | |
139 | [AB8500_VERSION_AB8505] = "AB8505", | |
140 | [AB8500_VERSION_AB9540] = "AB9540", | |
141 | [AB8500_VERSION_AB8540] = "AB8540", | |
142 | }; | |
143 | ||
822672a7 | 144 | static int ab8500_prcmu_write(struct ab8500 *ab8500, u16 addr, u8 data) |
d28f1db8 LJ |
145 | { |
146 | int ret; | |
147 | ||
148 | ret = prcmu_abb_write((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 1); | |
149 | if (ret < 0) | |
150 | dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); | |
151 | return ret; | |
152 | } | |
153 | ||
822672a7 | 154 | static int ab8500_prcmu_write_masked(struct ab8500 *ab8500, u16 addr, u8 mask, |
d28f1db8 LJ |
155 | u8 data) |
156 | { | |
157 | int ret; | |
158 | ||
159 | ret = prcmu_abb_write_masked((u8)(addr >> 8), (u8)(addr & 0xFF), &data, | |
160 | &mask, 1); | |
161 | if (ret < 0) | |
162 | dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); | |
163 | return ret; | |
164 | } | |
165 | ||
822672a7 | 166 | static int ab8500_prcmu_read(struct ab8500 *ab8500, u16 addr) |
d28f1db8 LJ |
167 | { |
168 | int ret; | |
169 | u8 data; | |
170 | ||
171 | ret = prcmu_abb_read((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 1); | |
172 | if (ret < 0) { | |
173 | dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); | |
174 | return ret; | |
175 | } | |
176 | return (int)data; | |
177 | } | |
178 | ||
47c16975 MW |
179 | static int ab8500_get_chip_id(struct device *dev) |
180 | { | |
6bce7bf1 MW |
181 | struct ab8500 *ab8500; |
182 | ||
183 | if (!dev) | |
184 | return -EINVAL; | |
185 | ab8500 = dev_get_drvdata(dev->parent); | |
186 | return ab8500 ? (int)ab8500->chip_id : -EINVAL; | |
47c16975 MW |
187 | } |
188 | ||
189 | static int set_register_interruptible(struct ab8500 *ab8500, u8 bank, | |
190 | u8 reg, u8 data) | |
62579266 RV |
191 | { |
192 | int ret; | |
47c16975 MW |
193 | /* |
194 | * Put the u8 bank and u8 register together into a an u16. | |
195 | * The bank on higher 8 bits and register in lower 8 bits. | |
196 | * */ | |
197 | u16 addr = ((u16)bank) << 8 | reg; | |
62579266 RV |
198 | |
199 | dev_vdbg(ab8500->dev, "wr: addr %#x <= %#x\n", addr, data); | |
200 | ||
392cbd1e | 201 | mutex_lock(&ab8500->lock); |
47c16975 | 202 | |
62579266 RV |
203 | ret = ab8500->write(ab8500, addr, data); |
204 | if (ret < 0) | |
205 | dev_err(ab8500->dev, "failed to write reg %#x: %d\n", | |
206 | addr, ret); | |
47c16975 | 207 | mutex_unlock(&ab8500->lock); |
62579266 RV |
208 | |
209 | return ret; | |
210 | } | |
211 | ||
47c16975 MW |
212 | static int ab8500_set_register(struct device *dev, u8 bank, |
213 | u8 reg, u8 value) | |
62579266 | 214 | { |
112a80d2 | 215 | int ret; |
47c16975 | 216 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); |
62579266 | 217 | |
112a80d2 JA |
218 | atomic_inc(&ab8500->transfer_ongoing); |
219 | ret = set_register_interruptible(ab8500, bank, reg, value); | |
220 | atomic_dec(&ab8500->transfer_ongoing); | |
221 | return ret; | |
62579266 | 222 | } |
62579266 | 223 | |
47c16975 MW |
224 | static int get_register_interruptible(struct ab8500 *ab8500, u8 bank, |
225 | u8 reg, u8 *value) | |
62579266 RV |
226 | { |
227 | int ret; | |
47c16975 MW |
228 | /* put the u8 bank and u8 reg together into a an u16. |
229 | * bank on higher 8 bits and reg in lower */ | |
230 | u16 addr = ((u16)bank) << 8 | reg; | |
231 | ||
392cbd1e | 232 | mutex_lock(&ab8500->lock); |
62579266 RV |
233 | |
234 | ret = ab8500->read(ab8500, addr); | |
235 | if (ret < 0) | |
236 | dev_err(ab8500->dev, "failed to read reg %#x: %d\n", | |
237 | addr, ret); | |
47c16975 MW |
238 | else |
239 | *value = ret; | |
62579266 | 240 | |
47c16975 | 241 | mutex_unlock(&ab8500->lock); |
62579266 RV |
242 | dev_vdbg(ab8500->dev, "rd: addr %#x => data %#x\n", addr, ret); |
243 | ||
244 | return ret; | |
245 | } | |
246 | ||
47c16975 MW |
247 | static int ab8500_get_register(struct device *dev, u8 bank, |
248 | u8 reg, u8 *value) | |
62579266 | 249 | { |
112a80d2 | 250 | int ret; |
47c16975 | 251 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); |
62579266 | 252 | |
112a80d2 JA |
253 | atomic_inc(&ab8500->transfer_ongoing); |
254 | ret = get_register_interruptible(ab8500, bank, reg, value); | |
255 | atomic_dec(&ab8500->transfer_ongoing); | |
256 | return ret; | |
62579266 | 257 | } |
47c16975 MW |
258 | |
259 | static int mask_and_set_register_interruptible(struct ab8500 *ab8500, u8 bank, | |
260 | u8 reg, u8 bitmask, u8 bitvalues) | |
62579266 RV |
261 | { |
262 | int ret; | |
47c16975 MW |
263 | /* put the u8 bank and u8 reg together into a an u16. |
264 | * bank on higher 8 bits and reg in lower */ | |
265 | u16 addr = ((u16)bank) << 8 | reg; | |
62579266 | 266 | |
392cbd1e | 267 | mutex_lock(&ab8500->lock); |
62579266 | 268 | |
bc628fd1 MN |
269 | if (ab8500->write_masked == NULL) { |
270 | u8 data; | |
62579266 | 271 | |
bc628fd1 MN |
272 | ret = ab8500->read(ab8500, addr); |
273 | if (ret < 0) { | |
274 | dev_err(ab8500->dev, "failed to read reg %#x: %d\n", | |
275 | addr, ret); | |
276 | goto out; | |
277 | } | |
62579266 | 278 | |
bc628fd1 MN |
279 | data = (u8)ret; |
280 | data = (~bitmask & data) | (bitmask & bitvalues); | |
281 | ||
282 | ret = ab8500->write(ab8500, addr, data); | |
283 | if (ret < 0) | |
284 | dev_err(ab8500->dev, "failed to write reg %#x: %d\n", | |
285 | addr, ret); | |
62579266 | 286 | |
bc628fd1 MN |
287 | dev_vdbg(ab8500->dev, "mask: addr %#x => data %#x\n", addr, |
288 | data); | |
289 | goto out; | |
290 | } | |
291 | ret = ab8500->write_masked(ab8500, addr, bitmask, bitvalues); | |
292 | if (ret < 0) | |
293 | dev_err(ab8500->dev, "failed to modify reg %#x: %d\n", addr, | |
294 | ret); | |
62579266 RV |
295 | out: |
296 | mutex_unlock(&ab8500->lock); | |
297 | return ret; | |
298 | } | |
47c16975 MW |
299 | |
300 | static int ab8500_mask_and_set_register(struct device *dev, | |
301 | u8 bank, u8 reg, u8 bitmask, u8 bitvalues) | |
302 | { | |
112a80d2 | 303 | int ret; |
47c16975 MW |
304 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); |
305 | ||
112a80d2 JA |
306 | atomic_inc(&ab8500->transfer_ongoing); |
307 | ret= mask_and_set_register_interruptible(ab8500, bank, reg, | |
308 | bitmask, bitvalues); | |
309 | atomic_dec(&ab8500->transfer_ongoing); | |
310 | return ret; | |
47c16975 MW |
311 | } |
312 | ||
313 | static struct abx500_ops ab8500_ops = { | |
314 | .get_chip_id = ab8500_get_chip_id, | |
315 | .get_register = ab8500_get_register, | |
316 | .set_register = ab8500_set_register, | |
317 | .get_register_page = NULL, | |
318 | .set_register_page = NULL, | |
319 | .mask_and_set_register = ab8500_mask_and_set_register, | |
320 | .event_registers_startup_state_get = NULL, | |
321 | .startup_irq_enabled = NULL, | |
322 | }; | |
62579266 | 323 | |
9505a0a0 | 324 | static void ab8500_irq_lock(struct irq_data *data) |
62579266 | 325 | { |
9505a0a0 | 326 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
62579266 RV |
327 | |
328 | mutex_lock(&ab8500->irq_lock); | |
112a80d2 | 329 | atomic_inc(&ab8500->transfer_ongoing); |
62579266 RV |
330 | } |
331 | ||
9505a0a0 | 332 | static void ab8500_irq_sync_unlock(struct irq_data *data) |
62579266 | 333 | { |
9505a0a0 | 334 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
62579266 RV |
335 | int i; |
336 | ||
2ced445e | 337 | for (i = 0; i < ab8500->mask_size; i++) { |
62579266 RV |
338 | u8 old = ab8500->oldmask[i]; |
339 | u8 new = ab8500->mask[i]; | |
340 | int reg; | |
341 | ||
342 | if (new == old) | |
343 | continue; | |
344 | ||
0f620837 LW |
345 | /* |
346 | * Interrupt register 12 doesn't exist prior to AB8500 version | |
347 | * 2.0 | |
348 | */ | |
349 | if (ab8500->irq_reg_offset[i] == 11 && | |
350 | is_ab8500_1p1_or_earlier(ab8500)) | |
92d50a41 MW |
351 | continue; |
352 | ||
62579266 RV |
353 | ab8500->oldmask[i] = new; |
354 | ||
2ced445e | 355 | reg = AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i]; |
47c16975 | 356 | set_register_interruptible(ab8500, AB8500_INTERRUPT, reg, new); |
62579266 | 357 | } |
112a80d2 | 358 | atomic_dec(&ab8500->transfer_ongoing); |
62579266 RV |
359 | mutex_unlock(&ab8500->irq_lock); |
360 | } | |
361 | ||
9505a0a0 | 362 | static void ab8500_irq_mask(struct irq_data *data) |
62579266 | 363 | { |
9505a0a0 | 364 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
06e589ef | 365 | int offset = data->hwirq; |
62579266 RV |
366 | int index = offset / 8; |
367 | int mask = 1 << (offset % 8); | |
368 | ||
369 | ab8500->mask[index] |= mask; | |
370 | } | |
371 | ||
9505a0a0 | 372 | static void ab8500_irq_unmask(struct irq_data *data) |
62579266 | 373 | { |
9505a0a0 | 374 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
06e589ef | 375 | int offset = data->hwirq; |
62579266 RV |
376 | int index = offset / 8; |
377 | int mask = 1 << (offset % 8); | |
378 | ||
379 | ab8500->mask[index] &= ~mask; | |
380 | } | |
381 | ||
382 | static struct irq_chip ab8500_irq_chip = { | |
383 | .name = "ab8500", | |
9505a0a0 MB |
384 | .irq_bus_lock = ab8500_irq_lock, |
385 | .irq_bus_sync_unlock = ab8500_irq_sync_unlock, | |
386 | .irq_mask = ab8500_irq_mask, | |
e6f9306e | 387 | .irq_disable = ab8500_irq_mask, |
9505a0a0 | 388 | .irq_unmask = ab8500_irq_unmask, |
62579266 RV |
389 | }; |
390 | ||
7ccfe9b1 MJ |
391 | static int ab8500_handle_hierarchical_line(struct ab8500 *ab8500, |
392 | int latch_offset, u8 latch_val) | |
393 | { | |
394 | int int_bit = __ffs(latch_val); | |
395 | int line, i; | |
396 | ||
397 | do { | |
398 | int_bit = __ffs(latch_val); | |
399 | ||
400 | for (i = 0; i < ab8500->mask_size; i++) | |
401 | if (ab8500->irq_reg_offset[i] == latch_offset) | |
402 | break; | |
403 | ||
404 | if (i >= ab8500->mask_size) { | |
405 | dev_err(ab8500->dev, "Register offset 0x%2x not declared\n", | |
406 | latch_offset); | |
407 | return -ENXIO; | |
408 | } | |
409 | ||
410 | line = (i << 3) + int_bit; | |
411 | latch_val &= ~(1 << int_bit); | |
412 | ||
413 | handle_nested_irq(ab8500->irq_base + line); | |
414 | } while (latch_val); | |
415 | ||
416 | return 0; | |
417 | } | |
418 | ||
419 | static int ab8500_handle_hierarchical_latch(struct ab8500 *ab8500, | |
420 | int hier_offset, u8 hier_val) | |
421 | { | |
422 | int latch_bit, status; | |
423 | u8 latch_offset, latch_val; | |
424 | ||
425 | do { | |
426 | latch_bit = __ffs(hier_val); | |
427 | latch_offset = (hier_offset << 3) + latch_bit; | |
428 | ||
429 | /* Fix inconsistent ITFromLatch25 bit mapping... */ | |
430 | if (unlikely(latch_offset == 17)) | |
431 | latch_offset = 24; | |
432 | ||
433 | status = get_register_interruptible(ab8500, | |
434 | AB8500_INTERRUPT, | |
435 | AB8500_IT_LATCH1_REG + latch_offset, | |
436 | &latch_val); | |
437 | if (status < 0 || latch_val == 0) | |
438 | goto discard; | |
439 | ||
440 | status = ab8500_handle_hierarchical_line(ab8500, | |
441 | latch_offset, latch_val); | |
442 | if (status < 0) | |
443 | return status; | |
444 | discard: | |
445 | hier_val &= ~(1 << latch_bit); | |
446 | } while (hier_val); | |
447 | ||
448 | return 0; | |
449 | } | |
450 | ||
451 | static irqreturn_t ab8500_hierarchical_irq(int irq, void *dev) | |
452 | { | |
453 | struct ab8500 *ab8500 = dev; | |
454 | u8 i; | |
455 | ||
456 | dev_vdbg(ab8500->dev, "interrupt\n"); | |
457 | ||
458 | /* Hierarchical interrupt version */ | |
459 | for (i = 0; i < AB8500_IT_LATCHHIER_NUM; i++) { | |
460 | int status; | |
461 | u8 hier_val; | |
462 | ||
463 | status = get_register_interruptible(ab8500, AB8500_INTERRUPT, | |
464 | AB8500_IT_LATCHHIER1_REG + i, &hier_val); | |
465 | if (status < 0 || hier_val == 0) | |
466 | continue; | |
467 | ||
468 | status = ab8500_handle_hierarchical_latch(ab8500, i, hier_val); | |
469 | if (status < 0) | |
470 | break; | |
471 | } | |
472 | return IRQ_HANDLED; | |
473 | } | |
474 | ||
80633f05 LJ |
475 | /** |
476 | * ab8500_irq_get_virq(): Map an interrupt on a chip to a virtual IRQ | |
477 | * | |
478 | * @ab8500: ab8500_irq controller to operate on. | |
479 | * @irq: index of the interrupt requested in the chip IRQs | |
480 | * | |
481 | * Useful for drivers to request their own IRQs. | |
482 | */ | |
483 | static int ab8500_irq_get_virq(struct ab8500 *ab8500, int irq) | |
484 | { | |
485 | if (!ab8500) | |
486 | return -EINVAL; | |
487 | ||
488 | return irq_create_mapping(ab8500->domain, irq); | |
489 | } | |
490 | ||
62579266 RV |
491 | static irqreturn_t ab8500_irq(int irq, void *dev) |
492 | { | |
493 | struct ab8500 *ab8500 = dev; | |
494 | int i; | |
495 | ||
496 | dev_vdbg(ab8500->dev, "interrupt\n"); | |
497 | ||
112a80d2 JA |
498 | atomic_inc(&ab8500->transfer_ongoing); |
499 | ||
2ced445e LW |
500 | for (i = 0; i < ab8500->mask_size; i++) { |
501 | int regoffset = ab8500->irq_reg_offset[i]; | |
62579266 | 502 | int status; |
47c16975 | 503 | u8 value; |
62579266 | 504 | |
0f620837 LW |
505 | /* |
506 | * Interrupt register 12 doesn't exist prior to AB8500 version | |
507 | * 2.0 | |
508 | */ | |
509 | if (regoffset == 11 && is_ab8500_1p1_or_earlier(ab8500)) | |
92d50a41 MW |
510 | continue; |
511 | ||
47c16975 MW |
512 | status = get_register_interruptible(ab8500, AB8500_INTERRUPT, |
513 | AB8500_IT_LATCH1_REG + regoffset, &value); | |
514 | if (status < 0 || value == 0) | |
62579266 RV |
515 | continue; |
516 | ||
517 | do { | |
88aec4f7 | 518 | int bit = __ffs(value); |
62579266 | 519 | int line = i * 8 + bit; |
0a37fc56 | 520 | int virq = ab8500_irq_get_virq(ab8500, line); |
62579266 | 521 | |
0a37fc56 | 522 | handle_nested_irq(virq); |
47c16975 | 523 | value &= ~(1 << bit); |
112a80d2 | 524 | |
47c16975 | 525 | } while (value); |
62579266 | 526 | } |
112a80d2 | 527 | atomic_dec(&ab8500->transfer_ongoing); |
62579266 RV |
528 | return IRQ_HANDLED; |
529 | } | |
530 | ||
06e589ef LJ |
531 | static int ab8500_irq_map(struct irq_domain *d, unsigned int virq, |
532 | irq_hw_number_t hwirq) | |
533 | { | |
534 | struct ab8500 *ab8500 = d->host_data; | |
535 | ||
536 | if (!ab8500) | |
537 | return -EINVAL; | |
538 | ||
539 | irq_set_chip_data(virq, ab8500); | |
540 | irq_set_chip_and_handler(virq, &ab8500_irq_chip, | |
541 | handle_simple_irq); | |
542 | irq_set_nested_thread(virq, 1); | |
62579266 | 543 | #ifdef CONFIG_ARM |
06e589ef | 544 | set_irq_flags(virq, IRQF_VALID); |
62579266 | 545 | #else |
06e589ef | 546 | irq_set_noprobe(virq); |
62579266 | 547 | #endif |
62579266 RV |
548 | |
549 | return 0; | |
550 | } | |
551 | ||
06e589ef LJ |
552 | static struct irq_domain_ops ab8500_irq_ops = { |
553 | .map = ab8500_irq_map, | |
554 | .xlate = irq_domain_xlate_twocell, | |
555 | }; | |
556 | ||
557 | static int ab8500_irq_init(struct ab8500 *ab8500, struct device_node *np) | |
62579266 | 558 | { |
2ced445e LW |
559 | int num_irqs; |
560 | ||
d6255529 LW |
561 | if (is_ab9540(ab8500)) |
562 | num_irqs = AB9540_NR_IRQS; | |
a982362c BJ |
563 | else if (is_ab8505(ab8500)) |
564 | num_irqs = AB8505_NR_IRQS; | |
d6255529 LW |
565 | else |
566 | num_irqs = AB8500_NR_IRQS; | |
62579266 | 567 | |
f1d11f39 LW |
568 | /* If ->irq_base is zero this will give a linear mapping */ |
569 | ab8500->domain = irq_domain_add_simple(NULL, | |
570 | num_irqs, ab8500->irq_base, | |
571 | &ab8500_irq_ops, ab8500); | |
06e589ef LJ |
572 | |
573 | if (!ab8500->domain) { | |
574 | dev_err(ab8500->dev, "Failed to create irqdomain\n"); | |
575 | return -ENOSYS; | |
576 | } | |
577 | ||
578 | return 0; | |
62579266 RV |
579 | } |
580 | ||
112a80d2 JA |
581 | int ab8500_suspend(struct ab8500 *ab8500) |
582 | { | |
583 | if (atomic_read(&ab8500->transfer_ongoing)) | |
584 | return -EINVAL; | |
585 | else | |
586 | return 0; | |
587 | } | |
588 | ||
a9e9ce4c | 589 | static struct resource ab8500_gpadc_resources[] = { |
62579266 RV |
590 | { |
591 | .name = "HW_CONV_END", | |
592 | .start = AB8500_INT_GP_HW_ADC_CONV_END, | |
593 | .end = AB8500_INT_GP_HW_ADC_CONV_END, | |
594 | .flags = IORESOURCE_IRQ, | |
595 | }, | |
596 | { | |
597 | .name = "SW_CONV_END", | |
598 | .start = AB8500_INT_GP_SW_ADC_CONV_END, | |
599 | .end = AB8500_INT_GP_SW_ADC_CONV_END, | |
600 | .flags = IORESOURCE_IRQ, | |
601 | }, | |
602 | }; | |
603 | ||
a9e9ce4c | 604 | static struct resource ab8500_rtc_resources[] = { |
62579266 RV |
605 | { |
606 | .name = "60S", | |
607 | .start = AB8500_INT_RTC_60S, | |
608 | .end = AB8500_INT_RTC_60S, | |
609 | .flags = IORESOURCE_IRQ, | |
610 | }, | |
611 | { | |
612 | .name = "ALARM", | |
613 | .start = AB8500_INT_RTC_ALARM, | |
614 | .end = AB8500_INT_RTC_ALARM, | |
615 | .flags = IORESOURCE_IRQ, | |
616 | }, | |
617 | }; | |
618 | ||
a9e9ce4c | 619 | static struct resource ab8500_poweronkey_db_resources[] = { |
77686517 SI |
620 | { |
621 | .name = "ONKEY_DBF", | |
622 | .start = AB8500_INT_PON_KEY1DB_F, | |
623 | .end = AB8500_INT_PON_KEY1DB_F, | |
624 | .flags = IORESOURCE_IRQ, | |
625 | }, | |
626 | { | |
627 | .name = "ONKEY_DBR", | |
628 | .start = AB8500_INT_PON_KEY1DB_R, | |
629 | .end = AB8500_INT_PON_KEY1DB_R, | |
630 | .flags = IORESOURCE_IRQ, | |
631 | }, | |
632 | }; | |
633 | ||
a9e9ce4c | 634 | static struct resource ab8500_av_acc_detect_resources[] = { |
e098aded | 635 | { |
6af75ecd LW |
636 | .name = "ACC_DETECT_1DB_F", |
637 | .start = AB8500_INT_ACC_DETECT_1DB_F, | |
638 | .end = AB8500_INT_ACC_DETECT_1DB_F, | |
639 | .flags = IORESOURCE_IRQ, | |
e098aded MW |
640 | }, |
641 | { | |
6af75ecd LW |
642 | .name = "ACC_DETECT_1DB_R", |
643 | .start = AB8500_INT_ACC_DETECT_1DB_R, | |
644 | .end = AB8500_INT_ACC_DETECT_1DB_R, | |
645 | .flags = IORESOURCE_IRQ, | |
646 | }, | |
647 | { | |
648 | .name = "ACC_DETECT_21DB_F", | |
649 | .start = AB8500_INT_ACC_DETECT_21DB_F, | |
650 | .end = AB8500_INT_ACC_DETECT_21DB_F, | |
651 | .flags = IORESOURCE_IRQ, | |
652 | }, | |
653 | { | |
654 | .name = "ACC_DETECT_21DB_R", | |
655 | .start = AB8500_INT_ACC_DETECT_21DB_R, | |
656 | .end = AB8500_INT_ACC_DETECT_21DB_R, | |
657 | .flags = IORESOURCE_IRQ, | |
658 | }, | |
659 | { | |
660 | .name = "ACC_DETECT_22DB_F", | |
661 | .start = AB8500_INT_ACC_DETECT_22DB_F, | |
662 | .end = AB8500_INT_ACC_DETECT_22DB_F, | |
663 | .flags = IORESOURCE_IRQ, | |
e098aded | 664 | }, |
6af75ecd LW |
665 | { |
666 | .name = "ACC_DETECT_22DB_R", | |
667 | .start = AB8500_INT_ACC_DETECT_22DB_R, | |
668 | .end = AB8500_INT_ACC_DETECT_22DB_R, | |
669 | .flags = IORESOURCE_IRQ, | |
670 | }, | |
671 | }; | |
672 | ||
a9e9ce4c | 673 | static struct resource ab8500_charger_resources[] = { |
e098aded MW |
674 | { |
675 | .name = "MAIN_CH_UNPLUG_DET", | |
676 | .start = AB8500_INT_MAIN_CH_UNPLUG_DET, | |
677 | .end = AB8500_INT_MAIN_CH_UNPLUG_DET, | |
678 | .flags = IORESOURCE_IRQ, | |
679 | }, | |
680 | { | |
681 | .name = "MAIN_CHARGE_PLUG_DET", | |
682 | .start = AB8500_INT_MAIN_CH_PLUG_DET, | |
683 | .end = AB8500_INT_MAIN_CH_PLUG_DET, | |
684 | .flags = IORESOURCE_IRQ, | |
685 | }, | |
e098aded MW |
686 | { |
687 | .name = "VBUS_DET_R", | |
688 | .start = AB8500_INT_VBUS_DET_R, | |
689 | .end = AB8500_INT_VBUS_DET_R, | |
690 | .flags = IORESOURCE_IRQ, | |
691 | }, | |
692 | { | |
6af75ecd LW |
693 | .name = "VBUS_DET_F", |
694 | .start = AB8500_INT_VBUS_DET_F, | |
695 | .end = AB8500_INT_VBUS_DET_F, | |
e098aded MW |
696 | .flags = IORESOURCE_IRQ, |
697 | }, | |
698 | { | |
6af75ecd LW |
699 | .name = "USB_LINK_STATUS", |
700 | .start = AB8500_INT_USB_LINK_STATUS, | |
701 | .end = AB8500_INT_USB_LINK_STATUS, | |
702 | .flags = IORESOURCE_IRQ, | |
703 | }, | |
e098aded MW |
704 | { |
705 | .name = "VBUS_OVV", | |
706 | .start = AB8500_INT_VBUS_OVV, | |
707 | .end = AB8500_INT_VBUS_OVV, | |
708 | .flags = IORESOURCE_IRQ, | |
709 | }, | |
710 | { | |
6af75ecd LW |
711 | .name = "USB_CH_TH_PROT_R", |
712 | .start = AB8500_INT_USB_CH_TH_PROT_R, | |
713 | .end = AB8500_INT_USB_CH_TH_PROT_R, | |
e098aded MW |
714 | .flags = IORESOURCE_IRQ, |
715 | }, | |
716 | { | |
6af75ecd LW |
717 | .name = "USB_CH_TH_PROT_F", |
718 | .start = AB8500_INT_USB_CH_TH_PROT_F, | |
719 | .end = AB8500_INT_USB_CH_TH_PROT_F, | |
e098aded MW |
720 | .flags = IORESOURCE_IRQ, |
721 | }, | |
722 | { | |
6af75ecd LW |
723 | .name = "MAIN_EXT_CH_NOT_OK", |
724 | .start = AB8500_INT_MAIN_EXT_CH_NOT_OK, | |
725 | .end = AB8500_INT_MAIN_EXT_CH_NOT_OK, | |
726 | .flags = IORESOURCE_IRQ, | |
727 | }, | |
728 | { | |
729 | .name = "MAIN_CH_TH_PROT_R", | |
730 | .start = AB8500_INT_MAIN_CH_TH_PROT_R, | |
731 | .end = AB8500_INT_MAIN_CH_TH_PROT_R, | |
732 | .flags = IORESOURCE_IRQ, | |
733 | }, | |
734 | { | |
735 | .name = "MAIN_CH_TH_PROT_F", | |
736 | .start = AB8500_INT_MAIN_CH_TH_PROT_F, | |
737 | .end = AB8500_INT_MAIN_CH_TH_PROT_F, | |
738 | .flags = IORESOURCE_IRQ, | |
739 | }, | |
740 | { | |
741 | .name = "USB_CHARGER_NOT_OKR", | |
a982362c BJ |
742 | .start = AB8500_INT_USB_CHARGER_NOT_OKR, |
743 | .end = AB8500_INT_USB_CHARGER_NOT_OKR, | |
6af75ecd LW |
744 | .flags = IORESOURCE_IRQ, |
745 | }, | |
746 | { | |
747 | .name = "CH_WD_EXP", | |
748 | .start = AB8500_INT_CH_WD_EXP, | |
749 | .end = AB8500_INT_CH_WD_EXP, | |
750 | .flags = IORESOURCE_IRQ, | |
751 | }, | |
752 | }; | |
753 | ||
a9e9ce4c | 754 | static struct resource ab8500_btemp_resources[] = { |
6af75ecd LW |
755 | { |
756 | .name = "BAT_CTRL_INDB", | |
757 | .start = AB8500_INT_BAT_CTRL_INDB, | |
758 | .end = AB8500_INT_BAT_CTRL_INDB, | |
e098aded MW |
759 | .flags = IORESOURCE_IRQ, |
760 | }, | |
761 | { | |
762 | .name = "BTEMP_LOW", | |
763 | .start = AB8500_INT_BTEMP_LOW, | |
764 | .end = AB8500_INT_BTEMP_LOW, | |
765 | .flags = IORESOURCE_IRQ, | |
766 | }, | |
767 | { | |
768 | .name = "BTEMP_HIGH", | |
769 | .start = AB8500_INT_BTEMP_HIGH, | |
770 | .end = AB8500_INT_BTEMP_HIGH, | |
771 | .flags = IORESOURCE_IRQ, | |
772 | }, | |
773 | { | |
6af75ecd LW |
774 | .name = "BTEMP_LOW_MEDIUM", |
775 | .start = AB8500_INT_BTEMP_LOW_MEDIUM, | |
776 | .end = AB8500_INT_BTEMP_LOW_MEDIUM, | |
e098aded MW |
777 | .flags = IORESOURCE_IRQ, |
778 | }, | |
779 | { | |
6af75ecd LW |
780 | .name = "BTEMP_MEDIUM_HIGH", |
781 | .start = AB8500_INT_BTEMP_MEDIUM_HIGH, | |
782 | .end = AB8500_INT_BTEMP_MEDIUM_HIGH, | |
e098aded MW |
783 | .flags = IORESOURCE_IRQ, |
784 | }, | |
6af75ecd LW |
785 | }; |
786 | ||
a9e9ce4c | 787 | static struct resource ab8500_fg_resources[] = { |
e098aded | 788 | { |
6af75ecd LW |
789 | .name = "NCONV_ACCU", |
790 | .start = AB8500_INT_CCN_CONV_ACC, | |
791 | .end = AB8500_INT_CCN_CONV_ACC, | |
e098aded MW |
792 | .flags = IORESOURCE_IRQ, |
793 | }, | |
794 | { | |
6af75ecd LW |
795 | .name = "BATT_OVV", |
796 | .start = AB8500_INT_BATT_OVV, | |
797 | .end = AB8500_INT_BATT_OVV, | |
e098aded MW |
798 | .flags = IORESOURCE_IRQ, |
799 | }, | |
800 | { | |
6af75ecd LW |
801 | .name = "LOW_BAT_F", |
802 | .start = AB8500_INT_LOW_BAT_F, | |
803 | .end = AB8500_INT_LOW_BAT_F, | |
804 | .flags = IORESOURCE_IRQ, | |
805 | }, | |
806 | { | |
807 | .name = "LOW_BAT_R", | |
808 | .start = AB8500_INT_LOW_BAT_R, | |
809 | .end = AB8500_INT_LOW_BAT_R, | |
810 | .flags = IORESOURCE_IRQ, | |
811 | }, | |
812 | { | |
813 | .name = "CC_INT_CALIB", | |
814 | .start = AB8500_INT_CC_INT_CALIB, | |
815 | .end = AB8500_INT_CC_INT_CALIB, | |
e098aded MW |
816 | .flags = IORESOURCE_IRQ, |
817 | }, | |
a982362c BJ |
818 | { |
819 | .name = "CCEOC", | |
820 | .start = AB8500_INT_CCEOC, | |
821 | .end = AB8500_INT_CCEOC, | |
822 | .flags = IORESOURCE_IRQ, | |
823 | }, | |
e098aded MW |
824 | }; |
825 | ||
a9e9ce4c | 826 | static struct resource ab8500_chargalg_resources[] = {}; |
6af75ecd | 827 | |
df720647 | 828 | #ifdef CONFIG_DEBUG_FS |
a9e9ce4c | 829 | static struct resource ab8500_debug_resources[] = { |
e098aded MW |
830 | { |
831 | .name = "IRQ_FIRST", | |
832 | .start = AB8500_INT_MAIN_EXT_CH_NOT_OK, | |
833 | .end = AB8500_INT_MAIN_EXT_CH_NOT_OK, | |
834 | .flags = IORESOURCE_IRQ, | |
835 | }, | |
836 | { | |
837 | .name = "IRQ_LAST", | |
a982362c BJ |
838 | .start = AB8500_INT_XTAL32K_KO, |
839 | .end = AB8500_INT_XTAL32K_KO, | |
e098aded MW |
840 | .flags = IORESOURCE_IRQ, |
841 | }, | |
842 | }; | |
df720647 | 843 | #endif |
e098aded | 844 | |
a9e9ce4c | 845 | static struct resource ab8500_usb_resources[] = { |
e098aded MW |
846 | { |
847 | .name = "ID_WAKEUP_R", | |
848 | .start = AB8500_INT_ID_WAKEUP_R, | |
849 | .end = AB8500_INT_ID_WAKEUP_R, | |
850 | .flags = IORESOURCE_IRQ, | |
851 | }, | |
852 | { | |
853 | .name = "ID_WAKEUP_F", | |
854 | .start = AB8500_INT_ID_WAKEUP_F, | |
855 | .end = AB8500_INT_ID_WAKEUP_F, | |
856 | .flags = IORESOURCE_IRQ, | |
857 | }, | |
858 | { | |
859 | .name = "VBUS_DET_F", | |
860 | .start = AB8500_INT_VBUS_DET_F, | |
861 | .end = AB8500_INT_VBUS_DET_F, | |
862 | .flags = IORESOURCE_IRQ, | |
863 | }, | |
864 | { | |
865 | .name = "VBUS_DET_R", | |
866 | .start = AB8500_INT_VBUS_DET_R, | |
867 | .end = AB8500_INT_VBUS_DET_R, | |
868 | .flags = IORESOURCE_IRQ, | |
869 | }, | |
92d50a41 MW |
870 | { |
871 | .name = "USB_LINK_STATUS", | |
872 | .start = AB8500_INT_USB_LINK_STATUS, | |
873 | .end = AB8500_INT_USB_LINK_STATUS, | |
874 | .flags = IORESOURCE_IRQ, | |
875 | }, | |
6af75ecd LW |
876 | { |
877 | .name = "USB_ADP_PROBE_PLUG", | |
878 | .start = AB8500_INT_ADP_PROBE_PLUG, | |
879 | .end = AB8500_INT_ADP_PROBE_PLUG, | |
880 | .flags = IORESOURCE_IRQ, | |
881 | }, | |
882 | { | |
883 | .name = "USB_ADP_PROBE_UNPLUG", | |
884 | .start = AB8500_INT_ADP_PROBE_UNPLUG, | |
885 | .end = AB8500_INT_ADP_PROBE_UNPLUG, | |
886 | .flags = IORESOURCE_IRQ, | |
887 | }, | |
e098aded MW |
888 | }; |
889 | ||
a9e9ce4c | 890 | static struct resource ab8505_iddet_resources[] = { |
44f72e53 VS |
891 | { |
892 | .name = "KeyDeglitch", | |
893 | .start = AB8505_INT_KEYDEGLITCH, | |
894 | .end = AB8505_INT_KEYDEGLITCH, | |
895 | .flags = IORESOURCE_IRQ, | |
896 | }, | |
897 | { | |
898 | .name = "KP", | |
899 | .start = AB8505_INT_KP, | |
900 | .end = AB8505_INT_KP, | |
901 | .flags = IORESOURCE_IRQ, | |
902 | }, | |
903 | { | |
904 | .name = "IKP", | |
905 | .start = AB8505_INT_IKP, | |
906 | .end = AB8505_INT_IKP, | |
907 | .flags = IORESOURCE_IRQ, | |
908 | }, | |
909 | { | |
910 | .name = "IKR", | |
911 | .start = AB8505_INT_IKR, | |
912 | .end = AB8505_INT_IKR, | |
913 | .flags = IORESOURCE_IRQ, | |
914 | }, | |
915 | { | |
916 | .name = "KeyStuck", | |
917 | .start = AB8505_INT_KEYSTUCK, | |
918 | .end = AB8505_INT_KEYSTUCK, | |
919 | .flags = IORESOURCE_IRQ, | |
920 | }, | |
921 | }; | |
922 | ||
a9e9ce4c | 923 | static struct resource ab8500_temp_resources[] = { |
e098aded MW |
924 | { |
925 | .name = "AB8500_TEMP_WARM", | |
926 | .start = AB8500_INT_TEMP_WARM, | |
927 | .end = AB8500_INT_TEMP_WARM, | |
928 | .flags = IORESOURCE_IRQ, | |
929 | }, | |
930 | }; | |
931 | ||
a9e9ce4c | 932 | static struct mfd_cell abx500_common_devs[] = { |
5814fc35 MW |
933 | #ifdef CONFIG_DEBUG_FS |
934 | { | |
935 | .name = "ab8500-debug", | |
bad76991 | 936 | .of_compatible = "stericsson,ab8500-debug", |
e098aded MW |
937 | .num_resources = ARRAY_SIZE(ab8500_debug_resources), |
938 | .resources = ab8500_debug_resources, | |
5814fc35 MW |
939 | }, |
940 | #endif | |
e098aded MW |
941 | { |
942 | .name = "ab8500-sysctrl", | |
bad76991 | 943 | .of_compatible = "stericsson,ab8500-sysctrl", |
e098aded MW |
944 | }, |
945 | { | |
946 | .name = "ab8500-regulator", | |
bad76991 | 947 | .of_compatible = "stericsson,ab8500-regulator", |
e098aded | 948 | }, |
916a871c UH |
949 | { |
950 | .name = "abx500-clk", | |
951 | .of_compatible = "stericsson,abx500-clk", | |
952 | }, | |
62579266 RV |
953 | { |
954 | .name = "ab8500-gpadc", | |
bad76991 | 955 | .of_compatible = "stericsson,ab8500-gpadc", |
62579266 RV |
956 | .num_resources = ARRAY_SIZE(ab8500_gpadc_resources), |
957 | .resources = ab8500_gpadc_resources, | |
958 | }, | |
959 | { | |
960 | .name = "ab8500-rtc", | |
bad76991 | 961 | .of_compatible = "stericsson,ab8500-rtc", |
62579266 RV |
962 | .num_resources = ARRAY_SIZE(ab8500_rtc_resources), |
963 | .resources = ab8500_rtc_resources, | |
964 | }, | |
6af75ecd LW |
965 | { |
966 | .name = "ab8500-acc-det", | |
bad76991 | 967 | .of_compatible = "stericsson,ab8500-acc-det", |
6af75ecd LW |
968 | .num_resources = ARRAY_SIZE(ab8500_av_acc_detect_resources), |
969 | .resources = ab8500_av_acc_detect_resources, | |
970 | }, | |
e098aded MW |
971 | { |
972 | .name = "ab8500-poweron-key", | |
bad76991 | 973 | .of_compatible = "stericsson,ab8500-poweron-key", |
e098aded MW |
974 | .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources), |
975 | .resources = ab8500_poweronkey_db_resources, | |
976 | }, | |
f0f05b1c AM |
977 | { |
978 | .name = "ab8500-pwm", | |
bad76991 | 979 | .of_compatible = "stericsson,ab8500-pwm", |
f0f05b1c AM |
980 | .id = 1, |
981 | }, | |
982 | { | |
983 | .name = "ab8500-pwm", | |
bad76991 | 984 | .of_compatible = "stericsson,ab8500-pwm", |
f0f05b1c AM |
985 | .id = 2, |
986 | }, | |
987 | { | |
988 | .name = "ab8500-pwm", | |
bad76991 | 989 | .of_compatible = "stericsson,ab8500-pwm", |
f0f05b1c AM |
990 | .id = 3, |
991 | }, | |
bad76991 LJ |
992 | { |
993 | .name = "ab8500-leds", | |
994 | .of_compatible = "stericsson,ab8500-leds", | |
995 | }, | |
77686517 | 996 | { |
e098aded | 997 | .name = "ab8500-denc", |
bad76991 | 998 | .of_compatible = "stericsson,ab8500-denc", |
e098aded MW |
999 | }, |
1000 | { | |
1001 | .name = "ab8500-temp", | |
bad76991 | 1002 | .of_compatible = "stericsson,ab8500-temp", |
e098aded MW |
1003 | .num_resources = ARRAY_SIZE(ab8500_temp_resources), |
1004 | .resources = ab8500_temp_resources, | |
77686517 | 1005 | }, |
62579266 RV |
1006 | }; |
1007 | ||
a9e9ce4c | 1008 | static struct mfd_cell ab8500_bm_devs[] = { |
6ef9418c RA |
1009 | { |
1010 | .name = "ab8500-charger", | |
4aef72db | 1011 | .of_compatible = "stericsson,ab8500-charger", |
6ef9418c RA |
1012 | .num_resources = ARRAY_SIZE(ab8500_charger_resources), |
1013 | .resources = ab8500_charger_resources, | |
4aef72db R |
1014 | #ifndef CONFIG_OF |
1015 | .platform_data = &ab8500_bm_data, | |
1016 | .pdata_size = sizeof(ab8500_bm_data), | |
1017 | #endif | |
6ef9418c RA |
1018 | }, |
1019 | { | |
1020 | .name = "ab8500-btemp", | |
bd9e8ab2 | 1021 | .of_compatible = "stericsson,ab8500-btemp", |
6ef9418c RA |
1022 | .num_resources = ARRAY_SIZE(ab8500_btemp_resources), |
1023 | .resources = ab8500_btemp_resources, | |
bd9e8ab2 R |
1024 | #ifndef CONFIG_OF |
1025 | .platform_data = &ab8500_bm_data, | |
1026 | .pdata_size = sizeof(ab8500_bm_data), | |
1027 | #endif | |
6ef9418c RA |
1028 | }, |
1029 | { | |
1030 | .name = "ab8500-fg", | |
e0f1abeb | 1031 | .of_compatible = "stericsson,ab8500-fg", |
6ef9418c RA |
1032 | .num_resources = ARRAY_SIZE(ab8500_fg_resources), |
1033 | .resources = ab8500_fg_resources, | |
e0f1abeb R |
1034 | #ifndef CONFIG_OF |
1035 | .platform_data = &ab8500_bm_data, | |
1036 | .pdata_size = sizeof(ab8500_bm_data), | |
1037 | #endif | |
6ef9418c RA |
1038 | }, |
1039 | { | |
1040 | .name = "ab8500-chargalg", | |
a12810ab | 1041 | .of_compatible = "stericsson,ab8500-chargalg", |
6ef9418c RA |
1042 | .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), |
1043 | .resources = ab8500_chargalg_resources, | |
a12810ab R |
1044 | #ifndef CONFIG_OF |
1045 | .platform_data = &ab8500_bm_data, | |
1046 | .pdata_size = sizeof(ab8500_bm_data), | |
1047 | #endif | |
6ef9418c RA |
1048 | }, |
1049 | }; | |
1050 | ||
a9e9ce4c | 1051 | static struct mfd_cell ab8500_devs[] = { |
d6255529 LW |
1052 | { |
1053 | .name = "ab8500-gpio", | |
bad76991 | 1054 | .of_compatible = "stericsson,ab8500-gpio", |
d6255529 LW |
1055 | }, |
1056 | { | |
1057 | .name = "ab8500-usb", | |
bad76991 | 1058 | .of_compatible = "stericsson,ab8500-usb", |
d6255529 LW |
1059 | .num_resources = ARRAY_SIZE(ab8500_usb_resources), |
1060 | .resources = ab8500_usb_resources, | |
1061 | }, | |
44f72e53 VS |
1062 | { |
1063 | .name = "ab8500-codec", | |
81a21cdd | 1064 | .of_compatible = "stericsson,ab8500-codec", |
44f72e53 | 1065 | }, |
d6255529 LW |
1066 | }; |
1067 | ||
a9e9ce4c | 1068 | static struct mfd_cell ab9540_devs[] = { |
d6255529 LW |
1069 | { |
1070 | .name = "ab8500-gpio", | |
d6255529 LW |
1071 | }, |
1072 | { | |
1073 | .name = "ab9540-usb", | |
1074 | .num_resources = ARRAY_SIZE(ab8500_usb_resources), | |
1075 | .resources = ab8500_usb_resources, | |
1076 | }, | |
44f72e53 VS |
1077 | { |
1078 | .name = "ab9540-codec", | |
1079 | }, | |
1080 | }; | |
1081 | ||
1082 | /* Device list common to ab9540 and ab8505 */ | |
a9e9ce4c | 1083 | static struct mfd_cell ab9540_ab8505_devs[] = { |
44f72e53 VS |
1084 | { |
1085 | .name = "ab-iddet", | |
1086 | .num_resources = ARRAY_SIZE(ab8505_iddet_resources), | |
1087 | .resources = ab8505_iddet_resources, | |
1088 | }, | |
d6255529 LW |
1089 | }; |
1090 | ||
cca69b67 MW |
1091 | static ssize_t show_chip_id(struct device *dev, |
1092 | struct device_attribute *attr, char *buf) | |
1093 | { | |
1094 | struct ab8500 *ab8500; | |
1095 | ||
1096 | ab8500 = dev_get_drvdata(dev); | |
1097 | return sprintf(buf, "%#x\n", ab8500 ? ab8500->chip_id : -EINVAL); | |
1098 | } | |
1099 | ||
e5c238c3 MW |
1100 | /* |
1101 | * ab8500 has switched off due to (SWITCH_OFF_STATUS): | |
1102 | * 0x01 Swoff bit programming | |
1103 | * 0x02 Thermal protection activation | |
1104 | * 0x04 Vbat lower then BattOk falling threshold | |
1105 | * 0x08 Watchdog expired | |
1106 | * 0x10 Non presence of 32kHz clock | |
1107 | * 0x20 Battery level lower than power on reset threshold | |
1108 | * 0x40 Power on key 1 pressed longer than 10 seconds | |
1109 | * 0x80 DB8500 thermal shutdown | |
1110 | */ | |
1111 | static ssize_t show_switch_off_status(struct device *dev, | |
1112 | struct device_attribute *attr, char *buf) | |
1113 | { | |
1114 | int ret; | |
1115 | u8 value; | |
1116 | struct ab8500 *ab8500; | |
1117 | ||
1118 | ab8500 = dev_get_drvdata(dev); | |
1119 | ret = get_register_interruptible(ab8500, AB8500_RTC, | |
1120 | AB8500_SWITCH_OFF_STATUS, &value); | |
1121 | if (ret < 0) | |
1122 | return ret; | |
1123 | return sprintf(buf, "%#x\n", value); | |
1124 | } | |
1125 | ||
b4a31037 AL |
1126 | /* |
1127 | * ab8500 has turned on due to (TURN_ON_STATUS): | |
1128 | * 0x01 PORnVbat | |
1129 | * 0x02 PonKey1dbF | |
1130 | * 0x04 PonKey2dbF | |
1131 | * 0x08 RTCAlarm | |
1132 | * 0x10 MainChDet | |
1133 | * 0x20 VbusDet | |
1134 | * 0x40 UsbIDDetect | |
1135 | * 0x80 Reserved | |
1136 | */ | |
1137 | static ssize_t show_turn_on_status(struct device *dev, | |
1138 | struct device_attribute *attr, char *buf) | |
1139 | { | |
1140 | int ret; | |
1141 | u8 value; | |
1142 | struct ab8500 *ab8500; | |
1143 | ||
1144 | ab8500 = dev_get_drvdata(dev); | |
1145 | ret = get_register_interruptible(ab8500, AB8500_SYS_CTRL1_BLOCK, | |
1146 | AB8500_TURN_ON_STATUS, &value); | |
1147 | if (ret < 0) | |
1148 | return ret; | |
1149 | return sprintf(buf, "%#x\n", value); | |
1150 | } | |
1151 | ||
d6255529 LW |
1152 | static ssize_t show_ab9540_dbbrstn(struct device *dev, |
1153 | struct device_attribute *attr, char *buf) | |
1154 | { | |
1155 | struct ab8500 *ab8500; | |
1156 | int ret; | |
1157 | u8 value; | |
1158 | ||
1159 | ab8500 = dev_get_drvdata(dev); | |
1160 | ||
1161 | ret = get_register_interruptible(ab8500, AB8500_REGU_CTRL2, | |
1162 | AB9540_MODEM_CTRL2_REG, &value); | |
1163 | if (ret < 0) | |
1164 | return ret; | |
1165 | ||
1166 | return sprintf(buf, "%d\n", | |
1167 | (value & AB9540_MODEM_CTRL2_SWDBBRSTN_BIT) ? 1 : 0); | |
1168 | } | |
1169 | ||
1170 | static ssize_t store_ab9540_dbbrstn(struct device *dev, | |
1171 | struct device_attribute *attr, const char *buf, size_t count) | |
1172 | { | |
1173 | struct ab8500 *ab8500; | |
1174 | int ret = count; | |
1175 | int err; | |
1176 | u8 bitvalues; | |
1177 | ||
1178 | ab8500 = dev_get_drvdata(dev); | |
1179 | ||
1180 | if (count > 0) { | |
1181 | switch (buf[0]) { | |
1182 | case '0': | |
1183 | bitvalues = 0; | |
1184 | break; | |
1185 | case '1': | |
1186 | bitvalues = AB9540_MODEM_CTRL2_SWDBBRSTN_BIT; | |
1187 | break; | |
1188 | default: | |
1189 | goto exit; | |
1190 | } | |
1191 | ||
1192 | err = mask_and_set_register_interruptible(ab8500, | |
1193 | AB8500_REGU_CTRL2, AB9540_MODEM_CTRL2_REG, | |
1194 | AB9540_MODEM_CTRL2_SWDBBRSTN_BIT, bitvalues); | |
1195 | if (err) | |
1196 | dev_info(ab8500->dev, | |
1197 | "Failed to set DBBRSTN %c, err %#x\n", | |
1198 | buf[0], err); | |
1199 | } | |
1200 | ||
1201 | exit: | |
1202 | return ret; | |
1203 | } | |
1204 | ||
cca69b67 | 1205 | static DEVICE_ATTR(chip_id, S_IRUGO, show_chip_id, NULL); |
e5c238c3 | 1206 | static DEVICE_ATTR(switch_off_status, S_IRUGO, show_switch_off_status, NULL); |
b4a31037 | 1207 | static DEVICE_ATTR(turn_on_status, S_IRUGO, show_turn_on_status, NULL); |
d6255529 LW |
1208 | static DEVICE_ATTR(dbbrstn, S_IRUGO | S_IWUSR, |
1209 | show_ab9540_dbbrstn, store_ab9540_dbbrstn); | |
cca69b67 MW |
1210 | |
1211 | static struct attribute *ab8500_sysfs_entries[] = { | |
1212 | &dev_attr_chip_id.attr, | |
e5c238c3 | 1213 | &dev_attr_switch_off_status.attr, |
b4a31037 | 1214 | &dev_attr_turn_on_status.attr, |
cca69b67 MW |
1215 | NULL, |
1216 | }; | |
1217 | ||
d6255529 LW |
1218 | static struct attribute *ab9540_sysfs_entries[] = { |
1219 | &dev_attr_chip_id.attr, | |
1220 | &dev_attr_switch_off_status.attr, | |
1221 | &dev_attr_turn_on_status.attr, | |
1222 | &dev_attr_dbbrstn.attr, | |
1223 | NULL, | |
1224 | }; | |
1225 | ||
cca69b67 MW |
1226 | static struct attribute_group ab8500_attr_group = { |
1227 | .attrs = ab8500_sysfs_entries, | |
1228 | }; | |
1229 | ||
d6255529 LW |
1230 | static struct attribute_group ab9540_attr_group = { |
1231 | .attrs = ab9540_sysfs_entries, | |
1232 | }; | |
1233 | ||
f791be49 | 1234 | static int ab8500_probe(struct platform_device *pdev) |
62579266 | 1235 | { |
b04c530c JA |
1236 | static char *switch_off_status[] = { |
1237 | "Swoff bit programming", | |
1238 | "Thermal protection activation", | |
1239 | "Vbat lower then BattOk falling threshold", | |
1240 | "Watchdog expired", | |
1241 | "Non presence of 32kHz clock", | |
1242 | "Battery level lower than power on reset threshold", | |
1243 | "Power on key 1 pressed longer than 10 seconds", | |
1244 | "DB8500 thermal shutdown"}; | |
d28f1db8 LJ |
1245 | struct ab8500_platform_data *plat = dev_get_platdata(&pdev->dev); |
1246 | const struct platform_device_id *platid = platform_get_device_id(pdev); | |
6bc4a568 LJ |
1247 | enum ab8500_version version = AB8500_VERSION_UNDEFINED; |
1248 | struct device_node *np = pdev->dev.of_node; | |
d28f1db8 LJ |
1249 | struct ab8500 *ab8500; |
1250 | struct resource *resource; | |
62579266 RV |
1251 | int ret; |
1252 | int i; | |
47c16975 | 1253 | u8 value; |
62579266 | 1254 | |
8c4203cb | 1255 | ab8500 = devm_kzalloc(&pdev->dev, sizeof *ab8500, GFP_KERNEL); |
d28f1db8 LJ |
1256 | if (!ab8500) |
1257 | return -ENOMEM; | |
1258 | ||
62579266 RV |
1259 | if (plat) |
1260 | ab8500->irq_base = plat->irq_base; | |
1261 | ||
d28f1db8 LJ |
1262 | ab8500->dev = &pdev->dev; |
1263 | ||
1264 | resource = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | |
8c4203cb LJ |
1265 | if (!resource) |
1266 | return -ENODEV; | |
d28f1db8 LJ |
1267 | |
1268 | ab8500->irq = resource->start; | |
1269 | ||
822672a7 LJ |
1270 | ab8500->read = ab8500_prcmu_read; |
1271 | ab8500->write = ab8500_prcmu_write; | |
1272 | ab8500->write_masked = ab8500_prcmu_write_masked; | |
d28f1db8 | 1273 | |
62579266 RV |
1274 | mutex_init(&ab8500->lock); |
1275 | mutex_init(&ab8500->irq_lock); | |
112a80d2 | 1276 | atomic_set(&ab8500->transfer_ongoing, 0); |
62579266 | 1277 | |
d28f1db8 LJ |
1278 | platform_set_drvdata(pdev, ab8500); |
1279 | ||
6bc4a568 LJ |
1280 | if (platid) |
1281 | version = platid->driver_data; | |
6bc4a568 | 1282 | |
0f620837 LW |
1283 | if (version != AB8500_VERSION_UNDEFINED) |
1284 | ab8500->version = version; | |
1285 | else { | |
1286 | ret = get_register_interruptible(ab8500, AB8500_MISC, | |
1287 | AB8500_IC_NAME_REG, &value); | |
1288 | if (ret < 0) | |
8c4203cb | 1289 | return ret; |
0f620837 LW |
1290 | |
1291 | ab8500->version = value; | |
1292 | } | |
1293 | ||
47c16975 MW |
1294 | ret = get_register_interruptible(ab8500, AB8500_MISC, |
1295 | AB8500_REV_REG, &value); | |
62579266 | 1296 | if (ret < 0) |
8c4203cb | 1297 | return ret; |
62579266 | 1298 | |
47c16975 | 1299 | ab8500->chip_id = value; |
62579266 | 1300 | |
0f620837 LW |
1301 | dev_info(ab8500->dev, "detected chip, %s rev. %1x.%1x\n", |
1302 | ab8500_version_str[ab8500->version], | |
1303 | ab8500->chip_id >> 4, | |
1304 | ab8500->chip_id & 0x0F); | |
1305 | ||
d6255529 | 1306 | /* Configure AB8500 or AB9540 IRQ */ |
a982362c | 1307 | if (is_ab9540(ab8500) || is_ab8505(ab8500)) { |
d6255529 LW |
1308 | ab8500->mask_size = AB9540_NUM_IRQ_REGS; |
1309 | ab8500->irq_reg_offset = ab9540_irq_regoffset; | |
1310 | } else { | |
1311 | ab8500->mask_size = AB8500_NUM_IRQ_REGS; | |
1312 | ab8500->irq_reg_offset = ab8500_irq_regoffset; | |
1313 | } | |
8c4203cb | 1314 | ab8500->mask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL); |
2ced445e LW |
1315 | if (!ab8500->mask) |
1316 | return -ENOMEM; | |
8c4203cb LJ |
1317 | ab8500->oldmask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL); |
1318 | if (!ab8500->oldmask) | |
1319 | return -ENOMEM; | |
1320 | ||
e5c238c3 MW |
1321 | /* |
1322 | * ab8500 has switched off due to (SWITCH_OFF_STATUS): | |
1323 | * 0x01 Swoff bit programming | |
1324 | * 0x02 Thermal protection activation | |
1325 | * 0x04 Vbat lower then BattOk falling threshold | |
1326 | * 0x08 Watchdog expired | |
1327 | * 0x10 Non presence of 32kHz clock | |
1328 | * 0x20 Battery level lower than power on reset threshold | |
1329 | * 0x40 Power on key 1 pressed longer than 10 seconds | |
1330 | * 0x80 DB8500 thermal shutdown | |
1331 | */ | |
1332 | ||
1333 | ret = get_register_interruptible(ab8500, AB8500_RTC, | |
1334 | AB8500_SWITCH_OFF_STATUS, &value); | |
1335 | if (ret < 0) | |
1336 | return ret; | |
b04c530c JA |
1337 | dev_info(ab8500->dev, "switch off cause(s) (%#x): ", value); |
1338 | ||
1339 | if (value) { | |
1340 | for (i = 0; i < ARRAY_SIZE(switch_off_status); i++) { | |
1341 | if (value & 1) | |
1342 | printk(KERN_CONT " \"%s\"", | |
1343 | switch_off_status[i]); | |
1344 | value = value >> 1; | |
1345 | ||
1346 | } | |
1347 | printk(KERN_CONT "\n"); | |
1348 | } else { | |
1349 | printk(KERN_CONT " None\n"); | |
1350 | } | |
e5c238c3 | 1351 | |
62579266 RV |
1352 | if (plat && plat->init) |
1353 | plat->init(ab8500); | |
1354 | ||
1355 | /* Clear and mask all interrupts */ | |
2ced445e | 1356 | for (i = 0; i < ab8500->mask_size; i++) { |
0f620837 LW |
1357 | /* |
1358 | * Interrupt register 12 doesn't exist prior to AB8500 version | |
1359 | * 2.0 | |
1360 | */ | |
1361 | if (ab8500->irq_reg_offset[i] == 11 && | |
1362 | is_ab8500_1p1_or_earlier(ab8500)) | |
92d50a41 | 1363 | continue; |
62579266 | 1364 | |
47c16975 | 1365 | get_register_interruptible(ab8500, AB8500_INTERRUPT, |
2ced445e | 1366 | AB8500_IT_LATCH1_REG + ab8500->irq_reg_offset[i], |
92d50a41 | 1367 | &value); |
47c16975 | 1368 | set_register_interruptible(ab8500, AB8500_INTERRUPT, |
2ced445e | 1369 | AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i], 0xff); |
62579266 RV |
1370 | } |
1371 | ||
47c16975 MW |
1372 | ret = abx500_register_ops(ab8500->dev, &ab8500_ops); |
1373 | if (ret) | |
8c4203cb | 1374 | return ret; |
47c16975 | 1375 | |
2ced445e | 1376 | for (i = 0; i < ab8500->mask_size; i++) |
62579266 RV |
1377 | ab8500->mask[i] = ab8500->oldmask[i] = 0xff; |
1378 | ||
06e589ef LJ |
1379 | ret = ab8500_irq_init(ab8500, np); |
1380 | if (ret) | |
8c4203cb | 1381 | return ret; |
62579266 | 1382 | |
06e589ef LJ |
1383 | /* Activate this feature only in ab9540 */ |
1384 | /* till tests are done on ab8500 1p2 or later*/ | |
1385 | if (is_ab9540(ab8500)) { | |
8c4203cb LJ |
1386 | ret = devm_request_threaded_irq(&pdev->dev, ab8500->irq, NULL, |
1387 | ab8500_hierarchical_irq, | |
1388 | IRQF_ONESHOT | IRQF_NO_SUSPEND, | |
1389 | "ab8500", ab8500); | |
06e589ef LJ |
1390 | } |
1391 | else { | |
8c4203cb LJ |
1392 | ret = devm_request_threaded_irq(&pdev->dev, ab8500->irq, NULL, |
1393 | ab8500_irq, | |
1394 | IRQF_ONESHOT | IRQF_NO_SUSPEND, | |
1395 | "ab8500", ab8500); | |
62579266 | 1396 | if (ret) |
8c4203cb | 1397 | return ret; |
62579266 RV |
1398 | } |
1399 | ||
bad76991 LJ |
1400 | ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs, |
1401 | ARRAY_SIZE(abx500_common_devs), NULL, | |
55692af5 | 1402 | ab8500->irq_base, ab8500->domain); |
bad76991 | 1403 | if (ret) |
8c4203cb | 1404 | return ret; |
d6255529 | 1405 | |
bad76991 LJ |
1406 | if (is_ab9540(ab8500)) |
1407 | ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, | |
1408 | ARRAY_SIZE(ab9540_devs), NULL, | |
55692af5 | 1409 | ab8500->irq_base, ab8500->domain); |
bad76991 LJ |
1410 | else |
1411 | ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, | |
1412 | ARRAY_SIZE(ab8500_devs), NULL, | |
55692af5 | 1413 | ab8500->irq_base, ab8500->domain); |
bad76991 | 1414 | if (ret) |
8c4203cb | 1415 | return ret; |
44f72e53 | 1416 | |
bad76991 LJ |
1417 | if (is_ab9540(ab8500) || is_ab8505(ab8500)) |
1418 | ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs, | |
1419 | ARRAY_SIZE(ab9540_ab8505_devs), NULL, | |
55692af5 | 1420 | ab8500->irq_base, ab8500->domain); |
bad76991 | 1421 | if (ret) |
8c4203cb | 1422 | return ret; |
62579266 | 1423 | |
6ef9418c RA |
1424 | if (!no_bm) { |
1425 | /* Add battery management devices */ | |
1426 | ret = mfd_add_devices(ab8500->dev, 0, ab8500_bm_devs, | |
1427 | ARRAY_SIZE(ab8500_bm_devs), NULL, | |
55692af5 | 1428 | ab8500->irq_base, ab8500->domain); |
6ef9418c RA |
1429 | if (ret) |
1430 | dev_err(ab8500->dev, "error adding bm devices\n"); | |
1431 | } | |
1432 | ||
d6255529 LW |
1433 | if (is_ab9540(ab8500)) |
1434 | ret = sysfs_create_group(&ab8500->dev->kobj, | |
1435 | &ab9540_attr_group); | |
1436 | else | |
1437 | ret = sysfs_create_group(&ab8500->dev->kobj, | |
1438 | &ab8500_attr_group); | |
cca69b67 MW |
1439 | if (ret) |
1440 | dev_err(ab8500->dev, "error creating sysfs entries\n"); | |
06e589ef LJ |
1441 | |
1442 | return ret; | |
62579266 RV |
1443 | } |
1444 | ||
4740f73f | 1445 | static int ab8500_remove(struct platform_device *pdev) |
62579266 | 1446 | { |
d28f1db8 LJ |
1447 | struct ab8500 *ab8500 = platform_get_drvdata(pdev); |
1448 | ||
d6255529 LW |
1449 | if (is_ab9540(ab8500)) |
1450 | sysfs_remove_group(&ab8500->dev->kobj, &ab9540_attr_group); | |
1451 | else | |
1452 | sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group); | |
06e589ef | 1453 | |
62579266 | 1454 | mfd_remove_devices(ab8500->dev); |
62579266 RV |
1455 | |
1456 | return 0; | |
1457 | } | |
1458 | ||
d28f1db8 LJ |
1459 | static const struct platform_device_id ab8500_id[] = { |
1460 | { "ab8500-core", AB8500_VERSION_AB8500 }, | |
1461 | { "ab8505-i2c", AB8500_VERSION_AB8505 }, | |
1462 | { "ab9540-i2c", AB8500_VERSION_AB9540 }, | |
1463 | { "ab8540-i2c", AB8500_VERSION_AB8540 }, | |
1464 | { } | |
1465 | }; | |
1466 | ||
1467 | static struct platform_driver ab8500_core_driver = { | |
1468 | .driver = { | |
1469 | .name = "ab8500-core", | |
1470 | .owner = THIS_MODULE, | |
1471 | }, | |
1472 | .probe = ab8500_probe, | |
84449216 | 1473 | .remove = ab8500_remove, |
d28f1db8 LJ |
1474 | .id_table = ab8500_id, |
1475 | }; | |
1476 | ||
1477 | static int __init ab8500_core_init(void) | |
1478 | { | |
1479 | return platform_driver_register(&ab8500_core_driver); | |
1480 | } | |
1481 | ||
1482 | static void __exit ab8500_core_exit(void) | |
1483 | { | |
1484 | platform_driver_unregister(&ab8500_core_driver); | |
1485 | } | |
ba7cbc3e | 1486 | core_initcall(ab8500_core_init); |
d28f1db8 LJ |
1487 | module_exit(ab8500_core_exit); |
1488 | ||
adceed62 | 1489 | MODULE_AUTHOR("Mattias Wallin, Srinidhi Kasagar, Rabin Vincent"); |
62579266 RV |
1490 | MODULE_DESCRIPTION("AB8500 MFD core"); |
1491 | MODULE_LICENSE("GPL v2"); |