blob: 644d3620165e2710ac3e90a8b6a414d9ced69c46 [file] [log] [blame]
From koba@kmckk.co.jp Wed Oct 3 04:27:18 2012
From: Tetsuyuki Kobayashi <koba@kmckk.co.jp>
Date: Wed, 3 Oct 2012 20:22:58 +0900
Subject: [PATCH 06/26] serial8250: Use dl_read()/dl_write() on RM9K
To: greg@kroah.com
Cc: ltsi-dev@lists.linuxfoundation.org, horms@verge.net.au, damm@opensource.se, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Tetsuyuki Kobayashi <koba@kmckk.co.jp>
Message-ID: <1349263398-13152-7-git-send-email-koba@kmckk.co.jp>
From: Magnus Damm <damm@opensource.se>
Convert the 8250 RM9K support code to make
use of the new dl_read()/dl_write() callbacks.
Signed-off-by: Magnus Damm <damm@opensource.se>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 28bf4cf22dcd936f93dd6063696b1accdc1d5207)
Signed-off-by: Tetsuyuki Kobayashi <koba@kmckk.co.jp>
---
drivers/tty/serial/8250/8250.c | 62 +++++++++++++++++++----------------------
1 file changed, 29 insertions(+), 33 deletions(-)
--- a/drivers/tty/serial/8250/8250.c
+++ b/drivers/tty/serial/8250/8250.c
@@ -324,25 +324,6 @@ static void default_dl_write(struct uart
serial_out(up, UART_DLM, value >> 8 & 0xff);
}
-#if defined(CONFIG_SERIAL_8250_RM9K)
-static int _serial_dl_read(struct uart_8250_port *up)
-{
- return (up->port.iotype == UPIO_RM9000) ?
- (((__raw_readl(up->port.membase + 0x10) << 8) |
- (__raw_readl(up->port.membase + 0x08) & 0xff)) & 0xffff) :
- default_dl_read(up);
-}
-
-static void _serial_dl_write(struct uart_8250_port *up, int value)
-{
- if (up->port.iotype == UPIO_RM9000) {
- __raw_writel(value, up->port.membase + 0x08);
- __raw_writel(value >> 8, up->port.membase + 0x10);
- } else {
- default_dl_write(up, value);
- }
-}
-#else
static int _serial_dl_read(struct uart_8250_port *up)
{
return default_dl_read(up);
@@ -352,7 +333,6 @@ static void _serial_dl_write(struct uart
{
default_dl_write(up, value);
}
-#endif
#ifdef CONFIG_MIPS_ALCHEMY
@@ -400,7 +380,7 @@ static void au_serial_dl_write(struct ua
#endif
-#if defined(CONFIG_SERIAL_8250_RM9K)
+#ifdef CONFIG_SERIAL_8250_RM9K
static const u8
regmap_in[8] = {
@@ -424,28 +404,36 @@ static const u8
[UART_SCR] = 0x2c
};
-static inline int map_8250_in_reg(struct uart_port *p, int offset)
+static unsigned int rm9k_serial_in(struct uart_port *p, int offset)
+{
+ offset = regmap_in[offset] << p->regshift;
+ return readl(p->membase + offset);
+}
+
+static void rm9k_serial_out(struct uart_port *p, int offset, int value)
{
- if (p->iotype != UPIO_RM9000)
- return offset;
- return regmap_in[offset];
+ offset = regmap_out[offset] << p->regshift;
+ writel(value, p->membase + offset);
+}
+
+static int rm9k_serial_dl_read(struct uart_8250_port *up)
+{
+ return ((__raw_readl(up->port.membase + 0x10) << 8) |
+ (__raw_readl(up->port.membase + 0x08) & 0xff)) & 0xffff;
}
-static inline int map_8250_out_reg(struct uart_port *p, int offset)
+static void rm9k_serial_dl_write(struct uart_8250_port *up, int value)
{
- if (p->iotype != UPIO_RM9000)
- return offset;
- return regmap_out[offset];
+ __raw_writel(value, up->port.membase + 0x08);
+ __raw_writel(value >> 8, up->port.membase + 0x10);
}
-#else
+#endif
/* sane hardware needs no mapping */
#define map_8250_in_reg(up, offset) (offset)
#define map_8250_out_reg(up, offset) (offset)
-#endif
-
static unsigned int hub6_serial_in(struct uart_port *p, int offset)
{
offset = map_8250_in_reg(p, offset) << p->regshift;
@@ -517,12 +505,20 @@ static void set_io_from_upio(struct uart
p->serial_out = mem_serial_out;
break;
- case UPIO_RM9000:
case UPIO_MEM32:
p->serial_in = mem32_serial_in;
p->serial_out = mem32_serial_out;
break;
+#ifdef CONFIG_SERIAL_8250_RM9K
+ case UPIO_RM9000:
+ p->serial_in = rm9k_serial_in;
+ p->serial_out = rm9k_serial_out;
+ up->dl_read = rm9k_serial_dl_read;
+ up->dl_write = rm9k_serial_dl_write;
+ break;
+#endif
+
#ifdef CONFIG_MIPS_ALCHEMY
case UPIO_AU:
p->serial_in = au_serial_in;