Add proper match routines for PCCARD nics.
authorJoerg Sonnenberger <joerg@dragonflybsd.org>
Thu, 19 Feb 2004 14:31:13 +0000 (14:31 +0000)
committerJoerg Sonnenberger <joerg@dragonflybsd.org>
Thu, 19 Feb 2004 14:31:13 +0000 (14:31 +0000)
IDs and match routines taken from FreeBSD.

sys/dev/netif/an/Makefile
sys/dev/netif/an/if_an_pccard.c
sys/dev/netif/awi/if_awi_pccard.c
sys/dev/netif/cs/if_cs_pccard.c
sys/dev/netif/ep/if_ep_pccard.c
sys/dev/netif/ex/if_ex_pccard.c
sys/dev/netif/fe/if_fe_pccard.c
sys/dev/netif/sn/if_sn_pccard.c

index d19d11b..1605187 100644 (file)
@@ -1,10 +1,10 @@
 # $FreeBSD: src/sys/modules/an/Makefile,v 1.2 2000/01/28 11:26:26 bde Exp $
-# $DragonFly: src/sys/dev/netif/an/Makefile,v 1.2 2003/06/17 04:28:43 dillon Exp $
+# $DragonFly: src/sys/dev/netif/an/Makefile,v 1.3 2004/02/19 14:31:12 joerg Exp $
 
 .PATH: ${.CURDIR}/../../dev/an
 KMOD   = if_an
 SRCS   = if_an.c if_an_pccard.c if_an_pci.c if_an_isa.c
-SRCS   += opt_inet.h device_if.h bus_if.h pci_if.h isa_if.h
+SRCS   += opt_inet.h device_if.h bus_if.h pci_if.h isa_if.h card_if.h
 
 opt_inet.h:
        echo "#define INET 1" > opt_inet.h
index 18f8687..e7fc4be 100644 (file)
@@ -30,7 +30,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/an/if_an_pccard.c,v 1.1.2.6 2003/02/01 03:25:12 ambrisko Exp $
- * $DragonFly: src/sys/dev/netif/an/if_an_pccard.c,v 1.3 2003/08/07 21:16:59 dillon Exp $
+ * $DragonFly: src/sys/dev/netif/an/if_an_pccard.c,v 1.4 2004/02/19 14:31:12 joerg Exp $
  *
  * $FreeBSD: src/sys/dev/an/if_an_pccard.c,v 1.1.2.6 2003/02/01 03:25:12 ambrisko Exp $
  */
 #include <net/if_types.h>
 #include <net/if_media.h>
 
+#include <bus/pccard/pccardvar.h>
+#include <bus/pccard/pccarddevs.h>
+#include "card_if.h"
+
 #include "if_aironet_ieee.h"
 #include "if_anreg.h"
 
 /*
  * Support for PCMCIA cards.
  */
+static int  an_pccard_match(device_t);
 static int  an_pccard_probe(device_t);
 static int  an_pccard_attach(device_t);
 static int  an_pccard_detach(device_t);
 
 static device_method_t an_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         an_pccard_probe),
-       DEVMETHOD(device_attach,        an_pccard_attach),
-       DEVMETHOD(device_detach,        an_pccard_detach),
+       DEVMETHOD(device_probe,         pccard_compat_probe),
+       DEVMETHOD(device_attach,        pccard_compat_attach),
        DEVMETHOD(device_shutdown,      an_shutdown),
+       DEVMETHOD(device_detach,        an_pccard_detach),
+
+       /* Card interface */
+       DEVMETHOD(card_compat_match,    an_pccard_match),
+       DEVMETHOD(card_compat_probe,    an_pccard_probe),
+       DEVMETHOD(card_compat_attach,   an_pccard_attach),
 
        { 0, 0 }
 };
@@ -97,6 +107,28 @@ static devclass_t an_pccard_devclass;
 
 DRIVER_MODULE(if_an, pccard, an_pccard_driver, an_pccard_devclass, 0, 0);
 
+static const struct pccard_product an_pccard_products[] = {
+       PCMCIA_CARD(AIRONET, PC4500, 0),
+       PCMCIA_CARD(AIRONET, PC4800, 0),
+       PCMCIA_CARD(AIRONET, 350, 0),
+       PCMCIA_CARD(XIRCOM, CWE1130, 0), 
+       { NULL }
+};
+
+static int
+an_pccard_match(device_t dev)
+{
+       const struct pccard_product *pp;
+
+       if ((pp = pccard_product_lookup(dev, an_pccard_products,
+           sizeof(an_pccard_products[0]), NULL)) != NULL) {
+               if (pp->pp_name != NULL)
+                       device_set_desc(dev, pp->pp_name);
+               return (0);
+       }
+       return (ENXIO);
+}
+
 static int
 an_pccard_detach(device_t dev)
 {
@@ -143,18 +175,26 @@ an_pccard_attach(device_t dev)
        an_alloc_port(dev, sc->port_rid, AN_IOSIZ);
        an_alloc_irq(dev, sc->irq_rid, 0);
 
-       error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
-                              an_intr, sc, &sc->irq_handle);
-       if (error) {
-               printf("setup intr failed %d \n", error);
-               an_release_resources(dev);
-               return (error);
-       }
-
        sc->an_bhandle = rman_get_bushandle(sc->port_res);
        sc->an_btag = rman_get_bustag(sc->port_res);
        sc->an_dev = dev;
 
        error = an_attach(sc, device_get_unit(dev), flags);
+       if (error) {
+               goto fail;
+       }
+       
+       /*
+        * Must setup the interrupt after the an_attach to prevent racing.
+        */
+       error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
+                              an_intr, sc, &sc->irq_handle);
+       if (error) {
+               goto fail;
+       }
+
+fail:
+       if (error)
+               an_release_resources(dev);
        return (error);
 }
index b90a27a..b7d9b7e 100644 (file)
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/awi/if_awi_pccard.c,v 1.5.2.1 2000/12/07 04:09:39 imp Exp $
- * $DragonFly: src/sys/dev/netif/awi/Attic/if_awi_pccard.c,v 1.5 2004/01/06 01:40:46 dillon Exp $
+ * $DragonFly: src/sys/dev/netif/awi/Attic/if_awi_pccard.c,v 1.6 2004/02/19 14:31:13 joerg Exp $
  */
 
 #include <sys/param.h>
 #include "awireg.h"
 #include "awivar.h"
 
+#include <bus/pccard/pccardvar.h>
+#include <bus/pccard/pccarddevs.h>
+#include "card_if.h"
+
 struct awi_pccard_softc {
        struct awi_softc        sc_awi;
 
@@ -65,6 +69,40 @@ struct awi_pccard_softc {
        int             sc_mem_rid;
 };
 
+static const struct pccard_product awi_pccard_products[] = {
+       PCMCIA_CARD(AMD, AM79C930, 0),
+       PCMCIA_CARD(BAY, STACK_650, 0),
+       PCMCIA_CARD(BAY, STACK_660, 0),
+       PCMCIA_CARD(BAY, SURFER_PRO, 0),
+       PCMCIA_CARD(ICOM, SL200, 0),
+       PCMCIA_CARD(NOKIA, C020_WLAN, 0),
+       PCMCIA_CARD(FARALLON, SKYLINE, 0),
+       PCMCIA_CARD(ZOOM, AIR_4000, 0),
+       { NULL }
+};
+
+static int awi_pccard_match(device_t);
+static int awi_pccard_probe(device_t);
+static int awi_pccard_attach(device_t);
+static int awi_pccard_detach(device_t);
+static void awi_pccard_shutdown(device_t);
+static int awi_pccard_enable(struct awi_softc *);
+static void awi_pccard_disable(struct awi_softc *);
+
+static int
+awi_pccard_match(device_t dev)
+{
+       const struct pccard_product *pp;
+
+       if ((pp = pccard_product_lookup(dev, awi_pccard_products,
+           sizeof(awi_pccard_products[0]), NULL)) != NULL) {
+               if (pp->pp_name != NULL)
+                       device_set_desc(dev, pp->pp_name);
+               return 0;
+       }
+       return ENXIO;
+}
+
 /*
  * Initialize the device - called from Slot manager.
  */
@@ -234,10 +272,15 @@ awi_pccard_detach(device_t dev)
 
 static device_method_t awi_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         awi_pccard_probe),
-       DEVMETHOD(device_attach,        awi_pccard_attach),
+       DEVMETHOD(device_probe,         pccard_compat_probe),
+       DEVMETHOD(device_attach,        pccard_compat_attach),
        DEVMETHOD(device_detach,        awi_pccard_detach),
 
+       /* Card interface */
+       DEVMETHOD(card_compat_match,    awi_pccard_match),
+       DEVMETHOD(card_compat_probe,    awi_pccard_probe),
+       DEVMETHOD(card_compat_attach,   awi_pccard_attach),
+
        { 0, 0 }
 };
 
index f08b4a6..c9713ed 100644 (file)
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/cs/if_cs_pccard.c,v 1.1.2.1 2001/01/25 20:13:48 imp Exp $
- * $DragonFly: src/sys/dev/netif/cs/if_cs_pccard.c,v 1.4 2004/01/06 03:17:22 dillon Exp $
+ * $DragonFly: src/sys/dev/netif/cs/if_cs_pccard.c,v 1.5 2004/02/19 14:31:13 joerg Exp $
  */
 
 #include <sys/param.h>
 
 #include "if_csvar.h"
 #include <bus/pccard/pccardvar.h>
+#include <bus/pccard/pccarddevs.h>
 
 #include "card_if.h"
 
+static const struct pccard_product cs_pccard_products[] = {
+       PCMCIA_CARD(IBM, ETHERJET, 0),
+       { NULL }
+};
+static int
+cs_pccard_match(device_t dev)
+{
+       const struct pccard_product *pp;
+
+       if ((pp = pccard_product_lookup(dev, cs_pccard_products,
+           sizeof(cs_pccard_products[0]), NULL)) != NULL) {
+               if (pp->pp_name != NULL)
+                       device_set_desc(dev, pp->pp_name);
+               return 0;
+       }
+       return EIO;
+}
+
 static int
 cs_pccard_probe(device_t dev)
 {
@@ -83,11 +102,17 @@ bad:
 
 static device_method_t cs_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         cs_pccard_probe),
-       DEVMETHOD(device_attach,        cs_pccard_attach),
+       DEVMETHOD(device_probe,         pccard_compat_probe),
+       DEVMETHOD(device_attach,        pccard_compat_attach),
 #ifdef CS_HAS_DETACH
        DEVMETHOD(device_detach,        cs_detach),
 #endif
+
+       /* Card interface */
+       DEVMETHOD(card_compat_match,    cs_pccard_match),
+       DEVMETHOD(card_compat_probe,    cs_pccard_probe),
+       DEVMETHOD(card_compat_attach,   cs_pccard_attach),
+
        { 0, 0 }
 };
 
index 6173f11..481d7ed 100644 (file)
@@ -28,7 +28,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ep/if_ep_pccard.c,v 1.12.2.2 2000/08/08 23:55:02 peter Exp $
- * $DragonFly: src/sys/dev/netif/ep/if_ep_pccard.c,v 1.4 2003/11/20 22:07:27 dillon Exp $
+ * $DragonFly: src/sys/dev/netif/ep/if_ep_pccard.c,v 1.5 2004/02/19 14:31:13 joerg Exp $
  */
 
 /*
 #include "if_epreg.h"
 #include "if_epvar.h"
 
+#include <bus/pccard/pccardvar.h>
+#include <bus/pccard/pccarddevs.h>
+
+#include "card_if.h"
+
 static const char *ep_pccard_identify(u_short id);
 
 /*
@@ -236,11 +241,41 @@ ep_pccard_detach(device_t dev)
        return (0);
 }
 
+static const struct pccard_product ep_pccard_products[] = {
+       PCMCIA_CARD(3COM, 3C1, 0),
+       PCMCIA_CARD(3COM, 3C562, 0),
+       PCMCIA_CARD(3COM, 3C574, 0),    /* ROADRUNNER */
+       PCMCIA_CARD(3COM, 3C589, 0),
+       PCMCIA_CARD(3COM, 3CCFEM556BI, 0),      /* ROADRUNNER */
+       PCMCIA_CARD(3COM, 3CXEM556, 0),
+       PCMCIA_CARD(3COM, 3CXEM556INT, 0),
+       {NULL}
+};
+
+static int
+ep_pccard_match(device_t dev)
+{
+       const struct pccard_product *pp;
+
+       if ((pp = pccard_product_lookup(dev, ep_pccard_products,
+                   sizeof(ep_pccard_products[0]), NULL)) != NULL) {
+               if (pp->pp_name != NULL)
+                       device_set_desc(dev, pp->pp_name);
+               return 0;
+       }
+       return EIO;
+}
+
 static device_method_t ep_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         ep_pccard_probe),
-       DEVMETHOD(device_attach,        ep_pccard_attach),
-       DEVMETHOD(device_detach,        ep_pccard_detach),
+       DEVMETHOD(device_probe, pccard_compat_probe),
+       DEVMETHOD(device_attach, pccard_compat_attach),
+       DEVMETHOD(device_detach, ep_pccard_detach),
+
+       /* Card interface */
+       DEVMETHOD(card_compat_match, ep_pccard_match),
+       DEVMETHOD(card_compat_probe, ep_pccard_probe),
+       DEVMETHOD(card_compat_attach, ep_pccard_attach),
 
        { 0, 0 }
 };
index 27e1e65..50e95df 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/ex/if_ex_pccard.c,v 1.2.2.1 2001/03/05 05:33:20 imp Exp $
- *     $DragonFly: src/sys/dev/netif/ex/if_ex_pccard.c,v 1.6 2004/02/13 22:12:33 joerg Exp $
+ *     $DragonFly: src/sys/dev/netif/ex/if_ex_pccard.c,v 1.7 2004/02/19 14:31:13 joerg Exp $
  */
 
 #include <sys/param.h>
 #include "if_exvar.h"
 
 #include <bus/pccard/pccardvar.h>
+#include <bus/pccard/pccarddevs.h>
+
+static const struct pccard_product ex_pccard_products[] = {
+       PCMCIA_CARD(OLICOM, OC2220, 0),
+       { NULL }
+};
 
 /* Bus Front End Functions */
+static int     ex_pccard_match         (device_t);
 static int     ex_pccard_probe         (device_t);
 static int     ex_pccard_attach        (device_t);
 static int     ex_pccard_detach        (device_t);
 
 static device_method_t ex_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         ex_pccard_probe),
-       DEVMETHOD(device_attach,        ex_pccard_attach),
+       DEVMETHOD(device_probe,         pccard_compat_probe),
+       DEVMETHOD(device_attach,        pccard_compat_attach),
        DEVMETHOD(device_detach,        ex_pccard_detach),
 
+       /* Card interface */
+       DEVMETHOD(card_compat_match,    ex_pccard_match),
+       DEVMETHOD(card_compat_probe,    ex_pccard_probe),
+       DEVMETHOD(card_compat_attach,   ex_pccard_attach),
+
        { 0, 0 }
 };
 
@@ -73,6 +85,20 @@ extern devclass_t ex_devclass;
 
 DRIVER_MODULE(if_ex, pccard, ex_pccard_driver, ex_devclass, 0, 0);
 
+static int
+ex_pccard_match(device_t dev)
+{
+       const struct pccard_product *pp;
+
+       if ((pp = pccard_product_lookup(dev, ex_pccard_products,
+           sizeof(ex_pccard_products[0]), NULL)) != NULL) {
+               if (pp->pp_name != NULL)
+                       device_set_desc(dev, pp->pp_name);
+               return 0;
+       }
+       return EIO;
+}
+
 static int
 ex_pccard_probe(device_t dev)
 {
index 729f66e..7f1ba8d 100644 (file)
@@ -20,7 +20,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/fe/if_fe_pccard.c,v 1.2.2.1 2000/09/22 10:01:47 nyan Exp $
- * $DragonFly: src/sys/dev/netif/fe/if_fe_pccard.c,v 1.5 2004/02/13 22:12:33 joerg Exp $
+ * $DragonFly: src/sys/dev/netif/fe/if_fe_pccard.c,v 1.6 2004/02/19 14:31:13 joerg Exp $
  */
 
 #include "opt_fe.h"
 #include "if_fevar.h"
 
 #include <bus/pccard/pccardvar.h>
+#include <bus/pccard/pccarddevs.h>
 #include <bus/pccard/cardinfo.h>
 
+#include "card_if.h"
+
 /*
  *     PC-Card (PCMCIA) specific code.
  */
 static int fe_pccard_probe(device_t);
 static int fe_pccard_attach(device_t);
 static int fe_pccard_detach(device_t);
+static int fe_pccard_match(device_t);
+
+static const struct fe_pccard_product {
+        struct pccard_product mpp_product;
+        u_int32_t mpp_ioalign;                  /* required alignment */
+        int mpp_enet_maddr;
+} fe_pccard_products[] = {
+        { PCMCIA_CARD(TDK, LAK_CD021BX, 0), 0, -1 }, 
+        { PCMCIA_CARD(TDK, LAK_CF010, 0), 0, -1 }, 
+#if 0 /* XXX 86960-based? */
+        { PCMCIA_CARD(TDK, LAK_DFL9610, 1), 0, -1 }, 
+#endif
+        { PCMCIA_CARD(CONTEC, CNETPC, 0), 0, -1 },
+       { PCMCIA_CARD(FUJITSU, LA501, 0), 0x20, -1 },
+       { PCMCIA_CARD(FUJITSU, LA10S, 0), 0, -1 },
+       { PCMCIA_CARD(RATOC, REX_R280, 0), 0, 0x1fc },
+        { { NULL } }
+};
+
+static int
+fe_pccard_match(device_t dev)
+{
+        const struct pccard_product *pp;
+
+        if ((pp = pccard_product_lookup(dev,
+           (const struct pccard_product *)fe_pccard_products,
+            sizeof(fe_pccard_products[0]), NULL)) != NULL) {
+               if (pp->pp_name != NULL)
+                       device_set_desc(dev, pp->pp_name);
+                return 0;
+        }
+        return ENXIO;
+}
 
 static device_method_t fe_pccard_methods[] = {
-       /* Device interface */
-       DEVMETHOD(device_probe,         fe_pccard_probe),
-       DEVMETHOD(device_attach,        fe_pccard_attach),
-       DEVMETHOD(device_detach,        fe_pccard_detach),
+        /* Device interface */
+        DEVMETHOD(device_probe,         pccard_compat_probe),
+        DEVMETHOD(device_attach,        pccard_compat_attach),
+        DEVMETHOD(device_detach,        fe_pccard_detach),
+
+        /* Card interface */
+        DEVMETHOD(card_compat_match,    fe_pccard_match),
+        DEVMETHOD(card_compat_probe,    fe_pccard_probe),
+        DEVMETHOD(card_compat_attach,   fe_pccard_attach),
 
        { 0, 0 }
 };
index 2005d05..7ea0ff4 100644 (file)
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/sn/if_sn_pccard.c,v 1.3.2.2 2001/01/25 19:40:27 imp Exp $
- * $DragonFly: src/sys/dev/netif/sn/if_sn_pccard.c,v 1.4 2004/02/13 22:12:33 joerg Exp $
+ * $DragonFly: src/sys/dev/netif/sn/if_sn_pccard.c,v 1.5 2004/02/19 14:31:13 joerg Exp $
  */
 
 /*
 #include "if_snreg.h"
 #include "if_snvar.h"
 #include <bus/pccard/pccardvar.h>
+#include <bus/pccard/pccarddevs.h>
+
+#include "card_if.h"
+
+static const struct pccard_product sn_pccard_products[] = {
+       PCMCIA_CARD(DSPSI, XJACK, 0),
+       PCMCIA_CARD(NEWMEDIA, BASICS, 0),
+#if 0
+       PCMCIA_CARD(SMC, 8020BT, 0),
+#endif
+       { NULL }
+};
+
+static int
+sn_pccard_match(device_t dev)
+{
+       const struct pccard_product *pp;
+
+       if ((pp = pccard_product_lookup(dev, sn_pccard_products,
+           sizeof(sn_pccard_products[0]), NULL)) != NULL) {
+               if (pp->pp_name != NULL)
+                       device_set_desc(dev, pp->pp_name);
+               return 0;
+       }
+       return EIO;
+}
 
 /*
  * Initialize the device - called from Slot manager.
@@ -98,10 +124,15 @@ sn_pccard_detach(device_t dev)
 
 static device_method_t sn_pccard_methods[] = {
        /* Device interface */
-       DEVMETHOD(device_probe,         sn_pccard_probe),
-       DEVMETHOD(device_attach,        sn_pccard_attach),
+       DEVMETHOD(device_probe,         pccard_compat_probe),
+       DEVMETHOD(device_attach,        pccard_compat_attach),
        DEVMETHOD(device_detach,        sn_pccard_detach),
 
+       /* Card interface */
+       DEVMETHOD(card_compat_match,    sn_pccard_match),
+       DEVMETHOD(card_compat_probe,    sn_pccard_probe),
+       DEVMETHOD(card_compat_attach,   sn_pccard_attach),
+
        { 0, 0 }
 };