1 /* 2 * Copyright 2021-2022 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 /***************************************************************************** 9 * PHY LAN8720A driver change log 10 *****************************************************************************/ 11 12 /*! 13 @page driver_log Driver Change Log 14 15 @section phylan8720 PHYLAN8720A 16 The current PHYLAN8720A driver version is 2.0.0. 17 18 - 2.0.0 19 - Initial version. 20 */ 21 22 #ifndef _FSL_PHYLAN8720A_H_ 23 #define _FSL_PHYLAN8720A_H_ 24 25 #include "fsl_phy.h" 26 27 /*! 28 * @addtogroup phy_driver 29 * @{ 30 */ 31 32 /******************************************************************************* 33 * Definitions 34 ******************************************************************************/ 35 36 /*! @brief PHY driver version */ 37 #define FSL_PHY_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) 38 39 typedef struct _phy_lan8720a_resource 40 { 41 mdioWrite write; 42 mdioRead read; 43 } phy_lan8720a_resource_t; 44 45 extern const phy_operations_t phylan8720a_ops; 46 47 /******************************************************************************* 48 * API 49 ******************************************************************************/ 50 51 #if defined(__cplusplus) 52 extern "C" { 53 #endif 54 55 /*! 56 * @name PHY Driver 57 * @{ 58 */ 59 60 /*! 61 * @brief Initializes PHY. 62 * This function initializes PHY. 63 * 64 * @param handle PHY device handle. 65 * @param config Pointer to structure of phy_config_t. 66 * @retval kStatus_Success PHY initialization succeeds 67 * @retval kStatus_Fail PHY initialization fails 68 * @retval kStatus_Timeout PHY MDIO visit time out 69 */ 70 status_t PHY_LAN8720A_Init(phy_handle_t *handle, const phy_config_t *config); 71 72 /*! 73 * @brief PHY Write function. 74 * This function writes data over the MDIO to the specified PHY register. 75 * 76 * @param handle PHY device handle. 77 * @param phyReg The PHY register. 78 * @param data The data written to the PHY register. 79 * @retval kStatus_Success PHY write success 80 * @retval kStatus_Timeout PHY MDIO visit time out 81 */ 82 status_t PHY_LAN8720A_Write(phy_handle_t *handle, uint8_t phyReg, uint16_t data); 83 84 /*! 85 * @brief PHY Read function. 86 * This interface reads data over the MDIO from the specified PHY register. 87 * 88 * @param handle PHY device handle. 89 * @param phyReg The PHY register. 90 * @param pData The address to store the data read from the PHY register. 91 * @retval kStatus_Success PHY read success 92 * @retval kStatus_Timeout PHY MDIO visit time out 93 */ 94 status_t PHY_LAN8720A_Read(phy_handle_t *handle, uint8_t phyReg, uint16_t *pData); 95 96 /*! 97 * @brief Gets the PHY auto-negotiation status. 98 * 99 * @param handle PHY device handle. 100 * @param status The auto-negotiation status of the PHY. 101 * - true the auto-negotiation is over. 102 * - false the auto-negotiation is on-going or not started. 103 * @retval kStatus_Success PHY gets status success 104 * @retval kStatus_Timeout PHY MDIO visit time out 105 */ 106 status_t PHY_LAN8720A_GetAutoNegotiationStatus(phy_handle_t *handle, bool *status); 107 108 /*! 109 * @brief Gets the PHY link status. 110 * 111 * @param handle PHY device handle. 112 * @param status The link up or down status of the PHY. 113 * - true the link is up. 114 * - false the link is down. 115 * @retval kStatus_Success PHY gets link status success 116 * @retval kStatus_Timeout PHY MDIO visit time out 117 */ 118 status_t PHY_LAN8720A_GetLinkStatus(phy_handle_t *handle, bool *status); 119 120 /*! 121 * @brief Gets the PHY link speed and duplex. 122 * 123 * @brief This function gets the speed and duplex mode of PHY. User can give one of speed 124 * and duplex address paramter and set the other as NULL if only wants to get one of them. 125 * 126 * @param handle PHY device handle. 127 * @param speed The address of PHY link speed. 128 * @param duplex The link duplex of PHY. 129 * @retval kStatus_Success PHY gets link speed and duplex success 130 * @retval kStatus_Timeout PHY MDIO visit time out 131 */ 132 status_t PHY_LAN8720A_GetLinkSpeedDuplex(phy_handle_t *handle, phy_speed_t *speed, phy_duplex_t *duplex); 133 134 /*! 135 * @brief Sets the PHY link speed and duplex. 136 * 137 * @param handle PHY device handle. 138 * @param speed Specified PHY link speed. 139 * @param duplex Specified PHY link duplex. 140 * @retval kStatus_Success PHY gets status success 141 * @retval kStatus_Timeout PHY MDIO visit time out 142 */ 143 status_t PHY_LAN8720A_SetLinkSpeedDuplex(phy_handle_t *handle, phy_speed_t speed, phy_duplex_t duplex); 144 145 /*! 146 * @brief Enable PHY loopcback mode. 147 * 148 * @param handle PHY device handle. 149 * @param mode The loopback mode to be enabled, please see "phy_loop_t". 150 * All loopback modes should not be set together, when one loopback mode is set 151 * another should be disabled. 152 * @param speed PHY speed for loopback mode. 153 * @param enable True to enable, false to disable. 154 * @retval kStatus_Success PHY get link speed and duplex success 155 * @retval kStatus_Timeout PHY MDIO visit time out 156 */ 157 status_t PHY_LAN8720A_EnableLoopback(phy_handle_t *handle, phy_loop_t mode, phy_speed_t speed, bool enable); 158 159 /* @} */ 160 161 #if defined(__cplusplus) 162 } 163 #endif 164 165 /*! @}*/ 166 167 #endif /* _FSL_PHYLAN8720A_H_ */ 168