]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c
edk2: Remove packages moved to edk2-platforms
[mirror_edk2.git] / OptionRomPkg / Bus / Usb / UsbNetworking / Ax88772b / Ax88772.c
diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c
deleted file mode 100644 (file)
index 12684a6..0000000
+++ /dev/null
@@ -1,875 +0,0 @@
-/** @file\r
-  Implement the interface to the AX88772 Ethernet controller.\r
-\r
-  This module implements the interface to the ASIX AX88772\r
-  USB to Ethernet MAC with integrated 10/100 PHY.  Note that this implementation\r
-  only supports the integrated PHY since no other test cases were available.\r
-\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Ax88772.h"\r
-\r
-\r
-/**\r
-  Compute the CRC \r
-\r
-  @param [in] pMacAddress      Address of a six byte buffer to containing the MAC address.\r
-\r
-  @returns The CRC-32 value associated with this MAC address\r
-\r
-**/\r
-UINT32\r
-Ax88772Crc (\r
-  IN UINT8 * pMacAddress\r
-  )\r
-{\r
-  UINT32 BitNumber;\r
-  INT32 Carry;\r
-  INT32 Crc;\r
-  UINT32 Data;\r
-  UINT8 * pEnd;\r
-\r
-  //\r
-  //  Walk the MAC address\r
-  //\r
-  Crc = -1;\r
-  pEnd = &pMacAddress[ PXE_HWADDR_LEN_ETHER ];\r
-  while ( pEnd > pMacAddress ) {\r
-    Data = *pMacAddress++;\r
-    //\r
-    //  CRC32: x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1\r
-    //\r
-    //          1 0000 0100 1100 0001 0001 1101 1011 0111\r
-    //\r
-    for ( BitNumber = 0; 8 > BitNumber; BitNumber++ ) {\r
-      Carry = (( Crc >> 31 ) & 1 ) ^ ( Data & 1 );\r
-      Crc <<= 1;\r
-      if ( 0 != Carry ) {\r
-        Crc ^= 0x04c11db7;\r
-      }\r
-      Data >>= 1;\r
-    }\r
-  }\r
-  //\r
-  //  Return the CRC value\r
-  //\r
-  return (UINT32) Crc;\r
-}\r
-\r
-\r
-/**\r
-  Get the MAC address\r
-\r
-  This routine calls ::Ax88772UsbCommand to request the MAC\r
-  address from the network adapter.\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-  @param [out] pMacAddress      Address of a six byte buffer to receive the MAC address.\r
-\r
-  @retval EFI_SUCCESS          The MAC address is available.\r
-  @retval other                The MAC address is not valid.\r
-\r
-**/\r
-EFI_STATUS\r
-Ax88772MacAddressGet (\r
-  IN NIC_DEVICE * pNicDevice,\r
-  OUT UINT8 * pMacAddress\r
-  )\r
-{\r
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-\r
-  //\r
-  //  Set the register address.\r
-  //\r
-  SetupMsg.RequestType = USB_ENDPOINT_DIR_IN\r
-                       | USB_REQ_TYPE_VENDOR\r
-                       | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_MAC_ADDRESS_READ;\r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = PXE_HWADDR_LEN_ETHER;\r
-\r
-  //\r
-  //  Read the PHY register\r
-  //\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                               &SetupMsg,\r
-                               pMacAddress );\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Set the MAC address\r
-\r
-  This routine calls ::Ax88772UsbCommand to set the MAC address\r
-  in the network adapter.\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-  @param [in] pMacAddress      Address of a six byte buffer to containing the new MAC address.\r
-\r
-  @retval EFI_SUCCESS          The MAC address was set.\r
-  @retval other                The MAC address was not set.\r
-\r
-**/\r
-EFI_STATUS\r
-Ax88772MacAddressSet (\r
-  IN NIC_DEVICE * pNicDevice,\r
-  IN UINT8 * pMacAddress\r
-  )\r
-{\r
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-\r
-  //\r
-  //  Set the register address.\r
-  //\r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                       | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_MAC_ADDRESS_WRITE;\r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = PXE_HWADDR_LEN_ETHER;\r
-  \r
-  //\r
-  //  Read the PHY register\r
-  //\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                               &SetupMsg,\r
-                               pMacAddress );\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Clear the multicast hash table\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-\r
-**/\r
-VOID\r
-Ax88772MulticastClear (\r
-  IN NIC_DEVICE * pNicDevice\r
-  )\r
-{\r
-  int i = 0;\r
-  //\r
-  // Clear the multicast hash table\r
-  //\r
-  for ( i = 0 ; i < 8 ; i ++ )\r
-     pNicDevice->MulticastHash[0] = 0;\r
-}\r
-\r
-/**\r
-  Enable a multicast address in the multicast hash table\r
-\r
-  This routine calls ::Ax88772Crc to compute the hash bit for\r
-  this MAC address.\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-  @param [in] pMacAddress      Address of a six byte buffer to containing the MAC address.\r
-\r
-**/\r
-VOID\r
-Ax88772MulticastSet (\r
-  IN NIC_DEVICE * pNicDevice,\r
-  IN UINT8 * pMacAddress\r
-  )\r
-{\r
-  UINT32 Crc;\r
-\r
-  //\r
-  //  Compute the CRC on the destination address\r
-  //\r
-  Crc = Ax88772Crc ( pMacAddress ) >> 26;\r
-\r
-  //\r
-  //  Set the bit corresponding to the destination address\r
-  //\r
-   pNicDevice->MulticastHash [ Crc >> 3 ] |= ( 1<< (Crc& 7));\r
-}\r
-\r
-/**\r
-  Start the link negotiation\r
-\r
-  This routine calls ::Ax88772PhyWrite to start the PHY's link\r
-  negotiation.\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-\r
-  @retval EFI_SUCCESS          The link negotiation was started.\r
-  @retval other                Failed to start the link negotiation.\r
-\r
-**/\r
-EFI_STATUS\r
-Ax88772NegotiateLinkStart (\r
-  IN NIC_DEVICE * pNicDevice\r
-  )\r
-{\r
-  UINT16 Control;\r
-  EFI_STATUS Status;\r
-  int i; \r
-  //\r
-  // Set the supported capabilities.\r
-  //\r
-  Status = Ax88772PhyWrite ( pNicDevice,\r
-                             PHY_ANAR,\r
-                             AN_CSMA_CD\r
-                             | AN_TX_FDX | AN_TX_HDX\r
-                             | AN_10_FDX | AN_10_HDX );\r
-  if ( !EFI_ERROR ( Status )) {\r
-    //\r
-    // Set the link speed and duplex\r
-    //\r
-    Control = BMCR_AUTONEGOTIATION_ENABLE\r
-            | BMCR_RESTART_AUTONEGOTIATION;\r
-    if ( pNicDevice->b100Mbps ) {\r
-      Control |= BMCR_100MBPS;\r
-    }\r
-    if ( pNicDevice->bFullDuplex ) {\r
-      Control |= BMCR_FULL_DUPLEX;\r
-    }\r
-    Status = Ax88772PhyWrite ( pNicDevice, PHY_BMCR, Control );\r
-  }\r
-  \r
-  if (!EFI_ERROR(Status)) {\r
-    i = 0;\r
-    do {\r
-      \r
-        if (pNicDevice->bComplete && pNicDevice->bLinkUp) {\r
-            pNicDevice->SimpleNetwork.Mode->MediaPresent \r
-               = pNicDevice->bLinkUp & pNicDevice->bComplete;\r
-           break;\r
-       }\r
-       else {\r
-            gBS->Stall(AUTONEG_DELAY);\r
-            Status = Ax88772NegotiateLinkComplete ( pNicDevice,\r
-                                            &pNicDevice->PollCount,\r
-                                            &pNicDevice->bComplete,\r
-                                            &pNicDevice->bLinkUp,\r
-                                            &pNicDevice->b100Mbps,\r
-                                            &pNicDevice->bFullDuplex );\r
-            i++;\r
-        }\r
-    }while(!pNicDevice->bLinkUp && i < AUTONEG_POLLCNT);\r
-  }\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Complete the negotiation of the PHY link\r
-\r
-  This routine calls ::Ax88772PhyRead to determine if the\r
-  link negotiation is complete.\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-  @param [in, out] pPollCount  Address of number of times this routine was polled\r
-  @param [out] pbComplete      Address of boolean to receive complate status.\r
-  @param [out] pbLinkUp        Address of boolean to receive link status, TRUE=up.\r
-  @param [out] pbHiSpeed       Address of boolean to receive link speed, TRUE=100Mbps.\r
-  @param [out] pbFullDuplex    Address of boolean to receive link duplex, TRUE=full.\r
-\r
-  @retval EFI_SUCCESS          The MAC address is available.\r
-  @retval other                The MAC address is not valid.\r
-\r
-**/\r
-EFI_STATUS\r
-Ax88772NegotiateLinkComplete (\r
-  IN NIC_DEVICE * pNicDevice,\r
-  IN OUT UINTN * pPollCount,\r
-  OUT BOOLEAN * pbComplete,\r
-  OUT BOOLEAN * pbLinkUp,\r
-  OUT BOOLEAN * pbHiSpeed,\r
-  OUT BOOLEAN * pbFullDuplex\r
-  )\r
-{\r
-  UINT16 Mask;\r
-  UINT16 PhyData;\r
-  EFI_STATUS  Status;\r
\r
-  //\r
-  //  Determine if the link is up.\r
-  //\r
-  *pbComplete = FALSE;  \r
-\r
-  //\r
-  //  Get the link status\r
-  //\r
-  Status = Ax88772PhyRead ( pNicDevice,\r
-                            PHY_BMSR,\r
-                            &PhyData );\r
-\r
-  if ( !EFI_ERROR ( Status )) {\r
-      *pbLinkUp = (BOOLEAN)( 0 != ( PhyData & BMSR_LINKST ));\r
-      if ( 0 == *pbLinkUp ) {\r
-        DEBUG (( EFI_D_INFO, "Link Down\n" ));\r
-      }      \r
-      else {\r
-         *pbComplete = (BOOLEAN)( 0 != ( PhyData & 0x20 ));\r
-         if ( 0 == *pbComplete ) {\r
-              DEBUG (( EFI_D_INFO, "Autoneg is not yet Complete\n" ));\r
-        }\r
-        else {\r
-          Status = Ax88772PhyRead ( pNicDevice,\r
-                                PHY_ANLPAR,\r
-                                &PhyData );\r
-          if ( !EFI_ERROR ( Status )) {\r
-            //\r
-            //  Autonegotiation is complete\r
-            //  Determine the link speed.\r
-            //\r
-            *pbHiSpeed = (BOOLEAN)( 0 != ( PhyData & ( AN_TX_FDX | AN_TX_HDX )));\r
-\r
-            //\r
-            //  Determine the link duplex.\r
-            //\r
-            Mask = ( *pbHiSpeed ) ? AN_TX_FDX : AN_10_FDX;\r
-            *pbFullDuplex = (BOOLEAN)( 0 != ( PhyData & Mask ));\r
-          }\r
-        } \r
-      }\r
-  } \r
-  else {\r
-      DEBUG (( EFI_D_ERROR, "Failed to read BMCR\n" ));\r
-  }\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Read a register from the PHY\r
-\r
-  This routine calls ::Ax88772UsbCommand to read a PHY register.\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-  @param [in] RegisterAddress  Number of the register to read.\r
-  @param [in, out] pPhyData    Address of a buffer to receive the PHY register value\r
-\r
-  @retval EFI_SUCCESS          The PHY data is available.\r
-  @retval other                The PHY data is not valid.\r
-\r
-**/\r
-EFI_STATUS\r
-Ax88772PhyRead (\r
-  IN NIC_DEVICE * pNicDevice,\r
-  IN UINT8 RegisterAddress,\r
-  IN OUT UINT16 * pPhyData\r
-  )\r
-{\r
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-\r
-  //\r
-  //  Request access to the PHY\r
-  //\r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                       | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_PHY_ACCESS_SOFTWARE;   \r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = 0;\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                               &SetupMsg,\r
-                               NULL );\r
-  if ( !EFI_ERROR ( Status )) {\r
-    //\r
-    //  Read the PHY register address.\r
-    //\r
-    SetupMsg.RequestType = USB_ENDPOINT_DIR_IN\r
-                         | USB_REQ_TYPE_VENDOR\r
-                         | USB_TARGET_DEVICE;\r
-    SetupMsg.Request = CMD_PHY_REG_READ;\r
-    SetupMsg.Value = pNicDevice->PhyId;\r
-    SetupMsg.Index = RegisterAddress;\r
-    SetupMsg.Length = sizeof ( *pPhyData );\r
-    Status = Ax88772UsbCommand ( pNicDevice,\r
-                                 &SetupMsg,\r
-                                 pPhyData );\r
-    if ( !EFI_ERROR ( Status )) {\r
-\r
-      //\r
-      //  Release the PHY to the hardware\r
-      //\r
-      SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                           | USB_TARGET_DEVICE;\r
-      SetupMsg.Request = CMD_PHY_ACCESS_HARDWARE;\r
-      SetupMsg.Value = 0;\r
-      SetupMsg.Index = 0;\r
-      SetupMsg.Length = 0;\r
-      Status = Ax88772UsbCommand ( pNicDevice,\r
-                                   &SetupMsg,\r
-                                   NULL );\r
-    }\r
-  }\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Write to a PHY register\r
-\r
-  This routine calls ::Ax88772UsbCommand to write a PHY register.\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-  @param [in] RegisterAddress  Number of the register to read.\r
-  @param [in] PhyData          Address of a buffer to receive the PHY register value\r
-\r
-  @retval EFI_SUCCESS          The PHY data was written.\r
-  @retval other                Failed to wwrite the PHY register.\r
-\r
-**/\r
-EFI_STATUS\r
-Ax88772PhyWrite (\r
-  IN NIC_DEVICE * pNicDevice,\r
-  IN UINT8 RegisterAddress,\r
-  IN UINT16 PhyData\r
-  )\r
-{\r
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-\r
-  //\r
-  //  Request access to the PHY\r
-  //\r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                       | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_PHY_ACCESS_SOFTWARE;\r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = 0;\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                               &SetupMsg,\r
-                               NULL );\r
-  if ( !EFI_ERROR ( Status )) {\r
-    //\r
-    //  Write the PHY register\r
-    //\r
-    SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                         | USB_TARGET_DEVICE;\r
-    SetupMsg.Request = CMD_PHY_REG_WRITE;\r
-    SetupMsg.Value = pNicDevice->PhyId;\r
-    SetupMsg.Index = RegisterAddress;\r
-    SetupMsg.Length = sizeof ( PhyData );\r
-    Status = Ax88772UsbCommand ( pNicDevice,\r
-                                 &SetupMsg,\r
-                                 &PhyData );\r
-    if ( !EFI_ERROR ( Status )) {\r
-\r
-      //\r
-      //  Release the PHY to the hardware\r
-      //\r
-      SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                           | USB_TARGET_DEVICE;\r
-      SetupMsg.Request = CMD_PHY_ACCESS_HARDWARE;\r
-      SetupMsg.Value = 0;\r
-      SetupMsg.Index = 0;\r
-      SetupMsg.Length = 0;\r
-      Status = Ax88772UsbCommand ( pNicDevice,\r
-                                   &SetupMsg,\r
-                                   NULL );\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Reset the AX88772\r
-\r
-  This routine uses ::Ax88772UsbCommand to reset the network\r
-  adapter.  This routine also uses ::Ax88772PhyWrite to reset\r
-  the PHY.\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-\r
-  @retval EFI_SUCCESS          The MAC address is available.\r
-  @retval other                The MAC address is not valid.\r
-\r
-**/\r
-EFI_STATUS\r
-Ax88772Reset (\r
-  IN NIC_DEVICE * pNicDevice\r
-  )\r
-{\r
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-  \r
-  EFI_USB_IO_PROTOCOL *pUsbIo;\r
-  EFI_USB_DEVICE_DESCRIPTOR Device;\r
-  \r
-  pUsbIo = pNicDevice->pUsbIo;\r
-  Status = pUsbIo->UsbGetDeviceDescriptor ( pUsbIo, &Device );\r
-\r
-       if (EFI_ERROR(Status)) goto err; \r
-\r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                           | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_PHY_ACCESS_HARDWARE;\r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = 0;\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                                &SetupMsg,\r
-                                NULL );\r
-                                   \r
-  if (EFI_ERROR(Status)) goto err;                                 \r
-                                   \r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                          | USB_TARGET_DEVICE;\r
-      SetupMsg.Request = CMD_PHY_SELECT;\r
-      SetupMsg.Value = SPHY_PSEL;\r
-      SetupMsg.Index = 0;\r
-      SetupMsg.Length = 0;\r
-      Status = Ax88772UsbCommand ( pNicDevice,\r
-                                    &SetupMsg,\r
-                                    NULL );\r
-                                    \r
-  if (EFI_ERROR(Status)) goto err;  \r
-                                     \r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                          | USB_TARGET_DEVICE;                                \r
-  SetupMsg.Request = CMD_RESET;\r
-      SetupMsg.Value = SRR_IPRL ;\r
-      SetupMsg.Index = 0;\r
-      SetupMsg.Length = 0;\r
-      Status = Ax88772UsbCommand ( pNicDevice,\r
-                                   &SetupMsg,\r
-                                   NULL );  \r
-                                   \r
-  if (EFI_ERROR(Status)) goto err;  \r
-                                   \r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                          | USB_TARGET_DEVICE;                                \r
-  SetupMsg.Request = CMD_RESET;\r
-        SetupMsg.Value = SRR_IPPD | SRR_IPRL ;\r
-        SetupMsg.Index = 0;\r
-        SetupMsg.Length = 0;\r
-        Status = Ax88772UsbCommand ( pNicDevice,\r
-                                    &SetupMsg,\r
-                                    NULL );\r
-                                   \r
-  gBS->Stall ( 200000 );\r
-    \r
-  if (EFI_ERROR(Status)) goto err;  \r
-    \r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                          | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_RESET;\r
-  SetupMsg.Value =  SRR_IPRL  ;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = 0;\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                                &SetupMsg,\r
-                                NULL );   \r
-                                    \r
-  gBS->Stall ( 200000 ); \r
-     \r
-  if (EFI_ERROR(Status)) goto err;  \r
-     \r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                          | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_RESET;\r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = 0;\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                                    &SetupMsg,\r
-                                    NULL );\r
-                                    \r
-  if (EFI_ERROR(Status)) goto err;                                \r
-                                    \r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                          | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_PHY_SELECT;\r
-  SetupMsg.Value = SPHY_PSEL;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = 0;\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                                    &SetupMsg,\r
-                                    NULL ); \r
-                                    \r
-  if (EFI_ERROR(Status)) goto err;                                \r
-                                    \r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                          | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_RESET;\r
-  SetupMsg.Value =  SRR_IPRL | SRR_BZ | SRR_BZTYPE;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = 0;\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                                    &SetupMsg,\r
-                                    NULL );\r
-                                    \r
-  if (EFI_ERROR(Status)) goto err;                                \r
-                                    \r
-  SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                        | USB_TARGET_DEVICE;\r
-  SetupMsg.Request = CMD_RX_CONTROL_WRITE;\r
-  SetupMsg.Value = 0;\r
-  SetupMsg.Index = 0;\r
-  SetupMsg.Length = 0;\r
-  Status = Ax88772UsbCommand ( pNicDevice,\r
-                                  &SetupMsg,\r
-                                  NULL );\r
-                                  \r
-  if (EFI_ERROR(Status)) goto err;  \r
-\r
-  if (pNicDevice->Flags != FLAG_TYPE_AX88772) {\r
-        SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                        | USB_TARGET_DEVICE;\r
-        SetupMsg.Request = CMD_RXQTC;\r
-        SetupMsg.Value = 0x8000;\r
-        SetupMsg.Index = 0x8001;\r
-        SetupMsg.Length = 0;\r
-        Status = Ax88772UsbCommand ( pNicDevice,\r
-                                  &SetupMsg,\r
-                                  NULL );\r
-  }\r
-\r
-err:\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Enable or disable the receiver\r
-\r
-  This routine calls ::Ax88772UsbCommand to update the\r
-  receiver state.  This routine also calls ::Ax88772MacAddressSet\r
-  to establish the MAC address for the network adapter.\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-  @param [in] RxFilter         Simple network RX filter mask value\r
-\r
-  @retval EFI_SUCCESS          The MAC address was set.\r
-  @retval other                The MAC address was not set.\r
-\r
-**/\r
-EFI_STATUS\r
-Ax88772RxControl (\r
-  IN NIC_DEVICE * pNicDevice,\r
-  IN UINT32 RxFilter\r
-  )\r
-{\r
-  UINT16 MediumStatus;\r
-  UINT16 RxControl;\r
-  USB_DEVICE_REQUEST SetupMsg;\r
-  EFI_STATUS Status;\r
-  EFI_USB_IO_PROTOCOL *pUsbIo;\r
-  EFI_USB_DEVICE_DESCRIPTOR Device;\r
-  \r
-  pUsbIo = pNicDevice->pUsbIo;\r
-  Status = pUsbIo->UsbGetDeviceDescriptor ( pUsbIo, &Device );\r
-  \r
-  if (EFI_ERROR(Status)) {\r
-    DEBUG (( EFI_D_ERROR, "Failed to get device descriptor\n" ));\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Enable the receiver if something is to be received\r
-  //\r
-  \r
-  if ( 0 != RxFilter ) {\r
-    //\r
-    //  Enable the receiver\r
-    //\r
-    SetupMsg.RequestType = USB_ENDPOINT_DIR_IN\r
-                         | USB_REQ_TYPE_VENDOR\r
-                         | USB_TARGET_DEVICE;\r
-    SetupMsg.Request = CMD_MEDIUM_STATUS_READ;    \r
-    SetupMsg.Value = 0;\r
-    SetupMsg.Index = 0;\r
-    SetupMsg.Length = sizeof ( MediumStatus );\r
-    Status = Ax88772UsbCommand ( pNicDevice,\r
-                                 &SetupMsg,\r
-                                 &MediumStatus );\r
-    if ( !EFI_ERROR ( Status )) {\r
-      if ( 0 == ( MediumStatus & MS_RE )) {\r
-        MediumStatus |= MS_RE | MS_ONE;\r
-        \r
-        if ( pNicDevice->bFullDuplex )\r
-          MediumStatus |= MS_TFC | MS_RFC | MS_FD;\r
-        else\r
-          MediumStatus &= ~(MS_TFC | MS_RFC | MS_FD);\r
-        \r
-        if ( pNicDevice->b100Mbps )\r
-          MediumStatus |= MS_PS;\r
-        else\r
-          MediumStatus &= ~MS_PS;\r
-        \r
-        SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                             | USB_TARGET_DEVICE;\r
-        SetupMsg.Request = CMD_MEDIUM_STATUS_WRITE;\r
-        SetupMsg.Value = MediumStatus;\r
-        SetupMsg.Index = 0;\r
-        SetupMsg.Length = 0;\r
-        Status = Ax88772UsbCommand ( pNicDevice,\r
-                                     &SetupMsg,\r
-                                     NULL );\r
-        if ( EFI_ERROR ( Status )) {\r
-            DEBUG (( EFI_D_ERROR, "Failed to enable receiver, Status: %r\r\n",\r
-              Status ));\r
-        }\r
-      }\r
-    }\r
-    else {\r
-        DEBUG (( EFI_D_ERROR, "Failed to read receiver status, Status: %r\r\n",\r
-              Status ));\r
-    }\r
-  }\r
-  \r
-  RxControl = RXC_SO | RXC_RH1M;  \r
-  //\r
-  //  Enable multicast if requested\r
-  //\r
-  if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST )) {\r
-      RxControl |= RXC_AM;\r
-      //\r
-      //  Update the multicast hash table\r
-      //\r
-      SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                           | USB_TARGET_DEVICE;\r
-      SetupMsg.Request = CMD_MULTICAST_HASH_WRITE;\r
-      SetupMsg.Value = 0;\r
-      SetupMsg.Index = 0;\r
-      SetupMsg.Length = sizeof ( pNicDevice ->MulticastHash );\r
-      Status = Ax88772UsbCommand ( pNicDevice,\r
-                                   &SetupMsg,\r
-                                   &pNicDevice->MulticastHash );\r
-  }\r
-  //\r
-  //  Enable all multicast if requested\r
-  //\r
-  if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST )) {\r
-      RxControl |= RXC_AMALL;\r
-  }\r
-\r
-  //\r
-  //  Enable broadcast if requested\r
-  //\r
-  if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST )) {\r
-      RxControl |= RXC_AB;\r
-  }\r
-\r
-  //\r
-  //  Enable promiscuous mode if requested\r
-  //\r
-  if ( 0 != ( RxFilter & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS )) {\r
-      RxControl |= RXC_PRO;\r
-  }\r
-    \r
-  //\r
-  //  Update the receiver control\r
-  //\r
-  if (pNicDevice->CurRxControl != RxControl) {\r
-    SetupMsg.RequestType = USB_REQ_TYPE_VENDOR\r
-                         | USB_TARGET_DEVICE;\r
-    SetupMsg.Request = CMD_RX_CONTROL_WRITE;\r
-    SetupMsg.Value = RxControl;\r
-    SetupMsg.Index = 0;\r
-    SetupMsg.Length = 0;\r
-    Status = Ax88772UsbCommand ( pNicDevice,\r
-                                 &SetupMsg,\r
-                                 NULL );\r
-    if ( !EFI_ERROR ( Status )) {\r
-      pNicDevice->CurRxControl = RxControl;\r
-      \r
-    }\r
-    else {\r
-        DEBUG (( EFI_D_ERROR, "ERROR - Failed to set receiver control, Status: %r\r\n",\r
-            Status ));\r
-    }\r
-  }\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Read an SROM location\r
-\r
-  This routine calls ::Ax88772UsbCommand to read data from the\r
-  SROM.\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-  @param [in] Address          SROM address\r
-  @param [out] pData           Buffer to receive the data\r
-\r
-  @retval EFI_SUCCESS          The read was successful\r
-  @retval other                The read failed\r
-\r
-**/\r
-EFI_STATUS\r
-Ax88772SromRead (\r
-  IN NIC_DEVICE * pNicDevice,\r
-  IN UINT32 Address,\r
-  OUT UINT16 * pData\r
-  )\r
-{ \r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Send a command to the USB device.\r
-\r
-  @param [in] pNicDevice       Pointer to the NIC_DEVICE structure\r
-  @param [in] pRequest         Pointer to the request structure\r
-  @param [in, out] pBuffer     Data buffer address\r
-\r
-  @retval EFI_SUCCESS          The USB transfer was successful\r
-  @retval other                The USB transfer failed\r
-\r
-**/\r
-EFI_STATUS\r
-Ax88772UsbCommand (\r
-  IN NIC_DEVICE * pNicDevice,\r
-  IN USB_DEVICE_REQUEST * pRequest,\r
-  IN OUT VOID * pBuffer\r
-  )\r
-{\r
-  UINT32 CmdStatus;\r
-  EFI_USB_DATA_DIRECTION Direction;\r
-  EFI_USB_IO_PROTOCOL * pUsbIo;\r
-  EFI_STATUS Status;\r
-\r
-  //\r
-  // Determine the transfer direction\r
-  //\r
-  Direction = EfiUsbNoData;\r
-  if ( 0 != pRequest->Length ) {\r
-    Direction = ( 0 != ( pRequest->RequestType & USB_ENDPOINT_DIR_IN ))\r
-              ? EfiUsbDataIn : EfiUsbDataOut;\r
-  }\r
-\r
-  //\r
-  // Issue the command\r
-  //\r
-  pUsbIo = pNicDevice->pUsbIo;\r
-  Status = pUsbIo->UsbControlTransfer ( pUsbIo,\r
-                                        pRequest,\r
-                                        Direction,\r
-                                        USB_BUS_TIMEOUT,\r
-                                        pBuffer,\r
-                                        pRequest->Length,\r
-                                        &CmdStatus );\r
-  //\r
-  // Determine the operation status\r
-  //\r
-  if ( !EFI_ERROR ( Status )) {\r
-    Status = CmdStatus;\r
-  }\r
-  else {\r
-    //\r
-    // Only use status values associated with the Simple Network protocol\r
-    //\r
-    if ( EFI_TIMEOUT == Status ) {\r
-      Status = EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-  return Status;\r
-}\r
-\r