ref: 837c596bdf90e7a723864b65a3bac84155ee66f6
parent: 5028b882da353ad46ac81340db9e03ffae8f87db
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Dec 16 00:14:45 EST 2024
usbdwc: preserve Prtpwr bit for portstatus, turn off power by default, handle channel timeout preserve the Prtpwr bit in portstatus instead of unconditionally setting it. turn off port powert on init. (let usbd will turn it on). make chanio() halt the channel and error out when interrupt status is 0 after timout. this happens when the port is powered off.
--- a/sys/src/9/bcm/usbdwc.c
+++ b/sys/src/9/bcm/usbdwc.c
@@ -234,14 +234,20 @@
int intr, ointr, chan;
ulong start, now;
+ if(waserror()){
+ chanhalt(ep, hc);
+ nexterror();
+ }
chan = hc - ctlr->regs->hchan;
for(;;){
-restart:
+ restart:
tsleep(&ctlr->chanintr[chan], chandone, hc, 1000);
if((intr = hc->hcint) == 0)
- goto restart;
- if(intr & Chhltd)
+ error("channel timeout");
+ if(intr & Chhltd){
+ poperror();
return intr;
+ }
ointr = intr;
now = start = fastticks(0);
do{
@@ -252,6 +258,7 @@
(now - start) > 60)
dprint("ep%d.%d await %x after %ldµs %x -> %x\n",
ep->dev->nb, ep->nb, mask, now - start, ointr, intr);
+ poperror();
return intr;
}
if((intr & mask) == 0){
@@ -686,7 +693,7 @@
dprint("usbdwc: FIFO depth %d sizes rx/nptx/ptx %8.8ux %8.8ux %8.8ux\n",
n, r->grxfsiz, r->gnptxfsiz, r->hptxfsiz);
- r->hport0 = Prtpwr|Prtconndet|Prtenchng|Prtovrcurrchng;
+ r->hport0 = Prtconndet|Prtenchng|Prtovrcurrchng;
r->gintsts = ~0;
r->gintmsk = Hcintr;
r->gahbcfg |= Glblintrmsk;
@@ -982,7 +989,7 @@
s = r->hport0;
b = s & (Prtconndet|Prtenchng|Prtovrcurrchng);
if(b != 0)
- r->hport0 = Prtpwr | b;
+ r->hport0 = (s & Prtpwr) | b;
b = 0;
if(s & Prtconnsts)
b |= HPpresent;
--
⑨