4 Copyright (c) 2002 Broadcom Corporation
6 No portions of this material may be reproduced in any form without the
10 Irvine, California 92619
11 All information contained in this document is Broadcom Corporation
12 company private, proprietary, and trade secret.
16 #ifndef __BCM6345_ETH_H
17 #define __BCM6345_ETH_H
21 #include "6345_common.h"
23 #define MII_READ_DELAY 1000
24 #define MII_WRITE_DELAY 10000
26 // from linux if_ether.h
27 #define ETH_ALEN 6 /* Octets in one ethernet addr */
28 #define ETH_HLEN 14 /* Total octets in header. */
29 #define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
30 #define ETH_DATA_LEN 1500 /* Max. octets in payload */
33 /*---------------------------------------------------------------------*/
34 /* specify number of BDs and buffers to use */
35 /*---------------------------------------------------------------------*/
38 #define ENET_MAX_MTU_SIZE 1520 /* Body(1500) + EH_SIZE(14) + FCS(4) */
39 #define DMA_MAX_BURST_LENGTH 16 /* in 32 bit words */
41 #define BRCM_TYPE 0x8874
44 #define EPHY_LOOPBACK 0x4000
45 #define EPHY_AUTONEGOTIATE 0x1000
46 #define EPHY_100MBIT 0x2000
47 #define EPHY_FULLDUPLEX 0x0100
48 #define EPHY_RESTART_AUTONEGOTIATION 0x0200
50 #define EPHY_AUTONEGOTIATION_COMPLETE 0x0020
56 #define EPHY_ADDR MII_INTERNAL
60 MII_FULLDUPLEX
= 0x0002,
64 #define MAKE4(x) ((x[3] & 0xFF) | ((x[2] & 0xFF) << 8) | ((x[1] & 0xFF) << 16) | ((x[0] & 0xFF) << 24))
65 #define MAKE2(x) ((x[1] & 0xFF) | ((x[0] & 0xFF) << 8))
68 #define ERROR(x) xsprintf x
70 #define ASSERT(x) if (x); else ERROR(("assert: "__FILE__" line %d\n", __LINE__));
75 #if defined(DUMP_TRACE)
76 #define TRACE (x) xprintf x
81 typedef struct PM_Addr
{
82 uint16 valid
; /* 1 indicates the corresponding address is valid */
83 unsigned char dAddr
[ETH_ALEN
];/* perfect match register's destination address */
84 unsigned int ref
; /* reference count */
86 #define MAX_PMADDR 4 /* # of perfect match address */
88 typedef struct bcm6345_softc
{
90 volatile DmaChannel
*dmaChannels
;
92 /* transmit variables */
93 volatile DmaChannel
*txDma
; /* location of transmit DMA register set */
94 volatile DmaDesc
*txBds
; /* Memory location of tx Dma BD ring */
95 volatile DmaDesc
*txFirstBdPtr
; /* ptr to first allocated Tx BD */
96 volatile DmaDesc
*txNextBdPtr
; /* ptr to next Tx BD to transmit with */
97 volatile DmaDesc
*txLastBdPtr
; /* ptr to last allocated Tx BD */
99 /* receive variables */
100 volatile DmaChannel
*rxDma
; /* location of receive DMA register set */
101 volatile DmaDesc
*rxBds
; /* Memory location of rx bd ring */
102 volatile DmaDesc
*rxFirstBdPtr
; /* ptr to first allocated rx bd */
103 volatile DmaDesc
*rxBdReadPtr
; /* ptr to next rx bd to be processed */
104 volatile DmaDesc
*rxLastBdPtr
; /* ptr to last allocated rx bd */
109 uint16 chipId
; /* chip's id */
110 uint16 chipRev
; /* step */
111 int phyAddr
; /* 1 - external MII, 0 - internal MII (default after reset) */
112 // PM_Addr pmAddr[MAX_PMADDR]; /* perfect match address */
113 uint8_t hwaddr
[ETH_ALEN
];
119 #define IncRxBdPtr(x, s) if (x == ((bcm6345_softc *)s)->rxLastBdPtr) \
120 x = ((bcm6345_softc *)s)->rxBds; \
122 #define InctxBdPtr(x, s) if (x == ((bcm6345_softc *)s)->txLastBdPtr) \
123 x = ((bcm6345_softc *)s)->txBds; \
126 // extern and function prototype
128 extern int32_t _getticks(void);
129 static void delay_t(int ticks
);
130 static int internal_open(bcm6345_softc
* softc
);
133 static void hexdump( unsigned char * src
, int srclen
, int rowlen
, int rows
);
136 #endif // __BCM6345_ETH_H