[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7hmsly60o3.fsf@baylibre.com>
Date: Tue, 30 Jul 2024 14:16:12 -0700
From: Kevin Hilman <khilman@...libre.com>
To: Markus Schneider-Pargmann <msp@...libre.com>, Greg Kroah-Hartman
<gregkh@...uxfoundation.org>, Jiri Slaby <jirislaby@...nel.org>, Rob
Herring <robh@...nel.org>, Krzysztof Kozlowski
<krzysztof.kozlowski+dt@...aro.org>, Conor Dooley <conor+dt@...nel.org>,
Tony Lindgren <tony@...mide.com>, John Ogness <john.ogness@...utronix.de>,
Markus Schneider-Pargmann <msp@...libre.com>, Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>, Ronald Wahl <ronald.wahl@...itan.com>,
Thomas Richard <thomas.richard@...tlin.com>, Thomas Gleixner
<tglx@...utronix.de>, Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Arnd Bergmann <arnd@...db.de>, Vignesh Raghavendra <vigneshr@...com>
Cc: Vibhore Vardhan <vibhore@...com>, Dhruva Gole <d-gole@...com>,
linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org,
devicetree@...r.kernel.org
Subject: Re: [PATCH 4/5] serial: 8250: omap: Support wakeup pinctrl state
Markus Schneider-Pargmann <msp@...libre.com> writes:
> UART can be used as a wakeup source for am62 from a powered-off SoC
nit: To be a bit more precise, instead of saying UART can be used as a
wakeup source, I think you should say:
Certain UART pins can be used...
> state. 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 sys_off.
>
> Signed-off-by: Markus Schneider-Pargmann <msp@...libre.com>
Reviewed-by: Kevin Hilman <khilman@...libre.com>
> ---
> drivers/tty/serial/8250/8250_omap.c | 39 +++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
> index 5b7508dfb5d8..617a421a1396 100644
> --- a/drivers/tty/serial/8250/8250_omap.c
> +++ b/drivers/tty/serial/8250/8250_omap.c
> @@ -27,8 +27,10 @@
> #include <linux/pm_qos.h>
> #include <linux/pm_wakeirq.h>
> #include <linux/dma-mapping.h>
> +#include <linux/reboot.h>
> #include <linux/sys_soc.h>
> #include <linux/pm_domain.h>
> +#include <linux/pinctrl/consumer.h>
>
> #include "8250.h"
>
> @@ -149,6 +151,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 {
> @@ -1345,6 +1350,30 @@ 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 int omap8250_sysoff_handler(struct sys_off_data *data)
> +{
> + struct omap8250_priv *priv = dev_get_drvdata(data->dev);
> + int ret;
> +
> + ret = omap8250_select_wakeup_pinctrl(data->dev, priv);
> + if (ret)
> + dev_err(data->dev, "Failed to select pinctrl state 'wakeup', continuing poweroff\n");
> +
> + return NOTIFY_DONE;
> +}
> +
> static struct omap8250_dma_params am654_dma = {
> .rx_size = SZ_2K,
> .rx_trigger = 1,
> @@ -1566,6 +1595,16 @@ 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");
> +
> + devm_register_sys_off_handler(&pdev->dev,
> + SYS_OFF_MODE_POWER_OFF_PREPARE,
> + SYS_OFF_PRIO_DEFAULT,
> + omap8250_sysoff_handler, NULL);
> +
> return 0;
> err:
> pm_runtime_dont_use_autosuspend(&pdev->dev);
> --
> 2.43.0
Powered by blists - more mailing lists