* [PATCH 0/2] STM32 enable gpio irqs as wakeup irqs for uart port
@ 2022-02-03 17:16 Erwan Le Ray
2022-02-03 17:16 ` [PATCH 1/2] serial: mctrl_gpio: add a new API to enable / disable wake_irq Erwan Le Ray
2022-02-03 17:16 ` [PATCH 2/2] serial: stm32: enable / disable wake irqs for mcrtl_gpio wakeup sources Erwan Le Ray
0 siblings, 2 replies; 5+ messages in thread
From: Erwan Le Ray @ 2022-02-03 17:16 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Maxime Coquelin, Alexandre Torgue, Gerald Baeza,
Erwan Le Ray, Valentin Caron, linux-serial, linux-stm32,
linux-arm-kernel, linux-kernel
This patchset allows to use mctrl_gpio pins as wakeup source.
Add a new API to enable / disable wake_irq for serial mctrl_gpio pins.
Use this API in STM32 usart driver to enable / disable mctrl_gpio pins
wake_irq in suspend / resume procedure.
Erwan Le Ray (2):
serial: mctrl_gpio: add a new API to enable / disable wake_irq
serial: stm32: enable / disable wake irqs for mcrtl_gpio wakeup
sources
drivers/tty/serial/serial_mctrl_gpio.c | 38 ++++++++++++++++++++++++++
drivers/tty/serial/serial_mctrl_gpio.h | 18 ++++++++++++
drivers/tty/serial/stm32-usart.c | 3 +-
3 files changed, 58 insertions(+), 1 deletion(-)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] serial: mctrl_gpio: add a new API to enable / disable wake_irq
2022-02-03 17:16 [PATCH 0/2] STM32 enable gpio irqs as wakeup irqs for uart port Erwan Le Ray
@ 2022-02-03 17:16 ` Erwan Le Ray
[not found] ` <CAHp75VfxGj=3mKvjcRpQjyXBCM0szsidHVuJGdAL8yP5SmdBzw@mail.gmail.com>
2022-02-03 17:16 ` [PATCH 2/2] serial: stm32: enable / disable wake irqs for mcrtl_gpio wakeup sources Erwan Le Ray
1 sibling, 1 reply; 5+ messages in thread
From: Erwan Le Ray @ 2022-02-03 17:16 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Maxime Coquelin, Alexandre Torgue, Gerald Baeza,
Erwan Le Ray, Valentin Caron, linux-serial, linux-stm32,
linux-arm-kernel, linux-kernel
Add a new API to enable / disable wake_irq in order to enable gpio irqs as
wakeup irqs for the uart port.
Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com>
diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c
index c41d8911ce95..1663b3afc3a0 100644
--- a/drivers/tty/serial/serial_mctrl_gpio.c
+++ b/drivers/tty/serial/serial_mctrl_gpio.c
@@ -299,4 +299,42 @@ void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios)
}
EXPORT_SYMBOL_GPL(mctrl_gpio_disable_ms);
+void mctrl_gpio_enable_irq_wake(struct mctrl_gpios *gpios)
+{
+ enum mctrl_gpio_idx i;
+
+ if (!gpios)
+ return;
+
+ if (!gpios->mctrl_on)
+ return;
+
+ for (i = 0; i < UART_GPIO_MAX; ++i) {
+ if (!gpios->irq[i])
+ continue;
+
+ enable_irq_wake(gpios->irq[i]);
+ }
+}
+EXPORT_SYMBOL_GPL(mctrl_gpio_enable_irq_wake);
+
+void mctrl_gpio_disable_irq_wake(struct mctrl_gpios *gpios)
+{
+ enum mctrl_gpio_idx i;
+
+ if (!gpios)
+ return;
+
+ if (!gpios->mctrl_on)
+ return;
+
+ for (i = 0; i < UART_GPIO_MAX; ++i) {
+ if (!gpios->irq[i])
+ continue;
+
+ disable_irq_wake(gpios->irq[i]);
+ }
+}
+EXPORT_SYMBOL_GPL(mctrl_gpio_disable_irq_wake);
+
MODULE_LICENSE("GPL");
diff --git a/drivers/tty/serial/serial_mctrl_gpio.h b/drivers/tty/serial/serial_mctrl_gpio.h
index b134a0ffc894..fc76910fb105 100644
--- a/drivers/tty/serial/serial_mctrl_gpio.h
+++ b/drivers/tty/serial/serial_mctrl_gpio.h
@@ -91,6 +91,16 @@ void mctrl_gpio_enable_ms(struct mctrl_gpios *gpios);
*/
void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios);
+/*
+ * Enable gpio wakeup interrupts to enable wake up source.
+ */
+void mctrl_gpio_enable_irq_wake(struct mctrl_gpios *gpios);
+
+/*
+ * Disable gpio wakeup interrupts to enable wake up source.
+ */
+void mctrl_gpio_disable_irq_wake(struct mctrl_gpios *gpios);
+
#else /* GPIOLIB */
static inline
@@ -142,6 +152,14 @@ static inline void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios)
{
}
+static inline void mctrl_gpio_enable_irq_wake(struct mctrl_gpios *gpios)
+{
+}
+
+static inline void mctrl_gpio_disable_irq_wake(struct mctrl_gpios *gpios)
+{
+}
+
#endif /* GPIOLIB */
#endif
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] serial: stm32: enable / disable wake irqs for mcrtl_gpio wakeup sources
2022-02-03 17:16 [PATCH 0/2] STM32 enable gpio irqs as wakeup irqs for uart port Erwan Le Ray
2022-02-03 17:16 ` [PATCH 1/2] serial: mctrl_gpio: add a new API to enable / disable wake_irq Erwan Le Ray
@ 2022-02-03 17:16 ` Erwan Le Ray
1 sibling, 0 replies; 5+ messages in thread
From: Erwan Le Ray @ 2022-02-03 17:16 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Maxime Coquelin, Alexandre Torgue, Gerald Baeza,
Erwan Le Ray, Valentin Caron, linux-serial, linux-stm32,
linux-arm-kernel, linux-kernel
Enable mctrl_gpio wake_irq if device_may_wakeup when usart is suspended,
and disable mctrl_gpios wake_irq if device_may_wakeup when usart is
resumed.
Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com>
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index 3244e7f6818c..df86c53e62a7 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -1708,6 +1708,7 @@ static int __maybe_unused stm32_usart_serial_en_wakeup(struct uart_port *port,
if (enable) {
stm32_usart_set_bits(port, ofs->cr1, USART_CR1_UESM);
stm32_usart_set_bits(port, ofs->cr3, USART_CR3_WUFIE);
+ mctrl_gpio_enable_irq_wake(stm32_port->gpios);
/*
* When DMA is used for reception, it must be disabled before
@@ -1734,7 +1735,7 @@ static int __maybe_unused stm32_usart_serial_en_wakeup(struct uart_port *port,
if (ret)
return ret;
}
-
+ mctrl_gpio_disable_irq_wake(stm32_port->gpios);
stm32_usart_clr_bits(port, ofs->cr1, USART_CR1_UESM);
stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_WUFIE);
}
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] serial: mctrl_gpio: add a new API to enable / disable wake_irq
[not found] ` <CAHp75VfxGj=3mKvjcRpQjyXBCM0szsidHVuJGdAL8yP5SmdBzw@mail.gmail.com>
@ 2022-02-04 15:41 ` Erwan LE RAY
2022-02-08 10:07 ` Greg Kroah-Hartman
0 siblings, 1 reply; 5+ messages in thread
From: Erwan LE RAY @ 2022-02-04 15:41 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Greg Kroah-Hartman, Jiri Slaby, Maxime Coquelin, Alexandre Torgue,
Gerald Baeza, Valentin Caron, linux-serial@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Hi Andy,
On 2/4/22 10:07 AM, Andy Shevchenko wrote:
>
>
> On Thursday, February 3, 2022, Erwan Le Ray <erwan.leray@foss.st.com
> <mailto:erwan.leray@foss.st.com>> wrote:
>
> Add a new API to enable / disable wake_irq in order to enable gpio
> irqs as
> wakeup irqs for the uart port.
>
> Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com
> <mailto:erwan.leray@foss.st.com>>
>
> diff --git a/drivers/tty/serial/serial_mctrl_gpio.c
> b/drivers/tty/serial/serial_mctrl_gpio.c
> index c41d8911ce95..1663b3afc3a0 100644
> --- a/drivers/tty/serial/serial_mctrl_gpio.c
> +++ b/drivers/tty/serial/serial_mctrl_gpio.c
> @@ -299,4 +299,42 @@ void mctrl_gpio_disable_ms(struct mctrl_gpios
> *gpios)
> }
> EXPORT_SYMBOL_GPL(mctrl_gpio_disable_ms);
>
> +void mctrl_gpio_enable_irq_wake(struct mctrl_gpios *gpios)
> +{
> + enum mctrl_gpio_idx i;
> +
> + if (!gpios)
> + return;
> +
> + if (!gpios->mctrl_on)
> + return;
> +
> + for (i = 0; i < UART_GPIO_MAX; ++i) {
> + if (!gpios->irq[i])
> + continue;
>
>
>
> Why not simply
>
> if (gpios[])
> enable_irq_...
>
> ?
>
> And same for disabling.
>
> +
> + enable_irq_wake(gpios->irq[i]);
> + }
> +}
> +EXPORT_SYMBOL_GPL(mctrl_gpio_enable_irq_wake);
> +
> +void mctrl_gpio_disable_irq_wake(struct mctrl_gpios *gpios)
> +{
> + enum mctrl_gpio_idx i;
> +
> + if (!gpios)
> + return;
> +
> + if (!gpios->mctrl_on)
> + return;
> +
> + for (i = 0; i < UART_GPIO_MAX; ++i) {
> + if (!gpios->irq[i])
> + continue;
> +
> + disable_irq_wake(gpios->irq[i]);
> + }
> +}
> +EXPORT_SYMBOL_GPL(mctrl_gpio_disable_irq_wake);
> +
> MODULE_LICENSE("GPL");
> diff --git a/drivers/tty/serial/serial_mctrl_gpio.h
> b/drivers/tty/serial/serial_mctrl_gpio.h
> index b134a0ffc894..fc76910fb105 100644
> --- a/drivers/tty/serial/serial_mctrl_gpio.h
> +++ b/drivers/tty/serial/serial_mctrl_gpio.h
> @@ -91,6 +91,16 @@ void mctrl_gpio_enable_ms(struct mctrl_gpios *gpios);
> */
> void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios);
>
> +/*
> + * Enable gpio wakeup interrupts to enable wake up source.
> + */
> +void mctrl_gpio_enable_irq_wake(struct mctrl_gpios *gpios);
> +
> +/*
> + * Disable gpio wakeup interrupts to enable wake up source.
> + */
> +void mctrl_gpio_disable_irq_wake(struct mctrl_gpios *gpios);
> +
> #else /* GPIOLIB */
>
> static inline
> @@ -142,6 +152,14 @@ static inline void mctrl_gpio_disable_ms(struct
> mctrl_gpios *gpios)
> {
> }
>
> +static inline void mctrl_gpio_enable_irq_wake(struct mctrl_gpios
> *gpios)
> +{
> +}
> +
> +static inline void mctrl_gpio_disable_irq_wake(struct mctrl_gpios
> *gpios)
> +{
> +}
> +
> #endif /* GPIOLIB */
>
> #endif
> --
> 2.17.1
>
>
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
Thanks for your review.
I fully agree with your comment, but I wrote this code like it is to
keep the same structure than all the other ops of serial_mcrtrl_gpio
driver. I preferred keeping an homogeneous code in the driver rather
than breaking the driver homogeneity with the addition of an optimized code.
Greg, can you please indicate which solution you recommend ?
Cheers, Erwan.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] serial: mctrl_gpio: add a new API to enable / disable wake_irq
2022-02-04 15:41 ` Erwan LE RAY
@ 2022-02-08 10:07 ` Greg Kroah-Hartman
0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2022-02-08 10:07 UTC (permalink / raw)
To: Erwan LE RAY
Cc: Andy Shevchenko, Jiri Slaby, Maxime Coquelin, Alexandre Torgue,
Gerald Baeza, Valentin Caron, linux-serial@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
On Fri, Feb 04, 2022 at 04:41:58PM +0100, Erwan LE RAY wrote:
> Hi Andy,
>
> On 2/4/22 10:07 AM, Andy Shevchenko wrote:
> >
> >
> > On Thursday, February 3, 2022, Erwan Le Ray <erwan.leray@foss.st.com
> > <mailto:erwan.leray@foss.st.com>> wrote:
> >
> > Add a new API to enable / disable wake_irq in order to enable gpio
> > irqs as
> > wakeup irqs for the uart port.
> >
> > Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com
> > <mailto:erwan.leray@foss.st.com>>
> >
> > diff --git a/drivers/tty/serial/serial_mctrl_gpio.c
> > b/drivers/tty/serial/serial_mctrl_gpio.c
> > index c41d8911ce95..1663b3afc3a0 100644
> > --- a/drivers/tty/serial/serial_mctrl_gpio.c
> > +++ b/drivers/tty/serial/serial_mctrl_gpio.c
> > @@ -299,4 +299,42 @@ void mctrl_gpio_disable_ms(struct mctrl_gpios
> > *gpios)
> > }
> > EXPORT_SYMBOL_GPL(mctrl_gpio_disable_ms);
> >
> > +void mctrl_gpio_enable_irq_wake(struct mctrl_gpios *gpios)
> > +{
> > + enum mctrl_gpio_idx i;
> > +
> > + if (!gpios)
> > + return;
> > +
> > + if (!gpios->mctrl_on)
> > + return;
> > +
> > + for (i = 0; i < UART_GPIO_MAX; ++i) {
> > + if (!gpios->irq[i])
> > + continue;
> >
> >
> >
> > Why not simply
> >
> > if (gpios[])
> > enable_irq_...
> >
> > ?
> >
> > And same for disabling.
> >
> > +
> > + enable_irq_wake(gpios->irq[i]);
> > + }
> > +}
> > +EXPORT_SYMBOL_GPL(mctrl_gpio_enable_irq_wake);
> > +
> > +void mctrl_gpio_disable_irq_wake(struct mctrl_gpios *gpios)
> > +{
> > + enum mctrl_gpio_idx i;
> > +
> > + if (!gpios)
> > + return;
> > +
> > + if (!gpios->mctrl_on)
> > + return;
> > +
> > + for (i = 0; i < UART_GPIO_MAX; ++i) {
> > + if (!gpios->irq[i])
> > + continue;
> > +
> > + disable_irq_wake(gpios->irq[i]);
> > + }
> > +}
> > +EXPORT_SYMBOL_GPL(mctrl_gpio_disable_irq_wake);
> > +
> > MODULE_LICENSE("GPL");
> > diff --git a/drivers/tty/serial/serial_mctrl_gpio.h
> > b/drivers/tty/serial/serial_mctrl_gpio.h
> > index b134a0ffc894..fc76910fb105 100644
> > --- a/drivers/tty/serial/serial_mctrl_gpio.h
> > +++ b/drivers/tty/serial/serial_mctrl_gpio.h
> > @@ -91,6 +91,16 @@ void mctrl_gpio_enable_ms(struct mctrl_gpios *gpios);
> > */
> > void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios);
> >
> > +/*
> > + * Enable gpio wakeup interrupts to enable wake up source.
> > + */
> > +void mctrl_gpio_enable_irq_wake(struct mctrl_gpios *gpios);
> > +
> > +/*
> > + * Disable gpio wakeup interrupts to enable wake up source.
> > + */
> > +void mctrl_gpio_disable_irq_wake(struct mctrl_gpios *gpios);
> > +
> > #else /* GPIOLIB */
> >
> > static inline
> > @@ -142,6 +152,14 @@ static inline void mctrl_gpio_disable_ms(struct
> > mctrl_gpios *gpios)
> > {
> > }
> >
> > +static inline void mctrl_gpio_enable_irq_wake(struct mctrl_gpios
> > *gpios)
> > +{
> > +}
> > +
> > +static inline void mctrl_gpio_disable_irq_wake(struct mctrl_gpios
> > *gpios)
> > +{
> > +}
> > +
> > #endif /* GPIOLIB */
> >
> > #endif
> > -- 2.17.1
> >
> >
> >
> > --
> > With Best Regards,
> > Andy Shevchenko
> >
> >
>
> Thanks for your review.
> I fully agree with your comment, but I wrote this code like it is to keep
> the same structure than all the other ops of serial_mcrtrl_gpio driver. I
> preferred keeping an homogeneous code in the driver rather than breaking the
> driver homogeneity with the addition of an optimized code.
>
> Greg, can you please indicate which solution you recommend ?
Sadly, this is the format in this file, so I'll take this as-is.
thanks,
greg k-h
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-08 10:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-03 17:16 [PATCH 0/2] STM32 enable gpio irqs as wakeup irqs for uart port Erwan Le Ray
2022-02-03 17:16 ` [PATCH 1/2] serial: mctrl_gpio: add a new API to enable / disable wake_irq Erwan Le Ray
[not found] ` <CAHp75VfxGj=3mKvjcRpQjyXBCM0szsidHVuJGdAL8yP5SmdBzw@mail.gmail.com>
2022-02-04 15:41 ` Erwan LE RAY
2022-02-08 10:07 ` Greg Kroah-Hartman
2022-02-03 17:16 ` [PATCH 2/2] serial: stm32: enable / disable wake irqs for mcrtl_gpio wakeup sources Erwan Le Ray
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).