1 /* $OpenBSD: omap_com.c,v 1.2 2013/11/06 19:03:07 syl Exp $ */
3 * Copyright 2003 Wasabi Systems, Inc.
6 * Written by Steve C. Woodford for Wasabi Systems, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed for the NetBSD Project by
19 * Wasabi Systems, Inc.
20 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
21 * or promote products derived from this software without specific prior
24 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/device.h>
42 #include <machine/intr.h>
43 #include <machine/bus.h>
45 #include <dev/ic/comreg.h>
46 #include <dev/ic/comvar.h>
48 /* pick up armv7_a4x_bs_tag */
49 #include <arch/arm/armv7/armv7var.h>
51 #include <armv7/armv7/armv7var.h>
54 #define ISR_RECV (ISR_RXPL | ISR_XMODE | ISR_RCVEIR)
56 void omapuart_attach(struct device
*, struct device
*, void *);
57 int omapuart_activate(struct device
*, int);
59 struct cfattach com_omap_ca
= {
60 sizeof (struct com_softc
), NULL
, omapuart_attach
, NULL
,
65 omapuart_attach(struct device
*parent
, struct device
*self
, void *aux
)
67 struct com_softc
*sc
= (struct com_softc
*)self
;
68 struct armv7_attach_args
*aa
= aux
;
70 sc
->sc_iot
= &armv7_a4x_bs_tag
; /* XXX: This sucks */
71 sc
->sc_iobase
= aa
->aa_dev
->mem
[0].addr
;
72 sc
->sc_frequency
= 48000000;
73 sc
->sc_uarttype
= COM_UART_TI16750
;
75 if (bus_space_map(sc
->sc_iot
, sc
->sc_iobase
,
76 aa
->aa_dev
->mem
[0].size
, 0, &sc
->sc_ioh
)) {
77 printf("%s: bus_space_map failed\n", __func__
);
83 (void)arm_intr_establish(aa
->aa_dev
->irq
[0], IPL_TTY
, comintr
,
84 sc
, sc
->sc_dev
.dv_xname
);
88 omapuart_activate(struct device
*self
, int act
)
90 struct com_softc
*sc
= (struct com_softc
*)self
;
91 bus_space_tag_t iot
= sc
->sc_iot
;
92 bus_space_handle_t ioh
= sc
->sc_ioh
;
93 struct tty
*tp
= sc
->sc_tty
;
100 sc
->sc_initialize
= 1;
101 comparam(tp
, &tp
->t_termios
);
102 bus_space_write_1(iot
, ioh
, com_ier
, sc
->sc_ier
);
104 if (ISSET(sc
->sc_hwflags
, COM_HW_SIR
)) {
105 bus_space_write_1(iot
, ioh
, com_isr
,