aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2013-02-26 14:03:33 +0000
committerLee Jones <lee.jones@linaro.org>2013-03-07 12:28:50 +0800
commitc7ebaee292fb0f935752d50ef9bad1db74efde6e (patch)
treeb08c99448d7932d80fdfdac2023e2f1b6c32b60c
parentc55355221e259bc4d6c1dc3ebe0852afce644a40 (diff)
mfd: ab8500-debugfs: Dump sim registers
This patch allows to dump the SIM registers from debugfs. It will temporary change the config to allow APE side to read the SIM registers. Note that this read can cause problem on modem side since the modem can't read these registers while the operation is ongoing. Signed-off-by: Mattias Wallin <mattias.wallin@stericsson.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/mfd/ab8500-debugfs.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 1e44d65e177..a653a0747b3 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -1244,6 +1244,79 @@ static int ab8500_hwreg_open(struct inode *inode, struct file *file)
return single_open(file, ab8500_hwreg_print, inode->i_private);
}
+#define AB8500_SUPPLY_CONTROL_CONFIG_1 0x01
+#define AB8500_SUPPLY_CONTROL_REG 0x00
+#define AB8500_FIRST_SIM_REG 0x80
+#define AB8500_LAST_SIM_REG 0x8B
+#define AB8505_LAST_SIM_REG 0x8C
+
+static int ab8500_print_modem_registers(struct seq_file *s, void *p)
+{
+ struct device *dev = s->private;
+ struct ab8500 *ab8500;
+ int err;
+ u8 value;
+ u8 orig_value;
+ u32 bank = AB8500_REGU_CTRL2;
+ u32 last_sim_reg = AB8500_LAST_SIM_REG;
+ u32 reg;
+
+ ab8500 = dev_get_drvdata(dev->parent);
+ dev_warn(dev, "WARNING! This operation can interfer with modem side\n"
+ "and should only be done with care\n");
+
+ err = abx500_get_register_interruptible(dev,
+ AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, &orig_value);
+ if (err < 0) {
+ dev_err(dev, "ab->read fail %d\n", err);
+ return err;
+ }
+ /* Config 1 will allow APE side to read SIM registers */
+ err = abx500_set_register_interruptible(dev,
+ AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG,
+ AB8500_SUPPLY_CONTROL_CONFIG_1);
+ if (err < 0) {
+ dev_err(dev, "ab->write fail %d\n", err);
+ return err;
+ }
+
+ seq_printf(s, " bank 0x%02X:\n", bank);
+
+ if (is_ab9540(ab8500) || is_ab8505(ab8500))
+ last_sim_reg = AB8505_LAST_SIM_REG;
+
+ for (reg = AB8500_FIRST_SIM_REG; reg <= last_sim_reg; reg++) {
+ err = abx500_get_register_interruptible(dev,
+ bank, reg, &value);
+ if (err < 0) {
+ dev_err(dev, "ab->read fail %d\n", err);
+ return err;
+ }
+ err = seq_printf(s, " [0x%02X/0x%02X]: 0x%02X\n",
+ bank, reg, value);
+ }
+ err = abx500_set_register_interruptible(dev,
+ AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, orig_value);
+ if (err < 0) {
+ dev_err(dev, "ab->write fail %d\n", err);
+ return err;
+ }
+ return 0;
+}
+
+static int ab8500_modem_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, ab8500_print_modem_registers, inode->i_private);
+}
+
+static const struct file_operations ab8500_modem_fops = {
+ .open = ab8500_modem_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .owner = THIS_MODULE,
+};
+
static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p)
{
int bat_ctrl_raw;
@@ -2570,6 +2643,11 @@ static int ab8500_debug_probe(struct platform_device *plf)
if (!file)
goto err;
+ file = debugfs_create_file("all-modem-registers", (S_IRUGO | S_IWUGO),
+ ab8500_dir, &plf->dev, &ab8500_modem_fops);
+ if (!file)
+ goto err;
+
file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR),
ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bat_ctrl_fops);
if (!file)