109c434b8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 2669a5db4SJeff Garzik /* 3669a5db4SJeff Garzik * pata_netcell.c - Netcell PATA driver 4669a5db4SJeff Garzik * 5ab771630SAlan Cox * (c) 2006 Red Hat 6669a5db4SJeff Garzik */ 7669a5db4SJeff Garzik 8669a5db4SJeff Garzik #include <linux/kernel.h> 9669a5db4SJeff Garzik #include <linux/module.h> 10669a5db4SJeff Garzik #include <linux/pci.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 23d3ae33efSAlan Cox static unsigned int netcell_read_id(struct ata_device *adev, 24*0561e514SDamien Le Moal struct ata_taskfile *tf, __le16 *id) 25d3ae33efSAlan Cox { 26d3ae33efSAlan Cox unsigned int err_mask = ata_do_dev_read_id(adev, tf, id); 27*0561e514SDamien Le Moal 28d3ae33efSAlan Cox /* Firmware forgets to mark words 85-87 valid */ 29d3ae33efSAlan Cox if (err_mask == 0) 30*0561e514SDamien Le Moal id[ATA_ID_CSF_DEFAULT] |= cpu_to_le16(0x4000); 31d3ae33efSAlan Cox return err_mask; 32d3ae33efSAlan Cox } 33d3ae33efSAlan Cox 34669a5db4SJeff Garzik static struct scsi_host_template netcell_sht = { 3568d1d07bSTejun Heo ATA_BMDMA_SHT(DRV_NAME), 36669a5db4SJeff Garzik }; 37669a5db4SJeff Garzik 38029cfd6bSTejun Heo static struct ata_port_operations netcell_ops = { 39029cfd6bSTejun Heo .inherits = &ata_bmdma_port_ops, 403b4ba591SAlan Cox .cable_detect = ata_cable_80wire, 41d3ae33efSAlan Cox .read_id = netcell_read_id, 42669a5db4SJeff Garzik }; 43669a5db4SJeff Garzik 44669a5db4SJeff Garzik 45669a5db4SJeff Garzik /** 46669a5db4SJeff Garzik * netcell_init_one - Register Netcell ATA PCI device with kernel services 47669a5db4SJeff Garzik * @pdev: PCI device to register 48669a5db4SJeff Garzik * @ent: Entry in netcell_pci_tbl matching with @pdev 49669a5db4SJeff Garzik * 50669a5db4SJeff Garzik * Called from kernel PCI layer. 51669a5db4SJeff Garzik * 52669a5db4SJeff Garzik * LOCKING: 53669a5db4SJeff Garzik * Inherited from PCI layer (may sleep). 54669a5db4SJeff Garzik * 55669a5db4SJeff Garzik * RETURNS: 56669a5db4SJeff Garzik * Zero on success, or -ERRNO value. 57669a5db4SJeff Garzik */ 58669a5db4SJeff Garzik 59669a5db4SJeff Garzik static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 60669a5db4SJeff Garzik { 611626aeb8STejun Heo static const struct ata_port_info info = { 621d2808fdSJeff Garzik .flags = ATA_FLAG_SLAVE_POSS, 63669a5db4SJeff Garzik /* Actually we don't really care about these as the 64669a5db4SJeff Garzik firmware deals with it */ 6514bdef98SErik Inge Bolsø .pio_mask = ATA_PIO4, 6614bdef98SErik Inge Bolsø .mwdma_mask = ATA_MWDMA2, 67bf6263a8SJeff Garzik .udma_mask = ATA_UDMA5, /* UDMA 133 */ 68669a5db4SJeff Garzik .port_ops = &netcell_ops, 69669a5db4SJeff Garzik }; 701626aeb8STejun Heo const struct ata_port_info *port_info[] = { &info, NULL }; 71f08048e9STejun Heo int rc; 72669a5db4SJeff Garzik 7306296a1eSJoe Perches ata_print_version_once(&pdev->dev, DRV_VERSION); 74669a5db4SJeff Garzik 75f08048e9STejun Heo rc = pcim_enable_device(pdev); 76f08048e9STejun Heo if (rc) 77f08048e9STejun Heo return rc; 78f08048e9STejun Heo 79669a5db4SJeff Garzik /* Any chip specific setup/optimisation/messages here */ 809363c382STejun Heo ata_pci_bmdma_clear_simplex(pdev); 81669a5db4SJeff Garzik 82669a5db4SJeff Garzik /* And let the library code do the work */ 831c5afdf7STejun Heo return ata_pci_bmdma_init_one(pdev, port_info, &netcell_sht, NULL, 0); 84669a5db4SJeff Garzik } 85669a5db4SJeff Garzik 86669a5db4SJeff Garzik static const struct pci_device_id netcell_pci_tbl[] = { 872d2744fcSJeff Garzik { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), }, 882d2744fcSJeff Garzik 89669a5db4SJeff Garzik { } /* terminate list */ 90669a5db4SJeff Garzik }; 91669a5db4SJeff Garzik 92669a5db4SJeff Garzik static struct pci_driver netcell_pci_driver = { 93669a5db4SJeff Garzik .name = DRV_NAME, 94669a5db4SJeff Garzik .id_table = netcell_pci_tbl, 95669a5db4SJeff Garzik .probe = netcell_init_one, 96669a5db4SJeff Garzik .remove = ata_pci_remove_one, 9758eb8cd5SBartlomiej Zolnierkiewicz #ifdef CONFIG_PM_SLEEP 9830ced0f0SAlan .suspend = ata_pci_device_suspend, 9930ced0f0SAlan .resume = ata_pci_device_resume, 100438ac6d5STejun Heo #endif 101669a5db4SJeff Garzik }; 102669a5db4SJeff Garzik 1032fc75da0SAxel Lin module_pci_driver(netcell_pci_driver); 104669a5db4SJeff Garzik 105669a5db4SJeff Garzik MODULE_AUTHOR("Alan Cox"); 106669a5db4SJeff Garzik MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID"); 107669a5db4SJeff Garzik MODULE_LICENSE("GPL"); 108669a5db4SJeff Garzik MODULE_DEVICE_TABLE(pci, netcell_pci_tbl); 109669a5db4SJeff Garzik MODULE_VERSION(DRV_VERSION); 110