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] [0x%p:PEND] Pending Work Interupt\n", otg_Unit
));
21 /* **************** PROCESS DONE TRANSFERS **************** */
23 FNAME_ROOTHUB(PendingIO
)(otg_Unit
);
25 // FNAME_DEV(DoFinishedTDs)(otg_Unit);
27 if (otg_Unit
->hu_CtrlXFerQueue
.lh_Head
->ln_Succ
)
29 D(bug("[USB2OTG] [0x%p:PEND] Process CtrlXFer ..\n", otg_Unit
));
30 // FNAME_DEV(ScheduleCtrlTDs)(otg_Unit);
33 if (otg_Unit
->hu_IntXFerQueue
.lh_Head
->ln_Succ
)
35 D(bug("[USB2OTG] [0x%p:PEND] Process IntXFer ..\n", otg_Unit
));
36 // FNAME_DEV(ScheduleIntTDs)(otg_Unit);
39 if (otg_Unit
->hu_BulkXFerQueue
.lh_Head
->ln_Succ
)
41 D(bug("[USB2OTG] [0x%p:PEND] Process BulkXFer ..\n", otg_Unit
));
42 // FNAME_DEV(ScheduleBulkTDs)(otg_Unit);
45 D(bug("[USB2OTG] [0x%p:PEND] finished\n", otg_Unit
));
52 AROS_INTH1(FNAME_DEV(NakTimeoutInt
), struct USB2OTGUnit
*, otg_Unit
)
56 struct IOUsbHWReq
*ioreq
;
58 D(bug("[USB2OTG] [0x%p:NAK] NakTimeout Interupt\n", otg_Unit
));
61 // uhciUpdateFrameCounter(hc);
62 // framecnt = hc->hc_FrameCounter;
64 ioreq
= (struct IOUsbHWReq
*) otg_Unit
->hu_TDQueue
.lh_Head
;
65 while(((struct Node
*) ioreq
)->ln_Succ
)
67 if(ioreq
->iouh_Flags
& UHFF_NAKTIMEOUT
)
69 /* uqh = (struct UhciQH *) ioreq->iouh_DriverPrivate1;
72 KPRINTF(1, ("Examining IOReq=%p with UQH=%p\n", ioreq, uqh));
73 devadrep = (ioreq->iouh_DevAddr<<5) + ioreq->iouh_Endpoint + ((ioreq->iouh_Dir == UHDIR_IN) ? 0x10 : 0);
74 linkelem = READMEM32_LE(&uqh->uqh_Element);
75 if(linkelem & UHCI_TERMINATE)
77 KPRINTF(1, ("UQH terminated %08lx\n", linkelem));
78 if(framecnt > unit->hu_NakTimeoutFrame[devadrep])
80 // give the thing the chance to exit gracefully
81 KPRINTF(20, ("Terminated? NAK timeout %ld > %ld, IOReq=%p\n", framecnt, unit->hu_NakTimeoutFrame[devadrep], ioreq));
85 utd = (struct UhciTD *) (((IPTR)linkelem & UHCI_PTRMASK) - hc->hc_PCIVirtualAdjust - 16); // struct UhciTD starts 16 before physical TD
86 ctrlstatus = READMEM32_LE(&utd->utd_CtrlStatus);
87 if(ctrlstatus & UTCF_ACTIVE)
89 if(framecnt > unit->hu_NakTimeoutFrame[devadrep])
91 // give the thing the chance to exit gracefully
92 KPRINTF(20, ("NAK timeout %ld > %ld, IOReq=%p\n", framecnt, unit->hu_NakTimeoutFrame[devadrep], ioreq));
93 ctrlstatus &= ~UTCF_ACTIVE;
94 WRITEMEM32_LE(&utd->utd_CtrlStatus, ctrlstatus);
98 if(framecnt > unit->hu_NakTimeoutFrame[devadrep])
100 // give the thing the chance to exit gracefully
101 KPRINTF(20, ("Terminated? NAK timeout %ld > %ld, IOReq=%p\n", framecnt, unit->hu_NakTimeoutFrame[devadrep], ioreq));
108 ioreq
= (struct IOUsbHWReq
*) ((struct Node
*) ioreq
)->ln_Succ
;
111 // uhciCheckPortStatusChange(hc);
113 FNAME_ROOTHUB(PendingIO
)(otg_Unit
);
115 otg_Unit
->hu_NakTimeoutReq
.tr_time
.tv_micro
= 150 * 1000;
116 SendIO((APTR
) &otg_Unit
->hu_NakTimeoutReq
);
118 D(bug("[USB2OTG] [0x%p:NAK] processed\n", otg_Unit
));