adapted setup_port to old, clean state
[ppcskel.git] / usb / host / ohci.c
index 5a0d8a73ec12fb88ebeb3e9011c670a20409d86f..ce23376819570408e34841d74ce2d6e87bda0d52 100644 (file)
@@ -359,12 +359,15 @@ void hcdi_init()
        write32(OHCI0_HC_CONTROL, OHCI_CONTROL_INIT | OHCI_USB_OPER);
 
        /* wake on ConnectStatusChange, matching external hubs */
-       set32(OHCI0_HC_RH_STATUS, RH_HS_DRWE);
+       write32(OHCI0_HC_RH_STATUS, /*RH_HS_DRWE |*/ RH_HS_LPSC);
 
        /* Choose the interrupts we care about now, others later on demand */
        write32(OHCI0_HC_INT_STATUS, ~0);
        write32(OHCI0_HC_INT_ENABLE, OHCI_INTR_INIT);
 
+       //wtf?
+       wait_ms ((read32(OHCI0_HC_RH_DESCRIPTOR_A) >> 23) & 0x1fe);
+
        configure_ports((u8)1);
        irq_restore(cookie);
 
@@ -390,19 +393,19 @@ static void setup_port(u32 reg, u8 from_init)
        if((port & RH_PS_CCS) && ((port & RH_PS_CSC) || from_init)) {
                write32(reg, RH_PS_CSC);
 
-               wait_ms(100);
+               wait_ms(150);
 
                /* clear CSC flag, set PES and start port reset (PRS) */
                write32(reg, RH_PS_PES);
-               port = read32(reg);
+               while(!(read32(reg) & RH_PS_PES)) {
+                       printf("fu\n");
+                       return;
+               }
+
                write32(reg, RH_PS_PRS);
 
                /* spin until port reset is complete */
-               port = read32(reg);
-               while(!(port & RH_PS_PRSC)) {
-                       udelay(1);
-                       port = read32(reg);
-               }
+               while(!(read32(reg) & RH_PS_PRSC)); // hint: it may stuck here
                printf("loop done\n");
 
                (void) usb_add_device();