Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev add detach/activate routine



details:   https://anonhg.NetBSD.org/src/rev/200bfa715ea7
branches:  trunk
changeset: 520778:200bfa715ea7
user:      ichiro <ichiro%NetBSD.org@localhost>
date:      Wed Jan 16 02:11:20 2002 +0000

description:
add detach/activate routine

diffstat:

 sys/dev/cardbus/ahc_cardbus.c |  47 +++++++++++++++++++++++++++++++++++++++---
 sys/dev/ic/aic7xxx.c          |  46 ++++++++++++++++++++++++++++++++++++-----
 sys/dev/ic/aic7xxxvar.h       |   6 ++++-
 3 files changed, 88 insertions(+), 11 deletions(-)

diffs (204 lines):

diff -r 8f0262757c0f -r 200bfa715ea7 sys/dev/cardbus/ahc_cardbus.c
--- a/sys/dev/cardbus/ahc_cardbus.c     Wed Jan 16 01:47:36 2002 +0000
+++ b/sys/dev/cardbus/ahc_cardbus.c     Wed Jan 16 02:11:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahc_cardbus.c,v 1.5 2001/11/13 12:51:12 lukem Exp $    */
+/*     $NetBSD: ahc_cardbus.c,v 1.6 2002/01/16 02:11:22 ichiro Exp $   */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahc_cardbus.c,v 1.5 2001/11/13 12:51:12 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahc_cardbus.c,v 1.6 2002/01/16 02:11:22 ichiro Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -83,13 +83,16 @@
 
        int     sc_cbenable;            /* what CardBus access type to enable */
        int     sc_csr;                 /* CSR bits */
+       bus_size_t sc_size;
 };
 
 int    ahc_cardbus_match __P((struct device *, struct cfdata *, void *));
 void   ahc_cardbus_attach __P((struct device *, struct device *, void *));
+int    ahc_cardbus_detach __P((struct device *, int));
 
 struct cfattach ahc_cardbus_ca = {
        sizeof(struct ahc_cardbus_softc), ahc_cardbus_match, ahc_cardbus_attach,
+       ahc_cardbus_detach, ahc_activate
 };
 
 int
@@ -139,11 +142,11 @@
        csc->sc_csr = PCI_COMMAND_MASTER_ENABLE;
        if (Cardbus_mapreg_map(csc->sc_ct, AHC_CARDBUS_MMBA,
            PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT, 0,
-           &bst, &bsh, NULL, NULL) == 0) {
+           &bst, &bsh, NULL, &csc->sc_size) == 0) {
                csc->sc_cbenable = CARDBUS_MEM_ENABLE;
                csc->sc_csr |= PCI_COMMAND_MEM_ENABLE;
        } else if (Cardbus_mapreg_map(csc->sc_ct, AHC_CARDBUS_IOBA,
-           PCI_MAPREG_TYPE_IO, 0, &bst, &bsh, NULL, NULL) == 0) {
+           PCI_MAPREG_TYPE_IO, 0, &bst, &bsh, NULL, &csc->sc_size) == 0) {
                csc->sc_cbenable = CARDBUS_IO_ENABLE;
                csc->sc_csr |= PCI_COMMAND_IO_ENABLE;
        } else {
@@ -173,6 +176,9 @@
                cardbus_conf_write(cc, cf, ca->ca_tag, PCI_BHLC_REG, reg);
        }
 
+       ahc->tag = bst;
+       ahc->bsh = bsh;
+
        /*
         * ADP-1480 is always an AIC-7860.
         */
@@ -268,3 +274,36 @@
 
        ahc_attach(ahc);
 }
+
+int
+ahc_cardbus_detach(self, flags)
+       struct device *self;
+       int flags;
+{
+       struct ahc_cardbus_softc *csc = (void*)self;
+       struct ahc_softc *ahc = &csc->sc_ahc;
+
+       int rv;
+
+       rv = ahc_detach(ahc, flags);
+       if (rv)
+               return rv;
+
+       if (ahc->ih) {
+               cardbus_intr_disestablish(csc->sc_ct->ct_cc,
+                                         csc->sc_ct->ct_cf, ahc->ih);
+               ahc->ih = 0;
+       }
+
+       if (csc->sc_cbenable) {
+               if (csc->sc_cbenable == CARDBUS_MEM_ENABLE)
+                       Cardbus_mapreg_unmap(csc->sc_ct, AHC_CARDBUS_MMBA,
+                               ahc->tag, ahc->bsh, csc->sc_size);
+               else if (csc->sc_cbenable == CARDBUS_IO_ENABLE)
+                       Cardbus_mapreg_unmap(csc->sc_ct, AHC_CARDBUS_IOBA,
+                               ahc->tag, ahc->bsh, csc->sc_size);
+       csc->sc_cbenable = 0;
+       }
+
+       return (0);
+}
diff -r 8f0262757c0f -r 200bfa715ea7 sys/dev/ic/aic7xxx.c
--- a/sys/dev/ic/aic7xxx.c      Wed Jan 16 01:47:36 2002 +0000
+++ b/sys/dev/ic/aic7xxx.c      Wed Jan 16 02:11:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aic7xxx.c,v 1.85 2002/01/12 16:03:11 tsutsui Exp $     */
+/*     $NetBSD: aic7xxx.c,v 1.86 2002/01/16 02:11:20 ichiro Exp $      */
 
 /*
  * Generic driver for the aic7xxx based adaptec SCSI controllers
@@ -6,6 +6,7 @@
  * i386/eisa/ahc_eisa.c        27/284X and aic7770 motherboard controllers
  * pci/ahc_pci.c       3985, 3980, 3940, 2940, aic7895, aic7890,
  *                     aic7880, aic7870, aic7860, and aic7850 controllers
+ * cardbus/ahc_cardbus.c aic7860 cardbus controllers
  *
  * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000 Justin T. Gibbs.
  * All rights reserved.
@@ -87,7 +88,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aic7xxx.c,v 1.85 2002/01/12 16:03:11 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aic7xxx.c,v 1.86 2002/01/16 02:11:20 ichiro Exp $");
 
 #include "opt_ddb.h"
 #include "opt_ahc.h"
@@ -1407,17 +1408,50 @@
        }
 
        if ((ahc->flags & AHC_CHANNEL_B_PRIMARY) == 0) {
-               config_found((void *)ahc, &ahc->sc_channel, scsiprint);
+               ahc->child = config_found((void *)ahc, &ahc->sc_channel, scsiprint);
                if (ahc->features & AHC_TWIN)
-                       config_found((void *)ahc, &ahc->sc_channel_b,
+                       ahc->child = config_found((void *)ahc, &ahc->sc_channel_b,
                            scsiprint);
        } else {
-               config_found((void *)ahc, &ahc->sc_channel_b, scsiprint);
-               config_found((void *)ahc, &ahc->sc_channel, scsiprint);
+               ahc->child = config_found((void *)ahc, &ahc->sc_channel_b, scsiprint);
+               ahc->child = config_found((void *)ahc, &ahc->sc_channel, scsiprint);
        }
        return 1;
 }
 
+int
+ahc_detach(struct ahc_softc *ahc, int flags)
+{
+       int rv = 0;
+
+       if (ahc->child != NULL)
+               rv = config_detach(ahc->child, flags);
+        
+        return (rv);
+}
+
+int
+ahc_activate(struct device *self, enum devact act)
+{
+       struct ahc_softc *ahc = (void *) self;
+       int s, rv = 0;
+
+       s = splhigh();
+       switch (act) {
+       case DVACT_ACTIVATE:
+               rv = EOPNOTSUPP;
+               break;
+
+       case DVACT_DEACTIVATE:
+               if (ahc->child != NULL)
+                       rv = config_deactivate(ahc->child);
+               break;
+       }
+       splx(s);
+
+       return (rv);
+}
+
 static void
 ahc_fetch_devinfo(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
 {
diff -r 8f0262757c0f -r 200bfa715ea7 sys/dev/ic/aic7xxxvar.h
--- a/sys/dev/ic/aic7xxxvar.h   Wed Jan 16 01:47:36 2002 +0000
+++ b/sys/dev/ic/aic7xxxvar.h   Wed Jan 16 02:11:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aic7xxxvar.h,v 1.29 2001/07/04 20:34:03 wiz Exp $      */
+/*     $NetBSD: aic7xxxvar.h,v 1.30 2002/01/16 02:11:21 ichiro Exp $   */
 
 /*
  * Interface to the generic driver for the aic7xxx based adaptec
@@ -522,6 +522,8 @@
        u_int8_t                inited_targets[16];
        u_int8_t                inited_channels[2];
 
+       struct device           *child;
+
        /*
         * SCBs that have been send to the controller
         */
@@ -659,6 +661,8 @@
 int    ahc_probe_scbs(struct ahc_softc *);
 int    ahc_init(struct ahc_softc *);
 int    ahc_attach(struct ahc_softc *);
+int    ahc_detach(struct ahc_softc *, int);
+int    ahc_activate(struct device *, enum devact);
 int    ahc_intr(void *arg);
 
 /*



Home | Main Index | Thread Index | Old Index