revert between 56095 -> 55830 in arch
[AROS.git] / arch / arm-native / soc / broadcom / 2708 / usb / usb2otg / usb2otg_intern.h
blob793dd2cb9d80362940ed9e8e5d8647a72bc33ba0
1 #ifndef USB2OTG_INTERN_H
2 #define USB2OTG_INTERN_H
3 /*
4 Copyright © 2013-2019, The AROS Development Team. All rights reserved.
5 $Id$
6 */
8 #include LC_LIBDEFS_FILE
10 #include <aros/libcall.h>
11 #include <aros/asmcall.h>
12 #include <aros/symbolsets.h>
14 #include <exec/types.h>
15 #include <exec/lists.h>
16 #include <exec/memory.h>
17 #include <exec/libraries.h>
18 #include <exec/interrupts.h>
19 #include <exec/semaphores.h>
20 #include <exec/execbase.h>
21 #include <exec/devices.h>
22 #include <exec/io.h>
23 #include <exec/ports.h>
24 #include <exec/errors.h>
25 #include <exec/resident.h>
26 #include <exec/initializers.h>
27 #include <dos/dos.h>
29 #include <devices/timer.h>
30 #include <utility/utility.h>
32 #include <devices/usbhardware.h>
33 #include <devices/newstyle.h>
35 #include <oop/oop.h>
37 extern IPTR __arm_periiobase;
38 #define ARM_PERIIOBASE __arm_periiobase
39 #include <hardware/bcm2708.h>
40 #include <hardware/usb2otg.h>
43 Force the USB chipset to run in Host mode
44 AFAIK Poseidon doesnt support device mode? - TODO
46 //#define OTG_FORCEHOSTMODE
47 //#define OTG_FORCEDEVICEMODE
49 #include <asm/cpu.h>
51 /* Reply the iorequest with success */
52 #define RC_OK 0
54 /* Magic cookie, don't set error fields & don't reply the ioreq */
55 #define RC_DONTREPLY -1
57 #define MAX_ROOT_PORTS 16
59 #define VCMB_PROPCHAN 8
60 #define VCPOWER_USBHCD 3
61 #define VCPOWER_STATE_ON 1
62 #define VCPOWER_STATE_WAIT 2
64 static inline ULONG rd32le(IPTR iobase) {
65 ULONG val;
66 dmb();
67 val = AROS_LE2LONG(*(volatile ULONG *)(iobase));
68 dsb();
69 return val;
72 static inline UWORD rd16le(IPTR iobase) {
73 UWORD val;
74 dmb();
75 val = AROS_LE2WORD(*(volatile UWORD *)(iobase));
76 dsb();
77 return val;
80 static inline UBYTE rd8(IPTR iobase) {
81 UBYTE val;
82 dmb();
83 val = *(volatile UBYTE *)(iobase);
84 dsb();
85 return val;
88 static inline void wr32le(IPTR iobase, ULONG value) {
89 dsb();
90 *(volatile ULONG *)(iobase) = AROS_LONG2LE(value);
91 dmb();
94 static inline void wr16le(IPTR iobase, UWORD value) {
95 dsb();
96 *(volatile UWORD *)(iobase) = AROS_WORD2LE(value);
97 dmb();
100 static inline void wr8be(IPTR iobase, UBYTE value) {
101 dsb();
102 *(volatile UBYTE *)(iobase) = value;
103 dmb();
106 struct USBNSDeviceQueryResult
108 ULONG DevQueryFormat;
109 ULONG SizeAvailable;
110 UWORD DeviceType;
111 UWORD DeviceSubType;
112 const UWORD *SupportedCommands; /* 0 terminated list of cmd's */
115 struct USB2OTGUnit
117 struct Unit hu_Unit;
119 struct List hu_IOPendingQueue; /* Root Hub Pending IO Requests */
121 struct List hu_TDQueue;
122 struct List hu_PeriodicTDQueue;
123 struct List hu_CtrlXFerQueue;
124 struct List hu_IntXFerQueue;
125 struct List hu_IntXFerScheduled;
126 struct List hu_IsoXFerQueue;
127 struct List hu_BulkXFerQueue;
128 struct List hu_FinishedXfers;
131 struct USB2OTGChannel {
132 struct IOUsbHWReq * hc_Request;
133 ULONG hc_XferSize;
134 } hu_Channel[8];
136 // struct IOUsbHWReq * hu_InProgressXFer[8];
137 // ULONG hu_InProgressXFerSize[8];
139 struct List hu_AbortQueue;
141 APTR hu_GlobalIRQHandle;
142 struct Interrupt hu_PendingInt;
143 struct Interrupt hu_NakTimeoutInt;
144 struct timerequest hu_NakTimeoutReq;
145 struct MsgPort hu_NakTimeoutMsgPort;
147 UBYTE hu_OperatingMode; /* HOST/DEVICE mode */
148 UBYTE hu_HubAddr;
149 UBYTE hu_HostChans;
150 UBYTE hu_DevEPs;
151 UBYTE hu_DevInEPs;
153 BOOL hu_UnitAllocated; /* unit opened */
154 BOOL hu_HubPortChanged; /* Root port state change */
155 APTR hu_USB2OTGBase;
157 ULONG hu_XferSizeWidth;
158 ULONG hu_PktSizeWidth;
160 ULONG hu_PIDBits[128]; /* PID 2-bit pairs, one ULONG per device, each ULONG contains 2-bits for every endpoint */
163 /* PRIVATE device node */
164 struct USB2OTGDevice
166 struct Library hd_Library; /* standard */
167 UWORD hd_Flags; /* various flags */
169 APTR hd_KernelBase; /* kernel.resource base */
170 APTR hd_UtilityBase; /* for tags etc */
172 APTR hd_MemPool; /* memory pool */
174 struct USB2OTGUnit *hd_Unit; /* we only currently support a single unit.. */
176 struct MsgPort *hd_MsgPort;
177 struct timerequest *hd_TimerReq; /* Timer I/O Requests */
181 #define FNAME_DEV(x) USB2OTG__Dev__ ## x
182 #define FNAME_ROOTHUB(x) USB2OTG__RootHub__ ## x
184 #ifdef UtilityBase
185 #undef UtilityBase
186 #endif
188 #ifdef KernelBase
189 #undef KernelBase
190 #endif
192 #define UtilityBase USB2OTGBase->hd_UtilityBase
194 #define KernelBase USB2OTGBase->hd_KernelBase
196 struct Unit *FNAME_DEV(OpenUnit)(struct IOUsbHWReq *, LONG, struct USB2OTGDevice *);
197 void FNAME_DEV(CloseUnit)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
199 void FNAME_DEV(TermIO)(struct IOUsbHWReq *, struct USB2OTGDevice *);
201 WORD FNAME_DEV(cmdNSDeviceQuery)(struct IOStdReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
202 WORD FNAME_DEV(cmdQueryDevice)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
204 WORD FNAME_DEV(cmdReset)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
205 WORD FNAME_DEV(cmdFlush)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
207 WORD FNAME_DEV(cmdUsbReset)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
208 WORD FNAME_DEV(cmdUsbResume)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
209 WORD FNAME_DEV(cmdUsbSuspend)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
210 WORD FNAME_DEV(cmdUsbOper)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
211 WORD FNAME_DEV(cmdControlXFer)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
212 WORD FNAME_DEV(cmdBulkXFer)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
213 WORD FNAME_DEV(cmdIntXFer)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
214 WORD FNAME_DEV(cmdIsoXFer)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
216 void FNAME_DEV(Cause)(struct USB2OTGDevice *, struct Interrupt *);
218 WORD FNAME_ROOTHUB(cmdControlXFer)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
219 WORD FNAME_ROOTHUB(cmdIntXFer)(struct IOUsbHWReq *, struct USB2OTGUnit *, struct USB2OTGDevice *);
220 void FNAME_ROOTHUB(PendingIO)(struct USB2OTGUnit *);
222 void FNAME_DEV(GlobalIRQHandler)(struct USB2OTGUnit *USBUnit, struct ExecBase *SysBase);
223 void FNAME_DEV(ScheduleCtrlTDs)(struct USB2OTGUnit *);
224 void FNAME_DEV(ScheduleBulkTDs)(struct USB2OTGUnit *);
225 void FNAME_DEV(ScheduleIntTDs)(struct USB2OTGUnit *);
226 void FNAME_DEV(SetupChannel)(struct USB2OTGUnit *, int chan);
227 void FNAME_DEV(StartChannel)(struct USB2OTGUnit *, int chan, int quick);
228 int FNAME_DEV(AdvanceChannel)(struct USB2OTGUnit *, int chan);
229 void FNAME_DEV(FinalizeChannel)(struct USB2OTGUnit *, int chan);
231 #define CHAN_CTRL 0
232 #define CHAN_BULK 1
233 #define CHAN_INT1 2
234 #define CHAN_INT2 3
235 #define CHAN_INT3 4
236 #define CHAN_ISO1 5
237 #define CHAN_ISO2 6
238 #define CHAN_ISO3 7
240 #endif /* USB2OTG_INTERN_H */