OptionRomPkg: Ax88772b: Fixing register access issue in Apple Eth Adapter

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>
This commit is contained in:
Shivamurthy Shastri 2016-03-30 17:14:14 +08:00 committed by Ruiyu Ni
parent 45e675f2d0
commit 7361d3ff88
3 changed files with 51 additions and 9 deletions

View File

@ -625,15 +625,18 @@ Ax88772Reset (
if (EFI_ERROR(Status)) goto err; if (EFI_ERROR(Status)) goto err;
SetupMsg.RequestType = USB_REQ_TYPE_VENDOR if (pNicDevice->Flags != FLAG_TYPE_AX88772) {
SetupMsg.RequestType = USB_REQ_TYPE_VENDOR
| USB_TARGET_DEVICE; | USB_TARGET_DEVICE;
SetupMsg.Request = CMD_RXQTC; SetupMsg.Request = CMD_RXQTC;
SetupMsg.Value = 0x8000; SetupMsg.Value = 0x8000;
SetupMsg.Index = 0x8001; SetupMsg.Index = 0x8001;
SetupMsg.Length = 0; SetupMsg.Length = 0;
Status = Ax88772UsbCommand ( pNicDevice, Status = Ax88772UsbCommand ( pNicDevice,
&SetupMsg, &SetupMsg,
NULL ); NULL );
}
err: err:
return Status; return Status;
} }

View File

@ -405,6 +405,8 @@ typedef struct {
UINTN PktCntInQueue; UINTN PktCntInQueue;
UINT8 * pBulkInBuff; UINT8 * pBulkInBuff;
INT32 Flags;
} NIC_DEVICE; } NIC_DEVICE;
#define DEV_FROM_SIMPLE_NETWORK(a) CR (a, NIC_DEVICE, SimpleNetwork, DEV_SIGNATURE) ///< Locate NIC_DEVICE from Simple Network Protocol #define DEV_FROM_SIMPLE_NETWORK(a) CR (a, NIC_DEVICE, SimpleNetwork, DEV_SIGNATURE) ///< Locate NIC_DEVICE from Simple Network Protocol

View File

@ -124,6 +124,8 @@ DriverStart (
UINTN LengthInBytes; UINTN LengthInBytes;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath = NULL; EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath = NULL;
MAC_ADDR_DEVICE_PATH MacDeviceNode; MAC_ADDR_DEVICE_PATH MacDeviceNode;
EFI_USB_DEVICE_DESCRIPTOR Device;
UINT32 Index;
// //
// Allocate the device structure // Allocate the device structure
@ -178,6 +180,41 @@ DriverStart (
goto EXIT; goto EXIT;
} }
Status = pNicDevice->pUsbIo->UsbGetDeviceDescriptor ( pNicDevice->pUsbIo, &Device );
if (EFI_ERROR ( Status )) {
gBS->CloseProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
pThis->DriverBindingHandle,
Controller
);
gBS->FreePool ( pNicDevice );
goto EXIT;
} else {
//
// Validate the adapter
//
for (Index = 0; ASIX_DONGLES[Index].VendorId != 0; Index++) {
if (ASIX_DONGLES[Index].VendorId == Device.IdVendor &&
ASIX_DONGLES[Index].ProductId == Device.IdProduct) {
break;
}
}
if (ASIX_DONGLES[Index].VendorId == 0) {
gBS->CloseProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
pThis->DriverBindingHandle,
Controller
);
gBS->FreePool ( pNicDevice );
goto EXIT;
}
pNicDevice->Flags = ASIX_DONGLES[Index].Flags;
}
// //
// Set Device Path // Set Device Path
// //