max3107.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197
  1. /*
  2. * max3107.c - spi uart protocol driver for Maxim 3107
  3. * Based on max3100.c
  4. * by Christian Pellegrin <chripell@evolware.org>
  5. * and max3110.c
  6. * by Feng Tang <feng.tang@intel.com>
  7. *
  8. * Copyright (C) Aavamobile 2009
  9. *
  10. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. *
  26. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  27. *
  28. */
  29. #include <linux/delay.h>
  30. #include <linux/device.h>
  31. #include <linux/serial_core.h>
  32. #include <linux/serial.h>
  33. #include <linux/gpio.h>
  34. #include <linux/spi/spi.h>
  35. #include <linux/freezer.h>
  36. #include "max3107.h"
  37. static const struct baud_table brg26_ext[] = {
  38. { 300, MAX3107_BRG26_B300 },
  39. { 600, MAX3107_BRG26_B600 },
  40. { 1200, MAX3107_BRG26_B1200 },
  41. { 2400, MAX3107_BRG26_B2400 },
  42. { 4800, MAX3107_BRG26_B4800 },
  43. { 9600, MAX3107_BRG26_B9600 },
  44. { 19200, MAX3107_BRG26_B19200 },
  45. { 57600, MAX3107_BRG26_B57600 },
  46. { 115200, MAX3107_BRG26_B115200 },
  47. { 230400, MAX3107_BRG26_B230400 },
  48. { 460800, MAX3107_BRG26_B460800 },
  49. { 921600, MAX3107_BRG26_B921600 },
  50. { 0, 0 }
  51. };
  52. static const struct baud_table brg13_int[] = {
  53. { 300, MAX3107_BRG13_IB300 },
  54. { 600, MAX3107_BRG13_IB600 },
  55. { 1200, MAX3107_BRG13_IB1200 },
  56. { 2400, MAX3107_BRG13_IB2400 },
  57. { 4800, MAX3107_BRG13_IB4800 },
  58. { 9600, MAX3107_BRG13_IB9600 },
  59. { 19200, MAX3107_BRG13_IB19200 },
  60. { 57600, MAX3107_BRG13_IB57600 },
  61. { 115200, MAX3107_BRG13_IB115200 },
  62. { 230400, MAX3107_BRG13_IB230400 },
  63. { 460800, MAX3107_BRG13_IB460800 },
  64. { 921600, MAX3107_BRG13_IB921600 },
  65. { 0, 0 }
  66. };
  67. static u32 get_new_brg(int baud, struct max3107_port *s)
  68. {
  69. int i;
  70. const struct baud_table *baud_tbl = s->baud_tbl;
  71. for (i = 0; i < 13; i++) {
  72. if (baud == baud_tbl[i].baud)
  73. return baud_tbl[i].new_brg;
  74. }
  75. return 0;
  76. }
  77. /* Perform SPI transfer for write/read of device register(s) */
  78. int max3107_rw(struct max3107_port *s, u8 *tx, u8 *rx, int len)
  79. {
  80. struct spi_message spi_msg;
  81. struct spi_transfer spi_xfer;
  82. /* Initialize SPI ,message */
  83. spi_message_init(&spi_msg);
  84. /* Initialize SPI transfer */
  85. memset(&spi_xfer, 0, sizeof spi_xfer);
  86. spi_xfer.len = len;
  87. spi_xfer.tx_buf = tx;
  88. spi_xfer.rx_buf = rx;
  89. spi_xfer.speed_hz = MAX3107_SPI_SPEED;
  90. /* Add SPI transfer to SPI message */
  91. spi_message_add_tail(&spi_xfer, &spi_msg);
  92. #ifdef DBG_TRACE_SPI_DATA
  93. {
  94. int i;
  95. pr_info("tx len %d:\n", spi_xfer.len);
  96. for (i = 0 ; i < spi_xfer.len && i < 32 ; i++)
  97. pr_info(" %x", ((u8 *)spi_xfer.tx_buf)[i]);
  98. pr_info("\n");
  99. }
  100. #endif
  101. /* Perform synchronous SPI transfer */
  102. if (spi_sync(s->spi, &spi_msg)) {
  103. dev_err(&s->spi->dev, "spi_sync failure\n");
  104. return -EIO;
  105. }
  106. #ifdef DBG_TRACE_SPI_DATA
  107. if (spi_xfer.rx_buf) {
  108. int i;
  109. pr_info("rx len %d:\n", spi_xfer.len);
  110. for (i = 0 ; i < spi_xfer.len && i < 32 ; i++)
  111. pr_info(" %x", ((u8 *)spi_xfer.rx_buf)[i]);
  112. pr_info("\n");
  113. }
  114. #endif
  115. return 0;
  116. }
  117. EXPORT_SYMBOL_GPL(max3107_rw);
  118. /* Puts received data to circular buffer */
  119. static void put_data_to_circ_buf(struct max3107_port *s, unsigned char *data,
  120. int len)
  121. {
  122. struct uart_port *port = &s->port;
  123. struct tty_struct *tty;
  124. if (!port->state)
  125. return;
  126. tty = port->state->port.tty;
  127. if (!tty)
  128. return;
  129. /* Insert received data */
  130. tty_insert_flip_string(tty, data, len);
  131. /* Update RX counter */
  132. port->icount.rx += len;
  133. }
  134. /* Handle data receiving */
  135. static void max3107_handlerx(struct max3107_port *s, u16 rxlvl)
  136. {
  137. int i;
  138. int j;
  139. int len; /* SPI transfer buffer length */
  140. u16 *buf;
  141. u8 *valid_str;
  142. if (!s->rx_enabled)
  143. /* RX is disabled */
  144. return;
  145. if (rxlvl == 0) {
  146. /* RX fifo is empty */
  147. return;
  148. } else if (rxlvl >= MAX3107_RX_FIFO_SIZE) {
  149. dev_warn(&s->spi->dev, "Possible RX FIFO overrun %d\n", rxlvl);
  150. /* Ensure sanity of RX level */
  151. rxlvl = MAX3107_RX_FIFO_SIZE;
  152. }
  153. if ((s->rxbuf == 0) || (s->rxstr == 0)) {
  154. dev_warn(&s->spi->dev, "Rx buffer/str isn't ready\n");
  155. return;
  156. }
  157. buf = s->rxbuf;
  158. valid_str = s->rxstr;
  159. while (rxlvl) {
  160. pr_debug("rxlvl %d\n", rxlvl);
  161. /* Clear buffer */
  162. memset(buf, 0, sizeof(u16) * (MAX3107_RX_FIFO_SIZE + 2));
  163. len = 0;
  164. if (s->irqen_reg & MAX3107_IRQ_RXFIFO_BIT) {
  165. /* First disable RX FIFO interrupt */
  166. pr_debug("Disabling RX INT\n");
  167. buf[0] = (MAX3107_WRITE_BIT | MAX3107_IRQEN_REG);
  168. s->irqen_reg &= ~MAX3107_IRQ_RXFIFO_BIT;
  169. buf[0] |= s->irqen_reg;
  170. len++;
  171. }
  172. /* Just increase the length by amount of words in FIFO since
  173. * buffer was zeroed and SPI transfer of 0x0000 means reading
  174. * from RX FIFO
  175. */
  176. len += rxlvl;
  177. /* Append RX level query */
  178. buf[len] = MAX3107_RXFIFOLVL_REG;
  179. len++;
  180. /* Perform the SPI transfer */
  181. if (max3107_rw(s, (u8 *)buf, (u8 *)buf, len * 2)) {
  182. dev_err(&s->spi->dev, "SPI transfer for RX h failed\n");
  183. return;
  184. }
  185. /* Skip RX FIFO interrupt disabling word if it was added */
  186. j = ((len - 1) - rxlvl);
  187. /* Read received words */
  188. for (i = 0; i < rxlvl; i++, j++)
  189. valid_str[i] = (u8)buf[j];
  190. put_data_to_circ_buf(s, valid_str, rxlvl);
  191. /* Get new RX level */
  192. rxlvl = (buf[len - 1] & MAX3107_SPI_RX_DATA_MASK);
  193. }
  194. if (s->rx_enabled) {
  195. /* RX still enabled, re-enable RX FIFO interrupt */
  196. pr_debug("Enabling RX INT\n");
  197. buf[0] = (MAX3107_WRITE_BIT | MAX3107_IRQEN_REG);
  198. s->irqen_reg |= MAX3107_IRQ_RXFIFO_BIT;
  199. buf[0] |= s->irqen_reg;
  200. if (max3107_rw(s, (u8 *)buf, NULL, 2))
  201. dev_err(&s->spi->dev, "RX FIFO INT enabling failed\n");
  202. }
  203. /* Push the received data to receivers */
  204. if (s->port.state->port.tty)
  205. tty_flip_buffer_push(s->port.state->port.tty);
  206. }
  207. /* Handle data sending */
  208. static void max3107_handletx(struct max3107_port *s)
  209. {
  210. struct circ_buf *xmit = &s->port.state->xmit;
  211. int i;
  212. unsigned long flags;
  213. int len; /* SPI transfer buffer length */
  214. u16 *buf;
  215. if (!s->tx_fifo_empty)
  216. /* Don't send more data before previous data is sent */
  217. return;
  218. if (uart_circ_empty(xmit) || uart_tx_stopped(&s->port))
  219. /* No data to send or TX is stopped */
  220. return;
  221. if (!s->txbuf) {
  222. dev_warn(&s->spi->dev, "Txbuf isn't ready\n");
  223. return;
  224. }
  225. buf = s->txbuf;
  226. /* Get length of data pending in circular buffer */
  227. len = uart_circ_chars_pending(xmit);
  228. if (len) {
  229. /* Limit to size of TX FIFO */
  230. if (len > MAX3107_TX_FIFO_SIZE)
  231. len = MAX3107_TX_FIFO_SIZE;
  232. pr_debug("txlen %d\n", len);
  233. /* Update TX counter */
  234. s->port.icount.tx += len;
  235. /* TX FIFO will no longer be empty */
  236. s->tx_fifo_empty = 0;
  237. i = 0;
  238. if (s->irqen_reg & MAX3107_IRQ_TXEMPTY_BIT) {
  239. /* First disable TX empty interrupt */
  240. pr_debug("Disabling TE INT\n");
  241. buf[i] = (MAX3107_WRITE_BIT | MAX3107_IRQEN_REG);
  242. s->irqen_reg &= ~MAX3107_IRQ_TXEMPTY_BIT;
  243. buf[i] |= s->irqen_reg;
  244. i++;
  245. len++;
  246. }
  247. /* Add data to send */
  248. spin_lock_irqsave(&s->port.lock, flags);
  249. for ( ; i < len ; i++) {
  250. buf[i] = (MAX3107_WRITE_BIT | MAX3107_THR_REG);
  251. buf[i] |= ((u16)xmit->buf[xmit->tail] &
  252. MAX3107_SPI_TX_DATA_MASK);
  253. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  254. }
  255. spin_unlock_irqrestore(&s->port.lock, flags);
  256. if (!(s->irqen_reg & MAX3107_IRQ_TXEMPTY_BIT)) {
  257. /* Enable TX empty interrupt */
  258. pr_debug("Enabling TE INT\n");
  259. buf[i] = (MAX3107_WRITE_BIT | MAX3107_IRQEN_REG);
  260. s->irqen_reg |= MAX3107_IRQ_TXEMPTY_BIT;
  261. buf[i] |= s->irqen_reg;
  262. i++;
  263. len++;
  264. }
  265. if (!s->tx_enabled) {
  266. /* Enable TX */
  267. pr_debug("Enable TX\n");
  268. buf[i] = (MAX3107_WRITE_BIT | MAX3107_MODE1_REG);
  269. spin_lock_irqsave(&s->data_lock, flags);
  270. s->mode1_reg &= ~MAX3107_MODE1_TXDIS_BIT;
  271. buf[i] |= s->mode1_reg;
  272. spin_unlock_irqrestore(&s->data_lock, flags);
  273. s->tx_enabled = 1;
  274. i++;
  275. len++;
  276. }
  277. /* Perform the SPI transfer */
  278. if (max3107_rw(s, (u8 *)buf, NULL, len*2)) {
  279. dev_err(&s->spi->dev,
  280. "SPI transfer TX handling failed\n");
  281. return;
  282. }
  283. }
  284. /* Indicate wake up if circular buffer is getting low on data */
  285. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  286. uart_write_wakeup(&s->port);
  287. }
  288. /* Handle interrupts
  289. * Also reads and returns current RX FIFO level
  290. */
  291. static u16 handle_interrupt(struct max3107_port *s)
  292. {
  293. u16 buf[4]; /* Buffer for SPI transfers */
  294. u8 irq_status;
  295. u16 rx_level;
  296. unsigned long flags;
  297. /* Read IRQ status register */
  298. buf[0] = MAX3107_IRQSTS_REG;
  299. /* Read status IRQ status register */
  300. buf[1] = MAX3107_STS_IRQSTS_REG;
  301. /* Read LSR IRQ status register */
  302. buf[2] = MAX3107_LSR_IRQSTS_REG;
  303. /* Query RX level */
  304. buf[3] = MAX3107_RXFIFOLVL_REG;
  305. if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 8)) {
  306. dev_err(&s->spi->dev,
  307. "SPI transfer for INTR handling failed\n");
  308. return 0;
  309. }
  310. irq_status = (u8)buf[0];
  311. pr_debug("IRQSTS %x\n", irq_status);
  312. rx_level = (buf[3] & MAX3107_SPI_RX_DATA_MASK);
  313. if (irq_status & MAX3107_IRQ_LSR_BIT) {
  314. /* LSR interrupt */
  315. if (buf[2] & MAX3107_LSR_RXTO_BIT)
  316. /* RX timeout interrupt,
  317. * handled by normal RX handling
  318. */
  319. pr_debug("RX TO INT\n");
  320. }
  321. if (irq_status & MAX3107_IRQ_TXEMPTY_BIT) {
  322. /* Tx empty interrupt,
  323. * disable TX and set tx_fifo_empty flag
  324. */
  325. pr_debug("TE INT, disabling TX\n");
  326. buf[0] = (MAX3107_WRITE_BIT | MAX3107_MODE1_REG);
  327. spin_lock_irqsave(&s->data_lock, flags);
  328. s->mode1_reg |= MAX3107_MODE1_TXDIS_BIT;
  329. buf[0] |= s->mode1_reg;
  330. spin_unlock_irqrestore(&s->data_lock, flags);
  331. if (max3107_rw(s, (u8 *)buf, NULL, 2))
  332. dev_err(&s->spi->dev, "SPI transfer TX dis failed\n");
  333. s->tx_enabled = 0;
  334. s->tx_fifo_empty = 1;
  335. }
  336. if (irq_status & MAX3107_IRQ_RXFIFO_BIT)
  337. /* RX FIFO interrupt,
  338. * handled by normal RX handling
  339. */
  340. pr_debug("RFIFO INT\n");
  341. /* Return RX level */
  342. return rx_level;
  343. }
  344. /* Trigger work thread*/
  345. static void max3107_dowork(struct max3107_port *s)
  346. {
  347. if (!work_pending(&s->work) && !freezing(current) && !s->suspended)
  348. queue_work(s->workqueue, &s->work);
  349. else
  350. dev_warn(&s->spi->dev, "interrup isn't serviced normally!\n");
  351. }
  352. /* Work thread */
  353. static void max3107_work(struct work_struct *w)
  354. {
  355. struct max3107_port *s = container_of(w, struct max3107_port, work);
  356. u16 rxlvl = 0;
  357. int len; /* SPI transfer buffer length */
  358. u16 buf[5]; /* Buffer for SPI transfers */
  359. unsigned long flags;
  360. /* Start by reading current RX FIFO level */
  361. buf[0] = MAX3107_RXFIFOLVL_REG;
  362. if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 2)) {
  363. dev_err(&s->spi->dev, "SPI transfer RX lev failed\n");
  364. rxlvl = 0;
  365. } else {
  366. rxlvl = (buf[0] & MAX3107_SPI_RX_DATA_MASK);
  367. }
  368. do {
  369. pr_debug("rxlvl %d\n", rxlvl);
  370. /* Handle RX */
  371. max3107_handlerx(s, rxlvl);
  372. rxlvl = 0;
  373. if (s->handle_irq) {
  374. /* Handle pending interrupts
  375. * We also get new RX FIFO level since new data may
  376. * have been received while pushing received data to
  377. * receivers
  378. */
  379. s->handle_irq = 0;
  380. rxlvl = handle_interrupt(s);
  381. }
  382. /* Handle TX */
  383. max3107_handletx(s);
  384. /* Handle configuration changes */
  385. len = 0;
  386. spin_lock_irqsave(&s->data_lock, flags);
  387. if (s->mode1_commit) {
  388. pr_debug("mode1_commit\n");
  389. buf[len] = (MAX3107_WRITE_BIT | MAX3107_MODE1_REG);
  390. buf[len++] |= s->mode1_reg;
  391. s->mode1_commit = 0;
  392. }
  393. if (s->lcr_commit) {
  394. pr_debug("lcr_commit\n");
  395. buf[len] = (MAX3107_WRITE_BIT | MAX3107_LCR_REG);
  396. buf[len++] |= s->lcr_reg;
  397. s->lcr_commit = 0;
  398. }
  399. if (s->brg_commit) {
  400. pr_debug("brg_commit\n");
  401. buf[len] = (MAX3107_WRITE_BIT | MAX3107_BRGDIVMSB_REG);
  402. buf[len++] |= ((s->brg_cfg >> 16) &
  403. MAX3107_SPI_TX_DATA_MASK);
  404. buf[len] = (MAX3107_WRITE_BIT | MAX3107_BRGDIVLSB_REG);
  405. buf[len++] |= ((s->brg_cfg >> 8) &
  406. MAX3107_SPI_TX_DATA_MASK);
  407. buf[len] = (MAX3107_WRITE_BIT | MAX3107_BRGCFG_REG);
  408. buf[len++] |= ((s->brg_cfg) & 0xff);
  409. s->brg_commit = 0;
  410. }
  411. spin_unlock_irqrestore(&s->data_lock, flags);
  412. if (len > 0) {
  413. if (max3107_rw(s, (u8 *)buf, NULL, len * 2))
  414. dev_err(&s->spi->dev,
  415. "SPI transfer config failed\n");
  416. }
  417. /* Reloop if interrupt handling indicated data in RX FIFO */
  418. } while (rxlvl);
  419. }
  420. /* Set sleep mode */
  421. static void max3107_set_sleep(struct max3107_port *s, int mode)
  422. {
  423. u16 buf[1]; /* Buffer for SPI transfer */
  424. unsigned long flags;
  425. pr_debug("enter, mode %d\n", mode);
  426. buf[0] = (MAX3107_WRITE_BIT | MAX3107_MODE1_REG);
  427. spin_lock_irqsave(&s->data_lock, flags);
  428. switch (mode) {
  429. case MAX3107_DISABLE_FORCED_SLEEP:
  430. s->mode1_reg &= ~MAX3107_MODE1_FORCESLEEP_BIT;
  431. break;
  432. case MAX3107_ENABLE_FORCED_SLEEP:
  433. s->mode1_reg |= MAX3107_MODE1_FORCESLEEP_BIT;
  434. break;
  435. case MAX3107_DISABLE_AUTOSLEEP:
  436. s->mode1_reg &= ~MAX3107_MODE1_AUTOSLEEP_BIT;
  437. break;
  438. case MAX3107_ENABLE_AUTOSLEEP:
  439. s->mode1_reg |= MAX3107_MODE1_AUTOSLEEP_BIT;
  440. break;
  441. default:
  442. spin_unlock_irqrestore(&s->data_lock, flags);
  443. dev_warn(&s->spi->dev, "invalid sleep mode\n");
  444. return;
  445. }
  446. buf[0] |= s->mode1_reg;
  447. spin_unlock_irqrestore(&s->data_lock, flags);
  448. if (max3107_rw(s, (u8 *)buf, NULL, 2))
  449. dev_err(&s->spi->dev, "SPI transfer sleep mode failed\n");
  450. if (mode == MAX3107_DISABLE_AUTOSLEEP ||
  451. mode == MAX3107_DISABLE_FORCED_SLEEP)
  452. msleep(MAX3107_WAKEUP_DELAY);
  453. }
  454. /* Perform full register initialization */
  455. static void max3107_register_init(struct max3107_port *s)
  456. {
  457. u16 buf[11]; /* Buffer for SPI transfers */
  458. /* 1. Configure baud rate, 9600 as default */
  459. s->baud = 9600;
  460. /* the below is default*/
  461. if (s->ext_clk) {
  462. s->brg_cfg = MAX3107_BRG26_B9600;
  463. s->baud_tbl = (struct baud_table *)brg26_ext;
  464. } else {
  465. s->brg_cfg = MAX3107_BRG13_IB9600;
  466. s->baud_tbl = (struct baud_table *)brg13_int;
  467. }
  468. if (s->pdata->init)
  469. s->pdata->init(s);
  470. buf[0] = (MAX3107_WRITE_BIT | MAX3107_BRGDIVMSB_REG)
  471. | ((s->brg_cfg >> 16) & MAX3107_SPI_TX_DATA_MASK);
  472. buf[1] = (MAX3107_WRITE_BIT | MAX3107_BRGDIVLSB_REG)
  473. | ((s->brg_cfg >> 8) & MAX3107_SPI_TX_DATA_MASK);
  474. buf[2] = (MAX3107_WRITE_BIT | MAX3107_BRGCFG_REG)
  475. | ((s->brg_cfg) & 0xff);
  476. /* 2. Configure LCR register, 8N1 mode by default */
  477. s->lcr_reg = MAX3107_LCR_WORD_LEN_8;
  478. buf[3] = (MAX3107_WRITE_BIT | MAX3107_LCR_REG)
  479. | s->lcr_reg;
  480. /* 3. Configure MODE 1 register */
  481. s->mode1_reg = 0;
  482. /* Enable IRQ pin */
  483. s->mode1_reg |= MAX3107_MODE1_IRQSEL_BIT;
  484. /* Disable TX */
  485. s->mode1_reg |= MAX3107_MODE1_TXDIS_BIT;
  486. s->tx_enabled = 0;
  487. /* RX is enabled */
  488. s->rx_enabled = 1;
  489. buf[4] = (MAX3107_WRITE_BIT | MAX3107_MODE1_REG)
  490. | s->mode1_reg;
  491. /* 4. Configure MODE 2 register */
  492. buf[5] = (MAX3107_WRITE_BIT | MAX3107_MODE2_REG);
  493. if (s->loopback) {
  494. /* Enable loopback */
  495. buf[5] |= MAX3107_MODE2_LOOPBACK_BIT;
  496. }
  497. /* Reset FIFOs */
  498. buf[5] |= MAX3107_MODE2_FIFORST_BIT;
  499. s->tx_fifo_empty = 1;
  500. /* 5. Configure FIFO trigger level register */
  501. buf[6] = (MAX3107_WRITE_BIT | MAX3107_FIFOTRIGLVL_REG);
  502. /* RX FIFO trigger for 16 words, TX FIFO trigger not used */
  503. buf[6] |= (MAX3107_FIFOTRIGLVL_RX(16) | MAX3107_FIFOTRIGLVL_TX(0));
  504. /* 6. Configure flow control levels */
  505. buf[7] = (MAX3107_WRITE_BIT | MAX3107_FLOWLVL_REG);
  506. /* Flow control halt level 96, resume level 48 */
  507. buf[7] |= (MAX3107_FLOWLVL_RES(48) | MAX3107_FLOWLVL_HALT(96));
  508. /* 7. Configure flow control */
  509. buf[8] = (MAX3107_WRITE_BIT | MAX3107_FLOWCTRL_REG);
  510. /* Enable auto CTS and auto RTS flow control */
  511. buf[8] |= (MAX3107_FLOWCTRL_AUTOCTS_BIT | MAX3107_FLOWCTRL_AUTORTS_BIT);
  512. /* 8. Configure RX timeout register */
  513. buf[9] = (MAX3107_WRITE_BIT | MAX3107_RXTO_REG);
  514. /* Timeout after 48 character intervals */
  515. buf[9] |= 0x0030;
  516. /* 9. Configure LSR interrupt enable register */
  517. buf[10] = (MAX3107_WRITE_BIT | MAX3107_LSR_IRQEN_REG);
  518. /* Enable RX timeout interrupt */
  519. buf[10] |= MAX3107_LSR_RXTO_BIT;
  520. /* Perform SPI transfer */
  521. if (max3107_rw(s, (u8 *)buf, NULL, 22))
  522. dev_err(&s->spi->dev, "SPI transfer for init failed\n");
  523. /* 10. Clear IRQ status register by reading it */
  524. buf[0] = MAX3107_IRQSTS_REG;
  525. /* 11. Configure interrupt enable register */
  526. /* Enable LSR interrupt */
  527. s->irqen_reg = MAX3107_IRQ_LSR_BIT;
  528. /* Enable RX FIFO interrupt */
  529. s->irqen_reg |= MAX3107_IRQ_RXFIFO_BIT;
  530. buf[1] = (MAX3107_WRITE_BIT | MAX3107_IRQEN_REG)
  531. | s->irqen_reg;
  532. /* 12. Clear FIFO reset that was set in step 6 */
  533. buf[2] = (MAX3107_WRITE_BIT | MAX3107_MODE2_REG);
  534. if (s->loopback) {
  535. /* Keep loopback enabled */
  536. buf[2] |= MAX3107_MODE2_LOOPBACK_BIT;
  537. }
  538. /* Perform SPI transfer */
  539. if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 6))
  540. dev_err(&s->spi->dev, "SPI transfer for init failed\n");
  541. }
  542. /* IRQ handler */
  543. static irqreturn_t max3107_irq(int irqno, void *dev_id)
  544. {
  545. struct max3107_port *s = dev_id;
  546. if (irqno != s->spi->irq) {
  547. /* Unexpected IRQ */
  548. return IRQ_NONE;
  549. }
  550. /* Indicate irq */
  551. s->handle_irq = 1;
  552. /* Trigger work thread */
  553. max3107_dowork(s);
  554. return IRQ_HANDLED;
  555. }
  556. /* HW suspension function
  557. *
  558. * Currently autosleep is used to decrease current consumption, alternative
  559. * approach would be to set the chip to reset mode if UART is not being
  560. * used but that would mess the GPIOs
  561. *
  562. */
  563. void max3107_hw_susp(struct max3107_port *s, int suspend)
  564. {
  565. pr_debug("enter, suspend %d\n", suspend);
  566. if (suspend) {
  567. /* Suspend requested,
  568. * enable autosleep to decrease current consumption
  569. */
  570. s->suspended = 1;
  571. max3107_set_sleep(s, MAX3107_ENABLE_AUTOSLEEP);
  572. } else {
  573. /* Resume requested,
  574. * disable autosleep
  575. */
  576. s->suspended = 0;
  577. max3107_set_sleep(s, MAX3107_DISABLE_AUTOSLEEP);
  578. }
  579. }
  580. EXPORT_SYMBOL_GPL(max3107_hw_susp);
  581. /* Modem status IRQ enabling */
  582. static void max3107_enable_ms(struct uart_port *port)
  583. {
  584. /* Modem status not supported */
  585. }
  586. /* Data send function */
  587. static void max3107_start_tx(struct uart_port *port)
  588. {
  589. struct max3107_port *s = container_of(port, struct max3107_port, port);
  590. /* Trigger work thread for sending data */
  591. max3107_dowork(s);
  592. }
  593. /* Function for checking that there is no pending transfers */
  594. static unsigned int max3107_tx_empty(struct uart_port *port)
  595. {
  596. struct max3107_port *s = container_of(port, struct max3107_port, port);
  597. pr_debug("returning %d\n",
  598. (s->tx_fifo_empty && uart_circ_empty(&s->port.state->xmit)));
  599. return s->tx_fifo_empty && uart_circ_empty(&s->port.state->xmit);
  600. }
  601. /* Function for stopping RX */
  602. static void max3107_stop_rx(struct uart_port *port)
  603. {
  604. struct max3107_port *s = container_of(port, struct max3107_port, port);
  605. unsigned long flags;
  606. /* Set RX disabled in MODE 1 register */
  607. spin_lock_irqsave(&s->data_lock, flags);
  608. s->mode1_reg |= MAX3107_MODE1_RXDIS_BIT;
  609. s->mode1_commit = 1;
  610. spin_unlock_irqrestore(&s->data_lock, flags);
  611. /* Set RX disabled */
  612. s->rx_enabled = 0;
  613. /* Trigger work thread for doing the actual configuration change */
  614. max3107_dowork(s);
  615. }
  616. /* Function for returning control pin states */
  617. static unsigned int max3107_get_mctrl(struct uart_port *port)
  618. {
  619. /* DCD and DSR are not wired and CTS/RTS is handled automatically
  620. * so just indicate DSR and CAR asserted
  621. */
  622. return TIOCM_DSR | TIOCM_CAR;
  623. }
  624. /* Function for setting control pin states */
  625. static void max3107_set_mctrl(struct uart_port *port, unsigned int mctrl)
  626. {
  627. /* DCD and DSR are not wired and CTS/RTS is hadnled automatically
  628. * so do nothing
  629. */
  630. }
  631. /* Function for configuring UART parameters */
  632. static void max3107_set_termios(struct uart_port *port,
  633. struct ktermios *termios,
  634. struct ktermios *old)
  635. {
  636. struct max3107_port *s = container_of(port, struct max3107_port, port);
  637. struct tty_struct *tty;
  638. int baud;
  639. u16 new_lcr = 0;
  640. u32 new_brg = 0;
  641. unsigned long flags;
  642. if (!port->state)
  643. return;
  644. tty = port->state->port.tty;
  645. if (!tty)
  646. return;
  647. /* Get new LCR register values */
  648. /* Word size */
  649. if ((termios->c_cflag & CSIZE) == CS7)
  650. new_lcr |= MAX3107_LCR_WORD_LEN_7;
  651. else
  652. new_lcr |= MAX3107_LCR_WORD_LEN_8;
  653. /* Parity */
  654. if (termios->c_cflag & PARENB) {
  655. new_lcr |= MAX3107_LCR_PARITY_BIT;
  656. if (!(termios->c_cflag & PARODD))
  657. new_lcr |= MAX3107_LCR_EVENPARITY_BIT;
  658. }
  659. /* Stop bits */
  660. if (termios->c_cflag & CSTOPB) {
  661. /* 2 stop bits */
  662. new_lcr |= MAX3107_LCR_STOPLEN_BIT;
  663. }
  664. /* Mask termios capabilities we don't support */
  665. termios->c_cflag &= ~CMSPAR;
  666. /* Set status ignore mask */
  667. s->port.ignore_status_mask = 0;
  668. if (termios->c_iflag & IGNPAR)
  669. s->port.ignore_status_mask |= MAX3107_ALL_ERRORS;
  670. /* Set low latency to immediately handle pushed data */
  671. s->port.state->port.tty->low_latency = 1;
  672. /* Get new baud rate generator configuration */
  673. baud = tty_get_baud_rate(tty);
  674. spin_lock_irqsave(&s->data_lock, flags);
  675. new_brg = get_new_brg(baud, s);
  676. /* if can't find the corrent config, use previous */
  677. if (!new_brg) {
  678. baud = s->baud;
  679. new_brg = s->brg_cfg;
  680. }
  681. spin_unlock_irqrestore(&s->data_lock, flags);
  682. tty_termios_encode_baud_rate(termios, baud, baud);
  683. s->baud = baud;
  684. /* Update timeout according to new baud rate */
  685. uart_update_timeout(port, termios->c_cflag, baud);
  686. spin_lock_irqsave(&s->data_lock, flags);
  687. if (s->lcr_reg != new_lcr) {
  688. s->lcr_reg = new_lcr;
  689. s->lcr_commit = 1;
  690. }
  691. if (s->brg_cfg != new_brg) {
  692. s->brg_cfg = new_brg;
  693. s->brg_commit = 1;
  694. }
  695. spin_unlock_irqrestore(&s->data_lock, flags);
  696. /* Trigger work thread for doing the actual configuration change */
  697. max3107_dowork(s);
  698. }
  699. /* Port shutdown function */
  700. static void max3107_shutdown(struct uart_port *port)
  701. {
  702. struct max3107_port *s = container_of(port, struct max3107_port, port);
  703. if (s->suspended && s->pdata->hw_suspend)
  704. s->pdata->hw_suspend(s, 0);
  705. /* Free the interrupt */
  706. free_irq(s->spi->irq, s);
  707. if (s->workqueue) {
  708. /* Flush and destroy work queue */
  709. flush_workqueue(s->workqueue);
  710. destroy_workqueue(s->workqueue);
  711. s->workqueue = NULL;
  712. }
  713. /* Suspend HW */
  714. if (s->pdata->hw_suspend)
  715. s->pdata->hw_suspend(s, 1);
  716. }
  717. /* Port startup function */
  718. static int max3107_startup(struct uart_port *port)
  719. {
  720. struct max3107_port *s = container_of(port, struct max3107_port, port);
  721. /* Initialize work queue */
  722. s->workqueue = create_freezeable_workqueue("max3107");
  723. if (!s->workqueue) {
  724. dev_err(&s->spi->dev, "Workqueue creation failed\n");
  725. return -EBUSY;
  726. }
  727. INIT_WORK(&s->work, max3107_work);
  728. /* Setup IRQ */
  729. if (request_irq(s->spi->irq, max3107_irq, IRQF_TRIGGER_FALLING,
  730. "max3107", s)) {
  731. dev_err(&s->spi->dev, "IRQ reguest failed\n");
  732. destroy_workqueue(s->workqueue);
  733. s->workqueue = NULL;
  734. return -EBUSY;
  735. }
  736. /* Resume HW */
  737. if (s->pdata->hw_suspend)
  738. s->pdata->hw_suspend(s, 0);
  739. /* Init registers */
  740. max3107_register_init(s);
  741. return 0;
  742. }
  743. /* Port type function */
  744. static const char *max3107_type(struct uart_port *port)
  745. {
  746. struct max3107_port *s = container_of(port, struct max3107_port, port);
  747. return s->spi->modalias;
  748. }
  749. /* Port release function */
  750. static void max3107_release_port(struct uart_port *port)
  751. {
  752. /* Do nothing */
  753. }
  754. /* Port request function */
  755. static int max3107_request_port(struct uart_port *port)
  756. {
  757. /* Do nothing */
  758. return 0;
  759. }
  760. /* Port config function */
  761. static void max3107_config_port(struct uart_port *port, int flags)
  762. {
  763. struct max3107_port *s = container_of(port, struct max3107_port, port);
  764. s->port.type = PORT_MAX3107;
  765. }
  766. /* Port verify function */
  767. static int max3107_verify_port(struct uart_port *port,
  768. struct serial_struct *ser)
  769. {
  770. if (ser->type == PORT_UNKNOWN || ser->type == PORT_MAX3107)
  771. return 0;
  772. return -EINVAL;
  773. }
  774. /* Port stop TX function */
  775. static void max3107_stop_tx(struct uart_port *port)
  776. {
  777. /* Do nothing */
  778. }
  779. /* Port break control function */
  780. static void max3107_break_ctl(struct uart_port *port, int break_state)
  781. {
  782. /* We don't support break control, do nothing */
  783. }
  784. /* Port functions */
  785. static struct uart_ops max3107_ops = {
  786. .tx_empty = max3107_tx_empty,
  787. .set_mctrl = max3107_set_mctrl,
  788. .get_mctrl = max3107_get_mctrl,
  789. .stop_tx = max3107_stop_tx,
  790. .start_tx = max3107_start_tx,
  791. .stop_rx = max3107_stop_rx,
  792. .enable_ms = max3107_enable_ms,
  793. .break_ctl = max3107_break_ctl,
  794. .startup = max3107_startup,
  795. .shutdown = max3107_shutdown,
  796. .set_termios = max3107_set_termios,
  797. .type = max3107_type,
  798. .release_port = max3107_release_port,
  799. .request_port = max3107_request_port,
  800. .config_port = max3107_config_port,
  801. .verify_port = max3107_verify_port,
  802. };
  803. /* UART driver data */
  804. static struct uart_driver max3107_uart_driver = {
  805. .owner = THIS_MODULE,
  806. .driver_name = "ttyMAX",
  807. .dev_name = "ttyMAX",
  808. .nr = 1,
  809. };
  810. static int driver_registered = 0;
  811. /* 'Generic' platform data */
  812. static struct max3107_plat generic_plat_data = {
  813. .loopback = 0,
  814. .ext_clk = 1,
  815. .hw_suspend = max3107_hw_susp,
  816. .polled_mode = 0,
  817. .poll_time = 0,
  818. };
  819. /*******************************************************************/
  820. /**
  821. * max3107_probe - SPI bus probe entry point
  822. * @spi: the spi device
  823. *
  824. * SPI wants us to probe this device and if appropriate claim it.
  825. * Perform any platform specific requirements and then initialise
  826. * the device.
  827. */
  828. int max3107_probe(struct spi_device *spi, struct max3107_plat *pdata)
  829. {
  830. struct max3107_port *s;
  831. u16 buf[2]; /* Buffer for SPI transfers */
  832. int retval;
  833. pr_info("enter max3107 probe\n");
  834. /* Allocate port structure */
  835. s = kzalloc(sizeof(*s), GFP_KERNEL);
  836. if (!s) {
  837. pr_err("Allocating port structure failed\n");
  838. return -ENOMEM;
  839. }
  840. s->pdata = pdata;
  841. /* SPI Rx buffer
  842. * +2 for RX FIFO interrupt
  843. * disabling and RX level query
  844. */
  845. s->rxbuf = kzalloc(sizeof(u16) * (MAX3107_RX_FIFO_SIZE+2), GFP_KERNEL);
  846. if (!s->rxbuf) {
  847. pr_err("Allocating RX buffer failed\n");
  848. return -ENOMEM;
  849. }
  850. s->rxstr = kzalloc(sizeof(u8) * MAX3107_RX_FIFO_SIZE, GFP_KERNEL);
  851. if (!s->rxstr) {
  852. pr_err("Allocating RX buffer failed\n");
  853. return -ENOMEM;
  854. }
  855. /* SPI Tx buffer
  856. * SPI transfer buffer
  857. * +3 for TX FIFO empty
  858. * interrupt disabling and
  859. * enabling and TX enabling
  860. */
  861. s->txbuf = kzalloc(sizeof(u16) * MAX3107_TX_FIFO_SIZE + 3, GFP_KERNEL);
  862. if (!s->txbuf) {
  863. pr_err("Allocating TX buffer failed\n");
  864. return -ENOMEM;
  865. }
  866. /* Initialize shared data lock */
  867. spin_lock_init(&s->data_lock);
  868. /* SPI intializations */
  869. dev_set_drvdata(&spi->dev, s);
  870. spi->mode = SPI_MODE_0;
  871. spi->dev.platform_data = pdata;
  872. spi->bits_per_word = 16;
  873. s->ext_clk = pdata->ext_clk;
  874. s->loopback = pdata->loopback;
  875. spi_setup(spi);
  876. s->spi = spi;
  877. /* Check REV ID to ensure we are talking to what we expect */
  878. buf[0] = MAX3107_REVID_REG;
  879. if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 2)) {
  880. dev_err(&s->spi->dev, "SPI transfer for REVID read failed\n");
  881. return -EIO;
  882. }
  883. if ((buf[0] & MAX3107_SPI_RX_DATA_MASK) != MAX3107_REVID1 &&
  884. (buf[0] & MAX3107_SPI_RX_DATA_MASK) != MAX3107_REVID2) {
  885. dev_err(&s->spi->dev, "REVID %x does not match\n",
  886. (buf[0] & MAX3107_SPI_RX_DATA_MASK));
  887. return -ENODEV;
  888. }
  889. /* Disable all interrupts */
  890. buf[0] = (MAX3107_WRITE_BIT | MAX3107_IRQEN_REG | 0x0000);
  891. buf[0] |= 0x0000;
  892. /* Configure clock source */
  893. buf[1] = (MAX3107_WRITE_BIT | MAX3107_CLKSRC_REG);
  894. if (s->ext_clk) {
  895. /* External clock */
  896. buf[1] |= MAX3107_CLKSRC_EXTCLK_BIT;
  897. }
  898. /* PLL bypass ON */
  899. buf[1] |= MAX3107_CLKSRC_PLLBYP_BIT;
  900. /* Perform SPI transfer */
  901. if (max3107_rw(s, (u8 *)buf, NULL, 4)) {
  902. dev_err(&s->spi->dev, "SPI transfer for init failed\n");
  903. return -EIO;
  904. }
  905. /* Register UART driver */
  906. if (!driver_registered) {
  907. retval = uart_register_driver(&max3107_uart_driver);
  908. if (retval) {
  909. dev_err(&s->spi->dev, "Registering UART driver failed\n");
  910. return retval;
  911. }
  912. driver_registered = 1;
  913. }
  914. /* Initialize UART port data */
  915. s->port.fifosize = 128;
  916. s->port.ops = &max3107_ops;
  917. s->port.line = 0;
  918. s->port.dev = &spi->dev;
  919. s->port.uartclk = 9600;
  920. s->port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
  921. s->port.irq = s->spi->irq;
  922. s->port.type = PORT_MAX3107;
  923. /* Add UART port */
  924. retval = uart_add_one_port(&max3107_uart_driver, &s->port);
  925. if (retval < 0) {
  926. dev_err(&s->spi->dev, "Adding UART port failed\n");
  927. return retval;
  928. }
  929. if (pdata->configure) {
  930. retval = pdata->configure(s);
  931. if (retval < 0)
  932. return retval;
  933. }
  934. /* Go to suspend mode */
  935. if (pdata->hw_suspend)
  936. pdata->hw_suspend(s, 1);
  937. return 0;
  938. }
  939. EXPORT_SYMBOL_GPL(max3107_probe);
  940. /* Driver remove function */
  941. int max3107_remove(struct spi_device *spi)
  942. {
  943. struct max3107_port *s = dev_get_drvdata(&spi->dev);
  944. pr_info("enter max3107 remove\n");
  945. /* Remove port */
  946. if (uart_remove_one_port(&max3107_uart_driver, &s->port))
  947. dev_warn(&s->spi->dev, "Removing UART port failed\n");
  948. /* Free TxRx buffer */
  949. kfree(s->rxbuf);
  950. kfree(s->rxstr);
  951. kfree(s->txbuf);
  952. /* Free port structure */
  953. kfree(s);
  954. return 0;
  955. }
  956. EXPORT_SYMBOL_GPL(max3107_remove);
  957. /* Driver suspend function */
  958. int max3107_suspend(struct spi_device *spi, pm_message_t state)
  959. {
  960. #ifdef CONFIG_PM
  961. struct max3107_port *s = dev_get_drvdata(&spi->dev);
  962. pr_debug("enter suspend\n");
  963. /* Suspend UART port */
  964. uart_suspend_port(&max3107_uart_driver, &s->port);
  965. /* Go to suspend mode */
  966. if (s->pdata->hw_suspend)
  967. s->pdata->hw_suspend(s, 1);
  968. #endif /* CONFIG_PM */
  969. return 0;
  970. }
  971. EXPORT_SYMBOL_GPL(max3107_suspend);
  972. /* Driver resume function */
  973. int max3107_resume(struct spi_device *spi)
  974. {
  975. #ifdef CONFIG_PM
  976. struct max3107_port *s = dev_get_drvdata(&spi->dev);
  977. pr_debug("enter resume\n");
  978. /* Resume from suspend */
  979. if (s->pdata->hw_suspend)
  980. s->pdata->hw_suspend(s, 0);
  981. /* Resume UART port */
  982. uart_resume_port(&max3107_uart_driver, &s->port);
  983. #endif /* CONFIG_PM */
  984. return 0;
  985. }
  986. EXPORT_SYMBOL_GPL(max3107_resume);
  987. static int max3107_probe_generic(struct spi_device *spi)
  988. {
  989. return max3107_probe(spi, &generic_plat_data);
  990. }
  991. /* Spi driver data */
  992. static struct spi_driver max3107_driver = {
  993. .driver = {
  994. .name = "max3107",
  995. .bus = &spi_bus_type,
  996. .owner = THIS_MODULE,
  997. },
  998. .probe = max3107_probe_generic,
  999. .remove = __devexit_p(max3107_remove),
  1000. .suspend = max3107_suspend,
  1001. .resume = max3107_resume,
  1002. };
  1003. /* Driver init function */
  1004. static int __init max3107_init(void)
  1005. {
  1006. pr_info("enter max3107 init\n");
  1007. return spi_register_driver(&max3107_driver);
  1008. }
  1009. /* Driver exit function */
  1010. static void __exit max3107_exit(void)
  1011. {
  1012. pr_info("enter max3107 exit\n");
  1013. /* Unregister UART driver */
  1014. if (driver_registered)
  1015. uart_unregister_driver(&max3107_uart_driver);
  1016. spi_unregister_driver(&max3107_driver);
  1017. }
  1018. module_init(max3107_init);
  1019. module_exit(max3107_exit);
  1020. MODULE_DESCRIPTION("MAX3107 driver");
  1021. MODULE_AUTHOR("Aavamobile");
  1022. MODULE_ALIAS("max3107-spi");
  1023. MODULE_LICENSE("GPL v2");