ncr5380var.h revision 1.1 1 /* $NetBSD: ncr5380var.h,v 1.1 1995/07/08 21:30:44 pk Exp $ */
2
3 /*
4 * Copyright (C) 1994 Adam Glass, Gordon W. Ross
5 * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
6 * Michael L. Finch, Bradley A. Grantham, and
7 * Lawrence A. Kesteloot
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the Alice Group.
21 * 4. The names of the Alice Group or any of its members may not be used
22 * to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR
26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #define SCI_PHASE_DISC 0 /* sort of ... */
38 #define SCI_CLR_INTR(regs) ((volatile)(regs->sci_iack))
39 #define SCI_ACK(ptr,phase) (ptr)->sci_tcmd = (phase)
40 #define SCSI_TIMEOUT_VAL 1000000
41 #define WAIT_FOR_NOT_REQ(ptr) { \
42 int scsi_timeout = SCSI_TIMEOUT_VAL; \
43 while ( ((ptr)->sci_bus_csr & SCI_BUS_REQ) && \
44 ((ptr)->sci_bus_csr & SCI_BUS_REQ) && \
45 ((ptr)->sci_bus_csr & SCI_BUS_REQ) && \
46 (--scsi_timeout) ); \
47 if (!scsi_timeout) { \
48 printf("scsi timeout--WAIT_FOR_NOT_REQ---%s, line %d.\n", \
49 __FILE__, __LINE__); \
50 goto scsi_timeout_error; \
51 } \
52 }
53 #define WAIT_FOR_REQ(ptr) { \
54 int scsi_timeout = SCSI_TIMEOUT_VAL; \
55 while ( (((ptr)->sci_bus_csr & SCI_BUS_REQ) == 0) && \
56 (((ptr)->sci_bus_csr & SCI_BUS_REQ) == 0) && \
57 (((ptr)->sci_bus_csr & SCI_BUS_REQ) == 0) && \
58 (--scsi_timeout) ); \
59 if (!scsi_timeout) { \
60 printf("scsi timeout--WAIT_FOR_REQ---%s, line %d.\n", \
61 __FILE__, __LINE__); \
62 goto scsi_timeout_error; \
63 } \
64 }
65 #define WAIT_FOR_BSY(ptr) { \
66 int scsi_timeout = SCSI_TIMEOUT_VAL; \
67 while ( (((ptr)->sci_bus_csr & SCI_BUS_BSY) == 0) && \
68 (((ptr)->sci_bus_csr & SCI_BUS_BSY) == 0) && \
69 (((ptr)->sci_bus_csr & SCI_BUS_BSY) == 0) && \
70 (--scsi_timeout) ); \
71 if (!scsi_timeout) { \
72 printf("scsi timeout--WAIT_FOR_BSY---%s, line %d.\n", \
73 __FILE__, __LINE__); \
74 goto scsi_timeout_error; \
75 } \
76 }
77
78 #define ARBITRATION_RETRIES 1000
79
80 #ifdef DDB
81 int Debugger();
82 #else
83 #define Debugger() panic("Should call Debugger here %s:%d", \
84 __FILE__, __LINE__)
85 #endif
86
87 struct ncr5380_softc {
88 struct device sc_dev;
89 struct intrhand sc_ih; /* interrupt info */
90 volatile void *sc_regs;
91 int sc_adapter_type;
92 int sc_adapter_iv_am; /* int. vec + address modifier */
93 struct scsi_link sc_link;
94 };
95
96 static int ncr5380_reset_scsibus __P((struct ncr5380_softc *));
97 static int ncr5380_poll __P((int, int));
98 static void ncr5380_sbc_intr __P((struct ncr5380_softc *));
99 static int ncr5380_send_cmd __P((struct scsi_xfer *));
100 static int ncr5380_scsi_cmd __P((struct scsi_xfer *));
101 static int ncr5380_data_in __P((sci_regmap_t *, int, int, u_char *));
102 static int ncr5380_data_out __P((sci_regmap_t *, int, int, u_char *));
103 static int ncr5380_select_target __P((volatile sci_regmap_t *, u_char,
104 u_char, int));
105 static int ncr5380_command_transfer __P((volatile sci_regmap_t *, int,
106 u_char *, u_char *, u_char *));
107 static int ncr5380_data_transfer __P((volatile sci_regmap_t *, int,
108 u_char *, u_char *, u_char *));
109 static int ncr5380_dorequest __P((struct ncr5380_softc *, int, int,
110 u_char *, int, char *, int, int *));
111
112 static int ncr5380_generic __P((int, int, int, struct scsi_generic *,
113 int, void *, int));
114 static int ncr5380_group0 __P((int, int, int, int, int, int,
115 int, caddr_t, int));
116
117
118