| 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" | 
|  | 19 | #define DRV_VERSION	"0.1.5" | 
|  | 20 |  | 
|  | 21 | /** | 
|  | 22 | *	netcell_probe_init	-	check for 40/80 pin | 
|  | 23 | *	@ap: Port | 
|  | 24 | * | 
|  | 25 | *	Cables are handled by the RAID controller. Report 80 pin. | 
|  | 26 | */ | 
| Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 27 |  | 
| Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 28 | static int netcell_pre_reset(struct ata_port *ap) | 
|  | 29 | { | 
|  | 30 | ap->cbl = ATA_CBL_PATA80; | 
|  | 31 | return ata_std_prereset(ap); | 
|  | 32 | } | 
|  | 33 |  | 
|  | 34 | /** | 
|  | 35 | *	netcell_probe_reset - Probe specified port on PATA host controller | 
|  | 36 | *	@ap: Port to probe | 
|  | 37 | * | 
|  | 38 | *	LOCKING: | 
|  | 39 | *	None (inherited from caller). | 
|  | 40 | */ | 
|  | 41 |  | 
|  | 42 | static void netcell_error_handler(struct ata_port *ap) | 
|  | 43 | { | 
|  | 44 | return ata_bmdma_drive_eh(ap, netcell_pre_reset, ata_std_softreset, NULL, ata_std_postreset); | 
|  | 45 | } | 
|  | 46 |  | 
|  | 47 | /* No PIO or DMA methods needed for this device */ | 
|  | 48 |  | 
|  | 49 | static struct scsi_host_template netcell_sht = { | 
|  | 50 | .module			= THIS_MODULE, | 
|  | 51 | .name			= DRV_NAME, | 
|  | 52 | .ioctl			= ata_scsi_ioctl, | 
|  | 53 | .queuecommand		= ata_scsi_queuecmd, | 
|  | 54 | .can_queue		= ATA_DEF_QUEUE, | 
|  | 55 | .this_id		= ATA_SHT_THIS_ID, | 
|  | 56 | .sg_tablesize		= LIBATA_MAX_PRD, | 
|  | 57 | /* Special handling needed if you have sector or LBA48 limits */ | 
|  | 58 | .max_sectors		= ATA_MAX_SECTORS, | 
|  | 59 | .cmd_per_lun		= ATA_SHT_CMD_PER_LUN, | 
|  | 60 | .emulated		= ATA_SHT_EMULATED, | 
|  | 61 | .use_clustering		= ATA_SHT_USE_CLUSTERING, | 
|  | 62 | .proc_name		= DRV_NAME, | 
|  | 63 | .dma_boundary		= ATA_DMA_BOUNDARY, | 
|  | 64 | .slave_configure	= ata_scsi_slave_config, | 
|  | 65 | /* Use standard CHS mapping rules */ | 
|  | 66 | .bios_param		= ata_std_bios_param, | 
|  | 67 | }; | 
|  | 68 |  | 
|  | 69 | static const struct ata_port_operations netcell_ops = { | 
|  | 70 | .port_disable		= ata_port_disable, | 
|  | 71 |  | 
|  | 72 | /* Task file is PCI ATA format, use helpers */ | 
|  | 73 | .tf_load		= ata_tf_load, | 
|  | 74 | .tf_read		= ata_tf_read, | 
|  | 75 | .check_status		= ata_check_status, | 
|  | 76 | .exec_command		= ata_exec_command, | 
|  | 77 | .dev_select		= ata_std_dev_select, | 
|  | 78 |  | 
|  | 79 | .freeze			= ata_bmdma_freeze, | 
|  | 80 | .thaw			= ata_bmdma_thaw, | 
|  | 81 | .error_handler		= netcell_error_handler, | 
|  | 82 | .post_internal_cmd	= ata_bmdma_post_internal_cmd, | 
|  | 83 |  | 
|  | 84 | /* BMDMA handling is PCI ATA format, use helpers */ | 
|  | 85 | .bmdma_setup		= ata_bmdma_setup, | 
|  | 86 | .bmdma_start		= ata_bmdma_start, | 
|  | 87 | .bmdma_stop		= ata_bmdma_stop, | 
|  | 88 | .bmdma_status		= ata_bmdma_status, | 
|  | 89 | .qc_prep		= ata_qc_prep, | 
|  | 90 | .qc_issue		= ata_qc_issue_prot, | 
|  | 91 | .data_xfer		= ata_pio_data_xfer, | 
|  | 92 |  | 
| Jeff Garzik | bda3028 | 2006-09-27 05:41:13 -0400 | [diff] [blame] | 93 | /* IRQ-related hooks */ | 
| Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 94 | .irq_handler		= ata_interrupt, | 
|  | 95 | .irq_clear		= ata_bmdma_irq_clear, | 
|  | 96 |  | 
|  | 97 | /* Generic PATA PCI ATA helpers */ | 
|  | 98 | .port_start		= ata_port_start, | 
|  | 99 | .port_stop		= ata_port_stop, | 
|  | 100 | .host_stop		= ata_host_stop, | 
|  | 101 | }; | 
|  | 102 |  | 
|  | 103 |  | 
|  | 104 | /** | 
|  | 105 | *	netcell_init_one - Register Netcell ATA PCI device with kernel services | 
|  | 106 | *	@pdev: PCI device to register | 
|  | 107 | *	@ent: Entry in netcell_pci_tbl matching with @pdev | 
|  | 108 | * | 
|  | 109 | *	Called from kernel PCI layer. | 
|  | 110 | * | 
|  | 111 | *	LOCKING: | 
|  | 112 | *	Inherited from PCI layer (may sleep). | 
|  | 113 | * | 
|  | 114 | *	RETURNS: | 
|  | 115 | *	Zero on success, or -ERRNO value. | 
|  | 116 | */ | 
|  | 117 |  | 
|  | 118 | static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 
|  | 119 | { | 
|  | 120 | static int printed_version; | 
|  | 121 | static struct ata_port_info info = { | 
|  | 122 | .sht		= &netcell_sht, | 
|  | 123 | .flags		= ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 
|  | 124 | /* Actually we don't really care about these as the | 
|  | 125 | firmware deals with it */ | 
|  | 126 | .pio_mask	= 0x1f,	/* pio0-4 */ | 
|  | 127 | .mwdma_mask	= 0x07, /* mwdma0-2 */ | 
|  | 128 | .udma_mask 	= 0x3f, /* UDMA 133 */ | 
|  | 129 | .port_ops	= &netcell_ops, | 
|  | 130 | }; | 
|  | 131 | static struct ata_port_info *port_info[2] = { &info, &info }; | 
|  | 132 |  | 
|  | 133 | if (!printed_version++) | 
|  | 134 | dev_printk(KERN_DEBUG, &pdev->dev, | 
|  | 135 | "version " DRV_VERSION "\n"); | 
|  | 136 |  | 
|  | 137 | /* Any chip specific setup/optimisation/messages here */ | 
|  | 138 | ata_pci_clear_simplex(pdev); | 
| Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 139 |  | 
| Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 140 | /* And let the library code do the work */ | 
|  | 141 | return ata_pci_init_one(pdev, port_info, 2); | 
|  | 142 | } | 
|  | 143 |  | 
|  | 144 | static const struct pci_device_id netcell_pci_tbl[] = { | 
| Jeff Garzik | 2d2744f | 2006-09-28 20:21:59 -0400 | [diff] [blame] | 145 | { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), }, | 
|  | 146 |  | 
| Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 147 | { }	/* terminate list */ | 
|  | 148 | }; | 
|  | 149 |  | 
|  | 150 | static struct pci_driver netcell_pci_driver = { | 
|  | 151 | .name			= DRV_NAME, | 
|  | 152 | .id_table		= netcell_pci_tbl, | 
|  | 153 | .probe			= netcell_init_one, | 
|  | 154 | .remove			= ata_pci_remove_one, | 
|  | 155 | }; | 
|  | 156 |  | 
|  | 157 | static int __init netcell_init(void) | 
|  | 158 | { | 
|  | 159 | return pci_register_driver(&netcell_pci_driver); | 
|  | 160 | } | 
|  | 161 |  | 
|  | 162 | static void __exit netcell_exit(void) | 
|  | 163 | { | 
|  | 164 | pci_unregister_driver(&netcell_pci_driver); | 
|  | 165 | } | 
|  | 166 |  | 
|  | 167 | module_init(netcell_init); | 
|  | 168 | module_exit(netcell_exit); | 
|  | 169 |  | 
|  | 170 | MODULE_AUTHOR("Alan Cox"); | 
|  | 171 | MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID"); | 
|  | 172 | MODULE_LICENSE("GPL"); | 
|  | 173 | MODULE_DEVICE_TABLE(pci, netcell_pci_tbl); | 
|  | 174 | MODULE_VERSION(DRV_VERSION); | 
|  | 175 |  |