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