* [PATCH] serial: also set the uartclk value in resume after goes to highspeed
@ 2011-01-25 7:44 Yin Kangkai
2011-02-03 22:15 ` Greg KH
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yin Kangkai @ 2011-01-25 7:44 UTC (permalink / raw)
To: linux-serial; +Cc: Greg Kroah-Hartman, Woodhouse, David, linux-kernel
>From 6f96e25fd4401b152adb9d91ebda0777f3532162 Mon Sep 17 00:00:00 2001
From: Yin Kangkai <kangkai.yin@intel.com>
Date: Mon, 24 Jan 2011 18:45:39 +0800
Subject: [PATCH] serial: also set the uartclk value in resume after goes to highspeed
For any reason if the NS16550A was not work in high speed mode (e.g. we hold
NS16550A from going to high speed mode in autoconfig_16550a()), now we are
resume from suspend, we should also set the uartclk to the correct
value. Otherwise it is still the old 1843200 and that will bring issues.
Signed-off-by: Yin Kangkai <kangkai.yin@intel.com>
---
drivers/serial/8250.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 3e690da..e928e06 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2995,6 +2995,7 @@ void serial8250_resume_port(int line)
ns16550a_goto_highspeed(up);
serial_outp(up, UART_LCR, 0);
+ up->port.uartclk = 921600*16;
}
uart_resume_port(&serial8250_reg, &up->port);
}
--
1.6.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] serial: also set the uartclk value in resume after goes to highspeed
2011-01-25 7:44 [PATCH] serial: also set the uartclk value in resume after goes to highspeed Yin Kangkai
@ 2011-02-03 22:15 ` Greg KH
2011-02-09 3:34 ` [PATCH resend 1/2] " Yin Kangkai
2011-02-09 3:35 ` [PATCH resend 2/2] serial: change the divisor latch only when prescalar actually changed Yin Kangkai
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2011-02-03 22:15 UTC (permalink / raw)
To: Yin Kangkai
Cc: linux-serial, Greg Kroah-Hartman, Woodhouse, David, linux-kernel
On Tue, Jan 25, 2011 at 03:44:47PM +0800, Yin Kangkai wrote:
> From: Yin Kangkai <kangkai.yin@intel.com>
Please don't include the git patch in the email, use git-send-email to
send it out.
Anyway, this doesn't apply to the latest linux-next tree, care to
refresh it and resend it?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH resend 1/2] serial: also set the uartclk value in resume after goes to highspeed
2011-01-25 7:44 [PATCH] serial: also set the uartclk value in resume after goes to highspeed Yin Kangkai
2011-02-03 22:15 ` Greg KH
@ 2011-02-09 3:34 ` Yin Kangkai
2011-02-09 3:35 ` [PATCH resend 2/2] serial: change the divisor latch only when prescalar actually changed Yin Kangkai
2 siblings, 0 replies; 4+ messages in thread
From: Yin Kangkai @ 2011-02-09 3:34 UTC (permalink / raw)
To: linux-serial
Cc: Yin Kangkai, Greg Kroah-Hartman, David Woodhouse, linux-kernel,
stable
For any reason if the NS16550A was not work in high speed mode (e.g. we hold
NS16550A from going to high speed mode in autoconfig_16550a()), now we are
resume from suspend, we should also set the uartclk to the correct
value. Otherwise it is still the old 1843200 and that will bring issues.
CC: Greg Kroah-Hartman <greg@kroah.com>
CC: David Woodhouse <dwmw2@infradead.org>
CC: linux-kernel@vger.kernel.org
CC: stable@kernel.org
Signed-off-by: Yin Kangkai <kangkai.yin@linux.intel.com>
---
drivers/tty/serial/8250.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
index 3975df6..c10a6a9 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -3036,6 +3036,7 @@ void serial8250_resume_port(int line)
serial_outp(up, 0x04, tmp);
serial_outp(up, UART_LCR, 0);
+ up->port.uartclk = 921600*16;
}
uart_resume_port(&serial8250_reg, &up->port);
}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH resend 2/2] serial: change the divisor latch only when prescalar actually changed
2011-01-25 7:44 [PATCH] serial: also set the uartclk value in resume after goes to highspeed Yin Kangkai
2011-02-03 22:15 ` Greg KH
2011-02-09 3:34 ` [PATCH resend 1/2] " Yin Kangkai
@ 2011-02-09 3:35 ` Yin Kangkai
2 siblings, 0 replies; 4+ messages in thread
From: Yin Kangkai @ 2011-02-09 3:35 UTC (permalink / raw)
To: linux-serial
Cc: Yin Kangkai, Greg Kroah-Hartman, David Woodhouse, linux-kernel,
stable
In 8250.c original ns16550 autoconfig code, we change the divisor latch when
we goto to high speed mode, we're assuming the previous speed is legacy. This
some times is not true.
For example in a system with both CONFIG_SERIAL_8250 and
CONFIG_SERIAL_8250_PNP set, in this case, the code (autoconfig) will be called
twice, one in serial8250_init/probe() and the other is from
serial_pnp_probe. When serial_pnp_probe calls the autoconfig for NS16550A,
it's already in high speed mode, change the divisor latch (quot << 3) in this
case will make the UART console garbled.
CC: Greg Kroah-Hartman <greg@kroah.com>
CC: David Woodhouse <dwmw2@infradead.org>
CC: linux-kernel@vger.kernel.org
CC: stable@kernel.org
Signed-off-by: Yin Kangkai <kangkai.yin@linux.intel.com>
---
drivers/tty/serial/8250.c | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
index c10a6a9..b3b881b 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -954,6 +954,23 @@ static int broken_efr(struct uart_8250_port *up)
return 0;
}
+static inline int ns16550a_goto_highspeed(struct uart_8250_port *up)
+{
+ unsigned char status;
+
+ status = serial_in(up, 0x04); /* EXCR2 */
+#define PRESL(x) ((x) & 0x30)
+ if (PRESL(status) == 0x10) {
+ /* already in high speed mode */
+ return 0;
+ } else {
+ status &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */
+ status |= 0x10; /* 1.625 divisor for baud_base --> 921600 */
+ serial_outp(up, 0x04, status);
+ }
+ return 1;
+}
+
/*
* We know that the chip has FIFOs. Does it have an EFR? The
* EFR is located in the same register position as the IIR and
@@ -1025,12 +1042,8 @@ static void autoconfig_16550a(struct uart_8250_port *up)
quot = serial_dl_read(up);
quot <<= 3;
- status1 = serial_in(up, 0x04); /* EXCR2 */
- status1 &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */
- status1 |= 0x10; /* 1.625 divisor for baud_base --> 921600 */
- serial_outp(up, 0x04, status1);
-
- serial_dl_write(up, quot);
+ if (ns16550a_goto_highspeed(up))
+ serial_dl_write(up, quot);
serial_outp(up, UART_LCR, 0);
@@ -3025,15 +3038,10 @@ void serial8250_resume_port(int line)
struct uart_8250_port *up = &serial8250_ports[line];
if (up->capabilities & UART_NATSEMI) {
- unsigned char tmp;
-
/* Ensure it's still in high speed mode */
serial_outp(up, UART_LCR, 0xE0);
- tmp = serial_in(up, 0x04); /* EXCR2 */
- tmp &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */
- tmp |= 0x10; /* 1.625 divisor for baud_base --> 921600 */
- serial_outp(up, 0x04, tmp);
+ ns16550a_goto_highspeed(up);
serial_outp(up, UART_LCR, 0);
up->port.uartclk = 921600*16;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-02-09 3:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-25 7:44 [PATCH] serial: also set the uartclk value in resume after goes to highspeed Yin Kangkai
2011-02-03 22:15 ` Greg KH
2011-02-09 3:34 ` [PATCH resend 1/2] " Yin Kangkai
2011-02-09 3:35 ` [PATCH resend 2/2] serial: change the divisor latch only when prescalar actually changed Yin Kangkai
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).