Skip to contentSkip to conversation

: Serial 8250 optionally skip autodetection

PATCH New Tony Lindgren 1 participant 2 messages Aug 16, 2004 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 : Serial 8250 optionally skip autodetection

Hi Russell,

Following patch allows 8250 compatible serial drivers to optionally define the port type to allow skipping the serial port autodetection.

This is needed for OMAP serial port, which is 8250 compatible, but requires extra FIFO settings, and does not reliably work with the autodetection. The OMAP serial port support is in patch 2/2.

Regards,

Tony

drivers/serial/8250.c +5 -1
diff -Nru a/drivers/serial/8250.c b/drivers/serial/8250.c
@@ -2056,6 +2056,7 @@
 {
 	struct uart_port port;
 
+	port.type     = req->type;
 	port.iobase   = req->port;
 	port.membase  = req->iomem_base;
 	port.irq      = req->irq;
@@ -2063,9 +2064,12 @@
 	port.fifosize = req->xmit_fifo_size;
 	port.regshift = req->iomem_reg_shift;
 	port.iotype   = req->io_type;
-	port.flags    = req->flags | UPF_BOOT_AUTOCONF;
+	port.flags    = req->flags;
 	port.mapbase  = req->iomap_base;
 	port.line     = line;
+
+	if (req->type != PORT_OMAP)
+		req->flags |= UPF_BOOT_AUTOCONF;
 
 	if (share_irqs)
 		port.flags |= UPF_SHARE_IRQ;
drivers/serial/serial_core.c +1 -0
diff -Nru a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
@@ -2375,6 +2375,7 @@
 		 * If the port is already initialised, don't touch it.
 		 */
 		if (state->port->type == PORT_UNKNOWN) {
+			state->port->type     = port->type;
 			state->port->iobase   = port->iobase;
 			state->port->membase  = port->membase;
 			state->port->irq      = port->irq;
#1 lore raw

PATCH 2/2 : Serial 8250 OMAP support

Following patch adds OMAP support to the 8250 serial driver.

drivers/serial/8250.c +37 -0
diff -Nru a/drivers/serial/8250.c b/drivers/serial/8250.c
@@ -173,6 +173,7 @@
 	{ "RSA",	2048,	UART_CLEAR_FIFO | UART_USE_FIFO },
 	{ "NS16550A",	16,	UART_CLEAR_FIFO | UART_USE_FIFO | UART_NATSEMI },
 	{ "XScale",	32,	UART_CLEAR_FIFO | UART_USE_FIFO  },
+	{ "OMAP UART",	64,	UART_CLEAR_FIFO | UART_USE_FIFO | UART_STARTECH }
 };
 
 static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset)
@@ -1215,6 +1216,28 @@
 		serial_outp(up, UART_LCR, 0);
 	}
 
+#ifdef CONFIG_ARCH_OMAP
+       if (up->port.type == PORT_OMAP) {
+                serial_outp(up, UART_OMAP_MDR1, 0x07); /* disable UART */
+                serial_outp(up, UART_LCR, 0xBF);       /* select EFR */
+                serial_outp(up, UART_EFR, UART_EFR_ECB);
+                serial_outp(up, UART_LCR, UART_LCR_DLAB); /* set DLAB */
+                serial_outp(up, UART_DLL, 0x00);
+                serial_outp(up, UART_DLM, 0x00);
+                serial_outp(up, UART_LCR, 0x00);       /* reset DLAB */
+                serial_outp(up, UART_OMAP_SCR, 0x08);
+                serial_outp(up, UART_FCR, 0x00);
+                serial_outp(up, UART_MCR, 0x40);       /* enable TCR/TLR */
+                serial_outp(up, UART_OMAP_TCR, 0x0F);
+                serial_outp(up, UART_OMAP_TLR, 0x00);
+                serial_outp(up, UART_MCR, 0x00);
+                serial_outp(up, UART_LCR, 0xBF);       /* select EFR */
+                serial_outp(up, UART_EFR, 0x00);
+                serial_outp(up, UART_LCR, 0x00);       /* reset DLAB */
+                serial_outp(up, UART_OMAP_MDR1, 0x00); /* enable UART */
+        }
+#endif
+
 #ifdef CONFIG_SERIAL_8250_RSA
 	/*
 	 * If this is an RSA port, see if we can kick it up to the
@@ -1447,6 +1470,10 @@
 		else if (up->port.type == PORT_RSA)
 			fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_14;
 #endif
+#ifdef CONFIG_ARCH_OMAP
+		else if (up->port.type == PORT_OMAP)
+			fcr = UART_FCR_T_TRIGGER_56 | UART_FCR_R_TRIGGER_60 | UART_FCR_ENABLE_FIFO;
+#endif
 		else
 			fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8;
 	}
@@ -1519,6 +1546,16 @@
 		serial_outp(up, UART_EFR,
 			    termios->c_cflag & CRTSCTS ? UART_EFR_CTS :0);
 	}
+
+#ifdef CONFIG_ARCH_OMAP1510	/* Needed for 1510 only */
+        if (up->port.type == PORT_OMAP && cpu_is_omap1510()) {
+		if (baud == 115200) {
+			quot = 1;
+			serial_out(up, UART_OMAP_OSC_12M_SEL, 1);
+		} else
+			serial_out(up, UART_OMAP_OSC_12M_SEL, 0);
+        }
+#endif
 
 	if (up->capabilities & UART_NATSEMI) {
 		/* Switch to bank 2 not bank 1, to avoid resetting EXCR2 */
drivers/serial/8250_omap.c new file +125 -0

125 lines not on this page · raw message

drivers/serial/Kconfig +7 -0
diff -Nru a/drivers/serial/Kconfig b/drivers/serial/Kconfig
@@ -166,6 +166,13 @@
 	  system, say Y to this option.  The driver can handle 1, 2, or 3 port
 	  cards.  If unsure, say N.
 
+config SERIAL_8250_OMAP
+	tristate "OMAP serial port support"
+	depends on ARM && ARCH_OMAP && SERIAL_8250
+	help
+	  Say Y or M here if you want to use the integrated UARTs of the TI
+	  OMAP multimedia processor.
+
 config SERIAL_AMBA_PL010
 	tristate "ARM AMBA PL010 serial port support"
 	depends on ARM_AMBA
drivers/serial/Makefile +1 -0
diff -Nru a/drivers/serial/Makefile b/drivers/serial/Makefile
@@ -15,6 +15,7 @@
 obj-$(CONFIG_SERIAL_8250) += 8250.o $(serial-8250-y)
 obj-$(CONFIG_SERIAL_8250_CS) += serial_cs.o
 obj-$(CONFIG_SERIAL_8250_ACORN) += 8250_acorn.o
+obj-$(CONFIG_SERIAL_8250_OMAP) += 8250_omap.o
 obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o
 obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o
 obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
include/linux/serial_core.h +2 -1
diff -Nru a/include/linux/serial_core.h b/include/linux/serial_core.h
@@ -37,7 +37,8 @@
 #define PORT_RSA	13
 #define PORT_NS16550A	14
 #define PORT_XSCALE	15
-#define PORT_MAX_8250	15	/* max port ID */
+#define PORT_OMAP	16
+#define PORT_MAX_8250	16	/* max port ID */
 
 /*
  * ARM specific type numbers.  These are not currently guaranteed
include/linux/serial_reg.h +16 -0
diff -Nru a/include/linux/serial_reg.h b/include/linux/serial_reg.h
@@ -294,5 +294,21 @@
 #define SERIAL_RSA_BAUD_BASE (921600)
 #define SERIAL_RSA_BAUD_BASE_LO (SERIAL_RSA_BAUD_BASE / 8)
 
+/*
+ * Extra serial register definitions for the internal UARTs 
+ * in TI OMAP processors.
+ */
+#define UART_OMAP_TCR		0x06	/* Transmission control register */
+#define UART_OMAP_TLR		0x07	/* Trigger level register */
+#define UART_OMAP_MDR1		0x08	/* Mode definition register */
+#define UART_OMAP_MDR2		0x09	/* Mode definition register 2 */
+#define UART_OMAP_SCR		0x10	/* Supplementary control register */
+#define UART_OMAP_SSR		0x11	/* Supplementary status register */
+#define UART_OMAP_EBLR		0x12	/* BOF length register */
+#define UART_OMAP_OSC_12M_SEL	0x13	/* OMAP1510 12MHz osc select */
+#define UART_OMAP_MVER		0x14	/* Module version register */
+#define UART_OMAP_SYSC		0x15	/* System configuration register */
+#define UART_OMAP_SYSS		0x16	/* System status register */
+
 #endif /* _LINUX_SERIAL_REG_H */