1669a5db4SJeff Garzik /* 2669a5db4SJeff Garzik * pata_netcell.c - Netcell PATA driver 3669a5db4SJeff Garzik * 4669a5db4SJeff Garzik * (c) 2006 Red Hat <alan@redhat.com> 5669a5db4SJeff Garzik */ 6669a5db4SJeff Garzik 7669a5db4SJeff Garzik #include <linux/kernel.h> 8669a5db4SJeff Garzik #include <linux/module.h> 9669a5db4SJeff Garzik #include <linux/pci.h> 10669a5db4SJeff Garzik #include <linux/init.h> 11669a5db4SJeff Garzik #include <linux/blkdev.h> 12669a5db4SJeff Garzik #include <linux/delay.h> 13669a5db4SJeff Garzik #include <linux/device.h> 14669a5db4SJeff Garzik #include <scsi/scsi_host.h> 15669a5db4SJeff Garzik #include <linux/libata.h> 16669a5db4SJeff Garzik #include <linux/ata.h> 17669a5db4SJeff Garzik 18669a5db4SJeff Garzik #define DRV_NAME "pata_netcell" 19669a5db4SJeff Garzik #define DRV_VERSION "0.1.5" 20669a5db4SJeff Garzik 21669a5db4SJeff Garzik /** 22669a5db4SJeff Garzik * netcell_probe_init - check for 40/80 pin 23669a5db4SJeff Garzik * @ap: Port 24669a5db4SJeff Garzik * 25669a5db4SJeff Garzik * Cables are handled by the RAID controller. Report 80 pin. 26669a5db4SJeff Garzik */ 27669a5db4SJeff Garzik 28669a5db4SJeff Garzik static int netcell_pre_reset(struct ata_port *ap) 29669a5db4SJeff Garzik { 30669a5db4SJeff Garzik ap->cbl = ATA_CBL_PATA80; 31669a5db4SJeff Garzik return ata_std_prereset(ap); 32669a5db4SJeff Garzik } 33669a5db4SJeff Garzik 34669a5db4SJeff Garzik /** 35669a5db4SJeff Garzik * netcell_probe_reset - Probe specified port on PATA host controller 36669a5db4SJeff Garzik * @ap: Port to probe 37669a5db4SJeff Garzik * 38669a5db4SJeff Garzik * LOCKING: 39669a5db4SJeff Garzik * None (inherited from caller). 40669a5db4SJeff Garzik */ 41669a5db4SJeff Garzik 42669a5db4SJeff Garzik static void netcell_error_handler(struct ata_port *ap) 43669a5db4SJeff Garzik { 44669a5db4SJeff Garzik return ata_bmdma_drive_eh(ap, netcell_pre_reset, ata_std_softreset, NULL, ata_std_postreset); 45669a5db4SJeff Garzik } 46669a5db4SJeff Garzik 47669a5db4SJeff Garzik /* No PIO or DMA methods needed for this device */ 48669a5db4SJeff Garzik 49669a5db4SJeff Garzik static struct scsi_host_template netcell_sht = { 50669a5db4SJeff Garzik .module = THIS_MODULE, 51669a5db4SJeff Garzik .name = DRV_NAME, 52669a5db4SJeff Garzik .ioctl = ata_scsi_ioctl, 53669a5db4SJeff Garzik .queuecommand = ata_scsi_queuecmd, 54669a5db4SJeff Garzik .can_queue = ATA_DEF_QUEUE, 55669a5db4SJeff Garzik .this_id = ATA_SHT_THIS_ID, 56669a5db4SJeff Garzik .sg_tablesize = LIBATA_MAX_PRD, 57669a5db4SJeff Garzik /* Special handling needed if you have sector or LBA48 limits */ 58669a5db4SJeff Garzik .max_sectors = ATA_MAX_SECTORS, 59669a5db4SJeff Garzik .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 60669a5db4SJeff Garzik .emulated = ATA_SHT_EMULATED, 61669a5db4SJeff Garzik .use_clustering = ATA_SHT_USE_CLUSTERING, 62669a5db4SJeff Garzik .proc_name = DRV_NAME, 63669a5db4SJeff Garzik .dma_boundary = ATA_DMA_BOUNDARY, 64669a5db4SJeff Garzik .slave_configure = ata_scsi_slave_config, 65669a5db4SJeff Garzik /* Use standard CHS mapping rules */ 66669a5db4SJeff Garzik .bios_param = ata_std_bios_param, 67669a5db4SJeff Garzik }; 68669a5db4SJeff Garzik 69669a5db4SJeff Garzik static const struct ata_port_operations netcell_ops = { 70669a5db4SJeff Garzik .port_disable = ata_port_disable, 71669a5db4SJeff Garzik 72669a5db4SJeff Garzik /* Task file is PCI ATA format, use helpers */ 73669a5db4SJeff Garzik .tf_load = ata_tf_load, 74669a5db4SJeff Garzik .tf_read = ata_tf_read, 75669a5db4SJeff Garzik .check_status = ata_check_status, 76669a5db4SJeff Garzik .exec_command = ata_exec_command, 77669a5db4SJeff Garzik .dev_select = ata_std_dev_select, 78669a5db4SJeff Garzik 79669a5db4SJeff Garzik .freeze = ata_bmdma_freeze, 80669a5db4SJeff Garzik .thaw = ata_bmdma_thaw, 81669a5db4SJeff Garzik .error_handler = netcell_error_handler, 82669a5db4SJeff Garzik .post_internal_cmd = ata_bmdma_post_internal_cmd, 83669a5db4SJeff Garzik 84669a5db4SJeff Garzik /* BMDMA handling is PCI ATA format, use helpers */ 85669a5db4SJeff Garzik .bmdma_setup = ata_bmdma_setup, 86669a5db4SJeff Garzik .bmdma_start = ata_bmdma_start, 87669a5db4SJeff Garzik .bmdma_stop = ata_bmdma_stop, 88669a5db4SJeff Garzik .bmdma_status = ata_bmdma_status, 89669a5db4SJeff Garzik .qc_prep = ata_qc_prep, 90669a5db4SJeff Garzik .qc_issue = ata_qc_issue_prot, 91669a5db4SJeff Garzik .data_xfer = ata_pio_data_xfer, 92669a5db4SJeff Garzik 93bda30288SJeff Garzik /* IRQ-related hooks */ 94669a5db4SJeff Garzik .irq_handler = ata_interrupt, 95669a5db4SJeff Garzik .irq_clear = ata_bmdma_irq_clear, 96669a5db4SJeff Garzik 97669a5db4SJeff Garzik /* Generic PATA PCI ATA helpers */ 98669a5db4SJeff Garzik .port_start = ata_port_start, 99669a5db4SJeff Garzik .port_stop = ata_port_stop, 100669a5db4SJeff Garzik .host_stop = ata_host_stop, 101669a5db4SJeff Garzik }; 102669a5db4SJeff Garzik 103669a5db4SJeff Garzik 104669a5db4SJeff Garzik /** 105669a5db4SJeff Garzik * netcell_init_one - Register Netcell ATA PCI device with kernel services 106669a5db4SJeff Garzik * @pdev: PCI device to register 107669a5db4SJeff Garzik * @ent: Entry in netcell_pci_tbl matching with @pdev 108669a5db4SJeff Garzik * 109669a5db4SJeff Garzik * Called from kernel PCI layer. 110669a5db4SJeff Garzik * 111669a5db4SJeff Garzik * LOCKING: 112669a5db4SJeff Garzik * Inherited from PCI layer (may sleep). 113669a5db4SJeff Garzik * 114669a5db4SJeff Garzik * RETURNS: 115669a5db4SJeff Garzik * Zero on success, or -ERRNO value. 116669a5db4SJeff Garzik */ 117669a5db4SJeff Garzik 118669a5db4SJeff Garzik static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 119669a5db4SJeff Garzik { 120669a5db4SJeff Garzik static int printed_version; 121669a5db4SJeff Garzik static struct ata_port_info info = { 122669a5db4SJeff Garzik .sht = &netcell_sht, 123669a5db4SJeff Garzik .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 124669a5db4SJeff Garzik /* Actually we don't really care about these as the 125669a5db4SJeff Garzik firmware deals with it */ 126669a5db4SJeff Garzik .pio_mask = 0x1f, /* pio0-4 */ 127669a5db4SJeff Garzik .mwdma_mask = 0x07, /* mwdma0-2 */ 128669a5db4SJeff Garzik .udma_mask = 0x3f, /* UDMA 133 */ 129669a5db4SJeff Garzik .port_ops = &netcell_ops, 130669a5db4SJeff Garzik }; 131669a5db4SJeff Garzik static struct ata_port_info *port_info[2] = { &info, &info }; 132669a5db4SJeff Garzik 133669a5db4SJeff Garzik if (!printed_version++) 134669a5db4SJeff Garzik dev_printk(KERN_DEBUG, &pdev->dev, 135669a5db4SJeff Garzik "version " DRV_VERSION "\n"); 136669a5db4SJeff Garzik 137669a5db4SJeff Garzik /* Any chip specific setup/optimisation/messages here */ 138669a5db4SJeff Garzik ata_pci_clear_simplex(pdev); 139669a5db4SJeff Garzik 140669a5db4SJeff Garzik /* And let the library code do the work */ 141669a5db4SJeff Garzik return ata_pci_init_one(pdev, port_info, 2); 142669a5db4SJeff Garzik } 143669a5db4SJeff Garzik 144669a5db4SJeff Garzik static const struct pci_device_id netcell_pci_tbl[] = { 1452d2744fcSJeff Garzik { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), }, 1462d2744fcSJeff Garzik 147669a5db4SJeff Garzik { } /* terminate list */ 148669a5db4SJeff Garzik }; 149669a5db4SJeff Garzik 150669a5db4SJeff Garzik static struct pci_driver netcell_pci_driver = { 151669a5db4SJeff Garzik .name = DRV_NAME, 152669a5db4SJeff Garzik .id_table = netcell_pci_tbl, 153669a5db4SJeff Garzik .probe = netcell_init_one, 154669a5db4SJeff Garzik .remove = ata_pci_remove_one, 155669a5db4SJeff Garzik }; 156669a5db4SJeff Garzik 157669a5db4SJeff Garzik static int __init netcell_init(void) 158669a5db4SJeff Garzik { 159669a5db4SJeff Garzik return pci_register_driver(&netcell_pci_driver); 160669a5db4SJeff Garzik } 161669a5db4SJeff Garzik 162669a5db4SJeff Garzik static void __exit netcell_exit(void) 163669a5db4SJeff Garzik { 164669a5db4SJeff Garzik pci_unregister_driver(&netcell_pci_driver); 165669a5db4SJeff Garzik } 166669a5db4SJeff Garzik 167669a5db4SJeff Garzik module_init(netcell_init); 168669a5db4SJeff Garzik module_exit(netcell_exit); 169669a5db4SJeff Garzik 170669a5db4SJeff Garzik MODULE_AUTHOR("Alan Cox"); 171669a5db4SJeff Garzik MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID"); 172669a5db4SJeff Garzik MODULE_LICENSE("GPL"); 173669a5db4SJeff Garzik MODULE_DEVICE_TABLE(pci, netcell_pci_tbl); 174669a5db4SJeff Garzik MODULE_VERSION(DRV_VERSION); 175669a5db4SJeff Garzik 176