2 * Copyright (C) 2006 Red Hat <evan_ko@phison.com>
4 * May be copied or modified under the terms of the GNU General Public License
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".
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>
25 #define DRV_NAME "phison_e-box" /* #0003 */
26 #define DRV_VERSION "0.91" /* #0003 */
28 #define PCI_VENDOR_ID_PHISON 0x1987
29 #define PCI_DEVICE_ID_PS5000 0x5000
31 static int phison_pre_reset(struct ata_link *link, unsigned long deadline)
34 struct ata_port *ap = link->ap;
36 ap->cbl = ATA_CBL_NONE;
37 ret = ata_std_prereset(link, deadline);
38 dev_dbg(ap->dev, "phison_pre_reset(), ret = %x\n", ret);
42 static void phison_error_handler(struct ata_port *ap)
44 dev_dbg(ap->dev, "phison_error_handler()\n");
45 return ata_bmdma_drive_eh(ap, phison_pre_reset,
46 ata_std_softreset, NULL,
50 static struct scsi_host_template phison_sht = {
51 .module = THIS_MODULE,
53 .ioctl = ata_scsi_ioctl,
54 .queuecommand = ata_scsi_queuecmd,
55 .can_queue = ATA_DEF_QUEUE,
56 .this_id = ATA_SHT_THIS_ID,
57 .sg_tablesize = LIBATA_MAX_PRD,
58 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
59 .emulated = ATA_SHT_EMULATED,
60 .use_clustering = ATA_SHT_USE_CLUSTERING,
61 .proc_name = DRV_NAME,
62 .dma_boundary = ATA_DMA_BOUNDARY,
63 .slave_configure = ata_scsi_slave_config,
64 .slave_destroy = ata_scsi_slave_destroy,
65 /* Use standard CHS mapping rules */
66 .bios_param = ata_std_bios_param,
69 static const struct ata_port_operations phison_ops = {
70 /* Task file is PCI ATA format, use helpers */
71 .tf_load = ata_tf_load,
72 .tf_read = ata_tf_read,
73 .check_status = ata_check_status,
74 .exec_command = ata_exec_command,
75 .dev_select = ata_std_dev_select,
77 .freeze = ata_bmdma_freeze,
78 .thaw = ata_bmdma_thaw,
79 .error_handler = phison_error_handler,
80 .post_internal_cmd = ata_bmdma_post_internal_cmd,
82 /* BMDMA handling is PCI ATA format, use helpers */
83 .bmdma_setup = ata_bmdma_setup,
84 .bmdma_start = ata_bmdma_start,
85 .bmdma_stop = ata_bmdma_stop,
86 .bmdma_status = ata_bmdma_status,
87 .qc_prep = ata_qc_prep,
88 .qc_issue = ata_qc_issue_prot,
89 .data_xfer = ata_data_xfer,
91 /* IRQ-related hooks */
92 .irq_handler = ata_interrupt,
93 .irq_clear = ata_bmdma_irq_clear,
96 /* Generic PATA PCI ATA helpers */
97 .port_start = ata_port_start,
100 static int phison_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
102 struct ata_port_info info = {
104 .flags = ATA_FLAG_NO_ATAPI,
108 .udma_mask = ATA_UDMA5,
110 .port_ops = &phison_ops,
114 const struct ata_port_info *ppi[] = { &info, NULL };
116 ret = ata_pci_init_one(pdev, ppi);
118 dev_dbg(&pdev->dev, "phison_init_one(), ret = %x\n", ret);
123 static struct pci_device_id phison_pci_tbl[] = {
124 { PCI_VENDOR_ID_PHISON, PCI_DEVICE_ID_PS5000, PCI_ANY_ID, PCI_ANY_ID,
125 PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 0 },
128 MODULE_DEVICE_TABLE(pci, phison_pci_tbl);
130 static struct pci_driver phison_pci_driver = {
132 .id_table = phison_pci_tbl,
133 .probe = phison_init_one,
134 .remove = ata_pci_remove_one,
135 #ifdef CONFIG_PM /* haven't tested it. */
136 .suspend = ata_pci_device_suspend,
137 .resume = ata_pci_device_resume,
141 static int phison_ide_init(void)
143 return pci_register_driver(&phison_pci_driver);
146 static void phison_ide_exit(void)
148 pci_unregister_driver(&phison_pci_driver);
151 module_init(phison_ide_init);
152 module_exit(phison_ide_exit);
154 MODULE_AUTHOR("Evan Ko");
155 MODULE_DESCRIPTION("PCIE driver module for PHISON PS5000 E-BOX");
156 MODULE_LICENSE("GPL");
157 MODULE_VERSION(DRV_VERSION);