Home | History | Annotate | Line # | Download | only in dev
ncr5380reg.h revision 1.1
      1  1.1  leo /*	$NetBSD: ncr5380reg.h,v 1.1 1995/03/26 07:12:15 leo Exp $	*/
      2  1.1  leo 
      3  1.1  leo /*
      4  1.1  leo  * Copyright (c) 1995 Leo Weppelman.
      5  1.1  leo  * All rights reserved.
      6  1.1  leo  *
      7  1.1  leo  * Redistribution and use in source and binary forms, with or without
      8  1.1  leo  * modification, are permitted provided that the following conditions
      9  1.1  leo  * are met:
     10  1.1  leo  * 1. Redistributions of source code must retain the above copyright
     11  1.1  leo  *    notice, this list of conditions and the following disclaimer.
     12  1.1  leo  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  leo  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  leo  *    documentation and/or other materials provided with the distribution.
     15  1.1  leo  * 3. All advertising materials mentioning features or use of this software
     16  1.1  leo  *    must display the following acknowledgement:
     17  1.1  leo  *      This product includes software developed by Leo Weppelman.
     18  1.1  leo  * 4. The name of the author may not be used to endorse or promote products
     19  1.1  leo  *    derived from this software without specific prior written permission
     20  1.1  leo  *
     21  1.1  leo  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1  leo  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1  leo  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1  leo  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1  leo  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1  leo  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1  leo  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1  leo  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1  leo  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1  leo  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.1  leo  */
     32  1.1  leo 
     33  1.1  leo #ifndef _NCR5380REG_H
     34  1.1  leo #define _NCR5380REG_H
     35  1.1  leo /*
     36  1.1  leo  * Atari TT hardware:
     37  1.1  leo  * SCSI interface + DMA.
     38  1.1  leo  * The SCSI chip is an NCR5380
     39  1.1  leo  */
     40  1.1  leo 
     41  1.1  leo 
     42  1.1  leo #define	SCSI_DMA	((struct scsi_dma *)AD_SCSI_DMA)
     43  1.1  leo #define	SCSI_5380	((struct scsi_5380 *)AD_NCR5380)
     44  1.1  leo 
     45  1.1  leo struct scsi_dma {
     46  1.1  leo 	volatile u_char		s_dma_ptr[8];	/* use only the odd bytes */
     47  1.1  leo 	volatile u_char		s_dma_cnt[8];	/* use only the odd bytes */
     48  1.1  leo 	volatile u_char		s_dma_res[4];	/* data residue register  */
     49  1.1  leo 	volatile u_char		s_dma_gap;	/* not used		  */
     50  1.1  leo 	volatile u_char		s_dma_ctrl;	/* control register	  */
     51  1.1  leo };
     52  1.1  leo 
     53  1.1  leo #define	set_scsi_dma(addr, val)	(void)(					\
     54  1.1  leo 	{								\
     55  1.1  leo 	u_char	*address = (u_char*)addr+1;				\
     56  1.1  leo 	u_long	nval	 = (u_long)val;					\
     57  1.1  leo 	__asm("movepl	%0, %1@(0)": :"d" (nval), "a" (address));	\
     58  1.1  leo 	})
     59  1.1  leo 
     60  1.1  leo #define	get_scsi_dma(addr, res)	(					\
     61  1.1  leo 	{								\
     62  1.1  leo 	u_char	*address = (u_char*)addr+1;				\
     63  1.1  leo 	u_long	nval;							\
     64  1.1  leo 	__asm("movepl	%1@(0), %0": "=d" (nval) : "a" (address));	\
     65  1.1  leo 	res = (u_long)nval;						\
     66  1.1  leo 	})
     67  1.1  leo 
     68  1.1  leo /*
     69  1.1  leo  * Defines for DMA control register
     70  1.1  leo  */
     71  1.1  leo #define	SD_BUSERR	0x80		/* 1 = transfer caused bus error*/
     72  1.1  leo #define	SD_ZERO		0x40		/* 1 = byte counter is zero	*/
     73  1.1  leo #define	SD_ENABLE	0x02		/* 1 = Enable DMA		*/
     74  1.1  leo #define	SD_OUT		0x01		/* Direction: memory to SCSI	*/
     75  1.1  leo #define	SD_IN		0x00		/* Direction: SCSI to memory	*/
     76  1.1  leo 
     77  1.1  leo struct scsi_5380 {
     78  1.1  leo 	volatile u_char	scsi_5380[16];	/* use only the odd bytes	*/
     79  1.1  leo };
     80  1.1  leo 
     81  1.1  leo #define	scsi_data	scsi_5380[ 1]	/* Data register		*/
     82  1.1  leo #define	scsi_icom	scsi_5380[ 3]	/* Initiator command register	*/
     83  1.1  leo #define	scsi_mode	scsi_5380[ 5]	/* Mode register		*/
     84  1.1  leo #define	scsi_tcom	scsi_5380[ 7]	/* Target command register	*/
     85  1.1  leo #define	scsi_idstat	scsi_5380[ 9]	/* Bus status register		*/
     86  1.1  leo #define	scsi_dmstat	scsi_5380[11]	/* DMA status register		*/
     87  1.1  leo #define	scsi_trcv	scsi_5380[13]	/* Target receive register	*/
     88  1.1  leo #define	scsi_ircv	scsi_5380[15]	/* Initiator receive register	*/
     89  1.1  leo 
     90  1.1  leo /*
     91  1.1  leo  * Definitions for Initiator command register.
     92  1.1  leo  */
     93  1.1  leo #define	SC_A_RST	0x80	/* RW - Assert RST			*/
     94  1.1  leo #define	SC_TEST		0x40	/* W  - Test mode			*/
     95  1.1  leo #define	SC_AIP		0x40	/* R  - Arbitration in progress		*/
     96  1.1  leo #define	SC_LA		0x20	/* R  - Lost arbitration		*/
     97  1.1  leo #define	SC_A_ACK	0x10	/* RW - Assert ACK			*/
     98  1.1  leo #define	SC_A_BSY	0x08	/* RW - Assert BSY			*/
     99  1.1  leo #define	SC_A_SEL	0x04	/* RW - Assert SEL			*/
    100  1.1  leo #define	SC_A_ATN	0x02	/* RW - Assert ATN			*/
    101  1.1  leo #define	SC_ADTB		0x01	/* RW - Assert Data To Bus		*/
    102  1.1  leo 
    103  1.1  leo /*
    104  1.1  leo  * Definitions for mode register
    105  1.1  leo  */
    106  1.1  leo #define	SC_B_DMA	0x80	/* RW - Block mode DMA (not on TT!)	*/
    107  1.1  leo #define	SC_T_MODE	0x40	/* RW - Target mode			*/
    108  1.1  leo #define	SC_E_PAR	0x20	/* RW - Enable parity check		*/
    109  1.1  leo #define	SC_E_PARI	0x10	/* RW - Enable parity interrupt		*/
    110  1.1  leo #define	SC_E_EOPI	0x08	/* RW - Enable End Of Process Interrupt	*/
    111  1.1  leo #define	SC_MON_BSY	0x04	/* RW - Monitor BSY			*/
    112  1.1  leo #define	SC_M_DMA	0x02	/* RW - Set DMA mode			*/
    113  1.1  leo #define	SC_ARBIT	0x01	/* RW - Arbitrate			*/
    114  1.1  leo 
    115  1.1  leo /*
    116  1.1  leo  * Definitions for tcom register
    117  1.1  leo  */
    118  1.1  leo #define	SC_LBS		0x80	/* RW - Last Byte Send (not on TT!)	*/
    119  1.1  leo #define	SC_A_REQ	0x08	/* RW - Assert REQ			*/
    120  1.1  leo #define	SC_A_MSG	0x04	/* RW - Assert MSG			*/
    121  1.1  leo #define	SC_A_CD		0x02	/* RW - Assert C/D			*/
    122  1.1  leo #define	SC_A_IO		0x01	/* RW - Assert I/O			*/
    123  1.1  leo 
    124  1.1  leo /*
    125  1.1  leo  * Definitions for idstat register
    126  1.1  leo  */
    127  1.1  leo #define	SC_S_RST	0x80	/* R  - RST is set			*/
    128  1.1  leo #define	SC_S_BSY	0x40	/* R  - BSY is set			*/
    129  1.1  leo #define	SC_S_REQ	0x20	/* R  - REQ is set			*/
    130  1.1  leo #define	SC_S_MSG	0x10	/* R  - MSG is set			*/
    131  1.1  leo #define	SC_S_CD		0x08	/* R  - C/D is set			*/
    132  1.1  leo #define	SC_S_IO		0x04	/* R  - I/O is set			*/
    133  1.1  leo #define	SC_S_SEL	0x02	/* R  - SEL is set			*/
    134  1.1  leo #define	SC_S_PAR	0x01	/* R  - Parity bit			*/
    135  1.1  leo 
    136  1.1  leo /*
    137  1.1  leo  * Definitions for dmastat register
    138  1.1  leo  */
    139  1.1  leo #define	SC_END_DMA	0x80	/* R  - End of DMA			*/
    140  1.1  leo #define	SC_DMA_REQ	0x40	/* R  - DMA request			*/
    141  1.1  leo #define	SC_PAR_ERR	0x20	/* R  - Parity error			*/
    142  1.1  leo #define	SC_IRQ_SET	0x10	/* R  - IRQ is active			*/
    143  1.1  leo #define	SC_PHS_MTCH	0x08	/* R  - Phase Match			*/
    144  1.1  leo #define	SC_BSY_ERR	0x04	/* R  - Busy error			*/
    145  1.1  leo #define	SC_ATN_STAT	0x02	/* R  - State of ATN line		*/
    146  1.1  leo #define	SC_ACK_STAT	0x01	/* R  - State of ACK line		*/
    147  1.1  leo #define	SC_S_SEND	0x00	/* W  - Start DMA output		*/
    148  1.1  leo 
    149  1.1  leo #define	SC_CLINT	{ 		/* Clear interrupts	*/	\
    150  1.1  leo 			int i = SCSI_5380->scsi_ircv;			\
    151  1.1  leo 			}
    152  1.1  leo 
    153  1.1  leo 
    154  1.1  leo /*
    155  1.1  leo  * Definition of SCSI-bus phases. The values are determined by signals
    156  1.1  leo  * on the SCSI-bus. DO NOT CHANGE!
    157  1.1  leo  * The values must be used to index the pointers in SCSI-PARMS.
    158  1.1  leo  */
    159  1.1  leo #define	NR_PHASE	8
    160  1.1  leo #define	PH_DATAOUT	0
    161  1.1  leo #define	PH_DATAIN	1
    162  1.1  leo #define	PH_CMD		2
    163  1.1  leo #define	PH_STATUS	3
    164  1.1  leo #define	PH_RES1		4
    165  1.1  leo #define	PH_RES2		5
    166  1.1  leo #define	PH_MSGOUT	6
    167  1.1  leo #define	PH_MSGIN	7
    168  1.1  leo 
    169  1.1  leo #define	PH_OUT(phase)	(!(phase & 1))	/* TRUE if output phase		*/
    170  1.1  leo #define	PH_IN(phase)	(phase & 1)	/* TRUE if input phase		*/
    171  1.1  leo 
    172  1.1  leo /*
    173  1.1  leo  * Id of Host-adapter
    174  1.1  leo  */
    175  1.1  leo #define SC_HOST_ID	0x80
    176  1.1  leo 
    177  1.1  leo /*
    178  1.1  leo  * Base setting for 5380 mode register
    179  1.1  leo  */
    180  1.1  leo #define	IMODE_BASE	SC_E_PAR
    181  1.1  leo 
    182  1.1  leo #endif /* _NCR5380REG_H */
    183