1 1.14 thorpej /* $NetBSD: isa_machdep.c,v 1.14 2023/12/20 13:55:18 thorpej Exp $ */ 2 1.1 joff 3 1.1 joff /*- 4 1.1 joff * Copyright (c) 1996-1998 The NetBSD Foundation, Inc. 5 1.1 joff * All rights reserved. 6 1.1 joff * 7 1.1 joff * This code is derived from software contributed to The NetBSD Foundation 8 1.1 joff * by Jesse Off 9 1.1 joff * 10 1.1 joff * This code is derived from software contributed to The NetBSD Foundation 11 1.1 joff * by Mark Brinicombe, Charles M. Hannum and by Jason R. Thorpe of the 12 1.1 joff * Numerical Aerospace Simulation Facility, NASA Ames Research Center. 13 1.1 joff * 14 1.1 joff * Redistribution and use in source and binary forms, with or without 15 1.1 joff * modification, are permitted provided that the following conditions 16 1.1 joff * are met: 17 1.1 joff * 1. Redistributions of source code must retain the above copyright 18 1.1 joff * notice, this list of conditions and the following disclaimer. 19 1.1 joff * 2. Redistributions in binary form must reproduce the above copyright 20 1.1 joff * notice, this list of conditions and the following disclaimer in the 21 1.1 joff * documentation and/or other materials provided with the distribution. 22 1.1 joff * 23 1.1 joff * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 24 1.1 joff * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25 1.1 joff * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26 1.1 joff * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 27 1.1 joff * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 1.1 joff * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 1.1 joff * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 1.1 joff * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 1.1 joff * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 1.1 joff * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 1.1 joff * POSSIBILITY OF SUCH DAMAGE. 34 1.1 joff */ 35 1.1 joff 36 1.1 joff /*- 37 1.1 joff * Copyright (c) 1991 The Regents of the University of California. 38 1.1 joff * All rights reserved. 39 1.1 joff * 40 1.1 joff * This code is derived from software contributed to Berkeley by 41 1.1 joff * William Jolitz. 42 1.1 joff * 43 1.1 joff * Redistribution and use in source and binary forms, with or without 44 1.1 joff * modification, are permitted provided that the following conditions 45 1.1 joff * are met: 46 1.1 joff * 1. Redistributions of source code must retain the above copyright 47 1.1 joff * notice, this list of conditions and the following disclaimer. 48 1.1 joff * 2. Redistributions in binary form must reproduce the above copyright 49 1.1 joff * notice, this list of conditions and the following disclaimer in the 50 1.1 joff * documentation and/or other materials provided with the distribution. 51 1.1 joff * 3. Neither the name of the University nor the names of its contributors 52 1.1 joff * may be used to endorse or promote products derived from this software 53 1.1 joff * without specific prior written permission. 54 1.1 joff * 55 1.1 joff * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 56 1.1 joff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 57 1.1 joff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 58 1.1 joff * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 59 1.1 joff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 60 1.1 joff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 61 1.1 joff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 62 1.1 joff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 63 1.1 joff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 64 1.1 joff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 65 1.1 joff * SUCH DAMAGE. 66 1.1 joff * 67 1.1 joff * @(#)isa.c 7.2 (Berkeley) 5/13/91 68 1.1 joff */ 69 1.1 joff 70 1.1 joff #include <sys/cdefs.h> 71 1.14 thorpej __KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.14 2023/12/20 13:55:18 thorpej Exp $"); 72 1.1 joff 73 1.1 joff #include "opt_irqstats.h" 74 1.1 joff 75 1.1 joff #include <sys/param.h> 76 1.1 joff #include <sys/systm.h> 77 1.1 joff #include <sys/kernel.h> 78 1.1 joff #include <sys/syslog.h> 79 1.1 joff #include <sys/device.h> 80 1.1 joff #include <sys/proc.h> 81 1.1 joff 82 1.11 dyoung #include <sys/bus.h> 83 1.1 joff 84 1.1 joff #include <machine/intr.h> 85 1.1 joff #include <machine/pio.h> 86 1.1 joff #include <machine/bootconfig.h> 87 1.1 joff #include <machine/isa_machdep.h> 88 1.1 joff 89 1.1 joff #include <dev/isa/isareg.h> 90 1.1 joff #include <dev/isa/isavar.h> 91 1.1 joff 92 1.1 joff #include <arm/ep93xx/ep93xxvar.h> 93 1.1 joff #include <uvm/uvm_extern.h> 94 1.1 joff 95 1.1 joff /* prototypes */ 96 1.1 joff void isa_tsarm_init(u_int, u_int); 97 1.1 joff struct arm32_isa_chipset isa_chipset_tag; 98 1.1 joff 99 1.1 joff static unsigned int ep93xxirq[3] = { 20, 33, 40 }; 100 1.1 joff /* only have 3 irqs connected to real lines on TS-7xxx */ 101 1.1 joff static unsigned int isairq[3] = { 5, 6, 7 }; 102 1.1 joff static unsigned int isairq_nhandlers[3] = { 0, 0, 0 }; 103 1.1 joff 104 1.1 joff int 105 1.6 dsl isa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq) 106 1.1 joff { 107 1.1 joff int i, bestirq, count; 108 1.1 joff 109 1.1 joff if (type == IST_NONE) 110 1.1 joff panic("intr_alloc: bogus type"); 111 1.1 joff 112 1.1 joff bestirq = -1; 113 1.1 joff count = -1; 114 1.1 joff 115 1.1 joff /* some interrupts should never be dynamically allocated */ 116 1.2 joff mask &= 0x00e0; 117 1.1 joff 118 1.13 skrll for (i = 0; i < __arraycount(isairq); i++) { 119 1.1 joff if ((mask & (1<<isairq[i])) == 0) 120 1.1 joff continue; 121 1.1 joff if (isairq_nhandlers[i] < count || count == -1) { 122 1.1 joff bestirq = isairq[i]; 123 1.1 joff count = isairq_nhandlers[i]; 124 1.1 joff } 125 1.1 joff } 126 1.1 joff 127 1.1 joff if (bestirq == -1) 128 1.1 joff return (1); 129 1.1 joff 130 1.1 joff *irq = bestirq; 131 1.1 joff 132 1.1 joff return (0); 133 1.1 joff } 134 1.1 joff 135 1.1 joff const struct evcnt * 136 1.1 joff isa_intr_evcnt(isa_chipset_tag_t ic, int irq) 137 1.1 joff { 138 1.1 joff return NULL; 139 1.1 joff } 140 1.1 joff 141 1.1 joff /* 142 1.1 joff * Set up an interrupt handler to start being called. 143 1.1 joff */ 144 1.1 joff void * 145 1.8 dsl isa_intr_establish(isa_chipset_tag_t ic, int irq, int type, int level, int (*ih_fun)(void *), void *ih_arg) 146 1.1 joff { 147 1.1 joff int epirq = -1, i; 148 1.1 joff /* Find real EP93XX irq number */ 149 1.13 skrll for(i = 0; i < __arraycount(isairq); i++) { 150 1.1 joff if (irq == isairq[i]) epirq = ep93xxirq[i]; 151 1.1 joff } 152 1.1 joff 153 1.1 joff if (epirq == -1) 154 1.1 joff return NULL; 155 1.1 joff else 156 1.1 joff return (ep93xx_intr_establish(epirq, level, ih_fun, ih_arg)); 157 1.1 joff } 158 1.1 joff 159 1.1 joff /* 160 1.1 joff * Deregister an interrupt handler. 161 1.1 joff */ 162 1.1 joff void 163 1.6 dsl isa_intr_disestablish(isa_chipset_tag_t ic, void *arg) 164 1.1 joff { 165 1.1 joff ep93xx_intr_disestablish(arg); 166 1.1 joff } 167 1.1 joff 168 1.1 joff void 169 1.7 dsl isa_tsarm_init(u_int iobase16, u_int membase16) 170 1.1 joff { 171 1.1 joff isa_io_init(iobase16, membase16); 172 1.1 joff } 173 1.1 joff 174 1.1 joff 175 1.1 joff /* 176 1.1 joff * isa_intr_init() 177 1.1 joff * 178 1.1 joff * TODO: Set up ISA IRQ 5 on GPIO pin 179 1.1 joff */ 180 1.1 joff void 181 1.1 joff isa_intr_init(void) 182 1.1 joff { 183 1.1 joff } 184 1.1 joff 185 1.1 joff void 186 1.12 chs isa_attach_hook(device_t parent, device_t self, struct isabus_attach_args *iba) 187 1.1 joff { 188 1.1 joff /* 189 1.1 joff * Since we can only have one ISA bus, we just use a single 190 1.1 joff * statically allocated ISA chipset structure. Pass it up 191 1.1 joff * now. 192 1.1 joff */ 193 1.1 joff iba->iba_ic = &isa_chipset_tag; 194 1.1 joff printf(": PC/104 expansion bus"); 195 1.1 joff } 196 1.9 dyoung 197 1.9 dyoung void 198 1.10 dyoung isa_detach_hook(isa_chipset_tag_t ic, device_t self) 199 1.9 dyoung { 200 1.9 dyoung } 201