fw/e1-tracer: Import firmware for the E1 tracer board

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>
diff --git a/firmware/ice40-riscv/e1-tracer/misc.c b/firmware/ice40-riscv/e1-tracer/misc.c
new file mode 100644
index 0000000..6b100bd
--- /dev/null
+++ b/firmware/ice40-riscv/e1-tracer/misc.c
@@ -0,0 +1,35 @@
+/*
+ * misc.c
+ *
+ * Copyright (C) 2019-2020  Sylvain Munaut <tnt@246tNt.com>
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "config.h"
+#include "misc.h"
+
+
+struct misc {
+	uint32_t warmboot;
+	uint32_t _rsvd0[3];;
+	struct {
+		uint16_t tx;
+		uint16_t rx;
+	} e1_tick[2];
+	uint32_t _rsvd1;
+	uint32_t time;
+} __attribute__((packed,aligned(4)));
+
+static volatile struct misc * const misc_regs = (void*)(MISC_BASE);
+
+
+void
+e1_tick_read(uint16_t *ticks)
+{
+	uint32_t v = misc_regs->e1_tick;
+	ticks[0] = (v      ) & 0xffff;
+	ticks[1] = (v >> 16) & 0xffff;
+}