]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OptionRomPkg: Ax88772b: Fixing register access issue in Apple Eth Adapter
authorShivamurthy Shastri <shivamurthy.shastri@linaro.org>
Wed, 30 Mar 2016 09:14:14 +0000 (17:14 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 31 Mar 2016 00:53:51 +0000 (08:53 +0800)
The USB command CMD_RXQTC ("RX Queue Cascade Threshold Control") tries
to access the register and is always failing when using the Apple
Ethernet adapter.

It is fixed by checking flag before sending command.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Shivamurthy Shastri <shivamurthy.shastri@linaro.org>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.c
OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h
OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c

index 45ba3e52ff8a78854f521f30824b59795b957c55..e014d52ac0f3a33021f843ecc8ffcf1253082bb3 100644 (file)
@@ -625,15 +625,18 @@ Ax88772Reset (
                                   \r
   if (EFI_ERROR(Status)) goto err;  \r
 \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
+  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
+                                  NULL );\r
+  }\r
+\r
 err:\r
   return Status;\r
 }\r
index a2109cf67397864a7c80207eb8458d61b4f15eb8..92ac64d1b31be373dc5578ab67878f2702ecca9c 100644 (file)
@@ -404,7 +404,9 @@ typedef struct {
   RX_PKT * pFirstFill;\r
   UINTN   PktCntInQueue;\r
   UINT8 * pBulkInBuff;\r
\r
+\r
+  INT32 Flags;\r
+\r
 } NIC_DEVICE;\r
 \r
 #define DEV_FROM_SIMPLE_NETWORK(a)  CR (a, NIC_DEVICE, SimpleNetwork, DEV_SIGNATURE)  ///< Locate NIC_DEVICE from Simple Network Protocol\r
index d64bc739c1aea53f4078dbc26e5c2ef6178546de..bf05c742176c7a48e6fecd7c2d8be0c5d7eddf52 100644 (file)
@@ -124,6 +124,8 @@ DriverStart (
        UINTN                                                   LengthInBytes;\r
        EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath = NULL;\r
        MAC_ADDR_DEVICE_PATH            MacDeviceNode;\r
+        EFI_USB_DEVICE_DESCRIPTOR       Device;\r
+        UINT32                          Index;\r
 \r
   //\r
        //  Allocate the device structure\r
@@ -178,6 +180,41 @@ DriverStart (
                  goto EXIT;\r
   }\r
 \r
+  Status = pNicDevice->pUsbIo->UsbGetDeviceDescriptor ( pNicDevice->pUsbIo, &Device );\r
+  if (EFI_ERROR ( Status )) {\r
+     gBS->CloseProtocol (\r
+               Controller,\r
+               &gEfiUsbIoProtocolGuid,\r
+               pThis->DriverBindingHandle,\r
+               Controller\r
+               );\r
+     gBS->FreePool ( pNicDevice );\r
+              goto EXIT;\r
+  } else {\r
+      //\r
+      //  Validate the adapter\r
+      //\r
+      for (Index = 0; ASIX_DONGLES[Index].VendorId != 0; Index++) {\r
+          if (ASIX_DONGLES[Index].VendorId == Device.IdVendor &&\r
+              ASIX_DONGLES[Index].ProductId == Device.IdProduct) {\r
+                break;\r
+          }\r
+      }\r
+\r
+      if (ASIX_DONGLES[Index].VendorId == 0) {\r
+         gBS->CloseProtocol (\r
+                   Controller,\r
+                   &gEfiUsbIoProtocolGuid,\r
+                   pThis->DriverBindingHandle,\r
+                   Controller\r
+                   );\r
+          gBS->FreePool ( pNicDevice );\r
+                   goto EXIT;\r
+      }\r
+\r
+      pNicDevice->Flags = ASIX_DONGLES[Index].Flags;\r
+  }\r
+\r
        //\r
   // Set Device Path\r
   //                   \r