cbp will be count up, but only with low speed devices (except my usb
authorBernhard Urban <lewurm@gmx.net>
Sat, 19 Sep 2009 05:54:06 +0000 (07:54 +0200)
committerBernhard Urban <lewurm@gmx.net>
Sat, 19 Sep 2009 05:54:06 +0000 (07:54 +0200)
keyboard o_X)

usb/core/core.c
usb/core/usb.c
usb/host/ohci.c

index 87000fefa5c286e720336dc4e993e8597be9683f..27cfd93b2d9a40afc511a4ede62ad91f49876d70 100644 (file)
@@ -90,7 +90,7 @@ usb_device *usb_add_device()
 {
        usb_device *dev = (usb_device *) malloc(sizeof(usb_device));
        dev->address = 0;
 {
        usb_device *dev = (usb_device *) malloc(sizeof(usb_device));
        dev->address = 0;
-       dev->bMaxPacketSize0 = 8;                       /* send at first time only 8 bytes */
+       dev->bMaxPacketSize0 = 8;       /* send at first time only 8 bytes */
 
        dev->epSize[0] = 64;
        dev->epSize[1] = 64;
 
        dev->epSize[0] = 64;
        dev->epSize[1] = 64;
@@ -116,7 +116,7 @@ usb_device *usb_add_device()
         * wIndex = 0
         * wLength = 8 (in Bytes!?)
         */
         * wIndex = 0
         * wLength = 8 (in Bytes!?)
         */
-       usb_control_msg(dev, 0x80, GET_DESCRIPTOR, DEVICE, 0, 8, buf, 8, 0);
+       usb_control_msg(dev, 0x80, GET_DESCRIPTOR, DEVICE, 0, 64, buf, 8, 0);
 
        /* 
         * length (here =64) should be "number of byte to transfer", not 
 
        /* 
         * length (here =64) should be "number of byte to transfer", not 
@@ -283,18 +283,21 @@ u16 usb_submit_irp(usb_irp *irp)
                td = usb_create_transfer_descriptor(irp);
                td->pid = USB_PID_SETUP;
                td->buffer = irp->buffer;
                td = usb_create_transfer_descriptor(irp);
                td->pid = USB_PID_SETUP;
                td->buffer = irp->buffer;
-               td->actlen = 8;                                                 /* control message are always 8 bytes */
+               td->actlen = 64;                                                        /* control message are always 8 bytes */
                memcpy(mybuf, td->buffer, td->actlen);
 
                togl = 0;
                td->togl = togl;                                                /* start with data0 */
                memcpy(mybuf, td->buffer, td->actlen);
 
                togl = 0;
                td->togl = togl;                                                /* start with data0 */
+#if 0
                if (togl == 0)
                        togl = 1;
                else
                        togl = 0;
                if (togl == 0)
                        togl = 1;
                else
                        togl = 0;
+#endif
                        /**** send token ****/
                printf("togl: %d\n", togl);
                hcdi_enqueue(td);
                        /**** send token ****/
                printf("togl: %d\n", togl);
                hcdi_enqueue(td);
+               break;
 #if 0
                memcpy(td->buffer, mybuf, td->actlen);
 #endif
 #if 0
                memcpy(td->buffer, mybuf, td->actlen);
 #endif
index bfb37a6960ec7e89cd37619dacd2ac6b0ae9012e..1665abf131ff4b1ba75ea1f28f4be57fa9cecc07 100644 (file)
@@ -143,7 +143,7 @@ u8 usb_control_msg(usb_device *dev, u8 requesttype, u8 request, u16 value, u16 i
        irp->epsize = dev->bMaxPacketSize0;
        irp->type = USB_CTRL;
 
        irp->epsize = dev->bMaxPacketSize0;
        irp->type = USB_CTRL;
 
-#if 0
+#if 1
        buf[0]=(char)requesttype;
        buf[1]=(char)request;            
        buf[2]=(char)(value >> 8);
        buf[0]=(char)requesttype;
        buf[1]=(char)request;            
        buf[2]=(char)(value >> 8);
@@ -154,7 +154,7 @@ u8 usb_control_msg(usb_device *dev, u8 requesttype, u8 request, u16 value, u16 i
        buf[6]=(char)(length);
        buf[7]=(char)(length >> 8);
 #endif
        buf[6]=(char)(length);
        buf[7]=(char)(length >> 8);
 #endif
-#if 1
+#if 0
        //should be the right way around? :O
        buf[0]=(char)requesttype;
        buf[1]=(char)request;
        //should be the right way around? :O
        buf[0]=(char)requesttype;
        buf[1]=(char)request;
index bd3793c5a44d943a01f8213a204d93d5ff5e71c1..c0c13f9a7c1f7c63c0226204b70a7fe4798d2dfb 100644 (file)
@@ -177,7 +177,7 @@ static void dbg_td_flag(u32 flag)
  * Enqueue a transfer descriptor.
  */
 u8 hcdi_enqueue(usb_transfer_descriptor *td) {
  * Enqueue a transfer descriptor.
  */
 u8 hcdi_enqueue(usb_transfer_descriptor *td) {
-       control_quirk(); //required? YES! :O
+       control_quirk(); //required? YES! :O ... erm... or no? :/
        u32 tmptdbuffer;
 
        static struct endpoint_descriptor dummyconfig;
        u32 tmptdbuffer;
 
        static struct endpoint_descriptor dummyconfig;
@@ -212,7 +212,7 @@ u8 hcdi_enqueue(usb_transfer_descriptor *td) {
                        tmptd->flags |= ACCESS_LE(OHCI_TD_DIRECTION_PID_IN);
                        break;
        }
                        tmptd->flags |= ACCESS_LE(OHCI_TD_DIRECTION_PID_IN);
                        break;
        }
-       tmptd->flags |= ACCESS_LE((td->togl) ? OHCI_TD_TOGGLE_1 : OHCI_TD_TOGGLE_0);
+       tmptd->flags |= ACCESS_LE(((td->togl) ? OHCI_TD_TOGGLE_1 : OHCI_TD_TOGGLE_0) /*| OHCI_TD_BUFFER_ROUNDING*/);
        //tmptd->flags |= ACCESS_LE(OHCI_TD_TOGGLE_1);
 
        printf("tmptd hexdump (before) 0x%08X:\n", tmptd);
        //tmptd->flags |= ACCESS_LE(OHCI_TD_TOGGLE_1);
 
        printf("tmptd hexdump (before) 0x%08X:\n", tmptd);
@@ -276,20 +276,28 @@ u8 hcdi_enqueue(usb_transfer_descriptor *td) {
        sync_before_read(&hcca_oh0, 256);
        printf("done head (nach sync): 0x%08X\n", ACCESS_LE(hcca_oh0.done_head));
 
        sync_before_read(&hcca_oh0, 256);
        printf("done head (nach sync): 0x%08X\n", ACCESS_LE(hcca_oh0.done_head));
 
-       printf("td->buffer(1): 0x%08X\n", (void*)td->buffer);
        struct general_td* donetd = phys_to_virt(ACCESS_LE(hcca_oh0.done_head)&~1);
        sync_before_read(donetd, 16);
        printf("done head hexdump: 0x%08X\n", donetd);
        hexdump((void*) donetd, 16);
        struct general_td* donetd = phys_to_virt(ACCESS_LE(hcca_oh0.done_head)&~1);
        sync_before_read(donetd, 16);
        printf("done head hexdump: 0x%08X\n", donetd);
        hexdump((void*) donetd, 16);
-       printf("td->buffer(2): 0x%08X\n", (void*)td->buffer);
 
 
-       sync_before_read((void*) phys_to_virt(ACCESS_LE(tmptd->cbp)), td->actlen);
+       u32 newlen = 0;
+       if(td->actlen) {
+               sync_before_read((void*) tmptdbuffer, td->actlen);
+               newlen = (u32)phys_to_virt(ACCESS_LE(tmptd->cbp)) - tmptdbuffer;
+               printf("WOOOOT newlen: %d\n", newlen);
+               hexdump((void*) tmptdbuffer, newlen);
+       }
+
+       sync_before_read((void*) (phys_to_virt(ACCESS_LE(tmptd->cbp))-newlen), td->actlen);
        printf("td->buffer: 0x%08X\np2v(A_L(tmptd->cbp: 0x%08X\ntd->actlen: %d\n", (void*) (td->buffer), phys_to_virt(ACCESS_LE(tmptd->cbp)), td->actlen);
        printf("td->buffer: 0x%08X\np2v(A_L(tmptd->cbp: 0x%08X\ntd->actlen: %d\n", (void*) (td->buffer), phys_to_virt(ACCESS_LE(tmptd->cbp)), td->actlen);
-       (void) memcpy((void*) (td->buffer), phys_to_virt(ACCESS_LE(tmptd->cbp)), td->actlen);
+       (void) memcpy((void*) (td->buffer), phys_to_virt(ACCESS_LE(tmptd->cbp))-newlen, td->actlen);
 
        write32(OHCI0_HC_CONTROL, read32(OHCI0_HC_CONTROL)&~OHCI_CTRL_CLE);
        dummyconfig.headp = dummyconfig.tailp = dummyconfig.nexted = ACCESS_LE(0);
 
 
        write32(OHCI0_HC_CONTROL, read32(OHCI0_HC_CONTROL)&~OHCI_CTRL_CLE);
        dummyconfig.headp = dummyconfig.tailp = dummyconfig.nexted = ACCESS_LE(0);
 
+       write32(OHCI0_HC_CTRL_HEAD_ED, virt_to_phys(0));
+
 
        /* 
         * TD should be free'd after taking it from the done queue.
 
        /* 
         * TD should be free'd after taking it from the done queue.
@@ -297,9 +305,11 @@ u8 hcdi_enqueue(usb_transfer_descriptor *td) {
         */
 
        /* only when a buffer is allocated */
         */
 
        /* only when a buffer is allocated */
+#if 0
        if(td->actlen)
                free((void*)tmptdbuffer);
        free(tmptd);
        if(td->actlen)
                free((void*)tmptdbuffer);
        free(tmptd);
+#endif
        return 0;
 }
 
        return 0;
 }
 
@@ -408,7 +418,7 @@ 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);
 
        if((port & RH_PS_CCS) && ((port & RH_PS_CSC) || from_init)) {
                write32(reg, RH_PS_CSC);
 
-               wait_ms(150);
+               wait_ms(120);
 
                /* clear CSC flag, set PES and start port reset (PRS) */
                write32(reg, RH_PS_PES);
 
                /* clear CSC flag, set PES and start port reset (PRS) */
                write32(reg, RH_PS_PES);