diff mbox series

[v2,04/10] serial: 8250: dw: Allow to use a fallback CPR value if not synthesized

Message ID 20220317174627.360815-5-miquel.raynal@bootlin.com
State Superseded
Headers show
Series serial: 8250: dw: RZN1 DMA support | expand

Commit Message

Miquel Raynal March 17, 2022, 5:46 p.m. UTC
From: Phil Edworthy <phil.edworthy@renesas.com>

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

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

Comments

Andy Shevchenko March 18, 2022, 1:56 p.m. UTC | #1
On Thu, Mar 17, 2022 at 06:46:21PM +0100, Miquel Raynal wrote:
> From: Phil Edworthy <phil.edworthy@renesas.com>
> 
> DW UART controllers can be synthesized without the CPR register.
> In this case, allow to the platform information to provide a CPR value.

...

>  void dw8250_setup_port(struct uart_port *p)
>  {
>  	struct uart_8250_port *up = up_to_u8250p(p);
> +	const struct dw8250_platform_data *pdata = device_get_match_data(up->port.dev);

Why not p->dev?

...

>  	reg = dw8250_readl_ext(p, DW_UART_CPR);
> +	if (!reg && pdata)
> +		reg = pdata->cpr;

Perhaps

	if (!reg) {
		if (pdata)
			reg = pdata->cpr;
		dev_dbg("CPR is not available, using %x instead\n", reg);
	}

?

>  	if (!reg)
>  		return;
diff mbox series

Patch

diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c
index 622d3b0d89e7..cef20ca3ad61 100644
--- a/drivers/tty/serial/8250/8250_dwlib.c
+++ b/drivers/tty/serial/8250/8250_dwlib.c
@@ -5,6 +5,7 @@ 
 #include <linux/device.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/property.h>
 #include <linux/serial_8250.h>
 #include <linux/serial_core.h>
 
@@ -90,6 +91,7 @@  EXPORT_SYMBOL_GPL(dw8250_do_set_termios);
 void dw8250_setup_port(struct uart_port *p)
 {
 	struct uart_8250_port *up = up_to_u8250p(p);
+	const struct dw8250_platform_data *pdata = device_get_match_data(up->port.dev);
 	u32 reg;
 
 	/*
@@ -116,6 +118,8 @@  void dw8250_setup_port(struct uart_port *p)
 	}
 
 	reg = dw8250_readl_ext(p, DW_UART_CPR);
+	if (!reg && pdata)
+		reg = pdata->cpr;
 	if (!reg)
 		return;
 
diff --git a/drivers/tty/serial/8250/8250_dwlib.h b/drivers/tty/serial/8250/8250_dwlib.h
index 766f80799d13..704ba91ab09f 100644
--- a/drivers/tty/serial/8250/8250_dwlib.h
+++ b/drivers/tty/serial/8250/8250_dwlib.h
@@ -22,6 +22,7 @@  struct dw8250_port_data {
 
 struct dw8250_platform_data {
 	unsigned long quirks;
+	u32 cpr;
 };
 
 struct dw8250_data {