blob: 65389d1837b3694bdbd2e38875c76f1f51604360 [file] [log] [blame]
Jeff Garzik669a5db2006-08-29 18:12:40 -04001/*
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"
Alan Cox3b4ba592007-03-26 21:43:40 -080019#define DRV_VERSION "0.1.7"
Jeff Garzik669a5db2006-08-29 18:12:40 -040020
21/* No PIO or DMA methods needed for this device */
22
23static struct scsi_host_template netcell_sht = {
Tejun Heo68d1d072008-03-25 12:22:49 +090024 ATA_BMDMA_SHT(DRV_NAME),
Jeff Garzik669a5db2006-08-29 18:12:40 -040025};
26
Tejun Heo029cfd62008-03-25 12:22:49 +090027static struct ata_port_operations netcell_ops = {
28 .inherits = &ata_bmdma_port_ops,
Alan Cox3b4ba592007-03-26 21:43:40 -080029 .cable_detect = ata_cable_80wire,
Jeff Garzik669a5db2006-08-29 18:12:40 -040030};
31
32
33/**
34 * netcell_init_one - Register Netcell ATA PCI device with kernel services
35 * @pdev: PCI device to register
36 * @ent: Entry in netcell_pci_tbl matching with @pdev
37 *
38 * Called from kernel PCI layer.
39 *
40 * LOCKING:
41 * Inherited from PCI layer (may sleep).
42 *
43 * RETURNS:
44 * Zero on success, or -ERRNO value.
45 */
46
47static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
48{
49 static int printed_version;
Tejun Heo1626aeb2007-05-04 12:43:58 +020050 static const struct ata_port_info info = {
Jeff Garzik669a5db2006-08-29 18:12:40 -040051 .sht = &netcell_sht,
Jeff Garzik1d2808f2007-05-28 06:59:48 -040052 .flags = ATA_FLAG_SLAVE_POSS,
Jeff Garzik669a5db2006-08-29 18:12:40 -040053 /* Actually we don't really care about these as the
54 firmware deals with it */
55 .pio_mask = 0x1f, /* pio0-4 */
56 .mwdma_mask = 0x07, /* mwdma0-2 */
Jeff Garzikbf6263a2007-07-09 12:16:50 -040057 .udma_mask = ATA_UDMA5, /* UDMA 133 */
Jeff Garzik669a5db2006-08-29 18:12:40 -040058 .port_ops = &netcell_ops,
59 };
Tejun Heo1626aeb2007-05-04 12:43:58 +020060 const struct ata_port_info *port_info[] = { &info, NULL };
Tejun Heof08048e2008-03-25 12:22:47 +090061 int rc;
Jeff Garzik669a5db2006-08-29 18:12:40 -040062
63 if (!printed_version++)
64 dev_printk(KERN_DEBUG, &pdev->dev,
65 "version " DRV_VERSION "\n");
66
Tejun Heof08048e2008-03-25 12:22:47 +090067 rc = pcim_enable_device(pdev);
68 if (rc)
69 return rc;
70
Jeff Garzik669a5db2006-08-29 18:12:40 -040071 /* Any chip specific setup/optimisation/messages here */
72 ata_pci_clear_simplex(pdev);
Jeff Garzik85cd7252006-08-31 00:03:49 -040073
Jeff Garzik669a5db2006-08-29 18:12:40 -040074 /* And let the library code do the work */
Tejun Heo1626aeb2007-05-04 12:43:58 +020075 return ata_pci_init_one(pdev, port_info);
Jeff Garzik669a5db2006-08-29 18:12:40 -040076}
77
78static const struct pci_device_id netcell_pci_tbl[] = {
Jeff Garzik2d2744f2006-09-28 20:21:59 -040079 { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), },
80
Jeff Garzik669a5db2006-08-29 18:12:40 -040081 { } /* terminate list */
82};
83
84static struct pci_driver netcell_pci_driver = {
85 .name = DRV_NAME,
86 .id_table = netcell_pci_tbl,
87 .probe = netcell_init_one,
88 .remove = ata_pci_remove_one,
Tejun Heo438ac6d2007-03-02 17:31:26 +090089#ifdef CONFIG_PM
Alan30ced0f2006-11-22 16:57:36 +000090 .suspend = ata_pci_device_suspend,
91 .resume = ata_pci_device_resume,
Tejun Heo438ac6d2007-03-02 17:31:26 +090092#endif
Jeff Garzik669a5db2006-08-29 18:12:40 -040093};
94
95static int __init netcell_init(void)
96{
97 return pci_register_driver(&netcell_pci_driver);
98}
99
100static void __exit netcell_exit(void)
101{
102 pci_unregister_driver(&netcell_pci_driver);
103}
104
105module_init(netcell_init);
106module_exit(netcell_exit);
107
108MODULE_AUTHOR("Alan Cox");
109MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID");
110MODULE_LICENSE("GPL");
111MODULE_DEVICE_TABLE(pci, netcell_pci_tbl);
112MODULE_VERSION(DRV_VERSION);
113