From patchwork Mon May 15 07:48:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9726243 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF24360231 for ; Mon, 15 May 2017 07:55:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF1B82896C for ; Mon, 15 May 2017 07:55:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D15342896E; Mon, 15 May 2017 07:55:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04B212896C for ; Mon, 15 May 2017 07:55:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DcW2RKDBYUmtTClQAJ3K0bCPbaXgHOTa2PpTI4JkvUI=; b=EO38NeoeBUPRMo hrNrwsqzFhxOI/pY231qTEUoZBru0lQyop7XVXQ4tNvDfNH0gmUnTPb5PfFwr+dPyr6AFFxlEERoU PygINqLT6TrsIpJ4x3m6I+5VKaZEdmtfxDOUAA3OvZAKIhCaNBhbwtH1wdDK1fuPmVO1izYPu4PHF 0CahmgZmE5NC4hcXAHLQ9SrqHz+TDUDRxB+Cpuk5U0/04WFSUTjZG5fA7mhLuA4yulPbHk6h5HLyV kZ4CiTUFdQ60rG9H5Z2/HUtjkhyQxYssZWh6MmxCTJCgYYwRp40eHtRNgQ16nvtCmMgvAfgYAnhvp sz0YMqJtQDnE6Ps4vbzw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dAAqJ-0002q6-1W; Mon, 15 May 2017 07:54:59 +0000 Received: from mail-sn1nam01on0047.outbound.protection.outlook.com ([104.47.32.47] helo=NAM01-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dAAlG-0006ru-8r for linux-arm-kernel@lists.infradead.org; Mon, 15 May 2017 07:49:56 +0000 Received: from BN3PR03CA0051.namprd03.prod.outlook.com (10.167.1.139) by BY2PR03MB176.namprd03.prod.outlook.com (10.242.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16; Mon, 15 May 2017 07:49:22 +0000 Received: from BY2FFO11FD034.protection.gbl (2a01:111:f400:7c0c::126) by BN3PR03CA0051.outlook.office365.com (2a01:111:e400:7a4d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16 via Frontend Transport; Mon, 15 May 2017 07:49:22 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD034.mail.protection.outlook.com (10.1.14.219) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1075.5 via Frontend Transport; Mon, 15 May 2017 07:49:21 +0000 Received: from b29396-OptiPlex-7040.ap.freescale.net (b29396-OptiPlex-7040.ap.freescale.net [10.192.242.182]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v4F7msjZ003487; Mon, 15 May 2017 00:49:18 -0700 From: Dong Aisheng To: Subject: [PATCH V2 6/6] tty: serial: lpuart: add a more accurate baud rate calculation method Date: Mon, 15 May 2017 15:48:59 +0800 Message-ID: <1494834539-17523-7-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494834539-17523-1-git-send-email-aisheng.dong@nxp.com> References: <1494834539-17523-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131393081621563389; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39450400003)(39840400002)(39860400002)(39380400002)(39850400002)(39400400002)(39410400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(8676002)(81166006)(575784001)(305945005)(86362001)(8936002)(356003)(104016004)(50226002)(5820100001)(23676002)(50466002)(189998001)(76176999)(50986999)(7416002)(53936002)(498600001)(54906002)(8656002)(38730400002)(39060400002)(110136004)(6916009)(36756003)(2906002)(4326008)(2950100002)(2870700001)(6666003)(5660300001)(105606002)(47776003)(77096006)(2351001)(85426001)(106466001)(33646002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB176; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD034; 1:QGf1xcUyA5CpElSQpyOgAxMK5BDZ8JEt6SiWiLFPdnCdM2lRbPsZxIQJXDIraiCW7pnow5mG9sc/JbwRg0Tv0encCp0mXRrBrGvDCphdCz1shjEaB/7obwGdrz37IXHG6sKbNkIA/Ke4uGVetj4/zf1JzU23Q2+Bax2dRBKS712XOtEZGsZDmjMcKgKHerRKjXgkw0LRSJI8/bxjHbxgWKep98FQAnP9N5WUE9AooMwUJcbrl/oa/0RFyEhUJQGGSX0/dHy6OeQ8yj/5ysxJa4dfLl3OqRcaRhY02egRMjNDlAztEx0Pwul2nbF8dP4PLTsK+T8TUYWd07eW3It0q4J0fDjAThBGQAyFzLsf5VeRQdf4bbx7q7IyxJZHWyUjep7e7Ouzo7cacvWErzK7lCBFl/fR9GEr2CBpA/ePjab6qEeH+4qYPPYTIlz4/D8zEhZgYoYQRFQ/P8mbujMFY8IDO5fE9r4Lufd72NLHIdsFgAV04qb2H5LGVqDBstoHfYVb0z14yLGNmxWhsa+/krk3f7vXcaXoyZu/hwBwFqnuaS8mpusRNmSGayUYx8vVJrRi46luqq6C90nDBessyxSJP8wZo/GYIY3ibMP4tiai+2E6QweArtTnCeaGsv/sO1TtzNV5agX1emH74uiJRxOLUx9r7Lm6vOyCa6K61cjClWp6AZ3XGyGmX2PMDog+FmS1HDdU5r/zUrgTRvyv4WigT2lz0BEIfYi+DjOdADU= X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3528f30-8c84-4882-e69d-08d49b66e673 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:BY2PR03MB176; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB176; 3:B0mfkeDRaahzOSfzzLEmcIY5akP+fEQmJXTYaT5mIaLPPBV3sBykhF4pvWZVFUs0BTKbrds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B+T9HUINvQBwl+8msm9Q4l9vhCNDxSoMTmGnzgXaLsi/O1XSAgZqRD1mcQ2PXUqJC0TK3ZVFH X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(13017025)(5005006)(13018025)(13015025)(13023025)(8121501046)(13024025)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123563025)(20161123556025)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123565025)(20161123559100)(20161123561025); SRVR:BY2PR03MB176; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR03MB176; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjAzTUIxNzY7NDpDRGgwVzRvbEZ5ZytaTWNUWE5PTmwzbXVlVm5R?= =?utf-8?B?c3k0aXIydkRBdm1xQnRHNkVuTXN3TUxYSFdrVERpVUREdS9EWHdma0hMTGtz?= =?utf-8?B?SmNXaVIwb3BzQ1NnRC85UzRrOHNTWGJ5eW5YTEgvNG50bU92ekI4NFo0UmFa?= =?utf-8?B?dHlrR0RJeGNNM05Fc3VUYzQ3UTZ5VGt2UU96M1ZtNjNqeGEvS1crb1RGQzVt?= =?utf-8?B?cEVIQk1IRHdHUVBzYUc0TTlWc0EvUkZURXVIek9nNHFVREt6bTZQaVZ3UWxF?= =?utf-8?B?aWNtS1htdDdyWEptb1BHRjJEcWdoZFFMUk1iamJORi83RUJzYmRIMG5ISHds?= =?utf-8?B?NzZLdDlNWjNtMTR4eHM2TjNUYTJ0dUdPL3ByRW41WFpxYUp5dkRKM0dQTlJ2?= =?utf-8?B?TDhoNElOa3gwT00yVGFpRGxBTWdBUER5RTdPQnJQY0VGclNEaTVkN2pNcllT?= =?utf-8?B?V1dIS0l6WndtYnFMR283SkNLKzdaaHFhdFl3OFkxcTdOcVphc204NFNsZlZ2?= =?utf-8?B?VHpRbUJPL29ud2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microsoft-Exchange-Diagnostics: 1; BY2PR03MB176; 6:qEJjFCi0rdcXjLOCT9vge7VI672r005EVZUUjWv7rqamDX6XIU57LZoQOxOJooUCqzKPIeFMltfvcthuJ21MQPKs/qSKumq+3q+CtgkmRU+dlNOzk5nI28CBLKHhwdi+7n8Dm0CSiBKAwbx0rTz8Fj/qvx7Q/YQcb8q16GDeP67oJ1vu/eoAKrN9z+653olYEScTc87ILJpg6xIX0RD9TswMAQXPvvMynXjWAtwsDvIa2qRHQoVeol3pbtibHHuujem1vCFN9NPrf6HhZKxM0zacjtxRXL8ONK6WD9DQ+sNirq74RgHj3UmGc5D2BMSHqRo+TBmd0nYZ3UHNxLgp8h7euQL0PdPidyTKWKPJVthVOvGF1GFjj7g2LUCtvpvVwZLKE5QwCJBi2F8hHup8LeAKTn5jyTLkGQICyP0PXsX2Fqy/Mun20bxJ1r+n2KHwcVv0ufycAsfXEvCFV2LxvaK4RFvsCuUa/PkcI9XkIdDOekK0RVtOAHCjGEGhbMkavnaiQfNLT5D8VPafYBaN8A==; 5:kX10ltsJF15BqtDCkF5e+/HN861eRMMnHK2LZZtRXWCBqq2TenGWcI5AYBcJ+uOBf7Mjia2MIqAFkSKF6pCjVfe6UaFrTwVkYIo8XQQQz8LDRxnWRblSF/mJxQOIRDKzCgXdedXQ1FPggy3XVYu335en95RWsKVIzW3OOL8qTk2lS8xJ/7D3KAj6L1r4xNOV; 24:hcwT1bVjE1GsimX/TVee4/O8JCeiCRnAOb4YiduIX+mqb7/XG+JajLRhMeOiv55Vhu1hauzV0JV+xitQVJZLim2A3byvWw6LR/mHCdNSCUk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB176; 7:opIZphb4Y2Uq3NGXBjR2vl7tprh4YEmPSqDxxP3bs3nf2uiGGkMvkOcePFOlB7yc5amH7CeJUnq9M4GptUhEvzwGfn+z33JexSc0DmrDKFD+TpVI6e6I4yCah5V9L2zuxXOUqI2NPtcGdkbmM0yHYKBzfMBoMVVrwcvBOY8aYDySCi4mx7VJsPAjELWX8RG21r80YsAa1+5ol64ofmMYQFLVURu8BSFncgXst97vd5q7Y2OLKq/kIzA3/JU5Xr5GBOa4LT6Qy/LzZGIqZiiKkspdw52J8Ejb7Ci5VtqFzsgodlq5a+smNKLTCa6aMUmbWGRVSp4iwq8jUmXmQMDWJw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2017 07:49:21.9223 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB176 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170515_004947_054667_FE203B2B X-CRM114-Status: GOOD ( 16.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Aisheng , fugang.duan@nxp.com, dongas86@gmail.com, gregkh@linuxfoundation.org, yangbo.lu@nxp.com, linux-kernel@vger.kernel.org, stefan@agner.ch, Mingkai.Hu@nxp.com, jslaby@suse.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On new LPUART versions, the oversampling ratio for the receiver can be changed from 4x (00011) to 32x (11111) which could help us get a more accurate baud rate divider. The idea is to use the best OSR (over-sampling rate) possible. Note, OSR is typically hard-set to 16 in other LPUART instantiations. Loop to find the best OSR value possible, one that generates minimum baud diff iterate through the rest of the supported values of OSR. Currently only i.MX7ULP is using it. Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Stefan Agner Cc: Mingkai Hu Cc: Yangbo Lu Acked-by: Fugang Duan Signed-off-by: Dong Aisheng --- drivers/tty/serial/fsl_lpuart.c | 85 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 107d0911..bda4b0c 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -140,6 +140,8 @@ #define UARTBAUD_SBNS 0x00002000 #define UARTBAUD_SBR 0x00000000 #define UARTBAUD_SBR_MASK 0x1fff +#define UARTBAUD_OSR_MASK 0x1f +#define UARTBAUD_OSR_SHIFT 24 #define UARTSTAT_LBKDIF 0x80000000 #define UARTSTAT_RXEDGIF 0x40000000 @@ -1506,6 +1508,72 @@ lpuart_set_termios(struct uart_port *port, struct ktermios *termios, } static void +lpuart32_serial_setbrg(struct lpuart_port *sport, unsigned int baudrate) +{ + u32 sbr, osr, baud_diff, tmp_osr, tmp_sbr, tmp_diff, tmp; + u32 clk = sport->port.uartclk; + + /* + * The idea is to use the best OSR (over-sampling rate) possible. + * Note, OSR is typically hard-set to 16 in other LPUART instantiations. + * Loop to find the best OSR value possible, one that generates minimum + * baud_diff iterate through the rest of the supported values of OSR. + * + * Calculation Formula: + * Baud Rate = baud clock / ((OSR+1) × SBR) + */ + baud_diff = baudrate; + osr = 0; + sbr = 0; + + for (tmp_osr = 4; tmp_osr <= 32; tmp_osr++) { + /* calculate the temporary sbr value */ + tmp_sbr = (clk / (baudrate * tmp_osr)); + if (tmp_sbr == 0) + tmp_sbr = 1; + + /* + * calculate the baud rate difference based on the temporary + * osr and sbr values + */ + tmp_diff = clk / (tmp_osr * tmp_sbr) - baudrate; + + /* select best values between sbr and sbr+1 */ + tmp = clk / (tmp_osr * (tmp_sbr + 1)); + if (tmp_diff > (baudrate - tmp)) { + tmp_diff = baudrate - tmp; + tmp_sbr++; + } + + if (tmp_diff <= baud_diff) { + baud_diff = tmp_diff; + osr = tmp_osr; + sbr = tmp_sbr; + } + } + + /* handle buadrate outside acceptable rate */ + if (baud_diff > ((baudrate / 100) * 3)) + dev_warn(sport->port.dev, + "unacceptable baud rate difference of more than 3%%\n"); + + tmp = lpuart32_read(sport->port.membase + UARTBAUD); + + if ((osr > 3) && (osr < 8)) + tmp |= UARTBAUD_BOTHEDGE; + + tmp &= ~(UARTBAUD_OSR_MASK << UARTBAUD_OSR_SHIFT); + tmp |= (((osr-1) & UARTBAUD_OSR_MASK) << UARTBAUD_OSR_SHIFT); + + tmp &= ~UARTBAUD_SBR_MASK; + tmp |= sbr & UARTBAUD_SBR_MASK; + + tmp &= ~(UARTBAUD_TDMAE | UARTBAUD_RDMAE); + + lpuart32_write(tmp, sport->port.membase + UARTBAUD); +} + +static void lpuart32_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) { @@ -1611,12 +1679,17 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios, lpuart32_write(old_ctrl & ~(UARTCTRL_TE | UARTCTRL_RE), sport->port.membase + UARTCTRL); - sbr = sport->port.uartclk / (16 * baud); - bd &= ~UARTBAUD_SBR_MASK; - bd |= sbr & UARTBAUD_SBR_MASK; - bd |= UARTBAUD_BOTHEDGE; - bd &= ~(UARTBAUD_TDMAE | UARTBAUD_RDMAE); - lpuart32_write(bd, sport->port.membase + UARTBAUD); + if (of_device_is_compatible(port->dev->of_node, "fsl,imx7ulp-lpuart")) { + lpuart32_serial_setbrg(sport, baud); + } else { + sbr = sport->port.uartclk / (16 * baud); + bd &= ~UARTBAUD_SBR_MASK; + bd |= sbr & UARTBAUD_SBR_MASK; + bd |= UARTBAUD_BOTHEDGE; + bd &= ~(UARTBAUD_TDMAE | UARTBAUD_RDMAE); + lpuart32_write(bd, sport->port.membase + UARTBAUD); + } + lpuart32_write(modem, sport->port.membase + UARTMODIR); lpuart32_write(ctrl, sport->port.membase + UARTCTRL); /* restore control register */