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. .eng_timeout = ata_eng_timeout,
  49. .data_xfer = ata_pio_data_xfer,
  50. .irq_handler = ata_interrupt,
  51. .irq_clear = ata_bmdma_irq_clear,
  52. .port_start = ata_port_start,
  53. .port_stop = ata_port_stop,
  54. .host_stop = ata_host_stop
  55. };
  56. /**
  57. * isapnp_init_one - attach an isapnp interface
  58. * @idev: PnP device
  59. * @dev_id: matching detect line
  60. *
  61. * Register an ISA bus IDE interface. Such interfaces are PIO 0 and
  62. * non shared IRQ.
  63. */
  64. static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
  65. {
  66. struct ata_probe_ent ae;
  67. if (pnp_port_valid(idev, 0) == 0)
  68. return -ENODEV;
  69. /* FIXME: Should selected polled PIO here not fail */
  70. if (pnp_irq_valid(idev, 0) == 0)
  71. return -ENODEV;
  72. memset(&ae, 0, sizeof(struct ata_probe_ent));
  73. INIT_LIST_HEAD(&ae.node);
  74. ae.dev = &idev->dev;
  75. ae.port_ops = &isapnp_port_ops;
  76. ae.sht = &isapnp_sht;
  77. ae.n_ports = 1;
  78. ae.pio_mask = 1; /* ISA so PIO 0 cycles */
  79. ae.irq = pnp_irq(idev, 0);
  80. ae.irq_flags = 0;
  81. ae.port_flags = ATA_FLAG_SLAVE_POSS;
  82. ae.port[0].cmd_addr = pnp_port_start(idev, 0);
  83. if (pnp_port_valid(idev, 1) == 0) {
  84. ae.port[0].altstatus_addr = pnp_port_start(idev, 1);
  85. ae.port[0].ctl_addr = pnp_port_start(idev, 1);
  86. ae.port_flags |= ATA_FLAG_SRST;
  87. }
  88. ata_std_ports(&ae.port[0]);
  89. if (ata_device_add(&ae) == 0)
  90. return -ENODEV;
  91. return 0;
  92. }
  93. /**
  94. * isapnp_remove_one - unplug an isapnp interface
  95. * @idev: PnP device
  96. *
  97. * Remove a previously configured PnP ATA port. Called only on module
  98. * unload events as the core does not currently deal with ISAPnP docking.
  99. */
  100. static void isapnp_remove_one(struct pnp_dev *idev)
  101. {
  102. struct device *dev = &idev->dev;
  103. struct ata_host *host = dev_get_drvdata(dev);
  104. ata_host_remove(host);
  105. dev_set_drvdata(dev, NULL);
  106. }
  107. static struct pnp_device_id isapnp_devices[] = {
  108. /* Generic ESDI/IDE/ATA compatible hard disk controller */
  109. {.id = "PNP0600", .driver_data = 0},
  110. {.id = ""}
  111. };
  112. static struct pnp_driver isapnp_driver = {
  113. .name = DRV_NAME,
  114. .id_table = isapnp_devices,
  115. .probe = isapnp_init_one,
  116. .remove = isapnp_remove_one,
  117. };
  118. static int __init isapnp_init(void)
  119. {
  120. return pnp_register_driver(&isapnp_driver);
  121. }
  122. static void __exit isapnp_exit(void)
  123. {
  124. pnp_unregister_driver(&isapnp_driver);
  125. }
  126. MODULE_AUTHOR("Alan Cox");
  127. MODULE_DESCRIPTION("low-level driver for ISA PnP ATA");
  128. MODULE_LICENSE("GPL");
  129. MODULE_VERSION(DRV_VERSION);
  130. module_init(isapnp_init);
  131. module_exit(isapnp_exit);