Rather basic and not super well tested, use with caution
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I5f9ce6621492be967d6a44d31f270e107f3ef686
Note that this is read-only. We drop all data from the host
because we can't have the host reconfigure the module ...
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ieb6a653ece882c5f90ab27da1bca04c94184dc5a
This only initializes the GPS module and keeps track of the
antenna and fix status
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I24811f872fafefc7f8dfaa3028c4288001a87d2f
This allows the host driver to obtain the current errors, as they would
normally be reported over the IRQ endpoint. One important use case for
this is to obtain the initial error state when the driver starts up.
Change-Id: I6301bb23234c66afe083ceb500cff8a40813e8b6
We have upcoming ones not related to the E1 interface, so really
it make more sense to not have those in usb_e1.c
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I686916bb2b2cb90e94ac9c595deab19f189fcd49
The hardware has a tick counter (constantly incremented every
cycle) and a pps counter (which is the tick counter captured
at the pps edge).
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I2122ea3d636c8a430c6eb945b0c11e26e02fee43
The 32 bit register is split in different fields to speed up
access to the 'in' field. The oe/out fields can't be split because
all writes are 32 bit wide (i.e. no support for byte enable in the
gateware)
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ic25377bb777e5d25939f0e8cfe6b7c6ef8641f6d
Also don't force enable the runner in the e1_platform_led_set
callback.
Due to GPIO shortage, the E1 leds control are multiplexed with
SPI so this adds a method to temporarely stop the runner so SPI
can be used.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ie671daab5ee5e0b5f58de9d4fef1f0ca7d6d02b6
Those are already in the gateware, this just adds the define for
them.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I87fae20e4a987c2186d5db6747e03e7ce9789a8f
The init already takes care of both port and also calling
e1_init, so it makes sense to have a usb_e1_poll() that
encapsulate both the actual e1 hardware poll and running
the usb stuff for both port.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Icf81efcdc5c8f13480ba2652bc6e7c1ca226ae4d
So, once BD are submitted to hw, we have to wait for them to get
back, and that's what the SHUTDOWN state is for. Now, this needs
to completete before we can call e1_start() again and so in case
it wasn't done in time, we just busy waited in e1_start().
Problem is that in the absence of a valid signal, the RX side won't
process anything and so we will wait forever.
For the TX side, if we are in remote tick config and we never had
any valid signal, this could also hang.
So we change this. There is actually no need to wait for the shutdown
to complete, we can resume where we left off.
For RX: We use the 'RECOVER' which basically waits for all pending BD
to be done, empty the fifo and auto-restarts. The only "side effect" is
that we'll loose up to 4 multiframe of data at the beginning but the
RX start is async anyway, no guarantee of where we pick up.
For TX: First we empty the FIFO from any data that wasn't already
submitted to the hardware (and is now stale) and we also use the
'RECOVER' state which will wait until the FIFO reaches nominal level
before starting feeding new data. The "side effect" here is we might
TX up to 4 multiframe of old data. Although this is rather unlikely
because the conditions for TX not to have transmitted those before
are unlikely (and hopefully go away completely with OS#5402)
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I3f3de5491e0999f89a63f507fafdc4af8c22c905
Previously we were just doing a hard reset, calling init again.
And to stop, it was a bit harsh as well, just calling init with
0 as argument, not cleaning pending descriptors and such.
Now, the HW is initialized once and there is proper startup and
shutdown procedure, leaving things in the proper state.
Init of e1 hardware (call to e1_init) is also delegated to usb_e1
since it's that module that handles all state changes and config
so it makes sense it handles init too rather than calling it from
fw_app.c
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I639f90ce3488a1a08e87854e74e0586010264f5d
Store Rx/Tx config separately so we can change some of the config
bit depending on current state while still keeping what the user
asked for.
Not really used ATM since state is never IDLE, but for future use.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I0b4cbf88abc4af801054ba5d6779dede5649852a
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
Not much change in e1, just a typo fix that just triggered a warning.
In usb the only relevant change is a fix in the stack code that caused
GET_INTERFACE to fail for interfaces without alt-settings
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Idfe712f7a2173e5c5f9552f35136f1d732098139
We should use service-aliases and not the primary host name, as
that makes migration between machines hard.
Change-Id: Idd49f27c9b08c6cfd077f85276a3dedc4cf117ef