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