xref: /netbsd-src/sys/dev/ic/dptvar.h (revision cbab9cadce21ae72fac13910001079fff214cc29)
1*cbab9cadSchs /*	$NetBSD: dptvar.h,v 1.16 2012/10/27 17:18:20 chs Exp $	*/
248a0b623Sad 
348a0b623Sad /*
4b8702f53Skeihan  * Copyright (c) 1999, 2000, 2001 Andrew Doran <ad@NetBSD.org>
548a0b623Sad  * All rights reserved.
648a0b623Sad  *
748a0b623Sad  * Redistribution and use in source and binary forms, with or without
848a0b623Sad  * modification, are permitted provided that the following conditions
948a0b623Sad  * are met:
1048a0b623Sad  * 1. Redistributions of source code must retain the above copyright
1148a0b623Sad  *    notice, this list of conditions and the following disclaimer.
1248a0b623Sad  * 2. Redistributions in binary form must reproduce the above copyright
1348a0b623Sad  *    notice, this list of conditions and the following disclaimer in the
1448a0b623Sad  *    documentation and/or other materials provided with the distribution.
1548a0b623Sad  *
1648a0b623Sad  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1748a0b623Sad  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1848a0b623Sad  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1948a0b623Sad  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2048a0b623Sad  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2148a0b623Sad  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2248a0b623Sad  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2348a0b623Sad  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2448a0b623Sad  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2548a0b623Sad  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2648a0b623Sad  * SUCH DAMAGE.
2748a0b623Sad  *
2848a0b623Sad  */
2948a0b623Sad 
3048a0b623Sad #ifndef _IC_DPTVAR_H_
3148a0b623Sad #define _IC_DPTVAR_H_ 1
32937a7a3eSbouyer 
33937a7a3eSbouyer /* Software parameters */
34937a7a3eSbouyer #define DPT_SG_SIZE        	17
35937a7a3eSbouyer #define	DPT_MAX_XFER		65536
36937a7a3eSbouyer #define DPT_MAX_CCBS		256
37937a7a3eSbouyer #define DPT_ABORT_TIMEOUT	2000	/* milliseconds */
38937a7a3eSbouyer #define DPT_SCRATCH_SIZE	256	/* bytes */
3948a0b623Sad 
40f6e42db7Sad #define	CCB_OFF(sc,m)	((u_long)(m) - (u_long)((sc)->sc_ccbs))
4148a0b623Sad 
4250062f09Sad #define CCB_ABORT	0x01	/* abort has been issued on this CCB */
4350062f09Sad #define CCB_INTR	0x02	/* HBA interrupted for this CCB */
4450062f09Sad #define CCB_PRIVATE	0x04	/* ours; don't talk to scsipi when done */
4559773deaSad #define CCB_WAIT	0x08	/* sleeping on completion */
4648a0b623Sad 
4748a0b623Sad struct dpt_ccb {
4850062f09Sad 	/* Data that will be touched by the HBA */
4948a0b623Sad 	struct eata_cp	ccb_eata_cp;		/* EATA command packet */
5048a0b623Sad 	struct eata_sg	ccb_sg[DPT_SG_SIZE];	/* SG element list */
51df9803ceSthorpej 	struct scsi_sense_data ccb_sense;	/* SCSI sense data on error */
5250062f09Sad 
5350062f09Sad 	/* Data that will not be touched by the HBA */
5448a0b623Sad 	volatile int	ccb_flg;		/* CCB flags */
5548a0b623Sad 	int		ccb_timeout;		/* timeout in ms */
5648a0b623Sad 	u_int32_t	ccb_ccbpa;		/* physical addr of this CCB */
5748a0b623Sad 	bus_dmamap_t	ccb_dmamap_xfer;	/* dmamap for data xfers */
5848a0b623Sad 	int		ccb_hba_status;		/* from status packet */
5948a0b623Sad 	int		ccb_scsi_status;	/* from status packet */
6048a0b623Sad 	int		ccb_id;			/* unique ID of this CCB */
61937a7a3eSbouyer 	SLIST_ENTRY(dpt_ccb) ccb_chain;		/* link to next CCB */
6248a0b623Sad 	struct scsipi_xfer *ccb_xs;		/* initiating SCSI command */
6359773deaSad 	struct eata_sp	*ccb_savesp;		/* saved status packet */
6448a0b623Sad };
6548a0b623Sad 
6648a0b623Sad struct dpt_softc {
67*cbab9cadSchs 	device_t	sc_dev;		/* generic device data */
681293cee4Srmind 	kmutex_t	sc_lock;
69937a7a3eSbouyer 	struct scsipi_adapter sc_adapt;	/* scsipi adapter */
70937a7a3eSbouyer 	struct scsipi_channel sc_chans[3]; /* each channel */
7148a0b623Sad 	bus_space_handle_t sc_ioh;	/* bus space handle */
7248a0b623Sad 	bus_space_tag_t	sc_iot;		/* bus space tag */
7348a0b623Sad 	bus_dma_tag_t	sc_dmat;	/* bus DMA tag */
7450062f09Sad 	bus_dmamap_t	sc_dmamap;	/* maps the CCBs */
7548a0b623Sad 	void	 	*sc_ih;		/* interrupt handler cookie */
7648a0b623Sad 	struct dpt_ccb	*sc_ccbs;	/* all our CCBs */
7750062f09Sad 	struct eata_sp	*sc_stp;	/* EATA status packet */
7850062f09Sad 	int		sc_stpoff;	/* status packet offset in dmamap */
7950062f09Sad 	u_int32_t	sc_stppa;	/* status packet physical address */
8053524e44Schristos 	void *		sc_scr;		/* scratch area */
8148a0b623Sad 	int		sc_scroff;	/* scratch area offset in dmamap */
8248a0b623Sad 	u_int32_t	sc_scrpa;	/* scratch area physical address */
8348a0b623Sad 	int		sc_hbaid[3];	/* ID of HBA on each channel */
8448a0b623Sad 	int		sc_nccbs;	/* number of CCBs available */
85937a7a3eSbouyer 	SLIST_HEAD(, dpt_ccb) sc_ccb_free;/* free ccb list */
8650062f09Sad 	struct eata_cfg sc_ec;		/* EATA configuration data */
8759773deaSad 	int		sc_bustype;	/* SysInfo bus type */
8859773deaSad 	int		sc_isadrq;	/* ISA DRQ */
8959773deaSad 	int		sc_isairq;	/* ISA IRQ */
9059773deaSad 	int		sc_isaport;	/* ISA port */
9148a0b623Sad };
9248a0b623Sad 
93937a7a3eSbouyer void	dpt_init(struct dpt_softc *, const char *);
94937a7a3eSbouyer int	dpt_intr(void *);
95937a7a3eSbouyer int	dpt_readcfg(struct dpt_softc *);
9648a0b623Sad 
9748a0b623Sad #endif	/* !defined _IC_DPTVAR_H_ */
98