ether1.h 7.6 KB

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