1 /* $OpenBSD: com_iof.c,v 1.5 2009/10/16 00:15:46 miod Exp $ */
4 * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/param.h>
30 #include <sys/systm.h>
31 #include <sys/device.h>
34 #include <machine/autoconf.h>
35 #include <machine/bus.h>
37 #include <dev/ic/comreg.h>
38 #include <dev/ic/comvar.h>
40 #include <octeon/dev/obiovar.h>
41 #include <octeon/dev/octeonreg.h>
43 int com_oct_probe(struct device *, void *, void *);
44 void com_oct_attach(struct device *, struct device *, void *);
46 struct cfattach com_oct_ca = {
47 sizeof(struct com_softc), com_oct_probe, com_oct_attach
50 extern struct cfdriver com_cd;
53 com_oct_probe(struct device *parent, void *match, void *aux)
55 struct cfdata *cf = match;
56 struct obio_attach_args *oba = aux;
57 bus_space_tag_t iot = oba->oba_memt;
58 bus_space_handle_t ioh;
61 if (strcmp(oba->oba_name, com_cd.cd_name) != 0)
66 /* if it's in use as console, it's there. */
67 if (!(console && !comconsattached)) {
68 if (bus_space_map(iot, oba->oba_baseaddr, COM_NPORTS, 0, &ioh)) {
69 printf(": can't map uart registers\n");
72 rv = comprobe1(iot, ioh);
76 /* make a config stanza with exact locators match over a generic line */
77 if (cf->cf_loc[0] != -1)
84 com_oct_attach(struct device *parent, struct device *self, void *aux)
86 struct com_softc *sc = (void *)self;
87 struct obio_attach_args *oba = aux;
92 sc->sc_iot = oba->oba_memt;
93 sc->sc_iobase = oba->oba_baseaddr;
96 sc->sc_frequency = curcpu()->ci_hw.clock;
97 sc->sc_uarttype = COM_UART_16550;
99 /* if it's in use as console, it's there. */
100 if (bus_space_map(sc->sc_iot, sc->sc_iobase, COM_NPORTS, 0, &sc->sc_ioh)) {
101 printf(": can't map uart registers\n");
105 if (console && !comconsattached) {
107 * If we are the console, reuse the existing bus_space
108 * information, so that comcnattach() invokes bus_space_map()
109 * with correct parameters.
112 if (comcnattach(sc->sc_iot, sc->sc_iobase, 115200,
113 sc->sc_frequency, (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
114 panic("can't setup serial console");
119 obio_intr_establish(oba->oba_intr, IPL_TTY, comintr,
120 (void *)sc, sc->sc_dev.dv_xname);