From: Bernhard Urban Date: Sun, 20 Sep 2009 21:50:20 +0000 (+0200) Subject: done head fixed; we poll edhead->headp until it is null, to get sure X-Git-Tag: demo0~28 X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=ppcskel.git;a=commitdiff_plain;h=316456cf22ec6843102b39cb4a33b4bb3e484d45 done head fixed; we poll edhead->headp until it is null, to get sure all TDs are done --- diff --git a/usb/core/core.c b/usb/core/core.c index 14600ff..bf3fbf7 100644 --- a/usb/core/core.c +++ b/usb/core/core.c @@ -128,11 +128,13 @@ usb_device *usb_add_device() devdescr_size = (u8) buf[0]; /* save real length of device descriptor */ /* define new adress */ + /* usb_control_msg(dev, 0x00, SET_ADDRESS, address << 8, 0, 0, buf, 8, 0); dev->address = address; + */ /* get complete device descriptor */ - usb_control_msg(dev, 0x80, GET_DESCRIPTOR, 1, 0, devdescr_size, buf, 8, + usb_control_msg(dev, 0x80, GET_DESCRIPTOR, DEVICE<<8, 0, devdescr_size, buf, 8, 0); /* save only really neccessary values for this small usbstack */ diff --git a/usb/host/ohci.c b/usb/host/ohci.c index 559aeab..a852be2 100644 --- a/usb/host/ohci.c +++ b/usb/host/ohci.c @@ -260,32 +260,18 @@ void hcdi_fire() set32(OHCI0_HC_CONTROL, OHCI_CTRL_CLE); write32(OHCI0_HC_COMMAND_STATUS, OHCI_CLF); - //don't use this quirk stuff here!? -#if 0 - u32 wait=0; - while(!read32(OHCI0_HC_CTRL_CURRENT_ED)) { + /* poll until edhead->headp is null */ + sync_before_read(edhead, sizeof(struct endpoint_descriptor)); + while(LE(edhead->headp)&~0xf) { + sync_before_read(edhead, sizeof(struct endpoint_descriptor)); } - while(read32(OHCI0_HC_CTRL_CURRENT_ED)); - printf("+++++++++++++++++++++++++++++\n"); - printf("wait: %d\n", wait); - udelay(1000000); -#else - while(!read32(OHCI0_HC_CTRL_CURRENT_ED)) { - } - udelay(100000); - u32 current = read32(OHCI0_HC_CTRL_CURRENT_ED); - printf("current: 0x%08X\n", current); - printf("+++++++++++++++++++++++++++++\n"); - udelay(1000000); -#endif - sync_before_read(&hcca_oh0, sizeof(hcca_oh0)); - struct general_td *n = phys_to_virt(LE(hcca_oh0.done_head) & ~1); - printf("done_head: 0x%08X\n", n); + struct general_td *n = phys_to_virt(read32(OHCI0_HC_DONE_HEAD) & ~1); + printf("hc_done_head: 0x%08X\n", read32(OHCI0_HC_DONE_HEAD)); struct general_td *prev = 0, *next = 0; /* reverse done queue */ - while(virt_to_phys(n)) { + while(virt_to_phys(n) && edhead->tdcount) { sync_before_read((void*) n, sizeof(struct general_td)); printf("n: 0x%08X\n", n); printf("next: 0x%08X\n", next); @@ -295,6 +281,8 @@ void hcdi_fire() n = (struct general_td*) phys_to_virt(LE(n->nexttd)); next->nexttd = (u32) prev; prev = next; + + edhead->tdcount--; } n = next; @@ -324,8 +312,8 @@ void hcdi_fire() write32(OHCI0_HC_CONTROL, read32(OHCI0_HC_CONTROL)&~OHCI_CTRL_CLE); free(edhead); - edhead = 0; + printf("<^> <^> <^> hcdi_fire(end)\n"); } @@ -342,10 +330,12 @@ u8 hcdi_enqueue(const usb_transfer_descriptor *td) { OHCI_ENDPOINT_SET_DEVICE_ADDRESS(td->devaddress) | OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(td->endpoint) | OHCI_ENDPOINT_SET_MAX_PACKET_SIZE(td->maxp)); + edhead->tdcount = 0; } struct general_td *tdhw = allocate_general_td(); general_td_fill(tdhw, td); + edhead->tdcount ++; if(!edhead->headp) { /* first transfer */ diff --git a/usb/host/ohci.h b/usb/host/ohci.h index cea428e..51be9bf 100644 --- a/usb/host/ohci.h +++ b/usb/host/ohci.h @@ -120,10 +120,14 @@ struct ohci_hcca { } ALIGNED(256); struct endpoint_descriptor { + /* required by HC */ u32 flags; u32 tailp; u32 headp; u32 nexted; + + /* required by software */ + u32 tdcount; } ALIGNED(16); #define OHCI_ENDPOINT_ADDRESS_MASK 0x0000007f