place-holder for restructure
[AROS.git] / arch / arm-raspi / usb / usb2otg / usb2otg_intr.c
blobb798c6a134cff1939713021361571240969d037e
1 /*
2 Copyright © 2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 1
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)
20 AROS_INTFUNC_INIT
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"));
47 return FALSE;
49 AROS_INTFUNC_EXIT
52 AROS_INTH1(FNAME_DEV(NakTimeoutInt), struct USB2OTGUnit *, otg_Unit)
54 AROS_INTFUNC_INIT
56 struct IOUsbHWReq *ioreq;
58 D(bug("[USB2OTG] ## NakTimeout Interupt\n"));
60 // ULONG framecnt;
61 // uhciUpdateFrameCounter(hc);
62 // framecnt = hc->hc_FrameCounter;
63 #if (0)
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;
70 if(uqh)
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));
82 causeint = TRUE;
84 } else {
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);
95 causeint = TRUE;
97 } else {
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));
102 causeint = TRUE;
108 ioreq = (struct IOUsbHWReq *) ((struct Node *) ioreq)->ln_Succ;
111 // uhciCheckPortStatusChange(hc);
112 #endif
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"));
120 return FALSE;
122 AROS_INTFUNC_EXIT