1 /* $NetBSD: sscom_s3c2800.c,v 1.6 2005/12/11 12:16:51 christos Exp $ */
4 * Copyright (c) 2002, 2003 Fujitsu Component Limited
5 * Copyright (c) 2002, 2003 Genetec Corporation
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. Neither the name of The Fujitsu Component Limited nor the name of
17 * Genetec corporation may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY FUJITSU COMPONENT LIMITED AND GENETEC
21 * CORPORATION ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC
25 * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/cdefs.h>
36 __KERNEL_RCSID(0, "$NetBSD: sscom_s3c2800.c,v 1.6 2005/12/11 12:16:51 christos Exp $");
38 #include "opt_sscom.h"
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/ioctl.h>
45 #include <sys/select.h>
51 #include <sys/kernel.h>
52 #include <sys/syslog.h>
53 #include <sys/types.h>
54 #include <sys/device.h>
55 #include <sys/malloc.h>
56 #include <sys/timepps.h>
57 #include <sys/vnode.h>
59 #include <machine/intr.h>
60 #include <machine/bus.h>
62 #include <arm/s3c2xx0/s3c2800reg.h>
63 #include <arm/s3c2xx0/s3c2800var.h>
64 #include <arm/s3c2xx0/sscom_var.h>
65 #include <sys/termios.h>
67 static int sscom_match(struct device
*, struct cfdata
*, void *);
68 static void sscom_attach(struct device
*, struct device
*, void *);
70 CFATTACH_DECL(sscom
, sizeof(struct sscom_softc
), sscom_match
,
71 sscom_attach
, NULL
, NULL
);
73 const struct sscom_uart_info s3c2800_uart_config
[] = {
93 sscom_match(struct device
*parent
, struct cfdata
*cf
, void *aux
)
95 struct s3c2xx0_attach_args
*sa
= aux
;
96 int unit
= sa
->sa_index
;
98 return unit
== 0 || unit
== 1;
102 sscom_attach(struct device
*parent
, struct device
*self
, void *aux
)
104 struct sscom_softc
*sc
= (struct sscom_softc
*)self
;
105 struct s3c2xx0_attach_args
*sa
= aux
;
106 int unit
= sa
->sa_index
;
107 bus_addr_t iobase
= s3c2800_uart_config
[unit
].iobase
;
109 printf( ": UART%d addr=%lx", sa
->sa_index
, iobase
);
111 sc
->sc_iot
= s3c2xx0_softc
->sc_iot
;
113 sc
->sc_frequency
= s3c2xx0_softc
->sc_pclk
;
115 sc
->sc_rx_irqno
= S3C2800_INT_RXD0
+ sa
->sa_index
;
116 sc
->sc_tx_irqno
= S3C2800_INT_TXD0
+ sa
->sa_index
;
118 if (bus_space_map(sc
->sc_iot
, iobase
, SSCOM_SIZE
, 0, &sc
->sc_ioh
)) {
119 printf( ": failed to map registers\n" );
125 s3c2800_intr_establish(s3c2800_uart_config
[unit
].tx_int
,
126 IPL_SERIAL
, IST_LEVEL
, sscomtxintr
, sc
);
127 s3c2800_intr_establish(s3c2800_uart_config
[unit
].rx_int
,
128 IPL_SERIAL
, IST_LEVEL
, sscomrxintr
, sc
);
129 s3c2800_intr_establish(s3c2800_uart_config
[unit
].err_int
,
130 IPL_SERIAL
, IST_LEVEL
, sscomrxintr
, sc
);
131 sscom_disable_txrxint(sc
);
133 sscom_attach_subr(sc
);
139 s3c2800_sscom_cnattach(bus_space_tag_t iot
, int unit
, int rate
,
140 int frequency
, tcflag_t cflag
)
142 return sscom_cnattach(iot
, s3c2800_uart_config
+ unit
,
143 rate
, frequency
, cflag
);
148 s3c2800_sscom_kgdb_attach(bus_space_tag_t iot
, int unit
, int rate
,
149 int frequency
, tcflag_t cflag
)
151 return sscom_kgdb_attach(iot
, s3c2800_uart_config
+ unit
,
152 rate
, frequency
, cflag
);