1 /* $NetBSD: gtmpscvar.h,v 1.4 2003/03/24 17:02:15 matt Exp $ */ 2 3 /* 4 * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed for the NetBSD Project by 18 * Allegro Networks, Inc., and Wasabi Systems, Inc. 19 * 4. The name of Allegro Networks, Inc. may not be used to endorse 20 * or promote products derived from this software without specific prior 21 * written permission. 22 * 5. The name of Wasabi Systems, Inc. may not be used to endorse 23 * or promote products derived from this software without specific prior 24 * written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY ALLEGRO NETWORKS, INC. AND 27 * WASABI SYSTEMS, INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 28 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 29 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 30 * IN NO EVENT SHALL EITHER ALLEGRO NETWORKS, INC. OR WASABI SYSTEMS, INC. 31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * POSSIBILITY OF SUCH DAMAGE. 38 */ 39 40 /* 41 * gtmpscvar.h - includes for gtmpsctty GT-64260 UART-mode serial driver 42 * 43 * creation Mon Apr 9 19:54:33 PDT 2001 cliff 44 */ 45 #ifndef _DEV_MARVELL_GTMPSCVAR_H 46 #define _DEV_MARVELL_GTMPSCVAR_H 47 48 #include "opt_marvell.h" 49 50 #ifndef GT_MPSC_DEFAULT_BAUD_RATE 51 #define GT_MPSC_DEFAULT_BAUD_RATE 115200 52 #endif 53 #define GTMPSC_CLOCK_DIVIDER 8 54 #define GTMPSC_MMCR_HI_TCDV_DEFAULT GTMPSC_MMCR_HI_TCDV_8X 55 #define GTMPSC_MMCR_HI_RCDV_DEFAULT GTMPSC_MMCR_HI_RCDV_8X 56 #define BRG_BCR_CDV_MAX 0xffff 57 58 /* 59 * gtmpsc_poll_dmapage_t - used for MPSC getchar/putchar polled console 60 * 61 * sdma descriptors must be 16 byte aligned 62 * sdma RX buffer pointers must be 8 byte aligned 63 */ 64 #define GTMPSC_NTXDESC 64 65 #define GTMPSC_NRXDESC 64 66 #define GTMPSC_TXBUFSZ 16 67 #define GTMPSC_RXBUFSZ 16 68 69 typedef struct gtmpsc_polltx { 70 sdma_desc_t txdesc; 71 unsigned char txbuf[GTMPSC_TXBUFSZ]; 72 } gtmpsc_polltx_t; 73 74 typedef struct gtmpsc_pollrx { 75 sdma_desc_t rxdesc; 76 unsigned char rxbuf[GTMPSC_RXBUFSZ]; 77 } gtmpsc_pollrx_t; 78 79 typedef struct { 80 gtmpsc_polltx_t tx[GTMPSC_NTXDESC]; 81 gtmpsc_pollrx_t rx[GTMPSC_NRXDESC]; 82 } gtmpsc_poll_sdma_t; 83 84 /* Size of the Rx FIFO */ 85 #define GTMPSC_RXFIFOSZ (GTMPSC_NRXDESC * GTMPSC_RXBUFSZ * 2) 86 87 /* Flags in sc->gtmpsc_flags */ 88 #define GTMPSCF_KGDB 1 89 90 typedef struct gtmpsc_softc { 91 struct device gtmpsc_dev; 92 bus_space_tag_t gtmpsc_memt; 93 bus_space_handle_t gtmpsc_memh; 94 bus_dma_tag_t gtmpsc_dmat; 95 void *sc_si; /* softintr cookie */ 96 struct tty *gtmpsc_tty; /* our tty */ 97 int gtmpsc_unit; 98 unsigned int gtmpsc_flags; 99 unsigned int gtmpsc_baud_rate; 100 bus_dma_segment_t gtmpsc_dma_segs[1]; 101 bus_dmamap_t gtmpsc_dma_map; 102 gtmpsc_poll_sdma_t *gtmpsc_poll_sdmapage; 103 unsigned int gtmpsc_poll_txix; /* "current" tx xfer index */ 104 unsigned int gtmpsc_poll_rxix; /* "current" rx xfer index */ 105 unsigned int gtmpsc_cx; /* data index in gtmpsc_rxbuf */ 106 unsigned int gtmpsc_nc; /* data count in gtmpsc_rxbuf */ 107 unsigned int gtmpsc_chr2; /* soft copy of CHR2 */ 108 unsigned int gtmpsc_chr3; /* soft copy of CHR3 */ 109 unsigned int gtmpsc_brg_bcr; /* soft copy of BRG_BCR */ 110 volatile u_char sc_heldchange; /* new params wait for output */ 111 volatile u_char sc_tx_busy; 112 volatile u_char sc_tx_done; 113 volatile u_char sc_tx_stopped; 114 u_char *sc_tba; /* Tx buf ptr */ 115 u_int sc_tbc; /* Tx buf cnt */ 116 u_int sc_heldtbc; 117 unsigned char gtmpsc_rxbuf[GTMPSC_RXBUFSZ]; /* polling read buffer */ 118 volatile unsigned int gtmpsc_rxfifo_navail; 119 /* available count in fifo */ 120 unsigned int gtmpsc_rxfifo_putix; /* put index in fifo */ 121 unsigned int gtmpsc_rxfifo_getix; /* get index in fifo */ 122 unsigned char gtmpsc_rxfifo[GTMPSC_RXFIFOSZ]; 123 unsigned int cnt_rx_from_sdma; 124 unsigned int cnt_rx_to_fifo; 125 unsigned int cnt_rx_from_fifo; 126 unsigned int cnt_tx_from_ldisc; 127 unsigned int cnt_tx_to_sdma; 128 } gtmpsc_softc_t; 129 130 /* Macros to clear/set/test flags. */ 131 #define SET(t, f) (t) |= (f) 132 #define CLR(t, f) (t) &= ~(f) 133 #define ISSET(t, f) ((t) & (f)) 134 135 /* Make receiver interrupt 8 times a second */ 136 #define GTMPSC_MAXIDLE(baudrate) ((baudrate) / (10 * 8)) /* There are 10 bits 137 in a frame */ 138 139 int gtmpsccnattach(bus_space_tag_t, bus_space_handle_t, int, int, tcflag_t); 140 int gtmpsc_is_console(bus_space_tag_t, int); 141 142 #endif /* _DEV_MARVELL_GTPSCVAR_H */ 143