enc28j60.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. * (X) extracted from enc28j60.c
  3. * Reinhard Meyer, EMK Elektronik, reinhard.meyer@emk-elektronik.de
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef _enc28j60_h
  8. #define _enc28j60_h
  9. /*
  10. * SPI Commands
  11. *
  12. * Bits 7-5: Command
  13. * Bits 4-0: Register
  14. */
  15. #define CMD_RCR(x) (0x00+((x)&0x1f)) /* Read Control Register */
  16. #define CMD_RBM 0x3a /* Read Buffer Memory */
  17. #define CMD_WCR(x) (0x40+((x)&0x1f)) /* Write Control Register */
  18. #define CMD_WBM 0x7a /* Write Buffer Memory */
  19. #define CMD_BFS(x) (0x80+((x)&0x1f)) /* Bit Field Set */
  20. #define CMD_BFC(x) (0xa0+((x)&0x1f)) /* Bit Field Clear */
  21. #define CMD_SRC 0xff /* System Reset Command */
  22. /* NEW: encode (bank number+1) in upper byte */
  23. /* Common Control Registers accessible in all Banks */
  24. #define CTL_REG_EIE 0x01B
  25. #define CTL_REG_EIR 0x01C
  26. #define CTL_REG_ESTAT 0x01D
  27. #define CTL_REG_ECON2 0x01E
  28. #define CTL_REG_ECON1 0x01F
  29. /* Control Registers accessible in Bank 0 */
  30. #define CTL_REG_ERDPTL 0x100
  31. #define CTL_REG_ERDPTH 0x101
  32. #define CTL_REG_EWRPTL 0x102
  33. #define CTL_REG_EWRPTH 0x103
  34. #define CTL_REG_ETXSTL 0x104
  35. #define CTL_REG_ETXSTH 0x105
  36. #define CTL_REG_ETXNDL 0x106
  37. #define CTL_REG_ETXNDH 0x107
  38. #define CTL_REG_ERXSTL 0x108
  39. #define CTL_REG_ERXSTH 0x109
  40. #define CTL_REG_ERXNDL 0x10A
  41. #define CTL_REG_ERXNDH 0x10B
  42. #define CTL_REG_ERXRDPTL 0x10C
  43. #define CTL_REG_ERXRDPTH 0x10D
  44. #define CTL_REG_ERXWRPTL 0x10E
  45. #define CTL_REG_ERXWRPTH 0x10F
  46. #define CTL_REG_EDMASTL 0x110
  47. #define CTL_REG_EDMASTH 0x111
  48. #define CTL_REG_EDMANDL 0x112
  49. #define CTL_REG_EDMANDH 0x113
  50. #define CTL_REG_EDMADSTL 0x114
  51. #define CTL_REG_EDMADSTH 0x115
  52. #define CTL_REG_EDMACSL 0x116
  53. #define CTL_REG_EDMACSH 0x117
  54. /* Control Registers accessible in Bank 1 */
  55. #define CTL_REG_EHT0 0x200
  56. #define CTL_REG_EHT1 0x201
  57. #define CTL_REG_EHT2 0x202
  58. #define CTL_REG_EHT3 0x203
  59. #define CTL_REG_EHT4 0x204
  60. #define CTL_REG_EHT5 0x205
  61. #define CTL_REG_EHT6 0x206
  62. #define CTL_REG_EHT7 0x207
  63. #define CTL_REG_EPMM0 0x208
  64. #define CTL_REG_EPMM1 0x209
  65. #define CTL_REG_EPMM2 0x20A
  66. #define CTL_REG_EPMM3 0x20B
  67. #define CTL_REG_EPMM4 0x20C
  68. #define CTL_REG_EPMM5 0x20D
  69. #define CTL_REG_EPMM6 0x20E
  70. #define CTL_REG_EPMM7 0x20F
  71. #define CTL_REG_EPMCSL 0x210
  72. #define CTL_REG_EPMCSH 0x211
  73. #define CTL_REG_EPMOL 0x214
  74. #define CTL_REG_EPMOH 0x215
  75. #define CTL_REG_EWOLIE 0x216
  76. #define CTL_REG_EWOLIR 0x217
  77. #define CTL_REG_ERXFCON 0x218
  78. #define CTL_REG_EPKTCNT 0x219
  79. /* Control Registers accessible in Bank 2 */
  80. #define CTL_REG_MACON1 0x300
  81. #define CTL_REG_MACON2 0x301
  82. #define CTL_REG_MACON3 0x302
  83. #define CTL_REG_MACON4 0x303
  84. #define CTL_REG_MABBIPG 0x304
  85. #define CTL_REG_MAIPGL 0x306
  86. #define CTL_REG_MAIPGH 0x307
  87. #define CTL_REG_MACLCON1 0x308
  88. #define CTL_REG_MACLCON2 0x309
  89. #define CTL_REG_MAMXFLL 0x30A
  90. #define CTL_REG_MAMXFLH 0x30B
  91. #define CTL_REG_MAPHSUP 0x30D
  92. #define CTL_REG_MICON 0x311
  93. #define CTL_REG_MICMD 0x312
  94. #define CTL_REG_MIREGADR 0x314
  95. #define CTL_REG_MIWRL 0x316
  96. #define CTL_REG_MIWRH 0x317
  97. #define CTL_REG_MIRDL 0x318
  98. #define CTL_REG_MIRDH 0x319
  99. /* Control Registers accessible in Bank 3 */
  100. #define CTL_REG_MAADR1 0x400
  101. #define CTL_REG_MAADR0 0x401
  102. #define CTL_REG_MAADR3 0x402
  103. #define CTL_REG_MAADR2 0x403
  104. #define CTL_REG_MAADR5 0x404
  105. #define CTL_REG_MAADR4 0x405
  106. #define CTL_REG_EBSTSD 0x406
  107. #define CTL_REG_EBSTCON 0x407
  108. #define CTL_REG_EBSTCSL 0x408
  109. #define CTL_REG_EBSTCSH 0x409
  110. #define CTL_REG_MISTAT 0x40A
  111. #define CTL_REG_EREVID 0x412
  112. #define CTL_REG_ECOCON 0x415
  113. #define CTL_REG_EFLOCON 0x417
  114. #define CTL_REG_EPAUSL 0x418
  115. #define CTL_REG_EPAUSH 0x419
  116. /* PHY Register */
  117. #define PHY_REG_PHCON1 0x00
  118. #define PHY_REG_PHSTAT1 0x01
  119. #define PHY_REG_PHID1 0x02
  120. #define PHY_REG_PHID2 0x03
  121. #define PHY_REG_PHCON2 0x10
  122. #define PHY_REG_PHSTAT2 0x11
  123. #define PHY_REG_PHLCON 0x14
  124. /* Receive Filter Register (ERXFCON) bits */
  125. #define ENC_RFR_UCEN 0x80
  126. #define ENC_RFR_ANDOR 0x40
  127. #define ENC_RFR_CRCEN 0x20
  128. #define ENC_RFR_PMEN 0x10
  129. #define ENC_RFR_MPEN 0x08
  130. #define ENC_RFR_HTEN 0x04
  131. #define ENC_RFR_MCEN 0x02
  132. #define ENC_RFR_BCEN 0x01
  133. /* ECON1 Register Bits */
  134. #define ENC_ECON1_TXRST 0x80
  135. #define ENC_ECON1_RXRST 0x40
  136. #define ENC_ECON1_DMAST 0x20
  137. #define ENC_ECON1_CSUMEN 0x10
  138. #define ENC_ECON1_TXRTS 0x08
  139. #define ENC_ECON1_RXEN 0x04
  140. #define ENC_ECON1_BSEL1 0x02
  141. #define ENC_ECON1_BSEL0 0x01
  142. /* ECON2 Register Bits */
  143. #define ENC_ECON2_AUTOINC 0x80
  144. #define ENC_ECON2_PKTDEC 0x40
  145. #define ENC_ECON2_PWRSV 0x20
  146. #define ENC_ECON2_VRPS 0x08
  147. /* EIR Register Bits */
  148. #define ENC_EIR_PKTIF 0x40
  149. #define ENC_EIR_DMAIF 0x20
  150. #define ENC_EIR_LINKIF 0x10
  151. #define ENC_EIR_TXIF 0x08
  152. #define ENC_EIR_WOLIF 0x04
  153. #define ENC_EIR_TXERIF 0x02
  154. #define ENC_EIR_RXERIF 0x01
  155. /* ESTAT Register Bits */
  156. #define ENC_ESTAT_INT 0x80
  157. #define ENC_ESTAT_LATECOL 0x10
  158. #define ENC_ESTAT_RXBUSY 0x04
  159. #define ENC_ESTAT_TXABRT 0x02
  160. #define ENC_ESTAT_CLKRDY 0x01
  161. /* EIE Register Bits */
  162. #define ENC_EIE_INTIE 0x80
  163. #define ENC_EIE_PKTIE 0x40
  164. #define ENC_EIE_DMAIE 0x20
  165. #define ENC_EIE_LINKIE 0x10
  166. #define ENC_EIE_TXIE 0x08
  167. #define ENC_EIE_WOLIE 0x04
  168. #define ENC_EIE_TXERIE 0x02
  169. #define ENC_EIE_RXERIE 0x01
  170. /* MACON1 Register Bits */
  171. #define ENC_MACON1_LOOPBK 0x10
  172. #define ENC_MACON1_TXPAUS 0x08
  173. #define ENC_MACON1_RXPAUS 0x04
  174. #define ENC_MACON1_PASSALL 0x02
  175. #define ENC_MACON1_MARXEN 0x01
  176. /* MACON2 Register Bits */
  177. #define ENC_MACON2_MARST 0x80
  178. #define ENC_MACON2_RNDRST 0x40
  179. #define ENC_MACON2_MARXRST 0x08
  180. #define ENC_MACON2_RFUNRST 0x04
  181. #define ENC_MACON2_MATXRST 0x02
  182. #define ENC_MACON2_TFUNRST 0x01
  183. /* MACON3 Register Bits */
  184. #define ENC_MACON3_PADCFG2 0x80
  185. #define ENC_MACON3_PADCFG1 0x40
  186. #define ENC_MACON3_PADCFG0 0x20
  187. #define ENC_MACON3_TXCRCEN 0x10
  188. #define ENC_MACON3_PHDRLEN 0x08
  189. #define ENC_MACON3_HFRMEN 0x04
  190. #define ENC_MACON3_FRMLNEN 0x02
  191. #define ENC_MACON3_FULDPX 0x01
  192. /* MACON4 Register Bits */
  193. #define ENC_MACON4_DEFER 0x40
  194. /* MICMD Register Bits */
  195. #define ENC_MICMD_MIISCAN 0x02
  196. #define ENC_MICMD_MIIRD 0x01
  197. /* MISTAT Register Bits */
  198. #define ENC_MISTAT_NVALID 0x04
  199. #define ENC_MISTAT_SCAN 0x02
  200. #define ENC_MISTAT_BUSY 0x01
  201. /* PHID1 and PHID2 values */
  202. #define ENC_PHID1_VALUE 0x0083
  203. #define ENC_PHID2_VALUE 0x1400
  204. #define ENC_PHID2_MASK 0xFC00
  205. /* PHCON1 values */
  206. #define ENC_PHCON1_PDPXMD 0x0100
  207. /* PHSTAT1 values */
  208. #define ENC_PHSTAT1_LLSTAT 0x0004
  209. /* PHSTAT2 values */
  210. #define ENC_PHSTAT2_LSTAT 0x0400
  211. #define ENC_PHSTAT2_DPXSTAT 0x0200
  212. #endif