saa9730.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. /*
  2. * Carsten Langgaard, carstenl@mips.com
  3. * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
  4. *
  5. * ########################################################################
  6. *
  7. * This program is free software; you can distribute it and/or modify it
  8. * under the terms of the GNU General Public License (Version 2) as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14. * for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  19. *
  20. * ########################################################################
  21. *
  22. * SAA9730 ethernet driver description.
  23. *
  24. */
  25. #ifndef _SAA9730_H
  26. #define _SAA9730_H
  27. /* Number of 6-byte entries in the CAM. */
  28. #define LAN_SAA9730_CAM_ENTRIES 10
  29. #define LAN_SAA9730_CAM_DWORDS ((LAN_SAA9730_CAM_ENTRIES*6)/4)
  30. /* TX and RX packet size: fixed to 2048 bytes, according to HW requirements. */
  31. #define LAN_SAA9730_PACKET_SIZE 2048
  32. /*
  33. * Number of TX buffers = number of RX buffers = 2, which is fixed according
  34. * to HW requirements.
  35. */
  36. #define LAN_SAA9730_BUFFERS 2
  37. /* Number of RX packets per RX buffer. */
  38. #define LAN_SAA9730_RCV_Q_SIZE 15
  39. /* Number of TX packets per TX buffer. */
  40. #define LAN_SAA9730_TXM_Q_SIZE 15
  41. /*
  42. * We get an interrupt for each LAN_SAA9730_DEFAULT_RCV_Q_INT_THRESHOLD
  43. * packets received.
  44. * If however we receive less than LAN_SAA9730_DEFAULT_RCV_Q_INT_THRESHOLD
  45. * packets, the hardware can timeout after a certain time and still tell
  46. * us packets have arrived.
  47. * The timeout value in unit of 32 PCI clocks (33Mhz).
  48. * The value 200 approximates 0.0002 seconds.
  49. */
  50. #define LAN_SAA9730_RCV_Q_INT_THRESHOLD 1
  51. #define LAN_SAA9730_DEFAULT_TIME_OUT_CNT 10
  52. #define RXSF_NDIS 0
  53. #define RXSF_READY 2
  54. #define RXSF_HWDONE 3
  55. #define TXSF_EMPTY 0
  56. #define TXSF_READY 2
  57. #define TXSF_HWDONE 3
  58. #define LANEND_LITTLE 0
  59. #define LANEND_BIG_2143 1
  60. #define LANEND_BIG_4321 2
  61. #define LANMB_ANY 0
  62. #define LANMB_8 1
  63. #define LANMB_32 2
  64. #define LANMB_64 3
  65. #define MACCM_AUTOMATIC 0
  66. #define MACCM_10MB 1
  67. #define MACCM_MII 2
  68. /*
  69. * PHY definitions for Basic registers of QS6612 (used on MIPS ATLAS board)
  70. */
  71. #define PHY_CONTROL 0x0
  72. #define PHY_STATUS 0x1
  73. #define PHY_STATUS_LINK_UP 0x4
  74. #define PHY_CONTROL_RESET 0x8000
  75. #define PHY_CONTROL_AUTO_NEG 0x1000
  76. #define PHY_CONTROL_RESTART_AUTO_NEG 0x0200
  77. #define PHY_ADDRESS 0x0
  78. /* PK_COUNT register. */
  79. #define PK_COUNT_TX_A_SHF 24
  80. #define PK_COUNT_TX_A_MSK (0xff << PK_COUNT_TX_A_SHF)
  81. #define PK_COUNT_TX_B_SHF 16
  82. #define PK_COUNT_TX_B_MSK (0xff << PK_COUNT_TX_B_SHF)
  83. #define PK_COUNT_RX_A_SHF 8
  84. #define PK_COUNT_RX_A_MSK (0xff << PK_COUNT_RX_A_SHF)
  85. #define PK_COUNT_RX_B_SHF 0
  86. #define PK_COUNT_RX_B_MSK (0xff << PK_COUNT_RX_B_SHF)
  87. /* OK2USE register. */
  88. #define OK2USE_TX_A 0x8
  89. #define OK2USE_TX_B 0x4
  90. #define OK2USE_RX_A 0x2
  91. #define OK2USE_RX_B 0x1
  92. /* LAN DMA CONTROL register. */
  93. #define DMA_CTL_BLK_INT 0x80000000
  94. #define DMA_CTL_MAX_XFER_SHF 18
  95. #define DMA_CTL_MAX_XFER_MSK (0x3 << LAN_DMA_CTL_MAX_XFER_SHF)
  96. #define DMA_CTL_ENDIAN_SHF 16
  97. #define DMA_CTL_ENDIAN_MSK (0x3 << LAN_DMA_CTL_ENDIAN_SHF)
  98. #define DMA_CTL_RX_INT_COUNT_SHF 8
  99. #define DMA_CTL_RX_INT_COUNT_MSK (0xff << LAN_DMA_CTL_RX_INT_COUNT_SHF)
  100. #define DMA_CTL_EN_TX_DMA 0x00000080
  101. #define DMA_CTL_EN_RX_DMA 0x00000040
  102. #define DMA_CTL_RX_INT_BUFFUL_EN 0x00000020
  103. #define DMA_CTL_RX_INT_TO_EN 0x00000010
  104. #define DMA_CTL_RX_INT_EN 0x00000008
  105. #define DMA_CTL_TX_INT_EN 0x00000004
  106. #define DMA_CTL_MAC_TX_INT_EN 0x00000002
  107. #define DMA_CTL_MAC_RX_INT_EN 0x00000001
  108. /* DMA STATUS register. */
  109. #define DMA_STATUS_BAD_ADDR_SHF 16
  110. #define DMA_STATUS_BAD_ADDR_MSK (0xf << DMA_STATUS_BAD_ADDR_SHF)
  111. #define DMA_STATUS_RX_PKTS_RECEIVED_SHF 8
  112. #define DMA_STATUS_RX_PKTS_RECEIVED_MSK (0xff << DMA_STATUS_RX_PKTS_RECEIVED_SHF)
  113. #define DMA_STATUS_TX_EN_SYNC 0x00000080
  114. #define DMA_STATUS_RX_BUF_A_FUL 0x00000040
  115. #define DMA_STATUS_RX_BUF_B_FUL 0x00000020
  116. #define DMA_STATUS_RX_TO_INT 0x00000010
  117. #define DMA_STATUS_RX_INT 0x00000008
  118. #define DMA_STATUS_TX_INT 0x00000004
  119. #define DMA_STATUS_MAC_TX_INT 0x00000002
  120. #define DMA_STATUS_MAC_RX_INT 0x00000001
  121. /* DMA TEST/PANIC SWITHES register. */
  122. #define DMA_TEST_LOOPBACK 0x01000000
  123. #define DMA_TEST_SW_RESET 0x00000001
  124. /* MAC CONTROL register. */
  125. #define MAC_CONTROL_EN_MISS_ROLL 0x00002000
  126. #define MAC_CONTROL_MISS_ROLL 0x00000400
  127. #define MAC_CONTROL_LOOP10 0x00000080
  128. #define MAC_CONTROL_CONN_SHF 5
  129. #define MAC_CONTROL_CONN_MSK (0x3 << MAC_CONTROL_CONN_SHF)
  130. #define MAC_CONTROL_MAC_LOOP 0x00000010
  131. #define MAC_CONTROL_FULL_DUP 0x00000008
  132. #define MAC_CONTROL_RESET 0x00000004
  133. #define MAC_CONTROL_HALT_IMM 0x00000002
  134. #define MAC_CONTROL_HALT_REQ 0x00000001
  135. /* CAM CONTROL register. */
  136. #define CAM_CONTROL_COMP_EN 0x00000010
  137. #define CAM_CONTROL_NEG_CAM 0x00000008
  138. #define CAM_CONTROL_BROAD_ACC 0x00000004
  139. #define CAM_CONTROL_GROUP_ACC 0x00000002
  140. #define CAM_CONTROL_STATION_ACC 0x00000001
  141. /* TRANSMIT CONTROL register. */
  142. #define TX_CTL_EN_COMP 0x00004000
  143. #define TX_CTL_EN_TX_PAR 0x00002000
  144. #define TX_CTL_EN_LATE_COLL 0x00001000
  145. #define TX_CTL_EN_EX_COLL 0x00000800
  146. #define TX_CTL_EN_L_CARR 0x00000400
  147. #define TX_CTL_EN_EX_DEFER 0x00000200
  148. #define TX_CTL_EN_UNDER 0x00000100
  149. #define TX_CTL_MII10 0x00000080
  150. #define TX_CTL_SD_PAUSE 0x00000040
  151. #define TX_CTL_NO_EX_DEF0 0x00000020
  152. #define TX_CTL_F_BACK 0x00000010
  153. #define TX_CTL_NO_CRC 0x00000008
  154. #define TX_CTL_NO_PAD 0x00000004
  155. #define TX_CTL_TX_HALT 0x00000002
  156. #define TX_CTL_TX_EN 0x00000001
  157. /* TRANSMIT STATUS register. */
  158. #define TX_STATUS_SQ_ERR 0x00010000
  159. #define TX_STATUS_TX_HALTED 0x00008000
  160. #define TX_STATUS_COMP 0x00004000
  161. #define TX_STATUS_TX_PAR 0x00002000
  162. #define TX_STATUS_LATE_COLL 0x00001000
  163. #define TX_STATUS_TX10_STAT 0x00000800
  164. #define TX_STATUS_L_CARR 0x00000400
  165. #define TX_STATUS_EX_DEFER 0x00000200
  166. #define TX_STATUS_UNDER 0x00000100
  167. #define TX_STATUS_IN_TX 0x00000080
  168. #define TX_STATUS_PAUSED 0x00000040
  169. #define TX_STATUS_TX_DEFERRED 0x00000020
  170. #define TX_STATUS_EX_COLL 0x00000010
  171. #define TX_STATUS_TX_COLL_SHF 0
  172. #define TX_STATUS_TX_COLL_MSK (0xf << TX_STATUS_TX_COLL_SHF)
  173. /* RECEIVE CONTROL register. */
  174. #define RX_CTL_EN_GOOD 0x00004000
  175. #define RX_CTL_EN_RX_PAR 0x00002000
  176. #define RX_CTL_EN_LONG_ERR 0x00000800
  177. #define RX_CTL_EN_OVER 0x00000400
  178. #define RX_CTL_EN_CRC_ERR 0x00000200
  179. #define RX_CTL_EN_ALIGN 0x00000100
  180. #define RX_CTL_IGNORE_CRC 0x00000040
  181. #define RX_CTL_PASS_CTL 0x00000020
  182. #define RX_CTL_STRIP_CRC 0x00000010
  183. #define RX_CTL_SHORT_EN 0x00000008
  184. #define RX_CTL_LONG_EN 0x00000004
  185. #define RX_CTL_RX_HALT 0x00000002
  186. #define RX_CTL_RX_EN 0x00000001
  187. /* RECEIVE STATUS register. */
  188. #define RX_STATUS_RX_HALTED 0x00008000
  189. #define RX_STATUS_GOOD 0x00004000
  190. #define RX_STATUS_RX_PAR 0x00002000
  191. #define RX_STATUS_LONG_ERR 0x00000800
  192. #define RX_STATUS_OVERFLOW 0x00000400
  193. #define RX_STATUS_CRC_ERR 0x00000200
  194. #define RX_STATUS_ALIGN_ERR 0x00000100
  195. #define RX_STATUS_RX10_STAT 0x00000080
  196. #define RX_STATUS_INT_RX 0x00000040
  197. #define RX_STATUS_CTL_RECD 0x00000020
  198. /* MD_CA register. */
  199. #define MD_CA_PRE_SUP 0x00001000
  200. #define MD_CA_BUSY 0x00000800
  201. #define MD_CA_WR 0x00000400
  202. #define MD_CA_PHY_SHF 5
  203. #define MD_CA_PHY_MSK (0x1f << MD_CA_PHY_SHF)
  204. #define MD_CA_ADDR_SHF 0
  205. #define MD_CA_ADDR_MSK (0x1f << MD_CA_ADDR_SHF)
  206. /* Tx Status/Control. */
  207. #define TX_STAT_CTL_OWNER_SHF 30
  208. #define TX_STAT_CTL_OWNER_MSK (0x3 << TX_STAT_CTL_OWNER_SHF)
  209. #define TX_STAT_CTL_FRAME_SHF 27
  210. #define TX_STAT_CTL_FRAME_MSK (0x7 << TX_STAT_CTL_FRAME_SHF)
  211. #define TX_STAT_CTL_STATUS_SHF 11
  212. #define TX_STAT_CTL_STATUS_MSK (0x1ffff << TX_STAT_CTL_STATUS_SHF)
  213. #define TX_STAT_CTL_LENGTH_SHF 0
  214. #define TX_STAT_CTL_LENGTH_MSK (0x7ff << TX_STAT_CTL_LENGTH_SHF)
  215. #define TX_STAT_CTL_ERROR_MSK ((TX_STATUS_SQ_ERR | \
  216. TX_STATUS_TX_HALTED | \
  217. TX_STATUS_TX_PAR | \
  218. TX_STATUS_LATE_COLL | \
  219. TX_STATUS_L_CARR | \
  220. TX_STATUS_EX_DEFER | \
  221. TX_STATUS_UNDER | \
  222. TX_STATUS_PAUSED | \
  223. TX_STATUS_TX_DEFERRED | \
  224. TX_STATUS_EX_COLL | \
  225. TX_STATUS_TX_COLL_MSK) \
  226. << TX_STAT_CTL_STATUS_SHF)
  227. #define TX_STAT_CTL_INT_AFTER_TX 0x4
  228. /* Rx Status/Control. */
  229. #define RX_STAT_CTL_OWNER_SHF 30
  230. #define RX_STAT_CTL_OWNER_MSK (0x3 << RX_STAT_CTL_OWNER_SHF)
  231. #define RX_STAT_CTL_STATUS_SHF 11
  232. #define RX_STAT_CTL_STATUS_MSK (0xffff << RX_STAT_CTL_STATUS_SHF)
  233. #define RX_STAT_CTL_LENGTH_SHF 0
  234. #define RX_STAT_CTL_LENGTH_MSK (0x7ff << RX_STAT_CTL_LENGTH_SHF)
  235. /* The SAA9730 (LAN) controller register map, as seen via the PCI-bus. */
  236. #define SAA9730_LAN_REGS_ADDR 0x20400
  237. struct lan_saa9730_regmap {
  238. volatile unsigned int TxBuffA; /* 0x20400 */
  239. volatile unsigned int TxBuffB; /* 0x20404 */
  240. volatile unsigned int RxBuffA; /* 0x20408 */
  241. volatile unsigned int RxBuffB; /* 0x2040c */
  242. volatile unsigned int PacketCount; /* 0x20410 */
  243. volatile unsigned int Ok2Use; /* 0x20414 */
  244. volatile unsigned int LanDmaCtl; /* 0x20418 */
  245. volatile unsigned int Timeout; /* 0x2041c */
  246. volatile unsigned int DmaStatus; /* 0x20420 */
  247. volatile unsigned int DmaTest; /* 0x20424 */
  248. volatile unsigned char filler20428[0x20430 - 0x20428];
  249. volatile unsigned int PauseCount; /* 0x20430 */
  250. volatile unsigned int RemotePauseCount; /* 0x20434 */
  251. volatile unsigned char filler20438[0x20440 - 0x20438];
  252. volatile unsigned int MacCtl; /* 0x20440 */
  253. volatile unsigned int CamCtl; /* 0x20444 */
  254. volatile unsigned int TxCtl; /* 0x20448 */
  255. volatile unsigned int TxStatus; /* 0x2044c */
  256. volatile unsigned int RxCtl; /* 0x20450 */
  257. volatile unsigned int RxStatus; /* 0x20454 */
  258. volatile unsigned int StationMgmtData; /* 0x20458 */
  259. volatile unsigned int StationMgmtCtl; /* 0x2045c */
  260. volatile unsigned int CamAddress; /* 0x20460 */
  261. volatile unsigned int CamData; /* 0x20464 */
  262. volatile unsigned int CamEnable; /* 0x20468 */
  263. volatile unsigned char filler2046c[0x20500 - 0x2046c];
  264. volatile unsigned int DebugPCIMasterAddr; /* 0x20500 */
  265. volatile unsigned int DebugLanTxStateMachine; /* 0x20504 */
  266. volatile unsigned int DebugLanRxStateMachine; /* 0x20508 */
  267. volatile unsigned int DebugLanTxFifoPointers; /* 0x2050c */
  268. volatile unsigned int DebugLanRxFifoPointers; /* 0x20510 */
  269. volatile unsigned int DebugLanCtlStateMachine; /* 0x20514 */
  270. };
  271. typedef volatile struct lan_saa9730_regmap t_lan_saa9730_regmap;
  272. /* EVM interrupt control registers. */
  273. #define EVM_LAN_INT 0x00010000
  274. #define EVM_MASTER_EN 0x00000001
  275. /* The SAA9730 (EVM) controller register map, as seen via the PCI-bus. */
  276. #define SAA9730_EVM_REGS_ADDR 0x02000
  277. struct evm_saa9730_regmap {
  278. volatile unsigned int InterruptStatus1; /* 0x2000 */
  279. volatile unsigned int InterruptEnable1; /* 0x2004 */
  280. volatile unsigned int InterruptMonitor1; /* 0x2008 */
  281. volatile unsigned int Counter; /* 0x200c */
  282. volatile unsigned int CounterThreshold; /* 0x2010 */
  283. volatile unsigned int CounterControl; /* 0x2014 */
  284. volatile unsigned int GpioControl1; /* 0x2018 */
  285. volatile unsigned int InterruptStatus2; /* 0x201c */
  286. volatile unsigned int InterruptEnable2; /* 0x2020 */
  287. volatile unsigned int InterruptMonitor2; /* 0x2024 */
  288. volatile unsigned int GpioControl2; /* 0x2028 */
  289. volatile unsigned int InterruptBlock1; /* 0x202c */
  290. volatile unsigned int InterruptBlock2; /* 0x2030 */
  291. };
  292. typedef volatile struct evm_saa9730_regmap t_evm_saa9730_regmap;
  293. struct lan_saa9730_private {
  294. /* Pointer for the SAA9730 LAN controller register set. */
  295. t_lan_saa9730_regmap *lan_saa9730_regs;
  296. /* Pointer to the SAA9730 EVM register. */
  297. t_evm_saa9730_regmap *evm_saa9730_regs;
  298. /* TRUE if the next buffer to write is RxBuffA, FALSE if RxBuffB. */
  299. unsigned char NextRcvToUseIsA;
  300. /* Rcv buffer Index. */
  301. unsigned char NextRcvPacketIndex;
  302. /* Index of next packet to use in that buffer. */
  303. unsigned char NextTxmPacketIndex;
  304. /* Next buffer index. */
  305. unsigned char NextTxmBufferIndex;
  306. /* Index of first pending packet ready to send. */
  307. unsigned char PendingTxmPacketIndex;
  308. /* Pending buffer index. */
  309. unsigned char PendingTxmBufferIndex;
  310. unsigned char DmaRcvPackets;
  311. unsigned char DmaTxmPackets;
  312. unsigned char RcvAIndex; /* index into RcvBufferSpace[] for Blk A */
  313. unsigned char RcvBIndex; /* index into RcvBufferSpace[] for Blk B */
  314. unsigned int
  315. TxmBuffer[LAN_SAA9730_BUFFERS][LAN_SAA9730_TXM_Q_SIZE];
  316. unsigned int
  317. RcvBuffer[LAN_SAA9730_BUFFERS][LAN_SAA9730_RCV_Q_SIZE];
  318. unsigned int TxBufferFree[LAN_SAA9730_BUFFERS];
  319. unsigned char PhysicalAddress[LAN_SAA9730_CAM_ENTRIES][6];
  320. struct net_device_stats stats;
  321. spinlock_t lock;
  322. };
  323. #endif /* _SAA9730_H */