From: "Marcin Wojtas" <mw@semihalf.com>
To: devel@edk2.groups.io
Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org,
mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com,
kostap@marvell.com, Jici.Gao@arm.com
Subject: [edk2-platforms: PATCH v2 2/4] Marvell/Drivers: MvPhyDxe: Refactor 88E1510 initialization
Date: Mon, 6 May 2019 04:37:05 +0200 [thread overview]
Message-ID: <1557110227-31466-3-git-send-email-mw@semihalf.com> (raw)
In-Reply-To: <1557110227-31466-1-git-send-email-mw@semihalf.com>
This patch adds only a non-functional change, extracting common
startup autonegotiation configuration into a separate routine.
It will be re-used in 88E1112 PHY support addition in a following
patch.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c | 86 +++++++++++++-------
1 file changed, 57 insertions(+), 29 deletions(-)
diff --git a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c b/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c
index 9be0489..63af640 100644
--- a/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c
+++ b/Silicon/Marvell/Drivers/Net/MvPhyDxe/MvPhyDxe.c
@@ -251,6 +251,58 @@ MvPhyParseStatus (
return EFI_SUCCESS;
}
+/**
+ Configure PHY device autonegotiation.
+
+ @param[in out] *PhyDevice A pointer to configured PHY device structure.
+
+**/
+STATIC
+EFI_STATUS
+MvPhyConfigureAutonegotiation (
+ IN OUT PHY_DEVICE *PhyDevice
+ )
+{
+ UINT32 Data;
+ INTN Index;
+
+ /* Read BMSR register in order to check autoneg capabilities and status. */
+ Mdio->Read (Mdio, PhyDevice->Addr, PhyDevice->MdioIndex, MII_BMSR, &Data);
+
+ if ((Data & BMSR_ANEGCAPABLE) && !(Data & BMSR_ANEGCOMPLETE)) {
+
+ DEBUG ((DEBUG_INFO,
+ "%a: Waiting for PHY auto negotiation...",
+ __FUNCTION__));
+
+ /* Wait for autonegotiation to complete and read media status */
+ for (Index = 0; !(Data & BMSR_ANEGCOMPLETE); Index++) {
+ if (Index > PHY_AUTONEGOTIATE_TIMEOUT) {
+ DEBUG ((DEBUG_ERROR, "%a: Timeout\n", __FUNCTION__));
+ PhyDevice->LinkUp = FALSE;
+ return EFI_TIMEOUT;
+ }
+ gBS->Stall (1000); /* 1 ms */
+ Mdio->Read (Mdio, PhyDevice->Addr, PhyDevice->MdioIndex, MII_BMSR, &Data);
+ }
+
+ PhyDevice->LinkUp = TRUE;
+ DEBUG ((DEBUG_INFO, "%a: link up\n", __FUNCTION__));
+ } else {
+ Mdio->Read (Mdio, PhyDevice->Addr, PhyDevice->MdioIndex, MII_BMSR, &Data);
+
+ if (Data & BMSR_LSTATUS) {
+ PhyDevice->LinkUp = TRUE;
+ DEBUG ((DEBUG_INFO, "%a: link up\n", __FUNCTION__));
+ } else {
+ PhyDevice->LinkUp = FALSE;
+ DEBUG ((DEBUG_INFO, "%a: link down\n", __FUNCTION__));
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
STATIC
VOID
MvPhy1512WriteBits (
@@ -282,8 +334,7 @@ MvPhyInit1512 (
IN OUT PHY_DEVICE *PhyDev
)
{
- UINT32 Data;
- INTN i;
+ EFI_STATUS Status;
if (PhyDev->Connection == PHY_CONNECTION_SGMII) {
/* Select page 0xff and update configuration registers according to
@@ -321,34 +372,11 @@ MvPhyInit1512 (
if (!PcdGetBool (PcdPhyStartupAutoneg))
return EFI_SUCCESS;
- Mdio->Read (Mdio, PhyDev->Addr, PhyDev->MdioIndex, MII_BMSR, &Data);
-
- if ((Data & BMSR_ANEGCAPABLE) && !(Data & BMSR_ANEGCOMPLETE)) {
-
- DEBUG((DEBUG_ERROR, "MvPhyDxe: Waiting for PHY auto negotiation... "));
- for (i = 0; !(Data & BMSR_ANEGCOMPLETE); i++) {
- if (i > PHY_AUTONEGOTIATE_TIMEOUT) {
- DEBUG((DEBUG_ERROR, "timeout\n"));
- PhyDev->LinkUp = FALSE;
- return EFI_TIMEOUT;
- }
-
- gBS->Stall(1000); /* 1 ms */
- Mdio->Read (Mdio, PhyDev->Addr, PhyDev->MdioIndex, MII_BMSR, &Data);
- }
- PhyDev->LinkUp = TRUE;
- DEBUG((DEBUG_INFO, "MvPhyDxe: link up\n"));
- } else {
- Mdio->Read (Mdio, PhyDev->Addr, PhyDev->MdioIndex, MII_BMSR, &Data);
-
- if (Data & BMSR_LSTATUS) {
- PhyDev->LinkUp = TRUE;
- DEBUG((DEBUG_INFO, "MvPhyDxe: link up\n"));
- } else {
- PhyDev->LinkUp = FALSE;
- DEBUG((DEBUG_INFO, "MvPhyDxe: link down\n"));
- }
+ Status = MvPhyConfigureAutonegotiation (PhyDev);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
+
MvPhyParseStatus (PhyDev);
return EFI_SUCCESS;
--
2.7.4
next prev parent reply other threads:[~2019-05-06 2:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-06 2:37 [edk2-platforms: PATCH v2 0/4] Armada 7k8k network improvements Marcin Wojtas
2019-05-06 2:37 ` [edk2-platforms: PATCH v2 1/4] Marvel/Drivers: Pp2Dxe: Basic support for Adapter Information Protocol Marcin Wojtas
2019-05-06 2:37 ` Marcin Wojtas [this message]
2019-05-06 2:37 ` [edk2-platforms: PATCH v2 3/4] Marvell/Drivers: MvPhyDxe: Introduce 88E1112 initialization Marcin Wojtas
2019-05-06 2:37 ` [edk2-platforms: PATCH v2 4/4] Marvell/Drivers: MvPhyDxe: Reset PHY only once Marcin Wojtas
2019-05-08 17:52 ` [edk2-platforms: PATCH v2 0/4] Armada 7k8k network improvements Leif Lindholm
2019-05-08 23:26 ` Marcin Wojtas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1557110227-31466-3-git-send-email-mw@semihalf.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox