PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/arch/hc/src/m9s12/m9s12_emac.h

https://bitbucket.org/hg42/nuttx
C Header | 248 lines | 125 code | 45 blank | 78 comment | 0 complexity | 9b01621025f010063a79c2b2231c5792 MD5 | raw file
Possible License(s): 0BSD
  1. /************************************************************************************
  2. * arch/hc/src/m9s12/m9s12_emac.h
  3. *
  4. * Copyright (C) 2011 Gregory Nutt. All rights reserved.
  5. * Author: Gregory Nutt <gnutt@nuttx.org>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. * 3. Neither the name NuttX nor the names of its contributors may be
  18. * used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. * POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. ************************************************************************************/
  35. #ifndef __ARCH_ARM_HC_SRC_M9S12_M9S12_EMAC_H
  36. #define __ARCH_ARM_HC_SRC_M9S12_M9S12_EMAC_H
  37. /************************************************************************************
  38. * Included Files
  39. ************************************************************************************/
  40. #include <nuttx/config.h>
  41. #include "chip.h"
  42. /************************************************************************************
  43. * Pre-processor Definitions
  44. ************************************************************************************/
  45. /* Register Offsets *****************************************************************/
  46. #define HCS12_EMAC_NETCTL_OFFSET 0x0000 /* Network Control (8-bit) */
  47. #define HCS12_EMAC_RXCTS_OFFSET 0x0003 /* Receive Control and Status (8-bit) */
  48. #define HCS12_EMAC_TXCTS_OFFSET 0x0004 /* Transmit Control and Status (8-bit) */
  49. #define HCS12_EMAC_ETCTL_OFFSET 0x0005 /* Ethertype Control (8-bit) */
  50. #define HCS12_EMAC_ETYPE_OFFSET 0x0006 /* Programmable Ethertype (16-bit) */
  51. #define HCS12_EMAC_PTIME_OFFSET 0x0008 /* PAUSE Timer Value and Counter (16-bit) */
  52. #define HCS12_EMAC_IEVENT_OFFSET 0x000a /* Interrupt Event (16-bit) */
  53. #define HCS12_EMAC_IMASK_OFFSET 0x000c /* Interrupt Mask (16-bit) */
  54. #define HCS12_EMAC_SWRST_OFFSET 0x000e /* Software Reset (8-bit) */
  55. #define HCS12_EMAC_MPADR_OFFSET 0x0010 /* MII Management PHY Address (8-bit) */
  56. #define HCS12_EMAC_MRADR_OFFSET 0x0011 /* MII Management Register Address (8-bit) */
  57. #define HCS12_EMAC_MWDATA_OFFSET 0x0012 /* MII Management Write Data (16-bit) */
  58. #define HCS12_EMAC_MRDATA_OFFSET 0x0014 /* MII Management Read Data (16-bit) */
  59. #define HCS12_EMAC_MCMST_OFFSET 0x0016 /* MII Management Command and Status (8-bit) */
  60. #define HCS12_EMAC_BUFCFG_OFFSET 0x0018 /* Ethernet Buffer Configuration (16-bit) */
  61. #define HCS12_EMAC_RXAEFP_OFFSET 0x001a /* Receive A End-of-Frame Pointer (16-bit) */
  62. #define HCS12_EMAC_RXBEFP_OFFSET 0x001c /* Receive B End-of-Frame Pointer (16-bit) */
  63. #define HCS12_EMAC_TXEFP_OFFSET 0x001e /* Transmit End-of-Frame Pointer (16-bit) */
  64. #define HCS12_EMAC_MCHASH48_OFFSET 0x0020 /* Multicast Hash Table 48-63 (16-bit) */
  65. #define HCS12_EMAC_MCHASH32_OFFSET 0x0022 /* Multicast Hash Table 32-47 (16-bit) */
  66. #define HCS12_EMAC_MCHASH16_OFFSET 0x0024 /* Multicast Hash Table 16-31 (16-bit) */
  67. #define HCS12_EMAC_MCHASH0_OFFSET 0x0026 /* Multicast Hash Table 0:15 (16-bit) */
  68. #define HCS12_EMAC_MACAD32_OFFSET 0x0028 /* MAC Unicast AAddress 32-47 (16-bit) */
  69. #define HCS12_EMAC_MACAD16_OFFSET 0x002a /* MAC Unicast AAddress 16-31 (16-bit) */
  70. #define HCS12_EMAC_MACAD0_OFFSET 0x002c /* MAC Unicast AAddress 0-15 (16-bit) */
  71. #define HCS12_EMAC_EMISC _OFFSET 0x002e /* Miscellaneous (16-bit) */
  72. /* Register Addresses ***************************************************************/
  73. #define HCS12_EMAC_NETCTL (HCS12_EMAC_BASE+HCS12_EMAC_NETCTL_OFFSET)
  74. #define HCS12_EMAC_RXCTS (HCS12_EMAC_BASE+HCS12_EMAC_RXCTS_OFFSET)
  75. #define HCS12_EMAC_TXCTS (HCS12_EMAC_BASE+HCS12_EMAC_TXCTS_OFFSET)
  76. #define HCS12_EMAC_ETCTL (HCS12_EMAC_BASE+HCS12_EMAC_ETCTL_OFFSET)
  77. #define HCS12_EMAC_ETYPE (HCS12_EMAC_BASE+HCS12_EMAC_ETYPE_OFFSET)
  78. #define HCS12_EMAC_PTIME (HCS12_EMAC_BASE+HCS12_EMAC_PTIME_OFFSET)
  79. #define HCS12_EMAC_IEVENT (HCS12_EMAC_BASE+HCS12_EMAC_IEVENT_OFFSET)
  80. #define HCS12_EMAC_IMASK (HCS12_EMAC_BASE+HCS12_EMAC_IMASK_OFFSET)
  81. #define HCS12_EMAC_SWRST (HCS12_EMAC_BASE+HCS12_EMAC_SWRST_OFFSET)
  82. #define HCS12_EMAC_MPADR (HCS12_EMAC_BASE+HCS12_EMAC_MPADR_OFFSET)
  83. #define HCS12_EMAC_MRADR (HCS12_EMAC_BASE+HCS12_EMAC_MRADR_OFFSET)
  84. #define HCS12_EMAC_MWDATA (HCS12_EMAC_BASE+HCS12_EMAC_MWDATA_OFFSET)
  85. #define HCS12_EMAC_MRDATA (HCS12_EMAC_BASE+HCS12_EMAC_MRDATA_OFFSET)
  86. #define HCS12_EMAC_MCMST (HCS12_EMAC_BASE+HCS12_EMAC_MCMST_OFFSET)
  87. #define HCS12_EMAC_BUFCFG (HCS12_EMAC_BASE+HCS12_EMAC_BUFCFG_OFFSET)
  88. #define HCS12_EMAC_RXAEFP (HCS12_EMAC_BASE+HCS12_EMAC_RXAEFP_OFFSET)
  89. #define HCS12_EMAC_RXBEFP (HCS12_EMAC_BASE+HCS12_EMAC_RXBEFP_OFFSET)
  90. #define HCS12_EMAC_TXEFP (HCS12_EMAC_BASE+HCS12_EMAC_TXEFP_OFFSET)
  91. #define HCS12_EMAC_MCHASH48 (HCS12_EMAC_BASE+HCS12_EMAC_MCHASH48_OFFSET)
  92. #define HCS12_EMAC_MCHASH32 (HCS12_EMAC_BASE+HCS12_EMAC_MCHASH32_OFFSET)
  93. #define HCS12_EMAC_MCHASH16 (HCS12_EMAC_BASE+HCS12_EMAC_MCHASH16_OFFSET)
  94. #define HCS12_EMAC_MCHASH0 (HCS12_EMAC_BASE+HCS12_EMAC_MCHASH0_OFFSET)
  95. #define HCS12_EMAC_MACAD32 (HCS12_EMAC_BASE+HCS12_EMAC_MACAD32_OFFSET)
  96. #define HCS12_EMAC_MACAD16 (HCS12_EMAC_BASE+HCS12_EMAC_MACAD16_OFFSET)
  97. #define HCS12_EMAC_MACAD0 (HCS12_EMAC_BASE+HCS12_EMAC_MACAD0_OFFSET)
  98. #define HCS12_EMAC_EMISC (HCS12_EMAC_BASE+HCS12_EMAC_EMISC_OFFSET)
  99. /* Register Bit-Field Definitions ***************************************************/
  100. /* Network Control (8-bit) */
  101. #define EMAC_NETCTL_FDX (1 << 1) /* Bit 1: Full Duplex */
  102. #define EMAC_NETCTL_MLB (1 << 2) /* Bit 2: MAC Loopback */
  103. #define EMAC_NETCTL_EXTPHY (1 << 3) /* Bit 3: External PHY */
  104. #define EMAC_NETCTL_ESWAI (1 << 4) /* Bit 4: EMAC Disabled during Wait Mode */
  105. #define EMAC_NETCTL_EMACE (1 << 7) /* Bit 7: EMAC Enable */
  106. /* Receive Control and Status (8-bit) */
  107. #define EMAC_RXCTS_BCREJ (1 << 0) /* Bit 0: Broadcast Reject */
  108. #define EMAC_RXCTS_CONMC (1 << 1) /* Bit 1: Conditional Multicast */
  109. #define EMAC_RXCTS_PROM (1 << 2) /* Bit 2: Promiscuous Mode */
  110. #define EMAC_RXCTS_RFCE (1 << 4) /* Bit 4: Reception Flow Control Enable */
  111. #define EMAC_RXCTS_RXACT (1 << 7) /* Bit 7: Receiver Active Status */
  112. /* Transmit Control and Status (8-bit) */
  113. #define EMAC_TXCTS_TCMD_SHIFT (0) /* Bits 0-1: Transmit Command */
  114. #define EMAC_TXCTS_TCMD_MASK (3)
  115. # define EMAC_TXCTS_TCMD_START (1) /* Transmit buffer frame */
  116. # define EMAC_TXCTS_TCMD_PAUSE (2) /* Transmit PAUSE frame (full-duplex mode only) */
  117. # define EMAC_TXCTS_TCMD_ABORT (3) /* Abort transmission */
  118. #define EMAC_TXCTS_SSB (1 << 3) /* Bit 3: Single Slot Backoff */
  119. #define EMAC_TXCTS_PTRC (1 << 4) /* Bit 4: PAUSE Timer Register Control */
  120. #define EMAC_TXCTS_CSLF (1 << 5) /* Bit 5: Carrier Sense Lost Flag */
  121. #define EMAC_TXCTS_TXACT (1 << 7) /* Bit 7: Transmitter Active Status */
  122. /* Ethertype Control (8-bit) */
  123. #define EMAC_ETCTL_FIEEE (1 << 0) /* Bit 0: IEEE802.3 Length Field Ethertype */
  124. #define EMAC_ETCTL_FIPV4 (1 << 1) /* Bit 1: Internet Protocol Version 4 (IPv4) Ethertype */
  125. #define EMAC_ETCTL_FARP (1 << 2) /* Bit 2: Address Resolution Protocol (ARP) Ethertype */
  126. #define EMAC_ETCTL_FIPV6 (1 << 3) /* Bit 3: Internet Protocol Version 6 (IPv6) Ethertype */
  127. #define EMAC_ETCTL_FEMW (1 << 4) /* Bit 4: Emware Ethertype */
  128. #define EMAC_ETCTL_FPET (1 << 7) /* Bit 7: Programmable Ethertype */
  129. /* Programmable Ethertype (16-bit) -- 16-bit Ethernet type data */
  130. /* PAUSE Timer Value and Counter (16-bit) -- 16-bit PAUSER timer value */
  131. /* Interrupt Event (16-bit) */
  132. /* Interrupt Mask (16-bit) */
  133. #define EMAC_INT_TXCI (1 << 1) /* Bit 1: Frame Transmission Complete Interrupt */
  134. #define EMAC_INT_ECI (1 << 4) /* Bit 4: Excessive Collision Interrupt */
  135. #define EMAC_INT_LCI (1 << 5) /* Bit 5: Late Collision Interrupt */
  136. #define EMAC_INT_MMCI (1 << 7) /* Bit 7: MII Management Transfer Complete Interrupt */
  137. #define EMAC_INT_RXBCI (1 << 8) /* Bit 8: Valid Frame Reception to Receive Buffer B Complete Interrupt */
  138. #define EMAC_INT_RXACI (1 << 9) /* Bit 9: Valid Frame Reception to Receive Buffer A Complete Interrupt */
  139. #define EMAC_INT_RXBOI (1 << 10) /* Bit 10: Receive Buffer B Overrun Interrupt */
  140. #define EMAC_INT_RXAOI (1 << 11) /* Bit 11: Receive Buffer A Overrun Interrupt */
  141. #define EMAC_INT_RXEI (1 << 12) /* Bit 12: Receive Error Interrupt */
  142. #define EMAC_INT_BREI (1 << 13) /* Bit 13: Babbling Receive Error Interrupt */
  143. #define EMAC_INT_RFCI (1 << 15) /* Bit 15: Receive Flow Control Interrupt */
  144. /* Software Reset (8-bit) */
  145. #define EMAC_SWRST_MACRST (1 << 7) /* Bit 7: EMAC is reset */
  146. /* MII Management PHY Address (8-bit) */
  147. #define EMAC_MPADR_MASK (0x1f)
  148. /* MII Management Register Address (8-bit) */
  149. #define EMAC_MRADR_MASK (0x1f)
  150. /* MII Management Write Data (16-bit) -- 16-bit write data */
  151. /* MII Management Read Data (16-bit) -- 16-bit read data */
  152. /* MII Management Command and Status (8-bit) */
  153. #define EMAC_MCMST_MDCSEL_SHIFT (0) /* Bits 0-3: Management Clock Rate Sel */
  154. #define EMAC_MCMST_MDCSEL_MASK (15) /* MDC frequency = Bus clock frequency / (2 * MDCSEL) */
  155. #define EMAC_MCMST_NOPRE (1 << 4) /* Bit 4: No Preamble */
  156. #define EMAC_MCMST_BUSY (1 << 5) /* Bit 5: Operation in Progress */
  157. #define EMAC_MCMST_OP_SHIFT (6) /* Bits 6-7: Operation Code */
  158. #define EMAC_MCMST_OP_MASK (3 << EMAC_MCMST_OP_SHIFT)
  159. # define EMAC_MCMST_OP_IGNORE (0 << EMAC_MCMST_OP_SHIFT)
  160. # define EMAC_MCMST_OP_WRITE (1 << EMAC_MCMST_OP_SHIFT)
  161. # define EMAC_MCMST_OP_READ (2 << EMAC_MCMST_OP_SHIFT)
  162. /* Ethernet Buffer Configuration (16-bit) */
  163. #define EMAC_BUFCFG_MAXFL_SHIFT (0) /* Bits 0-10 Receive Maximum Frame Length */
  164. #define EMAC_BUFCFG_MAXFL_MASK (0x07ff)
  165. #define EMAC_BUFCFG_BUFMAP_SHIFT (12) /* Bits 12-14: Buffer Size and Starting Address Mapping */
  166. #define EMAC_BUFCFG_BUFMAP_SHIFT (7 << EMAC_BUFCFG_BUFMAP_SHIFT)
  167. # define EMAC_BUFCFG_BUFMAP_128 (0 << EMAC_BUFCFG_BUFMAP_SHIFT) /* Rx/Tx = 128 bytes */
  168. # define EMAC_BUFCFG_BUFMAP_256 (1 << EMAC_BUFCFG_BUFMAP_SHIFT) /* Rx/Tx = 256 bytes */
  169. # define EMAC_BUFCFG_BUFMAP_512 (2 << EMAC_BUFCFG_BUFMAP_SHIFT) /* Rx/Tx = 512 bytes */
  170. # define EMAC_BUFCFG_BUFMAP_1024 (3 << EMAC_BUFCFG_BUFMAP_SHIFT) /* Rx/Tx = 1Kb */
  171. # define EMAC_BUFCFG_BUFMAP_1536 (4 << EMAC_BUFCFG_BUFMAP_SHIFT) /* Rx/Tx = 1.5Kb */
  172. /* Receive A End-of-Frame Pointer (16-bit) */
  173. #define EMAC_RXAEFP_MASK (0x07ff)
  174. /* Receive B End-of-Frame Pointer (16-bit) */
  175. #define EMAC_RXBEFP_MASK (0x07ff)
  176. /* Transmit End-of-Frame Pointer (16-bit) */
  177. #define EMAC_TXEFP_MASK (0x07ff)
  178. /* Multicast Hash Table 48-63 (16-bit) -- 16-bits of MAC address */
  179. /* Multicast Hash Table 32-47 (16-bit) -- 16-bits of MAC address */
  180. /* Multicast Hash Table 16-31 (16-bit) -- 16-bits of MAC address */
  181. /* Multicast Hash Table 0:15 (16-bit) -- 16-bits of MAC address */
  182. /* MAC Unicast Address 32-47 (16-bit) -- 16-bits of address */
  183. /* MAC Unicast AAddress 16-31 (16-bit) -- 16-bits of address */
  184. /* MAC Unicast AAddress 0-15 (16-bit) -- 16-bits of address */
  185. /* Miscellaneous (16-bit) */
  186. #define EMAC_EMISC_SHIFT (0) /* Bits 0-10: Misc data */
  187. #define EMAC_EMISC_MASK (0x07ff)
  188. #define EMAC_EMISC_INDEX_SHIFT (13) /* Bits 13-15: Miscellaneous Index */
  189. #define EMAC_EMISC_INDEX_MASK (7 << EMAC_EMISC_INDEX_SHIFT)
  190. # define EMAC_EMISC_INDEX_TXBYT (3 << EMAC_EMISC_INDEX_SHIFT) /* Transmit Frame Byte Counter */
  191. # define EMAC_EMISC_INDEX_BSLOT (4 << EMAC_EMISC_INDEX_SHIFT) /* Backoff Slot Time Counter */
  192. # define EMAC_EMISC_INDEX_RETX (5 << EMAC_EMISC_INDEX_SHIFT) /* Retransmission Counter */
  193. # define EMAC_EMISC_INDEX_RANDOM (6 << EMAC_EMISC_INDEX_SHIFT) /* Backoff Random Number */
  194. /************************************************************************************
  195. * Public Types
  196. ************************************************************************************/
  197. /************************************************************************************
  198. * Public Data
  199. ************************************************************************************/
  200. /************************************************************************************
  201. * Public Functions
  202. ************************************************************************************/
  203. #endif /* __ARCH_ARM_HC_SRC_M9S12_M9S12_EMAC_H */