2 Copyright © 2013-2015, The AROS Development Team. All rights reserved.
7 #include <aros/debug.h>
9 #include <proto/exec.h>
10 #include <proto/kernel.h>
11 #include <proto/utility.h>
13 #include "usb2otg_intern.h"
15 AROS_INTH1(FNAME_DEV(PendingInt
), struct USB2OTGUnit
*, otg_Unit
)
19 D(bug("[USB2OTG] ## Pending Work Interupt\n"));
21 /* **************** PROCESS DONE TRANSFERS **************** */
23 FNAME_ROOTHUB(PendingIO
)(otg_Unit
);
25 // uhciHandleFinishedTDs(otg_Unit);
27 if (otg_Unit
->hu_CtrlXFerQueue
.lh_Head
->ln_Succ
)
29 // uhciScheduleCtrlTDs(otg_Unit);
32 if (otg_Unit
->hu_IntXFerQueue
.lh_Head
->ln_Succ
)
34 // uhciScheduleIntTDs(otg_Unit);
37 if (otg_Unit
->hu_BulkXFerQueue
.lh_Head
->ln_Succ
)
39 // uhciScheduleBulkTDs(otg_Unit);
42 D(bug("[USB2OTG] ## Pending Work Processed\n"));
49 AROS_INTH1(FNAME_DEV(NakTimeoutInt
), struct USB2OTGUnit
*, otg_Unit
)
53 struct IOUsbHWReq
*ioreq
;
55 D(bug("[USB2OTG] ## NakTimeout Interupt\n"));
58 // uhciUpdateFrameCounter(hc);
59 // framecnt = hc->hc_FrameCounter;
61 ioreq
= (struct IOUsbHWReq
*) otg_Unit
->hu_TDQueue
.lh_Head
;
62 while(((struct Node
*) ioreq
)->ln_Succ
)
64 if(ioreq
->iouh_Flags
& UHFF_NAKTIMEOUT
)
66 /* uqh = (struct UhciQH *) ioreq->iouh_DriverPrivate1;
69 KPRINTF(1, ("Examining IOReq=%p with UQH=%p\n", ioreq, uqh));
70 devadrep = (ioreq->iouh_DevAddr<<5) + ioreq->iouh_Endpoint + ((ioreq->iouh_Dir == UHDIR_IN) ? 0x10 : 0);
71 linkelem = READMEM32_LE(&uqh->uqh_Element);
72 if(linkelem & UHCI_TERMINATE)
74 KPRINTF(1, ("UQH terminated %08lx\n", linkelem));
75 if(framecnt > unit->hu_NakTimeoutFrame[devadrep])
77 // give the thing the chance to exit gracefully
78 KPRINTF(20, ("Terminated? NAK timeout %ld > %ld, IOReq=%p\n", framecnt, unit->hu_NakTimeoutFrame[devadrep], ioreq));
82 utd = (struct UhciTD *) (((IPTR)linkelem & UHCI_PTRMASK) - hc->hc_PCIVirtualAdjust - 16); // struct UhciTD starts 16 before physical TD
83 ctrlstatus = READMEM32_LE(&utd->utd_CtrlStatus);
84 if(ctrlstatus & UTCF_ACTIVE)
86 if(framecnt > unit->hu_NakTimeoutFrame[devadrep])
88 // give the thing the chance to exit gracefully
89 KPRINTF(20, ("NAK timeout %ld > %ld, IOReq=%p\n", framecnt, unit->hu_NakTimeoutFrame[devadrep], ioreq));
90 ctrlstatus &= ~UTCF_ACTIVE;
91 WRITEMEM32_LE(&utd->utd_CtrlStatus, ctrlstatus);
95 if(framecnt > unit->hu_NakTimeoutFrame[devadrep])
97 // give the thing the chance to exit gracefully
98 KPRINTF(20, ("Terminated? NAK timeout %ld > %ld, IOReq=%p\n", framecnt, unit->hu_NakTimeoutFrame[devadrep], ioreq));
105 ioreq
= (struct IOUsbHWReq
*) ((struct Node
*) ioreq
)->ln_Succ
;
108 // uhciCheckPortStatusChange(hc);
110 FNAME_ROOTHUB(PendingIO
)(otg_Unit
);
112 otg_Unit
->hu_NakTimeoutReq
.tr_time
.tv_micro
= 150 * 1000;
113 SendIO((APTR
) &otg_Unit
->hu_NakTimeoutReq
);
115 D(bug("[USB2OTG] ## NakTimeout Processed\n"));