Skip to content

Commit 63d1bc1

Browse files
chleroygregkh
authored andcommitted
tty: serial: cpm_uart - fix init when SMC is relocated
[ Upstream commit 06aaa3d ] SMC relocation can also be activated earlier by the bootloader, so the driver's behaviour cannot rely on selected kernel config. When the SMC is relocated, CPM_CR_INIT_TRX cannot be used. But the only thing CPM_CR_INIT_TRX does is to clear the rstate and tstate registers, so this can be done manually, even when SMC is not relocated. Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Fixes: 9ab9212 ("cpm_uart: fix non-console port startup bug") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 345f195 commit 63d1bc1

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

drivers/tty/serial/cpm_uart/cpm_uart_core.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,16 @@ static int cpm_uart_startup(struct uart_port *port)
421421
clrbits16(&pinfo->sccp->scc_sccm, UART_SCCM_RX);
422422
}
423423
cpm_uart_initbd(pinfo);
424-
cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX);
424+
if (IS_SMC(pinfo)) {
425+
out_be32(&pinfo->smcup->smc_rstate, 0);
426+
out_be32(&pinfo->smcup->smc_tstate, 0);
427+
out_be16(&pinfo->smcup->smc_rbptr,
428+
in_be16(&pinfo->smcup->smc_rbase));
429+
out_be16(&pinfo->smcup->smc_tbptr,
430+
in_be16(&pinfo->smcup->smc_tbase));
431+
} else {
432+
cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX);
433+
}
425434
}
426435
/* Install interrupt handler. */
427436
retval = request_irq(port->irq, cpm_uart_int, 0, "cpm_uart", port);
@@ -875,16 +884,14 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo)
875884
(u8 __iomem *)pinfo->tx_bd_base - DPRAM_BASE);
876885

877886
/*
878-
* In case SMC1 is being relocated...
887+
* In case SMC is being relocated...
879888
*/
880-
#if defined (CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
881889
out_be16(&up->smc_rbptr, in_be16(&pinfo->smcup->smc_rbase));
882890
out_be16(&up->smc_tbptr, in_be16(&pinfo->smcup->smc_tbase));
883891
out_be32(&up->smc_rstate, 0);
884892
out_be32(&up->smc_tstate, 0);
885893
out_be16(&up->smc_brkcr, 1); /* number of break chars */
886894
out_be16(&up->smc_brkec, 0);
887-
#endif
888895

889896
/* Set up the uart parameters in the
890897
* parameter ram.
@@ -898,8 +905,6 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo)
898905
out_be16(&up->smc_brkec, 0);
899906
out_be16(&up->smc_brkcr, 1);
900907

901-
cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX);
902-
903908
/* Set UART mode, 8 bit, no parity, one stop.
904909
* Enable receive and transmit.
905910
*/

0 commit comments

Comments
 (0)