11/*
2- * The Clear BSD License
32 * Copyright (c) 2015, Freescale Semiconductor, Inc.
4- * Copyright 2016-2017 NXP
3+ * Copyright 2016-2018 NXP
54 * All rights reserved.
65 *
7- * Redistribution and use in source and binary forms, with or without modification,
8- * are permitted (subject to the limitations in the disclaimer below) provided
9- * that the following conditions are met:
10- *
11- * o Redistributions of source code must retain the above copyright notice, this list
12- * of conditions and the following disclaimer.
13- *
14- * o Redistributions in binary form must reproduce the above copyright notice, this
15- * list of conditions and the following disclaimer in the documentation and/or
16- * other materials provided with the distribution.
17- *
18- * o Neither the name of the copyright holder nor the names of its
19- * contributors may be used to endorse or promote products derived from this
20- * software without specific prior written permission.
21- *
22- * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6+ * SPDX-License-Identifier: BSD-3-Clause
337 */
348
359#include "fsl_phy.h"
3812 ******************************************************************************/
3913
4014/*! @brief Defines the timeout macro. */
41- #define PHY_TIMEOUT_COUNT 0x3FFFFFFU
15+ #define PHY_TIMEOUT_COUNT 100000
4216
4317/*******************************************************************************
4418 * Prototypes
@@ -82,7 +56,7 @@ status_t PHY_Init(ENET_Type *base, uint32_t phyAddr, uint32_t srcClock_Hz)
8256 while ((idReg != PHY_CONTROL_ID1 ) && (counter != 0 ))
8357 {
8458 PHY_Read (base , phyAddr , PHY_ID1_REG , & idReg );
85- counter -- ;
59+ counter -- ;
8660 }
8761
8862 if (!counter )
@@ -94,11 +68,10 @@ status_t PHY_Init(ENET_Type *base, uint32_t phyAddr, uint32_t srcClock_Hz)
9468 result = PHY_Write (base , phyAddr , PHY_BASICCONTROL_REG , PHY_BCTL_RESET_MASK );
9569 if (result == kStatus_Success )
9670 {
97-
9871#if defined(FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE )
9972 uint32_t data = 0 ;
10073 result = PHY_Read (base , phyAddr , PHY_CONTROL2_REG , & data );
101- if ( result != kStatus_Success )
74+ if (result != kStatus_Success )
10275 {
10376 return result ;
10477 }
@@ -131,16 +104,16 @@ status_t PHY_AutoNegotiation(ENET_Type *base, uint32_t phyAddr)
131104 if (result == kStatus_Success )
132105 {
133106 /* Check auto negotiation complete. */
134- while (counter -- )
107+ while (counter -- )
135108 {
136109 result = PHY_Read (base , phyAddr , PHY_BASICSTATUS_REG , & bssReg );
137- if ( result == kStatus_Success )
110+ if (result == kStatus_Success )
138111 {
139112 PHY_Read (base , phyAddr , PHY_CONTROL1_REG , & ctlReg );
140113 if (((bssReg & PHY_BSTATUS_AUTONEGCOMP_MASK ) != 0 ) && (ctlReg & PHY_LINK_READY_MASK ))
141114 {
142115 /* Wait a moment for Phy status stable. */
143- for (timeDelay = 0 ; timeDelay < PHY_TIMEOUT_COUNT ; timeDelay ++ )
116+ for (timeDelay = 0 ; timeDelay < PHY_TIMEOUT_COUNT ; timeDelay ++ )
144117 {
145118 __ASM ("nop" );
146119 }
0 commit comments