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