Home | History | Annotate | Line # | Download | only in ofw
ofisascr.c revision 1.1
      1 /*	$NetBSD: ofisascr.c,v 1.1 2002/02/10 01:57:58 thorpej Exp $	*/
      2 
      3 /*
      4  * Copyright 1997
      5  * Digital Equipment Corporation. All rights reserved.
      6  *
      7  * This software is furnished under license and may be used and
      8  * copied only in accordance with the following terms and conditions.
      9  * Subject to these conditions, you may download, copy, install,
     10  * use, modify and distribute this software in source and/or binary
     11  * form. No title or ownership is transferred hereby.
     12  *
     13  * 1) Any source code used, modified or distributed must reproduce
     14  *    and retain this copyright notice and list of conditions as
     15  *    they appear in the source file.
     16  *
     17  * 2) No right is granted to use any trade name, trademark, or logo of
     18  *    Digital Equipment Corporation. Neither the "Digital Equipment
     19  *    Corporation" name nor any trademark or logo of Digital Equipment
     20  *    Corporation may be used to endorse or promote products derived
     21  *    from this software without the prior written permission of
     22  *    Digital Equipment Corporation.
     23  *
     24  * 3) This software is provided "AS-IS" and any express or implied
     25  *    warranties, including but not limited to, any implied warranties
     26  *    of merchantability, fitness for a particular purpose, or
     27  *    non-infringement are disclaimed. In no event shall DIGITAL be
     28  *    liable for any damages whatsoever, and in particular, DIGITAL
     29  *    shall not be liable for special, indirect, consequential, or
     30  *    incidental damages or damages for lost profits, loss of
     31  *    revenue or loss of use, whether such damages arise in contract,
     32  *    negligence, tort, under statute, in equity, at law or otherwise,
     33  *    even if advised of the possibility of such damage.
     34  */
     35 
     36 /*
     37  *  OFW Glue for Smart Card Driver
     38  */
     39 
     40 #include <sys/param.h>
     41 #include <sys/device.h>
     42 #include <sys/systm.h>
     43 
     44 #include <machine/intr.h>
     45 
     46 #include <dev/ofw/openfirm.h>
     47 #include <dev/isa/isavar.h>
     48 #include <shark/shark/sequoia.h>
     49 
     50 int ofisascrprobe __P((struct device *, struct cfdata *, void *));
     51 void ofisascrattach __P((struct device *, struct device *, void *));
     52 
     53 
     54 struct cfattach ofisascr_ca = {
     55 	sizeof(struct device), ofisascrprobe, ofisascrattach
     56 };
     57 
     58 extern struct cfdriver ofisascr_cd;
     59 
     60 
     61 int
     62 ofisascrprobe(parent, cf, aux)
     63 	struct device *parent;
     64 	struct cfdata *cf;
     65 	void *aux;
     66 {
     67 	struct ofbus_attach_args *oba = aux;
     68 	char type[64];
     69 	char name[64];
     70 
     71 	/* At a minimum, must match type and name properties. */
     72 	if ( OF_getprop(oba->oba_phandle, "device_type", type,
     73 	    sizeof(type)) < 0 || strcmp(type, "ISO7816") != 0 ||
     74 	    OF_getprop(oba->oba_phandle, "name", name, sizeof(name)) < 0 ||
     75 	    strcmp(name, "scr") != 0)
     76 		return 0;
     77 
     78 	/* Match, we dont have models yet  */
     79 	return 2;
     80 }
     81 
     82 
     83 void
     84 ofisascrattach(parent, dev, aux)
     85 	struct device *parent, *dev;
     86 	void *aux;
     87 {
     88 	struct ofbus_attach_args *oba = aux;
     89 	struct isa_attach_args ia;
     90 	struct isa_io ia_io[1];
     91 
     92 	printf("\n");
     93 
     94 	/* XXX - Hard-wire the ISA attach args for now. -JJK */
     95 	ia.ia_iot = &isa_io_bs_tag;
     96 	ia.ia_memt = &isa_mem_bs_tag;
     97 	ia.ia_ic = NULL;			/* not used */
     98 
     99 	ia.ia_nio = 1;
    100 	ia.ia_io = ia_io;
    101 	ia.ia_io[0].ir_addr = SEQUOIA_BASE;
    102 	ia.ia_io[0].ir_size = SEQUOIA_NPORTS;
    103 
    104 	ia.ia_niomem = 0;
    105 	ia.ia_nirq = 0;
    106 	ia.ia_ndrq = 0;
    107 
    108 	ia.ia_aux = (void *)oba->oba_phandle;
    109 
    110 	config_found(dev, &ia, NULL);
    111 }
    112