Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
#define USB2OTG_HOSTCHAN_DMABUFF (0x1c)
#define USB2OTG_HOST_CHANREGSIZE (0x20)

#define USB2OTG_HOSTCHAR_MAXPACKETSIZE(x) ((x) & 1023)
#define USB2OTG_HOSTCHAR_MAXPACKETSIZE(x) ((x) & 0x7ff)
#define USB2OTG_HOSTCHAR_EPNO(x) (((x) & 0x0f) << 11)
#define USB2OTG_HOSTCHAR_EPDIR(x) (((x) & 1) << 15)
#define USB2OTG_HOSTCHAR_ADDR(x) (((x) & 0x7f) << 22)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm-native/soc/broadcom/2708/usb/usb2otg/usb2otg.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##begin config
version 2.0
version 2.1
libbase USB2OTGBase
libbasetype struct USB2OTGDevice
libbasetypeextern struct Device
Expand Down
5 changes: 3 additions & 2 deletions arch/arm-native/soc/broadcom/2708/usb/usb2otg/usb2otg_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ struct Unit * FNAME_DEV(OpenUnit)(struct IOUsbHWReq *ioreq,
* NPTxFEmpLvl=1 → NPTXFEMP only fires when fully drained, so
* OUT-arming code doesn't queue while stale data is in FIFO.
*/
otg_RegVal = rd32le(USB2OTG_AHB);
/* As at device init (and dwc2 on BCM2835): wait for AXI writes */
otg_RegVal = rd32le(USB2OTG_AHB) & ~0x1f;
otg_RegVal |= USB2OTG_AHB_DMAENABLE
| USB2OTG_AHB_AXIBURSTLENGTH
| USB2OTG_AHB_WAITFORAXIWRITES
| USB2OTG_AHB_INTENABLE
| USB2OTG_AHB_TRANSFEREMPTYLEVEL; /* NPTxFEmpLvl = fully empty */
wr32le(USB2OTG_AHB, otg_RegVal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include LC_LIBDEFS_FILE

#include <aros/debug.h>
#include <aros/atomic.h>
#include <aros/libcall.h>
#include <aros/asmcall.h>
#include <aros/symbolsets.h>
Expand Down Expand Up @@ -911,7 +912,8 @@ static inline BOOL usb2otg_sof_gate_arm(struct USB2OTGUnit *unit, ULONG frames)
tr->tr_node.io_Command = TR_ADDREQUEST;
tr->tr_time.tv_secs = frames / 1000;
tr->tr_time.tv_micro = (frames % 1000) * 1000;
unit->hu_SofGateBusy |= 1 << i;
/* Atomic: the gate softint clears bits from any CPU */
AROS_ATOMIC_OR(unit->hu_SofGateBusy, 1 << i);
unit->hu_SofGateDue[i] = due;
SendIO(&tr->tr_node);
return TRUE;
Expand Down
132 changes: 89 additions & 43 deletions arch/arm-native/soc/broadcom/2708/usb/usb2otg/usb2otg_intr.c

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions arch/arm-native/soc/broadcom/2708/usb/usb2otg/usb2otg_iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,10 @@ static BOOL iso_halted(struct USB2OTGUnit *unit, struct USB2OTGIso *is, ULONG in
* Move the bound endpoint on, from the SOF or the previous halt: start a
* packet that is due, or (split) issue the sequence's next transaction.
* is_Next keeps it to one packet an interval; ODDFRM holds the channel to
* the target. hu_Lock held. FALSE if nothing is queued.
* the target. hu_Lock held. FALSE if nothing is queued; *done is set if a
* request finished.
*/
static BOOL iso_kick(struct USB2OTGUnit *unit, struct USB2OTGIso *is, UWORD now)
static BOOL iso_kick(struct USB2OTGUnit *unit, struct USB2OTGIso *is, UWORD now, BOOL *done)
{
UWORD target = (now + 1) & USB2OTG_HFNUM_MASK;

Expand All @@ -484,8 +485,9 @@ static BOOL iso_kick(struct USB2OTGUnit *unit, struct USB2OTGIso *is, UWORD now)
if ((now >> 3) != is->is_Frame)
{
is->is_DropLate++;
/* The caller Causes once hu_Lock is released */
if (iso_split_drop(unit, is))
FNAME_DEV(Cause)(unit->hu_USB2OTGBase, &unit->hu_PendingInt);
*done = TRUE;
return TRUE;
}
iso_arm_split(is);
Expand All @@ -506,6 +508,9 @@ static BOOL iso_kick(struct USB2OTGUnit *unit, struct USB2OTGIso *is, UWORD now)

if (!is->is_Split)
{
/* Room in the periodic request queue, or the next SOF */
if (((rd32le(USB2OTG_HOSTFIFOSTATUS) >> 16) & 0xff) < 2)
return TRUE;
/* Behind (a slow start or a stall): restart from here, no burst */
if (!iso_frame_le(target, is->is_Next))
is->is_Next = target;
Expand Down Expand Up @@ -561,21 +566,27 @@ void usb2otg_iso_sof(struct USB2OTGUnit *unit, ULONG hfnum)
/* A transaction whose halt never came must not stop the stream */
if (is->is_Armed && ++is->is_Age >= USB2OTG_ISO_STUCK)
{
if (is->is_Age == USB2OTG_ISO_STUCK)
/* Direct periodic channels halt on their own; CHDIS only for splits */
if (is->is_Age == USB2OTG_ISO_STUCK && is->is_Split)
wr32le(USB2OTG_CHANNEL_REG(is->is_Chan, CHARBASE),
rd32le(USB2OTG_CHANNEL_REG(is->is_Chan, CHARBASE)) |
USB2OTG_HOSTCHAR_ENABLE | USB2OTG_HOSTCHAR_DISABLE);
else if (is->is_Age >= 2 * USB2OTG_ISO_STUCK)
{
bug("[USB2OTG:ISO] chan %d never halted, packet dropped\n", (int)is->is_Chan);
bug("[USB2OTG:ISO] chan %d never halted, packet dropped (HPTX %08x)\n", (int)is->is_Chan,
rd32le(USB2OTG_HOSTFIFOSTATUS));
is->is_Armed = FALSE;
if (iso_split_drop(unit, is))
/* Still enabled: reset, or iso_kick() waits on it forever */
if (!is->is_Split &&
(rd32le(USB2OTG_CHANNEL_REG(is->is_Chan, CHARBASE)) & USB2OTG_HOSTCHAR_ENABLE))
usb2otg_exorcise_channel(is->is_Chan);
if (is->is_Split ? iso_split_drop(unit, is) : iso_packet_done(unit, is, FALSE, 0))
wake = TRUE;
}
continue;
}

if (!iso_kick(unit, is, now) && ++is->is_Idle > USB2OTG_ISO_LINGER)
if (!iso_kick(unit, is, now, &wake) && ++is->is_Idle > USB2OTG_ISO_LINGER)
{
/* Not just a slow requeue: hand the channel back, split state cleared */
bug("[USB2OTG:ISO] dev %d ep %d %s%s: %u packets, %u lost (split: out %u, in-ss %u, in-cs %u, late %u)\n",
Expand Down Expand Up @@ -626,7 +637,7 @@ void usb2otg_iso_chan_irq(struct USB2OTGUnit *unit, int chan, ULONG intr)
done = iso_halted(unit, is, is->is_Pending, now);
/* Direct: the next packet now, in case the SOF that would arm it is late */
if (!is->is_Split)
iso_kick(unit, is, now);
iso_kick(unit, is, now, &done);
#if defined(__AROSEXEC_SMP__)
KrnSpinUnLock(&unit->hu_Lock);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ BOOL FNAME_DEV(SetupChannel)(struct USB2OTGUnit *otg_Unit, int chan)
if (queue == NULL)
{
otg_Unit->hu_QuarSetTick[chan] = otg_Unit->hu_WdTicks;
otg_Unit->hu_DeadChannels |= (1 << chan);
AROS_ATOMIC_OR(otg_Unit->hu_DeadChannels, 1 << chan);
usb2otg_finish_setup_error(otg_Unit, chan, req, UHIOERR_HOSTERROR);
return FALSE;
}
Expand All @@ -371,7 +371,7 @@ BOOL FNAME_DEV(SetupChannel)(struct USB2OTGUnit *otg_Unit, int chan)
KrnSpinLock(&otg_Unit->hu_Lock, NULL, SPINLOCK_MODE_WRITE);
#endif
otg_Unit->hu_QuarSetTick[chan] = otg_Unit->hu_WdTicks;
otg_Unit->hu_DeadChannels |= (1 << chan);
AROS_ATOMIC_OR(otg_Unit->hu_DeadChannels, 1 << chan);
otg_Unit->hu_Channel[chan].hc_Request = NULL;
usb2otg_requeue(otg_Unit, queue, req, TRUE);
usb2otg_sof_gate_wake(otg_Unit);
Expand Down
Loading