]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/common/phyksz8081/fsl_phy_driver.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / hal / TARGET_Freescale / TARGET_KPSDK_MCUS / TARGET_KPSDK_CODE / common / phyksz8081 / fsl_phy_driver.h
1 /*
2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * o Redistributions of source code must retain the above copyright notice, this list
9 * of conditions and the following disclaimer.
10 *
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.
14 *
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.
18 *
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.
29 */
30 #ifndef __FSL_PHY_DRIVER_H__
31 #define __FSL_PHY_DRIVER_H__
32
33 #include <stdint.h>
34 #include <stdbool.h>
35 #include "fsl_enet_driver.h"
36
37 #ifndef MBED_NO_ENET
38
39 /*!
40 * @addtogroup phy_driver
41 * @{
42 */
43
44 /*! @file*/
45
46 /*******************************************************************************
47 * Definitions
48 ******************************************************************************/
49 /*! @brief Defines the PHY return status. */
50 typedef enum _phy_status
51 {
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*/
56 } phy_status_t;
57
58 /*! @brief Defines the ENET timeout.*/
59 typedef enum _phy_timeout
60 {
61 kPhyTimeout = 0x10000, /*!< ENET resets timeout.*/
62 } phy_timeout_t;
63
64 /*! @brief Defines the PHY register.*/
65 typedef enum _enet_phy_register
66 {
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;
73
74 /*! @brief Defines the control flag.*/
75 typedef enum _enet_phy_control
76 {
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*/
85 } enet_phy_control_t;
86
87 /*! @brief Defines the PHY link speed. */
88 typedef enum _enet_phy_speed
89 {
90 kEnetSpeed10M = 0, /*!< ENET PHY 10 M speed*/
91 kEnetSpeed100M = 1 /*!< ENET PHY 100 M speed*/
92 } enet_phy_speed_t;
93
94 /*! @brief Defines the PHY link duplex.*/
95 typedef enum _enet_phy_duplex
96 {
97 kEnetHalfDuplex = 0, /*!< ENET PHY half duplex*/
98 kEnetFullDuplex = 1 /*!< ENET PHY full duplex*/
99 } enet_phy_duplex_t;
100
101 /*! @brief Defines the PHY status.*/
102 typedef enum _enet_phy_status
103 {
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*/
108 } enet_phy_status_t;
109
110 /*! @brief Defines the basic PHY application.*/
111 typedef struct ENETPhyApi
112 {
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*/
118 } enet_phy_api_t;
119
120 /*******************************************************************************
121 * Global variables
122 ******************************************************************************/
123 extern const enet_phy_api_t g_enetPhyApi;
124
125 /*******************************************************************************
126 * API
127 ******************************************************************************/
128
129 #if defined(__cplusplus)
130 extern "C" {
131 #endif
132
133 /*!
134 * @name PHY Driver
135 * @{
136 */
137
138 /*!
139 * @brief Initializes PHY.
140 *
141 * @param enetIfPtr The ENET context structure.
142 * @return The execution status.
143 */
144 uint32_t phy_init(enet_dev_if_t * enetIfPtr);
145
146 /*!
147 * @brief PHY address auto discover.
148 *
149 * @param enetIfPtr The ENET context structure.
150 * @return The execution status.
151 */
152 uint32_t phy_auto_discover(enet_dev_if_t * enetIfPtr);
153
154 /*!
155 * @brief Gets the PHY link speed.
156 *
157 * @param enetIfPtr The ENET context structure.
158 * @param status The link speed of PHY.
159 * @return The execution status.
160 */
161 uint32_t phy_get_link_speed(enet_dev_if_t * enetIfPtr, enet_phy_speed_t *status);
162
163 /*!
164 * @brief Gets the PHY link status.
165 *
166 * @param enetIfPtr The ENET context structure.
167 * @param status The link on or down status of the PHY.
168 * @return The execution status.
169 */
170 uint32_t phy_get_link_status(enet_dev_if_t * enetIfPtr, bool *status);
171
172 /*!
173 * @brief Gets the PHY link duplex.
174 *
175 * @param enetIfPtr The ENET context structure.
176 * @param status The link duplex status of PHY.
177 * @return The execution status.
178 */
179 uint32_t phy_get_link_duplex(enet_dev_if_t * enetIfPtr, enet_phy_duplex_t *status);
180
181 /* @} */
182
183 #if defined(__cplusplus)
184 }
185 #endif
186
187 #endif
188
189 /*! @}*/
190
191 #endif /* __FSL_PHY_DRIVER_H__ */
192 /*******************************************************************************
193 * EOF
194 ******************************************************************************/
195
Imprint / Impressum