1 |
27 |
unneback |
#ifndef CYGONCE_DEVS_ETH_SMSC_LAN91CXX_LAN91CXX_H
|
2 |
|
|
#define CYGONCE_DEVS_ETH_SMSC_LAN91CXX_LAN91CXX_H
|
3 |
|
|
//==========================================================================
|
4 |
|
|
//
|
5 |
|
|
// lan91cxx.h
|
6 |
|
|
//
|
7 |
|
|
// SMCS LAN91C110 (LAN91CXX compatible) Ethernet chip
|
8 |
|
|
//
|
9 |
|
|
//==========================================================================
|
10 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
18 |
|
|
//
|
19 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
20 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
21 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
22 |
|
|
// for more details.
|
23 |
|
|
//
|
24 |
|
|
// You should have received a copy of the GNU General Public License along
|
25 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
26 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
27 |
|
|
//
|
28 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
29 |
|
|
// or inline functions from this file, or you compile this file and link it
|
30 |
|
|
// with other works to produce a work based on this file, this file does not
|
31 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
32 |
|
|
// License. However the source code for this file must still be made available
|
33 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
36 |
|
|
// this file might be covered by the GNU General Public License.
|
37 |
|
|
//
|
38 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
39 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//####BSDCOPYRIGHTBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// -------------------------------------------
|
45 |
|
|
//
|
46 |
|
|
// Portions of this software may have been derived from OpenBSD or other sources,
|
47 |
|
|
// and are covered by the appropriate copyright disclaimers included herein.
|
48 |
|
|
//
|
49 |
|
|
// -------------------------------------------
|
50 |
|
|
//
|
51 |
|
|
//####BSDCOPYRIGHTEND####
|
52 |
|
|
//==========================================================================
|
53 |
|
|
//#####DESCRIPTIONBEGIN####
|
54 |
|
|
//
|
55 |
|
|
// Author(s): jskov
|
56 |
|
|
// Contributors: jskov, hmt, jco
|
57 |
|
|
// Date: 2001-01-22
|
58 |
|
|
// Purpose: Hardware description of LAN9000 series, LAN91C96/110.
|
59 |
|
|
// Description:
|
60 |
|
|
//
|
61 |
|
|
//####DESCRIPTIONEND####
|
62 |
|
|
//
|
63 |
|
|
//==========================================================================
|
64 |
|
|
|
65 |
|
|
#include <cyg/hal/hal_io.h>
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
#define LAN91CXX_TCR 0x00
|
69 |
|
|
#define LAN91CXX_EPH_STATUS 0x01
|
70 |
|
|
#define LAN91CXX_RCR 0x02
|
71 |
|
|
#define LAN91CXX_COUNTER 0x03
|
72 |
|
|
#define LAN91CXX_MIR 0x04
|
73 |
|
|
#define LAN91CXX_MCR 0x05 // Other than 91C111
|
74 |
|
|
#define LAN91CXX_RPCR 0x05 // 91C111 only
|
75 |
|
|
#define LAN91CXX_RESERVED_0 0x06
|
76 |
|
|
#define LAN91CXX_BS 0x07
|
77 |
|
|
#define LAN91CXX_CONFIG 0x08
|
78 |
|
|
#define LAN91CXX_BASE_REG 0x09
|
79 |
|
|
#define LAN91CXX_IA01 0x0a
|
80 |
|
|
#define LAN91CXX_IA23 0x0b
|
81 |
|
|
#define LAN91CXX_IA45 0x0c
|
82 |
|
|
#define LAN91CXX_GENERAL 0x0d // 91C96 - was "RESERVED_1" for others
|
83 |
|
|
#define LAN91CXX_CONTROL 0x0e
|
84 |
|
|
#define LAN91CXX_BS2 0x0f
|
85 |
|
|
#define LAN91CXX_MMU_COMMAND 0x10
|
86 |
|
|
#define LAN91CXX_PNR 0x11
|
87 |
|
|
#define LAN91CXX_FIFO_PORTS 0x12
|
88 |
|
|
#define LAN91CXX_POINTER 0x13
|
89 |
|
|
#define LAN91CXX_DATA_HIGH 0x14
|
90 |
|
|
#define LAN91CXX_DATA 0x15
|
91 |
|
|
#define LAN91CXX_INTERRUPT 0x16
|
92 |
|
|
#define LAN91CXX_BS3 0x17
|
93 |
|
|
#define LAN91CXX_MT01 0x18
|
94 |
|
|
#define LAN91CXX_MT23 0x19
|
95 |
|
|
#define LAN91CXX_MT45 0x1a
|
96 |
|
|
#define LAN91CXX_MT67 0x1b
|
97 |
|
|
#define LAN91CXX_MGMT 0x1c
|
98 |
|
|
#define LAN91CXX_REVISION 0x1d
|
99 |
|
|
#define LAN91CXX_ERCV 0x1e
|
100 |
|
|
#define LAN91CXX_BS4 0x1f
|
101 |
|
|
|
102 |
|
|
#define LAN91CXX_RCR_SOFT_RST 0x8000 // soft reset
|
103 |
|
|
#define LAN91CXX_RCR_FILT_CAR 0x4000 // filter carrier
|
104 |
|
|
#define LAN91CXX_RCR_ABORT_ENB 0x2000 // abort on collision
|
105 |
|
|
#define LAN91CXX_RCR_STRIP_CRC 0x0200 // strip CRC
|
106 |
|
|
#define LAN91CXX_RCR_RXEN 0x0100 // enable RX
|
107 |
|
|
#define LAN91CXX_RCR_ALMUL 0x0004 // receive all muticasts
|
108 |
|
|
#define LAN91CXX_RCR_PRMS 0x0002 // promiscuous
|
109 |
|
|
#define LAN91CXX_RCR_RX_ABORT 0x0001 // set when abort due to long frame
|
110 |
|
|
|
111 |
|
|
#define LAN91CXX_TCR_SWFDUP 0x8000 // Switched Full Duplex mode
|
112 |
|
|
#define LAN91CXX_TCR_ETEN_TYPE 0x4000 // ETEN type (91C96) 0 <=> like a 91C94
|
113 |
|
|
#define LAN91CXX_TCR_EPH_LOOP 0x2000 // loopback mode
|
114 |
|
|
#define LAN91CXX_TCR_STP_SQET 0x1000 // Stop transmission on SQET error
|
115 |
|
|
#define LAN91CXX_TCR_FDUPLX 0x0800 // full duplex
|
116 |
|
|
#define LAN91CXX_TCR_MON_CSN 0x0400 // monitor carrier during tx (91C96)
|
117 |
|
|
#define LAN91CXX_TCR_NOCRC 0x0100 // does not append CRC to frames
|
118 |
|
|
#define LAN91CXX_TCR_PAD_EN 0x0080 // pads frames with 00 to min length
|
119 |
|
|
#define LAN91CXX_TCR_FORCOL 0x0004 // force collision
|
120 |
|
|
#define LAN91CXX_TCR_LLOOP 0x0002 // local loopback (91C96)
|
121 |
|
|
#define LAN91CXX_TCR_TXENA 0x0001 // enable
|
122 |
|
|
|
123 |
|
|
#define LAN91CXX_POINTER_RCV 0x8000
|
124 |
|
|
#define LAN91CXX_POINTER_AUTO_INCR 0x4000
|
125 |
|
|
#define LAN91CXX_POINTER_READ 0x2000
|
126 |
|
|
#define LAN91CXX_POINTER_ETEN 0x1000
|
127 |
|
|
#define LAN91CXX_POINTER_NOT_EMPTY 0x0800
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
#define LAN91CXX_INTERRUPT_TX_IDLE_M 0x8000 // (91C96)
|
131 |
|
|
#define LAN91CXX_INTERRUPT_ERCV_INT_M 0x4000
|
132 |
|
|
#define LAN91CXX_INTERRUPT_EPH_INT_M 0x2000
|
133 |
|
|
#define LAN91CXX_INTERRUPT_RX_OVRN_INT_M 0x1000
|
134 |
|
|
#define LAN91CXX_INTERRUPT_ALLOC_INT_M 0x0800
|
135 |
|
|
#define LAN91CXX_INTERRUPT_TX_EMPTY_INT_M 0x0400
|
136 |
|
|
#define LAN91CXX_INTERRUPT_TX_INT_M 0x0200
|
137 |
|
|
#define LAN91CXX_INTERRUPT_RCV_INT_M 0x0100
|
138 |
|
|
#define LAN91CXX_INTERRUPT_TX_IDLE 0x0080 // (91C96)
|
139 |
|
|
#define LAN91CXX_INTERRUPT_ERCV_INT 0x0040 // also ack
|
140 |
|
|
#define LAN91CXX_INTERRUPT_EPH_INT 0x0020
|
141 |
|
|
#define LAN91CXX_INTERRUPT_RX_OVRN_INT 0x0010 // also ack
|
142 |
|
|
#define LAN91CXX_INTERRUPT_ALLOC_INT 0x0008
|
143 |
|
|
#define LAN91CXX_INTERRUPT_TX_EMPTY_INT 0x0004 // also ack
|
144 |
|
|
#define LAN91CXX_INTERRUPT_TX_INT 0x0002 // also ack
|
145 |
|
|
#define LAN91CXX_INTERRUPT_RCV_INT 0x0001
|
146 |
|
|
|
147 |
|
|
#if 0 // Whichever we choose, the behaviour is the same.
|
148 |
|
|
#define LAN91CXX_INTERRUPT_TX_SET 0x0002 // TX
|
149 |
|
|
#define LAN91CXX_INTERRUPT_TX_SET_ACK 0x0000 // -none-
|
150 |
|
|
#define LAN91CXX_INTERRUPT_TX_FIFO_ACK 0x0002 // TX alone
|
151 |
|
|
#define LAN91CXX_INTERRUPT_TX_SET_M 0x0200 // TX alone
|
152 |
|
|
#else
|
153 |
|
|
#define LAN91CXX_INTERRUPT_TX_SET 0x0006 // TX_EMPTY + TX
|
154 |
|
|
#define LAN91CXX_INTERRUPT_TX_SET_ACK 0x0004 // TX_EMPTY and not plain TX
|
155 |
|
|
#define LAN91CXX_INTERRUPT_TX_FIFO_ACK 0x0002 // TX alone
|
156 |
|
|
#define LAN91CXX_INTERRUPT_TX_SET_M 0x0600 // TX_EMPTY + TX
|
157 |
|
|
#endif
|
158 |
|
|
|
159 |
|
|
#define LAN91CXX_CONTROL_RCV_BAD 0x4000
|
160 |
|
|
#define LAN91CXX_CONTROL_AUTO_RELEASE 0x0800
|
161 |
|
|
#define LAN91CXX_CONTROL_LE_ENABLE 0x0080
|
162 |
|
|
#define LAN91CXX_CONTROL_CR_ENABLE 0x0040
|
163 |
|
|
#define LAN91CXX_CONTROL_TE_ENABLE 0x0020
|
164 |
|
|
|
165 |
|
|
// These are for setting the MAC address in the 91C96 serial EEPROM
|
166 |
|
|
#define LAN91CXX_CONTROL_EEPROM_SELECT 0x0004
|
167 |
|
|
#define LAN91CXX_CONTROL_RELOAD 0x0002
|
168 |
|
|
#define LAN91CXX_CONTROL_STORE 0x0001
|
169 |
|
|
#define LAN91CXX_CONTROL_EEPROM_BUSY 0x0003
|
170 |
|
|
#define LAN91CXX_ESA_EEPROM_OFFSET 0x0020
|
171 |
|
|
|
172 |
|
|
#define LAN91CXX_STATUS_TX_UNRN 0x8000
|
173 |
|
|
#define LAN91CXX_STATUS_LINK_OK 0x4000
|
174 |
|
|
#define LAN91CXX_STATUS_CTR_ROL 0x1000
|
175 |
|
|
#define LAN91CXX_STATUS_EXC_DEF 0x0800
|
176 |
|
|
#define LAN91CXX_STATUS_LOST_CARR 0x0400
|
177 |
|
|
#define LAN91CXX_STATUS_LATCOL 0x0200
|
178 |
|
|
#define LAN91CXX_STATUS_WAKEUP 0x0100
|
179 |
|
|
#define LAN91CXX_STATUS_TX_DEFR 0x0080
|
180 |
|
|
#define LAN91CXX_STATUS_LTX_BRD 0x0040
|
181 |
|
|
#define LAN91CXX_STATUS_SQET 0x0020
|
182 |
|
|
#define LAN91CXX_STATUS_16COL 0x0010
|
183 |
|
|
#define LAN91CXX_STATUS_LTX_MULT 0x0008
|
184 |
|
|
#define LAN91CXX_STATUS_MUL_COL 0x0004
|
185 |
|
|
#define LAN91CXX_STATUS_SNGL_COL 0x0002
|
186 |
|
|
#define LAN91CXX_STATUS_TX_SUC 0x0001
|
187 |
|
|
|
188 |
|
|
#define LAN91CXX_MMU_noop 0x0000
|
189 |
|
|
#define LAN91CXX_MMU_alloc_for_tx 0x0020
|
190 |
|
|
#define LAN91CXX_MMU_reset_mmu 0x0040
|
191 |
|
|
#define LAN91CXX_MMU_rem_rx_frame 0x0060
|
192 |
|
|
#define LAN91CXX_MMU_rem_tx_frame 0x0070 // (91C96) only when TX stopped
|
193 |
|
|
#define LAN91CXX_MMU_remrel_rx_frame 0x0080
|
194 |
|
|
#define LAN91CXX_MMU_rel_packet 0x00a0
|
195 |
|
|
#define LAN91CXX_MMU_enq_packet 0x00c0
|
196 |
|
|
#define LAN91CXX_MMU_reset_tx_fifo 0x00e0
|
197 |
|
|
|
198 |
|
|
#define LAN91CXX_CONTROLBYTE_CRC 0x1000
|
199 |
|
|
#define LAN91CXX_CONTROLBYTE_ODD 0x2000
|
200 |
|
|
#define LAN91CXX_CONTROLBYTE_RX 0x4000
|
201 |
|
|
|
202 |
|
|
#define LAN91CXX_RX_STATUS_ALIGNERR 0x8000
|
203 |
|
|
#define LAN91CXX_RX_STATUS_BCAST 0x4000
|
204 |
|
|
#define LAN91CXX_RX_STATUS_BADCRC 0x2000
|
205 |
|
|
#define LAN91CXX_RX_STATUS_ODDFRM 0x1000
|
206 |
|
|
#define LAN91CXX_RX_STATUS_TOOLONG 0x0800
|
207 |
|
|
#define LAN91CXX_RX_STATUS_TOOSHORT 0x0400
|
208 |
|
|
#define LAN91CXX_RX_STATUS_HASHVALMASK 0x007e // MASK
|
209 |
|
|
#define LAN91CXX_RX_STATUS_MCAST 0x0001
|
210 |
|
|
#define LAN91CXX_RX_STATUS_BAD \
|
211 |
|
|
(LAN91CXX_RX_STATUS_ALIGNERR | \
|
212 |
|
|
LAN91CXX_RX_STATUS_BADCRC | \
|
213 |
|
|
LAN91CXX_RX_STATUS_TOOLONG | \
|
214 |
|
|
LAN91CXX_RX_STATUS_TOOSHORT)
|
215 |
|
|
|
216 |
|
|
// Attribute memory registers in PCMCIA mode
|
217 |
|
|
#define LAN91CXX_ECOR 0x8000
|
218 |
|
|
#define LAN91CXX_ECOR_RESET (1<<7)
|
219 |
|
|
#define LAN91CXX_ECOR_LEVIRQ (1<<6)
|
220 |
|
|
#define LAN91CXX_ECOR_ATTWR (1<<2)
|
221 |
|
|
#define LAN91CXX_ECOR_ENABLE (1<<0)
|
222 |
|
|
|
223 |
|
|
#define LAN91CXX_ECSR 0x8002
|
224 |
|
|
#define LAN91CXX_ECSR_IOIS8 (1<<5)
|
225 |
|
|
#define LAN91CXX_ECSR_PWRDWN (1<<2)
|
226 |
|
|
#define LAN91CXX_ECSR_INTR (1<<1)
|
227 |
|
|
|
228 |
|
|
// These are for manipulating the MII interface
|
229 |
|
|
#define LAN91CXX_MGMT_MDO 0x0001
|
230 |
|
|
#define LAN91CXX_MGMT_MDI 0x0002
|
231 |
|
|
#define LAN91CXX_MGMT_MCLK 0x0004
|
232 |
|
|
#define LAN91CXX_MGMT_MDOE 0x0008
|
233 |
|
|
|
234 |
|
|
// Internal PHY registers (91c111)
|
235 |
|
|
#define LAN91CXX_PHY_CTRL 0
|
236 |
|
|
#define LAN91CXX_PHY_STAT 1
|
237 |
|
|
#define LAN91CXX_PHY_ID1 2
|
238 |
|
|
#define LAN91CXX_PHY_ID2 3
|
239 |
|
|
#define LAN91CXX_PHY_AUTO_AD 4
|
240 |
|
|
#define LAN91CXX_PHY_AUTO_CAP 5
|
241 |
|
|
#define LAN91CXX_PHY_CONFIG1 16
|
242 |
|
|
#define LAN91CXX_PHY_CONFIG2 17
|
243 |
|
|
#define LAN91CXX_PHY_STATUS_OUT 18
|
244 |
|
|
#define LAN91CXX_PHY_MASK 19
|
245 |
|
|
|
246 |
|
|
// PHY control bits
|
247 |
|
|
#define LAN91CXX_PHY_CTRL_COLTST (1 << 7)
|
248 |
|
|
#define LAN91CXX_PHY_CTRL_DPLX (1 << 8)
|
249 |
|
|
#define LAN91CXX_PHY_CTRL_ANEG_RST (1 << 9)
|
250 |
|
|
#define LAN91CXX_PHY_CTRL_MII_DIS (1 << 10)
|
251 |
|
|
#define LAN91CXX_PHY_CTRL_PDN (1 << 11)
|
252 |
|
|
#define LAN91CXX_PHY_CTRL_ANEG_EN (1 << 12)
|
253 |
|
|
#define LAN91CXX_PHY_CTRL_SPEED (1 << 13)
|
254 |
|
|
#define LAN91CXX_PHY_CTRL_LPBK (1 << 14)
|
255 |
|
|
#define LAN91CXX_PHY_CTRL_RST (1 << 15)
|
256 |
|
|
|
257 |
|
|
#define LAN91CXX_RPCR_LEDA_LINK (0 << 2)
|
258 |
|
|
#define LAN91CXX_RPCR_LEDA_TXRX (4 << 2)
|
259 |
|
|
#define LAN91CXX_RPCR_LEDA_RX (6 << 2)
|
260 |
|
|
#define LAN91CXX_RPCR_LEDA_TX (7 << 2)
|
261 |
|
|
#define LAN91CXX_RPCR_LEDB_LINK (0 << 5)
|
262 |
|
|
#define LAN91CXX_RPCR_LEDB_TXRX (4 << 5)
|
263 |
|
|
#define LAN91CXX_RPCR_LEDB_RX (6 << 5)
|
264 |
|
|
#define LAN91CXX_RPCR_LEDB_TX (7 << 5)
|
265 |
|
|
#define LAN91CXX_RPCR_ANEG (1 << 11)
|
266 |
|
|
#define LAN91CXX_RPCR_DPLX (1 << 12)
|
267 |
|
|
#define LAN91CXX_RPCR_SPEED (1 << 13)
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
// ------------------------------------------------------------------------
|
271 |
|
|
|
272 |
|
|
#ifdef KEEP_STATISTICS
|
273 |
|
|
struct smsc_lan91cxx_stats {
|
274 |
|
|
unsigned int tx_good ;
|
275 |
|
|
unsigned int tx_max_collisions ;
|
276 |
|
|
unsigned int tx_late_collisions ;
|
277 |
|
|
unsigned int tx_underrun ;
|
278 |
|
|
unsigned int tx_carrier_loss ;
|
279 |
|
|
unsigned int tx_deferred ;
|
280 |
|
|
unsigned int tx_sqetesterrors ;
|
281 |
|
|
unsigned int tx_single_collisions;
|
282 |
|
|
unsigned int tx_mult_collisions ;
|
283 |
|
|
unsigned int tx_total_collisions ;
|
284 |
|
|
unsigned int rx_good ;
|
285 |
|
|
unsigned int rx_crc_errors ;
|
286 |
|
|
unsigned int rx_align_errors ;
|
287 |
|
|
unsigned int rx_resource_errors ;
|
288 |
|
|
unsigned int rx_overrun_errors ;
|
289 |
|
|
unsigned int rx_collisions ;
|
290 |
|
|
unsigned int rx_short_frames ;
|
291 |
|
|
unsigned int rx_too_long_frames ;
|
292 |
|
|
unsigned int rx_symbol_errors ;
|
293 |
|
|
unsigned int interrupts ;
|
294 |
|
|
unsigned int rx_count ;
|
295 |
|
|
unsigned int rx_deliver ;
|
296 |
|
|
unsigned int rx_resource ;
|
297 |
|
|
unsigned int rx_restart ;
|
298 |
|
|
unsigned int tx_count ;
|
299 |
|
|
unsigned int tx_complete ;
|
300 |
|
|
unsigned int tx_dropped ;
|
301 |
|
|
};
|
302 |
|
|
#endif
|
303 |
|
|
|
304 |
|
|
typedef struct lan91cxx_priv_data {
|
305 |
|
|
int txbusy; // A packet has been sent
|
306 |
|
|
unsigned long txkey; // Used to ack when packet sent
|
307 |
|
|
unsigned short* base; // Base I/O address of controller
|
308 |
|
|
// (as it comes out of reset)
|
309 |
|
|
#if CYGINT_DEVS_ETH_SMSC_LAN91CXX_PCMCIA_MODE
|
310 |
|
|
unsigned char* attbase; // Base attribute address of controller
|
311 |
|
|
// only used in PCMCIA mode
|
312 |
|
|
#endif
|
313 |
|
|
int interrupt; // Interrupt vector used by controller
|
314 |
|
|
unsigned char enaddr[6]; // Controller ESA
|
315 |
|
|
// Function to configure the ESA - may fetch ESA from EPROM or
|
316 |
|
|
// RedBoot config option.
|
317 |
|
|
void (*config_enaddr)(struct lan91cxx_priv_data* cpd);
|
318 |
|
|
int txpacket;
|
319 |
|
|
int rxpacket;
|
320 |
|
|
int within_send;
|
321 |
|
|
int addrsh; // Address bits to shift
|
322 |
|
|
#ifdef KEEP_STATISTICS
|
323 |
|
|
struct smsc_lan91cxx_stats stats;
|
324 |
|
|
#endif
|
325 |
|
|
} lan91cxx_priv_data;
|
326 |
|
|
|
327 |
|
|
// ------------------------------------------------------------------------
|
328 |
|
|
|
329 |
|
|
#include CYGDAT_DEVS_ETH_SMSC_LAN91CXX_INL
|
330 |
|
|
|
331 |
|
|
#ifdef LAN91CXX_32BIT_RX
|
332 |
|
|
typedef cyg_uint32 rxd_t;
|
333 |
|
|
#else
|
334 |
|
|
typedef cyg_uint16 rxd_t;
|
335 |
|
|
#endif
|
336 |
|
|
|
337 |
|
|
#ifndef SMSC_PLATFORM_DEFINED_GET_REG
|
338 |
|
|
static __inline__ unsigned short
|
339 |
|
|
get_reg(struct eth_drv_sc *sc, int regno)
|
340 |
|
|
{
|
341 |
|
|
struct lan91cxx_priv_data *cpd =
|
342 |
|
|
(struct lan91cxx_priv_data *)sc->driver_private;
|
343 |
|
|
unsigned short val;
|
344 |
|
|
|
345 |
|
|
HAL_WRITE_UINT16(cpd->base+(LAN91CXX_BS << cpd->addrsh), regno>>3);
|
346 |
|
|
HAL_READ_UINT16(cpd->base+((regno&0x7) << cpd->addrsh), val);
|
347 |
|
|
#if DEBUG & 2
|
348 |
|
|
diag_printf("read reg %d val 0x%04x\n", regno, val);
|
349 |
|
|
#endif
|
350 |
|
|
return val;
|
351 |
|
|
}
|
352 |
|
|
#endif // SMSC_PLATFORM_DEFINED_GET_REG
|
353 |
|
|
|
354 |
|
|
#ifndef SMSC_PLATFORM_DEFINED_PUT_REG
|
355 |
|
|
static __inline__ void
|
356 |
|
|
put_reg(struct eth_drv_sc *sc, int regno, unsigned short val)
|
357 |
|
|
{
|
358 |
|
|
struct lan91cxx_priv_data *cpd =
|
359 |
|
|
(struct lan91cxx_priv_data *)sc->driver_private;
|
360 |
|
|
|
361 |
|
|
HAL_WRITE_UINT16(cpd->base+(LAN91CXX_BS << cpd->addrsh), regno>>3);
|
362 |
|
|
HAL_WRITE_UINT16(cpd->base+((regno&0x7) << cpd->addrsh), val);
|
363 |
|
|
|
364 |
|
|
#if DEBUG & 2
|
365 |
|
|
diag_printf("write reg %d val 0x%04x\n", regno, val);
|
366 |
|
|
#endif
|
367 |
|
|
}
|
368 |
|
|
#endif // SMSC_PLATFORM_DEFINED_PUT_REG
|
369 |
|
|
|
370 |
|
|
#ifndef SMSC_PLATFORM_DEFINED_PUT_DATA
|
371 |
|
|
// ------------------------------------------------------------------------
|
372 |
|
|
// Assumes bank2 has been selected
|
373 |
|
|
static __inline__ void
|
374 |
|
|
put_data(struct eth_drv_sc *sc, unsigned short val)
|
375 |
|
|
{
|
376 |
|
|
struct lan91cxx_priv_data *cpd =
|
377 |
|
|
(struct lan91cxx_priv_data *)sc->driver_private;
|
378 |
|
|
|
379 |
|
|
HAL_WRITE_UINT16(cpd->base+((LAN91CXX_DATA & 0x7) << cpd->addrsh), val);
|
380 |
|
|
|
381 |
|
|
#if DEBUG & 2
|
382 |
|
|
diag_printf("write data 0x%04x\n", val);
|
383 |
|
|
#endif
|
384 |
|
|
}
|
385 |
|
|
#endif // SMSC_PLATFORM_DEFINED_PUT_DATA
|
386 |
|
|
|
387 |
|
|
#ifndef SMSC_PLATFORM_DEFINED_GET_DATA
|
388 |
|
|
// Assumes bank2 has been selected
|
389 |
|
|
static __inline__ rxd_t
|
390 |
|
|
get_data(struct eth_drv_sc *sc)
|
391 |
|
|
{
|
392 |
|
|
rxd_t val;
|
393 |
|
|
struct lan91cxx_priv_data *cpd =
|
394 |
|
|
(struct lan91cxx_priv_data *)sc->driver_private;
|
395 |
|
|
|
396 |
|
|
#ifdef LAN91CXX_32BIT_RX
|
397 |
|
|
HAL_READ_UINT32(cpd->base+((LAN91CXX_DATA_HIGH & 0x7) << cpd->addrsh), val);
|
398 |
|
|
#else
|
399 |
|
|
HAL_READ_UINT16(cpd->base+((LAN91CXX_DATA & 0x7) << cpd->addrsh), val);
|
400 |
|
|
#endif
|
401 |
|
|
|
402 |
|
|
#if DEBUG & 2
|
403 |
|
|
diag_printf("read data 0x%x\n", val);
|
404 |
|
|
#endif
|
405 |
|
|
return val;
|
406 |
|
|
}
|
407 |
|
|
#endif // SMSC_PLATFORM_DEFINED_GET_DATA
|
408 |
|
|
|
409 |
|
|
// ------------------------------------------------------------------------
|
410 |
|
|
// Read the bank register (this one is bank-independent)
|
411 |
|
|
static __inline__ unsigned short
|
412 |
|
|
get_banksel(struct eth_drv_sc *sc)
|
413 |
|
|
{
|
414 |
|
|
struct lan91cxx_priv_data *cpd =
|
415 |
|
|
(struct lan91cxx_priv_data *)sc->driver_private;
|
416 |
|
|
unsigned short val;
|
417 |
|
|
|
418 |
|
|
HAL_READ_UINT16(cpd->base+(LAN91CXX_BS << cpd->addrsh), val);
|
419 |
|
|
#if DEBUG & 2
|
420 |
|
|
diag_printf("read bank val 0x%04x\n", val);
|
421 |
|
|
#endif
|
422 |
|
|
return val;
|
423 |
|
|
}
|
424 |
|
|
|
425 |
|
|
|
426 |
|
|
// ------------------------------------------------------------------------
|
427 |
|
|
// Write on PCMCIA attribute memory
|
428 |
|
|
#if CYGINT_DEVS_ETH_SMSC_LAN91CXX_PCMCIA_MODE
|
429 |
|
|
static __inline__ void
|
430 |
|
|
put_att(struct eth_drv_sc *sc, int offs, unsigned char val)
|
431 |
|
|
{
|
432 |
|
|
struct lan91cxx_priv_data *cpd =
|
433 |
|
|
(struct lan91cxx_priv_data *)sc->driver_private;
|
434 |
|
|
|
435 |
|
|
HAL_WRITE_UINT8(cpd->attbase + (offs << cpd->addrsh), val);
|
436 |
|
|
|
437 |
|
|
#if DEBUG & 2
|
438 |
|
|
diag_printf("write attr %d val 0x%02x\n", offs, val);
|
439 |
|
|
#endif
|
440 |
|
|
}
|
441 |
|
|
|
442 |
|
|
// Read from PCMCIA attribute memory
|
443 |
|
|
static __inline__ unsigned char
|
444 |
|
|
get_att(struct eth_drv_sc *sc, int offs)
|
445 |
|
|
{
|
446 |
|
|
struct lan91cxx_priv_data *cpd =
|
447 |
|
|
(struct lan91cxx_priv_data *)sc->driver_private;
|
448 |
|
|
unsigned char val;
|
449 |
|
|
|
450 |
|
|
HAL_READ_UINT8(cpd->attbase + (offs << cpd->addrsh), val);
|
451 |
|
|
#if DEBUG & 2
|
452 |
|
|
diag_printf("read attr %d val 0x%02x\n", offs, val);
|
453 |
|
|
#endif
|
454 |
|
|
return val;
|
455 |
|
|
}
|
456 |
|
|
#endif // #if CYGINT_DEVS_ETH_SMSC_LAN91CXX_PCMCIA_MODE
|
457 |
|
|
|
458 |
|
|
// ------------------------------------------------------------------------
|
459 |
|
|
#endif // CYGONCE_DEVS_ETH_SMSC_LAN91CXX_LAN91CXX_H
|
460 |
|
|
// EOF smsc_lan91cxx.h
|