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