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