Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 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" |
Alan Cox | 3b4ba59 | 2007-03-26 21:43:40 -0800 | [diff] [blame] | 19 | #define DRV_VERSION "0.1.7" |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 20 | |
| 21 | /* No PIO or DMA methods needed for this device */ |
| 22 | |
| 23 | static struct scsi_host_template netcell_sht = { |
Tejun Heo | 68d1d07 | 2008-03-25 12:22:49 +0900 | [diff] [blame] | 24 | ATA_BMDMA_SHT(DRV_NAME), |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 25 | }; |
| 26 | |
Tejun Heo | 029cfd6 | 2008-03-25 12:22:49 +0900 | [diff] [blame] | 27 | static struct ata_port_operations netcell_ops = { |
| 28 | .inherits = &ata_bmdma_port_ops, |
Alan Cox | 3b4ba59 | 2007-03-26 21:43:40 -0800 | [diff] [blame] | 29 | .cable_detect = ata_cable_80wire, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 30 | }; |
| 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 | |
| 47 | static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
| 48 | { |
| 49 | static int printed_version; |
Tejun Heo | 1626aeb | 2007-05-04 12:43:58 +0200 | [diff] [blame] | 50 | static const struct ata_port_info info = { |
Jeff Garzik | 1d2808f | 2007-05-28 06:59:48 -0400 | [diff] [blame] | 51 | .flags = ATA_FLAG_SLAVE_POSS, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 52 | /* Actually we don't really care about these as the |
| 53 | firmware deals with it */ |
| 54 | .pio_mask = 0x1f, /* pio0-4 */ |
| 55 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
Jeff Garzik | bf6263a | 2007-07-09 12:16:50 -0400 | [diff] [blame] | 56 | .udma_mask = ATA_UDMA5, /* UDMA 133 */ |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 57 | .port_ops = &netcell_ops, |
| 58 | }; |
Tejun Heo | 1626aeb | 2007-05-04 12:43:58 +0200 | [diff] [blame] | 59 | const struct ata_port_info *port_info[] = { &info, NULL }; |
Tejun Heo | f08048e | 2008-03-25 12:22:47 +0900 | [diff] [blame] | 60 | int rc; |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 61 | |
| 62 | if (!printed_version++) |
| 63 | dev_printk(KERN_DEBUG, &pdev->dev, |
| 64 | "version " DRV_VERSION "\n"); |
| 65 | |
Tejun Heo | f08048e | 2008-03-25 12:22:47 +0900 | [diff] [blame] | 66 | rc = pcim_enable_device(pdev); |
| 67 | if (rc) |
| 68 | return rc; |
| 69 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 70 | /* Any chip specific setup/optimisation/messages here */ |
| 71 | ata_pci_clear_simplex(pdev); |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 72 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 73 | /* And let the library code do the work */ |
Tejun Heo | 887125e | 2008-03-25 12:22:49 +0900 | [diff] [blame] | 74 | return ata_pci_init_one(pdev, port_info, &netcell_sht, NULL); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | static const struct pci_device_id netcell_pci_tbl[] = { |
Jeff Garzik | 2d2744f | 2006-09-28 20:21:59 -0400 | [diff] [blame] | 78 | { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), }, |
| 79 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 80 | { } /* terminate list */ |
| 81 | }; |
| 82 | |
| 83 | static struct pci_driver netcell_pci_driver = { |
| 84 | .name = DRV_NAME, |
| 85 | .id_table = netcell_pci_tbl, |
| 86 | .probe = netcell_init_one, |
| 87 | .remove = ata_pci_remove_one, |
Tejun Heo | 438ac6d | 2007-03-02 17:31:26 +0900 | [diff] [blame] | 88 | #ifdef CONFIG_PM |
Alan | 30ced0f | 2006-11-22 16:57:36 +0000 | [diff] [blame] | 89 | .suspend = ata_pci_device_suspend, |
| 90 | .resume = ata_pci_device_resume, |
Tejun Heo | 438ac6d | 2007-03-02 17:31:26 +0900 | [diff] [blame] | 91 | #endif |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | static int __init netcell_init(void) |
| 95 | { |
| 96 | return pci_register_driver(&netcell_pci_driver); |
| 97 | } |
| 98 | |
| 99 | static void __exit netcell_exit(void) |
| 100 | { |
| 101 | pci_unregister_driver(&netcell_pci_driver); |
| 102 | } |
| 103 | |
| 104 | module_init(netcell_init); |
| 105 | module_exit(netcell_exit); |
| 106 | |
| 107 | MODULE_AUTHOR("Alan Cox"); |
| 108 | MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID"); |
| 109 | MODULE_LICENSE("GPL"); |
| 110 | MODULE_DEVICE_TABLE(pci, netcell_pci_tbl); |
| 111 | MODULE_VERSION(DRV_VERSION); |
| 112 | |