Home | History | Annotate | Line # | Download | only in mvme
mvmebus.h revision 1.2
      1 /*	$NetBSD: mvmebus.h,v 1.2 2007/03/04 06:02:15 christos Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2000, 2002 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Steve C. Woodford.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #ifndef _MVME_MVMEBUS_H
     40 #define _MVME_MVMEBUS_H
     41 
     42 /*
     43  * VMEbus master and slave windows are described using
     44  * instances of this structure.
     45  *
     46  * The chip-specific code records the details of the available mappings
     47  * for the MVME board.
     48  */
     49 struct mvmebus_range {
     50 	vme_am_t	vr_am;		/* Address modifier (A16, A24, A32) */
     51 	vme_datasize_t	vr_datasize;	/* Datasize: logical OR of D8,D16,D32 */
     52 	paddr_t		vr_locstart;	/* CPU-relative address of mapping */
     53 	paddr_t		vr_mask;	/* Mask to apply to this mapping */
     54 	vme_addr_t	vr_vmestart;	/* VMEbus start address */
     55 	vme_addr_t	vr_vmeend;	/* VMEbus end address */
     56 };
     57 
     58 /* Assigned to vr_am to specify the mapping is not valid */
     59 #define MVMEBUS_AM_DISABLED	((vme_am_t)-1)
     60 
     61 /* For slave mappings, these specify the slave's capabilities */
     62 #define MVMEBUS_AM_CAP_DATA	0x0100
     63 #define MVMEBUS_AM_CAP_PROG	0x0200
     64 #define MVMEBUS_AM_CAP_BLK	0x0400
     65 #define MVMEBUS_AM_CAP_BLKD64	0x0800
     66 #define MVMEBUS_AM_CAP_USER	0x1000
     67 #define MVMEBUS_AM_CAP_SUPER	0x2000
     68 #define MVMEBUS_AM_HAS_CAP(x)	(((x) & 0x3f00) != 0)
     69 
     70 #define MVMEBUS_AM2CAP(am)	(_mvmebus_am_cap[((am) & \
     71 				    (VME_AM_MODEMASK | VME_AM_PRIVMASK))])
     72 
     73 
     74 /*
     75  * This records VMEbus-specific details of a region of bus_space_map'd
     76  * VMEbus address space.
     77  */
     78 struct mvmebus_mapresc {
     79 	bus_space_handle_t	mr_handle;
     80 	bus_addr_t		mr_addr;
     81 	bus_size_t		mr_size;
     82 	vme_am_t		mr_am;
     83 	vme_datasize_t		mr_datasize;
     84 	int			mr_range;
     85 };
     86 
     87 
     88 /*
     89  * This records the VMEbus-specific details of a region of phyisical
     90  * memory accessible through a VMEbus slave map.
     91  */
     92 struct mvmebus_dmamap {
     93 	vme_am_t		vm_am;
     94 	vme_datasize_t		vm_datasize;
     95 	vme_swap_t		vm_swap;
     96 	struct mvmebus_range	*vm_slave;
     97 };
     98 
     99 
    100 struct mvmebus_softc {
    101 	struct device		sc_dev;
    102 	bus_space_tag_t		sc_bust;
    103 	bus_dma_tag_t		sc_dmat;
    104 	short			sc_irqref[8];
    105 	void			*sc_chip;
    106 	int			sc_nmasters;
    107 	struct mvmebus_range	*sc_masters;
    108 	int			sc_nslaves;
    109 	struct mvmebus_range	*sc_slaves;
    110 	struct evcnt		sc_evcnt[7];
    111 	void			(*sc_intr_establish)(void *, int, int, int, int,
    112 				    int (*)(void *), void *, struct evcnt *);
    113 	void			(*sc_intr_disestablish)(void *, int, int, int,
    114 				    struct evcnt *);
    115 	struct vme_chipset_tag	sc_vct;
    116 	struct mvme68k_bus_dma_tag	sc_mvmedmat;
    117 };
    118 
    119 
    120 void	mvmebus_attach(struct mvmebus_softc *);
    121 int	mvmebus_map(void *, vme_addr_t, vme_size_t, vme_am_t,
    122 	    vme_datasize_t, vme_swap_t, bus_space_tag_t *,
    123 	    bus_space_handle_t *, vme_mapresc_t *);
    124 void	mvmebus_unmap(void *, vme_mapresc_t);
    125 int	mvmebus_probe(void *, vme_addr_t, vme_size_t,
    126 	    vme_am_t, vme_datasize_t,
    127 	    int (*) (void *, bus_space_tag_t, bus_space_handle_t), void *arg);
    128 int	mvmebus_intmap(void *, int, int, vme_intr_handle_t *);
    129 const struct evcnt *mvmebus_intr_evcnt(void *, vme_intr_handle_t);
    130 void *	mvmebus_intr_establish(void *, vme_intr_handle_t, int,
    131 	    int (*) (void *), void *);
    132 void	mvmebus_intr_disestablish(void *, vme_intr_handle_t);
    133 
    134 int	mvmebus_dmamap_create(void *, vme_size_t, vme_am_t, vme_datasize_t,
    135 	    vme_swap_t, int, vme_size_t, vme_addr_t, int, bus_dmamap_t *);
    136 void	mvmebus_dmamap_destroy(void *, bus_dmamap_t);
    137 int	mvmebus_dmamap_load(bus_dma_tag_t, bus_dmamap_t,
    138 	    void *, bus_size_t, struct proc *, int);
    139 int	mvmebus_dmamap_load_mbuf(bus_dma_tag_t,
    140 	    bus_dmamap_t, struct mbuf *, int);
    141 int	mvmebus_dmamap_load_uio(bus_dma_tag_t,
    142 	    bus_dmamap_t, struct uio *, int);
    143 int	mvmebus_dmamap_load_raw(bus_dma_tag_t,
    144 	    bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int);
    145 void	mvmebus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
    146 void	mvmebus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
    147 	    bus_size_t, int);
    148 
    149 int	mvmebus_dmamem_alloc(void *, vme_size_t, vme_am_t, vme_datasize_t,
    150 	    vme_swap_t, bus_dma_segment_t *, int, int *, int);
    151 void	mvmebus_dmamem_free(void *, bus_dma_segment_t *, int);
    152 int	mvmebus_dmamem_map(bus_dma_tag_t, bus_dma_segment_t *, int,
    153 	    size_t, void **, int);
    154 void	mvmebus_dmamem_unmap(bus_dma_tag_t, void *, size_t);
    155 paddr_t	mvmebus_dmamem_mmap(bus_dma_tag_t, bus_dma_segment_t *, int,
    156 	    off_t, int, int);
    157 
    158 extern vme_am_t _mvmebus_am_cap[];
    159 extern const char *mvmebus_irq_name[];
    160 
    161 #endif /* _MVME_MVMEBUS_H */
    162