grml...
[seabios.git] / src / usb-ohci.c
index 43fe238b6f57e38bd284fa220a6086a79a776918..9107db2bcd2af68e76fc7ceb9656d7dd4d1c73c6 100644 (file)
@@ -60,7 +60,7 @@ ohci_hub_reset(struct usbhub_s *hub, u32 port)
         if (!(sts & RH_PS_PRS))
             // XXX - need to ensure USB_TIME_DRSTR time in reset?
             break;
-        if (check_time(end)) {
+        if (check_tsc(end)) {
             // Timeout.
             warn_timeout();
             ohci_hub_disconnect(hub, port);
@@ -129,7 +129,7 @@ start_ohci(struct usb_ohci_s *cntl, struct ohci_hcca *hcca)
         u32 status = readl(&cntl->regs->cmdstatus);
         if (! status & OHCI_HCR)
             break;
-        if (check_time(end)) {
+        if (check_tsc(end)) {
             warn_timeout();
             return -1;
         }
@@ -204,15 +204,21 @@ free:
 }
 
 void
-ohci_init(u16 bdf, int busid)
+ohci_init(struct pci_device *pci, int busid)
 {
     if (! CONFIG_USB_OHCI)
         return;
     struct usb_ohci_s *cntl = malloc_tmphigh(sizeof(*cntl));
+    if (!cntl) {
+        warn_noalloc();
+        return;
+    }
     memset(cntl, 0, sizeof(*cntl));
     cntl->usb.busid = busid;
+    cntl->usb.pci = pci;
     cntl->usb.type = USB_TYPE_OHCI;
 
+    u16 bdf = pci->bdf;
     u32 baseaddr = pci_config_readl(bdf, PCI_BASE_ADDRESS_0);
     cntl->regs = (void*)(baseaddr & PCI_BASE_ADDRESS_MEM_MASK);
 
@@ -246,7 +252,7 @@ wait_ed(struct ohci_ed *ed)
     for (;;) {
         if (ed->hwHeadP == ed->hwTailP)
             return 0;
-        if (check_time(end)) {
+        if (check_tsc(end)) {
             warn_timeout();
             return -1;
         }
@@ -265,7 +271,7 @@ ohci_waittick(struct usb_ohci_s *cntl)
     for (;;) {
         if (hcca->frame_no != startframe)
             break;
-        if (check_time(end)) {
+        if (check_tsc(end)) {
             warn_timeout();
             return;
         }
@@ -411,6 +417,21 @@ ohci_control(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
     return ret;
 }
 
+struct usb_pipe *
+ohci_alloc_bulk_pipe(struct usb_pipe *dummy)
+{
+    if (! CONFIG_USB_OHCI)
+        return NULL;
+    dprintf(1, "OHCI Bulk transfers not supported.\n");
+    return NULL;
+}
+
+int
+ohci_send_bulk(struct usb_pipe *p, int dir, void *data, int datasize)
+{
+    return -1;
+}
+
 struct usb_pipe *
 ohci_alloc_intr_pipe(struct usb_pipe *dummy, int frameexp)
 {
@@ -485,7 +506,7 @@ ohci_poll_intr(struct usb_pipe *p, void *data)
 
     struct ohci_pipe *pipe = container_of(p, struct ohci_pipe, pipe);
     struct ohci_td *tds = GET_FLATPTR(pipe->tds);
-    struct ohci_td *head = (void*)GET_FLATPTR(pipe->ed.hwHeadP);
+    struct ohci_td *head = (void*)(GET_FLATPTR(pipe->ed.hwHeadP) & ~(ED_C|ED_H));
     struct ohci_td *tail = (void*)GET_FLATPTR(pipe->ed.hwTailP);
     int count = GET_FLATPTR(pipe->count);
     int pos = (tail - tds + 1) % count;