rtlregs.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. #ifndef _DEV_RTLREGS_H_
  2. #define _DEV_RTLREGS_H_
  3. /*
  4. * Copyright (C) 2001-2003 by egnite Software GmbH
  5. * Copyright (C) 2009 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: rtlregs.h 4115 2012-04-12 21:06:13Z olereinhardt $
  39. *
  40. * WARNING! Do not use any part of Basemon for your own applications. WARNING!
  41. *
  42. * This is not a typical application sample. It overrides parts of Nut/OS to
  43. * keep it running on broken hardware.
  44. */
  45. /*!
  46. * \file dev/rtlregs.h
  47. * \brief Realtek 8019AS register definitions.
  48. */
  49. #define NIC_BASE 0x8300
  50. /*
  51. * Register offset applicable to all register pages.
  52. */
  53. #define NIC_CR 0x00 /*!< \brief Command register */
  54. #define NIC_IOPORT 0x10 /*!< \brief I/O data port */
  55. #define NIC_RESET 0x1f /*!< \brief Reset port */
  56. /*
  57. * Page 0 register offsets.
  58. */
  59. #define NIC_PG0_CLDA0 0x01 /*!< \brief Current local DMA address 0 */
  60. #define NIC_PG0_PSTART 0x01 /*!< \brief Page start register */
  61. #define NIC_PG0_CLDA1 0x02 /*!< \brief Current local DMA address 1 */
  62. #define NIC_PG0_PSTOP 0x02 /*!< \brief Page stop register */
  63. #define NIC_PG0_BNRY 0x03 /*!< \brief Boundary pointer */
  64. #define NIC_PG0_TSR 0x04 /*!< \brief Transmit status register */
  65. #define NIC_PG0_TPSR 0x04 /*!< \brief Transmit page start address */
  66. #define NIC_PG0_NCR 0x05 /*!< \brief Number of collisions register */
  67. #define NIC_PG0_TBCR0 0x05 /*!< \brief Transmit byte count register 0 */
  68. #define NIC_PG0_FIFO 0x06 /*!< \brief FIFO */
  69. #define NIC_PG0_TBCR1 0x06 /*!< \brief Transmit byte count register 1 */
  70. #define NIC_PG0_ISR 0x07 /*!< \brief Interrupt status register */
  71. #define NIC_PG0_CRDA0 0x08 /*!< \brief Current remote DMA address 0 */
  72. #define NIC_PG0_RSAR0 0x08 /*!< \brief Remote start address register 0
  73. Low byte address to read from the buffer. */
  74. #define NIC_PG0_CRDA1 0x09 /*!< \brief Current remote DMA address 1 */
  75. #define NIC_PG0_RSAR1 0x09 /*!< \brief Remote start address register 1
  76. High byte address to read from the buffer. */
  77. #define NIC_PG0_RBCR0 0x0a /*!< \brief Remote byte count register 0
  78. Low byte of the number of bytes to read
  79. from the buffer. */
  80. #define NIC_PG0_RBCR1 0x0b /*!< \brief Remote byte count register 1
  81. High byte of the number of bytes to read
  82. from the buffer. */
  83. #define NIC_PG0_RSR 0x0c /*!< \brief Receive status register */
  84. #define NIC_PG0_RCR 0x0c /*!< \brief Receive configuration register */
  85. #define NIC_PG0_CNTR0 0x0d /*!< \brief Tally counter 0 (frame alignment errors) */
  86. #define NIC_PG0_TCR 0x0d /*!< \brief Transmit configuration register */
  87. #define NIC_PG0_CNTR1 0x0e /*!< \brief Tally counter 1 (CRC errors) */
  88. #define NIC_PG0_DCR 0x0e /*!< \brief Data configuration register */
  89. #define NIC_PG0_CNTR2 0x0f /*!< \brief Tally counter 2 (Missed packet errors) */
  90. #define NIC_PG0_IMR 0x0f /*!< \brief Interrupt mask register */
  91. /*
  92. * Page 1 register offsets.
  93. */
  94. #define NIC_PG1_PAR0 0x01 /*!< \brief Physical address register 0 */
  95. #define NIC_PG1_PAR1 0x02 /*!< \brief Physical address register 1 */
  96. #define NIC_PG1_PAR2 0x03 /*!< \brief Physical address register 2 */
  97. #define NIC_PG1_PAR3 0x04 /*!< \brief Physical address register 3 */
  98. #define NIC_PG1_PAR4 0x05 /*!< \brief Physical address register 4 */
  99. #define NIC_PG1_PAR5 0x06 /*!< \brief Physical address register 5 */
  100. #define NIC_PG1_CURR 0x07 /*!< \brief Current page register
  101. The next incoming packet will be stored
  102. at this page address. */
  103. #define NIC_PG1_MAR0 0x08 /*!< \brief Multicast address register 0 */
  104. #define NIC_PG1_MAR1 0x09 /*!< \brief Multicast address register 1 */
  105. #define NIC_PG1_MAR2 0x0a /*!< \brief Multicast address register 2 */
  106. #define NIC_PG1_MAR3 0x0b /*!< \brief Multicast address register 3 */
  107. #define NIC_PG1_MAR4 0x0c /*!< \brief Multicast address register 4 */
  108. #define NIC_PG1_MAR5 0x0d /*!< \brief Multicast address register 5 */
  109. #define NIC_PG1_MAR6 0x0e /*!< \brief Multicast address register 6 */
  110. #define NIC_PG1_MAR7 0x0f /*!< \brief Multicast address register 7 */
  111. /*
  112. * Page 2 register offsets.
  113. */
  114. #define NIC_PG2_PSTART 0x01 /*!< \brief Page start register */
  115. #define NIC_PG2_CLDA0 0x01 /*!< \brief Current local DMA address 0 */
  116. #define NIC_PG2_PSTOP 0x02 /*!< \brief Page stop register */
  117. #define NIC_PG2_CLDA1 0x02 /*!< \brief Current local DMA address 1 */
  118. #define NIC_PG2_RNP 0x03 /*!< \brief Remote next packet pointer */
  119. #define NIC_PG2_TSPR 0x04 /*!< \brief Transmit page start register */
  120. #define NIC_PG2_LNP 0x05 /*!< \brief Local next packet pointer */
  121. #define NIC_PG2_ACU 0x06 /*!< \brief Address counter (upper) */
  122. #define NIC_PG2_ACL 0x07 /*!< \brief Address counter (lower) */
  123. #define NIC_PG2_RCR 0x0c /*!< \brief Receive configuration register */
  124. #define NIC_PG2_TCR 0x0d /*!< \brief Transmit configuration register */
  125. #define NIC_PG2_DCR 0x0e /*!< \brief Data configuration register */
  126. #define NIC_PG2_IMR 0x0f /*!< \brief Interrupt mask register */
  127. /*
  128. * Page 3 register offsets.
  129. */
  130. #define NIC_PG3_EECR 0x01 /*!< \brief EEPROM command register */
  131. #define NIC_PG3_BPAGE 0x02 /*!< \brief Boot-ROM page register */
  132. #define NIC_PG3_CONFIG0 0x03 /*!< \brief Configuration register 0 (r/o) */
  133. #define NIC_PG3_CONFIG1 0x04 /*!< \brief Configuration register 1 */
  134. #define NIC_PG3_CONFIG2 0x05 /*!< \brief Configuration register 2 */
  135. #define NIC_PG3_CONFIG3 0x06 /*!< \brief Configuration register 3 */
  136. #define NIC_PG3_CSNSAV 0x08 /*!< \brief CSN save register (r/o) */
  137. #define NIC_PG3_HLTCLK 0x09 /*!< \brief Halt clock */
  138. #define NIC_PG3_INTR 0x0b /*!< \brief Interrupt pins (r/o) */
  139. /*
  140. * Command register bits.
  141. */
  142. #define NIC_CR_STP 0x01 /*!< \brief Stop */
  143. #define NIC_CR_STA 0x02 /*!< \brief Start */
  144. #define NIC_CR_TXP 0x04 /*!< \brief Transmit packet */
  145. #define NIC_CR_RD0 0x08 /*!< \brief Remote DMA command bit 0 */
  146. #define NIC_CR_RD1 0x10 /*!< \brief Remote DMA command bit 1 */
  147. #define NIC_CR_RD2 0x20 /*!< \brief Remote DMA command bit 2 */
  148. #define NIC_CR_PS0 0x40 /*!< \brief Page select bit 0 */
  149. #define NIC_CR_PS1 0x80 /*!< \brief Page select bit 1 */
  150. /*
  151. * Interrupt status register bits.
  152. */
  153. #define NIC_ISR_PRX 0x01 /*!< \brief Packet received */
  154. #define NIC_ISR_PTX 0x02 /*!< \brief Packet transmitted */
  155. #define NIC_ISR_RXE 0x04 /*!< \brief Receive error */
  156. #define NIC_ISR_TXE 0x08 /*!< \brief Transmit error */
  157. #define NIC_ISR_OVW 0x10 /*!< \brief Overwrite warning */
  158. #define NIC_ISR_CNT 0x20 /*!< \brief Counter overflow */
  159. #define NIC_ISR_RDC 0x40 /*!< \brief Remote DMA complete */
  160. #define NIC_ISR_RST 0x80 /*!< \brief Reset status */
  161. /*
  162. * Interrupt mask register bits.
  163. */
  164. #define NIC_IMR_PRXE 0x01 /*!< \brief Packet received interrupt enable */
  165. #define NIC_IMR_PTXE 0x02 /*!< \brief Packet transmitted interrupt enable */
  166. #define NIC_IMR_RXEE 0x04 /*!< \brief Receive error interrupt enable */
  167. #define NIC_IMR_TXEE 0x08 /*!< \brief Transmit error interrupt enable */
  168. #define NIC_IMR_OVWE 0x10 /*!< \brief Overwrite warning interrupt enable */
  169. #define NIC_IMR_CNTE 0x20 /*!< \brief Counter overflow interrupt enable */
  170. #define NIC_IMR_RCDE 0x40 /*!< \brief Remote DMA complete interrupt enable */
  171. /*
  172. * Data configuration register bits.
  173. */
  174. #define NIC_DCR_WTS 0x01 /*!< \brief Word transfer select */
  175. #define NIC_DCR_BOS 0x02 /*!< \brief Byte order select */
  176. #define NIC_DCR_LAS 0x04 /*!< \brief Long address select */
  177. #define NIC_DCR_LS 0x08 /*!< \brief Loopback select */
  178. #define NIC_DCR_AR 0x10 /*!< \brief Auto-initialize remote */
  179. #define NIC_DCR_FT0 0x20 /*!< \brief FIFO threshold select bit 0 */
  180. #define NIC_DCR_FT1 0x40 /*!< \brief FIFO threshold select bit 1 */
  181. /*
  182. * Transmit configuration register bits.
  183. */
  184. #define NIC_TCR_CRC 0x01 /*!< \brief Inhibit CRC */
  185. #define NIC_TCR_LB0 0x02 /*!< \brief Encoded loopback control bit 0 */
  186. #define NIC_TCR_LB1 0x04 /*!< \brief Encoded loopback control bit 1 */
  187. #define NIC_TCR_ATD 0x08 /*!< \brief Auto transmit disable */
  188. #define NIC_TCR_OFST 0x10 /*!< \brief Collision offset enable */
  189. /*
  190. * Transmit status register bits.
  191. */
  192. #define NIC_TSR_PTX 0x01 /*!< \brief Packet transmitted */
  193. #define NIC_TSR_COL 0x04 /*!< \brief Transmit collided */
  194. #define NIC_TSR_ABT 0x08 /*!< \brief Transmit aborted */
  195. #define NIC_TSR_CRS 0x10 /*!< \brief Carrier sense lost */
  196. #define NIC_TSR_FU 0x20 /*!< \brief FIFO underrun */
  197. #define NIC_TSR_CDH 0x40 /*!< \brief CD heartbeat */
  198. #define NIC_TSR_OWC 0x80 /*!< \brief Out of window collision */
  199. /*
  200. * Receive configuration register bits.
  201. */
  202. #define NIC_RCR_SEP 0x01 /*!< \brief Save errored packets */
  203. #define NIC_RCR_AR 0x02 /*!< \brief Accept runt packets */
  204. #define NIC_RCR_AB 0x04 /*!< \brief Accept broadcast */
  205. #define NIC_RCR_AM 0x08 /*!< \brief Accept multicast */
  206. #define NIC_RCR_PRO 0x10 /*!< \brief Promiscuous physical */
  207. #define NIC_RCR_MON 0x20 /*!< \brief Monitor mode */
  208. /*
  209. * Receive status register bits.
  210. */
  211. #define NIC_RSR_PRX 0x01 /*!< \brief Packet received intact */
  212. #define NIC_RSR_CRC 0x02 /*!< \brief CRC error */
  213. #define NIC_RSR_FAE 0x04 /*!< \brief Frame alignment error */
  214. #define NIC_RSR_FO 0x08 /*!< \brief FIFO overrun */
  215. #define NIC_RSR_MPA 0x10 /*!< \brief Missed packet */
  216. #define NIC_RSR_PHY 0x20 /*!< \brief Physical/multicast address */
  217. #define NIC_RSR_DIS 0x40 /*!< \brief Receiver disabled */
  218. #define NIC_RSR_DFR 0x80 /*!< \brief Deferring */
  219. /*
  220. * EEPROM command register bits.
  221. */
  222. #define NIC_EECR_EEM1 0x80 /*!< \brief EEPROM Operating Mode */
  223. #define NIC_EECR_EEM0 0x40 /*!< \brief EEPROM Operating Mode
  224. - 0 0 Normal operation
  225. - 0 1 Auto-load
  226. - 1 0 9346 programming
  227. - 1 1 Config register write enab */
  228. #define NIC_EECR_EECS 0x08 /*!< \brief EEPROM Chip Select */
  229. #define NIC_EECR_EESK 0x04 /*!< \brief EEPROM Clock */
  230. #define NIC_EECR_EEDI 0x02 /*!< \brief EEPROM Data In */
  231. #define NIC_EECR_EEDO 0x01 /*!< \brief EEPROM Data Out */
  232. /*
  233. * Configuration register 2 bits.
  234. */
  235. #define NIC_CONFIG2_PL1 0x80 /*!< \brief Network media type */
  236. #define NIC_CONFIG2_PL0 0x40 /*!< \brief Network media type
  237. - 0 0 TP/CX auto-detect
  238. - 0 1 10baseT
  239. - 1 0 10base5
  240. - 1 1 10base2 */
  241. #define NIC_CONFIG2_BSELB 0x20 /*!< \brief BROM disable */
  242. #define NIC_CONFIG2_BS4 0x10 /*!< \brief BROM size/base */
  243. #define NIC_CONFIG2_BS3 0x08
  244. #define NIC_CONFIG2_BS2 0x04
  245. #define NIC_CONFIG2_BS1 0x02
  246. #define NIC_CONFIG2_BS0 0x01
  247. /*
  248. * Configuration register 3 bits
  249. */
  250. #define NIC_CONFIG3_PNP 0x80 /*!< \brief PnP Mode */
  251. #define NIC_CONFIG3_FUDUP 0x40 /*!< \brief Full duplex */
  252. #define NIC_CONFIG3_LEDS1 0x20 /*!< \brief LED1/2 pin configuration
  253. - 0 LED1 == LED_RX, LED2 == LED_TX
  254. - 1 LED1 == LED_CRS, LED2 == MCSB */
  255. #define NIC_CONFIG3_LEDS0 0x10 /*!< \brief LED0 pin configration
  256. - 0 LED0 pin == LED_COL
  257. - 1 LED0 pin == LED_LINK */
  258. #define NIC_CONFIG3_SLEEP 0x04 /*!< \brief Sleep mode */
  259. #define NIC_CONFIG3_PWRDN 0x02 /*!< \brief Power Down */
  260. #define NIC_CONFIG3_ACTIVEB 0x01 /*!< \brief inverse of bit 0 in PnP Act Reg */
  261. /*!
  262. * \brief Read byte from controller register.
  263. */
  264. #define nic_read(reg) *(base + (reg))
  265. /*!
  266. * \brief Write byte to controller register.
  267. */
  268. #define nic_write(reg, data) *(base + (reg)) = data
  269. #define nic_outlb(reg, val) (*(volatile uint8_t *)(nic_base + (reg)) = (val))
  270. #define nic_inlb(reg) (*(volatile uint8_t *)(nic_base + (reg)))
  271. #define nic_inw(reg) (*(volatile uint16_t *)(nic_base + (reg)))
  272. #define nic_bs(bank) nic_outlb(NIC_BSR, (bank))
  273. #endif