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