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