1 /* $NetBSD: at91usartvar.h,v 1.7 2015/04/14 20:32:35 riastradh 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 #ifdef RND_COM 35 #include <sys/rndsource.h> 36 #endif 37 38 /* Hardware flag masks */ 39 #define COM_HW_NOIEN 0x01 40 #define COM_HW_DEV_OK 0x20 41 #define COM_HW_CONSOLE 0x40 42 #define COM_HW_KGDB 0x80 43 44 #define RX_TTY_BLOCKED 0x01 45 #define RX_TTY_OVERFLOWED 0x02 46 #define RX_IBUF_BLOCKED 0x04 47 #define RX_IBUF_OVERFLOWED 0x08 48 #define RX_ANY_BLOCK 0x0f 49 50 #define AT91USART_RING_SIZE MAX(PAGE_SIZE, 2048) 51 52 struct at91usart_softc { 53 device_t sc_dev; 54 bus_addr_t sc_hwbase; 55 bus_space_tag_t sc_iot; 56 bus_space_handle_t sc_ioh; 57 bus_dma_tag_t sc_dmat; 58 int sc_pid; 59 60 /* hardware flow control callbacks: */ 61 void (*hwflow)(struct at91usart_softc *, int enabled); 62 void (*start_tx)(struct at91usart_softc *sc); 63 void (*stop_tx)(struct at91usart_softc *sc); 64 void (*rx_started)(struct at91usart_softc *sc); 65 void (*rx_stopped)(struct at91usart_softc *sc); 66 void (*rx_rts_ctl)(struct at91usart_softc *sc, int enabled); 67 68 at91pdc_fifo_t sc_rx_fifo; 69 at91pdc_fifo_t sc_tx_fifo; 70 71 u_char *sc_tba; 72 int sc_tbc; 73 74 void *sc_si; 75 76 struct tty *sc_tty; 77 78 /* status flags */ 79 int sc_hwflags, sc_swflags; 80 81 volatile u_int sc_rx_flags, 82 sc_rx_ready; 83 84 volatile u_int sc_csr, sc_brgr, sc_ier, sc_poll; 85 86 /* power management hooks */ 87 int (*enable)(struct at91usart_softc *); 88 int (*disable)(struct at91usart_softc *); 89 90 int enabled; 91 #ifdef RND_COM 92 krndsource_t rnd_source; 93 #endif 94 }; 95 96 struct at91bus_attach_args; 97 void at91usart_attach_subr(struct at91usart_softc *, struct at91bus_attach_args *); 98 int at91usart_cn_attach(bus_space_tag_t, bus_addr_t, bus_space_handle_t, uint32_t mstclk, int, tcflag_t); 99 100 #endif /* _AT91USARTVAR_H_ */ 101