aic7770_osm.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * Linux driver attachment glue for aic7770 based controllers.
  3. *
  4. * Copyright (c) 2000-2003 Adaptec Inc.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions, and the following disclaimer,
  12. * without modification.
  13. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  14. * substantially similar to the "NO WARRANTY" disclaimer below
  15. * ("Disclaimer") and any redistribution must be conditioned upon
  16. * including a substantially similar Disclaimer requirement for further
  17. * binary redistribution.
  18. * 3. Neither the names of the above-listed copyright holders nor the names
  19. * of any contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * Alternatively, this software may be distributed under the terms of the
  23. * GNU General Public License ("GPL") version 2 as published by the Free
  24. * Software Foundation.
  25. *
  26. * NO WARRANTY
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  30. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  31. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  33. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  34. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  35. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  36. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37. * POSSIBILITY OF SUCH DAMAGES.
  38. *
  39. * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#14 $
  40. */
  41. #include "aic7xxx_osm.h"
  42. #include <linux/device.h>
  43. #include <linux/eisa.h>
  44. int
  45. aic7770_map_registers(struct ahc_softc *ahc, u_int port)
  46. {
  47. /*
  48. * Lock out other contenders for our i/o space.
  49. */
  50. if (!request_region(port, AHC_EISA_IOSIZE, "aic7xxx"))
  51. return (ENOMEM);
  52. ahc->tag = BUS_SPACE_PIO;
  53. ahc->bsh.ioport = port;
  54. return (0);
  55. }
  56. int
  57. aic7770_map_int(struct ahc_softc *ahc, u_int irq)
  58. {
  59. int error;
  60. int shared;
  61. shared = 0;
  62. if ((ahc->flags & AHC_EDGE_INTERRUPT) == 0)
  63. shared = IRQF_SHARED;
  64. error = request_irq(irq, ahc_linux_isr, shared, "aic7xxx", ahc);
  65. if (error == 0)
  66. ahc->platform_data->irq = irq;
  67. return (-error);
  68. }
  69. static int
  70. aic7770_probe(struct device *dev)
  71. {
  72. struct eisa_device *edev = to_eisa_device(dev);
  73. u_int eisaBase = edev->base_addr+AHC_EISA_SLOT_OFFSET;
  74. struct ahc_softc *ahc;
  75. char buf[80];
  76. char *name;
  77. int error;
  78. sprintf(buf, "ahc_eisa:%d", eisaBase >> 12);
  79. name = kstrdup(buf, GFP_ATOMIC);
  80. if (name == NULL)
  81. return (ENOMEM);
  82. ahc = ahc_alloc(&aic7xxx_driver_template, name);
  83. if (ahc == NULL)
  84. return (ENOMEM);
  85. error = aic7770_config(ahc, aic7770_ident_table + edev->id.driver_data,
  86. eisaBase);
  87. if (error != 0) {
  88. ahc->bsh.ioport = 0;
  89. ahc_free(ahc);
  90. return (error);
  91. }
  92. dev_set_drvdata(dev, ahc);
  93. error = ahc_linux_register_host(ahc, &aic7xxx_driver_template);
  94. return (error);
  95. }
  96. static int
  97. aic7770_remove(struct device *dev)
  98. {
  99. struct ahc_softc *ahc = dev_get_drvdata(dev);
  100. u_long s;
  101. if (ahc->platform_data && ahc->platform_data->host)
  102. scsi_remove_host(ahc->platform_data->host);
  103. ahc_lock(ahc, &s);
  104. ahc_intr_enable(ahc, FALSE);
  105. ahc_unlock(ahc, &s);
  106. ahc_free(ahc);
  107. return 0;
  108. }
  109. static struct eisa_device_id aic7770_ids[] = {
  110. { "ADP7771", 0 }, /* AHA 274x */
  111. { "ADP7756", 1 }, /* AHA 284x BIOS enabled */
  112. { "ADP7757", 2 }, /* AHA 284x BIOS disabled */
  113. { "ADP7782", 3 }, /* AHA 274x Olivetti OEM */
  114. { "ADP7783", 4 }, /* AHA 274x Olivetti OEM (Differential) */
  115. { "ADP7770", 5 }, /* AIC7770 generic */
  116. { "" }
  117. };
  118. MODULE_DEVICE_TABLE(eisa, aic7770_ids);
  119. static struct eisa_driver aic7770_driver = {
  120. .id_table = aic7770_ids,
  121. .driver = {
  122. .name = "aic7xxx",
  123. .probe = aic7770_probe,
  124. .remove = aic7770_remove,
  125. }
  126. };
  127. int
  128. ahc_linux_eisa_init(void)
  129. {
  130. return eisa_driver_register(&aic7770_driver);
  131. }
  132. void
  133. ahc_linux_eisa_exit(void)
  134. {
  135. eisa_driver_unregister(&aic7770_driver);
  136. }