Home | History | Annotate | Line # | Download | only in pci
aceride.c revision 1.6.4.1
      1  1.6.4.1      riz /*	$NetBSD: aceride.c,v 1.6.4.1 2005/08/07 15:51:33 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_acer_reg.h>
     40      1.1   bouyer 
     41  1.6.4.1      riz static int acer_pcib_match(struct pci_attach_args *);
     42  1.6.4.1      riz static void acer_do_reset(struct wdc_channel *, int);
     43      1.2  thorpej static void acer_chip_map(struct pciide_softc*, struct pci_attach_args*);
     44      1.5  thorpej static void acer_setup_channel(struct wdc_channel*);
     45      1.2  thorpej static int  acer_pci_intr(void *);
     46      1.1   bouyer 
     47      1.2  thorpej static int  aceride_match(struct device *, struct cfdata *, void *);
     48      1.2  thorpej static void aceride_attach(struct device *, struct device *, void *);
     49      1.1   bouyer 
     50  1.6.4.1      riz struct aceride_softc {
     51  1.6.4.1      riz 	struct pciide_softc pciide_sc;
     52  1.6.4.1      riz 	struct pci_attach_args pcib_pa;
     53  1.6.4.1      riz };
     54  1.6.4.1      riz CFATTACH_DECL(aceride, sizeof(struct aceride_softc),
     55      1.1   bouyer     aceride_match, aceride_attach, NULL, NULL);
     56      1.1   bouyer 
     57      1.2  thorpej static const struct pciide_product_desc pciide_acer_products[] =  {
     58      1.1   bouyer 	{ PCI_PRODUCT_ALI_M5229,
     59      1.1   bouyer 	  0,
     60      1.1   bouyer 	  "Acer Labs M5229 UDMA IDE Controller",
     61      1.1   bouyer 	  acer_chip_map,
     62      1.1   bouyer 	},
     63      1.1   bouyer 	{ 0,
     64      1.1   bouyer 	  0,
     65      1.1   bouyer 	  NULL,
     66      1.1   bouyer 	  NULL
     67      1.1   bouyer 	}
     68      1.1   bouyer };
     69      1.1   bouyer 
     70      1.2  thorpej static int
     71      1.2  thorpej aceride_match(struct device *parent, struct cfdata *match, void *aux)
     72      1.1   bouyer {
     73      1.1   bouyer 	struct pci_attach_args *pa = aux;
     74      1.1   bouyer 
     75      1.3  mycroft 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ALI &&
     76      1.3  mycroft 	    PCI_CLASS(pa->pa_class) == PCI_CLASS_MASS_STORAGE &&
     77      1.3  mycroft 	    PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_IDE) {
     78      1.1   bouyer 		if (pciide_lookup_product(pa->pa_id, pciide_acer_products))
     79      1.1   bouyer 			return (2);
     80      1.1   bouyer 	}
     81      1.1   bouyer 	return (0);
     82      1.1   bouyer }
     83      1.1   bouyer 
     84      1.2  thorpej static void
     85      1.2  thorpej aceride_attach(struct device *parent, struct device *self, void *aux)
     86      1.1   bouyer {
     87      1.1   bouyer 	struct pci_attach_args *pa = aux;
     88      1.1   bouyer 	struct pciide_softc *sc = (struct pciide_softc *)self;
     89      1.1   bouyer 
     90      1.1   bouyer 	pciide_common_attach(sc, pa,
     91      1.1   bouyer 	    pciide_lookup_product(pa->pa_id, pciide_acer_products));
     92      1.1   bouyer 
     93      1.1   bouyer }
     94      1.1   bouyer 
     95  1.6.4.1      riz static int
     96  1.6.4.1      riz acer_pcib_match(struct pci_attach_args *pa)
     97  1.6.4.1      riz {
     98  1.6.4.1      riz 	/*
     99  1.6.4.1      riz 	 * we need to access the PCI config space of the pcib, see
    100  1.6.4.1      riz 	 * acer_do_reset()
    101  1.6.4.1      riz 	 */
    102  1.6.4.1      riz 	if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE &&
    103  1.6.4.1      riz 	    PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_BRIDGE_ISA &&
    104  1.6.4.1      riz 	    PCI_VENDOR(pa->pa_id) == PCI_VENDOR_ALI &&
    105  1.6.4.1      riz 	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_ALI_M1543)
    106  1.6.4.1      riz 		return 1;
    107  1.6.4.1      riz 	return 0;
    108  1.6.4.1      riz }
    109  1.6.4.1      riz 
    110      1.2  thorpej static void
    111      1.2  thorpej acer_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
    112      1.1   bouyer {
    113      1.1   bouyer 	struct pciide_channel *cp;
    114      1.1   bouyer 	int channel;
    115      1.1   bouyer 	pcireg_t cr, interface;
    116      1.1   bouyer 	bus_size_t cmdsize, ctlsize;
    117      1.1   bouyer 	pcireg_t rev = PCI_REVISION(pa->pa_class);
    118  1.6.4.1      riz 	struct aceride_softc *acer_sc = (struct aceride_softc *)sc;
    119      1.1   bouyer 
    120      1.1   bouyer 	if (pciide_chipen(sc, pa) == 0)
    121      1.1   bouyer 		return;
    122      1.1   bouyer 
    123      1.1   bouyer 	aprint_normal("%s: bus-master DMA support present",
    124      1.1   bouyer 	    sc->sc_wdcdev.sc_dev.dv_xname);
    125      1.1   bouyer 	pciide_mapreg_dma(sc, pa);
    126      1.1   bouyer 	aprint_normal("\n");
    127      1.1   bouyer 	sc->sc_wdcdev.cap = WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32 |
    128      1.1   bouyer 	    WDC_CAPABILITY_MODE;
    129      1.1   bouyer 	if (sc->sc_dma_ok) {
    130      1.1   bouyer 		sc->sc_wdcdev.cap |= WDC_CAPABILITY_DMA;
    131      1.1   bouyer 		if (rev >= 0x20) {
    132      1.1   bouyer 			sc->sc_wdcdev.cap |= WDC_CAPABILITY_UDMA;
    133      1.1   bouyer 			if (rev >= 0xC4)
    134      1.1   bouyer 				sc->sc_wdcdev.UDMA_cap = 5;
    135      1.1   bouyer 			else if (rev >= 0xC2)
    136      1.1   bouyer 				sc->sc_wdcdev.UDMA_cap = 4;
    137      1.1   bouyer 			else
    138      1.1   bouyer 				sc->sc_wdcdev.UDMA_cap = 2;
    139      1.1   bouyer 		}
    140      1.1   bouyer 		sc->sc_wdcdev.cap |= WDC_CAPABILITY_IRQACK;
    141      1.1   bouyer 		sc->sc_wdcdev.irqack = pciide_irqack;
    142      1.1   bouyer 	}
    143      1.1   bouyer 
    144      1.1   bouyer 	sc->sc_wdcdev.PIO_cap = 4;
    145      1.1   bouyer 	sc->sc_wdcdev.DMA_cap = 2;
    146      1.1   bouyer 	sc->sc_wdcdev.set_modes = acer_setup_channel;
    147      1.1   bouyer 	sc->sc_wdcdev.channels = sc->wdc_chanarray;
    148      1.1   bouyer 	sc->sc_wdcdev.nchannels = PCIIDE_NUM_CHANNELS;
    149      1.1   bouyer 
    150      1.1   bouyer 	pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_CDRC,
    151      1.1   bouyer 	    (pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_CDRC) |
    152      1.1   bouyer 		ACER_CDRC_DMA_EN) & ~ACER_CDRC_FIFO_DISABLE);
    153      1.1   bouyer 
    154      1.1   bouyer 	/* Enable "microsoft register bits" R/W. */
    155      1.1   bouyer 	pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_CCAR3,
    156      1.1   bouyer 	    pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_CCAR3) | ACER_CCAR3_PI);
    157      1.1   bouyer 	pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_CCAR1,
    158      1.1   bouyer 	    pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_CCAR1) &
    159      1.1   bouyer 	    ~(ACER_CHANSTATUS_RO|PCIIDE_CHAN_RO(0)|PCIIDE_CHAN_RO(1)));
    160      1.1   bouyer 	pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_CCAR2,
    161      1.1   bouyer 	    pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_CCAR2) &
    162      1.1   bouyer 	    ~ACER_CHANSTATUSREGS_RO);
    163      1.1   bouyer 	cr = pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_CLASS_REG);
    164      1.1   bouyer 	cr |= (PCIIDE_CHANSTATUS_EN << PCI_INTERFACE_SHIFT);
    165      1.1   bouyer 	pci_conf_write(sc->sc_pc, sc->sc_tag, PCI_CLASS_REG, cr);
    166      1.1   bouyer 	/* Don't use cr, re-read the real register content instead */
    167      1.1   bouyer 	interface = PCI_INTERFACE(pci_conf_read(sc->sc_pc, sc->sc_tag,
    168      1.1   bouyer 	    PCI_CLASS_REG));
    169      1.1   bouyer 
    170      1.1   bouyer 	/* From linux: enable "Cable Detection" */
    171      1.1   bouyer 	if (rev >= 0xC2) {
    172      1.1   bouyer 		pciide_pci_write(sc->sc_pc, sc->sc_tag, ACER_0x4B,
    173      1.1   bouyer 		    pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_0x4B)
    174      1.1   bouyer 		    | ACER_0x4B_CDETECT);
    175      1.1   bouyer 	}
    176      1.1   bouyer 
    177  1.6.4.1      riz 	if (rev == 0xC3) {
    178  1.6.4.1      riz 		/* install reset bug workaround */
    179  1.6.4.1      riz 		if (pci_find_device(&acer_sc->pcib_pa, acer_pcib_match) == 0) {
    180  1.6.4.1      riz 			printf("%s: WARNING: can't find pci-isa bridge\n",
    181  1.6.4.1      riz 			    sc->sc_wdcdev.sc_dev.dv_xname);
    182  1.6.4.1      riz 		} else
    183  1.6.4.1      riz 			sc->sc_wdcdev.reset = acer_do_reset;
    184  1.6.4.1      riz 	}
    185  1.6.4.1      riz 
    186      1.1   bouyer 	for (channel = 0; channel < sc->sc_wdcdev.nchannels; channel++) {
    187      1.1   bouyer 		cp = &sc->pciide_channels[channel];
    188      1.1   bouyer 		if (pciide_chansetup(sc, channel, interface) == 0)
    189      1.1   bouyer 			continue;
    190      1.1   bouyer 		if ((interface & PCIIDE_CHAN_EN(channel)) == 0) {
    191      1.1   bouyer 			aprint_normal("%s: %s channel ignored (disabled)\n",
    192      1.1   bouyer 			    sc->sc_wdcdev.sc_dev.dv_xname, cp->name);
    193      1.1   bouyer 			cp->wdc_channel.ch_flags |= WDCF_DISABLED;
    194      1.1   bouyer 			continue;
    195      1.1   bouyer 		}
    196      1.1   bouyer 		/* newer controllers seems to lack the ACER_CHIDS. Sigh */
    197      1.1   bouyer 		pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
    198      1.1   bouyer 		     (rev >= 0xC2) ? pciide_pci_intr : acer_pci_intr);
    199      1.1   bouyer 	}
    200      1.1   bouyer }
    201      1.1   bouyer 
    202      1.2  thorpej static void
    203  1.6.4.1      riz acer_do_reset(struct wdc_channel *chp, int poll)
    204  1.6.4.1      riz {
    205  1.6.4.1      riz 	struct pciide_channel *cp = (struct pciide_channel*)chp;
    206  1.6.4.1      riz 	struct pciide_softc *sc = (struct pciide_softc *)cp->wdc_channel.ch_wdc;
    207  1.6.4.1      riz 	struct aceride_softc *acer_sc = (struct aceride_softc *)sc;
    208  1.6.4.1      riz 	u_int8_t reg;
    209  1.6.4.1      riz 
    210  1.6.4.1      riz 	/*
    211  1.6.4.1      riz 	 * From OpenSolaris: after a reset we need to disable/enable the
    212  1.6.4.1      riz 	 * corresponding channel, or data corruption will occur in
    213  1.6.4.1      riz 	 * UltraDMA modes
    214  1.6.4.1      riz 	 */
    215  1.6.4.1      riz 
    216  1.6.4.1      riz 	wdc_do_reset(chp, poll);
    217  1.6.4.1      riz 	reg = pciide_pci_read(acer_sc->pcib_pa.pa_pc, acer_sc->pcib_pa.pa_tag,
    218  1.6.4.1      riz 	    ACER_PCIB_CTRL);
    219  1.6.4.1      riz 	pciide_pci_write(acer_sc->pcib_pa.pa_pc, acer_sc->pcib_pa.pa_tag,
    220  1.6.4.1      riz 	    ACER_PCIB_CTRL, reg & ACER_PCIB_CTRL_ENCHAN(chp->ch_channel));
    221  1.6.4.1      riz 	delay(1000);
    222  1.6.4.1      riz 	pciide_pci_write(acer_sc->pcib_pa.pa_pc, acer_sc->pcib_pa.pa_tag,
    223  1.6.4.1      riz 	    ACER_PCIB_CTRL, reg);
    224  1.6.4.1      riz }
    225  1.6.4.1      riz 
    226  1.6.4.1      riz static void
    227      1.5  thorpej acer_setup_channel(struct wdc_channel *chp)
    228      1.1   bouyer {
    229      1.1   bouyer 	struct ata_drive_datas *drvp;
    230      1.1   bouyer 	int drive;
    231      1.1   bouyer 	u_int32_t acer_fifo_udma;
    232      1.1   bouyer 	u_int32_t idedma_ctl;
    233      1.1   bouyer 	struct pciide_channel *cp = (struct pciide_channel*)chp;
    234      1.6  thorpej 	struct pciide_softc *sc = (struct pciide_softc *)cp->wdc_channel.ch_wdc;
    235      1.1   bouyer 
    236      1.1   bouyer 	idedma_ctl = 0;
    237      1.1   bouyer 	acer_fifo_udma = pci_conf_read(sc->sc_pc, sc->sc_tag, ACER_FTH_UDMA);
    238      1.1   bouyer 	WDCDEBUG_PRINT(("acer_setup_channel: old fifo/udma reg 0x%x\n",
    239      1.1   bouyer 	    acer_fifo_udma), DEBUG_PROBE);
    240      1.1   bouyer 	/* setup DMA if needed */
    241      1.1   bouyer 	pciide_channel_dma_setup(cp);
    242      1.1   bouyer 
    243      1.1   bouyer 	if ((chp->ch_drive[0].drive_flags | chp->ch_drive[1].drive_flags) &
    244      1.1   bouyer 	    DRIVE_UDMA) { /* check 80 pins cable */
    245      1.1   bouyer 		if (pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_0x4A) &
    246      1.6  thorpej 		    ACER_0x4A_80PIN(chp->ch_channel)) {
    247      1.1   bouyer 			if (chp->ch_drive[0].UDMA_mode > 2)
    248      1.1   bouyer 				chp->ch_drive[0].UDMA_mode = 2;
    249      1.1   bouyer 			if (chp->ch_drive[1].UDMA_mode > 2)
    250      1.1   bouyer 				chp->ch_drive[1].UDMA_mode = 2;
    251      1.1   bouyer 		}
    252      1.1   bouyer 	}
    253      1.1   bouyer 
    254      1.1   bouyer 	for (drive = 0; drive < 2; drive++) {
    255      1.1   bouyer 		drvp = &chp->ch_drive[drive];
    256      1.1   bouyer 		/* If no drive, skip */
    257      1.1   bouyer 		if ((drvp->drive_flags & DRIVE) == 0)
    258      1.1   bouyer 			continue;
    259      1.1   bouyer 		WDCDEBUG_PRINT(("acer_setup_channel: old timings reg for "
    260      1.6  thorpej 		    "channel %d drive %d 0x%x\n", chp->ch_channel, drive,
    261      1.1   bouyer 		    pciide_pci_read(sc->sc_pc, sc->sc_tag,
    262      1.6  thorpej 		    ACER_IDETIM(chp->ch_channel, drive))), DEBUG_PROBE);
    263      1.1   bouyer 		/* clear FIFO/DMA mode */
    264      1.6  thorpej 		acer_fifo_udma &= ~(ACER_FTH_OPL(chp->ch_channel, drive, 0x3) |
    265      1.6  thorpej 		    ACER_UDMA_EN(chp->ch_channel, drive) |
    266      1.6  thorpej 		    ACER_UDMA_TIM(chp->ch_channel, drive, 0x7));
    267      1.1   bouyer 
    268      1.1   bouyer 		/* add timing values, setup DMA if needed */
    269      1.1   bouyer 		if ((drvp->drive_flags & DRIVE_DMA) == 0 &&
    270      1.1   bouyer 		    (drvp->drive_flags & DRIVE_UDMA) == 0) {
    271      1.1   bouyer 			acer_fifo_udma |=
    272      1.6  thorpej 			    ACER_FTH_OPL(chp->ch_channel, drive, 0x1);
    273      1.1   bouyer 			goto pio;
    274      1.1   bouyer 		}
    275      1.1   bouyer 
    276      1.6  thorpej 		acer_fifo_udma |= ACER_FTH_OPL(chp->ch_channel, drive, 0x2);
    277      1.1   bouyer 		if (drvp->drive_flags & DRIVE_UDMA) {
    278      1.1   bouyer 			/* use Ultra/DMA */
    279      1.1   bouyer 			drvp->drive_flags &= ~DRIVE_DMA;
    280      1.6  thorpej 			acer_fifo_udma |= ACER_UDMA_EN(chp->ch_channel, drive);
    281      1.1   bouyer 			acer_fifo_udma |=
    282      1.6  thorpej 			    ACER_UDMA_TIM(chp->ch_channel, drive,
    283      1.1   bouyer 				acer_udma[drvp->UDMA_mode]);
    284      1.1   bouyer 			/* XXX disable if one drive < UDMA3 ? */
    285      1.1   bouyer 			if (drvp->UDMA_mode >= 3) {
    286      1.1   bouyer 				pciide_pci_write(sc->sc_pc, sc->sc_tag,
    287      1.1   bouyer 				    ACER_0x4B,
    288      1.1   bouyer 				    pciide_pci_read(sc->sc_pc, sc->sc_tag,
    289      1.1   bouyer 					ACER_0x4B) | ACER_0x4B_UDMA66);
    290      1.1   bouyer 			}
    291      1.1   bouyer 		} else {
    292      1.1   bouyer 			/*
    293      1.1   bouyer 			 * use Multiword DMA
    294      1.1   bouyer 			 * Timings will be used for both PIO and DMA,
    295      1.1   bouyer 			 * so adjust DMA mode if needed
    296      1.1   bouyer 			 */
    297      1.1   bouyer 			if (drvp->PIO_mode > (drvp->DMA_mode + 2))
    298      1.1   bouyer 				drvp->PIO_mode = drvp->DMA_mode + 2;
    299      1.1   bouyer 			if (drvp->DMA_mode + 2 > (drvp->PIO_mode))
    300      1.1   bouyer 				drvp->DMA_mode = (drvp->PIO_mode > 2) ?
    301      1.1   bouyer 				    drvp->PIO_mode - 2 : 0;
    302      1.1   bouyer 			if (drvp->DMA_mode == 0)
    303      1.1   bouyer 				drvp->PIO_mode = 0;
    304      1.1   bouyer 		}
    305      1.1   bouyer 		idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
    306      1.1   bouyer pio:		pciide_pci_write(sc->sc_pc, sc->sc_tag,
    307      1.6  thorpej 		    ACER_IDETIM(chp->ch_channel, drive),
    308      1.1   bouyer 		    acer_pio[drvp->PIO_mode]);
    309      1.1   bouyer 	}
    310      1.1   bouyer 	WDCDEBUG_PRINT(("acer_setup_channel: new fifo/udma reg 0x%x\n",
    311      1.1   bouyer 	    acer_fifo_udma), DEBUG_PROBE);
    312      1.1   bouyer 	pci_conf_write(sc->sc_pc, sc->sc_tag, ACER_FTH_UDMA, acer_fifo_udma);
    313      1.1   bouyer 	if (idedma_ctl != 0) {
    314      1.1   bouyer 		/* Add software bits in status register */
    315      1.4     fvdl 		bus_space_write_1(sc->sc_dma_iot, cp->dma_iohs[IDEDMA_CTL], 0,
    316      1.1   bouyer 		    idedma_ctl);
    317      1.1   bouyer 	}
    318      1.1   bouyer }
    319      1.1   bouyer 
    320      1.2  thorpej static int
    321      1.2  thorpej acer_pci_intr(void *arg)
    322      1.1   bouyer {
    323      1.1   bouyer 	struct pciide_softc *sc = arg;
    324      1.1   bouyer 	struct pciide_channel *cp;
    325      1.5  thorpej 	struct wdc_channel *wdc_cp;
    326      1.1   bouyer 	int i, rv, crv;
    327      1.1   bouyer 	u_int32_t chids;
    328      1.1   bouyer 
    329      1.1   bouyer 	rv = 0;
    330      1.1   bouyer 	chids = pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_CHIDS);
    331      1.1   bouyer 	for (i = 0; i < sc->sc_wdcdev.nchannels; i++) {
    332      1.1   bouyer 		cp = &sc->pciide_channels[i];
    333      1.1   bouyer 		wdc_cp = &cp->wdc_channel;
    334      1.1   bouyer 		/* If a compat channel skip. */
    335      1.1   bouyer 		if (cp->compat)
    336      1.1   bouyer 			continue;
    337      1.1   bouyer 		if (chids & ACER_CHIDS_INT(i)) {
    338      1.1   bouyer 			crv = wdcintr(wdc_cp);
    339      1.1   bouyer 			if (crv == 0)
    340      1.1   bouyer 				printf("%s:%d: bogus intr\n",
    341      1.1   bouyer 				    sc->sc_wdcdev.sc_dev.dv_xname, i);
    342      1.1   bouyer 			else
    343      1.1   bouyer 				rv = 1;
    344      1.1   bouyer 		}
    345      1.1   bouyer 	}
    346      1.1   bouyer 	return rv;
    347      1.1   bouyer }
    348