1 |
578 |
jeremybenn |
/*
|
2 |
|
|
* File: mii.h
|
3 |
|
|
* Purpose:
|
4 |
|
|
*
|
5 |
|
|
* Notes:
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
#ifndef _MII_H_
|
9 |
|
|
#define _MII_H_
|
10 |
|
|
|
11 |
|
|
/********************************************************************/
|
12 |
|
|
|
13 |
|
|
/* Timeout for MII communications */
|
14 |
|
|
#define FEC_MII_TIMEOUT 0x10000
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
/********************************************************************/
|
18 |
|
|
//Fucntion Protoypes
|
19 |
|
|
|
20 |
|
|
int FEC_Mii_Write(int, int, int);
|
21 |
|
|
int FEC_Mii_Read(int, int, unsigned short*);
|
22 |
|
|
void FEC_Mii_Init(void);
|
23 |
|
|
void fec_mii_reg_printf(void);
|
24 |
|
|
|
25 |
|
|
/********************************************************************/
|
26 |
|
|
//Register Mask and Other
|
27 |
|
|
//===============
|
28 |
|
|
/* Definition of allowed values for MDCSEL */
|
29 |
|
|
#define MII_MDCSEL(x) x/5000000
|
30 |
|
|
|
31 |
|
|
#define MII_WRITE 0x01
|
32 |
|
|
#define MII_READ 0x02
|
33 |
|
|
|
34 |
|
|
#define TCMD_START 0x01 /* Transmit buffer frame */
|
35 |
|
|
#define TCMD_PAUSE 0x02 /* Transmit PAUSE frame */
|
36 |
|
|
#define TCMD_ABORT 0x03 /* Abort transmission */
|
37 |
|
|
|
38 |
|
|
/* PHY registers symbolic names */
|
39 |
|
|
/* (located in MII memory map, accessible through MDIO) */
|
40 |
|
|
#define PHY_REG_CR 0x00 /* Control Register */
|
41 |
|
|
#define PHY_REG_SR 0x01 /* Status Register */
|
42 |
|
|
#define PHY_REG_ID1 0x02 /* PHY Identification Register 1 */
|
43 |
|
|
#define PHY_REG_ID2 0x03 /* PHY Identification Register 2 */
|
44 |
|
|
#define PHY_REG_ANAR 0x04 /* Auto-Negotiation Advertisement Register */
|
45 |
|
|
#define PHY_REG_ANLPAR 0x05 /* Auto-Negotiation Link Partner Ability Register */
|
46 |
|
|
#define PHY_REG_ER 0x06 /* Auto-Negotiation Expansion Register */
|
47 |
|
|
#define PHY_REG_NPTR 0x07 /* Auto-Negotiation Next Page Transfer Register */
|
48 |
|
|
#define PHY_REG_IR 0x10 /* Interrupt Register */
|
49 |
|
|
#define PHY_REG_PSR 0x11 /* Proprietary Status Register */
|
50 |
|
|
#define PHY_REG_PCR 0x12 /* Proprietary Control Register */
|
51 |
|
|
#define PHY_REG_10BTBC 0x13 /* 10Base-T Bypass Control Register */
|
52 |
|
|
#define PHY_REG_100BXBC 0x14 /* 100Base-X Bypass Control Register */
|
53 |
|
|
#define PHY_REG_ADDR 0x15 /* Test & Trim Control Register */
|
54 |
|
|
#define PHY_REG_DSPRC 0x17 /* DSP Reset Control */
|
55 |
|
|
#define PHY_REG_DSPRR1 0x18 /* 100Base-X DSP Read Registers */
|
56 |
|
|
#define PHY_REG_DSPRR2 0x19
|
57 |
|
|
#define PHY_REG_DSPRR3 0x1A
|
58 |
|
|
#define PHY_REG_DSPWR1 0x1B /* 100Base-X DSP Write Registers */
|
59 |
|
|
#define PHY_REG_DSPWR2 0x1C
|
60 |
|
|
#define PHY_REG_DSPWR3 0x1D
|
61 |
|
|
|
62 |
|
|
/* PHY registers structure */
|
63 |
|
|
/* 0 - Control Register */
|
64 |
|
|
#define PHY_R0_RESET 0x8000 /* Reset */
|
65 |
|
|
#define PHY_R0_LB 0x4000 /* Loop Back */
|
66 |
|
|
#define PHY_R0_DR 0x2000 /* Data Rate (100Mb/s) */
|
67 |
|
|
#define PHY_R0_ANE 0x1000 /* Auto-Negotiation Enable */
|
68 |
|
|
#define PHY_R0_PD 0x0800 /* Power Down */
|
69 |
|
|
#define PHY_R0_ISOLATE 0x0400 /* Isolate (MII is disconnected) */
|
70 |
|
|
#define PHY_R0_RAN 0x0200 /* Restart Auto-Negotiation */
|
71 |
|
|
#define PHY_R0_DPLX 0x0100 /* Duplex (Full duplex) */
|
72 |
|
|
#define PHY_R0_CT 0x0080 /* Collision Test (Enable) */
|
73 |
|
|
|
74 |
|
|
/* 1 - Status Register */
|
75 |
|
|
#define PHY_R1_100T4 0x8000 /* 100BASET4 Supported */
|
76 |
|
|
#define PHY_R1_100F 0x4000 /* 100Mb/s Full Duplex Supported */
|
77 |
|
|
#define PHY_R1_100H 0x2000 /* 100Mb/s Half Duplex Supported */
|
78 |
|
|
#define PHY_R1_10F 0x1000 /* 10Mb/s Full Duplex Supported */
|
79 |
|
|
#define PHY_R1_10H 0x0800 /* 10Mb/s Half Duplex Supported */
|
80 |
|
|
#define PHY_R1_SUP 0x0040 /* MI Preamble Supression (capable of) */
|
81 |
|
|
#define PHY_R1_ANC 0x0020 /* Auto Negotiation Complete */
|
82 |
|
|
#define PHY_R1_RF 0x0010 /* Remote Fault */
|
83 |
|
|
#define PHY_R1_ANA 0x0008 /* Auto-Negotiation Ability (present) */
|
84 |
|
|
#define PHY_R1_LS 0x0004 /* Link Status (Link is Up) */
|
85 |
|
|
#define PHY_R1_JD 0x0002 /* Jabber Detect (detected) */
|
86 |
|
|
#define PHY_R1_EC 0x0001 /* Extended Capability (regs 2 to 31 exists) */
|
87 |
|
|
|
88 |
|
|
/* 2 - PHY Identifier Register 1 */
|
89 |
|
|
/* 3 - PHY Identifier Register 2 */
|
90 |
|
|
/* read only - contains Manufacturer's info etc.
|
91 |
|
|
see documentation for the detailed description */
|
92 |
|
|
|
93 |
|
|
/* 4 - Auto Negotiation Advertisement Register */
|
94 |
|
|
#define PHY_R4_NP 0x8000 /* Next Page (capable of sending next pages) */
|
95 |
|
|
#define PHY_R4_RF 0x2000 /* Remote Fault */
|
96 |
|
|
#define PHY_R4_FC 0x0400 /* Flow Control */
|
97 |
|
|
#define PHY_R4_100F 0x0100 /* 100Base-TX Full Duplex Capable */
|
98 |
|
|
#define PHY_R4_100H 0x0080 /* 100Base-TX Half Duplex Capable */
|
99 |
|
|
#define PHY_R4_10F 0x0040 /* 10Base-T Full Duplex Capable */
|
100 |
|
|
#define PHY_R4_10H 0x0020 /* 10Base-T Half Duplex Capable */
|
101 |
|
|
/* bits 4 to 0 are Selector Field (IEEE Std 802.3 = 00001) */
|
102 |
|
|
|
103 |
|
|
/* 5 - Auto Negotiation Link Partner Ability Register (Base Page & Next Page) */
|
104 |
|
|
/* read only - please consult PHY documentation */
|
105 |
|
|
#define PHY_R5_FCTL 0x0400 /* 10Base-T Half Duplex Capable */
|
106 |
|
|
|
107 |
|
|
/* 16 - Interrupt Control Register */
|
108 |
|
|
#define PHY_R16_ACKIE 0x4000 //Acknowledge Bit Received Interrupt Enable
|
109 |
|
|
#define PHY_R16_PRIE 0x2000 //Page Received INT Enable
|
110 |
|
|
#define PHY_R16_LCIE 0x1000 //Link Changed Enable
|
111 |
|
|
#define PHY_R16_ANIE 0x0800 //Auto-Negotiation Changed Enable
|
112 |
|
|
#define PHY_R16_PDFIE 0x0400 //Parallel Detect Fault Enable
|
113 |
|
|
#define PHY_R16_RFIE 0x0200 //Remote Fault Interrupt Enable
|
114 |
|
|
#define PHY_R16_JABIE 0x0100 //Jabber Interrupt Enable
|
115 |
|
|
|
116 |
|
|
#define PHY_R16_ACKR 0x0040 //Acknowledge Bit Received Interrupt
|
117 |
|
|
#define PHY_R16_PGR 0x0020 //Page Received
|
118 |
|
|
#define PHY_R16_LKC 0x0010 //Link Changed
|
119 |
|
|
#define PHY_R16_ANC 0x0008 //Auto-Negotiation Changed
|
120 |
|
|
#define PHY_R16_PDF 0x0004 //Parallel Detect Fault
|
121 |
|
|
#define PHY_R16_RMTF 0x0002 //Remote Fault Interrupt
|
122 |
|
|
#define PHY_R16_JABI 0x0001 //Jabber Interrupt
|
123 |
|
|
|
124 |
|
|
////Proprietary Status Register
|
125 |
|
|
#define PHY_R17_LNK 0x4000 //
|
126 |
|
|
#define PHY_R17_DPM 0x2000 //Duplex Mode
|
127 |
|
|
#define PHY_R17_SPD 0x1000 //Speed
|
128 |
|
|
#define PHY_R17_ANNC 0x0400 //Auto-Negotiation Complete
|
129 |
|
|
#define PHY_R17_PRCVD 0x0200 //
|
130 |
|
|
#define PHY_R17_ANCM 0x0100 // Auto-Negotiation (A-N) Common Operating Mode
|
131 |
|
|
#define PHY_R17_PLR 0x0020 //
|
132 |
|
|
|
133 |
|
|
/* Bit definitions and macros for MCF_FEC_MMFR */
|
134 |
|
|
#define FEC_MMFR_DATA(x) (((x)&0x0000FFFF)<<0)
|
135 |
|
|
#define FEC_MMFR_TA(x) (((x)&0x00000003)<<16)
|
136 |
|
|
#define FEC_MMFR_RA(x) (((x)&0x0000001F)<<18)
|
137 |
|
|
#define FEC_MMFR_PA(x) (((x)&0x0000001F)<<23)
|
138 |
|
|
#define FEC_MMFR_OP(x) (((x)&0x00000003)<<28)
|
139 |
|
|
#define FEC_MMFR_ST(x) (((x)&0x00000003)<<30)
|
140 |
|
|
#define FEC_MMFR_ST_01 (0x40000000)
|
141 |
|
|
#define FEC_MMFR_OP_READ (0x20000000)
|
142 |
|
|
#define FEC_MMFR_OP_WRITE (0x10000000)
|
143 |
|
|
#define FEC_MMFR_TA_10 (0x00020000)
|
144 |
|
|
|
145 |
|
|
/********************************************************************/
|
146 |
|
|
|
147 |
|
|
#endif /* _MII_H_ */
|