From patchwork Wed Sep 26 08:50:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 11730 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 CB75B23EFF for ; Wed, 26 Sep 2012 08:51:01 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 68280A18870 for ; Wed, 26 Sep 2012 08:51:01 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so770989iej.11 for ; Wed, 26 Sep 2012 01:51:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=sTrbhK2mdbxr3LZRBV4b3yUVpxW6VQO8AzAh4EDHFqE=; b=S0biFOLUDFGCs1I77eHzrOZjXwq6GC7GsEfKOFozpFiFuqKtwMdXnumPiHJY+1l/68 CzQVVzYtVcuMrrMkgjmMmyhoHF+lZjs9TLYQqU61vjIDlAbaYGerfIUwCWWiXIPK/ucp A4KK5AhKmWWM0MBdETSYYD30JQZLPmr8lRsoFItTEYaxxO9Dgc/boTx0glUDXiMFdmFR AqCeIso4Run6RmPPo8Yk/udlAMkuBkO6YLDCAFJkYP5ndrQAlYNzQ3tbVdmvV6i/VEDn s/7M6eh18OzRCEruG6MejPPNk8yh9l+mzfG50mPWUjQr17Vp220KgTq3j5EEiTRO4BfJ 8gTg== Received: by 10.50.0.193 with SMTP id 1mr10566476igg.0.1348649460947; Wed, 26 Sep 2012 01:51:00 -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.50.184.232 with SMTP id ex8csp343344igc; Wed, 26 Sep 2012 01:51:00 -0700 (PDT) Received: by 10.14.178.72 with SMTP id e48mr24366022eem.1.1348649459523; Wed, 26 Sep 2012 01:50:59 -0700 (PDT) Received: from eu1sys200aog104.obsmtp.com (eu1sys200aog104.obsmtp.com [207.126.144.117]) by mx.google.com with SMTP id k2si962750een.129.2012.09.26.01.50.48 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Sep 2012 01:50:59 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.117 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.117; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.117 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob104.postini.com ([207.126.147.11]) with SMTP ID DSNKUGLB5yXslO4aLwWqVvkhWwuxX6FvHsqS@postini.com; Wed, 26 Sep 2012 08:50:59 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 1FCF23B; Wed, 26 Sep 2012 08:49:48 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 1761A4E; Wed, 26 Sep 2012 04:40:06 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 4EFE624C2F8; Wed, 26 Sep 2012 10:50:13 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 26 Sep 2012 10:50:17 +0200 From: Linus Walleij To: , Greg Kroah-Hartman Cc: , Anmar Oueja , Linus Walleij , , Bibek Basu , Par-Gunnar Hjalmdahl , Guillaume Jaunet , Christophe Arnal , Matthias Locher , Rajanikanth HV Subject: [PATCH v2] serial: pl011: handle corruption at high clock speeds Date: Wed, 26 Sep 2012 10:50:12 +0200 Message-ID: <1348649412-25812-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQndV9modizy8DXZ9pTuJypXBzQZvOr7/rJRXgCDwZ9uk8cMdpgFQFrq7Tgrrh/vTjmUQdGD From: Linus Walleij This works around a few glitches in the ST version of the PL011 serial driver when using very high baud rates, as we do in the Ux500: 3, 3.25, 4 and 4.05 Mbps. Problem Observed/rootcause: When using high baud-rates, and the baudrate*8 is getting close to the provided clock frequency (so a division factor close to 1), when using bursts of characters (so they are abutted), then it seems as if there is not enough time to detect the beginning of the start-bit which is a timing reference for the entire character, and thus the sampling moment of character bits is moving towards the end of each bit, instead of the middle. Fix: Increase slightly the RX baud rate of the UART above the theoretical baudrate by 5%. This will definitely give more margin time to the UART_RX to correctly sample the data at the middle of the bit period. Also fix the ages old copy-paste error in the very stressed comment, it's referencing the registers used in the PL010 driver rather than the PL011 ones. Cc: stable@kernel.org Cc: Bibek Basu Cc: Par-Gunnar Hjalmdahl Signed-off-by: Guillaume Jaunet Signed-off-by: Christophe Arnal Signed-off-by: Matthias Locher Signed-off-by: Rajanikanth HV Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Use >= comparison for 3 Mbaud, add some parenthesis to make the logical expressions crystal clear. --- drivers/tty/serial/amba-pl011.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index d626d84..cb9f694 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -1594,13 +1594,26 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios, old_cr &= ~ST_UART011_CR_OVSFACT; } + /* + * Workaround for the ST Micro oversampling variants to + * increase the bitrate slightly, by lowering the divisor, + * to avoid delayed sampling of start bit at high speeds, + * else we see data corruption. + */ + if (uap->vendor->oversampling) { + if (baud > 3000000 && baud < 3250000 && quot > 1) + quot -= 1; + else if (baud > 3250000 && quot > 2) + quot -= 2; + } /* Set baud rate */ writew(quot & 0x3f, port->membase + UART011_FBRD); writew(quot >> 6, port->membase + UART011_IBRD); /* * ----------v----------v----------v----------v----- - * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L + * NOTE: lcrh_tx and lcrh_rx MUST BE WRITTEN AFTER + * UART011_FBRD & UART011_IBRD. * ----------^----------^----------^----------^----- */ writew(lcr_h, port->membase + uap->lcrh_rx);