[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN8PR11MB3668D24337821FDE00FE7BB2E97A9@BN8PR11MB3668.namprd11.prod.outlook.com>
Date: Fri, 2 Sep 2022 02:20:18 +0000
From: <Kumaravel.Thiagarajan@...rochip.com>
To: <ilpo.jarvinen@...ux.intel.com>
CC: <gregkh@...uxfoundation.org>, <jirislaby@...nel.org>,
<andy.shevchenko@...il.com>, <u.kleine-koenig@...gutronix.de>,
<johan@...nel.org>, <wander@...hat.com>,
<etremblay@...tech-controls.com>, <macro@...am.me.uk>,
<geert+renesas@...der.be>, <jk@...abs.org>,
<phil.edworthy@...esas.com>, <lukas@...ner.de>,
<linux-kernel@...r.kernel.org>, <linux-serial@...r.kernel.org>,
<UNGLinuxDriver@...rochip.com>
Subject: RE: [PATCH v1 tty-next 2/2] 8250: microchip: pci1xxxx: Add power
management functions to pci1xxxx's quad-uart driver.
> -----Original Message-----
> From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> Sent: Wednesday, August 31, 2022 3:24 PM
> To: Kumaravel Thiagarajan - I21417 <Kumaravel.Thiagarajan@...rochip.com>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>; Jiri Slaby
> <jirislaby@...nel.org>; andy.shevchenko@...il.com; u.kleine-
> koenig@...gutronix.de; johan@...nel.org; wander@...hat.com;
> etremblay@...tech-controls.com; macro@...am.me.uk;
> geert+renesas@...der.be; jk@...abs.org; phil.edworthy@...esas.com;
> Lukas Wunner <lukas@...ner.de>; LKML <linux-kernel@...r.kernel.org>;
> linux-serial <linux-serial@...r.kernel.org>; UNGLinuxDriver
> <UNGLinuxDriver@...rochip.com>
> Subject: Re: [PATCH v1 tty-next 2/2] 8250: microchip: pci1xxxx: Add power
> management functions to pci1xxxx's quad-uart driver.
>
>
> On Tue, 30 Aug 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 upon resume.
> >
> > Signed-off-by: Kumaravel Thiagarajan
> > <kumaravel.thiagarajan@...rochip.com>
> > ---
> > drivers/tty/serial/8250/8250_pci1xxxx.c | 122
> > ++++++++++++++++++++++++
> > 1 file changed, 122 insertions(+)
> >
> > diff --git a/drivers/tty/serial/8250/8250_pci1xxxx.c
> > b/drivers/tty/serial/8250/8250_pci1xxxx.c
> > index 56852ae0585e..38c2a6a9e5d5 100644
> > --- a/drivers/tty/serial/8250/8250_pci1xxxx.c
> > +++ b/drivers/tty/serial/8250/8250_pci1xxxx.c
> > @@ -70,6 +70,7 @@
> >
> > #define UART_PCI_CTRL_REG 0x80
> > #define UART_PCI_CTRL_SET_MULTIPLE_MSI BIT(4)
> > +#define UART_PCI_CTRL_D3_CLK_ENABLE BIT(0)
>
> Reorder.
I have ordered this like - Register offset followed by individual bits from MSB to LSB.
Should I reorder this based on some other criteria?
>
> > +static char pci1xxxx_port_suspend(int line)
>
> Why char???
I will modify this to bool.
>
> > +{
> > + struct uart_8250_port *up = serial8250_get_port(line);
> > + struct uart_port *port = &up->port;
> > + unsigned long flags;
> > + u8 wakeup_mask;
> > + char ret = 0;
> > +
> > + 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 = 0x01;
> > + else
> > + ret = 0x00;
>
> Is it a bool or should you name these it with a #define?
bool is the correct data type. I will fix this.
>
> > + }
> > +
> > + writeb(UART_WAKE_SRCS, port->membase + UART_WAKE_REG);
> > +
> > + return ret;
> > +}
> > +
> > +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) {
> > + 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;
> > + char wakeup = 0;
> > + 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]);
> > + }
> > + }
> > +
> > + p = pci_ioremap_bar(pcidev, 0);
> > + if (!p) {
> > + dev_err(dev, "remapping of bar 0 memory failed");
> > + return -ENOMEM;
> > + }
> > +
> > + data = readl(p + UART_RESET_REG);
> > + writel(data | UART_RESET_D3_RESET_DISABLE, p + UART_RESET_REG);
> > +
> > + if (wakeup)
>
> It looks you'd want bool instead of char here.
Yes. I will modify this to bool.
Thank You.
Regards,
Kumaravel
Powered by blists - more mailing lists