X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FBus%2FUsb%2FUsbBusDxe%2FUsbEnumer.c;h=65eb2dd77ffa547a57f3381e3ab15083f6b5e843;hp=b92e9e072e4c17e670af8434e4b685e2ba319f09;hb=41e8ff2781f3ca14f73ef5f39e781ccba8cb373d;hpb=ba5711102a63d081cb388289983a0e2734e42fb5 diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c index b92e9e072e..65eb2dd77f 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c @@ -656,13 +656,9 @@ UsbEnumerateNewDev ( Parent = HubIf->Device; Bus = Parent->Bus; HubApi = HubIf->HubApi; - - - // - // Wait at least 100 ms for the power on port to stable - // - gBS->Stall (100 * USB_STALL_1_MS); - + + gBS->Stall (USB_WAIT_PORT_STABLE_STALL); + // // Hub resets the device for at least 10 milliseconds. // Host learns device speed. If device is of low/full speed @@ -774,11 +770,8 @@ UsbEnumerateNewDev ( DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to set device address - %r\n", Status)); goto ON_ERROR; } - - // - // Wait 20ms for set address to complete - // - gBS->Stall (20 * USB_STALL_1_MS); + + gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL); DEBUG ((EFI_D_INFO, "UsbEnumerateNewDev: device is now ADDRESSED at %d\n", Address)); @@ -886,47 +879,44 @@ UsbEnumeratePort ( if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_OVERCURRENT)) { // - // Both OverCurrent and OverCurrentChange set, means over current occurs, - // which probably is caused by short circuit. It has to wait system hardware - // to perform recovery. + // Case1: + // Both OverCurrent and OverCurrentChange set, means over current occurs, + // which probably is caused by short circuit. It has to wait system hardware + // to perform recovery. // DEBUG (( EFI_D_ERROR, "UsbEnumeratePort: Critical Over Current\n", Port)); return EFI_DEVICE_ERROR; - } else { - // - // Only OverCurrentChange set, means system has been recoveried from - // over current. As a result, all ports are nearly power-off, so - // it's necessary to detach and enumerate all ports again. - // - DEBUG (( EFI_D_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port)); - goto ON_ENUMERATE; - - } + } + // + // Case2: + // Only OverCurrentChange set, means system has been recoveried from + // over current. As a result, all ports are nearly power-off, so + // it's necessary to detach and enumerate all ports again. + // + DEBUG (( EFI_D_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port)); } if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_ENABLE)) { // - // 1.1 roothub port reg doesn't reflect over-current state, while its counterpart - // on 2.0 roothub does. When over-current has influence on 1.1 device, the port - // would be disabled, so it's also necessary to detach and enumerate again. + // Case3: + // 1.1 roothub port reg doesn't reflect over-current state, while its counterpart + // on 2.0 roothub does. When over-current has influence on 1.1 device, the port + // would be disabled, so it's also necessary to detach and enumerate again. // DEBUG (( EFI_D_ERROR, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port)); - goto ON_ENUMERATE; } if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_CONNECTION)) { // - // Device connected or disconnected normally. + // Case4: + // Device connected or disconnected normally. // - goto ON_ENUMERATE; + DEBUG ((EFI_D_ERROR, "UsbEnumeratePort: Device Connect/Discount Normally\n", Port)); } -ON_ENUMERATE: - // - // In case there is already a device on this port logically, it's safety to remove - // and enumerate again. + // Following as the above cases, it's safety to remove and create again. // Child = UsbFindChild (HubIf, Port);