Currently it's called 'reset' but really it's the init because
it sets up the memory allocation and such. We rename that to e1f_init
and introduce a true e1f_reset that only clears the fifo and resets
the pointers
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I425c38e93fb235d5c5fc6f3a5027ac49cf3466d9
Just from this patch, it's not clear why this is better, but
it makes things a bit cleaner in upcoming patches
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I4c75bb4eb20c1d1aaa1695e95bdf0417bbf3bf76
This is a bit cleaner when masking in/out those rather than using
the specific vaue that has all bits set.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: If2ca8efff37cb8fd1f1841656537ea8ad11ef55c
There is no remote side alarm if there is no remote-side ...
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I78f43eded5ed6ffde9d86726ccee2b776a3f4675
* FIFO target level :
- The '8 * 16' makes no sense as the FIFO was 128 so this
is the "full" case and could never be that high.
- We tighten up the margin around 5 * 16 which is the "target"
level for the FIFO
* FIFO size :
We also increase the FIFO size to 256 frames. This doesn't
actually affect latency since the target level is the same,
but it allows more leeway to recover without data loss in
case something goes wrong.
* Ticks :
We don't bother using ticks ... the current algo wasn't
working (or rather not doing anything all that useful),
because the difference between USB clock and E1 clock is
tiny and measured over 1 ms, it's not meaningful.
So for the time being we just sent the nominal rate biased
with the FIFO level to keep it on target and this seems
to work fine.
It'd be nice to have a good long term estimate of the rate
to minimize the jitter, but it doesn't seem to be strictly
required for operation for now.
* Misc cleanup :
Just do all in one function instead of splitting the check
if BD needs refill and the actual refill.
This gets rid of sporadic 'TX FIFO Overflow' conditions
by properly handling the case where we have a bit too much
data.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ibd3bc9080961cc56093e43ab9a824840e84c24d2
This prevents inlining of the code, and is completely
unecessary.
(1) It will be filled a bit later
(2) We don't have any meaningful feedback to provide anyway
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I6e97bc79d1fe50950bb1f7cd71d8c428e928d4ae
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@246tNt.com>
Change-Id: I700adeb909e7955db0d15c6e2beade3d38b21e01
Currently all the users of those function just statically use port 0
only.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I17671be65543f5a2bf3d16ba2b5a5081eb38ebdf
No benefit to use uint8_t and for consistency with later patches,
use 'int' here too.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I50a76476af844acf20436b9d410cb917b723590d
Several issues :
- The reported length includes the CRC so it's minus 6 and
not minus 4. (2 for CRC, 4 for header)
- Cast length to int to make it signed so the minus works
- If the packet is empty, this would be negative (no header),
underflow, and then try to submit a giant number of frames
to the E1 hardware
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ib754e460290fe2e1551a0090e30a51846131d07d
Avoid hardcoded ids everywhere. This also prepares a bit for
multi-port support in the future.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I89c86ac6afd52dd19e3383b38c3311276a090d50
They might be used somewhere else ... just don't handle them, but
let someone else potentially do it.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ie1bce4565d14d6635d4a32c2a08f64728132a75e
This way they can be used in other parts of the code more easily.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I565d9a43bc26b99bc385b46522e7da6a207b2412
It was pointed out that this should be 0 since we trigger
detach ourselves, we don't need a bus reset.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Id7051ce00863c03e3498f4bab0a7124938e197c0
Some of it was written before some of the helpers were provided
by the no2usb code and was never update. So instead of manually
setting up a bunch of stuff we make proper use of some of the provided
helpers.
Side effects:
- We recall e1_init(0,0) when enabling which happens to work
around a bug ... proper fix coming later.
- The 'dual BD' config for EP 0x81 and 0x83 is fixed. It didn't
matter before since we overwrote it anyway, but now it's used
and so needs to be correct.
- The descriptors don't have the isoc endpoints at all in the
"OFF" alt setting.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I33c92896acfba023abe0152d63dff3afe43b53cd
Scan over every odd E1 frame TS0 byte to check if the A-bit is set,
indicating a remote alarm. If so, set yellow LED and report via the
error flags communicated to the host by USB interrupt transfer.
Change-Id: Ic4f57cf79bd32cf75f81ef3073cb8d4a2d1857d8
Those are actually disabled right now, but since the submodule got
updated and the protocol struct/defines changed, this updates them
anyway so you can uncommend/enable them without causing a build
failure
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I1895702eac9c6c392f24327b12f9ba3651e3249a
So far we started on altsetting 0->1 transition, but we didn't stop
on the inverse 1->0 which typically happens when the host software
(osmo-e1d) stops.
Closes: OS#4676
Change-Id: I8e4817f68d8893ab2dc98fe93ce9a673e209ca63
This introduces a number of vendor-specific control requests for
configuration of the icE1usb from the host software.
Closes: OS#4675
Change-Id: I9d28566ba21a2a78def5e4a0ba07ecbc4a583aa9
Those clear bits are only set once at start-up and then later
explicitly. They shouldn't be stored with the user configuration
in state variables.
Change-Id: If38e86aefea7f1be4e1ff5a88860f8be593eeedc
Whenever Rx is aligned, the green LED is permanently on.
Whenever Rx is not aligned, the green LED is blinking.
What's missing is to check for E1 clock ticks and turn the LED off
completely if there are no clock ticks.
Change-Id: I42d53544858dbbbae5206d9a62b08672966c9ebf
This should enable the host to detect discontinuities, and also know
when a multiframe starts.
Related: OS#4674
Change-Id: Ie0688647c56ebfc2e08de44f8ec569e1c2cd6a28
The position indicates where we are in terms of frame and multiframe.
The related code was ported over from e1-tracer.
Related: OS#4674
Change-Id: I9e59d86a2e8f4e85ca84c592438ad79966b49448
This resembles what we do for other firmware targets, such as simtrace2,
osmo-ccid-firmware, etc.
As we have multiple different firmware, hardware, gateware projects in
this repository, and they each may have separate tags, we now require
that there are project specific tags. So for example, tags with a
prefix of icE1usb-fw for the firmware versions.
symlinks for easy use by scripts etc. are generated, always pointing to
the last-built versioned filename.
Change-Id: Ia308587e36a79c27fdb285e369a9c921ee65995f
This was broken when moving the design to non-hacked multi channel
E1.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I5e7ce22935609bc64333e2d5c310eb7493555a93
This was never used and doesn't really belong here, this was just
an example descriptor in the original firmware this is based on.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ic72c991eb7a566b227484c7cde2c305d58202219
This is a remanence of old firmware of the icepick on which that
design is based on.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I0bc27da4faa91de983cd5f355553ecaa13754266
Also default build to it since very few people would want to build
firmware targetted to the prototypes ...
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
The documentation always had the rRX tick in the LSB which
is consistent with having the RX units before TX.
They can be read as 16 bit value anyway so there isn't any
performance impact.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Some more code could probably be unified with the "normal" usb E1 adapter
to both reduce code duplication but also offer 'sniff' function to the
E1 adapter.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Currently only the icE1usb-proto is supported. Adaptation for the
final production hardware is yet to be done.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>