diff options
Diffstat (limited to 'drivers/leds/leds-lm3530.c')
| -rw-r--r-- | drivers/leds/leds-lm3530.c | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c index a036a19040f..41b5f574ad0 100644 --- a/drivers/leds/leds-lm3530.c +++ b/drivers/leds/leds-lm3530.c @@ -1,12 +1,15 @@ /* + * Copyright (C) 2015 Olio Devices * Copyright (C) 2011 ST-Ericsson SA. * Copyright (C) 2009 Motorola, Inc. * * License Terms: GNU General Public License v2 * - * Simple driver for National Semiconductor LM3530 Backlight driver chip + * Simple driver for National Semiconductor LM3530 Backlight driver chip, + * with basic suspend and resume. * - * Author: Shreshtha Kumar SAHU <shreshthakumar.sahu@stericsson.com> + * Author: Mattis Fjallstrom <mattis@oliodevices.com> + * based on leds-lm3530.c by Shreshtha Kumar SAHU <shreshthakumar.sahu@stericsson.com> * based on leds-lm3530.c by Dan Murphy <D.Murphy@motorola.com> */ @@ -486,6 +489,64 @@ static int lm3530_remove(struct i2c_client *client) return 0; } + +/** + * lm3530_shutdown - make sure brightness is set to 0 + * + * The PMIC of the Olio H1 can't provide the power needed by the lm3530, + * in other words, it does it's own power management. This means we need + * to shut off power usage. Brightness of 0 should do this. + */ + +static void lm3530_shutdown(struct i2c_client *client) +{ + struct lm3530_data *drvdata = i2c_get_clientdata(client); + + lm3530_brightness_set(&(drvdata->led_dev), LED_OFF); + + return; +} + +/** + * lm3530_suspend - suspend backlight + * + * For now, off. Should also save the previous setting. + */ + +static int lm3530_suspend(struct device *dev) { + struct led_classdev *led_cdev = dev_get_drvdata(dev); + + printk ("OLIO %s:%s Suspending\n", __FILE__, __FUNCTION__); + + lm3530_brightness_set(led_cdev, LED_OFF); + + return 0; +} + +/** + * lm3530_resume - reset backlight + * + * Turn the backlight on again (Does android take care of this for us?) + * For now, leave this as a no-op - Android turns on the lights. + */ + +static int lm3530_resume(struct device *dev) { + struct led_classdev *led_cdev = dev_get_drvdata(dev); + + printk ("OLIO %s:%s Resuming\n", __FILE__, __FUNCTION__); + + /* lm3530_brightness_set(led_cdev, 100); */ + + return 0; +} + + +/* ---------------------------------------------------------------------- */ + +static const struct dev_pm_ops lm3530_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(lm3530_suspend, lm3530_resume) +}; + static const struct i2c_device_id lm3530_id[] = { {LM3530_NAME, 0}, {} @@ -495,10 +556,12 @@ MODULE_DEVICE_TABLE(i2c, lm3530_id); static struct i2c_driver lm3530_i2c_driver = { .probe = lm3530_probe, .remove = lm3530_remove, + .shutdown = lm3530_shutdown, .id_table = lm3530_id, .driver = { .name = LM3530_NAME, .owner = THIS_MODULE, + .pm = &lm3530_pm_ops, }, }; |