The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/isapnp/isic_isapnp.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2002 The NetBSD Foundation, Inc.
    3  * All rights reserved.
    4  *
    5  * This code is derived from software contributed to The NetBSD Foundation
    6  * by Martin Husemann <martin@NetBSD.org>.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. All advertising materials mentioning features or use of this software
   17  *    must display the following acknowledgement:
   18  *        This product includes software developed by the NetBSD
   19  *        Foundation, Inc. and its contributors.
   20  * 4. Neither the name of The NetBSD Foundation nor the names of its
   21  *    contributors may be used to endorse or promote products derived
   22  *    from this software without specific prior written permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   25  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   26  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   27  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   28  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   34  * POSSIBILITY OF SUCH DAMAGE.
   35  */
   36 
   37 #include <sys/cdefs.h>
   38 __KERNEL_RCSID(0, "$NetBSD: isic_isapnp.c,v 1.17 2003/12/04 13:57:30 keihan Exp $");
   39 
   40 #include <sys/param.h>
   41 #include <sys/errno.h>
   42 #include <sys/syslog.h>
   43 #include <sys/device.h>
   44 #include <sys/socket.h>
   45 #include <net/if.h>
   46 #include <sys/systm.h>
   47 #include <sys/malloc.h>
   48 
   49 #if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
   50 #include <sys/callout.h>
   51 #endif
   52 
   53 #include <machine/cpu.h>
   54 #include <machine/intr.h>
   55 #include <machine/bus.h>
   56 
   57 #include <dev/isa/isavar.h>
   58 #include <dev/isapnp/isapnpreg.h>
   59 #include <dev/isapnp/isapnpvar.h>
   60 
   61 #ifdef __FreeBSD__
   62 #include <machine/i4b_ioctl.h>
   63 #include <machine/i4b_trace.h>
   64 #else
   65 #include <netisdn/i4b_global.h>
   66 #include <netisdn/i4b_debug.h>
   67 #include <netisdn/i4b_ioctl.h>
   68 #include <netisdn/i4b_trace.h>
   69 #include <netisdn/i4b_l2.h>
   70 #include <netisdn/i4b_l1l2.h>
   71 #endif
   72 
   73 #include <dev/ic/isic_l1.h>
   74 #include <dev/ic/ipac.h>
   75 #include <dev/ic/isac.h>
   76 #include <dev/ic/hscx.h>
   77 
   78 #include <netisdn/i4b_l1l2.h>
   79 #include <netisdn/i4b_global.h>
   80 
   81 #include "opt_isicpnp.h"
   82 
   83 extern const struct isdn_layer1_isdnif_driver isic_std_driver;
   84 
   85 #ifdef __BROKEN_INDIRECT_CONFIG
   86 static int isic_isapnp_probe __P((struct device *, void *, void *));
   87 #else
   88 static int isic_isapnp_probe __P((struct device *, struct cfdata *, void *));
   89 #endif
   90 static void isic_isapnp_attach __P((struct device *, struct device *, void *));
   91 
   92 CFATTACH_DECL(isic_isapnp, sizeof(struct isic_softc),
   93     isic_isapnp_probe, isic_isapnp_attach, NULL, NULL);
   94 
   95 typedef void (*allocmaps_func)(struct isapnp_attach_args *ipa, struct isic_softc *sc);
   96 typedef void (*attach_func)(struct isic_softc *sc);
   97 
   98 /* map allocators */
   99 #if defined(ISICPNP_ELSA_QS1ISA) || defined(ISICPNP_SEDLBAUER) \
  100         || defined(ISICPNP_DYNALINK) || defined(ISICPNP_SIEMENS_ISURF2) \
  101         || defined(ISICPNP_ITKIX)
  102 static void generic_pnp_mapalloc(struct isapnp_attach_args *ipa, struct isic_softc *sc);
  103 #endif
  104 #ifdef ISICPNP_DRN_NGO
  105 static void ngo_pnp_mapalloc(struct isapnp_attach_args *ipa, struct isic_softc *sc);
  106 #endif
  107 #if defined(ISICPNP_CRTX_S0_P) || defined(ISICPNP_TEL_S0_16_3_P)
  108 static void tls_pnp_mapalloc(struct isapnp_attach_args *ipa, struct isic_softc *sc);
  109 #endif
  110 
  111 /* card attach functions */
  112 extern void isic_attach_Cs0P __P((struct isic_softc *sc));
  113 extern void isic_attach_Dyn __P((struct isic_softc *sc));
  114 extern void isic_attach_s0163P __P((struct isic_softc *sc));
  115 extern void isic_attach_drnngo __P((struct isic_softc *sc));
  116 extern void isic_attach_sws __P((struct isic_softc *sc));
  117 extern void isic_attach_Eqs1pi __P((struct isic_softc *sc));
  118 extern void isic_attach_siemens_isurf __P((struct isic_softc *sc));
  119 extern void isic_attach_isapnp_itkix1 __P((struct isic_softc *sc));
  120 
  121 struct isic_isapnp_card_desc {
  122         char *devlogic;                 /* ISAPNP logical device ID */
  123         char *name;                     /* Name of the card */
  124         int card_type;                  /* isic card type identifier */
  125         allocmaps_func allocmaps;       /* map allocator function */
  126         attach_func attach;             /* card attach and init function */
  127 };
  128 static const struct isic_isapnp_card_desc
  129 isic_isapnp_descriptions[] =
  130 {
  131 #ifdef ISICPNP_CRTX_S0_P
  132         { "CTX0000", "Creatix ISDN S0-16 P&P", CARD_TYPEP_CS0P,
  133           tls_pnp_mapalloc, isic_attach_Cs0P },
  134 #endif
  135 #ifdef ISICPNP_TEL_S0_16_3_P
  136         { "TAG2110", "Teles S0/PnP", CARD_TYPEP_163P,
  137           tls_pnp_mapalloc, isic_attach_s0163P },
  138 #endif
  139 #ifdef ISICPNP_DRN_NGO
  140         { "SDA0150", "Dr. Neuhaus NICCY GO@", CARD_TYPEP_DRNNGO,
  141           ngo_pnp_mapalloc, isic_attach_drnngo },
  142 #endif
  143 #ifdef ISICPNP_ELSA_QS1ISA
  144         { "ELS0133", "Elsa QuickStep 1000 (ISA)", CARD_TYPEP_ELSAQS1ISA,
  145           generic_pnp_mapalloc, isic_attach_Eqs1pi },
  146 #endif
  147 #ifdef ISICPNP_SEDLBAUER
  148         { "SAG0001", "Sedlbauer WinSpeed", CARD_TYPEP_SWS,
  149           generic_pnp_mapalloc, isic_attach_sws },
  150 #endif
  151 #ifdef ISICPNP_DYNALINK
  152         { "ASU1688", "Dynalink IS64PH", CARD_TYPEP_DYNALINK,
  153           generic_pnp_mapalloc, isic_attach_Dyn },
  154 #endif
  155 #ifdef ISICPNP_SIEMENS_ISURF2
  156         { "SIE0020", "Siemens I-Surf 2.0 PnP", CARD_TYPEP_SIE_ISURF2,
  157           generic_pnp_mapalloc, isic_attach_siemens_isurf },
  158 #endif
  159 #ifdef ISICPNP_ITKIX
  160         { "ITK0025", "ix1-micro 3.0", 0,
  161           generic_pnp_mapalloc, isic_attach_isapnp_itkix1 },
  162 #endif
  163 };
  164 #define NUM_DESCRIPTIONS        (sizeof(isic_isapnp_descriptions)/sizeof(isic_isapnp_descriptions[0]))
  165 
  166 /*
  167  * Probe card
  168  */
  169 static int
  170 #ifdef __BROKEN_INDIRECT_CONFIG
  171 isic_isapnp_probe(parent, match, aux)
  172 #else
  173 isic_isapnp_probe(parent, cf, aux)
  174 #endif
  175         struct device *parent;
  176 #ifdef __BROKEN_INDIRECT_CONFIG
  177         void *match;
  178 #else
  179         struct cfdata *cf;
  180 #endif
  181         void *aux;
  182 {
  183         struct isapnp_attach_args *ipa = aux;
  184         const struct isic_isapnp_card_desc *desc = isic_isapnp_descriptions;
  185         int i;
  186 
  187         for (i = 0; i < NUM_DESCRIPTIONS; i++, desc++)
  188                 if (strcmp(ipa->ipa_devlogic, desc->devlogic) == 0)
  189         return 1;
  190 
  191         return 0;
  192 }
  193 
  194 /*---------------------------------------------------------------------------*
  195  *      card independend attach for ISA P&P cards
  196  *---------------------------------------------------------------------------*/
  197 
  198 /* parameter and format for message producing e.g. "isic0: " */
  199 
  200 #ifdef __FreeBSD__
  201 #define ISIC_FMT        "isic%d: "
  202 #define ISIC_PARM       dev->id_unit
  203 #define TERMFMT " "
  204 #else
  205 #define ISIC_FMT        "%s: "
  206 #define ISIC_PARM       sc->sc_dev.dv_xname
  207 #define TERMFMT "\n"
  208 #endif
  209 
  210 static void
  211 isic_isapnp_attach(parent, self, aux)
  212         struct device *parent, *self;
  213         void *aux;
  214 {
  215         static char *ISACversion[] = {
  216                 "2085 Version A1/A2 or 2086/2186 Version 1.1",
  217                 "2085 Version B1",
  218                 "2085 Version B2",
  219                 "2085 Version V2.3 (B3)",
  220                 "Unknown Version"
  221         };
  222 
  223         static char *HSCXversion[] = {
  224                 "82525 Version A1",
  225                 "Unknown (0x01)",
  226                 "82525 Version A2",
  227                 "Unknown (0x03)",
  228                 "82525 Version A3",
  229                 "82525 or 21525 Version 2.1",
  230                 "Unknown Version"
  231         };
  232 
  233         struct isic_softc *sc = (void *)self;
  234         struct isapnp_attach_args *ipa = aux;
  235         const struct isic_isapnp_card_desc *desc = isic_isapnp_descriptions;
  236         int i;
  237 
  238         if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
  239                 printf("%s: error in region allocation\n",
  240                     sc->sc_dev.dv_xname);
  241                 return;
  242         }
  243 
  244         for (i = 0; i < NUM_DESCRIPTIONS; i++, desc++)
  245                 if (strcmp(ipa->ipa_devlogic, desc->devlogic) == 0)
  246                         break;
  247         if (i >= NUM_DESCRIPTIONS)
  248                 panic("could not identify isic PnP device");
  249 
  250         /* setup parameters */
  251         sc->sc_cardtyp = desc->card_type;
  252         sc->sc_irq = ipa->ipa_irq[0].num;
  253         desc->allocmaps(ipa, sc);
  254 
  255         /* announce card name */
  256         printf(": %s\n", desc->name);
  257 
  258         /* establish interrupt handler */
  259         if (isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num, ipa->ipa_irq[0].type,
  260                 IPL_NET, isicintr, sc) == NULL)
  261                 printf("%s: couldn't establish interrupt handler\n",
  262                         sc->sc_dev.dv_xname);
  263 
  264         /* init card */
  265         desc->attach(sc);
  266 
  267         /* announce chip versions */
  268         sc->sc_isac_version = 0;
  269         sc->sc_isac_version = ((ISAC_READ(I_RBCH)) >> 5) & 0x03;
  270 
  271         switch(sc->sc_isac_version)
  272         {
  273                 case ISAC_VA:
  274                 case ISAC_VB1:
  275                 case ISAC_VB2:
  276                 case ISAC_VB3:
  277                         break;
  278 
  279                 default:
  280                         printf(ISIC_FMT "Error, ISAC version %d unknown!\n",
  281                                 ISIC_PARM, sc->sc_isac_version);
  282                         return;
  283                         break;
  284         }
  285 
  286         sc->sc_hscx_version = HSCX_READ(0, H_VSTR) & 0xf;
  287 
  288         switch(sc->sc_hscx_version)
  289         {
  290                 case HSCX_VA1:
  291                 case HSCX_VA2:
  292                 case HSCX_VA3:
  293                 case HSCX_V21:
  294                         break;
  295                         
  296                 default:
  297                         printf(ISIC_FMT "Error, HSCX version %d unknown!\n",
  298                                 ISIC_PARM, sc->sc_hscx_version);
  299                         return;
  300                         break;
  301         };
  302 
  303         sc->sc_intr_valid = ISIC_INTR_DISABLED;
  304 
  305         /* HSCX setup */
  306 
  307         isic_bchannel_setup(sc, HSCX_CH_A, BPROT_NONE, 0);
  308         
  309         isic_bchannel_setup(sc, HSCX_CH_B, BPROT_NONE, 0);
  310 
  311         /* setup linktab */
  312 
  313         isic_init_linktab(sc);
  314 
  315         /* set trace level */
  316 
  317         sc->sc_trace = TRACE_OFF;
  318 
  319         sc->sc_state = ISAC_IDLE;
  320 
  321         sc->sc_ibuf = NULL;
  322         sc->sc_ib = NULL;
  323         sc->sc_ilen = 0;
  324 
  325         sc->sc_obuf = NULL;
  326         sc->sc_op = NULL;
  327         sc->sc_ol = 0;
  328         sc->sc_freeflag = 0;
  329 
  330         sc->sc_obuf2 = NULL;
  331         sc->sc_freeflag2 = 0;
  332 
  333 #if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
  334         callout_init(&sc->sc_T3_callout);
  335         callout_init(&sc->sc_T4_callout);
  336 #endif
  337 
  338         /* announce chip versions */
  339         
  340         if(sc->sc_isac_version >= ISAC_UNKN)
  341         {
  342                 printf(ISIC_FMT "ISAC Version UNKNOWN (VN=0x%x)" TERMFMT,
  343                                 ISIC_PARM,
  344                                 sc->sc_isac_version);
  345                 sc->sc_isac_version = ISAC_UNKN;
  346         }
  347         else
  348         {
  349                 printf(ISIC_FMT "ISAC %s (IOM-%c)" TERMFMT,
  350                                 ISIC_PARM,
  351                                 ISACversion[sc->sc_isac_version],
  352                                 sc->sc_bustyp == BUS_TYPE_IOM1 ? '1' : '2');
  353         }
  354 
  355         if(sc->sc_hscx_version >= HSCX_UNKN)
  356         {
  357                 printf(ISIC_FMT "HSCX Version UNKNOWN (VN=0x%x)" TERMFMT,
  358                                 ISIC_PARM,
  359                                 sc->sc_hscx_version);
  360                 sc->sc_hscx_version = HSCX_UNKN;
  361         }
  362         else
  363         {
  364                 printf(ISIC_FMT "HSCX %s" TERMFMT,
  365                                 ISIC_PARM,
  366                                 HSCXversion[sc->sc_hscx_version]);
  367         }
  368 
  369         /* init higher protocol layers and save l2 handle */
  370         isic_attach_bri(sc, desc->name, &isic_std_driver);
  371 }
  372 
  373 #if defined(ISICPNP_ELSA_QS1ISA) || defined(ISICPNP_SEDLBAUER) \
  374         || defined(ISICPNP_DYNALINK) || defined(ISICPNP_SIEMENS_ISURF2) \
  375         || defined(ISICPNP_ITKIX)
  376 static void
  377 generic_pnp_mapalloc(struct isapnp_attach_args *ipa, struct isic_softc *sc)
  378 {
  379         sc->sc_num_mappings = 1;        /* most cards have just one mapping */
  380         MALLOC_MAPS(sc);                /* malloc the maps */
  381         sc->sc_maps[0].t = ipa->ipa_iot;        /* copy the access handles */
  382         sc->sc_maps[0].h = ipa->ipa_io[0].h;
  383         sc->sc_maps[0].size = 0;        /* foreign mapping, leave it alone */
  384 }
  385 #endif
  386 
  387 #ifdef ISICPNP_DRN_NGO
  388 static void
  389 ngo_pnp_mapalloc(struct isapnp_attach_args *ipa, struct isic_softc *sc)
  390 {
  391         sc->sc_num_mappings = 2;        /* one data, one address mapping */
  392         MALLOC_MAPS(sc);                /* malloc the maps */
  393         sc->sc_maps[0].t = ipa->ipa_iot;        /* copy the access handles */
  394         sc->sc_maps[0].h = ipa->ipa_io[0].h;
  395         sc->sc_maps[0].size = 0;        /* foreign mapping, leave it alone */
  396                 sc->sc_maps[1].t = ipa->ipa_iot;
  397                 sc->sc_maps[1].h = ipa->ipa_io[1].h;
  398                 sc->sc_maps[1].size = 0;
  399 }
  400 #endif
  401 
  402 #if defined(ISICPNP_CRTX_S0_P) || defined(ISICPNP_TEL_S0_16_3_P)
  403 static void
  404 tls_pnp_mapalloc(struct isapnp_attach_args *ipa, struct isic_softc *sc)
  405 {
  406         sc->sc_num_mappings = 4;        /* config, isac, 2 * hscx */
  407         MALLOC_MAPS(sc);                /* malloc the maps */
  408         sc->sc_maps[0].t = ipa->ipa_iot;        /* copy the access handles */
  409         sc->sc_maps[0].h = ipa->ipa_io[0].h;
  410         sc->sc_maps[0].size = 0;        /* foreign mapping, leave it alone */
  411                 sc->sc_maps[1].t = ipa->ipa_iot;
  412                 sc->sc_maps[1].h = ipa->ipa_io[0].h;
  413                 sc->sc_maps[1].size = 0;
  414                 sc->sc_maps[1].offset = - 0x20;
  415                 sc->sc_maps[2].t = ipa->ipa_iot;
  416                 sc->sc_maps[2].offset = - 0x20;
  417                 sc->sc_maps[2].h = ipa->ipa_io[1].h;
  418                 sc->sc_maps[2].size = 0;
  419                 sc->sc_maps[3].t = ipa->ipa_iot;
  420                 sc->sc_maps[3].offset = 0;
  421                 sc->sc_maps[3].h = ipa->ipa_io[1].h;
  422                 sc->sc_maps[3].size = 0;
  423 }
  424 #endif

Cache object: 9f3510d55e276b333f7696cde3b9f654


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.