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