dtl1_cs.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. /*
  2. *
  3. * A driver for Nokia Connectivity Card DTL-1 devices
  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/config.h>
  23. #include <linux/module.h>
  24. #include <linux/kernel.h>
  25. #include <linux/init.h>
  26. #include <linux/slab.h>
  27. #include <linux/types.h>
  28. #include <linux/sched.h>
  29. #include <linux/delay.h>
  30. #include <linux/errno.h>
  31. #include <linux/ptrace.h>
  32. #include <linux/ioport.h>
  33. #include <linux/spinlock.h>
  34. #include <linux/moduleparam.h>
  35. #include <linux/skbuff.h>
  36. #include <linux/string.h>
  37. #include <linux/serial.h>
  38. #include <linux/serial_reg.h>
  39. #include <linux/bitops.h>
  40. #include <asm/system.h>
  41. #include <asm/io.h>
  42. #include <pcmcia/cs_types.h>
  43. #include <pcmcia/cs.h>
  44. #include <pcmcia/cistpl.h>
  45. #include <pcmcia/ciscode.h>
  46. #include <pcmcia/ds.h>
  47. #include <pcmcia/cisreg.h>
  48. #include <net/bluetooth/bluetooth.h>
  49. #include <net/bluetooth/hci_core.h>
  50. /* ======================== Module parameters ======================== */
  51. MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
  52. MODULE_DESCRIPTION("Bluetooth driver for Nokia Connectivity Card DTL-1");
  53. MODULE_LICENSE("GPL");
  54. /* ======================== Local structures ======================== */
  55. typedef struct dtl1_info_t {
  56. dev_link_t link;
  57. dev_node_t node;
  58. struct hci_dev *hdev;
  59. spinlock_t lock; /* For serializing operations */
  60. unsigned long flowmask; /* HCI flow mask */
  61. int ri_latch;
  62. struct sk_buff_head txq;
  63. unsigned long tx_state;
  64. unsigned long rx_state;
  65. unsigned long rx_count;
  66. struct sk_buff *rx_skb;
  67. } dtl1_info_t;
  68. static void dtl1_config(dev_link_t *link);
  69. static void dtl1_release(dev_link_t *link);
  70. static void dtl1_detach(struct pcmcia_device *p_dev);
  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_NSH 0
  77. #define RECV_WAIT_DATA 1
  78. typedef struct {
  79. u8 type;
  80. u8 zero;
  81. u16 len;
  82. } __attribute__ ((packed)) nsh_t; /* Nokia Specific Header */
  83. #define NSHL 4 /* Nokia Specific Header Length */
  84. /* ======================== Interrupt handling ======================== */
  85. static int dtl1_write(unsigned int iobase, int fifo_size, __u8 *buf, int len)
  86. {
  87. int actual = 0;
  88. /* Tx FIFO should be empty */
  89. if (!(inb(iobase + UART_LSR) & UART_LSR_THRE))
  90. return 0;
  91. /* Fill FIFO with current frame */
  92. while ((fifo_size-- > 0) && (actual < len)) {
  93. /* Transmit next byte */
  94. outb(buf[actual], iobase + UART_TX);
  95. actual++;
  96. }
  97. return actual;
  98. }
  99. static void dtl1_write_wakeup(dtl1_info_t *info)
  100. {
  101. if (!info) {
  102. BT_ERR("Unknown device");
  103. return;
  104. }
  105. if (test_bit(XMIT_WAITING, &(info->tx_state))) {
  106. set_bit(XMIT_WAKEUP, &(info->tx_state));
  107. return;
  108. }
  109. if (test_and_set_bit(XMIT_SENDING, &(info->tx_state))) {
  110. set_bit(XMIT_WAKEUP, &(info->tx_state));
  111. return;
  112. }
  113. do {
  114. register unsigned int iobase = info->link.io.BasePort1;
  115. register struct sk_buff *skb;
  116. register int len;
  117. clear_bit(XMIT_WAKEUP, &(info->tx_state));
  118. if (!(info->link.state & DEV_PRESENT))
  119. return;
  120. if (!(skb = skb_dequeue(&(info->txq))))
  121. break;
  122. /* Send frame */
  123. len = dtl1_write(iobase, 32, skb->data, skb->len);
  124. if (len == skb->len) {
  125. set_bit(XMIT_WAITING, &(info->tx_state));
  126. kfree_skb(skb);
  127. } else {
  128. skb_pull(skb, len);
  129. skb_queue_head(&(info->txq), skb);
  130. }
  131. info->hdev->stat.byte_tx += len;
  132. } while (test_bit(XMIT_WAKEUP, &(info->tx_state)));
  133. clear_bit(XMIT_SENDING, &(info->tx_state));
  134. }
  135. static void dtl1_control(dtl1_info_t *info, struct sk_buff *skb)
  136. {
  137. u8 flowmask = *(u8 *)skb->data;
  138. int i;
  139. printk(KERN_INFO "Bluetooth: Nokia control data =");
  140. for (i = 0; i < skb->len; i++) {
  141. printk(" %02x", skb->data[i]);
  142. }
  143. printk("\n");
  144. /* transition to active state */
  145. if (((info->flowmask & 0x07) == 0) && ((flowmask & 0x07) != 0)) {
  146. clear_bit(XMIT_WAITING, &(info->tx_state));
  147. dtl1_write_wakeup(info);
  148. }
  149. info->flowmask = flowmask;
  150. kfree_skb(skb);
  151. }
  152. static void dtl1_receive(dtl1_info_t *info)
  153. {
  154. unsigned int iobase;
  155. nsh_t *nsh;
  156. int boguscount = 0;
  157. if (!info) {
  158. BT_ERR("Unknown device");
  159. return;
  160. }
  161. iobase = info->link.io.BasePort1;
  162. do {
  163. info->hdev->stat.byte_rx++;
  164. /* Allocate packet */
  165. if (info->rx_skb == NULL)
  166. if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
  167. BT_ERR("Can't allocate mem for new packet");
  168. info->rx_state = RECV_WAIT_NSH;
  169. info->rx_count = NSHL;
  170. return;
  171. }
  172. *skb_put(info->rx_skb, 1) = inb(iobase + UART_RX);
  173. nsh = (nsh_t *)info->rx_skb->data;
  174. info->rx_count--;
  175. if (info->rx_count == 0) {
  176. switch (info->rx_state) {
  177. case RECV_WAIT_NSH:
  178. info->rx_state = RECV_WAIT_DATA;
  179. info->rx_count = nsh->len + (nsh->len & 0x0001);
  180. break;
  181. case RECV_WAIT_DATA:
  182. bt_cb(info->rx_skb)->pkt_type = nsh->type;
  183. /* remove PAD byte if it exists */
  184. if (nsh->len & 0x0001) {
  185. info->rx_skb->tail--;
  186. info->rx_skb->len--;
  187. }
  188. /* remove NSH */
  189. skb_pull(info->rx_skb, NSHL);
  190. switch (bt_cb(info->rx_skb)->pkt_type) {
  191. case 0x80:
  192. /* control data for the Nokia Card */
  193. dtl1_control(info, info->rx_skb);
  194. break;
  195. case 0x82:
  196. case 0x83:
  197. case 0x84:
  198. /* send frame to the HCI layer */
  199. info->rx_skb->dev = (void *) info->hdev;
  200. bt_cb(info->rx_skb)->pkt_type &= 0x0f;
  201. hci_recv_frame(info->rx_skb);
  202. break;
  203. default:
  204. /* unknown packet */
  205. BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
  206. kfree_skb(info->rx_skb);
  207. break;
  208. }
  209. info->rx_state = RECV_WAIT_NSH;
  210. info->rx_count = NSHL;
  211. info->rx_skb = NULL;
  212. break;
  213. }
  214. }
  215. /* Make sure we don't stay here too long */
  216. if (boguscount++ > 32)
  217. break;
  218. } while (inb(iobase + UART_LSR) & UART_LSR_DR);
  219. }
  220. static irqreturn_t dtl1_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
  221. {
  222. dtl1_info_t *info = dev_inst;
  223. unsigned int iobase;
  224. unsigned char msr;
  225. int boguscount = 0;
  226. int iir, lsr;
  227. if (!info || !info->hdev) {
  228. BT_ERR("Call of irq %d for unknown device", irq);
  229. return IRQ_NONE;
  230. }
  231. iobase = info->link.io.BasePort1;
  232. spin_lock(&(info->lock));
  233. iir = inb(iobase + UART_IIR) & UART_IIR_ID;
  234. while (iir) {
  235. /* Clear interrupt */
  236. lsr = inb(iobase + UART_LSR);
  237. switch (iir) {
  238. case UART_IIR_RLSI:
  239. BT_ERR("RLSI");
  240. break;
  241. case UART_IIR_RDI:
  242. /* Receive interrupt */
  243. dtl1_receive(info);
  244. break;
  245. case UART_IIR_THRI:
  246. if (lsr & UART_LSR_THRE) {
  247. /* Transmitter ready for data */
  248. dtl1_write_wakeup(info);
  249. }
  250. break;
  251. default:
  252. BT_ERR("Unhandled IIR=%#x", iir);
  253. break;
  254. }
  255. /* Make sure we don't stay here too long */
  256. if (boguscount++ > 100)
  257. break;
  258. iir = inb(iobase + UART_IIR) & UART_IIR_ID;
  259. }
  260. msr = inb(iobase + UART_MSR);
  261. if (info->ri_latch ^ (msr & UART_MSR_RI)) {
  262. info->ri_latch = msr & UART_MSR_RI;
  263. clear_bit(XMIT_WAITING, &(info->tx_state));
  264. dtl1_write_wakeup(info);
  265. }
  266. spin_unlock(&(info->lock));
  267. return IRQ_HANDLED;
  268. }
  269. /* ======================== HCI interface ======================== */
  270. static int dtl1_hci_open(struct hci_dev *hdev)
  271. {
  272. set_bit(HCI_RUNNING, &(hdev->flags));
  273. return 0;
  274. }
  275. static int dtl1_hci_flush(struct hci_dev *hdev)
  276. {
  277. dtl1_info_t *info = (dtl1_info_t *)(hdev->driver_data);
  278. /* Drop TX queue */
  279. skb_queue_purge(&(info->txq));
  280. return 0;
  281. }
  282. static int dtl1_hci_close(struct hci_dev *hdev)
  283. {
  284. if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags)))
  285. return 0;
  286. dtl1_hci_flush(hdev);
  287. return 0;
  288. }
  289. static int dtl1_hci_send_frame(struct sk_buff *skb)
  290. {
  291. dtl1_info_t *info;
  292. struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
  293. struct sk_buff *s;
  294. nsh_t nsh;
  295. if (!hdev) {
  296. BT_ERR("Frame for unknown HCI device (hdev=NULL)");
  297. return -ENODEV;
  298. }
  299. info = (dtl1_info_t *)(hdev->driver_data);
  300. switch (bt_cb(skb)->pkt_type) {
  301. case HCI_COMMAND_PKT:
  302. hdev->stat.cmd_tx++;
  303. nsh.type = 0x81;
  304. break;
  305. case HCI_ACLDATA_PKT:
  306. hdev->stat.acl_tx++;
  307. nsh.type = 0x82;
  308. break;
  309. case HCI_SCODATA_PKT:
  310. hdev->stat.sco_tx++;
  311. nsh.type = 0x83;
  312. break;
  313. };
  314. nsh.zero = 0;
  315. nsh.len = skb->len;
  316. s = bt_skb_alloc(NSHL + skb->len + 1, GFP_ATOMIC);
  317. skb_reserve(s, NSHL);
  318. memcpy(skb_put(s, skb->len), skb->data, skb->len);
  319. if (skb->len & 0x0001)
  320. *skb_put(s, 1) = 0; /* PAD */
  321. /* Prepend skb with Nokia frame header and queue */
  322. memcpy(skb_push(s, NSHL), &nsh, NSHL);
  323. skb_queue_tail(&(info->txq), s);
  324. dtl1_write_wakeup(info);
  325. kfree_skb(skb);
  326. return 0;
  327. }
  328. static void dtl1_hci_destruct(struct hci_dev *hdev)
  329. {
  330. }
  331. static int dtl1_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg)
  332. {
  333. return -ENOIOCTLCMD;
  334. }
  335. /* ======================== Card services HCI interaction ======================== */
  336. static int dtl1_open(dtl1_info_t *info)
  337. {
  338. unsigned long flags;
  339. unsigned int iobase = info->link.io.BasePort1;
  340. struct hci_dev *hdev;
  341. spin_lock_init(&(info->lock));
  342. skb_queue_head_init(&(info->txq));
  343. info->rx_state = RECV_WAIT_NSH;
  344. info->rx_count = NSHL;
  345. info->rx_skb = NULL;
  346. set_bit(XMIT_WAITING, &(info->tx_state));
  347. /* Initialize HCI device */
  348. hdev = hci_alloc_dev();
  349. if (!hdev) {
  350. BT_ERR("Can't allocate HCI device");
  351. return -ENOMEM;
  352. }
  353. info->hdev = hdev;
  354. hdev->type = HCI_PCCARD;
  355. hdev->driver_data = info;
  356. hdev->open = dtl1_hci_open;
  357. hdev->close = dtl1_hci_close;
  358. hdev->flush = dtl1_hci_flush;
  359. hdev->send = dtl1_hci_send_frame;
  360. hdev->destruct = dtl1_hci_destruct;
  361. hdev->ioctl = dtl1_hci_ioctl;
  362. hdev->owner = THIS_MODULE;
  363. spin_lock_irqsave(&(info->lock), flags);
  364. /* Reset UART */
  365. outb(0, iobase + UART_MCR);
  366. /* Turn off interrupts */
  367. outb(0, iobase + UART_IER);
  368. /* Initialize UART */
  369. outb(UART_LCR_WLEN8, iobase + UART_LCR); /* Reset DLAB */
  370. outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase + UART_MCR);
  371. info->ri_latch = inb(info->link.io.BasePort1 + UART_MSR) & UART_MSR_RI;
  372. /* Turn on interrupts */
  373. outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER);
  374. spin_unlock_irqrestore(&(info->lock), flags);
  375. /* Timeout before it is safe to send the first HCI packet */
  376. msleep(2000);
  377. /* Register HCI device */
  378. if (hci_register_dev(hdev) < 0) {
  379. BT_ERR("Can't register HCI device");
  380. info->hdev = NULL;
  381. hci_free_dev(hdev);
  382. return -ENODEV;
  383. }
  384. return 0;
  385. }
  386. static int dtl1_close(dtl1_info_t *info)
  387. {
  388. unsigned long flags;
  389. unsigned int iobase = info->link.io.BasePort1;
  390. struct hci_dev *hdev = info->hdev;
  391. if (!hdev)
  392. return -ENODEV;
  393. dtl1_hci_close(hdev);
  394. spin_lock_irqsave(&(info->lock), flags);
  395. /* Reset UART */
  396. outb(0, iobase + UART_MCR);
  397. /* Turn off interrupts */
  398. outb(0, iobase + UART_IER);
  399. spin_unlock_irqrestore(&(info->lock), flags);
  400. if (hci_unregister_dev(hdev) < 0)
  401. BT_ERR("Can't unregister HCI device %s", hdev->name);
  402. hci_free_dev(hdev);
  403. return 0;
  404. }
  405. static int dtl1_attach(struct pcmcia_device *p_dev)
  406. {
  407. dtl1_info_t *info;
  408. dev_link_t *link;
  409. /* Create new info device */
  410. info = kzalloc(sizeof(*info), GFP_KERNEL);
  411. if (!info)
  412. return -ENOMEM;
  413. link = &info->link;
  414. link->priv = info;
  415. link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
  416. link->io.NumPorts1 = 8;
  417. link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
  418. link->irq.IRQInfo1 = IRQ_LEVEL_ID;
  419. link->irq.Handler = dtl1_interrupt;
  420. link->irq.Instance = info;
  421. link->conf.Attributes = CONF_ENABLE_IRQ;
  422. link->conf.Vcc = 50;
  423. link->conf.IntType = INT_MEMORY_AND_IO;
  424. link->handle = p_dev;
  425. p_dev->instance = link;
  426. link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
  427. dtl1_config(link);
  428. return 0;
  429. }
  430. static void dtl1_detach(struct pcmcia_device *p_dev)
  431. {
  432. dev_link_t *link = dev_to_instance(p_dev);
  433. dtl1_info_t *info = link->priv;
  434. if (link->state & DEV_CONFIG)
  435. dtl1_release(link);
  436. kfree(info);
  437. }
  438. static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
  439. {
  440. int i;
  441. i = pcmcia_get_tuple_data(handle, tuple);
  442. if (i != CS_SUCCESS)
  443. return i;
  444. return pcmcia_parse_tuple(handle, tuple, parse);
  445. }
  446. static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
  447. {
  448. if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS)
  449. return CS_NO_MORE_ITEMS;
  450. return get_tuple(handle, tuple, parse);
  451. }
  452. static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
  453. {
  454. if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS)
  455. return CS_NO_MORE_ITEMS;
  456. return get_tuple(handle, tuple, parse);
  457. }
  458. static void dtl1_config(dev_link_t *link)
  459. {
  460. client_handle_t handle = link->handle;
  461. dtl1_info_t *info = link->priv;
  462. tuple_t tuple;
  463. u_short buf[256];
  464. cisparse_t parse;
  465. cistpl_cftable_entry_t *cf = &parse.cftable_entry;
  466. config_info_t config;
  467. int i, last_ret, last_fn;
  468. tuple.TupleData = (cisdata_t *)buf;
  469. tuple.TupleOffset = 0;
  470. tuple.TupleDataMax = 255;
  471. tuple.Attributes = 0;
  472. /* Get configuration register information */
  473. tuple.DesiredTuple = CISTPL_CONFIG;
  474. last_ret = first_tuple(handle, &tuple, &parse);
  475. if (last_ret != CS_SUCCESS) {
  476. last_fn = ParseTuple;
  477. goto cs_failed;
  478. }
  479. link->conf.ConfigBase = parse.config.base;
  480. link->conf.Present = parse.config.rmask[0];
  481. /* Configure card */
  482. link->state |= DEV_CONFIG;
  483. i = pcmcia_get_configuration_info(handle, &config);
  484. link->conf.Vcc = config.Vcc;
  485. tuple.TupleData = (cisdata_t *)buf;
  486. tuple.TupleOffset = 0;
  487. tuple.TupleDataMax = 255;
  488. tuple.Attributes = 0;
  489. tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
  490. /* Look for a generic full-sized window */
  491. link->io.NumPorts1 = 8;
  492. i = first_tuple(handle, &tuple, &parse);
  493. while (i != CS_NO_MORE_ITEMS) {
  494. if ((i == CS_SUCCESS) && (cf->io.nwin == 1) && (cf->io.win[0].len > 8)) {
  495. link->conf.ConfigIndex = cf->index;
  496. link->io.BasePort1 = cf->io.win[0].base;
  497. link->io.NumPorts1 = cf->io.win[0].len; /*yo */
  498. link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK;
  499. i = pcmcia_request_io(link->handle, &link->io);
  500. if (i == CS_SUCCESS)
  501. break;
  502. }
  503. i = next_tuple(handle, &tuple, &parse);
  504. }
  505. if (i != CS_SUCCESS) {
  506. cs_error(link->handle, RequestIO, i);
  507. goto failed;
  508. }
  509. i = pcmcia_request_irq(link->handle, &link->irq);
  510. if (i != CS_SUCCESS) {
  511. cs_error(link->handle, RequestIRQ, i);
  512. link->irq.AssignedIRQ = 0;
  513. }
  514. i = pcmcia_request_configuration(link->handle, &link->conf);
  515. if (i != CS_SUCCESS) {
  516. cs_error(link->handle, RequestConfiguration, i);
  517. goto failed;
  518. }
  519. if (dtl1_open(info) != 0)
  520. goto failed;
  521. strcpy(info->node.dev_name, info->hdev->name);
  522. link->dev = &info->node;
  523. link->state &= ~DEV_CONFIG_PENDING;
  524. return;
  525. cs_failed:
  526. cs_error(link->handle, last_fn, last_ret);
  527. failed:
  528. dtl1_release(link);
  529. }
  530. static void dtl1_release(dev_link_t *link)
  531. {
  532. dtl1_info_t *info = link->priv;
  533. if (link->state & DEV_PRESENT)
  534. dtl1_close(info);
  535. link->dev = NULL;
  536. pcmcia_release_configuration(link->handle);
  537. pcmcia_release_io(link->handle, &link->io);
  538. pcmcia_release_irq(link->handle, &link->irq);
  539. link->state &= ~DEV_CONFIG;
  540. }
  541. static int dtl1_suspend(struct pcmcia_device *dev)
  542. {
  543. dev_link_t *link = dev_to_instance(dev);
  544. link->state |= DEV_SUSPEND;
  545. if (link->state & DEV_CONFIG)
  546. pcmcia_release_configuration(link->handle);
  547. return 0;
  548. }
  549. static int dtl1_resume(struct pcmcia_device *dev)
  550. {
  551. dev_link_t *link = dev_to_instance(dev);
  552. link->state &= ~DEV_SUSPEND;
  553. if (DEV_OK(link))
  554. pcmcia_request_configuration(link->handle, &link->conf);
  555. return 0;
  556. }
  557. static struct pcmcia_device_id dtl1_ids[] = {
  558. PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d),
  559. PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863),
  560. PCMCIA_DEVICE_PROD_ID12("Socket", "CF+ Personal Network Card", 0xb38bcc2e, 0xe732bae3),
  561. PCMCIA_DEVICE_NULL
  562. };
  563. MODULE_DEVICE_TABLE(pcmcia, dtl1_ids);
  564. static struct pcmcia_driver dtl1_driver = {
  565. .owner = THIS_MODULE,
  566. .drv = {
  567. .name = "dtl1_cs",
  568. },
  569. .probe = dtl1_attach,
  570. .remove = dtl1_detach,
  571. .id_table = dtl1_ids,
  572. .suspend = dtl1_suspend,
  573. .resume = dtl1_resume,
  574. };
  575. static int __init init_dtl1_cs(void)
  576. {
  577. return pcmcia_register_driver(&dtl1_driver);
  578. }
  579. static void __exit exit_dtl1_cs(void)
  580. {
  581. pcmcia_unregister_driver(&dtl1_driver);
  582. }
  583. module_init(init_dtl1_cs);
  584. module_exit(exit_dtl1_cs);