1 /*****************************************************************************
2 ** FILE NAME : ifxhcd_intr.c
3 ** PROJECT : IFX USB sub-system V3
4 ** MODULES : IFX USB sub-system Host and Device driver
7 ** AUTHOR : Chen, Howard
8 ** DESCRIPTION : This file contains the implementation of the HCD Interrupt handlers.
9 *****************************************************************************/
13 \ingroup IFXUSB_DRIVER_V3
14 \brief This file contains the implementation of the HCD Interrupt handlers.
18 #include <linux/version.h>
19 #include "ifxusb_version.h"
21 #include "ifxusb_plat.h"
22 #include "ifxusb_regs.h"
23 #include "ifxusb_cif.h"
29 #error AVM/WK: CONFIG_USB_HOST_IFX_WITH_ISO currently not supported!
32 /* Macro used to clear one channel interrupt */
33 #define clear_hc_int(_hc_regs_,_intr_) \
35 hcint_data_t hcint_clear = {.d32 = 0}; \
36 hcint_clear.b._intr_ = 1; \
37 ifxusb_wreg(&((_hc_regs_)->hcint), hcint_clear.d32); \
41 * Macro used to disable one channel interrupt. Channel interrupts are
42 * disabled when the channel is halted or released by the interrupt handler.
43 * There is no need to handle further interrupts of that type until the
44 * channel is re-assigned. In fact, subsequent handling may cause crashes
45 * because the channel structures are cleaned up when the channel is released.
47 #define disable_hc_int(_hc_regs_,_intr_) \
49 hcint_data_t hcintmsk = {.d32 = 0}; \
50 hcintmsk.b._intr_ = 1; \
51 ifxusb_mreg(&((_hc_regs_)->hcintmsk), hcintmsk.d32, 0); \
54 #define enable_hc_int(_hc_regs_,_intr_) \
56 hcint_data_t hcintmsk = {.d32 = 0}; \
57 hcintmsk.b._intr_ = 1; \
58 ifxusb_mreg(&((_hc_regs_)->hcintmsk),0, hcintmsk.d32); \
62 * Save the starting data toggle for the next transfer. The data toggle is
63 * saved in the QH for non-control transfers and it's saved in the QTD for
66 uint8_t read_data_toggle(ifxusb_hc_regs_t
*_hc_regs
)
69 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
74 static void release_channel_dump(ifxhcd_hc_t
*ifxhc
,
78 ifxhcd_halt_status_e halt_status
)
84 case HC_XFER_NO_HALT_STATUS
:
85 printk("HC_XFER_NO_HALT_STATUS");break;
86 case HC_XFER_URB_COMPLETE
:
87 printk("HC_XFER_URB_COMPLETE");break;
89 printk("HC_XFER_AHB_ERR");break;
91 printk("HC_XFER_STALL");break;
92 case HC_XFER_BABBLE_ERR
:
93 printk("HC_XFER_BABBLE_ERR");break;
94 case HC_XFER_XACT_ERR
:
95 printk("HC_XFER_XACT_ERR");break;
96 case HC_XFER_URB_DEQUEUE
:
97 printk("HC_XFER_URB_DEQUEUE");break;
98 case HC_XFER_FRAME_OVERRUN
:
99 printk("HC_XFER_FRAME_OVERRUN");break;
100 case HC_XFER_DATA_TOGGLE_ERR
:
101 printk("HC_XFER_DATA_TOGGLE_ERR");break;
103 printk("HC_XFER_NAK");break;
104 case HC_XFER_COMPLETE
:
105 printk("HC_XFER_COMPLETE");break;
107 printk("KNOWN");break;
110 printk("Ch %d %s%s S%d " , ifxhc
->hc_num
111 ,(ifxhc
->ep_type
== IFXUSB_EP_TYPE_CTRL
)?"CTRL-":
112 ((ifxhc
->ep_type
== IFXUSB_EP_TYPE_BULK
)?"BULK-":
113 ((ifxhc
->ep_type
== IFXUSB_EP_TYPE_INTR
)?"INTR-":
114 ((ifxhc
->ep_type
== IFXUSB_EP_TYPE_ISOC
)?"ISOC-":"????"
118 ,(ifxhc
->is_in
)?"IN":"OUT"
122 printk(" [NULL HC] ");
123 printk("urb=%p epqh=%p urbd=%p\n",urb
,epqh
,urbd
);
127 printk(KERN_INFO
" Device address: %d\n", usb_pipedevice(urb
->pipe
));
128 printk(KERN_INFO
" Endpoint: %d, %s\n", usb_pipeendpoint(urb
->pipe
),
129 (usb_pipein(urb
->pipe
) ? "IN" : "OUT"));
130 printk(KERN_INFO
" Endpoint type: %s\n",
132 switch (usb_pipetype(urb
->pipe
)) {
133 case PIPE_CONTROL
: pipetype
= "CTRL"; break;
134 case PIPE_BULK
: pipetype
= "BULK"; break;
135 case PIPE_INTERRUPT
: pipetype
= "INTR"; break;
136 case PIPE_ISOCHRONOUS
: pipetype
= "ISOC"; break;
137 default: pipetype
= "????"; break;
139 printk(KERN_INFO
" Speed: %s\n",
141 switch (urb
->dev
->speed
) {
142 case USB_SPEED_HIGH
: speed
= "HS"; break;
143 case USB_SPEED_FULL
: speed
= "FS"; break;
144 case USB_SPEED_LOW
: speed
= "LS"; break;
145 default: speed
= "????"; break;
147 printk(KERN_INFO
" Max packet size: %d\n",
148 usb_maxpacket(urb
->dev
, urb
->pipe
, usb_pipeout(urb
->pipe
)));
149 printk(KERN_INFO
" Data buffer length: %d\n", urb
->transfer_buffer_length
);
150 printk(KERN_INFO
" Transfer buffer: %p, Transfer DMA: %p\n",
151 urb
->transfer_buffer
, (void *)urb
->transfer_dma
);
152 printk(KERN_INFO
" Setup buffer: %p, Setup DMA: %p\n",
153 urb
->setup_packet
, (void *)urb
->setup_dma
);
154 printk(KERN_INFO
" Interval: %d\n", urb
->interval
);
157 case HC_XFER_NO_HALT_STATUS
:
158 printk(KERN_INFO
" STATUS:HC_XFER_NO_HALT_STATUS\n");break;
159 case HC_XFER_URB_COMPLETE
:
160 printk(KERN_INFO
" STATUS:HC_XFER_URB_COMPLETE\n");break;
161 case HC_XFER_AHB_ERR
:
162 printk(KERN_INFO
" STATUS:HC_XFER_AHB_ERR\n");break;
164 printk(KERN_INFO
" STATUS:HC_XFER_STALL\n");break;
165 case HC_XFER_BABBLE_ERR
:
166 printk(KERN_INFO
" STATUS:HC_XFER_BABBLE_ERR\n");break;
167 case HC_XFER_XACT_ERR
:
168 printk(KERN_INFO
" STATUS:HC_XFER_XACT_ERR\n");break;
169 case HC_XFER_URB_DEQUEUE
:
170 printk(KERN_INFO
" STATUS:HC_XFER_URB_DEQUEUE\n");break;
171 case HC_XFER_FRAME_OVERRUN
:
172 printk(KERN_INFO
" STATUS:HC_XFER_FRAME_OVERRUN\n");break;
173 case HC_XFER_DATA_TOGGLE_ERR
:
174 printk(KERN_INFO
" STATUS:HC_XFER_DATA_TOGGLE_ERR\n");break;
175 case HC_XFER_COMPLETE
:
176 printk(KERN_INFO
" STATUS:HC_XFER_COMPLETE\n");break;
178 printk(KERN_INFO
" STATUS:KNOWN\n");break;
185 static void release_channel(ifxhcd_hcd_t
*_ifxhcd
,
187 ifxhcd_halt_status_e _halt_status
)
189 ifxusb_hc_regs_t
*hc_regs
= _ifxhcd
->core_if
.hc_regs
[_ifxhc
->hc_num
];
190 struct urb
*urb
= NULL
;
191 ifxhcd_epqh_t
*epqh
= NULL
;
192 ifxhcd_urbd_t
*urbd
= NULL
;
194 IFX_DEBUGPL(DBG_HCDV
, " %s: channel %d, halt_status %d\n",
195 __func__
, _ifxhc
->hc_num
, _halt_status
);
200 IFX_ERROR("%s epqh=null\n",__func__
);
205 IFX_ERROR("%s urbd=null\n",__func__
);
210 IFX_ERROR("%s urb =null\n",__func__
);
212 /* == AVM/WK 20100710 Fix - Use toggle of usbcore ==*/
213 unsigned toggle
= (read_data_toggle(hc_regs
) == IFXUSB_HC_PID_DATA0
)? 0: 1;
214 usb_settoggle (urb
->dev
, usb_pipeendpoint (urb
->pipe
), usb_pipeout(urb
->pipe
), toggle
);
217 //epqh->data_toggle = read_data_toggle(hc_regs);
221 switch (_halt_status
)
223 case HC_XFER_NO_HALT_STATUS
:
224 IFX_ERROR("%s: No halt_status, channel %d\n", __func__
, _ifxhc
->hc_num
);
226 case HC_XFER_COMPLETE
:
227 IFX_ERROR("%s: Inavalid halt_status HC_XFER_COMPLETE, channel %d\n", __func__
, _ifxhc
->hc_num
);
229 case HC_XFER_URB_COMPLETE
:
230 case HC_XFER_URB_DEQUEUE
:
231 case HC_XFER_AHB_ERR
:
232 case HC_XFER_XACT_ERR
:
233 case HC_XFER_FRAME_OVERRUN
:
235 /* == 20110803 AVM/WK FIX set status, if still in progress == */
236 if (urb
->status
== -EINPROGRESS
) {
237 switch (_halt_status
) {
238 case HC_XFER_URB_COMPLETE
:
241 case HC_XFER_URB_DEQUEUE
:
242 urb
->status
= -ECONNRESET
;
244 case HC_XFER_AHB_ERR
:
245 case HC_XFER_XACT_ERR
:
246 case HC_XFER_FRAME_OVERRUN
:
247 urb
->status
= -EPROTO
;
253 /*== AVM/BC 20101111 Deferred Complete ==*/
254 defer_ifxhcd_complete_urb(_ifxhcd
, urbd
, urb
->status
);
258 IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__
,__LINE__
,urbd
,urb
);
259 release_channel_dump(_ifxhc
,urb
,epqh
,urbd
,_halt_status
);
262 ifxhcd_epqh_idle(_ifxhcd
, epqh
);
265 IFX_WARN("WARNING %s():%d epqh=%p\n",__func__
,__LINE__
,epqh
);
266 release_channel_dump(_ifxhc
,urb
,epqh
,urbd
,_halt_status
);
269 list_add_tail(&_ifxhc
->hc_list_entry
, &_ifxhcd
->free_hc_list
);
270 ifxhcd_hc_cleanup(&_ifxhcd
->core_if
, _ifxhc
);
273 release_channel_dump(_ifxhc
,urb
,epqh
,urbd
,_halt_status
);
275 /*== AVM/BC 20101111 Deferred Complete ==*/
276 defer_ifxhcd_complete_urb(_ifxhcd
, urbd
, -EPIPE
);
278 IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__
,__LINE__
,urbd
,urb
);
281 // epqh->data_toggle = 0;
282 ifxhcd_epqh_idle(_ifxhcd
, epqh
);
285 IFX_WARN("WARNING %s():%d epqh=%p\n",__func__
,__LINE__
,epqh
);
286 list_add_tail(&_ifxhc
->hc_list_entry
, &_ifxhcd
->free_hc_list
);
287 ifxhcd_hc_cleanup(&_ifxhcd
->core_if
, _ifxhc
);
290 release_channel_dump(_ifxhc
,urb
,epqh
,urbd
,_halt_status
);
293 //ifxhcd_complete_urb(_ifxhcd, urbd, -ETIMEDOUT);
295 /*== AVM/BC 20101111 Deferred Complete ==*/
296 defer_ifxhcd_complete_urb(_ifxhcd
, urbd
, urb
->status
);
299 IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__
,__LINE__
,urbd
,urb
);
301 ifxhcd_epqh_idle(_ifxhcd
, epqh
);
303 IFX_WARN("WARNING %s():%d epqh=%p\n",__func__
,__LINE__
,epqh
);
304 list_add_tail(&_ifxhc
->hc_list_entry
, &_ifxhcd
->free_hc_list
);
305 ifxhcd_hc_cleanup(&_ifxhcd
->core_if
, _ifxhc
);
307 case HC_XFER_BABBLE_ERR
:
308 case HC_XFER_DATA_TOGGLE_ERR
:
309 release_channel_dump(_ifxhc
,urb
,epqh
,urbd
,_halt_status
);
311 /*== AVM/BC 20101111 Deferred Complete ==*/
312 defer_ifxhcd_complete_urb(_ifxhcd
, urbd
, -EOVERFLOW
);
314 IFX_WARN("WARNING %s():%d urbd=%p urb=%p\n",__func__
,__LINE__
,urbd
,urb
);
316 ifxhcd_epqh_idle(_ifxhcd
, epqh
);
318 IFX_WARN("WARNING %s():%d epqh=%p\n",__func__
,__LINE__
,epqh
);
319 list_add_tail(&_ifxhc
->hc_list_entry
, &_ifxhcd
->free_hc_list
);
320 ifxhcd_hc_cleanup(&_ifxhcd
->core_if
, _ifxhc
);
327 * Updates the state of the URB after a Transfer Complete interrupt on the
328 * host channel. Updates the actual_length field of the URB based on the
329 * number of bytes transferred via the host channel. Sets the URB status
330 * if the data transfer is finished.
332 * @return 1 if the data transfer specified by the URB is completely finished,
335 static int update_urb_state_xfer_comp(ifxhcd_hc_t
*_ifxhc
,
336 ifxusb_hc_regs_t
*_hc_regs
,
338 ifxhcd_urbd_t
*_urbd
)
344 hctsiz_data_t hctsiz
;
345 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
346 _urb
->actual_length
+= (_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
);
347 if ((hctsiz
.b
.xfersize
!= 0) || (_urb
->actual_length
>= _urb
->transfer_buffer_length
))
351 /* 20110805 AVM/WK Workaround: catch overflow error here, hardware does not */
352 if (_urb
->actual_length
> _urb
->transfer_buffer_length
) {
353 _urb
->status
= -EOVERFLOW
;
356 if (_urb
->actual_length
< _urb
->transfer_buffer_length
&& _urb
->transfer_flags
& URB_SHORT_NOT_OK
)
357 _urb
->status
= -EREMOTEIO
;
365 _urb
->actual_length
+= _ifxhc
->ssplit_out_xfer_count
;
367 _urb
->actual_length
+= _ifxhc
->xfer_len
;
369 if (_urb
->actual_length
>= _urb
->transfer_buffer_length
)
371 /*== AVM/BC WK 20110421 ZERO PACKET Workaround ==*/
372 if ((_ifxhc
->short_rw
== 1) && ( _ifxhc
->xfer_len
> 0) && ( _ifxhc
->xfer_len
% _ifxhc
->mps
== 0 ))
374 _ifxhc
->short_rw
= 0;
375 //Transfer not finished. Another iteration for ZLP.
387 hctsiz_data_t hctsiz
;
388 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
389 IFX_DEBUGPL(DBG_HCDV
, "IFXUSB: %s: %s, channel %d\n",
390 __func__
, (_ifxhc
->is_in
? "IN" : "OUT"), _ifxhc
->hc_num
);
391 IFX_DEBUGPL(DBG_HCDV
, " hc->xfer_len %d\n", _ifxhc
->xfer_len
);
392 IFX_DEBUGPL(DBG_HCDV
, " hctsiz.xfersize %d\n", hctsiz
.b
.xfersize
);
393 IFX_DEBUGPL(DBG_HCDV
, " urb->transfer_buffer_length %d\n",
394 _urb
->transfer_buffer_length
);
395 IFX_DEBUGPL(DBG_HCDV
, " urb->actual_length %d\n", _urb
->actual_length
);
401 /*== AVM/BC 20101111 Function called with Lock ==*/
403 void complete_channel(ifxhcd_hcd_t
*_ifxhcd
,
405 ifxhcd_urbd_t
*_urbd
)
407 ifxusb_hc_regs_t
*hc_regs
= _ifxhcd
->core_if
.hc_regs
[_ifxhc
->hc_num
];
408 struct urb
*urb
= NULL
;
409 ifxhcd_epqh_t
*epqh
= NULL
;
412 IFX_DEBUGPL(DBG_HCD
, "--Complete Channel %d : \n", _ifxhc
->hc_num
);
416 IFX_ERROR("ERROR %s():%d urbd=%p\n",__func__
,__LINE__
,_urbd
);
425 IFX_ERROR("ERROR %s():%d urb=%p epqh=%p\n",__func__
,__LINE__
,urb
,epqh
);
434 switch (epqh
->ep_type
)
436 case IFXUSB_EP_TYPE_CTRL
:
437 switch (_ifxhc
->control_phase
)
439 case IFXHCD_CONTROL_SETUP
:
440 IFX_DEBUGPL(DBG_HCDV
, " Control setup transaction done\n");
441 if (_urbd
->xfer_len
> 0)
443 _ifxhc
->control_phase
= IFXHCD_CONTROL_DATA
;
444 _ifxhc
->is_in
= _urbd
->is_in
;
445 _ifxhc
->xfer_len
= _urbd
->xfer_len
;
446 #if defined(__UNALIGNED_BUFFER_ADJ__)
447 if(epqh
->using_aligned_buf
)
448 _ifxhc
->xfer_buff
= epqh
->aligned_buf
;
451 _ifxhc
->xfer_buff
= _urbd
->xfer_buff
;
455 _ifxhc
->control_phase
= IFXHCD_CONTROL_STATUS
;
457 _ifxhc
->xfer_len
= 0;
458 _ifxhc
->xfer_buff
= _ifxhcd
->status_buf
;
463 _ifxhc
->short_rw
=(urb
->transfer_flags
& URB_ZERO_PACKET
)?1:0;
464 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA1
;
465 _ifxhc
->xfer_count
= 0;
466 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
467 /*== AVM/BC 20101111 Lock not needed ==*/
468 process_channels_sub(_ifxhcd
);
470 case IFXHCD_CONTROL_DATA
:
471 urb_xfer_done
= update_urb_state_xfer_comp(_ifxhc
, hc_regs
, urb
, _urbd
);
474 _ifxhc
->control_phase
= IFXHCD_CONTROL_STATUS
;
475 _ifxhc
->is_in
= (_urbd
->is_in
)?0:1;
476 _ifxhc
->xfer_len
= 0;
477 _ifxhc
->xfer_count
= 0;
478 _ifxhc
->xfer_buff
= _ifxhcd
->status_buf
;
479 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
480 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA1
;
488 _ifxhc
->xfer_len
= _urbd
->xfer_len
- urb
->actual_length
;
489 _ifxhc
->xfer_count
= urb
->actual_length
;
490 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
491 _ifxhc
->data_pid_start
= read_data_toggle(hc_regs
);
493 /*== AVM/BC 20101111 Lock not needed ==*/
494 process_channels_sub(_ifxhcd
);
496 case IFXHCD_CONTROL_STATUS
:
497 if (urb
->status
== -EINPROGRESS
)
499 release_channel(_ifxhcd
,_ifxhc
,HC_XFER_URB_COMPLETE
);
503 case IFXUSB_EP_TYPE_BULK
:
504 IFX_DEBUGPL(DBG_HCDV
, " Bulk transfer complete\n");
505 urb_xfer_done
= update_urb_state_xfer_comp(_ifxhc
, hc_regs
, urb
, _urbd
);
507 release_channel(_ifxhcd
,_ifxhc
,HC_XFER_URB_COMPLETE
);
510 _ifxhc
->xfer_len
= _urbd
->xfer_len
- urb
->actual_length
;
511 _ifxhc
->xfer_count
= urb
->actual_length
;
512 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
513 _ifxhc
->data_pid_start
= read_data_toggle(hc_regs
);
514 /*== AVM/BC 20101111 Lock not needed ==*/
515 process_channels_sub(_ifxhcd
);
518 case IFXUSB_EP_TYPE_INTR
:
519 urb_xfer_done
= update_urb_state_xfer_comp(_ifxhc
, hc_regs
, urb
, _urbd
);
520 release_channel(_ifxhcd
,_ifxhc
,HC_XFER_URB_COMPLETE
);
522 case IFXUSB_EP_TYPE_ISOC
:
523 // if (_urbd->isoc_split_pos == IFXUSB_HCSPLIT_XACTPOS_ALL)
524 // halt_status = update_isoc_urb_state(_ifxhcd, _ifxhc, hc_regs, _urbd, HC_XFER_COMPLETE);
525 // complete_periodic_xfer(_ifxhcd, _ifxhc, hc_regs, _urbd, halt_status);
526 urb_xfer_done
= update_urb_state_xfer_comp(_ifxhc
, hc_regs
, urb
, _urbd
);
527 release_channel(_ifxhcd
,_ifxhc
,HC_XFER_URB_COMPLETE
);
534 void showint(uint32_t val_hcint
535 ,uint32_t val_hcintmsk
536 ,uint32_t val_hctsiz
)
539 hcint_data_t hcint
= {.d32
= val_hcint
};
540 hcint_data_t hcintmsk
= {.d32
= val_hcintmsk
};
542 printk(KERN_INFO
" WITH FLAG: Sz:%08x I:%08X/M:%08X %s%s%s%s%s%s%s%s%s%s\n"
543 ,val_hctsiz
,hcint
.d32
,hcintmsk
.d32
544 ,(hcint
.b
.datatglerr
|| hcintmsk
.b
.datatglerr
)?
546 (hcint
.b
.datatglerr
&& hcintmsk
.b
.datatglerr
)?"datatglerr[*/*] ":
548 (hcint
.b
.datatglerr
)?"datatglerr[*/] ":"datatglerr[/*] "
552 ,(hcint
.b
.frmovrun
|| hcintmsk
.b
.frmovrun
)?
554 (hcint
.b
.frmovrun
&& hcintmsk
.b
.frmovrun
)?"frmovrun[*/*] ":
556 (hcint
.b
.frmovrun
)?"frmovrun[*/] ":"frmovrun[/*] "
560 ,(hcint
.b
.bblerr
|| hcintmsk
.b
.bblerr
)?
562 (hcint
.b
.bblerr
&& hcintmsk
.b
.bblerr
)?"bblerr[*/*] ":
564 (hcint
.b
.bblerr
)?"bblerr[*/] ":"bblerr[/*] "
568 ,(hcint
.b
.xacterr
|| hcintmsk
.b
.xacterr
)?
570 (hcint
.b
.xacterr
&& hcintmsk
.b
.xacterr
)?"xacterr[*/*] ":
572 (hcint
.b
.xacterr
)?"xacterr[*/] ":"xacterr[/*] "
576 ,(hcint
.b
.nyet
|| hcintmsk
.b
.nyet
)?
578 (hcint
.b
.nyet
&& hcintmsk
.b
.nyet
)?"nyet[*/*] ":
580 (hcint
.b
.nyet
)?"nyet[*/] ":"nyet[/*] "
584 ,(hcint
.b
.nak
|| hcintmsk
.b
.nak
)?
586 (hcint
.b
.nak
&& hcintmsk
.b
.nak
)?"nak[*/*] ":
588 (hcint
.b
.nak
)?"nak[*/] ":"nak[/*] "
592 ,(hcint
.b
.ack
|| hcintmsk
.b
.ack
)?
594 (hcint
.b
.ack
&& hcintmsk
.b
.ack
)?"ack[*/*] ":
596 (hcint
.b
.ack
)?"ack[*/] ":"ack[/*] "
600 ,(hcint
.b
.stall
|| hcintmsk
.b
.stall
)?
602 (hcint
.b
.stall
&& hcintmsk
.b
.stall
)?"stall[*/*] ":
604 (hcint
.b
.stall
)?"stall[*/] ":"stall[/*] "
608 ,(hcint
.b
.ahberr
|| hcintmsk
.b
.ahberr
)?
610 (hcint
.b
.ahberr
&& hcintmsk
.b
.ahberr
)?"ahberr[*/*] ":
612 (hcint
.b
.ahberr
)?"ahberr[*/] ":"ahberr[/*] "
616 ,(hcint
.b
.xfercomp
|| hcintmsk
.b
.xfercomp
)?
618 (hcint
.b
.xfercomp
&& hcintmsk
.b
.xfercomp
)?"xfercomp[*/*] ":
620 (hcint
.b
.xfercomp
)?"xfercomp[*/] ":"xfercomp[/*] "
629 extern void ifxhcd_hc_dumb_rx(ifxusb_core_if_t
*_core_if
, ifxhcd_hc_t
*_ifxhc
,uint8_t *dump_buf
);
631 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
632 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
633 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
634 static int32_t chhltd_ctrlbulk_rx_nonsplit(ifxhcd_hcd_t
*_ifxhcd
,
636 ifxusb_hc_regs_t
*_hc_regs
,
637 ifxhcd_urbd_t
*_urbd
)
640 hcint_data_t hcintmsk
;
641 hctsiz_data_t hctsiz
;
643 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
644 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
645 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
647 disable_hc_int(_hc_regs
,ack
);
648 disable_hc_int(_hc_regs
,nak
);
649 disable_hc_int(_hc_regs
,nyet
);
652 if(_ifxhc
->halt_status
== HC_XFER_NAK
)
654 if(_ifxhc
->nak_retry_r
)
656 _urbd
->urb
->actual_length
+= (_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
);
658 if(_ifxhc
->nak_retry
)
660 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
661 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
662 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
663 _ifxhc
->wait_for_sof
= 1;
664 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
665 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
669 _ifxhc
->wait_for_sof
= 0;
670 release_channel(_ifxhcd
, _ifxhc
, _ifxhc
->halt_status
);
675 _urbd
->urb
->actual_length
+= (_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
);
676 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
677 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
678 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
679 _ifxhc
->wait_for_sof
= 1;
680 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
681 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
686 if (hcint
.b
.xfercomp
)
688 _urbd
->error_count
=0;
689 _ifxhc
->wait_for_sof
=0;
690 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
693 else if (hcint
.b
.stall
)
695 _urbd
->error_count
=0;
696 _ifxhc
->wait_for_sof
=0;
699 if(hctsiz
.b
.pktcnt
==0)
700 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
704 // Stall FIFO compensation.
707 sz2
=_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
;
709 sz1
=_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
;
712 ifxhcd_hc_dumb_rx(&_ifxhcd
->core_if
, _ifxhc
,_ifxhc
->epqh
->dump_buf
);
714 _urbd
->urb
->actual_length
+= (_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
);
715 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
719 else if (hcint
.b
.bblerr
)
721 _urbd
->error_count
=0;
722 _ifxhc
->wait_for_sof
=0;
726 if(hctsiz
.b
.pktcnt
==0)
727 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
730 _urbd
->urb
->actual_length
+= (_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
);
731 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
734 else if (hcint
.b
.xacterr
)
738 if(hctsiz
.b
.pktcnt
==0)
740 _urbd
->error_count
=0;
741 _ifxhc
->wait_for_sof
=0;
742 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
747 _urbd
->urb
->actual_length
+= (_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
);
748 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
749 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
750 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
752 /* 20110803 AVM/WK FIX: Reset error count on any handshake */
753 if (hcint
.b
.nak
|| hcint
.b
.nyet
|| hcint
.b
.ack
) {
754 _urbd
->error_count
= 1;
756 _urbd
->error_count
++;
759 if (_urbd
->error_count
>= 3)
761 _urbd
->error_count
=0;
762 _ifxhc
->wait_for_sof
=0;
763 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
767 _ifxhc
->wait_for_sof
= 1;
768 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
773 else if(hcint
.b
.datatglerr
)
775 _urbd
->urb
->actual_length
+= (_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
);
777 if(_ifxhc
->data_pid_start
== IFXUSB_HC_PID_DATA0
)
778 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA1
;
780 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA0
;
781 _ifxhc
->wait_for_sof
= 1;
782 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
783 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
784 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
786 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_DATA_TOGGLE_ERR
);
790 else if(hcint
.b
.frmovrun
)
792 IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT0 FRMOVRUN [should be Period only]\n",__func__
,__LINE__
);
793 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
794 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_FRAME_OVERRUN
);
797 else if(hcint
.b
.nyet
)
799 IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT0 NYET [should be Out only]\n",__func__
,__LINE__
);
800 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
804 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
805 static int32_t chhltd_ctrlbulk_tx_nonsplit(ifxhcd_hcd_t
*_ifxhcd
,
807 ifxusb_hc_regs_t
*_hc_regs
,
808 ifxhcd_urbd_t
*_urbd
)
811 hcint_data_t hcintmsk
;
812 hctsiz_data_t hctsiz
;
819 if (_ifxhcd
->core_if
.snpsid
>= 0x4f54271a && _ifxhc
->speed
== IFXUSB_EP_SPEED_HIGH
)
822 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
823 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
824 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
827 if(!first
&& _ifxhc
->ep_type
== IFXUSB_EP_TYPE_BULK
828 &&(hcint
.b
.stall
|| hcint
.b
.datatglerr
|| hcint
.b
.frmovrun
|| hcint
.b
.bblerr
|| hcint
.b
.xacterr
) && !hcint
.b
.ack
)
830 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
832 printk(KERN_INFO
" [%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X] \n"
833 ,*(_ifxhc
->xfer_buff
+ 0),*(_ifxhc
->xfer_buff
+ 1),*(_ifxhc
->xfer_buff
+ 2),*(_ifxhc
->xfer_buff
+ 3)
834 ,*(_ifxhc
->xfer_buff
+ 4),*(_ifxhc
->xfer_buff
+ 5),*(_ifxhc
->xfer_buff
+ 6),*(_ifxhc
->xfer_buff
+ 7)
835 ,*(_ifxhc
->xfer_buff
+ 8),*(_ifxhc
->xfer_buff
+ 9),*(_ifxhc
->xfer_buff
+10),*(_ifxhc
->xfer_buff
+11)
836 ,*(_ifxhc
->xfer_buff
+12),*(_ifxhc
->xfer_buff
+13),*(_ifxhc
->xfer_buff
+14),*(_ifxhc
->xfer_buff
+15));
838 printk(KERN_INFO
" [_urbd->urb->actual_length:%08X _ifxhc->start_pkt_count:%08X hctsiz.b.pktcnt:%08X ,_urbd->xfer_len:%08x] \n"
839 ,_urbd
->urb
->actual_length
840 ,_ifxhc
->start_pkt_count
846 if(_ifxhc
->halt_status
== HC_XFER_NAK
)
848 if(_ifxhc
->nak_retry_r
)
851 if(_ifxhc
->nak_retry
)
853 if(_ifxhc
->xfer_len
!=0)
854 _urbd
->urb
->actual_length
+= ((_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
) * _ifxhc
->mps
);
855 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
856 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
857 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
858 _ifxhc
->wait_for_sof
= 1;
859 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
860 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
864 _ifxhc
->wait_for_sof
= 0;
865 release_channel(_ifxhcd
, _ifxhc
, _ifxhc
->halt_status
);
870 if(_ifxhc
->xfer_len
!=0)
871 _urbd
->urb
->actual_length
+= ((_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
) * _ifxhc
->mps
);
872 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
873 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
874 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
875 _ifxhc
->wait_for_sof
= 1;
876 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
877 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
882 if (hcint
.b
.xfercomp
)
884 disable_hc_int(_hc_regs
,ack
);
885 disable_hc_int(_hc_regs
,nak
);
886 disable_hc_int(_hc_regs
,nyet
);
887 _urbd
->error_count
=0;
888 if(_ifxhc
->xfer_len
==0 && !hcint
.b
.ack
&& hcint
.b
.nak
)
890 // Walkaround: When sending ZLP and receive NAK but also issue CMPT intr
891 // Solution: NoSplit: Resend at next SOF
892 // Split : Resend at next SOF with SSPLIT
893 if(hcint
.b
.nyet
&& !out_nak_enh
)
897 _ifxhc
->xfer_len
= 0;
898 _ifxhc
->xfer_count
= 0;
899 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
900 _ifxhc
->wait_for_sof
= 1;
901 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
905 _ifxhc
->wait_for_sof
= 0;
907 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
911 else if (hcint
.b
.stall
)
913 disable_hc_int(_hc_regs
,ack
);
914 disable_hc_int(_hc_regs
,nak
);
915 disable_hc_int(_hc_regs
,nyet
);
916 _urbd
->error_count
=0;
917 _ifxhc
->wait_for_sof
=0;
922 if(hctsiz
.b
.pktcnt
==0)
923 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
927 if(_ifxhc
->xfer_len
!=0)
928 _urbd
->urb
->actual_length
+= ((_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
) * _ifxhc
->mps
);
929 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
933 else if (hcint
.b
.xacterr
)
937 if(hctsiz
.b
.pktcnt
==0)
939 disable_hc_int(_hc_regs
,ack
);
940 disable_hc_int(_hc_regs
,nak
);
941 disable_hc_int(_hc_regs
,nyet
);
942 _urbd
->error_count
=0;
943 _ifxhc
->wait_for_sof
=0;
945 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
950 if(_ifxhc
->xfer_len
!=0)
951 _urbd
->urb
->actual_length
+= ((_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
) * _ifxhc
->mps
);
952 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
953 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
954 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
956 if (hcint
.b
.nak
|| hcint
.b
.nyet
|| hcint
.b
.ack
)
958 _urbd
->error_count
=0;
959 _ifxhc
->wait_for_sof
=1;
960 enable_hc_int(_hc_regs
,ack
);
961 enable_hc_int(_hc_regs
,nak
);
962 enable_hc_int(_hc_regs
,nyet
);
967 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
971 _urbd
->error_count
++ ;
972 if (_urbd
->error_count
== 3)
974 disable_hc_int(_hc_regs
,ack
);
975 disable_hc_int(_hc_regs
,nak
);
976 disable_hc_int(_hc_regs
,nyet
);
977 _urbd
->error_count
=0;
978 _ifxhc
->wait_for_sof
=0;
980 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
984 enable_hc_int(_hc_regs
,ack
);
985 enable_hc_int(_hc_regs
,nak
);
986 enable_hc_int(_hc_regs
,nyet
);
987 _ifxhc
->wait_for_sof
=1;
992 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
998 else if(hcint
.b
.bblerr
)
1000 IFX_WARN("%s() %d Warning CTRLBULK OUT SPLIT0 BABBLE [should be IN only]\n",__func__
,__LINE__
);
1001 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1002 _ifxhc
->do_ping
= 0;
1003 if(_ifxhc
->xfer_len
!=0)
1004 _urbd
->urb
->actual_length
+= ((_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
) * _ifxhc
->mps
);
1005 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
1008 else if(hcint
.b
.nak
|| hcint
.b
.nyet
)
1014 if(hctsiz
.b
.pktcnt
==0)
1016 _urbd
->error_count
=0;
1017 _ifxhc
->wait_for_sof
=0;
1019 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1028 if(_ifxhc
->xfer_len
!=0)
1030 _urbd
->urb
->actual_length
+= ((_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
) * _ifxhc
->mps
);
1031 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
1032 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
1034 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
1035 _ifxhc
->wait_for_sof
= 1;
1036 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1041 else if(hcint
.b
.datatglerr
)
1043 IFX_WARN("%s() %d Warning CTRLBULK OUT SPLIT0 DATATGLERR [should be IN only]\n",__func__
,__LINE__
);
1044 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1045 _urbd
->error_count
=0;
1046 _ifxhc
->wait_for_sof
=0;
1048 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_DATA_TOGGLE_ERR
);
1051 else if(hcint
.b
.frmovrun
)
1053 IFX_WARN("%s() %d Warning CTRLBULK OUT SPLIT0 FRMOVRUN [should be PERIODIC only]\n",__func__
,__LINE__
);
1054 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1055 _urbd
->error_count
=0;
1056 _ifxhc
->wait_for_sof
=0;
1058 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_FRAME_OVERRUN
);
1063 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1064 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1065 static int32_t chhltd_intr_rx_nonsplit(ifxhcd_hcd_t
*_ifxhcd
,
1066 ifxhcd_hc_t
*_ifxhc
,
1067 ifxusb_hc_regs_t
*_hc_regs
,
1068 ifxhcd_urbd_t
*_urbd
)
1071 hcint_data_t hcintmsk
;
1072 hctsiz_data_t hctsiz
;
1074 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
1075 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
1076 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
1077 disable_hc_int(_hc_regs
,ack
);
1078 disable_hc_int(_hc_regs
,nak
);
1079 disable_hc_int(_hc_regs
,nyet
);
1082 if(_ifxhc
->halt_status
== HC_XFER_NAK
)
1084 if(_ifxhc
->nak_retry_r
)
1086 _ifxhc
->nak_retry
--;
1087 if(_ifxhc
->nak_retry
)
1089 if(_ifxhc
->xfer_len
!=0)
1090 _urbd
->urb
->actual_length
+= ((_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
) * _ifxhc
->mps
);
1091 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
1092 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
1093 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
1094 _ifxhc
->wait_for_sof
= 1;
1095 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
1096 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1100 _ifxhc
->wait_for_sof
= 0;
1101 release_channel(_ifxhcd
, _ifxhc
, _ifxhc
->halt_status
);
1106 if(_ifxhc
->xfer_len
!=0)
1107 _urbd
->urb
->actual_length
+= ((_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
) * _ifxhc
->mps
);
1108 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
1109 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
1110 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
1111 _ifxhc
->wait_for_sof
= 1;
1112 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
1113 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1118 if(hcint
.b
.xfercomp
)
1120 _urbd
->error_count
=0;
1121 //restart INTR immediately
1123 if(hctsiz
.b
.pktcnt
>0)
1125 // TODO Re-initialize Channel (in next b_interval - 1 uF/F)
1126 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
1127 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
1128 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1133 _ifxhc
->wait_for_sof
=0;
1134 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1138 else if (hcint
.b
.stall
)
1140 _urbd
->error_count
=0;
1141 _ifxhc
->wait_for_sof
=0;
1143 // Don't care shortcut
1145 if(hctsiz
.b
.pktcnt
==0)
1146 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1150 // Stall FIFO compensation.
1153 sz2
=_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
;
1155 sz1
=_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
;
1158 ifxhcd_hc_dumb_rx(&_ifxhcd
->core_if
, _ifxhc
,_ifxhc
->epqh
->dump_buf
);
1160 _urbd
->urb
->actual_length
+= (_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
);
1161 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
1167 else if (hcint
.b
.bblerr
)
1169 _urbd
->error_count
=0;
1170 _ifxhc
->wait_for_sof
=0;
1172 // Don't care shortcut
1174 if(hctsiz
.b
.pktcnt
==0)
1175 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1179 _urbd
->urb
->actual_length
+= (_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
);
1180 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
1184 else if (hcint
.b
.nak
|| hcint
.b
.datatglerr
|| hcint
.b
.frmovrun
)
1186 _urbd
->error_count
=0;
1187 //restart INTR immediately
1189 if(hctsiz
.b
.pktcnt
>0)
1191 // TODO Re-initialize Channel (in next b_interval - 1 uF/F)
1192 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
1193 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
1194 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1199 _ifxhc
->wait_for_sof
=0;
1200 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1204 else if (hcint
.b
.xacterr
)
1208 if(hctsiz
.b
.pktcnt
==0)
1210 _urbd
->error_count
=0;
1211 _ifxhc
->wait_for_sof
=0;
1212 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1217 /* 20110803 AVM/WK FIX: Reset error count on any handshake */
1218 if (hcint
.b
.nak
|| hcint
.b
.nyet
|| hcint
.b
.ack
) {
1219 _urbd
->error_count
= 1;
1221 _urbd
->error_count
++;
1224 if(_urbd
->error_count
>=3)
1226 _urbd
->error_count
=0;
1227 _ifxhc
->wait_for_sof
=0;
1228 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
1232 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
1233 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1238 else if(hcint
.b
.nyet
)
1240 IFX_WARN("%s() %d Warning INTR IN SPLIT0 NYET [should be OUT only]\n",__func__
,__LINE__
);
1241 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1246 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1247 static int32_t chhltd_intr_tx_nonsplit(ifxhcd_hcd_t
*_ifxhcd
,
1248 ifxhcd_hc_t
*_ifxhc
,
1249 ifxusb_hc_regs_t
*_hc_regs
,
1250 ifxhcd_urbd_t
*_urbd
)
1253 hcint_data_t hcintmsk
;
1254 hctsiz_data_t hctsiz
;
1255 int out_nak_enh
= 0;
1257 if (_ifxhcd
->core_if
.snpsid
>= 0x4f54271a && _ifxhc
->speed
== IFXUSB_EP_SPEED_HIGH
)
1260 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
1261 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
1262 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
1264 if(_ifxhc
->halt_status
== HC_XFER_NAK
)
1266 if(_ifxhc
->nak_retry_r
)
1268 _ifxhc
->nak_retry
--;
1269 if(_ifxhc
->nak_retry
)
1271 if(_ifxhc
->xfer_len
!=0)
1272 _urbd
->urb
->actual_length
+= ((_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
) * _ifxhc
->mps
);
1273 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
1274 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
1275 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
1276 _ifxhc
->wait_for_sof
= 1;
1277 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
1278 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1282 _ifxhc
->wait_for_sof
= 0;
1283 release_channel(_ifxhcd
, _ifxhc
, _ifxhc
->halt_status
);
1288 if(_ifxhc
->xfer_len
!=0)
1289 _urbd
->urb
->actual_length
+= ((_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
) * _ifxhc
->mps
);
1290 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
1291 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
1292 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
1293 _ifxhc
->wait_for_sof
= 1;
1294 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
1295 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1300 if(hcint
.b
.xfercomp
)
1302 disable_hc_int(_hc_regs
,ack
);
1303 disable_hc_int(_hc_regs
,nak
);
1304 disable_hc_int(_hc_regs
,nyet
);
1305 _urbd
->error_count
=0;
1306 //restart INTR immediately
1308 if(hctsiz
.b
.pktcnt
>0)
1310 // TODO Re-initialize Channel (in next b_interval - 1 uF/F)
1311 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
1312 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
1313 if(hcint
.b
.nyet
&& !out_nak_enh
)
1317 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1322 _ifxhc
->wait_for_sof
=0;
1324 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1328 else if (hcint
.b
.stall
)
1330 disable_hc_int(_hc_regs
,ack
);
1331 disable_hc_int(_hc_regs
,nyet
);
1332 disable_hc_int(_hc_regs
,nak
);
1333 _urbd
->error_count
=0;
1334 _ifxhc
->wait_for_sof
=0;
1337 // Don't care shortcut
1339 if(hctsiz
.b
.pktcnt
==0)
1340 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1344 if(_ifxhc
->xfer_len
!=0)// !_ifxhc->is_in
1345 _urbd
->urb
->actual_length
+= ((_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
) * _ifxhc
->mps
);
1346 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
1350 else if(hcint
.b
.nak
|| hcint
.b
.frmovrun
)
1352 disable_hc_int(_hc_regs
,ack
);
1353 disable_hc_int(_hc_regs
,nyet
);
1354 disable_hc_int(_hc_regs
,nak
);
1355 _urbd
->error_count
=0;
1356 //restart INTR immediately
1358 if(hctsiz
.b
.pktcnt
>0)
1360 // TODO Re-initialize Channel (in next b_interval - 1 uF/F)
1361 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
1362 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
1367 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1372 _ifxhc
->wait_for_sof
=0;
1374 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1378 else if(hcint
.b
.xacterr
)
1382 if(hctsiz
.b
.pktcnt
==0)
1384 _urbd
->error_count
=0;
1385 _ifxhc
->wait_for_sof
=0;
1387 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1392 /* 20110803 AVM/WK FIX: Reset error count on any handshake */
1393 if (hcint
.b
.nak
|| hcint
.b
.nyet
|| hcint
.b
.ack
) {
1394 _urbd
->error_count
= 1;
1396 _urbd
->error_count
++;
1399 if(_urbd
->error_count
>=3)
1401 _urbd
->error_count
=0;
1402 _ifxhc
->wait_for_sof
=0;
1404 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
1408 //_ifxhc->wait_for_sof = _ifxhc->epqh->interval-1;
1409 //if(!_ifxhc->wait_for_sof) _ifxhc->wait_for_sof=1;
1410 _ifxhc
->wait_for_sof
=1;
1416 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1421 else if(hcint
.b
.bblerr
)
1423 IFX_WARN("%s() %d Warning INTR OUT SPLIT0 BABBLEERR [should be IN only]\n",__func__
,__LINE__
);
1424 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1425 _urbd
->error_count
=0;
1426 _ifxhc
->wait_for_sof
=0;
1428 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
1431 else if(hcint
.b
.datatglerr
)
1433 IFX_WARN("%s() %d Warning INTR OUT SPLIT0 DATATGLERR\n",__func__
,__LINE__
);
1434 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1435 _urbd
->error_count
=0;
1436 _ifxhc
->wait_for_sof
=0;
1438 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_DATA_TOGGLE_ERR
);
1443 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1444 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1445 static int32_t chhltd_isoc_rx_nonsplit(ifxhcd_hcd_t
*_ifxhcd
,
1446 ifxhcd_hc_t
*_ifxhc
,
1447 ifxusb_hc_regs_t
*_hc_regs
,
1448 ifxhcd_urbd_t
*_urbd
)
1450 #if defined(__EN_ISOC__)
1452 hcint_data_t hcintmsk
;
1453 hctsiz_data_t hctsiz
;
1455 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
1456 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
1457 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
1459 if (hcint
.b
.xfercomp
|| hcint
.b
.frmovrun
)
1461 _urbd
->error_count
=0;
1462 disable_hc_int(_hc_regs
,ack
);
1463 disable_hc_int(_hc_regs
,nak
);
1464 disable_hc_int(_hc_regs
,nyet
);
1465 _ifxhc
->wait_for_sof
= 0;
1466 if (hcint
.b
.xfercomp
)
1467 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1469 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_FRAME_OVERRUN
);
1471 else if (hcint
.b
.xacterr
|| hcint
.b
.bblerr
)
1474 if(hctsiz
.b
.pktcnt
==0)
1476 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1481 sz2
=_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
;
1483 sz1
=_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
;
1486 ifxhcd_hc_dumb_rx(&_ifxhcd
->core_if
, _ifxhc
,_ifxhc
->epqh
->dump_buf
);
1487 _urbd
->urb
->actual_length
+= (_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
);
1488 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
1489 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
1490 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
1491 _urbd
->error_count
++;
1492 if(_urbd
->error_count
>=3)
1494 _urbd
->error_count
=0;
1495 _ifxhc
->wait_for_sof
= 0;
1496 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
1497 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
1501 _ifxhc
->wait_for_sof
= 1;
1502 enable_hc_int(_hc_regs
,ack
);
1503 enable_hc_int(_hc_regs
,nak
);
1504 enable_hc_int(_hc_regs
,nyet
);
1505 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1510 else if(hcint
.b
.datatglerr
)
1514 else if(hcint
.b
.stall
)
1522 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1523 static int32_t chhltd_isoc_tx_nonsplit(ifxhcd_hcd_t
*_ifxhcd
,
1524 ifxhcd_hc_t
*_ifxhc
,
1525 ifxusb_hc_regs_t
*_hc_regs
,
1526 ifxhcd_urbd_t
*_urbd
)
1528 #if defined(__EN_ISOC__)
1530 hcint_data_t hcintmsk
;
1531 hctsiz_data_t hctsiz
;
1532 int out_nak_enh
= 0;
1534 if (_ifxhcd
->core_if
.snpsid
>= 0x4f54271a && _ifxhc
->speed
== IFXUSB_EP_SPEED_HIGH
)
1537 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
1538 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
1539 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
1541 if (hcint
.b
.xfercomp
)
1543 _urbd
->error_count
=0;
1544 disable_hc_int(_hc_regs
,ack
);
1545 disable_hc_int(_hc_regs
,nak
);
1546 disable_hc_int(_hc_regs
,nyet
);
1547 _ifxhc
->wait_for_sof
= 0;
1548 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1551 else if (hcint
.b
.frmovrun
)
1554 _urbd
->error_count
=0;
1555 disable_hc_int(_hc_regs
,ack
);
1556 disable_hc_int(_hc_regs
,nak
);
1557 disable_hc_int(_hc_regs
,nyet
);
1558 _ifxhc
->wait_for_sof
= 0;
1559 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_FRAME_OVERRUN
);
1562 else if(hcint
.b
.datatglerr
)
1566 else if(hcint
.b
.bblerr
)
1569 if(hctsiz
.b
.pktcnt
==0)
1571 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1576 sz2
=_ifxhc
->start_pkt_count
- hctsiz
.b
.pktcnt
;
1578 sz1
=_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
;
1581 ifxhcd_hc_dumb_rx(&_ifxhcd
->core_if
, _ifxhc
,_ifxhc
->epqh
->dump_buf
);
1582 _urbd
->urb
->actual_length
+= (_ifxhc
->xfer_len
- hctsiz
.b
.xfersize
);
1583 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
1584 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
1585 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
1586 _urbd
->error_count
++;
1587 if(_urbd
->error_count
>=3)
1589 _urbd
->error_count
=0;
1590 _ifxhc
->wait_for_sof
= 0;
1591 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
1595 _ifxhc
->wait_for_sof
= 1;
1596 enable_hc_int(_hc_regs
,ack
);
1597 enable_hc_int(_hc_regs
,nak
);
1598 enable_hc_int(_hc_regs
,nyet
);
1599 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1604 else if(hcint
.b
.xacterr
)
1606 if(hctsiz
.b
.pktcnt
==0)
1608 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
1611 _urbd
->error_count
++;
1612 if(_urbd
->error_count
>=3)
1614 _urbd
->error_count
=0;
1615 _ifxhc
->wait_for_sof
= 0;
1616 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
1620 _ifxhc
->wait_for_sof
= 1;
1621 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1625 else if(hcint
.b
.stall
)
1633 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1634 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1635 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1636 static int32_t chhltd_ctrlbulk_rx_ssplit(ifxhcd_hcd_t
*_ifxhcd
,
1637 ifxhcd_hc_t
*_ifxhc
,
1638 ifxusb_hc_regs_t
*_hc_regs
,
1639 ifxhcd_urbd_t
*_urbd
)
1642 hcint_data_t hcintmsk
;
1643 hctsiz_data_t hctsiz
;
1645 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
1646 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
1647 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
1649 disable_hc_int(_hc_regs
,ack
);
1650 disable_hc_int(_hc_regs
,nak
);
1651 disable_hc_int(_hc_regs
,nyet
);
1657 _urbd
->error_count
=0;
1659 _ifxhc
->wait_for_sof
= 8;
1660 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
1661 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1664 else if (hcint
.b
.nak
)
1666 _ifxhc
->wait_for_sof
= 1;
1667 _urbd
->error_count
= 0;
1668 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1671 else if (hcint
.b
.xacterr
)
1673 _urbd
->error_count
++;
1674 if(_urbd
->error_count
>=3)
1676 _urbd
->error_count
=0;
1677 _ifxhc
->wait_for_sof
=0;
1678 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
1682 _ifxhc
->wait_for_sof
=1;
1683 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1687 else if(hcint
.b
.bblerr
)
1689 _urbd
->error_count
=0;
1690 _ifxhc
->wait_for_sof
=0;
1691 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
1694 else if(hcint
.b
.stall
)
1696 _urbd
->error_count
=0;
1697 _ifxhc
->wait_for_sof
=0;
1698 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
1701 else if(hcint
.b
.datatglerr
)
1703 IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT1 HC_XFER_DATA_TOGGLE_ERR\n",__func__
,__LINE__
);
1704 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1705 _urbd
->error_count
=0;
1706 _ifxhc
->wait_for_sof
=0;
1707 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_DATA_TOGGLE_ERR
);
1710 else if(hcint
.b
.frmovrun
)
1712 IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT1 HC_XFER_FRAME_OVERRUN\n",__func__
,__LINE__
);
1713 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1714 _urbd
->error_count
=0;
1715 _ifxhc
->wait_for_sof
=0;
1716 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_FRAME_OVERRUN
);
1719 else if(hcint
.b
.nyet
)
1721 IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT1 NYET\n",__func__
,__LINE__
);
1722 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1724 else if(hcint
.b
.xfercomp
)
1726 IFX_WARN("%s() %d Warning CTRLBULK IN SPLIT1 COMPLETE\n",__func__
,__LINE__
);
1727 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1731 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1732 static int32_t chhltd_ctrlbulk_tx_ssplit(ifxhcd_hcd_t
*_ifxhcd
,
1733 ifxhcd_hc_t
*_ifxhc
,
1734 ifxusb_hc_regs_t
*_hc_regs
,
1735 ifxhcd_urbd_t
*_urbd
)
1738 hcint_data_t hcintmsk
;
1739 hctsiz_data_t hctsiz
;
1740 int out_nak_enh
= 0;
1746 if (_ifxhcd
->core_if
.snpsid
>= 0x4f54271a && _ifxhc
->speed
== IFXUSB_EP_SPEED_HIGH
)
1749 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
1750 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
1751 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
1752 disable_hc_int(_hc_regs
,ack
);
1753 disable_hc_int(_hc_regs
,nak
);
1754 disable_hc_int(_hc_regs
,nyet
);
1757 if(!first
&& _ifxhc
->ep_type
== IFXUSB_EP_TYPE_BULK
1758 &&(hcint
.b
.stall
|| hcint
.b
.datatglerr
|| hcint
.b
.frmovrun
|| hcint
.b
.bblerr
|| hcint
.b
.xacterr
) && !hcint
.b
.ack
)
1760 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1762 printk(KERN_INFO
" [%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X] \n"
1763 ,*(_ifxhc
->xfer_buff
+ 0),*(_ifxhc
->xfer_buff
+ 1),*(_ifxhc
->xfer_buff
+ 2),*(_ifxhc
->xfer_buff
+ 3)
1764 ,*(_ifxhc
->xfer_buff
+ 4),*(_ifxhc
->xfer_buff
+ 5),*(_ifxhc
->xfer_buff
+ 6),*(_ifxhc
->xfer_buff
+ 7)
1765 ,*(_ifxhc
->xfer_buff
+ 8),*(_ifxhc
->xfer_buff
+ 9),*(_ifxhc
->xfer_buff
+10),*(_ifxhc
->xfer_buff
+11)
1766 ,*(_ifxhc
->xfer_buff
+12),*(_ifxhc
->xfer_buff
+13),*(_ifxhc
->xfer_buff
+14),*(_ifxhc
->xfer_buff
+15));
1768 printk(KERN_INFO
" [_urbd->urb->actual_length:%08X _ifxhc->start_pkt_count:%08X hctsiz.b.pktcnt:%08X ,_urbd->xfer_len:%08x] \n"
1769 ,_urbd
->urb
->actual_length
1770 ,_ifxhc
->start_pkt_count
1778 _urbd
->error_count
=0;
1779 if (_ifxhc
->ep_type
== IFXUSB_EP_TYPE_BULK
|| _ifxhc
->control_phase
!= IFXHCD_CONTROL_SETUP
)
1780 _ifxhc
->ssplit_out_xfer_count
= _ifxhc
->xfer_len
;
1782 _ifxhc
->wait_for_sof
=8;
1783 _ifxhc
->data_pid_start
=read_data_toggle(_hc_regs
);
1784 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1787 else if(hcint
.b
.nyet
)
1789 IFX_WARN("%s() %d Warning CTRLBULK OUT SPLIT1 NYET\n",__func__
,__LINE__
);
1790 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1791 _urbd
->error_count
=0;
1792 if (_ifxhc
->ep_type
== IFXUSB_EP_TYPE_BULK
|| _ifxhc
->control_phase
!= IFXHCD_CONTROL_SETUP
)
1793 _ifxhc
->ssplit_out_xfer_count
= _ifxhc
->xfer_len
;
1795 _ifxhc
->wait_for_sof
=1;
1796 _ifxhc
->data_pid_start
=read_data_toggle(_hc_regs
);
1797 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1800 else if(hcint
.b
.nak
)
1802 _ifxhc
->wait_for_sof
=1;
1807 _urbd
->error_count
=0;
1808 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1811 else if(hcint
.b
.xacterr
)
1813 _urbd
->error_count
++;
1814 if(_urbd
->error_count
>=3)
1816 _urbd
->error_count
=0;
1817 _ifxhc
->wait_for_sof
=0;
1819 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
1823 _ifxhc
->wait_for_sof
=1;
1825 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1829 else if(hcint
.b
.datatglerr
)
1831 _urbd
->error_count
=0;
1832 _ifxhc
->wait_for_sof
=0;
1834 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_DATA_TOGGLE_ERR
);
1837 else if(hcint
.b
.bblerr
)
1839 _urbd
->error_count
=0;
1840 _ifxhc
->wait_for_sof
=0;
1842 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
1845 else if(hcint
.b
.stall
)
1847 _urbd
->error_count
=0;
1848 _ifxhc
->wait_for_sof
=0;
1850 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
1853 else if(hcint
.b
.frmovrun
)
1855 IFX_WARN("%s() %d Warning CTRLBULK OUT SPLIT1 HC_XFER_FRAME_OVERRUN\n",__func__
,__LINE__
);
1856 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1857 _urbd
->error_count
=0;
1858 _ifxhc
->wait_for_sof
=0;
1860 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_FRAME_OVERRUN
);
1863 else if(hcint
.b
.xfercomp
)
1865 printk(KERN_INFO
"%s() %d Warning CTRLBULK OUT SPLIT1 COMPLETE\n",__func__
,__LINE__
);
1869 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1870 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1871 static int32_t chhltd_intr_rx_ssplit(ifxhcd_hcd_t
*_ifxhcd
,
1872 ifxhcd_hc_t
*_ifxhc
,
1873 ifxusb_hc_regs_t
*_hc_regs
,
1874 ifxhcd_urbd_t
*_urbd
)
1877 hcint_data_t hcintmsk
;
1878 hctsiz_data_t hctsiz
;
1880 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
1881 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
1882 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
1884 disable_hc_int(_hc_regs
,ack
);
1885 disable_hc_int(_hc_regs
,nak
);
1886 disable_hc_int(_hc_regs
,nyet
);
1892 /*== AVM/BC 20100701 - Workaround FullSpeed Interrupts with HiSpeed Hub ==*/
1893 _ifxhc
->nyet_count
=0;
1895 _urbd
->error_count
=0;
1897 _ifxhc
->wait_for_sof
= 0;
1898 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
1899 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1902 else if(hcint
.b
.nak
)
1904 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
1905 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
1906 _urbd
->error_count
=0;
1907 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1910 else if(hcint
.b
.xacterr
)
1912 hcchar_data_t hcchar
;
1913 hcchar
.d32
= ifxusb_rreg(&_hc_regs
->hcchar
);
1914 _urbd
->error_count
=hcchar
.b
.multicnt
;
1915 if(_urbd
->error_count
>=3)
1917 _urbd
->error_count
=0;
1918 _ifxhc
->wait_for_sof
= 0;
1919 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
1923 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
1924 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
1925 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1929 else if(hcint
.b
.stall
)
1931 _urbd
->error_count
=0;
1932 _ifxhc
->wait_for_sof
=0;
1933 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
1936 else if(hcint
.b
.bblerr
)
1938 _urbd
->error_count
=0;
1939 _ifxhc
->wait_for_sof
=0;
1940 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
1943 else if(hcint
.b
.frmovrun
)
1945 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
1946 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
1947 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
1950 else if(hcint
.b
.datatglerr
)
1952 IFX_WARN( "%s() %d Warning INTR IN SPLIT1 DATATGLERR\n",__func__
,__LINE__
);
1953 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1954 _urbd
->error_count
=0;
1955 _ifxhc
->wait_for_sof
=0;
1956 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_DATA_TOGGLE_ERR
);
1959 else if(hcint
.b
.xfercomp
)
1961 IFX_WARN("%s() %d Warning INTR IN SPLIT1 COMPLETE\n",__func__
,__LINE__
);
1962 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
1966 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1967 static int32_t chhltd_intr_tx_ssplit(ifxhcd_hcd_t
*_ifxhcd
,
1968 ifxhcd_hc_t
*_ifxhc
,
1969 ifxusb_hc_regs_t
*_hc_regs
,
1970 ifxhcd_urbd_t
*_urbd
)
1973 hcint_data_t hcintmsk
;
1974 hctsiz_data_t hctsiz
;
1975 int out_nak_enh
= 0;
1977 if (_ifxhcd
->core_if
.snpsid
>= 0x4f54271a && _ifxhc
->speed
== IFXUSB_EP_SPEED_HIGH
)
1980 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
1981 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
1982 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
1984 disable_hc_int(_hc_regs
,ack
);
1985 disable_hc_int(_hc_regs
,nak
);
1986 disable_hc_int(_hc_regs
,nyet
);
1990 /*== AVM/BC 20100701 - Workaround FullSpeed Interrupts with HiSpeed Hub ==*/
1991 _ifxhc
->nyet_count
=0;
1993 _urbd
->error_count
=0;
1994 _ifxhc
->ssplit_out_xfer_count
= _ifxhc
->xfer_len
;
1996 _ifxhc
->wait_for_sof
= 0;
1997 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
1998 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2001 else if(hcint
.b
.nyet
)
2003 IFX_WARN("%s() %d Warning INTR OUT SPLIT1 NYET\n",__func__
,__LINE__
);
2004 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
2005 _urbd
->error_count
=0;
2006 _ifxhc
->ssplit_out_xfer_count
= _ifxhc
->xfer_len
;
2008 _ifxhc
->wait_for_sof
= 0;
2009 _ifxhc
->data_pid_start
= read_data_toggle(_hc_regs
);
2010 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2013 else if(hcint
.b
.nak
)
2015 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
2016 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
2017 _urbd
->error_count
=0;
2018 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2021 else if(hcint
.b
.frmovrun
)
2023 _urbd
->error_count
=0;
2024 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
2025 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
2026 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2029 else if(hcint
.b
.xacterr
)
2031 hcchar_data_t hcchar
;
2032 hcchar
.d32
= ifxusb_rreg(&_hc_regs
->hcchar
);
2033 _urbd
->error_count
=hcchar
.b
.multicnt
;
2034 if(_urbd
->error_count
>=3)
2036 _urbd
->error_count
=0;
2037 _ifxhc
->wait_for_sof
=0;
2038 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
2042 enable_hc_int(_hc_regs
,ack
);
2043 enable_hc_int(_hc_regs
,nak
);
2044 enable_hc_int(_hc_regs
,nyet
);
2045 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
2046 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
2047 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2051 else if(hcint
.b
.datatglerr
)
2053 IFX_WARN("%s() %d Warning INTR IN SPLIT1 DATATGLERR\n",__func__
,__LINE__
);
2054 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
2055 _urbd
->error_count
=0;
2056 _ifxhc
->wait_for_sof
=0;
2057 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_DATA_TOGGLE_ERR
);
2060 else if(hcint
.b
.bblerr
)
2062 IFX_WARN("%s() %d Warning INTR IN SPLIT1 BABBLEERR\n",__func__
,__LINE__
);
2063 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
2064 _urbd
->error_count
=0;
2065 _ifxhc
->wait_for_sof
=0;
2066 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
2069 else if(hcint
.b
.stall
)
2071 IFX_WARN("%s() %d Warning INTR IN SPLIT1 STALL\n",__func__
,__LINE__
);
2072 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
2073 _urbd
->error_count
=0;
2074 _ifxhc
->wait_for_sof
=0;
2075 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
2078 else if(hcint
.b
.xfercomp
)
2080 IFX_WARN("%s() %d Warning INTR IN SPLIT1 COMPLETE\n",__func__
,__LINE__
);
2081 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
2085 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2086 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2087 static int32_t chhltd_isoc_rx_ssplit(ifxhcd_hcd_t
*_ifxhcd
,
2088 ifxhcd_hc_t
*_ifxhc
,
2089 ifxusb_hc_regs_t
*_hc_regs
,
2090 ifxhcd_urbd_t
*_urbd
)
2092 #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
2094 hcint_data_t hcintmsk
;
2095 hctsiz_data_t hctsiz
;
2097 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
2098 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
2099 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
2104 else if(hcint
.b
.frmovrun
)
2106 Rewind Buffer Pointers
2107 Retry Start
Split (in next b_interval ¡V
1 uF
)
2109 else if(hcint
.b
.datatglerr
)
2113 else if(hcint
.b
.bblerr
)
2117 else if(hcint
.b
.xacterr
)
2121 else if(hcint
.b
.stall
)
2125 else if(hcint
.b
.nak
)
2129 else if(hcint
.b
.xfercomp
)
2133 else if(hcint
.b
.nyet
)
2140 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2141 static int32_t chhltd_isoc_tx_ssplit(ifxhcd_hcd_t
*_ifxhcd
,
2142 ifxhcd_hc_t
*_ifxhc
,
2143 ifxusb_hc_regs_t
*_hc_regs
,
2144 ifxhcd_urbd_t
*_urbd
)
2146 #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
2148 hcint_data_t hcintmsk
;
2149 hctsiz_data_t hctsiz
;
2150 int out_nak_enh
= 0;
2152 if (_ifxhcd
->core_if
.snpsid
>= 0x4f54271a && _ifxhc
->speed
== IFXUSB_EP_SPEED_HIGH
)
2155 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
2156 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
2157 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
2160 Do Next Start
Split (in next b_interval ¡V
1 uF
)
2162 else if(hcint
.b
.frmovrun
)
2164 Do Next Transaction in next frame
.
2166 else if(hcint
.b
.datatglerr
)
2170 else if(hcint
.b
.bblerr
)
2174 else if(hcint
.b
.xacterr
)
2178 else if(hcint
.b
.stall
)
2182 else if(hcint
.b
.nak
)
2186 else if(hcint
.b
.xfercomp
)
2190 else if(hcint
.b
.nyet
)
2197 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2198 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2199 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2200 static int32_t chhltd_ctrlbulk_rx_csplit(ifxhcd_hcd_t
*_ifxhcd
,
2201 ifxhcd_hc_t
*_ifxhc
,
2202 ifxusb_hc_regs_t
*_hc_regs
,
2203 ifxhcd_urbd_t
*_urbd
)
2206 hcint_data_t hcintmsk
;
2207 hctsiz_data_t hctsiz
;
2209 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
2210 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
2211 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
2212 disable_hc_int(_hc_regs
,ack
);
2213 disable_hc_int(_hc_regs
,nak
);
2214 disable_hc_int(_hc_regs
,nyet
);
2216 _ifxhc
->do_ping
= 0;
2218 if (hcint
.b
.xfercomp
)
2220 _urbd
->error_count
=0;
2221 _ifxhc
->wait_for_sof
= 0;
2223 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
2226 else if (hcint
.b
.nak
)
2228 _urbd
->error_count
=0;
2231 _ifxhc
->wait_for_sof
= 1;
2232 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2233 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2234 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2237 else if(hcint
.b
.nyet
)
2239 _urbd
->error_count
=0;
2240 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
2241 _ifxhc
->wait_for_sof
= 1;
2242 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2245 else if(hcint
.b
.stall
|| hcint
.b
.bblerr
)
2247 _urbd
->error_count
=0;
2248 _ifxhc
->wait_for_sof
= 0;
2250 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
2251 else if(hcint
.b
.bblerr
)
2252 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
2255 else if(hcint
.b
.xacterr
)
2257 _urbd
->error_count
++;
2258 if(_urbd
->error_count
>=3)
2260 _urbd
->error_count
=0;
2261 _ifxhc
->wait_for_sof
= 0;
2262 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
2267 _ifxhc
->wait_for_sof
= 1;
2268 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2269 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2270 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2274 else if(hcint
.b
.datatglerr
)
2276 if(_ifxhc
->data_pid_start
== IFXUSB_HC_PID_DATA0
)
2277 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA1
;
2279 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA0
;
2281 _ifxhc
->wait_for_sof
= 1;
2282 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2283 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2284 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2287 else if(hcint
.b
.frmovrun
)
2289 _urbd
->error_count
=0;
2290 _ifxhc
->wait_for_sof
= 0;
2291 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_FRAME_OVERRUN
);
2296 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2297 static int32_t chhltd_ctrlbulk_tx_csplit(ifxhcd_hcd_t
*_ifxhcd
,
2298 ifxhcd_hc_t
*_ifxhc
,
2299 ifxusb_hc_regs_t
*_hc_regs
,
2300 ifxhcd_urbd_t
*_urbd
)
2303 hcint_data_t hcintmsk
;
2304 hctsiz_data_t hctsiz
;
2305 int out_nak_enh
= 0;
2311 if (_ifxhcd
->core_if
.snpsid
>= 0x4f54271a && _ifxhc
->speed
== IFXUSB_EP_SPEED_HIGH
)
2314 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
2315 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
2316 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
2317 disable_hc_int(_hc_regs
,ack
);
2318 disable_hc_int(_hc_regs
,nak
);
2319 disable_hc_int(_hc_regs
,nyet
);
2322 if(!first
&& _ifxhc
->ep_type
== IFXUSB_EP_TYPE_BULK
2323 &&(hcint
.b
.stall
|| hcint
.b
.datatglerr
|| hcint
.b
.frmovrun
|| hcint
.b
.bblerr
|| hcint
.b
.xacterr
) && !hcint
.b
.ack
)
2325 showint( hcint
.d32
,hcintmsk
.d32
,hctsiz
.d32
);
2327 printk(KERN_INFO
" [%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X] \n"
2328 ,*(_ifxhc
->xfer_buff
+ 0),*(_ifxhc
->xfer_buff
+ 1),*(_ifxhc
->xfer_buff
+ 2),*(_ifxhc
->xfer_buff
+ 3)
2329 ,*(_ifxhc
->xfer_buff
+ 4),*(_ifxhc
->xfer_buff
+ 5),*(_ifxhc
->xfer_buff
+ 6),*(_ifxhc
->xfer_buff
+ 7)
2330 ,*(_ifxhc
->xfer_buff
+ 8),*(_ifxhc
->xfer_buff
+ 9),*(_ifxhc
->xfer_buff
+10),*(_ifxhc
->xfer_buff
+11)
2331 ,*(_ifxhc
->xfer_buff
+12),*(_ifxhc
->xfer_buff
+13),*(_ifxhc
->xfer_buff
+14),*(_ifxhc
->xfer_buff
+15));
2333 printk(KERN_INFO
" [_urbd->urb->actual_length:%08X _ifxhc->start_pkt_count:%08X hctsiz.b.pktcnt:%08X ,_urbd->xfer_len:%08x] \n"
2334 ,_urbd
->urb
->actual_length
2335 ,_ifxhc
->start_pkt_count
2341 if(hcint
.b
.xfercomp
)
2343 _urbd
->error_count
=0;
2347 if(_ifxhc
->xfer_len
==0 && !hcint
.b
.ack
&& (hcint
.b
.nak
|| hcint
.b
.nyet
))
2349 // Walkaround: When sending ZLP and receive NYEY or NAK but also issue CMPT intr
2350 // Solution: NoSplit: Resend at next SOF
2351 // Split : Resend at next SOF with SSPLIT
2352 _ifxhc
->xfer_len
= 0;
2353 _ifxhc
->xfer_count
= 0;
2354 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
2355 _ifxhc
->wait_for_sof
= 1;
2356 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2361 _ifxhc
->wait_for_sof
= 0;
2362 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
2366 else if(hcint
.b
.nak
)
2368 _urbd
->error_count
=0;
2371 _ifxhc
->wait_for_sof
= 1;
2376 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2377 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2378 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2381 else if(hcint
.b
.nyet
)
2383 //Retry Complete Split
2384 // Issue Retry instantly on next SOF, without gothrough process_channels
2385 _urbd
->error_count
=0;
2386 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
2387 _ifxhc
->wait_for_sof
= 1;
2388 _ifxhc
->do_ping
= 0;
2389 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2392 else if(hcint
.b
.stall
)
2394 _urbd
->error_count
=0;
2395 _ifxhc
->wait_for_sof
= 0;
2396 _ifxhc
->do_ping
= 0;
2397 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
2400 else if(hcint
.b
.xacterr
)
2402 _urbd
->error_count
++;
2403 if(_urbd
->error_count
>=3)
2405 _urbd
->error_count
=0;
2406 _ifxhc
->wait_for_sof
= 0;
2407 _ifxhc
->do_ping
= 0;
2408 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
2413 _ifxhc
->wait_for_sof
= 1;
2418 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2419 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2420 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2424 else if(hcint
.b
.datatglerr
)
2426 if(_ifxhc
->data_pid_start
== IFXUSB_HC_PID_DATA0
)
2427 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA1
;
2429 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA0
;
2431 _ifxhc
->wait_for_sof
= 1;
2436 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2437 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2438 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2441 else if(hcint
.b
.frmovrun
)
2443 _urbd
->error_count
=0;
2444 _ifxhc
->wait_for_sof
= 0;
2445 _ifxhc
->do_ping
= 0;
2446 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_FRAME_OVERRUN
);
2449 else if(hcint
.b
.bblerr
)
2451 _urbd
->error_count
=0;
2452 _ifxhc
->wait_for_sof
= 0;
2453 _ifxhc
->do_ping
= 0;
2454 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
2459 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2460 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2461 static int32_t chhltd_intr_rx_csplit(ifxhcd_hcd_t
*_ifxhcd
,
2462 ifxhcd_hc_t
*_ifxhc
,
2463 ifxusb_hc_regs_t
*_hc_regs
,
2464 ifxhcd_urbd_t
*_urbd
)
2467 hcint_data_t hcintmsk
;
2468 hctsiz_data_t hctsiz
;
2470 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
2471 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
2472 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
2473 disable_hc_int(_hc_regs
,ack
);
2474 disable_hc_int(_hc_regs
,nak
);
2475 disable_hc_int(_hc_regs
,nyet
);
2476 _ifxhc
->do_ping
= 0;
2478 if (hcint
.b
.xfercomp
)
2480 _urbd
->error_count
=0;
2481 _ifxhc
->wait_for_sof
= 0;
2483 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
2486 else if(hcint
.b
.nak
)
2488 _urbd
->error_count
=0;
2490 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
2491 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
2492 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2493 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2494 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2497 else if(hcint
.b
.nyet
)
2499 _urbd
->error_count
=0;
2500 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
2501 _ifxhc
->wait_for_sof
= 0;
2503 /*== AVM/BC 20100701 - Workaround FullSpeed Interrupts with HiSpeed Hub ==*/
2504 _ifxhc
->nyet_count
++;
2505 if(_ifxhc
->nyet_count
> 2) {
2507 _ifxhc
->nyet_count
= 0;
2508 _ifxhc
->wait_for_sof
= 5;
2511 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2514 else if(hcint
.b
.frmovrun
|| hcint
.b
.bblerr
|| hcint
.b
.stall
)
2516 _urbd
->error_count
=0;
2517 _ifxhc
->wait_for_sof
= 0;
2519 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
2520 else if(hcint
.b
.bblerr
)
2521 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
2522 else if(hcint
.b
.frmovrun
)
2523 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_FRAME_OVERRUN
);
2526 else if(hcint
.b
.xacterr
)
2528 hcchar_data_t hcchar
;
2529 hcchar
.d32
= ifxusb_rreg(&_hc_regs
->hcchar
);
2530 _urbd
->error_count
=hcchar
.b
.multicnt
;
2531 if(_urbd
->error_count
>=3)
2533 _urbd
->error_count
=0;
2534 _ifxhc
->wait_for_sof
= 0;
2535 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
2540 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
2541 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
2542 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2543 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2544 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2548 else if(hcint
.b
.datatglerr
)
2550 if(_ifxhc
->data_pid_start
== IFXUSB_HC_PID_DATA0
)
2551 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA1
;
2553 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA0
;
2555 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
2556 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
2557 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2558 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2559 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2564 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2565 static int32_t chhltd_intr_tx_csplit(ifxhcd_hcd_t
*_ifxhcd
,
2566 ifxhcd_hc_t
*_ifxhc
,
2567 ifxusb_hc_regs_t
*_hc_regs
,
2568 ifxhcd_urbd_t
*_urbd
)
2571 hcint_data_t hcintmsk
;
2572 hctsiz_data_t hctsiz
;
2573 int out_nak_enh
= 0;
2575 if (_ifxhcd
->core_if
.snpsid
>= 0x4f54271a && _ifxhc
->speed
== IFXUSB_EP_SPEED_HIGH
)
2578 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
2579 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
2580 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
2581 disable_hc_int(_hc_regs
,ack
);
2582 disable_hc_int(_hc_regs
,nak
);
2583 disable_hc_int(_hc_regs
,nyet
);
2585 if(hcint
.b
.xfercomp
)
2587 _urbd
->error_count
=0;
2588 _ifxhc
->wait_for_sof
= 0;
2590 _ifxhc
->do_ping
= 0;
2591 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
2594 else if(hcint
.b
.nak
)
2596 _urbd
->error_count
=0;
2598 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
2599 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
2604 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2605 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2606 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2609 else if(hcint
.b
.nyet
)
2611 _urbd
->error_count
=0;
2612 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
2613 _ifxhc
->wait_for_sof
= 0;
2614 _ifxhc
->do_ping
= 0;
2616 /*== AVM/BC 20100701 - Workaround FullSpeed Interrupts with HiSpeed Hub ==*/
2617 _ifxhc
->nyet_count
++;
2618 if(_ifxhc
->nyet_count
> 2) {
2620 _ifxhc
->nyet_count
= 0;
2621 _ifxhc
->wait_for_sof
= 5;
2624 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2627 else if(hcint
.b
.stall
|| hcint
.b
.frmovrun
)
2629 _urbd
->error_count
=0;
2630 _ifxhc
->wait_for_sof
= 0;
2631 _ifxhc
->do_ping
= 0;
2633 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
2634 else if(hcint
.b
.frmovrun
)
2635 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_FRAME_OVERRUN
);
2638 else if(hcint
.b
.xacterr
)
2640 hcchar_data_t hcchar
;
2641 hcchar
.d32
= ifxusb_rreg(&_hc_regs
->hcchar
);
2642 _urbd
->error_count
=hcchar
.b
.multicnt
;
2643 if(_urbd
->error_count
>=3)
2645 _urbd
->error_count
=0;
2646 _ifxhc
->wait_for_sof
= 0;
2647 _ifxhc
->do_ping
= 0;
2648 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_XACT_ERR
);
2653 _ifxhc
->wait_for_sof
= _ifxhc
->epqh
->interval
-1;
2654 if(!_ifxhc
->wait_for_sof
) _ifxhc
->wait_for_sof
=1;
2659 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2660 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2661 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2665 else if(hcint
.b
.datatglerr
)
2667 if(_ifxhc
->data_pid_start
== IFXUSB_HC_PID_DATA0
)
2668 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA1
;
2670 _ifxhc
->data_pid_start
= IFXUSB_HC_PID_DATA0
;
2676 _ifxhc
->xfer_len
= _urbd
->xfer_len
- _urbd
->urb
->actual_length
;
2677 _ifxhc
->xfer_count
= _urbd
->urb
->actual_length
;
2678 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2681 else if(hcint
.b
.bblerr
)
2683 _urbd
->error_count
=0;
2684 _ifxhc
->wait_for_sof
= 0;
2685 _ifxhc
->do_ping
= 0;
2686 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_BABBLE_ERR
);
2691 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2692 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2693 static int32_t chhltd_isoc_rx_csplit(ifxhcd_hcd_t
*_ifxhcd
,
2694 ifxhcd_hc_t
*_ifxhc
,
2695 ifxusb_hc_regs_t
*_hc_regs
,
2696 ifxhcd_urbd_t
*_urbd
)
2698 #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
2700 hcint_data_t hcintmsk
;
2701 hctsiz_data_t hctsiz
;
2703 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
2704 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
2705 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
2706 if(hcint
.b
.xfercomp
)
2708 disable_hc_int(_hc_regs
,ack
);
2709 disable_hc_int(_hc_regs
,nak
);
2710 disable_hc_int(_hc_regs
,nyet
);
2711 _urbd
->error_count
=0;
2712 _ifxhc
->wait_for_sof
= 0;
2714 complete_channel(_ifxhcd
, _ifxhc
, _urbd
);
2717 else if(hcint
.b
.nak
)
2719 Retry Start
Split (in next b_interval ¡V
1 uF
)
2721 else if(hcint
.b
.nyet
)
2723 //Do Next Complete Split
2724 // Issue Retry instantly on next SOF, without gothrough process_channels
2725 _urbd
->error_count
=0;
2726 //disable_hc_int(_hc_regs,ack);
2727 //disable_hc_int(_hc_regs,nak);
2728 //disable_hc_int(_hc_regs,datatglerr);
2729 _ifxhc
->halt_status
= HC_XFER_NO_HALT_STATUS
;
2730 _ifxhc
->wait_for_sof
= 1;
2731 ifxhcd_hc_start(&_ifxhcd
->core_if
, _ifxhc
);
2734 else if(hcint
.b
.frmovrun
|| hcint
.b
.stall
|| hcint
.b
.bblerr
)
2736 _urbd
->error_count
=0;
2737 disable_hc_int(_hc_regs
,ack
);
2738 disable_hc_int(_hc_regs
,nyet
);
2739 disable_hc_int(_hc_regs
,nak
);
2740 _ifxhc
->wait_for_sof
= 0;
2742 //if(hctsiz.b.pktcnt==0)
2744 // complete_channel(_ifxhcd, _ifxhc, _urbd);
2748 // _urbd->urb->actual_length += (_ifxhc->xfer_len - hctsiz.b.xfersize);
2750 release_channel(_ifxhcd
, _ifxhc
, HC_XFER_STALL
);
2751 else if(hcint
.b
.frmovrun
)
2752 else if(hcint
.b
.bblerr
)
2755 else if(hcint
.b
.xacterr
)
2757 Rewind Buffer Pointers
2758 if (HCCHARn
.EC
= = 3) // ERR response received
2761 Do Next Start
Split (in next frame
)
2768 else if(hcint
.b
.datatglerr
)
2772 else if(hcint
.b
.ack
)
2779 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2780 static int32_t chhltd_isoc_tx_csplit(ifxhcd_hcd_t
*_ifxhcd
,
2781 ifxhcd_hc_t
*_ifxhc
,
2782 ifxusb_hc_regs_t
*_hc_regs
,
2783 ifxhcd_urbd_t
*_urbd
)
2785 #if defined(__EN_ISOC__) && defined(__EN_ISOC_SPLIT__)
2787 hcint_data_t hcintmsk
;
2788 hctsiz_data_t hctsiz
;
2789 int out_nak_enh
= 0;
2791 if (_ifxhcd
->core_if
.snpsid
>= 0x4f54271a && _ifxhc
->speed
== IFXUSB_EP_SPEED_HIGH
)
2794 hcint
.d32
= ifxusb_rreg(&_hc_regs
->hcint
);
2795 hcintmsk
.d32
= ifxusb_rreg(&_hc_regs
->hcintmsk
);
2796 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
2801 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2802 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2803 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2805 static int32_t handle_hc_chhltd_intr(ifxhcd_hcd_t
*_ifxhcd
,
2806 ifxhcd_hc_t
*_ifxhc
,
2807 ifxusb_hc_regs_t
*_hc_regs
,
2808 ifxhcd_urbd_t
*_urbd
)
2810 IFX_DEBUGPL(DBG_HCD
, "--Host Channel %d Interrupt: Channel Halted--\n", _ifxhc
->hc_num
);
2812 _ifxhc
->halting
= 0;
2813 _ifxhc
->xfer_started
= 0;
2815 if (_ifxhc
->halt_status
== HC_XFER_URB_DEQUEUE
||
2816 _ifxhc
->halt_status
== HC_XFER_AHB_ERR
) {
2818 * Just release the channel. A dequeue can happen on a
2819 * transfer timeout. In the case of an AHB Error, the channel
2820 * was forced to halt because there's no way to gracefully
2823 release_channel(_ifxhcd
, _ifxhc
, _ifxhc
->halt_status
);
2827 if (_ifxhc
->ep_type
== IFXUSB_EP_TYPE_CTRL
|| _ifxhc
->ep_type
== IFXUSB_EP_TYPE_BULK
)
2829 if (_ifxhc
->split
==0)
2832 return (chhltd_ctrlbulk_rx_nonsplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2834 return (chhltd_ctrlbulk_tx_nonsplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2836 else if(_ifxhc
->split
==1)
2839 return (chhltd_ctrlbulk_rx_ssplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2841 return (chhltd_ctrlbulk_tx_ssplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2843 else if(_ifxhc
->split
==2)
2846 return (chhltd_ctrlbulk_rx_csplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2848 return (chhltd_ctrlbulk_tx_csplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2851 else if(_ifxhc
->ep_type
== IFXUSB_EP_TYPE_INTR
)
2853 if (_ifxhc
->split
==0)
2856 return (chhltd_intr_rx_nonsplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2858 return (chhltd_intr_tx_nonsplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2860 else if(_ifxhc
->split
==1)
2863 return (chhltd_intr_rx_ssplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2865 return (chhltd_intr_tx_ssplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2867 else if(_ifxhc
->split
==2)
2870 return (chhltd_intr_rx_csplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2872 return (chhltd_intr_tx_csplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2875 else if(_ifxhc
->ep_type
== IFXUSB_EP_TYPE_ISOC
)
2877 if (_ifxhc
->split
==0)
2880 return (chhltd_isoc_rx_nonsplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2882 return (chhltd_isoc_tx_nonsplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2884 else if(_ifxhc
->split
==1)
2887 return (chhltd_isoc_rx_ssplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2889 return (chhltd_isoc_tx_ssplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2891 else if(_ifxhc
->split
==2)
2894 return (chhltd_isoc_rx_csplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2896 return (chhltd_isoc_tx_csplit(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
));
2903 * Handles a host channel AHB error interrupt. This handler is only called in
2906 static void hc_other_intr_dump(ifxhcd_hcd_t
*_ifxhcd
,
2907 ifxhcd_hc_t
*_ifxhc
,
2908 ifxusb_hc_regs_t
*_hc_regs
,
2909 ifxhcd_urbd_t
*_urbd
)
2912 hcchar_data_t hcchar
;
2913 hcsplt_data_t hcsplt
;
2914 hctsiz_data_t hctsiz
;
2916 struct urb
*urb
= _urbd
->urb
;
2917 hcchar
.d32
= ifxusb_rreg(&_hc_regs
->hcchar
);
2918 hcsplt
.d32
= ifxusb_rreg(&_hc_regs
->hcsplt
);
2919 hctsiz
.d32
= ifxusb_rreg(&_hc_regs
->hctsiz
);
2920 hcdma
= ifxusb_rreg(&_hc_regs
->hcdma
);
2922 IFX_ERROR("Channel %d\n", _ifxhc
->hc_num
);
2923 IFX_ERROR(" hcchar 0x%08x, hcsplt 0x%08x\n", hcchar
.d32
, hcsplt
.d32
);
2924 IFX_ERROR(" hctsiz 0x%08x, hcdma 0x%08x\n", hctsiz
.d32
, hcdma
);
2925 IFX_ERROR(" Device address: %d\n", usb_pipedevice(urb
->pipe
));
2926 IFX_ERROR(" Endpoint: %d, %s\n", usb_pipeendpoint(urb
->pipe
),
2927 (usb_pipein(urb
->pipe
) ? "IN" : "OUT"));
2928 IFX_ERROR(" Endpoint type: %s\n",
2930 switch (usb_pipetype(urb
->pipe
)) {
2931 case PIPE_CONTROL
: pipetype
= "CTRL"; break;
2932 case PIPE_BULK
: pipetype
= "BULK"; break;
2933 case PIPE_INTERRUPT
: pipetype
= "INTR"; break;
2934 case PIPE_ISOCHRONOUS
: pipetype
= "ISOC"; break;
2935 default: pipetype
= "????"; break;
2937 IFX_ERROR(" Speed: %s\n",
2939 switch (urb
->dev
->speed
) {
2940 case USB_SPEED_HIGH
: speed
= "HS"; break;
2941 case USB_SPEED_FULL
: speed
= "FS"; break;
2942 case USB_SPEED_LOW
: speed
= "LS"; break;
2943 default: speed
= "????"; break;
2945 IFX_ERROR(" Max packet size: %d\n",
2946 usb_maxpacket(urb
->dev
, urb
->pipe
, usb_pipeout(urb
->pipe
)));
2947 IFX_ERROR(" Data buffer length: %d\n", urb
->transfer_buffer_length
);
2948 IFX_ERROR(" Transfer buffer: %p, Transfer DMA: %p\n",
2949 urb
->transfer_buffer
, (void *)urb
->transfer_dma
);
2950 IFX_ERROR(" Setup buffer: %p, Setup DMA: %p\n",
2951 urb
->setup_packet
, (void *)urb
->setup_dma
);
2952 IFX_ERROR(" Interval: %d\n", urb
->interval
);
2957 * Handles a host channel ACK interrupt. This interrupt is enabled when
2958 * errors occur, and during Start Split transactions.
2960 static int32_t handle_hc_ack_intr(ifxhcd_hcd_t
*_ifxhcd
,
2961 ifxhcd_hc_t
*_ifxhc
,
2962 ifxusb_hc_regs_t
*_hc_regs
,
2963 ifxhcd_urbd_t
*_urbd
)
2965 _urbd
->error_count
=0;
2966 if(_ifxhc
->nak_countdown_r
)
2968 _ifxhc
->nak_retry
=_ifxhc
->nak_retry_r
;
2969 _ifxhc
->nak_countdown
=_ifxhc
->nak_countdown_r
;
2972 disable_hc_int(_hc_regs
,nak
);
2973 disable_hc_int(_hc_regs
,ack
);
2978 * Handles a host channel ACK interrupt. This interrupt is enabled when
2979 * errors occur, and during Start Split transactions.
2981 static int32_t handle_hc_nak_intr(ifxhcd_hcd_t
*_ifxhcd
,
2982 ifxhcd_hc_t
*_ifxhc
,
2983 ifxusb_hc_regs_t
*_hc_regs
,
2984 ifxhcd_urbd_t
*_urbd
)
2987 _urbd
->error_count
=0;
2989 if(_ifxhc
->nak_countdown_r
)
2991 _ifxhc
->nak_countdown
--;
2992 if(!_ifxhc
->nak_countdown
)
2994 _ifxhc
->nak_countdown
=_ifxhc
->nak_countdown_r
;
2995 disable_hc_int(_hc_regs
,ack
);
2996 disable_hc_int(_hc_regs
,nak
);
2997 ifxhcd_hc_halt(&_ifxhcd
->core_if
, _ifxhc
, HC_XFER_NAK
);
3000 enable_hc_int(_hc_regs
,ack
);
3004 disable_hc_int(_hc_regs
,ack
);
3005 disable_hc_int(_hc_regs
,nak
);
3011 * Handles a host channel AHB error interrupt. This handler is only called in
3014 static int32_t handle_hc_ahberr_intr(ifxhcd_hcd_t
*_ifxhcd
,
3015 ifxhcd_hc_t
*_ifxhc
,
3016 ifxusb_hc_regs_t
*_hc_regs
,
3017 ifxhcd_urbd_t
*_urbd
)
3019 IFX_DEBUGPL(DBG_HCD
, "--Host Channel %d Interrupt: "
3020 "AHB Error--\n", _ifxhc
->hc_num
);
3021 hc_other_intr_dump(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
);
3023 ifxhcd_hc_halt(&_ifxhcd
->core_if
, _ifxhc
, HC_XFER_AHB_ERR
);
3030 static int32_t handle_hc_datatglerr_intr(ifxhcd_hcd_t
*_ifxhcd
,
3031 ifxhcd_hc_t
*_ifxhc
,
3032 ifxusb_hc_regs_t
*_hc_regs
,
3033 ifxhcd_urbd_t
*_urbd
)
3035 IFX_ERROR( "--Host Channel %d Interrupt: "
3036 "DATATOGGLE Error--\n", _ifxhc
->hc_num
);
3037 hc_other_intr_dump(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
);
3038 disable_hc_int(_hc_regs
,datatglerr
);
3045 * Interrupts which should not been triggered
3047 static int32_t handle_hc_frmovrun_intr(ifxhcd_hcd_t
*_ifxhcd
,
3048 ifxhcd_hc_t
*_ifxhc
,
3049 ifxusb_hc_regs_t
*_hc_regs
,
3050 ifxhcd_urbd_t
*_urbd
)
3052 IFX_ERROR( "--Host Channel %d Interrupt: "
3053 "FrameOverRun Error--\n", _ifxhc
->hc_num
);
3054 hc_other_intr_dump(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
);
3055 disable_hc_int(_hc_regs
,frmovrun
);
3059 static int32_t handle_hc_bblerr_intr(ifxhcd_hcd_t
*_ifxhcd
,
3060 ifxhcd_hc_t
*_ifxhc
,
3061 ifxusb_hc_regs_t
*_hc_regs
,
3062 ifxhcd_urbd_t
*_urbd
)
3064 IFX_ERROR( "--Host Channel %d Interrupt: "
3065 "BBL Error--\n", _ifxhc
->hc_num
);
3066 hc_other_intr_dump(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
);
3067 disable_hc_int(_hc_regs
,bblerr
);
3071 static int32_t handle_hc_xacterr_intr(ifxhcd_hcd_t
*_ifxhcd
,
3072 ifxhcd_hc_t
*_ifxhc
,
3073 ifxusb_hc_regs_t
*_hc_regs
,
3074 ifxhcd_urbd_t
*_urbd
)
3076 IFX_ERROR( "--Host Channel %d Interrupt: "
3077 "XACT Error--\n", _ifxhc
->hc_num
);
3078 hc_other_intr_dump(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
);
3079 disable_hc_int(_hc_regs
,xacterr
);
3083 static int32_t handle_hc_nyet_intr(ifxhcd_hcd_t
*_ifxhcd
,
3084 ifxhcd_hc_t
*_ifxhc
,
3085 ifxusb_hc_regs_t
*_hc_regs
,
3086 ifxhcd_urbd_t
*_urbd
)
3088 IFX_ERROR( "--Host Channel %d Interrupt: "
3089 "NYET--\n", _ifxhc
->hc_num
);
3090 hc_other_intr_dump(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
);
3091 _urbd
->error_count
=0;
3092 disable_hc_int(_hc_regs
,nyet
);
3096 static int32_t handle_hc_stall_intr(ifxhcd_hcd_t
*_ifxhcd
,
3097 ifxhcd_hc_t
*_ifxhc
,
3098 ifxusb_hc_regs_t
*_hc_regs
,
3099 ifxhcd_urbd_t
*_urbd
)
3101 IFX_ERROR( "--Host Channel %d Interrupt: "
3102 "STALL--\n", _ifxhc
->hc_num
);
3103 hc_other_intr_dump(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
);
3104 disable_hc_int(_hc_regs
,stall
);
3108 static int32_t handle_hc_xfercomp_intr(ifxhcd_hcd_t
*_ifxhcd
,
3109 ifxhcd_hc_t
*_ifxhc
,
3110 ifxusb_hc_regs_t
*_hc_regs
,
3111 ifxhcd_urbd_t
*_urbd
)
3113 IFX_ERROR( "--Host Channel %d Interrupt: "
3114 "XFERCOMP--\n", _ifxhc
->hc_num
);
3115 hc_other_intr_dump(_ifxhcd
,_ifxhc
,_hc_regs
,_urbd
);
3116 disable_hc_int(_hc_regs
,xfercomp
);
3122 /* This interrupt indicates that the specified host channels has a pending
3123 * interrupt. There are multiple conditions that can cause each host channel
3124 * interrupt. This function determines which conditions have occurred for this
3125 * host channel interrupt and handles them appropriately. */
3126 static int32_t handle_hc_n_intr (ifxhcd_hcd_t
*_ifxhcd
, uint32_t _num
)
3128 uint32_t hcintval
,hcintmsk
;
3131 ifxusb_hc_regs_t
*hc_regs
;
3132 ifxhcd_urbd_t
*urbd
;
3133 unsigned long flags
;
3137 IFX_DEBUGPL(DBG_HCDV
, "--Host Channel Interrupt--, Channel %d\n", _num
);
3139 /*== AVM/BC 20101111 Lock needed ==*/
3140 SPIN_LOCK_IRQSAVE(&_ifxhcd
->lock
, flags
);
3142 ifxhc
= &_ifxhcd
->ifxhc
[_num
];
3143 hc_regs
= _ifxhcd
->core_if
.hc_regs
[_num
];
3145 hcintval
= ifxusb_rreg(&hc_regs
->hcint
);
3146 hcintmsk
= ifxusb_rreg(&hc_regs
->hcintmsk
);
3147 hcint
.d32
= hcintval
& hcintmsk
;
3148 IFX_DEBUGPL(DBG_HCDV
, " 0x%08x & 0x%08x = 0x%08x\n",
3149 hcintval
, hcintmsk
, hcint
.d32
);
3151 urbd
= list_entry(ifxhc
->epqh
->urbd_list
.next
, ifxhcd_urbd_t
, urbd_list_entry
);
3153 if (hcint
.b
.datatglerr
)
3154 retval
|= handle_hc_datatglerr_intr(_ifxhcd
, ifxhc
, hc_regs
, urbd
);
3155 if (hcint
.b
.frmovrun
)
3156 retval
|= handle_hc_frmovrun_intr(_ifxhcd
, ifxhc
, hc_regs
, urbd
);
3158 retval
|= handle_hc_bblerr_intr(_ifxhcd
, ifxhc
, hc_regs
, urbd
);
3159 if (hcint
.b
.xacterr
)
3160 retval
|= handle_hc_xacterr_intr(_ifxhcd
, ifxhc
, hc_regs
, urbd
);
3162 retval
|= handle_hc_nyet_intr(_ifxhcd
, ifxhc
, hc_regs
, urbd
);
3164 retval
|= handle_hc_ack_intr(_ifxhcd
, ifxhc
, hc_regs
, urbd
);
3166 retval
|= handle_hc_nak_intr(_ifxhcd
, ifxhc
, hc_regs
, urbd
);
3168 retval
|= handle_hc_stall_intr(_ifxhcd
, ifxhc
, hc_regs
, urbd
);
3169 if (hcint
.b
.ahberr
) {
3170 clear_hc_int(hc_regs
, ahberr
);
3171 retval
|= handle_hc_ahberr_intr(_ifxhcd
, ifxhc
, hc_regs
, urbd
);
3173 if (hcint
.b
.chhltd
) {
3174 /* == 20110901 AVM/WK Fix: Flag must not be cleared after restart of channel ==*/
3175 clear_hc_int(hc_regs
, chhltd
);
3176 retval
|= handle_hc_chhltd_intr(_ifxhcd
, ifxhc
, hc_regs
, urbd
);
3178 if (hcint
.b
.xfercomp
)
3179 retval
|= handle_hc_xfercomp_intr(_ifxhcd
, ifxhc
, hc_regs
, urbd
);
3181 /* == 20110901 AVM/WK Fix: Never clear possibly new intvals ==*/
3182 //ifxusb_wreg(&hc_regs->hcint,hcintval);
3184 SPIN_UNLOCK_IRQRESTORE(&_ifxhcd
->lock
, flags
);
3194 static uint8_t update_interval_counter(ifxhcd_epqh_t
*_epqh
,uint32_t _diff
)
3196 if(_diff
>=_epqh
->period_counter
)
3199 if(_diff
>_epqh
->interval
)
3200 _epqh
->period_counter
=1;
3202 _epqh
->period_counter
=_epqh
->period_counter
+_epqh
->interval
-_diff
;
3205 _epqh
->period_counter
=_epqh
->period_counter
-_diff
;
3213 * Handles the start-of-frame interrupt in host mode. Non-periodic
3214 * transactions may be queued to the DWC_otg controller for the current
3215 * (micro)frame. Periodic transactions may be queued to the controller for the
3216 * next (micro)frame.
3218 static int32_t handle_sof_intr (ifxhcd_hcd_t
*_ifxhcd
)
3220 #ifdef __DYN_SOF_INTR__
3221 uint8_t with_count_down
=0;
3223 uint8_t active_on
=0;
3225 struct list_head
*epqh_entry
;
3226 ifxhcd_epqh_t
*epqh
;
3230 unsigned long flags
;
3231 #ifdef __USE_TIMER_4_SOF__
3232 uint32_t wait_for_sof
= 0x10000;
3235 SPIN_LOCK_IRQSAVE(&_ifxhcd
->lock
, flags
);
3239 ifxusb_hc_regs_t
*hc_regs
;
3241 num_channels
= _ifxhcd
->core_if
.params
.host_channels
;
3243 // AVM/WK moved block here due to use of SOF timer
3244 hfnum
.d32
= ifxusb_rreg(&_ifxhcd
->core_if
.host_global_regs
->hfnum
);
3245 fndiff
= hfnum
.b
.frnum
;
3246 fndiff
+= 0x00004000;
3247 fndiff
-= _ifxhcd
->lastframe
;
3248 fndiff
&= 0x00003FFF;
3249 if(!fndiff
) fndiff
=1;
3251 for (i
= 0; i
< num_channels
; i
++)
3253 if(_ifxhcd
->ifxhc
[i
].wait_for_sof
&& _ifxhcd
->ifxhc
[i
].xfer_started
)
3255 #ifdef __USE_TIMER_4_SOF__
3256 if (_ifxhcd
->ifxhc
[i
].wait_for_sof
> fndiff
) {
3257 _ifxhcd
->ifxhc
[i
].wait_for_sof
-= fndiff
;
3259 _ifxhcd
->ifxhc
[i
].wait_for_sof
= 0;
3262 _ifxhcd
->ifxhc
[i
].wait_for_sof
--;
3264 if(_ifxhcd
->ifxhc
[i
].wait_for_sof
==0)
3266 hcint_data_t hcint
= { .d32
=0 };
3267 hc_regs
= _ifxhcd
->core_if
.hc_regs
[i
];
3269 hcint
.d32
=0xFFFFFFFF;
3270 ifxusb_wreg(&hc_regs
->hcint
, hcint
.d32
);
3272 hcint
.d32
=ifxusb_rreg(&hc_regs
->hcintmsk
);
3275 /* == 20110901 AVM/WK Fix: We don't need NOT YET IRQ ==*/
3277 _ifxhcd
->ifxhc
[i
].nak_countdown
=_ifxhcd
->ifxhc
[i
].nak_countdown_r
;
3278 if(_ifxhcd
->ifxhc
[i
].nak_countdown_r
)
3280 ifxusb_wreg(&hc_regs
->hcintmsk
, hcint
.d32
);
3282 /* AVM WK / BC 20100827
3283 * FIX: Packet was ignored because of wrong Oddframe bit
3285 if (_ifxhcd
->ifxhc
[i
].ep_type
== IFXUSB_EP_TYPE_INTR
|| _ifxhcd
->ifxhc
[i
].ep_type
== IFXUSB_EP_TYPE_ISOC
)
3287 hcchar_data_t hcchar
;
3288 hcchar
.d32
= _ifxhcd
->ifxhc
[i
].hcchar
;
3289 hfnum
.d32
= ifxusb_rreg(&_ifxhcd
->core_if
.host_global_regs
->hfnum
);
3290 /* 1 if _next_ frame is odd, 0 if it's even */
3291 hcchar
.b
.oddfrm
= (hfnum
.b
.frnum
& 0x1) ? 0 : 1;
3292 _ifxhcd
->ifxhc
[i
].hcchar
= hcchar
.d32
;
3295 ifxusb_wreg(&hc_regs
->hcchar
, _ifxhcd
->ifxhc
[i
].hcchar
);
3300 _ifxhcd
->ifxhc
[i
].wait_for_sof
=0;
3302 #ifdef __USE_TIMER_4_SOF__
3303 if (_ifxhcd
->ifxhc
[i
].wait_for_sof
&& (wait_for_sof
> _ifxhcd
->ifxhc
[i
].wait_for_sof
)) {
3304 wait_for_sof
= _ifxhcd
->ifxhc
[i
].wait_for_sof
;
3312 #error ISOC not supported: missing SOF code
3313 epqh_entry
= _ifxhcd
->epqh_isoc_active
.next
;
3314 while (epqh_entry
!= &_ifxhcd
->epqh_isoc_active
)
3316 epqh
= list_entry(epqh_entry
, ifxhcd_epqh_t
, epqh_list_entry
);
3317 epqh_entry
= epqh_entry
->next
;
3318 #ifdef __DYN_SOF_INTR__
3321 active_on
+=update_interval_counter(epqh
,fndiff
);
3325 epqh_entry
= _ifxhcd
->epqh_isoc_ready
.next
;
3326 while (epqh_entry
!= &_ifxhcd
->epqh_isoc_ready
)
3328 epqh
= list_entry(epqh_entry
, ifxhcd_epqh_t
, epqh_list_entry
);
3329 epqh_entry
= epqh_entry
->next
;
3330 #ifdef __DYN_SOF_INTR__
3333 ready_on
+=update_interval_counter(epqh
,fndiff
);
3338 epqh_entry
= _ifxhcd
->epqh_intr_active
.next
;
3339 while (epqh_entry
!= &_ifxhcd
->epqh_intr_active
)
3341 epqh
= list_entry(epqh_entry
, ifxhcd_epqh_t
, epqh_list_entry
);
3342 epqh_entry
= epqh_entry
->next
;
3343 #ifdef __DYN_SOF_INTR__
3346 #ifdef __USE_TIMER_4_SOF__
3347 if (update_interval_counter(epqh
,fndiff
)) {
3351 if (epqh
->period_counter
&& (wait_for_sof
> epqh
->period_counter
)) {
3352 wait_for_sof
= epqh
->period_counter
;
3356 active_on
+=update_interval_counter(epqh
,fndiff
);
3361 epqh_entry
= _ifxhcd
->epqh_intr_ready
.next
;
3362 while (epqh_entry
!= &_ifxhcd
->epqh_intr_ready
)
3364 epqh
= list_entry(epqh_entry
, ifxhcd_epqh_t
, epqh_list_entry
);
3365 epqh_entry
= epqh_entry
->next
;
3366 #ifdef __DYN_SOF_INTR__
3369 #ifdef __USE_TIMER_4_SOF__
3370 if (update_interval_counter(epqh
,fndiff
)) {
3374 if (epqh
->period_counter
&& (wait_for_sof
> epqh
->period_counter
)) {
3375 wait_for_sof
= epqh
->period_counter
;
3379 ready_on
+=update_interval_counter(epqh
,fndiff
);
3384 epqh_entry
= _ifxhcd
->epqh_stdby
.next
;
3385 while (epqh_entry
!= &_ifxhcd
->epqh_stdby
)
3387 epqh
= list_entry(epqh_entry
, ifxhcd_epqh_t
, epqh_list_entry
);
3388 epqh_entry
= epqh_entry
->next
;
3389 if(epqh
->period_counter
> 0 ) {
3390 #ifdef __USE_TIMER_4_SOF__
3391 if (epqh
->period_counter
> fndiff
) {
3392 epqh
->period_counter
-= fndiff
;
3394 epqh
->period_counter
= 0;
3397 epqh
->period_counter
--;
3399 #ifdef __DYN_SOF_INTR__
3403 if(epqh
->period_counter
== 0) {
3404 ifxhcd_epqh_idle_periodic(epqh
);
3406 #ifdef __USE_TIMER_4_SOF__
3408 if (wait_for_sof
> epqh
->period_counter
) {
3409 wait_for_sof
= epqh
->period_counter
;
3414 SPIN_UNLOCK_IRQRESTORE(&_ifxhcd
->lock
, flags
);
3417 select_eps(_ifxhcd
);
3419 process_channels(_ifxhcd
);
3421 /* Clear interrupt */
3423 gint_data_t gintsts
;
3425 gintsts
.b
.sofintr
= 1;
3426 ifxusb_wreg(&_ifxhcd
->core_if
.core_global_regs
->gintsts
, gintsts
.d32
);
3428 #ifdef __DYN_SOF_INTR__
3429 if(!with_count_down
)
3430 ifxusb_mreg(&_ifxhcd
->core_if
.core_global_regs
->gintmsk
, gintsts
.d32
,0);
3432 #ifdef __USE_TIMER_4_SOF__
3433 wait_for_sof
&= 0xFFFF; // reduce to 16 Bits.
3435 if(wait_for_sof
== 1) {
3437 gint_data_t gintsts
;
3439 gintsts
.b
.sofintr
= 1;
3440 ifxusb_mreg(&_ifxhcd
->core_if
.core_global_regs
->gintmsk
, 0,gintsts
.d32
);
3443 ifxusb_mreg(&_ifxhcd
->core_if
.core_global_regs
->gintmsk
, gintsts
.d32
,0);
3444 if (wait_for_sof
> 1) {
3445 // use timer, not SOF IRQ
3448 hprt0
.d32
= ifxusb_read_hprt0 (&_ifxhcd
->core_if
);
3449 if (hprt0
.b
.prtspd
== IFXUSB_HPRT0_PRTSPD_HIGH_SPEED
) {
3450 ktime
= ktime_set(0, wait_for_sof
* 125 * 1000); /*--- wakeup in n*125usec ---*/
3452 ktime
= ktime_set(0, wait_for_sof
* (1000*1000)); /*--- wakeup in n*1000usec ---*/
3454 hrtimer_start(&_ifxhcd
->hr_timer
, ktime
, HRTIMER_MODE_REL
);
3459 _ifxhcd
->lastframe
=hfnum
.b
.frnum
;
3465 /* There are multiple conditions that can cause a port interrupt. This function
3466 * determines which interrupt conditions have occurred and handles them
3468 static int32_t handle_port_intr (ifxhcd_hcd_t
*_ifxhcd
)
3472 hprt0_data_t hprt0_modify
;
3475 hprt0_modify
.d32
= ifxusb_rreg(_ifxhcd
->core_if
.hprt0
);
3477 /* Clear appropriate bits in HPRT0 to clear the interrupt bit in
3480 hprt0_modify
.b
.prtena
= 0;
3481 hprt0_modify
.b
.prtconndet
= 0;
3482 hprt0_modify
.b
.prtenchng
= 0;
3483 hprt0_modify
.b
.prtovrcurrchng
= 0;
3485 /* Port Connect Detected
3486 * Set flag and clear if detected */
3487 if (hprt0
.b
.prtconndet
) {
3488 IFX_DEBUGPL(DBG_HCD
, "--Port Interrupt HPRT0=0x%08x "
3489 "Port Connect Detected--\n", hprt0
.d32
);
3490 _ifxhcd
->flags
.b
.port_connect_status_change
= 1;
3491 _ifxhcd
->flags
.b
.port_connect_status
= 1;
3492 hprt0_modify
.b
.prtconndet
= 1;
3494 /* The Hub driver asserts a reset when it sees port connect
3495 * status change flag */
3499 /* Port Enable Changed
3500 * Clear if detected - Set internal flag if disabled */
3501 if (hprt0
.b
.prtenchng
) {
3503 IFX_DEBUGPL(DBG_HCD
, " --Port Interrupt HPRT0=0x%08x "
3504 "Port Enable Changed--\n", hprt0
.d32
);
3505 hprt0_modify
.b
.prtenchng
= 1;
3506 if (hprt0
.b
.prtena
== 1)
3507 /* Port has been enabled set the reset change flag */
3508 _ifxhcd
->flags
.b
.port_reset_change
= 1;
3510 _ifxhcd
->flags
.b
.port_enable_change
= 1;
3514 /* Overcurrent Change Interrupt */
3516 if (hprt0
.b
.prtovrcurrchng
) {
3517 IFX_DEBUGPL(DBG_HCD
, " --Port Interrupt HPRT0=0x%08x "
3518 "Port Overcurrent Changed--\n", hprt0
.d32
);
3519 _ifxhcd
->flags
.b
.port_over_current_change
= 1;
3520 hprt0_modify
.b
.prtovrcurrchng
= 1;
3524 /* Clear Port Interrupts */
3525 ifxusb_wreg(_ifxhcd
->core_if
.hprt0
, hprt0_modify
.d32
);
3530 * This interrupt indicates that SUSPEND state has been detected on
3532 * No Functioning in Host Mode
3534 static int32_t handle_usb_suspend_intr(ifxhcd_hcd_t
*_ifxhcd
)
3536 gint_data_t gintsts
;
3537 IFX_DEBUGP("USB SUSPEND RECEIVED!\n");
3538 /* Clear interrupt */
3540 gintsts
.b
.usbsuspend
= 1;
3541 ifxusb_wreg(&_ifxhcd
->core_if
.core_global_regs
->gintsts
, gintsts
.d32
);
3546 * This interrupt indicates that the IFXUSB controller has detected a
3547 * resume or remote wakeup sequence. If the IFXUSB controller is in
3548 * low power mode, the handler must brings the controller out of low
3549 * power mode. The controller automatically begins resume
3550 * signaling. The handler schedules a time to stop resume signaling.
3552 static int32_t handle_wakeup_detected_intr(ifxhcd_hcd_t
*_ifxhcd
)
3554 gint_data_t gintsts
;
3555 hprt0_data_t hprt0
= {.d32
=0};
3556 pcgcctl_data_t pcgcctl
= {.d32
=0};
3557 ifxusb_core_if_t
*core_if
= &_ifxhcd
->core_if
;
3559 IFX_DEBUGPL(DBG_ANY
, "++Resume and Remote Wakeup Detected Interrupt++\n");
3562 * Clear the Resume after 70ms. (Need 20 ms minimum. Use 70 ms
3563 * so that OPT tests pass with all PHYs).
3565 /* Restart the Phy Clock */
3566 pcgcctl
.b
.stoppclk
= 1;
3567 ifxusb_mreg(core_if
->pcgcctl
, pcgcctl
.d32
, 0);
3570 /* Now wait for 70 ms. */
3571 hprt0
.d32
= ifxusb_read_hprt0( core_if
);
3572 IFX_DEBUGPL(DBG_ANY
,"Resume: HPRT0=%0x\n", hprt0
.d32
);
3574 hprt0
.b
.prtres
= 0; /* Resume */
3575 ifxusb_wreg(core_if
->hprt0
, hprt0
.d32
);
3576 IFX_DEBUGPL(DBG_ANY
,"Clear Resume: HPRT0=%0x\n", ifxusb_rreg(core_if
->hprt0
));
3578 /* Clear interrupt */
3580 gintsts
.b
.wkupintr
= 1;
3581 ifxusb_wreg(&core_if
->core_global_regs
->gintsts
, gintsts
.d32
);
3586 * This interrupt indicates that a device is initiating the Session
3587 * Request Protocol to request the host to turn on bus power so a new
3588 * session can begin. The handler responds by turning on bus power. If
3589 * the DWC_otg controller is in low power mode, the handler brings the
3590 * controller out of low power mode before turning on bus power.
3592 static int32_t handle_session_req_intr(ifxhcd_hcd_t
*_ifxhcd
)
3594 /* Clear interrupt */
3595 gint_data_t gintsts
= { .d32
= 0 };
3596 gintsts
.b
.sessreqintr
= 1;
3597 ifxusb_wreg(&_ifxhcd
->core_if
.core_global_regs
->gintsts
, gintsts
.d32
);
3602 * This interrupt indicates that a device has been disconnected from
3605 static int32_t handle_disconnect_intr(ifxhcd_hcd_t
*_ifxhcd
)
3607 gint_data_t gintsts
;
3609 ifxhcd_disconnect(_ifxhcd
);
3612 gintsts
.b
.disconnect
= 1;
3613 ifxusb_wreg(&_ifxhcd
->core_if
.core_global_regs
->gintsts
, gintsts
.d32
);
3618 * This function handles the Connector ID Status Change Interrupt. It
3619 * reads the OTG Interrupt Register (GOTCTL) to determine whether this
3620 * is a Device to Host Mode transition or a Host Mode to Device
3622 * This only occurs when the cable is connected/removed from the PHY
3625 static int32_t handle_conn_id_status_change_intr(ifxhcd_hcd_t
*_ifxhcd
)
3627 gint_data_t gintsts
;
3629 IFX_WARN("ID Status Change Interrupt: currently in %s mode\n",
3630 ifxusb_mode(&_ifxhcd
->core_if
) ? "Host" : "Device");
3633 gintsts
.b
.conidstschng
= 1;
3634 ifxusb_wreg(&_ifxhcd
->core_if
.core_global_regs
->gintsts
, gintsts
.d32
);
3638 static int32_t handle_otg_intr(ifxhcd_hcd_t
*_ifxhcd
)
3640 ifxusb_core_global_regs_t
*global_regs
= _ifxhcd
->core_if
.core_global_regs
;
3641 gotgint_data_t gotgint
;
3642 gotgint
.d32
= ifxusb_rreg( &global_regs
->gotgint
);
3644 ifxusb_wreg (&global_regs
->gotgint
, gotgint
.d32
);
3648 /** This function will log a debug message */
3649 static int32_t handle_mode_mismatch_intr(ifxhcd_hcd_t
*_ifxhcd
)
3651 gint_data_t gintsts
;
3653 IFX_WARN("Mode Mismatch Interrupt: currently in %s mode\n",
3654 ifxusb_mode(&_ifxhcd
->core_if
) ? "Host" : "Device");
3656 gintsts
.b
.modemismatch
= 1;
3657 ifxusb_wreg(&_ifxhcd
->core_if
.core_global_regs
->gintsts
, gintsts
.d32
);
3661 /** This function handles interrupts for the HCD. */
3662 int32_t ifxhcd_handle_intr (ifxhcd_hcd_t
*_ifxhcd
)
3666 ifxusb_core_if_t
*core_if
= &_ifxhcd
->core_if
;
3667 /* AVM/BC 20101111 Unnecesary variable removed*/
3668 //gint_data_t gintsts,gintsts2;
3669 gint_data_t gintsts
;
3671 /* Check if HOST Mode */
3672 if (ifxusb_is_device_mode(core_if
))
3674 IFX_ERROR("%s() CRITICAL! IN DEVICE MODE\n", __func__
);
3678 gintsts
.d32
= ifxusb_read_core_intr(core_if
);
3684 if (gintsts
.b
.modemismatch
)
3686 retval
|= handle_mode_mismatch_intr(_ifxhcd
);
3687 gintsts
.b
.modemismatch
=0;
3689 if (gintsts
.b
.otgintr
)
3691 retval
|= handle_otg_intr(_ifxhcd
);
3692 gintsts
.b
.otgintr
=0;
3694 if (gintsts
.b
.conidstschng
)
3696 retval
|= handle_conn_id_status_change_intr(_ifxhcd
);
3697 gintsts
.b
.conidstschng
=0;
3699 if (gintsts
.b
.disconnect
)
3701 retval
|= handle_disconnect_intr(_ifxhcd
);
3702 gintsts
.b
.disconnect
=0;
3704 if (gintsts
.b
.sessreqintr
)
3706 retval
|= handle_session_req_intr(_ifxhcd
);
3707 gintsts
.b
.sessreqintr
=0;
3709 if (gintsts
.b
.wkupintr
)
3711 retval
|= handle_wakeup_detected_intr(_ifxhcd
);
3712 gintsts
.b
.wkupintr
=0;
3714 if (gintsts
.b
.usbsuspend
)
3716 retval
|= handle_usb_suspend_intr(_ifxhcd
);
3717 gintsts
.b
.usbsuspend
=0;
3721 if (gintsts
.b
.sofintr
)
3723 retval
|= handle_sof_intr (_ifxhcd
);
3724 gintsts
.b
.sofintr
=0;
3726 if (gintsts
.b
.portintr
)
3728 retval
|= handle_port_intr (_ifxhcd
);
3729 gintsts
.b
.portintr
=0;
3731 if (gintsts
.b
.hcintr
)
3735 haint
.d32
= ifxusb_read_host_all_channels_intr(core_if
);
3736 for (i
=0; i
< core_if
->params
.host_channels
; i
++)
3737 if (haint
.b2
.chint
& (1 << i
))
3738 retval
|= handle_hc_n_intr (_ifxhcd
, i
);