xref: /netbsd-src/sys/arch/shark/ofw/ofisascr.c (revision 2a015064ddb9440959d41af721b9eae8c9818e88)
1*2a015064Sthorpej /*	$NetBSD: ofisascr.c,v 1.13 2022/01/21 19:12:28 thorpej Exp $	*/
280675955Sthorpej 
380675955Sthorpej /*
480675955Sthorpej  * Copyright 1997
580675955Sthorpej  * Digital Equipment Corporation. All rights reserved.
680675955Sthorpej  *
780675955Sthorpej  * This software is furnished under license and may be used and
880675955Sthorpej  * copied only in accordance with the following terms and conditions.
980675955Sthorpej  * Subject to these conditions, you may download, copy, install,
1080675955Sthorpej  * use, modify and distribute this software in source and/or binary
1180675955Sthorpej  * form. No title or ownership is transferred hereby.
1280675955Sthorpej  *
1380675955Sthorpej  * 1) Any source code used, modified or distributed must reproduce
1480675955Sthorpej  *    and retain this copyright notice and list of conditions as
1580675955Sthorpej  *    they appear in the source file.
1680675955Sthorpej  *
1780675955Sthorpej  * 2) No right is granted to use any trade name, trademark, or logo of
1880675955Sthorpej  *    Digital Equipment Corporation. Neither the "Digital Equipment
1980675955Sthorpej  *    Corporation" name nor any trademark or logo of Digital Equipment
2080675955Sthorpej  *    Corporation may be used to endorse or promote products derived
2180675955Sthorpej  *    from this software without the prior written permission of
2280675955Sthorpej  *    Digital Equipment Corporation.
2380675955Sthorpej  *
2480675955Sthorpej  * 3) This software is provided "AS-IS" and any express or implied
2580675955Sthorpej  *    warranties, including but not limited to, any implied warranties
2680675955Sthorpej  *    of merchantability, fitness for a particular purpose, or
2780675955Sthorpej  *    non-infringement are disclaimed. In no event shall DIGITAL be
2880675955Sthorpej  *    liable for any damages whatsoever, and in particular, DIGITAL
2980675955Sthorpej  *    shall not be liable for special, indirect, consequential, or
3080675955Sthorpej  *    incidental damages or damages for lost profits, loss of
3180675955Sthorpej  *    revenue or loss of use, whether such damages arise in contract,
3280675955Sthorpej  *    negligence, tort, under statute, in equity, at law or otherwise,
3380675955Sthorpej  *    even if advised of the possibility of such damage.
3480675955Sthorpej  */
3580675955Sthorpej 
3680675955Sthorpej /*
3780675955Sthorpej  *  OFW Glue for Smart Card Driver
3880675955Sthorpej  */
3980675955Sthorpej 
40ed517291Slukem #include <sys/cdefs.h>
41*2a015064Sthorpej __KERNEL_RCSID(0, "$NetBSD: ofisascr.c,v 1.13 2022/01/21 19:12:28 thorpej Exp $");
42ed517291Slukem 
4380675955Sthorpej #include <sys/param.h>
4480675955Sthorpej #include <sys/device.h>
4580675955Sthorpej #include <sys/systm.h>
4680675955Sthorpej 
4780675955Sthorpej #include <machine/intr.h>
4880675955Sthorpej 
4980675955Sthorpej #include <dev/ofw/openfirm.h>
5080675955Sthorpej #include <dev/isa/isavar.h>
5180675955Sthorpej #include <shark/shark/sequoia.h>
5280675955Sthorpej 
53338de10aSmatt int ofisascrprobe(device_t, cfdata_t, void *);
54338de10aSmatt void ofisascrattach(device_t, device_t, void *);
5580675955Sthorpej 
5680675955Sthorpej 
57338de10aSmatt CFATTACH_DECL_NEW(ofisascr, 0,
5889bf5a8fSthorpej     ofisascrprobe, ofisascrattach, NULL, NULL);
5980675955Sthorpej 
6080675955Sthorpej extern struct cfdriver ofisascr_cd;
6180675955Sthorpej 
6280675955Sthorpej 
6380675955Sthorpej int
ofisascrprobe(device_t parent,cfdata_t cf,void * aux)64338de10aSmatt ofisascrprobe(device_t parent, cfdata_t cf, void *aux)
6580675955Sthorpej {
6680675955Sthorpej 	struct ofbus_attach_args *oba = aux;
6780675955Sthorpej 	char type[64];
6880675955Sthorpej 	char name[64];
6980675955Sthorpej 
7080675955Sthorpej 	/* At a minimum, must match type and name properties. */
7180675955Sthorpej 	if ( OF_getprop(oba->oba_phandle, "device_type", type,
7280675955Sthorpej 	    sizeof(type)) < 0 || strcmp(type, "ISO7816") != 0 ||
7380675955Sthorpej 	    OF_getprop(oba->oba_phandle, "name", name, sizeof(name)) < 0 ||
7480675955Sthorpej 	    strcmp(name, "scr") != 0)
7580675955Sthorpej 		return 0;
7680675955Sthorpej 
7780675955Sthorpej 	/* Match, we dont have models yet  */
7880675955Sthorpej 	return 2;
7980675955Sthorpej }
8080675955Sthorpej 
8180675955Sthorpej 
8280675955Sthorpej void
ofisascrattach(device_t parent,device_t dev,void * aux)83338de10aSmatt ofisascrattach(device_t parent, device_t dev, void *aux)
8480675955Sthorpej {
8580675955Sthorpej 	struct ofbus_attach_args *oba = aux;
8680675955Sthorpej 	struct isa_attach_args ia;
8780675955Sthorpej 	struct isa_io ia_io[1];
8880675955Sthorpej 
8980675955Sthorpej 	printf("\n");
9080675955Sthorpej 
9180675955Sthorpej 	/* XXX - Hard-wire the ISA attach args for now. -JJK */
9280675955Sthorpej 	ia.ia_iot = &isa_io_bs_tag;
9380675955Sthorpej 	ia.ia_memt = &isa_mem_bs_tag;
9480675955Sthorpej 	ia.ia_ic = NULL;			/* not used */
9580675955Sthorpej 
9680675955Sthorpej 	ia.ia_nio = 1;
9780675955Sthorpej 	ia.ia_io = ia_io;
9880675955Sthorpej 	ia.ia_io[0].ir_addr = SEQUOIA_BASE;
9980675955Sthorpej 	ia.ia_io[0].ir_size = SEQUOIA_NPORTS;
10080675955Sthorpej 
10180675955Sthorpej 	ia.ia_niomem = 0;
10280675955Sthorpej 	ia.ia_nirq = 0;
10380675955Sthorpej 	ia.ia_ndrq = 0;
10480675955Sthorpej 
10580675955Sthorpej 	ia.ia_aux = (void *)oba->oba_phandle;
10680675955Sthorpej 
1072685996bSthorpej 	config_found(dev, &ia, NULL,
108*2a015064Sthorpej 	    CFARGS(.devhandle = device_handle(dev)));
10980675955Sthorpej }
110