rtlregs.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. #ifndef _DEV_RTLREGS_H_
  2. #define _DEV_RTLREGS_H_
  3. /*
  4. * Copyright (C) 2001-2003 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. */
  35. /*!
  36. * \file arch/avr/dev/rtlregs.h
  37. * \brief Realtek 8019AS registers.
  38. *
  39. * \verbatim
  40. * $Id: rtlregs.h 4706 2012-10-06 17:42:01Z haraldkipp $
  41. * \endverbatim
  42. */
  43. /*!
  44. * \brief Realtek 8019AS register definitions.
  45. */
  46. /*@{*/
  47. /*
  48. * Register offset applicable to all register pages.
  49. */
  50. #define NIC_CR 0x00 /*!< \brief Command register */
  51. #define NIC_IOPORT 0x10 /*!< \brief I/O data port */
  52. #define NIC_RESET 0x1f /*!< \brief Reset port */
  53. /*
  54. * Page 0 register offsets.
  55. */
  56. #define NIC_PG0_CLDA0 0x01 /*!< \brief Current local DMA address 0 */
  57. #define NIC_PG0_PSTART 0x01 /*!< \brief Page start register */
  58. #define NIC_PG0_CLDA1 0x02 /*!< \brief Current local DMA address 1 */
  59. #define NIC_PG0_PSTOP 0x02 /*!< \brief Page stop register */
  60. #define NIC_PG0_BNRY 0x03 /*!< \brief Boundary pointer */
  61. #define NIC_PG0_TSR 0x04 /*!< \brief Transmit status register */
  62. #define NIC_PG0_TPSR 0x04 /*!< \brief Transmit page start address */
  63. #define NIC_PG0_NCR 0x05 /*!< \brief Number of collisions register */
  64. #define NIC_PG0_TBCR0 0x05 /*!< \brief Transmit byte count register 0 */
  65. #define NIC_PG0_FIFO 0x06 /*!< \brief FIFO */
  66. #define NIC_PG0_TBCR1 0x06 /*!< \brief Transmit byte count register 1 */
  67. #define NIC_PG0_ISR 0x07 /*!< \brief Interrupt status register */
  68. #define NIC_PG0_CRDA0 0x08 /*!< \brief Current remote DMA address 0 */
  69. #define NIC_PG0_RSAR0 0x08 /*!< \brief Remote start address register 0
  70. Low byte address to read from the buffer. */
  71. #define NIC_PG0_CRDA1 0x09 /*!< \brief Current remote DMA address 1 */
  72. #define NIC_PG0_RSAR1 0x09 /*!< \brief Remote start address register 1
  73. High byte address to read from the buffer. */
  74. #define NIC_PG0_RBCR0 0x0a /*!< \brief Remote byte count register 0
  75. Low byte of the number of bytes to read
  76. from the buffer. */
  77. #define NIC_PG0_RBCR1 0x0b /*!< \brief Remote byte count register 1
  78. High byte of the number of bytes to read
  79. from the buffer. */
  80. #define NIC_PG0_RSR 0x0c /*!< \brief Receive status register */
  81. #define NIC_PG0_RCR 0x0c /*!< \brief Receive configuration register */
  82. #define NIC_PG0_CNTR0 0x0d /*!< \brief Tally counter 0 (frame alignment errors) */
  83. #define NIC_PG0_TCR 0x0d /*!< \brief Transmit configuration register */
  84. #define NIC_PG0_CNTR1 0x0e /*!< \brief Tally counter 1 (CRC errors) */
  85. #define NIC_PG0_DCR 0x0e /*!< \brief Data configuration register */
  86. #define NIC_PG0_CNTR2 0x0f /*!< \brief Tally counter 2 (Missed packet errors) */
  87. #define NIC_PG0_IMR 0x0f /*!< \brief Interrupt mask register */
  88. /*
  89. * Page 1 register offsets.
  90. */
  91. #define NIC_PG1_PAR0 0x01 /*!< \brief Physical address register 0 */
  92. #define NIC_PG1_PAR1 0x02 /*!< \brief Physical address register 1 */
  93. #define NIC_PG1_PAR2 0x03 /*!< \brief Physical address register 2 */
  94. #define NIC_PG1_PAR3 0x04 /*!< \brief Physical address register 3 */
  95. #define NIC_PG1_PAR4 0x05 /*!< \brief Physical address register 4 */
  96. #define NIC_PG1_PAR5 0x06 /*!< \brief Physical address register 5 */
  97. #define NIC_PG1_CURR 0x07 /*!< \brief Current page register
  98. The next incoming packet will be stored
  99. at this page address. */
  100. #define NIC_PG1_MAR0 0x08 /*!< \brief Multicast address register 0 */
  101. #define NIC_PG1_MAR1 0x09 /*!< \brief Multicast address register 1 */
  102. #define NIC_PG1_MAR2 0x0a /*!< \brief Multicast address register 2 */
  103. #define NIC_PG1_MAR3 0x0b /*!< \brief Multicast address register 3 */
  104. #define NIC_PG1_MAR4 0x0c /*!< \brief Multicast address register 4 */
  105. #define NIC_PG1_MAR5 0x0d /*!< \brief Multicast address register 5 */
  106. #define NIC_PG1_MAR6 0x0e /*!< \brief Multicast address register 6 */
  107. #define NIC_PG1_MAR7 0x0f /*!< \brief Multicast address register 7 */
  108. /*
  109. * Page 2 register offsets.
  110. */
  111. #define NIC_PG2_PSTART 0x01 /*!< \brief Page start register */
  112. #define NIC_PG2_CLDA0 0x01 /*!< \brief Current local DMA address 0 */
  113. #define NIC_PG2_PSTOP 0x02 /*!< \brief Page stop register */
  114. #define NIC_PG2_CLDA1 0x02 /*!< \brief Current local DMA address 1 */
  115. #define NIC_PG2_RNP 0x03 /*!< \brief Remote next packet pointer */
  116. #define NIC_PG2_TSPR 0x04 /*!< \brief Transmit page start register */
  117. #define NIC_PG2_LNP 0x05 /*!< \brief Local next packet pointer */
  118. #define NIC_PG2_ACU 0x06 /*!< \brief Address counter (upper) */
  119. #define NIC_PG2_ACL 0x07 /*!< \brief Address counter (lower) */
  120. #define NIC_PG2_RCR 0x0c /*!< \brief Receive configuration register */
  121. #define NIC_PG2_TCR 0x0d /*!< \brief Transmit configuration register */
  122. #define NIC_PG2_DCR 0x0e /*!< \brief Data configuration register */
  123. #define NIC_PG2_IMR 0x0f /*!< \brief Interrupt mask register */
  124. /*
  125. * Page 3 register offsets.
  126. */
  127. #define NIC_PG3_EECR 0x01 /*!< \brief EEPROM command register */
  128. #define NIC_PG3_BPAGE 0x02 /*!< \brief Boot-ROM page register */
  129. #define NIC_PG3_CONFIG0 0x03 /*!< \brief Configuration register 0 (r/o) */
  130. #define NIC_PG3_CONFIG1 0x04 /*!< \brief Configuration register 1 */
  131. #define NIC_PG3_CONFIG2 0x05 /*!< \brief Configuration register 2 */
  132. #define NIC_PG3_CONFIG3 0x06 /*!< \brief Configuration register 3 */
  133. #define NIC_PG3_CSNSAV 0x08 /*!< \brief CSN save register (r/o) */
  134. #define NIC_PG3_HLTCLK 0x09 /*!< \brief Halt clock */
  135. #define NIC_PG3_INTR 0x0b /*!< \brief Interrupt pins (r/o) */
  136. /*
  137. * Command register bits.
  138. */
  139. #define NIC_CR_STP 0x01 /*!< \brief Stop */
  140. #define NIC_CR_STA 0x02 /*!< \brief Start */
  141. #define NIC_CR_TXP 0x04 /*!< \brief Transmit packet */
  142. #define NIC_CR_RD0 0x08 /*!< \brief Remote DMA command bit 0 */
  143. #define NIC_CR_RD1 0x10 /*!< \brief Remote DMA command bit 1 */
  144. #define NIC_CR_RD2 0x20 /*!< \brief Remote DMA command bit 2 */
  145. #define NIC_CR_PS0 0x40 /*!< \brief Page select bit 0 */
  146. #define NIC_CR_PS1 0x80 /*!< \brief Page select bit 1 */
  147. /*
  148. * Interrupt status register bits.
  149. */
  150. #define NIC_ISR_PRX 0x01 /*!< \brief Packet received */
  151. #define NIC_ISR_PTX 0x02 /*!< \brief Packet transmitted */
  152. #define NIC_ISR_RXE 0x04 /*!< \brief Receive error */
  153. #define NIC_ISR_TXE 0x08 /*!< \brief Transmit error */
  154. #define NIC_ISR_OVW 0x10 /*!< \brief Overwrite warning */
  155. #define NIC_ISR_CNT 0x20 /*!< \brief Counter overflow */
  156. #define NIC_ISR_RDC 0x40 /*!< \brief Remote DMA complete */
  157. #define NIC_ISR_RST 0x80 /*!< \brief Reset status */
  158. /*
  159. * Interrupt mask register bits.
  160. */
  161. #define NIC_IMR_PRXE 0x01 /*!< \brief Packet received interrupt enable */
  162. #define NIC_IMR_PTXE 0x02 /*!< \brief Packet transmitted interrupt enable */
  163. #define NIC_IMR_RXEE 0x04 /*!< \brief Receive error interrupt enable */
  164. #define NIC_IMR_TXEE 0x08 /*!< \brief Transmit error interrupt enable */
  165. #define NIC_IMR_OVWE 0x10 /*!< \brief Overwrite warning interrupt enable */
  166. #define NIC_IMR_CNTE 0x20 /*!< \brief Counter overflow interrupt enable */
  167. #define NIC_IMR_RCDE 0x40 /*!< \brief Remote DMA complete interrupt enable */
  168. /*
  169. * Data configuration register bits.
  170. */
  171. #define NIC_DCR_WTS 0x01 /*!< \brief Word transfer select */
  172. #define NIC_DCR_BOS 0x02 /*!< \brief Byte order select */
  173. #define NIC_DCR_LAS 0x04 /*!< \brief Long address select */
  174. #define NIC_DCR_LS 0x08 /*!< \brief Loopback select */
  175. #define NIC_DCR_AR 0x10 /*!< \brief Auto-initialize remote */
  176. #define NIC_DCR_FT0 0x20 /*!< \brief FIFO threshold select bit 0 */
  177. #define NIC_DCR_FT1 0x40 /*!< \brief FIFO threshold select bit 1 */
  178. /*
  179. * Transmit configuration register bits.
  180. */
  181. #define NIC_TCR_CRC 0x01 /*!< \brief Inhibit CRC */
  182. #define NIC_TCR_LB0 0x02 /*!< \brief Encoded loopback control bit 0 */
  183. #define NIC_TCR_LB1 0x04 /*!< \brief Encoded loopback control bit 1 */
  184. #define NIC_TCR_ATD 0x08 /*!< \brief Auto transmit disable */
  185. #define NIC_TCR_OFST 0x10 /*!< \brief Collision offset enable */
  186. /*
  187. * Transmit status register bits.
  188. */
  189. #define NIC_TSR_PTX 0x01 /*!< \brief Packet transmitted */
  190. #define NIC_TSR_COL 0x04 /*!< \brief Transmit collided */
  191. #define NIC_TSR_ABT 0x08 /*!< \brief Transmit aborted */
  192. #define NIC_TSR_CRS 0x10 /*!< \brief Carrier sense lost */
  193. #define NIC_TSR_FU 0x20 /*!< \brief FIFO underrun */
  194. #define NIC_TSR_CDH 0x40 /*!< \brief CD heartbeat */
  195. #define NIC_TSR_OWC 0x80 /*!< \brief Out of window collision */
  196. /*
  197. * Receive configuration register bits.
  198. */
  199. #define NIC_RCR_SEP 0x01 /*!< \brief Save errored packets */
  200. #define NIC_RCR_AR 0x02 /*!< \brief Accept runt packets */
  201. #define NIC_RCR_AB 0x04 /*!< \brief Accept broadcast */
  202. #define NIC_RCR_AM 0x08 /*!< \brief Accept multicast */
  203. #define NIC_RCR_PRO 0x10 /*!< \brief Promiscuous physical */
  204. #define NIC_RCR_MON 0x20 /*!< \brief Monitor mode */
  205. /*
  206. * Receive status register bits.
  207. */
  208. #define NIC_RSR_PRX 0x01 /*!< \brief Packet received intact */
  209. #define NIC_RSR_CRC 0x02 /*!< \brief CRC error */
  210. #define NIC_RSR_FAE 0x04 /*!< \brief Frame alignment error */
  211. #define NIC_RSR_FO 0x08 /*!< \brief FIFO overrun */
  212. #define NIC_RSR_MPA 0x10 /*!< \brief Missed packet */
  213. #define NIC_RSR_PHY 0x20 /*!< \brief Physical/multicast address */
  214. #define NIC_RSR_DIS 0x40 /*!< \brief Receiver disabled */
  215. #define NIC_RSR_DFR 0x80 /*!< \brief Deferring */
  216. /*
  217. * EEPROM command register bits.
  218. */
  219. #define NIC_EECR_EEM1 0x80 /*!< \brief EEPROM Operating Mode */
  220. #define NIC_EECR_EEM0 0x40 /*!< \brief EEPROM Operating Mode
  221. - 0 0 Normal operation
  222. - 0 1 Auto-load
  223. - 1 0 9346 programming
  224. - 1 1 Config register write enab */
  225. #define NIC_EECR_EECS 0x08 /*!< \brief EEPROM Chip Select */
  226. #define NIC_EECR_EESK 0x04 /*!< \brief EEPROM Clock */
  227. #define NIC_EECR_EEDI 0x02 /*!< \brief EEPROM Data In */
  228. #define NIC_EECR_EEDO 0x01 /*!< \brief EEPROM Data Out */
  229. /*
  230. * Configuration register 2 bits.
  231. */
  232. #define NIC_CONFIG2_PL1 0x80 /*!< \brief Network media type */
  233. #define NIC_CONFIG2_PL0 0x40 /*!< \brief Network media type
  234. - 0 0 TP/CX auto-detect
  235. - 0 1 10baseT
  236. - 1 0 10base5
  237. - 1 1 10base2 */
  238. #define NIC_CONFIG2_BSELB 0x20 /*!< \brief BROM disable */
  239. #define NIC_CONFIG2_BS4 0x10 /*!< \brief BROM size/base */
  240. #define NIC_CONFIG2_BS3 0x08
  241. #define NIC_CONFIG2_BS2 0x04
  242. #define NIC_CONFIG2_BS1 0x02
  243. #define NIC_CONFIG2_BS0 0x01
  244. /*
  245. * Configuration register 3 bits
  246. */
  247. #define NIC_CONFIG3_PNP 0x80 /*!< \brief PnP Mode */
  248. #define NIC_CONFIG3_FUDUP 0x40 /*!< \brief Full duplex */
  249. #define NIC_CONFIG3_LEDS1 0x20 /*!< \brief LED1/2 pin configuration
  250. - 0 LED1 == LED_RX, LED2 == LED_TX
  251. - 1 LED1 == LED_CRS, LED2 == MCSB */
  252. #define NIC_CONFIG3_LEDS0 0x10 /*!< \brief LED0 pin configration
  253. - 0 LED0 pin == LED_COL
  254. - 1 LED0 pin == LED_LINK */
  255. #define NIC_CONFIG3_SLEEP 0x04 /*!< \brief Sleep mode */
  256. #define NIC_CONFIG3_PWRDN 0x02 /*!< \brief Power Down */
  257. #define NIC_CONFIG3_ACTIVEB 0x01 /*!< \brief inverse of bit 0 in PnP Act Reg */
  258. /*@}*/
  259. /*!
  260. * \brief Read byte from controller register.
  261. */
  262. #define nic_read(reg) *(base + (reg))
  263. /*!
  264. * \brief Write byte to controller register.
  265. */
  266. #define nic_write(reg, data) *(base + (reg)) = data
  267. #endif