Home | History | Annotate | Line # | Download | only in mvme
      1 /*	$NetBSD: mvmebus.h,v 1.4 2012/10/27 17:18:27 chs 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  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef _MVME_MVMEBUS_H
     33 #define _MVME_MVMEBUS_H
     34 
     35 /*
     36  * VMEbus master and slave windows are described using
     37  * instances of this structure.
     38  *
     39  * The chip-specific code records the details of the available mappings
     40  * for the MVME board.
     41  */
     42 struct mvmebus_range {
     43 	vme_am_t	vr_am;		/* Address modifier (A16, A24, A32) */
     44 	vme_datasize_t	vr_datasize;	/* Datasize: logical OR of D8,D16,D32 */
     45 	paddr_t		vr_locstart;	/* CPU-relative address of mapping */
     46 	paddr_t		vr_mask;	/* Mask to apply to this mapping */
     47 	vme_addr_t	vr_vmestart;	/* VMEbus start address */
     48 	vme_addr_t	vr_vmeend;	/* VMEbus end address */
     49 };
     50 
     51 /* Assigned to vr_am to specify the mapping is not valid */
     52 #define MVMEBUS_AM_DISABLED	((vme_am_t)-1)
     53 
     54 /* For slave mappings, these specify the slave's capabilities */
     55 #define MVMEBUS_AM_CAP_DATA	0x0100
     56 #define MVMEBUS_AM_CAP_PROG	0x0200
     57 #define MVMEBUS_AM_CAP_BLK	0x0400
     58 #define MVMEBUS_AM_CAP_BLKD64	0x0800
     59 #define MVMEBUS_AM_CAP_USER	0x1000
     60 #define MVMEBUS_AM_CAP_SUPER	0x2000
     61 #define MVMEBUS_AM_HAS_CAP(x)	(((x) & 0x3f00) != 0)
     62 
     63 #define MVMEBUS_AM2CAP(am)	(_mvmebus_am_cap[((am) & \
     64 				    (VME_AM_MODEMASK | VME_AM_PRIVMASK))])
     65 
     66 
     67 /*
     68  * This records VMEbus-specific details of a region of bus_space_map'd
     69  * VMEbus address space.
     70  */
     71 struct mvmebus_mapresc {
     72 	bus_space_handle_t	mr_handle;
     73 	bus_addr_t		mr_addr;
     74 	bus_size_t		mr_size;
     75 	vme_am_t		mr_am;
     76 	vme_datasize_t		mr_datasize;
     77 	int			mr_range;
     78 };
     79 
     80 
     81 /*
     82  * This records the VMEbus-specific details of a region of phyisical
     83  * memory accessible through a VMEbus slave map.
     84  */
     85 struct mvmebus_dmamap {
     86 	vme_am_t		vm_am;
     87 	vme_datasize_t		vm_datasize;
     88 	vme_swap_t		vm_swap;
     89 	struct mvmebus_range	*vm_slave;
     90 };
     91 
     92 
     93 struct mvmebus_softc {
     94 	device_t		sc_dev;
     95 	bus_space_tag_t		sc_bust;
     96 	bus_dma_tag_t		sc_dmat;
     97 	short			sc_irqref[8];
     98 	void			*sc_chip;
     99 	int			sc_nmasters;
    100 	struct mvmebus_range	*sc_masters;
    101 	int			sc_nslaves;
    102 	struct mvmebus_range	*sc_slaves;
    103 	struct evcnt		sc_evcnt[7];
    104 	void			(*sc_intr_establish)(void *, int, int, int, int,
    105 				    int (*)(void *), void *, struct evcnt *);
    106 	void			(*sc_intr_disestablish)(void *, int, int, int,
    107 				    struct evcnt *);
    108 	struct vme_chipset_tag	sc_vct;
    109 	struct mvme68k_bus_dma_tag	sc_mvmedmat;
    110 };
    111 
    112 
    113 void	mvmebus_attach(struct mvmebus_softc *);
    114 int	mvmebus_map(void *, vme_addr_t, vme_size_t, vme_am_t,
    115 	    vme_datasize_t, vme_swap_t, bus_space_tag_t *,
    116 	    bus_space_handle_t *, vme_mapresc_t *);
    117 void	mvmebus_unmap(void *, vme_mapresc_t);
    118 int	mvmebus_probe(void *, vme_addr_t, vme_size_t,
    119 	    vme_am_t, vme_datasize_t,
    120 	    int (*) (void *, bus_space_tag_t, bus_space_handle_t), void *arg);
    121 int	mvmebus_intmap(void *, int, int, vme_intr_handle_t *);
    122 const struct evcnt *mvmebus_intr_evcnt(void *, vme_intr_handle_t);
    123 void *	mvmebus_intr_establish(void *, vme_intr_handle_t, int,
    124 	    int (*) (void *), void *);
    125 void	mvmebus_intr_disestablish(void *, vme_intr_handle_t);
    126 
    127 int	mvmebus_dmamap_create(void *, vme_size_t, vme_am_t, vme_datasize_t,
    128 	    vme_swap_t, int, vme_size_t, vme_addr_t, int, bus_dmamap_t *);
    129 void	mvmebus_dmamap_destroy(void *, bus_dmamap_t);
    130 int	mvmebus_dmamap_load(bus_dma_tag_t, bus_dmamap_t,
    131 	    void *, bus_size_t, struct proc *, int);
    132 int	mvmebus_dmamap_load_mbuf(bus_dma_tag_t,
    133 	    bus_dmamap_t, struct mbuf *, int);
    134 int	mvmebus_dmamap_load_uio(bus_dma_tag_t,
    135 	    bus_dmamap_t, struct uio *, int);
    136 int	mvmebus_dmamap_load_raw(bus_dma_tag_t,
    137 	    bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int);
    138 void	mvmebus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
    139 void	mvmebus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
    140 	    bus_size_t, int);
    141 
    142 int	mvmebus_dmamem_alloc(void *, vme_size_t, vme_am_t, vme_datasize_t,
    143 	    vme_swap_t, bus_dma_segment_t *, int, int *, int);
    144 void	mvmebus_dmamem_free(void *, bus_dma_segment_t *, int);
    145 int	mvmebus_dmamem_map(bus_dma_tag_t, bus_dma_segment_t *, int,
    146 	    size_t, void **, int);
    147 void	mvmebus_dmamem_unmap(bus_dma_tag_t, void *, size_t);
    148 paddr_t	mvmebus_dmamem_mmap(bus_dma_tag_t, bus_dma_segment_t *, int,
    149 	    off_t, int, int);
    150 
    151 extern vme_am_t _mvmebus_am_cap[];
    152 extern const char *mvmebus_irq_name[];
    153 
    154 #endif /* _MVME_MVMEBUS_H */
    155