cs89x0var.h revision 1.1.4.2 1 1.1.4.2 thorpej /* $NetBSD: cs89x0var.h,v 1.1.4.2 2002/01/10 19:54:22 thorpej Exp $ */
2 1.1.4.2 thorpej
3 1.1.4.2 thorpej /*
4 1.1.4.2 thorpej * Copyright 1997
5 1.1.4.2 thorpej * Digital Equipment Corporation. All rights reserved.
6 1.1.4.2 thorpej *
7 1.1.4.2 thorpej * This software is furnished under license and may be used and
8 1.1.4.2 thorpej * copied only in accordance with the following terms and conditions.
9 1.1.4.2 thorpej * Subject to these conditions, you may download, copy, install,
10 1.1.4.2 thorpej * use, modify and distribute this software in source and/or binary
11 1.1.4.2 thorpej * form. No title or ownership is transferred hereby.
12 1.1.4.2 thorpej *
13 1.1.4.2 thorpej * 1) Any source code used, modified or distributed must reproduce
14 1.1.4.2 thorpej * and retain this copyright notice and list of conditions as
15 1.1.4.2 thorpej * they appear in the source file.
16 1.1.4.2 thorpej *
17 1.1.4.2 thorpej * 2) No right is granted to use any trade name, trademark, or logo of
18 1.1.4.2 thorpej * Digital Equipment Corporation. Neither the "Digital Equipment
19 1.1.4.2 thorpej * Corporation" name nor any trademark or logo of Digital Equipment
20 1.1.4.2 thorpej * Corporation may be used to endorse or promote products derived
21 1.1.4.2 thorpej * from this software without the prior written permission of
22 1.1.4.2 thorpej * Digital Equipment Corporation.
23 1.1.4.2 thorpej *
24 1.1.4.2 thorpej * 3) This software is provided "AS-IS" and any express or implied
25 1.1.4.2 thorpej * warranties, including but not limited to, any implied warranties
26 1.1.4.2 thorpej * of merchantability, fitness for a particular purpose, or
27 1.1.4.2 thorpej * non-infringement are disclaimed. In no event shall DIGITAL be
28 1.1.4.2 thorpej * liable for any damages whatsoever, and in particular, DIGITAL
29 1.1.4.2 thorpej * shall not be liable for special, indirect, consequential, or
30 1.1.4.2 thorpej * incidental damages or damages for lost profits, loss of
31 1.1.4.2 thorpej * revenue or loss of use, whether such damages arise in contract,
32 1.1.4.2 thorpej * negligence, tort, under statute, in equity, at law or otherwise,
33 1.1.4.2 thorpej * even if advised of the possibility of such damage.
34 1.1.4.2 thorpej */
35 1.1.4.2 thorpej
36 1.1.4.2 thorpej /*
37 1.1.4.2 thorpej **++
38 1.1.4.2 thorpej ** FACILITY Crystal CS8900 Ethernet driver header file
39 1.1.4.2 thorpej **
40 1.1.4.2 thorpej ** ABSTRACT
41 1.1.4.2 thorpej **
42 1.1.4.2 thorpej ** This module provides CS8900 driver softc and related definitions
43 1.1.4.2 thorpej **
44 1.1.4.2 thorpej ** AUTHORS
45 1.1.4.2 thorpej **
46 1.1.4.2 thorpej ** Peter Dettori SEA - Software Engineering.
47 1.1.4.2 thorpej **
48 1.1.4.2 thorpej ** CREATION DATE:
49 1.1.4.2 thorpej **
50 1.1.4.2 thorpej ** 13-Feb-1997.
51 1.1.4.2 thorpej **
52 1.1.4.2 thorpej ** MODIFICATION HISTORY:
53 1.1.4.2 thorpej **
54 1.1.4.2 thorpej **--
55 1.1.4.2 thorpej */
56 1.1.4.2 thorpej
57 1.1.4.2 thorpej #ifndef _DEV_IC_CS89X0VAR_H_
58 1.1.4.2 thorpej #define _DEV_IC_CS89X0VAR_H_
59 1.1.4.2 thorpej
60 1.1.4.2 thorpej /*
61 1.1.4.2 thorpej * Ethernet software status per interface.
62 1.1.4.2 thorpej *
63 1.1.4.2 thorpej * Each interface is referenced by a network interface structure,
64 1.1.4.2 thorpej * arpcom.ac_if, which the routing code uses to locate the interface.
65 1.1.4.2 thorpej * This structure contains the output queue for the interface,
66 1.1.4.2 thorpej * its address, ...
67 1.1.4.2 thorpej */
68 1.1.4.2 thorpej struct cs_softc {
69 1.1.4.2 thorpej struct device sc_dev; /* base device glue */
70 1.1.4.2 thorpej struct ethercom sc_ethercom; /* Ethernet common */
71 1.1.4.2 thorpej struct ifmedia sc_media; /* media control structures */
72 1.1.4.2 thorpej
73 1.1.4.2 thorpej void *sc_ih; /* interupt handler */
74 1.1.4.2 thorpej void *sc_sh; /* shutdown hook */
75 1.1.4.2 thorpej
76 1.1.4.2 thorpej bus_space_tag_t sc_iot; /* bus space tag for IO */
77 1.1.4.2 thorpej bus_space_tag_t sc_memt; /* bus space tag for memory mode */
78 1.1.4.2 thorpej bus_space_handle_t sc_ioh; /* bus space handles */
79 1.1.4.2 thorpej bus_space_handle_t sc_memh;
80 1.1.4.2 thorpej
81 1.1.4.2 thorpej #if 0
82 1.1.4.2 thorpej isa_chipset_tag_t sc_ic; /* ISA chipset */
83 1.1.4.2 thorpej #endif
84 1.1.4.2 thorpej
85 1.1.4.2 thorpej int sc_irq; /* IRQ line */
86 1.1.4.2 thorpej
87 1.1.4.2 thorpej int sc_prodid; /* saved product ID */
88 1.1.4.2 thorpej int sc_prodrev; /* saved product rev */
89 1.1.4.2 thorpej
90 1.1.4.2 thorpej bus_addr_t sc_pktpgaddr; /* PacketPage bus memory address */
91 1.1.4.2 thorpej
92 1.1.4.2 thorpej int sc_cfgflags; /* software configuration flags */
93 1.1.4.2 thorpej
94 1.1.4.2 thorpej int sc_memorymode; /* are we in memory mode? */
95 1.1.4.2 thorpej int sc_txbusy; /* transmit in progress */
96 1.1.4.2 thorpej int sc_resetting; /* reset in progress */
97 1.1.4.2 thorpej
98 1.1.4.2 thorpej int sc_xe_ent; /* current early-xmit table entry */
99 1.1.4.2 thorpej int sc_xe_togo; /* # of packets to go at this ent */
100 1.1.4.2 thorpej
101 1.1.4.2 thorpej int sc_carrier; /* has carrier */
102 1.1.4.2 thorpej
103 1.1.4.2 thorpej u_int8_t sc_enaddr[ETHER_ADDR_LEN]; /* MAC address */
104 1.1.4.2 thorpej
105 1.1.4.2 thorpej #if NRND > 0
106 1.1.4.2 thorpej rndsource_element_t rnd_source; /* random source */
107 1.1.4.2 thorpej #endif
108 1.1.4.2 thorpej
109 1.1.4.2 thorpej /* power management */
110 1.1.4.2 thorpej int (*sc_enable) __P((struct cs_softc *));
111 1.1.4.2 thorpej void (*sc_disable) __P((struct cs_softc *));
112 1.1.4.2 thorpej void *sc_powerhook;
113 1.1.4.2 thorpej
114 1.1.4.2 thorpej /* dma hooks */
115 1.1.4.2 thorpej void (*sc_dma_process_rx) __P((struct cs_softc *));
116 1.1.4.2 thorpej void (*sc_dma_chipinit) __P((struct cs_softc *));
117 1.1.4.2 thorpej void (*sc_dma_attach) __P((struct cs_softc *));
118 1.1.4.2 thorpej };
119 1.1.4.2 thorpej
120 1.1.4.2 thorpej
121 1.1.4.2 thorpej /* Config Flags in cs_softc */
122 1.1.4.2 thorpej
123 1.1.4.2 thorpej #define CFGFLG_MEM_MODE 0x0001
124 1.1.4.2 thorpej #define CFGFLG_USE_SA 0x0002
125 1.1.4.2 thorpej #define CFGFLG_IOCHRDY 0x0004
126 1.1.4.2 thorpej #define CFGFLG_DCDC_POL 0x0008
127 1.1.4.2 thorpej #define CFGFLG_DMA_MODE 0x0020
128 1.1.4.2 thorpej #define CFGFLG_ATTACHED 0x0040 /* XXX should not be here? */
129 1.1.4.2 thorpej #define CFGFLG_CARDBUS_HACK 0x0080
130 1.1.4.2 thorpej #define CFGFLG_ENABLED 0x0100 /* XXX should not be here? */
131 1.1.4.2 thorpej #define CFGFLG_NOT_EEPROM 0x8000
132 1.1.4.2 thorpej
133 1.1.4.2 thorpej
134 1.1.4.2 thorpej /*
135 1.1.4.2 thorpej * Inlines for reading/writing the packet page area.
136 1.1.4.2 thorpej */
137 1.1.4.2 thorpej
138 1.1.4.2 thorpej static __inline__ u_int16_t _cs_read_port(struct cs_softc *, int);
139 1.1.4.2 thorpej
140 1.1.4.2 thorpej static __inline__ u_int16_t
141 1.1.4.2 thorpej _cs_read_port(struct cs_softc *sc, int off)
142 1.1.4.2 thorpej {
143 1.1.4.2 thorpej u_int16_t result;
144 1.1.4.2 thorpej
145 1.1.4.2 thorpej if (sc->sc_cfgflags & CFGFLG_CARDBUS_HACK) {
146 1.1.4.2 thorpej /*
147 1.1.4.2 thorpej * hack for EtherJet PCMCIA and cardbus (obtained from freebsd)
148 1.1.4.2 thorpej *
149 1.1.4.2 thorpej * EtherJet PCMCIA don't work with cardbus bridges
150 1.1.4.2 thorpej * (at least TI1250) without this hack.
151 1.1.4.2 thorpej */
152 1.1.4.2 thorpej result = (bus_space_read_1(sc->sc_iot, sc->sc_ioh, off) & 0xff);
153 1.1.4.2 thorpej result |= ((bus_space_read_1(sc->sc_iot, sc->sc_ioh, off+1) & 0xff) << 8);
154 1.1.4.2 thorpej }
155 1.1.4.2 thorpej else {
156 1.1.4.2 thorpej result = bus_space_read_2(sc->sc_iot, sc->sc_ioh, off);
157 1.1.4.2 thorpej }
158 1.1.4.2 thorpej
159 1.1.4.2 thorpej return result;
160 1.1.4.2 thorpej }
161 1.1.4.2 thorpej
162 1.1.4.2 thorpej static __inline__ u_int16_t _CS_READ_PACKET_PAGE_IO(struct cs_softc *, int);
163 1.1.4.2 thorpej
164 1.1.4.2 thorpej static __inline__ u_int16_t
165 1.1.4.2 thorpej _CS_READ_PACKET_PAGE_IO(struct cs_softc *sc, int offset)
166 1.1.4.2 thorpej {
167 1.1.4.2 thorpej
168 1.1.4.2 thorpej bus_space_write_2(sc->sc_iot, sc->sc_ioh, PORT_PKTPG_PTR, offset);
169 1.1.4.2 thorpej return (_cs_read_port(sc, PORT_PKTPG_DATA));
170 1.1.4.2 thorpej }
171 1.1.4.2 thorpej
172 1.1.4.2 thorpej static __inline__ u_int16_t CS_READ_PACKET_PAGE_IO __P((bus_space_tag_t,
173 1.1.4.2 thorpej bus_space_handle_t, int));
174 1.1.4.2 thorpej
175 1.1.4.2 thorpej static __inline__ u_int16_t
176 1.1.4.2 thorpej CS_READ_PACKET_PAGE_IO(iot, ioh, offset)
177 1.1.4.2 thorpej bus_space_tag_t iot;
178 1.1.4.2 thorpej bus_space_handle_t ioh;
179 1.1.4.2 thorpej int offset;
180 1.1.4.2 thorpej {
181 1.1.4.2 thorpej
182 1.1.4.2 thorpej bus_space_write_2(iot, ioh, PORT_PKTPG_PTR, offset);
183 1.1.4.2 thorpej return (bus_space_read_2(iot, ioh, PORT_PKTPG_DATA));
184 1.1.4.2 thorpej }
185 1.1.4.2 thorpej
186 1.1.4.2 thorpej #define CS_READ_PACKET_PAGE_MEM(memt, memh, offset) \
187 1.1.4.2 thorpej bus_space_read_2((memt), (memh), (offset))
188 1.1.4.2 thorpej
189 1.1.4.2 thorpej #define CS_READ_PACKET_PAGE(sc, offset) \
190 1.1.4.2 thorpej ((sc)->sc_memorymode ? CS_READ_PACKET_PAGE_MEM((sc)->sc_memt, \
191 1.1.4.2 thorpej (sc)->sc_memh, (offset)) : \
192 1.1.4.2 thorpej _CS_READ_PACKET_PAGE_IO((sc), (offset)))
193 1.1.4.2 thorpej
194 1.1.4.2 thorpej #define CS_WRITE_PACKET_PAGE_IO(iot, ioh, offset, val) \
195 1.1.4.2 thorpej do { \
196 1.1.4.2 thorpej bus_space_write_2((iot), (ioh), PORT_PKTPG_PTR, (offset)); \
197 1.1.4.2 thorpej bus_space_write_2((iot), (ioh), PORT_PKTPG_DATA, (val)); \
198 1.1.4.2 thorpej } while (0)
199 1.1.4.2 thorpej
200 1.1.4.2 thorpej #define CS_WRITE_PACKET_PAGE_MEM(memt, memh, offset, val) \
201 1.1.4.2 thorpej bus_space_write_2((memt), (memh), (offset), (val))
202 1.1.4.2 thorpej
203 1.1.4.2 thorpej #define CS_WRITE_PACKET_PAGE(sc, offset, val) \
204 1.1.4.2 thorpej do { \
205 1.1.4.2 thorpej if ((sc)->sc_memorymode) \
206 1.1.4.2 thorpej CS_WRITE_PACKET_PAGE_MEM((sc)->sc_memt, (sc)->sc_memh, \
207 1.1.4.2 thorpej (offset), (val)); \
208 1.1.4.2 thorpej else \
209 1.1.4.2 thorpej CS_WRITE_PACKET_PAGE_IO((sc)->sc_iot, (sc)->sc_ioh, \
210 1.1.4.2 thorpej (offset), (val)); \
211 1.1.4.2 thorpej } while (0)
212 1.1.4.2 thorpej
213 1.1.4.2 thorpej #define CS_READ_PORT(sc, off)\
214 1.1.4.2 thorpej bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, (off))
215 1.1.4.2 thorpej
216 1.1.4.2 thorpej #define CS_WRITE_PORT(sc, off, val)\
217 1.1.4.2 thorpej bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, (off), (val))
218 1.1.4.2 thorpej
219 1.1.4.2 thorpej
220 1.1.4.2 thorpej /* Return Status */
221 1.1.4.2 thorpej #define CS_ERROR -1
222 1.1.4.2 thorpej #define CS_OK 1
223 1.1.4.2 thorpej
224 1.1.4.2 thorpej
225 1.1.4.2 thorpej /* Media Type in cs_softc */
226 1.1.4.2 thorpej
227 1.1.4.2 thorpej #define MEDIA_AUI 0x0001
228 1.1.4.2 thorpej #define MEDIA_10BASE2 0x0002
229 1.1.4.2 thorpej #define MEDIA_10BASET 0x0003
230 1.1.4.2 thorpej
231 1.1.4.2 thorpej
232 1.1.4.2 thorpej /* Miscellaneous definitions */
233 1.1.4.2 thorpej
234 1.1.4.2 thorpej #define MAXLOOP 0x8888
235 1.1.4.2 thorpej
236 1.1.4.2 thorpej int cs_attach __P((struct cs_softc *sc, u_int8_t *enaddr,
237 1.1.4.2 thorpej int *media, int nmedia, int defmedia));
238 1.1.4.2 thorpej int cs_detach __P((struct cs_softc *sc));
239 1.1.4.2 thorpej int cs_verify_eeprom __P((bus_space_tag_t, bus_space_handle_t));
240 1.1.4.2 thorpej int cs_read_eeprom __P((bus_space_tag_t, bus_space_handle_t, int,
241 1.1.4.2 thorpej u_int16_t *));
242 1.1.4.2 thorpej int cs_intr __P((void *));
243 1.1.4.2 thorpej int cs_activate __P((struct device *, enum devact));
244 1.1.4.2 thorpej void cs_ether_input __P((struct cs_softc *, struct mbuf *));
245 1.1.4.2 thorpej void cs_print_rx_errors __P((struct cs_softc *, u_int16_t));
246 1.1.4.2 thorpej int cs_init __P((struct ifnet *));
247 1.1.4.2 thorpej
248 1.1.4.2 thorpej #define CS_IS_ENABLED(sc) ((sc)->sc_cfgflags & CFGFLG_ENABLED)
249 1.1.4.2 thorpej
250 1.1.4.2 thorpej #endif /* _DEV_IC_CS89X0VAR_H_ */
251