From patchwork Fri Jun 27 17:25:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 32628 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2F820200B9 for ; Fri, 27 Jun 2014 17:25:25 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id ij19sf9932109vcb.6 for ; Fri, 27 Jun 2014 10:25:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=MA6k7UZXiZuK2gtUcqTlxvtCHCK+FIO2EsV8AmPf3Os=; b=YmnJzNVWX/uTmLQzEvEWRvJARDskHV8fNyXTnY4fqfH2FU11lSfvOkLaBYwrem3DX2 p5xqj5keHjgLve4XOLz3Mr1KduCjRihAUFesYYzW+aEnNwPogExtQlyiv1suyU3cu4rQ Q7kJ+ovEq9PvFant2bSwko83IL1DTMPAst062s36tmBpVXT8VOJU6sPg+6QVyeJZKBpR OwFkrlFyslvGsyhmTq/fBi/rDbXf1q35s39zSUSHgY/+RWCWKO26uVtpedQc1gAgOeoX tdx+OBWLq5JjNIWUGV/rCTyoefBztyFXFSLiJDuzdoOUbx4pJPFIRkKYZ4rQxvuN7e2x aNPA== X-Gm-Message-State: ALoCoQl3E6+Trjj23gKCrexL9+bpxNm01PwXQ28Fmq0NUpYbkl9eDh29eXpvZb5X3Q4IRymwauIp X-Received: by 10.58.19.227 with SMTP id i3mr12127783vee.2.1403889924887; Fri, 27 Jun 2014 10:25:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.193 with SMTP id q59ls716160qga.91.gmail; Fri, 27 Jun 2014 10:25:24 -0700 (PDT) X-Received: by 10.52.241.76 with SMTP id wg12mr17744488vdc.5.1403889924799; Fri, 27 Jun 2014 10:25:24 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id og7si6732557vcb.23.2014.06.27.10.25.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 10:25:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hy10so5374028vcb.15 for ; Fri, 27 Jun 2014 10:25:24 -0700 (PDT) X-Received: by 10.58.29.164 with SMTP id l4mr20959993veh.8.1403889924631; Fri, 27 Jun 2014 10:25:24 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp124321vcb; Fri, 27 Jun 2014 10:25:24 -0700 (PDT) X-Received: by 10.68.192.106 with SMTP id hf10mr32522892pbc.30.1403889923762; Fri, 27 Jun 2014 10:25:23 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ht8si14638772pbc.152.2014.06.27.10.25.23; Fri, 27 Jun 2014 10:25:23 -0700 (PDT) Received-SPF: none (google.com: linux-serial-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751675AbaF0RZW (ORCPT + 1 other); Fri, 27 Jun 2014 13:25:22 -0400 Received: from mail-ig0-f179.google.com ([209.85.213.179]:57978 "EHLO mail-ig0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751493AbaF0RZV (ORCPT ); Fri, 27 Jun 2014 13:25:21 -0400 Received: by mail-ig0-f179.google.com with SMTP id uq10so2203008igb.0 for ; Fri, 27 Jun 2014 10:25:21 -0700 (PDT) X-Received: by 10.42.91.1 with SMTP id n1mr4061831icm.76.1403889921150; Fri, 27 Jun 2014 10:25:21 -0700 (PDT) Received: from localhost.localdomain (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id z6sm1015081igl.1.2014.06.27.10.25.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jun 2014 10:25:20 -0700 (PDT) From: Alex Elder To: gregkh@linuxfoundation.org Cc: heikki.krogerus@linux.intel.com, david.daney@cavium.com, loic.poulain@intel.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] serial: 8250_dw: support high baudrates if possible Date: Fri, 27 Jun 2014 12:25:20 -0500 Message-Id: <1403889920-1127-1-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-serial-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-serial@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently the Synopsys DesignWare 8250 driver assumes its UART clock runs at a fixed rate. If a "real" clock was set up using the common clock framework, and that clock's rate is adjustable, it may be possible to support a wider range of baud rates by changing the UART clock rate. This is done by setting up a uart_port->set_termios method that requests a clock rate change if a different rate might make it more likely to achieve a specified baud. Signed-off-by: Alex Elder --- This patch is also available here: http://git.linaro.org/landing-teams/working/broadcom/kernel.git Branch review/dw8250_clock drivers/tty/serial/8250/8250_dw.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index 51b307a..013aa9b 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -242,6 +242,43 @@ dw8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old) pm_runtime_put_sync_suspend(port->dev); } +/* + * If our clock was configured through the common clock framework we + * might be able to support a wider range of baud rates by changing + * its frequency. For the "traditional" baud rates (115200 or + * less), request the conventional 1.8432 MHz clock. The clock + * frequency needs to be at least 16 times the baud rate, so + * use 16 times the requested rate for those higher than 115200. + */ +static void +dw8250_set_termios(struct uart_port *p, struct ktermios *new, + struct ktermios *old) +{ + struct dw8250_data *data = p->private_data; + + if (!IS_ERR(data->clk)) { + speed_t baud; + unsigned int rate; + + baud = tty_termios_baud_rate(new); + BUG_ON(baud > (speed_t)UINT_MAX); + rate = 16 * max(115200U, (unsigned int)baud); + + /* + * Request a different clock rate if necessary, and + * record it if successful. + */ + if (rate != p->uartclk) { + BUG_ON(!data->clk); + if (!clk_set_rate(data->clk, (unsigned long)rate)) + p->uartclk = rate; + } + } + + /* The standard code does most of the work. */ + serial8250_do_set_termios(p, new, old); +} + static bool dw8250_dma_filter(struct dma_chan *chan, void *param) { struct dw8250_data *data = param; @@ -417,6 +454,7 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.iotype = UPIO_MEM; uart.port.serial_in = dw8250_serial_in; uart.port.serial_out = dw8250_serial_out; + uart.port.set_termios = dw8250_set_termios; uart.port.private_data = data; if (pdev->dev.of_node) {