1
1
/*
2
- * The Clear BSD License
3
2
* Copyright (c) 2015, Freescale Semiconductor, Inc.
4
- * Copyright 2016-2017 NXP
3
+ * Copyright 2016-2018 NXP
5
4
* All rights reserved.
6
5
*
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
33
7
*/
34
8
35
9
#include "fsl_phy.h"
38
12
******************************************************************************/
39
13
40
14
/*! @brief Defines the timeout macro. */
41
- #define PHY_TIMEOUT_COUNT 0x3FFFFFFU
15
+ #define PHY_TIMEOUT_COUNT 100000
42
16
43
17
/*******************************************************************************
44
18
* Prototypes
@@ -82,7 +56,7 @@ status_t PHY_Init(ENET_Type *base, uint32_t phyAddr, uint32_t srcClock_Hz)
82
56
while ((idReg != PHY_CONTROL_ID1 ) && (counter != 0 ))
83
57
{
84
58
PHY_Read (base , phyAddr , PHY_ID1_REG , & idReg );
85
- counter -- ;
59
+ counter -- ;
86
60
}
87
61
88
62
if (!counter )
@@ -94,11 +68,10 @@ status_t PHY_Init(ENET_Type *base, uint32_t phyAddr, uint32_t srcClock_Hz)
94
68
result = PHY_Write (base , phyAddr , PHY_BASICCONTROL_REG , PHY_BCTL_RESET_MASK );
95
69
if (result == kStatus_Success )
96
70
{
97
-
98
71
#if defined(FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE )
99
72
uint32_t data = 0 ;
100
73
result = PHY_Read (base , phyAddr , PHY_CONTROL2_REG , & data );
101
- if ( result != kStatus_Success )
74
+ if (result != kStatus_Success )
102
75
{
103
76
return result ;
104
77
}
@@ -131,16 +104,16 @@ status_t PHY_AutoNegotiation(ENET_Type *base, uint32_t phyAddr)
131
104
if (result == kStatus_Success )
132
105
{
133
106
/* Check auto negotiation complete. */
134
- while (counter -- )
107
+ while (counter -- )
135
108
{
136
109
result = PHY_Read (base , phyAddr , PHY_BASICSTATUS_REG , & bssReg );
137
- if ( result == kStatus_Success )
110
+ if (result == kStatus_Success )
138
111
{
139
112
PHY_Read (base , phyAddr , PHY_CONTROL1_REG , & ctlReg );
140
113
if (((bssReg & PHY_BSTATUS_AUTONEGCOMP_MASK ) != 0 ) && (ctlReg & PHY_LINK_READY_MASK ))
141
114
{
142
115
/* 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 ++ )
144
117
{
145
118
__ASM ("nop" );
146
119
}
0 commit comments