Skip to content

Commit bb0b197

Browse files
AngeloGioacchino Del Regnogregkh
authored andcommitted
serial: 8250_mtk: Fix UART_EFR register address
On MediaTek SoCs, the UART IP is 16550A compatible, but there are some specific quirks: we are declaring a register shift of 2, but this is only valid for the majority of the registers, as there are some that are out of the standard layout. Specifically, this driver is using definitions from serial_reg.h, where we have a UART_EFR register defined as 2: this results in a 0x8 offset, but there we have the FCR register instead. The right offset for the EFR register on MediaTek UART is at 0x98, so, following the decimal definition convention in serial_reg.h and accounting for the register left shift of two, add and use the correct register address for this IP, defined as decimal 38, so that the final calculation results in (0x26 << 2) = 0x98. Fixes: bdbd0a7 ("serial: 8250-mtk: modify baudrate setting") Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 447ee15 commit bb0b197

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/tty/serial/8250/8250_mtk.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#define MTK_UART_IER_RTSI 0x40 /* Enable RTS Modem status interrupt */
3838
#define MTK_UART_IER_CTSI 0x80 /* Enable CTS Modem status interrupt */
3939

40+
#define MTK_UART_EFR 38 /* I/O: Extended Features Register */
4041
#define MTK_UART_EFR_EN 0x10 /* Enable enhancement feature */
4142
#define MTK_UART_EFR_RTS 0x40 /* Enable hardware rx flow control */
4243
#define MTK_UART_EFR_CTS 0x80 /* Enable hardware tx flow control */
@@ -169,7 +170,7 @@ static void mtk8250_dma_enable(struct uart_8250_port *up)
169170
MTK_UART_DMA_EN_RX | MTK_UART_DMA_EN_TX);
170171

171172
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
172-
serial_out(up, UART_EFR, UART_EFR_ECB);
173+
serial_out(up, MTK_UART_EFR, UART_EFR_ECB);
173174
serial_out(up, UART_LCR, lcr);
174175

175176
if (dmaengine_slave_config(dma->rxchan, &dma->rxconf) != 0)
@@ -232,7 +233,7 @@ static void mtk8250_set_flow_ctrl(struct uart_8250_port *up, int mode)
232233
int lcr = serial_in(up, UART_LCR);
233234

234235
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
235-
serial_out(up, UART_EFR, UART_EFR_ECB);
236+
serial_out(up, MTK_UART_EFR, UART_EFR_ECB);
236237
serial_out(up, UART_LCR, lcr);
237238
lcr = serial_in(up, UART_LCR);
238239

@@ -241,7 +242,7 @@ static void mtk8250_set_flow_ctrl(struct uart_8250_port *up, int mode)
241242
serial_out(up, MTK_UART_ESCAPE_DAT, MTK_UART_ESCAPE_CHAR);
242243
serial_out(up, MTK_UART_ESCAPE_EN, 0x00);
243244
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
244-
serial_out(up, UART_EFR, serial_in(up, UART_EFR) &
245+
serial_out(up, MTK_UART_EFR, serial_in(up, MTK_UART_EFR) &
245246
(~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK)));
246247
serial_out(up, UART_LCR, lcr);
247248
mtk8250_disable_intrs(up, MTK_UART_IER_XOFFI |
@@ -255,8 +256,8 @@ static void mtk8250_set_flow_ctrl(struct uart_8250_port *up, int mode)
255256
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
256257

257258
/*enable hw flow control*/
258-
serial_out(up, UART_EFR, MTK_UART_EFR_HW_FC |
259-
(serial_in(up, UART_EFR) &
259+
serial_out(up, MTK_UART_EFR, MTK_UART_EFR_HW_FC |
260+
(serial_in(up, MTK_UART_EFR) &
260261
(~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK))));
261262

262263
serial_out(up, UART_LCR, lcr);
@@ -270,8 +271,8 @@ static void mtk8250_set_flow_ctrl(struct uart_8250_port *up, int mode)
270271
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
271272

272273
/*enable sw flow control */
273-
serial_out(up, UART_EFR, MTK_UART_EFR_XON1_XOFF1 |
274-
(serial_in(up, UART_EFR) &
274+
serial_out(up, MTK_UART_EFR, MTK_UART_EFR_XON1_XOFF1 |
275+
(serial_in(up, MTK_UART_EFR) &
275276
(~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK))));
276277

277278
serial_out(up, UART_XON1, START_CHAR(port->state->port.tty));

0 commit comments

Comments
 (0)