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 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
[]) {
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
[]) {
324 .range
= (struct ab8500_reg_range
[]) {
333 .range
= (struct ab8500_reg_range
[]) {
372 [AB8500_GAS_GAUGE
] = {
374 .range
= (struct ab8500_reg_range
[]) {
389 [AB8500_DEVELOPMENT
] = {
391 .range
= (struct ab8500_reg_range
[]) {
400 .range
= (struct ab8500_reg_range
[]) {
409 .range
= (struct ab8500_reg_range
[]) {
416 [AB8500_INTERRUPT
] = {
422 .range
= (struct ab8500_reg_range
[]) {
431 .range
= (struct ab8500_reg_range
[]) {
482 [AB8500_OTP_EMUL
] = {
484 .range
= (struct ab8500_reg_range
[]) {
493 static struct ab8500_prcmu_ranges ab8505_debug_ranges
[AB8500_NUM_BANKS
] = {
498 [AB8500_SYS_CTRL1_BLOCK
] = {
500 .range
= (struct ab8500_reg_range
[]) {
523 [AB8500_SYS_CTRL2_BLOCK
] = {
525 .range
= (struct ab8500_reg_range
[]) {
548 [AB8500_REGU_CTRL1
] = {
550 .range
= (struct ab8500_reg_range
[]) {
565 [AB8500_REGU_CTRL2
] = {
567 .range
= (struct ab8500_reg_range
[]) {
593 * 0x80-0x8B are SIM registers and should
594 * not be accessed from here
600 .range
= (struct ab8500_reg_range
[]) {
623 [AB8500_ECI_AV_ACC
] = {
625 .range
= (struct ab8500_reg_range
[]) {
632 [AB8500_RESERVED
] = {
638 .range
= (struct ab8500_reg_range
[]) {
647 .range
= (struct ab8500_reg_range
[]) {
686 [AB8500_GAS_GAUGE
] = {
688 .range
= (struct ab8500_reg_range
[]) {
705 .range
= (struct ab8500_reg_range
[]) {
712 [AB8500_INTERRUPT
] = {
714 .range
= (struct ab8500_reg_range
[]) {
739 /* Latch registers should not be read here */
760 /* LatchHier registers should not be read here */
765 .range
= (struct ab8500_reg_range
[]) {
778 .range
= (struct ab8500_reg_range
[]) {
813 [AB8500_DEVELOPMENT
] = {
815 .range
= (struct ab8500_reg_range
[]) {
828 .range
= (struct ab8500_reg_range
[]) {
835 [AB8500_PROD_TEST
] = {
839 [AB8500_STE_TEST
] = {
843 [AB8500_OTP_EMUL
] = {
845 .range
= (struct ab8500_reg_range
[]) {
854 static struct ab8500_prcmu_ranges ab8540_debug_ranges
[AB8500_NUM_BANKS
] = {
855 [AB8500_M_FSM_RANK
] = {
857 .range
= (struct ab8500_reg_range
[]) {
864 [AB8500_SYS_CTRL1_BLOCK
] = {
866 .range
= (struct ab8500_reg_range
[]) {
893 [AB8500_SYS_CTRL2_BLOCK
] = {
895 .range
= (struct ab8500_reg_range
[]) {
918 [AB8500_REGU_CTRL1
] = {
920 .range
= (struct ab8500_reg_range
[]) {
939 [AB8500_REGU_CTRL2
] = {
941 .range
= (struct ab8500_reg_range
[]) {
978 .range
= (struct ab8500_reg_range
[]) {
999 .range
= (struct ab8500_reg_range
[]) {
1018 [AB8500_ECI_AV_ACC
] = {
1020 .range
= (struct ab8500_reg_range
[]) {
1031 [AB8500_RESERVED
] = {
1037 .range
= (struct ab8500_reg_range
[]) {
1056 [AB8500_CHARGER
] = {
1058 .range
= (struct ab8500_reg_range
[]) {
1101 [AB8500_GAS_GAUGE
] = {
1103 .range
= (struct ab8500_reg_range
[]) {
1120 .range
= (struct ab8500_reg_range
[]) {
1127 [AB8500_INTERRUPT
] = {
1129 .range
= (struct ab8500_reg_range
[]) {
1142 /* Latch registers should not be read here */
1155 /* LatchHier registers should not be read here */
1160 .range
= (struct ab8500_reg_range
[]) {
1177 .range
= (struct ab8500_reg_range
[]) {
1216 [AB8500_DEVELOPMENT
] = {
1218 .range
= (struct ab8500_reg_range
[]) {
1235 .range
= (struct ab8500_reg_range
[]) {
1250 [AB8500_PROD_TEST
] = {
1254 [AB8500_STE_TEST
] = {
1258 [AB8500_OTP_EMUL
] = {
1260 .range
= (struct ab8500_reg_range
[]) {
1270 static irqreturn_t
ab8500_debug_handler(int irq
, void *data
)
1273 struct kobject
*kobj
= (struct kobject
*)data
;
1274 unsigned int irq_abb
= irq
- irq_first
;
1276 if (irq_abb
< num_irqs
)
1277 irq_count
[irq_abb
]++;
1279 * This makes it possible to use poll for events (POLLPRI | POLLERR)
1280 * from userspace on sysfs file named <irq-nr>
1282 sprintf(buf
, "%d", irq
);
1283 sysfs_notify(kobj
, NULL
, buf
);
1288 /* Prints to seq_file or log_buf */
1289 static int ab8500_registers_print(struct device
*dev
, u32 bank
,
1294 for (i
= 0; i
< debug_ranges
[bank
].num_ranges
; i
++) {
1297 for (reg
= debug_ranges
[bank
].range
[i
].first
;
1298 reg
<= debug_ranges
[bank
].range
[i
].last
;
1303 err
= abx500_get_register_interruptible(dev
,
1304 (u8
)bank
, (u8
)reg
, &value
);
1306 dev_err(dev
, "ab->read fail %d\n", err
);
1311 seq_printf(s
, " [0x%02X/0x%02X]: 0x%02X\n",
1314 * Error is not returned here since
1315 * the output is wanted in any case
1317 if (seq_has_overflowed(s
))
1320 dev_info(dev
, " [0x%02X/0x%02X]: 0x%02X\n",
1329 static int ab8500_print_bank_registers(struct seq_file
*s
, void *p
)
1331 struct device
*dev
= s
->private;
1332 u32 bank
= debug_bank
;
1334 seq_puts(s
, AB8500_NAME_STRING
" register values:\n");
1336 seq_printf(s
, " bank 0x%02X:\n", bank
);
1338 return ab8500_registers_print(dev
, bank
, s
);
1341 static int ab8500_registers_open(struct inode
*inode
, struct file
*file
)
1343 return single_open(file
, ab8500_print_bank_registers
, inode
->i_private
);
1346 static const struct file_operations ab8500_registers_fops
= {
1347 .open
= ab8500_registers_open
,
1349 .llseek
= seq_lseek
,
1350 .release
= single_release
,
1351 .owner
= THIS_MODULE
,
1354 static int ab8500_print_all_banks(struct seq_file
*s
, void *p
)
1356 struct device
*dev
= s
->private;
1359 seq_puts(s
, AB8500_NAME_STRING
" register values:\n");
1361 for (i
= 0; i
< AB8500_NUM_BANKS
; i
++) {
1364 seq_printf(s
, " bank 0x%02X:\n", i
);
1365 err
= ab8500_registers_print(dev
, i
, s
);
1372 /* Dump registers to kernel log */
1373 void ab8500_dump_all_banks(struct device
*dev
)
1377 dev_info(dev
, "ab8500 register values:\n");
1379 for (i
= 1; i
< AB8500_NUM_BANKS
; i
++) {
1380 dev_info(dev
, " bank 0x%02X:\n", i
);
1381 ab8500_registers_print(dev
, i
, NULL
);
1385 /* Space for 500 registers. */
1386 #define DUMP_MAX_REGS 700
1387 static struct ab8500_register_dump
1392 } ab8500_complete_register_dump
[DUMP_MAX_REGS
];
1394 /* This shall only be called upon kernel panic! */
1395 void ab8500_dump_all_banks_to_mem(void)
1401 pr_info("Saving all ABB registers for crash analysis.\n");
1403 for (bank
= 0; bank
< AB8500_NUM_BANKS
; bank
++) {
1404 for (i
= 0; i
< debug_ranges
[bank
].num_ranges
; i
++) {
1407 for (reg
= debug_ranges
[bank
].range
[i
].first
;
1408 reg
<= debug_ranges
[bank
].range
[i
].last
;
1412 err
= prcmu_abb_read(bank
, reg
, &value
, 1);
1417 ab8500_complete_register_dump
[r
].bank
= bank
;
1418 ab8500_complete_register_dump
[r
].reg
= reg
;
1419 ab8500_complete_register_dump
[r
].value
= value
;
1423 if (r
>= DUMP_MAX_REGS
) {
1424 pr_err("%s: too many register to dump!\n",
1434 pr_info("Saved all ABB registers.\n");
1436 pr_info("Failed to save all ABB registers.\n");
1439 static int ab8500_all_banks_open(struct inode
*inode
, struct file
*file
)
1444 err
= single_open(file
, ab8500_print_all_banks
, inode
->i_private
);
1446 /* Default buf size in seq_read is not enough */
1447 s
= (struct seq_file
*)file
->private_data
;
1448 s
->size
= (PAGE_SIZE
* 2);
1449 s
->buf
= kmalloc(s
->size
, GFP_KERNEL
);
1451 single_release(inode
, file
);
1458 static const struct file_operations ab8500_all_banks_fops
= {
1459 .open
= ab8500_all_banks_open
,
1461 .llseek
= seq_lseek
,
1462 .release
= single_release
,
1463 .owner
= THIS_MODULE
,
1466 static int ab8500_bank_print(struct seq_file
*s
, void *p
)
1468 seq_printf(s
, "0x%02X\n", debug_bank
);
1472 static int ab8500_bank_open(struct inode
*inode
, struct file
*file
)
1474 return single_open(file
, ab8500_bank_print
, inode
->i_private
);
1477 static ssize_t
ab8500_bank_write(struct file
*file
,
1478 const char __user
*user_buf
,
1479 size_t count
, loff_t
*ppos
)
1481 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1482 unsigned long user_bank
;
1485 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_bank
);
1489 if (user_bank
>= AB8500_NUM_BANKS
) {
1490 dev_err(dev
, "debugfs error input > number of banks\n");
1494 debug_bank
= user_bank
;
1499 static int ab8500_address_print(struct seq_file
*s
, void *p
)
1501 seq_printf(s
, "0x%02X\n", debug_address
);
1505 static int ab8500_address_open(struct inode
*inode
, struct file
*file
)
1507 return single_open(file
, ab8500_address_print
, inode
->i_private
);
1510 static ssize_t
ab8500_address_write(struct file
*file
,
1511 const char __user
*user_buf
,
1512 size_t count
, loff_t
*ppos
)
1514 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1515 unsigned long user_address
;
1518 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_address
);
1522 if (user_address
> 0xff) {
1523 dev_err(dev
, "debugfs error input > 0xff\n");
1526 debug_address
= user_address
;
1531 static int ab8500_val_print(struct seq_file
*s
, void *p
)
1533 struct device
*dev
= s
->private;
1537 ret
= abx500_get_register_interruptible(dev
,
1538 (u8
)debug_bank
, (u8
)debug_address
, ®value
);
1540 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
1544 seq_printf(s
, "0x%02X\n", regvalue
);
1549 static int ab8500_val_open(struct inode
*inode
, struct file
*file
)
1551 return single_open(file
, ab8500_val_print
, inode
->i_private
);
1554 static ssize_t
ab8500_val_write(struct file
*file
,
1555 const char __user
*user_buf
,
1556 size_t count
, loff_t
*ppos
)
1558 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1559 unsigned long user_val
;
1562 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
1566 if (user_val
> 0xff) {
1567 dev_err(dev
, "debugfs error input > 0xff\n");
1570 err
= abx500_set_register_interruptible(dev
,
1571 (u8
)debug_bank
, debug_address
, (u8
)user_val
);
1573 pr_err("abx500_set_reg failed %d, %d", err
, __LINE__
);
1583 static u32 num_interrupts
[AB8500_MAX_NR_IRQS
];
1584 static u32 num_wake_interrupts
[AB8500_MAX_NR_IRQS
];
1585 static int num_interrupt_lines
;
1587 bool __attribute__((weak
)) suspend_test_wake_cause_interrupt_is_mine(u32 my_int
)
1592 void ab8500_debug_register_interrupt(int line
)
1594 if (line
< num_interrupt_lines
) {
1595 num_interrupts
[line
]++;
1596 if (suspend_test_wake_cause_interrupt_is_mine(irq_ab8500
))
1597 num_wake_interrupts
[line
]++;
1601 static int ab8500_interrupts_print(struct seq_file
*s
, void *p
)
1605 seq_puts(s
, "name: number: number of: wake:\n");
1607 for (line
= 0; line
< num_interrupt_lines
; line
++) {
1608 struct irq_desc
*desc
= irq_to_desc(line
+ irq_first
);
1610 seq_printf(s
, "%3i: %6i %4i",
1612 num_interrupts
[line
],
1613 num_wake_interrupts
[line
]);
1615 if (desc
&& desc
->name
)
1616 seq_printf(s
, "-%-8s", desc
->name
);
1617 if (desc
&& desc
->action
) {
1618 struct irqaction
*action
= desc
->action
;
1620 seq_printf(s
, " %s", action
->name
);
1621 while ((action
= action
->next
) != NULL
)
1622 seq_printf(s
, ", %s", action
->name
);
1630 static int ab8500_interrupts_open(struct inode
*inode
, struct file
*file
)
1632 return single_open(file
, ab8500_interrupts_print
, inode
->i_private
);
1636 * - HWREG DB8500 formated routines
1638 static int ab8500_hwreg_print(struct seq_file
*s
, void *d
)
1640 struct device
*dev
= s
->private;
1644 ret
= abx500_get_register_interruptible(dev
,
1645 (u8
)hwreg_cfg
.bank
, (u8
)hwreg_cfg
.addr
, ®value
);
1647 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
1652 if (hwreg_cfg
.shift
>= 0)
1653 regvalue
>>= hwreg_cfg
.shift
;
1655 regvalue
<<= -hwreg_cfg
.shift
;
1656 regvalue
&= hwreg_cfg
.mask
;
1658 if (REG_FMT_DEC(&hwreg_cfg
))
1659 seq_printf(s
, "%d\n", regvalue
);
1661 seq_printf(s
, "0x%02X\n", regvalue
);
1665 static int ab8500_hwreg_open(struct inode
*inode
, struct file
*file
)
1667 return single_open(file
, ab8500_hwreg_print
, inode
->i_private
);
1670 #define AB8500_SUPPLY_CONTROL_CONFIG_1 0x01
1671 #define AB8500_SUPPLY_CONTROL_REG 0x00
1672 #define AB8500_FIRST_SIM_REG 0x80
1673 #define AB8500_LAST_SIM_REG 0x8B
1674 #define AB8505_LAST_SIM_REG 0x8C
1676 static int ab8500_print_modem_registers(struct seq_file
*s
, void *p
)
1678 struct device
*dev
= s
->private;
1679 struct ab8500
*ab8500
;
1683 u32 bank
= AB8500_REGU_CTRL2
;
1684 u32 last_sim_reg
= AB8500_LAST_SIM_REG
;
1687 ab8500
= dev_get_drvdata(dev
->parent
);
1688 dev_warn(dev
, "WARNING! This operation can interfer with modem side\n"
1689 "and should only be done with care\n");
1691 err
= abx500_get_register_interruptible(dev
,
1692 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
, &orig_value
);
1694 dev_err(dev
, "ab->read fail %d\n", err
);
1697 /* Config 1 will allow APE side to read SIM registers */
1698 err
= abx500_set_register_interruptible(dev
,
1699 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
,
1700 AB8500_SUPPLY_CONTROL_CONFIG_1
);
1702 dev_err(dev
, "ab->write fail %d\n", err
);
1706 seq_printf(s
, " bank 0x%02X:\n", bank
);
1708 if (is_ab9540(ab8500
) || is_ab8505(ab8500
))
1709 last_sim_reg
= AB8505_LAST_SIM_REG
;
1711 for (reg
= AB8500_FIRST_SIM_REG
; reg
<= last_sim_reg
; reg
++) {
1712 err
= abx500_get_register_interruptible(dev
,
1715 dev_err(dev
, "ab->read fail %d\n", err
);
1718 seq_printf(s
, " [0x%02X/0x%02X]: 0x%02X\n", bank
, reg
, value
);
1720 err
= abx500_set_register_interruptible(dev
,
1721 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
, orig_value
);
1723 dev_err(dev
, "ab->write fail %d\n", err
);
1729 static int ab8500_modem_open(struct inode
*inode
, struct file
*file
)
1731 return single_open(file
, ab8500_print_modem_registers
,
1735 static const struct file_operations ab8500_modem_fops
= {
1736 .open
= ab8500_modem_open
,
1738 .llseek
= seq_lseek
,
1739 .release
= single_release
,
1740 .owner
= THIS_MODULE
,
1743 static int ab8500_gpadc_bat_ctrl_print(struct seq_file
*s
, void *p
)
1746 int bat_ctrl_convert
;
1747 struct ab8500_gpadc
*gpadc
;
1749 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1750 bat_ctrl_raw
= ab8500_gpadc_read_raw(gpadc
, BAT_CTRL
,
1751 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1752 bat_ctrl_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1753 BAT_CTRL
, bat_ctrl_raw
);
1755 seq_printf(s
, "%d,0x%X\n", bat_ctrl_convert
, bat_ctrl_raw
);
1760 static int ab8500_gpadc_bat_ctrl_open(struct inode
*inode
, struct file
*file
)
1762 return single_open(file
, ab8500_gpadc_bat_ctrl_print
,
1766 static const struct file_operations ab8500_gpadc_bat_ctrl_fops
= {
1767 .open
= ab8500_gpadc_bat_ctrl_open
,
1769 .llseek
= seq_lseek
,
1770 .release
= single_release
,
1771 .owner
= THIS_MODULE
,
1774 static int ab8500_gpadc_btemp_ball_print(struct seq_file
*s
, void *p
)
1777 int btemp_ball_convert
;
1778 struct ab8500_gpadc
*gpadc
;
1780 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1781 btemp_ball_raw
= ab8500_gpadc_read_raw(gpadc
, BTEMP_BALL
,
1782 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1783 btemp_ball_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, BTEMP_BALL
,
1786 seq_printf(s
, "%d,0x%X\n", btemp_ball_convert
, btemp_ball_raw
);
1791 static int ab8500_gpadc_btemp_ball_open(struct inode
*inode
,
1794 return single_open(file
, ab8500_gpadc_btemp_ball_print
,
1798 static const struct file_operations ab8500_gpadc_btemp_ball_fops
= {
1799 .open
= ab8500_gpadc_btemp_ball_open
,
1801 .llseek
= seq_lseek
,
1802 .release
= single_release
,
1803 .owner
= THIS_MODULE
,
1806 static int ab8500_gpadc_main_charger_v_print(struct seq_file
*s
, void *p
)
1808 int main_charger_v_raw
;
1809 int main_charger_v_convert
;
1810 struct ab8500_gpadc
*gpadc
;
1812 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1813 main_charger_v_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_CHARGER_V
,
1814 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1815 main_charger_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1816 MAIN_CHARGER_V
, main_charger_v_raw
);
1818 seq_printf(s
, "%d,0x%X\n", main_charger_v_convert
, main_charger_v_raw
);
1823 static int ab8500_gpadc_main_charger_v_open(struct inode
*inode
,
1826 return single_open(file
, ab8500_gpadc_main_charger_v_print
,
1830 static const struct file_operations ab8500_gpadc_main_charger_v_fops
= {
1831 .open
= ab8500_gpadc_main_charger_v_open
,
1833 .llseek
= seq_lseek
,
1834 .release
= single_release
,
1835 .owner
= THIS_MODULE
,
1838 static int ab8500_gpadc_acc_detect1_print(struct seq_file
*s
, void *p
)
1840 int acc_detect1_raw
;
1841 int acc_detect1_convert
;
1842 struct ab8500_gpadc
*gpadc
;
1844 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1845 acc_detect1_raw
= ab8500_gpadc_read_raw(gpadc
, ACC_DETECT1
,
1846 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1847 acc_detect1_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ACC_DETECT1
,
1850 seq_printf(s
, "%d,0x%X\n", acc_detect1_convert
, acc_detect1_raw
);
1855 static int ab8500_gpadc_acc_detect1_open(struct inode
*inode
,
1858 return single_open(file
, ab8500_gpadc_acc_detect1_print
,
1862 static const struct file_operations ab8500_gpadc_acc_detect1_fops
= {
1863 .open
= ab8500_gpadc_acc_detect1_open
,
1865 .llseek
= seq_lseek
,
1866 .release
= single_release
,
1867 .owner
= THIS_MODULE
,
1870 static int ab8500_gpadc_acc_detect2_print(struct seq_file
*s
, void *p
)
1872 int acc_detect2_raw
;
1873 int acc_detect2_convert
;
1874 struct ab8500_gpadc
*gpadc
;
1876 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1877 acc_detect2_raw
= ab8500_gpadc_read_raw(gpadc
, ACC_DETECT2
,
1878 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1879 acc_detect2_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1880 ACC_DETECT2
, acc_detect2_raw
);
1882 seq_printf(s
, "%d,0x%X\n", acc_detect2_convert
, acc_detect2_raw
);
1887 static int ab8500_gpadc_acc_detect2_open(struct inode
*inode
,
1890 return single_open(file
, ab8500_gpadc_acc_detect2_print
,
1894 static const struct file_operations ab8500_gpadc_acc_detect2_fops
= {
1895 .open
= ab8500_gpadc_acc_detect2_open
,
1897 .llseek
= seq_lseek
,
1898 .release
= single_release
,
1899 .owner
= THIS_MODULE
,
1902 static int ab8500_gpadc_aux1_print(struct seq_file
*s
, void *p
)
1906 struct ab8500_gpadc
*gpadc
;
1908 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1909 aux1_raw
= ab8500_gpadc_read_raw(gpadc
, ADC_AUX1
,
1910 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1911 aux1_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ADC_AUX1
,
1914 seq_printf(s
, "%d,0x%X\n", aux1_convert
, aux1_raw
);
1919 static int ab8500_gpadc_aux1_open(struct inode
*inode
, struct file
*file
)
1921 return single_open(file
, ab8500_gpadc_aux1_print
, inode
->i_private
);
1924 static const struct file_operations ab8500_gpadc_aux1_fops
= {
1925 .open
= ab8500_gpadc_aux1_open
,
1927 .llseek
= seq_lseek
,
1928 .release
= single_release
,
1929 .owner
= THIS_MODULE
,
1932 static int ab8500_gpadc_aux2_print(struct seq_file
*s
, void *p
)
1936 struct ab8500_gpadc
*gpadc
;
1938 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1939 aux2_raw
= ab8500_gpadc_read_raw(gpadc
, ADC_AUX2
,
1940 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1941 aux2_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ADC_AUX2
,
1944 seq_printf(s
, "%d,0x%X\n", aux2_convert
, aux2_raw
);
1949 static int ab8500_gpadc_aux2_open(struct inode
*inode
, struct file
*file
)
1951 return single_open(file
, ab8500_gpadc_aux2_print
, inode
->i_private
);
1954 static const struct file_operations ab8500_gpadc_aux2_fops
= {
1955 .open
= ab8500_gpadc_aux2_open
,
1957 .llseek
= seq_lseek
,
1958 .release
= single_release
,
1959 .owner
= THIS_MODULE
,
1962 static int ab8500_gpadc_main_bat_v_print(struct seq_file
*s
, void *p
)
1965 int main_bat_v_convert
;
1966 struct ab8500_gpadc
*gpadc
;
1968 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1969 main_bat_v_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_BAT_V
,
1970 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1971 main_bat_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, MAIN_BAT_V
,
1974 seq_printf(s
, "%d,0x%X\n", main_bat_v_convert
, main_bat_v_raw
);
1979 static int ab8500_gpadc_main_bat_v_open(struct inode
*inode
,
1982 return single_open(file
, ab8500_gpadc_main_bat_v_print
,
1986 static const struct file_operations ab8500_gpadc_main_bat_v_fops
= {
1987 .open
= ab8500_gpadc_main_bat_v_open
,
1989 .llseek
= seq_lseek
,
1990 .release
= single_release
,
1991 .owner
= THIS_MODULE
,
1994 static int ab8500_gpadc_vbus_v_print(struct seq_file
*s
, void *p
)
1998 struct ab8500_gpadc
*gpadc
;
2000 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2001 vbus_v_raw
= ab8500_gpadc_read_raw(gpadc
, VBUS_V
,
2002 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2003 vbus_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, VBUS_V
,
2006 seq_printf(s
, "%d,0x%X\n", vbus_v_convert
, vbus_v_raw
);
2011 static int ab8500_gpadc_vbus_v_open(struct inode
*inode
, struct file
*file
)
2013 return single_open(file
, ab8500_gpadc_vbus_v_print
, inode
->i_private
);
2016 static const struct file_operations ab8500_gpadc_vbus_v_fops
= {
2017 .open
= ab8500_gpadc_vbus_v_open
,
2019 .llseek
= seq_lseek
,
2020 .release
= single_release
,
2021 .owner
= THIS_MODULE
,
2024 static int ab8500_gpadc_main_charger_c_print(struct seq_file
*s
, void *p
)
2026 int main_charger_c_raw
;
2027 int main_charger_c_convert
;
2028 struct ab8500_gpadc
*gpadc
;
2030 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2031 main_charger_c_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_CHARGER_C
,
2032 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2033 main_charger_c_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2034 MAIN_CHARGER_C
, main_charger_c_raw
);
2036 seq_printf(s
, "%d,0x%X\n", main_charger_c_convert
, main_charger_c_raw
);
2041 static int ab8500_gpadc_main_charger_c_open(struct inode
*inode
,
2044 return single_open(file
, ab8500_gpadc_main_charger_c_print
,
2048 static const struct file_operations ab8500_gpadc_main_charger_c_fops
= {
2049 .open
= ab8500_gpadc_main_charger_c_open
,
2051 .llseek
= seq_lseek
,
2052 .release
= single_release
,
2053 .owner
= THIS_MODULE
,
2056 static int ab8500_gpadc_usb_charger_c_print(struct seq_file
*s
, void *p
)
2058 int usb_charger_c_raw
;
2059 int usb_charger_c_convert
;
2060 struct ab8500_gpadc
*gpadc
;
2062 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2063 usb_charger_c_raw
= ab8500_gpadc_read_raw(gpadc
, USB_CHARGER_C
,
2064 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2065 usb_charger_c_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2066 USB_CHARGER_C
, usb_charger_c_raw
);
2068 seq_printf(s
, "%d,0x%X\n", usb_charger_c_convert
, usb_charger_c_raw
);
2073 static int ab8500_gpadc_usb_charger_c_open(struct inode
*inode
,
2076 return single_open(file
, ab8500_gpadc_usb_charger_c_print
,
2080 static const struct file_operations ab8500_gpadc_usb_charger_c_fops
= {
2081 .open
= ab8500_gpadc_usb_charger_c_open
,
2083 .llseek
= seq_lseek
,
2084 .release
= single_release
,
2085 .owner
= THIS_MODULE
,
2088 static int ab8500_gpadc_bk_bat_v_print(struct seq_file
*s
, void *p
)
2091 int bk_bat_v_convert
;
2092 struct ab8500_gpadc
*gpadc
;
2094 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2095 bk_bat_v_raw
= ab8500_gpadc_read_raw(gpadc
, BK_BAT_V
,
2096 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2097 bk_bat_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2098 BK_BAT_V
, bk_bat_v_raw
);
2100 seq_printf(s
, "%d,0x%X\n", bk_bat_v_convert
, bk_bat_v_raw
);
2105 static int ab8500_gpadc_bk_bat_v_open(struct inode
*inode
, struct file
*file
)
2107 return single_open(file
, ab8500_gpadc_bk_bat_v_print
,
2111 static const struct file_operations ab8500_gpadc_bk_bat_v_fops
= {
2112 .open
= ab8500_gpadc_bk_bat_v_open
,
2114 .llseek
= seq_lseek
,
2115 .release
= single_release
,
2116 .owner
= THIS_MODULE
,
2119 static int ab8500_gpadc_die_temp_print(struct seq_file
*s
, void *p
)
2122 int die_temp_convert
;
2123 struct ab8500_gpadc
*gpadc
;
2125 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2126 die_temp_raw
= ab8500_gpadc_read_raw(gpadc
, DIE_TEMP
,
2127 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2128 die_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, DIE_TEMP
,
2131 seq_printf(s
, "%d,0x%X\n", die_temp_convert
, die_temp_raw
);
2136 static int ab8500_gpadc_die_temp_open(struct inode
*inode
, struct file
*file
)
2138 return single_open(file
, ab8500_gpadc_die_temp_print
,
2142 static const struct file_operations ab8500_gpadc_die_temp_fops
= {
2143 .open
= ab8500_gpadc_die_temp_open
,
2145 .llseek
= seq_lseek
,
2146 .release
= single_release
,
2147 .owner
= THIS_MODULE
,
2150 static int ab8500_gpadc_usb_id_print(struct seq_file
*s
, void *p
)
2154 struct ab8500_gpadc
*gpadc
;
2156 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2157 usb_id_raw
= ab8500_gpadc_read_raw(gpadc
, USB_ID
,
2158 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2159 usb_id_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, USB_ID
,
2162 seq_printf(s
, "%d,0x%X\n", usb_id_convert
, usb_id_raw
);
2167 static int ab8500_gpadc_usb_id_open(struct inode
*inode
, struct file
*file
)
2169 return single_open(file
, ab8500_gpadc_usb_id_print
, inode
->i_private
);
2172 static const struct file_operations ab8500_gpadc_usb_id_fops
= {
2173 .open
= ab8500_gpadc_usb_id_open
,
2175 .llseek
= seq_lseek
,
2176 .release
= single_release
,
2177 .owner
= THIS_MODULE
,
2180 static int ab8540_gpadc_xtal_temp_print(struct seq_file
*s
, void *p
)
2183 int xtal_temp_convert
;
2184 struct ab8500_gpadc
*gpadc
;
2186 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2187 xtal_temp_raw
= ab8500_gpadc_read_raw(gpadc
, XTAL_TEMP
,
2188 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2189 xtal_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, XTAL_TEMP
,
2192 seq_printf(s
, "%d,0x%X\n", xtal_temp_convert
, xtal_temp_raw
);
2197 static int ab8540_gpadc_xtal_temp_open(struct inode
*inode
, struct file
*file
)
2199 return single_open(file
, ab8540_gpadc_xtal_temp_print
,
2203 static const struct file_operations ab8540_gpadc_xtal_temp_fops
= {
2204 .open
= ab8540_gpadc_xtal_temp_open
,
2206 .llseek
= seq_lseek
,
2207 .release
= single_release
,
2208 .owner
= THIS_MODULE
,
2211 static int ab8540_gpadc_vbat_true_meas_print(struct seq_file
*s
, void *p
)
2213 int vbat_true_meas_raw
;
2214 int vbat_true_meas_convert
;
2215 struct ab8500_gpadc
*gpadc
;
2217 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2218 vbat_true_meas_raw
= ab8500_gpadc_read_raw(gpadc
, VBAT_TRUE_MEAS
,
2219 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2220 vbat_true_meas_convert
=
2221 ab8500_gpadc_ad_to_voltage(gpadc
, VBAT_TRUE_MEAS
,
2222 vbat_true_meas_raw
);
2224 seq_printf(s
, "%d,0x%X\n", vbat_true_meas_convert
, vbat_true_meas_raw
);
2229 static int ab8540_gpadc_vbat_true_meas_open(struct inode
*inode
,
2232 return single_open(file
, ab8540_gpadc_vbat_true_meas_print
,
2236 static const struct file_operations ab8540_gpadc_vbat_true_meas_fops
= {
2237 .open
= ab8540_gpadc_vbat_true_meas_open
,
2239 .llseek
= seq_lseek
,
2240 .release
= single_release
,
2241 .owner
= THIS_MODULE
,
2244 static int ab8540_gpadc_bat_ctrl_and_ibat_print(struct seq_file
*s
, void *p
)
2247 int bat_ctrl_convert
;
2250 struct ab8500_gpadc
*gpadc
;
2252 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2253 bat_ctrl_raw
= ab8500_gpadc_double_read_raw(gpadc
, BAT_CTRL_AND_IBAT
,
2254 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2256 bat_ctrl_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, BAT_CTRL
,
2258 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2264 bat_ctrl_convert
, bat_ctrl_raw
,
2265 ibat_convert
, ibat_raw
);
2270 static int ab8540_gpadc_bat_ctrl_and_ibat_open(struct inode
*inode
,
2273 return single_open(file
, ab8540_gpadc_bat_ctrl_and_ibat_print
,
2277 static const struct file_operations ab8540_gpadc_bat_ctrl_and_ibat_fops
= {
2278 .open
= ab8540_gpadc_bat_ctrl_and_ibat_open
,
2280 .llseek
= seq_lseek
,
2281 .release
= single_release
,
2282 .owner
= THIS_MODULE
,
2285 static int ab8540_gpadc_vbat_meas_and_ibat_print(struct seq_file
*s
, void *p
)
2288 int vbat_meas_convert
;
2291 struct ab8500_gpadc
*gpadc
;
2293 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2294 vbat_meas_raw
= ab8500_gpadc_double_read_raw(gpadc
, VBAT_MEAS_AND_IBAT
,
2295 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2296 vbat_meas_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, MAIN_BAT_V
,
2298 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2304 vbat_meas_convert
, vbat_meas_raw
,
2305 ibat_convert
, ibat_raw
);
2310 static int ab8540_gpadc_vbat_meas_and_ibat_open(struct inode
*inode
,
2313 return single_open(file
, ab8540_gpadc_vbat_meas_and_ibat_print
,
2317 static const struct file_operations ab8540_gpadc_vbat_meas_and_ibat_fops
= {
2318 .open
= ab8540_gpadc_vbat_meas_and_ibat_open
,
2320 .llseek
= seq_lseek
,
2321 .release
= single_release
,
2322 .owner
= THIS_MODULE
,
2325 static int ab8540_gpadc_vbat_true_meas_and_ibat_print(struct seq_file
*s
,
2328 int vbat_true_meas_raw
;
2329 int vbat_true_meas_convert
;
2332 struct ab8500_gpadc
*gpadc
;
2334 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2335 vbat_true_meas_raw
= ab8500_gpadc_double_read_raw(gpadc
,
2336 VBAT_TRUE_MEAS_AND_IBAT
, avg_sample
, trig_edge
,
2337 trig_timer
, conv_type
, &ibat_raw
);
2338 vbat_true_meas_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2339 VBAT_TRUE_MEAS
, vbat_true_meas_raw
);
2340 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2346 vbat_true_meas_convert
, vbat_true_meas_raw
,
2347 ibat_convert
, ibat_raw
);
2352 static int ab8540_gpadc_vbat_true_meas_and_ibat_open(struct inode
*inode
,
2355 return single_open(file
, ab8540_gpadc_vbat_true_meas_and_ibat_print
,
2359 static const struct file_operations
2360 ab8540_gpadc_vbat_true_meas_and_ibat_fops
= {
2361 .open
= ab8540_gpadc_vbat_true_meas_and_ibat_open
,
2363 .llseek
= seq_lseek
,
2364 .release
= single_release
,
2365 .owner
= THIS_MODULE
,
2368 static int ab8540_gpadc_bat_temp_and_ibat_print(struct seq_file
*s
, void *p
)
2371 int bat_temp_convert
;
2374 struct ab8500_gpadc
*gpadc
;
2376 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2377 bat_temp_raw
= ab8500_gpadc_double_read_raw(gpadc
, BAT_TEMP_AND_IBAT
,
2378 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2379 bat_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, BTEMP_BALL
,
2381 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2387 bat_temp_convert
, bat_temp_raw
,
2388 ibat_convert
, ibat_raw
);
2393 static int ab8540_gpadc_bat_temp_and_ibat_open(struct inode
*inode
,
2396 return single_open(file
, ab8540_gpadc_bat_temp_and_ibat_print
,
2400 static const struct file_operations ab8540_gpadc_bat_temp_and_ibat_fops
= {
2401 .open
= ab8540_gpadc_bat_temp_and_ibat_open
,
2403 .llseek
= seq_lseek
,
2404 .release
= single_release
,
2405 .owner
= THIS_MODULE
,
2408 static int ab8540_gpadc_otp_cal_print(struct seq_file
*s
, void *p
)
2410 struct ab8500_gpadc
*gpadc
;
2411 u16 vmain_l
, vmain_h
, btemp_l
, btemp_h
;
2412 u16 vbat_l
, vbat_h
, ibat_l
, ibat_h
;
2414 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2415 ab8540_gpadc_get_otp(gpadc
, &vmain_l
, &vmain_h
, &btemp_l
, &btemp_h
,
2416 &vbat_l
, &vbat_h
, &ibat_l
, &ibat_h
);
2426 vmain_l
, vmain_h
, btemp_l
, btemp_h
,
2427 vbat_l
, vbat_h
, ibat_l
, ibat_h
);
2432 static int ab8540_gpadc_otp_cal_open(struct inode
*inode
, struct file
*file
)
2434 return single_open(file
, ab8540_gpadc_otp_cal_print
, inode
->i_private
);
2437 static const struct file_operations ab8540_gpadc_otp_calib_fops
= {
2438 .open
= ab8540_gpadc_otp_cal_open
,
2440 .llseek
= seq_lseek
,
2441 .release
= single_release
,
2442 .owner
= THIS_MODULE
,
2445 static int ab8500_gpadc_avg_sample_print(struct seq_file
*s
, void *p
)
2447 seq_printf(s
, "%d\n", avg_sample
);
2452 static int ab8500_gpadc_avg_sample_open(struct inode
*inode
, struct file
*file
)
2454 return single_open(file
, ab8500_gpadc_avg_sample_print
,
2458 static ssize_t
ab8500_gpadc_avg_sample_write(struct file
*file
,
2459 const char __user
*user_buf
,
2460 size_t count
, loff_t
*ppos
)
2462 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2463 unsigned long user_avg_sample
;
2466 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_avg_sample
);
2470 if ((user_avg_sample
== SAMPLE_1
) || (user_avg_sample
== SAMPLE_4
)
2471 || (user_avg_sample
== SAMPLE_8
)
2472 || (user_avg_sample
== SAMPLE_16
)) {
2473 avg_sample
= (u8
) user_avg_sample
;
2476 "debugfs err input: should be egal to 1, 4, 8 or 16\n");
2483 static const struct file_operations ab8500_gpadc_avg_sample_fops
= {
2484 .open
= ab8500_gpadc_avg_sample_open
,
2486 .write
= ab8500_gpadc_avg_sample_write
,
2487 .llseek
= seq_lseek
,
2488 .release
= single_release
,
2489 .owner
= THIS_MODULE
,
2492 static int ab8500_gpadc_trig_edge_print(struct seq_file
*s
, void *p
)
2494 seq_printf(s
, "%d\n", trig_edge
);
2499 static int ab8500_gpadc_trig_edge_open(struct inode
*inode
, struct file
*file
)
2501 return single_open(file
, ab8500_gpadc_trig_edge_print
,
2505 static ssize_t
ab8500_gpadc_trig_edge_write(struct file
*file
,
2506 const char __user
*user_buf
,
2507 size_t count
, loff_t
*ppos
)
2509 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2510 unsigned long user_trig_edge
;
2513 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_trig_edge
);
2517 if ((user_trig_edge
== RISING_EDGE
)
2518 || (user_trig_edge
== FALLING_EDGE
)) {
2519 trig_edge
= (u8
) user_trig_edge
;
2521 dev_err(dev
, "Wrong input:\n"
2522 "Enter 0. Rising edge\n"
2523 "Enter 1. Falling edge\n");
2530 static const struct file_operations ab8500_gpadc_trig_edge_fops
= {
2531 .open
= ab8500_gpadc_trig_edge_open
,
2533 .write
= ab8500_gpadc_trig_edge_write
,
2534 .llseek
= seq_lseek
,
2535 .release
= single_release
,
2536 .owner
= THIS_MODULE
,
2539 static int ab8500_gpadc_trig_timer_print(struct seq_file
*s
, void *p
)
2541 seq_printf(s
, "%d\n", trig_timer
);
2546 static int ab8500_gpadc_trig_timer_open(struct inode
*inode
, struct file
*file
)
2548 return single_open(file
, ab8500_gpadc_trig_timer_print
,
2552 static ssize_t
ab8500_gpadc_trig_timer_write(struct file
*file
,
2553 const char __user
*user_buf
,
2554 size_t count
, loff_t
*ppos
)
2556 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2557 unsigned long user_trig_timer
;
2560 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_trig_timer
);
2564 if (user_trig_timer
& ~0xFF) {
2566 "debugfs error input: should be beetween 0 to 255\n");
2570 trig_timer
= (u8
) user_trig_timer
;
2575 static const struct file_operations ab8500_gpadc_trig_timer_fops
= {
2576 .open
= ab8500_gpadc_trig_timer_open
,
2578 .write
= ab8500_gpadc_trig_timer_write
,
2579 .llseek
= seq_lseek
,
2580 .release
= single_release
,
2581 .owner
= THIS_MODULE
,
2584 static int ab8500_gpadc_conv_type_print(struct seq_file
*s
, void *p
)
2586 seq_printf(s
, "%d\n", conv_type
);
2591 static int ab8500_gpadc_conv_type_open(struct inode
*inode
, struct file
*file
)
2593 return single_open(file
, ab8500_gpadc_conv_type_print
,
2597 static ssize_t
ab8500_gpadc_conv_type_write(struct file
*file
,
2598 const char __user
*user_buf
,
2599 size_t count
, loff_t
*ppos
)
2601 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2602 unsigned long user_conv_type
;
2605 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_conv_type
);
2609 if ((user_conv_type
== ADC_SW
)
2610 || (user_conv_type
== ADC_HW
)) {
2611 conv_type
= (u8
) user_conv_type
;
2613 dev_err(dev
, "Wrong input:\n"
2614 "Enter 0. ADC SW conversion\n"
2615 "Enter 1. ADC HW conversion\n");
2622 static const struct file_operations ab8500_gpadc_conv_type_fops
= {
2623 .open
= ab8500_gpadc_conv_type_open
,
2625 .write
= ab8500_gpadc_conv_type_write
,
2626 .llseek
= seq_lseek
,
2627 .release
= single_release
,
2628 .owner
= THIS_MODULE
,
2632 * return length of an ASCII numerical value, 0 is string is not a
2634 * string shall start at value 1st char.
2635 * string can be tailed with \0 or space or newline chars only.
2636 * value can be decimal or hexadecimal (prefixed 0x or 0X).
2638 static int strval_len(char *b
)
2642 if ((*s
== '0') && ((*(s
+1) == 'x') || (*(s
+1) == 'X'))) {
2644 for (; *s
&& (*s
!= ' ') && (*s
!= '\n'); s
++) {
2651 for (; *s
&& (*s
!= ' ') && (*s
!= '\n'); s
++) {
2660 * parse hwreg input data.
2661 * update global hwreg_cfg only if input data syntax is ok.
2663 static ssize_t
hwreg_common_write(char *b
, struct hwreg_cfg
*cfg
,
2666 uint write
, val
= 0;
2669 struct hwreg_cfg loc
= {
2670 .bank
= 0, /* default: invalid phys addr */
2671 .addr
= 0, /* default: invalid phys addr */
2672 .fmt
= 0, /* default: 32bit access, hex output */
2673 .mask
= 0xFFFFFFFF, /* default: no mask */
2674 .shift
= 0, /* default: no bit shift */
2677 /* read or write ? */
2678 if (!strncmp(b
, "read ", 5)) {
2681 } else if (!strncmp(b
, "write ", 6)) {
2687 /* OPTIONS -l|-w|-b -s -m -o */
2688 while ((*b
== ' ') || (*b
== '-')) {
2689 if (*(b
-1) != ' ') {
2693 if ((!strncmp(b
, "-d ", 3)) ||
2694 (!strncmp(b
, "-dec ", 5))) {
2695 b
+= (*(b
+2) == ' ') ? 3 : 5;
2697 } else if ((!strncmp(b
, "-h ", 3)) ||
2698 (!strncmp(b
, "-hex ", 5))) {
2699 b
+= (*(b
+2) == ' ') ? 3 : 5;
2701 } else if ((!strncmp(b
, "-m ", 3)) ||
2702 (!strncmp(b
, "-mask ", 6))) {
2703 b
+= (*(b
+2) == ' ') ? 3 : 6;
2704 if (strval_len(b
) == 0)
2706 ret
= kstrtoul(b
, 0, &loc
.mask
);
2709 } else if ((!strncmp(b
, "-s ", 3)) ||
2710 (!strncmp(b
, "-shift ", 7))) {
2711 b
+= (*(b
+2) == ' ') ? 3 : 7;
2712 if (strval_len(b
) == 0)
2714 ret
= kstrtol(b
, 0, &loc
.shift
);
2721 /* get arg BANK and ADDRESS */
2722 if (strval_len(b
) == 0)
2724 ret
= kstrtouint(b
, 0, &loc
.bank
);
2729 if (strval_len(b
) == 0)
2731 ret
= kstrtoul(b
, 0, &loc
.addr
);
2738 if (strval_len(b
) == 0)
2740 ret
= kstrtouint(b
, 0, &val
);
2745 /* args are ok, update target cfg (mainly for read) */
2748 #ifdef ABB_HWREG_DEBUG
2749 pr_warn("HWREG request: %s, %s,\n", (write
) ? "write" : "read",
2750 REG_FMT_DEC(cfg
) ? "decimal" : "hexa");
2751 pr_warn(" addr=0x%08X, mask=0x%X, shift=%d" "value=0x%X\n",
2752 cfg
->addr
, cfg
->mask
, cfg
->shift
, val
);
2758 ret
= abx500_get_register_interruptible(dev
,
2759 (u8
)cfg
->bank
, (u8
)cfg
->addr
, ®value
);
2761 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
2766 if (cfg
->shift
>= 0) {
2767 regvalue
&= ~(cfg
->mask
<< (cfg
->shift
));
2768 val
= (val
& cfg
->mask
) << (cfg
->shift
);
2770 regvalue
&= ~(cfg
->mask
>> (-cfg
->shift
));
2771 val
= (val
& cfg
->mask
) >> (-cfg
->shift
);
2773 val
= val
| regvalue
;
2775 ret
= abx500_set_register_interruptible(dev
,
2776 (u8
)cfg
->bank
, (u8
)cfg
->addr
, (u8
)val
);
2778 pr_err("abx500_set_reg failed %d, %d", ret
, __LINE__
);
2785 static ssize_t
ab8500_hwreg_write(struct file
*file
,
2786 const char __user
*user_buf
, size_t count
, loff_t
*ppos
)
2788 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2792 /* Get userspace string and assure termination */
2793 buf_size
= min(count
, (sizeof(buf
)-1));
2794 if (copy_from_user(buf
, user_buf
, buf_size
))
2798 /* get args and process */
2799 ret
= hwreg_common_write(buf
, &hwreg_cfg
, dev
);
2800 return (ret
) ? ret
: buf_size
;
2804 * - irq subscribe/unsubscribe stuff
2806 static int ab8500_subscribe_unsubscribe_print(struct seq_file
*s
, void *p
)
2808 seq_printf(s
, "%d\n", irq_first
);
2813 static int ab8500_subscribe_unsubscribe_open(struct inode
*inode
,
2816 return single_open(file
, ab8500_subscribe_unsubscribe_print
,
2821 * Userspace should use poll() on this file. When an event occur
2822 * the blocking poll will be released.
2824 static ssize_t
show_irq(struct device
*dev
,
2825 struct device_attribute
*attr
, char *buf
)
2828 unsigned int irq_index
;
2831 err
= kstrtoul(attr
->attr
.name
, 0, &name
);
2835 irq_index
= name
- irq_first
;
2836 if (irq_index
>= num_irqs
)
2839 return sprintf(buf
, "%u\n", irq_count
[irq_index
]);
2842 static ssize_t
ab8500_subscribe_write(struct file
*file
,
2843 const char __user
*user_buf
,
2844 size_t count
, loff_t
*ppos
)
2846 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2847 unsigned long user_val
;
2849 unsigned int irq_index
;
2851 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
2855 if (user_val
< irq_first
) {
2856 dev_err(dev
, "debugfs error input < %d\n", irq_first
);
2859 if (user_val
> irq_last
) {
2860 dev_err(dev
, "debugfs error input > %d\n", irq_last
);
2864 irq_index
= user_val
- irq_first
;
2865 if (irq_index
>= num_irqs
)
2869 * This will create a sysfs file named <irq-nr> which userspace can
2870 * use to select or poll and get the AB8500 events
2872 dev_attr
[irq_index
] = kmalloc(sizeof(struct device_attribute
),
2874 if (!dev_attr
[irq_index
])
2877 event_name
[irq_index
] = kmalloc(count
, GFP_KERNEL
);
2878 if (!event_name
[irq_index
])
2881 sprintf(event_name
[irq_index
], "%lu", user_val
);
2882 dev_attr
[irq_index
]->show
= show_irq
;
2883 dev_attr
[irq_index
]->store
= NULL
;
2884 dev_attr
[irq_index
]->attr
.name
= event_name
[irq_index
];
2885 dev_attr
[irq_index
]->attr
.mode
= S_IRUGO
;
2886 err
= sysfs_create_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2888 pr_info("sysfs_create_file failed %d\n", err
);
2892 err
= request_threaded_irq(user_val
, NULL
, ab8500_debug_handler
,
2893 IRQF_SHARED
| IRQF_NO_SUSPEND
| IRQF_ONESHOT
,
2894 "ab8500-debug", &dev
->kobj
);
2896 pr_info("request_threaded_irq failed %d, %lu\n",
2898 sysfs_remove_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2905 static ssize_t
ab8500_unsubscribe_write(struct file
*file
,
2906 const char __user
*user_buf
,
2907 size_t count
, loff_t
*ppos
)
2909 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2910 unsigned long user_val
;
2912 unsigned int irq_index
;
2914 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
2918 if (user_val
< irq_first
) {
2919 dev_err(dev
, "debugfs error input < %d\n", irq_first
);
2922 if (user_val
> irq_last
) {
2923 dev_err(dev
, "debugfs error input > %d\n", irq_last
);
2927 irq_index
= user_val
- irq_first
;
2928 if (irq_index
>= num_irqs
)
2931 /* Set irq count to 0 when unsubscribe */
2932 irq_count
[irq_index
] = 0;
2934 if (dev_attr
[irq_index
])
2935 sysfs_remove_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2938 free_irq(user_val
, &dev
->kobj
);
2939 kfree(event_name
[irq_index
]);
2940 kfree(dev_attr
[irq_index
]);
2946 * - several deubgfs nodes fops
2949 static const struct file_operations ab8500_bank_fops
= {
2950 .open
= ab8500_bank_open
,
2951 .write
= ab8500_bank_write
,
2953 .llseek
= seq_lseek
,
2954 .release
= single_release
,
2955 .owner
= THIS_MODULE
,
2958 static const struct file_operations ab8500_address_fops
= {
2959 .open
= ab8500_address_open
,
2960 .write
= ab8500_address_write
,
2962 .llseek
= seq_lseek
,
2963 .release
= single_release
,
2964 .owner
= THIS_MODULE
,
2967 static const struct file_operations ab8500_val_fops
= {
2968 .open
= ab8500_val_open
,
2969 .write
= ab8500_val_write
,
2971 .llseek
= seq_lseek
,
2972 .release
= single_release
,
2973 .owner
= THIS_MODULE
,
2976 static const struct file_operations ab8500_interrupts_fops
= {
2977 .open
= ab8500_interrupts_open
,
2979 .llseek
= seq_lseek
,
2980 .release
= single_release
,
2981 .owner
= THIS_MODULE
,
2984 static const struct file_operations ab8500_subscribe_fops
= {
2985 .open
= ab8500_subscribe_unsubscribe_open
,
2986 .write
= ab8500_subscribe_write
,
2988 .llseek
= seq_lseek
,
2989 .release
= single_release
,
2990 .owner
= THIS_MODULE
,
2993 static const struct file_operations ab8500_unsubscribe_fops
= {
2994 .open
= ab8500_subscribe_unsubscribe_open
,
2995 .write
= ab8500_unsubscribe_write
,
2997 .llseek
= seq_lseek
,
2998 .release
= single_release
,
2999 .owner
= THIS_MODULE
,
3002 static const struct file_operations ab8500_hwreg_fops
= {
3003 .open
= ab8500_hwreg_open
,
3004 .write
= ab8500_hwreg_write
,
3006 .llseek
= seq_lseek
,
3007 .release
= single_release
,
3008 .owner
= THIS_MODULE
,
3011 static struct dentry
*ab8500_dir
;
3012 static struct dentry
*ab8500_gpadc_dir
;
3014 static int ab8500_debug_probe(struct platform_device
*plf
)
3016 struct dentry
*file
;
3017 struct ab8500
*ab8500
;
3018 struct resource
*res
;
3020 debug_bank
= AB8500_MISC
;
3021 debug_address
= AB8500_REV_REG
& 0x00FF;
3023 ab8500
= dev_get_drvdata(plf
->dev
.parent
);
3024 num_irqs
= ab8500
->mask_size
;
3026 irq_count
= devm_kzalloc(&plf
->dev
,
3027 sizeof(*irq_count
)*num_irqs
, GFP_KERNEL
);
3031 dev_attr
= devm_kzalloc(&plf
->dev
,
3032 sizeof(*dev_attr
)*num_irqs
, GFP_KERNEL
);
3036 event_name
= devm_kzalloc(&plf
->dev
,
3037 sizeof(*event_name
)*num_irqs
, GFP_KERNEL
);
3041 res
= platform_get_resource_byname(plf
, 0, "IRQ_AB8500");
3043 dev_err(&plf
->dev
, "AB8500 irq not found, err %d\n", irq_first
);
3046 irq_ab8500
= res
->start
;
3048 irq_first
= platform_get_irq_byname(plf
, "IRQ_FIRST");
3049 if (irq_first
< 0) {
3050 dev_err(&plf
->dev
, "First irq not found, err %d\n", irq_first
);
3054 irq_last
= platform_get_irq_byname(plf
, "IRQ_LAST");
3056 dev_err(&plf
->dev
, "Last irq not found, err %d\n", irq_last
);
3060 ab8500_dir
= debugfs_create_dir(AB8500_NAME_STRING
, NULL
);
3064 ab8500_gpadc_dir
= debugfs_create_dir(AB8500_ADC_NAME_STRING
,
3066 if (!ab8500_gpadc_dir
)
3069 file
= debugfs_create_file("all-bank-registers", S_IRUGO
, ab8500_dir
,
3070 &plf
->dev
, &ab8500_registers_fops
);
3074 file
= debugfs_create_file("all-banks", S_IRUGO
, ab8500_dir
,
3075 &plf
->dev
, &ab8500_all_banks_fops
);
3079 file
= debugfs_create_file("register-bank",
3080 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3081 ab8500_dir
, &plf
->dev
, &ab8500_bank_fops
);
3085 file
= debugfs_create_file("register-address",
3086 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3087 ab8500_dir
, &plf
->dev
, &ab8500_address_fops
);
3091 file
= debugfs_create_file("register-value",
3092 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3093 ab8500_dir
, &plf
->dev
, &ab8500_val_fops
);
3097 file
= debugfs_create_file("irq-subscribe",
3098 (S_IRUGO
| S_IWUSR
| S_IWGRP
), ab8500_dir
,
3099 &plf
->dev
, &ab8500_subscribe_fops
);
3103 if (is_ab8500(ab8500
)) {
3104 debug_ranges
= ab8500_debug_ranges
;
3105 num_interrupt_lines
= AB8500_NR_IRQS
;
3106 } else if (is_ab8505(ab8500
)) {
3107 debug_ranges
= ab8505_debug_ranges
;
3108 num_interrupt_lines
= AB8505_NR_IRQS
;
3109 } else if (is_ab9540(ab8500
)) {
3110 debug_ranges
= ab8505_debug_ranges
;
3111 num_interrupt_lines
= AB9540_NR_IRQS
;
3112 } else if (is_ab8540(ab8500
)) {
3113 debug_ranges
= ab8540_debug_ranges
;
3114 num_interrupt_lines
= AB8540_NR_IRQS
;
3117 file
= debugfs_create_file("interrupts", (S_IRUGO
), ab8500_dir
,
3118 &plf
->dev
, &ab8500_interrupts_fops
);
3122 file
= debugfs_create_file("irq-unsubscribe",
3123 (S_IRUGO
| S_IWUSR
| S_IWGRP
), ab8500_dir
,
3124 &plf
->dev
, &ab8500_unsubscribe_fops
);
3128 file
= debugfs_create_file("hwreg", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3129 ab8500_dir
, &plf
->dev
, &ab8500_hwreg_fops
);
3133 file
= debugfs_create_file("all-modem-registers",
3134 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3135 ab8500_dir
, &plf
->dev
, &ab8500_modem_fops
);
3139 file
= debugfs_create_file("bat_ctrl", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3140 ab8500_gpadc_dir
, &plf
->dev
,
3141 &ab8500_gpadc_bat_ctrl_fops
);
3145 file
= debugfs_create_file("btemp_ball", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3147 &plf
->dev
, &ab8500_gpadc_btemp_ball_fops
);
3151 file
= debugfs_create_file("main_charger_v",
3152 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3153 ab8500_gpadc_dir
, &plf
->dev
,
3154 &ab8500_gpadc_main_charger_v_fops
);
3158 file
= debugfs_create_file("acc_detect1",
3159 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3160 ab8500_gpadc_dir
, &plf
->dev
,
3161 &ab8500_gpadc_acc_detect1_fops
);
3165 file
= debugfs_create_file("acc_detect2",
3166 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3167 ab8500_gpadc_dir
, &plf
->dev
,
3168 &ab8500_gpadc_acc_detect2_fops
);
3172 file
= debugfs_create_file("adc_aux1", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3173 ab8500_gpadc_dir
, &plf
->dev
,
3174 &ab8500_gpadc_aux1_fops
);
3178 file
= debugfs_create_file("adc_aux2", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3179 ab8500_gpadc_dir
, &plf
->dev
,
3180 &ab8500_gpadc_aux2_fops
);
3184 file
= debugfs_create_file("main_bat_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3185 ab8500_gpadc_dir
, &plf
->dev
,
3186 &ab8500_gpadc_main_bat_v_fops
);
3190 file
= debugfs_create_file("vbus_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3191 ab8500_gpadc_dir
, &plf
->dev
,
3192 &ab8500_gpadc_vbus_v_fops
);
3196 file
= debugfs_create_file("main_charger_c",
3197 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3198 ab8500_gpadc_dir
, &plf
->dev
,
3199 &ab8500_gpadc_main_charger_c_fops
);
3203 file
= debugfs_create_file("usb_charger_c",
3204 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3206 &plf
->dev
, &ab8500_gpadc_usb_charger_c_fops
);
3210 file
= debugfs_create_file("bk_bat_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3211 ab8500_gpadc_dir
, &plf
->dev
,
3212 &ab8500_gpadc_bk_bat_v_fops
);
3216 file
= debugfs_create_file("die_temp", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3217 ab8500_gpadc_dir
, &plf
->dev
,
3218 &ab8500_gpadc_die_temp_fops
);
3222 file
= debugfs_create_file("usb_id", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3223 ab8500_gpadc_dir
, &plf
->dev
,
3224 &ab8500_gpadc_usb_id_fops
);
3228 if (is_ab8540(ab8500
)) {
3229 file
= debugfs_create_file("xtal_temp",
3230 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3231 ab8500_gpadc_dir
, &plf
->dev
,
3232 &ab8540_gpadc_xtal_temp_fops
);
3235 file
= debugfs_create_file("vbattruemeas",
3236 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3237 ab8500_gpadc_dir
, &plf
->dev
,
3238 &ab8540_gpadc_vbat_true_meas_fops
);
3241 file
= debugfs_create_file("batctrl_and_ibat",
3242 (S_IRUGO
| S_IWUGO
),
3245 &ab8540_gpadc_bat_ctrl_and_ibat_fops
);
3248 file
= debugfs_create_file("vbatmeas_and_ibat",
3249 (S_IRUGO
| S_IWUGO
),
3250 ab8500_gpadc_dir
, &plf
->dev
,
3251 &ab8540_gpadc_vbat_meas_and_ibat_fops
);
3254 file
= debugfs_create_file("vbattruemeas_and_ibat",
3255 (S_IRUGO
| S_IWUGO
),
3258 &ab8540_gpadc_vbat_true_meas_and_ibat_fops
);
3261 file
= debugfs_create_file("battemp_and_ibat",
3262 (S_IRUGO
| S_IWUGO
),
3264 &plf
->dev
, &ab8540_gpadc_bat_temp_and_ibat_fops
);
3267 file
= debugfs_create_file("otp_calib",
3268 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3270 &plf
->dev
, &ab8540_gpadc_otp_calib_fops
);
3274 file
= debugfs_create_file("avg_sample", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3275 ab8500_gpadc_dir
, &plf
->dev
,
3276 &ab8500_gpadc_avg_sample_fops
);
3280 file
= debugfs_create_file("trig_edge", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3281 ab8500_gpadc_dir
, &plf
->dev
,
3282 &ab8500_gpadc_trig_edge_fops
);
3286 file
= debugfs_create_file("trig_timer", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3287 ab8500_gpadc_dir
, &plf
->dev
,
3288 &ab8500_gpadc_trig_timer_fops
);
3292 file
= debugfs_create_file("conv_type", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3293 ab8500_gpadc_dir
, &plf
->dev
,
3294 &ab8500_gpadc_conv_type_fops
);
3301 debugfs_remove_recursive(ab8500_dir
);
3302 dev_err(&plf
->dev
, "failed to create debugfs entries.\n");
3307 static int ab8500_debug_remove(struct platform_device
*plf
)
3309 debugfs_remove_recursive(ab8500_dir
);
3314 static struct platform_driver ab8500_debug_driver
= {
3316 .name
= "ab8500-debug",
3318 .probe
= ab8500_debug_probe
,
3319 .remove
= ab8500_debug_remove
3322 static int __init
ab8500_debug_init(void)
3324 return platform_driver_register(&ab8500_debug_driver
);
3327 static void __exit
ab8500_debug_exit(void)
3329 platform_driver_unregister(&ab8500_debug_driver
);
3331 subsys_initcall(ab8500_debug_init
);
3332 module_exit(ab8500_debug_exit
);
3334 MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
3335 MODULE_DESCRIPTION("AB8500 DEBUG");
3336 MODULE_LICENSE("GPL v2");