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