]> Pileus Git - ~andy/linux/blob - drivers/staging/phison/phison.c
Staging: phison: fix up checkpatch and other formatting issues
[~andy/linux] / drivers / staging / phison / phison.c
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
25 #define DRV_NAME                "phison_e-box"  /* #0003 */
26 #define DRV_VERSION             "0.91"          /* #0003 */
27
28 #define PCI_VENDOR_ID_PHISON    0x1987
29 #define PCI_DEVICE_ID_PS5000    0x5000
30
31 static int phison_pre_reset(struct ata_link *link, unsigned long deadline)
32 {
33         int ret;
34         struct ata_port *ap = link->ap;
35
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);
39         return ret;
40 }
41
42 static void phison_error_handler(struct ata_port *ap)
43 {
44         dev_dbg(ap->dev, "phison_error_handler()\n");
45         return ata_bmdma_drive_eh(ap, phison_pre_reset,
46                                   ata_std_softreset, NULL,
47                                   ata_std_postreset);
48 }
49
50 static struct scsi_host_template phison_sht = {
51         .module                 = THIS_MODULE,
52         .name                   = DRV_NAME,
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,
67 };
68
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,
76
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,
81
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,
90
91         /* IRQ-related hooks */
92         .irq_handler            = ata_interrupt,
93         .irq_clear              = ata_bmdma_irq_clear,
94         .irq_on                 = ata_irq_on,
95
96         /* Generic PATA PCI ATA helpers */
97         .port_start             = ata_port_start,
98 };
99
100 static int phison_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
101 {
102         struct ata_port_info info = {
103                 .sht            = &phison_sht,
104                 .flags  = ATA_FLAG_NO_ATAPI,
105
106                 .pio_mask       = 0x1f,
107                 .mwdma_mask     = 0x07,
108                 .udma_mask      = ATA_UDMA5,
109
110                 .port_ops       = &phison_ops,
111         };
112         int ret;
113
114         const struct ata_port_info *ppi[] = { &info, NULL };
115
116         ret = ata_pci_init_one(pdev, ppi);
117
118         dev_dbg(&pdev->dev, "phison_init_one(), ret = %x\n", ret);
119
120         return ret;
121 }
122
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 },
126         { 0, },
127 };
128 MODULE_DEVICE_TABLE(pci, phison_pci_tbl);
129
130 static struct pci_driver phison_pci_driver = {
131         .name           = DRV_NAME,
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,
138 #endif
139 };
140
141 static int phison_ide_init(void)
142 {
143         return pci_register_driver(&phison_pci_driver);
144 }
145
146 static void phison_ide_exit(void)
147 {
148         pci_unregister_driver(&phison_pci_driver);
149 }
150
151 module_init(phison_ide_init);
152 module_exit(phison_ide_exit);
153
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);