1 /* ==========================================================================
2 * $File: //dwh/usb_iip/dev/software/otg_ipmate/linux/drivers/dwc_otg_hcd_intr.c $
7 * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
8 * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
9 * otherwise expressly agreed to in writing between Synopsys and you.
11 * The Software IS NOT an item of Licensed Software or Licensed Product under
12 * any End User Software License Agreement or Agreement for Licensed Product
13 * with Synopsys or any supplement thereto. You are permitted to use and
14 * redistribute this Software in source and binary forms, with or without
15 * modification, provided that redistributions of source code must retain this
16 * notice. You may not view, use, disclose, copy or distribute this file or
17 * any information contained herein except pursuant to this license grant from
18 * Synopsys. If you do not agree with this notice, including the disclaimer
19 * below, then you are not authorized to use the Software.
21 * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
32 * ========================================================================== */
33 #ifndef DWC_DEVICE_ONLY
35 #include "dwc_otg_driver.h"
36 #include "dwc_otg_hcd.h"
37 #include "dwc_otg_regs.h"
40 * This file contains the implementation of the HCD Interrupt handlers.
43 /** This function handles interrupts for the HCD. */
44 int32_t dwc_otg_hcd_handle_intr (dwc_otg_hcd_t *_dwc_otg_hcd)
48 dwc_otg_core_if_t *core_if = _dwc_otg_hcd->core_if;
49 gintsts_data_t gintsts;
51 dwc_otg_core_global_regs_t *global_regs = core_if->core_global_regs;
54 /* Check if HOST Mode */
55 if (dwc_otg_is_host_mode(core_if)) {
56 gintsts.d32 = dwc_otg_read_core_intr(core_if);
58 // DWC_PRINT("%s,GINTSTS = 0\n",__func__);
63 /* Don't print debug message in the interrupt handler on SOF */
65 if (gintsts.d32 != DWC_SOF_INTR_MASK)
67 DWC_DEBUGPL (DBG_HCD, "\n");
72 if (gintsts.d32 != DWC_SOF_INTR_MASK)
74 DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD Interrupt Detected "
75 "gintsts&gintmsk=0x%08x\n",
79 if (gintsts.b.sofintr) {
80 retval |= dwc_otg_hcd_handle_sof_intr (_dwc_otg_hcd);
82 if (gintsts.b.rxstsqlvl) {
83 retval |= dwc_otg_hcd_handle_rx_status_q_level_intr (_dwc_otg_hcd);
85 if (gintsts.b.nptxfempty) {
86 retval |= dwc_otg_hcd_handle_np_tx_fifo_empty_intr (_dwc_otg_hcd);
88 if (gintsts.b.i2cintr) {
89 /** @todo Implement i2cintr handler. */
91 if (gintsts.b.portintr) {
92 retval |= dwc_otg_hcd_handle_port_intr (_dwc_otg_hcd);
94 if (gintsts.b.hcintr) {
95 retval |= dwc_otg_hcd_handle_hc_intr (_dwc_otg_hcd);
97 if (gintsts.b.ptxfempty) {
98 retval |= dwc_otg_hcd_handle_perio_tx_fifo_empty_intr (_dwc_otg_hcd);
102 if (gintsts.d32 != DWC_SOF_INTR_MASK)
105 DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD Finished Servicing Interrupts\n");
106 DWC_DEBUGPL(DBG_HCDV, "DWC OTG HCD gintsts=0x%08x\n",
107 dwc_read_reg32(&global_regs->gintsts));
108 DWC_DEBUGPL(DBG_HCDV, "DWC OTG HCD gintmsk=0x%08x\n",
109 dwc_read_reg32(&global_regs->gintmsk));
115 if (gintsts.d32 != DWC_SOF_INTR_MASK)
117 DWC_DEBUGPL (DBG_HCD, "\n");
125 #ifdef DWC_TRACK_MISSED_SOFS
126 #warning Compiling code to track missed SOFs
127 #define FRAME_NUM_ARRAY_SIZE 1000
129 * This function is for debug only.
131 static inline void track_missed_sofs(uint16_t _curr_frame_number) {
132 static uint16_t frame_num_array[FRAME_NUM_ARRAY_SIZE];
133 static uint16_t last_frame_num_array[FRAME_NUM_ARRAY_SIZE];
134 static int frame_num_idx = 0;
135 static uint16_t last_frame_num = DWC_HFNUM_MAX_FRNUM;
136 static int dumped_frame_num_array = 0;
138 if (frame_num_idx < FRAME_NUM_ARRAY_SIZE) {
139 if ((((last_frame_num + 1) & DWC_HFNUM_MAX_FRNUM) != _curr_frame_number)) {
140 frame_num_array[frame_num_idx] = _curr_frame_number;
141 last_frame_num_array[frame_num_idx++] = last_frame_num;
143 } else if (!dumped_frame_num_array) {
145 printk(KERN_EMERG USB_DWC "Frame Last Frame\n");
146 printk(KERN_EMERG USB_DWC "----- ----------\n");
147 for (i = 0; i < FRAME_NUM_ARRAY_SIZE; i++) {
148 printk(KERN_EMERG USB_DWC "0x%04x 0x%04x\n",
149 frame_num_array[i], last_frame_num_array[i]);
151 dumped_frame_num_array = 1;
153 last_frame_num = _curr_frame_number;
158 * Handles the start-of-frame interrupt in host mode. Non-periodic
159 * transactions may be queued to the DWC_otg controller for the current
160 * (micro)frame. Periodic transactions may be queued to the controller for the
163 int32_t dwc_otg_hcd_handle_sof_intr (dwc_otg_hcd_t *_hcd)
166 struct list_head *qh_entry;
169 dwc_otg_transaction_type_e tr_type;
170 gintsts_data_t gintsts = {.d32 = 0};
172 hfnum.d32 = dwc_read_reg32(&_hcd->core_if->host_if->host_global_regs->hfnum);
175 DWC_DEBUGPL(DBG_HCD, "--Start of Frame Interrupt--\n");
178 _hcd->frame_number = hfnum.b.frnum;
181 _hcd->frrem_accum += hfnum.b.frrem;
182 _hcd->frrem_samples++;
185 #ifdef DWC_TRACK_MISSED_SOFS
186 track_missed_sofs(_hcd->frame_number);
189 /* Determine whether any periodic QHs should be executed. */
190 qh_entry = _hcd->periodic_sched_inactive.next;
191 while (qh_entry != &_hcd->periodic_sched_inactive) {
192 qh = list_entry(qh_entry, dwc_otg_qh_t, qh_list_entry);
193 if(qh->qh_state != QH_INACTIVE){
194 qh_entry = qh_entry->next;
197 qh_entry = qh_entry->next;
198 if (dwc_frame_num_le(qh->sched_frame, _hcd->frame_number)) {
201 * fix bug for alcro hub
202 * do not send csplit after start_split_frame+4
204 qtd = list_entry(qh->qtd_list.next, dwc_otg_qtd_t, qtd_list_entry);
205 if((qh->do_split)&&dwc_frame_num_gt(_hcd->frame_number,
206 dwc_frame_num_inc(qh->start_split_frame, 4))&&(qtd->complete_split))
208 DWC_PRINT("frame_number 0x%x, start 0x%x, complete: %x",
209 _hcd->frame_number, qh->start_split_frame, qtd->complete_split);
210 qtd->complete_split = 0;
212 qh->sched_frame = dwc_frame_num_inc(qh->start_split_frame,
214 if (dwc_frame_num_le(qh->sched_frame, _hcd->frame_number)) {
215 qh->sched_frame = _hcd->frame_number;
217 qh->sched_frame |= 0x7;
218 qh->start_split_frame = qh->sched_frame;
224 * Move QH to the ready list to be executed next
227 //list_move_tail(&qh->qh_list_entry, &_hcd->periodic_sched_ready);
228 qh->qh_state = QH_READY;
233 tr_type = dwc_otg_hcd_select_transactions(_hcd);
234 if (tr_type != DWC_OTG_TRANSACTION_NONE) {
235 dwc_otg_hcd_queue_transactions(_hcd, tr_type);
237 } else if (list_empty(&_hcd->periodic_sched_inactive) //&&
238 // list_empty(&_hcd->periodic_sched_ready) &&
239 // list_empty(&_hcd->periodic_sched_assigned) &&
240 // list_empty(&_hcd->periodic_sched_queued)
243 * We don't have USB data to send. Unfortunately the
244 * Synopsis block continues to generate interrupts at
245 * about 8k/sec. In order not waste time on these
246 * useless interrupts, we're going to disable the SOF
247 * interrupt. It will be re-enabled when a new packet
248 * is enqueued in dwc_otg_hcd_urb_enqueue()
250 dwc_modify_reg32(&_hcd->core_if->core_global_regs->gintmsk,
251 DWC_SOF_INTR_MASK, 0);
255 /* Clear interrupt */
256 gintsts.b.sofintr = 1;
257 dwc_write_reg32(&_hcd->core_if->core_global_regs->gintsts, gintsts.d32);
262 /** Handles the Rx Status Queue Level Interrupt, which indicates that there is at
263 * least one packet in the Rx FIFO. The packets are moved from the FIFO to
264 * memory if the DWC_otg controller is operating in Slave mode. */
265 int32_t dwc_otg_hcd_handle_rx_status_q_level_intr (dwc_otg_hcd_t *_dwc_otg_hcd)
267 host_grxsts_data_t grxsts;
270 DWC_DEBUGPL(DBG_HCD, "--RxStsQ Level Interrupt--\n");
272 grxsts.d32 = dwc_read_reg32(&_dwc_otg_hcd->core_if->core_global_regs->grxstsp);
274 hc = _dwc_otg_hcd->hc_ptr_array[grxsts.b.chnum];
277 DWC_DEBUGPL(DBG_HCDV, " Ch num = %d\n", grxsts.b.chnum);
278 DWC_DEBUGPL(DBG_HCDV, " Count = %d\n", grxsts.b.bcnt);
279 DWC_DEBUGPL(DBG_HCDV, " DPID = %d, hc.dpid = %d\n", grxsts.b.dpid, hc->data_pid_start);
280 DWC_DEBUGPL(DBG_HCDV, " PStatus = %d\n", grxsts.b.pktsts);
282 switch (grxsts.b.pktsts) {
283 case DWC_GRXSTS_PKTSTS_IN:
284 /* Read the data into the host buffer. */
285 if (grxsts.b.bcnt > 0) {
286 dwc_otg_read_packet(_dwc_otg_hcd->core_if,
290 /* Update the HC fields for the next packet received. */
291 hc->xfer_count += grxsts.b.bcnt;
292 hc->xfer_buff += grxsts.b.bcnt;
295 case DWC_GRXSTS_PKTSTS_IN_XFER_COMP:
296 case DWC_GRXSTS_PKTSTS_DATA_TOGGLE_ERR:
297 case DWC_GRXSTS_PKTSTS_CH_HALTED:
298 /* Handled in interrupt, just ignore data */
301 DWC_ERROR ("RX_STS_Q Interrupt: Unknown status %d\n", grxsts.b.pktsts);
308 /** This interrupt occurs when the non-periodic Tx FIFO is half-empty. More
309 * data packets may be written to the FIFO for OUT transfers. More requests
310 * may be written to the non-periodic request queue for IN transfers. This
311 * interrupt is enabled only in Slave mode. */
312 int32_t dwc_otg_hcd_handle_np_tx_fifo_empty_intr (dwc_otg_hcd_t *_dwc_otg_hcd)
314 DWC_DEBUGPL(DBG_HCD, "--Non-Periodic TxFIFO Empty Interrupt--\n");
315 dwc_otg_hcd_queue_transactions(_dwc_otg_hcd,
316 DWC_OTG_TRANSACTION_NON_PERIODIC);
320 /** This interrupt occurs when the periodic Tx FIFO is half-empty. More data
321 * packets may be written to the FIFO for OUT transfers. More requests may be
322 * written to the periodic request queue for IN transfers. This interrupt is
323 * enabled only in Slave mode. */
324 int32_t dwc_otg_hcd_handle_perio_tx_fifo_empty_intr (dwc_otg_hcd_t *_dwc_otg_hcd)
326 DWC_DEBUGPL(DBG_HCD, "--Periodic TxFIFO Empty Interrupt--\n");
327 dwc_otg_hcd_queue_transactions(_dwc_otg_hcd,
328 DWC_OTG_TRANSACTION_PERIODIC);
332 /** There are multiple conditions that can cause a port interrupt. This function
333 * determines which interrupt conditions have occurred and handles them
335 int32_t dwc_otg_hcd_handle_port_intr (dwc_otg_hcd_t *_dwc_otg_hcd)
339 hprt0_data_t hprt0_modify;
341 hprt0.d32 = dwc_read_reg32(_dwc_otg_hcd->core_if->host_if->hprt0);
342 hprt0_modify.d32 = dwc_read_reg32(_dwc_otg_hcd->core_if->host_if->hprt0);
344 /* Clear appropriate bits in HPRT0 to clear the interrupt bit in
347 hprt0_modify.b.prtena = 0;
348 hprt0_modify.b.prtconndet = 0;
349 hprt0_modify.b.prtenchng = 0;
350 hprt0_modify.b.prtovrcurrchng = 0;
352 /* Port Connect Detected
353 * Set flag and clear if detected */
354 if (hprt0.b.prtconndet) {
355 DWC_DEBUGPL(DBG_HCD, "--Port Interrupt HPRT0=0x%08x "
356 "Port Connect Detected--\n", hprt0.d32);
357 _dwc_otg_hcd->flags.b.port_connect_status_change = 1;
358 _dwc_otg_hcd->flags.b.port_connect_status = 1;
359 hprt0_modify.b.prtconndet = 1;
361 /* B-Device has connected, Delete the connection timer. */
362 // del_timer( &_dwc_otg_hcd->conn_timer );
364 /* The Hub driver asserts a reset when it sees port connect
365 * status change flag */
369 /* Port Enable Changed
370 * Clear if detected - Set internal flag if disabled */
371 if (hprt0.b.prtenchng) {
372 DWC_DEBUGPL(DBG_HCD, " --Port Interrupt HPRT0=0x%08x "
373 "Port Enable Changed--\n", hprt0.d32);
374 hprt0_modify.b.prtenchng = 1;
375 if (hprt0.b.prtena == 1) {
377 dwc_otg_core_params_t *params = _dwc_otg_hcd->core_if->core_params;
378 dwc_otg_core_global_regs_t *global_regs = _dwc_otg_hcd->core_if->core_global_regs;
379 dwc_otg_host_if_t *host_if = _dwc_otg_hcd->core_if->host_if;
381 /* Check if we need to adjust the PHY clock speed for
382 * low power and adjust it */
384 /*fix bug usb host 1.1 with low-speed*/
385 if (params->host_support_fs_ls_low_power)
387 gusbcfg_data_t usbcfg;
389 usbcfg.d32 = dwc_read_reg32 (&global_regs->gusbcfg);
391 if ((hprt0.b.prtspd == DWC_HPRT0_PRTSPD_LOW_SPEED) ||
392 (hprt0.b.prtspd == DWC_HPRT0_PRTSPD_FULL_SPEED))
399 if (usbcfg.b.phylpwrclksel == 0) {
400 /* Set PHY low power clock select for FS/LS devices */
401 usbcfg.b.phylpwrclksel = 1;
402 dwc_write_reg32(&global_regs->gusbcfg, usbcfg.d32);
407 hcfg.d32 = dwc_read_reg32(&host_if->host_global_regs->hcfg);
409 if ((hprt0.b.prtspd == DWC_HPRT0_PRTSPD_LOW_SPEED) &&
410 (params->host_ls_low_power_phy_clk ==
411 DWC_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ))
414 DWC_DEBUGPL(DBG_CIL, "FS_PHY programming HCFG to 6 MHz (Low Power)\n");
415 if (hcfg.b.fslspclksel != DWC_HCFG_6_MHZ) {
416 hcfg.b.fslspclksel = DWC_HCFG_6_MHZ;
417 dwc_write_reg32(&host_if->host_global_regs->hcfg,
419 dwc_write_reg32(&host_if->host_global_regs->hfir, 0x1770);
425 DWC_DEBUGPL(DBG_CIL, "FS_PHY programming HCFG to 48 MHz ()\n");
426 if (hcfg.b.fslspclksel != DWC_HCFG_48_MHZ) {
427 hcfg.b.fslspclksel = DWC_HCFG_48_MHZ;
428 dwc_write_reg32(&host_if->host_global_regs->hcfg,
430 dwc_write_reg32(&host_if->host_global_regs->hfir, 0xea60);
439 if (usbcfg.b.phylpwrclksel == 1) {
440 usbcfg.b.phylpwrclksel = 0;
441 dwc_write_reg32(&global_regs->gusbcfg, usbcfg.d32);
447 tasklet_schedule(_dwc_otg_hcd->reset_tasklet);
452 /* Port has been enabled set the reset change flag */
453 _dwc_otg_hcd->flags.b.port_reset_change = 1;
457 _dwc_otg_hcd->flags.b.port_enable_change = 1;
462 /** Overcurrent Change Interrupt */
463 if (hprt0.b.prtovrcurrchng) {
464 DWC_DEBUGPL(DBG_HCD, " --Port Interrupt HPRT0=0x%08x "
465 "Port Overcurrent Changed--\n", hprt0.d32);
466 _dwc_otg_hcd->flags.b.port_over_current_change = 1;
467 hprt0_modify.b.prtovrcurrchng = 1;
471 /* Clear Port Interrupts */
472 dwc_write_reg32(_dwc_otg_hcd->core_if->host_if->hprt0, hprt0_modify.d32);
478 /** This interrupt indicates that one or more host channels has a pending
479 * interrupt. There are multiple conditions that can cause each host channel
480 * interrupt. This function determines which conditions have occurred for each
481 * host channel interrupt and handles them appropriately. */
482 int32_t dwc_otg_hcd_handle_hc_intr (dwc_otg_hcd_t *_dwc_otg_hcd)
485 volatile haint_data_t haint;
487 struct list_head *qh_entry;
491 /* Clear appropriate bits in HCINTn to clear the interrupt bit in
494 haint.d32 = dwc_otg_read_host_all_channels_intr(_dwc_otg_hcd->core_if);
496 for (i = 0; i < _dwc_otg_hcd->core_if->core_params->host_channels; i++) {
497 if (haint.b2.chint & (1 << i))
498 retval |= dwc_otg_hcd_handle_hc_n_intr(_dwc_otg_hcd, i);
502 * USB Spec2.0 11.18.4
503 * for all periodic endpoints that have split transactions scheduled within
504 * a particular microframe, the host must issue complete-split transactions
505 * in the same relative order as the corresponding start-split transactions
508 qh_entry = _dwc_otg_hcd->periodic_sched_inactive.next;
509 while (qh_entry != &_dwc_otg_hcd->periodic_sched_inactive) {
510 qh = list_entry(qh_entry, dwc_otg_qh_t, qh_list_entry);
511 qh_entry = qh_entry->next;
512 if(qh->qh_state != QH_QUEUED)
514 if(qh->channel == NULL){
515 DWC_PRINT("%s channel NULL 1\n", __func__);
518 hcnum = qh->channel->hc_num;
519 if (haint.b2.chint & (1 << hcnum)) {
520 retval |= dwc_otg_hcd_handle_hc_n_intr (_dwc_otg_hcd, hcnum);
524 haint.d32 = dwc_otg_read_host_all_channels_intr(_dwc_otg_hcd->core_if);
525 qh_entry = _dwc_otg_hcd->non_periodic_sched_active.next;
526 while (&_dwc_otg_hcd->non_periodic_sched_active != qh_entry){
527 qh = list_entry(qh_entry, dwc_otg_qh_t, qh_list_entry);
528 qh_entry = qh_entry->next;
529 if(qh->channel == NULL){
530 DWC_PRINT("%s channel NULL 2\n", __func__);
533 hcnum = qh->channel->hc_num;
534 if (haint.b2.chint & (1 << hcnum)) {
535 retval |= dwc_otg_hcd_handle_hc_n_intr (_dwc_otg_hcd, hcnum);
538 haint.d32 = dwc_otg_read_host_all_channels_intr(_dwc_otg_hcd->core_if);
539 for (i = 0; i < _dwc_otg_hcd->core_if->core_params->host_channels; i++) {
540 if (haint.b2.chint & (1 << i))
541 retval |= dwc_otg_hcd_handle_hc_n_intr(_dwc_otg_hcd, i);
547 /* Macro used to clear one channel interrupt */
548 #define clear_hc_int(_hc_regs_,_intr_) \
550 hcint_data_t hcint_clear = {.d32 = 0}; \
551 hcint_clear.b._intr_ = 1; \
552 dwc_write_reg32(&((_hc_regs_)->hcint), hcint_clear.d32); \
556 * Macro used to disable one channel interrupt. Channel interrupts are
557 * disabled when the channel is halted or released by the interrupt handler.
558 * There is no need to handle further interrupts of that type until the
559 * channel is re-assigned. In fact, subsequent handling may cause crashes
560 * because the channel structures are cleaned up when the channel is released.
562 #define disable_hc_int(_hc_regs_,_intr_) \
564 hcintmsk_data_t hcintmsk = {.d32 = 0}; \
565 hcintmsk.b._intr_ = 1; \
566 dwc_modify_reg32(&((_hc_regs_)->hcintmsk), hcintmsk.d32, 0); \
570 * Gets the actual length of a transfer after the transfer halts. _halt_status
571 * holds the reason for the halt.
573 * For IN transfers where _halt_status is DWC_OTG_HC_XFER_COMPLETE,
574 * *_short_read is set to 1 upon return if less than the requested
575 * number of bytes were transferred. Otherwise, *_short_read is set to 0 upon
576 * return. _short_read may also be NULL on entry, in which case it remains
579 static uint32_t get_actual_xfer_length(dwc_hc_t *_hc,
580 dwc_otg_hc_regs_t *_hc_regs,
582 dwc_otg_halt_status_e _halt_status,
585 hctsiz_data_t hctsiz;
588 if (_short_read != NULL) {
591 hctsiz.d32 = dwc_read_reg32(&_hc_regs->hctsiz);
593 if (_halt_status == DWC_OTG_HC_XFER_COMPLETE) {
595 length = _hc->xfer_len - hctsiz.b.xfersize;
596 if (_short_read != NULL) {
597 *_short_read = (hctsiz.b.xfersize != 0);
599 } else if (_hc->qh->do_split) {
600 length = _qtd->ssplit_out_xfer_count;
602 length = _hc->xfer_len;
606 * Must use the hctsiz.pktcnt field to determine how much data
607 * has been transferred. This field reflects the number of
608 * packets that have been transferred via the USB. This is
609 * always an integral number of packets if the transfer was
610 * halted before its normal completion. (Can't use the
611 * hctsiz.xfersize field because that reflects the number of
612 * bytes transferred via the AHB, not the USB).
614 length = (_hc->start_pkt_count - hctsiz.b.pktcnt) * _hc->max_packet;
621 * Updates the state of the URB after a Transfer Complete interrupt on the
622 * host channel. Updates the actual_length field of the URB based on the
623 * number of bytes transferred via the host channel. Sets the URB status
624 * if the data transfer is finished.
626 * @return 1 if the data transfer specified by the URB is completely finished,
629 static int update_urb_state_xfer_comp(dwc_hc_t *_hc,
630 dwc_otg_hc_regs_t *_hc_regs,
637 _urb->actual_length += get_actual_xfer_length(_hc, _hc_regs, _qtd,
638 DWC_OTG_HC_XFER_COMPLETE,
641 if (short_read || (_urb->actual_length >= _urb->transfer_buffer_length)) {
643 if (short_read && (_urb->transfer_flags & URB_SHORT_NOT_OK)) {
644 _urb->status = -EREMOTEIO;
653 hctsiz_data_t hctsiz;
654 hctsiz.d32 = dwc_read_reg32(&_hc_regs->hctsiz);
655 DWC_DEBUGPL(DBG_HCDV, "DWC_otg: %s: %s, channel %d\n",
656 __func__, (_hc->ep_is_in ? "IN" : "OUT"), _hc->hc_num);
657 DWC_DEBUGPL(DBG_HCDV, " hc->xfer_len %d\n", _hc->xfer_len);
658 DWC_DEBUGPL(DBG_HCDV, " hctsiz.xfersize %d\n", hctsiz.b.xfersize);
659 DWC_DEBUGPL(DBG_HCDV, " urb->transfer_buffer_length %d\n",
660 _urb->transfer_buffer_length);
661 DWC_DEBUGPL(DBG_HCDV, " urb->actual_length %d\n", _urb->actual_length);
662 DWC_DEBUGPL(DBG_HCDV, " short_read %d, xfer_done %d\n",
663 short_read, xfer_done);
671 * Save the starting data toggle for the next transfer. The data toggle is
672 * saved in the QH for non-control transfers and it's saved in the QTD for
675 static void save_data_toggle(dwc_hc_t *_hc,
676 dwc_otg_hc_regs_t *_hc_regs,
679 hctsiz_data_t hctsiz;
680 hctsiz.d32 = dwc_read_reg32(&_hc_regs->hctsiz);
682 if (_hc->ep_type != DWC_OTG_EP_TYPE_CONTROL) {
683 dwc_otg_qh_t *qh = _hc->qh;
684 if (hctsiz.b.pid == DWC_HCTSIZ_DATA0) {
685 qh->data_toggle = DWC_OTG_HC_PID_DATA0;
687 qh->data_toggle = DWC_OTG_HC_PID_DATA1;
690 if (hctsiz.b.pid == DWC_HCTSIZ_DATA0) {
691 _qtd->data_toggle = DWC_OTG_HC_PID_DATA0;
693 _qtd->data_toggle = DWC_OTG_HC_PID_DATA1;
699 * Frees the first QTD in the QH's list if free_qtd is 1. For non-periodic
700 * QHs, removes the QH from the active non-periodic schedule. If any QTDs are
701 * still linked to the QH, the QH is added to the end of the inactive
702 * non-periodic schedule. For periodic QHs, removes the QH from the periodic
703 * schedule if no more QTDs are linked to the QH.
705 static void deactivate_qh(dwc_otg_hcd_t *_hcd,
709 int continue_split = 0;
712 DWC_DEBUGPL(DBG_HCDV, " %s(%p,%p,%d)\n", __func__, _hcd, _qh, free_qtd);
714 qtd = list_entry(_qh->qtd_list.next, dwc_otg_qtd_t, qtd_list_entry);
716 if (qtd->complete_split) {
719 else if ((qtd->isoc_split_pos == DWC_HCSPLIT_XACTPOS_MID) ||
720 (qtd->isoc_split_pos == DWC_HCSPLIT_XACTPOS_END))
726 dwc_otg_hcd_qtd_remove_and_free(qtd);
731 _qh->qtd_in_process = NULL;
732 dwc_otg_hcd_qh_deactivate(_hcd, _qh, continue_split);
736 * Updates the state of an Isochronous URB when the transfer is stopped for
737 * any reason. The fields of the current entry in the frame descriptor array
738 * are set based on the transfer state and the input _halt_status. Completes
739 * the Isochronous URB if all the URB frames have been completed.
741 * @return DWC_OTG_HC_XFER_COMPLETE if there are more frames remaining to be
742 * transferred in the URB. Otherwise return DWC_OTG_HC_XFER_URB_COMPLETE.
744 static dwc_otg_halt_status_e
745 update_isoc_urb_state(dwc_otg_hcd_t *_hcd,
747 dwc_otg_hc_regs_t *_hc_regs,
749 dwc_otg_halt_status_e _halt_status)
751 struct urb *urb = _qtd->urb;
752 dwc_otg_halt_status_e ret_val = _halt_status;
753 struct usb_iso_packet_descriptor *frame_desc;
755 frame_desc = &urb->iso_frame_desc[_qtd->isoc_frame_index];
756 switch (_halt_status) {
757 case DWC_OTG_HC_XFER_COMPLETE:
758 frame_desc->status = 0;
759 frame_desc->actual_length =
760 get_actual_xfer_length(_hc, _hc_regs, _qtd,
763 case DWC_OTG_HC_XFER_FRAME_OVERRUN:
766 frame_desc->status = -ENOSR;
768 frame_desc->status = -ECOMM;
770 frame_desc->actual_length = 0;
772 case DWC_OTG_HC_XFER_BABBLE_ERR:
774 frame_desc->status = -EOVERFLOW;
775 /* Don't need to update actual_length in this case. */
777 case DWC_OTG_HC_XFER_XACT_ERR:
779 frame_desc->status = -EPROTO;
780 frame_desc->actual_length =
781 get_actual_xfer_length(_hc, _hc_regs, _qtd,
785 DWC_ERROR("%s: Unhandled _halt_status (%d)\n", __func__,
791 if (++_qtd->isoc_frame_index == urb->number_of_packets) {
793 * urb->status is not used for isoc transfers.
794 * The individual frame_desc statuses are used instead.
796 dwc_otg_hcd_complete_urb(_hcd, urb, 0);
797 ret_val = DWC_OTG_HC_XFER_URB_COMPLETE;
799 ret_val = DWC_OTG_HC_XFER_COMPLETE;
806 * Releases a host channel for use by other transfers. Attempts to select and
807 * queue more transactions since at least one host channel is available.
809 * @param _hcd The HCD state structure.
810 * @param _hc The host channel to release.
811 * @param _qtd The QTD associated with the host channel. This QTD may be freed
812 * if the transfer is complete or an error has occurred.
813 * @param _halt_status Reason the channel is being released. This status
814 * determines the actions taken by this function.
817 void release_channel(dwc_otg_hcd_t *_hcd,
820 dwc_otg_halt_status_e _halt_status)
822 dwc_otg_transaction_type_e tr_type;
824 int continue_trans = 1;
825 if(_halt_status != DWC_OTG_HC_XFER_URB_DEQUEUE){
826 if(((uint32_t) _qtd & 0xf0000000)==0){
827 DWC_PRINT("%s qtd %p, status %d\n", __func__, _qtd, _halt_status);
830 if(((uint32_t) _qtd & 0x80000000)==0){
831 DWC_PRINT("%s qtd %p, status %d 1\n", __func__, _qtd, _halt_status);
834 if(((uint32_t) _qtd->urb & 0xf0000000)==0){
835 DWC_PRINT("%s qtd %p urb %p, status %d\n", __func__, _qtd, _qtd->urb, _halt_status);
840 DWC_DEBUGPL(DBG_HCDV, " %s: channel %d, halt_status %d\n",
841 __func__, _hc->hc_num, _halt_status);
842 switch (_halt_status) {
843 case DWC_OTG_HC_XFER_URB_COMPLETE:
846 case DWC_OTG_HC_XFER_AHB_ERR:
847 case DWC_OTG_HC_XFER_STALL:
848 case DWC_OTG_HC_XFER_BABBLE_ERR:
851 case DWC_OTG_HC_XFER_XACT_ERR:
852 if (_qtd->error_count >= 3) {
853 DWC_DEBUGPL(DBG_HCDV, " Complete URB with transaction error\n");
855 _qtd->urb->status = -EPROTO;
856 dwc_otg_hcd_complete_urb(_hcd, _qtd->urb, -EPROTO);
861 case DWC_OTG_HC_XFER_URB_DEQUEUE:
863 * The QTD has already been removed and the QH has been
864 * deactivated. Don't want to do anything except release the
865 * host channel and try to queue more transfers.
869 case DWC_OTG_HC_XFER_NO_HALT_STATUS:
870 DWC_ERROR("%s: No halt_status, channel %d\n", __func__, _hc->hc_num);
884 deactivate_qh(_hcd, _hc->qh, free_qtd);
888 * Release the host channel for use by other transfers. The cleanup
889 * function clears the channel interrupt enables and conditions, so
890 * there's no need to clear the Channel Halted interrupt separately.
892 dwc_otg_hc_cleanup(_hcd->core_if, _hc);
893 list_add_tail(&_hc->hc_list_entry, &_hcd->free_hc_list);
895 switch (_hc->ep_type) {
896 case DWC_OTG_EP_TYPE_CONTROL:
897 case DWC_OTG_EP_TYPE_BULK:
898 _hcd->non_periodic_channels--;
903 * Don't release reservations for periodic channels here.
904 * That's done when a periodic transfer is descheduled (i.e.
905 * when the QH is removed from the periodic schedule).
911 /* Try to queue more transfers now that there's a free channel. */
912 tr_type = dwc_otg_hcd_select_transactions(_hcd);
913 if (tr_type != DWC_OTG_TRANSACTION_NONE) {
914 dwc_otg_hcd_queue_transactions(_hcd, tr_type);
918 * Make sure the start of frame interrupt is enabled now that
919 * we know we should have queued data. The SOF interrupt
920 * handler automatically disables itself when idle to reduce
921 * the number of interrupts. See dwc_otg_hcd_handle_sof_intr()
924 dwc_modify_reg32(&_hcd->core_if->core_global_regs->gintmsk, 0,
929 * Halts a host channel. If the channel cannot be halted immediately because
930 * the request queue is full, this function ensures that the FIFO empty
931 * interrupt for the appropriate queue is enabled so that the halt request can
932 * be queued when there is space in the request queue.
934 * This function may also be called in DMA mode. In that case, the channel is
935 * simply released since the core always halts the channel automatically in
938 static void halt_channel(dwc_otg_hcd_t *_hcd,
941 dwc_otg_halt_status_e _halt_status)
943 if (_hcd->core_if->dma_enable) {
944 release_channel(_hcd, _hc, _qtd, _halt_status);
948 /* Slave mode processing... */
949 dwc_otg_hc_halt(_hcd->core_if, _hc, _halt_status);
951 if (_hc->halt_on_queue) {
952 gintmsk_data_t gintmsk = {.d32 = 0};
953 dwc_otg_core_global_regs_t *global_regs;
954 global_regs = _hcd->core_if->core_global_regs;
956 if (_hc->ep_type == DWC_OTG_EP_TYPE_CONTROL ||
957 _hc->ep_type == DWC_OTG_EP_TYPE_BULK) {
959 * Make sure the Non-periodic Tx FIFO empty interrupt
960 * is enabled so that the non-periodic schedule will
963 gintmsk.b.nptxfempty = 1;
964 dwc_modify_reg32(&global_regs->gintmsk, 0, gintmsk.d32);
967 * Move the QH from the periodic queued schedule to
968 * the periodic assigned schedule. This allows the
969 * halt to be queued when the periodic schedule is
972 //list_move_tail(&_hc->qh->qh_list_entry,
973 // &_hcd->periodic_sched_assigned);
976 * Make sure the Periodic Tx FIFO Empty interrupt is
977 * enabled so that the periodic schedule will be
980 gintmsk.b.ptxfempty = 1;
981 dwc_modify_reg32(&global_regs->gintmsk, 0, gintmsk.d32);
987 * Performs common cleanup for non-periodic transfers after a Transfer
988 * Complete interrupt. This function should be called after any endpoint type
989 * specific handling is finished to release the host channel.
991 static void complete_non_periodic_xfer(dwc_otg_hcd_t *_hcd,
993 dwc_otg_hc_regs_t *_hc_regs,
995 dwc_otg_halt_status_e _halt_status)
999 _qtd->error_count = 0;
1001 hcint.d32 = dwc_read_reg32(&_hc_regs->hcint);
1004 * Got a NYET on the last transaction of the transfer. This
1005 * means that the endpoint should be in the PING state at the
1006 * beginning of the next transfer.
1008 _hc->qh->ping_state = 1;
1009 clear_hc_int(_hc_regs,nyet);
1013 * Always halt and release the host channel to make it available for
1014 * more transfers. There may still be more phases for a control
1015 * transfer or more data packets for a bulk transfer at this point,
1016 * but the host channel is still halted. A channel will be reassigned
1017 * to the transfer when the non-periodic schedule is processed after
1018 * the channel is released. This allows transactions to be queued
1019 * properly via dwc_otg_hcd_queue_transactions, which also enables the
1020 * Tx FIFO Empty interrupt if necessary.
1022 if (_hc->ep_is_in) {
1024 * IN transfers in Slave mode require an explicit disable to
1025 * halt the channel. (In DMA mode, this call simply releases
1028 halt_channel(_hcd, _hc, _qtd, _halt_status);
1031 * The channel is automatically disabled by the core for OUT
1032 * transfers in Slave mode.
1034 release_channel(_hcd, _hc, _qtd, _halt_status);
1039 * Performs common cleanup for periodic transfers after a Transfer Complete
1040 * interrupt. This function should be called after any endpoint type specific
1041 * handling is finished to release the host channel.
1043 static void complete_periodic_xfer(dwc_otg_hcd_t *_hcd,
1045 dwc_otg_hc_regs_t *_hc_regs,
1046 dwc_otg_qtd_t *_qtd,
1047 dwc_otg_halt_status_e _halt_status)
1049 hctsiz_data_t hctsiz;
1050 _qtd->error_count = 0;
1052 hctsiz.d32 = dwc_read_reg32(&_hc_regs->hctsiz);
1053 if (!_hc->ep_is_in || hctsiz.b.pktcnt == 0) {
1054 /* Core halts channel in these cases. */
1055 release_channel(_hcd, _hc, _qtd, _halt_status);
1057 /* Flush any outstanding requests from the Tx queue. */
1058 halt_channel(_hcd, _hc, _qtd, _halt_status);
1063 * Handles a host channel Transfer Complete interrupt. This handler may be
1064 * called in either DMA mode or Slave mode.
1066 static int32_t handle_hc_xfercomp_intr(dwc_otg_hcd_t *_hcd,
1068 dwc_otg_hc_regs_t *_hc_regs,
1069 dwc_otg_qtd_t *_qtd)
1072 dwc_otg_halt_status_e halt_status = DWC_OTG_HC_XFER_COMPLETE;
1076 DWC_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
1077 "Transfer Complete--\n", _hc->hc_num);
1079 if(((uint32_t) _qtd & 0xf0000000)==0){
1080 DWC_PRINT("%s qtd %p\n", __func__, _qtd);
1081 release_channel(_hcd, _hc, _qtd, _hc->halt_status);
1086 if(((uint32_t)urb & 0xf0000000)==0){
1087 DWC_PRINT("%s qtd %p, urb %p\n", __func__, _qtd, urb);
1088 release_channel(_hcd, _hc, _qtd, _hc->halt_status);
1093 * Handle xfer complete on CSPLIT.
1095 if (_hc->qh->do_split) {
1096 _qtd->complete_split = 0;
1099 pipe_type = usb_pipetype(urb->pipe);
1100 /* Update the QTD and URB states. */
1101 switch (pipe_type) {
1103 switch (_qtd->control_phase) {
1104 case DWC_OTG_CONTROL_SETUP:
1105 if (urb->transfer_buffer_length > 0) {
1106 _qtd->control_phase = DWC_OTG_CONTROL_DATA;
1108 _qtd->control_phase = DWC_OTG_CONTROL_STATUS;
1110 DWC_DEBUGPL(DBG_HCDV, " Control setup transaction done\n");
1111 halt_status = DWC_OTG_HC_XFER_COMPLETE;
1113 case DWC_OTG_CONTROL_DATA: {
1114 urb_xfer_done = update_urb_state_xfer_comp(_hc, _hc_regs, urb, _qtd);
1115 if (urb_xfer_done) {
1116 _qtd->control_phase = DWC_OTG_CONTROL_STATUS;
1117 DWC_DEBUGPL(DBG_HCDV, " Control data transfer done\n");
1119 save_data_toggle(_hc, _hc_regs, _qtd);
1121 halt_status = DWC_OTG_HC_XFER_COMPLETE;
1124 case DWC_OTG_CONTROL_STATUS:
1125 DWC_DEBUGPL(DBG_HCDV, " Control transfer complete\n");
1126 if (urb->status == -EINPROGRESS) {
1129 dwc_otg_hcd_complete_urb(_hcd, urb, urb->status);
1130 halt_status = DWC_OTG_HC_XFER_URB_COMPLETE;
1134 complete_non_periodic_xfer(_hcd, _hc, _hc_regs, _qtd, halt_status);
1137 DWC_DEBUGPL(DBG_HCDV, " Bulk transfer complete\n");
1138 urb_xfer_done = update_urb_state_xfer_comp(_hc, _hc_regs, urb, _qtd);
1139 if (urb_xfer_done) {
1140 dwc_otg_hcd_complete_urb(_hcd, urb, urb->status);
1141 halt_status = DWC_OTG_HC_XFER_URB_COMPLETE;
1143 halt_status = DWC_OTG_HC_XFER_COMPLETE;
1146 save_data_toggle(_hc, _hc_regs, _qtd);
1147 complete_non_periodic_xfer(_hcd, _hc, _hc_regs, _qtd, halt_status);
1149 case PIPE_INTERRUPT:
1150 DWC_DEBUGPL(DBG_HCDV, " Interrupt transfer complete\n");
1151 urb_xfer_done = update_urb_state_xfer_comp(_hc, _hc_regs, urb, _qtd);
1153 save_data_toggle(_hc, _hc_regs, _qtd);
1154 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_NAK);
1158 * Interrupt URB is done on the first transfer complete
1161 dwc_otg_hcd_complete_urb(_hcd, urb, urb->status);
1162 save_data_toggle(_hc, _hc_regs, _qtd);
1163 complete_periodic_xfer(_hcd, _hc, _hc_regs, _qtd,
1164 DWC_OTG_HC_XFER_URB_COMPLETE);
1166 case PIPE_ISOCHRONOUS:
1167 DWC_DEBUGPL(DBG_HCDV, " Isochronous transfer complete\n");
1168 if (_qtd->isoc_split_pos == DWC_HCSPLIT_XACTPOS_ALL)
1170 halt_status = update_isoc_urb_state(_hcd, _hc, _hc_regs, _qtd,
1171 DWC_OTG_HC_XFER_COMPLETE);
1173 complete_periodic_xfer(_hcd, _hc, _hc_regs, _qtd, halt_status);
1177 disable_hc_int(_hc_regs,xfercompl);
1183 * Handles a host channel STALL interrupt. This handler may be called in
1184 * either DMA mode or Slave mode.
1186 static int32_t handle_hc_stall_intr(dwc_otg_hcd_t *_hcd,
1188 dwc_otg_hc_regs_t *_hc_regs,
1189 dwc_otg_qtd_t *_qtd)
1191 struct urb *urb = _qtd->urb;
1192 int pipe_type = usb_pipetype(urb->pipe);
1194 DWC_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
1195 "STALL Received--\n", _hc->hc_num);
1197 if (pipe_type == PIPE_CONTROL) {
1198 dwc_otg_hcd_complete_urb(_hcd, _qtd->urb, -EPIPE);
1201 if (pipe_type == PIPE_BULK || pipe_type == PIPE_INTERRUPT) {
1202 dwc_otg_hcd_complete_urb(_hcd, _qtd->urb, -EPIPE);
1204 * USB protocol requires resetting the data toggle for bulk
1205 * and interrupt endpoints when a CLEAR_FEATURE(ENDPOINT_HALT)
1206 * setup command is issued to the endpoint. Anticipate the
1207 * CLEAR_FEATURE command since a STALL has occurred and reset
1208 * the data toggle now.
1210 _hc->qh->data_toggle = 0;
1213 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_STALL);
1215 disable_hc_int(_hc_regs,stall);
1221 * Updates the state of the URB when a transfer has been stopped due to an
1222 * abnormal condition before the transfer completes. Modifies the
1223 * actual_length field of the URB to reflect the number of bytes that have
1224 * actually been transferred via the host channel.
1226 static void update_urb_state_xfer_intr(dwc_hc_t *_hc,
1227 dwc_otg_hc_regs_t *_hc_regs,
1229 dwc_otg_qtd_t *_qtd,
1230 dwc_otg_halt_status_e _halt_status)
1232 uint32_t bytes_transferred = get_actual_xfer_length(_hc, _hc_regs, _qtd,
1233 _halt_status, NULL);
1234 _urb->actual_length += bytes_transferred;
1238 hctsiz_data_t hctsiz;
1239 hctsiz.d32 = dwc_read_reg32(&_hc_regs->hctsiz);
1240 DWC_DEBUGPL(DBG_HCDV, "DWC_otg: %s: %s, channel %d\n",
1241 __func__, (_hc->ep_is_in ? "IN" : "OUT"), _hc->hc_num);
1242 DWC_DEBUGPL(DBG_HCDV, " _hc->start_pkt_count %d\n", _hc->start_pkt_count);
1243 DWC_DEBUGPL(DBG_HCDV, " hctsiz.pktcnt %d\n", hctsiz.b.pktcnt);
1244 DWC_DEBUGPL(DBG_HCDV, " _hc->max_packet %d\n", _hc->max_packet);
1245 DWC_DEBUGPL(DBG_HCDV, " bytes_transferred %d\n", bytes_transferred);
1246 DWC_DEBUGPL(DBG_HCDV, " _urb->actual_length %d\n", _urb->actual_length);
1247 DWC_DEBUGPL(DBG_HCDV, " _urb->transfer_buffer_length %d\n",
1248 _urb->transfer_buffer_length);
1254 * Handles a host channel NAK interrupt. This handler may be called in either
1255 * DMA mode or Slave mode.
1257 static int32_t handle_hc_nak_intr(dwc_otg_hcd_t *_hcd,
1259 dwc_otg_hc_regs_t *_hc_regs,
1260 dwc_otg_qtd_t *_qtd)
1262 DWC_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
1263 "NAK Received--\n", _hc->hc_num);
1266 * Handle NAK for IN/OUT SSPLIT/CSPLIT transfers, bulk, control, and
1267 * interrupt. Re-start the SSPLIT transfer.
1269 if (_hc->do_split) {
1270 if (_hc->complete_split) {
1271 _qtd->error_count = 0;
1274 _qtd->complete_split = 0;
1275 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_NAK);
1276 goto handle_nak_done;
1279 switch (usb_pipetype(_qtd->urb->pipe)) {
1282 if (_hcd->core_if->dma_enable && _hc->ep_is_in) {
1284 * NAK interrupts are enabled on bulk/control IN
1285 * transfers in DMA mode for the sole purpose of
1286 * resetting the error count after a transaction error
1287 * occurs. The core will continue transferring data.
1289 _qtd->error_count = 0;
1290 goto handle_nak_done;
1294 * NAK interrupts normally occur during OUT transfers in DMA
1295 * or Slave mode. For IN transfers, more requests will be
1296 * queued as request queue space is available.
1298 _qtd->error_count = 0;
1300 if (!_hc->qh->ping_state) {
1301 update_urb_state_xfer_intr(_hc, _hc_regs, _qtd->urb,
1302 _qtd, DWC_OTG_HC_XFER_NAK);
1303 save_data_toggle(_hc, _hc_regs, _qtd);
1304 if (_qtd->urb->dev->speed == USB_SPEED_HIGH) {
1305 _hc->qh->ping_state = 1;
1310 * Halt the channel so the transfer can be re-started from
1311 * the appropriate point or the PING protocol will
1314 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_NAK);
1316 case PIPE_INTERRUPT:
1317 _qtd->error_count = 0;
1318 update_urb_state_xfer_intr(_hc, _hc_regs, _qtd->urb,_qtd, DWC_OTG_HC_XFER_NAK);
1319 save_data_toggle(_hc, _hc_regs, _qtd);
1320 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_NAK);
1322 case PIPE_ISOCHRONOUS:
1323 /* Should never get called for isochronous transfers. */
1329 clear_hc_int(_hc_regs,nak);
1330 disable_hc_int(_hc_regs,nak);
1336 * Handles a host channel ACK interrupt. This interrupt is enabled when
1337 * performing the PING protocol in Slave mode, when errors occur during
1338 * either Slave mode or DMA mode, and during Start Split transactions.
1340 static int32_t handle_hc_ack_intr(dwc_otg_hcd_t *_hcd,
1342 dwc_otg_hc_regs_t *_hc_regs,
1343 dwc_otg_qtd_t *_qtd)
1345 DWC_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
1346 "ACK Received--\n", _hc->hc_num);
1348 if (_hc->do_split) {
1350 * Handle ACK on SSPLIT.
1351 * ACK should not occur in CSPLIT.
1353 if ((!_hc->ep_is_in) && (_hc->data_pid_start != DWC_OTG_HC_PID_SETUP)) {
1354 _qtd->ssplit_out_xfer_count = _hc->xfer_len;
1356 if (!(_hc->ep_type == DWC_OTG_EP_TYPE_ISOC && !_hc->ep_is_in)) {
1357 /* Don't need complete for isochronous out transfers. */
1358 _qtd->complete_split = 1;
1362 if ((_hc->ep_type == DWC_OTG_EP_TYPE_ISOC) && !_hc->ep_is_in) {
1363 switch (_hc->xact_pos) {
1364 case DWC_HCSPLIT_XACTPOS_ALL:
1366 case DWC_HCSPLIT_XACTPOS_END:
1367 _qtd->isoc_split_pos = DWC_HCSPLIT_XACTPOS_ALL;
1368 _qtd->isoc_split_offset = 0;
1370 case DWC_HCSPLIT_XACTPOS_BEGIN:
1371 case DWC_HCSPLIT_XACTPOS_MID:
1373 * For BEGIN or MID, calculate the length for
1374 * the next microframe to determine the correct
1375 * SSPLIT token, either MID or END.
1378 struct usb_iso_packet_descriptor *frame_desc;
1380 frame_desc = &_qtd->urb->iso_frame_desc[_qtd->isoc_frame_index];
1381 _qtd->isoc_split_offset += 188;
1383 if ((frame_desc->length - _qtd->isoc_split_offset) <= 188) {
1384 _qtd->isoc_split_pos = DWC_HCSPLIT_XACTPOS_END;
1387 _qtd->isoc_split_pos = DWC_HCSPLIT_XACTPOS_MID;
1395 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_ACK);
1398 _qtd->error_count = 0;
1400 if (_hc->qh->ping_state) {
1401 _hc->qh->ping_state = 0;
1403 * Halt the channel so the transfer can be re-started
1404 * from the appropriate point. This only happens in
1405 * Slave mode. In DMA mode, the ping_state is cleared
1406 * when the transfer is started because the core
1407 * automatically executes the PING, then the transfer.
1409 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_ACK);
1414 * If the ACK occurred when _not_ in the PING state, let the channel
1415 * continue transferring data after clearing the error count.
1418 disable_hc_int(_hc_regs,ack);
1424 * Handles a host channel NYET interrupt. This interrupt should only occur on
1425 * Bulk and Control OUT endpoints and for complete split transactions. If a
1426 * NYET occurs at the same time as a Transfer Complete interrupt, it is
1427 * handled in the xfercomp interrupt handler, not here. This handler may be
1428 * called in either DMA mode or Slave mode.
1430 static int32_t handle_hc_nyet_intr(dwc_otg_hcd_t *_hcd,
1432 dwc_otg_hc_regs_t *_hc_regs,
1433 dwc_otg_qtd_t *_qtd)
1435 DWC_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
1436 "NYET Received--\n", _hc->hc_num);
1440 * re-do the CSPLIT immediately on non-periodic
1442 if ((_hc->do_split) && (_hc->complete_split)) {
1443 if ((_hc->ep_type == DWC_OTG_EP_TYPE_INTR) ||
1444 (_hc->ep_type == DWC_OTG_EP_TYPE_ISOC)) {
1445 int frnum = dwc_otg_hcd_get_frame_number(dwc_otg_hcd_to_hcd(_hcd));
1447 if (dwc_full_frame_num(frnum) !=
1448 dwc_full_frame_num(_hc->qh->sched_frame)) {
1450 * No longer in the same full speed frame.
1451 * Treat this as a transaction error.
1454 /** @todo Fix system performance so this can
1455 * be treated as an error. Right now complete
1456 * splits cannot be scheduled precisely enough
1457 * due to other system activity, so this error
1458 * occurs regularly in Slave mode.
1460 _qtd->error_count++;
1462 _qtd->complete_split = 0;
1463 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_XACT_ERR);
1464 /** @todo add support for isoc release */
1465 goto handle_nyet_done;
1469 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_NYET);
1470 goto handle_nyet_done;
1473 _hc->qh->ping_state = 1;
1474 _qtd->error_count = 0;
1476 update_urb_state_xfer_intr(_hc, _hc_regs, _qtd->urb, _qtd,
1477 DWC_OTG_HC_XFER_NYET);
1478 save_data_toggle(_hc, _hc_regs, _qtd);
1481 * Halt the channel and re-start the transfer so the PING
1482 * protocol will start.
1484 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_NYET);
1487 disable_hc_int(_hc_regs,nyet);
1492 * Handles a host channel babble interrupt. This handler may be called in
1493 * either DMA mode or Slave mode.
1495 static int32_t handle_hc_babble_intr(dwc_otg_hcd_t *_hcd,
1497 dwc_otg_hc_regs_t *_hc_regs,
1498 dwc_otg_qtd_t *_qtd)
1500 DWC_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
1501 "Babble Error--\n", _hc->hc_num);
1502 DWC_PRINT("%s \n", __func__);
1503 if (_hc->ep_type != DWC_OTG_EP_TYPE_ISOC) {
1504 dwc_otg_hcd_complete_urb(_hcd, _qtd->urb, -EOVERFLOW);
1505 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_BABBLE_ERR);
1507 dwc_otg_halt_status_e halt_status;
1508 halt_status = update_isoc_urb_state(_hcd, _hc, _hc_regs, _qtd,
1509 DWC_OTG_HC_XFER_BABBLE_ERR);
1510 halt_channel(_hcd, _hc, _qtd, halt_status);
1512 disable_hc_int(_hc_regs,bblerr);
1517 * Handles a host channel AHB error interrupt. This handler is only called in
1520 static int32_t handle_hc_ahberr_intr(dwc_otg_hcd_t *_hcd,
1522 dwc_otg_hc_regs_t *_hc_regs,
1523 dwc_otg_qtd_t *_qtd)
1525 hcchar_data_t hcchar;
1526 hcsplt_data_t hcsplt;
1527 hctsiz_data_t hctsiz;
1529 struct urb *urb = _qtd->urb;
1531 DWC_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
1532 "AHB Error--\n", _hc->hc_num);
1534 hcchar.d32 = dwc_read_reg32(&_hc_regs->hcchar);
1535 hcsplt.d32 = dwc_read_reg32(&_hc_regs->hcsplt);
1536 hctsiz.d32 = dwc_read_reg32(&_hc_regs->hctsiz);
1537 hcdma = dwc_read_reg32(&_hc_regs->hcdma);
1539 DWC_ERROR("AHB ERROR, Channel %d\n", _hc->hc_num);
1540 DWC_ERROR(" hcchar 0x%08x, hcsplt 0x%08x\n", hcchar.d32, hcsplt.d32);
1541 DWC_ERROR(" hctsiz 0x%08x, hcdma 0x%08x\n", hctsiz.d32, hcdma);
1542 DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD URB Enqueue\n");
1543 DWC_ERROR(" Device address: %d\n", usb_pipedevice(urb->pipe));
1544 DWC_ERROR(" Endpoint: %d, %s\n", usb_pipeendpoint(urb->pipe),
1545 (usb_pipein(urb->pipe) ? "IN" : "OUT"));
1546 DWC_ERROR(" Endpoint type: %s\n",
1548 switch (usb_pipetype(urb->pipe)) {
1549 case PIPE_CONTROL: pipetype = "CONTROL"; break;
1550 case PIPE_BULK: pipetype = "BULK"; break;
1551 case PIPE_INTERRUPT: pipetype = "INTERRUPT"; break;
1552 case PIPE_ISOCHRONOUS: pipetype = "ISOCHRONOUS"; break;
1553 default: pipetype = "UNKNOWN"; break;
1555 DWC_ERROR(" Speed: %s\n",
1557 switch (urb->dev->speed) {
1558 case USB_SPEED_HIGH: speed = "HIGH"; break;
1559 case USB_SPEED_FULL: speed = "FULL"; break;
1560 case USB_SPEED_LOW: speed = "LOW"; break;
1561 default: speed = "UNKNOWN"; break;
1563 DWC_ERROR(" Max packet size: %d\n",
1564 usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)));
1565 DWC_ERROR(" Data buffer length: %d\n", urb->transfer_buffer_length);
1566 DWC_ERROR(" Transfer buffer: %p, Transfer DMA: %p\n",
1567 urb->transfer_buffer, (void *)urb->transfer_dma);
1568 DWC_ERROR(" Setup buffer: %p, Setup DMA: %p\n",
1569 urb->setup_packet, (void *)urb->setup_dma);
1570 DWC_ERROR(" Interval: %d\n", urb->interval);
1572 dwc_otg_hcd_complete_urb(_hcd, urb, -EIO);
1575 * Force a channel halt. Don't call halt_channel because that won't
1576 * write to the HCCHARn register in DMA mode to force the halt.
1578 dwc_otg_hc_halt(_hcd->core_if, _hc, DWC_OTG_HC_XFER_AHB_ERR);
1580 disable_hc_int(_hc_regs,ahberr);
1585 * Handles a host channel transaction error interrupt. This handler may be
1586 * called in either DMA mode or Slave mode.
1588 static int32_t handle_hc_xacterr_intr(dwc_otg_hcd_t *_hcd,
1590 dwc_otg_hc_regs_t *_hc_regs,
1591 dwc_otg_qtd_t *_qtd)
1593 dwc_otg_halt_status_e halt_status = DWC_OTG_HC_XFER_NO_HALT_STATUS;
1594 DWC_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
1595 "Transaction Error--\n", _hc->hc_num);
1596 if (list_empty(&_hc->qh->qh_list_entry)){
1597 DWC_PRINT("%s qh empty\n", __func__);
1601 if(((uint32_t) _qtd & 0xf0000000)==0){
1602 DWC_PRINT("%s qtd %p\n", __func__, _qtd);
1605 if(((uint32_t) _qtd & 0xf0000000)==0xf0000000){
1606 DWC_PRINT("%s qtd %p 1\n", __func__, _qtd);
1609 if(((uint32_t) _qtd->urb & 0xf0000000)==0){
1610 DWC_PRINT("%s qtd %p urb %p\n", __func__,_qtd, _qtd->urb);
1613 switch (usb_pipetype(_qtd->urb->pipe)) {
1616 _qtd->error_count++;
1617 if (!_hc->qh->ping_state) {
1618 update_urb_state_xfer_intr(_hc, _hc_regs, _qtd->urb,
1619 _qtd, DWC_OTG_HC_XFER_XACT_ERR);
1620 save_data_toggle(_hc, _hc_regs, _qtd);
1621 if (!_hc->ep_is_in && _qtd->urb->dev->speed == USB_SPEED_HIGH) {
1622 _hc->qh->ping_state = 1;
1627 * Halt the channel so the transfer can be re-started from
1628 * the appropriate point or the PING protocol will start.
1630 halt_status = DWC_OTG_HC_XFER_XACT_ERR;
1632 case PIPE_INTERRUPT:
1633 _qtd->error_count++;
1634 if ((_hc->do_split) && (_hc->complete_split)) {
1635 _qtd->complete_split = 0;
1637 halt_status = DWC_OTG_HC_XFER_XACT_ERR;
1639 case PIPE_ISOCHRONOUS:
1641 halt_status = update_isoc_urb_state(_hcd, _hc, _hc_regs, _qtd,
1642 DWC_OTG_HC_XFER_XACT_ERR);
1649 halt_channel(_hcd, _hc, _qtd, halt_status);
1650 disable_hc_int(_hc_regs,xacterr);
1656 * Handles a host channel frame overrun interrupt. This handler may be called
1657 * in either DMA mode or Slave mode.
1659 static int32_t handle_hc_frmovrun_intr(dwc_otg_hcd_t *_hcd,
1661 dwc_otg_hc_regs_t *_hc_regs,
1662 dwc_otg_qtd_t *_qtd)
1664 DWC_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
1665 "Frame Overrun--\n", _hc->hc_num);
1667 switch (usb_pipetype(_qtd->urb->pipe)) {
1671 case PIPE_INTERRUPT:
1672 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_FRAME_OVERRUN);
1674 case PIPE_ISOCHRONOUS:
1676 dwc_otg_halt_status_e halt_status;
1677 halt_status = update_isoc_urb_state(_hcd, _hc, _hc_regs, _qtd,
1678 DWC_OTG_HC_XFER_FRAME_OVERRUN);
1680 halt_channel(_hcd, _hc, _qtd, halt_status);
1685 disable_hc_int(_hc_regs,frmovrun);
1691 * Handles a host channel data toggle error interrupt. This handler may be
1692 * called in either DMA mode or Slave mode.
1694 static int32_t handle_hc_datatglerr_intr(dwc_otg_hcd_t *_hcd,
1696 dwc_otg_hc_regs_t *_hc_regs,
1697 dwc_otg_qtd_t *_qtd)
1699 DWC_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
1700 "Data Toggle Error--\n", _hc->hc_num);
1702 if (_hc->ep_is_in) {
1703 _qtd->error_count = 0;
1705 DWC_ERROR("Data Toggle Error on OUT transfer,"
1706 "channel %d\n", _hc->hc_num);
1709 disable_hc_int(_hc_regs,datatglerr);
1716 * This function is for debug only. It checks that a valid halt status is set
1717 * and that HCCHARn.chdis is clear. If there's a problem, corrective action is
1718 * taken and a warning is issued.
1719 * @return 1 if halt status is ok, 0 otherwise.
1721 static inline int halt_status_ok(dwc_otg_hcd_t *_hcd,
1723 dwc_otg_hc_regs_t *_hc_regs,
1724 dwc_otg_qtd_t *_qtd)
1726 hcchar_data_t hcchar;
1727 hctsiz_data_t hctsiz;
1729 hcintmsk_data_t hcintmsk;
1730 hcsplt_data_t hcsplt;
1732 if (_hc->halt_status == DWC_OTG_HC_XFER_NO_HALT_STATUS) {
1734 * This code is here only as a check. This condition should
1735 * never happen. Ignore the halt if it does occur.
1737 hcchar.d32 = dwc_read_reg32(&_hc_regs->hcchar);
1738 hctsiz.d32 = dwc_read_reg32(&_hc_regs->hctsiz);
1739 hcint.d32 = dwc_read_reg32(&_hc_regs->hcint);
1740 hcintmsk.d32 = dwc_read_reg32(&_hc_regs->hcintmsk);
1741 hcsplt.d32 = dwc_read_reg32(&_hc_regs->hcsplt);
1742 DWC_WARN("%s: _hc->halt_status == DWC_OTG_HC_XFER_NO_HALT_STATUS, "
1743 "channel %d, hcchar 0x%08x, hctsiz 0x%08x, "
1744 "hcint 0x%08x, hcintmsk 0x%08x, "
1745 "hcsplt 0x%08x, qtd->complete_split %d\n",
1746 __func__, _hc->hc_num, hcchar.d32, hctsiz.d32,
1747 hcint.d32, hcintmsk.d32,
1748 hcsplt.d32, _qtd->complete_split);
1750 DWC_WARN("%s: no halt status, channel %d, ignoring interrupt\n",
1751 __func__, _hc->hc_num);
1753 clear_hc_int(_hc_regs,chhltd);
1758 * This code is here only as a check. hcchar.chdis should
1759 * never be set when the halt interrupt occurs. Halt the
1760 * channel again if it does occur.
1762 hcchar.d32 = dwc_read_reg32(&_hc_regs->hcchar);
1763 if (hcchar.b.chdis) {
1764 DWC_WARN("%s: hcchar.chdis set unexpectedly, "
1765 "hcchar 0x%08x, trying to halt again\n",
1766 __func__, hcchar.d32);
1767 clear_hc_int(_hc_regs,chhltd);
1768 _hc->halt_pending = 0;
1769 halt_channel(_hcd, _hc, _qtd, _hc->halt_status);
1778 * Handles a host Channel Halted interrupt in DMA mode. This handler
1779 * determines the reason the channel halted and proceeds accordingly.
1781 static void handle_hc_chhltd_intr_dma(dwc_otg_hcd_t *_hcd,
1783 dwc_otg_hc_regs_t *_hc_regs,
1784 dwc_otg_qtd_t *_qtd)
1787 hcintmsk_data_t hcintmsk;
1789 if (_hc->halt_status == DWC_OTG_HC_XFER_URB_DEQUEUE ||
1790 _hc->halt_status == DWC_OTG_HC_XFER_AHB_ERR) {
1792 * Just release the channel. A dequeue can happen on a
1793 * transfer timeout. In the case of an AHB Error, the channel
1794 * was forced to halt because there's no way to gracefully
1797 release_channel(_hcd, _hc, _qtd, _hc->halt_status);
1801 /* Read the HCINTn register to determine the cause for the halt. */
1802 hcint.d32 = dwc_read_reg32(&_hc_regs->hcint);
1803 hcintmsk.d32 = dwc_read_reg32(&_hc_regs->hcintmsk);
1805 if (hcint.b.xfercomp) {
1806 /** @todo This is here because of a possible hardware bug. Spec
1807 * says that on SPLIT-ISOC OUT transfers in DMA mode that a HALT
1808 * interrupt w/ACK bit set should occur, but I only see the
1809 * XFERCOMP bit, even with it masked out. This is a workaround
1810 * for that behavior. Should fix this when hardware is fixed.
1812 if ((_hc->ep_type == DWC_OTG_EP_TYPE_ISOC) && (!_hc->ep_is_in)) {
1813 handle_hc_ack_intr(_hcd, _hc, _hc_regs, _qtd);
1815 handle_hc_xfercomp_intr(_hcd, _hc, _hc_regs, _qtd);
1816 } else if (hcint.b.stall) {
1817 handle_hc_stall_intr(_hcd, _hc, _hc_regs, _qtd);
1818 } else if (hcint.b.xacterr) {
1820 * Must handle xacterr before nak or ack. Could get a xacterr
1821 * at the same time as either of these on a BULK/CONTROL OUT
1822 * that started with a PING. The xacterr takes precedence.
1824 handle_hc_xacterr_intr(_hcd, _hc, _hc_regs, _qtd);
1825 } else if (hcint.b.nyet) {
1827 * Must handle nyet before nak or ack. Could get a nyet at the
1828 * same time as either of those on a BULK/CONTROL OUT that
1829 * started with a PING. The nyet takes precedence.
1831 handle_hc_nyet_intr(_hcd, _hc, _hc_regs, _qtd);
1832 } else if (hcint.b.bblerr) {
1833 handle_hc_babble_intr(_hcd, _hc, _hc_regs, _qtd);
1834 } else if (hcint.b.frmovrun) {
1835 handle_hc_frmovrun_intr(_hcd, _hc, _hc_regs, _qtd);
1836 } else if (hcint.b.nak && !hcintmsk.b.nak) {
1838 * If nak is not masked, it's because a non-split IN transfer
1839 * is in an error state. In that case, the nak is handled by
1840 * the nak interrupt handler, not here. Handle nak here for
1841 * BULK/CONTROL OUT transfers, which halt on a NAK to allow
1842 * rewinding the buffer pointer.
1844 handle_hc_nak_intr(_hcd, _hc, _hc_regs, _qtd);
1845 } else if (hcint.b.ack && !hcintmsk.b.ack) {
1847 * If ack is not masked, it's because a non-split IN transfer
1848 * is in an error state. In that case, the ack is handled by
1849 * the ack interrupt handler, not here. Handle ack here for
1850 * split transfers. Start splits halt on ACK.
1852 handle_hc_ack_intr(_hcd, _hc, _hc_regs, _qtd);
1853 } else if(hcint.b.datatglerr){
1854 DWC_PRINT("%s, DATA toggle error, Channel %d\n",__func__, _hc->hc_num);
1855 _qtd->error_count++;
1856 save_data_toggle(_hc, _hc_regs, _qtd);
1857 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_XACT_ERR);
1858 clear_hc_int(_hc_regs,chhltd);
1860 if (_hc->ep_type == DWC_OTG_EP_TYPE_INTR ||
1861 _hc->ep_type == DWC_OTG_EP_TYPE_ISOC) {
1863 * A periodic transfer halted with no other channel
1864 * interrupts set. Assume it was halted by the core
1865 * because it could not be completed in its scheduled
1869 DWC_PRINT("%s: Halt channel %d (assume incomplete periodic transfer)\n",
1870 __func__, _hc->hc_num);
1872 halt_channel(_hcd, _hc, _qtd, DWC_OTG_HC_XFER_PERIODIC_INCOMPLETE);
1874 DWC_ERROR("%s: Channel %d, DMA Mode -- ChHltd set, but reason "
1875 "for halting is unknown, hcint 0x%08x, intsts 0x%08x\n",
1876 __func__, _hc->hc_num, hcint.d32,
1877 dwc_read_reg32(&_hcd->core_if->core_global_regs->gintsts));
1878 clear_hc_int(_hc_regs,chhltd);
1884 * Handles a host channel Channel Halted interrupt.
1886 * In slave mode, this handler is called only when the driver specifically
1887 * requests a halt. This occurs during handling other host channel interrupts
1888 * (e.g. nak, xacterr, stall, nyet, etc.).
1890 * In DMA mode, this is the interrupt that occurs when the core has finished
1891 * processing a transfer on a channel. Other host channel interrupts (except
1892 * ahberr) are disabled in DMA mode.
1894 static int32_t handle_hc_chhltd_intr(dwc_otg_hcd_t *_hcd,
1896 dwc_otg_hc_regs_t *_hc_regs,
1897 dwc_otg_qtd_t *_qtd)
1899 DWC_DEBUGPL(DBG_HCD, "--Host Channel %d Interrupt: "
1900 "Channel Halted--\n", _hc->hc_num);
1902 if (_hcd->core_if->dma_enable) {
1903 handle_hc_chhltd_intr_dma(_hcd, _hc, _hc_regs, _qtd);
1906 if (!halt_status_ok(_hcd, _hc, _hc_regs, _qtd)) {
1910 release_channel(_hcd, _hc, _qtd, _hc->halt_status);
1916 /** Handles interrupt for a specific Host Channel */
1917 int32_t dwc_otg_hcd_handle_hc_n_intr (dwc_otg_hcd_t *_dwc_otg_hcd, uint32_t _num)
1921 hcintmsk_data_t hcintmsk;
1923 dwc_otg_hc_regs_t *hc_regs;
1926 DWC_DEBUGPL(DBG_HCDV, "--Host Channel Interrupt--, Channel %d\n", _num);
1928 hc = _dwc_otg_hcd->hc_ptr_array[_num];
1929 hc_regs = _dwc_otg_hcd->core_if->host_if->hc_regs[_num];
1930 qtd = list_entry(hc->qh->qtd_list.next, dwc_otg_qtd_t, qtd_list_entry);
1931 hcint.d32 = dwc_read_reg32(&hc_regs->hcint);
1932 hcintmsk.d32 = dwc_read_reg32(&hc_regs->hcintmsk);
1933 DWC_DEBUGPL(DBG_HCDV, " hcint 0x%08x, hcintmsk 0x%08x, hcint&hcintmsk 0x%08x\n",
1934 hcint.d32, hcintmsk.d32, (hcint.d32 & hcintmsk.d32));
1935 hcint.d32 = hcint.d32 & hcintmsk.d32;
1937 if (!_dwc_otg_hcd->core_if->dma_enable) {
1938 if ((hcint.b.chhltd) && (hcint.d32 != 0x2)) {
1943 if (hcint.b.chhltd) {
1944 retval |= handle_hc_chhltd_intr(_dwc_otg_hcd, hc, hc_regs, qtd);
1946 if (hcint.b.xfercomp) {
1947 retval |= handle_hc_xfercomp_intr(_dwc_otg_hcd, hc, hc_regs, qtd);
1949 * If NYET occurred at same time as Xfer Complete, the NYET is
1950 * handled by the Xfer Complete interrupt handler. Don't want
1951 * to call the NYET interrupt handler in this case.
1955 if (hcint.b.ahberr) {
1956 retval |= handle_hc_ahberr_intr(_dwc_otg_hcd, hc, hc_regs, qtd);
1958 if (hcint.b.stall) {
1959 retval |= handle_hc_stall_intr(_dwc_otg_hcd, hc, hc_regs, qtd);
1962 retval |= handle_hc_nak_intr(_dwc_otg_hcd, hc, hc_regs, qtd);
1966 retval |= handle_hc_ack_intr(_dwc_otg_hcd, hc, hc_regs, qtd);
1969 retval |= handle_hc_nyet_intr(_dwc_otg_hcd, hc, hc_regs, qtd);
1971 if (hcint.b.xacterr) {
1972 retval |= handle_hc_xacterr_intr(_dwc_otg_hcd, hc, hc_regs, qtd);
1974 if (hcint.b.bblerr) {
1975 retval |= handle_hc_babble_intr(_dwc_otg_hcd, hc, hc_regs, qtd);
1977 if (hcint.b.frmovrun) {
1978 retval |= handle_hc_frmovrun_intr(_dwc_otg_hcd, hc, hc_regs, qtd);
1980 if (hcint.b.datatglerr) {
1981 retval |= handle_hc_datatglerr_intr(_dwc_otg_hcd, hc, hc_regs, qtd);
1986 #endif /* DWC_DEVICE_ONLY */