Home | History | Annotate | Line # | Download | only in pci
pciide.c revision 1.215
      1  1.215  christos /*	$NetBSD: pciide.c,v 1.215 2006/11/16 01:33:09 christos Exp $	*/
      2   1.41    bouyer 
      3   1.41    bouyer 
      4   1.41    bouyer /*
      5  1.113    bouyer  * Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
      6   1.41    bouyer  *
      7   1.41    bouyer  * Redistribution and use in source and binary forms, with or without
      8   1.41    bouyer  * modification, are permitted provided that the following conditions
      9   1.41    bouyer  * are met:
     10   1.41    bouyer  * 1. Redistributions of source code must retain the above copyright
     11   1.41    bouyer  *    notice, this list of conditions and the following disclaimer.
     12   1.41    bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.41    bouyer  *    notice, this list of conditions and the following disclaimer in the
     14   1.41    bouyer  *    documentation and/or other materials provided with the distribution.
     15   1.41    bouyer  * 3. All advertising materials mentioning features or use of this software
     16   1.41    bouyer  *    must display the following acknowledgement:
     17  1.151    bouyer  *	This product includes software developed by Manuel Bouyer.
     18  1.207    bouyer  * 4. The name of the author may not be used to endorse or promote products
     19  1.207    bouyer  *    derived from this software without specific prior written permission.
     20   1.41    bouyer  *
     21   1.58    bouyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22   1.58    bouyer  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23   1.58    bouyer  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.212     perry  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25   1.58    bouyer  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26   1.58    bouyer  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27   1.58    bouyer  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28   1.58    bouyer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29   1.58    bouyer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30   1.58    bouyer  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31   1.41    bouyer  *
     32   1.41    bouyer  */
     33   1.41    bouyer 
     34    1.1       cgd 
     35    1.1       cgd /*
     36    1.1       cgd  * Copyright (c) 1996, 1998 Christopher G. Demetriou.  All rights reserved.
     37    1.1       cgd  *
     38    1.1       cgd  * Redistribution and use in source and binary forms, with or without
     39    1.1       cgd  * modification, are permitted provided that the following conditions
     40    1.1       cgd  * are met:
     41    1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     42    1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     43    1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     44    1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     45    1.1       cgd  *    documentation and/or other materials provided with the distribution.
     46    1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     47    1.1       cgd  *    must display the following acknowledgement:
     48    1.1       cgd  *      This product includes software developed by Christopher G. Demetriou
     49    1.1       cgd  *	for the NetBSD Project.
     50    1.1       cgd  * 4. The name of the author may not be used to endorse or promote products
     51    1.1       cgd  *    derived from this software without specific prior written permission
     52    1.1       cgd  *
     53    1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     54    1.1       cgd  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     55    1.1       cgd  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     56    1.1       cgd  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     57    1.1       cgd  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     58    1.1       cgd  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     59    1.1       cgd  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     60    1.1       cgd  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     61    1.1       cgd  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     62    1.1       cgd  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     63    1.1       cgd  */
     64    1.1       cgd 
     65    1.1       cgd /*
     66    1.1       cgd  * PCI IDE controller driver.
     67    1.1       cgd  *
     68    1.1       cgd  * Author: Christopher G. Demetriou, March 2, 1998 (derived from NetBSD
     69    1.1       cgd  * sys/dev/pci/ppb.c, revision 1.16).
     70    1.1       cgd  *
     71    1.2       cgd  * See "PCI IDE Controller Specification, Revision 1.0 3/4/94" and
     72    1.2       cgd  * "Programming Interface for Bus Master IDE Controller, Revision 1.0
     73    1.2       cgd  * 5/16/94" from the PCI SIG.
     74    1.1       cgd  *
     75    1.1       cgd  */
     76  1.134     lukem 
     77  1.134     lukem #include <sys/cdefs.h>
     78  1.215  christos __KERNEL_RCSID(0, "$NetBSD: pciide.c,v 1.215 2006/11/16 01:33:09 christos Exp $");
     79    1.1       cgd 
     80    1.1       cgd #include <sys/param.h>
     81    1.9    bouyer 
     82    1.1       cgd #include <dev/pci/pcivar.h>
     83    1.1       cgd #include <dev/pci/pciidereg.h>
     84    1.1       cgd #include <dev/pci/pciidevar.h>
     85   1.13    bouyer 
     86  1.211     perry int	pciide_match(struct device *, struct cfdata *, void *);
     87  1.211     perry void	pciide_attach(struct device *, struct device *, void *);
     88    1.1       cgd 
     89  1.172   thorpej CFATTACH_DECL(pciide, sizeof(struct pciide_softc),
     90  1.173   thorpej     pciide_match, pciide_attach, NULL, NULL);
     91  1.172   thorpej 
     92    1.1       cgd int
     93  1.215  christos pciide_match(struct device *parent, struct cfdata *match,
     94  1.214  christos     void *aux)
     95    1.1       cgd {
     96    1.1       cgd 	struct pci_attach_args *pa = aux;
     97    1.1       cgd 
     98    1.1       cgd 	/*
     99    1.1       cgd 	 * Check the ID register to see that it's a PCI IDE controller.
    100    1.1       cgd 	 * If it is, we assume that we can deal with it; it _should_
    101    1.1       cgd 	 * work in a standardized way...
    102    1.1       cgd 	 */
    103    1.1       cgd 	if (PCI_CLASS(pa->pa_class) == PCI_CLASS_MASS_STORAGE &&
    104    1.1       cgd 	    PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_IDE) {
    105    1.1       cgd 		return (1);
    106    1.1       cgd 	}
    107    1.1       cgd 
    108    1.1       cgd 	return (0);
    109    1.1       cgd }
    110    1.1       cgd 
    111    1.1       cgd void
    112  1.215  christos pciide_attach(struct device *parent, struct device *self, void *aux)
    113    1.1       cgd {
    114    1.1       cgd 	struct pci_attach_args *pa = aux;
    115    1.1       cgd 	struct pciide_softc *sc = (struct pciide_softc *)self;
    116  1.210     enami 
    117  1.209    bouyer 	pciide_common_attach(sc, pa, NULL);
    118    1.1       cgd }
    119