From 2696c4252ff4b284ebcdd03726bbfbbcd873ece1 Mon Sep 17 00:00:00 2001 From: schulz Date: Wed, 30 Jan 2019 20:03:27 +0000 Subject: [PATCH] toggle PID on successful transfer only if odd number of packets was sent git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@55649 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- .../arm-native/soc/broadcom/2708/usb/usb2otg/usb2otg_intr.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/arm-native/soc/broadcom/2708/usb/usb2otg/usb2otg_intr.c b/arch/arm-native/soc/broadcom/2708/usb/usb2otg/usb2otg_intr.c index aae1620ea5..f23296dcda 100644 --- a/arch/arm-native/soc/broadcom/2708/usb/usb2otg/usb2otg_intr.c +++ b/arch/arm-native/soc/broadcom/2708/usb/usb2otg/usb2otg_intr.c @@ -204,9 +204,16 @@ void FNAME_DEV(GlobalIRQHandler)(struct USB2OTGUnit *USBUnit, struct ExecBase *S if (tmp == 0x23) { - /* Toggle PID */ - USBUnit->hu_PIDBits[req->iouh_DevAddr] ^= (2 << (2 * req->iouh_Endpoint)); - req->iouh_Actual = req->iouh_Length; + /* Determine number of packets involved in last transfer. If it is even, toggle + the PID (the OTG was toggling it itself) */ + int txsize = rd32le(USB2OTG_CHANNEL_REG(chan, TRANSSIZE)) & 524287; + int pktcnt = (txsize + req->iouh_MaxPktSize - 1) / req->iouh_MaxPktSize; + if (pktcnt & 1) + { + /* Toggle PID */ + USBUnit->hu_PIDBits[req->iouh_DevAddr] ^= (2 << (2 * req->iouh_Endpoint)); + } + req->iouh_Actual += txsize; req->iouh_Req.io_Error = 0; } else if (tmp & 0x80) -- 2.11.4.GIT