lan91c96.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /*------------------------------------------------------------------------
  2. * lan91c96.h
  3. *
  4. * (C) Copyright 2002
  5. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  6. * Rolf Offermanns <rof@sysgo.de>
  7. * Copyright (C) 2001 Standard Microsystems Corporation (SMSC)
  8. * Developed by Simple Network Magic Corporation (SNMC)
  9. * Copyright (C) 1996 by Erik Stahlman (ES)
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. *
  25. * This file contains register information and access macros for
  26. * the LAN91C96 single chip ethernet controller. It is a modified
  27. * version of the smc9111.h file.
  28. *
  29. * Information contained in this file was obtained from the LAN91C96
  30. * manual from SMC. To get a copy, if you really want one, you can find
  31. * information under www.smsc.com.
  32. *
  33. * Authors
  34. * Erik Stahlman ( erik@vt.edu )
  35. * Daris A Nevil ( dnevil@snmc.com )
  36. *
  37. * History
  38. * 04/30/03 Mathijs Haarman Modified smc91111.h (u-boot version)
  39. * for lan91c96
  40. *-------------------------------------------------------------------------
  41. */
  42. #ifndef _LAN91C96_H_
  43. #define _LAN91C96_H_
  44. #include <asm/types.h>
  45. #include <asm/io.h>
  46. #include <config.h>
  47. /*
  48. * This function may be called by the board specific initialisation code
  49. * in order to override the default mac address.
  50. */
  51. void smc_set_mac_addr(const unsigned char *addr);
  52. /* I want some simple types */
  53. typedef unsigned char byte;
  54. typedef unsigned short word;
  55. typedef unsigned long int dword;
  56. /*
  57. * DEBUGGING LEVELS
  58. *
  59. * 0 for normal operation
  60. * 1 for slightly more details
  61. * >2 for various levels of increasingly useless information
  62. * 2 for interrupt tracking, status flags
  63. * 3 for packet info
  64. * 4 for complete packet dumps
  65. */
  66. /*#define SMC_DEBUG 0 */
  67. /* Because of bank switching, the LAN91xxx uses only 16 I/O ports */
  68. #define SMC_IO_EXTENT 16
  69. #ifdef CONFIG_PXA250
  70. #ifdef CONFIG_LUBBOCK
  71. #define SMC_IO_SHIFT 2
  72. #undef USE_32_BIT
  73. #else
  74. #define SMC_IO_SHIFT 0
  75. #endif
  76. #define SMCREG(r) (SMC_BASE_ADDRESS+((r)<<SMC_IO_SHIFT))
  77. #define SMC_inl(r) (*((volatile dword *)SMCREG(r)))
  78. #define SMC_inw(r) (*((volatile word *)SMCREG(r)))
  79. #define SMC_inb(p) ({ \
  80. unsigned int __p = p; \
  81. unsigned int __v = SMC_inw(__p & ~1); \
  82. if (__p & 1) __v >>= 8; \
  83. else __v &= 0xff; \
  84. __v; })
  85. #define SMC_outl(d,r) (*((volatile dword *)SMCREG(r)) = d)
  86. #define SMC_outw(d,r) (*((volatile word *)SMCREG(r)) = d)
  87. #define SMC_outb(d,r) ({ word __d = (byte)(d); \
  88. word __w = SMC_inw((r)&~1); \
  89. __w &= ((r)&1) ? 0x00FF : 0xFF00; \
  90. __w |= ((r)&1) ? __d<<8 : __d; \
  91. SMC_outw(__w,(r)&~1); \
  92. })
  93. #define SMC_outsl(r,b,l) ({ int __i; \
  94. dword *__b2; \
  95. __b2 = (dword *) b; \
  96. for (__i = 0; __i < l; __i++) { \
  97. SMC_outl( *(__b2 + __i), r ); \
  98. } \
  99. })
  100. #define SMC_outsw(r,b,l) ({ int __i; \
  101. word *__b2; \
  102. __b2 = (word *) b; \
  103. for (__i = 0; __i < l; __i++) { \
  104. SMC_outw( *(__b2 + __i), r ); \
  105. } \
  106. })
  107. #define SMC_insl(r,b,l) ({ int __i ; \
  108. dword *__b2; \
  109. __b2 = (dword *) b; \
  110. for (__i = 0; __i < l; __i++) { \
  111. *(__b2 + __i) = SMC_inl(r); \
  112. SMC_inl(0); \
  113. }; \
  114. })
  115. #define SMC_insw(r,b,l) ({ int __i ; \
  116. word *__b2; \
  117. __b2 = (word *) b; \
  118. for (__i = 0; __i < l; __i++) { \
  119. *(__b2 + __i) = SMC_inw(r); \
  120. SMC_inw(0); \
  121. }; \
  122. })
  123. #define SMC_insb(r,b,l) ({ int __i ; \
  124. byte *__b2; \
  125. __b2 = (byte *) b; \
  126. for (__i = 0; __i < l; __i++) { \
  127. *(__b2 + __i) = SMC_inb(r); \
  128. SMC_inb(0); \
  129. }; \
  130. })
  131. #else /* if not CONFIG_PXA250 */
  132. /*
  133. * We have only 16 Bit PCMCIA access on Socket 0
  134. */
  135. #define SMC_inw(r) (*((volatile word *)(SMC_BASE_ADDRESS+(r))))
  136. #define SMC_inb(r) (((r)&1) ? SMC_inw((r)&~1)>>8 : SMC_inw(r)&0xFF)
  137. #define SMC_outw(d,r) (*((volatile word *)(SMC_BASE_ADDRESS+(r))) = d)
  138. #define SMC_outb(d,r) ({ word __d = (byte)(d); \
  139. word __w = SMC_inw((r)&~1); \
  140. __w &= ((r)&1) ? 0x00FF : 0xFF00; \
  141. __w |= ((r)&1) ? __d<<8 : __d; \
  142. SMC_outw(__w,(r)&~1); \
  143. })
  144. #if 0
  145. #define SMC_outsw(r,b,l) outsw(SMC_BASE_ADDRESS+(r), (b), (l))
  146. #else
  147. #define SMC_outsw(r,b,l) ({ int __i; \
  148. word *__b2; \
  149. __b2 = (word *) b; \
  150. for (__i = 0; __i < l; __i++) { \
  151. SMC_outw( *(__b2 + __i), r); \
  152. } \
  153. })
  154. #endif
  155. #if 0
  156. #define SMC_insw(r,b,l) insw(SMC_BASE_ADDRESS+(r), (b), (l))
  157. #else
  158. #define SMC_insw(r,b,l) ({ int __i ; \
  159. word *__b2; \
  160. __b2 = (word *) b; \
  161. for (__i = 0; __i < l; __i++) { \
  162. *(__b2 + __i) = SMC_inw(r); \
  163. SMC_inw(0); \
  164. }; \
  165. })
  166. #endif
  167. #endif
  168. /*
  169. ****************************************************************************
  170. * Bank Select Field
  171. ****************************************************************************
  172. */
  173. #define LAN91C96_BANK_SELECT 14 /* Bank Select Register */
  174. #define LAN91C96_BANKSELECT (0x3UC << 0)
  175. #define BANK0 0x00
  176. #define BANK1 0x01
  177. #define BANK2 0x02
  178. #define BANK3 0x03
  179. #define BANK4 0x04
  180. /*
  181. ****************************************************************************
  182. * EEPROM Addresses.
  183. ****************************************************************************
  184. */
  185. #define EEPROM_MAC_OFFSET_1 0x6020
  186. #define EEPROM_MAC_OFFSET_2 0x6021
  187. #define EEPROM_MAC_OFFSET_3 0x6022
  188. /*
  189. ****************************************************************************
  190. * Bank 0 Register Map in I/O Space
  191. ****************************************************************************
  192. */
  193. #define LAN91C96_TCR 0 /* Transmit Control Register */
  194. #define LAN91C96_EPH_STATUS 2 /* EPH Status Register */
  195. #define LAN91C96_RCR 4 /* Receive Control Register */
  196. #define LAN91C96_COUNTER 6 /* Counter Register */
  197. #define LAN91C96_MIR 8 /* Memory Information Register */
  198. #define LAN91C96_MCR 10 /* Memory Configuration Register */
  199. /*
  200. ****************************************************************************
  201. * Transmit Control Register - Bank 0 - Offset 0
  202. ****************************************************************************
  203. */
  204. #define LAN91C96_TCR_TXENA (0x1U << 0)
  205. #define LAN91C96_TCR_LOOP (0x1U << 1)
  206. #define LAN91C96_TCR_FORCOL (0x1U << 2)
  207. #define LAN91C96_TCR_TXP_EN (0x1U << 3)
  208. #define LAN91C96_TCR_PAD_EN (0x1U << 7)
  209. #define LAN91C96_TCR_NOCRC (0x1U << 8)
  210. #define LAN91C96_TCR_MON_CSN (0x1U << 10)
  211. #define LAN91C96_TCR_FDUPLX (0x1U << 11)
  212. #define LAN91C96_TCR_STP_SQET (0x1U << 12)
  213. #define LAN91C96_TCR_EPH_LOOP (0x1U << 13)
  214. #define LAN91C96_TCR_ETEN_TYPE (0x1U << 14)
  215. #define LAN91C96_TCR_FDSE (0x1U << 15)
  216. /*
  217. ****************************************************************************
  218. * EPH Status Register - Bank 0 - Offset 2
  219. ****************************************************************************
  220. */
  221. #define LAN91C96_EPHSR_TX_SUC (0x1U << 0)
  222. #define LAN91C96_EPHSR_SNGL_COL (0x1U << 1)
  223. #define LAN91C96_EPHSR_MUL_COL (0x1U << 2)
  224. #define LAN91C96_EPHSR_LTX_MULT (0x1U << 3)
  225. #define LAN91C96_EPHSR_16COL (0x1U << 4)
  226. #define LAN91C96_EPHSR_SQET (0x1U << 5)
  227. #define LAN91C96_EPHSR_LTX_BRD (0x1U << 6)
  228. #define LAN91C96_EPHSR_TX_DEFR (0x1U << 7)
  229. #define LAN91C96_EPHSR_WAKEUP (0x1U << 8)
  230. #define LAN91C96_EPHSR_LATCOL (0x1U << 9)
  231. #define LAN91C96_EPHSR_LOST_CARR (0x1U << 10)
  232. #define LAN91C96_EPHSR_EXC_DEF (0x1U << 11)
  233. #define LAN91C96_EPHSR_CTR_ROL (0x1U << 12)
  234. #define LAN91C96_EPHSR_LINK_OK (0x1U << 14)
  235. #define LAN91C96_EPHSR_TX_UNRN (0x1U << 15)
  236. #define LAN91C96_EPHSR_ERRORS (LAN91C96_EPHSR_SNGL_COL | \
  237. LAN91C96_EPHSR_MUL_COL | \
  238. LAN91C96_EPHSR_16COL | \
  239. LAN91C96_EPHSR_SQET | \
  240. LAN91C96_EPHSR_TX_DEFR | \
  241. LAN91C96_EPHSR_LATCOL | \
  242. LAN91C96_EPHSR_LOST_CARR | \
  243. LAN91C96_EPHSR_EXC_DEF | \
  244. LAN91C96_EPHSR_LINK_OK | \
  245. LAN91C96_EPHSR_TX_UNRN)
  246. /*
  247. ****************************************************************************
  248. * Receive Control Register - Bank 0 - Offset 4
  249. ****************************************************************************
  250. */
  251. #define LAN91C96_RCR_RX_ABORT (0x1U << 0)
  252. #define LAN91C96_RCR_PRMS (0x1U << 1)
  253. #define LAN91C96_RCR_ALMUL (0x1U << 2)
  254. #define LAN91C96_RCR_RXEN (0x1U << 8)
  255. #define LAN91C96_RCR_STRIP_CRC (0x1U << 9)
  256. #define LAN91C96_RCR_FILT_CAR (0x1U << 14)
  257. #define LAN91C96_RCR_SOFT_RST (0x1U << 15)
  258. /*
  259. ****************************************************************************
  260. * Counter Register - Bank 0 - Offset 6
  261. ****************************************************************************
  262. */
  263. #define LAN91C96_ECR_SNGL_COL (0xFU << 0)
  264. #define LAN91C96_ECR_MULT_COL (0xFU << 5)
  265. #define LAN91C96_ECR_DEF_TX (0xFU << 8)
  266. #define LAN91C96_ECR_EXC_DEF_TX (0xFU << 12)
  267. /*
  268. ****************************************************************************
  269. * Memory Information Register - Bank 0 - OFfset 8
  270. ****************************************************************************
  271. */
  272. #define LAN91C96_MIR_SIZE (0x18 << 0) /* 6144 bytes */
  273. /*
  274. ****************************************************************************
  275. * Memory Configuration Register - Bank 0 - Offset 10
  276. ****************************************************************************
  277. */
  278. #define LAN91C96_MCR_MEM_RES (0xFFU << 0)
  279. #define LAN91C96_MCR_MEM_MULT (0x3U << 9)
  280. #define LAN91C96_MCR_HIGH_ID (0x3U << 12)
  281. #define LAN91C96_MCR_TRANSMIT_PAGES 0x6
  282. /*
  283. ****************************************************************************
  284. * Bank 1 Register Map in I/O Space
  285. ****************************************************************************
  286. */
  287. #define LAN91C96_CONFIG 0 /* Configuration Register */
  288. #define LAN91C96_BASE 2 /* Base Address Register */
  289. #define LAN91C96_IA0 4 /* Individual Address Register - 0 */
  290. #define LAN91C96_IA1 5 /* Individual Address Register - 1 */
  291. #define LAN91C96_IA2 6 /* Individual Address Register - 2 */
  292. #define LAN91C96_IA3 7 /* Individual Address Register - 3 */
  293. #define LAN91C96_IA4 8 /* Individual Address Register - 4 */
  294. #define LAN91C96_IA5 9 /* Individual Address Register - 5 */
  295. #define LAN91C96_GEN_PURPOSE 10 /* General Address Registers */
  296. #define LAN91C96_CONTROL 12 /* Control Register */
  297. /*
  298. ****************************************************************************
  299. * Configuration Register - Bank 1 - Offset 0
  300. ****************************************************************************
  301. */
  302. #define LAN91C96_CR_INT_SEL0 (0x1U << 1)
  303. #define LAN91C96_CR_INT_SEL1 (0x1U << 2)
  304. #define LAN91C96_CR_RES (0x3U << 3)
  305. #define LAN91C96_CR_DIS_LINK (0x1U << 6)
  306. #define LAN91C96_CR_16BIT (0x1U << 7)
  307. #define LAN91C96_CR_AUI_SELECT (0x1U << 8)
  308. #define LAN91C96_CR_SET_SQLCH (0x1U << 9)
  309. #define LAN91C96_CR_FULL_STEP (0x1U << 10)
  310. #define LAN91C96_CR_NO_WAIT (0x1U << 12)
  311. /*
  312. ****************************************************************************
  313. * Base Address Register - Bank 1 - Offset 2
  314. ****************************************************************************
  315. */
  316. #define LAN91C96_BAR_RA_BITS (0x27U << 0)
  317. #define LAN91C96_BAR_ROM_SIZE (0x1U << 6)
  318. #define LAN91C96_BAR_A_BITS (0xFFU << 8)
  319. /*
  320. ****************************************************************************
  321. * Control Register - Bank 1 - Offset 12
  322. ****************************************************************************
  323. */
  324. #define LAN91C96_CTR_STORE (0x1U << 0)
  325. #define LAN91C96_CTR_RELOAD (0x1U << 1)
  326. #define LAN91C96_CTR_EEPROM (0x1U << 2)
  327. #define LAN91C96_CTR_TE_ENABLE (0x1U << 5)
  328. #define LAN91C96_CTR_CR_ENABLE (0x1U << 6)
  329. #define LAN91C96_CTR_LE_ENABLE (0x1U << 7)
  330. #define LAN91C96_CTR_BIT_8 (0x1U << 8)
  331. #define LAN91C96_CTR_AUTO_RELEASE (0x1U << 11)
  332. #define LAN91C96_CTR_WAKEUP_EN (0x1U << 12)
  333. #define LAN91C96_CTR_PWRDN (0x1U << 13)
  334. #define LAN91C96_CTR_RCV_BAD (0x1U << 14)
  335. /*
  336. ****************************************************************************
  337. * Bank 2 Register Map in I/O Space
  338. ****************************************************************************
  339. */
  340. #define LAN91C96_MMU 0 /* MMU Command Register */
  341. #define LAN91C96_AUTO_TX_START 1 /* Auto Tx Start Register */
  342. #define LAN91C96_PNR 2 /* Packet Number Register */
  343. #define LAN91C96_ARR 3 /* Allocation Result Register */
  344. #define LAN91C96_FIFO 4 /* FIFO Ports Register */
  345. #define LAN91C96_POINTER 6 /* Pointer Register */
  346. #define LAN91C96_DATA_HIGH 8 /* Data High Register */
  347. #define LAN91C96_DATA_LOW 10 /* Data Low Register */
  348. #define LAN91C96_INT_STATS 12 /* Interrupt Status Register - RO */
  349. #define LAN91C96_INT_ACK 12 /* Interrupt Acknowledge Register -WO */
  350. #define LAN91C96_INT_MASK 13 /* Interrupt Mask Register */
  351. /*
  352. ****************************************************************************
  353. * MMU Command Register - Bank 2 - Offset 0
  354. ****************************************************************************
  355. */
  356. #define LAN91C96_MMUCR_NO_BUSY (0x1U << 0)
  357. #define LAN91C96_MMUCR_N1 (0x1U << 1)
  358. #define LAN91C96_MMUCR_N2 (0x1U << 2)
  359. #define LAN91C96_MMUCR_COMMAND (0xFU << 4)
  360. #define LAN91C96_MMUCR_ALLOC_TX (0x2U << 4) /* WXYZ = 0010 */
  361. #define LAN91C96_MMUCR_RESET_MMU (0x4U << 4) /* WXYZ = 0100 */
  362. #define LAN91C96_MMUCR_REMOVE_RX (0x6U << 4) /* WXYZ = 0110 */
  363. #define LAN91C96_MMUCR_REMOVE_TX (0x7U << 4) /* WXYZ = 0111 */
  364. #define LAN91C96_MMUCR_RELEASE_RX (0x8U << 4) /* WXYZ = 1000 */
  365. #define LAN91C96_MMUCR_RELEASE_TX (0xAU << 4) /* WXYZ = 1010 */
  366. #define LAN91C96_MMUCR_ENQUEUE (0xCU << 4) /* WXYZ = 1100 */
  367. #define LAN91C96_MMUCR_RESET_TX (0xEU << 4) /* WXYZ = 1110 */
  368. /*
  369. ****************************************************************************
  370. * Auto Tx Start Register - Bank 2 - Offset 1
  371. ****************************************************************************
  372. */
  373. #define LAN91C96_AUTOTX (0xFFU << 0)
  374. /*
  375. ****************************************************************************
  376. * Packet Number Register - Bank 2 - Offset 2
  377. ****************************************************************************
  378. */
  379. #define LAN91C96_PNR_TX (0x1FU << 0)
  380. /*
  381. ****************************************************************************
  382. * Allocation Result Register - Bank 2 - Offset 3
  383. ****************************************************************************
  384. */
  385. #define LAN91C96_ARR_ALLOC_PN (0x7FU << 0)
  386. #define LAN91C96_ARR_FAILED (0x1U << 7)
  387. /*
  388. ****************************************************************************
  389. * FIFO Ports Register - Bank 2 - Offset 4
  390. ****************************************************************************
  391. */
  392. #define LAN91C96_FIFO_TX_DONE_PN (0x1FU << 0)
  393. #define LAN91C96_FIFO_TEMPTY (0x1U << 7)
  394. #define LAN91C96_FIFO_RX_DONE_PN (0x1FU << 8)
  395. #define LAN91C96_FIFO_RXEMPTY (0x1U << 15)
  396. /*
  397. ****************************************************************************
  398. * Pointer Register - Bank 2 - Offset 6
  399. ****************************************************************************
  400. */
  401. #define LAN91C96_PTR_LOW (0xFFU << 0)
  402. #define LAN91C96_PTR_HIGH (0x7U << 8)
  403. #define LAN91C96_PTR_AUTO_TX (0x1U << 11)
  404. #define LAN91C96_PTR_ETEN (0x1U << 12)
  405. #define LAN91C96_PTR_READ (0x1U << 13)
  406. #define LAN91C96_PTR_AUTO_INCR (0x1U << 14)
  407. #define LAN91C96_PTR_RCV (0x1U << 15)
  408. #define LAN91C96_PTR_RX_FRAME (LAN91C96_PTR_RCV | \
  409. LAN91C96_PTR_AUTO_INCR | \
  410. LAN91C96_PTR_READ)
  411. /*
  412. ****************************************************************************
  413. * Data Register - Bank 2 - Offset 8
  414. ****************************************************************************
  415. */
  416. #define LAN91C96_CONTROL_CRC (0x1U << 4) /* CRC bit */
  417. #define LAN91C96_CONTROL_ODD (0x1U << 5) /* ODD bit */
  418. /*
  419. ****************************************************************************
  420. * Interrupt Status Register - Bank 2 - Offset 12
  421. ****************************************************************************
  422. */
  423. #define LAN91C96_IST_RCV_INT (0x1U << 0)
  424. #define LAN91C96_IST_TX_INT (0x1U << 1)
  425. #define LAN91C96_IST_TX_EMPTY_INT (0x1U << 2)
  426. #define LAN91C96_IST_ALLOC_INT (0x1U << 3)
  427. #define LAN91C96_IST_RX_OVRN_INT (0x1U << 4)
  428. #define LAN91C96_IST_EPH_INT (0x1U << 5)
  429. #define LAN91C96_IST_ERCV_INT (0x1U << 6)
  430. #define LAN91C96_IST_RX_IDLE_INT (0x1U << 7)
  431. /*
  432. ****************************************************************************
  433. * Interrupt Acknowledge Register - Bank 2 - Offset 12
  434. ****************************************************************************
  435. */
  436. #define LAN91C96_ACK_TX_INT (0x1U << 1)
  437. #define LAN91C96_ACK_TX_EMPTY_INT (0x1U << 2)
  438. #define LAN91C96_ACK_RX_OVRN_INT (0x1U << 4)
  439. #define LAN91C96_ACK_ERCV_INT (0x1U << 6)
  440. /*
  441. ****************************************************************************
  442. * Interrupt Mask Register - Bank 2 - Offset 13
  443. ****************************************************************************
  444. */
  445. #define LAN91C96_MSK_RCV_INT (0x1U << 0)
  446. #define LAN91C96_MSK_TX_INT (0x1U << 1)
  447. #define LAN91C96_MSK_TX_EMPTY_INT (0x1U << 2)
  448. #define LAN91C96_MSK_ALLOC_INT (0x1U << 3)
  449. #define LAN91C96_MSK_RX_OVRN_INT (0x1U << 4)
  450. #define LAN91C96_MSK_EPH_INT (0x1U << 5)
  451. #define LAN91C96_MSK_ERCV_INT (0x1U << 6)
  452. #define LAN91C96_MSK_TX_IDLE_INT (0x1U << 7)
  453. /*
  454. ****************************************************************************
  455. * Bank 3 Register Map in I/O Space
  456. **************************************************************************
  457. */
  458. #define LAN91C96_MGMT_MDO (0x1U << 0)
  459. #define LAN91C96_MGMT_MDI (0x1U << 1)
  460. #define LAN91C96_MGMT_MCLK (0x1U << 2)
  461. #define LAN91C96_MGMT_MDOE (0x1U << 3)
  462. #define LAN91C96_MGMT_LOW_ID (0x3U << 4)
  463. #define LAN91C96_MGMT_IOS0 (0x1U << 8)
  464. #define LAN91C96_MGMT_IOS1 (0x1U << 9)
  465. #define LAN91C96_MGMT_IOS2 (0x1U << 10)
  466. #define LAN91C96_MGMT_nXNDEC (0x1U << 11)
  467. #define LAN91C96_MGMT_HIGH_ID (0x3U << 12)
  468. /*
  469. ****************************************************************************
  470. * Revision Register - Bank 3 - Offset 10
  471. ****************************************************************************
  472. */
  473. #define LAN91C96_REV_REVID (0xFU << 0)
  474. #define LAN91C96_REV_CHIPID (0xFU << 4)
  475. /*
  476. ****************************************************************************
  477. * Early RCV Register - Bank 3 - Offset 12
  478. ****************************************************************************
  479. */
  480. #define LAN91C96_ERCV_THRESHOLD (0x1FU << 0)
  481. #define LAN91C96_ERCV_RCV_DISCRD (0x1U << 7)
  482. /*
  483. ****************************************************************************
  484. * PCMCIA Configuration Registers
  485. ****************************************************************************
  486. */
  487. #define LAN91C96_ECOR 0x8000 /* Ethernet Configuration Register */
  488. #define LAN91C96_ECSR 0x8002 /* Ethernet Configuration and Status */
  489. /*
  490. ****************************************************************************
  491. * PCMCIA Ethernet Configuration Option Register (ECOR)
  492. ****************************************************************************
  493. */
  494. #define LAN91C96_ECOR_ENABLE (0x1U << 0)
  495. #define LAN91C96_ECOR_WR_ATTRIB (0x1U << 2)
  496. #define LAN91C96_ECOR_LEVEL_REQ (0x1U << 6)
  497. #define LAN91C96_ECOR_SRESET (0x1U << 7)
  498. /*
  499. ****************************************************************************
  500. * PCMCIA Ethernet Configuration and Status Register (ECSR)
  501. ****************************************************************************
  502. */
  503. #define LAN91C96_ECSR_INTR (0x1U << 1)
  504. #define LAN91C96_ECSR_PWRDWN (0x1U << 2)
  505. #define LAN91C96_ECSR_IOIS8 (0x1U << 5)
  506. /*
  507. ****************************************************************************
  508. * Receive Frame Status Word - See page 38 of the LAN91C96 specification.
  509. ****************************************************************************
  510. */
  511. #define LAN91C96_TOO_SHORT (0x1U << 10)
  512. #define LAN91C96_TOO_LONG (0x1U << 11)
  513. #define LAN91C96_ODD_FRM (0x1U << 12)
  514. #define LAN91C96_BAD_CRC (0x1U << 13)
  515. #define LAN91C96_BROD_CAST (0x1U << 14)
  516. #define LAN91C96_ALGN_ERR (0x1U << 15)
  517. #define FRAME_FILTER (LAN91C96_TOO_SHORT | LAN91C96_TOO_LONG | LAN91C96_BAD_CRC | LAN91C96_ALGN_ERR)
  518. /*
  519. ****************************************************************************
  520. * Default MAC Address
  521. ****************************************************************************
  522. */
  523. #define MAC_DEF_HI 0x0800
  524. #define MAC_DEF_MED 0x3333
  525. #define MAC_DEF_LO 0x0100
  526. /*
  527. ****************************************************************************
  528. * Default I/O Signature - 0x33
  529. ****************************************************************************
  530. */
  531. #define LAN91C96_LOW_SIGNATURE (0x33U << 0)
  532. #define LAN91C96_HIGH_SIGNATURE (0x33U << 8)
  533. #define LAN91C96_SIGNATURE (LAN91C96_HIGH_SIGNATURE | LAN91C96_LOW_SIGNATURE)
  534. #define LAN91C96_MAX_PAGES 6 /* Maximum number of 256 pages. */
  535. #define ETHERNET_MAX_LENGTH 1514
  536. /*-------------------------------------------------------------------------
  537. * I define some macros to make it easier to do somewhat common
  538. * or slightly complicated, repeated tasks.
  539. *-------------------------------------------------------------------------
  540. */
  541. /* select a register bank, 0 to 3 */
  542. #define SMC_SELECT_BANK(x) { SMC_outw( x, LAN91C96_BANK_SELECT ); }
  543. /* this enables an interrupt in the interrupt mask register */
  544. #define SMC_ENABLE_INT(x) {\
  545. unsigned char mask;\
  546. SMC_SELECT_BANK(2);\
  547. mask = SMC_inb( LAN91C96_INT_MASK );\
  548. mask |= (x);\
  549. SMC_outb( mask, LAN91C96_INT_MASK ); \
  550. }
  551. /* this disables an interrupt from the interrupt mask register */
  552. #define SMC_DISABLE_INT(x) {\
  553. unsigned char mask;\
  554. SMC_SELECT_BANK(2);\
  555. mask = SMC_inb( LAN91C96_INT_MASK );\
  556. mask &= ~(x);\
  557. SMC_outb( mask, LAN91C96_INT_MASK ); \
  558. }
  559. /*----------------------------------------------------------------------
  560. * Define the interrupts that I want to receive from the card
  561. *
  562. * I want:
  563. * LAN91C96_IST_EPH_INT, for nasty errors
  564. * LAN91C96_IST_RCV_INT, for happy received packets
  565. * LAN91C96_IST_RX_OVRN_INT, because I have to kick the receiver
  566. *-------------------------------------------------------------------------
  567. */
  568. #define SMC_INTERRUPT_MASK (LAN91C96_IST_EPH_INT | LAN91C96_IST_RX_OVRN_INT | LAN91C96_IST_RCV_INT)
  569. #endif /* _LAN91C96_H_ */