Skip to contentSkip to conversation

extcon: gpio: Add power resume support

PATCH In review RongJun Ying 3 participants 6 messages Jan 7, 2014 – Jan 9, 2014 External connector subsystem (extcon)

lore
Share & tools
lore
#0 lore raw

PATCH v3 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.

---
-v3:
'check_on_resume' instead of 'load_sleep_irq' as Chanwoo Choi's proposal.

 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
index 7e0dff5..fde52c1 100644
@@ -40,6 +40,7 @@ struct gpio_extcon_data {
 	int irq;
 	struct delayed_work work;
 	unsigned long debounce_jiffies;
+	bool check_on_resume;
 };
 
 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->check_on_resume = pdata->check_on_resume;
 	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->check_on_resume)
+		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
index 4195810..c7f0c3e 100644
@@ -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 check_on_resume;
 };
 
 #endif /* __EXTCON_GPIO_H__ */

--
1.7.5.4

maintainer
#1 lore raw

This patch has conflict as following:
You have to implement extcon patch based mainline extcon-next branch.

Applying: extcon: gpio: Add power resume support
error: patch failed: drivers/extcon/extcon-gpio.c:103
error: drivers/extcon/extcon-gpio.c: patch does not apply Patch failed at 0001 extcon: gpio: Add power resume support The copy of the patch that failed is found in:
/home/cwchoi00/kernel/git.kernel/extcon/.git/rebase-apply/patch
When you have resolved this problem, run "git am --resolved". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

This time, I will manually apply this patch on extcon branch.

Thanks,
Chanwoo Choi

Quoted 82 lines · RongJun Ying

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.

---
-v3:
'check_on_resume' instead of 'load_sleep_irq' as Chanwoo Choi's proposal.

 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
index 7e0dff5..fde52c1 100644
@@ -40,6 +40,7 @@ struct gpio_extcon_data {
 	int irq;
 	struct delayed_work work;
 	unsigned long debounce_jiffies;
+	bool check_on_resume;
 };
 
 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->check_on_resume = pdata->check_on_resume;
 	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->check_on_resume)
+		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
index 4195810..c7f0c3e 100644
@@ -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 check_on_resume;
 };
 
 #endif /* __EXTCON_GPIO_H__ */
--

1.7.5.4

#2 lore raw
Quoted 23 lines

-----Original Message-----
From: Chanwoo Choi [mailto:cw00.choi at samsung.com]
Sent: Tuesday, January 07, 2014 2:07 PM
To: RongJun Ying
Cc: MyungJoo Ham; Barry Song; linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org; DL-SHA-WorkGroupLinux; Rongjun Ying
Subject: Re: [PATCH v3] extcon: gpio: Add power resume support

This patch has conflict as following:
You have to implement extcon patch based mainline extcon-next branch.

Applying: extcon: gpio: Add power resume support
error: patch failed: drivers/extcon/extcon-gpio.c:103
error: drivers/extcon/extcon-gpio.c: patch does not apply Patch failed at 0001 extcon: gpio: Add power resume support The copy of the patch that failed is found in:
/home/cwchoi00/kernel/git.kernel/extcon/.git/rebase-apply/patch
When you have resolved this problem, run "git am --resolved". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

Quoted 5 lines

This time, I will manually apply this patch on extcon branch.

Thanks,
Chanwoo Choi

Thank you.

RongJun Ying

Quoted 79 lines · RongJun Ying
Quoted 10 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.

---
-v3:
'check_on_resume' instead of 'load_sleep_irq' as Chanwoo Choi's

proposal.

drivers/extcon/extcon-gpio.c static int gpio_extcon_remove(struct

Quoted 26 lines
 drivers/extcon/extcon-gpio.c       |   20 ++++++++++++++++++++
 include/linux/extcon/extcon-gpio.h |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/drivers/extcon/extcon-gpio.c index 7e0dff5..fde52c1 100644

drivers/extcon/extcon-gpio.c +3 -0
@@ -40,6 +40,7 @@ struct gpio_extcon_data {
 	int irq;
 	struct delayed_work work;
 	unsigned long debounce_jiffies;
+	bool check_on_resume;
 };
 
 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->check_on_resume = pdata->check_on_resume;
 	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)

Quoted 40 lines
drivers/extcon/extcon-gpio.c +16 -0
 	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->check_on_resume)
+		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
index 4195810..c7f0c3e 100644
@@ -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 check_on_resume;
 };
 
Quoted 11 lines
Quoted 5 lines
include/linux/extcon/extcon-gpio.h +0 -1
 #endif /* __EXTCON_GPIO_H__ */
--

1.7.5.4

To report this email as spam click
https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==
BhEym36W00netVd8YYrcUQrAnqreWejYcysfmF8UmgH1OQ== .

Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube, www.youtube.com/user/CSRplc, Facebook, www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at www.twitter.com/CSR_plc. New for 2014, you can now access the wide range of products powered by aptX at www.aptx.com.

maintainer
#3 lore raw
In reply to RongJun Ying

Hi RongJun,

Quoted 44 lines · RongJun Ying

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.

---
-v3:
'check_on_resume' instead of 'load_sleep_irq' as Chanwoo Choi's proposal.

 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 +7 -0
index 7e0dff5..fde52c1 100644
@@ -40,6 +40,7 @@ struct gpio_extcon_data {
 	int irq;
 	struct delayed_work work;
 	unsigned long debounce_jiffies;
+	bool check_on_resume;
 };
 
 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->check_on_resume = pdata->check_on_resume;
 	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;
+

drivers/extcon/extcon-gpio.c static int gpio_extcon_remove(struct platform_device *pdev) · line 178

Quoted 10 lines
drivers/extcon/extcon-gpio.c +10 -0
+	extcon_data = dev_get_drvdata(dev);
+	if (extcon_data->check_on_resume)
+		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)

If CONFIG_PM_SLEEP is undefined, gpio_extcon_pm_ops cannot find gpio_extcon_resume function. You should define dummy function for gpio_extcon_resume function.

#4 lore raw
Quoted 64 lines

-----Original Message-----
From: Chanwoo Choi [mailto:cw00.choi at samsung.com]
Sent: Tuesday, January 07, 2014 2:09 PM
To: RongJun Ying
Cc: MyungJoo Ham; Barry Song; linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org; DL-SHA-WorkGroupLinux; Rongjun Ying
Subject: Re: [PATCH v3] extcon: gpio: Add power resume support

Hi RongJun,

Quoted 10 lines · RongJun Ying

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.

---
-v3:
'check_on_resume' instead of 'load_sleep_irq' as Chanwoo Choi's

proposal.

drivers/extcon/extcon-gpio.c static int gpio_extcon_remove(struct

Quoted 26 lines
 drivers/extcon/extcon-gpio.c       |   20 ++++++++++++++++++++
 include/linux/extcon/extcon-gpio.h |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/drivers/extcon/extcon-gpio.c index 7e0dff5..fde52c1 100644

drivers/extcon/extcon-gpio.c +3 -0
@@ -40,6 +40,7 @@ struct gpio_extcon_data {
 	int irq;
 	struct delayed_work work;
 	unsigned long debounce_jiffies;
+	bool check_on_resume;
 };
 
 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->check_on_resume = pdata->check_on_resume;
 	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)

Quoted 13 lines
drivers/extcon/extcon-gpio.c +10 -0
 	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->check_on_resume)
+		queue_delayed_work(system_power_efficient_wq,
+			&extcon_data->work, extcon_data->debounce_jiffies);
+	return 0;
+}
Quoted 10 lines

drivers/extcon/extcon-gpio.c static int gpio_extcon_remove(struct platform_device *pdev) · line 178

Quoted 4 lines
drivers/extcon/extcon-gpio.c +4 -0
+#endif
+
+static const struct dev_pm_ops gpio_extcon_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(NULL, gpio_extcon_resume)

If CONFIG_PM_SLEEP is undefined, gpio_extcon_pm_ops cannot find gpio_extcon_resume function.
You should define dummy function for gpio_extcon_resume function.

In the include/Linux/pm.h
If CONFIG_PM_SLEEP is undefined, the SET_SYSTEM_SLEEP_PM_OPS macro is bypassed.

#ifdef CONFIG_PM_SLEEP

#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
        .suspend = suspend_fn, \
        .resume = resume_fn, \
        .freeze = suspend_fn, \
        .thaw = resume_fn, \
        .poweroff = suspend_fn, \
        .restore = resume_fn,

#else
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) #endif

Quoted 5 lines

To report this email as spam click
https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==
UfkIuR0P8QH1DW7C+lVo3569nqreWejYcysfmF8UmgH1OQ== .

Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube, www.youtube.com/user/CSRplc, Facebook, www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at www.twitter.com/CSR_plc. New for 2014, you can now access the wide range of products powered by aptX at www.aptx.com.

maintainer
#5 lore raw

Hi Rongjun,

OK, I applied this patch on extcon-next branch.

Thannks,
Chanwoo Choi

Quoted 104 lines · Rongjun Ying
Quoted 64 lines

-----Original Message-----
From: Chanwoo Choi [mailto:cw00.choi at samsung.com]
Sent: Tuesday, January 07, 2014 2:09 PM
To: RongJun Ying
Cc: MyungJoo Ham; Barry Song; linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org; DL-SHA-WorkGroupLinux; Rongjun Ying
Subject: Re: [PATCH v3] extcon: gpio: Add power resume support

Hi RongJun,

Quoted 10 lines · RongJun Ying

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.

---
-v3:
'check_on_resume' instead of 'load_sleep_irq' as Chanwoo Choi's

proposal.

drivers/extcon/extcon-gpio.c static int gpio_extcon_remove(struct

Quoted 26 lines
 drivers/extcon/extcon-gpio.c       |   20 ++++++++++++++++++++
 include/linux/extcon/extcon-gpio.h |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/drivers/extcon/extcon-gpio.c index 7e0dff5..fde52c1 100644

drivers/extcon/extcon-gpio.c +3 -0
@@ -40,6 +40,7 @@ struct gpio_extcon_data {
 	int irq;
 	struct delayed_work work;
 	unsigned long debounce_jiffies;
+	bool check_on_resume;
 };
 
 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->check_on_resume = pdata->check_on_resume;
 	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)

Quoted 13 lines
drivers/extcon/extcon-gpio.c +10 -0
 	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->check_on_resume)
+		queue_delayed_work(system_power_efficient_wq,
+			&extcon_data->work, extcon_data->debounce_jiffies);
+	return 0;
+}
Quoted 10 lines

drivers/extcon/extcon-gpio.c static int gpio_extcon_remove(struct platform_device *pdev) · line 178

Quoted 4 lines
drivers/extcon/extcon-gpio.c +4 -0
+#endif
+
+static const struct dev_pm_ops gpio_extcon_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(NULL, gpio_extcon_resume)

If CONFIG_PM_SLEEP is undefined, gpio_extcon_pm_ops cannot find gpio_extcon_resume function.
You should define dummy function for gpio_extcon_resume function.

In the include/Linux/pm.h
If CONFIG_PM_SLEEP is undefined, the SET_SYSTEM_SLEEP_PM_OPS macro is bypassed.

#ifdef CONFIG_PM_SLEEP

#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
        .suspend = suspend_fn, \
        .resume = resume_fn, \
        .freeze = suspend_fn, \
        .thaw = resume_fn, \
        .poweroff = suspend_fn, \
        .restore = resume_fn,

#else
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) #endif

Quoted 5 lines

To report this email as spam click
https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==
UfkIuR0P8QH1DW7C+lVo3569nqreWejYcysfmF8UmgH1OQ== .

Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube, www.youtube.com/user/CSRplc, Facebook, www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at www.twitter.com/CSR_plc. New for 2014, you can now access the wide range of products powered by aptX at www.aptx.com.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/