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