aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2012-02-29 17:33:46 -0500
committerKevin Hilman <khilman@ti.com>2012-03-05 14:29:27 -0500
commit4018bfebc6e704838f1a9f1d96110d9bd68ae0f9 (patch)
tree47cf36c0fe0cdf164ee5cae725a36054608f386a /arch/arm/mach-omap2
parent1a21a680f1679c9648821f052abb5e77ad0f48af (diff)
ARM: OMAP3+: SmartReflex: misc cleanups
There are no functional changes here, only misc cleanups in general: - re-organize variable declarations, - converting if {} else if {} else {} into switch statements, - correct comments typos, - add/remove white lines to improve readability, - etc. Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Jean Pihet <j-pihet@ti.com> Reviewed-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Kevin Hilman <khilman@ti.com>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r--arch/arm/mach-omap2/smartreflex.c100
1 files changed, 67 insertions, 33 deletions
diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index 72fe4d1b01c4..f1db4c67c48a 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -36,6 +36,12 @@
36#define SR_DISABLE_TIMEOUT 200 36#define SR_DISABLE_TIMEOUT 200
37 37
38struct omap_sr { 38struct omap_sr {
39 struct list_head node;
40 struct platform_device *pdev;
41 struct omap_sr_nvalue_table *nvalue_table;
42 struct voltagedomain *voltdm;
43 struct dentry *dbg_dir;
44 unsigned int irq;
39 int srid; 45 int srid;
40 int ip_type; 46 int ip_type;
41 int nvalue_count; 47 int nvalue_count;
@@ -49,13 +55,7 @@ struct omap_sr {
49 u32 senp_avgweight; 55 u32 senp_avgweight;
50 u32 senp_mod; 56 u32 senp_mod;
51 u32 senn_mod; 57 u32 senn_mod;
52 unsigned int irq;
53 void __iomem *base; 58 void __iomem *base;
54 struct platform_device *pdev;
55 struct list_head node;
56 struct omap_sr_nvalue_table *nvalue_table;
57 struct voltagedomain *voltdm;
58 struct dentry *dbg_dir;
59}; 59};
60 60
61/* sr_list contains all the instances of smartreflex module */ 61/* sr_list contains all the instances of smartreflex module */
@@ -123,21 +123,28 @@ static struct omap_sr *_sr_lookup(struct voltagedomain *voltdm)
123 123
124static irqreturn_t sr_interrupt(int irq, void *data) 124static irqreturn_t sr_interrupt(int irq, void *data)
125{ 125{
126 struct omap_sr *sr_info = (struct omap_sr *)data; 126 struct omap_sr *sr_info = data;
127 u32 status = 0; 127 u32 status = 0;
128 128
129 if (sr_info->ip_type == SR_TYPE_V1) { 129 switch (sr_info->ip_type) {
130 case SR_TYPE_V1:
130 /* Read the status bits */ 131 /* Read the status bits */
131 status = sr_read_reg(sr_info, ERRCONFIG_V1); 132 status = sr_read_reg(sr_info, ERRCONFIG_V1);
132 133
133 /* Clear them by writing back */ 134 /* Clear them by writing back */
134 sr_write_reg(sr_info, ERRCONFIG_V1, status); 135 sr_write_reg(sr_info, ERRCONFIG_V1, status);
135 } else if (sr_info->ip_type == SR_TYPE_V2) { 136 break;
137 case SR_TYPE_V2:
136 /* Read the status bits */ 138 /* Read the status bits */
137 status = sr_read_reg(sr_info, IRQSTATUS); 139 status = sr_read_reg(sr_info, IRQSTATUS);
138 140
139 /* Clear them by writing back */ 141 /* Clear them by writing back */
140 sr_write_reg(sr_info, IRQSTATUS, status); 142 sr_write_reg(sr_info, IRQSTATUS, status);
143 break;
144 default:
145 dev_err(&sr_info->pdev->dev, "UNKNOWN IP type %d\n",
146 sr_info->ip_type);
147 return IRQ_NONE;
141 } 148 }
142 149
143 if (sr_class->notify) 150 if (sr_class->notify)
@@ -161,6 +168,7 @@ static void sr_set_clk_length(struct omap_sr *sr)
161 __func__); 168 __func__);
162 return; 169 return;
163 } 170 }
171
164 sys_clk_speed = clk_get_rate(sys_ck); 172 sys_clk_speed = clk_get_rate(sys_ck);
165 clk_put(sys_ck); 173 clk_put(sys_ck);
166 174
@@ -262,7 +270,7 @@ static int sr_late_init(struct omap_sr *sr_info)
262 goto error; 270 goto error;
263 } 271 }
264 ret = request_irq(sr_info->irq, sr_interrupt, 272 ret = request_irq(sr_info->irq, sr_interrupt,
265 0, name, (void *)sr_info); 273 0, name, sr_info);
266 if (ret) 274 if (ret)
267 goto error; 275 goto error;
268 disable_irq(sr_info->irq); 276 disable_irq(sr_info->irq);
@@ -283,6 +291,7 @@ error:
283 "not function as desired\n", __func__); 291 "not function as desired\n", __func__);
284 kfree(name); 292 kfree(name);
285 kfree(sr_info); 293 kfree(sr_info);
294
286 return ret; 295 return ret;
287} 296}
288 297
@@ -403,8 +412,9 @@ static u32 sr_retrieve_nvalue(struct omap_sr *sr, u32 efuse_offs)
403 */ 412 */
404int sr_configure_errgen(struct voltagedomain *voltdm) 413int sr_configure_errgen(struct voltagedomain *voltdm)
405{ 414{
406 u32 sr_config, sr_errconfig, errconfig_offs, vpboundint_en; 415 u32 sr_config, sr_errconfig, errconfig_offs;
407 u32 vpboundint_st, senp_en = 0, senn_en = 0; 416 u32 vpboundint_en, vpboundint_st;
417 u32 senp_en = 0, senn_en = 0;
408 u8 senp_shift, senn_shift; 418 u8 senp_shift, senn_shift;
409 struct omap_sr *sr = _sr_lookup(voltdm); 419 struct omap_sr *sr = _sr_lookup(voltdm);
410 420
@@ -423,20 +433,23 @@ int sr_configure_errgen(struct voltagedomain *voltdm)
423 sr_config = (sr->clk_length << SRCONFIG_SRCLKLENGTH_SHIFT) | 433 sr_config = (sr->clk_length << SRCONFIG_SRCLKLENGTH_SHIFT) |
424 SRCONFIG_SENENABLE | SRCONFIG_ERRGEN_EN; 434 SRCONFIG_SENENABLE | SRCONFIG_ERRGEN_EN;
425 435
426 if (sr->ip_type == SR_TYPE_V1) { 436 switch (sr->ip_type) {
437 case SR_TYPE_V1:
427 sr_config |= SRCONFIG_DELAYCTRL; 438 sr_config |= SRCONFIG_DELAYCTRL;
428 senn_shift = SRCONFIG_SENNENABLE_V1_SHIFT; 439 senn_shift = SRCONFIG_SENNENABLE_V1_SHIFT;
429 senp_shift = SRCONFIG_SENPENABLE_V1_SHIFT; 440 senp_shift = SRCONFIG_SENPENABLE_V1_SHIFT;
430 errconfig_offs = ERRCONFIG_V1; 441 errconfig_offs = ERRCONFIG_V1;
431 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V1; 442 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V1;
432 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V1; 443 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V1;
433 } else if (sr->ip_type == SR_TYPE_V2) { 444 break;
445 case SR_TYPE_V2:
434 senn_shift = SRCONFIG_SENNENABLE_V2_SHIFT; 446 senn_shift = SRCONFIG_SENNENABLE_V2_SHIFT;
435 senp_shift = SRCONFIG_SENPENABLE_V2_SHIFT; 447 senp_shift = SRCONFIG_SENPENABLE_V2_SHIFT;
436 errconfig_offs = ERRCONFIG_V2; 448 errconfig_offs = ERRCONFIG_V2;
437 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V2; 449 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V2;
438 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V2; 450 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V2;
439 } else { 451 break;
452 default:
440 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex" 453 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex"
441 "module without specifying the ip\n", __func__); 454 "module without specifying the ip\n", __func__);
442 return -EINVAL; 455 return -EINVAL;
@@ -469,8 +482,8 @@ int sr_configure_errgen(struct voltagedomain *voltdm)
469 */ 482 */
470int sr_disable_errgen(struct voltagedomain *voltdm) 483int sr_disable_errgen(struct voltagedomain *voltdm)
471{ 484{
472 u32 errconfig_offs, vpboundint_en; 485 u32 errconfig_offs;
473 u32 vpboundint_st; 486 u32 vpboundint_en, vpboundint_st;
474 struct omap_sr *sr = _sr_lookup(voltdm); 487 struct omap_sr *sr = _sr_lookup(voltdm);
475 488
476 if (IS_ERR(sr)) { 489 if (IS_ERR(sr)) {
@@ -479,15 +492,18 @@ int sr_disable_errgen(struct voltagedomain *voltdm)
479 return -EINVAL; 492 return -EINVAL;
480 } 493 }
481 494
482 if (sr->ip_type == SR_TYPE_V1) { 495 switch (sr->ip_type) {
496 case SR_TYPE_V1:
483 errconfig_offs = ERRCONFIG_V1; 497 errconfig_offs = ERRCONFIG_V1;
484 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V1; 498 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V1;
485 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V1; 499 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V1;
486 } else if (sr->ip_type == SR_TYPE_V2) { 500 break;
501 case SR_TYPE_V2:
487 errconfig_offs = ERRCONFIG_V2; 502 errconfig_offs = ERRCONFIG_V2;
488 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V2; 503 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V2;
489 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V2; 504 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V2;
490 } else { 505 break;
506 default:
491 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex" 507 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex"
492 "module without specifying the ip\n", __func__); 508 "module without specifying the ip\n", __func__);
493 return -EINVAL; 509 return -EINVAL;
@@ -537,14 +553,17 @@ int sr_configure_minmax(struct voltagedomain *voltdm)
537 SRCONFIG_SENENABLE | 553 SRCONFIG_SENENABLE |
538 (sr->accum_data << SRCONFIG_ACCUMDATA_SHIFT); 554 (sr->accum_data << SRCONFIG_ACCUMDATA_SHIFT);
539 555
540 if (sr->ip_type == SR_TYPE_V1) { 556 switch (sr->ip_type) {
557 case SR_TYPE_V1:
541 sr_config |= SRCONFIG_DELAYCTRL; 558 sr_config |= SRCONFIG_DELAYCTRL;
542 senn_shift = SRCONFIG_SENNENABLE_V1_SHIFT; 559 senn_shift = SRCONFIG_SENNENABLE_V1_SHIFT;
543 senp_shift = SRCONFIG_SENPENABLE_V1_SHIFT; 560 senp_shift = SRCONFIG_SENPENABLE_V1_SHIFT;
544 } else if (sr->ip_type == SR_TYPE_V2) { 561 break;
562 case SR_TYPE_V2:
545 senn_shift = SRCONFIG_SENNENABLE_V2_SHIFT; 563 senn_shift = SRCONFIG_SENNENABLE_V2_SHIFT;
546 senp_shift = SRCONFIG_SENPENABLE_V2_SHIFT; 564 senp_shift = SRCONFIG_SENPENABLE_V2_SHIFT;
547 } else { 565 break;
566 default:
548 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex" 567 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex"
549 "module without specifying the ip\n", __func__); 568 "module without specifying the ip\n", __func__);
550 return -EINVAL; 569 return -EINVAL;
@@ -560,20 +579,27 @@ int sr_configure_minmax(struct voltagedomain *voltdm)
560 * Enabling the interrupts if MINMAXAVG module is used. 579 * Enabling the interrupts if MINMAXAVG module is used.
561 * TODO: check if all the interrupts are mandatory 580 * TODO: check if all the interrupts are mandatory
562 */ 581 */
563 if (sr->ip_type == SR_TYPE_V1) { 582 switch (sr->ip_type) {
583 case SR_TYPE_V1:
564 sr_modify_reg(sr, ERRCONFIG_V1, 584 sr_modify_reg(sr, ERRCONFIG_V1,
565 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUVALIDINTEN | 585 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUVALIDINTEN |
566 ERRCONFIG_MCUBOUNDINTEN), 586 ERRCONFIG_MCUBOUNDINTEN),
567 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUACCUMINTST | 587 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUACCUMINTST |
568 ERRCONFIG_MCUVALIDINTEN | ERRCONFIG_MCUVALIDINTST | 588 ERRCONFIG_MCUVALIDINTEN | ERRCONFIG_MCUVALIDINTST |
569 ERRCONFIG_MCUBOUNDINTEN | ERRCONFIG_MCUBOUNDINTST)); 589 ERRCONFIG_MCUBOUNDINTEN | ERRCONFIG_MCUBOUNDINTST));
570 } else if (sr->ip_type == SR_TYPE_V2) { 590 break;
591 case SR_TYPE_V2:
571 sr_write_reg(sr, IRQSTATUS, 592 sr_write_reg(sr, IRQSTATUS,
572 IRQSTATUS_MCUACCUMINT | IRQSTATUS_MCVALIDINT | 593 IRQSTATUS_MCUACCUMINT | IRQSTATUS_MCVALIDINT |
573 IRQSTATUS_MCBOUNDSINT | IRQSTATUS_MCUDISABLEACKINT); 594 IRQSTATUS_MCBOUNDSINT | IRQSTATUS_MCUDISABLEACKINT);
574 sr_write_reg(sr, IRQENABLE_SET, 595 sr_write_reg(sr, IRQENABLE_SET,
575 IRQENABLE_MCUACCUMINT | IRQENABLE_MCUVALIDINT | 596 IRQENABLE_MCUACCUMINT | IRQENABLE_MCUVALIDINT |
576 IRQENABLE_MCUBOUNDSINT | IRQENABLE_MCUDISABLEACKINT); 597 IRQENABLE_MCUBOUNDSINT | IRQENABLE_MCUDISABLEACKINT);
598 break;
599 default:
600 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex"
601 "module without specifying the ip\n", __func__);
602 return -EINVAL;
577 } 603 }
578 604
579 return 0; 605 return 0;
@@ -592,9 +618,9 @@ int sr_configure_minmax(struct voltagedomain *voltdm)
592 */ 618 */
593int sr_enable(struct voltagedomain *voltdm, unsigned long volt) 619int sr_enable(struct voltagedomain *voltdm, unsigned long volt)
594{ 620{
595 u32 nvalue_reciprocal;
596 struct omap_volt_data *volt_data; 621 struct omap_volt_data *volt_data;
597 struct omap_sr *sr = _sr_lookup(voltdm); 622 struct omap_sr *sr = _sr_lookup(voltdm);
623 u32 nvalue_reciprocal;
598 int ret; 624 int ret;
599 625
600 if (IS_ERR(sr)) { 626 if (IS_ERR(sr)) {
@@ -666,10 +692,17 @@ void sr_disable(struct voltagedomain *voltdm)
666 * disable the clocks. 692 * disable the clocks.
667 */ 693 */
668 if (sr_read_reg(sr, SRCONFIG) & SRCONFIG_SRENABLE) { 694 if (sr_read_reg(sr, SRCONFIG) & SRCONFIG_SRENABLE) {
669 if (sr->ip_type == SR_TYPE_V1) 695 switch (sr->ip_type) {
696 case SR_TYPE_V1:
670 sr_v1_disable(sr); 697 sr_v1_disable(sr);
671 else if (sr->ip_type == SR_TYPE_V2) 698 break;
699 case SR_TYPE_V2:
672 sr_v2_disable(sr); 700 sr_v2_disable(sr);
701 break;
702 default:
703 dev_err(&sr->pdev->dev, "UNKNOWN IP type %d\n",
704 sr->ip_type);
705 }
673 } 706 }
674 707
675 pm_runtime_put_sync_suspend(&sr->pdev->dev); 708 pm_runtime_put_sync_suspend(&sr->pdev->dev);
@@ -828,10 +861,10 @@ void omap_sr_register_pmic(struct omap_sr_pmic_data *pmic_data)
828 sr_pmic_data = pmic_data; 861 sr_pmic_data = pmic_data;
829} 862}
830 863
831/* PM Debug Fs enteries to enable disable smartreflex. */ 864/* PM Debug FS entries to enable and disable smartreflex. */
832static int omap_sr_autocomp_show(void *data, u64 *val) 865static int omap_sr_autocomp_show(void *data, u64 *val)
833{ 866{
834 struct omap_sr *sr_info = (struct omap_sr *) data; 867 struct omap_sr *sr_info = data;
835 868
836 if (!sr_info) { 869 if (!sr_info) {
837 pr_warning("%s: omap_sr struct not found\n", __func__); 870 pr_warning("%s: omap_sr struct not found\n", __func__);
@@ -845,7 +878,7 @@ static int omap_sr_autocomp_show(void *data, u64 *val)
845 878
846static int omap_sr_autocomp_store(void *data, u64 val) 879static int omap_sr_autocomp_store(void *data, u64 val)
847{ 880{
848 struct omap_sr *sr_info = (struct omap_sr *) data; 881 struct omap_sr *sr_info = data;
849 882
850 if (!sr_info) { 883 if (!sr_info) {
851 pr_warning("%s: omap_sr struct not found\n", __func__); 884 pr_warning("%s: omap_sr struct not found\n", __func__);
@@ -870,11 +903,11 @@ static int omap_sr_autocomp_store(void *data, u64 val)
870} 903}
871 904
872DEFINE_SIMPLE_ATTRIBUTE(pm_sr_fops, omap_sr_autocomp_show, 905DEFINE_SIMPLE_ATTRIBUTE(pm_sr_fops, omap_sr_autocomp_show,
873 omap_sr_autocomp_store, "%llu\n"); 906 omap_sr_autocomp_store, "%llu\n");
874 907
875static int __init omap_sr_probe(struct platform_device *pdev) 908static int __init omap_sr_probe(struct platform_device *pdev)
876{ 909{
877 struct omap_sr *sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL); 910 struct omap_sr *sr_info;
878 struct omap_sr_data *pdata = pdev->dev.platform_data; 911 struct omap_sr_data *pdata = pdev->dev.platform_data;
879 struct resource *mem, *irq; 912 struct resource *mem, *irq;
880 struct dentry *nvalue_dir; 913 struct dentry *nvalue_dir;
@@ -882,6 +915,7 @@ static int __init omap_sr_probe(struct platform_device *pdev)
882 int i, ret = 0; 915 int i, ret = 0;
883 char *name; 916 char *name;
884 917
918 sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL);
885 if (!sr_info) { 919 if (!sr_info) {
886 dev_err(&pdev->dev, "%s: unable to allocate sr_info\n", 920 dev_err(&pdev->dev, "%s: unable to allocate sr_info\n",
887 __func__); 921 __func__);