xref: /netbsd-src/sys/dev/pci/pciide_ixp_reg.h (revision fad4c9f71477ae11cea2ee75ec82151ac770a534)
1 /* $NetBSD: pciide_ixp_reg.h,v 1.3 2005/12/11 12:22:50 christos Exp $ */
2 
3 /*
4  *  Copyright (c) 2004 The NetBSD Foundation.
5  *  All rights reserved.
6  *
7  *  This code is derived from software contributed to the NetBSD Foundation
8  *  by Quentin Garnier.
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 /* All values gathered from the linux driver. */
40 
41 #define IXP_PIO_TIMING	0x40
42 #define IXP_MDMA_TIMING	0x44
43 #define IXP_PIO_CTL	0x48
44 #define IXP_PIO_MODE	0x4a
45 #define IXP_UDMA_CTL	0x54
46 #define IXP_UDMA_MODE	0x56
47 
48 /* First 4 bits of UDMA_CTL enable or disable UDMA for the drive */
49 #define IXP_UDMA_ENABLE(u, c, d)	do {	\
50     	(u) |= (1 << (2 * (c) + (d)));		\
51     } while (0)
52 #define IXP_UDMA_DISABLE(u, c, d)	do {	\
53     	(u) &= ~(1 << (2 * (c) + (d)));		\
54     } while (0)
55 
56 /*
57  * UDMA_MODE has 4 bits per drive, though only 3 are actually used
58  * Note that in this macro u is the whole
59  * UDMA_CTL+UDMA_MODE register (32bits).
60  * PIO_MODE works just the same.
61  */
62 #define IXP_SET_MODE(u, c, d, m)	do {	\
63     	int __ixpshift = 16 + 8*(c) + 4*(d);	\
64     	(u) &= ~(0x7 << __ixpshift);		\
65     	(u) |= (((m) & 0x7) << __ixpshift);	\
66     } while (0)
67 
68 /*
69  * MDMA_TIMING has one byte per drive.
70  * PIO_TIMING works just the same.
71  */
72 #define IXP_SET_TIMING(m, c, d, t)	do {	\
73         int __ixpshift = 16*(c) + 8*(d);	\
74     	(m) &= ~(0xff << __ixpshift);		\
75     	(m) |= ((t) & 0xff) << __ixpshift;	\
76     } while (0)
77