1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(DATA61_BSD)
11 */
12#ifndef _DRIVERS_CDC_H_
13#define _DRIVERS_CDC_H_
14
15#include <usb/drivers/cdc.h>
16
17/* Management Element Request Code (CDC spec 6.2) */
18enum cdc_req_code {
19	SEND_ENCAPSULATED_COMMAND       = 0x0, //CDC 6.2.1
20	GET_ENCAPSULATED_RESPONSE       = 0x1, //CDC 6.2.2
21	SET_COMM_FEATURE                = 0x2, //PSTN
22	GET_COMM_FEATURE                = 0x3, //PSTN
23	CLEAR_COMM_FEATURE              = 0x4, //PSTN
24	RESET_FUNCTION                  = 0x5, //MBIM
25	/* RESERVED (future use) 0x6h-0Fh */
26	SET_AUX_LINE_STATE              = 0x10, //PSTN
27	SET_HOOK_STATE                  = 0x11, //PSTN
28	PULSE_SETUP                     = 0x12, //PSTN
29	SEND_PULSE                      = 0x13, //PSTN
30	SET_PULSE_TIME                  = 0x14, //PSTN
31	RING_AUX_JACK                   = 0x15, //PSTN
32	/* RESERVED (future use) 16h-1Fh */
33	SET_LINE_CODING                 = 0x20, //PSTN
34	GET_LINE_CODING                 = 0x21, //PSTN
35	SET_CONTROL_LINE_STATE          = 0x22, //PSTN
36	SEND_BREAK                      = 0x23, //PSTN
37	/* RESERVED (future use) 24h-2Fh */
38	SET_RINGER_PARMS                = 0x30, //PSTN
39	GET_RINGER_PARMS                = 0x31, //PSTN
40	SET_OPERATION_PARMS             = 0x32, //PSTN
41	GET_OPERATION_PARMS             = 0x33, //PSTN
42	SET_LINE_PARMS                  = 0x34, //PSTN
43
44	GET_LINE_PARMS                  = 0x35, //PSTN
45	DIAL_DIGITS                     = 0x36, //PSTN
46	SET_UNIT_PARAMETER              = 0x37, //ISDN
47	GET_UNIT_PARAMETER              = 0x38, //ISDN
48	CLEAR_UNIT_PARAMETER            = 0x39, //ISDN
49	GET_PROFILE                     = 0x3A, //ISDN
50	/* RESERVED (future use) 3Bh-3Fh */
51	SET_ETHERNET_MULTICAST_FILTERS  = 0x40, //ECM
52	SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x41, //ECM
53	GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x42, //ECM
54	SET_ETHERNET_PACKET_FILTER      = 0x43, //ECM
55	GET_ETHERNET_STATISTIC          = 0x44, //ECM
56	/* RESERVED (future use) 45h-4Fh */
57	SET_ATM_DATA_FORMAT             = 0x50, //ATM
58	GET_ATM_DEVICE_STATISTICS       = 0x51, //ATM
59	SET_ATM_DEFAULT_VC              = 0x52, //ATM
60	GET_ATM_VC_STATISTICS           = 0x53, //ATM
61	/* RESERVED (future use) 54h-5Fh */
62	/* MDLM Semantic-Model specific Requests 60h ��� 7Fh */
63	GET_NTB_PARAMETERS              = 0x80, //NCM
64	GET_NET_ADDRESS                 = 0x81, //NCM
65	SET_NET_ADDRESS                 = 0x82, //NCM
66	GET_NTB_FORMAT                  = 0x83, //NCM
67	SET_NTB_FORMAT                  = 0x84, //NCM
68	GET_NTB_INPUT_SIZE              = 0x85, //NCM
69	SET_NTB_INPUT_SIZE              = 0x86, //NCM
70	GET_MAX_DATAGRAM_SIZE           = 0x87, //NCM
71	SET_MAX_DATAGRAM_SIZE           = 0x88, //NCM
72	GET_CRC_MODE                    = 0x89, //NCM
73	SET_CRC_MODE                    = 0x8A  //NCM
74	/* RESERVED (future use) 8Bh-FFh */
75};
76
77/* Management Element Notification (CDC spec 6.3) */
78#define CDC_NOTIFY_NETWORK_CONNECTION       0x0
79#define CDC_NOTIFY_RESPONSE_AVALIABLE       0x1
80#define CDC_NOTIFY_AUX_JACK_HOOL_STATE      0x8
81#define CDC_NOTIFY_RING_DETECT              0x9
82#define CDC_NOTIFY_SERIAL_STATE             0x20
83#define CDC_NOTIFY_CALL_STATE_CHANGE        0x28
84#define CDC_NOTIFY_LINE_STATE_CHANGE        0x29
85#define CDC_NOTIFY_CONNECTION_SPEED_CHANGE  0x2A
86
87struct func_desc {
88    uint8_t bFunctionLength;
89    uint8_t bDescriptorType;
90    uint8_t bDescriptorSubtype;
91} __attribute__ ((packed));
92
93struct header_desc {
94    uint8_t bFunctionLength;
95    uint8_t bDescriptorType;
96    uint8_t bDescriptorSubtype;
97    uint16_t bcdCDC;
98} __attribute__ ((packed));
99
100struct union_desc {
101    uint8_t bFunctionLength;
102    uint8_t bDescriptorType;
103    uint8_t bDescriptorSubtype;
104    uint8_t bControlInterface;
105    uint8_t bSubordinateInterface[0];
106} __attribute__ ((packed));
107
108#endif /* _DRIVERS_CDC_H_ */
109
110