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 int phison_pre_reset(struct ata_link *link, unsigned long deadline)
34 struct ata_port *ap = link->ap;
35 ap->cbl = ATA_CBL_NONE;
36 ret = ata_std_prereset(link, deadline);
38 printk("****** phison_pre_reset(), ret = %x ******\n", ret);
43 void phison_error_handler(struct ata_port *ap)
46 printk("****** phison_error_handler() ******\n");
48 return ata_bmdma_drive_eh(ap, phison_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
51 struct scsi_host_template phison_sht = {
52 .module = THIS_MODULE,
54 .ioctl = ata_scsi_ioctl,
55 .queuecommand = ata_scsi_queuecmd,
56 .can_queue = ATA_DEF_QUEUE,
57 .this_id = ATA_SHT_THIS_ID,
58 .sg_tablesize = LIBATA_MAX_PRD,
59 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
60 .emulated = ATA_SHT_EMULATED,
61 .use_clustering = ATA_SHT_USE_CLUSTERING,
62 .proc_name = DRV_NAME,
63 .dma_boundary = ATA_DMA_BOUNDARY,
64 .slave_configure = ata_scsi_slave_config,
65 .slave_destroy = ata_scsi_slave_destroy,
66 /* Use standard CHS mapping rules */
67 .bios_param = ata_std_bios_param,
70 const struct ata_port_operations phison_ops = {
71 /* Task file is PCI ATA format, use helpers */
72 .tf_load = ata_tf_load,
73 .tf_read = ata_tf_read,
74 .check_status = ata_check_status,
75 .exec_command = ata_exec_command,
76 .dev_select = ata_std_dev_select,
78 .freeze = ata_bmdma_freeze,
79 .thaw = ata_bmdma_thaw,
80 .error_handler = phison_error_handler,
81 .post_internal_cmd = ata_bmdma_post_internal_cmd,
83 /* BMDMA handling is PCI ATA format, use helpers */
84 .bmdma_setup = ata_bmdma_setup,
85 .bmdma_start = ata_bmdma_start,
86 .bmdma_stop = ata_bmdma_stop,
87 .bmdma_status = ata_bmdma_status,
88 .qc_prep = ata_qc_prep,
89 .qc_issue = ata_qc_issue_prot,
90 .data_xfer = ata_data_xfer,
92 /* IRQ-related hooks */
93 .irq_handler = ata_interrupt,
94 .irq_clear = ata_bmdma_irq_clear,
97 /* Generic PATA PCI ATA helpers */
98 .port_start = ata_port_start,
101 int phison_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
103 struct ata_port_info info = {
105 .flags = ATA_FLAG_NO_ATAPI,
109 .udma_mask = ATA_UDMA5,
111 .port_ops = &phison_ops,
115 const struct ata_port_info *ppi[] = { &info, NULL };
117 ret = ata_pci_init_one(pdev, ppi);
120 printk("****** phison_init_one(), ret = %x ******\n", ret);
127 struct pci_device_id phison_pci_tbl[] = {
128 { PCI_VENDOR_ID_PHISON, PCI_DEVICE_ID_PS5000, PCI_ANY_ID, PCI_ANY_ID,
129 PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 0 },
133 MODULE_DEVICE_TABLE(pci, phison_pci_tbl);
135 struct pci_driver phison_pci_driver = {
137 .id_table = phison_pci_tbl,
138 .probe = phison_init_one,
139 .remove = ata_pci_remove_one,
140 #ifdef CONFIG_PM //haven't test it.
141 .suspend = ata_pci_device_suspend,
142 .resume = ata_pci_device_resume,
146 int phison_ide_init(void)
149 struct pci_dev *pci_dev = NULL;
150 struct pci_dev *ps5k_dev = NULL;
153 u32 addr1,addr2,addr3, addr4,addr5,addr6;
155 printk("****** phison_ide_init ******\n");
161 pci_dev = pci_find_device(PCI_ANY_ID,PCI_ANY_ID, pci_dev);
165 pci_read_config_word(pci_dev, 0, &pid);
166 pci_read_config_word(pci_dev, 2, &vid);
167 pci_read_config_dword(pci_dev, 16, &addr1);
168 pci_read_config_dword(pci_dev, 16, &addr1);
169 pci_read_config_dword(pci_dev, 16, &addr1);
170 pci_read_config_dword(pci_dev, 16, &addr1);
171 pci_read_config_dword(pci_dev, 20, &addr2);
172 pci_read_config_dword(pci_dev, 24, &addr3);
173 pci_read_config_dword(pci_dev, 28, &addr4);
174 pci_read_config_dword(pci_dev, 32, &addr5);
175 pci_read_config_dword(pci_dev, 36, &addr6);
177 printk("****** <0x%02x>, %x, %x, %x,%x,%x,%x,%x,%x ******\n", i, pid, vid, addr1, addr2, addr3, addr4,addr5,addr6);
180 if((pid==PCI_VENDOR_ID_PHISON)&&(vid==PCI_DEVICE_ID_PS5000)) ps5k_dev = pci_dev;
184 if(i==0) printk("****** no pci device found ******\n");
191 ret = pci_register_driver(&phison_pci_driver);
192 printk("****** PS5000 found, Ret = %x ******\n", ret);
196 printk("****** PS5000 not found ******\n");
201 ret = pci_register_driver(&phison_pci_driver);
204 printk("****** phison_ide_init(), ret = %x ******\n", ret);
213 void phison_ide_exit(void)
216 printk("****** phison_ide_exit() ******\n");
218 pci_unregister_driver(&phison_pci_driver);
221 module_init(phison_ide_init);
222 module_exit(phison_ide_exit);
224 MODULE_AUTHOR("Evan Ko");
225 MODULE_DESCRIPTION("PCIE driver module for PHISON PS5000 E-BOX");//#0003
226 MODULE_LICENSE("GPL");
227 MODULE_VERSION(DRV_VERSION);