PERFORCE change 161985 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Tue May 12 17:22:55 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=161985
Change 161985 by hselasky at hselasky_laptop001 on 2009/05/12 17:22:29
USB controller:
- finish atmegadci chip init
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/controller/atmegadci.c#24 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/controller/atmegadci.c#24 (text+ko) ====
@@ -1216,13 +1216,28 @@
sc->sc_bus.methods = &atmegadci_bus_methods;
USB_BUS_LOCK(&sc->sc_bus);
-#if 0
- /* XXX TODO - currently done by boot strap */
+
+ /* make sure USB is enabled */
+ ATMEGA_WRITE_1(sc, ATMEGA_USBCON,
+ ATMEGA_USBCON_USBE |
+ ATMEGA_USBCON_FRZCLK);
/* enable USB PAD regulator */
ATMEGA_WRITE_1(sc, ATMEGA_UHWCON,
- ATMEGA_UHWCON_UVREGE | ATMEGA_UHWCON_UIMOD);
-#endif
+ ATMEGA_UHWCON_UVREGE |
+ ATMEGA_UHWCON_UIMOD);
+
+ /* the following register sets up the USB PLL, assuming 16MHz X-tal */
+ ATMEGA_WRITE_1(sc, 0x49 /* PLLCSR */, 0x14 | 0x02);
+
+ /* wait for PLL to lock */
+ for (n = 0; n != 20; n++) {
+ if (!(ATMEGA_READ_1(sc, 0x49) & 0x01))
+ break;
+ /* wait a little bit for PLL to start */
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100);
+ }
+
/* make sure USB is enabled */
ATMEGA_WRITE_1(sc, ATMEGA_USBCON,
ATMEGA_USBCON_USBE |
@@ -1846,6 +1861,11 @@
/* clear connect change flag */
sc->sc_flags.change_connect = 0;
+ if (!sc->sc_flags.status_bus_reset) {
+ /* we are not connected */
+ break;
+ }
+
/* configure the control endpoint */
/* select endpoint number */
More information about the p4-projects
mailing list