Commit Graph

17 Commits

Author SHA1 Message Date
Sylvain Munaut 2de84f804e icE1usb fw: Better flow regulation mechanism
* 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
2022-01-09 19:19:14 +01:00
Sylvain Munaut 3da5151569 icE1usb fw: Add multi-port support for e1.{c,h}
Currently all the users of those function just statically use port 0
only.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I17671be65543f5a2bf3d16ba2b5a5081eb38ebdf
2022-01-09 17:21:04 +01:00
Sylvain Munaut 2c0c136b7a icE1usb fw: Misc cosmetic cleanup in e1.{c,h} / usb_e1.c
Moving things around, comments, spacing, ... nothing functional.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Icc2a6ef6b03c89dd92e661a01d219e42dbf7067d
2022-01-09 17:21:04 +01:00
Sylvain Munaut 35856a1d61 icE1usb fw: Don't expose some E1 helper functions globally
Not used anywhere and really shouldn't be

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I1e339d1b8faecffba5f8d73588b376edc7a75a96
2022-01-09 17:21:04 +01:00
Harald Welte 51baa368ce icE1usb firmware: Detect A-bit in TS0; report via USB + LED
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
2022-01-02 12:42:35 +01:00
Harald Welte 805f2cf16e icE1usb fw: Expose error conditions from E1 driver
This will allow the USB interface code to report the errors to the
host PC.

Related: OS#4674
Change-Id: Iba3e00a2b28a2fef6dbd986bfc706c1619c3a3ed
2021-01-05 23:25:34 +01:00
Harald Welte 9469e046f1 icE1usb fw: USB control request handling
This introduces a number of vendor-specific control requests for
configuration of the icE1usb from the host software.

Closes: OS#4675
Change-Id: I9d28566ba21a2a78def5e4a0ba07ecbc4a583aa9
2021-01-05 23:24:32 +01:00
Harald Welte 6add0aa3e4 icE1usb fw: Internal API for configuring E1 rx/tx config register
Related: OS#4675
Change-Id: Ib23f9b99f169ab18d730bcf67b97a7b6bf863e98
2021-01-05 23:24:28 +01:00
Harald Welte 7f74fe6e48 icE1usb fw: Don't store E1_*_CR_*_CLR in variables
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
2020-12-27 15:16:19 +01:00
Harald Welte f74dad7b60 icE1usb fw: Put E1 IP core register related #defines in e1_hw.h
Related: OS#4675
Change-Id: I6783f473e6bb7dd08a5b5714bdd9b5aac0f28f0d
2020-12-27 14:09:02 +01:00
Harald Welte 5276567b24 icE1usb fw: Use green per-port LED to indicate alignment status
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
2020-12-20 23:20:21 +00:00
Harald Welte daff4f6463 icE1usb fw: Have e1_rx_need_data() optionally return FIFO position
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
2020-12-20 23:20:21 +00:00
Harald Welte 175b37c42f icE1usb fw: Use register bit #define instead of magic number
Change-Id: Ic824ce5a6605c96989fefbf92f365bff618dccb2
2020-12-20 23:20:21 +00:00
Harald Welte a59ef2bb3f icE1usb fw: define e1_data_ptr() using e1_data_ofs()
It's best to compute the offset only at one place and use that
computation elsewhere.

Change-Id: I9a6cce07ea8b6eff1527215de00621da960b0472
2020-12-20 23:20:21 +00:00
Harald Welte 30fc560017 icE1usb fw: cosmetic: more comments in the code
Change-Id: I445bb2f92b6dcfe29ac20109ea2e63efb31051a1
2020-12-20 23:20:21 +00:00
Sylvain Munaut de20fb713d firmware/ice40-riscv: Fix a couple of 'mixed signedness' warnings
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I31343263d7dab88a25254258cef44c6c2ddc730a
2020-10-29 13:24:50 +01:00
Sylvain Munaut bc9f5c4219 fw/icE1usb: Import firmware for the icE1usb and icE1usb-proto boards
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>
2020-09-14 10:56:49 +02:00