Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *    pata_netcell.c - Netcell PATA driver
0004  *
0005  *  (c) 2006 Red Hat
0006  */
0007 
0008 #include <linux/kernel.h>
0009 #include <linux/module.h>
0010 #include <linux/pci.h>
0011 #include <linux/blkdev.h>
0012 #include <linux/delay.h>
0013 #include <linux/device.h>
0014 #include <scsi/scsi_host.h>
0015 #include <linux/libata.h>
0016 #include <linux/ata.h>
0017 
0018 #define DRV_NAME    "pata_netcell"
0019 #define DRV_VERSION "0.1.7"
0020 
0021 /* No PIO or DMA methods needed for this device */
0022 
0023 static unsigned int netcell_read_id(struct ata_device *adev,
0024                     struct ata_taskfile *tf, __le16 *id)
0025 {
0026     unsigned int err_mask = ata_do_dev_read_id(adev, tf, id);
0027 
0028     /* Firmware forgets to mark words 85-87 valid */
0029     if (err_mask == 0)
0030         id[ATA_ID_CSF_DEFAULT] |= cpu_to_le16(0x4000);
0031     return err_mask;
0032 }
0033 
0034 static struct scsi_host_template netcell_sht = {
0035     ATA_BMDMA_SHT(DRV_NAME),
0036 };
0037 
0038 static struct ata_port_operations netcell_ops = {
0039     .inherits   = &ata_bmdma_port_ops,
0040     .cable_detect   = ata_cable_80wire,
0041     .read_id    = netcell_read_id,
0042 };
0043 
0044 
0045 /**
0046  *  netcell_init_one - Register Netcell ATA PCI device with kernel services
0047  *  @pdev: PCI device to register
0048  *  @ent: Entry in netcell_pci_tbl matching with @pdev
0049  *
0050  *  Called from kernel PCI layer.
0051  *
0052  *  LOCKING:
0053  *  Inherited from PCI layer (may sleep).
0054  *
0055  *  RETURNS:
0056  *  Zero on success, or -ERRNO value.
0057  */
0058 
0059 static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
0060 {
0061     static const struct ata_port_info info = {
0062         .flags      = ATA_FLAG_SLAVE_POSS,
0063         /* Actually we don't really care about these as the
0064            firmware deals with it */
0065         .pio_mask   = ATA_PIO4,
0066         .mwdma_mask = ATA_MWDMA2,
0067         .udma_mask  = ATA_UDMA5, /* UDMA 133 */
0068         .port_ops   = &netcell_ops,
0069     };
0070     const struct ata_port_info *port_info[] = { &info, NULL };
0071     int rc;
0072 
0073     ata_print_version_once(&pdev->dev, DRV_VERSION);
0074 
0075     rc = pcim_enable_device(pdev);
0076     if (rc)
0077         return rc;
0078 
0079     /* Any chip specific setup/optimisation/messages here */
0080     ata_pci_bmdma_clear_simplex(pdev);
0081 
0082     /* And let the library code do the work */
0083     return ata_pci_bmdma_init_one(pdev, port_info, &netcell_sht, NULL, 0);
0084 }
0085 
0086 static const struct pci_device_id netcell_pci_tbl[] = {
0087     { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), },
0088 
0089     { } /* terminate list */
0090 };
0091 
0092 static struct pci_driver netcell_pci_driver = {
0093     .name           = DRV_NAME,
0094     .id_table       = netcell_pci_tbl,
0095     .probe          = netcell_init_one,
0096     .remove         = ata_pci_remove_one,
0097 #ifdef CONFIG_PM_SLEEP
0098     .suspend        = ata_pci_device_suspend,
0099     .resume         = ata_pci_device_resume,
0100 #endif
0101 };
0102 
0103 module_pci_driver(netcell_pci_driver);
0104 
0105 MODULE_AUTHOR("Alan Cox");
0106 MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID");
0107 MODULE_LICENSE("GPL");
0108 MODULE_DEVICE_TABLE(pci, netcell_pci_tbl);
0109 MODULE_VERSION(DRV_VERSION);