aha1542.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #ifndef _AHA1542_H
  2. /* $Id: aha1542.h,v 1.1 1992/07/24 06:27:38 root Exp root $
  3. *
  4. * Header file for the adaptec 1542 driver for Linux
  5. *
  6. * $Log: aha1542.h,v $
  7. * Revision 1.1 1992/07/24 06:27:38 root
  8. * Initial revision
  9. *
  10. * Revision 1.2 1992/07/04 18:41:49 root
  11. * Replaced distribution with current drivers
  12. *
  13. * Revision 1.3 1992/06/23 23:58:20 root
  14. * Fixes.
  15. *
  16. * Revision 1.2 1992/05/26 22:13:23 root
  17. * Changed bug that prevented DMA above first 2 mbytes.
  18. *
  19. * Revision 1.1 1992/05/22 21:00:29 root
  20. * Initial revision
  21. *
  22. * Revision 1.1 1992/04/24 18:01:50 root
  23. * Initial revision
  24. *
  25. * Revision 1.1 1992/04/02 03:23:13 drew
  26. * Initial revision
  27. *
  28. * Revision 1.3 1992/01/27 14:46:29 tthorn
  29. * *** empty log message ***
  30. *
  31. */
  32. #include <linux/types.h>
  33. /* I/O Port interface 4.2 */
  34. /* READ */
  35. #define STATUS(base) base
  36. #define STST 0x80 /* Self Test in Progress */
  37. #define DIAGF 0x40 /* Internal Diagnostic Failure */
  38. #define INIT 0x20 /* Mailbox Initialization Required */
  39. #define IDLE 0x10 /* SCSI Host Adapter Idle */
  40. #define CDF 0x08 /* Command/Data Out Port Full */
  41. #define DF 0x04 /* Data In Port Full */
  42. #define INVDCMD 0x01 /* Invalid H A Command */
  43. #define STATMASK 0xfd /* 0x02 is reserved */
  44. #define INTRFLAGS(base) (STATUS(base)+2)
  45. #define ANYINTR 0x80 /* Any Interrupt */
  46. #define SCRD 0x08 /* SCSI Reset Detected */
  47. #define HACC 0x04 /* HA Command Complete */
  48. #define MBOA 0x02 /* MBO Empty */
  49. #define MBIF 0x01 /* MBI Full */
  50. #define INTRMASK 0x8f
  51. /* WRITE */
  52. #define CONTROL(base) STATUS(base)
  53. #define HRST 0x80 /* Hard Reset */
  54. #define SRST 0x40 /* Soft Reset */
  55. #define IRST 0x20 /* Interrupt Reset */
  56. #define SCRST 0x10 /* SCSI Bus Reset */
  57. /* READ/WRITE */
  58. #define DATA(base) (STATUS(base)+1)
  59. #define CMD_NOP 0x00 /* No Operation */
  60. #define CMD_MBINIT 0x01 /* Mailbox Initialization */
  61. #define CMD_START_SCSI 0x02 /* Start SCSI Command */
  62. #define CMD_INQUIRY 0x04 /* Adapter Inquiry */
  63. #define CMD_EMBOI 0x05 /* Enable MailBox Out Interrupt */
  64. #define CMD_BUSON_TIME 0x07 /* Set Bus-On Time */
  65. #define CMD_BUSOFF_TIME 0x08 /* Set Bus-Off Time */
  66. #define CMD_DMASPEED 0x09 /* Set AT Bus Transfer Speed */
  67. #define CMD_RETDEVS 0x0a /* Return Installed Devices */
  68. #define CMD_RETCONF 0x0b /* Return Configuration Data */
  69. #define CMD_RETSETUP 0x0d /* Return Setup Data */
  70. #define CMD_ECHO 0x1f /* ECHO Command Data */
  71. #define CMD_EXTBIOS 0x28 /* Return extend bios information only 1542C */
  72. #define CMD_MBENABLE 0x29 /* Set Mailbox Interface enable only 1542C */
  73. /* Mailbox Definition 5.2.1 and 5.2.2 */
  74. struct mailbox {
  75. unchar status; /* Command/Status */
  76. unchar ccbptr[3]; /* msb, .., lsb */
  77. };
  78. /* This is used with scatter-gather */
  79. struct chain {
  80. unchar datalen[3]; /* Size of this part of chain */
  81. unchar dataptr[3]; /* Location of data */
  82. };
  83. /* These belong in scsi.h also */
  84. static inline void any2scsi(u8 *p, u32 v)
  85. {
  86. p[0] = v >> 16;
  87. p[1] = v >> 8;
  88. p[2] = v;
  89. }
  90. #define scsi2int(up) ( (((long)*(up)) << 16) + (((long)(up)[1]) << 8) + ((long)(up)[2]) )
  91. #define xany2scsi(up, p) \
  92. (up)[0] = ((long)(p)) >> 24; \
  93. (up)[1] = ((long)(p)) >> 16; \
  94. (up)[2] = ((long)(p)) >> 8; \
  95. (up)[3] = ((long)(p));
  96. #define xscsi2int(up) ( (((long)(up)[0]) << 24) + (((long)(up)[1]) << 16) \
  97. + (((long)(up)[2]) << 8) + ((long)(up)[3]) )
  98. #define MAX_CDB 12
  99. #define MAX_SENSE 14
  100. struct ccb { /* Command Control Block 5.3 */
  101. unchar op; /* Command Control Block Operation Code */
  102. unchar idlun; /* op=0,2:Target Id, op=1:Initiator Id */
  103. /* Outbound data transfer, length is checked*/
  104. /* Inbound data transfer, length is checked */
  105. /* Logical Unit Number */
  106. unchar cdblen; /* SCSI Command Length */
  107. unchar rsalen; /* Request Sense Allocation Length/Disable */
  108. unchar datalen[3]; /* Data Length (msb, .., lsb) */
  109. unchar dataptr[3]; /* Data Pointer */
  110. unchar linkptr[3]; /* Link Pointer */
  111. unchar commlinkid; /* Command Linking Identifier */
  112. unchar hastat; /* Host Adapter Status (HASTAT) */
  113. unchar tarstat; /* Target Device Status */
  114. unchar reserved[2];
  115. unchar cdb[MAX_CDB+MAX_SENSE];/* SCSI Command Descriptor Block */
  116. /* REQUEST SENSE */
  117. };
  118. static int aha1542_detect(struct scsi_host_template *);
  119. static int aha1542_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
  120. static int aha1542_bus_reset(Scsi_Cmnd * SCpnt);
  121. static int aha1542_dev_reset(Scsi_Cmnd * SCpnt);
  122. static int aha1542_host_reset(Scsi_Cmnd * SCpnt);
  123. #if 0
  124. static int aha1542_old_abort(Scsi_Cmnd * SCpnt);
  125. static int aha1542_old_reset(Scsi_Cmnd *, unsigned int);
  126. #endif
  127. static int aha1542_biosparam(struct scsi_device *, struct block_device *,
  128. sector_t, int *);
  129. #define AHA1542_MAILBOXES 8
  130. #define AHA1542_SCATTER 16
  131. #define AHA1542_CMDLUN 1
  132. #endif