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