if_xereg.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /* $OpenBSD: if_xereg.h,v 1.4 2003/10/22 09:58:46 jmc Exp $ */
  2. /*
  3. * Copyright (c) 1999 Niklas Hallqvist, C Stone, Job de Haas
  4. * 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. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. All advertising materials mentioning features or use of this software
  15. * must display the following acknowledgement:
  16. * This product includes software developed by Niklas Hallqvist,
  17. * C Stone and Job de Haas.
  18. * 4. The name of the author may not be used to endorse or promote products
  19. * derived from this software without specific prior written permission
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  22. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  23. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  26. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. /* Additional Card Configuration Registers on Dingo */
  33. #define PCMCIA_CCR_DCOR0 0x20
  34. #define PCMCIA_CCR_DCOR0_MRST_SFRST 0x80
  35. #define PCMCIA_CCR_DCOR0_MRST_SFPWDN 0x40
  36. #define PCMCIA_CCR_DCOR0_LED3_SFRST 0x20
  37. #define PCMCIA_CCR_DCOR0_LED3_SFPWDN 0x10
  38. #define PCMCIA_CCR_DCOR0_BUS 0x08
  39. #define PCMCIA_CCR_DCOR0_DECODE 0x04
  40. #define PCMCIA_CCR_DCOR0_SFINT 0x01
  41. #define PCMCIA_CCR_DCOR1 0x22
  42. #define PCMCIA_CCR_DCOR1_SFCSR_WAIT 0xC0
  43. #define PCMCIA_CCR_DCOR1_SHADOW_SFIOB 0x20
  44. #define PCMCIA_CCR_DCOR1_SHADOW_SFCSR 0x10
  45. #define PCMCIA_CCR_DCOR1_FORCE_LEVIREQ 0x08
  46. #define PCMCIA_CCR_DCOR1_D6 0x04
  47. #define PCMCIA_CCR_DCOR1_SF_STSCHG 0x02
  48. #define PCMCIA_CCR_DCOR1_SF_IREQ 0x01
  49. #define PCMCIA_CCR_DCOR2 0x24
  50. #define PCMCIA_CCR_DCOR2_SHADOW_SFCOR 0x10
  51. #define PCMCIA_CCR_DCOR2_SMEM_BASE 0x0F
  52. #define PCMCIA_CCR_DCOR3 0x26
  53. #define PCMCIA_CCR_DCOR4 0x28
  54. #define PCMCIA_CCR_SFCOR 0x40
  55. #define PCMCIA_CCR_SFCOR_SRESET 0x80
  56. #define PCMCIA_CCR_SFCOR_LEVIREQ 0x40
  57. #define PCMCIA_CCR_SFCOR_IRQ_STSCHG 0x20
  58. #define PCMCIA_CCR_SFCOR_CFINDEX 0x18
  59. #define PCMCIA_CCR_SFCOR_IREQ_ENABLE 0x04
  60. #define PCMCIA_CCR_SFCOR_ADDR_DECODE 0x02
  61. #define PCMCIA_CCR_SFCOR_FUNC_ENABLE 0x01
  62. #define PCMCIA_CCR_SFCSR 0x42
  63. #define PCMCIA_CCR_SFCSR_IOIS8 0x20
  64. #define PCMCIA_CCR_SFCSR_AUDIO 0x08
  65. #define PCMCIA_CCR_SFCSR_PWRDWN 0x04
  66. #define PCMCIA_CCR_SFCSR_INTR 0x02
  67. #define PCMCIA_CCR_SFCSR_INTRACK 0x01
  68. #define PCMCIA_CCR_SFIOBASE0 0x4A
  69. #define PCMCIA_CCR_SFIOBASE1 0x4C
  70. #define PCMCIA_CCR_SFILR 0x52
  71. #define PCMCIA_CCR_SIZE_DINGO 0x54
  72. /* All pages */
  73. #define CR 0x0 /* W - Command register */
  74. #define ESR 0x0 /* R - Ethernet status register */
  75. #define PR 0x1 /* RW - Page register select */
  76. #define EDP 0x4 /* RW - Ethernet data port, 4 registers */
  77. #define ISR0 0x6 /* R - Ethernet interrupt status register */
  78. #define GIR 0x7 /* RW - Global interrupt register */
  79. #define PTR 0xd /* R - Packets Transmitted register */
  80. /* Page 0 */
  81. #define TSO0 0x8 /* R - Transmit space open, 3 registers */
  82. #define TSO1 0x9
  83. #define TSO2 0xa
  84. #define DO0 0xc /* W - Data offset, 2 registers */
  85. #define DO1 0xd
  86. #define RSR 0xc /* R - Rx status register */
  87. #define TPR 0xd /* R - Tx packets register */
  88. #define RBC0 0xe /* R - Rx byte count, 2 registers */
  89. #define RBC1 0xf
  90. /* Page 1 */
  91. #define IMR0 0xc /* RW - Interrupt mask, 2 registers */
  92. #define IMR1 0xd
  93. #define ECR 0xe /* RW - Ethernet config register */
  94. /* Page 2 */
  95. #define RBS0 0x8 /* RW - Receive buffer start, 2 registers */
  96. #define RBS1 0x9
  97. #define LED 0xa /* RW - LED control register */
  98. #define LED3 0xb /* RW - LED3 control register */
  99. #define MSR 0xc /* RW - Misc. setup register */
  100. #define GP2 0xd /* RW - General purpose register 2 */
  101. /* Page 3 */
  102. #define TPT0 0xa /* RW - Tx packet threshold, 2 registers */
  103. #define TPT1 0xb
  104. /* Page 4 */
  105. #define GP0 0x8 /* RW - General purpose register 0 */
  106. #define GP1 0x9 /* RW - General purpose register 1 */
  107. #define BV 0xa /* R - Bonding version register */
  108. #define EES 0xb /* RW - EEPROM control register */
  109. /* Page 5 */
  110. #define RHSA0 0xa /* RX host start address */
  111. /* Page 6 */
  112. /* Page 7 */
  113. /* Page 8 */
  114. /* Page 16 */
  115. /* Page 0x40 */
  116. #define CMD0 0x8 /* W - Receive status register */
  117. #define RXST0 0x9 /* RW - Receive status register */
  118. #define TXST0 0xb /* RW - Transmit status, 2 registers */
  119. #define TXST1 0xc
  120. #define RX0MSK 0xd /* RW - Receive status mask register */
  121. #define TX0MSK 0xe /* RW - Transmit status mask, 2 registers */
  122. #define TX1MSK 0xf /* RW - Dingo does not define this register */
  123. /* Page 0x42 */
  124. #define SWC0 0x8 /* RW - Software configuration, 2 registers */
  125. #define SWC1 0x9
  126. /* Page 0x50-0x57 */
  127. #define IA 0x8 /* RW - Individual address */
  128. /* CR register bits */
  129. #define TX_PKT 0x01 /* Transmit packet. */
  130. #define SOFT_RESET 0x02 /* Software reset. */
  131. #define ENABLE_INT 0x04 /* Enable interrupt. */
  132. #define FORCE_INT 0x08 /* Force interrupt. */
  133. #define CLR_TX_FIFO 0x10 /* Clear transmit FIFO. */
  134. #define CLR_RX_OVERRUN 0x20 /* Clear receive overrun. */
  135. #define RESTART_TX 0x40 /* Restart transmit process. */
  136. /* ESR register bits */
  137. #define FULL_PKT_RCV 0x01 /* Full packet received. */
  138. #define PKT_REJECTED 0x04 /* A packet was rejected. */
  139. #define TX_PKT_PEND 0x08 /* TX Packet Pending. */
  140. #define INCOR_POLARITY 0x10 /* XXX from linux driver, but not used there */
  141. #define MEDIA_SELECT 0x20 /* set if TP, clear if AUI */
  142. /* DO register bits */
  143. #define DO_OFF_MASK 0x1fff /* Mask for offset value. */
  144. #define DO_CHG_OFFSET 0x2000 /* Change offset command. */
  145. #define DO_SHM_MODE 0x4000 /* Shared memory mode. */
  146. #define DO_SKIP_RX_PKT 0x8000 /* Skip Rx packet. */
  147. /* RBC register bits */
  148. #define RBC_COUNT_MASK 0x1fff /* Mask for byte count. */
  149. #define RBC_RX_FULL 0x2000 /* Receive full packet. */
  150. #define RBC_RX_PARTIAL 0x4000 /* Receive partial packet. */
  151. #define RBC_RX_PKT_REJ 0x8000 /* Receive packet rejected. */
  152. /* ISR0(/IMR0) register bits */
  153. #define ISR_TX_OFLOW 0x01 /* Transmit buffer overflow. */
  154. #define ISR_PKT_TX 0x02 /* Packet transmitted. */
  155. #define ISR_MAC_INT 0x04 /* MAC interrupt. */
  156. #define ISR_RX_EARLY 0x10 /* Receive early packet. */
  157. #define ISR_RX_FULL 0x20 /* Receive full packet. */
  158. #define ISR_RX_PKT_REJ 0x40 /* Receive packet rejected. */
  159. #define ISR_FORCED_INT 0x80 /* Forced interrupt. */
  160. /* ECR register bits */
  161. #define ECR_EARLY_TX 0x01 /* Early transmit mode. */
  162. #define ECR_EARLY_RX 0x02 /* Early receive mode. */
  163. #define ECR_FULL_DUPLEX 0x04 /* Full duplex select. */
  164. #define ECR_LNK_PLS_DIS 0x20 /* Link pulse disable. */
  165. #define ECR_SW_COMPAT 0x80 /* Software compatibility switch. */
  166. /* GP0 register bits */
  167. #define GP1_WR 0x01 /* GP1 pin output value. */
  168. #define GP2_WR 0x02 /* GP2 pin output value. */
  169. #define GP1_OUT 0x04 /* GP1 pin output select. */
  170. #define GP2_OUT 0x08 /* GP2 pin output select. */
  171. #define GP1_RD 0x10 /* GP1 pin input value. */
  172. #define GP2_RD 0x20 /* GP2 pin input value. */
  173. /* GP1 register bits */
  174. #define POWER_UP 0x01 /* When 0, power down analogue part of chip. */
  175. /* LED register bits */
  176. #define LED0_SHIFT 0 /* LED0 Output shift & mask */
  177. #define LED0_MASK 0x7
  178. #define LED1_SHIFT 3 /* LED1 Output shift & mask */
  179. #define LED1_MASK 0x38
  180. #define LED0_RX_ENA 0x40 /* LED0 - receive enable */
  181. #define LED1_RX_ENA 0x80 /* LED1 - receive enable */
  182. /* LED3 register bits */
  183. #define LED3_SHIFT 0 /* LED0 output shift & mask */
  184. #define LED3_MASK 0x7
  185. #define LED3_RX_ENA 0x40 /* LED0 - receive enable */
  186. /* LED output values */
  187. #define LED_DISABLE 0 /* LED disabled */
  188. #define LED_COLL_ACT 1 /* Collision activity */
  189. #define LED_COLL_INACT 2 /* (NOT) Collision activity */
  190. #define LED_10MB_LINK 3 /* 10 Mb link detected */
  191. #define LED_100MB_LINK 4 /* 100 Mb link detected */
  192. #define LED_LINK 5 /* 10 Mb or 100 Mb link detected */
  193. #define LED_AUTO 6 /* Automatic assertion */
  194. #define LED_TX_ACT 7 /* Transmit activity */
  195. /* MSR register bits */
  196. #define SRAM_128K_EXT 0x01 /* 128K SRAM extension */
  197. #define RBS_BIT16 0x02 /* RBS bit 16 */
  198. #define SELECT_MII 0x08 /* Select MII */
  199. #define HASH_TBL_ENA 0x20 /* Hash table enable */
  200. /* GP2 register bits */
  201. #define GP3_WR 0x01 /* GP3 pin output value. */
  202. #define GP4_WR 0x02 /* GP4 pin output value. */
  203. #define GP3_OUT 0x04 /* GP3 pin output select. */
  204. #define GP4_OUT 0x08 /* GP4 pin output select. */
  205. #define GP3_RD 0x10 /* GP3 pin input value. */
  206. #define GP4_RD 0x20 /* GP4 pin input value. */
  207. /* RSR register bits */
  208. #define RSR_NOTMCAST 0x01 /* clear when multicast packet */
  209. #define RSR_BCAST 0x02 /* set when broadcast packet */
  210. #define RSR_TOO_LONG 0x04 /* set if packet is longer than 1518 octets */
  211. #define RSR_ALIGNERR 0x10 /* incorrect CRC and last octet not complete */
  212. #define RSR_CRCERR 0x20 /* incorrect CRC and last octet complete */
  213. #define RSR_RX_OK 0x80 /* packet received okay */
  214. /* CMD0 register bits */
  215. #define ONLINE 0x04 /* Online */
  216. #define OFFLINE 0x08 /* Online */
  217. #define ENABLE_RX 0x20 /* Enable receiver */
  218. #define DISABLE_RX 0x80 /* Disable receiver */
  219. /* RX0Msk register bits */
  220. #define PKT_TOO_LONG 0x02 /* Packet too long mask. */
  221. #define CRC_ERR 0x08 /* CRC error mask. */
  222. #define RX_OVERRUN 0x10 /* Receive overrun mask. */
  223. #define RX_ABORT 0x40 /* Receive abort mask. */
  224. #define RX_OK 0x80 /* Receive OK mask. */
  225. /* TX0Msk register bits */
  226. #define CARRIER_LOST 0x01 /* Carrier sense lost. */
  227. #define EXCESSIVE_COLL 0x02 /* Excessive collisions mask. */
  228. #define TX_UNDERRUN 0x08 /* Transmit underrun mask. */
  229. #define LATE_COLLISION 0x10 /* Late collision mask. */
  230. #define SQE 0x20 /* Signal quality error mask.. */
  231. #define TX_ABORT 0x40 /* Transmit abort mask. */
  232. #define TX_OK 0x80 /* Transmit OK mask. */
  233. /* SWC1 register bits */
  234. #define SWC1_IND_ADDR 0x01 /* Individual address enable. */
  235. #define SWC1_MCAST_PROM 0x02 /* Multicast promiscuous enable. */
  236. #define SWC1_PROMISC 0x04 /* Promiscuous mode enable. */
  237. #define SWC1_BCAST_DIS 0x08 /* Broadcast disable. */
  238. #define SWC1_MEDIA_SEL 0x40 /* Media select (Mohawk). */
  239. #define SWC1_AUTO_MEDIA 0x80 /* Automatic media select (Mohawk). */
  240. /* Misc. defines. */
  241. #define PAGE(sc, page) \
  242. bus_space_write_1((sc->sc_bst), (sc->sc_bsh), (sc->sc_offset) + PR, (page))
  243. /*
  244. * GP3 is connected to the MDC pin of the NS DP83840A PHY, GP4 is
  245. * connected to the MDIO pin. These are utility macros to enhance
  246. * readability of the code.
  247. */
  248. #define MDC_LOW GP3_OUT
  249. #define MDC_HIGH (GP3_OUT | GP3_WR)
  250. #define MDIO_LOW GP4_OUT
  251. #define MDIO_HIGH (GP4_OUT | GP4_WR)
  252. #define MDIO GP4_RD
  253. /* Values found in MANFID. */
  254. #define XEMEDIA_ETHER 0x01
  255. #define XEMEDIA_TOKEN 0x02
  256. #define XEMEDIA_ARC 0x04
  257. #define XEMEDIA_WIRELESS 0x08
  258. #define XEMEDIA_MODEM 0x10
  259. #define XEMEDIA_GSM 0x20
  260. #define XEPROD_IDMASK 0x0f
  261. #define XEPROD_POCKET 0x10
  262. #define XEPROD_EXTERNAL 0x20
  263. #define XEPROD_CREDITCARD 0x40
  264. #define XEPROD_CARDBUS 0x80