Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Sep 2016 19:06:59 +0000 (UTC)
From:      Luiz Otavio O Souza <loos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r306050 - head/sys/arm/ti/am335x
Message-ID:  <201609201906.u8KJ6xSY050392@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: loos
Date: Tue Sep 20 19:06:58 2016
New Revision: 306050
URL: https://svnweb.freebsd.org/changeset/base/306050

Log:
  If present, honor the USB port mode (host or peripheral) set on DTS, if not,
  keep the beaglebone defaults: USB0 -> peripheral/gadget, USB1 -> host.
  
  This is only a workaround as in fact fact this hardware is capable of detect
  the USB port mode based on type of cable and act according with the detected
  mode.  Unfortunately the driver does not handle that at moment.
  
  MFC after:	3 days
  Sponsored by:	Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/ti/am335x/am335x_musb.c

Modified: head/sys/arm/ti/am335x/am335x_musb.c
==============================================================================
--- head/sys/arm/ti/am335x/am335x_musb.c	Tue Sep 20 18:53:42 2016	(r306049)
+++ head/sys/arm/ti/am335x/am335x_musb.c	Tue Sep 20 19:06:58 2016	(r306050)
@@ -237,6 +237,7 @@ static int
 musbotg_attach(device_t dev)
 {
 	struct musbotg_super_softc *sc = device_get_softc(dev);
+	char mode[16];
 	int err;
 	uint32_t reg;
 
@@ -308,10 +309,19 @@ musbotg_attach(device_t dev)
 	}
 
 	sc->sc_otg.sc_platform_data = sc;
-	if (sc->sc_otg.sc_id == 0)
-		sc->sc_otg.sc_mode = MUSB2_DEVICE_MODE;
-	else
-		sc->sc_otg.sc_mode = MUSB2_HOST_MODE;
+	if (OF_getprop(ofw_bus_get_node(dev), "dr_mode", mode,
+	    sizeof(mode)) > 0) {
+		if (strcasecmp(mode, "host") == 0)
+			sc->sc_otg.sc_mode = MUSB2_HOST_MODE;
+		else
+			sc->sc_otg.sc_mode = MUSB2_DEVICE_MODE;
+	} else {
+		/* Beaglebone defaults: USB0 device, USB1 HOST. */
+		if (sc->sc_otg.sc_id == 0)
+			sc->sc_otg.sc_mode = MUSB2_DEVICE_MODE;
+		else
+			sc->sc_otg.sc_mode = MUSB2_HOST_MODE;
+	}
 
 	/*
 	 * software-controlled function



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