linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] early serial init
@ 2002-04-11 20:00 John Tyner
  2002-04-11 14:20 ` Armin
  0 siblings, 1 reply; 16+ messages in thread
From: John Tyner @ 2002-04-11 20:00 UTC (permalink / raw)
  To: linuxppc-embedded


Here is a patch to setup the serial ports early. It works fine on our
walnut boards.

--- arch/ppc/platforms/walnut.c.orig	Thu Apr 11 12:55:55 2002
+++ arch/ppc/platforms/walnut.c	Thu Apr 11 12:58:35 2002
@@ -31,6 +31,7 @@
 #include <linux/blk.h>
 #include <linux/pci.h>
 #include <linux/rtc.h>
+#include <linux/serial.h>

 #include <asm/system.h>
 #include <asm/pci-bridge.h>
@@ -247,6 +248,11 @@
 void __init
 board_init(void)
 {
+	struct serial_struct serial_req;
+	bd_t *bip = (bd_t *) __res;
+	u32 chrcr;
+	int div;
+	ulong bb;
 #ifdef CONFIG_PPC_RTC
 	ppc_md.time_init = todc_time_init;
 	ppc_md.set_rtc_time = todc_set_rtc_time;
@@ -254,4 +260,40 @@
 	ppc_md.nvram_read_val = todc_direct_read_val;
 	ppc_md.nvram_write_val = todc_direct_write_val;
 #endif
+	chrcr = mfdcr(DCRN_CHCR0);
+	div = ((chrcr&0x3e)>>1)+1;
+	div *= 16;
+	bb = bip->bi_intfreq/div;
+
+	if( !(chrcr & CHR0_U0EC) ){
+		memset(&serial_req, 0, sizeof(serial_req));
+		serial_req.line       = 0;
+		serial_req.baud_base  = bb;
+		serial_req.port       = 0;
+		serial_req.irq        = UART0_INT;
+		serial_req.flags      = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
+		serial_req.io_type    = SERIAL_IO_MEM;
+		serial_req.iomem_base = (u8 *)UART0_IO_BASE;
+		serial_req.iomem_reg_shift = 0;
+
+		if (early_serial_setup(&serial_req) != 0) {
+			printk("Early serial init of port 0 failed\n");
+		}
+	}
+
+	if( !(chrcr & CHR0_U1EC) ){
+		memset(&serial_req, 0, sizeof(serial_req));
+		serial_req.line       = 1;
+		serial_req.baud_base  = bb;
+		serial_req.port       = 1;
+		serial_req.irq        = UART1_INT;
+		serial_req.flags      = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
+		serial_req.io_type    = SERIAL_IO_MEM;
+		serial_req.iomem_base = (u8 *)UART1_IO_BASE;
+		serial_req.iomem_reg_shift = 0;
+
+		if (early_serial_setup(&serial_req) != 0) {
+			printk("Early serial init of port 1 failed\n");
+		}
+	}
 }


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

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2002-04-12  1:29 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-11 20:00 [PATCH] early serial init John Tyner
2002-04-11 14:20 ` Armin
2002-04-11 21:26   ` John Tyner
2002-04-11 14:53     ` Armin
2002-04-11 22:36       ` andrew may
2002-04-11 16:05         ` Armin
2002-04-11 23:18           ` andrew may
2002-04-11 22:43         ` Matthew Locke
2002-04-11 22:52           ` John Tyner
2002-04-11 22:54         ` Matthew Locke
2002-04-11 23:10         ` Tom Rini
2002-04-11 23:28           ` andrew may
2002-04-12  0:03             ` Tom Rini
2002-04-12  0:41               ` andrew may
2002-04-11 23:09       ` Tom Rini
2002-04-12  1:29         ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).