From 80b5ccf1922f4770369409064169b35243ac6a41 Mon Sep 17 00:00:00 2001 From: Flynn xu Date: Fri, 1 Mar 2019 17:59:31 -0500 Subject: [PATCH] MLK-21006 Driver: lpuart: Disable interrupts before request irq Commit b311ef1d549b ("MLK-20989: Driver: lpuart: reset registers before enable lpuart") breaks early console function, and the commit already was reverted. The reworked patch is to fix the issue correctly. This patch has been tested on i.MX8QM/QXP. change log: V1 -> V2: 1. Remove lock, since there is no race condition. Suggested-by: Peng Fan Signed-off-by: Flynn xu Signed-off-by: Arulpandiyan Vadivel Signed-off-by: Shrikant Bobade (cherry picked from commit 161f0144934fe917123c79eae6a7539806d1e04e) --- drivers/tty/serial/fsl_lpuart.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 3d91576c2fa0..12b8f4206a73 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -2398,6 +2398,8 @@ static int lpuart_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct lpuart_port *sport; struct resource *res; + unsigned long cr_32; + unsigned char cr_8; int ret; sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL); @@ -2471,6 +2473,17 @@ static int lpuart_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &sport->port); + /* Disable interrupts before request irq */ + if (lpuart_is_32(sport)) { + cr_32 = lpuart32_read(&sport->port, UARTCTRL); + cr_32 &= ~(UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE | UARTCTRL_ILIE); + lpuart32_write(&sport->port, cr_32, UARTCTRL); + } else { + cr_8 = readb(sport->port.membase + UARTCR2); + cr_8 &= ~(UARTCR2_TIE | UARTCR2_TCIE | UARTCR2_RIE | UARTCR2_ILIE); + writeb(cr_8, sport->port.membase + UARTCR2); + } + if (lpuart_is_32(sport)) { lpuart_reg.cons = LPUART32_CONSOLE; ret = devm_request_irq(&pdev->dev, sport->port.irq, lpuart32_int, 0, -- 2.17.1