Home | History | Annotate | Line # | Download | only in eisa
eisa_machdep.c revision 1.1
      1 /*	$NetBSD: eisa_machdep.c,v 1.1 2006/02/23 19:44:02 garbled Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the NetBSD
     22  *	Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 /*
     41  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
     42  *
     43  * Redistribution and use in source and binary forms, with or without
     44  * modification, are permitted provided that the following conditions
     45  * are met:
     46  * 1. Redistributions of source code must retain the above copyright
     47  *    notice, this list of conditions and the following disclaimer.
     48  * 2. Redistributions in binary form must reproduce the above copyright
     49  *    notice, this list of conditions and the following disclaimer in the
     50  *    documentation and/or other materials provided with the distribution.
     51  * 3. All advertising materials mentioning features or use of this software
     52  *    must display the following acknowledgement:
     53  *      This product includes software developed by Christopher G. Demetriou
     54  *	for the NetBSD Project.
     55  * 4. The name of the author may not be used to endorse or promote products
     56  *    derived from this software without specific prior written permission
     57  *
     58  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     59  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     60  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     61  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     62  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     63  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     64  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     65  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     66  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     67  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     68  */
     69 
     70 /*
     71  * Machine-specific functions for EISA autoconfiguration.
     72  */
     73 
     74 #include <sys/cdefs.h>
     75 __KERNEL_RCSID(0, "$NetBSD: eisa_machdep.c,v 1.1 2006/02/23 19:44:02 garbled Exp $");
     76 
     77 #include <sys/types.h>
     78 #include <sys/param.h>
     79 #include <sys/time.h>
     80 #include <sys/systm.h>
     81 #include <sys/errno.h>
     82 #include <sys/device.h>
     83 #include <sys/extent.h>
     84 
     85 #define _POWERPC_BUS_DMA_PRIVATE
     86 #include <machine/bus.h>
     87 #include <machine/pio.h>
     88 #include <machine/intr.h>
     89 
     90 #include <dev/isa/isareg.h>
     91 #include <dev/isa/isavar.h>
     92 #include <dev/eisa/eisavar.h>
     93 
     94 /*
     95  * EISA doesn't have any special needs; just use the generic versions
     96  * of these funcions.
     97  */
     98 struct powerpc_bus_dma_tag eisa_bus_dma_tag = {
     99 	0,			/* _bounce_thresh */
    100 	_bus_dmamap_create,
    101 	_bus_dmamap_destroy,
    102 	_bus_dmamap_load,
    103 	_bus_dmamap_load_mbuf,
    104 	_bus_dmamap_load_uio,
    105 	_bus_dmamap_load_raw,
    106 	_bus_dmamap_unload,
    107 	NULL,			/* _dmamap_sync */
    108 	_bus_dmamem_alloc,
    109 	_bus_dmamem_free,
    110 	_bus_dmamem_map,
    111 	_bus_dmamem_unmap,
    112 	_bus_dmamem_mmap,
    113 };
    114 
    115 void
    116 eisa_attach_hook(struct device *parent, struct device *self,
    117     struct eisabus_attach_args *eba)
    118 {
    119 	/* Nothing to do. */
    120 }
    121 
    122 int
    123 eisa_maxslots(eisa_chipset_tag_t ec)
    124 {
    125 
    126 	/*
    127 	 * Always try 16 slots.
    128 	 */
    129 	return (16);
    130 }
    131 
    132 int
    133 eisa_intr_map(eisa_chipset_tag_t ec, u_int irq, eisa_intr_handle_t *ihp)
    134 {
    135 	if (irq >= I8259_INTR_NUM) {
    136 		printf("eisa_intr_map: bad IRQ %d\n", irq);
    137 		*ihp = -1;
    138 		return 1;
    139 	}
    140 	if (irq == 2) {
    141 		printf("eisa_intr_map: changed IRQ 2 to IRQ 9\n");
    142 		irq = 9;
    143 	}
    144 
    145 	*ihp = irq;
    146 	return 0;
    147 }
    148 
    149 const char *
    150 eisa_intr_string(eisa_chipset_tag_t ec, eisa_intr_handle_t ih)
    151 {
    152 	static char irqstr[8];		/* 4 + 2 + NULL + sanity */
    153 
    154 	if (ih == 0 || (ih & 0xff) >= I8259_INTR_NUM || ih == 2)
    155 		panic("eisa_intr_string: bogus handle 0x%x", ih);
    156 
    157 	snprintf(irqstr, sizeof(irqstr), "irq %d", ih);
    158 	return (irqstr);
    159 
    160 }
    161 
    162 const struct evcnt *
    163 eisa_intr_evcnt(eisa_chipset_tag_t ec, eisa_intr_handle_t ih)
    164 {
    165 
    166 	/* XXX for now, no evcnt parent reported */
    167 	return NULL;
    168 }
    169 
    170 void *
    171 eisa_intr_establish(eisa_chipset_tag_t ec, eisa_intr_handle_t ih,
    172     int type, int level, int (*func)(void *), void *arg)
    173 {
    174 	int irq;
    175 
    176 	irq = ih;
    177 	return (void *)intr_establish(irq, type, level, func, arg);
    178 }
    179 
    180 void
    181 eisa_intr_disestablish(eisa_chipset_tag_t ec, void *cookie)
    182 {
    183 
    184 	intr_disestablish(cookie);
    185 }
    186 
    187 int
    188 eisa_conf_read_mem(eisa_chipset_tag_t ec, int slot, int func, int entry,
    189     struct eisa_cfg_mem *ecm)
    190 {
    191 
    192 	/* XXX XXX XXX */
    193 	return (ENOENT);
    194 }
    195 
    196 int
    197 eisa_conf_read_irq(eisa_chipset_tag_t ec, int slot, int func, int entry,
    198     struct eisa_cfg_irq *eci)
    199 {
    200 
    201 	/* XXX XXX XXX */
    202 	return (ENOENT);
    203 }
    204 
    205 int
    206 eisa_conf_read_dma(eisa_chipset_tag_t ec, int slot, int func, int entry,
    207     struct eisa_cfg_dma *ecd)
    208 {
    209 
    210 	/* XXX XXX XXX */
    211 	return (ENOENT);
    212 }
    213 
    214 int
    215 eisa_conf_read_io(eisa_chipset_tag_t ec, int slot, int func, int entry,
    216     struct eisa_cfg_io *ecio)
    217 {
    218 
    219 	/* XXX XXX XXX */
    220 	return (ENOENT);
    221 }
    222