FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/cacvar.h
1 /* $NetBSD: cacvar.h,v 1.11 2005/02/27 00:27:01 perry 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 Andrew 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 #define CAC_MAX_CCBS 20
43 #define CAC_MAX_XFER (0xffff * 512)
44 #define CAC_SG_SIZE 32
45
46 #define cac_inb(sc, port) \
47 bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, port)
48 #define cac_inw(sc, port) \
49 bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, port)
50 #define cac_inl(sc, port) \
51 bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, port)
52 #define cac_outb(sc, port, val) \
53 bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh, port, val)
54 #define cac_outw(sc, port, val) \
55 bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, port, val)
56 #define cac_outl(sc, port, val) \
57 bus_space_write_4((sc)->sc_iot, (sc)->sc_ioh, port, val)
58
59 /*
60 * Stupid macros to deal with alignment/endianness issues.
61 */
62
63 #define CAC_GET1(x) \
64 (((u_char *)&(x))[0])
65 #define CAC_GET2(x) \
66 (((u_char *)&(x))[0] | (((u_char *)&(x))[1] << 8))
67 #define CAC_GET4(x) \
68 ((((u_char *)&(x))[0] | (((u_char *)&(x))[1] << 8)) | \
69 (((u_char *)&(x))[0] << 16 | (((u_char *)&(x))[1] << 24)))
70
71 struct cac_softc;
72 struct cac_ccb;
73
74 struct cac_context {
75 void (*cc_handler)(struct device *, void *, int);
76 struct device *cc_dv;
77 void *cc_context;
78 };
79
80 struct cac_ccb {
81 /* Data the controller will touch - 276 bytes */
82 struct cac_hdr ccb_hdr;
83 struct cac_req ccb_req;
84 struct cac_sgb ccb_seg[CAC_SG_SIZE];
85
86 /* Data the controller won't touch */
87 int ccb_flags;
88 int ccb_datasize;
89 paddr_t ccb_paddr;
90 bus_dmamap_t ccb_dmamap_xfer;
91 SIMPLEQ_ENTRY(cac_ccb) ccb_chain;
92 struct cac_context ccb_context;
93 };
94
95 #define CAC_CCB_DATA_IN 0x0001 /* Map describes inbound xfer */
96 #define CAC_CCB_DATA_OUT 0x0002 /* Map describes outbound xfer */
97 #define CAC_CCB_ACTIVE 0x0004 /* Command submitted to controller */
98
99 struct cac_linkage {
100 struct cac_ccb *(*cl_completed)(struct cac_softc *);
101 int (*cl_fifo_full)(struct cac_softc *);
102 void (*cl_intr_enable)(struct cac_softc *, int);
103 int (*cl_intr_pending)(struct cac_softc *);
104 void (*cl_submit)(struct cac_softc *, struct cac_ccb *);
105 };
106
107 struct cac_softc {
108 struct device sc_dv;
109 bus_space_tag_t sc_iot;
110 bus_space_handle_t sc_ioh;
111 bus_dma_tag_t sc_dmat;
112 bus_dmamap_t sc_dmamap;
113 int sc_nunits;
114 void *sc_ih;
115 caddr_t sc_ccbs;
116 paddr_t sc_ccbs_paddr;
117 SIMPLEQ_HEAD(, cac_ccb) sc_ccb_free;
118 SIMPLEQ_HEAD(, cac_ccb) sc_ccb_queue;
119 struct cac_linkage sc_cl;
120 };
121
122 struct cac_attach_args {
123 int caca_unit;
124 };
125
126 int cac_cmd(struct cac_softc *, int, void *, int, int, int, int,
127 struct cac_context *);
128 int cac_init(struct cac_softc *, const char *, int);
129 int cac_intr(void *);
130
131 extern const struct cac_linkage cac_l0;
132
133 #endif /* !_IC_CACVAR_H_ */
Cache object: 594a2a167c73203c2d4b44cdb860b113
|