From patchwork Fri Feb 10 15:24:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 9566961 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 5E433601C3 for ; Fri, 10 Feb 2017 15:27:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48F362654B for ; Fri, 10 Feb 2017 15:27:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A9232793A; Fri, 10 Feb 2017 15:27:10 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable 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 D19B52654B for ; Fri, 10 Feb 2017 15:27:09 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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:In-Reply-To: References:List-Owner; bh=orfXcsm6YEJQUp2SL36G0eBjqWNq4cQwwuE9wcJAMC8=; b=hXr hTSAIvbj5po7BI8GtsFOdFEBBOn0m6l1zn6TbTJrh/5G9bxJ67XCemDEB5M6QwQwbZAFDGauYTtHN nQKnAHUZhg2N8Ltt+q3/wPwjc38j/ZaZ4bu0uoGdB6+NniPBirAriextfraOYv2aQkPLc/cgIuoHN FmsVQPtWDPrZieARuGeYu6u11tS+ns995eHaH6OEnyKRyNMpeiKthxpfohVavxFfNdXQMAAtHQFI4 7TVRNixNB5rUFSidx1bL68oQbYbFWXzkon5YGImE7PiqjcIaXo7lqK4BAJLBcH3D9girUR/JhjpaI iuUsb3KX9Ri98dgmXZTxu0KyIjl5OkA==; 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 1ccD6I-0002Cf-AM; Fri, 10 Feb 2017 15:27:06 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ccD4k-0000qy-4g for linux-arm-kernel@lists.infradead.org; Fri, 10 Feb 2017 15:25:37 +0000 Received: by mail-wm0-x244.google.com with SMTP id u63so7846767wmu.2 for ; Fri, 10 Feb 2017 07:25:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=dLiqxVLllmqDy9qijMI4XuruS/Go+OOLhnOAJrnv2V4=; b=iuWWAfRx2mjMmcWko+L1qml/D/OdEhXlblKSgA0F3fwJ59HMmhxalFMQwrlu6CpnS5 N4gjEO/XZLx2oB/rbajq2/Cw1pR4+ZvWznovCIemj7YChfkzYQ7HL6NOacoflJB9IhyD itfpImzeZd2MDC7okyQpaDJEPT8jD0kBw8RuXx5A1YKmrybFSitkt7yDin2lG7/E5mrr HFgko2YSqDCdaLpOY2KVcHWKmXzUr9s0dpwuyj9TUsznzW3EXMvKlH80xYmnt9tbNeT9 qt3f85vp518kiDpbfDFxBgSx7fd38YybqBuFHSv4D/14eE6p3Q1G2SGTchPTCptVKHQh tceQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dLiqxVLllmqDy9qijMI4XuruS/Go+OOLhnOAJrnv2V4=; b=aNB8GEv7gNOEJ5fVxQuSqyACka87593/CuWswY3BCzrFJMk75f7hQ4C51/m2tqcedN e+vaRuVNwC5ZIezLd2kwZkK04o7rHHYc1xXoMjQyahNMtUJOVbWsNReKD36JYI8zM6z8 sKcr1HViR39yIDTpNkXmAuAzwN7+jzilf/uDtC8WPIQRAkr7iVujpwT50D67CMFjWegZ qPL/7Hy13FB5OgdT23caeSblAv8xaRCt3GgEur6PgGkWlfStecS5ojSYMCM6pq/khxbn kEFpLa/u9wXGchwHnaybWusTyFdk+i3tYu6cOd35BSkrc41kcxH8k9MpaJEkbZdxIh3N sMYw== X-Gm-Message-State: AMke39lIzKn/gcMKJT19awdgITxrpPW4lNNG7S80PLwEZdSNELeh7wi8ov5wj9oUTStdJg== X-Received: by 10.28.227.133 with SMTP id a127mr25622486wmh.104.1486740307838; Fri, 10 Feb 2017 07:25:07 -0800 (PST) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id 36sm3243526wrz.8.2017.02.10.07.25.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Feb 2017 07:25:07 -0800 (PST) From: Romain Izard To: linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] atmel_serial: Use the fractional divider when possible Date: Fri, 10 Feb 2017 16:24:46 +0100 Message-Id: <20170210152446.12674-1-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.9.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170210_072530_363286_6DA8A345 X-CRM114-Status: GOOD ( 12.63 ) 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: Richard Genoud , Greg Kroah-Hartman , Ludovic Desroches , Nicolas Ferre , Romain Izard MIME-Version: 1.0 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 The fractional baud rate generator is available when using the asynchronous mode of Atmel USART controllers. It makes it possible to use higher baudrates, in exchange for a less precise clock with a variable duty cycle. The existing code restricts its use to the normal mode of the USART controller, following the recommendation from the datasheet for the first chip embedding this type of controller. This recommendation has been removed from the documentation for the newer chips. After verification, all revisions of this controller should be able to use the fractional baud rate generator with the different asynchronous modes. Removing the condition on ATMEL_US_USMODE makes it possible to get correct baudrates at high speed in more cases. This was tested with a board using an Atmel SAMA5D2 chip and a TI WL1831 WiFi/Bluetooth combo chip at 3 Mbauds, with hardware flow control enabled. Signed-off-by: Romain Izard Acked-by: Ludovic Desroches Signed-off-by: Richard Genoud --- drivers/tty/serial/atmel_serial.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index fabbe76203bb..6684456dca9e 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -1758,7 +1758,9 @@ static void atmel_get_ip_name(struct uart_port *port) /* * Only USART devices from at91sam9260 SOC implement fractional - * baudrate. + * baudrate. It is available for all asynchronous modes, with the + * following restriction: the sampling clock's duty cycle is not + * constant. */ atmel_port->has_frac_baudrate = false; atmel_port->has_hw_timer = false; @@ -2202,8 +2204,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, * then * 8 CD + FP = selected clock / (2 * baudrate) */ - if (atmel_port->has_frac_baudrate && - (mode & ATMEL_US_USMODE) == ATMEL_US_USMODE_NORMAL) { + if (atmel_port->has_frac_baudrate) { div = DIV_ROUND_CLOSEST(port->uartclk, baud * 2); cd = div >> 3; fp = div & ATMEL_US_FP_MASK;