Skip to content

Commit 96f834e

Browse files
committed
MIMXRT1050: Update the ENET PHY driver from SDK 2.6
Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent b7ca64b commit 96f834e

File tree

2 files changed

+13
-66
lines changed

2 files changed

+13
-66
lines changed

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/fsl_phy.c

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,9 @@
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"
@@ -38,7 +12,7 @@
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
}

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/fsl_phy.h

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,9 @@
11
/*
2-
* The Clear BSD License
32
* Copyright (c) 2015, Freescale Semiconductor, Inc.
43
* Copyright 2016-2017 NXP
54
* All rights reserved.
6-
*
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:
105
*
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
#ifndef _FSL_PHY_H_
359
#define _FSL_PHY_H_
@@ -70,16 +44,16 @@
7044

7145
/*!@brief Defines the mask flag of operation mode in control two register*/
7246
#define PHY_CTL2_REMOTELOOP_MASK 0x0004U /*!< The PHY remote loopback mask. */
73-
#define PHY_CTL2_REFCLK_SELECT_MASK 0x0080U /*!< The PHY RMII reference clock select. */
47+
#define PHY_CTL2_REFCLK_SELECT_MASK 0x0080U /*!< The PHY RMII reference clock select. */
7448
#define PHY_CTL1_10HALFDUPLEX_MASK 0x0001U /*!< The PHY 10M half duplex mask. */
7549
#define PHY_CTL1_100HALFDUPLEX_MASK 0x0002U /*!< The PHY 100M half duplex mask. */
7650
#define PHY_CTL1_10FULLDUPLEX_MASK 0x0005U /*!< The PHY 10M full duplex mask. */
7751
#define PHY_CTL1_100FULLDUPLEX_MASK 0x0006U /*!< The PHY 100M full duplex mask. */
7852
#define PHY_CTL1_SPEEDUPLX_MASK 0x0007U /*!< The PHY speed and duplex mask. */
7953
#define PHY_CTL1_ENERGYDETECT_MASK 0x10U /*!< The PHY signal present on rx differential pair. */
80-
#define PHY_CTL1_LINKUP_MASK 0x100U /*!< The PHY link up. */
54+
#define PHY_CTL1_LINKUP_MASK 0x100U /*!< The PHY link up. */
8155
#define PHY_LINK_READY_MASK (PHY_CTL1_ENERGYDETECT_MASK | PHY_CTL1_LINKUP_MASK)
82-
56+
8357
/*! @brief Defines the mask flag in basic status register. */
8458
#define PHY_BSTATUS_LINKSTATUS_MASK 0x0004U /*!< The PHY link status mask. */
8559
#define PHY_BSTATUS_AUTONEGABLE_MASK 0x0008U /*!< The PHY auto-negotiation ability mask. */
@@ -138,7 +112,7 @@ extern "C" {
138112
*
139113
* This function initialize the SMI interface and initialize PHY.
140114
* The SMI is the MII management interface between PHY and MAC, which should be
141-
* firstly initialized before any other operation for PHY. The PHY initialize with auto-negotiation.
115+
* firstly initialized before any other operation for PHY. The PHY initialize with auto-negotiation.
142116
*
143117
* @param base ENET peripheral base address.
144118
* @param phyAddr The PHY address.

0 commit comments

Comments
 (0)