mfd: Add asic3 based LED suspend/resume handlers
authorPaul Parsons <lost.distance@yahoo.com>
Tue, 9 Aug 2011 16:27:33 +0000 (16:27 +0000)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 24 Oct 2011 12:09:09 +0000 (14:09 +0200)
Added led suspend/resume handlers to the leds/leds-asic3 and mfd/asic3 drivers.
On suspend the leds will be turned off and their clocks disabled. On resume the
reverse.

Signed-off-by: Paul Parsons <lost.distance@yahoo.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/leds/leds-asic3.c
drivers/mfd/asic3.c

index 22f847c..fbd5d88 100644 (file)
@@ -107,9 +107,10 @@ static int __devinit asic3_led_probe(struct platform_device *pdev)
        }
 
        led->cdev->name = led->name;
-       led->cdev->default_trigger = led->default_trigger;
+       led->cdev->flags = LED_CORE_SUSPENDRESUME;
        led->cdev->brightness_set = brightness_set;
        led->cdev->blink_set = blink_set;
+       led->cdev->default_trigger = led->default_trigger;
 
        ret = led_classdev_register(&pdev->dev, led->cdev);
        if (ret < 0)
@@ -136,12 +137,44 @@ static int __devexit asic3_led_remove(struct platform_device *pdev)
        return mfd_cell_disable(pdev);
 }
 
+static int asic3_led_suspend(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       const struct mfd_cell *cell = mfd_get_cell(pdev);
+       int ret;
+
+       ret = 0;
+       if (cell->suspend)
+               ret = (*cell->suspend)(pdev);
+
+       return ret;
+}
+
+static int asic3_led_resume(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       const struct mfd_cell *cell = mfd_get_cell(pdev);
+       int ret;
+
+       ret = 0;
+       if (cell->resume)
+               ret = (*cell->resume)(pdev);
+
+       return ret;
+}
+
+static const struct dev_pm_ops asic3_led_pm_ops = {
+       .suspend        = asic3_led_suspend,
+       .resume         = asic3_led_resume,
+};
+
 static struct platform_driver asic3_led_driver = {
        .probe          = asic3_led_probe,
        .remove         = __devexit_p(asic3_led_remove),
        .driver         = {
                .name   = "leds-asic3",
                .owner  = THIS_MODULE,
+               .pm     = &asic3_led_pm_ops,
        },
 };
 
index 5ac2961..2dbb8ca 100644 (file)
@@ -813,24 +813,43 @@ static int asic3_leds_disable(struct platform_device *pdev)
        return 0;
 }
 
+static int asic3_leds_suspend(struct platform_device *pdev)
+{
+       const struct mfd_cell *cell = mfd_get_cell(pdev);
+       struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
+
+       while (asic3_gpio_get(&asic->gpio, ASIC3_GPIO(C, cell->id)) != 0)
+               msleep(1);
+
+       asic3_clk_disable(asic, &asic->clocks[clock_ledn[cell->id]]);
+
+       return 0;
+}
+
 static struct mfd_cell asic3_cell_leds[ASIC3_NUM_LEDS] = {
        [0] = {
                .name          = "leds-asic3",
                .id            = 0,
                .enable        = asic3_leds_enable,
                .disable       = asic3_leds_disable,
+               .suspend       = asic3_leds_suspend,
+               .resume        = asic3_leds_enable,
        },
        [1] = {
                .name          = "leds-asic3",
                .id            = 1,
                .enable        = asic3_leds_enable,
                .disable       = asic3_leds_disable,
+               .suspend       = asic3_leds_suspend,
+               .resume        = asic3_leds_enable,
        },
        [2] = {
                .name          = "leds-asic3",
                .id            = 2,
                .enable        = asic3_leds_enable,
                .disable       = asic3_leds_disable,
+               .suspend       = asic3_leds_suspend,
+               .resume        = asic3_leds_enable,
        },
 };