From patchwork Thu Jul 9 16:12:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 1326047 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.a=rsa-sha256 header.s=dec2015msa header.b=J/oioPWf; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B2h6H3FYBz9s1x for ; Fri, 10 Jul 2020 02:12:55 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 08A1F82255; Thu, 9 Jul 2020 18:12:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="J/oioPWf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1ECF882247; Thu, 9 Jul 2020 18:12:42 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from conuserg-07.nifty.com (conuserg-07.nifty.com [210.131.2.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5A70282218 for ; Thu, 9 Jul 2020 18:12:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=yamada.masahiro@socionext.com Received: from oscar.flets-west.jp (softbank126090202047.bbtec.net [126.90.202.47]) (authenticated) by conuserg-07.nifty.com with ESMTP id 069GCH2P029258; Fri, 10 Jul 2020 01:12:17 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 069GCH2P029258 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1594311138; bh=hEL1n/bmXgfwreLn8uMHutLDwtg0cBqzt/PUygjV6Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J/oioPWfd+OLceKOZnggMdGsI4dkltjgpHcaMqEykL0dA9dKwlQC1Mwr1y7tXO/Wp oknjoDyeBYYEMoD8zsUNtF2H6Y40jroJPNiLkIIpsSbI+NIPeOC7PiwNWS6DTs0hex V1DN3TzwNEAbG758FyO4GVwejcqul/xBoxzxL7mBvn9qAo1nmd7NbPsIWpJXz3Ug7Y zlEsYdZR1QcVJqkBRLhCzfyO6V5FqnVIthJDj61ORdBExx326ak+uEumsv0ukgWeOw J26Q2wKiU+R/SN4/udMTzYJ3nb2HG95kpqEGfn/gU8n8G8Xe+Ys1416aPsm4t/3NuB LBD9vdGsXq47w== X-Nifty-SrcIP: [126.90.202.47] From: Masahiro Yamada To: u-boot@lists.denx.de Cc: Masahiro Yamada Subject: [PATCH 2/3] serial: uniphier: flush transmitter before changing hardware settings Date: Fri, 10 Jul 2020 01:12:07 +0900 Message-Id: <20200709161208.223814-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200709161208.223814-1-yamada.masahiro@socionext.com> References: <20200709161208.223814-1-yamada.masahiro@socionext.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Ensure the transmitter is empty when chaining the baudrate or any hardware settings. If a character is remaining in the transmitter, the console will be garbled. Signed-off-by: Masahiro Yamada --- drivers/serial/serial_uniphier.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c index 2ffab004bd..aaf8657ee1 100644 --- a/drivers/serial/serial_uniphier.c +++ b/drivers/serial/serial_uniphier.c @@ -43,6 +43,10 @@ static int uniphier_serial_setbrg(struct udevice *dev, int baudrate) divisor = DIV_ROUND_CLOSEST(priv->uartclk, mode_x_div * baudrate); + /* flush the trasmitter before changing hw setting */ + while (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_TEMT)) + ; + writel(divisor, priv->membase + UNIPHIER_UART_DLR); return 0; @@ -132,6 +136,10 @@ static int uniphier_serial_probe(struct udevice *dev) priv->uartclk = clk_data->clk_rate; + /* flush the trasmitter empty before changing hw setting */ + while (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_TEMT)) + ; + tmp = readl(priv->membase + UNIPHIER_UART_LCR_MCR); tmp &= ~UNIPHIER_UART_LCR_MASK; tmp |= FIELD_PREP(UNIPHIER_UART_LCR_MASK, UART_LCR_WLEN8);