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