Skip to content

Commit 68e6939

Browse files
thom24gregkh
authored andcommitted
serial: 8250_omap: Set the console genpd always on if no console suspend
If the console suspend is disabled, the genpd of the console shall not be powered-off during suspend. Set the flag GENPD_FLAG_ALWAYS_ON to the corresponding genpd during suspend, and restore the original value during the resume. Signed-off-by: Thomas Richard <thomas.richard@bootlin.com> Link: https://lore.kernel.org/r/20231017130540.1149721-1-thomas.richard@bootlin.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a30badf commit 68e6939

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

drivers/tty/serial/8250/8250_omap.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/pm_wakeirq.h>
2929
#include <linux/dma-mapping.h>
3030
#include <linux/sys_soc.h>
31+
#include <linux/pm_domain.h>
3132

3233
#include "8250.h"
3334

@@ -115,6 +116,12 @@
115116
/* RX FIFO occupancy indicator */
116117
#define UART_OMAP_RX_LVL 0x19
117118

119+
/*
120+
* Copy of the genpd flags for the console.
121+
* Only used if console suspend is disabled
122+
*/
123+
static unsigned int genpd_flags_console;
124+
118125
struct omap8250_priv {
119126
void __iomem *membase;
120127
int line;
@@ -1623,6 +1630,7 @@ static int omap8250_suspend(struct device *dev)
16231630
{
16241631
struct omap8250_priv *priv = dev_get_drvdata(dev);
16251632
struct uart_8250_port *up = serial8250_get_port(priv->line);
1633+
struct generic_pm_domain *genpd = pd_to_genpd(dev->pm_domain);
16261634
int err = 0;
16271635

16281636
serial8250_suspend_port(priv->line);
@@ -1633,8 +1641,19 @@ static int omap8250_suspend(struct device *dev)
16331641
if (!device_may_wakeup(dev))
16341642
priv->wer = 0;
16351643
serial_out(up, UART_OMAP_WER, priv->wer);
1636-
if (uart_console(&up->port) && console_suspend_enabled)
1637-
err = pm_runtime_force_suspend(dev);
1644+
if (uart_console(&up->port)) {
1645+
if (console_suspend_enabled)
1646+
err = pm_runtime_force_suspend(dev);
1647+
else {
1648+
/*
1649+
* The pd shall not be powered-off (no console suspend).
1650+
* Make copy of genpd flags before to set it always on.
1651+
* The original value is restored during the resume.
1652+
*/
1653+
genpd_flags_console = genpd->flags;
1654+
genpd->flags |= GENPD_FLAG_ALWAYS_ON;
1655+
}
1656+
}
16381657
flush_work(&priv->qos_work);
16391658

16401659
return err;
@@ -1644,12 +1663,16 @@ static int omap8250_resume(struct device *dev)
16441663
{
16451664
struct omap8250_priv *priv = dev_get_drvdata(dev);
16461665
struct uart_8250_port *up = serial8250_get_port(priv->line);
1666+
struct generic_pm_domain *genpd = pd_to_genpd(dev->pm_domain);
16471667
int err;
16481668

16491669
if (uart_console(&up->port) && console_suspend_enabled) {
1650-
err = pm_runtime_force_resume(dev);
1651-
if (err)
1652-
return err;
1670+
if (console_suspend_enabled) {
1671+
err = pm_runtime_force_resume(dev);
1672+
if (err)
1673+
return err;
1674+
} else
1675+
genpd->flags = genpd_flags_console;
16531676
}
16541677

16551678
serial8250_resume_port(priv->line);

0 commit comments

Comments
 (0)