sscom_var.h revision 1.1 1 1.1 bsh /* $NetBSD: sscom_var.h,v 1.1 2002/11/20 17:52:53 bsh Exp $ */
2 1.1 bsh
3 1.1 bsh /*
4 1.1 bsh * Copyright (c) 2002 Fujitsu Component Limited
5 1.1 bsh * Copyright (c) 2002 Genetec Corporation
6 1.1 bsh * All rights reserved.
7 1.1 bsh *
8 1.1 bsh * Redistribution and use in source and binary forms, with or without
9 1.1 bsh * modification, are permitted provided that the following conditions
10 1.1 bsh * are met:
11 1.1 bsh * 1. Redistributions of source code must retain the above copyright
12 1.1 bsh * notice, this list of conditions and the following disclaimer.
13 1.1 bsh * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 bsh * notice, this list of conditions and the following disclaimer in the
15 1.1 bsh * documentation and/or other materials provided with the distribution.
16 1.1 bsh * 3. Neither the name of The Fujitsu Component Limited nor the name of
17 1.1 bsh * Genetec corporation may not be used to endorse or promote products
18 1.1 bsh * derived from this software without specific prior written permission.
19 1.1 bsh *
20 1.1 bsh * THIS SOFTWARE IS PROVIDED BY FUJITSU COMPONENT LIMITED AND GENETEC
21 1.1 bsh * CORPORATION ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 1.1 bsh * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 1.1 bsh * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 1.1 bsh * DISCLAIMED. IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC
25 1.1 bsh * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 1.1 bsh * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 1.1 bsh * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 1.1 bsh * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 1.1 bsh * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 1.1 bsh * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 1.1 bsh * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 bsh * SUCH DAMAGE.
33 1.1 bsh */
34 1.1 bsh /* derived from sys/dev/ic/comvar.h */
35 1.1 bsh /*
36 1.1 bsh * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
37 1.1 bsh *
38 1.1 bsh * Redistribution and use in source and binary forms, with or without
39 1.1 bsh * modification, are permitted provided that the following conditions
40 1.1 bsh * are met:
41 1.1 bsh * 1. Redistributions of source code must retain the above copyright
42 1.1 bsh * notice, this list of conditions and the following disclaimer.
43 1.1 bsh * 2. Redistributions in binary form must reproduce the above copyright
44 1.1 bsh * notice, this list of conditions and the following disclaimer in the
45 1.1 bsh * documentation and/or other materials provided with the distribution.
46 1.1 bsh * 3. All advertising materials mentioning features or use of this software
47 1.1 bsh * must display the following acknowledgement:
48 1.1 bsh * This product includes software developed by Christopher G. Demetriou
49 1.1 bsh * for the NetBSD Project.
50 1.1 bsh * 4. The name of the author may not be used to endorse or promote products
51 1.1 bsh * derived from this software without specific prior written permission
52 1.1 bsh *
53 1.1 bsh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
54 1.1 bsh * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
55 1.1 bsh * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
56 1.1 bsh * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
57 1.1 bsh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
58 1.1 bsh * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59 1.1 bsh * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60 1.1 bsh * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61 1.1 bsh * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
62 1.1 bsh * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 1.1 bsh */
64 1.1 bsh
65 1.1 bsh #ifndef _ARM_S3C2XX0_SSCOM_VAR_H
66 1.1 bsh #define _ARM_S3C2XX0_SSCOM_VAR_H
67 1.1 bsh
68 1.1 bsh #include <sys/param.h>
69 1.1 bsh #include <sys/systm.h>
70 1.1 bsh #include <sys/device.h>
71 1.1 bsh #include <sys/termios.h>
72 1.1 bsh #include <sys/callout.h>
73 1.1 bsh #include <machine/bus.h>
74 1.1 bsh
75 1.1 bsh /* Hardware flag masks */
76 1.1 bsh #define SSCOM_HW_FIFO 0x01
77 1.1 bsh #define SSCOM_HW_FLOW 0x02
78 1.1 bsh #define SSCOM_HW_DEV_OK 0x04
79 1.1 bsh #define SSCOM_HW_CONSOLE 0x08
80 1.1 bsh #define SSCOM_HW_KGDB 0x10
81 1.1 bsh #define SSCOM_HW_TXINT 0x20
82 1.1 bsh #define SSCOM_HW_RXINT 0x40
83 1.1 bsh
84 1.1 bsh /* Buffer size for character buffer */
85 1.1 bsh #define SSCOM_RING_SIZE 2048
86 1.1 bsh
87 1.1 bsh struct sscom_softc {
88 1.1 bsh struct device sc_dev;
89 1.1 bsh void *sc_si;
90 1.1 bsh struct tty *sc_tty;
91 1.1 bsh
92 1.1 bsh struct callout sc_diag_callout;
93 1.1 bsh
94 1.1 bsh int sc_unit; /* UART0/UART1 */
95 1.1 bsh int sc_frequency;
96 1.1 bsh
97 1.1 bsh bus_space_tag_t sc_iot;
98 1.1 bsh bus_space_handle_t sc_ioh;
99 1.1 bsh
100 1.1 bsh u_int sc_overflows,
101 1.1 bsh sc_floods,
102 1.1 bsh sc_errors;
103 1.1 bsh
104 1.1 bsh int sc_hwflags,
105 1.1 bsh sc_swflags;
106 1.1 bsh u_int sc_fifolen;
107 1.1 bsh
108 1.1 bsh u_int sc_r_hiwat,
109 1.1 bsh sc_r_lowat;
110 1.1 bsh u_char *volatile sc_rbget,
111 1.1 bsh *volatile sc_rbput;
112 1.1 bsh volatile u_int sc_rbavail;
113 1.1 bsh u_char *sc_rbuf,
114 1.1 bsh *sc_ebuf;
115 1.1 bsh
116 1.1 bsh u_char *sc_tba;
117 1.1 bsh u_int sc_tbc,
118 1.1 bsh sc_heldtbc;
119 1.1 bsh
120 1.1 bsh volatile u_char sc_rx_flags,
121 1.1 bsh #define RX_TTY_BLOCKED 0x01
122 1.1 bsh #define RX_TTY_OVERFLOWED 0x02
123 1.1 bsh #define RX_IBUF_BLOCKED 0x04
124 1.1 bsh #define RX_IBUF_OVERFLOWED 0x08
125 1.1 bsh #define RX_ANY_BLOCK 0x0f
126 1.1 bsh sc_tx_busy,
127 1.1 bsh sc_tx_done,
128 1.1 bsh sc_tx_stopped,
129 1.1 bsh sc_st_check,
130 1.1 bsh sc_rx_ready;
131 1.1 bsh
132 1.1 bsh /* data to stored in UART registers.
133 1.1 bsh actual write to UART register is pended while sc_tx_busy */
134 1.1 bsh uint16_t sc_ucon; /* control register */
135 1.1 bsh uint16_t sc_ubrdiv; /* baudrate register */
136 1.1 bsh uint8_t sc_heldchange; /* register changes are pended */
137 1.1 bsh uint8_t sc_ulcon; /* line control */
138 1.1 bsh uint8_t sc_umcon; /* modem control */
139 1.1 bsh #define UMCON_HW_MASK (UMCON_RTS)
140 1.1 bsh #define UMCON_DTR (1<<4) /* provided by other means such as GPIO */
141 1.1 bsh uint8_t sc_msts; /* modem status */
142 1.1 bsh #define MSTS_CTS UMSTAT_CTS /* bit0 */
143 1.1 bsh #define MSTS_DCD (1<<1)
144 1.1 bsh #define MSTS_DSR (1<<2)
145 1.1 bsh
146 1.1 bsh uint8_t sc_msr_dcd; /* DCD or 0 */
147 1.1 bsh uint8_t sc_mcr_dtr; /* DTR or 0 or DTR|RTS*/
148 1.1 bsh uint8_t sc_mcr_rts; /* RTS or DTR in sc_umcon */
149 1.1 bsh uint8_t sc_msr_cts; /* CTS or DCD in sc_msts */
150 1.1 bsh
151 1.1 bsh uint8_t sc_msr_mask; /* sc_msr_cts|sc_msr_dcd */
152 1.1 bsh uint8_t sc_mcr_active;
153 1.1 bsh uint8_t sc_msr_delta;
154 1.1 bsh
155 1.1 bsh uint8_t sc_rx_irqno, sc_tx_irqno;
156 1.1 bsh
157 1.1 bsh #if 0
158 1.1 bsh /* PPS signal on DCD, with or without inkernel clock disciplining */
159 1.1 bsh u_char sc_ppsmask; /* pps signal mask */
160 1.1 bsh u_char sc_ppsassert; /* pps leading edge */
161 1.1 bsh u_char sc_ppsclear; /* pps trailing edge */
162 1.1 bsh pps_info_t ppsinfo;
163 1.1 bsh pps_params_t ppsparam;
164 1.1 bsh #endif
165 1.1 bsh
166 1.1 bsh #if NRND > 0 && defined(RND_COM)
167 1.1 bsh rndsource_element_t rnd_source;
168 1.1 bsh #endif
169 1.1 bsh #if (defined(MULTIPROCESSOR) || defined(LOCKDEBUG)) && defined(SSCOM_MPLOCK)
170 1.1 bsh struct simplelock sc_lock;
171 1.1 bsh #endif
172 1.1 bsh
173 1.1 bsh /*
174 1.1 bsh * S3C2XX0's UART doesn't have modem control/status pins.
175 1.1 bsh * On platforms with S3C2XX0, those pins are simply unavailable
176 1.1 bsh * or provided by other means such as GPIO. Platform specific attach routine
177 1.1 bsh * have to provide functions to read/write modem control/status pins.
178 1.1 bsh */
179 1.1 bsh int (* read_modem_status)( struct sscom_softc * );
180 1.1 bsh void (* set_modem_control)( struct sscom_softc * );
181 1.1 bsh };
182 1.1 bsh
183 1.1 bsh /* Macros to clear/set/test flags. */
184 1.1 bsh #define SET(t, f) (t) |= (f)
185 1.1 bsh #define CLR(t, f) (t) &= ~(f)
186 1.1 bsh #define ISSET(t, f) ((t) & (f))
187 1.1 bsh
188 1.1 bsh /* UART register address, etc. */
189 1.1 bsh struct sscom_uart_info {
190 1.1 bsh int unit;
191 1.1 bsh char tx_int, rx_int, err_int;
192 1.1 bsh bus_addr_t iobase;
193 1.1 bsh };
194 1.1 bsh
195 1.1 bsh #define sscom_rxrdy(iot,ioh) \
196 1.1 bsh (bus_space_read_1((iot), (ioh), SSCOM_UTRSTAT) & UTRSTAT_RXREADY)
197 1.1 bsh #define sscom_getc(iot,ioh) bus_space_read_1((iot), (ioh), SSCOM_URXH)
198 1.1 bsh #define sscom_geterr(iot,ioh) bus_space_read_1((iot), (ioh), SSCOM_UERSTAT)
199 1.1 bsh
200 1.1 bsh #define sscom_enable_rxint(sc) (s3c2xx0_unmask_interrupts(1<<sc->sc_rx_irqno), \
201 1.1 bsh (sc->sc_hwflags |= SSCOM_HW_RXINT))
202 1.1 bsh #define sscom_disable_rxint(sc) (s3c2xx0_mask_interrupts(1<<sc->sc_rx_irqno), \
203 1.1 bsh (sc->sc_hwflags &= ~SSCOM_HW_RXINT))
204 1.1 bsh #define sscom_enable_txint(sc) (s3c2xx0_unmask_interrupts(1<<sc->sc_tx_irqno), \
205 1.1 bsh (sc->sc_hwflags |= SSCOM_HW_TXINT))
206 1.1 bsh #define sscom_disable_txint(sc) (s3c2xx0_mask_interrupts(1<<sc->sc_tx_irqno), \
207 1.1 bsh (sc->sc_hwflags &= ~SSCOM_HW_TXINT))
208 1.1 bsh #define sscom_enable_txrxint(sc) \
209 1.1 bsh (s3c2xx0_unmask_interrupts((1<<sc->sc_tx_irqno)|(1<<sc->sc_rx_irqno)), \
210 1.1 bsh (sc->sc_hwflags |= (SSCOM_HW_TXINT|SSCOM_HW_RXINT)))
211 1.1 bsh #define sscom_disable_txrxint(sc) \
212 1.1 bsh (s3c2xx0_mask_interrupts((1<<sc->sc_tx_irqno)|(1<<sc->sc_rx_irqno)), \
213 1.1 bsh (sc->sc_hwflags &= ~(SSCOM_HW_TXINT|SSCOM_HW_RXINT)))
214 1.1 bsh
215 1.1 bsh
216 1.1 bsh int sscomspeed(long, long);
217 1.1 bsh void sscom_attach_subr(struct sscom_softc *);
218 1.1 bsh
219 1.1 bsh int sscom_detach(struct device *, int);
220 1.1 bsh int sscom_activate(struct device *, enum devact);
221 1.1 bsh void sscom_shutdown(struct sscom_softc *);
222 1.1 bsh void sscomdiag (void *);
223 1.1 bsh void sscomstart(struct tty *);
224 1.1 bsh int sscomparam(struct tty *, struct termios *);
225 1.1 bsh int sscomread(dev_t, struct uio *, int);
226 1.1 bsh void sscom_config(struct sscom_softc *);
227 1.1 bsh
228 1.1 bsh int sscomintr(void *);
229 1.1 bsh
230 1.1 bsh int sscom_cnattach(bus_space_tag_t, const struct sscom_uart_info *,
231 1.1 bsh int, int, tcflag_t);
232 1.1 bsh void sscom_cndetach(void);
233 1.1 bsh int sscom_is_console(bus_space_tag_t, int, bus_space_handle_t *);
234 1.1 bsh
235 1.1 bsh #ifdef KGDB
236 1.1 bsh int sscom_kgdb_attach(bus_space_tag_t, const struct sscom_uart_info *,
237 1.1 bsh int, int, tcflag_t);
238 1.1 bsh #endif
239 1.1 bsh
240 1.1 bsh #endif /* _ARM_S3C2XX0_SSCOM_VAR_H */
241