This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/21776 )
Change subject: icE1usb fw: move entire E1 configuration to USB
......................................................................
icE1usb fw: move entire E1 configuration to USB
Maintain all of the E1 IP core configuration in usb_e1.c, rather than
having compile-time defaults in e1.c, unused compile-time defaults in
usb_e1.c and runtime config received via USB.
Related: OS#4675
Change-Id: Ia1cc1e685aad9fe5ceb230b66f35d5cb2829c845
---
M firmware/ice40-riscv/icE1usb/e1.c
M firmware/ice40-riscv/icE1usb/e1.h
M firmware/ice40-riscv/icE1usb/fw_app.c
M firmware/ice40-riscv/icE1usb/usb_e1.c
4 files changed, 26 insertions(+), 28 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/76/21776/1
diff --git a/firmware/ice40-riscv/icE1usb/e1.c b/firmware/ice40-riscv/icE1usb/e1.c
index 4ce75bf..e033206 100644
--- a/firmware/ice40-riscv/icE1usb/e1.c
+++ b/firmware/ice40-riscv/icE1usb/e1.c
@@ -241,7 +241,7 @@
void
-e1_init(bool clk_mode)
+e1_init(uint16_t rx_cr, uint16_t tx_cr)
{
/* Global state init */
memset(&g_e1, 0x00, sizeof(g_e1));
@@ -250,17 +250,10 @@
e1f_reset(&g_e1.rx.fifo, 0, 128);
e1f_reset(&g_e1.tx.fifo, 128, 128);
- /* Enable Rx */
- g_e1.rx.cr = E1_RX_CR_OVFL_CLR |
- E1_RX_CR_MODE_MFA |
- E1_RX_CR_ENABLE;
+ g_e1.rx.cr = E1_RX_CR_OVFL_CLR | E1_RX_CR_ENABLE | rx_cr;
e1_regs->rx.csr = g_e1.rx.cr;
- /* Enable Tx */
- g_e1.tx.cr = E1_TX_CR_UNFL_CLR |
- (clk_mode ? E1_TX_CR_TICK_REMOTE : E1_TX_CR_TICK_LOCAL) |
- E1_TX_CR_MODE_TS0_CRC_E |
- E1_TX_CR_ENABLE;
+ g_e1.tx.cr = E1_TX_CR_UNFL_CLR | E1_TX_CR_ENABLE |tx_cr;
e1_regs->tx.csr = g_e1.tx.cr;
/* State */
diff --git a/firmware/ice40-riscv/icE1usb/e1.h b/firmware/ice40-riscv/icE1usb/e1.h
index 05ce19a..fcd4284 100644
--- a/firmware/ice40-riscv/icE1usb/e1.h
+++ b/firmware/ice40-riscv/icE1usb/e1.h
@@ -7,7 +7,7 @@
#pragma once
-void e1_init(bool clk_mode);
+void e1_init(uint16_t rx_cr, uint16_t tx_cr);
void e1_poll(void);
void e1_debug_print(bool data);
diff --git a/firmware/ice40-riscv/icE1usb/fw_app.c b/firmware/ice40-riscv/icE1usb/fw_app.c
index 62f4b0e..eebc21f 100644
--- a/firmware/ice40-riscv/icE1usb/fw_app.c
+++ b/firmware/ice40-riscv/icE1usb/fw_app.c
@@ -102,7 +102,7 @@
usb_e1_init();
/* Start */
- e1_init(false); // local tick
+ e1_init(0, 0);
e1_active = true;
led_state(true);
usb_connect();
@@ -138,16 +138,6 @@
case 'O':
e1_debug_print(true);
break;
- case 'e':
- e1_init(true);
- e1_active = true;
- led_state(true);
- break;
- case 'E':
- e1_init(false);
- e1_active = true;
- led_state(true);
- break;
case 'c':
usb_connect();
break;
diff --git a/firmware/ice40-riscv/icE1usb/usb_e1.c b/firmware/ice40-riscv/icE1usb/usb_e1.c
index e910852..f94b897 100644
--- a/firmware/ice40-riscv/icE1usb/usb_e1.c
+++ b/firmware/ice40-riscv/icE1usb/usb_e1.c
@@ -216,6 +216,22 @@
return USB_FND_SUCCESS;
}
+static void _perform_tx_config(void)
+{
+ const struct ice1usb_tx_config *cfg = &g_usb_e1.tx_cfg;
+ e1_tx_config(E1_TX_CR_ENABLE |
+ ((cfg->mode & 2) << 1) |
+ ((cfg->timing & 1) << 3) |
+ ((cfg->alarm & 1) << 4) |
+ ((cfg->ext_loopback & 2) << 5) );
+}
+
+static void _perform_rx_config(void)
+{
+ const struct ice1usb_rx_config *cfg = &g_usb_e1.rx_cfg;
+ e1_rx_config(E1_RX_CR_ENABLE | (cfg->mode << 1));
+}
+
static enum usb_fnd_resp
_e1_set_intf(const struct usb_intf_desc *base, const struct usb_intf_desc *sel)
{
@@ -229,6 +245,9 @@
if (g_usb_e1.running)
return USB_FND_SUCCESS;
+ _perform_rx_config();
+ _perform_tx_config();
+
g_usb_e1.running = true;
/* Configure EP1 OUT / EP2 IN */
@@ -276,11 +295,7 @@
printf("set_tx_mode %02x%02x%02x%02x\r\n",
xfer->data[0], xfer->data[1], xfer->data[2], xfer->data[3]);
g_usb_e1.tx_cfg = *cfg;
- e1_tx_config(E1_TX_CR_ENABLE |
- ((cfg->mode & 2) << 1) |
- ((cfg->timing & 1) << 3) |
- ((cfg->alarm & 1) << 4) |
- ((cfg->ext_loopback & 2) << 5) );
+ _perform_tx_config();
return true;
}
@@ -290,7 +305,7 @@
const struct ice1usb_rx_config *cfg = (const struct ice1usb_rx_config *) xfer->data;
printf("set_rx_mode %02x\r\n", xfer->data[0]);
g_usb_e1.rx_cfg = *cfg;
- e1_rx_config(E1_RX_CR_ENABLE | (cfg->mode << 1));
+ _perform_rx_config();
return true;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-e1-hardware/+/21776
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-e1-hardware
Gerrit-Branch: master
Gerrit-Change-Id: Ia1cc1e685aad9fe5ceb230b66f35d5cb2829c845
Gerrit-Change-Number: 21776
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201217/c112c60e/attachment.htm>