From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AE4A24C080; Thu, 3 Apr 2025 15:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743693924; cv=none; b=HOMYmPLOFQG3bD8c5jgExhcY7dI1XpfKTbn3KSUtbfCNlXra8P2oVVt6Rgz+1bSSoY7aDRpQeYwIG6YKiLEuwdK5acIjhoA4VbKEiHq92TqGen7o/fRODfCsUfQbw7xzRMslNJQvTlP2RKiXM8rVwkMJYB2WZ8Lgw3+Zf3v9ofU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743693924; c=relaxed/simple; bh=uBjQgKlH50tOsrxR54PW1lQVI23OLHyjZ8J7gFsDVGk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BhDNmNaZOp7hLq+uPJxLMO+yfsFPaDGgHqr3iG6XounnMHPGG6UygJzWuop1DS0gTSgC7d4WvemdYiTwi8CjKKRce4w/afdumm1KuWEKEqZFmJydj7wzR4kg4LVbwQx1YQyice1yxEngugXEbhJbWBi+G25ZNE17Feu3J6UEphQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eopB/ODI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eopB/ODI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B13BBC4CEE3; Thu, 3 Apr 2025 15:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1743693924; bh=uBjQgKlH50tOsrxR54PW1lQVI23OLHyjZ8J7gFsDVGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eopB/ODI82n+dPVyHxkh5pOxB0X7tgV4T8c+4K3YvKQ+xZm130J+8dBaW6xu+3zJv TQHaAbftqRm9t5A9d/3M6iJjDdwN2CJw8JfLzUZylfrVQl1aMVHI4wlvIDMiowZSV8 146Bx9JS3M7uWAfQ47ieh+Uo2k4G4uHzN+LV8/o8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Sherry Sun , Frank Li Subject: [PATCH 6.13 13/23] tty: serial: fsl_lpuart: disable transmitter before changing RS485 related registers Date: Thu, 3 Apr 2025 16:20:30 +0100 Message-ID: <20250403151622.656287194@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250403151622.273788569@linuxfoundation.org> References: <20250403151622.273788569@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sherry Sun commit f5cb528d6441eb860250a2f085773aac4f44085e upstream. According to the LPUART reference manual, TXRTSE and TXRTSPOL of MODIR register only can be changed when the transmitter is disabled. So disable the transmitter before changing RS485 related registers and re-enable it after the change is done. Fixes: 67b01837861c ("tty: serial: lpuart: Add RS485 support for 32-bit uart flavour") Cc: stable Signed-off-by: Sherry Sun Reviewed-by: Frank Li Link: https://lore.kernel.org/r/20250312022503.1342990-1-sherry.sun@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/fsl_lpuart.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1484,6 +1484,19 @@ static int lpuart32_config_rs485(struct unsigned long modem = lpuart32_read(&sport->port, UARTMODIR) & ~(UARTMODIR_TXRTSPOL | UARTMODIR_TXRTSE); + u32 ctrl; + + /* TXRTSE and TXRTSPOL only can be changed when transmitter is disabled. */ + ctrl = lpuart32_read(&sport->port, UARTCTRL); + if (ctrl & UARTCTRL_TE) { + /* wait for the transmit engine to complete */ + lpuart32_wait_bit_set(&sport->port, UARTSTAT, UARTSTAT_TC); + lpuart32_write(&sport->port, ctrl & ~UARTCTRL_TE, UARTCTRL); + + while (lpuart32_read(&sport->port, UARTCTRL) & UARTCTRL_TE) + cpu_relax(); + } + lpuart32_write(&sport->port, modem, UARTMODIR); if (rs485->flags & SER_RS485_ENABLED) { @@ -1503,6 +1516,10 @@ static int lpuart32_config_rs485(struct } lpuart32_write(&sport->port, modem, UARTMODIR); + + if (ctrl & UARTCTRL_TE) + lpuart32_write(&sport->port, ctrl, UARTCTRL); + return 0; }