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