xref: /minix3/minix/drivers/net/dec21140A/dec21140A.h (revision f7df02e7476731c31f12548e38bcadbaf0233f6a)
1433d6423SLionel Sambuc #ifndef INCL_DEC21041_H_GUARD
2433d6423SLionel Sambuc #define INCL_DEC21041_H_GUARD
3433d6423SLionel Sambuc /*
4433d6423SLionel Sambuc de.h
5433d6423SLionel Sambuc 
6433d6423SLionel Sambuc Header for the driver of the DEC 21140A ethernet card as emulated
7433d6423SLionel Sambuc by VirtualPC 2007
8433d6423SLionel Sambuc 
9433d6423SLionel Sambuc Created: 09/01/2009   Nicolas Tittley (first.last @ gmail DOT com)
10433d6423SLionel Sambuc */
11433d6423SLionel Sambuc 
12433d6423SLionel Sambuc #include <sys/null.h>
13433d6423SLionel Sambuc 
14433d6423SLionel Sambuc #if debug == 1
15433d6423SLionel Sambuc #	define DEBUG(statm) statm
16433d6423SLionel Sambuc #else
17433d6423SLionel Sambuc #	define DEBUG(statm)
18433d6423SLionel Sambuc #endif
19433d6423SLionel Sambuc 
20433d6423SLionel Sambuc #define DE_NB_SEND_DESCR    32
21*f7df02e7SDavid van Moolenbroek #define DE_SEND_BUF_SIZE    (NDEV_ETH_PACKET_MAX+2)
22433d6423SLionel Sambuc #define DE_NB_RECV_DESCR    32
23*f7df02e7SDavid van Moolenbroek #define DE_RECV_BUF_SIZE    (NDEV_ETH_PACKET_MAX+2)
2429018b4eSDavid van Moolenbroek 
25433d6423SLionel Sambuc #define DE_MIN_BASE_ADDR    0x0400
26433d6423SLionel Sambuc #define DE_SROM_EA_OFFSET   20
27433d6423SLionel Sambuc #define DE_SETUP_FRAME_SIZE 192
28433d6423SLionel Sambuc 
29433d6423SLionel Sambuc typedef struct de_descr {
30433d6423SLionel Sambuc   u32_t des[4];
31433d6423SLionel Sambuc } de_descr_t;
32433d6423SLionel Sambuc 
33433d6423SLionel Sambuc typedef struct de_local_descr {
34433d6423SLionel Sambuc   de_descr_t *descr;
35433d6423SLionel Sambuc   u8_t *buf1;
36433d6423SLionel Sambuc   u8_t *buf2;
37433d6423SLionel Sambuc } de_loc_descr_t;
38433d6423SLionel Sambuc 
39433d6423SLionel Sambuc typedef struct dpeth {
40433d6423SLionel Sambuc   port_t de_base_port;          /* Base port, for multiple card instance */
41433d6423SLionel Sambuc   int de_irq;                   /* IRQ line number */
42433d6423SLionel Sambuc   int de_hook;			/* interrupt hook at kernel */
43433d6423SLionel Sambuc 
44433d6423SLionel Sambuc   int de_type;			/* What kind of hardware */
45433d6423SLionel Sambuc 
46433d6423SLionel Sambuc   /* Space reservation. We will allocate all structures later in the code.
47433d6423SLionel Sambuc      here we just make sure we have the space we need at compile time */
48433d6423SLionel Sambuc   u8_t sendrecv_descr_buf[(DE_NB_SEND_DESCR+DE_NB_RECV_DESCR)*
49433d6423SLionel Sambuc 			  sizeof(de_descr_t)];
50433d6423SLionel Sambuc   u8_t sendrecv_buf[DE_NB_SEND_DESCR*DE_SEND_BUF_SIZE +
51433d6423SLionel Sambuc 		    DE_NB_RECV_DESCR*DE_RECV_BUF_SIZE];
52433d6423SLionel Sambuc   phys_bytes sendrecv_descr_phys_addr[2];
53433d6423SLionel Sambuc   de_loc_descr_t descr[2][MAX(DE_NB_RECV_DESCR, DE_NB_SEND_DESCR)];
54433d6423SLionel Sambuc   int cur_descr[2];
55433d6423SLionel Sambuc 
56433d6423SLionel Sambuc #define DESCR_RECV 0
57433d6423SLionel Sambuc #define DESCR_TRAN 1
58433d6423SLionel Sambuc 
59433d6423SLionel Sambuc   /* Serial ROM */
60433d6423SLionel Sambuc #define SROM_BITWIDTH 6
61433d6423SLionel Sambuc 
62433d6423SLionel Sambuc   u8_t srom[((1<<SROM_BITWIDTH)-1)*2];    /* Space to read in
63433d6423SLionel Sambuc 					     all the configuration ROM */
64433d6423SLionel Sambuc } dpeth_t;
65433d6423SLionel Sambuc 
66433d6423SLionel Sambuc 
67433d6423SLionel Sambuc /************/
68433d6423SLionel Sambuc /* Revisons */
69433d6423SLionel Sambuc /************/
70433d6423SLionel Sambuc 
71433d6423SLionel Sambuc #define DEC_21140A 0x20
72433d6423SLionel Sambuc #define DE_TYPE_UNKNOWN 0x0
73433d6423SLionel Sambuc /* #define CSR_ADDR(x, i) csraddr2(x->de_base_port + i) */
74433d6423SLionel Sambuc #define CSR_ADDR(x, i) (x->de_base_port + i)
75433d6423SLionel Sambuc 
76433d6423SLionel Sambuc /* CSRs */
77433d6423SLionel Sambuc #define CSR0 0x00
78433d6423SLionel Sambuc #define     CSR0_SWR   0x00000001 /* sw reset */
79433d6423SLionel Sambuc #define     CSR0_BAR   0x00000002 /* bus arbitration */
80433d6423SLionel Sambuc #define     CSR0_CAL_8 0x00004000 /* cache align 8 long word */
81433d6423SLionel Sambuc #define     CSR0_TAP   0x00080000 /* trans auto polling */
82433d6423SLionel Sambuc #define CSR1 0x08 /* transmit poll demand */
83433d6423SLionel Sambuc #define CSR2 0x10 /* receive poll demand */
84433d6423SLionel Sambuc #define CSR3 0x18 /* receive list address */
85433d6423SLionel Sambuc #define CSR4 0x20 /* transmit list address */
86433d6423SLionel Sambuc #define CSR5 0x28              /* status register */
87433d6423SLionel Sambuc #define     CSR5_EB  0x03800000 /* error bits */
88433d6423SLionel Sambuc #define     CSR5_TS  0x00700000 /* Transmit proc state */
89433d6423SLionel Sambuc #define     CSR5_RS  0x000E0000 /* Receive proc state */
90433d6423SLionel Sambuc #define     CSR5_NIS 0x00010000 /* Norm Int summ */
91433d6423SLionel Sambuc #define     CSR5_AIS 0x00008000 /* Abnorm Int sum */
92433d6423SLionel Sambuc #define     CSR5_FBE 0x00002000 /* Fatal bit error */
93433d6423SLionel Sambuc #define     CSR5_GTE 0x00000800 /* Gen-purp timer exp */
94433d6423SLionel Sambuc #define     CSR5_ETI 0x00000400 /* Early Trans int */
95433d6423SLionel Sambuc #define     CSR5_RWT 0x00000200 /* Recv watchdog timeout */
96433d6423SLionel Sambuc #define     CSR5_RPS 0x00000100 /* Recv proc stop */
97433d6423SLionel Sambuc #define     CSR5_RU  0x00000080 /* Recv buf unavail */
98433d6423SLionel Sambuc #define     CSR5_RI  0x00000040 /* Recv interrupt */
99433d6423SLionel Sambuc #define     CSR5_UNF 0x00000020 /* Trans underflow */
100433d6423SLionel Sambuc #define     CSR5_TJT 0x00000008 /* Trans Jabber Timeout */
101433d6423SLionel Sambuc #define     CSR5_TU  0x00000004 /* Trans buf unavail */
102433d6423SLionel Sambuc #define     CSR5_TPS 0x00000002 /* Trans proc stopped */
103433d6423SLionel Sambuc #define     CSR5_TI  0x00000001 /* Trans interrupt */
104433d6423SLionel Sambuc #define CSR6 0x30 /* Operation mode */
105433d6423SLionel Sambuc #define     CSR6_SC  0x80000000 /* Special capt effect ena 31 */
106433d6423SLionel Sambuc #define     CSR6_RA  0x40000000 /* receive all 30 */
107433d6423SLionel Sambuc #define     CSR6_MBO 0x02000000 /* must be one 25 */
108433d6423SLionel Sambuc #define     CSR6_SCR 0x01000000 /* Scrambler mode 24 */
109433d6423SLionel Sambuc #define     CSR6_PCS 0x00800000 /* PCS function 23 */
110433d6423SLionel Sambuc #define     CSR6_TTM 0x00400000 /* Trans threshold mode 22 */
111433d6423SLionel Sambuc #define     CSR6_SF  0x00200000 /* store and forward 21 */
112433d6423SLionel Sambuc #define     CSR6_HBD 0x00080000 /* Heartbeat disable 19 */
113433d6423SLionel Sambuc #define     CSR6_PS  0x00040000 /* port select 18 */
114433d6423SLionel Sambuc #define     CSR6_CA  0x00020000 /* Capt effect ena 17 */
115433d6423SLionel Sambuc #define     CSR6_TR_00 0x00000000 /* Trans thresh 15:14 */
116433d6423SLionel Sambuc #define     CSR6_TR_01 0x00004000 /* Trans thresh 15:14 */
117433d6423SLionel Sambuc #define     CSR6_TR_10 0x00008000 /* Trans thresh 15:14 */
118433d6423SLionel Sambuc #define     CSR6_TR_11 0x0000C000 /* Trans thresh 15:14 */
119433d6423SLionel Sambuc #define     CSR6_ST  0x00002000 /* start/stop trans 13 */
120433d6423SLionel Sambuc #define     CSR6_FD  0x00000200 /* Full Duplex 9 */
121433d6423SLionel Sambuc #define     CSR6_PM  0x00000080 /* Pass all multicast 7 */
122433d6423SLionel Sambuc #define     CSR6_PR  0x00000040 /* Promisc mode 6 */
123433d6423SLionel Sambuc #define     CSR6_IF  0x00000010 /* Inv filtering 4 */
124433d6423SLionel Sambuc #define     CSR6_HO  0x00000004 /* Hash-only filtering 2 */
125433d6423SLionel Sambuc #define     CSR6_SR  0x00000002 /* start/stop recv 1 */
126433d6423SLionel Sambuc #define     CSR6_HP  0x00000001 /* Hash/perfect recv filt mode 0 */
127433d6423SLionel Sambuc #define CSR7 0x38 /* Interrupt enable */
128433d6423SLionel Sambuc #define     CSR7_NI  0x00010000 /* Normal interrupt ena */
129433d6423SLionel Sambuc #define     CSR7_AI  0x00008000 /* Abnormal int ena */
130433d6423SLionel Sambuc #define     CSR7_TI  0x00000001 /* trans int ena */
131433d6423SLionel Sambuc #define     CSR7_TU  0x00000004 /* trans buf unavail ena */
132433d6423SLionel Sambuc #define     CSR7_RI  0x00000040 /* recv interp ena */
133433d6423SLionel Sambuc #define     CSR7_GPT 0x00000800 /* gen purpose timer ena */
134433d6423SLionel Sambuc #define CSR9 0x48 /* Boot Rom, serial ROM, MII */
135433d6423SLionel Sambuc #define     CSR9_SR  0x0800 /* serial ROM select */
136433d6423SLionel Sambuc #define     CSR9_RD  0x4000 /* read */
137433d6423SLionel Sambuc #define     CSR9_DO  0x0008 /* data out */
138433d6423SLionel Sambuc #define     CSR9_DI  0x0004 /* data in */
139433d6423SLionel Sambuc #define     CSR9_SRC 0x0002 /* serial clock */
140433d6423SLionel Sambuc #define     CSR9_CS  0x0001 /* serial rom chip select */
141433d6423SLionel Sambuc /* Send/Recv Descriptors */
142433d6423SLionel Sambuc 
143433d6423SLionel Sambuc #define DES0 0
144433d6423SLionel Sambuc #define  DES0_OWN 0x80000000 /* descr ownership. 1=211140A */
145433d6423SLionel Sambuc #define  DES0_FL  0x3FFF0000 /* frame length */
146433d6423SLionel Sambuc #define   DES0_FL_SHIFT 16   /* shift to fix frame length */
147433d6423SLionel Sambuc #define   DES0_ES 0x00008000 /* Error sum */
148433d6423SLionel Sambuc #define   DES0_TO 0x00004000 /* Trans jabber timeout */
149433d6423SLionel Sambuc #define   DES0_LO 0x00000800 /* Loss of carrier */
150433d6423SLionel Sambuc #define   DES0_NC 0x00000400 /* no carrier */
151433d6423SLionel Sambuc #define   DES0_LC 0x00000200 /* Late coll */
152433d6423SLionel Sambuc #define   DES0_EC 0x00000100 /* Excessive coll */
153433d6423SLionel Sambuc #define   DES0_UF 0x00000002 /* Underflow error */
154433d6423SLionel Sambuc #define   DES0_RE 0x00000008 /* MII error */
155433d6423SLionel Sambuc #define   DES0_FS 0x00000200 /* first descr */
156433d6423SLionel Sambuc #define   DES0_LS 0x00000100 /* last descr */
157433d6423SLionel Sambuc #define DES1 1
158433d6423SLionel Sambuc #define  DES1_ER  0x02000000 /* end of ring */
159433d6423SLionel Sambuc #define  DES1_SAC 0x01000000 /* 2nd address chained */
160433d6423SLionel Sambuc #define  DES1_BS2 0x003FF800 /* 2nd buffer size */
161433d6423SLionel Sambuc #define  DES1_BS2_SHFT 11    /* shift to obtain 2nd buffer size */
162433d6423SLionel Sambuc #define  DES1_BS1 0x000007FF /* 1nd buffer size */
163433d6423SLionel Sambuc #define  DES1_IC  0x80000000 /* Interrupt on completion 31 */
164433d6423SLionel Sambuc #define  DES1_LS  0x40000000 /* Last Segment 30 */
165433d6423SLionel Sambuc #define  DES1_FS  0x20000000 /* First Segment 29 */
166433d6423SLionel Sambuc #define  DES1_FT1 0x10000000 /* Filtering type 28 */
167433d6423SLionel Sambuc #define  DES1_SET 0x08000000 /* Setup frame 27 */
168433d6423SLionel Sambuc #define  DES1_AC  0x04000000 /* Add CRC disable 26 */
169433d6423SLionel Sambuc #define  DES1_DPD 0x00800000 /* Disabled padding 23 */
170433d6423SLionel Sambuc #define  DES1_FT0 0x00400000 /* Filtering type 22 */
171433d6423SLionel Sambuc #define DES2 2 /* 1st buffer addr */
172433d6423SLionel Sambuc #define DES3 3 /* 2nd buffer addr */
173433d6423SLionel Sambuc 
174433d6423SLionel Sambuc #define DES_BUF1 DES2
175433d6423SLionel Sambuc #define DES_BUF2 DES3
176433d6423SLionel Sambuc 
177433d6423SLionel Sambuc #endif /* Include Guard */
178