at91usartvar.h revision 1.2 1 1.2 matt /* $NetBSD: at91usartvar.h,v 1.2 2008/07/03 01:15:39 matt Exp $ */
2 1.2 matt
3 1.2 matt /*-
4 1.2 matt * Copyright (c) 2007 Embedtronics Oy. All rights reserved.
5 1.2 matt *
6 1.2 matt * Redistribution and use in source and binary forms, with or without
7 1.2 matt * modification, are permitted provided that the following conditions
8 1.2 matt * are met:
9 1.2 matt * 1. Redistributions of source code must retain the above copyright
10 1.2 matt * notice, this list of conditions and the following disclaimer.
11 1.2 matt * 2. Redistributions in binary form must reproduce the above copyright
12 1.2 matt * notice, this list of conditions and the following disclaimer in the
13 1.2 matt * documentation and/or other materials provided with the distribution.
14 1.2 matt * 3. All advertising materials mentioning features or use of this software
15 1.2 matt * must display the following acknowledgement:
16 1.2 matt * This product includes software developed by the NetBSD
17 1.2 matt * Foundation, Inc. and its contributors.
18 1.2 matt * 4. Neither the name of The NetBSD Foundation nor the names of its
19 1.2 matt * contributors may be used to endorse or promote products derived
20 1.2 matt * from this software without specific prior written permission.
21 1.2 matt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.2 matt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.2 matt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.2 matt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.2 matt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.2 matt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.2 matt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.2 matt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.2 matt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.2 matt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.2 matt * SUCH DAMAGE.
32 1.2 matt *
33 1.2 matt */
34 1.2 matt
35 1.2 matt #ifndef _AT91USARTVAR_H_
36 1.2 matt #define _AT91USARTVAR_H_
37 1.2 matt
38 1.2 matt #include <sys/tty.h>
39 1.2 matt #include <arm/at91/at91pdcvar.h>
40 1.2 matt
41 1.2 matt /* Hardware flag masks */
42 1.2 matt #define COM_HW_NOIEN 0x01
43 1.2 matt #define COM_HW_DEV_OK 0x20
44 1.2 matt #define COM_HW_CONSOLE 0x40
45 1.2 matt #define COM_HW_KGDB 0x80
46 1.2 matt
47 1.2 matt #define RX_TTY_BLOCKED 0x01
48 1.2 matt #define RX_TTY_OVERFLOWED 0x02
49 1.2 matt #define RX_IBUF_BLOCKED 0x04
50 1.2 matt #define RX_IBUF_OVERFLOWED 0x08
51 1.2 matt #define RX_ANY_BLOCK 0x0f
52 1.2 matt
53 1.2 matt #define AT91USART_RING_SIZE MAX(PAGE_SIZE, 2048)
54 1.2 matt
55 1.2 matt struct at91usart_softc {
56 1.2 matt device_t sc_dev;
57 1.2 matt bus_addr_t sc_hwbase;
58 1.2 matt bus_space_tag_t sc_iot;
59 1.2 matt bus_space_handle_t sc_ioh;
60 1.2 matt bus_dma_tag_t sc_dmat;
61 1.2 matt int sc_pid;
62 1.2 matt
63 1.2 matt /* hardware flow control callbacks: */
64 1.2 matt void (*hwflow)(struct at91usart_softc *, int enabled);
65 1.2 matt void (*start_tx)(struct at91usart_softc *sc);
66 1.2 matt void (*stop_tx)(struct at91usart_softc *sc);
67 1.2 matt void (*rx_started)(struct at91usart_softc *sc);
68 1.2 matt void (*rx_stopped)(struct at91usart_softc *sc);
69 1.2 matt void (*rx_rts_ctl)(struct at91usart_softc *sc, int enabled);
70 1.2 matt
71 1.2 matt at91pdc_fifo_t sc_rx_fifo;
72 1.2 matt at91pdc_fifo_t sc_tx_fifo;
73 1.2 matt
74 1.2 matt u_char *sc_tba;
75 1.2 matt int sc_tbc;
76 1.2 matt
77 1.2 matt void *sc_si;
78 1.2 matt
79 1.2 matt struct tty *sc_tty;
80 1.2 matt
81 1.2 matt /* status flags */
82 1.2 matt int sc_hwflags, sc_swflags;
83 1.2 matt
84 1.2 matt volatile u_int sc_rx_flags,
85 1.2 matt sc_rx_ready;
86 1.2 matt
87 1.2 matt volatile u_int sc_csr, sc_brgr, sc_ier, sc_poll;
88 1.2 matt
89 1.2 matt /* power management hooks */
90 1.2 matt int (*enable)(struct at91usart_softc *);
91 1.2 matt int (*disable)(struct at91usart_softc *);
92 1.2 matt
93 1.2 matt int enabled;
94 1.2 matt #if NRND > 0 && defined(RND_COM)
95 1.2 matt rndsource_element_t rnd_source;
96 1.2 matt #endif
97 1.2 matt };
98 1.2 matt
99 1.2 matt struct at91bus_attach_args;
100 1.2 matt void at91usart_attach_subr(struct at91usart_softc *, struct at91bus_attach_args *);
101 1.2 matt int at91usart_cn_attach(bus_space_tag_t, bus_addr_t, bus_space_handle_t, u_int32_t mstclk, int, tcflag_t);
102 1.2 matt
103 1.2 matt #endif /* _AT91USARTVAR_H_ */
104