linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 06/10] serial: sh-sci: support lower baud rate
Date: Wed, 07 Nov 2012 06:59:45 +0000	[thread overview]
Message-ID: <509A06E1.6090908@renesas.com> (raw)
In-Reply-To: <509A0658.1010503@renesas.com>

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 <takashi.yoshii.zj@renesas.com>
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
---
 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);
 
-- 
1.7.12.4


  parent reply	other threads:[~2012-11-07  6:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-07  6:57 [PATCH 00/10] serial: sh-sci fixes - console PM, SCIFB, SMP lockup, etc Shinya Kuribayashi
2012-11-07  6:58 ` [PATCH 01/10] Revert "sh-sci / PM: Avoid deadlocking runtime PM" Shinya Kuribayashi
2012-11-07  6:58 ` [PATCH 02/10] Revert "sh-sci / PM: Use power.irq_safe" Shinya Kuribayashi
2012-11-07  6:58 ` [PATCH 03/10] Partially revert "serial: sh-sci: console Runtime PM support" Shinya Kuribayashi
2012-11-07  6:59 ` [PATCH 04/10] serial: sh-sci: console runtime PM support (revisit) Shinya Kuribayashi
2012-11-07  6:59 ` [PATCH 05/10] serial: sh-sci: fix condition test to set SCBRR Shinya Kuribayashi
2012-11-07  6:59 ` Shinya Kuribayashi [this message]
2012-11-07  7:00 ` [PATCH 07/10] serial: sh-sci: mask SCTFDR/RFDR according to fifosize Shinya Kuribayashi
2012-11-07  7:00 ` [PATCH 08/10] serial: sh-sci: fix common SCIFB regmap definition Shinya Kuribayashi
2012-11-07  7:00 ` [PATCH 09/10] serial: sh-sci: add locking to console write function to avoid SMP lockup Shinya Kuribayashi
2012-11-07  7:01 ` [PATCH 10/10] serial: sh-sci: fix possible race cases on SCSCR register accesses Shinya Kuribayashi
2012-11-07  7:18 ` [PATCH 00/10] serial: sh-sci fixes - console PM, SCIFB, SMP lockup, etc Shinya Kuribayashi
2012-11-16  1:01   ` Greg KH
2012-11-16  1:49     ` [PATCH v2 " Shinya Kuribayashi
2012-11-16  1:50       ` [PATCH v2 01/10] Revert "sh-sci / PM: Avoid deadlocking runtime PM" Shinya Kuribayashi
2012-11-16  1:51       ` [PATCH v2 02/10] Revert "sh-sci / PM: Use power.irq_safe" Shinya Kuribayashi
2012-11-16  1:51       ` [PATCH v2 03/10] Partially revert "serial: sh-sci: console Runtime PM support" Shinya Kuribayashi
2012-11-16  1:51       ` [PATCH v2 04/10] serial: sh-sci: console runtime PM support (revisit) Shinya Kuribayashi
2012-11-16  1:52       ` [PATCH v2 05/10] serial: sh-sci: fix condition test to set SCBRR Shinya Kuribayashi
2012-11-16  1:52       ` [PATCH v2 06/10] serial: sh-sci: support lower baud rate Shinya Kuribayashi
2012-11-16  1:53       ` [PATCH v2 07/10] serial: sh-sci: mask SCTFDR/RFDR according to fifosize Shinya Kuribayashi
2012-11-16  1:53       ` [PATCH v2 08/10] serial: sh-sci: fix common SCIFB regmap definition Shinya Kuribayashi
2012-11-16  1:54       ` [PATCH v2 09/10] serial: sh-sci: add locking to console write function to avoid SMP lockup Shinya Kuribayashi
2012-11-16  1:54       ` [PATCH v2 10/10] serial: sh-sci: fix possible race cases on SCSCR register accesses Shinya Kuribayashi
2012-11-16  2:04       ` [PATCH v2 00/10] serial: sh-sci fixes - console PM, SCIFB, SMP lockup, etc Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=509A06E1.6090908@renesas.com \
    --to=shinya.kuribayashi.px@renesas.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).