Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: "Michał Kardaś" <mkmkl@google.com>
To: "Linus Walleij" <linusw@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Jiri Slaby" <jirislaby@kernel.org>
Cc: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Douglas Anderson" <dianders@chromium.org>,
	"Vic Huang" <vich@google.com>,
	linux-gpio@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, "Michał Kardaś" <mkmkl@google.com>
Subject: [PATCH v1 2/2] tty: serial: 8250_dw: Keep init pinctrl state until first open
Date: Mon, 10 Aug 2026 13:06:35 +0000	[thread overview]
Message-ID: <20260810130635.1166626-3-mkmkl@google.com> (raw)
In-Reply-To: <20260810130635.1166626-1-mkmkl@google.com>

When a UART port is connected to an external peripheral whose power
domain is kept powered off until first use, transitioning the UART
pins from the "init" state to the "default" state prematurely at probe
completion can cause parasitic back-powering into the unpowered
peripheral.

Ensure that on boards specifying an "init" pinctrl state for the port,
the "init" state is preserved until the port is first opened:

1. In dw8250_probe(), call pinctrl_keep_init_state(dev) to opt out of the
   automatic "init" -> "default" transition at probe completion and record
   this in data->in_init_state.
2. In dw8250_do_pm(), when the port is opened (state == 0), transition
   pins from "init" to "default" if data->in_init_state is set, and clear
   the flag.

Suggested-by: Douglas Anderson <dianders@chromium.org>
Co-developed-by: Vic Huang <vich@google.com>
Signed-off-by: Vic Huang <vich@google.com>
Signed-off-by: Michał Kardaś <mkmkl@google.com>
---
 drivers/tty/serial/8250/8250_dw.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 5fba913f3301..74e568e2a0d3 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -18,6 +18,7 @@
 #include <linux/io.h>
 #include <linux/lockdep.h>
 #include <linux/module.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/property.h>
@@ -77,6 +78,7 @@ struct dw8250_data {
 	unsigned int		skip_autocfg:1;
 	unsigned int		uart_16550_compatible:1;
 	unsigned int		in_idle:1;
+	unsigned int		in_init_state:1;
 
 	u8			no_int_count;
 };
@@ -461,8 +463,15 @@ static int dw8250_handle_irq(struct uart_port *p)
 static void
 dw8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old)
 {
-	if (!state)
+	struct dw8250_data *d = to_dw8250_data(port->private_data);
+
+	if (!state) {
 		pm_runtime_get_sync(port->dev);
+		if (d->in_init_state) {
+			d->in_init_state = false;
+			pinctrl_pm_select_default_state(port->dev);
+		}
+	}
 
 	serial8250_do_pm(port, state, old);
 
@@ -770,6 +779,8 @@ static int dw8250_probe(struct platform_device *pdev)
 	if (data->data.line < 0)
 		return data->data.line;
 
+	data->in_init_state = pinctrl_keep_init_state(dev);
+
 	platform_set_drvdata(pdev, data);
 
 	pm_runtime_enable(dev);
-- 
2.55.0.654.g21b8a5bc05-goog


  parent reply	other threads:[~2026-08-10 13:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 13:06 [PATCH v1 0/2] pinctrl / 8250_dw: Allow drivers to keep init pinctrl state until first open Michał Kardaś
2026-08-10 13:06 ` [PATCH v1 1/2] pinctrl: core: Allow drivers to keep "init" pinctrl state after probe Michał Kardaś
2026-08-10 18:12   ` Andy Shevchenko
2026-08-10 13:06 ` Michał Kardaś [this message]
2026-08-10 18:17   ` [PATCH v1 2/2] tty: serial: 8250_dw: Keep init pinctrl state until first open Andy Shevchenko
2026-08-11  6:36   ` Linus Walleij
2026-08-11  6:34 ` [PATCH v1 0/2] pinctrl / 8250_dw: Allow drivers to keep " Linus Walleij

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=20260810130635.1166626-3-mkmkl@google.com \
    --to=mkmkl@google.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dianders@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=vich@google.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