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