aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Pihet <j-pihet@ti.com>2012-04-24 01:11:27 -0400
committerKevin Hilman <khilman@ti.com>2012-05-31 19:03:44 -0400
commit8b765d727d711650ab3521411fd48a0d8f62a84c (patch)
treee20803fa5d17ad670a016db4ae7a7d5146de9944
parent80821c9c90427dd0f9274a82f9d69e43300d10bb (diff)
ARM: OMAP2+: smartreflex: Use the names from hwmod data instead of voltage domains.
Associate a name with each SmartReflex instance from the hwmod data, rather than attempting to reuse the name of a voltage domain. The name from hwmod better reflects the smartreflex integration in the system. Also have the name passed to the drivers using pdata, which helps to remove any dependencies on SoC-specific structures. Signed-off-by: Jean Pihet <j-pihet@ti.com> Signed-off-by: J Keerthy <j-keerthy@ti.com> Reviewed-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Kevin Hilman <khilman@ti.com>
-rw-r--r--arch/arm/mach-omap2/smartreflex-class3.c4
-rw-r--r--arch/arm/mach-omap2/smartreflex.c65
-rw-r--r--arch/arm/mach-omap2/sr_device.c1
-rw-r--r--include/linux/power/smartreflex.h3
4 files changed, 32 insertions, 41 deletions
diff --git a/arch/arm/mach-omap2/smartreflex-class3.c b/arch/arm/mach-omap2/smartreflex-class3.c
index 9381654e869b..1da8f03c479e 100644
--- a/arch/arm/mach-omap2/smartreflex-class3.c
+++ b/arch/arm/mach-omap2/smartreflex-class3.c
@@ -19,8 +19,8 @@ static int sr_class3_enable(struct omap_sr *sr)
19 unsigned long volt = voltdm_get_voltage(sr->voltdm); 19 unsigned long volt = voltdm_get_voltage(sr->voltdm);
20 20
21 if (!volt) { 21 if (!volt) {
22 pr_warning("%s: Curr voltage unknown. Cannot enable sr_%s\n", 22 pr_warning("%s: Curr voltage unknown. Cannot enable %s\n",
23 __func__, sr->voltdm->name); 23 __func__, sr->name);
24 return -ENODATA; 24 return -ENODATA;
25 } 25 }
26 26
diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index 82bdd2838a17..2edd1e2e4622 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -183,7 +183,7 @@ static void sr_set_regfields(struct omap_sr *sr)
183 sr->err_weight = OMAP3430_SR_ERRWEIGHT; 183 sr->err_weight = OMAP3430_SR_ERRWEIGHT;
184 sr->err_maxlimit = OMAP3430_SR_ERRMAXLIMIT; 184 sr->err_maxlimit = OMAP3430_SR_ERRMAXLIMIT;
185 sr->accum_data = OMAP3430_SR_ACCUMDATA; 185 sr->accum_data = OMAP3430_SR_ACCUMDATA;
186 if (!(strcmp(sr->voltdm->name, "mpu"))) { 186 if (!(strcmp(sr->name, "sr1"))) {
187 sr->senn_avgweight = OMAP3430_SR1_SENNAVGWEIGHT; 187 sr->senn_avgweight = OMAP3430_SR1_SENNAVGWEIGHT;
188 sr->senp_avgweight = OMAP3430_SR1_SENPAVGWEIGHT; 188 sr->senp_avgweight = OMAP3430_SR1_SENPAVGWEIGHT;
189 } else { 189 } else {
@@ -234,19 +234,13 @@ static void sr_stop_vddautocomp(struct omap_sr *sr)
234 */ 234 */
235static int sr_late_init(struct omap_sr *sr_info) 235static int sr_late_init(struct omap_sr *sr_info)
236{ 236{
237 char *name;
238 struct omap_sr_data *pdata = sr_info->pdev->dev.platform_data; 237 struct omap_sr_data *pdata = sr_info->pdev->dev.platform_data;
239 struct resource *mem; 238 struct resource *mem;
240 int ret = 0; 239 int ret = 0;
241 240
242 if (sr_class->notify && sr_class->notify_flags && sr_info->irq) { 241 if (sr_class->notify && sr_class->notify_flags && sr_info->irq) {
243 name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
244 if (name == NULL) {
245 ret = -ENOMEM;
246 goto error;
247 }
248 ret = request_irq(sr_info->irq, sr_interrupt, 242 ret = request_irq(sr_info->irq, sr_interrupt,
249 0, name, sr_info); 243 0, sr_info->name, sr_info);
250 if (ret) 244 if (ret)
251 goto error; 245 goto error;
252 disable_irq(sr_info->irq); 246 disable_irq(sr_info->irq);
@@ -265,7 +259,6 @@ error:
265 dev_err(&sr_info->pdev->dev, "%s: ERROR in registering" 259 dev_err(&sr_info->pdev->dev, "%s: ERROR in registering"
266 "interrupt handler. Smartreflex will" 260 "interrupt handler. Smartreflex will"
267 "not function as desired\n", __func__); 261 "not function as desired\n", __func__);
268 kfree(name);
269 kfree(sr_info); 262 kfree(sr_info);
270 263
271 return ret; 264 return ret;
@@ -395,8 +388,7 @@ int sr_configure_errgen(struct voltagedomain *voltdm)
395 struct omap_sr *sr = _sr_lookup(voltdm); 388 struct omap_sr *sr = _sr_lookup(voltdm);
396 389
397 if (IS_ERR(sr)) { 390 if (IS_ERR(sr)) {
398 pr_warning("%s: omap_sr struct for sr_%s not found\n", 391 pr_warning("%s: omap_sr struct for voltdm not found\n", __func__);
399 __func__, voltdm->name);
400 return PTR_ERR(sr); 392 return PTR_ERR(sr);
401 } 393 }
402 394
@@ -463,8 +455,7 @@ int sr_disable_errgen(struct voltagedomain *voltdm)
463 struct omap_sr *sr = _sr_lookup(voltdm); 455 struct omap_sr *sr = _sr_lookup(voltdm);
464 456
465 if (IS_ERR(sr)) { 457 if (IS_ERR(sr)) {
466 pr_warning("%s: omap_sr struct for sr_%s not found\n", 458 pr_warning("%s: omap_sr struct for voltdm not found\n", __func__);
467 __func__, voltdm->name);
468 return PTR_ERR(sr); 459 return PTR_ERR(sr);
469 } 460 }
470 461
@@ -514,8 +505,7 @@ int sr_configure_minmax(struct voltagedomain *voltdm)
514 struct omap_sr *sr = _sr_lookup(voltdm); 505 struct omap_sr *sr = _sr_lookup(voltdm);
515 506
516 if (IS_ERR(sr)) { 507 if (IS_ERR(sr)) {
517 pr_warning("%s: omap_sr struct for sr_%s not found\n", 508 pr_warning("%s: omap_sr struct for voltdm not found\n", __func__);
518 __func__, voltdm->name);
519 return PTR_ERR(sr); 509 return PTR_ERR(sr);
520 } 510 }
521 511
@@ -600,8 +590,7 @@ int sr_enable(struct voltagedomain *voltdm, unsigned long volt)
600 int ret; 590 int ret;
601 591
602 if (IS_ERR(sr)) { 592 if (IS_ERR(sr)) {
603 pr_warning("%s: omap_sr struct for sr_%s not found\n", 593 pr_warning("%s: omap_sr struct for voltdm not found\n", __func__);
604 __func__, voltdm->name);
605 return PTR_ERR(sr); 594 return PTR_ERR(sr);
606 } 595 }
607 596
@@ -654,8 +643,7 @@ void sr_disable(struct voltagedomain *voltdm)
654 struct omap_sr *sr = _sr_lookup(voltdm); 643 struct omap_sr *sr = _sr_lookup(voltdm);
655 644
656 if (IS_ERR(sr)) { 645 if (IS_ERR(sr)) {
657 pr_warning("%s: omap_sr struct for sr_%s not found\n", 646 pr_warning("%s: omap_sr struct for voltdm not found\n", __func__);
658 __func__, voltdm->name);
659 return; 647 return;
660 } 648 }
661 649
@@ -735,8 +723,7 @@ void omap_sr_enable(struct voltagedomain *voltdm)
735 struct omap_sr *sr = _sr_lookup(voltdm); 723 struct omap_sr *sr = _sr_lookup(voltdm);
736 724
737 if (IS_ERR(sr)) { 725 if (IS_ERR(sr)) {
738 pr_warning("%s: omap_sr struct for sr_%s not found\n", 726 pr_warning("%s: omap_sr struct for voltdm not found\n", __func__);
739 __func__, voltdm->name);
740 return; 727 return;
741 } 728 }
742 729
@@ -768,8 +755,7 @@ void omap_sr_disable(struct voltagedomain *voltdm)
768 struct omap_sr *sr = _sr_lookup(voltdm); 755 struct omap_sr *sr = _sr_lookup(voltdm);
769 756
770 if (IS_ERR(sr)) { 757 if (IS_ERR(sr)) {
771 pr_warning("%s: omap_sr struct for sr_%s not found\n", 758 pr_warning("%s: omap_sr struct for voltdm not found\n", __func__);
772 __func__, voltdm->name);
773 return; 759 return;
774 } 760 }
775 761
@@ -801,8 +787,7 @@ void omap_sr_disable_reset_volt(struct voltagedomain *voltdm)
801 struct omap_sr *sr = _sr_lookup(voltdm); 787 struct omap_sr *sr = _sr_lookup(voltdm);
802 788
803 if (IS_ERR(sr)) { 789 if (IS_ERR(sr)) {
804 pr_warning("%s: omap_sr struct for sr_%s not found\n", 790 pr_warning("%s: omap_sr struct for voltdm not found\n", __func__);
805 __func__, voltdm->name);
806 return; 791 return;
807 } 792 }
808 793
@@ -889,7 +874,6 @@ static int __init omap_sr_probe(struct platform_device *pdev)
889 struct dentry *nvalue_dir; 874 struct dentry *nvalue_dir;
890 struct omap_volt_data *volt_data; 875 struct omap_volt_data *volt_data;
891 int i, ret = 0; 876 int i, ret = 0;
892 char *name;
893 877
894 sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL); 878 sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL);
895 if (!sr_info) { 879 if (!sr_info) {
@@ -926,6 +910,14 @@ static int __init omap_sr_probe(struct platform_device *pdev)
926 pm_runtime_enable(&pdev->dev); 910 pm_runtime_enable(&pdev->dev);
927 pm_runtime_irq_safe(&pdev->dev); 911 pm_runtime_irq_safe(&pdev->dev);
928 912
913 sr_info->name = kasprintf(GFP_KERNEL, "%s", pdata->name);
914 if (!sr_info->name) {
915 dev_err(&pdev->dev, "%s: Unable to alloc SR instance name\n",
916 __func__);
917 ret = -ENOMEM;
918 goto err_release_region;
919 }
920
929 sr_info->pdev = pdev; 921 sr_info->pdev = pdev;
930 sr_info->srid = pdev->id; 922 sr_info->srid = pdev->id;
931 sr_info->voltdm = pdata->voltdm; 923 sr_info->voltdm = pdata->voltdm;
@@ -973,20 +965,12 @@ static int __init omap_sr_probe(struct platform_device *pdev)
973 } 965 }
974 } 966 }
975 967
976 name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name); 968 sr_info->dbg_dir = debugfs_create_dir(sr_info->name, sr_dbg_dir);
977 if (!name) {
978 dev_err(&pdev->dev, "%s: Unable to alloc debugfs name\n",
979 __func__);
980 ret = -ENOMEM;
981 goto err_iounmap;
982 }
983 sr_info->dbg_dir = debugfs_create_dir(name, sr_dbg_dir);
984 kfree(name);
985 if (IS_ERR_OR_NULL(sr_info->dbg_dir)) { 969 if (IS_ERR_OR_NULL(sr_info->dbg_dir)) {
986 dev_err(&pdev->dev, "%s: Unable to create debugfs directory\n", 970 dev_err(&pdev->dev, "%s: Unable to create debugfs directory\n",
987 __func__); 971 __func__);
988 ret = PTR_ERR(sr_info->dbg_dir); 972 ret = PTR_ERR(sr_info->dbg_dir);
989 goto err_iounmap; 973 goto err_free_name;
990 } 974 }
991 975
992 (void) debugfs_create_file("autocomp", S_IRUGO | S_IWUSR, 976 (void) debugfs_create_file("autocomp", S_IRUGO | S_IWUSR,
@@ -1008,10 +992,10 @@ static int __init omap_sr_probe(struct platform_device *pdev)
1008 992
1009 omap_voltage_get_volttable(sr_info->voltdm, &volt_data); 993 omap_voltage_get_volttable(sr_info->voltdm, &volt_data);
1010 if (!volt_data) { 994 if (!volt_data) {
1011 dev_warn(&pdev->dev, "%s: No Voltage table for the" 995 dev_warn(&pdev->dev, "%s: %s: No Voltage table for the"
1012 " corresponding vdd vdd_%s. Cannot create debugfs" 996 " corresponding vdd. Cannot create debugfs"
1013 "entries for n-values\n", 997 "entries for n-values\n",
1014 __func__, sr_info->voltdm->name); 998 __func__, sr_info->name);
1015 ret = -ENODATA; 999 ret = -ENODATA;
1016 goto err_debugfs; 1000 goto err_debugfs;
1017 } 1001 }
@@ -1029,6 +1013,8 @@ static int __init omap_sr_probe(struct platform_device *pdev)
1029 1013
1030err_debugfs: 1014err_debugfs:
1031 debugfs_remove_recursive(sr_info->dbg_dir); 1015 debugfs_remove_recursive(sr_info->dbg_dir);
1016err_free_name:
1017 kfree(sr_info->name);
1032err_iounmap: 1018err_iounmap:
1033 list_del(&sr_info->node); 1019 list_del(&sr_info->node);
1034 iounmap(sr_info->base); 1020 iounmap(sr_info->base);
@@ -1065,6 +1051,7 @@ static int __devexit omap_sr_remove(struct platform_device *pdev)
1065 1051
1066 list_del(&sr_info->node); 1052 list_del(&sr_info->node);
1067 iounmap(sr_info->base); 1053 iounmap(sr_info->base);
1054 kfree(sr_info->name);
1068 kfree(sr_info); 1055 kfree(sr_info);
1069 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1056 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1070 release_mem_region(mem->start, resource_size(mem)); 1057 release_mem_region(mem->start, resource_size(mem));
diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c
index 86e438e75105..e081174f28af 100644
--- a/arch/arm/mach-omap2/sr_device.c
+++ b/arch/arm/mach-omap2/sr_device.c
@@ -93,6 +93,7 @@ static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
93 goto exit; 93 goto exit;
94 } 94 }
95 95
96 sr_data->name = oh->name;
96 sr_data->ip_type = oh->class->rev; 97 sr_data->ip_type = oh->class->rev;
97 sr_data->senn_mod = 0x1; 98 sr_data->senn_mod = 0x1;
98 sr_data->senp_mod = 0x1; 99 sr_data->senp_mod = 0x1;
diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
index 4224698cf8bd..884eaeea96be 100644
--- a/include/linux/power/smartreflex.h
+++ b/include/linux/power/smartreflex.h
@@ -144,6 +144,7 @@
144#define OMAP3430_SR_ERRMAXLIMIT 0x02 144#define OMAP3430_SR_ERRMAXLIMIT 0x02
145 145
146struct omap_sr { 146struct omap_sr {
147 char *name;
147 struct list_head node; 148 struct list_head node;
148 struct platform_device *pdev; 149 struct platform_device *pdev;
149 struct omap_sr_nvalue_table *nvalue_table; 150 struct omap_sr_nvalue_table *nvalue_table;
@@ -232,6 +233,7 @@ struct omap_sr_nvalue_table {
232/** 233/**
233 * struct omap_sr_data - Smartreflex platform data. 234 * struct omap_sr_data - Smartreflex platform data.
234 * 235 *
236 * @name: instance name
235 * @ip_type: Smartreflex IP type. 237 * @ip_type: Smartreflex IP type.
236 * @senp_mod: SENPENABLE value for the sr 238 * @senp_mod: SENPENABLE value for the sr
237 * @senn_mod: SENNENABLE value for sr 239 * @senn_mod: SENNENABLE value for sr
@@ -243,6 +245,7 @@ struct omap_sr_nvalue_table {
243 * @voltdm: Pointer to the voltage domain associated with the SR 245 * @voltdm: Pointer to the voltage domain associated with the SR
244 */ 246 */
245struct omap_sr_data { 247struct omap_sr_data {
248 const char *name;
246 int ip_type; 249 int ip_type;
247 u32 senp_mod; 250 u32 senp_mod;
248 u32 senn_mod; 251 u32 senn_mod;