Re: [PATCH v1 2/2] tty: serial: 8250_dw: Keep init pinctrl state until first open

Andy Shevchenko <[email protected]>
Newsgroups org.kernel.vger.linux-kernel,org.kernel.vger.linux-gpio,org.kernel.vger.linux-serial
Organization Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo
Message-ID <[email protected]>
On Mon, Aug 10, 2026 at 01:06:35PM +0000, Michał Kardaś wrote:
> 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.

...

>  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;

Mistyped assignee. Should be 0.

> +			pinctrl_pm_select_default_state(port->dev);
> +		}
> +	}

Obviously the above needs a good comment in the code explaining why it is doing
that.

...

>  	if (data->data.line < 0)
>  		return data->data.line;

And a good comment explaining what you put in the commit message.

> +	data->in_init_state = pinctrl_keep_init_state(dev);

>  	platform_set_drvdata(pdev, data);
>  
>  	pm_runtime_enable(dev);

...

Wondering if this anyhow affects the future idea of the OOB wakeup for the UART
using its Rx as GPIO wake source in the suspend.

-- 
With Best Regards,
Andy Shevchenko
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.