diff -N linux-2.4.x/include/asm-m68knommu/serial.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ linux-2.4.x/include/asm-m68knommu/serial.h	4 Jun 2003 18:03:36 -0000	1.6
@@ -0,0 +1,67 @@
+/*
+ * linux/include/asm-m68knommu/serial.h
+ *
+ * Copyright (C) 2003 Develer S.r.l. (http://www.develer.com/)
+ * Author: Bernardo Innocenti <bernie@codewiz.org>
+ *
+ * Based on linux/include/asm-i386/serial.h
+ */
+#include <linux/config.h>
+
+/*
+ * This assumes you have a 1.8432 MHz clock for your UART.
+ *
+ * It'd be nice if someone built a serial card with a 24.576 MHz
+ * clock, since the 16550A is capable of handling a top speed of 1.5
+ * megabits/second; but this requires the faster clock.
+ */
+#define BASE_BAUD ( 1843200 / 16 )
+
+#ifdef CONFIG_SERIAL_CDB4
+
+#define CONFIG_SERIAL_SHARE_IRQ
+
+#define CDB4_COM_BASE		((u8 *)0x40000000)
+#define CDB4_COM_IRQ		67	/* external IRQ3 */
+#define CDB4_COM_IRQPRI		5	/* interrupt priority */
+#define CDB4_COM_RESET_BIT	13	/* PA13 hooked to 16C554 RESET line, active high */
+#define STD_COM_FLAGS		ASYNC_BOOT_AUTOCONF
+
+#define SERIAL_PORT_DFNS				\
+	{						\
+		.baud_base	= BASE_BAUD,		\
+		.iomem_base	= CDB4_COM_BASE + 0x10,	\
+		.io_type	= SERIAL_IO_MEM,	\
+		.irq		= CDB4_COM_IRQ,		\
+		.flags		= STD_COM_FLAGS		\
+	},						\
+	{						\
+		.baud_base	= BASE_BAUD,		\
+		.iomem_base	= CDB4_COM_BASE + 0x18,	\
+		.io_type	= SERIAL_IO_MEM,	\
+		.irq		= CDB4_COM_IRQ,		\
+		.flags		= STD_COM_FLAGS		\
+	},						\
+	{						\
+		.baud_base	= BASE_BAUD,		\
+		.iomem_base	= CDB4_COM_BASE + 0x20,	\
+		.io_type	= SERIAL_IO_MEM,	\
+		.irq		= CDB4_COM_IRQ,		\
+		.flags		= STD_COM_FLAGS		\
+	},						\
+	{						\
+		.baud_base	= BASE_BAUD,		\
+		.iomem_base	= CDB4_COM_BASE + 0x28,	\
+		.io_type	= SERIAL_IO_MEM,	\
+		.irq		= CDB4_COM_IRQ,		\
+		.flags		= STD_COM_FLAGS		\
+	}
+
+#define RS_TABLE_SIZE  4
+
+#else /* !CONFIG_SERIAL_CDB4 */
+
+#error serial port not supported on this board
+
+#endif /* !CONFIG_SERIAL_CDB4 */
+
diff -u -3 -p -r1.1.1.2 -r1.2
--- linux-2.4.x/include/linux/serialP.h	28 Jan 2003 18:01:43 -0000	1.1.1.2
+++ linux-2.4.x/include/linux/serialP.h	5 Apr 2003 17:25:18 -0000	1.2
@@ -126,11 +126,14 @@ struct rs_multiport_struct {
 	int		port_monitor;
 };
 
-#if defined(__alpha__) && !defined(CONFIG_PCI)
+#if (defined(__alpha__) && !defined(CONFIG_PCI)) || defined(CONFIG_SERIAL_CDB4)
 /*
  * Digital did something really horribly wrong with the OUT1 and OUT2
  * lines on at least some ALPHA's.  The failure mode is that if either
  * is cleared, the machine locks up with endless interrupts.
+ *
+ * CDB4 board has the very same problem, so we're using the very same
+ * workaround.
  */
 #define ALPHA_KLUDGE_MCR  (UART_MCR_OUT2 | UART_MCR_OUT1)
 #else
diff -u -3 -p -r1.1.1.5 -r1.7
--- linux-2.4.x/drivers/char/serial.c	16 May 2003 01:06:50 -0000	1.1.1.5
+++ linux-2.4.x/drivers/char/serial.c	4 Jun 2003 17:56:31 -0000	1.7
@@ -65,6 +65,9 @@
  *
  *  9/02: Add support for IXP425 uart chip. Intel Corporation.
  *	  <support@jungo.com>
+ *
+ * 04/03: Add ColdFire support, based on previous work by Andrea Tarani.
+ *	  Bernardo Innocenti <bernie@develer.com>
  */
 
 static char *serial_version = "5.05c";
@@ -228,6 +231,11 @@ static char *serial_revdate = "2001-07-0
 #ifdef CONFIG_LEDMAN
 #include <linux/ledman.h>
 #endif
+#ifdef CONFIG_COLDFIRE
+#include <asm/coldfire.h>
+#include <asm/mcfpci.h>
+#include <asm/mcfsim.h>
+#endif
 
 /*
  * All of the compatibilty code so we can compile serial.c against
@@ -272,6 +280,13 @@ static struct timer_list serial_timer;
 /* number of characters left in xmit buffer before we ask for more */
 #define WAKEUP_CHARS 256
 
+#ifdef CONFIG_COLDFIRE
+#undef	TTY_MAJOR
+#define	TTY_MAJOR	24
+#undef	TTYAUX_MAJOR
+#define	TTYAUX_MAJOR	25
+#endif
+
 /*
  * IRQ_timeout		- How long the timeout should be for each IRQ
  * 				should be after the IRQ has been active.
@@ -399,6 +414,36 @@ static struct semaphore tmp_buf_sem = MU
 #endif
 
 
+#ifdef CONFIG_COLDFIRE
+static inline void mcf_reset_irq(int irq)
+{
+	volatile unsigned long *icrp;
+
+	irq -= 65;
+	if (irq < 0 || irq >= 32)
+		return;
+
+	icrp = (volatile unsigned long *)(MCF_MBAR + MCFSIM_ICR1) + (irq >> 3);
+	*icrp = (*icrp & 0x77777777) | (0x80000000 >> ((irq & 7) << 2));
+}
+static inline void mcf_manage_sim(int irq, int pri)
+{
+	volatile unsigned long *icrp;
+
+	irq -= 65;
+	if(irq < 0 || irq >= 32)
+		return;
+
+	icrp = (volatile unsigned long *)(MCF_MBAR + MCFSIM_ICR1) + irq / 8;
+	irq = (7 - (irq % 8)) * 4;
+
+	*icrp = (*icrp & ((7 << irq) ^ 0x77777777)) | ((8 + pri) << irq);
+}
+#else /* !CONFIG_COLDFIRE */
+# define mcf_reset_irq(irq) do {} while(0)
+# define mcf_manage_sim(irq,pri) do {} while(0)
+#endif /* !CONFIG_COLDFIRE */
+
 static inline int serial_paranoia_check(struct async_struct *info,
 					kdev_t device, const char *routine)
 {
@@ -898,6 +943,9 @@ static void rs_interrupt(int irq, void *
 			continue;
 		}
 	} while (end_mark != info);
+
+	mcf_reset_irq(irq);
+
 #ifdef CONFIG_SERIAL_MULTIPORT	
 	if (multi->port_monitor)
 		printk("rs port monitor (normal) irq %d: 0x%x, 0x%x\n",
@@ -963,6 +1011,9 @@ static void rs_interrupt_single(int irq,
 #endif
 	} while ((iir & UART_IIR_NO_INT) == 0);
 	info->last_active = jiffies;
+
+	mcf_reset_irq(irq);
+	
 #ifdef CONFIG_SERIAL_MULTIPORT	
 	if (multi->port_monitor)
 		printk("rs port monitor (single) irq %d: 0x%x, 0x%x\n",
@@ -1056,6 +1107,9 @@ static void rs_interrupt_multi(int irq, 
 			continue;
 		break;
 	} 
+
+	mcf_reset_irq(irq);
+
 #ifdef SERIAL_DEBUG_INTR
 	printk("end.\n");
 #endif
@@ -1402,6 +1456,10 @@ static int startup(struct async_struct *
 			}
 			goto errout;
 		}
+#ifdef CONFIG_COLDFIRE
+		else if(handler == rs_interrupt_single)
+			mcf_manage_sim(state->irq, CDB4_COM_IRQPRI);
+#endif /* CONFIG_COLDFIRE */
 	}
 
 	/*
@@ -3878,6 +3936,11 @@ static void autoconfig(struct serial_sta
 	serial_outp(info, UART_IER, 0);
 	
 	restore_flags(flags);
+
+#ifdef CONFIG_SERIAL_CDB4
+	printk("serial: activating INTM workaround for CDB4 on ttyS%d\n", state->line);
+	serial_outp(info, UART_MCR, save_mcr | UART_MCR_OUT2);
+#endif /* CONFIG_SERIAL_CDB4 */
 }
 
 int register_serial(struct serial_struct *req);
@@ -5505,6 +5568,14 @@ static int __init rs_init(void)
 #endif
 	show_serial_version();
 
+#ifdef CONFIG_SERIAL_CDB4
+	printk("serial: Resetting CDB4 UART\n");
+	*((volatile uint16_t *)(MCF_MBAR + MCFSIM_PADDR)) |= (1<<CDB4_COM_RESET_BIT);
+	*((volatile uint16_t *)(MCF_MBAR + MCFSIM_PADAT)) |= (1<<CDB4_COM_RESET_BIT);
+	udelay(1); /* Hold reset for at least 1000ns */
+	*((volatile uint16_t *)(MCF_MBAR + MCFSIM_PADAT)) &= ~(1<<CDB4_COM_RESET_BIT);
+#endif
+
 	/* Initialize the tty_driver structure */
 	
 	memset(&serial_driver, 0, sizeof(struct tty_driver));
@@ -5642,8 +5713,9 @@ static int __init rs_init(void)
 	probe_serial_pci();
 #endif
 #ifdef ENABLE_SERIAL_PNP
-       probe_serial_pnp();
+	probe_serial_pnp();
 #endif
+
 	return 0;
 }
 
diff -u -3 -p -r1.1.1.8 -r1.7
--- linux-2.4.x/drivers/char/Config.in	16 May 2003 01:06:48 -0000	1.1.1.8
+++ linux-2.4.x/drivers/char/Config.in	16 May 2003 17:05:55 -0000	1.7
@@ -82,6 +82,9 @@ fi
 
 if [ "$CONFIG_COLDFIRE" = "y" ]; then
   bool 'ColdFire serial support' CONFIG_COLDFIRE_SERIAL
+  if [ "$CONFIG_DEVELER_CDB4" = "y" ]; then
+    bool '16C554 serial support for AEP CDB4 board' CONFIG_SERIAL_CDB4
+  fi
   bool 'ColdFire MBUS Support' CONFIG_MCF_MBUS
   tristate 'ColdFire QSPI Support' CONFIG_MCF_QSPI
   bool 'Support for TEXT based LCD driver' CONFIG_LCDTXT
