Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 Red Hat <evan_ko@phison.com> |
| 3 | * |
| 4 | * May be copied or modified under the terms of the GNU General Public License |
| 5 | * |
| 6 | * [Modify History] |
| 7 | * #0001, Evan, 2008.10.22, V0.00, New release. |
| 8 | * #0002, Evan, 2008.11.01, V0.90, Test Work In Ubuntu Linux 8.04. |
| 9 | * #0003, Evan, 2008.01.08, V0.91, Change Name "PCIE-SSD" to "E-BOX". |
| 10 | */ |
| 11 | |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/pci.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/blkdev.h> |
| 17 | #include <linux/delay.h> |
| 18 | #include <linux/device.h> |
| 19 | #include <scsi/scsi_host.h> |
| 20 | #include <linux/libata.h> |
| 21 | #include <linux/ata.h> |
| 22 | |
| 23 | #define PHISON_DEBUG |
| 24 | |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 25 | #define DRV_NAME "phison_e-box" /* #0003 */ |
Jonas Lundqvist | 33f84a8 | 2010-03-16 15:41:09 +0100 | [diff] [blame] | 26 | #define DRV_VERSION "0.91" /* #0003 */ |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 27 | |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 28 | #define PCI_VENDOR_ID_PHISON 0x1987 |
| 29 | #define PCI_DEVICE_ID_PS5000 0x5000 |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 30 | |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 31 | static int phison_pre_reset(struct ata_link *link, unsigned long deadline) |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 32 | { |
| 33 | int ret; |
| 34 | struct ata_port *ap = link->ap; |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 35 | |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 36 | ap->cbl = ATA_CBL_NONE; |
| 37 | ret = ata_std_prereset(link, deadline); |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 38 | dev_dbg(ap->dev, "phison_pre_reset(), ret = %x\n", ret); |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 39 | return ret; |
| 40 | } |
| 41 | |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 42 | static struct scsi_host_template phison_sht = { |
Greg Kroah-Hartman | 76d86df | 2009-02-12 13:37:51 -0800 | [diff] [blame] | 43 | ATA_BMDMA_SHT(DRV_NAME), |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 44 | }; |
| 45 | |
Greg Kroah-Hartman | 76d86df | 2009-02-12 13:37:51 -0800 | [diff] [blame] | 46 | static struct ata_port_operations phison_ops = { |
| 47 | .inherits = &ata_bmdma_port_ops, |
| 48 | .prereset = phison_pre_reset, |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 49 | }; |
| 50 | |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 51 | static int phison_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 52 | { |
Greg Kroah-Hartman | 76d86df | 2009-02-12 13:37:51 -0800 | [diff] [blame] | 53 | int ret; |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 54 | struct ata_port_info info = { |
Greg Kroah-Hartman | 76d86df | 2009-02-12 13:37:51 -0800 | [diff] [blame] | 55 | .flags = ATA_FLAG_NO_ATAPI, |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 56 | |
| 57 | .pio_mask = 0x1f, |
| 58 | .mwdma_mask = 0x07, |
Jonas Lundqvist | 33f84a8 | 2010-03-16 15:41:09 +0100 | [diff] [blame] | 59 | .udma_mask = ATA_UDMA5, |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 60 | |
| 61 | .port_ops = &phison_ops, |
| 62 | }; |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 63 | const struct ata_port_info *ppi[] = { &info, NULL }; |
| 64 | |
Greg Kroah-Hartman | cf10700 | 2010-10-09 13:26:12 -0700 | [diff] [blame] | 65 | ret = ata_pci_bmdma_init_one(pdev, ppi, &phison_sht, NULL, 0); |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 66 | |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 67 | dev_dbg(&pdev->dev, "phison_init_one(), ret = %x\n", ret); |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 68 | |
| 69 | return ret; |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 70 | } |
| 71 | |
Namhyung Kim | abb9eb7 | 2010-12-10 01:40:28 +0900 | [diff] [blame] | 72 | static DEFINE_PCI_DEVICE_TABLE(phison_pci_tbl) = { |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 73 | { PCI_VENDOR_ID_PHISON, PCI_DEVICE_ID_PS5000, PCI_ANY_ID, PCI_ANY_ID, |
| 74 | PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 0 }, |
| 75 | { 0, }, |
| 76 | }; |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 77 | MODULE_DEVICE_TABLE(pci, phison_pci_tbl); |
| 78 | |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 79 | static struct pci_driver phison_pci_driver = { |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 80 | .name = DRV_NAME, |
| 81 | .id_table = phison_pci_tbl, |
| 82 | .probe = phison_init_one, |
| 83 | .remove = ata_pci_remove_one, |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 84 | #ifdef CONFIG_PM /* haven't tested it. */ |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 85 | .suspend = ata_pci_device_suspend, |
| 86 | .resume = ata_pci_device_resume, |
| 87 | #endif |
| 88 | }; |
| 89 | |
Peter Huewe | 73d3f66 | 2009-09-29 01:53:16 +0200 | [diff] [blame] | 90 | static int __init phison_ide_init(void) |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 91 | { |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 92 | return pci_register_driver(&phison_pci_driver); |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 93 | } |
| 94 | |
Peter Huewe | 73d3f66 | 2009-09-29 01:53:16 +0200 | [diff] [blame] | 95 | static void __exit phison_ide_exit(void) |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 96 | { |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 97 | pci_unregister_driver(&phison_pci_driver); |
| 98 | } |
| 99 | |
| 100 | module_init(phison_ide_init); |
| 101 | module_exit(phison_ide_exit); |
| 102 | |
| 103 | MODULE_AUTHOR("Evan Ko"); |
Greg Kroah-Hartman | 3321020 | 2009-02-12 13:36:54 -0800 | [diff] [blame] | 104 | MODULE_DESCRIPTION("PCIE driver module for PHISON PS5000 E-BOX"); |
Evan Ko | cfc2f94 | 2009-02-09 13:02:35 -0800 | [diff] [blame] | 105 | MODULE_LICENSE("GPL"); |
| 106 | MODULE_VERSION(DRV_VERSION); |