11 #include <linux/module.h>
18 static u32 debug_bank;
19 static u32 debug_address;
45 #define AB8500_NAME_STRING "ab8500"
46 #define AB8500_NUM_BANKS 22
48 #define AB8500_REV_REG 0x80
357 static int ab8500_registers_print(
struct seq_file *
s,
void *
p)
361 u32 bank = debug_bank;
366 for (i = 0; i < debug_ranges[bank].
num_ranges; i++) {
370 reg <= debug_ranges[bank].
range[
i].last;
376 (
u8)bank, (
u8)reg, &value);
378 dev_err(dev,
"ab->read fail %d\n", err);
382 err =
seq_printf(s,
" [%u/0x%02X]: 0x%02X\n", bank,
385 dev_err(dev,
"seq_printf overflow\n");
401 .open = ab8500_registers_open,
408 static int ab8500_bank_print(
struct seq_file *s,
void *p)
419 const char __user *user_buf,
420 size_t count, loff_t *ppos)
423 unsigned long user_bank;
432 dev_err(dev,
"debugfs error input > number of banks\n");
436 debug_bank = user_bank;
441 static int ab8500_address_print(
struct seq_file *s,
void *p)
443 return seq_printf(s,
"0x%02X\n", debug_address);
446 static int ab8500_address_open(
struct inode *
inode,
struct file *file)
451 static ssize_t ab8500_address_write(
struct file *file,
452 const char __user *user_buf,
453 size_t count, loff_t *ppos)
456 unsigned long user_address;
464 if (user_address > 0xff) {
465 dev_err(dev,
"debugfs error input > 0xff\n");
468 debug_address = user_address;
472 static int ab8500_val_print(
struct seq_file *s,
void *p)
479 (
u8)debug_bank, (
u8)debug_address, ®value);
481 dev_err(dev,
"abx500_get_reg fail %d, %d\n",
490 static int ab8500_val_open(
struct inode *
inode,
struct file *file)
495 static ssize_t ab8500_val_write(
struct file *file,
496 const char __user *user_buf,
497 size_t count, loff_t *ppos)
500 unsigned long user_val;
508 if (user_val > 0xff) {
509 dev_err(dev,
"debugfs error input > 0xff\n");
513 (
u8)debug_bank, debug_address, (
u8)user_val);
523 .open = ab8500_bank_open,
524 .write = ab8500_bank_write,
532 .open = ab8500_address_open,
533 .write = ab8500_address_write,
541 .open = ab8500_val_open,
542 .write = ab8500_val_write,
549 static struct dentry *ab8500_dir;
550 static struct dentry *ab8500_reg_file;
551 static struct dentry *ab8500_bank_file;
552 static struct dentry *ab8500_address_file;
553 static struct dentry *ab8500_val_file;
562 goto exit_no_debugfs;
565 S_IRUGO, ab8500_dir, &plf->
dev, &ab8500_registers_fops);
566 if (!ab8500_reg_file)
567 goto exit_destroy_dir;
571 if (!ab8500_bank_file)
572 goto exit_destroy_reg;
576 &ab8500_address_fops);
577 if (!ab8500_address_file)
578 goto exit_destroy_bank;
582 if (!ab8500_val_file)
583 goto exit_destroy_address;
587 exit_destroy_address:
596 dev_err(&plf->
dev,
"failed to create debugfs entries.\n");
613 .name =
"ab8500-debug",
616 .probe = ab8500_debug_probe,
620 static int __init ab8500_debug_init(
void)
625 static void __exit ab8500_debug_exit(
void)