From 5028b882da353ad46ac81340db9e03ffae8f87db Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 16 Dec 2024 01:52:12 +0000 Subject: [PATCH] usbehci: implement portpower control for rootports --- sys/src/9/port/usbehci.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/sys/src/9/port/usbehci.c b/sys/src/9/port/usbehci.c index 9ab389456..cea4785e4 100644 --- a/sys/src/9/port/usbehci.c +++ b/sys/src/9/port/usbehci.c @@ -1639,7 +1639,7 @@ static void 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", @@ -1648,6 +1648,27 @@ portlend(Ctlr *ctlr, int port, char *ss) opio->portsc[port-1] = s | Psowner; } +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) { @@ -3221,7 +3242,6 @@ init(Hci *hp) { Ctlr *ctlr; Eopio *opio; - int i; hp->highspeed = 1; ctlr = hp->aux; @@ -3243,10 +3263,6 @@ init(Hci *hp) /* 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 @@ ehcilinkage(Hci *hp) 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"; }