Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4951eb9 authored by Xiaowen Wu's avatar Xiaowen Wu
Browse files

pinctrl: add restore function for sx150x



Add restore function for sx150x to re-init hw after hibernation.

Change-Id: I657ccca872a04ebc458273fbe0ea69c7969c4dbb
Signed-off-by: default avatarXiaowen Wu <wxiaowen@codeaurora.org>
parent 5043ac1c
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2019, The Linux Foundation. All rights reserved.
 *
 * Copyright (c) 2016, BayLibre, SAS. All rights reserved.
 * Author: Neil Armstrong <narmstrong@baylibre.com>
 *
@@ -1251,10 +1253,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,