blob: 9ac21362145f1404135be5bc68778a171e451ff2 [file] [log] [blame]
Harald Welte9469e042020-12-15 23:09:40 +01001/*
2 * ice1usb_proto.h
3 *
4 * Copyright (C) 2020 Harald Welte <laforge@osmocom.org>
5 * SPDX-License-Identifier: MIT
6 *
7 * Header file describing the USB protocol between the icE1usb firmware and the host
8 * software (currently really only osmo-e1d)
9 */
10
11#pragma once
12
13/***********************************************************************
14 * Control Endpoint / Device Requests
15 ***********************************************************************/
16
17/*! returns a bit-mask of optional device capabilities (see enum e1usb_dev_capability) */
18#define ICE1USB_DEV_GET_CAPABILITIES 0x01
19#define ICE1USB_DEV_GET_FW_BUILD 0x02
20
21enum e1usb_dev_capability {
22 /*! Does this board have a GPS-DO */
23 ICE1USB_DEV_CAP_GPSDO,
24};
25
26
27/* Interface Requests */
28
29/*! returns a bit-mask of optional device capabilities (see enum e1usb_intf_capability) */
30#define ICE1USB_INTF_GET_CAPABILITIES 0x01
31#define ICE1USB_INTF_SET_TX_CFG 0x02 /*!< struct ice1usb_tx_config */
32#define ICE1USB_INTF_GET_TX_CFG 0x03 /*!< struct ice1usb_tx_config */
33#define ICE1USB_INTF_SET_RX_CFG 0x04 /*!< struct ice1usb_rx_config */
34#define ICE1USB_INTF_GET_RX_CFG 0x05 /*!< struct ice1usb_rx_config */
Harald Welte1b89f3b2022-01-13 10:03:42 +010035#define ICE1USB_INTF_GET_ERRORS 0x06 /*!< struct ice1usb_irq_err */
Harald Welte9469e042020-12-15 23:09:40 +010036
37//enum e1usb_intf_capability { };
38
39enum ice1usb_tx_mode {
40 ICE1USB_TX_MODE_TRANSP = 0,
41 ICE1USB_TX_MODE_TS0 = 1,
42 ICE1USB_TX_MODE_TS0_CRC4 = 2,
43 ICE1USB_TX_MODE_TS0_CRC4_E = 3,
44};
45
46enum ice1usb_tx_timing {
47 ICE1USB_TX_TIME_SRC_LOCAL = 0,
48 ICE1USB_TX_TIME_SRC_REMOTE = 1,
49};
50
51enum ice1usb_tx_ext_loopback {
52 ICE1USB_TX_EXT_LOOPBACK_OFF = 0,
53 ICE1USB_TX_EXT_LOOPBACK_SAME = 1,
54 ICE1USB_TX_EXT_LOOPBACK_CROSS = 2,
55};
56
57/* ICE1USB_INTF_{GET,SET}_TX_CFG */
58struct ice1usb_tx_config {
59 uint8_t mode; /*!< enum ice1usb_tx_mode */
60 uint8_t timing; /*!< enum ice1usb_tx_timing */
61 uint8_t ext_loopback; /*!< enum ice1usb_tx_ext_loopback */
62 uint8_t alarm; /*!< 1 = transmit alarm; 0 = don't */
63} __attribute__((packed));
64
65
66enum ice1usb_rx_mode {
67 /*! transparent, unaligned bitstream */
68 ICE1USB_RX_MODE_TRANSP = 0,
69 /*! alignment to E1 frame */
70 ICE1USB_RX_MODE_FRAME = 2,
71 /*! alignment to E1 multiframe */
72 ICE1USB_RX_MODE_MULTIFRAME = 3,
73};
74
75/* ICE1USB_INTF_{GET,SET}_RX_CFG */
76struct ice1usb_rx_config {
77 uint8_t mode; /*!< enum ice1usb_rx_mode */
78} __attribute__((packed));
Harald Welte805f2cf2020-12-14 17:31:03 +010079
80
81/***********************************************************************
82 * Interrupt Endpoint
83 ***********************************************************************/
84
85enum ice1usb_irq_type {
86 ICE1USB_IRQ_T_ERRCNT = 1,
87};
88
Harald Welte51baa362022-01-01 15:22:25 +010089/* Ensue to keep those in sync with e1.h */
Harald Welte805f2cf2020-12-14 17:31:03 +010090#define ICE1USB_ERR_F_ALIGN_ERR 0x01
91#define ICE1USB_ERR_F_LOS 0x02
Harald Welte51baa362022-01-01 15:22:25 +010092#define ICE1USB_ERR_F_RAI 0x04
Harald Welte805f2cf2020-12-14 17:31:03 +010093
94struct ice1usb_irq_err {
95 /* 16-bit little-endian counters */
96 uint16_t crc;
97 uint16_t align;
98 uint16_t ovfl;
99 uint16_t unfl;
100 uint8_t flags;
101} __attribute__((packed));
102
103struct ice1usb_irq {
104 uint8_t type; /*!< enum ice1usb_irq_type */
105 union {
106 struct ice1usb_irq_err errors;
107 } u;
108} __attribute__((packed));