2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * o Redistributions of source code must retain the above copyright notice, this list
9 * of conditions and the following disclaimer.
11 * o Redistributions in binary form must reproduce the above copyright notice, this
12 * list of conditions and the following disclaimer in the documentation and/or
13 * other materials provided with the distribution.
15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef __FSL_PHY_DRIVER_H__
31 #define __FSL_PHY_DRIVER_H__
35 #include "fsl_enet_driver.h"
40 * @addtogroup phy_driver
46 /*******************************************************************************
48 ******************************************************************************/
49 /*! @brief Defines the PHY return status. */
50 typedef enum _phy_status
52 kStatus_PHY_Success
= 0, /*!< Success*/
53 kStatus_PHY_InvaildInput
= 1, /*!< Invalid PHY input parameter*/
54 kStatus_PHY_TimeOut
= 2, /*!< PHY timeout*/
55 kStatus_PHY_Fail
= 3 /*!< PHY fail*/
58 /*! @brief Defines the ENET timeout.*/
59 typedef enum _phy_timeout
61 kPhyTimeout
= 0x10000, /*!< ENET resets timeout.*/
64 /*! @brief Defines the PHY register.*/
65 typedef enum _enet_phy_register
67 kEnetPhyCR
= 0, /*!< PHY control register */
68 kEnetPhySR
= 1, /*!< PHY status register*/
69 kEnetPhyId1
= 2, /*!< PHY identification register 1*/
70 kEnetPhyId2
= 3, /*!< PHY identification register 2*/
71 kEnetPhyCt2
= 0x1e /*!< PHY control2 register*/
72 } enet_phy_register_t
;
74 /*! @brief Defines the control flag.*/
75 typedef enum _enet_phy_control
77 kEnetPhyAutoNeg
= 0x1000,/*!< ENET PHY auto negotiation control*/
78 kEnetPhySpeed
= 0x2000, /*! ENET PHY speed control*/
79 kEnetPhyLoop
= 0x4000, /*!< ENET PHY loop control*/
80 kEnetPhyReset
= 0x8000, /*!< ENET PHY reset control*/
81 kEnetPhy10HalfDuplex
= 0x01, /*!< ENET PHY 10 M half duplex*/
82 kEnetPhy100HalfDuplex
= 0x02,/*!< ENET PHY 100 M half duplex*/
83 kEnetPhy10FullDuplex
= 0x05,/*!< ENET PHY 10 M full duplex*/
84 kEnetPhy100FullDuplex
= 0x06/*!< ENET PHY 100 M full duplex*/
87 /*! @brief Defines the PHY link speed. */
88 typedef enum _enet_phy_speed
90 kEnetSpeed10M
= 0, /*!< ENET PHY 10 M speed*/
91 kEnetSpeed100M
= 1 /*!< ENET PHY 100 M speed*/
94 /*! @brief Defines the PHY link duplex.*/
95 typedef enum _enet_phy_duplex
97 kEnetHalfDuplex
= 0, /*!< ENET PHY half duplex*/
98 kEnetFullDuplex
= 1 /*!< ENET PHY full duplex*/
101 /*! @brief Defines the PHY status.*/
102 typedef enum _enet_phy_status
104 kEnetPhyLinkStatus
= 0x4, /*!< ENET PHY link status bit*/
105 kEnetPhyAutoNegAble
= 0x08, /*!< ENET PHY auto negotiation ability*/
106 kEnetPhyAutoNegComplete
= 0x20, /*!< ENET PHY auto negotiation complete*/
107 kEnetPhySpeedDulpexMask
= 0x07 /*!< ENET PHY speed mask on status register 2*/
110 /*! @brief Defines the basic PHY application.*/
111 typedef struct ENETPhyApi
113 uint32_t (* phy_auto_discover
)(enet_dev_if_t
* enetIfPtr
);/*!< PHY auto discover*/
114 uint32_t (* phy_init
)(enet_dev_if_t
* enetIfPtr
);/*!< PHY initialize*/
115 uint32_t (* phy_get_link_speed
)(enet_dev_if_t
* enetIfPtr
, enet_phy_speed_t
*speed
);/*!< Get PHY speed*/
116 uint32_t (* phy_get_link_status
)(enet_dev_if_t
* enetIfPtr
, bool *status
);/*! Get PHY link status*/
117 uint32_t (* phy_get_link_duplex
)(enet_dev_if_t
* enetIfPtr
, enet_phy_duplex_t
*duplex
);/*!< Get PHY link duplex*/
120 /*******************************************************************************
122 ******************************************************************************/
123 extern const enet_phy_api_t g_enetPhyApi
;
125 /*******************************************************************************
127 ******************************************************************************/
129 #if defined(__cplusplus)
139 * @brief Initializes PHY.
141 * @param enetIfPtr The ENET context structure.
142 * @return The execution status.
144 uint32_t phy_init(enet_dev_if_t
* enetIfPtr
);
147 * @brief PHY address auto discover.
149 * @param enetIfPtr The ENET context structure.
150 * @return The execution status.
152 uint32_t phy_auto_discover(enet_dev_if_t
* enetIfPtr
);
155 * @brief Gets the PHY link speed.
157 * @param enetIfPtr The ENET context structure.
158 * @param status The link speed of PHY.
159 * @return The execution status.
161 uint32_t phy_get_link_speed(enet_dev_if_t
* enetIfPtr
, enet_phy_speed_t
*status
);
164 * @brief Gets the PHY link status.
166 * @param enetIfPtr The ENET context structure.
167 * @param status The link on or down status of the PHY.
168 * @return The execution status.
170 uint32_t phy_get_link_status(enet_dev_if_t
* enetIfPtr
, bool *status
);
173 * @brief Gets the PHY link duplex.
175 * @param enetIfPtr The ENET context structure.
176 * @param status The link duplex status of PHY.
177 * @return The execution status.
179 uint32_t phy_get_link_duplex(enet_dev_if_t
* enetIfPtr
, enet_phy_duplex_t
*status
);
183 #if defined(__cplusplus)
191 #endif /* __FSL_PHY_DRIVER_H__ */
192 /*******************************************************************************
194 ******************************************************************************/