Home | History | Annotate | Line # | Download | only in isa
opms_isa.c revision 1.8.74.1
      1  1.8.74.1       mjf /* $NetBSD: opms_isa.c,v 1.8.74.1 2008/09/28 10:39:47 mjf Exp $ */
      2       1.1      soda 
      3       1.1      soda /*
      4       1.1      soda  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      5       1.1      soda  * All rights reserved.
      6       1.1      soda  *
      7       1.1      soda  * Author: Chris G. Demetriou
      8       1.1      soda  *
      9       1.1      soda  * Permission to use, copy, modify and distribute this software and
     10       1.1      soda  * its documentation is hereby granted, provided that both the copyright
     11       1.1      soda  * notice and this permission notice appear in all copies of the
     12       1.1      soda  * software, derivative works or modified versions, and any portions
     13       1.1      soda  * thereof, and that both notices appear in supporting documentation.
     14       1.1      soda  *
     15       1.1      soda  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16       1.1      soda  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17       1.1      soda  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18       1.1      soda  *
     19       1.1      soda  * Carnegie Mellon requests users of this software to return to
     20       1.1      soda  *
     21       1.1      soda  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22       1.1      soda  *  School of Computer Science
     23       1.1      soda  *  Carnegie Mellon University
     24       1.1      soda  *  Pittsburgh PA 15213-3890
     25       1.1      soda  *
     26       1.1      soda  * any improvements or extensions that they make and grant Carnegie the
     27       1.1      soda  * rights to redistribute these changes.
     28       1.1      soda  */
     29       1.5     lukem 
     30       1.5     lukem #include <sys/cdefs.h>
     31  1.8.74.1       mjf __KERNEL_RCSID(0, "$NetBSD: opms_isa.c,v 1.8.74.1 2008/09/28 10:39:47 mjf Exp $");
     32       1.1      soda 
     33       1.1      soda #include <sys/param.h>
     34       1.1      soda #include <sys/systm.h>
     35       1.1      soda #include <sys/tty.h>
     36       1.1      soda #include <sys/device.h>
     37       1.1      soda 
     38       1.1      soda #include <machine/bus.h>
     39       1.1      soda 
     40       1.1      soda #include <dev/isa/isareg.h>
     41       1.1      soda #include <dev/isa/isavar.h>
     42       1.1      soda 
     43       1.1      soda #include <arc/dev/pcconsvar.h>
     44       1.1      soda #include <arc/dev/opmsvar.h>
     45       1.1      soda 
     46  1.8.74.1       mjf static int	opms_isa_match(device_t, cfdata_t, void *);
     47  1.8.74.1       mjf static void	opms_isa_attach(device_t, device_t, void *);
     48       1.1      soda 
     49  1.8.74.1       mjf CFATTACH_DECL_NEW(opms_isa, sizeof(struct opms_softc),
     50       1.4   thorpej     opms_isa_match, opms_isa_attach, NULL, NULL);
     51       1.1      soda 
     52       1.1      soda struct pccons_config *pccons_isa_conf;	/* share stroage with pccons_isa.c */
     53       1.1      soda 
     54  1.8.74.1       mjf static int
     55  1.8.74.1       mjf opms_isa_match(device_t parent, cfdata_t cf, void *aux)
     56       1.1      soda {
     57       1.1      soda 	struct isa_attach_args *ia = aux;
     58       1.1      soda 	bus_addr_t iobase = IO_KBD;
     59       1.1      soda 	bus_size_t iosize = IO_KBDSIZE;
     60       1.1      soda 	int irq = 12;
     61       1.1      soda 
     62       1.2   thorpej 	if (ia->ia_nio < 1)
     63       1.7   tsutsui 		return 0;
     64       1.6  drochner 	if (ia->ia_io[0].ir_addr != ISA_UNKNOWN_PORT)
     65       1.2   thorpej 		iobase = ia->ia_io[0].ir_addr;
     66       1.1      soda #if 0	/* XXX isa.c */
     67       1.1      soda 	if (ia->ia_iosize != 0)
     68       1.1      soda 		iosize = ia->ia_iosize;
     69       1.1      soda #endif
     70       1.6  drochner 	if (ia->ia_irq[0].ir_irq != ISA_UNKNOWN_IRQ)
     71       1.2   thorpej 		irq = ia->ia_irq[0].ir_irq;
     72       1.1      soda 
     73       1.1      soda #if 0
     74       1.1      soda 	/* If values are hardwired to something that they can't be, punt. */
     75       1.1      soda 	if (iobase != IO_KBD || iosize != IO_KBDSIZE ||
     76       1.1      soda 	    ia->ia_maddr != MADDRUNK || ia->ia_msize != 0 ||
     77       1.1      soda 	    ia->ia_irq != 1 || ia->ia_drq != DRQUNK)
     78       1.7   tsutsui 		return 0;
     79       1.1      soda #endif
     80       1.1      soda 
     81       1.1      soda 	if (pccons_isa_conf == NULL)
     82       1.7   tsutsui 		return 0;
     83       1.1      soda 
     84       1.1      soda 	if (!opms_common_match(ia->ia_iot, pccons_isa_conf))
     85       1.7   tsutsui 		return 0;
     86       1.1      soda 
     87       1.2   thorpej 	ia->ia_nio = 1;
     88       1.2   thorpej 	ia->ia_io[0].ir_addr = iobase;
     89       1.2   thorpej 	ia->ia_io[0].ir_size = iosize;
     90       1.2   thorpej 
     91       1.2   thorpej 	ia->ia_nirq = 1;
     92       1.2   thorpej 	ia->ia_irq[0].ir_irq = irq;
     93       1.2   thorpej 
     94       1.2   thorpej 	ia->ia_niomem = 0;
     95       1.2   thorpej 	ia->ia_ndrq = 0;
     96       1.2   thorpej 
     97       1.7   tsutsui 	return 1;
     98       1.1      soda }
     99       1.1      soda 
    100  1.8.74.1       mjf static void
    101  1.8.74.1       mjf opms_isa_attach(device_t parent, device_t self, void *aux)
    102       1.1      soda {
    103  1.8.74.1       mjf 	struct opms_softc *sc = device_private(self);
    104       1.1      soda 	struct isa_attach_args *ia = aux;
    105       1.1      soda 
    106  1.8.74.1       mjf 	sc->sc_dev = self;
    107  1.8.74.1       mjf 
    108  1.8.74.1       mjf 	aprint_normal("\n");
    109       1.1      soda 
    110       1.2   thorpej 	isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_TTY,
    111  1.8.74.1       mjf 	    pcintr, sc);
    112       1.1      soda 	opms_common_attach(sc, ia->ia_iot, pccons_isa_conf);
    113       1.1      soda }
    114