fwohcivar.h revision 139749
1139749Simp/*-
2113584Ssimokawa * Copyright (c) 2003 Hidetoshi SHimokawa
3103285Sikob * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi SHimokawa
4103285Sikob * All rights reserved.
5103285Sikob *
6103285Sikob * Redistribution and use in source and binary forms, with or without
7103285Sikob * modification, are permitted provided that the following conditions
8103285Sikob * are met:
9103285Sikob * 1. Redistributions of source code must retain the above copyright
10103285Sikob *    notice, this list of conditions and the following disclaimer.
11103285Sikob * 2. Redistributions in binary form must reproduce the above copyright
12103285Sikob *    notice, this list of conditions and the following disclaimer in the
13103285Sikob *    documentation and/or other materials provided with the distribution.
14103285Sikob * 3. All advertising materials mentioning features or use of this software
15103285Sikob *    must display the acknowledgement as bellow:
16103285Sikob *
17103285Sikob *    This product includes software developed by K. Kobayashi and H. Shimokawa
18103285Sikob *
19103285Sikob * 4. The name of the author may not be used to endorse or promote products
20103285Sikob *    derived from this software without specific prior written permission.
21103285Sikob *
22103285Sikob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23103285Sikob * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24103285Sikob * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25103285Sikob * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
26103285Sikob * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27103285Sikob * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28103285Sikob * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29103285Sikob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30103285Sikob * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31103285Sikob * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32103285Sikob * POSSIBILITY OF SUCH DAMAGE.
33103285Sikob *
34103285Sikob * $FreeBSD: head/sys/dev/firewire/fwohcivar.h 139749 2005-01-06 01:43:34Z imp $
35103285Sikob *
36103285Sikob */
37113584Ssimokawa
38127468Ssimokawa#if defined(__DragonFly__) || __FreeBSD_version < 500000
39127468Ssimokawa#define FWOHCI_TASKQUEUE        0
40127468Ssimokawa#else
41113584Ssimokawa#define FWOHCI_TASKQUEUE        1
42113584Ssimokawa#endif
43113584Ssimokawa#if FWOHCI_TASKQUEUE
44113584Ssimokawa#include <sys/taskqueue.h>
45113584Ssimokawa#endif
46113584Ssimokawa
47103285Sikobtypedef struct fwohci_softc {
48103285Sikob	struct firewire_comm fc;
49103285Sikob	bus_space_tag_t bst;
50103285Sikob	bus_space_handle_t bsh;
51103285Sikob	void *ih;
52127468Ssimokawa#if defined(__DragonFly__) || __FreeBSD_version < 500000
53103285Sikob	void *ih_cam;
54121506Ssimokawa	void *ih_bio;
55103285Sikob#endif
56103285Sikob	struct resource *bsr;
57103285Sikob	struct resource *irq_res;
58103285Sikob	struct fwohci_dbch{
59103285Sikob		u_int ndb;
60103285Sikob		u_int ndesc;
61103285Sikob		STAILQ_HEAD(, fwohcidb_tr) db_trq;
62103285Sikob		struct fwohcidb_tr *top, *bottom, *pdb_tr;
63103285Sikob		struct fw_xferq xferq;
64103285Sikob		int flags;
65108527Ssimokawa#define	FWOHCI_DBCH_INIT	(1<<0)
66103285Sikob#define	FWOHCI_DBCH_FULL	(1<<1)
67113584Ssimokawa		/* used only in receive context */
68113584Ssimokawa		int buf_offset;	/* signed */
69109379Ssimokawa#define FWOHCI_DBCH_MAX_PAGES	32
70113584Ssimokawa		/* Context programs buffer */
71113584Ssimokawa		struct fwdma_alloc_multi *am;
72113584Ssimokawa		bus_dma_tag_t dmat;
73108276Ssimokawa	} arrq, arrs, atrq, atrs, it[OHCI_DMA_ITCH], ir[OHCI_DMA_IRCH];
74103285Sikob	u_int maxrec;
75129585Sdfr	uint32_t *sid_buf;
76113584Ssimokawa	struct fwdma_alloc sid_dma;
77113584Ssimokawa	struct fwdma_alloc crom_dma;
78113584Ssimokawa	struct fwdma_alloc dummy_dma;
79129585Sdfr	uint32_t intmask, irstat, itstat;
80113584Ssimokawa#if FWOHCI_TASKQUEUE
81129585Sdfr	uint32_t intstat;
82113584Ssimokawa	struct task fwohci_task_complete;
83113584Ssimokawa#endif
84103285Sikob} fwohci_softc_t;
85113584Ssimokawa
86124169Ssimokawavoid fwohci_intr (void *arg);
87124169Ssimokawaint fwohci_init (struct fwohci_softc *, device_t);
88124169Ssimokawavoid fwohci_poll (struct firewire_comm *, int, int);
89124169Ssimokawavoid fwohci_reset (struct fwohci_softc *, device_t);
90124169Ssimokawaint fwohci_detach (struct fwohci_softc *, device_t);
91124169Ssimokawaint fwohci_resume (struct fwohci_softc *, device_t);
92124169Ssimokawaint fwohci_stop (struct fwohci_softc *, device_t dev);
93