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