From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=fhpAWdJG; spf=pass (domain: linaro.org, ip: 209.85.166.196, mailfrom: ard.biesheuvel@linaro.org) Received: from mail-it1-f196.google.com (mail-it1-f196.google.com [209.85.166.196]) by groups.io with SMTP; Thu, 02 May 2019 23:35:38 -0700 Received: by mail-it1-f196.google.com with SMTP id l140so7537088itb.0 for ; Thu, 02 May 2019 23:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aH4BYIGkYQbz0DR6kY81lsJVua5Y/+Mj4qXTmEpQ4rg=; b=fhpAWdJGixv3OlSnGi3PttWFfBASPXEbov7VCTHJAUHgNImj71KqkAFvIF5xEIKRfu vFlvOhMhiLvjwpEOq9aM0ea057DQI5cOyCY1st22/IZyuvPrNcM0cjmN7alMg5txl4k+ QPiUukh6hWz1XdPfMj/LNW122bJ2dHeshEp1oDwBXwsFSjdVhCCwWXqIV3g45ZNs7KRy yq3YxpmCJ3DGq35OXTr0C9h2mKbbgUqlUCNXMikVm9r+irE8kYosF2tijkV4/11vuyIR ojdg7s9UQyYn4BSsYHyy++2PoZpq7Zs2xOYM1ZaRgGtInvcfDP0+gVDku5UyqontMFZV ryPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aH4BYIGkYQbz0DR6kY81lsJVua5Y/+Mj4qXTmEpQ4rg=; b=HPmF7i1N4W68ITC1zl1o6Q2C6jOX0CNMyp9vrQ6VXQU8jBu1rMOjsIC21dgn4cfOyc mve5s3r1x32R/YOD873elABGSdt4nMCqcApkINnzRKRLxv9YezPIwz/mIXSEBEFbz0Tu Gd49PsvHnbXnl/PUEY54cIGZo24WvHFY8ROouD4GW6oQAUI/0vfSLIbrafrYK+7Vc+Yj h79+9XJ0f2GmR2dmFWKTBk0bhEWFwdYZ2/dEUHczdlnj4JpbAleVYGhB3tppWBS3HMgg rD/tCbokiIyjCRQN18hdFp+/h36YerGW4p847Ds6bQwAROHUR3JvIv58Vg2aZeAKVNhy lytg== X-Gm-Message-State: APjAAAUSEMWsgBysZ2b8HXBev3CR1tfAitx93tXxnrqjvIO0pe+6c6Bi NYv1K7x4vTNffeDf5xEyexNU1rIHYoB1+6iteqiQcg== X-Google-Smtp-Source: APXvYqztrjamrfAZlQ/L/3/gQ5x7PhLaU97q+b3bH7wCg8kKz1Akw3jqzbJXGXRh82BmNBA+e9kuNeK1xUfIQhc+YO4= X-Received: by 2002:a24:59c1:: with SMTP id p184mr6109659itb.158.1556865338143; Thu, 02 May 2019 23:35:38 -0700 (PDT) MIME-Version: 1.0 References: <1556841016-10342-1-git-send-email-mw@semihalf.com> <1556841016-10342-3-git-send-email-mw@semihalf.com> In-Reply-To: <1556841016-10342-3-git-send-email-mw@semihalf.com> From: "Ard Biesheuvel" Date: Fri, 3 May 2019 08:35:26 +0200 Message-ID: Subject: Re: [edk2-platforms: PATCH 2/4] Marvell/Drivers: MvPhyDxe: Improve 88E1510 initialization To: Marcin Wojtas Cc: edk2-devel-groups-io , Leif Lindholm , =?UTF-8?B?SmFuIETEhWJyb8Wb?= , Grzegorz Jaszczyk , Kostya Porotchkin , Jici Gao Content-Type: text/plain; charset="UTF-8" On Fri, 3 May 2019 at 01:50, Marcin Wojtas wrote: > > 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. > In that case, call it 'refactor' not 'improve' > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Marcin Wojtas > --- > 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..780e8bd 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 */ Space before ( > + 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 >