GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / arch / mips / board / bcm9635x / include / dev_bcm635x_enet.h
blob8b79966768f602cc29ec527a26650bd4992b7e36
1 /*
2 <:copyright-broadcom
4 Copyright (c) 2002 Broadcom Corporation
5 All Rights Reserved
6 No portions of this material may be reproduced in any form without the
7 written permission of:
8 Broadcom Corporation
9 16215 Alton Parkway
10 Irvine, California 92619
11 All information contained in this document is Broadcom Corporation
12 company private, proprietary, and trade secret.
16 #ifndef _DEV_BCM6352ENET_H_
17 #define _DEV_BCM6352ENET_H_
19 #include "6352_map.h"
21 /*---------------------------------------------------------------------*/
22 /* specify number of BDs and buffers to use */
23 /*---------------------------------------------------------------------*/
24 #define NR_TX_BDS 100
25 #define NR_RX_BDS 100
26 #define ENET_MAX_BUF_SIZE 1514 /* Body(1500) + EH_SIZE(14) */
27 #define ENET_MAX_MTU_SIZE 1536 /* Body(1500) + EH_SIZE(14) + FCS(4) */
28 /* + BRCM TYPE(2) + BRCM_TAG(4) + */
29 /* RECALCULATE CRC(4) + pad to 16 */
30 /* boundary(8) */
31 #define HEDR_LEN 18
32 #define DMA_MAX_BURST_LENGTH 16 /* in 32 bit words */
34 #define ETH_ALEN 6
36 typedef struct Brcm_Hdr {
37 unsigned char dAddr[ETH_ALEN];/* destination hardware address */
38 unsigned char sAddr[ETH_ALEN];/* destination hardware address */
39 uint16_t brcmType; /* special Broadcom type */
40 uint32_t brcmTag; /* special Broadcom tag */
41 }__attribute__((packed)) Brcm_Hdr;
44 * device context
45 */
46 typedef struct bcm6352enet_softc {
47 unsigned long dualMacMode; /* dual mac mode */
48 unsigned char macAddr[ETH_ALEN];
50 /* transmit variables */
51 volatile DmaChannel *dmaChannels;
52 volatile DmaChannel *txDma; /* location of transmit DMA register set */
53 unsigned char txBuf[ENET_MAX_MTU_SIZE+16];
54 unsigned char *txBufPtr;
56 /* receive variables */
57 volatile DmaChannel *rxDma; /* location of receive DMA register set */
58 volatile DmaDesc *rxBds; /* Memory location of rx bd ring */
59 volatile DmaDesc *rxBdAssignPtr; /* ptr to next rx bd to become full */
60 volatile DmaDesc *rxBdReadPtr; /* ptr to next rx bd to be processed */
61 volatile DmaDesc *rxLastBdPtr; /* ptr to last allocated rx bd */
62 volatile DmaDesc *rxFirstBdPtr; /* ptr to first allocated rx bd */
63 int nrRxBds; /* number of receive bds */
64 unsigned long rxBufLen; /* size of rx buffers for DMA */
65 uint16_t chipId; /* chip's id */
66 uint16_t chipRev; /* step */
67 unsigned char *rxBuffers;
68 unsigned char rxMem[NR_RX_BDS * (sizeof(DmaDesc)+ENET_MAX_MTU_SIZE+16)];
69 } bcm6352enet_softc;
72 // BD macros
73 #define IncRxBDptr(x, s) if (x == ((bcm6352enet_softc *)s)->rxLastBdPtr) \
74 x = ((bcm6352enet_softc *)s)->rxFirstBdPtr; \
75 else x++
78 /* The Broadcom type and tag fields */
79 #define BRCM_TYPE 0x8874
81 /* header length: DA (6) + SA (6) + BRCM_TYPE (2) + BRCM_TAG (4) */
82 #define HEADER_LENGTH 18
84 /* SMP port bit definition */
85 #define SMP_PORT 0x40 /* frame management port */
86 #define SMP_PORT_ID 0x0A /* management port ID */
87 #define FORWARDING_STATE 0xA0 /* STP state */
88 #define RX_DISABLE 0x01 /* receive disable */
89 #define TX_DISABLE 0x02 /* transmit disable */
90 #define SW_FWDG_EN 0x02 /* software forwarding enabled */
91 #define MANAGED_MODE 0x01 /* managed mode */
93 /* PORT ID definition */
94 #define MANAGEMENT_PORT 10
95 #define PHY0_PORT 0
96 #define PHY1_PORT 1
98 static inline int test_bit(int nr, volatile void *addr)
100 return ((1UL << (nr & 31)) & (((const unsigned int *) addr)[nr >> 5])) != 0;
103 static inline void set_bit(int nr, volatile void * addr)
105 int mask;
106 volatile int *a = addr;
108 a += nr >> 5;
109 mask = 1 << (nr & 0x1f);
110 *a |= mask;
113 static inline void clear_bit(int nr, volatile void * addr)
115 int mask;
116 volatile int *a = addr;
118 a += nr >> 5;
119 mask = 1 << (nr & 0x1f);
120 *a &= ~mask;
123 static inline int test_and_set_bit(int nr, volatile void * addr)
125 int mask, retval;
126 volatile int *a = addr;
128 a += nr >> 5;
129 mask = 1 << (nr & 0x1f);
130 retval = (mask & *a) != 0;
131 *a |= mask;
133 return retval;
136 static inline int test_and_clear_bit(int nr, volatile void * addr)
138 int mask, retval;
139 volatile int *a = addr;
141 a += nr >> 5;
142 mask = 1 << (nr & 0x1f);
143 retval = (mask & *a) != 0;
144 *a &= ~mask;
146 return retval;
149 #endif /* _DEV_BCM6352ENET_H_ */