?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /*********************************************************************
2 *
3 * External Phy API header file
4 *
5 *********************************************************************
6 * FileName: ETHPIC32ExtPhy.h
7 * Dependencies:
8 * Processor: PIC32
9 *
10 * Complier: MPLAB C32
11 * MPLAB IDE
12 * Company: Microchip Technology, Inc.
13 *
14 * Software License Agreement
15 * Microchip Audio Library – PIC32 Software.
16 * Copyright © 2008 Microchip Technology Inc. All rights reserved.
17 *
18 * Microchip licenses the Software for your use with Microchip microcontrollers
19 * and Microchip digital signal controllers pursuant to the terms of the
20 * Non-Exclusive Software License Agreement accompanying this Software.
21 *
22 * SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY
23 * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION,
24 * ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS
25 * FOR A PARTICULAR PURPOSE.
26 * MICROCHIP AND ITS LICENSORS ASSUME NO RESPONSIBILITY FOR THE ACCURACY,
27 * RELIABILITY OR APPLICATION OF THE SOFTWARE AND DOCUMENTATION.
28 * IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED
29 * UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH
30 * OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT
31 * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL,
32 * SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS
33 * OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY,
34 * SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED
35 * TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
36 *
37 *$Id: $
38 ********************************************************************/
39  
40  
41 #ifndef _ETH_PHY_H_
42 #define _ETH_PHY_H_
43  
44 #include <peripheral/eth.h>
45  
46 // definitions
47  
48 #ifdef _ETH // ETHC present
49  
50  
51 #define PHY_NEG_INIT_TMO 1 // negotiation initiation timeout, ms.
52  
53 #define PHY_NEG_DONE_TMO 2000 // negotiation complete timeout, ms.
54 // based on IEEE 802.3 Clause 28 Table 28-9 autoneg_wait_timer value (max 1s)
55  
56 #define PHY_RESET_CLR_TMO 500 // reset self clear timeout, ms.
57 // IEEE 802.3 Clause 22 Table 22-7 and paragraph "22.2.4.1.1 Reset" (max 0.5s)
58  
59 typedef enum
60 {
61 // PHY flags, connection flags
62 ETH_PHY_CFG_RMII = 0x01, // check that configuration fuses is RMII
63 ETH_PHY_CFG_MII = 0x00, // check that configuration fuses is MII
64 ETH_PHY_CFG_ALTERNATE = 0x02, // check that configuration fuses is ALT
65 ETH_PHY_CFG_DEFAULT = 0x00, // check that configuration fuses is DEFAULT
66 ETH_PHY_CFG_AUTO = 0x10 // use the fuses configuration to detect if you are RMII/MII and ALT/DEFAULT configuration
67 // NOTE: - this option does not check the consistency btw the software call and the way the
68 // fuses are configured. If just assumes that the fuses are properly configured.
69 // - option is valid for EthPhyInit() call only!
70  
71 }eEthPhyCfgFlags; // flags for EthPhyInit() call
72  
73  
74  
75 /*****************************************************************
76 * PHY Interface functions
77 * They are generic and should work for any PHY
78 * They can be overridden if needed.
79 *****************************************************************/
80  
81  
82 /****************************************************************************
83 * Function: EthPhyInit
84 *
85 * PreCondition: - EthInit should have been called.
86 *
87 * Input: oFlags - the requested open flags
88 * cFlags - PHY MII/RMII configuration flags
89 * pResFlags - address to store the initialization result
90 *
91 * Output: ETH_RES_OK for success,
92 * an error code otherwise
93 *
94 *
95 * Side Effects: None
96 *
97 * Overview: This function initializes the PHY communication.
98 * It tries to detect the external PHY, to read the capabilties and find a match
99 * with the requested features.
100 * Then it programs the PHY accordingly.
101 *
102 * Note: None
103 *****************************************************************************/
104 eEthRes __attribute__((weak)) EthPhyInit(eEthOpenFlags oFlags, eEthPhyCfgFlags cFlags, eEthOpenFlags* pResFlags);
105  
106  
107 /****************************************************************************
108 * Function: EthPhyRestartNegotiation
109 *
110 * PreCondition: - EthPhyInit should have been called.
111 * - The PHY should have been initialized with proper duplex/speed mode!
112 *
113 * Input: None
114 *
115 * Output: ETH_RES_OK for success,
116 * an error code otherwise
117 *
118 * Side Effects: None
119 *
120 * Overview: This function restarts the PHY negotiation.
121 * After this restart the link can be reconfigured.
122 * The EthPhyGetNegotiationResults() can be used to see the outcoming result.
123 *
124 * Note: None
125 *****************************************************************************/
126 eEthRes __attribute__((weak)) EthPhyRestartNegotiation(void);
127  
128  
129 /****************************************************************************
130 * Function: EthPhyNegotiationComplete
131 *
132 * PreCondition: EthPhyInit (and EthPhyRestartNegotiation) should have been called.
133 *
134 * Input: waitComplete - if wait for completion needed
135 *
136 * Output: ETH_RES_OK if negotiation done,
137 * an error code otherwise
138 *
139 * Side Effects: None
140 *
141 * Overview: This function waits for a previously initiated PHY negotiation to complete.
142 * Subsequently, EthPhyGetNegotiationResult() can be called.
143 *
144 * Note: None
145 *****************************************************************************/
146 eEthRes __attribute__((weak)) EthPhyNegotiationComplete(int waitComplete);
147  
148  
149 /****************************************************************************
150 * Function: EthPhyGetNegotiationResult
151 *
152 * PreCondition: EthPhyInit, EthPhyRestartNegotiation and EthPhyNegotiationComplete should have been called.
153 *
154 * Input: pFlags - address to store the negotiation result
155 * pPauseType - address to store the pause type supported by the LP
156 *
157 * Output: the link status after the (completed) negotiation
158 *
159 * Side Effects: None
160 *
161 * Overview: This function returns the result of a previously initiated negotiation.
162 * The result is based on the PHY status!.
163 *
164 * Note: If no negotiation possible/active/failed, most likely the flags are invalid!
165 *****************************************************************************/
166 eEthLinkStat __attribute__((weak)) EthPhyGetNegotiationResult(eEthOpenFlags* pFlags, eMacPauseType* pPauseType);
167  
168  
169 /****************************************************************************
170 * Function: EthPhyGetLinkStatus
171 *
172 * PreCondition: EthPhyInit should have been called.
173 *
174 * Input: refresh - boolean to specify if double read is needed.
175 *
176 * Output: the current link status
177 *
178 * Side Effects: None
179 *
180 * Overview: This function reads the PHY to get current link status
181 * If refresh is specified then, if the link is down a second read
182 * will be performed to return the current link status.
183 *
184 * Note: This function performs a full MIIM transaction.
185 * It should not be used when a link scan has been initiated (EthPhyScanLinkStart()).
186 *****************************************************************************/
187 eEthLinkStat __attribute__((weak)) EthPhyGetLinkStatus(int refresh);
188  
189  
190  
191 /****************************************************************************
192 * Function: EthPhyReset
193 *
194 * PreCondition: EthPhyInit() should have been called
195 * Communication with the PHY already established
196 *
197 * Input: waitComplete - if TRUE the procedure will wait for reset to complete
198 *
199 * Output: TRUE if the reset procedure completed (or completion not required)
200 * FALSE otherwise
201 *
202 * Side Effects: None
203 *
204 * Overview: This function immediately resets the PHY.
205 * It does not wait for the reset procedure to complete
206 *
207 * Note: None
208 *****************************************************************************/
209 int __attribute__((weak)) EthPhyReset(int waitComplete);
210  
211  
212 /****************************************************************************
213 * Function: EthPhyScanLinkStart
214 *
215 * PreCondition: EthPhyInit() should have been called
216 * Communication with the PHY already established
217 *
218 * Input: None
219 *
220 * Output: None
221 *
222 * Side Effects: None
223 *
224 * Overview: This function starts a scan of the PHY link status register.
225 * It is meant as a more efficient way of having access to the current link status
226 * since the normal MIIM frame read operation is pretty lengthy.
227 *
228 * Note: Any PHY register can be subject of a scan.
229 * The application should use the MIIM access functions of the Ethernet plib abd the specific PHY knowledge.
230 *****************************************************************************/
231 void __attribute__((weak)) EthPhyScanLinkStart(void);
232  
233  
234 /****************************************************************************
235 * Function: EthPhyScanLinkRead
236 *
237 * PreCondition: EthPhyInit() should have been called
238 * Communication with the PHY already established
239 * A PHY scan operation should have been started.
240 *
241 * Input: None
242 *
243 * Output: the current link status as being updated by the current scan in progress
244 *
245 * Side Effects: None
246 *
247 * Overview: This function returns the current result of a scan operation.
248 * The last updated value is returned.
249 * There's no way of knowing when effectively this last update occurred.
250 *
251 * Note: None
252 *****************************************************************************/
253 eEthLinkStat __attribute__((weak)) EthPhyScanLinkRead(void);
254  
255  
256 /****************************************************************************
257 * Function: EthPhyScanLinkStop
258 *
259 * PreCondition: EthPhyInit() should have been called
260 * Communication with the PHY already established
261 * A PHY scan operation should have been started.
262 *
263 * Input: None
264 *
265 * Output: None
266 *
267 * Side Effects: None
268 *
269 * Overview: This function stops a previously started PHY scan.
270 *
271 * Note: The scan operation shouldn't interfere with normal read operations.
272 * Therefore the scan operation should be stopped before initiating another
273 * normal MIIM transaction
274 *****************************************************************************/
275 void __attribute__((weak)) EthPhyScanLinkStop(void);
276  
277  
278  
279 /*****************************************************************
280 * PHY SPecific Interface functions
281 * Have to be provided for each specific PHY
282 *****************************************************************/
283  
284 /****************************************************************************
285 * Function: EthPhyMIIMAddress
286 *
287 * PreCondition: None
288 *
289 * Input: None
290 *
291 * Output: PHY MIIM address
292 *
293 *
294 * Side Effects: None
295 *
296 * Overview: This function returns the address the PHY uses for MIIM transactions
297 *
298 * Note: None
299 *****************************************************************************/
300 extern unsigned int EthPhyMIIMAddress(void);
301  
302  
303 /****************************************************************************
304 * Function: EthPhyMIIMClock
305 *
306 * PreCondition: None
307 *
308 * Input: None
309 *
310 * Output: PHY MIIM clock, Hz
311 *
312 *
313 * Side Effects: None
314 *
315 * Overview: This function returns the maximum clock frequency that the PHY can use for the MIIM transactions
316 *
317 * Note: None
318 *****************************************************************************/
319 extern unsigned int EthPhyMIIMClock(void);
320  
321  
322 /****************************************************************************
323 * Function: EthPhyConfigureMII
324 *
325 * PreCondition: - Communication to the PHY should have been established.
326 *
327 * Input: cFlags - the requested configuration flags: ETH_PHY_CFG_RMII/ETH_PHY_CFG_MII
328 *
329 * Output: ETH_RES_OK - success,
330 * an error code otherwise
331 *
332 *
333 * Side Effects: None
334 *
335 * Overview: This function configures the PHY in one of MII/RMII operation modes.
336 *
337 * Note: None
338 *****************************************************************************/
339 extern eEthRes EthPhyConfigureMII(eEthPhyCfgFlags cFlags);
340  
341  
342  
343 /****************************************************************************
344 * Function: EthPhyConfigureMdix
345 *
346 * PreCondition: - Communication to the PHY should have been established.
347 *
348 * Input: oFlags - the requested open flags: ETH_OPEN_MDIX_AUTO, ETH_OPEN_MDIX_NORM/ETH_OPEN_MDIX_SWAP
349 *
350 * Output: ETH_RES_OK - success,
351 * an error code otherwise
352 *
353 *
354 * Side Effects: None
355 *
356 * Overview: This function configures the MDIX mode for the PHY.
357 *
358 * Note: None
359 *****************************************************************************/
360 extern eEthRes EthPhyConfigureMdix(eEthOpenFlags oFlags);
361  
362  
363  
364 #endif // _ETH
365  
366 #endif // _ETH_PHY_H_
367  
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3