check for hs otg usb controller and dump settings. disable global usb irqs, and regis...
[AROS.git] / arch / arm-raspi / usb / poseidon / usbromstartup.c
blobe12e3abdec21bf84fc74eaf03efc99f7b5f31d6e
1 /* Very basic bootstrap for Poseidon in AROS kernel for enabling of USB booting and HID devices.
2 * PsdStackloader should be started during startup-sequence nonetheless */
4 #define DEBUG 1
6 #include <aros/asmcall.h>
7 #include <aros/debug.h>
8 #include <aros/symbolsets.h>
9 #include <exec/resident.h>
10 #include <proto/poseidon.h>
11 #include <proto/exec.h>
13 int __startup usbromstartup_entry(void)
15 return -1;
18 static const char name[];
19 static const char version[];
20 static const UBYTE endptr;
22 AROS_UFP3(static IPTR, usbromstartup_init,
23 AROS_UFHA(ULONG, dummy, D0),
24 AROS_UFHA(BPTR, seglist, A0),
25 AROS_UFHA(struct ExecBase *, SysBase, A6));
27 const struct Resident usbHook =
29 RTC_MATCHWORD,
30 (struct Resident *)&usbHook,
31 (APTR)&endptr,
32 RTF_COLDSTART,
33 41,
34 NT_TASK,
35 35,
36 name,
37 &version[5],
38 (APTR)usbromstartup_init
41 static const char name[] = "Poseidon ROM starter";
42 static const char version[] = "$VER:Poseidon ROM startup v41.1";
44 AROS_UFH3(static IPTR, usbromstartup_init,
45 AROS_UFHA(ULONG, dummy, D0),
46 AROS_UFHA(BPTR, seglist, A0),
47 AROS_UFHA(struct ExecBase *, SysBase, A6))
49 AROS_USERFUNC_INIT
51 struct Library *ps;
52 struct PsdHardware *phw;
54 D(bug("[USBROMStartup] Loading poseidon...\n"));
56 if((ps = OpenLibrary("poseidon.library", 4)))
58 APTR msdclass;
59 IPTR usecount = 0;
60 ULONG bootdelay = 4;
62 D(bug("[USBROMStartup] Adding classes...\n"));
64 psdAddClass("hub.class", 0);
65 if(!(psdAddClass("hid.class", 0)))
67 psdAddClass("bootmouse.class", 0);
68 psdAddClass("bootkeyboard.class", 0);
70 msdclass = psdAddClass("massstorage.class", 0);
72 D(bug("[USBROMStartup] Added chipset drivers...\n"));
74 /* load the raspi usb hardware driver */
75 while((phw = psdAddHardware("usb2otg.device", 0)))
77 D(bug("[USBROMStartup] Added usb2otg.device unit %u\n", 0));
79 psdEnumerateHardware(phw);
82 D(bug("[USBROMStartup] Scanning classes...\n"));
83 psdClassScan();
84 D(bug("[USBROMStartup] classes enumerated\n"));
86 if(msdclass)
88 D(bug("[USBROMStartup] waiting for hubs..\n"));
89 psdDelayMS(1000); // wait for hubs to settle
90 D(bug("[USBROMStartup] checking for massstorage devices..\n"));
91 psdGetAttrs(PGA_USBCLASS, msdclass, UCA_UseCount, &usecount, TAG_END);
92 D(bug("[USBROMStartup] %d masstorage devices found\n", usecount));
93 if(usecount > 0)
95 D(bug("[USBROMStartup] adding boot delay\n"));
97 psdAddErrorMsg(RETURN_OK, (STRPTR)name,
98 "Delaying further execution by %ld second(s) (boot delay).",
99 bootdelay);
100 if(bootdelay > 1)
102 psdDelayMS((bootdelay-1)*1000);
104 } else {
105 psdAddErrorMsg(RETURN_OK, (STRPTR)name, "Boot delay skipped, no mass storage devices found.");
109 D(bug("[USBROMStartup] cleaning up .. \n"));
110 CloseLibrary(ps);
112 D(bug("[USBROMStartup] Finished...\n"));
114 return 0;
116 AROS_USERFUNC_EXIT
119 static const UBYTE endptr = 0;