tnt has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26840 )
Change subject: icE1usb fw: Tweak descriptors in preparation for dual port support
......................................................................
icE1usb fw: Tweak descriptors in preparation for dual port support
In dual port mode we can't have 388 bytes wMaxPacket size, that's
too much reserved bandwidth.
So we dial that back to 292 which is the minimum we can use. We need
4 bytes for header, then 256 byte of nominal transfer size then 32
more byte for potentially one more frame than nominal to compensate
differences between E1 clock and USB clock.
We obviously need to adapt the code filling up the packets to respect
that more restricted size ...
Signed-off-by: Sylvain Munaut <tnt(a)246tNt.com>
Change-Id: I700adeb909e7955db0d15c6e2beade3d38b21e01
---
M firmware/ice40-riscv/icE1usb/usb_desc_app.c
M firmware/ice40-riscv/icE1usb/usb_e1.c
2 files changed, 11 insertions(+), 13 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/40/26840/1
diff --git a/firmware/ice40-riscv/icE1usb/usb_desc_app.c
b/firmware/ice40-riscv/icE1usb/usb_desc_app.c
index ec01854..663be0b 100644
--- a/firmware/ice40-riscv/icE1usb/usb_desc_app.c
+++ b/firmware/ice40-riscv/icE1usb/usb_desc_app.c
@@ -90,7 +90,7 @@
.bEndpointAddress = USB_EP_E1_INT(0),
.bmAttributes = 0x03,
.wMaxPacketSize = 10,
- .bInterval = 3,
+ .bInterval = 4, /* every 4 ms */
},
},
.on = {
@@ -110,7 +110,7 @@
.bDescriptorType = USB_DT_EP,
.bEndpointAddress = USB_EP_E1_IN(0),
.bmAttributes = 0x05,
- .wMaxPacketSize = 388,
+ .wMaxPacketSize = 292,
.bInterval = 1,
},
.ep_data_out = {
@@ -118,7 +118,7 @@
.bDescriptorType = USB_DT_EP,
.bEndpointAddress = USB_EP_E1_OUT(0),
.bmAttributes = 0x05,
- .wMaxPacketSize = 388,
+ .wMaxPacketSize = 292,
.bInterval = 1,
},
.ep_fb = {
@@ -126,8 +126,8 @@
.bDescriptorType = USB_DT_EP,
.bEndpointAddress = USB_EP_E1_FB(0),
.bmAttributes = 0x11,
- .wMaxPacketSize = 8,
- .bInterval = 3,
+ .wMaxPacketSize = 3,
+ .bInterval = 3, /* every 2^(3-1) = 4 ms */
},
.ep_interrupt = {
.bLength = sizeof(struct usb_ep_desc),
@@ -135,7 +135,7 @@
.bEndpointAddress = USB_EP_E1_INT(0),
.bmAttributes = 0x03,
.wMaxPacketSize = 10,
- .bInterval = 3,
+ .bInterval = 4, /* every 4 ms */
},
},
},
diff --git a/firmware/ice40-riscv/icE1usb/usb_e1.c
b/firmware/ice40-riscv/icE1usb/usb_e1.c
index 8e78ffa..75811c2 100644
--- a/firmware/ice40-riscv/icE1usb/usb_e1.c
+++ b/firmware/ice40-riscv/icE1usb/usb_e1.c
@@ -128,10 +128,8 @@
/* Get some data from E1 */
int n = e1_rx_level(0);
- if (n > 64)
- n = 12;
- else if (n > 32)
- n = 10;
+ if (n > 32)
+ n = 9;
else if (n > 8)
n = 8;
else if (!n)
@@ -177,7 +175,7 @@
refill:
/* Refill it */
- ep_regs->bd[bdi].csr = USB_BD_STATE_RDY_DATA | USB_BD_LEN(388);
+ ep_regs->bd[bdi].csr = USB_BD_STATE_RDY_DATA | USB_BD_LEN(292);
/* Next BDI */
bdi ^= 1;
@@ -282,8 +280,8 @@
/* EP OUT: Queue two buffers */
ep_regs = _get_ep_regs(USB_EP_E1_FB(0));
- ep_regs->bd[0].csr = USB_BD_STATE_RDY_DATA | USB_BD_LEN(388);
- ep_regs->bd[1].csr = USB_BD_STATE_RDY_DATA | USB_BD_LEN(388);
+ ep_regs->bd[0].csr = USB_BD_STATE_RDY_DATA | USB_BD_LEN(292);
+ ep_regs->bd[1].csr = USB_BD_STATE_RDY_DATA | USB_BD_LEN(292);
/* EP Feedback: Pre-fill */
_usb_fill_feedback_ep();
--
To view, visit
https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26840
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-e1-hardware
Gerrit-Branch: master
Gerrit-Change-Id: I700adeb909e7955db0d15c6e2beade3d38b21e01
Gerrit-Change-Number: 26840
Gerrit-PatchSet: 1
Gerrit-Owner: tnt <tnt(a)246tNt.com>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange