pata_isapnp.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * pata-isapnp.c - ISA PnP PATA controller driver.
  3. * Copyright 2005/2006 Red Hat Inc <alan@redhat.com>, all rights reserved.
  4. *
  5. * Based in part on ide-pnp.c by Andrey Panin <pazke@donpac.ru>
  6. */
  7. #include <linux/kernel.h>
  8. #include <linux/module.h>
  9. #include <linux/isapnp.h>
  10. #include <linux/init.h>
  11. #include <linux/blkdev.h>
  12. #include <linux/delay.h>
  13. #include <scsi/scsi_host.h>
  14. #include <linux/ata.h>
  15. #include <linux/libata.h>
  16. #define DRV_NAME "pata_isapnp"
  17. #define DRV_VERSION "0.1.5"
  18. static struct scsi_host_template isapnp_sht = {
  19. .module = THIS_MODULE,
  20. .name = DRV_NAME,
  21. .ioctl = ata_scsi_ioctl,
  22. .queuecommand = ata_scsi_queuecmd,
  23. .can_queue = ATA_DEF_QUEUE,
  24. .this_id = ATA_SHT_THIS_ID,
  25. .sg_tablesize = LIBATA_MAX_PRD,
  26. .max_sectors = ATA_MAX_SECTORS,
  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. .bios_param = ata_std_bios_param,
  34. };
  35. static struct ata_port_operations isapnp_port_ops = {
  36. .port_disable = ata_port_disable,
  37. .tf_load = ata_tf_load,
  38. .tf_read = ata_tf_read,
  39. .check_status = ata_check_status,
  40. .exec_command = ata_exec_command,
  41. .dev_select = ata_std_dev_select,
  42. .freeze = ata_bmdma_freeze,
  43. .thaw = ata_bmdma_thaw,
  44. .error_handler = ata_bmdma_error_handler,
  45. .post_internal_cmd = ata_bmdma_post_internal_cmd,
  46. .qc_prep = ata_qc_prep,
  47. .qc_issue = ata_qc_issue_prot,
  48. .data_xfer = ata_pio_data_xfer,
  49. .irq_handler = ata_interrupt,
  50. .irq_clear = ata_bmdma_irq_clear,
  51. .port_start = ata_port_start,
  52. .port_stop = ata_port_stop,
  53. .host_stop = ata_host_stop
  54. };
  55. /**
  56. * isapnp_init_one - attach an isapnp interface
  57. * @idev: PnP device
  58. * @dev_id: matching detect line
  59. *
  60. * Register an ISA bus IDE interface. Such interfaces are PIO 0 and
  61. * non shared IRQ.
  62. */
  63. static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
  64. {
  65. struct ata_probe_ent ae;
  66. if (pnp_port_valid(idev, 0) == 0)
  67. return -ENODEV;
  68. /* FIXME: Should selected polled PIO here not fail */
  69. if (pnp_irq_valid(idev, 0) == 0)
  70. return -ENODEV;
  71. memset(&ae, 0, sizeof(struct ata_probe_ent));
  72. INIT_LIST_HEAD(&ae.node);
  73. ae.dev = &idev->dev;
  74. ae.port_ops = &isapnp_port_ops;
  75. ae.sht = &isapnp_sht;
  76. ae.n_ports = 1;
  77. ae.pio_mask = 1; /* ISA so PIO 0 cycles */
  78. ae.irq = pnp_irq(idev, 0);
  79. ae.irq_flags = 0;
  80. ae.port_flags = ATA_FLAG_SLAVE_POSS;
  81. ae.port[0].cmd_addr = pnp_port_start(idev, 0);
  82. if (pnp_port_valid(idev, 1) == 0) {
  83. ae.port[0].altstatus_addr = pnp_port_start(idev, 1);
  84. ae.port[0].ctl_addr = pnp_port_start(idev, 1);
  85. ae.port_flags |= ATA_FLAG_SRST;
  86. }
  87. ata_std_ports(&ae.port[0]);
  88. if (ata_device_add(&ae) == 0)
  89. return -ENODEV;
  90. return 0;
  91. }
  92. /**
  93. * isapnp_remove_one - unplug an isapnp interface
  94. * @idev: PnP device
  95. *
  96. * Remove a previously configured PnP ATA port. Called only on module
  97. * unload events as the core does not currently deal with ISAPnP docking.
  98. */
  99. static void isapnp_remove_one(struct pnp_dev *idev)
  100. {
  101. struct device *dev = &idev->dev;
  102. struct ata_host *host = dev_get_drvdata(dev);
  103. ata_host_remove(host);
  104. dev_set_drvdata(dev, NULL);
  105. }
  106. static struct pnp_device_id isapnp_devices[] = {
  107. /* Generic ESDI/IDE/ATA compatible hard disk controller */
  108. {.id = "PNP0600", .driver_data = 0},
  109. {.id = ""}
  110. };
  111. static struct pnp_driver isapnp_driver = {
  112. .name = DRV_NAME,
  113. .id_table = isapnp_devices,
  114. .probe = isapnp_init_one,
  115. .remove = isapnp_remove_one,
  116. };
  117. static int __init isapnp_init(void)
  118. {
  119. return pnp_register_driver(&isapnp_driver);
  120. }
  121. static void __exit isapnp_exit(void)
  122. {
  123. pnp_unregister_driver(&isapnp_driver);
  124. }
  125. MODULE_AUTHOR("Alan Cox");
  126. MODULE_DESCRIPTION("low-level driver for ISA PnP ATA");
  127. MODULE_LICENSE("GPL");
  128. MODULE_VERSION(DRV_VERSION);
  129. module_init(isapnp_init);
  130. module_exit(isapnp_exit);