Driver_ETH_PHY.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (c) 2013-2020 ARM Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * $Date: 24. January 2020
  19. * $Revision: V2.2
  20. *
  21. * Project: Ethernet PHY (Physical Transceiver) Driver definitions
  22. */
  23. /* History:
  24. * Version 2.2
  25. * Removed volatile from ARM_ETH_LINK_INFO
  26. * Version 2.1
  27. * ARM_ETH_LINK_INFO made volatile
  28. * Version 2.0
  29. * changed parameter "mode" in function ARM_ETH_PHY_SetMode
  30. * Changed prefix ARM_DRV -> ARM_DRIVER
  31. * Changed return values of some functions to int32_t
  32. * Version 1.10
  33. * Namespace prefix ARM_ added
  34. * Version 1.00
  35. * Initial release
  36. */
  37. #ifndef DRIVER_ETH_PHY_H_
  38. #define DRIVER_ETH_PHY_H_
  39. #ifdef __cplusplus
  40. extern "C"
  41. {
  42. #endif
  43. #include "Driver_ETH.h"
  44. #define ARM_ETH_PHY_API_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(2,2) /* API version */
  45. #define _ARM_Driver_ETH_PHY_(n) Driver_ETH_PHY##n
  46. #define ARM_Driver_ETH_PHY_(n) _ARM_Driver_ETH_PHY_(n)
  47. /****** Ethernet PHY Mode *****/
  48. #define ARM_ETH_PHY_SPEED_Pos 0
  49. #define ARM_ETH_PHY_SPEED_Msk (3UL << ARM_ETH_PHY_SPEED_Pos)
  50. #define ARM_ETH_PHY_SPEED_10M (ARM_ETH_SPEED_10M << ARM_ETH_PHY_SPEED_Pos) ///< 10 Mbps link speed
  51. #define ARM_ETH_PHY_SPEED_100M (ARM_ETH_SPEED_100M << ARM_ETH_PHY_SPEED_Pos) ///< 100 Mbps link speed
  52. #define ARM_ETH_PHY_SPEED_1G (ARM_ETH_SPEED_1G << ARM_ETH_PHY_SPEED_Pos) ///< 1 Gpbs link speed
  53. #define ARM_ETH_PHY_DUPLEX_Pos 2
  54. #define ARM_ETH_PHY_DUPLEX_Msk (1UL << ARM_ETH_PHY_DUPLEX_Pos)
  55. #define ARM_ETH_PHY_DUPLEX_HALF (ARM_ETH_DUPLEX_HALF << ARM_ETH_PHY_DUPLEX_Pos) ///< Half duplex link
  56. #define ARM_ETH_PHY_DUPLEX_FULL (ARM_ETH_DUPLEX_FULL << ARM_ETH_PHY_DUPLEX_Pos) ///< Full duplex link
  57. #define ARM_ETH_PHY_AUTO_NEGOTIATE (1UL << 3) ///< Auto Negotiation mode
  58. #define ARM_ETH_PHY_LOOPBACK (1UL << 4) ///< Loop-back test mode
  59. #define ARM_ETH_PHY_ISOLATE (1UL << 5) ///< Isolate PHY from MII/RMII interface
  60. // Function documentation
  61. /**
  62. \fn ARM_DRIVER_VERSION ARM_ETH_PHY_GetVersion (void)
  63. \brief Get driver version.
  64. \return \ref ARM_DRIVER_VERSION
  65. */
  66. /**
  67. \fn int32_t ARM_ETH_PHY_Initialize (ARM_ETH_PHY_Read_t fn_read,
  68. ARM_ETH_PHY_Write_t fn_write)
  69. \brief Initialize Ethernet PHY Device.
  70. \param[in] fn_read Pointer to \ref ARM_ETH_MAC_PHY_Read
  71. \param[in] fn_write Pointer to \ref ARM_ETH_MAC_PHY_Write
  72. \return \ref execution_status
  73. */
  74. /**
  75. \fn int32_t ARM_ETH_PHY_Uninitialize (void)
  76. \brief De-initialize Ethernet PHY Device.
  77. \return \ref execution_status
  78. */
  79. /**
  80. \fn int32_t ARM_ETH_PHY_PowerControl (ARM_POWER_STATE state)
  81. \brief Control Ethernet PHY Device Power.
  82. \param[in] state Power state
  83. \return \ref execution_status
  84. */
  85. /**
  86. \fn int32_t ARM_ETH_PHY_SetInterface (uint32_t interface)
  87. \brief Set Ethernet Media Interface.
  88. \param[in] interface Media Interface type
  89. \return \ref execution_status
  90. */
  91. /**
  92. \fn int32_t ARM_ETH_PHY_SetMode (uint32_t mode)
  93. \brief Set Ethernet PHY Device Operation mode.
  94. \param[in] mode Operation Mode
  95. \return \ref execution_status
  96. */
  97. /**
  98. \fn ARM_ETH_LINK_STATE ARM_ETH_PHY_GetLinkState (void)
  99. \brief Get Ethernet PHY Device Link state.
  100. \return current link status \ref ARM_ETH_LINK_STATE
  101. */
  102. /**
  103. \fn ARM_ETH_LINK_INFO ARM_ETH_PHY_GetLinkInfo (void)
  104. \brief Get Ethernet PHY Device Link information.
  105. \return current link parameters \ref ARM_ETH_LINK_INFO
  106. */
  107. typedef int32_t (*ARM_ETH_PHY_Read_t) (uint8_t phy_addr, uint8_t reg_addr, uint16_t *data); ///< Pointer to \ref ARM_ETH_MAC_PHY_Read : Read Ethernet PHY Register.
  108. typedef int32_t (*ARM_ETH_PHY_Write_t) (uint8_t phy_addr, uint8_t reg_addr, uint16_t data); ///< Pointer to \ref ARM_ETH_MAC_PHY_Write : Write Ethernet PHY Register.
  109. /**
  110. \brief Access structure of the Ethernet PHY Driver
  111. */
  112. typedef struct _ARM_DRIVER_ETH_PHY {
  113. ARM_DRIVER_VERSION (*GetVersion) (void); ///< Pointer to \ref ARM_ETH_PHY_GetVersion : Get driver version.
  114. int32_t (*Initialize) (ARM_ETH_PHY_Read_t fn_read,
  115. ARM_ETH_PHY_Write_t fn_write); ///< Pointer to \ref ARM_ETH_PHY_Initialize : Initialize PHY Device.
  116. int32_t (*Uninitialize) (void); ///< Pointer to \ref ARM_ETH_PHY_Uninitialize : De-initialize PHY Device.
  117. int32_t (*PowerControl) (ARM_POWER_STATE state); ///< Pointer to \ref ARM_ETH_PHY_PowerControl : Control PHY Device Power.
  118. int32_t (*SetInterface) (uint32_t interface); ///< Pointer to \ref ARM_ETH_PHY_SetInterface : Set Ethernet Media Interface.
  119. int32_t (*SetMode) (uint32_t mode); ///< Pointer to \ref ARM_ETH_PHY_SetMode : Set Ethernet PHY Device Operation mode.
  120. ARM_ETH_LINK_STATE (*GetLinkState) (void); ///< Pointer to \ref ARM_ETH_PHY_GetLinkState : Get Ethernet PHY Device Link state.
  121. ARM_ETH_LINK_INFO (*GetLinkInfo) (void); ///< Pointer to \ref ARM_ETH_PHY_GetLinkInfo : Get Ethernet PHY Device Link information.
  122. } const ARM_DRIVER_ETH_PHY;
  123. #ifdef __cplusplus
  124. }
  125. #endif
  126. #endif /* DRIVER_ETH_PHY_H_ */