OMAP3+: SR: enable/disable SR only on need
[pandora-kernel.git] / arch / arm / mach-omap2 / smartreflex.c
index fb7dc52..3bd9fac 100644 (file)
@@ -143,7 +143,7 @@ static irqreturn_t sr_interrupt(int irq, void *data)
                sr_write_reg(sr_info, IRQSTATUS, status);
        }
 
-       if (sr_class->class_type == SR_CLASS2 && sr_class->notify)
+       if (sr_class->notify)
                sr_class->notify(sr_info->voltdm, status);
 
        return IRQ_HANDLED;
@@ -258,9 +258,7 @@ static int sr_late_init(struct omap_sr *sr_info)
        struct resource *mem;
        int ret = 0;
 
-       if (sr_class->class_type == SR_CLASS2 &&
-               sr_class->notify_flags && sr_info->irq) {
-
+       if (sr_class->notify && sr_class->notify_flags && sr_info->irq) {
                name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
                if (name == NULL) {
                        ret = -ENOMEM;
@@ -270,6 +268,7 @@ static int sr_late_init(struct omap_sr *sr_info)
                                0, name, (void *)sr_info);
                if (ret)
                        goto error;
+               disable_irq(sr_info->irq);
        }
 
        if (pdata && pdata->enable_on_init)
@@ -808,10 +807,13 @@ static int omap_sr_autocomp_store(void *data, u64 val)
                return -EINVAL;
        }
 
-       if (!val)
-               sr_stop_vddautocomp(sr_info);
-       else
-               sr_start_vddautocomp(sr_info);
+       /* control enable/disable only if there is a delta in value */
+       if (sr_info->autocomp_active != val) {
+               if (!val)
+                       sr_stop_vddautocomp(sr_info);
+               else
+                       sr_start_vddautocomp(sr_info);
+       }
 
        return 0;
 }