Merge "pinctrl: add restore function for sx150x"

This commit is contained in:
qctecmdr 2021-02-06 05:10:46 -08:00 • committed by Gerrit - the friendly Code Review server
commit 46bb8e6b35

View file

@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
*
* Copyright (c) 2016, BayLibre, SAS. All rights reserved.
* Author: Neil Armstrong <narmstrong@baylibre.com>
*
@ -1243,10 +1245,47 @@ static int sx150x_probe(struct i2c_client *client,
return 0;
}
#ifdef CONFIG_PM_SLEEP
static int sx150x_restore(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct sx150x_pinctrl *pctl = i2c_get_clientdata(client);
int ret;
ret = sx150x_init_hw(pctl);
if (ret)
return ret;
ret = pinctrl_force_default(pctl->pctldev);
if (ret) {
dev_err(dev, "Failed to enable pinctrl device\n");
return ret;
}
if (client->irq > 0) {
mutex_lock(&pctl->lock);
regmap_write(pctl->regmap,
pctl->data->reg_irq_mask, pctl->irq.masked);
regmap_write(pctl->regmap,
pctl->data->reg_sense, pctl->irq.sense);
mutex_unlock(&pctl->lock);
}
return 0;
}
static const struct dev_pm_ops sx150x_pm = {
.restore = sx150x_restore,
};
#endif
static struct i2c_driver sx150x_driver = {
.driver = {
.name = "sx150x-pinctrl",
.of_match_table = of_match_ptr(sx150x_of_match),
#ifdef CONFIG_PM_SLEEP
.pm = &sx150x_pm,
#endif
},
.probe = sx150x_probe,
.id_table = sx150x_id,