Lines Matching defs:oxu

334 	struct oxu_hcd		*oxu;
482 #define oxu_dbg(oxu, fmt, args...) \
483 dev_dbg(oxu_to_hcd(oxu)->self.controller , fmt , ## args)
484 #define oxu_err(oxu, fmt, args...) \
485 dev_err(oxu_to_hcd(oxu)->self.controller , fmt , ## args)
486 #define oxu_info(oxu, fmt, args...) \
487 dev_info(oxu_to_hcd(oxu)->self.controller , fmt , ## args)
493 static inline struct usb_hcd *oxu_to_hcd(struct oxu_hcd *oxu)
495 return container_of((void *) oxu, struct usb_hcd, hcd_priv);
513 #define oxu_vdbg(oxu, fmt, args...) /* Nop */
632 #define dbg_status(oxu, label, status) { \
635 oxu_dbg(oxu, "%s\n", _buf); \
638 #define dbg_cmd(oxu, label, command) { \
641 oxu_dbg(oxu, "%s\n", _buf); \
644 #define dbg_port(oxu, label, port, status) { \
647 oxu_dbg(oxu, "%s\n", _buf); \
670 static void ehci_work(struct oxu_hcd *oxu);
690 static inline void timer_action_done(struct oxu_hcd *oxu,
693 clear_bit(action, &oxu->actions);
696 static inline void timer_action(struct oxu_hcd *oxu,
699 if (!test_and_set_bit(action, &oxu->actions)) {
724 && t > oxu->watchdog.expires
725 && timer_pending(&oxu->watchdog))
727 mod_timer(&oxu->watchdog, t);
748 static int handshake(struct oxu_hcd *oxu, void __iomem *ptr,
765 static int ehci_halt(struct oxu_hcd *oxu)
767 u32 temp = readl(&oxu->regs->status);
770 writel(0, &oxu->regs->intr_enable);
775 temp = readl(&oxu->regs->command);
777 writel(temp, &oxu->regs->command);
778 return handshake(oxu, &oxu->regs->status,
783 static void tdi_reset(struct oxu_hcd *oxu)
788 reg_ptr = (u32 __iomem *)(((u8 __iomem *)oxu->regs) + 0x68);
795 static int ehci_reset(struct oxu_hcd *oxu)
798 u32 command = readl(&oxu->regs->command);
801 dbg_cmd(oxu, "reset", command);
802 writel(command, &oxu->regs->command);
803 oxu_to_hcd(oxu)->state = HC_STATE_HALT;
804 oxu->next_statechange = jiffies;
805 retval = handshake(oxu, &oxu->regs->command,
811 tdi_reset(oxu);
817 static void ehci_quiesce(struct oxu_hcd *oxu)
822 BUG_ON(!HC_IS_RUNNING(oxu_to_hcd(oxu)->state));
826 temp = readl(&oxu->regs->command) << 10;
828 if (handshake(oxu, &oxu->regs->status, STS_ASS | STS_PSS,
830 oxu_to_hcd(oxu)->state = HC_STATE_HALT;
835 temp = readl(&oxu->regs->command);
837 writel(temp, &oxu->regs->command);
840 if (handshake(oxu, &oxu->regs->status, STS_ASS | STS_PSS,
842 oxu_to_hcd(oxu)->state = HC_STATE_HALT;
847 static int check_reset_complete(struct oxu_hcd *oxu, int index,
851 oxu->reset_done[index] = 0;
857 oxu_dbg(oxu, "Failed to enable port %d on root hub TT\n",
861 oxu_dbg(oxu, "port %d high speed\n", index + 1);
866 static void ehci_hub_descriptor(struct oxu_hcd *oxu,
869 int ports = HCS_N_PORTS(oxu->hcs_params);
873 desc->bPwrOn2PwrGood = 10; /* oxu 1.0, 2.3.9 says 20ms max */
885 if (HCS_PPC(oxu->hcs_params))
907 static int oxu_buf_alloc(struct oxu_hcd *oxu, struct ehci_qtd *qtd, int len)
915 oxu_err(oxu, "buffer too big (%d)\n", len);
919 spin_lock(&oxu->mem_lock);
930 i += max(a_blocks, (int)oxu->db_used[i])) {
934 if (oxu->db_used[i + j])
941 qtd->buffer = (void *) &oxu->mem->db_pool[i];
945 oxu->db_used[i] = a_blocks;
947 spin_unlock(&oxu->mem_lock);
954 spin_unlock(&oxu->mem_lock);
959 static void oxu_buf_free(struct oxu_hcd *oxu, struct ehci_qtd *qtd)
963 spin_lock(&oxu->mem_lock);
965 index = (qtd->buffer - (void *) &oxu->mem->db_pool[0])
967 oxu->db_used[index] = 0;
972 spin_unlock(&oxu->mem_lock);
985 static inline void oxu_qtd_free(struct oxu_hcd *oxu, struct ehci_qtd *qtd)
990 oxu_buf_free(oxu, qtd);
992 spin_lock(&oxu->mem_lock);
994 index = qtd - &oxu->mem->qtd_pool[0];
995 oxu->qtd_used[index] = 0;
997 spin_unlock(&oxu->mem_lock);
1000 static struct ehci_qtd *ehci_qtd_alloc(struct oxu_hcd *oxu)
1005 spin_lock(&oxu->mem_lock);
1008 if (!oxu->qtd_used[i])
1012 qtd = (struct ehci_qtd *) &oxu->mem->qtd_pool[i];
1022 oxu->qtd_used[i] = 1;
1025 spin_unlock(&oxu->mem_lock);
1030 static void oxu_qh_free(struct oxu_hcd *oxu, struct ehci_qh *qh)
1034 spin_lock(&oxu->mem_lock);
1036 index = qh - &oxu->mem->qh_pool[0];
1037 oxu->qh_used[index] = 0;
1039 spin_unlock(&oxu->mem_lock);
1045 struct oxu_hcd *oxu = qh->oxu;
1049 oxu_dbg(oxu, "unused qh not empty!\n");
1053 oxu_qtd_free(oxu, qh->dummy);
1054 oxu_qh_free(oxu, qh);
1057 static struct ehci_qh *oxu_qh_alloc(struct oxu_hcd *oxu)
1062 spin_lock(&oxu->mem_lock);
1065 if (!oxu->qh_used[i])
1069 qh = (struct ehci_qh *) &oxu->mem->qh_pool[i];
1073 qh->oxu = oxu;
1078 qh->dummy = ehci_qtd_alloc(oxu);
1080 oxu_dbg(oxu, "no dummy td\n");
1081 oxu->qh_used[i] = 0;
1086 oxu->qh_used[i] = 1;
1089 spin_unlock(&oxu->mem_lock);
1106 static void oxu_murb_free(struct oxu_hcd *oxu, struct oxu_murb *murb)
1110 spin_lock(&oxu->mem_lock);
1112 index = murb - &oxu->murb_pool[0];
1113 oxu->murb_used[index] = 0;
1115 spin_unlock(&oxu->mem_lock);
1118 static struct oxu_murb *oxu_murb_alloc(struct oxu_hcd *oxu)
1124 spin_lock(&oxu->mem_lock);
1127 if (!oxu->murb_used[i])
1131 murb = &(oxu->murb_pool)[i];
1133 oxu->murb_used[i] = 1;
1136 spin_unlock(&oxu->mem_lock);
1145 static void ehci_mem_cleanup(struct oxu_hcd *oxu)
1147 kfree(oxu->murb_pool);
1148 oxu->murb_pool = NULL;
1150 if (oxu->async)
1151 qh_put(oxu->async);
1152 oxu->async = NULL;
1154 del_timer(&oxu->urb_timer);
1156 oxu->periodic = NULL;
1159 kfree(oxu->pshadow);
1160 oxu->pshadow = NULL;
1165 static int ehci_mem_init(struct oxu_hcd *oxu, gfp_t flags)
1169 for (i = 0; i < oxu->periodic_size; i++)
1170 oxu->mem->frame_list[i] = EHCI_LIST_END;
1172 oxu->qh_used[i] = 0;
1174 oxu->qtd_used[i] = 0;
1176 oxu->murb_pool = kcalloc(MURB_NUM, sizeof(struct oxu_murb), flags);
1177 if (!oxu->murb_pool)
1181 oxu->murb_used[i] = 0;
1183 oxu->async = oxu_qh_alloc(oxu);
1184 if (!oxu->async)
1187 oxu->periodic = (__le32 *) &oxu->mem->frame_list;
1188 oxu->periodic_dma = virt_to_phys(oxu->periodic);
1190 for (i = 0; i < oxu->periodic_size; i++)
1191 oxu->periodic[i] = EHCI_LIST_END;
1194 oxu->pshadow = kcalloc(oxu->periodic_size, sizeof(void *), flags);
1195 if (oxu->pshadow != NULL)
1199 oxu_dbg(oxu, "couldn't init memory\n");
1200 ehci_mem_cleanup(oxu);
1244 static inline void qh_update(struct oxu_hcd *oxu,
1278 static void qh_refresh(struct oxu_hcd *oxu, struct ehci_qh *qh)
1293 qh_update(oxu, qh, qtd);
1296 static void qtd_copy_status(struct oxu_hcd *oxu, struct urb *urb,
1328 oxu_dbg(oxu, "devpath %s ep%d%s 3strikes\n",
1340 oxu_vdbg(oxu, "dev%d ep%d%s qtd token %08x --> status %d\n",
1348 static void ehci_urb_done(struct oxu_hcd *oxu, struct urb *urb)
1349 __releases(oxu->lock)
1350 __acquires(oxu->lock)
1359 oxu_to_hcd(oxu)->self.bandwidth_int_reqs--;
1381 oxu_dbg(oxu, "%s %s urb %p ep%d%s status %d len %d/%d\n",
1390 spin_unlock(&oxu->lock);
1391 usb_hcd_giveback_urb(oxu_to_hcd(oxu), urb, urb->status);
1392 spin_lock(&oxu->lock);
1395 static void start_unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh);
1396 static void unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh);
1398 static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh);
1399 static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh);
1407 static unsigned qh_completions(struct oxu_hcd *oxu, struct ehci_qh *qh)
1448 ehci_urb_done(oxu, last->urb);
1451 oxu_murb_free(oxu, murb);
1453 ehci_urb_done(oxu, last->urb);
1457 oxu_qtd_free(oxu, last);
1486 HC_IS_RUNNING(oxu_to_hcd(oxu)->state))) {
1492 if (unlikely(!HC_IS_RUNNING(oxu_to_hcd(oxu)->state)))
1527 qtd_copy_status(oxu, urb->complete ?
1551 ehci_urb_done(oxu, last->urb);
1554 oxu_murb_free(oxu, murb);
1556 ehci_urb_done(oxu, last->urb);
1559 oxu_qtd_free(oxu, last);
1572 qh_refresh(oxu, qh);
1580 intr_deschedule(oxu, qh);
1581 (void) qh_schedule(oxu, qh);
1583 unlink_async(oxu, qh);
1600 static void qtd_list_free(struct oxu_hcd *oxu,
1607 oxu_qtd_free(oxu, qtd);
1613 static struct list_head *qh_urb_transaction(struct oxu_hcd *oxu,
1629 qtd = ehci_qtd_alloc(oxu);
1646 ret = oxu_buf_alloc(oxu, qtd, sizeof(struct usb_ctrlrequest));
1658 qtd = ehci_qtd_alloc(oxu);
1674 ret = oxu_buf_alloc(oxu, qtd, len);
1704 qtd->hw_alt_next = oxu->async->hw_alt_next;
1714 qtd = ehci_qtd_alloc(oxu);
1718 ret = oxu_buf_alloc(oxu, qtd, len);
1752 qtd = ehci_qtd_alloc(oxu);
1769 qtd_list_free(oxu, urb, head);
1780 static struct ehci_qh *qh_make(struct oxu_hcd *oxu,
1783 struct ehci_qh *qh = oxu_qh_alloc(oxu);
1825 oxu_dbg(oxu, "intr period %d uframes, NYET!\n",
1897 oxu_dbg(oxu, "bogus dev %p speed %d\n", urb->dev, urb->dev->speed);
1910 qh_refresh(oxu, qh);
1916 static void qh_link_async(struct oxu_hcd *oxu, struct ehci_qh *qh)
1922 head = oxu->async;
1923 timer_action_done(oxu, TIMER_ASYNC_OFF);
1925 u32 cmd = readl(&oxu->regs->command);
1929 (void)handshake(oxu, &oxu->regs->status,
1932 writel(cmd, &oxu->regs->command);
1933 oxu_to_hcd(oxu)->state = HC_STATE_RUNNING;
1940 qh_refresh(oxu, qh);
1962 static struct ehci_qh *qh_append_tds(struct oxu_hcd *oxu,
1970 /* can't sleep here, we have oxu->lock... */
1971 qh = qh_make(oxu, urb, GFP_ATOMIC);
2037 static int submit_async(struct oxu_hcd *oxu, struct urb *urb,
2049 oxu_dbg(oxu, "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n",
2056 spin_lock_irqsave(&oxu->lock, flags);
2057 if (unlikely(!HCD_HW_ACCESSIBLE(oxu_to_hcd(oxu)))) {
2062 qh = qh_append_tds(oxu, urb, qtd_list, epnum, &urb->ep->hcpriv);
2072 qh_link_async(oxu, qh_get(qh));
2074 spin_unlock_irqrestore(&oxu->lock, flags);
2076 qtd_list_free(oxu, urb, qtd_list);
2082 static void end_unlink_async(struct oxu_hcd *oxu)
2084 struct ehci_qh *qh = oxu->reclaim;
2087 timer_action_done(oxu, TIMER_IAA_WATCHDOG);
2095 oxu->reclaim = next;
2096 oxu->reclaim_ready = 0;
2099 qh_completions(oxu, qh);
2102 && HC_IS_RUNNING(oxu_to_hcd(oxu)->state))
2103 qh_link_async(oxu, qh);
2110 if (HC_IS_RUNNING(oxu_to_hcd(oxu)->state)
2111 && oxu->async->qh_next.qh == NULL)
2112 timer_action(oxu, TIMER_ASYNC_OFF);
2116 oxu->reclaim = NULL;
2117 start_unlink_async(oxu, next);
2122 /* caller must own oxu->lock */
2124 static void start_unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh)
2126 int cmd = readl(&oxu->regs->command);
2130 assert_spin_locked(&oxu->lock);
2131 BUG_ON(oxu->reclaim || (qh->qh_state != QH_STATE_LINKED
2136 if (unlikely(qh == oxu->async)) {
2138 if (oxu_to_hcd(oxu)->state != HC_STATE_HALT
2139 && !oxu->reclaim) {
2141 writel(cmd & ~CMD_ASE, &oxu->regs->command);
2144 timer_action_done(oxu, TIMER_ASYNC_OFF);
2150 oxu->reclaim = qh = qh_get(qh);
2152 prev = oxu->async;
2160 if (unlikely(oxu_to_hcd(oxu)->state == HC_STATE_HALT)) {
2164 end_unlink_async(oxu);
2168 oxu->reclaim_ready = 0;
2170 writel(cmd, &oxu->regs->command);
2171 (void) readl(&oxu->regs->command);
2172 timer_action(oxu, TIMER_IAA_WATCHDOG);
2175 static void scan_async(struct oxu_hcd *oxu)
2180 if (!++(oxu->stamp))
2181 oxu->stamp++;
2182 timer_action_done(oxu, TIMER_ASYNC_SHRINK);
2184 qh = oxu->async->qh_next.qh;
2189 && qh->stamp != oxu->stamp) {
2198 qh->stamp = oxu->stamp;
2199 temp = qh_completions(oxu, qh);
2212 if (qh->stamp == oxu->stamp)
2214 else if (!oxu->reclaim
2216 start_unlink_async(oxu, qh);
2223 timer_action(oxu, TIMER_ASYNC_SHRINK);
2241 /* caller must hold oxu->lock */
2242 static void periodic_unlink(struct oxu_hcd *oxu, unsigned frame, void *ptr)
2244 union ehci_shadow *prev_p = &oxu->pshadow[frame];
2245 __le32 *hw_p = &oxu->periodic[frame];
2266 static unsigned short periodic_usecs(struct oxu_hcd *oxu,
2269 __le32 *hw_p = &oxu->periodic[frame];
2270 union ehci_shadow *q = &oxu->pshadow[frame];
2290 oxu_err(oxu, "uframe %d sched overrun: %d usecs\n",
2296 static int enable_periodic(struct oxu_hcd *oxu)
2304 status = handshake(oxu, &oxu->regs->status, STS_PSS, 0, 9 * 125);
2306 oxu_to_hcd(oxu)->state = HC_STATE_HALT;
2307 usb_hc_died(oxu_to_hcd(oxu));
2311 cmd = readl(&oxu->regs->command) | CMD_PSE;
2312 writel(cmd, &oxu->regs->command);
2314 oxu_to_hcd(oxu)->state = HC_STATE_RUNNING;
2317 oxu->next_uframe = readl(&oxu->regs->frame_index)
2318 % (oxu->periodic_size << 3);
2322 static int disable_periodic(struct oxu_hcd *oxu)
2330 status = handshake(oxu, &oxu->regs->status, STS_PSS, STS_PSS, 9 * 125);
2332 oxu_to_hcd(oxu)->state = HC_STATE_HALT;
2333 usb_hc_died(oxu_to_hcd(oxu));
2337 cmd = readl(&oxu->regs->command) & ~CMD_PSE;
2338 writel(cmd, &oxu->regs->command);
2341 oxu->next_uframe = -1;
2349 * no FSTN support (yet; oxu 0.96+)
2351 static int qh_link_periodic(struct oxu_hcd *oxu, struct ehci_qh *qh)
2365 for (i = qh->start; i < oxu->periodic_size; i += period) {
2366 union ehci_shadow *prev = &oxu->pshadow[i];
2367 __le32 *hw_p = &oxu->periodic[i];
2405 oxu_to_hcd(oxu)->self.bandwidth_allocated += qh->period
2410 if (!oxu->periodic_sched++)
2411 return enable_periodic(oxu);
2416 static void qh_unlink_periodic(struct oxu_hcd *oxu, struct ehci_qh *qh)
2434 for (i = qh->start; i < oxu->periodic_size; i += period)
2435 periodic_unlink(oxu, i, qh);
2438 oxu_to_hcd(oxu)->self.bandwidth_allocated -= qh->period
2454 oxu->periodic_sched--;
2455 if (!oxu->periodic_sched)
2456 (void) disable_periodic(oxu);
2459 static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh)
2463 qh_unlink_periodic(oxu, qh);
2482 static int check_period(struct oxu_hcd *oxu,
2506 claimed = periodic_usecs(oxu, frame, uframe);
2510 } while ((frame += 1) < oxu->periodic_size);
2515 claimed = periodic_usecs(oxu, frame, uframe);
2518 } while ((frame += period) < oxu->periodic_size);
2524 static int check_intr_schedule(struct oxu_hcd *oxu,
2533 if (!check_period(oxu, frame, uframe, qh->period, qh->usecs))
2548 static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh)
2555 qh_refresh(oxu, qh);
2562 status = check_intr_schedule(oxu, frame, --uframe,
2579 status = check_intr_schedule(oxu,
2590 status = check_intr_schedule(oxu, 0, 0, qh, &c_mask);
2603 oxu_dbg(oxu, "reused qh %p schedule\n", qh);
2606 status = qh_link_periodic(oxu, qh);
2611 static int intr_submit(struct oxu_hcd *oxu, struct urb *urb,
2623 spin_lock_irqsave(&oxu->lock, flags);
2625 if (unlikely(!HCD_HW_ACCESSIBLE(oxu_to_hcd(oxu)))) {
2632 qh = qh_append_tds(oxu, urb, &empty, epnum, &urb->ep->hcpriv);
2638 status = qh_schedule(oxu, qh);
2644 qh = qh_append_tds(oxu, urb, qtd_list, epnum, &urb->ep->hcpriv);
2648 oxu_to_hcd(oxu)->self.bandwidth_int_reqs++;
2651 spin_unlock_irqrestore(&oxu->lock, flags);
2653 qtd_list_free(oxu, urb, qtd_list);
2658 static inline int itd_submit(struct oxu_hcd *oxu, struct urb *urb,
2661 oxu_dbg(oxu, "iso support is missing!\n");
2665 static inline int sitd_submit(struct oxu_hcd *oxu, struct urb *urb,
2668 oxu_dbg(oxu, "split iso support is missing!\n");
2672 static void scan_periodic(struct oxu_hcd *oxu)
2677 mod = oxu->periodic_size << 3;
2684 now_uframe = oxu->next_uframe;
2685 if (HC_IS_RUNNING(oxu_to_hcd(oxu)->state))
2686 clock = readl(&oxu->regs->frame_index);
2704 q_p = &oxu->pshadow[frame];
2705 hw_p = &oxu->periodic[frame];
2719 modified = qh_completions(oxu, temp.qh);
2721 intr_deschedule(oxu, temp.qh);
2725 oxu_dbg(oxu, "corrupt type %d frame %d shadow %p\n",
2749 if (!HC_IS_RUNNING(oxu_to_hcd(oxu)->state))
2751 oxu->next_uframe = now_uframe;
2752 now = readl(&oxu->regs->frame_index) % mod;
2769 static void ehci_turn_off_all_ports(struct oxu_hcd *oxu)
2771 int port = HCS_N_PORTS(oxu->hcs_params);
2774 writel(PORT_RWC_BITS, &oxu->regs->port_status[port]);
2777 static void ehci_port_power(struct oxu_hcd *oxu, int is_on)
2781 if (!HCS_PPC(oxu->hcs_params))
2784 oxu_dbg(oxu, "...power%s ports...\n", is_on ? "up" : "down");
2785 for (port = HCS_N_PORTS(oxu->hcs_params); port > 0; ) {
2787 oxu_hub_control(oxu_to_hcd(oxu), SetPortFeature,
2790 oxu_hub_control(oxu_to_hcd(oxu), ClearPortFeature,
2798 * It calls driver completion functions, after dropping oxu->lock.
2800 static void ehci_work(struct oxu_hcd *oxu)
2802 timer_action_done(oxu, TIMER_IO_WATCHDOG);
2803 if (oxu->reclaim_ready)
2804 end_unlink_async(oxu);
2806 /* another CPU may drop oxu->lock during a schedule scan while
2810 if (oxu->scanning)
2812 oxu->scanning = 1;
2813 scan_async(oxu);
2814 if (oxu->next_uframe != -1)
2815 scan_periodic(oxu);
2816 oxu->scanning = 0;
2822 if (HC_IS_RUNNING(oxu_to_hcd(oxu)->state) &&
2823 (oxu->async->qh_next.ptr != NULL ||
2824 oxu->periodic_sched != 0))
2825 timer_action(oxu, TIMER_IO_WATCHDOG);
2828 static void unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh)
2832 && oxu->reclaim
2833 && HC_IS_RUNNING(oxu_to_hcd(oxu)->state)) {
2836 for (last = oxu->reclaim;
2844 } else if (!HC_IS_RUNNING(oxu_to_hcd(oxu)->state) && oxu->reclaim)
2845 end_unlink_async(oxu);
2849 start_unlink_async(oxu, qh);
2858 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2862 spin_lock(&oxu->lock);
2864 status = readl(&oxu->regs->status);
2868 oxu_dbg(oxu, "device removed\n");
2875 spin_unlock(&oxu->lock);
2880 writel(status, &oxu->regs->status);
2881 readl(&oxu->regs->command); /* unblock posted write */
2886 dbg_status(oxu, "irq", status);
2897 oxu->reclaim_ready = 1;
2903 unsigned i = HCS_N_PORTS(oxu->hcs_params);
2907 if (!(readl(&oxu->regs->command) & CMD_RUN))
2911 int pstatus = readl(&oxu->regs->port_status[i]);
2916 || oxu->reset_done[i] != 0)
2923 oxu->reset_done[i] = jiffies +
2925 oxu_dbg(oxu, "port %d remote wakeup\n", i + 1);
2926 mod_timer(&hcd->rh_timer, oxu->reset_done[i]);
2933 status = readl(&oxu->regs->status);
2934 dbg_cmd(oxu, "fatal", readl(&oxu->regs->command));
2935 dbg_status(oxu, "fatal", status);
2937 oxu_err(oxu, "fatal error\n");
2939 ehci_reset(oxu);
2940 writel(0, &oxu->regs->configured_flag);
2950 ehci_work(oxu);
2951 spin_unlock(&oxu->lock);
2959 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2968 if ((oxu->is_otg && (status & OXU_USBOTGI)) ||
2969 (!oxu->is_otg && (status & OXU_USBSPHI)))
2982 struct oxu_hcd *oxu = from_timer(oxu, t, watchdog);
2985 spin_lock_irqsave(&oxu->lock, flags);
2988 if (oxu->reclaim) {
2989 u32 status = readl(&oxu->regs->status);
2991 oxu_vdbg(oxu, "lost IAA\n");
2992 writel(STS_IAA, &oxu->regs->status);
2993 oxu->reclaim_ready = 1;
2998 if (test_bit(TIMER_ASYNC_OFF, &oxu->actions))
2999 start_unlink_async(oxu, oxu->async);
3001 /* oxu could run by timer, without IRQs ... */
3002 ehci_work(oxu);
3004 spin_unlock_irqrestore(&oxu->lock, flags);
3011 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3016 spin_lock_init(&oxu->lock);
3018 timer_setup(&oxu->watchdog, oxu_watchdog, 0);
3024 oxu->periodic_size = DEFAULT_I_TDPS;
3025 retval = ehci_mem_init(oxu, GFP_KERNEL);
3030 hcc_params = readl(&oxu->caps->hcc_params);
3032 oxu->i_thresh = 8;
3034 oxu->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
3036 oxu->reclaim = NULL;
3037 oxu->reclaim_ready = 0;
3038 oxu->next_uframe = -1;
3047 oxu->async->qh_next.qh = NULL;
3048 oxu->async->hw_next = QH_NEXT(oxu->async->qh_dma);
3049 oxu->async->hw_info1 = cpu_to_le32(QH_HEAD);
3050 oxu->async->hw_token = cpu_to_le32(QTD_STS_HALT);
3051 oxu->async->hw_qtd_next = EHCI_LIST_END;
3052 oxu->async->qh_state = QH_STATE_LINKED;
3053 oxu->async->hw_alt_next = QTD_NEXT(oxu->async->dummy->qtd_dma);
3072 oxu_dbg(oxu, "park %d\n", park);
3079 oxu->command = temp;
3088 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3090 spin_lock_init(&oxu->mem_lock);
3091 INIT_LIST_HEAD(&oxu->urb_list);
3092 oxu->urb_len = 0;
3094 if (oxu->is_otg) {
3095 oxu->caps = hcd->regs + OXU_OTG_CAP_OFFSET;
3096 oxu->regs = hcd->regs + OXU_OTG_CAP_OFFSET + \
3097 HC_LENGTH(readl(&oxu->caps->hc_capbase));
3099 oxu->mem = hcd->regs + OXU_SPH_MEM;
3101 oxu->caps = hcd->regs + OXU_SPH_CAP_OFFSET;
3102 oxu->regs = hcd->regs + OXU_SPH_CAP_OFFSET + \
3103 HC_LENGTH(readl(&oxu->caps->hc_capbase));
3105 oxu->mem = hcd->regs + OXU_OTG_MEM;
3108 oxu->hcs_params = readl(&oxu->caps->hcs_params);
3109 oxu->sbrn = 0x20;
3116 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3123 retval = ehci_reset(oxu);
3125 ehci_mem_cleanup(oxu);
3128 writel(oxu->periodic_dma, &oxu->regs->frame_list);
3129 writel((u32) oxu->async->qh_dma, &oxu->regs->async_next);
3131 /* hcc_params controls whether oxu->regs->segment must (!!!)
3142 hcc_params = readl(&oxu->caps->hcc_params);
3144 writel(0, &oxu->regs->segment);
3146 oxu->command &= ~(CMD_LRESET | CMD_IAAD | CMD_PSE |
3148 oxu->command |= CMD_RUN;
3149 writel(oxu->command, &oxu->regs->command);
3150 dbg_cmd(oxu, "init", oxu->command);
3159 writel(FLAG_CF, &oxu->regs->configured_flag);
3160 readl(&oxu->regs->command); /* unblock posted writes */
3162 temp = HC_VERSION(readl(&oxu->caps->hc_capbase));
3163 oxu_info(oxu, "USB %x.%x started, quasi-EHCI %x.%02x, driver %s%s\n",
3164 ((oxu->sbrn & 0xf0)>>4), (oxu->sbrn & 0x0f),
3168 writel(INTR_MASK, &oxu->regs->intr_enable); /* Turn On Interrupts */
3175 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3178 ehci_port_power(oxu, 0);
3181 del_timer_sync(&oxu->watchdog);
3183 spin_lock_irq(&oxu->lock);
3185 ehci_quiesce(oxu);
3187 ehci_reset(oxu);
3188 writel(0, &oxu->regs->intr_enable);
3189 spin_unlock_irq(&oxu->lock);
3192 writel(0, &oxu->regs->configured_flag);
3195 spin_lock_irq(&oxu->lock);
3196 if (oxu->async)
3197 ehci_work(oxu);
3198 spin_unlock_irq(&oxu->lock);
3199 ehci_mem_cleanup(oxu);
3201 dbg_status(oxu, "oxu_stop completed", readl(&oxu->regs->status));
3210 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3212 (void) ehci_halt(oxu);
3213 ehci_turn_off_all_ports(oxu);
3216 writel(0, &oxu->regs->configured_flag);
3219 readl(&oxu->regs->configured_flag);
3236 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3245 if (!qh_urb_transaction(oxu, urb, &qtd_list, mem_flags))
3247 return submit_async(oxu, urb, &qtd_list, mem_flags);
3250 if (!qh_urb_transaction(oxu, urb, &qtd_list, mem_flags))
3252 return intr_submit(oxu, urb, &qtd_list, mem_flags);
3256 return itd_submit(oxu, urb, mem_flags);
3258 return sitd_submit(oxu, urb, mem_flags);
3268 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3296 murb = (struct urb *) oxu_murb_alloc(oxu);
3327 murb = (struct urb *) oxu_murb_alloc(oxu);
3358 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3362 spin_lock_irqsave(&oxu->lock, flags);
3370 unlink_async(oxu, qh);
3379 intr_deschedule(oxu, qh);
3382 qh_completions(oxu, qh);
3385 oxu_dbg(oxu, "bogus qh %p state %d\n",
3395 status = qh_schedule(oxu, qh);
3396 spin_unlock_irqrestore(&oxu->lock, flags);
3411 spin_unlock_irqrestore(&oxu->lock, flags);
3419 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3427 spin_lock_irqsave(&oxu->lock, flags);
3436 oxu_vdbg(oxu, "iso delay\n");
3444 for (tmp = oxu->async->qh_next.qh;
3451 unlink_async(oxu, qh);
3455 spin_unlock_irqrestore(&oxu->lock, flags);
3469 oxu_err(oxu, "qh %p (#%02x) state %d%s\n",
3476 spin_unlock_irqrestore(&oxu->lock, flags);
3481 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3483 return (readl(&oxu->regs->frame_index) >> 3) %
3484 oxu->periodic_size;
3490 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3501 ports = HCS_N_PORTS(oxu->hcs_params);
3521 spin_lock_irqsave(&oxu->lock, flags);
3523 temp = readl(&oxu->regs->port_status[i]);
3533 oxu->reset_done[i] = 0;
3535 time_after_eq(jiffies, oxu->reset_done[i]))) {
3544 spin_unlock_irqrestore(&oxu->lock, flags);
3549 static inline unsigned int oxu_port_speed(struct oxu_hcd *oxu,
3567 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3568 int ports = HCS_N_PORTS(oxu->hcs_params);
3569 u32 __iomem *status_reg = &oxu->regs->port_status[wIndex - 1];
3582 spin_lock_irqsave(&oxu->lock, flags);
3623 oxu->reset_done[wIndex] = jiffies
3631 if (HCS_PPC(oxu->hcs_params))
3647 readl(&oxu->regs->command); /* unblock posted write */
3650 ehci_hub_descriptor(oxu, (struct usb_hub_descriptor *)
3676 if (!oxu->reset_done[wIndex]) {
3678 oxu->reset_done[wIndex] = jiffies
3681 mod_timer(&oxu_to_hcd(oxu)->rh_timer,
3682 oxu->reset_done[wIndex]);
3687 oxu->reset_done[wIndex])) {
3689 oxu->reset_done[wIndex] = 0;
3695 retval = handshake(oxu, status_reg,
3698 oxu_err(oxu,
3710 oxu->reset_done[wIndex])) {
3712 oxu->reset_done[wIndex] = 0;
3720 retval = handshake(oxu, status_reg,
3723 oxu_err(oxu, "port %d reset error %d\n",
3729 temp = check_reset_complete(oxu, wIndex, status_reg,
3735 test_bit(wIndex, &oxu->companion_ports)) {
3739 oxu_dbg(oxu, "port %d --> companion\n", wIndex + 1);
3752 status |= oxu_port_speed(oxu, temp);
3768 dbg_port(oxu, "GetStatus", wIndex + 1, temp);
3802 if (HCS_PPC(oxu->hcs_params))
3812 oxu_vdbg(oxu, "port %d reset\n", wIndex + 1);
3820 oxu->reset_done[wIndex] = jiffies
3834 ehci_quiesce(oxu);
3835 ehci_halt(oxu);
3843 readl(&oxu->regs->command); /* unblock posted writes */
3851 spin_unlock_irqrestore(&oxu->lock, flags);
3859 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3863 oxu_dbg(oxu, "suspend root hub\n");
3865 if (time_before(jiffies, oxu->next_statechange))
3868 port = HCS_N_PORTS(oxu->hcs_params);
3869 spin_lock_irq(&oxu->lock);
3873 ehci_quiesce(oxu);
3876 oxu->command = readl(&oxu->regs->command);
3877 if (oxu->reclaim)
3878 oxu->reclaim_ready = 1;
3879 ehci_work(oxu);
3886 oxu->bus_suspended = 0;
3888 u32 __iomem *reg = &oxu->regs->port_status[port];
3896 set_bit(port, &oxu->bus_suspended);
3906 oxu_vdbg(oxu, "port %d, %08x -> %08x\n",
3912 spin_unlock_irq(&oxu->lock);
3914 del_timer_sync(&oxu->watchdog);
3915 spin_lock_irq(&oxu->lock);
3916 ehci_halt(oxu);
3923 writel(mask, &oxu->regs->intr_enable);
3924 readl(&oxu->regs->intr_enable);
3926 oxu->next_statechange = jiffies + msecs_to_jiffies(10);
3927 spin_unlock_irq(&oxu->lock);
3934 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3938 if (time_before(jiffies, oxu->next_statechange))
3940 spin_lock_irq(&oxu->lock);
3948 temp = readl(&oxu->regs->intr_enable);
3949 oxu_dbg(oxu, "resume root hub%s\n", temp ? "" : " after power loss");
3954 writel(0, &oxu->regs->intr_enable);
3957 writel(0, &oxu->regs->segment);
3958 writel(oxu->periodic_dma, &oxu->regs->frame_list);
3959 writel((u32) oxu->async->qh_dma, &oxu->regs->async_next);
3962 writel(oxu->command, &oxu->regs->command);
3969 i = HCS_N_PORTS(oxu->hcs_params);
3971 temp = readl(&oxu->regs->port_status[i]);
3974 if (test_bit(i, &oxu->bus_suspended) && (temp & PORT_SUSPEND)) {
3975 oxu->reset_done[i] = jiffies + msecs_to_jiffies(20);
3978 writel(temp, &oxu->regs->port_status[i]);
3980 i = HCS_N_PORTS(oxu->hcs_params);
3983 temp = readl(&oxu->regs->port_status[i]);
3984 if (test_bit(i, &oxu->bus_suspended) && (temp & PORT_SUSPEND)) {
3986 writel(temp, &oxu->regs->port_status[i]);
3987 oxu_vdbg(oxu, "resumed port %d\n", i + 1);
3990 (void) readl(&oxu->regs->command);
3994 if (oxu->async->qh_next.qh)
3996 if (oxu->periodic_sched)
3999 oxu->command |= temp;
4000 writel(oxu->command, &oxu->regs->command);
4003 oxu->next_statechange = jiffies + msecs_to_jiffies(5);
4007 writel(INTR_MASK, &oxu->regs->intr_enable);
4009 spin_unlock_irq(&oxu->lock);
4134 struct oxu_hcd *oxu;
4153 oxu = hcd_to_oxu(hcd);
4154 oxu->is_otg = otg;