2 * Copyright (c) 2013-2020 Arm Limited. All rights reserved.
4 * SPDX-License-Identifier: Apache-2.0
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
10 * www.apache.org/licenses/LICENSE-2.0
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.
19 #include "Driver_ETH_PHY.h"
21 #define ARM_ETH_PHY_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
24 static const ARM_DRIVER_VERSION DriverVersion = {
25 ARM_ETH_PHY_API_VERSION,
26 ARM_ETH_PHY_DRV_VERSION
33 static ARM_DRIVER_VERSION ARM_ETH_PHY_GetVersion(void)
38 static int32_t ARM_ETH_PHY_Initialize(ARM_ETH_PHY_Read_t fn_read, ARM_ETH_PHY_Write_t fn_write)
42 static int32_t ARM_ETH_PHY_Uninitialize(void)
46 static int32_t ARM_ETH_PHY_PowerControl(ARM_POWER_STATE state)
62 static int32_t ARM_ETH_PHY_SetInterface(uint32_t interface)
66 case ARM_ETH_INTERFACE_MII:
68 case ARM_ETH_INTERFACE_RMII:
71 return ARM_DRIVER_ERROR_UNSUPPORTED;
75 static int32_t ARM_ETH_PHY_SetMode(uint32_t mode)
77 switch (mode & ARM_ETH_PHY_SPEED_Msk)
79 case ARM_ETH_PHY_SPEED_10M:
81 case ARM_ETH_PHY_SPEED_100M:
84 return ARM_DRIVER_ERROR_UNSUPPORTED;
87 switch (mode & ARM_ETH_PHY_DUPLEX_Msk)
89 case ARM_ETH_PHY_DUPLEX_HALF:
91 case ARM_ETH_PHY_DUPLEX_FULL:
95 if (mode & ARM_ETH_PHY_AUTO_NEGOTIATE)
99 if (mode & ARM_ETH_PHY_LOOPBACK)
103 if (mode & ARM_ETH_PHY_ISOLATE)
108 static ARM_ETH_LINK_STATE ARM_ETH_PHY_GetLinkState(void)
112 static ARM_ETH_LINK_INFO ARM_ETH_PHY_GetLinkInfo(void)
117 ARM_DRIVER_ETH_PHY Driver_ETH_PHY0;
118 ARM_DRIVER_ETH_PHY Driver_ETH_PHY0 =
120 ARM_ETH_PHY_GetVersion,
121 ARM_ETH_PHY_Initialize,
122 ARM_ETH_PHY_Uninitialize,
123 ARM_ETH_PHY_PowerControl,
124 ARM_ETH_PHY_SetInterface,
126 ARM_ETH_PHY_GetLinkState,
127 ARM_ETH_PHY_GetLinkInfo,