Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / rs6000 / ioplanar / com_iop.c
blob41a9cd6814c3dc0b309a99cb3021fd00c31e7c28
1 /* $NetBSD: com_iop.c,v 1.2 2008/03/14 15:09:10 cube Exp $ */
3 /*-
4 * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tim Rightnour
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.
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.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: com_iop.c,v 1.2 2008/03/14 15:09:10 cube Exp $");
35 #include <sys/param.h>
36 #include <sys/device.h>
37 #include <sys/ioctl.h>
38 #include <sys/tty.h>
40 #include <machine/intr.h>
41 #include <machine/bus.h>
43 #include <dev/ic/comreg.h>
44 #include <dev/ic/comvar.h>
46 #include <dev/mca/mcavar.h>
47 #include <dev/mca/mcadevs.h>
49 #include <rs6000/ioplanar/ioplanarvar.h>
51 struct com_iop_softc {
52 struct com_softc sc_com; /* real com softc */
53 void *sc_ih;
56 int com_iop_probe(device_t, cfdata_t , void *);
57 void com_iop_attach(device_t, device_t, void *);
59 CFATTACH_DECL_NEW(com_iop, sizeof(struct com_iop_softc),
60 com_iop_probe, com_iop_attach, NULL, NULL);
62 #define COM_RAINBOW_FREQ 8000000
65 * This probe is very unorthodox. Basically, we have no way to actually
66 * probe the device, so instead, we check that the specific device should
67 * exist on the ioplanar, and just return true.
70 int
71 com_iop_probe(device_t parent, cfdata_t match, void *aux)
73 struct ioplanar_dev_attach_args *idaa = aux;
75 if (idaa->idaa_devid == MCA_PRODUCT_IBM_SIO_RAINBOW &&
76 (idaa->idaa_device == IOP_COM0 || idaa->idaa_device == IOP_COM1))
77 return 1;
79 return 0;
82 void
83 com_iop_attach(device_t parent, device_t self, void *aux)
85 struct com_iop_softc *isc = device_private(self);
86 struct com_softc *sc = &isc->sc_com;
87 int iobase, irq;
88 struct ioplanar_dev_attach_args *idaa = aux;
89 bus_space_handle_t ioh;
91 sc->sc_dev = self;
93 switch (idaa->idaa_devid) {
94 case MCA_PRODUCT_IBM_SIO_RAINBOW:
95 switch (idaa->idaa_device) {
96 case IOP_COM0:
97 iobase = 0x30;
98 irq = 2; /* ??? */
99 sc->sc_frequency = COM_RAINBOW_FREQ;
100 break;
101 case IOP_COM1:
102 iobase = 0x38;
103 irq = 2; /* ??? */
104 sc->sc_frequency = COM_RAINBOW_FREQ;
105 break;
106 default:
107 return;
109 break;
110 default:
111 return;
113 if (!com_is_console(idaa->idaa_iot, iobase, &ioh) &&
114 bus_space_map(idaa->idaa_iot, iobase, COM_NPORTS, 0, &ioh)) {
115 aprint_error(": can't map i/o space\n");
116 return;
119 COM_INIT_REGS(sc->sc_regs, idaa->idaa_iot, ioh, iobase);
121 aprint_normal("i/o %#x-%#x irq %d", iobase, iobase + COM_NPORTS - 1,
122 irq);
124 com_attach_subr(sc);
126 isc->sc_ih = mca_intr_establish(idaa->idaa_mc, irq, IPL_SERIAL,
127 comintr, sc);
129 if (isc->sc_ih == NULL) {
130 aprint_error_dev(self,
131 "couldn't establish interrupt handler\n");
132 return;