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