2 * Copyright (C) ST-Ericsson SA 2010
4 * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson.
5 * License Terms: GNU General Public License v2
8 * AB8500 register access
9 * ======================
12 * # echo BANK > <debugfs>/ab8500/register-bank
13 * # echo ADDR > <debugfs>/ab8500/register-address
14 * # cat <debugfs>/ab8500/register-value
17 * # echo BANK > <debugfs>/ab8500/register-bank
18 * # echo ADDR > <debugfs>/ab8500/register-address
19 * # echo VALUE > <debugfs>/ab8500/register-value
21 * read all registers from a bank:
22 * # echo BANK > <debugfs>/ab8500/register-bank
23 * # cat <debugfs>/ab8500/all-bank-register
25 * BANK target AB8500 register bank
26 * ADDR target AB8500 register address
27 * VALUE decimal or 0x-prefixed hexadecimal
30 * User Space notification on AB8500 IRQ
31 * =====================================
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.
37 * subscribe to an AB8500 IRQ:
38 * # echo IRQ > <debugfs>/ab8500/irq-subscribe
40 * unsubscribe from an AB8500 IRQ:
41 * # echo IRQ > <debugfs>/ab8500/irq-unsubscribe
44 * AB8500 register formated read/write access
45 * ==========================================
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]
53 * # echo "CMD [OPTIONS] BANK ADRESS [VALUE]" > $debugfs/ab8500/hwreg
55 * CMD read read access
58 * BANK target reg bank
59 * ADDRESS target reg address
60 * VALUE (write) value to be updated
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
70 * Warning: bit shift operation is applied to bit-mask.
71 * Warning: bit shift direction depends on read or right command.
74 #include <linux/seq_file.h>
75 #include <linux/uaccess.h>
77 #include <linux/module.h>
78 #include <linux/debugfs.h>
79 #include <linux/platform_device.h>
80 #include <linux/interrupt.h>
81 #include <linux/kobject.h>
82 #include <linux/slab.h>
84 #include <linux/mfd/abx500.h>
85 #include <linux/mfd/abx500/ab8500.h>
86 #include <linux/mfd/abx500/ab8500-gpadc.h>
88 #ifdef CONFIG_DEBUG_FS
89 #include <linux/string.h>
90 #include <linux/ctype.h>
93 static u32 debug_bank;
94 static u32 debug_address;
98 static u32 *irq_count;
101 static struct device_attribute **dev_attr;
102 static char **event_name;
104 static u8 avg_sample = SAMPLE_16;
105 static u8 trig_edge = RISING_EDGE;
106 static u8 conv_type = ADC_SW;
107 static u8 trig_timer;
110 * struct ab8500_reg_range
111 * @first: the first address of the range
112 * @last: the last address of the range
113 * @perm: access permissions for the range
115 struct ab8500_reg_range {
122 * struct ab8500_prcmu_ranges
123 * @num_ranges: the number of ranges in the list
124 * @bankid: bank identifier
125 * @range: the list of register ranges
127 struct ab8500_prcmu_ranges {
130 const struct ab8500_reg_range *range;
133 /* hwreg- "mask" and "shift" entries ressources */
135 u32 bank; /* target bank */
136 u32 addr; /* target address */
137 uint fmt; /* format */
138 uint mask; /* read/write mask, applied before any bit shift */
139 int shift; /* bit shift (read:right shift, write:left shift */
141 /* fmt bit #0: 0=hexa, 1=dec */
142 #define REG_FMT_DEC(c) ((c)->fmt & 0x1)
143 #define REG_FMT_HEX(c) (!REG_FMT_DEC(c))
145 static struct hwreg_cfg hwreg_cfg = {
146 .addr = 0, /* default: invalid phys addr */
147 .fmt = 0, /* default: 32bit access, hex output */
148 .mask = 0xFFFFFFFF, /* default: no mask */
149 .shift = 0, /* default: no bit shift */
152 #define AB8500_NAME_STRING "ab8500"
153 #define AB8500_ADC_NAME_STRING "gpadc"
154 #define AB8500_NUM_BANKS 24
156 #define AB8500_REV_REG 0x80
158 static struct ab8500_prcmu_ranges debug_ranges[AB8500_NUM_BANKS] = {
163 [AB8500_SYS_CTRL1_BLOCK] = {
165 .range = (struct ab8500_reg_range[]) {
180 [AB8500_SYS_CTRL2_BLOCK] = {
182 .range = (struct ab8500_reg_range[]) {
201 [AB8500_REGU_CTRL1] = {
203 .range = (struct ab8500_reg_range[]) {
218 [AB8500_REGU_CTRL2] = {
220 .range = (struct ab8500_reg_range[]) {
241 /* 0x80-0x8B is SIM registers and should
242 * not be accessed from here */
247 .range = (struct ab8500_reg_range[]) {
260 .range = (struct ab8500_reg_range[]) {
303 [AB8500_ECI_AV_ACC] = {
305 .range = (struct ab8500_reg_range[]) {
318 .range = (struct ab8500_reg_range[]) {
327 .range = (struct ab8500_reg_range[]) {
366 [AB8500_GAS_GAUGE] = {
368 .range = (struct ab8500_reg_range[]) {
383 [AB8500_DEVELOPMENT] = {
385 .range = (struct ab8500_reg_range[]) {
394 .range = (struct ab8500_reg_range[]) {
403 .range = (struct ab8500_reg_range[]) {
410 [AB8500_INTERRUPT] = {
416 .range = (struct ab8500_reg_range[]) {
425 .range = (struct ab8500_reg_range[]) {
476 [AB8500_OTP_EMUL] = {
478 .range = (struct ab8500_reg_range[]) {
487 static irqreturn_t ab8500_debug_handler(int irq, void *data)
490 struct kobject *kobj = (struct kobject *)data;
491 unsigned int irq_abb = irq - irq_first;
493 if (irq_abb < num_irqs)
494 irq_count[irq_abb]++;
496 * This makes it possible to use poll for events (POLLPRI | POLLERR)
497 * from userspace on sysfs file named <irq-nr>
499 sprintf(buf, "%d", irq);
500 sysfs_notify(kobj, NULL, buf);
505 /* Prints to seq_file or log_buf */
506 static int ab8500_registers_print(struct device *dev, u32 bank,
511 for (i = 0; i < debug_ranges[bank].num_ranges; i++) {
514 for (reg = debug_ranges[bank].range[i].first;
515 reg <= debug_ranges[bank].range[i].last;
520 err = abx500_get_register_interruptible(dev,
521 (u8)bank, (u8)reg, &value);
523 dev_err(dev, "ab->read fail %d\n", err);
528 err = seq_printf(s, " [0x%02X/0x%02X]: 0x%02X\n",
532 "seq_printf overflow bank=0x%02X reg=0x%02X\n",
534 /* Error is not returned here since
535 * the output is wanted in any case */
539 printk(KERN_INFO" [0x%02X/0x%02X]: 0x%02X\n",
547 static int ab8500_print_bank_registers(struct seq_file *s, void *p)
549 struct device *dev = s->private;
550 u32 bank = debug_bank;
552 seq_printf(s, AB8500_NAME_STRING " register values:\n");
554 seq_printf(s, " bank 0x%02X:\n", bank);
556 ab8500_registers_print(dev, bank, s);
560 static int ab8500_registers_open(struct inode *inode, struct file *file)
562 return single_open(file, ab8500_print_bank_registers, inode->i_private);
565 static const struct file_operations ab8500_registers_fops = {
566 .open = ab8500_registers_open,
569 .release = single_release,
570 .owner = THIS_MODULE,
573 static int ab8500_print_all_banks(struct seq_file *s, void *p)
575 struct device *dev = s->private;
579 seq_printf(s, AB8500_NAME_STRING " register values:\n");
581 for (i = 1; i < AB8500_NUM_BANKS; i++) {
582 err = seq_printf(s, " bank 0x%02X:\n", i);
584 dev_err(dev, "seq_printf overflow, bank=0x%02X\n", i);
586 ab8500_registers_print(dev, i, s);
591 /* Dump registers to kernel log */
592 void ab8500_dump_all_banks(struct device *dev)
596 printk(KERN_INFO"ab8500 register values:\n");
598 for (i = 1; i < AB8500_NUM_BANKS; i++) {
599 printk(KERN_INFO" bank 0x%02X:\n", i);
600 ab8500_registers_print(dev, i, NULL);
604 /* Space for 500 registers. */
605 #define DUMP_MAX_REGS 700
606 struct ab8500_register_dump
612 } ab8500_complete_register_dump[DUMP_MAX_REGS];
614 extern int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
616 /* This shall only be called upon kernel panic! */
617 void ab8500_dump_all_banks_to_mem(void)
622 pr_info("Saving all ABB registers at \"ab8500_complete_register_dump\" "
623 "for crash analyze.\n");
625 for (bank = 1; bank < AB8500_NUM_BANKS; bank++) {
626 for (i = 0; i < debug_ranges[bank].num_ranges; i++) {
629 for (reg = debug_ranges[bank].range[i].first;
630 reg <= debug_ranges[bank].range[i].last;
635 err = prcmu_abb_read(bank, reg, &value, 1);
637 ab8500_complete_register_dump[r].ret = err;
638 ab8500_complete_register_dump[r].bank = bank;
639 ab8500_complete_register_dump[r].reg = reg;
640 ab8500_complete_register_dump[r].value = value;
644 if (r >= DUMP_MAX_REGS) {
645 pr_err("%s: too many register to dump!\n",
654 static int ab8500_all_banks_open(struct inode *inode, struct file *file)
659 err = single_open(file, ab8500_print_all_banks, inode->i_private);
661 /* Default buf size in seq_read is not enough */
662 s = (struct seq_file *)file->private_data;
663 s->size = (PAGE_SIZE * 2);
664 s->buf = kmalloc(s->size, GFP_KERNEL);
666 single_release(inode, file);
673 static const struct file_operations ab8500_all_banks_fops = {
674 .open = ab8500_all_banks_open,
677 .release = single_release,
678 .owner = THIS_MODULE,
681 static int ab8500_bank_print(struct seq_file *s, void *p)
683 return seq_printf(s, "0x%02X\n", debug_bank);
686 static int ab8500_bank_open(struct inode *inode, struct file *file)
688 return single_open(file, ab8500_bank_print, inode->i_private);
691 static ssize_t ab8500_bank_write(struct file *file,
692 const char __user *user_buf,
693 size_t count, loff_t *ppos)
695 struct device *dev = ((struct seq_file *)(file->private_data))->private;
696 unsigned long user_bank;
699 /* Get userspace string and assure termination */
700 err = kstrtoul_from_user(user_buf, count, 0, &user_bank);
704 if (user_bank >= AB8500_NUM_BANKS) {
705 dev_err(dev, "debugfs error input > number of banks\n");
709 debug_bank = user_bank;
714 static int ab8500_address_print(struct seq_file *s, void *p)
716 return seq_printf(s, "0x%02X\n", debug_address);
719 static int ab8500_address_open(struct inode *inode, struct file *file)
721 return single_open(file, ab8500_address_print, inode->i_private);
724 static ssize_t ab8500_address_write(struct file *file,
725 const char __user *user_buf,
726 size_t count, loff_t *ppos)
728 struct device *dev = ((struct seq_file *)(file->private_data))->private;
729 unsigned long user_address;
732 /* Get userspace string and assure termination */
733 err = kstrtoul_from_user(user_buf, count, 0, &user_address);
737 if (user_address > 0xff) {
738 dev_err(dev, "debugfs error input > 0xff\n");
741 debug_address = user_address;
745 static int ab8500_val_print(struct seq_file *s, void *p)
747 struct device *dev = s->private;
751 ret = abx500_get_register_interruptible(dev,
752 (u8)debug_bank, (u8)debug_address, ®value);
754 dev_err(dev, "abx500_get_reg fail %d, %d\n",
758 seq_printf(s, "0x%02X\n", regvalue);
763 static int ab8500_val_open(struct inode *inode, struct file *file)
765 return single_open(file, ab8500_val_print, inode->i_private);
768 static ssize_t ab8500_val_write(struct file *file,
769 const char __user *user_buf,
770 size_t count, loff_t *ppos)
772 struct device *dev = ((struct seq_file *)(file->private_data))->private;
773 unsigned long user_val;
776 /* Get userspace string and assure termination */
777 err = kstrtoul_from_user(user_buf, count, 0, &user_val);
781 if (user_val > 0xff) {
782 dev_err(dev, "debugfs error input > 0xff\n");
785 err = abx500_set_register_interruptible(dev,
786 (u8)debug_bank, debug_address, (u8)user_val);
788 printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__);
798 static u32 num_interrupts[AB8500_MAX_NR_IRQS];
799 static int num_interrupt_lines;
801 void ab8500_debug_register_interrupt(int line)
803 if (line < num_interrupt_lines)
804 num_interrupts[line]++;
807 static int ab8500_interrupts_print(struct seq_file *s, void *p)
811 seq_printf(s, "irq: number of\n");
813 for (line = 0; line < num_interrupt_lines; line++)
814 seq_printf(s, "%3i: %6i\n", line, num_interrupts[line]);
819 static int ab8500_interrupts_open(struct inode *inode, struct file *file)
821 return single_open(file, ab8500_interrupts_print, inode->i_private);
825 * - HWREG DB8500 formated routines
827 static int ab8500_hwreg_print(struct seq_file *s, void *d)
829 struct device *dev = s->private;
833 ret = abx500_get_register_interruptible(dev,
834 (u8)hwreg_cfg.bank, (u8)hwreg_cfg.addr, ®value);
836 dev_err(dev, "abx500_get_reg fail %d, %d\n",
841 if (hwreg_cfg.shift >= 0)
842 regvalue >>= hwreg_cfg.shift;
844 regvalue <<= -hwreg_cfg.shift;
845 regvalue &= hwreg_cfg.mask;
847 if (REG_FMT_DEC(&hwreg_cfg))
848 seq_printf(s, "%d\n", regvalue);
850 seq_printf(s, "0x%02X\n", regvalue);
854 static int ab8500_hwreg_open(struct inode *inode, struct file *file)
856 return single_open(file, ab8500_hwreg_print, inode->i_private);
859 static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p)
862 int bat_ctrl_convert;
863 struct ab8500_gpadc *gpadc;
865 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
866 bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL,
867 avg_sample, trig_edge, trig_timer, conv_type);
868 bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc,
869 BAT_CTRL, bat_ctrl_raw);
871 return seq_printf(s, "%d,0x%X\n",
872 bat_ctrl_convert, bat_ctrl_raw);
875 static int ab8500_gpadc_bat_ctrl_open(struct inode *inode, struct file *file)
877 return single_open(file, ab8500_gpadc_bat_ctrl_print, inode->i_private);
880 static const struct file_operations ab8500_gpadc_bat_ctrl_fops = {
881 .open = ab8500_gpadc_bat_ctrl_open,
884 .release = single_release,
885 .owner = THIS_MODULE,
888 static int ab8500_gpadc_btemp_ball_print(struct seq_file *s, void *p)
891 int btemp_ball_convert;
892 struct ab8500_gpadc *gpadc;
894 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
895 btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL,
896 avg_sample, trig_edge, trig_timer, conv_type);
897 btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
901 "%d,0x%X\n", btemp_ball_convert, btemp_ball_raw);
904 static int ab8500_gpadc_btemp_ball_open(struct inode *inode,
907 return single_open(file, ab8500_gpadc_btemp_ball_print, inode->i_private);
910 static const struct file_operations ab8500_gpadc_btemp_ball_fops = {
911 .open = ab8500_gpadc_btemp_ball_open,
914 .release = single_release,
915 .owner = THIS_MODULE,
918 static int ab8500_gpadc_main_charger_v_print(struct seq_file *s, void *p)
920 int main_charger_v_raw;
921 int main_charger_v_convert;
922 struct ab8500_gpadc *gpadc;
924 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
925 main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V,
926 avg_sample, trig_edge, trig_timer, conv_type);
927 main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
928 MAIN_CHARGER_V, main_charger_v_raw);
930 return seq_printf(s, "%d,0x%X\n",
931 main_charger_v_convert, main_charger_v_raw);
934 static int ab8500_gpadc_main_charger_v_open(struct inode *inode,
937 return single_open(file, ab8500_gpadc_main_charger_v_print,
941 static const struct file_operations ab8500_gpadc_main_charger_v_fops = {
942 .open = ab8500_gpadc_main_charger_v_open,
945 .release = single_release,
946 .owner = THIS_MODULE,
949 static int ab8500_gpadc_acc_detect1_print(struct seq_file *s, void *p)
952 int acc_detect1_convert;
953 struct ab8500_gpadc *gpadc;
955 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
956 acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1,
957 avg_sample, trig_edge, trig_timer, conv_type);
958 acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1,
961 return seq_printf(s, "%d,0x%X\n",
962 acc_detect1_convert, acc_detect1_raw);
965 static int ab8500_gpadc_acc_detect1_open(struct inode *inode,
968 return single_open(file, ab8500_gpadc_acc_detect1_print,
972 static const struct file_operations ab8500_gpadc_acc_detect1_fops = {
973 .open = ab8500_gpadc_acc_detect1_open,
976 .release = single_release,
977 .owner = THIS_MODULE,
980 static int ab8500_gpadc_acc_detect2_print(struct seq_file *s, void *p)
983 int acc_detect2_convert;
984 struct ab8500_gpadc *gpadc;
986 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
987 acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2,
988 avg_sample, trig_edge, trig_timer, conv_type);
989 acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc,
990 ACC_DETECT2, acc_detect2_raw);
992 return seq_printf(s, "%d,0x%X\n",
993 acc_detect2_convert, acc_detect2_raw);
996 static int ab8500_gpadc_acc_detect2_open(struct inode *inode,
999 return single_open(file, ab8500_gpadc_acc_detect2_print,
1003 static const struct file_operations ab8500_gpadc_acc_detect2_fops = {
1004 .open = ab8500_gpadc_acc_detect2_open,
1006 .llseek = seq_lseek,
1007 .release = single_release,
1008 .owner = THIS_MODULE,
1011 static int ab8500_gpadc_aux1_print(struct seq_file *s, void *p)
1015 struct ab8500_gpadc *gpadc;
1017 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1018 aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1,
1019 avg_sample, trig_edge, trig_timer, conv_type);
1020 aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1,
1023 return seq_printf(s, "%d,0x%X\n",
1024 aux1_convert, aux1_raw);
1027 static int ab8500_gpadc_aux1_open(struct inode *inode, struct file *file)
1029 return single_open(file, ab8500_gpadc_aux1_print, inode->i_private);
1032 static const struct file_operations ab8500_gpadc_aux1_fops = {
1033 .open = ab8500_gpadc_aux1_open,
1035 .llseek = seq_lseek,
1036 .release = single_release,
1037 .owner = THIS_MODULE,
1040 static int ab8500_gpadc_aux2_print(struct seq_file *s, void *p)
1044 struct ab8500_gpadc *gpadc;
1046 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1047 aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2,
1048 avg_sample, trig_edge, trig_timer, conv_type);
1049 aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2,
1052 return seq_printf(s, "%d,0x%X\n",
1053 aux2_convert, aux2_raw);
1056 static int ab8500_gpadc_aux2_open(struct inode *inode, struct file *file)
1058 return single_open(file, ab8500_gpadc_aux2_print, inode->i_private);
1061 static const struct file_operations ab8500_gpadc_aux2_fops = {
1062 .open = ab8500_gpadc_aux2_open,
1064 .llseek = seq_lseek,
1065 .release = single_release,
1066 .owner = THIS_MODULE,
1069 static int ab8500_gpadc_main_bat_v_print(struct seq_file *s, void *p)
1072 int main_bat_v_convert;
1073 struct ab8500_gpadc *gpadc;
1075 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1076 main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V,
1077 avg_sample, trig_edge, trig_timer, conv_type);
1078 main_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
1081 return seq_printf(s, "%d,0x%X\n",
1082 main_bat_v_convert, main_bat_v_raw);
1085 static int ab8500_gpadc_main_bat_v_open(struct inode *inode,
1088 return single_open(file, ab8500_gpadc_main_bat_v_print, inode->i_private);
1091 static const struct file_operations ab8500_gpadc_main_bat_v_fops = {
1092 .open = ab8500_gpadc_main_bat_v_open,
1094 .llseek = seq_lseek,
1095 .release = single_release,
1096 .owner = THIS_MODULE,
1099 static int ab8500_gpadc_vbus_v_print(struct seq_file *s, void *p)
1103 struct ab8500_gpadc *gpadc;
1105 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1106 vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V,
1107 avg_sample, trig_edge, trig_timer, conv_type);
1108 vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V,
1111 return seq_printf(s, "%d,0x%X\n",
1112 vbus_v_convert, vbus_v_raw);
1115 static int ab8500_gpadc_vbus_v_open(struct inode *inode, struct file *file)
1117 return single_open(file, ab8500_gpadc_vbus_v_print, inode->i_private);
1120 static const struct file_operations ab8500_gpadc_vbus_v_fops = {
1121 .open = ab8500_gpadc_vbus_v_open,
1123 .llseek = seq_lseek,
1124 .release = single_release,
1125 .owner = THIS_MODULE,
1128 static int ab8500_gpadc_main_charger_c_print(struct seq_file *s, void *p)
1130 int main_charger_c_raw;
1131 int main_charger_c_convert;
1132 struct ab8500_gpadc *gpadc;
1134 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1135 main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C,
1136 avg_sample, trig_edge, trig_timer, conv_type);
1137 main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1138 MAIN_CHARGER_C, main_charger_c_raw);
1140 return seq_printf(s, "%d,0x%X\n",
1141 main_charger_c_convert, main_charger_c_raw);
1144 static int ab8500_gpadc_main_charger_c_open(struct inode *inode,
1147 return single_open(file, ab8500_gpadc_main_charger_c_print,
1151 static const struct file_operations ab8500_gpadc_main_charger_c_fops = {
1152 .open = ab8500_gpadc_main_charger_c_open,
1154 .llseek = seq_lseek,
1155 .release = single_release,
1156 .owner = THIS_MODULE,
1159 static int ab8500_gpadc_usb_charger_c_print(struct seq_file *s, void *p)
1161 int usb_charger_c_raw;
1162 int usb_charger_c_convert;
1163 struct ab8500_gpadc *gpadc;
1165 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1166 usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C,
1167 avg_sample, trig_edge, trig_timer, conv_type);
1168 usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1169 USB_CHARGER_C, usb_charger_c_raw);
1171 return seq_printf(s, "%d,0x%X\n",
1172 usb_charger_c_convert, usb_charger_c_raw);
1175 static int ab8500_gpadc_usb_charger_c_open(struct inode *inode,
1178 return single_open(file, ab8500_gpadc_usb_charger_c_print,
1182 static const struct file_operations ab8500_gpadc_usb_charger_c_fops = {
1183 .open = ab8500_gpadc_usb_charger_c_open,
1185 .llseek = seq_lseek,
1186 .release = single_release,
1187 .owner = THIS_MODULE,
1190 static int ab8500_gpadc_bk_bat_v_print(struct seq_file *s, void *p)
1193 int bk_bat_v_convert;
1194 struct ab8500_gpadc *gpadc;
1196 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1197 bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V,
1198 avg_sample, trig_edge, trig_timer, conv_type);
1199 bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1200 BK_BAT_V, bk_bat_v_raw);
1202 return seq_printf(s, "%d,0x%X\n",
1203 bk_bat_v_convert, bk_bat_v_raw);
1206 static int ab8500_gpadc_bk_bat_v_open(struct inode *inode, struct file *file)
1208 return single_open(file, ab8500_gpadc_bk_bat_v_print, inode->i_private);
1211 static const struct file_operations ab8500_gpadc_bk_bat_v_fops = {
1212 .open = ab8500_gpadc_bk_bat_v_open,
1214 .llseek = seq_lseek,
1215 .release = single_release,
1216 .owner = THIS_MODULE,
1219 static int ab8500_gpadc_die_temp_print(struct seq_file *s, void *p)
1222 int die_temp_convert;
1223 struct ab8500_gpadc *gpadc;
1225 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1226 die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP,
1227 avg_sample, trig_edge, trig_timer, conv_type);
1228 die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP,
1231 return seq_printf(s, "%d,0x%X\n",
1232 die_temp_convert, die_temp_raw);
1235 static int ab8500_gpadc_die_temp_open(struct inode *inode, struct file *file)
1237 return single_open(file, ab8500_gpadc_die_temp_print, inode->i_private);
1240 static const struct file_operations ab8500_gpadc_die_temp_fops = {
1241 .open = ab8500_gpadc_die_temp_open,
1243 .llseek = seq_lseek,
1244 .release = single_release,
1245 .owner = THIS_MODULE,
1248 static int ab8500_gpadc_avg_sample_print(struct seq_file *s, void *p)
1250 return seq_printf(s, "%d\n", avg_sample);
1253 static int ab8500_gpadc_avg_sample_open(struct inode *inode, struct file *file)
1255 return single_open(file, ab8500_gpadc_avg_sample_print,
1259 static ssize_t ab8500_gpadc_avg_sample_write(struct file *file,
1260 const char __user *user_buf,
1261 size_t count, loff_t *ppos)
1263 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1266 unsigned long user_avg_sample;
1269 /* Get userspace string and assure termination */
1270 buf_size = min(count, (sizeof(buf) - 1));
1271 if (copy_from_user(buf, user_buf, buf_size))
1275 err = strict_strtoul(buf, 0, &user_avg_sample);
1278 if ((user_avg_sample == SAMPLE_1) || (user_avg_sample == SAMPLE_4)
1279 || (user_avg_sample == SAMPLE_8)
1280 || (user_avg_sample == SAMPLE_16)) {
1281 avg_sample = (u8) user_avg_sample;
1283 dev_err(dev, "debugfs error input: "
1284 "should be egal to 1, 4, 8 or 16\n");
1290 static const struct file_operations ab8500_gpadc_avg_sample_fops = {
1291 .open = ab8500_gpadc_avg_sample_open,
1293 .write = ab8500_gpadc_avg_sample_write,
1294 .llseek = seq_lseek,
1295 .release = single_release,
1296 .owner = THIS_MODULE,
1299 static int ab8500_gpadc_trig_edge_print(struct seq_file *s, void *p)
1301 return seq_printf(s, "%d\n", trig_edge);
1304 static int ab8500_gpadc_trig_edge_open(struct inode *inode, struct file *file)
1306 return single_open(file, ab8500_gpadc_trig_edge_print,
1310 static ssize_t ab8500_gpadc_trig_edge_write(struct file *file,
1311 const char __user *user_buf,
1312 size_t count, loff_t *ppos)
1314 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1317 unsigned long user_trig_edge;
1320 /* Get userspace string and assure termination */
1321 buf_size = min(count, (sizeof(buf) - 1));
1322 if (copy_from_user(buf, user_buf, buf_size))
1326 err = strict_strtoul(buf, 0, &user_trig_edge);
1329 if ((user_trig_edge == RISING_EDGE)
1330 || (user_trig_edge == FALLING_EDGE)) {
1331 trig_edge = (u8) user_trig_edge;
1333 dev_err(dev, "Wrong input:\n"
1334 "Enter 0. Rising edge\n"
1335 "Enter 1. Falling edge\n");
1341 static const struct file_operations ab8500_gpadc_trig_edge_fops = {
1342 .open = ab8500_gpadc_trig_edge_open,
1344 .write = ab8500_gpadc_trig_edge_write,
1345 .llseek = seq_lseek,
1346 .release = single_release,
1347 .owner = THIS_MODULE,
1350 static int ab8500_gpadc_trig_timer_print(struct seq_file *s, void *p)
1352 return seq_printf(s, "%d\n", trig_timer);
1355 static int ab8500_gpadc_trig_timer_open(struct inode *inode, struct file *file)
1357 return single_open(file, ab8500_gpadc_trig_timer_print,
1361 static ssize_t ab8500_gpadc_trig_timer_write(struct file *file,
1362 const char __user *user_buf,
1363 size_t count, loff_t *ppos)
1365 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1368 unsigned long user_trig_timer;
1371 /* Get userspace string and assure termination */
1372 buf_size = min(count, (sizeof(buf) - 1));
1373 if (copy_from_user(buf, user_buf, buf_size))
1377 err = strict_strtoul(buf, 0, &user_trig_timer);
1380 if ((user_trig_timer >= 0) && (user_trig_timer <= 255)) {
1381 trig_timer = (u8) user_trig_timer;
1383 dev_err(dev, "debugfs error input: "
1384 "should be beetween 0 to 255\n");
1390 static const struct file_operations ab8500_gpadc_trig_timer_fops = {
1391 .open = ab8500_gpadc_trig_timer_open,
1393 .write = ab8500_gpadc_trig_timer_write,
1394 .llseek = seq_lseek,
1395 .release = single_release,
1396 .owner = THIS_MODULE,
1399 static int ab8500_gpadc_conv_type_print(struct seq_file *s, void *p)
1401 return seq_printf(s, "%d\n", conv_type);
1404 static int ab8500_gpadc_conv_type_open(struct inode *inode, struct file *file)
1406 return single_open(file, ab8500_gpadc_conv_type_print,
1410 static ssize_t ab8500_gpadc_conv_type_write(struct file *file,
1411 const char __user *user_buf,
1412 size_t count, loff_t *ppos)
1414 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1417 unsigned long user_conv_type;
1420 /* Get userspace string and assure termination */
1421 buf_size = min(count, (sizeof(buf) - 1));
1422 if (copy_from_user(buf, user_buf, buf_size))
1426 err = strict_strtoul(buf, 0, &user_conv_type);
1429 if ((user_conv_type == ADC_SW)
1430 || (user_conv_type == ADC_HW)) {
1431 conv_type = (u8) user_conv_type;
1433 dev_err(dev, "Wrong input:\n"
1434 "Enter 0. ADC SW conversion\n"
1435 "Enter 1. ADC HW conversion\n");
1441 static const struct file_operations ab8500_gpadc_conv_type_fops = {
1442 .open = ab8500_gpadc_conv_type_open,
1444 .write = ab8500_gpadc_conv_type_write,
1445 .llseek = seq_lseek,
1446 .release = single_release,
1447 .owner = THIS_MODULE,
1451 * return length of an ASCII numerical value, 0 is string is not a
1453 * string shall start at value 1st char.
1454 * string can be tailed with \0 or space or newline chars only.
1455 * value can be decimal or hexadecimal (prefixed 0x or 0X).
1457 static int strval_len(char *b)
1460 if ((*s == '0') && ((*(s+1) == 'x') || (*(s+1) == 'X'))) {
1462 for (; *s && (*s != ' ') && (*s != '\n'); s++) {
1469 for (; *s && (*s != ' ') && (*s != '\n'); s++) {
1478 * parse hwreg input data.
1479 * update global hwreg_cfg only if input data syntax is ok.
1481 static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg,
1484 uint write, val = 0;
1487 struct hwreg_cfg loc = {
1488 .bank = 0, /* default: invalid phys addr */
1489 .addr = 0, /* default: invalid phys addr */
1490 .fmt = 0, /* default: 32bit access, hex output */
1491 .mask = 0xFFFFFFFF, /* default: no mask */
1492 .shift = 0, /* default: no bit shift */
1495 /* read or write ? */
1496 if (!strncmp(b, "read ", 5)) {
1499 } else if (!strncmp(b, "write ", 6)) {
1505 /* OPTIONS -l|-w|-b -s -m -o */
1506 while ((*b == ' ') || (*b == '-')) {
1507 if (*(b-1) != ' ') {
1511 if ((!strncmp(b, "-d ", 3)) ||
1512 (!strncmp(b, "-dec ", 5))) {
1513 b += (*(b+2) == ' ') ? 3 : 5;
1515 } else if ((!strncmp(b, "-h ", 3)) ||
1516 (!strncmp(b, "-hex ", 5))) {
1517 b += (*(b+2) == ' ') ? 3 : 5;
1519 } else if ((!strncmp(b, "-m ", 3)) ||
1520 (!strncmp(b, "-mask ", 6))) {
1521 b += (*(b+2) == ' ') ? 3 : 6;
1522 if (strval_len(b) == 0)
1524 loc.mask = simple_strtoul(b, &b, 0);
1525 } else if ((!strncmp(b, "-s ", 3)) ||
1526 (!strncmp(b, "-shift ", 7))) {
1527 b += (*(b+2) == ' ') ? 3 : 7;
1528 if (strval_len(b) == 0)
1530 loc.shift = simple_strtol(b, &b, 0);
1535 /* get arg BANK and ADDRESS */
1536 if (strval_len(b) == 0)
1538 loc.bank = simple_strtoul(b, &b, 0);
1541 if (strval_len(b) == 0)
1543 loc.addr = simple_strtoul(b, &b, 0);
1548 if (strval_len(b) == 0)
1550 val = simple_strtoul(b, &b, 0);
1553 /* args are ok, update target cfg (mainly for read) */
1556 #ifdef ABB_HWREG_DEBUG
1557 pr_warn("HWREG request: %s, %s, addr=0x%08X, mask=0x%X, shift=%d"
1558 "value=0x%X\n", (write) ? "write" : "read",
1559 REG_FMT_DEC(cfg) ? "decimal" : "hexa",
1560 cfg->addr, cfg->mask, cfg->shift, val);
1566 ret = abx500_get_register_interruptible(dev,
1567 (u8)cfg->bank, (u8)cfg->addr, ®value);
1569 dev_err(dev, "abx500_get_reg fail %d, %d\n",
1574 if (cfg->shift >= 0) {
1575 regvalue &= ~(cfg->mask << (cfg->shift));
1576 val = (val & cfg->mask) << (cfg->shift);
1578 regvalue &= ~(cfg->mask >> (-cfg->shift));
1579 val = (val & cfg->mask) >> (-cfg->shift);
1581 val = val | regvalue;
1583 ret = abx500_set_register_interruptible(dev,
1584 (u8)cfg->bank, (u8)cfg->addr, (u8)val);
1586 pr_err("abx500_set_reg failed %d, %d", ret, __LINE__);
1593 static ssize_t ab8500_hwreg_write(struct file *file,
1594 const char __user *user_buf, size_t count, loff_t *ppos)
1596 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1600 /* Get userspace string and assure termination */
1601 buf_size = min(count, (sizeof(buf)-1));
1602 if (copy_from_user(buf, user_buf, buf_size))
1606 /* get args and process */
1607 ret = hwreg_common_write(buf, &hwreg_cfg, dev);
1608 return (ret) ? ret : buf_size;
1612 * - irq subscribe/unsubscribe stuff
1614 static int ab8500_subscribe_unsubscribe_print(struct seq_file *s, void *p)
1616 seq_printf(s, "%d\n", irq_first);
1621 static int ab8500_subscribe_unsubscribe_open(struct inode *inode,
1624 return single_open(file, ab8500_subscribe_unsubscribe_print,
1629 * Userspace should use poll() on this file. When an event occur
1630 * the blocking poll will be released.
1632 static ssize_t show_irq(struct device *dev,
1633 struct device_attribute *attr, char *buf)
1636 unsigned int irq_index;
1639 err = strict_strtoul(attr->attr.name, 0, &name);
1643 irq_index = name - irq_first;
1644 if (irq_index >= num_irqs)
1647 return sprintf(buf, "%u\n", irq_count[irq_index]);
1650 static ssize_t ab8500_subscribe_write(struct file *file,
1651 const char __user *user_buf,
1652 size_t count, loff_t *ppos)
1654 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1657 unsigned long user_val;
1659 unsigned int irq_index;
1661 /* Get userspace string and assure termination */
1662 buf_size = min(count, (sizeof(buf)-1));
1663 if (copy_from_user(buf, user_buf, buf_size))
1667 err = strict_strtoul(buf, 0, &user_val);
1670 if (user_val < irq_first) {
1671 dev_err(dev, "debugfs error input < %d\n", irq_first);
1674 if (user_val > irq_last) {
1675 dev_err(dev, "debugfs error input > %d\n", irq_last);
1679 irq_index = user_val - irq_first;
1680 if (irq_index >= num_irqs)
1684 * This will create a sysfs file named <irq-nr> which userspace can
1685 * use to select or poll and get the AB8500 events
1687 dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute),
1689 event_name[irq_index] = kmalloc(buf_size, GFP_KERNEL);
1690 sprintf(event_name[irq_index], "%lu", user_val);
1691 dev_attr[irq_index]->show = show_irq;
1692 dev_attr[irq_index]->store = NULL;
1693 dev_attr[irq_index]->attr.name = event_name[irq_index];
1694 dev_attr[irq_index]->attr.mode = S_IRUGO;
1695 err = sysfs_create_file(&dev->kobj, &dev_attr[irq_index]->attr);
1697 printk(KERN_ERR "sysfs_create_file failed %d\n", err);
1701 err = request_threaded_irq(user_val, NULL, ab8500_debug_handler,
1702 IRQF_SHARED | IRQF_NO_SUSPEND,
1703 "ab8500-debug", &dev->kobj);
1705 printk(KERN_ERR "request_threaded_irq failed %d, %lu\n",
1707 sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr);
1714 static ssize_t ab8500_unsubscribe_write(struct file *file,
1715 const char __user *user_buf,
1716 size_t count, loff_t *ppos)
1718 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1721 unsigned long user_val;
1723 unsigned int irq_index;
1725 /* Get userspace string and assure termination */
1726 buf_size = min(count, (sizeof(buf)-1));
1727 if (copy_from_user(buf, user_buf, buf_size))
1731 err = strict_strtoul(buf, 0, &user_val);
1734 if (user_val < irq_first) {
1735 dev_err(dev, "debugfs error input < %d\n", irq_first);
1738 if (user_val > irq_last) {
1739 dev_err(dev, "debugfs error input > %d\n", irq_last);
1743 irq_index = user_val - irq_first;
1744 if (irq_index >= num_irqs)
1747 /* Set irq count to 0 when unsubscribe */
1748 irq_count[irq_index] = 0;
1750 if (dev_attr[irq_index])
1751 sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr);
1754 free_irq(user_val, &dev->kobj);
1755 kfree(event_name[irq_index]);
1756 kfree(dev_attr[irq_index]);
1762 * - several deubgfs nodes fops
1765 static const struct file_operations ab8500_bank_fops = {
1766 .open = ab8500_bank_open,
1767 .write = ab8500_bank_write,
1769 .llseek = seq_lseek,
1770 .release = single_release,
1771 .owner = THIS_MODULE,
1774 static const struct file_operations ab8500_address_fops = {
1775 .open = ab8500_address_open,
1776 .write = ab8500_address_write,
1778 .llseek = seq_lseek,
1779 .release = single_release,
1780 .owner = THIS_MODULE,
1783 static const struct file_operations ab8500_val_fops = {
1784 .open = ab8500_val_open,
1785 .write = ab8500_val_write,
1787 .llseek = seq_lseek,
1788 .release = single_release,
1789 .owner = THIS_MODULE,
1792 static const struct file_operations ab8500_interrupts_fops = {
1793 .open = ab8500_interrupts_open,
1795 .llseek = seq_lseek,
1796 .release = single_release,
1797 .owner = THIS_MODULE,
1800 static const struct file_operations ab8500_subscribe_fops = {
1801 .open = ab8500_subscribe_unsubscribe_open,
1802 .write = ab8500_subscribe_write,
1804 .llseek = seq_lseek,
1805 .release = single_release,
1806 .owner = THIS_MODULE,
1809 static const struct file_operations ab8500_unsubscribe_fops = {
1810 .open = ab8500_subscribe_unsubscribe_open,
1811 .write = ab8500_unsubscribe_write,
1813 .llseek = seq_lseek,
1814 .release = single_release,
1815 .owner = THIS_MODULE,
1818 static const struct file_operations ab8500_hwreg_fops = {
1819 .open = ab8500_hwreg_open,
1820 .write = ab8500_hwreg_write,
1822 .llseek = seq_lseek,
1823 .release = single_release,
1824 .owner = THIS_MODULE,
1827 static struct dentry *ab8500_dir;
1828 static struct dentry *ab8500_gpadc_dir;
1830 static int ab8500_debug_probe(struct platform_device *plf)
1832 struct dentry *file;
1834 struct ab8500 *ab8500;
1835 debug_bank = AB8500_MISC;
1836 debug_address = AB8500_REV_REG & 0x00FF;
1838 ab8500 = dev_get_drvdata(plf->dev.parent);
1839 num_irqs = ab8500->mask_size;
1841 irq_count = kzalloc(sizeof(*irq_count)*num_irqs, GFP_KERNEL);
1845 dev_attr = kzalloc(sizeof(*dev_attr)*num_irqs,GFP_KERNEL);
1847 goto out_freeirq_count;
1849 event_name = kzalloc(sizeof(*event_name)*num_irqs, GFP_KERNEL);
1851 goto out_freedev_attr;
1853 irq_first = platform_get_irq_byname(plf, "IRQ_FIRST");
1854 if (irq_first < 0) {
1855 dev_err(&plf->dev, "First irq not found, err %d\n",
1858 goto out_freeevent_name;
1861 irq_last = platform_get_irq_byname(plf, "IRQ_LAST");
1863 dev_err(&plf->dev, "Last irq not found, err %d\n",
1866 goto out_freeevent_name;
1869 ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
1873 ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING,
1875 if (!ab8500_gpadc_dir)
1878 file = debugfs_create_file("all-bank-registers", S_IRUGO,
1879 ab8500_dir, &plf->dev, &ab8500_registers_fops);
1883 file = debugfs_create_file("all-banks", S_IRUGO,
1884 ab8500_dir, &plf->dev, &ab8500_all_banks_fops);
1888 file = debugfs_create_file("register-bank", (S_IRUGO | S_IWUSR),
1889 ab8500_dir, &plf->dev, &ab8500_bank_fops);
1893 file = debugfs_create_file("register-address", (S_IRUGO | S_IWUSR),
1894 ab8500_dir, &plf->dev, &ab8500_address_fops);
1898 file = debugfs_create_file("register-value", (S_IRUGO | S_IWUSR),
1899 ab8500_dir, &plf->dev, &ab8500_val_fops);
1903 file = debugfs_create_file("irq-subscribe", (S_IRUGO | S_IWUSR),
1904 ab8500_dir, &plf->dev, &ab8500_subscribe_fops);
1908 if (is_ab8500(ab8500))
1909 num_interrupt_lines = AB8500_NR_IRQS;
1910 else if (is_ab8505(ab8500))
1911 num_interrupt_lines = AB8505_NR_IRQS;
1912 else if (is_ab9540(ab8500))
1913 num_interrupt_lines = AB9540_NR_IRQS;
1915 file = debugfs_create_file("interrupts", (S_IRUGO),
1916 ab8500_dir, &plf->dev, &ab8500_interrupts_fops);
1920 file = debugfs_create_file("irq-unsubscribe", (S_IRUGO | S_IWUSR),
1921 ab8500_dir, &plf->dev, &ab8500_unsubscribe_fops);
1925 file = debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR),
1926 ab8500_dir, &plf->dev, &ab8500_hwreg_fops);
1930 file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR),
1931 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bat_ctrl_fops);
1935 file = debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR),
1936 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_btemp_ball_fops);
1940 file = debugfs_create_file("main_charger_v", (S_IRUGO | S_IWUSR),
1941 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_charger_v_fops);
1945 file = debugfs_create_file("acc_detect1", (S_IRUGO | S_IWUSR),
1946 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_acc_detect1_fops);
1950 file = debugfs_create_file("acc_detect2", (S_IRUGO | S_IWUSR),
1951 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_acc_detect2_fops);
1955 file = debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR),
1956 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux1_fops);
1960 file = debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR),
1961 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux2_fops);
1965 file = debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR),
1966 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_bat_v_fops);
1970 file = debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR),
1971 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_vbus_v_fops);
1975 file = debugfs_create_file("main_charger_c", (S_IRUGO | S_IWUSR),
1976 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_charger_c_fops);
1980 file = debugfs_create_file("usb_charger_c", (S_IRUGO | S_IWUSR),
1981 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_usb_charger_c_fops);
1985 file = debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR),
1986 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bk_bat_v_fops);
1990 file = debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR),
1991 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_die_temp_fops);
1995 file = debugfs_create_file("avg_sample", (S_IRUGO | S_IWUGO),
1996 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_avg_sample_fops);
2000 file = debugfs_create_file("trig_edge", (S_IRUGO | S_IWUGO),
2001 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_trig_edge_fops);
2005 file = debugfs_create_file("trig_timer", (S_IRUGO | S_IWUGO),
2006 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_trig_timer_fops);
2010 file = debugfs_create_file("conv_type", (S_IRUGO | S_IWUGO),
2011 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_conv_type_fops);
2019 debugfs_remove_recursive(ab8500_dir);
2020 dev_err(&plf->dev, "failed to create debugfs entries.\n");
2031 static int ab8500_debug_remove(struct platform_device *plf)
2033 debugfs_remove_recursive(ab8500_dir);
2041 static struct platform_driver ab8500_debug_driver = {
2043 .name = "ab8500-debug",
2044 .owner = THIS_MODULE,
2046 .probe = ab8500_debug_probe,
2047 .remove = ab8500_debug_remove
2050 static int __init ab8500_debug_init(void)
2052 return platform_driver_register(&ab8500_debug_driver);
2055 static void __exit ab8500_debug_exit(void)
2057 platform_driver_unregister(&ab8500_debug_driver);
2059 subsys_initcall(ab8500_debug_init);
2060 module_exit(ab8500_debug_exit);
2062 MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
2063 MODULE_DESCRIPTION("AB8500 DEBUG");
2064 MODULE_LICENSE("GPL v2");