diff options
| -rw-r--r-- | drivers/extcon/extcon-gpio.c | 21 | ||||
| -rw-r--r-- | include/linux/extcon/extcon-gpio.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 4736a9c57efa..a63a6b21c9ad 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c | |||
| @@ -40,6 +40,7 @@ struct gpio_extcon_data { | |||
| 40 | int irq; | 40 | int irq; |
| 41 | struct delayed_work work; | 41 | struct delayed_work work; |
| 42 | unsigned long debounce_jiffies; | 42 | unsigned long debounce_jiffies; |
| 43 | bool check_on_resume; | ||
| 43 | }; | 44 | }; |
| 44 | 45 | ||
| 45 | static void gpio_extcon_work(struct work_struct *work) | 46 | static void gpio_extcon_work(struct work_struct *work) |
| @@ -103,6 +104,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) | |||
| 103 | extcon_data->gpio_active_low = pdata->gpio_active_low; | 104 | extcon_data->gpio_active_low = pdata->gpio_active_low; |
| 104 | extcon_data->state_on = pdata->state_on; | 105 | extcon_data->state_on = pdata->state_on; |
| 105 | extcon_data->state_off = pdata->state_off; | 106 | extcon_data->state_off = pdata->state_off; |
| 107 | extcon_data->check_on_resume = pdata->check_on_resume; | ||
| 106 | if (pdata->state_on && pdata->state_off) | 108 | if (pdata->state_on && pdata->state_off) |
| 107 | extcon_data->edev.print_state = extcon_gpio_print_state; | 109 | extcon_data->edev.print_state = extcon_gpio_print_state; |
| 108 | 110 | ||
| @@ -160,12 +162,31 @@ static int gpio_extcon_remove(struct platform_device *pdev) | |||
| 160 | return 0; | 162 | return 0; |
| 161 | } | 163 | } |
| 162 | 164 | ||
| 165 | #ifdef CONFIG_PM_SLEEP | ||
| 166 | static int gpio_extcon_resume(struct device *dev) | ||
| 167 | { | ||
| 168 | struct gpio_extcon_data *extcon_data; | ||
| 169 | |||
| 170 | extcon_data = dev_get_drvdata(dev); | ||
| 171 | if (extcon_data->check_on_resume) | ||
| 172 | queue_delayed_work(system_power_efficient_wq, | ||
| 173 | &extcon_data->work, extcon_data->debounce_jiffies); | ||
| 174 | |||
| 175 | return 0; | ||
| 176 | } | ||
| 177 | #endif | ||
| 178 | |||
| 179 | static const struct dev_pm_ops gpio_extcon_pm_ops = { | ||
| 180 | SET_SYSTEM_SLEEP_PM_OPS(NULL, gpio_extcon_resume) | ||
| 181 | }; | ||
| 182 | |||
| 163 | static struct platform_driver gpio_extcon_driver = { | 183 | static struct platform_driver gpio_extcon_driver = { |
| 164 | .probe = gpio_extcon_probe, | 184 | .probe = gpio_extcon_probe, |
| 165 | .remove = gpio_extcon_remove, | 185 | .remove = gpio_extcon_remove, |
| 166 | .driver = { | 186 | .driver = { |
| 167 | .name = "extcon-gpio", | 187 | .name = "extcon-gpio", |
| 168 | .owner = THIS_MODULE, | 188 | .owner = THIS_MODULE, |
| 189 | .pm = &gpio_extcon_pm_ops, | ||
| 169 | }, | 190 | }, |
| 170 | }; | 191 | }; |
| 171 | 192 | ||
diff --git a/include/linux/extcon/extcon-gpio.h b/include/linux/extcon/extcon-gpio.h index 4195810f87fe..8900fdf511c6 100644 --- a/include/linux/extcon/extcon-gpio.h +++ b/include/linux/extcon/extcon-gpio.h | |||
| @@ -51,6 +51,7 @@ struct gpio_extcon_platform_data { | |||
| 51 | /* if NULL, "0" or "1" will be printed */ | 51 | /* if NULL, "0" or "1" will be printed */ |
| 52 | const char *state_on; | 52 | const char *state_on; |
| 53 | const char *state_off; | 53 | const char *state_off; |
| 54 | bool check_on_resume; | ||
| 54 | }; | 55 | }; |
| 55 | 56 | ||
| 56 | #endif /* __EXTCON_GPIO_H__ */ | 57 | #endif /* __EXTCON_GPIO_H__ */ |
