shithub: front

Download patch

ref: 5028b882da353ad46ac81340db9e03ffae8f87db
parent: eff4b9365281325a37ead1c6ae8ed77823b7037f
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Dec 15 20:52:12 EST 2024

usbehci: implement portpower control for rootports

--- a/sys/src/9/port/usbehci.c
+++ b/sys/src/9/port/usbehci.c
@@ -1639,7 +1639,7 @@
 portlend(Ctlr *ctlr, int port, char *ss)
 {
 	Eopio *opio;
-	ulong s;
+	int s;
 
 	opio = ctlr->opio;
 	dprint("ehci %#p port %d: %s speed device: no longer owned\n",
@@ -1649,6 +1649,27 @@
 }
 
 static void
+portpower(Hci *hp, int port, int on)
+{
+	Ctlr *ctlr;
+	Eopio *opio;
+	int s;
+
+	ctlr = hp->aux;
+	opio = ctlr->opio;
+	eqlock(&ctlr->portlck);
+	ilock(ctlr);
+	s = opio->portsc[port-1] & ~(Pschange|Psstatuschg);
+	if(on)
+		s |= Pspower;
+	else
+		s &= ~Pspower;
+	opio->portsc[port-1] = s;
+	iunlock(ctlr);
+	qunlock(&ctlr->portlck);
+}
+
+static void
 portenable(Hci *hp, int port, int on)
 {
 	Ctlr *ctlr;
@@ -3221,7 +3242,6 @@
 {
 	Ctlr *ctlr;
 	Eopio *opio;
-	int i;
 
 	hp->highspeed = 1;
 	ctlr = hp->aux;
@@ -3243,10 +3263,6 @@
 
 	/* route all ports to us */
 	opio->config = Callmine;
-	coherence();
-
-	for (i = 0; i < hp->nports; i++)
-		opio->portsc[i] = Pspower;
 	iunlock(ctlr);
 	if(ehcidebug > 1)
 		dump(hp);
@@ -3263,8 +3279,9 @@
 	hp->epread = epread;
 	hp->epwrite = epwrite;
 	hp->seprintep = seprintep;
-	hp->portenable = portenable;
+	hp->portpower = portpower;
 	hp->portreset = portreset;
+	hp->portenable = portenable;
 	hp->portstatus = portstatus;
 	hp->type = "ehci";
 }
--