lan91.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. #ifndef _DEV_LAN91_H_
  2. #define _DEV_LAN91_H_
  3. /*
  4. * Copyright (C) 2003 by egnite Software GmbH.
  5. * Copyright (C) 2008 by egnite GmbH.
  6. *
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. Neither the name of the copyright holders nor the names of
  19. * contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  31. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  32. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33. * SUCH DAMAGE.
  34. *
  35. * For additional information see http://www.ethernut.de/
  36. */
  37. /*
  38. * $Id: lan91.h 4470 2012-08-20 14:06:43Z haraldkipp $
  39. */
  40. #include <dev/netbuf.h>
  41. #include <net/if_var.h>
  42. /*!
  43. * \file dev/lanc91.h
  44. * \brief Network interface controller definitions.
  45. */
  46. /*!
  47. * \addtogroup xgNicLan91
  48. */
  49. /*@{*/
  50. #ifndef LAN91_BASE_ADDR
  51. #define LAN91_BASE_ADDR 0xC000
  52. #endif
  53. /*!
  54. * \brief Bank select register.
  55. */
  56. #define LAN91_BSR (LAN91_BASE_ADDR + 0x0E)
  57. /*!
  58. * \brief Bank 0 - Transmit control register.
  59. */
  60. #define LAN91_TCR (LAN91_BASE_ADDR + 0x00)
  61. #define LAN91_TCR_SWFDUP 0x8000 /*!< \ref LAN91_TCR bit mask, enables full duplex. */
  62. #define LAN91_TCR_EPH_LOOP 0x2000 /*!< \ref LAN91_TCR bit mask, enables internal loopback. */
  63. #define LAN91_TCR_STP_SQET 0x1000 /*!< \ref LAN91_TCR bit mask, enables transmission stop on SQET error. */
  64. #define LAN91_TCR_FDUPLX 0x0800 /*!< \ref LAN91_TCR bit mask, enables receiving own frames. */
  65. #define LAN91_TCR_MON_CSN 0x0400 /*!< \ref LAN91_TCR bit mask, enables carrier monitoring. */
  66. #define LAN91_TCR_NOCRC 0x0100 /*!< \ref LAN91_TCR bit mask, disables CRC transmission. */
  67. #define LAN91_TCR_PAD_EN 0x0080 /*!< \ref LAN91_TCR bit mask, enables automatic padding. */
  68. #define LAN91_TCR_FORCOL 0x0004 /*!< \ref LAN91_TCR bit mask, forces collision. */
  69. #define LAN91_TCR_LOOP 0x0002 /*!< \ref LAN91_TCR bit mask, enables PHY loopback. */
  70. #define LAN91_TCR_TXENA 0x0001 /*!< \ref LAN91_TCR bit mask, enables transmitter. */
  71. /*!
  72. * \brief Bank 0 - EPH status register.
  73. */
  74. #define LAN91_EPHSR (LAN91_BASE_ADDR + 0x02)
  75. /*!
  76. * \brief Bank 0 - Receive control register.
  77. */
  78. #define LAN91_RCR (LAN91_BASE_ADDR + 0x04)
  79. #define LAN91_RCR_SOFT_RST 0x8000 /*!< \ref LAN91_RCR bit mask, activates software reset. */
  80. #define LAN91_RCR_FILT_CAR 0x4000 /*!< \ref LAN91_RCR bit mask, enables carrier filter. */
  81. #define LAN91_RCR_ABORT_ENB 0x2000 /*!< \ref LAN91_RCR bit mask, enables receive abort on collision. */
  82. #define LAN91_RCR_STRIP_CRC 0x0200 /*!< \ref LAN91_RCR bit mask, strips CRC. */
  83. #define LAN91_RCR_RXEN 0x0100 /*!< \ref LAN91_RCR bit mask, enables receiver. */
  84. #define LAN91_RCR_ALMUL 0x0004 /*!< \ref LAN91_RCR bit mask, multicast frames accepted when set. */
  85. #define LAN91_RCR_PRMS 0x0002 /*!< \ref LAN91_RCR bit mask, enables promiscuous mode. */
  86. #define LAN91_RCR_RX_ABORT 0x0001 /*!< \ref LAN91_RCR bit mask, set when receive was aborted. */
  87. /*!
  88. * \brief Bank 0 - Counter register.
  89. */
  90. #define LAN91_ECR (LAN91_BASE_ADDR + 0x06)
  91. /*!
  92. * \brief Bank 0 - Memory information register.
  93. */
  94. #define LAN91_MIR (LAN91_BASE_ADDR + 0x08)
  95. /*!
  96. * \brief Bank 0 - Receive / PHY control register.
  97. */
  98. #define LAN91_RPCR (LAN91_BASE_ADDR + 0x0A)
  99. #define LAN91_RPCR_SPEED 0x2000 /*!< \ref LAN91_RPCR bit mask, PHY operates at 100 Mbps. */
  100. #define LAN91_RPCR_DPLX 0x1000 /*!< \ref LAN91_RPCR bit mask, PHY operates at full duplex mode. */
  101. #define LAN91_RPCR_ANEG 0x0800 /*!< \ref LAN91_RPCR bit mask, sets PHY in auto-negotiation mode. */
  102. #define LAN91_RPCR_LEDA_PAT 0x0000 /*!< \ref LAN91_RPCR bit mask for LEDA mode. */
  103. #define LAN91_RPCR_LEDB_PAT 0x0010 /*!< \ref LAN91_RPCR bit mask for LEDB mode. */
  104. /*!
  105. * \brief Bank 1 - Configuration register.
  106. */
  107. #define LAN91_CR (LAN91_BASE_ADDR + 0x00)
  108. #define LAN91_CR_EPH_EN 0x8000 /*!< \ref LAN91_CR bit mask, . */
  109. /*!
  110. * \brief Bank 1 - Base address register.
  111. */
  112. #define LAN91_BAR (LAN91_BASE_ADDR + 0x02)
  113. /*!
  114. * \brief Bank 1 - Individual address register.
  115. */
  116. #define LAN91_IAR (LAN91_BASE_ADDR + 0x04)
  117. /*!
  118. * \brief Bank 1 - General purpose register.
  119. */
  120. #define LAN91_GPR (LAN91_BASE_ADDR + 0x0A)
  121. /*!
  122. * \brief Bank 1 - Control register.
  123. */
  124. #define LAN91_CTR (LAN91_BASE_ADDR + 0x0C)
  125. #define LAN91_CTR_RCV_BAD 0x4000 /*!< \ref LAN91_CTR bit mask. */
  126. #define LAN91_CTR_AUTO_RELEASE 0x0800 /*!< \ref LAN91_CTR bit mask, transmit packets automatically released. */
  127. /*!
  128. * \brief Bank 2 - MMU command register.
  129. */
  130. #define LAN91_MMUCR (LAN91_BASE_ADDR + 0x00)
  131. #define LAN91_MMUCR_BUSY 0x0001
  132. #define LAN91_MMU_NOP 0
  133. #define LAN91_MMU_ALO (1<<5)
  134. #define LAN91_MMU_RST (2<<5)
  135. #define LAN91_MMU_REM (3<<5)
  136. #define LAN91_MMU_TOP (4<<5)
  137. #define LAN91_MMU_PKT (5<<5)
  138. #define LAN91_MMU_ENQ (6<<5)
  139. #define LAN91_MMU_RTX (7<<5)
  140. /*!
  141. * \brief Bank 2 - Packet number register.
  142. *
  143. * This byte register specifies the accessible transmit packet number.
  144. */
  145. #define LAN91_PNR (LAN91_BASE_ADDR + 0x02)
  146. /*!
  147. * \brief Bank 2 - Allocation result register.
  148. *
  149. * This byte register is updated upon a LAN91_MMU_ALO command.
  150. */
  151. #define LAN91_ARR (LAN91_BASE_ADDR + 0x03)
  152. #define LAN91_ARR_FAILED 0x80
  153. /*!
  154. * \brief Bank 2 - FIFO ports register.
  155. */
  156. #define LAN91_FIFO (LAN91_BASE_ADDR + 0x04)
  157. /*!
  158. * \brief Bank 2 - Pointer register.
  159. */
  160. #define LAN91_PTR (LAN91_BASE_ADDR + 0x06)
  161. #define LAN91_PTR_RCV 0x8000 /*! \ref LAN91_PTR bit mask, specifies receive or transmit buffer. */
  162. #define LAN91_PTR_AUTO_INCR 0x4000 /*! \ref LAN91_PTR bit mask, enables automatic pointer increment. */
  163. #define LAN91_PTR_READ 0x2000 /*! \ref LAN91_PTR bit mask, indicates type of access. */
  164. #define LAN91_PTR_ETEN 0x1000 /*! \ref LAN91_PTR bit mask, enables early transmit underrun detection. */
  165. #define LAN91_PTR_NOT_EMPTY 0x0800 /*! \ref LAN91_PTR bit mask, set when write data fifo is not empty. */
  166. /*!
  167. * \brief Bank 2 - Data register.
  168. */
  169. #define LAN91_DATA (LAN91_BASE_ADDR + 0x08)
  170. /*!
  171. * \brief Bank 2 - Interrupt status register.
  172. */
  173. #define LAN91_IST (LAN91_BASE_ADDR + 0x0C)
  174. /*!
  175. * \brief Bank 2 - Interrupt acknowledge register.
  176. */
  177. #define LAN91_ACK (LAN91_BASE_ADDR + 0x0C)
  178. /*!
  179. * \brief Bank 2 - Interrupt mask register.
  180. */
  181. #define LAN91_MSK (LAN91_BASE_ADDR + 0x0D)
  182. #define LAN91_INT_MD 0x80 /*!< \brief PHY state change interrupt bit mask. */
  183. #define LAN91_INT_ERCV 0x40 /*!< \brief Early receive interrupt bit mask. */
  184. #define LAN91_INT_EPH 0x20 /*!< \brief Ethernet protocol interrupt bit mask. */
  185. #define LAN91_INT_RX_OVRN 0x10 /*!< \brief Receive overrun interrupt bit mask. */
  186. #define LAN91_INT_ALLOC 0x08 /*!< \brief Transmit allocation interrupt bit mask. */
  187. #define LAN91_INT_TX_EMPTY 0x04 /*!< \brief Transmitter empty interrupt bit mask. */
  188. #define LAN91_INT_TX 0x02 /*!< \brief Transmit complete interrupt bit mask. */
  189. #define LAN91_INT_RCV 0x01 /*!< \brief Receive interrupt bit mask. */
  190. /*!
  191. * \brief Bank 3 - Multicast table register.
  192. */
  193. #define LAN91_MT (LAN91_BASE_ADDR + 0x00)
  194. /*!
  195. * \brief Bank 3 - Management interface register.
  196. */
  197. #define LAN91_MGMT (LAN91_BASE_ADDR + 0x08)
  198. #define LAN91_MGMT_MDOE 0x08 /*!< \ref LAN91_MGMT bit mask, enables MDO pin. */
  199. #define LAN91_MGMT_MCLK 0x04 /*!< \ref LAN91_MGMT bit mask, drives MDCLK pin. */
  200. #define LAN91_MGMT_MDI 0x02 /*!< \ref LAN91_MGMT bit mask, reflects MDI pin status. */
  201. #define LAN91_MGMT_MDO 0x01 /*!< \ref LAN91_MGMT bit mask, drives MDO pin. */
  202. /*!
  203. * \brief Bank 3 - Revision register.
  204. */
  205. #define LAN91_REV (LAN91_BASE_ADDR + 0x0A)
  206. /*!
  207. * \brief Bank 3 - Early RCV register.
  208. */
  209. #define LAN91_ERCV (LAN91_BASE_ADDR + 0x0C)
  210. /*!
  211. * \brief PHY control register.
  212. */
  213. #define LAN91_PHYCR 0
  214. #define LAN91_PHYCR_RST 0x8000 /*!< \ref LAN91_PHYCR bit mask, resets PHY. */
  215. #define LAN91_PHYCR_LPBK 0x4000 /*!< \ref LAN91_PHYCR bit mask, . */
  216. #define LAN91_PHYCR_SPEED 0x2000 /*!< \ref LAN91_PHYCR bit mask, . */
  217. #define LAN91_PHYCR_ANEG_EN 0x1000 /*!< \ref LAN91_PHYCR bit mask, . */
  218. #define LAN91_PHYCR_PDN 0x0800 /*!< \ref LAN91_PHYCR bit mask, . */
  219. #define LAN91_PHYCR_MII_DIS 0x0400 /*!< \ref LAN91_PHYCR bit mask, . */
  220. #define LAN91_PHYCR_ANEG_RST 0x0200 /*!< \ref LAN91_PHYCR bit mask, . */
  221. #define LAN91_PHYCR_DPLX 0x0100 /*!< \ref LAN91_PHYCR bit mask, . */
  222. #define LAN91_PHYCR_COLST 0x0080 /*!< \ref LAN91_PHYCR bit mask, . */
  223. /*!
  224. * \brief PHY status register.
  225. */
  226. #define LAN91_PHYSR 1
  227. #define LAN91_PHYSR_CAP_T4 0x8000 /*!< \ref LAN91_PHYSR bit mask, indicates 100BASE-T4 capability. */
  228. #define LAN91_PHYSR_CAP_TXF 0x4000 /*!< \ref LAN91_PHYSR bit mask, indicates 100BASE-TX full duplex capability. */
  229. #define LAN91_PHYSR_CAP_TXH 0x2000 /*!< \ref LAN91_PHYSR bit mask, indicates 100BASE-TX half duplex capability. */
  230. #define LAN91_PHYSR_CAP_TF 0x1000 /*!< \ref LAN91_PHYSR bit mask, indicates 10BASE-T full duplex capability. */
  231. #define LAN91_PHYSR_CAP_TH 0x0800 /*!< \ref LAN91_PHYSR bit mask, indicates 10BASE-T half duplex capability. */
  232. #define LAN91_PHYSR_CAP_SUPR 0x0040 /*!< \ref LAN91_PHYSR bit mask, indicates preamble suppression capability. */
  233. #define LAN91_PHYSR_ANEG_ACK 0x0020 /*!< \ref LAN91_PHYSR bit mask, auto-negotiation completed. */
  234. #define LAN91_PHYSR_REM_FLT 0x0010 /*!< \ref LAN91_PHYSR bit mask, remote fault detected. */
  235. #define LAN91_PHYSR_CAP_ANEG 0x0008 /*!< \ref LAN91_PHYSR bit mask, indicates auto-negotiation capability. */
  236. #define LAN91_PHYSR_LINK 0x0004 /*!< \ref LAN91_PHYSR bit mask, valid link status. */
  237. #define LAN91_PHYSR_JAB 0x0002 /*!< \ref LAN91_PHYSR bit mask, jabber collision detected. */
  238. #define LAN91_PHYSR_EXREG 0x0001 /*!< \ref LAN91_PHYSR bit mask, extended capabilities available. */
  239. /*!
  240. * \brief PHY identifier register 1.
  241. */
  242. #define LAN91_PHYID1 2
  243. /*!
  244. * \brief PHY identifier register 1.
  245. */
  246. #define LAN91_PHYID2 3
  247. /*!
  248. * \brief PHY auto-negotiation advertisement register.
  249. */
  250. #define LAN91_PHYANAD 4
  251. #define LAN91_PHYANAD_NP 0x8000 /*!< \ref LAN91_PHYANAD bit mask, exchanging next page information. */
  252. #define LAN91_PHYANAD_ACK 0x4000 /*!< \ref LAN91_PHYANAD bit mask, acknowledged. */
  253. #define LAN91_PHYANAD_RF 0x2000 /*!< \ref LAN91_PHYANAD bit mask, remote fault. */
  254. #define LAN91_PHYANAD_T4 0x0200 /*!< \ref LAN91_PHYANAD bit mask, indicates 100BASE-T4 capability. */
  255. #define LAN91_PHYANAD_TX_FDX 0x0100 /*!< \ref LAN91_PHYANAD bit mask, indicates 100BASE-TX full duplex capability. */
  256. #define LAN91_PHYANAD_TX_HDX 0x0080 /*!< \ref LAN91_PHYANAD bit mask, indicates 100BASE-TX half duplex capability. */
  257. #define LAN91_PHYANAD_10FDX 0x0040 /*!< \ref LAN91_PHYANAD bit mask, indicates 10BASE-T full duplex capability. */
  258. #define LAN91_PHYANAD_10_HDX 0x0020 /*!< \ref LAN91_PHYANAD bit mask, indicates 10BASE-T half duplex capability. */
  259. #define LAN91_PHYANAD_CSMA 0x0001 /*!< \ref LAN91_PHYANAD bit mask, indicates 802.3 CSMA capability. */
  260. /*!
  261. * \brief PHY auto-negotiation remote end capability register.
  262. */
  263. #define LAN91_PHYANRC 5
  264. /*!
  265. * \brief PHY configuration register 1.
  266. */
  267. #define LAN91_PHYCFR1 16
  268. /*!
  269. * \brief PHY configuration register 2.
  270. */
  271. #define LAN91_PHYCFR2 17
  272. /*!
  273. * \brief PHY status output register.
  274. */
  275. #define LAN91_PHYSOR 18
  276. #define LAN91_PHYSOR_INT 0x8000 /*!< \ref LAN91_PHYSOR bit mask, interrupt bits changed. */
  277. #define LAN91_PHYSOR_LNKFAIL 0x4000 /*!< \ref LAN91_PHYSOR bit mask, link failure detected. */
  278. #define LAN91_PHYSOR_LOSSSYNC 0x2000 /*!< \ref LAN91_PHYSOR bit mask, descrambler sync lost detected. */
  279. #define LAN91_PHYSOR_CWRD 0x1000 /*!< \ref LAN91_PHYSOR bit mask, code word error detected. */
  280. #define LAN91_PHYSOR_SSD 0x0800 /*!< \ref LAN91_PHYSOR bit mask, start of stream error detected. */
  281. #define LAN91_PHYSOR_ESD 0x0400 /*!< \ref LAN91_PHYSOR bit mask, end of stream error detected. */
  282. #define LAN91_PHYSOR_RPOL 0x0200 /*!< \ref LAN91_PHYSOR bit mask, reverse polarity detected. */
  283. #define LAN91_PHYSOR_JAB 0x0100 /*!< \ref LAN91_PHYSOR bit mask, jabber detected. */
  284. #define LAN91_PHYSOR_SPDDET 0x0080 /*!< \ref LAN91_PHYSOR bit mask, 100/10 speed detected. */
  285. #define LAN91_PHYSOR_DPLXDET 0x0040 /*!< \ref LAN91_PHYSOR bit mask, duplex detected. */
  286. /*!
  287. * \brief PHY mask register.
  288. */
  289. #define LAN91_PHYMSK 19
  290. #define LAN91_PHYMSK_MINT 0x8000 /*!< \ref LAN91_PHYMSK bit mask, enables \ref LAN91_PHYSOR_INT interrupt. */
  291. #define LAN91_PHYMSK_MLNKFAIL 0x4000 /*!< \ref LAN91_PHYMSK bit mask, enables \ref LAN91_PHYSOR_LNKFAIL interrupt. */
  292. #define LAN91_PHYMSK_MLOSSSYN 0x2000 /*!< \ref LAN91_PHYMSK bit mask, enables \ref LAN91_PHYSOR_LOSSSYNC interrupt. */
  293. #define LAN91_PHYMSK_MCWRD 0x1000 /*!< \ref LAN91_PHYMSK bit mask, enables \ref LAN91_PHYSOR_CWRD interrupt. */
  294. #define LAN91_PHYMSK_MSSD 0x0800 /*!< \ref LAN91_PHYMSK bit mask, enables \ref LAN91_PHYSOR_SSD interrupt. */
  295. #define LAN91_PHYMSK_MESD 0x0400 /*!< \ref LAN91_PHYMSK bit mask, enables \ref LAN91_PHYSOR_ESD interrupt. */
  296. #define LAN91_PHYMSK_MRPOL 0x0200 /*!< \ref LAN91_PHYMSK bit mask, enables \ref LAN91_PHYSOR_RPOL interrupt. */
  297. #define LAN91_PHYMSK_MJAB 0x0100 /*!< \ref LAN91_PHYMSK bit mask, enables \ref LAN91_PHYSOR_JAB interrupt. */
  298. #define LAN91_PHYMSK_MSPDDT 0x0080 /*!< \ref LAN91_PHYMSK bit mask, enables \ref LAN91_PHYSOR_SPDDET interrupt. */
  299. #define LAN91_PHYMSK_MDPLDT 0x0040 /*!< \ref LAN91_PHYMSK bit mask, enables \ref LAN91_PHYSOR_DPLXDET interrupt. */
  300. /*@}*/
  301. /*
  302. * Available drivers.
  303. */
  304. extern NUTDEVICE devLan91;
  305. #ifndef DEV_ETHER
  306. #define DEV_ETHER devLan91
  307. #endif
  308. #endif