2 * Copyright 2006 Kyma Systems LLC.
5 * Written by Sanjay Lal <sanjayl@kymasys.com>
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.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed for the NetBSD Project by
19 * 4. The name of Kyma Systems LLC may not be used to endorse
20 * or promote products derived from this software without specific prior
23 * THIS SOFTWARE IS PROVIDED BY KYMA SYSTEMS LLC ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KYMA SYSTEMS LLC
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
36 /* com device attachment to mainbus for MAMBO G5 simulator */
38 #include <sys/cdefs.h>
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/device.h>
44 #include <machine/bus.h>
45 #include <dev/ofw/openfirm.h>
47 #include <dev/ic/comreg.h>
48 #include <dev/ic/comvar.h>
50 struct com_mainbus_softc
52 struct com_softc sc_com
; /* real "com" softc */
53 void *sc_ih
; /* interrupt handler */
56 int com_mainbus_probe(device_t
, cfdata_t
, void *);
57 void com_mainbus_attach(device_t
, device_t
, void *);
59 CFATTACH_DECL_NEW(com_mainbus
, sizeof(struct com_mainbus_softc
),
60 com_mainbus_probe
, com_mainbus_attach
, NULL
, NULL
);
62 int com_mainbus_attached
= 0;
64 com_mainbus_probe(device_t parent
, cfdata_t match
, void *aux
)
66 struct confargs
*ca
= aux
;
68 if (strcmp(ca
->ca_name
, "com") != 0)
71 if (!com_mainbus_attached
) {
72 com_mainbus_attached
= 1;
80 com_mainbus_attach(device_t parent
, device_t self
, void *aux
)
82 struct com_mainbus_softc
*msc
= device_private(self
);
83 struct com_softc
*sc
= &msc
->sc_com
;
84 int serial
, interrupt_length
;
87 bus_space_handle_t ioh
;
92 serial
= OF_finddevice("/ht@0/isa@4/serial@0x3f8");
95 OF_getprop(serial
, "interrupts", interrupts
, sizeof(interrupts
));
99 iot
= (bus_space_tag_t
)0xf4000000;
101 comcnattach(iot
, iobase
, 9600, 1843200, COM_TYPE_NORMAL
, (CREAD
| CS8
));
102 bus_space_map(iot
, iobase
, COM_NPORTS
, 0, &ioh
);
103 COM_INIT_REGS(sc
->sc_regs
, iot
, ioh
, iobase
);
105 sc
->sc_frequency
= 1843200;
110 intr_establish(interrupts
[0], IST_LEVEL
, IPL_SERIAL
, comintr
, sc
);
112 if (msc
->sc_ih
== NULL
)
113 panic("failed to establish int handler");