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 u32 addr
; /* target address */
139 uint fmt
; /* format */
140 uint mask
; /* read/write mask, applied before any bit shift */
141 int 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 24
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
] = {
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
[]) {
245 /* 0x80-0x8B is SIM registers and should
246 * not be accessed from here */
251 .range
= (struct ab8500_reg_range
[]) {
264 .range
= (struct ab8500_reg_range
[]) {
307 [AB8500_ECI_AV_ACC
] = {
309 .range
= (struct ab8500_reg_range
[]) {
322 .range
= (struct ab8500_reg_range
[]) {
331 .range
= (struct ab8500_reg_range
[]) {
370 [AB8500_GAS_GAUGE
] = {
372 .range
= (struct ab8500_reg_range
[]) {
387 [AB8500_DEVELOPMENT
] = {
389 .range
= (struct ab8500_reg_range
[]) {
398 .range
= (struct ab8500_reg_range
[]) {
407 .range
= (struct ab8500_reg_range
[]) {
414 [AB8500_INTERRUPT
] = {
420 .range
= (struct ab8500_reg_range
[]) {
429 .range
= (struct ab8500_reg_range
[]) {
480 [AB8500_OTP_EMUL
] = {
482 .range
= (struct ab8500_reg_range
[]) {
491 static struct ab8500_prcmu_ranges ab8505_debug_ranges
[AB8500_NUM_BANKS
] = {
496 [AB8500_SYS_CTRL1_BLOCK
] = {
498 .range
= (struct ab8500_reg_range
[]) {
521 [AB8500_SYS_CTRL2_BLOCK
] = {
523 .range
= (struct ab8500_reg_range
[]) {
546 [AB8500_REGU_CTRL1
] = {
548 .range
= (struct ab8500_reg_range
[]) {
563 [AB8500_REGU_CTRL2
] = {
565 .range
= (struct ab8500_reg_range
[]) {
590 /* 0x80-0x8B is SIM registers and should
591 * not be accessed from here */
596 .range
= (struct ab8500_reg_range
[]) {
619 [AB8500_ECI_AV_ACC
] = {
621 .range
= (struct ab8500_reg_range
[]) {
628 [AB8500_RESERVED
] = {
634 .range
= (struct ab8500_reg_range
[]) {
643 .range
= (struct ab8500_reg_range
[]) {
682 [AB8500_GAS_GAUGE
] = {
684 .range
= (struct ab8500_reg_range
[]) {
701 .range
= (struct ab8500_reg_range
[]) {
708 [AB8500_INTERRUPT
] = {
710 .range
= (struct ab8500_reg_range
[]) {
735 /* Latch registers should not be read here */
756 /* LatchHier registers should not be read here */
761 .range
= (struct ab8500_reg_range
[]) {
774 .range
= (struct ab8500_reg_range
[]) {
809 [AB8500_DEVELOPMENT
] = {
811 .range
= (struct ab8500_reg_range
[]) {
824 .range
= (struct ab8500_reg_range
[]) {
831 [AB8500_PROD_TEST
] = {
835 [AB8500_STE_TEST
] = {
839 [AB8500_OTP_EMUL
] = {
841 .range
= (struct ab8500_reg_range
[]) {
850 static struct ab8500_prcmu_ranges ab8540_debug_ranges
[AB8500_NUM_BANKS
] = {
851 [AB8500_M_FSM_RANK
] = {
853 .range
= (struct ab8500_reg_range
[]) {
860 [AB8500_SYS_CTRL1_BLOCK
] = {
862 .range
= (struct ab8500_reg_range
[]) {
889 [AB8500_SYS_CTRL2_BLOCK
] = {
891 .range
= (struct ab8500_reg_range
[]) {
914 [AB8500_REGU_CTRL1
] = {
916 .range
= (struct ab8500_reg_range
[]) {
935 [AB8500_REGU_CTRL2
] = {
937 .range
= (struct ab8500_reg_range
[]) {
974 .range
= (struct ab8500_reg_range
[]) {
995 .range
= (struct ab8500_reg_range
[]) {
1014 [AB8500_ECI_AV_ACC
] = {
1016 .range
= (struct ab8500_reg_range
[]) {
1027 [AB8500_RESERVED
] = {
1033 .range
= (struct ab8500_reg_range
[]) {
1052 [AB8500_CHARGER
] = {
1054 .range
= (struct ab8500_reg_range
[]) {
1097 [AB8500_GAS_GAUGE
] = {
1099 .range
= (struct ab8500_reg_range
[]) {
1116 .range
= (struct ab8500_reg_range
[]) {
1123 [AB8500_INTERRUPT
] = {
1125 .range
= (struct ab8500_reg_range
[]) {
1138 /* Latch registers should not be read here */
1151 /* LatchHier registers should not be read here */
1156 .range
= (struct ab8500_reg_range
[]) {
1173 .range
= (struct ab8500_reg_range
[]) {
1212 [AB8500_DEVELOPMENT
] = {
1214 .range
= (struct ab8500_reg_range
[]) {
1231 .range
= (struct ab8500_reg_range
[]) {
1246 [AB8500_PROD_TEST
] = {
1250 [AB8500_STE_TEST
] = {
1254 [AB8500_OTP_EMUL
] = {
1256 .range
= (struct ab8500_reg_range
[]) {
1266 static irqreturn_t
ab8500_debug_handler(int irq
, void *data
)
1269 struct kobject
*kobj
= (struct kobject
*)data
;
1270 unsigned int irq_abb
= irq
- irq_first
;
1272 if (irq_abb
< num_irqs
)
1273 irq_count
[irq_abb
]++;
1275 * This makes it possible to use poll for events (POLLPRI | POLLERR)
1276 * from userspace on sysfs file named <irq-nr>
1278 sprintf(buf
, "%d", irq
);
1279 sysfs_notify(kobj
, NULL
, buf
);
1284 /* Prints to seq_file or log_buf */
1285 static int ab8500_registers_print(struct device
*dev
, u32 bank
,
1290 for (i
= 0; i
< debug_ranges
[bank
].num_ranges
; i
++) {
1293 for (reg
= debug_ranges
[bank
].range
[i
].first
;
1294 reg
<= debug_ranges
[bank
].range
[i
].last
;
1299 err
= abx500_get_register_interruptible(dev
,
1300 (u8
)bank
, (u8
)reg
, &value
);
1302 dev_err(dev
, "ab->read fail %d\n", err
);
1307 err
= seq_printf(s
, " [0x%02X/0x%02X]: 0x%02X\n",
1310 /* Error is not returned here since
1311 * the output is wanted in any case */
1315 printk(KERN_INFO
" [0x%02X/0x%02X]: 0x%02X\n",
1323 static int ab8500_print_bank_registers(struct seq_file
*s
, void *p
)
1325 struct device
*dev
= s
->private;
1326 u32 bank
= debug_bank
;
1328 seq_printf(s
, AB8500_NAME_STRING
" register values:\n");
1330 seq_printf(s
, " bank 0x%02X:\n", bank
);
1332 ab8500_registers_print(dev
, bank
, s
);
1336 static int ab8500_registers_open(struct inode
*inode
, struct file
*file
)
1338 return single_open(file
, ab8500_print_bank_registers
, inode
->i_private
);
1341 static const struct file_operations ab8500_registers_fops
= {
1342 .open
= ab8500_registers_open
,
1344 .llseek
= seq_lseek
,
1345 .release
= single_release
,
1346 .owner
= THIS_MODULE
,
1349 static int ab8500_print_all_banks(struct seq_file
*s
, void *p
)
1351 struct device
*dev
= s
->private;
1355 seq_printf(s
, AB8500_NAME_STRING
" register values:\n");
1357 for (i
= 0; i
< AB8500_NUM_BANKS
; i
++) {
1358 err
= seq_printf(s
, " bank 0x%02X:\n", i
);
1360 ab8500_registers_print(dev
, i
, s
);
1365 /* Dump registers to kernel log */
1366 void ab8500_dump_all_banks(struct device
*dev
)
1370 printk(KERN_INFO
"ab8500 register values:\n");
1372 for (i
= 1; i
< AB8500_NUM_BANKS
; i
++) {
1373 printk(KERN_INFO
" bank 0x%02X:\n", i
);
1374 ab8500_registers_print(dev
, i
, NULL
);
1378 /* Space for 500 registers. */
1379 #define DUMP_MAX_REGS 700
1380 static struct ab8500_register_dump
1385 } ab8500_complete_register_dump
[DUMP_MAX_REGS
];
1387 extern int prcmu_abb_read(u8 slave
, u8 reg
, u8
*value
, u8 size
);
1389 /* This shall only be called upon kernel panic! */
1390 void ab8500_dump_all_banks_to_mem(void)
1396 pr_info("Saving all ABB registers at \"ab8500_complete_register_dump\" "
1397 "for crash analyze.\n");
1399 for (bank
= 0; bank
< AB8500_NUM_BANKS
; bank
++) {
1400 for (i
= 0; i
< debug_ranges
[bank
].num_ranges
; i
++) {
1403 for (reg
= debug_ranges
[bank
].range
[i
].first
;
1404 reg
<= debug_ranges
[bank
].range
[i
].last
;
1408 err
= prcmu_abb_read(bank
, reg
, &value
, 1);
1413 ab8500_complete_register_dump
[r
].bank
= bank
;
1414 ab8500_complete_register_dump
[r
].reg
= reg
;
1415 ab8500_complete_register_dump
[r
].value
= value
;
1419 if (r
>= DUMP_MAX_REGS
) {
1420 pr_err("%s: too many register to dump!\n",
1430 pr_info("Saved all ABB registers.\n");
1432 pr_info("Failed to save all ABB registers.\n");
1435 static int ab8500_all_banks_open(struct inode
*inode
, struct file
*file
)
1440 err
= single_open(file
, ab8500_print_all_banks
, inode
->i_private
);
1442 /* Default buf size in seq_read is not enough */
1443 s
= (struct seq_file
*)file
->private_data
;
1444 s
->size
= (PAGE_SIZE
* 2);
1445 s
->buf
= kmalloc(s
->size
, GFP_KERNEL
);
1447 single_release(inode
, file
);
1454 static const struct file_operations ab8500_all_banks_fops
= {
1455 .open
= ab8500_all_banks_open
,
1457 .llseek
= seq_lseek
,
1458 .release
= single_release
,
1459 .owner
= THIS_MODULE
,
1462 static int ab8500_bank_print(struct seq_file
*s
, void *p
)
1464 return seq_printf(s
, "0x%02X\n", debug_bank
);
1467 static int ab8500_bank_open(struct inode
*inode
, struct file
*file
)
1469 return single_open(file
, ab8500_bank_print
, inode
->i_private
);
1472 static ssize_t
ab8500_bank_write(struct file
*file
,
1473 const char __user
*user_buf
,
1474 size_t count
, loff_t
*ppos
)
1476 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1477 unsigned long user_bank
;
1480 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_bank
);
1484 if (user_bank
>= AB8500_NUM_BANKS
) {
1485 dev_err(dev
, "debugfs error input > number of banks\n");
1489 debug_bank
= user_bank
;
1494 static int ab8500_address_print(struct seq_file
*s
, void *p
)
1496 return seq_printf(s
, "0x%02X\n", debug_address
);
1499 static int ab8500_address_open(struct inode
*inode
, struct file
*file
)
1501 return single_open(file
, ab8500_address_print
, inode
->i_private
);
1504 static ssize_t
ab8500_address_write(struct file
*file
,
1505 const char __user
*user_buf
,
1506 size_t count
, loff_t
*ppos
)
1508 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1509 unsigned long user_address
;
1512 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_address
);
1516 if (user_address
> 0xff) {
1517 dev_err(dev
, "debugfs error input > 0xff\n");
1520 debug_address
= user_address
;
1525 static int ab8500_val_print(struct seq_file
*s
, void *p
)
1527 struct device
*dev
= s
->private;
1531 ret
= abx500_get_register_interruptible(dev
,
1532 (u8
)debug_bank
, (u8
)debug_address
, ®value
);
1534 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
1538 seq_printf(s
, "0x%02X\n", regvalue
);
1543 static int ab8500_val_open(struct inode
*inode
, struct file
*file
)
1545 return single_open(file
, ab8500_val_print
, inode
->i_private
);
1548 static ssize_t
ab8500_val_write(struct file
*file
,
1549 const char __user
*user_buf
,
1550 size_t count
, loff_t
*ppos
)
1552 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1553 unsigned long user_val
;
1556 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
1560 if (user_val
> 0xff) {
1561 dev_err(dev
, "debugfs error input > 0xff\n");
1564 err
= abx500_set_register_interruptible(dev
,
1565 (u8
)debug_bank
, debug_address
, (u8
)user_val
);
1567 printk(KERN_ERR
"abx500_set_reg failed %d, %d", err
, __LINE__
);
1577 static u32 num_interrupts
[AB8500_MAX_NR_IRQS
];
1578 static u32 num_wake_interrupts
[AB8500_MAX_NR_IRQS
];
1579 static int num_interrupt_lines
;
1581 bool __attribute__((weak
)) suspend_test_wake_cause_interrupt_is_mine(u32 my_int
)
1586 void ab8500_debug_register_interrupt(int line
)
1588 if (line
< num_interrupt_lines
) {
1589 num_interrupts
[line
]++;
1590 if (suspend_test_wake_cause_interrupt_is_mine(irq_ab8500
))
1591 num_wake_interrupts
[line
]++;
1595 static int ab8500_interrupts_print(struct seq_file
*s
, void *p
)
1599 seq_printf(s
, "name: number: number of: wake:\n");
1601 for (line
= 0; line
< num_interrupt_lines
; line
++) {
1602 struct irq_desc
*desc
= irq_to_desc(line
+ irq_first
);
1603 struct irqaction
*action
= desc
->action
;
1605 seq_printf(s
, "%3i: %6i %4i", line
,
1606 num_interrupts
[line
],
1607 num_wake_interrupts
[line
]);
1609 if (desc
&& desc
->name
)
1610 seq_printf(s
, "-%-8s", desc
->name
);
1612 seq_printf(s
, " %s", action
->name
);
1613 while ((action
= action
->next
) != NULL
)
1614 seq_printf(s
, ", %s", action
->name
);
1622 static int ab8500_interrupts_open(struct inode
*inode
, struct file
*file
)
1624 return single_open(file
, ab8500_interrupts_print
, inode
->i_private
);
1628 * - HWREG DB8500 formated routines
1630 static int ab8500_hwreg_print(struct seq_file
*s
, void *d
)
1632 struct device
*dev
= s
->private;
1636 ret
= abx500_get_register_interruptible(dev
,
1637 (u8
)hwreg_cfg
.bank
, (u8
)hwreg_cfg
.addr
, ®value
);
1639 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
1644 if (hwreg_cfg
.shift
>= 0)
1645 regvalue
>>= hwreg_cfg
.shift
;
1647 regvalue
<<= -hwreg_cfg
.shift
;
1648 regvalue
&= hwreg_cfg
.mask
;
1650 if (REG_FMT_DEC(&hwreg_cfg
))
1651 seq_printf(s
, "%d\n", regvalue
);
1653 seq_printf(s
, "0x%02X\n", regvalue
);
1657 static int ab8500_hwreg_open(struct inode
*inode
, struct file
*file
)
1659 return single_open(file
, ab8500_hwreg_print
, inode
->i_private
);
1662 #define AB8500_SUPPLY_CONTROL_CONFIG_1 0x01
1663 #define AB8500_SUPPLY_CONTROL_REG 0x00
1664 #define AB8500_FIRST_SIM_REG 0x80
1665 #define AB8500_LAST_SIM_REG 0x8B
1666 #define AB8505_LAST_SIM_REG 0x8C
1668 static int ab8500_print_modem_registers(struct seq_file
*s
, void *p
)
1670 struct device
*dev
= s
->private;
1671 struct ab8500
*ab8500
;
1675 u32 bank
= AB8500_REGU_CTRL2
;
1676 u32 last_sim_reg
= AB8500_LAST_SIM_REG
;
1679 ab8500
= dev_get_drvdata(dev
->parent
);
1680 dev_warn(dev
, "WARNING! This operation can interfer with modem side\n"
1681 "and should only be done with care\n");
1683 err
= abx500_get_register_interruptible(dev
,
1684 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
, &orig_value
);
1686 dev_err(dev
, "ab->read fail %d\n", err
);
1689 /* Config 1 will allow APE side to read SIM registers */
1690 err
= abx500_set_register_interruptible(dev
,
1691 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
,
1692 AB8500_SUPPLY_CONTROL_CONFIG_1
);
1694 dev_err(dev
, "ab->write fail %d\n", err
);
1698 seq_printf(s
, " bank 0x%02X:\n", bank
);
1700 if (is_ab9540(ab8500
) || is_ab8505(ab8500
))
1701 last_sim_reg
= AB8505_LAST_SIM_REG
;
1703 for (reg
= AB8500_FIRST_SIM_REG
; reg
<= last_sim_reg
; reg
++) {
1704 err
= abx500_get_register_interruptible(dev
,
1707 dev_err(dev
, "ab->read fail %d\n", err
);
1710 err
= seq_printf(s
, " [0x%02X/0x%02X]: 0x%02X\n",
1713 err
= abx500_set_register_interruptible(dev
,
1714 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
, orig_value
);
1716 dev_err(dev
, "ab->write fail %d\n", err
);
1722 static int ab8500_modem_open(struct inode
*inode
, struct file
*file
)
1724 return single_open(file
, ab8500_print_modem_registers
, inode
->i_private
);
1727 static const struct file_operations ab8500_modem_fops
= {
1728 .open
= ab8500_modem_open
,
1730 .llseek
= seq_lseek
,
1731 .release
= single_release
,
1732 .owner
= THIS_MODULE
,
1735 static int ab8500_gpadc_bat_ctrl_print(struct seq_file
*s
, void *p
)
1738 int bat_ctrl_convert
;
1739 struct ab8500_gpadc
*gpadc
;
1741 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1742 bat_ctrl_raw
= ab8500_gpadc_read_raw(gpadc
, BAT_CTRL
,
1743 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1744 bat_ctrl_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1745 BAT_CTRL
, bat_ctrl_raw
);
1747 return seq_printf(s
, "%d,0x%X\n",
1748 bat_ctrl_convert
, bat_ctrl_raw
);
1751 static int ab8500_gpadc_bat_ctrl_open(struct inode
*inode
, struct file
*file
)
1753 return single_open(file
, ab8500_gpadc_bat_ctrl_print
, inode
->i_private
);
1756 static const struct file_operations ab8500_gpadc_bat_ctrl_fops
= {
1757 .open
= ab8500_gpadc_bat_ctrl_open
,
1759 .llseek
= seq_lseek
,
1760 .release
= single_release
,
1761 .owner
= THIS_MODULE
,
1764 static int ab8500_gpadc_btemp_ball_print(struct seq_file
*s
, void *p
)
1767 int btemp_ball_convert
;
1768 struct ab8500_gpadc
*gpadc
;
1770 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1771 btemp_ball_raw
= ab8500_gpadc_read_raw(gpadc
, BTEMP_BALL
,
1772 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1773 btemp_ball_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, BTEMP_BALL
,
1776 return seq_printf(s
,
1777 "%d,0x%X\n", btemp_ball_convert
, btemp_ball_raw
);
1780 static int ab8500_gpadc_btemp_ball_open(struct inode
*inode
,
1783 return single_open(file
, ab8500_gpadc_btemp_ball_print
, inode
->i_private
);
1786 static const struct file_operations ab8500_gpadc_btemp_ball_fops
= {
1787 .open
= ab8500_gpadc_btemp_ball_open
,
1789 .llseek
= seq_lseek
,
1790 .release
= single_release
,
1791 .owner
= THIS_MODULE
,
1794 static int ab8500_gpadc_main_charger_v_print(struct seq_file
*s
, void *p
)
1796 int main_charger_v_raw
;
1797 int main_charger_v_convert
;
1798 struct ab8500_gpadc
*gpadc
;
1800 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1801 main_charger_v_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_CHARGER_V
,
1802 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1803 main_charger_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1804 MAIN_CHARGER_V
, main_charger_v_raw
);
1806 return seq_printf(s
, "%d,0x%X\n",
1807 main_charger_v_convert
, main_charger_v_raw
);
1810 static int ab8500_gpadc_main_charger_v_open(struct inode
*inode
,
1813 return single_open(file
, ab8500_gpadc_main_charger_v_print
,
1817 static const struct file_operations ab8500_gpadc_main_charger_v_fops
= {
1818 .open
= ab8500_gpadc_main_charger_v_open
,
1820 .llseek
= seq_lseek
,
1821 .release
= single_release
,
1822 .owner
= THIS_MODULE
,
1825 static int ab8500_gpadc_acc_detect1_print(struct seq_file
*s
, void *p
)
1827 int acc_detect1_raw
;
1828 int acc_detect1_convert
;
1829 struct ab8500_gpadc
*gpadc
;
1831 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1832 acc_detect1_raw
= ab8500_gpadc_read_raw(gpadc
, ACC_DETECT1
,
1833 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1834 acc_detect1_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ACC_DETECT1
,
1837 return seq_printf(s
, "%d,0x%X\n",
1838 acc_detect1_convert
, acc_detect1_raw
);
1841 static int ab8500_gpadc_acc_detect1_open(struct inode
*inode
,
1844 return single_open(file
, ab8500_gpadc_acc_detect1_print
,
1848 static const struct file_operations ab8500_gpadc_acc_detect1_fops
= {
1849 .open
= ab8500_gpadc_acc_detect1_open
,
1851 .llseek
= seq_lseek
,
1852 .release
= single_release
,
1853 .owner
= THIS_MODULE
,
1856 static int ab8500_gpadc_acc_detect2_print(struct seq_file
*s
, void *p
)
1858 int acc_detect2_raw
;
1859 int acc_detect2_convert
;
1860 struct ab8500_gpadc
*gpadc
;
1862 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1863 acc_detect2_raw
= ab8500_gpadc_read_raw(gpadc
, ACC_DETECT2
,
1864 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1865 acc_detect2_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1866 ACC_DETECT2
, acc_detect2_raw
);
1868 return seq_printf(s
, "%d,0x%X\n",
1869 acc_detect2_convert
, acc_detect2_raw
);
1872 static int ab8500_gpadc_acc_detect2_open(struct inode
*inode
,
1875 return single_open(file
, ab8500_gpadc_acc_detect2_print
,
1879 static const struct file_operations ab8500_gpadc_acc_detect2_fops
= {
1880 .open
= ab8500_gpadc_acc_detect2_open
,
1882 .llseek
= seq_lseek
,
1883 .release
= single_release
,
1884 .owner
= THIS_MODULE
,
1887 static int ab8500_gpadc_aux1_print(struct seq_file
*s
, void *p
)
1891 struct ab8500_gpadc
*gpadc
;
1893 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1894 aux1_raw
= ab8500_gpadc_read_raw(gpadc
, ADC_AUX1
,
1895 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1896 aux1_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ADC_AUX1
,
1899 return seq_printf(s
, "%d,0x%X\n",
1900 aux1_convert
, aux1_raw
);
1903 static int ab8500_gpadc_aux1_open(struct inode
*inode
, struct file
*file
)
1905 return single_open(file
, ab8500_gpadc_aux1_print
, inode
->i_private
);
1908 static const struct file_operations ab8500_gpadc_aux1_fops
= {
1909 .open
= ab8500_gpadc_aux1_open
,
1911 .llseek
= seq_lseek
,
1912 .release
= single_release
,
1913 .owner
= THIS_MODULE
,
1916 static int ab8500_gpadc_aux2_print(struct seq_file
*s
, void *p
)
1920 struct ab8500_gpadc
*gpadc
;
1922 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1923 aux2_raw
= ab8500_gpadc_read_raw(gpadc
, ADC_AUX2
,
1924 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1925 aux2_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ADC_AUX2
,
1928 return seq_printf(s
, "%d,0x%X\n",
1929 aux2_convert
, aux2_raw
);
1932 static int ab8500_gpadc_aux2_open(struct inode
*inode
, struct file
*file
)
1934 return single_open(file
, ab8500_gpadc_aux2_print
, inode
->i_private
);
1937 static const struct file_operations ab8500_gpadc_aux2_fops
= {
1938 .open
= ab8500_gpadc_aux2_open
,
1940 .llseek
= seq_lseek
,
1941 .release
= single_release
,
1942 .owner
= THIS_MODULE
,
1945 static int ab8500_gpadc_main_bat_v_print(struct seq_file
*s
, void *p
)
1948 int main_bat_v_convert
;
1949 struct ab8500_gpadc
*gpadc
;
1951 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1952 main_bat_v_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_BAT_V
,
1953 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1954 main_bat_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, MAIN_BAT_V
,
1957 return seq_printf(s
, "%d,0x%X\n",
1958 main_bat_v_convert
, main_bat_v_raw
);
1961 static int ab8500_gpadc_main_bat_v_open(struct inode
*inode
,
1964 return single_open(file
, ab8500_gpadc_main_bat_v_print
, inode
->i_private
);
1967 static const struct file_operations ab8500_gpadc_main_bat_v_fops
= {
1968 .open
= ab8500_gpadc_main_bat_v_open
,
1970 .llseek
= seq_lseek
,
1971 .release
= single_release
,
1972 .owner
= THIS_MODULE
,
1975 static int ab8500_gpadc_vbus_v_print(struct seq_file
*s
, void *p
)
1979 struct ab8500_gpadc
*gpadc
;
1981 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1982 vbus_v_raw
= ab8500_gpadc_read_raw(gpadc
, VBUS_V
,
1983 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1984 vbus_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, VBUS_V
,
1987 return seq_printf(s
, "%d,0x%X\n",
1988 vbus_v_convert
, vbus_v_raw
);
1991 static int ab8500_gpadc_vbus_v_open(struct inode
*inode
, struct file
*file
)
1993 return single_open(file
, ab8500_gpadc_vbus_v_print
, inode
->i_private
);
1996 static const struct file_operations ab8500_gpadc_vbus_v_fops
= {
1997 .open
= ab8500_gpadc_vbus_v_open
,
1999 .llseek
= seq_lseek
,
2000 .release
= single_release
,
2001 .owner
= THIS_MODULE
,
2004 static int ab8500_gpadc_main_charger_c_print(struct seq_file
*s
, void *p
)
2006 int main_charger_c_raw
;
2007 int main_charger_c_convert
;
2008 struct ab8500_gpadc
*gpadc
;
2010 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2011 main_charger_c_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_CHARGER_C
,
2012 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2013 main_charger_c_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2014 MAIN_CHARGER_C
, main_charger_c_raw
);
2016 return seq_printf(s
, "%d,0x%X\n",
2017 main_charger_c_convert
, main_charger_c_raw
);
2020 static int ab8500_gpadc_main_charger_c_open(struct inode
*inode
,
2023 return single_open(file
, ab8500_gpadc_main_charger_c_print
,
2027 static const struct file_operations ab8500_gpadc_main_charger_c_fops
= {
2028 .open
= ab8500_gpadc_main_charger_c_open
,
2030 .llseek
= seq_lseek
,
2031 .release
= single_release
,
2032 .owner
= THIS_MODULE
,
2035 static int ab8500_gpadc_usb_charger_c_print(struct seq_file
*s
, void *p
)
2037 int usb_charger_c_raw
;
2038 int usb_charger_c_convert
;
2039 struct ab8500_gpadc
*gpadc
;
2041 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2042 usb_charger_c_raw
= ab8500_gpadc_read_raw(gpadc
, USB_CHARGER_C
,
2043 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2044 usb_charger_c_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2045 USB_CHARGER_C
, usb_charger_c_raw
);
2047 return seq_printf(s
, "%d,0x%X\n",
2048 usb_charger_c_convert
, usb_charger_c_raw
);
2051 static int ab8500_gpadc_usb_charger_c_open(struct inode
*inode
,
2054 return single_open(file
, ab8500_gpadc_usb_charger_c_print
,
2058 static const struct file_operations ab8500_gpadc_usb_charger_c_fops
= {
2059 .open
= ab8500_gpadc_usb_charger_c_open
,
2061 .llseek
= seq_lseek
,
2062 .release
= single_release
,
2063 .owner
= THIS_MODULE
,
2066 static int ab8500_gpadc_bk_bat_v_print(struct seq_file
*s
, void *p
)
2069 int bk_bat_v_convert
;
2070 struct ab8500_gpadc
*gpadc
;
2072 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2073 bk_bat_v_raw
= ab8500_gpadc_read_raw(gpadc
, BK_BAT_V
,
2074 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2075 bk_bat_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2076 BK_BAT_V
, bk_bat_v_raw
);
2078 return seq_printf(s
, "%d,0x%X\n",
2079 bk_bat_v_convert
, bk_bat_v_raw
);
2082 static int ab8500_gpadc_bk_bat_v_open(struct inode
*inode
, struct file
*file
)
2084 return single_open(file
, ab8500_gpadc_bk_bat_v_print
, inode
->i_private
);
2087 static const struct file_operations ab8500_gpadc_bk_bat_v_fops
= {
2088 .open
= ab8500_gpadc_bk_bat_v_open
,
2090 .llseek
= seq_lseek
,
2091 .release
= single_release
,
2092 .owner
= THIS_MODULE
,
2095 static int ab8500_gpadc_die_temp_print(struct seq_file
*s
, void *p
)
2098 int die_temp_convert
;
2099 struct ab8500_gpadc
*gpadc
;
2101 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2102 die_temp_raw
= ab8500_gpadc_read_raw(gpadc
, DIE_TEMP
,
2103 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2104 die_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, DIE_TEMP
,
2107 return seq_printf(s
, "%d,0x%X\n",
2108 die_temp_convert
, die_temp_raw
);
2111 static int ab8500_gpadc_die_temp_open(struct inode
*inode
, struct file
*file
)
2113 return single_open(file
, ab8500_gpadc_die_temp_print
, inode
->i_private
);
2116 static const struct file_operations ab8500_gpadc_die_temp_fops
= {
2117 .open
= ab8500_gpadc_die_temp_open
,
2119 .llseek
= seq_lseek
,
2120 .release
= single_release
,
2121 .owner
= THIS_MODULE
,
2124 static int ab8500_gpadc_usb_id_print(struct seq_file
*s
, void *p
)
2128 struct ab8500_gpadc
*gpadc
;
2130 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2131 usb_id_raw
= ab8500_gpadc_read_raw(gpadc
, USB_ID
,
2132 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2133 usb_id_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, USB_ID
,
2136 return seq_printf(s
, "%d,0x%X\n",
2137 usb_id_convert
, usb_id_raw
);
2140 static int ab8500_gpadc_usb_id_open(struct inode
*inode
, struct file
*file
)
2142 return single_open(file
, ab8500_gpadc_usb_id_print
, inode
->i_private
);
2145 static const struct file_operations ab8500_gpadc_usb_id_fops
= {
2146 .open
= ab8500_gpadc_usb_id_open
,
2148 .llseek
= seq_lseek
,
2149 .release
= single_release
,
2150 .owner
= THIS_MODULE
,
2153 static int ab8540_gpadc_xtal_temp_print(struct seq_file
*s
, void *p
)
2156 int xtal_temp_convert
;
2157 struct ab8500_gpadc
*gpadc
;
2159 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2160 xtal_temp_raw
= ab8500_gpadc_read_raw(gpadc
, XTAL_TEMP
,
2161 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2162 xtal_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, XTAL_TEMP
,
2165 return seq_printf(s
, "%d,0x%X\n",
2166 xtal_temp_convert
, xtal_temp_raw
);
2169 static int ab8540_gpadc_xtal_temp_open(struct inode
*inode
, struct file
*file
)
2171 return single_open(file
, ab8540_gpadc_xtal_temp_print
,
2175 static const struct file_operations ab8540_gpadc_xtal_temp_fops
= {
2176 .open
= ab8540_gpadc_xtal_temp_open
,
2178 .llseek
= seq_lseek
,
2179 .release
= single_release
,
2180 .owner
= THIS_MODULE
,
2183 static int ab8540_gpadc_vbat_true_meas_print(struct seq_file
*s
, void *p
)
2185 int vbat_true_meas_raw
;
2186 int vbat_true_meas_convert
;
2187 struct ab8500_gpadc
*gpadc
;
2189 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2190 vbat_true_meas_raw
= ab8500_gpadc_read_raw(gpadc
, VBAT_TRUE_MEAS
,
2191 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2192 vbat_true_meas_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, VBAT_TRUE_MEAS
,
2193 vbat_true_meas_raw
);
2195 return seq_printf(s
, "%d,0x%X\n",
2196 vbat_true_meas_convert
, vbat_true_meas_raw
);
2199 static int ab8540_gpadc_vbat_true_meas_open(struct inode
*inode
,
2202 return single_open(file
, ab8540_gpadc_vbat_true_meas_print
,
2206 static const struct file_operations ab8540_gpadc_vbat_true_meas_fops
= {
2207 .open
= ab8540_gpadc_vbat_true_meas_open
,
2209 .llseek
= seq_lseek
,
2210 .release
= single_release
,
2211 .owner
= THIS_MODULE
,
2214 static int ab8540_gpadc_bat_ctrl_and_ibat_print(struct seq_file
*s
, void *p
)
2217 int bat_ctrl_convert
;
2220 struct ab8500_gpadc
*gpadc
;
2222 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2223 bat_ctrl_raw
= ab8500_gpadc_double_read_raw(gpadc
, BAT_CTRL_AND_IBAT
,
2224 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2226 bat_ctrl_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, BAT_CTRL
,
2228 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2231 return seq_printf(s
, "%d,0x%X\n" "%d,0x%X\n",
2232 bat_ctrl_convert
, bat_ctrl_raw
,
2233 ibat_convert
, ibat_raw
);
2236 static int ab8540_gpadc_bat_ctrl_and_ibat_open(struct inode
*inode
,
2239 return single_open(file
, ab8540_gpadc_bat_ctrl_and_ibat_print
,
2243 static const struct file_operations ab8540_gpadc_bat_ctrl_and_ibat_fops
= {
2244 .open
= ab8540_gpadc_bat_ctrl_and_ibat_open
,
2246 .llseek
= seq_lseek
,
2247 .release
= single_release
,
2248 .owner
= THIS_MODULE
,
2251 static int ab8540_gpadc_vbat_meas_and_ibat_print(struct seq_file
*s
, void *p
)
2254 int vbat_meas_convert
;
2257 struct ab8500_gpadc
*gpadc
;
2259 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2260 vbat_meas_raw
= ab8500_gpadc_double_read_raw(gpadc
, VBAT_MEAS_AND_IBAT
,
2261 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2262 vbat_meas_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, MAIN_BAT_V
,
2264 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2267 return seq_printf(s
, "%d,0x%X\n" "%d,0x%X\n",
2268 vbat_meas_convert
, vbat_meas_raw
,
2269 ibat_convert
, ibat_raw
);
2272 static int ab8540_gpadc_vbat_meas_and_ibat_open(struct inode
*inode
,
2275 return single_open(file
, ab8540_gpadc_vbat_meas_and_ibat_print
,
2279 static const struct file_operations ab8540_gpadc_vbat_meas_and_ibat_fops
= {
2280 .open
= ab8540_gpadc_vbat_meas_and_ibat_open
,
2282 .llseek
= seq_lseek
,
2283 .release
= single_release
,
2284 .owner
= THIS_MODULE
,
2287 static int ab8540_gpadc_vbat_true_meas_and_ibat_print(struct seq_file
*s
, void *p
)
2289 int vbat_true_meas_raw
;
2290 int vbat_true_meas_convert
;
2293 struct ab8500_gpadc
*gpadc
;
2295 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2296 vbat_true_meas_raw
= ab8500_gpadc_double_read_raw(gpadc
,
2297 VBAT_TRUE_MEAS_AND_IBAT
, avg_sample
, trig_edge
,
2298 trig_timer
, conv_type
, &ibat_raw
);
2299 vbat_true_meas_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2300 VBAT_TRUE_MEAS
, vbat_true_meas_raw
);
2301 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2304 return seq_printf(s
, "%d,0x%X\n" "%d,0x%X\n",
2305 vbat_true_meas_convert
, vbat_true_meas_raw
,
2306 ibat_convert
, ibat_raw
);
2309 static int ab8540_gpadc_vbat_true_meas_and_ibat_open(struct inode
*inode
,
2312 return single_open(file
, ab8540_gpadc_vbat_true_meas_and_ibat_print
,
2316 static const struct file_operations ab8540_gpadc_vbat_true_meas_and_ibat_fops
= {
2317 .open
= ab8540_gpadc_vbat_true_meas_and_ibat_open
,
2319 .llseek
= seq_lseek
,
2320 .release
= single_release
,
2321 .owner
= THIS_MODULE
,
2324 static int ab8540_gpadc_bat_temp_and_ibat_print(struct seq_file
*s
, void *p
)
2327 int bat_temp_convert
;
2330 struct ab8500_gpadc
*gpadc
;
2332 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2333 bat_temp_raw
= ab8500_gpadc_double_read_raw(gpadc
, BAT_TEMP_AND_IBAT
,
2334 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2335 bat_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, BTEMP_BALL
,
2337 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2340 return seq_printf(s
, "%d,0x%X\n" "%d,0x%X\n",
2341 bat_temp_convert
, bat_temp_raw
,
2342 ibat_convert
, ibat_raw
);
2345 static int ab8540_gpadc_bat_temp_and_ibat_open(struct inode
*inode
,
2348 return single_open(file
, ab8540_gpadc_bat_temp_and_ibat_print
,
2352 static const struct file_operations ab8540_gpadc_bat_temp_and_ibat_fops
= {
2353 .open
= ab8540_gpadc_bat_temp_and_ibat_open
,
2355 .llseek
= seq_lseek
,
2356 .release
= single_release
,
2357 .owner
= THIS_MODULE
,
2360 static int ab8540_gpadc_otp_cal_print(struct seq_file
*s
, void *p
)
2362 struct ab8500_gpadc
*gpadc
;
2363 u16 vmain_l
, vmain_h
, btemp_l
, btemp_h
;
2364 u16 vbat_l
, vbat_h
, ibat_l
, ibat_h
;
2366 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2367 ab8540_gpadc_get_otp(gpadc
, &vmain_l
, &vmain_h
, &btemp_l
, &btemp_h
,
2368 &vbat_l
, &vbat_h
, &ibat_l
, &ibat_h
);
2369 return seq_printf(s
, "VMAIN_L:0x%X\n"
2377 vmain_l
, vmain_h
, btemp_l
, btemp_h
, vbat_l
, vbat_h
, ibat_l
, ibat_h
);
2380 static int ab8540_gpadc_otp_cal_open(struct inode
*inode
, struct file
*file
)
2382 return single_open(file
, ab8540_gpadc_otp_cal_print
, inode
->i_private
);
2385 static const struct file_operations ab8540_gpadc_otp_calib_fops
= {
2386 .open
= ab8540_gpadc_otp_cal_open
,
2388 .llseek
= seq_lseek
,
2389 .release
= single_release
,
2390 .owner
= THIS_MODULE
,
2393 static int ab8500_gpadc_avg_sample_print(struct seq_file
*s
, void *p
)
2395 return seq_printf(s
, "%d\n", avg_sample
);
2398 static int ab8500_gpadc_avg_sample_open(struct inode
*inode
, struct file
*file
)
2400 return single_open(file
, ab8500_gpadc_avg_sample_print
,
2404 static ssize_t
ab8500_gpadc_avg_sample_write(struct file
*file
,
2405 const char __user
*user_buf
,
2406 size_t count
, loff_t
*ppos
)
2408 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2409 unsigned long user_avg_sample
;
2412 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_avg_sample
);
2416 if ((user_avg_sample
== SAMPLE_1
) || (user_avg_sample
== SAMPLE_4
)
2417 || (user_avg_sample
== SAMPLE_8
)
2418 || (user_avg_sample
== SAMPLE_16
)) {
2419 avg_sample
= (u8
) user_avg_sample
;
2421 dev_err(dev
, "debugfs error input: "
2422 "should be egal to 1, 4, 8 or 16\n");
2429 static const struct file_operations ab8500_gpadc_avg_sample_fops
= {
2430 .open
= ab8500_gpadc_avg_sample_open
,
2432 .write
= ab8500_gpadc_avg_sample_write
,
2433 .llseek
= seq_lseek
,
2434 .release
= single_release
,
2435 .owner
= THIS_MODULE
,
2438 static int ab8500_gpadc_trig_edge_print(struct seq_file
*s
, void *p
)
2440 return seq_printf(s
, "%d\n", trig_edge
);
2443 static int ab8500_gpadc_trig_edge_open(struct inode
*inode
, struct file
*file
)
2445 return single_open(file
, ab8500_gpadc_trig_edge_print
,
2449 static ssize_t
ab8500_gpadc_trig_edge_write(struct file
*file
,
2450 const char __user
*user_buf
,
2451 size_t count
, loff_t
*ppos
)
2453 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2454 unsigned long user_trig_edge
;
2457 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_trig_edge
);
2461 if ((user_trig_edge
== RISING_EDGE
)
2462 || (user_trig_edge
== FALLING_EDGE
)) {
2463 trig_edge
= (u8
) user_trig_edge
;
2465 dev_err(dev
, "Wrong input:\n"
2466 "Enter 0. Rising edge\n"
2467 "Enter 1. Falling edge\n");
2474 static const struct file_operations ab8500_gpadc_trig_edge_fops
= {
2475 .open
= ab8500_gpadc_trig_edge_open
,
2477 .write
= ab8500_gpadc_trig_edge_write
,
2478 .llseek
= seq_lseek
,
2479 .release
= single_release
,
2480 .owner
= THIS_MODULE
,
2483 static int ab8500_gpadc_trig_timer_print(struct seq_file
*s
, void *p
)
2485 return seq_printf(s
, "%d\n", trig_timer
);
2488 static int ab8500_gpadc_trig_timer_open(struct inode
*inode
, struct file
*file
)
2490 return single_open(file
, ab8500_gpadc_trig_timer_print
,
2494 static ssize_t
ab8500_gpadc_trig_timer_write(struct file
*file
,
2495 const char __user
*user_buf
,
2496 size_t count
, loff_t
*ppos
)
2498 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2499 unsigned long user_trig_timer
;
2502 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_trig_timer
);
2506 if ((user_trig_timer
>= 0) && (user_trig_timer
<= 255)) {
2507 trig_timer
= (u8
) user_trig_timer
;
2509 dev_err(dev
, "debugfs error input: "
2510 "should be beetween 0 to 255\n");
2517 static const struct file_operations ab8500_gpadc_trig_timer_fops
= {
2518 .open
= ab8500_gpadc_trig_timer_open
,
2520 .write
= ab8500_gpadc_trig_timer_write
,
2521 .llseek
= seq_lseek
,
2522 .release
= single_release
,
2523 .owner
= THIS_MODULE
,
2526 static int ab8500_gpadc_conv_type_print(struct seq_file
*s
, void *p
)
2528 return seq_printf(s
, "%d\n", conv_type
);
2531 static int ab8500_gpadc_conv_type_open(struct inode
*inode
, struct file
*file
)
2533 return single_open(file
, ab8500_gpadc_conv_type_print
,
2537 static ssize_t
ab8500_gpadc_conv_type_write(struct file
*file
,
2538 const char __user
*user_buf
,
2539 size_t count
, loff_t
*ppos
)
2541 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2542 unsigned long user_conv_type
;
2545 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_conv_type
);
2549 if ((user_conv_type
== ADC_SW
)
2550 || (user_conv_type
== ADC_HW
)) {
2551 conv_type
= (u8
) user_conv_type
;
2553 dev_err(dev
, "Wrong input:\n"
2554 "Enter 0. ADC SW conversion\n"
2555 "Enter 1. ADC HW conversion\n");
2562 static const struct file_operations ab8500_gpadc_conv_type_fops
= {
2563 .open
= ab8500_gpadc_conv_type_open
,
2565 .write
= ab8500_gpadc_conv_type_write
,
2566 .llseek
= seq_lseek
,
2567 .release
= single_release
,
2568 .owner
= THIS_MODULE
,
2572 * return length of an ASCII numerical value, 0 is string is not a
2574 * string shall start at value 1st char.
2575 * string can be tailed with \0 or space or newline chars only.
2576 * value can be decimal or hexadecimal (prefixed 0x or 0X).
2578 static int strval_len(char *b
)
2581 if ((*s
== '0') && ((*(s
+1) == 'x') || (*(s
+1) == 'X'))) {
2583 for (; *s
&& (*s
!= ' ') && (*s
!= '\n'); s
++) {
2590 for (; *s
&& (*s
!= ' ') && (*s
!= '\n'); s
++) {
2599 * parse hwreg input data.
2600 * update global hwreg_cfg only if input data syntax is ok.
2602 static ssize_t
hwreg_common_write(char *b
, struct hwreg_cfg
*cfg
,
2605 uint write
, val
= 0;
2608 struct hwreg_cfg loc
= {
2609 .bank
= 0, /* default: invalid phys addr */
2610 .addr
= 0, /* default: invalid phys addr */
2611 .fmt
= 0, /* default: 32bit access, hex output */
2612 .mask
= 0xFFFFFFFF, /* default: no mask */
2613 .shift
= 0, /* default: no bit shift */
2616 /* read or write ? */
2617 if (!strncmp(b
, "read ", 5)) {
2620 } else if (!strncmp(b
, "write ", 6)) {
2626 /* OPTIONS -l|-w|-b -s -m -o */
2627 while ((*b
== ' ') || (*b
== '-')) {
2628 if (*(b
-1) != ' ') {
2632 if ((!strncmp(b
, "-d ", 3)) ||
2633 (!strncmp(b
, "-dec ", 5))) {
2634 b
+= (*(b
+2) == ' ') ? 3 : 5;
2636 } else if ((!strncmp(b
, "-h ", 3)) ||
2637 (!strncmp(b
, "-hex ", 5))) {
2638 b
+= (*(b
+2) == ' ') ? 3 : 5;
2640 } else if ((!strncmp(b
, "-m ", 3)) ||
2641 (!strncmp(b
, "-mask ", 6))) {
2642 b
+= (*(b
+2) == ' ') ? 3 : 6;
2643 if (strval_len(b
) == 0)
2645 loc
.mask
= simple_strtoul(b
, &b
, 0);
2646 } else if ((!strncmp(b
, "-s ", 3)) ||
2647 (!strncmp(b
, "-shift ", 7))) {
2648 b
+= (*(b
+2) == ' ') ? 3 : 7;
2649 if (strval_len(b
) == 0)
2651 loc
.shift
= simple_strtol(b
, &b
, 0);
2656 /* get arg BANK and ADDRESS */
2657 if (strval_len(b
) == 0)
2659 loc
.bank
= simple_strtoul(b
, &b
, 0);
2662 if (strval_len(b
) == 0)
2664 loc
.addr
= simple_strtoul(b
, &b
, 0);
2669 if (strval_len(b
) == 0)
2671 val
= simple_strtoul(b
, &b
, 0);
2674 /* args are ok, update target cfg (mainly for read) */
2677 #ifdef ABB_HWREG_DEBUG
2678 pr_warn("HWREG request: %s, %s, addr=0x%08X, mask=0x%X, shift=%d"
2679 "value=0x%X\n", (write
) ? "write" : "read",
2680 REG_FMT_DEC(cfg
) ? "decimal" : "hexa",
2681 cfg
->addr
, cfg
->mask
, cfg
->shift
, val
);
2687 ret
= abx500_get_register_interruptible(dev
,
2688 (u8
)cfg
->bank
, (u8
)cfg
->addr
, ®value
);
2690 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
2695 if (cfg
->shift
>= 0) {
2696 regvalue
&= ~(cfg
->mask
<< (cfg
->shift
));
2697 val
= (val
& cfg
->mask
) << (cfg
->shift
);
2699 regvalue
&= ~(cfg
->mask
>> (-cfg
->shift
));
2700 val
= (val
& cfg
->mask
) >> (-cfg
->shift
);
2702 val
= val
| regvalue
;
2704 ret
= abx500_set_register_interruptible(dev
,
2705 (u8
)cfg
->bank
, (u8
)cfg
->addr
, (u8
)val
);
2707 pr_err("abx500_set_reg failed %d, %d", ret
, __LINE__
);
2714 static ssize_t
ab8500_hwreg_write(struct file
*file
,
2715 const char __user
*user_buf
, size_t count
, loff_t
*ppos
)
2717 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2721 /* Get userspace string and assure termination */
2722 buf_size
= min(count
, (sizeof(buf
)-1));
2723 if (copy_from_user(buf
, user_buf
, buf_size
))
2727 /* get args and process */
2728 ret
= hwreg_common_write(buf
, &hwreg_cfg
, dev
);
2729 return (ret
) ? ret
: buf_size
;
2733 * - irq subscribe/unsubscribe stuff
2735 static int ab8500_subscribe_unsubscribe_print(struct seq_file
*s
, void *p
)
2737 seq_printf(s
, "%d\n", irq_first
);
2742 static int ab8500_subscribe_unsubscribe_open(struct inode
*inode
,
2745 return single_open(file
, ab8500_subscribe_unsubscribe_print
,
2750 * Userspace should use poll() on this file. When an event occur
2751 * the blocking poll will be released.
2753 static ssize_t
show_irq(struct device
*dev
,
2754 struct device_attribute
*attr
, char *buf
)
2757 unsigned int irq_index
;
2760 err
= kstrtoul(attr
->attr
.name
, 0, &name
);
2764 irq_index
= name
- irq_first
;
2765 if (irq_index
>= num_irqs
)
2768 return sprintf(buf
, "%u\n", irq_count
[irq_index
]);
2771 static ssize_t
ab8500_subscribe_write(struct file
*file
,
2772 const char __user
*user_buf
,
2773 size_t count
, loff_t
*ppos
)
2775 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2776 unsigned long user_val
;
2778 unsigned int irq_index
;
2780 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
2784 if (user_val
< irq_first
) {
2785 dev_err(dev
, "debugfs error input < %d\n", irq_first
);
2788 if (user_val
> irq_last
) {
2789 dev_err(dev
, "debugfs error input > %d\n", irq_last
);
2793 irq_index
= user_val
- irq_first
;
2794 if (irq_index
>= num_irqs
)
2798 * This will create a sysfs file named <irq-nr> which userspace can
2799 * use to select or poll and get the AB8500 events
2801 dev_attr
[irq_index
] = kmalloc(sizeof(struct device_attribute
),
2803 if (!dev_attr
[irq_index
])
2806 event_name
[irq_index
] = kmalloc(count
, GFP_KERNEL
);
2807 if (!event_name
[irq_index
])
2810 sprintf(event_name
[irq_index
], "%lu", user_val
);
2811 dev_attr
[irq_index
]->show
= show_irq
;
2812 dev_attr
[irq_index
]->store
= NULL
;
2813 dev_attr
[irq_index
]->attr
.name
= event_name
[irq_index
];
2814 dev_attr
[irq_index
]->attr
.mode
= S_IRUGO
;
2815 err
= sysfs_create_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2817 printk(KERN_ERR
"sysfs_create_file failed %d\n", err
);
2821 err
= request_threaded_irq(user_val
, NULL
, ab8500_debug_handler
,
2822 IRQF_SHARED
| IRQF_NO_SUSPEND
,
2823 "ab8500-debug", &dev
->kobj
);
2825 printk(KERN_ERR
"request_threaded_irq failed %d, %lu\n",
2827 sysfs_remove_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2834 static ssize_t
ab8500_unsubscribe_write(struct file
*file
,
2835 const char __user
*user_buf
,
2836 size_t count
, loff_t
*ppos
)
2838 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2839 unsigned long user_val
;
2841 unsigned int irq_index
;
2843 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
2847 if (user_val
< irq_first
) {
2848 dev_err(dev
, "debugfs error input < %d\n", irq_first
);
2851 if (user_val
> irq_last
) {
2852 dev_err(dev
, "debugfs error input > %d\n", irq_last
);
2856 irq_index
= user_val
- irq_first
;
2857 if (irq_index
>= num_irqs
)
2860 /* Set irq count to 0 when unsubscribe */
2861 irq_count
[irq_index
] = 0;
2863 if (dev_attr
[irq_index
])
2864 sysfs_remove_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2867 free_irq(user_val
, &dev
->kobj
);
2868 kfree(event_name
[irq_index
]);
2869 kfree(dev_attr
[irq_index
]);
2875 * - several deubgfs nodes fops
2878 static const struct file_operations ab8500_bank_fops
= {
2879 .open
= ab8500_bank_open
,
2880 .write
= ab8500_bank_write
,
2882 .llseek
= seq_lseek
,
2883 .release
= single_release
,
2884 .owner
= THIS_MODULE
,
2887 static const struct file_operations ab8500_address_fops
= {
2888 .open
= ab8500_address_open
,
2889 .write
= ab8500_address_write
,
2891 .llseek
= seq_lseek
,
2892 .release
= single_release
,
2893 .owner
= THIS_MODULE
,
2896 static const struct file_operations ab8500_val_fops
= {
2897 .open
= ab8500_val_open
,
2898 .write
= ab8500_val_write
,
2900 .llseek
= seq_lseek
,
2901 .release
= single_release
,
2902 .owner
= THIS_MODULE
,
2905 static const struct file_operations ab8500_interrupts_fops
= {
2906 .open
= ab8500_interrupts_open
,
2908 .llseek
= seq_lseek
,
2909 .release
= single_release
,
2910 .owner
= THIS_MODULE
,
2913 static const struct file_operations ab8500_subscribe_fops
= {
2914 .open
= ab8500_subscribe_unsubscribe_open
,
2915 .write
= ab8500_subscribe_write
,
2917 .llseek
= seq_lseek
,
2918 .release
= single_release
,
2919 .owner
= THIS_MODULE
,
2922 static const struct file_operations ab8500_unsubscribe_fops
= {
2923 .open
= ab8500_subscribe_unsubscribe_open
,
2924 .write
= ab8500_unsubscribe_write
,
2926 .llseek
= seq_lseek
,
2927 .release
= single_release
,
2928 .owner
= THIS_MODULE
,
2931 static const struct file_operations ab8500_hwreg_fops
= {
2932 .open
= ab8500_hwreg_open
,
2933 .write
= ab8500_hwreg_write
,
2935 .llseek
= seq_lseek
,
2936 .release
= single_release
,
2937 .owner
= THIS_MODULE
,
2940 static struct dentry
*ab8500_dir
;
2941 static struct dentry
*ab8500_gpadc_dir
;
2943 static int ab8500_debug_probe(struct platform_device
*plf
)
2945 struct dentry
*file
;
2946 struct ab8500
*ab8500
;
2947 struct resource
*res
;
2948 debug_bank
= AB8500_MISC
;
2949 debug_address
= AB8500_REV_REG
& 0x00FF;
2951 ab8500
= dev_get_drvdata(plf
->dev
.parent
);
2952 num_irqs
= ab8500
->mask_size
;
2954 irq_count
= devm_kzalloc(&plf
->dev
,
2955 sizeof(*irq_count
)*num_irqs
, GFP_KERNEL
);
2959 dev_attr
= devm_kzalloc(&plf
->dev
,
2960 sizeof(*dev_attr
)*num_irqs
,GFP_KERNEL
);
2964 event_name
= devm_kzalloc(&plf
->dev
,
2965 sizeof(*event_name
)*num_irqs
, GFP_KERNEL
);
2969 res
= platform_get_resource_byname(plf
, 0, "IRQ_AB8500");
2971 dev_err(&plf
->dev
, "AB8500 irq not found, err %d\n",
2975 irq_ab8500
= res
->start
;
2977 irq_first
= platform_get_irq_byname(plf
, "IRQ_FIRST");
2978 if (irq_first
< 0) {
2979 dev_err(&plf
->dev
, "First irq not found, err %d\n",
2984 irq_last
= platform_get_irq_byname(plf
, "IRQ_LAST");
2986 dev_err(&plf
->dev
, "Last irq not found, err %d\n",
2991 ab8500_dir
= debugfs_create_dir(AB8500_NAME_STRING
, NULL
);
2995 ab8500_gpadc_dir
= debugfs_create_dir(AB8500_ADC_NAME_STRING
,
2997 if (!ab8500_gpadc_dir
)
3000 file
= debugfs_create_file("all-bank-registers", S_IRUGO
,
3001 ab8500_dir
, &plf
->dev
, &ab8500_registers_fops
);
3005 file
= debugfs_create_file("all-banks", S_IRUGO
,
3006 ab8500_dir
, &plf
->dev
, &ab8500_all_banks_fops
);
3010 file
= debugfs_create_file("register-bank", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3011 ab8500_dir
, &plf
->dev
, &ab8500_bank_fops
);
3015 file
= debugfs_create_file("register-address", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3016 ab8500_dir
, &plf
->dev
, &ab8500_address_fops
);
3020 file
= debugfs_create_file("register-value", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3021 ab8500_dir
, &plf
->dev
, &ab8500_val_fops
);
3025 file
= debugfs_create_file("irq-subscribe", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3026 ab8500_dir
, &plf
->dev
, &ab8500_subscribe_fops
);
3030 if (is_ab8500(ab8500
)) {
3031 debug_ranges
= ab8500_debug_ranges
;
3032 num_interrupt_lines
= AB8500_NR_IRQS
;
3033 } else if (is_ab8505(ab8500
)) {
3034 debug_ranges
= ab8505_debug_ranges
;
3035 num_interrupt_lines
= AB8505_NR_IRQS
;
3036 } else if (is_ab9540(ab8500
)) {
3037 debug_ranges
= ab8505_debug_ranges
;
3038 num_interrupt_lines
= AB9540_NR_IRQS
;
3039 } else if (is_ab8540(ab8500
)) {
3040 debug_ranges
= ab8540_debug_ranges
;
3041 num_interrupt_lines
= AB8540_NR_IRQS
;
3044 file
= debugfs_create_file("interrupts", (S_IRUGO
),
3045 ab8500_dir
, &plf
->dev
, &ab8500_interrupts_fops
);
3049 file
= debugfs_create_file("irq-unsubscribe", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3050 ab8500_dir
, &plf
->dev
, &ab8500_unsubscribe_fops
);
3054 file
= debugfs_create_file("hwreg", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3055 ab8500_dir
, &plf
->dev
, &ab8500_hwreg_fops
);
3059 file
= debugfs_create_file("all-modem-registers", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3060 ab8500_dir
, &plf
->dev
, &ab8500_modem_fops
);
3064 file
= debugfs_create_file("bat_ctrl", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3065 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_bat_ctrl_fops
);
3069 file
= debugfs_create_file("btemp_ball", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3070 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_btemp_ball_fops
);
3074 file
= debugfs_create_file("main_charger_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3075 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_main_charger_v_fops
);
3079 file
= debugfs_create_file("acc_detect1", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3080 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_acc_detect1_fops
);
3084 file
= debugfs_create_file("acc_detect2", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3085 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_acc_detect2_fops
);
3089 file
= debugfs_create_file("adc_aux1", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3090 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_aux1_fops
);
3094 file
= debugfs_create_file("adc_aux2", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3095 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_aux2_fops
);
3099 file
= debugfs_create_file("main_bat_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3100 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_main_bat_v_fops
);
3104 file
= debugfs_create_file("vbus_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3105 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_vbus_v_fops
);
3109 file
= debugfs_create_file("main_charger_c", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3110 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_main_charger_c_fops
);
3114 file
= debugfs_create_file("usb_charger_c", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3115 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_usb_charger_c_fops
);
3119 file
= debugfs_create_file("bk_bat_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3120 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_bk_bat_v_fops
);
3124 file
= debugfs_create_file("die_temp", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3125 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_die_temp_fops
);
3129 file
= debugfs_create_file("usb_id", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3130 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_usb_id_fops
);
3134 if (is_ab8540(ab8500
)) {
3135 file
= debugfs_create_file("xtal_temp", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3136 ab8500_gpadc_dir
, &plf
->dev
, &ab8540_gpadc_xtal_temp_fops
);
3139 file
= debugfs_create_file("vbattruemeas", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3140 ab8500_gpadc_dir
, &plf
->dev
,
3141 &ab8540_gpadc_vbat_true_meas_fops
);
3144 file
= debugfs_create_file("batctrl_and_ibat",
3145 (S_IRUGO
| S_IWUGO
), ab8500_gpadc_dir
,
3146 &plf
->dev
, &ab8540_gpadc_bat_ctrl_and_ibat_fops
);
3149 file
= debugfs_create_file("vbatmeas_and_ibat",
3150 (S_IRUGO
| S_IWUGO
), ab8500_gpadc_dir
,
3152 &ab8540_gpadc_vbat_meas_and_ibat_fops
);
3155 file
= debugfs_create_file("vbattruemeas_and_ibat",
3156 (S_IRUGO
| S_IWUGO
), ab8500_gpadc_dir
,
3158 &ab8540_gpadc_vbat_true_meas_and_ibat_fops
);
3161 file
= debugfs_create_file("battemp_and_ibat",
3162 (S_IRUGO
| S_IWUGO
), ab8500_gpadc_dir
,
3163 &plf
->dev
, &ab8540_gpadc_bat_temp_and_ibat_fops
);
3166 file
= debugfs_create_file("otp_calib", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3167 ab8500_gpadc_dir
, &plf
->dev
, &ab8540_gpadc_otp_calib_fops
);
3171 file
= debugfs_create_file("avg_sample", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3172 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_avg_sample_fops
);
3176 file
= debugfs_create_file("trig_edge", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3177 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_trig_edge_fops
);
3181 file
= debugfs_create_file("trig_timer", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3182 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_trig_timer_fops
);
3186 file
= debugfs_create_file("conv_type", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3187 ab8500_gpadc_dir
, &plf
->dev
, &ab8500_gpadc_conv_type_fops
);
3195 debugfs_remove_recursive(ab8500_dir
);
3196 dev_err(&plf
->dev
, "failed to create debugfs entries.\n");
3201 static int ab8500_debug_remove(struct platform_device
*plf
)
3203 debugfs_remove_recursive(ab8500_dir
);
3208 static struct platform_driver ab8500_debug_driver
= {
3210 .name
= "ab8500-debug",
3211 .owner
= THIS_MODULE
,
3213 .probe
= ab8500_debug_probe
,
3214 .remove
= ab8500_debug_remove
3217 static int __init
ab8500_debug_init(void)
3219 return platform_driver_register(&ab8500_debug_driver
);
3222 static void __exit
ab8500_debug_exit(void)
3224 platform_driver_unregister(&ab8500_debug_driver
);
3226 subsys_initcall(ab8500_debug_init
);
3227 module_exit(ab8500_debug_exit
);
3229 MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
3230 MODULE_DESCRIPTION("AB8500 DEBUG");
3231 MODULE_LICENSE("GPL v2");