xref: /haiku/src/add-ons/kernel/drivers/ports/usb_serial/Silicon.h (revision 1deede7388b04dbeec5af85cae7164735ea9e70d)
1 /*
2  * Copyright 2011, Adrien Destugues <pulkomandy@pulkomandy.ath.cx>
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Alexander von Gluck IV, kallisti5@unixzen.com
7  */
8 #ifndef _USB_SILICON_H_
9 #define _USB_SILICON_H_
10 
11 
12 #include "SerialDevice.h"
13 
14 
15 /* supported vendor and product ids */
16 #define VENDOR_RENESAS		0x045B
17 #define VENDOR_AKATOM		0x0471
18 #define VENDOR_PIRELLI		0x0489
19 #define VENDOR_CYPHERLAB	0x0745
20 #define VENDOR_GEMALTO		0x08E6
21 #define VENDOR_DIGIANSWER	0x08FD
22 #define VENDOR_MEI			0x0BED
23 #define VENDOR_DYNASTREAM	0x0FCF
24 #define VENDOR_KNOCKOFF		0x10A6
25 #define VENDOR_SIEMENS		0x10AB
26 #define VENDOR_NOKIA		0x10B5
27 #define VENDOR_SILICON		0x10C4
28 #define VENDOR_SILICON2		0x10C5
29 #define VENDOR_SILICON3		0x10CE
30 #define VENDOR_BALTECH		0x13AD
31 #define VENDOR_OWEN			0x1555
32 #define VENDOR_CLIPSAL		0x166A
33 #define VENDOR_JABLOTRON	0x16D6
34 #define VENDOR_WIENER		0x16DC
35 #define VENDOR_WAVESENSE	0x17F4
36 #define VENDOR_VAISALA		0x1843
37 #define VENDOR_ELV			0x18EF
38 #define VENDOR_WAGO			0x1BE3
39 #define VENDOR_DW700		0x413C
40 
41 const usb_serial_device kSiliconDevices[] = {
42 	{VENDOR_RENESAS,	0x0053, "Renesas RX610 RX-Stick"},
43 	{VENDOR_AKATOM,		0x066A, "AKTAKOM ACE-1001"},
44 	{VENDOR_PIRELLI,	0xE000, "Pirelli DP-L10 GSM Mobile"},
45 	{VENDOR_PIRELLI,	0xE003, "Pirelli DP-L10 GSM Mobile"},
46 	{VENDOR_CYPHERLAB,	0x1000, "Cipherlab CCD Barcode Scanner"},
47 	{VENDOR_GEMALTO,	0x5501, "Gemalto contactless smartcard reader"},
48 	{VENDOR_DIGIANSWER,	0x000A, "Digianswer ZigBee MAC device"},
49 	{VENDOR_MEI,		0x1100, "MEI Acceptor"},
50 	{VENDOR_MEI,		0x1101, "MEI Acceptor"},
51 	{VENDOR_DYNASTREAM,	0x1003, "Dynastream ANT development board"},
52 	{VENDOR_DYNASTREAM,	0x1004, "Dynastream ANT development board"},
53 	{VENDOR_DYNASTREAM,	0x1006, "Dynastream ANT development board"},
54 	{VENDOR_KNOCKOFF,	0xAA26, "Knock-off DCU-11"},
55 	{VENDOR_SIEMENS,	0x10C5, "Siemens MC60"},
56 	{VENDOR_NOKIA,		0xAC70, "Nokia CA-42"},
57 	{VENDOR_BALTECH,	0x9999, "Balteck card reader"},
58 	{VENDOR_OWEN,		0x0004, "Owen AC4 USB-RS485 Converter"},
59 	{VENDOR_CLIPSAL,	0x0303, "Clipsal 5500PCU C-Bus USB interface"},
60 	{VENDOR_JABLOTRON,	0x0001, "Jablotron serial interface"},
61 	{VENDOR_WIENER,		0x0010, "W-IE-NE-R Plein & Baus GmbH device"},
62 	{VENDOR_WIENER,		0x0011, "W-IE-NE-R Plein & Baus GmbH device"},
63 	{VENDOR_WIENER,		0x0012, "W-IE-NE-R Plein & Baus GmbH device"},
64 	{VENDOR_WIENER,		0x0015, "W-IE-NE-R Plein & Baus GmbH device"},
65 	{VENDOR_WAVESENSE,	0xAAAA, "Wavesense Jazz blood glucose meter"},
66 	{VENDOR_VAISALA,	0x0200, "Vaisala USB instrument"},
67 	{VENDOR_ELV,		0xE00F, "ELV USB I²C interface"},
68 	{VENDOR_WAGO,		0x07A6, "WAGO 750-923 USB Service"},
69 	{VENDOR_DW700,		0x9500, "DW700 GPS USB interface"},
70 	{VENDOR_SILICON,	0x0F91, "Silicon Labs CP210x USB UART converter"},
71 	{VENDOR_SILICON,	0x1101, "Silicon Labs CP210x USB UART converter"},
72 	{VENDOR_SILICON,	0x1601, "Silicon Labs CP210x USB UART converter"},
73 	{VENDOR_SILICON,	0x800A, "Silicon Labs CP210x USB UART converter"},
74 	{VENDOR_SILICON,	0x803B, "Silicon Labs CP210x USB UART converter"},
75 	{VENDOR_SILICON,	0x8044, "Silicon Labs CP210x USB UART converter"},
76 	{VENDOR_SILICON,	0x804E, "Silicon Labs CP210x USB UART converter"},
77 	{VENDOR_SILICON,	0x8053, "Silicon Labs CP210x USB UART converter"},
78 	{VENDOR_SILICON,	0x8054, "Silicon Labs CP210x USB UART converter"},
79 	{VENDOR_SILICON,	0x8066, "Silicon Labs CP210x USB UART converter"},
80 	{VENDOR_SILICON,	0x806F, "Silicon Labs CP210x USB UART converter"},
81 	{VENDOR_SILICON,	0x807A, "Silicon Labs CP210x USB UART converter"},
82 	{VENDOR_SILICON,	0x80CA, "Silicon Labs CP210x USB UART converter"},
83 	{VENDOR_SILICON,	0x80DD, "Silicon Labs CP210x USB UART converter"},
84 	{VENDOR_SILICON,	0x80F6, "Silicon Labs CP210x USB UART converter"},
85 	{VENDOR_SILICON,	0x8115, "Silicon Labs CP210x USB UART converter"},
86 	{VENDOR_SILICON,	0x813D, "Silicon Labs CP210x USB UART converter"},
87 	{VENDOR_SILICON,	0x813F, "Silicon Labs CP210x USB UART converter"},
88 	{VENDOR_SILICON,	0x814A, "Silicon Labs CP210x USB UART converter"},
89 	{VENDOR_SILICON,	0x814B, "Silicon Labs CP210x USB UART converter"},
90 	{VENDOR_SILICON,	0x8156, "Silicon Labs CP210x USB UART converter"},
91 	{VENDOR_SILICON,	0x815E, "Silicon Labs CP210x USB UART converter"},
92 	{VENDOR_SILICON,	0x818B, "Silicon Labs CP210x USB UART converter"},
93 	{VENDOR_SILICON,	0x819F, "Silicon Labs CP210x USB UART converter"},
94 	{VENDOR_SILICON,	0x81A6, "Silicon Labs CP210x USB UART converter"},
95 	{VENDOR_SILICON,	0x81AC, "Silicon Labs CP210x USB UART converter"},
96 	{VENDOR_SILICON,	0x81AD, "Silicon Labs CP210x USB UART converter"},
97 	{VENDOR_SILICON,	0x81C8, "Silicon Labs CP210x USB UART converter"},
98 	{VENDOR_SILICON,	0x81E2, "Silicon Labs CP210x USB UART converter"},
99 	{VENDOR_SILICON,	0x81E7, "Silicon Labs CP210x USB UART converter"},
100 	{VENDOR_SILICON,	0x81E8, "Silicon Labs CP210x USB UART converter"},
101 	{VENDOR_SILICON,	0x81F2, "Silicon Labs CP210x USB UART converter"},
102 	{VENDOR_SILICON,	0x8218, "Silicon Labs CP210x USB UART converter"},
103 	{VENDOR_SILICON,	0x822B, "Silicon Labs CP210x USB UART converter"},
104 	{VENDOR_SILICON,	0x826B, "Silicon Labs CP210x USB UART converter"},
105 	{VENDOR_SILICON,	0x8293, "Silicon Labs CP210x USB UART converter"},
106 	{VENDOR_SILICON,	0x82F9, "Silicon Labs CP210x USB UART converter"},
107 	{VENDOR_SILICON,	0x8341, "Silicon Labs CP210x USB UART converter"},
108 	{VENDOR_SILICON,	0x8382, "Silicon Labs CP210x USB UART converter"},
109 	{VENDOR_SILICON,	0x83A8, "Silicon Labs CP210x USB UART converter"},
110 	{VENDOR_SILICON,	0x83D8, "Silicon Labs CP210x USB UART converter"},
111 	{VENDOR_SILICON,	0x8411, "Silicon Labs CP210x USB UART converter"},
112 	{VENDOR_SILICON,	0x8418, "Silicon Labs CP210x USB UART converter"},
113 	{VENDOR_SILICON,	0x846E, "Silicon Labs CP210x USB UART converter"},
114 	{VENDOR_SILICON,	0x8477, "Silicon Labs CP210x USB UART converter"},
115 	{VENDOR_SILICON,	0x85EA, "Silicon Labs CP210x USB UART converter"},
116 	{VENDOR_SILICON,	0x85EB, "Silicon Labs CP210x USB UART converter"},
117 	{VENDOR_SILICON,	0x8664, "Silicon Labs CP210x USB UART converter"},
118 	{VENDOR_SILICON,	0x8665, "Silicon Labs CP210x USB UART converter"},
119 	{VENDOR_SILICON,	0xEA60, "Silicon Labs CP210x USB UART converter"},
120 	{VENDOR_SILICON,	0xEA61, "Silicon Labs CP210x USB UART converter"},
121 	{VENDOR_SILICON,	0xEA71, "Silicon Labs CP210x USB UART converter"},
122 	{VENDOR_SILICON,	0xF001, "Silicon Labs CP210x USB UART converter"},
123 	{VENDOR_SILICON,	0xF002, "Silicon Labs CP210x USB UART converter"},
124 	{VENDOR_SILICON,	0xF003, "Silicon Labs CP210x USB UART converter"},
125 	{VENDOR_SILICON,	0xF004, "Silicon Labs CP210x USB UART converter"},
126 	{VENDOR_SILICON2,	0xEA61, "Silicon Labs GPRS USB Modem"},
127 	{VENDOR_SILICON3,	0xEA6A, "Silicon Labs GPRS USB Modem 100EU"}
128 };
129 
130 
131 class SiliconDevice : public SerialDevice {
132 public:
133 					SiliconDevice(usb_device device, uint16 vendorID,
134 						uint16 productID, const char *description);
135 
136 virtual	status_t	AddDevice(const usb_configuration_info *config);
137 
138 virtual	status_t	ResetDevice();
139 
140 virtual	status_t	SetLineCoding(usb_cdc_line_coding *coding);
141 virtual	status_t	SetControlLineState(uint16 state);
142 
143 private:
144 enum CP210XRequest {
145 	ENABLE_UART = 0,
146 		/* 1 to enable the UART function, 0 to disable
147 		 * (some Silicon Labs chips have other functions such as GPIOs) */
148 
149 
150 	SET_BAUDRATE_DIVIDER = 1,
151 	GET_BAUDRATE_DIVIDER = 2,
152 		/*
153 		 Baudrate base clock is 3686400
154 
155 		 3686400 / 32 = 115200
156 		 ...
157 		 3686400 / 384 = 9600
158 		*/
159 
160 	SET_LINE_FORMAT = 3,
161 	GET_LINE_FORMAT = 4,
162 		/*
163 		 DataBits << 0x100 | Parity << 0x10 | StopBits
164 
165 		 Databits in [5,9]
166 		 Parity :
167 		 	0 = none
168 			1 = odd
169 			2 = even
170 			3 = mark
171 			4 = space
172 		Stop bits:
173 			0 = 1 stop bit
174 			1 = 1.5 stop bits
175 			2 = 2 stop bits
176 		*/
177 
178 	SET_BREAK = 5,
179 		/* 1 to enable, 0 to disable */
180 
181 	IMMEDIATE_CHAR = 6,
182 
183 	SET_STATUS = 7,
184 	GET_STATUS = 8,
185 		/*
186 		 bit 0 = DTR
187 		 bit 1 = RTS
188 
189 		 bit 4 = CTS
190 		 bit 5 = DSR
191 		 bit 6 = RING
192 		 bit 7 = DCD
193 		 bit 8 = WRITE_DTR (unset to not touch DTR)
194 		 bit 9 = WRITE_RTS (unset to not touch RTS)
195 		*/
196 
197 	SET_XON = 9,
198 	SET_XOFF = 10,
199 	SET_EVENTMASK = 11,
200 	GET_EVENTMASK = 12,
201 	SET_CHAR = 13,
202 	GET_CHARS = 14,
203 	GET_PROPS = 15,
204 	GET_COMM_STATUS = 16,
205 	RESET = 17,
206 	PURGE = 18,
207 
208 	SET_FLOW = 19,
209 	GET_FLOW = 20,
210 		/* Hardware flow control setup */
211 
212 	EMBED_EVENTS = 21,
213 	GET_EVENTSTATE = 22,
214 	SET_CHARS = 0x19
215 };
216 
217 private:
218 status_t 			WriteConfig(CP210XRequest request, uint16_t* data,
219 						size_t size);
220 };
221 
222 
223 #endif //_USB_SILICON_H_
224