Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / mmeye / dev / com_mainbus.c
blob06fbb35b33328269193fa69d6ca8f57ed928090c
1 /* $NetBSD: com_mainbus.c,v 1.8 2008/03/14 15:09:10 cube Exp $ */
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * 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 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>
37 #include <dev/cons.h>
38 #include <sys/conf.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>
48 #ifndef COMCN_SPEED
49 #define COMCN_SPEED 19200
50 #endif
51 #ifndef CONADDR
52 #define CONADDR 0xa4000000
53 #endif
54 #ifndef CONMODE
55 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
56 #endif
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);
70 int
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)
77 return (1);
79 return (0);
82 void
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;
89 csc->sc_dev = self;
90 csc->sc_frequency = COM_FREQ;
91 COM_INIT_REGS(csc->sc_regs, 0, ma->ma_addr1, 0);
93 /* sanity check */
94 if (!comprobe1(0, ma->ma_addr1)) {
95 aprint_error(": device problem. don't attach.\n");
96 return;
99 com_attach_subr(csc);
101 mmeye_intr_establish(ma->ma_irq1, IST_LEVEL, IPL_SERIAL, comintr, sc);
104 void
105 comcnprobe(struct consdev *cp)
108 #ifdef COMCONSOLE
109 cp->cn_pri = CN_REMOTE; /* Force a serial port console */
110 #else
111 cp->cn_pri = CN_NORMAL;
112 #endif
115 void
116 comcninit(struct consdev *cp)
119 comcnattach(0, CONADDR, COMCN_SPEED, COM_FREQ, COM_TYPE_NORMAL,
120 CONMODE);