blob: 0ea18331d4669cf8bad844f64f6a8070880abf1d [file] [log] [blame]
Jeff Garzik669a5db2006-08-29 18:12:40 -04001/*
2 * pata_netcell.c - Netcell PATA driver
3 *
Alan Coxab771632008-10-27 15:09:10 +00004 * (c) 2006 Red Hat
Jeff Garzik669a5db2006-08-29 18:12:40 -04005 */
6
7#include <linux/kernel.h>
8#include <linux/module.h>
9#include <linux/pci.h>
Jeff Garzik669a5db2006-08-29 18:12:40 -040010#include <linux/blkdev.h>
11#include <linux/delay.h>
12#include <linux/device.h>
13#include <scsi/scsi_host.h>
14#include <linux/libata.h>
15#include <linux/ata.h>
16
17#define DRV_NAME "pata_netcell"
Alan Cox3b4ba592007-03-26 21:43:40 -080018#define DRV_VERSION "0.1.7"
Jeff Garzik669a5db2006-08-29 18:12:40 -040019
20/* No PIO or DMA methods needed for this device */
21
Alan Coxd3ae33e2009-06-02 12:34:31 +010022static unsigned int netcell_read_id(struct ata_device *adev,
23 struct ata_taskfile *tf, u16 *id)
24{
25 unsigned int err_mask = ata_do_dev_read_id(adev, tf, id);
26 /* Firmware forgets to mark words 85-87 valid */
27 if (err_mask == 0)
Alan Cox5284c6b2009-06-08 12:31:00 +010028 id[ATA_ID_CSF_DEFAULT] |= 0x4000;
Alan Coxd3ae33e2009-06-02 12:34:31 +010029 return err_mask;
30}
31
Jeff Garzik669a5db2006-08-29 18:12:40 -040032static struct scsi_host_template netcell_sht = {
Tejun Heo68d1d072008-03-25 12:22:49 +090033 ATA_BMDMA_SHT(DRV_NAME),
Jeff Garzik669a5db2006-08-29 18:12:40 -040034};
35
Tejun Heo029cfd62008-03-25 12:22:49 +090036static struct ata_port_operations netcell_ops = {
37 .inherits = &ata_bmdma_port_ops,
Alan Coxd3ae33e2009-06-02 12:34:31 +010038 .cable_detect = ata_cable_80wire,
39 .read_id = netcell_read_id,
Jeff Garzik669a5db2006-08-29 18:12:40 -040040};
41
42
43/**
44 * netcell_init_one - Register Netcell ATA PCI device with kernel services
45 * @pdev: PCI device to register
46 * @ent: Entry in netcell_pci_tbl matching with @pdev
47 *
48 * Called from kernel PCI layer.
49 *
50 * LOCKING:
51 * Inherited from PCI layer (may sleep).
52 *
53 * RETURNS:
54 * Zero on success, or -ERRNO value.
55 */
56
57static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
58{
Tejun Heo1626aeb2007-05-04 12:43:58 +020059 static const struct ata_port_info info = {
Jeff Garzik1d2808f2007-05-28 06:59:48 -040060 .flags = ATA_FLAG_SLAVE_POSS,
Jeff Garzik669a5db2006-08-29 18:12:40 -040061 /* Actually we don't really care about these as the
62 firmware deals with it */
Erik Inge Bolsø14bdef92009-03-14 21:38:24 +010063 .pio_mask = ATA_PIO4,
64 .mwdma_mask = ATA_MWDMA2,
Jeff Garzikbf6263a2007-07-09 12:16:50 -040065 .udma_mask = ATA_UDMA5, /* UDMA 133 */
Jeff Garzik669a5db2006-08-29 18:12:40 -040066 .port_ops = &netcell_ops,
67 };
Tejun Heo1626aeb2007-05-04 12:43:58 +020068 const struct ata_port_info *port_info[] = { &info, NULL };
Tejun Heof08048e2008-03-25 12:22:47 +090069 int rc;
Jeff Garzik669a5db2006-08-29 18:12:40 -040070
Joe Perches06296a12011-04-15 15:52:00 -070071 ata_print_version_once(&pdev->dev, DRV_VERSION);
Jeff Garzik669a5db2006-08-29 18:12:40 -040072
Tejun Heof08048e2008-03-25 12:22:47 +090073 rc = pcim_enable_device(pdev);
74 if (rc)
75 return rc;
76
Jeff Garzik669a5db2006-08-29 18:12:40 -040077 /* Any chip specific setup/optimisation/messages here */
Tejun Heo9363c382008-04-07 22:47:16 +090078 ata_pci_bmdma_clear_simplex(pdev);
Jeff Garzik85cd7252006-08-31 00:03:49 -040079
Jeff Garzik669a5db2006-08-29 18:12:40 -040080 /* And let the library code do the work */
Tejun Heo1c5afdf2010-05-19 22:10:22 +020081 return ata_pci_bmdma_init_one(pdev, port_info, &netcell_sht, NULL, 0);
Jeff Garzik669a5db2006-08-29 18:12:40 -040082}
83
84static const struct pci_device_id netcell_pci_tbl[] = {
Jeff Garzik2d2744f2006-09-28 20:21:59 -040085 { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), },
86
Jeff Garzik669a5db2006-08-29 18:12:40 -040087 { } /* terminate list */
88};
89
90static struct pci_driver netcell_pci_driver = {
91 .name = DRV_NAME,
92 .id_table = netcell_pci_tbl,
93 .probe = netcell_init_one,
94 .remove = ata_pci_remove_one,
Bartlomiej Zolnierkiewicz58eb8cd2014-05-07 17:17:44 +020095#ifdef CONFIG_PM_SLEEP
Alan30ced0f2006-11-22 16:57:36 +000096 .suspend = ata_pci_device_suspend,
97 .resume = ata_pci_device_resume,
Tejun Heo438ac6d2007-03-02 17:31:26 +090098#endif
Jeff Garzik669a5db2006-08-29 18:12:40 -040099};
100
Axel Lin2fc75da2012-04-19 13:43:05 +0800101module_pci_driver(netcell_pci_driver);
Jeff Garzik669a5db2006-08-29 18:12:40 -0400102
103MODULE_AUTHOR("Alan Cox");
104MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID");
105MODULE_LICENSE("GPL");
106MODULE_DEVICE_TABLE(pci, netcell_pci_tbl);
107MODULE_VERSION(DRV_VERSION);