aic_isa.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* $OpenBSD: aic_isa.c,v 1.7 2014/09/14 14:17:25 jsg Exp $ */
  2. /* $NetBSD: aic6360.c,v 1.52 1996/12/10 21:27:51 thorpej Exp $ */
  3. /*
  4. * Copyright (c) 1994, 1995, 1996 Charles Hannum. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. All advertising materials mentioning features or use of this software
  15. * must display the following acknowledgement:
  16. * This product includes software developed by Charles M. Hannum.
  17. * 4. The name of the author may not be used to endorse or promote products
  18. * derived from this software without specific prior written permission.
  19. *
  20. * Copyright (c) 1994 Jarle Greipsland
  21. * All rights reserved.
  22. *
  23. * Redistribution and use in source and binary forms, with or without
  24. * modification, are permitted provided that the following conditions
  25. * are met:
  26. * 1. Redistributions of source code must retain the above copyright
  27. * notice, this list of conditions and the following disclaimer.
  28. * 2. Redistributions in binary form must reproduce the above copyright
  29. * notice, this list of conditions and the following disclaimer in the
  30. * documentation and/or other materials provided with the distribution.
  31. * 3. The name of the author may not be used to endorse or promote products
  32. * derived from this software without specific prior written permission.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  35. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  36. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  37. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  38. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  39. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  40. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  41. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  42. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  43. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  44. * POSSIBILITY OF SUCH DAMAGE.
  45. */
  46. /*
  47. * Acknowledgements: Many of the algorithms used in this driver are
  48. * inspired by the work of Julian Elischer (julian@tfs.com) and
  49. * Charles Hannum (mycroft@duality.gnu.ai.mit.edu). Thanks a million!
  50. */
  51. #include <sys/types.h>
  52. #include <sys/param.h>
  53. #include <sys/systm.h>
  54. #include <sys/kernel.h>
  55. #include <sys/errno.h>
  56. #include <sys/ioctl.h>
  57. #include <sys/device.h>
  58. #include <sys/buf.h>
  59. #include <sys/queue.h>
  60. #include <machine/bus.h>
  61. #include <machine/intr.h>
  62. #include <scsi/scsi_all.h>
  63. #include <scsi/scsi_message.h>
  64. #include <scsi/scsiconf.h>
  65. #include <dev/isa/isavar.h>
  66. #include <dev/ic/aic6360reg.h>
  67. #include <dev/ic/aic6360var.h>
  68. int aic_isa_probe(struct device *, void *, void *);
  69. void aic_isa_attach(struct device *, struct device *, void *);
  70. struct cfattach aic_isa_ca = {
  71. sizeof(struct aic_softc), aic_isa_probe, aic_isa_attach
  72. };
  73. /*
  74. * INITIALIZATION ROUTINES (probe, attach ++)
  75. */
  76. /*
  77. * aicprobe: probe for AIC6360 SCSI-controller
  78. * returns non-zero value if a controller is found.
  79. */
  80. int
  81. aic_isa_probe(parent, match, aux)
  82. struct device *parent;
  83. void *match, *aux;
  84. {
  85. struct isa_attach_args *ia = aux;
  86. bus_space_tag_t iot = ia->ia_iot;
  87. bus_space_handle_t ioh;
  88. int rv;
  89. if (bus_space_map(iot, ia->ia_iobase, AIC_NPORTS, 0, &ioh))
  90. return (0);
  91. AIC_TRACE(("aic: probing for aic-chip at port 0x%x\n", ia->ia_iobase));
  92. rv = aic_find(iot, ioh);
  93. bus_space_unmap(iot, ioh, AIC_NPORTS);
  94. if (rv) {
  95. ia->ia_msize = 0;
  96. ia->ia_iosize = AIC_NPORTS;
  97. }
  98. return (rv);
  99. }
  100. /*
  101. * Attach the AIC6360, fill out some high and low level data structures
  102. */
  103. void
  104. aic_isa_attach(parent, self, aux)
  105. struct device *parent, *self;
  106. void *aux;
  107. {
  108. struct isa_attach_args *ia = aux;
  109. bus_space_tag_t iot = ia->ia_iot;
  110. bus_space_handle_t ioh;
  111. struct aic_softc *sc = (void *)self;
  112. if (bus_space_map(iot, ia->ia_iobase, AIC_NPORTS, 0, &ioh))
  113. panic("%s: can't map i/o-ports", sc->sc_dev.dv_xname);
  114. sc->sc_iot = iot;
  115. sc->sc_ioh = ioh;
  116. printf("\n");
  117. sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
  118. IPL_BIO, aicintr, sc, sc->sc_dev.dv_xname);
  119. aicattach(sc);
  120. }