bea9a252b27910490f14e55a45cb7216e03e85a4
[dragonfly.git] / sys / bus / firewire / fwohcivar.h
1 /*
2  * Copyright (c) 2003 Hidetoshi SHimokawa
3  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi SHimokawa
4  * 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. All advertising materials mentioning features or use of this software
15  *    must display the acknowledgement as bellow:
16  *
17  *    This product includes software developed by K. Kobayashi and H. Shimokawa
18  *
19  * 4. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
26  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  * 
34  * $FreeBSD: src/sys/dev/firewire/fwohcivar.h,v 1.1.2.6 2003/04/28 03:29:18 simokawa Exp $
35  * $DragonFly: src/sys/bus/firewire/fwohcivar.h,v 1.3 2003/08/27 11:42:34 rob Exp $
36  *
37  */
38
39 #if __FreeBSD_version >= 500000
40 #define FWOHCI_TASKQUEUE        1
41 #else
42 #define FWOHCI_TASKQUEUE        0
43 #endif
44 #if FWOHCI_TASKQUEUE
45 #include <sys/taskqueue.h>
46 #endif
47
48 typedef struct fwohci_softc {
49         struct firewire_comm fc;
50         bus_space_tag_t bst;
51         bus_space_handle_t bsh;
52         void *ih;
53 #if __FreeBSD_version < 500000
54         void *ih_cam;
55 #endif
56         struct resource *bsr;
57         struct resource *irq_res;
58         struct fwohci_dbch{
59                 u_int ndb;
60                 u_int ndesc;
61                 STAILQ_HEAD(, fwohcidb_tr) db_trq;
62                 struct fwohcidb_tr *top, *bottom, *pdb_tr;
63                 struct fw_xferq xferq;
64                 int flags;
65 #define FWOHCI_DBCH_INIT        (1<<0)
66 #define FWOHCI_DBCH_FULL        (1<<1)
67                 /* used only in receive context */
68                 int buf_offset; /* signed */
69 #define FWOHCI_DBCH_MAX_PAGES   32
70                 /* Context programs buffer */
71                 struct fwdma_alloc_multi *am;
72                 bus_dma_tag_t dmat;
73         } arrq, arrs, atrq, atrs, it[OHCI_DMA_ITCH], ir[OHCI_DMA_IRCH];
74         u_int maxrec;
75         u_int32_t *sid_buf;
76         struct fwdma_alloc sid_dma;
77         struct fwdma_alloc crom_dma;
78         struct fwdma_alloc dummy_dma;
79         u_int32_t intmask, irstat, itstat;
80 #if FWOHCI_TASKQUEUE
81         u_int32_t intstat;
82         struct task fwohci_task_complete;
83 #endif
84 } fwohci_softc_t;
85
86 void fwohci_intr (void *arg);
87 int fwohci_init (struct fwohci_softc *, device_t);
88 void fwohci_reset (struct fwohci_softc *, device_t);
89 int fwohci_detach (struct fwohci_softc *, device_t);
90 int fwohci_resume (struct fwohci_softc *, device_t);
91 int fwohci_stop (struct fwohci_softc *, device_t dev);