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 | |
| 27 | static const struct ata_port_operations netcell_ops = { |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 28 | /* Task file is PCI ATA format, use helpers */ |
| 29 | .tf_load = ata_tf_load, |
| 30 | .tf_read = ata_tf_read, |
| 31 | .check_status = ata_check_status, |
| 32 | .exec_command = ata_exec_command, |
| 33 | .dev_select = ata_std_dev_select, |
| 34 | |
Tejun Heo | 6bd99b4 | 2008-03-25 12:22:48 +0900 | [diff] [blame] | 35 | .mode_filter = ata_pci_default_filter, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 36 | .freeze = ata_bmdma_freeze, |
| 37 | .thaw = ata_bmdma_thaw, |
Alan Cox | 3b4ba59 | 2007-03-26 21:43:40 -0800 | [diff] [blame] | 38 | .error_handler = ata_bmdma_error_handler, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 39 | .post_internal_cmd = ata_bmdma_post_internal_cmd, |
Alan Cox | 3b4ba59 | 2007-03-26 21:43:40 -0800 | [diff] [blame] | 40 | .cable_detect = ata_cable_80wire, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 41 | |
| 42 | /* BMDMA handling is PCI ATA format, use helpers */ |
| 43 | .bmdma_setup = ata_bmdma_setup, |
| 44 | .bmdma_start = ata_bmdma_start, |
| 45 | .bmdma_stop = ata_bmdma_stop, |
| 46 | .bmdma_status = ata_bmdma_status, |
| 47 | .qc_prep = ata_qc_prep, |
| 48 | .qc_issue = ata_qc_issue_prot, |
Tejun Heo | 0d5ff56 | 2007-02-01 15:06:36 +0900 | [diff] [blame] | 49 | .data_xfer = ata_data_xfer, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 50 | |
Jeff Garzik | bda3028 | 2006-09-27 05:41:13 -0400 | [diff] [blame] | 51 | /* IRQ-related hooks */ |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 52 | .irq_handler = ata_interrupt, |
| 53 | .irq_clear = ata_bmdma_irq_clear, |
Akira Iguchi | 246ce3b | 2007-01-26 16:27:58 +0900 | [diff] [blame] | 54 | .irq_on = ata_irq_on, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 55 | |
| 56 | /* Generic PATA PCI ATA helpers */ |
Alan Cox | 81ad183 | 2007-08-22 22:55:41 +0100 | [diff] [blame] | 57 | .port_start = ata_sff_port_start, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | |
| 61 | /** |
| 62 | * netcell_init_one - Register Netcell ATA PCI device with kernel services |
| 63 | * @pdev: PCI device to register |
| 64 | * @ent: Entry in netcell_pci_tbl matching with @pdev |
| 65 | * |
| 66 | * Called from kernel PCI layer. |
| 67 | * |
| 68 | * LOCKING: |
| 69 | * Inherited from PCI layer (may sleep). |
| 70 | * |
| 71 | * RETURNS: |
| 72 | * Zero on success, or -ERRNO value. |
| 73 | */ |
| 74 | |
| 75 | static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
| 76 | { |
| 77 | static int printed_version; |
Tejun Heo | 1626aeb | 2007-05-04 12:43:58 +0200 | [diff] [blame] | 78 | static const struct ata_port_info info = { |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 79 | .sht = &netcell_sht, |
Jeff Garzik | 1d2808f | 2007-05-28 06:59:48 -0400 | [diff] [blame] | 80 | .flags = ATA_FLAG_SLAVE_POSS, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 81 | /* Actually we don't really care about these as the |
| 82 | firmware deals with it */ |
| 83 | .pio_mask = 0x1f, /* pio0-4 */ |
| 84 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
Jeff Garzik | bf6263a | 2007-07-09 12:16:50 -0400 | [diff] [blame] | 85 | .udma_mask = ATA_UDMA5, /* UDMA 133 */ |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 86 | .port_ops = &netcell_ops, |
| 87 | }; |
Tejun Heo | 1626aeb | 2007-05-04 12:43:58 +0200 | [diff] [blame] | 88 | const struct ata_port_info *port_info[] = { &info, NULL }; |
Tejun Heo | f08048e | 2008-03-25 12:22:47 +0900 | [diff] [blame] | 89 | int rc; |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 90 | |
| 91 | if (!printed_version++) |
| 92 | dev_printk(KERN_DEBUG, &pdev->dev, |
| 93 | "version " DRV_VERSION "\n"); |
| 94 | |
Tejun Heo | f08048e | 2008-03-25 12:22:47 +0900 | [diff] [blame] | 95 | rc = pcim_enable_device(pdev); |
| 96 | if (rc) |
| 97 | return rc; |
| 98 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 99 | /* Any chip specific setup/optimisation/messages here */ |
| 100 | ata_pci_clear_simplex(pdev); |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 101 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 102 | /* And let the library code do the work */ |
Tejun Heo | 1626aeb | 2007-05-04 12:43:58 +0200 | [diff] [blame] | 103 | return ata_pci_init_one(pdev, port_info); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | static const struct pci_device_id netcell_pci_tbl[] = { |
Jeff Garzik | 2d2744f | 2006-09-28 20:21:59 -0400 | [diff] [blame] | 107 | { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), }, |
| 108 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 109 | { } /* terminate list */ |
| 110 | }; |
| 111 | |
| 112 | static struct pci_driver netcell_pci_driver = { |
| 113 | .name = DRV_NAME, |
| 114 | .id_table = netcell_pci_tbl, |
| 115 | .probe = netcell_init_one, |
| 116 | .remove = ata_pci_remove_one, |
Tejun Heo | 438ac6d | 2007-03-02 17:31:26 +0900 | [diff] [blame] | 117 | #ifdef CONFIG_PM |
Alan | 30ced0f | 2006-11-22 16:57:36 +0000 | [diff] [blame] | 118 | .suspend = ata_pci_device_suspend, |
| 119 | .resume = ata_pci_device_resume, |
Tejun Heo | 438ac6d | 2007-03-02 17:31:26 +0900 | [diff] [blame] | 120 | #endif |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | static int __init netcell_init(void) |
| 124 | { |
| 125 | return pci_register_driver(&netcell_pci_driver); |
| 126 | } |
| 127 | |
| 128 | static void __exit netcell_exit(void) |
| 129 | { |
| 130 | pci_unregister_driver(&netcell_pci_driver); |
| 131 | } |
| 132 | |
| 133 | module_init(netcell_init); |
| 134 | module_exit(netcell_exit); |
| 135 | |
| 136 | MODULE_AUTHOR("Alan Cox"); |
| 137 | MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID"); |
| 138 | MODULE_LICENSE("GPL"); |
| 139 | MODULE_DEVICE_TABLE(pci, netcell_pci_tbl); |
| 140 | MODULE_VERSION(DRV_VERSION); |
| 141 | |