iuu_phoenix.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  1. /*
  2. * Infinity Unlimited USB Phoenix driver
  3. *
  4. * Copyright (C) 2010 James Courtier-Dutton (James@superbug.co.uk)
  5. * Copyright (C) 2007 Alain Degreffe (eczema@ecze.com)
  6. *
  7. * Original code taken from iuutool (Copyright (C) 2006 Juan Carlos Borrás)
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * And tested with help of WB Electronics
  15. *
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/errno.h>
  19. #include <linux/slab.h>
  20. #include <linux/tty.h>
  21. #include <linux/tty_driver.h>
  22. #include <linux/tty_flip.h>
  23. #include <linux/serial.h>
  24. #include <linux/module.h>
  25. #include <linux/moduleparam.h>
  26. #include <linux/spinlock.h>
  27. #include <linux/uaccess.h>
  28. #include <linux/usb.h>
  29. #include <linux/usb/serial.h>
  30. #include "iuu_phoenix.h"
  31. #include <linux/random.h>
  32. #define DRIVER_DESC "Infinity USB Unlimited Phoenix driver"
  33. static const struct usb_device_id id_table[] = {
  34. {USB_DEVICE(IUU_USB_VENDOR_ID, IUU_USB_PRODUCT_ID)},
  35. {} /* Terminating entry */
  36. };
  37. MODULE_DEVICE_TABLE(usb, id_table);
  38. /* turbo parameter */
  39. static int boost = 100;
  40. static int clockmode = 1;
  41. static int cdmode = 1;
  42. static int iuu_cardin;
  43. static int iuu_cardout;
  44. static bool xmas;
  45. static int vcc_default = 5;
  46. static int iuu_create_sysfs_attrs(struct usb_serial_port *port);
  47. static int iuu_remove_sysfs_attrs(struct usb_serial_port *port);
  48. static void read_rxcmd_callback(struct urb *urb);
  49. struct iuu_private {
  50. spinlock_t lock; /* store irq state */
  51. u8 line_status;
  52. int tiostatus; /* store IUART SIGNAL for tiocmget call */
  53. u8 reset; /* if 1 reset is needed */
  54. int poll; /* number of poll */
  55. u8 *writebuf; /* buffer for writing to device */
  56. int writelen; /* num of byte to write to device */
  57. u8 *buf; /* used for initialize speed */
  58. u8 len;
  59. int vcc; /* vcc (either 3 or 5 V) */
  60. u32 baud;
  61. u32 boost;
  62. u32 clk;
  63. };
  64. static int iuu_attach(struct usb_serial *serial)
  65. {
  66. unsigned char num_ports = serial->num_ports;
  67. if (serial->num_bulk_in < num_ports || serial->num_bulk_out < num_ports)
  68. return -ENODEV;
  69. return 0;
  70. }
  71. static int iuu_port_probe(struct usb_serial_port *port)
  72. {
  73. struct iuu_private *priv;
  74. int ret;
  75. priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
  76. if (!priv)
  77. return -ENOMEM;
  78. priv->buf = kzalloc(256, GFP_KERNEL);
  79. if (!priv->buf) {
  80. kfree(priv);
  81. return -ENOMEM;
  82. }
  83. priv->writebuf = kzalloc(256, GFP_KERNEL);
  84. if (!priv->writebuf) {
  85. kfree(priv->buf);
  86. kfree(priv);
  87. return -ENOMEM;
  88. }
  89. priv->vcc = vcc_default;
  90. spin_lock_init(&priv->lock);
  91. usb_set_serial_port_data(port, priv);
  92. ret = iuu_create_sysfs_attrs(port);
  93. if (ret) {
  94. kfree(priv->writebuf);
  95. kfree(priv->buf);
  96. kfree(priv);
  97. return ret;
  98. }
  99. return 0;
  100. }
  101. static int iuu_port_remove(struct usb_serial_port *port)
  102. {
  103. struct iuu_private *priv = usb_get_serial_port_data(port);
  104. iuu_remove_sysfs_attrs(port);
  105. kfree(priv->writebuf);
  106. kfree(priv->buf);
  107. kfree(priv);
  108. return 0;
  109. }
  110. static int iuu_tiocmset(struct tty_struct *tty,
  111. unsigned int set, unsigned int clear)
  112. {
  113. struct usb_serial_port *port = tty->driver_data;
  114. struct iuu_private *priv = usb_get_serial_port_data(port);
  115. unsigned long flags;
  116. /* FIXME: locking on tiomstatus */
  117. dev_dbg(&port->dev, "%s msg : SET = 0x%04x, CLEAR = 0x%04x\n",
  118. __func__, set, clear);
  119. spin_lock_irqsave(&priv->lock, flags);
  120. if ((set & TIOCM_RTS) && !(priv->tiostatus == TIOCM_RTS)) {
  121. dev_dbg(&port->dev, "%s TIOCMSET RESET called !!!\n", __func__);
  122. priv->reset = 1;
  123. }
  124. if (set & TIOCM_RTS)
  125. priv->tiostatus = TIOCM_RTS;
  126. spin_unlock_irqrestore(&priv->lock, flags);
  127. return 0;
  128. }
  129. /* This is used to provide a carrier detect mechanism
  130. * When a card is present, the response is 0x00
  131. * When no card , the reader respond with TIOCM_CD
  132. * This is known as CD autodetect mechanism
  133. */
  134. static int iuu_tiocmget(struct tty_struct *tty)
  135. {
  136. struct usb_serial_port *port = tty->driver_data;
  137. struct iuu_private *priv = usb_get_serial_port_data(port);
  138. unsigned long flags;
  139. int rc;
  140. spin_lock_irqsave(&priv->lock, flags);
  141. rc = priv->tiostatus;
  142. spin_unlock_irqrestore(&priv->lock, flags);
  143. return rc;
  144. }
  145. static void iuu_rxcmd(struct urb *urb)
  146. {
  147. struct usb_serial_port *port = urb->context;
  148. int result;
  149. int status = urb->status;
  150. if (status) {
  151. dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
  152. /* error stop all */
  153. return;
  154. }
  155. memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1);
  156. usb_fill_bulk_urb(port->write_urb, port->serial->dev,
  157. usb_sndbulkpipe(port->serial->dev,
  158. port->bulk_out_endpointAddress),
  159. port->write_urb->transfer_buffer, 1,
  160. read_rxcmd_callback, port);
  161. result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
  162. }
  163. static int iuu_reset(struct usb_serial_port *port, u8 wt)
  164. {
  165. struct iuu_private *priv = usb_get_serial_port_data(port);
  166. int result;
  167. char *buf_ptr = port->write_urb->transfer_buffer;
  168. /* Prepare the reset sequence */
  169. *buf_ptr++ = IUU_RST_SET;
  170. *buf_ptr++ = IUU_DELAY_MS;
  171. *buf_ptr++ = wt;
  172. *buf_ptr = IUU_RST_CLEAR;
  173. /* send the sequence */
  174. usb_fill_bulk_urb(port->write_urb,
  175. port->serial->dev,
  176. usb_sndbulkpipe(port->serial->dev,
  177. port->bulk_out_endpointAddress),
  178. port->write_urb->transfer_buffer, 4, iuu_rxcmd, port);
  179. result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
  180. priv->reset = 0;
  181. return result;
  182. }
  183. /* Status Function
  184. * Return value is
  185. * 0x00 = no card
  186. * 0x01 = smartcard
  187. * 0x02 = sim card
  188. */
  189. static void iuu_update_status_callback(struct urb *urb)
  190. {
  191. struct usb_serial_port *port = urb->context;
  192. struct iuu_private *priv = usb_get_serial_port_data(port);
  193. u8 *st;
  194. int status = urb->status;
  195. if (status) {
  196. dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
  197. /* error stop all */
  198. return;
  199. }
  200. st = urb->transfer_buffer;
  201. dev_dbg(&port->dev, "%s - enter\n", __func__);
  202. if (urb->actual_length == 1) {
  203. switch (st[0]) {
  204. case 0x1:
  205. priv->tiostatus = iuu_cardout;
  206. break;
  207. case 0x0:
  208. priv->tiostatus = iuu_cardin;
  209. break;
  210. default:
  211. priv->tiostatus = iuu_cardin;
  212. }
  213. }
  214. iuu_rxcmd(urb);
  215. }
  216. static void iuu_status_callback(struct urb *urb)
  217. {
  218. struct usb_serial_port *port = urb->context;
  219. int result;
  220. int status = urb->status;
  221. dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
  222. usb_fill_bulk_urb(port->read_urb, port->serial->dev,
  223. usb_rcvbulkpipe(port->serial->dev,
  224. port->bulk_in_endpointAddress),
  225. port->read_urb->transfer_buffer, 256,
  226. iuu_update_status_callback, port);
  227. result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
  228. }
  229. static int iuu_status(struct usb_serial_port *port)
  230. {
  231. int result;
  232. memset(port->write_urb->transfer_buffer, IUU_GET_STATE_REGISTER, 1);
  233. usb_fill_bulk_urb(port->write_urb, port->serial->dev,
  234. usb_sndbulkpipe(port->serial->dev,
  235. port->bulk_out_endpointAddress),
  236. port->write_urb->transfer_buffer, 1,
  237. iuu_status_callback, port);
  238. result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
  239. return result;
  240. }
  241. static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
  242. {
  243. int status;
  244. struct usb_serial *serial = port->serial;
  245. int actual = 0;
  246. /* send the data out the bulk port */
  247. status =
  248. usb_bulk_msg(serial->dev,
  249. usb_sndbulkpipe(serial->dev,
  250. port->bulk_out_endpointAddress), buf,
  251. count, &actual, 1000);
  252. if (status != IUU_OPERATION_OK)
  253. dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status);
  254. else
  255. dev_dbg(&port->dev, "%s - write OK !\n", __func__);
  256. return status;
  257. }
  258. static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
  259. {
  260. int status;
  261. struct usb_serial *serial = port->serial;
  262. int actual = 0;
  263. /* send the data out the bulk port */
  264. status =
  265. usb_bulk_msg(serial->dev,
  266. usb_rcvbulkpipe(serial->dev,
  267. port->bulk_in_endpointAddress), buf,
  268. count, &actual, 1000);
  269. if (status != IUU_OPERATION_OK)
  270. dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status);
  271. else
  272. dev_dbg(&port->dev, "%s - read OK !\n", __func__);
  273. return status;
  274. }
  275. static int iuu_led(struct usb_serial_port *port, unsigned int R,
  276. unsigned int G, unsigned int B, u8 f)
  277. {
  278. int status;
  279. u8 *buf;
  280. buf = kmalloc(8, GFP_KERNEL);
  281. if (!buf)
  282. return -ENOMEM;
  283. buf[0] = IUU_SET_LED;
  284. buf[1] = R & 0xFF;
  285. buf[2] = (R >> 8) & 0xFF;
  286. buf[3] = G & 0xFF;
  287. buf[4] = (G >> 8) & 0xFF;
  288. buf[5] = B & 0xFF;
  289. buf[6] = (B >> 8) & 0xFF;
  290. buf[7] = f;
  291. status = bulk_immediate(port, buf, 8);
  292. kfree(buf);
  293. if (status != IUU_OPERATION_OK)
  294. dev_dbg(&port->dev, "%s - led error status = %2x\n", __func__, status);
  295. else
  296. dev_dbg(&port->dev, "%s - led OK !\n", __func__);
  297. return IUU_OPERATION_OK;
  298. }
  299. static void iuu_rgbf_fill_buffer(u8 *buf, u8 r1, u8 r2, u8 g1, u8 g2, u8 b1,
  300. u8 b2, u8 freq)
  301. {
  302. *buf++ = IUU_SET_LED;
  303. *buf++ = r1;
  304. *buf++ = r2;
  305. *buf++ = g1;
  306. *buf++ = g2;
  307. *buf++ = b1;
  308. *buf++ = b2;
  309. *buf = freq;
  310. }
  311. static void iuu_led_activity_on(struct urb *urb)
  312. {
  313. struct usb_serial_port *port = urb->context;
  314. int result;
  315. char *buf_ptr = port->write_urb->transfer_buffer;
  316. *buf_ptr++ = IUU_SET_LED;
  317. if (xmas == 1) {
  318. get_random_bytes(buf_ptr, 6);
  319. *(buf_ptr+7) = 1;
  320. } else {
  321. iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255);
  322. }
  323. usb_fill_bulk_urb(port->write_urb, port->serial->dev,
  324. usb_sndbulkpipe(port->serial->dev,
  325. port->bulk_out_endpointAddress),
  326. port->write_urb->transfer_buffer, 8 ,
  327. iuu_rxcmd, port);
  328. result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
  329. }
  330. static void iuu_led_activity_off(struct urb *urb)
  331. {
  332. struct usb_serial_port *port = urb->context;
  333. int result;
  334. char *buf_ptr = port->write_urb->transfer_buffer;
  335. if (xmas == 1) {
  336. iuu_rxcmd(urb);
  337. return;
  338. } else {
  339. *buf_ptr++ = IUU_SET_LED;
  340. iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255);
  341. }
  342. usb_fill_bulk_urb(port->write_urb, port->serial->dev,
  343. usb_sndbulkpipe(port->serial->dev,
  344. port->bulk_out_endpointAddress),
  345. port->write_urb->transfer_buffer, 8 ,
  346. iuu_rxcmd, port);
  347. result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
  348. }
  349. static int iuu_clk(struct usb_serial_port *port, int dwFrq)
  350. {
  351. int status;
  352. struct iuu_private *priv = usb_get_serial_port_data(port);
  353. int Count = 0;
  354. u8 FrqGenAdr = 0x69;
  355. u8 DIV = 0; /* 8bit */
  356. u8 XDRV = 0; /* 8bit */
  357. u8 PUMP = 0; /* 3bit */
  358. u8 PBmsb = 0; /* 2bit */
  359. u8 PBlsb = 0; /* 8bit */
  360. u8 PO = 0; /* 1bit */
  361. u8 Q = 0; /* 7bit */
  362. /* 24bit = 3bytes */
  363. unsigned int P = 0;
  364. unsigned int P2 = 0;
  365. int frq = (int)dwFrq;
  366. if (frq == 0) {
  367. priv->buf[Count++] = IUU_UART_WRITE_I2C;
  368. priv->buf[Count++] = FrqGenAdr << 1;
  369. priv->buf[Count++] = 0x09;
  370. priv->buf[Count++] = 0x00;
  371. status = bulk_immediate(port, (u8 *) priv->buf, Count);
  372. if (status != 0) {
  373. dev_dbg(&port->dev, "%s - write error\n", __func__);
  374. return status;
  375. }
  376. } else if (frq == 3579000) {
  377. DIV = 100;
  378. P = 1193;
  379. Q = 40;
  380. XDRV = 0;
  381. } else if (frq == 3680000) {
  382. DIV = 105;
  383. P = 161;
  384. Q = 5;
  385. XDRV = 0;
  386. } else if (frq == 6000000) {
  387. DIV = 66;
  388. P = 66;
  389. Q = 2;
  390. XDRV = 0x28;
  391. } else {
  392. unsigned int result = 0;
  393. unsigned int tmp = 0;
  394. unsigned int check;
  395. unsigned int check2;
  396. char found = 0x00;
  397. unsigned int lQ = 2;
  398. unsigned int lP = 2055;
  399. unsigned int lDiv = 4;
  400. for (lQ = 2; lQ <= 47 && !found; lQ++)
  401. for (lP = 2055; lP >= 8 && !found; lP--)
  402. for (lDiv = 4; lDiv <= 127 && !found; lDiv++) {
  403. tmp = (12000000 / lDiv) * (lP / lQ);
  404. if (abs((int)(tmp - frq)) <
  405. abs((int)(frq - result))) {
  406. check2 = (12000000 / lQ);
  407. if (check2 < 250000)
  408. continue;
  409. check = (12000000 / lQ) * lP;
  410. if (check > 400000000)
  411. continue;
  412. if (check < 100000000)
  413. continue;
  414. if (lDiv < 4 || lDiv > 127)
  415. continue;
  416. result = tmp;
  417. P = lP;
  418. DIV = lDiv;
  419. Q = lQ;
  420. if (result == frq)
  421. found = 0x01;
  422. }
  423. }
  424. }
  425. P2 = ((P - PO) / 2) - 4;
  426. DIV = DIV;
  427. PUMP = 0x04;
  428. PBmsb = (P2 >> 8 & 0x03);
  429. PBlsb = P2 & 0xFF;
  430. PO = (P >> 10) & 0x01;
  431. Q = Q - 2;
  432. priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
  433. priv->buf[Count++] = FrqGenAdr << 1;
  434. priv->buf[Count++] = 0x09;
  435. priv->buf[Count++] = 0x20; /* Adr = 0x09 */
  436. priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
  437. priv->buf[Count++] = FrqGenAdr << 1;
  438. priv->buf[Count++] = 0x0C;
  439. priv->buf[Count++] = DIV; /* Adr = 0x0C */
  440. priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
  441. priv->buf[Count++] = FrqGenAdr << 1;
  442. priv->buf[Count++] = 0x12;
  443. priv->buf[Count++] = XDRV; /* Adr = 0x12 */
  444. priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
  445. priv->buf[Count++] = FrqGenAdr << 1;
  446. priv->buf[Count++] = 0x13;
  447. priv->buf[Count++] = 0x6B; /* Adr = 0x13 */
  448. priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
  449. priv->buf[Count++] = FrqGenAdr << 1;
  450. priv->buf[Count++] = 0x40;
  451. priv->buf[Count++] = (0xC0 | ((PUMP & 0x07) << 2)) |
  452. (PBmsb & 0x03); /* Adr = 0x40 */
  453. priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
  454. priv->buf[Count++] = FrqGenAdr << 1;
  455. priv->buf[Count++] = 0x41;
  456. priv->buf[Count++] = PBlsb; /* Adr = 0x41 */
  457. priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
  458. priv->buf[Count++] = FrqGenAdr << 1;
  459. priv->buf[Count++] = 0x42;
  460. priv->buf[Count++] = Q | (((PO & 0x01) << 7)); /* Adr = 0x42 */
  461. priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
  462. priv->buf[Count++] = FrqGenAdr << 1;
  463. priv->buf[Count++] = 0x44;
  464. priv->buf[Count++] = (char)0xFF; /* Adr = 0x44 */
  465. priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
  466. priv->buf[Count++] = FrqGenAdr << 1;
  467. priv->buf[Count++] = 0x45;
  468. priv->buf[Count++] = (char)0xFE; /* Adr = 0x45 */
  469. priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
  470. priv->buf[Count++] = FrqGenAdr << 1;
  471. priv->buf[Count++] = 0x46;
  472. priv->buf[Count++] = 0x7F; /* Adr = 0x46 */
  473. priv->buf[Count++] = IUU_UART_WRITE_I2C; /* 0x4C */
  474. priv->buf[Count++] = FrqGenAdr << 1;
  475. priv->buf[Count++] = 0x47;
  476. priv->buf[Count++] = (char)0x84; /* Adr = 0x47 */
  477. status = bulk_immediate(port, (u8 *) priv->buf, Count);
  478. if (status != IUU_OPERATION_OK)
  479. dev_dbg(&port->dev, "%s - write error\n", __func__);
  480. return status;
  481. }
  482. static int iuu_uart_flush(struct usb_serial_port *port)
  483. {
  484. struct device *dev = &port->dev;
  485. int i;
  486. int status;
  487. u8 rxcmd = IUU_UART_RX;
  488. struct iuu_private *priv = usb_get_serial_port_data(port);
  489. if (iuu_led(port, 0xF000, 0, 0, 0xFF) < 0)
  490. return -EIO;
  491. for (i = 0; i < 2; i++) {
  492. status = bulk_immediate(port, &rxcmd, 1);
  493. if (status != IUU_OPERATION_OK) {
  494. dev_dbg(dev, "%s - uart_flush_write error\n", __func__);
  495. return status;
  496. }
  497. status = read_immediate(port, &priv->len, 1);
  498. if (status != IUU_OPERATION_OK) {
  499. dev_dbg(dev, "%s - uart_flush_read error\n", __func__);
  500. return status;
  501. }
  502. if (priv->len > 0) {
  503. dev_dbg(dev, "%s - uart_flush datalen is : %i\n", __func__, priv->len);
  504. status = read_immediate(port, priv->buf, priv->len);
  505. if (status != IUU_OPERATION_OK) {
  506. dev_dbg(dev, "%s - uart_flush_read error\n", __func__);
  507. return status;
  508. }
  509. }
  510. }
  511. dev_dbg(dev, "%s - uart_flush_read OK!\n", __func__);
  512. iuu_led(port, 0, 0xF000, 0, 0xFF);
  513. return status;
  514. }
  515. static void read_buf_callback(struct urb *urb)
  516. {
  517. struct usb_serial_port *port = urb->context;
  518. unsigned char *data = urb->transfer_buffer;
  519. int status = urb->status;
  520. if (status) {
  521. if (status == -EPROTO) {
  522. /* reschedule needed */
  523. }
  524. return;
  525. }
  526. dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length);
  527. if (data == NULL)
  528. dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__);
  529. if (urb->actual_length && data) {
  530. tty_insert_flip_string(&port->port, data, urb->actual_length);
  531. tty_flip_buffer_push(&port->port);
  532. }
  533. iuu_led_activity_on(urb);
  534. }
  535. static int iuu_bulk_write(struct usb_serial_port *port)
  536. {
  537. struct iuu_private *priv = usb_get_serial_port_data(port);
  538. unsigned long flags;
  539. int result;
  540. int buf_len;
  541. char *buf_ptr = port->write_urb->transfer_buffer;
  542. spin_lock_irqsave(&priv->lock, flags);
  543. *buf_ptr++ = IUU_UART_ESC;
  544. *buf_ptr++ = IUU_UART_TX;
  545. *buf_ptr++ = priv->writelen;
  546. memcpy(buf_ptr, priv->writebuf, priv->writelen);
  547. buf_len = priv->writelen;
  548. priv->writelen = 0;
  549. spin_unlock_irqrestore(&priv->lock, flags);
  550. dev_dbg(&port->dev, "%s - writing %i chars : %*ph\n", __func__,
  551. buf_len, buf_len, buf_ptr);
  552. usb_fill_bulk_urb(port->write_urb, port->serial->dev,
  553. usb_sndbulkpipe(port->serial->dev,
  554. port->bulk_out_endpointAddress),
  555. port->write_urb->transfer_buffer, buf_len + 3,
  556. iuu_rxcmd, port);
  557. result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
  558. usb_serial_port_softint(port);
  559. return result;
  560. }
  561. static int iuu_read_buf(struct usb_serial_port *port, int len)
  562. {
  563. int result;
  564. usb_fill_bulk_urb(port->read_urb, port->serial->dev,
  565. usb_rcvbulkpipe(port->serial->dev,
  566. port->bulk_in_endpointAddress),
  567. port->read_urb->transfer_buffer, len,
  568. read_buf_callback, port);
  569. result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
  570. return result;
  571. }
  572. static void iuu_uart_read_callback(struct urb *urb)
  573. {
  574. struct usb_serial_port *port = urb->context;
  575. struct iuu_private *priv = usb_get_serial_port_data(port);
  576. unsigned long flags;
  577. int status = urb->status;
  578. int error = 0;
  579. int len = 0;
  580. unsigned char *data = urb->transfer_buffer;
  581. priv->poll++;
  582. if (status) {
  583. dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
  584. /* error stop all */
  585. return;
  586. }
  587. if (data == NULL)
  588. dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__);
  589. if (urb->actual_length == 1 && data != NULL)
  590. len = (int) data[0];
  591. if (urb->actual_length > 1) {
  592. dev_dbg(&port->dev, "%s - urb->actual_length = %i\n", __func__,
  593. urb->actual_length);
  594. error = 1;
  595. return;
  596. }
  597. /* if len > 0 call readbuf */
  598. if (len > 0 && error == 0) {
  599. dev_dbg(&port->dev, "%s - call read buf - len to read is %i\n",
  600. __func__, len);
  601. status = iuu_read_buf(port, len);
  602. return;
  603. }
  604. /* need to update status ? */
  605. if (priv->poll > 99) {
  606. status = iuu_status(port);
  607. priv->poll = 0;
  608. return;
  609. }
  610. /* reset waiting ? */
  611. if (priv->reset == 1) {
  612. status = iuu_reset(port, 0xC);
  613. return;
  614. }
  615. /* Writebuf is waiting */
  616. spin_lock_irqsave(&priv->lock, flags);
  617. if (priv->writelen > 0) {
  618. spin_unlock_irqrestore(&priv->lock, flags);
  619. status = iuu_bulk_write(port);
  620. return;
  621. }
  622. spin_unlock_irqrestore(&priv->lock, flags);
  623. /* if nothing to write call again rxcmd */
  624. dev_dbg(&port->dev, "%s - rxcmd recall\n", __func__);
  625. iuu_led_activity_off(urb);
  626. }
  627. static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port,
  628. const u8 *buf, int count)
  629. {
  630. struct iuu_private *priv = usb_get_serial_port_data(port);
  631. unsigned long flags;
  632. if (count > 256)
  633. return -ENOMEM;
  634. spin_lock_irqsave(&priv->lock, flags);
  635. /* fill the buffer */
  636. memcpy(priv->writebuf + priv->writelen, buf, count);
  637. priv->writelen += count;
  638. spin_unlock_irqrestore(&priv->lock, flags);
  639. return count;
  640. }
  641. static void read_rxcmd_callback(struct urb *urb)
  642. {
  643. struct usb_serial_port *port = urb->context;
  644. int result;
  645. int status = urb->status;
  646. if (status) {
  647. /* error stop all */
  648. return;
  649. }
  650. usb_fill_bulk_urb(port->read_urb, port->serial->dev,
  651. usb_rcvbulkpipe(port->serial->dev,
  652. port->bulk_in_endpointAddress),
  653. port->read_urb->transfer_buffer, 256,
  654. iuu_uart_read_callback, port);
  655. result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
  656. dev_dbg(&port->dev, "%s - submit result = %d\n", __func__, result);
  657. }
  658. static int iuu_uart_on(struct usb_serial_port *port)
  659. {
  660. int status;
  661. u8 *buf;
  662. buf = kmalloc(sizeof(u8) * 4, GFP_KERNEL);
  663. if (!buf)
  664. return -ENOMEM;
  665. buf[0] = IUU_UART_ENABLE;
  666. buf[1] = (u8) ((IUU_BAUD_9600 >> 8) & 0x00FF);
  667. buf[2] = (u8) (0x00FF & IUU_BAUD_9600);
  668. buf[3] = (u8) (0x0F0 & IUU_ONE_STOP_BIT) | (0x07 & IUU_PARITY_EVEN);
  669. status = bulk_immediate(port, buf, 4);
  670. if (status != IUU_OPERATION_OK) {
  671. dev_dbg(&port->dev, "%s - uart_on error\n", __func__);
  672. goto uart_enable_failed;
  673. }
  674. /* iuu_reset() the card after iuu_uart_on() */
  675. status = iuu_uart_flush(port);
  676. if (status != IUU_OPERATION_OK)
  677. dev_dbg(&port->dev, "%s - uart_flush error\n", __func__);
  678. uart_enable_failed:
  679. kfree(buf);
  680. return status;
  681. }
  682. /* Disables the IUU UART (a.k.a. the Phoenix voiderface) */
  683. static int iuu_uart_off(struct usb_serial_port *port)
  684. {
  685. int status;
  686. u8 *buf;
  687. buf = kmalloc(1, GFP_KERNEL);
  688. if (!buf)
  689. return -ENOMEM;
  690. buf[0] = IUU_UART_DISABLE;
  691. status = bulk_immediate(port, buf, 1);
  692. if (status != IUU_OPERATION_OK)
  693. dev_dbg(&port->dev, "%s - uart_off error\n", __func__);
  694. kfree(buf);
  695. return status;
  696. }
  697. static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base,
  698. u32 *actual, u8 parity)
  699. {
  700. int status;
  701. u32 baud;
  702. u8 *dataout;
  703. u8 DataCount = 0;
  704. u8 T1Frekvens = 0;
  705. u8 T1reload = 0;
  706. unsigned int T1FrekvensHZ = 0;
  707. dev_dbg(&port->dev, "%s - enter baud_base=%d\n", __func__, baud_base);
  708. dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL);
  709. if (!dataout)
  710. return -ENOMEM;
  711. /*baud = (((priv->clk / 35) * baud_base) / 100000); */
  712. baud = baud_base;
  713. if (baud < 1200 || baud > 230400) {
  714. kfree(dataout);
  715. return IUU_INVALID_PARAMETER;
  716. }
  717. if (baud > 977) {
  718. T1Frekvens = 3;
  719. T1FrekvensHZ = 500000;
  720. }
  721. if (baud > 3906) {
  722. T1Frekvens = 2;
  723. T1FrekvensHZ = 2000000;
  724. }
  725. if (baud > 11718) {
  726. T1Frekvens = 1;
  727. T1FrekvensHZ = 6000000;
  728. }
  729. if (baud > 46875) {
  730. T1Frekvens = 0;
  731. T1FrekvensHZ = 24000000;
  732. }
  733. T1reload = 256 - (u8) (T1FrekvensHZ / (baud * 2));
  734. /* magic number here: ENTER_FIRMWARE_UPDATE; */
  735. dataout[DataCount++] = IUU_UART_ESC;
  736. /* magic number here: CHANGE_BAUD; */
  737. dataout[DataCount++] = IUU_UART_CHANGE;
  738. dataout[DataCount++] = T1Frekvens;
  739. dataout[DataCount++] = T1reload;
  740. *actual = (T1FrekvensHZ / (256 - T1reload)) / 2;
  741. switch (parity & 0x0F) {
  742. case IUU_PARITY_NONE:
  743. dataout[DataCount++] = 0x00;
  744. break;
  745. case IUU_PARITY_EVEN:
  746. dataout[DataCount++] = 0x01;
  747. break;
  748. case IUU_PARITY_ODD:
  749. dataout[DataCount++] = 0x02;
  750. break;
  751. case IUU_PARITY_MARK:
  752. dataout[DataCount++] = 0x03;
  753. break;
  754. case IUU_PARITY_SPACE:
  755. dataout[DataCount++] = 0x04;
  756. break;
  757. default:
  758. kfree(dataout);
  759. return IUU_INVALID_PARAMETER;
  760. break;
  761. }
  762. switch (parity & 0xF0) {
  763. case IUU_ONE_STOP_BIT:
  764. dataout[DataCount - 1] |= IUU_ONE_STOP_BIT;
  765. break;
  766. case IUU_TWO_STOP_BITS:
  767. dataout[DataCount - 1] |= IUU_TWO_STOP_BITS;
  768. break;
  769. default:
  770. kfree(dataout);
  771. return IUU_INVALID_PARAMETER;
  772. break;
  773. }
  774. status = bulk_immediate(port, dataout, DataCount);
  775. if (status != IUU_OPERATION_OK)
  776. dev_dbg(&port->dev, "%s - uart_off error\n", __func__);
  777. kfree(dataout);
  778. return status;
  779. }
  780. static void iuu_set_termios(struct tty_struct *tty,
  781. struct usb_serial_port *port, struct ktermios *old_termios)
  782. {
  783. const u32 supported_mask = CMSPAR|PARENB|PARODD;
  784. struct iuu_private *priv = usb_get_serial_port_data(port);
  785. unsigned int cflag = tty->termios.c_cflag;
  786. int status;
  787. u32 actual;
  788. u32 parity;
  789. int csize = CS7;
  790. int baud;
  791. u32 newval = cflag & supported_mask;
  792. /* Just use the ospeed. ispeed should be the same. */
  793. baud = tty->termios.c_ospeed;
  794. dev_dbg(&port->dev, "%s - enter c_ospeed or baud=%d\n", __func__, baud);
  795. /* compute the parity parameter */
  796. parity = 0;
  797. if (cflag & CMSPAR) { /* Using mark space */
  798. if (cflag & PARODD)
  799. parity |= IUU_PARITY_SPACE;
  800. else
  801. parity |= IUU_PARITY_MARK;
  802. } else if (!(cflag & PARENB)) {
  803. parity |= IUU_PARITY_NONE;
  804. csize = CS8;
  805. } else if (cflag & PARODD)
  806. parity |= IUU_PARITY_ODD;
  807. else
  808. parity |= IUU_PARITY_EVEN;
  809. parity |= (cflag & CSTOPB ? IUU_TWO_STOP_BITS : IUU_ONE_STOP_BIT);
  810. /* set it */
  811. status = iuu_uart_baud(port,
  812. baud * priv->boost / 100,
  813. &actual, parity);
  814. /* set the termios value to the real one, so the user now what has
  815. * changed. We support few fields so its easies to copy the old hw
  816. * settings back over and then adjust them
  817. */
  818. if (old_termios)
  819. tty_termios_copy_hw(&tty->termios, old_termios);
  820. if (status != 0) /* Set failed - return old bits */
  821. return;
  822. /* Re-encode speed, parity and csize */
  823. tty_encode_baud_rate(tty, baud, baud);
  824. tty->termios.c_cflag &= ~(supported_mask|CSIZE);
  825. tty->termios.c_cflag |= newval | csize;
  826. }
  827. static void iuu_close(struct usb_serial_port *port)
  828. {
  829. /* iuu_led (port,255,0,0,0); */
  830. iuu_uart_off(port);
  831. usb_kill_urb(port->write_urb);
  832. usb_kill_urb(port->read_urb);
  833. iuu_led(port, 0, 0, 0xF000, 0xFF);
  834. }
  835. static void iuu_init_termios(struct tty_struct *tty)
  836. {
  837. tty->termios = tty_std_termios;
  838. tty->termios.c_cflag = CLOCAL | CREAD | CS8 | B9600
  839. | TIOCM_CTS | CSTOPB | PARENB;
  840. tty->termios.c_ispeed = 9600;
  841. tty->termios.c_ospeed = 9600;
  842. tty->termios.c_lflag = 0;
  843. tty->termios.c_oflag = 0;
  844. tty->termios.c_iflag = 0;
  845. }
  846. static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
  847. {
  848. struct usb_serial *serial = port->serial;
  849. struct device *dev = &port->dev;
  850. u8 *buf;
  851. int result;
  852. int baud;
  853. u32 actual;
  854. struct iuu_private *priv = usb_get_serial_port_data(port);
  855. baud = tty->termios.c_ospeed;
  856. tty->termios.c_ispeed = baud;
  857. /* Re-encode speed */
  858. tty_encode_baud_rate(tty, baud, baud);
  859. dev_dbg(dev, "%s - baud %d\n", __func__, baud);
  860. usb_clear_halt(serial->dev, port->write_urb->pipe);
  861. usb_clear_halt(serial->dev, port->read_urb->pipe);
  862. buf = kmalloc(10, GFP_KERNEL);
  863. if (buf == NULL)
  864. return -ENOMEM;
  865. priv->poll = 0;
  866. /* initialize writebuf */
  867. #define FISH(a, b, c, d) do { \
  868. result = usb_control_msg(port->serial->dev, \
  869. usb_rcvctrlpipe(port->serial->dev, 0), \
  870. b, a, c, d, buf, 1, 1000); \
  871. dev_dbg(dev, "0x%x:0x%x:0x%x:0x%x %d - %x\n", a, b, c, d, result, \
  872. buf[0]); } while (0);
  873. #define SOUP(a, b, c, d) do { \
  874. result = usb_control_msg(port->serial->dev, \
  875. usb_sndctrlpipe(port->serial->dev, 0), \
  876. b, a, c, d, NULL, 0, 1000); \
  877. dev_dbg(dev, "0x%x:0x%x:0x%x:0x%x %d\n", a, b, c, d, result); } while (0)
  878. /* This is not UART related but IUU USB driver related or something */
  879. /* like that. Basically no IUU will accept any commands from the USB */
  880. /* host unless it has received the following message */
  881. /* sprintf(buf ,"%c%c%c%c",0x03,0x02,0x02,0x0); */
  882. SOUP(0x03, 0x02, 0x02, 0x0);
  883. kfree(buf);
  884. iuu_led(port, 0xF000, 0xF000, 0, 0xFF);
  885. iuu_uart_on(port);
  886. if (boost < 100)
  887. boost = 100;
  888. priv->boost = boost;
  889. priv->baud = baud;
  890. switch (clockmode) {
  891. case 2: /* 3.680 Mhz */
  892. priv->clk = IUU_CLK_3680000;
  893. iuu_clk(port, IUU_CLK_3680000 * boost / 100);
  894. result =
  895. iuu_uart_baud(port, baud * boost / 100, &actual,
  896. IUU_PARITY_EVEN);
  897. break;
  898. case 3: /* 6.00 Mhz */
  899. iuu_clk(port, IUU_CLK_6000000 * boost / 100);
  900. priv->clk = IUU_CLK_6000000;
  901. /* Ratio of 6000000 to 3500000 for baud 9600 */
  902. result =
  903. iuu_uart_baud(port, 16457 * boost / 100, &actual,
  904. IUU_PARITY_EVEN);
  905. break;
  906. default: /* 3.579 Mhz */
  907. iuu_clk(port, IUU_CLK_3579000 * boost / 100);
  908. priv->clk = IUU_CLK_3579000;
  909. result =
  910. iuu_uart_baud(port, baud * boost / 100, &actual,
  911. IUU_PARITY_EVEN);
  912. }
  913. /* set the cardin cardout signals */
  914. switch (cdmode) {
  915. case 0:
  916. iuu_cardin = 0;
  917. iuu_cardout = 0;
  918. break;
  919. case 1:
  920. iuu_cardin = TIOCM_CD;
  921. iuu_cardout = 0;
  922. break;
  923. case 2:
  924. iuu_cardin = 0;
  925. iuu_cardout = TIOCM_CD;
  926. break;
  927. case 3:
  928. iuu_cardin = TIOCM_DSR;
  929. iuu_cardout = 0;
  930. break;
  931. case 4:
  932. iuu_cardin = 0;
  933. iuu_cardout = TIOCM_DSR;
  934. break;
  935. case 5:
  936. iuu_cardin = TIOCM_CTS;
  937. iuu_cardout = 0;
  938. break;
  939. case 6:
  940. iuu_cardin = 0;
  941. iuu_cardout = TIOCM_CTS;
  942. break;
  943. case 7:
  944. iuu_cardin = TIOCM_RNG;
  945. iuu_cardout = 0;
  946. break;
  947. case 8:
  948. iuu_cardin = 0;
  949. iuu_cardout = TIOCM_RNG;
  950. }
  951. iuu_uart_flush(port);
  952. dev_dbg(dev, "%s - initialization done\n", __func__);
  953. memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1);
  954. usb_fill_bulk_urb(port->write_urb, port->serial->dev,
  955. usb_sndbulkpipe(port->serial->dev,
  956. port->bulk_out_endpointAddress),
  957. port->write_urb->transfer_buffer, 1,
  958. read_rxcmd_callback, port);
  959. result = usb_submit_urb(port->write_urb, GFP_KERNEL);
  960. if (result) {
  961. dev_err(dev, "%s - failed submitting read urb, error %d\n", __func__, result);
  962. iuu_close(port);
  963. } else {
  964. dev_dbg(dev, "%s - rxcmd OK\n", __func__);
  965. }
  966. return result;
  967. }
  968. /* how to change VCC */
  969. static int iuu_vcc_set(struct usb_serial_port *port, unsigned int vcc)
  970. {
  971. int status;
  972. u8 *buf;
  973. buf = kmalloc(5, GFP_KERNEL);
  974. if (!buf)
  975. return -ENOMEM;
  976. buf[0] = IUU_SET_VCC;
  977. buf[1] = vcc & 0xFF;
  978. buf[2] = (vcc >> 8) & 0xFF;
  979. buf[3] = (vcc >> 16) & 0xFF;
  980. buf[4] = (vcc >> 24) & 0xFF;
  981. status = bulk_immediate(port, buf, 5);
  982. kfree(buf);
  983. if (status != IUU_OPERATION_OK)
  984. dev_dbg(&port->dev, "%s - vcc error status = %2x\n", __func__, status);
  985. else
  986. dev_dbg(&port->dev, "%s - vcc OK !\n", __func__);
  987. return status;
  988. }
  989. /*
  990. * Sysfs Attributes
  991. */
  992. static ssize_t vcc_mode_show(struct device *dev,
  993. struct device_attribute *attr, char *buf)
  994. {
  995. struct usb_serial_port *port = to_usb_serial_port(dev);
  996. struct iuu_private *priv = usb_get_serial_port_data(port);
  997. return sprintf(buf, "%d\n", priv->vcc);
  998. }
  999. static ssize_t vcc_mode_store(struct device *dev,
  1000. struct device_attribute *attr, const char *buf, size_t count)
  1001. {
  1002. struct usb_serial_port *port = to_usb_serial_port(dev);
  1003. struct iuu_private *priv = usb_get_serial_port_data(port);
  1004. unsigned long v;
  1005. if (kstrtoul(buf, 10, &v)) {
  1006. dev_err(dev, "%s - vcc_mode: %s is not a unsigned long\n",
  1007. __func__, buf);
  1008. goto fail_store_vcc_mode;
  1009. }
  1010. dev_dbg(dev, "%s: setting vcc_mode = %ld\n", __func__, v);
  1011. if ((v != 3) && (v != 5)) {
  1012. dev_err(dev, "%s - vcc_mode %ld is invalid\n", __func__, v);
  1013. } else {
  1014. iuu_vcc_set(port, v);
  1015. priv->vcc = v;
  1016. }
  1017. fail_store_vcc_mode:
  1018. return count;
  1019. }
  1020. static DEVICE_ATTR_RW(vcc_mode);
  1021. static int iuu_create_sysfs_attrs(struct usb_serial_port *port)
  1022. {
  1023. return device_create_file(&port->dev, &dev_attr_vcc_mode);
  1024. }
  1025. static int iuu_remove_sysfs_attrs(struct usb_serial_port *port)
  1026. {
  1027. device_remove_file(&port->dev, &dev_attr_vcc_mode);
  1028. return 0;
  1029. }
  1030. /*
  1031. * End Sysfs Attributes
  1032. */
  1033. static struct usb_serial_driver iuu_device = {
  1034. .driver = {
  1035. .owner = THIS_MODULE,
  1036. .name = "iuu_phoenix",
  1037. },
  1038. .id_table = id_table,
  1039. .num_ports = 1,
  1040. .bulk_in_size = 512,
  1041. .bulk_out_size = 512,
  1042. .open = iuu_open,
  1043. .close = iuu_close,
  1044. .write = iuu_uart_write,
  1045. .read_bulk_callback = iuu_uart_read_callback,
  1046. .tiocmget = iuu_tiocmget,
  1047. .tiocmset = iuu_tiocmset,
  1048. .set_termios = iuu_set_termios,
  1049. .init_termios = iuu_init_termios,
  1050. .attach = iuu_attach,
  1051. .port_probe = iuu_port_probe,
  1052. .port_remove = iuu_port_remove,
  1053. };
  1054. static struct usb_serial_driver * const serial_drivers[] = {
  1055. &iuu_device, NULL
  1056. };
  1057. module_usb_serial_driver(serial_drivers, id_table);
  1058. MODULE_AUTHOR("Alain Degreffe eczema@ecze.com");
  1059. MODULE_DESCRIPTION(DRIVER_DESC);
  1060. MODULE_LICENSE("GPL");
  1061. module_param(xmas, bool, S_IRUGO | S_IWUSR);
  1062. MODULE_PARM_DESC(xmas, "Xmas colors enabled or not");
  1063. module_param(boost, int, S_IRUGO | S_IWUSR);
  1064. MODULE_PARM_DESC(boost, "Card overclock boost (in percent 100-500)");
  1065. module_param(clockmode, int, S_IRUGO | S_IWUSR);
  1066. MODULE_PARM_DESC(clockmode, "Card clock mode (1=3.579 MHz, 2=3.680 MHz, "
  1067. "3=6 Mhz)");
  1068. module_param(cdmode, int, S_IRUGO | S_IWUSR);
  1069. MODULE_PARM_DESC(cdmode, "Card detect mode (0=none, 1=CD, 2=!CD, 3=DSR, "
  1070. "4=!DSR, 5=CTS, 6=!CTS, 7=RING, 8=!RING)");
  1071. module_param(vcc_default, int, S_IRUGO | S_IWUSR);
  1072. MODULE_PARM_DESC(vcc_default, "Set default VCC (either 3 for 3.3V or 5 "
  1073. "for 5V). Default to 5.");