pata_netcell.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * pata_netcell.c - Netcell PATA driver
  4. *
  5. * (c) 2006 Red Hat
  6. */
  7. #include <linux/kernel.h>
  8. #include <linux/module.h>
  9. #include <linux/pci.h>
  10. #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. #define DRV_NAME "pata_netcell"
  17. #define DRV_VERSION "0.1.7"
  18. /* No PIO or DMA methods needed for this device */
  19. static unsigned int netcell_read_id(struct ata_device *adev,
  20. struct ata_taskfile *tf, u16 *id)
  21. {
  22. unsigned int err_mask = ata_do_dev_read_id(adev, tf, id);
  23. /* Firmware forgets to mark words 85-87 valid */
  24. if (err_mask == 0)
  25. id[ATA_ID_CSF_DEFAULT] |= 0x4000;
  26. return err_mask;
  27. }
  28. static struct scsi_host_template netcell_sht = {
  29. ATA_BMDMA_SHT(DRV_NAME),
  30. };
  31. static struct ata_port_operations netcell_ops = {
  32. .inherits = &ata_bmdma_port_ops,
  33. .cable_detect = ata_cable_80wire,
  34. .read_id = netcell_read_id,
  35. };
  36. /**
  37. * netcell_init_one - Register Netcell ATA PCI device with kernel services
  38. * @pdev: PCI device to register
  39. * @ent: Entry in netcell_pci_tbl matching with @pdev
  40. *
  41. * Called from kernel PCI layer.
  42. *
  43. * LOCKING:
  44. * Inherited from PCI layer (may sleep).
  45. *
  46. * RETURNS:
  47. * Zero on success, or -ERRNO value.
  48. */
  49. static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
  50. {
  51. static const struct ata_port_info info = {
  52. .flags = ATA_FLAG_SLAVE_POSS,
  53. /* Actually we don't really care about these as the
  54. firmware deals with it */
  55. .pio_mask = ATA_PIO4,
  56. .mwdma_mask = ATA_MWDMA2,
  57. .udma_mask = ATA_UDMA5, /* UDMA 133 */
  58. .port_ops = &netcell_ops,
  59. };
  60. const struct ata_port_info *port_info[] = { &info, NULL };
  61. int rc;
  62. ata_print_version_once(&pdev->dev, DRV_VERSION);
  63. rc = pcim_enable_device(pdev);
  64. if (rc)
  65. return rc;
  66. /* Any chip specific setup/optimisation/messages here */
  67. ata_pci_bmdma_clear_simplex(pdev);
  68. /* And let the library code do the work */
  69. return ata_pci_bmdma_init_one(pdev, port_info, &netcell_sht, NULL, 0);
  70. }
  71. static const struct pci_device_id netcell_pci_tbl[] = {
  72. { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), },
  73. { } /* terminate list */
  74. };
  75. static struct pci_driver netcell_pci_driver = {
  76. .name = DRV_NAME,
  77. .id_table = netcell_pci_tbl,
  78. .probe = netcell_init_one,
  79. .remove = ata_pci_remove_one,
  80. #ifdef CONFIG_PM_SLEEP
  81. .suspend = ata_pci_device_suspend,
  82. .resume = ata_pci_device_resume,
  83. #endif
  84. };
  85. module_pci_driver(netcell_pci_driver);
  86. MODULE_AUTHOR("Alan Cox");
  87. MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID");
  88. MODULE_LICENSE("GPL");
  89. MODULE_DEVICE_TABLE(pci, netcell_pci_tbl);
  90. MODULE_VERSION(DRV_VERSION);