From patchwork Wed Nov 7 06:59:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinya Kuribayashi X-Patchwork-Id: 1708251 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 21ECEDFB7A for ; Wed, 7 Nov 2012 06:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751688Ab2KGG7r (ORCPT ); Wed, 7 Nov 2012 01:59:47 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:49155 "EHLO relmlor2.renesas.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751182Ab2KGG7q (ORCPT ); Wed, 7 Nov 2012 01:59:46 -0500 Received: from relmlir1.idc.renesas.com ([10.200.68.151]) by relmlor2.idc.renesas.com ( SJSMS) with ESMTP id <0MD300HRBVFLZK40@relmlor2.idc.renesas.com>; Wed, 07 Nov 2012 15:59:45 +0900 (JST) Received: from relmlac3.idc.renesas.com ([10.200.69.23]) by relmlir1.idc.renesas.com (SJSMS) with ESMTP id <0MD3007T0VFLT710@relmlir1.idc.renesas.com>; Wed, 07 Nov 2012 15:59:45 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 489941809F; Wed, 07 Nov 2012 15:59:45 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 3F3741809C; Wed, 07 Nov 2012 15:59:45 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id RAH08365; Wed, 07 Nov 2012 15:59:45 +0900 X-IronPort-AV: E=Sophos; i="4.80,727,1344178800"; d="scan'208"; a="105176938" Received: from unknown (HELO [10.161.64.55]) ([10.161.64.55]) by relmlii1.idc.renesas.com with ESMTP; Wed, 07 Nov 2012 15:59:45 +0900 Message-id: <509A06E1.6090908@renesas.com> Date: Wed, 07 Nov 2012 15:59:45 +0900 From: Shinya Kuribayashi User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-version: 1.0 To: lethal@linux-sh.org, magnus.damm@gmail.com, takashi.yoshii.zj@renesas.com, alan@linux.intel.com, gregkh@linuxfoundation.org Cc: rjw@sisk.pl, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org Subject: [PATCH 06/10] serial: sh-sci: support lower baud rate References: <509A0658.1010503@renesas.com> In-reply-to: <509A0658.1010503@renesas.com> Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org Support prescaler 1/16 and 1/64, in addition to current 1 and 1/4. Supporting below 2400bps was dropped long time ago in mainline. Since then, setting lower rate has been resulting in erroneous register value, without indicating any errors through API. This patch adds more prescaler to support lower rates again. This still doesn't check range, but we won't hit the case because even 50bps at 48MHz clock is now supported. Signed-off-by: Takashi Yoshii Signed-off-by: Shinya Kuribayashi --- drivers/tty/serial/sh-sci.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index ffeca65..3021912 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1814,7 +1814,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, { struct sci_port *s = to_sci_port(port); struct plat_sci_reg *reg; - unsigned int baud, smr_val, max_baud; + unsigned int baud, smr_val, max_baud, cks; int t = -1; /* @@ -1848,21 +1848,18 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, uart_update_timeout(port, termios->c_cflag, baud); - serial_port_out(port, SCSMR, smr_val); + for (cks = 0; t >= 256 && cks <= 3; cks++) + t >>= 2; - dev_dbg(port->dev, "%s: SMR %x, t %x, SCSCR %x\n", __func__, smr_val, t, - s->cfg->scscr); + dev_dbg(port->dev, "%s: SMR %x, cks %x, t %x, SCSCR %x\n", + __func__, smr_val, cks, t, s->cfg->scscr); if (t >= 0) { - if (t >= 256) { - serial_port_out(port, SCSMR, (serial_port_in(port, SCSMR) & ~3) | 1); - t >>= 2; - } else - serial_port_out(port, SCSMR, serial_port_in(port, SCSMR) & ~3); - + serial_port_out(port, SCSMR, (smr_val & ~3) | cks); serial_port_out(port, SCBRR, t); udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */ - } + } else + serial_port_out(port, SCSMR, smr_val); sci_init_pins(port, termios->c_cflag);