Make the FIFO configuration a bit more flexible for the DWC OTG in

device side mode.
This commit is contained in:
Hans Petter Selasky 2015-05-18 16:18:04 +00:00
parent dfad72a7d7
commit 2624de5c56
2 changed files with 21 additions and 21 deletions

View File

@ -297,32 +297,29 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode)
if (x < sc->sc_dev_in_ep_max) {
uint32_t limit;
limit = (x == 1) ? DWC_OTG_MAX_TXN :
(DWC_OTG_MAX_TXN / 2);
limit = (x == 1) ? MIN(DWC_OTG_TX_MAX_FIFO_SIZE,
DWC_OTG_MAX_TXN) : MIN(DWC_OTG_MAX_TXN / 2,
DWC_OTG_TX_MAX_FIFO_SIZE);
if (fifo_size >= limit) {
DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x),
((limit / 4) << 16) |
(tx_start / 4));
tx_start += limit;
fifo_size -= limit;
pf->usb.max_in_frame_size = 0x200;
pf->usb.support_in = 1;
/* see if there is enough FIFO space */
if (limit <= fifo_size) {
pf->max_buffer = limit;
} else if (fifo_size >= 0x80) {
DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x),
((0x80 / 4) << 16) | (tx_start / 4));
tx_start += 0x80;
fifo_size -= 0x80;
pf->usb.max_in_frame_size = 0x40;
pf->usb.support_in = 1;
} else {
pf->usb.is_simplex = 1;
DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x),
(0x0 << 16) | (tx_start / 4));
limit = MIN(DWC_OTG_TX_MAX_FIFO_SIZE, 0x40);
if (limit <= fifo_size) {
pf->usb.support_in = 1;
} else {
pf->usb.is_simplex = 1;
limit = 0;
}
}
/* set FIFO size */
DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x),
((limit / 4) << 16) | (tx_start / 4));
tx_start += limit;
fifo_size -= limit;
pf->usb.max_in_frame_size = limit;
} else {
pf->usb.is_simplex = 1;
}

View File

@ -38,6 +38,9 @@
#define DWC_OTG_SLOT_IDLE_MAX 3
#define DWC_OTG_SLOT_IDLE_MIN 2
#define DWC_OTG_NAK_MAX 8 /* 1 ms */
#ifndef DWC_OTG_TX_MAX_FIFO_SIZE
#define DWC_OTG_TX_MAX_FIFO_SIZE DWC_OTG_MAX_TXN
#endif
#define DWC_OTG_READ_4(sc, reg) \
bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg)