Add PCCARD match routines sio and the disk drivers.
authorJoerg Sonnenberger <joerg@dragonflybsd.org>
Thu, 19 Feb 2004 15:48:26 +0000 (15:48 +0000)
committerJoerg Sonnenberger <joerg@dragonflybsd.org>
Thu, 19 Feb 2004 15:48:26 +0000 (15:48 +0000)
Partly taken from FreeBSD.

sys/conf/files.i386
sys/dev/disk/aic/aic_pccard.c
sys/dev/disk/fd/fd_pccard.c
sys/dev/disk/ncv/ncr53c500_pccard.c
sys/dev/disk/nsp/nsp_pccard.c
sys/dev/disk/stg/tmc18c30_pccard.c
sys/dev/serial/sio/sio_pccard.c

index c1d9b65..4665a06 100644 (file)
@@ -2,7 +2,7 @@
 # files marked standard are always included.
 #
 # $FreeBSD: src/sys/conf/files.i386,v 1.307.2.38 2003/01/02 20:41:33 kan Exp $
-# $DragonFly: src/sys/conf/Attic/files.i386,v 1.17 2004/02/17 19:38:53 dillon Exp $
+# $DragonFly: src/sys/conf/Attic/files.i386,v 1.18 2004/02/19 15:48:26 joerg Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -250,7 +250,7 @@ dev/serial/cy/cy.c                  optional        cy
 dev/netif/elink_layer/elink.c          optional        ep
 dev/netif/elink_layer/elink.c          optional        ie
 dev/disk/fd/fd.c                       optional        fd
-dev/disk/fd/fd_pccard.c                        optional        fd card
+dev/disk/fd/fd_pccard.c                        optional        fd pccard
 dev/misc/gpib/gpib.c                   optional        gp
 dev/video/gsc/gsc.c                    optional        gsc
 dev/netif/cx/if_cx.c                   optional        cx
@@ -476,7 +476,7 @@ dev/misc/atkbdc_layer/atkbdc_isa.c  optional        atkbdc
 dev/misc/ppc/ppc.c                     optional        ppc
 dev/misc/psm/psm.c                     optional        psm
 dev/serial/sio/sio.c                   optional        sio
-dev/serial/sio/sio_pccard.c            optional        sio card
+dev/serial/sio/sio_pccard.c            optional        sio pccard
 bus/isa/syscons_isa.c                  optional        sc
 bus/isa/vga_isa.c                      optional        vga
 kern/md4c.c                            optional        netsmb
index a9465ca..f5955e5 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/aic/aic_pccard.c,v 1.1 2000/01/14 23:42:36 imp Exp $
- * $DragonFly: src/sys/dev/disk/aic/aic_pccard.c,v 1.4 2003/08/27 10:35:16 rob Exp $
+ * $DragonFly: src/sys/dev/disk/aic/aic_pccard.c,v 1.5 2004/02/19 15:48:26 joerg Exp $
  */
 
 #include <sys/param.h>
 #include "aic6360reg.h"
 #include "aicvar.h"
 
+#include <bus/pccard/pccardvar.h>
+#include <bus/pccard/pccarddevs.h>
+
+#include "card_if.h"
+
 struct aic_pccard_softc {
        struct  aic_softc sc_aic;
        struct  resource *sc_port;
@@ -50,9 +55,19 @@ struct aic_pccard_softc {
 
 static int aic_pccard_alloc_resources (device_t);
 static void aic_pccard_release_resources (device_t);
+static int aic_pccard_match(device_t);
 static int aic_pccard_probe (device_t);
 static int aic_pccard_attach (device_t);
 
+static const struct pccard_product aic_pccard_products[] = {
+       PCMCIA_CARD(ADAPTEC, APA1460, 0),
+       PCMCIA_CARD(ADAPTEC, APA1460A, 0),
+       PCMCIA_CARD(NEWMEDIA, BUSTOASTER, 0),
+       PCMCIA_CARD(NEWMEDIA, BUSTOASTER2, 0),
+       PCMCIA_CARD(NEWMEDIA, BUSTOASTER3, 0),
+       { NULL }
+};
+
 #define        AIC_PCCARD_PORTSIZE 0x20
 
 static int
@@ -95,6 +110,20 @@ aic_pccard_release_resources(device_t dev)
        sc->sc_port = sc->sc_irq = 0;
 }
 
+static int
+aic_pccard_match(device_t dev)
+{
+       const struct pccard_product *pp;
+
+       if ((pp = pccard_product_lookup(dev, aic_pccard_products,
+           sizeof(aic_pccard_products[0]), NULL)) != NULL) {
+               if (pp->pp_name != NULL)
+                       device_set_desc(dev, pp->pp_name);
+               return 0;
+       }
+       return ENXIO;
+}
+
 static int
 aic_pccard_probe(device_t dev)
 {
@@ -167,9 +196,14 @@ aic_pccard_detach(device_t dev)
 
 static device_method_t aic_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         aic_pccard_probe),
-       DEVMETHOD(device_attach,        aic_pccard_attach),
+       DEVMETHOD(device_probe,         pccard_compat_probe),
+       DEVMETHOD(device_attach,        pccard_compat_attach),
        DEVMETHOD(device_detach,        aic_pccard_detach),
+
+       /* Card interface */
+       DEVMETHOD(card_compat_match,    aic_pccard_match),
+       DEVMETHOD(card_compat_probe,    aic_pccard_probe),
+       DEVMETHOD(card_compat_attach,   aic_pccard_attach),
        { 0, 0 }
 };
 
index bd39c6c..a56e1d4 100644 (file)
@@ -49,7 +49,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $DragonFly: src/sys/dev/disk/fd/fd_pccard.c,v 1.1 2004/01/11 16:45:16 joerg Exp $
+ * $DragonFly: src/sys/dev/disk/fd/fd_pccard.c,v 1.2 2004/02/19 15:48:26 joerg Exp $
  */
 
 #include <sys/param.h>
 #include "fdc.h"
 #include "fdreg.h"
 
+#include <bus/pccard/pccardvar.h>
+#include <bus/pccard/pccarddevs.h>
+
+#include "card_if.h"
+
+static const struct pccard_product fdc_products[] = {
+       PCMCIA_CARD(YEDATA, EXTERNAL_FDD, 0),
+       { NULL }
+};
+
 static void
 fdctl_wr_pcmcia(fdc_p fdc, u_int8_t v)
 {
        bus_space_write_1(fdc->portt, fdc->porth, FDCTL+fdc->port_off, v);
 }
 
+static int fdc_pccard_match(device_t dev)
+{
+       const struct pccard_product *pp;
+
+       if ((pp = pccard_product_lookup(dev, fdc_products,
+           sizeof(fdc_products[0]), NULL)) != NULL) {
+               device_set_desc(dev, pp->pp_name);
+               return (0);
+       }
+       return (ENXIO);
+}
+
 static int
 fdc_pccard_probe(device_t dev)
 {
@@ -99,7 +121,6 @@ fdc_pccard_probe(device_t dev)
                goto out;
        }
 
-       device_set_desc(dev, "Y-E Data PCMCIA floppy");
        fdc->fdct = FDC_NE765;
 
 out:
@@ -134,13 +155,19 @@ fdc_pccard_detach(device_t dev)
 
 static device_method_t fdc_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         fdc_pccard_probe),
-       DEVMETHOD(device_attach,        fdc_attach),
+       DEVMETHOD(device_probe,         pccard_compat_probe),
+       DEVMETHOD(device_attach,        pccard_compat_attach),
        DEVMETHOD(device_detach,        fdc_pccard_detach),
        DEVMETHOD(device_shutdown,      bus_generic_shutdown),
        DEVMETHOD(device_suspend,       bus_generic_suspend),
        DEVMETHOD(device_resume,        bus_generic_resume),
 
+       /* Card interface */
+       DEVMETHOD(card_compat_match,    fdc_pccard_match),
+       DEVMETHOD(card_compat_probe,    fdc_pccard_probe),
+       DEVMETHOD(card_compat_attach,   fdc_attach),
+       /* Device interface */
+
        /* Bus interface */
        DEVMETHOD(bus_print_child,      fdc_print_child),
        DEVMETHOD(bus_read_ivar,        fdc_read_ivar),
index a03dd4e..7626390 100644 (file)
@@ -1,5 +1,5 @@
 /*     $FreeBSD: src/sys/dev/ncv/ncr53c500_pccard.c,v 1.2.2.5 2001/12/17 13:30:18 non Exp $    */
-/*     $DragonFly: src/sys/dev/disk/ncv/ncr53c500_pccard.c,v 1.5 2004/02/12 00:00:14 dillon Exp $      */
+/*     $DragonFly: src/sys/dev/disk/ncv/ncr53c500_pccard.c,v 1.6 2004/02/19 15:48:26 joerg Exp $       */
 /*     $NecBSD: ncr53c500_pisa.c,v 1.28 1998/11/26 01:59:11 honda Exp $        */
 /*     $NetBSD$        */
 
@@ -54,6 +54,9 @@
 
 #include <sys/device_port.h>
 
+#include <bus/pccard/pccarddevs.h>
+#include <bus/pccard/pccardvar.h>
+
 #include <bus/cam/scsi/scsi_low.h>
 #include <bus/cam/scsi/scsi_low_pisa.h>
 
@@ -74,6 +77,24 @@ static int ncvattach(DEVPORT_PDEVICE devi);
 
 static void    ncv_card_unload (DEVPORT_PDEVICE);
 
+static const struct ncv_product {
+       struct pccard_product   prod;
+       int flags;
+} ncv_products[] = {
+       { PCMCIA_CARD(EPSON, SC200, 0), 0}, 
+       { PCMCIA_CARD(PANASONIC, KXLC002, 0), 0xb4d00000 }, 
+       { PCMCIA_CARD(PANASONIC, KXLC004, 0), 0xb4d00100 }, 
+       { PCMCIA_CARD(MACNICA, MPS100, 0), 0xb6250000 }, 
+       { PCMCIA_CARD(MACNICA, MPS110, 0), 0 }, 
+       { PCMCIA_CARD(NEC, PC9801N_J03R, 0), 0 }, 
+       { PCMCIA_CARD(NEWMEDIA, BASICS_SCSI, 0), 0 }, 
+       { PCMCIA_CARD(QLOGIC, PC05, 0), 0x84d00000 }, 
+#define FLAGS_REX5572 0x84d00000
+       { PCMCIA_CARD(RATOC, REX5572, 0), FLAGS_REX5572 }, 
+       { PCMCIA_CARD(RATOC, REX9530, 0), 0x84d00000 }, 
+       { { NULL }, 0 }
+};
+
 /*
  * Additional code for FreeBSD new-bus PCCard frontend
  */
@@ -183,6 +204,31 @@ ncv_alloc_resource(DEVPORT_PDEVICE dev)
        return(0);
 }
 
+static int ncv_pccard_match(device_t dev)
+{
+       const struct ncv_product *pp;
+       const char *vendorstr;
+       const char *prodstr;
+
+       if ((pp = (const struct ncv_product *) pccard_product_lookup(dev, 
+           (const struct pccard_product *) ncv_products,
+           sizeof(ncv_products[0]), NULL)) != NULL) {
+               if (pp->prod.pp_name != NULL)
+                       device_set_desc(dev, pp->prod.pp_name);
+               device_set_flags(dev, pp->flags);
+               return(0);
+       }
+       vendorstr = pccard_get_vendor_str(dev);
+       prodstr = pccard_get_product_str(dev);
+       if (strcmp(vendorstr, "RATOC System Inc.") == 0 &&
+               strncmp(prodstr, "SOUND/SCSI2 CARD", 16) == 0) {
+               device_set_desc(dev, "RATOC REX-5572");
+               device_set_flags(dev, FLAGS_REX5572);
+               return (0);
+       }
+       return(EIO);
+}
+
 static int
 ncv_pccard_probe(DEVPORT_PDEVICE dev)
 {
@@ -241,10 +287,15 @@ ncv_pccard_detach(DEVPORT_PDEVICE dev)
 
 static device_method_t ncv_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         ncv_pccard_probe),
-       DEVMETHOD(device_attach,        ncv_pccard_attach),
+       DEVMETHOD(device_probe,         pccard_compat_probe),
+       DEVMETHOD(device_attach,        pccard_compat_attach),
        DEVMETHOD(device_detach,        ncv_pccard_detach),
 
+       /* Card interface */
+       DEVMETHOD(card_compat_match,    ncv_pccard_match),
+       DEVMETHOD(card_compat_probe,    ncv_pccard_probe),
+       DEVMETHOD(card_compat_attach,   ncv_pccard_attach),
+
        { 0, 0 }
 };
 
index 250328d..42bb329 100644 (file)
@@ -1,5 +1,5 @@
 /*     $FreeBSD: src/sys/dev/nsp/nsp_pccard.c,v 1.2.2.6 2001/12/17 13:30:19 non Exp $  */
-/*     $DragonFly: src/sys/dev/disk/nsp/nsp_pccard.c,v 1.4 2003/08/27 10:35:17 rob Exp $       */
+/*     $DragonFly: src/sys/dev/disk/nsp/nsp_pccard.c,v 1.5 2004/02/19 15:48:26 joerg Exp $     */
 /*     $NecBSD: nsp_pisa.c,v 1.4 1999/04/15 01:35:54 kmatsuda Exp $    */
 /*     $NetBSD$        */
 
@@ -54,6 +54,9 @@
 
 #include <sys/device_port.h>
 
+#include <bus/pccard/pccarddevs.h>
+#include <bus/pccard/pccardvar.h>
+
 #include <bus/cam/scsi/scsi_low.h>
 #include <bus/cam/scsi/scsi_low_pisa.h>
 
@@ -77,6 +80,14 @@ static int nspattach(DEVPORT_PDEVICE devi);
 
 static void    nsp_card_unload (DEVPORT_PDEVICE);
 
+static const struct pccard_product nsp_products[] = {
+       PCMCIA_CARD(IODATA3, CBSC16, 0),
+       PCMCIA_CARD(PANASONIC, KME, 0),
+       PCMCIA_CARD(WORKBIT2, NINJA_SCSI3, 0),
+       PCMCIA_CARD(WORKBIT, ULTRA_NINJA_16, 0),
+       { NULL }
+};
+
 /*
  * Additional code for FreeBSD new-bus PCCard frontend
  */
@@ -166,6 +177,18 @@ nsp_alloc_resource(DEVPORT_PDEVICE dev)
        return(0);
 }
 
+static int nsp_pccard_match(device_t dev)
+{
+       const struct pccard_product *pp;
+
+       if ((pp = pccard_product_lookup(dev, nsp_products,
+           sizeof(nsp_products[0]), NULL)) != NULL) {
+               device_set_desc(dev, pp->pp_name);
+               return (0);
+       }
+       return (ENXIO);
+}
+
 static int
 nsp_pccard_probe(DEVPORT_PDEVICE dev)
 {
@@ -224,10 +247,15 @@ nsp_pccard_detach(DEVPORT_PDEVICE dev)
 
 static device_method_t nsp_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         nsp_pccard_probe),
-       DEVMETHOD(device_attach,        nsp_pccard_attach),
+       DEVMETHOD(device_probe,         pccard_compat_probe),
+       DEVMETHOD(device_attach,        pccard_compat_attach),
        DEVMETHOD(device_detach,        nsp_pccard_detach),
 
+       /* Card interface */
+       DEVMETHOD(card_compat_match,    nsp_pccard_match),
+       DEVMETHOD(card_compat_probe,    nsp_pccard_probe),
+       DEVMETHOD(card_compat_attach,   nsp_pccard_attach),
+
        { 0, 0 }
 };
 
index c1c1dc4..b2caf1f 100644 (file)
@@ -1,5 +1,5 @@
 /*     $FreeBSD: src/sys/dev/stg/tmc18c30_pccard.c,v 1.2.2.6 2001/12/17 13:30:19 non Exp $     */
-/*     $DragonFly: src/sys/dev/disk/stg/tmc18c30_pccard.c,v 1.5 2004/02/12 00:00:18 dillon Exp $       */
+/*     $DragonFly: src/sys/dev/disk/stg/tmc18c30_pccard.c,v 1.6 2004/02/19 15:48:26 joerg Exp $        */
 /*     $NecBSD: tmc18c30_pisa.c,v 1.22 1998/11/26 01:59:21 honda Exp $ */
 /*     $NetBSD$        */
 
@@ -56,6 +56,9 @@
 
 #include <sys/device_port.h>
 
+#include <bus/pccard/pccarddevs.h>
+#include <bus/pccard/pccardvar.h>
+
 #include <bus/cam/scsi/scsi_low.h>
 #include <bus/cam/scsi/scsi_low_pisa.h>
 
 #include       <bus/pccard/cardinfo.h>
 #include       <bus/pccard/slot.h>
 
+static const struct pccard_product stg_products[] = {
+       PCMCIA_CARD(FUTUREDOMAIN, SCSI2GO, 0),
+       PCMCIA_CARD(IBM, SCSICARD, 0),
+       PCMCIA_CARD(RATOC, REX5536, 0),
+       PCMCIA_CARD(RATOC, REX5536AM, 0),
+       PCMCIA_CARD(RATOC, REX5536M, 0),
+       { NULL }
+};
+
 static int     stgprobe(DEVPORT_PDEVICE devi);
 static int     stgattach(DEVPORT_PDEVICE devi);
 
@@ -78,6 +90,19 @@ static       void    stg_card_unload (DEVPORT_PDEVICE);
  * Additional code for FreeBSD new-bus PCCard frontend
  */
 
+static int stg_pccard_match(device_t dev)
+{
+       const struct pccard_product *pp;
+
+       if ((pp = pccard_product_lookup(dev, stg_products,
+           sizeof(stg_products[0]), NULL)) != NULL) {
+               if (pp->pp_name != NULL)
+                       device_set_desc(dev, pp->pp_name);
+               return(0);
+       }
+       return(EIO);
+}
+
 static void
 stg_pccard_intr(void * arg)
 {
@@ -216,10 +241,15 @@ stg_pccard_detach(DEVPORT_PDEVICE dev)
 
 static device_method_t stg_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         stg_pccard_probe),
-       DEVMETHOD(device_attach,        stg_pccard_attach),
+       DEVMETHOD(device_probe,         pccard_compat_probe),
+       DEVMETHOD(device_attach,        pccard_compat_attach),
        DEVMETHOD(device_detach,        stg_pccard_detach),
 
+       /* Card interface */
+       DEVMETHOD(card_compat_match,    stg_pccard_match),
+       DEVMETHOD(card_compat_probe,    stg_pccard_probe),
+       DEVMETHOD(card_compat_attach,   stg_pccard_attach),
+
        { 0, 0 }
 };
 
index 3a5cb7e..29bac0e 100644 (file)
@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $DragonFly: src/sys/dev/serial/sio/sio_pccard.c,v 1.1 2004/01/11 16:45:17 joerg Exp $
+ * $DragonFly: src/sys/dev/serial/sio/sio_pccard.c,v 1.2 2004/02/19 15:48:26 joerg Exp $
  */
 #include <sys/param.h>
 #include <sys/systm.h>
 #include "sioreg.h"
 #include "sio_private.h"
 
-static int     sio_pccard_attach (device_t dev);
-static int     sio_pccard_detach (device_t dev);
-static int     sio_pccard_probe (device_t dev);
+#include <bus/pccard/pccarddevs.h>
+#include <bus/pccard/pccardreg.h>
+#include <bus/pccard/pccardvar.h>
+
+static int     sio_pccard_attach(device_t dev);
+static int     sio_pccard_match(device_t self);
+static int     sio_pccard_detach(device_t dev);
+static int     sio_pccard_probe(device_t dev);
 
 static device_method_t sio_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         sio_pccard_probe),
-       DEVMETHOD(device_attach,        sio_pccard_attach),
+       DEVMETHOD(device_probe,         pccard_compat_probe),
+       DEVMETHOD(device_attach,        pccard_compat_attach),
        DEVMETHOD(device_detach,        sio_pccard_detach),
 
+       /* Card interface */
+       DEVMETHOD(card_compat_match,    sio_pccard_match),
+       DEVMETHOD(card_compat_probe,    sio_pccard_probe),
+       DEVMETHOD(card_compat_attach,   sio_pccard_attach),
+
        { 0, 0 }
 };
 
@@ -67,6 +77,26 @@ static driver_t sio_pccard_driver = {
        sizeof(struct com_s),
 };
 
+static int
+sio_pccard_match(device_t dev)
+{
+       int             error = 0;
+       u_int32_t       fcn = PCCARD_FUNCTION_UNSPEC;
+
+       fcn = pccard_get_function(dev);
+       if (error != 0)
+               return (error);
+       /*
+        * If a serial card, we are likely the right driver.  However,
+        * some serial cards are better servered by other drivers, so
+        * allow other drivers to claim it, if they want.
+        */
+       if (fcn == PCCARD_FUNCTION_SERIAL)
+               return (-100);
+
+       return(ENXIO);
+}
+
 static int
 sio_pccard_probe(dev)
        device_t        dev;