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