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