Lines Matching +full:has +full:- +full:transaction +full:- +full:translator

1 // SPDX-License-Identifier: GPL-2.0
6 * - ISO
7 * - OTG
31 #include "isp1760-core.h"
32 #include "isp1760-hcd.h"
33 #include "isp1760-regs.h"
44 return *(struct isp1760_hcd **)hcd->hcd_priv; in hcd_to_priv()
126 /* the rest is HCD-private */
133 /* QTD_PAYLOAD_ALLOC: chip mem has been allocated for payload */
134 /* QTD_XFER_STARTED: valid ptd has been written to isp176x - only
136 /* QTD_XFER_COMPLETE: payload has been transferred successfully */
178 * HC_MEMORY_REG (see isp176x datasheet). Unless you want to do fancy multi-
185 * doesn't quite work because some people have to enforce 32-bit access
200 bytes -= 4; in bank_reads8()
207 bytes -= 4; in bank_reads8()
230 bytes--; in bank_reads8()
252 bytes -= 4; in mem_writes8()
259 bytes -= 4; in mem_writes8()
294 mem_writes8(base, ptd_offset + slot*sizeof(*ptd) + sizeof(ptd->dw0), in ptd_write()
295 &ptd->dw1, 7*sizeof(ptd->dw1)); in ptd_write()
299 mem_writes8(base, ptd_offset + slot*sizeof(*ptd), &ptd->dw0, in ptd_write()
300 sizeof(ptd->dw0)); in ptd_write()
312 priv->memory_pool[i].start = payload_addr; in init_memory()
313 priv->memory_pool[i].size = BLOCK_1_SIZE; in init_memory()
314 priv->memory_pool[i].free = 1; in init_memory()
315 payload_addr += priv->memory_pool[i].size; in init_memory()
320 priv->memory_pool[curr + i].start = payload_addr; in init_memory()
321 priv->memory_pool[curr + i].size = BLOCK_2_SIZE; in init_memory()
322 priv->memory_pool[curr + i].free = 1; in init_memory()
323 payload_addr += priv->memory_pool[curr + i].size; in init_memory()
328 priv->memory_pool[curr + i].start = payload_addr; in init_memory()
329 priv->memory_pool[curr + i].size = BLOCK_3_SIZE; in init_memory()
330 priv->memory_pool[curr + i].free = 1; in init_memory()
331 payload_addr += priv->memory_pool[curr + i].size; in init_memory()
334 WARN_ON(payload_addr - priv->memory_pool[0].start > PAYLOAD_AREA_SIZE); in init_memory()
342 WARN_ON(qtd->payload_addr); in alloc_mem()
344 if (!qtd->length) in alloc_mem()
348 if (priv->memory_pool[i].size >= qtd->length && in alloc_mem()
349 priv->memory_pool[i].free) { in alloc_mem()
350 priv->memory_pool[i].free = 0; in alloc_mem()
351 qtd->payload_addr = priv->memory_pool[i].start; in alloc_mem()
362 if (!qtd->payload_addr) in free_mem()
366 if (priv->memory_pool[i].start == qtd->payload_addr) { in free_mem()
367 WARN_ON(priv->memory_pool[i].free); in free_mem()
368 priv->memory_pool[i].free = 1; in free_mem()
369 qtd->payload_addr = 0; in free_mem()
374 dev_err(hcd->self.controller, "%s: Invalid pointer: %08x\n", in free_mem()
375 __func__, qtd->payload_addr); in free_mem()
377 qtd->payload_addr = 0; in free_mem()
386 ret = readl_poll_timeout_atomic(hcd->regs + reg, result, in handshake()
390 return -ENODEV; in handshake()
395 /* reset a non-running (STS_HALT == 1) controller */
400 u32 command = reg_read32(hcd->regs, HC_USBCMD); in ehci_reset()
403 reg_write32(hcd->regs, HC_USBCMD, command); in ehci_reset()
404 hcd->state = HC_STATE_HALT; in ehci_reset()
405 priv->next_statechange = jiffies; in ehci_reset()
418 INIT_LIST_HEAD(&qh->qh_list); in qh_alloc()
419 INIT_LIST_HEAD(&qh->qtd_list); in qh_alloc()
420 qh->slot = -1; in qh_alloc()
427 WARN_ON(!list_empty(&qh->qtd_list)); in qh_free()
428 WARN_ON(qh->slot > -1); in qh_free()
432 /* one-time init, only for memory state */
439 spin_lock_init(&priv->lock); in priv_init()
442 INIT_LIST_HEAD(&priv->qh_list[i]); in priv_init()
448 priv->periodic_size = DEFAULT_I_TDPS; in priv_init()
451 hcc_params = reg_read32(hcd->regs, HC_HCCPARAMS); in priv_init()
454 priv->i_thresh = 8; in priv_init()
456 priv->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); in priv_init()
467 reg_write32(hcd->regs, HC_SCRATCH_REG, 0xdeadbabe); in isp1760_hc_setup()
469 scratch = reg_read32(hcd->regs, HC_CHIP_ID_REG); in isp1760_hc_setup()
470 scratch = reg_read32(hcd->regs, HC_SCRATCH_REG); in isp1760_hc_setup()
472 dev_err(hcd->self.controller, "Scratch test failed.\n"); in isp1760_hc_setup()
473 return -ENODEV; in isp1760_hc_setup()
482 * has been reset in core code anyway, so this shouldn't matter. in isp1760_hc_setup()
484 reg_write32(hcd->regs, HC_BUFFER_STATUS_REG, 0); in isp1760_hc_setup()
485 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, NO_TRANSFER_ACTIVE); in isp1760_hc_setup()
486 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, NO_TRANSFER_ACTIVE); in isp1760_hc_setup()
487 reg_write32(hcd->regs, HC_ISO_PTD_SKIPMAP_REG, NO_TRANSFER_ACTIVE); in isp1760_hc_setup()
496 hwmode = reg_read32(hcd->regs, HC_HW_MODE_CTRL) & ~ALL_ATX_RESET; in isp1760_hc_setup()
497 reg_write32(hcd->regs, HC_HW_MODE_CTRL, hwmode | ALL_ATX_RESET); in isp1760_hc_setup()
499 reg_write32(hcd->regs, HC_HW_MODE_CTRL, hwmode); in isp1760_hc_setup()
501 reg_write32(hcd->regs, HC_INTERRUPT_ENABLE, INTERRUPT_ENABLE_MASK); in isp1760_hc_setup()
503 priv->hcs_params = reg_read32(hcd->regs, HC_HCSPARAMS); in isp1760_hc_setup()
510 return ((base - 0x400) >> 3); in base_to_chip()
517 if (list_is_last(&qtd->qtd_list, &qh->qtd_list)) in last_qtd_of_urb()
520 urb = qtd->urb; in last_qtd_of_urb()
521 qtd = list_entry(qtd->qtd_list.next, typeof(*qtd), qtd_list); in last_qtd_of_urb()
522 return (qtd->urb != urb); in last_qtd_of_urb()
526 #define EHCI_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */
529 #define EHCI_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */
544 maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe, in create_ptd_atl()
545 usb_pipeout(qtd->urb->pipe)); in create_ptd_atl()
550 ptd->dw0 = DW0_VALID_BIT; in create_ptd_atl()
551 ptd->dw0 |= TO_DW0_LENGTH(qtd->length); in create_ptd_atl()
552 ptd->dw0 |= TO_DW0_MAXPACKET(maxpacket); in create_ptd_atl()
553 ptd->dw0 |= TO_DW0_ENDPOINT(usb_pipeendpoint(qtd->urb->pipe)); in create_ptd_atl()
556 ptd->dw1 = usb_pipeendpoint(qtd->urb->pipe) >> 1; in create_ptd_atl()
557 ptd->dw1 |= TO_DW1_DEVICE_ADDR(usb_pipedevice(qtd->urb->pipe)); in create_ptd_atl()
558 ptd->dw1 |= TO_DW1_PID_TOKEN(qtd->packet_type); in create_ptd_atl()
560 if (usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
561 ptd->dw1 |= DW1_TRANS_BULK; in create_ptd_atl()
562 else if (usb_pipeint(qtd->urb->pipe)) in create_ptd_atl()
563 ptd->dw1 |= DW1_TRANS_INT; in create_ptd_atl()
565 if (qtd->urb->dev->speed != USB_SPEED_HIGH) { in create_ptd_atl()
566 /* split transaction */ in create_ptd_atl()
568 ptd->dw1 |= DW1_TRANS_SPLIT; in create_ptd_atl()
569 if (qtd->urb->dev->speed == USB_SPEED_LOW) in create_ptd_atl()
570 ptd->dw1 |= DW1_SE_USB_LOSPEED; in create_ptd_atl()
572 ptd->dw1 |= TO_DW1_PORT_NUM(qtd->urb->dev->ttport); in create_ptd_atl()
573 ptd->dw1 |= TO_DW1_HUB_NUM(qtd->urb->dev->tt->hub->devnum); in create_ptd_atl()
576 if (usb_pipeint(qtd->urb->pipe) && in create_ptd_atl()
577 (qtd->urb->dev->speed == USB_SPEED_LOW)) in create_ptd_atl()
578 ptd->dw1 |= 2 << 16; in create_ptd_atl()
583 ptd->dw0 |= TO_DW0_MULTI(multi); in create_ptd_atl()
584 if (usb_pipecontrol(qtd->urb->pipe) || in create_ptd_atl()
585 usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
586 ptd->dw3 |= TO_DW3_PING(qh->ping); in create_ptd_atl()
589 ptd->dw2 = 0; in create_ptd_atl()
590 ptd->dw2 |= TO_DW2_DATA_START_ADDR(base_to_chip(qtd->payload_addr)); in create_ptd_atl()
591 ptd->dw2 |= TO_DW2_RL(rl); in create_ptd_atl()
594 ptd->dw3 |= TO_DW3_NAKCOUNT(nak); in create_ptd_atl()
595 ptd->dw3 |= TO_DW3_DATA_TOGGLE(qh->toggle); in create_ptd_atl()
596 if (usb_pipecontrol(qtd->urb->pipe)) { in create_ptd_atl()
597 if (qtd->data_buffer == qtd->urb->setup_packet) in create_ptd_atl()
598 ptd->dw3 &= ~TO_DW3_DATA_TOGGLE(1); in create_ptd_atl()
600 ptd->dw3 |= TO_DW3_DATA_TOGGLE(1); in create_ptd_atl()
603 ptd->dw3 |= DW3_ACTIVE_BIT; in create_ptd_atl()
605 ptd->dw3 |= TO_DW3_CERR(ERR_COUNTER); in create_ptd_atl()
623 if (qtd->urb->dev->speed == USB_SPEED_HIGH) { in transform_add_int()
624 /* urb->interval is in units of microframes (1/8 ms) */ in transform_add_int()
625 period = qtd->urb->interval >> 3; in transform_add_int()
627 if (qtd->urb->interval > 4) in transform_add_int()
629 interval 1 ms * uFrame-match */ in transform_add_int()
630 else if (qtd->urb->interval > 2) in transform_add_int()
632 else if (qtd->urb->interval > 1) in transform_add_int()
637 /* urb->interval is in units of frames (1 ms) */ in transform_add_int()
638 period = qtd->urb->interval; in transform_add_int()
649 /* ptd->dw5 = 0x1c; */ in transform_add_int()
650 ptd->dw5 = 0xff; /* Execute Complete Split on any uFrame */ in transform_add_int()
656 ptd->dw2 |= period; in transform_add_int()
657 ptd->dw4 = usof; in transform_add_int()
668 __releases(priv->lock) in isp1760_urb_done()
669 __acquires(priv->lock) in isp1760_urb_done()
673 if (!urb->unlinked) { in isp1760_urb_done()
674 if (urb->status == -EINPROGRESS) in isp1760_urb_done()
675 urb->status = 0; in isp1760_urb_done()
678 if (usb_pipein(urb->pipe) && usb_pipetype(urb->pipe) != PIPE_CONTROL) { in isp1760_urb_done()
680 for (ptr = urb->transfer_buffer; in isp1760_urb_done()
681 ptr < urb->transfer_buffer + urb->transfer_buffer_length; in isp1760_urb_done()
688 spin_unlock(&priv->lock); in isp1760_urb_done()
689 usb_hcd_giveback_urb(hcd, urb, urb->status); in isp1760_urb_done()
690 spin_lock(&priv->lock); in isp1760_urb_done()
702 INIT_LIST_HEAD(&qtd->qtd_list); in qtd_alloc()
703 qtd->urb = urb; in qtd_alloc()
704 qtd->packet_type = packet_type; in qtd_alloc()
705 qtd->status = QTD_ENQUEUED; in qtd_alloc()
706 qtd->actual_length = 0; in qtd_alloc()
713 WARN_ON(qtd->payload_addr); in qtd_free()
726 WARN_ON(qtd->length && !qtd->payload_addr); in start_bus_transfer()
729 WARN_ON(qtd->status != QTD_PAYLOAD_ALLOC); in start_bus_transfer()
731 /* Make sure done map has not triggered from some unlinked transfer */ in start_bus_transfer()
733 priv->atl_done_map |= reg_read32(hcd->regs, in start_bus_transfer()
735 priv->atl_done_map &= ~(1 << slot); in start_bus_transfer()
737 priv->int_done_map |= reg_read32(hcd->regs, in start_bus_transfer()
739 priv->int_done_map &= ~(1 << slot); in start_bus_transfer()
742 qh->slot = slot; in start_bus_transfer()
743 qtd->status = QTD_XFER_STARTED; in start_bus_transfer()
747 ptd_write(hcd->regs, ptd_offset, slot, ptd); in start_bus_transfer()
750 skip_map = reg_read32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG); in start_bus_transfer()
751 skip_map &= ~(1 << qh->slot); in start_bus_transfer()
752 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map); in start_bus_transfer()
754 skip_map = reg_read32(hcd->regs, HC_INT_PTD_SKIPMAP_REG); in start_bus_transfer()
755 skip_map &= ~(1 << qh->slot); in start_bus_transfer()
756 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, skip_map); in start_bus_transfer()
762 return (usb_pipebulk(qtd->urb->pipe) && in is_short_bulk()
763 (qtd->actual_length < qtd->length)); in is_short_bulk()
773 list_for_each_entry_safe(qtd, qtd_next, &qh->qtd_list, qtd_list) { in collect_qtds()
774 if (qtd->status < QTD_XFER_COMPLETE) in collect_qtds()
779 if ((!last_qtd) && (qtd->status == QTD_RETIRE)) in collect_qtds()
780 qtd_next->status = QTD_RETIRE; in collect_qtds()
782 if (qtd->status == QTD_XFER_COMPLETE) { in collect_qtds()
783 if (qtd->actual_length) { in collect_qtds()
784 switch (qtd->packet_type) { in collect_qtds()
786 mem_reads8(hcd->regs, qtd->payload_addr, in collect_qtds()
787 qtd->data_buffer, in collect_qtds()
788 qtd->actual_length); in collect_qtds()
791 qtd->urb->actual_length += in collect_qtds()
792 qtd->actual_length; in collect_qtds()
800 if (qtd->urb->transfer_flags & URB_SHORT_NOT_OK) in collect_qtds()
801 qtd->urb->status = -EREMOTEIO; in collect_qtds()
803 qtd_next->status = QTD_RETIRE; in collect_qtds()
807 if (qtd->payload_addr) in collect_qtds()
811 if ((qtd->status == QTD_RETIRE) && in collect_qtds()
812 (qtd->urb->status == -EINPROGRESS)) in collect_qtds()
813 qtd->urb->status = -EPIPE; in collect_qtds()
819 urb_listitem->urb = qtd->urb; in collect_qtds()
820 list_add_tail(&urb_listitem->urb_list, urb_list); in collect_qtds()
823 list_del(&qtd->qtd_list); in collect_qtds()
839 if (unlikely(list_empty(&qh->qtd_list))) { in enqueue_qtds()
845 if (qh->tt_buffer_dirty) in enqueue_qtds()
848 if (usb_pipeint(list_entry(qh->qtd_list.next, struct isp1760_qtd, in enqueue_qtds()
849 qtd_list)->urb->pipe)) { in enqueue_qtds()
851 slots = priv->int_slots; in enqueue_qtds()
854 slots = priv->atl_slots; in enqueue_qtds()
857 free_slot = -1; in enqueue_qtds()
859 if ((free_slot == -1) && (slots[curr_slot].qtd == NULL)) in enqueue_qtds()
866 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) { in enqueue_qtds()
867 if (qtd->status == QTD_ENQUEUED) { in enqueue_qtds()
868 WARN_ON(qtd->payload_addr); in enqueue_qtds()
870 if ((qtd->length) && (!qtd->payload_addr)) in enqueue_qtds()
873 if ((qtd->length) && in enqueue_qtds()
874 ((qtd->packet_type == SETUP_PID) || in enqueue_qtds()
875 (qtd->packet_type == OUT_PID))) { in enqueue_qtds()
876 mem_writes8(hcd->regs, qtd->payload_addr, in enqueue_qtds()
877 qtd->data_buffer, qtd->length); in enqueue_qtds()
880 qtd->status = QTD_PAYLOAD_ALLOC; in enqueue_qtds()
883 if (qtd->status == QTD_PAYLOAD_ALLOC) { in enqueue_qtds()
885 if ((curr_slot > 31) && (free_slot == -1)) in enqueue_qtds()
886 dev_dbg(hcd->self.controller, "%s: No slot " in enqueue_qtds()
890 if ((curr_slot > 31) && (free_slot > -1)) { in enqueue_qtds()
891 if (usb_pipeint(qtd->urb->pipe)) in enqueue_qtds()
928 ep_queue = &priv->qh_list[i]; in schedule_ptds()
931 if (list_empty(&qh->qtd_list)) in schedule_ptds()
932 list_del(&qh->qh_list); in schedule_ptds()
938 isp1760_urb_done(hcd, urb_listitem->urb); in schedule_ptds()
967 ep_queue = &priv->qh_list[i]; in schedule_ptds()
983 dw4 = ptd->dw4; in check_int_transfer()
989 if (ptd->dw3 & DW3_HALT_BIT) { in check_int_transfer()
991 urb->status = -EPROTO; /* Default unknown error */ in check_int_transfer()
996 dev_dbg(hcd->self.controller, "%s: underrun " in check_int_transfer()
999 urb->status = -ECOMM; /* Could not write data */ in check_int_transfer()
1002 dev_dbg(hcd->self.controller, "%s: transaction " in check_int_transfer()
1005 urb->status = -EPROTO; /* timeout, bad CRC, PID in check_int_transfer()
1009 dev_dbg(hcd->self.controller, "%s: babble " in check_int_transfer()
1012 urb->status = -EOVERFLOW; in check_int_transfer()
1028 if (ptd->dw3 & DW3_HALT_BIT) { in check_atl_transfer()
1029 if (ptd->dw3 & DW3_BABBLE_BIT) in check_atl_transfer()
1030 urb->status = -EOVERFLOW; in check_atl_transfer()
1031 else if (FROM_DW3_CERR(ptd->dw3)) in check_atl_transfer()
1032 urb->status = -EPIPE; /* Stall */ in check_atl_transfer()
1034 urb->status = -EPROTO; /* Unknown */ in check_atl_transfer()
1036 dev_dbg(hcd->self.controller, "%s: ptd error:\n" in check_atl_transfer()
1040 ptd->dw0, ptd->dw1, ptd->dw2, ptd->dw3, in check_atl_transfer()
1041 ptd->dw4, ptd->dw5, ptd->dw6, ptd->dw7); in check_atl_transfer()
1046 if ((ptd->dw3 & DW3_ERROR_BIT) && (ptd->dw3 & DW3_ACTIVE_BIT)) { in check_atl_transfer()
1047 /* Transfer Error, *but* active and no HALT -> reload */ in check_atl_transfer()
1048 dev_dbg(hcd->self.controller, "PID error; reloading ptd\n"); in check_atl_transfer()
1052 if (!FROM_DW3_NAKCOUNT(ptd->dw3) && (ptd->dw3 & DW3_ACTIVE_BIT)) { in check_atl_transfer()
1077 skip_map = reg_read32(hcd->regs, HC_INT_PTD_SKIPMAP_REG); in handle_done_ptds()
1078 priv->int_done_map &= ~skip_map; in handle_done_ptds()
1079 skip_map = reg_read32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG); in handle_done_ptds()
1080 priv->atl_done_map &= ~skip_map; in handle_done_ptds()
1082 modified = priv->int_done_map || priv->atl_done_map; in handle_done_ptds()
1084 while (priv->int_done_map || priv->atl_done_map) { in handle_done_ptds()
1085 if (priv->int_done_map) { in handle_done_ptds()
1087 slot = __ffs(priv->int_done_map); in handle_done_ptds()
1088 priv->int_done_map &= ~(1 << slot); in handle_done_ptds()
1089 slots = priv->int_slots; in handle_done_ptds()
1097 ptd_read(hcd->regs, INT_PTD_OFFSET, slot, &ptd); in handle_done_ptds()
1099 slots[slot].qtd->urb); in handle_done_ptds()
1102 slot = __ffs(priv->atl_done_map); in handle_done_ptds()
1103 priv->atl_done_map &= ~(1 << slot); in handle_done_ptds()
1104 slots = priv->atl_slots; in handle_done_ptds()
1112 ptd_read(hcd->regs, ATL_PTD_OFFSET, slot, &ptd); in handle_done_ptds()
1114 slots[slot].qtd->urb); in handle_done_ptds()
1121 qh->slot = -1; in handle_done_ptds()
1123 WARN_ON(qtd->status != QTD_XFER_STARTED); in handle_done_ptds()
1127 if ((usb_pipeint(qtd->urb->pipe)) && in handle_done_ptds()
1128 (qtd->urb->dev->speed != USB_SPEED_HIGH)) in handle_done_ptds()
1129 qtd->actual_length = in handle_done_ptds()
1132 qtd->actual_length = in handle_done_ptds()
1135 qtd->status = QTD_XFER_COMPLETE; in handle_done_ptds()
1136 if (list_is_last(&qtd->qtd_list, &qh->qtd_list) || in handle_done_ptds()
1140 qtd = list_entry(qtd->qtd_list.next, in handle_done_ptds()
1143 qh->toggle = FROM_DW3_DATA_TOGGLE(ptd.dw3); in handle_done_ptds()
1144 qh->ping = FROM_DW3_PING(ptd.dw3); in handle_done_ptds()
1148 qtd->status = QTD_PAYLOAD_ALLOC; in handle_done_ptds()
1155 qh->toggle = FROM_DW3_DATA_TOGGLE(ptd.dw3); in handle_done_ptds()
1156 qh->ping = FROM_DW3_PING(ptd.dw3); in handle_done_ptds()
1160 qtd->status = QTD_RETIRE; in handle_done_ptds()
1161 if ((qtd->urb->dev->speed != USB_SPEED_HIGH) && in handle_done_ptds()
1162 (qtd->urb->status != -EPIPE) && in handle_done_ptds()
1163 (qtd->urb->status != -EREMOTEIO)) { in handle_done_ptds()
1164 qh->tt_buffer_dirty = 1; in handle_done_ptds()
1165 if (usb_hub_clear_tt_buffer(qtd->urb)) in handle_done_ptds()
1168 qh->tt_buffer_dirty = 0; in handle_done_ptds()
1171 qh->toggle = 0; in handle_done_ptds()
1172 qh->ping = 0; in handle_done_ptds()
1180 if (qtd && (qtd->status == QTD_PAYLOAD_ALLOC)) { in handle_done_ptds()
1181 if (slots == priv->int_slots) { in handle_done_ptds()
1183 dev_err(hcd->self.controller, in handle_done_ptds()
1208 spin_lock(&priv->lock); in isp1760_irq()
1210 if (!(hcd->state & HC_STATE_RUNNING)) in isp1760_irq()
1213 imask = reg_read32(hcd->regs, HC_INTERRUPT_REG); in isp1760_irq()
1216 reg_write32(hcd->regs, HC_INTERRUPT_REG, imask); /* Clear */ in isp1760_irq()
1218 priv->int_done_map |= reg_read32(hcd->regs, HC_INT_PTD_DONEMAP_REG); in isp1760_irq()
1219 priv->atl_done_map |= reg_read32(hcd->regs, HC_ATL_PTD_DONEMAP_REG); in isp1760_irq()
1225 spin_unlock(&priv->lock); in isp1760_irq()
1236 * enabling ATL interrupts also causes the chip to sometimes - rarely - "forget"
1240 * done bit is not being set. This is bad - it blocks the endpoint until reboot.
1268 spin_lock_irqsave(&priv->lock, spinflags); in errata2_function()
1271 if (priv->atl_slots[slot].qh && time_after(jiffies, in errata2_function()
1272 priv->atl_slots[slot].timestamp + in errata2_function()
1274 ptd_read(hcd->regs, ATL_PTD_OFFSET, slot, &ptd); in errata2_function()
1277 priv->atl_done_map |= 1 << slot; in errata2_function()
1280 if (priv->atl_done_map) in errata2_function()
1283 spin_unlock_irqrestore(&priv->lock, spinflags); in errata2_function()
1296 hcd->uses_new_polling = 1; in isp1760_run()
1298 hcd->state = HC_STATE_RUNNING; in isp1760_run()
1301 reg_write32(hcd->regs, HC_ATL_IRQ_MASK_AND_REG, 0); in isp1760_run()
1302 reg_write32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG, 0xffffffff); in isp1760_run()
1303 reg_write32(hcd->regs, HC_INT_IRQ_MASK_AND_REG, 0); in isp1760_run()
1304 reg_write32(hcd->regs, HC_INT_IRQ_MASK_OR_REG, 0xffffffff); in isp1760_run()
1305 reg_write32(hcd->regs, HC_ISO_IRQ_MASK_AND_REG, 0); in isp1760_run()
1306 reg_write32(hcd->regs, HC_ISO_IRQ_MASK_OR_REG, 0xffffffff); in isp1760_run()
1309 temp = reg_read32(hcd->regs, HC_HW_MODE_CTRL); in isp1760_run()
1310 reg_write32(hcd->regs, HC_HW_MODE_CTRL, temp | HW_GLOBAL_INTR_EN); in isp1760_run()
1312 command = reg_read32(hcd->regs, HC_USBCMD); in isp1760_run()
1315 reg_write32(hcd->regs, HC_USBCMD, command); in isp1760_run()
1327 reg_write32(hcd->regs, HC_CONFIGFLAG, FLAG_CF); in isp1760_run()
1339 chipid = reg_read32(hcd->regs, HC_CHIP_ID_REG); in isp1760_run()
1340 dev_info(hcd->self.controller, "USB ISP %04x HW rev. %d started\n", in isp1760_run()
1346 reg_write32(hcd->regs, HC_ATL_PTD_LASTPTD_REG, 0x80000000); in isp1760_run()
1347 reg_write32(hcd->regs, HC_INT_PTD_LASTPTD_REG, 0x80000000); in isp1760_run()
1348 reg_write32(hcd->regs, HC_ISO_PTD_LASTPTD_REG, 0x00000001); in isp1760_run()
1349 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, 0xffffffff); in isp1760_run()
1350 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, 0xffffffff); in isp1760_run()
1351 reg_write32(hcd->regs, HC_ISO_PTD_SKIPMAP_REG, 0xffffffff); in isp1760_run()
1352 reg_write32(hcd->regs, HC_BUFFER_STATUS_REG, in isp1760_run()
1355 /* GRR this is run-once init(), being done every time the HC starts. in isp1760_run()
1364 qtd->data_buffer = databuffer; in qtd_fill()
1368 qtd->length = len; in qtd_fill()
1370 return qtd->length; in qtd_fill()
1378 list_del(&qtd->qtd_list); in qtd_list_free()
1384 * Packetize urb->transfer_buffer into list of packets of size wMaxPacketSize.
1397 * URBs map to sequences of QTDs: one logical transaction in packetize_urb()
1400 if (!urb->transfer_buffer && urb->transfer_buffer_length) { in packetize_urb()
1402 dev_err(hcd->self.controller, in packetize_urb()
1404 (long unsigned)urb->transfer_dma, in packetize_urb()
1405 urb->transfer_buffer_length); in packetize_urb()
1409 if (usb_pipein(urb->pipe)) in packetize_urb()
1414 if (usb_pipecontrol(urb->pipe)) { in packetize_urb()
1418 qtd_fill(qtd, urb->setup_packet, sizeof(struct usb_ctrlrequest)); in packetize_urb()
1419 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1422 if (urb->transfer_buffer_length == 0) in packetize_urb()
1426 maxpacketsize = max_packet(usb_maxpacket(urb->dev, urb->pipe, in packetize_urb()
1427 usb_pipeout(urb->pipe))); in packetize_urb()
1434 buf = urb->transfer_buffer; in packetize_urb()
1435 len = urb->transfer_buffer_length; in packetize_urb()
1444 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1446 len -= this_qtd_len; in packetize_urb()
1457 if (urb->transfer_buffer_length != 0) { in packetize_urb()
1460 if (usb_pipecontrol(urb->pipe)) { in packetize_urb()
1466 } else if (usb_pipebulk(urb->pipe) in packetize_urb()
1467 && (urb->transfer_flags & URB_ZERO_PACKET) in packetize_urb()
1468 && !(urb->transfer_buffer_length % in packetize_urb()
1479 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1500 switch (usb_pipetype(urb->pipe)) { in isp1760_urb_enqueue()
1502 ep_queue = &priv->qh_list[QH_CONTROL]; in isp1760_urb_enqueue()
1505 ep_queue = &priv->qh_list[QH_BULK]; in isp1760_urb_enqueue()
1508 if (urb->interval < 0) in isp1760_urb_enqueue()
1509 return -EINVAL; in isp1760_urb_enqueue()
1511 ep_queue = &priv->qh_list[QH_INTERRUPT]; in isp1760_urb_enqueue()
1514 dev_err(hcd->self.controller, "%s: isochronous USB packets " in isp1760_urb_enqueue()
1517 return -EPIPE; in isp1760_urb_enqueue()
1519 dev_err(hcd->self.controller, "%s: unknown pipe type\n", in isp1760_urb_enqueue()
1521 return -EPIPE; in isp1760_urb_enqueue()
1524 if (usb_pipein(urb->pipe)) in isp1760_urb_enqueue()
1525 urb->actual_length = 0; in isp1760_urb_enqueue()
1529 return -ENOMEM; in isp1760_urb_enqueue()
1532 spin_lock_irqsave(&priv->lock, spinflags); in isp1760_urb_enqueue()
1534 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { in isp1760_urb_enqueue()
1535 retval = -ESHUTDOWN; in isp1760_urb_enqueue()
1545 qh = urb->ep->hcpriv; in isp1760_urb_enqueue()
1555 list_add_tail(&qh->qh_list, ep_queue); in isp1760_urb_enqueue()
1559 retval = -ENOMEM; in isp1760_urb_enqueue()
1564 list_add_tail(&qh->qh_list, ep_queue); in isp1760_urb_enqueue()
1565 urb->ep->hcpriv = qh; in isp1760_urb_enqueue()
1568 list_splice_tail(&new_qtds, &qh->qtd_list); in isp1760_urb_enqueue()
1572 spin_unlock_irqrestore(&priv->lock, spinflags); in isp1760_urb_enqueue()
1582 WARN_ON(qh->slot == -1); in kill_transfer()
1586 if (usb_pipecontrol(urb->pipe) || usb_pipebulk(urb->pipe)) { in kill_transfer()
1587 skip_map = reg_read32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG); in kill_transfer()
1588 skip_map |= (1 << qh->slot); in kill_transfer()
1589 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map); in kill_transfer()
1590 priv->atl_slots[qh->slot].qh = NULL; in kill_transfer()
1591 priv->atl_slots[qh->slot].qtd = NULL; in kill_transfer()
1593 skip_map = reg_read32(hcd->regs, HC_INT_PTD_SKIPMAP_REG); in kill_transfer()
1594 skip_map |= (1 << qh->slot); in kill_transfer()
1595 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, skip_map); in kill_transfer()
1596 priv->int_slots[qh->slot].qh = NULL; in kill_transfer()
1597 priv->int_slots[qh->slot].qtd = NULL; in kill_transfer()
1600 qh->slot = -1; in kill_transfer()
1613 urb = qtd->urb; in dequeue_urb_from_qtd()
1615 list_for_each_entry_from(qtd, &qh->qtd_list, qtd_list) { in dequeue_urb_from_qtd()
1616 if (qtd->urb != urb) in dequeue_urb_from_qtd()
1619 if (qtd->status >= QTD_XFER_STARTED) in dequeue_urb_from_qtd()
1622 (qtd->status >= QTD_XFER_COMPLETE)) in dequeue_urb_from_qtd()
1625 if (qtd->status == QTD_XFER_STARTED) in dequeue_urb_from_qtd()
1627 qtd->status = QTD_RETIRE; in dequeue_urb_from_qtd()
1630 if ((urb->dev->speed != USB_SPEED_HIGH) && urb_was_running) { in dequeue_urb_from_qtd()
1631 qh->tt_buffer_dirty = 1; in dequeue_urb_from_qtd()
1634 qh->tt_buffer_dirty = 0; in dequeue_urb_from_qtd()
1647 spin_lock_irqsave(&priv->lock, spinflags); in isp1760_urb_dequeue()
1652 qh = urb->ep->hcpriv; in isp1760_urb_dequeue()
1654 retval = -EINVAL; in isp1760_urb_dequeue()
1658 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) in isp1760_urb_dequeue()
1659 if (qtd->urb == urb) { in isp1760_urb_dequeue()
1661 list_move(&qtd->qtd_list, &qh->qtd_list); in isp1760_urb_dequeue()
1665 urb->status = status; in isp1760_urb_dequeue()
1669 spin_unlock_irqrestore(&priv->lock, spinflags); in isp1760_urb_dequeue()
1681 spin_lock_irqsave(&priv->lock, spinflags); in isp1760_endpoint_disable()
1683 qh = ep->hcpriv; in isp1760_endpoint_disable()
1687 WARN_ON(!list_empty(&qh->qtd_list)); in isp1760_endpoint_disable()
1690 list_for_each_entry(qh_iter, &priv->qh_list[i], qh_list) in isp1760_endpoint_disable()
1692 list_del(&qh_iter->qh_list); in isp1760_endpoint_disable()
1697 ep->hcpriv = NULL; in isp1760_endpoint_disable()
1702 spin_unlock_irqrestore(&priv->lock, spinflags); in isp1760_endpoint_disable()
1714 if (!HC_IS_RUNNING(hcd->state)) in isp1760_hub_status_data()
1717 /* init status to no-changes */ in isp1760_hub_status_data()
1721 spin_lock_irqsave(&priv->lock, flags); in isp1760_hub_status_data()
1722 temp = reg_read32(hcd->regs, HC_PORTSC1); in isp1760_hub_status_data()
1727 reg_write32(hcd->regs, HC_PORTSC1, temp); in isp1760_hub_status_data()
1735 * high-speed device is switched over to the companion in isp1760_hub_status_data()
1742 priv->reset_done))) { in isp1760_hub_status_data()
1748 spin_unlock_irqrestore(&priv->lock, flags); in isp1760_hub_status_data()
1755 int ports = HCS_N_PORTS(priv->hcs_params); in isp1760_hub_descriptor()
1758 desc->bDescriptorType = USB_DT_HUB; in isp1760_hub_descriptor()
1760 desc->bPwrOn2PwrGood = 10; in isp1760_hub_descriptor()
1761 desc->bHubContrCurrent = 0; in isp1760_hub_descriptor()
1763 desc->bNbrPorts = ports; in isp1760_hub_descriptor()
1765 desc->bDescLength = 7 + 2 * temp; in isp1760_hub_descriptor()
1768 memset(&desc->u.hs.DeviceRemovable[0], 0, temp); in isp1760_hub_descriptor()
1769 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); in isp1760_hub_descriptor()
1771 /* per-port overcurrent reporting */ in isp1760_hub_descriptor()
1773 if (HCS_PPC(priv->hcs_params)) in isp1760_hub_descriptor()
1774 /* per-port power control */ in isp1760_hub_descriptor()
1779 desc->wHubCharacteristics = cpu_to_le16(temp); in isp1760_hub_descriptor()
1790 /* if reset finished and it's still not enabled -- handoff */ in check_reset_complete()
1793 dev_info(hcd->self.controller, in check_reset_complete()
1794 "port %d full speed --> companion\n", in check_reset_complete()
1799 reg_write32(hcd->regs, HC_PORTSC1, port_status); in check_reset_complete()
1802 dev_info(hcd->self.controller, "port %d high speed\n", in check_reset_complete()
1812 int ports = HCS_N_PORTS(priv->hcs_params); in isp1760_hub_control()
1824 spin_lock_irqsave(&priv->lock, flags); in isp1760_hub_control()
1830 /* no hub-wide feature/status flags */ in isp1760_hub_control()
1839 wIndex--; in isp1760_hub_control()
1840 temp = reg_read32(hcd->regs, HC_PORTSC1); in isp1760_hub_control()
1845 * the port-change status bits (especially in isp1760_hub_control()
1851 reg_write32(hcd->regs, HC_PORTSC1, temp & ~PORT_PE); in isp1760_hub_control()
1865 reg_write32(hcd->regs, HC_PORTSC1, in isp1760_hub_control()
1867 priv->reset_done = jiffies + in isp1760_hub_control()
1872 /* we auto-clear this feature */ in isp1760_hub_control()
1875 if (HCS_PPC(priv->hcs_params)) in isp1760_hub_control()
1876 reg_write32(hcd->regs, HC_PORTSC1, in isp1760_hub_control()
1880 reg_write32(hcd->regs, HC_PORTSC1, temp | PORT_CSC); in isp1760_hub_control()
1891 reg_read32(hcd->regs, HC_USBCMD); in isp1760_hub_control()
1898 /* no hub-wide feature/status flags */ in isp1760_hub_control()
1904 wIndex--; in isp1760_hub_control()
1906 temp = reg_read32(hcd->regs, HC_PORTSC1); in isp1760_hub_control()
1915 dev_err(hcd->self.controller, "Port resume should be skipped.\n"); in isp1760_hub_control()
1918 if (!priv->reset_done) { in isp1760_hub_control()
1920 priv->reset_done = jiffies in isp1760_hub_control()
1923 mod_timer(&hcd->rh_timer, priv->reset_done); in isp1760_hub_control()
1928 priv->reset_done)) { in isp1760_hub_control()
1930 priv->reset_done = 0; in isp1760_hub_control()
1933 temp = reg_read32(hcd->regs, HC_PORTSC1); in isp1760_hub_control()
1934 reg_write32(hcd->regs, HC_PORTSC1, in isp1760_hub_control()
1939 dev_err(hcd->self.controller, in isp1760_hub_control()
1951 priv->reset_done)) { in isp1760_hub_control()
1953 priv->reset_done = 0; in isp1760_hub_control()
1956 reg_write32(hcd->regs, HC_PORTSC1, temp & ~PORT_RESET); in isp1760_hub_control()
1963 dev_err(hcd->self.controller, "port %d reset error %d\n", in isp1760_hub_control()
1970 reg_read32(hcd->regs, HC_PORTSC1)); in isp1760_hub_control()
1979 dev_err(hcd->self.controller, "PORT_OWNER is set\n"); in isp1760_hub_control()
2001 /* no hub-wide feature/status flags */ in isp1760_hub_control()
2011 wIndex--; in isp1760_hub_control()
2012 temp = reg_read32(hcd->regs, HC_PORTSC1); in isp1760_hub_control()
2019 reg_write32(hcd->regs, HC_PORTSC1, temp | PORT_PE); in isp1760_hub_control()
2027 reg_write32(hcd->regs, HC_PORTSC1, temp | PORT_SUSPEND); in isp1760_hub_control()
2030 if (HCS_PPC(priv->hcs_params)) in isp1760_hub_control()
2031 reg_write32(hcd->regs, HC_PORTSC1, in isp1760_hub_control()
2038 * which can be fine if this root hub has a in isp1760_hub_control()
2039 * transaction translator built in. in isp1760_hub_control()
2052 priv->reset_done = jiffies + in isp1760_hub_control()
2055 reg_write32(hcd->regs, HC_PORTSC1, temp); in isp1760_hub_control()
2060 reg_read32(hcd->regs, HC_USBCMD); in isp1760_hub_control()
2066 retval = -EPIPE; in isp1760_hub_control()
2068 spin_unlock_irqrestore(&priv->lock, flags); in isp1760_hub_control()
2077 fr = reg_read32(hcd->regs, HC_FRINDEX); in isp1760_get_frame()
2078 return (fr >> 3) % priv->periodic_size; in isp1760_get_frame()
2092 spin_lock_irq(&priv->lock); in isp1760_stop()
2095 temp = reg_read32(hcd->regs, HC_HW_MODE_CTRL); in isp1760_stop()
2096 reg_write32(hcd->regs, HC_HW_MODE_CTRL, temp &= ~HW_GLOBAL_INTR_EN); in isp1760_stop()
2097 spin_unlock_irq(&priv->lock); in isp1760_stop()
2099 reg_write32(hcd->regs, HC_CONFIGFLAG, 0); in isp1760_stop()
2107 temp = reg_read32(hcd->regs, HC_HW_MODE_CTRL); in isp1760_shutdown()
2108 reg_write32(hcd->regs, HC_HW_MODE_CTRL, temp &= ~HW_GLOBAL_INTR_EN); in isp1760_shutdown()
2110 command = reg_read32(hcd->regs, HC_USBCMD); in isp1760_shutdown()
2112 reg_write32(hcd->regs, HC_USBCMD, command); in isp1760_shutdown()
2119 struct isp1760_qh *qh = ep->hcpriv; in isp1760_clear_tt_buffer_complete()
2125 spin_lock_irqsave(&priv->lock, spinflags); in isp1760_clear_tt_buffer_complete()
2126 qh->tt_buffer_dirty = 0; in isp1760_clear_tt_buffer_complete()
2128 spin_unlock_irqrestore(&priv->lock, spinflags); in isp1760_clear_tt_buffer_complete()
2133 .description = "isp1760-hcd",
2158 return -ENOMEM; in isp1760_init_kmem_once()
2165 return -ENOMEM; in isp1760_init_kmem_once()
2172 return -ENOMEM; in isp1760_init_kmem_once()
2194 return -ENOMEM; in isp1760_hcd_register()
2196 *(struct isp1760_hcd **)hcd->hcd_priv = priv; in isp1760_hcd_register()
2198 priv->hcd = hcd; in isp1760_hcd_register()
2202 hcd->irq = irq; in isp1760_hcd_register()
2203 hcd->regs = regs; in isp1760_hcd_register()
2204 hcd->rsrc_start = mem->start; in isp1760_hcd_register()
2205 hcd->rsrc_len = resource_size(mem); in isp1760_hcd_register()
2208 hcd->cant_recv_wakeups = 1; in isp1760_hcd_register()
2214 device_wakeup_enable(hcd->self.controller); in isp1760_hcd_register()
2225 if (!priv->hcd) in isp1760_hcd_unregister()
2228 usb_remove_hcd(priv->hcd); in isp1760_hcd_unregister()
2229 usb_put_hcd(priv->hcd); in isp1760_hcd_unregister()