blob: 22fc392ddca9214cad377c5e5c7c383d9db7f336 [file] [log] [blame]
Aubrey Li10ebdd92007-03-19 01:24:52 +08001#define PHYADDR 0x01
2#define NO_PHY_REGS 0x20
3
4#define DEFAULT_PHY_PHYID1 0x0007
5#define DEFAULT_PHY_PHYID2 0xC0A3
6#define PHY_MODECTL 0x00
7#define PHY_MODESTAT 0x01
8#define PHY_PHYID1 0x02
9#define PHY_PHYID2 0x03
10#define PHY_ANAR 0x04
11#define PHY_ANLPAR 0x05
12#define PHY_ANER 0x06
13
14#define PHY_RESET 0x8000
15#define PHY_ANEG_EN 0x1000
16#define PHY_DUPLEX 0x0100
17#define PHY_SPD_SET 0x2000
18
19#define RECV_BUFSIZE (0x614)
20
21typedef volatile u32 reg32;
22typedef volatile u16 reg16;
23
24typedef struct ADI_DMA_CONFIG_REG {
25 u16 b_DMA_EN:1; /* 0 Enabled */
26 u16 b_WNR:1; /* 1 Direction */
27 u16 b_WDSIZE:2; /* 2:3 Transfer word size */
28 u16 b_DMA2D:1; /* 4 DMA mode */
29 u16 b_RESTART:1; /* 5 Retain FIFO */
30 u16 b_DI_SEL:1; /* 6 Data interrupt timing select */
31 u16 b_DI_EN:1; /* 7 Data interrupt enabled */
32 u16 b_NDSIZE:4; /* 8:11 Flex descriptor size */
33 u16 b_FLOW:3; /* 12:14Flow */
34} ADI_DMA_CONFIG_REG;
35
36typedef struct adi_ether_frame_buffer {
37 u16 NoBytes; /* the no. of following bytes */
38 u8 Dest[6]; /* destination MAC address */
39 u8 Srce[6]; /* source MAC address */
40 u16 LTfield; /* length/type field */
41 u8 Data[0]; /* payload bytes */
42} ADI_ETHER_FRAME_BUFFER;
43/* 16 bytes/struct */
44
45typedef struct dma_descriptor {
46 struct dma_descriptor *NEXT_DESC_PTR;
47 u32 START_ADDR;
48 ADI_DMA_CONFIG_REG CONFIG;
49} DMA_DESCRIPTOR;
50/* 10 bytes/struct in 12 bytes */
51
52typedef struct adi_ether_buffer {
53 DMA_DESCRIPTOR Dma[2]; /* first for the frame, second for the status */
54 ADI_ETHER_FRAME_BUFFER *FrmData;/* pointer to data */
55 struct adi_ether_buffer *pNext; /* next buffer */
56 struct adi_ether_buffer *pPrev; /* prev buffer */
57 u16 IPHdrChksum; /* the IP header checksum */
58 u16 IPPayloadChksum; /* the IP header and payload checksum */
59 volatile u32 StatusWord; /* the frame status word */
60} ADI_ETHER_BUFFER;
61/* 40 bytes/struct in 44 bytes */
62
63void SetupMacAddr(u8 * MACaddr);
64
65void PollMdcDone(void);
66void WrPHYReg(u16 PHYAddr, u16 RegAddr, u16 Data);
67u16 RdPHYReg(u16 PHYAddr, u16 RegAddr);
68void SoftResetPHY(void);
69void DumpPHYRegs(void);
70
71int SetupSystemRegs(int *opmode);