Lines Matching +full:autosuspend +full:- +full:period
1 // SPDX-License-Identifier: GPL-2.0
6 * - ISO
7 * - OTG
33 #include "isp1760-core.h"
34 #include "isp1760-hcd.h"
35 #include "isp1760-regs.h"
46 return *(struct isp1760_hcd **)hcd->hcd_priv; in hcd_to_priv()
150 /* the rest is HCD-private */
158 /* QTD_XFER_STARTED: valid ptd has been written to isp176x - only
204 return isp1760_field_read(priv->fields, field); in isp1760_hcd_read()
215 u16 portsc1_reg = priv->is_isp1763 ? ISP1763_HC_PORTSC1 : in isp1760_hcd_portsc1_set_clear()
217 u32 port_status = readl(priv->base + portsc1_reg); in isp1760_hcd_portsc1_set_clear()
220 writel(port_status | bit, priv->base + portsc1_reg); in isp1760_hcd_portsc1_set_clear()
222 writel(port_status & ~bit, priv->base + portsc1_reg); in isp1760_hcd_portsc1_set_clear()
232 isp1760_field_write(priv->fields, field, val); in isp1760_hcd_write()
253 return regmap_field_read_poll_timeout(priv->fields[field], val, in isp1760_hcd_set_and_wait()
265 return regmap_field_read_poll_timeout(priv->fields[field], val, in isp1760_hcd_set_and_wait_swap()
277 return regmap_field_read_poll_timeout(priv->fields[field], val, in isp1760_hcd_clear_and_wait()
290 if (priv->is_isp1763) in isp1760_hcd_ppc_is_set()
300 if (priv->is_isp1763) in isp1760_hcd_n_ports()
310 * HC_MEMORY_REG (see isp176x datasheet). Unless you want to do fancy multi-
317 * doesn't quite work because some people have to enforce 32-bit access
332 bytes -= 4; in bank_reads8()
339 bytes -= 4; in bank_reads8()
362 bytes--; in bank_reads8()
371 isp1760_reg_write(priv->regs, ISP176x_HC_MEMORY, src_offset); in isp1760_mem_read()
374 bank_reads8(priv->base, src_offset, ISP_BANK_0, dst, bytes); in isp1760_mem_read()
388 isp1760_reg_write(priv->regs, ISP1763_HC_MEMORY, srcaddr); in isp1763_mem_read()
391 /* As long there are at least 16-bit to read ... */ in isp1763_mem_read()
393 *dstptr = __raw_readw(priv->base + ISP1763_HC_DATA); in isp1763_mem_read()
394 bytes -= 2; in isp1763_mem_read()
402 *((u8 *)dstptr) = (u8)(readw(priv->base + ISP1763_HC_DATA) & 0xFF); in isp1763_mem_read()
410 if (!priv->is_isp1763) in mem_read()
426 bytes -= 4; in isp1760_mem_write()
433 bytes -= 4; in isp1760_mem_write()
457 isp1760_reg_write(priv->regs, ISP1763_HC_MEMORY, dstaddr); in isp1763_mem_write()
462 __raw_writew(*src, priv->base + ISP1763_HC_DATA); in isp1763_mem_write()
463 bytes -= 2; in isp1763_mem_write()
475 writew(*((u8 *)src), priv->base + ISP1763_HC_DATA); in isp1763_mem_write()
483 if (!priv->is_isp1763) in mem_write()
484 return isp1760_mem_write(priv->base, dst_offset, src, bytes); in mem_write()
499 isp1760_reg_write(priv->regs, ISP176x_HC_MEMORY, src_offset); in isp1760_ptd_read()
502 bank_reads8(priv->base, src_offset, ISP_BANK_0, (void *)ptd, in isp1760_ptd_read()
514 ptd->dw0 = le32_to_dw(le32_ptd.dw0); in isp1763_ptd_read()
515 ptd->dw1 = le32_to_dw(le32_ptd.dw1); in isp1763_ptd_read()
516 ptd->dw2 = le32_to_dw(le32_ptd.dw2); in isp1763_ptd_read()
517 ptd->dw3 = le32_to_dw(le32_ptd.dw3); in isp1763_ptd_read()
518 ptd->dw4 = le32_to_dw(le32_ptd.dw4); in isp1763_ptd_read()
519 ptd->dw5 = le32_to_dw(le32_ptd.dw5); in isp1763_ptd_read()
520 ptd->dw6 = le32_to_dw(le32_ptd.dw6); in isp1763_ptd_read()
521 ptd->dw7 = le32_to_dw(le32_ptd.dw7); in isp1763_ptd_read()
529 if (!priv->is_isp1763) in ptd_read()
541 ptd.dw0 = dw_to_le32(cpu_ptd->dw0); in isp1763_ptd_write()
542 ptd.dw1 = dw_to_le32(cpu_ptd->dw1); in isp1763_ptd_write()
543 ptd.dw2 = dw_to_le32(cpu_ptd->dw2); in isp1763_ptd_write()
544 ptd.dw3 = dw_to_le32(cpu_ptd->dw3); in isp1763_ptd_write()
545 ptd.dw4 = dw_to_le32(cpu_ptd->dw4); in isp1763_ptd_write()
546 ptd.dw5 = dw_to_le32(cpu_ptd->dw5); in isp1763_ptd_write()
547 ptd.dw6 = dw_to_le32(cpu_ptd->dw6); in isp1763_ptd_write()
548 ptd.dw7 = dw_to_le32(cpu_ptd->dw7); in isp1763_ptd_write()
563 isp1760_mem_write(base, dst_offset + sizeof(ptd->dw0), in isp1760_ptd_write()
564 (__force u32 *)&ptd->dw1, 7 * sizeof(ptd->dw1)); in isp1760_ptd_write()
566 isp1760_mem_write(base, dst_offset, (__force u32 *)&ptd->dw0, in isp1760_ptd_write()
567 sizeof(ptd->dw0)); in isp1760_ptd_write()
575 if (!priv->is_isp1763) in ptd_write()
576 return isp1760_ptd_write(priv->base, ptd_offset, slot, ptd); in ptd_write()
584 const struct isp1760_memory_layout *mem = priv->memory_layout; in init_memory()
590 for (i = 0, curr = 0; i < ARRAY_SIZE(mem->blocks); i++, curr += j) { in init_memory()
591 for (j = 0; j < mem->blocks[i]; j++) { in init_memory()
592 priv->memory_pool[curr + j].start = payload_addr; in init_memory()
593 priv->memory_pool[curr + j].size = mem->blocks_size[i]; in init_memory()
594 priv->memory_pool[curr + j].free = 1; in init_memory()
595 payload_addr += priv->memory_pool[curr + j].size; in init_memory()
599 WARN_ON(payload_addr - priv->memory_pool[0].start > in init_memory()
600 mem->payload_area_size); in init_memory()
606 const struct isp1760_memory_layout *mem = priv->memory_layout; in alloc_mem()
609 WARN_ON(qtd->payload_addr); in alloc_mem()
611 if (!qtd->length) in alloc_mem()
614 for (i = 0; i < mem->payload_blocks; i++) { in alloc_mem()
615 if (priv->memory_pool[i].size >= qtd->length && in alloc_mem()
616 priv->memory_pool[i].free) { in alloc_mem()
617 priv->memory_pool[i].free = 0; in alloc_mem()
618 qtd->payload_addr = priv->memory_pool[i].start; in alloc_mem()
627 const struct isp1760_memory_layout *mem = priv->memory_layout; in free_mem()
630 if (!qtd->payload_addr) in free_mem()
633 for (i = 0; i < mem->payload_blocks; i++) { in free_mem()
634 if (priv->memory_pool[i].start == qtd->payload_addr) { in free_mem()
635 WARN_ON(priv->memory_pool[i].free); in free_mem()
636 priv->memory_pool[i].free = 1; in free_mem()
637 qtd->payload_addr = 0; in free_mem()
642 dev_err(hcd->self.controller, "%s: Invalid pointer: %08x\n", in free_mem()
643 __func__, qtd->payload_addr); in free_mem()
645 qtd->payload_addr = 0; in free_mem()
648 /* reset a non-running (STS_HALT == 1) controller */
653 hcd->state = HC_STATE_HALT; in ehci_reset()
654 priv->next_statechange = jiffies; in ehci_reset()
667 INIT_LIST_HEAD(&qh->qh_list); in qh_alloc()
668 INIT_LIST_HEAD(&qh->qtd_list); in qh_alloc()
669 qh->slot = -1; in qh_alloc()
676 WARN_ON(!list_empty(&qh->qtd_list)); in qh_free()
677 WARN_ON(qh->slot > -1); in qh_free()
681 /* one-time init, only for memory state */
689 spin_lock_init(&priv->lock); in priv_init()
692 INIT_LIST_HEAD(&priv->qh_list[i]); in priv_init()
698 priv->periodic_size = DEFAULT_I_TDPS; in priv_init()
700 if (priv->is_isp1763) { in priv_init()
701 priv->i_thresh = 2; in priv_init()
711 priv->i_thresh = 8; in priv_init()
713 priv->i_thresh = 2 + isoc_thres; in priv_init()
726 if (priv->is_isp1763) in isp1760_hc_setup()
740 dev_err(hcd->self.controller, "Scratch test failed. 0x%08x\n", in isp1760_hc_setup()
742 return -ENODEV; in isp1760_hc_setup()
768 if (priv->is_isp1763) in isp1760_hc_setup()
777 if (priv->is_isp1763) { in isp1760_hc_setup()
794 return ((base - 0x400) >> 3); in base_to_chip()
801 if (list_is_last(&qtd->qtd_list, &qh->qtd_list)) in last_qtd_of_urb()
804 urb = qtd->urb; in last_qtd_of_urb()
805 qtd = list_entry(qtd->qtd_list.next, typeof(*qtd), qtd_list); in last_qtd_of_urb()
806 return (qtd->urb != urb); in last_qtd_of_urb()
810 #define EHCI_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */
813 #define EHCI_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */
828 maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe); in create_ptd_atl()
833 ptd->dw0 = DW0_VALID_BIT; in create_ptd_atl()
834 ptd->dw0 |= TO_DW0_LENGTH(qtd->length); in create_ptd_atl()
835 ptd->dw0 |= TO_DW0_MAXPACKET(maxpacket); in create_ptd_atl()
836 ptd->dw0 |= TO_DW0_ENDPOINT(usb_pipeendpoint(qtd->urb->pipe)); in create_ptd_atl()
839 ptd->dw1 = TO_DW((usb_pipeendpoint(qtd->urb->pipe) >> 1)); in create_ptd_atl()
840 ptd->dw1 |= TO_DW1_DEVICE_ADDR(usb_pipedevice(qtd->urb->pipe)); in create_ptd_atl()
841 ptd->dw1 |= TO_DW1_PID_TOKEN(qtd->packet_type); in create_ptd_atl()
843 if (usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
844 ptd->dw1 |= DW1_TRANS_BULK; in create_ptd_atl()
845 else if (usb_pipeint(qtd->urb->pipe)) in create_ptd_atl()
846 ptd->dw1 |= DW1_TRANS_INT; in create_ptd_atl()
848 if (qtd->urb->dev->speed != USB_SPEED_HIGH) { in create_ptd_atl()
851 ptd->dw1 |= DW1_TRANS_SPLIT; in create_ptd_atl()
852 if (qtd->urb->dev->speed == USB_SPEED_LOW) in create_ptd_atl()
853 ptd->dw1 |= DW1_SE_USB_LOSPEED; in create_ptd_atl()
855 ptd->dw1 |= TO_DW1_PORT_NUM(qtd->urb->dev->ttport); in create_ptd_atl()
856 ptd->dw1 |= TO_DW1_HUB_NUM(qtd->urb->dev->tt->hub->devnum); in create_ptd_atl()
859 if (usb_pipeint(qtd->urb->pipe) && in create_ptd_atl()
860 (qtd->urb->dev->speed == USB_SPEED_LOW)) in create_ptd_atl()
861 ptd->dw1 |= DW1_SE_USB_LOSPEED; in create_ptd_atl()
866 ptd->dw0 |= TO_DW0_MULTI(multi); in create_ptd_atl()
867 if (usb_pipecontrol(qtd->urb->pipe) || in create_ptd_atl()
868 usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
869 ptd->dw3 |= TO_DW3_PING(qh->ping); in create_ptd_atl()
872 ptd->dw2 = 0; in create_ptd_atl()
873 ptd->dw2 |= TO_DW2_DATA_START_ADDR(base_to_chip(qtd->payload_addr)); in create_ptd_atl()
874 ptd->dw2 |= TO_DW2_RL(rl); in create_ptd_atl()
877 ptd->dw3 |= TO_DW3_NAKCOUNT(nak); in create_ptd_atl()
878 ptd->dw3 |= TO_DW3_DATA_TOGGLE(qh->toggle); in create_ptd_atl()
879 if (usb_pipecontrol(qtd->urb->pipe)) { in create_ptd_atl()
880 if (qtd->data_buffer == qtd->urb->setup_packet) in create_ptd_atl()
881 ptd->dw3 &= ~TO_DW3_DATA_TOGGLE(1); in create_ptd_atl()
883 ptd->dw3 |= TO_DW3_DATA_TOGGLE(1); in create_ptd_atl()
886 ptd->dw3 |= DW3_ACTIVE_BIT; in create_ptd_atl()
888 ptd->dw3 |= TO_DW3_CERR(ERR_COUNTER); in create_ptd_atl()
895 u32 period; in transform_add_int() local
906 if (qtd->urb->dev->speed == USB_SPEED_HIGH) { in transform_add_int()
907 /* urb->interval is in units of microframes (1/8 ms) */ in transform_add_int()
908 period = qtd->urb->interval >> 3; in transform_add_int()
910 if (qtd->urb->interval > 4) in transform_add_int()
912 interval 1 ms * uFrame-match */ in transform_add_int()
913 else if (qtd->urb->interval > 2) in transform_add_int()
915 else if (qtd->urb->interval > 1) in transform_add_int()
920 /* urb->interval is in units of frames (1 ms) */ in transform_add_int()
921 period = qtd->urb->interval; in transform_add_int()
932 /* ptd->dw5 = 0x1c; */ in transform_add_int()
933 ptd->dw5 = TO_DW(0xff); /* Execute Complete Split on any uFrame */ in transform_add_int()
936 period = period >> 1;/* Ensure equal or shorter period than requested */ in transform_add_int()
937 period &= 0xf8; /* Mask off too large values and lowest unused 3 bits */ in transform_add_int()
939 ptd->dw2 |= TO_DW(period); in transform_add_int()
940 ptd->dw4 = TO_DW(usof); in transform_add_int()
951 __releases(priv->lock) in isp1760_urb_done()
952 __acquires(priv->lock) in isp1760_urb_done()
956 if (!urb->unlinked) { in isp1760_urb_done()
957 if (urb->status == -EINPROGRESS) in isp1760_urb_done()
958 urb->status = 0; in isp1760_urb_done()
961 if (usb_pipein(urb->pipe) && usb_pipetype(urb->pipe) != PIPE_CONTROL) { in isp1760_urb_done()
963 for (ptr = urb->transfer_buffer; in isp1760_urb_done()
964 ptr < urb->transfer_buffer + urb->transfer_buffer_length; in isp1760_urb_done()
971 spin_unlock(&priv->lock); in isp1760_urb_done()
972 usb_hcd_giveback_urb(hcd, urb, urb->status); in isp1760_urb_done()
973 spin_lock(&priv->lock); in isp1760_urb_done()
985 INIT_LIST_HEAD(&qtd->qtd_list); in qtd_alloc()
986 qtd->urb = urb; in qtd_alloc()
987 qtd->packet_type = packet_type; in qtd_alloc()
988 qtd->status = QTD_ENQUEUED; in qtd_alloc()
989 qtd->actual_length = 0; in qtd_alloc()
996 WARN_ON(qtd->payload_addr); in qtd_free()
1006 const struct isp1760_memory_layout *mem = priv->memory_layout; in start_bus_transfer()
1009 WARN_ON((slot < 0) || (slot > mem->slot_num - 1)); in start_bus_transfer()
1010 WARN_ON(qtd->length && !qtd->payload_addr); in start_bus_transfer()
1013 WARN_ON(qtd->status != QTD_PAYLOAD_ALLOC); in start_bus_transfer()
1015 if (priv->is_isp1763) in start_bus_transfer()
1023 priv->atl_done_map |= isp1760_hcd_read(hcd, HC_ATL_PTD_DONEMAP); in start_bus_transfer()
1024 priv->atl_done_map &= ~(1 << slot); in start_bus_transfer()
1029 priv->int_done_map |= isp1760_hcd_read(hcd, HC_INT_PTD_DONEMAP); in start_bus_transfer()
1030 priv->int_done_map &= ~(1 << slot); in start_bus_transfer()
1034 qh->slot = slot; in start_bus_transfer()
1035 qtd->status = QTD_XFER_STARTED; in start_bus_transfer()
1049 return (usb_pipebulk(qtd->urb->pipe) && in is_short_bulk()
1050 (qtd->actual_length < qtd->length)); in is_short_bulk()
1060 list_for_each_entry_safe(qtd, qtd_next, &qh->qtd_list, qtd_list) { in collect_qtds()
1061 if (qtd->status < QTD_XFER_COMPLETE) in collect_qtds()
1066 if ((!last_qtd) && (qtd->status == QTD_RETIRE)) in collect_qtds()
1067 qtd_next->status = QTD_RETIRE; in collect_qtds()
1069 if (qtd->status == QTD_XFER_COMPLETE) { in collect_qtds()
1070 if (qtd->actual_length) { in collect_qtds()
1071 switch (qtd->packet_type) { in collect_qtds()
1073 mem_read(hcd, qtd->payload_addr, in collect_qtds()
1074 qtd->data_buffer, in collect_qtds()
1075 qtd->actual_length); in collect_qtds()
1078 qtd->urb->actual_length += in collect_qtds()
1079 qtd->actual_length; in collect_qtds()
1087 if (qtd->urb->transfer_flags & URB_SHORT_NOT_OK) in collect_qtds()
1088 qtd->urb->status = -EREMOTEIO; in collect_qtds()
1090 qtd_next->status = QTD_RETIRE; in collect_qtds()
1094 if (qtd->payload_addr) in collect_qtds()
1098 if ((qtd->status == QTD_RETIRE) && in collect_qtds()
1099 (qtd->urb->status == -EINPROGRESS)) in collect_qtds()
1100 qtd->urb->status = -EPIPE; in collect_qtds()
1106 urb_listitem->urb = qtd->urb; in collect_qtds()
1107 list_add_tail(&urb_listitem->urb_list, urb_list); in collect_qtds()
1110 list_del(&qtd->qtd_list); in collect_qtds()
1119 const struct isp1760_memory_layout *mem = priv->memory_layout; in enqueue_qtds()
1120 int slot_num = mem->slot_num; in enqueue_qtds()
1128 if (unlikely(list_empty(&qh->qtd_list))) { in enqueue_qtds()
1134 if (qh->tt_buffer_dirty) in enqueue_qtds()
1137 if (usb_pipeint(list_entry(qh->qtd_list.next, struct isp1760_qtd, in enqueue_qtds()
1138 qtd_list)->urb->pipe)) { in enqueue_qtds()
1140 slots = priv->int_slots; in enqueue_qtds()
1143 slots = priv->atl_slots; in enqueue_qtds()
1146 free_slot = -1; in enqueue_qtds()
1148 if ((free_slot == -1) && (slots[curr_slot].qtd == NULL)) in enqueue_qtds()
1155 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) { in enqueue_qtds()
1156 if (qtd->status == QTD_ENQUEUED) { in enqueue_qtds()
1157 WARN_ON(qtd->payload_addr); in enqueue_qtds()
1159 if ((qtd->length) && (!qtd->payload_addr)) in enqueue_qtds()
1162 if (qtd->length && (qtd->packet_type == SETUP_PID || in enqueue_qtds()
1163 qtd->packet_type == OUT_PID)) { in enqueue_qtds()
1164 mem_write(hcd, qtd->payload_addr, in enqueue_qtds()
1165 qtd->data_buffer, qtd->length); in enqueue_qtds()
1168 qtd->status = QTD_PAYLOAD_ALLOC; in enqueue_qtds()
1171 if (qtd->status == QTD_PAYLOAD_ALLOC) { in enqueue_qtds()
1173 if ((curr_slot > 31) && (free_slot == -1)) in enqueue_qtds()
1174 dev_dbg(hcd->self.controller, "%s: No slot " in enqueue_qtds()
1178 if ((curr_slot > slot_num - 1) && (free_slot > -1)) { in enqueue_qtds()
1179 if (usb_pipeint(qtd->urb->pipe)) in enqueue_qtds()
1216 ep_queue = &priv->qh_list[i]; in schedule_ptds()
1219 if (list_empty(&qh->qtd_list)) in schedule_ptds()
1220 list_del(&qh->qh_list); in schedule_ptds()
1226 isp1760_urb_done(hcd, urb_listitem->urb); in schedule_ptds()
1255 ep_queue = &priv->qh_list[i]; in schedule_ptds()
1271 dw4 = TO_U32(ptd->dw4); in check_int_transfer()
1277 if (ptd->dw3 & DW3_HALT_BIT) { in check_int_transfer()
1279 urb->status = -EPROTO; /* Default unknown error */ in check_int_transfer()
1284 dev_dbg(hcd->self.controller, "%s: underrun " in check_int_transfer()
1287 urb->status = -ECOMM; /* Could not write data */ in check_int_transfer()
1290 dev_dbg(hcd->self.controller, "%s: transaction " in check_int_transfer()
1293 urb->status = -EPROTO; /* timeout, bad CRC, PID in check_int_transfer()
1297 dev_dbg(hcd->self.controller, "%s: babble " in check_int_transfer()
1300 urb->status = -EOVERFLOW; in check_int_transfer()
1316 if (ptd->dw3 & DW3_HALT_BIT) { in check_atl_transfer()
1317 if (ptd->dw3 & DW3_BABBLE_BIT) in check_atl_transfer()
1318 urb->status = -EOVERFLOW; in check_atl_transfer()
1319 else if (FROM_DW3_CERR(ptd->dw3)) in check_atl_transfer()
1320 urb->status = -EPIPE; /* Stall */ in check_atl_transfer()
1322 urb->status = -EPROTO; /* Unknown */ in check_atl_transfer()
1324 dev_dbg(hcd->self.controller, "%s: ptd error:\n" in check_atl_transfer()
1328 ptd->dw0, ptd->dw1, ptd->dw2, ptd->dw3, in check_atl_transfer()
1329 ptd->dw4, ptd->dw5, ptd->dw6, ptd->dw7); in check_atl_transfer()
1334 if ((ptd->dw3 & DW3_ERROR_BIT) && (ptd->dw3 & DW3_ACTIVE_BIT)) { in check_atl_transfer()
1335 /* Transfer Error, *but* active and no HALT -> reload */ in check_atl_transfer()
1336 dev_dbg(hcd->self.controller, "PID error; reloading ptd\n"); in check_atl_transfer()
1340 if (!FROM_DW3_NAKCOUNT(ptd->dw3) && (ptd->dw3 & DW3_ACTIVE_BIT)) { in check_atl_transfer()
1366 priv->int_done_map &= ~skip_map; in handle_done_ptds()
1368 priv->atl_done_map &= ~skip_map; in handle_done_ptds()
1370 modified = priv->int_done_map || priv->atl_done_map; in handle_done_ptds()
1372 while (priv->int_done_map || priv->atl_done_map) { in handle_done_ptds()
1373 if (priv->int_done_map) { in handle_done_ptds()
1375 slot = __ffs(priv->int_done_map); in handle_done_ptds()
1376 priv->int_done_map &= ~(1 << slot); in handle_done_ptds()
1377 slots = priv->int_slots; in handle_done_ptds()
1387 slots[slot].qtd->urb); in handle_done_ptds()
1390 slot = __ffs(priv->atl_done_map); in handle_done_ptds()
1391 priv->atl_done_map &= ~(1 << slot); in handle_done_ptds()
1392 slots = priv->atl_slots; in handle_done_ptds()
1402 slots[slot].qtd->urb); in handle_done_ptds()
1409 qh->slot = -1; in handle_done_ptds()
1411 WARN_ON(qtd->status != QTD_XFER_STARTED); in handle_done_ptds()
1415 if ((usb_pipeint(qtd->urb->pipe)) && in handle_done_ptds()
1416 (qtd->urb->dev->speed != USB_SPEED_HIGH)) in handle_done_ptds()
1417 qtd->actual_length = in handle_done_ptds()
1420 qtd->actual_length = in handle_done_ptds()
1423 qtd->status = QTD_XFER_COMPLETE; in handle_done_ptds()
1424 if (list_is_last(&qtd->qtd_list, &qh->qtd_list) || in handle_done_ptds()
1428 qtd = list_entry(qtd->qtd_list.next, in handle_done_ptds()
1431 qh->toggle = FROM_DW3_DATA_TOGGLE(ptd.dw3); in handle_done_ptds()
1432 qh->ping = FROM_DW3_PING(ptd.dw3); in handle_done_ptds()
1436 qtd->status = QTD_PAYLOAD_ALLOC; in handle_done_ptds()
1443 qh->toggle = FROM_DW3_DATA_TOGGLE(ptd.dw3); in handle_done_ptds()
1444 qh->ping = FROM_DW3_PING(ptd.dw3); in handle_done_ptds()
1448 qtd->status = QTD_RETIRE; in handle_done_ptds()
1449 if ((qtd->urb->dev->speed != USB_SPEED_HIGH) && in handle_done_ptds()
1450 (qtd->urb->status != -EPIPE) && in handle_done_ptds()
1451 (qtd->urb->status != -EREMOTEIO)) { in handle_done_ptds()
1452 qh->tt_buffer_dirty = 1; in handle_done_ptds()
1453 if (usb_hub_clear_tt_buffer(qtd->urb)) in handle_done_ptds()
1456 qh->tt_buffer_dirty = 0; in handle_done_ptds()
1459 qh->toggle = 0; in handle_done_ptds()
1460 qh->ping = 0; in handle_done_ptds()
1468 if (qtd && (qtd->status == QTD_PAYLOAD_ALLOC)) { in handle_done_ptds()
1469 if (slots == priv->int_slots) { in handle_done_ptds()
1471 dev_err(hcd->self.controller, in handle_done_ptds()
1497 spin_lock(&priv->lock); in isp1760_irq()
1499 if (!(hcd->state & HC_STATE_RUNNING)) in isp1760_irq()
1506 int_reg = priv->is_isp1763 ? ISP1763_HC_INTERRUPT : in isp1760_irq()
1508 isp1760_reg_write(priv->regs, int_reg, imask); in isp1760_irq()
1510 priv->int_done_map |= isp1760_hcd_read(hcd, HC_INT_PTD_DONEMAP); in isp1760_irq()
1511 priv->atl_done_map |= isp1760_hcd_read(hcd, HC_ATL_PTD_DONEMAP); in isp1760_irq()
1518 spin_unlock(&priv->lock); in isp1760_irq()
1529 * enabling ATL interrupts also causes the chip to sometimes - rarely - "forget"
1533 * done bit is not being set. This is bad - it blocks the endpoint until reboot.
1557 const struct isp1760_memory_layout *mem = priv->memory_layout; in errata2_function()
1562 spin_lock_irqsave(&priv->lock, spinflags); in errata2_function()
1564 for (slot = 0; slot < mem->slot_num; slot++) in errata2_function()
1565 if (priv->atl_slots[slot].qh && time_after(jiffies, in errata2_function()
1566 priv->atl_slots[slot].timestamp + in errata2_function()
1571 priv->atl_done_map |= 1 << slot; in errata2_function()
1574 if (priv->atl_done_map) in errata2_function()
1577 spin_unlock_irqrestore(&priv->lock, spinflags); in errata2_function()
1593 hcd->uses_new_polling = 1; in isp1763_run()
1594 hcd->state = HC_STATE_RUNNING; in isp1763_run()
1599 dev_info(hcd->self.controller, "USB ISP %02x%02x HW rev. %d started\n", in isp1763_run()
1615 isp1760_reg_write(priv->regs, ISP1763_HC_OTG_CTRL_CLEAR, BIT(7)); in isp1763_run()
1616 isp1760_reg_write(priv->regs, ISP1763_HC_OTG_CTRL_CLEAR, BIT(15)); in isp1763_run()
1673 if (priv->is_isp1763) in isp1760_run()
1676 hcd->uses_new_polling = 1; in isp1760_run()
1678 hcd->state = HC_STATE_RUNNING; in isp1760_run()
1720 dev_info(hcd->self.controller, "USB ISP %02x%02x HW rev. %d started\n", in isp1760_run()
1740 /* GRR this is run-once init(), being done every time the HC starts. in isp1760_run()
1749 qtd->data_buffer = databuffer; in qtd_fill()
1751 qtd->length = len; in qtd_fill()
1753 return qtd->length; in qtd_fill()
1761 list_del(&qtd->qtd_list); in qtd_list_free()
1767 * Packetize urb->transfer_buffer into list of packets of size wMaxPacketSize.
1774 const struct isp1760_memory_layout *mem = priv->memory_layout; in packetize_urb()
1784 if (!urb->transfer_buffer && urb->transfer_buffer_length) { in packetize_urb()
1786 dev_err(hcd->self.controller, in packetize_urb()
1788 (long unsigned)urb->transfer_dma, in packetize_urb()
1789 urb->transfer_buffer_length); in packetize_urb()
1793 if (usb_pipein(urb->pipe)) in packetize_urb()
1798 if (usb_pipecontrol(urb->pipe)) { in packetize_urb()
1802 qtd_fill(qtd, urb->setup_packet, sizeof(struct usb_ctrlrequest)); in packetize_urb()
1803 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1806 if (urb->transfer_buffer_length == 0) in packetize_urb()
1810 maxpacketsize = usb_maxpacket(urb->dev, urb->pipe); in packetize_urb()
1817 buf = urb->transfer_buffer; in packetize_urb()
1818 len = urb->transfer_buffer_length; in packetize_urb()
1827 if (len > mem->blocks_size[ISP176x_BLOCK_NUM - 1]) in packetize_urb()
1828 this_qtd_len = mem->blocks_size[ISP176x_BLOCK_NUM - 1]; in packetize_urb()
1833 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1835 len -= this_qtd_len; in packetize_urb()
1846 if (urb->transfer_buffer_length != 0) { in packetize_urb()
1849 if (usb_pipecontrol(urb->pipe)) { in packetize_urb()
1855 } else if (usb_pipebulk(urb->pipe) && maxpacketsize in packetize_urb()
1856 && (urb->transfer_flags & URB_ZERO_PACKET) in packetize_urb()
1857 && !(urb->transfer_buffer_length % in packetize_urb()
1868 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1889 switch (usb_pipetype(urb->pipe)) { in isp1760_urb_enqueue()
1891 ep_queue = &priv->qh_list[QH_CONTROL]; in isp1760_urb_enqueue()
1894 ep_queue = &priv->qh_list[QH_BULK]; in isp1760_urb_enqueue()
1897 if (urb->interval < 0) in isp1760_urb_enqueue()
1898 return -EINVAL; in isp1760_urb_enqueue()
1900 ep_queue = &priv->qh_list[QH_INTERRUPT]; in isp1760_urb_enqueue()
1903 dev_err(hcd->self.controller, "%s: isochronous USB packets " in isp1760_urb_enqueue()
1906 return -EPIPE; in isp1760_urb_enqueue()
1908 dev_err(hcd->self.controller, "%s: unknown pipe type\n", in isp1760_urb_enqueue()
1910 return -EPIPE; in isp1760_urb_enqueue()
1913 if (usb_pipein(urb->pipe)) in isp1760_urb_enqueue()
1914 urb->actual_length = 0; in isp1760_urb_enqueue()
1918 return -ENOMEM; in isp1760_urb_enqueue()
1920 spin_lock_irqsave(&priv->lock, spinflags); in isp1760_urb_enqueue()
1922 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { in isp1760_urb_enqueue()
1923 retval = -ESHUTDOWN; in isp1760_urb_enqueue()
1933 qh = urb->ep->hcpriv; in isp1760_urb_enqueue()
1943 list_add_tail(&qh->qh_list, ep_queue); in isp1760_urb_enqueue()
1947 retval = -ENOMEM; in isp1760_urb_enqueue()
1952 list_add_tail(&qh->qh_list, ep_queue); in isp1760_urb_enqueue()
1953 urb->ep->hcpriv = qh; in isp1760_urb_enqueue()
1956 list_splice_tail(&new_qtds, &qh->qtd_list); in isp1760_urb_enqueue()
1960 spin_unlock_irqrestore(&priv->lock, spinflags); in isp1760_urb_enqueue()
1970 WARN_ON(qh->slot == -1); in kill_transfer()
1974 if (usb_pipecontrol(urb->pipe) || usb_pipebulk(urb->pipe)) { in kill_transfer()
1975 if (qh->slot != -1) { in kill_transfer()
1977 skip_map |= (1 << qh->slot); in kill_transfer()
1981 priv->atl_slots[qh->slot].qh = NULL; in kill_transfer()
1982 priv->atl_slots[qh->slot].qtd = NULL; in kill_transfer()
1984 if (qh->slot != -1) { in kill_transfer()
1986 skip_map |= (1 << qh->slot); in kill_transfer()
1989 priv->int_slots[qh->slot].qh = NULL; in kill_transfer()
1990 priv->int_slots[qh->slot].qtd = NULL; in kill_transfer()
1993 qh->slot = -1; in kill_transfer()
2006 urb = qtd->urb; in dequeue_urb_from_qtd()
2008 list_for_each_entry_from(qtd, &qh->qtd_list, qtd_list) { in dequeue_urb_from_qtd()
2009 if (qtd->urb != urb) in dequeue_urb_from_qtd()
2012 if (qtd->status >= QTD_XFER_STARTED) in dequeue_urb_from_qtd()
2015 (qtd->status >= QTD_XFER_COMPLETE)) in dequeue_urb_from_qtd()
2018 if (qtd->status == QTD_XFER_STARTED) in dequeue_urb_from_qtd()
2020 qtd->status = QTD_RETIRE; in dequeue_urb_from_qtd()
2023 if ((urb->dev->speed != USB_SPEED_HIGH) && urb_was_running) { in dequeue_urb_from_qtd()
2024 qh->tt_buffer_dirty = 1; in dequeue_urb_from_qtd()
2027 qh->tt_buffer_dirty = 0; in dequeue_urb_from_qtd()
2040 spin_lock_irqsave(&priv->lock, spinflags); in isp1760_urb_dequeue()
2045 qh = urb->ep->hcpriv; in isp1760_urb_dequeue()
2047 retval = -EINVAL; in isp1760_urb_dequeue()
2051 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) in isp1760_urb_dequeue()
2052 if (qtd->urb == urb) { in isp1760_urb_dequeue()
2054 list_move(&qtd->qtd_list, &qh->qtd_list); in isp1760_urb_dequeue()
2058 urb->status = status; in isp1760_urb_dequeue()
2062 spin_unlock_irqrestore(&priv->lock, spinflags); in isp1760_urb_dequeue()
2074 spin_lock_irqsave(&priv->lock, spinflags); in isp1760_endpoint_disable()
2076 qh = ep->hcpriv; in isp1760_endpoint_disable()
2080 WARN_ON(!list_empty(&qh->qtd_list)); in isp1760_endpoint_disable()
2083 list_for_each_entry(qh_iter, &priv->qh_list[i], qh_list) in isp1760_endpoint_disable()
2085 list_del(&qh_iter->qh_list); in isp1760_endpoint_disable()
2090 ep->hcpriv = NULL; in isp1760_endpoint_disable()
2095 spin_unlock_irqrestore(&priv->lock, spinflags); in isp1760_endpoint_disable()
2106 if (!HC_IS_RUNNING(hcd->state)) in isp1760_hub_status_data()
2109 /* init status to no-changes */ in isp1760_hub_status_data()
2112 spin_lock_irqsave(&priv->lock, flags); in isp1760_hub_status_data()
2123 * high-speed device is switched over to the companion in isp1760_hub_status_data()
2128 time_after_eq(jiffies, priv->reset_done))) { in isp1760_hub_status_data()
2132 /* FIXME autosuspend idle root hubs */ in isp1760_hub_status_data()
2134 spin_unlock_irqrestore(&priv->lock, flags); in isp1760_hub_status_data()
2144 ports = isp1760_hcd_n_ports(priv->hcd); in isp1760_hub_descriptor()
2146 desc->bDescriptorType = USB_DT_HUB; in isp1760_hub_descriptor()
2148 desc->bPwrOn2PwrGood = 10; in isp1760_hub_descriptor()
2149 desc->bHubContrCurrent = 0; in isp1760_hub_descriptor()
2151 desc->bNbrPorts = ports; in isp1760_hub_descriptor()
2153 desc->bDescLength = 7 + 2 * temp; in isp1760_hub_descriptor()
2156 memset(&desc->u.hs.DeviceRemovable[0], 0, temp); in isp1760_hub_descriptor()
2157 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); in isp1760_hub_descriptor()
2159 /* per-port overcurrent reporting */ in isp1760_hub_descriptor()
2161 if (isp1760_hcd_ppc_is_set(priv->hcd)) in isp1760_hub_descriptor()
2162 /* per-port power control */ in isp1760_hub_descriptor()
2167 desc->wHubCharacteristics = cpu_to_le16(temp); in isp1760_hub_descriptor()
2177 /* if reset finished and it's still not enabled -- handoff */ in check_reset_complete()
2179 dev_info(hcd->self.controller, in check_reset_complete()
2180 "port %d full speed --> companion\n", index + 1); in check_reset_complete()
2186 dev_info(hcd->self.controller, "port %d high speed\n", in check_reset_complete()
2211 spin_lock_irqsave(&priv->lock, flags); in isp1760_hub_control()
2217 /* no hub-wide feature/status flags */ in isp1760_hub_control()
2226 wIndex--; in isp1760_hub_control()
2231 * the port-change status bits (especially in isp1760_hub_control()
2253 priv->reset_done = jiffies + in isp1760_hub_control()
2258 /* we auto-clear this feature */ in isp1760_hub_control()
2283 /* no hub-wide feature/status flags */ in isp1760_hub_control()
2289 wIndex--; in isp1760_hub_control()
2298 dev_err(hcd->self.controller, "Port resume should be skipped.\n"); in isp1760_hub_control()
2301 if (!priv->reset_done) { in isp1760_hub_control()
2303 priv->reset_done = jiffies in isp1760_hub_control()
2306 mod_timer(&hcd->rh_timer, priv->reset_done); in isp1760_hub_control()
2311 priv->reset_done)) { in isp1760_hub_control()
2313 priv->reset_done = 0; in isp1760_hub_control()
2321 dev_err(hcd->self.controller, in isp1760_hub_control()
2331 time_after_eq(jiffies, priv->reset_done)) { in isp1760_hub_control()
2333 priv->reset_done = 0; in isp1760_hub_control()
2342 dev_err(hcd->self.controller, "port %d reset error %d\n", in isp1760_hub_control()
2357 dev_err(hcd->self.controller, "PORT_OWNER is set\n"); in isp1760_hub_control()
2380 /* no hub-wide feature/status flags */ in isp1760_hub_control()
2390 wIndex--; in isp1760_hub_control()
2430 priv->reset_done = jiffies + in isp1760_hub_control()
2442 retval = -EPIPE; in isp1760_hub_control()
2444 spin_unlock_irqrestore(&priv->lock, flags); in isp1760_hub_control()
2454 return (fr >> 3) % priv->periodic_size; in isp1760_get_frame()
2467 spin_lock_irq(&priv->lock); in isp1760_stop()
2471 spin_unlock_irq(&priv->lock); in isp1760_stop()
2489 struct isp1760_qh *qh = ep->hcpriv; in isp1760_clear_tt_buffer_complete()
2495 spin_lock_irqsave(&priv->lock, spinflags); in isp1760_clear_tt_buffer_complete()
2496 qh->tt_buffer_dirty = 0; in isp1760_clear_tt_buffer_complete()
2498 spin_unlock_irqrestore(&priv->lock, spinflags); in isp1760_clear_tt_buffer_complete()
2503 .description = "isp1760-hcd",
2527 return -ENOMEM; in isp1760_init_kmem_once()
2549 return -ENOMEM; in isp1760_init_kmem_once()
2563 const struct isp1760_memory_layout *mem_layout = priv->memory_layout; in isp1760_hcd_register()
2569 return -ENOMEM; in isp1760_hcd_register()
2571 *(struct isp1760_hcd **)hcd->hcd_priv = priv; in isp1760_hcd_register()
2573 priv->hcd = hcd; in isp1760_hcd_register()
2575 priv->atl_slots = kcalloc(mem_layout->slot_num, in isp1760_hcd_register()
2577 if (!priv->atl_slots) { in isp1760_hcd_register()
2578 ret = -ENOMEM; in isp1760_hcd_register()
2582 priv->int_slots = kcalloc(mem_layout->slot_num, in isp1760_hcd_register()
2584 if (!priv->int_slots) { in isp1760_hcd_register()
2585 ret = -ENOMEM; in isp1760_hcd_register()
2591 hcd->irq = irq; in isp1760_hcd_register()
2592 hcd->rsrc_start = mem->start; in isp1760_hcd_register()
2593 hcd->rsrc_len = resource_size(mem); in isp1760_hcd_register()
2596 hcd->cant_recv_wakeups = 1; in isp1760_hcd_register()
2602 device_wakeup_enable(hcd->self.controller); in isp1760_hcd_register()
2607 kfree(priv->int_slots); in isp1760_hcd_register()
2609 kfree(priv->atl_slots); in isp1760_hcd_register()
2617 if (!priv->hcd) in isp1760_hcd_unregister()
2620 usb_remove_hcd(priv->hcd); in isp1760_hcd_unregister()
2621 usb_put_hcd(priv->hcd); in isp1760_hcd_unregister()
2622 kfree(priv->atl_slots); in isp1760_hcd_unregister()
2623 kfree(priv->int_slots); in isp1760_hcd_unregister()