Home | History | Annotate | Line # | Download | only in ic
cacvar.h revision 1.3
      1 /*	$NetBSD: cacvar.h,v 1.3 2000/04/26 15:58:01 ad Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Andy Doran.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #ifndef _IC_CACVAR_H_
     40 #define _IC_CACVAR_H_
     41 
     42 #include "locators.h"
     43 
     44 #define	CAC_MAX_CCBS	20
     45 #define	CAC_MAX_XFER	(0xffff * 512)
     46 #define CAC_SG_SIZE	32
     47 
     48 struct cac_softc;
     49 struct cac_ccb;
     50 
     51 struct cac_context {
     52 	void		(*cc_handler) __P((struct cac_ccb *, int));
     53 	struct device	*cc_dv;
     54 	void 		*cc_context;
     55 };
     56 
     57 struct cac_ccb {
     58 	/* Data the controller will touch - 276 bytes */
     59 	struct cac_hdr	ccb_hdr;
     60 	struct cac_req	ccb_req;
     61 	struct cac_sgb	ccb_seg[CAC_SG_SIZE];
     62 
     63 	/* Data the controller won't touch */
     64 	int		ccb_flags;
     65 	int		ccb_datasize;
     66 	paddr_t		ccb_paddr;
     67 	bus_dmamap_t	ccb_dmamap_xfer;
     68 	SIMPLEQ_ENTRY(cac_ccb) ccb_chain;
     69 	struct cac_context ccb_context;
     70 };
     71 
     72 #define	CAC_CCB_DATA_IN		0x0001
     73 #define	CAC_CCB_DATA_OUT	0x0002
     74 
     75 struct cac_linkage {
     76 	void	(*cl_submit) __P((struct cac_softc *, paddr_t));
     77 	paddr_t	(*cl_completed) __P((struct cac_softc *));
     78 	int	(*cl_intr_pending) __P((struct cac_softc *));
     79 	void	(*cl_intr_enable) __P((struct cac_softc *, int));
     80 	int	(*cl_fifo_full) __P((struct cac_softc *));
     81 };
     82 
     83 struct cac_softc {
     84 	struct device		sc_dv;
     85 	bus_space_tag_t		sc_iot;
     86 	bus_space_handle_t	sc_ioh;
     87 	bus_dma_tag_t		sc_dmat;
     88 	bus_dmamap_t		sc_dmamap;
     89 	void			*sc_ih;
     90 	struct cac_linkage	*sc_cl;
     91 	char			*sc_typestr;
     92 	caddr_t			sc_ccbs;
     93 	paddr_t			sc_ccbs_paddr;
     94 	SIMPLEQ_HEAD(, cac_ccb)	sc_ccb_free;
     95 	SIMPLEQ_HEAD(, cac_ccb)	sc_ccb_queue;
     96 	SIMPLEQ_ENTRY(cac_softc) sc_chain;
     97 };
     98 
     99 struct cac_attach_args {
    100 	int		caca_unit;
    101 };
    102 
    103 #define CACACF_UNIT	0
    104 
    105 #define	cacacf_unit	cf_loc[CACACF_UNIT]
    106 
    107 #define	CACACF_UNIT_UNKNOWN 	-1
    108 
    109 int	cac_cmd __P((struct cac_softc *, int, void *, int, int, int, int,
    110 		struct cac_context *));
    111 void	cac_minphys __P((struct buf *));
    112 int	cac_intr __P((void *));
    113 int	cac_init __P((struct cac_softc *, const char *));
    114 void	cac_ccb_free __P((struct cac_softc *, struct cac_ccb *));
    115 int	cac_ccb_start __P((struct cac_softc *, struct cac_ccb *));
    116 struct	cac_ccb *cac_ccb_alloc __P((struct cac_softc *, int));
    117 
    118 #endif	/* !_IC_CACVAR_H_ */
    119