source: rtems/c/src/libchip/network/cs8900.h @ 1c36c3e4

4.104.114.84.95
Last change on this file since 1c36c3e4 was a2117cd6, checked in by Joel Sherrill <joel.sherrill@…>, on 09/07/02 at 23:09:47

2002-09-07 Chris Johns <ccj@…>

  • network/Makefile.am, network/README.cs8900, network/cs8900.c, network/cs8900.h: Significant update which corrects the problem where the cs8900.c file was actually the BSP glue. Joel did some hacking so this file will compile. Previously it required providing a target.h file to compile.
  • network/cs8900.c.bsp: New file.
  • Property mode set to 100644
File size: 13.0 KB
Line 
1/*
2  ------------------------------------------------------------------------
3  $Id$
4  ------------------------------------------------------------------------
5 
6  My Right Boot, a boot ROM for embedded hardware.
7 
8  Copyright Cybertec Pty Ltd, 2000
9  All rights reserved Cybertec Pty Ltd, 2000
10 
11  COPYRIGHT (c) 1989-1998.
12  On-Line Applications Research Corporation (OAR).
13
14  The license and distribution terms for this file may be
15  found in the file LICENSE in this distribution or at
16  http://www.OARcorp.com/rtems/license.html.
17 
18  ------------------------------------------------------------------------
19
20  CS8900 net boot driver.
21
22 */
23
24#if !defined(_CS8900_H_)
25#define _CS8900_H_
26
27#include <rtems.h>
28#include <rtems/error.h>
29#include <rtems/rtems_bsdnet.h>
30
31#include <sys/param.h>
32#include <sys/mbuf.h>
33#include <sys/socket.h>
34#include <sys/sockio.h>
35
36#include <net/if.h>
37
38#include <netinet/in.h>
39#include <netinet/if_ether.h>
40
41/* #include <target.h> what does this provide? joel to chris */
42
43#define ET_MINLEN 60
44
45/*
46 * CS8900 device register definitions
47 */
48
49/*
50 * Crystal ESIA product id.
51 */
52
53#define CS8900_ESIA_ID             (0x630e)
54
55/*
56 * IO Registers.
57 */
58
59#define CS8900_IO_RX_TX_DATA_PORT0 (0x0000)
60#define CS8900_IO_TX_TX_DATA_PORT1 (0x0002)
61#define CS8900_IO_TxCMD            (0x0004)
62#define CS8900_IO_TxLength         (0x0006)
63#define CS8900_IO_ISQ              (0x0008)
64#define CS8900_IO_PACKET_PAGE_PTR  (0x000a)
65#define CS8900_IO_PP_DATA_PORT0    (0x000c)
66#define CS8900_IO_PP_DATA_PORT1    (0x000e)
67
68/*
69 * Packet Page Registers.
70 */
71
72/*
73 * Bus Interface Registers.
74 */
75
76#define CS8900_PP_PROD_ID          (0x0000)
77#define CS8900_PP_IO_BASE          (0x0020)
78#define CS8900_PP_INT              (0x0022)
79#define CS8900_PP_DMA_CHANNEL      (0x0024)
80#define CS8900_PP_DMA_SOF          (0x0026)
81#define CS8900_PP_DMA_FRM_CNT      (0x0028)
82#define CS8900_PP_DMA_RX_BCNT      (0x002a)
83#define CS8900_PP_MEM_BASE         (0x002c)
84#define CS8900_PP_BPROM_BASE       (0x0030)
85#define CS8900_PP_BPROM_AMASK      (0x0034)
86#define CS8900_PP_EEPROM_CMD       (0x0040)
87#define CS8900_PP_EEPROM_DATA      (0x0042)
88#define CS8900_PP_RX_FRAME_BCNT    (0x0050)
89
90/*
91 * Configuration and Control Registers.
92 */
93
94#define CS8900_PP_RxCFG            (0x0102)
95#define CS8900_PP_RxCTL            (0x0104)
96#define CS8900_PP_TxCFG            (0x0106)
97#define CS8900_PP_TxCMD_READ       (0x0108)
98#define CS8900_PP_BufCFG           (0x010a)
99#define CS8900_PP_LineCFG          (0x0112)
100#define CS8900_PP_SelfCTL          (0x0114)
101#define CS8900_PP_BusCTL           (0x0116)
102#define CS8900_PP_TestCTL          (0x0118)
103
104/*
105 * Status and Event Registers.
106 */
107
108#define CS8900_PP_ISQ              (0x0120)
109#define CS8900_PP_RxEvent          (0x0124)
110#define CS8900_PP_TxEvent          (0x0128)
111#define CS8900_PP_BufEvent         (0x012c)
112#define CS8900_PP_RxMISS           (0x0130)
113#define CS8900_PP_TxCol            (0x0132)
114#define CS8900_PP_LineST           (0x0134)
115#define CS8900_PP_SelfST           (0x0136)
116#define CS8900_PP_BusST            (0x0138)
117#define CS8900_PP_TDR              (0x013c)
118
119/*
120 * Initiate Transmit Registers.
121 */
122
123#define CS8900_PP_TxCMD            (0x0144)
124#define CS8900_PP_TxLength         (0x0146)
125
126/*
127 * Address Filter Registers.
128 */
129
130#define CS8900_PP_LAF              (0x0150)
131#define CS8900_PP_IA               (0x0158)
132
133/*
134 * Frame Location.
135 */
136
137#define CS8900_PP_RxStatus         (0x0400)
138#define CS8900_PP_RxLength         (0x0402)
139#define CS8900_PP_RxFrameLoc       (0x0404)
140#define CS8900_PP_TxFrameLoc       (0x0a00)
141
142/*
143 * Bit Definitions of Registers.
144 */
145
146/*
147 * IO Packet Page Pointer.
148 */
149
150#define CS8900_PPP_AUTO_INCREMENT             (0x8000)
151
152/*
153 * Reg 3. Receiver Configuration.
154 */
155
156#define CS8900_RX_CONFIG_SKIP_1               (1 << 6)
157#define CS8900_RX_CONFIG_STREAM_ENABLE        (1 << 7)
158#define CS8900_RX_CONFIG_RX_OK                (1 << 8)
159#define CS8900_RX_CONFIG_RX_DMA               (1 << 9)
160#define CS8900_RX_CONFIG_RX_AUTO_DMA          (1 << 10)
161#define CS8900_RX_CONFIG_BUFFER_CRC           (1 << 11)
162#define CS8900_RX_CONFIG_CRC_ERROR            (1 << 12)
163#define CS8900_RX_CONFIG_RUNT                 (1 << 13)
164#define CS8900_RX_CONFIG_EXTRA_DATA           (1 << 14)
165
166/*
167 * Reg 4. Receiver Event.
168 */
169
170#define CS8900_RX_EVENT_HASH_IA_MATCH         (1 << 6)
171#define CS8900_RX_EVENT_DRIBBLE_BITS          (1 << 7)
172#define CS8900_RX_EVENT_RX_OK                 (1 << 8)
173#define CS8900_RX_EVENT_HASHED                (1 << 9)
174#define CS8900_RX_EVENT_IA                    (1 << 10)
175#define CS8900_RX_EVENT_BROADCAST             (1 << 11)
176#define CS8900_RX_EVENT_CRC_ERROR             (1 << 12)
177#define CS8900_RX_EVENT_RUNT                  (1 << 13)
178#define CS8900_RX_EVENT_EXTRA_DATA            (1 << 14)
179
180/*
181 * Reg 5. Receiver Control.
182 */
183
184#define CS8900_RX_CTRL_HASH_IA_MATCH          (1 << 6)
185#define CS8900_RX_CTRL_PROMISCUOUS            (1 << 7)
186#define CS8900_RX_CTRL_RX_OK                  (1 << 8)
187#define CS8900_RX_CTRL_MULTICAST              (1 << 9)
188#define CS8900_RX_CTRL_INDIVIDUAL             (1 << 10)
189#define CS8900_RX_CTRL_BROADCAST              (1 << 11)
190#define CS8900_RX_CTRL_CRC_ERROR              (1 << 12)
191#define CS8900_RX_CTRL_RUNT                   (1 << 13)
192#define CS8900_RX_CTRL_EXTRA_DATA             (1 << 14)
193
194/*
195 * Reg 7. Transmit Configuration.
196 */
197
198#define CS8900_TX_CONFIG_LOSS_OF_CARRIER      (1 << 6)
199#define CS8900_TX_CONFIG_SQ_ERROR             (1 << 7)
200#define CS8900_TX_CONFIG_TX_OK                (1 << 8)
201#define CS8900_TX_CONFIG_OUT_OF_WINDOW        (1 << 9)
202#define CS8900_TX_CONFIG_JABBER               (1 << 10)
203#define CS8900_TX_CONFIG_ANY_COLLISION        (1 << 11)
204#define CS8900_TX_CONFIG_16_COLLISION         (1 << 15)
205
206/*
207 * Reg 8. Transmit Event.
208 */
209
210#define CS8900_TX_EVENT_LOSS_OF_CARRIER       (1 << 6)
211#define CS8900_TX_EVENT_SQ_ERROR              (1 << 7)
212#define CS8900_TX_EVENT_TX_OK                 (1 << 8)
213#define CS8900_TX_EVENT_OUT_OF_WINDOW         (1 << 9)
214#define CS8900_TX_EVENT_JABBER                (1 << 10)
215#define CS8900_TX_EVENT_16_COLLISIONS         (1 << 15)
216
217/*
218 * Reg 9. Transmit Command Status.
219 */
220
221#define CS8900_TX_CMD_STATUS_TX_START_5       (0 << 6)
222#define CS8900_TX_CMD_STATUS_TX_START_381     (1 << 6)
223#define CS8900_TX_CMD_STATUS_TX_START_1021    (2 << 6)
224#define CS8900_TX_CMD_STATUS_TX_START_ENTIRE  (3 << 6)
225#define CS8900_TX_CMD_STATUS_FORCE            (1 << 8)
226#define CS8900_TX_CMD_STATUS_ONE_COLLISION    (1 << 9)
227#define CS8900_TX_CMD_STATUS_INHIBIT_CRC      (1 << 12)
228#define CS8900_TX_CMD_STATUS_TX_PAD_DISABLED  (1 << 13)
229
230/*
231 * Reg B. Buffer Configuration.
232 */
233
234#define CS8900_BUFFER_CONFIG_SW_INT           (1 << 6)
235#define CS8900_BUFFER_CONFIG_RX_DMA_DONE      (1 << 7)
236#define CS8900_BUFFER_CONFIG_RDY_FOR_TX       (1 << 8)
237#define CS8900_BUFFER_CONFIG_TX_UNDERRUN      (1 << 9)
238#define CS8900_BUFFER_CONFIG_RX_MISSED        (1 << 10)
239#define CS8900_BUFFER_CONFIG_RX_128_BYTES     (1 << 11)
240#define CS8900_BUFFER_CONFIG_TX_COL_OVF       (1 << 12)
241#define CS8900_BUFFER_CONFIG_RX_MISSED_OVF    (1 << 13)
242#define CS8900_BUFFER_CONFIG_RX_DEST_MATCH    (1 << 15)
243
244/*
245 * Reg C. Buffer Event.
246 */
247
248#define CS8900_BUFFER_EVENT_SW_INT            (1 << 6)
249#define CS8900_BUFFER_EVENT_RX_DMA_DONE       (1 << 7)
250#define CS8900_BUFFER_EVENT_RDY_FOR_TX        (1 << 8)
251#define CS8900_BUFFER_EVENT_TX_UNDERRUN       (1 << 9)
252#define CS8900_BUFFER_EVENT_RX_MISSED         (1 << 10)
253#define CS8900_BUFFER_EVENT_RX_128_BYTES      (1 << 11)
254#define CS8900_BUFFER_EVENT_RX_DEST_MATCH     (1 << 15)
255
256/*
257 * Reg 13. Line Control.
258 */
259
260#define CS8900_LINE_CTRL_RX_ON               (1 << 6)
261#define CS8900_LINE_CTRL_TX_ON               (1 << 7)
262#define CS8900_LINE_CTRL_AUI                 (1 << 8)
263#define CS8900_LINE_CTRL_10BASET             (0 << 9)
264#define CS8900_LINE_CTRL_AUTO_AUI_10BASET    (1 << 9)
265#define CS8900_LINE_CTRL_MOD_BACKOFF         (1 << 11)
266#define CS8900_LINE_CTRL_POLARITY_DISABLED   (1 << 12)
267#define CS8900_LINE_CTRL_2_PART_DEF_DISABLED (1 << 13)
268#define CS8900_LINE_CTRL_LO_RX_SQUELCH       (1 << 14)
269
270/*
271 * Reg 14. Line Status.
272 */
273
274#define CS8900_LINE_STATUS_LINK_OK           (1 << 7)
275#define CS8900_LINE_STATUS_AUI               (1 << 8)
276#define CS8900_LINE_STATUS_10_BASE_T         (1 << 9)
277#define CS8900_LINE_STATUS_POLARITY_OK       (1 << 12)
278#define CS8900_LINE_STATUS_CRS               (1 << 14)
279
280/*
281 * Reg 15. Self Control.
282 */
283
284#define CS8900_SELF_CTRL_RESET              (1 << 6)
285#define CS8900_SELF_CTRL_SW_SUSPEND         (1 << 8)
286#define CS8900_SELF_CTRL_HW_SLEEP           (1 << 9)
287#define CS8900_SELF_CTRL_HW_STANDBY         (1 << 10)
288#define CS8900_SELF_CTRL_HC0E               (1 << 12)
289#define CS8900_SELF_CTRL_HC1E               (1 << 13)
290#define CS8900_SELF_CTRL_HCB0               (1 << 14)
291#define CS8900_SELF_CTRL_HCB1               (1 << 15)
292
293/*
294 * Reg 16. Self Status.
295 */
296
297#define CS8900_SELF_STATUS_3_3_V            (1 << 6)
298#define CS8900_SELF_STATUS_INITD            (1 << 7)
299#define CS8900_SELF_STATUS_SIBUST           (1 << 8)
300#define CS8900_SELF_STATUS_EEPROM_PRESENT   (1 << 9) 
301#define CS8900_SELF_STATUS_EEPROM_OK        (1 << 10)
302#define CS8900_SELF_STATUS_EL_PRESENT       (1 << 11)
303#define CS8900_SELF_STATUS_EE_SIZE          (1 << 12)
304
305/*
306 * Reg 17. Bus Control.
307 */
308
309#define CS8900_BUS_CTRL_RESET_RX_DMA        (1 << 6)
310#define CS8900_BUS_CTRL_USE_SA              (1 << 9)
311#define CS8900_BUS_CTRL_MEMORY_ENABLE       (1 << 10)
312#define CS8900_BUS_CTRL_DMA_BURST           (1 << 11)
313#define CS8900_BUS_CTRL_IOCHRDYE            (1 << 12)
314#define CS8900_BUS_CTRL_RX_DMA_SIZE         (1 << 13)
315#define CS8900_BUS_CTRL_ENABLE_INT          (1 << 15)
316
317/*
318 * Reg 18. Bus Status.
319 */
320
321#define CS8900_BUS_STATUS_TX_BID_ERROR      (1 << 7)
322#define CS8900_BUS_STATUS_RDY_FOR_TX_NOW    (1 << 8)
323
324/*
325 * Trace for debugging the isq processing. Define to 1 to enable.
326 */
327#define CS8900_TRACE      0
328#define CS8900_TRACE_SIZE (400)
329
330/*
331 * Stats, more for debugging than anything else.
332 */
333
334typedef struct
335{
336  unsigned long rx_packets;     /* total packets received         */
337  unsigned long tx_packets;     /* total packets transmitted      */
338  unsigned long rx_bytes;       /* total bytes received           */
339  unsigned long tx_bytes;       /* total bytes transmitted        */
340  unsigned long rx_interrupts;  /* total number of rx interrupts  */
341  unsigned long tx_interrupts;  /* total number of tx interrupts  */
342
343  /* detailed rx errors: */
344  unsigned long rx_dropped;     /* no mbufs in queue              */
345  unsigned long rx_no_mbufs;    /* no mbufs                       */
346  unsigned long rx_no_clusters; /* no clusters                    */
347  unsigned long rx_oversize_errors;
348  unsigned long rx_crc_errors;    /* recved pkt with crc error    */
349  unsigned long rx_runt_errors;
350  unsigned long rx_missed_errors; /* receiver missed packet       */
351
352  /* detailed tx errors */
353  unsigned long tx_ok;
354  unsigned long tx_collisions;
355  unsigned long tx_bid_errors;
356  unsigned long tx_wait_for_rdy4tx;
357  unsigned long tx_rdy4tx;
358  unsigned long tx_underrun_errors;
359  unsigned long tx_dropped;
360  unsigned long tx_resends;
361 
362  /* interrupt watch dog */
363  unsigned long int_swint_req;
364  unsigned long int_swint_res;
365  unsigned long int_lockup;
366 
367  unsigned long interrupts;
368
369} eth_statistics;
370
371/*
372 * CS8900 device structure
373 */
374
375typedef struct
376{
377  /*
378   * Device number.
379   */
380
381  int dev;
382
383  /*
384   * The bsdnet information structure. 
385   */
386
387  struct arpcom  arpcom;
388
389  /*
390   * Driver state and resources.
391   */
392
393  int            accept_bcast;
394  int            tx_active;
395 
396  rtems_id       rx_task;
397  rtems_id       tx_task;
398
399  /*
400   * The queues. FIXME : these should be changed to be mbuf lists.
401   */
402  struct mbuf    *rx_ready_head;
403  struct mbuf    *rx_ready_tail;
404  int            rx_ready_len;
405 
406  struct mbuf    *rx_loaded_head;
407  struct mbuf    *rx_loaded_tail;
408  int            rx_loaded_len;
409
410#if CS8900_TRACE
411  unsigned short trace_key[CS8900_TRACE_SIZE];
412  unsigned long  trace_var[CS8900_TRACE_SIZE];
413  unsigned long  trace_time[CS8900_TRACE_SIZE];
414  int            trace_in;
415#endif
416
417  /*
418   * Standard(!) ethernet statistics
419   */
420
421  eth_statistics eth_stats;
422 
423} cs8900_device;
424
425/*
426 * Link is active, and RX count.
427 */
428
429int           cs8900_link_active (int dev);
430int           cs8900_driver_attach (struct rtems_bsdnet_ifconfig *config,
431                                    int                          attaching);
432rtems_isr     cs8900_interrupt (rtems_vector_number v, void *cs);
433
434/*
435 * Functions Users Provide to implement the driver.
436 */
437
438void           cs8900_attach_interrupt (int dev, cs8900_device *cs);
439void           cs8900_detach_interrupt (int dev);
440void           cs8900_get_mac_addr (int dev, unsigned char *mac_address);
441void           cs8900_io_set_reg (int dev, unsigned short reg, unsigned short data);
442unsigned short cs8900_io_get_reg (int dev, unsigned short reg);
443void           cs8900_mem_set_reg (int dev, unsigned long reg, unsigned short data);
444unsigned short cs8900_mem_get_reg (int dev, unsigned long reg);
445void           cs8900_put_data_block (int dev, int len, unsigned char *data);
446unsigned short cs8900_get_data_block (int dev, unsigned char *data);
447void           cs8900_tx_load (int dev, struct mbuf *m);
448
449#endif
Note: See TracBrowser for help on using the repository browser.