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>
83 #include <linux/irq.h>
85 #include <linux/mfd/abx500.h>
86 #include <linux/mfd/abx500/ab8500.h>
87 #include <linux/mfd/abx500/ab8500-gpadc.h>
89 #ifdef CONFIG_DEBUG_FS
90 #include <linux/string.h>
91 #include <linux/ctype.h>
94 static u32 debug_bank
;
95 static u32 debug_address
;
97 static int irq_ab8500
;
100 static u32
*irq_count
;
103 static struct device_attribute
**dev_attr
;
104 static char **event_name
;
106 static u8 avg_sample
= SAMPLE_16
;
107 static u8 trig_edge
= RISING_EDGE
;
108 static u8 conv_type
= ADC_SW
;
109 static u8 trig_timer
;
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
117 struct ab8500_reg_range
{
124 * struct ab8500_prcmu_ranges
125 * @num_ranges: the number of ranges in the list
126 * @bankid: bank identifier
127 * @range: the list of register ranges
129 struct ab8500_prcmu_ranges
{
132 const struct ab8500_reg_range
*range
;
135 /* hwreg- "mask" and "shift" entries ressources */
137 u32 bank
; /* target bank */
138 unsigned long addr
; /* target address */
139 uint fmt
; /* format */
140 unsigned long mask
; /* read/write mask, applied before any bit shift */
141 long shift
; /* bit shift (read:right shift, write:left shift */
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))
147 static struct hwreg_cfg hwreg_cfg
= {
148 .addr
= 0, /* default: invalid phys addr */
149 .fmt
= 0, /* default: 32bit access, hex output */
150 .mask
= 0xFFFFFFFF, /* default: no mask */
151 .shift
= 0, /* default: no bit shift */
154 #define AB8500_NAME_STRING "ab8500"
155 #define AB8500_ADC_NAME_STRING "gpadc"
156 #define AB8500_NUM_BANKS AB8500_DEBUG_FIELD_LAST
158 #define AB8500_REV_REG 0x80
160 static struct ab8500_prcmu_ranges
*debug_ranges
;
162 static struct ab8500_prcmu_ranges ab8500_debug_ranges
[AB8500_NUM_BANKS
] = {
163 [AB8500_M_FSM_RANK
] = {
167 [AB8500_SYS_CTRL1_BLOCK
] = {
169 .range
= (struct ab8500_reg_range
[]) {
184 [AB8500_SYS_CTRL2_BLOCK
] = {
186 .range
= (struct ab8500_reg_range
[]) {
205 [AB8500_REGU_CTRL1
] = {
207 .range
= (struct ab8500_reg_range
[]) {
222 [AB8500_REGU_CTRL2
] = {
224 .range
= (struct ab8500_reg_range
[]) {
246 * 0x80-0x8B are SIM registers and should
247 * not be accessed from here
253 .range
= (struct ab8500_reg_range
[]) {
266 .range
= (struct ab8500_reg_range
[]) {
309 [AB8500_ECI_AV_ACC
] = {
311 .range
= (struct ab8500_reg_range
[]) {
318 [AB8500_RESERVED
] = {
324 .range
= (struct ab8500_reg_range
[]) {
333 .range
= (struct ab8500_reg_range
[]) {
372 [AB8500_GAS_GAUGE
] = {
374 .range
= (struct ab8500_reg_range
[]) {
391 .range
= (struct ab8500_reg_range
[]) {
398 [AB8500_INTERRUPT
] = {
404 .range
= (struct ab8500_reg_range
[]) {
413 .range
= (struct ab8500_reg_range
[]) {
448 [AB8500_DEVELOPMENT
] = {
450 .range
= (struct ab8500_reg_range
[]) {
459 .range
= (struct ab8500_reg_range
[]) {
466 [AB8500_PROD_TEST
] = {
470 [AB8500_STE_TEST
] = {
474 [AB8500_OTP_EMUL
] = {
476 .range
= (struct ab8500_reg_range
[]) {
485 static struct ab8500_prcmu_ranges ab8505_debug_ranges
[AB8500_NUM_BANKS
] = {
490 [AB8500_SYS_CTRL1_BLOCK
] = {
492 .range
= (struct ab8500_reg_range
[]) {
515 [AB8500_SYS_CTRL2_BLOCK
] = {
517 .range
= (struct ab8500_reg_range
[]) {
540 [AB8500_REGU_CTRL1
] = {
542 .range
= (struct ab8500_reg_range
[]) {
557 [AB8500_REGU_CTRL2
] = {
559 .range
= (struct ab8500_reg_range
[]) {
585 * 0x80-0x8B are SIM registers and should
586 * not be accessed from here
592 .range
= (struct ab8500_reg_range
[]) {
615 [AB8500_ECI_AV_ACC
] = {
617 .range
= (struct ab8500_reg_range
[]) {
624 [AB8500_RESERVED
] = {
630 .range
= (struct ab8500_reg_range
[]) {
639 .range
= (struct ab8500_reg_range
[]) {
678 [AB8500_GAS_GAUGE
] = {
680 .range
= (struct ab8500_reg_range
[]) {
697 .range
= (struct ab8500_reg_range
[]) {
704 [AB8500_INTERRUPT
] = {
706 .range
= (struct ab8500_reg_range
[]) {
731 /* Latch registers should not be read here */
752 /* LatchHier registers should not be read here */
757 .range
= (struct ab8500_reg_range
[]) {
770 .range
= (struct ab8500_reg_range
[]) {
805 [AB8500_DEVELOPMENT
] = {
807 .range
= (struct ab8500_reg_range
[]) {
820 .range
= (struct ab8500_reg_range
[]) {
827 [AB8500_PROD_TEST
] = {
831 [AB8500_STE_TEST
] = {
835 [AB8500_OTP_EMUL
] = {
837 .range
= (struct ab8500_reg_range
[]) {
846 static struct ab8500_prcmu_ranges ab8540_debug_ranges
[AB8500_NUM_BANKS
] = {
847 [AB8500_M_FSM_RANK
] = {
849 .range
= (struct ab8500_reg_range
[]) {
856 [AB8500_SYS_CTRL1_BLOCK
] = {
858 .range
= (struct ab8500_reg_range
[]) {
885 [AB8500_SYS_CTRL2_BLOCK
] = {
887 .range
= (struct ab8500_reg_range
[]) {
910 [AB8500_REGU_CTRL1
] = {
912 .range
= (struct ab8500_reg_range
[]) {
931 [AB8500_REGU_CTRL2
] = {
933 .range
= (struct ab8500_reg_range
[]) {
970 .range
= (struct ab8500_reg_range
[]) {
991 .range
= (struct ab8500_reg_range
[]) {
1010 [AB8500_ECI_AV_ACC
] = {
1012 .range
= (struct ab8500_reg_range
[]) {
1023 [AB8500_RESERVED
] = {
1029 .range
= (struct ab8500_reg_range
[]) {
1048 [AB8500_CHARGER
] = {
1050 .range
= (struct ab8500_reg_range
[]) {
1093 [AB8500_GAS_GAUGE
] = {
1095 .range
= (struct ab8500_reg_range
[]) {
1112 .range
= (struct ab8500_reg_range
[]) {
1119 [AB8500_INTERRUPT
] = {
1121 .range
= (struct ab8500_reg_range
[]) {
1134 /* Latch registers should not be read here */
1147 /* LatchHier registers should not be read here */
1152 .range
= (struct ab8500_reg_range
[]) {
1169 .range
= (struct ab8500_reg_range
[]) {
1208 [AB8500_DEVELOPMENT
] = {
1210 .range
= (struct ab8500_reg_range
[]) {
1227 .range
= (struct ab8500_reg_range
[]) {
1242 [AB8500_PROD_TEST
] = {
1246 [AB8500_STE_TEST
] = {
1250 [AB8500_OTP_EMUL
] = {
1252 .range
= (struct ab8500_reg_range
[]) {
1262 static irqreturn_t
ab8500_debug_handler(int irq
, void *data
)
1265 struct kobject
*kobj
= (struct kobject
*)data
;
1266 unsigned int irq_abb
= irq
- irq_first
;
1268 if (irq_abb
< num_irqs
)
1269 irq_count
[irq_abb
]++;
1271 * This makes it possible to use poll for events (POLLPRI | POLLERR)
1272 * from userspace on sysfs file named <irq-nr>
1274 sprintf(buf
, "%d", irq
);
1275 sysfs_notify(kobj
, NULL
, buf
);
1280 /* Prints to seq_file or log_buf */
1281 static int ab8500_registers_print(struct device
*dev
, u32 bank
,
1286 for (i
= 0; i
< debug_ranges
[bank
].num_ranges
; i
++) {
1289 for (reg
= debug_ranges
[bank
].range
[i
].first
;
1290 reg
<= debug_ranges
[bank
].range
[i
].last
;
1295 err
= abx500_get_register_interruptible(dev
,
1296 (u8
)bank
, (u8
)reg
, &value
);
1298 dev_err(dev
, "ab->read fail %d\n", err
);
1303 seq_printf(s
, " [0x%02X/0x%02X]: 0x%02X\n",
1306 * Error is not returned here since
1307 * the output is wanted in any case
1309 if (seq_has_overflowed(s
))
1312 dev_info(dev
, " [0x%02X/0x%02X]: 0x%02X\n",
1321 static int ab8500_print_bank_registers(struct seq_file
*s
, void *p
)
1323 struct device
*dev
= s
->private;
1324 u32 bank
= debug_bank
;
1326 seq_puts(s
, AB8500_NAME_STRING
" register values:\n");
1328 seq_printf(s
, " bank 0x%02X:\n", bank
);
1330 return ab8500_registers_print(dev
, bank
, s
);
1333 static int ab8500_registers_open(struct inode
*inode
, struct file
*file
)
1335 return single_open(file
, ab8500_print_bank_registers
, inode
->i_private
);
1338 static const struct file_operations ab8500_registers_fops
= {
1339 .open
= ab8500_registers_open
,
1341 .llseek
= seq_lseek
,
1342 .release
= single_release
,
1343 .owner
= THIS_MODULE
,
1346 static int ab8500_print_all_banks(struct seq_file
*s
, void *p
)
1348 struct device
*dev
= s
->private;
1351 seq_puts(s
, AB8500_NAME_STRING
" register values:\n");
1353 for (i
= 0; i
< AB8500_NUM_BANKS
; i
++) {
1356 seq_printf(s
, " bank 0x%02X:\n", i
);
1357 err
= ab8500_registers_print(dev
, i
, s
);
1364 /* Dump registers to kernel log */
1365 void ab8500_dump_all_banks(struct device
*dev
)
1369 dev_info(dev
, "ab8500 register values:\n");
1371 for (i
= 1; i
< AB8500_NUM_BANKS
; i
++) {
1372 dev_info(dev
, " bank 0x%02X:\n", i
);
1373 ab8500_registers_print(dev
, i
, NULL
);
1377 static int ab8500_all_banks_open(struct inode
*inode
, struct file
*file
)
1382 err
= single_open(file
, ab8500_print_all_banks
, inode
->i_private
);
1384 /* Default buf size in seq_read is not enough */
1385 s
= (struct seq_file
*)file
->private_data
;
1386 s
->size
= (PAGE_SIZE
* 2);
1387 s
->buf
= kmalloc(s
->size
, GFP_KERNEL
);
1389 single_release(inode
, file
);
1396 static const struct file_operations ab8500_all_banks_fops
= {
1397 .open
= ab8500_all_banks_open
,
1399 .llseek
= seq_lseek
,
1400 .release
= single_release
,
1401 .owner
= THIS_MODULE
,
1404 static int ab8500_bank_print(struct seq_file
*s
, void *p
)
1406 seq_printf(s
, "0x%02X\n", debug_bank
);
1410 static int ab8500_bank_open(struct inode
*inode
, struct file
*file
)
1412 return single_open(file
, ab8500_bank_print
, inode
->i_private
);
1415 static ssize_t
ab8500_bank_write(struct file
*file
,
1416 const char __user
*user_buf
,
1417 size_t count
, loff_t
*ppos
)
1419 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1420 unsigned long user_bank
;
1423 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_bank
);
1427 if (user_bank
>= AB8500_NUM_BANKS
) {
1428 dev_err(dev
, "debugfs error input > number of banks\n");
1432 debug_bank
= user_bank
;
1437 static int ab8500_address_print(struct seq_file
*s
, void *p
)
1439 seq_printf(s
, "0x%02X\n", debug_address
);
1443 static int ab8500_address_open(struct inode
*inode
, struct file
*file
)
1445 return single_open(file
, ab8500_address_print
, inode
->i_private
);
1448 static ssize_t
ab8500_address_write(struct file
*file
,
1449 const char __user
*user_buf
,
1450 size_t count
, loff_t
*ppos
)
1452 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1453 unsigned long user_address
;
1456 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_address
);
1460 if (user_address
> 0xff) {
1461 dev_err(dev
, "debugfs error input > 0xff\n");
1464 debug_address
= user_address
;
1469 static int ab8500_val_print(struct seq_file
*s
, void *p
)
1471 struct device
*dev
= s
->private;
1475 ret
= abx500_get_register_interruptible(dev
,
1476 (u8
)debug_bank
, (u8
)debug_address
, ®value
);
1478 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
1482 seq_printf(s
, "0x%02X\n", regvalue
);
1487 static int ab8500_val_open(struct inode
*inode
, struct file
*file
)
1489 return single_open(file
, ab8500_val_print
, inode
->i_private
);
1492 static ssize_t
ab8500_val_write(struct file
*file
,
1493 const char __user
*user_buf
,
1494 size_t count
, loff_t
*ppos
)
1496 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1497 unsigned long user_val
;
1500 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
1504 if (user_val
> 0xff) {
1505 dev_err(dev
, "debugfs error input > 0xff\n");
1508 err
= abx500_set_register_interruptible(dev
,
1509 (u8
)debug_bank
, debug_address
, (u8
)user_val
);
1511 pr_err("abx500_set_reg failed %d, %d", err
, __LINE__
);
1521 static u32 num_interrupts
[AB8500_MAX_NR_IRQS
];
1522 static u32 num_wake_interrupts
[AB8500_MAX_NR_IRQS
];
1523 static int num_interrupt_lines
;
1525 void ab8500_debug_register_interrupt(int line
)
1527 if (line
< num_interrupt_lines
)
1528 num_interrupts
[line
]++;
1531 static int ab8500_interrupts_print(struct seq_file
*s
, void *p
)
1535 seq_puts(s
, "name: number: number of: wake:\n");
1537 for (line
= 0; line
< num_interrupt_lines
; line
++) {
1538 struct irq_desc
*desc
= irq_to_desc(line
+ irq_first
);
1540 seq_printf(s
, "%3i: %6i %4i",
1542 num_interrupts
[line
],
1543 num_wake_interrupts
[line
]);
1545 if (desc
&& desc
->name
)
1546 seq_printf(s
, "-%-8s", desc
->name
);
1547 if (desc
&& desc
->action
) {
1548 struct irqaction
*action
= desc
->action
;
1550 seq_printf(s
, " %s", action
->name
);
1551 while ((action
= action
->next
) != NULL
)
1552 seq_printf(s
, ", %s", action
->name
);
1560 static int ab8500_interrupts_open(struct inode
*inode
, struct file
*file
)
1562 return single_open(file
, ab8500_interrupts_print
, inode
->i_private
);
1566 * - HWREG DB8500 formated routines
1568 static int ab8500_hwreg_print(struct seq_file
*s
, void *d
)
1570 struct device
*dev
= s
->private;
1574 ret
= abx500_get_register_interruptible(dev
,
1575 (u8
)hwreg_cfg
.bank
, (u8
)hwreg_cfg
.addr
, ®value
);
1577 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
1582 if (hwreg_cfg
.shift
>= 0)
1583 regvalue
>>= hwreg_cfg
.shift
;
1585 regvalue
<<= -hwreg_cfg
.shift
;
1586 regvalue
&= hwreg_cfg
.mask
;
1588 if (REG_FMT_DEC(&hwreg_cfg
))
1589 seq_printf(s
, "%d\n", regvalue
);
1591 seq_printf(s
, "0x%02X\n", regvalue
);
1595 static int ab8500_hwreg_open(struct inode
*inode
, struct file
*file
)
1597 return single_open(file
, ab8500_hwreg_print
, inode
->i_private
);
1600 #define AB8500_SUPPLY_CONTROL_CONFIG_1 0x01
1601 #define AB8500_SUPPLY_CONTROL_REG 0x00
1602 #define AB8500_FIRST_SIM_REG 0x80
1603 #define AB8500_LAST_SIM_REG 0x8B
1604 #define AB8505_LAST_SIM_REG 0x8C
1606 static int ab8500_print_modem_registers(struct seq_file
*s
, void *p
)
1608 struct device
*dev
= s
->private;
1609 struct ab8500
*ab8500
;
1613 u32 bank
= AB8500_REGU_CTRL2
;
1614 u32 last_sim_reg
= AB8500_LAST_SIM_REG
;
1617 ab8500
= dev_get_drvdata(dev
->parent
);
1618 dev_warn(dev
, "WARNING! This operation can interfer with modem side\n"
1619 "and should only be done with care\n");
1621 err
= abx500_get_register_interruptible(dev
,
1622 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
, &orig_value
);
1624 dev_err(dev
, "ab->read fail %d\n", err
);
1627 /* Config 1 will allow APE side to read SIM registers */
1628 err
= abx500_set_register_interruptible(dev
,
1629 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
,
1630 AB8500_SUPPLY_CONTROL_CONFIG_1
);
1632 dev_err(dev
, "ab->write fail %d\n", err
);
1636 seq_printf(s
, " bank 0x%02X:\n", bank
);
1638 if (is_ab9540(ab8500
) || is_ab8505(ab8500
))
1639 last_sim_reg
= AB8505_LAST_SIM_REG
;
1641 for (reg
= AB8500_FIRST_SIM_REG
; reg
<= last_sim_reg
; reg
++) {
1642 err
= abx500_get_register_interruptible(dev
,
1645 dev_err(dev
, "ab->read fail %d\n", err
);
1648 seq_printf(s
, " [0x%02X/0x%02X]: 0x%02X\n", bank
, reg
, value
);
1650 err
= abx500_set_register_interruptible(dev
,
1651 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
, orig_value
);
1653 dev_err(dev
, "ab->write fail %d\n", err
);
1659 static int ab8500_modem_open(struct inode
*inode
, struct file
*file
)
1661 return single_open(file
, ab8500_print_modem_registers
,
1665 static const struct file_operations ab8500_modem_fops
= {
1666 .open
= ab8500_modem_open
,
1668 .llseek
= seq_lseek
,
1669 .release
= single_release
,
1670 .owner
= THIS_MODULE
,
1673 static int ab8500_gpadc_bat_ctrl_print(struct seq_file
*s
, void *p
)
1676 int bat_ctrl_convert
;
1677 struct ab8500_gpadc
*gpadc
;
1679 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1680 bat_ctrl_raw
= ab8500_gpadc_read_raw(gpadc
, BAT_CTRL
,
1681 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1682 bat_ctrl_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1683 BAT_CTRL
, bat_ctrl_raw
);
1685 seq_printf(s
, "%d,0x%X\n", bat_ctrl_convert
, bat_ctrl_raw
);
1690 static int ab8500_gpadc_bat_ctrl_open(struct inode
*inode
, struct file
*file
)
1692 return single_open(file
, ab8500_gpadc_bat_ctrl_print
,
1696 static const struct file_operations ab8500_gpadc_bat_ctrl_fops
= {
1697 .open
= ab8500_gpadc_bat_ctrl_open
,
1699 .llseek
= seq_lseek
,
1700 .release
= single_release
,
1701 .owner
= THIS_MODULE
,
1704 static int ab8500_gpadc_btemp_ball_print(struct seq_file
*s
, void *p
)
1707 int btemp_ball_convert
;
1708 struct ab8500_gpadc
*gpadc
;
1710 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1711 btemp_ball_raw
= ab8500_gpadc_read_raw(gpadc
, BTEMP_BALL
,
1712 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1713 btemp_ball_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, BTEMP_BALL
,
1716 seq_printf(s
, "%d,0x%X\n", btemp_ball_convert
, btemp_ball_raw
);
1721 static int ab8500_gpadc_btemp_ball_open(struct inode
*inode
,
1724 return single_open(file
, ab8500_gpadc_btemp_ball_print
,
1728 static const struct file_operations ab8500_gpadc_btemp_ball_fops
= {
1729 .open
= ab8500_gpadc_btemp_ball_open
,
1731 .llseek
= seq_lseek
,
1732 .release
= single_release
,
1733 .owner
= THIS_MODULE
,
1736 static int ab8500_gpadc_main_charger_v_print(struct seq_file
*s
, void *p
)
1738 int main_charger_v_raw
;
1739 int main_charger_v_convert
;
1740 struct ab8500_gpadc
*gpadc
;
1742 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1743 main_charger_v_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_CHARGER_V
,
1744 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1745 main_charger_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1746 MAIN_CHARGER_V
, main_charger_v_raw
);
1748 seq_printf(s
, "%d,0x%X\n", main_charger_v_convert
, main_charger_v_raw
);
1753 static int ab8500_gpadc_main_charger_v_open(struct inode
*inode
,
1756 return single_open(file
, ab8500_gpadc_main_charger_v_print
,
1760 static const struct file_operations ab8500_gpadc_main_charger_v_fops
= {
1761 .open
= ab8500_gpadc_main_charger_v_open
,
1763 .llseek
= seq_lseek
,
1764 .release
= single_release
,
1765 .owner
= THIS_MODULE
,
1768 static int ab8500_gpadc_acc_detect1_print(struct seq_file
*s
, void *p
)
1770 int acc_detect1_raw
;
1771 int acc_detect1_convert
;
1772 struct ab8500_gpadc
*gpadc
;
1774 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1775 acc_detect1_raw
= ab8500_gpadc_read_raw(gpadc
, ACC_DETECT1
,
1776 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1777 acc_detect1_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ACC_DETECT1
,
1780 seq_printf(s
, "%d,0x%X\n", acc_detect1_convert
, acc_detect1_raw
);
1785 static int ab8500_gpadc_acc_detect1_open(struct inode
*inode
,
1788 return single_open(file
, ab8500_gpadc_acc_detect1_print
,
1792 static const struct file_operations ab8500_gpadc_acc_detect1_fops
= {
1793 .open
= ab8500_gpadc_acc_detect1_open
,
1795 .llseek
= seq_lseek
,
1796 .release
= single_release
,
1797 .owner
= THIS_MODULE
,
1800 static int ab8500_gpadc_acc_detect2_print(struct seq_file
*s
, void *p
)
1802 int acc_detect2_raw
;
1803 int acc_detect2_convert
;
1804 struct ab8500_gpadc
*gpadc
;
1806 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1807 acc_detect2_raw
= ab8500_gpadc_read_raw(gpadc
, ACC_DETECT2
,
1808 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1809 acc_detect2_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1810 ACC_DETECT2
, acc_detect2_raw
);
1812 seq_printf(s
, "%d,0x%X\n", acc_detect2_convert
, acc_detect2_raw
);
1817 static int ab8500_gpadc_acc_detect2_open(struct inode
*inode
,
1820 return single_open(file
, ab8500_gpadc_acc_detect2_print
,
1824 static const struct file_operations ab8500_gpadc_acc_detect2_fops
= {
1825 .open
= ab8500_gpadc_acc_detect2_open
,
1827 .llseek
= seq_lseek
,
1828 .release
= single_release
,
1829 .owner
= THIS_MODULE
,
1832 static int ab8500_gpadc_aux1_print(struct seq_file
*s
, void *p
)
1836 struct ab8500_gpadc
*gpadc
;
1838 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1839 aux1_raw
= ab8500_gpadc_read_raw(gpadc
, ADC_AUX1
,
1840 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1841 aux1_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ADC_AUX1
,
1844 seq_printf(s
, "%d,0x%X\n", aux1_convert
, aux1_raw
);
1849 static int ab8500_gpadc_aux1_open(struct inode
*inode
, struct file
*file
)
1851 return single_open(file
, ab8500_gpadc_aux1_print
, inode
->i_private
);
1854 static const struct file_operations ab8500_gpadc_aux1_fops
= {
1855 .open
= ab8500_gpadc_aux1_open
,
1857 .llseek
= seq_lseek
,
1858 .release
= single_release
,
1859 .owner
= THIS_MODULE
,
1862 static int ab8500_gpadc_aux2_print(struct seq_file
*s
, void *p
)
1866 struct ab8500_gpadc
*gpadc
;
1868 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1869 aux2_raw
= ab8500_gpadc_read_raw(gpadc
, ADC_AUX2
,
1870 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1871 aux2_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ADC_AUX2
,
1874 seq_printf(s
, "%d,0x%X\n", aux2_convert
, aux2_raw
);
1879 static int ab8500_gpadc_aux2_open(struct inode
*inode
, struct file
*file
)
1881 return single_open(file
, ab8500_gpadc_aux2_print
, inode
->i_private
);
1884 static const struct file_operations ab8500_gpadc_aux2_fops
= {
1885 .open
= ab8500_gpadc_aux2_open
,
1887 .llseek
= seq_lseek
,
1888 .release
= single_release
,
1889 .owner
= THIS_MODULE
,
1892 static int ab8500_gpadc_main_bat_v_print(struct seq_file
*s
, void *p
)
1895 int main_bat_v_convert
;
1896 struct ab8500_gpadc
*gpadc
;
1898 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1899 main_bat_v_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_BAT_V
,
1900 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1901 main_bat_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, MAIN_BAT_V
,
1904 seq_printf(s
, "%d,0x%X\n", main_bat_v_convert
, main_bat_v_raw
);
1909 static int ab8500_gpadc_main_bat_v_open(struct inode
*inode
,
1912 return single_open(file
, ab8500_gpadc_main_bat_v_print
,
1916 static const struct file_operations ab8500_gpadc_main_bat_v_fops
= {
1917 .open
= ab8500_gpadc_main_bat_v_open
,
1919 .llseek
= seq_lseek
,
1920 .release
= single_release
,
1921 .owner
= THIS_MODULE
,
1924 static int ab8500_gpadc_vbus_v_print(struct seq_file
*s
, void *p
)
1928 struct ab8500_gpadc
*gpadc
;
1930 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1931 vbus_v_raw
= ab8500_gpadc_read_raw(gpadc
, VBUS_V
,
1932 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1933 vbus_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, VBUS_V
,
1936 seq_printf(s
, "%d,0x%X\n", vbus_v_convert
, vbus_v_raw
);
1941 static int ab8500_gpadc_vbus_v_open(struct inode
*inode
, struct file
*file
)
1943 return single_open(file
, ab8500_gpadc_vbus_v_print
, inode
->i_private
);
1946 static const struct file_operations ab8500_gpadc_vbus_v_fops
= {
1947 .open
= ab8500_gpadc_vbus_v_open
,
1949 .llseek
= seq_lseek
,
1950 .release
= single_release
,
1951 .owner
= THIS_MODULE
,
1954 static int ab8500_gpadc_main_charger_c_print(struct seq_file
*s
, void *p
)
1956 int main_charger_c_raw
;
1957 int main_charger_c_convert
;
1958 struct ab8500_gpadc
*gpadc
;
1960 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1961 main_charger_c_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_CHARGER_C
,
1962 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1963 main_charger_c_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1964 MAIN_CHARGER_C
, main_charger_c_raw
);
1966 seq_printf(s
, "%d,0x%X\n", main_charger_c_convert
, main_charger_c_raw
);
1971 static int ab8500_gpadc_main_charger_c_open(struct inode
*inode
,
1974 return single_open(file
, ab8500_gpadc_main_charger_c_print
,
1978 static const struct file_operations ab8500_gpadc_main_charger_c_fops
= {
1979 .open
= ab8500_gpadc_main_charger_c_open
,
1981 .llseek
= seq_lseek
,
1982 .release
= single_release
,
1983 .owner
= THIS_MODULE
,
1986 static int ab8500_gpadc_usb_charger_c_print(struct seq_file
*s
, void *p
)
1988 int usb_charger_c_raw
;
1989 int usb_charger_c_convert
;
1990 struct ab8500_gpadc
*gpadc
;
1992 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1993 usb_charger_c_raw
= ab8500_gpadc_read_raw(gpadc
, USB_CHARGER_C
,
1994 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1995 usb_charger_c_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1996 USB_CHARGER_C
, usb_charger_c_raw
);
1998 seq_printf(s
, "%d,0x%X\n", usb_charger_c_convert
, usb_charger_c_raw
);
2003 static int ab8500_gpadc_usb_charger_c_open(struct inode
*inode
,
2006 return single_open(file
, ab8500_gpadc_usb_charger_c_print
,
2010 static const struct file_operations ab8500_gpadc_usb_charger_c_fops
= {
2011 .open
= ab8500_gpadc_usb_charger_c_open
,
2013 .llseek
= seq_lseek
,
2014 .release
= single_release
,
2015 .owner
= THIS_MODULE
,
2018 static int ab8500_gpadc_bk_bat_v_print(struct seq_file
*s
, void *p
)
2021 int bk_bat_v_convert
;
2022 struct ab8500_gpadc
*gpadc
;
2024 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2025 bk_bat_v_raw
= ab8500_gpadc_read_raw(gpadc
, BK_BAT_V
,
2026 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2027 bk_bat_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2028 BK_BAT_V
, bk_bat_v_raw
);
2030 seq_printf(s
, "%d,0x%X\n", bk_bat_v_convert
, bk_bat_v_raw
);
2035 static int ab8500_gpadc_bk_bat_v_open(struct inode
*inode
, struct file
*file
)
2037 return single_open(file
, ab8500_gpadc_bk_bat_v_print
,
2041 static const struct file_operations ab8500_gpadc_bk_bat_v_fops
= {
2042 .open
= ab8500_gpadc_bk_bat_v_open
,
2044 .llseek
= seq_lseek
,
2045 .release
= single_release
,
2046 .owner
= THIS_MODULE
,
2049 static int ab8500_gpadc_die_temp_print(struct seq_file
*s
, void *p
)
2052 int die_temp_convert
;
2053 struct ab8500_gpadc
*gpadc
;
2055 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2056 die_temp_raw
= ab8500_gpadc_read_raw(gpadc
, DIE_TEMP
,
2057 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2058 die_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, DIE_TEMP
,
2061 seq_printf(s
, "%d,0x%X\n", die_temp_convert
, die_temp_raw
);
2066 static int ab8500_gpadc_die_temp_open(struct inode
*inode
, struct file
*file
)
2068 return single_open(file
, ab8500_gpadc_die_temp_print
,
2072 static const struct file_operations ab8500_gpadc_die_temp_fops
= {
2073 .open
= ab8500_gpadc_die_temp_open
,
2075 .llseek
= seq_lseek
,
2076 .release
= single_release
,
2077 .owner
= THIS_MODULE
,
2080 static int ab8500_gpadc_usb_id_print(struct seq_file
*s
, void *p
)
2084 struct ab8500_gpadc
*gpadc
;
2086 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2087 usb_id_raw
= ab8500_gpadc_read_raw(gpadc
, USB_ID
,
2088 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2089 usb_id_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, USB_ID
,
2092 seq_printf(s
, "%d,0x%X\n", usb_id_convert
, usb_id_raw
);
2097 static int ab8500_gpadc_usb_id_open(struct inode
*inode
, struct file
*file
)
2099 return single_open(file
, ab8500_gpadc_usb_id_print
, inode
->i_private
);
2102 static const struct file_operations ab8500_gpadc_usb_id_fops
= {
2103 .open
= ab8500_gpadc_usb_id_open
,
2105 .llseek
= seq_lseek
,
2106 .release
= single_release
,
2107 .owner
= THIS_MODULE
,
2110 static int ab8540_gpadc_xtal_temp_print(struct seq_file
*s
, void *p
)
2113 int xtal_temp_convert
;
2114 struct ab8500_gpadc
*gpadc
;
2116 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2117 xtal_temp_raw
= ab8500_gpadc_read_raw(gpadc
, XTAL_TEMP
,
2118 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2119 xtal_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, XTAL_TEMP
,
2122 seq_printf(s
, "%d,0x%X\n", xtal_temp_convert
, xtal_temp_raw
);
2127 static int ab8540_gpadc_xtal_temp_open(struct inode
*inode
, struct file
*file
)
2129 return single_open(file
, ab8540_gpadc_xtal_temp_print
,
2133 static const struct file_operations ab8540_gpadc_xtal_temp_fops
= {
2134 .open
= ab8540_gpadc_xtal_temp_open
,
2136 .llseek
= seq_lseek
,
2137 .release
= single_release
,
2138 .owner
= THIS_MODULE
,
2141 static int ab8540_gpadc_vbat_true_meas_print(struct seq_file
*s
, void *p
)
2143 int vbat_true_meas_raw
;
2144 int vbat_true_meas_convert
;
2145 struct ab8500_gpadc
*gpadc
;
2147 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2148 vbat_true_meas_raw
= ab8500_gpadc_read_raw(gpadc
, VBAT_TRUE_MEAS
,
2149 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2150 vbat_true_meas_convert
=
2151 ab8500_gpadc_ad_to_voltage(gpadc
, VBAT_TRUE_MEAS
,
2152 vbat_true_meas_raw
);
2154 seq_printf(s
, "%d,0x%X\n", vbat_true_meas_convert
, vbat_true_meas_raw
);
2159 static int ab8540_gpadc_vbat_true_meas_open(struct inode
*inode
,
2162 return single_open(file
, ab8540_gpadc_vbat_true_meas_print
,
2166 static const struct file_operations ab8540_gpadc_vbat_true_meas_fops
= {
2167 .open
= ab8540_gpadc_vbat_true_meas_open
,
2169 .llseek
= seq_lseek
,
2170 .release
= single_release
,
2171 .owner
= THIS_MODULE
,
2174 static int ab8540_gpadc_bat_ctrl_and_ibat_print(struct seq_file
*s
, void *p
)
2177 int bat_ctrl_convert
;
2180 struct ab8500_gpadc
*gpadc
;
2182 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2183 bat_ctrl_raw
= ab8500_gpadc_double_read_raw(gpadc
, BAT_CTRL_AND_IBAT
,
2184 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2186 bat_ctrl_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, BAT_CTRL
,
2188 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2194 bat_ctrl_convert
, bat_ctrl_raw
,
2195 ibat_convert
, ibat_raw
);
2200 static int ab8540_gpadc_bat_ctrl_and_ibat_open(struct inode
*inode
,
2203 return single_open(file
, ab8540_gpadc_bat_ctrl_and_ibat_print
,
2207 static const struct file_operations ab8540_gpadc_bat_ctrl_and_ibat_fops
= {
2208 .open
= ab8540_gpadc_bat_ctrl_and_ibat_open
,
2210 .llseek
= seq_lseek
,
2211 .release
= single_release
,
2212 .owner
= THIS_MODULE
,
2215 static int ab8540_gpadc_vbat_meas_and_ibat_print(struct seq_file
*s
, void *p
)
2218 int vbat_meas_convert
;
2221 struct ab8500_gpadc
*gpadc
;
2223 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2224 vbat_meas_raw
= ab8500_gpadc_double_read_raw(gpadc
, VBAT_MEAS_AND_IBAT
,
2225 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2226 vbat_meas_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, MAIN_BAT_V
,
2228 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2234 vbat_meas_convert
, vbat_meas_raw
,
2235 ibat_convert
, ibat_raw
);
2240 static int ab8540_gpadc_vbat_meas_and_ibat_open(struct inode
*inode
,
2243 return single_open(file
, ab8540_gpadc_vbat_meas_and_ibat_print
,
2247 static const struct file_operations ab8540_gpadc_vbat_meas_and_ibat_fops
= {
2248 .open
= ab8540_gpadc_vbat_meas_and_ibat_open
,
2250 .llseek
= seq_lseek
,
2251 .release
= single_release
,
2252 .owner
= THIS_MODULE
,
2255 static int ab8540_gpadc_vbat_true_meas_and_ibat_print(struct seq_file
*s
,
2258 int vbat_true_meas_raw
;
2259 int vbat_true_meas_convert
;
2262 struct ab8500_gpadc
*gpadc
;
2264 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2265 vbat_true_meas_raw
= ab8500_gpadc_double_read_raw(gpadc
,
2266 VBAT_TRUE_MEAS_AND_IBAT
, avg_sample
, trig_edge
,
2267 trig_timer
, conv_type
, &ibat_raw
);
2268 vbat_true_meas_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2269 VBAT_TRUE_MEAS
, vbat_true_meas_raw
);
2270 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2276 vbat_true_meas_convert
, vbat_true_meas_raw
,
2277 ibat_convert
, ibat_raw
);
2282 static int ab8540_gpadc_vbat_true_meas_and_ibat_open(struct inode
*inode
,
2285 return single_open(file
, ab8540_gpadc_vbat_true_meas_and_ibat_print
,
2289 static const struct file_operations
2290 ab8540_gpadc_vbat_true_meas_and_ibat_fops
= {
2291 .open
= ab8540_gpadc_vbat_true_meas_and_ibat_open
,
2293 .llseek
= seq_lseek
,
2294 .release
= single_release
,
2295 .owner
= THIS_MODULE
,
2298 static int ab8540_gpadc_bat_temp_and_ibat_print(struct seq_file
*s
, void *p
)
2301 int bat_temp_convert
;
2304 struct ab8500_gpadc
*gpadc
;
2306 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2307 bat_temp_raw
= ab8500_gpadc_double_read_raw(gpadc
, BAT_TEMP_AND_IBAT
,
2308 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2309 bat_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, BTEMP_BALL
,
2311 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2317 bat_temp_convert
, bat_temp_raw
,
2318 ibat_convert
, ibat_raw
);
2323 static int ab8540_gpadc_bat_temp_and_ibat_open(struct inode
*inode
,
2326 return single_open(file
, ab8540_gpadc_bat_temp_and_ibat_print
,
2330 static const struct file_operations ab8540_gpadc_bat_temp_and_ibat_fops
= {
2331 .open
= ab8540_gpadc_bat_temp_and_ibat_open
,
2333 .llseek
= seq_lseek
,
2334 .release
= single_release
,
2335 .owner
= THIS_MODULE
,
2338 static int ab8540_gpadc_otp_cal_print(struct seq_file
*s
, void *p
)
2340 struct ab8500_gpadc
*gpadc
;
2341 u16 vmain_l
, vmain_h
, btemp_l
, btemp_h
;
2342 u16 vbat_l
, vbat_h
, ibat_l
, ibat_h
;
2344 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2345 ab8540_gpadc_get_otp(gpadc
, &vmain_l
, &vmain_h
, &btemp_l
, &btemp_h
,
2346 &vbat_l
, &vbat_h
, &ibat_l
, &ibat_h
);
2356 vmain_l
, vmain_h
, btemp_l
, btemp_h
,
2357 vbat_l
, vbat_h
, ibat_l
, ibat_h
);
2362 static int ab8540_gpadc_otp_cal_open(struct inode
*inode
, struct file
*file
)
2364 return single_open(file
, ab8540_gpadc_otp_cal_print
, inode
->i_private
);
2367 static const struct file_operations ab8540_gpadc_otp_calib_fops
= {
2368 .open
= ab8540_gpadc_otp_cal_open
,
2370 .llseek
= seq_lseek
,
2371 .release
= single_release
,
2372 .owner
= THIS_MODULE
,
2375 static int ab8500_gpadc_avg_sample_print(struct seq_file
*s
, void *p
)
2377 seq_printf(s
, "%d\n", avg_sample
);
2382 static int ab8500_gpadc_avg_sample_open(struct inode
*inode
, struct file
*file
)
2384 return single_open(file
, ab8500_gpadc_avg_sample_print
,
2388 static ssize_t
ab8500_gpadc_avg_sample_write(struct file
*file
,
2389 const char __user
*user_buf
,
2390 size_t count
, loff_t
*ppos
)
2392 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2393 unsigned long user_avg_sample
;
2396 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_avg_sample
);
2400 if ((user_avg_sample
== SAMPLE_1
) || (user_avg_sample
== SAMPLE_4
)
2401 || (user_avg_sample
== SAMPLE_8
)
2402 || (user_avg_sample
== SAMPLE_16
)) {
2403 avg_sample
= (u8
) user_avg_sample
;
2406 "debugfs err input: should be egal to 1, 4, 8 or 16\n");
2413 static const struct file_operations ab8500_gpadc_avg_sample_fops
= {
2414 .open
= ab8500_gpadc_avg_sample_open
,
2416 .write
= ab8500_gpadc_avg_sample_write
,
2417 .llseek
= seq_lseek
,
2418 .release
= single_release
,
2419 .owner
= THIS_MODULE
,
2422 static int ab8500_gpadc_trig_edge_print(struct seq_file
*s
, void *p
)
2424 seq_printf(s
, "%d\n", trig_edge
);
2429 static int ab8500_gpadc_trig_edge_open(struct inode
*inode
, struct file
*file
)
2431 return single_open(file
, ab8500_gpadc_trig_edge_print
,
2435 static ssize_t
ab8500_gpadc_trig_edge_write(struct file
*file
,
2436 const char __user
*user_buf
,
2437 size_t count
, loff_t
*ppos
)
2439 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2440 unsigned long user_trig_edge
;
2443 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_trig_edge
);
2447 if ((user_trig_edge
== RISING_EDGE
)
2448 || (user_trig_edge
== FALLING_EDGE
)) {
2449 trig_edge
= (u8
) user_trig_edge
;
2451 dev_err(dev
, "Wrong input:\n"
2452 "Enter 0. Rising edge\n"
2453 "Enter 1. Falling edge\n");
2460 static const struct file_operations ab8500_gpadc_trig_edge_fops
= {
2461 .open
= ab8500_gpadc_trig_edge_open
,
2463 .write
= ab8500_gpadc_trig_edge_write
,
2464 .llseek
= seq_lseek
,
2465 .release
= single_release
,
2466 .owner
= THIS_MODULE
,
2469 static int ab8500_gpadc_trig_timer_print(struct seq_file
*s
, void *p
)
2471 seq_printf(s
, "%d\n", trig_timer
);
2476 static int ab8500_gpadc_trig_timer_open(struct inode
*inode
, struct file
*file
)
2478 return single_open(file
, ab8500_gpadc_trig_timer_print
,
2482 static ssize_t
ab8500_gpadc_trig_timer_write(struct file
*file
,
2483 const char __user
*user_buf
,
2484 size_t count
, loff_t
*ppos
)
2486 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2487 unsigned long user_trig_timer
;
2490 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_trig_timer
);
2494 if (user_trig_timer
& ~0xFF) {
2496 "debugfs error input: should be between 0 to 255\n");
2500 trig_timer
= (u8
) user_trig_timer
;
2505 static const struct file_operations ab8500_gpadc_trig_timer_fops
= {
2506 .open
= ab8500_gpadc_trig_timer_open
,
2508 .write
= ab8500_gpadc_trig_timer_write
,
2509 .llseek
= seq_lseek
,
2510 .release
= single_release
,
2511 .owner
= THIS_MODULE
,
2514 static int ab8500_gpadc_conv_type_print(struct seq_file
*s
, void *p
)
2516 seq_printf(s
, "%d\n", conv_type
);
2521 static int ab8500_gpadc_conv_type_open(struct inode
*inode
, struct file
*file
)
2523 return single_open(file
, ab8500_gpadc_conv_type_print
,
2527 static ssize_t
ab8500_gpadc_conv_type_write(struct file
*file
,
2528 const char __user
*user_buf
,
2529 size_t count
, loff_t
*ppos
)
2531 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2532 unsigned long user_conv_type
;
2535 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_conv_type
);
2539 if ((user_conv_type
== ADC_SW
)
2540 || (user_conv_type
== ADC_HW
)) {
2541 conv_type
= (u8
) user_conv_type
;
2543 dev_err(dev
, "Wrong input:\n"
2544 "Enter 0. ADC SW conversion\n"
2545 "Enter 1. ADC HW conversion\n");
2552 static const struct file_operations ab8500_gpadc_conv_type_fops
= {
2553 .open
= ab8500_gpadc_conv_type_open
,
2555 .write
= ab8500_gpadc_conv_type_write
,
2556 .llseek
= seq_lseek
,
2557 .release
= single_release
,
2558 .owner
= THIS_MODULE
,
2562 * return length of an ASCII numerical value, 0 is string is not a
2564 * string shall start at value 1st char.
2565 * string can be tailed with \0 or space or newline chars only.
2566 * value can be decimal or hexadecimal (prefixed 0x or 0X).
2568 static int strval_len(char *b
)
2572 if ((*s
== '0') && ((*(s
+1) == 'x') || (*(s
+1) == 'X'))) {
2574 for (; *s
&& (*s
!= ' ') && (*s
!= '\n'); s
++) {
2581 for (; *s
&& (*s
!= ' ') && (*s
!= '\n'); s
++) {
2590 * parse hwreg input data.
2591 * update global hwreg_cfg only if input data syntax is ok.
2593 static ssize_t
hwreg_common_write(char *b
, struct hwreg_cfg
*cfg
,
2596 uint write
, val
= 0;
2599 struct hwreg_cfg loc
= {
2600 .bank
= 0, /* default: invalid phys addr */
2601 .addr
= 0, /* default: invalid phys addr */
2602 .fmt
= 0, /* default: 32bit access, hex output */
2603 .mask
= 0xFFFFFFFF, /* default: no mask */
2604 .shift
= 0, /* default: no bit shift */
2607 /* read or write ? */
2608 if (!strncmp(b
, "read ", 5)) {
2611 } else if (!strncmp(b
, "write ", 6)) {
2617 /* OPTIONS -l|-w|-b -s -m -o */
2618 while ((*b
== ' ') || (*b
== '-')) {
2619 if (*(b
-1) != ' ') {
2623 if ((!strncmp(b
, "-d ", 3)) ||
2624 (!strncmp(b
, "-dec ", 5))) {
2625 b
+= (*(b
+2) == ' ') ? 3 : 5;
2627 } else if ((!strncmp(b
, "-h ", 3)) ||
2628 (!strncmp(b
, "-hex ", 5))) {
2629 b
+= (*(b
+2) == ' ') ? 3 : 5;
2631 } else if ((!strncmp(b
, "-m ", 3)) ||
2632 (!strncmp(b
, "-mask ", 6))) {
2633 b
+= (*(b
+2) == ' ') ? 3 : 6;
2634 if (strval_len(b
) == 0)
2636 ret
= kstrtoul(b
, 0, &loc
.mask
);
2639 } else if ((!strncmp(b
, "-s ", 3)) ||
2640 (!strncmp(b
, "-shift ", 7))) {
2641 b
+= (*(b
+2) == ' ') ? 3 : 7;
2642 if (strval_len(b
) == 0)
2644 ret
= kstrtol(b
, 0, &loc
.shift
);
2651 /* get arg BANK and ADDRESS */
2652 if (strval_len(b
) == 0)
2654 ret
= kstrtouint(b
, 0, &loc
.bank
);
2659 if (strval_len(b
) == 0)
2661 ret
= kstrtoul(b
, 0, &loc
.addr
);
2668 if (strval_len(b
) == 0)
2670 ret
= kstrtouint(b
, 0, &val
);
2675 /* args are ok, update target cfg (mainly for read) */
2678 #ifdef ABB_HWREG_DEBUG
2679 pr_warn("HWREG request: %s, %s,\n", (write
) ? "write" : "read",
2680 REG_FMT_DEC(cfg
) ? "decimal" : "hexa");
2681 pr_warn(" addr=0x%08X, mask=0x%X, shift=%d" "value=0x%X\n",
2682 cfg
->addr
, cfg
->mask
, cfg
->shift
, val
);
2688 ret
= abx500_get_register_interruptible(dev
,
2689 (u8
)cfg
->bank
, (u8
)cfg
->addr
, ®value
);
2691 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
2696 if (cfg
->shift
>= 0) {
2697 regvalue
&= ~(cfg
->mask
<< (cfg
->shift
));
2698 val
= (val
& cfg
->mask
) << (cfg
->shift
);
2700 regvalue
&= ~(cfg
->mask
>> (-cfg
->shift
));
2701 val
= (val
& cfg
->mask
) >> (-cfg
->shift
);
2703 val
= val
| regvalue
;
2705 ret
= abx500_set_register_interruptible(dev
,
2706 (u8
)cfg
->bank
, (u8
)cfg
->addr
, (u8
)val
);
2708 pr_err("abx500_set_reg failed %d, %d", ret
, __LINE__
);
2715 static ssize_t
ab8500_hwreg_write(struct file
*file
,
2716 const char __user
*user_buf
, size_t count
, loff_t
*ppos
)
2718 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2722 /* Get userspace string and assure termination */
2723 buf_size
= min(count
, (sizeof(buf
)-1));
2724 if (copy_from_user(buf
, user_buf
, buf_size
))
2728 /* get args and process */
2729 ret
= hwreg_common_write(buf
, &hwreg_cfg
, dev
);
2730 return (ret
) ? ret
: buf_size
;
2734 * - irq subscribe/unsubscribe stuff
2736 static int ab8500_subscribe_unsubscribe_print(struct seq_file
*s
, void *p
)
2738 seq_printf(s
, "%d\n", irq_first
);
2743 static int ab8500_subscribe_unsubscribe_open(struct inode
*inode
,
2746 return single_open(file
, ab8500_subscribe_unsubscribe_print
,
2751 * Userspace should use poll() on this file. When an event occur
2752 * the blocking poll will be released.
2754 static ssize_t
show_irq(struct device
*dev
,
2755 struct device_attribute
*attr
, char *buf
)
2758 unsigned int irq_index
;
2761 err
= kstrtoul(attr
->attr
.name
, 0, &name
);
2765 irq_index
= name
- irq_first
;
2766 if (irq_index
>= num_irqs
)
2769 return sprintf(buf
, "%u\n", irq_count
[irq_index
]);
2772 static ssize_t
ab8500_subscribe_write(struct file
*file
,
2773 const char __user
*user_buf
,
2774 size_t count
, loff_t
*ppos
)
2776 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2777 unsigned long user_val
;
2779 unsigned int irq_index
;
2781 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
2785 if (user_val
< irq_first
) {
2786 dev_err(dev
, "debugfs error input < %d\n", irq_first
);
2789 if (user_val
> irq_last
) {
2790 dev_err(dev
, "debugfs error input > %d\n", irq_last
);
2794 irq_index
= user_val
- irq_first
;
2795 if (irq_index
>= num_irqs
)
2799 * This will create a sysfs file named <irq-nr> which userspace can
2800 * use to select or poll and get the AB8500 events
2802 dev_attr
[irq_index
] = kmalloc(sizeof(struct device_attribute
),
2804 if (!dev_attr
[irq_index
])
2807 event_name
[irq_index
] = kmalloc(count
, GFP_KERNEL
);
2808 if (!event_name
[irq_index
])
2811 sprintf(event_name
[irq_index
], "%lu", user_val
);
2812 dev_attr
[irq_index
]->show
= show_irq
;
2813 dev_attr
[irq_index
]->store
= NULL
;
2814 dev_attr
[irq_index
]->attr
.name
= event_name
[irq_index
];
2815 dev_attr
[irq_index
]->attr
.mode
= S_IRUGO
;
2816 err
= sysfs_create_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2818 pr_info("sysfs_create_file failed %d\n", err
);
2822 err
= request_threaded_irq(user_val
, NULL
, ab8500_debug_handler
,
2823 IRQF_SHARED
| IRQF_NO_SUSPEND
| IRQF_ONESHOT
,
2824 "ab8500-debug", &dev
->kobj
);
2826 pr_info("request_threaded_irq failed %d, %lu\n",
2828 sysfs_remove_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2835 static ssize_t
ab8500_unsubscribe_write(struct file
*file
,
2836 const char __user
*user_buf
,
2837 size_t count
, loff_t
*ppos
)
2839 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2840 unsigned long user_val
;
2842 unsigned int irq_index
;
2844 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
2848 if (user_val
< irq_first
) {
2849 dev_err(dev
, "debugfs error input < %d\n", irq_first
);
2852 if (user_val
> irq_last
) {
2853 dev_err(dev
, "debugfs error input > %d\n", irq_last
);
2857 irq_index
= user_val
- irq_first
;
2858 if (irq_index
>= num_irqs
)
2861 /* Set irq count to 0 when unsubscribe */
2862 irq_count
[irq_index
] = 0;
2864 if (dev_attr
[irq_index
])
2865 sysfs_remove_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2868 free_irq(user_val
, &dev
->kobj
);
2869 kfree(event_name
[irq_index
]);
2870 kfree(dev_attr
[irq_index
]);
2876 * - several deubgfs nodes fops
2879 static const struct file_operations ab8500_bank_fops
= {
2880 .open
= ab8500_bank_open
,
2881 .write
= ab8500_bank_write
,
2883 .llseek
= seq_lseek
,
2884 .release
= single_release
,
2885 .owner
= THIS_MODULE
,
2888 static const struct file_operations ab8500_address_fops
= {
2889 .open
= ab8500_address_open
,
2890 .write
= ab8500_address_write
,
2892 .llseek
= seq_lseek
,
2893 .release
= single_release
,
2894 .owner
= THIS_MODULE
,
2897 static const struct file_operations ab8500_val_fops
= {
2898 .open
= ab8500_val_open
,
2899 .write
= ab8500_val_write
,
2901 .llseek
= seq_lseek
,
2902 .release
= single_release
,
2903 .owner
= THIS_MODULE
,
2906 static const struct file_operations ab8500_interrupts_fops
= {
2907 .open
= ab8500_interrupts_open
,
2909 .llseek
= seq_lseek
,
2910 .release
= single_release
,
2911 .owner
= THIS_MODULE
,
2914 static const struct file_operations ab8500_subscribe_fops
= {
2915 .open
= ab8500_subscribe_unsubscribe_open
,
2916 .write
= ab8500_subscribe_write
,
2918 .llseek
= seq_lseek
,
2919 .release
= single_release
,
2920 .owner
= THIS_MODULE
,
2923 static const struct file_operations ab8500_unsubscribe_fops
= {
2924 .open
= ab8500_subscribe_unsubscribe_open
,
2925 .write
= ab8500_unsubscribe_write
,
2927 .llseek
= seq_lseek
,
2928 .release
= single_release
,
2929 .owner
= THIS_MODULE
,
2932 static const struct file_operations ab8500_hwreg_fops
= {
2933 .open
= ab8500_hwreg_open
,
2934 .write
= ab8500_hwreg_write
,
2936 .llseek
= seq_lseek
,
2937 .release
= single_release
,
2938 .owner
= THIS_MODULE
,
2941 static struct dentry
*ab8500_dir
;
2942 static struct dentry
*ab8500_gpadc_dir
;
2944 static int ab8500_debug_probe(struct platform_device
*plf
)
2946 struct dentry
*file
;
2947 struct ab8500
*ab8500
;
2948 struct resource
*res
;
2950 debug_bank
= AB8500_MISC
;
2951 debug_address
= AB8500_REV_REG
& 0x00FF;
2953 ab8500
= dev_get_drvdata(plf
->dev
.parent
);
2954 num_irqs
= ab8500
->mask_size
;
2956 irq_count
= devm_kzalloc(&plf
->dev
,
2957 sizeof(*irq_count
)*num_irqs
, GFP_KERNEL
);
2961 dev_attr
= devm_kzalloc(&plf
->dev
,
2962 sizeof(*dev_attr
)*num_irqs
, GFP_KERNEL
);
2966 event_name
= devm_kzalloc(&plf
->dev
,
2967 sizeof(*event_name
)*num_irqs
, GFP_KERNEL
);
2971 res
= platform_get_resource_byname(plf
, 0, "IRQ_AB8500");
2973 dev_err(&plf
->dev
, "AB8500 irq not found, err %d\n", irq_first
);
2976 irq_ab8500
= res
->start
;
2978 irq_first
= platform_get_irq_byname(plf
, "IRQ_FIRST");
2979 if (irq_first
< 0) {
2980 dev_err(&plf
->dev
, "First irq not found, err %d\n", irq_first
);
2984 irq_last
= platform_get_irq_byname(plf
, "IRQ_LAST");
2986 dev_err(&plf
->dev
, "Last irq not found, err %d\n", irq_last
);
2990 ab8500_dir
= debugfs_create_dir(AB8500_NAME_STRING
, NULL
);
2994 ab8500_gpadc_dir
= debugfs_create_dir(AB8500_ADC_NAME_STRING
,
2996 if (!ab8500_gpadc_dir
)
2999 file
= debugfs_create_file("all-bank-registers", S_IRUGO
, ab8500_dir
,
3000 &plf
->dev
, &ab8500_registers_fops
);
3004 file
= debugfs_create_file("all-banks", S_IRUGO
, ab8500_dir
,
3005 &plf
->dev
, &ab8500_all_banks_fops
);
3009 file
= debugfs_create_file("register-bank",
3010 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3011 ab8500_dir
, &plf
->dev
, &ab8500_bank_fops
);
3015 file
= debugfs_create_file("register-address",
3016 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3017 ab8500_dir
, &plf
->dev
, &ab8500_address_fops
);
3021 file
= debugfs_create_file("register-value",
3022 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3023 ab8500_dir
, &plf
->dev
, &ab8500_val_fops
);
3027 file
= debugfs_create_file("irq-subscribe",
3028 (S_IRUGO
| S_IWUSR
| S_IWGRP
), ab8500_dir
,
3029 &plf
->dev
, &ab8500_subscribe_fops
);
3033 if (is_ab8500(ab8500
)) {
3034 debug_ranges
= ab8500_debug_ranges
;
3035 num_interrupt_lines
= AB8500_NR_IRQS
;
3036 } else if (is_ab8505(ab8500
)) {
3037 debug_ranges
= ab8505_debug_ranges
;
3038 num_interrupt_lines
= AB8505_NR_IRQS
;
3039 } else if (is_ab9540(ab8500
)) {
3040 debug_ranges
= ab8505_debug_ranges
;
3041 num_interrupt_lines
= AB9540_NR_IRQS
;
3042 } else if (is_ab8540(ab8500
)) {
3043 debug_ranges
= ab8540_debug_ranges
;
3044 num_interrupt_lines
= AB8540_NR_IRQS
;
3047 file
= debugfs_create_file("interrupts", (S_IRUGO
), ab8500_dir
,
3048 &plf
->dev
, &ab8500_interrupts_fops
);
3052 file
= debugfs_create_file("irq-unsubscribe",
3053 (S_IRUGO
| S_IWUSR
| S_IWGRP
), ab8500_dir
,
3054 &plf
->dev
, &ab8500_unsubscribe_fops
);
3058 file
= debugfs_create_file("hwreg", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3059 ab8500_dir
, &plf
->dev
, &ab8500_hwreg_fops
);
3063 file
= debugfs_create_file("all-modem-registers",
3064 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3065 ab8500_dir
, &plf
->dev
, &ab8500_modem_fops
);
3069 file
= debugfs_create_file("bat_ctrl", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3070 ab8500_gpadc_dir
, &plf
->dev
,
3071 &ab8500_gpadc_bat_ctrl_fops
);
3075 file
= debugfs_create_file("btemp_ball", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3077 &plf
->dev
, &ab8500_gpadc_btemp_ball_fops
);
3081 file
= debugfs_create_file("main_charger_v",
3082 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3083 ab8500_gpadc_dir
, &plf
->dev
,
3084 &ab8500_gpadc_main_charger_v_fops
);
3088 file
= debugfs_create_file("acc_detect1",
3089 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3090 ab8500_gpadc_dir
, &plf
->dev
,
3091 &ab8500_gpadc_acc_detect1_fops
);
3095 file
= debugfs_create_file("acc_detect2",
3096 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3097 ab8500_gpadc_dir
, &plf
->dev
,
3098 &ab8500_gpadc_acc_detect2_fops
);
3102 file
= debugfs_create_file("adc_aux1", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3103 ab8500_gpadc_dir
, &plf
->dev
,
3104 &ab8500_gpadc_aux1_fops
);
3108 file
= debugfs_create_file("adc_aux2", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3109 ab8500_gpadc_dir
, &plf
->dev
,
3110 &ab8500_gpadc_aux2_fops
);
3114 file
= debugfs_create_file("main_bat_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3115 ab8500_gpadc_dir
, &plf
->dev
,
3116 &ab8500_gpadc_main_bat_v_fops
);
3120 file
= debugfs_create_file("vbus_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3121 ab8500_gpadc_dir
, &plf
->dev
,
3122 &ab8500_gpadc_vbus_v_fops
);
3126 file
= debugfs_create_file("main_charger_c",
3127 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3128 ab8500_gpadc_dir
, &plf
->dev
,
3129 &ab8500_gpadc_main_charger_c_fops
);
3133 file
= debugfs_create_file("usb_charger_c",
3134 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3136 &plf
->dev
, &ab8500_gpadc_usb_charger_c_fops
);
3140 file
= debugfs_create_file("bk_bat_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3141 ab8500_gpadc_dir
, &plf
->dev
,
3142 &ab8500_gpadc_bk_bat_v_fops
);
3146 file
= debugfs_create_file("die_temp", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3147 ab8500_gpadc_dir
, &plf
->dev
,
3148 &ab8500_gpadc_die_temp_fops
);
3152 file
= debugfs_create_file("usb_id", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3153 ab8500_gpadc_dir
, &plf
->dev
,
3154 &ab8500_gpadc_usb_id_fops
);
3158 if (is_ab8540(ab8500
)) {
3159 file
= debugfs_create_file("xtal_temp",
3160 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3161 ab8500_gpadc_dir
, &plf
->dev
,
3162 &ab8540_gpadc_xtal_temp_fops
);
3165 file
= debugfs_create_file("vbattruemeas",
3166 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3167 ab8500_gpadc_dir
, &plf
->dev
,
3168 &ab8540_gpadc_vbat_true_meas_fops
);
3171 file
= debugfs_create_file("batctrl_and_ibat",
3172 (S_IRUGO
| S_IWUGO
),
3175 &ab8540_gpadc_bat_ctrl_and_ibat_fops
);
3178 file
= debugfs_create_file("vbatmeas_and_ibat",
3179 (S_IRUGO
| S_IWUGO
),
3180 ab8500_gpadc_dir
, &plf
->dev
,
3181 &ab8540_gpadc_vbat_meas_and_ibat_fops
);
3184 file
= debugfs_create_file("vbattruemeas_and_ibat",
3185 (S_IRUGO
| S_IWUGO
),
3188 &ab8540_gpadc_vbat_true_meas_and_ibat_fops
);
3191 file
= debugfs_create_file("battemp_and_ibat",
3192 (S_IRUGO
| S_IWUGO
),
3194 &plf
->dev
, &ab8540_gpadc_bat_temp_and_ibat_fops
);
3197 file
= debugfs_create_file("otp_calib",
3198 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3200 &plf
->dev
, &ab8540_gpadc_otp_calib_fops
);
3204 file
= debugfs_create_file("avg_sample", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3205 ab8500_gpadc_dir
, &plf
->dev
,
3206 &ab8500_gpadc_avg_sample_fops
);
3210 file
= debugfs_create_file("trig_edge", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3211 ab8500_gpadc_dir
, &plf
->dev
,
3212 &ab8500_gpadc_trig_edge_fops
);
3216 file
= debugfs_create_file("trig_timer", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3217 ab8500_gpadc_dir
, &plf
->dev
,
3218 &ab8500_gpadc_trig_timer_fops
);
3222 file
= debugfs_create_file("conv_type", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3223 ab8500_gpadc_dir
, &plf
->dev
,
3224 &ab8500_gpadc_conv_type_fops
);
3231 debugfs_remove_recursive(ab8500_dir
);
3232 dev_err(&plf
->dev
, "failed to create debugfs entries.\n");
3237 static int ab8500_debug_remove(struct platform_device
*plf
)
3239 debugfs_remove_recursive(ab8500_dir
);
3244 static struct platform_driver ab8500_debug_driver
= {
3246 .name
= "ab8500-debug",
3248 .probe
= ab8500_debug_probe
,
3249 .remove
= ab8500_debug_remove
3252 static int __init
ab8500_debug_init(void)
3254 return platform_driver_register(&ab8500_debug_driver
);
3257 static void __exit
ab8500_debug_exit(void)
3259 platform_driver_unregister(&ab8500_debug_driver
);
3261 subsys_initcall(ab8500_debug_init
);
3262 module_exit(ab8500_debug_exit
);
3264 MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
3265 MODULE_DESCRIPTION("AB8500 DEBUG");
3266 MODULE_LICENSE("GPL v2");