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, " [%u/0x%02X]: 0x%02X\n",
532 "seq_printf overflow bank=%d reg=%d\n",
534 /* Error is not returned here since
535 * the output is wanted in any case */
539 printk(KERN_INFO" [%u/0x%02X]: 0x%02X\n", bank,
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 %u:\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 %u:\n", i);
584 dev_err(dev, "seq_printf overflow, bank=%d\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 %u:\n", i);
600 ab8500_registers_print(dev, i, NULL);
604 static int ab8500_all_banks_open(struct inode *inode, struct file *file)
609 err = single_open(file, ab8500_print_all_banks, inode->i_private);
611 /* Default buf size in seq_read is not enough */
612 s = (struct seq_file *)file->private_data;
613 s->size = (PAGE_SIZE * 2);
614 s->buf = kmalloc(s->size, GFP_KERNEL);
616 single_release(inode, file);
623 static const struct file_operations ab8500_all_banks_fops = {
624 .open = ab8500_all_banks_open,
627 .release = single_release,
628 .owner = THIS_MODULE,
631 static int ab8500_bank_print(struct seq_file *s, void *p)
633 return seq_printf(s, "%d\n", debug_bank);
636 static int ab8500_bank_open(struct inode *inode, struct file *file)
638 return single_open(file, ab8500_bank_print, inode->i_private);
641 static ssize_t ab8500_bank_write(struct file *file,
642 const char __user *user_buf,
643 size_t count, loff_t *ppos)
645 struct device *dev = ((struct seq_file *)(file->private_data))->private;
646 unsigned long user_bank;
649 /* Get userspace string and assure termination */
650 err = kstrtoul_from_user(user_buf, count, 0, &user_bank);
654 if (user_bank >= AB8500_NUM_BANKS) {
655 dev_err(dev, "debugfs error input > number of banks\n");
659 debug_bank = user_bank;
664 static int ab8500_address_print(struct seq_file *s, void *p)
666 return seq_printf(s, "0x%02X\n", debug_address);
669 static int ab8500_address_open(struct inode *inode, struct file *file)
671 return single_open(file, ab8500_address_print, inode->i_private);
674 static ssize_t ab8500_address_write(struct file *file,
675 const char __user *user_buf,
676 size_t count, loff_t *ppos)
678 struct device *dev = ((struct seq_file *)(file->private_data))->private;
679 unsigned long user_address;
682 /* Get userspace string and assure termination */
683 err = kstrtoul_from_user(user_buf, count, 0, &user_address);
687 if (user_address > 0xff) {
688 dev_err(dev, "debugfs error input > 0xff\n");
691 debug_address = user_address;
695 static int ab8500_val_print(struct seq_file *s, void *p)
697 struct device *dev = s->private;
701 ret = abx500_get_register_interruptible(dev,
702 (u8)debug_bank, (u8)debug_address, ®value);
704 dev_err(dev, "abx500_get_reg fail %d, %d\n",
708 seq_printf(s, "0x%02X\n", regvalue);
713 static int ab8500_val_open(struct inode *inode, struct file *file)
715 return single_open(file, ab8500_val_print, inode->i_private);
718 static ssize_t ab8500_val_write(struct file *file,
719 const char __user *user_buf,
720 size_t count, loff_t *ppos)
722 struct device *dev = ((struct seq_file *)(file->private_data))->private;
723 unsigned long user_val;
726 /* Get userspace string and assure termination */
727 err = kstrtoul_from_user(user_buf, count, 0, &user_val);
731 if (user_val > 0xff) {
732 dev_err(dev, "debugfs error input > 0xff\n");
735 err = abx500_set_register_interruptible(dev,
736 (u8)debug_bank, debug_address, (u8)user_val);
738 printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__);
748 static u32 num_interrupts[AB8500_MAX_NR_IRQS];
749 static int num_interrupt_lines;
751 void ab8500_debug_register_interrupt(int line)
753 if (line < num_interrupt_lines)
754 num_interrupts[line]++;
757 static int ab8500_interrupts_print(struct seq_file *s, void *p)
761 seq_printf(s, "irq: number of\n");
763 for (line = 0; line < num_interrupt_lines; line++)
764 seq_printf(s, "%3i: %6i\n", line, num_interrupts[line]);
769 static int ab8500_interrupts_open(struct inode *inode, struct file *file)
771 return single_open(file, ab8500_interrupts_print, inode->i_private);
775 * - HWREG DB8500 formated routines
777 static int ab8500_hwreg_print(struct seq_file *s, void *d)
779 struct device *dev = s->private;
783 ret = abx500_get_register_interruptible(dev,
784 (u8)hwreg_cfg.bank, (u8)hwreg_cfg.addr, ®value);
786 dev_err(dev, "abx500_get_reg fail %d, %d\n",
791 if (hwreg_cfg.shift >= 0)
792 regvalue >>= hwreg_cfg.shift;
794 regvalue <<= -hwreg_cfg.shift;
795 regvalue &= hwreg_cfg.mask;
797 if (REG_FMT_DEC(&hwreg_cfg))
798 seq_printf(s, "%d\n", regvalue);
800 seq_printf(s, "0x%02X\n", regvalue);
804 static int ab8500_hwreg_open(struct inode *inode, struct file *file)
806 return single_open(file, ab8500_hwreg_print, inode->i_private);
809 static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p)
812 int bat_ctrl_convert;
813 struct ab8500_gpadc *gpadc;
815 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
816 bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL,
817 avg_sample, trig_edge, trig_timer, conv_type);
818 bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc,
819 BAT_CTRL, bat_ctrl_raw);
821 return seq_printf(s, "%d,0x%X\n",
822 bat_ctrl_convert, bat_ctrl_raw);
825 static int ab8500_gpadc_bat_ctrl_open(struct inode *inode, struct file *file)
827 return single_open(file, ab8500_gpadc_bat_ctrl_print, inode->i_private);
830 static const struct file_operations ab8500_gpadc_bat_ctrl_fops = {
831 .open = ab8500_gpadc_bat_ctrl_open,
834 .release = single_release,
835 .owner = THIS_MODULE,
838 static int ab8500_gpadc_btemp_ball_print(struct seq_file *s, void *p)
841 int btemp_ball_convert;
842 struct ab8500_gpadc *gpadc;
844 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
845 btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL,
846 avg_sample, trig_edge, trig_timer, conv_type);
847 btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
851 "%d,0x%X\n", btemp_ball_convert, btemp_ball_raw);
854 static int ab8500_gpadc_btemp_ball_open(struct inode *inode,
857 return single_open(file, ab8500_gpadc_btemp_ball_print, inode->i_private);
860 static const struct file_operations ab8500_gpadc_btemp_ball_fops = {
861 .open = ab8500_gpadc_btemp_ball_open,
864 .release = single_release,
865 .owner = THIS_MODULE,
868 static int ab8500_gpadc_main_charger_v_print(struct seq_file *s, void *p)
870 int main_charger_v_raw;
871 int main_charger_v_convert;
872 struct ab8500_gpadc *gpadc;
874 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
875 main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V,
876 avg_sample, trig_edge, trig_timer, conv_type);
877 main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
878 MAIN_CHARGER_V, main_charger_v_raw);
880 return seq_printf(s, "%d,0x%X\n",
881 main_charger_v_convert, main_charger_v_raw);
884 static int ab8500_gpadc_main_charger_v_open(struct inode *inode,
887 return single_open(file, ab8500_gpadc_main_charger_v_print,
891 static const struct file_operations ab8500_gpadc_main_charger_v_fops = {
892 .open = ab8500_gpadc_main_charger_v_open,
895 .release = single_release,
896 .owner = THIS_MODULE,
899 static int ab8500_gpadc_acc_detect1_print(struct seq_file *s, void *p)
902 int acc_detect1_convert;
903 struct ab8500_gpadc *gpadc;
905 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
906 acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1,
907 avg_sample, trig_edge, trig_timer, conv_type);
908 acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1,
911 return seq_printf(s, "%d,0x%X\n",
912 acc_detect1_convert, acc_detect1_raw);
915 static int ab8500_gpadc_acc_detect1_open(struct inode *inode,
918 return single_open(file, ab8500_gpadc_acc_detect1_print,
922 static const struct file_operations ab8500_gpadc_acc_detect1_fops = {
923 .open = ab8500_gpadc_acc_detect1_open,
926 .release = single_release,
927 .owner = THIS_MODULE,
930 static int ab8500_gpadc_acc_detect2_print(struct seq_file *s, void *p)
933 int acc_detect2_convert;
934 struct ab8500_gpadc *gpadc;
936 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
937 acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2,
938 avg_sample, trig_edge, trig_timer, conv_type);
939 acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc,
940 ACC_DETECT2, acc_detect2_raw);
942 return seq_printf(s, "%d,0x%X\n",
943 acc_detect2_convert, acc_detect2_raw);
946 static int ab8500_gpadc_acc_detect2_open(struct inode *inode,
949 return single_open(file, ab8500_gpadc_acc_detect2_print,
953 static const struct file_operations ab8500_gpadc_acc_detect2_fops = {
954 .open = ab8500_gpadc_acc_detect2_open,
957 .release = single_release,
958 .owner = THIS_MODULE,
961 static int ab8500_gpadc_aux1_print(struct seq_file *s, void *p)
965 struct ab8500_gpadc *gpadc;
967 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
968 aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1,
969 avg_sample, trig_edge, trig_timer, conv_type);
970 aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1,
973 return seq_printf(s, "%d,0x%X\n",
974 aux1_convert, aux1_raw);
977 static int ab8500_gpadc_aux1_open(struct inode *inode, struct file *file)
979 return single_open(file, ab8500_gpadc_aux1_print, inode->i_private);
982 static const struct file_operations ab8500_gpadc_aux1_fops = {
983 .open = ab8500_gpadc_aux1_open,
986 .release = single_release,
987 .owner = THIS_MODULE,
990 static int ab8500_gpadc_aux2_print(struct seq_file *s, void *p)
994 struct ab8500_gpadc *gpadc;
996 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
997 aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2,
998 avg_sample, trig_edge, trig_timer, conv_type);
999 aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2,
1002 return seq_printf(s, "%d,0x%X\n",
1003 aux2_convert, aux2_raw);
1006 static int ab8500_gpadc_aux2_open(struct inode *inode, struct file *file)
1008 return single_open(file, ab8500_gpadc_aux2_print, inode->i_private);
1011 static const struct file_operations ab8500_gpadc_aux2_fops = {
1012 .open = ab8500_gpadc_aux2_open,
1014 .llseek = seq_lseek,
1015 .release = single_release,
1016 .owner = THIS_MODULE,
1019 static int ab8500_gpadc_main_bat_v_print(struct seq_file *s, void *p)
1022 int main_bat_v_convert;
1023 struct ab8500_gpadc *gpadc;
1025 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1026 main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V,
1027 avg_sample, trig_edge, trig_timer, conv_type);
1028 main_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
1031 return seq_printf(s, "%d,0x%X\n",
1032 main_bat_v_convert, main_bat_v_raw);
1035 static int ab8500_gpadc_main_bat_v_open(struct inode *inode,
1038 return single_open(file, ab8500_gpadc_main_bat_v_print, inode->i_private);
1041 static const struct file_operations ab8500_gpadc_main_bat_v_fops = {
1042 .open = ab8500_gpadc_main_bat_v_open,
1044 .llseek = seq_lseek,
1045 .release = single_release,
1046 .owner = THIS_MODULE,
1049 static int ab8500_gpadc_vbus_v_print(struct seq_file *s, void *p)
1053 struct ab8500_gpadc *gpadc;
1055 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1056 vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V,
1057 avg_sample, trig_edge, trig_timer, conv_type);
1058 vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V,
1061 return seq_printf(s, "%d,0x%X\n",
1062 vbus_v_convert, vbus_v_raw);
1065 static int ab8500_gpadc_vbus_v_open(struct inode *inode, struct file *file)
1067 return single_open(file, ab8500_gpadc_vbus_v_print, inode->i_private);
1070 static const struct file_operations ab8500_gpadc_vbus_v_fops = {
1071 .open = ab8500_gpadc_vbus_v_open,
1073 .llseek = seq_lseek,
1074 .release = single_release,
1075 .owner = THIS_MODULE,
1078 static int ab8500_gpadc_main_charger_c_print(struct seq_file *s, void *p)
1080 int main_charger_c_raw;
1081 int main_charger_c_convert;
1082 struct ab8500_gpadc *gpadc;
1084 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1085 main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C,
1086 avg_sample, trig_edge, trig_timer, conv_type);
1087 main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1088 MAIN_CHARGER_C, main_charger_c_raw);
1090 return seq_printf(s, "%d,0x%X\n",
1091 main_charger_c_convert, main_charger_c_raw);
1094 static int ab8500_gpadc_main_charger_c_open(struct inode *inode,
1097 return single_open(file, ab8500_gpadc_main_charger_c_print,
1101 static const struct file_operations ab8500_gpadc_main_charger_c_fops = {
1102 .open = ab8500_gpadc_main_charger_c_open,
1104 .llseek = seq_lseek,
1105 .release = single_release,
1106 .owner = THIS_MODULE,
1109 static int ab8500_gpadc_usb_charger_c_print(struct seq_file *s, void *p)
1111 int usb_charger_c_raw;
1112 int usb_charger_c_convert;
1113 struct ab8500_gpadc *gpadc;
1115 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1116 usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C,
1117 avg_sample, trig_edge, trig_timer, conv_type);
1118 usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1119 USB_CHARGER_C, usb_charger_c_raw);
1121 return seq_printf(s, "%d,0x%X\n",
1122 usb_charger_c_convert, usb_charger_c_raw);
1125 static int ab8500_gpadc_usb_charger_c_open(struct inode *inode,
1128 return single_open(file, ab8500_gpadc_usb_charger_c_print,
1132 static const struct file_operations ab8500_gpadc_usb_charger_c_fops = {
1133 .open = ab8500_gpadc_usb_charger_c_open,
1135 .llseek = seq_lseek,
1136 .release = single_release,
1137 .owner = THIS_MODULE,
1140 static int ab8500_gpadc_bk_bat_v_print(struct seq_file *s, void *p)
1143 int bk_bat_v_convert;
1144 struct ab8500_gpadc *gpadc;
1146 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1147 bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V,
1148 avg_sample, trig_edge, trig_timer, conv_type);
1149 bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1150 BK_BAT_V, bk_bat_v_raw);
1152 return seq_printf(s, "%d,0x%X\n",
1153 bk_bat_v_convert, bk_bat_v_raw);
1156 static int ab8500_gpadc_bk_bat_v_open(struct inode *inode, struct file *file)
1158 return single_open(file, ab8500_gpadc_bk_bat_v_print, inode->i_private);
1161 static const struct file_operations ab8500_gpadc_bk_bat_v_fops = {
1162 .open = ab8500_gpadc_bk_bat_v_open,
1164 .llseek = seq_lseek,
1165 .release = single_release,
1166 .owner = THIS_MODULE,
1169 static int ab8500_gpadc_die_temp_print(struct seq_file *s, void *p)
1172 int die_temp_convert;
1173 struct ab8500_gpadc *gpadc;
1175 gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1176 die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP,
1177 avg_sample, trig_edge, trig_timer, conv_type);
1178 die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP,
1181 return seq_printf(s, "%d,0x%X\n",
1182 die_temp_convert, die_temp_raw);
1185 static int ab8500_gpadc_die_temp_open(struct inode *inode, struct file *file)
1187 return single_open(file, ab8500_gpadc_die_temp_print, inode->i_private);
1190 static const struct file_operations ab8500_gpadc_die_temp_fops = {
1191 .open = ab8500_gpadc_die_temp_open,
1193 .llseek = seq_lseek,
1194 .release = single_release,
1195 .owner = THIS_MODULE,
1198 static int ab8500_gpadc_avg_sample_print(struct seq_file *s, void *p)
1200 return seq_printf(s, "%d\n", avg_sample);
1203 static int ab8500_gpadc_avg_sample_open(struct inode *inode, struct file *file)
1205 return single_open(file, ab8500_gpadc_avg_sample_print,
1209 static ssize_t ab8500_gpadc_avg_sample_write(struct file *file,
1210 const char __user *user_buf,
1211 size_t count, loff_t *ppos)
1213 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1216 unsigned long user_avg_sample;
1219 /* Get userspace string and assure termination */
1220 buf_size = min(count, (sizeof(buf) - 1));
1221 if (copy_from_user(buf, user_buf, buf_size))
1225 err = strict_strtoul(buf, 0, &user_avg_sample);
1228 if ((user_avg_sample == SAMPLE_1) || (user_avg_sample == SAMPLE_4)
1229 || (user_avg_sample == SAMPLE_8)
1230 || (user_avg_sample == SAMPLE_16)) {
1231 avg_sample = (u8) user_avg_sample;
1233 dev_err(dev, "debugfs error input: "
1234 "should be egal to 1, 4, 8 or 16\n");
1240 static const struct file_operations ab8500_gpadc_avg_sample_fops = {
1241 .open = ab8500_gpadc_avg_sample_open,
1243 .write = ab8500_gpadc_avg_sample_write,
1244 .llseek = seq_lseek,
1245 .release = single_release,
1246 .owner = THIS_MODULE,
1249 static int ab8500_gpadc_trig_edge_print(struct seq_file *s, void *p)
1251 return seq_printf(s, "%d\n", trig_edge);
1254 static int ab8500_gpadc_trig_edge_open(struct inode *inode, struct file *file)
1256 return single_open(file, ab8500_gpadc_trig_edge_print,
1260 static ssize_t ab8500_gpadc_trig_edge_write(struct file *file,
1261 const char __user *user_buf,
1262 size_t count, loff_t *ppos)
1264 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1267 unsigned long user_trig_edge;
1270 /* Get userspace string and assure termination */
1271 buf_size = min(count, (sizeof(buf) - 1));
1272 if (copy_from_user(buf, user_buf, buf_size))
1276 err = strict_strtoul(buf, 0, &user_trig_edge);
1279 if ((user_trig_edge == RISING_EDGE)
1280 || (user_trig_edge == FALLING_EDGE)) {
1281 trig_edge = (u8) user_trig_edge;
1283 dev_err(dev, "Wrong input:\n"
1284 "Enter 0. Rising edge\n"
1285 "Enter 1. Falling edge\n");
1291 static const struct file_operations ab8500_gpadc_trig_edge_fops = {
1292 .open = ab8500_gpadc_trig_edge_open,
1294 .write = ab8500_gpadc_trig_edge_write,
1295 .llseek = seq_lseek,
1296 .release = single_release,
1297 .owner = THIS_MODULE,
1300 static int ab8500_gpadc_trig_timer_print(struct seq_file *s, void *p)
1302 return seq_printf(s, "%d\n", trig_timer);
1305 static int ab8500_gpadc_trig_timer_open(struct inode *inode, struct file *file)
1307 return single_open(file, ab8500_gpadc_trig_timer_print,
1311 static ssize_t ab8500_gpadc_trig_timer_write(struct file *file,
1312 const char __user *user_buf,
1313 size_t count, loff_t *ppos)
1315 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1318 unsigned long user_trig_timer;
1321 /* Get userspace string and assure termination */
1322 buf_size = min(count, (sizeof(buf) - 1));
1323 if (copy_from_user(buf, user_buf, buf_size))
1327 err = strict_strtoul(buf, 0, &user_trig_timer);
1330 if ((user_trig_timer >= 0) && (user_trig_timer <= 255)) {
1331 trig_timer = (u8) user_trig_timer;
1333 dev_err(dev, "debugfs error input: "
1334 "should be beetween 0 to 255\n");
1340 static const struct file_operations ab8500_gpadc_trig_timer_fops = {
1341 .open = ab8500_gpadc_trig_timer_open,
1343 .write = ab8500_gpadc_trig_timer_write,
1344 .llseek = seq_lseek,
1345 .release = single_release,
1346 .owner = THIS_MODULE,
1349 static int ab8500_gpadc_conv_type_print(struct seq_file *s, void *p)
1351 return seq_printf(s, "%d\n", conv_type);
1354 static int ab8500_gpadc_conv_type_open(struct inode *inode, struct file *file)
1356 return single_open(file, ab8500_gpadc_conv_type_print,
1360 static ssize_t ab8500_gpadc_conv_type_write(struct file *file,
1361 const char __user *user_buf,
1362 size_t count, loff_t *ppos)
1364 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1367 unsigned long user_conv_type;
1370 /* Get userspace string and assure termination */
1371 buf_size = min(count, (sizeof(buf) - 1));
1372 if (copy_from_user(buf, user_buf, buf_size))
1376 err = strict_strtoul(buf, 0, &user_conv_type);
1379 if ((user_conv_type == ADC_SW)
1380 || (user_conv_type == ADC_HW)) {
1381 conv_type = (u8) user_conv_type;
1383 dev_err(dev, "Wrong input:\n"
1384 "Enter 0. ADC SW conversion\n"
1385 "Enter 1. ADC HW conversion\n");
1391 static const struct file_operations ab8500_gpadc_conv_type_fops = {
1392 .open = ab8500_gpadc_conv_type_open,
1394 .write = ab8500_gpadc_conv_type_write,
1395 .llseek = seq_lseek,
1396 .release = single_release,
1397 .owner = THIS_MODULE,
1401 * return length of an ASCII numerical value, 0 is string is not a
1403 * string shall start at value 1st char.
1404 * string can be tailed with \0 or space or newline chars only.
1405 * value can be decimal or hexadecimal (prefixed 0x or 0X).
1407 static int strval_len(char *b)
1410 if ((*s == '0') && ((*(s+1) == 'x') || (*(s+1) == 'X'))) {
1412 for (; *s && (*s != ' ') && (*s != '\n'); s++) {
1419 for (; *s && (*s != ' ') && (*s != '\n'); s++) {
1428 * parse hwreg input data.
1429 * update global hwreg_cfg only if input data syntax is ok.
1431 static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg,
1434 uint write, val = 0;
1437 struct hwreg_cfg loc = {
1438 .bank = 0, /* default: invalid phys addr */
1439 .addr = 0, /* default: invalid phys addr */
1440 .fmt = 0, /* default: 32bit access, hex output */
1441 .mask = 0xFFFFFFFF, /* default: no mask */
1442 .shift = 0, /* default: no bit shift */
1445 /* read or write ? */
1446 if (!strncmp(b, "read ", 5)) {
1449 } else if (!strncmp(b, "write ", 6)) {
1455 /* OPTIONS -l|-w|-b -s -m -o */
1456 while ((*b == ' ') || (*b == '-')) {
1457 if (*(b-1) != ' ') {
1461 if ((!strncmp(b, "-d ", 3)) ||
1462 (!strncmp(b, "-dec ", 5))) {
1463 b += (*(b+2) == ' ') ? 3 : 5;
1465 } else if ((!strncmp(b, "-h ", 3)) ||
1466 (!strncmp(b, "-hex ", 5))) {
1467 b += (*(b+2) == ' ') ? 3 : 5;
1469 } else if ((!strncmp(b, "-m ", 3)) ||
1470 (!strncmp(b, "-mask ", 6))) {
1471 b += (*(b+2) == ' ') ? 3 : 6;
1472 if (strval_len(b) == 0)
1474 loc.mask = simple_strtoul(b, &b, 0);
1475 } else if ((!strncmp(b, "-s ", 3)) ||
1476 (!strncmp(b, "-shift ", 7))) {
1477 b += (*(b+2) == ' ') ? 3 : 7;
1478 if (strval_len(b) == 0)
1480 loc.shift = simple_strtol(b, &b, 0);
1485 /* get arg BANK and ADDRESS */
1486 if (strval_len(b) == 0)
1488 loc.bank = simple_strtoul(b, &b, 0);
1491 if (strval_len(b) == 0)
1493 loc.addr = simple_strtoul(b, &b, 0);
1498 if (strval_len(b) == 0)
1500 val = simple_strtoul(b, &b, 0);
1503 /* args are ok, update target cfg (mainly for read) */
1506 #ifdef ABB_HWREG_DEBUG
1507 pr_warn("HWREG request: %s, %s, addr=0x%08X, mask=0x%X, shift=%d"
1508 "value=0x%X\n", (write) ? "write" : "read",
1509 REG_FMT_DEC(cfg) ? "decimal" : "hexa",
1510 cfg->addr, cfg->mask, cfg->shift, val);
1516 ret = abx500_get_register_interruptible(dev,
1517 (u8)cfg->bank, (u8)cfg->addr, ®value);
1519 dev_err(dev, "abx500_get_reg fail %d, %d\n",
1524 if (cfg->shift >= 0) {
1525 regvalue &= ~(cfg->mask << (cfg->shift));
1526 val = (val & cfg->mask) << (cfg->shift);
1528 regvalue &= ~(cfg->mask >> (-cfg->shift));
1529 val = (val & cfg->mask) >> (-cfg->shift);
1531 val = val | regvalue;
1533 ret = abx500_set_register_interruptible(dev,
1534 (u8)cfg->bank, (u8)cfg->addr, (u8)val);
1536 pr_err("abx500_set_reg failed %d, %d", ret, __LINE__);
1543 static ssize_t ab8500_hwreg_write(struct file *file,
1544 const char __user *user_buf, size_t count, loff_t *ppos)
1546 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1550 /* Get userspace string and assure termination */
1551 buf_size = min(count, (sizeof(buf)-1));
1552 if (copy_from_user(buf, user_buf, buf_size))
1556 /* get args and process */
1557 ret = hwreg_common_write(buf, &hwreg_cfg, dev);
1558 return (ret) ? ret : buf_size;
1562 * - irq subscribe/unsubscribe stuff
1564 static int ab8500_subscribe_unsubscribe_print(struct seq_file *s, void *p)
1566 seq_printf(s, "%d\n", irq_first);
1571 static int ab8500_subscribe_unsubscribe_open(struct inode *inode,
1574 return single_open(file, ab8500_subscribe_unsubscribe_print,
1579 * Userspace should use poll() on this file. When an event occur
1580 * the blocking poll will be released.
1582 static ssize_t show_irq(struct device *dev,
1583 struct device_attribute *attr, char *buf)
1586 unsigned int irq_index;
1589 err = strict_strtoul(attr->attr.name, 0, &name);
1593 irq_index = name - irq_first;
1594 if (irq_index >= num_irqs)
1597 return sprintf(buf, "%u\n", irq_count[irq_index]);
1600 static ssize_t ab8500_subscribe_write(struct file *file,
1601 const char __user *user_buf,
1602 size_t count, loff_t *ppos)
1604 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1607 unsigned long user_val;
1609 unsigned int irq_index;
1611 /* Get userspace string and assure termination */
1612 buf_size = min(count, (sizeof(buf)-1));
1613 if (copy_from_user(buf, user_buf, buf_size))
1617 err = strict_strtoul(buf, 0, &user_val);
1620 if (user_val < irq_first) {
1621 dev_err(dev, "debugfs error input < %d\n", irq_first);
1624 if (user_val > irq_last) {
1625 dev_err(dev, "debugfs error input > %d\n", irq_last);
1629 irq_index = user_val - irq_first;
1630 if (irq_index >= num_irqs)
1634 * This will create a sysfs file named <irq-nr> which userspace can
1635 * use to select or poll and get the AB8500 events
1637 dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute),
1639 event_name[irq_index] = kmalloc(buf_size, GFP_KERNEL);
1640 sprintf(event_name[irq_index], "%lu", user_val);
1641 dev_attr[irq_index]->show = show_irq;
1642 dev_attr[irq_index]->store = NULL;
1643 dev_attr[irq_index]->attr.name = event_name[irq_index];
1644 dev_attr[irq_index]->attr.mode = S_IRUGO;
1645 err = sysfs_create_file(&dev->kobj, &dev_attr[irq_index]->attr);
1647 printk(KERN_ERR "sysfs_create_file failed %d\n", err);
1651 err = request_threaded_irq(user_val, NULL, ab8500_debug_handler,
1652 IRQF_SHARED | IRQF_NO_SUSPEND,
1653 "ab8500-debug", &dev->kobj);
1655 printk(KERN_ERR "request_threaded_irq failed %d, %lu\n",
1657 sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr);
1664 static ssize_t ab8500_unsubscribe_write(struct file *file,
1665 const char __user *user_buf,
1666 size_t count, loff_t *ppos)
1668 struct device *dev = ((struct seq_file *)(file->private_data))->private;
1671 unsigned long user_val;
1673 unsigned int irq_index;
1675 /* Get userspace string and assure termination */
1676 buf_size = min(count, (sizeof(buf)-1));
1677 if (copy_from_user(buf, user_buf, buf_size))
1681 err = strict_strtoul(buf, 0, &user_val);
1684 if (user_val < irq_first) {
1685 dev_err(dev, "debugfs error input < %d\n", irq_first);
1688 if (user_val > irq_last) {
1689 dev_err(dev, "debugfs error input > %d\n", irq_last);
1693 irq_index = user_val - irq_first;
1694 if (irq_index >= num_irqs)
1697 /* Set irq count to 0 when unsubscribe */
1698 irq_count[irq_index] = 0;
1700 if (dev_attr[irq_index])
1701 sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr);
1704 free_irq(user_val, &dev->kobj);
1705 kfree(event_name[irq_index]);
1706 kfree(dev_attr[irq_index]);
1712 * - several deubgfs nodes fops
1715 static const struct file_operations ab8500_bank_fops = {
1716 .open = ab8500_bank_open,
1717 .write = ab8500_bank_write,
1719 .llseek = seq_lseek,
1720 .release = single_release,
1721 .owner = THIS_MODULE,
1724 static const struct file_operations ab8500_address_fops = {
1725 .open = ab8500_address_open,
1726 .write = ab8500_address_write,
1728 .llseek = seq_lseek,
1729 .release = single_release,
1730 .owner = THIS_MODULE,
1733 static const struct file_operations ab8500_val_fops = {
1734 .open = ab8500_val_open,
1735 .write = ab8500_val_write,
1737 .llseek = seq_lseek,
1738 .release = single_release,
1739 .owner = THIS_MODULE,
1742 static const struct file_operations ab8500_interrupts_fops = {
1743 .open = ab8500_interrupts_open,
1745 .llseek = seq_lseek,
1746 .release = single_release,
1747 .owner = THIS_MODULE,
1750 static const struct file_operations ab8500_subscribe_fops = {
1751 .open = ab8500_subscribe_unsubscribe_open,
1752 .write = ab8500_subscribe_write,
1754 .llseek = seq_lseek,
1755 .release = single_release,
1756 .owner = THIS_MODULE,
1759 static const struct file_operations ab8500_unsubscribe_fops = {
1760 .open = ab8500_subscribe_unsubscribe_open,
1761 .write = ab8500_unsubscribe_write,
1763 .llseek = seq_lseek,
1764 .release = single_release,
1765 .owner = THIS_MODULE,
1768 static const struct file_operations ab8500_hwreg_fops = {
1769 .open = ab8500_hwreg_open,
1770 .write = ab8500_hwreg_write,
1772 .llseek = seq_lseek,
1773 .release = single_release,
1774 .owner = THIS_MODULE,
1777 static struct dentry *ab8500_dir;
1778 static struct dentry *ab8500_gpadc_dir;
1780 static int ab8500_debug_probe(struct platform_device *plf)
1782 struct dentry *file;
1784 struct ab8500 *ab8500;
1785 debug_bank = AB8500_MISC;
1786 debug_address = AB8500_REV_REG & 0x00FF;
1788 ab8500 = dev_get_drvdata(plf->dev.parent);
1789 num_irqs = ab8500->mask_size;
1791 irq_count = kzalloc(sizeof(*irq_count)*num_irqs, GFP_KERNEL);
1795 dev_attr = kzalloc(sizeof(*dev_attr)*num_irqs,GFP_KERNEL);
1797 goto out_freeirq_count;
1799 event_name = kzalloc(sizeof(*event_name)*num_irqs, GFP_KERNEL);
1801 goto out_freedev_attr;
1803 irq_first = platform_get_irq_byname(plf, "IRQ_FIRST");
1804 if (irq_first < 0) {
1805 dev_err(&plf->dev, "First irq not found, err %d\n",
1808 goto out_freeevent_name;
1811 irq_last = platform_get_irq_byname(plf, "IRQ_LAST");
1813 dev_err(&plf->dev, "Last irq not found, err %d\n",
1816 goto out_freeevent_name;
1819 ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
1823 ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING,
1825 if (!ab8500_gpadc_dir)
1828 file = debugfs_create_file("all-bank-registers", S_IRUGO,
1829 ab8500_dir, &plf->dev, &ab8500_registers_fops);
1833 file = debugfs_create_file("all-banks", S_IRUGO,
1834 ab8500_dir, &plf->dev, &ab8500_all_banks_fops);
1838 file = debugfs_create_file("register-bank", (S_IRUGO | S_IWUSR),
1839 ab8500_dir, &plf->dev, &ab8500_bank_fops);
1843 file = debugfs_create_file("register-address", (S_IRUGO | S_IWUSR),
1844 ab8500_dir, &plf->dev, &ab8500_address_fops);
1848 file = debugfs_create_file("register-value", (S_IRUGO | S_IWUSR),
1849 ab8500_dir, &plf->dev, &ab8500_val_fops);
1853 file = debugfs_create_file("irq-subscribe", (S_IRUGO | S_IWUSR),
1854 ab8500_dir, &plf->dev, &ab8500_subscribe_fops);
1858 if (is_ab8500(ab8500))
1859 num_interrupt_lines = AB8500_NR_IRQS;
1860 else if (is_ab8505(ab8500))
1861 num_interrupt_lines = AB8505_NR_IRQS;
1862 else if (is_ab9540(ab8500))
1863 num_interrupt_lines = AB9540_NR_IRQS;
1865 file = debugfs_create_file("interrupts", (S_IRUGO),
1866 ab8500_dir, &plf->dev, &ab8500_interrupts_fops);
1870 file = debugfs_create_file("irq-unsubscribe", (S_IRUGO | S_IWUSR),
1871 ab8500_dir, &plf->dev, &ab8500_unsubscribe_fops);
1875 file = debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR),
1876 ab8500_dir, &plf->dev, &ab8500_hwreg_fops);
1880 file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR),
1881 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bat_ctrl_fops);
1885 file = debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR),
1886 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_btemp_ball_fops);
1890 file = debugfs_create_file("main_charger_v", (S_IRUGO | S_IWUSR),
1891 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_charger_v_fops);
1895 file = debugfs_create_file("acc_detect1", (S_IRUGO | S_IWUSR),
1896 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_acc_detect1_fops);
1900 file = debugfs_create_file("acc_detect2", (S_IRUGO | S_IWUSR),
1901 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_acc_detect2_fops);
1905 file = debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR),
1906 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux1_fops);
1910 file = debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR),
1911 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux2_fops);
1915 file = debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR),
1916 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_bat_v_fops);
1920 file = debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR),
1921 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_vbus_v_fops);
1925 file = debugfs_create_file("main_charger_c", (S_IRUGO | S_IWUSR),
1926 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_charger_c_fops);
1930 file = debugfs_create_file("usb_charger_c", (S_IRUGO | S_IWUSR),
1931 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_usb_charger_c_fops);
1935 file = debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR),
1936 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bk_bat_v_fops);
1940 file = debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR),
1941 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_die_temp_fops);
1945 file = debugfs_create_file("avg_sample", (S_IRUGO | S_IWUGO),
1946 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_avg_sample_fops);
1950 file = debugfs_create_file("trig_edge", (S_IRUGO | S_IWUGO),
1951 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_trig_edge_fops);
1955 file = debugfs_create_file("trig_timer", (S_IRUGO | S_IWUGO),
1956 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_trig_timer_fops);
1960 file = debugfs_create_file("conv_type", (S_IRUGO | S_IWUGO),
1961 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_conv_type_fops);
1969 debugfs_remove_recursive(ab8500_dir);
1970 dev_err(&plf->dev, "failed to create debugfs entries.\n");
1981 static int ab8500_debug_remove(struct platform_device *plf)
1983 debugfs_remove_recursive(ab8500_dir);
1991 static struct platform_driver ab8500_debug_driver = {
1993 .name = "ab8500-debug",
1994 .owner = THIS_MODULE,
1996 .probe = ab8500_debug_probe,
1997 .remove = ab8500_debug_remove
2000 static int __init ab8500_debug_init(void)
2002 return platform_driver_register(&ab8500_debug_driver);
2005 static void __exit ab8500_debug_exit(void)
2007 platform_driver_unregister(&ab8500_debug_driver);
2009 subsys_initcall(ab8500_debug_init);
2010 module_exit(ab8500_debug_exit);
2012 MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
2013 MODULE_DESCRIPTION("AB8500 DEBUG");
2014 MODULE_LICENSE("GPL v2");