Home | History | Annotate | Line # | Download | only in dev
      1 /*	$NetBSD: sbcvar.h,v 1.15 2024/11/22 07:16:01 nat Exp $	*/
      2 
      3 /*
      4  * Copyright (C) 1996 Scott Reynolds.  All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. The name of the author may not be used to endorse or promote products
     15  *    derived from this software without specific prior written permission
     16  *
     17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 /*
     30  * Transfers smaller than this are done using PIO
     31  * (on assumption they're not worth PDMA overhead)
     32  */
     33 #define	MIN_DMA_LEN 128
     34 
     35 /*
     36  * Transfers larger than 8192 bytes need to be split up
     37  * due to the size of the PDMA space.
     38  */
     39 #define	MAX_DMA_LEN 0x2000
     40 
     41 /*
     42  * This structure is used to keep track of PDMA requests.
     43  */
     44 struct sbc_pdma_handle {
     45 	int	dh_flags;	/* flags */
     46 #define	SBC_DH_BUSY	0x01	/* This handle is in use */
     47 #define	SBC_DH_OUT	0x02	/* PDMA data out (write) */
     48 #define	SBC_DH_DONE	0x04	/* PDMA transfer is complete */
     49 	u_char	*dh_addr;	/* data buffer */
     50 	int	dh_len;		/* length of data buffer */
     51 };
     52 
     53 /*
     54  * The first structure member has to be the ncr5380_softc
     55  * so we can just cast to go back and forth between them.
     56  */
     57 struct sbc_softc {
     58 	struct ncr5380_softc ncr_sc;
     59 	volatile struct sbc_regs *sc_regs;
     60 	volatile vaddr_t	sc_drq_addr;
     61 	volatile vaddr_t	sc_nodrq_addr;
     62 	void			(*sc_clrintr)(struct ncr5380_softc *);
     63 	volatile int		sc_resid;
     64 	int			sc_options;	/* options for this instance. */
     65 	struct sbc_pdma_handle sc_pdma[SCI_OPENINGS];
     66 	kmutex_t		sc_drq_lock;
     67 };
     68 
     69 /*
     70  * Options.  By default, SCSI interrupts and reselect are disabled.
     71  * You may enable either of these features with the `flags' directive
     72  * in your kernel's configuration file.
     73  *
     74  * Alternatively, you can patch your kernel with DDB or some other
     75  * mechanism.  The sc_options member of the softc is OR'd with
     76  * the value in sbc_options.
     77  *
     78  * The options code is based on the sparc 'si' driver's version of
     79  * the same.
     80  */
     81 #define	SBC_PDMA		0x01	/* Use PDMA for polled transfers */
     82 #define	SBC_INTR		0x02	/* Allow SCSI IRQ/DRQ interrupts */
     83 #define	SBC_RESELECT		0x04	/* Allow disconnect/reselect */
     84 #define	SBC_PDMA_NO_WRITE	0x08	/* No PDMA for writes */
     85 #define	SBC_OPTIONS_MASK (SBC_PDMA_NO_WRITE|SBC_RESELECT|SBC_INTR|SBC_PDMA)
     86 #define	SBC_OPTIONS_BITS	"\10\4NOWRITE\3RESELECT\2INTR\1PDMA"
     87 
     88 extern int	sbc_debug;
     89 extern int	sbc_link_flags;
     90 extern int	sbc_options;
     91 
     92 int	sbc_pdma_in(struct ncr5380_softc *, int, int, u_char *);
     93 int	sbc_pdma_out(struct ncr5380_softc *, int, int, u_char *);
     94 void	sbc_irq_intr(void *);
     95 void	sbc_drq_intr(void *);
     96 void	sbc_dma_alloc(struct ncr5380_softc *);
     97 void	sbc_dma_free(struct ncr5380_softc *);
     98 void	sbc_dma_poll(struct ncr5380_softc *);
     99 void	sbc_dma_setup(struct ncr5380_softc *);
    100 void	sbc_dma_start(struct ncr5380_softc *);
    101 void	sbc_dma_eop(struct ncr5380_softc *);
    102 void	sbc_dma_stop(struct ncr5380_softc *);
    103 #ifdef SBC_DEBUG
    104 void	decode_5380_intr(struct ncr5380_softc *);
    105 #endif
    106