]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/arm/at91/if_atereg.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / arm / at91 / if_atereg.h
1 /*-
2  * Copyright (c) 2006 M. Warner Losh.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  */
25
26 /* $FreeBSD$ */
27
28 #ifndef ARM_AT91_IF_ATEREG_H
29 #define ARM_AT91_IF_ATEREG_H
30
31 #define ETH_CTL         0x00            /* EMAC Control Register */
32 #define ETH_CFG         0x04            /* EMAC Configuration Register */
33 #define ETH_SR          0x08            /* EMAC STatus Register */
34 #define ETH_TAR         0x0c            /* EMAC Transmit Address Register */
35 #define ETH_TCR         0x10            /* EMAC Transmit Control Register */
36 #define ETH_TSR         0x14            /* EMAC Transmit Status Register */
37 #define ETH_RBQP        0x18            /* EMAC Receive Buffer Queue Pointer */
38                 /*      0x1c               reserved */
39 #define ETH_RSR         0x20            /* EMAC Receive Status Register */
40 #define ETH_ISR         0x24            /* EMAC Interrupt Status Register */
41 #define ETH_IER         0x28            /* EMAC Interrupt Enable Register */
42 #define ETH_IDR         0x2c            /* EMAC Interrupt Disable Register */
43 #define ETH_IMR         0x30            /* EMAC Interrupt Mask Register */
44 #define ETH_MAN         0x34            /* EMAC PHY Maintenance Register */
45                 /*      0x38               reserved */
46                 /*      0x3c               reserved */
47 #define ETH_FRA         0x40            /* Frames Transmitted OK Register */
48 #define ETH_SCOL        0x44            /* Single Collision Frame Register */
49 #define ETH_MCOL        0x48            /* Multiple Collision Frame Register */
50 #define ETH_OK          0x4c            /* Frames Received OK Register */
51 #define ETH_SEQE        0x50            /* Frame Check Sequence Error Reg */
52 #define ETH_ALE         0x54            /* Alignment Error Register */
53 #define ETH_DTE         0x58            /* Deferred Transmittion Frame Reg */
54 #define ETH_LCOL        0x5c            /* Late Collision Register */
55 #define ETH_ECOL        0x60            /* Excessive Collision Register */
56 #define ETH_TUE         0x64            /* Transmit Underrun Error Register */
57 #define ETH_CSE         0x68            /* Carrier Sense Error Register */
58 #define ETH_DRFC        0x6c            /* Discarded RX Frame Register */
59 #define ETH_ROV         0x68            /* Receive Overrun Register */
60 #define ETH_CDE         0x64            /* Code Error Register */
61 #define ETH_ELR         0x78            /* Excessive Length Error Register */
62 #define ETH_RJB         0x7c            /* Receive Jabber Register */
63 #define ETH_USF         0x80            /* Undersize Frame Register */
64 #define ETH_SQEE        0x84            /* SQE Test Error Register */
65                 /*      0x88               reserved */
66                 /*      0x8c               reserved */
67 #define ETH_HSL         0x90            /* EMAC Hash Address Low [31:0] */
68 #define ETH_HSH         0x94            /* EMAC Hash Address High [63:32] */
69 #define ETH_SA1L        0x98            /* EMAC Specific Address 1 Low */
70 #define ETH_SA1H        0x9c            /* EMAC Specific Address 1 High */
71 #define ETH_SA2L        0xa0            /* EMAC Specific Address 2 Low */
72 #define ETH_SA2H        0xa4            /* EMAC Specific Address 2 High */
73 #define ETH_SA3L        0xa8            /* EMAC Specific Address 3 Low */
74 #define ETH_SA3H        0xac            /* EMAC Specific Address 3 High */
75 #define ETH_SA4L        0xb0            /* EMAC Specific Address 4 Low */
76 #define ETH_SA4H        0xb4            /* EMAC Specific Address 4 High */
77
78
79 /* ETH_CTL */
80 #define ETH_CTL_LB      (1U << 0)       /* LB: Loopback */
81 #define ETH_CTL_LBL     (1U << 1)       /* LBL: Loopback Local */
82 #define ETH_CTL_RE      (1U << 2)       /* RE: Receive Enable */
83 #define ETH_CTL_TE      (1U << 3)       /* TE: Transmit Enable */
84 #define ETH_CTL_MPE     (1U << 4)       /* MPE: Management Port Enable */
85 #define ETH_CTL_CSR     (1U << 5)       /* CSR: Clear Statistics Registers */
86 #define ETH_CTL_ISR     (1U << 6)       /* ISR: Incremenet Statistics Regs */
87 #define ETH_CTL_WES     (1U << 7)       /* WES: Write Enable Statistics regs */
88 #define ETH_CTL_BP      (1U << 8)       /* BP: Back Pressure */
89
90 /* ETH_CFG */
91 #define ETH_CFG_SPD     (1U << 0)       /* SPD: Speed 1 == 100: 0 == 10 */
92 #define ETH_CFG_FD      (1U << 1)       /* FD: Full duplex */
93 #define ETH_CFG_BR      (1U << 2)       /* BR: Bit Rate (optional?) */
94                 /* bit 3 reserved */
95 #define ETH_CFG_CAF     (1U << 4)       /* CAF: Copy All Frames */
96 #define ETH_CFG_NBC     (1U << 5)       /* NBC: No Broadcast */
97 #define ETH_CFG_MTI     (1U << 6)       /* MTI: Multicast Hash Enable */
98 #define ETH_CFG_UNI     (1U << 7)       /* UNI: Unicast Hash Enable */
99 #define ETH_CFG_BIG     (1U << 8)       /* BIG: Receive 1522 Bytes */
100 #define ETH_CFG_EAE     (1U << 9)       /* EAE: External Address Match En */
101 #define ETH_CFG_CLK_8   (0U << 10)      /* CLK: Clock / 8 */
102 #define ETH_CFG_CLK_16  (1U << 10)      /* CLK: Clock / 16 */
103 #define ETH_CFG_CLK_32  (2U << 10)      /* CLK: Clock / 32 */
104 #define ETH_CFG_CLK_64  (3U << 10)      /* CLK: Clock / 64 */
105 #define ETH_CFG_RTY     (1U << 12)      /* RTY: Retry Test*/
106 #define ETH_CFG_RMII    (1U << 13)      /* RMII: Reduce MII */
107
108 /* ETH_SR */
109 #define ETH_SR_LINK     (1U << 0)       /* Reserved! */
110 #define ETH_SR_MDIO     (1U << 1)       /* MDIO pin status */
111 #define ETH_SR_IDLE     (1U << 2)       /* IDLE (PHY logic) */
112
113 /* ETH_TCR */
114 #define ETH_TCR_NCRC    (1U << 15)      /* NCRC: No CRC */
115
116 /* ETH_TSR */
117 #define ETH_TSR_OVR     (1U << 0)       /* OVR: Ethernet Transmit Overrun */
118 #define ETH_TSR_COL     (1U << 1)       /* COL: Collision Occurred */
119 #define ETH_TSR_RLE     (1U << 2)       /* RLE: Retry Limit Exceeded */
120 #define ETH_TSR_IDLE    (1U << 3)       /* IDLE: Transmitter Idle */
121 #define ETH_TSR_BNQ     (1U << 4)       /* BNQ: Enet Tran Buff not Queued */
122 #define ETH_TSR_COMP    (1U << 5)       /* COMP: Transmit Complete */
123 #define ETH_TSR_UND     (1U << 6)       /* UND: Transmit Underrun */
124 #define ETH_TSR_WR_MASK (0x67)  /* write 1 to clear bits */
125
126 /* ETH_RSR */
127 #define ETH_RSR_BNA     (1U << 0)       /* BNA: Buffer Not Available */
128 #define ETH_RSR_REC     (1U << 1)       /* REC: Frame Received */
129 #define ETH_RSR_OVR     (1U << 2)       /* OVR: RX Overrun */
130
131 /* ETH_ISR */
132 #define ETH_ISR_DONE    (1U << 0)       /* DONE: Management Done */
133 #define ETH_ISR_RCOM    (1U << 1)       /* RCOM: Receive Complete */
134 #define ETH_ISR_RBNA    (1U << 2)       /* RBNA: Receive Buffer Not Avail */
135 #define ETH_ISR_TOVR    (1U << 3)       /* TOVR: Transmit Buffer Overrun */
136 #define ETH_ISR_TUND    (1U << 4)       /* TUND: Transmit Buffer Underrun */
137 #define ETH_ISR_RTRY    (1U << 5)       /* RTRY: Retry Limit */
138 #define ETH_ISR_TBRE    (1U << 6)       /* TBRE: Trasnmit Buffer Reg empty */
139 #define ETH_ISR_TCOM    (1U << 7)       /* TCOM: Transmit Complete */
140 #define ETH_ISR_TIDLE   (1U << 8)       /* TIDLE: Transmit Idle */
141 #define ETH_ISR_LINK    (1U << 9)       /* LINK: Link pin delta (optional) */
142 #define ETH_ISR_ROVR    (1U << 10)      /* ROVR: RX Overrun */
143 #define ETH_ISR_ABT     (1U << 11)      /* ABT: Abort */
144
145 /* ETH_MAN */
146 #define ETH_MAN_BITS    0x40020000      /* HIGH and CODE bits */
147 #define ETH_MAN_READ    (2U << 28)
148 #define ETH_MAN_WRITE   (1U << 28)
149 #define ETH_MAN_PHYA_BIT 23
150 #define ETH_MAN_REGA_BIT 18
151 #define ETH_MAN_VALUE_MASK      0xffffU
152 #define ETH_MAN_REG_WR(phy, reg, val) \
153                 (ETH_MAN_BITS | ETH_MAN_WRITE | ((phy) << ETH_MAN_PHYA_BIT) | \
154                 ((reg) << ETH_MAN_REGA_BIT) | ((val) & ETH_MAN_VALUE_MASK))
155 #define ETH_MAN_REG_RD(phy, reg) \
156                 (ETH_MAN_BITS | ETH_MAN_READ | ((phy) << ETH_MAN_PHYA_BIT) | \
157                 ((reg) << ETH_MAN_REGA_BIT))
158
159 typedef struct {
160         uint32_t        addr;
161 #define ETH_CPU_OWNER   (1U << 0)
162 #define ETH_WRAP_BIT    (1U << 1)
163         uint32_t        status;
164 #define ETH_LEN_MASK    0x7ff
165 #define ETH_MAC_LOCAL_4 (1U << 23)      /* Packet matched addr 4 */
166 #define ETH_MAC_LOCAL_3 (1U << 24)      /* Packet matched addr 3 */
167 #define ETH_MAC_LOCAL_2 (1U << 25)      /* Packet matched addr 2 */
168 #define ETH_MAC_LOCAL_1 (1U << 26)      /* Packet matched addr 1 */
169 #define ETH_MAC_UNK     (1U << 27)      /* Unkown source address RFU */
170 #define ETH_MAC_EXT     (1U << 28)      /* External Address */
171 #define ETH_MAC_UCAST   (1U << 29)      /* Unicast hash match */
172 #define ETH_MAC_MCAST   (1U << 30)      /* Multicast hash match */
173 #define ETH_MAC_ONES    (1U << 31)      /* Global all ones bcast addr */
174 } eth_rx_desc_t;
175
176 #endif /* ARM_AT91_IF_ATEREG_H */