piixide.c revision 1.8.2.1.2.4 1 1.8.2.1.2.4 riz /* $NetBSD: piixide.c,v 1.8.2.1.2.4 2005/08/22 21:55:01 riz Exp $ */
2 1.1 bouyer
3 1.1 bouyer /*
4 1.1 bouyer * Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
5 1.1 bouyer *
6 1.1 bouyer * Redistribution and use in source and binary forms, with or without
7 1.1 bouyer * modification, are permitted provided that the following conditions
8 1.1 bouyer * are met:
9 1.1 bouyer * 1. Redistributions of source code must retain the above copyright
10 1.1 bouyer * notice, this list of conditions and the following disclaimer.
11 1.1 bouyer * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 bouyer * notice, this list of conditions and the following disclaimer in the
13 1.1 bouyer * documentation and/or other materials provided with the distribution.
14 1.1 bouyer * 3. All advertising materials mentioning features or use of this software
15 1.1 bouyer * must display the following acknowledgement:
16 1.1 bouyer * This product includes software developed by Manuel Bouyer.
17 1.1 bouyer * 4. The name of the author may not be used to endorse or promote products
18 1.1 bouyer * derived from this software without specific prior written permission.
19 1.1 bouyer *
20 1.1 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1 bouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1 bouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1 bouyer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1 bouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1 bouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1 bouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1 bouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1 bouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1 bouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 bouyer */
31 1.1 bouyer
32 1.1 bouyer #include <sys/param.h>
33 1.1 bouyer #include <sys/systm.h>
34 1.1 bouyer
35 1.1 bouyer #include <dev/pci/pcivar.h>
36 1.1 bouyer #include <dev/pci/pcidevs.h>
37 1.1 bouyer #include <dev/pci/pciidereg.h>
38 1.1 bouyer #include <dev/pci/pciidevar.h>
39 1.1 bouyer #include <dev/pci/pciide_piix_reg.h>
40 1.1 bouyer
41 1.2 thorpej static void piix_chip_map(struct pciide_softc*, struct pci_attach_args *);
42 1.7 thorpej static void piix_setup_channel(struct wdc_channel *);
43 1.7 thorpej static void piix3_4_setup_channel(struct wdc_channel *);
44 1.2 thorpej static u_int32_t piix_setup_idetim_timings(u_int8_t, u_int8_t, u_int8_t);
45 1.2 thorpej static u_int32_t piix_setup_idetim_drvs(struct ata_drive_datas *);
46 1.2 thorpej static u_int32_t piix_setup_sidetim_timings(u_int8_t, u_int8_t, u_int8_t);
47 1.5 bouyer static void piixsata_chip_map(struct pciide_softc*, struct pci_attach_args *);
48 1.2 thorpej
49 1.2 thorpej static int piixide_match(struct device *, struct cfdata *, void *);
50 1.2 thorpej static void piixide_attach(struct device *, struct device *, void *);
51 1.1 bouyer
52 1.2 thorpej static const struct pciide_product_desc pciide_intel_products[] = {
53 1.1 bouyer { PCI_PRODUCT_INTEL_82092AA,
54 1.1 bouyer 0,
55 1.1 bouyer "Intel 82092AA IDE controller",
56 1.1 bouyer default_chip_map,
57 1.1 bouyer },
58 1.1 bouyer { PCI_PRODUCT_INTEL_82371FB_IDE,
59 1.1 bouyer 0,
60 1.1 bouyer "Intel 82371FB IDE controller (PIIX)",
61 1.1 bouyer piix_chip_map,
62 1.1 bouyer },
63 1.1 bouyer { PCI_PRODUCT_INTEL_82371SB_IDE,
64 1.1 bouyer 0,
65 1.1 bouyer "Intel 82371SB IDE Interface (PIIX3)",
66 1.1 bouyer piix_chip_map,
67 1.1 bouyer },
68 1.1 bouyer { PCI_PRODUCT_INTEL_82371AB_IDE,
69 1.1 bouyer 0,
70 1.1 bouyer "Intel 82371AB IDE controller (PIIX4)",
71 1.1 bouyer piix_chip_map,
72 1.1 bouyer },
73 1.1 bouyer { PCI_PRODUCT_INTEL_82440MX_IDE,
74 1.1 bouyer 0,
75 1.1 bouyer "Intel 82440MX IDE controller",
76 1.1 bouyer piix_chip_map
77 1.1 bouyer },
78 1.1 bouyer { PCI_PRODUCT_INTEL_82801AA_IDE,
79 1.1 bouyer 0,
80 1.1 bouyer "Intel 82801AA IDE Controller (ICH)",
81 1.1 bouyer piix_chip_map,
82 1.1 bouyer },
83 1.1 bouyer { PCI_PRODUCT_INTEL_82801AB_IDE,
84 1.1 bouyer 0,
85 1.1 bouyer "Intel 82801AB IDE Controller (ICH0)",
86 1.1 bouyer piix_chip_map,
87 1.1 bouyer },
88 1.1 bouyer { PCI_PRODUCT_INTEL_82801BA_IDE,
89 1.1 bouyer 0,
90 1.1 bouyer "Intel 82801BA IDE Controller (ICH2)",
91 1.1 bouyer piix_chip_map,
92 1.1 bouyer },
93 1.1 bouyer { PCI_PRODUCT_INTEL_82801BAM_IDE,
94 1.1 bouyer 0,
95 1.1 bouyer "Intel 82801BAM IDE Controller (ICH2-M)",
96 1.1 bouyer piix_chip_map,
97 1.1 bouyer },
98 1.1 bouyer { PCI_PRODUCT_INTEL_82801CA_IDE_1,
99 1.1 bouyer 0,
100 1.1 bouyer "Intel 82801CA IDE Controller (ICH3)",
101 1.1 bouyer piix_chip_map,
102 1.1 bouyer },
103 1.1 bouyer { PCI_PRODUCT_INTEL_82801CA_IDE_2,
104 1.1 bouyer 0,
105 1.1 bouyer "Intel 82801CA IDE Controller (ICH3)",
106 1.1 bouyer piix_chip_map,
107 1.1 bouyer },
108 1.1 bouyer { PCI_PRODUCT_INTEL_82801DB_IDE,
109 1.1 bouyer 0,
110 1.1 bouyer "Intel 82801DB IDE Controller (ICH4)",
111 1.1 bouyer piix_chip_map,
112 1.1 bouyer },
113 1.1 bouyer { PCI_PRODUCT_INTEL_82801DBM_IDE,
114 1.1 bouyer 0,
115 1.1 bouyer "Intel 82801DBM IDE Controller (ICH4-M)",
116 1.1 bouyer piix_chip_map,
117 1.1 bouyer },
118 1.1 bouyer { PCI_PRODUCT_INTEL_82801EB_IDE,
119 1.1 bouyer 0,
120 1.1 bouyer "Intel 82801EB IDE Controller (ICH5)",
121 1.1 bouyer piix_chip_map,
122 1.1 bouyer },
123 1.1 bouyer { PCI_PRODUCT_INTEL_82801EB_SATA,
124 1.1 bouyer 0,
125 1.1 bouyer "Intel 82801EB Serial ATA Controller",
126 1.5 bouyer piixsata_chip_map,
127 1.4 bouyer },
128 1.4 bouyer { PCI_PRODUCT_INTEL_82801ER_SATA,
129 1.4 bouyer 0,
130 1.4 bouyer "Intel 82801ER Serial ATA/Raid Controller",
131 1.5 bouyer piixsata_chip_map,
132 1.1 bouyer },
133 1.8.2.1 tron { PCI_PRODUCT_INTEL_6300ESB_IDE,
134 1.8.2.1 tron 0,
135 1.8.2.1 tron "Intel 6300ESB IDE Controller (ICH5)",
136 1.8.2.1 tron piix_chip_map,
137 1.8.2.1 tron },
138 1.8.2.1 tron { PCI_PRODUCT_INTEL_6300ESB_SATA,
139 1.8.2.1 tron 0,
140 1.8.2.1 tron "Intel 6300ESB Serial ATA Controller",
141 1.8.2.1 tron piixsata_chip_map,
142 1.8.2.1 tron },
143 1.8.2.1.2.2 tron { PCI_PRODUCT_INTEL_82801FB_IDE,
144 1.8.2.1.2.2 tron 0,
145 1.8.2.1.2.2 tron "Intel 82801FB IDE Controller (ICH6)",
146 1.8.2.1.2.2 tron piix_chip_map,
147 1.8.2.1.2.2 tron },
148 1.8.2.1.2.1 tron { PCI_PRODUCT_INTEL_82801FB_SATA,
149 1.8.2.1.2.1 tron 0,
150 1.8.2.1.2.1 tron "Intel 82801FB Serial ATA/Raid Controller",
151 1.8.2.1.2.1 tron piixsata_chip_map,
152 1.8.2.1.2.1 tron },
153 1.8.2.1.2.1 tron { PCI_PRODUCT_INTEL_82801FR_SATA,
154 1.8.2.1.2.1 tron 0,
155 1.8.2.1.2.1 tron "Intel 82801FR Serial ATA/Raid Controller",
156 1.8.2.1.2.1 tron piixsata_chip_map,
157 1.8.2.1.2.1 tron },
158 1.8.2.1.2.3 riz { PCI_PRODUCT_INTEL_82801FBM_SATA,
159 1.8.2.1.2.3 riz 0,
160 1.8.2.1.2.3 riz "Intel 82801FBM Serial ATA Controller (ICH6)",
161 1.8.2.1.2.3 riz piixsata_chip_map,
162 1.8.2.1.2.3 riz },
163 1.1 bouyer { 0,
164 1.1 bouyer 0,
165 1.1 bouyer NULL,
166 1.1 bouyer NULL
167 1.1 bouyer }
168 1.1 bouyer };
169 1.1 bouyer
170 1.1 bouyer CFATTACH_DECL(piixide, sizeof(struct pciide_softc),
171 1.1 bouyer piixide_match, piixide_attach, NULL, NULL);
172 1.1 bouyer
173 1.2 thorpej static int
174 1.2 thorpej piixide_match(struct device *parent, struct cfdata *match, void *aux)
175 1.1 bouyer {
176 1.1 bouyer struct pci_attach_args *pa = aux;
177 1.1 bouyer
178 1.1 bouyer if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INTEL) {
179 1.1 bouyer if (pciide_lookup_product(pa->pa_id, pciide_intel_products))
180 1.1 bouyer return (2);
181 1.1 bouyer }
182 1.1 bouyer return (0);
183 1.1 bouyer }
184 1.1 bouyer
185 1.2 thorpej static void
186 1.2 thorpej piixide_attach(struct device *parent, struct device *self, void *aux)
187 1.1 bouyer {
188 1.1 bouyer struct pci_attach_args *pa = aux;
189 1.1 bouyer struct pciide_softc *sc = (struct pciide_softc *)self;
190 1.1 bouyer
191 1.1 bouyer pciide_common_attach(sc, pa,
192 1.1 bouyer pciide_lookup_product(pa->pa_id, pciide_intel_products));
193 1.1 bouyer
194 1.1 bouyer }
195 1.1 bouyer
196 1.2 thorpej static void
197 1.2 thorpej piix_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
198 1.1 bouyer {
199 1.1 bouyer struct pciide_channel *cp;
200 1.1 bouyer int channel;
201 1.1 bouyer u_int32_t idetim;
202 1.1 bouyer bus_size_t cmdsize, ctlsize;
203 1.8.2.1.2.4 riz pcireg_t interface = PCI_INTERFACE(pa->pa_class);
204 1.1 bouyer
205 1.1 bouyer if (pciide_chipen(sc, pa) == 0)
206 1.1 bouyer return;
207 1.1 bouyer
208 1.1 bouyer aprint_normal("%s: bus-master DMA support present",
209 1.1 bouyer sc->sc_wdcdev.sc_dev.dv_xname);
210 1.1 bouyer pciide_mapreg_dma(sc, pa);
211 1.1 bouyer aprint_normal("\n");
212 1.1 bouyer sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32 |
213 1.1 bouyer WDC_CAPABILITY_MODE;
214 1.1 bouyer if (sc->sc_dma_ok) {
215 1.1 bouyer sc->sc_wdcdev.cap |= WDC_CAPABILITY_DMA | WDC_CAPABILITY_IRQACK;
216 1.1 bouyer sc->sc_wdcdev.irqack = pciide_irqack;
217 1.1 bouyer switch(sc->sc_pp->ide_product) {
218 1.1 bouyer case PCI_PRODUCT_INTEL_82371AB_IDE:
219 1.1 bouyer case PCI_PRODUCT_INTEL_82440MX_IDE:
220 1.1 bouyer case PCI_PRODUCT_INTEL_82801AA_IDE:
221 1.1 bouyer case PCI_PRODUCT_INTEL_82801AB_IDE:
222 1.1 bouyer case PCI_PRODUCT_INTEL_82801BA_IDE:
223 1.1 bouyer case PCI_PRODUCT_INTEL_82801BAM_IDE:
224 1.1 bouyer case PCI_PRODUCT_INTEL_82801CA_IDE_1:
225 1.1 bouyer case PCI_PRODUCT_INTEL_82801CA_IDE_2:
226 1.1 bouyer case PCI_PRODUCT_INTEL_82801DB_IDE:
227 1.1 bouyer case PCI_PRODUCT_INTEL_82801DBM_IDE:
228 1.1 bouyer case PCI_PRODUCT_INTEL_82801EB_IDE:
229 1.8.2.1 tron case PCI_PRODUCT_INTEL_6300ESB_IDE:
230 1.8.2.1.2.2 tron case PCI_PRODUCT_INTEL_82801FB_IDE:
231 1.1 bouyer sc->sc_wdcdev.cap |= WDC_CAPABILITY_UDMA;
232 1.1 bouyer }
233 1.1 bouyer }
234 1.1 bouyer sc->sc_wdcdev.PIO_cap = 4;
235 1.1 bouyer sc->sc_wdcdev.DMA_cap = 2;
236 1.1 bouyer switch(sc->sc_pp->ide_product) {
237 1.1 bouyer case PCI_PRODUCT_INTEL_82801AA_IDE:
238 1.1 bouyer sc->sc_wdcdev.UDMA_cap = 4;
239 1.1 bouyer break;
240 1.1 bouyer case PCI_PRODUCT_INTEL_82801BA_IDE:
241 1.1 bouyer case PCI_PRODUCT_INTEL_82801BAM_IDE:
242 1.1 bouyer case PCI_PRODUCT_INTEL_82801CA_IDE_1:
243 1.1 bouyer case PCI_PRODUCT_INTEL_82801CA_IDE_2:
244 1.1 bouyer case PCI_PRODUCT_INTEL_82801DB_IDE:
245 1.1 bouyer case PCI_PRODUCT_INTEL_82801DBM_IDE:
246 1.1 bouyer case PCI_PRODUCT_INTEL_82801EB_IDE:
247 1.8.2.1 tron case PCI_PRODUCT_INTEL_6300ESB_IDE:
248 1.8.2.1.2.2 tron case PCI_PRODUCT_INTEL_82801FB_IDE:
249 1.1 bouyer sc->sc_wdcdev.UDMA_cap = 5;
250 1.1 bouyer break;
251 1.1 bouyer default:
252 1.1 bouyer sc->sc_wdcdev.UDMA_cap = 2;
253 1.1 bouyer }
254 1.1 bouyer if (sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82371FB_IDE)
255 1.1 bouyer sc->sc_wdcdev.set_modes = piix_setup_channel;
256 1.1 bouyer else
257 1.1 bouyer sc->sc_wdcdev.set_modes = piix3_4_setup_channel;
258 1.1 bouyer sc->sc_wdcdev.channels = sc->wdc_chanarray;
259 1.1 bouyer sc->sc_wdcdev.nchannels = PCIIDE_NUM_CHANNELS;
260 1.1 bouyer
261 1.1 bouyer WDCDEBUG_PRINT(("piix_setup_chip: old idetim=0x%x",
262 1.1 bouyer pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_IDETIM)),
263 1.1 bouyer DEBUG_PROBE);
264 1.1 bouyer if (sc->sc_pp->ide_product != PCI_PRODUCT_INTEL_82371FB_IDE) {
265 1.1 bouyer WDCDEBUG_PRINT((", sidetim=0x%x",
266 1.1 bouyer pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_SIDETIM)),
267 1.1 bouyer DEBUG_PROBE);
268 1.1 bouyer if (sc->sc_wdcdev.cap & WDC_CAPABILITY_UDMA) {
269 1.1 bouyer WDCDEBUG_PRINT((", udamreg 0x%x",
270 1.1 bouyer pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_UDMAREG)),
271 1.1 bouyer DEBUG_PROBE);
272 1.1 bouyer }
273 1.1 bouyer if (sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801AA_IDE ||
274 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801AB_IDE ||
275 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801BA_IDE ||
276 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801BAM_IDE ||
277 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801CA_IDE_1 ||
278 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801CA_IDE_2 ||
279 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801DB_IDE ||
280 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801DBM_IDE ||
281 1.8.2.1 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801EB_IDE ||
282 1.8.2.1.2.2 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801FB_IDE ||
283 1.8.2.1 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_6300ESB_IDE) {
284 1.1 bouyer WDCDEBUG_PRINT((", IDE_CONTROL 0x%x",
285 1.1 bouyer pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_CONFIG)),
286 1.1 bouyer DEBUG_PROBE);
287 1.1 bouyer }
288 1.1 bouyer
289 1.1 bouyer }
290 1.1 bouyer WDCDEBUG_PRINT(("\n"), DEBUG_PROBE);
291 1.1 bouyer
292 1.1 bouyer for (channel = 0; channel < sc->sc_wdcdev.nchannels; channel++) {
293 1.1 bouyer cp = &sc->pciide_channels[channel];
294 1.8.2.1.2.4 riz if (pciide_chansetup(sc, channel, interface) == 0)
295 1.1 bouyer continue;
296 1.1 bouyer idetim = pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_IDETIM);
297 1.1 bouyer if ((PIIX_IDETIM_READ(idetim, channel) &
298 1.1 bouyer PIIX_IDETIM_IDE) == 0) {
299 1.1 bouyer #if 1
300 1.1 bouyer aprint_normal("%s: %s channel ignored (disabled)\n",
301 1.1 bouyer sc->sc_wdcdev.sc_dev.dv_xname, cp->name);
302 1.1 bouyer cp->wdc_channel.ch_flags |= WDCF_DISABLED;
303 1.1 bouyer continue;
304 1.1 bouyer #else
305 1.1 bouyer pcireg_t interface;
306 1.1 bouyer
307 1.1 bouyer idetim = PIIX_IDETIM_SET(idetim, PIIX_IDETIM_IDE,
308 1.1 bouyer channel);
309 1.1 bouyer pci_conf_write(sc->sc_pc, sc->sc_tag, PIIX_IDETIM,
310 1.1 bouyer idetim);
311 1.1 bouyer interface = PCI_INTERFACE(pci_conf_read(sc->sc_pc,
312 1.1 bouyer sc->sc_tag, PCI_CLASS_REG));
313 1.1 bouyer aprint_normal("channel %d idetim=%08x interface=%02x\n",
314 1.1 bouyer channel, idetim, interface);
315 1.1 bouyer #endif
316 1.1 bouyer }
317 1.8.2.1.2.4 riz pciide_mapchan(pa, cp, interface,
318 1.8.2.1.2.4 riz &cmdsize, &ctlsize, pciide_pci_intr);
319 1.1 bouyer }
320 1.1 bouyer
321 1.1 bouyer WDCDEBUG_PRINT(("piix_setup_chip: idetim=0x%x",
322 1.1 bouyer pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_IDETIM)),
323 1.1 bouyer DEBUG_PROBE);
324 1.1 bouyer if (sc->sc_pp->ide_product != PCI_PRODUCT_INTEL_82371FB_IDE) {
325 1.1 bouyer WDCDEBUG_PRINT((", sidetim=0x%x",
326 1.1 bouyer pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_SIDETIM)),
327 1.1 bouyer DEBUG_PROBE);
328 1.1 bouyer if (sc->sc_wdcdev.cap & WDC_CAPABILITY_UDMA) {
329 1.1 bouyer WDCDEBUG_PRINT((", udamreg 0x%x",
330 1.1 bouyer pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_UDMAREG)),
331 1.1 bouyer DEBUG_PROBE);
332 1.1 bouyer }
333 1.1 bouyer if (sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801AA_IDE ||
334 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801AB_IDE ||
335 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801BA_IDE ||
336 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801BAM_IDE ||
337 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801CA_IDE_1 ||
338 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801CA_IDE_2 ||
339 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801DB_IDE ||
340 1.8.2.1 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801DBM_IDE ||
341 1.8.2.1 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801EB_IDE ||
342 1.8.2.1.2.2 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801FB_IDE ||
343 1.8.2.1 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_6300ESB_IDE) {
344 1.1 bouyer WDCDEBUG_PRINT((", IDE_CONTROL 0x%x",
345 1.1 bouyer pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_CONFIG)),
346 1.1 bouyer DEBUG_PROBE);
347 1.1 bouyer }
348 1.1 bouyer }
349 1.1 bouyer WDCDEBUG_PRINT(("\n"), DEBUG_PROBE);
350 1.1 bouyer }
351 1.1 bouyer
352 1.2 thorpej static void
353 1.7 thorpej piix_setup_channel(struct wdc_channel *chp)
354 1.1 bouyer {
355 1.1 bouyer u_int8_t mode[2], drive;
356 1.1 bouyer u_int32_t oidetim, idetim, idedma_ctl;
357 1.1 bouyer struct pciide_channel *cp = (struct pciide_channel*)chp;
358 1.8 thorpej struct pciide_softc *sc = (struct pciide_softc *)cp->wdc_channel.ch_wdc;
359 1.1 bouyer struct ata_drive_datas *drvp = cp->wdc_channel.ch_drive;
360 1.1 bouyer
361 1.1 bouyer oidetim = pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_IDETIM);
362 1.8 thorpej idetim = PIIX_IDETIM_CLEAR(oidetim, 0xffff, chp->ch_channel);
363 1.1 bouyer idedma_ctl = 0;
364 1.1 bouyer
365 1.1 bouyer /* set up new idetim: Enable IDE registers decode */
366 1.1 bouyer idetim = PIIX_IDETIM_SET(idetim, PIIX_IDETIM_IDE,
367 1.8 thorpej chp->ch_channel);
368 1.1 bouyer
369 1.1 bouyer /* setup DMA */
370 1.1 bouyer pciide_channel_dma_setup(cp);
371 1.1 bouyer
372 1.1 bouyer /*
373 1.1 bouyer * Here we have to mess up with drives mode: PIIX can't have
374 1.1 bouyer * different timings for master and slave drives.
375 1.1 bouyer * We need to find the best combination.
376 1.1 bouyer */
377 1.1 bouyer
378 1.1 bouyer /* If both drives supports DMA, take the lower mode */
379 1.1 bouyer if ((drvp[0].drive_flags & DRIVE_DMA) &&
380 1.1 bouyer (drvp[1].drive_flags & DRIVE_DMA)) {
381 1.1 bouyer mode[0] = mode[1] =
382 1.1 bouyer min(drvp[0].DMA_mode, drvp[1].DMA_mode);
383 1.1 bouyer drvp[0].DMA_mode = mode[0];
384 1.1 bouyer drvp[1].DMA_mode = mode[1];
385 1.1 bouyer goto ok;
386 1.1 bouyer }
387 1.1 bouyer /*
388 1.1 bouyer * If only one drive supports DMA, use its mode, and
389 1.1 bouyer * put the other one in PIO mode 0 if mode not compatible
390 1.1 bouyer */
391 1.1 bouyer if (drvp[0].drive_flags & DRIVE_DMA) {
392 1.1 bouyer mode[0] = drvp[0].DMA_mode;
393 1.1 bouyer mode[1] = drvp[1].PIO_mode;
394 1.1 bouyer if (piix_isp_pio[mode[1]] != piix_isp_dma[mode[0]] ||
395 1.1 bouyer piix_rtc_pio[mode[1]] != piix_rtc_dma[mode[0]])
396 1.1 bouyer mode[1] = drvp[1].PIO_mode = 0;
397 1.1 bouyer goto ok;
398 1.1 bouyer }
399 1.1 bouyer if (drvp[1].drive_flags & DRIVE_DMA) {
400 1.1 bouyer mode[1] = drvp[1].DMA_mode;
401 1.1 bouyer mode[0] = drvp[0].PIO_mode;
402 1.1 bouyer if (piix_isp_pio[mode[0]] != piix_isp_dma[mode[1]] ||
403 1.1 bouyer piix_rtc_pio[mode[0]] != piix_rtc_dma[mode[1]])
404 1.1 bouyer mode[0] = drvp[0].PIO_mode = 0;
405 1.1 bouyer goto ok;
406 1.1 bouyer }
407 1.1 bouyer /*
408 1.1 bouyer * If both drives are not DMA, takes the lower mode, unless
409 1.1 bouyer * one of them is PIO mode < 2
410 1.1 bouyer */
411 1.1 bouyer if (drvp[0].PIO_mode < 2) {
412 1.1 bouyer mode[0] = drvp[0].PIO_mode = 0;
413 1.1 bouyer mode[1] = drvp[1].PIO_mode;
414 1.1 bouyer } else if (drvp[1].PIO_mode < 2) {
415 1.1 bouyer mode[1] = drvp[1].PIO_mode = 0;
416 1.1 bouyer mode[0] = drvp[0].PIO_mode;
417 1.1 bouyer } else {
418 1.1 bouyer mode[0] = mode[1] =
419 1.1 bouyer min(drvp[1].PIO_mode, drvp[0].PIO_mode);
420 1.1 bouyer drvp[0].PIO_mode = mode[0];
421 1.1 bouyer drvp[1].PIO_mode = mode[1];
422 1.1 bouyer }
423 1.1 bouyer ok: /* The modes are setup */
424 1.1 bouyer for (drive = 0; drive < 2; drive++) {
425 1.1 bouyer if (drvp[drive].drive_flags & DRIVE_DMA) {
426 1.1 bouyer idetim |= piix_setup_idetim_timings(
427 1.8 thorpej mode[drive], 1, chp->ch_channel);
428 1.1 bouyer goto end;
429 1.1 bouyer }
430 1.1 bouyer }
431 1.1 bouyer /* If we are there, none of the drives are DMA */
432 1.1 bouyer if (mode[0] >= 2)
433 1.1 bouyer idetim |= piix_setup_idetim_timings(
434 1.8 thorpej mode[0], 0, chp->ch_channel);
435 1.1 bouyer else
436 1.1 bouyer idetim |= piix_setup_idetim_timings(
437 1.8 thorpej mode[1], 0, chp->ch_channel);
438 1.1 bouyer end: /*
439 1.1 bouyer * timing mode is now set up in the controller. Enable
440 1.1 bouyer * it per-drive
441 1.1 bouyer */
442 1.1 bouyer for (drive = 0; drive < 2; drive++) {
443 1.1 bouyer /* If no drive, skip */
444 1.1 bouyer if ((drvp[drive].drive_flags & DRIVE) == 0)
445 1.1 bouyer continue;
446 1.1 bouyer idetim |= piix_setup_idetim_drvs(&drvp[drive]);
447 1.1 bouyer if (drvp[drive].drive_flags & DRIVE_DMA)
448 1.1 bouyer idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
449 1.1 bouyer }
450 1.1 bouyer if (idedma_ctl != 0) {
451 1.1 bouyer /* Add software bits in status register */
452 1.3 fvdl bus_space_write_1(sc->sc_dma_iot, cp->dma_iohs[IDEDMA_CTL], 0,
453 1.1 bouyer idedma_ctl);
454 1.1 bouyer }
455 1.1 bouyer pci_conf_write(sc->sc_pc, sc->sc_tag, PIIX_IDETIM, idetim);
456 1.1 bouyer }
457 1.1 bouyer
458 1.2 thorpej static void
459 1.7 thorpej piix3_4_setup_channel(struct wdc_channel *chp)
460 1.1 bouyer {
461 1.1 bouyer struct ata_drive_datas *drvp;
462 1.1 bouyer u_int32_t oidetim, idetim, sidetim, udmareg, ideconf, idedma_ctl;
463 1.1 bouyer struct pciide_channel *cp = (struct pciide_channel*)chp;
464 1.8 thorpej struct pciide_softc *sc = (struct pciide_softc *)cp->wdc_channel.ch_wdc;
465 1.8 thorpej struct wdc_softc *wdc = &sc->sc_wdcdev;
466 1.1 bouyer int drive;
467 1.8 thorpej int channel = chp->ch_channel;
468 1.1 bouyer
469 1.1 bouyer oidetim = pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_IDETIM);
470 1.1 bouyer sidetim = pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_SIDETIM);
471 1.1 bouyer udmareg = pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_UDMAREG);
472 1.1 bouyer ideconf = pci_conf_read(sc->sc_pc, sc->sc_tag, PIIX_CONFIG);
473 1.1 bouyer idetim = PIIX_IDETIM_CLEAR(oidetim, 0xffff, channel);
474 1.1 bouyer sidetim &= ~(PIIX_SIDETIM_ISP_MASK(channel) |
475 1.1 bouyer PIIX_SIDETIM_RTC_MASK(channel));
476 1.1 bouyer idedma_ctl = 0;
477 1.1 bouyer
478 1.1 bouyer /* set up new idetim: Enable IDE registers decode */
479 1.1 bouyer idetim = PIIX_IDETIM_SET(idetim, PIIX_IDETIM_IDE, channel);
480 1.1 bouyer
481 1.1 bouyer /* setup DMA if needed */
482 1.1 bouyer pciide_channel_dma_setup(cp);
483 1.1 bouyer
484 1.1 bouyer for (drive = 0; drive < 2; drive++) {
485 1.1 bouyer udmareg &= ~(PIIX_UDMACTL_DRV_EN(channel, drive) |
486 1.1 bouyer PIIX_UDMATIM_SET(0x3, channel, drive));
487 1.1 bouyer drvp = &chp->ch_drive[drive];
488 1.1 bouyer /* If no drive, skip */
489 1.1 bouyer if ((drvp->drive_flags & DRIVE) == 0)
490 1.1 bouyer continue;
491 1.1 bouyer if (((drvp->drive_flags & DRIVE_DMA) == 0 &&
492 1.1 bouyer (drvp->drive_flags & DRIVE_UDMA) == 0))
493 1.1 bouyer goto pio;
494 1.1 bouyer
495 1.1 bouyer if (sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801AA_IDE ||
496 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801AB_IDE ||
497 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801BA_IDE ||
498 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801BAM_IDE ||
499 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801CA_IDE_1 ||
500 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801CA_IDE_2 ||
501 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801DB_IDE ||
502 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801DBM_IDE ||
503 1.8.2.1 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801EB_IDE ||
504 1.8.2.1.2.2 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801FB_IDE ||
505 1.8.2.1 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_6300ESB_IDE) {
506 1.1 bouyer ideconf |= PIIX_CONFIG_PINGPONG;
507 1.1 bouyer }
508 1.1 bouyer if (sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801BA_IDE ||
509 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801BAM_IDE ||
510 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801CA_IDE_1 ||
511 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801CA_IDE_2 ||
512 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801DB_IDE ||
513 1.1 bouyer sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801DBM_IDE ||
514 1.8.2.1 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801EB_IDE ||
515 1.8.2.1.2.2 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801FB_IDE ||
516 1.8.2.1 tron sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_6300ESB_IDE) {
517 1.1 bouyer /* setup Ultra/100 */
518 1.1 bouyer if (drvp->UDMA_mode > 2 &&
519 1.1 bouyer (ideconf & PIIX_CONFIG_CR(channel, drive)) == 0)
520 1.1 bouyer drvp->UDMA_mode = 2;
521 1.1 bouyer if (drvp->UDMA_mode > 4) {
522 1.1 bouyer ideconf |= PIIX_CONFIG_UDMA100(channel, drive);
523 1.1 bouyer } else {
524 1.1 bouyer ideconf &= ~PIIX_CONFIG_UDMA100(channel, drive);
525 1.1 bouyer if (drvp->UDMA_mode > 2) {
526 1.1 bouyer ideconf |= PIIX_CONFIG_UDMA66(channel,
527 1.1 bouyer drive);
528 1.1 bouyer } else {
529 1.1 bouyer ideconf &= ~PIIX_CONFIG_UDMA66(channel,
530 1.1 bouyer drive);
531 1.1 bouyer }
532 1.1 bouyer }
533 1.1 bouyer }
534 1.1 bouyer if (sc->sc_pp->ide_product == PCI_PRODUCT_INTEL_82801AA_IDE) {
535 1.1 bouyer /* setup Ultra/66 */
536 1.1 bouyer if (drvp->UDMA_mode > 2 &&
537 1.1 bouyer (ideconf & PIIX_CONFIG_CR(channel, drive)) == 0)
538 1.1 bouyer drvp->UDMA_mode = 2;
539 1.1 bouyer if (drvp->UDMA_mode > 2)
540 1.1 bouyer ideconf |= PIIX_CONFIG_UDMA66(channel, drive);
541 1.1 bouyer else
542 1.1 bouyer ideconf &= ~PIIX_CONFIG_UDMA66(channel, drive);
543 1.1 bouyer }
544 1.8 thorpej if ((wdc->cap & WDC_CAPABILITY_UDMA) &&
545 1.1 bouyer (drvp->drive_flags & DRIVE_UDMA)) {
546 1.1 bouyer /* use Ultra/DMA */
547 1.1 bouyer drvp->drive_flags &= ~DRIVE_DMA;
548 1.1 bouyer udmareg |= PIIX_UDMACTL_DRV_EN( channel, drive);
549 1.1 bouyer udmareg |= PIIX_UDMATIM_SET(
550 1.1 bouyer piix4_sct_udma[drvp->UDMA_mode], channel, drive);
551 1.1 bouyer } else {
552 1.1 bouyer /* use Multiword DMA */
553 1.1 bouyer drvp->drive_flags &= ~DRIVE_UDMA;
554 1.1 bouyer if (drive == 0) {
555 1.1 bouyer idetim |= piix_setup_idetim_timings(
556 1.1 bouyer drvp->DMA_mode, 1, channel);
557 1.1 bouyer } else {
558 1.1 bouyer sidetim |= piix_setup_sidetim_timings(
559 1.1 bouyer drvp->DMA_mode, 1, channel);
560 1.1 bouyer idetim =PIIX_IDETIM_SET(idetim,
561 1.1 bouyer PIIX_IDETIM_SITRE, channel);
562 1.1 bouyer }
563 1.1 bouyer }
564 1.1 bouyer idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
565 1.1 bouyer
566 1.1 bouyer pio: /* use PIO mode */
567 1.1 bouyer idetim |= piix_setup_idetim_drvs(drvp);
568 1.1 bouyer if (drive == 0) {
569 1.1 bouyer idetim |= piix_setup_idetim_timings(
570 1.1 bouyer drvp->PIO_mode, 0, channel);
571 1.1 bouyer } else {
572 1.1 bouyer sidetim |= piix_setup_sidetim_timings(
573 1.1 bouyer drvp->PIO_mode, 0, channel);
574 1.1 bouyer idetim =PIIX_IDETIM_SET(idetim,
575 1.1 bouyer PIIX_IDETIM_SITRE, channel);
576 1.1 bouyer }
577 1.1 bouyer }
578 1.1 bouyer if (idedma_ctl != 0) {
579 1.1 bouyer /* Add software bits in status register */
580 1.3 fvdl bus_space_write_1(sc->sc_dma_iot, cp->dma_iohs[IDEDMA_CTL], 0,
581 1.1 bouyer idedma_ctl);
582 1.1 bouyer }
583 1.1 bouyer pci_conf_write(sc->sc_pc, sc->sc_tag, PIIX_IDETIM, idetim);
584 1.1 bouyer pci_conf_write(sc->sc_pc, sc->sc_tag, PIIX_SIDETIM, sidetim);
585 1.1 bouyer pci_conf_write(sc->sc_pc, sc->sc_tag, PIIX_UDMAREG, udmareg);
586 1.1 bouyer pci_conf_write(sc->sc_pc, sc->sc_tag, PIIX_CONFIG, ideconf);
587 1.1 bouyer }
588 1.1 bouyer
589 1.1 bouyer
590 1.1 bouyer /* setup ISP and RTC fields, based on mode */
591 1.1 bouyer static u_int32_t
592 1.1 bouyer piix_setup_idetim_timings(mode, dma, channel)
593 1.1 bouyer u_int8_t mode;
594 1.1 bouyer u_int8_t dma;
595 1.1 bouyer u_int8_t channel;
596 1.1 bouyer {
597 1.1 bouyer
598 1.1 bouyer if (dma)
599 1.1 bouyer return PIIX_IDETIM_SET(0,
600 1.1 bouyer PIIX_IDETIM_ISP_SET(piix_isp_dma[mode]) |
601 1.1 bouyer PIIX_IDETIM_RTC_SET(piix_rtc_dma[mode]),
602 1.1 bouyer channel);
603 1.1 bouyer else
604 1.1 bouyer return PIIX_IDETIM_SET(0,
605 1.1 bouyer PIIX_IDETIM_ISP_SET(piix_isp_pio[mode]) |
606 1.1 bouyer PIIX_IDETIM_RTC_SET(piix_rtc_pio[mode]),
607 1.1 bouyer channel);
608 1.1 bouyer }
609 1.1 bouyer
610 1.1 bouyer /* setup DTE, PPE, IE and TIME field based on PIO mode */
611 1.1 bouyer static u_int32_t
612 1.1 bouyer piix_setup_idetim_drvs(drvp)
613 1.1 bouyer struct ata_drive_datas *drvp;
614 1.1 bouyer {
615 1.1 bouyer u_int32_t ret = 0;
616 1.7 thorpej struct wdc_channel *chp = drvp->chnl_softc;
617 1.8 thorpej u_int8_t channel = chp->ch_channel;
618 1.1 bouyer u_int8_t drive = drvp->drive;
619 1.1 bouyer
620 1.1 bouyer /*
621 1.1 bouyer * If drive is using UDMA, timings setups are independant
622 1.1 bouyer * So just check DMA and PIO here.
623 1.1 bouyer */
624 1.1 bouyer if (drvp->drive_flags & DRIVE_DMA) {
625 1.1 bouyer /* if mode = DMA mode 0, use compatible timings */
626 1.1 bouyer if ((drvp->drive_flags & DRIVE_DMA) &&
627 1.1 bouyer drvp->DMA_mode == 0) {
628 1.1 bouyer drvp->PIO_mode = 0;
629 1.1 bouyer return ret;
630 1.1 bouyer }
631 1.1 bouyer ret = PIIX_IDETIM_SET(ret, PIIX_IDETIM_TIME(drive), channel);
632 1.1 bouyer /*
633 1.1 bouyer * PIO and DMA timings are the same, use fast timings for PIO
634 1.1 bouyer * too, else use compat timings.
635 1.1 bouyer */
636 1.1 bouyer if ((piix_isp_pio[drvp->PIO_mode] !=
637 1.1 bouyer piix_isp_dma[drvp->DMA_mode]) ||
638 1.1 bouyer (piix_rtc_pio[drvp->PIO_mode] !=
639 1.1 bouyer piix_rtc_dma[drvp->DMA_mode]))
640 1.1 bouyer drvp->PIO_mode = 0;
641 1.1 bouyer /* if PIO mode <= 2, use compat timings for PIO */
642 1.1 bouyer if (drvp->PIO_mode <= 2) {
643 1.1 bouyer ret = PIIX_IDETIM_SET(ret, PIIX_IDETIM_DTE(drive),
644 1.1 bouyer channel);
645 1.1 bouyer return ret;
646 1.1 bouyer }
647 1.1 bouyer }
648 1.1 bouyer
649 1.1 bouyer /*
650 1.1 bouyer * Now setup PIO modes. If mode < 2, use compat timings.
651 1.1 bouyer * Else enable fast timings. Enable IORDY and prefetch/post
652 1.1 bouyer * if PIO mode >= 3.
653 1.1 bouyer */
654 1.1 bouyer
655 1.1 bouyer if (drvp->PIO_mode < 2)
656 1.1 bouyer return ret;
657 1.1 bouyer
658 1.1 bouyer ret = PIIX_IDETIM_SET(ret, PIIX_IDETIM_TIME(drive), channel);
659 1.1 bouyer if (drvp->PIO_mode >= 3) {
660 1.1 bouyer ret = PIIX_IDETIM_SET(ret, PIIX_IDETIM_IE(drive), channel);
661 1.1 bouyer ret = PIIX_IDETIM_SET(ret, PIIX_IDETIM_PPE(drive), channel);
662 1.1 bouyer }
663 1.1 bouyer return ret;
664 1.1 bouyer }
665 1.1 bouyer
666 1.1 bouyer /* setup values in SIDETIM registers, based on mode */
667 1.1 bouyer static u_int32_t
668 1.1 bouyer piix_setup_sidetim_timings(mode, dma, channel)
669 1.1 bouyer u_int8_t mode;
670 1.1 bouyer u_int8_t dma;
671 1.1 bouyer u_int8_t channel;
672 1.1 bouyer {
673 1.1 bouyer if (dma)
674 1.1 bouyer return PIIX_SIDETIM_ISP_SET(piix_isp_dma[mode], channel) |
675 1.1 bouyer PIIX_SIDETIM_RTC_SET(piix_rtc_dma[mode], channel);
676 1.1 bouyer else
677 1.1 bouyer return PIIX_SIDETIM_ISP_SET(piix_isp_pio[mode], channel) |
678 1.1 bouyer PIIX_SIDETIM_RTC_SET(piix_rtc_pio[mode], channel);
679 1.5 bouyer }
680 1.5 bouyer
681 1.5 bouyer static void
682 1.5 bouyer piixsata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
683 1.5 bouyer {
684 1.5 bouyer struct pciide_channel *cp;
685 1.5 bouyer bus_size_t cmdsize, ctlsize;
686 1.5 bouyer pcireg_t interface;
687 1.5 bouyer int channel;
688 1.5 bouyer
689 1.5 bouyer if (pciide_chipen(sc, pa) == 0)
690 1.5 bouyer return;
691 1.5 bouyer
692 1.5 bouyer aprint_normal("%s: bus-master DMA support present",
693 1.5 bouyer sc->sc_wdcdev.sc_dev.dv_xname);
694 1.5 bouyer pciide_mapreg_dma(sc, pa);
695 1.5 bouyer aprint_normal("\n");
696 1.1 bouyer
697 1.1 bouyer sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32 |
698 1.1 bouyer WDC_CAPABILITY_MODE;
699 1.1 bouyer sc->sc_wdcdev.PIO_cap = 4;
700 1.1 bouyer if (sc->sc_dma_ok) {
701 1.1 bouyer sc->sc_wdcdev.cap |= WDC_CAPABILITY_DMA | WDC_CAPABILITY_UDMA;
702 1.1 bouyer sc->sc_wdcdev.cap |= WDC_CAPABILITY_IRQACK;
703 1.1 bouyer sc->sc_wdcdev.irqack = pciide_irqack;
704 1.1 bouyer sc->sc_wdcdev.DMA_cap = 2;
705 1.1 bouyer sc->sc_wdcdev.UDMA_cap = 6;
706 1.1 bouyer }
707 1.1 bouyer sc->sc_wdcdev.set_modes = sata_setup_channel;
708 1.1 bouyer
709 1.1 bouyer sc->sc_wdcdev.channels = sc->wdc_chanarray;
710 1.1 bouyer sc->sc_wdcdev.nchannels = PCIIDE_NUM_CHANNELS;
711 1.1 bouyer
712 1.1 bouyer interface = PCI_INTERFACE(pa->pa_class);
713 1.1 bouyer
714 1.1 bouyer for (channel = 0; channel < sc->sc_wdcdev.nchannels; channel++) {
715 1.1 bouyer cp = &sc->pciide_channels[channel];
716 1.1 bouyer if (pciide_chansetup(sc, channel, interface) == 0)
717 1.1 bouyer continue;
718 1.1 bouyer pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
719 1.1 bouyer pciide_pci_intr);
720 1.1 bouyer }
721 1.1 bouyer }
722