Skip to contentSkip to conversation

16552 UART detection

PATCH David Howells 1 participant 1 message Mar 10, 2004

lore
Share & tools
lore
#0 lore raw

Hi Russell,

Would something like the following be a reasonable way of detecting a NatSemi PC16552 UART?:

	if type == 16650A
	then
		set LCR.DLAB to 1
		if EFR bits 7-3 are 0
		then
			set EFR to 0xff
			if EFR == 0x07
			then
				set type to 16552
				set EFR to 0
			fi
		else
			restore EFR to previous value
		fi
	fi

This needs to be inserted before the test for the StarTech ST16650.

I've implemented by the attached patch against a 2.4.18 kernel.

David

Index: drivers/char/serial.c
===================================================================
RCS file: /home/cvs/linux-am33-2.4.18/drivers/char/serial.c,v retrieving revision 1.1.1.1

char/serial.c +14 -0
diff -u -r1.1.1.1 serial.c
@@ -312,6 +312,7 @@
 	{ "XR16850", 128, UART_CLEAR_FIFO | UART_USE_FIFO |
 		  UART_STARTECH },
 	{ "RSA", 2048, UART_CLEAR_FIFO | UART_USE_FIFO }, 
+	{ "16552", 16, UART_CLEAR_FIFO | UART_USE_FIFO }, 
 	{ 0, 0}
 };
 
@@ -3739,6 +3740,19 @@
 		case 3:
 			state->type = PORT_16550A;
 			break;
+	}
+	if (state->type == PORT_16550A) {
+		/* check for half of an NS 16552 */
+		serial_outp(info, UART_LCR, UART_LCR_DLAB);
+		scratch = serial_in(info, UART_EFR);
+		if ((scratch & ~7) == 0) {
+			serial_outp(info, UART_EFR, 0xff);
+			if (serial_in(info, UART_EFR) == 7) {
+				state->type = PORT_16552;
+				scratch = 0;
+			}
+			serial_outp(info, UART_EFR, scratch);
+		}
 	}
 	if (state->type == PORT_16550A) {
 		/* Check for Startech UART's */

Index: include/linux/serial.h
===================================================================
RCS file: /home/cvs/linux-am33-2.4.18/include/linux/serial.h,v retrieving revision 1.1.1.1

linux/serial.h +2 -1
diff -u -r1.1.1.1 serial.h
@@ -75,7 +75,8 @@
 #define PORT_16654	11
 #define PORT_16850	12
 #define PORT_RSA	13	/* RSA-DV II/S card */
-#define PORT_MAX	13
+#define PORT_16552	14
+#define PORT_MAX	14
 
 #define SERIAL_IO_PORT	0
 #define SERIAL_IO_HUB6	1