aceride.c revision 1.25.14.1 1 1.25.14.1 riz /* $NetBSD: aceride.c,v 1.25.14.1 2010/11/21 23:41:20 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.14 perry * 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.15 lukem #include <sys/cdefs.h>
33 1.25.14.1 riz __KERNEL_RCSID(0, "$NetBSD: aceride.c,v 1.25.14.1 2010/11/21 23:41:20 riz Exp $");
34 1.15 lukem
35 1.1 bouyer #include <sys/param.h>
36 1.1 bouyer #include <sys/systm.h>
37 1.1 bouyer
38 1.1 bouyer #include <dev/pci/pcivar.h>
39 1.1 bouyer #include <dev/pci/pcidevs.h>
40 1.1 bouyer #include <dev/pci/pciidereg.h>
41 1.1 bouyer #include <dev/pci/pciidevar.h>
42 1.1 bouyer #include <dev/pci/pciide_acer_reg.h>
43 1.1 bouyer
44 1.16 bouyer static int acer_pcib_match(struct pci_attach_args *);
45 1.16 bouyer static void acer_do_reset(struct ata_channel *, int);
46 1.2 thorpej static void acer_chip_map(struct pciide_softc*, struct pci_attach_args*);
47 1.10 thorpej static void acer_setup_channel(struct ata_channel*);
48 1.2 thorpej static int acer_pci_intr(void *);
49 1.25.14.1 riz static int acer_dma_init(void *, int, int, void *, size_t, int);
50 1.1 bouyer
51 1.25 cube static int aceride_match(device_t, cfdata_t, void *);
52 1.25 cube static void aceride_attach(device_t, device_t, void *);
53 1.1 bouyer
54 1.16 bouyer struct aceride_softc {
55 1.16 bouyer struct pciide_softc pciide_sc;
56 1.16 bouyer struct pci_attach_args pcib_pa;
57 1.16 bouyer };
58 1.16 bouyer
59 1.25 cube CFATTACH_DECL_NEW(aceride, sizeof(struct aceride_softc),
60 1.1 bouyer aceride_match, aceride_attach, NULL, NULL);
61 1.1 bouyer
62 1.2 thorpej static const struct pciide_product_desc pciide_acer_products[] = {
63 1.1 bouyer { PCI_PRODUCT_ALI_M5229,
64 1.1 bouyer 0,
65 1.1 bouyer "Acer Labs M5229 UDMA IDE Controller",
66 1.1 bouyer acer_chip_map,
67 1.1 bouyer },
68 1.1 bouyer { 0,
69 1.1 bouyer 0,
70 1.1 bouyer NULL,
71 1.1 bouyer NULL
72 1.1 bouyer }
73 1.1 bouyer };
74 1.1 bouyer
75 1.2 thorpej static int
76 1.25 cube aceride_match(device_t parent, cfdata_t match, void *aux)
77 1.1 bouyer {
78 1.1 bouyer struct pci_attach_args *pa = aux;
79 1.1 bouyer
80 1.3 mycroft if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ALI &&
81 1.3 mycroft PCI_CLASS(pa->pa_class) == PCI_CLASS_MASS_STORAGE &&
82 1.3 mycroft PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_IDE) {
83 1.1 bouyer if (pciide_lookup_product(pa->pa_id, pciide_acer_products))
84 1.1 bouyer return (2);
85 1.1 bouyer }
86 1.1 bouyer return (0);
87 1.1 bouyer }
88 1.1 bouyer
89 1.2 thorpej static void
90 1.25 cube aceride_attach(device_t parent, device_t self, void *aux)
91 1.1 bouyer {
92 1.1 bouyer struct pci_attach_args *pa = aux;
93 1.25 cube struct pciide_softc *sc = device_private(self);
94 1.25 cube
95 1.25 cube sc->sc_wdcdev.sc_atac.atac_dev = self;
96 1.1 bouyer
97 1.1 bouyer pciide_common_attach(sc, pa,
98 1.1 bouyer pciide_lookup_product(pa->pa_id, pciide_acer_products));
99 1.1 bouyer }
100 1.1 bouyer
101 1.16 bouyer static int
102 1.16 bouyer acer_pcib_match(struct pci_attach_args *pa)
103 1.16 bouyer {
104 1.16 bouyer /*
105 1.16 bouyer * we need to access the PCI config space of the pcib, see
106 1.16 bouyer * acer_do_reset()
107 1.16 bouyer */
108 1.16 bouyer if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE &&
109 1.16 bouyer PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_BRIDGE_ISA &&
110 1.16 bouyer PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ALI &&
111 1.16 bouyer PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ALI_M1543)
112 1.16 bouyer return 1;
113 1.16 bouyer return 0;
114 1.16 bouyer }
115 1.16 bouyer
116 1.2 thorpej static void
117 1.2 thorpej acer_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
118 1.1 bouyer {
119 1.1 bouyer struct pciide_channel *cp;
120 1.1 bouyer int channel;
121 1.1 bouyer pcireg_t cr, interface;
122 1.1 bouyer bus_size_t cmdsize, ctlsize;
123 1.1 bouyer pcireg_t rev = PCI_REVISION(pa->pa_class);
124 1.16 bouyer struct aceride_softc *acer_sc = (struct aceride_softc *)sc;
125 1.1 bouyer
126 1.1 bouyer if (pciide_chipen(sc, pa) == 0)
127 1.1 bouyer return;
128 1.1 bouyer
129 1.25 cube aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev,
130 1.25 cube "bus-master DMA support present");
131 1.1 bouyer pciide_mapreg_dma(sc, pa);
132 1.23 ad aprint_verbose("\n");
133 1.12 thorpej sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DATA32;
134 1.1 bouyer if (sc->sc_dma_ok) {
135 1.12 thorpej sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DMA;
136 1.1 bouyer if (rev >= 0x20) {
137 1.12 thorpej sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_UDMA;
138 1.22 christos if (rev >= 0xC7)
139 1.22 christos sc->sc_wdcdev.sc_atac.atac_udma_cap = 6;
140 1.22 christos else if (rev >= 0xC4)
141 1.12 thorpej sc->sc_wdcdev.sc_atac.atac_udma_cap = 5;
142 1.1 bouyer else if (rev >= 0xC2)
143 1.12 thorpej sc->sc_wdcdev.sc_atac.atac_udma_cap = 4;
144 1.1 bouyer else
145 1.12 thorpej sc->sc_wdcdev.sc_atac.atac_udma_cap = 2;
146 1.1 bouyer }
147 1.1 bouyer sc->sc_wdcdev.irqack = pciide_irqack;
148 1.25.14.1 riz if (rev <= 0xc4) {
149 1.25.14.1 riz sc->sc_wdcdev.dma_init = acer_dma_init;
150 1.25.14.1 riz aprint_verbose_dev(sc->sc_wdcdev.sc_atac.atac_dev,
151 1.25.14.1 riz "using PIO transfers above 137GB as workaround for "
152 1.25.14.1 riz "48bit DMA access bug, expect reduced performance\n");
153 1.25.14.1 riz }
154 1.1 bouyer }
155 1.14 perry
156 1.12 thorpej sc->sc_wdcdev.sc_atac.atac_pio_cap = 4;
157 1.12 thorpej sc->sc_wdcdev.sc_atac.atac_dma_cap = 2;
158 1.12 thorpej sc->sc_wdcdev.sc_atac.atac_set_modes = acer_setup_channel;
159 1.12 thorpej sc->sc_wdcdev.sc_atac.atac_channels = sc->wdc_chanarray;
160 1.12 thorpej sc->sc_wdcdev.sc_atac.atac_nchannels = PCIIDE_NUM_CHANNELS;
161 1.1 bouyer
162 1.1 bouyer pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_CDRC,
163 1.1 bouyer (pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_CDRC) |
164 1.1 bouyer ACER_CDRC_DMA_EN) & ~ACER_CDRC_FIFO_DISABLE);
165 1.1 bouyer
166 1.1 bouyer /* Enable "microsoft register bits" R/W. */
167 1.1 bouyer pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_CCAR3,
168 1.1 bouyer pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_CCAR3) | ACER_CCAR3_PI);
169 1.1 bouyer pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_CCAR1,
170 1.1 bouyer pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_CCAR1) &
171 1.1 bouyer ~(ACER_CHANSTATUS_RO|PCIIDE_CHAN_RO(0)|PCIIDE_CHAN_RO(1)));
172 1.1 bouyer pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_CCAR2,
173 1.1 bouyer pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_CCAR2) &
174 1.1 bouyer ~ACER_CHANSTATUSREGS_RO);
175 1.1 bouyer cr = pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_CLASS_REG);
176 1.1 bouyer cr |= (PCIIDE_CHANSTATUS_EN << PCI_INTERFACE_SHIFT);
177 1.24 chris
178 1.24 chris {
179 1.24 chris /*
180 1.24 chris * some BIOSes (port-cats ABLE) enable native mode, but don't
181 1.24 chris * setup everything correctly, so allow the forcing of
182 1.24 chris * compat mode
183 1.24 chris */
184 1.24 chris bool force_compat_mode;
185 1.24 chris bool property_is_set;
186 1.24 chris property_is_set = prop_dictionary_get_bool(
187 1.25 cube device_properties(sc->sc_wdcdev.sc_atac.atac_dev),
188 1.24 chris "ali1543-ide-force-compat-mode",
189 1.24 chris &force_compat_mode);
190 1.24 chris if (property_is_set && force_compat_mode) {
191 1.24 chris cr &= ~((PCIIDE_INTERFACE_PCI(0)
192 1.24 chris | PCIIDE_INTERFACE_PCI(1))
193 1.24 chris << PCI_INTERFACE_SHIFT);
194 1.24 chris }
195 1.24 chris }
196 1.24 chris
197 1.1 bouyer pci_conf_write(sc->sc_pc, sc->sc_tag, PCI_CLASS_REG, cr);
198 1.1 bouyer /* Don't use cr, re-read the real register content instead */
199 1.1 bouyer interface = PCI_INTERFACE(pci_conf_read(sc->sc_pc, sc->sc_tag,
200 1.1 bouyer PCI_CLASS_REG));
201 1.1 bouyer
202 1.1 bouyer /* From linux: enable "Cable Detection" */
203 1.1 bouyer if (rev >= 0xC2) {
204 1.1 bouyer pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_0x4B,
205 1.1 bouyer pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_0x4B)
206 1.1 bouyer | ACER_0x4B_CDETECT);
207 1.1 bouyer }
208 1.1 bouyer
209 1.10 thorpej wdc_allocate_regs(&sc->sc_wdcdev);
210 1.16 bouyer if (rev == 0xC3) {
211 1.16 bouyer /* install reset bug workaround */
212 1.16 bouyer if (pci_find_device(&acer_sc->pcib_pa, acer_pcib_match) == 0) {
213 1.25 cube aprint_error_dev(sc->sc_wdcdev.sc_atac.atac_dev,
214 1.25 cube "WARNING: can't find pci-isa bridge\n");
215 1.16 bouyer } else
216 1.16 bouyer sc->sc_wdcdev.reset = acer_do_reset;
217 1.16 bouyer }
218 1.10 thorpej
219 1.12 thorpej for (channel = 0; channel < sc->sc_wdcdev.sc_atac.atac_nchannels;
220 1.12 thorpej channel++) {
221 1.1 bouyer cp = &sc->pciide_channels[channel];
222 1.1 bouyer if (pciide_chansetup(sc, channel, interface) == 0)
223 1.1 bouyer continue;
224 1.1 bouyer if ((interface & PCIIDE_CHAN_EN(channel)) == 0) {
225 1.25 cube aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev,
226 1.25 cube "%s channel ignored (disabled)\n", cp->name);
227 1.10 thorpej cp->ata_channel.ch_flags |= ATACH_DISABLED;
228 1.1 bouyer continue;
229 1.1 bouyer }
230 1.1 bouyer /* newer controllers seems to lack the ACER_CHIDS. Sigh */
231 1.1 bouyer pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
232 1.1 bouyer (rev >= 0xC2) ? pciide_pci_intr : acer_pci_intr);
233 1.1 bouyer }
234 1.1 bouyer }
235 1.1 bouyer
236 1.2 thorpej static void
237 1.16 bouyer acer_do_reset(struct ata_channel *chp, int poll)
238 1.16 bouyer {
239 1.16 bouyer struct pciide_softc *sc = CHAN_TO_PCIIDE(chp);
240 1.16 bouyer struct aceride_softc *acer_sc = (struct aceride_softc *)sc;
241 1.16 bouyer u_int8_t reg;
242 1.16 bouyer
243 1.16 bouyer /*
244 1.16 bouyer * From OpenSolaris: after a reset we need to disable/enable the
245 1.16 bouyer * corresponding channel, or data corruption will occur in
246 1.16 bouyer * UltraDMA modes
247 1.16 bouyer */
248 1.16 bouyer
249 1.16 bouyer wdc_do_reset(chp, poll);
250 1.16 bouyer reg = pciide_pci_read(acer_sc->pcib_pa.pa_pc, acer_sc->pcib_pa.pa_tag,
251 1.16 bouyer ACER_PCIB_CTRL);
252 1.16 bouyer pciide_pci_write(acer_sc->pcib_pa.pa_pc, acer_sc->pcib_pa.pa_tag,
253 1.18 bouyer ACER_PCIB_CTRL, reg & ~ACER_PCIB_CTRL_ENCHAN(chp->ch_channel));
254 1.16 bouyer delay(1000);
255 1.16 bouyer pciide_pci_write(acer_sc->pcib_pa.pa_pc, acer_sc->pcib_pa.pa_tag,
256 1.16 bouyer ACER_PCIB_CTRL, reg);
257 1.16 bouyer }
258 1.16 bouyer
259 1.16 bouyer static void
260 1.10 thorpej acer_setup_channel(struct ata_channel *chp)
261 1.1 bouyer {
262 1.1 bouyer struct ata_drive_datas *drvp;
263 1.13 thorpej int drive, s;
264 1.1 bouyer u_int32_t acer_fifo_udma;
265 1.1 bouyer u_int32_t idedma_ctl;
266 1.1 bouyer struct pciide_channel *cp = (struct pciide_channel*)chp;
267 1.11 thorpej struct pciide_softc *sc = CHAN_TO_PCIIDE(chp);
268 1.1 bouyer
269 1.1 bouyer idedma_ctl = 0;
270 1.1 bouyer acer_fifo_udma = pci_conf_read(sc->sc_pc, sc->sc_tag, ACER_FTH_UDMA);
271 1.14 perry ATADEBUG_PRINT(("acer_setup_channel: old fifo/udma reg 0x%x\n",
272 1.1 bouyer acer_fifo_udma), DEBUG_PROBE);
273 1.1 bouyer /* setup DMA if needed */
274 1.1 bouyer pciide_channel_dma_setup(cp);
275 1.1 bouyer
276 1.1 bouyer if ((chp->ch_drive[0].drive_flags | chp->ch_drive[1].drive_flags) &
277 1.1 bouyer DRIVE_UDMA) { /* check 80 pins cable */
278 1.1 bouyer if (pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_0x4A) &
279 1.6 thorpej ACER_0x4A_80PIN(chp->ch_channel)) {
280 1.1 bouyer if (chp->ch_drive[0].UDMA_mode > 2)
281 1.1 bouyer chp->ch_drive[0].UDMA_mode = 2;
282 1.1 bouyer if (chp->ch_drive[1].UDMA_mode > 2)
283 1.1 bouyer chp->ch_drive[1].UDMA_mode = 2;
284 1.1 bouyer }
285 1.1 bouyer }
286 1.1 bouyer
287 1.1 bouyer for (drive = 0; drive < 2; drive++) {
288 1.1 bouyer drvp = &chp->ch_drive[drive];
289 1.1 bouyer /* If no drive, skip */
290 1.1 bouyer if ((drvp->drive_flags & DRIVE) == 0)
291 1.1 bouyer continue;
292 1.9 thorpej ATADEBUG_PRINT(("acer_setup_channel: old timings reg for "
293 1.6 thorpej "channel %d drive %d 0x%x\n", chp->ch_channel, drive,
294 1.1 bouyer pciide_pci_read(sc->sc_pc, sc->sc_tag,
295 1.6 thorpej ACER_IDETIM(chp->ch_channel, drive))), DEBUG_PROBE);
296 1.1 bouyer /* clear FIFO/DMA mode */
297 1.6 thorpej acer_fifo_udma &= ~(ACER_FTH_OPL(chp->ch_channel, drive, 0x3) |
298 1.6 thorpej ACER_UDMA_EN(chp->ch_channel, drive) |
299 1.6 thorpej ACER_UDMA_TIM(chp->ch_channel, drive, 0x7));
300 1.1 bouyer
301 1.1 bouyer /* add timing values, setup DMA if needed */
302 1.1 bouyer if ((drvp->drive_flags & DRIVE_DMA) == 0 &&
303 1.1 bouyer (drvp->drive_flags & DRIVE_UDMA) == 0) {
304 1.1 bouyer acer_fifo_udma |=
305 1.6 thorpej ACER_FTH_OPL(chp->ch_channel, drive, 0x1);
306 1.1 bouyer goto pio;
307 1.1 bouyer }
308 1.1 bouyer
309 1.6 thorpej acer_fifo_udma |= ACER_FTH_OPL(chp->ch_channel, drive, 0x2);
310 1.1 bouyer if (drvp->drive_flags & DRIVE_UDMA) {
311 1.1 bouyer /* use Ultra/DMA */
312 1.13 thorpej s = splbio();
313 1.1 bouyer drvp->drive_flags &= ~DRIVE_DMA;
314 1.13 thorpej splx(s);
315 1.6 thorpej acer_fifo_udma |= ACER_UDMA_EN(chp->ch_channel, drive);
316 1.14 perry acer_fifo_udma |=
317 1.6 thorpej ACER_UDMA_TIM(chp->ch_channel, drive,
318 1.1 bouyer acer_udma[drvp->UDMA_mode]);
319 1.1 bouyer /* XXX disable if one drive < UDMA3 ? */
320 1.1 bouyer if (drvp->UDMA_mode >= 3) {
321 1.1 bouyer pciide_pci_write(sc->sc_pc, sc->sc_tag,
322 1.1 bouyer ACER_0x4B,
323 1.1 bouyer pciide_pci_read(sc->sc_pc, sc->sc_tag,
324 1.1 bouyer ACER_0x4B) | ACER_0x4B_UDMA66);
325 1.1 bouyer }
326 1.1 bouyer } else {
327 1.1 bouyer /*
328 1.1 bouyer * use Multiword DMA
329 1.1 bouyer * Timings will be used for both PIO and DMA,
330 1.1 bouyer * so adjust DMA mode if needed
331 1.1 bouyer */
332 1.1 bouyer if (drvp->PIO_mode > (drvp->DMA_mode + 2))
333 1.1 bouyer drvp->PIO_mode = drvp->DMA_mode + 2;
334 1.1 bouyer if (drvp->DMA_mode + 2 > (drvp->PIO_mode))
335 1.1 bouyer drvp->DMA_mode = (drvp->PIO_mode > 2) ?
336 1.1 bouyer drvp->PIO_mode - 2 : 0;
337 1.1 bouyer if (drvp->DMA_mode == 0)
338 1.1 bouyer drvp->PIO_mode = 0;
339 1.1 bouyer }
340 1.1 bouyer idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
341 1.1 bouyer pio: pciide_pci_write(sc->sc_pc, sc->sc_tag,
342 1.6 thorpej ACER_IDETIM(chp->ch_channel, drive),
343 1.1 bouyer acer_pio[drvp->PIO_mode]);
344 1.1 bouyer }
345 1.9 thorpej ATADEBUG_PRINT(("acer_setup_channel: new fifo/udma reg 0x%x\n",
346 1.1 bouyer acer_fifo_udma), DEBUG_PROBE);
347 1.1 bouyer pci_conf_write(sc->sc_pc, sc->sc_tag, ACER_FTH_UDMA, acer_fifo_udma);
348 1.1 bouyer if (idedma_ctl != 0) {
349 1.1 bouyer /* Add software bits in status register */
350 1.4 fvdl bus_space_write_1(sc->sc_dma_iot, cp->dma_iohs[IDEDMA_CTL], 0,
351 1.1 bouyer idedma_ctl);
352 1.1 bouyer }
353 1.1 bouyer }
354 1.1 bouyer
355 1.2 thorpej static int
356 1.2 thorpej acer_pci_intr(void *arg)
357 1.1 bouyer {
358 1.1 bouyer struct pciide_softc *sc = arg;
359 1.1 bouyer struct pciide_channel *cp;
360 1.10 thorpej struct ata_channel *wdc_cp;
361 1.14 perry int i, rv, crv;
362 1.1 bouyer u_int32_t chids;
363 1.1 bouyer
364 1.1 bouyer rv = 0;
365 1.1 bouyer chids = pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_CHIDS);
366 1.12 thorpej for (i = 0; i < sc->sc_wdcdev.sc_atac.atac_nchannels; i++) {
367 1.1 bouyer cp = &sc->pciide_channels[i];
368 1.10 thorpej wdc_cp = &cp->ata_channel;
369 1.1 bouyer /* If a compat channel skip. */
370 1.1 bouyer if (cp->compat)
371 1.1 bouyer continue;
372 1.1 bouyer if (chids & ACER_CHIDS_INT(i)) {
373 1.1 bouyer crv = wdcintr(wdc_cp);
374 1.7 bouyer if (crv == 0) {
375 1.25 cube aprint_error("%s:%d: bogus intr\n",
376 1.25 cube device_xname(
377 1.25 cube sc->sc_wdcdev.sc_atac.atac_dev), i);
378 1.7 bouyer pciide_irqack(wdc_cp);
379 1.7 bouyer } else
380 1.1 bouyer rv = 1;
381 1.1 bouyer }
382 1.1 bouyer }
383 1.1 bouyer return rv;
384 1.1 bouyer }
385 1.25.14.1 riz
386 1.25.14.1 riz static int
387 1.25.14.1 riz acer_dma_init(void *v, int channel, int drive, void *databuf,
388 1.25.14.1 riz size_t datalen, int flags)
389 1.25.14.1 riz {
390 1.25.14.1 riz
391 1.25.14.1 riz /* use PIO for LBA48 transfer */
392 1.25.14.1 riz if (flags & WDC_DMA_LBA48)
393 1.25.14.1 riz return EINVAL;
394 1.25.14.1 riz
395 1.25.14.1 riz return pciide_dma_init(v, channel, drive, databuf, datalen, flags);
396 1.25.14.1 riz }
397