pata_isapnp.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * pata-isapnp.c - ISA PnP PATA controller driver.
  3. * Copyright 2005/2006 Red Hat Inc, 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.2.5"
  18. static struct scsi_host_template isapnp_sht = {
  19. ATA_PIO_SHT(DRV_NAME),
  20. };
  21. static struct ata_port_operations isapnp_port_ops = {
  22. .inherits = &ata_sff_port_ops,
  23. .cable_detect = ata_cable_40wire,
  24. };
  25. static struct ata_port_operations isapnp_noalt_port_ops = {
  26. .inherits = &ata_sff_port_ops,
  27. .cable_detect = ata_cable_40wire,
  28. /* No altstatus so we don't want to use the lost interrupt poll */
  29. .lost_interrupt = ATA_OP_NULL,
  30. };
  31. /**
  32. * isapnp_init_one - attach an isapnp interface
  33. * @idev: PnP device
  34. * @dev_id: matching detect line
  35. *
  36. * Register an ISA bus IDE interface. Such interfaces are PIO 0 and
  37. * non shared IRQ.
  38. */
  39. static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
  40. {
  41. struct ata_host *host;
  42. struct ata_port *ap;
  43. void __iomem *cmd_addr, *ctl_addr;
  44. int irq = 0;
  45. irq_handler_t handler = NULL;
  46. if (pnp_port_valid(idev, 0) == 0)
  47. return -ENODEV;
  48. if (pnp_irq_valid(idev, 0)) {
  49. irq = pnp_irq(idev, 0);
  50. handler = ata_sff_interrupt;
  51. }
  52. /* allocate host */
  53. host = ata_host_alloc(&idev->dev, 1);
  54. if (!host)
  55. return -ENOMEM;
  56. /* acquire resources and fill host */
  57. cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8);
  58. if (!cmd_addr)
  59. return -ENOMEM;
  60. ap = host->ports[0];
  61. ap->ops = &isapnp_noalt_port_ops;
  62. ap->pio_mask = ATA_PIO0;
  63. ap->flags |= ATA_FLAG_SLAVE_POSS;
  64. ap->ioaddr.cmd_addr = cmd_addr;
  65. if (pnp_port_valid(idev, 1)) {
  66. ctl_addr = devm_ioport_map(&idev->dev,
  67. pnp_port_start(idev, 1), 1);
  68. ap->ioaddr.altstatus_addr = ctl_addr;
  69. ap->ioaddr.ctl_addr = ctl_addr;
  70. ap->ops = &isapnp_port_ops;
  71. }
  72. ata_sff_std_ports(&ap->ioaddr);
  73. ata_port_desc(ap, "cmd 0x%llx ctl 0x%llx",
  74. (unsigned long long)pnp_port_start(idev, 0),
  75. (unsigned long long)pnp_port_start(idev, 1));
  76. /* activate */
  77. return ata_host_activate(host, irq, handler, 0,
  78. &isapnp_sht);
  79. }
  80. /**
  81. * isapnp_remove_one - unplug an isapnp interface
  82. * @idev: PnP device
  83. *
  84. * Remove a previously configured PnP ATA port. Called only on module
  85. * unload events as the core does not currently deal with ISAPnP docking.
  86. */
  87. static void isapnp_remove_one(struct pnp_dev *idev)
  88. {
  89. struct device *dev = &idev->dev;
  90. struct ata_host *host = dev_get_drvdata(dev);
  91. ata_host_detach(host);
  92. }
  93. static struct pnp_device_id isapnp_devices[] = {
  94. /* Generic ESDI/IDE/ATA compatible hard disk controller */
  95. {.id = "PNP0600", .driver_data = 0},
  96. {.id = ""}
  97. };
  98. MODULE_DEVICE_TABLE(pnp, isapnp_devices);
  99. static struct pnp_driver isapnp_driver = {
  100. .name = DRV_NAME,
  101. .id_table = isapnp_devices,
  102. .probe = isapnp_init_one,
  103. .remove = isapnp_remove_one,
  104. };
  105. module_pnp_driver(isapnp_driver);
  106. MODULE_AUTHOR("Alan Cox");
  107. MODULE_DESCRIPTION("low-level driver for ISA PnP ATA");
  108. MODULE_LICENSE("GPL");
  109. MODULE_VERSION(DRV_VERSION);