All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-renesas-soc@vger.kernel.org, linux-serial@vger.kernel.org,
	Milan Stevanovic <milan.stevanovic@se.com>,
	Jimmy Lalande <jimmy.lalande@se.com>,
	Pascal Eberhard <pascal.eberhard@se.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Herve Codina <herve.codina@bootlin.com>,
	Clement Leger <clement.leger@bootlin.com>,
	Ilpo Jarvinen <ilpo.jarvinen@linux.intel.com>,
	Phil Edworthy <phil.edworthy@renesas.com>
Subject: [PATCH v5 05/11] serial: 8250: dw: Allow to use a fallback CPR value if not synthesized
Date: Wed, 13 Apr 2022 09:51:35 +0200	[thread overview]
Message-ID: <20220413075141.72777-6-miquel.raynal@bootlin.com> (raw)
In-Reply-To: <20220413075141.72777-1-miquel.raynal@bootlin.com>

DW UART controllers can be synthesized without the CPR register.
In this case, allow to the platform information to provide a CPR value.

Co-developed-by: Phil Edworthy <phil.edworthy@renesas.com>
Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/tty/serial/8250/8250_dwlib.c | 10 +++++++---
 drivers/tty/serial/8250/8250_dwlib.h |  1 +
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c
index 622d3b0d89e7..22154b5848d5 100644
--- a/drivers/tty/serial/8250/8250_dwlib.c
+++ b/drivers/tty/serial/8250/8250_dwlib.c
@@ -89,6 +89,8 @@ EXPORT_SYMBOL_GPL(dw8250_do_set_termios);
 
 void dw8250_setup_port(struct uart_port *p)
 {
+	struct dw8250_port_data *pd = p->private_data;
+	struct dw8250_data *data = to_dw8250_data(pd);
 	struct uart_8250_port *up = up_to_u8250p(p);
 	u32 reg;
 
@@ -108,14 +110,16 @@ void dw8250_setup_port(struct uart_port *p)
 	dw8250_writel_ext(p, DW_UART_DLF, 0);
 
 	if (reg) {
-		struct dw8250_port_data *d = p->private_data;
-
-		d->dlf_size = fls(reg);
+		pd->dlf_size = fls(reg);
 		p->get_divisor = dw8250_get_divisor;
 		p->set_divisor = dw8250_set_divisor;
 	}
 
 	reg = dw8250_readl_ext(p, DW_UART_CPR);
+	if (!reg) {
+		reg = data->pdata->cpr;
+		dev_dbg(p->dev, "CPR is not available, using 0x%08x instead\n", reg);
+	}
 	if (!reg)
 		return;
 
diff --git a/drivers/tty/serial/8250/8250_dwlib.h b/drivers/tty/serial/8250/8250_dwlib.h
index 0df6baa6eaee..412f4e83e0b3 100644
--- a/drivers/tty/serial/8250/8250_dwlib.h
+++ b/drivers/tty/serial/8250/8250_dwlib.h
@@ -24,6 +24,7 @@ struct dw8250_port_data {
 struct dw8250_platform_data {
 	u8 usr_reg;
 	unsigned int quirks;
+	u32 cpr;
 };
 
 struct dw8250_data {
-- 
2.27.0


  parent reply	other threads:[~2022-04-13  7:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13  7:51 [PATCH v5 00/11] serial: 8250: dw: RZN1 DMA support Miquel Raynal
2022-04-13  7:51 ` [PATCH v5 01/11] serial: 8250: dw: Move definitions to the shared header Miquel Raynal
2022-04-13  7:51 ` [PATCH v5 02/11] serial: 8250: dw: Use the device API Miquel Raynal
2022-04-13  7:51 ` [PATCH v5 03/11] serial: 8250: dw: Create a more generic platform data structure Miquel Raynal
2022-04-13  7:51 ` [PATCH v5 04/11] serial: 8250: dw: Move the USR register to pdata Miquel Raynal
2022-04-13 10:50   ` Andy Shevchenko
2022-04-13  7:51 ` Miquel Raynal [this message]
2022-04-13 10:53   ` [PATCH v5 05/11] serial: 8250: dw: Allow to use a fallback CPR value if not synthesized Andy Shevchenko
2022-04-13  7:51 ` [PATCH v5 06/11] serial: 8250: dma: Allow driver operations before starting DMA transfers Miquel Raynal
2022-04-13  7:51 ` [PATCH v5 07/11] serial: 8250: dw: Introduce an rx_timeout variable in the IRQ path Miquel Raynal
2022-04-13  7:51 ` [PATCH v5 08/11] serial: 8250: dw: Move the IO accessors to 8250_dwlib.h Miquel Raynal
2022-04-13 10:55   ` Andy Shevchenko
2022-04-13  7:51 ` [PATCH v5 09/11] serial: 8250: dw: Add support for DMA flow controlling devices Miquel Raynal
2022-04-13 10:58   ` Andy Shevchenko
2022-04-13  7:51 ` [PATCH v5 10/11] serial: 8250: dw: Improve RZN1 support Miquel Raynal
2022-04-13  7:51 ` [PATCH v5 11/11] ARM: dts: r9a06g032: Fill the UART DMA properties Miquel Raynal
2022-04-15  9:36 ` [PATCH v5 00/11] serial: 8250: dw: RZN1 DMA support Greg Kroah-Hartman
2022-04-20  8:56   ` Miquel Raynal
2022-04-21  9:30     ` Miquel Raynal

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=20220413075141.72777-6-miquel.raynal@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=clement.leger@bootlin.com \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=herve.codina@bootlin.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jimmy.lalande@se.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=milan.stevanovic@se.com \
    --cc=pascal.eberhard@se.com \
    --cc=phil.edworthy@renesas.com \
    --cc=thomas.petazzoni@bootlin.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.