summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMiles Bader <miles@lsi.nec.co.jp>2003-07-17 20:10:48 -0700
committerLinus Torvalds <torvalds@home.osdl.org>2003-07-17 20:10:48 -0700
commit701096cf9b0b69c4167d9010b964da2c013e2c20 (patch)
treed17e37439fa01810cfc3cd11f338cf83e5a16479 /include
parent15d7359a36fd9aa2717416421c216db8c5f371df (diff)
[PATCH] Refactor v850 UART driver
The v850 family contains several related-but-not-identical on-chip UARTs. This patch factors out the common code and uses it to implement both types (only one was supported before). Also, this patch changes the way the v850 UART is initialized, to use the same method as other linux serial drivers. This patch renames the UART code to be `v850e_uart' rather than `nb85e_uart', as the former is more correct. As this change renames some files too, the patch contains a number of whole-file add/removes.
Diffstat (limited to 'include')
-rw-r--r--include/asm-v850/anna.h15
-rw-r--r--include/asm-v850/as85ep1.h12
-rw-r--r--include/asm-v850/ma.h4
-rw-r--r--include/asm-v850/ma1.h7
-rw-r--r--include/asm-v850/nb85e_uart.h144
-rw-r--r--include/asm-v850/rte_ma1_cb.h8
-rw-r--r--include/asm-v850/rte_nb85e_cb.h8
-rw-r--r--include/asm-v850/teg.h22
-rw-r--r--include/asm-v850/v850e_uart.h77
-rw-r--r--include/asm-v850/v850e_uarta.h278
-rw-r--r--include/asm-v850/v850e_uartb.h262
-rw-r--r--include/linux/serial_core.h2
12 files changed, 657 insertions, 182 deletions
diff --git a/include/asm-v850/anna.h b/include/asm-v850/anna.h
index 44d261afa82a..1bb65a29c0b0 100644
--- a/include/asm-v850/anna.h
+++ b/include/asm-v850/anna.h
@@ -116,12 +116,15 @@ extern void anna_init_irqs (void);
/* Anna UART details (basically the same as the V850E/MA1, but 2 channels). */
-#define NB85E_UART_NUM_CHANNELS 2
-#define NB85E_UART_BASE_FREQ (SYS_CLOCK_FREQ / 2)
-#define NB85E_UART_CHIP_NAME "V850E2/NA85E2A"
+#define V850E_UART_NUM_CHANNELS 2
+#define V850E_UART_BASE_FREQ (SYS_CLOCK_FREQ / 2)
+#define V850E_UART_CHIP_NAME "V850E2/NA85E2A"
+
+/* This is the UART channel that's actually connected on the board. */
+#define V850E_UART_CONSOLE_CHANNEL 1
/* This is a function that gets called before configuring the UART. */
-#define NB85E_UART_PRE_CONFIGURE anna_uart_pre_configure
+#define V850E_UART_PRE_CONFIGURE anna_uart_pre_configure
#ifndef __ASSEMBLY__
extern void anna_uart_pre_configure (unsigned chan,
unsigned cflags, unsigned baud);
@@ -130,9 +133,9 @@ extern void anna_uart_pre_configure (unsigned chan,
/* This board supports RTS/CTS for the on-chip UART, but only for channel 1. */
/* CTS for UART channel 1 is pin P37 (bit 7 of port 3). */
-#define NB85E_UART_CTS(chan) ((chan) == 1 ? !(ANNA_PORT_IO(3) & 0x80) : 1)
+#define V850E_UART_CTS(chan) ((chan) == 1 ? !(ANNA_PORT_IO(3) & 0x80) : 1)
/* RTS for UART channel 1 is pin P07 (bit 7 of port 0). */
-#define NB85E_UART_SET_RTS(chan, val) \
+#define V850E_UART_SET_RTS(chan, val) \
do { \
if (chan == 1) { \
unsigned old = ANNA_PORT_IO(0); \
diff --git a/include/asm-v850/as85ep1.h b/include/asm-v850/as85ep1.h
index 707d40da101a..ceeb5f09f703 100644
--- a/include/asm-v850/as85ep1.h
+++ b/include/asm-v850/as85ep1.h
@@ -110,12 +110,12 @@ extern void as85ep1_init_irqs (void);
/* AS85EP1 UART details (basically the same as the V850E/MA1, but 2 channels). */
-#define NB85E_UART_NUM_CHANNELS 2
-#define NB85E_UART_BASE_FREQ (SYS_CLOCK_FREQ / 4)
-#define NB85E_UART_CHIP_NAME "V850E/NA85E"
+#define V850E_UART_NUM_CHANNELS 2
+#define V850E_UART_BASE_FREQ (SYS_CLOCK_FREQ / 4)
+#define V850E_UART_CHIP_NAME "V850E/NA85E"
/* This is a function that gets called before configuring the UART. */
-#define NB85E_UART_PRE_CONFIGURE as85ep1_uart_pre_configure
+#define V850E_UART_PRE_CONFIGURE as85ep1_uart_pre_configure
#ifndef __ASSEMBLY__
extern void as85ep1_uart_pre_configure (unsigned chan,
unsigned cflags, unsigned baud);
@@ -124,9 +124,9 @@ extern void as85ep1_uart_pre_configure (unsigned chan,
/* This board supports RTS/CTS for the on-chip UART, but only for channel 1. */
/* CTS for UART channel 1 is pin P54 (bit 4 of port 5). */
-#define NB85E_UART_CTS(chan) ((chan) == 1 ? !(AS85EP1_PORT_IO(5) & 0x10) : 1)
+#define V850E_UART_CTS(chan) ((chan) == 1 ? !(AS85EP1_PORT_IO(5) & 0x10) : 1)
/* RTS for UART channel 1 is pin P53 (bit 3 of port 5). */
-#define NB85E_UART_SET_RTS(chan, val) \
+#define V850E_UART_SET_RTS(chan, val) \
do { \
if (chan == 1) { \
unsigned old = AS85EP1_PORT_IO(5); \
diff --git a/include/asm-v850/ma.h b/include/asm-v850/ma.h
index 991a9c343ef1..89e66473a176 100644
--- a/include/asm-v850/ma.h
+++ b/include/asm-v850/ma.h
@@ -27,10 +27,10 @@
/* MA series UART details. */
-#define NB85E_UART_BASE_FREQ CPU_CLOCK_FREQ
+#define V850E_UART_BASE_FREQ CPU_CLOCK_FREQ
/* This is a function that gets called before configuring the UART. */
-#define NB85E_UART_PRE_CONFIGURE ma_uart_pre_configure
+#define V850E_UART_PRE_CONFIGURE ma_uart_pre_configure
#ifndef __ASSEMBLY__
extern void ma_uart_pre_configure (unsigned chan,
unsigned cflags, unsigned baud);
diff --git a/include/asm-v850/ma1.h b/include/asm-v850/ma1.h
index 034eea17a02f..ede1f1de2b7a 100644
--- a/include/asm-v850/ma1.h
+++ b/include/asm-v850/ma1.h
@@ -1,8 +1,8 @@
/*
* include/asm-v850/ma1.h -- V850E/MA1 cpu chip
*
- * Copyright (C) 2001,02 NEC Corporation
- * Copyright (C) 2001,02 Miles Bader <miles@gnu.org>
+ * Copyright (C) 2001,02,03 NEC Electronics Corporation
+ * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
*
* This file is subject to the terms and conditions of the GNU General
* Public License. See the file COPYING in the main directory of this
@@ -40,12 +40,11 @@
#define IRQ_INTST(n) (0x27 + (n)*4) /* UART 0-2 transmission completion */
#define IRQ_INTST_NUM 3
-/* For <asm/irq.h> */
#define NUM_CPU_IRQS 0x30
/* The MA1 has a UART with 3 channels. */
-#define NB85E_UART_NUM_CHANNELS 3
+#define V850E_UART_NUM_CHANNELS 3
#endif /* __V850_MA1_H__ */
diff --git a/include/asm-v850/nb85e_uart.h b/include/asm-v850/nb85e_uart.h
deleted file mode 100644
index ac8e8b1375fe..000000000000
--- a/include/asm-v850/nb85e_uart.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * include/asm-v850/nb85e_uart.h -- On-chip UART often used with the
- * NB85E cpu core
- *
- * Copyright (C) 2001,02 NEC Corporation
- * Copyright (C) 2001,02 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License. See the file COPYING in the main directory of this
- * archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-/* There's not actually a single UART implementation used by nb85e
- derivatives, but rather a series of implementations that are all
- `close' to one another. This file attempts to capture some
- commonality between them. */
-
-#ifndef __V850_NB85E_UART_H__
-#define __V850_NB85E_UART_H__
-
-#include <asm/types.h>
-#include <asm/machdep.h> /* Pick up chip-specific defs. */
-
-
-/* The base address of the UART control registers for channel N.
- The default is the address used on the V850E/MA1. */
-#ifndef NB85E_UART_BASE_ADDR
-#define NB85E_UART_BASE_ADDR(n) (0xFFFFFA00 + 0x10 * (n))
-#endif
-
-/* Addresses of specific UART control registers for channel N.
- The defaults are the addresses used on the V850E/MA1; if a platform
- wants to redefine any of these, it must redefine them all. */
-#ifndef NB85E_UART_ASIM_ADDR
-#define NB85E_UART_ASIM_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x0)
-#define NB85E_UART_RXB_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x2)
-#define NB85E_UART_ASIS_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x3)
-#define NB85E_UART_TXB_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x4)
-#define NB85E_UART_ASIF_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x5)
-#define NB85E_UART_CKSR_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x6)
-#define NB85E_UART_BRGC_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x7)
-#endif
-
-#ifndef NB85E_UART_CKSR_MAX_FREQ
-#define NB85E_UART_CKSR_MAX_FREQ (25*1000*1000)
-#endif
-
-/* UART config registers. */
-#define NB85E_UART_ASIM(n) (*(volatile u8 *)NB85E_UART_ASIM_ADDR(n))
-/* Control bits for config registers. */
-#define NB85E_UART_ASIM_CAE 0x80 /* clock enable */
-#define NB85E_UART_ASIM_TXE 0x40 /* transmit enable */
-#define NB85E_UART_ASIM_RXE 0x20 /* receive enable */
-#define NB85E_UART_ASIM_PS_MASK 0x18 /* mask covering parity-select bits */
-#define NB85E_UART_ASIM_PS_NONE 0x00 /* no parity */
-#define NB85E_UART_ASIM_PS_ZERO 0x08 /* zero parity */
-#define NB85E_UART_ASIM_PS_ODD 0x10 /* odd parity */
-#define NB85E_UART_ASIM_PS_EVEN 0x18 /* even parity */
-#define NB85E_UART_ASIM_CL_8 0x04 /* char len is 8 bits (otherwise, 7) */
-#define NB85E_UART_ASIM_SL_2 0x02 /* 2 stop bits (otherwise, 1) */
-#define NB85E_UART_ASIM_ISRM 0x01 /* generate INTSR interrupt on errors
- (otherwise, generate INTSER) */
-
-/* UART serial interface status registers. */
-#define NB85E_UART_ASIS(n) (*(volatile u8 *)NB85E_UART_ASIS_ADDR(n))
-/* Control bits for status registers. */
-#define NB85E_UART_ASIS_PE 0x04 /* parity error */
-#define NB85E_UART_ASIS_FE 0x02 /* framing error */
-#define NB85E_UART_ASIS_OVE 0x01 /* overrun error */
-
-/* UART serial interface transmission status registers. */
-#define NB85E_UART_ASIF(n) (*(volatile u8 *)NB85E_UART_ASIF_ADDR(n))
-#define NB85E_UART_ASIF_TXBF 0x02 /* transmit buffer flag (data in TXB) */
-#define NB85E_UART_ASIF_TXSF 0x01 /* transmit shift flag (sending data) */
-
-/* UART receive buffer register. */
-#define NB85E_UART_RXB(n) (*(volatile u8 *)NB85E_UART_RXB_ADDR(n))
-
-/* UART transmit buffer register. */
-#define NB85E_UART_TXB(n) (*(volatile u8 *)NB85E_UART_TXB_ADDR(n))
-
-/* UART baud-rate generator control registers. */
-#define NB85E_UART_CKSR(n) (*(volatile u8 *)NB85E_UART_CKSR_ADDR(n))
-#define NB85E_UART_CKSR_MAX 11
-#define NB85E_UART_BRGC(n) (*(volatile u8 *)NB85E_UART_BRGC_ADDR(n))
-
-
-/* This UART doesn't implement RTS/CTS by default, but some platforms
- implement them externally, so check to see if <asm/machdep.h> defined
- anything. */
-#ifdef NB85E_UART_CTS
-#define nb85e_uart_cts(n) NB85E_UART_CTS(n)
-#else
-#define nb85e_uart_cts(n) (1)
-#endif
-
-/* Do the same for RTS. */
-#ifdef NB85E_UART_SET_RTS
-#define nb85e_uart_set_rts(n,v) NB85E_UART_SET_RTS(n,v)
-#else
-#define nb85e_uart_set_rts(n,v) ((void)0)
-#endif
-
-/* Return true if all characters awaiting transmission on uart channel N
- have been transmitted. */
-#define nb85e_uart_xmit_done(n) \
- (! (NB85E_UART_ASIF(n) & NB85E_UART_ASIF_TXBF))
-/* Wait for this to be true. */
-#define nb85e_uart_wait_for_xmit_done(n) \
- do { } while (! nb85e_uart_xmit_done (n))
-
-/* Return true if uart channel N is ready to transmit a character. */
-#define nb85e_uart_xmit_ok(n) \
- (nb85e_uart_xmit_done(n) && nb85e_uart_cts(n))
-/* Wait for this to be true. */
-#define nb85e_uart_wait_for_xmit_ok(n) \
- do { } while (! nb85e_uart_xmit_ok (n))
-
-/* Write character CH to uart channel N. */
-#define nb85e_uart_putc(n, ch) (NB85E_UART_TXB(n) = (ch))
-
-
-#define NB85E_UART_MINOR_BASE 64
-
-
-#ifndef __ASSEMBLY__
-
-/* Setup a console using channel 0 of the builtin uart. */
-extern void nb85e_uart_cons_init (unsigned chan);
-
-/* Configure and turn on uart channel CHAN, using the termios `control
- modes' bits in CFLAGS, and a baud-rate of BAUD. */
-void nb85e_uart_configure (unsigned chan, unsigned cflags, unsigned baud);
-
-/* If the macro NB85E_UART_PRE_CONFIGURE is defined (presumably by a
- <asm/machdep.h>), it is called from nb85e_uart_pre_configure before
- anything else is done, with interrupts disabled. */
-
-#endif /* !__ASSEMBLY__ */
-
-
-#endif /* __V850_NB85E_UART_H__ */
diff --git a/include/asm-v850/rte_ma1_cb.h b/include/asm-v850/rte_ma1_cb.h
index c9e7fb89e34d..94c287bdbc70 100644
--- a/include/asm-v850/rte_ma1_cb.h
+++ b/include/asm-v850/rte_ma1_cb.h
@@ -98,8 +98,8 @@
/* Override the basic MA uart pre-initialization so that we can
initialize extra stuff. */
-#undef NB85E_UART_PRE_CONFIGURE /* should be defined by <asm/ma.h> */
-#define NB85E_UART_PRE_CONFIGURE rte_ma1_cb_uart_pre_configure
+#undef V850E_UART_PRE_CONFIGURE /* should be defined by <asm/ma.h> */
+#define V850E_UART_PRE_CONFIGURE rte_ma1_cb_uart_pre_configure
#ifndef __ASSEMBLY__
extern void rte_ma1_cb_uart_pre_configure (unsigned chan,
unsigned cflags, unsigned baud);
@@ -108,9 +108,9 @@ extern void rte_ma1_cb_uart_pre_configure (unsigned chan,
/* This board supports RTS/CTS for the on-chip UART, but only for channel 0. */
/* CTS for UART channel 0 is pin P43 (bit 3 of port 4). */
-#define NB85E_UART_CTS(chan) ((chan) == 0 ? !(MA_PORT4_IO & 0x8) : 1)
+#define V850E_UART_CTS(chan) ((chan) == 0 ? !(MA_PORT4_IO & 0x8) : 1)
/* RTS for UART channel 0 is pin P42 (bit 2 of port 4). */
-#define NB85E_UART_SET_RTS(chan, val) \
+#define V850E_UART_SET_RTS(chan, val) \
do { \
if (chan == 0) { \
unsigned old = MA_PORT4_IO; \
diff --git a/include/asm-v850/rte_nb85e_cb.h b/include/asm-v850/rte_nb85e_cb.h
index 77aa72f8cc81..f56591cad90a 100644
--- a/include/asm-v850/rte_nb85e_cb.h
+++ b/include/asm-v850/rte_nb85e_cb.h
@@ -89,8 +89,8 @@
/* Override the basic TEG UART pre-initialization so that we can
initialize extra stuff. */
-#undef NB85E_UART_PRE_CONFIGURE /* should be defined by <asm/teg.h> */
-#define NB85E_UART_PRE_CONFIGURE rte_nb85e_cb_uart_pre_configure
+#undef V850E_UART_PRE_CONFIGURE /* should be defined by <asm/teg.h> */
+#define V850E_UART_PRE_CONFIGURE rte_nb85e_cb_uart_pre_configure
#ifndef __ASSEMBLY__
extern void rte_nb85e_cb_uart_pre_configure (unsigned chan,
unsigned cflags, unsigned baud);
@@ -99,9 +99,9 @@ extern void rte_nb85e_cb_uart_pre_configure (unsigned chan,
/* This board supports RTS/CTS for the on-chip UART. */
/* CTS is pin P00. */
-#define NB85E_UART_CTS(chan) (! (TEG_PORT0_IO & 0x1))
+#define V850E_UART_CTS(chan) (! (TEG_PORT0_IO & 0x1))
/* RTS is pin P02. */
-#define NB85E_UART_SET_RTS(chan, val) \
+#define V850E_UART_SET_RTS(chan, val) \
do { \
unsigned old = TEG_PORT0_IO; \
TEG_PORT0_IO = val ? (old & ~0x4) : (old | 0x4); \
diff --git a/include/asm-v850/teg.h b/include/asm-v850/teg.h
index 0f641a4e6eb9..acc8c7d95329 100644
--- a/include/asm-v850/teg.h
+++ b/include/asm-v850/teg.h
@@ -51,18 +51,18 @@
/* TEG UART details. */
-#define NB85E_UART_BASE_ADDR(n) (0xFFFFF600 + 0x10 * (n))
-#define NB85E_UART_ASIM_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x0)
-#define NB85E_UART_ASIS_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x2)
-#define NB85E_UART_ASIF_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x4)
-#define NB85E_UART_CKSR_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x6)
-#define NB85E_UART_BRGC_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0x8)
-#define NB85E_UART_TXB_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0xA)
-#define NB85E_UART_RXB_ADDR(n) (NB85E_UART_BASE_ADDR(n) + 0xC)
-#define NB85E_UART_NUM_CHANNELS 1
-#define NB85E_UART_BASE_FREQ CPU_CLOCK_FREQ
+#define V850E_UART_BASE_ADDR(n) (0xFFFFF600 + 0x10 * (n))
+#define V850E_UART_ASIM_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x0)
+#define V850E_UART_ASIS_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x2)
+#define V850E_UART_ASIF_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x4)
+#define V850E_UART_CKSR_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x6)
+#define V850E_UART_BRGC_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x8)
+#define V850E_UART_TXB_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0xA)
+#define V850E_UART_RXB_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0xC)
+#define V850E_UART_NUM_CHANNELS 1
+#define V850E_UART_BASE_FREQ CPU_CLOCK_FREQ
/* This is a function that gets called before configuring the UART. */
-#define NB85E_UART_PRE_CONFIGURE teg_uart_pre_configure
+#define V850E_UART_PRE_CONFIGURE teg_uart_pre_configure
#ifndef __ASSEMBLY__
extern void teg_uart_pre_configure (unsigned chan,
unsigned cflags, unsigned baud);
diff --git a/include/asm-v850/v850e_uart.h b/include/asm-v850/v850e_uart.h
new file mode 100644
index 000000000000..5930d5990b19
--- /dev/null
+++ b/include/asm-v850/v850e_uart.h
@@ -0,0 +1,77 @@
+/*
+ * include/asm-v850/v850e_uart.h -- common V850E on-chip UART driver
+ *
+ * Copyright (C) 2001,02,03 NEC Electronics Corporation
+ * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * Written by Miles Bader <miles@gnu.org>
+ */
+
+/* There's not actually a single UART implementation used by V850E CPUs,
+ but rather a series of implementations that are all `close' to one
+ another. This file corresponds to the single driver which handles all
+ of them. */
+
+#ifndef __V850_V850E_UART_H__
+#define __V850_V850E_UART_H__
+
+#include <linux/config.h>
+#include <linux/termios.h>
+
+#include <asm/v850e_utils.h>
+#include <asm/types.h>
+#include <asm/machdep.h> /* Pick up chip-specific defs. */
+
+
+/* Include model-specific definitions. */
+#ifdef CONFIG_V850E_UART
+# ifdef CONFIG_V850E_UARTB
+# include <asm-v850/v850e_uartb.h>
+# else
+# include <asm-v850/v850e_uarta.h> /* original V850E UART */
+# endif
+#endif
+
+
+/* Optional capabilities some hardware provides. */
+
+/* This UART doesn't implement RTS/CTS by default, but some platforms
+ implement them externally, so check to see if <asm/machdep.h> defined
+ anything. */
+#ifdef V850E_UART_CTS
+#define v850e_uart_cts(n) V850E_UART_CTS(n)
+#else
+#define v850e_uart_cts(n) (1)
+#endif
+
+/* Do the same for RTS. */
+#ifdef V850E_UART_SET_RTS
+#define v850e_uart_set_rts(n,v) V850E_UART_SET_RTS(n,v)
+#else
+#define v850e_uart_set_rts(n,v) ((void)0)
+#endif
+
+
+/* This is the serial channel to use for the boot console (if desired). */
+#ifndef V850E_UART_CONSOLE_CHANNEL
+# define V850E_UART_CONSOLE_CHANNEL 0
+#endif
+
+
+#ifndef __ASSEMBLY__
+
+/* Setup a console using channel 0 of the builtin uart. */
+extern void v850e_uart_cons_init (unsigned chan);
+
+/* Configure and turn on uart channel CHAN, using the termios `control
+ modes' bits in CFLAGS, and a baud-rate of BAUD. */
+void v850e_uart_configure (unsigned chan, unsigned cflags, unsigned baud);
+
+#endif /* !__ASSEMBLY__ */
+
+
+#endif /* __V850_V850E_UART_H__ */
diff --git a/include/asm-v850/v850e_uarta.h b/include/asm-v850/v850e_uarta.h
new file mode 100644
index 000000000000..e483e0950725
--- /dev/null
+++ b/include/asm-v850/v850e_uarta.h
@@ -0,0 +1,278 @@
+/*
+ * include/asm-v850/v850e_uarta.h -- original V850E on-chip UART
+ *
+ * Copyright (C) 2001,02,03 NEC Electronics Corporation
+ * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * Written by Miles Bader <miles@gnu.org>
+ */
+
+/* This is the original V850E UART implementation is called just `UART' in
+ the docs, but we name this header file <asm/v850e_uarta.h> because the
+ name <asm/v850e_uart.h> is used for the common driver that handles both
+ `UART' and `UARTB' implementations. */
+
+#ifndef __V850_V850E_UARTA_H__
+#define __V850_V850E_UARTA_H__
+
+
+/* Raw hardware interface. */
+
+/* The base address of the UART control registers for channel N.
+ The default is the address used on the V850E/MA1. */
+#ifndef V850E_UART_BASE_ADDR
+#define V850E_UART_BASE_ADDR(n) (0xFFFFFA00 + 0x10 * (n))
+#endif
+
+/* Addresses of specific UART control registers for channel N.
+ The defaults are the addresses used on the V850E/MA1; if a platform
+ wants to redefine any of these, it must redefine them all. */
+#ifndef V850E_UART_ASIM_ADDR
+#define V850E_UART_ASIM_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x0)
+#define V850E_UART_RXB_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x2)
+#define V850E_UART_ASIS_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x3)
+#define V850E_UART_TXB_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x4)
+#define V850E_UART_ASIF_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x5)
+#define V850E_UART_CKSR_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x6)
+#define V850E_UART_BRGC_ADDR(n) (V850E_UART_BASE_ADDR(n) + 0x7)
+#endif
+
+/* UART config registers. */
+#define V850E_UART_ASIM(n) (*(volatile u8 *)V850E_UART_ASIM_ADDR(n))
+/* Control bits for config registers. */
+#define V850E_UART_ASIM_CAE 0x80 /* clock enable */
+#define V850E_UART_ASIM_TXE 0x40 /* transmit enable */
+#define V850E_UART_ASIM_RXE 0x20 /* receive enable */
+#define V850E_UART_ASIM_PS_MASK 0x18 /* mask covering parity-select bits */
+#define V850E_UART_ASIM_PS_NONE 0x00 /* no parity */
+#define V850E_UART_ASIM_PS_ZERO 0x08 /* zero parity */
+#define V850E_UART_ASIM_PS_ODD 0x10 /* odd parity */
+#define V850E_UART_ASIM_PS_EVEN 0x18 /* even parity */
+#define V850E_UART_ASIM_CL_8 0x04 /* char len is 8 bits (otherwise, 7) */
+#define V850E_UART_ASIM_SL_2 0x02 /* 2 stop bits (otherwise, 1) */
+#define V850E_UART_ASIM_ISRM 0x01 /* generate INTSR interrupt on errors
+ (otherwise, generate INTSER) */
+
+/* UART serial interface status registers. */
+#define V850E_UART_ASIS(n) (*(volatile u8 *)V850E_UART_ASIS_ADDR(n))
+/* Control bits for status registers. */
+#define V850E_UART_ASIS_PE 0x04 /* parity error */
+#define V850E_UART_ASIS_FE 0x02 /* framing error */
+#define V850E_UART_ASIS_OVE 0x01 /* overrun error */
+
+/* UART serial interface transmission status registers. */
+#define V850E_UART_ASIF(n) (*(volatile u8 *)V850E_UART_ASIF_ADDR(n))
+#define V850E_UART_ASIF_TXBF 0x02 /* transmit buffer flag (data in TXB) */
+#define V850E_UART_ASIF_TXSF 0x01 /* transmit shift flag (sending data) */
+
+/* UART receive buffer register. */
+#define V850E_UART_RXB(n) (*(volatile u8 *)V850E_UART_RXB_ADDR(n))
+
+/* UART transmit buffer register. */
+#define V850E_UART_TXB(n) (*(volatile u8 *)V850E_UART_TXB_ADDR(n))
+
+/* UART baud-rate generator control registers. */
+#define V850E_UART_CKSR(n) (*(volatile u8 *)V850E_UART_CKSR_ADDR(n))
+#define V850E_UART_CKSR_MAX 11
+#define V850E_UART_BRGC(n) (*(volatile u8 *)V850E_UART_BRGC_ADDR(n))
+#define V850E_UART_BRGC_MIN 8
+
+
+#ifndef V850E_UART_CKSR_MAX_FREQ
+#define V850E_UART_CKSR_MAX_FREQ (25*1000*1000)
+#endif
+
+/* Calculate the minimum value for CKSR on this processor. */
+static inline unsigned v850e_uart_cksr_min (void)
+{
+ int min = 0;
+ unsigned freq = V850E_UART_BASE_FREQ;
+ while (freq > V850E_UART_CKSR_MAX_FREQ) {
+ freq >>= 1;
+ min++;
+ }
+ return min;
+}
+
+
+/* Slightly abstract interface used by driver. */
+
+
+/* Interrupts used by the UART. */
+
+/* Received when the most recently transmitted character has been sent. */
+#define V850E_UART_TX_IRQ(chan) IRQ_INTST (chan)
+/* Received when a new character has been received. */
+#define V850E_UART_RX_IRQ(chan) IRQ_INTSR (chan)
+
+
+/* UART clock generator interface. */
+
+/* This type encapsulates a particular uart frequency. */
+typedef struct {
+ unsigned clk_divlog2;
+ unsigned brgen_count;
+} v850e_uart_speed_t;
+
+/* Calculate a uart speed from BAUD for this uart. */
+static inline v850e_uart_speed_t v850e_uart_calc_speed (unsigned baud)
+{
+ v850e_uart_speed_t speed;
+
+ /* Calculate the log2 clock divider and baud-rate counter values
+ (note that the UART divides the resulting clock by 2, so
+ multiply BAUD by 2 here to compensate). */
+ calc_counter_params (V850E_UART_BASE_FREQ, baud * 2,
+ v850e_uart_cksr_min(),
+ V850E_UART_CKSR_MAX, 8/*bits*/,
+ &speed.clk_divlog2, &speed.brgen_count);
+
+ return speed;
+}
+
+/* Return the current speed of uart channel CHAN. */
+static inline v850e_uart_speed_t v850e_uart_speed (unsigned chan)
+{
+ v850e_uart_speed_t speed;
+ speed.clk_divlog2 = V850E_UART_CKSR (chan);
+ speed.brgen_count = V850E_UART_BRGC (chan);
+ return speed;
+}
+
+/* Set the current speed of uart channel CHAN. */
+static inline void v850e_uart_set_speed(unsigned chan,v850e_uart_speed_t speed)
+{
+ V850E_UART_CKSR (chan) = speed.clk_divlog2;
+ V850E_UART_BRGC (chan) = speed.brgen_count;
+}
+
+static inline int
+v850e_uart_speed_eq (v850e_uart_speed_t speed1, v850e_uart_speed_t speed2)
+{
+ return speed1.clk_divlog2 == speed2.clk_divlog2
+ && speed1.brgen_count == speed2.brgen_count;
+}
+
+/* Minimum baud rate possible. */
+#define v850e_uart_min_baud() \
+ ((V850E_UART_BASE_FREQ >> V850E_UART_CKSR_MAX) / (2 * 255) + 1)
+
+/* Maximum baud rate possible. The error is quite high at max, though. */
+#define v850e_uart_max_baud() \
+ ((V850E_UART_BASE_FREQ >> v850e_uart_cksr_min()) / (2 *V850E_UART_BRGC_MIN))
+
+/* The `maximum' clock rate the uart can used, which is wanted (though not
+ really used in any useful way) by the serial framework. */
+#define v850e_uart_max_clock() \
+ ((V850E_UART_BASE_FREQ >> v850e_uart_cksr_min()) / 2)
+
+
+/* UART configuration interface. */
+
+/* Type of the uart config register; must be a scalar. */
+typedef u16 v850e_uart_config_t;
+
+/* The uart hardware config register for channel CHAN. */
+#define V850E_UART_CONFIG(chan) V850E_UART_ASIM (chan)
+
+/* This config bit set if the uart is enabled. */
+#define V850E_UART_CONFIG_ENABLED V850E_UART_ASIM_CAE
+/* If the uart _isn't_ enabled, store this value to it to do so. */
+#define V850E_UART_CONFIG_INIT V850E_UART_ASIM_CAE
+/* Store this config value to disable the uart channel completely. */
+#define V850E_UART_CONFIG_FINI 0
+
+/* Setting/clearing these bits enable/disable TX/RX, respectively (but
+ otherwise generally leave things running). */
+#define V850E_UART_CONFIG_RX_ENABLE V850E_UART_ASIM_RXE
+#define V850E_UART_CONFIG_TX_ENABLE V850E_UART_ASIM_TXE
+
+/* These masks define which config bits affect TX/RX modes, respectively. */
+#define V850E_UART_CONFIG_RX_BITS \
+ (V850E_UART_ASIM_PS_MASK | V850E_UART_ASIM_CL_8 | V850E_UART_ASIM_ISRM)
+#define V850E_UART_CONFIG_TX_BITS \
+ (V850E_UART_ASIM_PS_MASK | V850E_UART_ASIM_CL_8 | V850E_UART_ASIM_SL_2)
+
+static inline v850e_uart_config_t v850e_uart_calc_config (unsigned cflags)
+{
+ v850e_uart_config_t config = 0;
+
+ /* Figure out new configuration of control register. */
+ if (cflags & CSTOPB)
+ /* Number of stop bits, 1 or 2. */
+ config |= V850E_UART_ASIM_SL_2;
+ if ((cflags & CSIZE) == CS8)
+ /* Number of data bits, 7 or 8. */
+ config |= V850E_UART_ASIM_CL_8;
+ if (! (cflags & PARENB))
+ /* No parity check/generation. */
+ config |= V850E_UART_ASIM_PS_NONE;
+ else if (cflags & PARODD)
+ /* Odd parity check/generation. */
+ config |= V850E_UART_ASIM_PS_ODD;
+ else
+ /* Even parity check/generation. */
+ config |= V850E_UART_ASIM_PS_EVEN;
+ if (cflags & CREAD)
+ /* Reading enabled. */
+ config |= V850E_UART_ASIM_RXE;
+
+ config |= V850E_UART_ASIM_CAE;
+ config |= V850E_UART_ASIM_TXE; /* Writing is always enabled. */
+ config |= V850E_UART_ASIM_ISRM; /* Errors generate a read-irq. */
+
+ return config;
+}
+
+/* This should delay as long as necessary for a recently written config
+ setting to settle, before we turn the uart back on. */
+static inline void
+v850e_uart_config_delay (v850e_uart_config_t config, v850e_uart_speed_t speed)
+{
+ /* The UART may not be reset properly unless we wait at least 2
+ `basic-clocks' until turning on the TXE/RXE bits again.
+ A `basic clock' is the clock used by the baud-rate generator,
+ i.e., the cpu clock divided by the 2^new_clk_divlog2.
+ The loop takes 2 insns, so loop CYCLES / 2 times. */
+ register unsigned count = 1 << speed.clk_divlog2;
+ while (--count != 0)
+ /* nothing */;
+}
+
+
+/* RX/TX interface. */
+
+/* Return true if all characters awaiting transmission on uart channel N
+ have been transmitted. */
+#define v850e_uart_xmit_done(n) \
+ (! (V850E_UART_ASIF(n) & V850E_UART_ASIF_TXBF))
+/* Wait for this to be true. */
+#define v850e_uart_wait_for_xmit_done(n) \
+ do { } while (! v850e_uart_xmit_done (n))
+
+/* Return true if uart channel N is ready to transmit a character. */
+#define v850e_uart_xmit_ok(n) \
+ (v850e_uart_xmit_done(n) && v850e_uart_cts(n))
+/* Wait for this to be true. */
+#define v850e_uart_wait_for_xmit_ok(n) \
+ do { } while (! v850e_uart_xmit_ok (n))
+
+/* Write character CH to uart channel CHAN. */
+#define v850e_uart_putc(chan, ch) (V850E_UART_TXB(chan) = (ch))
+
+/* Return latest character read on channel CHAN. */
+#define v850e_uart_getc(chan) V850E_UART_RXB (chan)
+
+/* Return bit-mask of uart error status. */
+#define v850e_uart_err(chan) V850E_UART_ASIS (chan)
+/* Various error bits set in the error result. */
+#define V850E_UART_ERR_OVERRUN V850E_UART_ASIS_OVE
+#define V850E_UART_ERR_FRAME V850E_UART_ASIS_FE
+#define V850E_UART_ERR_PARITY V850E_UART_ASIS_PE
+
+
+#endif /* __V850_V850E_UARTA_H__ */
diff --git a/include/asm-v850/v850e_uartb.h b/include/asm-v850/v850e_uartb.h
new file mode 100644
index 000000000000..6d4767d5a835
--- /dev/null
+++ b/include/asm-v850/v850e_uartb.h
@@ -0,0 +1,262 @@
+/*
+ * include/asm-v850/v850e_uartb.h -- V850E on-chip `UARTB' UART
+ *
+ * Copyright (C) 2001,02,03 NEC Electronics Corporation
+ * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file COPYING in the main directory of this
+ * archive for more details.
+ *
+ * Written by Miles Bader <miles@gnu.org>
+ */
+
+/* The V850E UARTB is basically a superset of the original V850E UART, but
+ even where it's the same, the names and details have changed a bit.
+ It's similar enough to use the same driver (v850e_uart.c), but the
+ details have been abstracted slightly to do so. */
+
+#ifndef __V850_V850E_UARTB_H__
+#define __V850_V850E_UARTB_H__
+
+
+/* Raw hardware interface. */
+
+#define V850E_UARTB_BASE_ADDR(n) (0xFFFFFA00 + 0x10 * (n))
+
+/* Addresses of specific UART control registers for channel N. */
+#define V850E_UARTB_CTL0_ADDR(n) (V850E_UARTB_BASE_ADDR(n) + 0x0)
+#define V850E_UARTB_CTL2_ADDR(n) (V850E_UARTB_BASE_ADDR(n) + 0x2)
+#define V850E_UARTB_STR_ADDR(n) (V850E_UARTB_BASE_ADDR(n) + 0x4)
+#define V850E_UARTB_RX_ADDR(n) (V850E_UARTB_BASE_ADDR(n) + 0x6)
+#define V850E_UARTB_RXAP_ADDR(n) (V850E_UARTB_BASE_ADDR(n) + 0x6)
+#define V850E_UARTB_TX_ADDR(n) (V850E_UARTB_BASE_ADDR(n) + 0x8)
+#define V850E_UARTB_FIC0_ADDR(n) (V850E_UARTB_BASE_ADDR(n) + 0xA)
+#define V850E_UARTB_FIC1_ADDR(n) (V850E_UARTB_BASE_ADDR(n) + 0xB)
+#define V850E_UARTB_FIC2_ADDR(n) (V850E_UARTB_BASE_ADDR(n) + 0xC)
+#define V850E_UARTB_FIS0_ADDR(n) (V850E_UARTB_BASE_ADDR(n) + 0xE)
+#define V850E_UARTB_FIS1_ADDR(n) (V850E_UARTB_BASE_ADDR(n) + 0xF)
+
+/* UARTB control register 0 (general config). */
+#define V850E_UARTB_CTL0(n) (*(volatile u8 *)V850E_UARTB_CTL0_ADDR(n))
+/* Control bits for config registers. */
+#define V850E_UARTB_CTL0_PWR 0x80 /* clock enable */
+#define V850E_UARTB_CTL0_TXE 0x40 /* transmit enable */
+#define V850E_UARTB_CTL0_RXE 0x20 /* receive enable */
+#define V850E_UARTB_CTL0_DIR 0x10 /* */
+#define V850E_UARTB_CTL0_PS1 0x08 /* parity */
+#define V850E_UARTB_CTL0_PS0 0x04 /* parity */
+#define V850E_UARTB_CTL0_CL 0x02 /* char len 1:8bit, 0:7bit */
+#define V850E_UARTB_CTL0_SL 0x01 /* stop bit 1:2bit, 0:1bit */
+#define V850E_UARTB_CTL0_PS_MASK 0x0C /* mask covering parity bits */
+#define V850E_UARTB_CTL0_PS_NONE 0x00 /* no parity */
+#define V850E_UARTB_CTL0_PS_ZERO 0x04 /* zero parity */
+#define V850E_UARTB_CTL0_PS_ODD 0x08 /* odd parity */
+#define V850E_UARTB_CTL0_PS_EVEN 0x0C /* even parity */
+#define V850E_UARTB_CTL0_CL_8 0x02 /* char len 1:8bit, 0:7bit */
+#define V850E_UARTB_CTL0_SL_2 0x01 /* stop bit 1:2bit, 0:1bit */
+
+/* UARTB control register 2 (clock divider). */
+#define V850E_UARTB_CTL2(n) (*(volatile u16 *)V850E_UARTB_CTL2_ADDR(n))
+#define V850E_UARTB_CTL2_MIN 4
+#define V850E_UARTB_CTL2_MAX 0xFFFF
+
+/* UARTB serial interface status register. */
+#define V850E_UARTB_STR(n) (*(volatile u8 *)V850E_UARTB_STR_ADDR(n))
+/* Control bits for status registers. */
+#define V850E_UARTB_STR_TSF 0x80 /* UBTX or FIFO exist data */
+#define V850E_UARTB_STR_OVF 0x08 /* overflow error */
+#define V850E_UARTB_STR_PE 0x04 /* parity error */
+#define V850E_UARTB_STR_FE 0x02 /* framing error */
+#define V850E_UARTB_STR_OVE 0x01 /* overrun error */
+
+/* UARTB receive data register. */
+#define V850E_UARTB_RX(n) (*(volatile u8 *)V850E_UARTB_RX_ADDR(n))
+#define V850E_UARTB_RXAP(n) (*(volatile u16 *)V850E_UARTB_RXAP_ADDR(n))
+/* Control bits for status registers. */
+#define V850E_UARTB_RXAP_PEF 0x0200 /* parity error */
+#define V850E_UARTB_RXAP_FEF 0x0100 /* framing error */
+
+/* UARTB transmit data register. */
+#define V850E_UARTB_TX(n) (*(volatile u8 *)V850E_UARTB_TX_ADDR(n))
+
+/* UARTB FIFO control register 0. */
+#define V850E_UARTB_FIC0(n) (*(volatile u8 *)V850E_UARTB_FIC0_ADDR(n))
+
+/* UARTB FIFO control register 1. */
+#define V850E_UARTB_FIC1(n) (*(volatile u8 *)V850E_UARTB_FIC1_ADDR(n))
+
+/* UARTB FIFO control register 2. */
+#define V850E_UARTB_FIC2(n) (*(volatile u16 *)V850E_UARTB_FIC2_ADDR(n))
+
+/* UARTB FIFO status register 0. */
+#define V850E_UARTB_FIS0(n) (*(volatile u8 *)V850E_UARTB_FIS0_ADDR(n))
+
+/* UARTB FIFO status register 1. */
+#define V850E_UARTB_FIS1(n) (*(volatile u8 *)V850E_UARTB_FIS1_ADDR(n))
+
+
+/* Slightly abstract interface used by driver. */
+
+
+/* Interrupts used by the UART. */
+
+/* Received when the most recently transmitted character has been sent. */
+#define V850E_UART_TX_IRQ(chan) IRQ_INTUBTIT (chan)
+/* Received when a new character has been received. */
+#define V850E_UART_RX_IRQ(chan) IRQ_INTUBTIR (chan)
+
+/* Use by serial driver for information purposes. */
+#define V850E_UART_BASE_ADDR(chan) V850E_UARTB_BASE_ADDR(chan)
+
+
+/* UART clock generator interface. */
+
+/* This type encapsulates a particular uart frequency. */
+typedef u16 v850e_uart_speed_t;
+
+/* Calculate a uart speed from BAUD for this uart. */
+static inline v850e_uart_speed_t v850e_uart_calc_speed (unsigned baud)
+{
+ v850e_uart_speed_t speed;
+
+ /*
+ * V850E/ME2 UARTB baud rate is determined by the value of UBCTL2
+ * fx = V850E_UARTB_BASE_FREQ = CPU_CLOCK_FREQ/4
+ * baud = fx / 2*speed [ speed >= 4 ]
+ */
+ speed = V850E_UARTB_CTL2_MIN;
+ while (((V850E_UARTB_BASE_FREQ / 2) / speed ) > baud)
+ speed++;
+
+ return speed;
+}
+
+/* Return the current speed of uart channel CHAN. */
+#define v850e_uart_speed(chan) V850E_UARTB_CTL2 (chan)
+
+/* Set the current speed of uart channel CHAN. */
+#define v850e_uart_set_speed(chan, speed) (V850E_UARTB_CTL2 (chan) = (speed))
+
+/* Return true if SPEED1 and SPEED2 are the same. */
+#define v850e_uart_speed_eq(speed1, speed2) ((speed1) == (speed2))
+
+/* Minimum baud rate possible. */
+#define v850e_uart_min_baud() \
+ ((V850E_UARTB_BASE_FREQ / 2) / V850E_UARTB_CTL2_MAX)
+
+/* Maximum baud rate possible. The error is quite high at max, though. */
+#define v850e_uart_max_baud() \
+ ((V850E_UARTB_BASE_FREQ / 2) / V850E_UARTB_CTL2_MIN)
+
+/* The `maximum' clock rate the uart can used, which is wanted (though not
+ really used in any useful way) by the serial framework. */
+#define v850e_uart_max_clock() \
+ (V850E_UARTB_BASE_FREQ / 2)
+
+
+/* UART configuration interface. */
+
+/* Type of the uart config register; must be a scalar. */
+typedef u16 v850e_uart_config_t;
+
+/* The uart hardware config register for channel CHAN. */
+#define V850E_UART_CONFIG(chan) V850E_UARTB_CTL0 (chan)
+
+/* This config bit set if the uart is enabled. */
+#define V850E_UART_CONFIG_ENABLED V850E_UARTB_CTL0_PWR
+/* If the uart _isn't_ enabled, store this value to it to do so. */
+#define V850E_UART_CONFIG_INIT V850E_UARTB_CTL0_PWR
+/* Store this config value to disable the uart channel completely. */
+#define V850E_UART_CONFIG_FINI 0
+
+/* Setting/clearing these bits enable/disable TX/RX, respectively (but
+ otherwise generally leave things running). */
+#define V850E_UART_CONFIG_RX_ENABLE V850E_UARTB_CTL0_RXE
+#define V850E_UART_CONFIG_TX_ENABLE V850E_UARTB_CTL0_TXE
+
+/* These masks define which config bits affect TX/RX modes, respectively. */
+#define V850E_UART_CONFIG_RX_BITS \
+ (V850E_UARTB_CTL0_PS_MASK | V850E_UARTB_CTL0_CL_8)
+#define V850E_UART_CONFIG_TX_BITS \
+ (V850E_UARTB_CTL0_PS_MASK | V850E_UARTB_CTL0_CL_8 | V850E_UARTB_CTL0_SL_2)
+
+static inline v850e_uart_config_t v850e_uart_calc_config (unsigned cflags)
+{
+ v850e_uart_config_t config = 0;
+
+ /* Figure out new configuration of control register. */
+ if (cflags & CSTOPB)
+ /* Number of stop bits, 1 or 2. */
+ config |= V850E_UARTB_CTL0_SL_2;
+ if ((cflags & CSIZE) == CS8)
+ /* Number of data bits, 7 or 8. */
+ config |= V850E_UARTB_CTL0_CL_8;
+ if (! (cflags & PARENB))
+ /* No parity check/generation. */
+ config |= V850E_UARTB_CTL0_PS_NONE;
+ else if (cflags & PARODD)
+ /* Odd parity check/generation. */
+ config |= V850E_UARTB_CTL0_PS_ODD;
+ else
+ /* Even parity check/generation. */
+ config |= V850E_UARTB_CTL0_PS_EVEN;
+ if (cflags & CREAD)
+ /* Reading enabled. */
+ config |= V850E_UARTB_CTL0_RXE;
+
+ config |= V850E_UARTB_CTL0_PWR;
+ config |= V850E_UARTB_CTL0_TXE; /* Writing is always enabled. */
+ config |= V850E_UARTB_CTL0_DIR; /* LSB first. */
+
+ return config;
+}
+
+/* This should delay as long as necessary for a recently written config
+ setting to settle, before we turn the uart back on. */
+static inline void
+v850e_uart_config_delay (v850e_uart_config_t config, v850e_uart_speed_t speed)
+{
+ /* The UART may not be reset properly unless we wait at least 2
+ `basic-clocks' until turning on the TXE/RXE bits again.
+ A `basic clock' is the clock used by the baud-rate generator,
+ i.e., the cpu clock divided by the 2^new_clk_divlog2.
+ The loop takes 2 insns, so loop CYCLES / 2 times. */
+ register unsigned count = 1 << speed;
+ while (--count != 0)
+ /* nothing */;
+}
+
+
+/* RX/TX interface. */
+
+/* Return true if all characters awaiting transmission on uart channel N
+ have been transmitted. */
+#define v850e_uart_xmit_done(n) \
+ (! (V850E_UARTB_STR(n) & V850E_UARTB_STR_TSF))
+/* Wait for this to be true. */
+#define v850e_uart_wait_for_xmit_done(n) \
+ do { } while (! v850e_uart_xmit_done (n))
+
+/* Return true if uart channel N is ready to transmit a character. */
+#define v850e_uart_xmit_ok(n) \
+ (v850e_uart_xmit_done(n) && v850e_uart_cts(n))
+/* Wait for this to be true. */
+#define v850e_uart_wait_for_xmit_ok(n) \
+ do { } while (! v850e_uart_xmit_ok (n))
+
+/* Write character CH to uart channel CHAN. */
+#define v850e_uart_putc(chan, ch) (V850E_UARTB_TX(chan) = (ch))
+
+/* Return latest character read on channel CHAN. */
+#define v850e_uart_getc(chan) V850E_UARTB_RX (chan)
+
+/* Return bit-mask of uart error status. */
+#define v850e_uart_err(chan) V850E_UARTB_STR (chan)
+/* Various error bits set in the error result. */
+#define V850E_UART_ERR_OVERRUN V850E_UARTB_STR_OVE
+#define V850E_UART_ERR_FRAME V850E_UARTB_STR_FE
+#define V850E_UART_ERR_PARITY V850E_UARTB_STR_PE
+
+
+#endif /* __V850_V850E_UARTB_H__ */
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 93ab5714ad94..a7cb796c4deb 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -57,7 +57,7 @@
#define PORT_SUNSAB 39
/* NEC v850. */
-#define PORT_NB85E_UART 40
+#define PORT_V850E_UART 40
/* NEC PC-9800 */
#define PORT_8251_PC98 41