Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 May 2009 17:22:53 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 161985 for review
Message-ID:  <200905121722.n4CHMrZm029342@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=161985

Change 161985 by hselasky@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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905121722.n4CHMrZm029342>