From: Kendall Willis <k-willis@ti.com>
To: <gregkh@linuxfoundation.org>, <jirislaby@kernel.org>,
<robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
<vigneshr@ti.com>, <linux-kernel@vger.kernel.org>,
<linux-serial@vger.kernel.org>, <devicetree@vger.kernel.org>
Cc: <d-gole@ti.com>, <vishalm@ti.com>, <sebin.francis@ti.com>,
<msp@baylibre.com>, <khilman@baylibre.com>, <a-kaur@ti.com>,
<k-willis@ti.com>, <john.ogness@linutronix.de>,
<andriy.shevchenko@linux.intel.com>, <yujiaoliang@vivo.com>,
<b-liu@ti.com>, <u.kleine-koenig@baylibre.com>
Subject: [PATCH 3/3] serial: 8250: omap: Support wakeup pinctrl state on suspend
Date: Thu, 4 Sep 2025 16:24:55 -0500 [thread overview]
Message-ID: <20250904212455.3729029-4-k-willis@ti.com> (raw)
In-Reply-To: <20250904212455.3729029-1-k-willis@ti.com>
From: Markus Schneider-Pargmann <msp@baylibre.com>
UART can be used as a wakeup source for am62 from suspend to ram states.
To enable wakeup from UART am62 requires a wakeup flag being set in the
pinctrl.
If the device is marked as wakeup enabled, select the 'wakeup' pinctrl
state on suspend and restore the default pinctrl state on resume.
Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Signed-off-by: Kendall Willis <k-willis@ti.com>
---
drivers/tty/serial/8250/8250_omap.c | 36 +++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index bb23afdd63f29..9e49ef48b851b 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -27,6 +27,8 @@
#include <linux/pm_wakeirq.h>
#include <linux/dma-mapping.h>
#include <linux/sys_soc.h>
+#include <linux/reboot.h>
+#include <linux/pinctrl/consumer.h>
#include "8250.h"
@@ -145,6 +147,9 @@ struct omap8250_priv {
spinlock_t rx_dma_lock;
bool rx_dma_broken;
bool throttled;
+
+ struct pinctrl *pinctrl;
+ struct pinctrl_state *pinctrl_wakeup;
};
struct omap8250_dma_params {
@@ -1349,6 +1354,18 @@ static int omap8250_no_handle_irq(struct uart_port *port)
return 0;
}
+static int omap8250_select_wakeup_pinctrl(struct device *dev,
+ struct omap8250_priv *priv)
+{
+ if (IS_ERR_OR_NULL(priv->pinctrl_wakeup))
+ return 0;
+
+ if (!device_may_wakeup(dev))
+ return 0;
+
+ return pinctrl_select_state(priv->pinctrl, priv->pinctrl_wakeup);
+}
+
static struct omap8250_dma_params am654_dma = {
.rx_size = SZ_2K,
.rx_trigger = 1,
@@ -1573,6 +1590,11 @@ static int omap8250_probe(struct platform_device *pdev)
priv->line = ret;
pm_runtime_mark_last_busy(&pdev->dev);
pm_runtime_put_autosuspend(&pdev->dev);
+
+ priv->pinctrl = devm_pinctrl_get(&pdev->dev);
+ if (!IS_ERR_OR_NULL(priv->pinctrl))
+ priv->pinctrl_wakeup = pinctrl_lookup_state(priv->pinctrl, "wakeup");
+
return 0;
err:
pm_runtime_dont_use_autosuspend(&pdev->dev);
@@ -1630,6 +1652,13 @@ static int omap8250_suspend(struct device *dev)
struct uart_8250_port *up = serial8250_get_port(priv->line);
int err = 0;
+ err = omap8250_select_wakeup_pinctrl(dev, priv);
+ if (err) {
+ dev_err(dev, "Failed to select wakeup pinctrl, aborting suspend %pe\n",
+ ERR_PTR(err));
+ return err;
+ }
+
serial8250_suspend_port(priv->line);
err = pm_runtime_resume_and_get(dev);
@@ -1651,6 +1680,13 @@ static int omap8250_resume(struct device *dev)
struct uart_8250_port *up = serial8250_get_port(priv->line);
int err;
+ err = pinctrl_select_default_state(dev);
+ if (err) {
+ dev_err(dev, "Failed to select default pinctrl state on resume: %pe\n",
+ ERR_PTR(err));
+ return err;
+ }
+
if (uart_console(&up->port) && console_suspend_enabled) {
err = pm_runtime_force_resume(dev);
if (err)
--
2.34.1
prev parent reply other threads:[~2025-09-04 21:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 21:24 [PATCH 0/3] serial: 8250: omap: Add wakeup support Kendall Willis
2025-09-04 21:24 ` [PATCH 1/3] dt-bindings: serial: 8250_omap: Update wakeup-source type property Kendall Willis
2025-09-05 18:38 ` Conor Dooley
2025-09-05 18:48 ` Dhruva Gole
2025-09-09 9:05 ` Markus Schneider-Pargmann
2025-09-09 18:59 ` Kendall Willis
2025-09-05 20:38 ` Rob Herring
2025-09-09 19:00 ` Kendall Willis
2025-09-04 21:24 ` [PATCH 2/3] dt-bindings: serial: 8250_omap: Add wakeup pinctrl state Kendall Willis
2025-09-05 20:41 ` Rob Herring
2025-09-09 21:26 ` Kendall Willis
2025-09-04 21:24 ` Kendall Willis [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250904212455.3729029-4-k-willis@ti.com \
--to=k-willis@ti.com \
--cc=a-kaur@ti.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=b-liu@ti.com \
--cc=conor+dt@kernel.org \
--cc=d-gole@ti.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=msp@baylibre.com \
--cc=robh@kernel.org \
--cc=sebin.francis@ti.com \
--cc=u.kleine-koenig@baylibre.com \
--cc=vigneshr@ti.com \
--cc=vishalm@ti.com \
--cc=yujiaoliang@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox