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
diff --git a/firmware/ice40-riscv/icE1usb/usb_e1.c b/firmware/ice40-riscv/icE1usb/usb_e1.c
index 9dc6f1d..96ca72a 100644
--- a/firmware/ice40-riscv/icE1usb/usb_e1.c
+++ b/firmware/ice40-riscv/icE1usb/usb_e1.c
@@ -289,15 +289,12 @@
 	switch (usb_e1->running) {
 	case false:
 		/* Disable E1 rx/tx */
-		e1_init(port, 0, 0);
+		e1_stop(port);
 		break;
 
 	case true:
 		/* Reset and Re-Enable E1 */
-		e1_init(port,
-			_rx_config_reg(&rx_cfg_default),
-			_tx_config_reg(&tx_cfg_default)
-		);
+		e1_start(port);
 
 		/* Reset BDI */
 		usb_e1->in_bdi = 0;
@@ -464,11 +461,15 @@
 void
 usb_e1_init(void)
 {
+	uint32_t rx_cr = _rx_config_reg(&rx_cfg_default);
+	uint32_t tx_cr = _tx_config_reg(&tx_cfg_default);
+
 	for (int i=0; i<2; i++) {
 		struct usb_e1_state *usb_e1 = _get_state(i);
 		memset(usb_e1, 0x00, sizeof(struct usb_e1_state));
 		usb_e1->tx_cfg = tx_cfg_default;
 		usb_e1->rx_cfg = rx_cfg_default;
+		e1_init(i, rx_cr, tx_cr);
 	}
 
 	usb_register_function_driver(&_e1_drv);