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