From patchwork Sun Oct 2 21:52:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 4466 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 342C323F57 for ; Sun, 2 Oct 2011 21:52:58 +0000 (UTC) Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 18969A18146 for ; Sun, 2 Oct 2011 21:52:58 +0000 (UTC) Received: by bke5 with SMTP id 5so6151561bke.11 for ; Sun, 02 Oct 2011 14:52:57 -0700 (PDT) Received: by 10.223.26.26 with SMTP id b26mr5015691fac.122.1317592377699; Sun, 02 Oct 2011 14:52:57 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.3.234 with SMTP id f10cs30798laf; Sun, 2 Oct 2011 14:52:56 -0700 (PDT) Received: by 10.204.153.202 with SMTP id l10mr1401450bkw.245.1317592376375; Sun, 02 Oct 2011 14:52:56 -0700 (PDT) Received: from mail.df.lth.se (mail.df.lth.se. [194.47.250.12]) by mx.google.com with ESMTPS id b9si6363203bke.42.2011.10.02.14.52.55 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 02 Oct 2011 14:52:56 -0700 (PDT) Received-SPF: pass (google.com: domain of triad@df.lth.se designates 194.47.250.12 as permitted sender) client-ip=194.47.250.12; Authentication-Results: mx.google.com; spf=pass (google.com: domain of triad@df.lth.se designates 194.47.250.12 as permitted sender) smtp.mail=triad@df.lth.se Received: from mer.df.lth.se (mer.df.lth.se [194.47.250.37]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.df.lth.se (Postfix) with ESMTPS id 2283665DA6; Sun, 2 Oct 2011 23:52:55 +0200 (CEST) Received: from mer.df.lth.se (triad@localhost.localdomain [127.0.0.1]) by mer.df.lth.se (8.14.3/8.14.3/Debian-9.4) with ESMTP id p92Lqsa3032311; Sun, 2 Oct 2011 23:52:54 +0200 Received: (from triad@localhost) by mer.df.lth.se (8.14.3/8.14.3/Submit) id p92Lqskx032310; Sun, 2 Oct 2011 23:52:54 +0200 From: Linus Walleij To: U-Boot@lists.denx.de Cc: Linus Walleij Subject: [PATCH] serial: pl01x: drain PL01x FIFO before baudrate change Date: Sun, 2 Oct 2011 23:52:52 +0200 Message-Id: <1317592372-32283-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.7.2.5 Not draining the FIFO and waiting for the UART to be non-busy before changing baudrate results in crap characters on the console, so let's wait for the FIFO to drain and the last character to be clocked out before we do that. Signed-off-by: Linus Walleij --- drivers/serial/serial_pl01x.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 7a064ff..ed581ae 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -194,7 +194,17 @@ int serial_tstc (void) void serial_setbrg (void) { + struct pl01x_regs *regs = pl01x_get_regs(CONSOLE_PORT); + baudrate = gd->baudrate; + /* + * Flush FIFO and wait for non-busy before changing baudrate to avoid + * crap in console + */ + while (!(readl(®s->fr) & UART_PL01x_FR_TXFE)) + WATCHDOG_RESET(); + while (readl(®s->fr) & UART_PL01x_FR_BUSY) + WATCHDOG_RESET(); serial_init(); }