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
987 td_fill(ohci, info | (cnt? TD_T_TOGGLE:toggle), in td_submit_job()
993 td_fill(ohci, info | (cnt? TD_T_TOGGLE:toggle), data, in td_submit_job()
997 if (!ohci->sleeping) { in td_submit_job()
999 ohci_writel(OHCI_BLF, &ohci->regs->cmdstatus); in td_submit_job()
1007 td_fill(ohci, info, setup, 8, dev, cnt++, urb); in td_submit_job()
1015 td_fill(ohci, info, data, data_len, dev, cnt++, urb); in td_submit_job()
1022 td_fill(ohci, info, data, 0, dev, cnt++, urb); in td_submit_job()
1024 if (!ohci->sleeping) { in td_submit_job()
1026 ohci_writel(OHCI_CLF, &ohci->regs->cmdstatus); in td_submit_job()
1034 td_fill(ohci, info, data, data_len, dev, cnt++, urb); in td_submit_job()
1098 static td_t *dl_reverse_done_list(ohci_t *ohci) in dl_reverse_done_list() argument
1104 invalidate_dcache_hcca(ohci->hcca); in dl_reverse_done_list()
1105 td_list_hc = m32_swap(ohci->hcca->done_head) & 0xfffffff0; in dl_reverse_done_list()
1106 ohci->hcca->done_head = 0; in dl_reverse_done_list()
1107 flush_dcache_hcca(ohci->hcca); in dl_reverse_done_list()
1123 static void finish_urb(ohci_t *ohci, urb_priv_t *urb, int status) in finish_urb() argument
1137 static int takeback_td(ohci_t *ohci, td_t *td_list) in takeback_td() argument
1166 finish_urb(ohci, lurb_priv, ed->state); in takeback_td()
1178 ep_unlink(ohci, ed); in takeback_td()
1183 static int dl_done_list(ohci_t *ohci) in dl_done_list() argument
1186 td_t *td_list = dl_reverse_done_list(ohci); in dl_done_list()
1190 stat = takeback_td(ohci, td_list); in dl_done_list()
1209 &ohci->regs->roothub.status); }
1211 (x)); ohci_writel((x), &ohci->regs->roothub.portstatus[wIndex-1]); }
1213 #define WR_RH_STAT(x) ohci_writel((x), &ohci->regs->roothub.status)
1215 &ohci->regs->roothub.portstatus[wIndex-1])
1217 #define RD_RH_STAT roothub_status(ohci)
1218 #define RD_RH_PORTSTAT roothub_portstatus(ohci, wIndex-1)
1246 static int ohci_submit_rh_msg(ohci_t *ohci, struct usb_device *dev, in ohci_submit_rh_msg() argument
1261 pkt_print(ohci, NULL, dev, pipe, buffer, transfer_len, in ohci_submit_rh_msg()
1354 ohci->rh.devnum = wValue; in ohci_submit_rh_msg()
1399 __u32 temp = roothub_a(ohci); in ohci_submit_rh_msg()
1418 temp = roothub_b(ohci); in ohci_submit_rh_msg()
1447 ohci_dump_roothub(ohci, 1); in ohci_submit_rh_msg()
1459 pkt_print(ohci, NULL, dev, pipe, buffer, in ohci_submit_rh_msg()
1470 static ohci_dev_t *ohci_get_ohci_dev(ohci_t *ohci, int devnum, int intr) in ohci_get_ohci_dev() argument
1475 return &ohci->ohci_dev; in ohci_get_ohci_dev()
1479 if (ohci->int_dev[i].devnum == devnum) in ohci_get_ohci_dev()
1480 return &ohci->int_dev[i]; in ohci_get_ohci_dev()
1485 if (ohci->int_dev[i].devnum == -1) { in ohci_get_ohci_dev()
1486 ohci->int_dev[i].devnum = devnum; in ohci_get_ohci_dev()
1487 return &ohci->int_dev[i]; in ohci_get_ohci_dev()
1517 static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, in submit_common_msg() argument
1533 pkt_print(ohci, urb, dev, pipe, buffer, transfer_len, in submit_common_msg()
1544 ohci_dev = ohci_get_ohci_dev(ohci, dev->devnum, usb_pipeint(pipe)); in submit_common_msg()
1548 if (sohci_submit_job(ohci, ohci_dev, urb, setup) < 0) { in submit_common_msg()
1561 stat = hc_interrupt(ohci); in submit_common_msg()
1603 pkt_print(ohci, urb, dev, pipe, buffer, transfer_len, in submit_common_msg()
1620 static struct int_queue *_ohci_create_int_queue(ohci_t *ohci, in _ohci_create_int_queue() argument
1631 ohci_dev = ohci_get_ohci_dev(ohci, udev->devnum, 1); in _ohci_create_int_queue()
1648 if (sohci_submit_job(ohci, ohci_dev, queue->urb[i], NULL)) { in _ohci_create_int_queue()
1666 static void *_ohci_poll_int_queue(ohci_t *ohci, struct usb_device *udev, in _ohci_poll_int_queue() argument
1672 if (hc_interrupt(ohci) < 0) in _ohci_poll_int_queue()
1684 static int _ohci_destroy_int_queue(ohci_t *ohci, struct usb_device *dev, in _ohci_destroy_int_queue() argument
1734 static int _ohci_submit_control_msg(ohci_t *ohci, struct usb_device *dev, in _ohci_submit_control_msg() argument
1742 pkt_print(ohci, NULL, dev, pipe, buffer, transfer_len, in _ohci_submit_control_msg()
1752 if (((pipe >> 8) & 0x7f) == ohci->rh.devnum) { in _ohci_submit_control_msg()
1753 ohci->rh.dev = dev; in _ohci_submit_control_msg()
1755 return ohci_submit_rh_msg(ohci, dev, pipe, buffer, in _ohci_submit_control_msg()
1759 return submit_common_msg(ohci, dev, pipe, buffer, transfer_len, in _ohci_submit_control_msg()
1769 static int hc_reset(ohci_t *ohci) in hc_reset() argument
1803 if (ohci_readl(&ohci->regs->control) & OHCI_CTRL_IR) { in hc_reset()
1805 ohci_writel(OHCI_OCR, &ohci->regs->cmdstatus); in hc_reset()
1807 while (ohci_readl(&ohci->regs->control) & OHCI_CTRL_IR) { in hc_reset()
1817 ohci_writel(OHCI_INTR_MIE, &ohci->regs->intrdisable); in hc_reset()
1820 ohci->slot_name, in hc_reset()
1821 ohci_readl(&ohci->regs->control)); in hc_reset()
1824 ohci->hc_control = 0; in hc_reset()
1825 ohci_writel(ohci->hc_control, &ohci->regs->control); in hc_reset()
1828 ohci_writel(OHCI_HCR, &ohci->regs->cmdstatus); in hc_reset()
1829 while ((ohci_readl(&ohci->regs->cmdstatus) & OHCI_HCR) != 0) { in hc_reset()
1845 static int hc_start(ohci_t *ohci) in hc_start() argument
1851 ohci->disabled = 1; in hc_start()
1853 ohci->int_dev[i].devnum = -1; in hc_start()
1858 ohci_writel(0, &ohci->regs->ed_controlhead); in hc_start()
1859 ohci_writel(0, &ohci->regs->ed_bulkhead); in hc_start()
1861 ohci_writel((uintptr_t)ohci->hcca, in hc_start()
1862 &ohci->regs->hcca); /* reset clears this */ in hc_start()
1865 ohci_writel((fminterval * 9) / 10, &ohci->regs->periodicstart); in hc_start()
1867 ohci_writel(fminterval, &ohci->regs->fminterval); in hc_start()
1868 ohci_writel(0x628, &ohci->regs->lsthresh); in hc_start()
1871 ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER; in hc_start()
1872 ohci->disabled = 0; in hc_start()
1873 ohci_writel(ohci->hc_control, &ohci->regs->control); in hc_start()
1879 ohci_writel(mask, &ohci->regs->intrdisable); in hc_start()
1882 ohci_writel(mask, &ohci->regs->intrstatus); in hc_start()
1885 ohci_writel(mask, &ohci->regs->intrenable); in hc_start()
1889 ohci_writel((roothub_a(ohci) | RH_A_NPS) & ~RH_A_PSM, in hc_start()
1890 &ohci->regs->roothub.a); in hc_start()
1891 ohci_writel(RH_HS_LPSC, &ohci->regs->roothub.status); in hc_start()
1895 ohci->rh.devnum = 0; in hc_start()
1904 static int hc_interrupt(ohci_t *ohci) in hc_interrupt() argument
1906 struct ohci_regs *regs = ohci->regs; in hc_interrupt()
1910 invalidate_dcache_hcca(ohci->hcca); in hc_interrupt()
1912 if ((ohci->hcca->done_head != 0) && in hc_interrupt()
1913 !(m32_swap(ohci->hcca->done_head) & 0x01)) { in hc_interrupt()
1918 ohci->disabled++; in hc_interrupt()
1919 err("%s device removed!", ohci->slot_name); in hc_interrupt()
1937 ohci->disabled++; in hc_interrupt()
1939 ohci->slot_name); in hc_interrupt()
1943 ohci_dump(ohci, 1); in hc_interrupt()
1951 hc_reset(ohci); in hc_interrupt()
1959 stat = dl_done_list(ohci); in hc_interrupt()
1972 unsigned int frame = m16_swap(ohci->hcca->frame_no) & 1; in hc_interrupt()
1975 if (ohci->ed_rm_list[frame] != NULL) in hc_interrupt()
1992 static void hc_release_ohci(ohci_t *ohci) in hc_release_ohci() argument
1994 dbg("USB HC release ohci usb-%s", ohci->slot_name); in hc_release_ohci()
1996 if (!ohci->disabled) in hc_release_ohci()
1997 hc_reset(ohci); in hc_release_ohci()
2144 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_submit_control_msg() local
2146 return _ohci_submit_control_msg(ohci, udev, pipe, buffer, in ohci_submit_control_msg()
2153 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_submit_bulk_msg() local
2155 return submit_common_msg(ohci, udev, pipe, buffer, length, NULL, 0); in ohci_submit_bulk_msg()
2162 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_submit_int_msg() local
2164 return submit_common_msg(ohci, udev, pipe, buffer, length, in ohci_submit_int_msg()
2172 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_create_int_queue() local
2174 return _ohci_create_int_queue(ohci, udev, pipe, queuesize, elementsize, in ohci_create_int_queue()
2181 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_poll_int_queue() local
2183 return _ohci_poll_int_queue(ohci, udev, queue); in ohci_poll_int_queue()
2189 ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); in ohci_destroy_int_queue() local
2191 return _ohci_destroy_int_queue(ohci, udev, queue); in ohci_destroy_int_queue()
2197 ohci_t *ohci = dev_get_priv(dev); in ohci_register() local
2202 ohci->regs = regs; in ohci_register()
2203 ohci->hcca = memalign(256, sizeof(struct ohci_hcca)); in ohci_register()
2204 if (!ohci->hcca) in ohci_register()
2206 memset(ohci->hcca, 0, sizeof(struct ohci_hcca)); in ohci_register()
2207 flush_dcache_hcca(ohci->hcca); in ohci_register()
2209 if (hc_reset(ohci) < 0) in ohci_register()
2212 if (hc_start(ohci) < 0) in ohci_register()
2223 ohci_t *ohci = dev_get_priv(dev); in ohci_deregister() local
2225 if (hc_reset(ohci) < 0) in ohci_deregister()
2228 free(ohci->hcca); in ohci_deregister()