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> | |
14 | #include <linux/delay.h> | |
15 | #include <linux/interrupt.h> | |
16 | #include <linux/module.h> | |
17 | #include <linux/platform_device.h> | |
18 | #include <linux/mfd/core.h> | |
47c16975 | 19 | #include <linux/mfd/abx500.h> |
ee66e653 | 20 | #include <linux/mfd/abx500/ab8500.h> |
549931f9 | 21 | #include <linux/regulator/ab8500.h> |
62579266 RV |
22 | |
23 | /* | |
24 | * Interrupt register offsets | |
25 | * Bank : 0x0E | |
26 | */ | |
47c16975 MW |
27 | #define AB8500_IT_SOURCE1_REG 0x00 |
28 | #define AB8500_IT_SOURCE2_REG 0x01 | |
29 | #define AB8500_IT_SOURCE3_REG 0x02 | |
30 | #define AB8500_IT_SOURCE4_REG 0x03 | |
31 | #define AB8500_IT_SOURCE5_REG 0x04 | |
32 | #define AB8500_IT_SOURCE6_REG 0x05 | |
33 | #define AB8500_IT_SOURCE7_REG 0x06 | |
34 | #define AB8500_IT_SOURCE8_REG 0x07 | |
35 | #define AB8500_IT_SOURCE19_REG 0x12 | |
36 | #define AB8500_IT_SOURCE20_REG 0x13 | |
37 | #define AB8500_IT_SOURCE21_REG 0x14 | |
38 | #define AB8500_IT_SOURCE22_REG 0x15 | |
39 | #define AB8500_IT_SOURCE23_REG 0x16 | |
40 | #define AB8500_IT_SOURCE24_REG 0x17 | |
62579266 RV |
41 | |
42 | /* | |
43 | * latch registers | |
44 | */ | |
47c16975 MW |
45 | #define AB8500_IT_LATCH1_REG 0x20 |
46 | #define AB8500_IT_LATCH2_REG 0x21 | |
47 | #define AB8500_IT_LATCH3_REG 0x22 | |
48 | #define AB8500_IT_LATCH4_REG 0x23 | |
49 | #define AB8500_IT_LATCH5_REG 0x24 | |
50 | #define AB8500_IT_LATCH6_REG 0x25 | |
51 | #define AB8500_IT_LATCH7_REG 0x26 | |
52 | #define AB8500_IT_LATCH8_REG 0x27 | |
53 | #define AB8500_IT_LATCH9_REG 0x28 | |
54 | #define AB8500_IT_LATCH10_REG 0x29 | |
92d50a41 | 55 | #define AB8500_IT_LATCH12_REG 0x2B |
47c16975 MW |
56 | #define AB8500_IT_LATCH19_REG 0x32 |
57 | #define AB8500_IT_LATCH20_REG 0x33 | |
58 | #define AB8500_IT_LATCH21_REG 0x34 | |
59 | #define AB8500_IT_LATCH22_REG 0x35 | |
60 | #define AB8500_IT_LATCH23_REG 0x36 | |
61 | #define AB8500_IT_LATCH24_REG 0x37 | |
62579266 RV |
62 | |
63 | /* | |
64 | * mask registers | |
65 | */ | |
66 | ||
47c16975 MW |
67 | #define AB8500_IT_MASK1_REG 0x40 |
68 | #define AB8500_IT_MASK2_REG 0x41 | |
69 | #define AB8500_IT_MASK3_REG 0x42 | |
70 | #define AB8500_IT_MASK4_REG 0x43 | |
71 | #define AB8500_IT_MASK5_REG 0x44 | |
72 | #define AB8500_IT_MASK6_REG 0x45 | |
73 | #define AB8500_IT_MASK7_REG 0x46 | |
74 | #define AB8500_IT_MASK8_REG 0x47 | |
75 | #define AB8500_IT_MASK9_REG 0x48 | |
76 | #define AB8500_IT_MASK10_REG 0x49 | |
77 | #define AB8500_IT_MASK11_REG 0x4A | |
78 | #define AB8500_IT_MASK12_REG 0x4B | |
79 | #define AB8500_IT_MASK13_REG 0x4C | |
80 | #define AB8500_IT_MASK14_REG 0x4D | |
81 | #define AB8500_IT_MASK15_REG 0x4E | |
82 | #define AB8500_IT_MASK16_REG 0x4F | |
83 | #define AB8500_IT_MASK17_REG 0x50 | |
84 | #define AB8500_IT_MASK18_REG 0x51 | |
85 | #define AB8500_IT_MASK19_REG 0x52 | |
86 | #define AB8500_IT_MASK20_REG 0x53 | |
87 | #define AB8500_IT_MASK21_REG 0x54 | |
88 | #define AB8500_IT_MASK22_REG 0x55 | |
89 | #define AB8500_IT_MASK23_REG 0x56 | |
90 | #define AB8500_IT_MASK24_REG 0x57 | |
91 | ||
92 | #define AB8500_REV_REG 0x80 | |
0f620837 | 93 | #define AB8500_IC_NAME_REG 0x82 |
e5c238c3 | 94 | #define AB8500_SWITCH_OFF_STATUS 0x00 |
62579266 | 95 | |
b4a31037 AL |
96 | #define AB8500_TURN_ON_STATUS 0x00 |
97 | ||
62579266 RV |
98 | /* |
99 | * Map interrupt numbers to the LATCH and MASK register offsets, Interrupt | |
2ced445e LW |
100 | * numbers are indexed into this array with (num / 8). The interupts are |
101 | * defined in linux/mfd/ab8500.h | |
62579266 RV |
102 | * |
103 | * This is one off from the register names, i.e. AB8500_IT_MASK1_REG is at | |
104 | * offset 0. | |
105 | */ | |
2ced445e | 106 | /* AB8500 support */ |
62579266 | 107 | static const int ab8500_irq_regoffset[AB8500_NUM_IRQ_REGS] = { |
92d50a41 | 108 | 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 18, 19, 20, 21, |
62579266 RV |
109 | }; |
110 | ||
0f620837 LW |
111 | static const char ab8500_version_str[][7] = { |
112 | [AB8500_VERSION_AB8500] = "AB8500", | |
113 | [AB8500_VERSION_AB8505] = "AB8505", | |
114 | [AB8500_VERSION_AB9540] = "AB9540", | |
115 | [AB8500_VERSION_AB8540] = "AB8540", | |
116 | }; | |
117 | ||
47c16975 MW |
118 | static int ab8500_get_chip_id(struct device *dev) |
119 | { | |
6bce7bf1 MW |
120 | struct ab8500 *ab8500; |
121 | ||
122 | if (!dev) | |
123 | return -EINVAL; | |
124 | ab8500 = dev_get_drvdata(dev->parent); | |
125 | return ab8500 ? (int)ab8500->chip_id : -EINVAL; | |
47c16975 MW |
126 | } |
127 | ||
128 | static int set_register_interruptible(struct ab8500 *ab8500, u8 bank, | |
129 | u8 reg, u8 data) | |
62579266 RV |
130 | { |
131 | int ret; | |
47c16975 MW |
132 | /* |
133 | * Put the u8 bank and u8 register together into a an u16. | |
134 | * The bank on higher 8 bits and register in lower 8 bits. | |
135 | * */ | |
136 | u16 addr = ((u16)bank) << 8 | reg; | |
62579266 RV |
137 | |
138 | dev_vdbg(ab8500->dev, "wr: addr %#x <= %#x\n", addr, data); | |
139 | ||
47c16975 MW |
140 | ret = mutex_lock_interruptible(&ab8500->lock); |
141 | if (ret) | |
142 | return ret; | |
143 | ||
62579266 RV |
144 | ret = ab8500->write(ab8500, addr, data); |
145 | if (ret < 0) | |
146 | dev_err(ab8500->dev, "failed to write reg %#x: %d\n", | |
147 | addr, ret); | |
47c16975 | 148 | mutex_unlock(&ab8500->lock); |
62579266 RV |
149 | |
150 | return ret; | |
151 | } | |
152 | ||
47c16975 MW |
153 | static int ab8500_set_register(struct device *dev, u8 bank, |
154 | u8 reg, u8 value) | |
62579266 | 155 | { |
47c16975 | 156 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); |
62579266 | 157 | |
47c16975 | 158 | return set_register_interruptible(ab8500, bank, reg, value); |
62579266 | 159 | } |
62579266 | 160 | |
47c16975 MW |
161 | static int get_register_interruptible(struct ab8500 *ab8500, u8 bank, |
162 | u8 reg, u8 *value) | |
62579266 RV |
163 | { |
164 | int ret; | |
47c16975 MW |
165 | /* put the u8 bank and u8 reg together into a an u16. |
166 | * bank on higher 8 bits and reg in lower */ | |
167 | u16 addr = ((u16)bank) << 8 | reg; | |
168 | ||
169 | ret = mutex_lock_interruptible(&ab8500->lock); | |
170 | if (ret) | |
171 | return ret; | |
62579266 RV |
172 | |
173 | ret = ab8500->read(ab8500, addr); | |
174 | if (ret < 0) | |
175 | dev_err(ab8500->dev, "failed to read reg %#x: %d\n", | |
176 | addr, ret); | |
47c16975 MW |
177 | else |
178 | *value = ret; | |
62579266 | 179 | |
47c16975 | 180 | mutex_unlock(&ab8500->lock); |
62579266 RV |
181 | dev_vdbg(ab8500->dev, "rd: addr %#x => data %#x\n", addr, ret); |
182 | ||
183 | return ret; | |
184 | } | |
185 | ||
47c16975 MW |
186 | static int ab8500_get_register(struct device *dev, u8 bank, |
187 | u8 reg, u8 *value) | |
62579266 | 188 | { |
47c16975 | 189 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); |
62579266 | 190 | |
47c16975 | 191 | return get_register_interruptible(ab8500, bank, reg, value); |
62579266 | 192 | } |
47c16975 MW |
193 | |
194 | static int mask_and_set_register_interruptible(struct ab8500 *ab8500, u8 bank, | |
195 | u8 reg, u8 bitmask, u8 bitvalues) | |
62579266 RV |
196 | { |
197 | int ret; | |
47c16975 MW |
198 | u8 data; |
199 | /* put the u8 bank and u8 reg together into a an u16. | |
200 | * bank on higher 8 bits and reg in lower */ | |
201 | u16 addr = ((u16)bank) << 8 | reg; | |
62579266 | 202 | |
47c16975 MW |
203 | ret = mutex_lock_interruptible(&ab8500->lock); |
204 | if (ret) | |
205 | return ret; | |
62579266 | 206 | |
47c16975 MW |
207 | ret = ab8500->read(ab8500, addr); |
208 | if (ret < 0) { | |
209 | dev_err(ab8500->dev, "failed to read reg %#x: %d\n", | |
210 | addr, ret); | |
62579266 | 211 | goto out; |
47c16975 | 212 | } |
62579266 | 213 | |
47c16975 MW |
214 | data = (u8)ret; |
215 | data = (~bitmask & data) | (bitmask & bitvalues); | |
62579266 | 216 | |
47c16975 MW |
217 | ret = ab8500->write(ab8500, addr, data); |
218 | if (ret < 0) | |
219 | dev_err(ab8500->dev, "failed to write reg %#x: %d\n", | |
220 | addr, ret); | |
62579266 | 221 | |
47c16975 | 222 | dev_vdbg(ab8500->dev, "mask: addr %#x => data %#x\n", addr, data); |
62579266 RV |
223 | out: |
224 | mutex_unlock(&ab8500->lock); | |
225 | return ret; | |
226 | } | |
47c16975 MW |
227 | |
228 | static int ab8500_mask_and_set_register(struct device *dev, | |
229 | u8 bank, u8 reg, u8 bitmask, u8 bitvalues) | |
230 | { | |
231 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); | |
232 | ||
233 | return mask_and_set_register_interruptible(ab8500, bank, reg, | |
234 | bitmask, bitvalues); | |
235 | ||
236 | } | |
237 | ||
238 | static struct abx500_ops ab8500_ops = { | |
239 | .get_chip_id = ab8500_get_chip_id, | |
240 | .get_register = ab8500_get_register, | |
241 | .set_register = ab8500_set_register, | |
242 | .get_register_page = NULL, | |
243 | .set_register_page = NULL, | |
244 | .mask_and_set_register = ab8500_mask_and_set_register, | |
245 | .event_registers_startup_state_get = NULL, | |
246 | .startup_irq_enabled = NULL, | |
247 | }; | |
62579266 | 248 | |
9505a0a0 | 249 | static void ab8500_irq_lock(struct irq_data *data) |
62579266 | 250 | { |
9505a0a0 | 251 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
62579266 RV |
252 | |
253 | mutex_lock(&ab8500->irq_lock); | |
254 | } | |
255 | ||
9505a0a0 | 256 | static void ab8500_irq_sync_unlock(struct irq_data *data) |
62579266 | 257 | { |
9505a0a0 | 258 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
62579266 RV |
259 | int i; |
260 | ||
2ced445e | 261 | for (i = 0; i < ab8500->mask_size; i++) { |
62579266 RV |
262 | u8 old = ab8500->oldmask[i]; |
263 | u8 new = ab8500->mask[i]; | |
264 | int reg; | |
265 | ||
266 | if (new == old) | |
267 | continue; | |
268 | ||
0f620837 LW |
269 | /* |
270 | * Interrupt register 12 doesn't exist prior to AB8500 version | |
271 | * 2.0 | |
272 | */ | |
273 | if (ab8500->irq_reg_offset[i] == 11 && | |
274 | is_ab8500_1p1_or_earlier(ab8500)) | |
92d50a41 MW |
275 | continue; |
276 | ||
62579266 RV |
277 | ab8500->oldmask[i] = new; |
278 | ||
2ced445e | 279 | reg = AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i]; |
47c16975 | 280 | set_register_interruptible(ab8500, AB8500_INTERRUPT, reg, new); |
62579266 RV |
281 | } |
282 | ||
283 | mutex_unlock(&ab8500->irq_lock); | |
284 | } | |
285 | ||
9505a0a0 | 286 | static void ab8500_irq_mask(struct irq_data *data) |
62579266 | 287 | { |
9505a0a0 MB |
288 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
289 | int offset = data->irq - ab8500->irq_base; | |
62579266 RV |
290 | int index = offset / 8; |
291 | int mask = 1 << (offset % 8); | |
292 | ||
293 | ab8500->mask[index] |= mask; | |
294 | } | |
295 | ||
9505a0a0 | 296 | static void ab8500_irq_unmask(struct irq_data *data) |
62579266 | 297 | { |
9505a0a0 MB |
298 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
299 | int offset = data->irq - ab8500->irq_base; | |
62579266 RV |
300 | int index = offset / 8; |
301 | int mask = 1 << (offset % 8); | |
302 | ||
303 | ab8500->mask[index] &= ~mask; | |
304 | } | |
305 | ||
306 | static struct irq_chip ab8500_irq_chip = { | |
307 | .name = "ab8500", | |
9505a0a0 MB |
308 | .irq_bus_lock = ab8500_irq_lock, |
309 | .irq_bus_sync_unlock = ab8500_irq_sync_unlock, | |
310 | .irq_mask = ab8500_irq_mask, | |
e6f9306e | 311 | .irq_disable = ab8500_irq_mask, |
9505a0a0 | 312 | .irq_unmask = ab8500_irq_unmask, |
62579266 RV |
313 | }; |
314 | ||
315 | static irqreturn_t ab8500_irq(int irq, void *dev) | |
316 | { | |
317 | struct ab8500 *ab8500 = dev; | |
318 | int i; | |
319 | ||
320 | dev_vdbg(ab8500->dev, "interrupt\n"); | |
321 | ||
2ced445e LW |
322 | for (i = 0; i < ab8500->mask_size; i++) { |
323 | int regoffset = ab8500->irq_reg_offset[i]; | |
62579266 | 324 | int status; |
47c16975 | 325 | u8 value; |
62579266 | 326 | |
0f620837 LW |
327 | /* |
328 | * Interrupt register 12 doesn't exist prior to AB8500 version | |
329 | * 2.0 | |
330 | */ | |
331 | if (regoffset == 11 && is_ab8500_1p1_or_earlier(ab8500)) | |
92d50a41 MW |
332 | continue; |
333 | ||
47c16975 MW |
334 | status = get_register_interruptible(ab8500, AB8500_INTERRUPT, |
335 | AB8500_IT_LATCH1_REG + regoffset, &value); | |
336 | if (status < 0 || value == 0) | |
62579266 RV |
337 | continue; |
338 | ||
339 | do { | |
88aec4f7 | 340 | int bit = __ffs(value); |
62579266 RV |
341 | int line = i * 8 + bit; |
342 | ||
343 | handle_nested_irq(ab8500->irq_base + line); | |
47c16975 MW |
344 | value &= ~(1 << bit); |
345 | } while (value); | |
62579266 RV |
346 | } |
347 | ||
348 | return IRQ_HANDLED; | |
349 | } | |
350 | ||
351 | static int ab8500_irq_init(struct ab8500 *ab8500) | |
352 | { | |
353 | int base = ab8500->irq_base; | |
354 | int irq; | |
2ced445e | 355 | int num_irqs; |
62579266 | 356 | |
2ced445e LW |
357 | num_irqs = AB8500_NR_IRQS; |
358 | ||
359 | for (irq = base; irq < base + num_irqs; irq++) { | |
d5bb1221 TG |
360 | irq_set_chip_data(irq, ab8500); |
361 | irq_set_chip_and_handler(irq, &ab8500_irq_chip, | |
62579266 | 362 | handle_simple_irq); |
d5bb1221 | 363 | irq_set_nested_thread(irq, 1); |
62579266 RV |
364 | #ifdef CONFIG_ARM |
365 | set_irq_flags(irq, IRQF_VALID); | |
366 | #else | |
d5bb1221 | 367 | irq_set_noprobe(irq); |
62579266 RV |
368 | #endif |
369 | } | |
370 | ||
371 | return 0; | |
372 | } | |
373 | ||
374 | static void ab8500_irq_remove(struct ab8500 *ab8500) | |
375 | { | |
376 | int base = ab8500->irq_base; | |
377 | int irq; | |
2ced445e LW |
378 | int num_irqs; |
379 | ||
380 | num_irqs = AB8500_NR_IRQS; | |
62579266 | 381 | |
2ced445e | 382 | for (irq = base; irq < base + num_irqs; irq++) { |
62579266 RV |
383 | #ifdef CONFIG_ARM |
384 | set_irq_flags(irq, 0); | |
385 | #endif | |
d5bb1221 TG |
386 | irq_set_chip_and_handler(irq, NULL, NULL); |
387 | irq_set_chip_data(irq, NULL); | |
62579266 RV |
388 | } |
389 | } | |
390 | ||
5cef8df5 | 391 | static struct resource __devinitdata ab8500_gpio_resources[] = { |
0cb3fcd7 BB |
392 | { |
393 | .name = "GPIO_INT6", | |
394 | .start = AB8500_INT_GPIO6R, | |
395 | .end = AB8500_INT_GPIO41F, | |
396 | .flags = IORESOURCE_IRQ, | |
397 | } | |
398 | }; | |
399 | ||
5cef8df5 | 400 | static struct resource __devinitdata ab8500_gpadc_resources[] = { |
62579266 RV |
401 | { |
402 | .name = "HW_CONV_END", | |
403 | .start = AB8500_INT_GP_HW_ADC_CONV_END, | |
404 | .end = AB8500_INT_GP_HW_ADC_CONV_END, | |
405 | .flags = IORESOURCE_IRQ, | |
406 | }, | |
407 | { | |
408 | .name = "SW_CONV_END", | |
409 | .start = AB8500_INT_GP_SW_ADC_CONV_END, | |
410 | .end = AB8500_INT_GP_SW_ADC_CONV_END, | |
411 | .flags = IORESOURCE_IRQ, | |
412 | }, | |
413 | }; | |
414 | ||
5cef8df5 | 415 | static struct resource __devinitdata ab8500_rtc_resources[] = { |
62579266 RV |
416 | { |
417 | .name = "60S", | |
418 | .start = AB8500_INT_RTC_60S, | |
419 | .end = AB8500_INT_RTC_60S, | |
420 | .flags = IORESOURCE_IRQ, | |
421 | }, | |
422 | { | |
423 | .name = "ALARM", | |
424 | .start = AB8500_INT_RTC_ALARM, | |
425 | .end = AB8500_INT_RTC_ALARM, | |
426 | .flags = IORESOURCE_IRQ, | |
427 | }, | |
428 | }; | |
429 | ||
5cef8df5 | 430 | static struct resource __devinitdata ab8500_poweronkey_db_resources[] = { |
77686517 SI |
431 | { |
432 | .name = "ONKEY_DBF", | |
433 | .start = AB8500_INT_PON_KEY1DB_F, | |
434 | .end = AB8500_INT_PON_KEY1DB_F, | |
435 | .flags = IORESOURCE_IRQ, | |
436 | }, | |
437 | { | |
438 | .name = "ONKEY_DBR", | |
439 | .start = AB8500_INT_PON_KEY1DB_R, | |
440 | .end = AB8500_INT_PON_KEY1DB_R, | |
441 | .flags = IORESOURCE_IRQ, | |
442 | }, | |
443 | }; | |
444 | ||
6af75ecd | 445 | static struct resource __devinitdata ab8500_av_acc_detect_resources[] = { |
e098aded | 446 | { |
6af75ecd LW |
447 | .name = "ACC_DETECT_1DB_F", |
448 | .start = AB8500_INT_ACC_DETECT_1DB_F, | |
449 | .end = AB8500_INT_ACC_DETECT_1DB_F, | |
450 | .flags = IORESOURCE_IRQ, | |
e098aded MW |
451 | }, |
452 | { | |
6af75ecd LW |
453 | .name = "ACC_DETECT_1DB_R", |
454 | .start = AB8500_INT_ACC_DETECT_1DB_R, | |
455 | .end = AB8500_INT_ACC_DETECT_1DB_R, | |
456 | .flags = IORESOURCE_IRQ, | |
457 | }, | |
458 | { | |
459 | .name = "ACC_DETECT_21DB_F", | |
460 | .start = AB8500_INT_ACC_DETECT_21DB_F, | |
461 | .end = AB8500_INT_ACC_DETECT_21DB_F, | |
462 | .flags = IORESOURCE_IRQ, | |
463 | }, | |
464 | { | |
465 | .name = "ACC_DETECT_21DB_R", | |
466 | .start = AB8500_INT_ACC_DETECT_21DB_R, | |
467 | .end = AB8500_INT_ACC_DETECT_21DB_R, | |
468 | .flags = IORESOURCE_IRQ, | |
469 | }, | |
470 | { | |
471 | .name = "ACC_DETECT_22DB_F", | |
472 | .start = AB8500_INT_ACC_DETECT_22DB_F, | |
473 | .end = AB8500_INT_ACC_DETECT_22DB_F, | |
474 | .flags = IORESOURCE_IRQ, | |
e098aded | 475 | }, |
6af75ecd LW |
476 | { |
477 | .name = "ACC_DETECT_22DB_R", | |
478 | .start = AB8500_INT_ACC_DETECT_22DB_R, | |
479 | .end = AB8500_INT_ACC_DETECT_22DB_R, | |
480 | .flags = IORESOURCE_IRQ, | |
481 | }, | |
482 | }; | |
483 | ||
484 | static struct resource __devinitdata ab8500_charger_resources[] = { | |
e098aded MW |
485 | { |
486 | .name = "MAIN_CH_UNPLUG_DET", | |
487 | .start = AB8500_INT_MAIN_CH_UNPLUG_DET, | |
488 | .end = AB8500_INT_MAIN_CH_UNPLUG_DET, | |
489 | .flags = IORESOURCE_IRQ, | |
490 | }, | |
491 | { | |
492 | .name = "MAIN_CHARGE_PLUG_DET", | |
493 | .start = AB8500_INT_MAIN_CH_PLUG_DET, | |
494 | .end = AB8500_INT_MAIN_CH_PLUG_DET, | |
495 | .flags = IORESOURCE_IRQ, | |
496 | }, | |
e098aded MW |
497 | { |
498 | .name = "VBUS_DET_R", | |
499 | .start = AB8500_INT_VBUS_DET_R, | |
500 | .end = AB8500_INT_VBUS_DET_R, | |
501 | .flags = IORESOURCE_IRQ, | |
502 | }, | |
503 | { | |
6af75ecd LW |
504 | .name = "VBUS_DET_F", |
505 | .start = AB8500_INT_VBUS_DET_F, | |
506 | .end = AB8500_INT_VBUS_DET_F, | |
e098aded MW |
507 | .flags = IORESOURCE_IRQ, |
508 | }, | |
509 | { | |
6af75ecd LW |
510 | .name = "USB_LINK_STATUS", |
511 | .start = AB8500_INT_USB_LINK_STATUS, | |
512 | .end = AB8500_INT_USB_LINK_STATUS, | |
513 | .flags = IORESOURCE_IRQ, | |
514 | }, | |
515 | { | |
516 | .name = "USB_CHARGE_DET_DONE", | |
517 | .start = AB8500_INT_USB_CHG_DET_DONE, | |
518 | .end = AB8500_INT_USB_CHG_DET_DONE, | |
e098aded MW |
519 | .flags = IORESOURCE_IRQ, |
520 | }, | |
521 | { | |
522 | .name = "VBUS_OVV", | |
523 | .start = AB8500_INT_VBUS_OVV, | |
524 | .end = AB8500_INT_VBUS_OVV, | |
525 | .flags = IORESOURCE_IRQ, | |
526 | }, | |
527 | { | |
6af75ecd LW |
528 | .name = "USB_CH_TH_PROT_R", |
529 | .start = AB8500_INT_USB_CH_TH_PROT_R, | |
530 | .end = AB8500_INT_USB_CH_TH_PROT_R, | |
e098aded MW |
531 | .flags = IORESOURCE_IRQ, |
532 | }, | |
533 | { | |
6af75ecd LW |
534 | .name = "USB_CH_TH_PROT_F", |
535 | .start = AB8500_INT_USB_CH_TH_PROT_F, | |
536 | .end = AB8500_INT_USB_CH_TH_PROT_F, | |
e098aded MW |
537 | .flags = IORESOURCE_IRQ, |
538 | }, | |
539 | { | |
6af75ecd LW |
540 | .name = "MAIN_EXT_CH_NOT_OK", |
541 | .start = AB8500_INT_MAIN_EXT_CH_NOT_OK, | |
542 | .end = AB8500_INT_MAIN_EXT_CH_NOT_OK, | |
543 | .flags = IORESOURCE_IRQ, | |
544 | }, | |
545 | { | |
546 | .name = "MAIN_CH_TH_PROT_R", | |
547 | .start = AB8500_INT_MAIN_CH_TH_PROT_R, | |
548 | .end = AB8500_INT_MAIN_CH_TH_PROT_R, | |
549 | .flags = IORESOURCE_IRQ, | |
550 | }, | |
551 | { | |
552 | .name = "MAIN_CH_TH_PROT_F", | |
553 | .start = AB8500_INT_MAIN_CH_TH_PROT_F, | |
554 | .end = AB8500_INT_MAIN_CH_TH_PROT_F, | |
555 | .flags = IORESOURCE_IRQ, | |
556 | }, | |
557 | { | |
558 | .name = "USB_CHARGER_NOT_OKR", | |
559 | .start = AB8500_INT_USB_CHARGER_NOT_OK, | |
560 | .end = AB8500_INT_USB_CHARGER_NOT_OK, | |
561 | .flags = IORESOURCE_IRQ, | |
562 | }, | |
563 | { | |
564 | .name = "USB_CHARGER_NOT_OKF", | |
565 | .start = AB8500_INT_USB_CHARGER_NOT_OKF, | |
566 | .end = AB8500_INT_USB_CHARGER_NOT_OKF, | |
567 | .flags = IORESOURCE_IRQ, | |
568 | }, | |
569 | { | |
570 | .name = "CH_WD_EXP", | |
571 | .start = AB8500_INT_CH_WD_EXP, | |
572 | .end = AB8500_INT_CH_WD_EXP, | |
573 | .flags = IORESOURCE_IRQ, | |
574 | }, | |
575 | }; | |
576 | ||
577 | static struct resource __devinitdata ab8500_btemp_resources[] = { | |
578 | { | |
579 | .name = "BAT_CTRL_INDB", | |
580 | .start = AB8500_INT_BAT_CTRL_INDB, | |
581 | .end = AB8500_INT_BAT_CTRL_INDB, | |
e098aded MW |
582 | .flags = IORESOURCE_IRQ, |
583 | }, | |
584 | { | |
585 | .name = "BTEMP_LOW", | |
586 | .start = AB8500_INT_BTEMP_LOW, | |
587 | .end = AB8500_INT_BTEMP_LOW, | |
588 | .flags = IORESOURCE_IRQ, | |
589 | }, | |
590 | { | |
591 | .name = "BTEMP_HIGH", | |
592 | .start = AB8500_INT_BTEMP_HIGH, | |
593 | .end = AB8500_INT_BTEMP_HIGH, | |
594 | .flags = IORESOURCE_IRQ, | |
595 | }, | |
596 | { | |
6af75ecd LW |
597 | .name = "BTEMP_LOW_MEDIUM", |
598 | .start = AB8500_INT_BTEMP_LOW_MEDIUM, | |
599 | .end = AB8500_INT_BTEMP_LOW_MEDIUM, | |
e098aded MW |
600 | .flags = IORESOURCE_IRQ, |
601 | }, | |
602 | { | |
6af75ecd LW |
603 | .name = "BTEMP_MEDIUM_HIGH", |
604 | .start = AB8500_INT_BTEMP_MEDIUM_HIGH, | |
605 | .end = AB8500_INT_BTEMP_MEDIUM_HIGH, | |
e098aded MW |
606 | .flags = IORESOURCE_IRQ, |
607 | }, | |
6af75ecd LW |
608 | }; |
609 | ||
610 | static struct resource __devinitdata ab8500_fg_resources[] = { | |
e098aded | 611 | { |
6af75ecd LW |
612 | .name = "NCONV_ACCU", |
613 | .start = AB8500_INT_CCN_CONV_ACC, | |
614 | .end = AB8500_INT_CCN_CONV_ACC, | |
e098aded MW |
615 | .flags = IORESOURCE_IRQ, |
616 | }, | |
617 | { | |
6af75ecd LW |
618 | .name = "BATT_OVV", |
619 | .start = AB8500_INT_BATT_OVV, | |
620 | .end = AB8500_INT_BATT_OVV, | |
e098aded MW |
621 | .flags = IORESOURCE_IRQ, |
622 | }, | |
623 | { | |
6af75ecd LW |
624 | .name = "LOW_BAT_F", |
625 | .start = AB8500_INT_LOW_BAT_F, | |
626 | .end = AB8500_INT_LOW_BAT_F, | |
627 | .flags = IORESOURCE_IRQ, | |
628 | }, | |
629 | { | |
630 | .name = "LOW_BAT_R", | |
631 | .start = AB8500_INT_LOW_BAT_R, | |
632 | .end = AB8500_INT_LOW_BAT_R, | |
633 | .flags = IORESOURCE_IRQ, | |
634 | }, | |
635 | { | |
636 | .name = "CC_INT_CALIB", | |
637 | .start = AB8500_INT_CC_INT_CALIB, | |
638 | .end = AB8500_INT_CC_INT_CALIB, | |
e098aded MW |
639 | .flags = IORESOURCE_IRQ, |
640 | }, | |
641 | }; | |
642 | ||
6af75ecd LW |
643 | static struct resource __devinitdata ab8500_chargalg_resources[] = {}; |
644 | ||
df720647 | 645 | #ifdef CONFIG_DEBUG_FS |
5cef8df5 | 646 | static struct resource __devinitdata ab8500_debug_resources[] = { |
e098aded MW |
647 | { |
648 | .name = "IRQ_FIRST", | |
649 | .start = AB8500_INT_MAIN_EXT_CH_NOT_OK, | |
650 | .end = AB8500_INT_MAIN_EXT_CH_NOT_OK, | |
651 | .flags = IORESOURCE_IRQ, | |
652 | }, | |
653 | { | |
654 | .name = "IRQ_LAST", | |
655 | .start = AB8500_INT_USB_CHARGER_NOT_OKF, | |
656 | .end = AB8500_INT_USB_CHARGER_NOT_OKF, | |
657 | .flags = IORESOURCE_IRQ, | |
658 | }, | |
659 | }; | |
df720647 | 660 | #endif |
e098aded | 661 | |
5cef8df5 | 662 | static struct resource __devinitdata ab8500_usb_resources[] = { |
e098aded MW |
663 | { |
664 | .name = "ID_WAKEUP_R", | |
665 | .start = AB8500_INT_ID_WAKEUP_R, | |
666 | .end = AB8500_INT_ID_WAKEUP_R, | |
667 | .flags = IORESOURCE_IRQ, | |
668 | }, | |
669 | { | |
670 | .name = "ID_WAKEUP_F", | |
671 | .start = AB8500_INT_ID_WAKEUP_F, | |
672 | .end = AB8500_INT_ID_WAKEUP_F, | |
673 | .flags = IORESOURCE_IRQ, | |
674 | }, | |
675 | { | |
676 | .name = "VBUS_DET_F", | |
677 | .start = AB8500_INT_VBUS_DET_F, | |
678 | .end = AB8500_INT_VBUS_DET_F, | |
679 | .flags = IORESOURCE_IRQ, | |
680 | }, | |
681 | { | |
682 | .name = "VBUS_DET_R", | |
683 | .start = AB8500_INT_VBUS_DET_R, | |
684 | .end = AB8500_INT_VBUS_DET_R, | |
685 | .flags = IORESOURCE_IRQ, | |
686 | }, | |
92d50a41 MW |
687 | { |
688 | .name = "USB_LINK_STATUS", | |
689 | .start = AB8500_INT_USB_LINK_STATUS, | |
690 | .end = AB8500_INT_USB_LINK_STATUS, | |
691 | .flags = IORESOURCE_IRQ, | |
692 | }, | |
6af75ecd LW |
693 | { |
694 | .name = "USB_ADP_PROBE_PLUG", | |
695 | .start = AB8500_INT_ADP_PROBE_PLUG, | |
696 | .end = AB8500_INT_ADP_PROBE_PLUG, | |
697 | .flags = IORESOURCE_IRQ, | |
698 | }, | |
699 | { | |
700 | .name = "USB_ADP_PROBE_UNPLUG", | |
701 | .start = AB8500_INT_ADP_PROBE_UNPLUG, | |
702 | .end = AB8500_INT_ADP_PROBE_UNPLUG, | |
703 | .flags = IORESOURCE_IRQ, | |
704 | }, | |
e098aded MW |
705 | }; |
706 | ||
5cef8df5 | 707 | static struct resource __devinitdata ab8500_temp_resources[] = { |
e098aded MW |
708 | { |
709 | .name = "AB8500_TEMP_WARM", | |
710 | .start = AB8500_INT_TEMP_WARM, | |
711 | .end = AB8500_INT_TEMP_WARM, | |
712 | .flags = IORESOURCE_IRQ, | |
713 | }, | |
714 | }; | |
715 | ||
5cef8df5 | 716 | static struct mfd_cell __devinitdata ab8500_devs[] = { |
5814fc35 MW |
717 | #ifdef CONFIG_DEBUG_FS |
718 | { | |
719 | .name = "ab8500-debug", | |
e098aded MW |
720 | .num_resources = ARRAY_SIZE(ab8500_debug_resources), |
721 | .resources = ab8500_debug_resources, | |
5814fc35 MW |
722 | }, |
723 | #endif | |
e098aded MW |
724 | { |
725 | .name = "ab8500-sysctrl", | |
726 | }, | |
727 | { | |
728 | .name = "ab8500-regulator", | |
729 | }, | |
0cb3fcd7 BB |
730 | { |
731 | .name = "ab8500-gpio", | |
732 | .num_resources = ARRAY_SIZE(ab8500_gpio_resources), | |
733 | .resources = ab8500_gpio_resources, | |
734 | }, | |
62579266 RV |
735 | { |
736 | .name = "ab8500-gpadc", | |
737 | .num_resources = ARRAY_SIZE(ab8500_gpadc_resources), | |
738 | .resources = ab8500_gpadc_resources, | |
739 | }, | |
740 | { | |
741 | .name = "ab8500-rtc", | |
742 | .num_resources = ARRAY_SIZE(ab8500_rtc_resources), | |
743 | .resources = ab8500_rtc_resources, | |
744 | }, | |
e098aded | 745 | { |
6af75ecd LW |
746 | .name = "ab8500-charger", |
747 | .num_resources = ARRAY_SIZE(ab8500_charger_resources), | |
748 | .resources = ab8500_charger_resources, | |
749 | }, | |
750 | { | |
751 | .name = "ab8500-btemp", | |
752 | .num_resources = ARRAY_SIZE(ab8500_btemp_resources), | |
753 | .resources = ab8500_btemp_resources, | |
754 | }, | |
755 | { | |
756 | .name = "ab8500-fg", | |
757 | .num_resources = ARRAY_SIZE(ab8500_fg_resources), | |
758 | .resources = ab8500_fg_resources, | |
759 | }, | |
760 | { | |
761 | .name = "ab8500-chargalg", | |
762 | .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), | |
763 | .resources = ab8500_chargalg_resources, | |
764 | }, | |
765 | { | |
766 | .name = "ab8500-acc-det", | |
767 | .num_resources = ARRAY_SIZE(ab8500_av_acc_detect_resources), | |
768 | .resources = ab8500_av_acc_detect_resources, | |
769 | }, | |
770 | { | |
771 | .name = "ab8500-codec", | |
e098aded | 772 | }, |
e098aded MW |
773 | { |
774 | .name = "ab8500-usb", | |
775 | .num_resources = ARRAY_SIZE(ab8500_usb_resources), | |
776 | .resources = ab8500_usb_resources, | |
777 | }, | |
778 | { | |
779 | .name = "ab8500-poweron-key", | |
780 | .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources), | |
781 | .resources = ab8500_poweronkey_db_resources, | |
782 | }, | |
f0f05b1c AM |
783 | { |
784 | .name = "ab8500-pwm", | |
785 | .id = 1, | |
786 | }, | |
787 | { | |
788 | .name = "ab8500-pwm", | |
789 | .id = 2, | |
790 | }, | |
791 | { | |
792 | .name = "ab8500-pwm", | |
793 | .id = 3, | |
794 | }, | |
e098aded | 795 | { .name = "ab8500-leds", }, |
77686517 | 796 | { |
e098aded MW |
797 | .name = "ab8500-denc", |
798 | }, | |
799 | { | |
800 | .name = "ab8500-temp", | |
801 | .num_resources = ARRAY_SIZE(ab8500_temp_resources), | |
802 | .resources = ab8500_temp_resources, | |
77686517 | 803 | }, |
62579266 RV |
804 | }; |
805 | ||
cca69b67 MW |
806 | static ssize_t show_chip_id(struct device *dev, |
807 | struct device_attribute *attr, char *buf) | |
808 | { | |
809 | struct ab8500 *ab8500; | |
810 | ||
811 | ab8500 = dev_get_drvdata(dev); | |
812 | return sprintf(buf, "%#x\n", ab8500 ? ab8500->chip_id : -EINVAL); | |
813 | } | |
814 | ||
e5c238c3 MW |
815 | /* |
816 | * ab8500 has switched off due to (SWITCH_OFF_STATUS): | |
817 | * 0x01 Swoff bit programming | |
818 | * 0x02 Thermal protection activation | |
819 | * 0x04 Vbat lower then BattOk falling threshold | |
820 | * 0x08 Watchdog expired | |
821 | * 0x10 Non presence of 32kHz clock | |
822 | * 0x20 Battery level lower than power on reset threshold | |
823 | * 0x40 Power on key 1 pressed longer than 10 seconds | |
824 | * 0x80 DB8500 thermal shutdown | |
825 | */ | |
826 | static ssize_t show_switch_off_status(struct device *dev, | |
827 | struct device_attribute *attr, char *buf) | |
828 | { | |
829 | int ret; | |
830 | u8 value; | |
831 | struct ab8500 *ab8500; | |
832 | ||
833 | ab8500 = dev_get_drvdata(dev); | |
834 | ret = get_register_interruptible(ab8500, AB8500_RTC, | |
835 | AB8500_SWITCH_OFF_STATUS, &value); | |
836 | if (ret < 0) | |
837 | return ret; | |
838 | return sprintf(buf, "%#x\n", value); | |
839 | } | |
840 | ||
b4a31037 AL |
841 | /* |
842 | * ab8500 has turned on due to (TURN_ON_STATUS): | |
843 | * 0x01 PORnVbat | |
844 | * 0x02 PonKey1dbF | |
845 | * 0x04 PonKey2dbF | |
846 | * 0x08 RTCAlarm | |
847 | * 0x10 MainChDet | |
848 | * 0x20 VbusDet | |
849 | * 0x40 UsbIDDetect | |
850 | * 0x80 Reserved | |
851 | */ | |
852 | static ssize_t show_turn_on_status(struct device *dev, | |
853 | struct device_attribute *attr, char *buf) | |
854 | { | |
855 | int ret; | |
856 | u8 value; | |
857 | struct ab8500 *ab8500; | |
858 | ||
859 | ab8500 = dev_get_drvdata(dev); | |
860 | ret = get_register_interruptible(ab8500, AB8500_SYS_CTRL1_BLOCK, | |
861 | AB8500_TURN_ON_STATUS, &value); | |
862 | if (ret < 0) | |
863 | return ret; | |
864 | return sprintf(buf, "%#x\n", value); | |
865 | } | |
866 | ||
cca69b67 | 867 | static DEVICE_ATTR(chip_id, S_IRUGO, show_chip_id, NULL); |
e5c238c3 | 868 | static DEVICE_ATTR(switch_off_status, S_IRUGO, show_switch_off_status, NULL); |
b4a31037 | 869 | static DEVICE_ATTR(turn_on_status, S_IRUGO, show_turn_on_status, NULL); |
cca69b67 MW |
870 | |
871 | static struct attribute *ab8500_sysfs_entries[] = { | |
872 | &dev_attr_chip_id.attr, | |
e5c238c3 | 873 | &dev_attr_switch_off_status.attr, |
b4a31037 | 874 | &dev_attr_turn_on_status.attr, |
cca69b67 MW |
875 | NULL, |
876 | }; | |
877 | ||
878 | static struct attribute_group ab8500_attr_group = { | |
879 | .attrs = ab8500_sysfs_entries, | |
880 | }; | |
881 | ||
0f620837 | 882 | int __devinit ab8500_init(struct ab8500 *ab8500, enum ab8500_version version) |
62579266 RV |
883 | { |
884 | struct ab8500_platform_data *plat = dev_get_platdata(ab8500->dev); | |
885 | int ret; | |
886 | int i; | |
47c16975 | 887 | u8 value; |
62579266 RV |
888 | |
889 | if (plat) | |
890 | ab8500->irq_base = plat->irq_base; | |
891 | ||
892 | mutex_init(&ab8500->lock); | |
893 | mutex_init(&ab8500->irq_lock); | |
894 | ||
0f620837 LW |
895 | if (version != AB8500_VERSION_UNDEFINED) |
896 | ab8500->version = version; | |
897 | else { | |
898 | ret = get_register_interruptible(ab8500, AB8500_MISC, | |
899 | AB8500_IC_NAME_REG, &value); | |
900 | if (ret < 0) | |
901 | return ret; | |
902 | ||
903 | ab8500->version = value; | |
904 | } | |
905 | ||
47c16975 MW |
906 | ret = get_register_interruptible(ab8500, AB8500_MISC, |
907 | AB8500_REV_REG, &value); | |
62579266 RV |
908 | if (ret < 0) |
909 | return ret; | |
910 | ||
47c16975 | 911 | ab8500->chip_id = value; |
62579266 | 912 | |
0f620837 LW |
913 | dev_info(ab8500->dev, "detected chip, %s rev. %1x.%1x\n", |
914 | ab8500_version_str[ab8500->version], | |
915 | ab8500->chip_id >> 4, | |
916 | ab8500->chip_id & 0x0F); | |
917 | ||
2ced445e LW |
918 | ab8500->mask_size = AB8500_NUM_IRQ_REGS; |
919 | ab8500->irq_reg_offset = ab8500_irq_regoffset; | |
920 | ab8500->mask = kzalloc(ab8500->mask_size, GFP_KERNEL); | |
921 | if (!ab8500->mask) | |
922 | return -ENOMEM; | |
923 | ab8500->oldmask = kzalloc(ab8500->mask_size, GFP_KERNEL); | |
924 | if (!ab8500->oldmask) { | |
925 | ret = -ENOMEM; | |
926 | goto out_freemask; | |
927 | } | |
e5c238c3 MW |
928 | /* |
929 | * ab8500 has switched off due to (SWITCH_OFF_STATUS): | |
930 | * 0x01 Swoff bit programming | |
931 | * 0x02 Thermal protection activation | |
932 | * 0x04 Vbat lower then BattOk falling threshold | |
933 | * 0x08 Watchdog expired | |
934 | * 0x10 Non presence of 32kHz clock | |
935 | * 0x20 Battery level lower than power on reset threshold | |
936 | * 0x40 Power on key 1 pressed longer than 10 seconds | |
937 | * 0x80 DB8500 thermal shutdown | |
938 | */ | |
939 | ||
940 | ret = get_register_interruptible(ab8500, AB8500_RTC, | |
941 | AB8500_SWITCH_OFF_STATUS, &value); | |
942 | if (ret < 0) | |
943 | return ret; | |
944 | dev_info(ab8500->dev, "switch off status: %#x", value); | |
945 | ||
62579266 RV |
946 | if (plat && plat->init) |
947 | plat->init(ab8500); | |
948 | ||
949 | /* Clear and mask all interrupts */ | |
2ced445e | 950 | for (i = 0; i < ab8500->mask_size; i++) { |
0f620837 LW |
951 | /* |
952 | * Interrupt register 12 doesn't exist prior to AB8500 version | |
953 | * 2.0 | |
954 | */ | |
955 | if (ab8500->irq_reg_offset[i] == 11 && | |
956 | is_ab8500_1p1_or_earlier(ab8500)) | |
92d50a41 | 957 | continue; |
62579266 | 958 | |
47c16975 | 959 | get_register_interruptible(ab8500, AB8500_INTERRUPT, |
2ced445e | 960 | AB8500_IT_LATCH1_REG + ab8500->irq_reg_offset[i], |
92d50a41 | 961 | &value); |
47c16975 | 962 | set_register_interruptible(ab8500, AB8500_INTERRUPT, |
2ced445e | 963 | AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i], 0xff); |
62579266 RV |
964 | } |
965 | ||
47c16975 MW |
966 | ret = abx500_register_ops(ab8500->dev, &ab8500_ops); |
967 | if (ret) | |
2ced445e | 968 | goto out_freeoldmask; |
47c16975 | 969 | |
2ced445e | 970 | for (i = 0; i < ab8500->mask_size; i++) |
62579266 RV |
971 | ab8500->mask[i] = ab8500->oldmask[i] = 0xff; |
972 | ||
973 | if (ab8500->irq_base) { | |
974 | ret = ab8500_irq_init(ab8500); | |
975 | if (ret) | |
2ced445e | 976 | goto out_freeoldmask; |
62579266 RV |
977 | |
978 | ret = request_threaded_irq(ab8500->irq, NULL, ab8500_irq, | |
4f079985 MW |
979 | IRQF_ONESHOT | IRQF_NO_SUSPEND, |
980 | "ab8500", ab8500); | |
62579266 RV |
981 | if (ret) |
982 | goto out_removeirq; | |
983 | } | |
984 | ||
549931f9 | 985 | ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, |
62579266 RV |
986 | ARRAY_SIZE(ab8500_devs), NULL, |
987 | ab8500->irq_base); | |
988 | if (ret) | |
989 | goto out_freeirq; | |
990 | ||
cca69b67 MW |
991 | ret = sysfs_create_group(&ab8500->dev->kobj, &ab8500_attr_group); |
992 | if (ret) | |
993 | dev_err(ab8500->dev, "error creating sysfs entries\n"); | |
994 | ||
62579266 RV |
995 | return ret; |
996 | ||
997 | out_freeirq: | |
6d95b7fd | 998 | if (ab8500->irq_base) |
62579266 RV |
999 | free_irq(ab8500->irq, ab8500); |
1000 | out_removeirq: | |
6d95b7fd | 1001 | if (ab8500->irq_base) |
62579266 | 1002 | ab8500_irq_remove(ab8500); |
2ced445e LW |
1003 | out_freeoldmask: |
1004 | kfree(ab8500->oldmask); | |
1005 | out_freemask: | |
1006 | kfree(ab8500->mask); | |
6d95b7fd | 1007 | |
62579266 RV |
1008 | return ret; |
1009 | } | |
1010 | ||
1011 | int __devexit ab8500_exit(struct ab8500 *ab8500) | |
1012 | { | |
cca69b67 | 1013 | sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group); |
62579266 RV |
1014 | mfd_remove_devices(ab8500->dev); |
1015 | if (ab8500->irq_base) { | |
1016 | free_irq(ab8500->irq, ab8500); | |
1017 | ab8500_irq_remove(ab8500); | |
1018 | } | |
2ced445e LW |
1019 | kfree(ab8500->oldmask); |
1020 | kfree(ab8500->mask); | |
62579266 RV |
1021 | |
1022 | return 0; | |
1023 | } | |
1024 | ||
adceed62 | 1025 | MODULE_AUTHOR("Mattias Wallin, Srinidhi Kasagar, Rabin Vincent"); |
62579266 RV |
1026 | MODULE_DESCRIPTION("AB8500 MFD core"); |
1027 | MODULE_LICENSE("GPL v2"); |