From: Bernhard Urban Date: Sat, 19 Sep 2009 05:54:06 +0000 (+0200) Subject: cbp will be count up, but only with low speed devices (except my usb X-Git-Tag: firstresponse~8 X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=ppcskel.git;a=commitdiff_plain;h=a097034dd02e527ef24443273b079b52c4c30925 cbp will be count up, but only with low speed devices (except my usb keyboard o_X) --- diff --git a/usb/core/core.c b/usb/core/core.c index 87000fe..27cfd93 100644 --- a/usb/core/core.c +++ b/usb/core/core.c @@ -90,7 +90,7 @@ usb_device *usb_add_device() { 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; @@ -116,7 +116,7 @@ usb_device *usb_add_device() * 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 @@ -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->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 */ +#if 0 if (togl == 0) togl = 1; else togl = 0; +#endif /**** send token ****/ printf("togl: %d\n", togl); hcdi_enqueue(td); + break; #if 0 memcpy(td->buffer, mybuf, td->actlen); #endif diff --git a/usb/core/usb.c b/usb/core/usb.c index bfb37a6..1665abf 100644 --- a/usb/core/usb.c +++ b/usb/core/usb.c @@ -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; -#if 0 +#if 1 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 -#if 1 +#if 0 //should be the right way around? :O buf[0]=(char)requesttype; buf[1]=(char)request; diff --git a/usb/host/ohci.c b/usb/host/ohci.c index bd3793c..c0c13f9 100644 --- a/usb/host/ohci.c +++ b/usb/host/ohci.c @@ -177,7 +177,7 @@ static void dbg_td_flag(u32 flag) * 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; @@ -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((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); @@ -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)); - 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); - 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); - (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_CTRL_HEAD_ED, virt_to_phys(0)); + /* * 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 */ +#if 0 if(td->actlen) free((void*)tmptdbuffer); free(tmptd); +#endif 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); - wait_ms(150); + wait_ms(120); /* clear CSC flag, set PES and start port reset (PRS) */ write32(reg, RH_PS_PES);