Home | History | Annotate | Line # | Download | only in isa
pccons_isa.c revision 1.6
      1 /* $NetBSD: pccons_isa.c,v 1.6 2004/09/14 20:32:48 drochner Exp $ */
      2 /* NetBSD: vga_isa.c,v 1.4 2000/08/14 20:14:51 thorpej Exp  */
      3 
      4 /*
      5  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      6  * All rights reserved.
      7  *
      8  * Author: Chris G. Demetriou
      9  *
     10  * Permission to use, copy, modify and distribute this software and
     11  * its documentation is hereby granted, provided that both the copyright
     12  * notice and this permission notice appear in all copies of the
     13  * software, derivative works or modified versions, and any portions
     14  * thereof, and that both notices appear in supporting documentation.
     15  *
     16  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     17  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     18  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     19  *
     20  * Carnegie Mellon requests users of this software to return to
     21  *
     22  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     23  *  School of Computer Science
     24  *  Carnegie Mellon University
     25  *  Pittsburgh PA 15213-3890
     26  *
     27  * any improvements or extensions that they make and grant Carnegie the
     28  * rights to redistribute these changes.
     29  */
     30 
     31 #include <sys/cdefs.h>
     32 __KERNEL_RCSID(0, "$NetBSD: pccons_isa.c,v 1.6 2004/09/14 20:32:48 drochner Exp $");
     33 
     34 #include <sys/param.h>
     35 #include <sys/systm.h>
     36 #include <sys/device.h>
     37 
     38 #include <machine/bus.h>
     39 
     40 #include <dev/isa/isavar.h>
     41 
     42 #include <arc/dev/pcconsvar.h>
     43 #include <arc/isa/pccons_isavar.h>
     44 
     45 int	pccons_isa_match __P((struct device *, struct cfdata *, void *));
     46 void	pccons_isa_attach __P((struct device *, struct device *, void *));
     47 
     48 CFATTACH_DECL(pc_isa, sizeof(struct pc_softc),
     49     pccons_isa_match, pccons_isa_attach, NULL, NULL);
     50 
     51 struct pccons_config *pccons_isa_conf;
     52 
     53 int
     54 pccons_isa_match(parent, match, aux)
     55 	struct device *parent;
     56 	struct cfdata *match;
     57 	void *aux;
     58 {
     59 	struct isa_attach_args *ia = aux;
     60 	bus_addr_t iobase = 0x3b0;	/* XXX mono 0x3b0 color 0x3c0 */
     61 	bus_size_t iosize = 0x30;	/* XXX 0x20 */
     62 	bus_addr_t maddr = 0xa0000;
     63 	bus_size_t msize = 0x20000;
     64 	int irq = 1;
     65 
     66 	if (ia->ia_nio < 1)
     67 		return (0);
     68 	if (ia->ia_io[0].ir_addr != ISA_UNKNOWN_PORT)
     69 		iobase = ia->ia_io[0].ir_addr;
     70 #if 0	/* XXX isa.c */
     71 	if (ia->ia_iosize != 0)
     72 		iosize = ia->ia_iosize;
     73 #endif
     74 	if (ia->ia_niomem < 1)
     75 		return (0);
     76 	if (ia->ia_iomem[0].ir_addr != ISA_UNKNOWN_IOMEM)
     77 		maddr = ia->ia_iomem[0].ir_addr;
     78 	if (ia->ia_iomem[0].ir_size != ISA_UNKNOWN_IOSIZ)
     79 		msize = ia->ia_iomem[0].ir_size;
     80 
     81 	if (ia->ia_nirq < 1)
     82 		return (0);
     83 	if (ia->ia_irq[0].ir_irq != ISA_UNKNOWN_IRQ)
     84 		irq = ia->ia_irq[0].ir_irq;
     85 
     86 #if 0
     87 	/* If values are hardwired to something that they can't be, punt. */
     88 	if (iobase != 0x3b0 || iosize != 0x30 ||
     89 	    maddr != 0xa0000 || msize != 0x20000 ||
     90 	    ia->ia_irq != 1 || ia->ia_drq != DRQUNK)
     91 		return (0);
     92 #endif
     93 
     94 	if (pccons_isa_conf == NULL)
     95 		return (0);
     96 
     97 	if (!pccons_common_match(ia->ia_iot, ia->ia_memt, ia->ia_iot,
     98 	    pccons_isa_conf))
     99 		return (0);
    100 
    101 	ia->ia_nio = 1;
    102 	ia->ia_io[0].ir_addr = iobase;
    103 	ia->ia_io[0].ir_size = iosize;
    104 
    105 	ia->ia_niomem = 1;
    106 	ia->ia_iomem[0].ir_addr = maddr;
    107 	ia->ia_iomem[0].ir_size = msize;
    108 
    109 	ia->ia_nirq = 1;
    110 	ia->ia_irq[0].ir_irq = irq;
    111 
    112 	ia->ia_ndrq = 0;
    113 
    114 	return (1);
    115 }
    116 
    117 void
    118 pccons_isa_attach(parent, self, aux)
    119 	struct device *parent, *self;
    120 	void *aux;
    121 {
    122 	struct pc_softc *sc = (struct pc_softc *)self;
    123 	struct isa_attach_args *ia = aux;
    124 
    125 	isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_TTY,
    126 	    pcintr, self);
    127 	pccons_common_attach(sc, ia->ia_iot, ia->ia_memt, ia->ia_iot,
    128 	    pccons_isa_conf);
    129 }
    130 
    131 int
    132 pccons_isa_cnattach(iot, memt)
    133 	bus_space_tag_t iot, memt;
    134 {
    135 	if (pccons_isa_conf == NULL)
    136 		return (ENXIO);
    137 
    138 	pccons_common_cnattach(iot, memt, iot, pccons_isa_conf);
    139 	return (0);
    140 }
    141