aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ab8500-debugfs.c
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2013-02-26 09:03:33 -0500
committerLee Jones <lee.jones@linaro.org>2013-03-06 23:28:50 -0500
commitc7ebaee292fb0f935752d50ef9bad1db74efde6e (patch)
treeb08c99448d7932d80fdfdac2023e2f1b6c32b60c /drivers/mfd/ab8500-debugfs.c
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>
Diffstat (limited to 'drivers/mfd/ab8500-debugfs.c')
-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 1e44d65e1771..a653a0747b31 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)
1244 return single_open(file, ab8500_hwreg_print, inode->i_private); 1244 return single_open(file, ab8500_hwreg_print, inode->i_private);
1245} 1245}
1246 1246
1247#define AB8500_SUPPLY_CONTROL_CONFIG_1 0x01
1248#define AB8500_SUPPLY_CONTROL_REG 0x00
1249#define AB8500_FIRST_SIM_REG 0x80
1250#define AB8500_LAST_SIM_REG 0x8B
1251#define AB8505_LAST_SIM_REG 0x8C
1252
1253static int ab8500_print_modem_registers(struct seq_file *s, void *p)
1254{
1255 struct device *dev = s->private;
1256 struct ab8500 *ab8500;
1257 int err;
1258 u8 value;
1259 u8 orig_value;
1260 u32 bank = AB8500_REGU_CTRL2;
1261 u32 last_sim_reg = AB8500_LAST_SIM_REG;
1262 u32 reg;
1263
1264 ab8500 = dev_get_drvdata(dev->parent);
1265 dev_warn(dev, "WARNING! This operation can interfer with modem side\n"
1266 "and should only be done with care\n");
1267
1268 err = abx500_get_register_interruptible(dev,
1269 AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, &orig_value);
1270 if (err < 0) {
1271 dev_err(dev, "ab->read fail %d\n", err);
1272 return err;
1273 }
1274 /* Config 1 will allow APE side to read SIM registers */
1275 err = abx500_set_register_interruptible(dev,
1276 AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG,
1277 AB8500_SUPPLY_CONTROL_CONFIG_1);
1278 if (err < 0) {
1279 dev_err(dev, "ab->write fail %d\n", err);
1280 return err;
1281 }
1282
1283 seq_printf(s, " bank 0x%02X:\n", bank);
1284
1285 if (is_ab9540(ab8500) || is_ab8505(ab8500))
1286 last_sim_reg = AB8505_LAST_SIM_REG;
1287
1288 for (reg = AB8500_FIRST_SIM_REG; reg <= last_sim_reg; reg++) {
1289 err = abx500_get_register_interruptible(dev,
1290 bank, reg, &value);
1291 if (err < 0) {
1292 dev_err(dev, "ab->read fail %d\n", err);
1293 return err;
1294 }
1295 err = seq_printf(s, " [0x%02X/0x%02X]: 0x%02X\n",
1296 bank, reg, value);
1297 }
1298 err = abx500_set_register_interruptible(dev,
1299 AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, orig_value);
1300 if (err < 0) {
1301 dev_err(dev, "ab->write fail %d\n", err);
1302 return err;
1303 }
1304 return 0;
1305}
1306
1307static int ab8500_modem_open(struct inode *inode, struct file *file)
1308{
1309 return single_open(file, ab8500_print_modem_registers, inode->i_private);
1310}
1311
1312static const struct file_operations ab8500_modem_fops = {
1313 .open = ab8500_modem_open,
1314 .read = seq_read,
1315 .llseek = seq_lseek,
1316 .release = single_release,
1317 .owner = THIS_MODULE,
1318};
1319
1247static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p) 1320static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p)
1248{ 1321{
1249 int bat_ctrl_raw; 1322 int bat_ctrl_raw;
@@ -2570,6 +2643,11 @@ static int ab8500_debug_probe(struct platform_device *plf)
2570 if (!file) 2643 if (!file)
2571 goto err; 2644 goto err;
2572 2645
2646 file = debugfs_create_file("all-modem-registers", (S_IRUGO | S_IWUGO),
2647 ab8500_dir, &plf->dev, &ab8500_modem_fops);
2648 if (!file)
2649 goto err;
2650
2573 file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR), 2651 file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR),
2574 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bat_ctrl_fops); 2652 ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bat_ctrl_fops);
2575 if (!file) 2653 if (!file)