btuart_cs.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. /*
  2. *
  3. * Driver for Bluetooth PCMCIA cards with HCI UART interface
  4. *
  5. * Copyright (C) 2001-2002 Marcel Holtmann <marcel@holtmann.org>
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation;
  11. *
  12. * Software distributed under the License is distributed on an "AS
  13. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  14. * implied. See the License for the specific language governing
  15. * rights and limitations under the License.
  16. *
  17. * The initial developer of the original code is David A. Hinds
  18. * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
  19. * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
  20. *
  21. */
  22. #include <linux/module.h>
  23. #include <linux/kernel.h>
  24. #include <linux/init.h>
  25. #include <linux/slab.h>
  26. #include <linux/types.h>
  27. #include <linux/delay.h>
  28. #include <linux/errno.h>
  29. #include <linux/ptrace.h>
  30. #include <linux/ioport.h>
  31. #include <linux/spinlock.h>
  32. #include <linux/moduleparam.h>
  33. #include <linux/skbuff.h>
  34. #include <linux/string.h>
  35. #include <linux/serial.h>
  36. #include <linux/serial_reg.h>
  37. #include <linux/bitops.h>
  38. #include <asm/system.h>
  39. #include <asm/io.h>
  40. #include <pcmcia/cs_types.h>
  41. #include <pcmcia/cs.h>
  42. #include <pcmcia/cistpl.h>
  43. #include <pcmcia/ciscode.h>
  44. #include <pcmcia/ds.h>
  45. #include <pcmcia/cisreg.h>
  46. #include <net/bluetooth/bluetooth.h>
  47. #include <net/bluetooth/hci_core.h>
  48. /* ======================== Module parameters ======================== */
  49. MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
  50. MODULE_DESCRIPTION("Bluetooth driver for Bluetooth PCMCIA cards with HCI UART interface");
  51. MODULE_LICENSE("GPL");
  52. /* ======================== Local structures ======================== */
  53. typedef struct btuart_info_t {
  54. struct pcmcia_device *p_dev;
  55. dev_node_t node;
  56. struct hci_dev *hdev;
  57. spinlock_t lock; /* For serializing operations */
  58. struct sk_buff_head txq;
  59. unsigned long tx_state;
  60. unsigned long rx_state;
  61. unsigned long rx_count;
  62. struct sk_buff *rx_skb;
  63. } btuart_info_t;
  64. static int btuart_config(struct pcmcia_device *link);
  65. static void btuart_release(struct pcmcia_device *link);
  66. static void btuart_detach(struct pcmcia_device *p_dev);
  67. /* Maximum baud rate */
  68. #define SPEED_MAX 115200
  69. /* Default baud rate: 57600, 115200, 230400 or 460800 */
  70. #define DEFAULT_BAUD_RATE 115200
  71. /* Transmit states */
  72. #define XMIT_SENDING 1
  73. #define XMIT_WAKEUP 2
  74. #define XMIT_WAITING 8
  75. /* Receiver states */
  76. #define RECV_WAIT_PACKET_TYPE 0
  77. #define RECV_WAIT_EVENT_HEADER 1
  78. #define RECV_WAIT_ACL_HEADER 2
  79. #define RECV_WAIT_SCO_HEADER 3
  80. #define RECV_WAIT_DATA 4
  81. /* ======================== Interrupt handling ======================== */
  82. static int btuart_write(unsigned int iobase, int fifo_size, __u8 *buf, int len)
  83. {
  84. int actual = 0;
  85. /* Tx FIFO should be empty */
  86. if (!(inb(iobase + UART_LSR) & UART_LSR_THRE))
  87. return 0;
  88. /* Fill FIFO with current frame */
  89. while ((fifo_size-- > 0) && (actual < len)) {
  90. /* Transmit next byte */
  91. outb(buf[actual], iobase + UART_TX);
  92. actual++;
  93. }
  94. return actual;
  95. }
  96. static void btuart_write_wakeup(btuart_info_t *info)
  97. {
  98. if (!info) {
  99. BT_ERR("Unknown device");
  100. return;
  101. }
  102. if (test_and_set_bit(XMIT_SENDING, &(info->tx_state))) {
  103. set_bit(XMIT_WAKEUP, &(info->tx_state));
  104. return;
  105. }
  106. do {
  107. register unsigned int iobase = info->p_dev->io.BasePort1;
  108. register struct sk_buff *skb;
  109. register int len;
  110. clear_bit(XMIT_WAKEUP, &(info->tx_state));
  111. if (!pcmcia_dev_present(info->p_dev))
  112. return;
  113. if (!(skb = skb_dequeue(&(info->txq))))
  114. break;
  115. /* Send frame */
  116. len = btuart_write(iobase, 16, skb->data, skb->len);
  117. set_bit(XMIT_WAKEUP, &(info->tx_state));
  118. if (len == skb->len) {
  119. kfree_skb(skb);
  120. } else {
  121. skb_pull(skb, len);
  122. skb_queue_head(&(info->txq), skb);
  123. }
  124. info->hdev->stat.byte_tx += len;
  125. } while (test_bit(XMIT_WAKEUP, &(info->tx_state)));
  126. clear_bit(XMIT_SENDING, &(info->tx_state));
  127. }
  128. static void btuart_receive(btuart_info_t *info)
  129. {
  130. unsigned int iobase;
  131. int boguscount = 0;
  132. if (!info) {
  133. BT_ERR("Unknown device");
  134. return;
  135. }
  136. iobase = info->p_dev->io.BasePort1;
  137. do {
  138. info->hdev->stat.byte_rx++;
  139. /* Allocate packet */
  140. if (info->rx_skb == NULL) {
  141. info->rx_state = RECV_WAIT_PACKET_TYPE;
  142. info->rx_count = 0;
  143. if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
  144. BT_ERR("Can't allocate mem for new packet");
  145. return;
  146. }
  147. }
  148. if (info->rx_state == RECV_WAIT_PACKET_TYPE) {
  149. info->rx_skb->dev = (void *) info->hdev;
  150. bt_cb(info->rx_skb)->pkt_type = inb(iobase + UART_RX);
  151. switch (bt_cb(info->rx_skb)->pkt_type) {
  152. case HCI_EVENT_PKT:
  153. info->rx_state = RECV_WAIT_EVENT_HEADER;
  154. info->rx_count = HCI_EVENT_HDR_SIZE;
  155. break;
  156. case HCI_ACLDATA_PKT:
  157. info->rx_state = RECV_WAIT_ACL_HEADER;
  158. info->rx_count = HCI_ACL_HDR_SIZE;
  159. break;
  160. case HCI_SCODATA_PKT:
  161. info->rx_state = RECV_WAIT_SCO_HEADER;
  162. info->rx_count = HCI_SCO_HDR_SIZE;
  163. break;
  164. default:
  165. /* Unknown packet */
  166. BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
  167. info->hdev->stat.err_rx++;
  168. clear_bit(HCI_RUNNING, &(info->hdev->flags));
  169. kfree_skb(info->rx_skb);
  170. info->rx_skb = NULL;
  171. break;
  172. }
  173. } else {
  174. *skb_put(info->rx_skb, 1) = inb(iobase + UART_RX);
  175. info->rx_count--;
  176. if (info->rx_count == 0) {
  177. int dlen;
  178. struct hci_event_hdr *eh;
  179. struct hci_acl_hdr *ah;
  180. struct hci_sco_hdr *sh;
  181. switch (info->rx_state) {
  182. case RECV_WAIT_EVENT_HEADER:
  183. eh = (struct hci_event_hdr *)(info->rx_skb->data);
  184. info->rx_state = RECV_WAIT_DATA;
  185. info->rx_count = eh->plen;
  186. break;
  187. case RECV_WAIT_ACL_HEADER:
  188. ah = (struct hci_acl_hdr *)(info->rx_skb->data);
  189. dlen = __le16_to_cpu(ah->dlen);
  190. info->rx_state = RECV_WAIT_DATA;
  191. info->rx_count = dlen;
  192. break;
  193. case RECV_WAIT_SCO_HEADER:
  194. sh = (struct hci_sco_hdr *)(info->rx_skb->data);
  195. info->rx_state = RECV_WAIT_DATA;
  196. info->rx_count = sh->dlen;
  197. break;
  198. case RECV_WAIT_DATA:
  199. hci_recv_frame(info->rx_skb);
  200. info->rx_skb = NULL;
  201. break;
  202. }
  203. }
  204. }
  205. /* Make sure we don't stay here too long */
  206. if (boguscount++ > 16)
  207. break;
  208. } while (inb(iobase + UART_LSR) & UART_LSR_DR);
  209. }
  210. static irqreturn_t btuart_interrupt(int irq, void *dev_inst)
  211. {
  212. btuart_info_t *info = dev_inst;
  213. unsigned int iobase;
  214. int boguscount = 0;
  215. int iir, lsr;
  216. if (!info || !info->hdev) {
  217. BT_ERR("Call of irq %d for unknown device", irq);
  218. return IRQ_NONE;
  219. }
  220. iobase = info->p_dev->io.BasePort1;
  221. spin_lock(&(info->lock));
  222. iir = inb(iobase + UART_IIR) & UART_IIR_ID;
  223. while (iir) {
  224. /* Clear interrupt */
  225. lsr = inb(iobase + UART_LSR);
  226. switch (iir) {
  227. case UART_IIR_RLSI:
  228. BT_ERR("RLSI");
  229. break;
  230. case UART_IIR_RDI:
  231. /* Receive interrupt */
  232. btuart_receive(info);
  233. break;
  234. case UART_IIR_THRI:
  235. if (lsr & UART_LSR_THRE) {
  236. /* Transmitter ready for data */
  237. btuart_write_wakeup(info);
  238. }
  239. break;
  240. default:
  241. BT_ERR("Unhandled IIR=%#x", iir);
  242. break;
  243. }
  244. /* Make sure we don't stay here too long */
  245. if (boguscount++ > 100)
  246. break;
  247. iir = inb(iobase + UART_IIR) & UART_IIR_ID;
  248. }
  249. spin_unlock(&(info->lock));
  250. return IRQ_HANDLED;
  251. }
  252. static void btuart_change_speed(btuart_info_t *info, unsigned int speed)
  253. {
  254. unsigned long flags;
  255. unsigned int iobase;
  256. int fcr; /* FIFO control reg */
  257. int lcr; /* Line control reg */
  258. int divisor;
  259. if (!info) {
  260. BT_ERR("Unknown device");
  261. return;
  262. }
  263. iobase = info->p_dev->io.BasePort1;
  264. spin_lock_irqsave(&(info->lock), flags);
  265. /* Turn off interrupts */
  266. outb(0, iobase + UART_IER);
  267. divisor = SPEED_MAX / speed;
  268. fcr = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT;
  269. /*
  270. * Use trigger level 1 to avoid 3 ms. timeout delay at 9600 bps, and
  271. * almost 1,7 ms at 19200 bps. At speeds above that we can just forget
  272. * about this timeout since it will always be fast enough.
  273. */
  274. if (speed < 38400)
  275. fcr |= UART_FCR_TRIGGER_1;
  276. else
  277. fcr |= UART_FCR_TRIGGER_14;
  278. /* Bluetooth cards use 8N1 */
  279. lcr = UART_LCR_WLEN8;
  280. outb(UART_LCR_DLAB | lcr, iobase + UART_LCR); /* Set DLAB */
  281. outb(divisor & 0xff, iobase + UART_DLL); /* Set speed */
  282. outb(divisor >> 8, iobase + UART_DLM);
  283. outb(lcr, iobase + UART_LCR); /* Set 8N1 */
  284. outb(fcr, iobase + UART_FCR); /* Enable FIFO's */
  285. /* Turn on interrups */
  286. outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER);
  287. spin_unlock_irqrestore(&(info->lock), flags);
  288. }
  289. /* ======================== HCI interface ======================== */
  290. static int btuart_hci_flush(struct hci_dev *hdev)
  291. {
  292. btuart_info_t *info = (btuart_info_t *)(hdev->driver_data);
  293. /* Drop TX queue */
  294. skb_queue_purge(&(info->txq));
  295. return 0;
  296. }
  297. static int btuart_hci_open(struct hci_dev *hdev)
  298. {
  299. set_bit(HCI_RUNNING, &(hdev->flags));
  300. return 0;
  301. }
  302. static int btuart_hci_close(struct hci_dev *hdev)
  303. {
  304. if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags)))
  305. return 0;
  306. btuart_hci_flush(hdev);
  307. return 0;
  308. }
  309. static int btuart_hci_send_frame(struct sk_buff *skb)
  310. {
  311. btuart_info_t *info;
  312. struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
  313. if (!hdev) {
  314. BT_ERR("Frame for unknown HCI device (hdev=NULL)");
  315. return -ENODEV;
  316. }
  317. info = (btuart_info_t *)(hdev->driver_data);
  318. switch (bt_cb(skb)->pkt_type) {
  319. case HCI_COMMAND_PKT:
  320. hdev->stat.cmd_tx++;
  321. break;
  322. case HCI_ACLDATA_PKT:
  323. hdev->stat.acl_tx++;
  324. break;
  325. case HCI_SCODATA_PKT:
  326. hdev->stat.sco_tx++;
  327. break;
  328. };
  329. /* Prepend skb with frame type */
  330. memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
  331. skb_queue_tail(&(info->txq), skb);
  332. btuart_write_wakeup(info);
  333. return 0;
  334. }
  335. static void btuart_hci_destruct(struct hci_dev *hdev)
  336. {
  337. }
  338. static int btuart_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg)
  339. {
  340. return -ENOIOCTLCMD;
  341. }
  342. /* ======================== Card services HCI interaction ======================== */
  343. static int btuart_open(btuart_info_t *info)
  344. {
  345. unsigned long flags;
  346. unsigned int iobase = info->p_dev->io.BasePort1;
  347. struct hci_dev *hdev;
  348. spin_lock_init(&(info->lock));
  349. skb_queue_head_init(&(info->txq));
  350. info->rx_state = RECV_WAIT_PACKET_TYPE;
  351. info->rx_count = 0;
  352. info->rx_skb = NULL;
  353. /* Initialize HCI device */
  354. hdev = hci_alloc_dev();
  355. if (!hdev) {
  356. BT_ERR("Can't allocate HCI device");
  357. return -ENOMEM;
  358. }
  359. info->hdev = hdev;
  360. hdev->type = HCI_PCCARD;
  361. hdev->driver_data = info;
  362. SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
  363. hdev->open = btuart_hci_open;
  364. hdev->close = btuart_hci_close;
  365. hdev->flush = btuart_hci_flush;
  366. hdev->send = btuart_hci_send_frame;
  367. hdev->destruct = btuart_hci_destruct;
  368. hdev->ioctl = btuart_hci_ioctl;
  369. hdev->owner = THIS_MODULE;
  370. spin_lock_irqsave(&(info->lock), flags);
  371. /* Reset UART */
  372. outb(0, iobase + UART_MCR);
  373. /* Turn off interrupts */
  374. outb(0, iobase + UART_IER);
  375. /* Initialize UART */
  376. outb(UART_LCR_WLEN8, iobase + UART_LCR); /* Reset DLAB */
  377. outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase + UART_MCR);
  378. /* Turn on interrupts */
  379. // outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER);
  380. spin_unlock_irqrestore(&(info->lock), flags);
  381. btuart_change_speed(info, DEFAULT_BAUD_RATE);
  382. /* Timeout before it is safe to send the first HCI packet */
  383. msleep(1000);
  384. /* Register HCI device */
  385. if (hci_register_dev(hdev) < 0) {
  386. BT_ERR("Can't register HCI device");
  387. info->hdev = NULL;
  388. hci_free_dev(hdev);
  389. return -ENODEV;
  390. }
  391. return 0;
  392. }
  393. static int btuart_close(btuart_info_t *info)
  394. {
  395. unsigned long flags;
  396. unsigned int iobase = info->p_dev->io.BasePort1;
  397. struct hci_dev *hdev = info->hdev;
  398. if (!hdev)
  399. return -ENODEV;
  400. btuart_hci_close(hdev);
  401. spin_lock_irqsave(&(info->lock), flags);
  402. /* Reset UART */
  403. outb(0, iobase + UART_MCR);
  404. /* Turn off interrupts */
  405. outb(0, iobase + UART_IER);
  406. spin_unlock_irqrestore(&(info->lock), flags);
  407. if (hci_unregister_dev(hdev) < 0)
  408. BT_ERR("Can't unregister HCI device %s", hdev->name);
  409. hci_free_dev(hdev);
  410. return 0;
  411. }
  412. static int btuart_probe(struct pcmcia_device *link)
  413. {
  414. btuart_info_t *info;
  415. /* Create new info device */
  416. info = kzalloc(sizeof(*info), GFP_KERNEL);
  417. if (!info)
  418. return -ENOMEM;
  419. info->p_dev = link;
  420. link->priv = info;
  421. link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
  422. link->io.NumPorts1 = 8;
  423. link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
  424. link->irq.IRQInfo1 = IRQ_LEVEL_ID;
  425. link->irq.Handler = btuart_interrupt;
  426. link->irq.Instance = info;
  427. link->conf.Attributes = CONF_ENABLE_IRQ;
  428. link->conf.IntType = INT_MEMORY_AND_IO;
  429. return btuart_config(link);
  430. }
  431. static void btuart_detach(struct pcmcia_device *link)
  432. {
  433. btuart_info_t *info = link->priv;
  434. btuart_release(link);
  435. kfree(info);
  436. }
  437. static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
  438. {
  439. int i;
  440. i = pcmcia_get_tuple_data(handle, tuple);
  441. if (i != CS_SUCCESS)
  442. return i;
  443. return pcmcia_parse_tuple(handle, tuple, parse);
  444. }
  445. static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
  446. {
  447. if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS)
  448. return CS_NO_MORE_ITEMS;
  449. return get_tuple(handle, tuple, parse);
  450. }
  451. static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
  452. {
  453. if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS)
  454. return CS_NO_MORE_ITEMS;
  455. return get_tuple(handle, tuple, parse);
  456. }
  457. static int btuart_config(struct pcmcia_device *link)
  458. {
  459. static kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
  460. btuart_info_t *info = link->priv;
  461. tuple_t tuple;
  462. u_short buf[256];
  463. cisparse_t parse;
  464. cistpl_cftable_entry_t *cf = &parse.cftable_entry;
  465. int i, j, try;
  466. /* First pass: look for a config entry that looks normal. */
  467. tuple.TupleData = (cisdata_t *) buf;
  468. tuple.TupleOffset = 0;
  469. tuple.TupleDataMax = 255;
  470. tuple.Attributes = 0;
  471. tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
  472. /* Two tries: without IO aliases, then with aliases */
  473. for (try = 0; try < 2; try++) {
  474. i = first_tuple(link, &tuple, &parse);
  475. while (i != CS_NO_MORE_ITEMS) {
  476. if (i != CS_SUCCESS)
  477. goto next_entry;
  478. if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM))
  479. link->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000;
  480. if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) {
  481. link->conf.ConfigIndex = cf->index;
  482. link->io.BasePort1 = cf->io.win[0].base;
  483. link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK;
  484. i = pcmcia_request_io(link, &link->io);
  485. if (i == CS_SUCCESS)
  486. goto found_port;
  487. }
  488. next_entry:
  489. i = next_tuple(link, &tuple, &parse);
  490. }
  491. }
  492. /* Second pass: try to find an entry that isn't picky about
  493. its base address, then try to grab any standard serial port
  494. address, and finally try to get any free port. */
  495. i = first_tuple(link, &tuple, &parse);
  496. while (i != CS_NO_MORE_ITEMS) {
  497. if ((i == CS_SUCCESS) && (cf->io.nwin > 0)
  498. && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) {
  499. link->conf.ConfigIndex = cf->index;
  500. for (j = 0; j < 5; j++) {
  501. link->io.BasePort1 = base[j];
  502. link->io.IOAddrLines = base[j] ? 16 : 3;
  503. i = pcmcia_request_io(link, &link->io);
  504. if (i == CS_SUCCESS)
  505. goto found_port;
  506. }
  507. }
  508. i = next_tuple(link, &tuple, &parse);
  509. }
  510. found_port:
  511. if (i != CS_SUCCESS) {
  512. BT_ERR("No usable port range found");
  513. cs_error(link, RequestIO, i);
  514. goto failed;
  515. }
  516. i = pcmcia_request_irq(link, &link->irq);
  517. if (i != CS_SUCCESS) {
  518. cs_error(link, RequestIRQ, i);
  519. link->irq.AssignedIRQ = 0;
  520. }
  521. i = pcmcia_request_configuration(link, &link->conf);
  522. if (i != CS_SUCCESS) {
  523. cs_error(link, RequestConfiguration, i);
  524. goto failed;
  525. }
  526. if (btuart_open(info) != 0)
  527. goto failed;
  528. strcpy(info->node.dev_name, info->hdev->name);
  529. link->dev_node = &info->node;
  530. return 0;
  531. failed:
  532. btuart_release(link);
  533. return -ENODEV;
  534. }
  535. static void btuart_release(struct pcmcia_device *link)
  536. {
  537. btuart_info_t *info = link->priv;
  538. btuart_close(info);
  539. pcmcia_disable_device(link);
  540. }
  541. static struct pcmcia_device_id btuart_ids[] = {
  542. /* don't use this driver. Use serial_cs + hci_uart instead */
  543. PCMCIA_DEVICE_NULL
  544. };
  545. MODULE_DEVICE_TABLE(pcmcia, btuart_ids);
  546. static struct pcmcia_driver btuart_driver = {
  547. .owner = THIS_MODULE,
  548. .drv = {
  549. .name = "btuart_cs",
  550. },
  551. .probe = btuart_probe,
  552. .remove = btuart_detach,
  553. .id_table = btuart_ids,
  554. };
  555. static int __init init_btuart_cs(void)
  556. {
  557. return pcmcia_register_driver(&btuart_driver);
  558. }
  559. static void __exit exit_btuart_cs(void)
  560. {
  561. pcmcia_unregister_driver(&btuart_driver);
  562. }
  563. module_init(init_btuart_cs);
  564. module_exit(exit_btuart_cs);