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