Lines Matching refs:fotg210
98 #define fotg210_dbg(fotg210, fmt, args...) \ argument
99 dev_dbg(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args)
100 #define fotg210_err(fotg210, fmt, args...) \ argument
101 dev_err(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args)
102 #define fotg210_info(fotg210, fmt, args...) \ argument
103 dev_info(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args)
104 #define fotg210_warn(fotg210, fmt, args...) \ argument
105 dev_warn(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args)
111 static void dbg_hcs_params(struct fotg210_hcd *fotg210, char *label) in dbg_hcs_params() argument
113 u32 params = fotg210_readl(fotg210, &fotg210->caps->hcs_params); in dbg_hcs_params()
115 fotg210_dbg(fotg210, in dbg_hcs_params()
126 static void dbg_hcc_params(struct fotg210_hcd *fotg210, char *label) in dbg_hcc_params() argument
128 u32 params = fotg210_readl(fotg210, &fotg210->caps->hcc_params); in dbg_hcc_params()
130 fotg210_dbg(fotg210, in dbg_hcc_params()
139 dbg_qtd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd) in dbg_qtd() argument
141 fotg210_dbg(fotg210, "%s td %p n%08x %08x t%08x p0=%08x\n", label, qtd, in dbg_qtd()
142 hc32_to_cpup(fotg210, &qtd->hw_next), in dbg_qtd()
143 hc32_to_cpup(fotg210, &qtd->hw_alt_next), in dbg_qtd()
144 hc32_to_cpup(fotg210, &qtd->hw_token), in dbg_qtd()
145 hc32_to_cpup(fotg210, &qtd->hw_buf[0])); in dbg_qtd()
147 fotg210_dbg(fotg210, " p1=%08x p2=%08x p3=%08x p4=%08x\n", in dbg_qtd()
148 hc32_to_cpup(fotg210, &qtd->hw_buf[1]), in dbg_qtd()
149 hc32_to_cpup(fotg210, &qtd->hw_buf[2]), in dbg_qtd()
150 hc32_to_cpup(fotg210, &qtd->hw_buf[3]), in dbg_qtd()
151 hc32_to_cpup(fotg210, &qtd->hw_buf[4])); in dbg_qtd()
155 dbg_qh(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qh *qh) in dbg_qh() argument
159 fotg210_dbg(fotg210, "%s qh %p n%08x info %x %x qtd %x\n", label, in dbg_qh()
161 dbg_qtd("overlay", fotg210, (struct fotg210_qtd *) &hw->hw_qtd_next); in dbg_qh()
165 dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd) in dbg_itd() argument
167 fotg210_dbg(fotg210, "%s[%d] itd %p, next %08x, urb %p\n", in dbg_itd()
168 label, itd->frame, itd, hc32_to_cpu(fotg210, itd->hw_next), in dbg_itd()
170 fotg210_dbg(fotg210, in dbg_itd()
172 hc32_to_cpu(fotg210, itd->hw_transaction[0]), in dbg_itd()
173 hc32_to_cpu(fotg210, itd->hw_transaction[1]), in dbg_itd()
174 hc32_to_cpu(fotg210, itd->hw_transaction[2]), in dbg_itd()
175 hc32_to_cpu(fotg210, itd->hw_transaction[3]), in dbg_itd()
176 hc32_to_cpu(fotg210, itd->hw_transaction[4]), in dbg_itd()
177 hc32_to_cpu(fotg210, itd->hw_transaction[5]), in dbg_itd()
178 hc32_to_cpu(fotg210, itd->hw_transaction[6]), in dbg_itd()
179 hc32_to_cpu(fotg210, itd->hw_transaction[7])); in dbg_itd()
180 fotg210_dbg(fotg210, in dbg_itd()
182 hc32_to_cpu(fotg210, itd->hw_bufp[0]), in dbg_itd()
183 hc32_to_cpu(fotg210, itd->hw_bufp[1]), in dbg_itd()
184 hc32_to_cpu(fotg210, itd->hw_bufp[2]), in dbg_itd()
185 hc32_to_cpu(fotg210, itd->hw_bufp[3]), in dbg_itd()
186 hc32_to_cpu(fotg210, itd->hw_bufp[4]), in dbg_itd()
187 hc32_to_cpu(fotg210, itd->hw_bufp[5]), in dbg_itd()
188 hc32_to_cpu(fotg210, itd->hw_bufp[6])); in dbg_itd()
189 fotg210_dbg(fotg210, " index: %d %d %d %d %d %d %d %d\n", in dbg_itd()
288 #define dbg_status(fotg210, label, status) { \ argument
291 fotg210_dbg(fotg210, "%s\n", _buf); \
294 #define dbg_cmd(fotg210, label, command) { \ argument
297 fotg210_dbg(fotg210, "%s\n", _buf); \
300 #define dbg_port(fotg210, label, port, status) { \ argument
302 fotg210_dbg(fotg210, "%s\n", dbg_port_buf(_buf, sizeof(_buf), label, port, status) ); \
362 static inline char token_mark(struct fotg210_hcd *fotg210, __hc32 token) in token_mark() argument
364 __u32 v = hc32_to_cpu(fotg210, token); in token_mark()
377 struct fotg210_hcd *fotg210, in qh_lines() argument
390 __le32 list_end = FOTG210_LIST_END(fotg210); in qh_lines()
396 mark = token_mark(fotg210, hw->hw_token); in qh_lines()
398 if ((hw->hw_alt_next & QTD_MASK(fotg210)) in qh_lines()
399 == fotg210->async->hw->hw_alt_next) in qh_lines()
405 scratch = hc32_to_cpup(fotg210, &hw->hw_info1); in qh_lines()
406 hw_curr = (mark == '*') ? hc32_to_cpup(fotg210, &hw->hw_current) : 0; in qh_lines()
412 scratch, hc32_to_cpup(fotg210, &hw->hw_info2), in qh_lines()
413 hc32_to_cpup(fotg210, &hw->hw_token), mark, in qh_lines()
414 (cpu_to_hc32(fotg210, QTD_TOGGLE) & hw->hw_token) in qh_lines()
416 (hc32_to_cpup(fotg210, &hw->hw_alt_next) >> 1) & 0x0f); in qh_lines()
422 scratch = hc32_to_cpup(fotg210, &td->hw_token); in qh_lines()
426 else if (hw->hw_qtd_next == cpu_to_hc32(fotg210, td->qtd_dma)) in qh_lines()
429 if (td->hw_alt_next == fotg210->async->hw->hw_alt_next) in qh_lines()
476 struct fotg210_hcd *fotg210; in fill_async_buffer() local
483 fotg210 = hcd_to_fotg210(hcd); in fill_async_buffer()
493 spin_lock_irqsave(&fotg210->lock, flags); in fill_async_buffer()
494 for (qh = fotg210->async->qh_next.qh; size > 0 && qh; in fill_async_buffer()
496 qh_lines(fotg210, qh, &next, &size); in fill_async_buffer()
497 if (fotg210->async_unlink && size > 0) { in fill_async_buffer()
502 for (qh = fotg210->async_unlink; size > 0 && qh; in fill_async_buffer()
504 qh_lines(fotg210, qh, &next, &size); in fill_async_buffer()
506 spin_unlock_irqrestore(&fotg210->lock, flags); in fill_async_buffer()
515 struct fotg210_hcd *fotg210; in fill_periodic_buffer() local
529 fotg210 = hcd_to_fotg210(hcd); in fill_periodic_buffer()
533 temp = scnprintf(next, size, "size = %d\n", fotg210->periodic_size); in fill_periodic_buffer()
540 spin_lock_irqsave(&fotg210->lock, flags); in fill_periodic_buffer()
541 for (i = 0; i < fotg210->periodic_size; i++) { in fill_periodic_buffer()
542 p = fotg210->pshadow[i]; in fill_periodic_buffer()
545 tag = Q_NEXT_TYPE(fotg210, fotg210->periodic[i]); in fill_periodic_buffer()
554 switch (hc32_to_cpu(fotg210, tag)) { in fill_periodic_buffer()
559 hc32_to_cpup(fotg210, in fill_periodic_buffer()
580 u32 scratch = hc32_to_cpup(fotg210, in fill_periodic_buffer()
592 fotg210, in fill_periodic_buffer()
617 tag = Q_NEXT_TYPE(fotg210, hw->hw_next); in fill_periodic_buffer()
624 tag = Q_NEXT_TYPE(fotg210, p.fstn->hw_next); in fill_periodic_buffer()
630 tag = Q_NEXT_TYPE(fotg210, p.itd->hw_next); in fill_periodic_buffer()
642 spin_unlock_irqrestore(&fotg210->lock, flags); in fill_periodic_buffer()
649 static const char *rh_state_string(struct fotg210_hcd *fotg210) in rh_state_string() argument
651 switch (fotg210->rh_state) { in rh_state_string()
667 struct fotg210_hcd *fotg210; in fill_registers_buffer() local
675 fotg210 = hcd_to_fotg210(hcd); in fill_registers_buffer()
679 spin_lock_irqsave(&fotg210->lock, flags); in fill_registers_buffer()
693 i = HC_VERSION(fotg210, fotg210_readl(fotg210, in fill_registers_buffer()
694 &fotg210->caps->hc_capbase)); in fill_registers_buffer()
702 i >> 8, i & 0x0ff, rh_state_string(fotg210)); in fill_registers_buffer()
707 i = fotg210_readl(fotg210, &fotg210->caps->hcs_params); in fill_registers_buffer()
712 i = fotg210_readl(fotg210, &fotg210->caps->hcc_params); in fill_registers_buffer()
719 fotg210_readl(fotg210, &fotg210->regs->status)); in fill_registers_buffer()
725 fotg210_readl(fotg210, &fotg210->regs->command)); in fill_registers_buffer()
731 fotg210_readl(fotg210, &fotg210->regs->intr_enable)); in fill_registers_buffer()
737 fotg210_read_frame_index(fotg210)); in fill_registers_buffer()
741 if (fotg210->async_unlink) { in fill_registers_buffer()
743 fotg210->async_unlink); in fill_registers_buffer()
751 fotg210->stats.normal, fotg210->stats.error, fotg210->stats.iaa, in fill_registers_buffer()
752 fotg210->stats.lost_iaa); in fill_registers_buffer()
757 fotg210->stats.complete, fotg210->stats.unlink); in fill_registers_buffer()
763 spin_unlock_irqrestore(&fotg210->lock, flags); in fill_registers_buffer()
870 static inline void create_debug_files(struct fotg210_hcd *fotg210) in create_debug_files() argument
872 struct usb_bus *bus = &fotg210_to_hcd(fotg210)->self; in create_debug_files()
874 fotg210->debug_dir = debugfs_create_dir(bus->bus_name, in create_debug_files()
876 if (!fotg210->debug_dir) in create_debug_files()
879 if (!debugfs_create_file("async", S_IRUGO, fotg210->debug_dir, bus, in create_debug_files()
883 if (!debugfs_create_file("periodic", S_IRUGO, fotg210->debug_dir, bus, in create_debug_files()
887 if (!debugfs_create_file("registers", S_IRUGO, fotg210->debug_dir, bus, in create_debug_files()
894 debugfs_remove_recursive(fotg210->debug_dir); in create_debug_files()
897 static inline void remove_debug_files(struct fotg210_hcd *fotg210) in remove_debug_files() argument
899 debugfs_remove_recursive(fotg210->debug_dir); in remove_debug_files()
921 static int handshake(struct fotg210_hcd *fotg210, void __iomem *ptr, in handshake() argument
927 result = fotg210_readl(fotg210, ptr); in handshake()
943 static int fotg210_halt(struct fotg210_hcd *fotg210) in fotg210_halt() argument
947 spin_lock_irq(&fotg210->lock); in fotg210_halt()
950 fotg210_writel(fotg210, 0, &fotg210->regs->intr_enable); in fotg210_halt()
956 fotg210->command &= ~CMD_RUN; in fotg210_halt()
957 temp = fotg210_readl(fotg210, &fotg210->regs->command); in fotg210_halt()
959 fotg210_writel(fotg210, temp, &fotg210->regs->command); in fotg210_halt()
961 spin_unlock_irq(&fotg210->lock); in fotg210_halt()
962 synchronize_irq(fotg210_to_hcd(fotg210)->irq); in fotg210_halt()
964 return handshake(fotg210, &fotg210->regs->status, in fotg210_halt()
972 static int fotg210_reset(struct fotg210_hcd *fotg210) in fotg210_reset() argument
975 u32 command = fotg210_readl(fotg210, &fotg210->regs->command); in fotg210_reset()
979 if (fotg210->debug && !dbgp_reset_prep(fotg210_to_hcd(fotg210))) in fotg210_reset()
980 fotg210->debug = NULL; in fotg210_reset()
983 dbg_cmd(fotg210, "reset", command); in fotg210_reset()
984 fotg210_writel(fotg210, command, &fotg210->regs->command); in fotg210_reset()
985 fotg210->rh_state = FOTG210_RH_HALTED; in fotg210_reset()
986 fotg210->next_statechange = jiffies; in fotg210_reset()
987 retval = handshake(fotg210, &fotg210->regs->command, in fotg210_reset()
993 if (fotg210->debug) in fotg210_reset()
994 dbgp_external_startup(fotg210_to_hcd(fotg210)); in fotg210_reset()
996 fotg210->port_c_suspend = fotg210->suspended_ports = in fotg210_reset()
997 fotg210->resuming_ports = 0; in fotg210_reset()
1005 static void fotg210_quiesce(struct fotg210_hcd *fotg210) in fotg210_quiesce() argument
1009 if (fotg210->rh_state != FOTG210_RH_RUNNING) in fotg210_quiesce()
1013 temp = (fotg210->command << 10) & (STS_ASS | STS_PSS); in fotg210_quiesce()
1014 handshake(fotg210, &fotg210->regs->status, STS_ASS | STS_PSS, temp, in fotg210_quiesce()
1018 spin_lock_irq(&fotg210->lock); in fotg210_quiesce()
1019 fotg210->command &= ~(CMD_ASE | CMD_PSE); in fotg210_quiesce()
1020 fotg210_writel(fotg210, fotg210->command, &fotg210->regs->command); in fotg210_quiesce()
1021 spin_unlock_irq(&fotg210->lock); in fotg210_quiesce()
1024 handshake(fotg210, &fotg210->regs->status, STS_ASS | STS_PSS, 0, in fotg210_quiesce()
1030 static void end_unlink_async(struct fotg210_hcd *fotg210);
1031 static void unlink_empty_async(struct fotg210_hcd *fotg210);
1032 static void fotg210_work(struct fotg210_hcd *fotg210);
1033 static void start_unlink_intr(struct fotg210_hcd *fotg210,
1035 static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
1040 static void fotg210_set_command_bit(struct fotg210_hcd *fotg210, u32 bit) in fotg210_set_command_bit() argument
1042 fotg210->command |= bit; in fotg210_set_command_bit()
1043 fotg210_writel(fotg210, fotg210->command, &fotg210->regs->command); in fotg210_set_command_bit()
1046 fotg210_readl(fotg210, &fotg210->regs->command); in fotg210_set_command_bit()
1050 static void fotg210_clear_command_bit(struct fotg210_hcd *fotg210, u32 bit) in fotg210_clear_command_bit() argument
1052 fotg210->command &= ~bit; in fotg210_clear_command_bit()
1053 fotg210_writel(fotg210, fotg210->command, &fotg210->regs->command); in fotg210_clear_command_bit()
1056 fotg210_readl(fotg210, &fotg210->regs->command); in fotg210_clear_command_bit()
1103 static void fotg210_enable_event(struct fotg210_hcd *fotg210, unsigned event, in fotg210_enable_event() argument
1106 ktime_t *timeout = &fotg210->hr_timeouts[event]; in fotg210_enable_event()
1111 fotg210->enabled_hrtimer_events |= (1 << event); in fotg210_enable_event()
1114 if (event < fotg210->next_hrtimer_event) { in fotg210_enable_event()
1115 fotg210->next_hrtimer_event = event; in fotg210_enable_event()
1116 hrtimer_start_range_ns(&fotg210->hrtimer, *timeout, in fotg210_enable_event()
1123 static void fotg210_poll_ASS(struct fotg210_hcd *fotg210) in fotg210_poll_ASS() argument
1128 if (fotg210->rh_state != FOTG210_RH_RUNNING) in fotg210_poll_ASS()
1131 want = (fotg210->command & CMD_ASE) ? STS_ASS : 0; in fotg210_poll_ASS()
1132 actual = fotg210_readl(fotg210, &fotg210->regs->status) & STS_ASS; in fotg210_poll_ASS()
1137 if (fotg210->ASS_poll_count++ < 20) { in fotg210_poll_ASS()
1138 fotg210_enable_event(fotg210, FOTG210_HRTIMER_POLL_ASS, in fotg210_poll_ASS()
1142 fotg210_dbg(fotg210, "Waited too long for the async schedule status (%x/%x), giving up\n", in fotg210_poll_ASS()
1145 fotg210->ASS_poll_count = 0; in fotg210_poll_ASS()
1149 if (fotg210->async_count > 0) in fotg210_poll_ASS()
1150 fotg210_set_command_bit(fotg210, CMD_ASE); in fotg210_poll_ASS()
1153 if (fotg210->async_count == 0) { in fotg210_poll_ASS()
1156 fotg210_enable_event(fotg210, in fotg210_poll_ASS()
1164 static void fotg210_disable_ASE(struct fotg210_hcd *fotg210) in fotg210_disable_ASE() argument
1166 fotg210_clear_command_bit(fotg210, CMD_ASE); in fotg210_disable_ASE()
1171 static void fotg210_poll_PSS(struct fotg210_hcd *fotg210) in fotg210_poll_PSS() argument
1176 if (fotg210->rh_state != FOTG210_RH_RUNNING) in fotg210_poll_PSS()
1179 want = (fotg210->command & CMD_PSE) ? STS_PSS : 0; in fotg210_poll_PSS()
1180 actual = fotg210_readl(fotg210, &fotg210->regs->status) & STS_PSS; in fotg210_poll_PSS()
1185 if (fotg210->PSS_poll_count++ < 20) { in fotg210_poll_PSS()
1186 fotg210_enable_event(fotg210, FOTG210_HRTIMER_POLL_PSS, in fotg210_poll_PSS()
1190 fotg210_dbg(fotg210, "Waited too long for the periodic schedule status (%x/%x), giving up\n", in fotg210_poll_PSS()
1193 fotg210->PSS_poll_count = 0; in fotg210_poll_PSS()
1197 if (fotg210->periodic_count > 0) in fotg210_poll_PSS()
1198 fotg210_set_command_bit(fotg210, CMD_PSE); in fotg210_poll_PSS()
1201 if (fotg210->periodic_count == 0) { in fotg210_poll_PSS()
1204 fotg210_enable_event(fotg210, in fotg210_poll_PSS()
1212 static void fotg210_disable_PSE(struct fotg210_hcd *fotg210) in fotg210_disable_PSE() argument
1214 fotg210_clear_command_bit(fotg210, CMD_PSE); in fotg210_disable_PSE()
1219 static void fotg210_handle_controller_death(struct fotg210_hcd *fotg210) in fotg210_handle_controller_death() argument
1221 if (!(fotg210_readl(fotg210, &fotg210->regs->status) & STS_HALT)) { in fotg210_handle_controller_death()
1224 if (fotg210->died_poll_count++ < 5) { in fotg210_handle_controller_death()
1226 fotg210_enable_event(fotg210, in fotg210_handle_controller_death()
1230 fotg210_warn(fotg210, "Waited too long for the controller to stop, giving up\n"); in fotg210_handle_controller_death()
1234 fotg210->rh_state = FOTG210_RH_HALTED; in fotg210_handle_controller_death()
1235 fotg210_writel(fotg210, 0, &fotg210->regs->intr_enable); in fotg210_handle_controller_death()
1236 fotg210_work(fotg210); in fotg210_handle_controller_death()
1237 end_unlink_async(fotg210); in fotg210_handle_controller_death()
1244 static void fotg210_handle_intr_unlinks(struct fotg210_hcd *fotg210) in fotg210_handle_intr_unlinks() argument
1246 bool stopped = (fotg210->rh_state < FOTG210_RH_RUNNING); in fotg210_handle_intr_unlinks()
1255 fotg210->intr_unlinking = true; in fotg210_handle_intr_unlinks()
1256 while (fotg210->intr_unlink) { in fotg210_handle_intr_unlinks()
1257 struct fotg210_qh *qh = fotg210->intr_unlink; in fotg210_handle_intr_unlinks()
1259 if (!stopped && qh->unlink_cycle == fotg210->intr_unlink_cycle) in fotg210_handle_intr_unlinks()
1261 fotg210->intr_unlink = qh->unlink_next; in fotg210_handle_intr_unlinks()
1263 end_unlink_intr(fotg210, qh); in fotg210_handle_intr_unlinks()
1267 if (fotg210->intr_unlink) { in fotg210_handle_intr_unlinks()
1268 fotg210_enable_event(fotg210, FOTG210_HRTIMER_UNLINK_INTR, in fotg210_handle_intr_unlinks()
1270 ++fotg210->intr_unlink_cycle; in fotg210_handle_intr_unlinks()
1272 fotg210->intr_unlinking = false; in fotg210_handle_intr_unlinks()
1277 static void start_free_itds(struct fotg210_hcd *fotg210) in start_free_itds() argument
1279 if (!(fotg210->enabled_hrtimer_events & in start_free_itds()
1281 fotg210->last_itd_to_free = list_entry( in start_free_itds()
1282 fotg210->cached_itd_list.prev, in start_free_itds()
1284 fotg210_enable_event(fotg210, FOTG210_HRTIMER_FREE_ITDS, true); in start_free_itds()
1289 static void end_free_itds(struct fotg210_hcd *fotg210) in end_free_itds() argument
1293 if (fotg210->rh_state < FOTG210_RH_RUNNING) in end_free_itds()
1294 fotg210->last_itd_to_free = NULL; in end_free_itds()
1296 list_for_each_entry_safe(itd, n, &fotg210->cached_itd_list, itd_list) { in end_free_itds()
1298 dma_pool_free(fotg210->itd_pool, itd, itd->itd_dma); in end_free_itds()
1299 if (itd == fotg210->last_itd_to_free) in end_free_itds()
1303 if (!list_empty(&fotg210->cached_itd_list)) in end_free_itds()
1304 start_free_itds(fotg210); in end_free_itds()
1309 static void fotg210_iaa_watchdog(struct fotg210_hcd *fotg210) in fotg210_iaa_watchdog() argument
1311 if (fotg210->rh_state != FOTG210_RH_RUNNING) in fotg210_iaa_watchdog()
1320 if (fotg210->async_iaa) { in fotg210_iaa_watchdog()
1329 cmd = fotg210_readl(fotg210, &fotg210->regs->command); in fotg210_iaa_watchdog()
1338 status = fotg210_readl(fotg210, &fotg210->regs->status); in fotg210_iaa_watchdog()
1340 COUNT(fotg210->stats.lost_iaa); in fotg210_iaa_watchdog()
1341 fotg210_writel(fotg210, STS_IAA, in fotg210_iaa_watchdog()
1342 &fotg210->regs->status); in fotg210_iaa_watchdog()
1345 fotg210_dbg(fotg210, "IAA watchdog: status %x cmd %x\n", in fotg210_iaa_watchdog()
1347 end_unlink_async(fotg210); in fotg210_iaa_watchdog()
1353 static void turn_on_io_watchdog(struct fotg210_hcd *fotg210) in turn_on_io_watchdog() argument
1356 if (fotg210->rh_state != FOTG210_RH_RUNNING || in turn_on_io_watchdog()
1357 (fotg210->enabled_hrtimer_events & in turn_on_io_watchdog()
1365 if (fotg210->isoc_count > 0 || (fotg210->need_io_watchdog && in turn_on_io_watchdog()
1366 fotg210->async_count + fotg210->intr_count > 0)) in turn_on_io_watchdog()
1367 fotg210_enable_event(fotg210, FOTG210_HRTIMER_IO_WATCHDOG, in turn_on_io_watchdog()
1392 struct fotg210_hcd *fotg210 = in fotg210_hrtimer_func() local
1399 spin_lock_irqsave(&fotg210->lock, flags); in fotg210_hrtimer_func()
1401 events = fotg210->enabled_hrtimer_events; in fotg210_hrtimer_func()
1402 fotg210->enabled_hrtimer_events = 0; in fotg210_hrtimer_func()
1403 fotg210->next_hrtimer_event = FOTG210_HRTIMER_NO_EVENT; in fotg210_hrtimer_func()
1411 if (now.tv64 >= fotg210->hr_timeouts[e].tv64) in fotg210_hrtimer_func()
1412 event_handlers[e](fotg210); in fotg210_hrtimer_func()
1414 fotg210_enable_event(fotg210, e, false); in fotg210_hrtimer_func()
1417 spin_unlock_irqrestore(&fotg210->lock, flags); in fotg210_hrtimer_func()
1429 struct fotg210_hcd *fotg210, in check_reset_complete() argument
1440 fotg210_dbg(fotg210, in check_reset_complete()
1445 fotg210_dbg(fotg210, "port %d reset complete, port enabled\n", in check_reset_complete()
1460 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_hub_status_data() local
1472 status = fotg210->resuming_ports; in fotg210_hub_status_data()
1480 spin_lock_irqsave(&fotg210->lock, flags); in fotg210_hub_status_data()
1482 temp = fotg210_readl(fotg210, &fotg210->regs->port_status); in fotg210_hub_status_data()
1491 if ((temp & mask) != 0 || test_bit(0, &fotg210->port_c_suspend) in fotg210_hub_status_data()
1492 || (fotg210->reset_done[0] && time_after_eq( in fotg210_hub_status_data()
1493 jiffies, fotg210->reset_done[0]))) { in fotg210_hub_status_data()
1498 spin_unlock_irqrestore(&fotg210->lock, flags); in fotg210_hub_status_data()
1506 struct fotg210_hcd *fotg210, in fotg210_hub_descriptor() argument
1509 int ports = HCS_N_PORTS(fotg210->hcs_params); in fotg210_hub_descriptor()
1539 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_hub_control() local
1540 int ports = HCS_N_PORTS(fotg210->hcs_params); in fotg210_hub_control()
1541 u32 __iomem *status_reg = &fotg210->regs->port_status; in fotg210_hub_control()
1554 spin_lock_irqsave(&fotg210->lock, flags); in fotg210_hub_control()
1570 temp = fotg210_readl(fotg210, status_reg); in fotg210_hub_control()
1582 fotg210_writel(fotg210, temp & ~PORT_PE, status_reg); in fotg210_hub_control()
1585 fotg210_writel(fotg210, temp | PORT_PEC, status_reg); in fotg210_hub_control()
1596 fotg210_writel(fotg210, temp | PORT_RESUME, status_reg); in fotg210_hub_control()
1597 fotg210->reset_done[wIndex] = jiffies in fotg210_hub_control()
1601 clear_bit(wIndex, &fotg210->port_c_suspend); in fotg210_hub_control()
1604 fotg210_writel(fotg210, temp | PORT_CSC, status_reg); in fotg210_hub_control()
1607 fotg210_writel(fotg210, temp | OTGISR_OVC, in fotg210_hub_control()
1608 &fotg210->regs->otgisr); in fotg210_hub_control()
1616 fotg210_readl(fotg210, &fotg210->regs->command); in fotg210_hub_control()
1619 fotg210_hub_descriptor(fotg210, (struct usb_hub_descriptor *) in fotg210_hub_control()
1632 temp = fotg210_readl(fotg210, status_reg); in fotg210_hub_control()
1640 temp1 = fotg210_readl(fotg210, &fotg210->regs->otgisr); in fotg210_hub_control()
1648 if (!fotg210->reset_done[wIndex]) { in fotg210_hub_control()
1650 fotg210->reset_done[wIndex] = jiffies in fotg210_hub_control()
1653 mod_timer(&fotg210_to_hcd(fotg210)->rh_timer, in fotg210_hub_control()
1654 fotg210->reset_done[wIndex]); in fotg210_hub_control()
1659 fotg210->reset_done[wIndex])) { in fotg210_hub_control()
1660 clear_bit(wIndex, &fotg210->suspended_ports); in fotg210_hub_control()
1661 set_bit(wIndex, &fotg210->port_c_suspend); in fotg210_hub_control()
1662 fotg210->reset_done[wIndex] = 0; in fotg210_hub_control()
1665 temp = fotg210_readl(fotg210, status_reg); in fotg210_hub_control()
1666 fotg210_writel(fotg210, in fotg210_hub_control()
1669 clear_bit(wIndex, &fotg210->resuming_ports); in fotg210_hub_control()
1670 retval = handshake(fotg210, status_reg, in fotg210_hub_control()
1673 fotg210_err(fotg210, in fotg210_hub_control()
1685 fotg210->reset_done[wIndex])) { in fotg210_hub_control()
1687 fotg210->reset_done[wIndex] = 0; in fotg210_hub_control()
1688 clear_bit(wIndex, &fotg210->resuming_ports); in fotg210_hub_control()
1691 fotg210_writel(fotg210, in fotg210_hub_control()
1697 retval = handshake(fotg210, status_reg, in fotg210_hub_control()
1700 fotg210_err(fotg210, "port %d reset error %d\n", in fotg210_hub_control()
1706 temp = check_reset_complete(fotg210, wIndex, status_reg, in fotg210_hub_control()
1707 fotg210_readl(fotg210, status_reg)); in fotg210_hub_control()
1711 fotg210->reset_done[wIndex] = 0; in fotg210_hub_control()
1712 clear_bit(wIndex, &fotg210->resuming_ports); in fotg210_hub_control()
1717 test_bit(wIndex, &fotg210->companion_ports)) { in fotg210_hub_control()
1719 fotg210_writel(fotg210, temp, status_reg); in fotg210_hub_control()
1720 fotg210_dbg(fotg210, "port %d --> companion\n", in fotg210_hub_control()
1722 temp = fotg210_readl(fotg210, status_reg); in fotg210_hub_control()
1733 status |= fotg210_port_speed(fotg210, temp); in fotg210_hub_control()
1741 } else if (test_bit(wIndex, &fotg210->suspended_ports)) { in fotg210_hub_control()
1742 clear_bit(wIndex, &fotg210->suspended_ports); in fotg210_hub_control()
1743 clear_bit(wIndex, &fotg210->resuming_ports); in fotg210_hub_control()
1744 fotg210->reset_done[wIndex] = 0; in fotg210_hub_control()
1746 set_bit(wIndex, &fotg210->port_c_suspend); in fotg210_hub_control()
1749 temp1 = fotg210_readl(fotg210, &fotg210->regs->otgisr); in fotg210_hub_control()
1754 if (test_bit(wIndex, &fotg210->port_c_suspend)) in fotg210_hub_control()
1758 dbg_port(fotg210, "GetStatus", wIndex + 1, temp); in fotg210_hub_control()
1778 temp = fotg210_readl(fotg210, status_reg); in fotg210_hub_control()
1790 fotg210_writel(fotg210, temp | PORT_SUSPEND, in fotg210_hub_control()
1792 set_bit(wIndex, &fotg210->suspended_ports); in fotg210_hub_control()
1801 fotg210_dbg(fotg210, "port %d reset\n", wIndex + 1); in fotg210_hub_control()
1809 fotg210->reset_done[wIndex] = jiffies in fotg210_hub_control()
1811 fotg210_writel(fotg210, temp, status_reg); in fotg210_hub_control()
1823 spin_unlock_irqrestore(&fotg210->lock, flags); in fotg210_hub_control()
1824 fotg210_quiesce(fotg210); in fotg210_hub_control()
1825 spin_lock_irqsave(&fotg210->lock, flags); in fotg210_hub_control()
1828 temp = fotg210_readl(fotg210, status_reg) & in fotg210_hub_control()
1831 fotg210_writel(fotg210, temp | PORT_SUSPEND, in fotg210_hub_control()
1834 spin_unlock_irqrestore(&fotg210->lock, flags); in fotg210_hub_control()
1835 fotg210_halt(fotg210); in fotg210_hub_control()
1836 spin_lock_irqsave(&fotg210->lock, flags); in fotg210_hub_control()
1838 temp = fotg210_readl(fotg210, status_reg); in fotg210_hub_control()
1840 fotg210_writel(fotg210, temp, status_reg); in fotg210_hub_control()
1846 fotg210_readl(fotg210, &fotg210->regs->command); in fotg210_hub_control()
1854 spin_unlock_irqrestore(&fotg210->lock, flags); in fotg210_hub_control()
1885 static inline void fotg210_qtd_init(struct fotg210_hcd *fotg210, in fotg210_qtd_init() argument
1890 qtd->hw_token = cpu_to_hc32(fotg210, QTD_STS_HALT); in fotg210_qtd_init()
1891 qtd->hw_next = FOTG210_LIST_END(fotg210); in fotg210_qtd_init()
1892 qtd->hw_alt_next = FOTG210_LIST_END(fotg210); in fotg210_qtd_init()
1896 static struct fotg210_qtd *fotg210_qtd_alloc(struct fotg210_hcd *fotg210, in fotg210_qtd_alloc() argument
1902 qtd = dma_pool_alloc(fotg210->qtd_pool, flags, &dma); in fotg210_qtd_alloc()
1904 fotg210_qtd_init(fotg210, qtd, dma); in fotg210_qtd_alloc()
1909 static inline void fotg210_qtd_free(struct fotg210_hcd *fotg210, in fotg210_qtd_free() argument
1912 dma_pool_free(fotg210->qtd_pool, qtd, qtd->qtd_dma); in fotg210_qtd_free()
1916 static void qh_destroy(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) in qh_destroy() argument
1920 fotg210_dbg(fotg210, "unused qh not empty!\n"); in qh_destroy()
1924 fotg210_qtd_free(fotg210, qh->dummy); in qh_destroy()
1925 dma_pool_free(fotg210->qh_pool, qh->hw, qh->qh_dma); in qh_destroy()
1929 static struct fotg210_qh *fotg210_qh_alloc(struct fotg210_hcd *fotg210, in fotg210_qh_alloc() argument
1939 dma_pool_alloc(fotg210->qh_pool, flags, &dma); in fotg210_qh_alloc()
1947 qh->dummy = fotg210_qtd_alloc(fotg210, flags); in fotg210_qh_alloc()
1949 fotg210_dbg(fotg210, "no dummy td\n"); in fotg210_qh_alloc()
1955 dma_pool_free(fotg210->qh_pool, qh->hw, qh->qh_dma); in fotg210_qh_alloc()
1968 static void fotg210_mem_cleanup(struct fotg210_hcd *fotg210) in fotg210_mem_cleanup() argument
1970 if (fotg210->async) in fotg210_mem_cleanup()
1971 qh_destroy(fotg210, fotg210->async); in fotg210_mem_cleanup()
1972 fotg210->async = NULL; in fotg210_mem_cleanup()
1974 if (fotg210->dummy) in fotg210_mem_cleanup()
1975 qh_destroy(fotg210, fotg210->dummy); in fotg210_mem_cleanup()
1976 fotg210->dummy = NULL; in fotg210_mem_cleanup()
1979 if (fotg210->qtd_pool) in fotg210_mem_cleanup()
1980 dma_pool_destroy(fotg210->qtd_pool); in fotg210_mem_cleanup()
1981 fotg210->qtd_pool = NULL; in fotg210_mem_cleanup()
1983 if (fotg210->qh_pool) { in fotg210_mem_cleanup()
1984 dma_pool_destroy(fotg210->qh_pool); in fotg210_mem_cleanup()
1985 fotg210->qh_pool = NULL; in fotg210_mem_cleanup()
1988 if (fotg210->itd_pool) in fotg210_mem_cleanup()
1989 dma_pool_destroy(fotg210->itd_pool); in fotg210_mem_cleanup()
1990 fotg210->itd_pool = NULL; in fotg210_mem_cleanup()
1992 if (fotg210->periodic) in fotg210_mem_cleanup()
1993 dma_free_coherent(fotg210_to_hcd(fotg210)->self.controller, in fotg210_mem_cleanup()
1994 fotg210->periodic_size * sizeof(u32), in fotg210_mem_cleanup()
1995 fotg210->periodic, fotg210->periodic_dma); in fotg210_mem_cleanup()
1996 fotg210->periodic = NULL; in fotg210_mem_cleanup()
1999 kfree(fotg210->pshadow); in fotg210_mem_cleanup()
2000 fotg210->pshadow = NULL; in fotg210_mem_cleanup()
2004 static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags) in fotg210_mem_init() argument
2009 fotg210->qtd_pool = dma_pool_create("fotg210_qtd", in fotg210_mem_init()
2010 fotg210_to_hcd(fotg210)->self.controller, in fotg210_mem_init()
2014 if (!fotg210->qtd_pool) in fotg210_mem_init()
2018 fotg210->qh_pool = dma_pool_create("fotg210_qh", in fotg210_mem_init()
2019 fotg210_to_hcd(fotg210)->self.controller, in fotg210_mem_init()
2023 if (!fotg210->qh_pool) in fotg210_mem_init()
2026 fotg210->async = fotg210_qh_alloc(fotg210, flags); in fotg210_mem_init()
2027 if (!fotg210->async) in fotg210_mem_init()
2031 fotg210->itd_pool = dma_pool_create("fotg210_itd", in fotg210_mem_init()
2032 fotg210_to_hcd(fotg210)->self.controller, in fotg210_mem_init()
2036 if (!fotg210->itd_pool) in fotg210_mem_init()
2040 fotg210->periodic = (__le32 *) in fotg210_mem_init()
2041 dma_alloc_coherent(fotg210_to_hcd(fotg210)->self.controller, in fotg210_mem_init()
2042 fotg210->periodic_size * sizeof(__le32), in fotg210_mem_init()
2043 &fotg210->periodic_dma, 0); in fotg210_mem_init()
2044 if (fotg210->periodic == NULL) in fotg210_mem_init()
2047 for (i = 0; i < fotg210->periodic_size; i++) in fotg210_mem_init()
2048 fotg210->periodic[i] = FOTG210_LIST_END(fotg210); in fotg210_mem_init()
2051 fotg210->pshadow = kcalloc(fotg210->periodic_size, sizeof(void *), in fotg210_mem_init()
2053 if (fotg210->pshadow != NULL) in fotg210_mem_init()
2057 fotg210_dbg(fotg210, "couldn't init memory\n"); in fotg210_mem_init()
2058 fotg210_mem_cleanup(fotg210); in fotg210_mem_init()
2085 qtd_fill(struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd, dma_addr_t buf, in qtd_fill() argument
2092 qtd->hw_buf[0] = cpu_to_hc32(fotg210, (u32)addr); in qtd_fill()
2093 qtd->hw_buf_hi[0] = cpu_to_hc32(fotg210, (u32)(addr >> 32)); in qtd_fill()
2104 qtd->hw_buf[i] = cpu_to_hc32(fotg210, (u32)addr); in qtd_fill()
2105 qtd->hw_buf_hi[i] = cpu_to_hc32(fotg210, in qtd_fill()
2118 qtd->hw_token = cpu_to_hc32(fotg210, (count << 16) | token); in qtd_fill()
2127 qh_update(struct fotg210_hcd *fotg210, struct fotg210_qh *qh, in qh_update() argument
2135 hw->hw_qtd_next = QTD_NEXT(fotg210, qtd->qtd_dma); in qh_update()
2136 hw->hw_alt_next = FOTG210_LIST_END(fotg210); in qh_update()
2143 if (!(hw->hw_info1 & cpu_to_hc32(fotg210, QH_TOGGLE_CTL))) { in qh_update()
2147 epnum = (hc32_to_cpup(fotg210, &hw->hw_info1) >> 8) & 0x0f; in qh_update()
2149 hw->hw_token &= ~cpu_to_hc32(fotg210, QTD_TOGGLE); in qh_update()
2154 hw->hw_token &= cpu_to_hc32(fotg210, QTD_TOGGLE | QTD_STS_PING); in qh_update()
2162 qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) in qh_refresh() argument
2178 if (cpu_to_hc32(fotg210, qtd->qtd_dma) == qh->hw->hw_current) { in qh_refresh()
2185 qh_update(fotg210, qh, qtd); in qh_refresh()
2190 static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
2195 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_clear_tt_buffer_complete() local
2199 spin_lock_irqsave(&fotg210->lock, flags); in fotg210_clear_tt_buffer_complete()
2202 && fotg210->rh_state == FOTG210_RH_RUNNING) in fotg210_clear_tt_buffer_complete()
2203 qh_link_async(fotg210, qh); in fotg210_clear_tt_buffer_complete()
2204 spin_unlock_irqrestore(&fotg210->lock, flags); in fotg210_clear_tt_buffer_complete()
2207 static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210, in fotg210_clear_tt_buffer() argument
2226 fotg210_to_hcd(fotg210)->self.root_hub) { in fotg210_clear_tt_buffer()
2234 struct fotg210_hcd *fotg210, in qtd_copy_status() argument
2276 fotg210_dbg(fotg210, "devpath %s ep%d%s 3strikes\n", in qtd_copy_status()
2285 fotg210_dbg(fotg210, in qtd_copy_status()
2297 fotg210_urb_done(struct fotg210_hcd *fotg210, struct urb *urb, int status) in fotg210_urb_done() argument
2298 __releases(fotg210->lock) in fotg210_urb_done()
2299 __acquires(fotg210->lock) in fotg210_urb_done()
2305 if ((qh->hw->hw_info2 & cpu_to_hc32(fotg210, QH_SMASK)) != 0) { in fotg210_urb_done()
2308 fotg210_to_hcd(fotg210)->self.bandwidth_int_reqs--; in fotg210_urb_done()
2313 COUNT(fotg210->stats.unlink); in fotg210_urb_done()
2318 COUNT(fotg210->stats.complete); in fotg210_urb_done()
2322 fotg210_dbg(fotg210, in fotg210_urb_done()
2332 usb_hcd_unlink_urb_from_ep(fotg210_to_hcd(fotg210), urb); in fotg210_urb_done()
2333 spin_unlock(&fotg210->lock); in fotg210_urb_done()
2334 usb_hcd_giveback_urb(fotg210_to_hcd(fotg210), urb, status); in fotg210_urb_done()
2335 spin_lock(&fotg210->lock); in fotg210_urb_done()
2338 static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
2346 qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) in qh_completions() argument
2394 fotg210_urb_done(fotg210, last->urb, in qh_completions()
2399 fotg210_qtd_free(fotg210, last); in qh_completions()
2409 token = hc32_to_cpu(fotg210, qtd->hw_token); in qh_completions()
2417 fotg210_dbg(fotg210, in qh_completions()
2439 fotg210_dbg(fotg210, in qh_completions()
2451 qtd->hw_token = cpu_to_hc32(fotg210, in qh_completions()
2454 hw->hw_token = cpu_to_hc32(fotg210, in qh_completions()
2471 & FOTG210_LIST_END(fotg210))) { in qh_completions()
2477 && fotg210->rh_state >= FOTG210_RH_RUNNING)) { in qh_completions()
2485 if (fotg210->rh_state < FOTG210_RH_RUNNING) in qh_completions()
2496 && cpu_to_hc32(fotg210, qtd->qtd_dma) in qh_completions()
2498 token = hc32_to_cpu(fotg210, hw->hw_token); in qh_completions()
2504 fotg210_clear_tt_buffer(fotg210, qh, urb, in qh_completions()
2517 last_status = qtd_copy_status(fotg210, urb, in qh_completions()
2521 & FOTG210_LIST_END(fotg210))) in qh_completions()
2539 fotg210_clear_tt_buffer(fotg210, qh, in qh_completions()
2563 fotg210_urb_done(fotg210, last->urb, last_status); in qh_completions()
2565 fotg210_qtd_free(fotg210, last); in qh_completions()
2590 if (stopped != 0 || hw->hw_qtd_next == FOTG210_LIST_END(fotg210)) { in qh_completions()
2593 qh_refresh(fotg210, qh); in qh_completions()
2630 struct fotg210_hcd *fotg210, in qtd_list_free() argument
2641 fotg210_qtd_free(fotg210, qtd); in qtd_list_free()
2650 struct fotg210_hcd *fotg210, in qh_urb_transaction() argument
2666 qtd = fotg210_qtd_alloc(fotg210, flags); in qh_urb_transaction()
2680 qtd_fill(fotg210, qtd, urb->setup_dma, in qh_urb_transaction()
2687 qtd = fotg210_qtd_alloc(fotg210, flags); in qh_urb_transaction()
2691 qtd_prev->hw_next = QTD_NEXT(fotg210, qtd->qtd_dma); in qh_urb_transaction()
2731 this_qtd_len = qtd_fill(fotg210, qtd, buf, this_sg_len, token, in qh_urb_transaction()
2743 qtd->hw_alt_next = fotg210->async->hw->hw_alt_next; in qh_urb_transaction()
2758 qtd = fotg210_qtd_alloc(fotg210, flags); in qh_urb_transaction()
2762 qtd_prev->hw_next = QTD_NEXT(fotg210, qtd->qtd_dma); in qh_urb_transaction()
2773 qtd->hw_alt_next = FOTG210_LIST_END(fotg210); in qh_urb_transaction()
2794 qtd = fotg210_qtd_alloc(fotg210, flags); in qh_urb_transaction()
2798 qtd_prev->hw_next = QTD_NEXT(fotg210, qtd->qtd_dma); in qh_urb_transaction()
2802 qtd_fill(fotg210, qtd, 0, 0, token, 0); in qh_urb_transaction()
2808 qtd->hw_token |= cpu_to_hc32(fotg210, QTD_IOC); in qh_urb_transaction()
2812 qtd_list_free(fotg210, urb, head); in qh_urb_transaction()
2836 struct fotg210_hcd *fotg210, in qh_make() argument
2840 struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags); in qh_make()
2864 fotg210_dbg(fotg210, "bogus qh maxpacket %d\n", in qh_make()
2894 } else if (qh->period > fotg210->periodic_size) { in qh_make()
2895 qh->period = fotg210->periodic_size; in qh_make()
2919 if (qh->period > fotg210->periodic_size) { in qh_make()
2920 qh->period = fotg210->periodic_size; in qh_make()
2950 if (fotg210_has_fsl_portno_bug(fotg210)) in qh_make()
2958 if (tt && tt->hub != fotg210_to_hcd(fotg210)->self.root_hub) in qh_make()
2988 fotg210_dbg(fotg210, "bogus dev %p speed %d\n", urb->dev, in qh_make()
2991 qh_destroy(fotg210, qh); in qh_make()
3000 hw->hw_info1 = cpu_to_hc32(fotg210, info1); in qh_make()
3001 hw->hw_info2 = cpu_to_hc32(fotg210, info2); in qh_make()
3004 qh_refresh(fotg210, qh); in qh_make()
3010 static void enable_async(struct fotg210_hcd *fotg210) in enable_async() argument
3012 if (fotg210->async_count++) in enable_async()
3016 fotg210->enabled_hrtimer_events &= ~BIT(FOTG210_HRTIMER_DISABLE_ASYNC); in enable_async()
3019 fotg210_poll_ASS(fotg210); in enable_async()
3020 turn_on_io_watchdog(fotg210); in enable_async()
3023 static void disable_async(struct fotg210_hcd *fotg210) in disable_async() argument
3025 if (--fotg210->async_count) in disable_async()
3029 WARN_ON(fotg210->async->qh_next.qh || fotg210->async_unlink); in disable_async()
3032 fotg210_poll_ASS(fotg210); in disable_async()
3037 static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) in qh_link_async() argument
3039 __hc32 dma = QH_NEXT(fotg210, qh->qh_dma); in qh_link_async()
3049 qh_refresh(fotg210, qh); in qh_link_async()
3052 head = fotg210->async; in qh_link_async()
3064 enable_async(fotg210); in qh_link_async()
3076 struct fotg210_hcd *fotg210, in qh_append_tds() argument
3084 __hc32 qh_addr_mask = cpu_to_hc32(fotg210, 0x7f); in qh_append_tds()
3089 qh = qh_make(fotg210, urb, GFP_ATOMIC); in qh_append_tds()
3122 qtd->hw_token = HALT_BIT(fotg210); in qh_append_tds()
3134 fotg210_qtd_init(fotg210, qtd, qtd->qtd_dma); in qh_append_tds()
3141 qtd->hw_next = QTD_NEXT(fotg210, dma); in qh_append_tds()
3157 struct fotg210_hcd *fotg210, in submit_async() argument
3173 fotg210_dbg(fotg210, in submit_async()
3182 spin_lock_irqsave(&fotg210->lock, flags); in submit_async()
3183 if (unlikely(!HCD_HW_ACCESSIBLE(fotg210_to_hcd(fotg210)))) { in submit_async()
3187 rc = usb_hcd_link_urb_to_ep(fotg210_to_hcd(fotg210), urb); in submit_async()
3191 qh = qh_append_tds(fotg210, urb, qtd_list, epnum, &urb->ep->hcpriv); in submit_async()
3193 usb_hcd_unlink_urb_from_ep(fotg210_to_hcd(fotg210), urb); in submit_async()
3202 qh_link_async(fotg210, qh); in submit_async()
3204 spin_unlock_irqrestore(&fotg210->lock, flags); in submit_async()
3206 qtd_list_free(fotg210, urb, qtd_list); in submit_async()
3212 static void single_unlink_async(struct fotg210_hcd *fotg210, in single_unlink_async() argument
3219 if (fotg210->async_unlink) in single_unlink_async()
3220 fotg210->async_unlink_last->unlink_next = qh; in single_unlink_async()
3222 fotg210->async_unlink = qh; in single_unlink_async()
3223 fotg210->async_unlink_last = qh; in single_unlink_async()
3226 prev = fotg210->async; in single_unlink_async()
3232 if (fotg210->qh_scan_next == qh) in single_unlink_async()
3233 fotg210->qh_scan_next = qh->qh_next.qh; in single_unlink_async()
3236 static void start_iaa_cycle(struct fotg210_hcd *fotg210, bool nested) in start_iaa_cycle() argument
3242 if (fotg210->async_iaa || fotg210->async_unlinking) in start_iaa_cycle()
3246 fotg210->async_iaa = fotg210->async_unlink; in start_iaa_cycle()
3247 fotg210->async_unlink = NULL; in start_iaa_cycle()
3250 if (unlikely(fotg210->rh_state < FOTG210_RH_RUNNING)) { in start_iaa_cycle()
3252 end_unlink_async(fotg210); in start_iaa_cycle()
3255 } else if (likely(fotg210->rh_state == FOTG210_RH_RUNNING)) { in start_iaa_cycle()
3259 fotg210_writel(fotg210, fotg210->command | CMD_IAAD, in start_iaa_cycle()
3260 &fotg210->regs->command); in start_iaa_cycle()
3261 fotg210_readl(fotg210, &fotg210->regs->command); in start_iaa_cycle()
3262 fotg210_enable_event(fotg210, FOTG210_HRTIMER_IAA_WATCHDOG, in start_iaa_cycle()
3269 static void end_unlink_async(struct fotg210_hcd *fotg210) in end_unlink_async() argument
3275 fotg210->async_unlinking = true; in end_unlink_async()
3276 while (fotg210->async_iaa) { in end_unlink_async()
3277 qh = fotg210->async_iaa; in end_unlink_async()
3278 fotg210->async_iaa = qh->unlink_next; in end_unlink_async()
3284 qh_completions(fotg210, qh); in end_unlink_async()
3286 fotg210->rh_state == FOTG210_RH_RUNNING) in end_unlink_async()
3287 qh_link_async(fotg210, qh); in end_unlink_async()
3288 disable_async(fotg210); in end_unlink_async()
3290 fotg210->async_unlinking = false; in end_unlink_async()
3293 if (fotg210->async_unlink) { in end_unlink_async()
3294 start_iaa_cycle(fotg210, true); in end_unlink_async()
3295 if (unlikely(fotg210->rh_state < FOTG210_RH_RUNNING)) in end_unlink_async()
3300 static void unlink_empty_async(struct fotg210_hcd *fotg210) in unlink_empty_async() argument
3303 bool stopped = (fotg210->rh_state < FOTG210_RH_RUNNING); in unlink_empty_async()
3307 next = fotg210->async->qh_next.qh; in unlink_empty_async()
3315 fotg210->async_unlink_cycle) in unlink_empty_async()
3318 single_unlink_async(fotg210, qh); in unlink_empty_async()
3323 if (fotg210->async_unlink) in unlink_empty_async()
3324 start_iaa_cycle(fotg210, false); in unlink_empty_async()
3328 fotg210_enable_event(fotg210, FOTG210_HRTIMER_ASYNC_UNLINKS, in unlink_empty_async()
3330 ++fotg210->async_unlink_cycle; in unlink_empty_async()
3337 static void start_unlink_async(struct fotg210_hcd *fotg210, in start_unlink_async() argument
3351 single_unlink_async(fotg210, qh); in start_unlink_async()
3352 start_iaa_cycle(fotg210, false); in start_unlink_async()
3357 static void scan_async(struct fotg210_hcd *fotg210) in scan_async() argument
3362 fotg210->qh_scan_next = fotg210->async->qh_next.qh; in scan_async()
3363 while (fotg210->qh_scan_next) { in scan_async()
3364 qh = fotg210->qh_scan_next; in scan_async()
3365 fotg210->qh_scan_next = qh->qh_next.qh; in scan_async()
3378 temp = qh_completions(fotg210, qh); in scan_async()
3380 start_unlink_async(fotg210, qh); in scan_async()
3383 qh->unlink_cycle = fotg210->async_unlink_cycle; in scan_async()
3396 if (check_unlinks_later && fotg210->rh_state == FOTG210_RH_RUNNING && in scan_async()
3397 !(fotg210->enabled_hrtimer_events & in scan_async()
3399 fotg210_enable_event(fotg210, in scan_async()
3401 ++fotg210->async_unlink_cycle; in scan_async()
3428 periodic_next_shadow(struct fotg210_hcd *fotg210, in periodic_next_shadow() argument
3431 switch (hc32_to_cpu(fotg210, tag)) { in periodic_next_shadow()
3442 shadow_next_periodic(struct fotg210_hcd *fotg210, in shadow_next_periodic() argument
3445 switch (hc32_to_cpu(fotg210, tag)) { in shadow_next_periodic()
3456 static void periodic_unlink(struct fotg210_hcd *fotg210, unsigned frame, in periodic_unlink() argument
3459 union fotg210_shadow *prev_p = &fotg210->pshadow[frame]; in periodic_unlink()
3460 __hc32 *hw_p = &fotg210->periodic[frame]; in periodic_unlink()
3465 prev_p = periodic_next_shadow(fotg210, prev_p, in periodic_unlink()
3466 Q_NEXT_TYPE(fotg210, *hw_p)); in periodic_unlink()
3467 hw_p = shadow_next_periodic(fotg210, &here, in periodic_unlink()
3468 Q_NEXT_TYPE(fotg210, *hw_p)); in periodic_unlink()
3478 *prev_p = *periodic_next_shadow(fotg210, &here, in periodic_unlink()
3479 Q_NEXT_TYPE(fotg210, *hw_p)); in periodic_unlink()
3481 *hw_p = *shadow_next_periodic(fotg210, &here, in periodic_unlink()
3482 Q_NEXT_TYPE(fotg210, *hw_p)); in periodic_unlink()
3487 periodic_usecs(struct fotg210_hcd *fotg210, unsigned frame, unsigned uframe) in periodic_usecs() argument
3489 __hc32 *hw_p = &fotg210->periodic[frame]; in periodic_usecs()
3490 union fotg210_shadow *q = &fotg210->pshadow[frame]; in periodic_usecs()
3495 switch (hc32_to_cpu(fotg210, Q_NEXT_TYPE(fotg210, *hw_p))) { in periodic_usecs()
3499 if (hw->hw_info2 & cpu_to_hc32(fotg210, 1 << uframe)) in periodic_usecs()
3502 if (hw->hw_info2 & cpu_to_hc32(fotg210, in periodic_usecs()
3513 if (q->fstn->hw_prev != FOTG210_LIST_END(fotg210)) in periodic_usecs()
3514 fotg210_dbg(fotg210, "ignoring FSTN cost ...\n"); in periodic_usecs()
3527 if (usecs > fotg210->uframe_periodic_max) in periodic_usecs()
3528 fotg210_err(fotg210, "uframe %d sched overrun: %d usecs\n", in periodic_usecs()
3552 struct fotg210_hcd *fotg210, in tt_no_collision() argument
3566 for (; frame < fotg210->periodic_size; frame += period) { in tt_no_collision()
3571 here = fotg210->pshadow[frame]; in tt_no_collision()
3572 type = Q_NEXT_TYPE(fotg210, fotg210->periodic[frame]); in tt_no_collision()
3574 switch (hc32_to_cpu(fotg210, type)) { in tt_no_collision()
3576 type = Q_NEXT_TYPE(fotg210, here.itd->hw_next); in tt_no_collision()
3584 mask = hc32_to_cpu(fotg210, in tt_no_collision()
3591 type = Q_NEXT_TYPE(fotg210, hw->hw_next); in tt_no_collision()
3596 fotg210_dbg(fotg210, in tt_no_collision()
3612 static void enable_periodic(struct fotg210_hcd *fotg210) in enable_periodic() argument
3614 if (fotg210->periodic_count++) in enable_periodic()
3618 fotg210->enabled_hrtimer_events &= in enable_periodic()
3622 fotg210_poll_PSS(fotg210); in enable_periodic()
3623 turn_on_io_watchdog(fotg210); in enable_periodic()
3626 static void disable_periodic(struct fotg210_hcd *fotg210) in disable_periodic() argument
3628 if (--fotg210->periodic_count) in disable_periodic()
3632 fotg210_poll_PSS(fotg210); in disable_periodic()
3643 static void qh_link_periodic(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) in qh_link_periodic() argument
3650 period, hc32_to_cpup(fotg210, &qh->hw->hw_info2) in qh_link_periodic()
3658 for (i = qh->start; i < fotg210->periodic_size; i += period) { in qh_link_periodic()
3659 union fotg210_shadow *prev = &fotg210->pshadow[i]; in qh_link_periodic()
3660 __hc32 *hw_p = &fotg210->periodic[i]; in qh_link_periodic()
3666 type = Q_NEXT_TYPE(fotg210, *hw_p); in qh_link_periodic()
3667 if (type == cpu_to_hc32(fotg210, Q_TYPE_QH)) in qh_link_periodic()
3669 prev = periodic_next_shadow(fotg210, prev, type); in qh_link_periodic()
3670 hw_p = shadow_next_periodic(fotg210, &here, type); in qh_link_periodic()
3691 *hw_p = QH_NEXT(fotg210, qh->qh_dma); in qh_link_periodic()
3698 fotg210_to_hcd(fotg210)->self.bandwidth_allocated += qh->period in qh_link_periodic()
3702 list_add(&qh->intr_node, &fotg210->intr_qh_list); in qh_link_periodic()
3705 ++fotg210->intr_count; in qh_link_periodic()
3706 enable_periodic(fotg210); in qh_link_periodic()
3709 static void qh_unlink_periodic(struct fotg210_hcd *fotg210, in qh_unlink_periodic() argument
3735 for (i = qh->start; i < fotg210->periodic_size; i += period) in qh_unlink_periodic()
3736 periodic_unlink(fotg210, i, qh); in qh_unlink_periodic()
3739 fotg210_to_hcd(fotg210)->self.bandwidth_allocated -= qh->period in qh_unlink_periodic()
3746 hc32_to_cpup(fotg210, &qh->hw->hw_info2) & in qh_unlink_periodic()
3753 if (fotg210->qh_scan_next == qh) in qh_unlink_periodic()
3754 fotg210->qh_scan_next = list_entry(qh->intr_node.next, in qh_unlink_periodic()
3759 static void start_unlink_intr(struct fotg210_hcd *fotg210, in start_unlink_intr() argument
3772 qh_unlink_periodic(fotg210, qh); in start_unlink_intr()
3782 qh->unlink_cycle = fotg210->intr_unlink_cycle; in start_unlink_intr()
3785 if (fotg210->intr_unlink) in start_unlink_intr()
3786 fotg210->intr_unlink_last->unlink_next = qh; in start_unlink_intr()
3788 fotg210->intr_unlink = qh; in start_unlink_intr()
3789 fotg210->intr_unlink_last = qh; in start_unlink_intr()
3791 if (fotg210->intr_unlinking) in start_unlink_intr()
3793 else if (fotg210->rh_state < FOTG210_RH_RUNNING) in start_unlink_intr()
3794 fotg210_handle_intr_unlinks(fotg210); in start_unlink_intr()
3795 else if (fotg210->intr_unlink == qh) { in start_unlink_intr()
3796 fotg210_enable_event(fotg210, FOTG210_HRTIMER_UNLINK_INTR, in start_unlink_intr()
3798 ++fotg210->intr_unlink_cycle; in start_unlink_intr()
3802 static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) in end_unlink_intr() argument
3808 hw->hw_next = FOTG210_LIST_END(fotg210); in end_unlink_intr()
3810 qh_completions(fotg210, qh); in end_unlink_intr()
3814 fotg210->rh_state == FOTG210_RH_RUNNING) { in end_unlink_intr()
3815 rc = qh_schedule(fotg210, qh); in end_unlink_intr()
3824 fotg210_err(fotg210, "can't reschedule qh %p, err %d\n", in end_unlink_intr()
3829 --fotg210->intr_count; in end_unlink_intr()
3830 disable_periodic(fotg210); in end_unlink_intr()
3836 struct fotg210_hcd *fotg210, in check_period() argument
3851 usecs = fotg210->uframe_periodic_max - usecs; in check_period()
3859 claimed = periodic_usecs(fotg210, frame, in check_period()
3864 } while ((frame += 1) < fotg210->periodic_size); in check_period()
3869 claimed = periodic_usecs(fotg210, frame, uframe); in check_period()
3872 } while ((frame += period) < fotg210->periodic_size); in check_period()
3880 struct fotg210_hcd *fotg210, in check_intr_schedule() argument
3893 if (!check_period(fotg210, frame, uframe, qh->period, qh->usecs)) in check_intr_schedule()
3909 *c_maskp = cpu_to_hc32(fotg210, mask << 8); in check_intr_schedule()
3912 if (tt_no_collision(fotg210, qh->period, qh->dev, frame, mask)) { in check_intr_schedule()
3913 if (!check_period(fotg210, frame, uframe + qh->gap_uf + 1, in check_intr_schedule()
3916 if (!check_period(fotg210, frame, uframe + qh->gap_uf, in check_intr_schedule()
3928 static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) in qh_schedule() argument
3936 qh_refresh(fotg210, qh); in qh_schedule()
3937 hw->hw_next = FOTG210_LIST_END(fotg210); in qh_schedule()
3942 uframe = ffs(hc32_to_cpup(fotg210, &hw->hw_info2) & QH_SMASK); in qh_schedule()
3943 status = check_intr_schedule(fotg210, frame, --uframe, in qh_schedule()
3960 frame = ++fotg210->random_frame % qh->period; in qh_schedule()
3962 status = check_intr_schedule(fotg210, in qh_schedule()
3973 status = check_intr_schedule(fotg210, 0, 0, qh, in qh_schedule()
3981 hw->hw_info2 &= cpu_to_hc32(fotg210, ~(QH_CMASK | QH_SMASK)); in qh_schedule()
3983 ? cpu_to_hc32(fotg210, 1 << uframe) in qh_schedule()
3984 : cpu_to_hc32(fotg210, QH_SMASK); in qh_schedule()
3987 fotg210_dbg(fotg210, "reused qh %p schedule\n", qh); in qh_schedule()
3990 qh_link_periodic(fotg210, qh); in qh_schedule()
3996 struct fotg210_hcd *fotg210, in intr_submit() argument
4010 spin_lock_irqsave(&fotg210->lock, flags); in intr_submit()
4012 if (unlikely(!HCD_HW_ACCESSIBLE(fotg210_to_hcd(fotg210)))) { in intr_submit()
4016 status = usb_hcd_link_urb_to_ep(fotg210_to_hcd(fotg210), urb); in intr_submit()
4022 qh = qh_append_tds(fotg210, urb, &empty, epnum, &urb->ep->hcpriv); in intr_submit()
4028 status = qh_schedule(fotg210, qh); in intr_submit()
4034 qh = qh_append_tds(fotg210, urb, qtd_list, epnum, &urb->ep->hcpriv); in intr_submit()
4038 fotg210_to_hcd(fotg210)->self.bandwidth_int_reqs++; in intr_submit()
4042 usb_hcd_unlink_urb_from_ep(fotg210_to_hcd(fotg210), urb); in intr_submit()
4044 spin_unlock_irqrestore(&fotg210->lock, flags); in intr_submit()
4046 qtd_list_free(fotg210, urb, qtd_list); in intr_submit()
4051 static void scan_intr(struct fotg210_hcd *fotg210) in scan_intr() argument
4055 list_for_each_entry_safe(qh, fotg210->qh_scan_next, in scan_intr()
4056 &fotg210->intr_qh_list, intr_node) { in scan_intr()
4069 temp = qh_completions(fotg210, qh); in scan_intr()
4073 start_unlink_intr(fotg210, qh); in scan_intr()
4100 struct fotg210_hcd *fotg210, in iso_stream_init() argument
4130 stream->buf0 = cpu_to_hc32(fotg210, (epnum << 8) | dev->devnum); in iso_stream_init()
4131 stream->buf1 = cpu_to_hc32(fotg210, buf1); in iso_stream_init()
4132 stream->buf2 = cpu_to_hc32(fotg210, multi); in iso_stream_init()
4157 iso_stream_find(struct fotg210_hcd *fotg210, struct urb *urb) in iso_stream_find() argument
4170 spin_lock_irqsave(&fotg210->lock, flags); in iso_stream_find()
4178 iso_stream_init(fotg210, stream, urb->dev, urb->pipe, in iso_stream_find()
4184 fotg210_dbg(fotg210, "dev %s ep%d%s, not iso??\n", in iso_stream_find()
4190 spin_unlock_irqrestore(&fotg210->lock, flags); in iso_stream_find()
4214 struct fotg210_hcd *fotg210, in itd_sched_init() argument
4244 uframe->transaction = cpu_to_hc32(fotg210, trans); in itd_sched_init()
4270 struct fotg210_hcd *fotg210, in itd_urb_transaction() argument
4286 itd_sched_init(fotg210, sched, stream, urb); in itd_urb_transaction()
4294 spin_lock_irqsave(&fotg210->lock, flags); in itd_urb_transaction()
4304 if (itd->frame == fotg210->now_frame) in itd_urb_transaction()
4310 spin_unlock_irqrestore(&fotg210->lock, flags); in itd_urb_transaction()
4311 itd = dma_pool_alloc(fotg210->itd_pool, mem_flags, in itd_urb_transaction()
4313 spin_lock_irqsave(&fotg210->lock, flags); in itd_urb_transaction()
4316 spin_unlock_irqrestore(&fotg210->lock, flags); in itd_urb_transaction()
4325 spin_unlock_irqrestore(&fotg210->lock, flags); in itd_urb_transaction()
4337 struct fotg210_hcd *fotg210, in itd_slot_ok() argument
4347 if (periodic_usecs(fotg210, uframe >> 3, uframe & 0x7) in itd_slot_ok()
4348 > (fotg210->uframe_periodic_max - usecs)) in itd_slot_ok()
4372 struct fotg210_hcd *fotg210, in iso_stream_schedule() argument
4379 unsigned mod = fotg210->periodic_size << 3; in iso_stream_schedule()
4386 fotg210_dbg(fotg210, "iso request %p too long\n", urb); in iso_stream_schedule()
4391 now = fotg210_read_frame_index(fotg210) & (mod - 1); in iso_stream_schedule()
4406 if (!stream->highspeed && fotg210->fs_i_thresh) in iso_stream_schedule()
4407 next = now + fotg210->i_thresh; in iso_stream_schedule()
4422 fotg210_dbg(fotg210, "request %p would overflow (%d+%d >= %d)\n", in iso_stream_schedule()
4452 if (itd_slot_ok(fotg210, mod, start, in iso_stream_schedule()
4459 fotg210_dbg(fotg210, "iso resched full %p (now %d max %d)\n", in iso_stream_schedule()
4469 fotg210_dbg(fotg210, "request %p would overflow (%d+%d >= %d)\n", in iso_stream_schedule()
4484 if (fotg210->isoc_count == 0) in iso_stream_schedule()
4485 fotg210->next_frame = now >> 3; in iso_stream_schedule()
4497 itd_init(struct fotg210_hcd *fotg210, struct fotg210_iso_stream *stream, in itd_init() argument
4503 itd->hw_next = FOTG210_LIST_END(fotg210); in itd_init()
4516 struct fotg210_hcd *fotg210, in itd_patch() argument
4530 itd->hw_transaction[uframe] |= cpu_to_hc32(fotg210, pg << 12); in itd_patch()
4531 itd->hw_bufp[pg] |= cpu_to_hc32(fotg210, uf->bufp & ~(u32)0); in itd_patch()
4532 itd->hw_bufp_hi[pg] |= cpu_to_hc32(fotg210, (u32)(uf->bufp >> 32)); in itd_patch()
4539 itd->hw_bufp[pg] |= cpu_to_hc32(fotg210, bufp & ~(u32)0); in itd_patch()
4540 itd->hw_bufp_hi[pg] |= cpu_to_hc32(fotg210, (u32)(bufp >> 32)); in itd_patch()
4545 itd_link(struct fotg210_hcd *fotg210, unsigned frame, struct fotg210_itd *itd) in itd_link() argument
4547 union fotg210_shadow *prev = &fotg210->pshadow[frame]; in itd_link()
4548 __hc32 *hw_p = &fotg210->periodic[frame]; in itd_link()
4554 type = Q_NEXT_TYPE(fotg210, *hw_p); in itd_link()
4555 if (type == cpu_to_hc32(fotg210, Q_TYPE_QH)) in itd_link()
4557 prev = periodic_next_shadow(fotg210, prev, type); in itd_link()
4558 hw_p = shadow_next_periodic(fotg210, &here, type); in itd_link()
4567 *hw_p = cpu_to_hc32(fotg210, itd->itd_dma | Q_TYPE_ITD); in itd_link()
4572 struct fotg210_hcd *fotg210, in itd_link_urb() argument
4586 fotg210_to_hcd(fotg210)->self.bandwidth_allocated in itd_link_urb()
4588 fotg210_dbg(fotg210, in itd_link_urb()
4608 itd_init(fotg210, stream, itd); in itd_link_urb()
4614 itd_patch(fotg210, itd, iso_sched, packet, uframe); in itd_link_urb()
4623 itd_link(fotg210, frame & (fotg210->periodic_size - 1), in itd_link_urb()
4634 ++fotg210->isoc_count; in itd_link_urb()
4635 enable_periodic(fotg210); in itd_link_urb()
4651 static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd) in itd_complete() argument
4669 t = hc32_to_cpup(fotg210, &itd->hw_transaction[uframe]); in itd_complete()
4711 fotg210_urb_done(fotg210, urb, 0); in itd_complete()
4715 --fotg210->isoc_count; in itd_complete()
4716 disable_periodic(fotg210); in itd_complete()
4719 fotg210_to_hcd(fotg210)->self.bandwidth_allocated in itd_complete()
4721 fotg210_dbg(fotg210, in itd_complete()
4736 &fotg210->cached_itd_list); in itd_complete()
4737 start_free_itds(fotg210); in itd_complete()
4745 static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb, in itd_submit() argument
4753 stream = iso_stream_find(fotg210, urb); in itd_submit()
4755 fotg210_dbg(fotg210, "can't get iso stream\n"); in itd_submit()
4759 fotg210_port_speed(fotg210, 0) == in itd_submit()
4761 fotg210_dbg(fotg210, "can't change iso interval %d --> %d\n", in itd_submit()
4767 fotg210_dbg(fotg210, in itd_submit()
4778 status = itd_urb_transaction(stream, fotg210, urb, mem_flags); in itd_submit()
4780 fotg210_dbg(fotg210, "can't init itds\n"); in itd_submit()
4785 spin_lock_irqsave(&fotg210->lock, flags); in itd_submit()
4786 if (unlikely(!HCD_HW_ACCESSIBLE(fotg210_to_hcd(fotg210)))) { in itd_submit()
4790 status = usb_hcd_link_urb_to_ep(fotg210_to_hcd(fotg210), urb); in itd_submit()
4793 status = iso_stream_schedule(fotg210, urb, stream); in itd_submit()
4795 itd_link_urb(fotg210, urb, fotg210->periodic_size << 3, stream); in itd_submit()
4797 usb_hcd_unlink_urb_from_ep(fotg210_to_hcd(fotg210), urb); in itd_submit()
4799 spin_unlock_irqrestore(&fotg210->lock, flags); in itd_submit()
4806 static void scan_isoc(struct fotg210_hcd *fotg210) in scan_isoc() argument
4809 unsigned fmask = fotg210->periodic_size - 1; in scan_isoc()
4817 if (fotg210->rh_state >= FOTG210_RH_RUNNING) { in scan_isoc()
4818 uf = fotg210_read_frame_index(fotg210); in scan_isoc()
4822 now_frame = (fotg210->next_frame - 1) & fmask; in scan_isoc()
4825 fotg210->now_frame = now_frame; in scan_isoc()
4827 frame = fotg210->next_frame; in scan_isoc()
4834 q_p = &fotg210->pshadow[frame]; in scan_isoc()
4835 hw_p = &fotg210->periodic[frame]; in scan_isoc()
4837 type = Q_NEXT_TYPE(fotg210, *hw_p); in scan_isoc()
4841 switch (hc32_to_cpu(fotg210, type)) { in scan_isoc()
4852 ITD_ACTIVE(fotg210)) in scan_isoc()
4858 type = Q_NEXT_TYPE(fotg210, in scan_isoc()
4872 type = Q_NEXT_TYPE(fotg210, q.itd->hw_next); in scan_isoc()
4874 modified = itd_complete(fotg210, q.itd); in scan_isoc()
4878 fotg210_dbg(fotg210, "corrupt type %d frame %d shadow %p\n", in scan_isoc()
4889 if (unlikely(modified && fotg210->isoc_count > 0)) in scan_isoc()
4898 fotg210->next_frame = now_frame; in scan_isoc()
4908 struct fotg210_hcd *fotg210; in show_uframe_periodic_max() local
4911 fotg210 = hcd_to_fotg210(bus_to_hcd(dev_get_drvdata(dev))); in show_uframe_periodic_max()
4912 n = scnprintf(buf, PAGE_SIZE, "%d\n", fotg210->uframe_periodic_max); in show_uframe_periodic_max()
4921 struct fotg210_hcd *fotg210; in store_uframe_periodic_max() local
4928 fotg210 = hcd_to_fotg210(bus_to_hcd(dev_get_drvdata(dev))); in store_uframe_periodic_max()
4933 fotg210_info(fotg210, "rejecting invalid request for uframe_periodic_max=%u\n", in store_uframe_periodic_max()
4944 spin_lock_irqsave(&fotg210->lock, flags); in store_uframe_periodic_max()
4951 if (uframe_periodic_max < fotg210->uframe_periodic_max) { in store_uframe_periodic_max()
4954 for (frame = 0; frame < fotg210->periodic_size; ++frame) in store_uframe_periodic_max()
4957 periodic_usecs(fotg210, frame, uframe)); in store_uframe_periodic_max()
4960 fotg210_info(fotg210, in store_uframe_periodic_max()
4971 fotg210_info(fotg210, "setting max periodic bandwidth to %u%% (== %u usec/uframe)\n", in store_uframe_periodic_max()
4975 fotg210_warn(fotg210, "max periodic bandwidth set is non-standard\n"); in store_uframe_periodic_max()
4977 fotg210->uframe_periodic_max = uframe_periodic_max; in store_uframe_periodic_max()
4981 spin_unlock_irqrestore(&fotg210->lock, flags); in store_uframe_periodic_max()
4988 static inline int create_sysfs_files(struct fotg210_hcd *fotg210) in create_sysfs_files() argument
4990 struct device *controller = fotg210_to_hcd(fotg210)->self.controller; in create_sysfs_files()
5001 static inline void remove_sysfs_files(struct fotg210_hcd *fotg210) in remove_sysfs_files() argument
5003 struct device *controller = fotg210_to_hcd(fotg210)->self.controller; in remove_sysfs_files()
5013 static void fotg210_turn_off_all_ports(struct fotg210_hcd *fotg210) in fotg210_turn_off_all_ports() argument
5015 u32 __iomem *status_reg = &fotg210->regs->port_status; in fotg210_turn_off_all_ports()
5017 fotg210_writel(fotg210, PORT_RWC_BITS, status_reg); in fotg210_turn_off_all_ports()
5024 static void fotg210_silence_controller(struct fotg210_hcd *fotg210) in fotg210_silence_controller() argument
5026 fotg210_halt(fotg210); in fotg210_silence_controller()
5028 spin_lock_irq(&fotg210->lock); in fotg210_silence_controller()
5029 fotg210->rh_state = FOTG210_RH_HALTED; in fotg210_silence_controller()
5030 fotg210_turn_off_all_ports(fotg210); in fotg210_silence_controller()
5031 spin_unlock_irq(&fotg210->lock); in fotg210_silence_controller()
5040 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_shutdown() local
5042 spin_lock_irq(&fotg210->lock); in fotg210_shutdown()
5043 fotg210->shutdown = true; in fotg210_shutdown()
5044 fotg210->rh_state = FOTG210_RH_STOPPING; in fotg210_shutdown()
5045 fotg210->enabled_hrtimer_events = 0; in fotg210_shutdown()
5046 spin_unlock_irq(&fotg210->lock); in fotg210_shutdown()
5048 fotg210_silence_controller(fotg210); in fotg210_shutdown()
5050 hrtimer_cancel(&fotg210->hrtimer); in fotg210_shutdown()
5059 static void fotg210_work(struct fotg210_hcd *fotg210) in fotg210_work() argument
5065 if (fotg210->scanning) { in fotg210_work()
5066 fotg210->need_rescan = true; in fotg210_work()
5069 fotg210->scanning = true; in fotg210_work()
5072 fotg210->need_rescan = false; in fotg210_work()
5073 if (fotg210->async_count) in fotg210_work()
5074 scan_async(fotg210); in fotg210_work()
5075 if (fotg210->intr_count > 0) in fotg210_work()
5076 scan_intr(fotg210); in fotg210_work()
5077 if (fotg210->isoc_count > 0) in fotg210_work()
5078 scan_isoc(fotg210); in fotg210_work()
5079 if (fotg210->need_rescan) in fotg210_work()
5081 fotg210->scanning = false; in fotg210_work()
5087 turn_on_io_watchdog(fotg210); in fotg210_work()
5095 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_stop() local
5097 fotg210_dbg(fotg210, "stop\n"); in fotg210_stop()
5101 spin_lock_irq(&fotg210->lock); in fotg210_stop()
5102 fotg210->enabled_hrtimer_events = 0; in fotg210_stop()
5103 spin_unlock_irq(&fotg210->lock); in fotg210_stop()
5105 fotg210_quiesce(fotg210); in fotg210_stop()
5106 fotg210_silence_controller(fotg210); in fotg210_stop()
5107 fotg210_reset(fotg210); in fotg210_stop()
5109 hrtimer_cancel(&fotg210->hrtimer); in fotg210_stop()
5110 remove_sysfs_files(fotg210); in fotg210_stop()
5111 remove_debug_files(fotg210); in fotg210_stop()
5114 spin_lock_irq(&fotg210->lock); in fotg210_stop()
5115 end_free_itds(fotg210); in fotg210_stop()
5116 spin_unlock_irq(&fotg210->lock); in fotg210_stop()
5117 fotg210_mem_cleanup(fotg210); in fotg210_stop()
5120 fotg210_dbg(fotg210, "irq normal %ld err %ld iaa %ld (lost %ld)\n", in fotg210_stop()
5121 fotg210->stats.normal, fotg210->stats.error, fotg210->stats.iaa, in fotg210_stop()
5122 fotg210->stats.lost_iaa); in fotg210_stop()
5123 fotg210_dbg(fotg210, "complete %ld unlink %ld\n", in fotg210_stop()
5124 fotg210->stats.complete, fotg210->stats.unlink); in fotg210_stop()
5127 dbg_status(fotg210, "fotg210_stop completed", in fotg210_stop()
5128 fotg210_readl(fotg210, &fotg210->regs->status)); in fotg210_stop()
5134 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in hcd_fotg210_init() local
5140 spin_lock_init(&fotg210->lock); in hcd_fotg210_init()
5145 fotg210->need_io_watchdog = 1; in hcd_fotg210_init()
5147 hrtimer_init(&fotg210->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); in hcd_fotg210_init()
5148 fotg210->hrtimer.function = fotg210_hrtimer_func; in hcd_fotg210_init()
5149 fotg210->next_hrtimer_event = FOTG210_HRTIMER_NO_EVENT; in hcd_fotg210_init()
5151 hcc_params = fotg210_readl(fotg210, &fotg210->caps->hcc_params); in hcd_fotg210_init()
5157 fotg210->uframe_periodic_max = 100; in hcd_fotg210_init()
5163 fotg210->periodic_size = DEFAULT_I_TDPS; in hcd_fotg210_init()
5164 INIT_LIST_HEAD(&fotg210->intr_qh_list); in hcd_fotg210_init()
5165 INIT_LIST_HEAD(&fotg210->cached_itd_list); in hcd_fotg210_init()
5171 fotg210->periodic_size = 1024; in hcd_fotg210_init()
5174 fotg210->periodic_size = 512; in hcd_fotg210_init()
5177 fotg210->periodic_size = 256; in hcd_fotg210_init()
5183 retval = fotg210_mem_init(fotg210, GFP_KERNEL); in hcd_fotg210_init()
5188 fotg210->i_thresh = 2; in hcd_fotg210_init()
5197 fotg210->async->qh_next.qh = NULL; in hcd_fotg210_init()
5198 hw = fotg210->async->hw; in hcd_fotg210_init()
5199 hw->hw_next = QH_NEXT(fotg210, fotg210->async->qh_dma); in hcd_fotg210_init()
5200 hw->hw_info1 = cpu_to_hc32(fotg210, QH_HEAD); in hcd_fotg210_init()
5201 hw->hw_token = cpu_to_hc32(fotg210, QTD_STS_HALT); in hcd_fotg210_init()
5202 hw->hw_qtd_next = FOTG210_LIST_END(fotg210); in hcd_fotg210_init()
5203 fotg210->async->qh_state = QH_STATE_LINKED; in hcd_fotg210_init()
5204 hw->hw_alt_next = QTD_NEXT(fotg210, fotg210->async->dummy->qtd_dma); in hcd_fotg210_init()
5223 fotg210_dbg(fotg210, "park %d\n", park); in hcd_fotg210_init()
5230 fotg210->command = temp; in hcd_fotg210_init()
5241 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_run() local
5249 fotg210_writel(fotg210, fotg210->periodic_dma, in fotg210_run()
5250 &fotg210->regs->frame_list); in fotg210_run()
5251 fotg210_writel(fotg210, (u32)fotg210->async->qh_dma, in fotg210_run()
5252 &fotg210->regs->async_next); in fotg210_run()
5266 hcc_params = fotg210_readl(fotg210, &fotg210->caps->hcc_params); in fotg210_run()
5272 fotg210->command &= ~(CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET); in fotg210_run()
5273 fotg210->command |= CMD_RUN; in fotg210_run()
5274 fotg210_writel(fotg210, fotg210->command, &fotg210->regs->command); in fotg210_run()
5275 dbg_cmd(fotg210, "init", fotg210->command); in fotg210_run()
5292 fotg210->rh_state = FOTG210_RH_RUNNING; in fotg210_run()
5294 fotg210_readl(fotg210, &fotg210->regs->command); in fotg210_run()
5297 fotg210->last_periodic_enable = ktime_get_real(); in fotg210_run()
5299 temp = HC_VERSION(fotg210, in fotg210_run()
5300 fotg210_readl(fotg210, &fotg210->caps->hc_capbase)); in fotg210_run()
5301 fotg210_info(fotg210, in fotg210_run()
5303 ((fotg210->sbrn & 0xf0)>>4), (fotg210->sbrn & 0x0f), in fotg210_run()
5306 fotg210_writel(fotg210, INTR_MASK, in fotg210_run()
5307 &fotg210->regs->intr_enable); /* Turn On Interrupts */ in fotg210_run()
5313 create_debug_files(fotg210); in fotg210_run()
5314 create_sysfs_files(fotg210); in fotg210_run()
5321 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_setup() local
5324 fotg210->regs = (void __iomem *)fotg210->caps + in fotg210_setup()
5325 HC_LENGTH(fotg210, in fotg210_setup()
5326 fotg210_readl(fotg210, &fotg210->caps->hc_capbase)); in fotg210_setup()
5327 dbg_hcs_params(fotg210, "reset"); in fotg210_setup()
5328 dbg_hcc_params(fotg210, "reset"); in fotg210_setup()
5331 fotg210->hcs_params = fotg210_readl(fotg210, in fotg210_setup()
5332 &fotg210->caps->hcs_params); in fotg210_setup()
5334 fotg210->sbrn = HCD_USB2; in fotg210_setup()
5341 retval = fotg210_halt(fotg210); in fotg210_setup()
5345 fotg210_reset(fotg210); in fotg210_setup()
5354 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_irq() local
5358 spin_lock(&fotg210->lock); in fotg210_irq()
5360 status = fotg210_readl(fotg210, &fotg210->regs->status); in fotg210_irq()
5364 fotg210_dbg(fotg210, "device removed\n"); in fotg210_irq()
5376 unlikely(fotg210->rh_state == FOTG210_RH_HALTED)) { in fotg210_irq()
5377 spin_unlock(&fotg210->lock); in fotg210_irq()
5382 fotg210_writel(fotg210, masked_status, &fotg210->regs->status); in fotg210_irq()
5383 cmd = fotg210_readl(fotg210, &fotg210->regs->command); in fotg210_irq()
5387 dbg_status(fotg210, "irq", status); in fotg210_irq()
5394 COUNT(fotg210->stats.normal); in fotg210_irq()
5396 COUNT(fotg210->stats.error); in fotg210_irq()
5404 fotg210->enabled_hrtimer_events &= in fotg210_irq()
5414 if (fotg210->next_hrtimer_event == FOTG210_HRTIMER_IAA_WATCHDOG) in fotg210_irq()
5415 ++fotg210->next_hrtimer_event; in fotg210_irq()
5419 fotg210_dbg(fotg210, "IAA with IAAD still set?\n"); in fotg210_irq()
5420 if (fotg210->async_iaa) { in fotg210_irq()
5421 COUNT(fotg210->stats.iaa); in fotg210_irq()
5422 end_unlink_async(fotg210); in fotg210_irq()
5424 fotg210_dbg(fotg210, "IAA with nothing unlinked?\n"); in fotg210_irq()
5430 u32 __iomem *status_reg = &fotg210->regs->port_status; in fotg210_irq()
5436 if (fotg210->rh_state == FOTG210_RH_SUSPENDED) in fotg210_irq()
5439 pstatus = fotg210_readl(fotg210, status_reg); in fotg210_irq()
5441 if (test_bit(0, &fotg210->suspended_ports) && in fotg210_irq()
5445 fotg210->reset_done[0] == 0) { in fotg210_irq()
5452 fotg210->reset_done[0] = jiffies + msecs_to_jiffies(25); in fotg210_irq()
5453 set_bit(0, &fotg210->resuming_ports); in fotg210_irq()
5454 fotg210_dbg(fotg210, "port 1 remote wakeup\n"); in fotg210_irq()
5455 mod_timer(&hcd->rh_timer, fotg210->reset_done[0]); in fotg210_irq()
5461 fotg210_err(fotg210, "fatal error\n"); in fotg210_irq()
5462 dbg_cmd(fotg210, "fatal", cmd); in fotg210_irq()
5463 dbg_status(fotg210, "fatal", status); in fotg210_irq()
5468 fotg210->shutdown = true; in fotg210_irq()
5469 fotg210->rh_state = FOTG210_RH_STOPPING; in fotg210_irq()
5470 fotg210->command &= ~(CMD_RUN | CMD_ASE | CMD_PSE); in fotg210_irq()
5471 fotg210_writel(fotg210, fotg210->command, in fotg210_irq()
5472 &fotg210->regs->command); in fotg210_irq()
5473 fotg210_writel(fotg210, 0, &fotg210->regs->intr_enable); in fotg210_irq()
5474 fotg210_handle_controller_death(fotg210); in fotg210_irq()
5481 fotg210_work(fotg210); in fotg210_irq()
5482 spin_unlock(&fotg210->lock); in fotg210_irq()
5507 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_urb_enqueue() local
5522 if (!qh_urb_transaction(fotg210, urb, &qtd_list, mem_flags)) in fotg210_urb_enqueue()
5524 return submit_async(fotg210, urb, &qtd_list, mem_flags); in fotg210_urb_enqueue()
5527 if (!qh_urb_transaction(fotg210, urb, &qtd_list, mem_flags)) in fotg210_urb_enqueue()
5529 return intr_submit(fotg210, urb, &qtd_list, mem_flags); in fotg210_urb_enqueue()
5532 return itd_submit(fotg210, urb, mem_flags); in fotg210_urb_enqueue()
5542 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_urb_dequeue() local
5547 spin_lock_irqsave(&fotg210->lock, flags); in fotg210_urb_dequeue()
5562 start_unlink_async(fotg210, qh); in fotg210_urb_dequeue()
5570 qh_completions(fotg210, qh); in fotg210_urb_dequeue()
5582 start_unlink_intr(fotg210, qh); in fotg210_urb_dequeue()
5585 qh_completions(fotg210, qh); in fotg210_urb_dequeue()
5588 fotg210_dbg(fotg210, "bogus qh %p state %d\n", in fotg210_urb_dequeue()
5602 spin_unlock_irqrestore(&fotg210->lock, flags); in fotg210_urb_dequeue()
5613 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_endpoint_disable() local
5621 spin_lock_irqsave(&fotg210->lock, flags); in fotg210_endpoint_disable()
5640 if (fotg210->rh_state < FOTG210_RH_RUNNING) in fotg210_endpoint_disable()
5645 for (tmp = fotg210->async->qh_next.qh; in fotg210_endpoint_disable()
5653 start_unlink_async(fotg210, qh); in fotg210_endpoint_disable()
5658 spin_unlock_irqrestore(&fotg210->lock, flags); in fotg210_endpoint_disable()
5665 qh_destroy(fotg210, qh); in fotg210_endpoint_disable()
5673 fotg210_err(fotg210, "qh %p (#%02x) state %d%s\n", in fotg210_endpoint_disable()
5680 spin_unlock_irqrestore(&fotg210->lock, flags); in fotg210_endpoint_disable()
5686 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_endpoint_reset() local
5696 spin_lock_irqsave(&fotg210->lock, flags); in fotg210_endpoint_reset()
5716 start_unlink_async(fotg210, qh); in fotg210_endpoint_reset()
5718 start_unlink_intr(fotg210, qh); in fotg210_endpoint_reset()
5721 spin_unlock_irqrestore(&fotg210->lock, flags); in fotg210_endpoint_reset()
5726 struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); in fotg210_get_frame() local
5727 return (fotg210_read_frame_index(fotg210) >> 3) % in fotg210_get_frame()
5728 fotg210->periodic_size; in fotg210_get_frame()
5789 static void fotg210_init(struct fotg210_hcd *fotg210) in fotg210_init() argument
5794 &fotg210->regs->gmir); in fotg210_init()
5796 value = ioread32(&fotg210->regs->otgcsr); in fotg210_init()
5799 iowrite32(value, &fotg210->regs->otgcsr); in fotg210_init()
5816 struct fotg210_hcd *fotg210; in fotg210_hcd_probe() local
5853 fotg210 = hcd_to_fotg210(hcd); in fotg210_hcd_probe()
5855 fotg210->caps = hcd->regs; in fotg210_hcd_probe()
5861 fotg210_init(fotg210); in fotg210_hcd_probe()