2002-10-17 11:58:18

by Osamu Tomita

[permalink] [raw]
Subject: [PATCH][RFC] add support for PC-9800 architecture (20/26) serial #1

This is part 20/26 of patchset for add support NEC PC-9800 architecture,
against 2.5.43.

Summary:
serial driver related modules.
- change IO port address and IRQ number.
- add new PNP device entry.
- add register definition for new serial driver.

diffstat:
drivers/serial/8250_cs.c | 1 +
drivers/serial/8250_pnp.c | 7 +++++++
drivers/serial/Config.in | 10 ++++++++++
drivers/serial/Makefile | 6 +++++-
include/asm-i386/serial.h | 18 ++++++++++++++++++
include/linux/serial.h | 13 +++++++++++++
include/linux/serialP.h | 5 +++++
include/linux/serial_core.h | 9 +++++++++
include/linux/serial_reg.h | 43 +++++++++++++++++++++++++++++++++++++++++++
9 files changed, 111 insertions(+), 1 deletion(-)

patch:
diff -urN linux/drivers/serial/Config.in linux98/drivers/serial/Config.in
--- linux/drivers/serial/Config.in Sat Oct 12 13:21:31 2002
+++ linux98/drivers/serial/Config.in Sun Oct 13 19:44:24 2002
@@ -12,12 +12,22 @@
dep_bool ' Console on 8250/16550 and compatible serial port (EXPERIMENTAL)' CONFIG_SERIAL_8250_CONSOLE $CONFIG_SERIAL_8250 $CONFIG_EXPERIMENTAL
dep_tristate ' 8250/16550 PCMCIA device support' CONFIG_SERIAL_8250_CS $CONFIG_PCMCIA $CONFIG_SERIAL_8250

+if [ "$CONFIG_PC9800" != "y" ]; then
dep_mbool 'Extended 8250/16550 serial driver options' CONFIG_SERIAL_8250_EXTENDED $CONFIG_SERIAL_8250
dep_bool ' Support more than 4 serial ports' CONFIG_SERIAL_8250_MANY_PORTS $CONFIG_SERIAL_8250_EXTENDED
dep_bool ' Support for sharing serial interrupts' CONFIG_SERIAL_8250_SHARE_IRQ $CONFIG_SERIAL_8250_EXTENDED
dep_bool ' Autodetect IRQ on standard ports (unsafe)' CONFIG_SERIAL_8250_DETECT_IRQ $CONFIG_SERIAL_8250_EXTENDED
dep_bool ' Support special multiport boards' CONFIG_SERIAL_8250_MULTIPORT $CONFIG_SERIAL_8250_EXTENDED
dep_bool ' Support RSA serial ports' CONFIG_SERIAL_8250_RSA $CONFIG_SERIAL_8250_EXTENDED
+else # CONFIG_PC9800=y
+dep_mbool 'NEC PC-9801 primary serial port support (EXPERIMENTAL)' CONFIG_SERIAL_PC9800 $CONFIG_SERIAL_8250
+dep_bool ' Support MC16550II (EXPERIMENTAL)' CONFIG_MC16550II $CONFIG_SERIAL_PC9800
+if [ "$CONFIG_MC16550II" = "y" ]; then
+ comment ' MC16550II COM2, COM3 '
+ int ' MC16550II shared IRQ (3, 5, 6, 12)' CONFIG_MC16550II_IRQ 3
+ hex ' MC16550II base address (d0,d2,d4,d6,d8,da,dc,de)' CONFIG_MC16550II_BASE d2
+fi
+fi

comment 'Non-8250 serial port support'

diff -urN linux/drivers/serial/Makefile linux98/drivers/serial/Makefile
--- linux/drivers/serial/Makefile Wed Oct 16 13:20:41 2002
+++ linux98/drivers/serial/Makefile Wed Oct 16 15:31:48 2002
@@ -4,14 +4,18 @@
# $Id: Makefile,v 1.8 2002/07/21 21:32:30 rmk Exp $
#

-export-objs := core.o 8250.o suncore.o
+export-objs := core.o 8250.o suncore.o serial98.o

serial-8250-y :=
serial-8250-$(CONFIG_PCI) += 8250_pci.o
serial-8250-$(CONFIG_ISAPNP) += 8250_pnp.o
obj-$(CONFIG_SERIAL_CORE) += core.o
obj-$(CONFIG_SERIAL_21285) += 21285.o
+ifneq ($(CONFIG_SERIAL_PC9800),y)
obj-$(CONFIG_SERIAL_8250) += 8250.o $(serial-8250-y)
+else
+obj-$(CONFIG_SERIAL_8250) += serial98.o $(serial-8250-y)
+endif
obj-$(CONFIG_SERIAL_8250_CS) += 8250_cs.o
obj-$(CONFIG_SERIAL_8250_ACORN) += 8250_acorn.o
obj-$(CONFIG_SERIAL_ANAKIN) += anakin.o
diff -urN linux/drivers/serial/8250_cs.c linux98/drivers/serial/8250_cs.c
--- linux/drivers/serial/8250_cs.c Thu Jul 25 06:03:28 2002
+++ linux98/drivers/serial/8250_cs.c Thu Jul 25 15:48:59 2002
@@ -307,6 +307,7 @@
serial.port = port;
serial.irq = irq;
serial.flags = ASYNC_SKIP_TEST | ASYNC_SHARE_IRQ;
+ serial.baud_base = 230400;
line = register_serial(&serial);
if (line < 0) {
printk(KERN_NOTICE "serial_cs: register_serial() at 0x%04lx,"
diff -urN linux/drivers/serial/8250_pnp.c linux98/drivers/serial/8250_pnp.c
--- linux/drivers/serial/8250_pnp.c Sat Oct 12 13:21:04 2002
+++ linux98/drivers/serial/8250_pnp.c Sun Oct 13 21:02:23 2002
@@ -187,6 +187,8 @@
{ "MVX00A1", 0 },
/* PC Rider K56 Phone System PnP */
{ "MVX00F2", 0 },
+ /* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
+ { "nEC8241", 0 },
/* Pace 56 Voice Internal Plug & Play Modem */
{ "PMC2430", 0 },
/* Generic */
@@ -379,7 +381,12 @@
((port->min == 0x2f8) ||
(port->min == 0x3f8) ||
(port->min == 0x2e8) ||
+#ifndef CONFIG_PC9800
(port->min == 0x3e8)))
+#else
+ (port->min == 0x3e8) ||
+ (port->min == 0x8b0)))
+#endif
return 0;
}

diff -urN linux/include/asm-i386/serial.h linux98/include/asm-i386/serial.h
--- linux/include/asm-i386/serial.h Mon Apr 15 04:18:51 2002
+++ linux98/include/asm-i386/serial.h Wed Apr 17 10:37:22 2002
@@ -50,14 +50,22 @@

#define C_P(card,port) (((card)<<6|(port)<<3) + 1)

+#ifndef CONFIG_PC9800
#define STD_SERIAL_PORT_DEFNS \
/* UART CLK PORT IRQ FLAGS */ \
{ 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS }, /* ttyS0 */ \
{ 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS }, /* ttyS1 */ \
{ 0, BASE_BAUD, 0x3E8, 4, STD_COM_FLAGS }, /* ttyS2 */ \
{ 0, BASE_BAUD, 0x2E8, 3, STD_COM4_FLAGS }, /* ttyS3 */
+#else
+#define STD_SERIAL_PORT_DEFNS \
+ /* UART CLK PORT IRQ FLAGS */ \
+ { 0, BASE_BAUD, 0x30, 4, STD_COM_FLAGS }, /* ttyS0 */ \
+ { 0, BASE_BAUD, 0x238, 5, STD_COM_FLAGS }, /* ttyS1 */
+#endif /* CONFIG_PC9800 */


+#ifndef CONFIG_PC9800
#ifdef CONFIG_SERIAL_MANY_PORTS
#define EXTRA_SERIAL_PORT_DEFNS \
{ 0, BASE_BAUD, 0x1A0, 9, FOURPORT_FLAGS }, /* ttyS4 */ \
@@ -91,6 +99,16 @@
#else
#define EXTRA_SERIAL_PORT_DEFNS
#endif
+#else /* CONFIG_PC9800 */
+#ifdef CONFIG_MC16550II
+#define EXTRA_SERIAL_PORT_DEFNS \
+ /* MC16550II */ \
+ { 0, BASE_BAUD*4, CONFIG_MC16550II_BASE, CONFIG_MC16550II_IRQ, STD_COM_FLAGS }, /* ttyS2 */ \
+ { 0, BASE_BAUD*4, CONFIG_MC16550II_BASE+0x800, CONFIG_MC16550II_IRQ, STD_COM_FLAGS }, /* ttyS3 */
+#else
+#define EXTRA_SERIAL_PORT_DEFNS
+#endif
+#endif /* CONFIG_PC9800 */

/* You can have up to four HUB6's in the system, but I've only
* included two cards here for a total of twelve ports.
diff -urN linux/include/linux/serial.h linux98/include/linux/serial.h
--- linux/include/linux/serial.h Mon Sep 16 11:18:23 2002
+++ linux98/include/linux/serial.h Mon Sep 16 16:21:38 2002
@@ -10,6 +10,8 @@
#ifndef _LINUX_SERIAL_H
#define _LINUX_SERIAL_H

+#include <linux/config.h>
+
#ifdef __KERNEL__
#include <asm/page.h>

@@ -75,11 +77,22 @@
#define PORT_16654 11
#define PORT_16850 12
#define PORT_RSA 13 /* RSA-DV II/S card */
+#ifndef CONFIG_PC9800
#define PORT_MAX 13
+#else
+#define PORT_8251 14
+#define PORT_8251_19K 15
+#define PORT_8251_FIFO 16
+#define PORT_8251_VFAST 17
+#define PORT_MC16550II 18
+#define PORT_MAX 18
+#endif

#define SERIAL_IO_PORT 0
#define SERIAL_IO_HUB6 1
#define SERIAL_IO_MEM 2
+#define SERIAL_IO_8251 3
+#define SERIAL_IO_MC16550II 4

struct serial_uart_config {
char *name;
diff -urN linux/include/linux/serialP.h linux98/include/linux/serialP.h
--- linux/include/linux/serialP.h Tue Oct 8 10:56:20 2002
+++ linux98/include/linux/serialP.h Tue Oct 8 11:01:42 2002
@@ -20,6 +20,7 @@
*/

#include <linux/config.h>
+#include <linux/version.h>
#include <linux/termios.h>
#include <linux/workqueue.h>
#include <linux/circ_buf.h>
@@ -75,6 +76,10 @@
int MCR; /* Modem control register */
int LCR; /* Line control register */
int ACR; /* 16950 Additional Control Reg. */
+#ifdef CONFIG_PC9800
+ int cmd8251;
+ int msr8251;
+#endif
unsigned long event;
unsigned long last_active;
int line;
diff -urN linux/include/linux/serial_core.h linux98/include/linux/serial_core.h
--- linux/include/linux/serial_core.h Sun Aug 11 10:41:20 2002
+++ linux98/include/linux/serial_core.h Wed Aug 21 16:26:45 2002
@@ -37,7 +37,16 @@
#define PORT_16654 11
#define PORT_16850 12
#define PORT_RSA 13
+#ifndef CONFIG_PC9800
#define PORT_MAX_8250 13 /* max port ID */
+#else
+#define PORT_8251 14
+#define PORT_8251_19K 15
+#define PORT_8251_FIFO 16
+#define PORT_8251_VFAST 17
+#define PORT_MC16550II 18
+#define PORT_MAX_8250 18 /* max port ID */
+#endif

/*
* ARM specific type numbers. These are not currently guaranteed
diff -urN linux/include/linux/serial_reg.h linux98/include/linux/serial_reg.h
--- linux/include/linux/serial_reg.h Wed May 2 08:05:00 2001
+++ linux98/include/linux/serial_reg.h Fri Aug 17 22:15:12 2001
@@ -14,6 +14,8 @@
#ifndef _LINUX_SERIAL_REG_H
#define _LINUX_SERIAL_REG_H

+#include <linux/config.h>
+
#define UART_RX 0 /* In: Receive buffer (DLAB=0) */
#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */
#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */
@@ -229,6 +231,47 @@
#define UART_TRG_120 0x78
#define UART_TRG_128 0x80

+#ifdef CONFIG_PC9800
+
+#define RX_8251F 0x130 /* In: Receive buffer */
+#define TX_8251F 0x130 /* Out: Transmit buffer */
+#define LSR_8251F 0x132 /* In: Line Status Register */
+#define MSR_8251F 0x134 /* In: Modem Status Register */
+#define IIR_8251F 0x136 /* In: Interrupt ID Register */
+#define FCR_8251F 0x138 /* I/O: FIFO Control Register */
+#define IER2_8251F 0x138 /* I/O: Interrupt Enable Register */
+#define VFAST_8251F 0x13a /* I/O: VFAST mode Register */
+
+#define COMMAND_8251F 0x32 /* Out: 8251 Command Resister */
+#define IER1_8251F 0x35 /* I/O: Interrupt Enable Register */
+#define IER1_8251F_COUT 0x37 /* Out: Interrupt Enable Register */
+
+#define COMMAND_8251F_DUMMY 0 /* Dummy Command */
+#define COMMAND_8251F_RESET 0x40 /* Reset Command */
+
+#define VFAST_ENABLE 0x80 /* V.Fast mode Enable */
+
+/* Interrupt Reason */
+#define INTR_8251_TXRE 4
+#define INTR_8251_TXEE 2
+#define INTR_8251_RXRE 1
+/* I/O Port */
+#define PORT_8251_DATA 0
+#define PORT_8251_CMD 2
+#define PORT_8251_MOD 2
+#define PORT_8251_STS 2
+/* status in */
+#define STAT_8251_TXRDY 1
+#define STAT_8251_RXRDY 2
+#define STAT_8251_TXEMP 4
+#define STAT_8251_PER 8
+#define STAT_8251_OER 16
+#define STAT_8251_FER 32
+#define STAT_8251_BRK 64
+#define STAT_8251_DSR 128
+
+#endif /* CONFIG_PC9800 */
+
/*
* These definitions are for the RSA-DV II/S card, from
*


2002-10-17 14:05:36

by Russell King

[permalink] [raw]
Subject: Re: [PATCH][RFC] add support for PC-9800 architecture (20/26) serial #1

I strongly recommend _n_o_t_ merging this patch.

On Thu, Oct 17, 2002 at 08:40:13PM +0900, Osamu Tomita wrote:
> diff -urN linux/drivers/serial/Makefile linux98/drivers/serial/Makefile
> --- linux/drivers/serial/Makefile Wed Oct 16 13:20:41 2002
> +++ linux98/drivers/serial/Makefile Wed Oct 16 15:31:48 2002
> @@ -4,14 +4,18 @@
> # $Id: Makefile,v 1.8 2002/07/21 21:32:30 rmk Exp $
> #
>
> -export-objs := core.o 8250.o suncore.o
> +export-objs := core.o 8250.o suncore.o serial98.o
>
> serial-8250-y :=
> serial-8250-$(CONFIG_PCI) += 8250_pci.o
> serial-8250-$(CONFIG_ISAPNP) += 8250_pnp.o
> obj-$(CONFIG_SERIAL_CORE) += core.o
> obj-$(CONFIG_SERIAL_21285) += 21285.o
> +ifneq ($(CONFIG_SERIAL_PC9800),y)
> obj-$(CONFIG_SERIAL_8250) += 8250.o $(serial-8250-y)
> +else
> +obj-$(CONFIG_SERIAL_8250) += serial98.o $(serial-8250-y)
> +endif

If you don't want 8250.c, then don't re-use CONFIG_SERIAL_8250

> diff -urN linux/drivers/serial/8250_cs.c linux98/drivers/serial/8250_cs.c
> --- linux/drivers/serial/8250_cs.c Thu Jul 25 06:03:28 2002
> +++ linux98/drivers/serial/8250_cs.c Thu Jul 25 15:48:59 2002
> @@ -307,6 +307,7 @@
> serial.port = port;
> serial.irq = irq;
> serial.flags = ASYNC_SKIP_TEST | ASYNC_SHARE_IRQ;
> + serial.baud_base = 230400;
> line = register_serial(&serial);
> if (line < 0) {
> printk(KERN_NOTICE "serial_cs: register_serial() at 0x%04lx,"

This breaks PCMCIA serial support on every other platform that supports
PCMCIA serial cards.

> diff -urN linux/include/linux/serial.h linux98/include/linux/serial.h
> --- linux/include/linux/serial.h Mon Sep 16 11:18:23 2002
> +++ linux98/include/linux/serial.h Mon Sep 16 16:21:38 2002
> @@ -10,6 +10,8 @@
> #ifndef _LINUX_SERIAL_H
> #define _LINUX_SERIAL_H
>
> +#include <linux/config.h>
> +
> #ifdef __KERNEL__
> #include <asm/page.h>
>
> @@ -75,11 +77,22 @@
> #define PORT_16654 11
> #define PORT_16850 12
> #define PORT_RSA 13 /* RSA-DV II/S card */
> +#ifndef CONFIG_PC9800
> #define PORT_MAX 13
> +#else
> +#define PORT_8251 14
> +#define PORT_8251_19K 15
> +#define PORT_8251_FIFO 16
> +#define PORT_8251_VFAST 17
> +#define PORT_MC16550II 18
> +#define PORT_MAX 18
> +#endif

Yuck. Just define the new numbers. There is no point putting an
ifdef around them.

> diff -urN linux/include/linux/serialP.h linux98/include/linux/serialP.h
> --- linux/include/linux/serialP.h Tue Oct 8 10:56:20 2002
> +++ linux98/include/linux/serialP.h Tue Oct 8 11:01:42 2002
> @@ -20,6 +20,7 @@
> */
>
> #include <linux/config.h>
> +#include <linux/version.h>
> #include <linux/termios.h>
> #include <linux/workqueue.h>
> #include <linux/circ_buf.h>
> @@ -75,6 +76,10 @@
> int MCR; /* Modem control register */
> int LCR; /* Line control register */
> int ACR; /* 16950 Additional Control Reg. */
> +#ifdef CONFIG_PC9800
> + int cmd8251;
> + int msr8251;
> +#endif
> unsigned long event;
> unsigned long last_active;
> int line;

I'm deferring comment on this until I've had time to digest your
other serial patch.

> diff -urN linux/include/linux/serial_core.h linux98/include/linux/serial_core.h
> --- linux/include/linux/serial_core.h Sun Aug 11 10:41:20 2002
> +++ linux98/include/linux/serial_core.h Wed Aug 21 16:26:45 2002
> @@ -37,7 +37,16 @@
> #define PORT_16654 11
> #define PORT_16850 12
> #define PORT_RSA 13
> +#ifndef CONFIG_PC9800
> #define PORT_MAX_8250 13 /* max port ID */
> +#else
> +#define PORT_8251 14
> +#define PORT_8251_19K 15
> +#define PORT_8251_FIFO 16
> +#define PORT_8251_VFAST 17
> +#define PORT_MC16550II 18
> +#define PORT_MAX_8250 18 /* max port ID */
> +#endif
>
> /*
> * ARM specific type numbers. These are not currently guaranteed

Same comments as serial.h

> diff -urN linux/include/linux/serial_reg.h linux98/include/linux/serial_reg.h
> --- linux/include/linux/serial_reg.h Wed May 2 08:05:00 2001
> +++ linux98/include/linux/serial_reg.h Fri Aug 17 22:15:12 2001
> @@ -14,6 +14,8 @@
> #ifndef _LINUX_SERIAL_REG_H
> #define _LINUX_SERIAL_REG_H
>
> +#include <linux/config.h>
> +
> #define UART_RX 0 /* In: Receive buffer (DLAB=0) */
> #define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */
> #define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */
> @@ -229,6 +231,47 @@
> #define UART_TRG_120 0x78
> #define UART_TRG_128 0x80
>
> +#ifdef CONFIG_PC9800
> +
> +#define RX_8251F 0x130 /* In: Receive buffer */
> +#define TX_8251F 0x130 /* Out: Transmit buffer */
> +#define LSR_8251F 0x132 /* In: Line Status Register */
> +#define MSR_8251F 0x134 /* In: Modem Status Register */
> +#define IIR_8251F 0x136 /* In: Interrupt ID Register */
> +#define FCR_8251F 0x138 /* I/O: FIFO Control Register */
> +#define IER2_8251F 0x138 /* I/O: Interrupt Enable Register */
> +#define VFAST_8251F 0x13a /* I/O: VFAST mode Register */
> +
> +#define COMMAND_8251F 0x32 /* Out: 8251 Command Resister */
> +#define IER1_8251F 0x35 /* I/O: Interrupt Enable Register */
> +#define IER1_8251F_COUT 0x37 /* Out: Interrupt Enable Register */
> +
> +#define COMMAND_8251F_DUMMY 0 /* Dummy Command */
> +#define COMMAND_8251F_RESET 0x40 /* Reset Command */
> +
> +#define VFAST_ENABLE 0x80 /* V.Fast mode Enable */
> +
> +/* Interrupt Reason */
> +#define INTR_8251_TXRE 4
> +#define INTR_8251_TXEE 2
> +#define INTR_8251_RXRE 1
> +/* I/O Port */
> +#define PORT_8251_DATA 0
> +#define PORT_8251_CMD 2
> +#define PORT_8251_MOD 2
> +#define PORT_8251_STS 2
> +/* status in */
> +#define STAT_8251_TXRDY 1
> +#define STAT_8251_RXRDY 2
> +#define STAT_8251_TXEMP 4
> +#define STAT_8251_PER 8
> +#define STAT_8251_OER 16
> +#define STAT_8251_FER 32
> +#define STAT_8251_BRK 64
> +#define STAT_8251_DSR 128
> +
> +#endif /* CONFIG_PC9800 */
> +

Same comments as serial.h

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html

2002-10-18 06:01:19

by Andrey Panin

[permalink] [raw]
Subject: Re: [PATCH][RFC] add support for PC-9800 architecture (20/26) serial #1

On Thu, Oct 17, 2002 at 03:11:25PM +0100, Russell King wrote:
> I strongly recommend _n_o_t_ merging this patch.

Did you see the next patch (21/26 serial #2) ? It looks even more interesting.
As I understand serial98.c driver should support older i8251 UART.
However it does it by perverting 8250.c and EMULATING i8250 on top of i8251,
see ugly code in serial_in() and serial_out() functions.

May be I misunderstand the issue, but IMHO this patch is unacceptible too :(

Best regards.

--
Andrey Panin | Embedded systems software developer
[email protected] | PGP key: wwwkeys.eu.pgp.net


Attachments:
(No filename) (609.00 B)
(No filename) (232.00 B)
Download all attachments

2002-10-18 08:25:49

by Russell King

[permalink] [raw]
Subject: Re: [PATCH][RFC] add support for PC-9800 architecture (20/26) serial #1

On Fri, Oct 18, 2002 at 10:06:11AM +0400, Andrey Panin wrote:
> On Thu, Oct 17, 2002 at 03:11:25PM +0100, Russell King wrote:
> > I strongly recommend _n_o_t_ merging this patch.
>
> Did you see the next patch (21/26 serial #2) ?

Yes. I said in the comments to #1 that I'd defer commenting on one section
of #1 and all of #2. (until I can read through the whole of #2 and provide
some useful feedback.)

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html