Lines Matching +full:inter +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0+
16 * (C) Copyright 2000-2002 David Brownell
19 * ebenard@eukrea.com - based on s3c24x0's driver
23 * 1 - Read doc/README.generic_usb_ohci
24 * 2 - this driver is intended for use with USB Mass Storage Devices
26 * 2 - when running on a PQFP208 AT91RM9200, define CONFIG_AT91C_PQFP_UHPBUG
146 /* Data Togg */ USB_ST_CRC_ERR,
148 /* DevNotResp */ -1,
153 /* reservd */ -1,
154 /* reservd */ -1,
157 /* Not Access */ -1,
158 /* Not Access */ -1
163 "CRC: Last data packet from endpoint contained a CRC error.",
164 "BITSTUFFING: Last data packet from endpoint contained a bit " \
166 "DATATOGGLEMISMATCH: Last packet from endpoint had data toggle PID\n" \
172 "PIDCHECKFAILURE: Check bits on PID from endpoint failed on data PID\n"\
176 "DATAOVERRUN: The amount of data returned by the endpoint exceeded\n" \
177 "either the size of the maximum data packet allowed\n" \
185 "BUFFEROVERRUN: During an IN, HC received data from endpoint faster\n" \
187 "BUFFERUNDERRUN: During an OUT, HC could not retrieve data from\n" \
188 "system memory fast enough to keep up with data USB " \
189 "data rate.",
197 { return ohci_readl(&hc->regs->roothub.a); } in roothub_a()
199 { return ohci_readl(&hc->regs->roothub.b); } in roothub_b()
201 { return ohci_readl(&hc->regs->roothub.status); } in roothub_status()
203 { return ohci_readl(&hc->regs->roothub.portstatus[i]); } in roothub_portstatus()
216 /*-------------------------------------------------------------------------*/
227 if (ohci_dev->tds[i].usb_dev == NULL) in td_alloc()
229 td = &ohci_dev->tds[i]; in td_alloc()
230 td->usb_dev = usb_dev; in td_alloc()
240 ed->usb_dev = NULL; in ed_free()
243 /*-------------------------------------------------------------------------*
245 *-------------------------------------------------------------------------*/
247 /* free HCD-private data associated with this URB */
255 last = urb->length - 1; in urb_free_priv()
258 td = urb->td[i]; in urb_free_priv()
260 td->usb_dev = NULL; in urb_free_priv()
261 urb->td[i] = NULL; in urb_free_priv()
268 /*-------------------------------------------------------------------------*/
274 * small: 0) header + data packets 1) just header */
280 dbg("%s URB:[%4x] dev:%2lu,ep:%2lu-%c,type:%s,len:%d/%d stat:%#lx", in pkt_print()
289 (purb ? purb->actual_length : 0), in pkt_print()
290 transfer_len, dev->status); in pkt_print()
302 printf(__FILE__ ": data(%d/%d):", in pkt_print()
303 (purb ? purb->actual_length : 0), in pkt_print()
306 (purb ? purb->actual_length : 0); in pkt_print()
315 /* just for debugging; prints non-empty branches of the int ed tree
323 ed_p = &(ohci->hcca->int_table [i]); in ep_print_int_eds()
328 while (*ed_p != 0 && j--) { in ep_print_int_eds()
331 printf(" ed: %4x;", ed->hwINFO); in ep_print_int_eds()
332 ed_p = &ed->hwNextED; in ep_print_int_eds()
362 dbg("%08x", edp->hwINFO); in maybe_print_eds()
363 dbg("%08x", edp->hwTailP); in maybe_print_eds()
364 dbg("%08x", edp->hwHeadP); in maybe_print_eds()
365 dbg("%08x", edp->hwNextED); in maybe_print_eds()
383 struct ohci_regs *regs = controller->regs; in ohci_dump_status()
386 temp = ohci_readl(®s->revision) & 0xff; in ohci_dump_status()
390 temp = ohci_readl(®s->control); in ohci_dump_status()
403 temp = ohci_readl(®s->cmdstatus); in ohci_dump_status()
412 ohci_dump_intr_mask("intrstatus", ohci_readl(®s->intrstatus)); in ohci_dump_status()
413 ohci_dump_intr_mask("intrenable", ohci_readl(®s->intrenable)); in ohci_dump_status()
416 ohci_readl(®s->ed_periodcurrent)); in ohci_dump_status()
418 maybe_print_eds("ed_controlhead", ohci_readl(®s->ed_controlhead)); in ohci_dump_status()
420 ohci_readl(®s->ed_controlcurrent)); in ohci_dump_status()
422 maybe_print_eds("ed_bulkhead", ohci_readl(®s->ed_bulkhead)); in ohci_dump_status()
423 maybe_print_eds("ed_bulkcurrent", ohci_readl(®s->ed_bulkcurrent)); in ohci_dump_status()
425 maybe_print_eds("donehead", ohci_readl(®s->donehead)); in ohci_dump_status()
490 dbg("OHCI controller usb-%s state", controller->slot_name); in ohci_dump()
496 invalidate_dcache_hcca(controller->hcca); in ohci_dump()
497 dbg("hcca frame #%04x", controller->hcca->frame_no); in ohci_dump()
502 /*-------------------------------------------------------------------------*
504 *-------------------------------------------------------------------------*/
514 struct usb_device *dev = urb->dev; in sohci_submit_job()
515 unsigned long pipe = urb->pipe; in sohci_submit_job()
516 void *buffer = urb->transfer_buffer; in sohci_submit_job()
517 int transfer_len = urb->transfer_buffer_length; in sohci_submit_job()
518 int interval = urb->interval; in sohci_submit_job()
522 if (ohci->disabled) { in sohci_submit_job()
524 return -1; in sohci_submit_job()
529 urb->finished = 0; in sohci_submit_job()
535 return -1; in sohci_submit_job()
541 size = (transfer_len - 1) / 4096 + 1; in sohci_submit_job()
545 (transfer_len - 1) / 4096 + 3; in sohci_submit_job()
552 ed->purb = urb; in sohci_submit_job()
554 if (size >= (N_URB_TD - 1)) { in sohci_submit_job()
556 return -1; in sohci_submit_job()
558 purb_priv->pipe = pipe; in sohci_submit_job()
561 purb_priv->length = size; in sohci_submit_job()
562 purb_priv->ed = ed; in sohci_submit_job()
563 purb_priv->actual_length = 0; in sohci_submit_job()
568 purb_priv->td[i] = td_alloc(ohci_dev, dev); in sohci_submit_job()
569 if (!purb_priv->td[i]) { in sohci_submit_job()
570 purb_priv->length = i; in sohci_submit_job()
573 return -1; in sohci_submit_job()
577 if (ed->state == ED_NEW || (ed->state & ED_DEL)) { in sohci_submit_job()
580 return -1; in sohci_submit_job()
584 if (ed->state != ED_OPER) in sohci_submit_job()
594 /*-------------------------------------------------------------------------*/
600 invalidate_dcache_hcca(ohci->hcca); in sohci_get_current_frame_number()
601 return m16_swap(ohci->hcca->frame_no); in sohci_get_current_frame_number()
605 /*-------------------------------------------------------------------------*
607 *-------------------------------------------------------------------------*/
622 if (ohci->ohci_int_load [branch] > ohci->ohci_int_load [i]) in ep_int_ballance()
627 ohci->ohci_int_load [i] += load; in ep_int_ballance()
632 /*-------------------------------------------------------------------------*/
634 /* 2^int( ld (inter)) */
636 static int ep_2_n_interval(int inter) in ep_2_n_interval() argument
639 for (i = 0; ((inter >> i) > 1) && (i < 5); i++); in ep_2_n_interval()
643 /*-------------------------------------------------------------------------*/
653 wout |= (((word >> i) & 1) << (num_bits - i - 1)); in ep_rev()
657 /*-------------------------------------------------------------------------*
659 *-------------------------------------------------------------------------*/
668 int inter; in ep_link() local
673 ed->state = ED_OPER; in ep_link()
674 ed->int_interval = 0; in ep_link()
676 switch (ed->type) { in ep_link()
678 ed->hwNextED = 0; in ep_link()
680 if (ohci->ed_controltail == NULL) in ep_link()
681 ohci_writel((uintptr_t)ed, &ohci->regs->ed_controlhead); in ep_link()
683 ohci->ed_controltail->hwNextED = in ep_link()
686 ed->ed_prev = ohci->ed_controltail; in ep_link()
687 if (!ohci->ed_controltail && !ohci->ed_rm_list[0] && in ep_link()
688 !ohci->ed_rm_list[1] && !ohci->sleeping) { in ep_link()
689 ohci->hc_control |= OHCI_CTRL_CLE; in ep_link()
690 ohci_writel(ohci->hc_control, &ohci->regs->control); in ep_link()
692 ohci->ed_controltail = edi; in ep_link()
696 ed->hwNextED = 0; in ep_link()
698 if (ohci->ed_bulktail == NULL) in ep_link()
699 ohci_writel((uintptr_t)ed, &ohci->regs->ed_bulkhead); in ep_link()
701 ohci->ed_bulktail->hwNextED = in ep_link()
704 ed->ed_prev = ohci->ed_bulktail; in ep_link()
705 if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] && in ep_link()
706 !ohci->ed_rm_list[1] && !ohci->sleeping) { in ep_link()
707 ohci->hc_control |= OHCI_CTRL_BLE; in ep_link()
708 ohci_writel(ohci->hc_control, &ohci->regs->control); in ep_link()
710 ohci->ed_bulktail = edi; in ep_link()
714 load = ed->int_load; in ep_link()
715 interval = ep_2_n_interval(ed->int_period); in ep_link()
716 ed->int_interval = interval; in ep_link()
718 ed->int_branch = int_branch; in ep_link()
720 for (i = 0; i < ep_rev(6, interval); i += inter) { in ep_link()
721 inter = 1; in ep_link()
722 for (ed_p = &(ohci->hcca->int_table[\ in ep_link()
725 (((ed_t *)ed_p)->int_interval >= interval); in ep_link()
726 ed_p = &(((ed_t *)ed_p)->hwNextED)) in ep_link()
727 inter = ep_rev(6, in ep_link()
728 ((ed_t *)ed_p)->int_interval); in ep_link()
729 ed->hwNextED = *ed_p; in ep_link()
732 flush_dcache_hcca(ohci->hcca); in ep_link()
739 /*-------------------------------------------------------------------------*/
748 __u32 *ed_p = &ohci->hcca->int_table [index]; in periodic_unlink()
754 *ed_p = ed->hwNextED; in periodic_unlink()
756 aligned_ed_p &= ~(ARCH_DMA_MINALIGN - 1); in periodic_unlink()
762 m32_swap((unsigned long)ed_p))->hwNextED); in periodic_unlink()
777 ed->hwINFO |= m32_swap(OHCI_ED_SKIP); in ep_unlink()
780 switch (ed->type) { in ep_unlink()
782 if (ed->ed_prev == NULL) { in ep_unlink()
783 if (!ed->hwNextED) { in ep_unlink()
784 ohci->hc_control &= ~OHCI_CTRL_CLE; in ep_unlink()
785 ohci_writel(ohci->hc_control, in ep_unlink()
786 &ohci->regs->control); in ep_unlink()
788 ohci_writel(m32_swap(*((__u32 *)&ed->hwNextED)), in ep_unlink()
789 &ohci->regs->ed_controlhead); in ep_unlink()
791 ed->ed_prev->hwNextED = ed->hwNextED; in ep_unlink()
792 flush_dcache_ed(ed->ed_prev); in ep_unlink()
794 if (ohci->ed_controltail == ed) { in ep_unlink()
795 ohci->ed_controltail = ed->ed_prev; in ep_unlink()
798 *((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev; in ep_unlink()
803 if (ed->ed_prev == NULL) { in ep_unlink()
804 if (!ed->hwNextED) { in ep_unlink()
805 ohci->hc_control &= ~OHCI_CTRL_BLE; in ep_unlink()
806 ohci_writel(ohci->hc_control, in ep_unlink()
807 &ohci->regs->control); in ep_unlink()
809 ohci_writel(m32_swap(*((__u32 *)&ed->hwNextED)), in ep_unlink()
810 &ohci->regs->ed_bulkhead); in ep_unlink()
812 ed->ed_prev->hwNextED = ed->hwNextED; in ep_unlink()
813 flush_dcache_ed(ed->ed_prev); in ep_unlink()
815 if (ohci->ed_bulktail == ed) { in ep_unlink()
816 ohci->ed_bulktail = ed->ed_prev; in ep_unlink()
819 *((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev; in ep_unlink()
825 for (i = ed->int_branch; i < 32; i += ed->int_interval) in ep_unlink()
826 ohci->ohci_int_load[i] -= ed->int_load; in ep_unlink()
829 ed->state = ED_UNLINK; in ep_unlink()
833 /*-------------------------------------------------------------------------*/
850 ed = ed_ret = &ohci_dev->ed[(usb_pipeendpoint(pipe) << 1) | in ep_add_ed()
853 if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) { in ep_add_ed()
859 if (ed->state == ED_NEW) { in ep_add_ed()
862 ed->hwTailP = m32_swap((unsigned long)td); in ep_add_ed()
863 ed->hwHeadP = ed->hwTailP; in ep_add_ed()
864 ed->state = ED_UNLINK; in ep_add_ed()
865 ed->type = usb_pipetype(pipe); in ep_add_ed()
866 ohci_dev->ed_cnt++; in ep_add_ed()
869 ed->hwINFO = m32_swap(usb_pipedevice(pipe) in ep_add_ed()
874 | (usb_dev->speed == USB_SPEED_LOW) << 13 in ep_add_ed()
877 if (ed->type == PIPE_INTERRUPT && ed->state == ED_UNLINK) { in ep_add_ed()
878 ed->int_period = interval; in ep_add_ed()
879 ed->int_load = load; in ep_add_ed()
887 /*-------------------------------------------------------------------------*
889 *-------------------------------------------------------------------------*/
894 void *data, int len, in td_fill() argument
902 if (index > urb_priv->length) { in td_fill()
907 td_pt = urb_priv->td [index]; in td_fill()
908 td_pt->hwNextTD = 0; in td_fill()
912 td = urb_priv->td [index] = in td_fill()
914 (m32_swap(urb_priv->ed->hwTailP) & ~0xf); in td_fill()
916 td->ed = urb_priv->ed; in td_fill()
917 td->next_dl_td = NULL; in td_fill()
918 td->index = index; in td_fill()
919 td->data = (uintptr_t)data; in td_fill()
921 if (usb_pipebulk(urb_priv->pipe) && usb_pipeout(urb_priv->pipe)) { in td_fill()
923 printf("td->data[%d] %#2x ", i, ((unsigned char *)td->data)[i]); in td_fill()
928 data = 0; in td_fill()
930 td->hwINFO = m32_swap(info); in td_fill()
931 td->hwCBP = m32_swap((unsigned long)data); in td_fill()
932 if (data) in td_fill()
933 td->hwBE = m32_swap((unsigned long)(data + len - 1)); in td_fill()
935 td->hwBE = 0; in td_fill()
937 td->hwNextTD = m32_swap((unsigned long)td_pt); in td_fill()
941 td->ed->hwTailP = td->hwNextTD; in td_fill()
942 flush_dcache_ed(td->ed); in td_fill()
945 /*-------------------------------------------------------------------------*/
955 void *data; in td_submit_job() local
962 /* OHCI handles the DATA-toggles itself, we just use the USB-toggle in td_submit_job()
971 urb->td_cnt = 0; in td_submit_job()
973 data = buffer; in td_submit_job()
975 data = 0; in td_submit_job()
983 data, 4096, dev, cnt, urb); in td_submit_job()
984 data += 4096; data_len -= 4096; cnt++; in td_submit_job()
988 td_fill(ohci, info | (cnt? TD_T_TOGGLE:toggle), data, in td_submit_job()
992 if (!ohci->sleeping) { in td_submit_job()
994 ohci_writel(OHCI_BLF, &ohci->regs->cmdstatus); in td_submit_job()
1004 /* Optional Data phase */ in td_submit_job()
1010 td_fill(ohci, info, data, data_len, dev, cnt++, urb); in td_submit_job()
1017 td_fill(ohci, info, data, 0, dev, cnt++, urb); in td_submit_job()
1019 if (!ohci->sleeping) { in td_submit_job()
1021 ohci_writel(OHCI_CLF, &ohci->regs->cmdstatus); in td_submit_job()
1026 info = usb_pipeout(urb->pipe)? in td_submit_job()
1029 td_fill(ohci, info, data, data_len, dev, cnt++, urb); in td_submit_job()
1032 if (urb->length != cnt) in td_submit_job()
1033 dbg("TD LENGTH %d != CNT %d", urb->length, cnt); in td_submit_job()
1036 /*-------------------------------------------------------------------------*
1038 *-------------------------------------------------------------------------*/
1045 urb_priv_t *lurb_priv = td->ed->purb; in dl_transfer_length()
1047 tdBE = m32_swap(td->hwBE); in dl_transfer_length()
1048 tdCBP = m32_swap(td->hwCBP); in dl_transfer_length()
1050 if (!(usb_pipecontrol(lurb_priv->pipe) && in dl_transfer_length()
1051 ((td->index == 0) || (td->index == lurb_priv->length - 1)))) { in dl_transfer_length()
1053 if (td->hwCBP == 0) in dl_transfer_length()
1054 lurb_priv->actual_length += tdBE - td->data + 1; in dl_transfer_length()
1056 lurb_priv->actual_length += tdCBP - td->data; in dl_transfer_length()
1061 /*-------------------------------------------------------------------------*/
1064 urb_priv_t *lurb_priv = td_list->ed->purb; in check_status()
1065 int urb_len = lurb_priv->length; in check_status()
1066 __u32 *phwHeadP = &td_list->ed->hwHeadP; in check_status()
1069 cc = TD_CC_GET(m32_swap(td_list->hwINFO)); in check_status()
1071 err(" USB-error: %s (%x)", cc_to_string[cc], cc); in check_status()
1073 invalidate_dcache_ed(td_list->ed); in check_status()
1076 ((td_list->index + 1) < urb_len)) { in check_status()
1078 (lurb_priv->td[urb_len - 1]->hwNextTD &\ in check_status()
1082 lurb_priv->td_cnt += urb_len - in check_status()
1083 td_list->index - 1; in check_status()
1086 flush_dcache_ed(td_list->ed); in check_status()
1092 * we reverse the reversed done-list */
1099 invalidate_dcache_hcca(ohci->hcca); in dl_reverse_done_list()
1100 td_list_hc = m32_swap(ohci->hcca->done_head) & 0xfffffff0; in dl_reverse_done_list()
1101 ohci->hcca->done_head = 0; in dl_reverse_done_list()
1102 flush_dcache_hcca(ohci->hcca); in dl_reverse_done_list()
1108 td_list->next_dl_td = td_rev; in dl_reverse_done_list()
1110 td_list_hc = m32_swap(td_list->hwNextTD) & 0xfffffff0; in dl_reverse_done_list()
1115 /*-------------------------------------------------------------------------*/
1116 /*-------------------------------------------------------------------------*/
1120 if ((status & (ED_OPER | ED_UNLINK)) && (urb->state != URB_DEL)) in finish_urb()
1121 urb->finished = 1; in finish_urb()
1142 tdINFO = m32_swap(td_list->hwINFO); in takeback_td()
1144 ed = td_list->ed; in takeback_td()
1145 lurb_priv = ed->purb; in takeback_td()
1149 lurb_priv->td_cnt++; in takeback_td()
1154 err("USB-error: %s (%x)", cc_to_string[cc], cc); in takeback_td()
1160 if (lurb_priv->td_cnt == lurb_priv->length) in takeback_td()
1161 finish_urb(ohci, lurb_priv, ed->state); in takeback_td()
1164 lurb_priv->td_cnt, lurb_priv->length); in takeback_td()
1166 if (ed->state != ED_NEW && (!usb_pipeint(lurb_priv->pipe))) { in takeback_td()
1168 edHeadP = m32_swap(ed->hwHeadP) & 0xfffffff0; in takeback_td()
1169 edTailP = m32_swap(ed->hwTailP); in takeback_td()
1172 if ((edHeadP == edTailP) && (ed->state == ED_OPER)) in takeback_td()
1184 td_t *td_next = td_list->next_dl_td; in dl_done_list()
1191 /*-------------------------------------------------------------------------*
1193 *-------------------------------------------------------------------------*/
1197 /* Hub class-specific descriptor is constructed dynamically */
1199 /*-------------------------------------------------------------------------*/
1204 &ohci->regs->roothub.status); }
1205 #define WR_RH_PORTSTAT(x) {info("WR:portstatus[%d] %#8x", wIndex-1, \
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])
1213 #define RD_RH_PORTSTAT roothub_portstatus(ohci, wIndex-1)
1222 res = -1; in rh_check_port_status()
1245 void *data = buffer; in ohci_submit_rh_msg() local
1262 info("Root-Hub submit IRQ: NOT implemented"); in ohci_submit_rh_msg()
1266 bmRType_bReq = cmd->requesttype | (cmd->request << 8); in ohci_submit_rh_msg()
1267 wValue = le16_to_cpu(cmd->value); in ohci_submit_rh_msg()
1268 wIndex = le16_to_cpu(cmd->index); in ohci_submit_rh_msg()
1269 wLength = le16_to_cpu(cmd->length); in ohci_submit_rh_msg()
1271 info("Root-Hub: adr: %2x cmd(%1x): %08x %04x %04x %04x", in ohci_submit_rh_msg()
1272 dev->devnum, 8, bmRType_bReq, wValue, wIndex, wLength); in ohci_submit_rh_msg()
1349 ohci->rh.devnum = wValue; in ohci_submit_rh_msg()
1403 if (temp & RH_A_PSM) /* per-port power switching? */ in ohci_submit_rh_msg()
1407 else if (temp & RH_A_OCPM)/* per-port overcurrent reporting? */ in ohci_submit_rh_msg()
1448 if (data != databuf) in ohci_submit_rh_msg()
1449 memcpy(data, databuf, len); in ohci_submit_rh_msg()
1450 dev->act_len = len; in ohci_submit_rh_msg()
1451 dev->status = stat; in ohci_submit_rh_msg()
1463 /*-------------------------------------------------------------------------*/
1470 return &ohci->ohci_dev; in ohci_get_ohci_dev()
1474 if (ohci->int_dev[i].devnum == devnum) in ohci_get_ohci_dev()
1475 return &ohci->int_dev[i]; in ohci_get_ohci_dev()
1480 if (ohci->int_dev[i].devnum == -1) { in ohci_get_ohci_dev()
1481 ohci->int_dev[i].devnum = devnum; in ohci_get_ohci_dev()
1482 return &ohci->int_dev[i]; in ohci_get_ohci_dev()
1490 /* common code for handling submit messages - used for all but root hub */
1503 urb->dev = dev; in ohci_alloc_urb()
1504 urb->pipe = pipe; in ohci_alloc_urb()
1505 urb->transfer_buffer = buffer; in ohci_alloc_urb()
1506 urb->transfer_buffer_length = transfer_len; in ohci_alloc_urb()
1507 urb->interval = interval; in ohci_alloc_urb()
1524 return -ENOMEM; in submit_common_msg()
1527 urb->actual_length = 0; in submit_common_msg()
1536 return -1; in submit_common_msg()
1539 ohci_dev = ohci_get_ohci_dev(ohci, dev->devnum, usb_pipeint(pipe)); in submit_common_msg()
1541 return -ENOMEM; in submit_common_msg()
1545 return -1; in submit_common_msg()
1564 /* NOTE: since we are not interrupt driven in U-Boot and always in submit_common_msg()
1570 * finished we need to re-iterate this loop so as in submit_common_msg()
1573 if ((stat >= 0) && (stat != 0xff) && (urb->finished)) { in submit_common_msg()
1574 /* 0xff is returned for an SF-interrupt */ in submit_common_msg()
1578 if (--timeout) { in submit_common_msg()
1580 if (!urb->finished) in submit_common_msg()
1587 urb->finished = 1; in submit_common_msg()
1593 dev->status = stat; in submit_common_msg()
1594 dev->act_len = urb->actual_length; in submit_common_msg()
1596 if (usb_pipein(pipe) && dev->status == 0 && dev->act_len) in submit_common_msg()
1597 invalidate_dcache_buffer(buffer, dev->act_len); in submit_common_msg()
1628 ohci_dev = ohci_get_ohci_dev(ohci, udev->devnum, 1); in _ohci_create_int_queue()
1639 queue->urb[i] = ohci_alloc_urb(udev, pipe, in _ohci_create_int_queue()
1642 if (!queue->urb[i]) in _ohci_create_int_queue()
1645 if (sohci_submit_job(ohci, ohci_dev, queue->urb[i], NULL)) { in _ohci_create_int_queue()
1647 urb_free_priv(queue->urb[i]); in _ohci_create_int_queue()
1657 queue->queuesize = i; in _ohci_create_int_queue()
1658 queue->curr_urb = 0; in _ohci_create_int_queue()
1666 if (queue->curr_urb == queue->queuesize) in _ohci_poll_int_queue()
1672 if (queue->urb[queue->curr_urb]->finished) { in _ohci_poll_int_queue()
1673 void *ret = queue->urb[queue->curr_urb]->transfer_buffer; in _ohci_poll_int_queue()
1674 queue->curr_urb++; in _ohci_poll_int_queue()
1686 for (i = 0; i < queue->queuesize; i++) in _ohci_destroy_int_queue()
1687 urb_free_priv(queue->urb[i]); in _ohci_destroy_int_queue()
1747 return -1; in _ohci_submit_control_msg()
1749 if (((pipe >> 8) & 0x7f) == ohci->rh.devnum) { in _ohci_submit_control_msg()
1750 ohci->rh.dev = dev; in _ohci_submit_control_msg()
1751 /* root hub - redirect */ in _ohci_submit_control_msg()
1760 /*-------------------------------------------------------------------------*
1762 *-------------------------------------------------------------------------*/
1778 * Some multi-function controllers (e.g. ISP1562) allow root hub in hc_reset()
1782 if (pdev != -1) { in hc_reset()
1791 if (timeout-- <= 0) { in hc_reset()
1800 if (ohci_readl(&ohci->regs->control) & OHCI_CTRL_IR) { in hc_reset()
1802 ohci_writel(OHCI_OCR, &ohci->regs->cmdstatus); in hc_reset()
1804 while (ohci_readl(&ohci->regs->control) & OHCI_CTRL_IR) { in hc_reset()
1806 if (--smm_timeout == 0) { in hc_reset()
1808 return -1; in hc_reset()
1814 ohci_writel(OHCI_INTR_MIE, &ohci->regs->intrdisable); in hc_reset()
1816 dbg("USB HC reset_hc usb-%s: ctrl = 0x%X ;\n", in hc_reset()
1817 ohci->slot_name, in hc_reset()
1818 ohci_readl(&ohci->regs->control)); in hc_reset()
1821 ohci->hc_control = 0; in hc_reset()
1822 ohci_writel(ohci->hc_control, &ohci->regs->control); in hc_reset()
1825 ohci_writel(OHCI_HCR, &ohci->regs->cmdstatus); in hc_reset()
1826 while ((ohci_readl(&ohci->regs->cmdstatus) & OHCI_HCR) != 0) { in hc_reset()
1827 if (--timeout == 0) { in hc_reset()
1829 return -1; in hc_reset()
1836 /*-------------------------------------------------------------------------*/
1848 ohci->disabled = 1; in hc_start()
1850 ohci->int_dev[i].devnum = -1; in hc_start()
1855 ohci_writel(0, &ohci->regs->ed_controlhead); in hc_start()
1856 ohci_writel(0, &ohci->regs->ed_bulkhead); in hc_start()
1858 ohci_writel((uintptr_t)ohci->hcca, in hc_start()
1859 &ohci->regs->hcca); /* reset clears this */ in hc_start()
1862 ohci_writel((fminterval * 9) / 10, &ohci->regs->periodicstart); in hc_start()
1863 fminterval |= ((((fminterval - 210) * 6) / 7) << 16); in hc_start()
1864 ohci_writel(fminterval, &ohci->regs->fminterval); in hc_start()
1865 ohci_writel(0x628, &ohci->regs->lsthresh); in hc_start()
1868 ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER; in hc_start()
1869 ohci->disabled = 0; in hc_start()
1870 ohci_writel(ohci->hc_control, &ohci->regs->control); in hc_start()
1876 ohci_writel(mask, &ohci->regs->intrdisable); in hc_start()
1879 ohci_writel(mask, &ohci->regs->intrstatus); in hc_start()
1880 /* Choose the interrupts we care about now - but w/o MIE */ in hc_start()
1882 ohci_writel(mask, &ohci->regs->intrenable); in hc_start()
1885 /* required for AMD-756 and some Mac platforms */ in hc_start()
1887 &ohci->regs->roothub.a); in hc_start()
1888 ohci_writel(RH_HS_LPSC, &ohci->regs->roothub.status); in hc_start()
1892 ohci->rh.devnum = 0; in hc_start()
1897 /*-------------------------------------------------------------------------*/
1903 struct ohci_regs *regs = ohci->regs; in hc_interrupt()
1905 int stat = -1; in hc_interrupt()
1907 invalidate_dcache_hcca(ohci->hcca); in hc_interrupt()
1909 if ((ohci->hcca->done_head != 0) && in hc_interrupt()
1910 !(m32_swap(ohci->hcca->done_head) & 0x01)) { in hc_interrupt()
1913 ints = ohci_readl(®s->intrstatus); in hc_interrupt()
1915 ohci->disabled++; in hc_interrupt()
1916 err("%s device removed!", ohci->slot_name); in hc_interrupt()
1917 return -1; in hc_interrupt()
1919 ints &= ohci_readl(®s->intrenable); in hc_interrupt()
1928 le16_to_cpu(ohci->hcca->frame_no)); */ in hc_interrupt()
1934 ohci->disabled++; in hc_interrupt()
1935 err("OHCI Unrecoverable Error, controller usb-%s disabled", in hc_interrupt()
1936 ohci->slot_name); in hc_interrupt()
1945 /* Make some non-interrupt context restart the controller. */ in hc_interrupt()
1949 return -1; in hc_interrupt()
1954 ohci_writel(OHCI_INTR_WDH, ®s->intrdisable); in hc_interrupt()
1955 (void)ohci_readl(®s->intrdisable); /* flush */ in hc_interrupt()
1957 ohci_writel(OHCI_INTR_WDH, ®s->intrenable); in hc_interrupt()
1958 (void)ohci_readl(®s->intrdisable); /* flush */ in hc_interrupt()
1963 ohci_writel(OHCI_INTR_SO, ®s->intrenable); in hc_interrupt()
1964 stat = -1; in hc_interrupt()
1969 unsigned int frame = m16_swap(ohci->hcca->frame_no) & 1; in hc_interrupt()
1971 ohci_writel(OHCI_INTR_SF, ®s->intrdisable); in hc_interrupt()
1972 if (ohci->ed_rm_list[frame] != NULL) in hc_interrupt()
1973 ohci_writel(OHCI_INTR_SF, ®s->intrenable); in hc_interrupt()
1977 ohci_writel(ints, ®s->intrstatus); in hc_interrupt()
1981 /*-------------------------------------------------------------------------*/
1985 /*-------------------------------------------------------------------------*/
1987 /* De-allocate all resources.. */
1991 dbg("USB HC release ohci usb-%s", ohci->slot_name); in hc_release_ohci()
1993 if (!ohci->disabled) in hc_release_ohci()
1997 /*-------------------------------------------------------------------------*/
2013 return -1; in usb_lowlevel_init()
2019 return -1; in usb_lowlevel_init()
2026 return -1; in usb_lowlevel_init()
2034 gohci.irq = -1; in usb_lowlevel_init()
2038 if (pdev != -1) { in usb_lowlevel_init()
2050 return -1; in usb_lowlevel_init()
2060 err ("can't reset usb-%s", gohci.slot_name); in usb_lowlevel_init()
2070 return -1; in usb_lowlevel_init()
2074 err("can't start usb-%s", gohci.slot_name); in usb_lowlevel_init()
2086 return -1; in usb_lowlevel_init()
2100 /* this gets called really early - before the controller has */ in usb_lowlevel_stop()
2111 return -1; in usb_lowlevel_stop()
2117 return -1; in usb_lowlevel_stop()
2119 /* This driver is no longer initialised. It needs a new low-level in usb_lowlevel_stop()
2194 priv->desc_before_addr = true; in ohci_register()
2196 ohci->regs = regs; in ohci_register()
2197 ohci->hcca = memalign(256, sizeof(struct ohci_hcca)); in ohci_register()
2198 if (!ohci->hcca) in ohci_register()
2199 return -ENOMEM; in ohci_register()
2200 memset(ohci->hcca, 0, sizeof(struct ohci_hcca)); in ohci_register()
2201 flush_dcache_hcca(ohci->hcca); in ohci_register()
2204 return -EIO; in ohci_register()
2207 return -EIO; in ohci_register()
2209 reg = ohci_readl(®s->revision); in ohci_register()
2220 return -EIO; in ohci_deregister()
2222 free(ohci->hcca); in ohci_deregister()