Skip to contentSkip to conversation

linuxppc_2_4_devel patch for arch/ppc/kernel/gen550_dbg.c

PATCH Mark A. Greer 2 participants 2 messages Jun 5, 2003

lore
Share & tools
lore
#0 lore raw

This patch add in the check to see if the UART already appears to be initialized that is in arch/ppc/boot/common/ns16550.c.

Please apply if there are no objections.

Mark
--

===== arch/ppc/kernel/gen550_dbg.c 1.3 vs edited =====

arch/ppc/kernel/gen550_dbg.c +28 -11
@@ -57,6 +57,7 @@
 unsigned long serial_init(int chan, void *ignored)
 {
 	unsigned long com_port;
+	unsigned char lcr, dlm;
 
 	/* We need to find out which type io we're expecting.  If it's
 	 * 'SERIAL_IO_PORT', we get an offset from the isa_io_base.
@@ -79,22 +80,38 @@
 
 	/* How far apart the registers are. */
 	shift = rs_table[chan].iomem_reg_shift;
+
+	/* save the LCR */
+	lcr = serial_inb(com_port + (UART_LCR << shift));
 
 	/* Access baud rate */
-	serial_outb(com_port + (UART_LCR << shift), 0x80);
+	serial_outb(com_port + (UART_LCR << shift), UART_LCR_DLAB);
+	dlm = serial_inb(com_port + (UART_DLM << shift));
 
-	/* Input clock. */
-	serial_outb(com_port + (UART_DLL << shift),
+	/*
+	 * Test if serial port is unconfigured
+	 * We assume that no-one uses less than 110 baud or
+	 * less than 7 bits per character these days.
+	 *  -- paulus.
+	 */
+	if ((dlm <= 4) && (lcr & 2)) {
+		/* port is configured, put the old LCR back */
+		serial_outb(com_port + (UART_LCR << shift), lcr);
+	}
+	else {
+		/* Input clock. */
+		serial_outb(com_port + (UART_DLL << shift),
 			(rs_table[chan].baud_base / SERIAL_BAUD) & 0xFF);
-	serial_outb(com_port + (UART_DLM << shift),
-			(rs_table[chan].baud_base / SERIAL_BAUD) >> 8);
-	/* 8 data, 1 stop, no parity */
-	serial_outb(com_port + (UART_LCR << shift), 0x03);
-	/* RTS/DTR */
-	serial_outb(com_port + (UART_MCR << shift), 0x03);
+		serial_outb(com_port + (UART_DLM << shift),
+				(rs_table[chan].baud_base / SERIAL_BAUD) >> 8);
+		/* 8 data, 1 stop, no parity */
+		serial_outb(com_port + (UART_LCR << shift), 0x03);
+		/* RTS/DTR */
+		serial_outb(com_port + (UART_MCR << shift), 0x03);
 
-	/* Clear & enable FIFOs */
-	serial_outb(com_port + (UART_FCR << shift), 0x07);
+		/* Clear & enable FIFOs */
+		serial_outb(com_port + (UART_FCR << shift), 0x07);
+	}
 
 	return (com_port);
 }
#1 lore raw
Quoted 1 line · Mark A. Greer

This patch add in the check to see if the UART already appears to be

[...]

arch/ppc/kernel/gen550_dbg.c line 95

Quoted 3 lines
arch/ppc/kernel/gen550_dbg.c +3 -0
+	 * We assume that no-one uses less than 110 baud or
+	 * less than 7 bits per character these days.
+	 *  -- paulus.

'These days' is a relative term, but last I looked, a few years ago, I still had a freind who was using a 6-bit airline protocol on a synchronoous serial port.

Yes, 6-bits means capital letters only. (26 alpha + 10 num + misc=64)

The protocol was still being used in many travel agencies to support older terminals. Our travel agency received it encapsulated in TCP on top of frame-relay. The airlines provides a router which sucks in frame-relay, and spits out 6-bit synch. serial. We used a serial cable to hook up a linux box, and converted the 6-bit protocol into the tcp over ethernet that we wanted.

Thought you might enjoy reading this. I'll skip over the detailed description of the four different end-of-message markers in the protocol.

--linas

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/