1 /* $NetBSD: consinit.c,v 1.3 2011/07/18 17:26:56 dyoung Exp $ */
2
3 /*-
4 * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tim Rightnour
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.3 2011/07/18 17:26:56 dyoung Exp $");
34
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/bus.h>
38
39 #include <machine/bootinfo.h>
40 #include <machine/intr.h>
41
42 #include <dev/cons.h>
43
44 #include "com.h"
45 #undef NCOM
46 #define NCOM 1
47 #if (NCOM > 0)
48 #include <sys/termios.h>
49 #include <dev/ic/comreg.h>
50 #include <dev/ic/comvar.h>
51 void comsoft(void);
52 #endif
53
54 extern void setled(uint32_t);
55
56 #undef COM_FREQ
57 #define COM_FREQ_PWR 23961600
58 #define COM_FREQ 8000000
59 /*
60 * consinit
61 * Initialize system console.
62 */
63 void
consinit(void)64 consinit(void)
65 {
66 struct btinfo_console *consinfo;
67 static int initted = 0;
68
69 if (initted)
70 return;
71 initted = 1;
72
73 consinfo = (struct btinfo_console *)lookup_bootinfo(BTINFO_CONSOLE);
74 if (!consinfo)
75 panic("not found console information in bootinfo");
76
77 /* #if (NCOM > 0) */
78 #if 1
79 if (!strcmp(consinfo->devname, "com")) {
80 bus_space_tag_t tag = &rs6000_iocc0_io_space_tag;
81
82 if(comcnattach(tag, consinfo->addr, consinfo->speed, COM_FREQ,
83 COM_TYPE_NORMAL,
84 ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8))) {
85 setled(0x77800000);
86 panic("can't init serial console");
87 }
88 setled(0x77700000);
89 return;
90 }
91 #endif
92 panic("invalid console device %s", consinfo->devname);
93 }
94