Skip to content

Commit 535fd4c

Browse files
hvilleneuvedoogregkh
authored andcommitted
serial: sc16is7xx: fix bug in flow control levels init
When trying to set MCR[2], XON1 is incorrectly accessed instead. And when writing to the TCR register to configure flow control levels, we are incorrectly writing to the MSR register. The default value of $00 is then used for TCR, which means that selectable trigger levels in FCR are used in place of TCR. TCR/TLR access requires EFR[4] (enable enhanced functions) and MCR[2] to be set. EFR[4] is already set in probe(). MCR access requires LCR[7] to be zero. Since LCR is set to $BF when trying to set MCR[2], XON1 is incorrectly accessed instead because MCR shares the same address space as XON1. Since MCR[2] is unmodified and still zero, when writing to TCR we are in fact writing to MSR because TCR/TLR registers share the same address space as MSR/SPR. Fix by first removing useless reconfiguration of EFR[4] (enable enhanced functions), as it is already enabled in sc16is7xx_probe() since commit 43c51bb ("sc16is7xx: make sure device is in suspend once probed"). Now LCR is $00, which means that MCR access is enabled. Also remove regcache_cache_bypass() calls since we no longer access the enhanced registers set, and TCR is already declared as volatile (in fact by declaring MSR as volatile, which shares the same address). Finally disable access to TCR/TLR registers after modifying them by clearing MCR[2]. Note: the comment about "... and internal clock div" is wrong and can be ignored/removed as access to internal clock div registers (DLL/DLH) is permitted only when LCR[7] is logic 1, not when enhanced features is enabled. And DLL/DLH access is not needed in sc16is7xx_startup(). Fixes: dfeae61 ("serial: sc16is7xx") Cc: [email protected] Signed-off-by: Hugo Villeneuve <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8f5ae30 commit 535fd4c

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

drivers/tty/serial/sc16is7xx.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,17 +1177,6 @@ static int sc16is7xx_startup(struct uart_port *port)
11771177
sc16is7xx_port_write(port, SC16IS7XX_FCR_REG,
11781178
SC16IS7XX_FCR_FIFO_BIT);
11791179

1180-
/* Enable EFR */
1181-
sc16is7xx_port_write(port, SC16IS7XX_LCR_REG,
1182-
SC16IS7XX_LCR_CONF_MODE_B);
1183-
1184-
regcache_cache_bypass(one->regmap, true);
1185-
1186-
/* Enable write access to enhanced features and internal clock div */
1187-
sc16is7xx_port_update(port, SC16IS7XX_EFR_REG,
1188-
SC16IS7XX_EFR_ENABLE_BIT,
1189-
SC16IS7XX_EFR_ENABLE_BIT);
1190-
11911180
/* Enable TCR/TLR */
11921181
sc16is7xx_port_update(port, SC16IS7XX_MCR_REG,
11931182
SC16IS7XX_MCR_TCRTLR_BIT,
@@ -1199,7 +1188,8 @@ static int sc16is7xx_startup(struct uart_port *port)
11991188
SC16IS7XX_TCR_RX_RESUME(24) |
12001189
SC16IS7XX_TCR_RX_HALT(48));
12011190

1202-
regcache_cache_bypass(one->regmap, false);
1191+
/* Disable TCR/TLR access */
1192+
sc16is7xx_port_update(port, SC16IS7XX_MCR_REG, SC16IS7XX_MCR_TCRTLR_BIT, 0);
12031193

12041194
/* Now, initialize the UART */
12051195
sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, SC16IS7XX_LCR_WORD_LEN_8);

0 commit comments

Comments
 (0)