Lines Matching refs:ohci
200 static inline u32 roothub_a(struct ohci *hc) in roothub_a()
202 static inline u32 roothub_b(struct ohci *hc) in roothub_b()
204 static inline u32 roothub_status(struct ohci *hc) in roothub_status()
206 static inline u32 roothub_portstatus(struct ohci *hc, int i) in roothub_portstatus()
210 static int hc_interrupt(ohci_t *ohci);
211 static void td_submit_job(ohci_t *ohci, struct usb_device *dev,
215 static int ep_link(ohci_t * ohci, ed_t * ed);
216 static int ep_unlink(ohci_t * ohci, ed_t * ed);
275 static int sohci_get_current_frame_number(ohci_t *ohci);
280 static void pkt_print(ohci_t *ohci, urb_priv_t *purb, struct usb_device *dev, in pkt_print() argument
286 sohci_get_current_frame_number(ohci), in pkt_print()
321 void ep_print_int_eds(ohci_t *ohci, char *str) in ep_print_int_eds() argument
327 ed_p = &(ohci->hcca->int_table [i]); in ep_print_int_eds()
512 int sohci_submit_job(ohci_t *ohci, ohci_dev_t *ohci_dev, urb_priv_t *urb, in sohci_submit_job() argument
526 if (ohci->disabled) { in sohci_submit_job()
589 ep_link(ohci, ed); in sohci_submit_job()
592 td_submit_job(ohci, dev, pipe, buffer, transfer_len, in sohci_submit_job()
602 static int sohci_get_current_frame_number(ohci_t *ohci) in sohci_get_current_frame_number() argument
604 invalidate_dcache_hcca(ohci->hcca); in sohci_get_current_frame_number()
605 return m16_swap(ohci->hcca->frame_no); in sohci_get_current_frame_number()
618 static int ep_int_ballance(ohci_t *ohci, int interval, int load) in ep_int_ballance() argument
626 if (ohci->ohci_int_load [branch] > ohci->ohci_int_load [i]) in ep_int_ballance()
631 ohci->ohci_int_load [i] += load; in ep_int_ballance()
667 static int ep_link(ohci_t *ohci, ed_t *edi) in ep_link() argument
684 if (ohci->ed_controltail == NULL) in ep_link()
685 ohci_writel((uintptr_t)ed, &ohci->regs->ed_controlhead); in ep_link()
687 ohci->ed_controltail->hwNextED = in ep_link()
690 ed->ed_prev = ohci->ed_controltail; in ep_link()
691 if (!ohci->ed_controltail && !ohci->ed_rm_list[0] && in ep_link()
692 !ohci->ed_rm_list[1] && !ohci->sleeping) { in ep_link()
693 ohci->hc_control |= OHCI_CTRL_CLE; in ep_link()
694 ohci_writel(ohci->hc_control, &ohci->regs->control); in ep_link()
696 ohci->ed_controltail = edi; in ep_link()
702 if (ohci->ed_bulktail == NULL) in ep_link()
703 ohci_writel((uintptr_t)ed, &ohci->regs->ed_bulkhead); in ep_link()
705 ohci->ed_bulktail->hwNextED = in ep_link()
708 ed->ed_prev = ohci->ed_bulktail; in ep_link()
709 if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] && in ep_link()
710 !ohci->ed_rm_list[1] && !ohci->sleeping) { in ep_link()
711 ohci->hc_control |= OHCI_CTRL_BLE; in ep_link()
712 ohci_writel(ohci->hc_control, &ohci->regs->control); in ep_link()
714 ohci->ed_bulktail = edi; in ep_link()
721 int_branch = ep_int_ballance(ohci, interval, load); in ep_link()
726 for (ed_p = &(ohci->hcca->int_table[\ in ep_link()
736 flush_dcache_hcca(ohci->hcca); in ep_link()
746 static void periodic_unlink(struct ohci *ohci, volatile struct ed *ed, in periodic_unlink() argument
752 __u32 *ed_p = &ohci->hcca->int_table [index]; in periodic_unlink()
776 static int ep_unlink(ohci_t *ohci, ed_t *edi) in ep_unlink() argument
788 ohci->hc_control &= ~OHCI_CTRL_CLE; in ep_unlink()
789 ohci_writel(ohci->hc_control, in ep_unlink()
790 &ohci->regs->control); in ep_unlink()
793 &ohci->regs->ed_controlhead); in ep_unlink()
798 if (ohci->ed_controltail == ed) { in ep_unlink()
799 ohci->ed_controltail = ed->ed_prev; in ep_unlink()
809 ohci->hc_control &= ~OHCI_CTRL_BLE; in ep_unlink()
810 ohci_writel(ohci->hc_control, in ep_unlink()
811 &ohci->regs->control); in ep_unlink()
814 &ohci->regs->ed_bulkhead); in ep_unlink()
819 if (ohci->ed_bulktail == ed) { in ep_unlink()
820 ohci->ed_bulktail = ed->ed_prev; in ep_unlink()
828 periodic_unlink(ohci, ed, 0, 1); in ep_unlink()
830 ohci->ohci_int_load[i] -= ed->int_load; in ep_unlink()
897 static void td_fill(ohci_t *ohci, unsigned int info, in td_fill() argument
953 static void td_submit_job(ohci_t *ohci, struct usb_device *dev, in td_submit_job() argument
986 td_fill(ohci, info | (cnt? TD_T_TOGGLE:toggle), in td_submit_job()
992 td_fill(ohci, info | (cnt? TD_T_TOGGLE:toggle), data, in td_submit_job()
996 if (!ohci->sleeping) { in td_submit_job()
998 ohci_writel(OHCI_BLF, &ohci->regs->cmdstatus); in td_submit_job()
1006 td_fill(ohci, info, setup, 8, dev, cnt++, urb); in td_submit_job()
1014 td_fill(ohci, info, data, data_len, dev, cnt++, urb); in td_submit_job()
1021 td_fill(ohci, info, data, 0, dev, cnt++, urb); in td_submit_job()
1023 if (!ohci->sleeping) { in td_submit_job()
1025 ohci_writel(OHCI_CLF, &ohci->regs->cmdstatus); in td_submit_job()
1033 td_fill(ohci, info, data, data_len, dev, cnt++, urb); in td_submit_job()
1097 static td_t *dl_reverse_done_list(ohci_t *ohci) in dl_reverse_done_list() argument
1103 invalidate_dcache_hcca(ohci->hcca); in dl_reverse_done_list()
1104 td_list_hc = m32_swap(ohci->hcca->done_head) & 0xfffffff0; in dl_reverse_done_list()
1105 ohci->hcca->done_head = 0; in dl_reverse_done_list()
1106 flush_dcache_hcca(ohci->hcca); in dl_reverse_done_list()
1122 static void finish_urb(ohci_t *ohci, urb_priv_t *urb, int status) in finish_urb() argument
1136 static int takeback_td(ohci_t *ohci, td_t *td_list) in takeback_td() argument
1165 finish_urb(ohci, lurb_priv, ed->state); in takeback_td()
1177 ep_unlink(ohci, ed); in takeback_td()
1182 static int dl_done_list(ohci_t *ohci) in dl_done_list() argument
1185 td_t *td_list = dl_reverse_done_list(ohci); in dl_done_list()
1189 stat = takeback_td(ohci, td_list); in dl_done_list()
1208 &ohci->regs->roothub.status); }
1210 (x)); ohci_writel((x), &ohci->regs->roothub.portstatus[wIndex-1]); }
1212 #define WR_RH_STAT(x) ohci_writel((x), &ohci->regs->roothub.status)
1214 &ohci->regs->roothub.portstatus[wIndex-1])
1216 #define RD_RH_STAT roothub_status(ohci)
1217 #define RD_RH_PORTSTAT roothub_portstatus(ohci, wIndex-1)
1245 static int ohci_submit_rh_msg(ohci_t *ohci, struct usb_device *dev, in ohci_submit_rh_msg() argument
1260 pkt_print(ohci, NULL, dev, pipe, buffer, transfer_len, in ohci_submit_rh_msg()
1353 ohci->rh.devnum = wValue; in ohci_submit_rh_msg()
1398 __u32 temp = roothub_a(ohci); in ohci_submit_rh_msg()
1417 temp = roothub_b(ohci); in ohci_submit_rh_msg()
1446 ohci_dump_roothub(ohci, 1); in ohci_submit_rh_msg()
1458 pkt_print(ohci, NULL, dev, pipe, buffer, in ohci_submit_rh_msg()
1469 static ohci_dev_t *ohci_get_ohci_dev(ohci_t *ohci, int devnum, int intr) in ohci_get_ohci_dev() argument
1474 return &ohci->ohci_dev; in ohci_get_ohci_dev()
1478 if (ohci->int_dev[i].devnum == devnum) in ohci_get_ohci_dev()
1479 return &ohci->int_dev[i]; in ohci_get_ohci_dev()
1484 if (ohci->int_dev[i].devnum == -1) { in ohci_get_ohci_dev()
1485 ohci->int_dev[i].devnum = devnum; in ohci_get_ohci_dev()
1486 return &ohci->int_dev[i]; in ohci_get_ohci_dev()
1516 static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, in submit_common_msg() argument
1532 pkt_print(ohci, urb, dev, pipe, buffer, transfer_len, in submit_common_msg()
1543 ohci_dev = ohci_get_ohci_dev(ohci, dev->devnum, usb_pipeint(pipe)); in submit_common_msg()
1547 if (sohci_submit_job(ohci, ohci_dev, urb, setup) < 0) { in submit_common_msg()
1560 stat = hc_interrupt(ohci); in submit_common_msg()
1602 pkt_print(ohci, urb, dev, pipe, buffer, transfer_len, in submit_common_msg()
1619 static struct int_queue *_ohci_create_int_queue(ohci_t *ohci, in _ohci_create_int_queue() argument
1630 ohci_dev = ohci_get_ohci_dev(ohci, udev->devnum, 1); in _ohci_create_int_queue()
1647 if (sohci_submit_job(ohci, ohci_dev, queue->urb[i], NULL)) { in _ohci_create_int_queue()
1665 static void *_ohci_poll_int_queue(ohci_t *ohci, struct usb_device *udev, in _ohci_poll_int_queue() argument
1671 if (hc_interrupt(ohci) < 0) in _ohci_poll_int_queue()
1683 static int _ohci_destroy_int_queue(ohci_t *ohci, struct usb_device *dev, in _ohci_destroy_int_queue() argument
1733 static int _ohci_submit_control_msg(ohci_t *ohci, struct usb_device *dev, in _ohci_submit_control_msg() argument
1741 pkt_print(ohci, NULL, dev, pipe, buffer, transfer_len, in _ohci_submit_control_msg()
1751 if (((pipe >> 8) & 0x7f) == ohci->rh.devnum) { in _ohci_submit_control_msg()
1752 ohci->rh.dev = dev; in _ohci_submit_control_msg()
1754 return ohci_submit_rh_msg(ohci, dev, pipe, buffer, in _ohci_submit_control_msg()
1758 return submit_common_msg(ohci, dev, pipe, buffer, transfer_len, in _ohci_submit_control_msg()
1768 static int hc_reset(ohci_t *ohci) in hc_reset() argument
1802 if (ohci_readl(&ohci->regs->control) & OHCI_CTRL_IR) { in hc_reset()
1804 ohci_writel(OHCI_OCR, &ohci->regs->cmdstatus); in hc_reset()
1806 while (ohci_readl(&ohci->regs->control) & OHCI_CTRL_IR) { in hc_reset()
1816 ohci_writel(OHCI_INTR_MIE, &ohci->regs->intrdisable); in hc_reset()
1819 ohci->slot_name, in hc_reset()
1820 ohci_readl(&ohci->regs->control)); in hc_reset()
1823 ohci->hc_control = 0; in hc_reset()
1824 ohci_writel(ohci->hc_control, &ohci->regs->control); in hc_reset()
1827 ohci_writel(OHCI_HCR, &ohci->regs->cmdstatus); in hc_reset()
1828 while ((ohci_readl(&ohci->regs->cmdstatus) & OHCI_HCR) != 0) { in hc_reset()
1844 static int hc_start(ohci_t *ohci) in hc_start() argument
1850 ohci->disabled = 1; in hc_start()
1852 ohci->int_dev[i].devnum = -1; in hc_start()
1857 ohci_writel(0, &ohci->regs->ed_controlhead); in hc_start()
1858 ohci_writel(0, &ohci->regs->ed_bulkhead); in hc_start()
1860 ohci_writel((uintptr_t)ohci->hcca, in hc_start()
1861 &ohci->regs->hcca); /* reset clears this */ in hc_start()
1864 ohci_writel((fminterval * 9) / 10, &ohci->regs->periodicstart); in hc_start()
1866 ohci_writel(fminterval, &ohci->regs->fminterval); in hc_start()
1867 ohci_writel(0x628, &ohci->regs->lsthresh); in hc_start()
1870 ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER; in hc_start()
1871 ohci->disabled = 0; in hc_start()
1872 ohci_writel(ohci->hc_control, &ohci->regs->control); in hc_start()
1878 ohci_writel(mask, &ohci->regs->intrdisable); in hc_start()
1881 ohci_writel(mask, &ohci->regs->intrstatus); in hc_start()
1884 ohci_writel(mask, &ohci->regs->intrenable); in hc_start()
1888 ohci_writel((roothub_a(ohci) | RH_A_NPS) & ~RH_A_PSM, in hc_start()
1889 &ohci->regs->roothub.a); in hc_start()
1890 ohci_writel(RH_HS_LPSC, &ohci->regs->roothub.status); in hc_start()
1894 ohci->rh.devnum = 0; in hc_start()
1903 static int hc_interrupt(ohci_t *ohci) in hc_interrupt() argument
1905 struct ohci_regs *regs = ohci->regs; in hc_interrupt()
1909 invalidate_dcache_hcca(ohci->hcca); in hc_interrupt()
1911 if ((ohci->hcca->done_head != 0) && in hc_interrupt()
1912 !(m32_swap(ohci->hcca->done_head) & 0x01)) { in hc_interrupt()
1917 ohci->disabled++; in hc_interrupt()
1918 err("%s device removed!", ohci->slot_name); in hc_interrupt()
1936 ohci->disabled++; in hc_interrupt()
1938 ohci->slot_name); in hc_interrupt()
1942 ohci_dump(ohci, 1); in hc_interrupt()
1950 hc_reset(ohci); in hc_interrupt()
1958 stat = dl_done_list(ohci); in hc_interrupt()
1971 unsigned int frame = m16_swap(ohci->hcca->frame_no) & 1; in hc_interrupt()
1974 if (ohci->ed_rm_list[frame] != NULL) in hc_interrupt()
1991 static void hc_release_ohci(ohci_t *ohci) in hc_release_ohci() argument
1993 dbg("USB HC release ohci usb-%s", ohci->slot_name); in hc_release_ohci()
1995 if (!ohci->disabled) in hc_release_ohci()
1996 hc_reset(ohci); in hc_release_ohci()
2143 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_submit_control_msg() local
2145 return _ohci_submit_control_msg(ohci, udev, pipe, buffer, in ohci_submit_control_msg()
2152 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_submit_bulk_msg() local
2154 return submit_common_msg(ohci, udev, pipe, buffer, length, NULL, 0); in ohci_submit_bulk_msg()
2161 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_submit_int_msg() local
2163 return submit_common_msg(ohci, udev, pipe, buffer, length, in ohci_submit_int_msg()
2171 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_create_int_queue() local
2173 return _ohci_create_int_queue(ohci, udev, pipe, queuesize, elementsize, in ohci_create_int_queue()
2180 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_poll_int_queue() local
2182 return _ohci_poll_int_queue(ohci, udev, queue); in ohci_poll_int_queue()
2188 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_destroy_int_queue() local
2190 return _ohci_destroy_int_queue(ohci, udev, queue); in ohci_destroy_int_queue()
2196 ohci_t *ohci = dev_get_priv(dev); in ohci_register() local
2201 ohci->regs = regs; in ohci_register()
2202 ohci->hcca = memalign(256, sizeof(struct ohci_hcca)); in ohci_register()
2203 if (!ohci->hcca) in ohci_register()
2205 memset(ohci->hcca, 0, sizeof(struct ohci_hcca)); in ohci_register()
2206 flush_dcache_hcca(ohci->hcca); in ohci_register()
2208 if (hc_reset(ohci) < 0) in ohci_register()
2211 if (hc_start(ohci) < 0) in ohci_register()
2222 ohci_t *ohci = dev_get_priv(dev); in ohci_deregister() local
2224 if (hc_reset(ohci) < 0) in ohci_deregister()
2227 free(ohci->hcca); in ohci_deregister()