public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/1] Add Sifive uart suspend and resume
@ 2023-08-09 13:50 Nick Hu
  2023-08-09 13:50 ` [PATCH v2 1/1] serial: sifive: Add suspend and resume operations Nick Hu
  2023-08-11 19:11 ` [PATCH v2 0/1] Add Sifive uart suspend and resume Greg KH
  0 siblings, 2 replies; 6+ messages in thread
From: Nick Hu @ 2023-08-09 13:50 UTC (permalink / raw)
  To: nick.hu, zong.li, gregkh, jirislaby, palmer, paul.walmsley,
	linux-serial, linux-kernel, linux-riscv

Add Sifive uart suspend and resume functions for system suspend.

Changes in v2:
- Change Signed-off-by: Ben Dooks to Reviewed-by: Ben Dooks
- Remove the unnecessary check

Nick Hu (1):
  serial: sifive: Add suspend and resume operations

 drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

-- 
2.34.1


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

* [PATCH v2 1/1] serial: sifive: Add suspend and resume operations
  2023-08-09 13:50 [PATCH v2 0/1] Add Sifive uart suspend and resume Nick Hu
@ 2023-08-09 13:50 ` Nick Hu
  2023-08-11 19:11 ` [PATCH v2 0/1] Add Sifive uart suspend and resume Greg KH
  1 sibling, 0 replies; 6+ messages in thread
From: Nick Hu @ 2023-08-09 13:50 UTC (permalink / raw)
  To: nick.hu, zong.li, gregkh, jirislaby, palmer, paul.walmsley,
	linux-serial, linux-kernel, linux-riscv
  Cc: Ben Dooks

If the Sifive Uart is not used as the wake up source, suspend the uart
before the system enter the suspend state to prevent it woken up by
unexpected uart interrupt. Resume the uart once the system woken up.

Signed-off-by: Nick Hu <nick.hu@sifive.com>
Reviewed-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c
index a19db49327e2..939dd351a058 100644
--- a/drivers/tty/serial/sifive.c
+++ b/drivers/tty/serial/sifive.c
@@ -1022,6 +1022,23 @@ static int sifive_serial_remove(struct platform_device *dev)
 	return 0;
 }
 
+static int sifive_serial_suspend(struct device *dev)
+{
+	struct sifive_serial_port *ssp = dev_get_drvdata(dev);
+
+	return uart_suspend_port(&sifive_serial_uart_driver, &ssp->port);
+}
+
+static int sifive_serial_resume(struct device *dev)
+{
+	struct sifive_serial_port *ssp = dev_get_drvdata(dev);
+
+	return uart_resume_port(&sifive_serial_uart_driver, &ssp->port);
+}
+
+DEFINE_SIMPLE_DEV_PM_OPS(sifive_uart_pm_ops, sifive_serial_suspend,
+			 sifive_serial_resume);
+
 static const struct of_device_id sifive_serial_of_match[] = {
 	{ .compatible = "sifive,fu540-c000-uart0" },
 	{ .compatible = "sifive,uart0" },
@@ -1034,6 +1051,7 @@ static struct platform_driver sifive_serial_platform_driver = {
 	.remove		= sifive_serial_remove,
 	.driver		= {
 		.name	= SIFIVE_SERIAL_NAME,
+		.pm = pm_sleep_ptr(&sifive_uart_pm_ops),
 		.of_match_table = of_match_ptr(sifive_serial_of_match),
 	},
 };
-- 
2.34.1


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

* Re: [PATCH v2 0/1] Add Sifive uart suspend and resume
  2023-08-09 13:50 [PATCH v2 0/1] Add Sifive uart suspend and resume Nick Hu
  2023-08-09 13:50 ` [PATCH v2 1/1] serial: sifive: Add suspend and resume operations Nick Hu
@ 2023-08-11 19:11 ` Greg KH
  2023-08-14  5:55   ` Nick Hu
  1 sibling, 1 reply; 6+ messages in thread
From: Greg KH @ 2023-08-11 19:11 UTC (permalink / raw)
  To: Nick Hu
  Cc: zong.li, jirislaby, palmer, paul.walmsley, linux-serial,
	linux-kernel, linux-riscv

On Wed, Aug 09, 2023 at 09:50:41PM +0800, Nick Hu wrote:
> Add Sifive uart suspend and resume functions for system suspend.
> 
> Changes in v2:
> - Change Signed-off-by: Ben Dooks to Reviewed-by: Ben Dooks
> - Remove the unnecessary check
> 
> Nick Hu (1):
>   serial: sifive: Add suspend and resume operations
> 
>  drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> -- 
> 2.34.1
> 

Does not apply to my tree :(

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

* Re: [PATCH v2 0/1] Add Sifive uart suspend and resume
  2023-08-11 19:11 ` [PATCH v2 0/1] Add Sifive uart suspend and resume Greg KH
@ 2023-08-14  5:55   ` Nick Hu
  2023-08-14  6:02     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Hu @ 2023-08-14  5:55 UTC (permalink / raw)
  To: Greg KH
  Cc: zong.li, jirislaby, palmer, paul.walmsley, linux-serial,
	linux-kernel, linux-riscv

Hi Greg

On Sat, Aug 12, 2023 at 3:11 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Aug 09, 2023 at 09:50:41PM +0800, Nick Hu wrote:
> > Add Sifive uart suspend and resume functions for system suspend.
> >
> > Changes in v2:
> > - Change Signed-off-by: Ben Dooks to Reviewed-by: Ben Dooks
> > - Remove the unnecessary check
> >
> > Nick Hu (1):
> >   serial: sifive: Add suspend and resume operations
> >
> >  drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> >
> > --
> > 2.34.1
> >
>
> Does not apply to my tree :(
Is there any reason that it doesn't apply to your tree?
Which tree should I go?

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

* Re: [PATCH v2 0/1] Add Sifive uart suspend and resume
  2023-08-14  5:55   ` Nick Hu
@ 2023-08-14  6:02     ` Greg KH
  2023-08-14  8:12       ` Nick Hu
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2023-08-14  6:02 UTC (permalink / raw)
  To: Nick Hu
  Cc: zong.li, jirislaby, palmer, paul.walmsley, linux-serial,
	linux-kernel, linux-riscv

On Mon, Aug 14, 2023 at 01:55:58PM +0800, Nick Hu wrote:
> Hi Greg
> 
> On Sat, Aug 12, 2023 at 3:11 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Wed, Aug 09, 2023 at 09:50:41PM +0800, Nick Hu wrote:
> > > Add Sifive uart suspend and resume functions for system suspend.
> > >
> > > Changes in v2:
> > > - Change Signed-off-by: Ben Dooks to Reviewed-by: Ben Dooks
> > > - Remove the unnecessary check
> > >
> > > Nick Hu (1):
> > >   serial: sifive: Add suspend and resume operations
> > >
> > >  drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
> > >  1 file changed, 18 insertions(+)
> > >
> > > --
> > > 2.34.1
> > >
> >
> > Does not apply to my tree :(
> Is there any reason that it doesn't apply to your tree?
> Which tree should I go?

Which tree did you make it against?  It doesn't apply due to conflicts.
Perhaps either regenerate it against the tty-next branch of the tty.git
tree, or linux-next?

thanks,

greg k-h

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

* Re: [PATCH v2 0/1] Add Sifive uart suspend and resume
  2023-08-14  6:02     ` Greg KH
@ 2023-08-14  8:12       ` Nick Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Hu @ 2023-08-14  8:12 UTC (permalink / raw)
  To: Greg KH
  Cc: zong.li, jirislaby, palmer, paul.walmsley, linux-serial,
	linux-kernel, linux-riscv

Hi Greg

On Mon, Aug 14, 2023 at 2:02 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Mon, Aug 14, 2023 at 01:55:58PM +0800, Nick Hu wrote:
> > Hi Greg
> >
> > On Sat, Aug 12, 2023 at 3:11 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> > >
> > > On Wed, Aug 09, 2023 at 09:50:41PM +0800, Nick Hu wrote:
> > > > Add Sifive uart suspend and resume functions for system suspend.
> > > >
> > > > Changes in v2:
> > > > - Change Signed-off-by: Ben Dooks to Reviewed-by: Ben Dooks
> > > > - Remove the unnecessary check
> > > >
> > > > Nick Hu (1):
> > > >   serial: sifive: Add suspend and resume operations
> > > >
> > > >  drivers/tty/serial/sifive.c | 18 ++++++++++++++++++
> > > >  1 file changed, 18 insertions(+)
> > > >
> > > > --
> > > > 2.34.1
> > > >
> > >
> > > Does not apply to my tree :(
> > Is there any reason that it doesn't apply to your tree?
> > Which tree should I go?
>
> Which tree did you make it against?  It doesn't apply due to conflicts.
> Perhaps either regenerate it against the tty-next branch of the tty.git
> tree, or linux-next?
>
> thanks,
>
> greg k-h
I'm using the mainline linux kernel.
Thanks for the information.
I can reproduce it in tty-next branch of the tty.git!
I'll fix it in v3.

Regards,
Nick

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

end of thread, other threads:[~2023-08-14  8:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 13:50 [PATCH v2 0/1] Add Sifive uart suspend and resume Nick Hu
2023-08-09 13:50 ` [PATCH v2 1/1] serial: sifive: Add suspend and resume operations Nick Hu
2023-08-11 19:11 ` [PATCH v2 0/1] Add Sifive uart suspend and resume Greg KH
2023-08-14  5:55   ` Nick Hu
2023-08-14  6:02     ` Greg KH
2023-08-14  8:12       ` Nick Hu

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