1*4f3f7d19Srin /* $NetBSD: consinit.c,v 1.12 2021/03/07 09:48:33 rin Exp $ */
2249e0067Shannken
3249e0067Shannken /*-
4249e0067Shannken * Copyright (c) 2003 The NetBSD Foundation, Inc.
5249e0067Shannken * All rights reserved.
6249e0067Shannken *
7249e0067Shannken * This code is derived from software contributed to The NetBSD Foundation
8249e0067Shannken * by Juergen Hannken-Illjes.
9249e0067Shannken *
10249e0067Shannken * Redistribution and use in source and binary forms, with or without
11249e0067Shannken * modification, are permitted provided that the following conditions
12249e0067Shannken * are met:
13249e0067Shannken * 1. Redistributions of source code must retain the above copyright
14249e0067Shannken * notice, this list of conditions and the following disclaimer.
15249e0067Shannken * 2. Redistributions in binary form must reproduce the above copyright
16249e0067Shannken * notice, this list of conditions and the following disclaimer in the
17249e0067Shannken * documentation and/or other materials provided with the distribution.
18249e0067Shannken *
19249e0067Shannken * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20249e0067Shannken * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21249e0067Shannken * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22249e0067Shannken * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23249e0067Shannken * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24249e0067Shannken * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25249e0067Shannken * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26249e0067Shannken * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27249e0067Shannken * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28249e0067Shannken * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29249e0067Shannken * POSSIBILITY OF SUCH DAMAGE.
30249e0067Shannken */
31249e0067Shannken
3214172728Slukem #include <sys/cdefs.h>
33*4f3f7d19Srin __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.12 2021/03/07 09:48:33 rin Exp $");
3414172728Slukem
35249e0067Shannken #include <sys/param.h>
36249e0067Shannken #include <sys/systm.h>
37249e0067Shannken
38249e0067Shannken #include <machine/explora.h>
39cf10107dSdyoung #include <sys/bus.h>
40249e0067Shannken
41249e0067Shannken #include "com.h"
42249e0067Shannken #if NCOM > 0
43249e0067Shannken #include <sys/termios.h>
44249e0067Shannken #include <dev/ic/comreg.h>
45249e0067Shannken #include <dev/ic/comvar.h>
46249e0067Shannken #endif
47249e0067Shannken
48249e0067Shannken #include "pckbc.h"
49249e0067Shannken #if (NPCKBC > 0)
50249e0067Shannken #include <dev/isa/isareg.h>
51249e0067Shannken #include <dev/ic/i8042reg.h>
52249e0067Shannken #include <dev/ic/pckbcvar.h>
53249e0067Shannken #endif
54249e0067Shannken #include "pckbd.h"
55249e0067Shannken
560b0e493eSscw #include <evbppc/explora/dev/elbvar.h>
5712c9d0e1Srin #include <powerpc/ibm4xx/cpu.h>
580b0e493eSscw
59249e0067Shannken #include "opt_explora.h"
60249e0067Shannken
61249e0067Shannken #ifndef COM_CONSOLE_SPEED
62249e0067Shannken #define COM_CONSOLE_SPEED 9600
63249e0067Shannken #endif
64249e0067Shannken
65ebd20e00Srin extern void fb_cnattach(bus_space_tag_t, bus_addr_t, void *);
66ebd20e00Srin
67249e0067Shannken void
consinit(void)68249e0067Shannken consinit(void)
69249e0067Shannken {
70249e0067Shannken bus_space_tag_t tag;
71249e0067Shannken static int done = 0;
72249e0067Shannken
73249e0067Shannken if (done)
74249e0067Shannken return;
75249e0067Shannken
76249e0067Shannken done = 1;
77249e0067Shannken
78249e0067Shannken #ifdef COM_IS_CONSOLE
790b0e493eSscw tag = elb_get_bus_space_tag(BASE_COM);
808b992330Shannken comcnattach(tag, _BUS_SPACE_UNSTRIDE(tag, BASE_COM), COM_CONSOLE_SPEED,
810eff6718Sthorpej COM_FREQ, COM_TYPE_NORMAL,
82249e0067Shannken (TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8);
83249e0067Shannken #else
840b0e493eSscw tag = elb_get_bus_space_tag(BASE_FB);
85249e0067Shannken fb_cnattach(tag, BASE_FB2, (void *)BASE_FB);
8612c9d0e1Srin
8712c9d0e1Srin calc_delayconst(); /* required by pckbc_cnattach() */
8812c9d0e1Srin
890b0e493eSscw tag = elb_get_bus_space_tag(BASE_PCKBC);
908b992330Shannken pckbc_cnattach(tag, _BUS_SPACE_UNSTRIDE(tag, BASE_PCKBC),
914be6ce2eSjdc _BUS_SPACE_UNSTRIDE(tag, BASE_PCKBC2-BASE_PCKBC), PCKBC_KBD_SLOT,
924be6ce2eSjdc 0);
93249e0067Shannken #endif
94249e0067Shannken }
95