Commit | Line | Data |
---|---|---|
5fd54ace | 1 | // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) |
b72458a8 | 2 | /*- |
3 | * Copyright (c) 2003, 2004 | |
4 | * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. | |
5 | * | |
0eb0226c SG |
6 | * Copyright (c) 2005-2007 Matthieu Castet <castet.matthieu@free.fr> |
7 | * Copyright (c) 2005-2007 Stanislaw Gruszka <stf_xl@wp.pl> | |
b72458a8 | 8 | * |
9 | * This software is available to you under a choice of one of two | |
10 | * licenses. You may choose to be licensed under the terms of the GNU | |
11 | * General Public License (GPL) Version 2, available from the file | |
12 | * COPYING in the main directory of this source tree, or the | |
13 | * BSD license below: | |
14 | * | |
15 | * Redistribution and use in source and binary forms, with or without | |
16 | * modification, are permitted provided that the following conditions | |
17 | * are met: | |
18 | * 1. Redistributions of source code must retain the above copyright | |
19 | * notice unmodified, this list of conditions, and the following | |
20 | * disclaimer. | |
21 | * 2. Redistributions in binary form must reproduce the above copyright | |
22 | * notice, this list of conditions and the following disclaimer in the | |
23 | * documentation and/or other materials provided with the distribution. | |
24 | * | |
25 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
35 | * SUCH DAMAGE. | |
36 | * | |
37 | * GPL license : | |
38 | * This program is free software; you can redistribute it and/or | |
39 | * modify it under the terms of the GNU General Public License | |
40 | * as published by the Free Software Foundation; either version 2 | |
41 | * of the License, or (at your option) any later version. | |
42 | * | |
43 | * This program is distributed in the hope that it will be useful, | |
44 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
45 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
46 | * GNU General Public License for more details. | |
47 | * | |
48 | * You should have received a copy of the GNU General Public License | |
49 | * along with this program; if not, write to the Free Software | |
50 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
51 | * | |
52 | * | |
53 | * HISTORY : some part of the code was base on ueagle 1.3 BSD driver, | |
54 | * Damien Bergamini agree to put his code under a DUAL GPL/BSD license. | |
55 | * | |
56 | * The rest of the code was was rewritten from scratch. | |
57 | */ | |
58 | ||
59 | #include <linux/module.h> | |
60 | #include <linux/moduleparam.h> | |
b72458a8 | 61 | #include <linux/crc32.h> |
62 | #include <linux/usb.h> | |
63 | #include <linux/firmware.h> | |
64 | #include <linux/ctype.h> | |
5371f80a | 65 | #include <linux/sched.h> |
b72458a8 | 66 | #include <linux/kthread.h> |
ab3c81ff | 67 | #include <linux/mutex.h> |
7dfb7103 | 68 | #include <linux/freezer.h> |
5a0e3ad6 | 69 | #include <linux/slab.h> |
e644814a | 70 | #include <linux/kernel.h> |
7dfb7103 | 71 | |
b72458a8 | 72 | #include <asm/unaligned.h> |
73 | ||
74 | #include "usbatm.h" | |
75 | ||
a7a0c9cd | 76 | #define EAGLEUSBVERSION "ueagle 1.4" |
b72458a8 | 77 | |
78 | ||
79 | /* | |
80 | * Debug macros | |
81 | */ | |
82 | #define uea_dbg(usb_dev, format, args...) \ | |
83 | do { \ | |
84 | if (debug >= 1) \ | |
85 | dev_dbg(&(usb_dev)->dev, \ | |
86 | "[ueagle-atm dbg] %s: " format, \ | |
441b62c1 | 87 | __func__, ##args); \ |
a7a0c9cd | 88 | } while (0) |
b72458a8 | 89 | |
90 | #define uea_vdbg(usb_dev, format, args...) \ | |
91 | do { \ | |
92 | if (debug >= 2) \ | |
93 | dev_dbg(&(usb_dev)->dev, \ | |
94 | "[ueagle-atm vdbg] " format, ##args); \ | |
a7a0c9cd | 95 | } while (0) |
b72458a8 | 96 | |
97 | #define uea_enters(usb_dev) \ | |
4545f7ee | 98 | uea_vdbg(usb_dev, "entering %s\n" , __func__) |
b72458a8 | 99 | |
100 | #define uea_leaves(usb_dev) \ | |
4545f7ee | 101 | uea_vdbg(usb_dev, "leaving %s\n" , __func__) |
b72458a8 | 102 | |
4545f7ee JBTN |
103 | #define uea_err(usb_dev, format, args...) \ |
104 | dev_err(&(usb_dev)->dev , "[UEAGLE-ATM] " format , ##args) | |
b72458a8 | 105 | |
4545f7ee JBTN |
106 | #define uea_warn(usb_dev, format, args...) \ |
107 | dev_warn(&(usb_dev)->dev , "[Ueagle-atm] " format, ##args) | |
b72458a8 | 108 | |
4545f7ee JBTN |
109 | #define uea_info(usb_dev, format, args...) \ |
110 | dev_info(&(usb_dev)->dev , "[ueagle-atm] " format, ##args) | |
b72458a8 | 111 | |
c8e46379 SG |
112 | struct intr_pkt; |
113 | ||
114 | /* cmv's from firmware */ | |
115 | struct uea_cmvs_v1 { | |
b72458a8 | 116 | u32 address; |
117 | u16 offset; | |
118 | u32 data; | |
58607307 | 119 | } __packed; |
b72458a8 | 120 | |
c8e46379 SG |
121 | struct uea_cmvs_v2 { |
122 | u32 group; | |
123 | u32 address; | |
124 | u32 offset; | |
125 | u32 data; | |
58607307 | 126 | } __packed; |
c8e46379 SG |
127 | |
128 | /* information about currently processed cmv */ | |
129 | struct cmv_dsc_e1 { | |
130 | u8 function; | |
131 | u16 idx; | |
132 | u32 address; | |
133 | u16 offset; | |
134 | }; | |
135 | ||
136 | struct cmv_dsc_e4 { | |
137 | u16 function; | |
138 | u16 offset; | |
139 | u16 address; | |
140 | u16 group; | |
141 | }; | |
142 | ||
143 | union cmv_dsc { | |
144 | struct cmv_dsc_e1 e1; | |
145 | struct cmv_dsc_e4 e4; | |
146 | }; | |
147 | ||
b72458a8 | 148 | struct uea_softc { |
149 | struct usb_device *usb_dev; | |
150 | struct usbatm_data *usbatm; | |
151 | ||
152 | int modem_index; | |
153 | unsigned int driver_info; | |
603cf608 SG |
154 | int annex; |
155 | #define ANNEXA 0 | |
156 | #define ANNEXB 1 | |
b72458a8 | 157 | |
158 | int booting; | |
159 | int reset; | |
160 | ||
161 | wait_queue_head_t sync_q; | |
162 | ||
163 | struct task_struct *kthread; | |
164 | u32 data; | |
c8e46379 | 165 | u32 data1; |
c8e46379 | 166 | |
b72458a8 | 167 | int cmv_ack; |
c8e46379 | 168 | union cmv_dsc cmv_dsc; |
b72458a8 | 169 | |
170 | struct work_struct task; | |
171 | u16 pageno; | |
172 | u16 ovl; | |
173 | ||
174 | const struct firmware *dsp_firm; | |
175 | struct urb *urb_int; | |
176 | ||
62b5c80a SB |
177 | void (*dispatch_cmv)(struct uea_softc *, struct intr_pkt *); |
178 | void (*schedule_load_page)(struct uea_softc *, struct intr_pkt *); | |
179 | int (*stat)(struct uea_softc *); | |
180 | int (*send_cmvs)(struct uea_softc *); | |
b72458a8 | 181 | |
182 | /* keep in sync with eaglectl */ | |
183 | struct uea_stats { | |
184 | struct { | |
185 | u32 state; | |
186 | u32 flags; | |
187 | u32 mflags; | |
188 | u32 vidcpe; | |
189 | u32 vidco; | |
190 | u32 dsrate; | |
191 | u32 usrate; | |
192 | u32 dsunc; | |
193 | u32 usunc; | |
194 | u32 dscorr; | |
195 | u32 uscorr; | |
196 | u32 txflow; | |
197 | u32 rxflow; | |
198 | u32 usattenuation; | |
199 | u32 dsattenuation; | |
200 | u32 dsmargin; | |
201 | u32 usmargin; | |
202 | u32 firmid; | |
203 | } phy; | |
204 | } stats; | |
205 | }; | |
206 | ||
207 | /* | |
208 | * Elsa IDs | |
209 | */ | |
210 | #define ELSA_VID 0x05CC | |
211 | #define ELSA_PID_PSTFIRM 0x3350 | |
212 | #define ELSA_PID_PREFIRM 0x3351 | |
213 | ||
603cf608 SG |
214 | #define ELSA_PID_A_PREFIRM 0x3352 |
215 | #define ELSA_PID_A_PSTFIRM 0x3353 | |
216 | #define ELSA_PID_B_PREFIRM 0x3362 | |
217 | #define ELSA_PID_B_PSTFIRM 0x3363 | |
218 | ||
b72458a8 | 219 | /* |
603cf608 | 220 | * Devolo IDs : pots if (pid & 0x10) |
b72458a8 | 221 | */ |
603cf608 SG |
222 | #define DEVOLO_VID 0x1039 |
223 | #define DEVOLO_EAGLE_I_A_PID_PSTFIRM 0x2110 | |
224 | #define DEVOLO_EAGLE_I_A_PID_PREFIRM 0x2111 | |
225 | ||
226 | #define DEVOLO_EAGLE_I_B_PID_PSTFIRM 0x2100 | |
227 | #define DEVOLO_EAGLE_I_B_PID_PREFIRM 0x2101 | |
228 | ||
229 | #define DEVOLO_EAGLE_II_A_PID_PSTFIRM 0x2130 | |
230 | #define DEVOLO_EAGLE_II_A_PID_PREFIRM 0x2131 | |
231 | ||
232 | #define DEVOLO_EAGLE_II_B_PID_PSTFIRM 0x2120 | |
233 | #define DEVOLO_EAGLE_II_B_PID_PREFIRM 0x2121 | |
234 | ||
235 | /* | |
236 | * Reference design USB IDs | |
237 | */ | |
238 | #define ANALOG_VID 0x1110 | |
239 | #define ADI930_PID_PREFIRM 0x9001 | |
240 | #define ADI930_PID_PSTFIRM 0x9000 | |
241 | ||
b72458a8 | 242 | #define EAGLE_I_PID_PREFIRM 0x9010 /* Eagle I */ |
243 | #define EAGLE_I_PID_PSTFIRM 0x900F /* Eagle I */ | |
244 | ||
245 | #define EAGLE_IIC_PID_PREFIRM 0x9024 /* Eagle IIC */ | |
246 | #define EAGLE_IIC_PID_PSTFIRM 0x9023 /* Eagle IIC */ | |
247 | ||
248 | #define EAGLE_II_PID_PREFIRM 0x9022 /* Eagle II */ | |
249 | #define EAGLE_II_PID_PSTFIRM 0x9021 /* Eagle II */ | |
250 | ||
b72458a8 | 251 | #define EAGLE_III_PID_PREFIRM 0x9032 /* Eagle III */ |
252 | #define EAGLE_III_PID_PSTFIRM 0x9031 /* Eagle III */ | |
253 | ||
c8e46379 SG |
254 | #define EAGLE_IV_PID_PREFIRM 0x9042 /* Eagle IV */ |
255 | #define EAGLE_IV_PID_PSTFIRM 0x9041 /* Eagle IV */ | |
256 | ||
b72458a8 | 257 | /* |
258 | * USR USB IDs | |
259 | */ | |
260 | #define USR_VID 0x0BAF | |
261 | #define MILLER_A_PID_PREFIRM 0x00F2 | |
262 | #define MILLER_A_PID_PSTFIRM 0x00F1 | |
263 | #define MILLER_B_PID_PREFIRM 0x00FA | |
264 | #define MILLER_B_PID_PSTFIRM 0x00F9 | |
265 | #define HEINEKEN_A_PID_PREFIRM 0x00F6 | |
266 | #define HEINEKEN_A_PID_PSTFIRM 0x00F5 | |
267 | #define HEINEKEN_B_PID_PREFIRM 0x00F8 | |
268 | #define HEINEKEN_B_PID_PSTFIRM 0x00F7 | |
269 | ||
270 | #define PREFIRM 0 | |
271 | #define PSTFIRM (1<<7) | |
603cf608 SG |
272 | #define AUTO_ANNEX_A (1<<8) |
273 | #define AUTO_ANNEX_B (1<<9) | |
274 | ||
b72458a8 | 275 | enum { |
276 | ADI930 = 0, | |
277 | EAGLE_I, | |
278 | EAGLE_II, | |
c8e46379 SG |
279 | EAGLE_III, |
280 | EAGLE_IV | |
b72458a8 | 281 | }; |
282 | ||
283 | /* macros for both struct usb_device_id and struct uea_softc */ | |
284 | #define UEA_IS_PREFIRM(x) \ | |
285 | (!((x)->driver_info & PSTFIRM)) | |
286 | #define UEA_CHIP_VERSION(x) \ | |
287 | ((x)->driver_info & 0xf) | |
288 | ||
603cf608 SG |
289 | #define IS_ISDN(x) \ |
290 | ((x)->annex & ANNEXB) | |
b72458a8 | 291 | |
4545f7ee | 292 | #define INS_TO_USBDEV(ins) (ins->usb_dev) |
b72458a8 | 293 | |
294 | #define GET_STATUS(data) \ | |
295 | ((data >> 8) & 0xf) | |
c8e46379 | 296 | |
b72458a8 | 297 | #define IS_OPERATIONAL(sc) \ |
c8e46379 SG |
298 | ((UEA_CHIP_VERSION(sc) != EAGLE_IV) ? \ |
299 | (GET_STATUS(sc->stats.phy.state) == 2) : \ | |
300 | (sc->stats.phy.state == 7)) | |
b72458a8 | 301 | |
302 | /* | |
303 | * Set of macros to handle unaligned data in the firmware blob. | |
304 | * The FW_GET_BYTE() macro is provided only for consistency. | |
305 | */ | |
306 | ||
4545f7ee | 307 | #define FW_GET_BYTE(p) (*((__u8 *) (p))) |
b72458a8 | 308 | |
309 | #define FW_DIR "ueagle-atm/" | |
47282502 TG |
310 | #define EAGLE_FIRMWARE FW_DIR "eagle.fw" |
311 | #define ADI930_FIRMWARE FW_DIR "adi930.fw" | |
312 | #define EAGLE_I_FIRMWARE FW_DIR "eagleI.fw" | |
313 | #define EAGLE_II_FIRMWARE FW_DIR "eagleII.fw" | |
314 | #define EAGLE_III_FIRMWARE FW_DIR "eagleIII.fw" | |
315 | #define EAGLE_IV_FIRMWARE FW_DIR "eagleIV.fw" | |
316 | ||
317 | #define DSP4I_FIRMWARE FW_DIR "DSP4i.bin" | |
318 | #define DSP4P_FIRMWARE FW_DIR "DSP4p.bin" | |
319 | #define DSP9I_FIRMWARE FW_DIR "DSP9i.bin" | |
320 | #define DSP9P_FIRMWARE FW_DIR "DSP9p.bin" | |
321 | #define DSPEI_FIRMWARE FW_DIR "DSPei.bin" | |
322 | #define DSPEP_FIRMWARE FW_DIR "DSPep.bin" | |
323 | #define FPGA930_FIRMWARE FW_DIR "930-fpga.bin" | |
324 | ||
325 | #define CMV4P_FIRMWARE FW_DIR "CMV4p.bin" | |
326 | #define CMV4PV2_FIRMWARE FW_DIR "CMV4p.bin.v2" | |
327 | #define CMV4I_FIRMWARE FW_DIR "CMV4i.bin" | |
328 | #define CMV4IV2_FIRMWARE FW_DIR "CMV4i.bin.v2" | |
329 | #define CMV9P_FIRMWARE FW_DIR "CMV9p.bin" | |
330 | #define CMV9PV2_FIRMWARE FW_DIR "CMV9p.bin.v2" | |
331 | #define CMV9I_FIRMWARE FW_DIR "CMV9i.bin" | |
332 | #define CMV9IV2_FIRMWARE FW_DIR "CMV9i.bin.v2" | |
333 | #define CMVEP_FIRMWARE FW_DIR "CMVep.bin" | |
334 | #define CMVEPV2_FIRMWARE FW_DIR "CMVep.bin.v2" | |
335 | #define CMVEI_FIRMWARE FW_DIR "CMVei.bin" | |
336 | #define CMVEIV2_FIRMWARE FW_DIR "CMVei.bin.v2" | |
337 | ||
ade901d7 | 338 | #define UEA_FW_NAME_MAX 30 |
b72458a8 | 339 | #define NB_MODEM 4 |
340 | ||
341 | #define BULK_TIMEOUT 300 | |
342 | #define CTRL_TIMEOUT 1000 | |
343 | ||
22fcceb5 | 344 | #define ACK_TIMEOUT msecs_to_jiffies(3000) |
b72458a8 | 345 | |
4545f7ee | 346 | #define UEA_INTR_IFACE_NO 0 |
b72458a8 | 347 | #define UEA_US_IFACE_NO 1 |
348 | #define UEA_DS_IFACE_NO 2 | |
349 | ||
350 | #define FASTEST_ISO_INTF 8 | |
351 | ||
352 | #define UEA_BULK_DATA_PIPE 0x02 | |
353 | #define UEA_IDMA_PIPE 0x04 | |
354 | #define UEA_INTR_PIPE 0x04 | |
355 | #define UEA_ISO_DATA_PIPE 0x08 | |
356 | ||
4545f7ee | 357 | #define UEA_E1_SET_BLOCK 0x0001 |
c8e46379 | 358 | #define UEA_E4_SET_BLOCK 0x002c |
4545f7ee | 359 | #define UEA_SET_MODE 0x0003 |
b72458a8 | 360 | #define UEA_SET_2183_DATA 0x0004 |
361 | #define UEA_SET_TIMEOUT 0x0011 | |
362 | ||
363 | #define UEA_LOOPBACK_OFF 0x0002 | |
364 | #define UEA_LOOPBACK_ON 0x0003 | |
365 | #define UEA_BOOT_IDMA 0x0006 | |
366 | #define UEA_START_RESET 0x0007 | |
367 | #define UEA_END_RESET 0x0008 | |
368 | ||
369 | #define UEA_SWAP_MAILBOX (0x3fcd | 0x4000) | |
370 | #define UEA_MPTX_START (0x3fce | 0x4000) | |
371 | #define UEA_MPTX_MAILBOX (0x3fd6 | 0x4000) | |
372 | #define UEA_MPRX_MAILBOX (0x3fdf | 0x4000) | |
373 | ||
c8e46379 SG |
374 | /* block information in eagle4 dsp firmware */ |
375 | struct block_index { | |
376 | __le32 PageOffset; | |
377 | __le32 NotLastBlock; | |
378 | __le32 dummy; | |
379 | __le32 PageSize; | |
380 | __le32 PageAddress; | |
381 | __le16 dummy1; | |
382 | __le16 PageNumber; | |
58607307 | 383 | } __packed; |
c8e46379 SG |
384 | |
385 | #define E4_IS_BOOT_PAGE(PageSize) ((le32_to_cpu(PageSize)) & 0x80000000) | |
386 | #define E4_PAGE_BYTES(PageSize) ((le32_to_cpu(PageSize) & 0x7fffffff) * 4) | |
387 | ||
388 | #define E4_L1_STRING_HEADER 0x10 | |
389 | #define E4_MAX_PAGE_NUMBER 0x58 | |
390 | #define E4_NO_SWAPPAGE_HEADERS 0x31 | |
391 | ||
392 | /* l1_code is eagle4 dsp firmware format */ | |
393 | struct l1_code { | |
394 | u8 string_header[E4_L1_STRING_HEADER]; | |
395 | u8 page_number_to_block_index[E4_MAX_PAGE_NUMBER]; | |
396 | struct block_index page_header[E4_NO_SWAPPAGE_HEADERS]; | |
4545f7ee | 397 | u8 code[0]; |
58607307 | 398 | } __packed; |
c8e46379 SG |
399 | |
400 | /* structures describing a block within a DSP page */ | |
401 | struct block_info_e1 { | |
b72458a8 | 402 | __le16 wHdr; |
b72458a8 | 403 | __le16 wAddress; |
404 | __le16 wSize; | |
405 | __le16 wOvlOffset; | |
406 | __le16 wOvl; /* overlay */ | |
407 | __le16 wLast; | |
58607307 | 408 | } __packed; |
c8e46379 SG |
409 | #define E1_BLOCK_INFO_SIZE 12 |
410 | ||
411 | struct block_info_e4 { | |
412 | __be16 wHdr; | |
413 | __u8 bBootPage; | |
414 | __u8 bPageNumber; | |
415 | __be32 dwSize; | |
416 | __be32 dwAddress; | |
417 | __be16 wReserved; | |
58607307 | 418 | } __packed; |
c8e46379 | 419 | #define E4_BLOCK_INFO_SIZE 14 |
b72458a8 | 420 | |
c8e46379 SG |
421 | #define UEA_BIHDR 0xabcd |
422 | #define UEA_RESERVED 0xffff | |
423 | ||
424 | /* constants describing cmv type */ | |
425 | #define E1_PREAMBLE 0x535c | |
426 | #define E1_MODEMTOHOST 0x01 | |
427 | #define E1_HOSTTOMODEM 0x10 | |
428 | ||
429 | #define E1_MEMACCESS 0x1 | |
430 | #define E1_ADSLDIRECTIVE 0x7 | |
431 | #define E1_FUNCTION_TYPE(f) ((f) >> 4) | |
432 | #define E1_FUNCTION_SUBTYPE(f) ((f) & 0x0f) | |
433 | ||
434 | #define E4_MEMACCESS 0 | |
435 | #define E4_ADSLDIRECTIVE 0xf | |
436 | #define E4_FUNCTION_TYPE(f) ((f) >> 8) | |
437 | #define E4_FUNCTION_SIZE(f) ((f) & 0x0f) | |
438 | #define E4_FUNCTION_SUBTYPE(f) (((f) >> 4) & 0x0f) | |
b72458a8 | 439 | |
b72458a8 | 440 | /* for MEMACCESS */ |
c8e46379 SG |
441 | #define E1_REQUESTREAD 0x0 |
442 | #define E1_REQUESTWRITE 0x1 | |
443 | #define E1_REPLYREAD 0x2 | |
444 | #define E1_REPLYWRITE 0x3 | |
445 | ||
446 | #define E4_REQUESTREAD 0x0 | |
447 | #define E4_REQUESTWRITE 0x4 | |
448 | #define E4_REPLYREAD (E4_REQUESTREAD | 1) | |
449 | #define E4_REPLYWRITE (E4_REQUESTWRITE | 1) | |
450 | ||
b72458a8 | 451 | /* for ADSLDIRECTIVE */ |
c8e46379 SG |
452 | #define E1_KERNELREADY 0x0 |
453 | #define E1_MODEMREADY 0x1 | |
b72458a8 | 454 | |
c8e46379 SG |
455 | #define E4_KERNELREADY 0x0 |
456 | #define E4_MODEMREADY 0x1 | |
457 | ||
458 | #define E1_MAKEFUNCTION(t, s) (((t) & 0xf) << 4 | ((s) & 0xf)) | |
4545f7ee JBTN |
459 | #define E4_MAKEFUNCTION(t, st, s) (((t) & 0xf) << 8 | \ |
460 | ((st) & 0xf) << 4 | ((s) & 0xf)) | |
c8e46379 SG |
461 | |
462 | #define E1_MAKESA(a, b, c, d) \ | |
b72458a8 | 463 | (((c) & 0xff) << 24 | \ |
464 | ((d) & 0xff) << 16 | \ | |
465 | ((a) & 0xff) << 8 | \ | |
466 | ((b) & 0xff)) | |
c8e46379 SG |
467 | |
468 | #define E1_GETSA1(a) ((a >> 8) & 0xff) | |
469 | #define E1_GETSA2(a) (a & 0xff) | |
470 | #define E1_GETSA3(a) ((a >> 24) & 0xff) | |
471 | #define E1_GETSA4(a) ((a >> 16) & 0xff) | |
472 | ||
473 | #define E1_SA_CNTL E1_MAKESA('C', 'N', 'T', 'L') | |
474 | #define E1_SA_DIAG E1_MAKESA('D', 'I', 'A', 'G') | |
475 | #define E1_SA_INFO E1_MAKESA('I', 'N', 'F', 'O') | |
476 | #define E1_SA_OPTN E1_MAKESA('O', 'P', 'T', 'N') | |
477 | #define E1_SA_RATE E1_MAKESA('R', 'A', 'T', 'E') | |
478 | #define E1_SA_STAT E1_MAKESA('S', 'T', 'A', 'T') | |
479 | ||
480 | #define E4_SA_CNTL 1 | |
481 | #define E4_SA_STAT 2 | |
482 | #define E4_SA_INFO 3 | |
483 | #define E4_SA_TEST 4 | |
484 | #define E4_SA_OPTN 5 | |
485 | #define E4_SA_RATE 6 | |
486 | #define E4_SA_DIAG 7 | |
487 | #define E4_SA_CNFG 8 | |
488 | ||
489 | /* structures representing a CMV (Configuration and Management Variable) */ | |
490 | struct cmv_e1 { | |
491 | __le16 wPreamble; | |
492 | __u8 bDirection; | |
493 | __u8 bFunction; | |
494 | __le16 wIndex; | |
495 | __le32 dwSymbolicAddress; | |
b72458a8 | 496 | __le16 wOffsetAddress; |
497 | __le32 dwData; | |
58607307 | 498 | } __packed; |
b72458a8 | 499 | |
c8e46379 SG |
500 | struct cmv_e4 { |
501 | __be16 wGroup; | |
502 | __be16 wFunction; | |
503 | __be16 wOffset; | |
504 | __be16 wAddress; | |
4545f7ee | 505 | __be32 dwData[6]; |
58607307 | 506 | } __packed; |
c8e46379 SG |
507 | |
508 | /* structures representing swap information */ | |
509 | struct swap_info_e1 { | |
b72458a8 | 510 | __u8 bSwapPageNo; |
511 | __u8 bOvl; /* overlay */ | |
58607307 | 512 | } __packed; |
b72458a8 | 513 | |
c8e46379 SG |
514 | struct swap_info_e4 { |
515 | __u8 bSwapPageNo; | |
58607307 | 516 | } __packed; |
c8e46379 SG |
517 | |
518 | /* structures representing interrupt data */ | |
519 | #define e1_bSwapPageNo u.e1.s1.swapinfo.bSwapPageNo | |
520 | #define e1_bOvl u.e1.s1.swapinfo.bOvl | |
521 | #define e4_bSwapPageNo u.e4.s1.swapinfo.bSwapPageNo | |
522 | ||
523 | #define INT_LOADSWAPPAGE 0x0001 | |
524 | #define INT_INCOMINGCMV 0x0002 | |
525 | ||
526 | union intr_data_e1 { | |
527 | struct { | |
528 | struct swap_info_e1 swapinfo; | |
529 | __le16 wDataSize; | |
58607307 | 530 | } __packed s1; |
c8e46379 SG |
531 | struct { |
532 | struct cmv_e1 cmv; | |
533 | __le16 wDataSize; | |
58607307 CF |
534 | } __packed s2; |
535 | } __packed; | |
c8e46379 SG |
536 | |
537 | union intr_data_e4 { | |
538 | struct { | |
539 | struct swap_info_e4 swapinfo; | |
540 | __le16 wDataSize; | |
58607307 | 541 | } __packed s1; |
c8e46379 SG |
542 | struct { |
543 | struct cmv_e4 cmv; | |
544 | __le16 wDataSize; | |
58607307 CF |
545 | } __packed s2; |
546 | } __packed; | |
c8e46379 | 547 | |
b72458a8 | 548 | struct intr_pkt { |
549 | __u8 bType; | |
550 | __u8 bNotification; | |
551 | __le16 wValue; | |
552 | __le16 wIndex; | |
553 | __le16 wLength; | |
554 | __le16 wInterrupt; | |
b72458a8 | 555 | union { |
c8e46379 SG |
556 | union intr_data_e1 e1; |
557 | union intr_data_e4 e4; | |
558 | } u; | |
58607307 | 559 | } __packed; |
c8e46379 SG |
560 | |
561 | #define E1_INTR_PKT_SIZE 28 | |
562 | #define E4_INTR_PKT_SIZE 64 | |
b72458a8 | 563 | |
564 | static struct usb_driver uea_driver; | |
ab3c81ff | 565 | static DEFINE_MUTEX(uea_mutex); |
6f95b4b7 CF |
566 | static const char * const chip_name[] = { |
567 | "ADI930", "Eagle I", "Eagle II", "Eagle III", "Eagle IV"}; | |
b72458a8 | 568 | |
569 | static int modem_index; | |
570 | static unsigned int debug; | |
4545f7ee JBTN |
571 | static unsigned int altsetting[NB_MODEM] = { |
572 | [0 ... (NB_MODEM - 1)] = FASTEST_ISO_INTF}; | |
90ab5ee9 | 573 | static bool sync_wait[NB_MODEM]; |
b72458a8 | 574 | static char *cmv_file[NB_MODEM]; |
603cf608 | 575 | static int annex[NB_MODEM]; |
b72458a8 | 576 | |
577 | module_param(debug, uint, 0644); | |
578 | MODULE_PARM_DESC(debug, "module debug level (0=off,1=on,2=verbose)"); | |
503add46 SG |
579 | module_param_array(altsetting, uint, NULL, 0644); |
580 | MODULE_PARM_DESC(altsetting, "alternate setting for incoming traffic: 0=bulk, " | |
581 | "1=isoc slowest, ... , 8=isoc fastest (default)"); | |
b72458a8 | 582 | module_param_array(sync_wait, bool, NULL, 0644); |
583 | MODULE_PARM_DESC(sync_wait, "wait the synchronisation before starting ATM"); | |
584 | module_param_array(cmv_file, charp, NULL, 0644); | |
585 | MODULE_PARM_DESC(cmv_file, | |
586 | "file name with configuration and management variables"); | |
603cf608 SG |
587 | module_param_array(annex, uint, NULL, 0644); |
588 | MODULE_PARM_DESC(annex, | |
4545f7ee | 589 | "manually set annex a/b (0=auto, 1=annex a, 2=annex b)"); |
b72458a8 | 590 | |
337427f9 SG |
591 | #define uea_wait(sc, cond, timeo) \ |
592 | ({ \ | |
593 | int _r = wait_event_interruptible_timeout(sc->sync_q, \ | |
594 | (cond) || kthread_should_stop(), timeo); \ | |
595 | if (kthread_should_stop()) \ | |
596 | _r = -ENODEV; \ | |
597 | _r; \ | |
598 | }) | |
599 | ||
b72458a8 | 600 | #define UPDATE_ATM_STAT(type, val) \ |
601 | do { \ | |
602 | if (sc->usbatm->atm_dev) \ | |
603 | sc->usbatm->atm_dev->type = val; \ | |
604 | } while (0) | |
605 | ||
cc7b86c1 KH |
606 | #define UPDATE_ATM_SIGNAL(val) \ |
607 | do { \ | |
608 | if (sc->usbatm->atm_dev) \ | |
609 | atm_dev_signal_change(sc->usbatm->atm_dev, val); \ | |
610 | } while (0) | |
611 | ||
612 | ||
b72458a8 | 613 | /* Firmware loading */ |
614 | #define LOAD_INTERNAL 0xA0 | |
615 | #define F8051_USBCS 0x7f92 | |
616 | ||
617 | /** | |
618 | * uea_send_modem_cmd - Send a command for pre-firmware devices. | |
619 | */ | |
620 | static int uea_send_modem_cmd(struct usb_device *usb, | |
aafcd2f7 | 621 | u16 addr, u16 size, const u8 *buff) |
b72458a8 | 622 | { |
623 | int ret = -ENOMEM; | |
624 | u8 *xfer_buff; | |
625 | ||
5d7efe5b | 626 | xfer_buff = kmemdup(buff, size, GFP_KERNEL); |
b72458a8 | 627 | if (xfer_buff) { |
b72458a8 | 628 | ret = usb_control_msg(usb, |
629 | usb_sndctrlpipe(usb, 0), | |
630 | LOAD_INTERNAL, | |
631 | USB_DIR_OUT | USB_TYPE_VENDOR | | |
632 | USB_RECIP_DEVICE, addr, 0, xfer_buff, | |
633 | size, CTRL_TIMEOUT); | |
634 | kfree(xfer_buff); | |
635 | } | |
636 | ||
637 | if (ret < 0) | |
638 | return ret; | |
639 | ||
640 | return (ret == size) ? 0 : -EIO; | |
641 | } | |
642 | ||
4545f7ee JBTN |
643 | static void uea_upload_pre_firmware(const struct firmware *fw_entry, |
644 | void *context) | |
b72458a8 | 645 | { |
646 | struct usb_device *usb = context; | |
aafcd2f7 DW |
647 | const u8 *pfw; |
648 | u8 value; | |
b72458a8 | 649 | u32 crc = 0; |
650 | int ret, size; | |
651 | ||
652 | uea_enters(usb); | |
653 | if (!fw_entry) { | |
654 | uea_err(usb, "firmware is not available\n"); | |
655 | goto err; | |
656 | } | |
657 | ||
658 | pfw = fw_entry->data; | |
659 | size = fw_entry->size; | |
8d7802ed | 660 | if (size < 4) |
661 | goto err_fw_corrupted; | |
b72458a8 | 662 | |
a5abdeaf | 663 | crc = get_unaligned_le32(pfw); |
b72458a8 | 664 | pfw += 4; |
665 | size -= 4; | |
8d7802ed | 666 | if (crc32_be(0, pfw, size) != crc) |
667 | goto err_fw_corrupted; | |
b72458a8 | 668 | |
669 | /* | |
877d0310 | 670 | * Start to upload firmware : send reset |
b72458a8 | 671 | */ |
672 | value = 1; | |
673 | ret = uea_send_modem_cmd(usb, F8051_USBCS, sizeof(value), &value); | |
674 | ||
675 | if (ret < 0) { | |
676 | uea_err(usb, "modem reset failed with error %d\n", ret); | |
677 | goto err; | |
678 | } | |
679 | ||
8d7802ed | 680 | while (size > 3) { |
b72458a8 | 681 | u8 len = FW_GET_BYTE(pfw); |
a5abdeaf | 682 | u16 add = get_unaligned_le16(pfw + 1); |
8d7802ed | 683 | |
684 | size -= len + 3; | |
685 | if (size < 0) | |
686 | goto err_fw_corrupted; | |
687 | ||
b72458a8 | 688 | ret = uea_send_modem_cmd(usb, add, len, pfw + 3); |
689 | if (ret < 0) { | |
690 | uea_err(usb, "uploading firmware data failed " | |
691 | "with error %d\n", ret); | |
692 | goto err; | |
693 | } | |
694 | pfw += len + 3; | |
b72458a8 | 695 | } |
696 | ||
8d7802ed | 697 | if (size != 0) |
698 | goto err_fw_corrupted; | |
699 | ||
b72458a8 | 700 | /* |
701 | * Tell the modem we finish : de-assert reset | |
702 | */ | |
703 | value = 0; | |
704 | ret = uea_send_modem_cmd(usb, F8051_USBCS, 1, &value); | |
705 | if (ret < 0) | |
706 | uea_err(usb, "modem de-assert failed with error %d\n", ret); | |
707 | else | |
708 | uea_info(usb, "firmware uploaded\n"); | |
709 | ||
9ebfbd45 | 710 | goto err; |
8d7802ed | 711 | |
712 | err_fw_corrupted: | |
713 | uea_err(usb, "firmware is corrupted\n"); | |
b72458a8 | 714 | err: |
9ebfbd45 | 715 | release_firmware(fw_entry); |
b72458a8 | 716 | uea_leaves(usb); |
717 | } | |
718 | ||
719 | /** | |
720 | * uea_load_firmware - Load usb firmware for pre-firmware devices. | |
721 | */ | |
722 | static int uea_load_firmware(struct usb_device *usb, unsigned int ver) | |
723 | { | |
724 | int ret; | |
47282502 | 725 | char *fw_name = EAGLE_FIRMWARE; |
b72458a8 | 726 | |
727 | uea_enters(usb); | |
728 | uea_info(usb, "pre-firmware device, uploading firmware\n"); | |
729 | ||
730 | switch (ver) { | |
731 | case ADI930: | |
47282502 | 732 | fw_name = ADI930_FIRMWARE; |
b72458a8 | 733 | break; |
734 | case EAGLE_I: | |
47282502 | 735 | fw_name = EAGLE_I_FIRMWARE; |
b72458a8 | 736 | break; |
737 | case EAGLE_II: | |
47282502 | 738 | fw_name = EAGLE_II_FIRMWARE; |
b72458a8 | 739 | break; |
740 | case EAGLE_III: | |
47282502 | 741 | fw_name = EAGLE_III_FIRMWARE; |
b72458a8 | 742 | break; |
c8e46379 | 743 | case EAGLE_IV: |
47282502 | 744 | fw_name = EAGLE_IV_FIRMWARE; |
c8e46379 | 745 | break; |
b72458a8 | 746 | } |
747 | ||
9ebfbd45 | 748 | ret = request_firmware_nowait(THIS_MODULE, 1, fw_name, &usb->dev, |
4545f7ee JBTN |
749 | GFP_KERNEL, usb, |
750 | uea_upload_pre_firmware); | |
b72458a8 | 751 | if (ret) |
752 | uea_err(usb, "firmware %s is not available\n", fw_name); | |
753 | else | |
754 | uea_info(usb, "loading firmware %s\n", fw_name); | |
755 | ||
756 | uea_leaves(usb); | |
757 | return ret; | |
758 | } | |
759 | ||
760 | /* modem management : dsp firmware, send/read CMV, monitoring statistic | |
761 | */ | |
762 | ||
763 | /* | |
764 | * Make sure that the DSP code provided is safe to use. | |
765 | */ | |
aafcd2f7 | 766 | static int check_dsp_e1(const u8 *dsp, unsigned int len) |
b72458a8 | 767 | { |
768 | u8 pagecount, blockcount; | |
769 | u16 blocksize; | |
770 | u32 pageoffset; | |
771 | unsigned int i, j, p, pp; | |
772 | ||
b72458a8 | 773 | pagecount = FW_GET_BYTE(dsp); |
774 | p = 1; | |
775 | ||
776 | /* enough space for page offsets? */ | |
777 | if (p + 4 * pagecount > len) | |
778 | return 1; | |
779 | ||
780 | for (i = 0; i < pagecount; i++) { | |
781 | ||
a5abdeaf | 782 | pageoffset = get_unaligned_le32(dsp + p); |
b72458a8 | 783 | p += 4; |
784 | ||
785 | if (pageoffset == 0) | |
786 | continue; | |
787 | ||
788 | /* enough space for blockcount? */ | |
789 | if (pageoffset >= len) | |
790 | return 1; | |
791 | ||
792 | pp = pageoffset; | |
793 | blockcount = FW_GET_BYTE(dsp + pp); | |
794 | pp += 1; | |
795 | ||
796 | for (j = 0; j < blockcount; j++) { | |
797 | ||
798 | /* enough space for block header? */ | |
799 | if (pp + 4 > len) | |
800 | return 1; | |
801 | ||
802 | pp += 2; /* skip blockaddr */ | |
a5abdeaf | 803 | blocksize = get_unaligned_le16(dsp + pp); |
b72458a8 | 804 | pp += 2; |
805 | ||
806 | /* enough space for block data? */ | |
807 | if (pp + blocksize > len) | |
808 | return 1; | |
809 | ||
810 | pp += blocksize; | |
811 | } | |
812 | } | |
813 | ||
814 | return 0; | |
815 | } | |
816 | ||
aafcd2f7 | 817 | static int check_dsp_e4(const u8 *dsp, int len) |
c8e46379 SG |
818 | { |
819 | int i; | |
820 | struct l1_code *p = (struct l1_code *) dsp; | |
821 | unsigned int sum = p->code - dsp; | |
822 | ||
823 | if (len < sum) | |
824 | return 1; | |
825 | ||
826 | if (strcmp("STRATIPHY ANEXA", p->string_header) != 0 && | |
827 | strcmp("STRATIPHY ANEXB", p->string_header) != 0) | |
828 | return 1; | |
829 | ||
830 | for (i = 0; i < E4_MAX_PAGE_NUMBER; i++) { | |
831 | struct block_index *blockidx; | |
832 | u8 blockno = p->page_number_to_block_index[i]; | |
833 | if (blockno >= E4_NO_SWAPPAGE_HEADERS) | |
834 | continue; | |
835 | ||
836 | do { | |
837 | u64 l; | |
838 | ||
839 | if (blockno >= E4_NO_SWAPPAGE_HEADERS) | |
840 | return 1; | |
841 | ||
842 | blockidx = &p->page_header[blockno++]; | |
843 | if ((u8 *)(blockidx + 1) - dsp >= len) | |
844 | return 1; | |
845 | ||
846 | if (le16_to_cpu(blockidx->PageNumber) != i) | |
847 | return 1; | |
848 | ||
849 | l = E4_PAGE_BYTES(blockidx->PageSize); | |
850 | sum += l; | |
851 | l += le32_to_cpu(blockidx->PageOffset); | |
852 | if (l > len) | |
853 | return 1; | |
854 | ||
855 | /* zero is zero regardless endianes */ | |
856 | } while (blockidx->NotLastBlock); | |
857 | } | |
858 | ||
859 | return (sum == len) ? 0 : 1; | |
860 | } | |
861 | ||
b72458a8 | 862 | /* |
863 | * send data to the idma pipe | |
864 | * */ | |
aafcd2f7 | 865 | static int uea_idma_write(struct uea_softc *sc, const void *data, u32 size) |
b72458a8 | 866 | { |
867 | int ret = -ENOMEM; | |
868 | u8 *xfer_buff; | |
869 | int bytes_read; | |
870 | ||
5d7efe5b | 871 | xfer_buff = kmemdup(data, size, GFP_KERNEL); |
b72458a8 | 872 | if (!xfer_buff) { |
873 | uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); | |
874 | return ret; | |
875 | } | |
876 | ||
b72458a8 | 877 | ret = usb_bulk_msg(sc->usb_dev, |
878 | usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE), | |
879 | xfer_buff, size, &bytes_read, BULK_TIMEOUT); | |
880 | ||
881 | kfree(xfer_buff); | |
882 | if (ret < 0) | |
883 | return ret; | |
884 | if (size != bytes_read) { | |
885 | uea_err(INS_TO_USBDEV(sc), "size != bytes_read %d %d\n", size, | |
886 | bytes_read); | |
887 | return -EIO; | |
888 | } | |
889 | ||
890 | return 0; | |
891 | } | |
892 | ||
893 | static int request_dsp(struct uea_softc *sc) | |
894 | { | |
895 | int ret; | |
896 | char *dsp_name; | |
897 | ||
c8e46379 | 898 | if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { |
603cf608 | 899 | if (IS_ISDN(sc)) |
47282502 | 900 | dsp_name = DSP4I_FIRMWARE; |
c8e46379 | 901 | else |
47282502 | 902 | dsp_name = DSP4P_FIRMWARE; |
c8e46379 | 903 | } else if (UEA_CHIP_VERSION(sc) == ADI930) { |
603cf608 | 904 | if (IS_ISDN(sc)) |
47282502 | 905 | dsp_name = DSP9I_FIRMWARE; |
b72458a8 | 906 | else |
47282502 | 907 | dsp_name = DSP9P_FIRMWARE; |
b72458a8 | 908 | } else { |
603cf608 | 909 | if (IS_ISDN(sc)) |
47282502 | 910 | dsp_name = DSPEI_FIRMWARE; |
b72458a8 | 911 | else |
47282502 | 912 | dsp_name = DSPEP_FIRMWARE; |
b72458a8 | 913 | } |
914 | ||
e40abaf6 | 915 | ret = request_firmware(&sc->dsp_firm, dsp_name, &sc->usb_dev->dev); |
b72458a8 | 916 | if (ret < 0) { |
917 | uea_err(INS_TO_USBDEV(sc), | |
918 | "requesting firmware %s failed with error %d\n", | |
4545f7ee | 919 | dsp_name, ret); |
b72458a8 | 920 | return ret; |
921 | } | |
922 | ||
c8e46379 SG |
923 | if (UEA_CHIP_VERSION(sc) == EAGLE_IV) |
924 | ret = check_dsp_e4(sc->dsp_firm->data, sc->dsp_firm->size); | |
925 | else | |
926 | ret = check_dsp_e1(sc->dsp_firm->data, sc->dsp_firm->size); | |
927 | ||
928 | if (ret) { | |
b72458a8 | 929 | uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", |
930 | dsp_name); | |
931 | release_firmware(sc->dsp_firm); | |
932 | sc->dsp_firm = NULL; | |
933 | return -EILSEQ; | |
934 | } | |
935 | ||
936 | return 0; | |
937 | } | |
938 | ||
939 | /* | |
940 | * The uea_load_page() function must be called within a process context | |
941 | */ | |
c8e46379 | 942 | static void uea_load_page_e1(struct work_struct *work) |
b72458a8 | 943 | { |
c4028958 | 944 | struct uea_softc *sc = container_of(work, struct uea_softc, task); |
b72458a8 | 945 | u16 pageno = sc->pageno; |
946 | u16 ovl = sc->ovl; | |
c8e46379 | 947 | struct block_info_e1 bi; |
b72458a8 | 948 | |
aafcd2f7 | 949 | const u8 *p; |
b72458a8 | 950 | u8 pagecount, blockcount; |
951 | u16 blockaddr, blocksize; | |
952 | u32 pageoffset; | |
953 | int i; | |
954 | ||
955 | /* reload firmware when reboot start and it's loaded already */ | |
533726f7 | 956 | if (ovl == 0 && pageno == 0) { |
b72458a8 | 957 | release_firmware(sc->dsp_firm); |
958 | sc->dsp_firm = NULL; | |
959 | } | |
960 | ||
961 | if (sc->dsp_firm == NULL && request_dsp(sc) < 0) | |
962 | return; | |
963 | ||
964 | p = sc->dsp_firm->data; | |
965 | pagecount = FW_GET_BYTE(p); | |
966 | p += 1; | |
967 | ||
968 | if (pageno >= pagecount) | |
969 | goto bad1; | |
970 | ||
971 | p += 4 * pageno; | |
a5abdeaf | 972 | pageoffset = get_unaligned_le32(p); |
b72458a8 | 973 | |
974 | if (pageoffset == 0) | |
975 | goto bad1; | |
976 | ||
977 | p = sc->dsp_firm->data + pageoffset; | |
978 | blockcount = FW_GET_BYTE(p); | |
979 | p += 1; | |
980 | ||
981 | uea_dbg(INS_TO_USBDEV(sc), | |
982 | "sending %u blocks for DSP page %u\n", blockcount, pageno); | |
983 | ||
984 | bi.wHdr = cpu_to_le16(UEA_BIHDR); | |
985 | bi.wOvl = cpu_to_le16(ovl); | |
986 | bi.wOvlOffset = cpu_to_le16(ovl | 0x8000); | |
987 | ||
988 | for (i = 0; i < blockcount; i++) { | |
a5abdeaf | 989 | blockaddr = get_unaligned_le16(p); |
b72458a8 | 990 | p += 2; |
991 | ||
a5abdeaf | 992 | blocksize = get_unaligned_le16(p); |
b72458a8 | 993 | p += 2; |
994 | ||
995 | bi.wSize = cpu_to_le16(blocksize); | |
996 | bi.wAddress = cpu_to_le16(blockaddr); | |
997 | bi.wLast = cpu_to_le16((i == blockcount - 1) ? 1 : 0); | |
998 | ||
999 | /* send block info through the IDMA pipe */ | |
c8e46379 | 1000 | if (uea_idma_write(sc, &bi, E1_BLOCK_INFO_SIZE)) |
b72458a8 | 1001 | goto bad2; |
1002 | ||
1003 | /* send block data through the IDMA pipe */ | |
1004 | if (uea_idma_write(sc, p, blocksize)) | |
1005 | goto bad2; | |
1006 | ||
1007 | p += blocksize; | |
1008 | } | |
1009 | ||
1010 | return; | |
1011 | ||
1012 | bad2: | |
1013 | uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", i); | |
1014 | return; | |
1015 | bad1: | |
2a99b507 | 1016 | uea_err(INS_TO_USBDEV(sc), "invalid DSP page %u requested\n", pageno); |
b72458a8 | 1017 | } |
1018 | ||
c8e46379 SG |
1019 | static void __uea_load_page_e4(struct uea_softc *sc, u8 pageno, int boot) |
1020 | { | |
1021 | struct block_info_e4 bi; | |
1022 | struct block_index *blockidx; | |
1023 | struct l1_code *p = (struct l1_code *) sc->dsp_firm->data; | |
1024 | u8 blockno = p->page_number_to_block_index[pageno]; | |
1025 | ||
1026 | bi.wHdr = cpu_to_be16(UEA_BIHDR); | |
1027 | bi.bBootPage = boot; | |
1028 | bi.bPageNumber = pageno; | |
1029 | bi.wReserved = cpu_to_be16(UEA_RESERVED); | |
1030 | ||
1031 | do { | |
aafcd2f7 | 1032 | const u8 *blockoffset; |
c8e46379 SG |
1033 | unsigned int blocksize; |
1034 | ||
1035 | blockidx = &p->page_header[blockno]; | |
1036 | blocksize = E4_PAGE_BYTES(blockidx->PageSize); | |
4545f7ee JBTN |
1037 | blockoffset = sc->dsp_firm->data + le32_to_cpu( |
1038 | blockidx->PageOffset); | |
c8e46379 SG |
1039 | |
1040 | bi.dwSize = cpu_to_be32(blocksize); | |
fd05e720 | 1041 | bi.dwAddress = cpu_to_be32(le32_to_cpu(blockidx->PageAddress)); |
c8e46379 SG |
1042 | |
1043 | uea_dbg(INS_TO_USBDEV(sc), | |
4545f7ee JBTN |
1044 | "sending block %u for DSP page " |
1045 | "%u size %u address %x\n", | |
1046 | blockno, pageno, blocksize, | |
1047 | le32_to_cpu(blockidx->PageAddress)); | |
c8e46379 SG |
1048 | |
1049 | /* send block info through the IDMA pipe */ | |
1050 | if (uea_idma_write(sc, &bi, E4_BLOCK_INFO_SIZE)) | |
1051 | goto bad; | |
1052 | ||
1053 | /* send block data through the IDMA pipe */ | |
1054 | if (uea_idma_write(sc, blockoffset, blocksize)) | |
1055 | goto bad; | |
1056 | ||
1057 | blockno++; | |
1058 | } while (blockidx->NotLastBlock); | |
1059 | ||
1060 | return; | |
1061 | ||
1062 | bad: | |
1063 | uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", blockno); | |
1064 | return; | |
1065 | } | |
1066 | ||
1067 | static void uea_load_page_e4(struct work_struct *work) | |
1068 | { | |
1069 | struct uea_softc *sc = container_of(work, struct uea_softc, task); | |
1070 | u8 pageno = sc->pageno; | |
1071 | int i; | |
1072 | struct block_info_e4 bi; | |
1073 | struct l1_code *p; | |
1074 | ||
1075 | uea_dbg(INS_TO_USBDEV(sc), "sending DSP page %u\n", pageno); | |
1076 | ||
1077 | /* reload firmware when reboot start and it's loaded already */ | |
533726f7 | 1078 | if (pageno == 0) { |
c8e46379 SG |
1079 | release_firmware(sc->dsp_firm); |
1080 | sc->dsp_firm = NULL; | |
1081 | } | |
1082 | ||
1083 | if (sc->dsp_firm == NULL && request_dsp(sc) < 0) | |
1084 | return; | |
1085 | ||
1086 | p = (struct l1_code *) sc->dsp_firm->data; | |
fd05e720 | 1087 | if (pageno >= le16_to_cpu(p->page_header[0].PageNumber)) { |
4545f7ee JBTN |
1088 | uea_err(INS_TO_USBDEV(sc), "invalid DSP " |
1089 | "page %u requested\n", pageno); | |
c8e46379 SG |
1090 | return; |
1091 | } | |
1092 | ||
1093 | if (pageno != 0) { | |
1094 | __uea_load_page_e4(sc, pageno, 0); | |
1095 | return; | |
1096 | } | |
1097 | ||
1098 | uea_dbg(INS_TO_USBDEV(sc), | |
1099 | "sending Main DSP page %u\n", p->page_header[0].PageNumber); | |
1100 | ||
1101 | for (i = 0; i < le16_to_cpu(p->page_header[0].PageNumber); i++) { | |
1102 | if (E4_IS_BOOT_PAGE(p->page_header[i].PageSize)) | |
1103 | __uea_load_page_e4(sc, i, 1); | |
1104 | } | |
1105 | ||
4545f7ee | 1106 | uea_dbg(INS_TO_USBDEV(sc) , "sending start bi\n"); |
c8e46379 SG |
1107 | |
1108 | bi.wHdr = cpu_to_be16(UEA_BIHDR); | |
1109 | bi.bBootPage = 0; | |
1110 | bi.bPageNumber = 0xff; | |
1111 | bi.wReserved = cpu_to_be16(UEA_RESERVED); | |
1112 | bi.dwSize = cpu_to_be32(E4_PAGE_BYTES(p->page_header[0].PageSize)); | |
fd05e720 | 1113 | bi.dwAddress = cpu_to_be32(le32_to_cpu(p->page_header[0].PageAddress)); |
c8e46379 SG |
1114 | |
1115 | /* send block info through the IDMA pipe */ | |
1116 | if (uea_idma_write(sc, &bi, E4_BLOCK_INFO_SIZE)) | |
1117 | uea_err(INS_TO_USBDEV(sc), "sending DSP start bi failed\n"); | |
1118 | } | |
1119 | ||
b72458a8 | 1120 | static inline void wake_up_cmv_ack(struct uea_softc *sc) |
1121 | { | |
2a99b507 | 1122 | BUG_ON(sc->cmv_ack); |
b72458a8 | 1123 | sc->cmv_ack = 1; |
337427f9 | 1124 | wake_up(&sc->sync_q); |
b72458a8 | 1125 | } |
1126 | ||
1127 | static inline int wait_cmv_ack(struct uea_softc *sc) | |
1128 | { | |
337427f9 SG |
1129 | int ret = uea_wait(sc, sc->cmv_ack , ACK_TIMEOUT); |
1130 | ||
b72458a8 | 1131 | sc->cmv_ack = 0; |
1132 | ||
2a99b507 | 1133 | uea_dbg(INS_TO_USBDEV(sc), "wait_event_timeout : %d ms\n", |
1134 | jiffies_to_msecs(ret)); | |
1135 | ||
b72458a8 | 1136 | if (ret < 0) |
1137 | return ret; | |
1138 | ||
1139 | return (ret == 0) ? -ETIMEDOUT : 0; | |
b72458a8 | 1140 | } |
1141 | ||
1142 | #define UCDC_SEND_ENCAPSULATED_COMMAND 0x00 | |
1143 | ||
1144 | static int uea_request(struct uea_softc *sc, | |
aafcd2f7 | 1145 | u16 value, u16 index, u16 size, const void *data) |
b72458a8 | 1146 | { |
1147 | u8 *xfer_buff; | |
1148 | int ret = -ENOMEM; | |
1149 | ||
5d7efe5b | 1150 | xfer_buff = kmemdup(data, size, GFP_KERNEL); |
b72458a8 | 1151 | if (!xfer_buff) { |
1152 | uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); | |
1153 | return ret; | |
1154 | } | |
b72458a8 | 1155 | |
1156 | ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0), | |
1157 | UCDC_SEND_ENCAPSULATED_COMMAND, | |
1158 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | |
1159 | value, index, xfer_buff, size, CTRL_TIMEOUT); | |
1160 | ||
1161 | kfree(xfer_buff); | |
1162 | if (ret < 0) { | |
1163 | uea_err(INS_TO_USBDEV(sc), "usb_control_msg error %d\n", ret); | |
1164 | return ret; | |
1165 | } | |
1166 | ||
1167 | if (ret != size) { | |
1168 | uea_err(INS_TO_USBDEV(sc), | |
1169 | "usb_control_msg send only %d bytes (instead of %d)\n", | |
1170 | ret, size); | |
1171 | return -EIO; | |
1172 | } | |
1173 | ||
1174 | return 0; | |
1175 | } | |
1176 | ||
c8e46379 | 1177 | static int uea_cmv_e1(struct uea_softc *sc, |
b72458a8 | 1178 | u8 function, u32 address, u16 offset, u32 data) |
1179 | { | |
c8e46379 | 1180 | struct cmv_e1 cmv; |
b72458a8 | 1181 | int ret; |
1182 | ||
2a99b507 | 1183 | uea_enters(INS_TO_USBDEV(sc)); |
1184 | uea_vdbg(INS_TO_USBDEV(sc), "Function : %d-%d, Address : %c%c%c%c, " | |
1185 | "offset : 0x%04x, data : 0x%08x\n", | |
4545f7ee JBTN |
1186 | E1_FUNCTION_TYPE(function), |
1187 | E1_FUNCTION_SUBTYPE(function), | |
1188 | E1_GETSA1(address), E1_GETSA2(address), | |
1189 | E1_GETSA3(address), | |
c8e46379 SG |
1190 | E1_GETSA4(address), offset, data); |
1191 | ||
b72458a8 | 1192 | /* we send a request, but we expect a reply */ |
c8e46379 SG |
1193 | sc->cmv_dsc.e1.function = function | 0x2; |
1194 | sc->cmv_dsc.e1.idx++; | |
1195 | sc->cmv_dsc.e1.address = address; | |
1196 | sc->cmv_dsc.e1.offset = offset; | |
b72458a8 | 1197 | |
c8e46379 SG |
1198 | cmv.wPreamble = cpu_to_le16(E1_PREAMBLE); |
1199 | cmv.bDirection = E1_HOSTTOMODEM; | |
b72458a8 | 1200 | cmv.bFunction = function; |
c8e46379 | 1201 | cmv.wIndex = cpu_to_le16(sc->cmv_dsc.e1.idx); |
a5abdeaf | 1202 | put_unaligned_le32(address, &cmv.dwSymbolicAddress); |
b72458a8 | 1203 | cmv.wOffsetAddress = cpu_to_le16(offset); |
a5abdeaf | 1204 | put_unaligned_le32(data >> 16 | data << 16, &cmv.dwData); |
b72458a8 | 1205 | |
4545f7ee JBTN |
1206 | ret = uea_request(sc, UEA_E1_SET_BLOCK, UEA_MPTX_START, |
1207 | sizeof(cmv), &cmv); | |
c8e46379 SG |
1208 | if (ret < 0) |
1209 | return ret; | |
1210 | ret = wait_cmv_ack(sc); | |
1211 | uea_leaves(INS_TO_USBDEV(sc)); | |
1212 | return ret; | |
1213 | } | |
1214 | ||
1215 | static int uea_cmv_e4(struct uea_softc *sc, | |
1216 | u16 function, u16 group, u16 address, u16 offset, u32 data) | |
1217 | { | |
1218 | struct cmv_e4 cmv; | |
1219 | int ret; | |
1220 | ||
1221 | uea_enters(INS_TO_USBDEV(sc)); | |
1222 | memset(&cmv, 0, sizeof(cmv)); | |
1223 | ||
1224 | uea_vdbg(INS_TO_USBDEV(sc), "Function : %d-%d, Group : 0x%04x, " | |
1225 | "Address : 0x%04x, offset : 0x%04x, data : 0x%08x\n", | |
1226 | E4_FUNCTION_TYPE(function), E4_FUNCTION_SUBTYPE(function), | |
1227 | group, address, offset, data); | |
1228 | ||
1229 | /* we send a request, but we expect a reply */ | |
1230 | sc->cmv_dsc.e4.function = function | (0x1 << 4); | |
1231 | sc->cmv_dsc.e4.offset = offset; | |
1232 | sc->cmv_dsc.e4.address = address; | |
1233 | sc->cmv_dsc.e4.group = group; | |
1234 | ||
1235 | cmv.wFunction = cpu_to_be16(function); | |
1236 | cmv.wGroup = cpu_to_be16(group); | |
1237 | cmv.wAddress = cpu_to_be16(address); | |
1238 | cmv.wOffset = cpu_to_be16(offset); | |
1239 | cmv.dwData[0] = cpu_to_be32(data); | |
1240 | ||
4545f7ee JBTN |
1241 | ret = uea_request(sc, UEA_E4_SET_BLOCK, UEA_MPTX_START, |
1242 | sizeof(cmv), &cmv); | |
b72458a8 | 1243 | if (ret < 0) |
1244 | return ret; | |
2a99b507 | 1245 | ret = wait_cmv_ack(sc); |
1246 | uea_leaves(INS_TO_USBDEV(sc)); | |
1247 | return ret; | |
b72458a8 | 1248 | } |
1249 | ||
c8e46379 | 1250 | static inline int uea_read_cmv_e1(struct uea_softc *sc, |
b72458a8 | 1251 | u32 address, u16 offset, u32 *data) |
1252 | { | |
c8e46379 | 1253 | int ret = uea_cmv_e1(sc, E1_MAKEFUNCTION(E1_MEMACCESS, E1_REQUESTREAD), |
b72458a8 | 1254 | address, offset, 0); |
1255 | if (ret < 0) | |
1256 | uea_err(INS_TO_USBDEV(sc), | |
1257 | "reading cmv failed with error %d\n", ret); | |
1258 | else | |
4545f7ee | 1259 | *data = sc->data; |
b72458a8 | 1260 | |
1261 | return ret; | |
1262 | } | |
1263 | ||
c8e46379 SG |
1264 | static inline int uea_read_cmv_e4(struct uea_softc *sc, |
1265 | u8 size, u16 group, u16 address, u16 offset, u32 *data) | |
1266 | { | |
4545f7ee JBTN |
1267 | int ret = uea_cmv_e4(sc, E4_MAKEFUNCTION(E4_MEMACCESS, |
1268 | E4_REQUESTREAD, size), | |
c8e46379 SG |
1269 | group, address, offset, 0); |
1270 | if (ret < 0) | |
1271 | uea_err(INS_TO_USBDEV(sc), | |
1272 | "reading cmv failed with error %d\n", ret); | |
1273 | else { | |
4545f7ee | 1274 | *data = sc->data; |
c8e46379 SG |
1275 | /* size is in 16-bit word quantities */ |
1276 | if (size > 2) | |
1277 | *(data + 1) = sc->data1; | |
1278 | } | |
1279 | return ret; | |
1280 | } | |
1281 | ||
1282 | static inline int uea_write_cmv_e1(struct uea_softc *sc, | |
b72458a8 | 1283 | u32 address, u16 offset, u32 data) |
1284 | { | |
c8e46379 | 1285 | int ret = uea_cmv_e1(sc, E1_MAKEFUNCTION(E1_MEMACCESS, E1_REQUESTWRITE), |
b72458a8 | 1286 | address, offset, data); |
1287 | if (ret < 0) | |
1288 | uea_err(INS_TO_USBDEV(sc), | |
1289 | "writing cmv failed with error %d\n", ret); | |
1290 | ||
1291 | return ret; | |
1292 | } | |
1293 | ||
c8e46379 SG |
1294 | static inline int uea_write_cmv_e4(struct uea_softc *sc, |
1295 | u8 size, u16 group, u16 address, u16 offset, u32 data) | |
1296 | { | |
4545f7ee JBTN |
1297 | int ret = uea_cmv_e4(sc, E4_MAKEFUNCTION(E4_MEMACCESS, |
1298 | E4_REQUESTWRITE, size), | |
c8e46379 SG |
1299 | group, address, offset, data); |
1300 | if (ret < 0) | |
1301 | uea_err(INS_TO_USBDEV(sc), | |
1302 | "writing cmv failed with error %d\n", ret); | |
1303 | ||
1304 | return ret; | |
1305 | } | |
1306 | ||
1307 | static void uea_set_bulk_timeout(struct uea_softc *sc, u32 dsrate) | |
1308 | { | |
1309 | int ret; | |
1310 | u16 timeout; | |
1311 | ||
1312 | /* in bulk mode the modem have problem with high rate | |
1313 | * changing internal timing could improve things, but the | |
25985edc | 1314 | * value is mysterious. |
c8e46379 SG |
1315 | * ADI930 don't support it (-EPIPE error). |
1316 | */ | |
1317 | ||
1318 | if (UEA_CHIP_VERSION(sc) == ADI930 || | |
503add46 | 1319 | altsetting[sc->modem_index] > 0 || |
c8e46379 SG |
1320 | sc->stats.phy.dsrate == dsrate) |
1321 | return; | |
1322 | ||
1323 | /* Original timming (1Mbit/s) from ADI (used in windows driver) */ | |
1324 | timeout = (dsrate <= 1024*1024) ? 0 : 1; | |
1325 | ret = uea_request(sc, UEA_SET_TIMEOUT, timeout, 0, NULL); | |
1326 | uea_info(INS_TO_USBDEV(sc), "setting new timeout %d%s\n", | |
1327 | timeout, ret < 0 ? " failed" : ""); | |
1328 | ||
1329 | } | |
1330 | ||
b72458a8 | 1331 | /* |
1332 | * Monitor the modem and update the stat | |
1333 | * return 0 if everything is ok | |
1334 | * return < 0 if an error occurs (-EAGAIN reboot needed) | |
1335 | */ | |
c8e46379 | 1336 | static int uea_stat_e1(struct uea_softc *sc) |
b72458a8 | 1337 | { |
1338 | u32 data; | |
1339 | int ret; | |
1340 | ||
1341 | uea_enters(INS_TO_USBDEV(sc)); | |
1342 | data = sc->stats.phy.state; | |
1343 | ||
c8e46379 | 1344 | ret = uea_read_cmv_e1(sc, E1_SA_STAT, 0, &sc->stats.phy.state); |
b72458a8 | 1345 | if (ret < 0) |
1346 | return ret; | |
1347 | ||
1348 | switch (GET_STATUS(sc->stats.phy.state)) { | |
1349 | case 0: /* not yet synchronized */ | |
1350 | uea_dbg(INS_TO_USBDEV(sc), | |
1351 | "modem not yet synchronized\n"); | |
1352 | return 0; | |
1353 | ||
1354 | case 1: /* initialization */ | |
1355 | uea_dbg(INS_TO_USBDEV(sc), "modem initializing\n"); | |
1356 | return 0; | |
1357 | ||
1358 | case 2: /* operational */ | |
1359 | uea_vdbg(INS_TO_USBDEV(sc), "modem operational\n"); | |
1360 | break; | |
1361 | ||
1362 | case 3: /* fail ... */ | |
a7a0c9cd | 1363 | uea_info(INS_TO_USBDEV(sc), "modem synchronization failed" |
c8e46379 | 1364 | " (may be try other cmv/dsp)\n"); |
b72458a8 | 1365 | return -EAGAIN; |
1366 | ||
1367 | case 4 ... 6: /* test state */ | |
1368 | uea_warn(INS_TO_USBDEV(sc), | |
1369 | "modem in test mode - not supported\n"); | |
1370 | return -EAGAIN; | |
1371 | ||
1372 | case 7: /* fast-retain ... */ | |
1373 | uea_info(INS_TO_USBDEV(sc), "modem in fast-retain mode\n"); | |
1374 | return 0; | |
1375 | default: | |
1376 | uea_err(INS_TO_USBDEV(sc), "modem invalid SW mode %d\n", | |
1377 | GET_STATUS(sc->stats.phy.state)); | |
1378 | return -EAGAIN; | |
1379 | } | |
1380 | ||
1381 | if (GET_STATUS(data) != 2) { | |
1382 | uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_OFF, 0, NULL); | |
1383 | uea_info(INS_TO_USBDEV(sc), "modem operational\n"); | |
1384 | ||
1385 | /* release the dsp firmware as it is not needed until | |
1386 | * the next failure | |
1387 | */ | |
7af39592 JJ |
1388 | release_firmware(sc->dsp_firm); |
1389 | sc->dsp_firm = NULL; | |
b72458a8 | 1390 | } |
1391 | ||
1392 | /* always update it as atm layer could not be init when we switch to | |
1393 | * operational state | |
1394 | */ | |
cc7b86c1 | 1395 | UPDATE_ATM_SIGNAL(ATM_PHY_SIG_FOUND); |
b72458a8 | 1396 | |
1397 | /* wake up processes waiting for synchronization */ | |
1398 | wake_up(&sc->sync_q); | |
1399 | ||
c8e46379 | 1400 | ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 2, &sc->stats.phy.flags); |
b72458a8 | 1401 | if (ret < 0) |
1402 | return ret; | |
1403 | sc->stats.phy.mflags |= sc->stats.phy.flags; | |
1404 | ||
1405 | /* in case of a flags ( for example delineation LOSS (& 0x10)), | |
1406 | * we check the status again in order to detect the failure earlier | |
1407 | */ | |
1408 | if (sc->stats.phy.flags) { | |
2a99b507 | 1409 | uea_dbg(INS_TO_USBDEV(sc), "Stat flag = 0x%x\n", |
b72458a8 | 1410 | sc->stats.phy.flags); |
1411 | return 0; | |
1412 | } | |
1413 | ||
c8e46379 | 1414 | ret = uea_read_cmv_e1(sc, E1_SA_RATE, 0, &data); |
b72458a8 | 1415 | if (ret < 0) |
1416 | return ret; | |
1417 | ||
c8e46379 | 1418 | uea_set_bulk_timeout(sc, (data >> 16) * 32); |
b72458a8 | 1419 | sc->stats.phy.dsrate = (data >> 16) * 32; |
1420 | sc->stats.phy.usrate = (data & 0xffff) * 32; | |
1421 | UPDATE_ATM_STAT(link_rate, sc->stats.phy.dsrate * 1000 / 424); | |
1422 | ||
c8e46379 | 1423 | ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 23, &data); |
b72458a8 | 1424 | if (ret < 0) |
1425 | return ret; | |
1426 | sc->stats.phy.dsattenuation = (data & 0xff) / 2; | |
1427 | ||
c8e46379 | 1428 | ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 47, &data); |
b72458a8 | 1429 | if (ret < 0) |
1430 | return ret; | |
1431 | sc->stats.phy.usattenuation = (data & 0xff) / 2; | |
1432 | ||
c8e46379 | 1433 | ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 25, &sc->stats.phy.dsmargin); |
b72458a8 | 1434 | if (ret < 0) |
1435 | return ret; | |
1436 | ||
c8e46379 | 1437 | ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 49, &sc->stats.phy.usmargin); |
b72458a8 | 1438 | if (ret < 0) |
1439 | return ret; | |
1440 | ||
c8e46379 | 1441 | ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 51, &sc->stats.phy.rxflow); |
b72458a8 | 1442 | if (ret < 0) |
1443 | return ret; | |
1444 | ||
c8e46379 | 1445 | ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 52, &sc->stats.phy.txflow); |
b72458a8 | 1446 | if (ret < 0) |
1447 | return ret; | |
1448 | ||
c8e46379 | 1449 | ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 54, &sc->stats.phy.dsunc); |
b72458a8 | 1450 | if (ret < 0) |
1451 | return ret; | |
1452 | ||
1453 | /* only for atu-c */ | |
c8e46379 | 1454 | ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 58, &sc->stats.phy.usunc); |
b72458a8 | 1455 | if (ret < 0) |
1456 | return ret; | |
1457 | ||
c8e46379 | 1458 | ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 53, &sc->stats.phy.dscorr); |
b72458a8 | 1459 | if (ret < 0) |
1460 | return ret; | |
1461 | ||
1462 | /* only for atu-c */ | |
c8e46379 | 1463 | ret = uea_read_cmv_e1(sc, E1_SA_DIAG, 57, &sc->stats.phy.uscorr); |
b72458a8 | 1464 | if (ret < 0) |
1465 | return ret; | |
1466 | ||
c8e46379 | 1467 | ret = uea_read_cmv_e1(sc, E1_SA_INFO, 8, &sc->stats.phy.vidco); |
b72458a8 | 1468 | if (ret < 0) |
1469 | return ret; | |
1470 | ||
c8e46379 | 1471 | ret = uea_read_cmv_e1(sc, E1_SA_INFO, 13, &sc->stats.phy.vidcpe); |
b72458a8 | 1472 | if (ret < 0) |
1473 | return ret; | |
1474 | ||
1475 | return 0; | |
1476 | } | |
1477 | ||
c8e46379 | 1478 | static int uea_stat_e4(struct uea_softc *sc) |
b72458a8 | 1479 | { |
c8e46379 SG |
1480 | u32 data; |
1481 | u32 tmp_arr[2]; | |
1482 | int ret; | |
1483 | ||
1484 | uea_enters(INS_TO_USBDEV(sc)); | |
1485 | data = sc->stats.phy.state; | |
1486 | ||
1487 | /* XXX only need to be done before operationnal... */ | |
1488 | ret = uea_read_cmv_e4(sc, 1, E4_SA_STAT, 0, 0, &sc->stats.phy.state); | |
1489 | if (ret < 0) | |
1490 | return ret; | |
1491 | ||
1492 | switch (sc->stats.phy.state) { | |
4545f7ee JBTN |
1493 | case 0x0: /* not yet synchronized */ |
1494 | case 0x1: | |
1495 | case 0x3: | |
1496 | case 0x4: | |
1497 | uea_dbg(INS_TO_USBDEV(sc), "modem not yet " | |
1498 | "synchronized\n"); | |
1499 | return 0; | |
1500 | case 0x5: /* initialization */ | |
1501 | case 0x6: | |
1502 | case 0x9: | |
1503 | case 0xa: | |
1504 | uea_dbg(INS_TO_USBDEV(sc), "modem initializing\n"); | |
1505 | return 0; | |
1506 | case 0x2: /* fail ... */ | |
1507 | uea_info(INS_TO_USBDEV(sc), "modem synchronization " | |
1508 | "failed (may be try other cmv/dsp)\n"); | |
1509 | return -EAGAIN; | |
1510 | case 0x7: /* operational */ | |
1511 | break; | |
1512 | default: | |
1513 | uea_warn(INS_TO_USBDEV(sc), "unknown state: %x\n", | |
1514 | sc->stats.phy.state); | |
1515 | return 0; | |
c8e46379 SG |
1516 | } |
1517 | ||
1518 | if (data != 7) { | |
1519 | uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_OFF, 0, NULL); | |
1520 | uea_info(INS_TO_USBDEV(sc), "modem operational\n"); | |
1521 | ||
1522 | /* release the dsp firmware as it is not needed until | |
1523 | * the next failure | |
1524 | */ | |
7af39592 JJ |
1525 | release_firmware(sc->dsp_firm); |
1526 | sc->dsp_firm = NULL; | |
c8e46379 SG |
1527 | } |
1528 | ||
1529 | /* always update it as atm layer could not be init when we switch to | |
1530 | * operational state | |
1531 | */ | |
cc7b86c1 | 1532 | UPDATE_ATM_SIGNAL(ATM_PHY_SIG_FOUND); |
c8e46379 SG |
1533 | |
1534 | /* wake up processes waiting for synchronization */ | |
1535 | wake_up(&sc->sync_q); | |
1536 | ||
1537 | /* TODO improve this state machine : | |
1538 | * we need some CMV info : what they do and their unit | |
1539 | * we should find the equivalent of eagle3- CMV | |
1540 | */ | |
1541 | /* check flags */ | |
1542 | ret = uea_read_cmv_e4(sc, 1, E4_SA_DIAG, 0, 0, &sc->stats.phy.flags); | |
1543 | if (ret < 0) | |
1544 | return ret; | |
1545 | sc->stats.phy.mflags |= sc->stats.phy.flags; | |
1546 | ||
1547 | /* in case of a flags ( for example delineation LOSS (& 0x10)), | |
1548 | * we check the status again in order to detect the failure earlier | |
1549 | */ | |
1550 | if (sc->stats.phy.flags) { | |
1551 | uea_dbg(INS_TO_USBDEV(sc), "Stat flag = 0x%x\n", | |
1552 | sc->stats.phy.flags); | |
4545f7ee | 1553 | if (sc->stats.phy.flags & 1) /* delineation LOSS */ |
c8e46379 | 1554 | return -EAGAIN; |
4545f7ee | 1555 | if (sc->stats.phy.flags & 0x4000) /* Reset Flag */ |
c8e46379 SG |
1556 | return -EAGAIN; |
1557 | return 0; | |
1558 | } | |
1559 | ||
1560 | /* rate data may be in upper or lower half of 64 bit word, strange */ | |
1561 | ret = uea_read_cmv_e4(sc, 4, E4_SA_RATE, 0, 0, tmp_arr); | |
1562 | if (ret < 0) | |
1563 | return ret; | |
1564 | data = (tmp_arr[0]) ? tmp_arr[0] : tmp_arr[1]; | |
1565 | sc->stats.phy.usrate = data / 1000; | |
1566 | ||
1567 | ret = uea_read_cmv_e4(sc, 4, E4_SA_RATE, 1, 0, tmp_arr); | |
1568 | if (ret < 0) | |
1569 | return ret; | |
1570 | data = (tmp_arr[0]) ? tmp_arr[0] : tmp_arr[1]; | |
1571 | uea_set_bulk_timeout(sc, data / 1000); | |
1572 | sc->stats.phy.dsrate = data / 1000; | |
1573 | UPDATE_ATM_STAT(link_rate, sc->stats.phy.dsrate * 1000 / 424); | |
1574 | ||
1575 | ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 68, 1, &data); | |
1576 | if (ret < 0) | |
1577 | return ret; | |
1578 | sc->stats.phy.dsattenuation = data / 10; | |
1579 | ||
1580 | ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 69, 1, &data); | |
1581 | if (ret < 0) | |
1582 | return ret; | |
1583 | sc->stats.phy.usattenuation = data / 10; | |
1584 | ||
1585 | ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 68, 3, &data); | |
1586 | if (ret < 0) | |
1587 | return ret; | |
1588 | sc->stats.phy.dsmargin = data / 2; | |
1589 | ||
1590 | ret = uea_read_cmv_e4(sc, 1, E4_SA_INFO, 69, 3, &data); | |
1591 | if (ret < 0) | |
1592 | return ret; | |
1593 | sc->stats.phy.usmargin = data / 10; | |
1594 | ||
1595 | return 0; | |
1596 | } | |
1597 | ||
1598 | static void cmvs_file_name(struct uea_softc *sc, char *const cmv_name, int ver) | |
1599 | { | |
1600 | char file_arr[] = "CMVxy.bin"; | |
b72458a8 | 1601 | char *file; |
b72458a8 | 1602 | |
b51d23e4 | 1603 | kernel_param_lock(THIS_MODULE); |
c8e46379 | 1604 | /* set proper name corresponding modem version and line type */ |
b72458a8 | 1605 | if (cmv_file[sc->modem_index] == NULL) { |
1606 | if (UEA_CHIP_VERSION(sc) == ADI930) | |
c8e46379 SG |
1607 | file_arr[3] = '9'; |
1608 | else if (UEA_CHIP_VERSION(sc) == EAGLE_IV) | |
1609 | file_arr[3] = '4'; | |
b72458a8 | 1610 | else |
c8e46379 SG |
1611 | file_arr[3] = 'e'; |
1612 | ||
603cf608 | 1613 | file_arr[4] = IS_ISDN(sc) ? 'i' : 'p'; |
c8e46379 | 1614 | file = file_arr; |
b72458a8 | 1615 | } else |
1616 | file = cmv_file[sc->modem_index]; | |
1617 | ||
1618 | strcpy(cmv_name, FW_DIR); | |
ade901d7 | 1619 | strlcat(cmv_name, file, UEA_FW_NAME_MAX); |
c8e46379 | 1620 | if (ver == 2) |
ade901d7 | 1621 | strlcat(cmv_name, ".v2", UEA_FW_NAME_MAX); |
b51d23e4 | 1622 | kernel_param_unlock(THIS_MODULE); |
c8e46379 SG |
1623 | } |
1624 | ||
1625 | static int request_cmvs_old(struct uea_softc *sc, | |
1626 | void **cmvs, const struct firmware **fw) | |
1627 | { | |
1628 | int ret, size; | |
1629 | u8 *data; | |
ade901d7 | 1630 | char cmv_name[UEA_FW_NAME_MAX]; /* 30 bytes stack variable */ |
b72458a8 | 1631 | |
c8e46379 | 1632 | cmvs_file_name(sc, cmv_name, 1); |
b72458a8 | 1633 | ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev); |
1634 | if (ret < 0) { | |
1635 | uea_err(INS_TO_USBDEV(sc), | |
1636 | "requesting firmware %s failed with error %d\n", | |
1637 | cmv_name, ret); | |
1638 | return ret; | |
1639 | } | |
1640 | ||
1641 | data = (u8 *) (*fw)->data; | |
c8e46379 SG |
1642 | size = (*fw)->size; |
1643 | if (size < 1) | |
1644 | goto err_fw_corrupted; | |
1645 | ||
1646 | if (size != *data * sizeof(struct uea_cmvs_v1) + 1) | |
1647 | goto err_fw_corrupted; | |
1648 | ||
1649 | *cmvs = (void *)(data + 1); | |
1650 | return *data; | |
1651 | ||
1652 | err_fw_corrupted: | |
1653 | uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", cmv_name); | |
1654 | release_firmware(*fw); | |
1655 | return -EILSEQ; | |
1656 | } | |
1657 | ||
1658 | static int request_cmvs(struct uea_softc *sc, | |
1659 | void **cmvs, const struct firmware **fw, int *ver) | |
1660 | { | |
1661 | int ret, size; | |
1662 | u32 crc; | |
1663 | u8 *data; | |
ade901d7 | 1664 | char cmv_name[UEA_FW_NAME_MAX]; /* 30 bytes stack variable */ |
c8e46379 SG |
1665 | |
1666 | cmvs_file_name(sc, cmv_name, 2); | |
1667 | ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev); | |
1668 | if (ret < 0) { | |
1669 | /* if caller can handle old version, try to provide it */ | |
1670 | if (*ver == 1) { | |
4545f7ee JBTN |
1671 | uea_warn(INS_TO_USBDEV(sc), "requesting " |
1672 | "firmware %s failed, " | |
c8e46379 SG |
1673 | "try to get older cmvs\n", cmv_name); |
1674 | return request_cmvs_old(sc, cmvs, fw); | |
1675 | } | |
1676 | uea_err(INS_TO_USBDEV(sc), | |
1677 | "requesting firmware %s failed with error %d\n", | |
1678 | cmv_name, ret); | |
1679 | return ret; | |
1680 | } | |
1681 | ||
1682 | size = (*fw)->size; | |
1683 | data = (u8 *) (*fw)->data; | |
1684 | if (size < 4 || strncmp(data, "cmv2", 4) != 0) { | |
1685 | if (*ver == 1) { | |
4545f7ee JBTN |
1686 | uea_warn(INS_TO_USBDEV(sc), "firmware %s is corrupted," |
1687 | " try to get older cmvs\n", cmv_name); | |
c8e46379 SG |
1688 | release_firmware(*fw); |
1689 | return request_cmvs_old(sc, cmvs, fw); | |
1690 | } | |
1691 | goto err_fw_corrupted; | |
b72458a8 | 1692 | } |
1693 | ||
c8e46379 SG |
1694 | *ver = 2; |
1695 | ||
1696 | data += 4; | |
1697 | size -= 4; | |
1698 | if (size < 5) | |
1699 | goto err_fw_corrupted; | |
1700 | ||
a5abdeaf | 1701 | crc = get_unaligned_le32(data); |
c8e46379 SG |
1702 | data += 4; |
1703 | size -= 4; | |
1704 | if (crc32_be(0, data, size) != crc) | |
1705 | goto err_fw_corrupted; | |
1706 | ||
1707 | if (size != *data * sizeof(struct uea_cmvs_v2) + 1) | |
1708 | goto err_fw_corrupted; | |
1709 | ||
1710 | *cmvs = (void *) (data + 1); | |
b72458a8 | 1711 | return *data; |
c8e46379 SG |
1712 | |
1713 | err_fw_corrupted: | |
1714 | uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", cmv_name); | |
1715 | release_firmware(*fw); | |
1716 | return -EILSEQ; | |
1717 | } | |
1718 | ||
1719 | static int uea_send_cmvs_e1(struct uea_softc *sc) | |
1720 | { | |
1721 | int i, ret, len; | |
1722 | void *cmvs_ptr; | |
1723 | const struct firmware *cmvs_fw; | |
4545f7ee | 1724 | int ver = 1; /* we can handle v1 cmv firmware version; */ |
c8e46379 SG |
1725 | |
1726 | /* Enter in R-IDLE (cmv) until instructed otherwise */ | |
1727 | ret = uea_write_cmv_e1(sc, E1_SA_CNTL, 0, 1); | |
1728 | if (ret < 0) | |
1729 | return ret; | |
1730 | ||
1731 | /* Dump firmware version */ | |
1732 | ret = uea_read_cmv_e1(sc, E1_SA_INFO, 10, &sc->stats.phy.firmid); | |
1733 | if (ret < 0) | |
1734 | return ret; | |
1735 | uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n", | |
1736 | sc->stats.phy.firmid); | |
1737 | ||
1738 | /* get options */ | |
4545f7ee | 1739 | ret = len = request_cmvs(sc, &cmvs_ptr, &cmvs_fw, &ver); |
c8e46379 SG |
1740 | if (ret < 0) |
1741 | return ret; | |
1742 | ||
1743 | /* send options */ | |
1744 | if (ver == 1) { | |
1745 | struct uea_cmvs_v1 *cmvs_v1 = cmvs_ptr; | |
1746 | ||
1747 | uea_warn(INS_TO_USBDEV(sc), "use deprecated cmvs version, " | |
1748 | "please update your firmware\n"); | |
1749 | ||
1750 | for (i = 0; i < len; i++) { | |
4545f7ee JBTN |
1751 | ret = uea_write_cmv_e1(sc, |
1752 | get_unaligned_le32(&cmvs_v1[i].address), | |
1753 | get_unaligned_le16(&cmvs_v1[i].offset), | |
1754 | get_unaligned_le32(&cmvs_v1[i].data)); | |
c8e46379 SG |
1755 | if (ret < 0) |
1756 | goto out; | |
1757 | } | |
1758 | } else if (ver == 2) { | |
1759 | struct uea_cmvs_v2 *cmvs_v2 = cmvs_ptr; | |
1760 | ||
1761 | for (i = 0; i < len; i++) { | |
4545f7ee JBTN |
1762 | ret = uea_write_cmv_e1(sc, |
1763 | get_unaligned_le32(&cmvs_v2[i].address), | |
1764 | (u16) get_unaligned_le32(&cmvs_v2[i].offset), | |
1765 | get_unaligned_le32(&cmvs_v2[i].data)); | |
c8e46379 SG |
1766 | if (ret < 0) |
1767 | goto out; | |
1768 | } | |
1769 | } else { | |
25985edc | 1770 | /* This really should not happen */ |
c8e46379 SG |
1771 | uea_err(INS_TO_USBDEV(sc), "bad cmvs version %d\n", ver); |
1772 | goto out; | |
1773 | } | |
1774 | ||
1775 | /* Enter in R-ACT-REQ */ | |
1776 | ret = uea_write_cmv_e1(sc, E1_SA_CNTL, 0, 2); | |
1777 | uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n"); | |
4545f7ee JBTN |
1778 | uea_info(INS_TO_USBDEV(sc), "modem started, waiting " |
1779 | "synchronization...\n"); | |
c8e46379 SG |
1780 | out: |
1781 | release_firmware(cmvs_fw); | |
1782 | return ret; | |
1783 | } | |
1784 | ||
1785 | static int uea_send_cmvs_e4(struct uea_softc *sc) | |
1786 | { | |
1787 | int i, ret, len; | |
1788 | void *cmvs_ptr; | |
1789 | const struct firmware *cmvs_fw; | |
4545f7ee | 1790 | int ver = 2; /* we can only handle v2 cmv firmware version; */ |
c8e46379 SG |
1791 | |
1792 | /* Enter in R-IDLE (cmv) until instructed otherwise */ | |
1793 | ret = uea_write_cmv_e4(sc, 1, E4_SA_CNTL, 0, 0, 1); | |
1794 | if (ret < 0) | |
1795 | return ret; | |
1796 | ||
1797 | /* Dump firmware version */ | |
1798 | /* XXX don't read the 3th byte as it is always 6 */ | |
1799 | ret = uea_read_cmv_e4(sc, 2, E4_SA_INFO, 55, 0, &sc->stats.phy.firmid); | |
1800 | if (ret < 0) | |
1801 | return ret; | |
1802 | uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n", | |
1803 | sc->stats.phy.firmid); | |
1804 | ||
1805 | ||
1806 | /* get options */ | |
4545f7ee | 1807 | ret = len = request_cmvs(sc, &cmvs_ptr, &cmvs_fw, &ver); |
c8e46379 SG |
1808 | if (ret < 0) |
1809 | return ret; | |
1810 | ||
1811 | /* send options */ | |
1812 | if (ver == 2) { | |
1813 | struct uea_cmvs_v2 *cmvs_v2 = cmvs_ptr; | |
1814 | ||
1815 | for (i = 0; i < len; i++) { | |
1816 | ret = uea_write_cmv_e4(sc, 1, | |
4545f7ee JBTN |
1817 | get_unaligned_le32(&cmvs_v2[i].group), |
1818 | get_unaligned_le32(&cmvs_v2[i].address), | |
1819 | get_unaligned_le32(&cmvs_v2[i].offset), | |
1820 | get_unaligned_le32(&cmvs_v2[i].data)); | |
c8e46379 SG |
1821 | if (ret < 0) |
1822 | goto out; | |
1823 | } | |
1824 | } else { | |
25985edc | 1825 | /* This really should not happen */ |
c8e46379 SG |
1826 | uea_err(INS_TO_USBDEV(sc), "bad cmvs version %d\n", ver); |
1827 | goto out; | |
1828 | } | |
1829 | ||
1830 | /* Enter in R-ACT-REQ */ | |
1831 | ret = uea_write_cmv_e4(sc, 1, E4_SA_CNTL, 0, 0, 2); | |
1832 | uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n"); | |
4545f7ee JBTN |
1833 | uea_info(INS_TO_USBDEV(sc), "modem started, waiting " |
1834 | "synchronization...\n"); | |
c8e46379 SG |
1835 | out: |
1836 | release_firmware(cmvs_fw); | |
1837 | return ret; | |
b72458a8 | 1838 | } |
1839 | ||
1840 | /* Start boot post firmware modem: | |
1841 | * - send reset commands through usb control pipe | |
1842 | * - start workqueue for DSP loading | |
1843 | * - send CMV options to modem | |
1844 | */ | |
1845 | ||
1846 | static int uea_start_reset(struct uea_softc *sc) | |
1847 | { | |
1848 | u16 zero = 0; /* ;-) */ | |
c8e46379 | 1849 | int ret; |
b72458a8 | 1850 | |
1851 | uea_enters(INS_TO_USBDEV(sc)); | |
1852 | uea_info(INS_TO_USBDEV(sc), "(re)booting started\n"); | |
1853 | ||
22fcceb5 | 1854 | /* mask interrupt */ |
b72458a8 | 1855 | sc->booting = 1; |
25985edc | 1856 | /* We need to set this here because, a ack timeout could have occurred, |
22fcceb5 | 1857 | * but before we start the reboot, the ack occurs and set this to 1. |
1858 | * So we will failed to wait Ready CMV. | |
1859 | */ | |
1860 | sc->cmv_ack = 0; | |
cc7b86c1 | 1861 | UPDATE_ATM_SIGNAL(ATM_PHY_SIG_LOST); |
b72458a8 | 1862 | |
1863 | /* reset statistics */ | |
1864 | memset(&sc->stats, 0, sizeof(struct uea_stats)); | |
1865 | ||
1866 | /* tell the modem that we want to boot in IDMA mode */ | |
1867 | uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL); | |
1868 | uea_request(sc, UEA_SET_MODE, UEA_BOOT_IDMA, 0, NULL); | |
1869 | ||
4545f7ee | 1870 | /* enter reset mode */ |
b72458a8 | 1871 | uea_request(sc, UEA_SET_MODE, UEA_START_RESET, 0, NULL); |
1872 | ||
1873 | /* original driver use 200ms, but windows driver use 100ms */ | |
337427f9 SG |
1874 | ret = uea_wait(sc, 0, msecs_to_jiffies(100)); |
1875 | if (ret < 0) | |
1876 | return ret; | |
b72458a8 | 1877 | |
1878 | /* leave reset mode */ | |
1879 | uea_request(sc, UEA_SET_MODE, UEA_END_RESET, 0, NULL); | |
1880 | ||
c8e46379 | 1881 | if (UEA_CHIP_VERSION(sc) != EAGLE_IV) { |
4545f7ee | 1882 | /* clear tx and rx mailboxes */ |
c8e46379 SG |
1883 | uea_request(sc, UEA_SET_2183_DATA, UEA_MPTX_MAILBOX, 2, &zero); |
1884 | uea_request(sc, UEA_SET_2183_DATA, UEA_MPRX_MAILBOX, 2, &zero); | |
1885 | uea_request(sc, UEA_SET_2183_DATA, UEA_SWAP_MAILBOX, 2, &zero); | |
1886 | } | |
b72458a8 | 1887 | |
337427f9 SG |
1888 | ret = uea_wait(sc, 0, msecs_to_jiffies(1000)); |
1889 | if (ret < 0) | |
1890 | return ret; | |
c8e46379 SG |
1891 | |
1892 | if (UEA_CHIP_VERSION(sc) == EAGLE_IV) | |
4545f7ee JBTN |
1893 | sc->cmv_dsc.e4.function = E4_MAKEFUNCTION(E4_ADSLDIRECTIVE, |
1894 | E4_MODEMREADY, 1); | |
c8e46379 | 1895 | else |
4545f7ee JBTN |
1896 | sc->cmv_dsc.e1.function = E1_MAKEFUNCTION(E1_ADSLDIRECTIVE, |
1897 | E1_MODEMREADY); | |
c8e46379 | 1898 | |
22fcceb5 | 1899 | /* demask interrupt */ |
b72458a8 | 1900 | sc->booting = 0; |
1901 | ||
1902 | /* start loading DSP */ | |
1903 | sc->pageno = 0; | |
1904 | sc->ovl = 0; | |
9abff15d | 1905 | schedule_work(&sc->task); |
b72458a8 | 1906 | |
1907 | /* wait for modem ready CMV */ | |
1908 | ret = wait_cmv_ack(sc); | |
1909 | if (ret < 0) | |
1910 | return ret; | |
1911 | ||
2a99b507 | 1912 | uea_vdbg(INS_TO_USBDEV(sc), "Ready CMV received\n"); |
1913 | ||
c8e46379 | 1914 | ret = sc->send_cmvs(sc); |
b72458a8 | 1915 | if (ret < 0) |
1916 | return ret; | |
1917 | ||
b72458a8 | 1918 | sc->reset = 0; |
1919 | uea_leaves(INS_TO_USBDEV(sc)); | |
1920 | return ret; | |
1921 | } | |
1922 | ||
1923 | /* | |
1924 | * In case of an error wait 1s before rebooting the modem | |
1925 | * if the modem don't request reboot (-EAGAIN). | |
1926 | * Monitor the modem every 1s. | |
1927 | */ | |
1928 | ||
1929 | static int uea_kthread(void *data) | |
1930 | { | |
1931 | struct uea_softc *sc = data; | |
1932 | int ret = -EAGAIN; | |
1933 | ||
83144186 | 1934 | set_freezable(); |
b72458a8 | 1935 | uea_enters(INS_TO_USBDEV(sc)); |
1936 | while (!kthread_should_stop()) { | |
1937 | if (ret < 0 || sc->reset) | |
1938 | ret = uea_start_reset(sc); | |
1939 | if (!ret) | |
c8e46379 | 1940 | ret = sc->stat(sc); |
b72458a8 | 1941 | if (ret != -EAGAIN) |
337427f9 | 1942 | uea_wait(sc, 0, msecs_to_jiffies(1000)); |
0eb0226c | 1943 | try_to_freeze(); |
b72458a8 | 1944 | } |
1945 | uea_leaves(INS_TO_USBDEV(sc)); | |
1946 | return ret; | |
1947 | } | |
1948 | ||
1949 | /* Load second usb firmware for ADI930 chip */ | |
1950 | static int load_XILINX_firmware(struct uea_softc *sc) | |
1951 | { | |
1952 | const struct firmware *fw_entry; | |
1953 | int ret, size, u, ln; | |
aafcd2f7 DW |
1954 | const u8 *pfw; |
1955 | u8 value; | |
47282502 | 1956 | char *fw_name = FPGA930_FIRMWARE; |
b72458a8 | 1957 | |
1958 | uea_enters(INS_TO_USBDEV(sc)); | |
1959 | ||
1960 | ret = request_firmware(&fw_entry, fw_name, &sc->usb_dev->dev); | |
1961 | if (ret) { | |
1962 | uea_err(INS_TO_USBDEV(sc), "firmware %s is not available\n", | |
1963 | fw_name); | |
1964 | goto err0; | |
1965 | } | |
1966 | ||
1967 | pfw = fw_entry->data; | |
1968 | size = fw_entry->size; | |
1969 | if (size != 0x577B) { | |
1970 | uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", | |
1971 | fw_name); | |
1972 | ret = -EILSEQ; | |
1973 | goto err1; | |
1974 | } | |
1975 | for (u = 0; u < size; u += ln) { | |
1976 | ln = min(size - u, 64); | |
1977 | ret = uea_request(sc, 0xe, 0, ln, pfw + u); | |
1978 | if (ret < 0) { | |
1979 | uea_err(INS_TO_USBDEV(sc), | |
1980 | "elsa download data failed (%d)\n", ret); | |
1981 | goto err1; | |
1982 | } | |
1983 | } | |
1984 | ||
e40abaf6 | 1985 | /* finish to send the fpga */ |
b72458a8 | 1986 | ret = uea_request(sc, 0xe, 1, 0, NULL); |
1987 | if (ret < 0) { | |
1988 | uea_err(INS_TO_USBDEV(sc), | |
1989 | "elsa download data failed (%d)\n", ret); | |
1990 | goto err1; | |
1991 | } | |
1992 | ||
e40abaf6 | 1993 | /* Tell the modem we finish : de-assert reset */ |
b72458a8 | 1994 | value = 0; |
1995 | ret = uea_send_modem_cmd(sc->usb_dev, 0xe, 1, &value); | |
1996 | if (ret < 0) | |
4545f7ee JBTN |
1997 | uea_err(sc->usb_dev, "elsa de-assert failed with error" |
1998 | " %d\n", ret); | |
b72458a8 | 1999 | |
b72458a8 | 2000 | err1: |
2001 | release_firmware(fw_entry); | |
2002 | err0: | |
2003 | uea_leaves(INS_TO_USBDEV(sc)); | |
2004 | return ret; | |
2005 | } | |
2006 | ||
e40abaf6 | 2007 | /* The modem send us an ack. First with check if it right */ |
c8e46379 | 2008 | static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr) |
b72458a8 | 2009 | { |
c8e46379 SG |
2010 | struct cmv_dsc_e1 *dsc = &sc->cmv_dsc.e1; |
2011 | struct cmv_e1 *cmv = &intr->u.e1.s2.cmv; | |
2012 | ||
b72458a8 | 2013 | uea_enters(INS_TO_USBDEV(sc)); |
c8e46379 | 2014 | if (le16_to_cpu(cmv->wPreamble) != E1_PREAMBLE) |
b72458a8 | 2015 | goto bad1; |
2016 | ||
c8e46379 | 2017 | if (cmv->bDirection != E1_MODEMTOHOST) |
b72458a8 | 2018 | goto bad1; |
2019 | ||
2020 | /* FIXME : ADI930 reply wrong preambule (func = 2, sub = 2) to | |
af901ca1 | 2021 | * the first MEMACCESS cmv. Ignore it... |
b72458a8 | 2022 | */ |
c8e46379 | 2023 | if (cmv->bFunction != dsc->function) { |
b72458a8 | 2024 | if (UEA_CHIP_VERSION(sc) == ADI930 |
c8e46379 SG |
2025 | && cmv->bFunction == E1_MAKEFUNCTION(2, 2)) { |
2026 | cmv->wIndex = cpu_to_le16(dsc->idx); | |
4545f7ee JBTN |
2027 | put_unaligned_le32(dsc->address, |
2028 | &cmv->dwSymbolicAddress); | |
c8e46379 SG |
2029 | cmv->wOffsetAddress = cpu_to_le16(dsc->offset); |
2030 | } else | |
b72458a8 | 2031 | goto bad2; |
2032 | } | |
2033 | ||
4545f7ee JBTN |
2034 | if (cmv->bFunction == E1_MAKEFUNCTION(E1_ADSLDIRECTIVE, |
2035 | E1_MODEMREADY)) { | |
b72458a8 | 2036 | wake_up_cmv_ack(sc); |
2a99b507 | 2037 | uea_leaves(INS_TO_USBDEV(sc)); |
b72458a8 | 2038 | return; |
2039 | } | |
2040 | ||
2041 | /* in case of MEMACCESS */ | |
c8e46379 | 2042 | if (le16_to_cpu(cmv->wIndex) != dsc->idx || |
a5abdeaf | 2043 | get_unaligned_le32(&cmv->dwSymbolicAddress) != dsc->address || |
c8e46379 | 2044 | le16_to_cpu(cmv->wOffsetAddress) != dsc->offset) |
b72458a8 | 2045 | goto bad2; |
2046 | ||
a5abdeaf | 2047 | sc->data = get_unaligned_le32(&cmv->dwData); |
b72458a8 | 2048 | sc->data = sc->data << 16 | sc->data >> 16; |
2049 | ||
2050 | wake_up_cmv_ack(sc); | |
2a99b507 | 2051 | uea_leaves(INS_TO_USBDEV(sc)); |
b72458a8 | 2052 | return; |
2053 | ||
2054 | bad2: | |
fec8de3a | 2055 | uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, " |
b72458a8 | 2056 | "Function : %d, Subfunction : %d\n", |
c8e46379 SG |
2057 | E1_FUNCTION_TYPE(cmv->bFunction), |
2058 | E1_FUNCTION_SUBTYPE(cmv->bFunction)); | |
2a99b507 | 2059 | uea_leaves(INS_TO_USBDEV(sc)); |
b72458a8 | 2060 | return; |
2061 | ||
2062 | bad1: | |
2063 | uea_err(INS_TO_USBDEV(sc), "invalid cmv received, " | |
2064 | "wPreamble %d, bDirection %d\n", | |
2065 | le16_to_cpu(cmv->wPreamble), cmv->bDirection); | |
2a99b507 | 2066 | uea_leaves(INS_TO_USBDEV(sc)); |
b72458a8 | 2067 | } |
2068 | ||
c8e46379 SG |
2069 | /* The modem send us an ack. First with check if it right */ |
2070 | static void uea_dispatch_cmv_e4(struct uea_softc *sc, struct intr_pkt *intr) | |
2071 | { | |
2072 | struct cmv_dsc_e4 *dsc = &sc->cmv_dsc.e4; | |
2073 | struct cmv_e4 *cmv = &intr->u.e4.s2.cmv; | |
2074 | ||
2075 | uea_enters(INS_TO_USBDEV(sc)); | |
2076 | uea_dbg(INS_TO_USBDEV(sc), "cmv %x %x %x %x %x %x\n", | |
2077 | be16_to_cpu(cmv->wGroup), be16_to_cpu(cmv->wFunction), | |
2078 | be16_to_cpu(cmv->wOffset), be16_to_cpu(cmv->wAddress), | |
2079 | be32_to_cpu(cmv->dwData[0]), be32_to_cpu(cmv->dwData[1])); | |
2080 | ||
2081 | if (be16_to_cpu(cmv->wFunction) != dsc->function) | |
2082 | goto bad2; | |
2083 | ||
4545f7ee JBTN |
2084 | if (be16_to_cpu(cmv->wFunction) == E4_MAKEFUNCTION(E4_ADSLDIRECTIVE, |
2085 | E4_MODEMREADY, 1)) { | |
c8e46379 SG |
2086 | wake_up_cmv_ack(sc); |
2087 | uea_leaves(INS_TO_USBDEV(sc)); | |
2088 | return; | |
2089 | } | |
2090 | ||
2091 | /* in case of MEMACCESS */ | |
2092 | if (be16_to_cpu(cmv->wOffset) != dsc->offset || | |
2093 | be16_to_cpu(cmv->wGroup) != dsc->group || | |
2094 | be16_to_cpu(cmv->wAddress) != dsc->address) | |
2095 | goto bad2; | |
2096 | ||
2097 | sc->data = be32_to_cpu(cmv->dwData[0]); | |
2098 | sc->data1 = be32_to_cpu(cmv->dwData[1]); | |
2099 | wake_up_cmv_ack(sc); | |
2100 | uea_leaves(INS_TO_USBDEV(sc)); | |
2101 | return; | |
2102 | ||
2103 | bad2: | |
fec8de3a | 2104 | uea_err(INS_TO_USBDEV(sc), "unexpected cmv received, " |
c8e46379 SG |
2105 | "Function : %d, Subfunction : %d\n", |
2106 | E4_FUNCTION_TYPE(cmv->wFunction), | |
2107 | E4_FUNCTION_SUBTYPE(cmv->wFunction)); | |
2108 | uea_leaves(INS_TO_USBDEV(sc)); | |
2109 | return; | |
2110 | } | |
2111 | ||
4545f7ee JBTN |
2112 | static void uea_schedule_load_page_e1(struct uea_softc *sc, |
2113 | struct intr_pkt *intr) | |
c8e46379 SG |
2114 | { |
2115 | sc->pageno = intr->e1_bSwapPageNo; | |
2116 | sc->ovl = intr->e1_bOvl >> 4 | intr->e1_bOvl << 4; | |
9abff15d | 2117 | schedule_work(&sc->task); |
c8e46379 SG |
2118 | } |
2119 | ||
4545f7ee JBTN |
2120 | static void uea_schedule_load_page_e4(struct uea_softc *sc, |
2121 | struct intr_pkt *intr) | |
c8e46379 SG |
2122 | { |
2123 | sc->pageno = intr->e4_bSwapPageNo; | |
9abff15d | 2124 | schedule_work(&sc->task); |
c8e46379 SG |
2125 | } |
2126 | ||
b72458a8 | 2127 | /* |
2128 | * interrupt handler | |
2129 | */ | |
7d12e780 | 2130 | static void uea_intr(struct urb *urb) |
b72458a8 | 2131 | { |
e40abaf6 | 2132 | struct uea_softc *sc = urb->context; |
2133 | struct intr_pkt *intr = urb->transfer_buffer; | |
508330eb GKH |
2134 | int status = urb->status; |
2135 | ||
b72458a8 | 2136 | uea_enters(INS_TO_USBDEV(sc)); |
2137 | ||
508330eb | 2138 | if (unlikely(status < 0)) { |
b72458a8 | 2139 | uea_err(INS_TO_USBDEV(sc), "uea_intr() failed with %d\n", |
508330eb | 2140 | status); |
b72458a8 | 2141 | return; |
2142 | } | |
2143 | ||
b72458a8 | 2144 | /* device-to-host interrupt */ |
2145 | if (intr->bType != 0x08 || sc->booting) { | |
e40abaf6 | 2146 | uea_err(INS_TO_USBDEV(sc), "wrong interrupt\n"); |
b72458a8 | 2147 | goto resubmit; |
2148 | } | |
2149 | ||
2150 | switch (le16_to_cpu(intr->wInterrupt)) { | |
2151 | case INT_LOADSWAPPAGE: | |
c8e46379 | 2152 | sc->schedule_load_page(sc, intr); |
b72458a8 | 2153 | break; |
2154 | ||
2155 | case INT_INCOMINGCMV: | |
c8e46379 | 2156 | sc->dispatch_cmv(sc, intr); |
b72458a8 | 2157 | break; |
2158 | ||
2159 | default: | |
e40abaf6 | 2160 | uea_err(INS_TO_USBDEV(sc), "unknown interrupt %u\n", |
b72458a8 | 2161 | le16_to_cpu(intr->wInterrupt)); |
2162 | } | |
2163 | ||
2164 | resubmit: | |
2165 | usb_submit_urb(sc->urb_int, GFP_ATOMIC); | |
2166 | } | |
2167 | ||
2168 | /* | |
2169 | * Start the modem : init the data and start kernel thread | |
2170 | */ | |
2171 | static int uea_boot(struct uea_softc *sc) | |
2172 | { | |
c8e46379 | 2173 | int ret, size; |
b72458a8 | 2174 | struct intr_pkt *intr; |
2175 | ||
2176 | uea_enters(INS_TO_USBDEV(sc)); | |
2177 | ||
c8e46379 SG |
2178 | if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { |
2179 | size = E4_INTR_PKT_SIZE; | |
2180 | sc->dispatch_cmv = uea_dispatch_cmv_e4; | |
2181 | sc->schedule_load_page = uea_schedule_load_page_e4; | |
2182 | sc->stat = uea_stat_e4; | |
2183 | sc->send_cmvs = uea_send_cmvs_e4; | |
2184 | INIT_WORK(&sc->task, uea_load_page_e4); | |
2185 | } else { | |
2186 | size = E1_INTR_PKT_SIZE; | |
2187 | sc->dispatch_cmv = uea_dispatch_cmv_e1; | |
2188 | sc->schedule_load_page = uea_schedule_load_page_e1; | |
2189 | sc->stat = uea_stat_e1; | |
2190 | sc->send_cmvs = uea_send_cmvs_e1; | |
2191 | INIT_WORK(&sc->task, uea_load_page_e1); | |
2192 | } | |
2193 | ||
b72458a8 | 2194 | init_waitqueue_head(&sc->sync_q); |
b72458a8 | 2195 | |
2196 | if (UEA_CHIP_VERSION(sc) == ADI930) | |
2197 | load_XILINX_firmware(sc); | |
2198 | ||
c8e46379 | 2199 | intr = kmalloc(size, GFP_KERNEL); |
59e1200e | 2200 | if (!intr) |
04ea02f5 | 2201 | goto err0; |
b72458a8 | 2202 | |
2203 | sc->urb_int = usb_alloc_urb(0, GFP_KERNEL); | |
7ff56857 | 2204 | if (!sc->urb_int) |
04ea02f5 | 2205 | goto err1; |
b72458a8 | 2206 | |
2207 | usb_fill_int_urb(sc->urb_int, sc->usb_dev, | |
2208 | usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE), | |
c8e46379 | 2209 | intr, size, uea_intr, sc, |
b72458a8 | 2210 | sc->usb_dev->actconfig->interface[0]->altsetting[0]. |
2211 | endpoint[0].desc.bInterval); | |
2212 | ||
2213 | ret = usb_submit_urb(sc->urb_int, GFP_KERNEL); | |
2214 | if (ret < 0) { | |
2215 | uea_err(INS_TO_USBDEV(sc), | |
4b26ebac | 2216 | "urb submission failed with error %d\n", ret); |
04ea02f5 | 2217 | goto err1; |
b72458a8 | 2218 | } |
2219 | ||
12f188f2 DW |
2220 | /* Create worker thread, but don't start it here. Start it after |
2221 | * all usbatm generic initialization is done. | |
2222 | */ | |
2223 | sc->kthread = kthread_create(uea_kthread, sc, "ueagle-atm"); | |
2224 | if (IS_ERR(sc->kthread)) { | |
b72458a8 | 2225 | uea_err(INS_TO_USBDEV(sc), "failed to create thread\n"); |
2226 | goto err2; | |
2227 | } | |
2228 | ||
2229 | uea_leaves(INS_TO_USBDEV(sc)); | |
2230 | return 0; | |
2231 | ||
2232 | err2: | |
2233 | usb_kill_urb(sc->urb_int); | |
04ea02f5 | 2234 | err1: |
b72458a8 | 2235 | usb_free_urb(sc->urb_int); |
4d45e218 | 2236 | sc->urb_int = NULL; |
2237 | kfree(intr); | |
04ea02f5 | 2238 | err0: |
b72458a8 | 2239 | uea_leaves(INS_TO_USBDEV(sc)); |
2240 | return -ENOMEM; | |
2241 | } | |
2242 | ||
2243 | /* | |
2244 | * Stop the modem : kill kernel thread and free data | |
2245 | */ | |
2246 | static void uea_stop(struct uea_softc *sc) | |
2247 | { | |
2248 | int ret; | |
2249 | uea_enters(INS_TO_USBDEV(sc)); | |
2250 | ret = kthread_stop(sc->kthread); | |
e40abaf6 | 2251 | uea_dbg(INS_TO_USBDEV(sc), "kthread finish with status %d\n", ret); |
b72458a8 | 2252 | |
b72458a8 | 2253 | uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL); |
2254 | ||
2255 | usb_kill_urb(sc->urb_int); | |
2256 | kfree(sc->urb_int->transfer_buffer); | |
2257 | usb_free_urb(sc->urb_int); | |
2258 | ||
9abff15d | 2259 | /* flush the work item, when no one can schedule it */ |
43829731 | 2260 | flush_work(&sc->task); |
04ea02f5 | 2261 | |
7af39592 | 2262 | release_firmware(sc->dsp_firm); |
b72458a8 | 2263 | uea_leaves(INS_TO_USBDEV(sc)); |
2264 | } | |
2265 | ||
2266 | /* syfs interface */ | |
2267 | static struct uea_softc *dev_to_uea(struct device *dev) | |
2268 | { | |
2269 | struct usb_interface *intf; | |
2270 | struct usbatm_data *usbatm; | |
2271 | ||
2272 | intf = to_usb_interface(dev); | |
2273 | if (!intf) | |
2274 | return NULL; | |
2275 | ||
2276 | usbatm = usb_get_intfdata(intf); | |
2277 | if (!usbatm) | |
2278 | return NULL; | |
2279 | ||
2280 | return usbatm->driver_data; | |
2281 | } | |
2282 | ||
2283 | static ssize_t read_status(struct device *dev, struct device_attribute *attr, | |
2284 | char *buf) | |
2285 | { | |
2286 | int ret = -ENODEV; | |
2287 | struct uea_softc *sc; | |
2288 | ||
ab3c81ff | 2289 | mutex_lock(&uea_mutex); |
b72458a8 | 2290 | sc = dev_to_uea(dev); |
2291 | if (!sc) | |
2292 | goto out; | |
2293 | ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state); | |
2294 | out: | |
ab3c81ff | 2295 | mutex_unlock(&uea_mutex); |
b72458a8 | 2296 | return ret; |
2297 | } | |
2298 | ||
2299 | static ssize_t reboot(struct device *dev, struct device_attribute *attr, | |
2300 | const char *buf, size_t count) | |
2301 | { | |
2302 | int ret = -ENODEV; | |
2303 | struct uea_softc *sc; | |
2304 | ||
ab3c81ff | 2305 | mutex_lock(&uea_mutex); |
b72458a8 | 2306 | sc = dev_to_uea(dev); |
2307 | if (!sc) | |
2308 | goto out; | |
2309 | sc->reset = 1; | |
2310 | ret = count; | |
2311 | out: | |
ab3c81ff | 2312 | mutex_unlock(&uea_mutex); |
b72458a8 | 2313 | return ret; |
2314 | } | |
2315 | ||
e502ac5e | 2316 | static DEVICE_ATTR(stat_status, S_IWUSR | S_IRUGO, read_status, reboot); |
b72458a8 | 2317 | |
4545f7ee JBTN |
2318 | static ssize_t read_human_status(struct device *dev, |
2319 | struct device_attribute *attr, char *buf) | |
b72458a8 | 2320 | { |
2321 | int ret = -ENODEV; | |
c8e46379 | 2322 | int modem_state; |
b72458a8 | 2323 | struct uea_softc *sc; |
2324 | ||
ab3c81ff | 2325 | mutex_lock(&uea_mutex); |
b72458a8 | 2326 | sc = dev_to_uea(dev); |
2327 | if (!sc) | |
2328 | goto out; | |
2329 | ||
c8e46379 SG |
2330 | if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { |
2331 | switch (sc->stats.phy.state) { | |
2332 | case 0x0: /* not yet synchronized */ | |
2333 | case 0x1: | |
2334 | case 0x3: | |
2335 | case 0x4: | |
2336 | modem_state = 0; | |
2337 | break; | |
2338 | case 0x5: /* initialization */ | |
2339 | case 0x6: | |
2340 | case 0x9: | |
2341 | case 0xa: | |
2342 | modem_state = 1; | |
2343 | break; | |
4545f7ee | 2344 | case 0x7: /* operational */ |
c8e46379 SG |
2345 | modem_state = 2; |
2346 | break; | |
2347 | case 0x2: /* fail ... */ | |
2348 | modem_state = 3; | |
2349 | break; | |
2350 | default: /* unknown */ | |
2351 | modem_state = 4; | |
2352 | break; | |
2353 | } | |
2354 | } else | |
2355 | modem_state = GET_STATUS(sc->stats.phy.state); | |
2356 | ||
2357 | switch (modem_state) { | |
b72458a8 | 2358 | case 0: |
2359 | ret = sprintf(buf, "Modem is booting\n"); | |
2360 | break; | |
2361 | case 1: | |
2362 | ret = sprintf(buf, "Modem is initializing\n"); | |
2363 | break; | |
2364 | case 2: | |
2365 | ret = sprintf(buf, "Modem is operational\n"); | |
2366 | break; | |
c8e46379 | 2367 | case 3: |
b72458a8 | 2368 | ret = sprintf(buf, "Modem synchronization failed\n"); |
2369 | break; | |
c8e46379 SG |
2370 | default: |
2371 | ret = sprintf(buf, "Modem state is unknown\n"); | |
2372 | break; | |
b72458a8 | 2373 | } |
2374 | out: | |
ab3c81ff | 2375 | mutex_unlock(&uea_mutex); |
b72458a8 | 2376 | return ret; |
2377 | } | |
2378 | ||
e502ac5e | 2379 | static DEVICE_ATTR(stat_human_status, S_IRUGO, read_human_status, NULL); |
b72458a8 | 2380 | |
2381 | static ssize_t read_delin(struct device *dev, struct device_attribute *attr, | |
2382 | char *buf) | |
2383 | { | |
2384 | int ret = -ENODEV; | |
2385 | struct uea_softc *sc; | |
c8e46379 | 2386 | char *delin = "GOOD"; |
b72458a8 | 2387 | |
ab3c81ff | 2388 | mutex_lock(&uea_mutex); |
b72458a8 | 2389 | sc = dev_to_uea(dev); |
2390 | if (!sc) | |
2391 | goto out; | |
2392 | ||
c8e46379 SG |
2393 | if (UEA_CHIP_VERSION(sc) == EAGLE_IV) { |
2394 | if (sc->stats.phy.flags & 0x4000) | |
2395 | delin = "RESET"; | |
2396 | else if (sc->stats.phy.flags & 0x0001) | |
2397 | delin = "LOSS"; | |
2398 | } else { | |
2399 | if (sc->stats.phy.flags & 0x0C00) | |
2400 | delin = "ERROR"; | |
2401 | else if (sc->stats.phy.flags & 0x0030) | |
2402 | delin = "LOSS"; | |
2403 | } | |
2404 | ||
2405 | ret = sprintf(buf, "%s\n", delin); | |
b72458a8 | 2406 | out: |
ab3c81ff | 2407 | mutex_unlock(&uea_mutex); |
b72458a8 | 2408 | return ret; |
2409 | } | |
2410 | ||
e502ac5e | 2411 | static DEVICE_ATTR(stat_delin, S_IRUGO, read_delin, NULL); |
b72458a8 | 2412 | |
4545f7ee | 2413 | #define UEA_ATTR(name, reset) \ |
b72458a8 | 2414 | \ |
4545f7ee | 2415 | static ssize_t read_##name(struct device *dev, \ |
b72458a8 | 2416 | struct device_attribute *attr, char *buf) \ |
4545f7ee JBTN |
2417 | { \ |
2418 | int ret = -ENODEV; \ | |
2419 | struct uea_softc *sc; \ | |
2420 | \ | |
2421 | mutex_lock(&uea_mutex); \ | |
b72458a8 | 2422 | sc = dev_to_uea(dev); \ |
4545f7ee JBTN |
2423 | if (!sc) \ |
2424 | goto out; \ | |
b72458a8 | 2425 | ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.name); \ |
2426 | if (reset) \ | |
2427 | sc->stats.phy.name = 0; \ | |
4545f7ee JBTN |
2428 | out: \ |
2429 | mutex_unlock(&uea_mutex); \ | |
2430 | return ret; \ | |
2431 | } \ | |
b72458a8 | 2432 | \ |
2433 | static DEVICE_ATTR(stat_##name, S_IRUGO, read_##name, NULL) | |
2434 | ||
2435 | UEA_ATTR(mflags, 1); | |
2436 | UEA_ATTR(vidcpe, 0); | |
2437 | UEA_ATTR(usrate, 0); | |
2438 | UEA_ATTR(dsrate, 0); | |
2439 | UEA_ATTR(usattenuation, 0); | |
2440 | UEA_ATTR(dsattenuation, 0); | |
2441 | UEA_ATTR(usmargin, 0); | |
2442 | UEA_ATTR(dsmargin, 0); | |
2443 | UEA_ATTR(txflow, 0); | |
2444 | UEA_ATTR(rxflow, 0); | |
2445 | UEA_ATTR(uscorr, 0); | |
2446 | UEA_ATTR(dscorr, 0); | |
2447 | UEA_ATTR(usunc, 0); | |
2448 | UEA_ATTR(dsunc, 0); | |
a7a0c9cd | 2449 | UEA_ATTR(firmid, 0); |
b72458a8 | 2450 | |
2451 | /* Retrieve the device End System Identifier (MAC) */ | |
2452 | ||
49e8eccf | 2453 | static int uea_getesi(struct uea_softc *sc, u_char *esi) |
b72458a8 | 2454 | { |
2455 | unsigned char mac_str[2 * ETH_ALEN + 1]; | |
2456 | int i; | |
2457 | if (usb_string | |
2458 | (sc->usb_dev, sc->usb_dev->descriptor.iSerialNumber, mac_str, | |
2459 | sizeof(mac_str)) != 2 * ETH_ALEN) | |
2460 | return 1; | |
2461 | ||
2462 | for (i = 0; i < ETH_ALEN; i++) | |
e644814a AS |
2463 | esi[i] = hex_to_bin(mac_str[2 * i]) * 16 + |
2464 | hex_to_bin(mac_str[2 * i + 1]); | |
b72458a8 | 2465 | |
2466 | return 0; | |
2467 | } | |
2468 | ||
2469 | /* ATM stuff */ | |
2470 | static int uea_atm_open(struct usbatm_data *usbatm, struct atm_dev *atm_dev) | |
2471 | { | |
2472 | struct uea_softc *sc = usbatm->driver_data; | |
2473 | ||
2474 | return uea_getesi(sc, atm_dev->esi); | |
2475 | } | |
2476 | ||
2477 | static int uea_heavy(struct usbatm_data *usbatm, struct usb_interface *intf) | |
2478 | { | |
2479 | struct uea_softc *sc = usbatm->driver_data; | |
2480 | ||
531a39bb | 2481 | wait_event_interruptible(sc->sync_q, IS_OPERATIONAL(sc)); |
b72458a8 | 2482 | |
2483 | return 0; | |
2484 | ||
2485 | } | |
2486 | ||
2487 | static int claim_interface(struct usb_device *usb_dev, | |
2488 | struct usbatm_data *usbatm, int ifnum) | |
2489 | { | |
2490 | int ret; | |
2491 | struct usb_interface *intf = usb_ifnum_to_if(usb_dev, ifnum); | |
2492 | ||
2493 | if (!intf) { | |
2494 | uea_err(usb_dev, "interface %d not found\n", ifnum); | |
2495 | return -ENODEV; | |
2496 | } | |
2497 | ||
2498 | ret = usb_driver_claim_interface(&uea_driver, intf, usbatm); | |
2499 | if (ret != 0) | |
2500 | uea_err(usb_dev, "can't claim interface %d, error %d\n", ifnum, | |
2501 | ret); | |
2502 | return ret; | |
2503 | } | |
2504 | ||
e7ccdfec GKH |
2505 | static struct attribute *attrs[] = { |
2506 | &dev_attr_stat_status.attr, | |
2507 | &dev_attr_stat_mflags.attr, | |
2508 | &dev_attr_stat_human_status.attr, | |
2509 | &dev_attr_stat_delin.attr, | |
2510 | &dev_attr_stat_vidcpe.attr, | |
2511 | &dev_attr_stat_usrate.attr, | |
2512 | &dev_attr_stat_dsrate.attr, | |
2513 | &dev_attr_stat_usattenuation.attr, | |
2514 | &dev_attr_stat_dsattenuation.attr, | |
2515 | &dev_attr_stat_usmargin.attr, | |
2516 | &dev_attr_stat_dsmargin.attr, | |
2517 | &dev_attr_stat_txflow.attr, | |
2518 | &dev_attr_stat_rxflow.attr, | |
2519 | &dev_attr_stat_uscorr.attr, | |
2520 | &dev_attr_stat_dscorr.attr, | |
2521 | &dev_attr_stat_usunc.attr, | |
2522 | &dev_attr_stat_dsunc.attr, | |
a7a0c9cd | 2523 | &dev_attr_stat_firmid.attr, |
9ab99c8c | 2524 | NULL, |
e7ccdfec | 2525 | }; |
d2032b4b | 2526 | static const struct attribute_group attr_grp = { |
e7ccdfec GKH |
2527 | .attrs = attrs, |
2528 | }; | |
2529 | ||
b72458a8 | 2530 | static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, |
35644b0c | 2531 | const struct usb_device_id *id) |
b72458a8 | 2532 | { |
2533 | struct usb_device *usb = interface_to_usbdev(intf); | |
2534 | struct uea_softc *sc; | |
2535 | int ret, ifnum = intf->altsetting->desc.bInterfaceNumber; | |
503add46 | 2536 | unsigned int alt; |
b72458a8 | 2537 | |
2538 | uea_enters(usb); | |
2539 | ||
2540 | /* interface 0 is for firmware/monitoring */ | |
2541 | if (ifnum != UEA_INTR_IFACE_NO) | |
2542 | return -ENODEV; | |
2543 | ||
0dfcd3e4 | 2544 | usbatm->flags = (sync_wait[modem_index] ? 0 : UDSL_SKIP_HEAVY_INIT); |
b72458a8 | 2545 | |
2546 | /* interface 1 is for outbound traffic */ | |
2547 | ret = claim_interface(usb, usbatm, UEA_US_IFACE_NO); | |
2548 | if (ret < 0) | |
2549 | return ret; | |
2550 | ||
e40abaf6 | 2551 | /* ADI930 has only 2 interfaces and inbound traffic is on interface 1 */ |
b72458a8 | 2552 | if (UEA_CHIP_VERSION(id) != ADI930) { |
2553 | /* interface 2 is for inbound traffic */ | |
2554 | ret = claim_interface(usb, usbatm, UEA_DS_IFACE_NO); | |
2555 | if (ret < 0) | |
2556 | return ret; | |
2557 | } | |
2558 | ||
2559 | sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL); | |
59e1200e | 2560 | if (!sc) |
b72458a8 | 2561 | return -ENOMEM; |
b72458a8 | 2562 | |
2563 | sc->usb_dev = usb; | |
2564 | usbatm->driver_data = sc; | |
2565 | sc->usbatm = usbatm; | |
2566 | sc->modem_index = (modem_index < NB_MODEM) ? modem_index++ : 0; | |
2567 | sc->driver_info = id->driver_info; | |
2568 | ||
603cf608 SG |
2569 | /* first try to use module parameter */ |
2570 | if (annex[sc->modem_index] == 1) | |
2571 | sc->annex = ANNEXA; | |
2572 | else if (annex[sc->modem_index] == 2) | |
2573 | sc->annex = ANNEXB; | |
2574 | /* try to autodetect annex */ | |
2575 | else if (sc->driver_info & AUTO_ANNEX_A) | |
2576 | sc->annex = ANNEXA; | |
2577 | else if (sc->driver_info & AUTO_ANNEX_B) | |
2578 | sc->annex = ANNEXB; | |
2579 | else | |
4545f7ee JBTN |
2580 | sc->annex = (le16_to_cpu |
2581 | (sc->usb_dev->descriptor.bcdDevice) & 0x80) ? ANNEXB : ANNEXA; | |
603cf608 | 2582 | |
503add46 | 2583 | alt = altsetting[sc->modem_index]; |
3c9666cc | 2584 | /* ADI930 don't support iso */ |
503add46 | 2585 | if (UEA_CHIP_VERSION(id) != ADI930 && alt > 0) { |
4545f7ee JBTN |
2586 | if (alt <= 8 && |
2587 | usb_set_interface(usb, UEA_DS_IFACE_NO, alt) == 0) { | |
503add46 | 2588 | uea_dbg(usb, "set alternate %u for 2 interface\n", alt); |
3c9666cc | 2589 | uea_info(usb, "using iso mode\n"); |
2590 | usbatm->flags |= UDSL_USE_ISOC | UDSL_IGNORE_EILSEQ; | |
2591 | } else { | |
503add46 SG |
2592 | uea_err(usb, "setting alternate %u failed for " |
2593 | "2 interface, using bulk mode\n", alt); | |
3c9666cc | 2594 | } |
2595 | } | |
2596 | ||
9ab99c8c | 2597 | ret = sysfs_create_group(&intf->dev.kobj, &attr_grp); |
2598 | if (ret < 0) | |
2599 | goto error; | |
2600 | ||
b72458a8 | 2601 | ret = uea_boot(sc); |
9ab99c8c | 2602 | if (ret < 0) |
4c132e77 | 2603 | goto error_rm_grp; |
b72458a8 | 2604 | |
b72458a8 | 2605 | return 0; |
4c132e77 SG |
2606 | |
2607 | error_rm_grp: | |
2608 | sysfs_remove_group(&intf->dev.kobj, &attr_grp); | |
9ab99c8c | 2609 | error: |
2610 | kfree(sc); | |
2611 | return ret; | |
b72458a8 | 2612 | } |
2613 | ||
2614 | static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf) | |
2615 | { | |
2616 | struct uea_softc *sc = usbatm->driver_data; | |
2617 | ||
9ab99c8c | 2618 | sysfs_remove_group(&intf->dev.kobj, &attr_grp); |
b72458a8 | 2619 | uea_stop(sc); |
2620 | kfree(sc); | |
2621 | } | |
2622 | ||
2623 | static struct usbatm_driver uea_usbatm_driver = { | |
2624 | .driver_name = "ueagle-atm", | |
b72458a8 | 2625 | .bind = uea_bind, |
2626 | .atm_start = uea_atm_open, | |
2627 | .unbind = uea_unbind, | |
2628 | .heavy_init = uea_heavy, | |
80aae7a1 DS |
2629 | .bulk_in = UEA_BULK_DATA_PIPE, |
2630 | .bulk_out = UEA_BULK_DATA_PIPE, | |
3c9666cc | 2631 | .isoc_in = UEA_ISO_DATA_PIPE, |
b72458a8 | 2632 | }; |
2633 | ||
2634 | static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id) | |
2635 | { | |
2636 | struct usb_device *usb = interface_to_usbdev(intf); | |
12f188f2 | 2637 | int ret; |
b72458a8 | 2638 | |
2639 | uea_enters(usb); | |
603cf608 SG |
2640 | uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) Rev (%#X): %s\n", |
2641 | le16_to_cpu(usb->descriptor.idVendor), | |
2642 | le16_to_cpu(usb->descriptor.idProduct), | |
2643 | le16_to_cpu(usb->descriptor.bcdDevice), | |
2644 | chip_name[UEA_CHIP_VERSION(id)]); | |
b72458a8 | 2645 | |
2646 | usb_reset_device(usb); | |
2647 | ||
2648 | if (UEA_IS_PREFIRM(id)) | |
2649 | return uea_load_firmware(usb, UEA_CHIP_VERSION(id)); | |
2650 | ||
12f188f2 DW |
2651 | ret = usbatm_usb_probe(intf, id, &uea_usbatm_driver); |
2652 | if (ret == 0) { | |
2653 | struct usbatm_data *usbatm = usb_get_intfdata(intf); | |
2654 | struct uea_softc *sc = usbatm->driver_data; | |
2655 | ||
2656 | /* Ensure carrier is initialized to off as early as possible */ | |
2657 | UPDATE_ATM_SIGNAL(ATM_PHY_SIG_LOST); | |
2658 | ||
2659 | /* Only start the worker thread when all init is done */ | |
2660 | wake_up_process(sc->kthread); | |
2661 | } | |
2662 | ||
2663 | return ret; | |
b72458a8 | 2664 | } |
2665 | ||
2666 | static void uea_disconnect(struct usb_interface *intf) | |
2667 | { | |
2668 | struct usb_device *usb = interface_to_usbdev(intf); | |
2669 | int ifnum = intf->altsetting->desc.bInterfaceNumber; | |
2670 | uea_enters(usb); | |
2671 | ||
2672 | /* ADI930 has 2 interfaces and eagle 3 interfaces. | |
2673 | * Pre-firmware device has one interface | |
2674 | */ | |
2675 | if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) { | |
ab3c81ff | 2676 | mutex_lock(&uea_mutex); |
b72458a8 | 2677 | usbatm_usb_disconnect(intf); |
ab3c81ff | 2678 | mutex_unlock(&uea_mutex); |
b72458a8 | 2679 | uea_info(usb, "ADSL device removed\n"); |
2680 | } | |
2681 | ||
2682 | uea_leaves(usb); | |
2683 | } | |
2684 | ||
2685 | /* | |
2686 | * List of supported VID/PID | |
2687 | */ | |
2688 | static const struct usb_device_id uea_ids[] = { | |
4545f7ee JBTN |
2689 | {USB_DEVICE(ANALOG_VID, ADI930_PID_PREFIRM), |
2690 | .driver_info = ADI930 | PREFIRM}, | |
2691 | {USB_DEVICE(ANALOG_VID, ADI930_PID_PSTFIRM), | |
2692 | .driver_info = ADI930 | PSTFIRM}, | |
2693 | {USB_DEVICE(ANALOG_VID, EAGLE_I_PID_PREFIRM), | |
2694 | .driver_info = EAGLE_I | PREFIRM}, | |
2695 | {USB_DEVICE(ANALOG_VID, EAGLE_I_PID_PSTFIRM), | |
2696 | .driver_info = EAGLE_I | PSTFIRM}, | |
2697 | {USB_DEVICE(ANALOG_VID, EAGLE_II_PID_PREFIRM), | |
2698 | .driver_info = EAGLE_II | PREFIRM}, | |
2699 | {USB_DEVICE(ANALOG_VID, EAGLE_II_PID_PSTFIRM), | |
2700 | .driver_info = EAGLE_II | PSTFIRM}, | |
2701 | {USB_DEVICE(ANALOG_VID, EAGLE_IIC_PID_PREFIRM), | |
2702 | .driver_info = EAGLE_II | PREFIRM}, | |
2703 | {USB_DEVICE(ANALOG_VID, EAGLE_IIC_PID_PSTFIRM), | |
2704 | .driver_info = EAGLE_II | PSTFIRM}, | |
2705 | {USB_DEVICE(ANALOG_VID, EAGLE_III_PID_PREFIRM), | |
2706 | .driver_info = EAGLE_III | PREFIRM}, | |
2707 | {USB_DEVICE(ANALOG_VID, EAGLE_III_PID_PSTFIRM), | |
2708 | .driver_info = EAGLE_III | PSTFIRM}, | |
2709 | {USB_DEVICE(ANALOG_VID, EAGLE_IV_PID_PREFIRM), | |
2710 | .driver_info = EAGLE_IV | PREFIRM}, | |
2711 | {USB_DEVICE(ANALOG_VID, EAGLE_IV_PID_PSTFIRM), | |
2712 | .driver_info = EAGLE_IV | PSTFIRM}, | |
2713 | {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_A_PID_PREFIRM), | |
2714 | .driver_info = EAGLE_I | PREFIRM}, | |
2715 | {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_A_PID_PSTFIRM), | |
2716 | .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_A}, | |
2717 | {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_B_PID_PREFIRM), | |
2718 | .driver_info = EAGLE_I | PREFIRM}, | |
2719 | {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_I_B_PID_PSTFIRM), | |
2720 | .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_B}, | |
2721 | {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_A_PID_PREFIRM), | |
2722 | .driver_info = EAGLE_II | PREFIRM}, | |
2723 | {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_A_PID_PSTFIRM), | |
2724 | .driver_info = EAGLE_II | PSTFIRM | AUTO_ANNEX_A}, | |
2725 | {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_B_PID_PREFIRM), | |
2726 | .driver_info = EAGLE_II | PREFIRM}, | |
2727 | {USB_DEVICE(DEVOLO_VID, DEVOLO_EAGLE_II_B_PID_PSTFIRM), | |
2728 | .driver_info = EAGLE_II | PSTFIRM | AUTO_ANNEX_B}, | |
2729 | {USB_DEVICE(ELSA_VID, ELSA_PID_PREFIRM), | |
2730 | .driver_info = ADI930 | PREFIRM}, | |
2731 | {USB_DEVICE(ELSA_VID, ELSA_PID_PSTFIRM), | |
2732 | .driver_info = ADI930 | PSTFIRM}, | |
2733 | {USB_DEVICE(ELSA_VID, ELSA_PID_A_PREFIRM), | |
2734 | .driver_info = ADI930 | PREFIRM}, | |
2735 | {USB_DEVICE(ELSA_VID, ELSA_PID_A_PSTFIRM), | |
2736 | .driver_info = ADI930 | PSTFIRM | AUTO_ANNEX_A}, | |
2737 | {USB_DEVICE(ELSA_VID, ELSA_PID_B_PREFIRM), | |
2738 | .driver_info = ADI930 | PREFIRM}, | |
2739 | {USB_DEVICE(ELSA_VID, ELSA_PID_B_PSTFIRM), | |
2740 | .driver_info = ADI930 | PSTFIRM | AUTO_ANNEX_B}, | |
2741 | {USB_DEVICE(USR_VID, MILLER_A_PID_PREFIRM), | |
2742 | .driver_info = EAGLE_I | PREFIRM}, | |
2743 | {USB_DEVICE(USR_VID, MILLER_A_PID_PSTFIRM), | |
2744 | .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_A}, | |
2745 | {USB_DEVICE(USR_VID, MILLER_B_PID_PREFIRM), | |
2746 | .driver_info = EAGLE_I | PREFIRM}, | |
2747 | {USB_DEVICE(USR_VID, MILLER_B_PID_PSTFIRM), | |
2748 | .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_B}, | |
2749 | {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PREFIRM), | |
2750 | .driver_info = EAGLE_I | PREFIRM}, | |
2751 | {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PSTFIRM), | |
2752 | .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_A}, | |
2753 | {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PREFIRM), | |
2754 | .driver_info = EAGLE_I | PREFIRM}, | |
2755 | {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PSTFIRM), | |
2756 | .driver_info = EAGLE_I | PSTFIRM | AUTO_ANNEX_B}, | |
b72458a8 | 2757 | {} |
2758 | }; | |
2759 | ||
2760 | /* | |
2761 | * USB driver descriptor | |
2762 | */ | |
2763 | static struct usb_driver uea_driver = { | |
b72458a8 | 2764 | .name = "ueagle-atm", |
2765 | .id_table = uea_ids, | |
2766 | .probe = uea_probe, | |
2767 | .disconnect = uea_disconnect, | |
2768 | }; | |
2769 | ||
2770 | MODULE_DEVICE_TABLE(usb, uea_ids); | |
2771 | ||
65db4305 | 2772 | module_usb_driver(uea_driver); |
b72458a8 | 2773 | |
2774 | MODULE_AUTHOR("Damien Bergamini/Matthieu Castet/Stanislaw W. Gruszka"); | |
2775 | MODULE_DESCRIPTION("ADI 930/Eagle USB ADSL Modem driver"); | |
2776 | MODULE_LICENSE("Dual BSD/GPL"); | |
47282502 TG |
2777 | MODULE_FIRMWARE(EAGLE_FIRMWARE); |
2778 | MODULE_FIRMWARE(ADI930_FIRMWARE); | |
2779 | MODULE_FIRMWARE(EAGLE_I_FIRMWARE); | |
2780 | MODULE_FIRMWARE(EAGLE_II_FIRMWARE); | |
2781 | MODULE_FIRMWARE(EAGLE_III_FIRMWARE); | |
2782 | MODULE_FIRMWARE(EAGLE_IV_FIRMWARE); | |
2783 | MODULE_FIRMWARE(DSP4I_FIRMWARE); | |
2784 | MODULE_FIRMWARE(DSP4P_FIRMWARE); | |
2785 | MODULE_FIRMWARE(DSP9I_FIRMWARE); | |
2786 | MODULE_FIRMWARE(DSP9P_FIRMWARE); | |
2787 | MODULE_FIRMWARE(DSPEI_FIRMWARE); | |
2788 | MODULE_FIRMWARE(DSPEP_FIRMWARE); | |
2789 | MODULE_FIRMWARE(FPGA930_FIRMWARE); | |
2790 | MODULE_FIRMWARE(CMV4P_FIRMWARE); | |
2791 | MODULE_FIRMWARE(CMV4PV2_FIRMWARE); | |
2792 | MODULE_FIRMWARE(CMV4I_FIRMWARE); | |
2793 | MODULE_FIRMWARE(CMV4IV2_FIRMWARE); | |
2794 | MODULE_FIRMWARE(CMV9P_FIRMWARE); | |
2795 | MODULE_FIRMWARE(CMV9PV2_FIRMWARE); | |
2796 | MODULE_FIRMWARE(CMV9I_FIRMWARE); | |
2797 | MODULE_FIRMWARE(CMV9IV2_FIRMWARE); | |
2798 | MODULE_FIRMWARE(CMVEP_FIRMWARE); | |
2799 | MODULE_FIRMWARE(CMVEPV2_FIRMWARE); | |
2800 | MODULE_FIRMWARE(CMVEI_FIRMWARE); | |
2801 | MODULE_FIRMWARE(CMVEIV2_FIRMWARE); |