1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2e51dacbfSOndrej Zary #ifndef _AHA1542_H_
3e51dacbfSOndrej Zary #define _AHA1542_H_
41da177e4SLinus Torvalds
51da177e4SLinus Torvalds #include <linux/types.h>
61da177e4SLinus Torvalds
71da177e4SLinus Torvalds /* I/O Port interface 4.2 */
81da177e4SLinus Torvalds /* READ */
91da177e4SLinus Torvalds #define STATUS(base) base
106d9ffe6aSOndrej Zary #define STST BIT(7) /* Self Test in Progress */
116d9ffe6aSOndrej Zary #define DIAGF BIT(6) /* Internal Diagnostic Failure */
126d9ffe6aSOndrej Zary #define INIT BIT(5) /* Mailbox Initialization Required */
136d9ffe6aSOndrej Zary #define IDLE BIT(4) /* SCSI Host Adapter Idle */
146d9ffe6aSOndrej Zary #define CDF BIT(3) /* Command/Data Out Port Full */
156d9ffe6aSOndrej Zary #define DF BIT(2) /* Data In Port Full */
166d9ffe6aSOndrej Zary /* BIT(1) is reserved */
176d9ffe6aSOndrej Zary #define INVDCMD BIT(0) /* Invalid H A Command */
186d9ffe6aSOndrej Zary #define STATMASK (STST | DIAGF | INIT | IDLE | CDF | DF | INVDCMD)
191da177e4SLinus Torvalds
201da177e4SLinus Torvalds #define INTRFLAGS(base) (STATUS(base)+2)
216d9ffe6aSOndrej Zary #define ANYINTR BIT(7) /* Any Interrupt */
226d9ffe6aSOndrej Zary #define SCRD BIT(3) /* SCSI Reset Detected */
236d9ffe6aSOndrej Zary #define HACC BIT(2) /* HA Command Complete */
246d9ffe6aSOndrej Zary #define MBOA BIT(1) /* MBO Empty */
256d9ffe6aSOndrej Zary #define MBIF BIT(0) /* MBI Full */
266d9ffe6aSOndrej Zary #define INTRMASK (ANYINTR | SCRD | HACC | MBOA | MBIF)
271da177e4SLinus Torvalds
281da177e4SLinus Torvalds /* WRITE */
291da177e4SLinus Torvalds #define CONTROL(base) STATUS(base)
306d9ffe6aSOndrej Zary #define HRST BIT(7) /* Hard Reset */
316d9ffe6aSOndrej Zary #define SRST BIT(6) /* Soft Reset */
326d9ffe6aSOndrej Zary #define IRST BIT(5) /* Interrupt Reset */
336d9ffe6aSOndrej Zary #define SCRST BIT(4) /* SCSI Bus Reset */
341da177e4SLinus Torvalds
351da177e4SLinus Torvalds /* READ/WRITE */
361da177e4SLinus Torvalds #define DATA(base) (STATUS(base)+1)
371da177e4SLinus Torvalds #define CMD_NOP 0x00 /* No Operation */
381da177e4SLinus Torvalds #define CMD_MBINIT 0x01 /* Mailbox Initialization */
391da177e4SLinus Torvalds #define CMD_START_SCSI 0x02 /* Start SCSI Command */
401da177e4SLinus Torvalds #define CMD_INQUIRY 0x04 /* Adapter Inquiry */
411da177e4SLinus Torvalds #define CMD_EMBOI 0x05 /* Enable MailBox Out Interrupt */
421da177e4SLinus Torvalds #define CMD_BUSON_TIME 0x07 /* Set Bus-On Time */
431da177e4SLinus Torvalds #define CMD_BUSOFF_TIME 0x08 /* Set Bus-Off Time */
441da177e4SLinus Torvalds #define CMD_DMASPEED 0x09 /* Set AT Bus Transfer Speed */
451da177e4SLinus Torvalds #define CMD_RETDEVS 0x0a /* Return Installed Devices */
461da177e4SLinus Torvalds #define CMD_RETCONF 0x0b /* Return Configuration Data */
471da177e4SLinus Torvalds #define CMD_RETSETUP 0x0d /* Return Setup Data */
481da177e4SLinus Torvalds #define CMD_ECHO 0x1f /* ECHO Command Data */
491da177e4SLinus Torvalds
501da177e4SLinus Torvalds #define CMD_EXTBIOS 0x28 /* Return extend bios information only 1542C */
511da177e4SLinus Torvalds #define CMD_MBENABLE 0x29 /* Set Mailbox Interface enable only 1542C */
521da177e4SLinus Torvalds
531da177e4SLinus Torvalds /* Mailbox Definition 5.2.1 and 5.2.2 */
541da177e4SLinus Torvalds struct mailbox {
55cb5b570cSOndrej Zary u8 status; /* Command/Status */
56cb5b570cSOndrej Zary u8 ccbptr[3]; /* msb, .., lsb */
571da177e4SLinus Torvalds };
581da177e4SLinus Torvalds
591da177e4SLinus Torvalds /* This is used with scatter-gather */
601da177e4SLinus Torvalds struct chain {
61cb5b570cSOndrej Zary u8 datalen[3]; /* Size of this part of chain */
62cb5b570cSOndrej Zary u8 dataptr[3]; /* Location of data */
631da177e4SLinus Torvalds };
641da177e4SLinus Torvalds
651da177e4SLinus Torvalds /* These belong in scsi.h also */
any2scsi(u8 * p,u32 v)661da177e4SLinus Torvalds static inline void any2scsi(u8 *p, u32 v)
671da177e4SLinus Torvalds {
681da177e4SLinus Torvalds p[0] = v >> 16;
691da177e4SLinus Torvalds p[1] = v >> 8;
701da177e4SLinus Torvalds p[2] = v;
711da177e4SLinus Torvalds }
721da177e4SLinus Torvalds
731da177e4SLinus Torvalds #define scsi2int(up) ( (((long)*(up)) << 16) + (((long)(up)[1]) << 8) + ((long)(up)[2]) )
741da177e4SLinus Torvalds
751da177e4SLinus Torvalds #define xscsi2int(up) ( (((long)(up)[0]) << 24) + (((long)(up)[1]) << 16) \
761da177e4SLinus Torvalds + (((long)(up)[2]) << 8) + ((long)(up)[3]) )
771da177e4SLinus Torvalds
781da177e4SLinus Torvalds #define MAX_CDB 12
791da177e4SLinus Torvalds #define MAX_SENSE 14
801da177e4SLinus Torvalds
81*5637d5b7SSergey Shtylyov /* Command Control Block (CCB), 5.3 */
82*5637d5b7SSergey Shtylyov struct ccb {
83*5637d5b7SSergey Shtylyov u8 op; /* Command Control Block Operation Code: */
84*5637d5b7SSergey Shtylyov /* 0x00: SCSI Initiator CCB, 0x01: SCSI Target CCB, */
85*5637d5b7SSergey Shtylyov /* 0x02: SCSI Initiator CCB with Scatter/Gather, */
86*5637d5b7SSergey Shtylyov /* 0x81: SCSI Bus Device Reset CCB */
87*5637d5b7SSergey Shtylyov u8 idlun; /* Address and Direction Control: */
88*5637d5b7SSergey Shtylyov /* Bits 7-5: op=0, 2: Target ID, op=1: Initiator ID */
89*5637d5b7SSergey Shtylyov /* Bit 4: Outbound data transfer, length is checked */
90*5637d5b7SSergey Shtylyov /* Bit 3: Inbound data transfer, length is checked */
91*5637d5b7SSergey Shtylyov /* Bits 2-0: Logical Unit Number */
92cb5b570cSOndrej Zary u8 cdblen; /* SCSI Command Length */
93*5637d5b7SSergey Shtylyov u8 rsalen; /* Request Sense Allocation Length/Disable Auto Sense */
94*5637d5b7SSergey Shtylyov u8 datalen[3]; /* Data Length (MSB, ..., LSB) */
95*5637d5b7SSergey Shtylyov u8 dataptr[3]; /* Data Pointer (MSB, ..., LSB) */
96*5637d5b7SSergey Shtylyov u8 linkptr[3]; /* Link Pointer (MSB, ..., LSB) */
97cb5b570cSOndrej Zary u8 commlinkid; /* Command Linking Identifier */
98cb5b570cSOndrej Zary u8 hastat; /* Host Adapter Status (HASTAT) */
99*5637d5b7SSergey Shtylyov u8 tarstat; /* Target Device Status (TARSTAT) */
100cb5b570cSOndrej Zary u8 reserved[2];
101cb5b570cSOndrej Zary u8 cdb[MAX_CDB + MAX_SENSE]; /* SCSI Command Descriptor Block */
102*5637d5b7SSergey Shtylyov /* followed by the Auto Sense data */
1031da177e4SLinus Torvalds };
1041da177e4SLinus Torvalds
1053a70c006SOndrej Zary #define AHA1542_REGION_SIZE 4
1061da177e4SLinus Torvalds #define AHA1542_MAILBOXES 8
1071da177e4SLinus Torvalds
108e51dacbfSOndrej Zary #endif /* _AHA1542_H_ */
109