Home | History | Annotate | Line # | Download | only in pci
pdcide.c revision 1.1
      1  1.1  bouyer /*	$NetBSD: pdcide.c,v 1.1 2003/10/08 11:51:59 bouyer Exp $	*/
      2  1.1  bouyer 
      3  1.1  bouyer 
      4  1.1  bouyer /*
      5  1.1  bouyer  * Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
      6  1.1  bouyer  *
      7  1.1  bouyer  * Redistribution and use in source and binary forms, with or without
      8  1.1  bouyer  * modification, are permitted provided that the following conditions
      9  1.1  bouyer  * are met:
     10  1.1  bouyer  * 1. Redistributions of source code must retain the above copyright
     11  1.1  bouyer  *    notice, this list of conditions and the following disclaimer.
     12  1.1  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  bouyer  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  bouyer  *    documentation and/or other materials provided with the distribution.
     15  1.1  bouyer  * 3. All advertising materials mentioning features or use of this software
     16  1.1  bouyer  *    must display the following acknowledgement:
     17  1.1  bouyer  *	This product includes software developed by Manuel Bouyer.
     18  1.1  bouyer  * 4. The name of the author may not be used to endorse or promote products
     19  1.1  bouyer  *    derived from this software without specific prior written permission.
     20  1.1  bouyer  *
     21  1.1  bouyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1  bouyer  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1  bouyer  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1  bouyer  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1  bouyer  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1  bouyer  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1  bouyer  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1  bouyer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1  bouyer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1  bouyer  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.1  bouyer  *
     32  1.1  bouyer  */
     33  1.1  bouyer 
     34  1.1  bouyer 
     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_pdc202xx_reg.h>
     43  1.1  bouyer 
     44  1.1  bouyer void pdc202xx_chip_map __P((struct pciide_softc*, struct pci_attach_args*));
     45  1.1  bouyer void pdc202xx_setup_channel __P((struct channel_softc*));
     46  1.1  bouyer void pdc20268_setup_channel __P((struct channel_softc*));
     47  1.1  bouyer int  pdc202xx_pci_intr __P((void *));
     48  1.1  bouyer int  pdc20265_pci_intr __P((void *));
     49  1.1  bouyer static void pdc20262_dma_start __P((void*, int, int));
     50  1.1  bouyer static int  pdc20262_dma_finish __P((void*, int, int, int));
     51  1.1  bouyer 
     52  1.1  bouyer int	pdcide_match __P((struct device *, struct cfdata *, void *));
     53  1.1  bouyer void	pdcide_attach __P((struct device *, struct device *, void *));
     54  1.1  bouyer 
     55  1.1  bouyer CFATTACH_DECL(pdcide, sizeof(struct pciide_softc),
     56  1.1  bouyer     pdcide_match, pdcide_attach, NULL, NULL);
     57  1.1  bouyer 
     58  1.1  bouyer const struct pciide_product_desc pciide_promise_products[] =  {
     59  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_ULTRA33,
     60  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
     61  1.1  bouyer 	  "Promise Ultra33/ATA Bus Master IDE Accelerator",
     62  1.1  bouyer 	  pdc202xx_chip_map,
     63  1.1  bouyer 	},
     64  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_ULTRA66,
     65  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
     66  1.1  bouyer 	  "Promise Ultra66/ATA Bus Master IDE Accelerator",
     67  1.1  bouyer 	  pdc202xx_chip_map,
     68  1.1  bouyer 	},
     69  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_ULTRA100,
     70  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
     71  1.1  bouyer 	  "Promise Ultra100/ATA Bus Master IDE Accelerator",
     72  1.1  bouyer 	  pdc202xx_chip_map,
     73  1.1  bouyer 	},
     74  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_ULTRA100X,
     75  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
     76  1.1  bouyer 	  "Promise Ultra100/ATA Bus Master IDE Accelerator",
     77  1.1  bouyer 	  pdc202xx_chip_map,
     78  1.1  bouyer 	},
     79  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_ULTRA100TX2,
     80  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
     81  1.1  bouyer 	  "Promise Ultra100TX2/ATA Bus Master IDE Accelerator",
     82  1.1  bouyer 	  pdc202xx_chip_map,
     83  1.1  bouyer 	},
     84  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_ULTRA100TX2v2,
     85  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
     86  1.1  bouyer 	  "Promise Ultra100TX2v2/ATA Bus Master IDE Accelerator",
     87  1.1  bouyer 	  pdc202xx_chip_map,
     88  1.1  bouyer 	},
     89  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_ULTRA133,
     90  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
     91  1.1  bouyer 	  "Promise Ultra133/ATA Bus Master IDE Accelerator",
     92  1.1  bouyer 	  pdc202xx_chip_map,
     93  1.1  bouyer 	},
     94  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_ULTRA133TX2,
     95  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
     96  1.1  bouyer 	  "Promise Ultra133TX2/ATA Bus Master IDE Accelerator",
     97  1.1  bouyer 	  pdc202xx_chip_map,
     98  1.1  bouyer 	},
     99  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_MBULTRA133,
    100  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
    101  1.1  bouyer 	  "Promise Ultra133/ATA Bus Master IDE Accelerator (MB)",
    102  1.1  bouyer 	  pdc202xx_chip_map,
    103  1.1  bouyer 	},
    104  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_ULTRA133TX2v2,
    105  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
    106  1.1  bouyer 	  "Promise Ultra133TX2v2/ATA Bus Master IDE Accelerator",
    107  1.1  bouyer 	  pdc202xx_chip_map,
    108  1.1  bouyer 	},
    109  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_FASTTRAK133LITE,
    110  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
    111  1.1  bouyer 	  "Promise Fasttrak133 Lite Bus Master IDE Accelerator",
    112  1.1  bouyer 	  pdc202xx_chip_map,
    113  1.1  bouyer 	},
    114  1.1  bouyer 	{ PCI_PRODUCT_PROMISE_SATA150TX2PLUS,
    115  1.1  bouyer 	  IDE_PCI_CLASS_OVERRIDE,
    116  1.1  bouyer 	  "Promise Serial ATA/150 TX2plus Bus Master IDE Accelerator",
    117  1.1  bouyer 	  pdc202xx_chip_map,
    118  1.1  bouyer 	},
    119  1.1  bouyer 	{ 0,
    120  1.1  bouyer 	  0,
    121  1.1  bouyer 	  NULL,
    122  1.1  bouyer 	  NULL
    123  1.1  bouyer 	}
    124  1.1  bouyer };
    125  1.1  bouyer 
    126  1.1  bouyer int
    127  1.1  bouyer pdcide_match(parent, match, aux)
    128  1.1  bouyer 	struct device *parent;
    129  1.1  bouyer 	struct cfdata *match;
    130  1.1  bouyer 	void *aux;
    131  1.1  bouyer {
    132  1.1  bouyer 	struct pci_attach_args *pa = aux;
    133  1.1  bouyer 
    134  1.1  bouyer 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_PROMISE) {
    135  1.1  bouyer 		if (pciide_lookup_product(pa->pa_id, pciide_promise_products))
    136  1.1  bouyer 			return (2);
    137  1.1  bouyer 	}
    138  1.1  bouyer 	return (0);
    139  1.1  bouyer }
    140  1.1  bouyer 
    141  1.1  bouyer void
    142  1.1  bouyer pdcide_attach(parent, self, aux)
    143  1.1  bouyer 	struct device *parent, *self;
    144  1.1  bouyer 	void *aux;
    145  1.1  bouyer {
    146  1.1  bouyer 	struct pci_attach_args *pa = aux;
    147  1.1  bouyer 	struct pciide_softc *sc = (struct pciide_softc *)self;
    148  1.1  bouyer 
    149  1.1  bouyer 	pciide_common_attach(sc, pa,
    150  1.1  bouyer 	    pciide_lookup_product(pa->pa_id, pciide_promise_products));
    151  1.1  bouyer 
    152  1.1  bouyer }
    153  1.1  bouyer 
    154  1.1  bouyer /* Macros to test product */
    155  1.1  bouyer #define PDC_IS_262(sc)							\
    156  1.1  bouyer 	((sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA66 ||	\
    157  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100 ||	\
    158  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100X ||	\
    159  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100TX2 ||	\
    160  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100TX2v2 || \
    161  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133 ||	\
    162  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133TX2 ||	\
    163  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_MBULTRA133 || \
    164  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133TX2v2 || \
    165  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_FASTTRAK133LITE)
    166  1.1  bouyer #define PDC_IS_265(sc)							\
    167  1.1  bouyer 	((sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100 ||	\
    168  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100X ||	\
    169  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100TX2 ||	\
    170  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100TX2v2 || \
    171  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133 ||	\
    172  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133TX2 ||	\
    173  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_MBULTRA133 || \
    174  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133TX2v2 || \
    175  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_FASTTRAK133LITE)
    176  1.1  bouyer #define PDC_IS_268(sc)							\
    177  1.1  bouyer 	((sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100TX2 ||	\
    178  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100TX2v2 || \
    179  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133 ||	\
    180  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133TX2 ||	\
    181  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_MBULTRA133 || \
    182  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133TX2v2 || \
    183  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_FASTTRAK133LITE)
    184  1.1  bouyer #define PDC_IS_276(sc)							\
    185  1.1  bouyer 	((sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133 ||	\
    186  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133TX2 ||	\
    187  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_MBULTRA133 || \
    188  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA133TX2v2 || \
    189  1.1  bouyer 	(sc)->sc_pp->ide_product == PCI_PRODUCT_PROMISE_FASTTRAK133LITE)
    190  1.1  bouyer 
    191  1.1  bouyer void
    192  1.1  bouyer pdc202xx_chip_map(sc, pa)
    193  1.1  bouyer 	struct pciide_softc *sc;
    194  1.1  bouyer 	struct pci_attach_args *pa;
    195  1.1  bouyer {
    196  1.1  bouyer 	struct pciide_channel *cp;
    197  1.1  bouyer 	int channel;
    198  1.1  bouyer 	pcireg_t interface, st, mode;
    199  1.1  bouyer 	bus_size_t cmdsize, ctlsize;
    200  1.1  bouyer 
    201  1.1  bouyer 	if (!PDC_IS_268(sc)) {
    202  1.1  bouyer 		st = pci_conf_read(sc->sc_pc, sc->sc_tag, PDC2xx_STATE);
    203  1.1  bouyer 		WDCDEBUG_PRINT(("pdc202xx_setup_chip: controller state 0x%x\n",
    204  1.1  bouyer 		    st), DEBUG_PROBE);
    205  1.1  bouyer 	}
    206  1.1  bouyer 	if (pciide_chipen(sc, pa) == 0)
    207  1.1  bouyer 		return;
    208  1.1  bouyer 
    209  1.1  bouyer 	/* turn off  RAID mode */
    210  1.1  bouyer 	if (!PDC_IS_268(sc))
    211  1.1  bouyer 		st &= ~PDC2xx_STATE_IDERAID;
    212  1.1  bouyer 
    213  1.1  bouyer 	/*
    214  1.1  bouyer 	 * can't rely on the PCI_CLASS_REG content if the chip was in raid
    215  1.1  bouyer 	 * mode. We have to fake interface
    216  1.1  bouyer 	 */
    217  1.1  bouyer 	interface = PCIIDE_INTERFACE_SETTABLE(0) | PCIIDE_INTERFACE_SETTABLE(1);
    218  1.1  bouyer 	if (PDC_IS_268(sc) || (st & PDC2xx_STATE_NATIVE))
    219  1.1  bouyer 		interface |= PCIIDE_INTERFACE_PCI(0) | PCIIDE_INTERFACE_PCI(1);
    220  1.1  bouyer 
    221  1.1  bouyer 	aprint_normal("%s: bus-master DMA support present",
    222  1.1  bouyer 	    sc->sc_wdcdev.sc_dev.dv_xname);
    223  1.1  bouyer 	pciide_mapreg_dma(sc, pa);
    224  1.1  bouyer 	aprint_normal("\n");
    225  1.1  bouyer 	sc->sc_wdcdev.cap = WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32 |
    226  1.1  bouyer 	    WDC_CAPABILITY_MODE;
    227  1.1  bouyer 	if (sc->sc_dma_ok) {
    228  1.1  bouyer 		sc->sc_wdcdev.cap |= WDC_CAPABILITY_DMA | WDC_CAPABILITY_UDMA;
    229  1.1  bouyer 		sc->sc_wdcdev.cap |= WDC_CAPABILITY_IRQACK;
    230  1.1  bouyer 		sc->sc_wdcdev.irqack = pciide_irqack;
    231  1.1  bouyer 	}
    232  1.1  bouyer 	if (PCI_CLASS(pa->pa_class) == PCI_CLASS_MASS_STORAGE &&
    233  1.1  bouyer 	    PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_RAID)
    234  1.1  bouyer 		sc->sc_wdcdev.cap |= WDC_CAPABILITY_RAID;
    235  1.1  bouyer 	sc->sc_wdcdev.PIO_cap = 4;
    236  1.1  bouyer 	sc->sc_wdcdev.DMA_cap = 2;
    237  1.1  bouyer 	if (PDC_IS_276(sc))
    238  1.1  bouyer 		sc->sc_wdcdev.UDMA_cap = 6;
    239  1.1  bouyer 	else if (PDC_IS_265(sc))
    240  1.1  bouyer 		sc->sc_wdcdev.UDMA_cap = 5;
    241  1.1  bouyer 	else if (PDC_IS_262(sc))
    242  1.1  bouyer 		sc->sc_wdcdev.UDMA_cap = 4;
    243  1.1  bouyer 	else
    244  1.1  bouyer 		sc->sc_wdcdev.UDMA_cap = 2;
    245  1.1  bouyer 	sc->sc_wdcdev.set_modes = PDC_IS_268(sc) ?
    246  1.1  bouyer 			pdc20268_setup_channel : pdc202xx_setup_channel;
    247  1.1  bouyer 	sc->sc_wdcdev.channels = sc->wdc_chanarray;
    248  1.1  bouyer 	sc->sc_wdcdev.nchannels = PCIIDE_NUM_CHANNELS;
    249  1.1  bouyer 
    250  1.1  bouyer 	if (sc->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA66 ||
    251  1.1  bouyer 	    sc->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100 ||
    252  1.1  bouyer 	    sc->sc_pp->ide_product == PCI_PRODUCT_PROMISE_ULTRA100X) {
    253  1.1  bouyer 		sc->sc_wdcdev.dma_start = pdc20262_dma_start;
    254  1.1  bouyer 		sc->sc_wdcdev.dma_finish = pdc20262_dma_finish;
    255  1.1  bouyer 	}
    256  1.1  bouyer 
    257  1.1  bouyer 	if (!PDC_IS_268(sc)) {
    258  1.1  bouyer 		/* setup failsafe defaults */
    259  1.1  bouyer 		mode = 0;
    260  1.1  bouyer 		mode = PDC2xx_TIM_SET_PA(mode, pdc2xx_pa[0]);
    261  1.1  bouyer 		mode = PDC2xx_TIM_SET_PB(mode, pdc2xx_pb[0]);
    262  1.1  bouyer 		mode = PDC2xx_TIM_SET_MB(mode, pdc2xx_dma_mb[0]);
    263  1.1  bouyer 		mode = PDC2xx_TIM_SET_MC(mode, pdc2xx_dma_mc[0]);
    264  1.1  bouyer 		for (channel = 0;
    265  1.1  bouyer 		     channel < sc->sc_wdcdev.nchannels;
    266  1.1  bouyer 		     channel++) {
    267  1.1  bouyer 			WDCDEBUG_PRINT(("pdc202xx_setup_chip: channel %d "
    268  1.1  bouyer 			    "drive 0 initial timings  0x%x, now 0x%x\n",
    269  1.1  bouyer 			    channel, pci_conf_read(sc->sc_pc, sc->sc_tag,
    270  1.1  bouyer 			    PDC2xx_TIM(channel, 0)), mode | PDC2xx_TIM_IORDYp),
    271  1.1  bouyer 			    DEBUG_PROBE);
    272  1.1  bouyer 			pci_conf_write(sc->sc_pc, sc->sc_tag,
    273  1.1  bouyer 			    PDC2xx_TIM(channel, 0), mode | PDC2xx_TIM_IORDYp);
    274  1.1  bouyer 			WDCDEBUG_PRINT(("pdc202xx_setup_chip: channel %d "
    275  1.1  bouyer 			    "drive 1 initial timings  0x%x, now 0x%x\n",
    276  1.1  bouyer 			    channel, pci_conf_read(sc->sc_pc, sc->sc_tag,
    277  1.1  bouyer 			    PDC2xx_TIM(channel, 1)), mode), DEBUG_PROBE);
    278  1.1  bouyer 			pci_conf_write(sc->sc_pc, sc->sc_tag,
    279  1.1  bouyer 			    PDC2xx_TIM(channel, 1), mode);
    280  1.1  bouyer 		}
    281  1.1  bouyer 
    282  1.1  bouyer 		mode = PDC2xx_SCR_DMA;
    283  1.1  bouyer 		if (PDC_IS_265(sc)) {
    284  1.1  bouyer 			mode = PDC2xx_SCR_SET_GEN(mode, PDC265_SCR_GEN_LAT);
    285  1.1  bouyer 		} else if (PDC_IS_262(sc)) {
    286  1.1  bouyer 			mode = PDC2xx_SCR_SET_GEN(mode, PDC262_SCR_GEN_LAT);
    287  1.1  bouyer 		} else {
    288  1.1  bouyer 			/* the BIOS set it up this way */
    289  1.1  bouyer 			mode = PDC2xx_SCR_SET_GEN(mode, 0x1);
    290  1.1  bouyer 		}
    291  1.1  bouyer 		mode = PDC2xx_SCR_SET_I2C(mode, 0x3); /* ditto */
    292  1.1  bouyer 		mode = PDC2xx_SCR_SET_POLL(mode, 0x1); /* ditto */
    293  1.1  bouyer 		WDCDEBUG_PRINT(("pdc202xx_setup_chip: initial SCR  0x%x, "
    294  1.1  bouyer 		    "now 0x%x\n",
    295  1.1  bouyer 		    bus_space_read_4(sc->sc_dma_iot, sc->sc_dma_ioh,
    296  1.1  bouyer 			PDC2xx_SCR),
    297  1.1  bouyer 		    mode), DEBUG_PROBE);
    298  1.1  bouyer 		bus_space_write_4(sc->sc_dma_iot, sc->sc_dma_ioh,
    299  1.1  bouyer 		    PDC2xx_SCR, mode);
    300  1.1  bouyer 
    301  1.1  bouyer 		/* controller initial state register is OK even without BIOS */
    302  1.1  bouyer 		/* Set DMA mode to IDE DMA compatibility */
    303  1.1  bouyer 		mode =
    304  1.1  bouyer 		    bus_space_read_1(sc->sc_dma_iot, sc->sc_dma_ioh, PDC2xx_PM);
    305  1.1  bouyer 		WDCDEBUG_PRINT(("pdc202xx_setup_chip: primary mode 0x%x", mode),
    306  1.1  bouyer 		    DEBUG_PROBE);
    307  1.1  bouyer 		bus_space_write_1(sc->sc_dma_iot, sc->sc_dma_ioh, PDC2xx_PM,
    308  1.1  bouyer 		    mode | 0x1);
    309  1.1  bouyer 		mode =
    310  1.1  bouyer 		    bus_space_read_1(sc->sc_dma_iot, sc->sc_dma_ioh, PDC2xx_SM);
    311  1.1  bouyer 		WDCDEBUG_PRINT((", secondary mode 0x%x\n", mode ), DEBUG_PROBE);
    312  1.1  bouyer 		bus_space_write_1(sc->sc_dma_iot, sc->sc_dma_ioh, PDC2xx_SM,
    313  1.1  bouyer 		    mode | 0x1);
    314  1.1  bouyer 	}
    315  1.1  bouyer 
    316  1.1  bouyer 	for (channel = 0; channel < sc->sc_wdcdev.nchannels; channel++) {
    317  1.1  bouyer 		cp = &sc->pciide_channels[channel];
    318  1.1  bouyer 		if (pciide_chansetup(sc, channel, interface) == 0)
    319  1.1  bouyer 			continue;
    320  1.1  bouyer 		if (!PDC_IS_268(sc) && (st & (PDC_IS_262(sc) ?
    321  1.1  bouyer 		    PDC262_STATE_EN(channel):PDC246_STATE_EN(channel))) == 0) {
    322  1.1  bouyer 			aprint_normal("%s: %s channel ignored (disabled)\n",
    323  1.1  bouyer 			    sc->sc_wdcdev.sc_dev.dv_xname, cp->name);
    324  1.1  bouyer 			cp->wdc_channel.ch_flags |= WDCF_DISABLED;
    325  1.1  bouyer 			continue;
    326  1.1  bouyer 		}
    327  1.1  bouyer 		pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
    328  1.1  bouyer 		    PDC_IS_265(sc) ? pdc20265_pci_intr : pdc202xx_pci_intr);
    329  1.1  bouyer 	}
    330  1.1  bouyer 	if (!PDC_IS_268(sc)) {
    331  1.1  bouyer 		WDCDEBUG_PRINT(("pdc202xx_setup_chip: new controller state "
    332  1.1  bouyer 		    "0x%x\n", st), DEBUG_PROBE);
    333  1.1  bouyer 		pci_conf_write(sc->sc_pc, sc->sc_tag, PDC2xx_STATE, st);
    334  1.1  bouyer 	}
    335  1.1  bouyer 	return;
    336  1.1  bouyer }
    337  1.1  bouyer 
    338  1.1  bouyer void
    339  1.1  bouyer pdc202xx_setup_channel(chp)
    340  1.1  bouyer 	struct channel_softc *chp;
    341  1.1  bouyer {
    342  1.1  bouyer 	struct ata_drive_datas *drvp;
    343  1.1  bouyer 	int drive;
    344  1.1  bouyer 	pcireg_t mode, st;
    345  1.1  bouyer 	u_int32_t idedma_ctl, scr, atapi;
    346  1.1  bouyer 	struct pciide_channel *cp = (struct pciide_channel*)chp;
    347  1.1  bouyer 	struct pciide_softc *sc = (struct pciide_softc *)cp->wdc_channel.wdc;
    348  1.1  bouyer 	int channel = chp->channel;
    349  1.1  bouyer 
    350  1.1  bouyer 	/* setup DMA if needed */
    351  1.1  bouyer 	pciide_channel_dma_setup(cp);
    352  1.1  bouyer 
    353  1.1  bouyer 	idedma_ctl = 0;
    354  1.1  bouyer 	WDCDEBUG_PRINT(("pdc202xx_setup_channel %s: scr 0x%x\n",
    355  1.1  bouyer 	    sc->sc_wdcdev.sc_dev.dv_xname,
    356  1.1  bouyer 	    bus_space_read_1(sc->sc_dma_iot, sc->sc_dma_ioh, PDC262_U66)),
    357  1.1  bouyer 	    DEBUG_PROBE);
    358  1.1  bouyer 
    359  1.1  bouyer 	/* Per channel settings */
    360  1.1  bouyer 	if (PDC_IS_262(sc)) {
    361  1.1  bouyer 		scr = bus_space_read_1(sc->sc_dma_iot, sc->sc_dma_ioh,
    362  1.1  bouyer 		    PDC262_U66);
    363  1.1  bouyer 		st = pci_conf_read(sc->sc_pc, sc->sc_tag, PDC2xx_STATE);
    364  1.1  bouyer 		/* Trim UDMA mode */
    365  1.1  bouyer 		if ((st & PDC262_STATE_80P(channel)) != 0 ||
    366  1.1  bouyer 		    (chp->ch_drive[0].drive_flags & DRIVE_UDMA &&
    367  1.1  bouyer 		    chp->ch_drive[0].UDMA_mode <= 2) ||
    368  1.1  bouyer 		    (chp->ch_drive[1].drive_flags & DRIVE_UDMA &&
    369  1.1  bouyer 		    chp->ch_drive[1].UDMA_mode <= 2)) {
    370  1.1  bouyer 			if (chp->ch_drive[0].UDMA_mode > 2)
    371  1.1  bouyer 				chp->ch_drive[0].UDMA_mode = 2;
    372  1.1  bouyer 			if (chp->ch_drive[1].UDMA_mode > 2)
    373  1.1  bouyer 				chp->ch_drive[1].UDMA_mode = 2;
    374  1.1  bouyer 		}
    375  1.1  bouyer 		/* Set U66 if needed */
    376  1.1  bouyer 		if ((chp->ch_drive[0].drive_flags & DRIVE_UDMA &&
    377  1.1  bouyer 		    chp->ch_drive[0].UDMA_mode > 2) ||
    378  1.1  bouyer 		    (chp->ch_drive[1].drive_flags & DRIVE_UDMA &&
    379  1.1  bouyer 		    chp->ch_drive[1].UDMA_mode > 2))
    380  1.1  bouyer 			scr |= PDC262_U66_EN(channel);
    381  1.1  bouyer 		else
    382  1.1  bouyer 			scr &= ~PDC262_U66_EN(channel);
    383  1.1  bouyer 		bus_space_write_1(sc->sc_dma_iot, sc->sc_dma_ioh,
    384  1.1  bouyer 		    PDC262_U66, scr);
    385  1.1  bouyer 		WDCDEBUG_PRINT(("pdc202xx_setup_channel %s:%d: ATAPI 0x%x\n",
    386  1.1  bouyer 		    sc->sc_wdcdev.sc_dev.dv_xname, channel,
    387  1.1  bouyer 		    bus_space_read_4(sc->sc_dma_iot, sc->sc_dma_ioh,
    388  1.1  bouyer 		    PDC262_ATAPI(channel))), DEBUG_PROBE);
    389  1.1  bouyer 		if (chp->ch_drive[0].drive_flags & DRIVE_ATAPI ||
    390  1.1  bouyer 			chp->ch_drive[1].drive_flags & DRIVE_ATAPI) {
    391  1.1  bouyer 			if (((chp->ch_drive[0].drive_flags & DRIVE_UDMA) &&
    392  1.1  bouyer 			    !(chp->ch_drive[1].drive_flags & DRIVE_UDMA) &&
    393  1.1  bouyer 			    (chp->ch_drive[1].drive_flags & DRIVE_DMA)) ||
    394  1.1  bouyer 			    ((chp->ch_drive[1].drive_flags & DRIVE_UDMA) &&
    395  1.1  bouyer 			    !(chp->ch_drive[0].drive_flags & DRIVE_UDMA) &&
    396  1.1  bouyer 			    (chp->ch_drive[0].drive_flags & DRIVE_DMA)))
    397  1.1  bouyer 				atapi = 0;
    398  1.1  bouyer 			else
    399  1.1  bouyer 				atapi = PDC262_ATAPI_UDMA;
    400  1.1  bouyer 			bus_space_write_4(sc->sc_dma_iot, sc->sc_dma_ioh,
    401  1.1  bouyer 			    PDC262_ATAPI(channel), atapi);
    402  1.1  bouyer 		}
    403  1.1  bouyer 	}
    404  1.1  bouyer 	for (drive = 0; drive < 2; drive++) {
    405  1.1  bouyer 		drvp = &chp->ch_drive[drive];
    406  1.1  bouyer 		/* If no drive, skip */
    407  1.1  bouyer 		if ((drvp->drive_flags & DRIVE) == 0)
    408  1.1  bouyer 			continue;
    409  1.1  bouyer 		mode = 0;
    410  1.1  bouyer 		if (drvp->drive_flags & DRIVE_UDMA) {
    411  1.1  bouyer 			/* use Ultra/DMA */
    412  1.1  bouyer 			drvp->drive_flags &= ~DRIVE_DMA;
    413  1.1  bouyer 			mode = PDC2xx_TIM_SET_MB(mode,
    414  1.1  bouyer 			    pdc2xx_udma_mb[drvp->UDMA_mode]);
    415  1.1  bouyer 			mode = PDC2xx_TIM_SET_MC(mode,
    416  1.1  bouyer 			    pdc2xx_udma_mc[drvp->UDMA_mode]);
    417  1.1  bouyer 			idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
    418  1.1  bouyer 		} else if (drvp->drive_flags & DRIVE_DMA) {
    419  1.1  bouyer 			mode = PDC2xx_TIM_SET_MB(mode,
    420  1.1  bouyer 			    pdc2xx_dma_mb[drvp->DMA_mode]);
    421  1.1  bouyer 			mode = PDC2xx_TIM_SET_MC(mode,
    422  1.1  bouyer 			    pdc2xx_dma_mc[drvp->DMA_mode]);
    423  1.1  bouyer 			idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
    424  1.1  bouyer 		} else {
    425  1.1  bouyer 			mode = PDC2xx_TIM_SET_MB(mode,
    426  1.1  bouyer 			    pdc2xx_dma_mb[0]);
    427  1.1  bouyer 			mode = PDC2xx_TIM_SET_MC(mode,
    428  1.1  bouyer 			    pdc2xx_dma_mc[0]);
    429  1.1  bouyer 		}
    430  1.1  bouyer 		mode = PDC2xx_TIM_SET_PA(mode, pdc2xx_pa[drvp->PIO_mode]);
    431  1.1  bouyer 		mode = PDC2xx_TIM_SET_PB(mode, pdc2xx_pb[drvp->PIO_mode]);
    432  1.1  bouyer 		if (drvp->drive_flags & DRIVE_ATA)
    433  1.1  bouyer 			mode |= PDC2xx_TIM_PRE;
    434  1.1  bouyer 		mode |= PDC2xx_TIM_SYNC | PDC2xx_TIM_ERRDY;
    435  1.1  bouyer 		if (drvp->PIO_mode >= 3) {
    436  1.1  bouyer 			mode |= PDC2xx_TIM_IORDY;
    437  1.1  bouyer 			if (drive == 0)
    438  1.1  bouyer 				mode |= PDC2xx_TIM_IORDYp;
    439  1.1  bouyer 		}
    440  1.1  bouyer 		WDCDEBUG_PRINT(("pdc202xx_setup_channel: %s:%d:%d "
    441  1.1  bouyer 		    "timings 0x%x\n",
    442  1.1  bouyer 		    sc->sc_wdcdev.sc_dev.dv_xname,
    443  1.1  bouyer 		    chp->channel, drive, mode), DEBUG_PROBE);
    444  1.1  bouyer 		pci_conf_write(sc->sc_pc, sc->sc_tag,
    445  1.1  bouyer 		    PDC2xx_TIM(chp->channel, drive), mode);
    446  1.1  bouyer 	}
    447  1.1  bouyer 	if (idedma_ctl != 0) {
    448  1.1  bouyer 		/* Add software bits in status register */
    449  1.1  bouyer 		bus_space_write_1(sc->sc_dma_iot, sc->sc_dma_ioh,
    450  1.1  bouyer 		    IDEDMA_CTL + (IDEDMA_SCH_OFFSET * chp->channel),
    451  1.1  bouyer 		    idedma_ctl);
    452  1.1  bouyer 	}
    453  1.1  bouyer }
    454  1.1  bouyer 
    455  1.1  bouyer void
    456  1.1  bouyer pdc20268_setup_channel(chp)
    457  1.1  bouyer 	struct channel_softc *chp;
    458  1.1  bouyer {
    459  1.1  bouyer 	struct ata_drive_datas *drvp;
    460  1.1  bouyer 	int drive;
    461  1.1  bouyer 	u_int32_t idedma_ctl;
    462  1.1  bouyer 	struct pciide_channel *cp = (struct pciide_channel*)chp;
    463  1.1  bouyer 	struct pciide_softc *sc = (struct pciide_softc *)cp->wdc_channel.wdc;
    464  1.1  bouyer 	int u100;
    465  1.1  bouyer 
    466  1.1  bouyer 	/* setup DMA if needed */
    467  1.1  bouyer 	pciide_channel_dma_setup(cp);
    468  1.1  bouyer 
    469  1.1  bouyer 	idedma_ctl = 0;
    470  1.1  bouyer 
    471  1.1  bouyer 	/* I don't know what this is for, FreeBSD does it ... */
    472  1.1  bouyer 	bus_space_write_1(sc->sc_dma_iot, sc->sc_dma_ioh,
    473  1.1  bouyer 	    IDEDMA_CMD + 0x1 + IDEDMA_SCH_OFFSET * chp->channel, 0x0b);
    474  1.1  bouyer 
    475  1.1  bouyer 	/*
    476  1.1  bouyer 	 * cable type detect, from FreeBSD
    477  1.1  bouyer 	 */
    478  1.1  bouyer 	u100 = (bus_space_read_1(sc->sc_dma_iot, sc->sc_dma_ioh,
    479  1.1  bouyer 	    IDEDMA_CMD + 0x3 + IDEDMA_SCH_OFFSET * chp->channel) & 0x04) ?
    480  1.1  bouyer 	    0 : 1;
    481  1.1  bouyer 
    482  1.1  bouyer 	for (drive = 0; drive < 2; drive++) {
    483  1.1  bouyer 		drvp = &chp->ch_drive[drive];
    484  1.1  bouyer 		/* If no drive, skip */
    485  1.1  bouyer 		if ((drvp->drive_flags & DRIVE) == 0)
    486  1.1  bouyer 			continue;
    487  1.1  bouyer 		if (drvp->drive_flags & DRIVE_UDMA) {
    488  1.1  bouyer 			/* use Ultra/DMA */
    489  1.1  bouyer 			drvp->drive_flags &= ~DRIVE_DMA;
    490  1.1  bouyer 			idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
    491  1.1  bouyer 			if (drvp->UDMA_mode > 2 && u100 == 0)
    492  1.1  bouyer 				drvp->UDMA_mode = 2;
    493  1.1  bouyer 		} else if (drvp->drive_flags & DRIVE_DMA) {
    494  1.1  bouyer 			idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
    495  1.1  bouyer 		}
    496  1.1  bouyer 	}
    497  1.1  bouyer 	/* nothing to do to setup modes, the controller snoop SET_FEATURE cmd */
    498  1.1  bouyer 	if (idedma_ctl != 0) {
    499  1.1  bouyer 		/* Add software bits in status register */
    500  1.1  bouyer 		bus_space_write_1(sc->sc_dma_iot, sc->sc_dma_ioh,
    501  1.1  bouyer 		    IDEDMA_CTL + (IDEDMA_SCH_OFFSET * chp->channel),
    502  1.1  bouyer 		    idedma_ctl);
    503  1.1  bouyer 	}
    504  1.1  bouyer }
    505  1.1  bouyer 
    506  1.1  bouyer int
    507  1.1  bouyer pdc202xx_pci_intr(arg)
    508  1.1  bouyer 	void *arg;
    509  1.1  bouyer {
    510  1.1  bouyer 	struct pciide_softc *sc = arg;
    511  1.1  bouyer 	struct pciide_channel *cp;
    512  1.1  bouyer 	struct channel_softc *wdc_cp;
    513  1.1  bouyer 	int i, rv, crv;
    514  1.1  bouyer 	u_int32_t scr;
    515  1.1  bouyer 
    516  1.1  bouyer 	rv = 0;
    517  1.1  bouyer 	scr = bus_space_read_4(sc->sc_dma_iot, sc->sc_dma_ioh, PDC2xx_SCR);
    518  1.1  bouyer 	for (i = 0; i < sc->sc_wdcdev.nchannels; i++) {
    519  1.1  bouyer 		cp = &sc->pciide_channels[i];
    520  1.1  bouyer 		wdc_cp = &cp->wdc_channel;
    521  1.1  bouyer 		/* If a compat channel skip. */
    522  1.1  bouyer 		if (cp->compat)
    523  1.1  bouyer 			continue;
    524  1.1  bouyer 		if (scr & PDC2xx_SCR_INT(i)) {
    525  1.1  bouyer 			crv = wdcintr(wdc_cp);
    526  1.1  bouyer 			if (crv == 0)
    527  1.1  bouyer 				printf("%s:%d: bogus intr (reg 0x%x)\n",
    528  1.1  bouyer 				    sc->sc_wdcdev.sc_dev.dv_xname, i, scr);
    529  1.1  bouyer 			else
    530  1.1  bouyer 				rv = 1;
    531  1.1  bouyer 		}
    532  1.1  bouyer 	}
    533  1.1  bouyer 	return rv;
    534  1.1  bouyer }
    535  1.1  bouyer 
    536  1.1  bouyer int
    537  1.1  bouyer pdc20265_pci_intr(arg)
    538  1.1  bouyer 	void *arg;
    539  1.1  bouyer {
    540  1.1  bouyer 	struct pciide_softc *sc = arg;
    541  1.1  bouyer 	struct pciide_channel *cp;
    542  1.1  bouyer 	struct channel_softc *wdc_cp;
    543  1.1  bouyer 	int i, rv, crv;
    544  1.1  bouyer 	u_int32_t dmastat;
    545  1.1  bouyer 
    546  1.1  bouyer 	rv = 0;
    547  1.1  bouyer 	for (i = 0; i < sc->sc_wdcdev.nchannels; i++) {
    548  1.1  bouyer 		cp = &sc->pciide_channels[i];
    549  1.1  bouyer 		wdc_cp = &cp->wdc_channel;
    550  1.1  bouyer 		/* If a compat channel skip. */
    551  1.1  bouyer 		if (cp->compat)
    552  1.1  bouyer 			continue;
    553  1.1  bouyer #if 0
    554  1.1  bouyer 		bus_space_write_1(sc->sc_dma_iot, sc->sc_dma_ioh, IDEDMA_CMD + 0x1 + IDEDMA_SCH_OFFSET * i, 0x0b);
    555  1.1  bouyer 		if ((bus_space_read_1(sc->sc_dma_iot, sc->sc_dma_ioh, IDEDMA_CMD + 0x3 + IDEDMA_SCH_OFFSET * i) & 0x20) == 0)
    556  1.1  bouyer 			continue;
    557  1.1  bouyer #endif
    558  1.1  bouyer 		/*
    559  1.1  bouyer 		 * The Ultra/100 seems to assert PDC2xx_SCR_INT * spuriously,
    560  1.1  bouyer 		 * however it asserts INT in IDEDMA_CTL even for non-DMA ops.
    561  1.1  bouyer 		 * So use it instead (requires 2 reg reads instead of 1,
    562  1.1  bouyer 		 * but we can't do it another way).
    563  1.1  bouyer 		 */
    564  1.1  bouyer 		dmastat = bus_space_read_1(sc->sc_dma_iot,
    565  1.1  bouyer 		    sc->sc_dma_ioh, IDEDMA_CTL + IDEDMA_SCH_OFFSET * i);
    566  1.1  bouyer 		if((dmastat & IDEDMA_CTL_INTR) == 0)
    567  1.1  bouyer 			continue;
    568  1.1  bouyer 		crv = wdcintr(wdc_cp);
    569  1.1  bouyer 		if (crv == 0)
    570  1.1  bouyer 			printf("%s:%d: bogus intr\n",
    571  1.1  bouyer 			    sc->sc_wdcdev.sc_dev.dv_xname, i);
    572  1.1  bouyer 		else
    573  1.1  bouyer 			rv = 1;
    574  1.1  bouyer 	}
    575  1.1  bouyer 	return rv;
    576  1.1  bouyer }
    577  1.1  bouyer 
    578  1.1  bouyer static void
    579  1.1  bouyer pdc20262_dma_start(v, channel, drive)
    580  1.1  bouyer 	void *v;
    581  1.1  bouyer 	int channel, drive;
    582  1.1  bouyer {
    583  1.1  bouyer 	struct pciide_softc *sc = v;
    584  1.1  bouyer 	struct pciide_dma_maps *dma_maps =
    585  1.1  bouyer 	    &sc->pciide_channels[channel].dma_maps[drive];
    586  1.1  bouyer 	int atapi;
    587  1.1  bouyer 
    588  1.1  bouyer 	if (dma_maps->dma_flags & WDC_DMA_LBA48) {
    589  1.1  bouyer 		atapi = (dma_maps->dma_flags & WDC_DMA_READ) ?
    590  1.1  bouyer 		    PDC262_ATAPI_LBA48_READ : PDC262_ATAPI_LBA48_WRITE;
    591  1.1  bouyer 		atapi |= dma_maps->dmamap_xfer->dm_mapsize >> 1;
    592  1.1  bouyer 		bus_space_write_4(sc->sc_dma_iot, sc->sc_dma_ioh,
    593  1.1  bouyer 		    PDC262_ATAPI(channel), atapi);
    594  1.1  bouyer 	}
    595  1.1  bouyer 
    596  1.1  bouyer 	pciide_dma_start(v, channel, drive);
    597  1.1  bouyer }
    598  1.1  bouyer 
    599  1.1  bouyer int
    600  1.1  bouyer pdc20262_dma_finish(v, channel, drive, force)
    601  1.1  bouyer 	void *v;
    602  1.1  bouyer 	int channel, drive;
    603  1.1  bouyer 	int force;
    604  1.1  bouyer {
    605  1.1  bouyer 	struct pciide_softc *sc = v;
    606  1.1  bouyer 	struct pciide_dma_maps *dma_maps =
    607  1.1  bouyer 	    &sc->pciide_channels[channel].dma_maps[drive];
    608  1.1  bouyer 	struct channel_softc *chp;
    609  1.1  bouyer 	int atapi, error;
    610  1.1  bouyer 
    611  1.1  bouyer 	error = pciide_dma_finish(v, channel, drive, force);
    612  1.1  bouyer 
    613  1.1  bouyer 	if (dma_maps->dma_flags & WDC_DMA_LBA48) {
    614  1.1  bouyer 		chp = sc->wdc_chanarray[channel];
    615  1.1  bouyer 		atapi = 0;
    616  1.1  bouyer 		if (chp->ch_drive[0].drive_flags & DRIVE_ATAPI ||
    617  1.1  bouyer 		    chp->ch_drive[1].drive_flags & DRIVE_ATAPI) {
    618  1.1  bouyer 			if ((!(chp->ch_drive[0].drive_flags & DRIVE_UDMA) ||
    619  1.1  bouyer 			    (chp->ch_drive[1].drive_flags & DRIVE_UDMA) ||
    620  1.1  bouyer 			    !(chp->ch_drive[1].drive_flags & DRIVE_DMA)) &&
    621  1.1  bouyer 			    (!(chp->ch_drive[1].drive_flags & DRIVE_UDMA) ||
    622  1.1  bouyer 			    (chp->ch_drive[0].drive_flags & DRIVE_UDMA) ||
    623  1.1  bouyer 			    !(chp->ch_drive[0].drive_flags & DRIVE_DMA)))
    624  1.1  bouyer 				atapi = PDC262_ATAPI_UDMA;
    625  1.1  bouyer 		}
    626  1.1  bouyer 		bus_space_write_4(sc->sc_dma_iot, sc->sc_dma_ioh,
    627  1.1  bouyer 		    PDC262_ATAPI(channel), atapi);
    628  1.1  bouyer 	}
    629  1.1  bouyer 
    630  1.1  bouyer 	return error;
    631  1.1  bouyer }
    632