Debian Codegraph @

drivers/dahdi/icE1usb/ice1usb_proto.h

raw symbols SCIP
1 /*
2 * ice1usb_proto.h
3 *
4 * Copyright (C) 2020 Harald Welte <[email protected]>
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
20 /*! returns a string describing the firmware version */
21 #define ICE1USB_DEV_GET_FW_BUILD 0x02
22
23 /*! performs an I2C register access (read/write depends on direction) */
24 #define ICE1USB_DEV_I2C_REG_ACCESS 0x10
25
26
27 enum e1usb_dev_capability {
28 /*! Does this board have a GPS-DO */
29 ICE1USB_DEV_CAP_GPSDO,
30 };
31
32 /***********************************************************************
33 * Control Endpoint / GPS-DO Interface Requests
34 ***********************************************************************/
35
36 #define ICE1USB_INTF_GET_GPSDO_STATUS 0x10
37 #define ICE1USB_INTF_GET_GPSDO_MODE 0x12 /*!< uint8_t */
38 #define ICE1USB_INTF_SET_GPSDO_MODE 0x13 /*!< wValue = mode */
39 #define ICE1USB_INTF_GET_GPSDO_TUNE 0x14 /*!< data = struct e1usb_gpsdo_tune */
40 #define ICE1USB_INTF_SET_GPSDO_TUNE 0x15 /*!< data = struct e1usb_gpsdo_tune */
41
42 enum ice1usb_gpsdo_mode {
43 ICE1USB_GPSDO_MODE_DISABLED = 0,
44 ICE1USB_GPSDO_MODE_AUTO = 1,
45 };
46
47 enum ice1usb_gpsdo_antenna_state {
48 ICE1USB_GPSDO_ANT_UNKNOWN = 0,
49 ICE1USB_GPSDO_ANT_OK = 1,
50 ICE1USB_GPSDO_ANT_OPEN = 2,
51 ICE1USB_GPSDO_ANT_SHORT = 3,
52 };
53
54 enum ice1usb_gpsdo_state {
55 ICE1USB_GPSDO_STATE_DISABLED = 0,
56 ICE1USB_GPSDO_STATE_CALIBRATE = 1,
57 ICE1USB_GPSDO_STATE_HOLD_OVER = 2,
58 ICE1USB_GPSDO_STATE_TUNE_COARSE = 3,
59 ICE1USB_GPSDO_STATE_TUNE_FINE = 4,
60 };
61
62 struct e1usb_gpsdo_tune {
63 uint16_t coarse;
64 uint16_t fine;
65 } __attribute__((packed));
66
67 struct e1usb_gpsdo_status {
68 uint8_t state;
69 uint8_t antenna_state; /*!< Antenna state */
70 uint8_t valid_fix; /*!< Valid GPS Fix (0/1) */
71 uint8_t mode; /*!< Current configured operating mode */
72 struct e1usb_gpsdo_tune tune; /*!< Current VCXO tuning values */
73 uint32_t freq_est; /*!< Latest frequency estimate measurement */
74 int16_t err_acc; /*!< Accumulated error (since fw icE1usb-fw-0.3 commit cfb8b0b7) */
75 } __attribute__((packed));
76
77
78 /***********************************************************************
79 * Control Endpoint / E1 Interface Requests
80 ***********************************************************************/
81
82 /*! returns a bit-mask of optional device capabilities (see enum e1usb_intf_capability) */
83 #define ICE1USB_INTF_GET_CAPABILITIES 0x01
84 #define ICE1USB_INTF_SET_TX_CFG 0x02 /*!< struct ice1usb_tx_config */
85 #define ICE1USB_INTF_GET_TX_CFG 0x03 /*!< struct ice1usb_tx_config */
86 #define ICE1USB_INTF_SET_RX_CFG 0x04 /*!< struct ice1usb_rx_config */
87 #define ICE1USB_INTF_GET_RX_CFG 0x05 /*!< struct ice1usb_rx_config */
88 #define ICE1USB_INTF_GET_ERRORS 0x06 /*!< struct ice1usb_irq_err */
89
90 //enum e1usb_intf_capability { };
91
92 enum ice1usb_tx_mode {
93 ICE1USB_TX_MODE_TRANSP = 0,
94 ICE1USB_TX_MODE_TS0 = 1,
95 ICE1USB_TX_MODE_TS0_CRC4 = 2,
96 ICE1USB_TX_MODE_TS0_CRC4_E = 3,
97 };
98
99 enum ice1usb_tx_timing {
100 ICE1USB_TX_TIME_SRC_LOCAL = 0,
101 ICE1USB_TX_TIME_SRC_REMOTE = 1,
102 };
103
104 enum ice1usb_tx_ext_loopback {
105 ICE1USB_TX_EXT_LOOPBACK_OFF = 0,
106 ICE1USB_TX_EXT_LOOPBACK_SAME = 1,
107 ICE1USB_TX_EXT_LOOPBACK_CROSS = 2,
108 };
109
110 /* ICE1USB_INTF_{GET,SET}_TX_CFG */
111 struct ice1usb_tx_config {
112 uint8_t mode; /*!< enum ice1usb_tx_mode */
113 uint8_t timing; /*!< enum ice1usb_tx_timing */
114 uint8_t ext_loopback; /*!< enum ice1usb_tx_ext_loopback */
115 uint8_t alarm; /*!< 1 = transmit alarm; 0 = don't */
116 } __attribute__((packed));
117
118
119 enum ice1usb_rx_mode {
120 /*! transparent, unaligned bitstream */
121 ICE1USB_RX_MODE_TRANSP = 0,
122 /*! alignment to E1 frame */
123 ICE1USB_RX_MODE_FRAME = 2,
124 /*! alignment to E1 multiframe */
125 ICE1USB_RX_MODE_MULTIFRAME = 3,
126 };
127
128 /* ICE1USB_INTF_{GET,SET}_RX_CFG */
129 struct ice1usb_rx_config {
130 uint8_t mode; /*!< enum ice1usb_rx_mode */
131 } __attribute__((packed));
132
133
134 /***********************************************************************
135 * Interrupt Endpoint
136 ***********************************************************************/
137
138 enum ice1usb_irq_type {
139 ICE1USB_IRQ_T_ERRCNT = 1,
140 };
141
142 /* Ensue to keep those in sync with e1.h */
143 #define ICE1USB_ERR_F_ALIGN_ERR 0x01
144 #define ICE1USB_ERR_F_LOS 0x02
145 #define ICE1USB_ERR_F_RAI 0x04
146 #define ICE1USB_ERR_F_AIS 0x08
147
148 struct ice1usb_irq_err {
149 /* 16-bit little-endian counters */
150 uint16_t crc;
151 uint16_t align;
152 uint16_t ovfl;
153 uint16_t unfl;
154 uint8_t flags;
155 } __attribute__((packed));
156
157 struct ice1usb_irq {
158 uint8_t type; /*!< enum ice1usb_irq_type */
159 union {
160 struct ice1usb_irq_err errors;
161 } u;
162 } __attribute__((packed));