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" 193b4ba591SAlan Cox #define DRV_VERSION "0.1.7" 20669a5db4SJeff Garzik 21669a5db4SJeff Garzik /* No PIO or DMA methods needed for this device */ 22669a5db4SJeff Garzik 23669a5db4SJeff Garzik static struct scsi_host_template netcell_sht = { 24669a5db4SJeff Garzik .module = THIS_MODULE, 25669a5db4SJeff Garzik .name = DRV_NAME, 26669a5db4SJeff Garzik .ioctl = ata_scsi_ioctl, 27669a5db4SJeff Garzik .queuecommand = ata_scsi_queuecmd, 28669a5db4SJeff Garzik .can_queue = ATA_DEF_QUEUE, 29669a5db4SJeff Garzik .this_id = ATA_SHT_THIS_ID, 30669a5db4SJeff Garzik .sg_tablesize = LIBATA_MAX_PRD, 31669a5db4SJeff Garzik .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 32669a5db4SJeff Garzik .emulated = ATA_SHT_EMULATED, 33669a5db4SJeff Garzik .use_clustering = ATA_SHT_USE_CLUSTERING, 34669a5db4SJeff Garzik .proc_name = DRV_NAME, 35669a5db4SJeff Garzik .dma_boundary = ATA_DMA_BOUNDARY, 36669a5db4SJeff Garzik .slave_configure = ata_scsi_slave_config, 37afdfe899STejun Heo .slave_destroy = ata_scsi_slave_destroy, 38669a5db4SJeff Garzik /* Use standard CHS mapping rules */ 39669a5db4SJeff Garzik .bios_param = ata_std_bios_param, 40438ac6d5STejun Heo #ifdef CONFIG_PM 4130ced0f0SAlan .resume = ata_scsi_device_resume, 4230ced0f0SAlan .suspend = ata_scsi_device_suspend, 43438ac6d5STejun Heo #endif 44669a5db4SJeff Garzik }; 45669a5db4SJeff Garzik 46669a5db4SJeff Garzik static const struct ata_port_operations netcell_ops = { 47669a5db4SJeff Garzik .port_disable = ata_port_disable, 48669a5db4SJeff Garzik 49669a5db4SJeff Garzik /* Task file is PCI ATA format, use helpers */ 50669a5db4SJeff Garzik .tf_load = ata_tf_load, 51669a5db4SJeff Garzik .tf_read = ata_tf_read, 52669a5db4SJeff Garzik .check_status = ata_check_status, 53669a5db4SJeff Garzik .exec_command = ata_exec_command, 54669a5db4SJeff Garzik .dev_select = ata_std_dev_select, 55669a5db4SJeff Garzik 56669a5db4SJeff Garzik .freeze = ata_bmdma_freeze, 57669a5db4SJeff Garzik .thaw = ata_bmdma_thaw, 583b4ba591SAlan Cox .error_handler = ata_bmdma_error_handler, 59669a5db4SJeff Garzik .post_internal_cmd = ata_bmdma_post_internal_cmd, 603b4ba591SAlan Cox .cable_detect = ata_cable_80wire, 61669a5db4SJeff Garzik 62669a5db4SJeff Garzik /* BMDMA handling is PCI ATA format, use helpers */ 63669a5db4SJeff Garzik .bmdma_setup = ata_bmdma_setup, 64669a5db4SJeff Garzik .bmdma_start = ata_bmdma_start, 65669a5db4SJeff Garzik .bmdma_stop = ata_bmdma_stop, 66669a5db4SJeff Garzik .bmdma_status = ata_bmdma_status, 67669a5db4SJeff Garzik .qc_prep = ata_qc_prep, 68669a5db4SJeff Garzik .qc_issue = ata_qc_issue_prot, 690d5ff566STejun Heo .data_xfer = ata_data_xfer, 70669a5db4SJeff Garzik 71bda30288SJeff Garzik /* IRQ-related hooks */ 72669a5db4SJeff Garzik .irq_handler = ata_interrupt, 73669a5db4SJeff Garzik .irq_clear = ata_bmdma_irq_clear, 74246ce3b6SAkira Iguchi .irq_on = ata_irq_on, 75246ce3b6SAkira Iguchi .irq_ack = ata_irq_ack, 76669a5db4SJeff Garzik 77669a5db4SJeff Garzik /* Generic PATA PCI ATA helpers */ 78669a5db4SJeff Garzik .port_start = ata_port_start, 79669a5db4SJeff Garzik }; 80669a5db4SJeff Garzik 81669a5db4SJeff Garzik 82669a5db4SJeff Garzik /** 83669a5db4SJeff Garzik * netcell_init_one - Register Netcell ATA PCI device with kernel services 84669a5db4SJeff Garzik * @pdev: PCI device to register 85669a5db4SJeff Garzik * @ent: Entry in netcell_pci_tbl matching with @pdev 86669a5db4SJeff Garzik * 87669a5db4SJeff Garzik * Called from kernel PCI layer. 88669a5db4SJeff Garzik * 89669a5db4SJeff Garzik * LOCKING: 90669a5db4SJeff Garzik * Inherited from PCI layer (may sleep). 91669a5db4SJeff Garzik * 92669a5db4SJeff Garzik * RETURNS: 93669a5db4SJeff Garzik * Zero on success, or -ERRNO value. 94669a5db4SJeff Garzik */ 95669a5db4SJeff Garzik 96669a5db4SJeff Garzik static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 97669a5db4SJeff Garzik { 98669a5db4SJeff Garzik static int printed_version; 99669a5db4SJeff Garzik static struct ata_port_info info = { 100669a5db4SJeff Garzik .sht = &netcell_sht, 101669a5db4SJeff Garzik .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 102669a5db4SJeff Garzik /* Actually we don't really care about these as the 103669a5db4SJeff Garzik firmware deals with it */ 104669a5db4SJeff Garzik .pio_mask = 0x1f, /* pio0-4 */ 105669a5db4SJeff Garzik .mwdma_mask = 0x07, /* mwdma0-2 */ 106669a5db4SJeff Garzik .udma_mask = 0x3f, /* UDMA 133 */ 107669a5db4SJeff Garzik .port_ops = &netcell_ops, 108669a5db4SJeff Garzik }; 109669a5db4SJeff Garzik static struct ata_port_info *port_info[2] = { &info, &info }; 110669a5db4SJeff Garzik 111669a5db4SJeff Garzik if (!printed_version++) 112669a5db4SJeff Garzik dev_printk(KERN_DEBUG, &pdev->dev, 113669a5db4SJeff Garzik "version " DRV_VERSION "\n"); 114669a5db4SJeff Garzik 115669a5db4SJeff Garzik /* Any chip specific setup/optimisation/messages here */ 116669a5db4SJeff Garzik ata_pci_clear_simplex(pdev); 117669a5db4SJeff Garzik 118669a5db4SJeff Garzik /* And let the library code do the work */ 119669a5db4SJeff Garzik return ata_pci_init_one(pdev, port_info, 2); 120669a5db4SJeff Garzik } 121669a5db4SJeff Garzik 122669a5db4SJeff Garzik static const struct pci_device_id netcell_pci_tbl[] = { 1232d2744fcSJeff Garzik { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), }, 1242d2744fcSJeff Garzik 125669a5db4SJeff Garzik { } /* terminate list */ 126669a5db4SJeff Garzik }; 127669a5db4SJeff Garzik 128669a5db4SJeff Garzik static struct pci_driver netcell_pci_driver = { 129669a5db4SJeff Garzik .name = DRV_NAME, 130669a5db4SJeff Garzik .id_table = netcell_pci_tbl, 131669a5db4SJeff Garzik .probe = netcell_init_one, 132669a5db4SJeff Garzik .remove = ata_pci_remove_one, 133438ac6d5STejun Heo #ifdef CONFIG_PM 13430ced0f0SAlan .suspend = ata_pci_device_suspend, 13530ced0f0SAlan .resume = ata_pci_device_resume, 136438ac6d5STejun Heo #endif 137669a5db4SJeff Garzik }; 138669a5db4SJeff Garzik 139669a5db4SJeff Garzik static int __init netcell_init(void) 140669a5db4SJeff Garzik { 141669a5db4SJeff Garzik return pci_register_driver(&netcell_pci_driver); 142669a5db4SJeff Garzik } 143669a5db4SJeff Garzik 144669a5db4SJeff Garzik static void __exit netcell_exit(void) 145669a5db4SJeff Garzik { 146669a5db4SJeff Garzik pci_unregister_driver(&netcell_pci_driver); 147669a5db4SJeff Garzik } 148669a5db4SJeff Garzik 149669a5db4SJeff Garzik module_init(netcell_init); 150669a5db4SJeff Garzik module_exit(netcell_exit); 151669a5db4SJeff Garzik 152669a5db4SJeff Garzik MODULE_AUTHOR("Alan Cox"); 153669a5db4SJeff Garzik MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID"); 154669a5db4SJeff Garzik MODULE_LICENSE("GPL"); 155669a5db4SJeff Garzik MODULE_DEVICE_TABLE(pci, netcell_pci_tbl); 156669a5db4SJeff Garzik MODULE_VERSION(DRV_VERSION); 157669a5db4SJeff Garzik 158