Thomas Gleixner | 09c434b | 2019-05-19 13:08:20 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 2 | /* |
| 3 | * pata_netcell.c - Netcell PATA driver |
| 4 | * |
Alan Cox | ab77163 | 2008-10-27 15:09:10 +0000 | [diff] [blame] | 5 | * (c) 2006 Red Hat |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/kernel.h> |
| 9 | #include <linux/module.h> |
| 10 | #include <linux/pci.h> |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 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 | |
Alan Cox | d3ae33e | 2009-06-02 12:34:31 +0100 | [diff] [blame] | 23 | static unsigned int netcell_read_id(struct ata_device *adev, |
Damien Le Moal | 0561e51 | 2022-01-04 17:54:18 +0900 | [diff] [blame] | 24 | struct ata_taskfile *tf, __le16 *id) |
Alan Cox | d3ae33e | 2009-06-02 12:34:31 +0100 | [diff] [blame] | 25 | { |
| 26 | unsigned int err_mask = ata_do_dev_read_id(adev, tf, id); |
Damien Le Moal | 0561e51 | 2022-01-04 17:54:18 +0900 | [diff] [blame] | 27 | |
Alan Cox | d3ae33e | 2009-06-02 12:34:31 +0100 | [diff] [blame] | 28 | /* Firmware forgets to mark words 85-87 valid */ |
| 29 | if (err_mask == 0) |
Damien Le Moal | 0561e51 | 2022-01-04 17:54:18 +0900 | [diff] [blame] | 30 | id[ATA_ID_CSF_DEFAULT] |= cpu_to_le16(0x4000); |
Alan Cox | d3ae33e | 2009-06-02 12:34:31 +0100 | [diff] [blame] | 31 | return err_mask; |
| 32 | } |
| 33 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 34 | static struct scsi_host_template netcell_sht = { |
Tejun Heo | 68d1d07 | 2008-03-25 12:22:49 +0900 | [diff] [blame] | 35 | ATA_BMDMA_SHT(DRV_NAME), |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 36 | }; |
| 37 | |
Tejun Heo | 029cfd6 | 2008-03-25 12:22:49 +0900 | [diff] [blame] | 38 | static struct ata_port_operations netcell_ops = { |
| 39 | .inherits = &ata_bmdma_port_ops, |
Alan Cox | d3ae33e | 2009-06-02 12:34:31 +0100 | [diff] [blame] | 40 | .cable_detect = ata_cable_80wire, |
| 41 | .read_id = netcell_read_id, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | |
| 45 | /** |
| 46 | * netcell_init_one - Register Netcell ATA PCI device with kernel services |
| 47 | * @pdev: PCI device to register |
| 48 | * @ent: Entry in netcell_pci_tbl matching with @pdev |
| 49 | * |
| 50 | * Called from kernel PCI layer. |
| 51 | * |
| 52 | * LOCKING: |
| 53 | * Inherited from PCI layer (may sleep). |
| 54 | * |
| 55 | * RETURNS: |
| 56 | * Zero on success, or -ERRNO value. |
| 57 | */ |
| 58 | |
| 59 | static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
| 60 | { |
Tejun Heo | 1626aeb | 2007-05-04 12:43:58 +0200 | [diff] [blame] | 61 | static const struct ata_port_info info = { |
Jeff Garzik | 1d2808f | 2007-05-28 06:59:48 -0400 | [diff] [blame] | 62 | .flags = ATA_FLAG_SLAVE_POSS, |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 63 | /* Actually we don't really care about these as the |
| 64 | firmware deals with it */ |
Erik Inge Bolsø | 14bdef9 | 2009-03-14 21:38:24 +0100 | [diff] [blame] | 65 | .pio_mask = ATA_PIO4, |
| 66 | .mwdma_mask = ATA_MWDMA2, |
Jeff Garzik | bf6263a | 2007-07-09 12:16:50 -0400 | [diff] [blame] | 67 | .udma_mask = ATA_UDMA5, /* UDMA 133 */ |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 68 | .port_ops = &netcell_ops, |
| 69 | }; |
Tejun Heo | 1626aeb | 2007-05-04 12:43:58 +0200 | [diff] [blame] | 70 | const struct ata_port_info *port_info[] = { &info, NULL }; |
Tejun Heo | f08048e | 2008-03-25 12:22:47 +0900 | [diff] [blame] | 71 | int rc; |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 72 | |
Joe Perches | 06296a1 | 2011-04-15 15:52:00 -0700 | [diff] [blame] | 73 | ata_print_version_once(&pdev->dev, DRV_VERSION); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 74 | |
Tejun Heo | f08048e | 2008-03-25 12:22:47 +0900 | [diff] [blame] | 75 | rc = pcim_enable_device(pdev); |
| 76 | if (rc) |
| 77 | return rc; |
| 78 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 79 | /* Any chip specific setup/optimisation/messages here */ |
Tejun Heo | 9363c38 | 2008-04-07 22:47:16 +0900 | [diff] [blame] | 80 | ata_pci_bmdma_clear_simplex(pdev); |
Jeff Garzik | 85cd725 | 2006-08-31 00:03:49 -0400 | [diff] [blame] | 81 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 82 | /* And let the library code do the work */ |
Tejun Heo | 1c5afdf | 2010-05-19 22:10:22 +0200 | [diff] [blame] | 83 | return ata_pci_bmdma_init_one(pdev, port_info, &netcell_sht, NULL, 0); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | static const struct pci_device_id netcell_pci_tbl[] = { |
Jeff Garzik | 2d2744f | 2006-09-28 20:21:59 -0400 | [diff] [blame] | 87 | { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), }, |
| 88 | |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 89 | { } /* terminate list */ |
| 90 | }; |
| 91 | |
| 92 | static struct pci_driver netcell_pci_driver = { |
| 93 | .name = DRV_NAME, |
| 94 | .id_table = netcell_pci_tbl, |
| 95 | .probe = netcell_init_one, |
| 96 | .remove = ata_pci_remove_one, |
Bartlomiej Zolnierkiewicz | 58eb8cd | 2014-05-07 17:17:44 +0200 | [diff] [blame] | 97 | #ifdef CONFIG_PM_SLEEP |
Alan | 30ced0f | 2006-11-22 16:57:36 +0000 | [diff] [blame] | 98 | .suspend = ata_pci_device_suspend, |
| 99 | .resume = ata_pci_device_resume, |
Tejun Heo | 438ac6d | 2007-03-02 17:31:26 +0900 | [diff] [blame] | 100 | #endif |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 101 | }; |
| 102 | |
Axel Lin | 2fc75da | 2012-04-19 13:43:05 +0800 | [diff] [blame] | 103 | module_pci_driver(netcell_pci_driver); |
Jeff Garzik | 669a5db | 2006-08-29 18:12:40 -0400 | [diff] [blame] | 104 | |
| 105 | MODULE_AUTHOR("Alan Cox"); |
| 106 | MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID"); |
| 107 | MODULE_LICENSE("GPL"); |
| 108 | MODULE_DEVICE_TABLE(pci, netcell_pci_tbl); |
| 109 | MODULE_VERSION(DRV_VERSION); |