Commit | Line | Data |
---|---|---|
5814fc35 MW |
1 | /* |
2 | * Copyright (C) ST-Ericsson SA 2010 | |
3 | * | |
4 | * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson. | |
5 | * License Terms: GNU General Public License v2 | |
6 | */ | |
0fbce76e | 7 | /* |
8 | * AB8500 register access | |
9 | * ====================== | |
10 | * | |
11 | * read: | |
12 | * # echo BANK > <debugfs>/ab8500/register-bank | |
13 | * # echo ADDR > <debugfs>/ab8500/register-address | |
14 | * # cat <debugfs>/ab8500/register-value | |
15 | * | |
16 | * write: | |
17 | * # echo BANK > <debugfs>/ab8500/register-bank | |
18 | * # echo ADDR > <debugfs>/ab8500/register-address | |
19 | * # echo VALUE > <debugfs>/ab8500/register-value | |
20 | * | |
21 | * read all registers from a bank: | |
22 | * # echo BANK > <debugfs>/ab8500/register-bank | |
23 | * # cat <debugfs>/ab8500/all-bank-register | |
24 | * | |
25 | * BANK target AB8500 register bank | |
26 | * ADDR target AB8500 register address | |
27 | * VALUE decimal or 0x-prefixed hexadecimal | |
28 | * | |
29 | * | |
30 | * User Space notification on AB8500 IRQ | |
31 | * ===================================== | |
32 | * | |
33 | * Allows user space entity to be notified when target AB8500 IRQ occurs. | |
34 | * When subscribed, a sysfs entry is created in ab8500.i2c platform device. | |
35 | * One can pool this file to get target IRQ occurence information. | |
36 | * | |
37 | * subscribe to an AB8500 IRQ: | |
38 | * # echo IRQ > <debugfs>/ab8500/irq-subscribe | |
39 | * | |
40 | * unsubscribe from an AB8500 IRQ: | |
41 | * # echo IRQ > <debugfs>/ab8500/irq-unsubscribe | |
42 | * | |
43 | * | |
44 | * AB8500 register formated read/write access | |
45 | * ========================================== | |
46 | * | |
47 | * Read: read data, data>>SHIFT, data&=MASK, output data | |
48 | * [0xABCDEF98] shift=12 mask=0xFFF => 0x00000CDE | |
49 | * Write: read data, data &= ~(MASK<<SHIFT), data |= (VALUE<<SHIFT), write data | |
50 | * [0xABCDEF98] shift=12 mask=0xFFF value=0x123 => [0xAB123F98] | |
51 | * | |
52 | * Usage: | |
53 | * # echo "CMD [OPTIONS] BANK ADRESS [VALUE]" > $debugfs/ab8500/hwreg | |
54 | * | |
55 | * CMD read read access | |
56 | * write write access | |
57 | * | |
58 | * BANK target reg bank | |
59 | * ADDRESS target reg address | |
60 | * VALUE (write) value to be updated | |
61 | * | |
62 | * OPTIONS | |
63 | * -d|-dec (read) output in decimal | |
64 | * -h|-hexa (read) output in 0x-hexa (default) | |
65 | * -l|-w|-b 32bit (default), 16bit or 8bit reg access | |
66 | * -m|-mask MASK 0x-hexa mask (default 0xFFFFFFFF) | |
67 | * -s|-shift SHIFT bit shift value (read:left, write:right) | |
68 | * -o|-offset OFFSET address offset to add to ADDRESS value | |
69 | * | |
70 | * Warning: bit shift operation is applied to bit-mask. | |
71 | * Warning: bit shift direction depends on read or right command. | |
72 | */ | |
5814fc35 MW |
73 | |
74 | #include <linux/seq_file.h> | |
75 | #include <linux/uaccess.h> | |
76 | #include <linux/fs.h> | |
4e36dd33 | 77 | #include <linux/module.h> |
5814fc35 MW |
78 | #include <linux/debugfs.h> |
79 | #include <linux/platform_device.h> | |
4b8ac082 LJ |
80 | #include <linux/interrupt.h> |
81 | #include <linux/kobject.h> | |
82 | #include <linux/slab.h> | |
2cf64e26 | 83 | #include <linux/irq.h> |
5814fc35 MW |
84 | |
85 | #include <linux/mfd/abx500.h> | |
0cd5b6d0 | 86 | #include <linux/mfd/abx500/ab8500.h> |
1478a316 | 87 | #include <linux/mfd/abx500/ab8500-gpadc.h> |
5814fc35 | 88 | |
0fbce76e | 89 | #ifdef CONFIG_DEBUG_FS |
90 | #include <linux/string.h> | |
91 | #include <linux/ctype.h> | |
92 | #endif | |
93 | ||
5814fc35 MW |
94 | static u32 debug_bank; |
95 | static u32 debug_address; | |
96 | ||
6999181e | 97 | static int irq_ab8500; |
4b8ac082 LJ |
98 | static int irq_first; |
99 | static int irq_last; | |
ddba25f1 LW |
100 | static u32 *irq_count; |
101 | static int num_irqs; | |
0b337e70 | 102 | |
ddba25f1 LW |
103 | static struct device_attribute **dev_attr; |
104 | static char **event_name; | |
4b8ac082 | 105 | |
73482346 LJ |
106 | static u8 avg_sample = SAMPLE_16; |
107 | static u8 trig_edge = RISING_EDGE; | |
108 | static u8 conv_type = ADC_SW; | |
109 | static u8 trig_timer; | |
110 | ||
5814fc35 MW |
111 | /** |
112 | * struct ab8500_reg_range | |
113 | * @first: the first address of the range | |
114 | * @last: the last address of the range | |
115 | * @perm: access permissions for the range | |
116 | */ | |
117 | struct ab8500_reg_range { | |
d7b9f322 MW |
118 | u8 first; |
119 | u8 last; | |
120 | u8 perm; | |
5814fc35 MW |
121 | }; |
122 | ||
123 | /** | |
822672a7 | 124 | * struct ab8500_prcmu_ranges |
5814fc35 MW |
125 | * @num_ranges: the number of ranges in the list |
126 | * @bankid: bank identifier | |
127 | * @range: the list of register ranges | |
128 | */ | |
822672a7 | 129 | struct ab8500_prcmu_ranges { |
d7b9f322 MW |
130 | u8 num_ranges; |
131 | u8 bankid; | |
132 | const struct ab8500_reg_range *range; | |
5814fc35 MW |
133 | }; |
134 | ||
0fbce76e | 135 | /* hwreg- "mask" and "shift" entries ressources */ |
136 | struct hwreg_cfg { | |
137 | u32 bank; /* target bank */ | |
4362175d | 138 | unsigned long addr; /* target address */ |
0fbce76e | 139 | uint fmt; /* format */ |
4362175d LJ |
140 | unsigned long mask; /* read/write mask, applied before any bit shift */ |
141 | long shift; /* bit shift (read:right shift, write:left shift */ | |
0fbce76e | 142 | }; |
143 | /* fmt bit #0: 0=hexa, 1=dec */ | |
144 | #define REG_FMT_DEC(c) ((c)->fmt & 0x1) | |
145 | #define REG_FMT_HEX(c) (!REG_FMT_DEC(c)) | |
146 | ||
147 | static struct hwreg_cfg hwreg_cfg = { | |
148 | .addr = 0, /* default: invalid phys addr */ | |
149 | .fmt = 0, /* default: 32bit access, hex output */ | |
150 | .mask = 0xFFFFFFFF, /* default: no mask */ | |
151 | .shift = 0, /* default: no bit shift */ | |
152 | }; | |
153 | ||
5814fc35 | 154 | #define AB8500_NAME_STRING "ab8500" |
1478a316 | 155 | #define AB8500_ADC_NAME_STRING "gpadc" |
40c064e4 | 156 | #define AB8500_NUM_BANKS 24 |
5814fc35 MW |
157 | |
158 | #define AB8500_REV_REG 0x80 | |
159 | ||
9581ae39 LJ |
160 | static struct ab8500_prcmu_ranges *debug_ranges; |
161 | ||
8455eaee | 162 | static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = { |
d7b9f322 MW |
163 | [0x0] = { |
164 | .num_ranges = 0, | |
fad55a86 | 165 | .range = NULL, |
d7b9f322 MW |
166 | }, |
167 | [AB8500_SYS_CTRL1_BLOCK] = { | |
168 | .num_ranges = 3, | |
169 | .range = (struct ab8500_reg_range[]) { | |
170 | { | |
171 | .first = 0x00, | |
172 | .last = 0x02, | |
173 | }, | |
174 | { | |
175 | .first = 0x42, | |
176 | .last = 0x42, | |
177 | }, | |
178 | { | |
179 | .first = 0x80, | |
180 | .last = 0x81, | |
181 | }, | |
182 | }, | |
183 | }, | |
184 | [AB8500_SYS_CTRL2_BLOCK] = { | |
185 | .num_ranges = 4, | |
186 | .range = (struct ab8500_reg_range[]) { | |
187 | { | |
188 | .first = 0x00, | |
189 | .last = 0x0D, | |
190 | }, | |
191 | { | |
192 | .first = 0x0F, | |
193 | .last = 0x17, | |
194 | }, | |
195 | { | |
196 | .first = 0x30, | |
197 | .last = 0x30, | |
198 | }, | |
199 | { | |
200 | .first = 0x32, | |
201 | .last = 0x33, | |
202 | }, | |
203 | }, | |
204 | }, | |
205 | [AB8500_REGU_CTRL1] = { | |
206 | .num_ranges = 3, | |
207 | .range = (struct ab8500_reg_range[]) { | |
208 | { | |
209 | .first = 0x00, | |
210 | .last = 0x00, | |
211 | }, | |
212 | { | |
213 | .first = 0x03, | |
214 | .last = 0x10, | |
215 | }, | |
216 | { | |
217 | .first = 0x80, | |
218 | .last = 0x84, | |
219 | }, | |
220 | }, | |
221 | }, | |
222 | [AB8500_REGU_CTRL2] = { | |
223 | .num_ranges = 5, | |
224 | .range = (struct ab8500_reg_range[]) { | |
225 | { | |
226 | .first = 0x00, | |
227 | .last = 0x15, | |
228 | }, | |
229 | { | |
230 | .first = 0x17, | |
231 | .last = 0x19, | |
232 | }, | |
233 | { | |
234 | .first = 0x1B, | |
235 | .last = 0x1D, | |
236 | }, | |
237 | { | |
238 | .first = 0x1F, | |
239 | .last = 0x22, | |
240 | }, | |
241 | { | |
242 | .first = 0x40, | |
243 | .last = 0x44, | |
244 | }, | |
de6a7693 LJ |
245 | /* |
246 | * 0x80-0x8B are SIM registers and should | |
247 | * not be accessed from here | |
248 | */ | |
d7b9f322 MW |
249 | }, |
250 | }, | |
251 | [AB8500_USB] = { | |
252 | .num_ranges = 2, | |
253 | .range = (struct ab8500_reg_range[]) { | |
254 | { | |
255 | .first = 0x80, | |
256 | .last = 0x83, | |
257 | }, | |
258 | { | |
259 | .first = 0x87, | |
260 | .last = 0x8A, | |
261 | }, | |
262 | }, | |
263 | }, | |
264 | [AB8500_TVOUT] = { | |
265 | .num_ranges = 9, | |
266 | .range = (struct ab8500_reg_range[]) { | |
267 | { | |
268 | .first = 0x00, | |
269 | .last = 0x12, | |
270 | }, | |
271 | { | |
272 | .first = 0x15, | |
273 | .last = 0x17, | |
274 | }, | |
275 | { | |
276 | .first = 0x19, | |
277 | .last = 0x21, | |
278 | }, | |
279 | { | |
280 | .first = 0x27, | |
281 | .last = 0x2C, | |
282 | }, | |
283 | { | |
284 | .first = 0x41, | |
285 | .last = 0x41, | |
286 | }, | |
287 | { | |
288 | .first = 0x45, | |
289 | .last = 0x5B, | |
290 | }, | |
291 | { | |
292 | .first = 0x5D, | |
293 | .last = 0x5D, | |
294 | }, | |
295 | { | |
296 | .first = 0x69, | |
297 | .last = 0x69, | |
298 | }, | |
299 | { | |
300 | .first = 0x80, | |
301 | .last = 0x81, | |
302 | }, | |
303 | }, | |
304 | }, | |
305 | [AB8500_DBI] = { | |
306 | .num_ranges = 0, | |
87fff232 | 307 | .range = NULL, |
d7b9f322 MW |
308 | }, |
309 | [AB8500_ECI_AV_ACC] = { | |
310 | .num_ranges = 1, | |
311 | .range = (struct ab8500_reg_range[]) { | |
312 | { | |
313 | .first = 0x80, | |
314 | .last = 0x82, | |
315 | }, | |
316 | }, | |
317 | }, | |
318 | [0x9] = { | |
319 | .num_ranges = 0, | |
87fff232 | 320 | .range = NULL, |
d7b9f322 MW |
321 | }, |
322 | [AB8500_GPADC] = { | |
323 | .num_ranges = 1, | |
324 | .range = (struct ab8500_reg_range[]) { | |
325 | { | |
326 | .first = 0x00, | |
327 | .last = 0x08, | |
328 | }, | |
329 | }, | |
330 | }, | |
331 | [AB8500_CHARGER] = { | |
40c064e4 | 332 | .num_ranges = 9, |
d7b9f322 MW |
333 | .range = (struct ab8500_reg_range[]) { |
334 | { | |
335 | .first = 0x00, | |
336 | .last = 0x03, | |
337 | }, | |
338 | { | |
339 | .first = 0x05, | |
340 | .last = 0x05, | |
341 | }, | |
342 | { | |
343 | .first = 0x40, | |
344 | .last = 0x40, | |
345 | }, | |
346 | { | |
347 | .first = 0x42, | |
348 | .last = 0x42, | |
349 | }, | |
350 | { | |
351 | .first = 0x44, | |
352 | .last = 0x44, | |
353 | }, | |
354 | { | |
355 | .first = 0x50, | |
356 | .last = 0x55, | |
357 | }, | |
358 | { | |
359 | .first = 0x80, | |
360 | .last = 0x82, | |
361 | }, | |
362 | { | |
363 | .first = 0xC0, | |
364 | .last = 0xC2, | |
365 | }, | |
40c064e4 PL |
366 | { |
367 | .first = 0xf5, | |
9581ae39 | 368 | .last = 0xf6, |
40c064e4 | 369 | }, |
d7b9f322 MW |
370 | }, |
371 | }, | |
372 | [AB8500_GAS_GAUGE] = { | |
373 | .num_ranges = 3, | |
374 | .range = (struct ab8500_reg_range[]) { | |
375 | { | |
376 | .first = 0x00, | |
377 | .last = 0x00, | |
378 | }, | |
379 | { | |
380 | .first = 0x07, | |
381 | .last = 0x0A, | |
382 | }, | |
383 | { | |
384 | .first = 0x10, | |
385 | .last = 0x14, | |
386 | }, | |
387 | }, | |
388 | }, | |
40c064e4 PL |
389 | [AB8500_DEVELOPMENT] = { |
390 | .num_ranges = 1, | |
391 | .range = (struct ab8500_reg_range[]) { | |
392 | { | |
393 | .first = 0x00, | |
394 | .last = 0x00, | |
395 | }, | |
396 | }, | |
397 | }, | |
398 | [AB8500_DEBUG] = { | |
399 | .num_ranges = 1, | |
400 | .range = (struct ab8500_reg_range[]) { | |
401 | { | |
402 | .first = 0x05, | |
403 | .last = 0x07, | |
404 | }, | |
405 | }, | |
406 | }, | |
d7b9f322 MW |
407 | [AB8500_AUDIO] = { |
408 | .num_ranges = 1, | |
409 | .range = (struct ab8500_reg_range[]) { | |
410 | { | |
411 | .first = 0x00, | |
412 | .last = 0x6F, | |
413 | }, | |
414 | }, | |
415 | }, | |
416 | [AB8500_INTERRUPT] = { | |
417 | .num_ranges = 0, | |
87fff232 | 418 | .range = NULL, |
d7b9f322 MW |
419 | }, |
420 | [AB8500_RTC] = { | |
421 | .num_ranges = 1, | |
422 | .range = (struct ab8500_reg_range[]) { | |
423 | { | |
424 | .first = 0x00, | |
425 | .last = 0x0F, | |
426 | }, | |
427 | }, | |
428 | }, | |
429 | [AB8500_MISC] = { | |
430 | .num_ranges = 8, | |
431 | .range = (struct ab8500_reg_range[]) { | |
432 | { | |
433 | .first = 0x00, | |
434 | .last = 0x05, | |
435 | }, | |
436 | { | |
437 | .first = 0x10, | |
438 | .last = 0x15, | |
439 | }, | |
440 | { | |
441 | .first = 0x20, | |
442 | .last = 0x25, | |
443 | }, | |
444 | { | |
445 | .first = 0x30, | |
446 | .last = 0x35, | |
447 | }, | |
448 | { | |
449 | .first = 0x40, | |
450 | .last = 0x45, | |
451 | }, | |
452 | { | |
453 | .first = 0x50, | |
454 | .last = 0x50, | |
455 | }, | |
456 | { | |
457 | .first = 0x60, | |
458 | .last = 0x67, | |
459 | }, | |
460 | { | |
461 | .first = 0x80, | |
462 | .last = 0x80, | |
463 | }, | |
464 | }, | |
465 | }, | |
466 | [0x11] = { | |
467 | .num_ranges = 0, | |
87fff232 | 468 | .range = NULL, |
d7b9f322 MW |
469 | }, |
470 | [0x12] = { | |
471 | .num_ranges = 0, | |
87fff232 | 472 | .range = NULL, |
d7b9f322 MW |
473 | }, |
474 | [0x13] = { | |
475 | .num_ranges = 0, | |
87fff232 | 476 | .range = NULL, |
d7b9f322 MW |
477 | }, |
478 | [0x14] = { | |
479 | .num_ranges = 0, | |
87fff232 | 480 | .range = NULL, |
d7b9f322 MW |
481 | }, |
482 | [AB8500_OTP_EMUL] = { | |
483 | .num_ranges = 1, | |
484 | .range = (struct ab8500_reg_range[]) { | |
485 | { | |
486 | .first = 0x01, | |
487 | .last = 0x0F, | |
488 | }, | |
489 | }, | |
490 | }, | |
5814fc35 MW |
491 | }; |
492 | ||
8455eaee | 493 | static struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = { |
9581ae39 LJ |
494 | [0x0] = { |
495 | .num_ranges = 0, | |
496 | .range = NULL, | |
497 | }, | |
498 | [AB8500_SYS_CTRL1_BLOCK] = { | |
499 | .num_ranges = 5, | |
500 | .range = (struct ab8500_reg_range[]) { | |
501 | { | |
502 | .first = 0x00, | |
503 | .last = 0x04, | |
504 | }, | |
505 | { | |
506 | .first = 0x42, | |
507 | .last = 0x42, | |
508 | }, | |
509 | { | |
510 | .first = 0x52, | |
511 | .last = 0x52, | |
512 | }, | |
513 | { | |
514 | .first = 0x54, | |
515 | .last = 0x57, | |
516 | }, | |
517 | { | |
518 | .first = 0x80, | |
519 | .last = 0x83, | |
520 | }, | |
521 | }, | |
522 | }, | |
523 | [AB8500_SYS_CTRL2_BLOCK] = { | |
524 | .num_ranges = 5, | |
525 | .range = (struct ab8500_reg_range[]) { | |
526 | { | |
527 | .first = 0x00, | |
528 | .last = 0x0D, | |
529 | }, | |
530 | { | |
531 | .first = 0x0F, | |
532 | .last = 0x17, | |
533 | }, | |
534 | { | |
535 | .first = 0x20, | |
536 | .last = 0x20, | |
537 | }, | |
538 | { | |
539 | .first = 0x30, | |
540 | .last = 0x30, | |
541 | }, | |
542 | { | |
543 | .first = 0x32, | |
544 | .last = 0x3A, | |
545 | }, | |
546 | }, | |
547 | }, | |
548 | [AB8500_REGU_CTRL1] = { | |
549 | .num_ranges = 3, | |
550 | .range = (struct ab8500_reg_range[]) { | |
551 | { | |
552 | .first = 0x00, | |
553 | .last = 0x00, | |
554 | }, | |
555 | { | |
556 | .first = 0x03, | |
557 | .last = 0x11, | |
558 | }, | |
559 | { | |
560 | .first = 0x80, | |
561 | .last = 0x86, | |
562 | }, | |
563 | }, | |
564 | }, | |
565 | [AB8500_REGU_CTRL2] = { | |
566 | .num_ranges = 6, | |
567 | .range = (struct ab8500_reg_range[]) { | |
568 | { | |
569 | .first = 0x00, | |
570 | .last = 0x06, | |
571 | }, | |
572 | { | |
573 | .first = 0x08, | |
574 | .last = 0x15, | |
575 | }, | |
576 | { | |
577 | .first = 0x17, | |
578 | .last = 0x19, | |
579 | }, | |
580 | { | |
581 | .first = 0x1B, | |
582 | .last = 0x1D, | |
583 | }, | |
584 | { | |
585 | .first = 0x1F, | |
586 | .last = 0x30, | |
587 | }, | |
588 | { | |
589 | .first = 0x40, | |
590 | .last = 0x48, | |
591 | }, | |
de6a7693 LJ |
592 | /* |
593 | * 0x80-0x8B are SIM registers and should | |
594 | * not be accessed from here | |
595 | */ | |
9581ae39 LJ |
596 | }, |
597 | }, | |
598 | [AB8500_USB] = { | |
599 | .num_ranges = 3, | |
600 | .range = (struct ab8500_reg_range[]) { | |
601 | { | |
602 | .first = 0x80, | |
603 | .last = 0x83, | |
604 | }, | |
605 | { | |
606 | .first = 0x87, | |
607 | .last = 0x8A, | |
608 | }, | |
609 | { | |
610 | .first = 0x91, | |
611 | .last = 0x94, | |
612 | }, | |
613 | }, | |
614 | }, | |
615 | [AB8500_TVOUT] = { | |
616 | .num_ranges = 0, | |
617 | .range = NULL, | |
618 | }, | |
619 | [AB8500_DBI] = { | |
620 | .num_ranges = 0, | |
621 | .range = NULL, | |
622 | }, | |
623 | [AB8500_ECI_AV_ACC] = { | |
624 | .num_ranges = 1, | |
625 | .range = (struct ab8500_reg_range[]) { | |
626 | { | |
627 | .first = 0x80, | |
628 | .last = 0x82, | |
629 | }, | |
630 | }, | |
631 | }, | |
632 | [AB8500_RESERVED] = { | |
633 | .num_ranges = 0, | |
634 | .range = NULL, | |
635 | }, | |
636 | [AB8500_GPADC] = { | |
637 | .num_ranges = 1, | |
638 | .range = (struct ab8500_reg_range[]) { | |
639 | { | |
640 | .first = 0x00, | |
641 | .last = 0x08, | |
642 | }, | |
643 | }, | |
644 | }, | |
645 | [AB8500_CHARGER] = { | |
646 | .num_ranges = 9, | |
647 | .range = (struct ab8500_reg_range[]) { | |
648 | { | |
649 | .first = 0x02, | |
650 | .last = 0x03, | |
651 | }, | |
652 | { | |
653 | .first = 0x05, | |
654 | .last = 0x05, | |
655 | }, | |
656 | { | |
657 | .first = 0x40, | |
658 | .last = 0x44, | |
659 | }, | |
660 | { | |
661 | .first = 0x50, | |
662 | .last = 0x57, | |
663 | }, | |
664 | { | |
665 | .first = 0x60, | |
666 | .last = 0x60, | |
667 | }, | |
668 | { | |
669 | .first = 0xA0, | |
670 | .last = 0xA7, | |
671 | }, | |
672 | { | |
673 | .first = 0xAF, | |
674 | .last = 0xB2, | |
675 | }, | |
676 | { | |
677 | .first = 0xC0, | |
678 | .last = 0xC2, | |
679 | }, | |
680 | { | |
681 | .first = 0xF5, | |
682 | .last = 0xF5, | |
683 | }, | |
684 | }, | |
685 | }, | |
686 | [AB8500_GAS_GAUGE] = { | |
687 | .num_ranges = 3, | |
688 | .range = (struct ab8500_reg_range[]) { | |
689 | { | |
690 | .first = 0x00, | |
691 | .last = 0x00, | |
692 | }, | |
693 | { | |
694 | .first = 0x07, | |
695 | .last = 0x0A, | |
696 | }, | |
697 | { | |
698 | .first = 0x10, | |
699 | .last = 0x14, | |
700 | }, | |
701 | }, | |
702 | }, | |
703 | [AB8500_AUDIO] = { | |
704 | .num_ranges = 1, | |
705 | .range = (struct ab8500_reg_range[]) { | |
706 | { | |
707 | .first = 0x00, | |
708 | .last = 0x83, | |
709 | }, | |
710 | }, | |
711 | }, | |
712 | [AB8500_INTERRUPT] = { | |
713 | .num_ranges = 11, | |
714 | .range = (struct ab8500_reg_range[]) { | |
715 | { | |
716 | .first = 0x00, | |
717 | .last = 0x04, | |
718 | }, | |
719 | { | |
720 | .first = 0x06, | |
721 | .last = 0x07, | |
722 | }, | |
723 | { | |
724 | .first = 0x09, | |
725 | .last = 0x09, | |
726 | }, | |
727 | { | |
728 | .first = 0x0B, | |
729 | .last = 0x0C, | |
730 | }, | |
731 | { | |
732 | .first = 0x12, | |
733 | .last = 0x15, | |
734 | }, | |
735 | { | |
736 | .first = 0x18, | |
737 | .last = 0x18, | |
738 | }, | |
739 | /* Latch registers should not be read here */ | |
740 | { | |
741 | .first = 0x40, | |
742 | .last = 0x44, | |
743 | }, | |
744 | { | |
745 | .first = 0x46, | |
746 | .last = 0x49, | |
747 | }, | |
748 | { | |
749 | .first = 0x4B, | |
750 | .last = 0x4D, | |
751 | }, | |
752 | { | |
753 | .first = 0x52, | |
754 | .last = 0x55, | |
755 | }, | |
756 | { | |
757 | .first = 0x58, | |
758 | .last = 0x58, | |
759 | }, | |
760 | /* LatchHier registers should not be read here */ | |
761 | }, | |
762 | }, | |
763 | [AB8500_RTC] = { | |
764 | .num_ranges = 2, | |
765 | .range = (struct ab8500_reg_range[]) { | |
766 | { | |
767 | .first = 0x00, | |
768 | .last = 0x14, | |
769 | }, | |
770 | { | |
771 | .first = 0x16, | |
772 | .last = 0x17, | |
773 | }, | |
774 | }, | |
775 | }, | |
776 | [AB8500_MISC] = { | |
777 | .num_ranges = 8, | |
778 | .range = (struct ab8500_reg_range[]) { | |
779 | { | |
780 | .first = 0x00, | |
781 | .last = 0x06, | |
782 | }, | |
783 | { | |
784 | .first = 0x10, | |
785 | .last = 0x16, | |
786 | }, | |
787 | { | |
788 | .first = 0x20, | |
789 | .last = 0x26, | |
790 | }, | |
791 | { | |
792 | .first = 0x30, | |
793 | .last = 0x36, | |
794 | }, | |
795 | { | |
796 | .first = 0x40, | |
797 | .last = 0x46, | |
798 | }, | |
799 | { | |
800 | .first = 0x50, | |
801 | .last = 0x50, | |
802 | }, | |
803 | { | |
804 | .first = 0x60, | |
805 | .last = 0x6B, | |
806 | }, | |
807 | { | |
808 | .first = 0x80, | |
809 | .last = 0x82, | |
810 | }, | |
811 | }, | |
812 | }, | |
813 | [AB8500_DEVELOPMENT] = { | |
814 | .num_ranges = 2, | |
815 | .range = (struct ab8500_reg_range[]) { | |
816 | { | |
817 | .first = 0x00, | |
818 | .last = 0x00, | |
819 | }, | |
820 | { | |
821 | .first = 0x05, | |
822 | .last = 0x05, | |
823 | }, | |
824 | }, | |
825 | }, | |
826 | [AB8500_DEBUG] = { | |
827 | .num_ranges = 1, | |
828 | .range = (struct ab8500_reg_range[]) { | |
829 | { | |
830 | .first = 0x05, | |
831 | .last = 0x07, | |
832 | }, | |
833 | }, | |
834 | }, | |
835 | [AB8500_PROD_TEST] = { | |
836 | .num_ranges = 0, | |
837 | .range = NULL, | |
838 | }, | |
839 | [AB8500_STE_TEST] = { | |
840 | .num_ranges = 0, | |
841 | .range = NULL, | |
842 | }, | |
843 | [AB8500_OTP_EMUL] = { | |
844 | .num_ranges = 1, | |
845 | .range = (struct ab8500_reg_range[]) { | |
846 | { | |
847 | .first = 0x01, | |
848 | .last = 0x15, | |
849 | }, | |
850 | }, | |
851 | }, | |
852 | }; | |
853 | ||
8455eaee | 854 | static struct ab8500_prcmu_ranges ab8540_debug_ranges[AB8500_NUM_BANKS] = { |
971480f5 LJ |
855 | [AB8500_M_FSM_RANK] = { |
856 | .num_ranges = 1, | |
857 | .range = (struct ab8500_reg_range[]) { | |
858 | { | |
859 | .first = 0x00, | |
860 | .last = 0x0B, | |
861 | }, | |
862 | }, | |
863 | }, | |
864 | [AB8500_SYS_CTRL1_BLOCK] = { | |
865 | .num_ranges = 6, | |
866 | .range = (struct ab8500_reg_range[]) { | |
867 | { | |
868 | .first = 0x00, | |
869 | .last = 0x04, | |
870 | }, | |
871 | { | |
872 | .first = 0x42, | |
873 | .last = 0x42, | |
874 | }, | |
875 | { | |
876 | .first = 0x50, | |
877 | .last = 0x54, | |
878 | }, | |
879 | { | |
880 | .first = 0x57, | |
881 | .last = 0x57, | |
882 | }, | |
883 | { | |
884 | .first = 0x80, | |
885 | .last = 0x83, | |
886 | }, | |
887 | { | |
888 | .first = 0x90, | |
889 | .last = 0x90, | |
890 | }, | |
891 | }, | |
892 | }, | |
893 | [AB8500_SYS_CTRL2_BLOCK] = { | |
894 | .num_ranges = 5, | |
895 | .range = (struct ab8500_reg_range[]) { | |
896 | { | |
897 | .first = 0x00, | |
898 | .last = 0x0D, | |
899 | }, | |
900 | { | |
901 | .first = 0x0F, | |
902 | .last = 0x10, | |
903 | }, | |
904 | { | |
905 | .first = 0x20, | |
906 | .last = 0x21, | |
907 | }, | |
908 | { | |
909 | .first = 0x32, | |
910 | .last = 0x3C, | |
911 | }, | |
912 | { | |
913 | .first = 0x40, | |
914 | .last = 0x42, | |
915 | }, | |
916 | }, | |
917 | }, | |
918 | [AB8500_REGU_CTRL1] = { | |
919 | .num_ranges = 4, | |
920 | .range = (struct ab8500_reg_range[]) { | |
921 | { | |
922 | .first = 0x03, | |
923 | .last = 0x15, | |
924 | }, | |
925 | { | |
926 | .first = 0x20, | |
927 | .last = 0x20, | |
928 | }, | |
929 | { | |
930 | .first = 0x80, | |
931 | .last = 0x85, | |
932 | }, | |
933 | { | |
934 | .first = 0x87, | |
935 | .last = 0x88, | |
936 | }, | |
937 | }, | |
938 | }, | |
939 | [AB8500_REGU_CTRL2] = { | |
940 | .num_ranges = 8, | |
941 | .range = (struct ab8500_reg_range[]) { | |
942 | { | |
943 | .first = 0x00, | |
944 | .last = 0x06, | |
945 | }, | |
946 | { | |
947 | .first = 0x08, | |
948 | .last = 0x15, | |
949 | }, | |
950 | { | |
951 | .first = 0x17, | |
952 | .last = 0x19, | |
953 | }, | |
954 | { | |
955 | .first = 0x1B, | |
956 | .last = 0x1D, | |
957 | }, | |
958 | { | |
959 | .first = 0x1F, | |
960 | .last = 0x2F, | |
961 | }, | |
962 | { | |
963 | .first = 0x31, | |
964 | .last = 0x3A, | |
965 | }, | |
966 | { | |
967 | .first = 0x43, | |
968 | .last = 0x44, | |
969 | }, | |
970 | { | |
971 | .first = 0x48, | |
972 | .last = 0x49, | |
973 | }, | |
974 | }, | |
975 | }, | |
976 | [AB8500_USB] = { | |
977 | .num_ranges = 3, | |
978 | .range = (struct ab8500_reg_range[]) { | |
979 | { | |
980 | .first = 0x80, | |
981 | .last = 0x83, | |
982 | }, | |
983 | { | |
984 | .first = 0x87, | |
985 | .last = 0x8A, | |
986 | }, | |
987 | { | |
988 | .first = 0x91, | |
989 | .last = 0x94, | |
990 | }, | |
991 | }, | |
992 | }, | |
993 | [AB8500_TVOUT] = { | |
994 | .num_ranges = 0, | |
995 | .range = NULL | |
996 | }, | |
997 | [AB8500_DBI] = { | |
998 | .num_ranges = 4, | |
999 | .range = (struct ab8500_reg_range[]) { | |
1000 | { | |
1001 | .first = 0x00, | |
1002 | .last = 0x07, | |
1003 | }, | |
1004 | { | |
1005 | .first = 0x10, | |
1006 | .last = 0x11, | |
1007 | }, | |
1008 | { | |
1009 | .first = 0x20, | |
1010 | .last = 0x21, | |
1011 | }, | |
1012 | { | |
1013 | .first = 0x30, | |
1014 | .last = 0x43, | |
1015 | }, | |
1016 | }, | |
1017 | }, | |
1018 | [AB8500_ECI_AV_ACC] = { | |
1019 | .num_ranges = 2, | |
1020 | .range = (struct ab8500_reg_range[]) { | |
1021 | { | |
1022 | .first = 0x00, | |
1023 | .last = 0x03, | |
1024 | }, | |
1025 | { | |
1026 | .first = 0x80, | |
1027 | .last = 0x82, | |
1028 | }, | |
1029 | }, | |
1030 | }, | |
1031 | [AB8500_RESERVED] = { | |
1032 | .num_ranges = 0, | |
1033 | .range = NULL, | |
1034 | }, | |
1035 | [AB8500_GPADC] = { | |
1036 | .num_ranges = 4, | |
1037 | .range = (struct ab8500_reg_range[]) { | |
1038 | { | |
1039 | .first = 0x00, | |
1040 | .last = 0x01, | |
1041 | }, | |
1042 | { | |
1043 | .first = 0x04, | |
1044 | .last = 0x06, | |
1045 | }, | |
1046 | { | |
1047 | .first = 0x09, | |
1048 | .last = 0x0A, | |
1049 | }, | |
1050 | { | |
1051 | .first = 0x10, | |
1052 | .last = 0x14, | |
1053 | }, | |
1054 | }, | |
1055 | }, | |
1056 | [AB8500_CHARGER] = { | |
1057 | .num_ranges = 10, | |
1058 | .range = (struct ab8500_reg_range[]) { | |
1059 | { | |
1060 | .first = 0x00, | |
1061 | .last = 0x00, | |
1062 | }, | |
1063 | { | |
1064 | .first = 0x02, | |
1065 | .last = 0x05, | |
1066 | }, | |
1067 | { | |
1068 | .first = 0x40, | |
1069 | .last = 0x44, | |
1070 | }, | |
1071 | { | |
1072 | .first = 0x50, | |
1073 | .last = 0x57, | |
1074 | }, | |
1075 | { | |
1076 | .first = 0x60, | |
1077 | .last = 0x60, | |
1078 | }, | |
1079 | { | |
1080 | .first = 0x70, | |
1081 | .last = 0x70, | |
1082 | }, | |
1083 | { | |
1084 | .first = 0xA0, | |
1085 | .last = 0xA9, | |
1086 | }, | |
1087 | { | |
1088 | .first = 0xAF, | |
1089 | .last = 0xB2, | |
1090 | }, | |
1091 | { | |
1092 | .first = 0xC0, | |
1093 | .last = 0xC6, | |
1094 | }, | |
1095 | { | |
1096 | .first = 0xF5, | |
1097 | .last = 0xF5, | |
1098 | }, | |
1099 | }, | |
1100 | }, | |
1101 | [AB8500_GAS_GAUGE] = { | |
1102 | .num_ranges = 3, | |
1103 | .range = (struct ab8500_reg_range[]) { | |
1104 | { | |
1105 | .first = 0x00, | |
1106 | .last = 0x00, | |
1107 | }, | |
1108 | { | |
1109 | .first = 0x07, | |
1110 | .last = 0x0A, | |
1111 | }, | |
1112 | { | |
1113 | .first = 0x10, | |
1114 | .last = 0x14, | |
1115 | }, | |
1116 | }, | |
1117 | }, | |
1118 | [AB8500_AUDIO] = { | |
1119 | .num_ranges = 1, | |
1120 | .range = (struct ab8500_reg_range[]) { | |
1121 | { | |
1122 | .first = 0x00, | |
1123 | .last = 0x9f, | |
1124 | }, | |
1125 | }, | |
1126 | }, | |
1127 | [AB8500_INTERRUPT] = { | |
1128 | .num_ranges = 6, | |
1129 | .range = (struct ab8500_reg_range[]) { | |
1130 | { | |
1131 | .first = 0x00, | |
1132 | .last = 0x05, | |
1133 | }, | |
1134 | { | |
1135 | .first = 0x0B, | |
1136 | .last = 0x0D, | |
1137 | }, | |
1138 | { | |
1139 | .first = 0x12, | |
1140 | .last = 0x20, | |
1141 | }, | |
1142 | /* Latch registers should not be read here */ | |
1143 | { | |
1144 | .first = 0x40, | |
1145 | .last = 0x45, | |
1146 | }, | |
1147 | { | |
1148 | .first = 0x4B, | |
1149 | .last = 0x4D, | |
1150 | }, | |
1151 | { | |
1152 | .first = 0x52, | |
1153 | .last = 0x60, | |
1154 | }, | |
1155 | /* LatchHier registers should not be read here */ | |
1156 | }, | |
1157 | }, | |
1158 | [AB8500_RTC] = { | |
1159 | .num_ranges = 3, | |
1160 | .range = (struct ab8500_reg_range[]) { | |
1161 | { | |
1162 | .first = 0x00, | |
1163 | .last = 0x07, | |
1164 | }, | |
1165 | { | |
1166 | .first = 0x0B, | |
1167 | .last = 0x18, | |
1168 | }, | |
1169 | { | |
1170 | .first = 0x20, | |
1171 | .last = 0x25, | |
1172 | }, | |
1173 | }, | |
1174 | }, | |
1175 | [AB8500_MISC] = { | |
1176 | .num_ranges = 9, | |
1177 | .range = (struct ab8500_reg_range[]) { | |
1178 | { | |
1179 | .first = 0x00, | |
1180 | .last = 0x06, | |
1181 | }, | |
1182 | { | |
1183 | .first = 0x10, | |
1184 | .last = 0x16, | |
1185 | }, | |
1186 | { | |
1187 | .first = 0x20, | |
1188 | .last = 0x26, | |
1189 | }, | |
1190 | { | |
1191 | .first = 0x30, | |
1192 | .last = 0x36, | |
1193 | }, | |
1194 | { | |
1195 | .first = 0x40, | |
1196 | .last = 0x49, | |
1197 | }, | |
1198 | { | |
1199 | .first = 0x50, | |
1200 | .last = 0x50, | |
1201 | }, | |
1202 | { | |
1203 | .first = 0x60, | |
1204 | .last = 0x6B, | |
1205 | }, | |
1206 | { | |
1207 | .first = 0x70, | |
1208 | .last = 0x74, | |
1209 | }, | |
1210 | { | |
1211 | .first = 0x80, | |
1212 | .last = 0x82, | |
1213 | }, | |
1214 | }, | |
1215 | }, | |
1216 | [AB8500_DEVELOPMENT] = { | |
1217 | .num_ranges = 3, | |
1218 | .range = (struct ab8500_reg_range[]) { | |
1219 | { | |
1220 | .first = 0x00, | |
1221 | .last = 0x01, | |
1222 | }, | |
1223 | { | |
1224 | .first = 0x06, | |
1225 | .last = 0x06, | |
1226 | }, | |
1227 | { | |
1228 | .first = 0x10, | |
1229 | .last = 0x21, | |
1230 | }, | |
1231 | }, | |
1232 | }, | |
1233 | [AB8500_DEBUG] = { | |
1234 | .num_ranges = 3, | |
1235 | .range = (struct ab8500_reg_range[]) { | |
1236 | { | |
1237 | .first = 0x01, | |
1238 | .last = 0x0C, | |
1239 | }, | |
1240 | { | |
1241 | .first = 0x0E, | |
1242 | .last = 0x11, | |
1243 | }, | |
1244 | { | |
1245 | .first = 0x80, | |
1246 | .last = 0x81, | |
1247 | }, | |
1248 | }, | |
1249 | }, | |
1250 | [AB8500_PROD_TEST] = { | |
1251 | .num_ranges = 0, | |
1252 | .range = NULL, | |
1253 | }, | |
1254 | [AB8500_STE_TEST] = { | |
1255 | .num_ranges = 0, | |
1256 | .range = NULL, | |
1257 | }, | |
1258 | [AB8500_OTP_EMUL] = { | |
1259 | .num_ranges = 1, | |
1260 | .range = (struct ab8500_reg_range[]) { | |
1261 | { | |
1262 | .first = 0x00, | |
1263 | .last = 0x3F, | |
1264 | }, | |
1265 | }, | |
1266 | }, | |
1267 | }; | |
1268 | ||
1269 | ||
4b8ac082 LJ |
1270 | static irqreturn_t ab8500_debug_handler(int irq, void *data) |
1271 | { | |
1272 | char buf[16]; | |
1273 | struct kobject *kobj = (struct kobject *)data; | |
0b337e70 | 1274 | unsigned int irq_abb = irq - irq_first; |
4b8ac082 | 1275 | |
ddba25f1 | 1276 | if (irq_abb < num_irqs) |
0b337e70 | 1277 | irq_count[irq_abb]++; |
4b8ac082 LJ |
1278 | /* |
1279 | * This makes it possible to use poll for events (POLLPRI | POLLERR) | |
0b337e70 | 1280 | * from userspace on sysfs file named <irq-nr> |
4b8ac082 | 1281 | */ |
0b337e70 | 1282 | sprintf(buf, "%d", irq); |
4b8ac082 LJ |
1283 | sysfs_notify(kobj, NULL, buf); |
1284 | ||
1285 | return IRQ_HANDLED; | |
1286 | } | |
1287 | ||
42002c6d MYK |
1288 | /* Prints to seq_file or log_buf */ |
1289 | static int ab8500_registers_print(struct device *dev, u32 bank, | |
9a503a7d | 1290 | struct seq_file *s) |
5814fc35 | 1291 | { |
d7b9f322 | 1292 | unsigned int i; |
d7b9f322 | 1293 | |
d7b9f322 MW |
1294 | for (i = 0; i < debug_ranges[bank].num_ranges; i++) { |
1295 | u32 reg; | |
1296 | ||
1297 | for (reg = debug_ranges[bank].range[i].first; | |
1298 | reg <= debug_ranges[bank].range[i].last; | |
1299 | reg++) { | |
1300 | u8 value; | |
1301 | int err; | |
1302 | ||
1303 | err = abx500_get_register_interruptible(dev, | |
1304 | (u8)bank, (u8)reg, &value); | |
1305 | if (err < 0) { | |
1306 | dev_err(dev, "ab->read fail %d\n", err); | |
1307 | return err; | |
1308 | } | |
1309 | ||
42002c6d | 1310 | if (s) { |
9a503a7d JP |
1311 | seq_printf(s, " [0x%02X/0x%02X]: 0x%02X\n", |
1312 | bank, reg, value); | |
de6a7693 LJ |
1313 | /* |
1314 | * Error is not returned here since | |
1315 | * the output is wanted in any case | |
1316 | */ | |
9a503a7d | 1317 | if (seq_has_overflowed(s)) |
42002c6d | 1318 | return 0; |
42002c6d | 1319 | } else { |
4362175d LJ |
1320 | dev_info(dev, " [0x%02X/0x%02X]: 0x%02X\n", |
1321 | bank, reg, value); | |
d7b9f322 MW |
1322 | } |
1323 | } | |
1324 | } | |
9a503a7d | 1325 | |
d7b9f322 | 1326 | return 0; |
5814fc35 MW |
1327 | } |
1328 | ||
42002c6d MYK |
1329 | static int ab8500_print_bank_registers(struct seq_file *s, void *p) |
1330 | { | |
1331 | struct device *dev = s->private; | |
1332 | u32 bank = debug_bank; | |
1333 | ||
4362175d | 1334 | seq_puts(s, AB8500_NAME_STRING " register values:\n"); |
42002c6d | 1335 | |
cfc0849c | 1336 | seq_printf(s, " bank 0x%02X:\n", bank); |
42002c6d | 1337 | |
9a503a7d | 1338 | return ab8500_registers_print(dev, bank, s); |
42002c6d MYK |
1339 | } |
1340 | ||
5814fc35 MW |
1341 | static int ab8500_registers_open(struct inode *inode, struct file *file) |
1342 | { | |
42002c6d | 1343 | return single_open(file, ab8500_print_bank_registers, inode->i_private); |
5814fc35 MW |
1344 | } |
1345 | ||
1346 | static const struct file_operations ab8500_registers_fops = { | |
d7b9f322 MW |
1347 | .open = ab8500_registers_open, |
1348 | .read = seq_read, | |
1349 | .llseek = seq_lseek, | |
1350 | .release = single_release, | |
1351 | .owner = THIS_MODULE, | |
5814fc35 MW |
1352 | }; |
1353 | ||
42002c6d MYK |
1354 | static int ab8500_print_all_banks(struct seq_file *s, void *p) |
1355 | { | |
1356 | struct device *dev = s->private; | |
1357 | unsigned int i; | |
42002c6d | 1358 | |
4362175d | 1359 | seq_puts(s, AB8500_NAME_STRING " register values:\n"); |
42002c6d | 1360 | |
971480f5 | 1361 | for (i = 0; i < AB8500_NUM_BANKS; i++) { |
9a503a7d | 1362 | int err; |
42002c6d | 1363 | |
9a503a7d JP |
1364 | seq_printf(s, " bank 0x%02X:\n", i); |
1365 | err = ab8500_registers_print(dev, i, s); | |
1366 | if (err) | |
1367 | return err; | |
42002c6d MYK |
1368 | } |
1369 | return 0; | |
1370 | } | |
1371 | ||
1d843a6c MYK |
1372 | /* Dump registers to kernel log */ |
1373 | void ab8500_dump_all_banks(struct device *dev) | |
1374 | { | |
1375 | unsigned int i; | |
1376 | ||
4362175d | 1377 | dev_info(dev, "ab8500 register values:\n"); |
1d843a6c MYK |
1378 | |
1379 | for (i = 1; i < AB8500_NUM_BANKS; i++) { | |
4362175d | 1380 | dev_info(dev, " bank 0x%02X:\n", i); |
1d843a6c MYK |
1381 | ab8500_registers_print(dev, i, NULL); |
1382 | } | |
1383 | } | |
1384 | ||
5ff9090f LJ |
1385 | /* Space for 500 registers. */ |
1386 | #define DUMP_MAX_REGS 700 | |
8455eaee | 1387 | static struct ab8500_register_dump |
5ff9090f LJ |
1388 | { |
1389 | u8 bank; | |
1390 | u8 reg; | |
1391 | u8 value; | |
5ff9090f LJ |
1392 | } ab8500_complete_register_dump[DUMP_MAX_REGS]; |
1393 | ||
5ff9090f LJ |
1394 | /* This shall only be called upon kernel panic! */ |
1395 | void ab8500_dump_all_banks_to_mem(void) | |
1396 | { | |
1397 | int i, r = 0; | |
1398 | u8 bank; | |
222460cb | 1399 | int err = 0; |
5ff9090f | 1400 | |
4362175d | 1401 | pr_info("Saving all ABB registers for crash analysis.\n"); |
5ff9090f | 1402 | |
971480f5 | 1403 | for (bank = 0; bank < AB8500_NUM_BANKS; bank++) { |
5ff9090f LJ |
1404 | for (i = 0; i < debug_ranges[bank].num_ranges; i++) { |
1405 | u8 reg; | |
1406 | ||
1407 | for (reg = debug_ranges[bank].range[i].first; | |
1408 | reg <= debug_ranges[bank].range[i].last; | |
1409 | reg++) { | |
1410 | u8 value; | |
5ff9090f LJ |
1411 | |
1412 | err = prcmu_abb_read(bank, reg, &value, 1); | |
1413 | ||
222460cb JA |
1414 | if (err < 0) |
1415 | goto out; | |
1416 | ||
5ff9090f LJ |
1417 | ab8500_complete_register_dump[r].bank = bank; |
1418 | ab8500_complete_register_dump[r].reg = reg; | |
1419 | ab8500_complete_register_dump[r].value = value; | |
1420 | ||
1421 | r++; | |
1422 | ||
1423 | if (r >= DUMP_MAX_REGS) { | |
1424 | pr_err("%s: too many register to dump!\n", | |
1425 | __func__); | |
222460cb JA |
1426 | err = -EINVAL; |
1427 | goto out; | |
5ff9090f LJ |
1428 | } |
1429 | } | |
1430 | } | |
1431 | } | |
222460cb JA |
1432 | out: |
1433 | if (err >= 0) | |
1434 | pr_info("Saved all ABB registers.\n"); | |
1435 | else | |
1436 | pr_info("Failed to save all ABB registers.\n"); | |
5ff9090f LJ |
1437 | } |
1438 | ||
42002c6d MYK |
1439 | static int ab8500_all_banks_open(struct inode *inode, struct file *file) |
1440 | { | |
1441 | struct seq_file *s; | |
1442 | int err; | |
1443 | ||
1444 | err = single_open(file, ab8500_print_all_banks, inode->i_private); | |
1445 | if (!err) { | |
1446 | /* Default buf size in seq_read is not enough */ | |
1447 | s = (struct seq_file *)file->private_data; | |
1448 | s->size = (PAGE_SIZE * 2); | |
1449 | s->buf = kmalloc(s->size, GFP_KERNEL); | |
1450 | if (!s->buf) { | |
1451 | single_release(inode, file); | |
1452 | err = -ENOMEM; | |
1453 | } | |
1454 | } | |
1455 | return err; | |
1456 | } | |
1457 | ||
1458 | static const struct file_operations ab8500_all_banks_fops = { | |
1459 | .open = ab8500_all_banks_open, | |
1460 | .read = seq_read, | |
1461 | .llseek = seq_lseek, | |
1462 | .release = single_release, | |
1463 | .owner = THIS_MODULE, | |
1464 | }; | |
1465 | ||
5814fc35 MW |
1466 | static int ab8500_bank_print(struct seq_file *s, void *p) |
1467 | { | |
9a503a7d JP |
1468 | seq_printf(s, "0x%02X\n", debug_bank); |
1469 | return 0; | |
5814fc35 MW |
1470 | } |
1471 | ||
1472 | static int ab8500_bank_open(struct inode *inode, struct file *file) | |
1473 | { | |
d7b9f322 | 1474 | return single_open(file, ab8500_bank_print, inode->i_private); |
5814fc35 MW |
1475 | } |
1476 | ||
1477 | static ssize_t ab8500_bank_write(struct file *file, | |
d7b9f322 MW |
1478 | const char __user *user_buf, |
1479 | size_t count, loff_t *ppos) | |
5814fc35 | 1480 | { |
d7b9f322 | 1481 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
d7b9f322 MW |
1482 | unsigned long user_bank; |
1483 | int err; | |
1484 | ||
8504d638 | 1485 | err = kstrtoul_from_user(user_buf, count, 0, &user_bank); |
d7b9f322 | 1486 | if (err) |
8504d638 | 1487 | return err; |
d7b9f322 MW |
1488 | |
1489 | if (user_bank >= AB8500_NUM_BANKS) { | |
1490 | dev_err(dev, "debugfs error input > number of banks\n"); | |
1491 | return -EINVAL; | |
1492 | } | |
1493 | ||
1494 | debug_bank = user_bank; | |
1495 | ||
8504d638 | 1496 | return count; |
5814fc35 MW |
1497 | } |
1498 | ||
1499 | static int ab8500_address_print(struct seq_file *s, void *p) | |
1500 | { | |
9a503a7d JP |
1501 | seq_printf(s, "0x%02X\n", debug_address); |
1502 | return 0; | |
5814fc35 MW |
1503 | } |
1504 | ||
1505 | static int ab8500_address_open(struct inode *inode, struct file *file) | |
1506 | { | |
d7b9f322 | 1507 | return single_open(file, ab8500_address_print, inode->i_private); |
5814fc35 MW |
1508 | } |
1509 | ||
1510 | static ssize_t ab8500_address_write(struct file *file, | |
9f9ba15f LJ |
1511 | const char __user *user_buf, |
1512 | size_t count, loff_t *ppos) | |
5814fc35 | 1513 | { |
d7b9f322 | 1514 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
d7b9f322 MW |
1515 | unsigned long user_address; |
1516 | int err; | |
1517 | ||
8504d638 | 1518 | err = kstrtoul_from_user(user_buf, count, 0, &user_address); |
d7b9f322 | 1519 | if (err) |
8504d638 PH |
1520 | return err; |
1521 | ||
d7b9f322 MW |
1522 | if (user_address > 0xff) { |
1523 | dev_err(dev, "debugfs error input > 0xff\n"); | |
1524 | return -EINVAL; | |
1525 | } | |
1526 | debug_address = user_address; | |
7b830ae4 | 1527 | |
8504d638 | 1528 | return count; |
5814fc35 MW |
1529 | } |
1530 | ||
1531 | static int ab8500_val_print(struct seq_file *s, void *p) | |
1532 | { | |
d7b9f322 MW |
1533 | struct device *dev = s->private; |
1534 | int ret; | |
1535 | u8 regvalue; | |
1536 | ||
1537 | ret = abx500_get_register_interruptible(dev, | |
1538 | (u8)debug_bank, (u8)debug_address, ®value); | |
1539 | if (ret < 0) { | |
1540 | dev_err(dev, "abx500_get_reg fail %d, %d\n", | |
1541 | ret, __LINE__); | |
1542 | return -EINVAL; | |
1543 | } | |
1544 | seq_printf(s, "0x%02X\n", regvalue); | |
1545 | ||
1546 | return 0; | |
5814fc35 MW |
1547 | } |
1548 | ||
1549 | static int ab8500_val_open(struct inode *inode, struct file *file) | |
1550 | { | |
d7b9f322 | 1551 | return single_open(file, ab8500_val_print, inode->i_private); |
5814fc35 MW |
1552 | } |
1553 | ||
1554 | static ssize_t ab8500_val_write(struct file *file, | |
9f9ba15f LJ |
1555 | const char __user *user_buf, |
1556 | size_t count, loff_t *ppos) | |
5814fc35 | 1557 | { |
d7b9f322 | 1558 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
d7b9f322 MW |
1559 | unsigned long user_val; |
1560 | int err; | |
1561 | ||
8504d638 | 1562 | err = kstrtoul_from_user(user_buf, count, 0, &user_val); |
d7b9f322 | 1563 | if (err) |
8504d638 PH |
1564 | return err; |
1565 | ||
d7b9f322 MW |
1566 | if (user_val > 0xff) { |
1567 | dev_err(dev, "debugfs error input > 0xff\n"); | |
1568 | return -EINVAL; | |
1569 | } | |
1570 | err = abx500_set_register_interruptible(dev, | |
1571 | (u8)debug_bank, debug_address, (u8)user_val); | |
1572 | if (err < 0) { | |
4362175d | 1573 | pr_err("abx500_set_reg failed %d, %d", err, __LINE__); |
d7b9f322 MW |
1574 | return -EINVAL; |
1575 | } | |
1576 | ||
8504d638 | 1577 | return count; |
5814fc35 MW |
1578 | } |
1579 | ||
8f0eb43b BJ |
1580 | /* |
1581 | * Interrupt status | |
1582 | */ | |
1583 | static u32 num_interrupts[AB8500_MAX_NR_IRQS]; | |
2cf64e26 | 1584 | static u32 num_wake_interrupts[AB8500_MAX_NR_IRQS]; |
8f0eb43b BJ |
1585 | static int num_interrupt_lines; |
1586 | ||
2cf64e26 JA |
1587 | bool __attribute__((weak)) suspend_test_wake_cause_interrupt_is_mine(u32 my_int) |
1588 | { | |
1589 | return false; | |
1590 | } | |
1591 | ||
8f0eb43b BJ |
1592 | void ab8500_debug_register_interrupt(int line) |
1593 | { | |
2cf64e26 | 1594 | if (line < num_interrupt_lines) { |
8f0eb43b | 1595 | num_interrupts[line]++; |
6999181e | 1596 | if (suspend_test_wake_cause_interrupt_is_mine(irq_ab8500)) |
2cf64e26 JA |
1597 | num_wake_interrupts[line]++; |
1598 | } | |
8f0eb43b BJ |
1599 | } |
1600 | ||
1601 | static int ab8500_interrupts_print(struct seq_file *s, void *p) | |
1602 | { | |
1603 | int line; | |
1604 | ||
4362175d | 1605 | seq_puts(s, "name: number: number of: wake:\n"); |
2cf64e26 JA |
1606 | |
1607 | for (line = 0; line < num_interrupt_lines; line++) { | |
1608 | struct irq_desc *desc = irq_to_desc(line + irq_first); | |
8f0eb43b | 1609 | |
9a503a7d JP |
1610 | seq_printf(s, "%3i: %6i %4i", |
1611 | line, | |
2cf64e26 JA |
1612 | num_interrupts[line], |
1613 | num_wake_interrupts[line]); | |
1614 | ||
1615 | if (desc && desc->name) | |
1616 | seq_printf(s, "-%-8s", desc->name); | |
7c0b2380 DC |
1617 | if (desc && desc->action) { |
1618 | struct irqaction *action = desc->action; | |
1619 | ||
2cf64e26 JA |
1620 | seq_printf(s, " %s", action->name); |
1621 | while ((action = action->next) != NULL) | |
1622 | seq_printf(s, ", %s", action->name); | |
1623 | } | |
1624 | seq_putc(s, '\n'); | |
1625 | } | |
8f0eb43b BJ |
1626 | |
1627 | return 0; | |
1628 | } | |
1629 | ||
1630 | static int ab8500_interrupts_open(struct inode *inode, struct file *file) | |
1631 | { | |
1632 | return single_open(file, ab8500_interrupts_print, inode->i_private); | |
1633 | } | |
1634 | ||
0fbce76e | 1635 | /* |
1636 | * - HWREG DB8500 formated routines | |
1637 | */ | |
1638 | static int ab8500_hwreg_print(struct seq_file *s, void *d) | |
1639 | { | |
1640 | struct device *dev = s->private; | |
1641 | int ret; | |
1642 | u8 regvalue; | |
1643 | ||
1644 | ret = abx500_get_register_interruptible(dev, | |
1645 | (u8)hwreg_cfg.bank, (u8)hwreg_cfg.addr, ®value); | |
1646 | if (ret < 0) { | |
1647 | dev_err(dev, "abx500_get_reg fail %d, %d\n", | |
1648 | ret, __LINE__); | |
1649 | return -EINVAL; | |
1650 | } | |
1651 | ||
1652 | if (hwreg_cfg.shift >= 0) | |
1653 | regvalue >>= hwreg_cfg.shift; | |
1654 | else | |
1655 | regvalue <<= -hwreg_cfg.shift; | |
1656 | regvalue &= hwreg_cfg.mask; | |
1657 | ||
1658 | if (REG_FMT_DEC(&hwreg_cfg)) | |
1659 | seq_printf(s, "%d\n", regvalue); | |
1660 | else | |
1661 | seq_printf(s, "0x%02X\n", regvalue); | |
1662 | return 0; | |
1663 | } | |
1664 | ||
1665 | static int ab8500_hwreg_open(struct inode *inode, struct file *file) | |
1666 | { | |
1667 | return single_open(file, ab8500_hwreg_print, inode->i_private); | |
1668 | } | |
1669 | ||
c7ebaee2 LJ |
1670 | #define AB8500_SUPPLY_CONTROL_CONFIG_1 0x01 |
1671 | #define AB8500_SUPPLY_CONTROL_REG 0x00 | |
1672 | #define AB8500_FIRST_SIM_REG 0x80 | |
1673 | #define AB8500_LAST_SIM_REG 0x8B | |
1674 | #define AB8505_LAST_SIM_REG 0x8C | |
1675 | ||
1676 | static int ab8500_print_modem_registers(struct seq_file *s, void *p) | |
1677 | { | |
1678 | struct device *dev = s->private; | |
1679 | struct ab8500 *ab8500; | |
1680 | int err; | |
1681 | u8 value; | |
1682 | u8 orig_value; | |
1683 | u32 bank = AB8500_REGU_CTRL2; | |
1684 | u32 last_sim_reg = AB8500_LAST_SIM_REG; | |
1685 | u32 reg; | |
1686 | ||
1687 | ab8500 = dev_get_drvdata(dev->parent); | |
1688 | dev_warn(dev, "WARNING! This operation can interfer with modem side\n" | |
1689 | "and should only be done with care\n"); | |
1690 | ||
1691 | err = abx500_get_register_interruptible(dev, | |
1692 | AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, &orig_value); | |
1693 | if (err < 0) { | |
1694 | dev_err(dev, "ab->read fail %d\n", err); | |
1695 | return err; | |
1696 | } | |
1697 | /* Config 1 will allow APE side to read SIM registers */ | |
1698 | err = abx500_set_register_interruptible(dev, | |
1699 | AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, | |
1700 | AB8500_SUPPLY_CONTROL_CONFIG_1); | |
1701 | if (err < 0) { | |
1702 | dev_err(dev, "ab->write fail %d\n", err); | |
1703 | return err; | |
1704 | } | |
1705 | ||
1706 | seq_printf(s, " bank 0x%02X:\n", bank); | |
1707 | ||
1708 | if (is_ab9540(ab8500) || is_ab8505(ab8500)) | |
1709 | last_sim_reg = AB8505_LAST_SIM_REG; | |
1710 | ||
1711 | for (reg = AB8500_FIRST_SIM_REG; reg <= last_sim_reg; reg++) { | |
1712 | err = abx500_get_register_interruptible(dev, | |
1713 | bank, reg, &value); | |
1714 | if (err < 0) { | |
1715 | dev_err(dev, "ab->read fail %d\n", err); | |
1716 | return err; | |
1717 | } | |
9a503a7d | 1718 | seq_printf(s, " [0x%02X/0x%02X]: 0x%02X\n", bank, reg, value); |
c7ebaee2 LJ |
1719 | } |
1720 | err = abx500_set_register_interruptible(dev, | |
1721 | AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, orig_value); | |
1722 | if (err < 0) { | |
1723 | dev_err(dev, "ab->write fail %d\n", err); | |
1724 | return err; | |
1725 | } | |
1726 | return 0; | |
1727 | } | |
1728 | ||
1729 | static int ab8500_modem_open(struct inode *inode, struct file *file) | |
1730 | { | |
4362175d LJ |
1731 | return single_open(file, ab8500_print_modem_registers, |
1732 | inode->i_private); | |
c7ebaee2 LJ |
1733 | } |
1734 | ||
1735 | static const struct file_operations ab8500_modem_fops = { | |
1736 | .open = ab8500_modem_open, | |
1737 | .read = seq_read, | |
1738 | .llseek = seq_lseek, | |
1739 | .release = single_release, | |
1740 | .owner = THIS_MODULE, | |
1741 | }; | |
1742 | ||
1478a316 JB |
1743 | static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p) |
1744 | { | |
1745 | int bat_ctrl_raw; | |
1746 | int bat_ctrl_convert; | |
1747 | struct ab8500_gpadc *gpadc; | |
1748 | ||
8908c049 | 1749 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
1750 | bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL, |
1751 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 1752 | bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
73482346 | 1753 | BAT_CTRL, bat_ctrl_raw); |
1478a316 | 1754 | |
9a503a7d JP |
1755 | seq_printf(s, "%d,0x%X\n", bat_ctrl_convert, bat_ctrl_raw); |
1756 | ||
1757 | return 0; | |
1478a316 JB |
1758 | } |
1759 | ||
1760 | static int ab8500_gpadc_bat_ctrl_open(struct inode *inode, struct file *file) | |
1761 | { | |
4362175d LJ |
1762 | return single_open(file, ab8500_gpadc_bat_ctrl_print, |
1763 | inode->i_private); | |
1478a316 JB |
1764 | } |
1765 | ||
1766 | static const struct file_operations ab8500_gpadc_bat_ctrl_fops = { | |
1767 | .open = ab8500_gpadc_bat_ctrl_open, | |
1768 | .read = seq_read, | |
1769 | .llseek = seq_lseek, | |
1770 | .release = single_release, | |
1771 | .owner = THIS_MODULE, | |
1772 | }; | |
1773 | ||
1774 | static int ab8500_gpadc_btemp_ball_print(struct seq_file *s, void *p) | |
1775 | { | |
1776 | int btemp_ball_raw; | |
1777 | int btemp_ball_convert; | |
1778 | struct ab8500_gpadc *gpadc; | |
1779 | ||
8908c049 | 1780 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
1781 | btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL, |
1782 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 1783 | btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL, |
73482346 | 1784 | btemp_ball_raw); |
1478a316 | 1785 | |
9a503a7d JP |
1786 | seq_printf(s, "%d,0x%X\n", btemp_ball_convert, btemp_ball_raw); |
1787 | ||
1788 | return 0; | |
1478a316 JB |
1789 | } |
1790 | ||
1791 | static int ab8500_gpadc_btemp_ball_open(struct inode *inode, | |
9f9ba15f | 1792 | struct file *file) |
1478a316 | 1793 | { |
4362175d LJ |
1794 | return single_open(file, ab8500_gpadc_btemp_ball_print, |
1795 | inode->i_private); | |
1478a316 JB |
1796 | } |
1797 | ||
1798 | static const struct file_operations ab8500_gpadc_btemp_ball_fops = { | |
1799 | .open = ab8500_gpadc_btemp_ball_open, | |
1800 | .read = seq_read, | |
1801 | .llseek = seq_lseek, | |
1802 | .release = single_release, | |
1803 | .owner = THIS_MODULE, | |
1804 | }; | |
1805 | ||
1806 | static int ab8500_gpadc_main_charger_v_print(struct seq_file *s, void *p) | |
1807 | { | |
1808 | int main_charger_v_raw; | |
1809 | int main_charger_v_convert; | |
1810 | struct ab8500_gpadc *gpadc; | |
1811 | ||
8908c049 | 1812 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
1813 | main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V, |
1814 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 1815 | main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
73482346 | 1816 | MAIN_CHARGER_V, main_charger_v_raw); |
1478a316 | 1817 | |
9a503a7d JP |
1818 | seq_printf(s, "%d,0x%X\n", main_charger_v_convert, main_charger_v_raw); |
1819 | ||
1820 | return 0; | |
1478a316 JB |
1821 | } |
1822 | ||
1823 | static int ab8500_gpadc_main_charger_v_open(struct inode *inode, | |
9f9ba15f | 1824 | struct file *file) |
1478a316 JB |
1825 | { |
1826 | return single_open(file, ab8500_gpadc_main_charger_v_print, | |
9f9ba15f | 1827 | inode->i_private); |
1478a316 JB |
1828 | } |
1829 | ||
1830 | static const struct file_operations ab8500_gpadc_main_charger_v_fops = { | |
1831 | .open = ab8500_gpadc_main_charger_v_open, | |
1832 | .read = seq_read, | |
1833 | .llseek = seq_lseek, | |
1834 | .release = single_release, | |
1835 | .owner = THIS_MODULE, | |
1836 | }; | |
1837 | ||
1838 | static int ab8500_gpadc_acc_detect1_print(struct seq_file *s, void *p) | |
1839 | { | |
1840 | int acc_detect1_raw; | |
1841 | int acc_detect1_convert; | |
1842 | struct ab8500_gpadc *gpadc; | |
1843 | ||
8908c049 | 1844 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
1845 | acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1, |
1846 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 1847 | acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1, |
73482346 | 1848 | acc_detect1_raw); |
1478a316 | 1849 | |
9a503a7d JP |
1850 | seq_printf(s, "%d,0x%X\n", acc_detect1_convert, acc_detect1_raw); |
1851 | ||
1852 | return 0; | |
1478a316 JB |
1853 | } |
1854 | ||
1855 | static int ab8500_gpadc_acc_detect1_open(struct inode *inode, | |
9f9ba15f | 1856 | struct file *file) |
1478a316 JB |
1857 | { |
1858 | return single_open(file, ab8500_gpadc_acc_detect1_print, | |
9f9ba15f | 1859 | inode->i_private); |
1478a316 JB |
1860 | } |
1861 | ||
1862 | static const struct file_operations ab8500_gpadc_acc_detect1_fops = { | |
1863 | .open = ab8500_gpadc_acc_detect1_open, | |
1864 | .read = seq_read, | |
1865 | .llseek = seq_lseek, | |
1866 | .release = single_release, | |
1867 | .owner = THIS_MODULE, | |
1868 | }; | |
1869 | ||
1870 | static int ab8500_gpadc_acc_detect2_print(struct seq_file *s, void *p) | |
1871 | { | |
1872 | int acc_detect2_raw; | |
1873 | int acc_detect2_convert; | |
1874 | struct ab8500_gpadc *gpadc; | |
1875 | ||
8908c049 | 1876 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
1877 | acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2, |
1878 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 1879 | acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
73482346 | 1880 | ACC_DETECT2, acc_detect2_raw); |
1478a316 | 1881 | |
9a503a7d JP |
1882 | seq_printf(s, "%d,0x%X\n", acc_detect2_convert, acc_detect2_raw); |
1883 | ||
1884 | return 0; | |
1478a316 JB |
1885 | } |
1886 | ||
1887 | static int ab8500_gpadc_acc_detect2_open(struct inode *inode, | |
1888 | struct file *file) | |
1889 | { | |
1890 | return single_open(file, ab8500_gpadc_acc_detect2_print, | |
9f9ba15f | 1891 | inode->i_private); |
1478a316 JB |
1892 | } |
1893 | ||
1894 | static const struct file_operations ab8500_gpadc_acc_detect2_fops = { | |
1895 | .open = ab8500_gpadc_acc_detect2_open, | |
1896 | .read = seq_read, | |
1897 | .llseek = seq_lseek, | |
1898 | .release = single_release, | |
1899 | .owner = THIS_MODULE, | |
1900 | }; | |
1901 | ||
1902 | static int ab8500_gpadc_aux1_print(struct seq_file *s, void *p) | |
1903 | { | |
1904 | int aux1_raw; | |
1905 | int aux1_convert; | |
1906 | struct ab8500_gpadc *gpadc; | |
1907 | ||
8908c049 | 1908 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
1909 | aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1, |
1910 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 1911 | aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1, |
73482346 | 1912 | aux1_raw); |
1478a316 | 1913 | |
9a503a7d JP |
1914 | seq_printf(s, "%d,0x%X\n", aux1_convert, aux1_raw); |
1915 | ||
1916 | return 0; | |
1478a316 JB |
1917 | } |
1918 | ||
1919 | static int ab8500_gpadc_aux1_open(struct inode *inode, struct file *file) | |
1920 | { | |
1921 | return single_open(file, ab8500_gpadc_aux1_print, inode->i_private); | |
1922 | } | |
1923 | ||
1924 | static const struct file_operations ab8500_gpadc_aux1_fops = { | |
1925 | .open = ab8500_gpadc_aux1_open, | |
1926 | .read = seq_read, | |
1927 | .llseek = seq_lseek, | |
1928 | .release = single_release, | |
1929 | .owner = THIS_MODULE, | |
1930 | }; | |
1931 | ||
1932 | static int ab8500_gpadc_aux2_print(struct seq_file *s, void *p) | |
1933 | { | |
1934 | int aux2_raw; | |
1935 | int aux2_convert; | |
1936 | struct ab8500_gpadc *gpadc; | |
1937 | ||
8908c049 | 1938 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
1939 | aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2, |
1940 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 1941 | aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2, |
73482346 | 1942 | aux2_raw); |
1478a316 | 1943 | |
9a503a7d JP |
1944 | seq_printf(s, "%d,0x%X\n", aux2_convert, aux2_raw); |
1945 | ||
1946 | return 0; | |
1478a316 JB |
1947 | } |
1948 | ||
1949 | static int ab8500_gpadc_aux2_open(struct inode *inode, struct file *file) | |
1950 | { | |
1951 | return single_open(file, ab8500_gpadc_aux2_print, inode->i_private); | |
1952 | } | |
1953 | ||
1954 | static const struct file_operations ab8500_gpadc_aux2_fops = { | |
1955 | .open = ab8500_gpadc_aux2_open, | |
1956 | .read = seq_read, | |
1957 | .llseek = seq_lseek, | |
1958 | .release = single_release, | |
1959 | .owner = THIS_MODULE, | |
1960 | }; | |
1961 | ||
1962 | static int ab8500_gpadc_main_bat_v_print(struct seq_file *s, void *p) | |
1963 | { | |
1964 | int main_bat_v_raw; | |
1965 | int main_bat_v_convert; | |
1966 | struct ab8500_gpadc *gpadc; | |
1967 | ||
8908c049 | 1968 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
1969 | main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V, |
1970 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 1971 | main_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V, |
73482346 | 1972 | main_bat_v_raw); |
1478a316 | 1973 | |
9a503a7d JP |
1974 | seq_printf(s, "%d,0x%X\n", main_bat_v_convert, main_bat_v_raw); |
1975 | ||
1976 | return 0; | |
1478a316 JB |
1977 | } |
1978 | ||
1979 | static int ab8500_gpadc_main_bat_v_open(struct inode *inode, | |
9f9ba15f | 1980 | struct file *file) |
1478a316 | 1981 | { |
4362175d LJ |
1982 | return single_open(file, ab8500_gpadc_main_bat_v_print, |
1983 | inode->i_private); | |
1478a316 JB |
1984 | } |
1985 | ||
1986 | static const struct file_operations ab8500_gpadc_main_bat_v_fops = { | |
1987 | .open = ab8500_gpadc_main_bat_v_open, | |
1988 | .read = seq_read, | |
1989 | .llseek = seq_lseek, | |
1990 | .release = single_release, | |
1991 | .owner = THIS_MODULE, | |
1992 | }; | |
1993 | ||
1994 | static int ab8500_gpadc_vbus_v_print(struct seq_file *s, void *p) | |
1995 | { | |
1996 | int vbus_v_raw; | |
1997 | int vbus_v_convert; | |
1998 | struct ab8500_gpadc *gpadc; | |
1999 | ||
8908c049 | 2000 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
2001 | vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V, |
2002 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 2003 | vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V, |
73482346 | 2004 | vbus_v_raw); |
1478a316 | 2005 | |
9a503a7d JP |
2006 | seq_printf(s, "%d,0x%X\n", vbus_v_convert, vbus_v_raw); |
2007 | ||
2008 | return 0; | |
1478a316 JB |
2009 | } |
2010 | ||
2011 | static int ab8500_gpadc_vbus_v_open(struct inode *inode, struct file *file) | |
2012 | { | |
2013 | return single_open(file, ab8500_gpadc_vbus_v_print, inode->i_private); | |
2014 | } | |
2015 | ||
2016 | static const struct file_operations ab8500_gpadc_vbus_v_fops = { | |
2017 | .open = ab8500_gpadc_vbus_v_open, | |
2018 | .read = seq_read, | |
2019 | .llseek = seq_lseek, | |
2020 | .release = single_release, | |
2021 | .owner = THIS_MODULE, | |
2022 | }; | |
2023 | ||
2024 | static int ab8500_gpadc_main_charger_c_print(struct seq_file *s, void *p) | |
2025 | { | |
2026 | int main_charger_c_raw; | |
2027 | int main_charger_c_convert; | |
2028 | struct ab8500_gpadc *gpadc; | |
2029 | ||
8908c049 | 2030 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
2031 | main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C, |
2032 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 2033 | main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
73482346 | 2034 | MAIN_CHARGER_C, main_charger_c_raw); |
1478a316 | 2035 | |
9a503a7d JP |
2036 | seq_printf(s, "%d,0x%X\n", main_charger_c_convert, main_charger_c_raw); |
2037 | ||
2038 | return 0; | |
1478a316 JB |
2039 | } |
2040 | ||
2041 | static int ab8500_gpadc_main_charger_c_open(struct inode *inode, | |
2042 | struct file *file) | |
2043 | { | |
2044 | return single_open(file, ab8500_gpadc_main_charger_c_print, | |
9f9ba15f | 2045 | inode->i_private); |
1478a316 JB |
2046 | } |
2047 | ||
2048 | static const struct file_operations ab8500_gpadc_main_charger_c_fops = { | |
2049 | .open = ab8500_gpadc_main_charger_c_open, | |
2050 | .read = seq_read, | |
2051 | .llseek = seq_lseek, | |
2052 | .release = single_release, | |
2053 | .owner = THIS_MODULE, | |
2054 | }; | |
2055 | ||
2056 | static int ab8500_gpadc_usb_charger_c_print(struct seq_file *s, void *p) | |
2057 | { | |
2058 | int usb_charger_c_raw; | |
2059 | int usb_charger_c_convert; | |
2060 | struct ab8500_gpadc *gpadc; | |
2061 | ||
8908c049 | 2062 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
2063 | usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C, |
2064 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 2065 | usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
73482346 | 2066 | USB_CHARGER_C, usb_charger_c_raw); |
1478a316 | 2067 | |
9a503a7d JP |
2068 | seq_printf(s, "%d,0x%X\n", usb_charger_c_convert, usb_charger_c_raw); |
2069 | ||
2070 | return 0; | |
1478a316 JB |
2071 | } |
2072 | ||
2073 | static int ab8500_gpadc_usb_charger_c_open(struct inode *inode, | |
2074 | struct file *file) | |
2075 | { | |
2076 | return single_open(file, ab8500_gpadc_usb_charger_c_print, | |
9f9ba15f | 2077 | inode->i_private); |
1478a316 JB |
2078 | } |
2079 | ||
2080 | static const struct file_operations ab8500_gpadc_usb_charger_c_fops = { | |
2081 | .open = ab8500_gpadc_usb_charger_c_open, | |
2082 | .read = seq_read, | |
2083 | .llseek = seq_lseek, | |
2084 | .release = single_release, | |
2085 | .owner = THIS_MODULE, | |
2086 | }; | |
2087 | ||
2088 | static int ab8500_gpadc_bk_bat_v_print(struct seq_file *s, void *p) | |
2089 | { | |
2090 | int bk_bat_v_raw; | |
2091 | int bk_bat_v_convert; | |
2092 | struct ab8500_gpadc *gpadc; | |
2093 | ||
8908c049 | 2094 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
2095 | bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V, |
2096 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 2097 | bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
73482346 | 2098 | BK_BAT_V, bk_bat_v_raw); |
1478a316 | 2099 | |
9a503a7d JP |
2100 | seq_printf(s, "%d,0x%X\n", bk_bat_v_convert, bk_bat_v_raw); |
2101 | ||
2102 | return 0; | |
1478a316 JB |
2103 | } |
2104 | ||
2105 | static int ab8500_gpadc_bk_bat_v_open(struct inode *inode, struct file *file) | |
2106 | { | |
4362175d LJ |
2107 | return single_open(file, ab8500_gpadc_bk_bat_v_print, |
2108 | inode->i_private); | |
1478a316 JB |
2109 | } |
2110 | ||
2111 | static const struct file_operations ab8500_gpadc_bk_bat_v_fops = { | |
2112 | .open = ab8500_gpadc_bk_bat_v_open, | |
2113 | .read = seq_read, | |
2114 | .llseek = seq_lseek, | |
2115 | .release = single_release, | |
2116 | .owner = THIS_MODULE, | |
2117 | }; | |
2118 | ||
2119 | static int ab8500_gpadc_die_temp_print(struct seq_file *s, void *p) | |
2120 | { | |
2121 | int die_temp_raw; | |
2122 | int die_temp_convert; | |
2123 | struct ab8500_gpadc *gpadc; | |
2124 | ||
8908c049 | 2125 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
73482346 LJ |
2126 | die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP, |
2127 | avg_sample, trig_edge, trig_timer, conv_type); | |
1478a316 | 2128 | die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP, |
73482346 | 2129 | die_temp_raw); |
1478a316 | 2130 | |
9a503a7d JP |
2131 | seq_printf(s, "%d,0x%X\n", die_temp_convert, die_temp_raw); |
2132 | ||
2133 | return 0; | |
1478a316 JB |
2134 | } |
2135 | ||
2136 | static int ab8500_gpadc_die_temp_open(struct inode *inode, struct file *file) | |
2137 | { | |
4362175d LJ |
2138 | return single_open(file, ab8500_gpadc_die_temp_print, |
2139 | inode->i_private); | |
1478a316 JB |
2140 | } |
2141 | ||
2142 | static const struct file_operations ab8500_gpadc_die_temp_fops = { | |
2143 | .open = ab8500_gpadc_die_temp_open, | |
2144 | .read = seq_read, | |
2145 | .llseek = seq_lseek, | |
2146 | .release = single_release, | |
2147 | .owner = THIS_MODULE, | |
2148 | }; | |
2149 | ||
127629d7 LJ |
2150 | static int ab8500_gpadc_usb_id_print(struct seq_file *s, void *p) |
2151 | { | |
2152 | int usb_id_raw; | |
2153 | int usb_id_convert; | |
2154 | struct ab8500_gpadc *gpadc; | |
2155 | ||
2156 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); | |
2157 | usb_id_raw = ab8500_gpadc_read_raw(gpadc, USB_ID, | |
2158 | avg_sample, trig_edge, trig_timer, conv_type); | |
2159 | usb_id_convert = ab8500_gpadc_ad_to_voltage(gpadc, USB_ID, | |
2160 | usb_id_raw); | |
2161 | ||
9a503a7d JP |
2162 | seq_printf(s, "%d,0x%X\n", usb_id_convert, usb_id_raw); |
2163 | ||
2164 | return 0; | |
127629d7 LJ |
2165 | } |
2166 | ||
2167 | static int ab8500_gpadc_usb_id_open(struct inode *inode, struct file *file) | |
2168 | { | |
2169 | return single_open(file, ab8500_gpadc_usb_id_print, inode->i_private); | |
2170 | } | |
2171 | ||
2172 | static const struct file_operations ab8500_gpadc_usb_id_fops = { | |
2173 | .open = ab8500_gpadc_usb_id_open, | |
2174 | .read = seq_read, | |
2175 | .llseek = seq_lseek, | |
2176 | .release = single_release, | |
2177 | .owner = THIS_MODULE, | |
2178 | }; | |
2179 | ||
bc6b4132 LJ |
2180 | static int ab8540_gpadc_xtal_temp_print(struct seq_file *s, void *p) |
2181 | { | |
2182 | int xtal_temp_raw; | |
2183 | int xtal_temp_convert; | |
2184 | struct ab8500_gpadc *gpadc; | |
2185 | ||
2186 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); | |
2187 | xtal_temp_raw = ab8500_gpadc_read_raw(gpadc, XTAL_TEMP, | |
2188 | avg_sample, trig_edge, trig_timer, conv_type); | |
2189 | xtal_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, XTAL_TEMP, | |
2190 | xtal_temp_raw); | |
2191 | ||
9a503a7d JP |
2192 | seq_printf(s, "%d,0x%X\n", xtal_temp_convert, xtal_temp_raw); |
2193 | ||
2194 | return 0; | |
bc6b4132 LJ |
2195 | } |
2196 | ||
2197 | static int ab8540_gpadc_xtal_temp_open(struct inode *inode, struct file *file) | |
2198 | { | |
2199 | return single_open(file, ab8540_gpadc_xtal_temp_print, | |
9f9ba15f | 2200 | inode->i_private); |
bc6b4132 LJ |
2201 | } |
2202 | ||
2203 | static const struct file_operations ab8540_gpadc_xtal_temp_fops = { | |
2204 | .open = ab8540_gpadc_xtal_temp_open, | |
2205 | .read = seq_read, | |
2206 | .llseek = seq_lseek, | |
2207 | .release = single_release, | |
2208 | .owner = THIS_MODULE, | |
2209 | }; | |
2210 | ||
2211 | static int ab8540_gpadc_vbat_true_meas_print(struct seq_file *s, void *p) | |
2212 | { | |
2213 | int vbat_true_meas_raw; | |
2214 | int vbat_true_meas_convert; | |
2215 | struct ab8500_gpadc *gpadc; | |
2216 | ||
2217 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); | |
2218 | vbat_true_meas_raw = ab8500_gpadc_read_raw(gpadc, VBAT_TRUE_MEAS, | |
2219 | avg_sample, trig_edge, trig_timer, conv_type); | |
4362175d LJ |
2220 | vbat_true_meas_convert = |
2221 | ab8500_gpadc_ad_to_voltage(gpadc, VBAT_TRUE_MEAS, | |
2222 | vbat_true_meas_raw); | |
bc6b4132 | 2223 | |
9a503a7d JP |
2224 | seq_printf(s, "%d,0x%X\n", vbat_true_meas_convert, vbat_true_meas_raw); |
2225 | ||
2226 | return 0; | |
bc6b4132 LJ |
2227 | } |
2228 | ||
2229 | static int ab8540_gpadc_vbat_true_meas_open(struct inode *inode, | |
2230 | struct file *file) | |
2231 | { | |
2232 | return single_open(file, ab8540_gpadc_vbat_true_meas_print, | |
9f9ba15f | 2233 | inode->i_private); |
bc6b4132 LJ |
2234 | } |
2235 | ||
2236 | static const struct file_operations ab8540_gpadc_vbat_true_meas_fops = { | |
2237 | .open = ab8540_gpadc_vbat_true_meas_open, | |
2238 | .read = seq_read, | |
2239 | .llseek = seq_lseek, | |
2240 | .release = single_release, | |
2241 | .owner = THIS_MODULE, | |
2242 | }; | |
2243 | ||
2244 | static int ab8540_gpadc_bat_ctrl_and_ibat_print(struct seq_file *s, void *p) | |
2245 | { | |
2246 | int bat_ctrl_raw; | |
2247 | int bat_ctrl_convert; | |
2248 | int ibat_raw; | |
2249 | int ibat_convert; | |
2250 | struct ab8500_gpadc *gpadc; | |
2251 | ||
2252 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); | |
2253 | bat_ctrl_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_CTRL_AND_IBAT, | |
2254 | avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw); | |
2255 | ||
2256 | bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc, BAT_CTRL, | |
2257 | bat_ctrl_raw); | |
2258 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, | |
2259 | ibat_raw); | |
2260 | ||
9a503a7d JP |
2261 | seq_printf(s, |
2262 | "%d,0x%X\n" | |
2263 | "%d,0x%X\n", | |
2264 | bat_ctrl_convert, bat_ctrl_raw, | |
2265 | ibat_convert, ibat_raw); | |
2266 | ||
2267 | return 0; | |
bc6b4132 LJ |
2268 | } |
2269 | ||
2270 | static int ab8540_gpadc_bat_ctrl_and_ibat_open(struct inode *inode, | |
2271 | struct file *file) | |
2272 | { | |
2273 | return single_open(file, ab8540_gpadc_bat_ctrl_and_ibat_print, | |
9f9ba15f | 2274 | inode->i_private); |
bc6b4132 LJ |
2275 | } |
2276 | ||
2277 | static const struct file_operations ab8540_gpadc_bat_ctrl_and_ibat_fops = { | |
2278 | .open = ab8540_gpadc_bat_ctrl_and_ibat_open, | |
2279 | .read = seq_read, | |
2280 | .llseek = seq_lseek, | |
2281 | .release = single_release, | |
2282 | .owner = THIS_MODULE, | |
2283 | }; | |
2284 | ||
2285 | static int ab8540_gpadc_vbat_meas_and_ibat_print(struct seq_file *s, void *p) | |
2286 | { | |
2287 | int vbat_meas_raw; | |
2288 | int vbat_meas_convert; | |
2289 | int ibat_raw; | |
2290 | int ibat_convert; | |
2291 | struct ab8500_gpadc *gpadc; | |
2292 | ||
2293 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); | |
2294 | vbat_meas_raw = ab8500_gpadc_double_read_raw(gpadc, VBAT_MEAS_AND_IBAT, | |
2295 | avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw); | |
2296 | vbat_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V, | |
2297 | vbat_meas_raw); | |
2298 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, | |
2299 | ibat_raw); | |
2300 | ||
9a503a7d JP |
2301 | seq_printf(s, |
2302 | "%d,0x%X\n" | |
2303 | "%d,0x%X\n", | |
2304 | vbat_meas_convert, vbat_meas_raw, | |
2305 | ibat_convert, ibat_raw); | |
2306 | ||
2307 | return 0; | |
bc6b4132 LJ |
2308 | } |
2309 | ||
2310 | static int ab8540_gpadc_vbat_meas_and_ibat_open(struct inode *inode, | |
2311 | struct file *file) | |
2312 | { | |
2313 | return single_open(file, ab8540_gpadc_vbat_meas_and_ibat_print, | |
9f9ba15f | 2314 | inode->i_private); |
bc6b4132 LJ |
2315 | } |
2316 | ||
2317 | static const struct file_operations ab8540_gpadc_vbat_meas_and_ibat_fops = { | |
2318 | .open = ab8540_gpadc_vbat_meas_and_ibat_open, | |
2319 | .read = seq_read, | |
2320 | .llseek = seq_lseek, | |
2321 | .release = single_release, | |
2322 | .owner = THIS_MODULE, | |
2323 | }; | |
2324 | ||
4362175d LJ |
2325 | static int ab8540_gpadc_vbat_true_meas_and_ibat_print(struct seq_file *s, |
2326 | void *p) | |
bc6b4132 LJ |
2327 | { |
2328 | int vbat_true_meas_raw; | |
2329 | int vbat_true_meas_convert; | |
2330 | int ibat_raw; | |
2331 | int ibat_convert; | |
2332 | struct ab8500_gpadc *gpadc; | |
2333 | ||
2334 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); | |
2335 | vbat_true_meas_raw = ab8500_gpadc_double_read_raw(gpadc, | |
2336 | VBAT_TRUE_MEAS_AND_IBAT, avg_sample, trig_edge, | |
2337 | trig_timer, conv_type, &ibat_raw); | |
2338 | vbat_true_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, | |
2339 | VBAT_TRUE_MEAS, vbat_true_meas_raw); | |
2340 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, | |
2341 | ibat_raw); | |
2342 | ||
9a503a7d JP |
2343 | seq_printf(s, |
2344 | "%d,0x%X\n" | |
2345 | "%d,0x%X\n", | |
2346 | vbat_true_meas_convert, vbat_true_meas_raw, | |
2347 | ibat_convert, ibat_raw); | |
2348 | ||
2349 | return 0; | |
bc6b4132 LJ |
2350 | } |
2351 | ||
2352 | static int ab8540_gpadc_vbat_true_meas_and_ibat_open(struct inode *inode, | |
2353 | struct file *file) | |
2354 | { | |
2355 | return single_open(file, ab8540_gpadc_vbat_true_meas_and_ibat_print, | |
9f9ba15f | 2356 | inode->i_private); |
bc6b4132 LJ |
2357 | } |
2358 | ||
4362175d LJ |
2359 | static const struct file_operations |
2360 | ab8540_gpadc_vbat_true_meas_and_ibat_fops = { | |
bc6b4132 LJ |
2361 | .open = ab8540_gpadc_vbat_true_meas_and_ibat_open, |
2362 | .read = seq_read, | |
2363 | .llseek = seq_lseek, | |
2364 | .release = single_release, | |
2365 | .owner = THIS_MODULE, | |
2366 | }; | |
2367 | ||
2368 | static int ab8540_gpadc_bat_temp_and_ibat_print(struct seq_file *s, void *p) | |
2369 | { | |
2370 | int bat_temp_raw; | |
2371 | int bat_temp_convert; | |
2372 | int ibat_raw; | |
2373 | int ibat_convert; | |
2374 | struct ab8500_gpadc *gpadc; | |
2375 | ||
2376 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); | |
2377 | bat_temp_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_TEMP_AND_IBAT, | |
2378 | avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw); | |
2379 | bat_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL, | |
2380 | bat_temp_raw); | |
2381 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, | |
2382 | ibat_raw); | |
2383 | ||
9a503a7d JP |
2384 | seq_printf(s, |
2385 | "%d,0x%X\n" | |
2386 | "%d,0x%X\n", | |
2387 | bat_temp_convert, bat_temp_raw, | |
2388 | ibat_convert, ibat_raw); | |
2389 | ||
2390 | return 0; | |
bc6b4132 LJ |
2391 | } |
2392 | ||
2393 | static int ab8540_gpadc_bat_temp_and_ibat_open(struct inode *inode, | |
2394 | struct file *file) | |
2395 | { | |
2396 | return single_open(file, ab8540_gpadc_bat_temp_and_ibat_print, | |
9f9ba15f | 2397 | inode->i_private); |
bc6b4132 LJ |
2398 | } |
2399 | ||
2400 | static const struct file_operations ab8540_gpadc_bat_temp_and_ibat_fops = { | |
2401 | .open = ab8540_gpadc_bat_temp_and_ibat_open, | |
2402 | .read = seq_read, | |
2403 | .llseek = seq_lseek, | |
2404 | .release = single_release, | |
2405 | .owner = THIS_MODULE, | |
2406 | }; | |
2407 | ||
2408 | static int ab8540_gpadc_otp_cal_print(struct seq_file *s, void *p) | |
2409 | { | |
2410 | struct ab8500_gpadc *gpadc; | |
2411 | u16 vmain_l, vmain_h, btemp_l, btemp_h; | |
2412 | u16 vbat_l, vbat_h, ibat_l, ibat_h; | |
2413 | ||
2414 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); | |
2415 | ab8540_gpadc_get_otp(gpadc, &vmain_l, &vmain_h, &btemp_l, &btemp_h, | |
2416 | &vbat_l, &vbat_h, &ibat_l, &ibat_h); | |
9a503a7d JP |
2417 | seq_printf(s, |
2418 | "VMAIN_L:0x%X\n" | |
2419 | "VMAIN_H:0x%X\n" | |
2420 | "BTEMP_L:0x%X\n" | |
2421 | "BTEMP_H:0x%X\n" | |
2422 | "VBAT_L:0x%X\n" | |
2423 | "VBAT_H:0x%X\n" | |
2424 | "IBAT_L:0x%X\n" | |
2425 | "IBAT_H:0x%X\n", | |
2426 | vmain_l, vmain_h, btemp_l, btemp_h, | |
2427 | vbat_l, vbat_h, ibat_l, ibat_h); | |
2428 | ||
2429 | return 0; | |
bc6b4132 LJ |
2430 | } |
2431 | ||
2432 | static int ab8540_gpadc_otp_cal_open(struct inode *inode, struct file *file) | |
2433 | { | |
2434 | return single_open(file, ab8540_gpadc_otp_cal_print, inode->i_private); | |
2435 | } | |
2436 | ||
2437 | static const struct file_operations ab8540_gpadc_otp_calib_fops = { | |
2438 | .open = ab8540_gpadc_otp_cal_open, | |
2439 | .read = seq_read, | |
2440 | .llseek = seq_lseek, | |
2441 | .release = single_release, | |
2442 | .owner = THIS_MODULE, | |
2443 | }; | |
2444 | ||
73482346 LJ |
2445 | static int ab8500_gpadc_avg_sample_print(struct seq_file *s, void *p) |
2446 | { | |
9a503a7d JP |
2447 | seq_printf(s, "%d\n", avg_sample); |
2448 | ||
2449 | return 0; | |
73482346 LJ |
2450 | } |
2451 | ||
2452 | static int ab8500_gpadc_avg_sample_open(struct inode *inode, struct file *file) | |
2453 | { | |
2454 | return single_open(file, ab8500_gpadc_avg_sample_print, | |
9f9ba15f | 2455 | inode->i_private); |
73482346 LJ |
2456 | } |
2457 | ||
2458 | static ssize_t ab8500_gpadc_avg_sample_write(struct file *file, | |
2459 | const char __user *user_buf, | |
2460 | size_t count, loff_t *ppos) | |
2461 | { | |
2462 | struct device *dev = ((struct seq_file *)(file->private_data))->private; | |
73482346 LJ |
2463 | unsigned long user_avg_sample; |
2464 | int err; | |
2465 | ||
7b830ae4 | 2466 | err = kstrtoul_from_user(user_buf, count, 0, &user_avg_sample); |
73482346 | 2467 | if (err) |
7b830ae4 | 2468 | return err; |
2469 | ||
73482346 LJ |
2470 | if ((user_avg_sample == SAMPLE_1) || (user_avg_sample == SAMPLE_4) |
2471 | || (user_avg_sample == SAMPLE_8) | |
2472 | || (user_avg_sample == SAMPLE_16)) { | |
2473 | avg_sample = (u8) user_avg_sample; | |
2474 | } else { | |
4362175d LJ |
2475 | dev_err(dev, |
2476 | "debugfs err input: should be egal to 1, 4, 8 or 16\n"); | |
73482346 LJ |
2477 | return -EINVAL; |
2478 | } | |
7b830ae4 | 2479 | |
2480 | return count; | |
73482346 LJ |
2481 | } |
2482 | ||
2483 | static const struct file_operations ab8500_gpadc_avg_sample_fops = { | |
2484 | .open = ab8500_gpadc_avg_sample_open, | |
2485 | .read = seq_read, | |
2486 | .write = ab8500_gpadc_avg_sample_write, | |
2487 | .llseek = seq_lseek, | |
2488 | .release = single_release, | |
2489 | .owner = THIS_MODULE, | |
2490 | }; | |
2491 | ||
2492 | static int ab8500_gpadc_trig_edge_print(struct seq_file *s, void *p) | |
2493 | { | |
9a503a7d JP |
2494 | seq_printf(s, "%d\n", trig_edge); |
2495 | ||
2496 | return 0; | |
73482346 LJ |
2497 | } |
2498 | ||
2499 | static int ab8500_gpadc_trig_edge_open(struct inode *inode, struct file *file) | |
2500 | { | |
2501 | return single_open(file, ab8500_gpadc_trig_edge_print, | |
9f9ba15f | 2502 | inode->i_private); |
73482346 LJ |
2503 | } |
2504 | ||
2505 | static ssize_t ab8500_gpadc_trig_edge_write(struct file *file, | |
2506 | const char __user *user_buf, | |
2507 | size_t count, loff_t *ppos) | |
2508 | { | |
2509 | struct device *dev = ((struct seq_file *)(file->private_data))->private; | |
73482346 LJ |
2510 | unsigned long user_trig_edge; |
2511 | int err; | |
2512 | ||
7b830ae4 | 2513 | err = kstrtoul_from_user(user_buf, count, 0, &user_trig_edge); |
73482346 | 2514 | if (err) |
7b830ae4 | 2515 | return err; |
2516 | ||
73482346 LJ |
2517 | if ((user_trig_edge == RISING_EDGE) |
2518 | || (user_trig_edge == FALLING_EDGE)) { | |
2519 | trig_edge = (u8) user_trig_edge; | |
2520 | } else { | |
2521 | dev_err(dev, "Wrong input:\n" | |
2522 | "Enter 0. Rising edge\n" | |
2523 | "Enter 1. Falling edge\n"); | |
2524 | return -EINVAL; | |
2525 | } | |
7b830ae4 | 2526 | |
2527 | return count; | |
73482346 LJ |
2528 | } |
2529 | ||
2530 | static const struct file_operations ab8500_gpadc_trig_edge_fops = { | |
2531 | .open = ab8500_gpadc_trig_edge_open, | |
2532 | .read = seq_read, | |
2533 | .write = ab8500_gpadc_trig_edge_write, | |
2534 | .llseek = seq_lseek, | |
2535 | .release = single_release, | |
2536 | .owner = THIS_MODULE, | |
2537 | }; | |
2538 | ||
2539 | static int ab8500_gpadc_trig_timer_print(struct seq_file *s, void *p) | |
2540 | { | |
9a503a7d JP |
2541 | seq_printf(s, "%d\n", trig_timer); |
2542 | ||
2543 | return 0; | |
73482346 LJ |
2544 | } |
2545 | ||
2546 | static int ab8500_gpadc_trig_timer_open(struct inode *inode, struct file *file) | |
2547 | { | |
2548 | return single_open(file, ab8500_gpadc_trig_timer_print, | |
9f9ba15f | 2549 | inode->i_private); |
73482346 LJ |
2550 | } |
2551 | ||
2552 | static ssize_t ab8500_gpadc_trig_timer_write(struct file *file, | |
2553 | const char __user *user_buf, | |
2554 | size_t count, loff_t *ppos) | |
2555 | { | |
2556 | struct device *dev = ((struct seq_file *)(file->private_data))->private; | |
73482346 LJ |
2557 | unsigned long user_trig_timer; |
2558 | int err; | |
2559 | ||
7b830ae4 | 2560 | err = kstrtoul_from_user(user_buf, count, 0, &user_trig_timer); |
73482346 | 2561 | if (err) |
7b830ae4 | 2562 | return err; |
2563 | ||
c3f27a26 LJ |
2564 | if (user_trig_timer & ~0xFF) { |
2565 | dev_err(dev, | |
c094cf13 | 2566 | "debugfs error input: should be between 0 to 255\n"); |
73482346 LJ |
2567 | return -EINVAL; |
2568 | } | |
7b830ae4 | 2569 | |
c3f27a26 LJ |
2570 | trig_timer = (u8) user_trig_timer; |
2571 | ||
7b830ae4 | 2572 | return count; |
73482346 LJ |
2573 | } |
2574 | ||
2575 | static const struct file_operations ab8500_gpadc_trig_timer_fops = { | |
2576 | .open = ab8500_gpadc_trig_timer_open, | |
2577 | .read = seq_read, | |
2578 | .write = ab8500_gpadc_trig_timer_write, | |
2579 | .llseek = seq_lseek, | |
2580 | .release = single_release, | |
2581 | .owner = THIS_MODULE, | |
2582 | }; | |
2583 | ||
2584 | static int ab8500_gpadc_conv_type_print(struct seq_file *s, void *p) | |
2585 | { | |
9a503a7d JP |
2586 | seq_printf(s, "%d\n", conv_type); |
2587 | ||
2588 | return 0; | |
73482346 LJ |
2589 | } |
2590 | ||
2591 | static int ab8500_gpadc_conv_type_open(struct inode *inode, struct file *file) | |
2592 | { | |
2593 | return single_open(file, ab8500_gpadc_conv_type_print, | |
9f9ba15f | 2594 | inode->i_private); |
73482346 LJ |
2595 | } |
2596 | ||
2597 | static ssize_t ab8500_gpadc_conv_type_write(struct file *file, | |
2598 | const char __user *user_buf, | |
2599 | size_t count, loff_t *ppos) | |
2600 | { | |
2601 | struct device *dev = ((struct seq_file *)(file->private_data))->private; | |
73482346 LJ |
2602 | unsigned long user_conv_type; |
2603 | int err; | |
2604 | ||
7b830ae4 | 2605 | err = kstrtoul_from_user(user_buf, count, 0, &user_conv_type); |
73482346 | 2606 | if (err) |
7b830ae4 | 2607 | return err; |
2608 | ||
73482346 LJ |
2609 | if ((user_conv_type == ADC_SW) |
2610 | || (user_conv_type == ADC_HW)) { | |
2611 | conv_type = (u8) user_conv_type; | |
2612 | } else { | |
2613 | dev_err(dev, "Wrong input:\n" | |
2614 | "Enter 0. ADC SW conversion\n" | |
2615 | "Enter 1. ADC HW conversion\n"); | |
2616 | return -EINVAL; | |
2617 | } | |
7b830ae4 | 2618 | |
2619 | return count; | |
73482346 LJ |
2620 | } |
2621 | ||
2622 | static const struct file_operations ab8500_gpadc_conv_type_fops = { | |
2623 | .open = ab8500_gpadc_conv_type_open, | |
2624 | .read = seq_read, | |
2625 | .write = ab8500_gpadc_conv_type_write, | |
2626 | .llseek = seq_lseek, | |
2627 | .release = single_release, | |
2628 | .owner = THIS_MODULE, | |
2629 | }; | |
2630 | ||
0fbce76e | 2631 | /* |
2632 | * return length of an ASCII numerical value, 0 is string is not a | |
2633 | * numerical value. | |
2634 | * string shall start at value 1st char. | |
2635 | * string can be tailed with \0 or space or newline chars only. | |
2636 | * value can be decimal or hexadecimal (prefixed 0x or 0X). | |
2637 | */ | |
2638 | static int strval_len(char *b) | |
2639 | { | |
2640 | char *s = b; | |
4362175d | 2641 | |
0fbce76e | 2642 | if ((*s == '0') && ((*(s+1) == 'x') || (*(s+1) == 'X'))) { |
2643 | s += 2; | |
2644 | for (; *s && (*s != ' ') && (*s != '\n'); s++) { | |
2645 | if (!isxdigit(*s)) | |
2646 | return 0; | |
2647 | } | |
2648 | } else { | |
2649 | if (*s == '-') | |
2650 | s++; | |
2651 | for (; *s && (*s != ' ') && (*s != '\n'); s++) { | |
2652 | if (!isdigit(*s)) | |
2653 | return 0; | |
2654 | } | |
2655 | } | |
2656 | return (int) (s-b); | |
2657 | } | |
2658 | ||
2659 | /* | |
2660 | * parse hwreg input data. | |
2661 | * update global hwreg_cfg only if input data syntax is ok. | |
2662 | */ | |
2663 | static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg, | |
2664 | struct device *dev) | |
2665 | { | |
2666 | uint write, val = 0; | |
2667 | u8 regvalue; | |
2668 | int ret; | |
2669 | struct hwreg_cfg loc = { | |
2670 | .bank = 0, /* default: invalid phys addr */ | |
2671 | .addr = 0, /* default: invalid phys addr */ | |
2672 | .fmt = 0, /* default: 32bit access, hex output */ | |
2673 | .mask = 0xFFFFFFFF, /* default: no mask */ | |
2674 | .shift = 0, /* default: no bit shift */ | |
2675 | }; | |
2676 | ||
2677 | /* read or write ? */ | |
2678 | if (!strncmp(b, "read ", 5)) { | |
2679 | write = 0; | |
2680 | b += 5; | |
2681 | } else if (!strncmp(b, "write ", 6)) { | |
2682 | write = 1; | |
2683 | b += 6; | |
2684 | } else | |
2685 | return -EINVAL; | |
2686 | ||
2687 | /* OPTIONS -l|-w|-b -s -m -o */ | |
2688 | while ((*b == ' ') || (*b == '-')) { | |
2689 | if (*(b-1) != ' ') { | |
2690 | b++; | |
2691 | continue; | |
2692 | } | |
2693 | if ((!strncmp(b, "-d ", 3)) || | |
2694 | (!strncmp(b, "-dec ", 5))) { | |
2695 | b += (*(b+2) == ' ') ? 3 : 5; | |
2696 | loc.fmt |= (1<<0); | |
2697 | } else if ((!strncmp(b, "-h ", 3)) || | |
2698 | (!strncmp(b, "-hex ", 5))) { | |
2699 | b += (*(b+2) == ' ') ? 3 : 5; | |
2700 | loc.fmt &= ~(1<<0); | |
2701 | } else if ((!strncmp(b, "-m ", 3)) || | |
2702 | (!strncmp(b, "-mask ", 6))) { | |
2703 | b += (*(b+2) == ' ') ? 3 : 6; | |
2704 | if (strval_len(b) == 0) | |
2705 | return -EINVAL; | |
4362175d LJ |
2706 | ret = kstrtoul(b, 0, &loc.mask); |
2707 | if (ret) | |
2708 | return ret; | |
0fbce76e | 2709 | } else if ((!strncmp(b, "-s ", 3)) || |
2710 | (!strncmp(b, "-shift ", 7))) { | |
2711 | b += (*(b+2) == ' ') ? 3 : 7; | |
2712 | if (strval_len(b) == 0) | |
2713 | return -EINVAL; | |
4362175d LJ |
2714 | ret = kstrtol(b, 0, &loc.shift); |
2715 | if (ret) | |
2716 | return ret; | |
0fbce76e | 2717 | } else { |
2718 | return -EINVAL; | |
2719 | } | |
2720 | } | |
2721 | /* get arg BANK and ADDRESS */ | |
2722 | if (strval_len(b) == 0) | |
2723 | return -EINVAL; | |
4362175d LJ |
2724 | ret = kstrtouint(b, 0, &loc.bank); |
2725 | if (ret) | |
2726 | return ret; | |
0fbce76e | 2727 | while (*b == ' ') |
2728 | b++; | |
2729 | if (strval_len(b) == 0) | |
2730 | return -EINVAL; | |
4362175d LJ |
2731 | ret = kstrtoul(b, 0, &loc.addr); |
2732 | if (ret) | |
2733 | return ret; | |
0fbce76e | 2734 | |
2735 | if (write) { | |
2736 | while (*b == ' ') | |
2737 | b++; | |
2738 | if (strval_len(b) == 0) | |
2739 | return -EINVAL; | |
4362175d LJ |
2740 | ret = kstrtouint(b, 0, &val); |
2741 | if (ret) | |
2742 | return ret; | |
0fbce76e | 2743 | } |
2744 | ||
2745 | /* args are ok, update target cfg (mainly for read) */ | |
2746 | *cfg = loc; | |
2747 | ||
2748 | #ifdef ABB_HWREG_DEBUG | |
de6a7693 LJ |
2749 | pr_warn("HWREG request: %s, %s,\n", (write) ? "write" : "read", |
2750 | REG_FMT_DEC(cfg) ? "decimal" : "hexa"); | |
2751 | pr_warn(" addr=0x%08X, mask=0x%X, shift=%d" "value=0x%X\n", | |
4362175d | 2752 | cfg->addr, cfg->mask, cfg->shift, val); |
0fbce76e | 2753 | #endif |
2754 | ||
2755 | if (!write) | |
2756 | return 0; | |
2757 | ||
2758 | ret = abx500_get_register_interruptible(dev, | |
2759 | (u8)cfg->bank, (u8)cfg->addr, ®value); | |
2760 | if (ret < 0) { | |
2761 | dev_err(dev, "abx500_get_reg fail %d, %d\n", | |
2762 | ret, __LINE__); | |
2763 | return -EINVAL; | |
2764 | } | |
2765 | ||
2766 | if (cfg->shift >= 0) { | |
2767 | regvalue &= ~(cfg->mask << (cfg->shift)); | |
2768 | val = (val & cfg->mask) << (cfg->shift); | |
2769 | } else { | |
2770 | regvalue &= ~(cfg->mask >> (-cfg->shift)); | |
2771 | val = (val & cfg->mask) >> (-cfg->shift); | |
2772 | } | |
2773 | val = val | regvalue; | |
2774 | ||
2775 | ret = abx500_set_register_interruptible(dev, | |
2776 | (u8)cfg->bank, (u8)cfg->addr, (u8)val); | |
2777 | if (ret < 0) { | |
2778 | pr_err("abx500_set_reg failed %d, %d", ret, __LINE__); | |
2779 | return -EINVAL; | |
2780 | } | |
2781 | ||
2782 | return 0; | |
2783 | } | |
2784 | ||
2785 | static ssize_t ab8500_hwreg_write(struct file *file, | |
2786 | const char __user *user_buf, size_t count, loff_t *ppos) | |
2787 | { | |
2788 | struct device *dev = ((struct seq_file *)(file->private_data))->private; | |
2789 | char buf[128]; | |
2790 | int buf_size, ret; | |
2791 | ||
2792 | /* Get userspace string and assure termination */ | |
2793 | buf_size = min(count, (sizeof(buf)-1)); | |
2794 | if (copy_from_user(buf, user_buf, buf_size)) | |
2795 | return -EFAULT; | |
2796 | buf[buf_size] = 0; | |
2797 | ||
2798 | /* get args and process */ | |
2799 | ret = hwreg_common_write(buf, &hwreg_cfg, dev); | |
2800 | return (ret) ? ret : buf_size; | |
2801 | } | |
2802 | ||
2803 | /* | |
2804 | * - irq subscribe/unsubscribe stuff | |
2805 | */ | |
4b8ac082 LJ |
2806 | static int ab8500_subscribe_unsubscribe_print(struct seq_file *s, void *p) |
2807 | { | |
2808 | seq_printf(s, "%d\n", irq_first); | |
2809 | ||
2810 | return 0; | |
2811 | } | |
2812 | ||
2813 | static int ab8500_subscribe_unsubscribe_open(struct inode *inode, | |
2814 | struct file *file) | |
2815 | { | |
2816 | return single_open(file, ab8500_subscribe_unsubscribe_print, | |
9f9ba15f | 2817 | inode->i_private); |
4b8ac082 LJ |
2818 | } |
2819 | ||
2820 | /* | |
0b337e70 | 2821 | * Userspace should use poll() on this file. When an event occur |
4b8ac082 LJ |
2822 | * the blocking poll will be released. |
2823 | */ | |
2824 | static ssize_t show_irq(struct device *dev, | |
2825 | struct device_attribute *attr, char *buf) | |
2826 | { | |
0b337e70 MW |
2827 | unsigned long name; |
2828 | unsigned int irq_index; | |
2829 | int err; | |
4b8ac082 | 2830 | |
8420a241 | 2831 | err = kstrtoul(attr->attr.name, 0, &name); |
0b337e70 MW |
2832 | if (err) |
2833 | return err; | |
2834 | ||
2835 | irq_index = name - irq_first; | |
ddba25f1 | 2836 | if (irq_index >= num_irqs) |
0b337e70 | 2837 | return -EINVAL; |
c3f27a26 LJ |
2838 | |
2839 | return sprintf(buf, "%u\n", irq_count[irq_index]); | |
0b337e70 | 2840 | } |
4b8ac082 LJ |
2841 | |
2842 | static ssize_t ab8500_subscribe_write(struct file *file, | |
2843 | const char __user *user_buf, | |
2844 | size_t count, loff_t *ppos) | |
2845 | { | |
2846 | struct device *dev = ((struct seq_file *)(file->private_data))->private; | |
4b8ac082 LJ |
2847 | unsigned long user_val; |
2848 | int err; | |
0b337e70 | 2849 | unsigned int irq_index; |
4b8ac082 | 2850 | |
7b830ae4 | 2851 | err = kstrtoul_from_user(user_buf, count, 0, &user_val); |
4b8ac082 | 2852 | if (err) |
7b830ae4 | 2853 | return err; |
2854 | ||
4b8ac082 LJ |
2855 | if (user_val < irq_first) { |
2856 | dev_err(dev, "debugfs error input < %d\n", irq_first); | |
2857 | return -EINVAL; | |
2858 | } | |
2859 | if (user_val > irq_last) { | |
2860 | dev_err(dev, "debugfs error input > %d\n", irq_last); | |
2861 | return -EINVAL; | |
2862 | } | |
2863 | ||
0b337e70 | 2864 | irq_index = user_val - irq_first; |
ddba25f1 | 2865 | if (irq_index >= num_irqs) |
0b337e70 MW |
2866 | return -EINVAL; |
2867 | ||
4b8ac082 | 2868 | /* |
0b337e70 | 2869 | * This will create a sysfs file named <irq-nr> which userspace can |
4b8ac082 LJ |
2870 | * use to select or poll and get the AB8500 events |
2871 | */ | |
0b337e70 MW |
2872 | dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute), |
2873 | GFP_KERNEL); | |
f840e23b LJ |
2874 | if (!dev_attr[irq_index]) |
2875 | return -ENOMEM; | |
2876 | ||
7b830ae4 | 2877 | event_name[irq_index] = kmalloc(count, GFP_KERNEL); |
d551c4c4 LJ |
2878 | if (!event_name[irq_index]) |
2879 | return -ENOMEM; | |
2880 | ||
0b337e70 MW |
2881 | sprintf(event_name[irq_index], "%lu", user_val); |
2882 | dev_attr[irq_index]->show = show_irq; | |
2883 | dev_attr[irq_index]->store = NULL; | |
2884 | dev_attr[irq_index]->attr.name = event_name[irq_index]; | |
2885 | dev_attr[irq_index]->attr.mode = S_IRUGO; | |
2886 | err = sysfs_create_file(&dev->kobj, &dev_attr[irq_index]->attr); | |
4b8ac082 | 2887 | if (err < 0) { |
4362175d | 2888 | pr_info("sysfs_create_file failed %d\n", err); |
4b8ac082 LJ |
2889 | return err; |
2890 | } | |
2891 | ||
2892 | err = request_threaded_irq(user_val, NULL, ab8500_debug_handler, | |
abe5b47c | 2893 | IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_ONESHOT, |
4b8ac082 LJ |
2894 | "ab8500-debug", &dev->kobj); |
2895 | if (err < 0) { | |
4362175d LJ |
2896 | pr_info("request_threaded_irq failed %d, %lu\n", |
2897 | err, user_val); | |
0b337e70 | 2898 | sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr); |
4b8ac082 LJ |
2899 | return err; |
2900 | } | |
2901 | ||
7b830ae4 | 2902 | return count; |
4b8ac082 LJ |
2903 | } |
2904 | ||
2905 | static ssize_t ab8500_unsubscribe_write(struct file *file, | |
2906 | const char __user *user_buf, | |
2907 | size_t count, loff_t *ppos) | |
2908 | { | |
2909 | struct device *dev = ((struct seq_file *)(file->private_data))->private; | |
4b8ac082 LJ |
2910 | unsigned long user_val; |
2911 | int err; | |
0b337e70 | 2912 | unsigned int irq_index; |
4b8ac082 | 2913 | |
7b830ae4 | 2914 | err = kstrtoul_from_user(user_buf, count, 0, &user_val); |
4b8ac082 | 2915 | if (err) |
7b830ae4 | 2916 | return err; |
2917 | ||
4b8ac082 LJ |
2918 | if (user_val < irq_first) { |
2919 | dev_err(dev, "debugfs error input < %d\n", irq_first); | |
2920 | return -EINVAL; | |
2921 | } | |
2922 | if (user_val > irq_last) { | |
2923 | dev_err(dev, "debugfs error input > %d\n", irq_last); | |
2924 | return -EINVAL; | |
2925 | } | |
2926 | ||
0b337e70 | 2927 | irq_index = user_val - irq_first; |
ddba25f1 | 2928 | if (irq_index >= num_irqs) |
0b337e70 MW |
2929 | return -EINVAL; |
2930 | ||
2931 | /* Set irq count to 0 when unsubscribe */ | |
2932 | irq_count[irq_index] = 0; | |
2933 | ||
2934 | if (dev_attr[irq_index]) | |
2935 | sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr); | |
4b8ac082 | 2936 | |
0b337e70 MW |
2937 | |
2938 | free_irq(user_val, &dev->kobj); | |
2939 | kfree(event_name[irq_index]); | |
2940 | kfree(dev_attr[irq_index]); | |
4b8ac082 | 2941 | |
7b830ae4 | 2942 | return count; |
4b8ac082 LJ |
2943 | } |
2944 | ||
0fbce76e | 2945 | /* |
2946 | * - several deubgfs nodes fops | |
2947 | */ | |
2948 | ||
5814fc35 | 2949 | static const struct file_operations ab8500_bank_fops = { |
d7b9f322 MW |
2950 | .open = ab8500_bank_open, |
2951 | .write = ab8500_bank_write, | |
2952 | .read = seq_read, | |
2953 | .llseek = seq_lseek, | |
2954 | .release = single_release, | |
2955 | .owner = THIS_MODULE, | |
5814fc35 MW |
2956 | }; |
2957 | ||
2958 | static const struct file_operations ab8500_address_fops = { | |
d7b9f322 MW |
2959 | .open = ab8500_address_open, |
2960 | .write = ab8500_address_write, | |
2961 | .read = seq_read, | |
2962 | .llseek = seq_lseek, | |
2963 | .release = single_release, | |
2964 | .owner = THIS_MODULE, | |
5814fc35 MW |
2965 | }; |
2966 | ||
2967 | static const struct file_operations ab8500_val_fops = { | |
d7b9f322 MW |
2968 | .open = ab8500_val_open, |
2969 | .write = ab8500_val_write, | |
2970 | .read = seq_read, | |
2971 | .llseek = seq_lseek, | |
2972 | .release = single_release, | |
2973 | .owner = THIS_MODULE, | |
5814fc35 MW |
2974 | }; |
2975 | ||
8f0eb43b BJ |
2976 | static const struct file_operations ab8500_interrupts_fops = { |
2977 | .open = ab8500_interrupts_open, | |
2978 | .read = seq_read, | |
2979 | .llseek = seq_lseek, | |
2980 | .release = single_release, | |
2981 | .owner = THIS_MODULE, | |
2982 | }; | |
2983 | ||
4b8ac082 LJ |
2984 | static const struct file_operations ab8500_subscribe_fops = { |
2985 | .open = ab8500_subscribe_unsubscribe_open, | |
2986 | .write = ab8500_subscribe_write, | |
2987 | .read = seq_read, | |
2988 | .llseek = seq_lseek, | |
2989 | .release = single_release, | |
2990 | .owner = THIS_MODULE, | |
2991 | }; | |
2992 | ||
2993 | static const struct file_operations ab8500_unsubscribe_fops = { | |
2994 | .open = ab8500_subscribe_unsubscribe_open, | |
2995 | .write = ab8500_unsubscribe_write, | |
2996 | .read = seq_read, | |
2997 | .llseek = seq_lseek, | |
2998 | .release = single_release, | |
2999 | .owner = THIS_MODULE, | |
3000 | }; | |
3001 | ||
0fbce76e | 3002 | static const struct file_operations ab8500_hwreg_fops = { |
3003 | .open = ab8500_hwreg_open, | |
3004 | .write = ab8500_hwreg_write, | |
3005 | .read = seq_read, | |
3006 | .llseek = seq_lseek, | |
3007 | .release = single_release, | |
3008 | .owner = THIS_MODULE, | |
3009 | }; | |
3010 | ||
5814fc35 | 3011 | static struct dentry *ab8500_dir; |
1478a316 | 3012 | static struct dentry *ab8500_gpadc_dir; |
5814fc35 | 3013 | |
f791be49 | 3014 | static int ab8500_debug_probe(struct platform_device *plf) |
5814fc35 | 3015 | { |
0fbce76e | 3016 | struct dentry *file; |
ddba25f1 | 3017 | struct ab8500 *ab8500; |
6999181e | 3018 | struct resource *res; |
4362175d | 3019 | |
d7b9f322 MW |
3020 | debug_bank = AB8500_MISC; |
3021 | debug_address = AB8500_REV_REG & 0x00FF; | |
5814fc35 | 3022 | |
ddba25f1 LW |
3023 | ab8500 = dev_get_drvdata(plf->dev.parent); |
3024 | num_irqs = ab8500->mask_size; | |
3025 | ||
c18cf6d1 LJ |
3026 | irq_count = devm_kzalloc(&plf->dev, |
3027 | sizeof(*irq_count)*num_irqs, GFP_KERNEL); | |
ddba25f1 LW |
3028 | if (!irq_count) |
3029 | return -ENOMEM; | |
3030 | ||
c18cf6d1 | 3031 | dev_attr = devm_kzalloc(&plf->dev, |
4362175d | 3032 | sizeof(*dev_attr)*num_irqs, GFP_KERNEL); |
ddba25f1 | 3033 | if (!dev_attr) |
c18cf6d1 | 3034 | return -ENOMEM; |
ddba25f1 | 3035 | |
c18cf6d1 LJ |
3036 | event_name = devm_kzalloc(&plf->dev, |
3037 | sizeof(*event_name)*num_irqs, GFP_KERNEL); | |
ddba25f1 | 3038 | if (!event_name) |
c18cf6d1 | 3039 | return -ENOMEM; |
ddba25f1 | 3040 | |
6999181e LW |
3041 | res = platform_get_resource_byname(plf, 0, "IRQ_AB8500"); |
3042 | if (!res) { | |
4362175d LJ |
3043 | dev_err(&plf->dev, "AB8500 irq not found, err %d\n", irq_first); |
3044 | return -ENXIO; | |
6999181e LW |
3045 | } |
3046 | irq_ab8500 = res->start; | |
3047 | ||
4b8ac082 LJ |
3048 | irq_first = platform_get_irq_byname(plf, "IRQ_FIRST"); |
3049 | if (irq_first < 0) { | |
4362175d | 3050 | dev_err(&plf->dev, "First irq not found, err %d\n", irq_first); |
c18cf6d1 | 3051 | return irq_first; |
4b8ac082 LJ |
3052 | } |
3053 | ||
3054 | irq_last = platform_get_irq_byname(plf, "IRQ_LAST"); | |
3055 | if (irq_last < 0) { | |
4362175d | 3056 | dev_err(&plf->dev, "Last irq not found, err %d\n", irq_last); |
c18cf6d1 | 3057 | return irq_last; |
4b8ac082 LJ |
3058 | } |
3059 | ||
d7b9f322 MW |
3060 | ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL); |
3061 | if (!ab8500_dir) | |
0fbce76e | 3062 | goto err; |
5814fc35 | 3063 | |
1478a316 | 3064 | ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING, |
4362175d | 3065 | ab8500_dir); |
1478a316 JB |
3066 | if (!ab8500_gpadc_dir) |
3067 | goto err; | |
3068 | ||
4362175d LJ |
3069 | file = debugfs_create_file("all-bank-registers", S_IRUGO, ab8500_dir, |
3070 | &plf->dev, &ab8500_registers_fops); | |
1478a316 JB |
3071 | if (!file) |
3072 | goto err; | |
3073 | ||
4362175d LJ |
3074 | file = debugfs_create_file("all-banks", S_IRUGO, ab8500_dir, |
3075 | &plf->dev, &ab8500_all_banks_fops); | |
42002c6d MYK |
3076 | if (!file) |
3077 | goto err; | |
3078 | ||
4362175d LJ |
3079 | file = debugfs_create_file("register-bank", |
3080 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3081 | ab8500_dir, &plf->dev, &ab8500_bank_fops); | |
1478a316 JB |
3082 | if (!file) |
3083 | goto err; | |
3084 | ||
4362175d LJ |
3085 | file = debugfs_create_file("register-address", |
3086 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3087 | ab8500_dir, &plf->dev, &ab8500_address_fops); | |
1478a316 JB |
3088 | if (!file) |
3089 | goto err; | |
3090 | ||
4362175d LJ |
3091 | file = debugfs_create_file("register-value", |
3092 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3093 | ab8500_dir, &plf->dev, &ab8500_val_fops); | |
1478a316 JB |
3094 | if (!file) |
3095 | goto err; | |
3096 | ||
4362175d LJ |
3097 | file = debugfs_create_file("irq-subscribe", |
3098 | (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir, | |
3099 | &plf->dev, &ab8500_subscribe_fops); | |
1478a316 JB |
3100 | if (!file) |
3101 | goto err; | |
3102 | ||
9581ae39 LJ |
3103 | if (is_ab8500(ab8500)) { |
3104 | debug_ranges = ab8500_debug_ranges; | |
8f0eb43b | 3105 | num_interrupt_lines = AB8500_NR_IRQS; |
9581ae39 LJ |
3106 | } else if (is_ab8505(ab8500)) { |
3107 | debug_ranges = ab8505_debug_ranges; | |
8f0eb43b | 3108 | num_interrupt_lines = AB8505_NR_IRQS; |
9581ae39 LJ |
3109 | } else if (is_ab9540(ab8500)) { |
3110 | debug_ranges = ab8505_debug_ranges; | |
8f0eb43b | 3111 | num_interrupt_lines = AB9540_NR_IRQS; |
9581ae39 | 3112 | } else if (is_ab8540(ab8500)) { |
971480f5 | 3113 | debug_ranges = ab8540_debug_ranges; |
e436ddff | 3114 | num_interrupt_lines = AB8540_NR_IRQS; |
9581ae39 | 3115 | } |
8f0eb43b | 3116 | |
4362175d LJ |
3117 | file = debugfs_create_file("interrupts", (S_IRUGO), ab8500_dir, |
3118 | &plf->dev, &ab8500_interrupts_fops); | |
8f0eb43b BJ |
3119 | if (!file) |
3120 | goto err; | |
3121 | ||
4362175d LJ |
3122 | file = debugfs_create_file("irq-unsubscribe", |
3123 | (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir, | |
3124 | &plf->dev, &ab8500_unsubscribe_fops); | |
1478a316 JB |
3125 | if (!file) |
3126 | goto err; | |
3127 | ||
f38487f2 | 3128 | file = debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d | 3129 | ab8500_dir, &plf->dev, &ab8500_hwreg_fops); |
1478a316 JB |
3130 | if (!file) |
3131 | goto err; | |
3132 | ||
4362175d LJ |
3133 | file = debugfs_create_file("all-modem-registers", |
3134 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3135 | ab8500_dir, &plf->dev, &ab8500_modem_fops); | |
c7ebaee2 LJ |
3136 | if (!file) |
3137 | goto err; | |
3138 | ||
f38487f2 | 3139 | file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3140 | ab8500_gpadc_dir, &plf->dev, |
3141 | &ab8500_gpadc_bat_ctrl_fops); | |
1478a316 JB |
3142 | if (!file) |
3143 | goto err; | |
3144 | ||
f38487f2 | 3145 | file = debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3146 | ab8500_gpadc_dir, |
3147 | &plf->dev, &ab8500_gpadc_btemp_ball_fops); | |
1478a316 JB |
3148 | if (!file) |
3149 | goto err; | |
3150 | ||
4362175d LJ |
3151 | file = debugfs_create_file("main_charger_v", |
3152 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3153 | ab8500_gpadc_dir, &plf->dev, | |
3154 | &ab8500_gpadc_main_charger_v_fops); | |
1478a316 JB |
3155 | if (!file) |
3156 | goto err; | |
3157 | ||
4362175d LJ |
3158 | file = debugfs_create_file("acc_detect1", |
3159 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3160 | ab8500_gpadc_dir, &plf->dev, | |
3161 | &ab8500_gpadc_acc_detect1_fops); | |
1478a316 JB |
3162 | if (!file) |
3163 | goto err; | |
3164 | ||
4362175d LJ |
3165 | file = debugfs_create_file("acc_detect2", |
3166 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3167 | ab8500_gpadc_dir, &plf->dev, | |
3168 | &ab8500_gpadc_acc_detect2_fops); | |
1478a316 JB |
3169 | if (!file) |
3170 | goto err; | |
3171 | ||
f38487f2 | 3172 | file = debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3173 | ab8500_gpadc_dir, &plf->dev, |
3174 | &ab8500_gpadc_aux1_fops); | |
1478a316 JB |
3175 | if (!file) |
3176 | goto err; | |
3177 | ||
f38487f2 | 3178 | file = debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3179 | ab8500_gpadc_dir, &plf->dev, |
3180 | &ab8500_gpadc_aux2_fops); | |
0fbce76e | 3181 | if (!file) |
3182 | goto err; | |
5814fc35 | 3183 | |
f38487f2 | 3184 | file = debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3185 | ab8500_gpadc_dir, &plf->dev, |
3186 | &ab8500_gpadc_main_bat_v_fops); | |
0fbce76e | 3187 | if (!file) |
3188 | goto err; | |
5814fc35 | 3189 | |
f38487f2 | 3190 | file = debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3191 | ab8500_gpadc_dir, &plf->dev, |
3192 | &ab8500_gpadc_vbus_v_fops); | |
0fbce76e | 3193 | if (!file) |
3194 | goto err; | |
5814fc35 | 3195 | |
4362175d LJ |
3196 | file = debugfs_create_file("main_charger_c", |
3197 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3198 | ab8500_gpadc_dir, &plf->dev, | |
3199 | &ab8500_gpadc_main_charger_c_fops); | |
0fbce76e | 3200 | if (!file) |
3201 | goto err; | |
3202 | ||
4362175d LJ |
3203 | file = debugfs_create_file("usb_charger_c", |
3204 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3205 | ab8500_gpadc_dir, | |
3206 | &plf->dev, &ab8500_gpadc_usb_charger_c_fops); | |
0fbce76e | 3207 | if (!file) |
3208 | goto err; | |
3209 | ||
f38487f2 | 3210 | file = debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3211 | ab8500_gpadc_dir, &plf->dev, |
3212 | &ab8500_gpadc_bk_bat_v_fops); | |
0fbce76e | 3213 | if (!file) |
3214 | goto err; | |
3215 | ||
f38487f2 | 3216 | file = debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3217 | ab8500_gpadc_dir, &plf->dev, |
3218 | &ab8500_gpadc_die_temp_fops); | |
0fbce76e | 3219 | if (!file) |
3220 | goto err; | |
127629d7 | 3221 | |
f38487f2 | 3222 | file = debugfs_create_file("usb_id", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3223 | ab8500_gpadc_dir, &plf->dev, |
3224 | &ab8500_gpadc_usb_id_fops); | |
127629d7 LJ |
3225 | if (!file) |
3226 | goto err; | |
3227 | ||
bc6b4132 | 3228 | if (is_ab8540(ab8500)) { |
4362175d LJ |
3229 | file = debugfs_create_file("xtal_temp", |
3230 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3231 | ab8500_gpadc_dir, &plf->dev, | |
3232 | &ab8540_gpadc_xtal_temp_fops); | |
bc6b4132 LJ |
3233 | if (!file) |
3234 | goto err; | |
4362175d LJ |
3235 | file = debugfs_create_file("vbattruemeas", |
3236 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3237 | ab8500_gpadc_dir, &plf->dev, | |
3238 | &ab8540_gpadc_vbat_true_meas_fops); | |
bc6b4132 LJ |
3239 | if (!file) |
3240 | goto err; | |
3241 | file = debugfs_create_file("batctrl_and_ibat", | |
4362175d LJ |
3242 | (S_IRUGO | S_IWUGO), |
3243 | ab8500_gpadc_dir, | |
3244 | &plf->dev, | |
3245 | &ab8540_gpadc_bat_ctrl_and_ibat_fops); | |
bc6b4132 LJ |
3246 | if (!file) |
3247 | goto err; | |
3248 | file = debugfs_create_file("vbatmeas_and_ibat", | |
4362175d LJ |
3249 | (S_IRUGO | S_IWUGO), |
3250 | ab8500_gpadc_dir, &plf->dev, | |
3251 | &ab8540_gpadc_vbat_meas_and_ibat_fops); | |
bc6b4132 LJ |
3252 | if (!file) |
3253 | goto err; | |
3254 | file = debugfs_create_file("vbattruemeas_and_ibat", | |
4362175d LJ |
3255 | (S_IRUGO | S_IWUGO), |
3256 | ab8500_gpadc_dir, | |
3257 | &plf->dev, | |
3258 | &ab8540_gpadc_vbat_true_meas_and_ibat_fops); | |
bc6b4132 LJ |
3259 | if (!file) |
3260 | goto err; | |
3261 | file = debugfs_create_file("battemp_and_ibat", | |
4362175d LJ |
3262 | (S_IRUGO | S_IWUGO), |
3263 | ab8500_gpadc_dir, | |
9f9ba15f | 3264 | &plf->dev, &ab8540_gpadc_bat_temp_and_ibat_fops); |
bc6b4132 LJ |
3265 | if (!file) |
3266 | goto err; | |
4362175d LJ |
3267 | file = debugfs_create_file("otp_calib", |
3268 | (S_IRUGO | S_IWUSR | S_IWGRP), | |
3269 | ab8500_gpadc_dir, | |
3270 | &plf->dev, &ab8540_gpadc_otp_calib_fops); | |
bc6b4132 LJ |
3271 | if (!file) |
3272 | goto err; | |
3273 | } | |
f38487f2 | 3274 | file = debugfs_create_file("avg_sample", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3275 | ab8500_gpadc_dir, &plf->dev, |
3276 | &ab8500_gpadc_avg_sample_fops); | |
73482346 LJ |
3277 | if (!file) |
3278 | goto err; | |
3279 | ||
f38487f2 | 3280 | file = debugfs_create_file("trig_edge", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3281 | ab8500_gpadc_dir, &plf->dev, |
3282 | &ab8500_gpadc_trig_edge_fops); | |
73482346 LJ |
3283 | if (!file) |
3284 | goto err; | |
3285 | ||
f38487f2 | 3286 | file = debugfs_create_file("trig_timer", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3287 | ab8500_gpadc_dir, &plf->dev, |
3288 | &ab8500_gpadc_trig_timer_fops); | |
73482346 LJ |
3289 | if (!file) |
3290 | goto err; | |
3291 | ||
f38487f2 | 3292 | file = debugfs_create_file("conv_type", (S_IRUGO | S_IWUSR | S_IWGRP), |
4362175d LJ |
3293 | ab8500_gpadc_dir, &plf->dev, |
3294 | &ab8500_gpadc_conv_type_fops); | |
73482346 LJ |
3295 | if (!file) |
3296 | goto err; | |
4b8ac082 | 3297 | |
d7b9f322 | 3298 | return 0; |
5814fc35 | 3299 | |
0fbce76e | 3300 | err: |
005d16b6 | 3301 | debugfs_remove_recursive(ab8500_dir); |
d7b9f322 | 3302 | dev_err(&plf->dev, "failed to create debugfs entries.\n"); |
ddba25f1 | 3303 | |
c18cf6d1 | 3304 | return -ENOMEM; |
5814fc35 MW |
3305 | } |
3306 | ||
4740f73f | 3307 | static int ab8500_debug_remove(struct platform_device *plf) |
5814fc35 | 3308 | { |
0fbce76e | 3309 | debugfs_remove_recursive(ab8500_dir); |
ddba25f1 | 3310 | |
d7b9f322 | 3311 | return 0; |
5814fc35 MW |
3312 | } |
3313 | ||
3314 | static struct platform_driver ab8500_debug_driver = { | |
d7b9f322 MW |
3315 | .driver = { |
3316 | .name = "ab8500-debug", | |
d7b9f322 MW |
3317 | }, |
3318 | .probe = ab8500_debug_probe, | |
84449216 | 3319 | .remove = ab8500_debug_remove |
5814fc35 MW |
3320 | }; |
3321 | ||
3322 | static int __init ab8500_debug_init(void) | |
3323 | { | |
d7b9f322 | 3324 | return platform_driver_register(&ab8500_debug_driver); |
5814fc35 MW |
3325 | } |
3326 | ||
3327 | static void __exit ab8500_debug_exit(void) | |
3328 | { | |
d7b9f322 | 3329 | platform_driver_unregister(&ab8500_debug_driver); |
5814fc35 MW |
3330 | } |
3331 | subsys_initcall(ab8500_debug_init); | |
3332 | module_exit(ab8500_debug_exit); | |
3333 | ||
3334 | MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com"); | |
3335 | MODULE_DESCRIPTION("AB8500 DEBUG"); | |
3336 | MODULE_LICENSE("GPL v2"); |