Skip to content

Commit 7094832

Browse files
stephan-ghgregkh
authored andcommitted
serial: msm: Configure correct working mode before starting earlycon
The MSM UART DM controller supports different working modes, e.g. DMA or the "single-character mode", where all reads/writes operate on a single character rather than 4 chars (32-bit) at once. When using earlycon, __msm_console_write() always writes 4 characters at a time, but we don't know which mode the bootloader was using and we don't set the mode either. This causes garbled output if the bootloader was using the single-character mode, because only every 4th character appears in the serial console, e.g. "[ 00oni pi 000xf0[ 00i s 5rm9(l)l s 1 1 SPMTA 7:C 5[ 00A ade k d[ 00ano:ameoi .Q1B[ 00ac _idaM00080oo'" If the bootloader was using the DMA ("DM") mode, output would likely fail entirely. Later, when the full serial driver probes, the port is re-initialized and output works as expected. Fix this also for earlycon by clearing the DMEN register and reset+re-enable the transmitter to apply the change. This ensures the transmitter is in the expected state before writing any output. Cc: stable <stable@kernel.org> Fixes: 0efe729 ("tty: serial: msm: Add earlycon support") Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://lore.kernel.org/r/20250408-msm-serial-earlycon-v1-1-429080127530@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0af2f6b commit 7094832

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/tty/serial/msm_serial.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,12 @@ msm_serial_early_console_setup_dm(struct earlycon_device *device,
17461746
if (!device->port.membase)
17471747
return -ENODEV;
17481748

1749+
/* Disable DM / single-character modes */
1750+
msm_write(&device->port, 0, UARTDM_DMEN);
1751+
msm_write(&device->port, MSM_UART_CR_CMD_RESET_RX, MSM_UART_CR);
1752+
msm_write(&device->port, MSM_UART_CR_CMD_RESET_TX, MSM_UART_CR);
1753+
msm_write(&device->port, MSM_UART_CR_TX_ENABLE, MSM_UART_CR);
1754+
17491755
device->con->write = msm_serial_early_write_dm;
17501756
return 0;
17511757
}

0 commit comments

Comments
 (0)