usb: enable writing with DMA

Nothing particular to change, simply make sure that the DMA channels
have higher priority than the USB module, otherwise the BEMP interrupt
might be executed before the DMA frees the channel, resulting in the
transfer failing because the channel is still busy.

Also reduce BUSWAIT since it works even on high overclock levels, and
keeping it high won't help increase performance.
This commit is contained in:
Lephe 2021-05-07 17:41:36 +02:00
parent a547235f8f
commit 31dcc6fd6c
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
4 changed files with 10 additions and 11 deletions

View File

@ -242,13 +242,13 @@ static void configure(void)
extern void inth_dma_ae(void);
intc_handler(0xbc0, inth_dma_ae, 32);
/* Set interrupt priority to 3 (IPRE[15..12] for first three channels,
IPRF[11..8] for last two and error gate */
/* Set interrupt priority to 3, except 11 for the channels that are
used by the USB driver */
intc_priority(INTC_DMA_DEI0, 3);
intc_priority(INTC_DMA_DEI1, 3);
intc_priority(INTC_DMA_DEI2, 3);
intc_priority(INTC_DMA_DEI3, 3);
intc_priority(INTC_DMA_DEI4, 3);
intc_priority(INTC_DMA_DEI3, 9);
intc_priority(INTC_DMA_DEI4, 9);
intc_priority(INTC_DMA_DEI5, 3);
intc_priority(INTC_DMA_DADERR, 3);

View File

@ -234,8 +234,6 @@ static void finish_round(struct transfer volatile *t, int pipe)
t->size -= t->flying;
t->flying = 0;
if(pipe) usb_log("%d left\n", t->size);
/* Account for auto-transfers */
if(t->used == pipe_bufsize(pipe)) t->used = 0;
@ -293,9 +291,9 @@ static void write_round(struct transfer volatile *t, int pipe)
/* Use DMA channel 3 for D0F and 4 for D1F */
int channel = (ct == D0F) ? 3 : 4;
int rc = dma_transfer_async(channel, block_size, size,
bool ok = dma_transfer_async(channel, block_size, size,
t->data, DMA_INC, (void *)FIFO, DMA_FIXED, callback);
usb_log("dma_transfer_async: %d, bs=%d, size=%d, fifo=%d\n", rc, block_size, size, ct);
if(!ok) usb_log("DMA async failed on channel %d!\n", channel);
}
else
{

View File

@ -85,8 +85,8 @@ static void hpoweron_write(void)
USB.SYSCFG.SCKE = 1;
for(int i = 0; i < 10; i++) __asm__ volatile("nop");
/* Set BUSWAIT to a safe value, hopefully avoiding overlock problems */
USB.BUSWAIT.word = 15;
/* Set BUSWAIT to a safe value */
USB.BUSWAIT.word = 5;
}
static void hpoweroff(void)
@ -170,7 +170,7 @@ int usb_open(usb_interface_t const **interfaces, gint_call_t callback)
USB.BEMPENB.word = 0x0000;
intc_handler_function(0xa20, GINT_CALL(usb_interrupt_handler));
intc_priority(INTC_USB, 15);
intc_priority(INTC_USB, 8);
return 0;
}

View File

@ -8,6 +8,7 @@
#include <gint/defs/attributes.h>
#include <gint/timer.h>
#include <gint/gint.h>
#include <gint/usb.h>
//---
// Configuration of the communication surface between module and host