hd64570var.h revision 1.11 1 1.11 chs /* $NetBSD: hd64570var.h,v 1.11 2012/10/27 17:18:20 chs Exp $ */
2 1.1 explorer
3 1.1 explorer /*
4 1.3 chopps * Copyright (c) 1999 Christian E. Hopps
5 1.1 explorer * Copyright (c) 1998 Vixie Enterprises
6 1.1 explorer * All rights reserved.
7 1.1 explorer *
8 1.1 explorer * Redistribution and use in source and binary forms, with or without
9 1.1 explorer * modification, are permitted provided that the following conditions
10 1.1 explorer * are met:
11 1.1 explorer *
12 1.1 explorer * 1. Redistributions of source code must retain the above copyright
13 1.1 explorer * notice, this list of conditions and the following disclaimer.
14 1.1 explorer * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 explorer * notice, this list of conditions and the following disclaimer in the
16 1.1 explorer * documentation and/or other materials provided with the distribution.
17 1.1 explorer * 3. Neither the name of Vixie Enterprises nor the names
18 1.1 explorer * of its contributors may be used to endorse or promote products derived
19 1.1 explorer * from this software without specific prior written permission.
20 1.1 explorer *
21 1.1 explorer * THIS SOFTWARE IS PROVIDED BY VIXIE ENTERPRISES AND
22 1.1 explorer * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 1.1 explorer * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 1.1 explorer * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 1.1 explorer * DISCLAIMED. IN NO EVENT SHALL VIXIE ENTERPRISES OR
26 1.1 explorer * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 1.1 explorer * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 1.1 explorer * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
29 1.1 explorer * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 1.1 explorer * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 1.1 explorer * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 1.1 explorer * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 explorer * SUCH DAMAGE.
34 1.1 explorer *
35 1.1 explorer * This software has been written for Vixie Enterprises by Michael Graff
36 1.1 explorer * <explorer (at) flame.org>. To learn more about Vixie Enterprises, see
37 1.1 explorer * ``http://www.vix.com''.
38 1.1 explorer */
39 1.1 explorer
40 1.2 kleink #ifndef _DEV_IC_HD64570VAR_H_
41 1.2 kleink #define _DEV_IC_HD64570VAR_H_
42 1.1 explorer
43 1.1 explorer #define SCA_USE_FASTQ /* use a split queue, one for fast traffic */
44 1.1 explorer
45 1.3 chopps #define SCA_MTU 1500 /* hard coded */
46 1.3 chopps
47 1.3 chopps #ifndef SCA_BSIZE
48 1.3 chopps #define SCA_BSIZE (SCA_MTU + 4) /* room for HDLC as well */
49 1.3 chopps #endif
50 1.3 chopps
51 1.3 chopps
52 1.1 explorer struct sca_softc;
53 1.1 explorer typedef struct sca_port sca_port_t;
54 1.1 explorer typedef struct sca_desc sca_desc_t;
55 1.1 explorer
56 1.1 explorer /*
57 1.1 explorer * device DMA descriptor
58 1.1 explorer */
59 1.1 explorer struct sca_desc {
60 1.3 chopps u_int16_t sd_chainp; /* chain pointer */
61 1.3 chopps u_int16_t sd_bufp; /* buffer pointer (low bits) */
62 1.3 chopps u_int8_t sd_hbufp; /* buffer pointer (high bits) */
63 1.3 chopps u_int8_t sd_unused0;
64 1.3 chopps u_int16_t sd_buflen; /* total length */
65 1.3 chopps u_int8_t sd_stat; /* status */
66 1.3 chopps u_int8_t sd_unused1;
67 1.1 explorer };
68 1.1 explorer #define SCA_DESC_EOT 0x01
69 1.1 explorer #define SCA_DESC_CRC 0x04
70 1.1 explorer #define SCA_DESC_OVRN 0x08
71 1.1 explorer #define SCA_DESC_RESD 0x10
72 1.1 explorer #define SCA_DESC_ABORT 0x20
73 1.1 explorer #define SCA_DESC_SHRTFRM 0x40
74 1.1 explorer #define SCA_DESC_EOM 0x80
75 1.1 explorer #define SCA_DESC_ERRORS 0x7C
76 1.1 explorer
77 1.1 explorer /*
78 1.1 explorer * softc structure for each port
79 1.1 explorer */
80 1.1 explorer struct sca_port {
81 1.1 explorer u_int msci_off; /* offset for msci address for this port */
82 1.1 explorer u_int dmac_off; /* offset of dmac address for this port */
83 1.1 explorer
84 1.1 explorer u_int sp_port;
85 1.1 explorer
86 1.1 explorer /*
87 1.1 explorer * CISCO keepalive stuff
88 1.1 explorer */
89 1.1 explorer u_int32_t cka_lasttx;
90 1.1 explorer u_int32_t cka_lastrx;
91 1.1 explorer
92 1.1 explorer /*
93 1.3 chopps * clock values, clockrate = sysclock / tmc / 2^div;
94 1.3 chopps */
95 1.3 chopps u_int8_t sp_eclock; /* enable external clock generate */
96 1.3 chopps u_int8_t sp_rxs; /* recv clock source */
97 1.3 chopps u_int8_t sp_txs; /* transmit clock source */
98 1.3 chopps u_int8_t sp_tmc; /* clock constant */
99 1.3 chopps
100 1.3 chopps /*
101 1.1 explorer * start of each important bit of information for transmit and
102 1.1 explorer * receive buffers.
103 1.3 chopps *
104 1.5 wiz * note: for non-DMA the phys and virtual version should be
105 1.3 chopps * the same value and should be an _offset_ from the beginning
106 1.3 chopps * of mapped memory described by sc_memt/sc_memh.
107 1.1 explorer */
108 1.3 chopps u_int sp_ntxdesc; /* number of tx descriptors */
109 1.10 jakllsch bus_addr_t sp_txdesc_p; /* paddress of first tx desc */
110 1.3 chopps sca_desc_t *sp_txdesc; /* vaddress of first tx desc */
111 1.10 jakllsch bus_addr_t sp_txbuf_p; /* paddress of first tx buffer */
112 1.3 chopps u_int8_t *sp_txbuf; /* vaddress of first tx buffer */
113 1.3 chopps
114 1.3 chopps volatile u_int sp_txcur; /* last descriptor in chain */
115 1.3 chopps volatile u_int sp_txinuse; /* descriptors in use */
116 1.3 chopps volatile u_int sp_txstart; /* start descriptor */
117 1.3 chopps
118 1.3 chopps u_int sp_nrxdesc; /* number of rx descriptors */
119 1.10 jakllsch bus_addr_t sp_rxdesc_p; /* paddress of first rx desc */
120 1.3 chopps sca_desc_t *sp_rxdesc; /* vaddress of first rx desc */
121 1.10 jakllsch bus_addr_t sp_rxbuf_p; /* paddress of first rx buffer */
122 1.3 chopps u_int8_t *sp_rxbuf; /* vaddress of first rx buffer */
123 1.3 chopps
124 1.3 chopps u_int sp_rxstart; /* index of first descriptor */
125 1.3 chopps u_int sp_rxend; /* index of last descriptor */
126 1.1 explorer
127 1.1 explorer struct ifnet sp_if; /* the network information */
128 1.1 explorer struct ifqueue linkq; /* link-level packets are high prio */
129 1.1 explorer #ifdef SCA_USE_FASTQ
130 1.1 explorer struct ifqueue fastq; /* interactive packets */
131 1.1 explorer #endif
132 1.1 explorer
133 1.1 explorer struct sca_softc *sca; /* pointer to parent */
134 1.1 explorer };
135 1.1 explorer
136 1.1 explorer /*
137 1.1 explorer * softc structure for the chip itself
138 1.1 explorer */
139 1.1 explorer struct sca_softc {
140 1.11 chs device_t sc_parent; /* our parent device, or NULL */
141 1.3 chopps int sc_numports; /* number of ports present */
142 1.3 chopps u_int32_t sc_baseclock; /* the base operating clock */
143 1.1 explorer
144 1.1 explorer /*
145 1.1 explorer * a callback into the parent, since the SCA chip has no control
146 1.1 explorer * over DTR, we have to make a callback into the parent, which
147 1.1 explorer * might know about DTR.
148 1.1 explorer *
149 1.1 explorer * If the function pointer is NULL, no callback is specified.
150 1.1 explorer */
151 1.3 chopps void *sc_aux;
152 1.6 itojun void (*sc_dtr_callback)(void *, int, int);
153 1.6 itojun void (*sc_clock_callback)(void *, int, int);
154 1.3 chopps
155 1.3 chopps /* used to read and write the device registers */
156 1.3 chopps u_int8_t (*sc_read_1)(struct sca_softc *, u_int);
157 1.3 chopps u_int16_t (*sc_read_2)(struct sca_softc *, u_int);
158 1.3 chopps void (*sc_write_1)(struct sca_softc *, u_int, u_int8_t);
159 1.3 chopps void (*sc_write_2)(struct sca_softc *, u_int, u_int16_t);
160 1.3 chopps
161 1.3 chopps sca_port_t sc_ports[2];
162 1.3 chopps
163 1.3 chopps bus_space_tag_t sc_iot; /* io space for registers */
164 1.3 chopps bus_space_handle_t sc_ioh; /* io space for registers */
165 1.3 chopps
166 1.3 chopps int sc_usedma;
167 1.3 chopps union {
168 1.3 chopps struct {
169 1.5 wiz bus_space_tag_t p_memt; /* mem for non-DMA */
170 1.5 wiz bus_space_handle_t p_memh; /* mem for non-DMA */
171 1.3 chopps bus_space_handle_t p_sca_ioh[16]; /* io for sca regs */
172 1.3 chopps bus_size_t p_pagesize; /* memory page size */
173 1.3 chopps bus_size_t p_pagemask; /* memory page mask */
174 1.3 chopps u_int p_pageshift; /* memory page shift */
175 1.3 chopps bus_size_t p_npages; /* num mem pages */
176 1.3 chopps
177 1.3 chopps void (*p_set_page)(struct sca_softc *, bus_addr_t);
178 1.3 chopps void (*p_page_on)(struct sca_softc *);
179 1.3 chopps void (*p_page_off)(struct sca_softc *);
180 1.3 chopps } u_paged;
181 1.3 chopps struct {
182 1.5 wiz bus_dma_tag_t d_dmat; /* bus DMA tag */
183 1.5 wiz bus_dmamap_t d_dmam; /* bus DMA map */
184 1.5 wiz bus_dma_segment_t d_seg; /* bus DMA segment */
185 1.8 christos void * d_dma_addr; /* kva of segment */
186 1.3 chopps bus_size_t d_allocsize; /* size of region */
187 1.3 chopps } u_dma;
188 1.3 chopps } sc_u;
189 1.1 explorer };
190 1.3 chopps #define scu_memt sc_u.u_paged.p_memt
191 1.3 chopps #define scu_memh sc_u.u_paged.p_memh
192 1.3 chopps #define scu_sca_ioh sc_u.u_paged.p_sca_ioh
193 1.3 chopps #define scu_pagesize sc_u.u_paged.p_pagesize
194 1.3 chopps #define scu_pagemask sc_u.u_paged.p_pagemask
195 1.3 chopps #define scu_pageshift sc_u.u_paged.p_pageshift
196 1.3 chopps #define scu_npages sc_u.u_paged.p_npages
197 1.3 chopps #define scu_set_page sc_u.u_paged.p_set_page
198 1.3 chopps #define scu_page_on sc_u.u_paged.p_page_on
199 1.3 chopps #define scu_page_off sc_u.u_paged.p_page_off
200 1.3 chopps #define scu_dmat sc_u.u_dma.d_dmat
201 1.3 chopps #define scu_dmam sc_u.u_dma.d_dmam
202 1.3 chopps #define scu_seg sc_u.u_dma.d_seg
203 1.3 chopps #define scu_dma_addr sc_u.u_dma.d_dma_addr
204 1.3 chopps #define scu_allocsize sc_u.u_dma.d_allocsize
205 1.1 explorer
206 1.3 chopps void sca_init(struct sca_softc *);
207 1.1 explorer void sca_port_attach(struct sca_softc *, u_int);
208 1.1 explorer int sca_hardintr(struct sca_softc *);
209 1.1 explorer void sca_shutdown(struct sca_softc *);
210 1.3 chopps void sca_get_base_clock(struct sca_softc *);
211 1.3 chopps void sca_print_clock_info(struct sca_softc *);
212 1.1 explorer
213 1.2 kleink #endif /* _DEV_IC_HD64570VAR_H_ */
214