mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] extcon: ptn5150: handle pending IRQ events during system resume
@ 2025-11-14  7:42 Xu Yang
  2025-11-14  8:08 ` Krzysztof Kozlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Xu Yang @ 2025-11-14  7:42 UTC (permalink / raw)
  To: krzk, myungjoo.ham, cw00.choi; +Cc: linux-kernel, imx

When the system is suspended and ptn5150 wakeup interrupt is disabled,
any changes on ptn5150 will only be record in interrupt status
registers and won't fire an IRQ since its trigger type is falling
edge. So the HW interrupt line will keep at low state and any further
changes won't trigger IRQ anymore. To fix it, this will schedule a
work to check whether any IRQ are pending and handle it accordingly.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
 drivers/extcon/extcon-ptn5150.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
index 78ad86c4a3be..4f7dbba5accd 100644
--- a/drivers/extcon/extcon-ptn5150.c
+++ b/drivers/extcon/extcon-ptn5150.c
@@ -331,6 +331,19 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
 	return 0;
 }
 
+static int ptn5150_resume(struct device *dev)
+{
+	struct i2c_client *i2c = to_i2c_client(dev);
+	struct ptn5150_info *info = i2c_get_clientdata(i2c);
+
+	/* Need to check possible pending interrupt events */
+	schedule_work(&info->irq_work);
+
+	return 0;
+}
+
+DEFINE_SIMPLE_DEV_PM_OPS(ptn5150_pm_ops, NULL, ptn5150_resume);
+
 static const struct of_device_id ptn5150_dt_match[] = {
 	{ .compatible = "nxp,ptn5150" },
 	{ },
@@ -346,6 +359,7 @@ MODULE_DEVICE_TABLE(i2c, ptn5150_i2c_id);
 static struct i2c_driver ptn5150_i2c_driver = {
 	.driver		= {
 		.name	= "ptn5150",
+		.pm = pm_sleep_ptr(&ptn5150_pm_ops),
 		.of_match_table = ptn5150_dt_match,
 	},
 	.probe		= ptn5150_i2c_probe,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] extcon: ptn5150: handle pending IRQ events during system resume
  2025-11-14  7:42 [PATCH] extcon: ptn5150: handle pending IRQ events during system resume Xu Yang
@ 2025-11-14  8:08 ` Krzysztof Kozlowski
  2025-11-15  2:30   ` Xu Yang
  2025-11-14 11:54 ` Fabio Estevam
       [not found] ` <CGME20251114074150epcas1p31037ab8f07810cbb5cc677bfc0cce01d@epcms1p5>
  2 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-14  8:08 UTC (permalink / raw)
  To: Xu Yang, myungjoo.ham, cw00.choi; +Cc: linux-kernel, imx

On 14/11/2025 08:42, Xu Yang wrote:
>  
> +static int ptn5150_resume(struct device *dev)
> +{
> +	struct i2c_client *i2c = to_i2c_client(dev);
> +	struct ptn5150_info *info = i2c_get_clientdata(i2c);
> +
> +	/* Need to check possible pending interrupt events */
> +	schedule_work(&info->irq_work);
> +
> +	return 0;
> +}
> +
> +DEFINE_SIMPLE_DEV_PM_OPS(ptn5150_pm_ops, NULL, ptn5150_resume);

static

With this fixed:

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] extcon: ptn5150: handle pending IRQ events during system resume
  2025-11-14  7:42 [PATCH] extcon: ptn5150: handle pending IRQ events during system resume Xu Yang
  2025-11-14  8:08 ` Krzysztof Kozlowski
@ 2025-11-14 11:54 ` Fabio Estevam
  2025-11-15  2:31   ` Xu Yang
       [not found] ` <CGME20251114074150epcas1p31037ab8f07810cbb5cc677bfc0cce01d@epcms1p5>
  2 siblings, 1 reply; 7+ messages in thread
From: Fabio Estevam @ 2025-11-14 11:54 UTC (permalink / raw)
  To: Xu Yang; +Cc: krzk, myungjoo.ham, cw00.choi, linux-kernel, imx

On Fri, Nov 14, 2025 at 4:42 AM Xu Yang <xu.yang_2@nxp.com> wrote:
>
> When the system is suspended and ptn5150 wakeup interrupt is disabled,
> any changes on ptn5150 will only be record in interrupt status
> registers and won't fire an IRQ since its trigger type is falling
> edge. So the HW interrupt line will keep at low state and any further
> changes won't trigger IRQ anymore. To fix it, this will schedule a
> work to check whether any IRQ are pending and handle it accordingly.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

Fixes tag?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] extcon: ptn5150: handle pending IRQ events during system resume
       [not found] ` <CGME20251114074150epcas1p31037ab8f07810cbb5cc677bfc0cce01d@epcms1p5>
@ 2025-11-15  1:01   ` MyungJoo Ham
  2025-11-15  2:35     ` Xu Yang
  0 siblings, 1 reply; 7+ messages in thread
From: MyungJoo Ham @ 2025-11-15  1:01 UTC (permalink / raw)
  To: Xu Yang, krzk, Chanwoo Choi; +Cc: linux-kernel, imx

>When the system is suspended and ptn5150 wakeup interrupt is disabled,
>any changes on ptn5150 will only be record in interrupt status
>registers and won't fire an IRQ since its trigger type is falling
>edge. So the HW interrupt line will keep at low state and any further
>changes won't trigger IRQ anymore. To fix it, this will schedule a
>work to check whether any IRQ are pending and handle it accordingly.

It is ok call ptn5150_irq_work() anytime during resume even if
irq-handler is invoked right before ptn5150_resume(), right?

Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>

>
>Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
>---
> drivers/extcon/extcon-ptn5150.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] extcon: ptn5150: handle pending IRQ events during system resume
  2025-11-14  8:08 ` Krzysztof Kozlowski
@ 2025-11-15  2:30   ` Xu Yang
  0 siblings, 0 replies; 7+ messages in thread
From: Xu Yang @ 2025-11-15  2:30 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: myungjoo.ham, cw00.choi, linux-kernel, imx

On Fri, Nov 14, 2025 at 09:08:24AM +0100, Krzysztof Kozlowski wrote:
> On 14/11/2025 08:42, Xu Yang wrote:
> >  
> > +static int ptn5150_resume(struct device *dev)
> > +{
> > +	struct i2c_client *i2c = to_i2c_client(dev);
> > +	struct ptn5150_info *info = i2c_get_clientdata(i2c);
> > +
> > +	/* Need to check possible pending interrupt events */
> > +	schedule_work(&info->irq_work);
> > +
> > +	return 0;
> > +}
> > +
> > +DEFINE_SIMPLE_DEV_PM_OPS(ptn5150_pm_ops, NULL, ptn5150_resume);
> 
> static
> 
> With this fixed:

Will do.

> 
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Thanks,
Xu Yang

> 
> Best regards,
> Krzysztof

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] extcon: ptn5150: handle pending IRQ events during system resume
  2025-11-14 11:54 ` Fabio Estevam
@ 2025-11-15  2:31   ` Xu Yang
  0 siblings, 0 replies; 7+ messages in thread
From: Xu Yang @ 2025-11-15  2:31 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: krzk, myungjoo.ham, cw00.choi, linux-kernel, imx

On Fri, Nov 14, 2025 at 08:54:03AM -0300, Fabio Estevam wrote:
> On Fri, Nov 14, 2025 at 4:42 AM Xu Yang <xu.yang_2@nxp.com> wrote:
> >
> > When the system is suspended and ptn5150 wakeup interrupt is disabled,
> > any changes on ptn5150 will only be record in interrupt status
> > registers and won't fire an IRQ since its trigger type is falling
> > edge. So the HW interrupt line will keep at low state and any further
> > changes won't trigger IRQ anymore. To fix it, this will schedule a
> > work to check whether any IRQ are pending and handle it accordingly.
> >
> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> 
> Fixes tag?

Will add it in v2.

Thanks,
Xu Yang

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] extcon: ptn5150: handle pending IRQ events during system resume
  2025-11-15  1:01   ` MyungJoo Ham
@ 2025-11-15  2:35     ` Xu Yang
  0 siblings, 0 replies; 7+ messages in thread
From: Xu Yang @ 2025-11-15  2:35 UTC (permalink / raw)
  To: MyungJoo Ham; +Cc: krzk, Chanwoo Choi, linux-kernel, imx

Hi MyungJoo,

On Sat, Nov 15, 2025 at 10:01:45AM +0900, MyungJoo Ham wrote:
> >When the system is suspended and ptn5150 wakeup interrupt is disabled,
> >any changes on ptn5150 will only be record in interrupt status
> >registers and won't fire an IRQ since its trigger type is falling
> >edge. So the HW interrupt line will keep at low state and any further
> >changes won't trigger IRQ anymore. To fix it, this will schedule a
> >work to check whether any IRQ are pending and handle it accordingly.
> 
> It is ok call ptn5150_irq_work() anytime during resume even if
> irq-handler is invoked right before ptn5150_resume(), right?

Yes, it's ok because the mutex lock will protect it and if irq-handler
is invoked firstly, ptn5150_resume() will just read the status registers
and return soon since no pending events.

> 
> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>

Thanks,
Xu Yang

> 
> >
> >Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> >---
> > drivers/extcon/extcon-ptn5150.c | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-11-15  2:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-14  7:42 [PATCH] extcon: ptn5150: handle pending IRQ events during system resume Xu Yang
2025-11-14  8:08 ` Krzysztof Kozlowski
2025-11-15  2:30   ` Xu Yang
2025-11-14 11:54 ` Fabio Estevam
2025-11-15  2:31   ` Xu Yang
     [not found] ` <CGME20251114074150epcas1p31037ab8f07810cbb5cc677bfc0cce01d@epcms1p5>
2025-11-15  1:01   ` MyungJoo Ham
2025-11-15  2:35     ` Xu Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®