ether1.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*
  2. * linux/drivers/acorn/net/ether1.h
  3. *
  4. * Copyright (C) 1996 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Network driver for Acorn Ether1 cards.
  11. */
  12. #ifndef _LINUX_ether1_H
  13. #define _LINUX_ether1_H
  14. #ifdef __ETHER1_C
  15. /* use 0 for production, 1 for verification, >2 for debug */
  16. #ifndef NET_DEBUG
  17. #define NET_DEBUG 0
  18. #endif
  19. #define priv(dev) ((struct ether1_priv *)netdev_priv(dev))
  20. /* Page register */
  21. #define REG_PAGE (priv(dev)->base + 0x0000)
  22. /* Control register */
  23. #define REG_CONTROL (priv(dev)->base + 0x0004)
  24. #define CTRL_RST 0x01
  25. #define CTRL_LOOPBACK 0x02
  26. #define CTRL_CA 0x04
  27. #define CTRL_ACK 0x08
  28. #define ETHER1_RAM (priv(dev)->base + 0x2000)
  29. /* HW address */
  30. #define IDPROM_ADDRESS (priv(dev)->base + 0x0024)
  31. struct ether1_priv {
  32. void __iomem *base;
  33. unsigned int tx_link;
  34. unsigned int tx_head;
  35. volatile unsigned int tx_tail;
  36. volatile unsigned int rx_head;
  37. volatile unsigned int rx_tail;
  38. unsigned char bus_type;
  39. unsigned char resetting;
  40. unsigned char initialising : 1;
  41. unsigned char restart : 1;
  42. };
  43. #define I82586_NULL (-1)
  44. typedef struct { /* tdr */
  45. unsigned short tdr_status;
  46. unsigned short tdr_command;
  47. unsigned short tdr_link;
  48. unsigned short tdr_result;
  49. #define TDR_TIME (0x7ff)
  50. #define TDR_SHORT (1 << 12)
  51. #define TDR_OPEN (1 << 13)
  52. #define TDR_XCVRPROB (1 << 14)
  53. #define TDR_LNKOK (1 << 15)
  54. } tdr_t;
  55. typedef struct { /* transmit */
  56. unsigned short tx_status;
  57. unsigned short tx_command;
  58. unsigned short tx_link;
  59. unsigned short tx_tbdoffset;
  60. } tx_t;
  61. typedef struct { /* tbd */
  62. unsigned short tbd_opts;
  63. #define TBD_CNT (0x3fff)
  64. #define TBD_EOL (1 << 15)
  65. unsigned short tbd_link;
  66. unsigned short tbd_bufl;
  67. unsigned short tbd_bufh;
  68. } tbd_t;
  69. typedef struct { /* rfd */
  70. unsigned short rfd_status;
  71. #define RFD_NOEOF (1 << 6)
  72. #define RFD_FRAMESHORT (1 << 7)
  73. #define RFD_DMAOVRN (1 << 8)
  74. #define RFD_NORESOURCES (1 << 9)
  75. #define RFD_ALIGNERROR (1 << 10)
  76. #define RFD_CRCERROR (1 << 11)
  77. #define RFD_OK (1 << 13)
  78. #define RFD_FDCONSUMED (1 << 14)
  79. #define RFD_COMPLETE (1 << 15)
  80. unsigned short rfd_command;
  81. #define RFD_CMDSUSPEND (1 << 14)
  82. #define RFD_CMDEL (1 << 15)
  83. unsigned short rfd_link;
  84. unsigned short rfd_rbdoffset;
  85. unsigned char rfd_dest[6];
  86. unsigned char rfd_src[6];
  87. unsigned short rfd_len;
  88. } rfd_t;
  89. typedef struct { /* rbd */
  90. unsigned short rbd_status;
  91. #define RBD_ACNT (0x3fff)
  92. #define RBD_ACNTVALID (1 << 14)
  93. #define RBD_EOF (1 << 15)
  94. unsigned short rbd_link;
  95. unsigned short rbd_bufl;
  96. unsigned short rbd_bufh;
  97. unsigned short rbd_len;
  98. } rbd_t;
  99. typedef struct { /* nop */
  100. unsigned short nop_status;
  101. unsigned short nop_command;
  102. unsigned short nop_link;
  103. } nop_t;
  104. typedef struct { /* set multicast */
  105. unsigned short mc_status;
  106. unsigned short mc_command;
  107. unsigned short mc_link;
  108. unsigned short mc_cnt;
  109. unsigned char mc_addrs[1][6];
  110. } mc_t;
  111. typedef struct { /* set address */
  112. unsigned short sa_status;
  113. unsigned short sa_command;
  114. unsigned short sa_link;
  115. unsigned char sa_addr[6];
  116. } sa_t;
  117. typedef struct { /* config command */
  118. unsigned short cfg_status;
  119. unsigned short cfg_command;
  120. unsigned short cfg_link;
  121. unsigned char cfg_bytecnt; /* size foll data: 4 - 12 */
  122. unsigned char cfg_fifolim; /* FIFO threshold */
  123. unsigned char cfg_byte8;
  124. #define CFG8_SRDY (1 << 6)
  125. #define CFG8_SAVEBADF (1 << 7)
  126. unsigned char cfg_byte9;
  127. #define CFG9_ADDRLEN(x) (x)
  128. #define CFG9_ADDRLENBUF (1 << 3)
  129. #define CFG9_PREAMB2 (0 << 4)
  130. #define CFG9_PREAMB4 (1 << 4)
  131. #define CFG9_PREAMB8 (2 << 4)
  132. #define CFG9_PREAMB16 (3 << 4)
  133. #define CFG9_ILOOPBACK (1 << 6)
  134. #define CFG9_ELOOPBACK (1 << 7)
  135. unsigned char cfg_byte10;
  136. #define CFG10_LINPRI(x) (x)
  137. #define CFG10_ACR(x) (x << 4)
  138. #define CFG10_BOFMET (1 << 7)
  139. unsigned char cfg_ifs;
  140. unsigned char cfg_slotl;
  141. unsigned char cfg_byte13;
  142. #define CFG13_SLOTH(x) (x)
  143. #define CFG13_RETRY(x) (x << 4)
  144. unsigned char cfg_byte14;
  145. #define CFG14_PROMISC (1 << 0)
  146. #define CFG14_DISBRD (1 << 1)
  147. #define CFG14_MANCH (1 << 2)
  148. #define CFG14_TNCRS (1 << 3)
  149. #define CFG14_NOCRC (1 << 4)
  150. #define CFG14_CRC16 (1 << 5)
  151. #define CFG14_BTSTF (1 << 6)
  152. #define CFG14_FLGPAD (1 << 7)
  153. unsigned char cfg_byte15;
  154. #define CFG15_CSTF(x) (x)
  155. #define CFG15_ICSS (1 << 3)
  156. #define CFG15_CDTF(x) (x << 4)
  157. #define CFG15_ICDS (1 << 7)
  158. unsigned short cfg_minfrmlen;
  159. } cfg_t;
  160. typedef struct { /* scb */
  161. unsigned short scb_status; /* status of 82586 */
  162. #define SCB_STRXMASK (7 << 4) /* Receive unit status */
  163. #define SCB_STRXIDLE (0 << 4) /* Idle */
  164. #define SCB_STRXSUSP (1 << 4) /* Suspended */
  165. #define SCB_STRXNRES (2 << 4) /* No resources */
  166. #define SCB_STRXRDY (4 << 4) /* Ready */
  167. #define SCB_STCUMASK (7 << 8) /* Command unit status */
  168. #define SCB_STCUIDLE (0 << 8) /* Idle */
  169. #define SCB_STCUSUSP (1 << 8) /* Suspended */
  170. #define SCB_STCUACTV (2 << 8) /* Active */
  171. #define SCB_STRNR (1 << 12) /* Receive unit not ready */
  172. #define SCB_STCNA (1 << 13) /* Command unit not ready */
  173. #define SCB_STFR (1 << 14) /* Frame received */
  174. #define SCB_STCX (1 << 15) /* Command completed */
  175. unsigned short scb_command; /* Next command */
  176. #define SCB_CMDRXSTART (1 << 4) /* Start (at rfa_offset) */
  177. #define SCB_CMDRXRESUME (2 << 4) /* Resume reception */
  178. #define SCB_CMDRXSUSPEND (3 << 4) /* Suspend reception */
  179. #define SCB_CMDRXABORT (4 << 4) /* Abort reception */
  180. #define SCB_CMDCUCSTART (1 << 8) /* Start (at cbl_offset) */
  181. #define SCB_CMDCUCRESUME (2 << 8) /* Resume execution */
  182. #define SCB_CMDCUCSUSPEND (3 << 8) /* Suspend execution */
  183. #define SCB_CMDCUCABORT (4 << 8) /* Abort execution */
  184. #define SCB_CMDACKRNR (1 << 12) /* Ack RU not ready */
  185. #define SCB_CMDACKCNA (1 << 13) /* Ack CU not ready */
  186. #define SCB_CMDACKFR (1 << 14) /* Ack Frame received */
  187. #define SCB_CMDACKCX (1 << 15) /* Ack Command complete */
  188. unsigned short scb_cbl_offset; /* Offset of first command unit */
  189. unsigned short scb_rfa_offset; /* Offset of first receive frame area */
  190. unsigned short scb_crc_errors; /* Properly aligned frame with CRC error*/
  191. unsigned short scb_aln_errors; /* Misaligned frames */
  192. unsigned short scb_rsc_errors; /* Frames lost due to no space */
  193. unsigned short scb_ovn_errors; /* Frames lost due to slow bus */
  194. } scb_t;
  195. typedef struct { /* iscp */
  196. unsigned short iscp_busy; /* set by CPU before CA */
  197. unsigned short iscp_offset; /* offset of SCB */
  198. unsigned short iscp_basel; /* base of SCB */
  199. unsigned short iscp_baseh;
  200. } iscp_t;
  201. /* this address must be 0xfff6 */
  202. typedef struct { /* scp */
  203. unsigned short scp_sysbus; /* bus size */
  204. #define SCP_SY_16BBUS 0x00
  205. #define SCP_SY_8BBUS 0x01
  206. unsigned short scp_junk[2]; /* junk */
  207. unsigned short scp_iscpl; /* lower 16 bits of iscp */
  208. unsigned short scp_iscph; /* upper 16 bits of iscp */
  209. } scp_t;
  210. /* commands */
  211. #define CMD_NOP 0
  212. #define CMD_SETADDRESS 1
  213. #define CMD_CONFIG 2
  214. #define CMD_SETMULTICAST 3
  215. #define CMD_TX 4
  216. #define CMD_TDR 5
  217. #define CMD_DUMP 6
  218. #define CMD_DIAGNOSE 7
  219. #define CMD_MASK 7
  220. #define CMD_INTR (1 << 13)
  221. #define CMD_SUSP (1 << 14)
  222. #define CMD_EOL (1 << 15)
  223. #define STAT_COLLISIONS (15)
  224. #define STAT_COLLEXCESSIVE (1 << 5)
  225. #define STAT_COLLAFTERTX (1 << 6)
  226. #define STAT_TXDEFERRED (1 << 7)
  227. #define STAT_TXSLOWDMA (1 << 8)
  228. #define STAT_TXLOSTCTS (1 << 9)
  229. #define STAT_NOCARRIER (1 << 10)
  230. #define STAT_FAIL (1 << 11)
  231. #define STAT_ABORTED (1 << 12)
  232. #define STAT_OK (1 << 13)
  233. #define STAT_BUSY (1 << 14)
  234. #define STAT_COMPLETE (1 << 15)
  235. #endif
  236. #endif
  237. /*
  238. * Ether1 card definitions:
  239. *
  240. * FAST accesses:
  241. * +0 Page register
  242. * 16 pages
  243. * +4 Control
  244. * '1' = reset
  245. * '2' = loopback
  246. * '4' = CA
  247. * '8' = int ack
  248. *
  249. * RAM at address + 0x2000
  250. * Pod. Prod id = 3
  251. * Words after ID block [base + 8 words]
  252. * +0 pcb issue (0x0c and 0xf3 invalid)
  253. * +1 - +6 eth hw address
  254. */