extcon: gpio: Add power resume support
PATCH v2 1/1 extcon: gpio: Add power resume support
From: Rongjun Ying <[email protected]>
When system on the suspend state, Some SoC can't get gpio interrupt. After system resume, need send extcon uevent to userspace.
---
-v2: Add lost_sleep_irq flags.
drivers/extcon/extcon-gpio.c | 20 ++++++++++++++++++++ include/linux/extcon/extcon-gpio.h | 1 + 2 files changed, 21 insertions(+), 0 deletions(-)
drivers/extcon/extcon-gpio.c +20 -0
@@ -40,6 +40,7 @@ struct gpio_extcon_data {int irq;struct delayed_work work;unsigned long debounce_jiffies; +bool lost_sleep_irq; };static void gpio_extcon_work (struct work_struct *work)
@@ -103,6 +104,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) extcon_data->gpio_active_low = pdata->gpio_active_low; extcon_data->state_on = pdata->state_on; extcon_data->state_off = pdata->state_off; + extcon_data->lost_sleep_irq = pdata->lost_sleep_irq;if (pdata->state_on && pdata->state_off) extcon_data->edev.print_state = extcon_gpio_print_state;if (pdata->debounce) {
@@ -159,12 +161,30 @@ static int gpio_extcon_remove(struct platform_device *pdev)return 0 ; } +#ifdef CONFIG_PM_SLEEP +static int gpio_extcon_resume (struct device *dev) +{ +struct gpio_extcon_data *extcon_data; + + extcon_data =dev_get_drvdata (dev); +if (extcon_data->lost_sleep_irq) +queue_delayed_work (system_power_efficient_wq, + &extcon_data->work, extcon_data->debounce_jiffies); +return 0 ; +} +#endif + +static const struct dev_pm_ops gpio_extcon_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (NULL , gpio_extcon_resume) +}; +static struct platform_driver gpio_extcon_driver = { .probe = gpio_extcon_probe, .remove = gpio_extcon_remove, .driver = { .name ="extcon-gpio" , .owner =THIS_MODULE , + .pm = &gpio_extcon_pm_ops, }, };
include/linux/extcon/extcon-gpio.h +1 -0
@@ -51,6 +51,7 @@ struct gpio_extcon_platform_data {/* if NULL, "0" or "1" will be printed */ const char *state_on;const char *state_off; + bool lost_sleep_irq; };#endif /* __EXTCON_GPIO_H__ */
Signature · 1 line
1.7.5.4
2013/12/27 rjying <[email protected]>:
Quoted 6 lines
From: Rongjun Ying <[email protected]>
When system on the suspend state, Some SoC can't get gpio interrupt. After system resume, need send extcon uevent to userspace.
Signed-off-by Rongjun Ying <[email protected]>
for CSR SiRFSoC, we need similar patch in extcon to make the lost plug/unplug event during sleeping to be resent.
Quoted 71 lines
---
-v2: Addlost_sleep_irqflags.drivers/extcon/extcon-gpio.c | 20 ++++++++++++++++++++ include/linux/extcon/extcon-gpio.h | 1 + 2 files changed, 21 insertions(+), 0 deletions(-)drivers/extcon/extcon-gpio.c +20
-0@@ -40,6 +40,7 @@ struct gpio_extcon_data {int irq;struct delayed_work work;unsigned long debounce_jiffies; +bool lost_sleep_irq; };static void gpio_extcon_work (struct work_struct *work)@@ -103,6 +104,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) extcon_data->gpio_active_low = pdata->gpio_active_low; extcon_data->state_on = pdata->state_on; extcon_data->state_off = pdata->state_off; + extcon_data->lost_sleep_irq = pdata->lost_sleep_irq;if (pdata->state_on && pdata->state_off) extcon_data->edev.print_state = extcon_gpio_print_state;if (pdata->debounce) {@@ -159,12 +161,30 @@ static int gpio_extcon_remove(struct platform_device *pdev)return 0 ; } +#ifdef CONFIG_PM_SLEEP +static int gpio_extcon_resume (struct device *dev) +{ +struct gpio_extcon_data *extcon_data; + + extcon_data =dev_get_drvdata (dev); +if (extcon_data->lost_sleep_irq) +queue_delayed_work (system_power_efficient_wq, + &extcon_data->work, extcon_data->debounce_jiffies); +return 0 ; +} +#endif + +static const struct dev_pm_ops gpio_extcon_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (NULL , gpio_extcon_resume) +}; +static struct platform_driver gpio_extcon_driver = { .probe = gpio_extcon_probe, .remove = gpio_extcon_remove, .driver = { .name ="extcon-gpio" , .owner =THIS_MODULE , + .pm = &gpio_extcon_pm_ops, }, };include/linux/extcon/extcon-gpio.h +1
-1@@ -51,6 +51,7 @@ struct gpio_extcon_platform_data {/* if NULL, "0" or "1" will be printed */ const char *state_on;const char *state_off; + bool lost_sleep_irq; };#endif /* __EXTCON_GPIO_H__ */ --
Quoted 1 line
1.7.5.4
-barry
Chanwoo Choi
maintainerQuoted 18 lines · rjying
From: Rongjun Ying <[email protected]>
When system on the suspend state, Some SoC can't get gpio interrupt. After system resume, need send extcon uevent to userspace.
Signed-off-by Rongjun Ying <[email protected]>---
-v2: Addlost_sleep_irqflags.drivers/extcon/extcon-gpio.c | 20 ++++++++++++++++++++ include/linux/extcon/extcon-gpio.h | 1 + 2 files changed, 21 insertions(+), 0 deletions(-)drivers/extcon/extcon-gpio.c +0
-0
drivers/extcon/extcon-gpio.c struct gpio_extcon_data { · line 43
Quoted 4 lines
drivers/extcon/extcon-gpio.c +1
-0@@ -40,6 +40,7 @@ struct gpio_extcon_data {int irq;struct delayed_work work;unsigned long debounce_jiffies; +bool lost_sleep_irq;
I prefer 'check_on_resume' instead of 'load_sleep_irq'.
drivers/extcon/extcon-gpio.c static int gpio_extcon_probe(struct platform_device *pdev) · line 107
Quoted 8 lines
drivers/extcon/extcon-gpio.c +1
-0};static void gpio_extcon_work (struct work_struct *work)@@ -103,6 +104,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) extcon_data->gpio_active_low = pdata->gpio_active_low; extcon_data->state_on = pdata->state_on; extcon_data->state_off = pdata->state_off; + extcon_data->lost_sleep_irq = pdata->lost_sleep_irq;
ditto.
Quoted 4 lines
drivers/extcon/extcon-gpio.c +0
-0if (pdata->state_on && pdata->state_off) extcon_data->edev.print_state = extcon_gpio_print_state;if (pdata->debounce) {
drivers/extcon/extcon-gpio.c static int gpio_extcon_remove(struct platform_device *pdev) · line 170
Quoted 10 lines
drivers/extcon/extcon-gpio.c +7
-0@@ -159,12 +161,30 @@ static int gpio_extcon_remove(struct platform_device *pdev)return 0 ; } +#ifdef CONFIG_PM_SLEEP +static int gpio_extcon_resume (struct device *dev) +{ +struct gpio_extcon_data *extcon_data; + + extcon_data =dev_get_drvdata (dev); +if (extcon_data->lost_sleep_irq)
ditto.
Quoted 25 lines
drivers/extcon/extcon-gpio.c +11
-0+queue_delayed_work (system_power_efficient_wq, + &extcon_data->work, extcon_data->debounce_jiffies); + return 0; +} +#endif + +static const struct dev_pm_ops gpio_extcon_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (NULL , gpio_extcon_resume) +}; +static struct platform_driver gpio_extcon_driver = { .probe = gpio_extcon_probe, .remove = gpio_extcon_remove, .driver = { .name ="extcon-gpio" , .owner =THIS_MODULE , + .pm = &gpio_extcon_pm_ops, }, };include/linux/extcon/extcon-gpio.h +0
-0
include/linux/extcon/extcon-gpio.h struct gpio_extcon_platform_data { · line 54
Quoted 4 lines
include/linux/extcon/extcon-gpio.h +1
-0@@ -51,6 +51,7 @@ struct gpio_extcon_platform_data {/* if NULL, "0" or "1" will be printed */ const char *state_on;const char *state_off; +bool lost_sleep_irq;
ditto.
include/linux/extcon/extcon-gpio.h struct gpio_extcon_platform_data { · line 57
Quoted 4 lines
include/linux/extcon/extcon-gpio.h +0
-0};#endif /* __EXTCON_GPIO_H__ */
Thanks,
Chanwoo Choi