dp8390var.h revision 1.37 1 1.37 andvar /* $NetBSD: dp8390var.h,v 1.37 2024/02/02 22:23:53 andvar Exp $ */
2 1.1 scottr
3 1.1 scottr /*
4 1.1 scottr * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
5 1.1 scottr * adapters.
6 1.1 scottr *
7 1.1 scottr * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
8 1.1 scottr *
9 1.1 scottr * Copyright (C) 1993, David Greenman. This software may be used, modified,
10 1.1 scottr * copied, distributed, and sold, in both source and binary form provided that
11 1.1 scottr * the above copyright and these terms are retained. Under no circumstances is
12 1.1 scottr * the author responsible for the proper functioning of this software, nor does
13 1.1 scottr * the author assume any responsibility for damages incurred with its use.
14 1.1 scottr */
15 1.1 scottr
16 1.33 riastrad #include <sys/rndsource.h>
17 1.11 thorpej
18 1.21 thorpej /*
19 1.21 thorpej * We include MII glue here -- some DP8390 compatible chips have
20 1.21 thorpej * MII interfaces on them (scary, isn't it...).
21 1.21 thorpej */
22 1.35 thorpej #include <sys/callout.h>
23 1.21 thorpej #include <dev/mii/miivar.h>
24 1.21 thorpej
25 1.1 scottr #define INTERFACE_NAME_LEN 32
26 1.1 scottr
27 1.1 scottr /*
28 1.1 scottr * dp8390_softc: per line info and status
29 1.1 scottr */
30 1.1 scottr struct dp8390_softc {
31 1.29 cube device_t sc_dev;
32 1.1 scottr void *sc_ih;
33 1.6 thorpej int sc_flags; /* interface flags, from config */
34 1.1 scottr
35 1.6 thorpej struct ethercom sc_ec; /* ethernet common */
36 1.21 thorpej struct mii_data sc_mii; /* MII glue */
37 1.36 andvar #define sc_media sc_mii.mii_media /* compatibility definition */
38 1.35 thorpej callout_t sc_tick_ch; /* MII tick callout */
39 1.1 scottr
40 1.1 scottr bus_space_tag_t sc_regt; /* NIC register space tag */
41 1.1 scottr bus_space_handle_t sc_regh; /* NIC register space handle */
42 1.1 scottr bus_space_tag_t sc_buft; /* Buffer space tag */
43 1.1 scottr bus_space_handle_t sc_bufh; /* Buffer space handle */
44 1.1 scottr
45 1.1 scottr bus_size_t sc_reg_map[16]; /* register map (offsets) */
46 1.1 scottr
47 1.7 thorpej int is790; /* NIC is a 790 */
48 1.1 scottr
49 1.1 scottr u_int8_t cr_proto; /* values always set in CR */
50 1.16 enami u_int8_t rcr_proto; /* values always set in RCR */
51 1.2 scottr u_int8_t dcr_reg; /* override DCR iff LS is set */
52 1.1 scottr
53 1.1 scottr int mem_start; /* offset of NIC memory */
54 1.1 scottr int mem_end; /* offset of NIC memory end */
55 1.1 scottr int mem_size; /* total shared memory size */
56 1.1 scottr int mem_ring; /* offset of start of RX ring-buffer */
57 1.1 scottr
58 1.1 scottr u_short txb_cnt; /* Number of transmit buffers */
59 1.1 scottr u_short txb_inuse; /* number of transmit buffers active */
60 1.1 scottr
61 1.1 scottr u_short txb_new; /* pointer to where new buffer will be added */
62 1.1 scottr u_short txb_next_tx; /* pointer to next buffer ready to xmit */
63 1.1 scottr u_short txb_len[8]; /* buffered xmit buffer lengths */
64 1.1 scottr u_short tx_page_start; /* first page of TX buffer area */
65 1.1 scottr u_short rec_page_start; /* first page of RX ring-buffer */
66 1.1 scottr u_short rec_page_stop; /* last page of RX ring-buffer */
67 1.1 scottr u_short next_packet; /* pointer to next unread RX packet */
68 1.1 scottr
69 1.20 tsutsui u_int8_t sc_enaddr[ETHER_ADDR_LEN]; /* storage for MAC address */
70 1.1 scottr
71 1.5 thorpej int sc_enabled; /* boolean; power enabled on interface */
72 1.11 thorpej
73 1.31 tls krndsource_t rnd_source; /* random source */
74 1.5 thorpej
75 1.25 perry int (*test_mem)(struct dp8390_softc *);
76 1.25 perry void (*init_card)(struct dp8390_softc *);
77 1.25 perry void (*stop_card)(struct dp8390_softc *);
78 1.25 perry void (*read_hdr)(struct dp8390_softc *, int, struct dp8390_ring *);
79 1.25 perry void (*recv_int)(struct dp8390_softc *);
80 1.28 christos int (*ring_copy)(struct dp8390_softc *, int, void *, u_short);
81 1.25 perry int (*write_mbuf)(struct dp8390_softc *, struct mbuf *, int);
82 1.25 perry
83 1.25 perry int (*sc_enable)(struct dp8390_softc *);
84 1.25 perry void (*sc_disable)(struct dp8390_softc *);
85 1.25 perry
86 1.25 perry void (*sc_media_init)(struct dp8390_softc *);
87 1.25 perry void (*sc_media_fini)(struct dp8390_softc *);
88 1.25 perry
89 1.25 perry int (*sc_mediachange)(struct dp8390_softc *);
90 1.25 perry void (*sc_mediastatus)(struct dp8390_softc *, struct ifmediareq *);
91 1.1 scottr };
92 1.1 scottr
93 1.1 scottr /*
94 1.1 scottr * Vendor types
95 1.1 scottr */
96 1.1 scottr #define DP8390_VENDOR_UNKNOWN 0xff /* Unknown network card */
97 1.1 scottr #define DP8390_VENDOR_WD_SMC 0x00 /* Western Digital/SMC */
98 1.1 scottr #define DP8390_VENDOR_3COM 0x01 /* 3Com */
99 1.1 scottr #define DP8390_VENDOR_NOVELL 0x02 /* Novell */
100 1.1 scottr #define DP8390_VENDOR_APPLE 0x10 /* Apple Ethernet card */
101 1.1 scottr #define DP8390_VENDOR_INTERLAN 0x11 /* Interlan A310 card (GatorCard) */
102 1.1 scottr #define DP8390_VENDOR_DAYNA 0x12 /* DaynaPORT E/30s (and others?) */
103 1.1 scottr #define DP8390_VENDOR_ASANTE 0x13 /* Asante MacCon II/E */
104 1.1 scottr #define DP8390_VENDOR_FARALLON 0x14 /* Farallon EtherMac II-TP */
105 1.1 scottr #define DP8390_VENDOR_FOCUS 0x15 /* FOCUS Enhancements EtherLAN */
106 1.1 scottr #define DP8390_VENDOR_KINETICS 0x16 /* Kinetics EtherPort SE/30 */
107 1.8 scottr #define DP8390_VENDOR_CABLETRON 0x17 /* Cabletron Ethernet */
108 1.1 scottr
109 1.1 scottr /*
110 1.1 scottr * Compile-time config flags
111 1.1 scottr */
112 1.1 scottr /*
113 1.37 andvar * This sets the default for enabling/disabling the transceiver.
114 1.1 scottr */
115 1.37 andvar #define DP8390_DISABLE_TRANSCEIVER 0x0001
116 1.1 scottr
117 1.1 scottr /*
118 1.1 scottr * This forces the board to be used in 8/16-bit mode even if it autoconfigs
119 1.1 scottr * differently.
120 1.1 scottr */
121 1.1 scottr #define DP8390_FORCE_8BIT_MODE 0x0002
122 1.1 scottr #define DP8390_FORCE_16BIT_MODE 0x0004
123 1.1 scottr
124 1.1 scottr /*
125 1.1 scottr * This disables the use of multiple transmit buffers.
126 1.1 scottr */
127 1.1 scottr #define DP8390_NO_MULTI_BUFFERING 0x0008
128 1.1 scottr
129 1.1 scottr /*
130 1.1 scottr * This forces all operations with the NIC memory to use Programmed I/O (i.e.
131 1.1 scottr * not via shared memory).
132 1.1 scottr */
133 1.1 scottr #define DP8390_FORCE_PIO 0x0010
134 1.16 enami
135 1.16 enami /*
136 1.16 enami * The chip is ASIX AX88190 and needs work around.
137 1.16 enami */
138 1.16 enami #define DP8390_DO_AX88190_WORKAROUND 0x0020
139 1.19 jhawk
140 1.19 jhawk #define DP8390_ATTACHED 0x0040 /* attach has succeeded */
141 1.1 scottr
142 1.1 scottr /*
143 1.26 bsh * ASIX AX88796 doesn't have remote DMA conmplete bit in ISR, so don't
144 1.26 bsh * check ISR.RDC
145 1.26 bsh */
146 1.26 bsh #define DP8390_NO_REMOTE_DMA_COMPLETE 0x0080
147 1.26 bsh
148 1.26 bsh /*
149 1.1 scottr * NIC register access macros
150 1.1 scottr */
151 1.5 thorpej #define NIC_GET(t, h, reg) bus_space_read_1(t, h, \
152 1.5 thorpej ((sc)->sc_reg_map[reg]))
153 1.5 thorpej #define NIC_PUT(t, h, reg, val) bus_space_write_1(t, h, \
154 1.5 thorpej ((sc)->sc_reg_map[reg]), (val))
155 1.17 ws #define NIC_BARRIER(t, h) bus_space_barrier(t, h, 0, 0x10, \
156 1.17 ws BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
157 1.1 scottr
158 1.25 perry int dp8390_config(struct dp8390_softc *);
159 1.25 perry int dp8390_intr(void *);
160 1.28 christos int dp8390_ioctl(struct ifnet *, u_long, void *);
161 1.25 perry void dp8390_start(struct ifnet *);
162 1.25 perry void dp8390_watchdog(struct ifnet *);
163 1.25 perry void dp8390_reset(struct dp8390_softc *);
164 1.25 perry void dp8390_init(struct dp8390_softc *);
165 1.25 perry void dp8390_stop(struct dp8390_softc *);
166 1.1 scottr
167 1.25 perry void dp8390_rint(struct dp8390_softc *);
168 1.1 scottr
169 1.25 perry void dp8390_getmcaf(struct ethercom *, u_int8_t *);
170 1.25 perry struct mbuf *dp8390_get(struct dp8390_softc *, int, u_short);
171 1.25 perry void dp8390_read(struct dp8390_softc *, int, u_short);
172 1.9 thorpej
173 1.25 perry int dp8390_enable(struct dp8390_softc *);
174 1.25 perry void dp8390_disable(struct dp8390_softc *);
175 1.10 thorpej
176 1.30 cegger int dp8390_activate(device_t, enum devact);
177 1.12 itojun
178 1.25 perry int dp8390_detach(struct dp8390_softc *, int);
179 1.22 thorpej
180 1.25 perry int dp8390_mediachange(struct ifnet *);
181 1.25 perry void dp8390_mediastatus(struct ifnet *, struct ifmediareq *);
182 1.22 thorpej
183 1.25 perry void dp8390_media_init(struct dp8390_softc *);
184