2 * jmb38x_ms.c - JMicron jmb38x MemoryStick card reader
4 * Copyright (C) 2008 Alex Dubov <oakad@yahoo.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
12 #include <linux/spinlock.h>
13 #include <linux/interrupt.h>
14 #include <linux/pci.h>
15 #include <linux/dma-mapping.h>
16 #include <linux/delay.h>
17 #include <linux/highmem.h>
18 #include <linux/memstick.h>
20 #define DRIVER_NAME "jmb38x_ms"
23 module_param(no_dma, bool, 0644);
36 INT_STATUS_ENABLE = 0x28,
37 INT_SIGNAL_ENABLE = 0x2c,
40 PAD_OUTPUT_ENABLE = 0x38,
49 struct jmb38x_ms_host {
50 struct jmb38x_ms *chip;
54 char host_id[DEVICE_ID_SIZE];
56 unsigned int block_pos;
57 unsigned long timeout_jiffies;
58 struct timer_list timer;
59 struct memstick_request *req;
60 unsigned char eject:1,
62 unsigned char cmd_flags;
64 unsigned int io_word[2];
70 struct memstick_host *hosts[];
73 #define BLOCK_COUNT_MASK 0xffff0000
74 #define BLOCK_SIZE_MASK 0x00000fff
76 #define DMA_CONTROL_ENABLE 0x00000001
78 #define TPC_DATA_SEL 0x00008000
79 #define TPC_DIR 0x00004000
80 #define TPC_WAIT_INT 0x00002000
81 #define TPC_GET_INT 0x00000800
82 #define TPC_CODE_SZ_MASK 0x00000700
83 #define TPC_DATA_SZ_MASK 0x00000007
85 #define HOST_CONTROL_RESET_REQ 0x00008000
86 #define HOST_CONTROL_REI 0x00004000
87 #define HOST_CONTROL_LED 0x00000400
88 #define HOST_CONTROL_FAST_CLK 0x00000200
89 #define HOST_CONTROL_RESET 0x00000100
90 #define HOST_CONTROL_POWER_EN 0x00000080
91 #define HOST_CONTROL_CLOCK_EN 0x00000040
92 #define HOST_CONTROL_IF_SHIFT 4
94 #define HOST_CONTROL_IF_SERIAL 0x0
95 #define HOST_CONTROL_IF_PAR4 0x1
96 #define HOST_CONTROL_IF_PAR8 0x3
98 #define STATUS_HAS_MEDIA 0x00000400
99 #define STATUS_FIFO_EMPTY 0x00000200
100 #define STATUS_FIFO_FULL 0x00000100
102 #define INT_STATUS_TPC_ERR 0x00080000
103 #define INT_STATUS_CRC_ERR 0x00040000
104 #define INT_STATUS_TIMER_TO 0x00020000
105 #define INT_STATUS_HSK_TO 0x00010000
106 #define INT_STATUS_ANY_ERR 0x00008000
107 #define INT_STATUS_FIFO_WRDY 0x00000080
108 #define INT_STATUS_FIFO_RRDY 0x00000040
109 #define INT_STATUS_MEDIA_OUT 0x00000010
110 #define INT_STATUS_MEDIA_IN 0x00000008
111 #define INT_STATUS_DMA_BOUNDARY 0x00000004
112 #define INT_STATUS_EOTRAN 0x00000002
113 #define INT_STATUS_EOTPC 0x00000001
115 #define INT_STATUS_ALL 0x000f801f
117 #define PAD_OUTPUT_ENABLE_MS 0x0F3F
119 #define PAD_PU_PD_OFF 0x7FFF0000
120 #define PAD_PU_PD_ON_MS_SOCK0 0x5f8f0000
121 #define PAD_PU_PD_ON_MS_SOCK1 0x0f0f0000
130 static unsigned int jmb38x_ms_read_data(struct jmb38x_ms_host *host,
131 unsigned char *buf, unsigned int length)
133 unsigned int off = 0;
135 while (host->io_pos && length) {
136 buf[off++] = host->io_word[0] & 0xff;
137 host->io_word[0] >>= 8;
145 while (!(STATUS_FIFO_EMPTY & readl(host->addr + STATUS))) {
148 *(unsigned int *)(buf + off) = __raw_readl(host->addr + DATA);
154 && !(STATUS_FIFO_EMPTY & readl(host->addr + STATUS))) {
155 host->io_word[0] = readl(host->addr + DATA);
156 for (host->io_pos = 4; host->io_pos; --host->io_pos) {
157 buf[off++] = host->io_word[0] & 0xff;
158 host->io_word[0] >>= 8;
168 static unsigned int jmb38x_ms_read_reg_data(struct jmb38x_ms_host *host,
172 unsigned int off = 0;
174 while (host->io_pos > 4 && length) {
175 buf[off++] = host->io_word[0] & 0xff;
176 host->io_word[0] >>= 8;
184 while (host->io_pos && length) {
185 buf[off++] = host->io_word[1] & 0xff;
186 host->io_word[1] >>= 8;
194 static unsigned int jmb38x_ms_write_data(struct jmb38x_ms_host *host,
198 unsigned int off = 0;
201 while (host->io_pos < 4 && length) {
202 host->io_word[0] |= buf[off++] << (host->io_pos * 8);
208 if (host->io_pos == 4
209 && !(STATUS_FIFO_FULL & readl(host->addr + STATUS))) {
210 writel(host->io_word[0], host->addr + DATA);
212 host->io_word[0] = 0;
213 } else if (host->io_pos) {
220 while (!(STATUS_FIFO_FULL & readl(host->addr + STATUS))) {
224 __raw_writel(*(unsigned int *)(buf + off),
232 host->io_word[0] |= buf[off + 2] << 16;
235 host->io_word[0] |= buf[off + 1] << 8;
238 host->io_word[0] |= buf[off];
247 static unsigned int jmb38x_ms_write_reg_data(struct jmb38x_ms_host *host,
251 unsigned int off = 0;
253 while (host->io_pos < 4 && length) {
254 host->io_word[0] &= ~(0xff << (host->io_pos * 8));
255 host->io_word[0] |= buf[off++] << (host->io_pos * 8);
263 while (host->io_pos < 8 && length) {
264 host->io_word[1] &= ~(0xff << (host->io_pos * 8));
265 host->io_word[1] |= buf[off++] << (host->io_pos * 8);
273 static int jmb38x_ms_transfer_data(struct jmb38x_ms_host *host)
277 unsigned int t_size, p_cnt;
280 unsigned long flags = 0;
282 if (host->req->long_data) {
283 length = host->req->sg.length - host->block_pos;
284 off = host->req->sg.offset + host->block_pos;
286 length = host->req->data_len - host->block_pos;
291 unsigned int uninitialized_var(p_off);
293 if (host->req->long_data) {
294 pg = nth_page(sg_page(&host->req->sg),
296 p_off = offset_in_page(off);
297 p_cnt = PAGE_SIZE - p_off;
298 p_cnt = min(p_cnt, length);
300 local_irq_save(flags);
301 buf = kmap_atomic(pg, KM_BIO_SRC_IRQ) + p_off;
303 buf = host->req->data + host->block_pos;
304 p_cnt = host->req->data_len - host->block_pos;
307 if (host->req->data_dir == WRITE)
308 t_size = !(host->cmd_flags & REG_DATA)
309 ? jmb38x_ms_write_data(host, buf, p_cnt)
310 : jmb38x_ms_write_reg_data(host, buf, p_cnt);
312 t_size = !(host->cmd_flags & REG_DATA)
313 ? jmb38x_ms_read_data(host, buf, p_cnt)
314 : jmb38x_ms_read_reg_data(host, buf, p_cnt);
316 if (host->req->long_data) {
317 kunmap_atomic(buf - p_off, KM_BIO_SRC_IRQ);
318 local_irq_restore(flags);
323 host->block_pos += t_size;
328 if (!length && host->req->data_dir == WRITE) {
329 if (host->cmd_flags & REG_DATA) {
330 writel(host->io_word[0], host->addr + TPC_P0);
331 writel(host->io_word[1], host->addr + TPC_P1);
332 } else if (host->io_pos) {
333 writel(host->io_word[0], host->addr + DATA);
340 static int jmb38x_ms_issue_cmd(struct memstick_host *msh)
342 struct jmb38x_ms_host *host = memstick_priv(msh);
344 unsigned int data_len, cmd, t_val;
346 if (!(STATUS_HAS_MEDIA & readl(host->addr + STATUS))) {
347 dev_dbg(msh->cdev.dev, "no media status\n");
348 host->req->error = -ETIME;
349 return host->req->error;
352 dev_dbg(msh->cdev.dev, "control %08x\n",
353 readl(host->addr + HOST_CONTROL));
354 dev_dbg(msh->cdev.dev, "status %08x\n", readl(host->addr + INT_STATUS));
355 dev_dbg(msh->cdev.dev, "hstatus %08x\n", readl(host->addr + STATUS));
360 host->io_word[0] = 0;
361 host->io_word[1] = 0;
363 cmd = host->req->tpc << 16;
366 if (host->req->data_dir == READ)
368 if (host->req->need_card_int)
370 if (host->req->get_int_reg)
373 data = host->req->data;
375 host->use_dma = !no_dma;
377 if (host->req->long_data) {
378 data_len = host->req->sg.length;
380 data_len = host->req->data_len;
385 cmd &= ~(TPC_DATA_SEL | 0xf);
386 host->cmd_flags |= REG_DATA;
387 cmd |= data_len & 0xf;
392 if (1 != pci_map_sg(host->chip->pdev, &host->req->sg, 1,
393 host->req->data_dir == READ
395 : PCI_DMA_TODEVICE)) {
396 host->req->error = -ENOMEM;
397 return host->req->error;
399 data_len = sg_dma_len(&host->req->sg);
400 writel(sg_dma_address(&host->req->sg),
401 host->addr + DMA_ADDRESS);
402 writel(((1 << 16) & BLOCK_COUNT_MASK)
403 | (data_len & BLOCK_SIZE_MASK),
405 writel(DMA_CONTROL_ENABLE, host->addr + DMA_CONTROL);
406 } else if (!(host->cmd_flags & REG_DATA)) {
407 writel(((1 << 16) & BLOCK_COUNT_MASK)
408 | (data_len & BLOCK_SIZE_MASK),
410 t_val = readl(host->addr + INT_STATUS_ENABLE);
411 t_val |= host->req->data_dir == READ
412 ? INT_STATUS_FIFO_RRDY
413 : INT_STATUS_FIFO_WRDY;
415 writel(t_val, host->addr + INT_STATUS_ENABLE);
416 writel(t_val, host->addr + INT_SIGNAL_ENABLE);
418 cmd &= ~(TPC_DATA_SEL | 0xf);
419 host->cmd_flags |= REG_DATA;
420 cmd |= data_len & 0xf;
422 if (host->req->data_dir == WRITE) {
423 jmb38x_ms_transfer_data(host);
424 writel(host->io_word[0], host->addr + TPC_P0);
425 writel(host->io_word[1], host->addr + TPC_P1);
429 mod_timer(&host->timer, jiffies + host->timeout_jiffies);
430 writel(HOST_CONTROL_LED | readl(host->addr + HOST_CONTROL),
431 host->addr + HOST_CONTROL);
432 host->req->error = 0;
434 writel(cmd, host->addr + TPC);
435 dev_dbg(msh->cdev.dev, "executing TPC %08x, len %x\n", cmd, data_len);
440 static void jmb38x_ms_complete_cmd(struct memstick_host *msh, int last)
442 struct jmb38x_ms_host *host = memstick_priv(msh);
443 unsigned int t_val = 0;
446 del_timer(&host->timer);
448 dev_dbg(msh->cdev.dev, "c control %08x\n",
449 readl(host->addr + HOST_CONTROL));
450 dev_dbg(msh->cdev.dev, "c status %08x\n",
451 readl(host->addr + INT_STATUS));
452 dev_dbg(msh->cdev.dev, "c hstatus %08x\n", readl(host->addr + STATUS));
454 if (host->req->get_int_reg) {
455 t_val = readl(host->addr + TPC_P0);
456 host->req->int_reg = (t_val & 0xff);
460 writel(0, host->addr + DMA_CONTROL);
461 pci_unmap_sg(host->chip->pdev, &host->req->sg, 1,
462 host->req->data_dir == READ
463 ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE);
465 t_val = readl(host->addr + INT_STATUS_ENABLE);
466 if (host->req->data_dir == READ)
467 t_val &= ~INT_STATUS_FIFO_RRDY;
469 t_val &= ~INT_STATUS_FIFO_WRDY;
471 writel(t_val, host->addr + INT_STATUS_ENABLE);
472 writel(t_val, host->addr + INT_SIGNAL_ENABLE);
475 writel((~HOST_CONTROL_LED) & readl(host->addr + HOST_CONTROL),
476 host->addr + HOST_CONTROL);
480 rc = memstick_next_req(msh, &host->req);
481 } while (!rc && jmb38x_ms_issue_cmd(msh));
484 rc = memstick_next_req(msh, &host->req);
486 host->req->error = -ETIME;
491 static irqreturn_t jmb38x_ms_isr(int irq, void *dev_id)
493 struct memstick_host *msh = dev_id;
494 struct jmb38x_ms_host *host = memstick_priv(msh);
495 unsigned int irq_status;
497 spin_lock(&host->lock);
498 irq_status = readl(host->addr + INT_STATUS);
499 dev_dbg(&host->chip->pdev->dev, "irq_status = %08x\n", irq_status);
500 if (irq_status == 0 || irq_status == (~0)) {
501 spin_unlock(&host->lock);
506 if (irq_status & INT_STATUS_ANY_ERR) {
507 if (irq_status & INT_STATUS_CRC_ERR)
508 host->req->error = -EILSEQ;
510 host->req->error = -ETIME;
513 if (irq_status & INT_STATUS_EOTRAN)
514 host->cmd_flags |= FIFO_READY;
516 if (irq_status & (INT_STATUS_FIFO_RRDY
517 | INT_STATUS_FIFO_WRDY))
518 jmb38x_ms_transfer_data(host);
520 if (irq_status & INT_STATUS_EOTRAN) {
521 jmb38x_ms_transfer_data(host);
522 host->cmd_flags |= FIFO_READY;
526 if (irq_status & INT_STATUS_EOTPC) {
527 host->cmd_flags |= CMD_READY;
528 if (host->cmd_flags & REG_DATA) {
529 if (host->req->data_dir == READ) {
538 jmb38x_ms_transfer_data(host);
540 host->cmd_flags |= FIFO_READY;
546 if (irq_status & (INT_STATUS_MEDIA_IN | INT_STATUS_MEDIA_OUT)) {
547 dev_dbg(&host->chip->pdev->dev, "media changed\n");
548 memstick_detect_change(msh);
551 writel(irq_status, host->addr + INT_STATUS);
554 && (((host->cmd_flags & CMD_READY)
555 && (host->cmd_flags & FIFO_READY))
556 || host->req->error))
557 jmb38x_ms_complete_cmd(msh, 0);
559 spin_unlock(&host->lock);
563 static void jmb38x_ms_abort(unsigned long data)
565 struct memstick_host *msh = (struct memstick_host *)data;
566 struct jmb38x_ms_host *host = memstick_priv(msh);
569 dev_dbg(&host->chip->pdev->dev, "abort\n");
570 spin_lock_irqsave(&host->lock, flags);
572 host->req->error = -ETIME;
573 jmb38x_ms_complete_cmd(msh, 0);
575 spin_unlock_irqrestore(&host->lock, flags);
578 static void jmb38x_ms_request(struct memstick_host *msh)
580 struct jmb38x_ms_host *host = memstick_priv(msh);
584 spin_lock_irqsave(&host->lock, flags);
586 spin_unlock_irqrestore(&host->lock, flags);
592 rc = memstick_next_req(msh, &host->req);
593 } while (!rc && jmb38x_ms_issue_cmd(msh));
594 spin_unlock_irqrestore(&host->lock, flags);
597 static void jmb38x_ms_reset(struct jmb38x_ms_host *host)
599 unsigned int host_ctl = readl(host->addr + HOST_CONTROL);
601 writel(host_ctl | HOST_CONTROL_RESET_REQ | HOST_CONTROL_RESET,
602 host->addr + HOST_CONTROL);
604 while (HOST_CONTROL_RESET_REQ
605 & (host_ctl = readl(host->addr + HOST_CONTROL))) {
607 dev_dbg(&host->chip->pdev->dev, "reset\n");
610 writel(INT_STATUS_ALL, host->addr + INT_STATUS_ENABLE);
611 writel(INT_STATUS_ALL, host->addr + INT_SIGNAL_ENABLE);
613 dev_dbg(&host->chip->pdev->dev, "reset\n");
616 static void jmb38x_ms_set_param(struct memstick_host *msh,
617 enum memstick_param param,
620 struct jmb38x_ms_host *host = memstick_priv(msh);
621 unsigned int host_ctl;
624 spin_lock_irqsave(&host->lock, flags);
628 if (value == MEMSTICK_POWER_ON) {
629 jmb38x_ms_reset(host);
631 writel(host->id ? PAD_PU_PD_ON_MS_SOCK1
632 : PAD_PU_PD_ON_MS_SOCK0,
633 host->addr + PAD_PU_PD);
635 writel(PAD_OUTPUT_ENABLE_MS,
636 host->addr + PAD_OUTPUT_ENABLE);
638 host_ctl = readl(host->addr + HOST_CONTROL);
640 writel(host_ctl | (HOST_CONTROL_POWER_EN
641 | HOST_CONTROL_CLOCK_EN),
642 host->addr + HOST_CONTROL);
644 dev_dbg(&host->chip->pdev->dev, "power on\n");
645 } else if (value == MEMSTICK_POWER_OFF) {
646 writel(readl(host->addr + HOST_CONTROL)
647 & ~(HOST_CONTROL_POWER_EN
648 | HOST_CONTROL_CLOCK_EN),
649 host->addr + HOST_CONTROL);
650 writel(0, host->addr + PAD_OUTPUT_ENABLE);
651 writel(PAD_PU_PD_OFF, host->addr + PAD_PU_PD);
652 dev_dbg(&host->chip->pdev->dev, "power off\n");
655 case MEMSTICK_INTERFACE:
656 /* jmb38x_ms_reset(host); */
658 host_ctl = readl(host->addr + HOST_CONTROL);
659 host_ctl &= ~(3 << HOST_CONTROL_IF_SHIFT);
662 if (value == MEMSTICK_SERIAL) {
663 host_ctl &= ~HOST_CONTROL_FAST_CLK;
664 host_ctl |= HOST_CONTROL_IF_SERIAL
665 << HOST_CONTROL_IF_SHIFT;
666 host_ctl |= HOST_CONTROL_REI;
667 writel(0, host->addr + CLOCK_DELAY);
668 } else if (value == MEMSTICK_PAR4) {
669 host_ctl |= HOST_CONTROL_FAST_CLK;
670 host_ctl |= HOST_CONTROL_IF_PAR4
671 << HOST_CONTROL_IF_SHIFT;
672 host_ctl &= ~HOST_CONTROL_REI;
673 writel(4, host->addr + CLOCK_DELAY);
674 } else if (value == MEMSTICK_PAR8) {
675 host_ctl |= HOST_CONTROL_FAST_CLK;
676 host_ctl |= HOST_CONTROL_IF_PAR8
677 << HOST_CONTROL_IF_SHIFT;
678 host_ctl &= ~HOST_CONTROL_REI;
679 writel(4, host->addr + CLOCK_DELAY);
681 writel(host_ctl, host->addr + HOST_CONTROL);
685 spin_unlock_irqrestore(&host->lock, flags);
690 static int jmb38x_ms_suspend(struct pci_dev *dev, pm_message_t state)
692 struct jmb38x_ms *jm = pci_get_drvdata(dev);
695 for (cnt = 0; cnt < jm->host_cnt; ++cnt) {
698 memstick_suspend_host(jm->hosts[cnt]);
702 pci_enable_wake(dev, pci_choose_state(dev, state), 0);
703 pci_disable_device(dev);
704 pci_set_power_state(dev, pci_choose_state(dev, state));
708 static int jmb38x_ms_resume(struct pci_dev *dev)
710 struct jmb38x_ms *jm = pci_get_drvdata(dev);
713 pci_set_power_state(dev, PCI_D0);
714 pci_restore_state(dev);
715 rc = pci_enable_device(dev);
720 pci_read_config_dword(dev, 0xac, &rc);
721 pci_write_config_dword(dev, 0xac, rc | 0x00470000);
723 for (rc = 0; rc < jm->host_cnt; ++rc) {
726 memstick_resume_host(jm->hosts[rc]);
727 memstick_detect_change(jm->hosts[rc]);
735 #define jmb38x_ms_suspend NULL
736 #define jmb38x_ms_resume NULL
738 #endif /* CONFIG_PM */
740 static int jmb38x_ms_count_slots(struct pci_dev *pdev)
744 for (cnt = 0; cnt < PCI_ROM_RESOURCE; ++cnt) {
745 if (!(IORESOURCE_MEM & pci_resource_flags(pdev, cnt)))
748 if (256 != pci_resource_len(pdev, cnt))
756 static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
758 struct memstick_host *msh;
759 struct jmb38x_ms_host *host;
761 msh = memstick_alloc_host(sizeof(struct jmb38x_ms_host),
766 host = memstick_priv(msh);
768 host->addr = ioremap(pci_resource_start(jm->pdev, cnt),
769 pci_resource_len(jm->pdev, cnt));
773 spin_lock_init(&host->lock);
775 snprintf(host->host_id, DEVICE_ID_SIZE, DRIVER_NAME ":slot%d",
777 host->irq = jm->pdev->irq;
778 host->timeout_jiffies = msecs_to_jiffies(4000);
779 msh->request = jmb38x_ms_request;
780 msh->set_param = jmb38x_ms_set_param;
782 msh->caps = MEMSTICK_CAP_AUTO_GET_INT | MEMSTICK_CAP_PAR4
785 msh->caps = MEMSTICK_CAP_PAR4 | MEMSTICK_CAP_PAR8;
787 setup_timer(&host->timer, jmb38x_ms_abort, (unsigned long)msh);
789 if (!request_irq(host->irq, jmb38x_ms_isr, IRQF_SHARED, host->host_id,
799 static void jmb38x_ms_free_host(struct memstick_host *msh)
801 struct jmb38x_ms_host *host = memstick_priv(msh);
803 free_irq(host->irq, msh);
805 memstick_free_host(msh);
808 static int jmb38x_ms_probe(struct pci_dev *pdev,
809 const struct pci_device_id *dev_id)
811 struct jmb38x_ms *jm;
812 int pci_dev_busy = 0;
815 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
819 rc = pci_enable_device(pdev);
823 pci_set_master(pdev);
825 rc = pci_request_regions(pdev, DRIVER_NAME);
831 pci_read_config_dword(pdev, 0xac, &rc);
832 pci_write_config_dword(pdev, 0xac, rc | 0x00470000);
834 cnt = jmb38x_ms_count_slots(pdev);
841 jm = kzalloc(sizeof(struct jmb38x_ms)
842 + cnt * sizeof(struct memstick_host *), GFP_KERNEL);
850 pci_set_drvdata(pdev, jm);
852 for (cnt = 0; cnt < jm->host_cnt; ++cnt) {
853 jm->hosts[cnt] = jmb38x_ms_alloc_host(jm, cnt);
857 rc = memstick_add_host(jm->hosts[cnt]);
860 jmb38x_ms_free_host(jm->hosts[cnt]);
861 jm->hosts[cnt] = NULL;
871 pci_set_drvdata(pdev, NULL);
874 pci_release_regions(pdev);
877 pci_disable_device(pdev);
881 static void jmb38x_ms_remove(struct pci_dev *dev)
883 struct jmb38x_ms *jm = pci_get_drvdata(dev);
884 struct jmb38x_ms_host *host;
888 for (cnt = 0; cnt < jm->host_cnt; ++cnt) {
892 host = memstick_priv(jm->hosts[cnt]);
894 writel(0, host->addr + INT_SIGNAL_ENABLE);
895 writel(0, host->addr + INT_STATUS_ENABLE);
897 dev_dbg(&jm->pdev->dev, "interrupts off\n");
898 spin_lock_irqsave(&host->lock, flags);
900 host->req->error = -ETIME;
901 jmb38x_ms_complete_cmd(jm->hosts[cnt], 1);
903 spin_unlock_irqrestore(&host->lock, flags);
905 memstick_remove_host(jm->hosts[cnt]);
906 dev_dbg(&jm->pdev->dev, "host removed\n");
908 jmb38x_ms_free_host(jm->hosts[cnt]);
911 pci_set_drvdata(dev, NULL);
912 pci_release_regions(dev);
913 pci_disable_device(dev);
917 static struct pci_device_id jmb38x_ms_id_tbl [] = {
918 { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB38X_MS, PCI_ANY_ID,
919 PCI_ANY_ID, 0, 0, 0 },
923 static struct pci_driver jmb38x_ms_driver = {
925 .id_table = jmb38x_ms_id_tbl,
926 .probe = jmb38x_ms_probe,
927 .remove = jmb38x_ms_remove,
928 .suspend = jmb38x_ms_suspend,
929 .resume = jmb38x_ms_resume
932 static int __init jmb38x_ms_init(void)
934 return pci_register_driver(&jmb38x_ms_driver);
937 static void __exit jmb38x_ms_exit(void)
939 pci_unregister_driver(&jmb38x_ms_driver);
942 MODULE_AUTHOR("Alex Dubov");
943 MODULE_DESCRIPTION("JMicron jmb38x MemoryStick driver");
944 MODULE_LICENSE("GPL");
945 MODULE_DEVICE_TABLE(pci, jmb38x_ms_id_tbl);
947 module_init(jmb38x_ms_init);
948 module_exit(jmb38x_ms_exit);