[PATCH] ppc64: Fix early serial setup baud rate

Benjamin Herrenschmidt benh at kernel.crashing.org
Mon Nov 22 12:54:46 EST 2004


Hi !

The "udbg" code used on ppc64 for early consoles including early serial
console recently got a new "default speed" option. This was implemented
as a switch case that missed a few important cases, one beeing necessary
for a board beeing released soon.

This patch fixes it by using the proper division to calculate the dll
value for the uart instead of that bogus switch/case.

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>

Index: linux-work/arch/ppc64/kernel/udbg.c
===================================================================
--- linux-work.orig/arch/ppc64/kernel/udbg.c	2004-11-22 11:49:25.000000000 +1100
+++ linux-work/arch/ppc64/kernel/udbg.c	2004-11-22 11:59:47.652774832 +1100
@@ -56,28 +56,17 @@
 
 void udbg_init_uart(void __iomem *comport, unsigned int speed)
 {
-	u8 dll = 12;
+	u16 dll = speed ? (115200 / speed) : 12;
 
-	switch(speed) {
-	case 115200:
-		dll = 1;
-		break;
-	case 57600:
-		dll = 2;
-		break;
-	case 38400:
-		dll = 3;
-		break;
-	}
 	if (comport) {
 		udbg_comport = (struct NS16550 __iomem *)comport;
 		out_8(&udbg_comport->lcr, 0x00);
 		out_8(&udbg_comport->ier, 0xff);
 		out_8(&udbg_comport->ier, 0x00);
 		out_8(&udbg_comport->lcr, 0x80);	/* Access baud rate */
-		out_8(&udbg_comport->dll,  dll);	/* 1 = 115200,  2 = 57600,
+		out_8(&udbg_comport->dll, dll & 0xff);	/* 1 = 115200,  2 = 57600,
 							   3 = 38400, 12 = 9600 baud */
-		out_8(&udbg_comport->dlm, 0x00);	/* dll >> 8 which should be zero
+		out_8(&udbg_comport->dlm, dll >> 8);	/* dll >> 8 which should be zero
 							   for fast rates; */
 		out_8(&udbg_comport->lcr, 0x03);	/* 8 data, 1 stop, no parity */
 		out_8(&udbg_comport->mcr, 0x03);	/* RTS/DTR */





More information about the Linuxppc64-dev mailing list