mvsatavar.h revision 1.2 1 1.2 kiyohara /* $NetBSD: mvsatavar.h,v 1.2 2010/07/13 12:53:42 kiyohara Exp $ */
2 1.1 kiyohara /*
3 1.1 kiyohara * Copyright (c) 2008 KIYOHARA Takashi
4 1.1 kiyohara * All rights reserved.
5 1.1 kiyohara *
6 1.1 kiyohara * Redistribution and use in source and binary forms, with or without
7 1.1 kiyohara * modification, are permitted provided that the following conditions
8 1.1 kiyohara * are met:
9 1.1 kiyohara * 1. Redistributions of source code must retain the above copyright
10 1.1 kiyohara * notice, this list of conditions and the following disclaimer.
11 1.1 kiyohara * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 kiyohara * notice, this list of conditions and the following disclaimer in the
13 1.1 kiyohara * documentation and/or other materials provided with the distribution.
14 1.1 kiyohara *
15 1.1 kiyohara * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 1.1 kiyohara * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 1.1 kiyohara * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 1.1 kiyohara * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 1.1 kiyohara * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 1.1 kiyohara * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 1.1 kiyohara * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 1.1 kiyohara * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 1.1 kiyohara * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 1.1 kiyohara * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1 kiyohara * POSSIBILITY OF SUCH DAMAGE.
26 1.1 kiyohara */
27 1.1 kiyohara
28 1.1 kiyohara #ifndef _MVSATAVAR_H_
29 1.1 kiyohara #define _MVSATAVAR_H_
30 1.1 kiyohara
31 1.2 kiyohara struct mvsata_product {
32 1.2 kiyohara int vendor;
33 1.2 kiyohara int model;
34 1.2 kiyohara int hc;
35 1.2 kiyohara int port;
36 1.2 kiyohara int generation;
37 1.2 kiyohara int flags;
38 1.2 kiyohara };
39 1.2 kiyohara
40 1.1 kiyohara #define MVSATA_EDMAQ_LEN 32 /* keep compatibility to gen1 */
41 1.1 kiyohara #define MVSATA_EDMAQ_INC(i) ((i) = ((i) + 1) % MVSATA_EDMAQ_LEN)
42 1.1 kiyohara #define MVSATA_HC_MAX 2
43 1.1 kiyohara #define MVSATA_PORT_MAX 4
44 1.1 kiyohara #define MVSATA_CHANNEL_MAX (MVSATA_HC_MAX * MVSATA_PORT_MAX)
45 1.1 kiyohara
46 1.1 kiyohara
47 1.1 kiyohara struct mvsata_port;
48 1.1 kiyohara
49 1.1 kiyohara union mvsata_crqb {
50 1.1 kiyohara struct crqb crqb;
51 1.1 kiyohara struct crqb_gen2e crqb_gen2e;
52 1.1 kiyohara };
53 1.1 kiyohara
54 1.1 kiyohara struct _fix_phy_param {
55 1.1 kiyohara uint32_t pre_amps; /* Pre/SignalAmps */
56 1.1 kiyohara
57 1.1 kiyohara void (*_fix_phy)(struct mvsata_port *);
58 1.1 kiyohara };
59 1.1 kiyohara
60 1.1 kiyohara struct mvsata_port {
61 1.1 kiyohara struct ata_channel port_ata_channel;
62 1.1 kiyohara
63 1.1 kiyohara int port;
64 1.1 kiyohara struct mvsata_hc *port_hc;
65 1.1 kiyohara
66 1.1 kiyohara enum {
67 1.1 kiyohara nodma,
68 1.1 kiyohara dma,
69 1.1 kiyohara queued,
70 1.1 kiyohara ncq,
71 1.1 kiyohara } port_edmamode;
72 1.1 kiyohara
73 1.1 kiyohara int port_quetagidx; /* Host Queue Tag valiable */
74 1.1 kiyohara
75 1.1 kiyohara int port_prev_erqqop; /* previous Req Queue Out-Pointer */
76 1.1 kiyohara bus_dma_tag_t port_dmat;
77 1.1 kiyohara union mvsata_crqb *port_crqb; /* EDMA Command Request Block */
78 1.1 kiyohara bus_dmamap_t port_crqb_dmamap;
79 1.1 kiyohara struct crpb *port_crpb; /* EDMA Command Response Block */
80 1.1 kiyohara bus_dmamap_t port_crpb_dmamap;
81 1.1 kiyohara struct eprd *port_eprd; /* EDMA Phy Region Description Table */
82 1.1 kiyohara bus_dmamap_t port_eprd_dmamap;
83 1.1 kiyohara struct {
84 1.1 kiyohara struct ata_xfer *xfer; /* queued xfer */
85 1.1 kiyohara bus_dmamap_t data_dmamap; /* DMA data buffer */
86 1.1 kiyohara bus_size_t eprd_offset; /* offset of ePRD buffer */
87 1.1 kiyohara struct eprd *eprd; /* ePRD buffer */
88 1.1 kiyohara } port_reqtbl[MVSATA_EDMAQ_LEN];
89 1.1 kiyohara
90 1.1 kiyohara bus_space_tag_t port_iot;
91 1.1 kiyohara bus_space_handle_t port_ioh;
92 1.1 kiyohara bus_space_handle_t port_sata_scontrol; /* SATA Interface control reg */
93 1.1 kiyohara bus_space_handle_t port_sata_serror; /* SATA Interface error reg */
94 1.1 kiyohara bus_space_handle_t port_sata_sstatus; /* SATA Interface status reg */
95 1.1 kiyohara struct ata_queue port_ata_queue;
96 1.1 kiyohara
97 1.1 kiyohara struct _fix_phy_param _fix_phy_param;
98 1.1 kiyohara };
99 1.1 kiyohara
100 1.1 kiyohara struct mvsata_hc {
101 1.1 kiyohara int hc;
102 1.1 kiyohara struct mvsata_softc *hc_sc;
103 1.1 kiyohara
104 1.1 kiyohara bus_space_tag_t hc_iot; /* Tag for SATAHC Arbiter */
105 1.1 kiyohara bus_space_handle_t hc_ioh; /* Handle for SATAHC Arbiter */
106 1.1 kiyohara
107 1.1 kiyohara struct mvsata_port *hc_ports[MVSATA_CHANNEL_MAX];
108 1.1 kiyohara };
109 1.1 kiyohara
110 1.1 kiyohara struct mvsata_softc {
111 1.1 kiyohara struct wdc_softc sc_wdcdev; /* common wdc definitions */
112 1.1 kiyohara
113 1.1 kiyohara int sc_model;
114 1.1 kiyohara int sc_rev;
115 1.1 kiyohara enum {
116 1.1 kiyohara gen_unknown = 0,
117 1.1 kiyohara gen1,
118 1.1 kiyohara gen2,
119 1.1 kiyohara gen2e
120 1.1 kiyohara } sc_gen; /* Generation for LSI */
121 1.1 kiyohara int sc_hc; /* number of host controller */
122 1.1 kiyohara int sc_port; /* number of port/host */
123 1.1 kiyohara
124 1.1 kiyohara bus_space_tag_t sc_iot;
125 1.1 kiyohara bus_space_handle_t sc_ioh;
126 1.1 kiyohara bus_dma_tag_t sc_dmat;
127 1.1 kiyohara
128 1.1 kiyohara struct wdc_regs *sc_wdc_regs;
129 1.1 kiyohara struct ata_channel *sc_ata_channels[MVSATA_CHANNEL_MAX];
130 1.1 kiyohara struct mvsata_hc sc_hcs[MVSATA_HC_MAX];
131 1.1 kiyohara
132 1.1 kiyohara int sc_flags;
133 1.1 kiyohara #define MVSATA_FLAGS_PCIE (1 << 0)
134 1.1 kiyohara
135 1.1 kiyohara void (*sc_edma_setup_crqb)(struct mvsata_port *, int, int,
136 1.1 kiyohara struct ata_bio *);
137 1.1 kiyohara void (*sc_enable_intr)(struct mvsata_port *, int);
138 1.1 kiyohara };
139 1.1 kiyohara
140 1.2 kiyohara int mvsata_attach(struct mvsata_softc *, struct mvsata_product *,
141 1.1 kiyohara int (*mvsata_sreset)(struct mvsata_softc *),
142 1.1 kiyohara int (*mvsata_misc_reset)(struct mvsata_softc *), int);
143 1.1 kiyohara int mvsata_intr(struct mvsata_hc *);
144 1.1 kiyohara int mvsata_error(struct mvsata_port *);
145 1.1 kiyohara
146 1.1 kiyohara #endif /* _MVSATAVAR_H_ */
147