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