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
[]) {
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
);
1308 " [0x%02X/0x%02X]: 0x%02X\n",
1311 /* Error is not returned here since
1312 * the output is wanted in any case */
1316 dev_info(dev
, " [0x%02X/0x%02X]: 0x%02X\n",
1324 static int ab8500_print_bank_registers(struct seq_file
*s
, void *p
)
1326 struct device
*dev
= s
->private;
1327 u32 bank
= debug_bank
;
1329 seq_puts(s
, AB8500_NAME_STRING
" register values:\n");
1331 seq_printf(s
, " bank 0x%02X:\n", bank
);
1333 ab8500_registers_print(dev
, bank
, s
);
1337 static int ab8500_registers_open(struct inode
*inode
, struct file
*file
)
1339 return single_open(file
, ab8500_print_bank_registers
, inode
->i_private
);
1342 static const struct file_operations ab8500_registers_fops
= {
1343 .open
= ab8500_registers_open
,
1345 .llseek
= seq_lseek
,
1346 .release
= single_release
,
1347 .owner
= THIS_MODULE
,
1350 static int ab8500_print_all_banks(struct seq_file
*s
, void *p
)
1352 struct device
*dev
= s
->private;
1355 seq_puts(s
, AB8500_NAME_STRING
" register values:\n");
1357 for (i
= 0; i
< AB8500_NUM_BANKS
; i
++) {
1358 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 dev_info(dev
, "ab8500 register values:\n");
1372 for (i
= 1; i
< AB8500_NUM_BANKS
; i
++) {
1373 dev_info(dev
, " 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 /* This shall only be called upon kernel panic! */
1388 void ab8500_dump_all_banks_to_mem(void)
1394 pr_info("Saving all ABB registers for crash analysis.\n");
1396 for (bank
= 0; bank
< AB8500_NUM_BANKS
; bank
++) {
1397 for (i
= 0; i
< debug_ranges
[bank
].num_ranges
; i
++) {
1400 for (reg
= debug_ranges
[bank
].range
[i
].first
;
1401 reg
<= debug_ranges
[bank
].range
[i
].last
;
1405 err
= prcmu_abb_read(bank
, reg
, &value
, 1);
1410 ab8500_complete_register_dump
[r
].bank
= bank
;
1411 ab8500_complete_register_dump
[r
].reg
= reg
;
1412 ab8500_complete_register_dump
[r
].value
= value
;
1416 if (r
>= DUMP_MAX_REGS
) {
1417 pr_err("%s: too many register to dump!\n",
1427 pr_info("Saved all ABB registers.\n");
1429 pr_info("Failed to save all ABB registers.\n");
1432 static int ab8500_all_banks_open(struct inode
*inode
, struct file
*file
)
1437 err
= single_open(file
, ab8500_print_all_banks
, inode
->i_private
);
1439 /* Default buf size in seq_read is not enough */
1440 s
= (struct seq_file
*)file
->private_data
;
1441 s
->size
= (PAGE_SIZE
* 2);
1442 s
->buf
= kmalloc(s
->size
, GFP_KERNEL
);
1444 single_release(inode
, file
);
1451 static const struct file_operations ab8500_all_banks_fops
= {
1452 .open
= ab8500_all_banks_open
,
1454 .llseek
= seq_lseek
,
1455 .release
= single_release
,
1456 .owner
= THIS_MODULE
,
1459 static int ab8500_bank_print(struct seq_file
*s
, void *p
)
1461 return seq_printf(s
, "0x%02X\n", debug_bank
);
1464 static int ab8500_bank_open(struct inode
*inode
, struct file
*file
)
1466 return single_open(file
, ab8500_bank_print
, inode
->i_private
);
1469 static ssize_t
ab8500_bank_write(struct file
*file
,
1470 const char __user
*user_buf
,
1471 size_t count
, loff_t
*ppos
)
1473 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1474 unsigned long user_bank
;
1477 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_bank
);
1481 if (user_bank
>= AB8500_NUM_BANKS
) {
1482 dev_err(dev
, "debugfs error input > number of banks\n");
1486 debug_bank
= user_bank
;
1491 static int ab8500_address_print(struct seq_file
*s
, void *p
)
1493 return seq_printf(s
, "0x%02X\n", debug_address
);
1496 static int ab8500_address_open(struct inode
*inode
, struct file
*file
)
1498 return single_open(file
, ab8500_address_print
, inode
->i_private
);
1501 static ssize_t
ab8500_address_write(struct file
*file
,
1502 const char __user
*user_buf
,
1503 size_t count
, loff_t
*ppos
)
1505 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1506 unsigned long user_address
;
1509 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_address
);
1513 if (user_address
> 0xff) {
1514 dev_err(dev
, "debugfs error input > 0xff\n");
1517 debug_address
= user_address
;
1522 static int ab8500_val_print(struct seq_file
*s
, void *p
)
1524 struct device
*dev
= s
->private;
1528 ret
= abx500_get_register_interruptible(dev
,
1529 (u8
)debug_bank
, (u8
)debug_address
, ®value
);
1531 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
1535 seq_printf(s
, "0x%02X\n", regvalue
);
1540 static int ab8500_val_open(struct inode
*inode
, struct file
*file
)
1542 return single_open(file
, ab8500_val_print
, inode
->i_private
);
1545 static ssize_t
ab8500_val_write(struct file
*file
,
1546 const char __user
*user_buf
,
1547 size_t count
, loff_t
*ppos
)
1549 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
1550 unsigned long user_val
;
1553 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
1557 if (user_val
> 0xff) {
1558 dev_err(dev
, "debugfs error input > 0xff\n");
1561 err
= abx500_set_register_interruptible(dev
,
1562 (u8
)debug_bank
, debug_address
, (u8
)user_val
);
1564 pr_err("abx500_set_reg failed %d, %d", err
, __LINE__
);
1574 static u32 num_interrupts
[AB8500_MAX_NR_IRQS
];
1575 static u32 num_wake_interrupts
[AB8500_MAX_NR_IRQS
];
1576 static int num_interrupt_lines
;
1578 bool __attribute__((weak
)) suspend_test_wake_cause_interrupt_is_mine(u32 my_int
)
1583 void ab8500_debug_register_interrupt(int line
)
1585 if (line
< num_interrupt_lines
) {
1586 num_interrupts
[line
]++;
1587 if (suspend_test_wake_cause_interrupt_is_mine(irq_ab8500
))
1588 num_wake_interrupts
[line
]++;
1592 static int ab8500_interrupts_print(struct seq_file
*s
, void *p
)
1596 seq_puts(s
, "name: number: number of: wake:\n");
1598 for (line
= 0; line
< num_interrupt_lines
; line
++) {
1599 struct irq_desc
*desc
= irq_to_desc(line
+ irq_first
);
1601 seq_printf(s
, "%3i: %6i %4i", line
,
1602 num_interrupts
[line
],
1603 num_wake_interrupts
[line
]);
1605 if (desc
&& desc
->name
)
1606 seq_printf(s
, "-%-8s", desc
->name
);
1607 if (desc
&& desc
->action
) {
1608 struct irqaction
*action
= desc
->action
;
1610 seq_printf(s
, " %s", action
->name
);
1611 while ((action
= action
->next
) != NULL
)
1612 seq_printf(s
, ", %s", action
->name
);
1620 static int ab8500_interrupts_open(struct inode
*inode
, struct file
*file
)
1622 return single_open(file
, ab8500_interrupts_print
, inode
->i_private
);
1626 * - HWREG DB8500 formated routines
1628 static int ab8500_hwreg_print(struct seq_file
*s
, void *d
)
1630 struct device
*dev
= s
->private;
1634 ret
= abx500_get_register_interruptible(dev
,
1635 (u8
)hwreg_cfg
.bank
, (u8
)hwreg_cfg
.addr
, ®value
);
1637 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
1642 if (hwreg_cfg
.shift
>= 0)
1643 regvalue
>>= hwreg_cfg
.shift
;
1645 regvalue
<<= -hwreg_cfg
.shift
;
1646 regvalue
&= hwreg_cfg
.mask
;
1648 if (REG_FMT_DEC(&hwreg_cfg
))
1649 seq_printf(s
, "%d\n", regvalue
);
1651 seq_printf(s
, "0x%02X\n", regvalue
);
1655 static int ab8500_hwreg_open(struct inode
*inode
, struct file
*file
)
1657 return single_open(file
, ab8500_hwreg_print
, inode
->i_private
);
1660 #define AB8500_SUPPLY_CONTROL_CONFIG_1 0x01
1661 #define AB8500_SUPPLY_CONTROL_REG 0x00
1662 #define AB8500_FIRST_SIM_REG 0x80
1663 #define AB8500_LAST_SIM_REG 0x8B
1664 #define AB8505_LAST_SIM_REG 0x8C
1666 static int ab8500_print_modem_registers(struct seq_file
*s
, void *p
)
1668 struct device
*dev
= s
->private;
1669 struct ab8500
*ab8500
;
1673 u32 bank
= AB8500_REGU_CTRL2
;
1674 u32 last_sim_reg
= AB8500_LAST_SIM_REG
;
1677 ab8500
= dev_get_drvdata(dev
->parent
);
1678 dev_warn(dev
, "WARNING! This operation can interfer with modem side\n"
1679 "and should only be done with care\n");
1681 err
= abx500_get_register_interruptible(dev
,
1682 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
, &orig_value
);
1684 dev_err(dev
, "ab->read fail %d\n", err
);
1687 /* Config 1 will allow APE side to read SIM registers */
1688 err
= abx500_set_register_interruptible(dev
,
1689 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
,
1690 AB8500_SUPPLY_CONTROL_CONFIG_1
);
1692 dev_err(dev
, "ab->write fail %d\n", err
);
1696 seq_printf(s
, " bank 0x%02X:\n", bank
);
1698 if (is_ab9540(ab8500
) || is_ab8505(ab8500
))
1699 last_sim_reg
= AB8505_LAST_SIM_REG
;
1701 for (reg
= AB8500_FIRST_SIM_REG
; reg
<= last_sim_reg
; reg
++) {
1702 err
= abx500_get_register_interruptible(dev
,
1705 dev_err(dev
, "ab->read fail %d\n", err
);
1708 err
= seq_printf(s
, " [0x%02X/0x%02X]: 0x%02X\n",
1711 err
= abx500_set_register_interruptible(dev
,
1712 AB8500_REGU_CTRL1
, AB8500_SUPPLY_CONTROL_REG
, orig_value
);
1714 dev_err(dev
, "ab->write fail %d\n", err
);
1720 static int ab8500_modem_open(struct inode
*inode
, struct file
*file
)
1722 return single_open(file
, ab8500_print_modem_registers
,
1726 static const struct file_operations ab8500_modem_fops
= {
1727 .open
= ab8500_modem_open
,
1729 .llseek
= seq_lseek
,
1730 .release
= single_release
,
1731 .owner
= THIS_MODULE
,
1734 static int ab8500_gpadc_bat_ctrl_print(struct seq_file
*s
, void *p
)
1737 int bat_ctrl_convert
;
1738 struct ab8500_gpadc
*gpadc
;
1740 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1741 bat_ctrl_raw
= ab8500_gpadc_read_raw(gpadc
, BAT_CTRL
,
1742 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1743 bat_ctrl_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1744 BAT_CTRL
, bat_ctrl_raw
);
1746 return seq_printf(s
, "%d,0x%X\n",
1747 bat_ctrl_convert
, bat_ctrl_raw
);
1750 static int ab8500_gpadc_bat_ctrl_open(struct inode
*inode
, struct file
*file
)
1752 return single_open(file
, ab8500_gpadc_bat_ctrl_print
,
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
,
1787 static const struct file_operations ab8500_gpadc_btemp_ball_fops
= {
1788 .open
= ab8500_gpadc_btemp_ball_open
,
1790 .llseek
= seq_lseek
,
1791 .release
= single_release
,
1792 .owner
= THIS_MODULE
,
1795 static int ab8500_gpadc_main_charger_v_print(struct seq_file
*s
, void *p
)
1797 int main_charger_v_raw
;
1798 int main_charger_v_convert
;
1799 struct ab8500_gpadc
*gpadc
;
1801 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1802 main_charger_v_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_CHARGER_V
,
1803 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1804 main_charger_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1805 MAIN_CHARGER_V
, main_charger_v_raw
);
1807 return seq_printf(s
, "%d,0x%X\n",
1808 main_charger_v_convert
, main_charger_v_raw
);
1811 static int ab8500_gpadc_main_charger_v_open(struct inode
*inode
,
1814 return single_open(file
, ab8500_gpadc_main_charger_v_print
,
1818 static const struct file_operations ab8500_gpadc_main_charger_v_fops
= {
1819 .open
= ab8500_gpadc_main_charger_v_open
,
1821 .llseek
= seq_lseek
,
1822 .release
= single_release
,
1823 .owner
= THIS_MODULE
,
1826 static int ab8500_gpadc_acc_detect1_print(struct seq_file
*s
, void *p
)
1828 int acc_detect1_raw
;
1829 int acc_detect1_convert
;
1830 struct ab8500_gpadc
*gpadc
;
1832 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1833 acc_detect1_raw
= ab8500_gpadc_read_raw(gpadc
, ACC_DETECT1
,
1834 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1835 acc_detect1_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ACC_DETECT1
,
1838 return seq_printf(s
, "%d,0x%X\n",
1839 acc_detect1_convert
, acc_detect1_raw
);
1842 static int ab8500_gpadc_acc_detect1_open(struct inode
*inode
,
1845 return single_open(file
, ab8500_gpadc_acc_detect1_print
,
1849 static const struct file_operations ab8500_gpadc_acc_detect1_fops
= {
1850 .open
= ab8500_gpadc_acc_detect1_open
,
1852 .llseek
= seq_lseek
,
1853 .release
= single_release
,
1854 .owner
= THIS_MODULE
,
1857 static int ab8500_gpadc_acc_detect2_print(struct seq_file
*s
, void *p
)
1859 int acc_detect2_raw
;
1860 int acc_detect2_convert
;
1861 struct ab8500_gpadc
*gpadc
;
1863 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1864 acc_detect2_raw
= ab8500_gpadc_read_raw(gpadc
, ACC_DETECT2
,
1865 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1866 acc_detect2_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
1867 ACC_DETECT2
, acc_detect2_raw
);
1869 return seq_printf(s
, "%d,0x%X\n",
1870 acc_detect2_convert
, acc_detect2_raw
);
1873 static int ab8500_gpadc_acc_detect2_open(struct inode
*inode
,
1876 return single_open(file
, ab8500_gpadc_acc_detect2_print
,
1880 static const struct file_operations ab8500_gpadc_acc_detect2_fops
= {
1881 .open
= ab8500_gpadc_acc_detect2_open
,
1883 .llseek
= seq_lseek
,
1884 .release
= single_release
,
1885 .owner
= THIS_MODULE
,
1888 static int ab8500_gpadc_aux1_print(struct seq_file
*s
, void *p
)
1892 struct ab8500_gpadc
*gpadc
;
1894 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1895 aux1_raw
= ab8500_gpadc_read_raw(gpadc
, ADC_AUX1
,
1896 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1897 aux1_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ADC_AUX1
,
1900 return seq_printf(s
, "%d,0x%X\n",
1901 aux1_convert
, aux1_raw
);
1904 static int ab8500_gpadc_aux1_open(struct inode
*inode
, struct file
*file
)
1906 return single_open(file
, ab8500_gpadc_aux1_print
, inode
->i_private
);
1909 static const struct file_operations ab8500_gpadc_aux1_fops
= {
1910 .open
= ab8500_gpadc_aux1_open
,
1912 .llseek
= seq_lseek
,
1913 .release
= single_release
,
1914 .owner
= THIS_MODULE
,
1917 static int ab8500_gpadc_aux2_print(struct seq_file
*s
, void *p
)
1921 struct ab8500_gpadc
*gpadc
;
1923 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1924 aux2_raw
= ab8500_gpadc_read_raw(gpadc
, ADC_AUX2
,
1925 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1926 aux2_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, ADC_AUX2
,
1929 return seq_printf(s
, "%d,0x%X\n",
1930 aux2_convert
, aux2_raw
);
1933 static int ab8500_gpadc_aux2_open(struct inode
*inode
, struct file
*file
)
1935 return single_open(file
, ab8500_gpadc_aux2_print
, inode
->i_private
);
1938 static const struct file_operations ab8500_gpadc_aux2_fops
= {
1939 .open
= ab8500_gpadc_aux2_open
,
1941 .llseek
= seq_lseek
,
1942 .release
= single_release
,
1943 .owner
= THIS_MODULE
,
1946 static int ab8500_gpadc_main_bat_v_print(struct seq_file
*s
, void *p
)
1949 int main_bat_v_convert
;
1950 struct ab8500_gpadc
*gpadc
;
1952 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1953 main_bat_v_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_BAT_V
,
1954 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1955 main_bat_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, MAIN_BAT_V
,
1958 return seq_printf(s
, "%d,0x%X\n",
1959 main_bat_v_convert
, main_bat_v_raw
);
1962 static int ab8500_gpadc_main_bat_v_open(struct inode
*inode
,
1965 return single_open(file
, ab8500_gpadc_main_bat_v_print
,
1969 static const struct file_operations ab8500_gpadc_main_bat_v_fops
= {
1970 .open
= ab8500_gpadc_main_bat_v_open
,
1972 .llseek
= seq_lseek
,
1973 .release
= single_release
,
1974 .owner
= THIS_MODULE
,
1977 static int ab8500_gpadc_vbus_v_print(struct seq_file
*s
, void *p
)
1981 struct ab8500_gpadc
*gpadc
;
1983 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
1984 vbus_v_raw
= ab8500_gpadc_read_raw(gpadc
, VBUS_V
,
1985 avg_sample
, trig_edge
, trig_timer
, conv_type
);
1986 vbus_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, VBUS_V
,
1989 return seq_printf(s
, "%d,0x%X\n",
1990 vbus_v_convert
, vbus_v_raw
);
1993 static int ab8500_gpadc_vbus_v_open(struct inode
*inode
, struct file
*file
)
1995 return single_open(file
, ab8500_gpadc_vbus_v_print
, inode
->i_private
);
1998 static const struct file_operations ab8500_gpadc_vbus_v_fops
= {
1999 .open
= ab8500_gpadc_vbus_v_open
,
2001 .llseek
= seq_lseek
,
2002 .release
= single_release
,
2003 .owner
= THIS_MODULE
,
2006 static int ab8500_gpadc_main_charger_c_print(struct seq_file
*s
, void *p
)
2008 int main_charger_c_raw
;
2009 int main_charger_c_convert
;
2010 struct ab8500_gpadc
*gpadc
;
2012 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2013 main_charger_c_raw
= ab8500_gpadc_read_raw(gpadc
, MAIN_CHARGER_C
,
2014 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2015 main_charger_c_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2016 MAIN_CHARGER_C
, main_charger_c_raw
);
2018 return seq_printf(s
, "%d,0x%X\n",
2019 main_charger_c_convert
, main_charger_c_raw
);
2022 static int ab8500_gpadc_main_charger_c_open(struct inode
*inode
,
2025 return single_open(file
, ab8500_gpadc_main_charger_c_print
,
2029 static const struct file_operations ab8500_gpadc_main_charger_c_fops
= {
2030 .open
= ab8500_gpadc_main_charger_c_open
,
2032 .llseek
= seq_lseek
,
2033 .release
= single_release
,
2034 .owner
= THIS_MODULE
,
2037 static int ab8500_gpadc_usb_charger_c_print(struct seq_file
*s
, void *p
)
2039 int usb_charger_c_raw
;
2040 int usb_charger_c_convert
;
2041 struct ab8500_gpadc
*gpadc
;
2043 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2044 usb_charger_c_raw
= ab8500_gpadc_read_raw(gpadc
, USB_CHARGER_C
,
2045 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2046 usb_charger_c_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2047 USB_CHARGER_C
, usb_charger_c_raw
);
2049 return seq_printf(s
, "%d,0x%X\n",
2050 usb_charger_c_convert
, usb_charger_c_raw
);
2053 static int ab8500_gpadc_usb_charger_c_open(struct inode
*inode
,
2056 return single_open(file
, ab8500_gpadc_usb_charger_c_print
,
2060 static const struct file_operations ab8500_gpadc_usb_charger_c_fops
= {
2061 .open
= ab8500_gpadc_usb_charger_c_open
,
2063 .llseek
= seq_lseek
,
2064 .release
= single_release
,
2065 .owner
= THIS_MODULE
,
2068 static int ab8500_gpadc_bk_bat_v_print(struct seq_file
*s
, void *p
)
2071 int bk_bat_v_convert
;
2072 struct ab8500_gpadc
*gpadc
;
2074 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2075 bk_bat_v_raw
= ab8500_gpadc_read_raw(gpadc
, BK_BAT_V
,
2076 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2077 bk_bat_v_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2078 BK_BAT_V
, bk_bat_v_raw
);
2080 return seq_printf(s
, "%d,0x%X\n",
2081 bk_bat_v_convert
, bk_bat_v_raw
);
2084 static int ab8500_gpadc_bk_bat_v_open(struct inode
*inode
, struct file
*file
)
2086 return single_open(file
, ab8500_gpadc_bk_bat_v_print
,
2090 static const struct file_operations ab8500_gpadc_bk_bat_v_fops
= {
2091 .open
= ab8500_gpadc_bk_bat_v_open
,
2093 .llseek
= seq_lseek
,
2094 .release
= single_release
,
2095 .owner
= THIS_MODULE
,
2098 static int ab8500_gpadc_die_temp_print(struct seq_file
*s
, void *p
)
2101 int die_temp_convert
;
2102 struct ab8500_gpadc
*gpadc
;
2104 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2105 die_temp_raw
= ab8500_gpadc_read_raw(gpadc
, DIE_TEMP
,
2106 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2107 die_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, DIE_TEMP
,
2110 return seq_printf(s
, "%d,0x%X\n",
2111 die_temp_convert
, die_temp_raw
);
2114 static int ab8500_gpadc_die_temp_open(struct inode
*inode
, struct file
*file
)
2116 return single_open(file
, ab8500_gpadc_die_temp_print
,
2120 static const struct file_operations ab8500_gpadc_die_temp_fops
= {
2121 .open
= ab8500_gpadc_die_temp_open
,
2123 .llseek
= seq_lseek
,
2124 .release
= single_release
,
2125 .owner
= THIS_MODULE
,
2128 static int ab8500_gpadc_usb_id_print(struct seq_file
*s
, void *p
)
2132 struct ab8500_gpadc
*gpadc
;
2134 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2135 usb_id_raw
= ab8500_gpadc_read_raw(gpadc
, USB_ID
,
2136 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2137 usb_id_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, USB_ID
,
2140 return seq_printf(s
, "%d,0x%X\n",
2141 usb_id_convert
, usb_id_raw
);
2144 static int ab8500_gpadc_usb_id_open(struct inode
*inode
, struct file
*file
)
2146 return single_open(file
, ab8500_gpadc_usb_id_print
, inode
->i_private
);
2149 static const struct file_operations ab8500_gpadc_usb_id_fops
= {
2150 .open
= ab8500_gpadc_usb_id_open
,
2152 .llseek
= seq_lseek
,
2153 .release
= single_release
,
2154 .owner
= THIS_MODULE
,
2157 static int ab8540_gpadc_xtal_temp_print(struct seq_file
*s
, void *p
)
2160 int xtal_temp_convert
;
2161 struct ab8500_gpadc
*gpadc
;
2163 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2164 xtal_temp_raw
= ab8500_gpadc_read_raw(gpadc
, XTAL_TEMP
,
2165 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2166 xtal_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, XTAL_TEMP
,
2169 return seq_printf(s
, "%d,0x%X\n",
2170 xtal_temp_convert
, xtal_temp_raw
);
2173 static int ab8540_gpadc_xtal_temp_open(struct inode
*inode
, struct file
*file
)
2175 return single_open(file
, ab8540_gpadc_xtal_temp_print
,
2179 static const struct file_operations ab8540_gpadc_xtal_temp_fops
= {
2180 .open
= ab8540_gpadc_xtal_temp_open
,
2182 .llseek
= seq_lseek
,
2183 .release
= single_release
,
2184 .owner
= THIS_MODULE
,
2187 static int ab8540_gpadc_vbat_true_meas_print(struct seq_file
*s
, void *p
)
2189 int vbat_true_meas_raw
;
2190 int vbat_true_meas_convert
;
2191 struct ab8500_gpadc
*gpadc
;
2193 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2194 vbat_true_meas_raw
= ab8500_gpadc_read_raw(gpadc
, VBAT_TRUE_MEAS
,
2195 avg_sample
, trig_edge
, trig_timer
, conv_type
);
2196 vbat_true_meas_convert
=
2197 ab8500_gpadc_ad_to_voltage(gpadc
, VBAT_TRUE_MEAS
,
2198 vbat_true_meas_raw
);
2200 return seq_printf(s
, "%d,0x%X\n",
2201 vbat_true_meas_convert
, vbat_true_meas_raw
);
2204 static int ab8540_gpadc_vbat_true_meas_open(struct inode
*inode
,
2207 return single_open(file
, ab8540_gpadc_vbat_true_meas_print
,
2211 static const struct file_operations ab8540_gpadc_vbat_true_meas_fops
= {
2212 .open
= ab8540_gpadc_vbat_true_meas_open
,
2214 .llseek
= seq_lseek
,
2215 .release
= single_release
,
2216 .owner
= THIS_MODULE
,
2219 static int ab8540_gpadc_bat_ctrl_and_ibat_print(struct seq_file
*s
, void *p
)
2222 int bat_ctrl_convert
;
2225 struct ab8500_gpadc
*gpadc
;
2227 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2228 bat_ctrl_raw
= ab8500_gpadc_double_read_raw(gpadc
, BAT_CTRL_AND_IBAT
,
2229 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2231 bat_ctrl_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, BAT_CTRL
,
2233 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2236 return seq_printf(s
, "%d,0x%X\n" "%d,0x%X\n",
2237 bat_ctrl_convert
, bat_ctrl_raw
,
2238 ibat_convert
, ibat_raw
);
2241 static int ab8540_gpadc_bat_ctrl_and_ibat_open(struct inode
*inode
,
2244 return single_open(file
, ab8540_gpadc_bat_ctrl_and_ibat_print
,
2248 static const struct file_operations ab8540_gpadc_bat_ctrl_and_ibat_fops
= {
2249 .open
= ab8540_gpadc_bat_ctrl_and_ibat_open
,
2251 .llseek
= seq_lseek
,
2252 .release
= single_release
,
2253 .owner
= THIS_MODULE
,
2256 static int ab8540_gpadc_vbat_meas_and_ibat_print(struct seq_file
*s
, void *p
)
2259 int vbat_meas_convert
;
2262 struct ab8500_gpadc
*gpadc
;
2264 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2265 vbat_meas_raw
= ab8500_gpadc_double_read_raw(gpadc
, VBAT_MEAS_AND_IBAT
,
2266 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2267 vbat_meas_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, MAIN_BAT_V
,
2269 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2272 return seq_printf(s
, "%d,0x%X\n" "%d,0x%X\n",
2273 vbat_meas_convert
, vbat_meas_raw
,
2274 ibat_convert
, ibat_raw
);
2277 static int ab8540_gpadc_vbat_meas_and_ibat_open(struct inode
*inode
,
2280 return single_open(file
, ab8540_gpadc_vbat_meas_and_ibat_print
,
2284 static const struct file_operations ab8540_gpadc_vbat_meas_and_ibat_fops
= {
2285 .open
= ab8540_gpadc_vbat_meas_and_ibat_open
,
2287 .llseek
= seq_lseek
,
2288 .release
= single_release
,
2289 .owner
= THIS_MODULE
,
2292 static int ab8540_gpadc_vbat_true_meas_and_ibat_print(struct seq_file
*s
,
2295 int vbat_true_meas_raw
;
2296 int vbat_true_meas_convert
;
2299 struct ab8500_gpadc
*gpadc
;
2301 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2302 vbat_true_meas_raw
= ab8500_gpadc_double_read_raw(gpadc
,
2303 VBAT_TRUE_MEAS_AND_IBAT
, avg_sample
, trig_edge
,
2304 trig_timer
, conv_type
, &ibat_raw
);
2305 vbat_true_meas_convert
= ab8500_gpadc_ad_to_voltage(gpadc
,
2306 VBAT_TRUE_MEAS
, vbat_true_meas_raw
);
2307 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2310 return seq_printf(s
, "%d,0x%X\n" "%d,0x%X\n",
2311 vbat_true_meas_convert
, vbat_true_meas_raw
,
2312 ibat_convert
, ibat_raw
);
2315 static int ab8540_gpadc_vbat_true_meas_and_ibat_open(struct inode
*inode
,
2318 return single_open(file
, ab8540_gpadc_vbat_true_meas_and_ibat_print
,
2322 static const struct file_operations
2323 ab8540_gpadc_vbat_true_meas_and_ibat_fops
= {
2324 .open
= ab8540_gpadc_vbat_true_meas_and_ibat_open
,
2326 .llseek
= seq_lseek
,
2327 .release
= single_release
,
2328 .owner
= THIS_MODULE
,
2331 static int ab8540_gpadc_bat_temp_and_ibat_print(struct seq_file
*s
, void *p
)
2334 int bat_temp_convert
;
2337 struct ab8500_gpadc
*gpadc
;
2339 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2340 bat_temp_raw
= ab8500_gpadc_double_read_raw(gpadc
, BAT_TEMP_AND_IBAT
,
2341 avg_sample
, trig_edge
, trig_timer
, conv_type
, &ibat_raw
);
2342 bat_temp_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, BTEMP_BALL
,
2344 ibat_convert
= ab8500_gpadc_ad_to_voltage(gpadc
, IBAT_VIRTUAL_CHANNEL
,
2347 return seq_printf(s
, "%d,0x%X\n" "%d,0x%X\n",
2348 bat_temp_convert
, bat_temp_raw
,
2349 ibat_convert
, ibat_raw
);
2352 static int ab8540_gpadc_bat_temp_and_ibat_open(struct inode
*inode
,
2355 return single_open(file
, ab8540_gpadc_bat_temp_and_ibat_print
,
2359 static const struct file_operations ab8540_gpadc_bat_temp_and_ibat_fops
= {
2360 .open
= ab8540_gpadc_bat_temp_and_ibat_open
,
2362 .llseek
= seq_lseek
,
2363 .release
= single_release
,
2364 .owner
= THIS_MODULE
,
2367 static int ab8540_gpadc_otp_cal_print(struct seq_file
*s
, void *p
)
2369 struct ab8500_gpadc
*gpadc
;
2370 u16 vmain_l
, vmain_h
, btemp_l
, btemp_h
;
2371 u16 vbat_l
, vbat_h
, ibat_l
, ibat_h
;
2373 gpadc
= ab8500_gpadc_get("ab8500-gpadc.0");
2374 ab8540_gpadc_get_otp(gpadc
, &vmain_l
, &vmain_h
, &btemp_l
, &btemp_h
,
2375 &vbat_l
, &vbat_h
, &ibat_l
, &ibat_h
);
2376 return seq_printf(s
, "VMAIN_L:0x%X\n"
2384 vmain_l
, vmain_h
, btemp_l
, btemp_h
,
2385 vbat_l
, vbat_h
, ibat_l
, ibat_h
);
2388 static int ab8540_gpadc_otp_cal_open(struct inode
*inode
, struct file
*file
)
2390 return single_open(file
, ab8540_gpadc_otp_cal_print
, inode
->i_private
);
2393 static const struct file_operations ab8540_gpadc_otp_calib_fops
= {
2394 .open
= ab8540_gpadc_otp_cal_open
,
2396 .llseek
= seq_lseek
,
2397 .release
= single_release
,
2398 .owner
= THIS_MODULE
,
2401 static int ab8500_gpadc_avg_sample_print(struct seq_file
*s
, void *p
)
2403 return seq_printf(s
, "%d\n", avg_sample
);
2406 static int ab8500_gpadc_avg_sample_open(struct inode
*inode
, struct file
*file
)
2408 return single_open(file
, ab8500_gpadc_avg_sample_print
,
2412 static ssize_t
ab8500_gpadc_avg_sample_write(struct file
*file
,
2413 const char __user
*user_buf
,
2414 size_t count
, loff_t
*ppos
)
2416 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2417 unsigned long user_avg_sample
;
2420 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_avg_sample
);
2424 if ((user_avg_sample
== SAMPLE_1
) || (user_avg_sample
== SAMPLE_4
)
2425 || (user_avg_sample
== SAMPLE_8
)
2426 || (user_avg_sample
== SAMPLE_16
)) {
2427 avg_sample
= (u8
) user_avg_sample
;
2430 "debugfs err input: should be egal to 1, 4, 8 or 16\n");
2437 static const struct file_operations ab8500_gpadc_avg_sample_fops
= {
2438 .open
= ab8500_gpadc_avg_sample_open
,
2440 .write
= ab8500_gpadc_avg_sample_write
,
2441 .llseek
= seq_lseek
,
2442 .release
= single_release
,
2443 .owner
= THIS_MODULE
,
2446 static int ab8500_gpadc_trig_edge_print(struct seq_file
*s
, void *p
)
2448 return seq_printf(s
, "%d\n", trig_edge
);
2451 static int ab8500_gpadc_trig_edge_open(struct inode
*inode
, struct file
*file
)
2453 return single_open(file
, ab8500_gpadc_trig_edge_print
,
2457 static ssize_t
ab8500_gpadc_trig_edge_write(struct file
*file
,
2458 const char __user
*user_buf
,
2459 size_t count
, loff_t
*ppos
)
2461 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2462 unsigned long user_trig_edge
;
2465 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_trig_edge
);
2469 if ((user_trig_edge
== RISING_EDGE
)
2470 || (user_trig_edge
== FALLING_EDGE
)) {
2471 trig_edge
= (u8
) user_trig_edge
;
2473 dev_err(dev
, "Wrong input:\n"
2474 "Enter 0. Rising edge\n"
2475 "Enter 1. Falling edge\n");
2482 static const struct file_operations ab8500_gpadc_trig_edge_fops
= {
2483 .open
= ab8500_gpadc_trig_edge_open
,
2485 .write
= ab8500_gpadc_trig_edge_write
,
2486 .llseek
= seq_lseek
,
2487 .release
= single_release
,
2488 .owner
= THIS_MODULE
,
2491 static int ab8500_gpadc_trig_timer_print(struct seq_file
*s
, void *p
)
2493 return seq_printf(s
, "%d\n", trig_timer
);
2496 static int ab8500_gpadc_trig_timer_open(struct inode
*inode
, struct file
*file
)
2498 return single_open(file
, ab8500_gpadc_trig_timer_print
,
2502 static ssize_t
ab8500_gpadc_trig_timer_write(struct file
*file
,
2503 const char __user
*user_buf
,
2504 size_t count
, loff_t
*ppos
)
2506 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2507 unsigned long user_trig_timer
;
2510 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_trig_timer
);
2514 if (user_trig_timer
& ~0xFF) {
2516 "debugfs error input: should be beetween 0 to 255\n");
2520 trig_timer
= (u8
) user_trig_timer
;
2525 static const struct file_operations ab8500_gpadc_trig_timer_fops
= {
2526 .open
= ab8500_gpadc_trig_timer_open
,
2528 .write
= ab8500_gpadc_trig_timer_write
,
2529 .llseek
= seq_lseek
,
2530 .release
= single_release
,
2531 .owner
= THIS_MODULE
,
2534 static int ab8500_gpadc_conv_type_print(struct seq_file
*s
, void *p
)
2536 return seq_printf(s
, "%d\n", conv_type
);
2539 static int ab8500_gpadc_conv_type_open(struct inode
*inode
, struct file
*file
)
2541 return single_open(file
, ab8500_gpadc_conv_type_print
,
2545 static ssize_t
ab8500_gpadc_conv_type_write(struct file
*file
,
2546 const char __user
*user_buf
,
2547 size_t count
, loff_t
*ppos
)
2549 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2550 unsigned long user_conv_type
;
2553 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_conv_type
);
2557 if ((user_conv_type
== ADC_SW
)
2558 || (user_conv_type
== ADC_HW
)) {
2559 conv_type
= (u8
) user_conv_type
;
2561 dev_err(dev
, "Wrong input:\n"
2562 "Enter 0. ADC SW conversion\n"
2563 "Enter 1. ADC HW conversion\n");
2570 static const struct file_operations ab8500_gpadc_conv_type_fops
= {
2571 .open
= ab8500_gpadc_conv_type_open
,
2573 .write
= ab8500_gpadc_conv_type_write
,
2574 .llseek
= seq_lseek
,
2575 .release
= single_release
,
2576 .owner
= THIS_MODULE
,
2580 * return length of an ASCII numerical value, 0 is string is not a
2582 * string shall start at value 1st char.
2583 * string can be tailed with \0 or space or newline chars only.
2584 * value can be decimal or hexadecimal (prefixed 0x or 0X).
2586 static int strval_len(char *b
)
2590 if ((*s
== '0') && ((*(s
+1) == 'x') || (*(s
+1) == 'X'))) {
2592 for (; *s
&& (*s
!= ' ') && (*s
!= '\n'); s
++) {
2599 for (; *s
&& (*s
!= ' ') && (*s
!= '\n'); s
++) {
2608 * parse hwreg input data.
2609 * update global hwreg_cfg only if input data syntax is ok.
2611 static ssize_t
hwreg_common_write(char *b
, struct hwreg_cfg
*cfg
,
2614 uint write
, val
= 0;
2617 struct hwreg_cfg loc
= {
2618 .bank
= 0, /* default: invalid phys addr */
2619 .addr
= 0, /* default: invalid phys addr */
2620 .fmt
= 0, /* default: 32bit access, hex output */
2621 .mask
= 0xFFFFFFFF, /* default: no mask */
2622 .shift
= 0, /* default: no bit shift */
2625 /* read or write ? */
2626 if (!strncmp(b
, "read ", 5)) {
2629 } else if (!strncmp(b
, "write ", 6)) {
2635 /* OPTIONS -l|-w|-b -s -m -o */
2636 while ((*b
== ' ') || (*b
== '-')) {
2637 if (*(b
-1) != ' ') {
2641 if ((!strncmp(b
, "-d ", 3)) ||
2642 (!strncmp(b
, "-dec ", 5))) {
2643 b
+= (*(b
+2) == ' ') ? 3 : 5;
2645 } else if ((!strncmp(b
, "-h ", 3)) ||
2646 (!strncmp(b
, "-hex ", 5))) {
2647 b
+= (*(b
+2) == ' ') ? 3 : 5;
2649 } else if ((!strncmp(b
, "-m ", 3)) ||
2650 (!strncmp(b
, "-mask ", 6))) {
2651 b
+= (*(b
+2) == ' ') ? 3 : 6;
2652 if (strval_len(b
) == 0)
2654 ret
= kstrtoul(b
, 0, &loc
.mask
);
2657 } else if ((!strncmp(b
, "-s ", 3)) ||
2658 (!strncmp(b
, "-shift ", 7))) {
2659 b
+= (*(b
+2) == ' ') ? 3 : 7;
2660 if (strval_len(b
) == 0)
2662 ret
= kstrtol(b
, 0, &loc
.shift
);
2669 /* get arg BANK and ADDRESS */
2670 if (strval_len(b
) == 0)
2672 ret
= kstrtouint(b
, 0, &loc
.bank
);
2677 if (strval_len(b
) == 0)
2679 ret
= kstrtoul(b
, 0, &loc
.addr
);
2686 if (strval_len(b
) == 0)
2688 ret
= kstrtouint(b
, 0, &val
);
2693 /* args are ok, update target cfg (mainly for read) */
2696 #ifdef ABB_HWREG_DEBUG
2697 pr_warn("HWREG request: %s, %s,\n"
2698 " addr=0x%08X, mask=0x%X, shift=%d" "value=0x%X\n",
2699 (write
) ? "write" : "read",
2700 REG_FMT_DEC(cfg
) ? "decimal" : "hexa",
2701 cfg
->addr
, cfg
->mask
, cfg
->shift
, val
);
2707 ret
= abx500_get_register_interruptible(dev
,
2708 (u8
)cfg
->bank
, (u8
)cfg
->addr
, ®value
);
2710 dev_err(dev
, "abx500_get_reg fail %d, %d\n",
2715 if (cfg
->shift
>= 0) {
2716 regvalue
&= ~(cfg
->mask
<< (cfg
->shift
));
2717 val
= (val
& cfg
->mask
) << (cfg
->shift
);
2719 regvalue
&= ~(cfg
->mask
>> (-cfg
->shift
));
2720 val
= (val
& cfg
->mask
) >> (-cfg
->shift
);
2722 val
= val
| regvalue
;
2724 ret
= abx500_set_register_interruptible(dev
,
2725 (u8
)cfg
->bank
, (u8
)cfg
->addr
, (u8
)val
);
2727 pr_err("abx500_set_reg failed %d, %d", ret
, __LINE__
);
2734 static ssize_t
ab8500_hwreg_write(struct file
*file
,
2735 const char __user
*user_buf
, size_t count
, loff_t
*ppos
)
2737 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2741 /* Get userspace string and assure termination */
2742 buf_size
= min(count
, (sizeof(buf
)-1));
2743 if (copy_from_user(buf
, user_buf
, buf_size
))
2747 /* get args and process */
2748 ret
= hwreg_common_write(buf
, &hwreg_cfg
, dev
);
2749 return (ret
) ? ret
: buf_size
;
2753 * - irq subscribe/unsubscribe stuff
2755 static int ab8500_subscribe_unsubscribe_print(struct seq_file
*s
, void *p
)
2757 seq_printf(s
, "%d\n", irq_first
);
2762 static int ab8500_subscribe_unsubscribe_open(struct inode
*inode
,
2765 return single_open(file
, ab8500_subscribe_unsubscribe_print
,
2770 * Userspace should use poll() on this file. When an event occur
2771 * the blocking poll will be released.
2773 static ssize_t
show_irq(struct device
*dev
,
2774 struct device_attribute
*attr
, char *buf
)
2777 unsigned int irq_index
;
2780 err
= kstrtoul(attr
->attr
.name
, 0, &name
);
2784 irq_index
= name
- irq_first
;
2785 if (irq_index
>= num_irqs
)
2788 return sprintf(buf
, "%u\n", irq_count
[irq_index
]);
2791 static ssize_t
ab8500_subscribe_write(struct file
*file
,
2792 const char __user
*user_buf
,
2793 size_t count
, loff_t
*ppos
)
2795 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2796 unsigned long user_val
;
2798 unsigned int irq_index
;
2800 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
2804 if (user_val
< irq_first
) {
2805 dev_err(dev
, "debugfs error input < %d\n", irq_first
);
2808 if (user_val
> irq_last
) {
2809 dev_err(dev
, "debugfs error input > %d\n", irq_last
);
2813 irq_index
= user_val
- irq_first
;
2814 if (irq_index
>= num_irqs
)
2818 * This will create a sysfs file named <irq-nr> which userspace can
2819 * use to select or poll and get the AB8500 events
2821 dev_attr
[irq_index
] = kmalloc(sizeof(struct device_attribute
),
2823 if (!dev_attr
[irq_index
])
2826 event_name
[irq_index
] = kmalloc(count
, GFP_KERNEL
);
2827 if (!event_name
[irq_index
])
2830 sprintf(event_name
[irq_index
], "%lu", user_val
);
2831 dev_attr
[irq_index
]->show
= show_irq
;
2832 dev_attr
[irq_index
]->store
= NULL
;
2833 dev_attr
[irq_index
]->attr
.name
= event_name
[irq_index
];
2834 dev_attr
[irq_index
]->attr
.mode
= S_IRUGO
;
2835 err
= sysfs_create_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2837 pr_info("sysfs_create_file failed %d\n", err
);
2841 err
= request_threaded_irq(user_val
, NULL
, ab8500_debug_handler
,
2842 IRQF_SHARED
| IRQF_NO_SUSPEND
,
2843 "ab8500-debug", &dev
->kobj
);
2845 pr_info("request_threaded_irq failed %d, %lu\n",
2847 sysfs_remove_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2854 static ssize_t
ab8500_unsubscribe_write(struct file
*file
,
2855 const char __user
*user_buf
,
2856 size_t count
, loff_t
*ppos
)
2858 struct device
*dev
= ((struct seq_file
*)(file
->private_data
))->private;
2859 unsigned long user_val
;
2861 unsigned int irq_index
;
2863 err
= kstrtoul_from_user(user_buf
, count
, 0, &user_val
);
2867 if (user_val
< irq_first
) {
2868 dev_err(dev
, "debugfs error input < %d\n", irq_first
);
2871 if (user_val
> irq_last
) {
2872 dev_err(dev
, "debugfs error input > %d\n", irq_last
);
2876 irq_index
= user_val
- irq_first
;
2877 if (irq_index
>= num_irqs
)
2880 /* Set irq count to 0 when unsubscribe */
2881 irq_count
[irq_index
] = 0;
2883 if (dev_attr
[irq_index
])
2884 sysfs_remove_file(&dev
->kobj
, &dev_attr
[irq_index
]->attr
);
2887 free_irq(user_val
, &dev
->kobj
);
2888 kfree(event_name
[irq_index
]);
2889 kfree(dev_attr
[irq_index
]);
2895 * - several deubgfs nodes fops
2898 static const struct file_operations ab8500_bank_fops
= {
2899 .open
= ab8500_bank_open
,
2900 .write
= ab8500_bank_write
,
2902 .llseek
= seq_lseek
,
2903 .release
= single_release
,
2904 .owner
= THIS_MODULE
,
2907 static const struct file_operations ab8500_address_fops
= {
2908 .open
= ab8500_address_open
,
2909 .write
= ab8500_address_write
,
2911 .llseek
= seq_lseek
,
2912 .release
= single_release
,
2913 .owner
= THIS_MODULE
,
2916 static const struct file_operations ab8500_val_fops
= {
2917 .open
= ab8500_val_open
,
2918 .write
= ab8500_val_write
,
2920 .llseek
= seq_lseek
,
2921 .release
= single_release
,
2922 .owner
= THIS_MODULE
,
2925 static const struct file_operations ab8500_interrupts_fops
= {
2926 .open
= ab8500_interrupts_open
,
2928 .llseek
= seq_lseek
,
2929 .release
= single_release
,
2930 .owner
= THIS_MODULE
,
2933 static const struct file_operations ab8500_subscribe_fops
= {
2934 .open
= ab8500_subscribe_unsubscribe_open
,
2935 .write
= ab8500_subscribe_write
,
2937 .llseek
= seq_lseek
,
2938 .release
= single_release
,
2939 .owner
= THIS_MODULE
,
2942 static const struct file_operations ab8500_unsubscribe_fops
= {
2943 .open
= ab8500_subscribe_unsubscribe_open
,
2944 .write
= ab8500_unsubscribe_write
,
2946 .llseek
= seq_lseek
,
2947 .release
= single_release
,
2948 .owner
= THIS_MODULE
,
2951 static const struct file_operations ab8500_hwreg_fops
= {
2952 .open
= ab8500_hwreg_open
,
2953 .write
= ab8500_hwreg_write
,
2955 .llseek
= seq_lseek
,
2956 .release
= single_release
,
2957 .owner
= THIS_MODULE
,
2960 static struct dentry
*ab8500_dir
;
2961 static struct dentry
*ab8500_gpadc_dir
;
2963 static int ab8500_debug_probe(struct platform_device
*plf
)
2965 struct dentry
*file
;
2966 struct ab8500
*ab8500
;
2967 struct resource
*res
;
2969 debug_bank
= AB8500_MISC
;
2970 debug_address
= AB8500_REV_REG
& 0x00FF;
2972 ab8500
= dev_get_drvdata(plf
->dev
.parent
);
2973 num_irqs
= ab8500
->mask_size
;
2975 irq_count
= devm_kzalloc(&plf
->dev
,
2976 sizeof(*irq_count
)*num_irqs
, GFP_KERNEL
);
2980 dev_attr
= devm_kzalloc(&plf
->dev
,
2981 sizeof(*dev_attr
)*num_irqs
, GFP_KERNEL
);
2985 event_name
= devm_kzalloc(&plf
->dev
,
2986 sizeof(*event_name
)*num_irqs
, GFP_KERNEL
);
2990 res
= platform_get_resource_byname(plf
, 0, "IRQ_AB8500");
2992 dev_err(&plf
->dev
, "AB8500 irq not found, err %d\n", irq_first
);
2995 irq_ab8500
= res
->start
;
2997 irq_first
= platform_get_irq_byname(plf
, "IRQ_FIRST");
2998 if (irq_first
< 0) {
2999 dev_err(&plf
->dev
, "First irq not found, err %d\n", irq_first
);
3003 irq_last
= platform_get_irq_byname(plf
, "IRQ_LAST");
3005 dev_err(&plf
->dev
, "Last irq not found, err %d\n", irq_last
);
3009 ab8500_dir
= debugfs_create_dir(AB8500_NAME_STRING
, NULL
);
3013 ab8500_gpadc_dir
= debugfs_create_dir(AB8500_ADC_NAME_STRING
,
3015 if (!ab8500_gpadc_dir
)
3018 file
= debugfs_create_file("all-bank-registers", S_IRUGO
, ab8500_dir
,
3019 &plf
->dev
, &ab8500_registers_fops
);
3023 file
= debugfs_create_file("all-banks", S_IRUGO
, ab8500_dir
,
3024 &plf
->dev
, &ab8500_all_banks_fops
);
3028 file
= debugfs_create_file("register-bank",
3029 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3030 ab8500_dir
, &plf
->dev
, &ab8500_bank_fops
);
3034 file
= debugfs_create_file("register-address",
3035 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3036 ab8500_dir
, &plf
->dev
, &ab8500_address_fops
);
3040 file
= debugfs_create_file("register-value",
3041 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3042 ab8500_dir
, &plf
->dev
, &ab8500_val_fops
);
3046 file
= debugfs_create_file("irq-subscribe",
3047 (S_IRUGO
| S_IWUSR
| S_IWGRP
), ab8500_dir
,
3048 &plf
->dev
, &ab8500_subscribe_fops
);
3052 if (is_ab8500(ab8500
)) {
3053 debug_ranges
= ab8500_debug_ranges
;
3054 num_interrupt_lines
= AB8500_NR_IRQS
;
3055 } else if (is_ab8505(ab8500
)) {
3056 debug_ranges
= ab8505_debug_ranges
;
3057 num_interrupt_lines
= AB8505_NR_IRQS
;
3058 } else if (is_ab9540(ab8500
)) {
3059 debug_ranges
= ab8505_debug_ranges
;
3060 num_interrupt_lines
= AB9540_NR_IRQS
;
3061 } else if (is_ab8540(ab8500
)) {
3062 debug_ranges
= ab8540_debug_ranges
;
3063 num_interrupt_lines
= AB8540_NR_IRQS
;
3066 file
= debugfs_create_file("interrupts", (S_IRUGO
), ab8500_dir
,
3067 &plf
->dev
, &ab8500_interrupts_fops
);
3071 file
= debugfs_create_file("irq-unsubscribe",
3072 (S_IRUGO
| S_IWUSR
| S_IWGRP
), ab8500_dir
,
3073 &plf
->dev
, &ab8500_unsubscribe_fops
);
3077 file
= debugfs_create_file("hwreg", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3078 ab8500_dir
, &plf
->dev
, &ab8500_hwreg_fops
);
3082 file
= debugfs_create_file("all-modem-registers",
3083 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3084 ab8500_dir
, &plf
->dev
, &ab8500_modem_fops
);
3088 file
= debugfs_create_file("bat_ctrl", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3089 ab8500_gpadc_dir
, &plf
->dev
,
3090 &ab8500_gpadc_bat_ctrl_fops
);
3094 file
= debugfs_create_file("btemp_ball", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3096 &plf
->dev
, &ab8500_gpadc_btemp_ball_fops
);
3100 file
= debugfs_create_file("main_charger_v",
3101 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3102 ab8500_gpadc_dir
, &plf
->dev
,
3103 &ab8500_gpadc_main_charger_v_fops
);
3107 file
= debugfs_create_file("acc_detect1",
3108 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3109 ab8500_gpadc_dir
, &plf
->dev
,
3110 &ab8500_gpadc_acc_detect1_fops
);
3114 file
= debugfs_create_file("acc_detect2",
3115 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3116 ab8500_gpadc_dir
, &plf
->dev
,
3117 &ab8500_gpadc_acc_detect2_fops
);
3121 file
= debugfs_create_file("adc_aux1", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3122 ab8500_gpadc_dir
, &plf
->dev
,
3123 &ab8500_gpadc_aux1_fops
);
3127 file
= debugfs_create_file("adc_aux2", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3128 ab8500_gpadc_dir
, &plf
->dev
,
3129 &ab8500_gpadc_aux2_fops
);
3133 file
= debugfs_create_file("main_bat_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3134 ab8500_gpadc_dir
, &plf
->dev
,
3135 &ab8500_gpadc_main_bat_v_fops
);
3139 file
= debugfs_create_file("vbus_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3140 ab8500_gpadc_dir
, &plf
->dev
,
3141 &ab8500_gpadc_vbus_v_fops
);
3145 file
= debugfs_create_file("main_charger_c",
3146 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3147 ab8500_gpadc_dir
, &plf
->dev
,
3148 &ab8500_gpadc_main_charger_c_fops
);
3152 file
= debugfs_create_file("usb_charger_c",
3153 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3155 &plf
->dev
, &ab8500_gpadc_usb_charger_c_fops
);
3159 file
= debugfs_create_file("bk_bat_v", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3160 ab8500_gpadc_dir
, &plf
->dev
,
3161 &ab8500_gpadc_bk_bat_v_fops
);
3165 file
= debugfs_create_file("die_temp", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3166 ab8500_gpadc_dir
, &plf
->dev
,
3167 &ab8500_gpadc_die_temp_fops
);
3171 file
= debugfs_create_file("usb_id", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3172 ab8500_gpadc_dir
, &plf
->dev
,
3173 &ab8500_gpadc_usb_id_fops
);
3177 if (is_ab8540(ab8500
)) {
3178 file
= debugfs_create_file("xtal_temp",
3179 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3180 ab8500_gpadc_dir
, &plf
->dev
,
3181 &ab8540_gpadc_xtal_temp_fops
);
3184 file
= debugfs_create_file("vbattruemeas",
3185 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3186 ab8500_gpadc_dir
, &plf
->dev
,
3187 &ab8540_gpadc_vbat_true_meas_fops
);
3190 file
= debugfs_create_file("batctrl_and_ibat",
3191 (S_IRUGO
| S_IWUGO
),
3194 &ab8540_gpadc_bat_ctrl_and_ibat_fops
);
3197 file
= debugfs_create_file("vbatmeas_and_ibat",
3198 (S_IRUGO
| S_IWUGO
),
3199 ab8500_gpadc_dir
, &plf
->dev
,
3200 &ab8540_gpadc_vbat_meas_and_ibat_fops
);
3203 file
= debugfs_create_file("vbattruemeas_and_ibat",
3204 (S_IRUGO
| S_IWUGO
),
3207 &ab8540_gpadc_vbat_true_meas_and_ibat_fops
);
3210 file
= debugfs_create_file("battemp_and_ibat",
3211 (S_IRUGO
| S_IWUGO
),
3213 &plf
->dev
, &ab8540_gpadc_bat_temp_and_ibat_fops
);
3216 file
= debugfs_create_file("otp_calib",
3217 (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3219 &plf
->dev
, &ab8540_gpadc_otp_calib_fops
);
3223 file
= debugfs_create_file("avg_sample", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3224 ab8500_gpadc_dir
, &plf
->dev
,
3225 &ab8500_gpadc_avg_sample_fops
);
3229 file
= debugfs_create_file("trig_edge", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3230 ab8500_gpadc_dir
, &plf
->dev
,
3231 &ab8500_gpadc_trig_edge_fops
);
3235 file
= debugfs_create_file("trig_timer", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3236 ab8500_gpadc_dir
, &plf
->dev
,
3237 &ab8500_gpadc_trig_timer_fops
);
3241 file
= debugfs_create_file("conv_type", (S_IRUGO
| S_IWUSR
| S_IWGRP
),
3242 ab8500_gpadc_dir
, &plf
->dev
,
3243 &ab8500_gpadc_conv_type_fops
);
3250 debugfs_remove_recursive(ab8500_dir
);
3251 dev_err(&plf
->dev
, "failed to create debugfs entries.\n");
3256 static int ab8500_debug_remove(struct platform_device
*plf
)
3258 debugfs_remove_recursive(ab8500_dir
);
3263 static struct platform_driver ab8500_debug_driver
= {
3265 .name
= "ab8500-debug",
3266 .owner
= THIS_MODULE
,
3268 .probe
= ab8500_debug_probe
,
3269 .remove
= ab8500_debug_remove
3272 static int __init
ab8500_debug_init(void)
3274 return platform_driver_register(&ab8500_debug_driver
);
3277 static void __exit
ab8500_debug_exit(void)
3279 platform_driver_unregister(&ab8500_debug_driver
);
3281 subsys_initcall(ab8500_debug_init
);
3282 module_exit(ab8500_debug_exit
);
3284 MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
3285 MODULE_DESCRIPTION("AB8500 DEBUG");
3286 MODULE_LICENSE("GPL v2");