Home | History | Annotate | Download | only in host

Lines Matching defs:ohci

3  * URB OHCI HCD (Host Controller Driver) for USB on the AT91RM9200 and PCI bus.
46 #include "ohci.h"
69 {0x10b9, 0x5237}, /* ULI1575 PCI OHCI module ids */
70 {0x1033, 0x0035}, /* NEC PCI OHCI module ids */
71 {0x1131, 0x1561}, /* Philips 1561 PCI OHCI module ids */
72 /* Please add supported PCI OHCI controller ids here */
141 /* mapping of the OHCI CC status to error codes */
196 static inline u32 roothub_a(struct ohci *hc)
198 static inline u32 roothub_b(struct ohci *hc)
200 static inline u32 roothub_status(struct ohci *hc)
202 static inline u32 roothub_portstatus(struct ohci *hc, int i)
206 static int hc_interrupt(ohci_t *ohci);
207 static void td_submit_job(ohci_t *ohci, struct usb_device *dev,
211 static int ep_link(ohci_t * ohci, ed_t * ed);
212 static int ep_unlink(ohci_t * ohci, ed_t * ed);
271 static int sohci_get_current_frame_number(ohci_t *ohci);
276 static void pkt_print(ohci_t *ohci, urb_priv_t *purb, struct usb_device *dev,
282 sohci_get_current_frame_number(ohci),
317 void ep_print_int_eds(ohci_t *ohci, char *str)
323 ed_p = &(ohci->hcca->int_table [i]);
490 dbg("OHCI controller usb-%s state", controller->slot_name);
508 int sohci_submit_job(ohci_t *ohci, ohci_dev_t *ohci_dev, urb_priv_t *urb,
522 if (ohci->disabled) {
585 ep_link(ohci, ed);
588 td_submit_job(ohci, dev, pipe, buffer, transfer_len,
598 static int sohci_get_current_frame_number(ohci_t *ohci)
600 invalidate_dcache_hcca(ohci->hcca);
601 return m16_swap(ohci->hcca->frame_no);
614 static int ep_int_ballance(ohci_t *ohci, int interval, int load)
622 if (ohci->ohci_int_load [branch] > ohci->ohci_int_load [i])
627 ohci->ohci_int_load [i] += load;
663 static int ep_link(ohci_t *ohci, ed_t *edi)
680 if (ohci->ed_controltail == NULL)
681 ohci_writel((uintptr_t)ed, &ohci->regs->ed_controlhead);
683 ohci->ed_controltail->hwNextED =
686 ed->ed_prev = ohci->ed_controltail;
687 if (!ohci->ed_controltail && !ohci->ed_rm_list[0] &&
688 !ohci->ed_rm_list[1] && !ohci->sleeping) {
689 ohci->hc_control |= OHCI_CTRL_CLE;
690 ohci_writel(ohci->hc_control, &ohci->regs->control);
692 ohci->ed_controltail = edi;
698 if (ohci->ed_bulktail == NULL)
699 ohci_writel((uintptr_t)ed, &ohci->regs->ed_bulkhead);
701 ohci->ed_bulktail->hwNextED =
704 ed->ed_prev = ohci->ed_bulktail;
705 if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] &&
706 !ohci->ed_rm_list[1] && !ohci->sleeping) {
707 ohci->hc_control |= OHCI_CTRL_BLE;
708 ohci_writel(ohci->hc_control, &ohci->regs->control);
710 ohci->ed_bulktail = edi;
717 int_branch = ep_int_ballance(ohci, interval, load);
722 for (ed_p = &(ohci->hcca->int_table[\
732 flush_dcache_hcca(ohci->hcca);
742 static void periodic_unlink(struct ohci *ohci, volatile struct ed *ed,
748 __u32 *ed_p = &ohci->hcca->int_table [index];
772 static int ep_unlink(ohci_t *ohci, ed_t *edi)
784 ohci->hc_control &= ~OHCI_CTRL_CLE;
785 ohci_writel(ohci->hc_control,
786 &ohci->regs->control);
789 &ohci->regs->ed_controlhead);
794 if (ohci->ed_controltail == ed) {
795 ohci->ed_controltail = ed->ed_prev;
805 ohci->hc_control &= ~OHCI_CTRL_BLE;
806 ohci_writel(ohci->hc_control,
807 &ohci->regs->control);
810 &ohci->regs->ed_bulkhead);
815 if (ohci->ed_bulktail == ed) {
816 ohci->ed_bulktail = ed->ed_prev;
824 periodic_unlink(ohci, ed, 0, 1);
826 ohci->ohci_int_load[i] -= ed->int_load;
891 /* enqueue next TD for this URB (OHCI spec 5.2.8.2) */
893 static void td_fill(ohci_t *ohci, unsigned int info,
949 static void td_submit_job(ohci_t *ohci, struct usb_device *dev,
962 /* OHCI handles the DATA-toggles itself, we just use the USB-toggle
982 td_fill(ohci, info | (cnt? TD_T_TOGGLE:toggle),
988 td_fill(ohci, info | (cnt? TD_T_TOGGLE:toggle), data,
992 if (!ohci->sleeping) {
994 ohci_writel(OHCI_BLF, &ohci->regs->cmdstatus);
1002 td_fill(ohci, info, setup, 8, dev, cnt++, urb);
1010 td_fill(ohci, info, data, data_len, dev, cnt++, urb);
1017 td_fill(ohci, info, data, 0, dev, cnt++, urb);
1019 if (!ohci->sleeping) {
1021 ohci_writel(OHCI_CLF, &ohci->regs->cmdstatus);
1029 td_fill(ohci, info, data, data_len, dev, cnt++, urb);
1093 static td_t *dl_reverse_done_list(ohci_t *ohci)
1099 invalidate_dcache_hcca(ohci->hcca);
1100 td_list_hc = m32_swap(ohci->hcca->done_head) & 0xfffffff0;
1101 ohci->hcca->done_head = 0;
1102 flush_dcache_hcca(ohci->hcca);
1118 static void finish_urb(ohci_t *ohci, urb_priv_t *urb, int status)
1132 static int takeback_td(ohci_t *ohci, td_t *td_list)
1161 finish_urb(ohci, lurb_priv, ed->state);
1173 ep_unlink(ohci, ed);
1178 static int dl_done_list(ohci_t *ohci)
1181 td_t *td_list = dl_reverse_done_list(ohci);
1185 stat = takeback_td(ohci, td_list);
1204 &ohci->regs->roothub.status); }
1206 (x)); ohci_writel((x), &ohci->regs->roothub.portstatus[wIndex-1]); }
1208 #define WR_RH_STAT(x) ohci_writel((x), &ohci->regs->roothub.status)
1210 &ohci->regs->roothub.portstatus[wIndex-1])
1212 #define RD_RH_STAT roothub_status(ohci)
1213 #define RD_RH_PORTSTAT roothub_portstatus(ohci, wIndex-1)
1241 static int ohci_submit_rh_msg(ohci_t *ohci, struct usb_device *dev,
1256 pkt_print(ohci, NULL, dev, pipe, buffer, transfer_len,
1349 ohci->rh.devnum = wValue;
1394 __u32 temp = roothub_a(ohci);
1413 temp = roothub_b(ohci);
1442 ohci_dump_roothub(ohci, 1);
1454 pkt_print(ohci, NULL, dev, pipe, buffer,
1465 static ohci_dev_t *ohci_get_ohci_dev(ohci_t *ohci, int devnum, int intr)
1470 return &ohci->ohci_dev;
1474 if (ohci->int_dev[i].devnum == devnum)
1475 return &ohci->int_dev[i];
1480 if (ohci->int_dev[i].devnum == -1) {
1481 ohci->int_dev[i].devnum = devnum;
1482 return &ohci->int_dev[i];
1486 printf("ohci: Error out of ohci_devs for interrupt endpoints\n");
1499 printf("ohci: Error out of memory allocating urb\n");
1512 static int submit_common_msg(ohci_t *ohci, struct usb_device *dev,
1528 pkt_print(ohci, urb, dev, pipe, buffer, transfer_len,
1539 ohci_dev = ohci_get_ohci_dev(ohci, dev->devnum, usb_pipeint(pipe));
1543 if (sohci_submit_job(ohci, ohci_dev, urb, setup) < 0) {
1550 /* ohci_dump_status(ohci); */
1558 stat = hc_interrupt(ohci);
1600 pkt_print(ohci, urb, dev, pipe, buffer, transfer_len,
1617 static struct int_queue *_ohci_create_int_queue(ohci_t *ohci,
1628 ohci_dev = ohci_get_ohci_dev(ohci, udev->devnum, 1);
1634 printf("ohci: Error out of memory allocating int queue\n");
1645 if (sohci_submit_job(ohci, ohci_dev, queue->urb[i], NULL)) {
1646 printf("ohci: Error submitting int queue job\n");
1663 static void *_ohci_poll_int_queue(ohci_t *ohci, struct usb_device *udev,
1669 if (hc_interrupt(ohci) < 0)
1681 static int _ohci_destroy_int_queue(ohci_t *ohci, struct usb_device *dev,
1731 static int _ohci_submit_control_msg(ohci_t *ohci, struct usb_device *dev,
1739 pkt_print(ohci, NULL, dev, pipe, buffer, transfer_len,
1749 if (((pipe >> 8) & 0x7f) == ohci->rh.devnum) {
1750 ohci->rh.dev = dev;
1752 return ohci_submit_rh_msg(ohci, dev, pipe, buffer,
1756 return submit_common_msg(ohci, dev, pipe, buffer, transfer_len,
1766 static int hc_reset(ohci_t *ohci)
1800 if (ohci_readl(&ohci->regs->control) & OHCI_CTRL_IR) {
1802 ohci_writel(OHCI_OCR, &ohci->regs->cmdstatus);
1804 while (ohci_readl(&ohci->regs->control) & OHCI_CTRL_IR) {
1814 ohci_writel(OHCI_INTR_MIE, &ohci->regs->intrdisable);
1817 ohci->slot_name,
1818 ohci_readl(&ohci->regs->control));
1821 ohci->hc_control = 0;
1822 ohci_writel(ohci->hc_control, &ohci->regs->control);
1825 ohci_writel(OHCI_HCR, &ohci->regs->cmdstatus);
1826 while ((ohci_readl(&ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
1838 /* Start an OHCI controller, set the BUS operational
1842 static int hc_start(ohci_t *ohci)
1848 ohci->disabled = 1;
1850 ohci->int_dev[i].devnum = -1;
1855 ohci_writel(0, &ohci->regs->ed_controlhead);
1856 ohci_writel(0, &ohci->regs->ed_bulkhead);
1858 ohci_writel((uintptr_t)ohci->hcca,
1859 &ohci->regs->hcca); /* reset clears this */
1862 ohci_writel((fminterval * 9) / 10, &ohci->regs->periodicstart);
1864 ohci_writel(fminterval, &ohci->regs->fminterval);
1865 ohci_writel(0x628, &ohci->regs->lsthresh);
1868 ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER;
1869 ohci->disabled = 0;
1870 ohci_writel(ohci->hc_control, &ohci->regs->control);
1876 ohci_writel(mask, &ohci->regs->intrdisable);
1879 ohci_writel(mask, &ohci->regs->intrstatus);
1882 ohci_writel(mask, &ohci->regs->intrenable);
1886 ohci_writel((roothub_a(ohci) | RH_A_NPS) & ~RH_A_PSM,
1887 &ohci->regs->roothub.a);
1888 ohci_writel(RH_HS_LPSC, &ohci->regs->roothub.status);
1892 ohci->rh.devnum = 0;
1901 static int hc_interrupt(ohci_t *ohci)
1903 struct ohci_regs *regs = ohci->regs;
1907 invalidate_dcache_hcca(ohci->hcca);
1909 if ((ohci->hcca->done_head != 0) &&
1910 !(m32_swap(ohci->hcca->done_head) & 0x01)) {
1915 ohci->disabled++;
1916 err("%s device removed!", ohci->slot_name);
1928 le16_to_cpu(ohci->hcca->frame_no)); */
1934 ohci->disabled++;
1935 err("OHCI Unrecoverable Error, controller usb-%s disabled",
1936 ohci->slot_name);
1940 ohci_dump(ohci, 1);
1948 hc_reset(ohci);
1956 stat = dl_done_list(ohci);
1969 unsigned int frame = m16_swap(ohci->hcca->frame_no) & 1;
1972 if (ohci->ed_rm_list[frame] != NULL)
1989 static void hc_release_ohci(ohci_t *ohci)
1991 dbg("USB HC release ohci usb-%s", ohci->slot_name);
1993 if (!ohci->disabled)
1994 hc_reset(ohci);
2043 printf("OHCI pci controller (%04x, %04x) found @(%d:%d:%d)\n",
2047 printf("OHCI regs address 0x%08x\n", base);
2138 ohci_t *ohci = dev_get_priv(usb_get_bus(dev));
2140 return _ohci_submit_control_msg(ohci, udev, pipe, buffer,
2147 ohci_t *ohci = dev_get_priv(usb_get_bus(dev));
2149 return submit_common_msg(ohci, udev, pipe, buffer, length, NULL, 0);
2156 ohci_t *ohci = dev_get_priv(usb_get_bus(dev));
2158 return submit_common_msg(ohci, udev, pipe, buffer, length,
2166 ohci_t *ohci = dev_get_priv(usb_get_bus(dev));
2168 return _ohci_create_int_queue(ohci, udev, pipe, queuesize, elementsize,
2175 ohci_t *ohci = dev_get_priv(usb_get_bus(dev));
2177 return _ohci_poll_int_queue(ohci, udev, queue);
2183 ohci_t *ohci = dev_get_priv(usb_get_bus(dev));
2185 return _ohci_destroy_int_queue(ohci, udev, queue);
2191 ohci_t *ohci = dev_get_priv(dev);
2196 ohci->regs = regs;
2197 ohci->hcca = memalign(256, sizeof(struct ohci_hcca));
2198 if (!ohci->hcca)
2200 memset(ohci->hcca, 0, sizeof(struct ohci_hcca));
2201 flush_dcache_hcca(ohci->hcca);
2203 if (hc_reset(ohci) < 0)
2206 if (hc_start(ohci) < 0)
2210 printf("USB OHCI %x.%x\n", (reg >> 4) & 0xf, reg & 0xf);
2217 ohci_t *ohci = dev_get_priv(dev);
2219 if (hc_reset(ohci) < 0)
2222 free(ohci->hcca);