No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / evbppc / walnut / consinit.c
blobba984563b567b5f977e89ea8e3f1988d6a9265c6
1 /* $NetBSD: consinit.c,v 1.2.2.3 2004/09/21 13:15:07 skrll Exp $ */
3 /*
4 * Copyright (c) 1998
5 * Matthias Drochner. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.2.2.3 2004/09/21 13:15:07 skrll Exp $");
32 #include "opt_kgdb.h"
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/device.h>
37 #include <machine/bus.h>
39 #include <powerpc/ibm4xx/ibm405gp.h>
40 #include <powerpc/ibm4xx/dev/opbvar.h>
42 #include "com.h"
43 #if (NCOM > 0)
44 #include <sys/termios.h>
45 #include <dev/ic/comreg.h>
46 #include <dev/ic/comvar.h>
47 #endif
49 #include <dev/cons.h>
51 #ifndef CONSDEVNAME
52 #define CONSDEVNAME "com"
53 #endif
55 #if (NCOM > 0)
56 #ifndef CONADDR
57 #define CONADDR IBM405GP_UART0_BASE
58 #endif
59 #ifndef CONSPEED
60 #define CONSPEED B9600 /* */
61 // #define CONSPEED B115200 /* 9600 is too slow for my taste */
62 #endif
63 #ifndef CONMODE
64 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
65 #endif
66 int comcnmode = CONMODE;
67 #endif /* NCOM */
69 #ifdef KGDB
70 #ifndef KGDB_DEVNAME
71 #define KGDB_DEVNAME "com"
72 #endif
73 char kgdb_devname[] = KGDB_DEVNAME;
75 #if (NCOM > 1)
76 #ifndef KGDB_DEVADDR
77 #define KGDB_DEVADDR UART1_BASE
78 #endif
79 int comkgdbaddr = KGDB_DEVADDR;
81 #ifndef KGDB_DEVRATE
82 #define KGDB_DEVRATE CONSPEED
83 #endif
84 int comkgdbrate = KGDB_DEVRATE;
86 #ifndef KGDB_DEVMODE
87 #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
88 #endif
89 int comkgdbmode = KGDB_DEVMODE;
91 #endif /* NCOM */
93 #endif /* KGDB */
96 * consinit:
97 * initialize the system console.
98 * XXX - shouldn't deal with this initted thing, but then,
99 * it shouldn't be called from initppc either.
101 void
102 consinit(void)
104 static int initted = 0;
105 #if (NCOM > 0)
106 bus_space_tag_t tag;
107 #endif
109 if (initted)
110 return;
111 initted = 1;
113 #if (NCOM > 0)
114 /* We *know* the com-console attaches to opb */
115 tag = opb_get_bus_space_tag();
117 if (comcnattach(tag, CONADDR, CONSPEED, COM_FREQ * 6,
118 COM_TYPE_NORMAL, comcnmode))
119 panic("can't init serial console @%x", CONADDR);
120 else
121 return;
122 #endif
123 panic("console device missing -- serial console not in kernel");
124 /* Of course, this is moot if there is no console... */
127 #ifdef KGDB
128 void
129 kgdb_port_init(void)
131 #if (NCOM > 0)
132 if(!strcmp(kgdb_devname, "com")) {
133 bus_space_tag_t tag = opb_get_bus_space_tag();
134 com_kgdb_attach(tag, comkgdbaddr, comkgdbrate, COM_FREQ * 6,
135 COM_TYPE_NORMAL, comkgdbmode);
137 #endif
139 #endif