pciide_piix_reg.h revision 1.3 1 /* $NetBSD: pciide_piix_reg.h,v 1.3 1999/08/30 12:49:22 bouyer Exp $ */
2
3 /*
4 * Copyright (c) 1998 Manuel Bouyer.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by the University of
17 * California, Berkeley and its contributors.
18 * 4. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 */
35
36 /*
37 * Registers definitions for Intel's PIIX serie PCI IDE controllers.
38 * See Intel's
39 * "82371FB (PIIX) and 82371SB (PIIX3) PCI ISA IDE XCELERATOR"
40 * "82371AB PCI-TO-ISA / IDE XCELERATOR (PIIX4)" and
41 * "Intel 82801AA (ICH) and Intel 82801AB (ICH0) I/O Controller Hub"
42 * available from http://developers.intel.com/
43 */
44
45 /*
46 * Bus master interface base address register
47 */
48 #define PIIX_BMIBA 0x20
49 #define PIIX_BMIBA_ADDR(x) (x & 0x0000FFFF0)
50 #define PIIX_BMIBA_RTE(x) (x & 0x000000001)
51 #define PIIX_BMIBA_RTE_IO 0x000000001 /* base addr maps to I/O space */
52
53 /*
54 * IDE timing register
55 * 0x40/0x41 is for primary, 0x42/0x43 for secondary channel
56 */
57 #define PIIX_IDETIM 0x40
58 #define PIIX_IDETIM_READ(x, channel) (((x) >> (16 * (channel))) & 0x0000FFFF)
59 #define PIIX_IDETIM_SET(x, bytes, channel) \
60 ((x) | ((bytes) << (16 * (channel))))
61 #define PIIX_IDETIM_CLEAR(x, bytes, channel) \
62 ((x) & ~((bytes) << (16 * (channel))))
63
64 #define PIIX_IDETIM_IDE 0x8000 /* PIIX decode IDE registers */
65 #define PIIX_IDETIM_SITRE 0x4000 /* slaves IDE timing registers
66 enabled (PIIX3/4 only) */
67 #define PIIX_IDETIM_ISP_MASK 0x3000 /* IOrdy sample point */
68 #define PIIX_IDETIM_ISP_SHIFT 12
69 #define PIIX_IDETIM_ISP_SET(x) ((x) << PIIX_IDETIM_ISP_SHIFT)
70 #define PIIX_IDETIM_RTC_MASK 0x0300 /* recovery time */
71 #define PIIX_IDETIM_RTC_SHIFT 8
72 #define PIIX_IDETIM_RTC_SET(x) ((x) << PIIX_IDETIM_RTC_SHIFT)
73 #define PIIX_IDETIM_DTE(d) (0x0008 << (4 * (d))) /* DMA timing only */
74 #define PIIX_IDETIM_PPE(d) (0x0004 << (4 * (d))) /* prefetch/posting */
75 #define PIIX_IDETIM_IE(d) (0x0002 << (4 * (d))) /* IORDY enable */
76 #define PIIX_IDETIM_TIME(d) (0x0001 << (4 * (d))) /* Fast timing enable */
77 /*
78 * Slave IDE timing register (PIIX3/4 only)
79 * This register must be enabled via the PIIX_IDETIM_SITRE bit
80 */
81 #define PIIX_SIDETIM 0x44
82 #define PIIX_SIDETIM_ISP_MASK(channel) (0x0c << ((channel) * 4))
83 #define PIIX_SIDETIM_ISP_SHIFT 2
84 #define PIIX_SIDETIM_ISP_SET(x, channel) \
85 (x << (PIIX_SIDETIM_ISP_SHIFT + ((channel) * 4)))
86 #define PIIX_SIDETIM_RTC_MASK(channel) (0x03 << ((channel) * 4))
87 #define PIIX_SIDETIM_RTC_SHIFT 0
88 #define PIIX_SIDETIM_RTC_SET(x, channel) \
89 (x << (PIIX_SIDETIM_RTC_SHIFT + ((channel) * 4)))
90
91 /*
92 * Ultra DMA/33 register (PIIX4 only)
93 */
94 #define PIIX_UDMAREG 0x48
95 /* Control register */
96 #define PIIX_UDMACTL_DRV_EN(channel, drive) (0x01 << ((channel) * 2 + (drive)))
97 /* Ultra DMA/33 timing register (PIIX4 only) */
98 #define PIIX_UDMATIM_SHIFT 16
99 #define PIIX_UDMATIM_SET(x, channel, drive) \
100 (((x) << ((channel * 8) + (drive * 4))) << PIIX_UDMATIM_SHIFT)
101
102 /*
103 * IDE config register (ICH/ICH0 only)
104 */
105 #define PIIX_CONFIG 0x54
106 #define PIIX_CONFIG_PINGPONG 0x0400
107 /* The following are only for the 82801AA (ICH) */
108 #define PIIX_CONFIG_CR(channel, drive) (0x0010 << ((channel) * 2 + (drive)))
109 #define PIIX_CONFIG_UDMA66(channel, drive) (0x0001 << ((channel) * 2 + (drive)))
110
111 /*
112 * these tables define the differents values to upload to the
113 * ISP and RTC registers for the various PIO and DMA mode
114 * (from the PIIX4 doc).
115 */
116 static int8_t piix_isp_pio[] = {0x00, 0x00, 0x01, 0x02, 0x02};
117 static int8_t piix_rtc_pio[] = {0x00, 0x00, 0x00, 0x01, 0x03};
118 static int8_t piix_isp_dma[] = {0x00, 0x02, 0x02};
119 static int8_t piix_rtc_dma[] = {0x00, 0x02, 0x03};
120 static int8_t piix4_sct_udma[] = {0x00, 0x01, 0x02, 0x01, 0x02};
121