<p>laforge has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-e1-hardware/+/21773">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">icE1usb fw: Put E1 IP core register related #defines in e1_hw.h<br><br>Related: OS#4675<br>Change-Id: I6783f473e6bb7dd08a5b5714bdd9b5aac0f28f0d<br>---<br>M firmware/ice40-riscv/icE1usb/e1.c<br>A firmware/ice40-riscv/icE1usb/e1_hw.h<br>2 files changed, 67 insertions(+), 60 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/73/21773/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/firmware/ice40-riscv/icE1usb/e1.c b/firmware/ice40-riscv/icE1usb/e1.c</span><br><span>index 4c60f63..532dcdf 100644</span><br><span>--- a/firmware/ice40-riscv/icE1usb/e1.c</span><br><span>+++ b/firmware/ice40-riscv/icE1usb/e1.c</span><br><span>@@ -12,6 +12,7 @@</span><br><span> #include "config.h"</span><br><span> #include "console.h"</span><br><span> #include "e1.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "e1_hw.h"</span><br><span> </span><br><span> #include "dma.h"</span><br><span> #include "led.h" // FIXME</span><br><span>@@ -19,66 +20,6 @@</span><br><span> #include "misc.h" // needed to get the E1 tick for "LOS" detection</span><br><span> </span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// Hardware</span><br><span style="color: hsl(0, 100%, 40%);">-// --------</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-struct e1_chan {</span><br><span style="color: hsl(0, 100%, 40%);">- uint32_t csr;</span><br><span style="color: hsl(0, 100%, 40%);">- uint32_t bd;</span><br><span style="color: hsl(0, 100%, 40%);">-} __attribute__((packed,aligned(4)));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-struct e1_core {</span><br><span style="color: hsl(0, 100%, 40%);">- struct e1_chan rx;</span><br><span style="color: hsl(0, 100%, 40%);">- struct e1_chan tx;</span><br><span style="color: hsl(0, 100%, 40%);">-} __attribute__((packed,aligned(4)));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/* E1 receiver control register */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_CR_ENABLE (1 << 0) /* Enable receiver */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_CR_MODE_TRSP (0 << 1) /* Request no alignment at all */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_CR_MODE_BYTE (1 << 1) /* Request byte-level alignment */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_CR_MODE_BFA (2 << 1) /* Request Basic Frame Alignment */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_CR_MODE_MFA (3 << 1) /* Request Multi-Frame Alignment */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_CR_OVFL_CLR (1 << 12) /* Clear Rx overflow condition */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/* E1 receiver status register */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_SR_ENABLED (1 << 0) /* Indicate Rx is enabled */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_SR_ALIGNED (1 << 1) /* Indicate Alignment achieved */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_SR_BD_IN_EMPTY (1 << 8)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_SR_BD_IN_FULL (1 << 9)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_SR_BD_OUT_EMPTY (1 << 10)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_SR_BD_OUT_FULL (1 << 11)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_RX_SR_OVFL (1 << 12) /* Indicate Rx overflow */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/* E1 transmitter control register */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_CR_ENABLE (1 << 0) /* Enable transmitter */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_CR_MODE_TRSP (0 << 1) /* Transparent bit-stream mode */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_CR_MODE_TS0 (1 << 1) /* Generate TS0 in framer */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_CR_MODE_TS0_CRC (2 << 1) /* Generate TS0 + CRC4 in framer */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_CR_MODE_TS0_CRC_E (3 << 1) /* Generate TS0 + CRC4 + E-bits (based on Rx) in framer */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_CR_TICK_LOCAL (0 << 3) /* use local clock for Tx */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_CR_TICK_REMOTE (1 << 3) /* use recovered remote clock for Tx */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_CR_ALARM (1 << 4) /* indicate ALARM to remote */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_CR_LOOPBACK (1 << 5) /* external loopback enable/diasble */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_CR_LOOPBACK_CROSS (1 << 6) /* source of loopback: local (0) or other (1) port */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_CR_UNFL_CLR (1 << 12) /* Clear Tx underflow condition */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/* E1 transmitter status register */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_SR_ENABLED (1 << 0) /* Indicate Tx is enabled */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_SR_BD_IN_EMPTY (1 << 8)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_SR_BD_IN_FULL (1 << 9)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_SR_BD_OUT_EMPTY (1 << 10)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_SR_BD_OUT_FULL (1 << 11)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_TX_SR_UNFL (1 << 12) /* Indicate Tx underflow */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/* E1 buffer descriptor flags */</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_BD_VALID (1 << 15)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_BD_CRC1 (1 << 14)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_BD_CRC0 (1 << 13)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_BD_ADDR(x) ((x) & 0x7f)</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_BD_ADDR_MSK 0x7f</span><br><span style="color: hsl(0, 100%, 40%);">-#define E1_BD_ADDR_SHFT 0</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> static volatile struct e1_core * const e1_regs = (void *)(E1_CORE_BASE);</span><br><span> static volatile uint8_t * const e1_data = (void *)(E1_DATA_BASE);</span><br><span> </span><br><span>diff --git a/firmware/ice40-riscv/icE1usb/e1_hw.h b/firmware/ice40-riscv/icE1usb/e1_hw.h</span><br><span>new file mode 100644</span><br><span>index 0000000..28190e9</span><br><span>--- /dev/null</span><br><span>+++ b/firmware/ice40-riscv/icE1usb/e1_hw.h</span><br><span>@@ -0,0 +1,66 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#pragma once</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdint.h></span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * e1_hw.h</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (C) 2019-2020 Sylvain Munaut <tnt@246tNt.com></span><br><span style="color: hsl(120, 100%, 40%);">+ * SPDX-License-Identifier: GPL-3.0-or-later</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//TODO: Shouldn't this go into the no2e1 git repo?</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct e1_chan {</span><br><span style="color: hsl(120, 100%, 40%);">+ uint32_t csr;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint32_t bd;</span><br><span style="color: hsl(120, 100%, 40%);">+} __attribute__((packed,aligned(4)));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct e1_core {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct e1_chan rx;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct e1_chan tx;</span><br><span style="color: hsl(120, 100%, 40%);">+} __attribute__((packed,aligned(4)));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* E1 receiver control register */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_CR_ENABLE (1 << 0) /* Enable receiver */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_CR_MODE_TRSP (0 << 1) /* Request no alignment at all */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_CR_MODE_BYTE (1 << 1) /* Request byte-level alignment */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_CR_MODE_BFA (2 << 1) /* Request Basic Frame Alignment */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_CR_MODE_MFA (3 << 1) /* Request Multi-Frame Alignment */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_CR_OVFL_CLR (1 << 12) /* Clear Rx overflow condition */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* E1 receiver status register */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_SR_ENABLED (1 << 0) /* Indicate Rx is enabled */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_SR_ALIGNED (1 << 1) /* Indicate Alignment achieved */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_SR_BD_IN_EMPTY (1 << 8)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_SR_BD_IN_FULL (1 << 9)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_SR_BD_OUT_EMPTY (1 << 10)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_SR_BD_OUT_FULL (1 << 11)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_RX_SR_OVFL (1 << 12) /* Indicate Rx overflow */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* E1 transmitter control register */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_CR_ENABLE (1 << 0) /* Enable transmitter */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_CR_MODE_TRSP (0 << 1) /* Transparent bit-stream mode */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_CR_MODE_TS0 (1 << 1) /* Generate TS0 in framer */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_CR_MODE_TS0_CRC (2 << 1) /* Generate TS0 + CRC4 in framer */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_CR_MODE_TS0_CRC_E (3 << 1) /* Generate TS0 + CRC4 + E-bits (based on Rx) in framer */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_CR_TICK_LOCAL (0 << 3) /* use local clock for Tx */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_CR_TICK_REMOTE (1 << 3) /* use recovered remote clock for Tx */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_CR_ALARM (1 << 4) /* indicate ALARM to remote */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_CR_LOOPBACK (1 << 5) /* external loopback enable/diasble */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_CR_LOOPBACK_CROSS (1 << 6) /* source of loopback: local (0) or other (1) port */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_CR_UNFL_CLR (1 << 12) /* Clear Tx underflow condition */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* E1 transmitter status register */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_SR_ENABLED (1 << 0) /* Indicate Tx is enabled */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_SR_BD_IN_EMPTY (1 << 8)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_SR_BD_IN_FULL (1 << 9)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_SR_BD_OUT_EMPTY (1 << 10)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_SR_BD_OUT_FULL (1 << 11)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_TX_SR_UNFL (1 << 12) /* Indicate Tx underflow */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* E1 buffer descriptor flags */</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_BD_VALID (1 << 15)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_BD_CRC1 (1 << 14)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_BD_CRC0 (1 << 13)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_BD_ADDR(x) ((x) & 0x7f)</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_BD_ADDR_MSK 0x7f</span><br><span style="color: hsl(120, 100%, 40%);">+#define E1_BD_ADDR_SHFT 0</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-e1-hardware/+/21773">change 21773</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-e1-hardware/+/21773"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: osmo-e1-hardware </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I6783f473e6bb7dd08a5b5714bdd9b5aac0f28f0d </div>
<div style="display:none"> Gerrit-Change-Number: 21773 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>