1 /* $NetBSD: omap_com.c,v 1.2 2008/03/14 15:09:09 cube Exp $ */
4 * Based on arch/arm/xscale/pxa2x0_com.c
6 * Copyright 2003 Wasabi Systems, Inc.
9 * Written by Steve C. Woodford for Wasabi Systems, Inc.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed for the NetBSD Project by
22 * Wasabi Systems, Inc.
23 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
24 * or promote products derived from this software without specific prior
27 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
40 #include <sys/cdefs.h>
41 __KERNEL_RCSID(0, "$NetBSD: omap_com.c,v 1.2 2008/03/14 15:09:09 cube Exp $");
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #include <sys/device.h>
48 #include <sys/termios.h>
50 #include <machine/intr.h>
51 #include <machine/bus.h>
53 #include <dev/ic/comreg.h>
54 #include <dev/ic/comvar.h>
56 #include <arm/omap/omap_reg.h>
57 #include <arm/omap/omap_tipb.h>
58 #include <arm/omap/omap_com.h>
62 static int omapuart_match(device_t
, cfdata_t
, void *);
63 static void omapuart_attach(device_t
, device_t
, void *);
65 CFATTACH_DECL_NEW(omapuart
, sizeof(struct com_softc
),
66 omapuart_match
, omapuart_attach
, NULL
, NULL
);
69 omapuart_match(device_t parent
, cfdata_t cf
, void *aux
)
71 struct tipb_attach_args
*tipb
= aux
;
72 bus_space_handle_t bh
;
75 if (tipb
->tipb_addr
== -1 || tipb
->tipb_intr
== -1)
76 panic("omapuart must have addr and intr specified in config.");
78 if (tipb
->tipb_size
== 0)
79 tipb
->tipb_size
= OMAP_COM_SIZE
;
81 if (com_is_console(tipb
->tipb_iot
, tipb
->tipb_addr
, NULL
))
84 if (bus_space_map(tipb
->tipb_iot
, tipb
->tipb_addr
, tipb
->tipb_size
,
89 * The TRM says the mode should be disabled while dll and dlh are
90 * being changed so we disable before probing, then enable.
92 bus_space_write_1(tipb
->tipb_iot
, bh
,
93 OMAP_COM_MDR1
, OMAP_COM_MDR1_MODE_DISABLE
);
95 rv
= comprobe1(tipb
->tipb_iot
, bh
);
97 bus_space_write_1(tipb
->tipb_iot
, bh
,
98 OMAP_COM_MDR1
, OMAP_COM_MDR1_MODE_UART_16X
);
100 bus_space_unmap(tipb
->tipb_iot
, bh
, tipb
->tipb_size
);
106 omapuart_attach(device_t parent
, device_t self
, void *aux
)
108 struct com_softc
*sc
= device_private(self
);
109 struct tipb_attach_args
*tipb
= aux
;
111 bus_space_handle_t ioh
;
115 iot
= tipb
->tipb_iot
;
116 iobase
= tipb
->tipb_addr
;
117 sc
->sc_frequency
= OMAP_COM_FREQ
;
118 sc
->sc_type
= COM_TYPE_NORMAL
;
120 if (com_is_console(iot
, iobase
, &ioh
) == 0 &&
121 bus_space_map(iot
, iobase
, tipb
->tipb_size
, 0, &ioh
)) {
122 panic(": can't map registers\n");
125 COM_INIT_REGS(sc
->sc_regs
, iot
, ioh
, iobase
);
130 omap_intr_establish(tipb
->tipb_intr
, IPL_SERIAL
,
131 device_xname(sc
->sc_dev
), comintr
, sc
);