gtmpscvar.h revision 1.1 1 /* $NetBSD: gtmpscvar.h,v 1.1 2003/03/05 22:08:22 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
46 #include "opt_marvell.h"
47
48 #ifndef GT_MPSC_DEFAULT_BAUD_RATE
49 #define GT_MPSC_DEFAULT_BAUD_RATE 115200
50 #endif
51 #define GTMPSC_CLOCK_DIVIDER 8
52 #define GTMPSC_MMCR_HI_TCDV_DEFAULT GTMPSC_MMCR_HI_TCDV_8X
53 #define GTMPSC_MMCR_HI_RCDV_DEFAULT GTMPSC_MMCR_HI_RCDV_8X
54 #define BRG_DEFAULT_INPUT_RATE 100000000
55 #define BRG_BCR_CDV_MAX 0xffff
56
57 /*
58 * gtmpsc_poll_dmapage_t - used for MPSC getchar/putchar polled console
59 *
60 * sdma descriptors must be 16 byte aligned
61 * sdma RX buffer pointers must be 8 byte aligned
62 */
63 #define GTMPSC_NTXDESC 64
64 #define GTMPSC_NRXDESC 64
65 #define GTMPSC_TXBUFSZ 16
66 #define GTMPSC_RXBUFSZ 16
67
68 typedef struct gtmpsc_polltx {
69 sdma_desc_t txdesc;
70 unsigned char txbuf[GTMPSC_TXBUFSZ];
71 } gtmpsc_polltx_t;
72
73 typedef struct gtmpsc_pollrx {
74 sdma_desc_t rxdesc;
75 unsigned char rxbuf[GTMPSC_RXBUFSZ];
76 } gtmpsc_pollrx_t;
77
78 typedef struct {
79 gtmpsc_polltx_t tx[GTMPSC_NTXDESC];
80 gtmpsc_pollrx_t rx[GTMPSC_NRXDESC];
81 } gtmpsc_poll_sdma_t;
82
83 /* Size of the Rx FIFO */
84 #define GTMPSC_RXFIFOSZ (GTMPSC_NRXDESC * GTMPSC_RXBUFSZ * 2)
85
86 /* Flags in sc->gtmpsc_flags */
87 #define GTMPSCF_KGDB 1
88
89 typedef struct gtmpsc_softc {
90 struct device gtmpsc_dev;
91 bus_space_tag_t gtmpsc_memt;
92 bus_dma_tag_t gtmpsc_dmat;
93 struct gt_softc *gtmpsc_gt; /* parent GT-64260 */
94 struct tty *gtmpsc_tty; /* our tty */
95 int gtmpsc_unit;
96 unsigned int gtmpsc_flags;
97 unsigned int gtmpsc_baud_rate;
98 bus_dma_segment_t gtmpsc_dma_segs[1];
99 gtmpsc_poll_sdma_t *gtmpsc_poll_sdmapage;
100 unsigned int gtmpsc_poll_txix; /* "current" tx xfer index */
101 unsigned int gtmpsc_poll_rxix; /* "current" rx xfer index */
102 unsigned int gtmpsc_cx; /* data index in gtmpsc_rxbuf */
103 unsigned int gtmpsc_nc; /* data count in gtmpsc_rxbuf */
104 unsigned int gtmpsc_chr2; /* soft copy of CHR2 */
105 unsigned int gtmpsc_chr3; /* soft copy of CHR3 */
106 unsigned int gtmpsc_brg_bcr; /* soft copy of BRG_BCR */
107 volatile u_char sc_heldchange; /* new params wait for output */
108 volatile u_char sc_tx_busy;
109 volatile u_char sc_tx_done;
110 volatile u_char sc_tx_stopped;
111 u_char *sc_tba; /* Tx buf ptr */
112 u_int sc_tbc; /* Tx buf cnt */
113 u_int sc_heldtbc;
114 unsigned char gtmpsc_rxbuf[GTMPSC_RXBUFSZ]; /* polling read buffer */
115 volatile unsigned int gtmpsc_rxfifo_navail;
116 /* available count in fifo */
117 unsigned int gtmpsc_rxfifo_putix; /* put index in fifo */
118 unsigned int gtmpsc_rxfifo_getix; /* get index in fifo */
119 unsigned char gtmpsc_rxfifo[GTMPSC_RXFIFOSZ];
120 unsigned int cnt_rx_from_sdma;
121 unsigned int cnt_rx_to_fifo;
122 unsigned int cnt_rx_from_fifo;
123 unsigned int cnt_tx_from_ldisc;
124 unsigned int cnt_tx_to_sdma;
125 } gtmpsc_softc_t;
126
127 /* Macros to clear/set/test flags. */
128 #define SET(t, f) (t) |= (f)
129 #define CLR(t, f) (t) &= ~(f)
130 #define ISSET(t, f) ((t) & (f))
131
132 /* Make receiver interrupt 8 times a second */
133 #define GTMPSC_MAXIDLE(baudrate) ((baudrate) / (10 * 8)) /* There are 10 bits
134 in a frame */
135