1 /* 2 * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /*******************************************************************************************************************//** 8 * @addtogroup ETHER_PHY 9 * @{ 10 **********************************************************************************************************************/ 11 12 #ifndef R_ETHER_PHY_H 13 #define R_ETHER_PHY_H 14 15 #include "bsp_api.h" 16 17 /* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ 18 FSP_HEADER 19 20 /*********************************************************************************************************************** 21 * Includes 22 **********************************************************************************************************************/ 23 #include "r_ether_phy_cfg.h" 24 #include "r_ether_phy_api.h" 25 26 /*********************************************************************************************************************** 27 * Macro definitions 28 **********************************************************************************************************************/ 29 30 /*********************************************************************************************************************** 31 * Typedef definitions 32 **********************************************************************************************************************/ 33 34 /** Initialization state for read/write */ 35 typedef enum e_ether_phy_interface_status 36 { 37 ETHER_PHY_INTERFACE_STATUS_UNINITIALIZED = 0, ///< ETHER PHY interface is uninitialized 38 ETHER_PHY_INTERFACE_STATUS_INITIALIZED = 1 ///< ETHER PHY interface is initialized 39 } ether_phy_interface_status_t; 40 41 /** ETHER PHY control block. DO NOT INITIALIZE. Initialization occurs when @ref ether_phy_api_t::open is called. */ 42 typedef struct st_ether_phy_instance_ctrl 43 { 44 uint32_t open; ///< Used to determine if the channel is configured 45 uint8_t phy_lsi_address; ///< Address of PHY-LSI 46 47 /* Configuration of Ethernet PHY-LSI module. */ 48 ether_phy_cfg_t const * p_ether_phy_cfg; ///< Pointer to initial configurations. 49 50 /* Interface for PHY-LSI chip. */ 51 volatile uint32_t * p_reg_pir; ///< Pointer to ETHERC peripheral registers. 52 53 /* The capabilities of the local link as PHY data */ 54 uint32_t local_advertise; ///< Capabilities bitmap for local advertising. 55 ether_phy_interface_status_t interface_status; ///< Initialized status of ETHER PHY interface. 56 } ether_phy_instance_ctrl_t; 57 58 /** ETHER PHY extended configuration. */ 59 typedef struct st_ether_phy_extended_cfg 60 { 61 void (* p_target_init)(ether_phy_instance_ctrl_t * p_instance_ctrl); ///< Pointer to callback that is called to initialize the target. 62 bool (* p_target_link_partner_ability_get)(ether_phy_instance_ctrl_t * p_instance_ctrl, uint32_t line_speed_duplex); ///< Pointer to callback that is called to get the link partner ability. 63 } ether_phy_extended_cfg_t; 64 65 /********************************************************************************************************************** 66 * Exported global variables 67 **********************************************************************************************************************/ 68 69 /** @cond INC_HEADER_DEFS_SEC */ 70 /** Filled in Interface API structure for this Instance. */ 71 extern const ether_phy_api_t g_ether_phy_on_ether_phy; 72 73 /** @endcond */ 74 75 /*********************************************************************************************************************** 76 * Exported global functions (to be accessed by other files) 77 ***********************************************************************************************************************/ 78 79 /********************************************************************************************************************** 80 * Public Function Prototypes 81 **********************************************************************************************************************/ 82 fsp_err_t R_ETHER_PHY_Open(ether_phy_ctrl_t * const p_ctrl, ether_phy_cfg_t const * const p_cfg); 83 84 fsp_err_t R_ETHER_PHY_Close(ether_phy_ctrl_t * const p_ctrl); 85 86 fsp_err_t R_ETHER_PHY_ChipInit(ether_phy_ctrl_t * const p_ctrl, ether_phy_cfg_t const * const p_cfg); 87 88 fsp_err_t R_ETHER_PHY_Read(ether_phy_ctrl_t * const p_ctrl, uint32_t reg_addr, uint32_t * const p_data); 89 90 fsp_err_t R_ETHER_PHY_Write(ether_phy_ctrl_t * const p_ctrl, uint32_t reg_addr, uint32_t data); 91 92 fsp_err_t R_ETHER_PHY_StartAutoNegotiate(ether_phy_ctrl_t * const p_ctrl); 93 94 fsp_err_t R_ETHER_PHY_LinkPartnerAbilityGet(ether_phy_ctrl_t * const p_ctrl, 95 uint32_t * const p_line_speed_duplex, 96 uint32_t * const p_local_pause, 97 uint32_t * const p_partner_pause); 98 99 fsp_err_t R_ETHER_PHY_LinkStatusGet(ether_phy_ctrl_t * const p_ctrl); 100 101 /*******************************************************************************************************************//** 102 * @} (end addtogroup ETHER_PHY) 103 **********************************************************************************************************************/ 104 105 /* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */ 106 FSP_FOOTER 107 108 #endif // R_ETHER_PHY_H 109