Commit Graph

297 Commits

Author SHA1 Message Date
Sylvain Munaut 9da5486e00 hardware/icE1usb: Remove panelized version
Further production runs will use another panel setup anyway
and this one is archived in r1.0 anyway.

But this cleans up the way for kicad 6 update

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I864503c1edf28993bc9c4c12842856ab1002870c
2022-09-05 22:29:51 +02:00
Sylvain Munaut 112d858a4d gateware/build: Update submodule
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ib61dac16fc2399b8b357ec8ba8e7f19e2c79b4d8
2022-08-25 17:05:01 +02:00
nickvsnetworking cf587af09e Doc Update - Build process for DAHDI on Debian 11
Change-Id: I0679bd14702b7b3d05c3346ce10358f45fef0301
2022-05-17 11:16:29 +02:00
Sylvain Munaut aae4d3059d firmware: Remove a couple of questionable debug puts()
Those were low level debug meant to be temporary and somehow ended
up committed.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ie1b802f347b0de9ea82edb61faaba6094b8f4dfa
2022-05-03 14:00:35 +02:00
Sylvain Munaut 0685eddc1f gateware/icE1usb: Use custom I2C core by default rather than SB_I2C
SB_I2C is apparently just a pain to use and buggy and such, so
use our custom one.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I1596ccbf03dd4450f519fe9b54a7fece125a7fbc
2022-05-03 14:00:35 +02:00
Sylvain Munaut 0c1684e5ae gateware/icE1usb: Set divider of I2C core to be ~ 400 kHz
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I1dd4ab34da9d01b599cf9c782e721aaee9b8740d
2022-05-03 14:00:35 +02:00
Sylvain Munaut 921f4779f5 gateware/icE1usb: Replace local I2C core with no2misc one
This core has been merged (and improved) upstream, so
update the submodule, remove local copy and make the required
tweaks.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I79fca561fee32bbaec94882b4f65c7ecaa44be11
2022-05-03 14:00:35 +02:00
Sylvain Munaut 9e02d4cd99 gateware/icE1usb: Typo in instance names
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I7db544b4ff98fcfc382193f040550f377178aebf
2022-05-03 14:00:35 +02:00
Sylvain Munaut f12087fed3 gateware/icE1usb: Don't let nextpnr promote globals
We manually use global buffers for the signals that need to be
global, don't let nextpnr heuristic mess with things.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I5dc5f2f39dca933b2570cbe4e26d9d7fd2a44688
2022-05-03 14:00:35 +02:00
Sylvain Munaut 90ca05dd54 gateware/common: Unify a bit with other repo
This just pulls in some small update in various files shared
by several repository. It's mostly comment and formatting, nothing
functionnal really.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Icb7bea1cf7243e9ace819cd567eb006fcc71c808
2022-05-02 20:45:08 +02:00
Sylvain Munaut b72aba9586 icE1usb fw/gpsdo: Limit the fine tuning range
Fine tuning has a limited tuning range. If at some point we
hit the limits, we need to bit the bullet and try to 'transfer'
some of that to the coarse range as best as we can. Hopefully
we get it close enough to limit disruption.

Note that this should really never happen because although it's
limited, the tuning range should be good enough to absorb any
reasonable temperature / aging variation once we have coarse tuned.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I2d9d348f5466f581b3d6d36c98847c47e2452f98
2022-04-22 10:37:58 +02:00
Sylvain Munaut 8598d48675 icE1usb fw/gpsdo: Attempt to recover from bad tuning
If we're in hold over mode and getting a bunch of invalid
frequency measurement despite a good fix, then we most likely
ended up on a bad tuning value and we need to recover by starting
from scratch.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: If8503a3eaf695e02a0ef0a3b6536de985d247c20
2022-04-22 10:35:53 +02:00
Sylvain Munaut 103a83cbdc icE1usb fw/gpsdo: Add debug prints for coarse/fine tune entry
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ife69f9ce4c6f3eb6d40b05ce8f862ff68180357f
2022-04-21 23:28:35 +02:00
Sylvain Munaut 8014c3cd09 icE1usb fw/gpsdo: Never use invalid measurements to feed loop
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I9c7b81c6e2e600ed49ac766fa33df23747dd339e
2022-04-21 23:27:57 +02:00
Sylvain Munaut 28eb5d1b96 icE1usb fw/gpsdo: Fix typo in the condition to exit TUNE_FINE
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I6106f07f7bff1c298ac3f86164e155d4bfb1b7ac
2022-04-21 23:26:59 +02:00
Manawyrm 212d6c3576 manual: add info and renders to show to set TE/NT mode
The page break is currently a bit ugly, but I didn't see an easy way
to fix it. The images and info text should make the process much clearer.

Change-Id: I5999dc60850da2cd02d9bbc7db5727cdebf041c6
2022-02-24 10:12:47 +00:00
Harald Welte 4d8e12413f manual: Document the factory default jumper setting
Also re-word/expand a bit on the situations in which NT mode
or cross-over is needed.

Change-Id: Ie726d4ca2e8605015a2f0384d2b435e1b40c1cad
2022-02-23 22:00:09 +01:00
Harald Welte ce1262fc51 manual: fix link to gateware
Change-Id: Iad107b33d182e3d9343dfb4e533360740e9c85df
2022-02-23 21:26:32 +01:00
Harald Welte cac342af6b icE1usb: Move GPS-DO USB control to separate USB interface
doing so significantly simplifies the development of a Linux kernel
driver, as the GPS-DO only exists once (not twice, like the per-E1-line
interface), and Linux kernel USB drivers typically are for an interface.

There is an option to write a usb_device_driver, but doing so will
exclude the per-interface drivers from still being probed in their usual
fashion.

While we introduce this new USB Interface for the GPS-DO, we also
move the related control endpoint requests from the device level to the
interface level.

Finally, some naming inconsistency between "enum
ice1usb_gpsdo_antenna_state" vs. the member name antenna_status is
resolved.

Change-Id: Icd6555a14896c38626fb147b78af44ff719f2254
2022-02-01 17:57:12 +01:00
Harald Welte fddf5990bd icE1usb: Fix ordering of USB interface numbers
The USB spec requires interface numbers to be in sequential order,
and the existing firmware fails that requirement, as is shown by
the Chapter9 test suite ("USB30CV").

With this patch applied, the USB30CV Chapter9 test suite passes.

Change-Id: I6a5434447ee20f77ce0ba9e7b1884cbd5b466439
2022-02-01 17:26:38 +01:00
Harald Welte fdfabf93f5 icE1usb doc: Add pictures of front and back side
Closes: OS#5406
Change-Id: Ifc382c762119b397dd9a6b484ebc9a237897fba9
2022-01-18 20:22:56 +00:00
Harald Welte 4090182ce0 icE1usb doc: Link to wiki page about iso USB issues
Change-Id: Id5f555519d5e320570017178613c752591db4a2f
2022-01-18 20:22:56 +00:00
Oliver Smith d0a5a5d074 checkpatch.conf: new file
Disable spacing and open brace checks, as this repository follows a
different code style.

If needed, the checkpatch file can be extended with other checks:
* get the check name from the linter output, e.g. SPACING in:
  firmware/ice40-riscv/icE1usb/fw_app.c:155: ERROR:SPACING: spaces required around that '=' (ctx:VxV)
* add a new "--ignore NAME" line to the file

Related: https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26841
Related: OS#5399
Change-Id: I4d2cf2eb698b8f4e54f04e62e4dbbc37146daf88
2022-01-17 17:28:16 +00:00
Harald Welte 9df9995d2f icE1usb: update manual to reflect firmware 0.2 (GPS-DO, 2 ports)
Change-Id: I9dac5b9479af37270dc13e334a278f91f260c7ce
2022-01-17 17:16:09 +01:00
Harald Welte 24eb3e308a icE1usb doc: DAHDI driver no longer experimental
Change-Id: I0c65d7be98f514a5f106472389472a177d3c58c2
2022-01-16 18:12:59 +01:00
Harald Welte da526ac8f6 jenkins.sh: Fix upload of tagged releases
Tagged releases get something like icE1usb-fw-0.2.elf without a
git-hash component suffix.  So the old glob *-*-*-*.{bin,elf}
was not matching and we got errors like

rsync: link_stat "/build/firmware/ice40-riscv/icE1usb/*-*-*-*.bin" failed: No such file or directory (2)
rsync: link_stat "/build/firmware/ice40-riscv/icE1usb/*-*-*-*.elf" failed: No such file or directory (2)
Change-Id: I7509f9d92ec19c1702af5f958d495e21321053bc
2022-01-16 18:10:41 +01:00
Sylvain Munaut c308334de7 icE1usb fw: Add USB control for the GPSDO function
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: If92aa68d8a49349fa0d6d556eec81bbb80be989c
2022-01-13 13:21:29 +01:00
Sylvain Munaut e76b643298 icE1usb fw: Add GPSDO VCXO trimming loop
Rather basic and not super well tested, use with caution

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I5f9ce6621492be967d6a44d31f270e107f3ef686
2022-01-13 13:21:29 +01:00
Sylvain Munaut 70c10f05cf icE1usb fw: Expose the GPS NMEA data as a CDC ACM
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
2022-01-13 13:21:29 +01:00
Sylvain Munaut ef5fe385fe icE1usb fw: Import GPS module driver code
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
2022-01-13 13:21:29 +01:00
Sylvain Munaut 7bed9039e4 common fw: Add hexval() utility function
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I724c14d1dee9e268f666030053fbf62ce5e1ba71
2022-01-13 13:21:29 +01:00
Harald Welte 1b89f3bcca icE1usb fw: New ICE1USB_INTF_GET_ERRORS control request
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
2022-01-13 13:21:29 +01:00
Sylvain Munaut 2c33f6d5bb icE1usb fw: Add support for the ICE1USB_DEV_GET_FW_BUILD control request
This was already defined but not implemented

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Id65734153c92ef87bc9ecf967447e9bf11804f24
2022-01-13 13:21:29 +01:00
Sylvain Munaut caf8cf94e1 icE1usb fw: Move handling of device-wide request in usb_dev.c
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
2022-01-13 13:21:29 +01:00
Sylvain Munaut 00b57625bc icE1usb fw: Add access functions for the 'time' hardware
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
2022-01-13 13:21:29 +01:00
Sylvain Munaut be5a53a4fe icE1usb fw: Add GPIO access functions
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
2022-01-13 13:21:29 +01:00
Sylvain Munaut 394748ab86 icE1usb fw: Add function to enable/disable E1 led runner
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
2022-01-13 13:21:29 +01:00
Sylvain Munaut 5848f14563 icE1usb fw: Add more hw units to config.h along with sys clock
Those are already in the gateware, this just adds the define for
them.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I87fae20e4a987c2186d5db6747e03e7ce9789a8f
2022-01-13 13:21:29 +01:00
Sylvain Munaut 51122af10f icE1usb fw: Add missing ice1usb_proto.h to dependency list
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I63af9839f79dbb0ce40e6582c86076a6cb213b39
2022-01-13 13:21:25 +01:00
Sylvain Munaut 9c213e6ca7 icE1usb fw: Add missing usb_e1.h in the Makefile header list
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I2088700c0fc99dbb2940956dd9066ea098ef3eb6
2022-01-13 13:19:06 +01:00
Sylvain Munaut c9c22a62cd icE1usb fw: Have usb_e1 handle the E1 polling and multi port
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
2022-01-13 13:19:06 +01:00
Sylvain Munaut d8f33aa792 icE1usb fw: Fix the E1 shutdown process
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
2022-01-13 13:19:06 +01:00
Sylvain Munaut 0cc1613f39 icE1usb fw: Update E1 core start/stop procedure
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
2022-01-10 14:48:56 +01:00
Sylvain Munaut 9410bdf8dd icE1usb fw: E1 core config update depending on state
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
2022-01-10 13:18:19 +01:00
Sylvain Munaut e98c0334ec icE1usb fw: Update LED status even in E1 FSM is in IDLE state
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I82b867c4886c9f34ff685764424d3db9a8303789
2022-01-10 12:46:49 +01:00
Sylvain Munaut 29d82097d7 icE1usb fw: Distinguish between E1 FIFO init and reset
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
2022-01-10 12:44:53 +01:00
Sylvain Munaut ace0932340 icE1usb fw: Use helper functions to derive config value from struct
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
2022-01-10 12:41:49 +01:00
Sylvain Munaut 4fd7155e93 icE1usb fw: Reorganize functions in e1.{c,h}
RX before TX for consistency ...

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Idcb1890a3a3f4fd2129f73585c4ce9f8475f1e21
2022-01-10 12:28:28 +01:00
Sylvain Munaut e9fe0dca2f icE1usb fw: Apply config reg field filter to e1_init call
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Id45688fed0533f8d7dbbfd993c93f9ffc4e2d53e
2022-01-10 12:26:20 +01:00
Sylvain Munaut ab75c94cce icE1usb fw: Add _MASK version for multibit fields in config regs
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
2022-01-10 12:22:41 +01:00