pata_netcell.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * pata_netcell.c - Netcell PATA driver
  3. *
  4. * (c) 2006 Red Hat <alan@redhat.com>
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/module.h>
  8. #include <linux/pci.h>
  9. #include <linux/init.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 struct scsi_host_template netcell_sht = {
  20. .module = THIS_MODULE,
  21. .name = DRV_NAME,
  22. .ioctl = ata_scsi_ioctl,
  23. .queuecommand = ata_scsi_queuecmd,
  24. .can_queue = ATA_DEF_QUEUE,
  25. .this_id = ATA_SHT_THIS_ID,
  26. .sg_tablesize = LIBATA_MAX_PRD,
  27. .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
  28. .emulated = ATA_SHT_EMULATED,
  29. .use_clustering = ATA_SHT_USE_CLUSTERING,
  30. .proc_name = DRV_NAME,
  31. .dma_boundary = ATA_DMA_BOUNDARY,
  32. .slave_configure = ata_scsi_slave_config,
  33. .slave_destroy = ata_scsi_slave_destroy,
  34. /* Use standard CHS mapping rules */
  35. .bios_param = ata_std_bios_param,
  36. };
  37. static const struct ata_port_operations netcell_ops = {
  38. /* Task file is PCI ATA format, use helpers */
  39. .tf_load = ata_tf_load,
  40. .tf_read = ata_tf_read,
  41. .check_status = ata_check_status,
  42. .exec_command = ata_exec_command,
  43. .dev_select = ata_std_dev_select,
  44. .freeze = ata_bmdma_freeze,
  45. .thaw = ata_bmdma_thaw,
  46. .error_handler = ata_bmdma_error_handler,
  47. .post_internal_cmd = ata_bmdma_post_internal_cmd,
  48. .cable_detect = ata_cable_80wire,
  49. /* BMDMA handling is PCI ATA format, use helpers */
  50. .bmdma_setup = ata_bmdma_setup,
  51. .bmdma_start = ata_bmdma_start,
  52. .bmdma_stop = ata_bmdma_stop,
  53. .bmdma_status = ata_bmdma_status,
  54. .qc_prep = ata_qc_prep,
  55. .qc_issue = ata_qc_issue_prot,
  56. .data_xfer = ata_data_xfer,
  57. /* IRQ-related hooks */
  58. .irq_handler = ata_interrupt,
  59. .irq_clear = ata_bmdma_irq_clear,
  60. .irq_on = ata_irq_on,
  61. /* Generic PATA PCI ATA helpers */
  62. .port_start = ata_sff_port_start,
  63. };
  64. /**
  65. * netcell_init_one - Register Netcell ATA PCI device with kernel services
  66. * @pdev: PCI device to register
  67. * @ent: Entry in netcell_pci_tbl matching with @pdev
  68. *
  69. * Called from kernel PCI layer.
  70. *
  71. * LOCKING:
  72. * Inherited from PCI layer (may sleep).
  73. *
  74. * RETURNS:
  75. * Zero on success, or -ERRNO value.
  76. */
  77. static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
  78. {
  79. static int printed_version;
  80. static const struct ata_port_info info = {
  81. .sht = &netcell_sht,
  82. .flags = ATA_FLAG_SLAVE_POSS,
  83. /* Actually we don't really care about these as the
  84. firmware deals with it */
  85. .pio_mask = 0x1f, /* pio0-4 */
  86. .mwdma_mask = 0x07, /* mwdma0-2 */
  87. .udma_mask = ATA_UDMA5, /* UDMA 133 */
  88. .port_ops = &netcell_ops,
  89. };
  90. const struct ata_port_info *port_info[] = { &info, NULL };
  91. if (!printed_version++)
  92. dev_printk(KERN_DEBUG, &pdev->dev,
  93. "version " DRV_VERSION "\n");
  94. /* Any chip specific setup/optimisation/messages here */
  95. ata_pci_clear_simplex(pdev);
  96. /* And let the library code do the work */
  97. return ata_pci_init_one(pdev, port_info);
  98. }
  99. static const struct pci_device_id netcell_pci_tbl[] = {
  100. { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), },
  101. { } /* terminate list */
  102. };
  103. static struct pci_driver netcell_pci_driver = {
  104. .name = DRV_NAME,
  105. .id_table = netcell_pci_tbl,
  106. .probe = netcell_init_one,
  107. .remove = ata_pci_remove_one,
  108. #ifdef CONFIG_PM
  109. .suspend = ata_pci_device_suspend,
  110. .resume = ata_pci_device_resume,
  111. #endif
  112. };
  113. static int __init netcell_init(void)
  114. {
  115. return pci_register_driver(&netcell_pci_driver);
  116. }
  117. static void __exit netcell_exit(void)
  118. {
  119. pci_unregister_driver(&netcell_pci_driver);
  120. }
  121. module_init(netcell_init);
  122. module_exit(netcell_exit);
  123. MODULE_AUTHOR("Alan Cox");
  124. MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID");
  125. MODULE_LICENSE("GPL");
  126. MODULE_DEVICE_TABLE(pci, netcell_pci_tbl);
  127. MODULE_VERSION(DRV_VERSION);