From: Matt Ranostay <mranostay@gmail.com>
To: linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org
Cc: Matt Ranostay <matt@ranostay.consulting>,
Tony Lindgren <tony@atomide.com>,
Richard Purdie <rpurdie@rpsys.net>,
Jacek Anaszewski <j.anaszewski@samsung.com>
Subject: [PATCH] leds: leds-pca963x: add power management support
Date: Fri, 30 Sep 2016 12:27:42 -0700 [thread overview]
Message-ID: <1475263662-14149-1-git-send-email-matt@ranostay.consulting> (raw)
Turn off LEDS on suspend and put device in low power state, and restore
settings on resume.
Cc: Tony Lindgren <tony@atomide.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
---
drivers/leds/leds-pca963x.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
index 407eba11e187..4840bdaa1b48 100644
--- a/drivers/leds/leds-pca963x.c
+++ b/drivers/leds/leds-pca963x.c
@@ -382,6 +382,7 @@ static int pca963x_probe(struct i2c_client *client,
pca963x[i].led_cdev.name = pca963x[i].name;
pca963x[i].led_cdev.brightness_set_blocking = pca963x_led_set;
+ pca963x[i].led_cdev.flags = LED_CORE_SUSPENDRESUME;
if (pdata && pdata->blink_type == PCA963X_HW_BLINK)
pca963x[i].led_cdev.blink_set = pca963x_blink_set;
@@ -422,10 +423,40 @@ static int pca963x_remove(struct i2c_client *client)
return 0;
}
+static int pca963x_set_power(struct i2c_client *client, bool state)
+{
+ return i2c_smbus_write_byte_data(client, PCA963X_MODE1,
+ state ? 0 : BIT(4));
+}
+
+static int pca963x_suspend(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+
+ return pca963x_set_power(client, false);
+}
+
+static int pca963x_resume(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ int ret;
+
+ ret = pca963x_set_power(client, true);
+
+ /* wait for oscillator enabling */
+ if (!ret)
+ usleep_range(500, 1000);
+
+ return ret;
+}
+
+static SIMPLE_DEV_PM_OPS(pca963x_pm, pca963x_suspend, pca963x_resume);
+
static struct i2c_driver pca963x_driver = {
.driver = {
.name = "leds-pca963x",
.of_match_table = of_match_ptr(of_pca963x_match),
+ .pm = &pca963x_pm,
},
.probe = pca963x_probe,
.remove = pca963x_remove,
--
2.7.4
next reply other threads:[~2016-09-30 19:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-30 19:27 Matt Ranostay [this message]
2016-09-30 21:23 ` Jacek Anaszewski
2016-09-30 22:57 ` Matt Ranostay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1475263662-14149-1-git-send-email-matt@ranostay.consulting \
--to=mranostay@gmail.com \
--cc=j.anaszewski@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=matt@ranostay.consulting \
--cc=rpurdie@rpsys.net \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®