From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Kumaravel Thiagarajan <kumaravel.thiagarajan@microchip.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
andy.shevchenko@gmail.com, u.kleine-koenig@pengutronix.de,
johan@kernel.org, wander@redhat.com,
etremblay@distech-controls.com, macro@orcam.me.uk,
geert+renesas@glider.be, jk@ozlabs.org,
phil.edworthy@renesas.com, Lukas Wunner <lukas@wunner.de>,
LKML <linux-kernel@vger.kernel.org>,
linux-serial <linux-serial@vger.kernel.org>,
UNGLinuxDriver@microchip.com
Subject: Re: [PATCH v2 tty-next 3/3] 8250: microchip: pci1xxxx: Add power management functions to quad-uart driver.
Date: Mon, 3 Oct 2022 12:51:23 +0300 (EEST) [thread overview]
Message-ID: <7892467b-c2de-c62-e977-62761dc5cbb@linux.intel.com> (raw)
In-Reply-To: <20221001061507.3508603-4-kumaravel.thiagarajan@microchip.com>
On Sat, 1 Oct 2022, Kumaravel Thiagarajan wrote:
> pci1xxxx's quad-uart function has the capability to wake up the host from
> suspend state. Enable wakeup before entering into suspend and disable
> wakeup on resume.
>
> Signed-off-by: Kumaravel Thiagarajan <kumaravel.thiagarajan@microchip.com>
> ---
> Changes in v2:
> - Use DEFINE_SIMPLE_DEV_PM_OPS instead of SIMPLE_DEV_PM_OPS.
> - Use pm_sleep_ptr instead of CONFIG_PM_SLEEP.
> - Change the return data type of pci1xxxx_port_suspend to bool from int.
> ---
> drivers/tty/serial/8250/8250_pci1xxxx.c | 112 ++++++++++++++++++++++++
> 1 file changed, 112 insertions(+)
>
> diff --git a/drivers/tty/serial/8250/8250_pci1xxxx.c b/drivers/tty/serial/8250/8250_pci1xxxx.c
> index 999e5a284266..0a0459f66177 100644
> --- a/drivers/tty/serial/8250/8250_pci1xxxx.c
> +++ b/drivers/tty/serial/8250/8250_pci1xxxx.c
> @@ -352,6 +352,112 @@ static void pci1xxxx_irq_assign(struct pci1xxxx_8250 *priv,
> }
> }
>
> +static bool pci1xxxx_port_suspend(int line)
> +{
> + struct uart_8250_port *up = serial8250_get_port(line);
> + struct uart_port *port = &up->port;
> + unsigned long flags;
> + u8 wakeup_mask;
> + bool ret = false;
> +
> + if (port->suspended == 0 && port->dev) {
> + wakeup_mask = readb(up->port.membase + UART_WAKE_MASK_REG);
> +
> + spin_lock_irqsave(&port->lock, flags);
> + port->mctrl &= ~TIOCM_OUT2;
> + port->ops->set_mctrl(port, port->mctrl);
> + spin_unlock_irqrestore(&port->lock, flags);
> +
> + if ((wakeup_mask & UART_WAKE_SRCS) != UART_WAKE_SRCS)
> + ret = true;
> + }
> +
> + writeb(UART_WAKE_SRCS, port->membase + UART_WAKE_REG);
> +
> + return ret;
> +}
> +
> +static void pci1xxxx_port_resume(int line)
> +{
> + struct uart_8250_port *up = serial8250_get_port(line);
> + struct uart_port *port = &up->port;
> + unsigned long flags;
> +
> + writeb(UART_WAKE_SRCS, port->membase + UART_WAKE_REG);
> +
> + if (port->suspended == 0) {
Is this check the right way around?
> + spin_lock_irqsave(&port->lock, flags);
> + port->mctrl |= TIOCM_OUT2;
> + port->ops->set_mctrl(port, port->mctrl);
> + spin_unlock_irqrestore(&port->lock, flags);
> + }
> +}
> +
> +static int pci1xxxx_suspend(struct device *dev)
> +{
> + struct pci1xxxx_8250 *priv = dev_get_drvdata(dev);
> + struct pci_dev *pcidev = to_pci_dev(dev);
> + unsigned int data;
> + void __iomem *p;
> + bool wakeup = false;
> + int i;
> +
> + for (i = 0; i < priv->nr; i++) {
> + if (priv->line[i] >= 0) {
> + serial8250_suspend_port(priv->line[i]);
> + wakeup |= pci1xxxx_port_suspend(priv->line[i]);
So first serial8250_suspend_port() calls into uart_suspend_port() that
sets port->suspended to 1, then pci1xxxx_port_suspend() checks if it's 0.
Is this intentional?
--
i.
next prev parent reply other threads:[~2022-10-03 9:51 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-01 6:15 [PATCH v2 tty-next 0/3] 8250: microchip: pci1xxxx: Add driver for the pci1xxxx's quad-uart function Kumaravel Thiagarajan
2022-10-01 6:15 ` [PATCH v2 tty-next 1/3] 8250: microchip: pci1xxxx: Add driver for quad-uart support Kumaravel Thiagarajan
2022-10-03 9:18 ` Ilpo Järvinen
2022-10-03 9:22 ` Andy Shevchenko
2022-10-05 9:51 ` Kumaravel.Thiagarajan
2022-10-26 10:54 ` Tharunkumar.Pasumarthi
2022-10-31 9:24 ` Tharunkumar.Pasumarthi
2022-10-31 14:37 ` Andy Shevchenko
2022-11-01 15:04 ` Tharunkumar.Pasumarthi
2022-11-01 15:17 ` Andy Shevchenko
2022-11-01 17:54 ` Kumaravel.Thiagarajan
2022-10-03 19:36 ` Christophe JAILLET
2022-10-04 9:46 ` Andy Shevchenko
2022-10-26 11:12 ` Tharunkumar.Pasumarthi
2022-10-26 20:10 ` Christophe JAILLET
2022-10-01 6:15 ` [PATCH v2 tty-next 2/3] 8250: microchip: pci1xxxx: Add rs485 support to quad-uart driver Kumaravel Thiagarajan
2022-10-03 9:04 ` Ilpo Järvinen
2022-11-01 14:53 ` Tharunkumar.Pasumarthi
2022-11-01 15:25 ` Ilpo Järvinen
2022-11-01 15:35 ` Andy Shevchenko
2022-11-01 15:49 ` Ilpo Järvinen
2022-11-01 18:10 ` Tharunkumar.Pasumarthi
2022-10-03 9:20 ` Ilpo Järvinen
2022-10-04 17:51 ` Kumaravel.Thiagarajan
2022-10-05 9:43 ` Ilpo Järvinen
2022-10-01 6:15 ` [PATCH v2 tty-next 3/3] 8250: microchip: pci1xxxx: Add power management functions " Kumaravel Thiagarajan
2022-10-03 9:26 ` Andy Shevchenko
2022-10-04 17:20 ` Kumaravel.Thiagarajan
2022-10-26 11:03 ` Tharunkumar.Pasumarthi
2022-10-31 9:41 ` Tharunkumar.Pasumarthi
2022-11-04 10:23 ` Tharunkumar.Pasumarthi
2022-11-04 12:50 ` Andy Shevchenko
2022-10-03 9:51 ` Ilpo Järvinen [this message]
2022-10-04 19:01 ` Kumaravel.Thiagarajan
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=7892467b-c2de-c62-e977-62761dc5cbb@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andy.shevchenko@gmail.com \
--cc=etremblay@distech-controls.com \
--cc=geert+renesas@glider.be \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=jk@ozlabs.org \
--cc=johan@kernel.org \
--cc=kumaravel.thiagarajan@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=macro@orcam.me.uk \
--cc=phil.edworthy@renesas.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wander@redhat.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