2 Copyright © 2013, 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 <asm/bcm2835.h>
14 #include <hardware/usb2otg.h>
16 #include "usb2otg_intern.h"
18 AROS_INTH1(FNAME_DEV(PendingInt
), struct USB2OTGUnit
*, otg_Unit
)
22 D(bug("[USB2OTG] ## Pending Work Interupt\n"));
24 /* **************** PROCESS DONE TRANSFERS **************** */
26 FNAME_ROOTHUB(PendingIO
)(otg_Unit
);
28 // uhciHandleFinishedTDs(otg_Unit);
30 if (otg_Unit
->hu_CtrlXFerQueue
.lh_Head
->ln_Succ
)
32 // uhciScheduleCtrlTDs(otg_Unit);
35 if (otg_Unit
->hu_IntXFerQueue
.lh_Head
->ln_Succ
)
37 // uhciScheduleIntTDs(otg_Unit);
40 if (otg_Unit
->hu_BulkXFerQueue
.lh_Head
->ln_Succ
)
42 // uhciScheduleBulkTDs(otg_Unit);
45 D(bug("[USB2OTG] ## Pending Work Processed\n"));
52 AROS_INTH1(FNAME_DEV(NakTimeoutInt
), struct USB2OTGUnit
*, otg_Unit
)
56 struct IOUsbHWReq
*ioreq
;
58 D(bug("[USB2OTG] ## NakTimeout Interupt\n"));
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] ## NakTimeout Processed\n"));