enc28j60.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. /****************************************************************************
  2. * drivers/net/enc28j60.h
  3. *
  4. * Copyright (C) 2010 Gregory Nutt. All rights reserved.
  5. * Author: Gregory Nutt <gnutt@nuttx.org>
  6. *
  7. * References:
  8. * - ENC28J60 Data Sheet, Stand-Alone Ethernet Controller with SPI Interface,
  9. * DS39662C, 2008 Microchip Technology Inc.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. *
  15. * 1. Redistributions of source code must retain the above copyright
  16. * notice, this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright
  18. * notice, this list of conditions and the following disclaimer in
  19. * the documentation and/or other materials provided with the
  20. * distribution.
  21. * 3. Neither the name NuttX nor the names of its contributors may be
  22. * used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  28. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  29. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  30. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  31. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  32. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  33. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  35. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. ****************************************************************************/
  39. #ifndef __DRIVERS_NET_ENC28J60_H
  40. #define __DRIVERS_NET_ENC28J60_H
  41. /****************************************************************************
  42. * Included Files
  43. ****************************************************************************/
  44. /****************************************************************************
  45. * Pre-processor Definitions
  46. ****************************************************************************/
  47. /* ENC28J60 Commands ********************************************************/
  48. /* A total of seven instructions are implemented on the ENC28J60. Where:
  49. *
  50. * aaaaaa is the 5-bit address of a control register, and
  51. * dddddddd is one or more bytes of data that may accompany the command.
  52. */
  53. #define ENC_RCR (0x00) /* Read Control Register
  54. * 000 | aaaaa | (Register value returned)) */
  55. #define ENC_RBM (0x3a) /* Read Buffer Memory
  56. * 001 | 11010 | (Read buffer data follows) */
  57. #define ENC_WCR (0x40) /* Write Control Register
  58. * 010 | aaaaa | dddddddd */
  59. #define ENC_WBM (0x7a) /* Write Buffer Memory
  60. * 011 | 11010 | (Write buffer data follows) */
  61. #define ENC_BFS (0x80) /* Bit Field Set
  62. * 100 | aaaaa | dddddddd */
  63. #define ENC_BFC (0xa0) /* Bit Field Clear
  64. * 101 | aaaaa | dddddddd */
  65. #define ENC_SRC (0xff) /* System Reset
  66. * 111 | 11111 | (No data) */
  67. /* Global Control Registers *************************************************/
  68. /* Control registers are accessed with the RCR, RBM, WCR, BFS, and BFC
  69. * commands. The following identifies all ENC28J60 control registers. The
  70. * control register memory is partitioned into four banks, selectable by the
  71. * bank select bits, BSEL1:BSEL0, in the ECON1 register.
  72. *
  73. * The last five locations (0x1b to 0x1f) of all banks point to a common set
  74. * of registers: EIE, EIR, ESTAT, ECON2 and ECON1. These are key registers
  75. * used in controlling and monitoring the operation of the device. Their
  76. * common mapping allows easy access without switching the bank.
  77. *
  78. * Control registers for the ENC28J60 are generically grouped as ETH, MAC and
  79. * MII registers. Register names starting with E belong to the ETH group.
  80. * Similarly, registers names starting with MA belong to the MAC group and
  81. * registers prefixed with MI belong to the MII group.
  82. */
  83. #define ENC_EIE (0x1b) /* Ethernet Interrupt Enable Register */
  84. #define ENC_EIR (0x1c) /* Ethernet Interupt Request Register */
  85. #define ENC_ESTAT (0x1d) /* Ethernet Status Register */
  86. #define ENC_ECON2 (0x1e) /* Ethernet Control 2 Register */
  87. #define ENC_ECON1 (0x1f) /* Ethernet Control 1 Register */
  88. /* Ethernet Interrupt Enable Register Bit Definitions */
  89. #define EIE_RXERIE (1 << 0) /* Bit 0: Receive Error Interrupt Enable */
  90. #define EIE_TXERIE (1 << 1) /* Bit 1: Transmit Error Interrupt Enable */
  91. /* Bit 2: Reserved */
  92. #define EIE_TXIE (1 << 3) /* Bit 3: Transmit Enable */
  93. #define EIE_LINKIE (1 << 4) /* Bit 4: Link Status Change Interrupt Enable */
  94. #define EIE_DMAIE (1 << 5) /* Bit 5: DMA Interrupt Enable */
  95. #define EIE_PKTIE (1 << 6) /* Bit 6: Receive Packet Pending Interrupt Enable */
  96. #define EIE_INTIE (1 << 7) /* Bit 7: Global INT Interrupt Enable */
  97. /* Ethernet Interrupt Request Register Bit Definitions */
  98. #define EIR_RXERIF (1 << 0) /* Bit 0: Receive Error Interrupt */
  99. #define EIR_TXERIF (1 << 1) /* Bit 1: Transmit Error Interrupt */
  100. /* Bit 2: Reserved */
  101. #define EIR_TXIF (1 << 3) /* Bit 3: Transmit Interrupt */
  102. #define EIR_LINKIF (1 << 4) /* Bit 4: Link Change Interrupt */
  103. #define EIR_DMAIF (1 << 5) /* Bit 5: DMA Interrupt */
  104. #define EIR_PKTIF (1 << 6) /* Bit 6: Receive Packet Pending Interrupt */
  105. /* Bit 7: Reserved */
  106. #define EIR_ALLINTS (0x7b) /* All interrupts */
  107. /* Ethernet Status Register Bit Definitions */
  108. #define ESTAT_CLKRDY (1 << 0) /* Bit 0: Clock Ready */
  109. #define ESTAT_TXABRT (1 << 1) /* Bit 1: Transmit Abort Error */
  110. #define ESTAT_RXBUSY (1 << 2) /* Bit 2: Receive Busy */
  111. /* Bit 3: Reserved */
  112. #define ESTAT_LATECOL (1 << 4) /* Bit 4: Late Collision Error */
  113. /* Bit 5: Reserved */
  114. #define ESTAT_BUFER (1 << 6) /* Bit 6: Ethernet Buffer Error Status */
  115. #define ESTAT_INT (1 << 7) /* Bit 7: INT Interrupt */
  116. /* Ethernet Control 1 Register Bit Definitions */
  117. #define ECON1_BSEL_SHIFT (0) /* Bits 0-1: Bank select */
  118. #define ECON1_BSEL_MASK (3 << ECON1_BSEL_SHIFT)
  119. # define ECON1_BSEL_BANK0 (0 << ECON1_BSEL_SHIFT) /* Bank 0 */
  120. # define ECON1_BSEL_BANK1 (1 << ECON1_BSEL_SHIFT) /* Bank 1 */
  121. # define ECON1_BSEL_BANK2 (2 << ECON1_BSEL_SHIFT) /* Bank 2 */
  122. # define ECON1_BSEL_BANK3 (3 << ECON1_BSEL_SHIFT) /* Bank 3 */
  123. #define ECON1_RXEN (1 << 2) /* Bit 2: Receive Enable */
  124. #define ECON1_TXRTS (1 << 3) /* Bit 3: Transmit Request to Send */
  125. #define ECON1_CSUMEN (1 << 4) /* Bit 4: DMA Checksum Enable */
  126. #define ECON1_DMAST (1 << 5) /* Bit 5: DMA Start and Busy Status */
  127. #define ECON1_RXRST (1 << 6) /* Bit 6: Receive Logic Reset */
  128. #define ECON1_TXRST (1 << 7) /* Bit 7: Transmit Logic Reset */
  129. /* Ethernet Control 2 Register */
  130. /* Bits 0-2: Reserved */
  131. #define ECON2_VRPS (1 << 3) /* Bit 3: Voltage Regulator Power Save Enable */
  132. /* Bit 4: Reserved */
  133. #define ECON2_PWRSV (1 << 5) /* Bit 5: Power Save Enable */
  134. #define ECON2_PKTDEC (1 << 6) /* Bit 6: Packet Decrement */
  135. #define ECON2_AUTOINC (1 << 7) /* Bit 7: Automatic Buffer Pointer Increment Enable */
  136. /* Banked Control Registers *************************************************/
  137. /* The remaining control registers are identified with a a 5 bit address and
  138. * a bank selection. We pack the bank number and an indication if this is
  139. * a MAC/PHY register access together with the control register address
  140. * together to keep the design simpler.
  141. */
  142. #define ENC_ADDR_SHIFT (0) /* Bits 0-4: Register address */
  143. #define ENC_ADDR_MASK (0x1f << ENC_ADDR_SHIFT)
  144. #define ENC_BANK_SHIFT (5) /* Bits 5-6: Bank number */
  145. #define ENC_BANK_MASK (3 << ENC_BSEL_SHIFT)
  146. # define ENC_BANK0 (0 << ENC_BSEL_SHIFT)
  147. # define ENC_BANK1 (1 << ENC_BSEL_SHIFT)
  148. # define ENC_BANK2 (2 << ENC_BSEL_SHIFT)
  149. # define ENC_BANK3 (3 << ENC_BSEL_SHIFT)
  150. #define ENC_PHYMAC_SHIFT (7) /* Bit 7: This is a PHY/MAC command */
  151. #define ENC_PHYMAC (1 << ENC_PHYMAC_SHIFT)
  152. #define REGADDR(a,b,m) ((m) << ENC_PHYMAC_SHIFT | (b) << ENC_BANK_SHIFT | (a))
  153. #define GETADDR(a) ((a) & ENC_ADDR_MASK)
  154. #define GETBANK(a) (((a) >> ENC_BANK_SHIFT) & 3)
  155. #define ISPHYMAC(a) (((a) & ENC_PHYMAC) != 0)
  156. /* Bank 0 Control Register Addresses */
  157. #define ENC_ERDPTL REGADDR(0x00, 0, 0) /* Read Pointer Low Byte (ERDPT<7:0> */
  158. #define ENC_ERDPTH REGADDR(0x01, 0, 0) /* Read Pointer High Byte (ERDPT<12:8>) */
  159. #define ENC_EWRPTL REGADDR(0x02, 0, 0) /* Write Pointer Low Byte (EWRPT<7:0>) */
  160. #define ENC_EWRPTH REGADDR(0x03, 0, 0) /* Write Pointer High Byte (EWRPT<12:8>) */
  161. #define ENC_ETXSTL REGADDR(0x04, 0, 0) /* TX Start Low Byte (ETXST<7:0>) */
  162. #define ENC_ETXSTH REGADDR(0x05, 0, 0) /* TX Start High Byte (ETXST<12:8>) */
  163. #define ENC_ETXNDL REGADDR(0x06, 0, 0) /* TX End Low Byte (ETXND<7:0>) */
  164. #define ENC_ETXNDH REGADDR(0x07, 0, 0) /* TX End High Byte (ETXND<12:8>) */
  165. #define ENC_ERXSTL REGADDR(0x08, 0, 0) /* RX Start Low Byte (ERXST<7:0>) */
  166. #define ENC_ERXSTH REGADDR(0x09, 0, 0) /* RX Start High Byte (ERXST<12:8>) */
  167. #define ENC_ERXNDL REGADDR(0x0a, 0, 0) /* RX End Low Byte (ERXND<7:0>) */
  168. #define ENC_ERXNDH REGADDR(0x0b, 0, 0) /* RX End High Byte (ERXND<12:8>) */
  169. #define ENC_ERXRDPTL REGADDR(0x0c, 0, 0) /* RX RD Pointer Low Byte (ERXRDPT<7:0>) */
  170. #define ENC_ERXRDPTH REGADDR(0x0d, 0, 0) /* RX RD Pointer High Byte (ERXRDPT<12:8>) */
  171. #define ENC_ERXWRPTL REGADDR(0x0e, 0, 0) /* RX WR Pointer Low Byte (ERXWRPT<7:0>) */
  172. #define ENC_ERXWRPTH REGADDR(0x0f, 0, 0) /* RX WR Pointer High Byte (ERXWRPT<12:8>) */
  173. #define ENC_EDMASTL REGADDR(0x10, 0, 0) /* DMA Start Low Byte (EDMAST<7:0>) */
  174. #define ENC_EDMASTH REGADDR(0x11, 0, 0) /* DMA Start High Byte (EDMAST<12:8>) */
  175. #define ENC_EDMANDL REGADDR(0x12, 0, 0) /* DMA End Low Byte (EDMAND<7:0>) */
  176. #define ENC_EDMANDH REGADDR(0x13, 0, 0) /* DMA End High Byte (EDMAND<12:8>) */
  177. #define ENC_EDMADSTL REGADDR(0x14, 0, 0) /* DMA Destination Low Byte (EDMADST<7:0>) */
  178. #define ENC_EDMADSTH REGADDR(0x15, 0, 0) /* DMA Destination High Byte (EDMADST<12:8>) */
  179. #define ENC_EDMACSL REGADDR(0x16, 0, 0) /* DMA Checksum Low Byte (EDMACS<7:0>) */
  180. #define ENC_EDMACSH REGADDR(0x17, 0, 0) /* DMA Checksum High Byte (EDMACS<15:8>) */
  181. /* 0x18-0x1a: Reserved */
  182. /* 0x1b-0x1f: EIE, EIR, ESTAT, ECON2, ECON1 */
  183. /* Bank 1 Control Register Addresses */
  184. #define ENC_EHT0 REGADDR(0x00, 1, 0) /* Hash Table Byte 0 (EHT<7:0>) */
  185. #define ENC_EHT1 REGADDR(0x01, 1, 0) /* Hash Table Byte 1 (EHT<15:8>) */
  186. #define ENC_EHT2 REGADDR(0x02, 1, 0) /* Hash Table Byte 2 (EHT<23:16>) */
  187. #define ENC_EHT3 REGADDR(0x03, 1, 0) /* Hash Table Byte 3 (EHT<31:24>) */
  188. #define ENC_EHT4 REGADDR(0x04, 1, 0) /* Hash Table Byte 4 (EHT<39:32>) */
  189. #define ENC_EHT5 REGADDR(0x05, 1, 0) /* Hash Table Byte 5 (EHT<47:40>) */
  190. #define ENC_EHT6 REGADDR(0x06, 1, 0) /* Hash Table Byte 6 (EHT<55:48>) */
  191. #define ENC_EHT7 REGADDR(0x07, 1, 0) /* Hash Table Byte 7 (EHT<63:56>) */
  192. #define ENC_EPMM0 REGADDR(0x08, 1, 0) /* Pattern Match Mask Byte 0 (EPMM<7:0>) */
  193. #define ENC_EPMM1 REGADDR(0x09, 1, 0) /* Pattern Match Mask Byte 1 (EPMM<15:8>) */
  194. #define ENC_EPMM2 REGADDR(0x0a, 1, 0) /* Pattern Match Mask Byte 2 (EPMM<23:16>) */
  195. #define ENC_EPMM3 REGADDR(0x0b, 1, 0) /* Pattern Match Mask Byte 3 (EPMM<31:24>) */
  196. #define ENC_EPMM4 REGADDR(0x0c, 1, 0) /* Pattern Match Mask Byte 4 (EPMM<39:32>) */
  197. #define ENC_EPMM5 REGADDR(0x0d, 1, 0) /* Pattern Match Mask Byte 5 (EPMM<47:40>) */
  198. #define ENC_EPMM6 REGADDR(0x0e, 1, 0) /* Pattern Match Mask Byte 6 (EPMM<55:48>) */
  199. #define ENC_EPMM7 REGADDR(0x0f, 1, 0) /* Pattern Match Mask Byte 7 (EPMM<63:56>) */
  200. #define ENC_EPMCSL REGADDR(0x10, 1, 0) /* Pattern Match Checksum Low Byte (EPMCS<7:0>) */
  201. #define ENC_EPMCSH REGADDR(0x11, 1, 0) /* Pattern Match Checksum High Byte (EPMCS<15:0>) */
  202. /* 0x12-0x13: Reserved */
  203. #define ENC_EPMOL REGADDR(0x14, 1, 0) /* Pattern Match Offset Low Byte (EPMO<7:0>) */
  204. #define ENC_EPMOH REGADDR(0x15, 1, 0) /* Pattern Match Offset High Byte (EPMO<12:8>) */
  205. /* 0x16-0x17: Reserved */
  206. #define ENC_ERXFCON REGADDR(0x18, 1, 0) /* Receive Filter Configuration */
  207. #define ENC_EPKTCNT REGADDR(0x19, 1, 0) /* Ethernet Packet Count */
  208. /* 0x1a: Reserved */
  209. /* 0x1b-0x1f: EIE, EIR, ESTAT, ECON2, ECON1 */
  210. /* Receive Filter Configuration Bit Definitions */
  211. #define ERXFCON_BCEN (1 << 0) /* Bit 0: Broadcast Filter Enable */
  212. #define ERXFCON_MCEN (1 << 1) /* Bit 1: Multicast Filter Enable */
  213. #define ERXFCON_HTEN (1 << 2) /* Bit 2: Hash Table Filter Enable */
  214. #define ERXFCON_MPEN (1 << 3) /* Bit 3: Magic Packet Filter Enable */
  215. #define ERXFCON_PMEN (1 << 4) /* Bit 4: Pattern Match Filter Enable */
  216. #define ERXFCON_CRCEN (1 << 5) /* Bit 5: Post-Filter CRC Check Enable */
  217. #define ERXFCON_ANDOR (1 << 6) /* Bit 6: AND/OR Filter Select */
  218. #define ERXFCON_UCEN (1 << 7) /* Bit 7: Unicast Filter Enable */
  219. /* Bank 2 Control Register Addresses */
  220. #define ENC_MACON1 REGADDR(0x00, 2, 1) /* MAC Control 1 */
  221. /* 0x01: Reserved */
  222. #define ENC_MACON3 REGADDR(0x02, 2, 1) /* MAC Control 3 */
  223. #define ENC_MACON4 REGADDR(0x03, 2, 1) /* MAC Control 4 */
  224. #define ENC_MABBIPG REGADDR(0x04, 2, 1) /* Back-to-Back Inter-Packet Gap (BBIPG<6:0>) */
  225. /* 0x05: Reserved */
  226. #define ENC_MAIPGL REGADDR(0x06, 2, 1) /* Non-Back-to-Back Inter-Packet Gap Low Byte (MAIPGL<6:0>) */
  227. #define ENC_MAIPGH REGADDR(0x07, 2, 1) /* Non-Back-to-Back Inter-Packet Gap High Byte (MAIPGH<6:0>) */
  228. #define ENC_MACLCON1 REGADDR(0x08, 2, 1) /* MAC Collision Control 1 */
  229. #define ENC_MACLCON2 REGADDR(0x09, 2, 1) /* MAC Collision Control 2 */
  230. #define ENC_MAMXFLL REGADDR(0x0a, 2, 1) /* Maximum Frame Length Low Byte (MAMXFL<7:0>) */
  231. #define ENC_MAMXFLH REGADDR(0x0b, 2, 1) /* Maximum Frame Length High Byte (MAMXFL<15:8>) */
  232. /* 0x0c-0x11: Reserved */
  233. #define ENC_MICMD REGADDR(0x12, 2, 1) /* MII Command Register */
  234. /* 0x13: Reserved */
  235. #define ENC_MIREGADR REGADDR(0x14, 2, 1) /* MII Register Address */
  236. /* 0x15: Reserved */
  237. #define ENC_MIWRL REGADDR(0x16, 2, 1) /* MII Write Data Low Byte (MIWR<7:0>) */
  238. #define ENC_MIWRH REGADDR(0x17, 2, 1) /* MII Write Data High Byte (MIWR<15:8>) */
  239. #define ENC_MIRDL REGADDR(0x18, 2, 1) /* MII Read Data Low Byte (MIRD<7:0>) */
  240. #define ENC_MIRDH REGADDR(0x19, 2, 1) /* MII Read Data High Byte(MIRD<15:8>) */
  241. /* 0x1a: Reserved */
  242. /* 0x1b-0x1f: EIE, EIR, ESTAT, ECON2, ECON1 */
  243. /* MAC Control 1 Register Bit Definitions */
  244. #define MACON1_MARXEN (1 << 0) /* Bit 0: MAC Receive Enable */
  245. #define MACON1_PASSALL (1 << 1) /* Bit 1: Pass All Received Frames Enable */
  246. #define MACON1_RXPAUS (1 << 2) /* Bit 2: Pause Control Frame Reception Enable */
  247. #define MACON1_TXPAUS (1 << 3) /* Bit 3: Pause Control Frame Transmission Enable */
  248. /* Bits 4-7: Unimplemented or reserved */
  249. /* MAC Control 1 Register Bit Definitions */
  250. #define MACON3_FULDPX (1 << 0) /* Bit 0: MAC Full-Duplex Enable */
  251. #define MACON3_FRMLNEN (1 << 1) /* Bit 1: Frame Length Checking Enable */
  252. #define MACON3_HFRMLEN (1 << 2) /* Bit 2: Huge Frame Enable */
  253. #define MACON3_PHDRLEN (1 << 3) /* Bit 3: Proprietary Header Enable */
  254. #define MACON3_TXCRCEN (1 << 4) /* Bit 4: Transmit CRC Enable */
  255. #define MACON3_PADCFG0 (1 << 5) /* Bit 5: Automatic Pad and CRC Configuration */
  256. #define MACON3_PADCFG1 (1 << 6) /* Bit 6: " " " " " " " " " " */
  257. #define MACON3_PADCFG2 (1 << 7) /* Bit 7: " " " " " " " " " " */
  258. /* MAC Control 1 Register Bit Definitions */
  259. #define MACON4_NOBKOFF (1 << 4) /* Bit 4: No Backoff Enable */
  260. #define MACON4_BPEN (1 << 5) /* Bit 5: No Backoff During Backpressure Enable */
  261. #define MACON4_DEFER (1 << 6) /* Bit 6: Defer Transmission Enable bit */
  262. /* MII Command Register Bit Definitions */
  263. #define MICMD_MIIRD (1 << 0) /* Bit 0: MII Read Enable */
  264. #define MICMD_MIISCAN (1 << 1) /* Bit 1: MII Scan Enable */
  265. /* Bank 3 Control Register Addresses */
  266. #define ENC_MAADR5 REGADDR(0x00, 3, 1) /* MAC Address Byte 5 (MAADR<15:8>) */
  267. #define ENC_MAADR6 REGADDR(0x01, 3, 1) /* MAC Address Byte 6 (MAADR<7:0>) */
  268. #define ENC_MAADR3 REGADDR(0x02, 3, 1) /* MAC Address Byte 3 (MAADR<31:24>), OUI Byte 3 */
  269. #define ENC_MAADR4 REGADDR(0x03, 3, 1) /* MAC Address Byte 4 (MAADR<23:16>) */
  270. #define ENC_MAADR1 REGADDR(0x04, 3, 1) /* MAC Address Byte 1 (MAADR<47:40>), OUI Byte 1 */
  271. #define ENC_MAADR2 REGADDR(0x05, 3, 1) /* MAC Address Byte 2 (MAADR<39:32>), OUI Byte 2 */
  272. #define ENC_EBSTSD REGADDR(0x06, 3, 0) /* Built-in Self-Test Fill Seed (EBSTSD<7:0>) */
  273. #define ENC_EBSTCON REGADDR(0x07, 3, 0) /* Built-in Self-Test Control */
  274. #define ENC_EBSTCSL REGADDR(0x08, 3, 0) /* Built-in Self-Test Checksum Low Byte (EBSTCS<7:0>) */
  275. #define ENC_EBSTCSH REGADDR(0x09, 3, 0) /* Built-in Self-Test Checksum High Byte (EBSTCS<15:8>) */
  276. #define ENC_MISTAT REGADDR(0x0a, 3, 1) /* MII Status Register */
  277. /* 0x0b-0x11: Reserved */
  278. #define ENC_EREVID REGADDR(0x12, 3, 0) /* Ethernet Revision ID */
  279. /* 0x13-0x14: Reserved */
  280. #define ENC_ECOCON REGADDR(0x15, 3, 0) /* Clock Output Control */
  281. /* 0x16: Reserved */
  282. #define ENC_EFLOCON REGADDR(0x17, 3, 0) /* Ethernet Flow Control */
  283. #define ENC_EPAUSL REGADDR(0x18, 3, 0) /* Pause Timer Value Low Byte (EPAUS<7:0>) */
  284. #define ENC_EPAUSH REGADDR(0x19, 3, 0) /* Pause Timer Value High Byte (EPAUS<15:8>) */
  285. /* 0x1a: Reserved */
  286. /* 0x1b-0x1f: EIE, EIR, ESTAT, ECON2, ECON1 */
  287. /* Built-in Self-Test Control Register Bit Definitions */
  288. #define EBSTCON_BISTST (1 << 0) /* Bit 0: Built-in Self-Test Start/Busy */
  289. #define EBSTCON_TME (1 << 1) /* Bit 1: Test Mode Enable */
  290. #define EBSTCON_TMSEL0 (1 << 2) /* Bit 2: Test Mode Select */
  291. #define EBSTCON_TMSEL1 (1 << 3) /* Bit 3: " " " " " " */
  292. #define EBSTCON_PSEL (1 << 4) /* Bit 4: Port Select */
  293. #define EBSTCON_PSV0 (1 << 5) /* Bit 5: Pattern Shift Value */
  294. #define EBSTCON_PSV1 (1 << 6) /* Bit 6: " " " " " */
  295. #define EBSTCON_PSV2 (1 << 7) /* Bit 7: " " " " " */
  296. /* MII Status Register Register Bit Definitions */
  297. #define MISTAT_BUSY (1 << 0) /* Bit 0: MII Management Busy */
  298. #define MISTAT_SCAN (1 << 1) /* Bit 1: MII Management Scan Operation */
  299. #define MISTAT_NVALID (1 << 2) /* Bit 2: MII Management Read Data Not Valid */
  300. /* Bits 3-7: Reserved or unimplemented */
  301. /* Ethernet Flow Control Register Bit Definitions */
  302. #define EFLOCON_FCEN0 (1 << 0) /* Bit 0: Flow Control Enable */
  303. #define EFLOCON_FCEN1 (1 << 1) /* Bit 1: " " " " " " */
  304. #define EFLOCON_FULDPXS (1 << 2) /* Bit 2: Read-Only MAC Full-Duplex Shadow */
  305. /* Bits 3-7: Reserved or unimplemented */
  306. /* PHY Registers ************************************************************/
  307. #define ENC_PHCON1 (0x00) /* PHY Control Register 1 */
  308. #define ENC_PHSTAT1 (0x01) /* PHY Status 1 */
  309. #define ENC_PHID1 (0x02) /* PHY ID Register 1 */
  310. #define ENC_PHID2 (0x03) /* PHY ID Register 2 */
  311. #define ENC_PHCON2 (0x10) /* PHY Control Register 2 */
  312. #define ENC_PHSTAT2 (0x11) /* PHY Status 2 */
  313. #define ENC_PHIE (0x12) /* PHY Interrupt Enable Register */
  314. #define ENC_PHIR (0x13) /* PHY Interrupt Request Register */
  315. #define ENC_PHLCON (0x14)
  316. /* PHY Control Register 1 Register Bit Definitions */
  317. #define PHCON1_PDPXMD (1 << 8) /* Bit 8: PHY Duplex Mode */
  318. #define PHCON1_PPWRSV (1 << 11) /* Bit 11: PHY Power-Down */
  319. #define PHCON1_PLOOPBK (1 << 14) /* Bit 14: PHY Loopback */
  320. #define PHCON1_PRST (1 << 15) /* Bit 15: PHY Software Reset */
  321. /* PHY Status 1 Register Bit Definitions */
  322. #define PHSTAT1_JBSTAT (1 << 1) /* Bit 1: PHY Latching Jabber Status */
  323. #define PHSTAT1_LLSTAT (1 << 2) /* Bit 2: PHY Latching Link Status */
  324. #define PHSTAT1_PHDPX (1 << 11) /* Bit 11: PHY Half-Duplex Capable */
  325. #define PHSTAT1_PFDPX (1 << 12) /* Bit 12: PHY Full-Duplex Capable */
  326. /* PHY Control Register 2 Register Bit Definitions */
  327. #define PHCON2_HDLDIS (1 << 8) /* Bit 8: PHY Half-Duplex Loopback Disable */
  328. #define PHCON2_JABBER (1 << 10) /* Bit 10: Jabber Correction Disable */
  329. #define PHCON2_TXDIS (1 << 13) /* Bit 13: Twisted-Pair Transmitter Disable */
  330. #define PHCON2_FRCLINK (1 << 14) /* Bit 14: PHY Force Linkup */
  331. /* PHY Status 2 Register Bit Definitions */
  332. #define PHSTAT2_PLRITY (1 << 5) /* Bit 5: Polarity Status */
  333. #define PHSTAT2_DPXSTAT (1 << 9) /* Bit 9: PHY Duplex Status */
  334. #define PHSTAT2_LSTAT (1 << 10) /* Bit 10: PHY Link Status */
  335. #define PHSTAT2_COLSTAT (1 << 11) /* Bit 11: PHY Collision Status */
  336. #define PHSTAT2_RXSTAT (1 << 12) /* Bit 12: PHY Receive Status */
  337. #define PHSTAT2_TXSTAT (1 << 13) /* Bit 13: PHY Transmit Status */
  338. /* PHY Interrupt Enable Register Bit Definitions */
  339. #define PHIE_PGEIE (1 << 1) /* Bit 1: PHY Global Interrupt Enable */
  340. #define PHIE_PLNKIE (1 << 4) /* Bit 4: PHY Link Change Interrupt Enable */
  341. /* PHIR Regiser Bit Definitions */
  342. #define PHIR_PGIF (1 << 2) /* Bit 2: PHY Global Interrupt */
  343. #define PHIR_PLNKIF (1 << 4) /* Bit 4: PHY Link Change Interrupt */
  344. /* PHLCON Regiser Bit Definitions */
  345. /* Bit 0: Reserved */
  346. #define PHLCON_STRCH (1 << 1) /* Bit 1: LED Pulse Stretching Enable */
  347. #define PHLCON_LFRQ0 (1 << 2) /* Bit 2: LED Pulse Stretch Time Configuration */
  348. #define PHLCON_LFRQ1 (1 << 3) /* Bit 3: " " " " " " " " " */
  349. #define PHLCON_LBCFG0 (1 << 4) /* Bit 4: LEDB Configuration */
  350. #define PHLCON_LBCFG1 (1 << 5) /* Bit 5: " " " " */
  351. #define PHLCON_LBCFG2 (1 << 6) /* Bit 6: " " " " */
  352. #define PHLCON_LBCFG3 (1 << 7) /* Bit 7: " " " " */
  353. #define PHLCON_LACFG0 (1 << 8) /* Bit 8: LEDA Configuration */
  354. #define PHLCON_LACFG1 (1 << 9) /* Bit 9: " " " " */
  355. #define PHLCON_LACFG2 (1 << 10) /* Bit 10: " " " " */
  356. #define PHLCON_LACFG3 (1 << 11) /* Bit 11: " " " " */
  357. /* Packet Memory ************************************************************/
  358. /* 8-Kbyte Transmit/Receive Packet Dual Port SRAM */
  359. #define PKTMEM_START 0x0000
  360. #define PKTMEM_END 0x1fff
  361. /* Ethernet frames are between 64 and 1518 bytes long */
  362. #define MIN_FRAMELEN 64
  363. #define MAX_FRAMELEN 1518
  364. /* Packet Control Bits Definitions ******************************************/
  365. #define PKTCTRL_POVERRIDE (1 << 0) /* Bit 0: Per Packet Override */
  366. #define PKTCTRL_PCRCEN (1 << 1) /* Bit 1: Per Packet CRC Enable */
  367. #define PKTCTRL_PPADEN (1 << 2) /* Bit 2: Per Packet Padding Enable */
  368. #define PKTCTRL_PHUGEEN (1 << 3) /* Bit 3: Per Packet Huge Frame Enable */
  369. /* RX Status Bit Definitions ************************************************/
  370. #define RXSTAT_LDEVENT (1 << 0) /* Bit 0: Long event or pack dropped */
  371. /* Bit 1: Reserved */
  372. #define RXSTAT_CEPS (1 << 2) /* Bit 2: Carrier event previously seen */
  373. /* Bit 3: Reserved */
  374. #define RXSTAT_CRCERROR (1 << 4) /* Bit 4: Frame CRC field bad */
  375. #define RXSTAT_LENERROR (1 << 5) /* Bit 5: Packet length != data length */
  376. #define RXSTAT_LENRANGE (1 << 6) /* Bit 6: Type/length field > 1500 bytes */
  377. #define RXSTAT_OK (1 << 7) /* Bit 7: Packet with valid CRC and no symbol errors */
  378. #define RXSTAT_MCAST (1 << 8) /* Bit 8: Packet with multicast address */
  379. #define RXSTAT_BCAST (1 << 9) /* Bit 9: Packet with broadcast address */
  380. #define RXSTAT_DRIBBLE (1 << 10) /* Bit 10: Additional bits received after packet */
  381. #define RXSTAT_CTRLFRAME (1 << 11) /* Bit 11: Control frame with valid type/length */
  382. #define RXSTAT_PAUSE (1 << 12) /* Bit 12: Control frame with pause frame opcde */
  383. #define RXSTAT_UNKOPCODE (1 << 13) /* Bit 13: Control frame with unknown opcode */
  384. #define RXSTAT_VLANTYPE (1 << 14) /* Bit 14: Current frame is a VLAN tagged frame */
  385. /* Bit 15: Zero */
  386. /****************************************************************************
  387. * Public Types
  388. ****************************************************************************/
  389. /****************************************************************************
  390. * Public Data
  391. ****************************************************************************/
  392. #ifdef __cplusplus
  393. #define EXTERN extern "C"
  394. extern "C" {
  395. #else
  396. #define EXTERN extern
  397. #endif
  398. /****************************************************************************
  399. * Public Function Prototypes
  400. ****************************************************************************/
  401. #undef EXTERN
  402. #ifdef __cplusplus
  403. }
  404. #endif
  405. #endif /* __DRIVERS_NET_ENC28J60_H */