at91_emac.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (C) 2009 Jens Scharsig (js_at_ng@scharsoft.de)
  3. *
  4. * based on AT91RM9200 datasheet revision I (36. Ethernet MAC (EMAC))
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #ifndef AT91_H
  25. #define AT91_H
  26. typedef struct at91_emac {
  27. u32 ctl;
  28. u32 cfg;
  29. u32 sr;
  30. u32 tar;
  31. u32 tcr;
  32. u32 tsr;
  33. u32 rbqp;
  34. u32 reserved0;
  35. u32 rsr;
  36. u32 isr;
  37. u32 ier;
  38. u32 idr;
  39. u32 imr;
  40. u32 man;
  41. u32 reserved1[2];
  42. u32 fra;
  43. u32 scol;
  44. u32 mocl;
  45. u32 ok;
  46. u32 seqe;
  47. u32 ale;
  48. u32 dte;
  49. u32 lcol;
  50. u32 ecol;
  51. u32 cse;
  52. u32 tue;
  53. u32 cde;
  54. u32 elr;
  55. u32 rjb;
  56. u32 usf;
  57. u32 sqee;
  58. u32 drfc;
  59. u32 reserved2[3];
  60. u32 hsh;
  61. u32 hsl;
  62. u32 sa1l;
  63. u32 sa1h;
  64. u32 sa2l;
  65. u32 sa2h;
  66. u32 sa3l;
  67. u32 sa3h;
  68. u32 sa4l;
  69. u32 sa4h;
  70. } at91_emac_t;
  71. #define AT91_EMAC_CTL_LB 0x0001
  72. #define AT91_EMAC_CTL_LBL 0x0002
  73. #define AT91_EMAC_CTL_RE 0x0004
  74. #define AT91_EMAC_CTL_TE 0x0008
  75. #define AT91_EMAC_CTL_MPE 0x0010
  76. #define AT91_EMAC_CTL_CSR 0x0020
  77. #define AT91_EMAC_CTL_ISR 0x0040
  78. #define AT91_EMAC_CTL_WES 0x0080
  79. #define AT91_EMAC_CTL_BP 0x1000
  80. #define AT91_EMAC_CFG_SPD 0x0001
  81. #define AT91_EMAC_CFG_FD 0x0002
  82. #define AT91_EMAC_CFG_BR 0x0004
  83. #define AT91_EMAC_CFG_CAF 0x0010
  84. #define AT91_EMAC_CFG_NBC 0x0020
  85. #define AT91_EMAC_CFG_MTI 0x0040
  86. #define AT91_EMAC_CFG_UNI 0x0080
  87. #define AT91_EMAC_CFG_BIG 0x0100
  88. #define AT91_EMAC_CFG_EAE 0x0200
  89. #define AT91_EMAC_CFG_CLK_MASK 0xFFFFF3FF
  90. #define AT91_EMAC_CFG_MCLK_8 0x0000
  91. #define AT91_EMAC_CFG_MCLK_16 0x0400
  92. #define AT91_EMAC_CFG_MCLK_32 0x0800
  93. #define AT91_EMAC_CFG_MCLK_64 0x0C00
  94. #define AT91_EMAC_CFG_RTY 0x1000
  95. #define AT91_EMAC_CFG_RMII 0x2000
  96. #define AT91_EMAC_SR_LINK 0x0001
  97. #define AT91_EMAC_SR_MDIO 0x0002
  98. #define AT91_EMAC_SR_IDLE 0x0004
  99. #define AT91_EMAC_TCR_LEN(x) (x & 0x7FF)
  100. #define AT91_EMAC_TCR_NCRC 0x8000
  101. #define AT91_EMAC_TSR_OVR 0x0001
  102. #define AT91_EMAC_TSR_COL 0x0002
  103. #define AT91_EMAC_TSR_RLE 0x0004
  104. #define AT91_EMAC_TSR_TXIDLE 0x0008
  105. #define AT91_EMAC_TSR_BNQ 0x0010
  106. #define AT91_EMAC_TSR_COMP 0x0020
  107. #define AT91_EMAC_TSR_UND 0x0040
  108. #define AT91_EMAC_RSR_BNA 0x0001
  109. #define AT91_EMAC_RSR_REC 0x0002
  110. #define AT91_EMAC_RSR_OVR 0x0004
  111. /* ISR, IER, IDR, IMR use the same bits */
  112. #define AT91_EMAC_IxR_DONE 0x0001
  113. #define AT91_EMAC_IxR_RCOM 0x0002
  114. #define AT91_EMAC_IxR_RBNA 0x0004
  115. #define AT91_EMAC_IxR_TOVR 0x0008
  116. #define AT91_EMAC_IxR_TUND 0x0010
  117. #define AT91_EMAC_IxR_RTRY 0x0020
  118. #define AT91_EMAC_IxR_TBRE 0x0040
  119. #define AT91_EMAC_IxR_TCOM 0x0080
  120. #define AT91_EMAC_IxR_TIDLE 0x0100
  121. #define AT91_EMAC_IxR_LINK 0x0200
  122. #define AT91_EMAC_IxR_ROVR 0x0400
  123. #define AT91_EMAC_IxR_HRESP 0x0800
  124. #define AT91_EMAC_MAN_DATA_MASK 0xFFFF
  125. #define AT91_EMAC_MAN_CODE_802_3 0x00020000
  126. #define AT91_EMAC_MAN_REGA(reg) ((reg & 0x1F) << 18)
  127. #define AT91_EMAC_MAN_PHYA(phy) ((phy & 0x1F) << 23)
  128. #define AT91_EMAC_MAN_RW_R 0x20000000
  129. #define AT91_EMAC_MAN_RW_W 0x10000000
  130. #define AT91_EMAC_MAN_HIGH 0x40000000
  131. #define AT91_EMAC_MAN_LOW 0x80000000
  132. #endif