xref: /netbsd/sys/dev/ic/siisatavar.h (revision 6550d01e)
1 /* $NetBSD: siisatavar.h,v 1.6 2010/07/26 15:41:33 jakllsch Exp $ */
2 
3 /* from ahcisatavar.h */
4 
5 /*
6  * Copyright (c) 2006 Manuel Bouyer.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 /*-
31  * Copyright (c) 2007, 2008, 2009 Jonathan A. Kollasch.
32  * All rights reserved.
33  *
34  * Redistribution and use in source and binary forms, with or without
35  * modification, are permitted provided that the following conditions
36  * are met:
37  * 1. Redistributions of source code must retain the above copyright
38  *    notice, this list of conditions and the following disclaimer.
39  * 2. Redistributions in binary form must reproduce the above copyright
40  *    notice, this list of conditions and the following disclaimer in the
41  *    documentation and/or other materials provided with the distribution.
42  *
43  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
44  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
45  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
46  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
47  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
52  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53  *
54  */
55 
56 #ifndef _IC_SIISATAVAR_H_
57 #define _IC_SIISATAVAR_H_
58 
59 #include <dev/ic/siisatareg.h>
60 #include <dev/ata/atavar.h>
61 
62 #define DEBUG_INTR   0x01
63 #define DEBUG_XFERS  0x02
64 #define DEBUG_FUNCS  0x08
65 #define DEBUG_PROBE  0x10
66 #define DEBUG_DETACH 0x20
67 #define DEBUG_DEBUG 0x80000000
68 #ifdef SIISATA_DEBUG
69 extern int siisata_debug_mask;
70 #define SIISATA_DEBUG_PRINT(args, level) \
71 	if (siisata_debug_mask & (level)) \
72 		printf args
73 #else
74 #define SIISATA_DEBUG_PRINT(args, level)
75 #endif
76 
77 struct siisata_softc {
78 	struct atac_softc sc_atac;
79 	bus_space_tag_t sc_grt;
80 	bus_space_handle_t sc_grh;
81 	bus_size_t sc_grs;
82 	bus_space_tag_t sc_prt;
83 	bus_space_handle_t sc_prh;
84 	bus_size_t sc_prs;
85 	bus_dma_tag_t sc_dmat;
86 
87 	struct ata_channel *sc_chanarray[SIISATA_MAX_PORTS];
88 	struct siisata_channel {
89 		struct ata_channel ata_channel;
90 		bus_space_handle_t sch_scontrol;
91 		bus_space_handle_t sch_sstatus;
92 		bus_space_handle_t sch_serror;
93 
94 		bus_dma_segment_t sch_prb_seg;
95 		int sch_prb_nseg;
96 		bus_dmamap_t sch_prbd;
97 		/* command activation PRBs */
98 		struct siisata_prb *sch_prb[SIISATA_MAX_SLOTS];
99 		bus_addr_t sch_bus_prb[SIISATA_MAX_SLOTS];
100 
101 		bus_dmamap_t sch_datad[SIISATA_MAX_SLOTS];
102 
103 		uint32_t sch_active_slots;
104 	} sc_channels[SIISATA_MAX_PORTS];
105 };
106 
107 #define SIISATANAME(sc) (device_xname((sc)->sc_atac.atac_dev))
108 
109 #define GRREAD(sc, reg) bus_space_read_4((sc)->sc_grt, (sc)->sc_grh, (reg))
110 #define GRWRITE(sc, reg, val) bus_space_write_4((sc)->sc_grt, (sc)->sc_grh, (reg), (val))
111 #define PRREAD(sc, reg) bus_space_read_4((sc)->sc_prt, (sc)->sc_prh, (reg))
112 #define PRWRITE(sc, reg, val) bus_space_write_4((sc)->sc_prt, (sc)->sc_prh, (reg), (val))
113 
114 #define SIISATA_PRB_SYNC(sc, schp, slot, op) bus_dmamap_sync((sc)->sc_dmat, \
115     (schp)->sch_prbd, slot * SIISATA_CMD_SIZE, SIISATA_CMD_SIZE, (op))
116 
117 #define SIISATA_NON_NCQ_SLOT 27
118 
119 void siisata_attach(struct siisata_softc *);
120 int siisata_detach(struct siisata_softc *, int);
121 void siisata_resume(struct siisata_softc *);
122 int siisata_intr(void *);
123 
124 #endif  /* !_IC_SIISATAVAR_H_ */
125