blob: b2c7e3b1edfabce7500c84f3388f58ebc9344059 [file] [log] [blame]
Mattias Wallin5814fc32010-09-13 16:05:04 +02001/*
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 */
carriere etienne0fbce762011-04-08 16:26:36 +02007/*
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 */
Mattias Wallin5814fc32010-09-13 16:05:04 +020073
74#include <linux/seq_file.h>
75#include <linux/uaccess.h>
76#include <linux/fs.h>
Paul Gortmaker4e36dd32011-07-03 15:13:27 -040077#include <linux/module.h>
Mattias Wallin5814fc32010-09-13 16:05:04 +020078#include <linux/debugfs.h>
79#include <linux/platform_device.h>
Lee Jones4b8ac082013-01-14 16:10:36 +000080#include <linux/interrupt.h>
81#include <linux/kobject.h>
82#include <linux/slab.h>
Jonas Aaberg2cf64e22012-05-31 07:57:07 +020083#include <linux/irq.h>
Mattias Wallin5814fc32010-09-13 16:05:04 +020084
85#include <linux/mfd/abx500.h>
Linus Walleij0cd5b6d02013-02-06 23:23:01 +010086#include <linux/mfd/abx500/ab8500.h>
John Beckett1478a312011-05-31 13:54:27 +010087#include <linux/mfd/abx500/ab8500-gpadc.h>
Mattias Wallin5814fc32010-09-13 16:05:04 +020088
carriere etienne0fbce762011-04-08 16:26:36 +020089#ifdef CONFIG_DEBUG_FS
90#include <linux/string.h>
91#include <linux/ctype.h>
92#endif
93
Mattias Wallin5814fc32010-09-13 16:05:04 +020094static u32 debug_bank;
95static u32 debug_address;
96
Linus Walleij69991812013-04-12 17:02:09 +020097static int irq_ab8500;
Lee Jones4b8ac082013-01-14 16:10:36 +000098static int irq_first;
99static int irq_last;
Linus Walleijddba25f2012-02-03 11:19:05 +0100100static u32 *irq_count;
101static int num_irqs;
Mattias Wallin0b337e72010-11-19 17:55:11 +0100102
Linus Walleijddba25f2012-02-03 11:19:05 +0100103static struct device_attribute **dev_attr;
104static char **event_name;
Lee Jones4b8ac082013-01-14 16:10:36 +0000105
Lee Jones73482342013-02-26 10:06:55 +0000106static u8 avg_sample = SAMPLE_16;
107static u8 trig_edge = RISING_EDGE;
108static u8 conv_type = ADC_SW;
109static u8 trig_timer;
110
Mattias Wallin5814fc32010-09-13 16:05:04 +0200111/**
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 */
117struct ab8500_reg_range {
Mattias Wallind7b9f322010-11-26 13:06:39 +0100118 u8 first;
119 u8 last;
120 u8 perm;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200121};
122
123/**
Lee Jones822672a2012-06-20 13:56:38 +0100124 * struct ab8500_prcmu_ranges
Mattias Wallin5814fc32010-09-13 16:05:04 +0200125 * @num_ranges: the number of ranges in the list
126 * @bankid: bank identifier
127 * @range: the list of register ranges
128 */
Lee Jones822672a2012-06-20 13:56:38 +0100129struct ab8500_prcmu_ranges {
Mattias Wallind7b9f322010-11-26 13:06:39 +0100130 u8 num_ranges;
131 u8 bankid;
132 const struct ab8500_reg_range *range;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200133};
134
carriere etienne0fbce762011-04-08 16:26:36 +0200135/* hwreg- "mask" and "shift" entries ressources */
136struct hwreg_cfg {
137 u32 bank; /* target bank */
Lee Jones43621752014-07-14 18:29:16 +0100138 unsigned long addr; /* target address */
carriere etienne0fbce762011-04-08 16:26:36 +0200139 uint fmt; /* format */
Lee Jones43621752014-07-14 18:29:16 +0100140 unsigned long mask; /* read/write mask, applied before any bit shift */
141 long shift; /* bit shift (read:right shift, write:left shift */
carriere etienne0fbce762011-04-08 16:26:36 +0200142};
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
147static 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
Mattias Wallin5814fc32010-09-13 16:05:04 +0200154#define AB8500_NAME_STRING "ab8500"
John Beckett1478a312011-05-31 13:54:27 +0100155#define AB8500_ADC_NAME_STRING "gpadc"
Philippe Langlais40c064e2011-10-17 09:48:55 +0200156#define AB8500_NUM_BANKS 24
Mattias Wallin5814fc32010-09-13 16:05:04 +0200157
158#define AB8500_REV_REG 0x80
159
Lee Jones9581ae32012-07-06 16:11:50 +0200160static struct ab8500_prcmu_ranges *debug_ranges;
161
Sachin Kamat8455eae2013-08-23 17:37:42 +0530162static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
Mattias Wallind7b9f322010-11-26 13:06:39 +0100163 [0x0] = {
164 .num_ranges = 0,
Lee Jonesfad55a82013-01-14 17:17:34 +0000165 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100166 },
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 },
245 /* 0x80-0x8B is SIM registers and should
246 * not be accessed from here */
247 },
248 },
249 [AB8500_USB] = {
250 .num_ranges = 2,
251 .range = (struct ab8500_reg_range[]) {
252 {
253 .first = 0x80,
254 .last = 0x83,
255 },
256 {
257 .first = 0x87,
258 .last = 0x8A,
259 },
260 },
261 },
262 [AB8500_TVOUT] = {
263 .num_ranges = 9,
264 .range = (struct ab8500_reg_range[]) {
265 {
266 .first = 0x00,
267 .last = 0x12,
268 },
269 {
270 .first = 0x15,
271 .last = 0x17,
272 },
273 {
274 .first = 0x19,
275 .last = 0x21,
276 },
277 {
278 .first = 0x27,
279 .last = 0x2C,
280 },
281 {
282 .first = 0x41,
283 .last = 0x41,
284 },
285 {
286 .first = 0x45,
287 .last = 0x5B,
288 },
289 {
290 .first = 0x5D,
291 .last = 0x5D,
292 },
293 {
294 .first = 0x69,
295 .last = 0x69,
296 },
297 {
298 .first = 0x80,
299 .last = 0x81,
300 },
301 },
302 },
303 [AB8500_DBI] = {
304 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000305 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100306 },
307 [AB8500_ECI_AV_ACC] = {
308 .num_ranges = 1,
309 .range = (struct ab8500_reg_range[]) {
310 {
311 .first = 0x80,
312 .last = 0x82,
313 },
314 },
315 },
316 [0x9] = {
317 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000318 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100319 },
320 [AB8500_GPADC] = {
321 .num_ranges = 1,
322 .range = (struct ab8500_reg_range[]) {
323 {
324 .first = 0x00,
325 .last = 0x08,
326 },
327 },
328 },
329 [AB8500_CHARGER] = {
Philippe Langlais40c064e2011-10-17 09:48:55 +0200330 .num_ranges = 9,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100331 .range = (struct ab8500_reg_range[]) {
332 {
333 .first = 0x00,
334 .last = 0x03,
335 },
336 {
337 .first = 0x05,
338 .last = 0x05,
339 },
340 {
341 .first = 0x40,
342 .last = 0x40,
343 },
344 {
345 .first = 0x42,
346 .last = 0x42,
347 },
348 {
349 .first = 0x44,
350 .last = 0x44,
351 },
352 {
353 .first = 0x50,
354 .last = 0x55,
355 },
356 {
357 .first = 0x80,
358 .last = 0x82,
359 },
360 {
361 .first = 0xC0,
362 .last = 0xC2,
363 },
Philippe Langlais40c064e2011-10-17 09:48:55 +0200364 {
365 .first = 0xf5,
Lee Jones9581ae32012-07-06 16:11:50 +0200366 .last = 0xf6,
Philippe Langlais40c064e2011-10-17 09:48:55 +0200367 },
Mattias Wallind7b9f322010-11-26 13:06:39 +0100368 },
369 },
370 [AB8500_GAS_GAUGE] = {
371 .num_ranges = 3,
372 .range = (struct ab8500_reg_range[]) {
373 {
374 .first = 0x00,
375 .last = 0x00,
376 },
377 {
378 .first = 0x07,
379 .last = 0x0A,
380 },
381 {
382 .first = 0x10,
383 .last = 0x14,
384 },
385 },
386 },
Philippe Langlais40c064e2011-10-17 09:48:55 +0200387 [AB8500_DEVELOPMENT] = {
388 .num_ranges = 1,
389 .range = (struct ab8500_reg_range[]) {
390 {
391 .first = 0x00,
392 .last = 0x00,
393 },
394 },
395 },
396 [AB8500_DEBUG] = {
397 .num_ranges = 1,
398 .range = (struct ab8500_reg_range[]) {
399 {
400 .first = 0x05,
401 .last = 0x07,
402 },
403 },
404 },
Mattias Wallind7b9f322010-11-26 13:06:39 +0100405 [AB8500_AUDIO] = {
406 .num_ranges = 1,
407 .range = (struct ab8500_reg_range[]) {
408 {
409 .first = 0x00,
410 .last = 0x6F,
411 },
412 },
413 },
414 [AB8500_INTERRUPT] = {
415 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000416 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100417 },
418 [AB8500_RTC] = {
419 .num_ranges = 1,
420 .range = (struct ab8500_reg_range[]) {
421 {
422 .first = 0x00,
423 .last = 0x0F,
424 },
425 },
426 },
427 [AB8500_MISC] = {
428 .num_ranges = 8,
429 .range = (struct ab8500_reg_range[]) {
430 {
431 .first = 0x00,
432 .last = 0x05,
433 },
434 {
435 .first = 0x10,
436 .last = 0x15,
437 },
438 {
439 .first = 0x20,
440 .last = 0x25,
441 },
442 {
443 .first = 0x30,
444 .last = 0x35,
445 },
446 {
447 .first = 0x40,
448 .last = 0x45,
449 },
450 {
451 .first = 0x50,
452 .last = 0x50,
453 },
454 {
455 .first = 0x60,
456 .last = 0x67,
457 },
458 {
459 .first = 0x80,
460 .last = 0x80,
461 },
462 },
463 },
464 [0x11] = {
465 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000466 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100467 },
468 [0x12] = {
469 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000470 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100471 },
472 [0x13] = {
473 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000474 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100475 },
476 [0x14] = {
477 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000478 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100479 },
480 [AB8500_OTP_EMUL] = {
481 .num_ranges = 1,
482 .range = (struct ab8500_reg_range[]) {
483 {
484 .first = 0x01,
485 .last = 0x0F,
486 },
487 },
488 },
Mattias Wallin5814fc32010-09-13 16:05:04 +0200489};
490
Sachin Kamat8455eae2013-08-23 17:37:42 +0530491static struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = {
Lee Jones9581ae32012-07-06 16:11:50 +0200492 [0x0] = {
493 .num_ranges = 0,
494 .range = NULL,
495 },
496 [AB8500_SYS_CTRL1_BLOCK] = {
497 .num_ranges = 5,
498 .range = (struct ab8500_reg_range[]) {
499 {
500 .first = 0x00,
501 .last = 0x04,
502 },
503 {
504 .first = 0x42,
505 .last = 0x42,
506 },
507 {
508 .first = 0x52,
509 .last = 0x52,
510 },
511 {
512 .first = 0x54,
513 .last = 0x57,
514 },
515 {
516 .first = 0x80,
517 .last = 0x83,
518 },
519 },
520 },
521 [AB8500_SYS_CTRL2_BLOCK] = {
522 .num_ranges = 5,
523 .range = (struct ab8500_reg_range[]) {
524 {
525 .first = 0x00,
526 .last = 0x0D,
527 },
528 {
529 .first = 0x0F,
530 .last = 0x17,
531 },
532 {
533 .first = 0x20,
534 .last = 0x20,
535 },
536 {
537 .first = 0x30,
538 .last = 0x30,
539 },
540 {
541 .first = 0x32,
542 .last = 0x3A,
543 },
544 },
545 },
546 [AB8500_REGU_CTRL1] = {
547 .num_ranges = 3,
548 .range = (struct ab8500_reg_range[]) {
549 {
550 .first = 0x00,
551 .last = 0x00,
552 },
553 {
554 .first = 0x03,
555 .last = 0x11,
556 },
557 {
558 .first = 0x80,
559 .last = 0x86,
560 },
561 },
562 },
563 [AB8500_REGU_CTRL2] = {
564 .num_ranges = 6,
565 .range = (struct ab8500_reg_range[]) {
566 {
567 .first = 0x00,
568 .last = 0x06,
569 },
570 {
571 .first = 0x08,
572 .last = 0x15,
573 },
574 {
575 .first = 0x17,
576 .last = 0x19,
577 },
578 {
579 .first = 0x1B,
580 .last = 0x1D,
581 },
582 {
583 .first = 0x1F,
584 .last = 0x30,
585 },
586 {
587 .first = 0x40,
588 .last = 0x48,
589 },
590 /* 0x80-0x8B is SIM registers and should
591 * not be accessed from here */
592 },
593 },
594 [AB8500_USB] = {
595 .num_ranges = 3,
596 .range = (struct ab8500_reg_range[]) {
597 {
598 .first = 0x80,
599 .last = 0x83,
600 },
601 {
602 .first = 0x87,
603 .last = 0x8A,
604 },
605 {
606 .first = 0x91,
607 .last = 0x94,
608 },
609 },
610 },
611 [AB8500_TVOUT] = {
612 .num_ranges = 0,
613 .range = NULL,
614 },
615 [AB8500_DBI] = {
616 .num_ranges = 0,
617 .range = NULL,
618 },
619 [AB8500_ECI_AV_ACC] = {
620 .num_ranges = 1,
621 .range = (struct ab8500_reg_range[]) {
622 {
623 .first = 0x80,
624 .last = 0x82,
625 },
626 },
627 },
628 [AB8500_RESERVED] = {
629 .num_ranges = 0,
630 .range = NULL,
631 },
632 [AB8500_GPADC] = {
633 .num_ranges = 1,
634 .range = (struct ab8500_reg_range[]) {
635 {
636 .first = 0x00,
637 .last = 0x08,
638 },
639 },
640 },
641 [AB8500_CHARGER] = {
642 .num_ranges = 9,
643 .range = (struct ab8500_reg_range[]) {
644 {
645 .first = 0x02,
646 .last = 0x03,
647 },
648 {
649 .first = 0x05,
650 .last = 0x05,
651 },
652 {
653 .first = 0x40,
654 .last = 0x44,
655 },
656 {
657 .first = 0x50,
658 .last = 0x57,
659 },
660 {
661 .first = 0x60,
662 .last = 0x60,
663 },
664 {
665 .first = 0xA0,
666 .last = 0xA7,
667 },
668 {
669 .first = 0xAF,
670 .last = 0xB2,
671 },
672 {
673 .first = 0xC0,
674 .last = 0xC2,
675 },
676 {
677 .first = 0xF5,
678 .last = 0xF5,
679 },
680 },
681 },
682 [AB8500_GAS_GAUGE] = {
683 .num_ranges = 3,
684 .range = (struct ab8500_reg_range[]) {
685 {
686 .first = 0x00,
687 .last = 0x00,
688 },
689 {
690 .first = 0x07,
691 .last = 0x0A,
692 },
693 {
694 .first = 0x10,
695 .last = 0x14,
696 },
697 },
698 },
699 [AB8500_AUDIO] = {
700 .num_ranges = 1,
701 .range = (struct ab8500_reg_range[]) {
702 {
703 .first = 0x00,
704 .last = 0x83,
705 },
706 },
707 },
708 [AB8500_INTERRUPT] = {
709 .num_ranges = 11,
710 .range = (struct ab8500_reg_range[]) {
711 {
712 .first = 0x00,
713 .last = 0x04,
714 },
715 {
716 .first = 0x06,
717 .last = 0x07,
718 },
719 {
720 .first = 0x09,
721 .last = 0x09,
722 },
723 {
724 .first = 0x0B,
725 .last = 0x0C,
726 },
727 {
728 .first = 0x12,
729 .last = 0x15,
730 },
731 {
732 .first = 0x18,
733 .last = 0x18,
734 },
735 /* Latch registers should not be read here */
736 {
737 .first = 0x40,
738 .last = 0x44,
739 },
740 {
741 .first = 0x46,
742 .last = 0x49,
743 },
744 {
745 .first = 0x4B,
746 .last = 0x4D,
747 },
748 {
749 .first = 0x52,
750 .last = 0x55,
751 },
752 {
753 .first = 0x58,
754 .last = 0x58,
755 },
756 /* LatchHier registers should not be read here */
757 },
758 },
759 [AB8500_RTC] = {
760 .num_ranges = 2,
761 .range = (struct ab8500_reg_range[]) {
762 {
763 .first = 0x00,
764 .last = 0x14,
765 },
766 {
767 .first = 0x16,
768 .last = 0x17,
769 },
770 },
771 },
772 [AB8500_MISC] = {
773 .num_ranges = 8,
774 .range = (struct ab8500_reg_range[]) {
775 {
776 .first = 0x00,
777 .last = 0x06,
778 },
779 {
780 .first = 0x10,
781 .last = 0x16,
782 },
783 {
784 .first = 0x20,
785 .last = 0x26,
786 },
787 {
788 .first = 0x30,
789 .last = 0x36,
790 },
791 {
792 .first = 0x40,
793 .last = 0x46,
794 },
795 {
796 .first = 0x50,
797 .last = 0x50,
798 },
799 {
800 .first = 0x60,
801 .last = 0x6B,
802 },
803 {
804 .first = 0x80,
805 .last = 0x82,
806 },
807 },
808 },
809 [AB8500_DEVELOPMENT] = {
810 .num_ranges = 2,
811 .range = (struct ab8500_reg_range[]) {
812 {
813 .first = 0x00,
814 .last = 0x00,
815 },
816 {
817 .first = 0x05,
818 .last = 0x05,
819 },
820 },
821 },
822 [AB8500_DEBUG] = {
823 .num_ranges = 1,
824 .range = (struct ab8500_reg_range[]) {
825 {
826 .first = 0x05,
827 .last = 0x07,
828 },
829 },
830 },
831 [AB8500_PROD_TEST] = {
832 .num_ranges = 0,
833 .range = NULL,
834 },
835 [AB8500_STE_TEST] = {
836 .num_ranges = 0,
837 .range = NULL,
838 },
839 [AB8500_OTP_EMUL] = {
840 .num_ranges = 1,
841 .range = (struct ab8500_reg_range[]) {
842 {
843 .first = 0x01,
844 .last = 0x15,
845 },
846 },
847 },
848};
849
Sachin Kamat8455eae2013-08-23 17:37:42 +0530850static struct ab8500_prcmu_ranges ab8540_debug_ranges[AB8500_NUM_BANKS] = {
Lee Jones971480f2012-11-19 12:20:03 +0100851 [AB8500_M_FSM_RANK] = {
852 .num_ranges = 1,
853 .range = (struct ab8500_reg_range[]) {
854 {
855 .first = 0x00,
856 .last = 0x0B,
857 },
858 },
859 },
860 [AB8500_SYS_CTRL1_BLOCK] = {
861 .num_ranges = 6,
862 .range = (struct ab8500_reg_range[]) {
863 {
864 .first = 0x00,
865 .last = 0x04,
866 },
867 {
868 .first = 0x42,
869 .last = 0x42,
870 },
871 {
872 .first = 0x50,
873 .last = 0x54,
874 },
875 {
876 .first = 0x57,
877 .last = 0x57,
878 },
879 {
880 .first = 0x80,
881 .last = 0x83,
882 },
883 {
884 .first = 0x90,
885 .last = 0x90,
886 },
887 },
888 },
889 [AB8500_SYS_CTRL2_BLOCK] = {
890 .num_ranges = 5,
891 .range = (struct ab8500_reg_range[]) {
892 {
893 .first = 0x00,
894 .last = 0x0D,
895 },
896 {
897 .first = 0x0F,
898 .last = 0x10,
899 },
900 {
901 .first = 0x20,
902 .last = 0x21,
903 },
904 {
905 .first = 0x32,
906 .last = 0x3C,
907 },
908 {
909 .first = 0x40,
910 .last = 0x42,
911 },
912 },
913 },
914 [AB8500_REGU_CTRL1] = {
915 .num_ranges = 4,
916 .range = (struct ab8500_reg_range[]) {
917 {
918 .first = 0x03,
919 .last = 0x15,
920 },
921 {
922 .first = 0x20,
923 .last = 0x20,
924 },
925 {
926 .first = 0x80,
927 .last = 0x85,
928 },
929 {
930 .first = 0x87,
931 .last = 0x88,
932 },
933 },
934 },
935 [AB8500_REGU_CTRL2] = {
936 .num_ranges = 8,
937 .range = (struct ab8500_reg_range[]) {
938 {
939 .first = 0x00,
940 .last = 0x06,
941 },
942 {
943 .first = 0x08,
944 .last = 0x15,
945 },
946 {
947 .first = 0x17,
948 .last = 0x19,
949 },
950 {
951 .first = 0x1B,
952 .last = 0x1D,
953 },
954 {
955 .first = 0x1F,
956 .last = 0x2F,
957 },
958 {
959 .first = 0x31,
960 .last = 0x3A,
961 },
962 {
963 .first = 0x43,
964 .last = 0x44,
965 },
966 {
967 .first = 0x48,
968 .last = 0x49,
969 },
970 },
971 },
972 [AB8500_USB] = {
973 .num_ranges = 3,
974 .range = (struct ab8500_reg_range[]) {
975 {
976 .first = 0x80,
977 .last = 0x83,
978 },
979 {
980 .first = 0x87,
981 .last = 0x8A,
982 },
983 {
984 .first = 0x91,
985 .last = 0x94,
986 },
987 },
988 },
989 [AB8500_TVOUT] = {
990 .num_ranges = 0,
991 .range = NULL
992 },
993 [AB8500_DBI] = {
994 .num_ranges = 4,
995 .range = (struct ab8500_reg_range[]) {
996 {
997 .first = 0x00,
998 .last = 0x07,
999 },
1000 {
1001 .first = 0x10,
1002 .last = 0x11,
1003 },
1004 {
1005 .first = 0x20,
1006 .last = 0x21,
1007 },
1008 {
1009 .first = 0x30,
1010 .last = 0x43,
1011 },
1012 },
1013 },
1014 [AB8500_ECI_AV_ACC] = {
1015 .num_ranges = 2,
1016 .range = (struct ab8500_reg_range[]) {
1017 {
1018 .first = 0x00,
1019 .last = 0x03,
1020 },
1021 {
1022 .first = 0x80,
1023 .last = 0x82,
1024 },
1025 },
1026 },
1027 [AB8500_RESERVED] = {
1028 .num_ranges = 0,
1029 .range = NULL,
1030 },
1031 [AB8500_GPADC] = {
1032 .num_ranges = 4,
1033 .range = (struct ab8500_reg_range[]) {
1034 {
1035 .first = 0x00,
1036 .last = 0x01,
1037 },
1038 {
1039 .first = 0x04,
1040 .last = 0x06,
1041 },
1042 {
1043 .first = 0x09,
1044 .last = 0x0A,
1045 },
1046 {
1047 .first = 0x10,
1048 .last = 0x14,
1049 },
1050 },
1051 },
1052 [AB8500_CHARGER] = {
1053 .num_ranges = 10,
1054 .range = (struct ab8500_reg_range[]) {
1055 {
1056 .first = 0x00,
1057 .last = 0x00,
1058 },
1059 {
1060 .first = 0x02,
1061 .last = 0x05,
1062 },
1063 {
1064 .first = 0x40,
1065 .last = 0x44,
1066 },
1067 {
1068 .first = 0x50,
1069 .last = 0x57,
1070 },
1071 {
1072 .first = 0x60,
1073 .last = 0x60,
1074 },
1075 {
1076 .first = 0x70,
1077 .last = 0x70,
1078 },
1079 {
1080 .first = 0xA0,
1081 .last = 0xA9,
1082 },
1083 {
1084 .first = 0xAF,
1085 .last = 0xB2,
1086 },
1087 {
1088 .first = 0xC0,
1089 .last = 0xC6,
1090 },
1091 {
1092 .first = 0xF5,
1093 .last = 0xF5,
1094 },
1095 },
1096 },
1097 [AB8500_GAS_GAUGE] = {
1098 .num_ranges = 3,
1099 .range = (struct ab8500_reg_range[]) {
1100 {
1101 .first = 0x00,
1102 .last = 0x00,
1103 },
1104 {
1105 .first = 0x07,
1106 .last = 0x0A,
1107 },
1108 {
1109 .first = 0x10,
1110 .last = 0x14,
1111 },
1112 },
1113 },
1114 [AB8500_AUDIO] = {
1115 .num_ranges = 1,
1116 .range = (struct ab8500_reg_range[]) {
1117 {
1118 .first = 0x00,
1119 .last = 0x9f,
1120 },
1121 },
1122 },
1123 [AB8500_INTERRUPT] = {
1124 .num_ranges = 6,
1125 .range = (struct ab8500_reg_range[]) {
1126 {
1127 .first = 0x00,
1128 .last = 0x05,
1129 },
1130 {
1131 .first = 0x0B,
1132 .last = 0x0D,
1133 },
1134 {
1135 .first = 0x12,
1136 .last = 0x20,
1137 },
1138 /* Latch registers should not be read here */
1139 {
1140 .first = 0x40,
1141 .last = 0x45,
1142 },
1143 {
1144 .first = 0x4B,
1145 .last = 0x4D,
1146 },
1147 {
1148 .first = 0x52,
1149 .last = 0x60,
1150 },
1151 /* LatchHier registers should not be read here */
1152 },
1153 },
1154 [AB8500_RTC] = {
1155 .num_ranges = 3,
1156 .range = (struct ab8500_reg_range[]) {
1157 {
1158 .first = 0x00,
1159 .last = 0x07,
1160 },
1161 {
1162 .first = 0x0B,
1163 .last = 0x18,
1164 },
1165 {
1166 .first = 0x20,
1167 .last = 0x25,
1168 },
1169 },
1170 },
1171 [AB8500_MISC] = {
1172 .num_ranges = 9,
1173 .range = (struct ab8500_reg_range[]) {
1174 {
1175 .first = 0x00,
1176 .last = 0x06,
1177 },
1178 {
1179 .first = 0x10,
1180 .last = 0x16,
1181 },
1182 {
1183 .first = 0x20,
1184 .last = 0x26,
1185 },
1186 {
1187 .first = 0x30,
1188 .last = 0x36,
1189 },
1190 {
1191 .first = 0x40,
1192 .last = 0x49,
1193 },
1194 {
1195 .first = 0x50,
1196 .last = 0x50,
1197 },
1198 {
1199 .first = 0x60,
1200 .last = 0x6B,
1201 },
1202 {
1203 .first = 0x70,
1204 .last = 0x74,
1205 },
1206 {
1207 .first = 0x80,
1208 .last = 0x82,
1209 },
1210 },
1211 },
1212 [AB8500_DEVELOPMENT] = {
1213 .num_ranges = 3,
1214 .range = (struct ab8500_reg_range[]) {
1215 {
1216 .first = 0x00,
1217 .last = 0x01,
1218 },
1219 {
1220 .first = 0x06,
1221 .last = 0x06,
1222 },
1223 {
1224 .first = 0x10,
1225 .last = 0x21,
1226 },
1227 },
1228 },
1229 [AB8500_DEBUG] = {
1230 .num_ranges = 3,
1231 .range = (struct ab8500_reg_range[]) {
1232 {
1233 .first = 0x01,
1234 .last = 0x0C,
1235 },
1236 {
1237 .first = 0x0E,
1238 .last = 0x11,
1239 },
1240 {
1241 .first = 0x80,
1242 .last = 0x81,
1243 },
1244 },
1245 },
1246 [AB8500_PROD_TEST] = {
1247 .num_ranges = 0,
1248 .range = NULL,
1249 },
1250 [AB8500_STE_TEST] = {
1251 .num_ranges = 0,
1252 .range = NULL,
1253 },
1254 [AB8500_OTP_EMUL] = {
1255 .num_ranges = 1,
1256 .range = (struct ab8500_reg_range[]) {
1257 {
1258 .first = 0x00,
1259 .last = 0x3F,
1260 },
1261 },
1262 },
1263};
1264
1265
Lee Jones4b8ac082013-01-14 16:10:36 +00001266static irqreturn_t ab8500_debug_handler(int irq, void *data)
1267{
1268 char buf[16];
1269 struct kobject *kobj = (struct kobject *)data;
Mattias Wallin0b337e72010-11-19 17:55:11 +01001270 unsigned int irq_abb = irq - irq_first;
Lee Jones4b8ac082013-01-14 16:10:36 +00001271
Linus Walleijddba25f2012-02-03 11:19:05 +01001272 if (irq_abb < num_irqs)
Mattias Wallin0b337e72010-11-19 17:55:11 +01001273 irq_count[irq_abb]++;
Lee Jones4b8ac082013-01-14 16:10:36 +00001274 /*
1275 * This makes it possible to use poll for events (POLLPRI | POLLERR)
Mattias Wallin0b337e72010-11-19 17:55:11 +01001276 * from userspace on sysfs file named <irq-nr>
Lee Jones4b8ac082013-01-14 16:10:36 +00001277 */
Mattias Wallin0b337e72010-11-19 17:55:11 +01001278 sprintf(buf, "%d", irq);
Lee Jones4b8ac082013-01-14 16:10:36 +00001279 sysfs_notify(kobj, NULL, buf);
1280
1281 return IRQ_HANDLED;
1282}
1283
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001284/* Prints to seq_file or log_buf */
1285static int ab8500_registers_print(struct device *dev, u32 bank,
1286 struct seq_file *s)
Mattias Wallin5814fc32010-09-13 16:05:04 +02001287{
Mattias Wallind7b9f322010-11-26 13:06:39 +01001288 unsigned int i;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001289
Mattias Wallind7b9f322010-11-26 13:06:39 +01001290 for (i = 0; i < debug_ranges[bank].num_ranges; i++) {
1291 u32 reg;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001292
Mattias Wallind7b9f322010-11-26 13:06:39 +01001293 for (reg = debug_ranges[bank].range[i].first;
1294 reg <= debug_ranges[bank].range[i].last;
1295 reg++) {
1296 u8 value;
1297 int err;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001298
Mattias Wallind7b9f322010-11-26 13:06:39 +01001299 err = abx500_get_register_interruptible(dev,
1300 (u8)bank, (u8)reg, &value);
1301 if (err < 0) {
1302 dev_err(dev, "ab->read fail %d\n", err);
1303 return err;
1304 }
Mattias Wallin5814fc32010-09-13 16:05:04 +02001305
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001306 if (s) {
Lee Jones43621752014-07-14 18:29:16 +01001307 err = seq_printf(s,
1308 " [0x%02X/0x%02X]: 0x%02X\n",
1309 bank, reg, value);
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001310 if (err < 0) {
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001311 /* Error is not returned here since
1312 * the output is wanted in any case */
1313 return 0;
1314 }
1315 } else {
Lee Jones43621752014-07-14 18:29:16 +01001316 dev_info(dev, " [0x%02X/0x%02X]: 0x%02X\n",
1317 bank, reg, value);
Mattias Wallind7b9f322010-11-26 13:06:39 +01001318 }
1319 }
1320 }
1321 return 0;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001322}
1323
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001324static int ab8500_print_bank_registers(struct seq_file *s, void *p)
1325{
1326 struct device *dev = s->private;
1327 u32 bank = debug_bank;
1328
Lee Jones43621752014-07-14 18:29:16 +01001329 seq_puts(s, AB8500_NAME_STRING " register values:\n");
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001330
Mattias Wallincfc08492012-05-28 15:53:58 +02001331 seq_printf(s, " bank 0x%02X:\n", bank);
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001332
1333 ab8500_registers_print(dev, bank, s);
1334 return 0;
1335}
1336
Mattias Wallin5814fc32010-09-13 16:05:04 +02001337static int ab8500_registers_open(struct inode *inode, struct file *file)
1338{
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001339 return single_open(file, ab8500_print_bank_registers, inode->i_private);
Mattias Wallin5814fc32010-09-13 16:05:04 +02001340}
1341
1342static const struct file_operations ab8500_registers_fops = {
Mattias Wallind7b9f322010-11-26 13:06:39 +01001343 .open = ab8500_registers_open,
1344 .read = seq_read,
1345 .llseek = seq_lseek,
1346 .release = single_release,
1347 .owner = THIS_MODULE,
Mattias Wallin5814fc32010-09-13 16:05:04 +02001348};
1349
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001350static int ab8500_print_all_banks(struct seq_file *s, void *p)
1351{
1352 struct device *dev = s->private;
1353 unsigned int i;
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001354
Lee Jones43621752014-07-14 18:29:16 +01001355 seq_puts(s, AB8500_NAME_STRING " register values:\n");
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001356
Lee Jones971480f2012-11-19 12:20:03 +01001357 for (i = 0; i < AB8500_NUM_BANKS; i++) {
Rickard Strandqvist93286172014-06-26 15:40:00 +02001358 seq_printf(s, " bank 0x%02X:\n", i);
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001359
1360 ab8500_registers_print(dev, i, s);
1361 }
1362 return 0;
1363}
1364
Mian Yousaf Kaukab1d843a62012-01-27 11:35:41 +01001365/* Dump registers to kernel log */
1366void ab8500_dump_all_banks(struct device *dev)
1367{
1368 unsigned int i;
1369
Lee Jones43621752014-07-14 18:29:16 +01001370 dev_info(dev, "ab8500 register values:\n");
Mian Yousaf Kaukab1d843a62012-01-27 11:35:41 +01001371
1372 for (i = 1; i < AB8500_NUM_BANKS; i++) {
Lee Jones43621752014-07-14 18:29:16 +01001373 dev_info(dev, " bank 0x%02X:\n", i);
Mian Yousaf Kaukab1d843a62012-01-27 11:35:41 +01001374 ab8500_registers_print(dev, i, NULL);
1375 }
1376}
1377
Lee Jones5ff90902013-02-12 14:35:28 +00001378/* Space for 500 registers. */
1379#define DUMP_MAX_REGS 700
Sachin Kamat8455eae2013-08-23 17:37:42 +05301380static struct ab8500_register_dump
Lee Jones5ff90902013-02-12 14:35:28 +00001381{
1382 u8 bank;
1383 u8 reg;
1384 u8 value;
Lee Jones5ff90902013-02-12 14:35:28 +00001385} ab8500_complete_register_dump[DUMP_MAX_REGS];
1386
Lee Jones5ff90902013-02-12 14:35:28 +00001387/* This shall only be called upon kernel panic! */
1388void ab8500_dump_all_banks_to_mem(void)
1389{
1390 int i, r = 0;
1391 u8 bank;
Jonas Aaberg222460c2012-06-18 10:35:28 +02001392 int err = 0;
Lee Jones5ff90902013-02-12 14:35:28 +00001393
Lee Jones43621752014-07-14 18:29:16 +01001394 pr_info("Saving all ABB registers for crash analysis.\n");
Lee Jones5ff90902013-02-12 14:35:28 +00001395
Lee Jones971480f2012-11-19 12:20:03 +01001396 for (bank = 0; bank < AB8500_NUM_BANKS; bank++) {
Lee Jones5ff90902013-02-12 14:35:28 +00001397 for (i = 0; i < debug_ranges[bank].num_ranges; i++) {
1398 u8 reg;
1399
1400 for (reg = debug_ranges[bank].range[i].first;
1401 reg <= debug_ranges[bank].range[i].last;
1402 reg++) {
1403 u8 value;
Lee Jones5ff90902013-02-12 14:35:28 +00001404
1405 err = prcmu_abb_read(bank, reg, &value, 1);
1406
Jonas Aaberg222460c2012-06-18 10:35:28 +02001407 if (err < 0)
1408 goto out;
1409
Lee Jones5ff90902013-02-12 14:35:28 +00001410 ab8500_complete_register_dump[r].bank = bank;
1411 ab8500_complete_register_dump[r].reg = reg;
1412 ab8500_complete_register_dump[r].value = value;
1413
1414 r++;
1415
1416 if (r >= DUMP_MAX_REGS) {
1417 pr_err("%s: too many register to dump!\n",
1418 __func__);
Jonas Aaberg222460c2012-06-18 10:35:28 +02001419 err = -EINVAL;
1420 goto out;
Lee Jones5ff90902013-02-12 14:35:28 +00001421 }
1422 }
1423 }
1424 }
Jonas Aaberg222460c2012-06-18 10:35:28 +02001425out:
1426 if (err >= 0)
1427 pr_info("Saved all ABB registers.\n");
1428 else
1429 pr_info("Failed to save all ABB registers.\n");
Lee Jones5ff90902013-02-12 14:35:28 +00001430}
1431
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01001432static int ab8500_all_banks_open(struct inode *inode, struct file *file)
1433{
1434 struct seq_file *s;
1435 int err;
1436
1437 err = single_open(file, ab8500_print_all_banks, inode->i_private);
1438 if (!err) {
1439 /* Default buf size in seq_read is not enough */
1440 s = (struct seq_file *)file->private_data;
1441 s->size = (PAGE_SIZE * 2);
1442 s->buf = kmalloc(s->size, GFP_KERNEL);
1443 if (!s->buf) {
1444 single_release(inode, file);
1445 err = -ENOMEM;
1446 }
1447 }
1448 return err;
1449}
1450
1451static const struct file_operations ab8500_all_banks_fops = {
1452 .open = ab8500_all_banks_open,
1453 .read = seq_read,
1454 .llseek = seq_lseek,
1455 .release = single_release,
1456 .owner = THIS_MODULE,
1457};
1458
Mattias Wallin5814fc32010-09-13 16:05:04 +02001459static int ab8500_bank_print(struct seq_file *s, void *p)
1460{
Mattias Wallincfc08492012-05-28 15:53:58 +02001461 return seq_printf(s, "0x%02X\n", debug_bank);
Mattias Wallin5814fc32010-09-13 16:05:04 +02001462}
1463
1464static int ab8500_bank_open(struct inode *inode, struct file *file)
1465{
Mattias Wallind7b9f322010-11-26 13:06:39 +01001466 return single_open(file, ab8500_bank_print, inode->i_private);
Mattias Wallin5814fc32010-09-13 16:05:04 +02001467}
1468
1469static ssize_t ab8500_bank_write(struct file *file,
Mattias Wallind7b9f322010-11-26 13:06:39 +01001470 const char __user *user_buf,
1471 size_t count, loff_t *ppos)
Mattias Wallin5814fc32010-09-13 16:05:04 +02001472{
Mattias Wallind7b9f322010-11-26 13:06:39 +01001473 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Mattias Wallind7b9f322010-11-26 13:06:39 +01001474 unsigned long user_bank;
1475 int err;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001476
Peter Huewe8504d632011-06-06 22:43:32 +02001477 err = kstrtoul_from_user(user_buf, count, 0, &user_bank);
Mattias Wallind7b9f322010-11-26 13:06:39 +01001478 if (err)
Peter Huewe8504d632011-06-06 22:43:32 +02001479 return err;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001480
Mattias Wallind7b9f322010-11-26 13:06:39 +01001481 if (user_bank >= AB8500_NUM_BANKS) {
1482 dev_err(dev, "debugfs error input > number of banks\n");
1483 return -EINVAL;
1484 }
Mattias Wallin5814fc32010-09-13 16:05:04 +02001485
Mattias Wallind7b9f322010-11-26 13:06:39 +01001486 debug_bank = user_bank;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001487
Peter Huewe8504d632011-06-06 22:43:32 +02001488 return count;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001489}
1490
1491static int ab8500_address_print(struct seq_file *s, void *p)
1492{
Mattias Wallind7b9f322010-11-26 13:06:39 +01001493 return seq_printf(s, "0x%02X\n", debug_address);
Mattias Wallin5814fc32010-09-13 16:05:04 +02001494}
1495
1496static int ab8500_address_open(struct inode *inode, struct file *file)
1497{
Mattias Wallind7b9f322010-11-26 13:06:39 +01001498 return single_open(file, ab8500_address_print, inode->i_private);
Mattias Wallin5814fc32010-09-13 16:05:04 +02001499}
1500
1501static ssize_t ab8500_address_write(struct file *file,
Lee Jones9f9ba152013-02-26 12:05:15 +00001502 const char __user *user_buf,
1503 size_t count, loff_t *ppos)
Mattias Wallin5814fc32010-09-13 16:05:04 +02001504{
Mattias Wallind7b9f322010-11-26 13:06:39 +01001505 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Mattias Wallind7b9f322010-11-26 13:06:39 +01001506 unsigned long user_address;
1507 int err;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001508
Peter Huewe8504d632011-06-06 22:43:32 +02001509 err = kstrtoul_from_user(user_buf, count, 0, &user_address);
Mattias Wallind7b9f322010-11-26 13:06:39 +01001510 if (err)
Peter Huewe8504d632011-06-06 22:43:32 +02001511 return err;
1512
Mattias Wallind7b9f322010-11-26 13:06:39 +01001513 if (user_address > 0xff) {
1514 dev_err(dev, "debugfs error input > 0xff\n");
1515 return -EINVAL;
1516 }
1517 debug_address = user_address;
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05301518
Peter Huewe8504d632011-06-06 22:43:32 +02001519 return count;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001520}
1521
1522static int ab8500_val_print(struct seq_file *s, void *p)
1523{
Mattias Wallind7b9f322010-11-26 13:06:39 +01001524 struct device *dev = s->private;
1525 int ret;
1526 u8 regvalue;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001527
Mattias Wallind7b9f322010-11-26 13:06:39 +01001528 ret = abx500_get_register_interruptible(dev,
1529 (u8)debug_bank, (u8)debug_address, &regvalue);
1530 if (ret < 0) {
1531 dev_err(dev, "abx500_get_reg fail %d, %d\n",
1532 ret, __LINE__);
1533 return -EINVAL;
1534 }
1535 seq_printf(s, "0x%02X\n", regvalue);
Mattias Wallin5814fc32010-09-13 16:05:04 +02001536
Mattias Wallind7b9f322010-11-26 13:06:39 +01001537 return 0;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001538}
1539
1540static int ab8500_val_open(struct inode *inode, struct file *file)
1541{
Mattias Wallind7b9f322010-11-26 13:06:39 +01001542 return single_open(file, ab8500_val_print, inode->i_private);
Mattias Wallin5814fc32010-09-13 16:05:04 +02001543}
1544
1545static ssize_t ab8500_val_write(struct file *file,
Lee Jones9f9ba152013-02-26 12:05:15 +00001546 const char __user *user_buf,
1547 size_t count, loff_t *ppos)
Mattias Wallin5814fc32010-09-13 16:05:04 +02001548{
Mattias Wallind7b9f322010-11-26 13:06:39 +01001549 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Mattias Wallind7b9f322010-11-26 13:06:39 +01001550 unsigned long user_val;
1551 int err;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001552
Peter Huewe8504d632011-06-06 22:43:32 +02001553 err = kstrtoul_from_user(user_buf, count, 0, &user_val);
Mattias Wallind7b9f322010-11-26 13:06:39 +01001554 if (err)
Peter Huewe8504d632011-06-06 22:43:32 +02001555 return err;
1556
Mattias Wallind7b9f322010-11-26 13:06:39 +01001557 if (user_val > 0xff) {
1558 dev_err(dev, "debugfs error input > 0xff\n");
1559 return -EINVAL;
1560 }
1561 err = abx500_set_register_interruptible(dev,
1562 (u8)debug_bank, debug_address, (u8)user_val);
1563 if (err < 0) {
Lee Jones43621752014-07-14 18:29:16 +01001564 pr_err("abx500_set_reg failed %d, %d", err, __LINE__);
Mattias Wallind7b9f322010-11-26 13:06:39 +01001565 return -EINVAL;
1566 }
Mattias Wallin5814fc32010-09-13 16:05:04 +02001567
Peter Huewe8504d632011-06-06 22:43:32 +02001568 return count;
Mattias Wallin5814fc32010-09-13 16:05:04 +02001569}
1570
carriere etienne0fbce762011-04-08 16:26:36 +02001571/*
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01001572 * Interrupt status
1573 */
1574static u32 num_interrupts[AB8500_MAX_NR_IRQS];
Jonas Aaberg2cf64e22012-05-31 07:57:07 +02001575static u32 num_wake_interrupts[AB8500_MAX_NR_IRQS];
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01001576static int num_interrupt_lines;
1577
Jonas Aaberg2cf64e22012-05-31 07:57:07 +02001578bool __attribute__((weak)) suspend_test_wake_cause_interrupt_is_mine(u32 my_int)
1579{
1580 return false;
1581}
1582
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01001583void ab8500_debug_register_interrupt(int line)
1584{
Jonas Aaberg2cf64e22012-05-31 07:57:07 +02001585 if (line < num_interrupt_lines) {
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01001586 num_interrupts[line]++;
Linus Walleij69991812013-04-12 17:02:09 +02001587 if (suspend_test_wake_cause_interrupt_is_mine(irq_ab8500))
Jonas Aaberg2cf64e22012-05-31 07:57:07 +02001588 num_wake_interrupts[line]++;
1589 }
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01001590}
1591
1592static int ab8500_interrupts_print(struct seq_file *s, void *p)
1593{
1594 int line;
1595
Lee Jones43621752014-07-14 18:29:16 +01001596 seq_puts(s, "name: number: number of: wake:\n");
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01001597
Jonas Aaberg2cf64e22012-05-31 07:57:07 +02001598 for (line = 0; line < num_interrupt_lines; line++) {
1599 struct irq_desc *desc = irq_to_desc(line + irq_first);
Jonas Aaberg2cf64e22012-05-31 07:57:07 +02001600
1601 seq_printf(s, "%3i: %6i %4i", line,
1602 num_interrupts[line],
1603 num_wake_interrupts[line]);
1604
1605 if (desc && desc->name)
1606 seq_printf(s, "-%-8s", desc->name);
Dan Carpenter7c0b2382013-11-13 10:40:30 +03001607 if (desc && desc->action) {
1608 struct irqaction *action = desc->action;
1609
Jonas Aaberg2cf64e22012-05-31 07:57:07 +02001610 seq_printf(s, " %s", action->name);
1611 while ((action = action->next) != NULL)
1612 seq_printf(s, ", %s", action->name);
1613 }
1614 seq_putc(s, '\n');
1615 }
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01001616
1617 return 0;
1618}
1619
1620static int ab8500_interrupts_open(struct inode *inode, struct file *file)
1621{
1622 return single_open(file, ab8500_interrupts_print, inode->i_private);
1623}
1624
1625/*
carriere etienne0fbce762011-04-08 16:26:36 +02001626 * - HWREG DB8500 formated routines
1627 */
1628static int ab8500_hwreg_print(struct seq_file *s, void *d)
1629{
1630 struct device *dev = s->private;
1631 int ret;
1632 u8 regvalue;
1633
1634 ret = abx500_get_register_interruptible(dev,
1635 (u8)hwreg_cfg.bank, (u8)hwreg_cfg.addr, &regvalue);
1636 if (ret < 0) {
1637 dev_err(dev, "abx500_get_reg fail %d, %d\n",
1638 ret, __LINE__);
1639 return -EINVAL;
1640 }
1641
1642 if (hwreg_cfg.shift >= 0)
1643 regvalue >>= hwreg_cfg.shift;
1644 else
1645 regvalue <<= -hwreg_cfg.shift;
1646 regvalue &= hwreg_cfg.mask;
1647
1648 if (REG_FMT_DEC(&hwreg_cfg))
1649 seq_printf(s, "%d\n", regvalue);
1650 else
1651 seq_printf(s, "0x%02X\n", regvalue);
1652 return 0;
1653}
1654
1655static int ab8500_hwreg_open(struct inode *inode, struct file *file)
1656{
1657 return single_open(file, ab8500_hwreg_print, inode->i_private);
1658}
1659
Lee Jonesc7ebaee2013-02-26 14:03:33 +00001660#define AB8500_SUPPLY_CONTROL_CONFIG_1 0x01
1661#define AB8500_SUPPLY_CONTROL_REG 0x00
1662#define AB8500_FIRST_SIM_REG 0x80
1663#define AB8500_LAST_SIM_REG 0x8B
1664#define AB8505_LAST_SIM_REG 0x8C
1665
1666static int ab8500_print_modem_registers(struct seq_file *s, void *p)
1667{
1668 struct device *dev = s->private;
1669 struct ab8500 *ab8500;
1670 int err;
1671 u8 value;
1672 u8 orig_value;
1673 u32 bank = AB8500_REGU_CTRL2;
1674 u32 last_sim_reg = AB8500_LAST_SIM_REG;
1675 u32 reg;
1676
1677 ab8500 = dev_get_drvdata(dev->parent);
1678 dev_warn(dev, "WARNING! This operation can interfer with modem side\n"
1679 "and should only be done with care\n");
1680
1681 err = abx500_get_register_interruptible(dev,
1682 AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, &orig_value);
1683 if (err < 0) {
1684 dev_err(dev, "ab->read fail %d\n", err);
1685 return err;
1686 }
1687 /* Config 1 will allow APE side to read SIM registers */
1688 err = abx500_set_register_interruptible(dev,
1689 AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG,
1690 AB8500_SUPPLY_CONTROL_CONFIG_1);
1691 if (err < 0) {
1692 dev_err(dev, "ab->write fail %d\n", err);
1693 return err;
1694 }
1695
1696 seq_printf(s, " bank 0x%02X:\n", bank);
1697
1698 if (is_ab9540(ab8500) || is_ab8505(ab8500))
1699 last_sim_reg = AB8505_LAST_SIM_REG;
1700
1701 for (reg = AB8500_FIRST_SIM_REG; reg <= last_sim_reg; reg++) {
1702 err = abx500_get_register_interruptible(dev,
1703 bank, reg, &value);
1704 if (err < 0) {
1705 dev_err(dev, "ab->read fail %d\n", err);
1706 return err;
1707 }
1708 err = seq_printf(s, " [0x%02X/0x%02X]: 0x%02X\n",
1709 bank, reg, value);
1710 }
1711 err = abx500_set_register_interruptible(dev,
1712 AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, orig_value);
1713 if (err < 0) {
1714 dev_err(dev, "ab->write fail %d\n", err);
1715 return err;
1716 }
1717 return 0;
1718}
1719
1720static int ab8500_modem_open(struct inode *inode, struct file *file)
1721{
Lee Jones43621752014-07-14 18:29:16 +01001722 return single_open(file, ab8500_print_modem_registers,
1723 inode->i_private);
Lee Jonesc7ebaee2013-02-26 14:03:33 +00001724}
1725
1726static const struct file_operations ab8500_modem_fops = {
1727 .open = ab8500_modem_open,
1728 .read = seq_read,
1729 .llseek = seq_lseek,
1730 .release = single_release,
1731 .owner = THIS_MODULE,
1732};
1733
John Beckett1478a312011-05-31 13:54:27 +01001734static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p)
1735{
1736 int bat_ctrl_raw;
1737 int bat_ctrl_convert;
1738 struct ab8500_gpadc *gpadc;
1739
Philippe Langlais8908c042012-04-18 15:52:59 +02001740 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00001741 bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL,
1742 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01001743 bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc,
Lee Jones73482342013-02-26 10:06:55 +00001744 BAT_CTRL, bat_ctrl_raw);
John Beckett1478a312011-05-31 13:54:27 +01001745
1746 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00001747 bat_ctrl_convert, bat_ctrl_raw);
John Beckett1478a312011-05-31 13:54:27 +01001748}
1749
1750static int ab8500_gpadc_bat_ctrl_open(struct inode *inode, struct file *file)
1751{
Lee Jones43621752014-07-14 18:29:16 +01001752 return single_open(file, ab8500_gpadc_bat_ctrl_print,
1753 inode->i_private);
John Beckett1478a312011-05-31 13:54:27 +01001754}
1755
1756static const struct file_operations ab8500_gpadc_bat_ctrl_fops = {
1757 .open = ab8500_gpadc_bat_ctrl_open,
1758 .read = seq_read,
1759 .llseek = seq_lseek,
1760 .release = single_release,
1761 .owner = THIS_MODULE,
1762};
1763
1764static int ab8500_gpadc_btemp_ball_print(struct seq_file *s, void *p)
1765{
1766 int btemp_ball_raw;
1767 int btemp_ball_convert;
1768 struct ab8500_gpadc *gpadc;
1769
Philippe Langlais8908c042012-04-18 15:52:59 +02001770 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00001771 btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL,
1772 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01001773 btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
Lee Jones73482342013-02-26 10:06:55 +00001774 btemp_ball_raw);
John Beckett1478a312011-05-31 13:54:27 +01001775
1776 return seq_printf(s,
Lee Jones9f9ba152013-02-26 12:05:15 +00001777 "%d,0x%X\n", btemp_ball_convert, btemp_ball_raw);
John Beckett1478a312011-05-31 13:54:27 +01001778}
1779
1780static int ab8500_gpadc_btemp_ball_open(struct inode *inode,
Lee Jones9f9ba152013-02-26 12:05:15 +00001781 struct file *file)
John Beckett1478a312011-05-31 13:54:27 +01001782{
Lee Jones43621752014-07-14 18:29:16 +01001783 return single_open(file, ab8500_gpadc_btemp_ball_print,
1784 inode->i_private);
John Beckett1478a312011-05-31 13:54:27 +01001785}
1786
1787static const struct file_operations ab8500_gpadc_btemp_ball_fops = {
1788 .open = ab8500_gpadc_btemp_ball_open,
1789 .read = seq_read,
1790 .llseek = seq_lseek,
1791 .release = single_release,
1792 .owner = THIS_MODULE,
1793};
1794
1795static int ab8500_gpadc_main_charger_v_print(struct seq_file *s, void *p)
1796{
1797 int main_charger_v_raw;
1798 int main_charger_v_convert;
1799 struct ab8500_gpadc *gpadc;
1800
Philippe Langlais8908c042012-04-18 15:52:59 +02001801 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00001802 main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V,
1803 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01001804 main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
Lee Jones73482342013-02-26 10:06:55 +00001805 MAIN_CHARGER_V, main_charger_v_raw);
John Beckett1478a312011-05-31 13:54:27 +01001806
1807 return seq_printf(s, "%d,0x%X\n",
1808 main_charger_v_convert, main_charger_v_raw);
1809}
1810
1811static int ab8500_gpadc_main_charger_v_open(struct inode *inode,
Lee Jones9f9ba152013-02-26 12:05:15 +00001812 struct file *file)
John Beckett1478a312011-05-31 13:54:27 +01001813{
1814 return single_open(file, ab8500_gpadc_main_charger_v_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00001815 inode->i_private);
John Beckett1478a312011-05-31 13:54:27 +01001816}
1817
1818static const struct file_operations ab8500_gpadc_main_charger_v_fops = {
1819 .open = ab8500_gpadc_main_charger_v_open,
1820 .read = seq_read,
1821 .llseek = seq_lseek,
1822 .release = single_release,
1823 .owner = THIS_MODULE,
1824};
1825
1826static int ab8500_gpadc_acc_detect1_print(struct seq_file *s, void *p)
1827{
1828 int acc_detect1_raw;
1829 int acc_detect1_convert;
1830 struct ab8500_gpadc *gpadc;
1831
Philippe Langlais8908c042012-04-18 15:52:59 +02001832 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00001833 acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1,
1834 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01001835 acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1,
Lee Jones73482342013-02-26 10:06:55 +00001836 acc_detect1_raw);
John Beckett1478a312011-05-31 13:54:27 +01001837
1838 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00001839 acc_detect1_convert, acc_detect1_raw);
John Beckett1478a312011-05-31 13:54:27 +01001840}
1841
1842static int ab8500_gpadc_acc_detect1_open(struct inode *inode,
Lee Jones9f9ba152013-02-26 12:05:15 +00001843 struct file *file)
John Beckett1478a312011-05-31 13:54:27 +01001844{
1845 return single_open(file, ab8500_gpadc_acc_detect1_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00001846 inode->i_private);
John Beckett1478a312011-05-31 13:54:27 +01001847}
1848
1849static const struct file_operations ab8500_gpadc_acc_detect1_fops = {
1850 .open = ab8500_gpadc_acc_detect1_open,
1851 .read = seq_read,
1852 .llseek = seq_lseek,
1853 .release = single_release,
1854 .owner = THIS_MODULE,
1855};
1856
1857static int ab8500_gpadc_acc_detect2_print(struct seq_file *s, void *p)
1858{
1859 int acc_detect2_raw;
1860 int acc_detect2_convert;
1861 struct ab8500_gpadc *gpadc;
1862
Philippe Langlais8908c042012-04-18 15:52:59 +02001863 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00001864 acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2,
1865 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01001866 acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc,
Lee Jones73482342013-02-26 10:06:55 +00001867 ACC_DETECT2, acc_detect2_raw);
John Beckett1478a312011-05-31 13:54:27 +01001868
1869 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00001870 acc_detect2_convert, acc_detect2_raw);
John Beckett1478a312011-05-31 13:54:27 +01001871}
1872
1873static int ab8500_gpadc_acc_detect2_open(struct inode *inode,
1874 struct file *file)
1875{
1876 return single_open(file, ab8500_gpadc_acc_detect2_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00001877 inode->i_private);
John Beckett1478a312011-05-31 13:54:27 +01001878}
1879
1880static const struct file_operations ab8500_gpadc_acc_detect2_fops = {
1881 .open = ab8500_gpadc_acc_detect2_open,
1882 .read = seq_read,
1883 .llseek = seq_lseek,
1884 .release = single_release,
1885 .owner = THIS_MODULE,
1886};
1887
1888static int ab8500_gpadc_aux1_print(struct seq_file *s, void *p)
1889{
1890 int aux1_raw;
1891 int aux1_convert;
1892 struct ab8500_gpadc *gpadc;
1893
Philippe Langlais8908c042012-04-18 15:52:59 +02001894 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00001895 aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1,
1896 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01001897 aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1,
Lee Jones73482342013-02-26 10:06:55 +00001898 aux1_raw);
John Beckett1478a312011-05-31 13:54:27 +01001899
1900 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00001901 aux1_convert, aux1_raw);
John Beckett1478a312011-05-31 13:54:27 +01001902}
1903
1904static int ab8500_gpadc_aux1_open(struct inode *inode, struct file *file)
1905{
1906 return single_open(file, ab8500_gpadc_aux1_print, inode->i_private);
1907}
1908
1909static const struct file_operations ab8500_gpadc_aux1_fops = {
1910 .open = ab8500_gpadc_aux1_open,
1911 .read = seq_read,
1912 .llseek = seq_lseek,
1913 .release = single_release,
1914 .owner = THIS_MODULE,
1915};
1916
1917static int ab8500_gpadc_aux2_print(struct seq_file *s, void *p)
1918{
1919 int aux2_raw;
1920 int aux2_convert;
1921 struct ab8500_gpadc *gpadc;
1922
Philippe Langlais8908c042012-04-18 15:52:59 +02001923 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00001924 aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2,
1925 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01001926 aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2,
Lee Jones73482342013-02-26 10:06:55 +00001927 aux2_raw);
John Beckett1478a312011-05-31 13:54:27 +01001928
1929 return seq_printf(s, "%d,0x%X\n",
1930 aux2_convert, aux2_raw);
1931}
1932
1933static int ab8500_gpadc_aux2_open(struct inode *inode, struct file *file)
1934{
1935 return single_open(file, ab8500_gpadc_aux2_print, inode->i_private);
1936}
1937
1938static const struct file_operations ab8500_gpadc_aux2_fops = {
1939 .open = ab8500_gpadc_aux2_open,
1940 .read = seq_read,
1941 .llseek = seq_lseek,
1942 .release = single_release,
1943 .owner = THIS_MODULE,
1944};
1945
1946static int ab8500_gpadc_main_bat_v_print(struct seq_file *s, void *p)
1947{
1948 int main_bat_v_raw;
1949 int main_bat_v_convert;
1950 struct ab8500_gpadc *gpadc;
1951
Philippe Langlais8908c042012-04-18 15:52:59 +02001952 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00001953 main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V,
1954 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01001955 main_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
Lee Jones73482342013-02-26 10:06:55 +00001956 main_bat_v_raw);
John Beckett1478a312011-05-31 13:54:27 +01001957
1958 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00001959 main_bat_v_convert, main_bat_v_raw);
John Beckett1478a312011-05-31 13:54:27 +01001960}
1961
1962static int ab8500_gpadc_main_bat_v_open(struct inode *inode,
Lee Jones9f9ba152013-02-26 12:05:15 +00001963 struct file *file)
John Beckett1478a312011-05-31 13:54:27 +01001964{
Lee Jones43621752014-07-14 18:29:16 +01001965 return single_open(file, ab8500_gpadc_main_bat_v_print,
1966 inode->i_private);
John Beckett1478a312011-05-31 13:54:27 +01001967}
1968
1969static const struct file_operations ab8500_gpadc_main_bat_v_fops = {
1970 .open = ab8500_gpadc_main_bat_v_open,
1971 .read = seq_read,
1972 .llseek = seq_lseek,
1973 .release = single_release,
1974 .owner = THIS_MODULE,
1975};
1976
1977static int ab8500_gpadc_vbus_v_print(struct seq_file *s, void *p)
1978{
1979 int vbus_v_raw;
1980 int vbus_v_convert;
1981 struct ab8500_gpadc *gpadc;
1982
Philippe Langlais8908c042012-04-18 15:52:59 +02001983 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00001984 vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V,
1985 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01001986 vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V,
Lee Jones73482342013-02-26 10:06:55 +00001987 vbus_v_raw);
John Beckett1478a312011-05-31 13:54:27 +01001988
1989 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00001990 vbus_v_convert, vbus_v_raw);
John Beckett1478a312011-05-31 13:54:27 +01001991}
1992
1993static int ab8500_gpadc_vbus_v_open(struct inode *inode, struct file *file)
1994{
1995 return single_open(file, ab8500_gpadc_vbus_v_print, inode->i_private);
1996}
1997
1998static const struct file_operations ab8500_gpadc_vbus_v_fops = {
1999 .open = ab8500_gpadc_vbus_v_open,
2000 .read = seq_read,
2001 .llseek = seq_lseek,
2002 .release = single_release,
2003 .owner = THIS_MODULE,
2004};
2005
2006static int ab8500_gpadc_main_charger_c_print(struct seq_file *s, void *p)
2007{
2008 int main_charger_c_raw;
2009 int main_charger_c_convert;
2010 struct ab8500_gpadc *gpadc;
2011
Philippe Langlais8908c042012-04-18 15:52:59 +02002012 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00002013 main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C,
2014 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01002015 main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
Lee Jones73482342013-02-26 10:06:55 +00002016 MAIN_CHARGER_C, main_charger_c_raw);
John Beckett1478a312011-05-31 13:54:27 +01002017
2018 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00002019 main_charger_c_convert, main_charger_c_raw);
John Beckett1478a312011-05-31 13:54:27 +01002020}
2021
2022static int ab8500_gpadc_main_charger_c_open(struct inode *inode,
2023 struct file *file)
2024{
2025 return single_open(file, ab8500_gpadc_main_charger_c_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002026 inode->i_private);
John Beckett1478a312011-05-31 13:54:27 +01002027}
2028
2029static const struct file_operations ab8500_gpadc_main_charger_c_fops = {
2030 .open = ab8500_gpadc_main_charger_c_open,
2031 .read = seq_read,
2032 .llseek = seq_lseek,
2033 .release = single_release,
2034 .owner = THIS_MODULE,
2035};
2036
2037static int ab8500_gpadc_usb_charger_c_print(struct seq_file *s, void *p)
2038{
2039 int usb_charger_c_raw;
2040 int usb_charger_c_convert;
2041 struct ab8500_gpadc *gpadc;
2042
Philippe Langlais8908c042012-04-18 15:52:59 +02002043 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00002044 usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C,
2045 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01002046 usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
Lee Jones73482342013-02-26 10:06:55 +00002047 USB_CHARGER_C, usb_charger_c_raw);
John Beckett1478a312011-05-31 13:54:27 +01002048
2049 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00002050 usb_charger_c_convert, usb_charger_c_raw);
John Beckett1478a312011-05-31 13:54:27 +01002051}
2052
2053static int ab8500_gpadc_usb_charger_c_open(struct inode *inode,
2054 struct file *file)
2055{
2056 return single_open(file, ab8500_gpadc_usb_charger_c_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002057 inode->i_private);
John Beckett1478a312011-05-31 13:54:27 +01002058}
2059
2060static const struct file_operations ab8500_gpadc_usb_charger_c_fops = {
2061 .open = ab8500_gpadc_usb_charger_c_open,
2062 .read = seq_read,
2063 .llseek = seq_lseek,
2064 .release = single_release,
2065 .owner = THIS_MODULE,
2066};
2067
2068static int ab8500_gpadc_bk_bat_v_print(struct seq_file *s, void *p)
2069{
2070 int bk_bat_v_raw;
2071 int bk_bat_v_convert;
2072 struct ab8500_gpadc *gpadc;
2073
Philippe Langlais8908c042012-04-18 15:52:59 +02002074 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00002075 bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V,
2076 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01002077 bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
Lee Jones73482342013-02-26 10:06:55 +00002078 BK_BAT_V, bk_bat_v_raw);
John Beckett1478a312011-05-31 13:54:27 +01002079
2080 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00002081 bk_bat_v_convert, bk_bat_v_raw);
John Beckett1478a312011-05-31 13:54:27 +01002082}
2083
2084static int ab8500_gpadc_bk_bat_v_open(struct inode *inode, struct file *file)
2085{
Lee Jones43621752014-07-14 18:29:16 +01002086 return single_open(file, ab8500_gpadc_bk_bat_v_print,
2087 inode->i_private);
John Beckett1478a312011-05-31 13:54:27 +01002088}
2089
2090static const struct file_operations ab8500_gpadc_bk_bat_v_fops = {
2091 .open = ab8500_gpadc_bk_bat_v_open,
2092 .read = seq_read,
2093 .llseek = seq_lseek,
2094 .release = single_release,
2095 .owner = THIS_MODULE,
2096};
2097
2098static int ab8500_gpadc_die_temp_print(struct seq_file *s, void *p)
2099{
2100 int die_temp_raw;
2101 int die_temp_convert;
2102 struct ab8500_gpadc *gpadc;
2103
Philippe Langlais8908c042012-04-18 15:52:59 +02002104 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
Lee Jones73482342013-02-26 10:06:55 +00002105 die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP,
2106 avg_sample, trig_edge, trig_timer, conv_type);
John Beckett1478a312011-05-31 13:54:27 +01002107 die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP,
Lee Jones73482342013-02-26 10:06:55 +00002108 die_temp_raw);
John Beckett1478a312011-05-31 13:54:27 +01002109
2110 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00002111 die_temp_convert, die_temp_raw);
John Beckett1478a312011-05-31 13:54:27 +01002112}
2113
2114static int ab8500_gpadc_die_temp_open(struct inode *inode, struct file *file)
2115{
Lee Jones43621752014-07-14 18:29:16 +01002116 return single_open(file, ab8500_gpadc_die_temp_print,
2117 inode->i_private);
John Beckett1478a312011-05-31 13:54:27 +01002118}
2119
2120static const struct file_operations ab8500_gpadc_die_temp_fops = {
2121 .open = ab8500_gpadc_die_temp_open,
2122 .read = seq_read,
2123 .llseek = seq_lseek,
2124 .release = single_release,
2125 .owner = THIS_MODULE,
2126};
2127
Lee Jones127629d2013-02-26 14:04:37 +00002128static int ab8500_gpadc_usb_id_print(struct seq_file *s, void *p)
2129{
2130 int usb_id_raw;
2131 int usb_id_convert;
2132 struct ab8500_gpadc *gpadc;
2133
2134 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
2135 usb_id_raw = ab8500_gpadc_read_raw(gpadc, USB_ID,
2136 avg_sample, trig_edge, trig_timer, conv_type);
2137 usb_id_convert = ab8500_gpadc_ad_to_voltage(gpadc, USB_ID,
2138 usb_id_raw);
2139
2140 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00002141 usb_id_convert, usb_id_raw);
Lee Jones127629d2013-02-26 14:04:37 +00002142}
2143
2144static int ab8500_gpadc_usb_id_open(struct inode *inode, struct file *file)
2145{
2146 return single_open(file, ab8500_gpadc_usb_id_print, inode->i_private);
2147}
2148
2149static const struct file_operations ab8500_gpadc_usb_id_fops = {
2150 .open = ab8500_gpadc_usb_id_open,
2151 .read = seq_read,
2152 .llseek = seq_lseek,
2153 .release = single_release,
2154 .owner = THIS_MODULE,
2155};
2156
Lee Jonesbc6b4132013-02-26 14:02:31 +00002157static int ab8540_gpadc_xtal_temp_print(struct seq_file *s, void *p)
2158{
2159 int xtal_temp_raw;
2160 int xtal_temp_convert;
2161 struct ab8500_gpadc *gpadc;
2162
2163 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
2164 xtal_temp_raw = ab8500_gpadc_read_raw(gpadc, XTAL_TEMP,
2165 avg_sample, trig_edge, trig_timer, conv_type);
2166 xtal_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, XTAL_TEMP,
2167 xtal_temp_raw);
2168
2169 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00002170 xtal_temp_convert, xtal_temp_raw);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002171}
2172
2173static int ab8540_gpadc_xtal_temp_open(struct inode *inode, struct file *file)
2174{
2175 return single_open(file, ab8540_gpadc_xtal_temp_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002176 inode->i_private);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002177}
2178
2179static const struct file_operations ab8540_gpadc_xtal_temp_fops = {
2180 .open = ab8540_gpadc_xtal_temp_open,
2181 .read = seq_read,
2182 .llseek = seq_lseek,
2183 .release = single_release,
2184 .owner = THIS_MODULE,
2185};
2186
2187static int ab8540_gpadc_vbat_true_meas_print(struct seq_file *s, void *p)
2188{
2189 int vbat_true_meas_raw;
2190 int vbat_true_meas_convert;
2191 struct ab8500_gpadc *gpadc;
2192
2193 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
2194 vbat_true_meas_raw = ab8500_gpadc_read_raw(gpadc, VBAT_TRUE_MEAS,
2195 avg_sample, trig_edge, trig_timer, conv_type);
Lee Jones43621752014-07-14 18:29:16 +01002196 vbat_true_meas_convert =
2197 ab8500_gpadc_ad_to_voltage(gpadc, VBAT_TRUE_MEAS,
2198 vbat_true_meas_raw);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002199
2200 return seq_printf(s, "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00002201 vbat_true_meas_convert, vbat_true_meas_raw);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002202}
2203
2204static int ab8540_gpadc_vbat_true_meas_open(struct inode *inode,
2205 struct file *file)
2206{
2207 return single_open(file, ab8540_gpadc_vbat_true_meas_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002208 inode->i_private);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002209}
2210
2211static const struct file_operations ab8540_gpadc_vbat_true_meas_fops = {
2212 .open = ab8540_gpadc_vbat_true_meas_open,
2213 .read = seq_read,
2214 .llseek = seq_lseek,
2215 .release = single_release,
2216 .owner = THIS_MODULE,
2217};
2218
2219static int ab8540_gpadc_bat_ctrl_and_ibat_print(struct seq_file *s, void *p)
2220{
2221 int bat_ctrl_raw;
2222 int bat_ctrl_convert;
2223 int ibat_raw;
2224 int ibat_convert;
2225 struct ab8500_gpadc *gpadc;
2226
2227 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
2228 bat_ctrl_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_CTRL_AND_IBAT,
2229 avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
2230
2231 bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc, BAT_CTRL,
2232 bat_ctrl_raw);
2233 ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
2234 ibat_raw);
2235
2236 return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00002237 bat_ctrl_convert, bat_ctrl_raw,
2238 ibat_convert, ibat_raw);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002239}
2240
2241static int ab8540_gpadc_bat_ctrl_and_ibat_open(struct inode *inode,
2242 struct file *file)
2243{
2244 return single_open(file, ab8540_gpadc_bat_ctrl_and_ibat_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002245 inode->i_private);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002246}
2247
2248static const struct file_operations ab8540_gpadc_bat_ctrl_and_ibat_fops = {
2249 .open = ab8540_gpadc_bat_ctrl_and_ibat_open,
2250 .read = seq_read,
2251 .llseek = seq_lseek,
2252 .release = single_release,
2253 .owner = THIS_MODULE,
2254};
2255
2256static int ab8540_gpadc_vbat_meas_and_ibat_print(struct seq_file *s, void *p)
2257{
2258 int vbat_meas_raw;
2259 int vbat_meas_convert;
2260 int ibat_raw;
2261 int ibat_convert;
2262 struct ab8500_gpadc *gpadc;
2263
2264 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
2265 vbat_meas_raw = ab8500_gpadc_double_read_raw(gpadc, VBAT_MEAS_AND_IBAT,
2266 avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
2267 vbat_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
2268 vbat_meas_raw);
2269 ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
2270 ibat_raw);
2271
2272 return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00002273 vbat_meas_convert, vbat_meas_raw,
2274 ibat_convert, ibat_raw);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002275}
2276
2277static int ab8540_gpadc_vbat_meas_and_ibat_open(struct inode *inode,
2278 struct file *file)
2279{
2280 return single_open(file, ab8540_gpadc_vbat_meas_and_ibat_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002281 inode->i_private);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002282}
2283
2284static const struct file_operations ab8540_gpadc_vbat_meas_and_ibat_fops = {
2285 .open = ab8540_gpadc_vbat_meas_and_ibat_open,
2286 .read = seq_read,
2287 .llseek = seq_lseek,
2288 .release = single_release,
2289 .owner = THIS_MODULE,
2290};
2291
Lee Jones43621752014-07-14 18:29:16 +01002292static int ab8540_gpadc_vbat_true_meas_and_ibat_print(struct seq_file *s,
2293 void *p)
Lee Jonesbc6b4132013-02-26 14:02:31 +00002294{
2295 int vbat_true_meas_raw;
2296 int vbat_true_meas_convert;
2297 int ibat_raw;
2298 int ibat_convert;
2299 struct ab8500_gpadc *gpadc;
2300
2301 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
2302 vbat_true_meas_raw = ab8500_gpadc_double_read_raw(gpadc,
2303 VBAT_TRUE_MEAS_AND_IBAT, avg_sample, trig_edge,
2304 trig_timer, conv_type, &ibat_raw);
2305 vbat_true_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc,
2306 VBAT_TRUE_MEAS, vbat_true_meas_raw);
2307 ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
2308 ibat_raw);
2309
2310 return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00002311 vbat_true_meas_convert, vbat_true_meas_raw,
2312 ibat_convert, ibat_raw);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002313}
2314
2315static int ab8540_gpadc_vbat_true_meas_and_ibat_open(struct inode *inode,
2316 struct file *file)
2317{
2318 return single_open(file, ab8540_gpadc_vbat_true_meas_and_ibat_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002319 inode->i_private);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002320}
2321
Lee Jones43621752014-07-14 18:29:16 +01002322static const struct file_operations
2323ab8540_gpadc_vbat_true_meas_and_ibat_fops = {
Lee Jonesbc6b4132013-02-26 14:02:31 +00002324 .open = ab8540_gpadc_vbat_true_meas_and_ibat_open,
2325 .read = seq_read,
2326 .llseek = seq_lseek,
2327 .release = single_release,
2328 .owner = THIS_MODULE,
2329};
2330
2331static int ab8540_gpadc_bat_temp_and_ibat_print(struct seq_file *s, void *p)
2332{
2333 int bat_temp_raw;
2334 int bat_temp_convert;
2335 int ibat_raw;
2336 int ibat_convert;
2337 struct ab8500_gpadc *gpadc;
2338
2339 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
2340 bat_temp_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_TEMP_AND_IBAT,
2341 avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
2342 bat_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
2343 bat_temp_raw);
2344 ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
2345 ibat_raw);
2346
2347 return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n",
Lee Jones9f9ba152013-02-26 12:05:15 +00002348 bat_temp_convert, bat_temp_raw,
2349 ibat_convert, ibat_raw);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002350}
2351
2352static int ab8540_gpadc_bat_temp_and_ibat_open(struct inode *inode,
2353 struct file *file)
2354{
2355 return single_open(file, ab8540_gpadc_bat_temp_and_ibat_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002356 inode->i_private);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002357}
2358
2359static const struct file_operations ab8540_gpadc_bat_temp_and_ibat_fops = {
2360 .open = ab8540_gpadc_bat_temp_and_ibat_open,
2361 .read = seq_read,
2362 .llseek = seq_lseek,
2363 .release = single_release,
2364 .owner = THIS_MODULE,
2365};
2366
2367static int ab8540_gpadc_otp_cal_print(struct seq_file *s, void *p)
2368{
2369 struct ab8500_gpadc *gpadc;
2370 u16 vmain_l, vmain_h, btemp_l, btemp_h;
2371 u16 vbat_l, vbat_h, ibat_l, ibat_h;
2372
2373 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
2374 ab8540_gpadc_get_otp(gpadc, &vmain_l, &vmain_h, &btemp_l, &btemp_h,
2375 &vbat_l, &vbat_h, &ibat_l, &ibat_h);
2376 return seq_printf(s, "VMAIN_L:0x%X\n"
Lee Jones43621752014-07-14 18:29:16 +01002377 "VMAIN_H:0x%X\n"
2378 "BTEMP_L:0x%X\n"
2379 "BTEMP_H:0x%X\n"
2380 "VBAT_L:0x%X\n"
2381 "VBAT_H:0x%X\n"
2382 "IBAT_L:0x%X\n"
2383 "IBAT_H:0x%X\n",
2384 vmain_l, vmain_h, btemp_l, btemp_h,
2385 vbat_l, vbat_h, ibat_l, ibat_h);
Lee Jonesbc6b4132013-02-26 14:02:31 +00002386}
2387
2388static int ab8540_gpadc_otp_cal_open(struct inode *inode, struct file *file)
2389{
2390 return single_open(file, ab8540_gpadc_otp_cal_print, inode->i_private);
2391}
2392
2393static const struct file_operations ab8540_gpadc_otp_calib_fops = {
2394 .open = ab8540_gpadc_otp_cal_open,
2395 .read = seq_read,
2396 .llseek = seq_lseek,
2397 .release = single_release,
2398 .owner = THIS_MODULE,
2399};
2400
Lee Jones73482342013-02-26 10:06:55 +00002401static int ab8500_gpadc_avg_sample_print(struct seq_file *s, void *p)
2402{
2403 return seq_printf(s, "%d\n", avg_sample);
2404}
2405
2406static int ab8500_gpadc_avg_sample_open(struct inode *inode, struct file *file)
2407{
2408 return single_open(file, ab8500_gpadc_avg_sample_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002409 inode->i_private);
Lee Jones73482342013-02-26 10:06:55 +00002410}
2411
2412static ssize_t ab8500_gpadc_avg_sample_write(struct file *file,
2413 const char __user *user_buf,
2414 size_t count, loff_t *ppos)
2415{
2416 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Lee Jones73482342013-02-26 10:06:55 +00002417 unsigned long user_avg_sample;
2418 int err;
2419
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302420 err = kstrtoul_from_user(user_buf, count, 0, &user_avg_sample);
Lee Jones73482342013-02-26 10:06:55 +00002421 if (err)
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302422 return err;
2423
Lee Jones73482342013-02-26 10:06:55 +00002424 if ((user_avg_sample == SAMPLE_1) || (user_avg_sample == SAMPLE_4)
2425 || (user_avg_sample == SAMPLE_8)
2426 || (user_avg_sample == SAMPLE_16)) {
2427 avg_sample = (u8) user_avg_sample;
2428 } else {
Lee Jones43621752014-07-14 18:29:16 +01002429 dev_err(dev,
2430 "debugfs err input: should be egal to 1, 4, 8 or 16\n");
Lee Jones73482342013-02-26 10:06:55 +00002431 return -EINVAL;
2432 }
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302433
2434 return count;
Lee Jones73482342013-02-26 10:06:55 +00002435}
2436
2437static const struct file_operations ab8500_gpadc_avg_sample_fops = {
2438 .open = ab8500_gpadc_avg_sample_open,
2439 .read = seq_read,
2440 .write = ab8500_gpadc_avg_sample_write,
2441 .llseek = seq_lseek,
2442 .release = single_release,
2443 .owner = THIS_MODULE,
2444};
2445
2446static int ab8500_gpadc_trig_edge_print(struct seq_file *s, void *p)
2447{
2448 return seq_printf(s, "%d\n", trig_edge);
2449}
2450
2451static int ab8500_gpadc_trig_edge_open(struct inode *inode, struct file *file)
2452{
2453 return single_open(file, ab8500_gpadc_trig_edge_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002454 inode->i_private);
Lee Jones73482342013-02-26 10:06:55 +00002455}
2456
2457static ssize_t ab8500_gpadc_trig_edge_write(struct file *file,
2458 const char __user *user_buf,
2459 size_t count, loff_t *ppos)
2460{
2461 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Lee Jones73482342013-02-26 10:06:55 +00002462 unsigned long user_trig_edge;
2463 int err;
2464
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302465 err = kstrtoul_from_user(user_buf, count, 0, &user_trig_edge);
Lee Jones73482342013-02-26 10:06:55 +00002466 if (err)
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302467 return err;
2468
Lee Jones73482342013-02-26 10:06:55 +00002469 if ((user_trig_edge == RISING_EDGE)
2470 || (user_trig_edge == FALLING_EDGE)) {
2471 trig_edge = (u8) user_trig_edge;
2472 } else {
2473 dev_err(dev, "Wrong input:\n"
2474 "Enter 0. Rising edge\n"
2475 "Enter 1. Falling edge\n");
2476 return -EINVAL;
2477 }
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302478
2479 return count;
Lee Jones73482342013-02-26 10:06:55 +00002480}
2481
2482static const struct file_operations ab8500_gpadc_trig_edge_fops = {
2483 .open = ab8500_gpadc_trig_edge_open,
2484 .read = seq_read,
2485 .write = ab8500_gpadc_trig_edge_write,
2486 .llseek = seq_lseek,
2487 .release = single_release,
2488 .owner = THIS_MODULE,
2489};
2490
2491static int ab8500_gpadc_trig_timer_print(struct seq_file *s, void *p)
2492{
2493 return seq_printf(s, "%d\n", trig_timer);
2494}
2495
2496static int ab8500_gpadc_trig_timer_open(struct inode *inode, struct file *file)
2497{
2498 return single_open(file, ab8500_gpadc_trig_timer_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002499 inode->i_private);
Lee Jones73482342013-02-26 10:06:55 +00002500}
2501
2502static ssize_t ab8500_gpadc_trig_timer_write(struct file *file,
2503 const char __user *user_buf,
2504 size_t count, loff_t *ppos)
2505{
2506 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Lee Jones73482342013-02-26 10:06:55 +00002507 unsigned long user_trig_timer;
2508 int err;
2509
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302510 err = kstrtoul_from_user(user_buf, count, 0, &user_trig_timer);
Lee Jones73482342013-02-26 10:06:55 +00002511 if (err)
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302512 return err;
2513
Lee Jonesc3f27a22014-07-02 11:22:10 +01002514 if (user_trig_timer & ~0xFF) {
2515 dev_err(dev,
2516 "debugfs error input: should be beetween 0 to 255\n");
Lee Jones73482342013-02-26 10:06:55 +00002517 return -EINVAL;
2518 }
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302519
Lee Jonesc3f27a22014-07-02 11:22:10 +01002520 trig_timer = (u8) user_trig_timer;
2521
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302522 return count;
Lee Jones73482342013-02-26 10:06:55 +00002523}
2524
2525static const struct file_operations ab8500_gpadc_trig_timer_fops = {
2526 .open = ab8500_gpadc_trig_timer_open,
2527 .read = seq_read,
2528 .write = ab8500_gpadc_trig_timer_write,
2529 .llseek = seq_lseek,
2530 .release = single_release,
2531 .owner = THIS_MODULE,
2532};
2533
2534static int ab8500_gpadc_conv_type_print(struct seq_file *s, void *p)
2535{
2536 return seq_printf(s, "%d\n", conv_type);
2537}
2538
2539static int ab8500_gpadc_conv_type_open(struct inode *inode, struct file *file)
2540{
2541 return single_open(file, ab8500_gpadc_conv_type_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002542 inode->i_private);
Lee Jones73482342013-02-26 10:06:55 +00002543}
2544
2545static ssize_t ab8500_gpadc_conv_type_write(struct file *file,
2546 const char __user *user_buf,
2547 size_t count, loff_t *ppos)
2548{
2549 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Lee Jones73482342013-02-26 10:06:55 +00002550 unsigned long user_conv_type;
2551 int err;
2552
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302553 err = kstrtoul_from_user(user_buf, count, 0, &user_conv_type);
Lee Jones73482342013-02-26 10:06:55 +00002554 if (err)
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302555 return err;
2556
Lee Jones73482342013-02-26 10:06:55 +00002557 if ((user_conv_type == ADC_SW)
2558 || (user_conv_type == ADC_HW)) {
2559 conv_type = (u8) user_conv_type;
2560 } else {
2561 dev_err(dev, "Wrong input:\n"
2562 "Enter 0. ADC SW conversion\n"
2563 "Enter 1. ADC HW conversion\n");
2564 return -EINVAL;
2565 }
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302566
2567 return count;
Lee Jones73482342013-02-26 10:06:55 +00002568}
2569
2570static const struct file_operations ab8500_gpadc_conv_type_fops = {
2571 .open = ab8500_gpadc_conv_type_open,
2572 .read = seq_read,
2573 .write = ab8500_gpadc_conv_type_write,
2574 .llseek = seq_lseek,
2575 .release = single_release,
2576 .owner = THIS_MODULE,
2577};
2578
carriere etienne0fbce762011-04-08 16:26:36 +02002579/*
2580 * return length of an ASCII numerical value, 0 is string is not a
2581 * numerical value.
2582 * string shall start at value 1st char.
2583 * string can be tailed with \0 or space or newline chars only.
2584 * value can be decimal or hexadecimal (prefixed 0x or 0X).
2585 */
2586static int strval_len(char *b)
2587{
2588 char *s = b;
Lee Jones43621752014-07-14 18:29:16 +01002589
carriere etienne0fbce762011-04-08 16:26:36 +02002590 if ((*s == '0') && ((*(s+1) == 'x') || (*(s+1) == 'X'))) {
2591 s += 2;
2592 for (; *s && (*s != ' ') && (*s != '\n'); s++) {
2593 if (!isxdigit(*s))
2594 return 0;
2595 }
2596 } else {
2597 if (*s == '-')
2598 s++;
2599 for (; *s && (*s != ' ') && (*s != '\n'); s++) {
2600 if (!isdigit(*s))
2601 return 0;
2602 }
2603 }
2604 return (int) (s-b);
2605}
2606
2607/*
2608 * parse hwreg input data.
2609 * update global hwreg_cfg only if input data syntax is ok.
2610 */
2611static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg,
2612 struct device *dev)
2613{
2614 uint write, val = 0;
2615 u8 regvalue;
2616 int ret;
2617 struct hwreg_cfg loc = {
2618 .bank = 0, /* default: invalid phys addr */
2619 .addr = 0, /* default: invalid phys addr */
2620 .fmt = 0, /* default: 32bit access, hex output */
2621 .mask = 0xFFFFFFFF, /* default: no mask */
2622 .shift = 0, /* default: no bit shift */
2623 };
2624
2625 /* read or write ? */
2626 if (!strncmp(b, "read ", 5)) {
2627 write = 0;
2628 b += 5;
2629 } else if (!strncmp(b, "write ", 6)) {
2630 write = 1;
2631 b += 6;
2632 } else
2633 return -EINVAL;
2634
2635 /* OPTIONS -l|-w|-b -s -m -o */
2636 while ((*b == ' ') || (*b == '-')) {
2637 if (*(b-1) != ' ') {
2638 b++;
2639 continue;
2640 }
2641 if ((!strncmp(b, "-d ", 3)) ||
2642 (!strncmp(b, "-dec ", 5))) {
2643 b += (*(b+2) == ' ') ? 3 : 5;
2644 loc.fmt |= (1<<0);
2645 } else if ((!strncmp(b, "-h ", 3)) ||
2646 (!strncmp(b, "-hex ", 5))) {
2647 b += (*(b+2) == ' ') ? 3 : 5;
2648 loc.fmt &= ~(1<<0);
2649 } else if ((!strncmp(b, "-m ", 3)) ||
2650 (!strncmp(b, "-mask ", 6))) {
2651 b += (*(b+2) == ' ') ? 3 : 6;
2652 if (strval_len(b) == 0)
2653 return -EINVAL;
Lee Jones43621752014-07-14 18:29:16 +01002654 ret = kstrtoul(b, 0, &loc.mask);
2655 if (ret)
2656 return ret;
carriere etienne0fbce762011-04-08 16:26:36 +02002657 } else if ((!strncmp(b, "-s ", 3)) ||
2658 (!strncmp(b, "-shift ", 7))) {
2659 b += (*(b+2) == ' ') ? 3 : 7;
2660 if (strval_len(b) == 0)
2661 return -EINVAL;
Lee Jones43621752014-07-14 18:29:16 +01002662 ret = kstrtol(b, 0, &loc.shift);
2663 if (ret)
2664 return ret;
carriere etienne0fbce762011-04-08 16:26:36 +02002665 } else {
2666 return -EINVAL;
2667 }
2668 }
2669 /* get arg BANK and ADDRESS */
2670 if (strval_len(b) == 0)
2671 return -EINVAL;
Lee Jones43621752014-07-14 18:29:16 +01002672 ret = kstrtouint(b, 0, &loc.bank);
2673 if (ret)
2674 return ret;
carriere etienne0fbce762011-04-08 16:26:36 +02002675 while (*b == ' ')
2676 b++;
2677 if (strval_len(b) == 0)
2678 return -EINVAL;
Lee Jones43621752014-07-14 18:29:16 +01002679 ret = kstrtoul(b, 0, &loc.addr);
2680 if (ret)
2681 return ret;
carriere etienne0fbce762011-04-08 16:26:36 +02002682
2683 if (write) {
2684 while (*b == ' ')
2685 b++;
2686 if (strval_len(b) == 0)
2687 return -EINVAL;
Lee Jones43621752014-07-14 18:29:16 +01002688 ret = kstrtouint(b, 0, &val);
2689 if (ret)
2690 return ret;
carriere etienne0fbce762011-04-08 16:26:36 +02002691 }
2692
2693 /* args are ok, update target cfg (mainly for read) */
2694 *cfg = loc;
2695
2696#ifdef ABB_HWREG_DEBUG
Lee Jones43621752014-07-14 18:29:16 +01002697 pr_warn("HWREG request: %s, %s,\n"
2698 " addr=0x%08X, mask=0x%X, shift=%d" "value=0x%X\n",
2699 (write) ? "write" : "read",
2700 REG_FMT_DEC(cfg) ? "decimal" : "hexa",
2701 cfg->addr, cfg->mask, cfg->shift, val);
carriere etienne0fbce762011-04-08 16:26:36 +02002702#endif
2703
2704 if (!write)
2705 return 0;
2706
2707 ret = abx500_get_register_interruptible(dev,
2708 (u8)cfg->bank, (u8)cfg->addr, &regvalue);
2709 if (ret < 0) {
2710 dev_err(dev, "abx500_get_reg fail %d, %d\n",
2711 ret, __LINE__);
2712 return -EINVAL;
2713 }
2714
2715 if (cfg->shift >= 0) {
2716 regvalue &= ~(cfg->mask << (cfg->shift));
2717 val = (val & cfg->mask) << (cfg->shift);
2718 } else {
2719 regvalue &= ~(cfg->mask >> (-cfg->shift));
2720 val = (val & cfg->mask) >> (-cfg->shift);
2721 }
2722 val = val | regvalue;
2723
2724 ret = abx500_set_register_interruptible(dev,
2725 (u8)cfg->bank, (u8)cfg->addr, (u8)val);
2726 if (ret < 0) {
2727 pr_err("abx500_set_reg failed %d, %d", ret, __LINE__);
2728 return -EINVAL;
2729 }
2730
2731 return 0;
2732}
2733
2734static ssize_t ab8500_hwreg_write(struct file *file,
2735 const char __user *user_buf, size_t count, loff_t *ppos)
2736{
2737 struct device *dev = ((struct seq_file *)(file->private_data))->private;
2738 char buf[128];
2739 int buf_size, ret;
2740
2741 /* Get userspace string and assure termination */
2742 buf_size = min(count, (sizeof(buf)-1));
2743 if (copy_from_user(buf, user_buf, buf_size))
2744 return -EFAULT;
2745 buf[buf_size] = 0;
2746
2747 /* get args and process */
2748 ret = hwreg_common_write(buf, &hwreg_cfg, dev);
2749 return (ret) ? ret : buf_size;
2750}
2751
2752/*
2753 * - irq subscribe/unsubscribe stuff
2754 */
Lee Jones4b8ac082013-01-14 16:10:36 +00002755static int ab8500_subscribe_unsubscribe_print(struct seq_file *s, void *p)
2756{
2757 seq_printf(s, "%d\n", irq_first);
2758
2759 return 0;
2760}
2761
2762static int ab8500_subscribe_unsubscribe_open(struct inode *inode,
2763 struct file *file)
2764{
2765 return single_open(file, ab8500_subscribe_unsubscribe_print,
Lee Jones9f9ba152013-02-26 12:05:15 +00002766 inode->i_private);
Lee Jones4b8ac082013-01-14 16:10:36 +00002767}
2768
2769/*
Mattias Wallin0b337e72010-11-19 17:55:11 +01002770 * Userspace should use poll() on this file. When an event occur
Lee Jones4b8ac082013-01-14 16:10:36 +00002771 * the blocking poll will be released.
2772 */
2773static ssize_t show_irq(struct device *dev,
2774 struct device_attribute *attr, char *buf)
2775{
Mattias Wallin0b337e72010-11-19 17:55:11 +01002776 unsigned long name;
2777 unsigned int irq_index;
2778 int err;
Lee Jones4b8ac082013-01-14 16:10:36 +00002779
Jingoo Han8420a242013-06-04 13:11:50 +09002780 err = kstrtoul(attr->attr.name, 0, &name);
Mattias Wallin0b337e72010-11-19 17:55:11 +01002781 if (err)
2782 return err;
2783
2784 irq_index = name - irq_first;
Linus Walleijddba25f2012-02-03 11:19:05 +01002785 if (irq_index >= num_irqs)
Mattias Wallin0b337e72010-11-19 17:55:11 +01002786 return -EINVAL;
Lee Jonesc3f27a22014-07-02 11:22:10 +01002787
2788 return sprintf(buf, "%u\n", irq_count[irq_index]);
Mattias Wallin0b337e72010-11-19 17:55:11 +01002789}
Lee Jones4b8ac082013-01-14 16:10:36 +00002790
2791static ssize_t ab8500_subscribe_write(struct file *file,
2792 const char __user *user_buf,
2793 size_t count, loff_t *ppos)
2794{
2795 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Lee Jones4b8ac082013-01-14 16:10:36 +00002796 unsigned long user_val;
2797 int err;
Mattias Wallin0b337e72010-11-19 17:55:11 +01002798 unsigned int irq_index;
Lee Jones4b8ac082013-01-14 16:10:36 +00002799
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302800 err = kstrtoul_from_user(user_buf, count, 0, &user_val);
Lee Jones4b8ac082013-01-14 16:10:36 +00002801 if (err)
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302802 return err;
2803
Lee Jones4b8ac082013-01-14 16:10:36 +00002804 if (user_val < irq_first) {
2805 dev_err(dev, "debugfs error input < %d\n", irq_first);
2806 return -EINVAL;
2807 }
2808 if (user_val > irq_last) {
2809 dev_err(dev, "debugfs error input > %d\n", irq_last);
2810 return -EINVAL;
2811 }
2812
Mattias Wallin0b337e72010-11-19 17:55:11 +01002813 irq_index = user_val - irq_first;
Linus Walleijddba25f2012-02-03 11:19:05 +01002814 if (irq_index >= num_irqs)
Mattias Wallin0b337e72010-11-19 17:55:11 +01002815 return -EINVAL;
2816
Lee Jones4b8ac082013-01-14 16:10:36 +00002817 /*
Mattias Wallin0b337e72010-11-19 17:55:11 +01002818 * This will create a sysfs file named <irq-nr> which userspace can
Lee Jones4b8ac082013-01-14 16:10:36 +00002819 * use to select or poll and get the AB8500 events
2820 */
Mattias Wallin0b337e72010-11-19 17:55:11 +01002821 dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute),
2822 GFP_KERNEL);
Lee Jonesf840e232013-07-19 08:44:50 +01002823 if (!dev_attr[irq_index])
2824 return -ENOMEM;
2825
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302826 event_name[irq_index] = kmalloc(count, GFP_KERNEL);
Lee Jonesd551c4c2013-07-19 08:53:24 +01002827 if (!event_name[irq_index])
2828 return -ENOMEM;
2829
Mattias Wallin0b337e72010-11-19 17:55:11 +01002830 sprintf(event_name[irq_index], "%lu", user_val);
2831 dev_attr[irq_index]->show = show_irq;
2832 dev_attr[irq_index]->store = NULL;
2833 dev_attr[irq_index]->attr.name = event_name[irq_index];
2834 dev_attr[irq_index]->attr.mode = S_IRUGO;
2835 err = sysfs_create_file(&dev->kobj, &dev_attr[irq_index]->attr);
Lee Jones4b8ac082013-01-14 16:10:36 +00002836 if (err < 0) {
Lee Jones43621752014-07-14 18:29:16 +01002837 pr_info("sysfs_create_file failed %d\n", err);
Lee Jones4b8ac082013-01-14 16:10:36 +00002838 return err;
2839 }
2840
2841 err = request_threaded_irq(user_val, NULL, ab8500_debug_handler,
2842 IRQF_SHARED | IRQF_NO_SUSPEND,
2843 "ab8500-debug", &dev->kobj);
2844 if (err < 0) {
Lee Jones43621752014-07-14 18:29:16 +01002845 pr_info("request_threaded_irq failed %d, %lu\n",
2846 err, user_val);
Mattias Wallin0b337e72010-11-19 17:55:11 +01002847 sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr);
Lee Jones4b8ac082013-01-14 16:10:36 +00002848 return err;
2849 }
2850
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302851 return count;
Lee Jones4b8ac082013-01-14 16:10:36 +00002852}
2853
2854static ssize_t ab8500_unsubscribe_write(struct file *file,
2855 const char __user *user_buf,
2856 size_t count, loff_t *ppos)
2857{
2858 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Lee Jones4b8ac082013-01-14 16:10:36 +00002859 unsigned long user_val;
2860 int err;
Mattias Wallin0b337e72010-11-19 17:55:11 +01002861 unsigned int irq_index;
Lee Jones4b8ac082013-01-14 16:10:36 +00002862
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302863 err = kstrtoul_from_user(user_buf, count, 0, &user_val);
Lee Jones4b8ac082013-01-14 16:10:36 +00002864 if (err)
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302865 return err;
2866
Lee Jones4b8ac082013-01-14 16:10:36 +00002867 if (user_val < irq_first) {
2868 dev_err(dev, "debugfs error input < %d\n", irq_first);
2869 return -EINVAL;
2870 }
2871 if (user_val > irq_last) {
2872 dev_err(dev, "debugfs error input > %d\n", irq_last);
2873 return -EINVAL;
2874 }
2875
Mattias Wallin0b337e72010-11-19 17:55:11 +01002876 irq_index = user_val - irq_first;
Linus Walleijddba25f2012-02-03 11:19:05 +01002877 if (irq_index >= num_irqs)
Mattias Wallin0b337e72010-11-19 17:55:11 +01002878 return -EINVAL;
Lee Jones4b8ac082013-01-14 16:10:36 +00002879
Mattias Wallin0b337e72010-11-19 17:55:11 +01002880 /* Set irq count to 0 when unsubscribe */
2881 irq_count[irq_index] = 0;
2882
2883 if (dev_attr[irq_index])
2884 sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr);
2885
2886
2887 free_irq(user_val, &dev->kobj);
2888 kfree(event_name[irq_index]);
2889 kfree(dev_attr[irq_index]);
Lee Jones4b8ac082013-01-14 16:10:36 +00002890
srinidhi kasagar7b830ae2012-11-23 15:11:00 +05302891 return count;
Lee Jones4b8ac082013-01-14 16:10:36 +00002892}
2893
carriere etienne0fbce762011-04-08 16:26:36 +02002894/*
2895 * - several deubgfs nodes fops
2896 */
2897
Mattias Wallin5814fc32010-09-13 16:05:04 +02002898static const struct file_operations ab8500_bank_fops = {
Mattias Wallind7b9f322010-11-26 13:06:39 +01002899 .open = ab8500_bank_open,
2900 .write = ab8500_bank_write,
2901 .read = seq_read,
2902 .llseek = seq_lseek,
2903 .release = single_release,
2904 .owner = THIS_MODULE,
Mattias Wallin5814fc32010-09-13 16:05:04 +02002905};
2906
2907static const struct file_operations ab8500_address_fops = {
Mattias Wallind7b9f322010-11-26 13:06:39 +01002908 .open = ab8500_address_open,
2909 .write = ab8500_address_write,
2910 .read = seq_read,
2911 .llseek = seq_lseek,
2912 .release = single_release,
2913 .owner = THIS_MODULE,
Mattias Wallin5814fc32010-09-13 16:05:04 +02002914};
2915
2916static const struct file_operations ab8500_val_fops = {
Mattias Wallind7b9f322010-11-26 13:06:39 +01002917 .open = ab8500_val_open,
2918 .write = ab8500_val_write,
2919 .read = seq_read,
2920 .llseek = seq_lseek,
2921 .release = single_release,
2922 .owner = THIS_MODULE,
Mattias Wallin5814fc32010-09-13 16:05:04 +02002923};
2924
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01002925static const struct file_operations ab8500_interrupts_fops = {
2926 .open = ab8500_interrupts_open,
2927 .read = seq_read,
2928 .llseek = seq_lseek,
2929 .release = single_release,
2930 .owner = THIS_MODULE,
2931};
2932
Lee Jones4b8ac082013-01-14 16:10:36 +00002933static const struct file_operations ab8500_subscribe_fops = {
2934 .open = ab8500_subscribe_unsubscribe_open,
2935 .write = ab8500_subscribe_write,
2936 .read = seq_read,
2937 .llseek = seq_lseek,
2938 .release = single_release,
2939 .owner = THIS_MODULE,
2940};
2941
2942static const struct file_operations ab8500_unsubscribe_fops = {
2943 .open = ab8500_subscribe_unsubscribe_open,
2944 .write = ab8500_unsubscribe_write,
2945 .read = seq_read,
2946 .llseek = seq_lseek,
2947 .release = single_release,
2948 .owner = THIS_MODULE,
2949};
2950
carriere etienne0fbce762011-04-08 16:26:36 +02002951static const struct file_operations ab8500_hwreg_fops = {
2952 .open = ab8500_hwreg_open,
2953 .write = ab8500_hwreg_write,
2954 .read = seq_read,
2955 .llseek = seq_lseek,
2956 .release = single_release,
2957 .owner = THIS_MODULE,
2958};
2959
Mattias Wallin5814fc32010-09-13 16:05:04 +02002960static struct dentry *ab8500_dir;
John Beckett1478a312011-05-31 13:54:27 +01002961static struct dentry *ab8500_gpadc_dir;
Mattias Wallin5814fc32010-09-13 16:05:04 +02002962
Bill Pembertonf791be42012-11-19 13:23:04 -05002963static int ab8500_debug_probe(struct platform_device *plf)
Mattias Wallin5814fc32010-09-13 16:05:04 +02002964{
carriere etienne0fbce762011-04-08 16:26:36 +02002965 struct dentry *file;
Linus Walleijddba25f2012-02-03 11:19:05 +01002966 struct ab8500 *ab8500;
Linus Walleij69991812013-04-12 17:02:09 +02002967 struct resource *res;
Lee Jones43621752014-07-14 18:29:16 +01002968
Mattias Wallind7b9f322010-11-26 13:06:39 +01002969 debug_bank = AB8500_MISC;
2970 debug_address = AB8500_REV_REG & 0x00FF;
Mattias Wallin5814fc32010-09-13 16:05:04 +02002971
Linus Walleijddba25f2012-02-03 11:19:05 +01002972 ab8500 = dev_get_drvdata(plf->dev.parent);
2973 num_irqs = ab8500->mask_size;
2974
Lee Jonesc18cf6d2013-05-23 16:25:05 +01002975 irq_count = devm_kzalloc(&plf->dev,
2976 sizeof(*irq_count)*num_irqs, GFP_KERNEL);
Linus Walleijddba25f2012-02-03 11:19:05 +01002977 if (!irq_count)
2978 return -ENOMEM;
2979
Lee Jonesc18cf6d2013-05-23 16:25:05 +01002980 dev_attr = devm_kzalloc(&plf->dev,
Lee Jones43621752014-07-14 18:29:16 +01002981 sizeof(*dev_attr)*num_irqs, GFP_KERNEL);
Linus Walleijddba25f2012-02-03 11:19:05 +01002982 if (!dev_attr)
Lee Jonesc18cf6d2013-05-23 16:25:05 +01002983 return -ENOMEM;
Linus Walleijddba25f2012-02-03 11:19:05 +01002984
Lee Jonesc18cf6d2013-05-23 16:25:05 +01002985 event_name = devm_kzalloc(&plf->dev,
2986 sizeof(*event_name)*num_irqs, GFP_KERNEL);
Linus Walleijddba25f2012-02-03 11:19:05 +01002987 if (!event_name)
Lee Jonesc18cf6d2013-05-23 16:25:05 +01002988 return -ENOMEM;
Linus Walleijddba25f2012-02-03 11:19:05 +01002989
Linus Walleij69991812013-04-12 17:02:09 +02002990 res = platform_get_resource_byname(plf, 0, "IRQ_AB8500");
2991 if (!res) {
Lee Jones43621752014-07-14 18:29:16 +01002992 dev_err(&plf->dev, "AB8500 irq not found, err %d\n", irq_first);
2993 return -ENXIO;
Linus Walleij69991812013-04-12 17:02:09 +02002994 }
2995 irq_ab8500 = res->start;
2996
Lee Jones4b8ac082013-01-14 16:10:36 +00002997 irq_first = platform_get_irq_byname(plf, "IRQ_FIRST");
2998 if (irq_first < 0) {
Lee Jones43621752014-07-14 18:29:16 +01002999 dev_err(&plf->dev, "First irq not found, err %d\n", irq_first);
Lee Jonesc18cf6d2013-05-23 16:25:05 +01003000 return irq_first;
Lee Jones4b8ac082013-01-14 16:10:36 +00003001 }
3002
3003 irq_last = platform_get_irq_byname(plf, "IRQ_LAST");
3004 if (irq_last < 0) {
Lee Jones43621752014-07-14 18:29:16 +01003005 dev_err(&plf->dev, "Last irq not found, err %d\n", irq_last);
Lee Jonesc18cf6d2013-05-23 16:25:05 +01003006 return irq_last;
Lee Jones4b8ac082013-01-14 16:10:36 +00003007 }
3008
Mattias Wallind7b9f322010-11-26 13:06:39 +01003009 ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
3010 if (!ab8500_dir)
carriere etienne0fbce762011-04-08 16:26:36 +02003011 goto err;
Mattias Wallin5814fc32010-09-13 16:05:04 +02003012
John Beckett1478a312011-05-31 13:54:27 +01003013 ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING,
Lee Jones43621752014-07-14 18:29:16 +01003014 ab8500_dir);
John Beckett1478a312011-05-31 13:54:27 +01003015 if (!ab8500_gpadc_dir)
3016 goto err;
3017
Lee Jones43621752014-07-14 18:29:16 +01003018 file = debugfs_create_file("all-bank-registers", S_IRUGO, ab8500_dir,
3019 &plf->dev, &ab8500_registers_fops);
carriere etienne0fbce762011-04-08 16:26:36 +02003020 if (!file)
3021 goto err;
Mattias Wallin5814fc32010-09-13 16:05:04 +02003022
Lee Jones43621752014-07-14 18:29:16 +01003023 file = debugfs_create_file("all-banks", S_IRUGO, ab8500_dir,
3024 &plf->dev, &ab8500_all_banks_fops);
Mian Yousaf Kaukab42002c62012-01-26 15:39:20 +01003025 if (!file)
3026 goto err;
3027
Lee Jones43621752014-07-14 18:29:16 +01003028 file = debugfs_create_file("register-bank",
3029 (S_IRUGO | S_IWUSR | S_IWGRP),
3030 ab8500_dir, &plf->dev, &ab8500_bank_fops);
carriere etienne0fbce762011-04-08 16:26:36 +02003031 if (!file)
3032 goto err;
Mattias Wallin5814fc32010-09-13 16:05:04 +02003033
Lee Jones43621752014-07-14 18:29:16 +01003034 file = debugfs_create_file("register-address",
3035 (S_IRUGO | S_IWUSR | S_IWGRP),
3036 ab8500_dir, &plf->dev, &ab8500_address_fops);
carriere etienne0fbce762011-04-08 16:26:36 +02003037 if (!file)
3038 goto err;
Mattias Wallin5814fc32010-09-13 16:05:04 +02003039
Lee Jones43621752014-07-14 18:29:16 +01003040 file = debugfs_create_file("register-value",
3041 (S_IRUGO | S_IWUSR | S_IWGRP),
3042 ab8500_dir, &plf->dev, &ab8500_val_fops);
carriere etienne0fbce762011-04-08 16:26:36 +02003043 if (!file)
3044 goto err;
Mattias Wallin5814fc32010-09-13 16:05:04 +02003045
Lee Jones43621752014-07-14 18:29:16 +01003046 file = debugfs_create_file("irq-subscribe",
3047 (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir,
3048 &plf->dev, &ab8500_subscribe_fops);
carriere etienne0fbce762011-04-08 16:26:36 +02003049 if (!file)
3050 goto err;
Lee Jones4b8ac082013-01-14 16:10:36 +00003051
Lee Jones9581ae32012-07-06 16:11:50 +02003052 if (is_ab8500(ab8500)) {
3053 debug_ranges = ab8500_debug_ranges;
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01003054 num_interrupt_lines = AB8500_NR_IRQS;
Lee Jones9581ae32012-07-06 16:11:50 +02003055 } else if (is_ab8505(ab8500)) {
3056 debug_ranges = ab8505_debug_ranges;
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01003057 num_interrupt_lines = AB8505_NR_IRQS;
Lee Jones9581ae32012-07-06 16:11:50 +02003058 } else if (is_ab9540(ab8500)) {
3059 debug_ranges = ab8505_debug_ranges;
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01003060 num_interrupt_lines = AB9540_NR_IRQS;
Lee Jones9581ae32012-07-06 16:11:50 +02003061 } else if (is_ab8540(ab8500)) {
Lee Jones971480f2012-11-19 12:20:03 +01003062 debug_ranges = ab8540_debug_ranges;
Lee Jonese436ddf2013-02-26 10:09:41 +00003063 num_interrupt_lines = AB8540_NR_IRQS;
Lee Jones9581ae32012-07-06 16:11:50 +02003064 }
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01003065
Lee Jones43621752014-07-14 18:29:16 +01003066 file = debugfs_create_file("interrupts", (S_IRUGO), ab8500_dir,
3067 &plf->dev, &ab8500_interrupts_fops);
Bengt Jonsson8f0eb432012-02-14 13:01:00 +01003068 if (!file)
3069 goto err;
3070
Lee Jones43621752014-07-14 18:29:16 +01003071 file = debugfs_create_file("irq-unsubscribe",
3072 (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir,
3073 &plf->dev, &ab8500_unsubscribe_fops);
carriere etienne0fbce762011-04-08 16:26:36 +02003074 if (!file)
3075 goto err;
3076
Lee Jonesf38487f2013-02-26 14:09:08 +00003077 file = debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003078 ab8500_dir, &plf->dev, &ab8500_hwreg_fops);
John Beckett1478a312011-05-31 13:54:27 +01003079 if (!file)
3080 goto err;
3081
Lee Jones43621752014-07-14 18:29:16 +01003082 file = debugfs_create_file("all-modem-registers",
3083 (S_IRUGO | S_IWUSR | S_IWGRP),
3084 ab8500_dir, &plf->dev, &ab8500_modem_fops);
Lee Jonesc7ebaee2013-02-26 14:03:33 +00003085 if (!file)
3086 goto err;
3087
Lee Jonesf38487f2013-02-26 14:09:08 +00003088 file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003089 ab8500_gpadc_dir, &plf->dev,
3090 &ab8500_gpadc_bat_ctrl_fops);
John Beckett1478a312011-05-31 13:54:27 +01003091 if (!file)
3092 goto err;
3093
Lee Jonesf38487f2013-02-26 14:09:08 +00003094 file = debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003095 ab8500_gpadc_dir,
3096 &plf->dev, &ab8500_gpadc_btemp_ball_fops);
John Beckett1478a312011-05-31 13:54:27 +01003097 if (!file)
3098 goto err;
3099
Lee Jones43621752014-07-14 18:29:16 +01003100 file = debugfs_create_file("main_charger_v",
3101 (S_IRUGO | S_IWUSR | S_IWGRP),
3102 ab8500_gpadc_dir, &plf->dev,
3103 &ab8500_gpadc_main_charger_v_fops);
John Beckett1478a312011-05-31 13:54:27 +01003104 if (!file)
3105 goto err;
3106
Lee Jones43621752014-07-14 18:29:16 +01003107 file = debugfs_create_file("acc_detect1",
3108 (S_IRUGO | S_IWUSR | S_IWGRP),
3109 ab8500_gpadc_dir, &plf->dev,
3110 &ab8500_gpadc_acc_detect1_fops);
John Beckett1478a312011-05-31 13:54:27 +01003111 if (!file)
3112 goto err;
3113
Lee Jones43621752014-07-14 18:29:16 +01003114 file = debugfs_create_file("acc_detect2",
3115 (S_IRUGO | S_IWUSR | S_IWGRP),
3116 ab8500_gpadc_dir, &plf->dev,
3117 &ab8500_gpadc_acc_detect2_fops);
John Beckett1478a312011-05-31 13:54:27 +01003118 if (!file)
3119 goto err;
3120
Lee Jonesf38487f2013-02-26 14:09:08 +00003121 file = debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003122 ab8500_gpadc_dir, &plf->dev,
3123 &ab8500_gpadc_aux1_fops);
John Beckett1478a312011-05-31 13:54:27 +01003124 if (!file)
3125 goto err;
3126
Lee Jonesf38487f2013-02-26 14:09:08 +00003127 file = debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003128 ab8500_gpadc_dir, &plf->dev,
3129 &ab8500_gpadc_aux2_fops);
John Beckett1478a312011-05-31 13:54:27 +01003130 if (!file)
3131 goto err;
3132
Lee Jonesf38487f2013-02-26 14:09:08 +00003133 file = debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003134 ab8500_gpadc_dir, &plf->dev,
3135 &ab8500_gpadc_main_bat_v_fops);
John Beckett1478a312011-05-31 13:54:27 +01003136 if (!file)
3137 goto err;
3138
Lee Jonesf38487f2013-02-26 14:09:08 +00003139 file = debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003140 ab8500_gpadc_dir, &plf->dev,
3141 &ab8500_gpadc_vbus_v_fops);
John Beckett1478a312011-05-31 13:54:27 +01003142 if (!file)
3143 goto err;
3144
Lee Jones43621752014-07-14 18:29:16 +01003145 file = debugfs_create_file("main_charger_c",
3146 (S_IRUGO | S_IWUSR | S_IWGRP),
3147 ab8500_gpadc_dir, &plf->dev,
3148 &ab8500_gpadc_main_charger_c_fops);
John Beckett1478a312011-05-31 13:54:27 +01003149 if (!file)
3150 goto err;
3151
Lee Jones43621752014-07-14 18:29:16 +01003152 file = debugfs_create_file("usb_charger_c",
3153 (S_IRUGO | S_IWUSR | S_IWGRP),
3154 ab8500_gpadc_dir,
3155 &plf->dev, &ab8500_gpadc_usb_charger_c_fops);
John Beckett1478a312011-05-31 13:54:27 +01003156 if (!file)
3157 goto err;
3158
Lee Jonesf38487f2013-02-26 14:09:08 +00003159 file = debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003160 ab8500_gpadc_dir, &plf->dev,
3161 &ab8500_gpadc_bk_bat_v_fops);
John Beckett1478a312011-05-31 13:54:27 +01003162 if (!file)
3163 goto err;
3164
Lee Jonesf38487f2013-02-26 14:09:08 +00003165 file = debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003166 ab8500_gpadc_dir, &plf->dev,
3167 &ab8500_gpadc_die_temp_fops);
carriere etienne0fbce762011-04-08 16:26:36 +02003168 if (!file)
3169 goto err;
Lee Jones127629d2013-02-26 14:04:37 +00003170
Lee Jonesf38487f2013-02-26 14:09:08 +00003171 file = debugfs_create_file("usb_id", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003172 ab8500_gpadc_dir, &plf->dev,
3173 &ab8500_gpadc_usb_id_fops);
Lee Jones127629d2013-02-26 14:04:37 +00003174 if (!file)
3175 goto err;
3176
Lee Jonesbc6b4132013-02-26 14:02:31 +00003177 if (is_ab8540(ab8500)) {
Lee Jones43621752014-07-14 18:29:16 +01003178 file = debugfs_create_file("xtal_temp",
3179 (S_IRUGO | S_IWUSR | S_IWGRP),
3180 ab8500_gpadc_dir, &plf->dev,
3181 &ab8540_gpadc_xtal_temp_fops);
Lee Jonesbc6b4132013-02-26 14:02:31 +00003182 if (!file)
3183 goto err;
Lee Jones43621752014-07-14 18:29:16 +01003184 file = debugfs_create_file("vbattruemeas",
3185 (S_IRUGO | S_IWUSR | S_IWGRP),
3186 ab8500_gpadc_dir, &plf->dev,
3187 &ab8540_gpadc_vbat_true_meas_fops);
Lee Jonesbc6b4132013-02-26 14:02:31 +00003188 if (!file)
3189 goto err;
3190 file = debugfs_create_file("batctrl_and_ibat",
Lee Jones43621752014-07-14 18:29:16 +01003191 (S_IRUGO | S_IWUGO),
3192 ab8500_gpadc_dir,
3193 &plf->dev,
3194 &ab8540_gpadc_bat_ctrl_and_ibat_fops);
Lee Jonesbc6b4132013-02-26 14:02:31 +00003195 if (!file)
3196 goto err;
3197 file = debugfs_create_file("vbatmeas_and_ibat",
Lee Jones43621752014-07-14 18:29:16 +01003198 (S_IRUGO | S_IWUGO),
3199 ab8500_gpadc_dir, &plf->dev,
3200 &ab8540_gpadc_vbat_meas_and_ibat_fops);
Lee Jonesbc6b4132013-02-26 14:02:31 +00003201 if (!file)
3202 goto err;
3203 file = debugfs_create_file("vbattruemeas_and_ibat",
Lee Jones43621752014-07-14 18:29:16 +01003204 (S_IRUGO | S_IWUGO),
3205 ab8500_gpadc_dir,
3206 &plf->dev,
3207 &ab8540_gpadc_vbat_true_meas_and_ibat_fops);
Lee Jonesbc6b4132013-02-26 14:02:31 +00003208 if (!file)
3209 goto err;
3210 file = debugfs_create_file("battemp_and_ibat",
Lee Jones43621752014-07-14 18:29:16 +01003211 (S_IRUGO | S_IWUGO),
3212 ab8500_gpadc_dir,
Lee Jones9f9ba152013-02-26 12:05:15 +00003213 &plf->dev, &ab8540_gpadc_bat_temp_and_ibat_fops);
Lee Jonesbc6b4132013-02-26 14:02:31 +00003214 if (!file)
3215 goto err;
Lee Jones43621752014-07-14 18:29:16 +01003216 file = debugfs_create_file("otp_calib",
3217 (S_IRUGO | S_IWUSR | S_IWGRP),
3218 ab8500_gpadc_dir,
3219 &plf->dev, &ab8540_gpadc_otp_calib_fops);
Lee Jonesbc6b4132013-02-26 14:02:31 +00003220 if (!file)
3221 goto err;
3222 }
Lee Jonesf38487f2013-02-26 14:09:08 +00003223 file = debugfs_create_file("avg_sample", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003224 ab8500_gpadc_dir, &plf->dev,
3225 &ab8500_gpadc_avg_sample_fops);
Lee Jones73482342013-02-26 10:06:55 +00003226 if (!file)
3227 goto err;
3228
Lee Jonesf38487f2013-02-26 14:09:08 +00003229 file = debugfs_create_file("trig_edge", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003230 ab8500_gpadc_dir, &plf->dev,
3231 &ab8500_gpadc_trig_edge_fops);
Lee Jones73482342013-02-26 10:06:55 +00003232 if (!file)
3233 goto err;
3234
Lee Jonesf38487f2013-02-26 14:09:08 +00003235 file = debugfs_create_file("trig_timer", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003236 ab8500_gpadc_dir, &plf->dev,
3237 &ab8500_gpadc_trig_timer_fops);
Lee Jones73482342013-02-26 10:06:55 +00003238 if (!file)
3239 goto err;
3240
Lee Jonesf38487f2013-02-26 14:09:08 +00003241 file = debugfs_create_file("conv_type", (S_IRUGO | S_IWUSR | S_IWGRP),
Lee Jones43621752014-07-14 18:29:16 +01003242 ab8500_gpadc_dir, &plf->dev,
3243 &ab8500_gpadc_conv_type_fops);
Lee Jones73482342013-02-26 10:06:55 +00003244 if (!file)
3245 goto err;
3246
Mattias Wallind7b9f322010-11-26 13:06:39 +01003247 return 0;
Mattias Wallin5814fc32010-09-13 16:05:04 +02003248
carriere etienne0fbce762011-04-08 16:26:36 +02003249err:
Fabian Frederick005d16b2014-06-28 13:58:17 +02003250 debugfs_remove_recursive(ab8500_dir);
Mattias Wallind7b9f322010-11-26 13:06:39 +01003251 dev_err(&plf->dev, "failed to create debugfs entries.\n");
Linus Walleijddba25f2012-02-03 11:19:05 +01003252
Lee Jonesc18cf6d2013-05-23 16:25:05 +01003253 return -ENOMEM;
Mattias Wallin5814fc32010-09-13 16:05:04 +02003254}
3255
Bill Pemberton4740f732012-11-19 13:26:01 -05003256static int ab8500_debug_remove(struct platform_device *plf)
Mattias Wallin5814fc32010-09-13 16:05:04 +02003257{
carriere etienne0fbce762011-04-08 16:26:36 +02003258 debugfs_remove_recursive(ab8500_dir);
Linus Walleijddba25f2012-02-03 11:19:05 +01003259
Mattias Wallind7b9f322010-11-26 13:06:39 +01003260 return 0;
Mattias Wallin5814fc32010-09-13 16:05:04 +02003261}
3262
3263static struct platform_driver ab8500_debug_driver = {
Mattias Wallind7b9f322010-11-26 13:06:39 +01003264 .driver = {
3265 .name = "ab8500-debug",
3266 .owner = THIS_MODULE,
3267 },
3268 .probe = ab8500_debug_probe,
Bill Pemberton84449212012-11-19 13:20:24 -05003269 .remove = ab8500_debug_remove
Mattias Wallin5814fc32010-09-13 16:05:04 +02003270};
3271
3272static int __init ab8500_debug_init(void)
3273{
Mattias Wallind7b9f322010-11-26 13:06:39 +01003274 return platform_driver_register(&ab8500_debug_driver);
Mattias Wallin5814fc32010-09-13 16:05:04 +02003275}
3276
3277static void __exit ab8500_debug_exit(void)
3278{
Mattias Wallind7b9f322010-11-26 13:06:39 +01003279 platform_driver_unregister(&ab8500_debug_driver);
Mattias Wallin5814fc32010-09-13 16:05:04 +02003280}
3281subsys_initcall(ab8500_debug_init);
3282module_exit(ab8500_debug_exit);
3283
3284MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
3285MODULE_DESCRIPTION("AB8500 DEBUG");
3286MODULE_LICENSE("GPL v2");