1 /* $NetBSD: com_mainbus.c,v 1.8 2008/03/14 15:09:10 cube Exp $ */
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.8 2008/03/14 15:09:10 cube Exp $");
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/device.h>
36 #include <sys/termios.h>
40 #include <machine/bus.h>
41 #include <machine/intr.h>
42 #include <machine/autoconf.h>
43 #include <machine/mmeye.h>
45 #include <dev/ic/comvar.h>
46 #include <dev/ic/comreg.h>
49 #define COMCN_SPEED 19200
52 #define CONADDR 0xa4000000
55 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
58 struct com_mainbus_softc
{
59 struct com_softc sc_com
; /* real "com" softc */
62 int com_mainbus_match(device_t
, cfdata_t
, void *);
63 void com_mainbus_attach(device_t
, device_t
, void *);
64 void comcnprobe(struct consdev
*);
65 void comcninit(struct consdev
*);
67 CFATTACH_DECL_NEW(com_mainbus
, sizeof(struct com_mainbus_softc
),
68 com_mainbus_match
, com_mainbus_attach
, NULL
, NULL
);
71 com_mainbus_match(device_t parent
, cfdata_t match
, void *aux
)
73 extern struct cfdriver com_cd
;
74 struct mainbus_attach_args
*ma
= aux
;
76 if (strcmp(ma
->ma_name
, com_cd
.cd_name
) == 0)
83 com_mainbus_attach(device_t parent
, device_t self
, void *aux
)
85 struct mainbus_attach_args
*ma
= aux
;
86 struct com_mainbus_softc
*sc
= device_private(self
);
87 struct com_softc
*csc
= &sc
->sc_com
;
90 csc
->sc_frequency
= COM_FREQ
;
91 COM_INIT_REGS(csc
->sc_regs
, 0, ma
->ma_addr1
, 0);
94 if (!comprobe1(0, ma
->ma_addr1
)) {
95 aprint_error(": device problem. don't attach.\n");
101 mmeye_intr_establish(ma
->ma_irq1
, IST_LEVEL
, IPL_SERIAL
, comintr
, sc
);
105 comcnprobe(struct consdev
*cp
)
109 cp
->cn_pri
= CN_REMOTE
; /* Force a serial port console */
111 cp
->cn_pri
= CN_NORMAL
;
116 comcninit(struct consdev
*cp
)
119 comcnattach(0, CONADDR
, COMCN_SPEED
, COM_FREQ
, COM_TYPE_NORMAL
,