diff options
author | Timo Alho <talho@nvidia.com> | 2013-12-30 17:18:03 +0200 |
---|---|---|
committer | Juha Tukkinen <jtukkinen@nvidia.com> | 2014-01-02 03:04:00 -0800 |
commit | f7a25fe70adb0b18169ff86de8358a4c973d8bb0 (patch) | |
tree | 60e612959fe53a783f65e97ce6ee586d59b40f0a /drivers/edp | |
parent | 4a1c9e116ccb573afe6307495f32c8f54ee91ad3 (diff) |
EDP: sysedp: add batmon debugfs entries
Add debugfs entries to sysedp_batmon_calc component.
* rbat - to show battery impedance table
* ibat - to show max. battery current table
* ocv - to show battery ocv table
* vsys_min - to show min. VSYS vlotage
* r_const - to show board impedance
Change-Id: I8a59450bdb080304630c88bbf140ad91f50f46d5
Signed-off-by: Timo Alho <talho@nvidia.com>
Reviewed-on: http://git-master/r/350657
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>
Diffstat (limited to 'drivers/edp')
-rw-r--r-- | drivers/edp/sysedp_batmon_calc.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/drivers/edp/sysedp_batmon_calc.c b/drivers/edp/sysedp_batmon_calc.c index 0f5db1196e4d..87e7a246b5fe 100644 --- a/drivers/edp/sysedp_batmon_calc.c +++ b/drivers/edp/sysedp_batmon_calc.c @@ -275,6 +275,92 @@ static int init_ocv_reader(void) return 0; } +#ifdef CONFIG_DEBUG_FS + +static int rbat_show(struct seq_file *file, void *data) +{ + int t, c, i = 0; + struct sysedp_batmon_rbat_lut *lut = pdata->rbat_lut; + + seq_printf(file, " %8s", "capacity"); + for (t = 0; t < lut->temp_size; t++) + seq_printf(file, "%7dC", lut->temp_axis[t]); + seq_puts(file, "\n"); + + for (c = 0; c < lut->capacity_size; c++) { + seq_printf(file, "%8d%%", lut->capacity_axis[c]); + for (t = 0; t < lut->temp_size; t++) + seq_printf(file, "%8d", lut->data[i++]); + seq_puts(file, "\n"); + } + return 0; +} + +static int ibat_show(struct seq_file *file, void *data) +{ + struct sysedp_batmon_ibat_lut *lut = pdata->ibat_lut; + + if (lut) { + do { + seq_printf(file, "%7dC %7dmA\n", lut->temp, lut->ibat); + } while ((lut++)->ibat); + } + return 0; +} + +static int ocv_show(struct seq_file *file, void *data) +{ + struct sysedp_batmon_ocv_lut *lut = pdata->ocv_lut; + + if (lut) { + do { + seq_printf(file, "%7d%% %7duV\n", lut->capacity, + lut->ocv); + } while ((lut++)->capacity); + } + return 0; +} + +static int debug_open(struct inode *inode, struct file *file) +{ + return single_open(file, inode->i_private, NULL); +} + +static const struct file_operations debug_fops = { + .open = debug_open, + .read = seq_read, +}; + +static void init_debug(void) +{ + struct dentry *dd, *df; + + if (!sysedp_debugfs_dir) + return; + + dd = debugfs_create_dir("batmon", sysedp_debugfs_dir); + WARN_ON(IS_ERR_OR_NULL(dd)); + + df = debugfs_create_file("rbat", S_IRUGO, dd, rbat_show, &debug_fops); + WARN_ON(IS_ERR_OR_NULL(df)); + + df = debugfs_create_file("ibat", S_IRUGO, dd, ibat_show, &debug_fops); + WARN_ON(IS_ERR_OR_NULL(df)); + + df = debugfs_create_file("ocv", S_IRUGO, dd, ocv_show, &debug_fops); + WARN_ON(IS_ERR_OR_NULL(df)); + + df = debugfs_create_u32("r_const", S_IRUGO, dd, &pdata->r_const); + WARN_ON(IS_ERR_OR_NULL(df)); + + df = debugfs_create_u32("vsys_min", S_IRUGO, dd, &pdata->vsys_min); + WARN_ON(IS_ERR_OR_NULL(df)); +} +#else +static inline void init_debug(void) {} +#endif + + static void of_batmon_calc_get_pdata(struct platform_device *pdev, struct sysedp_batmon_calc_platform_data **pdata) { @@ -503,6 +589,8 @@ static int batmon_probe(struct platform_device *pdev) INIT_DEFERRABLE_WORK(&work, batmon_update); schedule_delayed_work(&work, 0); + init_debug(); + return 0; } |