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