Skip to content

Commit 3ff1070

Browse files
andy-shevgregkh
authored andcommitted
serial: 8250_dw: Introduce IO accessors to extended registers
There are several extended (in comparison to the traditional 16550) registers are present in Synopsys DesignWare UART. All of them are 32-bit ones. Introduce helpers to simplify access to them and convert existing users. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 447735f commit 3ff1070

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

drivers/tty/serial/8250/8250_dw.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@ struct dw8250_data {
6767
unsigned int uart_16550_compatible:1;
6868
};
6969

70+
static inline u32 dw8250_readl_ext(struct uart_port *p, int offset)
71+
{
72+
if (p->iotype == UPIO_MEM32BE)
73+
return ioread32be(p->membase + offset);
74+
return readl(p->membase + offset);
75+
}
76+
77+
static inline void dw8250_writel_ext(struct uart_port *p, int offset, u32 reg)
78+
{
79+
if (p->iotype == UPIO_MEM32BE)
80+
iowrite32be(reg, p->membase + offset);
81+
else
82+
writel(reg, p->membase + offset);
83+
}
84+
7085
static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value)
7186
{
7287
struct dw8250_data *d = p->private_data;
@@ -404,20 +419,14 @@ static void dw8250_setup_port(struct uart_port *p)
404419
* If the Component Version Register returns zero, we know that
405420
* ADDITIONAL_FEATURES are not enabled. No need to go any further.
406421
*/
407-
if (p->iotype == UPIO_MEM32BE)
408-
reg = ioread32be(p->membase + DW_UART_UCV);
409-
else
410-
reg = readl(p->membase + DW_UART_UCV);
422+
reg = dw8250_readl_ext(p, DW_UART_UCV);
411423
if (!reg)
412424
return;
413425

414426
dev_dbg(p->dev, "Designware UART version %c.%c%c\n",
415427
(reg >> 24) & 0xff, (reg >> 16) & 0xff, (reg >> 8) & 0xff);
416428

417-
if (p->iotype == UPIO_MEM32BE)
418-
reg = ioread32be(p->membase + DW_UART_CPR);
419-
else
420-
reg = readl(p->membase + DW_UART_CPR);
429+
reg = dw8250_readl_ext(p, DW_UART_CPR);
421430
if (!reg)
422431
return;
423432

0 commit comments

Comments
 (0)