diff options
author | Shivamurthy Shastri <shivamurthy.shastri@linaro.org> | 2015-12-01 11:11:54 +0530 |
---|---|---|
committer | Shivamurthy Shastri <shivamurthy.shastri@linaro.org> | 2015-12-01 11:11:54 +0530 |
commit | 810dc2a7186253dbc2612a3e3c6669d84c328630 (patch) | |
tree | 8b37a585bc3b9b7b687b061f7eda110c84879229 | |
parent | 9310d76c6a445024d9fc2b655a97c8bccdfac181 (diff) |
Final Changeshikey
Signed-off-by: Shivamurthy Shastri <shivamurthy.shastri@linaro.org>
-rw-r--r-- | HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.c | 557 | ||||
-rw-r--r-- | HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.h | 75 | ||||
-rw-r--r-- | HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf | 15 | ||||
-rw-r--r-- | HisiPkg/HiKeyPkg/Drivers/PciEmulation/PciEmulation.c | 4 | ||||
-rw-r--r-- | HisiPkg/HiKeyPkg/HiKey.dsc | 1 | ||||
-rw-r--r-- | HisiPkg/HiKeyPkg/HiKey.fdf | 1 | ||||
-rw-r--r-- | OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h | 17 | ||||
-rw-r--r-- | OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c | 33 |
8 files changed, 235 insertions, 468 deletions
diff --git a/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.c b/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.c index 201975704..582e02d3b 100644 --- a/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.c +++ b/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.c @@ -16,19 +16,70 @@ #include "DwUsbHostDxe.h" #include "DwcHw.h" -EFI_DRIVER_BINDING_PROTOCOL -gDwUsbHostDriverBinding = { - DwUsbHostDriverBindingSupported, - DwUsbHostDriverBindingStart, - DwUsbHostDriverBindingStop, - 0x30, - NULL, - NULL +EFI_USB_PCIIO_DEVICE_PATH DwHcDevicePath = +{ + { + { ACPI_DEVICE_PATH, ACPI_DP, { sizeof (ACPI_HID_DEVICE_PATH), 0 } }, + EISA_PNP_ID(0x0A03), // HID + 0 // UID + }, + { + { HARDWARE_DEVICE_PATH, HW_PCI_DP, { sizeof (PCI_DEVICE_PATH), 0 } }, + 0, + 0 + }, + { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0} } }; VOID DwHcInit (IN DWUSB_OTGHC_DEV *DwHc); VOID DwCoreInit (IN DWUSB_OTGHC_DEV *DwHc); +VOID +ConfigureUsbPhy ( + VOID + ) +{ + UINT32 Data; + + /*Enable USB clock*/ + Data = MmioRead32 (0xF7030000 + 0x200); + Data |= 0x10; + MmioWrite32 (0xF7030000 + 0x200, 0x10); + + do { + Data = MmioRead32 (0xF7030000 + 0x208); + } while ((Data & 0x10) == 0); + + /*Take USB IPs out of reset*/ + MmioWrite32 (0xF7030000 + 0x304, 0xF0); + + do { + Data = MmioRead32 (0xF7030000 + 0x308); + Data &= 0xF0; + } while (Data); + + /*CTRL5*/ + Data = MmioRead32 (0xF7030000 + 0x010); + Data &= ~0x20; + Data |= 0x318; + MmioWrite32 (0xF7030000 + 0x010, Data); + + /*CTRL4*/ + /*Configure USB PHY*/ + Data = MmioRead32 (0xF7030000 + 0x00C); + + /*make PHY out of low power mode*/ + Data &= ~0x40; + Data &= ~0x100; + Data |= 0xC00; + Data &= ~0x200000; + MmioWrite32 (0xF7030000 + 0x00C, Data); + + MmioWrite32 (0xF7030000 + 0x018, 0x70533483); //EYE_PATTERN + + MicroSecondDelay (5000); +} + UINT32 Wait4Bit ( IN UINT32 Reg, @@ -75,7 +126,7 @@ Wait4Chhltd ( MicroSecondDelay (100); Hcint = MmioRead32 (DwHc->DwUsbBase + HCINT(DWC2_HC_CHANNEL)); if (Hcint & (DWC2_HCINT_NAK | DWC2_HCINT_FRMOVRUN)) { - DEBUG ((EFI_D_ERROR, "Wait4Chhltd: ERROR\n")); + DEBUG ((EFI_D_INFO, "Wait4Chhltd: ERROR\n")); return 1; } @@ -257,12 +308,24 @@ DwHcReset ( IN UINT16 Attributes ) { -// DWUSB_OTGHC_DEV *DwHc; + DWUSB_OTGHC_DEV *DwHc; + + DwHc = DWHC_FROM_THIS (This); - DEBUG ((EFI_D_ERROR, "Reset:0x%x\n",Attributes)); + ConfigureUsbPhy (); + DwCoreInit(DwHc); + DwHcInit(DwHc); -// DwHc = DWHC_FROM_THIS (This); -// DwCoreReset (DwHc); + MmioAndThenOr32 (DwHc->DwUsbBase + HPRT0, + ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET | + DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG), + DWC2_HPRT0_PRTRST); + + MicroSecondDelay (50000); + + MmioAnd32 (DwHc->DwUsbBase + HPRT0, ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET | + DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG | + DWC2_HPRT0_PRTRST)); return EFI_SUCCESS; } @@ -274,7 +337,12 @@ DwHcGetState ( OUT EFI_USB_HC_STATE *State ) { - DEBUG ((EFI_D_ERROR, "Get State\n")); + DWUSB_OTGHC_DEV *DwHc; + + DwHc = DWHC_FROM_THIS (This); + + *State = DwHc->DwHcState; + return EFI_SUCCESS; } @@ -285,9 +353,11 @@ DwHcSetState ( IN EFI_USB_HC_STATE State ) { - DEBUG ((EFI_D_ERROR, "Set State\n")); + DWUSB_OTGHC_DEV *DwHc; + + DwHc = DWHC_FROM_THIS (This); - DEBUG ((EFI_D_ERROR, "SetState: %d\n", State)); + DwHc->DwHcState = State; return EFI_SUCCESS; } @@ -366,7 +436,6 @@ DwHcSetRootHubPortFeature ( { DWUSB_OTGHC_DEV *DwHc; UINT32 Hprt0; - UINT32 PcgCtl; EFI_STATUS Status = EFI_SUCCESS; if (PortNumber > DWC2_HC_CHANNEL) { @@ -385,11 +454,6 @@ DwHcSetRootHubPortFeature ( DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG); Hprt0 |= DWC2_HPRT0_PRTSUSP; MmioWrite32 (DwHc->DwUsbBase + HPRT0, Hprt0); - - PcgCtl = MmioRead32 (DwHc->DwUsbBase + PCGCCTL); - PcgCtl |= DWC2_PCGCCTL_STOPPCLK; - MmioWrite32 (DwHc->DwUsbBase + PCGCCTL, PcgCtl); - MicroSecondDelay (10); break; case EfiUsbPortReset: MmioAndThenOr32 (DwHc->DwUsbBase + HPRT0, @@ -650,17 +714,12 @@ DwHcBulkTransfer ( Status = EFI_DEVICE_ERROR; TransferDirection = (EndPointAddress >> 7) & 0x01; EpAddress = EndPointAddress & 0x0F; - Pid = BulkDataToggle[DeviceAddress][EpAddress]; + Pid = (*DataToggle << 1); Status = DwHcTransfer (DwHc, DeviceAddress, MaximumPacketLength, &Pid, TransferDirection, Data[0], DataLength, EpAddress, DWC2_HCCHAR_EPTYPE_BULK, TransferResult, 1); - BulkDataToggle[DeviceAddress][EpAddress] = Pid; - - if (Pid == 2) - *DataToggle = (Pid >> 1); - else - *DataToggle = Pid; + *DataToggle = (Pid >> 1); return Status; } @@ -720,12 +779,14 @@ DwHcAsyncInterruptTransfer ( TransferResult = EFI_USB_NOERROR; EpAddress = EndPointAddress & 0x0F; TransferDirection = (EndPointAddress >> 7) & 0x01; - Pid = BulkDataToggle[DeviceAddress][EpAddress]; + Pid = (*DataToggle << 1); Status = DwHcTransfer (DwHc, DeviceAddress, MaximumPacketLength, &Pid, TransferDirection, Data, &DataLength, EpAddress, DWC2_HCCHAR_EPTYPE_INTR, &TransferResult, 1); + *DataToggle = (Pid >> 1); + if (CallBackFunction != NULL) CallBackFunction (Data, DataLength, Context, TransferResult); @@ -909,13 +970,6 @@ DwCoreInit ( UINT32 AhbCfg = 0; UINT32 UsbCfg = 0; -// UsbCfg |= DWC2_GUSBCFG_FORCEHOSTMODE; -// UsbCfg &= ~DWC2_GUSBCFG_FORCEDEVMODE; - -// MmioWrite32 (DwHc->DwUsbBase + GUSBCFG, UsbCfg); - -// MicroSecondDelay (200000); - UsbCfg = MmioRead32 (DwHc->DwUsbBase + GUSBCFG); UsbCfg |= DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV; @@ -947,14 +1001,11 @@ DwCoreInit ( DWUSB_OTGHC_DEV * CreateDwUsbHc ( - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN UINT64 OriginalPciAttributes + VOID ) { DWUSB_OTGHC_DEV *DwHc; UINT32 Pages; - PCI_TYPE00 Pci; DwHc = AllocateZeroPool (sizeof(DWUSB_OTGHC_DEV)); @@ -978,10 +1029,9 @@ CreateDwUsbHc ( DwHc->DwUsbOtgHc.ClearRootHubPortFeature = DwHcClearRootHubPortFeature; DwHc->DwUsbOtgHc.MajorRevision = 0x02; DwHc->DwUsbOtgHc.MinorRevision = 0x00; + DwHc->DwUsbBase = FixedPcdGet32 (PcdDwUsbBaseAddress); - DwHc->PciIo = PciIo; - DwHc->DevicePath = DevicePath; - DwHc->OriginalPciAttributes = OriginalPciAttributes; + CopyMem (&DwHc->DevicePath, &DwHcDevicePath, sizeof(DwHcDevicePath)); Pages = EFI_SIZE_TO_PAGES (DWC2_STATUS_BUF_SIZE); DwHc->StatusBuffer = UncachedAllocatePages (Pages); @@ -997,16 +1047,6 @@ CreateDwUsbHc ( return NULL; } - PciIo->Pci.Read ( - PciIo, - EfiPciIoWidthUint8, - 0, - sizeof (PCI_TYPE00), - &Pci - ); - - DwHc->DwUsbBase = Pci.Device.Bar[0]; - return DwHc; } @@ -1017,368 +1057,135 @@ DwUsbHcExitBootService ( VOID *Context ) { - //DWUSB_OTGHC_DEV *DwHc; - - //DwHc = (DWUSB_OTGHC_DEV *) Context; - - //Reset the controller -} - -/** -Driver Binding Protocol APIs -**/ + DWUSB_OTGHC_DEV *DwHc; -EFI_STATUS -EFIAPI -DwUsbHostDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - UINT32 Snpsid; - PCI_TYPE00 Pci; - - Status = gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - (VOID **) &PciIo, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } + DwHc = (DWUSB_OTGHC_DEV *) Context; - Status = PciIo->Pci.Read ( - PciIo, - EfiPciIoWidthUint8, - 0, - sizeof (PCI_TYPE00), - &Pci - ); + MmioAndThenOr32 (DwHc->DwUsbBase + HPRT0, + ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET | + DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG), + DWC2_HPRT0_PRTRST); - if (EFI_ERROR (Status)) { - Status = EFI_UNSUPPORTED; - goto End; - } - - //check vendor id device id class + MicroSecondDelay (50000); - if (Pci.Device.Bar[0] == 0xF72C0000) { - Snpsid = MmioRead32 (Pci.Device.Bar[0] + GSNPSID); - } + DwCoreReset (DwHc); +} - if ((Snpsid & DWC2_SNPSID_DEVID_MASK) != DWC2_SNPSID_DEVID_VER_3xx) { - DEBUG ((EFI_D_ERROR, "DwUsbHostDriverBindingSupported: Not DWC2 OTG Host Controller\n")); - Status = EFI_UNSUPPORTED; - } +/** + UEFI Driver Entry Point API -End: - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); + @param ImageHandle EFI_HANDLE. + @param SystemTable EFI_SYSTEM_TABLE. - return Status; -} + @return EFI_SUCCESS Success. + EFI_DEVICE_ERROR Fail. +**/ EFI_STATUS EFIAPI -DwUsbHostDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath +DwUsbHostEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; - DWUSB_OTGHC_DEV *DwHc; - EFI_PCI_IO_PROTOCOL *PciIo; - EFI_DEVICE_PATH_PROTOCOL *DwHcDevPath; - UINT64 Supports; - UINT64 OriginalPciAttributes; - BOOLEAN PciAttributesSaved; - UINT32 i, j; - - Status = gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - (VOID **) &PciIo, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - DwHcDevPath = NULL; - Status = gBS->OpenProtocol ( - Controller, - &gEfiDevicePathProtocolGuid, - (VOID **) &DwHcDevPath, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - - if (EFI_ERROR (Status)) { - goto CLOSE_PCIIO_PROTOCOL; - } - - PciAttributesSaved = FALSE; - - Status = PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationGet, - 0, - &OriginalPciAttributes - ); - - if (EFI_ERROR (Status)) { - goto CLOSE_DEVPATH_PROTOCOL; - } + EFI_STATUS Status; + DWUSB_OTGHC_DEV *DwHc; + UINT32 Pages; - PciAttributesSaved = TRUE; + Status = EFI_SUCCESS; - Status = PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationSupported, - 0, - &Supports - ); + DwHc = CreateDwUsbHc (); - if (EFI_ERROR(Status)) { - goto CLOSE_DEVPATH_PROTOCOL; - } + if (DwHc == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto EXIT; + } - Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE; - Status = PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationEnable, - Supports, + Status = gBS->InstallMultipleProtocolInterfaces ( + &DwHc->DeviceHandle, + &gEfiUsb2HcProtocolGuid, &DwHc->DwUsbOtgHc, + &gEfiDevicePathProtocolGuid, &DwHc->DevicePath, NULL - ); - - if (EFI_ERROR(Status)) { - goto RESTORE_PCI_ATTR; - } - - DwHc = CreateDwUsbHc (PciIo, DwHcDevPath, OriginalPciAttributes); - - if (DwHc == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto RESTORE_PCI_ATTR; - } - - Status = gBS->InstallProtocolInterface ( - &Controller, - &gEfiUsb2HcProtocolGuid, - EFI_NATIVE_INTERFACE, - &DwHc->DwUsbOtgHc - ); - - if (EFI_ERROR (Status)) { - goto FREE_DWHC; - } - - DwCoreInit(DwHc); - DwHcInit(DwHc); - - MmioAndThenOr32 (DwHc->DwUsbBase + HPRT0, - ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET | - DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG), - DWC2_HPRT0_PRTRST); - - MicroSecondDelay (50000); + ); - MmioAnd32 (DwHc->DwUsbBase + HPRT0, ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET | - DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG | - DWC2_HPRT0_PRTRST)); - - for (i=0; i<MAX_DEVICE; i++) { - for (j=0; j<MAX_ENDPOINT; j++) { - ControlDataToggle[i][j] = DWC2_HC_PID_DATA1; - BulkDataToggle[i][j] = DWC2_HC_PID_DATA0; - } - } - - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - DwUsbHcExitBootService, - DwHc, - &gEfiEventExitBootServicesGuid, - &DwHc->ExitBootServiceEvent - ); - - if (EFI_ERROR (Status)) { - goto UNINSTALL_USB2HC_PROTOCOL; - } - - AddUnicodeString2 ( - "eng", - gDwUsbHostComponentName.SupportedLanguages, - &DwHc->ControllerNameTable, - L"DW OTG Host Controller (USB 2.0)", - TRUE - ); - - AddUnicodeString2 ( - "en", - gDwUsbHostComponentName2.SupportedLanguages, - &DwHc->ControllerNameTable, - L"DW OTG Host Controller (USB 2.0)", - FALSE - ); + if (EFI_ERROR (Status)) { + goto FREE_DWUSBHC; + } - return EFI_SUCCESS; + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + DwUsbHcExitBootService, + DwHc, + &gEfiEventExitBootServicesGuid, + &DwHc->ExitBootServiceEvent + ); + + if (EFI_ERROR (Status)) { + goto UNINSTALL_PROTOCOL; + } -UNINSTALL_USB2HC_PROTOCOL: - MmioAndThenOr32 (DwHc->DwUsbBase + HPRT0, ~(DWC2_HPRT0_PRTENA | - DWC2_HPRT0_PRTCONNDET | DWC2_HPRT0_PRTENCHNG | - DWC2_HPRT0_PRTOVRCURRCHNG), - DWC2_HPRT0_PRTRST); + return Status; - gBS->UninstallProtocolInterface ( - Controller, - &gEfiUsb2HcProtocolGuid, - &DwHc->DwUsbOtgHc +UNINSTALL_PROTOCOL: + gBS->UninstallMultipleProtocolInterfaces ( + &DwHc->DeviceHandle, + &gEfiUsb2HcProtocolGuid, &DwHc->DwUsbOtgHc, + &gEfiDevicePathProtocolGuid, &DwHc->DevicePath, + NULL ); -FREE_DWHC: +FREE_DWUSBHC: + Pages = EFI_SIZE_TO_PAGES (DWC2_STATUS_BUF_SIZE); + UncachedFreePages (DwHc->StatusBuffer, Pages); + Pages = EFI_SIZE_TO_PAGES (DWC2_DATA_BUF_SIZE); + UncachedFreePages (DwHc->AlignedBuffer, Pages); gBS->FreePool (DwHc); -RESTORE_PCI_ATTR: - if (PciAttributesSaved) { - PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationSet, - OriginalPciAttributes, - NULL - ); - } -CLOSE_DEVPATH_PROTOCOL: - gBS->CloseProtocol ( - Controller, - &gEfiDevicePathProtocolGuid, - This->DriverBindingHandle, - Controller - ); -CLOSE_PCIIO_PROTOCOL: - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); - +EXIT: return Status; } EFI_STATUS EFIAPI -DwUsbHostDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer +DwUsbHostExitPoint ( + IN EFI_HANDLE ImageHandle ) { - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - EFI_USB2_HC_PROTOCOL *DwUsbHc; - DWUSB_OTGHC_DEV *DwHc; - - Status = gBS->OpenProtocol ( - Controller, - &gEfiUsb2HcProtocolGuid, - (VOID **) &DwUsbHc, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - - if (EFI_ERROR (Status)) { - return Status; - } + EFI_STATUS Status; + EFI_USB2_HC_PROTOCOL *DwUsbHc; + DWUSB_OTGHC_DEV *DwHc; + UINT32 Pages; - DwHc = DWHC_FROM_THIS(DwUsbHc); - PciIo = DwHc->PciIo; + Status = EFI_SUCCESS; - Status = gBS->UninstallProtocolInterface ( - Controller, - &gEfiUsb2HcProtocolGuid, - DwHc - ); + Status = gBS->LocateProtocol (&gEfiUsb2HcProtocolGuid, NULL, (VOID **) &DwUsbHc); - if (EFI_ERROR (Status)) { - return Status; - } + if (EFI_ERROR (Status)) { + return Status; + } - MmioAndThenOr32 (DwHc->DwUsbBase + HPRT0, ~(DWC2_HPRT0_PRTENA | - DWC2_HPRT0_PRTCONNDET | DWC2_HPRT0_PRTENCHNG | - DWC2_HPRT0_PRTOVRCURRCHNG), - DWC2_HPRT0_PRTRST); + DwHc = DWHC_FROM_THIS(DwUsbHc); if (DwHc->ExitBootServiceEvent != NULL) { gBS->CloseEvent (DwHc->ExitBootServiceEvent); } - if (DwHc->ControllerNameTable != NULL) { - FreeUnicodeStringTable (DwHc->ControllerNameTable); - } - - PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationSet, - DwHc->OriginalPciAttributes, - NULL - ); - - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); - - FreePool(DwHc); - - return EFI_SUCCESS; -} - -/** - UEFI Driver Entry Point API - - @param ImageHandle EFI_HANDLE. - @param SystemTable EFI_SYSTEM_TABLE. - - @return EFI_SUCCESS Success. - EFI_DEVICE_ERROR Fail. -**/ + gBS->UninstallMultipleProtocolInterfaces ( + &DwHc->DeviceHandle, + &gEfiUsb2HcProtocolGuid, &DwHc->DwUsbOtgHc, + &gEfiDevicePathProtocolGuid, &DwHc->DevicePath, + NULL + ); -EFI_STATUS -EFIAPI -DwUsbHostEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ + if (EFI_ERROR (Status)) { + return Status; + } - return EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gDwUsbHostDriverBinding, - ImageHandle, - &gDwUsbHostComponentName, - &gDwUsbHostComponentName2 - ); + Pages = EFI_SIZE_TO_PAGES (DWC2_STATUS_BUF_SIZE); + UncachedFreePages (DwHc->StatusBuffer, Pages); + Pages = EFI_SIZE_TO_PAGES (DWC2_DATA_BUF_SIZE); + UncachedFreePages (DwHc->AlignedBuffer, Pages); + FreePool (DwHc); + return Status; } diff --git a/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.h b/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.h index 27328b5e3..6c5d5e900 100644 --- a/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.h +++ b/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.h @@ -4,8 +4,6 @@ #include <Uefi.h> #include <Protocol/Usb2HostController.h> -#include <Protocol/PciIo.h> -//#include <Protocol/EmbeddedGpio.h> #include <Guid/EventGroup.h> @@ -24,43 +22,14 @@ #include <Library/IoLib.h> #include <Library/TimerLib.h> -#include <IndustryStandard/Pci.h> - -#include "ComponentName.h" - #define MAX_DEVICE 16 #define MAX_ENDPOINT 16 -UINT32 RhDevNum; - -UINT32 BulkDataToggle[MAX_DEVICE][MAX_ENDPOINT]; -UINT32 ControlDataToggle[MAX_DEVICE][MAX_ENDPOINT]; - typedef struct _DWUSB_OTGHC_DEV DWUSB_OTGHC_DEV; -typedef struct _USB_DEV_CONTEXT USB_DEV_CONTEXT; - -extern EFI_DRIVER_BINDING_PROTOCOL gDwUsbHostDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gDwUsbHostComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gDwUsbHostComponentName2; #define DWUSB_OTGHC_DEV_SIGNATURE SIGNATURE_32 ('d', 'w', 'h', 'c') #define DWHC_FROM_THIS(a) CR(a, DWUSB_OTGHC_DEV, DwUsbOtgHc, DWUSB_OTGHC_DEV_SIGNATURE) -#define min(x, y) ({ \ - typeof(x) _min1 = (x); \ - typeof(y) _min2 = (y); \ - (void) (&_min1 == &_min2); \ - _min1 < _min2 ? _min1 : _min2; }) - -#define max(x, y) ({ \ - typeof(x) _max1 = (x); \ - typeof(y) _max2 = (y); \ - (void) (&_max1 == &_max2); \ - _max1 > _max2 ? _max1 : _max2; }) - -#define min3(x, y, z) min((typeof(x))min(x, y), z) -#define max3(x, y, z) max((typeof(x))max(x, y), z) - // // The RequestType in EFI_USB_DEVICE_REQUEST is composed of // three fields: One bit direction, 2 bit type, and 5 bit @@ -69,23 +38,24 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gDwUsbHostComponentName2; #define USB_REQUEST_TYPE(Dir, Type, Target) \ ((UINT8)((((Dir) == EfiUsbDataIn ? 0x01 : 0) << 7) | (Type) | (Target))) -struct _USB_DEV_CONTEXT { - EFI_USB_DEVICE_DESCRIPTOR DevDesc; - EFI_USB_CONFIG_DESCRIPTOR **ConfDesc; -}; +typedef struct { + ACPI_HID_DEVICE_PATH AcpiDevicePath; + PCI_DEVICE_PATH PciDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} EFI_USB_PCIIO_DEVICE_PATH; struct _DWUSB_OTGHC_DEV { UINTN Signature; + EFI_HANDLE DeviceHandle; + EFI_USB2_HC_PROTOCOL DwUsbOtgHc; - EFI_PCI_IO_PROTOCOL *PciIo; + EFI_USB_HC_STATE DwHcState; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_USB_PCIIO_DEVICE_PATH DevicePath; - EFI_UNICODE_STRING_TABLE *ControllerNameTable; EFI_EVENT ExitBootServiceEvent; - UINT64 OriginalPciAttributes; UINT64 DwUsbBase; UINT8 *StatusBuffer; UINT8 *AlignedBuffer; @@ -94,33 +64,6 @@ struct _DWUSB_OTGHC_DEV { UINT16 PortChangeStatus; UINT32 RhDevNum; - - USB_DEV_CONTEXT UsbDevContext[256]; }; -EFI_STATUS -EFIAPI -DwUsbHostDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - -EFI_STATUS -EFIAPI -DwUsbHostDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - -EFI_STATUS -EFIAPI -DwUsbHostDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ); - #endif //_DWUSBHOSTDXE_H_ diff --git a/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf b/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf index 3141c8eb9..83b2913d8 100644 --- a/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf +++ b/HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf @@ -19,11 +19,17 @@ MODULE_TYPE = UEFI_DRIVER VERSION_STRING = 1.0 ENTRY_POINT = DwUsbHostEntryPoint + UNLOAD_IMAGE = DwUsbHostExitPoint [Sources.common] - ComponentName.c DwUsbHostDxe.c +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + [LibraryClasses] MemoryAllocationLib UncachedMemoryAllocationLib @@ -43,13 +49,6 @@ [Protocols] gEfiDriverBindingProtocolGuid gEfiUsb2HcProtocolGuid - gEfiPciIoProtocolGuid - -[Packages] - ArmPkg/ArmPkg.dec - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - EmbeddedPkg/EmbeddedPkg.dec [Pcd] gEmbeddedTokenSpaceGuid.PcdDwUsbBaseAddress diff --git a/HisiPkg/HiKeyPkg/Drivers/PciEmulation/PciEmulation.c b/HisiPkg/HiKeyPkg/Drivers/PciEmulation/PciEmulation.c index 2cd02a2aa..6818ef064 100644 --- a/HisiPkg/HiKeyPkg/Drivers/PciEmulation/PciEmulation.c +++ b/HisiPkg/HiKeyPkg/Drivers/PciEmulation/PciEmulation.c @@ -51,6 +51,7 @@ EFI_PCI_IO_DEVICE_PATH PciIoDevicePathTemplate = { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0} }
};
+#if 0
STATIC
VOID
ConfigureUSBHost (
@@ -96,6 +97,7 @@ ConfigureUSBHost ( MicroSecondDelay (5000);
}
+#endif
EFI_STATUS
PciIoPollMem (
@@ -557,7 +559,7 @@ PciEmulationEntryPoint ( //UINTN Count;
//Configure USB host
- ConfigureUSBHost();
+ //ConfigureUSBHost();
// Create a private structure
Private = AllocatePool(sizeof(EFI_PCI_IO_PRIVATE_DATA));
diff --git a/HisiPkg/HiKeyPkg/HiKey.dsc b/HisiPkg/HiKeyPkg/HiKey.dsc index aea52c259..d8eafa116 100644 --- a/HisiPkg/HiKeyPkg/HiKey.dsc +++ b/HisiPkg/HiKeyPkg/HiKey.dsc @@ -428,7 +428,6 @@ # # USB Host Support # - HisiPkg/HiKeyPkg/Drivers/PciEmulation/PciEmulation.inf HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf diff --git a/HisiPkg/HiKeyPkg/HiKey.fdf b/HisiPkg/HiKeyPkg/HiKey.fdf index b85338b2c..65e9ea2a2 100644 --- a/HisiPkg/HiKeyPkg/HiKey.fdf +++ b/HisiPkg/HiKeyPkg/HiKey.fdf @@ -135,7 +135,6 @@ READ_LOCK_STATUS = TRUE # # USB Host Support # - INF HisiPkg/HiKeyPkg/Drivers/PciEmulation/PciEmulation.inf INF HisiPkg/HiKeyPkg/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h index 420a6a7e2..e2df6deac 100644 --- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h +++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/Ax88772.h @@ -142,8 +142,8 @@ #define DEV_SIGNATURE SIGNATURE_32 ('A','X','8','8') ///< Signature of data structures in memory
-#define VENDOR_ID 0x05AC ///< Vendor ID for Asix
-#define PRODUCT_ID 0x1402 ///< Product ID for the AX88772 USB 10/100 Ethernet controller
+#define VENDOR_ID 0x0B95 ///< Vendor ID for Asix
+#define PRODUCT_ID 0x772B ///< Product ID for the AX88772 USB 10/100 Ethernet controller
#define RESET_MSEC 1000 ///< Reset duration
#define PHY_RESET_MSEC 500 ///< PHY reset duration
@@ -298,12 +298,23 @@ #define AN_10_HDX 0x0020 ///< 1 = 10BASE-T support
#define AN_CSMA_CD 0x0001 ///< 1 = IEEE 802.3 CSMA/CD support
-
+/* asix_flags defines */
+#define FLAG_NONE 0
+#define FLAG_TYPE_AX88172 (1U << 0)
+#define FLAG_TYPE_AX88772 (1U << 1)
+#define FLAG_TYPE_AX88772B (1U << 2)
+#define FLAG_EEPROM_MAC (1U << 3) /* initial mac address in eeprom */
//------------------------------------------------------------------------------
// Data Types
//------------------------------------------------------------------------------
+struct ASIX_DONGLE {
+ UINT16 VendorId;
+ UINT16 ProductId;
+ INT32 Flags;
+};
+
/**
Ethernet header layout
diff --git a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c index 3b7304047..90366cf4f 100644 --- a/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c +++ b/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c @@ -14,6 +14,13 @@ #include "Ax88772.h"
+struct ASIX_DONGLE ASIX_DONGLES[] = {
+ { 0x05AC, 0x1402, FLAG_TYPE_AX88772 }, /* Apple USB Ethernet Adapter */
+ /* ASIX 88772B */
+ { 0x0B95, 0x772B, FLAG_TYPE_AX88772B | FLAG_EEPROM_MAC },
+ { 0x0000, 0x0000, FLAG_NONE } /* END - Do not remove */
+};
+
/**
Verify the controller type
@@ -36,6 +43,8 @@ DriverSupported ( EFI_USB_DEVICE_DESCRIPTOR Device;
EFI_USB_IO_PROTOCOL * pUsbIo;
EFI_STATUS Status;
+ UINT32 i;
+
//
// Connect to the USB stack
//
@@ -60,19 +69,17 @@ DriverSupported ( else {
//
// Validate the adapter
- //
- if ( VENDOR_ID == Device.IdVendor ) {
-
- if (PRODUCT_ID == Device.IdProduct) {
- DEBUG ((EFI_D_INFO, "Found the AX88772B\r\n"));
- }
- else {
- Status = EFI_UNSUPPORTED;
- }
- }
- else {
- Status = EFI_UNSUPPORTED;
- }
+ //
+ for (i = 0; ASIX_DONGLES[i].VendorId != 0; i++) {
+ if (ASIX_DONGLES[i].VendorId == Device.IdVendor &&
+ ASIX_DONGLES[i].ProductId == Device.IdProduct) {
+ DEBUG ((EFI_D_INFO, "Found the AX88772B\r\n"));
+ break;
+ }
+ }
+
+ if (ASIX_DONGLES[i].VendorId == 0)
+ Status = EFI_UNSUPPORTED;
}
//
|