wdcvar.h revision 1.5 1 /* $NetBSD: wdcvar.h,v 1.5 1998/09/22 00:21:16 mark Exp $ */
2
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum, by Onno van der Linden and by Manuel Bouyer.
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 struct wdc_attachment_data {
40 /* manadatory fields */
41 int cap;
42 int flags;
43 bus_space_tag_t iot;
44 bus_space_handle_t ioh;
45 bus_space_tag_t auxiot;
46 bus_space_handle_t auxioh;
47
48 /* data32{iot,ioh} are only used for 32 bit xfers */
49 bus_space_tag_t data32iot;
50 bus_space_handle_t data32ioh;
51
52 /* if WDC_CAPABILITY_DMA set in 'cap' */
53 void *dma_arg;
54 void (*dma_setup) __P((void *));
55 void (*dma_start) __P((void *, void *, size_t,
56 int));
57 void (*dma_finish) __P((void *));
58
59 /* if WDC_CAPABILITY_HWLOCK set in 'cap' */
60 int (*claim_hw) __P((void *, int));
61 void (*free_hw) __P((void *));
62 };
63
64 /* Capabilities supported by the controller */
65 #define WDC_CAPABILITY_DATA32 0x01 /* 32-bit data access */
66 #define WDC_CAPABILITY_DMA 0x02 /* DMA */
67 #define WDC_CAPABILITY_HWLOCK 0x04 /* Needs to lock HW */
68
69 /* Flags passed from the attach routine to the wdc driver */
70 #define WDC_NO_EXTRA_RESETS 0x01 /* Only reset once at attach */
71
72 struct wdc_softc {
73 struct device sc_dev;
74 const struct wdc_attachment_data *sc_adp;
75
76 struct wd_link *d_link[2];
77 struct scsipi_link *ab_link;
78
79 TAILQ_HEAD(xferhead, wdc_xfer) sc_xfer;
80 int sc_flags;
81 #define WDCF_ACTIVE 0x01 /* controller is active */
82 #define WDCF_SINGLE 0x02 /* sector at a time mode */
83 #define WDCF_ERROR 0x04 /* processing a disk error */
84 #define WDCF_WANTED 0x08 /* XXX locking for wd_get_parms() */
85 #define WDCF_IRQ_WAIT 0x10 /* controller is waiting for irq */
86 #define WDCF_ONESLAVE 0x20 /* ctrl. has one ATAPI slave attached */
87 int sc_errors; /* errors during current transfer */
88 u_char sc_status; /* copy of status register */
89 u_char sc_error; /* copy of error register */
90 u_char sc_drives_mask; /* bitmask for drives present/absent */
91 };
92
93 #define sc_cap sc_adp->cap
94 #define sc_iot sc_adp->iot
95 #define sc_ioh sc_adp->ioh
96 #define sc_auxiot sc_adp->auxiot
97 #define sc_auxioh sc_adp->auxioh
98 #define sc_data32iot sc_adp->data32iot
99 #define sc_data32ioh sc_adp->data32ioh
100 #define sc_dma_arg sc_adp->dma_arg
101 #define sc_dma_setup sc_adp->dma_setup
102 #define sc_dma_start sc_adp->dma_start
103 #define sc_dma_finish sc_adp->dma_finish
104 #define sc_claim_hw sc_adp->claim_hw
105 #define sc_free_hw sc_adp->free_hw
106
107 void wdcattach(struct wdc_softc *, const struct wdc_attachment_data *);
108 int wdcintr(void *);
109 int wdcprobe(const struct wdc_attachment_data *);
110