aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorThara Gopinath <thara@ti.com>2010-10-27 10:59:37 -0400
committerKevin Hilman <khilman@deeprootsystems.com>2010-12-22 17:31:42 -0500
commit077fceca3a5db69791d64723ffba1caad2f03a08 (patch)
treef81edc23062a8573fd744eb6d7c4b5d396501911 /arch
parentfbc319f67660ede23cc22f3af5df559693f8062e (diff)
OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers
This patch adds debug support to the voltage and smartreflex drivers. This means a whole bunch of voltage processor and smartreflex parameters are now visible through the pm debugfs. The voltage parameters can be viewed at /debug/voltage/vdd_<x>/<parameter> and the smartreflex parameters can be viewed at /debug/voltage/vdd_<x>/smartreflex/<parameter> Also smartreflex n-target values are now exposed out at /debug/voltage/vdd_<x>/smartreflex/nvalue/<voltage> This is a read-write interface which means user has the flexibility to change the n-target values for any opp. Signed-off-by: Thara Gopinath <thara@ti.com> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap2/smartreflex.c46
-rw-r--r--arch/arm/mach-omap2/voltage.c66
2 files changed, 110 insertions, 2 deletions
diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index eee23d0f50de..52a05b336c08 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -31,6 +31,7 @@
31#include "pm.h" 31#include "pm.h"
32 32
33#define SMARTREFLEX_NAME_LEN 16 33#define SMARTREFLEX_NAME_LEN 16
34#define NVALUE_NAME_LEN 40
34#define SR_DISABLE_TIMEOUT 200 35#define SR_DISABLE_TIMEOUT 200
35 36
36struct omap_sr { 37struct omap_sr {
@@ -817,8 +818,9 @@ static int __init omap_sr_probe(struct platform_device *pdev)
817 struct omap_sr *sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL); 818 struct omap_sr *sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL);
818 struct omap_sr_data *pdata = pdev->dev.platform_data; 819 struct omap_sr_data *pdata = pdev->dev.platform_data;
819 struct resource *mem, *irq; 820 struct resource *mem, *irq;
820 struct dentry *vdd_dbg_dir, *dbg_dir; 821 struct dentry *vdd_dbg_dir, *dbg_dir, *nvalue_dir;
821 int ret = 0; 822 struct omap_volt_data *volt_data;
823 int i, ret = 0;
822 824
823 if (!sr_info) { 825 if (!sr_info) {
824 dev_err(&pdev->dev, "%s: unable to allocate sr_info\n", 826 dev_err(&pdev->dev, "%s: unable to allocate sr_info\n",
@@ -897,6 +899,46 @@ static int __init omap_sr_probe(struct platform_device *pdev)
897 899
898 (void) debugfs_create_file("autocomp", S_IRUGO | S_IWUGO, dbg_dir, 900 (void) debugfs_create_file("autocomp", S_IRUGO | S_IWUGO, dbg_dir,
899 (void *)sr_info, &pm_sr_fops); 901 (void *)sr_info, &pm_sr_fops);
902 (void) debugfs_create_x32("errweight", S_IRUGO, dbg_dir,
903 &sr_info->err_weight);
904 (void) debugfs_create_x32("errmaxlimit", S_IRUGO, dbg_dir,
905 &sr_info->err_maxlimit);
906 (void) debugfs_create_x32("errminlimit", S_IRUGO, dbg_dir,
907 &sr_info->err_minlimit);
908
909 nvalue_dir = debugfs_create_dir("nvalue", dbg_dir);
910 if (IS_ERR(nvalue_dir)) {
911 dev_err(&pdev->dev, "%s: Unable to create debugfs directory"
912 "for n-values\n", __func__);
913 return PTR_ERR(nvalue_dir);
914 }
915
916 omap_voltage_get_volttable(sr_info->voltdm, &volt_data);
917 if (!volt_data) {
918 dev_warn(&pdev->dev, "%s: No Voltage table for the"
919 " corresponding vdd vdd_%s. Cannot create debugfs"
920 "entries for n-values\n",
921 __func__, sr_info->voltdm->name);
922 return -ENODATA;
923 }
924
925 for (i = 0; i < sr_info->nvalue_count; i++) {
926 char *name;
927 char volt_name[32];
928
929 name = kzalloc(NVALUE_NAME_LEN + 1, GFP_KERNEL);
930 if (!name) {
931 dev_err(&pdev->dev, "%s: Unable to allocate memory"
932 " for n-value directory name\n", __func__);
933 return -ENOMEM;
934 }
935
936 strcpy(name, "volt_");
937 sprintf(volt_name, "%d", volt_data[i].volt_nominal);
938 strcat(name, volt_name);
939 (void) debugfs_create_x32(name, S_IRUGO | S_IWUGO, nvalue_dir,
940 &(sr_info->nvalue_table[i].nvalue));
941 }
900 942
901 return ret; 943 return ret;
902 944
diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index 875667f130e3..b27fa4f241fd 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -250,6 +250,47 @@ static void omap3_voltage_write_reg(u32 val, u16 mod, u8 offset)
250 omap2_prm_write_mod_reg(val, mod, offset); 250 omap2_prm_write_mod_reg(val, mod, offset);
251} 251}
252 252
253/* Voltage debugfs support */
254static int vp_volt_debug_get(void *data, u64 *val)
255{
256 struct omap_vdd_info *vdd = (struct omap_vdd_info *) data;
257 u8 vsel;
258
259 if (!vdd) {
260 pr_warning("Wrong paramater passed\n");
261 return -EINVAL;
262 }
263
264 vsel = vdd->read_reg(vdd->vp_reg.prm_mod, vdd->vp_offs.voltage);
265 pr_notice("curr_vsel = %x\n", vsel);
266
267 if (!vdd->pmic_info->vsel_to_uv) {
268 pr_warning("PMIC function to convert vsel to voltage"
269 "in uV not registerd\n");
270 return -EINVAL;
271 }
272
273 *val = vdd->pmic_info->vsel_to_uv(vsel);
274 return 0;
275}
276
277static int nom_volt_debug_get(void *data, u64 *val)
278{
279 struct omap_vdd_info *vdd = (struct omap_vdd_info *) data;
280
281 if (!vdd) {
282 pr_warning("Wrong paramater passed\n");
283 return -EINVAL;
284 }
285
286 *val = omap_voltage_get_nom_volt(&vdd->voltdm);
287
288 return 0;
289}
290
291DEFINE_SIMPLE_ATTRIBUTE(vp_volt_debug_fops, vp_volt_debug_get, NULL, "%llu\n");
292DEFINE_SIMPLE_ATTRIBUTE(nom_volt_debug_fops, nom_volt_debug_get, NULL,
293 "%llu\n");
253static void vp_latch_vsel(struct omap_vdd_info *vdd) 294static void vp_latch_vsel(struct omap_vdd_info *vdd)
254{ 295{
255 u32 vpconfig; 296 u32 vpconfig;
@@ -349,7 +390,32 @@ static void __init vdd_debugfs_init(struct omap_vdd_info *vdd)
349 pr_warning("%s: Unable to create debugfs directory for" 390 pr_warning("%s: Unable to create debugfs directory for"
350 " vdd_%s\n", __func__, vdd->voltdm.name); 391 " vdd_%s\n", __func__, vdd->voltdm.name);
351 vdd->debug_dir = NULL; 392 vdd->debug_dir = NULL;
393 return;
352 } 394 }
395
396 (void) debugfs_create_x16("vp_errorgain", S_IRUGO, vdd->debug_dir,
397 &(vdd->vp_reg.vpconfig_errorgain));
398 (void) debugfs_create_x16("vp_smpswaittimemin", S_IRUGO,
399 vdd->debug_dir,
400 &(vdd->vp_reg.vstepmin_smpswaittimemin));
401 (void) debugfs_create_x8("vp_stepmin", S_IRUGO, vdd->debug_dir,
402 &(vdd->vp_reg.vstepmin_stepmin));
403 (void) debugfs_create_x16("vp_smpswaittimemax", S_IRUGO,
404 vdd->debug_dir,
405 &(vdd->vp_reg.vstepmax_smpswaittimemax));
406 (void) debugfs_create_x8("vp_stepmax", S_IRUGO, vdd->debug_dir,
407 &(vdd->vp_reg.vstepmax_stepmax));
408 (void) debugfs_create_x8("vp_vddmax", S_IRUGO, vdd->debug_dir,
409 &(vdd->vp_reg.vlimitto_vddmax));
410 (void) debugfs_create_x8("vp_vddmin", S_IRUGO, vdd->debug_dir,
411 &(vdd->vp_reg.vlimitto_vddmin));
412 (void) debugfs_create_x16("vp_timeout", S_IRUGO, vdd->debug_dir,
413 &(vdd->vp_reg.vlimitto_timeout));
414 (void) debugfs_create_file("curr_vp_volt", S_IRUGO, vdd->debug_dir,
415 (void *) vdd, &vp_volt_debug_fops);
416 (void) debugfs_create_file("curr_nominal_volt", S_IRUGO,
417 vdd->debug_dir, (void *) vdd,
418 &nom_volt_debug_fops);
353} 419}
354 420
355/* Voltage scale and accessory APIs */ 421/* Voltage scale and accessory APIs */