Remove duplicate define. Put all phy chip specific defines in its
[bertos.git] / bertos / cpu / arm / drv / eth_at91.h
1 /**
2   * \file
3   * <!--
4   * This file is part of BeRTOS.
5   *
6   * Bertos is free software; you can redistribute it and/or modify
7   * it under the terms of the GNU General Public License as published by
8   * the Free Software Foundation; either version 2 of the License, or
9   * (at your option) any later version.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with this program; if not, write to the Free Software
18   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19   *
20   * As a special exception, you may use this file as part of a free software
21   * library without restriction.  Specifically, if other files instantiate
22   * templates or use macros or inline functions from this file, or you compile
23   * this file and link it with other files to produce an executable, this
24   * file does not by itself cause the resulting executable to be covered by
25   * the GNU General Public License.  This exception does not however
26   * invalidate any other reasons why the executable file might be covered by
27   * the GNU General Public License.
28   *
29   * Copyright 2009 Develer S.r.l. (http://www.develer.com/)
30   * All Rights Reserved.
31   * -->
32   *
33   * \brief EMAC driver for AT91SAM7X Family, interface.
34   *
35   * \author Daniele Basile <asterix@develer.com>
36   * \author Andrea Righi <arighi@develer.com>
37   */
38
39 #ifndef ETH_AT91_H
40 #define ETH_AT91_H
41
42 #include <cpu/types.h>
43
44 #define EMAC_TX_BUFSIZ          1518  //!!! Don't change this
45 #define EMAC_TX_BUFFERS         1     //!!! Don't change this
46 #define EMAC_TX_DESCRIPTORS     EMAC_TX_BUFFERS
47
48 #define EMAC_RX_BUFFERS         32    //!!! Don't change this
49 #define EMAC_RX_BUFSIZ          128   //!!! Don't change this
50 #define EMAC_RX_DESCRIPTORS     EMAC_RX_BUFFERS
51
52 // Flag to manage local tx buffer
53 #define TXS_USED            0x80000000  //Used buffer.
54 #define TXS_WRAP            0x40000000  //Last descriptor.
55 #define TXS_ERROR           0x20000000  //Retry limit exceeded.
56 #define TXS_UNDERRUN        0x10000000  //Transmit underrun.
57 #define TXS_NO_BUFFER       0x08000000  //Buffer exhausted.
58 #define TXS_NO_CRC          0x00010000  //CRC not appended.
59 #define TXS_LAST_BUFF       0x00008000  //Last buffer of frame.
60 #define TXS_LENGTH_FRAME    0x000007FF  // Length of frame including FCS.
61
62 // Flag to manage local rx buffer
63 #define RXBUF_OWNERSHIP     0x00000001
64 #define RXBUF_WRAP          0x00000002
65
66 #define BUF_ADDRMASK        0xFFFFFFFC
67
68 #define RXS_BROADCAST_ADDR  0x80000000  // Broadcast address detected.
69 #define RXS_MULTICAST_HASH  0x40000000  // Multicast hash match.
70 #define RXS_UNICAST_HASH    0x20000000  // Unicast hash match.
71 #define RXS_EXTERNAL_ADDR   0x10000000  // External address match.
72 #define RXS_SA1_ADDR        0x04000000  // Specific address register 1 match.
73 #define RXS_SA2_ADDR        0x02000000  // Specific address register 2 match.
74 #define RXS_SA3_ADDR        0x01000000  // Specific address register 3 match.
75 #define RXS_SA4_ADDR        0x00800000  // Specific address register 4 match.
76 #define RXS_TYPE_ID         0x00400000  // Type ID match.
77 #define RXS_VLAN_TAG        0x00200000  // VLAN tag detected.
78 #define RXS_PRIORITY_TAG    0x00100000  // Priority tag detected.
79 #define RXS_VLAN_PRIORITY   0x000E0000  // VLAN priority.
80 #define RXS_CFI_IND         0x00010000  // Concatenation format indicator.
81 #define RXS_EOF             0x00008000  // End of frame.
82 #define RXS_SOF             0x00004000  // Start of frame.
83 #define RXS_RBF_OFFSET      0x00003000  // Receive buffer offset mask.
84 #define RXS_LENGTH_FRAME    0x000007FF  // Length of frame including FCS.
85
86 #define EMAC_RSR_BITS   (BV(EMAC_BNA) | BV(EMAC_REC) | BV(EMAC_OVR))
87 #define EMAC_TSR_BITS   (BV(EMAC_UBR) | BV(EMAC_COL) | BV(EMAC_RLES) | \
88                         BV(EMAC_BEX) | BV(EMAC_COMP) | BV(EMAC_UND))
89
90 typedef struct BufDescriptor
91 {
92         volatile uint32_t addr;
93         volatile uint32_t stat;
94 } BufDescriptor;
95
96 #endif /* ETH_AT91_H */