]> err.no Git - linux-2.6/blob - drivers/ata/pata_netcell.c
libata: normalize port_info, port_operations and sht tables
[linux-2.6] / drivers / ata / pata_netcell.c
1 /*
2  *    pata_netcell.c - Netcell PATA driver
3  *
4  *      (c) 2006 Red Hat  <alan@redhat.com>
5  */
6
7 #include <linux/kernel.h>
8 #include <linux/module.h>
9 #include <linux/pci.h>
10 #include <linux/init.h>
11 #include <linux/blkdev.h>
12 #include <linux/delay.h>
13 #include <linux/device.h>
14 #include <scsi/scsi_host.h>
15 #include <linux/libata.h>
16 #include <linux/ata.h>
17
18 #define DRV_NAME        "pata_netcell"
19 #define DRV_VERSION     "0.1.7"
20
21 /* No PIO or DMA methods needed for this device */
22
23 static struct scsi_host_template netcell_sht = {
24         .module                 = THIS_MODULE,
25         .name                   = DRV_NAME,
26         .ioctl                  = ata_scsi_ioctl,
27         .queuecommand           = ata_scsi_queuecmd,
28         .can_queue              = ATA_DEF_QUEUE,
29         .this_id                = ATA_SHT_THIS_ID,
30         .sg_tablesize           = LIBATA_MAX_PRD,
31         .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
32         .emulated               = ATA_SHT_EMULATED,
33         .use_clustering         = ATA_SHT_USE_CLUSTERING,
34         .proc_name              = DRV_NAME,
35         .dma_boundary           = ATA_DMA_BOUNDARY,
36         .slave_configure        = ata_scsi_slave_config,
37         .slave_destroy          = ata_scsi_slave_destroy,
38         /* Use standard CHS mapping rules */
39         .bios_param             = ata_std_bios_param,
40 };
41
42 static const struct ata_port_operations netcell_ops = {
43         /* Task file is PCI ATA format, use helpers */
44         .tf_load                = ata_tf_load,
45         .tf_read                = ata_tf_read,
46         .check_status           = ata_check_status,
47         .exec_command           = ata_exec_command,
48         .dev_select             = ata_std_dev_select,
49
50         .mode_filter            = ata_pci_default_filter,
51         .freeze                 = ata_bmdma_freeze,
52         .thaw                   = ata_bmdma_thaw,
53         .error_handler          = ata_bmdma_error_handler,
54         .post_internal_cmd      = ata_bmdma_post_internal_cmd,
55         .cable_detect           = ata_cable_80wire,
56
57         /* BMDMA handling is PCI ATA format, use helpers */
58         .bmdma_setup            = ata_bmdma_setup,
59         .bmdma_start            = ata_bmdma_start,
60         .bmdma_stop             = ata_bmdma_stop,
61         .bmdma_status           = ata_bmdma_status,
62         .qc_prep                = ata_qc_prep,
63         .qc_issue               = ata_qc_issue_prot,
64         .data_xfer              = ata_data_xfer,
65
66         /* IRQ-related hooks */
67         .irq_handler            = ata_interrupt,
68         .irq_clear              = ata_bmdma_irq_clear,
69         .irq_on                 = ata_irq_on,
70
71         /* Generic PATA PCI ATA helpers */
72         .port_start             = ata_sff_port_start,
73 };
74
75
76 /**
77  *      netcell_init_one - Register Netcell ATA PCI device with kernel services
78  *      @pdev: PCI device to register
79  *      @ent: Entry in netcell_pci_tbl matching with @pdev
80  *
81  *      Called from kernel PCI layer.
82  *
83  *      LOCKING:
84  *      Inherited from PCI layer (may sleep).
85  *
86  *      RETURNS:
87  *      Zero on success, or -ERRNO value.
88  */
89
90 static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
91 {
92         static int printed_version;
93         static const struct ata_port_info info = {
94                 .sht            = &netcell_sht,
95                 .flags          = ATA_FLAG_SLAVE_POSS,
96                 /* Actually we don't really care about these as the
97                    firmware deals with it */
98                 .pio_mask       = 0x1f, /* pio0-4 */
99                 .mwdma_mask     = 0x07, /* mwdma0-2 */
100                 .udma_mask      = ATA_UDMA5, /* UDMA 133 */
101                 .port_ops       = &netcell_ops,
102         };
103         const struct ata_port_info *port_info[] = { &info, NULL };
104         int rc;
105
106         if (!printed_version++)
107                 dev_printk(KERN_DEBUG, &pdev->dev,
108                            "version " DRV_VERSION "\n");
109
110         rc = pcim_enable_device(pdev);
111         if (rc)
112                 return rc;
113
114         /* Any chip specific setup/optimisation/messages here */
115         ata_pci_clear_simplex(pdev);
116
117         /* And let the library code do the work */
118         return ata_pci_init_one(pdev, port_info);
119 }
120
121 static const struct pci_device_id netcell_pci_tbl[] = {
122         { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), },
123
124         { }     /* terminate list */
125 };
126
127 static struct pci_driver netcell_pci_driver = {
128         .name                   = DRV_NAME,
129         .id_table               = netcell_pci_tbl,
130         .probe                  = netcell_init_one,
131         .remove                 = ata_pci_remove_one,
132 #ifdef CONFIG_PM
133         .suspend                = ata_pci_device_suspend,
134         .resume                 = ata_pci_device_resume,
135 #endif
136 };
137
138 static int __init netcell_init(void)
139 {
140         return pci_register_driver(&netcell_pci_driver);
141 }
142
143 static void __exit netcell_exit(void)
144 {
145         pci_unregister_driver(&netcell_pci_driver);
146 }
147
148 module_init(netcell_init);
149 module_exit(netcell_exit);
150
151 MODULE_AUTHOR("Alan Cox");
152 MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID");
153 MODULE_LICENSE("GPL");
154 MODULE_DEVICE_TABLE(pci, netcell_pci_tbl);
155 MODULE_VERSION(DRV_VERSION);
156