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