aic7770_osm.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. ahc->dev = dev;
  86. error = aic7770_config(ahc, aic7770_ident_table + edev->id.driver_data,
  87. eisaBase);
  88. if (error != 0) {
  89. ahc->bsh.ioport = 0;
  90. ahc_free(ahc);
  91. return (error);
  92. }
  93. dev_set_drvdata(dev, ahc);
  94. error = ahc_linux_register_host(ahc, &aic7xxx_driver_template);
  95. return (error);
  96. }
  97. static int
  98. aic7770_remove(struct device *dev)
  99. {
  100. struct ahc_softc *ahc = dev_get_drvdata(dev);
  101. u_long s;
  102. if (ahc->platform_data && ahc->platform_data->host)
  103. scsi_remove_host(ahc->platform_data->host);
  104. ahc_lock(ahc, &s);
  105. ahc_intr_enable(ahc, FALSE);
  106. ahc_unlock(ahc, &s);
  107. ahc_free(ahc);
  108. return 0;
  109. }
  110. static struct eisa_device_id aic7770_ids[] = {
  111. { "ADP7771", 0 }, /* AHA 274x */
  112. { "ADP7756", 1 }, /* AHA 284x BIOS enabled */
  113. { "ADP7757", 2 }, /* AHA 284x BIOS disabled */
  114. { "ADP7782", 3 }, /* AHA 274x Olivetti OEM */
  115. { "ADP7783", 4 }, /* AHA 274x Olivetti OEM (Differential) */
  116. { "ADP7770", 5 }, /* AIC7770 generic */
  117. { "" }
  118. };
  119. MODULE_DEVICE_TABLE(eisa, aic7770_ids);
  120. static struct eisa_driver aic7770_driver = {
  121. .id_table = aic7770_ids,
  122. .driver = {
  123. .name = "aic7xxx",
  124. .probe = aic7770_probe,
  125. .remove = aic7770_remove,
  126. }
  127. };
  128. int
  129. ahc_linux_eisa_init(void)
  130. {
  131. return eisa_driver_register(&aic7770_driver);
  132. }
  133. void
  134. ahc_linux_eisa_exit(void)
  135. {
  136. eisa_driver_unregister(&aic7770_driver);
  137. }