Home | History | Annotate | Line # | Download | only in pci
pciide.c revision 1.217.2.1
      1  1.217.2.1  uebayasi /*	$NetBSD: pciide.c,v 1.217.2.1 2010/11/06 08:08:31 uebayasi 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.217.2.1  uebayasi __KERNEL_RCSID(0, "$NetBSD: pciide.c,v 1.217.2.1 2010/11/06 08:08:31 uebayasi 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.217.2.1  uebayasi static int	pciide_match(device_t, cfdata_t, void *);
     82  1.217.2.1  uebayasi static void	pciide_attach(device_t, device_t, void *);
     83  1.217.2.1  uebayasi static int	pciide_detach(device_t, int);
     84        1.1       cgd 
     85      1.216      cube CFATTACH_DECL_NEW(pciide, sizeof(struct pciide_softc),
     86  1.217.2.1  uebayasi     pciide_match, pciide_attach, pciide_detach, NULL);
     87      1.172   thorpej 
     88  1.217.2.1  uebayasi static int
     89      1.216      cube pciide_match(device_t parent, cfdata_t match, void *aux)
     90        1.1       cgd {
     91        1.1       cgd 	struct pci_attach_args *pa = aux;
     92        1.1       cgd 
     93        1.1       cgd 	/*
     94        1.1       cgd 	 * Check the ID register to see that it's a PCI IDE controller.
     95        1.1       cgd 	 * If it is, we assume that we can deal with it; it _should_
     96        1.1       cgd 	 * work in a standardized way...
     97        1.1       cgd 	 */
     98        1.1       cgd 	if (PCI_CLASS(pa->pa_class) == PCI_CLASS_MASS_STORAGE &&
     99        1.1       cgd 	    PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_IDE) {
    100        1.1       cgd 		return (1);
    101        1.1       cgd 	}
    102        1.1       cgd 
    103        1.1       cgd 	return (0);
    104        1.1       cgd }
    105        1.1       cgd 
    106  1.217.2.1  uebayasi static void
    107      1.216      cube pciide_attach(device_t parent, device_t self, void *aux)
    108        1.1       cgd {
    109        1.1       cgd 	struct pci_attach_args *pa = aux;
    110      1.216      cube 	struct pciide_softc *sc = device_private(self);
    111      1.216      cube 
    112      1.216      cube 	sc->sc_wdcdev.sc_atac.atac_dev = self;
    113      1.210     enami 
    114      1.209    bouyer 	pciide_common_attach(sc, pa, NULL);
    115        1.1       cgd }
    116  1.217.2.1  uebayasi 
    117  1.217.2.1  uebayasi static int
    118  1.217.2.1  uebayasi pciide_detach(device_t self, int flags)
    119  1.217.2.1  uebayasi {
    120  1.217.2.1  uebayasi 	struct pciide_softc *sc = device_private(self);
    121  1.217.2.1  uebayasi 	int ret;
    122  1.217.2.1  uebayasi 
    123  1.217.2.1  uebayasi 	ret = pciide_common_detach(sc, flags);
    124  1.217.2.1  uebayasi 
    125  1.217.2.1  uebayasi 	if (ret != 0)
    126  1.217.2.1  uebayasi 		return ret;
    127  1.217.2.1  uebayasi 
    128  1.217.2.1  uebayasi 	pci_intr_disestablish(sc->sc_pc, sc->sc_pci_ih);
    129  1.217.2.1  uebayasi 
    130  1.217.2.1  uebayasi 	return ret;
    131  1.217.2.1  uebayasi }
    132