From aed95973aba2b490473c4012a3248b0daed4268f Mon Sep 17 00:00:00 2001 From: Ziyuan Xu Date: Mon, 14 May 2018 18:16:54 +0800 Subject: [PATCH] leds: leds-is31fl32xx: add suspend & resume support This patch could reduce the power consumption almost 2ma@5v on rk3308-evb-v10 boards. Change-Id: I4ee94524427eda72b0f5b61be46cd7a6d3f6a17d Signed-off-by: Ziyuan Xu --- drivers/leds/leds-is31fl32xx.c | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c index 3a07312a79a3..a7d88d5b8c09 100644 --- a/drivers/leds/leds-is31fl32xx.c +++ b/drivers/leds/leds-is31fl32xx.c @@ -606,6 +606,36 @@ static void is31fl32xx_shutdown(struct i2c_client *client) gpiod_set_value(priv->reset_gpio, 0); } +#ifdef CONFIG_PM_SLEEP +static int is31fl32xx_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct is31fl32xx_priv *priv = i2c_get_clientdata(client); + + if (IS_ERR(priv->reset_gpio)) { + return is31fl3216_software_shutdown(priv, + IS31FL3216_CONFIG_SSD_DISABLE); + } else { + gpiod_set_value(priv->reset_gpio, 0); + return 0; + } +} + +static int is31fl32xx_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct is31fl32xx_priv *priv = i2c_get_clientdata(client); + + if (IS_ERR(priv->reset_gpio)) { + return is31fl3216_software_shutdown(priv, + IS31FL3216_CONFIG_SSD_ENABLE); + } else { + gpiod_set_value(priv->reset_gpio, 1); + return 0; + } +} +#endif /* CONFIG_PM_SLEEP */ + /* * i2c-core (and modalias) requires that id_table be properly filled, * even though it is not used for DeviceTree based instantiation. @@ -622,10 +652,15 @@ static const struct i2c_device_id is31fl32xx_id[] = { MODULE_DEVICE_TABLE(i2c, is31fl32xx_id); +static SIMPLE_DEV_PM_OPS(is31fl32xx_pmops, + is31fl32xx_suspend, + is31fl32xx_resume); + static struct i2c_driver is31fl32xx_driver = { .driver = { .name = "is31fl32xx", .of_match_table = of_is31fl32xx_match, + .pm = &is31fl32xx_pmops, }, .probe = is31fl32xx_probe, .remove = is31fl32xx_remove,