ueagle-atm.c 69 KB

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