extcon: gpio: update power management operations
During system resume, other subsystem may need to get the extcon state to decide if a hotplug device is present. So we need to make sure the extcon gpio device resumes early and update its state in a sync way. Change-Id: Id5c4e8c8c7e9196fea8fa8eecb42dfb4914aeb7b Signed-off-by: Can Guo <cang@codeaurora.org>
This commit is contained in:
@@ -178,6 +178,8 @@ static int gpio_extcon_probe(struct platform_device *pdev)
|
|||||||
if (data->irq <= 0)
|
if (data->irq <= 0)
|
||||||
return data->irq;
|
return data->irq;
|
||||||
|
|
||||||
|
data->check_on_resume = true;
|
||||||
|
|
||||||
data->supported_cable = devm_kzalloc(dev,
|
data->supported_cable = devm_kzalloc(dev,
|
||||||
sizeof(*data->supported_cable) * 2,
|
sizeof(*data->supported_cable) * 2,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
@@ -229,17 +231,29 @@ static int gpio_extcon_remove(struct platform_device *pdev)
|
|||||||
static int gpio_extcon_resume(struct device *dev)
|
static int gpio_extcon_resume(struct device *dev)
|
||||||
{
|
{
|
||||||
struct gpio_extcon_data *data;
|
struct gpio_extcon_data *data;
|
||||||
|
int state, ret = 0;
|
||||||
|
|
||||||
data = dev_get_drvdata(dev);
|
data = dev_get_drvdata(dev);
|
||||||
if (data->check_on_resume)
|
if (data->check_on_resume) {
|
||||||
queue_delayed_work(system_power_efficient_wq,
|
state = gpiod_get_value_cansleep(data->gpiod);
|
||||||
&data->work, data->debounce_jiffies);
|
ret = extcon_set_state_sync(data->edev, data->extcon_id, state);
|
||||||
|
if (ret)
|
||||||
|
dev_err(dev, "%s: Failed to set extcon gpio state\n",
|
||||||
|
__func__);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static SIMPLE_DEV_PM_OPS(gpio_extcon_pm_ops, NULL, gpio_extcon_resume);
|
static const struct dev_pm_ops gpio_extcon_pm_ops = {
|
||||||
|
SET_LATE_SYSTEM_SLEEP_PM_OPS(NULL, gpio_extcon_resume)
|
||||||
|
};
|
||||||
|
|
||||||
|
#define EXTCON_GPIO_PMOPS (&gpio_extcon_pm_ops)
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define EXTCON_GPIO_PMOPS NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
static const struct of_device_id extcon_gpio_of_match[] = {
|
static const struct of_device_id extcon_gpio_of_match[] = {
|
||||||
{ .compatible = "extcon-gpio"},
|
{ .compatible = "extcon-gpio"},
|
||||||
@@ -251,7 +265,7 @@ static struct platform_driver gpio_extcon_driver = {
|
|||||||
.remove = gpio_extcon_remove,
|
.remove = gpio_extcon_remove,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "extcon-gpio",
|
.name = "extcon-gpio",
|
||||||
.pm = &gpio_extcon_pm_ops,
|
.pm = EXTCON_GPIO_PMOPS,
|
||||||
.of_match_table = of_match_ptr(extcon_gpio_of_match),
|
.of_match_table = of_match_ptr(extcon_gpio_of_match),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user