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