pata_netcell.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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.6"
  18. /**
  19. * netcell_probe_init - check for 40/80 pin
  20. * @ap: Port
  21. *
  22. * Cables are handled by the RAID controller. Report 80 pin.
  23. */
  24. static int netcell_pre_reset(struct ata_port *ap)
  25. {
  26. ap->cbl = ATA_CBL_PATA80;
  27. return ata_std_prereset(ap);
  28. }
  29. /**
  30. * netcell_probe_reset - Probe specified port on PATA host controller
  31. * @ap: Port to probe
  32. *
  33. * LOCKING:
  34. * None (inherited from caller).
  35. */
  36. static void netcell_error_handler(struct ata_port *ap)
  37. {
  38. return ata_bmdma_drive_eh(ap, netcell_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
  39. }
  40. /* No PIO or DMA methods needed for this device */
  41. static struct scsi_host_template netcell_sht = {
  42. .module = THIS_MODULE,
  43. .name = DRV_NAME,
  44. .ioctl = ata_scsi_ioctl,
  45. .queuecommand = ata_scsi_queuecmd,
  46. .can_queue = ATA_DEF_QUEUE,
  47. .this_id = ATA_SHT_THIS_ID,
  48. .sg_tablesize = LIBATA_MAX_PRD,
  49. .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
  50. .emulated = ATA_SHT_EMULATED,
  51. .use_clustering = ATA_SHT_USE_CLUSTERING,
  52. .proc_name = DRV_NAME,
  53. .dma_boundary = ATA_DMA_BOUNDARY,
  54. .slave_configure = ata_scsi_slave_config,
  55. .slave_destroy = ata_scsi_slave_destroy,
  56. /* Use standard CHS mapping rules */
  57. .bios_param = ata_std_bios_param,
  58. .resume = ata_scsi_device_resume,
  59. .suspend = ata_scsi_device_suspend,
  60. };
  61. static const struct ata_port_operations netcell_ops = {
  62. .port_disable = ata_port_disable,
  63. /* Task file is PCI ATA format, use helpers */
  64. .tf_load = ata_tf_load,
  65. .tf_read = ata_tf_read,
  66. .check_status = ata_check_status,
  67. .exec_command = ata_exec_command,
  68. .dev_select = ata_std_dev_select,
  69. .freeze = ata_bmdma_freeze,
  70. .thaw = ata_bmdma_thaw,
  71. .error_handler = netcell_error_handler,
  72. .post_internal_cmd = ata_bmdma_post_internal_cmd,
  73. /* BMDMA handling is PCI ATA format, use helpers */
  74. .bmdma_setup = ata_bmdma_setup,
  75. .bmdma_start = ata_bmdma_start,
  76. .bmdma_stop = ata_bmdma_stop,
  77. .bmdma_status = ata_bmdma_status,
  78. .qc_prep = ata_qc_prep,
  79. .qc_issue = ata_qc_issue_prot,
  80. .data_xfer = ata_data_xfer,
  81. /* IRQ-related hooks */
  82. .irq_handler = ata_interrupt,
  83. .irq_clear = ata_bmdma_irq_clear,
  84. .irq_on = ata_irq_on,
  85. .irq_ack = ata_irq_ack,
  86. /* Generic PATA PCI ATA helpers */
  87. .port_start = ata_port_start,
  88. };
  89. /**
  90. * netcell_init_one - Register Netcell ATA PCI device with kernel services
  91. * @pdev: PCI device to register
  92. * @ent: Entry in netcell_pci_tbl matching with @pdev
  93. *
  94. * Called from kernel PCI layer.
  95. *
  96. * LOCKING:
  97. * Inherited from PCI layer (may sleep).
  98. *
  99. * RETURNS:
  100. * Zero on success, or -ERRNO value.
  101. */
  102. static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
  103. {
  104. static int printed_version;
  105. static struct ata_port_info info = {
  106. .sht = &netcell_sht,
  107. .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
  108. /* Actually we don't really care about these as the
  109. firmware deals with it */
  110. .pio_mask = 0x1f, /* pio0-4 */
  111. .mwdma_mask = 0x07, /* mwdma0-2 */
  112. .udma_mask = 0x3f, /* UDMA 133 */
  113. .port_ops = &netcell_ops,
  114. };
  115. static struct ata_port_info *port_info[2] = { &info, &info };
  116. if (!printed_version++)
  117. dev_printk(KERN_DEBUG, &pdev->dev,
  118. "version " DRV_VERSION "\n");
  119. /* Any chip specific setup/optimisation/messages here */
  120. ata_pci_clear_simplex(pdev);
  121. /* And let the library code do the work */
  122. return ata_pci_init_one(pdev, port_info, 2);
  123. }
  124. static const struct pci_device_id netcell_pci_tbl[] = {
  125. { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), },
  126. { } /* terminate list */
  127. };
  128. static struct pci_driver netcell_pci_driver = {
  129. .name = DRV_NAME,
  130. .id_table = netcell_pci_tbl,
  131. .probe = netcell_init_one,
  132. .remove = ata_pci_remove_one,
  133. .suspend = ata_pci_device_suspend,
  134. .resume = ata_pci_device_resume,
  135. };
  136. static int __init netcell_init(void)
  137. {
  138. return pci_register_driver(&netcell_pci_driver);
  139. }
  140. static void __exit netcell_exit(void)
  141. {
  142. pci_unregister_driver(&netcell_pci_driver);
  143. }
  144. module_init(netcell_init);
  145. module_exit(netcell_exit);
  146. MODULE_AUTHOR("Alan Cox");
  147. MODULE_DESCRIPTION("SCSI low-level driver for Netcell PATA RAID");
  148. MODULE_LICENSE("GPL");
  149. MODULE_DEVICE_TABLE(pci, netcell_pci_tbl);
  150. MODULE_VERSION(DRV_VERSION);